omp-superagent 0.1.6 → 0.1.8

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 (90) hide show
  1. package/DESIGN.md +36 -20
  2. package/README.ko.md +140 -33
  3. package/README.md +165 -41
  4. package/THIRD_PARTY_NOTICES.md +9 -7
  5. package/config.example.json +3 -1
  6. package/docs/OPERATIONS.md +395 -157
  7. package/docs/design/execution.md +156 -22
  8. package/docs/design/messaging.md +258 -52
  9. package/docs/discord-voice.md +8 -4
  10. package/docs/releases/0.1.7.md +25 -0
  11. package/docs/releases/0.1.8.md +21 -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/omp-host-owner-darwin-arm64 +0 -0
  17. package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
  18. package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
  19. package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
  20. package/package.json +9 -9
  21. package/scripts/ci.ts +4 -4
  22. package/scripts/test-omp.sh +2 -1
  23. package/skills/head/SKILL.md +26 -5
  24. package/skills/head/references/routing.md +68 -33
  25. package/skills/head/references/supervision.md +20 -4
  26. package/skills/lane/references/workflow.md +16 -7
  27. package/src/board.ts +5 -3
  28. package/src/cli.ts +161 -19
  29. package/src/config.ts +21 -1
  30. package/src/contracts.ts +63 -8
  31. package/src/cron-jobs.ts +443 -19
  32. package/src/cron-pr-intake.ts +257 -0
  33. package/src/discord-markdown.ts +350 -123
  34. package/src/extension.ts +78 -13
  35. package/src/gateway-client.ts +8 -2
  36. package/src/head-quota.ts +80 -0
  37. package/src/head-recovery.ts +40 -1
  38. package/src/host-extension.ts +122 -4
  39. package/src/host-inventory-manifest.ts +2 -2
  40. package/src/host-protocol.ts +11 -0
  41. package/src/host-sdk-helper.ts +121 -12
  42. package/src/host.ts +175 -57
  43. package/src/installed-omp.ts +116 -4
  44. package/src/lane-rows.ts +44 -4
  45. package/src/lane-watch.ts +339 -0
  46. package/src/managed-memory-helper.ts +13 -10
  47. package/src/managed-memory.ts +62 -27
  48. package/src/managed-ulw-probe.ts +75 -20
  49. package/src/managed-ulw.ts +174 -21
  50. package/src/messenger-command-catalog.json +2 -2
  51. package/src/native-launch-profile.ts +4 -2
  52. package/src/native-presets.ts +32 -5
  53. package/src/native-sessions.ts +3 -1
  54. package/src/native-settings.ts +47 -9
  55. package/src/observation-request.ts +23 -0
  56. package/src/omp-usage.ts +254 -36
  57. package/src/pr-github-schema.ts +5 -1
  58. package/src/pr-github.ts +68 -19
  59. package/src/pr-intake-automation.ts +316 -0
  60. package/src/pr-intake-comment.ts +226 -0
  61. package/src/pr-intake-fix.ts +233 -0
  62. package/src/pr-intake-github.ts +480 -0
  63. package/src/pr-intake-material.ts +230 -0
  64. package/src/pr-intake-mode.ts +59 -0
  65. package/src/pr-intake-review.ts +397 -0
  66. package/src/pr-intake-tree.ts +69 -0
  67. package/src/pr-intake-work.ts +29 -0
  68. package/src/pr-watch.ts +91 -32
  69. package/src/runtime.ts +2702 -391
  70. package/src/setup-judge.ts +1 -1
  71. package/src/setup.ts +12 -16
  72. package/src/store.ts +429 -86
  73. package/src/topic-history.ts +243 -47
  74. package/src/worker-checkout.ts +106 -0
  75. package/src/worker-destination.ts +10 -0
  76. package/src/worker-doctor.ts +66 -0
  77. package/src/worker-enrollment.ts +165 -0
  78. package/src/worker-host.ts +180 -0
  79. package/src/worker-ledger.ts +188 -0
  80. package/src/worker-placement.ts +78 -0
  81. package/src/worker-profile.ts +274 -0
  82. package/src/worker-registration.ts +288 -0
  83. package/src/worker-repository.ts +233 -0
  84. package/src/worker-request.ts +74 -0
  85. package/src/worker-service.ts +230 -0
  86. package/src/worker-stdio.ts +61 -0
  87. package/src/worker-trust.ts +36 -0
  88. package/src/worker-wire.ts +204 -0
  89. package/src/workflow.ts +81 -32
  90. package/src/setup-memory.ts +0 -21
