Registry / llm-agents / thingtalk

thingtalk

JSON →
library2.1.1jsnpmunverified

ThingTalk is a declarative, rule-based distributed programming language for virtual assistants, developed by Stanford Open Virtual Assistant Lab. This package (v2.1.1, not semver: minor bumps can break library APIs) provides the grammar, just-in-time compiler, interface for SMT-based program analysis, natural language translation, and runtime libraries. It connects web services and IoT devices via 'when-get-do' statements, leveraging Thingpedia API primitives. Differentiators: unique focus on virtual assistants, crowdsourced API repository, and non-semver versioning where minor versions may introduce breaking API changes. Release cadence: irregular, with major version bumps for language incompatibility, minor for library changes, patch for bug fixes.

npm install thingtalk
INSTALL
IMPORT
SIG · THINGTALK
T
thingtalk
llm-agentsjavascriptv2.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'thingtalk'
const compile = require('thingtalk').compile;
ESM only since v2; no default export
Grammar
import { Grammar } from 'thingtalk'
import Grammar from 'thingtalk';
Grammar is a named export, not default
Ast
import type { Ast } from 'thingtalk'
import { Ast } from 'thingtalk';
Ast is a type; use 'import type' in TypeScript to avoid runtime import

Compiles a ThingTalk program that monitors Washington Post articles, translates to Chinese, and posts to Facebook.

import { compile } from 'thingtalk'; const code = ` monitor(@com.washingtonpost.get_article(section=enum world)) => @com.yandex.translate.translate(target_language="zh", text=title) => @com.facebook.post(status=$result); `; try { const compiled = compile(code, { locale: 'en-US', timezone: 'America/Los_Angeles' }); console.log('Compiled program:', JSON.stringify(compiled, null, 2)); } catch (err) { console.error('Compilation failed:', err); }
thingtalk --version
Debug
Known issues
breakingMinor version bumps can break library APIs. Use tilde version ranges.
fix
Specify dependency as "thingtalk": "~2.1.0" in package.json to allow only patch updates.
affects: >=2.0
gotchaNo default export; all exports are named.
fix
Use named imports like `import { compile } from 'thingtalk'` instead of `import compile from 'thingtalk'`.
affects: >=2.0
deprecatedThe `translate` function has been deprecated in favor of `compileWithTranslation`.
fix
Use `compileWithTranslation` instead.
affects: >=2.0.0 <2.2
gotchaThingTalk syntax generated by a newer version may not parse with an older client. Specify library version for compatibility.
fix
Pass `{ libraryVersion: '2.1.0' }` in options when compiling for older clients.
affects: >=2.0
Errors
Common errors & fixes
SyntaxError: Unexpected token
Invalid ThingTalk syntax, possibly due to missing semicolons or wrong invocation syntax.
fix
Ensure each statement ends with a semicolon and uses correct triple arrow syntax: `=> @service.function(params)`. Refer to ThingTalk language specification.
Error: Cannot find module 'thingtalk'
Missing dependency or incorrect import path in CommonJS project.
fix
Run `npm install thingtalk` and use `import { compile } from 'thingtalk'` (ESM) or ensure your bundler supports ESM. For CommonJS, use dynamic import: `const { compile } = await import('thingtalk')`.
TypeError: compile is not a function
Importing default export instead of named export.
fix
Replace `import compile from 'thingtalk'` with `import { compile } from 'thingtalk'`.
ThingTalk version mismatch: expected 2.1.x, got 2.2.0
Generating syntax with a newer library version that is incompatible with the client version specified.
fix
Pass `{ libraryVersion: '2.1.0' }` in the compile options to output syntax compatible with the older client.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
genie-toolkitoptionalrequired to run ThingTalk programs in a full virtual assistant runtime
Agent activity
35 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
thingtalk — npm install thingtalk · libregistry