omp-superagent 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/DESIGN.md +27 -16
  2. package/README.ko.md +40 -19
  3. package/README.md +43 -18
  4. package/THIRD_PARTY_NOTICES.md +11 -11
  5. package/config.example.json +2 -1
  6. package/docs/OPERATIONS.md +285 -85
  7. package/docs/design/execution.md +133 -24
  8. package/docs/design/messaging.md +235 -50
  9. package/docs/discord-voice.md +8 -4
  10. package/docs/releases/0.1.8.md +21 -0
  11. package/docs/releases/0.1.9.md +18 -0
  12. package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
  13. package/gateway/bin/omp-gateway-darwin-x64 +0 -0
  14. package/gateway/bin/omp-gateway-linux-arm64 +0 -0
  15. package/gateway/bin/omp-gateway-linux-x64 +0 -0
  16. package/host-owner/bin/notices/darwin-arm64/Cargo-LICENSES.txt +2 -0
  17. package/host-owner/bin/notices/darwin-arm64/Cargo-SOURCES.txt +2 -0
  18. package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  19. package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  20. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  21. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  22. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  23. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  24. package/host-owner/bin/notices/darwin-x64/Cargo-LICENSES.txt +2 -0
  25. package/host-owner/bin/notices/darwin-x64/Cargo-SOURCES.txt +2 -0
  26. package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  27. package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  28. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  29. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  30. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  31. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  32. package/host-owner/bin/notices/linux-arm64/Cargo-LICENSES.txt +3 -0
  33. package/host-owner/bin/notices/linux-arm64/Cargo-SOURCES.txt +3 -0
  34. package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  35. package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  36. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
  37. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
  38. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  39. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
  40. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  41. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  42. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  43. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  44. package/host-owner/bin/notices/linux-x64/Cargo-LICENSES.txt +3 -0
  45. package/host-owner/bin/notices/linux-x64/Cargo-SOURCES.txt +3 -0
  46. package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  47. package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  48. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
  49. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
  50. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  51. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
  52. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  53. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  54. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  55. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  56. package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
  57. package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
  58. package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
  59. package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
  60. package/package.json +17 -15
  61. package/skills/head/SKILL.md +3 -11
  62. package/skills/head/references/routing.md +23 -17
  63. package/skills/head/references/supervision.md +13 -1
  64. package/skills/lane/references/workflow.md +8 -8
  65. package/src/cli.ts +6 -3
  66. package/src/config.ts +5 -0
  67. package/src/contracts.ts +95 -10
  68. package/src/cron-jobs.ts +443 -19
  69. package/src/cron-pr-intake.ts +257 -0
  70. package/src/discord-command-registration.ts +34 -186
  71. package/src/extension.ts +31 -3
  72. package/src/gateway-client.ts +11 -59
  73. package/src/gateway-protocol.ts +35 -1
  74. package/src/head-quota.ts +80 -0
  75. package/src/head-recovery.ts +249 -1
  76. package/src/host-extension.ts +194 -5
  77. package/src/host-protocol.ts +16 -9
  78. package/src/host-sdk-helper.ts +105 -10
  79. package/src/host.ts +111 -29
  80. package/src/installed-omp.ts +116 -4
  81. package/src/lane-models.ts +8 -0
  82. package/src/managed-ulw-probe.ts +22 -20
  83. package/src/managed-ulw.ts +137 -24
  84. package/src/messenger-command-catalog.json +6 -3
  85. package/src/messenger-commands.ts +9 -2
  86. package/src/native-presets.ts +32 -5
  87. package/src/omp-usage.ts +254 -36
  88. package/src/operator.ts +77 -0
  89. package/src/pr-github-schema.ts +2 -0
  90. package/src/pr-github.ts +4 -2
  91. package/src/pr-intake-automation.ts +315 -0
  92. package/src/pr-intake-comment.ts +225 -0
  93. package/src/pr-intake-fix.ts +232 -0
  94. package/src/pr-intake-github.ts +479 -0
  95. package/src/pr-intake-material.ts +229 -0
  96. package/src/pr-intake-mode.ts +59 -0
  97. package/src/pr-intake-review.ts +397 -0
  98. package/src/pr-intake-tree.ts +68 -0
  99. package/src/pr-intake-work.ts +29 -0
  100. package/src/pr-review-models.ts +28 -0
  101. package/src/result-attachment.ts +60 -79
  102. package/src/runtime.ts +2968 -449
  103. package/src/setup-profiles.ts +26 -65
  104. package/src/slack-command-registration.ts +48 -197
  105. package/src/store.ts +507 -87
  106. package/src/superkit-skills.ts +22 -0
  107. package/src/telegram-command-languages.json +17 -0
  108. package/src/telegram-command-registration.ts +32 -134
  109. package/src/topic-history.ts +30 -17
  110. package/src/worker-bridge.ts +21 -0
  111. package/src/worker-enrollment.ts +2 -1
  112. package/src/worker-host.ts +0 -24
  113. package/src/worker-serve-prepare.ts +19 -0
  114. package/src/worker-service.ts +51 -47
  115. package/scripts/ci.ts +0 -44
  116. package/scripts/release.ts +0 -112
  117. package/scripts/test-omp.sh +0 -43
  118. package/src/discord-commands.ts +0 -29
  119. package/src/discord-markdown.ts +0 -172
  120. package/src/slack-commands.ts +0 -18
  121. package/src/telegram-signal.ts +0 -14
  122. package/src/worker-stdio.ts +0 -61
