@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.9
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/CHANGELOG.md +25 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +746 -55
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +175 -37
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +239 -53
- package/dist/builtin/web-access/index.bundle.mjs +175 -37
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
- package/dist/builtin/workflows/builtin/chunk-17zk6ffd.js +69794 -0
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-8v8wmb7z.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-h5e65g7g.js +1080 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qe6bfpbd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-rbnj9621.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1294 -430
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +1022 -429
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +15 -0
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +3 -1
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +65 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +19 -0
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +2 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +108 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.16-alpha.
|
|
3
|
+
"version": "0.9.16-alpha.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
|
|
6
6
|
"contributors": [
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { SessionInfo } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export type SessionTargetResolution =
|
|
4
|
+
| { kind: "resolved"; session: SessionInfo }
|
|
5
|
+
| { kind: "ambiguous_name"; matches: readonly SessionInfo[] }
|
|
6
|
+
| { kind: "not_found" };
|
|
7
|
+
|
|
8
|
+
/** Resolve an Intercom session by exact ID or exact case-insensitive name. */
|
|
9
|
+
export function resolveSessionTarget(
|
|
10
|
+
sessions: readonly SessionInfo[],
|
|
11
|
+
nameOrId: string,
|
|
12
|
+
): SessionTargetResolution {
|
|
13
|
+
const target = nameOrId.trim();
|
|
14
|
+
const exactId = sessions.find((session) => session.id === target);
|
|
15
|
+
if (exactId !== undefined) return { kind: "resolved", session: exactId };
|
|
16
|
+
|
|
17
|
+
const lowerTarget = target.toLowerCase();
|
|
18
|
+
const exactNames = sessions.filter(
|
|
19
|
+
(session) => session.name?.toLowerCase() === lowerTarget,
|
|
20
|
+
);
|
|
21
|
+
if (exactNames.length === 1) {
|
|
22
|
+
return { kind: "resolved", session: exactNames[0]! };
|
|
23
|
+
}
|
|
24
|
+
if (exactNames.length > 1) {
|
|
25
|
+
return { kind: "ambiguous_name", matches: exactNames };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { kind: "not_found" };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function sessionTargetFailureReason(
|
|
32
|
+
target: string,
|
|
33
|
+
resolution: Exclude<SessionTargetResolution, { kind: "resolved" }>,
|
|
34
|
+
): string {
|
|
35
|
+
if (resolution.kind === "ambiguous_name") {
|
|
36
|
+
return `Multiple sessions named "${target}" are connected. Use the session ID instead.`;
|
|
37
|
+
}
|
|
38
|
+
return "Session not found";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SessionListingClient {
|
|
42
|
+
listSessions(): Promise<SessionInfo[]>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Resolve a target through the broker's current session list. */
|
|
46
|
+
export async function resolveSessionTargetId(
|
|
47
|
+
client: SessionListingClient,
|
|
48
|
+
nameOrId: string,
|
|
49
|
+
): Promise<string | null> {
|
|
50
|
+
const resolution = resolveSessionTarget(await client.listSessions(), nameOrId);
|
|
51
|
+
if (resolution.kind === "resolved") return resolution.session.id;
|
|
52
|
+
if (resolution.kind === "not_found") return null;
|
|
53
|
+
throw new Error(sessionTargetFailureReason(nameOrId, resolution));
|
|
54
|
+
}
|
|
@@ -75,7 +75,22 @@ intercom({ action: "list" })
|
|
|
75
75
|
intercom({ action: "ask", to: "6332faab-1111-4222-8333-123456789abc", message: "Which option should I use?" })
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
Live sessions accept an exact full session ID or exact case-insensitive name. Ordinary `send` to a known workflow stage whose session has not initialized uses the exact `<runId>:<stageKey>` identity. Unknown runs and stages retain the ordinary unknown-target failure.
|
|
79
|
+
|
|
80
|
+
### Deliver to workflow stages that have not started
|
|
81
|
+
|
|
82
|
+
Send material updates through Intercom to every affected workflow stage, including stages that have not started. Atomic queues messages for known pending stages and delivers them when their sessions initialize:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
intercom({
|
|
86
|
+
action: "send",
|
|
87
|
+
to: "<runId>:reviewer",
|
|
88
|
+
message: "Scope changed: preserve raw amendment text in the verification oracle."
|
|
89
|
+
})
|
|
90
|
+
// → queued, distinct from live-session delivered, with the FIFO position
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The stage receives the ordinary inbound Intercom message before its first model turn under **Messages received before you started**, with real sender identity and a `Sent:` timestamp. Only same-workflow-group sessions may queue messages. Each exact run/stage key holds at most 50 queued messages; the next send is refused rather than evicting one. Resume/replay, broker restart, and stage-attempt restart preserve exactly-once delivery. If the stage is skipped, cancelled, or becomes terminal before its session initializes, the message becomes undeliverable and acknowledgment-requesting senders receive a correlated failure. Do not use `ask`: Atomic returns `pending_stage_ask_unsupported` and recommends ordinary `send` instead of holding an unbounded waiter.
|
|
79
94
|
|
|
80
95
|
### Runtime named groups
|
|
81
96
|
|
|
@@ -230,8 +245,8 @@ In Atomic workflows, each invocation has its own Intercom group, and parallel st
|
|
|
230
245
|
|--------|----------|----------|
|
|
231
246
|
| `join` | Joins or creates a named group in place | Two plain chat sessions need a private group |
|
|
232
247
|
| `leave` | Returns to the resolved home group | Restore the session's startup group |
|
|
233
|
-
| `send` | Fire-and-forget | You don't need a response |
|
|
234
|
-
| `ask` | Blocks until
|
|
248
|
+
| `send` | Fire-and-forget to a live session, or durable `queued` delivery to `<runId>:<stageKey>` before a workflow stage starts | You don't need a response |
|
|
249
|
+
| `ask` | Blocks until a live recipient replies (10 min timeout); refused for an unstarted stage | You need an answer to continue |
|
|
235
250
|
| `reply` | Responds to the active or pending inbound ask; `to` accepts an exact full session ID or exact session name | You were asked something and need to answer naturally |
|
|
236
251
|
| `pending` | Lists unresolved inbound asks | You need to see who is waiting before replying |
|
|
237
252
|
| `list` | Returns all sessions in the current group with full session IDs and live status | You need to discover targets or choose an idle peer |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type SubagentChildPolicy } from "@bastani/atomic";
|
|
2
|
+
import type { Message } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export function buildSubagentMessageSource(
|
|
5
|
+
runIdValue: string | undefined,
|
|
6
|
+
agentValue: string | undefined,
|
|
7
|
+
indexValue: string | undefined,
|
|
8
|
+
): Message["source"] | undefined {
|
|
9
|
+
const subagentRunId = runIdValue?.trim();
|
|
10
|
+
if (!subagentRunId) return undefined;
|
|
11
|
+
const subagentAgent = agentValue?.trim();
|
|
12
|
+
const rawIndex = indexValue?.trim();
|
|
13
|
+
const parsedIndex = rawIndex === undefined ? undefined : Number(rawIndex);
|
|
14
|
+
const subagentIndex = parsedIndex !== undefined && Number.isInteger(parsedIndex) && parsedIndex >= 0
|
|
15
|
+
? parsedIndex : undefined;
|
|
16
|
+
return {
|
|
17
|
+
subagentRunId,
|
|
18
|
+
...(subagentAgent ? { subagentAgent } : {}),
|
|
19
|
+
...(subagentIndex !== undefined ? { subagentIndex } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function readSubagentMessageSource(policy?: SubagentChildPolicy): Message["source"] | undefined {
|
|
24
|
+
const identity = policy?.intercom;
|
|
25
|
+
if (!identity) return undefined;
|
|
26
|
+
return {
|
|
27
|
+
subagentRunId: identity.runId,
|
|
28
|
+
subagentAgent: identity.agent,
|
|
29
|
+
subagentIndex: identity.index,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface SessionInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
cwd: string;
|
|
5
|
+
model: string;
|
|
6
|
+
pid: number;
|
|
7
|
+
startedAt: number;
|
|
8
|
+
lastActivity: number;
|
|
9
|
+
status?: string;
|
|
10
|
+
/** Session's intercom group; undefined is treated as the shared "default" group. */
|
|
11
|
+
group?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Message {
|
|
15
|
+
id: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
replyTo?: string;
|
|
18
|
+
expectsReply?: boolean;
|
|
19
|
+
/** Actionable remote failure for a correlated ask reply. */
|
|
20
|
+
replyError?: string;
|
|
21
|
+
source?: {
|
|
22
|
+
subagentRunId: string;
|
|
23
|
+
subagentAgent?: string;
|
|
24
|
+
subagentIndex?: number;
|
|
25
|
+
};
|
|
26
|
+
content: {
|
|
27
|
+
text: string;
|
|
28
|
+
attachments?: Attachment[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Attachment {
|
|
33
|
+
type: "file" | "snippet" | "context";
|
|
34
|
+
name: string;
|
|
35
|
+
content: string;
|
|
36
|
+
language?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Broker capability metadata binding a child registration to its supervisor. */
|
|
39
|
+
export interface SupervisorRegistration {
|
|
40
|
+
capability: string;
|
|
41
|
+
supervisorSessionId: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export type ClientMessage =
|
|
46
|
+
| {
|
|
47
|
+
type: "register";
|
|
48
|
+
session: Omit<SessionInfo, "id">;
|
|
49
|
+
/** Internal host-owned identity retained across broker reconnects. */
|
|
50
|
+
returnAddress?: string;
|
|
51
|
+
supervisor?: SupervisorRegistration;
|
|
52
|
+
supervisorOwnerToken?: string;
|
|
53
|
+
}
|
|
54
|
+
| { type: "unregister" }
|
|
55
|
+
| { type: "list"; requestId: string; group?: string }
|
|
56
|
+
| { type: "authorize_supervisor"; requestId: string; childName: string; capability?: string }
|
|
57
|
+
| { type: "send" | "supervisor_send"; to: string; message: Message; attemptId?: string }
|
|
58
|
+
| {
|
|
59
|
+
type: "send_pending_stage_notification";
|
|
60
|
+
runId: string;
|
|
61
|
+
capability: string;
|
|
62
|
+
to: string;
|
|
63
|
+
senderRegistrationName?: string;
|
|
64
|
+
senderReturnAddress?: string;
|
|
65
|
+
message: Message;
|
|
66
|
+
attemptId?: string;
|
|
67
|
+
}
|
|
68
|
+
| { type: "pending_stage_notification_result"; requestId: string; delivered: boolean }
|
|
69
|
+
| { type: "register_pending_stage_route"; runId: string; group: string; capability: string }
|
|
70
|
+
| {
|
|
71
|
+
type: "register_live_workflow_stage_route";
|
|
72
|
+
requestId: string;
|
|
73
|
+
runId: string;
|
|
74
|
+
stageKeys: string[];
|
|
75
|
+
capability: string;
|
|
76
|
+
}
|
|
77
|
+
| {
|
|
78
|
+
type: "pending_stage_message_result";
|
|
79
|
+
requestId: string;
|
|
80
|
+
outcome: "queued" | "delivered" | "forward" | "refused";
|
|
81
|
+
position?: number;
|
|
82
|
+
reason?: string;
|
|
83
|
+
reasonCode?: "message_id_conflict";
|
|
84
|
+
}
|
|
85
|
+
| { type: "presence"; name?: string; status?: string; model?: string; group?: string; requestId?: string };
|
|
86
|
+
|
|
87
|
+
export type BrokerMessage =
|
|
88
|
+
| { type: "registered"; sessionId: string; supervisorSessionId?: string }
|
|
89
|
+
| { type: "registration_failed"; reason: string }
|
|
90
|
+
| { type: "sessions"; requestId: string; sessions: SessionInfo[] }
|
|
91
|
+
| { type: "supervisor_authorized"; requestId: string; capability: string; supervisorSessionId: string; childName: string }
|
|
92
|
+
| { type: "message"; from: SessionInfo; message: Message; channel?: "supervisor" }
|
|
93
|
+
| { type: "pending_stage_notification"; requestId: string; from: SessionInfo; message: Message }
|
|
94
|
+
| {
|
|
95
|
+
type: "pending_stage_message";
|
|
96
|
+
requestId: string;
|
|
97
|
+
from: SessionInfo;
|
|
98
|
+
senderRegistrationName?: string;
|
|
99
|
+
senderReturnAddress?: string;
|
|
100
|
+
runId: string;
|
|
101
|
+
stageKey: string;
|
|
102
|
+
message: Message;
|
|
103
|
+
live?: boolean;
|
|
104
|
+
}
|
|
105
|
+
| { type: "live_workflow_stage_route_registered"; requestId: string }
|
|
106
|
+
| { type: "presence_update"; session: SessionInfo }
|
|
107
|
+
| { type: "session_joined"; session: SessionInfo }
|
|
108
|
+
| { type: "session_left"; sessionId: string }
|
|
109
|
+
| { type: "peer_disconnected"; replyTo: string; peerSessionId: string; peerName?: string }
|
|
110
|
+
| { type: "presence_ack"; requestId: string; group: string }
|
|
111
|
+
| { type: "presence_failed"; requestId: string; reason: string }
|
|
112
|
+
| { type: "error"; error: string }
|
|
113
|
+
| { type: "delivered"; messageId: string; attemptId?: string }
|
|
114
|
+
| { type: "queued"; messageId: string; attemptId?: string; runId: string; stageKey: string; position: number }
|
|
115
|
+
| { type: "delivery_failed"; messageId: string; reason: string; reasonCode?: "message_id_conflict"; attemptId?: string };
|