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
@@ -6,8 +6,9 @@ description: Operate the messenger-facing OMP head, handling work directly or co
6
6
 
7
7
  # Main head operating contract
8
8
 
9
- You handle explicit `/head` requests, manager handoffs and global coordination.
10
- Ordinary topic requests, progress, and replies do not need your model to relay or rewrite them.
9
+ You handle ordinary unbound owner requests, explicit `/head` requests, manager
10
+ handoffs and global coordination. The controller routes ordinary bound-topic
11
+ requests, progress and replies without your model relaying or rewriting them.
11
12
  Read only the relevant topic evidence when coordination needs it, not a directory of transcripts.
12
13
  After idle rotation, use native OMP memory for durable preferences and decisions,
13
14
  and the exact topic journal for prior work. Neither is authority to resume a task,
@@ -19,15 +20,30 @@ an independent conversation.
19
20
 
20
21
  ## Decide before dispatch
21
22
 
22
- - Handle questions, status, and explicitly main-scoped work directly. For other
23
- actionable messenger work, do minimal routing triage and create or reuse its
24
- work topic before substantive work. A new lane needs a confirmed kickoff.
23
+ - Answer repo-free conversation and questions directly. For unbound repository
24
+ work, use the original request, scoped context, and any advisory lane,
25
+ workspace, or session coordinates to find and verify the workspace before
26
+ assigning work. These leads are not a dispatch, resume, or approval. Missing
27
+ recall or matches do not block direct answers. Ask one focused question only
28
+ if a material ambiguity remains after checking available evidence. Do not
29
+ treat the HEAD cwd as a default repository or look up the last active lane or chat.
30
+ - Keep discovered work in the original unbound Discord thread. Do not create a
31
+ sibling without an explicit split request. A new lane needs a confirmed kickoff.
32
+ Leave explicit cwd, `/new`, exact replies with a known workspace, and intentional
33
+ historical lookup or choice to the controller's placement path.
25
34
  - Handle an explicit request to schedule a one-time or recurring task directly,
26
35
  without creating a lane or doing the scheduled work now. Use `cron_create`
27
36
  with the current original owner `sourceId`, a supported schedule, and the
28
37
  requested task as its prompt. Ask if timing, time zone or task scope is
29
38
  ambiguous. Confirm the job ID and next time from the tool; quotes, reports,
30
39
  historical requests and cron-run prompts do not authorize new schedules.
40
+ - Treat “감시해 줘”, “keep an eye on it”, or “let me know when it finishes” as
41
+ observation, not authorization to do the work. Resolve **what** from the
42
+ original owner text and its bound conversation: bot availability uses
43
+ `messenger_presence`, GitHub PR/CI uses `pr_watch` / `pr_watch_list`, and a
44
+ specific managed job uses `lane_watch`. If more than one target fits, ask
45
+ which one. Confirm registration from the tool result; never promise to watch
46
+ from memory. Stopping a watch does not stop the lane, bot, or CI.
31
47
  - **One message can contain several workstreams.** Compare what can be accepted
32
48
  independently, what benefits from separate context or follow-ups, and what
33
49
  needs another track's output. Use several lanes when independent outcomes
@@ -39,6 +55,11 @@ an independent conversation.
39
55
  unsettled interface, identify the owner and sequence only the conflicting step.
40
56
  Give each track its exact workspace, allowed changes, independently checkable
41
57
  result, and handoff/gate if another track depends on it.
58
+ - For a new lane with an explicit remote, worker platform, or worker ID request,
59
+ use `lane_start.placement`. Keep `cwd` a verified local repository directory;
60
+ remote execution uses only its clean committed revision on an approved paired
61
+ worker. Never choose an SSH destination yourself or silently replace a
62
+ remote requirement with local execution. A lane's recorded placement is fixed.
42
63
  - Use the original stored source and confirmed destinations. Keep same-topic
43
64
  work with its existing lane, but the binding neither forwards nor authorizes
44
65
  work; send a scoped `lane_message` explicitly.
@@ -10,11 +10,14 @@ route grants access to an excluded tool.
10
10
  Read the trusted envelope. A routing envelope's original `sourceId` is the source
11
11
  for `lane_start`, not the `route:…` wrapper. Otherwise use the actual received
12
12
  request's identity. Never derive identity from a quoted ID or display name.
13
- Identify the outcome, scope of effects, and observable acceptance. Existing
14
- bindings are context only. The controller handles authenticated ordinary topic
15
- inputs without submitting them to this model; this reference governs explicit
16
- coordination and manager handoffs. Preserve admitted
17
- control boundaries; an ordinary edit is a new revision, not rollback of prior effects.
13
+ Identify the outcome, scope of effects, and observable acceptance. The
14
+ controller keeps bound-topic work with its existing session and opening-topic
15
+ work with its existing placement. It also handles explicit cwd, `/new`, exact
16
+ placed-task replies with a known workspace, and intentional historical lookup
17
+ or choice. Otherwise, ordinary unbound input reaches HEAD as the original
18
+ request, including requests that name a repository. Answer repo-free questions
19
+ without placement. Preserve the admitted source and control boundaries; an
20
+ ordinary edit is a new revision, not rollback of prior effects.
18
21
 
