@dungle-scrubs/harness-cli-normalizer 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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/execution/channel.d.ts +33 -0
- package/dist/execution/channel.d.ts.map +1 -0
- package/dist/execution/channel.js +86 -0
- package/dist/execution/channel.js.map +1 -0
- package/dist/execution/decode.d.ts +16 -0
- package/dist/execution/decode.d.ts.map +1 -0
- package/dist/execution/decode.js +60 -0
- package/dist/execution/decode.js.map +1 -0
- package/dist/execution/deps.d.ts +53 -0
- package/dist/execution/deps.d.ts.map +1 -0
- package/dist/execution/deps.js +8 -0
- package/dist/execution/deps.js.map +1 -0
- package/dist/execution/events.d.ts +54 -0
- package/dist/execution/events.d.ts.map +1 -0
- package/dist/execution/events.js +2 -0
- package/dist/execution/events.js.map +1 -0
- package/dist/execution/index.d.ts +19 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +19 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/lines.d.ts +21 -0
- package/dist/execution/lines.d.ts.map +1 -0
- package/dist/execution/lines.js +70 -0
- package/dist/execution/lines.js.map +1 -0
- package/dist/execution/node-deps.d.ts +13 -0
- package/dist/execution/node-deps.d.ts.map +1 -0
- package/dist/execution/node-deps.js +164 -0
- package/dist/execution/node-deps.js.map +1 -0
- package/dist/execution/open-session.d.ts +31 -0
- package/dist/execution/open-session.d.ts.map +1 -0
- package/dist/execution/open-session.js +360 -0
- package/dist/execution/open-session.js.map +1 -0
- package/dist/execution/stream-turn.d.ts +43 -0
- package/dist/execution/stream-turn.d.ts.map +1 -0
- package/dist/execution/stream-turn.js +283 -0
- package/dist/execution/stream-turn.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/interpretation/argv.d.ts +35 -0
- package/dist/interpretation/argv.d.ts.map +1 -0
- package/dist/interpretation/argv.js +147 -0
- package/dist/interpretation/argv.js.map +1 -0
- package/dist/interpretation/capabilities.d.ts +19 -0
- package/dist/interpretation/capabilities.d.ts.map +1 -0
- package/dist/interpretation/capabilities.js +25 -0
- package/dist/interpretation/capabilities.js.map +1 -0
- package/dist/interpretation/content.d.ts +33 -0
- package/dist/interpretation/content.d.ts.map +1 -0
- package/dist/interpretation/content.js +169 -0
- package/dist/interpretation/content.js.map +1 -0
- package/dist/interpretation/context.d.ts +17 -0
- package/dist/interpretation/context.d.ts.map +1 -0
- package/dist/interpretation/context.js +16 -0
- package/dist/interpretation/context.js.map +1 -0
- package/dist/interpretation/dimensions.d.ts +13 -0
- package/dist/interpretation/dimensions.d.ts.map +1 -0
- package/dist/interpretation/dimensions.js +6 -0
- package/dist/interpretation/dimensions.js.map +1 -0
- package/dist/interpretation/identity.d.ts +32 -0
- package/dist/interpretation/identity.d.ts.map +1 -0
- package/dist/interpretation/identity.js +44 -0
- package/dist/interpretation/identity.js.map +1 -0
- package/dist/interpretation/index.d.ts +23 -0
- package/dist/interpretation/index.d.ts.map +1 -0
- package/dist/interpretation/index.js +23 -0
- package/dist/interpretation/index.js.map +1 -0
- package/dist/interpretation/limits.d.ts +20 -0
- package/dist/interpretation/limits.d.ts.map +1 -0
- package/dist/interpretation/limits.js +35 -0
- package/dist/interpretation/limits.js.map +1 -0
- package/dist/interpretation/parse-resume.d.ts +28 -0
- package/dist/interpretation/parse-resume.d.ts.map +1 -0
- package/dist/interpretation/parse-resume.js +91 -0
- package/dist/interpretation/parse-resume.js.map +1 -0
- package/dist/interpretation/presence.d.ts +16 -0
- package/dist/interpretation/presence.d.ts.map +1 -0
- package/dist/interpretation/presence.js +32 -0
- package/dist/interpretation/presence.js.map +1 -0
- package/dist/interpretation/resume-last.d.ts +32 -0
- package/dist/interpretation/resume-last.d.ts.map +1 -0
- package/dist/interpretation/resume-last.js +70 -0
- package/dist/interpretation/resume-last.js.map +1 -0
- package/dist/interpretation/session-id.d.ts +22 -0
- package/dist/interpretation/session-id.d.ts.map +1 -0
- package/dist/interpretation/session-id.js +29 -0
- package/dist/interpretation/session-id.js.map +1 -0
- package/dist/interpretation/session-input.d.ts +13 -0
- package/dist/interpretation/session-input.d.ts.map +1 -0
- package/dist/interpretation/session-input.js +32 -0
- package/dist/interpretation/session-input.js.map +1 -0
- package/dist/interpretation/shape.d.ts +17 -0
- package/dist/interpretation/shape.d.ts.map +1 -0
- package/dist/interpretation/shape.js +54 -0
- package/dist/interpretation/shape.js.map +1 -0
- package/dist/interpretation/store.d.ts +16 -0
- package/dist/interpretation/store.d.ts.map +1 -0
- package/dist/interpretation/store.js +27 -0
- package/dist/interpretation/store.js.map +1 -0
- package/dist/interpretation/versions.d.ts +16 -0
- package/dist/interpretation/versions.d.ts.map +1 -0
- package/dist/interpretation/versions.js +44 -0
- package/dist/interpretation/versions.js.map +1 -0
- package/dist/interpretation/vocabulary.d.ts +29 -0
- package/dist/interpretation/vocabulary.d.ts.map +1 -0
- package/dist/interpretation/vocabulary.js +55 -0
- package/dist/interpretation/vocabulary.js.map +1 -0
- package/dist/knowledge/claude-code.d.ts +8 -0
- package/dist/knowledge/claude-code.d.ts.map +1 -0
- package/dist/knowledge/claude-code.js +132 -0
- package/dist/knowledge/claude-code.js.map +1 -0
- package/dist/knowledge/codex.d.ts +9 -0
- package/dist/knowledge/codex.d.ts.map +1 -0
- package/dist/knowledge/codex.js +106 -0
- package/dist/knowledge/codex.js.map +1 -0
- package/dist/knowledge/descriptor.d.ts +211 -0
- package/dist/knowledge/descriptor.d.ts.map +1 -0
- package/dist/knowledge/descriptor.js +20 -0
- package/dist/knowledge/descriptor.js.map +1 -0
- package/dist/knowledge/index.d.ts +19 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +19 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/matchers.d.ts +10 -0
- package/dist/knowledge/matchers.d.ts.map +1 -0
- package/dist/knowledge/matchers.js +11 -0
- package/dist/knowledge/matchers.js.map +1 -0
- package/dist/knowledge/muse.d.ts +12 -0
- package/dist/knowledge/muse.d.ts.map +1 -0
- package/dist/knowledge/muse.js +94 -0
- package/dist/knowledge/muse.js.map +1 -0
- package/dist/knowledge/overrides.d.ts +11 -0
- package/dist/knowledge/overrides.d.ts.map +1 -0
- package/dist/knowledge/overrides.js +166 -0
- package/dist/knowledge/overrides.js.map +1 -0
- package/dist/knowledge/pi.d.ts +11 -0
- package/dist/knowledge/pi.d.ts.map +1 -0
- package/dist/knowledge/pi.js +97 -0
- package/dist/knowledge/pi.js.map +1 -0
- package/package.json +69 -0
- package/src/execution/channel.ts +86 -0
- package/src/execution/decode.ts +79 -0
- package/src/execution/deps.ts +59 -0
- package/src/execution/events.ts +37 -0
- package/src/execution/index.ts +18 -0
- package/src/execution/lines.ts +71 -0
- package/src/execution/node-deps.ts +179 -0
- package/src/execution/open-session.ts +392 -0
- package/src/execution/stream-turn.ts +310 -0
- package/src/index.ts +7 -0
- package/src/interpretation/argv.ts +188 -0
- package/src/interpretation/capabilities.ts +51 -0
- package/src/interpretation/content.ts +191 -0
- package/src/interpretation/context.ts +28 -0
- package/src/interpretation/dimensions.ts +20 -0
- package/src/interpretation/identity.ts +81 -0
- package/src/interpretation/index.ts +22 -0
- package/src/interpretation/limits.ts +63 -0
- package/src/interpretation/parse-resume.ts +117 -0
- package/src/interpretation/presence.ts +49 -0
- package/src/interpretation/resume-last.ts +93 -0
- package/src/interpretation/session-id.ts +35 -0
- package/src/interpretation/session-input.ts +45 -0
- package/src/interpretation/shape.ts +55 -0
- package/src/interpretation/store.ts +43 -0
- package/src/interpretation/versions.ts +43 -0
- package/src/interpretation/vocabulary.ts +74 -0
- package/src/knowledge/claude-code.ts +132 -0
- package/src/knowledge/codex.ts +106 -0
- package/src/knowledge/descriptor.ts +217 -0
- package/src/knowledge/index.ts +23 -0
- package/src/knowledge/matchers.ts +19 -0
- package/src/knowledge/muse.ts +94 -0
- package/src/knowledge/overrides.ts +182 -0
- package/src/knowledge/pi.ts +97 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* streamTurn: the spawn-per-turn headless runner. Spawn, drain both stdio
|
|
3
|
+
* streams concurrently, decode typed HarnessEvents, watchdog stalls (only
|
|
4
|
+
* for none-granularity invocations - a structured stream proves its own
|
|
5
|
+
* liveness), classify the exit, always end with `done` (spawn failures
|
|
6
|
+
* included). Runtime primitives are injected (D-005); structured boundary
|
|
7
|
+
* events (spawn/exit/stall, argv redacted by POSITION) are always-on
|
|
8
|
+
* evidence, not diagnostics. An abandoned turn (consumer breaks early)
|
|
9
|
+
* closes backpressure, disposes output, stops the child, and awaits both
|
|
10
|
+
* pumps before it returns.
|
|
11
|
+
*/
|
|
12
|
+
import { buildLaunchArgv, buildResumeArgv, streamingGranularityOf, } from "../interpretation/argv.js";
|
|
13
|
+
import { stdinPolicyOf } from "../interpretation/dimensions.js";
|
|
14
|
+
import { detectAuthFailureInLine, detectLimitInLine } from "../interpretation/limits.js";
|
|
15
|
+
import { AsyncChannel } from "./channel.js";
|
|
16
|
+
import { decodeLine, freshDecodeState } from "./decode.js";
|
|
17
|
+
import { LineBuffer } from "./lines.js";
|
|
18
|
+
/** Fallback correlation when the host does not mint turn ids: monotonic per
|
|
19
|
+
* process. Hosts that need cross-process uniqueness pass deps.turnId. */
|
|
20
|
+
let turnCounter = 0;
|
|
21
|
+
/** SIGTERM -> SIGKILL escalation budget for a child that ignores the first
|
|
22
|
+
* signal, and the grace allowed for pipes still held open (by a grandchild)
|
|
23
|
+
* after the process itself exited. */
|
|
24
|
+
export const KILL_GRACE_MS = 5_000;
|
|
25
|
+
export const PIPE_GRACE_MS = 2_000;
|
|
26
|
+
const OUTPUT_STREAMS = ["stdout", "stderr"];
|
|
27
|
+
const pumpFailureMessage = (stream, cause) => `${stream} pump failed: ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
28
|
+
/** Stray secret-shaped tokens are masked; identifiers (session UUIDs, model
|
|
29
|
+
* ids, paths) log verbatim - they are what the log exists to correlate. */
|
|
30
|
+
const SECRETISH = /(sk-[A-Za-z0-9_-]{8,}|(?:token|key|secret|password)=\S+)/i;
|
|
31
|
+
/** Redact by POSITION, not shape: the prompt is a known argv slot and is
|
|
32
|
+
* masked wholesale (content never reaches a log line - v1 D-005); every
|
|
33
|
+
* other token is kept unless it is secret-shaped. */
|
|
34
|
+
export const redactArgv = (argv, prompt) => argv.map((token) => {
|
|
35
|
+
if (prompt !== undefined && token === prompt)
|
|
36
|
+
return `[prompt:${prompt.length}ch]`;
|
|
37
|
+
if (SECRETISH.test(token))
|
|
38
|
+
return "[redacted]";
|
|
39
|
+
return token;
|
|
40
|
+
});
|
|
41
|
+
/** Bounded tail of unmatched stderr - the crash context a nonzero exit is
|
|
42
|
+
* explained by (v1 kept the turn's output slice for exactly this). Shared
|
|
43
|
+
* with the session runner. */
|
|
44
|
+
export class StderrTail {
|
|
45
|
+
lines = [];
|
|
46
|
+
bytes = 0;
|
|
47
|
+
push(line) {
|
|
48
|
+
this.lines.push(line);
|
|
49
|
+
this.bytes += line.length;
|
|
50
|
+
while (this.lines.length > 20 || (this.bytes > 4096 && this.lines.length > 1)) {
|
|
51
|
+
const dropped = this.lines.shift();
|
|
52
|
+
this.bytes -= dropped?.length ?? 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
snapshot() {
|
|
56
|
+
return [...this.lines];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export async function* streamTurn(h, opts, deps) {
|
|
60
|
+
const turnId = deps.turnId ?? `turn-${++turnCounter}`;
|
|
61
|
+
const log = deps.log ?? (() => { });
|
|
62
|
+
const argv = opts.resume === undefined
|
|
63
|
+
? buildLaunchArgv(h, opts)
|
|
64
|
+
: buildResumeArgv(h, { ...opts, sessionId: opts.resume });
|
|
65
|
+
const granularity = streamingGranularityOf(h, argv);
|
|
66
|
+
log({
|
|
67
|
+
event: "spawn",
|
|
68
|
+
turnId,
|
|
69
|
+
harness: h.name,
|
|
70
|
+
argv: redactArgv(argv, opts.prompt),
|
|
71
|
+
granularity,
|
|
72
|
+
});
|
|
73
|
+
let proc;
|
|
74
|
+
try {
|
|
75
|
+
proc = deps.spawn(argv, {
|
|
76
|
+
stdin: stdinPolicyOf(h) === "close-required" ? "close" : "inherit",
|
|
77
|
+
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (cause) {
|
|
81
|
+
// A spawn that cannot start still honors the contract: error, done,
|
|
82
|
+
// and a closed exit log - never a throw out of the first next().
|
|
83
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
84
|
+
log({
|
|
85
|
+
event: "exit",
|
|
86
|
+
turnId,
|
|
87
|
+
harness: h.name,
|
|
88
|
+
exitCode: 127,
|
|
89
|
+
cause: "crash",
|
|
90
|
+
spawnError: message,
|
|
91
|
+
});
|
|
92
|
+
yield { kind: "error", message: `spawn failed: ${message}` };
|
|
93
|
+
yield { kind: "done", exitCode: 127, cause: "crash" };
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const queue = new AsyncChannel();
|
|
97
|
+
const state = freshDecodeState(opts.resume ?? null);
|
|
98
|
+
const stderrTail = new StderrTail();
|
|
99
|
+
let killedByWatchdog = false;
|
|
100
|
+
let exited = false;
|
|
101
|
+
let exitCode = null;
|
|
102
|
+
let pipesOpenAtExit = false;
|
|
103
|
+
let cancelled = false;
|
|
104
|
+
let terminalEventReached = false;
|
|
105
|
+
const safeSignal = (sig) => {
|
|
106
|
+
if (!exited)
|
|
107
|
+
deps.signal(proc, sig);
|
|
108
|
+
};
|
|
109
|
+
let escalationTimer = null;
|
|
110
|
+
const escalate = () => {
|
|
111
|
+
if (exited || escalationTimer !== null)
|
|
112
|
+
return;
|
|
113
|
+
safeSignal("SIGTERM");
|
|
114
|
+
escalationTimer = deps.clock.setTimeout(() => {
|
|
115
|
+
escalationTimer = null;
|
|
116
|
+
safeSignal("SIGKILL");
|
|
117
|
+
}, KILL_GRACE_MS);
|
|
118
|
+
};
|
|
119
|
+
let watchdog = null;
|
|
120
|
+
const disarm = () => {
|
|
121
|
+
if (watchdog !== null)
|
|
122
|
+
deps.clock.clearTimeout(watchdog);
|
|
123
|
+
watchdog = null;
|
|
124
|
+
};
|
|
125
|
+
const rearm = () => {
|
|
126
|
+
if (granularity !== "none" || deps.stallMs === undefined)
|
|
127
|
+
return;
|
|
128
|
+
disarm();
|
|
129
|
+
watchdog = deps.clock.setTimeout(() => {
|
|
130
|
+
killedByWatchdog = true;
|
|
131
|
+
log({ event: "stall", turnId, harness: h.name, stallMs: deps.stallMs });
|
|
132
|
+
escalate();
|
|
133
|
+
}, deps.stallMs);
|
|
134
|
+
};
|
|
135
|
+
rearm();
|
|
136
|
+
let pipeGrace = null;
|
|
137
|
+
void proc.exited.then((code) => {
|
|
138
|
+
exited = true;
|
|
139
|
+
exitCode = code;
|
|
140
|
+
if (escalationTimer !== null)
|
|
141
|
+
deps.clock.clearTimeout(escalationTimer);
|
|
142
|
+
escalationTimer = null;
|
|
143
|
+
// The process is gone: the watchdog has nothing left to kill, and a
|
|
144
|
+
// fire after this point would flip a completed turn to "stall".
|
|
145
|
+
disarm();
|
|
146
|
+
// Pipes held open past exit (a grandchild inherited the fd) must not
|
|
147
|
+
// hang the turn forever - close out with the exit code in hand.
|
|
148
|
+
if (cancelled)
|
|
149
|
+
return;
|
|
150
|
+
pipeGrace = deps.clock.setTimeout(() => {
|
|
151
|
+
pipesOpenAtExit = true;
|
|
152
|
+
proc.disposeOutput();
|
|
153
|
+
}, PIPE_GRACE_MS);
|
|
154
|
+
});
|
|
155
|
+
const pumpStdout = async () => {
|
|
156
|
+
const lines = new LineBuffer();
|
|
157
|
+
for await (const chunk of proc.stdout) {
|
|
158
|
+
if (cancelled)
|
|
159
|
+
break;
|
|
160
|
+
rearm();
|
|
161
|
+
for (const line of lines.push(chunk)) {
|
|
162
|
+
for (const event of decodeLine(h, line, state, opts.model ?? "")) {
|
|
163
|
+
await queue.push(event);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const rest = lines.flush();
|
|
168
|
+
if (rest !== null && !cancelled) {
|
|
169
|
+
for (const event of decodeLine(h, rest, state, opts.model ?? ""))
|
|
170
|
+
await queue.push(event);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const pumpStderr = async () => {
|
|
174
|
+
const lines = new LineBuffer();
|
|
175
|
+
for await (const chunk of proc.stderr) {
|
|
176
|
+
if (cancelled)
|
|
177
|
+
break;
|
|
178
|
+
rearm();
|
|
179
|
+
for (const line of lines.push(chunk)) {
|
|
180
|
+
const limit = detectLimitInLine(h, line);
|
|
181
|
+
if (limit !== null) {
|
|
182
|
+
state.limitSeen = true;
|
|
183
|
+
await queue.push({
|
|
184
|
+
kind: "limit",
|
|
185
|
+
code: limit,
|
|
186
|
+
message: `limit wall detected (${limit})`,
|
|
187
|
+
});
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const auth = detectAuthFailureInLine(h, line);
|
|
191
|
+
if (auth !== null) {
|
|
192
|
+
await queue.push({ kind: "error", message: `auth wall: ${auth}` });
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
stderrTail.push(line);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const observePump = async (stream, pump) => {
|
|
200
|
+
try {
|
|
201
|
+
await pump;
|
|
202
|
+
}
|
|
203
|
+
catch (cause) {
|
|
204
|
+
log({
|
|
205
|
+
event: "output_pump_failed",
|
|
206
|
+
turnId,
|
|
207
|
+
harness: h.name,
|
|
208
|
+
stream,
|
|
209
|
+
issue: "read-failed",
|
|
210
|
+
});
|
|
211
|
+
await queue.push({ kind: "error", message: pumpFailureMessage(stream, cause) });
|
|
212
|
+
escalate();
|
|
213
|
+
await proc.exited;
|
|
214
|
+
proc.disposeOutput();
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const pumpSettlements = Promise.all([
|
|
218
|
+
observePump("stdout", pumpStdout()),
|
|
219
|
+
observePump("stderr", pumpStderr()),
|
|
220
|
+
]);
|
|
221
|
+
void Promise.all([proc.exited, pumpSettlements]).then(() => queue.close());
|
|
222
|
+
try {
|
|
223
|
+
for await (const event of queue)
|
|
224
|
+
yield event;
|
|
225
|
+
const cause = state.limitSeen
|
|
226
|
+
? "limit"
|
|
227
|
+
: killedByWatchdog && exitCode !== 0
|
|
228
|
+
? "stall"
|
|
229
|
+
: exitCode === 0
|
|
230
|
+
? "clean"
|
|
231
|
+
: exitCode === null
|
|
232
|
+
? "killed"
|
|
233
|
+
: "crash";
|
|
234
|
+
const tail = stderrTail.snapshot();
|
|
235
|
+
log({
|
|
236
|
+
event: "exit",
|
|
237
|
+
turnId,
|
|
238
|
+
harness: h.name,
|
|
239
|
+
exitCode,
|
|
240
|
+
cause,
|
|
241
|
+
...(pipesOpenAtExit ? { pipesOpenAtExit } : {}),
|
|
242
|
+
...(cause === "crash" || cause === "stall" || cause === "killed" ? { stderrTail: tail } : {}),
|
|
243
|
+
});
|
|
244
|
+
// A failure with captured stderr surfaces as a stream-level error, not
|
|
245
|
+
// only in the exit log - so a crash from the real adapter's async spawn
|
|
246
|
+
// failure carries the same error-event signal as the sync-throw path.
|
|
247
|
+
if ((cause === "crash" || cause === "killed") && tail.length > 0) {
|
|
248
|
+
yield { kind: "error", message: tail.join("\n").slice(0, 4096) };
|
|
249
|
+
}
|
|
250
|
+
terminalEventReached = true;
|
|
251
|
+
yield { kind: "done", exitCode, cause };
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
const abandoned = !terminalEventReached;
|
|
255
|
+
cancelled = true;
|
|
256
|
+
queue.close();
|
|
257
|
+
disarm();
|
|
258
|
+
if (abandoned) {
|
|
259
|
+
log({ event: "abandoned", turnId, harness: h.name });
|
|
260
|
+
if (!exited)
|
|
261
|
+
escalate();
|
|
262
|
+
}
|
|
263
|
+
proc.disposeOutput();
|
|
264
|
+
const [settledExit] = await Promise.all([proc.exited, pumpSettlements]);
|
|
265
|
+
exitCode = settledExit;
|
|
266
|
+
if (pipeGrace !== null)
|
|
267
|
+
deps.clock.clearTimeout(pipeGrace);
|
|
268
|
+
pipeGrace = null;
|
|
269
|
+
if (escalationTimer !== null)
|
|
270
|
+
deps.clock.clearTimeout(escalationTimer);
|
|
271
|
+
escalationTimer = null;
|
|
272
|
+
if (abandoned) {
|
|
273
|
+
log({
|
|
274
|
+
event: "abandonment_settled",
|
|
275
|
+
turnId,
|
|
276
|
+
harness: h.name,
|
|
277
|
+
exitCode,
|
|
278
|
+
outputDisposed: true,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=stream-turn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-turn.js","sourceRoot":"","sources":["../../src/execution/stream-turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,eAAe,EACf,eAAe,EAEf,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;yEACyE;AACzE,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;sCAEsC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAErD,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I,SAAS,EAAE,CAAC;YACd,GAAG,CAAC;gBACF,KAAK,EAAE,qBAAqB;gBAC5B,MAAM;gBACN,OAAO,EAAE,CAAC,CAAC,IAAI;gBACf,QAAQ;gBACR,cAAc,EAAE,IAAI;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public package surface. The three architectural layers remain available as
|
|
3
|
+
* explicit subpath exports for consumers that want the narrowest dependency.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./execution/index.js";
|
|
6
|
+
export * from "./interpretation/index.js";
|
|
7
|
+
export * from "./knowledge/index.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public package surface. The three architectural layers remain available as
|
|
3
|
+
* explicit subpath exports for consumers that want the narrowest dependency.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./execution/index.js";
|
|
6
|
+
export * from "./interpretation/index.js";
|
|
7
|
+
export * from "./knowledge/index.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argv construction: pure functions turning a descriptor + launch options
|
|
3
|
+
* into the exact argv a spawner would exec. Ordering rules (positional
|
|
4
|
+
* prompt before tool grants) and the spawn-boundary refusals live here so
|
|
5
|
+
* no caller re-derives them.
|
|
6
|
+
*/
|
|
7
|
+
import type { HarnessDescriptor, StreamingGranularity } from "../knowledge/descriptor.js";
|
|
8
|
+
/** Raised when launch options would corrupt or subvert the spawned argv. */
|
|
9
|
+
export declare class ArgvRefusalError extends Error {
|
|
10
|
+
readonly issue: string;
|
|
11
|
+
constructor(issue: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
export interface TurnOptions {
|
|
14
|
+
readonly prompt: string;
|
|
15
|
+
readonly tools?: readonly string[];
|
|
16
|
+
readonly model?: string;
|
|
17
|
+
readonly autonomy?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ResumeOptions extends TurnOptions {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
}
|
|
22
|
+
export type LaunchOptions = TurnOptions;
|
|
23
|
+
export declare const buildLaunchArgv: (h: HarnessDescriptor, opts: LaunchOptions) => string[];
|
|
24
|
+
export declare const buildResumeArgv: (h: HarnessDescriptor, opts: ResumeOptions) => string[];
|
|
25
|
+
export interface SessionOptions {
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly model?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const buildSessionArgv: (h: HarnessDescriptor, opts: SessionOptions) => string[];
|
|
30
|
+
/** The granularity an invocation will actually emit: pins are checked in
|
|
31
|
+
* order, first fully-satisfied pin wins (every member present with its
|
|
32
|
+
* pinned value, last occurrence winning like the CLIs themselves); an argv
|
|
33
|
+
* satisfying no pin gets the floor. */
|
|
34
|
+
export declare const streamingGranularityOf: (h: HarnessDescriptor, argv: readonly string[]) => StreamingGranularity;
|
|
35
|
+
//# sourceMappingURL=argv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.d.ts","sourceRoot":"","sources":["../../src/interpretation/argv.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAI1F,4EAA4E;AAC5E,qBAAa,gBAAiB,SAAQ,KAAK;IAEvC,QAAQ,CAAC,KAAK,EAAE,MAAM;IADxB,YACW,KAAK,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EAIhB;CACF;AAcD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC;AA+BxC,eAAO,MAAM,eAAe,MAAO,iBAAiB,QAAQ,aAAa,KAAG,MAAM,EAIjF,CAAC;AAEF,eAAO,MAAM,eAAe,MAAO,iBAAiB,QAAQ,aAAa,KAAG,MAAM,EAejF,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,gBAAgB,MAAO,iBAAiB,QAAQ,cAAc,KAAG,MAAM,EAqBnF,CAAC;AAiDF;;;uCAGuC;AACvC,eAAO,MAAM,sBAAsB,MAC9B,iBAAiB,QACd,SAAS,MAAM,EAAE,KACtB,oBAOF,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { assertUsableSessionId } from "./session-id.js";
|
|
2
|
+
import { validateModel } from "./vocabulary.js";
|
|
3
|
+
/** Raised when launch options would corrupt or subvert the spawned argv. */
|
|
4
|
+
export class ArgvRefusalError extends Error {
|
|
5
|
+
issue;
|
|
6
|
+
constructor(issue, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.issue = issue;
|
|
9
|
+
this.name = "ArgvRefusalError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** One guard for every builder that places a positional prompt. Selector
|
|
13
|
+
* hygiene (session ids) lives in session-id.ts; model selectors go through
|
|
14
|
+
* validateModel - both refuse, never sanitize. */
|
|
15
|
+
const assertCleanPrompt = (h, prompt) => {
|
|
16
|
+
if (prompt.startsWith("-")) {
|
|
17
|
+
throw new ArgvRefusalError("prompt-flag-injection", `positional prompt may not start with '-'; it would be parsed as a flag by ${h.bin}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** The shared tail of every headless-turn argv: prompt, stream flags, then
|
|
21
|
+
* validated selections, with the variadic tools flag LAST and fed exactly
|
|
22
|
+
* one joined token so nothing after it can be swallowed as a tool name. */
|
|
23
|
+
const turnTail = (h, opts) => {
|
|
24
|
+
assertCleanPrompt(h, opts.prompt);
|
|
25
|
+
const tail = [opts.prompt, ...h.launch.streamFlags];
|
|
26
|
+
if (opts.model !== undefined) {
|
|
27
|
+
const validated = validateModel(h, opts.model);
|
|
28
|
+
if (!validated.ok)
|
|
29
|
+
throw new ArgvRefusalError("unknown-model", validated.reason);
|
|
30
|
+
tail.push(h.vocabulary.modelFlag, validated.id);
|
|
31
|
+
}
|
|
32
|
+
if (opts.autonomy === true) {
|
|
33
|
+
if (h.autonomy === null) {
|
|
34
|
+
throw new ArgvRefusalError("no-autonomy-mode", `${h.bin} has no unattended-run flag`);
|
|
35
|
+
}
|
|
36
|
+
tail.push(h.autonomy.flag);
|
|
37
|
+
}
|
|
38
|
+
if (opts.tools !== undefined && h.launch.toolsFlag !== null) {
|
|
39
|
+
if (opts.tools.length === 0 || opts.tools.some((t) => t.trim() === "" || t.includes(","))) {
|
|
40
|
+
throw new ArgvRefusalError("invalid-tool-grant", `tool grant for ${h.bin} contains an empty entry or a comma; a blank ${h.launch.toolsFlag} value grants nothing detectable, and a comma inside one name silently splits the grant`);
|
|
41
|
+
}
|
|
42
|
+
tail.push(h.launch.toolsFlag, opts.tools.join(","));
|
|
43
|
+
}
|
|
44
|
+
return tail;
|
|
45
|
+
};
|
|
46
|
+
export const buildLaunchArgv = (h, opts) => [
|
|
47
|
+
h.bin,
|
|
48
|
+
...h.launch.baseFlags,
|
|
49
|
+
...turnTail(h, opts),
|
|
50
|
+
];
|
|
51
|
+
export const buildResumeArgv = (h, opts) => {
|
|
52
|
+
assertUsableSessionId(opts.sessionId);
|
|
53
|
+
// Subcommands lead, then the resume token and id, then the flags the
|
|
54
|
+
// RESUME grammar accepts (never inherited launch flags - codex exec
|
|
55
|
+
// resume rejects --sandbox). One shape serves both styles:
|
|
56
|
+
// `claude --resume <id> -p <prompt>`, `codex exec resume <id> --json
|
|
57
|
+
// <prompt>`, `muse exec --session-id <id> <prompt>`.
|
|
58
|
+
return [
|
|
59
|
+
h.bin,
|
|
60
|
+
...h.launch.subcommands,
|
|
61
|
+
h.resume.flag,
|
|
62
|
+
opts.sessionId,
|
|
63
|
+
...h.resume.extraFlags,
|
|
64
|
+
...turnTail(h, opts),
|
|
65
|
+
];
|
|
66
|
+
};
|
|
67
|
+
export const buildSessionArgv = (h, opts) => {
|
|
68
|
+
if (!h.sessionMode) {
|
|
69
|
+
throw new ArgvRefusalError("no-session-mode", `${h.bin} declares no persistent headless session mode`);
|
|
70
|
+
}
|
|
71
|
+
assertUsableSessionId(opts.sessionId);
|
|
72
|
+
const argv = [
|
|
73
|
+
h.bin,
|
|
74
|
+
...h.launch.baseFlags,
|
|
75
|
+
...h.sessionMode.flags,
|
|
76
|
+
h.sessionMode.idFlag,
|
|
77
|
+
opts.sessionId,
|
|
78
|
+
];
|
|
79
|
+
if (opts.model !== undefined) {
|
|
80
|
+
const validated = validateModel(h, opts.model);
|
|
81
|
+
if (!validated.ok)
|
|
82
|
+
throw new ArgvRefusalError("unknown-model", validated.reason);
|
|
83
|
+
argv.push(h.vocabulary.modelFlag, validated.id);
|
|
84
|
+
}
|
|
85
|
+
return argv;
|
|
86
|
+
};
|
|
87
|
+
/** Canonicalize an argv into a last-wins flag map: `--flag=value` splits,
|
|
88
|
+
* `--flag value` consumes the following non-flag token as its value, a flag
|
|
89
|
+
* followed by another flag is boolean. Positional tokens are skipped, so a
|
|
90
|
+
* value can never satisfy a boolean pin member. Aliases map onto canonical
|
|
91
|
+
* spellings. Known limitation: a crafted argv giving a pin member as the
|
|
92
|
+
* value of an unknown variadic flag can still false-positive - full CLI
|
|
93
|
+
* grammar is unknowable from outside. */
|
|
94
|
+
const flagMapOf = (h, argv) => {
|
|
95
|
+
const map = new Map();
|
|
96
|
+
for (let i = 1; i < argv.length; i++) {
|
|
97
|
+
const token = argv[i];
|
|
98
|
+
if (token === undefined || !token.startsWith("-"))
|
|
99
|
+
continue;
|
|
100
|
+
const eq = token.indexOf("=");
|
|
101
|
+
if (eq !== -1) {
|
|
102
|
+
const name = token.slice(0, eq);
|
|
103
|
+
map.set(h.output.flagAliases[name] ?? name, token.slice(eq + 1));
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const name = h.output.flagAliases[token] ?? token;
|
|
107
|
+
const next = argv[i + 1];
|
|
108
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
109
|
+
map.set(name, next);
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
map.set(name, true);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return map;
|
|
117
|
+
};
|
|
118
|
+
const pinSatisfied = (pin, flags) => {
|
|
119
|
+
for (let i = 0; i < pin.length; i++) {
|
|
120
|
+
const member = pin[i];
|
|
121
|
+
if (member === undefined || !member.startsWith("-"))
|
|
122
|
+
continue;
|
|
123
|
+
const expected = pin[i + 1];
|
|
124
|
+
const actual = flags.get(member);
|
|
125
|
+
if (actual === undefined)
|
|
126
|
+
return false;
|
|
127
|
+
if (expected !== undefined && !expected.startsWith("-") && actual !== expected) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
/** The granularity an invocation will actually emit: pins are checked in
|
|
134
|
+
* order, first fully-satisfied pin wins (every member present with its
|
|
135
|
+
* pinned value, last occurrence winning like the CLIs themselves); an argv
|
|
136
|
+
* satisfying no pin gets the floor. */
|
|
137
|
+
export const streamingGranularityOf = (h, argv) => {
|
|
138
|
+
if (h.output.pins.length === 0)
|
|
139
|
+
return h.output.floor;
|
|
140
|
+
const flags = flagMapOf(h, argv);
|
|
141
|
+
for (const pin of h.output.pins) {
|
|
142
|
+
if (pinSatisfied(pin.flags, flags))
|
|
143
|
+
return pin.granularity;
|
|
144
|
+
}
|
|
145
|
+
return h.output.floor;
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.js","sourceRoot":"","sources":["../../src/interpretation/argv.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAE9B,KAAK;IADhB,YACW,KAAa,EACtB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;qBAHN,KAAK;QAId,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;kDAEkD;AAClD,MAAM,iBAAiB,GAAG,CAAC,CAAoB,EAAE,MAAc,EAAQ,EAAE;IACvE,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,gBAAgB,CACxB,uBAAuB,EACvB,6EAA6E,CAAC,CAAC,GAAG,EAAE,CACrF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAeF;;2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,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;uCAGuC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,CAAoB,EACpB,IAAuB,EACD,EAAE;IACxB,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC,WAAW,CAAC;IAC7D,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability resolution: capabilitiesOf(h, model, mode) answers what this
|
|
3
|
+
* harness/model/mode combination can actually do, always with a source.
|
|
4
|
+
* This layer serves the CURATED baseline (or degrades to unknown for a
|
|
5
|
+
* model outside the vocabulary); runtime verification against a live
|
|
6
|
+
* harness/registry happens at attach time in the consumer, which upgrades
|
|
7
|
+
* source to runtime-verified. An LLM self-asserting capability is neither.
|
|
8
|
+
*/
|
|
9
|
+
import type { HarnessDescriptor, HarnessMode, StreamingGranularity } from "../knowledge/descriptor.js";
|
|
10
|
+
export interface CapabilityResult {
|
|
11
|
+
readonly vision: boolean;
|
|
12
|
+
readonly images: boolean;
|
|
13
|
+
readonly streaming: StreamingGranularity;
|
|
14
|
+
readonly session: boolean;
|
|
15
|
+
readonly source: "runtime-verified" | "curated" | "unknown";
|
|
16
|
+
readonly confidence: "high" | "medium" | "none";
|
|
17
|
+
}
|
|
18
|
+
export declare const capabilitiesOf: (h: HarnessDescriptor, model: string, mode: HarnessMode) => CapabilityResult;
|
|
19
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/interpretation/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CACjD;AAED,eAAO,MAAM,cAAc,MACtB,iBAAiB,SACb,MAAM,QACP,WAAW,KAChB,gBAsBF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { resolveModel } from "./vocabulary.js";
|
|
2
|
+
export const capabilitiesOf = (h, model, mode) => {
|
|
3
|
+
if (!resolveModel(h, model).curated) {
|
|
4
|
+
// Curated claims cover curated models only - an extensible registry's
|
|
5
|
+
// unknown model still degrades here until runtime verification.
|
|
6
|
+
// Degrade: no raw-image claims, no streaming claims - transcribe/hold.
|
|
7
|
+
return {
|
|
8
|
+
vision: false,
|
|
9
|
+
images: false,
|
|
10
|
+
streaming: "none",
|
|
11
|
+
session: false,
|
|
12
|
+
source: "unknown",
|
|
13
|
+
confidence: "none",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
vision: h.capabilities.vision,
|
|
18
|
+
images: h.capabilities.images,
|
|
19
|
+
streaming: h.capabilities.streamingByMode[mode],
|
|
20
|
+
session: h.capabilities.session,
|
|
21
|
+
source: "curated",
|
|
22
|
+
confidence: "medium",
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/interpretation/capabilities.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,CAAoB,EACpB,KAAa,EACb,IAAiB,EACC,EAAE;IACpB,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QACpC,sEAAsE;QACtE,gEAAgE;QAChE,uEAAuE;QACvE,OAAO;YACL,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,MAAM;YACjB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,MAAM;SACnB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;QAC7B,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;QAC7B,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC;QAC/C,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,OAAO;QAC/B,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,QAAQ;KACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content decoding: extract assistant text, token deltas, tool calls, and
|
|
3
|
+
* progress from ONE parsed harness record. Each harness has an entirely
|
|
4
|
+
* different event vocabulary, so this dispatches by harness name to a pure
|
|
5
|
+
* per-harness reader. Identity and wall detection stay descriptor-driven
|
|
6
|
+
* elsewhere; this owns the message/token/tool/progress classes only.
|
|
7
|
+
*
|
|
8
|
+
* (Kept as functions rather than descriptor data because the shapes are
|
|
9
|
+
* structurally too varied - array-of-blocks text, nested delta events,
|
|
10
|
+
* payload-discriminated records - for the flat match/field spec that
|
|
11
|
+
* identity decoding uses.)
|
|
12
|
+
*/
|
|
13
|
+
import type { HarnessName } from "../knowledge/descriptor.js";
|
|
14
|
+
export type ContentEvent = {
|
|
15
|
+
readonly kind: "token";
|
|
16
|
+
readonly text: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "message";
|
|
19
|
+
readonly role: string;
|
|
20
|
+
readonly text: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "tool";
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly input?: unknown;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "progress";
|
|
27
|
+
readonly label: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "error";
|
|
30
|
+
readonly message: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const contentEventsOf: (harness: HarnessName, raw: unknown) => ContentEvent[];
|
|
33
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/interpretation/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAsKzD,eAAO,MAAM,eAAe,YAAa,WAAW,OAAO,OAAO,KAAG,YAAY,EAIhF,CAAC"}
|