omp-superagent 0.1.17 → 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/DESIGN.md +15 -12
- package/config.example.json +4 -1
- package/docs/OPERATIONS.en.md +205 -59
- package/docs/OPERATIONS.md +173 -47
- package/docs/design/execution.md +119 -37
- package/docs/design/messaging.md +160 -45
- package/docs/releases/0.1.18.md +10 -0
- 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 +6 -5
- package/skills/head/references/model-selection.md +8 -22
- package/skills/head/references/routing.md +36 -17
- 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 +21 -2
- package/src/contracts.ts +66 -7
- package/src/cron/cron-jobs.ts +135 -92
- package/src/cron/cron-pr-intake.ts +18 -11
- package/src/extension.ts +25 -10
- package/src/gateway/gateway-client.ts +3 -1
- 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/workflow.ts +12 -6
- package/src/lane-extension.ts +4 -21
- package/src/managed-super-probe.ts +21 -15
- package/src/messaging/messenger-command-catalog.json +1 -1
- package/src/messaging/messenger-commands.ts +8 -3
- package/src/messaging/result-attachment.ts +77 -19
- package/src/messaging/slack-context.ts +50 -0
- 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/omp/superkit-skills.ts +15 -2
- package/src/pr/pr-intake-order.ts +62 -0
- package/src/pr/pr-intake-review.ts +49 -31
- package/src/pr/pr-intake-work.ts +3 -2
- package/src/routing/message-order.ts +22 -1
- package/src/routing/topic-request.ts +48 -4
- package/src/runtime/controller.ts +968 -338
- package/src/runtime/deferred-routing.ts +12 -4
- package/src/runtime/dm-timeline.ts +3 -3
- 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/deferred-routing.ts +25 -4
- package/src/storage/store.ts +445 -75
- 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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Type, type Static } from "@sinclair/typebox/type";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
-
import { routeKey, type InputRecord, type OutputRecord, type StorePort } from "../contracts";
|
|
3
|
+
import { routeKey, type InputRecord, type OutputRecord, type Route, type StorePort } from "../contracts";
|
|
4
4
|
import type { CronJobs, CronPrJob } from "./cron-jobs";
|
|
5
5
|
import { parsePrRef } from "../pr/pr-github";
|
|
6
6
|
import { PrReadError } from "../pr/pr-github-schema";
|
|
7
|
-
import { intakeStatusKey } from "../pr/pr-intake-work";
|
|
7
|
+
import { intakeStatusKey, prCronCommand } from "../pr/pr-intake-work";
|
|
8
8
|
|
|
9
9
|
const offerPrefix = "cron-pr:offer:";
|
|
10
10
|
const githubId = Type.Readonly(Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }));
|
|
@@ -75,17 +75,24 @@ function sameIdentity(left: RepositoryIdentity, right: RepositoryIdentity): bool
|
|
|
75
75
|
return left.repositoryId === right.repositoryId && left.ownerId === right.ownerId;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function action(candidate: CronPrCandidate): string {
|
|
79
|
-
return
|
|
78
|
+
function action(candidate: CronPrCandidate, command: string): string {
|
|
79
|
+
return `${command} pr-review ${candidate.jobId} ${candidate.number} ${candidate.head}`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
function offerText(repository: string, candidate: CronPrCandidate): string {
|
|
83
|
-
|
|
82
|
+
function offerText(repository: string, candidate: CronPrCandidate, platform: Route["platform"]): string {
|
|
83
|
+
const command = prCronCommand(platform);
|
|
84
|
+
if (platform === "slack") {
|
|
85
|
+
return `${repository}#${candidate.number} — 새 외부 PR (${candidate.head}). `
|
|
86
|
+
+ (candidate.policyRevision ? "등록한 단계에 따라 이 메시지의 스레드에서 검토합니다. " : "")
|
|
87
|
+
+ `상태: ${command} show ${candidate.jobId} ${candidate.number}\n이 메시지의 스레드에서 수동 검토:\n${action(candidate, command)}`;
|
|
88
|
+
}
|
|
89
|
+
if (candidate.policyRevision) return `${repository}#${candidate.number} — 새 외부 PR (${candidate.head}). 등록한 단계에 따라 이 메시지에 전용 검토 스레드를 엽니다. 상태: /cron show ${candidate.jobId} ${candidate.number}\n수동 검토:\n${action(candidate, command)}`;
|
|
84
90
|
return `New external pull request: ${repository}#${candidate.number}. `
|
|
85
|
-
+ `The following owner command starts a read-only review; it does not merge or change the pull request.\n\n${action(candidate)}`;
|
|
91
|
+
+ `The following owner command starts a read-only review; it does not merge or change the pull request.\n\n${action(candidate, command)}`;
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
export function describePrIntake(store: StorePort, job: CronPrJob, number: number | null): string {
|
|
95
|
+
const command = prCronCommand(store.input(job.sourceId)?.route.platform ?? "discord");
|
|
89
96
|
const newest = ledger(store, job.repository)?.candidates.filter(candidate => candidate.jobId === job.id).reverse() ?? [];
|
|
90
97
|
const summary = job.lastRunId ? store.getMeta(outcomeKey(job.lastRunId)) : null;
|
|
91
98
|
const selected = number === null ? newest.slice(0, 10) : newest.filter(candidate => candidate.number === number);
|
|
@@ -96,12 +103,12 @@ export function describePrIntake(store: StorePort, job: CronPrJob, number: numbe
|
|
|
96
103
|
: candidate.epoch === job.epoch && open
|
|
97
104
|
? "deferred; up to one offer per scan" : "deferred offer suppressed; manual review only";
|
|
98
105
|
const progress = store.getMeta(intakeStatusKey(job.id, candidate.number));
|
|
99
|
-
return `${action(candidate)} (${status})${progress ? ` — ${progress}` : ""}`;
|
|
106
|
+
return `${action(candidate, command)} (${status})${progress ? ` — ${progress}` : ""}`;
|
|
100
107
|
});
|
|
101
108
|
return [
|
|
102
109
|
summary,
|
|
103
110
|
lines.length ? `Recorded PR offers:\n${lines.join("\n")}` : "No matching PR offers recorded.",
|
|
104
|
-
number === null && newest.length > selected.length ? `Showing the latest ${selected.length} of ${newest.length}; use
|
|
111
|
+
number === null && newest.length > selected.length ? `Showing the latest ${selected.length} of ${newest.length}; use ${command} show ${job.id} PR_NUMBER for an older offer.` : null,
|
|
105
112
|
].filter(Boolean).join("\n");
|
|
106
113
|
}
|
|
107
114
|
|
|
@@ -139,7 +146,7 @@ export class CronPrIntake {
|
|
|
139
146
|
const active = this.jobs.activePrEnrollment(candidate.jobId);
|
|
140
147
|
return active !== null && active.job.repository === repository && candidate.epoch === active.job.epoch
|
|
141
148
|
&& output.sourceId === active.source.id && routeKey(output.route) === routeKey(active.source.route)
|
|
142
|
-
&& output.text === offerText(repository, candidate);
|
|
149
|
+
&& output.text === offerText(repository, candidate, active.source.route.platform);
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
async consume(input: InputRecord, signal: AbortSignal): Promise<IntakeScan | undefined> {
|
|
@@ -223,7 +230,7 @@ export class CronPrIntake {
|
|
|
223
230
|
try {
|
|
224
231
|
this.store.queueOutput({
|
|
225
232
|
id: chosen.outputId, sourceId: current.source.id, route: current.source.route,
|
|
226
|
-
text: offerText(current.job.repository, chosen),
|
|
233
|
+
text: offerText(current.job.repository, chosen, current.source.route.platform),
|
|
227
234
|
});
|
|
228
235
|
} catch (error) {
|
|
229
236
|
this.finish(input.id, "The PR offer was claimed but outbox creation was interrupted; inspect the recorded status.", "cancelled");
|
package/src/extension.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type { PrWatchCommand } from "./pr/pr-watch";
|
|
|
20
20
|
import type { LaneWatchCommand } from "./lane/lane-watch";
|
|
21
21
|
import { registerDecisionAsk } from "./lane/decision-tool";
|
|
22
22
|
import { registerResultAttach, RESULT_ATTACH_TOOL } from "./messaging/result-attachment";
|
|
23
|
+
import { registerSlackContext } from "./messaging/slack-context";
|
|
23
24
|
import { HEAD_ROTATION_GUARD, HEAD_ROTATION_PROBE, HEAD_SLEEP_PROBE_READY, type HeadSleepProbeReadyEvent,
|
|
24
25
|
type RotationGuardEvent, type RotationProbeEvent } from "./runtime/head-rotation";
|
|
25
26
|
import { readHeadQuota } from "./runtime/head-quota";
|
|
@@ -70,6 +71,7 @@ const managerTools: Record<string, true> = {
|
|
|
70
71
|
thread_inspect: true, lane_thread_update: true,
|
|
71
72
|
messenger_presence: true,
|
|
72
73
|
discord_context: true, discord_purpose_list: true, discord_purpose_set: true, discord_purpose_clear: true,
|
|
74
|
+
slack_context: true, slack_purpose_list: true, slack_purpose_set: true, slack_purpose_clear: true,
|
|
73
75
|
pr_watch: true, pr_watch_list: true,
|
|
74
76
|
decision_list: true, decision_inspect: true, decision_withdraw: true,
|
|
75
77
|
[RESULT_ATTACH_TOOL]: true,
|
|
@@ -86,7 +88,6 @@ const workflowSchema = Type.Optional(workflowSelection);
|
|
|
86
88
|
const laneModelSelection = {
|
|
87
89
|
model: Type.Optional(Type.Object({ provider: Type.String({ minLength: 1 }), id: Type.String({ minLength: 1 }) })),
|
|
88
90
|
preset: Type.Optional(Type.String({ minLength: 1 })),
|
|
89
|
-
modelReason: Type.String({ minLength: 1 }),
|
|
90
91
|
} as const;
|
|
91
92
|
const threadTagsSchema = Type.Array(Type.String({ pattern: "^[0-9]{1,20}$" }), { maxItems: 5, uniqueItems: true });
|
|
92
93
|
const laneRouteSchema = Type.Object({
|
|
@@ -195,6 +196,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
195
196
|
if (ctx.agent.kind === "main" && runtime?.laneRecoveryActive() && Object.hasOwn(managerTools, event.toolName)) {
|
|
196
197
|
switch (event.toolName) {
|
|
197
198
|
case "lane_models": case "lane_inspect": case "thread_inspect": case "discord_context": case "discord_purpose_list":
|
|
199
|
+
case "slack_context": case "slack_purpose_list":
|
|
198
200
|
case "decision_list": case "decision_inspect": case "pr_watch_list":
|
|
199
201
|
// The runtime validates their exact report source, target and current authority.
|
|
200
202
|
case "lane_message": case "lane_set_model":
|
|
@@ -314,7 +316,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
314
316
|
});
|
|
315
317
|
pi.registerTool({
|
|
316
318
|
name: "lane_models", label: "Inspect lane model candidates", approval: "read", loadMode: "essential",
|
|
317
|
-
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.",
|
|
318
320
|
parameters: Type.Object({ selectors: Type.Optional(Type.Array(Type.String(), { minItems: 1 })) }),
|
|
319
321
|
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
320
322
|
const available = await requireRuntime(ctx).availableModels();
|
|
@@ -340,7 +342,7 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
340
342
|
candidates: selected,
|
|
341
343
|
nativePresets: inspection,
|
|
342
344
|
...(resolutions ? { resolutions } : {}),
|
|
343
|
-
guidance: "Catalog
|
|
345
|
+
guidance: "Catalog fields describe capabilities and prices, not measured performance, quota, or authority to spend.",
|
|
344
346
|
});
|
|
345
347
|
},
|
|
346
348
|
});
|
|
@@ -363,25 +365,36 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
363
365
|
});
|
|
364
366
|
pi.registerTool({
|
|
365
367
|
name: "lane_start", label: "Start independent work", loadMode: "essential", approval: "exec",
|
|
366
|
-
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.",
|
|
367
369
|
parameters: Type.Object({
|
|
368
370
|
sourceId: Type.String(), title: Type.String(), cwd: Type.String(),
|
|
369
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." }),
|
|
370
372
|
...laneModelSelection,
|
|
373
|
+
modelReason: Type.Optional(Type.String()),
|
|
371
374
|
brief: Type.Optional(Type.String()), acceptance: Type.Optional(Type.Array(Type.String())),
|
|
372
375
|
workflow: workflowSchema,
|
|
373
376
|
placement: Type.Optional(Type.Object({
|
|
374
377
|
target: Type.Optional(Type.Union([Type.Literal("local"), Type.Literal("remote")])),
|
|
375
378
|
platform: Type.Optional(Type.Union([Type.Literal("linux"), Type.Literal("darwin")])),
|
|
376
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." })),
|
|
377
384
|
}, {
|
|
378
385
|
additionalProperties: false,
|
|
379
|
-
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.",
|
|
380
387
|
})),
|
|
381
388
|
appliedTags: Type.Optional(threadTagsSchema),
|
|
382
389
|
destination: Type.Optional(laneRouteSchema),
|
|
383
390
|
}),
|
|
384
|
-
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
391
|
+
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
392
|
+
const controller = requireRuntime(ctx);
|
|
393
|
+
const lane = await controller.startLane(params);
|
|
394
|
+
const kickoff = controller.store.output(`${params.sourceId}:kickoff`);
|
|
395
|
+
return result(kickoff && kickoff.state !== "sent"
|
|
396
|
+
? { ...lane, kickoff: { outputId: kickoff.id, state: kickoff.state } } : lane);
|
|
397
|
+
},
|
|
385
398
|
});
|
|
386
399
|
pi.registerTool({
|
|
387
400
|
name: "pr_watch_list", label: "Inspect tracked pull requests", approval: "read",
|
|
@@ -416,8 +429,8 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
416
429
|
},
|
|
417
430
|
});
|
|
418
431
|
pi.registerTool({
|
|
419
|
-
name: "thread_inspect", label: "Inspect
|
|
420
|
-
description: "Read the original
|
|
432
|
+
name: "thread_inspect", label: "Inspect messenger thread", approval: "read",
|
|
433
|
+
description: "Read the original authorized Discord guild channel/thread or Slack thread, or an explicitly selected managed lane's thread. For Discord an eligible alternate guild parent may be selected instead via destination (threadId:null, no topicId). Discord returns tag policy, title and archive state; Slack verifies the exact root and whether the bot's managed starter label is editable. Slack has no native thread archive status or forum tags. This never creates a topic, changes lane state, or reads a conversation transcript.",
|
|
421
434
|
parameters: Type.Object({
|
|
422
435
|
sourceId: Type.String({ minLength: 1 }), laneId: Type.Optional(Type.String({ minLength: 1 })),
|
|
423
436
|
destination: Type.Optional(laneRouteSchema),
|
|
@@ -427,8 +440,8 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
427
440
|
},
|
|
428
441
|
});
|
|
429
442
|
pi.registerTool({
|
|
430
|
-
name: "lane_thread_update", label: "Manage a lane's
|
|
431
|
-
description: "Explicitly
|
|
443
|
+
name: "lane_thread_update", label: "Manage a lane's messenger thread", approval: "exec",
|
|
444
|
+
description: "Explicitly change a managed lane's thread under an original user sourceId. On Slack, only title is supported and only when the bot created the managed starter message; do not edit the user's root, or simulate tags, archive or reopen. On Discord, ManageThreads permits title, tag and archive changes; appliedTags replaces the full set using observed IDs. Omitted fields stay unchanged. Archiving never pauses a lane; reopening never resumes it. A repeated source returns its historical receipt without reapplying edits. After an uncertain response, inspect and use a new explicit user request rather than retrying.",
|
|
432
445
|
parameters: Type.Object({
|
|
433
446
|
id: Type.String({ minLength: 1 }), sourceId: Type.String({ minLength: 1 }),
|
|
434
447
|
changes: Type.Union([
|
|
@@ -479,12 +492,14 @@ export default function superagentExtension(pi: ExtensionAPI): void {
|
|
|
479
492
|
return result(await requireRuntime(ctx).discordPurpose({ ...params, action: "clear" }));
|
|
480
493
|
},
|
|
481
494
|
});
|
|
495
|
+
registerSlackContext(pi, requireRuntime);
|
|
482
496
|
pi.registerTool({
|
|
483
497
|
name: "lane_set_model", label: "Change an idle lane model", approval: "exec",
|
|
484
498
|
description: "Explicitly change one idle lane's model or full native preset snapshot without changing global OMP settings, the head, or other lanes. Requires a received authorized sourceId, exactly one model/preset and modelReason. Refuses active work, approvals/services/goals or unresolved submissions. Uses durable intent and native readback; do not blindly repeat an uncertain change.",
|
|
485
499
|
parameters: Type.Object({
|
|
486
500
|
id: Type.String(), sourceId: Type.String(),
|
|
487
501
|
...laneModelSelection,
|
|
502
|
+
modelReason: Type.String({ minLength: 1 }),
|
|
488
503
|
}),
|
|
489
504
|
async execute(_id, params, _signal, _onUpdate, ctx) { return result(await requireRuntime(ctx).changeModel(params)); },
|
|
490
505
|
});
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./gateway-protocol";
|
|
11
11
|
import type { GatewayReceipt, QueuedEvent } from "./gateway-wire";
|
|
12
12
|
import type { GroupReply } from "../group/group-policy";
|
|
13
|
-
import type { DiscordPresenceStatus, MessengerPresenceRequest } from "../contracts";
|
|
13
|
+
import type { DiscordPresenceStatus, MessengerPresenceRequest, SlackContext, SlackContextRequest, SlackPurposeNote, SlackPurposeRequest } from "../contracts";
|
|
14
14
|
|
|
15
15
|
export interface GatewayHeadMessenger extends Messenger {
|
|
16
16
|
assertRoute(route: Route, purpose?: "history" | "bound-work"): Promise<void>;
|
|
@@ -246,6 +246,8 @@ class GatewayMessenger implements GatewayHeadMessenger {
|
|
|
246
246
|
return this.effect("messengerPresence", [request]);
|
|
247
247
|
}
|
|
248
248
|
discordPurpose(request: DiscordPurposeRequest): Promise<readonly DiscordPurposeNote[]> { return this.effect("discordPurpose", [request]); }
|
|
249
|
+
inspectSlackContext(request: SlackContextRequest): Promise<SlackContext> { return this.effect("inspectSlackContext", [request]); }
|
|
250
|
+
slackPurpose(request: SlackPurposeRequest): Promise<readonly SlackPurposeNote[]> { return this.effect("slackPurpose", [request]); }
|
|
249
251
|
fetchAfter(route: Route, messageId: string, historySequence?: number): Promise<Inbound[] | null> {
|
|
250
252
|
return this.effect("fetchAfter", historySequence === undefined ? [route, messageId] : [route, messageId, historySequence]);
|
|
251
253
|
}
|
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/workflow.ts
CHANGED
|
@@ -58,11 +58,17 @@ export function leadingWorkflow(text: string): WorkflowName | null {
|
|
|
58
58
|
return leadingInvocation(text)?.name ?? null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
export function ownerWorkflowRequest(input: Inbound, task: string): {
|
|
61
|
+
/** Placement and formatting views may not supply an otherwise absent written selector. */
|
|
62
|
+
export function ownerWorkflowRequest(input: Inbound, task: string, unverifiedSlackPlacementTask = false): {
|
|
63
63
|
readonly name: WorkflowName | null;
|
|
64
64
|
readonly projection?: { readonly text: string; readonly selectorChanged: boolean };
|
|
65
65
|
} {
|
|
66
|
+
if (input.route.platform === "slack" && !input.pickerSelection
|
|
67
|
+
&& (unverifiedSlackPlacementTask || input.routingText !== undefined && input.routingText !== input.text)) {
|
|
68
|
+
const exposed = leadingInvocation(task);
|
|
69
|
+
// Do not pass a newly leading selector to OMP's native matcher either.
|
|
70
|
+
return exposed ? { name: null, projection: { text: task.slice(exposed.length), selectorChanged: true } } : { name: null };
|
|
71
|
+
}
|
|
66
72
|
if (input.route.platform !== "telegram" || input.pickerSelection || input.routingText === input.text)
|
|
67
73
|
return { name: leadingWorkflow(task) };
|
|
68
74
|
|
|
@@ -153,10 +159,10 @@ export function workflowPrompt(activation: WorkflowActivation, source: WorkflowS
|
|
|
153
159
|
// negated, suppresses that default and is left for OMP's native prose matcher.
|
|
154
160
|
// Check before adding context, whose metadata must not change this decision.
|
|
155
161
|
const nativeDefault = keyword && !explicitDelimiter && !nativeWords.test(argumentsText) ? ` ${keyword}` : "";
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
// as "ulw-plan".
|
|
159
|
-
const keepInvocation = selected && (
|
|
162
|
+
// Keep an admitted spelling that matches the live Host's vocabulary. A
|
|
163
|
+
// canonical Host no longer needs to recognize ULW aliases; an old Host
|
|
164
|
+
// still distinguishes spellings such as "ulwplan" and "ulw-plan".
|
|
165
|
+
const keepInvocation = selected && (legacyCommand ? selected.legacy : !selected.legacy);
|
|
160
166
|
// A worker takes ordinary prose, not native slash-command dispatch.
|
|
161
167
|
const prefix = worker ? invocationText.replace(/^(\s*)\//, "$1") : invocationText;
|
|
162
168
|
const request = keepInvocation
|
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");
|