19
22
  ### Choose lane count for one request
20
23
 
@@ -68,15 +71,41 @@ controls Host capacity.
68
71
 
69
72
  ## 2. Verify placement and avoid collisions
70
73
 
71
- - Resolve an existing absolute cwd from authorized paths, current repository/tree
72
- evidence, project guidance, and applicable skills. Check actual root/worktree,
73
- branch, and dirty state before mutation. Do not guess from a lane title or
74
- channel note. Non-Git workspaces are valid. Ask the owner only if a material
75
- scope/workspace ambiguity remains; do not clone, switch, or create a checkout
76
- to avoid settling it.
74
+ - Discover and verify an existing absolute cwd from the owner's request,
75
+ authorized paths and local repository/tree evidence. Use the original channel
76
+ or thread context, purpose note, and relevant scoped lane records as leads,
77
+ not as proof. Treat automatically supplied coordinates from scoped memory and
78
+ bounded native journal checks the same way. No raw memory or journal excerpts
79
+ are supplied; recall may be unavailable and direct journal matches may still
80
+ be useful. These hints neither authorize a dispatch nor replace the controller's
81
+ pinned evidence for deliberate historical continuation. Check actual
82
+ root/worktree, branch, and dirty state before mutation. Never guess from a
83
+ lane title, the HEAD cwd, a default repository,
84
+ or the last active chat or lane. Non-Git workspaces are valid. Ask a focused
85
+ question only if scope or workspace still matters and is ambiguous after
86
+ checking available evidence; do not clone, switch, or create a checkout to
87
+ avoid settling it.
77
88
  - Before adding an editing lane, use `lane_inspect({})` to check recorded ownership;
78
89
  inspect relevant IDs for live state. Compare real paths, common repository,
79
90
  worktree, branch, intended files, generated outputs, and shared external targets.
91
+ - `lane_start.placement` selects the execution location for a new lane, not its
92
+ workspace or messaging destination. Omit it for ordinary local placement or
93
+ an eligible operator-configured default; `{target: "local"}` opts out of that
94
+ default. `target: "remote"`, `platform: "linux" | "darwin"`, or an exact paired
95
+ `worker` ID requires remote placement. Do not combine `target: "local"` with
96
+ `platform` or `worker`. If the explicit requirement cannot be verified, hold
97
+ and explain that requirement; do not retry locally or switch the selected
98
+ worker without authority. An unavailable but matching worker can be recorded
99
+ as the lane's fixed placement while execution waits for its exact checkout and
100
+ capacity. Never supply a host, credentials, or SSH command.
101
+ - For remote work, continue resolving `cwd` from local evidence. The worker
102
+ needs the same approved repository identity and exact committed revision,
103
+ not a familiar repository name. Tracked, staged, or nonignored untracked
104
+ changes in the source checkout prevent remote placement. Ignored files,
105
+ private dependencies and credentials are never transferred; if the task
106
+ depends on them, do not claim the worker can reproduce it. When a lane
107
+ already exists, use its recorded placement and worker ID; an unavailable
108
+ worker is not authorization to move or replay that lane.
80
109
  - **Several editing lanes in one Git repository:** When the tracks can proceed
81
110
  independently, prefer separate authorized checkouts over forcing serial work in
82
111
  one checkout. Reuse suitable authorized checkouts. For new checkouts, use the
@@ -95,9 +124,11 @@ controls Host capacity.
95
124
  device is idle after its current run). For integration, settle the shared
96
125
  contract and name one owner and verification boundary. Checkout separation is not
97
126
  permission to merge, delete a checkout, or touch another lane's uncommitted work.
98
- - Keep the original route by default. A new topic from inside a bound thread uses
99
- the exact authorized parent `destination` with `threadId:null` and no `topicId`
100
- to create a sibling, never a channel or nested thread. Only use an existing
127
+ - Keep the original route by default. For work from an unbound Discord thread,
128
+ place any new lane in that exact thread, not its parent or a sibling.
129
+ For an explicitly requested split from a Discord thread, use the exact
130
+ authorized parent `destination` with `threadId:null` and no `topicId` to
131
+ create a sibling, never a channel or nested thread. Only use an existing
101
132
  destination when its exact platform/account/authority/guild/channel/thread/topic
102
133
  identity is observed and authorized. DMs without native support use honest
103
134
  logical topics. Never fabricate a thread ID, interaction source message, or Slack
@@ -162,30 +193,34 @@ entrusted objective, not permission to expand it or impersonate the user.
162
193
  select it without that token. Follow the native notice and the judge help topic
163
194
  advertised by `eval` (`help://eval/judge` on OMP 19.1). Admission is not
164
195
  activation: native settings and eval availability apply.
