@voicethere/agent 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/build-bundle.d.ts +14 -0
- package/dist/build-bundle.d.ts.map +1 -0
- package/dist/build-bundle.js +25 -0
- package/dist/build-bundle.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -0
- package/dist/cli.js.map +1 -0
- package/package.json +7 -4
- package/templates/README.md +3 -2
- package/templates/agent.ts +1 -1
package/README.md
CHANGED
|
@@ -101,14 +101,15 @@ Copy [`templates/agent.ts`](./templates/agent.ts) as a starting point — exhaus
|
|
|
101
101
|
|
|
102
102
|
## Building your agent bundle
|
|
103
103
|
|
|
104
|
-
**Recommended:**
|
|
104
|
+
**Recommended:** bundle with the package CLI (same esbuild settings VoiceThere uses in production):
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
npm install @voicethere/agent
|
|
108
|
-
npx
|
|
107
|
+
npm install @voicethere/agent
|
|
108
|
+
npx @voicethere/agent build
|
|
109
|
+
# or: npx @voicethere/agent build --entry src/agent.ts --outfile dist/agent.js
|
|
109
110
|
```
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
Defaults: entry `agent.ts`, output `dist/agent.js`. Upload the bundle (or point `AGENT_BUNDLE_PATH` at it locally). Inlining dependencies avoids runtime `node_modules` resolution inside the sandbox.
|
|
112
113
|
|
|
113
114
|
## Sandbox and security model
|
|
114
115
|
|
|
@@ -227,7 +228,9 @@ Prefer **one esbuild bundle** so production behavior matches `npm run verify:loc
|
|
|
227
228
|
## Scripts
|
|
228
229
|
|
|
229
230
|
```bash
|
|
230
|
-
npm run build #
|
|
231
|
+
npm run build # compile SDK + example bundle (repo dev)
|
|
232
|
+
npm run build:lib # compile SDK only (tsc → dist/)
|
|
233
|
+
npx @voicethere/agent build # customer project: bundle agent.ts → dist/agent.js
|
|
231
234
|
npm run verify:local # sandbox smoke (build + fork bundle)
|
|
232
235
|
npm run test:ci # typecheck + vitest
|
|
233
236
|
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as esbuild from "esbuild";
|
|
2
|
+
export interface BuildAgentBundleOptions {
|
|
3
|
+
/** Agent source entry (TypeScript or JavaScript). */
|
|
4
|
+
entry: string;
|
|
5
|
+
/** Output bundle path (typically `dist/agent.js`). */
|
|
6
|
+
outfile: string;
|
|
7
|
+
/** Working directory for relative paths. Defaults to `process.cwd()`. */
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Bundle customer agent source into a single ESM file for the sandboxed child.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildAgentBundle(options: BuildAgentBundleOptions): Promise<esbuild.BuildResult>;
|
|
14
|
+
//# sourceMappingURL=build-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-bundle.d.ts","sourceRoot":"","sources":["../src/build-bundle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAoB9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import * as esbuild from "esbuild";
|
|
4
|
+
/**
|
|
5
|
+
* Bundle customer agent source into a single ESM file for the sandboxed child.
|
|
6
|
+
*/
|
|
7
|
+
export async function buildAgentBundle(options) {
|
|
8
|
+
const cwd = options.cwd ?? process.cwd();
|
|
9
|
+
const entry = resolve(cwd, options.entry);
|
|
10
|
+
const outfile = resolve(cwd, options.outfile);
|
|
11
|
+
if (!existsSync(entry)) {
|
|
12
|
+
throw new Error(`Entry not found: ${entry}`);
|
|
13
|
+
}
|
|
14
|
+
mkdirSync(dirname(outfile), { recursive: true });
|
|
15
|
+
return esbuild.build({
|
|
16
|
+
entryPoints: [entry],
|
|
17
|
+
bundle: true,
|
|
18
|
+
platform: "node",
|
|
19
|
+
format: "esm",
|
|
20
|
+
outfile,
|
|
21
|
+
target: "node22",
|
|
22
|
+
logLevel: "warning",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=build-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-bundle.js","sourceRoot":"","sources":["../src/build-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAWnC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgC;IAEhC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9C,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjD,OAAO,OAAO,CAAC,KAAK,CAAC;QACnB,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;QACb,OAAO;QACP,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,SAAS;KACpB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Customer-facing CLI — bundle agent source for the VoiceThere sandbox.
|
|
4
|
+
*
|
|
5
|
+
* npx @voicethere/agent build
|
|
6
|
+
* npx @voicethere/agent build --entry agent.ts --outfile dist/agent.js
|
|
7
|
+
*/
|
|
8
|
+
import { buildAgentBundle } from "./build-bundle.js";
|
|
9
|
+
const DEFAULT_ENTRY = "agent.ts";
|
|
10
|
+
const DEFAULT_OUTFILE = "dist/agent.js";
|
|
11
|
+
function printHelp() {
|
|
12
|
+
process.stdout.write(`@voicethere/agent — bundle your voice agent for VoiceThere
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
npx @voicethere/agent build [options]
|
|
16
|
+
npx @voicethere/agent [options] (build is the default command)
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--entry, -e <path> Agent entry file (default: ${DEFAULT_ENTRY})
|
|
20
|
+
--outfile, -o <path> Output bundle (default: ${DEFAULT_OUTFILE})
|
|
21
|
+
--help, -h Show this help
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
npm install @voicethere/agent
|
|
25
|
+
npx @voicethere/agent build --entry src/agent.ts --outfile dist/agent.js
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
function parseBuildArgs(argv) {
|
|
29
|
+
let entry = DEFAULT_ENTRY;
|
|
30
|
+
let outfile = DEFAULT_OUTFILE;
|
|
31
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
32
|
+
const arg = argv[i];
|
|
33
|
+
if (arg === "--help" || arg === "-h") {
|
|
34
|
+
printHelp();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
if (arg === "--entry" || arg === "-e") {
|
|
38
|
+
const value = argv[i + 1];
|
|
39
|
+
if (!value) {
|
|
40
|
+
throw new Error(`${arg} requires a path`);
|
|
41
|
+
}
|
|
42
|
+
entry = value;
|
|
43
|
+
i += 1;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg === "--outfile" || arg === "-o") {
|
|
47
|
+
const value = argv[i + 1];
|
|
48
|
+
if (!value) {
|
|
49
|
+
throw new Error(`${arg} requires a path`);
|
|
50
|
+
}
|
|
51
|
+
outfile = value;
|
|
52
|
+
i += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
56
|
+
}
|
|
57
|
+
return { entry, outfile };
|
|
58
|
+
}
|
|
59
|
+
async function runBuild(argv) {
|
|
60
|
+
const { entry, outfile } = parseBuildArgs(argv);
|
|
61
|
+
await buildAgentBundle({ entry, outfile });
|
|
62
|
+
process.stdout.write(`Built ${outfile} from ${entry}\n`);
|
|
63
|
+
}
|
|
64
|
+
async function main() {
|
|
65
|
+
const args = process.argv.slice(2);
|
|
66
|
+
if (args.length === 0) {
|
|
67
|
+
await runBuild([]);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (args[0] === "help" || args[0] === "--help" || args[0] === "-h") {
|
|
71
|
+
printHelp();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (args[0] === "build") {
|
|
75
|
+
await runBuild(args.slice(1));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (args[0]?.startsWith("-")) {
|
|
79
|
+
await runBuild(args);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
process.stderr.write(`Unknown command: ${args[0]}\n\n`);
|
|
83
|
+
printHelp();
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
main().catch((error) => {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
process.stderr.write(`agent build failed: ${message}\n`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,SAAS,SAAS;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;sDAO+B,aAAa;mDAChB,eAAe;;;;;;CAMjE,CAAC,CAAC;AACH,CAAC;AAOD,SAAS,cAAc,CAAC,IAAc;IACpC,IAAI,KAAK,GAAG,aAAa,CAAC;IAC1B,IAAI,OAAO,GAAG,eAAe,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACrC,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtC,MAAM,KAAK,GAA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AC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACnE,SAAS,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxD,SAAS,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,OAAO,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicethere/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
"import": "./dist/index.js"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
+
"bin": "./dist/cli.js",
|
|
12
13
|
"files": [
|
|
13
14
|
"dist",
|
|
14
15
|
"templates",
|
|
15
16
|
"README.md"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
|
-
"build": "tsc -p tsconfig.json
|
|
19
|
+
"build:lib": "tsc -p tsconfig.json",
|
|
20
|
+
"build:example": "node dist/cli.js build --entry examples/agent.ts --outfile dist/agent.js",
|
|
21
|
+
"build": "npm run build:lib && npm run build:example",
|
|
19
22
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
20
23
|
"test": "vitest run",
|
|
21
24
|
"test:ci": "npm run typecheck && npm run build && npm run test",
|
|
@@ -45,14 +48,14 @@
|
|
|
45
48
|
},
|
|
46
49
|
"license": "UNLICENSED",
|
|
47
50
|
"dependencies": {
|
|
48
|
-
"@node-webrtc-rust/sdk": "0.5.2"
|
|
51
|
+
"@node-webrtc-rust/sdk": "0.5.2",
|
|
52
|
+
"esbuild": "^0.25.12"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
51
55
|
"@node-webrtc-rust/sdk": ">=0.5.2"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@types/node": "^22.10.0",
|
|
55
|
-
"esbuild": "^0.25.12",
|
|
56
59
|
"tsx": "^4.19.2",
|
|
57
60
|
"typescript": "^5.7.0",
|
|
58
61
|
"vitest": "^2.1.8"
|
package/templates/README.md
CHANGED
|
@@ -17,8 +17,9 @@ Full starter bundle covering every speech event from `@node-webrtc-rust/sdk/voic
|
|
|
17
17
|
**Build:**
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @voicethere/agent
|
|
21
|
-
npx
|
|
20
|
+
npm install @voicethere/agent
|
|
21
|
+
npx @voicethere/agent build
|
|
22
|
+
# optional: --entry agent.ts --outfile dist/agent.js
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
**Verify sandbox (no WebRTC):** from the agent repo, `npm run verify:local` after building your bundle.
|
package/templates/agent.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Build:
|
|
8
8
|
* npm install @voicethere/agent
|
|
9
|
-
* npx
|
|
9
|
+
* npx @voicethere/agent build
|
|
10
10
|
*
|
|
11
11
|
* Voice E2E (VoiceThere agent runner — platform or internal deployment):
|
|
12
12
|
* AGENT_BUNDLE_PATH=./dist/agent.js npm run start
|