@@ -51,14 +51,14 @@ substitute or unobserved activation.
51
51
  actually activated, and a goal exists. Plain SUPER selects no specialty mode and
52
52
  RPC activation alone creates no goal.
53
53
 
54
- | `workflow.name` | Installed skill |
55
- | --- | --- |
56
- | `super` | `skill://ultrawork` |
57
- | `super-plan` | `skill://ulw-plan` |
58
- | `super-run` | `skill://ulw-execute` |
59
- | `super-loop` | `skill://ulw-loop` |
60
- | `super-research` | `skill://ulw-research` |
61
- | `super-graph` | `skill://mass-ulw` |
54
+ | `workflow.name` | Installed skill | Fallback when the legacy revision has no canonical skill |
55
+ | --- | --- | --- |
56
+ | `super` | `skill://super` | `skill://ultrawork` |
57
+ | `super-plan` | `skill://super-plan` | `skill://ulw-plan` |
58
+ | `super-run` | `skill://super-run` | `skill://ulw-execute` |
59
+ | `super-loop` | `skill://super-loop` | `skill://ulw-loop` |
60
+ | `super-research` | `skill://super-research` | `skill://ulw-research` |
61
+ | `super-graph` | `skill://super-graph` | `skill://mass-ulw` |
62
62
 
63
63
  ## Implement and verify
64
64
 
package/src/cli.ts CHANGED
@@ -87,11 +87,15 @@ Owner controls in chat (not shell commands):
87
87
  Send /help in Discord or Telegram. In Slack messages replace / with ! (e.g. !help, !status);
88
88
  registered Slack commands use /superagent-* (e.g. /superagent-status).
89
89
  /status, /context, /usage Inspect HEAD state, context or usage without starting a model turn.
90
+ /usage-reset (Discord) List saved reset tickets; choose an account then confirm to spend one.
91
+ Telegram: /usage reset. Slack: !usage reset or /superagent-usage reset.
90
92
  /model [list|provider/id] Inspect or select the shared HEAD model; changes require an idle HEAD.
91
93
  /model preset [list|NAME] Inspect or select a preset. Only NAME --global also saves future defaults.
92
94
  /effort [LEVEL] Inspect or change HEAD thinking effort; existing lanes keep their settings.
93
95
  /compact [instructions] Compact idle HEAD context, optionally with multiline instructions.
94
96
  /cron [help] Schedule and manage one-time or recurring jobs in this conversation.
97
+ /cron pr-add "every 5m" OWNER/REPO Review newly opened external PRs and comment on GitHub (Discord guild parent).
98
+ /cron pr-mode JOB review|fix|merge Set the unattended ceiling: comment only, safe fix, or gated merge. Korean mode phrases also work.
95
99
  /new [request], /main Start a topic or return to the main topic in the owner's DM.
