omp-superagent 0.1.18 → 0.1.19
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/docs/OPERATIONS.en.md +127 -30
- package/docs/OPERATIONS.md +114 -27
- package/docs/design/execution.md +90 -23
- package/docs/design/messaging.md +34 -2
- package/docs/releases/0.1.19.md +10 -0
- package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
- package/gateway/bin/omp-gateway-darwin-x64 +0 -0
- package/gateway/bin/omp-gateway-linux-arm64 +0 -0
- package/gateway/bin/omp-gateway-linux-x64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
- package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
- package/package.json +1 -1
- package/skills/head/SKILL.md +4 -3
- package/skills/head/references/model-selection.md +8 -22
- package/skills/head/references/routing.md +19 -11
- package/skills/lane/SKILL.md +24 -76
- package/skills/lane/references/workflow.md +7 -94
- package/src/cli.ts +36 -16
- package/src/config/config.ts +6 -2
- package/src/contracts.ts +20 -4
- package/src/extension.ts +10 -5
- package/src/host-extension.ts +76 -8
- package/src/lane/lane-report.ts +1 -1
- package/src/lane/lane-rows.ts +2 -1
- package/src/lane-extension.ts +4 -21
- package/src/messaging/result-attachment.ts +77 -19
- package/src/messaging/written-directives.ts +56 -0
- package/src/omp/exit-record.ts +27 -0
- package/src/omp/host-protocol.ts +20 -0
- package/src/omp/host.ts +73 -20
- package/src/omp/installed-omp.ts +15 -12
- package/src/omp/managed-super.ts +135 -65
- package/src/routing/topic-request.ts +7 -4
- package/src/runtime/controller.ts +512 -165
- package/src/runtime/inbound-attachments.ts +70 -0
- package/src/runtime/local-host-fence.ts +85 -0
- package/src/runtime/model-journal.ts +14 -9
- package/src/runtime/native-frames.ts +5 -1
- package/src/runtime/result-attachments.ts +151 -24
- package/src/runtime/worker-result-download.ts +36 -0
- package/src/storage/store.ts +79 -26
- package/src/worker/worker-checkout.ts +89 -9
- package/src/worker/worker-destination.ts +8 -7
- package/src/worker/worker-doctor.ts +29 -9
- package/src/worker/worker-enrollment.ts +44 -12
- package/src/worker/worker-git-startup.ts +157 -0
- package/src/worker/worker-host.ts +16 -26
- package/src/worker/worker-ledger.ts +42 -18
- package/src/worker/worker-placement-intent.ts +13 -0
- package/src/worker/worker-placement.ts +204 -28
- package/src/worker/worker-profile.ts +18 -65
- package/src/worker/worker-project-startup.ts +106 -0
- package/src/worker/worker-registration.ts +85 -30
- package/src/worker/worker-repository.ts +55 -6
- package/src/worker/worker-request.ts +13 -6
- package/src/worker/worker-result-attachments.ts +185 -0
- package/src/worker/worker-result-wire.ts +12 -0
- package/src/worker/worker-service.ts +51 -23
- package/src/worker/worker-trust.ts +19 -4
- package/src/worker/worker-wire.ts +47 -14
- package/upstream/super.json +2 -3
package/src/cli.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { isAbsolute, join } from "node:path";
|
|
6
6
|
import { configuredPlatforms, credentialEnvNames, hostPaths, loadConfig, loadStateDirectory, requireMessengerCredentials } from "./config/config";
|
|
7
|
-
import { inspectInstalledOmp } from "./omp/installed-omp";
|
|
7
|
+
import { discoverInstalledOmp, inspectInstalledOmp } from "./omp/installed-omp";
|
|
8
8
|
import { requireHostOwner } from "./omp/host-owner-path";
|
|
9
9
|
import { loadCredentials } from "./config/credentials";
|
|
10
10
|
import { WORKFLOW_NAMES, type Lane } from "./contracts";
|
|
@@ -27,8 +27,8 @@ Usage:
|
|
|
27
27
|
omp-sa discord-commands --config FILE [--apply]
|
|
28
28
|
omp-sa telegram-commands --config FILE [--language CODE] [--apply]
|
|
29
29
|
omp-sa slack-commands --config FILE --manifest-token-env NAME [--apply]
|
|
30
|
-
omp-sa worker add user@host[:port] [--config FILE] [--default [--local-repo PATH]
|
|
31
|
-
omp-sa worker init --head-key PUBLIC_KEY --repo PATH
|
|
30
|
+
omp-sa worker add user@host[:port] [--config FILE] [--default | --default-current] [--local-repo PATH]
|
|
31
|
+
omp-sa worker init --head-key PUBLIC_KEY [--capacity N] [--repo PATH | --current-repo PATH | --trusted-repo PATH]...
|
|
32
32
|
omp-sa worker list [--config FILE]
|
|
33
33
|
omp-sa worker doctor user@host[:port] [--config FILE]
|
|
34
34
|
|
|
@@ -79,11 +79,15 @@ Same-process native TUI attach is not supported.
|
|
|
79
79
|
Remote workers are opt-in:
|
|
80
80
|
worker add generates a dedicated private key, prints the target init command, and never starts a bot.
|
|
81
81
|
worker init on the target authorizes only the restricted worker command for that public key and those Git roots.
|
|
82
|
+
Use --current-repo to authorize the worker's current checkout; --trusted-repo also permits supported project configuration.
|
|
82
83
|
After verifying the SSH host key separately, rerun worker add to verify and register the worker.
|
|
84
|
+
Use tailscale://user@host[:port] to reach OpenSSH through 'tailscale nc' without a local TCP route.
|
|
85
|
+
IPv6 literals need brackets. The same enrolled key, host-key checks and restricted command apply.
|
|
83
86
|
worker list reads the local verified inventory only; it does not contact endpoints or report live availability.
|
|
84
87
|
worker doctor checks the exact enrolled destination, current slot counts and, for a default worker, the pinned
|
|
85
88
|
checkout's current Git revision. It does not change enrollment, start work, or verify native Host readiness.
|
|
86
|
-
FILE defaults to ./config.local.json for worker add, list and doctor.
|
|
89
|
+
FILE defaults to ./config.local.json for worker add, list and doctor. --default matches a clean commit;
|
|
90
|
+
--default-current uses the approved worker's own checkout. --local-repo requires one of those defaults.
|
|
87
91
|
|
|
88
92
|
Owner controls in chat (not shell commands):
|
|
89
93
|
Send /help in Discord or Telegram. In Slack messages replace / with ! (e.g. !help, !status);
|
|
@@ -165,17 +169,22 @@ function laneRows(stateDir: string): Lane[] {
|
|
|
165
169
|
return readLaneRows(db);
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
function commandFlags(args: string[], usage: string,
|
|
172
|
+
function commandFlags(args: string[], usage: string, toggles: string | readonly string[], valueFlags: string[]) {
|
|
169
173
|
const values = new Map<string, string>();
|
|
170
|
-
|
|
174
|
+
const allowed = typeof toggles === "string" ? [toggles] : toggles;
|
|
175
|
+
let toggle: string | undefined;
|
|
171
176
|
for (let i = 0; i < args.length; i++) {
|
|
172
177
|
const flag = args[i];
|
|
173
|
-
if (flag
|
|
178
|
+
if (allowed.includes(flag)) {
|
|
179
|
+
if (toggle) throw new Error(usage);
|
|
180
|
+
toggle = flag;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
174
183
|
const value = args[++i];
|
|
175
184
|
if (!valueFlags.includes(flag) || values.has(flag) || !value || value.startsWith("-")) throw new Error(usage);
|
|
176
185
|
values.set(flag, value);
|
|
177
186
|
}
|
|
178
|
-
return { enabled, values };
|
|
187
|
+
return { enabled: toggle !== undefined, toggle, values };
|
|
179
188
|
}
|
|
180
189
|
|
|
181
190
|
async function workerCommand(args: string[]): Promise<void> {
|
|
@@ -186,17 +195,19 @@ async function workerCommand(args: string[]): Promise<void> {
|
|
|
186
195
|
if (operands.length === 0) { console.log(HELP); return; }
|
|
187
196
|
throw new Error("Usage: omp-sa worker --help");
|
|
188
197
|
case "add": {
|
|
189
|
-
const usage = "Usage: omp-sa worker add user@host[:port] [--config FILE] [--default [--local-repo PATH]
|
|
198
|
+
const usage = "Usage: omp-sa worker add user@host[:port] [--config FILE] [--default | --default-current] [--local-repo PATH]";
|
|
190
199
|
const [destination, ...flags] = operands;
|
|
191
200
|
if (!destination || destination.startsWith("-")) throw new Error(usage);
|
|
192
|
-
const {
|
|
201
|
+
const { toggle, values } = commandFlags(flags, usage, ["--default", "--default-current"], ["--config", "--local-repo"]);
|
|
193
202
|
const localRepo = values.get("--local-repo");
|
|
194
|
-
if (localRepo && !
|
|
203
|
+
if (localRepo && !toggle) throw new Error(usage);
|
|
195
204
|
const config = await loadConfig(values.get("--config") ?? "config.local.json");
|
|
196
205
|
const { addWorker } = await import("./worker/worker-registration");
|
|
197
206
|
const { workerDescribe } = await import("./worker/worker-wire");
|
|
198
207
|
const result = await addWorker({ destination, stateDir: config.stateDir,
|
|
199
|
-
...(
|
|
208
|
+
...(toggle === "--default" && { defaultRepositoryRoot: localRepo ?? config.headCwd }),
|
|
209
|
+
...(toggle === "--default-current" && { defaultCurrentRepositoryRoot: localRepo ?? config.headCwdSource ?? config.headCwd }),
|
|
210
|
+
}, workerDescribe);
|
|
200
211
|
printJson(result);
|
|
201
212
|
if (result.status === "pending" && result.verificationError) process.exitCode = 1;
|
|
202
213
|
return;
|
|
@@ -223,17 +234,23 @@ async function workerCommand(args: string[]): Promise<void> {
|
|
|
223
234
|
return;
|
|
224
235
|
}
|
|
225
236
|
case "init": {
|
|
226
|
-
const usage = "Usage: omp-sa worker init --head-key PUBLIC_KEY --repo PATH
|
|
237
|
+
const usage = "Usage: omp-sa worker init --head-key PUBLIC_KEY [--capacity N] [--repo PATH | --current-repo PATH | --trusted-repo PATH]...";
|
|
227
238
|
let headKey: string | undefined;
|
|
239
|
+
let slots: number | undefined;
|
|
228
240
|
const repositories: string[] = [];
|
|
241
|
+
const currentRepositories: string[] = [];
|
|
242
|
+
const trustedRepositories: string[] = [];
|
|
229
243
|
for (let index = 0; index < operands.length; index += 2) {
|
|
230
244
|
const [flag, value] = [operands[index], operands[index + 1]];
|
|
231
245
|
if (!value || value.startsWith("-")) throw new Error(usage);
|
|
232
246
|
if (flag === "--head-key" && headKey === undefined) headKey = value;
|
|
247
|
+
else if (flag === "--capacity" && slots === undefined && /^[1-9][0-9]*$/.test(value)) slots = Number(value);
|
|
233
248
|
else if (flag === "--repo") repositories.push(value);
|
|
249
|
+
else if (flag === "--current-repo") currentRepositories.push(value);
|
|
250
|
+
else if (flag === "--trusted-repo") trustedRepositories.push(value);
|
|
234
251
|
else throw new Error(usage);
|
|
235
252
|
}
|
|
236
|
-
if (!headKey || !repositories.length) throw new Error(usage);
|
|
253
|
+
if (!headKey || !(repositories.length + currentRepositories.length + trustedRepositories.length)) throw new Error(usage);
|
|
237
254
|
if (process.platform !== "darwin" && process.platform !== "linux") throw new Error("Worker init requires macOS or Linux");
|
|
238
255
|
const { workerPublicKey } = await import("./worker/worker-registration");
|
|
239
256
|
const publicKey = workerPublicKey(headKey);
|
|
@@ -241,8 +258,11 @@ async function workerCommand(args: string[]): Promise<void> {
|
|
|
241
258
|
const { activeManagedUlw } = await import("./omp/managed-super");
|
|
242
259
|
await requireHostOwner();
|
|
243
260
|
activeManagedUlw();
|
|
244
|
-
const {
|
|
245
|
-
|
|
261
|
+
const { workerId, stateDir, repos, capacity } = await enrollWorker({
|
|
262
|
+
home: homedir(), headKey: publicKey, repositories, currentRepositories, trustedRepositories, capacity: slots,
|
|
263
|
+
executable: discoverInstalledOmp(),
|
|
264
|
+
checkExecutable: (executable, env) => inspectInstalledOmp([executable], [], env, "/"),
|
|
265
|
+
});
|
|
246
266
|
printJson({ status: "initialized", workerId, stateDir, repos, capacity });
|
|
247
267
|
return;
|
|
248
268
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { chmodSync, lstatSync, mkdirSync, realpathSync } from "node:fs";
|
|
2
|
-
import { dirname, join, resolve } from "node:path";
|
|
2
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
3
|
import { physicalRoute, type Platform, type Route } from "../contracts";
|
|
4
4
|
import { resolveOmpCommand } from "../omp/installed-omp";
|
|
5
5
|
import { groupRoom, parseGroupRooms, type GroupRoom } from "../group/group-policy";
|
|
@@ -73,6 +73,7 @@ export interface Config {
|
|
|
73
73
|
path: string;
|
|
74
74
|
stateDir: string;
|
|
75
75
|
headCwd: string;
|
|
76
|
+
readonly headCwdSource?: string;
|
|
76
77
|
command: string[];
|
|
77
78
|
maxHosts: number;
|
|
78
79
|
maxSubagents: number;
|
|
@@ -237,7 +238,9 @@ export function parseConfig(value: unknown, path: string): Config {
|
|
|
237
238
|
throw new Error("command must be an argv array for an installed stock OMP executable");
|
|
238
239
|
if (raw.command.some(v => /^(?:--session-settings|--rpc-socket|--model-preset)(?:=|$)/.test(v)) || raw.command[1] === "attach")
|
|
239
240
|
throw new Error("command contains unsupported patched OMP arguments; configure an installed stock OMP executable");
|
|
240
|
-
const
|
|
241
|
+
const configuredCwd = text(raw.headCwd, "headCwd");
|
|
242
|
+
const headCwdSource = isAbsolute(configuredCwd) ? configuredCwd : `${base}/${configuredCwd}`;
|
|
243
|
+
const headCwd = realpathSync.native(headCwdSource);
|
|
241
244
|
if (!lstatSync(headCwd).isDirectory()) throw new Error("headCwd must be a directory");
|
|
242
245
|
const command = resolveOmpCommand(raw.command as string[], process.env.PATH, base);
|
|
243
246
|
const maxHosts = integer(raw.maxHosts, "maxHosts", 2);
|
|
@@ -304,6 +307,7 @@ export function parseConfig(value: unknown, path: string): Config {
|
|
|
304
307
|
path: absolute,
|
|
305
308
|
stateDir: stateDirectory(raw, base),
|
|
306
309
|
headCwd,
|
|
310
|
+
...(headCwdSource !== headCwd && { headCwdSource }),
|
|
307
311
|
command,
|
|
308
312
|
maxHosts,
|
|
309
313
|
maxSubagents,
|
package/src/contracts.ts
CHANGED
|
@@ -181,6 +181,8 @@ export interface Inbound {
|
|
|
181
181
|
readonly telegramProtectedCommand?: boolean;
|
|
182
182
|
/** Original Telegram text or caption when an addressed bot suffix was removed. */
|
|
183
183
|
readonly telegramOriginalText?: string;
|
|
184
|
+
/** UTF-16 end of the adapter-attested owner-written prefix (after Slack entity decoding). */
|
|
185
|
+
readonly ownerWrittenPrefix?: number;
|
|
184
186
|
receivedAt: number;
|
|
185
187
|
attachments: Attachment[];
|
|
186
188
|
reply?: ReplyContext;
|
|
@@ -237,6 +239,17 @@ export interface LaneObservation {
|
|
|
237
239
|
lastEvidence: (LaneEvidence & { at: number }) | null;
|
|
238
240
|
waiting: { target: LaneWaitTarget; since: number } | null;
|
|
239
241
|
}
|
|
242
|
+
/** Observed on the verified local stdio connection, never a remote process lookup. */
|
|
243
|
+
export interface LocalHostIdentity {
|
|
244
|
+
readonly pid: number;
|
|
245
|
+
readonly ownerPid: number;
|
|
246
|
+
readonly sessionId: string;
|
|
247
|
+
readonly sessionFile: string;
|
|
248
|
+
readonly dev: number;
|
|
249
|
+
readonly ino: number;
|
|
250
|
+
readonly ctimeMs: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
240
253
|
export interface Lane {
|
|
241
254
|
id: string;
|
|
242
255
|
title: string;
|
|
@@ -260,6 +273,7 @@ export interface Lane {
|
|
|
260
273
|
socketPath: string;
|
|
261
274
|
generation: number;
|
|
262
275
|
pid: number | null;
|
|
276
|
+
localOwner?: LocalHostIdentity & { readonly journalHeld?: true };
|
|
263
277
|
createdAt: number;
|
|
264
278
|
lastActivityAt: number;
|
|
265
279
|
result: string | null;
|
|
@@ -454,6 +468,8 @@ export interface StorePort {
|
|
|
454
468
|
laneReplyRoute(input: InputRecord, source: InputRecord): Route;
|
|
455
469
|
/** Exact original owner and authorized delivery route for a topic-owned lane input. */
|
|
456
470
|
topicDelivery(id: string): { readonly source: InputRecord; readonly route: Route; readonly outputSourceId: string } | null;
|
|
471
|
+
/** Original file recipient or its exact confirmed child for a remote admission; text routing does not grant file consent. */
|
|
472
|
+
resultAttachmentDelivery(id: string): ReturnType<StorePort["topicDelivery"]>;
|
|
457
473
|
/** Whether an unowned dialog could belong to a durable topic admission on this native generation. */
|
|
458
474
|
hasTopicAdmission(target: string, generation: number): boolean;
|
|
459
475
|
/** A timely owner choice or stop on the original route is durably admitted by Gateway and still awaiting its head receipt. */
|
|
@@ -536,17 +552,17 @@ export interface StorePort {
|
|
|
536
552
|
/** Settle an in-flight Slack joined notice from its exact durable Gateway receipt. */
|
|
537
553
|
reconcileSlackJoinedOutput(id: string): boolean;
|
|
538
554
|
finishOutput(id: string, state: "sent" | "uncertain" | "failed" | "pending", remoteId?: string, error?: string): void;
|
|
539
|
-
createLane(lane: Lane & { model: LaneModel
|
|
555
|
+
createLane(lane: Lane & { model: LaneModel }, sourceId: string): Lane;
|
|
540
556
|
lane(id: string): Lane | null;
|
|
541
557
|
laneForRoute(route: Route): Lane | null;
|
|
542
558
|
lanes(): Lane[];
|
|
543
559
|
updateLane(id: string, generation: number, patch: Partial<Pick<Lane,
|
|
544
|
-
"workState" | "runtimeState" | "sessionId" | "pid" | "lastActivityAt" | "result"
|
|
560
|
+
"workState" | "runtimeState" | "sessionId" | "pid" | "lastActivityAt" | "result" | "localOwner"
|
|
545
561
|
>>): boolean;
|
|
546
|
-
retireLocalLaneHost(expected: Pick<Lane, "id" | "generation" | "pid" | "sessionId" | "socketPath"
|
|
562
|
+
retireLocalLaneHost(expected: Pick<Lane, "id" | "generation" | "pid" | "sessionId" | "socketPath" | "localOwner">, orphan?: LocalHostIdentity): boolean;
|
|
547
563
|
nextGeneration(id: string, pickerRestoreSourceId?: string): Lane;
|
|
548
564
|
adoptLaneModel(id: string, generation: number, model: LaneModel, reason: string): boolean;
|
|
549
|
-
changeLaneModel(id: string, generation: number, expected: LaneModel | null, model: LaneModel, reason:
|
|
565
|
+
changeLaneModel(id: string, generation: number, expected: LaneModel | null, model: LaneModel, reason: Lane["modelReason"],
|
|
550
566
|
preset: ModelPreset | null, snapshot: LanePresetSnapshot | null, metadata?: Readonly<Record<string, string>>, operatorSourceId?: string): boolean;
|
|
551
567
|
recordLaneFallback(id: string, configured: LaneModel, previous: string | null, receipt: LaneFallbackReceipt,
|
|
552
568
|
notice: Pick<OutputRecord, "id" | "sourceId" | "route" | "text">): boolean;
|
package/src/extension.ts
CHANGED
|
@@ -88,7 +88,6 @@ const workflowSchema = Type.Optional(workflowSelection);
|
|
|
88
88
|
const laneModelSelection = {
|
|
89
89
|
model: Type.Optional(Type.Object({ provider: Type.String({ minLength: 1 }), id: Type.String({ minLength: 1 }) })),
|
|
90
90
|
preset: Type.Optional(Type.String({ minLength: 1 })),
|
|
91
|
-
modelReason: Type.String({ minLength: 1 }),
|
|
92
91
|
} as const;
|
|
93
92
|
const threadTagsSchema = Type.Array(Type.String({ pattern: "^[0-9]{1,20}$" }), { maxItems: 5, uniqueItems: true });
|
|
94
93
|
const laneRouteSchema = Type.Object({
|
|
@@ -317,7 +316,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
317
316
|
});
|
|
318
317
|
pi.registerTool({
|
|
319
318
|
name: "lane_models", label: "Inspect lane model candidates", approval: "read", loadMode: "essential",
|
|
320
|
-
description: "Inspect
|
|
319
|
+
description: "Inspect HEAD's native model presets, roles, and available chat models. Selectors accept preset:<name>, a native role such as @smol, or an exact provider/model. Omit selectors for the full coding shortlist. This is not a worker inventory or a performance ranking.",
|
|
321
320
|
parameters: Type.Object({ selectors: Type.Optional(Type.Array(Type.String(), { minItems: 1 })) }),
|
|
322
321
|
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
323
322
|
const available = await requireRuntime(ctx).availableModels();
|
|
@@ -343,7 +342,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
343
342
|
candidates: selected,
|
|
344
343
|
nativePresets: inspection,
|
|
345
344
|
...(resolutions ? { resolutions } : {}),
|
|
346
|
-
guidance: "Catalog
|
|
345
|
+
guidance: "Catalog fields describe capabilities and prices, not measured performance, quota, or authority to spend.",
|
|
347
346
|
});
|
|
348
347
|
},
|
|
349
348
|
});
|
|
@@ -366,20 +365,25 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
366
365
|
});
|
|
367
366
|
pi.registerTool({
|
|
368
367
|
name: "lane_start", label: "Start independent work", loadMode: "essential", approval: "exec",
|
|
369
|
-
description: "
|
|
368
|
+
description: "Start or reuse a lane at a verified cwd. Choose exactly one model or preset. Use the original sourceId; kickoff must be confirmed before work starts. Keep the original thread by default. For an explicitly separate topic, pass an authorized parent destination with threadId:null and no topicId; permitted cross-channel placement does not expand intake rights. Private chats without native threads use a logical topic. An explicit workflow applies only to this handoff. A returned lane ID is not completion.",
|
|
370
369
|
parameters: Type.Object({
|
|
371
370
|
sourceId: Type.String(), title: Type.String(), cwd: Type.String(),
|
|
372
371
|
kickoff: Type.String({ minLength: 1, description: "A concise message in the user's language stating the concrete approach. Delivered in the work topic before native lane execution; failed or uncertain delivery holds execution." }),
|
|
373
372
|
...laneModelSelection,
|
|
373
|
+
modelReason: Type.Optional(Type.String()),
|
|
374
374
|
brief: Type.Optional(Type.String()), acceptance: Type.Optional(Type.Array(Type.String())),
|
|
375
375
|
workflow: workflowSchema,
|
|
376
376
|
placement: Type.Optional(Type.Object({
|
|
377
377
|
target: Type.Optional(Type.Union([Type.Literal("local"), Type.Literal("remote")])),
|
|
378
378
|
platform: Type.Optional(Type.Union([Type.Literal("linux"), Type.Literal("darwin")])),
|
|
379
379
|
worker: Type.Optional(Type.String({ minLength: 1, description: "Exact paired worker ID, never an address or SSH command." })),
|
|
380
|
+
currentWorkspace: Type.Optional(Type.Object({
|
|
381
|
+
repoId: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
382
|
+
subdir: Type.String({ maxLength: 2048, description: "Exact checkout-relative directory, or an empty string for the root." }),
|
|
383
|
+
}, { additionalProperties: false, description: "Normally omit: the controller reads the exact worker and workspace from the owner's `/head worker-current: WORKER_ID REPO_ID [SUBDIR]` line. If supplied, these values must match that line. Use the verified local counterpart as cwd; no local changes are sent." })),
|
|
380
384
|
}, {
|
|
381
385
|
additionalProperties: false,
|
|
382
|
-
description: "Execution location for new work at the verified local cwd.
|
|
386
|
+
description: "Execution location for new work at the verified local cwd. Only omission can select an eligible --default-current worker; an empty object allows ordinary local or exact-default placement. Remote, platform, or worker normally requires an approved paired worker and a clean committed Git checkout, with no local fallback. The explicit currentWorkspace option uses the approved worker-owned checkout instead. A bound worker can hold execution until ready. Local opts out and cannot be combined with remote selectors.",
|
|
383
387
|
})),
|
|
384
388
|
appliedTags: Type.Optional(threadTagsSchema),
|
|
385
389
|
destination: Type.Optional(laneRouteSchema),
|
|
@@ -495,6 +499,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
495
499
|
parameters: Type.Object({
|
|
496
500
|
id: Type.String(), sourceId: Type.String(),
|
|
497
501
|
...laneModelSelection,
|
|
502
|
+
modelReason: Type.String({ minLength: 1 }),
|
|
498
503
|
}),
|
|
499
504
|
async execute(_id, params, _signal, _onUpdate, ctx) { return result(await requireRuntime(ctx).changeModel(params)); },
|
|
500
505
|
});
|
package/src/host-extension.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as net from "node:net";
|
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { isDeepStrictEqual } from "node:util";
|
|
7
|
+
import { Value } from "@sinclair/typebox/value";
|
|
7
8
|
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
8
9
|
import type { UnitScope } from "@oh-my-pi/pi-coding-agent/daemon/protocol";
|
|
9
10
|
import { cfgDefaultThinkingLevel, cfgTierAnthropic, cfgTierGoogle, cfgTierOpenai } from "@oh-my-pi/pi-coding-agent/session/settings";
|
|
@@ -22,7 +23,7 @@ import { fitAbortAndRestoreQueueResponse } from "@oh-my-pi/pi-coding-agent/modes
|
|
|
22
23
|
import type { RpcAbortAndRestoreQueueResult, RpcSessionState } from "@oh-my-pi/pi-coding-agent/modes/rpc/rpc-types";
|
|
23
24
|
import { calculateTokensPerSecond } from "@oh-my-pi/pi-coding-agent/utils/token-rate";
|
|
24
25
|
import { toolWireSchema } from "@oh-my-pi/pi-ai/utils/schema";
|
|
25
|
-
import type { LanePresetSnapshot } from "./contracts";
|
|
26
|
+
import type { LaneModel, LanePresetSnapshot } from "./contracts";
|
|
26
27
|
import { MANAGED_ULW_ENV } from "./omp/managed-super";
|
|
27
28
|
import { verifyHostSuperkit } from "./omp/host-superkit";
|
|
28
29
|
import { isPrReviewInferenceModel, prReviewModelChoices } from "./pr/pr-review-models";
|
|
@@ -36,6 +37,8 @@ import { isWorkerMemoryCursor, isWorkerMemoryStamp } from "./worker/worker-memor
|
|
|
36
37
|
import { canBeginWorkerFact, isWorkerFactRoot, type WorkerFactCarrier } from "./worker/worker-memory-proofs";
|
|
37
38
|
import { bindWorkerMemorySource } from "./worker/worker-memory-source";
|
|
38
39
|
import { WORKER_MEMORY_ENV, WORKER_MEMORY_PROFILE_ENV } from "./worker/worker-memory-storage";
|
|
40
|
+
import { WorkerResultAttachments } from "./worker/worker-result-attachments";
|
|
41
|
+
import { attestWorkerCheckout, workerCheckoutPinSchema, type WorkerCheckoutPin, type WorkerCheckoutProof } from "./worker/worker-checkout";
|
|
39
42
|
|
|
40
43
|
const serviceGeneration = ({ owner, id, generation, startedAt, restartCount }: ServiceUnit) =>
|
|
41
44
|
({ owner, id, generation, startedAt, restartCount });
|
|
@@ -93,6 +96,10 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
93
96
|
let instanceKey: string | undefined;
|
|
94
97
|
const selectedSuperkit = process.env[MANAGED_ULW_ENV];
|
|
95
98
|
const workerAttempt = process.env.OMP_SUPERAGENT_WORKER_ATTEMPT;
|
|
99
|
+
const workerWorkspace = process.env.OMP_SUPERAGENT_WORKER_RESULT_WORKSPACE;
|
|
100
|
+
let workerCheckout: { readonly pin: WorkerCheckoutPin; readonly proof: WorkerCheckoutProof } | undefined;
|
|
101
|
+
let workerResults = workerAttempt && process.env.OMP_SUPERAGENT_ROLE === "lane" &&
|
|
102
|
+
workerWorkspace && /^\d+:\d+$/.test(workerWorkspace) ? new WorkerResultAttachments(workerWorkspace) : undefined;
|
|
96
103
|
const memoryLaunch = workerAttempt && process.env.OMP_SUPERAGENT_ROLE === "lane" ? process.env[WORKER_MEMORY_ENV] : undefined;
|
|
97
104
|
const workerMemoryProfileBinding: NativeProfileBinding | null = memoryLaunch
|
|
98
105
|
? JSON.parse(process.env[WORKER_MEMORY_PROFILE_ENV] ?? "null") : null;
|
|
@@ -119,6 +126,12 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
119
126
|
if (!(root instanceof pi.pi.AgentSession)) throw new Error("Native root session is unavailable");
|
|
120
127
|
return root;
|
|
121
128
|
};
|
|
129
|
+
const availableLaneModel = (session: ReturnType<typeof rootSession>, choice: LaneModel) => {
|
|
130
|
+
const matches = session.getAvailableModels().filter(model => model.provider === choice.provider && model.id === choice.id);
|
|
131
|
+
const [model] = matches;
|
|
132
|
+
return matches.length === 1 && model && (model.kind === undefined || model.kind === "chat")
|
|
133
|
+
&& session.modelRegistry.hasConfiguredAuth(model) ? model : undefined;
|
|
134
|
+
};
|
|
122
135
|
const flushLaneModel = (session: ReturnType<typeof rootSession>, previousLeaf: string | null, promoting: boolean) => {
|
|
123
136
|
const journal = session.sessionManager;
|
|
124
137
|
const model = session.model;
|
|
@@ -199,7 +212,15 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
199
212
|
const ownerIdentity = ({ id, file, ref, session }: ReturnType<typeof exact>) => ({
|
|
200
213
|
hostPid: process.pid, sessionId: id, sessionFile: file, generation: ref.generation, instanceKey: session.instanceKey,
|
|
201
214
|
...(workerAttempt ? { workerAttempt, workerCwd: context?.cwd } : {}),
|
|
215
|
+
...(workerCheckout && { workerCheckoutProof: workerCheckout.proof }),
|
|
202
216
|
});
|
|
217
|
+
const confirmWorkerCheckout = async (identity: ReturnType<typeof exact>, pin: WorkerCheckoutPin) => {
|
|
218
|
+
const cwd = identity.session.sessionManager.getCwd();
|
|
219
|
+
const proof = await attestWorkerCheckout(cwd, pin);
|
|
220
|
+
if (exact().ref !== identity.ref || identity.session.sessionManager.getCwd() !== cwd || context?.cwd !== cwd)
|
|
221
|
+
throw new Error("Native worker session changed during checkout attestation");
|
|
222
|
+
return proof;
|
|
223
|
+
};
|
|
203
224
|
const currentNativeProfile = (file: string | undefined) => {
|
|
204
225
|
if (!profileBinding || !nativeProfilePaths || !file) return;
|
|
205
226
|
const { profile, discoveryEntry } = profileBinding;
|
|
@@ -694,9 +715,23 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
694
715
|
&& goalEnabled.get(readOnly(identity.session.settings)) === true)
|
|
695
716
|
await pi.setActiveTools([...new Set([...pi.getActiveTools(), "goal"])]);
|
|
696
717
|
if (nativeProfile && !currentNativeProfile(identity.file)) throw new Error("Native Host profile changed before activation");
|
|
718
|
+
if (command.workerCheckoutPin !== undefined) {
|
|
719
|
+
const pin = command.workerCheckoutPin;
|
|
720
|
+
if (!workerAttempt || !Value.Check(workerCheckoutPinSchema, pin))
|
|
721
|
+
throw new Error("Native worker-current activation requires a checkout pin");
|
|
722
|
+
const proof = await confirmWorkerCheckout(identity, pin);
|
|
723
|
+
workerCheckout = { pin, proof };
|
|
724
|
+
workerResults = new WorkerResultAttachments(proof.checkoutIdentity.slice(proof.checkoutIdentity.lastIndexOf("/") + 1));
|
|
725
|
+
}
|
|
697
726
|
pi.events.emit("superagent:host-ready", { sessionId: identity.id, sessionFile: identity.file, pid: process.pid,
|
|
698
727
|
...(nativeProfile ? { nativeProfile } : {}), ...(command.waking === true ? { waking: true } : {}) } satisfies HostReadyEvent);
|
|
699
|
-
return {};
|
|
728
|
+
return workerCheckout ? { ...ownerIdentity(identity), workerResultControlVersion: 1 } : {};
|
|
729
|
+
}
|
|
730
|
+
if (command.type === "attest_worker_checkout") {
|
|
731
|
+
if (!workerCheckout) throw new Error("Native worker-current checkout pin is unavailable");
|
|
732
|
+
const identity = exact();
|
|
733
|
+
const proof = await confirmWorkerCheckout(identity, workerCheckout.pin);
|
|
734
|
+
return { ...ownerIdentity(identity), workerCheckoutProof: proof };
|
|
700
735
|
}
|
|
701
736
|
if (command.type === "observe") {
|
|
702
737
|
if (command.customType !== "rpc_prompt_result") throw new Error("Unsupported native observation");
|
|
@@ -709,6 +744,19 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
709
744
|
if (observationHeld) throw new Error("Durable native observations are unavailable");
|
|
710
745
|
return { ...ownerIdentity(identity), leafId: identity.session.sessionManager.getLeafId() };
|
|
711
746
|
}
|
|
747
|
+
if (command.type === "copy_worker_result_attachment") {
|
|
748
|
+
const identity = exact();
|
|
749
|
+
const { id, file, session } = identity;
|
|
750
|
+
if (!workerResults || !context || !file || command.runOrdinal !== runOrdinal || mutationHeld || observationHeld ||
|
|
751
|
+
session.isDisposed || session.isSessionTransitioning !== false)
|
|
752
|
+
throw new Error("Worker result attachment is unavailable");
|
|
753
|
+
const scope = { cwd: context.cwd, sessionId: id, sessionFile: file, agentDir: session.settings.getAgentDir(), configPath };
|
|
754
|
+
const copy = command.op === "reserve" ? await workerResults.reserve(command, scope) : workerResults.copy(command, scope);
|
|
755
|
+
assertSameRoot(identity);
|
|
756
|
+
if (command.runOrdinal !== runOrdinal || mutationHeld || observationHeld)
|
|
757
|
+
throw new Error("Worker result attachment is unavailable");
|
|
758
|
+
return { ...ownerIdentity(identity), copy };
|
|
759
|
+
}
|
|
712
760
|
if (command.type === "get_worker_memory") {
|
|
713
761
|
const { after, unchanged } = command;
|
|
714
762
|
if (!workerMemoryProfile || !isWorkerMemoryCursor(after) || (unchanged !== undefined && (after !== 0 || !isWorkerMemoryStamp(unchanged))))
|
|
@@ -774,7 +822,11 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
774
822
|
&& !session.hasAdmittedSubmission && !session.hasPostPromptWork && session.queuedMessageCount === 0
|
|
775
823
|
&& !session.yieldQueue.has() && !session.getGoalModeState()?.enabled && !mutationHeld && !observationHeld;
|
|
776
824
|
// Only an owner that implements the cursor command can advertise it to peers.
|
|
825
|
+
const active = session.model;
|
|
777
826
|
return { ...ownerIdentity(ownership.identity), loadedSuperkitPath, prReviewPolicy, settingsScope: "session", modelSettings: snapshot(),
|
|
827
|
+
...(process.env.OMP_SUPERAGENT_ROLE === "lane" && !reviewCwd && {
|
|
828
|
+
laneModelAvailable: active && availableLaneModel(session, active) ? { provider: active.provider, id: active.id } : null,
|
|
829
|
+
}),
|
|
778
830
|
nativeProfile: currentNativeProfile(ownership.identity.file),
|
|
779
831
|
...(process.env.OMP_SUPERAGENT_ROLE === "head" ? {
|
|
780
832
|
stockLaunchReplay,
|
|
@@ -785,6 +837,7 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
785
837
|
} : {}),
|
|
786
838
|
journalCursorControlVersion: 1,
|
|
787
839
|
...(workerMemoryControlVersion && { workerMemoryControlVersion }),
|
|
840
|
+
...(workerResults && { workerResultControlVersion: 1 }),
|
|
788
841
|
...(replyVoice?.available() ? { replyVoiceControlVersion: 2 } : {}),
|
|
789
842
|
...(running ? { headJobs: { running: running.map(job => job.id), awaitingOnly } } : {}),
|
|
790
843
|
fastMode: headFastMode(ownership.identity.session),
|
|
@@ -823,11 +876,9 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
823
876
|
if (ownership.unknown || ownership.busy) throw new Error("session_busy");
|
|
824
877
|
// Use the current native catalogue and configured credential source,
|
|
825
878
|
// without resolving a key, refreshing discovery, or probing inference.
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
if (candidates.length !== 1 || !model || (model.kind !== undefined && model.kind !== "chat")
|
|
830
|
-
|| !session.modelRegistry.hasConfiguredAuth(model))
|
|
879
|
+
const model = typeof command.provider === "string" && typeof command.modelId === "string"
|
|
880
|
+
? availableLaneModel(session, { provider: command.provider, id: command.modelId }) : undefined;
|
|
881
|
+
if (!model)
|
|
831
882
|
throw new Error("An available exact chat model with configured auth is required");
|
|
832
883
|
const previousLeaf = session.sessionManager.getLeafId();
|
|
833
884
|
const before = exact();
|
|
@@ -944,8 +995,18 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
944
995
|
}
|
|
945
996
|
throw new Error("Unsupported private native control");
|
|
946
997
|
};
|
|
947
|
-
pi.on("agent_start", () => {
|
|
998
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
948
999
|
if (context?.agent.kind === "main") observation("rpc_agent_start", { runOrdinal: ++runOrdinal, hostPid: process.pid });
|
|
1000
|
+
if (ctx.agent.kind === "main" && ctx.agent.id === pi.pi.MAIN_AGENT_ID && ctx.sessionManager === context?.sessionManager)
|
|
1001
|
+
workerResults?.setActive(true);
|
|
1002
|
+
});
|
|
1003
|
+
pi.on("message_start", (event, ctx) => {
|
|
1004
|
+
if (!workerResults || ctx.agent.kind !== "main" || ctx.agent.id !== pi.pi.MAIN_AGENT_ID ||
|
|
1005
|
+
ctx.sessionManager !== context?.sessionManager || event.message.role !== "user" ||
|
|
1006
|
+
event.message.attribution === "agent" || event.message.synthetic) return;
|
|
1007
|
+
const content = event.message.content;
|
|
1008
|
+
const text = typeof content === "string" ? content : content.find(part => part.type === "text")?.text;
|
|
1009
|
+
if (text) workerResults.observeOwnerInput(text);
|
|
949
1010
|
});
|
|
950
1011
|
const observeWorkerFact = (tool: string, ctx: ExtensionContext, observe: (source: NonNullable<typeof workerMemory>,
|
|
951
1012
|
name: WorkerFactCarrier) => void, input?: unknown) => {
|
|
@@ -966,13 +1027,19 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
966
1027
|
}
|
|
967
1028
|
};
|
|
968
1029
|
pi.on("tool_execution_start", (event, ctx) => {
|
|
1030
|
+
if (ctx.agent.kind === "main" && ctx.agent.id === pi.pi.MAIN_AGENT_ID && ctx.sessionManager === context?.sessionManager)
|
|
1031
|
+
workerResults?.observe({ ...event });
|
|
969
1032
|
observeWorkerFact(event.toolName, ctx, (source, tool) => source.startFact(tool, event.toolCallId, event.args), event.args);
|
|
970
1033
|
});
|
|
971
1034
|
pi.on("tool_execution_end", (event, ctx) => {
|
|
1035
|
+
if (ctx.agent.kind === "main" && ctx.agent.id === pi.pi.MAIN_AGENT_ID && ctx.sessionManager === context?.sessionManager)
|
|
1036
|
+
workerResults?.observe({ ...event });
|
|
972
1037
|
observeWorkerFact(event.toolName, ctx, (source, tool) => source.finishFact(tool, event.toolCallId, !event.isError, event.result));
|
|
973
1038
|
});
|
|
974
1039
|
pi.on("agent_end", (_event, ctx) => {
|
|
975
1040
|
if (ctx.agent.kind === "main" && ctx.agent.id === pi.pi.MAIN_AGENT_ID) workerMemory?.clearFactStarts();
|
|
1041
|
+
if (ctx.agent.kind === "main" && ctx.agent.id === pi.pi.MAIN_AGENT_ID && ctx.sessionManager === context?.sessionManager)
|
|
1042
|
+
workerResults?.finishRun();
|
|
976
1043
|
});
|
|
977
1044
|
pi.on("tool_call", async (event, ctx) => {
|
|
978
1045
|
if (reviewCwd) return { block: true, reason: "Static PR review does not execute tools" };
|
|
@@ -1111,6 +1178,7 @@ export default function hostExtension(pi: ExtensionAPI): void {
|
|
|
1111
1178
|
if (ownerChannel !== channel) return;
|
|
1112
1179
|
ownerChannel = undefined;
|
|
1113
1180
|
replyVoice?.clear();
|
|
1181
|
+
workerResults?.setActive(false);
|
|
1114
1182
|
});
|
|
1115
1183
|
channel.encoder.setProtocolVersion(2);
|
|
1116
1184
|
channel.on("frame", (command: Frame) => {
|
package/src/lane/lane-report.ts
CHANGED
|
@@ -34,7 +34,7 @@ const text = (value: unknown): value is string => typeof value === "string" && v
|
|
|
34
34
|
const keys = (value: Record<string, unknown>, names: string[]) =>
|
|
35
35
|
Object.keys(value).every(key => names.includes(key));
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
function isLaneWaitTarget(value: unknown): value is LaneWaitTarget {
|
|
38
38
|
return record(value) && text(value.target) && (value.kind === "dependency"
|
|
39
39
|
? keys(value, ["kind", "target"])
|
|
40
40
|
: ["tool", "approval", "job"].includes(value.kind as string) &&
|
package/src/lane/lane-rows.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { isAbsolute, normalize } from "node:path";
|
|
|
3
3
|
import { Type } from "@sinclair/typebox/type";
|
|
4
4
|
import { Value } from "@sinclair/typebox/value";
|
|
5
5
|
import type { Lane } from "../contracts";
|
|
6
|
-
import type
|
|
6
|
+
import { workerCheckoutSchema, type RemotePlacement } from "../worker/worker-wire";
|
|
7
7
|
|
|
8
8
|
export interface LaneRow {
|
|
9
9
|
readonly data: string;
|
|
@@ -16,6 +16,7 @@ const remoteSchema = Type.Object({
|
|
|
16
16
|
repoId: Type.String({ pattern: "^[a-f0-9]{64}$" }),
|
|
17
17
|
revision: Type.String({ pattern: "^(?:[a-f0-9]{40}|[a-f0-9]{64})$" }),
|
|
18
18
|
subdir: Type.String({ maxLength: 2048 }),
|
|
19
|
+
workerCheckout: Type.Optional(workerCheckoutSchema),
|
|
19
20
|
stateDir: Type.String(),
|
|
20
21
|
}, { additionalProperties: false });
|
|
21
22
|
|
package/src/lane-extension.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, rea
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import type { ToolCall, ToolResultMessage } from "@oh-my-pi/pi-ai";
|
|
5
5
|
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Type } from "@sinclair/typebox/type";
|
|
7
|
+
import { Value } from "@sinclair/typebox/value";
|
|
8
|
+
import { type LaneEvidence, type LaneReportEvent, parseLaneReportResult } from "./lane/lane-report";
|
|
8
9
|
import { registerResultAttach, RESULT_ATTACH_TOOL } from "./messaging/result-attachment";
|
|
9
10
|
import { registerDecisionAsk } from "./lane/decision-tool";
|
|
10
11
|
|
|
@@ -35,24 +36,6 @@ const coordinationTool = (name: string) =>
|
|
|
35
36
|
name === "lane_report" || name === RESULT_ATTACH_TOOL || name === "decision_ask" || name.startsWith("board_");
|
|
36
37
|
const record = (value: unknown): value is Record<string, unknown> =>
|
|
37
38
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
38
|
-
const text = (value: unknown): value is string => typeof value === "string" && value.trim().length > 0;
|
|
39
|
-
const keys = (value: Record<string, unknown>, names: string[]) =>
|
|
40
|
-
Object.keys(value).every(key => names.includes(key));
|
|
41
|
-
|
|
42
|
-
// Direct native/custom-tool dispatch can bypass model argument validation.
|
|
43
|
-
function validInput(input: unknown): input is Static<typeof parameters> {
|
|
44
|
-
if (!record(input)) return false;
|
|
45
|
-
if (!keys(input, ["status", "summary", "waiting", "evidence"]) ||
|
|
46
|
-
!text(input.summary) || input.summary.length > 4000 ||
|
|
47
|
-
!["progress", "waiting", "resolved"].includes(input.status as string)) return false;
|
|
48
|
-
if (input.evidence !== undefined && (!Array.isArray(input.evidence) || input.evidence.length > 32 ||
|
|
49
|
-
input.evidence.some(item => !record(item) || (item.kind === "file"
|
|
50
|
-
? !keys(item, ["kind", "path"]) || !text(item.path)
|
|
51
|
-
: item.kind !== "tool" || !keys(item, ["kind", "toolCallId"]) || !text(item.toolCallId))))) return false;
|
|
52
|
-
if (input.status !== "waiting" && (!Array.isArray(input.evidence) || input.evidence.length === 0)) return false;
|
|
53
|
-
if (input.status === "progress") return !Object.hasOwn(input, "waiting");
|
|
54
|
-
return isLaneWaitTarget(input.waiting);
|
|
55
|
-
}
|
|
56
39
|
|
|
57
40
|
function fileEvidence(path: string, cwd: string): LaneEvidence {
|
|
58
41
|
const source = resolve(cwd, path);
|
|
@@ -192,7 +175,7 @@ export default function laneExtension(pi: ExtensionAPI): void {
|
|
|
192
175
|
parameters,
|
|
193
176
|
async execute(id, params, _signal, _onUpdate, ctx) {
|
|
194
177
|
if (ctx.agent.kind !== "main") throw new Error("Lane reporting is restricted to the root lane session");
|
|
195
|
-
if (!
|
|
178
|
+
if (!Value.Check(parameters, params)) throw new Error("Invalid lane report parameters");
|
|
196
179
|
const target = params.status === "waiting" ? params.waiting : undefined;
|
|
197
180
|
if (target?.kind === "approval" && !approvals(ctx).has(target.id)) {
|
|
198
181
|
throw new Error("Lane approval wait requires an observed pending native tool approval");
|