package/src/config.ts CHANGED
@@ -9,6 +9,8 @@ export interface DiscordConfig {
9
9
  ownerId: string;
10
10
  allowedGuildIds: string[];
11
11
  allowedChannelIds: string[];
12
+ readonly requireAddressing?: boolean;
13
+ readonly editProgressInPlace?: boolean;
12
14
  voice?: DiscordVoiceConfig;
13
15
  }
14
16
 
@@ -169,6 +171,16 @@ export async function loadConfig(path: string): Promise<Config> {
169
171
  return (await loadConfigSnapshot(path)).config;
170
172
  }
171
173
 
174
+ function stateDirectory(raw: Record<string, unknown>, base: string): string {
175
+ return resolve(base, text(raw.stateDir, "stateDir"));
176
+ }
177
+
178
+ /** Inspect saved inventory even when the head checkout or OMP is unavailable. */
179
+ export async function loadStateDirectory(path: string): Promise<string> {
180
+ const absolute = resolve(path);
181
+ return stateDirectory(record(await Bun.file(absolute).json(), "config"), dirname(absolute));
182
+ }
183
+
172
184
  /** Bind lifecycle authority to the same bytes that produced the normalized configuration. */
173
185
  export async function loadConfigSnapshot(path: string) {
174
186
  const absolute = resolve(path);
@@ -202,6 +214,12 @@ export function parseConfig(value: unknown, path: string): Config {
202
214
  const maxHosts = integer(raw.maxHosts, "maxHosts", 2);
203
215
  const maxSubagents = integer(raw.maxSubagents, "maxSubagents", maxHosts);
204
216
  const discordChannels = discord ? ids(discord.allowedChannelIds, "discord.allowedChannelIds") : [];
217
+ const requireAddressing = discord?.requireAddressing;
218
+ if (requireAddressing !== undefined && typeof requireAddressing !== "boolean")
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");
205
223
  const voice = discord?.voice === undefined ? undefined : record(discord.voice, "discord.voice");
206
224
  let voiceConfig: DiscordVoiceConfig | undefined;
207
225
  if (voice) {
@@ -238,7 +256,7 @@ export function parseConfig(value: unknown, path: string): Config {
238
256
  }
239
257
  const config: Config = {
240
258
  path: absolute,
241
- stateDir: pathValue(raw.stateDir, "stateDir"),
259
+ stateDir: stateDirectory(raw, base),
242
260
  headCwd,
243
261
  command,
244
262
  maxHosts,
@@ -250,6 +268,8 @@ export function parseConfig(value: unknown, path: string): Config {
250
268
  ownerId: id(discord.ownerId, "discord.ownerId", /^\d+$/),
251
269
  allowedGuildIds: ids(discord.allowedGuildIds, "discord.allowedGuildIds"),
252
270
  allowedChannelIds: discordChannels,
271
+ requireAddressing: requireAddressing ?? false,
272
+ editProgressInPlace: editProgressInPlace ?? false,
253
273
  ...(voiceConfig ? { voice: voiceConfig } : {}),
254
274
  } } : {}),
255
275
  ...(telegram ? { telegram: {
package/src/contracts.ts CHANGED
@@ -1,8 +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";
7
+ import type { RemotePlacement } from "./worker-wire";
8
+ import type { OmpResetAccount } from "./omp-usage";
6
9
 
7
10
  /** Coordination records only. OMP owns transcripts and execution state. */
8
11
  export type Platform = "discord" | "telegram" | "slack";
@@ -37,6 +40,9 @@ export function physicalRouteKey(route: Route): string {
37
40
  return routeKey(physicalRoute(route));
38
41
  }
39
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
+
40
46
  export interface Attachment {
41
47
  id: string;
42
48
  name: string;
@@ -82,6 +88,21 @@ export type DiscordPurposeRequest = {
82
88
  );
83
89
  export interface DiscordPurposeNote { readonly route: Route; readonly purpose: string }
84
90
 
91
+ export type PresenceAction = "start" | "status" | "stop";
92
+ export interface MessengerPresenceRequest {
93
+ readonly action: PresenceAction;
94
+ readonly sourceId: string;
95
+ readonly route: Route;
96
+ }
97
+ export interface DiscordPresenceStatus {
98
+ readonly platform: "discord";
99
+ readonly desired: "default" | "online" | "invisible";
100
+ readonly connection: "connected" | "disconnected";
101
+ /** Last presence written on this authenticated socket, not a Discord UI acknowledgement. */
102
+ readonly lastSent: "online" | "invisible" | null;
103
+ readonly replayed: boolean;
104
+ }
105
+
85
106
  export interface Inbound {
86
107
  id: string;
87
108
  route: Route;
@@ -97,8 +118,14 @@ export interface Inbound {
97
118
  readonly cardId: string;
98
119
  readonly group: number;
99
120
  readonly option: number;
121
+ /** Emitted only by the reset picker's separate Confirm action. */
122
+ readonly confirmed?: true;
100
123
  };
101
124
  text: string;
125
+ /** Physical Discord content when `text` is an addressed command or a confirmed voice draft. */
126
+ readonly discordOriginalText?: string;
127
+ /** Adapter-verified routing-only view; an empty string excludes the entire message. */
128
+ readonly routingText?: string;
102
129
  receivedAt: number;
103
130
  attachments: Attachment[];
104
131
  reply?: ReplyContext;
@@ -152,6 +179,8 @@ export interface Lane {
152
179
  route: Route;
153
180
  cwd: string;
154
181
  repoRoot: string | null;
182
+ /** Immutable remote ownership; absent for a local lane, including legacy rows. */
183
+ readonly remote?: RemotePlacement;
155
184
  brief: string;
156
185
  acceptance: string[];
157
186
  /** Null only for pre-selection records awaiting native-state adoption. */
@@ -175,7 +204,7 @@ export interface Lane {
175
204
 
176
205
  export type InputState = "pending" | "submitted" | "done" | "uncertain" | "cancelled";
177
206
  export type ActiveInputState = Extract<InputState, "pending" | "submitted" | "uncertain">;
178
- export const WORKFLOW_NAMES = ["ulw", "mass-ulw", "ulw-plan", "ulw-loop", "ulw-execute", "ulw-research", "jevify"] as const;
207
+ export const WORKFLOW_NAMES = ["super", "super-plan", "super-loop", "super-run", "super-graph", "super-research", "jevify"] as const;
179
208
  export type WorkflowName = typeof WORKFLOW_NAMES[number];
180
209
  export interface WorkflowChoice {
181
210
  name: WorkflowName;
@@ -204,6 +233,7 @@ export type HeadPicker = {
204
233
  } & (
205
234
  | { readonly kind: "model"; readonly currentProvider?: string }
206
235
  | { readonly kind: "effort"; readonly forModel: LaneModel }
236
+ | { readonly kind: "usage-reset"; readonly accounts: readonly Pick<OmpResetAccount, "target" | "label" | "identity" | "offer">[] }
207
237
  );
208
238
 
209
239
  export interface KickoffHold {
@@ -216,6 +246,10 @@ export interface OutputRecord {
216
246
  route: Route;
217
247
  /** Durable original owner message, only in the same physical conversation. */
218
248
  replyTo?: MessageReference;
249
+ /** Discord status message replaced in place; fixed when the output is claimed. */
250
+ readonly editOf?: MessageReference;
251
+ /** Initial Discord status message; overflow falls back to one attachment instead of multi-message split. */
252
+ readonly status?: boolean;
219
253
  readonly picker?: HeadPicker;
220
254
  readonly resultAttachment?: StagedResultAttachment;
221
255
  text: string;
@@ -281,9 +315,13 @@ export interface HeadRecoveryEffect {
281
315
  }
282
316
 
283
317
  export interface StorePort {
318
+ /** Typed, noninteractive work on the confirmed bot offer; never valid for ordinary owner intake. */
319
+ receivePrWork(input: Inbound, target: string | null, round: ReviewRound): boolean;
284
320
  receive(input: Inbound, target: string | null, metadata?: Readonly<Record<string, string>>, workflow?: WorkflowActivation | null): boolean;
285
321
  input(id: string): InputRecord | null;
286
322
  ownerSource(id: string): InputRecord | null;
323
+ /** Manager handoff's verified reply route, pinned if a bound reply joined its run. */
324
+ laneReplyRoute(input: InputRecord, source: InputRecord): Route;
287
325
  /** Exact original owner and authorized delivery route for a topic-owned lane input. */
288
326
  topicDelivery(id: string): { readonly source: InputRecord; readonly route: Route; readonly outputSourceId: string } | null;
289
327
  /** Whether an unowned dialog could belong to a durable topic admission on this native generation. */
@@ -294,6 +332,11 @@ export interface StorePort {
294
332
  tryAutoTopicChoice(input: InputRecord, deadline: number, pin: string): boolean;
295
333
  inputs(target?: string, state?: ActiveInputState): InputRecord[];
296
334
  hasInput(target: string, state: ActiveInputState): boolean;
335
+ /** Latest admitted lane run, excluding inputs joined to another run. */
336
+ latestLaneRun(target: string): InputRecord | null;
337
+ /** A successful lane run still has an unresolved final report or delivery. */
338
+ hasPendingLaneResult(target: string): boolean;
339
+ hasPendingLanePlacement(target: string): boolean;
297
340
  /** An uncertain HEAD input with a nonempty original native-owner record. */
298
341
  hasHeadRecoveryInput(): boolean;
299
342
  /** No automatic head replacement while an original HEAD delivery is unresolved. */
@@ -301,27 +344,38 @@ export interface StorePort {
301
344
  kickoffHold(target: string): KickoffHold | null;
302
345
  /** The first authorized revision on the physical route, even after settlement. */
303
346
  firstAdmittedMessage(route: Route, messageId: string): InputRecord | null;
347
+ /** Exact logical child of a parent reply; unverified evidence must not select a stop target. */
348
+ repliedParentTopic(route: Route, messageId: string): Lane | "unverified" | null;
304
349
  /** Workspace evidenced by a placed owner message or a confirmed bot reply on this physical route. */
305
350
  repliedTopicWorkspace(route: Route, messageId: string): string | null;
351
+ /** Exact HEAD lane_start placement, including its confirmed kickoff. */
352
+ headLanePlacement(sourceId: string): Lane | "unverified" | null;
353
+ /** Resolve one physical reply without treating its quoted content as identity. */
354
+ repliedStop(route: Route, messageId: string):
355
+ | { readonly kind: "lane"; readonly lane: Lane; readonly unplaced: readonly InputRecord[] }
356
+ | { readonly kind: "workspace"; readonly sourceId: string }
357
+ | { readonly kind: "sources"; readonly sources: readonly InputRecord[] }
358
+ | { readonly kind: "unverified" | "unknown" };
359
+ isDiscordWorkspaceQuestion(route: Route, messageId: string): boolean;
306
360
  sentOutputForMessage(route: Route, messageId: string): OutputRecord | null;
307
361
  /** Actual authorized message IDs in durable admission order; not invocation or edit IDs. */
308
362
  admittedMessageIds(route: Route): Iterable<string>;
309
363
  bindInput(id: string, target: string): void;
310
364
  submit(id: string, requestId: string, generation: number): boolean;
311
365
  /** Nonterminal native assistant observation; never settles or dispatches its owner. */
312
- progress(id: string, generation: number, sessionId: string, eventId: string, text: string): boolean;
366
+ progress(id: string, generation: number, sessionId: string, eventId: string, text: string, editInPlace?: boolean): boolean;
313
367
  recordLaneReport(id: string, generation: number, sessionId: string, eventId: string, report: LaneReport, observedAt?: number): boolean;
314
368
  resolveLaneWaiting(id: string, generation: number, sessionId: string, kind: "tool" | "approval", nativeId: string): boolean;
315
- settle(id: string, state: "done" | "uncertain" | "cancelled", output?: Pick<OutputRecord, "id" | "text" | "picker">, headModel?: HeadModelChange): boolean;
369
+ settle(id: string, state: "done" | "uncertain" | "cancelled", output?: Pick<OutputRecord, "id" | "text" | "picker">, headModel?: HeadModelChange, editInPlace?: boolean): boolean;
316
370
  settleCronControl(inputId: string, update: CronUpdate): boolean;
317
371
  resolveLaneInput(controlId: string, laneId: string, inputId: string, output: { readonly id: string; readonly text: string }): boolean;
318
372
  headRecoveryEffects(inputId: string): HeadRecoveryEffect[];
319
373
  prepareHeadRecovery(attempt: HeadRecoveryAttempt): boolean;
320
374
  commitHeadRecovery(expected: HeadRecoveryAttempt, decided: HeadRecoveryAttempt): boolean;
321
- queueOutput(output: Omit<OutputRecord, "state" | "remoteId" | "error">): boolean;
375
+ queueOutput(output: Omit<OutputRecord, "state" | "remoteId" | "error" | "editOf">): boolean;
322
376
  output(id: string): OutputRecord | null;
323
- outputs(): OutputRecord[];
324
- claimOutput(id: string): boolean;
377
+ outputs(physicalRoute?: string): OutputRecord[];
378
+ claimOutput(id: string, editInPlace?: boolean): boolean;
325
379
  finishOutput(id: string, state: "sent" | "uncertain" | "failed" | "pending", remoteId?: string, error?: string): void;
326
380
  createLane(lane: Lane & { model: LaneModel; modelReason: string }, sourceId: string): Lane;
327
381
  lane(id: string): Lane | null;
@@ -412,8 +466,8 @@ export interface Messenger {
412
466
  }): Promise<void>;
413
467
  send(output: OutputRecord): Promise<string>;
414
468
  sendGroup?(reply: GroupReply): Promise<string>;
415
- /** Verify against the currently authenticated adapter without sending or fetching messages. */
416
- assertRoute?(route: Route): void | Promise<void>;
469
+ /** Verify the authenticated adapter. History is read-only and may run before intake is acknowledged. */
470
+ assertRoute?(route: Route, purpose?: "history"): void | Promise<void>;
417
471
  /** Cosmetic own reactions on the original message; never an admission or completion receipt. */
418
472
  setActivity?(message: MessageReference, activity: MessageActivity): Promise<void>;
419
473
  showApproval(approval: Approval): Promise<string>;
@@ -426,6 +480,7 @@ export interface Messenger {
426
480
  updateThread?(route: Route, update: ThreadUpdate): Promise<ThreadInfo>;
427
481
  inspectDiscordContext?(route: Route): Promise<DiscordContext>;
428
482
  discordPurpose?(request: DiscordPurposeRequest): Promise<readonly DiscordPurposeNote[]>;
483
+ messengerPresence?(request: MessengerPresenceRequest): Promise<DiscordPresenceStatus>;
429
484
  /** null explicitly means no history API; intake recovery belongs to the adapter. */
430
485
  fetchAfter(route: Route, messageId: string): Promise<Inbound[] | null>;
431
486
  /** Validate platform/auth destination before fetching. Never follow redirects with credentials. */