96
100
  /stop [head|LANE_ID] Stop work, not the service. Pause the bound lane, or reply to select a
97
101
  pending placement or active request. Use /stop head for the global stop.
@@ -244,9 +248,8 @@ async function workerCommand(args: string[]): Promise<void> {
244
248
  throw new Error("Worker serve requires the enrolled SSH forced command");
245
249
  const { readWorkerPolicy } = await import("./worker-enrollment");
246
250
  const policy = readWorkerPolicy(homedir(), path);
247
- const { serveWorker } = await import("./worker-service");
248
- await serveWorker(policy);
249
- return;
251
+ const { execWorkerBridge } = await import("./worker-bridge");
252
+ return execWorkerBridge(policy, path);
250
253
  }
251
254
  default:
252
255
  throw new Error("Usage: omp-sa worker add|init|list|doctor (see omp-sa worker --help)");
package/src/config.ts CHANGED
@@ -10,6 +10,7 @@ export interface DiscordConfig {
10
10
  allowedGuildIds: string[];
11
11
  allowedChannelIds: string[];
12
12
  readonly requireAddressing?: boolean;
13
+ readonly editProgressInPlace?: boolean;
13
14
  voice?: DiscordVoiceConfig;
14
15
  }
15
16
 
@@ -216,6 +217,9 @@ export function parseConfig(value: unknown, path: string): Config {
216
217
  const requireAddressing = discord?.requireAddressing;
217
218
  if (requireAddressing !== undefined && typeof requireAddressing !== "boolean")
218
219
  throw new Error("discord.requireAddressing must be a boolean");
220
+ const editProgressInPlace = discord?.editProgressInPlace;
221
+ if (editProgressInPlace !== undefined && typeof editProgressInPlace !== "boolean")
222
+ throw new Error("discord.editProgressInPlace must be a boolean");
219
223
  const voice = discord?.voice === undefined ? undefined : record(discord.voice, "discord.voice");
220
224
  let voiceConfig: DiscordVoiceConfig | undefined;
221
225
  if (voice) {
@@ -265,6 +269,7 @@ export function parseConfig(value: unknown, path: string): Config {
265
269
  allowedGuildIds: ids(discord.allowedGuildIds, "discord.allowedGuildIds"),
266
270
  allowedChannelIds: discordChannels,
267
271
  requireAddressing: requireAddressing ?? false,
272
+ editProgressInPlace: editProgressInPlace ?? false,
268
273
  ...(voiceConfig ? { voice: voiceConfig } : {}),
269
274
  } } : {}),
