@excitedjs/dreamux 0.12.0 → 0.12.1-beta.50
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 +154 -62
- package/dist/admin/methods.js +72 -0
- package/dist/admin/methods.js.map +1 -1
- package/dist/agent-runtime/catalog.js +66 -0
- package/dist/agent-runtime/catalog.js.map +1 -0
- package/dist/agent-runtime/claude-code-session.js +268 -0
- package/dist/agent-runtime/claude-code-session.js.map +1 -0
- package/dist/agent-runtime/claude-code.js +318 -0
- package/dist/agent-runtime/claude-code.js.map +1 -0
- package/dist/agent-runtime/codex.js +60 -0
- package/dist/agent-runtime/codex.js.map +1 -0
- package/dist/agent-runtime/index.js +6 -0
- package/dist/agent-runtime/index.js.map +1 -0
- package/dist/agent-runtime/types.js +2 -0
- package/dist/agent-runtime/types.js.map +1 -0
- package/dist/channel/channel-providers.js +43 -0
- package/dist/channel/channel-providers.js.map +1 -0
- package/dist/channel/feishu-provider.js +58 -0
- package/dist/channel/feishu-provider.js.map +1 -0
- package/dist/channel/provider.js +51 -0
- package/dist/channel/provider.js.map +1 -0
- package/dist/cli/doctor.js +88 -30
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/dreamux.js +35 -1
- package/dist/cli/dreamux.js.map +1 -1
- package/dist/cli/server.js +13 -8
- package/dist/cli/server.js.map +1 -1
- package/dist/codex/mcp-config.js +18 -8
- package/dist/codex/mcp-config.js.map +1 -1
- package/dist/daemon/install.js +9 -7
- package/dist/daemon/install.js.map +1 -1
- package/dist/dispatcher/base-prompt.js +13 -10
- package/dist/dispatcher/base-prompt.js.map +1 -1
- package/dist/dispatcher/runtime.js +51 -0
- package/dist/dispatcher/runtime.js.map +1 -1
- package/dist/mcp/teammate-mcp.js +277 -0
- package/dist/mcp/teammate-mcp.js.map +1 -0
- package/dist/onboard/config-files.js +35 -22
- package/dist/onboard/config-files.js.map +1 -1
- package/dist/onboard/run.js +3 -2
- package/dist/onboard/run.js.map +1 -1
- package/dist/onboard/service.js +6 -5
- package/dist/onboard/service.js.map +1 -1
- package/dist/registry/builtins.js +99 -0
- package/dist/registry/builtins.js.map +1 -0
- package/dist/registry/index.js +11 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/provider-ref.js +100 -0
- package/dist/registry/provider-ref.js.map +1 -0
- package/dist/registry/registry.js +124 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/runtime/claude-code-args.js +69 -0
- package/dist/runtime/claude-code-args.js.map +1 -0
- package/dist/runtime/claude-code-stream.js +251 -0
- package/dist/runtime/claude-code-stream.js.map +1 -0
- package/dist/runtime/codex-args.js +8 -7
- package/dist/runtime/codex-args.js.map +1 -1
- package/dist/runtime/config.js +212 -39
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/dispatcher-store.js +14 -5
- package/dist/runtime/dispatcher-store.js.map +1 -1
- package/dist/runtime/paths.js +43 -0
- package/dist/runtime/paths.js.map +1 -1
- package/dist/runtime/secrets.js +7 -3
- package/dist/runtime/secrets.js.map +1 -1
- package/dist/server.js +218 -48
- package/dist/server.js.map +1 -1
- package/dist/teammate/delivery.js +124 -0
- package/dist/teammate/delivery.js.map +1 -0
- package/dist/teammate/ledger.js +505 -0
- package/dist/teammate/ledger.js.map +1 -0
- package/dist/teammate/mcp-config.js +19 -0
- package/dist/teammate/mcp-config.js.map +1 -0
- package/package.json +1 -1
- package/skills/dispatcher/SKILL.md +57 -12
- package/skills/dreamux-maintenance/SKILL.md +3 -1
- package/skills/team-dev-workflow/SKILL.md +2 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @excitedjs/dreamux
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
**Dispatchers**; each Dispatcher binds
|
|
3
|
+
The dreamux host server package. One long-running Node process hosts N
|
|
4
|
+
**Dispatchers**; each Dispatcher binds a Channel provider, an Agent Runtime
|
|
5
|
+
provider, and Dreamux-owned MCP surfaces for channel replies and TeamMate work.
|
|
5
6
|
|
|
6
7
|
This file is the **package-level** quick start. For the monorepo layout and
|
|
7
8
|
knowledge base, see the top-level [`README.md`](../../README.md) and
|
|
@@ -12,7 +13,10 @@ Design background:
|
|
|
12
13
|
[#2 Engineering plan](https://github.com/excitedjs/dreamux/issues/2) ·
|
|
13
14
|
[#4 Monorepo + harness](https://github.com/excitedjs/dreamux/issues/4) ·
|
|
14
15
|
[#18 Global bin onboarding](https://github.com/excitedjs/dreamux/issues/18) ·
|
|
15
|
-
[#36 MVP tracking](https://github.com/excitedjs/dreamux/issues/36)
|
|
16
|
+
[#36 MVP tracking](https://github.com/excitedjs/dreamux/issues/36) ·
|
|
17
|
+
[#71 Capability Registry](https://github.com/excitedjs/dreamux/issues/71) ·
|
|
18
|
+
[#98 compatibility stance](https://github.com/excitedjs/dreamux/issues/98) ·
|
|
19
|
+
[#110 plugin/provider Epic](https://github.com/excitedjs/dreamux/issues/110).
|
|
16
20
|
|
|
17
21
|
## What this package ships
|
|
18
22
|
|
|
@@ -21,37 +25,49 @@ Design background:
|
|
|
21
25
|
around the package-local `@excitedjs/tm` dependency for dispatcher skills.
|
|
22
26
|
- A bundled dispatcher Codex skill, copied by `dreamux onboard` into
|
|
23
27
|
`<dispatcher cwd>/.codex/skills/dispatcher/SKILL.md`.
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
- Providerized dispatcher declarations, a process-local Capability Registry,
|
|
29
|
+
server-owned state/log paths, the `builtin:feishu` Channel provider, the
|
|
30
|
+
`builtin:codex` and `builtin:claude-code` Agent Runtime providers, and
|
|
31
|
+
dispatcher-scoped MCP shims for channel replies and TeamMate scheduling.
|
|
32
|
+
- A server-hosted TeamMate ledger with asynchronous scheduling, completion
|
|
33
|
+
delivery, bounded retry, and read-only result retrieval.
|
|
34
|
+
|
|
35
|
+
## Phase 1 contract
|
|
36
|
+
|
|
37
|
+
- **One Node process, many Dispatchers.** Each Dispatcher has one configured
|
|
38
|
+
channel in Phase 1. The config shape is already `channels[]`, but runtime
|
|
39
|
+
routing still accepts exactly one channel per dispatcher.
|
|
40
|
+
- **Provider refs are explicit.** Wired builtin refs are `builtin:feishu`,
|
|
41
|
+
`builtin:codex`, and `builtin:claude-code`. Npm package refs and package
|
|
42
|
+
export refs are reserved syntax only in Phase 1; dreamux parses and rejects
|
|
43
|
+
them clearly instead of loading or executing external code.
|
|
33
44
|
- **One dispatcher is one trust domain.** A bot may receive multiple chats, but
|
|
34
|
-
all accepted messages share one
|
|
35
|
-
chats to the same dispatcher.
|
|
36
|
-
- **Dispatcher cwd is explicit
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
dispatcher cwd.
|
|
45
|
+
all accepted messages share one dispatcher runtime context. Do not bind
|
|
46
|
+
unrelated private chats to the same dispatcher.
|
|
47
|
+
- **Dispatcher cwd is explicit.** Codex-backed dispatchers use Codex's global
|
|
48
|
+
default home (`~/.codex`) for auth, memory, and config. Claude Code-backed
|
|
49
|
+
dispatchers use Claude Code's own CLI/auth behavior. The dispatcher skill is
|
|
50
|
+
workspace-local under the dispatcher cwd.
|
|
40
51
|
- **Inbound state is in memory.** The server keeps only process-local turn
|
|
41
52
|
queues, message dedupe, coalescing state, and received-reaction ownership.
|
|
42
53
|
Restarting the server drops unprocessed inbound messages and may leave
|
|
43
54
|
received reactions behind.
|
|
44
55
|
- **Outbound is MCP reply-only.** Assistant text emitted by Codex is never
|
|
45
56
|
forwarded to Feishu automatically. The model must call the dispatcher-scoped
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
channel MCP tools such as `reply` or `react`, and those tools exist only when
|
|
58
|
+
the Channel provider exposes the capability.
|
|
59
|
+
- **TeamMate is server-hosted.** Scheduling accepts a task and returns a task id
|
|
60
|
+
immediately. Completion is delivered later through the selected Agent Runtime
|
|
61
|
+
provider; if push delivery fails repeatedly, the final result remains
|
|
62
|
+
pull-able from the dispatcher-scoped TeamMate MCP tools.
|
|
63
|
+
- **No webhook surface in Phase 1.** Feishu inbound uses the SDK long-connection
|
|
48
64
|
WebSocket path. Webhook-only verification/encryption fields are not part of
|
|
49
65
|
the config schema.
|
|
50
66
|
|
|
51
|
-
Explicitly **not** in
|
|
67
|
+
Explicitly **not** in Phase 1: per-chat threads, durable inbound buffers,
|
|
52
68
|
automatic assistant-text outbound, HTTP MCP listeners by default, reaction
|
|
53
|
-
ledgers, streaming outbound,
|
|
54
|
-
coordination, and a web UI.
|
|
69
|
+
ledgers, streaming outbound, external npm provider loading, multi-channel
|
|
70
|
+
routing, cross-machine coordination, and a web UI.
|
|
55
71
|
|
|
56
72
|
## Install / build / test
|
|
57
73
|
|
|
@@ -84,11 +100,14 @@ logs:
|
|
|
84
100
|
| `~/.dreamux/config.json` | User-editable config and Feishu bot secrets, created by `dreamux onboard`; edit and restart to apply | the operator |
|
|
85
101
|
| `~/.dreamux/state/server.json` | Server status snapshot | the server |
|
|
86
102
|
| `~/.dreamux/state/admin.sock` | Admin Unix socket | the server |
|
|
87
|
-
| `~/.dreamux/state/<id>/status.json` | Dispatcher runtime status and
|
|
103
|
+
| `~/.dreamux/state/<id>/status.json` | Dispatcher runtime status and runtime thread/session id | the server |
|
|
88
104
|
| `~/.dreamux/state/<id>/access.json` | Dispatcher-local access-gate state | the server |
|
|
89
105
|
| `~/.dreamux/state/<id>/codex.sock` | Codex app-server Unix socket | the server |
|
|
106
|
+
| `~/.dreamux/state/<id>/claude-code-mcp.json` | Claude Code MCP config generated from Dreamux-owned descriptors | the server |
|
|
107
|
+
| `~/.dreamux/state/<id>/teammate/` | TeamMate task ledger, results, and delivery retry state | the server |
|
|
90
108
|
| `~/.dreamux/logs/codex-app-server/<id>.log` | Codex app-server stdout/stderr | the server |
|
|
91
109
|
| `~/.dreamux/logs/feishu-channel/<id>.log` | Feishu channel logs | the server |
|
|
110
|
+
| `~/.dreamux/logs/teammate-mcp/<id>.log` | TeamMate MCP shim diagnostics | the server |
|
|
92
111
|
| `~/.codex/` | Codex global default home: auth, memory, and config | the operator / Codex |
|
|
93
112
|
| `<dispatcher cwd>/.codex/skills/dispatcher/SKILL.md` | Dispatcher skill copied by `dreamux onboard`; reported but not deleted by `dreamux uninstall` | dreamux installer |
|
|
94
113
|
|
|
@@ -110,28 +129,42 @@ Dispatcher declarations live in `config.json`:
|
|
|
110
129
|
"id": "flow",
|
|
111
130
|
"cwd": "<WORKSPACE>",
|
|
112
131
|
"enabled": true,
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"
|
|
132
|
+
"channels": [
|
|
133
|
+
{
|
|
134
|
+
"id": "primary",
|
|
135
|
+
"provider": "builtin:feishu",
|
|
136
|
+
"config": {
|
|
137
|
+
"app_id": "<APP_ID>",
|
|
138
|
+
"app_secret": "<APP_SECRET>"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"runtime": {
|
|
143
|
+
"provider": "builtin:codex",
|
|
144
|
+
"config": {
|
|
145
|
+
"bin": "codex",
|
|
146
|
+
"approval_policy": "never",
|
|
147
|
+
"sandbox_mode": "workspace-write",
|
|
148
|
+
"extra_args": [],
|
|
149
|
+
"extra_env": {
|
|
150
|
+
"EXAMPLE_FLAG": "1"
|
|
151
|
+
},
|
|
152
|
+
"initialize_timeout_ms": 10000
|
|
153
|
+
}
|
|
126
154
|
}
|
|
127
155
|
}
|
|
128
156
|
]
|
|
129
157
|
}
|
|
130
158
|
```
|
|
131
159
|
|
|
132
|
-
|
|
133
|
-
`
|
|
134
|
-
|
|
160
|
+
`dreamux onboard` currently writes the default `builtin:feishu` +
|
|
161
|
+
`builtin:codex` shape. Operator-owned config is never silently rewritten: old
|
|
162
|
+
`dispatchers[].feishu` / `dispatchers[].codex` shapes fail loudly with rebuild
|
|
163
|
+
guidance, following issue #98.
|
|
164
|
+
|
|
165
|
+
There is no top-level `codex` block. Codex settings are per-dispatcher under
|
|
166
|
+
`dispatchers[].runtime.config` when `runtime.provider` is `builtin:codex`.
|
|
167
|
+
Every field defaults, so any field in it can be omitted:
|
|
135
168
|
|
|
136
169
|
- `bin` → `"codex"` (resolved on `PATH`)
|
|
137
170
|
- `approval_policy` → `"never"`
|
|
@@ -143,7 +176,33 @@ any field in it — can be omitted:
|
|
|
143
176
|
Most operators never touch `bin` or `initialize_timeout_ms`. The optional
|
|
144
177
|
`CODEX_HOST_CODEX_BIN` environment variable is a host-level override of the
|
|
145
178
|
codex binary across **every** dispatcher (e.g. CI or a non-PATH install); when
|
|
146
|
-
unset, each dispatcher's `
|
|
179
|
+
unset, each dispatcher's `runtime.config.bin` is used.
|
|
180
|
+
|
|
181
|
+
Claude Code dispatchers use a different runtime-owned config shape:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"runtime": {
|
|
186
|
+
"provider": "builtin:claude-code",
|
|
187
|
+
"config": {
|
|
188
|
+
"bin": "claude",
|
|
189
|
+
"model": null,
|
|
190
|
+
"permission_mode": null,
|
|
191
|
+
"extra_args": [],
|
|
192
|
+
"extra_env": {}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Claude Code is headless-per-turn (`claude --print`) and receives Dreamux MCP
|
|
199
|
+
servers through a generated MCP config file. It does not use Codex app-server,
|
|
200
|
+
Codex handshake, or Codex home diagnostics.
|
|
201
|
+
|
|
202
|
+
Provider refs reserved for future external providers look like npm package refs
|
|
203
|
+
or package export refs, for example `npm:@example/dreamux-provider` and
|
|
204
|
+
`npm:@example/dreamux-provider#channel`. They are not runnable in Phase 1:
|
|
205
|
+
dreamux does not install, import, or execute them.
|
|
147
206
|
|
|
148
207
|
Edit and restart `dreamux serve` to apply dispatcher declaration changes.
|
|
149
208
|
`app_id` values must be unique across all declared dispatchers, including
|
|
@@ -188,26 +247,31 @@ observations and warnings in the same file.
|
|
|
188
247
|
The codex binary path resolves in this order, highest first:
|
|
189
248
|
|
|
190
249
|
1. `CODEX_HOST_CODEX_BIN` environment variable (optional host-level override).
|
|
191
|
-
2. The dispatcher's `dispatchers[].
|
|
250
|
+
2. The dispatcher's `dispatchers[].runtime.config.bin` (default `"codex"`).
|
|
192
251
|
|
|
193
|
-
All other Codex values come from that dispatcher's `
|
|
194
|
-
falling back to the built-in defaults in
|
|
195
|
-
global `codex` layer. A dispatcher's
|
|
196
|
-
`-c key=value` options; dreamux appends its
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
default home.
|
|
252
|
+
All other Codex values come from that dispatcher's `runtime.config` field when
|
|
253
|
+
`runtime.provider` is `builtin:codex`, falling back to the built-in defaults in
|
|
254
|
+
`src/runtime/config.ts`. There is no global `codex` layer. A dispatcher's
|
|
255
|
+
`extra_args` are its only source of `-c key=value` options; dreamux appends its
|
|
256
|
+
own Channel provider MCP and TeamMate MCP `-c` args after them, relying on
|
|
257
|
+
Codex's last-write-wins behavior. Per-dispatcher `extra_env` is merged over the
|
|
258
|
+
server process environment before spawning that dispatcher app-server; dreamux
|
|
259
|
+
still removes `CODEX_HOME` so Codex keeps using its global default home.
|
|
201
260
|
|
|
202
261
|
The managed-service unit does **not** pin `CODEX_HOST_CODEX_BIN`; it adds the
|
|
203
262
|
onboarded codex binary's directory to the unit `PATH` so each dispatcher's
|
|
204
|
-
`
|
|
205
|
-
carry the env var — there it keeps acting as the override and nothing
|
|
263
|
+
`runtime.config.bin` resolves. Existing units installed before this change may
|
|
264
|
+
still carry the env var — there it keeps acting as the override and nothing
|
|
265
|
+
breaks.
|
|
206
266
|
|
|
207
|
-
## MCP
|
|
267
|
+
## MCP surfaces
|
|
208
268
|
|
|
209
|
-
Each dispatcher injects
|
|
210
|
-
|
|
269
|
+
Each dispatcher injects Dreamux-owned MCP stdio servers into its selected Agent
|
|
270
|
+
Runtime provider. Codex receives runtime-specific `mcp_servers.*` arguments;
|
|
271
|
+
Claude Code receives a runtime-owned MCP config file.
|
|
272
|
+
|
|
273
|
+
The Channel provider contributes its channel MCP server. For `builtin:feishu`,
|
|
274
|
+
the stdio shim does not read Feishu secrets. It forwards outbound tool calls to
|
|
211
275
|
the serve process over the admin socket, and the serve process owns the Feishu
|
|
212
276
|
client plus process-local received-reaction cleanup state.
|
|
213
277
|
|
|
@@ -218,18 +282,36 @@ The model-facing tools include:
|
|
|
218
282
|
|
|
219
283
|
If the model only emits assistant text, nothing is sent to Feishu.
|
|
220
284
|
|
|
221
|
-
|
|
285
|
+
The Dispatcher Service also contributes a TeamMate MCP server. Its
|
|
286
|
+
dispatcher-facing tools are:
|
|
287
|
+
|
|
288
|
+
- `schedule`: accept a TeamMate task and return immediately with a task id.
|
|
289
|
+
- `list_tasks`: list recent tasks without result bodies.
|
|
290
|
+
- `get_task`: fetch one task including status, result, delivery state, and
|
|
291
|
+
history.
|
|
292
|
+
- `pull_result`: fetch a retained final result, including after push delivery
|
|
293
|
+
failed.
|
|
294
|
+
|
|
295
|
+
There is no dispatcher-facing `complete` tool. Completion ingest is a
|
|
296
|
+
server/admin seam for future worker/operator paths, so a dispatcher model cannot
|
|
297
|
+
fake a TeamMate completion. TeamMate callers marked as `teammate` cannot
|
|
298
|
+
schedule more TeamMates.
|
|
299
|
+
|
|
300
|
+
## Phase 1 verification path
|
|
222
301
|
|
|
223
302
|
1. `dreamux onboard --dispatcher-id flow --dispatcher-cwd <WORKSPACE> --bot-app-id <APP_ID> --bot-app-secret <APP_SECRET>`
|
|
224
303
|
2. `dreamux serve` starts dispatcher `flow`.
|
|
225
304
|
3. Invite the bot to a Feishu group, send a mention that passes the access gate.
|
|
226
|
-
4. Server injects a `<feishu_message>` block into the
|
|
227
|
-
5.
|
|
305
|
+
4. Server injects a `<feishu_message>` block into the selected runtime.
|
|
306
|
+
5. The runtime calls the Feishu MCP `reply` tool; the reply is delivered to Feishu.
|
|
228
307
|
6. Send another accepted message from a different chat in the same trust
|
|
229
|
-
domain; it enters the same
|
|
230
|
-
7. Ask the
|
|
308
|
+
domain; it enters the same dispatcher runtime context.
|
|
309
|
+
7. Ask the dispatcher to schedule TeamMate work through the `teammate` MCP
|
|
310
|
+
tools; completion delivery later arrives through the runtime-specific
|
|
311
|
+
TeamMate completion path.
|
|
231
312
|
8. Restart the server and continue chatting; Codex `thread/resume` restores the
|
|
232
|
-
thread when possible, but in-flight inbound messages are not durable.
|
|
313
|
+
thread when possible, but in-flight inbound messages are not durable. TeamMate
|
|
314
|
+
final results already recorded in the ledger remain pull-able.
|
|
233
315
|
|
|
234
316
|
## Testing
|
|
235
317
|
|
|
@@ -244,12 +326,22 @@ node common/scripts/install-run-rush.js test
|
|
|
244
326
|
- `tests/bin-launcher.test.ts` — real launcher and repo-root shim behavior from
|
|
245
327
|
arbitrary cwd and through symlinks.
|
|
246
328
|
- `tests/doctor.test.ts` — standalone doctor checks for config, Codex home,
|
|
247
|
-
services, and dispatcher workspace skill
|
|
329
|
+
services, provider-owned runtime binaries, and dispatcher workspace skill
|
|
330
|
+
state.
|
|
331
|
+
- `tests/agent-runtime-provider.test.ts`, `tests/channel-provider.test.ts`,
|
|
332
|
+
`tests/registry.test.ts`, and `tests/provider-ref.test.ts` — provider ref,
|
|
333
|
+
registry, Channel provider, and Agent Runtime provider coverage.
|
|
334
|
+
- `tests/teammate-ledger.test.ts`, `tests/teammate-delivery.test.ts`, and
|
|
335
|
+
`tests/teammate-mcp.test.ts` — server-hosted TeamMate state, delivery, retry,
|
|
336
|
+
and retrieval coverage.
|
|
248
337
|
- `tests/codex-live.test.ts` — real Codex app-server compatibility checks,
|
|
249
338
|
plus the issue #63 mid-turn model gate. Set `DREAMUX_SKIP_LIVE_CODEX=1` only
|
|
250
339
|
when no Codex binary is available locally. Public CI loud-skips the model
|
|
251
340
|
gate unless `DREAMUX_RUN_LIVE_MODEL_GATE=1` is set in an environment with
|
|
252
341
|
usable Codex model auth.
|
|
342
|
+
- `tests/claude-code-live.test.ts` — opt-in Claude Code live contract. Set
|
|
343
|
+
`DREAMUX_RUN_LIVE_CLAUDE_CODE=1` only in an environment with a usable
|
|
344
|
+
`claude` binary and auth.
|
|
253
345
|
|
|
254
346
|
## License
|
|
255
347
|
|
package/dist/admin/methods.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { AdminError } from './protocol.js';
|
|
9
9
|
import { validateDispatcherId } from '../runtime/dispatcher-id.js';
|
|
10
|
+
import { NestedTeamMateDispatchError, } from '../teammate/ledger.js';
|
|
10
11
|
export const adminMethods = {
|
|
11
12
|
'server.status': (server) => ({
|
|
12
13
|
pid: process.pid,
|
|
@@ -101,6 +102,71 @@ export const adminMethods = {
|
|
|
101
102
|
const chatId = mustString(params, 'chat_id');
|
|
102
103
|
return server.listChatBotsFromMcp({ dispatcherId: id, chatId });
|
|
103
104
|
},
|
|
105
|
+
'mcp.teammate.schedule': async (server, params) => {
|
|
106
|
+
const id = mustDispatcherId(params);
|
|
107
|
+
mustExistingDispatcher(server, id);
|
|
108
|
+
const callerKind = mustCallerKind(params);
|
|
109
|
+
const title = mustString(params, 'title');
|
|
110
|
+
const prompt = mustString(params, 'prompt');
|
|
111
|
+
const teammateId = optionalString(params, 'teammate_id');
|
|
112
|
+
try {
|
|
113
|
+
return await server.scheduleTeamMateFromMcp({
|
|
114
|
+
dispatcherId: id,
|
|
115
|
+
callerKind,
|
|
116
|
+
title,
|
|
117
|
+
prompt,
|
|
118
|
+
...(teammateId !== null ? { teammateId } : {}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
if (err instanceof NestedTeamMateDispatchError) {
|
|
123
|
+
throw new AdminError('TEAMMATE_NESTED_DISPATCH_REJECTED', parseMessage(err));
|
|
124
|
+
}
|
|
125
|
+
throw new AdminError('TEAMMATE_SCHEDULE_FAILED', parseMessage(err));
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
// Worker/operator completion ingest (issue #110 PR8). Intentionally NOT a
|
|
129
|
+
// dispatcher-facing teammate-mcp tool, so a dispatcher model cannot fake a
|
|
130
|
+
// completion; it is the seam a future worker / operator tool drives.
|
|
131
|
+
'mcp.teammate.complete': async (server, params) => {
|
|
132
|
+
const id = mustDispatcherId(params);
|
|
133
|
+
mustExistingDispatcher(server, id);
|
|
134
|
+
const taskId = mustString(params, 'task_id');
|
|
135
|
+
const outcome = mustString(params, 'outcome');
|
|
136
|
+
if (outcome !== 'completed' && outcome !== 'failed') {
|
|
137
|
+
throw new AdminError('BAD_REQUEST', "param 'outcome' must be 'completed' or 'failed'");
|
|
138
|
+
}
|
|
139
|
+
const finalText = mustString(params, 'final_text');
|
|
140
|
+
try {
|
|
141
|
+
return await server.reportTeamMateCompletion({
|
|
142
|
+
dispatcherId: id,
|
|
143
|
+
taskId,
|
|
144
|
+
outcome,
|
|
145
|
+
finalText,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new AdminError('TEAMMATE_COMPLETE_FAILED', parseMessage(err));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
'mcp.teammate.list': async (server, params) => {
|
|
153
|
+
const id = mustDispatcherId(params);
|
|
154
|
+
mustExistingDispatcher(server, id);
|
|
155
|
+
return { tasks: await server.listTeamMateTasksFromMcp(id) };
|
|
156
|
+
},
|
|
157
|
+
'mcp.teammate.get': async (server, params) => {
|
|
158
|
+
const id = mustDispatcherId(params);
|
|
159
|
+
mustExistingDispatcher(server, id);
|
|
160
|
+
const taskId = mustString(params, 'task_id');
|
|
161
|
+
return { task: await server.getTeamMateTaskFromMcp(id, taskId) };
|
|
162
|
+
},
|
|
163
|
+
'mcp.teammate.pull': async (server, params) => {
|
|
164
|
+
const id = mustDispatcherId(params);
|
|
165
|
+
mustExistingDispatcher(server, id);
|
|
166
|
+
const taskId = optionalString(params, 'task_id');
|
|
167
|
+
const result = await server.pullTeamMateResultFromMcp(id, taskId !== null ? taskId : undefined);
|
|
168
|
+
return { result };
|
|
169
|
+
},
|
|
104
170
|
};
|
|
105
171
|
function mustString(params, key) {
|
|
106
172
|
if (params === undefined || typeof params[key] !== 'string') {
|
|
@@ -118,6 +184,12 @@ function mustDispatcherId(params) {
|
|
|
118
184
|
throw new AdminError('BAD_REQUEST', message);
|
|
119
185
|
}
|
|
120
186
|
}
|
|
187
|
+
function mustCallerKind(params) {
|
|
188
|
+
const callerKind = mustString(params, 'caller_kind');
|
|
189
|
+
if (callerKind === 'dispatcher' || callerKind === 'teammate')
|
|
190
|
+
return callerKind;
|
|
191
|
+
throw new AdminError('BAD_REQUEST', "param 'caller_kind' must be 'dispatcher' or 'teammate'");
|
|
192
|
+
}
|
|
121
193
|
function optionalString(params, key) {
|
|
122
194
|
if (params === undefined)
|
|
123
195
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/admin/methods.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/admin/methods.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACL,2BAA2B,GAE5B,MAAM,uBAAuB,CAAC;AAO/B,MAAM,CAAC,MAAM,YAAY,GAAiC;IACxD,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5B,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACvC,WAAW,E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UAAU,GAAG,+BAA+B,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,CAAa,CAAC;AACvB,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAc,EAAE,EAAU;IACxD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,UAAU,CAAC,sBAAsB,EAAE,0BAA0B,EAAE,GAAG,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAc,EAAE,EAAU;IACvD,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;QACnC,MAAM,IAAI,UAAU,CAClB,wBAAwB,EACxB,eAAe,EAAE,kBAAkB,CACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAAY;IAChC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createBuiltinRegistry, formatProviderRef, ReservedExternalProviderError, } from '../registry/index.js';
|
|
2
|
+
import { createCodexAgentRuntimeProvider } from './codex.js';
|
|
3
|
+
import { createClaudeCodeAgentRuntimeProvider } from './claude-code.js';
|
|
4
|
+
export class UnsupportedAgentRuntimeProviderError extends Error {
|
|
5
|
+
providerRef;
|
|
6
|
+
reason;
|
|
7
|
+
constructor(providerRef, reason) {
|
|
8
|
+
super(`agent runtime provider ${JSON.stringify(providerRef)} is not supported: ${reason}`);
|
|
9
|
+
this.providerRef = providerRef;
|
|
10
|
+
this.reason = reason;
|
|
11
|
+
this.name = 'UnsupportedAgentRuntimeProviderError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class WrongProviderKindError extends Error {
|
|
15
|
+
descriptor;
|
|
16
|
+
constructor(descriptor) {
|
|
17
|
+
super(`provider ${JSON.stringify(formatProviderRef(descriptor.ref))} is a ` +
|
|
18
|
+
`${descriptor.kind} provider, expected agentRuntime`);
|
|
19
|
+
this.descriptor = descriptor;
|
|
20
|
+
this.name = 'WrongProviderKindError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class AgentRuntimeProviderCatalog {
|
|
24
|
+
registry;
|
|
25
|
+
providers = new Map();
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.registry = options.registry ?? createBuiltinRegistry();
|
|
28
|
+
for (const provider of options.providers) {
|
|
29
|
+
this.providers.set(provider.ref, provider);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
list() {
|
|
33
|
+
return [...this.providers.values()];
|
|
34
|
+
}
|
|
35
|
+
resolve(ref) {
|
|
36
|
+
let descriptor;
|
|
37
|
+
try {
|
|
38
|
+
descriptor = this.registry.resolve(ref);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof ReservedExternalProviderError) {
|
|
42
|
+
throw new UnsupportedAgentRuntimeProviderError(ref, err.message);
|
|
43
|
+
}
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
if (descriptor.kind !== 'agentRuntime') {
|
|
47
|
+
throw new WrongProviderKindError(descriptor);
|
|
48
|
+
}
|
|
49
|
+
const canonicalRef = formatProviderRef(descriptor.ref);
|
|
50
|
+
const provider = this.providers.get(canonicalRef);
|
|
51
|
+
if (provider === undefined) {
|
|
52
|
+
throw new UnsupportedAgentRuntimeProviderError(canonicalRef, 'the provider is registered but has no runtime implementation wired in this phase');
|
|
53
|
+
}
|
|
54
|
+
return provider;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function createBuiltinAgentRuntimeProviderCatalog(options) {
|
|
58
|
+
return new AgentRuntimeProviderCatalog({
|
|
59
|
+
providers: [
|
|
60
|
+
createCodexAgentRuntimeProvider(options.codex),
|
|
61
|
+
createClaudeCodeAgentRuntimeProvider(options.claudeCode ?? {}),
|
|
62
|
+
],
|
|
63
|
+
...(options.registry !== undefined ? { registry: options.registry } : {}),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/agent-runtime/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,GAG9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAC;AAIxE,MAAM,OAAO,oCAAqC,SAAQ,KAAK;IAElD;IACA;IAFX,YACW,WAAmB,EACnB,MAAc;QAEvB,KAAK,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC;QAHlF,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,GAAN,MAAM,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,sCAAsC,CAAC;IACrD,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B;IAArB,YAAqB,UAA8B;QACjD,KAAK,CACH,YAAY,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ;YACnE,GAAG,UAAU,CAAC,IAAI,kCAAkC,CACvD,CAAC;QAJiB,eAAU,GAAV,UAAU,CAAoB;QAKjD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAOD,MAAM,OAAO,2BAA2B;IACrB,QAAQ,CAAqB;IAC7B,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IAErE,YAAY,OAA2C;QACrD,IAAI,CAAC,Q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