@openscout/protocol 0.2.64 → 0.2.83
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/LICENSE +202 -0
- package/README.md +103 -52
- package/dist/a2a.d.ts +224 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +225 -0
- package/dist/activity.d.ts +70 -0
- package/dist/activity.d.ts.map +1 -0
- package/dist/activity.js +1 -0
- package/dist/actors.d.ts +7 -3
- package/dist/actors.d.ts.map +1 -0
- package/dist/actors.js +15 -1
- package/dist/agent-broker-feed.d.ts +84 -0
- package/dist/agent-broker-feed.d.ts.map +1 -0
- package/dist/agent-broker-feed.js +1 -0
- package/dist/agent-identity.d.ts +23 -0
- package/dist/agent-identity.d.ts.map +1 -0
- package/dist/agent-identity.js +122 -8
- package/dist/agent-runs.d.ts +191 -0
- package/dist/agent-runs.d.ts.map +1 -0
- package/dist/agent-runs.js +365 -0
- package/dist/assigned-roles.d.ts +205 -0
- package/dist/assigned-roles.d.ts.map +1 -0
- package/dist/assigned-roles.js +228 -0
- package/dist/broker-routes.d.ts +40 -0
- package/dist/broker-routes.d.ts.map +1 -0
- package/dist/broker-routes.js +56 -0
- package/dist/budget.d.ts +65 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +19 -0
- package/dist/capability-matrix.d.ts +230 -0
- package/dist/capability-matrix.d.ts.map +1 -0
- package/dist/capability-matrix.js +304 -0
- package/dist/channel-identity.d.ts +40 -0
- package/dist/channel-identity.d.ts.map +1 -0
- package/dist/channel-identity.js +108 -0
- package/dist/collaboration.d.ts +45 -16
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +39 -23
- package/dist/common.d.ts +4 -3
- package/dist/common.d.ts.map +1 -0
- package/dist/conversations.d.ts +1 -0
- package/dist/conversations.d.ts.map +1 -0
- package/dist/cursor-transport.d.ts +22 -0
- package/dist/cursor-transport.d.ts.map +1 -0
- package/dist/cursor-transport.js +10 -0
- package/dist/debug-attach.d.ts +29 -0
- package/dist/debug-attach.d.ts.map +1 -0
- package/dist/debug-attach.js +6 -0
- package/dist/deliveries.d.ts +16 -2
- package/dist/deliveries.d.ts.map +1 -0
- package/dist/durable-actions.d.ts +94 -0
- package/dist/durable-actions.d.ts.map +1 -0
- package/dist/durable-actions.js +1 -0
- package/dist/events.d.ts +27 -1
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +14 -1
- package/dist/harness-feature-support.d.ts +76 -0
- package/dist/harness-feature-support.d.ts.map +1 -0
- package/dist/harness-feature-support.js +29 -0
- package/dist/host-integrations.d.ts +22 -0
- package/dist/host-integrations.d.ts.map +1 -0
- package/dist/host-integrations.js +64 -0
- package/dist/inbox.d.ts +50 -0
- package/dist/inbox.d.ts.map +1 -0
- package/dist/inbox.js +9 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -2
- package/dist/invocations.d.ts +119 -4
- package/dist/invocations.d.ts.map +1 -0
- package/dist/invocations.js +201 -1
- package/dist/mesh.d.ts +98 -0
- package/dist/mesh.d.ts.map +1 -0
- package/dist/mesh.js +18 -1
- package/dist/messages.d.ts +3 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/native-interactions.d.ts +30 -0
- package/dist/native-interactions.d.ts.map +1 -0
- package/dist/native-interactions.js +51 -0
- package/dist/observed-status.d.ts +33 -0
- package/dist/observed-status.d.ts.map +1 -0
- package/dist/observed-status.js +6 -0
- package/dist/orchestrator-prompt.d.ts +10 -0
- package/dist/orchestrator-prompt.d.ts.map +1 -0
- package/dist/orchestrator-prompt.js +36 -0
- package/dist/permission-policy.d.ts +5 -0
- package/dist/permission-policy.d.ts.map +1 -0
- package/dist/permission-policy.js +15 -0
- package/dist/provisional-agent-names.d.ts +30 -0
- package/dist/provisional-agent-names.d.ts.map +1 -0
- package/dist/provisional-agent-names.js +224 -0
- package/dist/read-receipts.d.ts +12 -0
- package/dist/read-receipts.d.ts.map +1 -0
- package/dist/read-receipts.js +1 -0
- package/dist/relay-agent-card.d.ts +10 -0
- package/dist/relay-agent-card.d.ts.map +1 -0
- package/dist/rendezvous.d.ts +97 -0
- package/dist/rendezvous.d.ts.map +1 -0
- package/dist/rendezvous.js +35 -0
- package/dist/reserved-vocabulary.d.ts +21 -0
- package/dist/reserved-vocabulary.d.ts.map +1 -0
- package/dist/reserved-vocabulary.js +101 -0
- package/dist/route-aliases.d.ts +112 -0
- package/dist/route-aliases.d.ts.map +1 -0
- package/dist/route-aliases.js +1 -0
- package/dist/runtime-catalog-contract.d.ts +39 -0
- package/dist/runtime-catalog-contract.d.ts.map +1 -0
- package/dist/runtime-catalog-contract.js +17 -0
- package/dist/runtime-catalog.d.ts +11 -0
- package/dist/runtime-catalog.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.d.ts +230 -0
- package/dist/runtime-catalog.generated.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.js +299 -0
- package/dist/runtime-catalog.js +192 -0
- package/dist/runtime-execution.d.ts +161 -0
- package/dist/runtime-execution.d.ts.map +1 -0
- package/dist/runtime-execution.js +327 -0
- package/dist/runtime-profiles.d.ts +12 -0
- package/dist/runtime-profiles.d.ts.map +1 -0
- package/dist/runtime-profiles.js +20 -0
- package/dist/scout-agent-card.d.ts +10 -0
- package/dist/scout-agent-card.d.ts.map +1 -0
- package/dist/scout-composer.d.ts +27 -0
- package/dist/scout-composer.d.ts.map +1 -0
- package/dist/scout-composer.js +192 -0
- package/dist/scout-delivery.d.ts +99 -4
- package/dist/scout-delivery.d.ts.map +1 -0
- package/dist/scout-dispatch.d.ts +40 -3
- package/dist/scout-dispatch.d.ts.map +1 -0
- package/dist/scout-reply-context.d.ts +1 -0
- package/dist/scout-reply-context.d.ts.map +1 -0
- package/dist/session-display-state.d.ts +132 -0
- package/dist/session-display-state.d.ts.map +1 -0
- package/dist/session-display-state.js +94 -0
- package/dist/terminal-host-topology.d.ts +119 -0
- package/dist/terminal-host-topology.d.ts.map +1 -0
- package/dist/terminal-host-topology.js +21 -0
- package/dist/terminal-sessions.d.ts +142 -0
- package/dist/terminal-sessions.d.ts.map +1 -0
- package/dist/terminal-sessions.js +81 -0
- package/dist/terminal-surface-id.d.ts +73 -0
- package/dist/terminal-surface-id.d.ts.map +1 -0
- package/dist/terminal-surface-id.js +162 -0
- package/dist/terminal-workspaces.d.ts +199 -0
- package/dist/terminal-workspaces.d.ts.map +1 -0
- package/dist/terminal-workspaces.js +287 -0
- package/dist/thread-events.d.ts +1 -0
- package/dist/thread-events.d.ts.map +1 -0
- package/dist/time.d.ts +16 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +33 -0
- package/dist/transports.d.ts +1 -0
- package/dist/transports.d.ts.map +1 -0
- package/package.json +37 -9
- package/src/a2a.ts +471 -0
- package/src/activity.ts +113 -0
- package/src/actors.ts +42 -8
- package/src/agent-broker-feed.ts +102 -0
- package/src/agent-identity.ts +143 -8
- package/src/agent-runs.ts +675 -0
- package/src/assigned-roles.ts +437 -0
- package/src/broker-routes.ts +62 -0
- package/src/budget.ts +88 -0
- package/src/capability-matrix.ts +648 -0
- package/src/channel-identity.ts +147 -0
- package/src/collaboration.ts +78 -48
- package/src/common.ts +24 -5
- package/src/cursor-transport.ts +34 -0
- package/src/debug-attach.ts +38 -0
- package/src/deliveries.ts +16 -1
- package/src/durable-actions.ts +125 -0
- package/src/events.ts +31 -0
- package/src/harness-feature-support.ts +116 -0
- package/src/host-integrations.ts +104 -0
- package/src/inbox.ts +68 -0
- package/src/index.ts +34 -2
- package/src/invocations.ts +351 -4
- package/src/mesh.ts +130 -0
- package/src/messages.ts +2 -0
- package/src/native-interactions.ts +100 -0
- package/src/observed-status.ts +90 -0
- package/src/orchestrator-prompt.ts +47 -0
- package/src/permission-policy.ts +21 -0
- package/src/provisional-agent-names.ts +272 -0
- package/src/read-receipts.ts +12 -0
- package/src/relay-agent-card.ts +73 -63
- package/src/rendezvous.ts +154 -0
- package/src/reserved-vocabulary.ts +135 -0
- package/src/route-aliases.ts +130 -0
- package/src/runtime-catalog-contract.ts +60 -0
- package/src/runtime-catalog.generated.ts +300 -0
- package/src/runtime-catalog.md +21 -0
- package/src/runtime-catalog.ts +193 -0
- package/src/runtime-catalog.v1.json +81 -0
- package/src/runtime-execution.ts +545 -0
- package/src/runtime-profiles.ts +37 -0
- package/src/scout-agent-card.ts +10 -0
- package/src/scout-composer.ts +249 -0
- package/src/scout-delivery.ts +113 -3
- package/src/scout-dispatch.ts +33 -2
- package/src/session-display-state.ts +202 -0
- package/src/terminal-host-topology.ts +132 -0
- package/src/terminal-sessions.ts +187 -0
- package/src/terminal-surface-id.ts +189 -0
- package/src/terminal-workspaces.ts +455 -0
- package/src/time.ts +49 -0
- package/dist/agent-address.d.ts +0 -1
- package/dist/agent-address.js +0 -1
- package/dist/agent-selectors.d.ts +0 -1
- package/dist/agent-selectors.js +0 -1
- package/src/agent-address.ts +0 -1
- package/src/agent-identity.test.ts +0 -435
- package/src/agent-selectors.ts +0 -1
- package/src/scout-agent-card.test.ts +0 -54
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { parseAgentIdentity } from "./agent-identity.js";
|
|
2
|
+
import { AGENT_HARNESSES, type AgentHarness } from "./actors.js";
|
|
3
|
+
import type { ScoutRouteTarget } from "./scout-dispatch.js";
|
|
4
|
+
|
|
5
|
+
export const SCOUT_COMPOSER_ROUTE_OPERATOR = ">>" as const;
|
|
6
|
+
export const SCOUT_TARGET_HANDLE_SHORTHAND = "⌖" as const;
|
|
7
|
+
|
|
8
|
+
export type ScoutComposerRouteDiagnosticCode =
|
|
9
|
+
| "missing_target"
|
|
10
|
+
| "invalid_target";
|
|
11
|
+
|
|
12
|
+
export interface ScoutComposerRouteDiagnostic {
|
|
13
|
+
code: ScoutComposerRouteDiagnosticCode;
|
|
14
|
+
message: string;
|
|
15
|
+
start: number;
|
|
16
|
+
end: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ScoutComposerRoute {
|
|
20
|
+
operator: typeof SCOUT_COMPOSER_ROUTE_OPERATOR;
|
|
21
|
+
token: string;
|
|
22
|
+
target: ScoutRouteTarget;
|
|
23
|
+
operatorStart: number;
|
|
24
|
+
operatorEnd: number;
|
|
25
|
+
targetStart: number;
|
|
26
|
+
targetEnd: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ScoutComposerRouteParseResult {
|
|
30
|
+
route: ScoutComposerRoute | null;
|
|
31
|
+
body: string;
|
|
32
|
+
diagnostics: ScoutComposerRouteDiagnostic[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const WHITESPACE_PATTERN = /\s/;
|
|
36
|
+
const TRAILING_TARGET_PUNCTUATION_PATTERN = /[.,!?;)\]}]+$/;
|
|
37
|
+
const ROUTE_VALUE_PATTERN = /^\S+$/;
|
|
38
|
+
const AGENT_LABEL_START_PATTERN = /^[A-Za-z0-9]/;
|
|
39
|
+
const SESSION_ROUTE_HARNESSES = new Set<AgentHarness>(AGENT_HARNESSES);
|
|
40
|
+
|
|
41
|
+
function findRouteOperator(input: string): { start: number; end: number } | null {
|
|
42
|
+
let searchFrom = 0;
|
|
43
|
+
|
|
44
|
+
while (searchFrom < input.length) {
|
|
45
|
+
const index = input.indexOf(SCOUT_COMPOSER_ROUTE_OPERATOR, searchFrom);
|
|
46
|
+
if (index === -1) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const previous = index > 0 ? input[index - 1] : "";
|
|
51
|
+
if (index === 0 || WHITESPACE_PATTERN.test(previous)) {
|
|
52
|
+
return {
|
|
53
|
+
start: index,
|
|
54
|
+
end: index + SCOUT_COMPOSER_ROUTE_OPERATOR.length,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
searchFrom = index + SCOUT_COMPOSER_ROUTE_OPERATOR.length;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function routeBodyWithoutTarget(input: string, start: number, end: number): string {
|
|
65
|
+
return `${input.slice(0, start)} ${input.slice(end)}`.replace(/\s+/g, " ").trim();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function trimRouteTargetToken(value: string): string {
|
|
69
|
+
return value
|
|
70
|
+
.trim()
|
|
71
|
+
.replace(TRAILING_TARGET_PUNCTUATION_PATTERN, "");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isRouteValue(value: string): boolean {
|
|
75
|
+
return value.length > 0 && ROUTE_VALUE_PATTERN.test(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function parseAgentLabelTarget(value: string): ScoutRouteTarget | null {
|
|
79
|
+
const label = value.replace(/^@+/, "");
|
|
80
|
+
if (!AGENT_LABEL_START_PATTERN.test(label)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (!parseAgentIdentity(label)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return { kind: "agent_label", label, value };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function parseTargetHandleTarget(rawValue: string): ScoutRouteTarget | null {
|
|
90
|
+
const handle = rawValue.replace(/^[@⌖]+/, "");
|
|
91
|
+
if (!isRouteValue(handle)) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return { kind: "target_handle", handle, value: `target:${handle}` };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function parseRouteAliasTarget(rawValue: string): ScoutRouteTarget | null {
|
|
98
|
+
const alias = rawValue.replace(/^@+/, "").trim().toLowerCase();
|
|
99
|
+
if (!isRouteValue(alias)) return null;
|
|
100
|
+
return { kind: "route_alias", alias, value: `alias:${alias}` };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function parseSessionRouteTarget(rawValue: string): ScoutRouteTarget | null {
|
|
104
|
+
const value = rawValue.replace(/^@+/, "");
|
|
105
|
+
if (!isRouteValue(value)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const harnessSeparator = value.indexOf(":");
|
|
110
|
+
if (harnessSeparator > 0) {
|
|
111
|
+
const maybeHarness = value.slice(0, harnessSeparator) as AgentHarness;
|
|
112
|
+
const sessionId = value.slice(harnessSeparator + 1);
|
|
113
|
+
if (SESSION_ROUTE_HARNESSES.has(maybeHarness) && isRouteValue(sessionId)) {
|
|
114
|
+
return {
|
|
115
|
+
kind: "session_id",
|
|
116
|
+
sessionId,
|
|
117
|
+
harness: maybeHarness,
|
|
118
|
+
value: `session:${maybeHarness}:${sessionId}`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { kind: "session_id", sessionId: value, value: `session:${value}` };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function parsePrefixedRouteTarget(prefix: string, rawValue: string): ScoutRouteTarget | null {
|
|
127
|
+
const value = rawValue.replace(/^@+/, "");
|
|
128
|
+
if (!isRouteValue(value)) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (prefix === "agent" || prefix === "a") {
|
|
133
|
+
return parseAgentLabelTarget(value);
|
|
134
|
+
}
|
|
135
|
+
if (prefix === "alias" || prefix === "route-alias" || prefix === "route_alias") {
|
|
136
|
+
return parseRouteAliasTarget(rawValue);
|
|
137
|
+
}
|
|
138
|
+
if (prefix === "target" || prefix === "target-handle" || prefix === "target_handle") {
|
|
139
|
+
return parseTargetHandleTarget(rawValue);
|
|
140
|
+
}
|
|
141
|
+
if (prefix === "ref" || prefix === "binding" || prefix === "binding-ref") {
|
|
142
|
+
return { kind: "binding_ref", ref: value, value: `ref:${value}` };
|
|
143
|
+
}
|
|
144
|
+
if (prefix === "project" || prefix === "project-path" || prefix === "project_path") {
|
|
145
|
+
return { kind: "project_path", projectPath: value, value: `project:${value}` };
|
|
146
|
+
}
|
|
147
|
+
if (prefix === "id" || prefix === "agent-id" || prefix === "agent_id") {
|
|
148
|
+
return { kind: "agent_id", agentId: value, value: `id:${value}` };
|
|
149
|
+
}
|
|
150
|
+
if (prefix === "session" || prefix === "session-id" || prefix === "session_id" || prefix === "sid" || prefix === "s") {
|
|
151
|
+
return parseSessionRouteTarget(rawValue);
|
|
152
|
+
}
|
|
153
|
+
if (prefix === "channel" || prefix === "chan" || prefix === "ch") {
|
|
154
|
+
return { kind: "channel", channel: value, value: `channel:${value}` };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function parseScoutComposerRouteTarget(value: string): ScoutRouteTarget | null {
|
|
161
|
+
const token = trimRouteTargetToken(value);
|
|
162
|
+
if (!isRouteValue(token)) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (token === "broadcast") {
|
|
167
|
+
return { kind: "broadcast", value: token };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (token.startsWith(SCOUT_TARGET_HANDLE_SHORTHAND)) {
|
|
171
|
+
return parseTargetHandleTarget(token);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const separatorIndex = token.indexOf(":");
|
|
175
|
+
if (separatorIndex > 0) {
|
|
176
|
+
const prefix = token.slice(0, separatorIndex).toLowerCase();
|
|
177
|
+
const rawValue = token.slice(separatorIndex + 1);
|
|
178
|
+
const prefixed = parsePrefixedRouteTarget(prefix, rawValue);
|
|
179
|
+
if (prefixed) {
|
|
180
|
+
return prefixed;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return parseAgentLabelTarget(token);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function parseScoutComposerRoute(input: string): ScoutComposerRouteParseResult {
|
|
188
|
+
const operator = findRouteOperator(input);
|
|
189
|
+
if (!operator) {
|
|
190
|
+
return {
|
|
191
|
+
route: null,
|
|
192
|
+
body: input.trim(),
|
|
193
|
+
diagnostics: [],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let targetStart = operator.end;
|
|
198
|
+
while (targetStart < input.length && WHITESPACE_PATTERN.test(input[targetStart] ?? "")) {
|
|
199
|
+
targetStart += 1;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (targetStart >= input.length) {
|
|
203
|
+
return {
|
|
204
|
+
route: null,
|
|
205
|
+
body: routeBodyWithoutTarget(input, operator.start, operator.end),
|
|
206
|
+
diagnostics: [{
|
|
207
|
+
code: "missing_target",
|
|
208
|
+
message: "route operator requires a target after >>",
|
|
209
|
+
start: operator.start,
|
|
210
|
+
end: operator.end,
|
|
211
|
+
}],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let targetEnd = targetStart;
|
|
216
|
+
while (targetEnd < input.length && !WHITESPACE_PATTERN.test(input[targetEnd] ?? "")) {
|
|
217
|
+
targetEnd += 1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const rawToken = input.slice(targetStart, targetEnd);
|
|
221
|
+
const token = trimRouteTargetToken(rawToken);
|
|
222
|
+
const target = parseScoutComposerRouteTarget(token);
|
|
223
|
+
if (!target) {
|
|
224
|
+
return {
|
|
225
|
+
route: null,
|
|
226
|
+
body: routeBodyWithoutTarget(input, operator.start, targetEnd),
|
|
227
|
+
diagnostics: [{
|
|
228
|
+
code: "invalid_target",
|
|
229
|
+
message: `invalid route target: ${rawToken}`,
|
|
230
|
+
start: targetStart,
|
|
231
|
+
end: targetEnd,
|
|
232
|
+
}],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
route: {
|
|
238
|
+
operator: SCOUT_COMPOSER_ROUTE_OPERATOR,
|
|
239
|
+
token,
|
|
240
|
+
target,
|
|
241
|
+
operatorStart: operator.start,
|
|
242
|
+
operatorEnd: operator.end,
|
|
243
|
+
targetStart,
|
|
244
|
+
targetEnd,
|
|
245
|
+
},
|
|
246
|
+
body: routeBodyWithoutTarget(input, operator.start, targetEnd),
|
|
247
|
+
diagnostics: [],
|
|
248
|
+
};
|
|
249
|
+
}
|
package/src/scout-delivery.ts
CHANGED
|
@@ -1,23 +1,92 @@
|
|
|
1
1
|
import type { ConversationDefinition } from "./conversations.js";
|
|
2
2
|
import type { MetadataMap, ScoutId } from "./common.js";
|
|
3
|
+
import type {
|
|
4
|
+
CollaborationAcceptanceState,
|
|
5
|
+
CollaborationPriority,
|
|
6
|
+
WorkItemRecord,
|
|
7
|
+
} from "./collaboration.js";
|
|
3
8
|
import type { FlightRecord, InvocationExecutionPreference } from "./invocations.js";
|
|
4
|
-
import type { MessageRecord } from "./messages.js";
|
|
9
|
+
import type { MessageAttachment, MessageRecord } from "./messages.js";
|
|
5
10
|
import type {
|
|
6
11
|
ScoutCallerContext,
|
|
7
12
|
ScoutDispatchRecord,
|
|
8
13
|
ScoutRoutePolicy,
|
|
9
14
|
ScoutRouteTarget,
|
|
10
15
|
} from "./scout-dispatch.js";
|
|
16
|
+
import type { RouteAliasResolutionProof } from "./route-aliases.js";
|
|
17
|
+
import type {
|
|
18
|
+
ScoutExecutionResolution,
|
|
19
|
+
ScoutRuntimeResolutionSource,
|
|
20
|
+
} from "./runtime-execution.js";
|
|
11
21
|
|
|
12
22
|
export type ScoutDeliverIntent = "tell" | "consult";
|
|
13
23
|
|
|
24
|
+
export type ScoutOperatorSignalKind = "notify" | "consult" | "need";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An agent-authored signal for its human operator.
|
|
28
|
+
*
|
|
29
|
+
* The three kinds are separated by what the agent does next, which is the only
|
|
30
|
+
* distinction the operator actually acts on:
|
|
31
|
+
*
|
|
32
|
+
* notify — FYI. The agent keeps going and expects nothing back.
|
|
33
|
+
* consult — input would help, and the agent has already decided what it will
|
|
34
|
+
* do without it (`defaultAction`). Silence is a valid answer.
|
|
35
|
+
* need — the agent cannot proceed. Silence is NOT an answer, so this is
|
|
36
|
+
* the only kind that is blocking, and the only one that raises the
|
|
37
|
+
* operator's needs-you surface.
|
|
38
|
+
*
|
|
39
|
+
* `notify` and `consult` stay conversational side effects: they never create a
|
|
40
|
+
* flight and never imply the agent is waiting. `need` is the exception on
|
|
41
|
+
* purpose — it is the agent declaring that the next move is yours.
|
|
42
|
+
*
|
|
43
|
+
* This is the declared counterpart to harness-level attention inference. An
|
|
44
|
+
* inferred stall says "something looks stuck"; a `need` says "here is exactly
|
|
45
|
+
* what I want from you", authored by the agent, and cannot be created without
|
|
46
|
+
* a question (enforced at the CLI boundary, not filtered downstream).
|
|
47
|
+
*/
|
|
48
|
+
export type ScoutOperatorSignal =
|
|
49
|
+
| {
|
|
50
|
+
kind: "notify";
|
|
51
|
+
blocking: false;
|
|
52
|
+
replyExpectation: "none";
|
|
53
|
+
}
|
|
54
|
+
| {
|
|
55
|
+
kind: "consult";
|
|
56
|
+
blocking: false;
|
|
57
|
+
replyExpectation: "optional";
|
|
58
|
+
defaultAction: string;
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
kind: "need";
|
|
62
|
+
blocking: true;
|
|
63
|
+
replyExpectation: "required";
|
|
64
|
+
/** What the agent is asking for. Never empty — that is the whole point. */
|
|
65
|
+
question: string;
|
|
66
|
+
/** Optional discrete choices, when the answer is a selection. */
|
|
67
|
+
options?: string[];
|
|
68
|
+
/** Why the agent cannot continue without it. */
|
|
69
|
+
blockedReason?: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
14
72
|
export type ScoutDeliverRouteKind = "dm" | "channel" | "broadcast";
|
|
15
73
|
|
|
74
|
+
export type ScoutProjectAgentPersistence = "one_time" | "sticky";
|
|
75
|
+
|
|
76
|
+
export interface ScoutProjectAgentSpec {
|
|
77
|
+
persistence?: ScoutProjectAgentPersistence;
|
|
78
|
+
/** Human-addressable handle, without requiring the caller to include "@". */
|
|
79
|
+
handle?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
16
82
|
export type ScoutDeliveryRemediationKind =
|
|
17
83
|
| "choose_target"
|
|
18
84
|
| "register_target"
|
|
19
85
|
| "wake_target"
|
|
20
86
|
| "retry_later"
|
|
87
|
+
| "use_current_registration"
|
|
88
|
+
| "session_reference_not_attachable"
|
|
89
|
+
/** @deprecated use use_current_registration or session_reference_not_attachable */
|
|
21
90
|
| "stale_reference";
|
|
22
91
|
|
|
23
92
|
export type ScoutDeliverRejectReason =
|
|
@@ -32,20 +101,37 @@ export interface ScoutDeliverRequest {
|
|
|
32
101
|
requesterId?: ScoutId;
|
|
33
102
|
requesterNodeId?: ScoutId;
|
|
34
103
|
body: string;
|
|
104
|
+
attachments?: MessageAttachment[];
|
|
35
105
|
intent: ScoutDeliverIntent;
|
|
36
106
|
target?: ScoutRouteTarget;
|
|
37
107
|
targetLabel?: string;
|
|
38
108
|
targetAgentId?: ScoutId;
|
|
109
|
+
targetSessionId?: ScoutId;
|
|
39
110
|
routePolicy?: ScoutRoutePolicy;
|
|
40
111
|
channel?: string;
|
|
41
112
|
replyToMessageId?: ScoutId;
|
|
113
|
+
replyToSessionId?: ScoutId;
|
|
42
114
|
speechText?: string;
|
|
43
115
|
ensureAwake?: boolean;
|
|
44
116
|
execution?: InvocationExecutionPreference;
|
|
117
|
+
executionSource?: Partial<Record<"harness" | "model" | "reasoningEffort", ScoutRuntimeResolutionSource>>;
|
|
118
|
+
projectAgent?: ScoutProjectAgentSpec;
|
|
119
|
+
labels?: string[];
|
|
45
120
|
createdAt?: number;
|
|
46
121
|
collaborationRecordId?: ScoutId;
|
|
122
|
+
workItem?: {
|
|
123
|
+
id?: ScoutId;
|
|
124
|
+
title: string;
|
|
125
|
+
summary?: string;
|
|
126
|
+
priority?: CollaborationPriority;
|
|
127
|
+
labels?: string[];
|
|
128
|
+
parentId?: ScoutId;
|
|
129
|
+
acceptanceState?: CollaborationAcceptanceState;
|
|
130
|
+
metadata?: MetadataMap;
|
|
131
|
+
};
|
|
47
132
|
messageMetadata?: MetadataMap;
|
|
48
133
|
invocationMetadata?: MetadataMap;
|
|
134
|
+
operatorSignal?: ScoutOperatorSignal;
|
|
49
135
|
}
|
|
50
136
|
|
|
51
137
|
export interface ScoutDeliveryReceipt {
|
|
@@ -54,12 +140,18 @@ export interface ScoutDeliveryReceipt {
|
|
|
54
140
|
requesterId: ScoutId;
|
|
55
141
|
requesterNodeId: ScoutId;
|
|
56
142
|
targetAgentId?: ScoutId;
|
|
143
|
+
targetSessionId?: ScoutId;
|
|
57
144
|
targetLabel?: string;
|
|
145
|
+
/** Provisional routable pointer (e.g. project-chopin) when target is cardless. */
|
|
146
|
+
sessionAlias?: string;
|
|
58
147
|
bindingRef?: string;
|
|
59
148
|
conversationId: ScoutId;
|
|
60
149
|
messageId: ScoutId;
|
|
61
150
|
flightId?: ScoutId;
|
|
151
|
+
/** Per-dimension requested/resolved launch truth available at acceptance. */
|
|
152
|
+
executionResolution?: ScoutExecutionResolution;
|
|
62
153
|
acceptedAt: number;
|
|
154
|
+
aliasResolution?: RouteAliasResolutionProof;
|
|
63
155
|
}
|
|
64
156
|
|
|
65
157
|
export interface ScoutDeliveryRemediationAction {
|
|
@@ -78,17 +170,35 @@ export interface ScoutDeliverAcceptedResponse {
|
|
|
78
170
|
conversation: ConversationDefinition;
|
|
79
171
|
message: MessageRecord;
|
|
80
172
|
targetAgentId?: ScoutId;
|
|
173
|
+
targetSessionId?: ScoutId;
|
|
174
|
+
sessionAlias?: string;
|
|
81
175
|
bindingRef?: string;
|
|
176
|
+
aliasResolution?: RouteAliasResolutionProof;
|
|
82
177
|
flight?: FlightRecord;
|
|
178
|
+
workItem?: WorkItemRecord;
|
|
83
179
|
}
|
|
84
180
|
|
|
85
|
-
|
|
181
|
+
/**
|
|
182
|
+
* A routing clarification: delivery was not accepted and the caller is asked to
|
|
183
|
+
* clarify or re-route the carried {@link ScoutDispatchRecord}. This is unrelated to
|
|
184
|
+
* the collaboration `question` kind ({@link QuestionRecord}) — the `question` field
|
|
185
|
+
* here carries the dispatch, and the wire `kind` discriminant stays `"question"` for
|
|
186
|
+
* backward compatibility.
|
|
187
|
+
*/
|
|
188
|
+
export interface ScoutDeliverClarificationResponse {
|
|
86
189
|
kind: "question";
|
|
87
190
|
accepted: false;
|
|
88
191
|
question: ScoutDispatchRecord;
|
|
89
192
|
remediation?: ScoutDeliveryRemediationAction;
|
|
90
193
|
}
|
|
91
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated Renamed to {@link ScoutDeliverClarificationResponse}. This routing
|
|
197
|
+
* clarification is distinct from the collaboration `question` kind. Retained as an
|
|
198
|
+
* alias for backward compatibility.
|
|
199
|
+
*/
|
|
200
|
+
export type ScoutDeliverQuestionResponse = ScoutDeliverClarificationResponse;
|
|
201
|
+
|
|
92
202
|
export interface ScoutDeliverRejectedResponse {
|
|
93
203
|
kind: "rejected";
|
|
94
204
|
accepted: false;
|
|
@@ -99,5 +209,5 @@ export interface ScoutDeliverRejectedResponse {
|
|
|
99
209
|
|
|
100
210
|
export type ScoutDeliverResponse =
|
|
101
211
|
| ScoutDeliverAcceptedResponse
|
|
102
|
-
|
|
|
212
|
+
| ScoutDeliverClarificationResponse
|
|
103
213
|
| ScoutDeliverRejectedResponse;
|
package/src/scout-dispatch.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import type { WakePolicy } from "./actors.js";
|
|
1
|
+
import type { AgentHarness, WakePolicy } from "./actors.js";
|
|
2
2
|
import type { AdvertiseScope, DeliveryTransport, MetadataMap, ScoutId } from "./common.js";
|
|
3
|
+
import type { RouteAliasDiagnosticCode, RouteAliasResolutionProof, RouteAliasScope } from "./route-aliases.js";
|
|
3
4
|
|
|
4
5
|
export type ScoutDispatchKind = "ambiguous" | "unknown" | "unparseable" | "unavailable";
|
|
5
6
|
|
|
6
7
|
export type ScoutCandidateEndpointState = "online" | "offline" | "unknown";
|
|
7
8
|
|
|
8
|
-
export type ScoutRouteTargetKind =
|
|
9
|
+
export type ScoutRouteTargetKind =
|
|
10
|
+
| "agent_id"
|
|
11
|
+
| "agent_label"
|
|
12
|
+
| "existing_handle"
|
|
13
|
+
| "runtime_profile"
|
|
14
|
+
| "route_alias"
|
|
15
|
+
| "target_handle"
|
|
16
|
+
| "session_id"
|
|
17
|
+
| "binding_ref"
|
|
18
|
+
| "project_path"
|
|
19
|
+
| "channel"
|
|
20
|
+
| "broadcast";
|
|
9
21
|
|
|
10
22
|
export type ScoutRouteAmbiguousPolicy = "reject" | "ask";
|
|
11
23
|
|
|
@@ -21,19 +33,36 @@ export interface ScoutCallerContext {
|
|
|
21
33
|
export type ScoutRouteTarget =
|
|
22
34
|
| { kind: "agent_id"; agentId: ScoutId; value?: string }
|
|
23
35
|
| { kind: "agent_label"; label: string; value?: string }
|
|
36
|
+
| { kind: "existing_handle"; handle: string; value?: string }
|
|
37
|
+
| {
|
|
38
|
+
kind: "runtime_profile";
|
|
39
|
+
profile: string;
|
|
40
|
+
projectPath: string;
|
|
41
|
+
reasoningEffort?: string;
|
|
42
|
+
value?: string;
|
|
43
|
+
}
|
|
44
|
+
| { kind: "route_alias"; alias: string; scope?: RouteAliasScope; bindingId?: ScoutId; value?: string }
|
|
45
|
+
| { kind: "target_handle"; handle: string; value?: string }
|
|
46
|
+
| { kind: "session_id"; sessionId: ScoutId; harness?: AgentHarness; value?: string }
|
|
24
47
|
| { kind: "binding_ref"; ref: string; value?: string }
|
|
48
|
+
| { kind: "project_path"; projectPath: string; value?: string }
|
|
25
49
|
| { kind: "channel"; channel: string; value?: string }
|
|
26
50
|
| { kind: "broadcast"; value?: string };
|
|
27
51
|
|
|
28
52
|
export interface ScoutRoutePolicy {
|
|
29
53
|
preferLocalNodeId?: ScoutId;
|
|
30
54
|
ambiguous?: ScoutRouteAmbiguousPolicy;
|
|
55
|
+
allowHistoricalDirectId?: boolean;
|
|
56
|
+
/** @deprecated use allowHistoricalDirectId */
|
|
31
57
|
allowStaleDirectId?: boolean;
|
|
32
58
|
}
|
|
33
59
|
|
|
34
60
|
export type ScoutDispatchUnavailableReason =
|
|
35
61
|
| "manual_wake_required"
|
|
36
62
|
| "retired"
|
|
63
|
+
| "superseded_registration"
|
|
64
|
+
| "session_reference_not_attachable"
|
|
65
|
+
/** @deprecated use superseded_registration or session_reference_not_attachable */
|
|
37
66
|
| "stale_registration"
|
|
38
67
|
| "unknown";
|
|
39
68
|
|
|
@@ -72,6 +101,8 @@ export interface ScoutDispatchEnvelope {
|
|
|
72
101
|
target?: ScoutDispatchUnavailableTarget;
|
|
73
102
|
dispatchedAt: number;
|
|
74
103
|
dispatcherNodeId: ScoutId;
|
|
104
|
+
diagnosticCode?: RouteAliasDiagnosticCode;
|
|
105
|
+
aliasResolution?: RouteAliasResolutionProof;
|
|
75
106
|
}
|
|
76
107
|
|
|
77
108
|
export interface ScoutDispatchRecord extends ScoutDispatchEnvelope {
|