270
275
  ...(telegram ? { telegram: {
package/src/contracts.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { ModelPreset as NativeModelPreset } from "@oh-my-pi/pi-coding-agent/config/model-settings";
2
2
  import type { LaneEvidence, LaneReport, LaneWaitTarget } from "./lane-report";
3
3
  import type { CronUpdate } from "./cron-jobs";
4
+ import type { ReviewRound } from "./pr-intake-review";
4
5
  import type { GroupReply, GroupRequest } from "./group-policy";
5
6
  import type { StagedResultAttachment } from "./result-attachment";
6
7
  import type { RemotePlacement } from "./worker-wire";
8
+ import type { OmpResetAccount } from "./omp-usage";
7
9
 
8
10
  /** Coordination records only. OMP owns transcripts and execution state. */
9
11
  export type Platform = "discord" | "telegram" | "slack";
@@ -38,6 +40,12 @@ export function physicalRouteKey(route: Route): string {
38
40
  return routeKey(physicalRoute(route));
39
41
  }
40
42
 
43
+ /** Store meta key: owner inputs acknowledged to Gateway whose topic routing is still pending, in delivery order. */
44
+ export const DEFERRED_ROUTING_META = "intake:deferred-routing";
45
+
46
+ /** Exact successor generation reserved when a submitted card is authorized to restore its original lane session. */
47
+ export const laneModelPickerRestoreKey = (sourceId: string) => `lane-model:picker-restore:${sourceId}`;
48
+
41
49
  export interface Attachment {
42
50
  id: string;
43
51
  name: string;
@@ -113,6 +121,10 @@ export interface Inbound {
113
121
  readonly cardId: string;
114
122
  readonly group: number;
115
123
  readonly option: number;
124
+ /** Emitted only when the final model choice is made on a scoped Discord card. */
125
+ readonly target?: "head" | "lane";
126
+ /** Emitted only by the reset picker's separate Confirm action. */
127
+ readonly confirmed?: true;
116
128
  };
117
129
  text: string;
118
130
  /** Physical Discord content when `text` is an addressed command or a confirmed voice draft. */
@@ -137,6 +149,13 @@ export interface LaneModel {
137
149
  provider: string;
138
150
  id: string;
139
151
  }
152
+ export const laneFallbackKey = (id: string) => `lane-model:${id}:fallback`;
153
+ export interface LaneFallbackReceipt {
154
+ readonly sessionId: string;
155
+ readonly generation: number;
156
+ readonly hostPid: number;
157
+ readonly entryId: string;
158
+ }
140
159
  export const HEAD_MODEL_CONTROL = "head:model-control";
141
160
  export interface HeadModelChange {
142
161
  readonly sourceId: string;
@@ -224,10 +243,34 @@ export type HeadPicker = {
224
243
  readonly current?: string;
225
244
  readonly groups: readonly { readonly label: string; readonly options: readonly string[] }[];
226
245
  } & (
227
- | { readonly kind: "model"; readonly currentProvider?: string }
246
+ | { readonly kind: "model"; readonly currentProvider?: string; readonly modelTargets?: {
247
+ readonly lane?: {
248
+ readonly id: string;
249
+ readonly generation: number;
250
+ readonly sessionId: string | null;
251
+ readonly current?: string;
252
+ readonly currentProvider?: string;
253
+ /** If present, the canonical option indices allowed in each HEAD group. Empty means no lane choices. */
254
+ readonly allowedOptions?: readonly (readonly number[])[];
255
+ };
256
+ } }
228
257
  | { readonly kind: "effort"; readonly forModel: LaneModel }
258
+ | { readonly kind: "usage-reset"; readonly accounts: readonly Pick<OmpResetAccount, "target" | "label" | "identity" | "offer">[] }
229
259
  );
230
260
 
261
+ /** Both admission and durable lane writes resolve the same original card coordinates. */
262
+ export function resolvePickerOption(picker: HeadPicker, selection: NonNullable<Inbound["pickerSelection"]>) {
263
+ if (!Number.isSafeInteger(selection.group) || selection.group < 0
264
+ || !Number.isSafeInteger(selection.option) || selection.option < 0) return null;
265
+ if (selection.target === "lane") {
266
+ const lane = picker.kind === "model" ? picker.modelTargets?.lane : undefined;
267
+ if (!lane || lane.allowedOptions !== undefined && !lane.allowedOptions?.[selection.group]?.includes(selection.option)) return null;
268
+ }
269
+ const group = picker.groups[selection.group];
270
+ const option = group?.options[selection.option];
271
+ return group && option ? { group, option } : null;
272
+ }
273
+
231
274
  export interface KickoffHold {
232
275
  readonly outputId: string;
233
276
  readonly state: OutputState | "missing";
@@ -238,6 +281,10 @@ export interface OutputRecord {
238
281
  route: Route;
239
282
  /** Durable original owner message, only in the same physical conversation. */
240
283
  replyTo?: MessageReference;
284
+ /** Discord status message replaced in place; fixed when the output is claimed. */
285
+ readonly editOf?: MessageReference;
286
+ /** Initial Discord status message; overflow falls back to one attachment instead of multi-message split. */
287
+ readonly status?: boolean;
241
288
  readonly picker?: HeadPicker;
242
289
  readonly resultAttachment?: StagedResultAttachment;
243
290
  text: string;
@@ -246,6 +293,17 @@ export interface OutputRecord {
246
293
  error: string | null;
247
294
  }
248
295
 
296
+ export type SettlementOutput = Pick<OutputRecord, "id" | "text" | "picker"> & {
297
+ /** Controller-only lane failure routing, never derived from output text. */
298
+ readonly laneFailure?: "quota" | "recover";
299
+ };
300
+
301
+ export interface LaneRecoveryScope {
302
+ readonly lane: Lane;
303
+ readonly failed: InputRecord;
304
+ readonly original: InputRecord;
305
+ }
306
+
249
307
  export interface Approval {
250
308
  id: string;
251
309
  target: string;
@@ -303,9 +361,17 @@ export interface HeadRecoveryEffect {
303
361
  }
304
362
 
305
363
  export interface StorePort {
364
+ /** Typed, noninteractive work on the confirmed bot offer; never valid for ordinary owner intake. */
365
+ receivePrWork(input: Inbound, target: string | null, round: ReviewRound): boolean;
306
366
  receive(input: Inbound, target: string | null, metadata?: Readonly<Record<string, string>>, workflow?: WorkflowActivation | null): boolean;
307
367
  input(id: string): InputRecord | null;
308
368
  ownerSource(id: string): InputRecord | null;
369
+ /** Revalidate a report's exact failed admission, actionable owner and operator selection. */
370
+ laneRecoveryScope(reportId: string): LaneRecoveryScope | null;
371
+ /** Original parent route for a redirected report or a handoff derived from that report. */
372
+ reportApprovalSource(id: string): InputRecord | null;
373
+ /** Manager handoff's verified reply route, pinned for a parent-origin thread follow-up or a joined bound reply. */
374
+ laneReplyRoute(input: InputRecord, source: InputRecord): Route;
309
375
  /** Exact original owner and authorized delivery route for a topic-owned lane input. */
310
376
  topicDelivery(id: string): { readonly source: InputRecord; readonly route: Route; readonly outputSourceId: string } | null;
311
377
  /** Whether an unowned dialog could belong to a durable topic admission on this native generation. */
@@ -316,6 +382,11 @@ export interface StorePort {
316
382
  tryAutoTopicChoice(input: InputRecord, deadline: number, pin: string): boolean;
317
383
  inputs(target?: string, state?: ActiveInputState): InputRecord[];
318
384
  hasInput(target: string, state: ActiveInputState): boolean;
385
+ /** Latest admitted lane run, excluding inputs joined to another run. */
386
+ latestLaneRun(target: string): InputRecord | null;
387
+ /** A successful lane run still has an unresolved final report or delivery. */
388
+ hasPendingLaneResult(target: string): boolean;
389
+ hasPendingLanePlacement(target: string): boolean;
319
390
  /** An uncertain HEAD input with a nonempty original native-owner record. */
320
391
  hasHeadRecoveryInput(): boolean;
321
392
  /** No automatic head replacement while an original HEAD delivery is unresolved. */
@@ -342,19 +413,20 @@ export interface StorePort {
342
413
  bindInput(id: string, target: string): void;
343
414
  submit(id: string, requestId: string, generation: number): boolean;
344
415
  /** Nonterminal native assistant observation; never settles or dispatches its owner. */
345
- progress(id: string, generation: number, sessionId: string, eventId: string, text: string): boolean;
416
+ progress(id: string, generation: number, sessionId: string, eventId: string, text: string, editInPlace?: boolean): boolean;
346
417
  recordLaneReport(id: string, generation: number, sessionId: string, eventId: string, report: LaneReport, observedAt?: number): boolean;
347
418
  resolveLaneWaiting(id: string, generation: number, sessionId: string, kind: "tool" | "approval", nativeId: string): boolean;
348
- settle(id: string, state: "done" | "uncertain" | "cancelled", output?: Pick<OutputRecord, "id" | "text" | "picker">, headModel?: HeadModelChange): boolean;
419
+ settle(id: string, state: "done" | "uncertain" | "cancelled", output?: SettlementOutput, headModel?: HeadModelChange, editInPlace?: boolean): boolean;
349
420
  settleCronControl(inputId: string, update: CronUpdate): boolean;
350
421
  resolveLaneInput(controlId: string, laneId: string, inputId: string, output: { readonly id: string; readonly text: string }): boolean;
351
422
  headRecoveryEffects(inputId: string): HeadRecoveryEffect[];
352
423
  prepareHeadRecovery(attempt: HeadRecoveryAttempt): boolean;
353
424
  commitHeadRecovery(expected: HeadRecoveryAttempt, decided: HeadRecoveryAttempt): boolean;
354
- queueOutput(output: Omit<OutputRecord, "state" | "remoteId" | "error">): boolean;
425
+ queueOutput(output: Omit<OutputRecord, "state" | "remoteId" | "error" | "editOf">): boolean;
426
+ recordHeadHoldNotice(blockerId: string, output: Omit<OutputRecord, "state" | "remoteId" | "error" | "editOf">): boolean;
355
427
  output(id: string): OutputRecord | null;
356
- outputs(): OutputRecord[];
357
- claimOutput(id: string): boolean;
428
+ outputs(physicalRoute?: string): OutputRecord[];
429
+ claimOutput(id: string, editInPlace?: boolean): boolean;
358
430
  finishOutput(id: string, state: "sent" | "uncertain" | "failed" | "pending", remoteId?: string, error?: string): void;
359
431
  createLane(lane: Lane & { model: LaneModel; modelReason: string }, sourceId: string): Lane;
360
432
  lane(id: string): Lane | null;
@@ -363,10 +435,12 @@ export interface StorePort {
363
435
  updateLane(id: string, generation: number, patch: Partial<Pick<Lane,
364
436
  "workState" | "runtimeState" | "sessionId" | "pid" | "lastActivityAt" | "result"
365
437
  >>): boolean;
366
- nextGeneration(id: string): Lane;
438
+ nextGeneration(id: string, pickerRestoreSourceId?: string): Lane;
367
439
  adoptLaneModel(id: string, generation: number, model: LaneModel, reason: string): boolean;
368
440
  changeLaneModel(id: string, generation: number, expected: LaneModel | null, model: LaneModel, reason: string,
369
- preset: ModelPreset | null, snapshot: LanePresetSnapshot | null, metadata?: Readonly<Record<string, string>>): boolean;
441
+ preset: ModelPreset | null, snapshot: LanePresetSnapshot | null, metadata?: Readonly<Record<string, string>>, operatorSourceId?: string): boolean;
442
+ recordLaneFallback(id: string, configured: LaneModel, previous: string | null, receipt: LaneFallbackReceipt,
443
+ notice: Pick<OutputRecord, "id" | "sourceId" | "route" | "text">): boolean;
370
444
  putApproval(approval: Approval, ownerInputId?: string): void;
371
445
  approval(id: string): Approval | null;
372
446
  approvals(target?: string): Approval[];
@@ -430,6 +504,17 @@ export interface ThreadUpdate {
430
504
  readonly archived?: boolean;
431
505
  }
432
506
 
507
+ export interface InboundAttachmentBatch {
508
+ readonly inputId: string;
509
+ readonly route: Route;
510
+ readonly attachments: readonly Attachment[];
511
+ }
512
+
513
+ export interface InboundAttachmentReceipt {
514
+ readonly receipt: string;
515
+ readonly files: readonly { readonly path: string; readonly size: number; readonly mimeType: string; readonly sha256: string }[];
516
+ }
517
+
433
518
  export interface Messenger {
434
519
  start(handlers: {
435
520
  /** Authenticate first; do not consume inbound events until native approvals are reconciled. */
@@ -462,7 +547,7 @@ export interface Messenger {
462
547
  messengerPresence?(request: MessengerPresenceRequest): Promise<DiscordPresenceStatus>;
463
548
  /** null explicitly means no history API; intake recovery belongs to the adapter. */
464
549
  fetchAfter(route: Route, messageId: string): Promise<Inbound[] | null>;
465
- /** Validate platform/auth destination before fetching. Never follow redirects with credentials. */
466
- openAttachment(route: Route, attachment: Attachment, signal: AbortSignal): Promise<Response>;
550
+ /** Validate the source before fetching; receipt only a complete, private batch. */
551
+ openAttachment(batch: InboundAttachmentBatch, signal: AbortSignal): Promise<InboundAttachmentReceipt>;
467
552
  stop(): Promise<void>;
468
553
  }