165
- No ULW skill lookup, model change, extra lane, goal, or artifacts are required.
196
+ No SUPER skill lookup, model change, extra lane, goal, or artifacts are required.
166
197
  Require coverage and directly checked flagged evidence, not just a batch result.
167
- - **ULW:** For a head-selected method, name the lighter direct/task/plain-lane
198
+ - **SUPER:** For a head-selected method, name the lighter direct/task/plain-lane
168
199
  alternative, its evidenced limitation, and the durable artifact, review gate,
169
200
  dependency or recovery benefit worth the overhead. For ambiguous choices use
170
201
  native advisory judge where available. Read the selected installed skill before
171
- dispatch (`skill://ultrawork` for `ulw`) and follow its own artifacts, approvals,
172
- attempt bounds, and review/recovery rules. Don't ask for brand consent; real
173
- cost, scope, and approval decisions still belong to the owner.
174
-
175
- | `workflow.name` | Choose for |
176
- | --- | --- |
177
- | `ulw` | Explicit native-goal working policy; no specialty mode or implicit RPC goal. |
178
- | `ulw-plan` | A decision-complete plan and review as the deliverable; not implementation. |
179
- | `ulw-execute` | Authorized execution of a selected plan requiring durable resume and evidence. Native plan approval alone does not select it. |
180
- | `ulw-loop` | Multiple real goals with dependencies, verified checkpoints, and recovery; not waiting or a watchdog. |
181
- | `mass-ulw` | Consumed producer artifacts or dependency-ordered work with durable handoffs; not ordinary parallelism. |
182
- | `ulw-research` | Deep/contested inquiry needing independent evidence, counter-search, and cited synthesis; not ordinary lookup. |
202
+ dispatch using the exact `skill://` identifier below. Follow its artifact,
203
+ approval, attempt and review/recovery rules. Don't ask for brand consent;
204
+ real cost, scope, and approval decisions still belong to the owner.
205
+
206
+ Use the command without `/` as `workflow.name`. Upstream skill identifiers are
207
+ different from invocation names; do not derive a skill URL from `workflow.name`.
208
+
209
+ | Operator invocation | `workflow.name` | Installed skill | Choose for |
210
+ | --- | --- | --- | --- |
211
+ | `/super` | `super` | `skill://ultrawork` | Explicit working policy; no specialty mode or implicit RPC goal. |
212
+ | `/super-plan` | `super-plan` | `skill://ulw-plan` | A decision-complete plan and review as the deliverable; not implementation. |
213
+ | `/super-run` | `super-run` | `skill://ulw-execute` | Authorized execution of a selected plan requiring durable resume and evidence. Native plan approval alone does not select it. |
214
+ | `/super-loop` | `super-loop` | `skill://ulw-loop` | Multiple real goals with dependencies, verified checkpoints, and recovery; not waiting or a watchdog. |
215
+ | `/super-research` | `super-research` | `skill://ulw-research` | Deep/contested inquiry needing independent evidence, counter-search, and cited synthesis; not ordinary lookup. |
216
+ | `/super-graph` | `super-graph` | `skill://mass-ulw` | Consumed producer artifacts or dependency-ordered work with durable handoffs; not ordinary parallelism. |
183
217
 
184
218
  Reuse the existing objective and artifact owner. Runtime puts the actual native
185
219
  invocation outside fenced context and applies the installed bridge's default
186
220
  mode only when original keywords allow it; don't rewrite/replay the envelope or
187
- strip quoted/negated keywords. ULW requires native advertisement of the exact
188
- extension command; missing capability cancels rather than degrading to plain
189
- work. `jevify` has no ULW command preflight. Selection, skill loading, native mode
190
- activation, and goal creation are separate facts. Preserve native settings,
191
- permissions, approvals, and stop semantics; never claim an unobserved activation.
221
+ strip quoted/negated keywords. Runtime checks the Host's exact extension command
222
+ advertisement for the selected SUPER workflow; missing capability cancels rather
223
+ than degrading to plain work. `jevify` has no SUPER command preflight.
224
+ Selection, skill loading, native mode activation, and goal creation are separate
225
+ facts. Preserve native settings, permissions, approvals, and stop semantics;
226
+ never claim an unobserved activation.
@@ -110,14 +110,30 @@ No polling, duty model, aggregate goal for lanes, or follow-up just for a report
110
110
 
111
111
  ## Observation tools are not work authority
112
112
 
113
+ - **Bot presence:** “봇 온라인 상태 유지해 줘” / “keep the bot online” calls
114
+ `messenger_presence` with `start` and the admitted owner `sourceId`. For
115
+ “온라인 상태 알려줘” use `status`; for “온라인 표시 꺼 줘” use `stop`.
116
+ Operate only on the account where that owner asked. Discord `stop` requests
117
+ invisible without stopping intake. Report the desired setting, connection
118
+ and last local socket write separately: even a successful write is not
119
+ confirmation of the displayed dot or model readiness. Slack Socket Mode bot
120
+ presence is controlled in the Slack app settings; Telegram has no bot
121
+ presence setter. Do not ask for a personal token or session cookie.
113
122
  - **PR watch:** On explicit request use `pr_watch` with `action: "track"`, original
