@voicethere/agent 0.1.0 → 0.1.1
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 +24 -30
- package/dist/protocol.d.ts +1 -1
- package/dist/protocol.js +1 -1
- package/package.json +1 -1
- package/templates/README.md +1 -1
- package/templates/agent.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @voicethere/agent
|
|
2
2
|
|
|
3
|
-
VoiceThere **customer agent SDK** — TypeScript types and runtime helpers for sandboxed child bundles running inside
|
|
3
|
+
VoiceThere **customer agent SDK** — TypeScript types and runtime helpers for sandboxed child bundles running inside the **VoiceThere agent runner** (session worker).
|
|
4
4
|
|
|
5
5
|
**npm:** `@voicethere/agent`
|
|
6
6
|
**Repo:** [`voicethere/agent`](https://github.com/voicethere/agent)
|
|
@@ -9,7 +9,7 @@ VoiceThere **customer agent SDK** — TypeScript types and runtime helpers for s
|
|
|
9
9
|
|
|
10
10
|
| Layer | Package | Runs in |
|
|
11
11
|
| --------- | ----------------------------------------------------------- | ------------------------------------ |
|
|
12
|
-
| Parent |
|
|
12
|
+
| Parent | VoiceThere agent runner | Trusted Node + WebRTC + speech stack |
|
|
13
13
|
| **Child** | **`@voicethere/agent`** | Sandboxed customer `agent.js` bundle |
|
|
14
14
|
|
|
15
15
|
The child receives speech lifecycle events over IPC (same shapes as `@node-webrtc-rust/sdk/voice`) and calls `speak()` to request TTS from the parent.
|
|
@@ -23,11 +23,10 @@ npm install
|
|
|
23
23
|
npm run build
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
**Voice E2E:** deploy to the VoiceThere platform or run against your organization's internal agent runner. With a local runner checkout, point it at your bundle:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
|
|
30
|
-
AGENT_BUNDLE_PATH=../agent/dist/agent.js npm run start
|
|
29
|
+
AGENT_BUNDLE_PATH=/path/to/dist/agent.js npm run start
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
Open the runner URL in a browser, connect, and speak.
|
|
@@ -45,9 +44,9 @@ npm run verify:local
|
|
|
45
44
|
| `npm run verify:local` | **Default** — `npm run build`, then fork `dist/agent.js` in the sandbox and assert a `speak` reply to `user_speech_final` |
|
|
46
45
|
| `npm run verify:local:only` | Re-run smoke after build; optional `AGENT_BUNDLE_PATH=./dist/agent.js` or `--bundle <path>` |
|
|
47
46
|
|
|
48
|
-
This checks bundle load, IPC, and Node permission flags. It does **not** replace a voice roundtrip — use
|
|
47
|
+
This checks bundle load, IPC, and Node permission flags. It does **not** replace a voice roundtrip — use the VoiceThere agent runner (platform or internal deployment) for mic/WebRTC E2E.
|
|
49
48
|
|
|
50
|
-
Harness: [`scripts/sandbox/`](./scripts/sandbox/) (aligned with
|
|
49
|
+
Harness: [`scripts/sandbox/`](./scripts/sandbox/) (aligned with the agent runner child launcher).
|
|
51
50
|
|
|
52
51
|
## API
|
|
53
52
|
|
|
@@ -82,7 +81,7 @@ defineAgent({
|
|
|
82
81
|
| `SPEECH_EVENT_TYPE` | Import from `@node-webrtc-rust/sdk/voice` (runtime constants; not bundled into child) |
|
|
83
82
|
| `speak` | Request parent TTS |
|
|
84
83
|
| `agentLog` | Forward structured logs to parent |
|
|
85
|
-
| `ParentToChildMessage` / `ChildToParentMessage` | IPC contract shared with
|
|
84
|
+
| `ParentToChildMessage` / `ChildToParentMessage` | IPC contract shared with the VoiceThere agent runner |
|
|
86
85
|
|
|
87
86
|
### Speech events (parent → child)
|
|
88
87
|
|
|
@@ -113,20 +112,17 @@ Upload `dist/agent.js` (or point `AGENT_BUNDLE_PATH` at it locally). Inlining de
|
|
|
113
112
|
|
|
114
113
|
## Sandbox and security model
|
|
115
114
|
|
|
116
|
-
Customer code runs in a **forked child process**, separate from the trusted runner parent (
|
|
115
|
+
Customer code runs in a **forked child process**, separate from the trusted agent runner parent (WebRTC, speech stack, TTS). Security is layered:
|
|
117
116
|
|
|
118
117
|
```text
|
|
119
118
|
┌──────────────────────────────────────────────────────────────┐
|
|
120
|
-
│
|
|
119
|
+
│ Agent runner parent (trusted) — WebRTC, speech stack, TTS │
|
|
121
120
|
│ fork(loader-entry.js, execArgv: [--permission, …]) │
|
|
122
121
|
│ │ IPC (process.send / on('message')) │
|
|
123
122
|
│ ▼ │
|
|
124
123
|
│ Customer child — Node Permission Model + stripped env │
|
|
125
124
|
│ loader-entry.js → import(your agent.js) │
|
|
126
125
|
└──────────────────────────────────────────────────────────────┘
|
|
127
|
-
│ same pod network namespace (K8s)
|
|
128
|
-
▼
|
|
129
|
-
Cilium NetworkPolicy on runner pod (egress rules)
|
|
130
126
|
```
|
|
131
127
|
|
|
132
128
|
### Layer 1 — Process isolation
|
|
@@ -134,9 +130,9 @@ Customer code runs in a **forked child process**, separate from the trusted runn
|
|
|
134
130
|
| Mechanism | What it means for your bundle |
|
|
135
131
|
| --------- | ----------------------------- |
|
|
136
132
|
| **Separate process** | Crash or `process.exit` in your bundle does not take down the parent voice stack |
|
|
137
|
-
| **IPC only** |
|
|
138
|
-
| **Stripped `process.env`** | Child receives only `NODE_ENV`, internal loader path, and allowlisted keys (`SESSION_ID`, `PROJECT_ID`, `BUILD_ID`) — not parent
|
|
139
|
-
| **Console redirection** | `console.log` / `warn` / `error` → IPC logs
|
|
133
|
+
| **IPC only for media** | WebRTC, mic, STT, and TTS go through the parent — use `defineAgent`, `speak`, and speech events |
|
|
134
|
+
| **Stripped `process.env`** | Child receives only `NODE_ENV`, internal loader path, and allowlisted keys (`SESSION_ID`, `PROJECT_ID`, `BUILD_ID`) — not parent secrets |
|
|
135
|
+
| **Console redirection** | `console.log` / `warn` / `error` → IPC logs |
|
|
140
136
|
|
|
141
137
|
### Layer 2 — Node `--permission` (runtime-enforced)
|
|
142
138
|
|
|
@@ -147,7 +143,7 @@ The parent starts the child with Node’s [Permission Model](https://nodejs.org/
|
|
|
147
143
|
| Flag | Effect |
|
|
148
144
|
| ---- | ------ |
|
|
149
145
|
| `--permission` | Enables restriction mode |
|
|
150
|
-
| `--allow-fs-read=<loaderDir>` | Read files under the
|
|
146
|
+
| `--allow-fs-read=<loaderDir>` | Read files under the child loader directory |
|
|
151
147
|
| `--allow-fs-read=<bundleParentDir>` | Read files under the **directory containing your `agent.js`** (see below) |
|
|
152
148
|
|
|
153
149
|
**Not granted → blocked at runtime:**
|
|
@@ -163,6 +159,8 @@ The parent starts the child with Node’s [Permission Model](https://nodejs.org/
|
|
|
163
159
|
|
|
164
160
|
This is **not** an import allowlist — Node gates **capability classes**, not package names. Using `node:fs` inside the allowed read tree can work; using it on `/etc/passwd` does not.
|
|
165
161
|
|
|
162
|
+
**Network is not gated by `--permission`.** `fetch`, `http`, `https`, and other outbound calls use the same network namespace as the parent. On VoiceThere-hosted sessions, **public internet egress is allowed** (e.g. calling your LLM or tool APIs). **Private cluster / internal platform addresses are not reachable** from the child — use the parent IPC surface for voice, not in-cluster services.
|
|
163
|
+
|
|
166
164
|
### Bundle directory vs single file
|
|
167
165
|
|
|
168
166
|
`--allow-fs-read` is applied to **`dirname(bundlePath)`**, not only the `.js` file:
|
|
@@ -185,26 +183,21 @@ This is **not** an import allowlist — Node gates **capability classes**, not p
|
|
|
185
183
|
|
|
186
184
|
Prefer **one esbuild bundle** so production behavior matches `npm run verify:local`.
|
|
187
185
|
|
|
188
|
-
### Layer 3 — Platform policy
|
|
189
|
-
|
|
190
|
-
These are **unsupported** in customer bundles even if Node might not block them today:
|
|
186
|
+
### Layer 3 — Platform policy
|
|
191
187
|
|
|
192
|
-
| Capability |
|
|
193
|
-
| ---------- |
|
|
194
|
-
| **Outbound network** (`fetch`, `http`, `
|
|
188
|
+
| Capability | Behavior |
|
|
189
|
+
| ---------- | -------- |
|
|
190
|
+
| **Outbound network** (`fetch`, `http`, `https`) | **Public internet:** allowed — typical for LLM/tool calls from your agent code. **Internal platform / private network:** blocked on hosted sessions. |
|
|
195
191
|
| **`process.exit`** | Not blocked — kills your agent leg; parent may play crash TTS |
|
|
196
192
|
| **Direct WebRTC / mic / STT / TTS** | Parent only — use `speak()` and speech event handlers |
|
|
197
193
|
|
|
198
|
-
### Layer 4 — Kubernetes (runner pod)
|
|
199
|
-
|
|
200
|
-
On cluster deploy, the runner pod also has Helm hardening (non-root, read-only rootfs, dropped caps) and **NetworkPolicy** for egress. That applies to the whole pod (parent + child).
|
|
201
|
-
|
|
202
194
|
### What you should use in agent code
|
|
203
195
|
|
|
204
196
|
**Supported**
|
|
205
197
|
|
|
206
198
|
- `@voicethere/agent` (`defineAgent`, `speak`, `agentLog`, `onSpeechEvent`, …)
|
|
207
199
|
- Pure TypeScript/JavaScript logic and in-memory state
|
|
200
|
+
- **`fetch` / HTTP(S) to public APIs** (LLMs, tools, your backends on the internet)
|
|
208
201
|
- Allowlisted env from `onSessionStart` (`SESSION_ID`, `PROJECT_ID`, `BUILD_ID`)
|
|
209
202
|
- `SPEECH_EVENT_TYPE` from `@node-webrtc-rust/sdk/voice` at build time (avoid bundling the full SDK runtime into the child when possible)
|
|
210
203
|
|
|
@@ -215,13 +208,14 @@ On cluster deploy, the runner pod also has Helm hardening (non-root, read-only r
|
|
|
215
208
|
- File writes
|
|
216
209
|
- Native Node addons (`.node`)
|
|
217
210
|
- `worker_threads` (not allowed)
|
|
218
|
-
- Direct
|
|
211
|
+
- Direct WebRTC / mic / STT / TTS (use parent IPC)
|
|
212
|
+
- Reachability to internal platform addresses from hosted sessions
|
|
219
213
|
|
|
220
214
|
**Pre-publish checklist**
|
|
221
215
|
|
|
222
216
|
1. `npm run build` — produce `dist/agent.js`
|
|
223
217
|
2. `npm run verify:local` — sandbox + IPC smoke (same flags as production child)
|
|
224
|
-
3. Optional: voice E2E with
|
|
218
|
+
3. Optional: voice E2E with the VoiceThere agent runner (platform or internal deployment)
|
|
225
219
|
|
|
226
220
|
## Build outputs
|
|
227
221
|
|
|
@@ -246,6 +240,6 @@ See [`scripts/RELEASE.md`](./scripts/RELEASE.md) — tag `release/X.Y.Z` trigger
|
|
|
246
240
|
|
|
247
241
|
| Repo | Purpose |
|
|
248
242
|
| ----------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
249
|
-
|
|
|
243
|
+
| VoiceThere agent runner (internal session worker) | Hosts your `agent.js` bundle in production and local E2E |
|
|
250
244
|
| [`voicethere/cli`](https://github.com/voicethere/cli) | CLI for the VoiceThere platform (projects, deploys, sessions) |
|
|
251
245
|
| [`akirilyuk/node-webrtc-rust`](https://github.com/akirilyuk/node-webrtc-rust) | WebRTC + voice SDK (`SpeechEvent` types) |
|
package/dist/protocol.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Transport: Node.js `process.send` / `process.on('message')` on a forked child.
|
|
5
5
|
* Speech payloads use {@link SpeechEvent} from `@node-webrtc-rust/sdk/voice` unchanged.
|
|
6
6
|
*
|
|
7
|
-
* IPC shapes are shared with
|
|
7
|
+
* IPC shapes are shared with the VoiceThere agent runner (session worker parent).
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
package/dist/protocol.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Transport: Node.js `process.send` / `process.on('message')` on a forked child.
|
|
5
5
|
* Speech payloads use {@link SpeechEvent} from `@node-webrtc-rust/sdk/voice` unchanged.
|
|
6
6
|
*
|
|
7
|
-
* IPC shapes are shared with
|
|
7
|
+
* IPC shapes are shared with the VoiceThere agent runner (session worker parent).
|
|
8
8
|
*
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
package/package.json
CHANGED
package/templates/README.md
CHANGED
|
@@ -23,4 +23,4 @@ npx esbuild agent.ts --bundle --platform=node --format=esm --outfile=dist/agent.
|
|
|
23
23
|
|
|
24
24
|
**Verify sandbox (no WebRTC):** from the agent repo, `npm run verify:local` after building your bundle.
|
|
25
25
|
|
|
26
|
-
**Voice E2E:** host with
|
|
26
|
+
**Voice E2E:** host with the VoiceThere agent runner (platform or internal deployment) — set `AGENT_BUNDLE_PATH` to your built `dist/agent.js`.
|
package/templates/agent.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* npm install @voicethere/agent
|
|
9
9
|
* npx esbuild agent.ts --bundle --platform=node --format=esm --outfile=dist/agent.js
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Voice E2E (VoiceThere agent runner — platform or internal deployment):
|
|
12
12
|
* AGENT_BUNDLE_PATH=./dist/agent.js npm run start
|
|
13
13
|
*/
|
|
14
14
|
|