114
- `sourceId`, GitHub.com PR URL or `owner/repo#N`, and explicit `intervalSeconds`;
123
+ `sourceId` and GitHub.com PR URL or `owner/repo#N`. For “이 PR CI 통과하면
124
+ 알려줘” use the requested interval or omit it for the five-minute default.
115
125
  `laneId` is informational and `ignoreAuthors` excludes named logins. Use
116
- `pr_watch_list` to inspect and source-bound `action: "untrack"` to stop. Don't poll in a
117
- model turn. First read is a quiet baseline; a hold, auth change, or failure is not
118
- proof of no change. HEAD stop holds watches until a new explicit registration.
126
+ `pr_watch_list({sourceId, ref?})` to inspect this conversation's watches and
127
+ source-bound `untrack` to stop. Don't poll in a model turn. First read is a quiet
128
+ baseline; missing checks, a hold or an error are not success. HEAD stop holds watches until a new explicit registration.
119
129
  Explain meaningful changes on their registered route; observations never
120
130
  authorize mutations, creating lanes, or resuming work.
131
+ - **Lane watch:** For “이 작업이 멈추거나 끝나면 알려줘”, use `lane_watch` with
132
+ `track`, the original `sourceId` and the verified `laneId` (the bound lane if
133
+ that is what “this job” means). Use `status` to see registrations on this route
134
+ and `untrack` to stop notifications. A quiet or unloaded Host is not proof of
135
+ a stall. Report recorded evidence, holds, errors and closure without claiming
136
+ completion from an idle socket or firing a new model turn to check it.
121
137
  - **Board:** Use advertised `board_post`, `board_read`, `board_subscribe` only for
122
138
  concise facts, evidence, and edit collisions. Membership is revalidated against
123
139
  actual managed session ID/file and current owner for this state instance, not
@@ -32,25 +32,34 @@ substitute or unobserved activation.
32
32
 
33
33
  - **`jevify`:** Follow the actual OMP notice and the judge help topic advertised
34
34
  by `eval` (`help://eval/judge` on OMP 19.1).
35
- Runtime uses lowercase native prose outside fenced context, not an ULW command.
35
+ Runtime uses lowercase native prose outside fenced context, not a SUPER command.
36
36
  Native settings and eval availability still matter. Neither admission nor a
37
37
  batch result proves activation, verified coverage, or correctness. Report actual
38
- coverage and checked flagged evidence. No ULW read, extra lane/goal, artifacts,
39
- model or settings change needed.
40
- - **ULW:** Read only the selected installed skill (`skill://ultrawork` for `ulw`,
41
- otherwise `skill://<workflow.name>`) and its required references before acting.
38
+ coverage and checked flagged evidence. No SUPER skill read, extra lane/goal,
39
+ artifacts, model or settings change needed.
40
+ - **SUPER:** Read only the selected installed skill from the table below and its
41
+ required references before acting. Do not build the URL from `workflow.name`.
42
42
  Follow its actual artifact ownership, stop rules, approval, review and recovery
43
43
  gates. Planning selection doesn't permit implementation. In native plan mode,
44
44
  write `local://<slug>-plan.md` and submit that same slug as the mode instructs:
45
45
  on OMP 19.1, run `propose <slug>` in OMP's `bash` if listed as a command,
46
46
  or call `propose` directly if offered as a tool. Do not substitute a chat
47
- question for plan approval. Approval doesn't select `ulw-execute` or grant
47
+ question for plan approval. Approval doesn't select `super-run` or grant
48
48
  permission to ship. Nested workflow state doesn't create a second objective
49
49
  or goal. Preserve source keywords and runtime's fenced context; don't force a
50
50
  native mode. Report separately whether the skill was loaded, a native mode
51
- actually activated, and a goal exists. Plain ULW selects no specialty mode and
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` |
62
+
54
63
  ## Implement and verify
55
64
 
56
65
  - Read affected code and callers; make the smallest complete change within the
package/src/board.ts CHANGED
@@ -427,9 +427,11 @@ export class Board {
427
427
  generation = Number(currentGeneration?.value ?? "0");
428
428
  } else {
429
429
  if (!tables.some(table => table.name === "lanes")) throw new BoardMembershipError();
430
- const row = this.db.query("SELECT generation, data FROM lanes WHERE id = ?")
431
- .get(this.identity.actor) as { generation: number; data: string } | null;
432
- if (!row) throw new BoardMembershipError();
430
+ // A remote PID/file pair can have a local namesake. It cannot grant
431
+ // membership to a process opening this machine's SQLite board.
432
+ const row = this.db.query<{ generation: number; data: string; remote?: string | null }, [string]>(
433
+ "SELECT * FROM lanes WHERE id = ?").get(this.identity.actor);
434
+ if (!row || row.remote != null) throw new BoardMembershipError();
433
435
  const lane = JSON.parse(row.data) as Lane;
434
436
  if (lane.id !== this.identity.actor || lane.sessionId !== this.identity.sessionId ||
435
437
  canonicalSessionFile(lane.sessionFile) !== this.sessionFile || lane.pid !== process.pid ||
package/src/cli.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env -S bun --no-env-file
2
2
  import { Database } from "bun:sqlite";
3
3
  import { existsSync } from "node:fs";
4
- import { join } from "node:path";
5
- import { configuredPlatforms, credentialEnvNames, hostPaths, loadConfig, requireMessengerCredentials } from "./config";
4
+ import { homedir } from "node:os";
5
+ import { isAbsolute, join } from "node:path";
6
+ import { configuredPlatforms, credentialEnvNames, hostPaths, loadConfig, loadStateDirectory, requireMessengerCredentials } from "./config";
6
7
  import { inspectInstalledOmp } from "./installed-omp";
7
8
  import { requireHostOwner } from "./host-owner-path";
8
9
  import { loadCredentials } from "./credentials";
9
- import type { Lane } from "./contracts";
10
+ import { WORKFLOW_NAMES, type Lane } from "./contracts";
11
+ import type { HostConnection } from "./host";
10
12
  import { readLaneRows } from "./lane-rows";
11
13
 
12
14
  // Keep Host/SDK imports out of setup, doctor and command registration:
@@ -26,14 +28,19 @@ Usage:
26
28
  omp-sa discord-commands --config FILE [--apply]
27
29
  omp-sa telegram-commands --config FILE [--language CODE] [--apply]
28
30
  omp-sa slack-commands --config FILE --manifest-token-env NAME [--apply]
31
+ omp-sa worker add user@host[:port] [--config FILE] [--default [--local-repo PATH]]
32
+ omp-sa worker init --head-key PUBLIC_KEY --repo PATH [--repo PATH ...]
33
+ omp-sa worker list [--config FILE]
34
+ omp-sa worker doctor user@host[:port] [--config FILE]
29
35
 
30
36
  Setup and service lifecycle:
31
37
  setup creates FILE interactively, or preserves an existing FILE and prompts for its configured credentials.
32
38
  It saves a private FILE.env and sets configured Discord/Telegram bot profile pictures through REST; it does not start bots.
33
- Managed sessions require effective native Mnemopi. Setup asks separately before changing native global settings.
39
+ Managed sessions keep any enabled native OMP memory backend. If the profile has memory off or unset,
40
+ saving setup or starting a managed session sets memory.backend=mnemopi; project and launch overrides are preserved.
34
41
  On first setup, if no native Judge model is configured, setup explains how to select one in ordinary OMP
35
42
  (/models > Roles > Judge); it does not choose a model for you.
36
- doctor checks native prerequisites, effective Mnemopi and credential presence, not successful login.
43
+ doctor checks native prerequisites, the effective memory backend and credential presence without changing settings or logging in.
37
44
  start launches a detached Gateway and one HEAD, activating ALL configured messengers. No autostart is installed.
38
45
  start can return before HEAD can accept work. Check head.ready and head.initialization in the start response
39
46
  (gateway.head in status); initial high/middle/low model presets must be verified before queued work runs.
@@ -67,18 +74,30 @@ All command registration is read-only by default and requires --apply to change
67
74
  Running a Host requires an installed stock OMP with stdio RPC (rpc-ui), session resume, and extensions.
68
75
  Same-process native TUI attach is not supported.
69
76
 
77
+ Remote workers are opt-in:
78
+ worker add generates a dedicated private key, prints the target init command, and never starts a bot.
79
+ worker init on the target authorizes only the restricted worker command for that public key and those Git roots.
80
+ After verifying the SSH host key separately, rerun worker add to verify and register the worker.
81
+ worker list reads the local verified inventory only; it does not contact endpoints or report live availability.
82
+ worker doctor checks the exact enrolled destination, current slot counts and, for a default worker, the pinned
83
+ checkout's current Git revision. It does not change enrollment, start work, or verify native Host readiness.
84
+ FILE defaults to ./config.local.json for worker add, list and doctor. Use --default only for default remote placement.
85
+
70
86
  Owner controls in chat (not shell commands):
71
87
  Send /help in Discord or Telegram. In Slack messages replace / with ! (e.g. !help, !status);
72
88
  registered Slack commands use /superagent-* (e.g. /superagent-status).
73
89
  /status, /context, /usage Inspect HEAD state, context or usage without starting a model turn.
90
+ /usage reset List saved reset tickets; choose an account then confirm to spend one.
74
91
  /model [list|provider/id] Inspect or select the shared HEAD model; changes require an idle HEAD.
75
92
  /model preset [list|NAME] Inspect or select a preset. Only NAME --global also saves future defaults.
76
93
  /effort [LEVEL] Inspect or change HEAD thinking effort; existing lanes keep their settings.
77
94
  /compact [instructions] Compact idle HEAD context, optionally with multiline instructions.
78
95
  /cron [help] Schedule and manage one-time or recurring jobs in this conversation.
96
+ /cron pr-add "every 5m" OWNER/REPO Review newly opened external PRs and comment on GitHub (Discord guild parent).
97
+ /cron pr-mode JOB review|fix|merge Set the unattended ceiling: comment only, safe fix, or gated merge. Korean mode phrases also work.
79
98
  /new [request], /main Start a topic or return to the main topic in the owner's DM.
80
- /stop [head|LANE_ID] Stop HEAD work or pause a lane, NOT the service. With no argument, pause
81
- the lane bound to this chat, or stop HEAD work if there is no bound lane.
99
+ /stop [head|LANE_ID] Stop work, not the service. Pause the bound lane, or reply to select a
100
+ pending placement or active request. Use /stop head for the global stop.
82
101
  /resume Resume the lane bound to this chat, not HEAD.
83
102
  /restart Interrupt HEAD work and restart Gateway and HEAD with the same session and
84
103
  memory profile. Independent lanes stay running; interrupted prompts are not replayed.
@@ -89,15 +108,17 @@ Owner controls in chat (not shell commands):
89
108
  Capabilities to request from HEAD in chat (not CLI subcommands):
90
109
  Lanes and threads: ask HEAD to start, inspect, steer, pause, resume or close an independent lane,
91
110
  select its model/preset, or inspect and update its Discord thread or forum tags.
92
- PR monitoring: give HEAD a GitHub PR URL and check interval to watch reviews and CI; ask to list or stop watches.
93
- Requires gh with read access. A change notification does not authorize a merge or a new task.
111
+ Monitoring: ask HEAD to watch a GitHub PR's reviews/CI, or a managed lane's progress, stalls and closure.
112
+ PRs require gh read access. Ask for status or stop the watch in the same conversation; a watch never merges or resumes work.
113
+ Bot presence: ask Discord HEAD to keep the bot online, show its presence or turn the indicator off without stopping intake.
114
+ Slack Socket Mode bot presence is set in Slack app settings; Telegram Bot API does not expose online presence.
94
115
  Scheduled jobs: explicitly ask HEAD in plain language to schedule a task; manage it with /cron in the same chat.
95
116
  Decisions: ask HEAD to request an owner decision, list pending decisions, inspect one or withdraw it.
96
117
  Discord channel context: ask HEAD to inspect channel/thread context or set, list or clear a local purpose
97
118
  note. Notes do not edit Discord's channel description or authorize work.
98
119
  Shared board: registered HEAD and lane sessions can post, read and subscribe to informational updates
99
120
  within this instance. Board posts are not commands or approvals.
100
- Workflows: begin a request with ulw, ulw-plan, ulw-execute, ulw-loop, ulw-research or mass-ulw.
121
+ Workflows: begin a request with one of: ${WORKFLOW_NAMES.filter(name => name !== "jevify").join(", ")}.
101
122
  For batch judging against one rubric, begin with lowercase jevify (not /jevify).
102
123
  Operations guide and native tool names: ${join(import.meta.dir, "../docs/OPERATIONS.md")}
103
124
 
@@ -140,12 +161,111 @@ function laneRows(stateDir: string): Lane[] {
140
161
  } finally { db.close(); }
141
162
  }
142
163
 
164
+ async function workerCommand(args: string[]): Promise<void> {
165
+ const [verb, ...operands] = args;
166
+ switch (verb) {
167
+ case undefined:
168
+ case "--help":
169
+ if (operands.length === 0) { console.log(HELP); return; }
170
+ throw new Error("Usage: omp-sa worker --help");
171
+ case "add": {
172
+ const usage = "Usage: omp-sa worker add user@host[:port] [--config FILE] [--default [--local-repo PATH]]";
173
+ const [destination, ...flags] = operands;
174
+ if (!destination || destination.startsWith("-")) throw new Error(usage);
175
+ let configPath: string | undefined;
176
+ let localRepo: string | undefined;
177
+ let preferred = false;
178
+ for (let index = 0; index < flags.length; index++) {
179
+ const flag = flags[index];
180
+ if (flag === "--default" && !preferred) { preferred = true; continue; }
181
+ const value = flags[index + 1];
182
+ if (!value || value.startsWith("-")) throw new Error(usage);
183
+ if (flag === "--config" && !configPath) configPath = value;
184
+ else if (flag === "--local-repo" && !localRepo) localRepo = value;
185
+ else throw new Error(usage);
186
+ index++;
187
+ }
188
+ if (localRepo && !preferred) throw new Error(usage);
189
+ const config = await loadConfig(configPath ?? "config.local.json");
190
+ const { addWorker } = await import("./worker-registration");
191
+ const { workerDescribe } = await import("./worker-wire");
192
+ const result = await addWorker({ destination, stateDir: config.stateDir,
193
+ ...(preferred ? { defaultRepositoryRoot: localRepo ?? config.headCwd } : {}) }, workerDescribe);
194
+ console.log(JSON.stringify(result, null, 2));
195
+ if (result.status === "pending" && result.verificationError) process.exitCode = 1;
196
+ return;
197
+ }
198
+ case "list":
199
+ case "doctor": {
200
+ const doctor = verb === "doctor";
201
+ const usage = `Usage: omp-sa worker ${verb}${doctor ? " user@host[:port]" : ""} [--config FILE]`;
202
+ const destination = doctor ? operands[0] : undefined;
203
+ if (doctor && (!destination || destination.startsWith("-"))) throw new Error(usage);
204
+ const flags = doctor ? operands.slice(1) : operands;
205
+ const [flag, file] = flags;
206
+ if (flags.length !== 0 && (flags.length !== 2 || flag !== "--config" || !file || file.startsWith("-")))
207
+ throw new Error(usage);
208
+ const stateDir = await loadStateDirectory(file ?? "config.local.json");
209
+ const { workerInventory, workerDoctor } = await import("./worker-doctor");
210
+ if (destination) {
211
+ const report = await workerDoctor(stateDir, destination);
212
+ console.log(JSON.stringify(report, null, 2));
213
+ if (report.status === "blocked") process.exitCode = 1;
214
+ } else {
215
+ console.log(JSON.stringify(workerInventory(stateDir), null, 2));
216
+ }
217
+ return;
218
+ }
219
+ case "init": {
220
+ const usage = "Usage: omp-sa worker init --head-key PUBLIC_KEY --repo PATH [--repo PATH ...]";
221
+ let headKey: string | undefined;
222
+ const repositories: string[] = [];
223
+ for (let index = 0; index < operands.length; index += 2) {
224
+ const [flag, value] = [operands[index], operands[index + 1]];
225
+ if (!value || value.startsWith("-")) throw new Error(usage);
226
+ if (flag === "--head-key" && headKey === undefined) headKey = value;
227
+ else if (flag === "--repo") repositories.push(value);
228
+ else throw new Error(usage);
229
+ }
230
+ if (!headKey || !repositories.length) throw new Error(usage);
231
+ if (process.platform !== "darwin" && process.platform !== "linux") throw new Error("Worker init requires macOS or Linux");
232
+ const { workerPublicKey } = await import("./worker-registration");
233
+ const publicKey = workerPublicKey(headKey);
234
+ const { enrollWorker } = await import("./worker-enrollment");
235
+ const { activeManagedUlw } = await import("./managed-ulw");
236
+ await requireHostOwner();
237
+ activeManagedUlw();
238
+ const { executable } = await inspectInstalledOmp(["omp"]);
239
+ const { workerId, stateDir, repos, capacity } = await enrollWorker({ home: homedir(), headKey: publicKey, repositories, executable });
240
+ console.log(JSON.stringify({ status: "initialized", workerId, stateDir, repos, capacity }, null, 2));
241
+ return;
242
+ }
243
+ case "serve": {
244
+ const [flag, path] = operands;
245
+ if (operands.length !== 2 || flag !== "--policy" || !path || !isAbsolute(path) ||
246
+ process.env.SSH_ORIGINAL_COMMAND !== "omp-sa-worker-v1")
247
+ throw new Error("Worker serve requires the enrolled SSH forced command");
248
+ const { readWorkerPolicy } = await import("./worker-enrollment");
249
+ const policy = readWorkerPolicy(homedir(), path);
250
+ const { serveWorker } = await import("./worker-service");
251
+ await serveWorker(policy);
252
+ return;
253
+ }
254
+ default:
255
+ throw new Error("Usage: omp-sa worker add|init|list|doctor (see omp-sa worker --help)");
256
+ }
257
+ }
258
+
143
259
  export async function main(args = process.argv.slice(2)): Promise<void> {
260
+ if (args[0] === "worker") { await workerCommand(args.slice(1)); return; }
144
261
  if (!args.length || args.includes("--help") || args[0] === "help") { console.log(HELP); return; }
145
262
  const [command] = args;
146
263
  if (!["setup", "start", "install", "uninstall", "status", "group", "stop", "doctor", "discord-commands", "telegram-commands", "slack-commands"].includes(command!)) throw new Error(`Unknown command: ${command}`);
147
264
  const configAt = args.indexOf("--config");
148
265
  if (configAt < 0 || !args[configAt + 1]) throw new Error("--config FILE is required");
266
+ if (command === "stop" && !((configAt === 1 && args.length === 3) ||
267
+ (configAt === 2 && args.length === 4 && !args[1]?.startsWith("-"))))
268
+ throw new Error("Usage: omp-sa stop [main|LANE_ID] --config FILE");
149
269
  if (command === "install" || command === "uninstall") {
150
270
  if (args.length !== 3 || configAt !== 1 || args[2]!.startsWith("-"))
151
271
  throw new Error(`Usage: ${command} --config FILE`);
@@ -204,13 +324,12 @@ export async function main(args = process.argv.slice(2)): Promise<void> {
204
324
  return;
205
325
  }
206
326
  const target = args[1] && !args[1]!.startsWith("-") ? args[1]! : "main";
207
- const paths = hostPaths(config, target);
208
327
  if (command === "doctor") {
209
328
  const { requireGateway } = await import("./gateway-native");
210
- const { inspectManagedMnemopi, memoryBlockReason } = await import("./managed-memory");
329
+ const { inspectManagedMemory, memoryBlockReason } = await import("./managed-memory");
211
330
  loadCredentials(config);
212
331
  const omp = await inspectInstalledOmp(config.command, credentialEnvNames(config));
213
- const memory = await inspectManagedMnemopi(config);
332
+ const memory = await inspectManagedMemory(config);
214
333
  console.log(JSON.stringify({
215
334
  config: config.path, command: config.command, headCwd: config.headCwd,
216
335
  omp, hostOwnerExecutable: await requireHostOwner(), gatewayExecutable: await requireGateway(), nativeTuiAttach: false,
@@ -227,21 +346,24 @@ export async function main(args = process.argv.slice(2)): Promise<void> {
227
346
  if (command === "status") {
228
347
  const { gatewayStatus } = await import("./gateway-protocol");
229
348
  const { autostartStatus } = await import("./autostart");
349
+ const { listWorkers } = await import("./worker-registration");
350
+ const { lanePlacement } = await import("./lane-rows");
230
351
  console.log(JSON.stringify({
231
352
  gateway: await gatewayStatus(config),
232
353
  autostart: await autostartStatus(config),
233
354
  main: { socketPath: hostPaths(config, "main").socketPath },
355
+ workers: listWorkers(config.stateDir).map(({ destination, description, defaultRepository }) =>
356
+ ({ destination, ...description, default: !!defaultRepository, ...(defaultRepository ? { defaultRepository } : {}) })),
234
357
  lanes: laneRows(config.stateDir).map(l => ({
235
358
  id: l.id, title: l.title, cwd: l.cwd, workState: l.workState,
236
359
  model: l.model, modelReason: l.modelReason, modelPreset: l.modelPreset,
237
360
  recordedRuntimeState: l.runtimeState, sessionId: l.sessionId, socketPath: l.socketPath,
361
+ placement: lanePlacement(l),
238
362
  })),
239
- note: "Gateway/head readiness is live when the Gateway is reachable; lane records are not a completion guarantee.",
363
+ note: "Gateway/head readiness is live when reachable. Lane records are not a completion guarantee; workers are last verified, not live probes.",
240
364
  }, null, 2));
241
365
  return;
242
366
  }
243
- if (target !== "main" && !laneRows(config.stateDir).some(l => l.id === target))
244
- throw new Error("Unknown managed lane");
245
367
  if (command === "stop") {
246
368
  if (target === "main") {
247
369
  const { stopGateway } = await import("./gateway-native");
@@ -249,16 +371,36 @@ export async function main(args = process.argv.slice(2)): Promise<void> {
249
371
  console.log("Gateway and supervised main host accepted graceful shutdown.");
250
372
  return;
251
373
  }
252
- const { connect } = await import("./host");
253
- const host = await connect(paths.socketPath);
374
+ const lane = laneRows(config.stateDir).find(record => record.id === target);
375
+ if (!lane) throw new Error("Unknown managed lane");
376
+ const remote = lane.remote;
377
+ let host: HostConnection;
378
+ if (remote) {
379
+ const { lookupWorker, remoteLanePaths, workerConnect, workerRef } = await import("./worker-wire");
380
+ const paths = remoteLanePaths(remote, lane.id);
381
+ if (lane.pid === null || !lane.sessionId || lane.sessionFile !== paths.sessionFile || lane.socketPath !== paths.socketPath)
382
+ throw new Error("Remote lane has no recorded Host identity eligible for shutdown");
383
+ host = await workerConnect(await lookupWorker(config.stateDir, remote), workerRef(lane));
384
+ } else {
385
+ const { connect } = await import("./host");
386
+ host = await connect(hostPaths(config, target).socketPath);
387
+ }
254
388
  try {
389
+ if (remote) {
390
+ const state = await host.client.getState();
391
+ if (state.hostPid !== lane.pid || state.sessionId !== lane.sessionId || state.sessionFile !== lane.sessionFile)
392
+ throw new Error("Remote Host identity no longer matches the recorded lane; shutdown was not sent");
393
+ }
255
394
  const response = await host.request({ type: "shutdown_host" });
256
395
  if (!response.success) throw new Error(response.error ?? "Host refused shutdown");
257
396
  console.log(`Host ${target} accepted graceful shutdown.`);
258
397
  } finally { await host.close(); }
259
398
  return;
260
399
  }
261
- if (target !== "main") throw new Error("start only activates the Gateway/main service; lanes remain head-owned");
400
+ if (target !== "main") {
401
+ if (!laneRows(config.stateDir).some(lane => lane.id === target)) throw new Error("Unknown managed lane");
402
+ throw new Error("start only activates the Gateway/main service; lanes remain head-owned");
403
+ }
262
404
  loadCredentials(config);
263
405
  // Only pass validated messenger credentials to the native launcher.
264
406
  requireMessengerCredentials(config);