@phren/cli 0.3.11 → 0.3.13

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 (182) hide show
  1. package/dist/bridge/account-usage.d.ts +124 -0
  2. package/dist/bridge/account-usage.js +258 -0
  3. package/dist/bridge/agent-hook-stores.d.ts +3 -0
  4. package/dist/bridge/agent-hook-stores.js +5 -0
  5. package/dist/bridge/agent-hooks.d.ts +162 -5
  6. package/dist/bridge/agent-hooks.js +682 -49
  7. package/dist/bridge/approval-summary.d.ts +16 -0
  8. package/dist/bridge/approval-summary.js +133 -0
  9. package/dist/bridge/authority-command.d.ts +20 -0
  10. package/dist/bridge/authority-command.js +120 -0
  11. package/dist/bridge/authority.d.ts +223 -0
  12. package/dist/bridge/authority.js +231 -0
  13. package/dist/bridge/claude-account-setup.d.ts +14 -0
  14. package/dist/bridge/claude-account-setup.js +69 -0
  15. package/dist/bridge/claude-accounts.d.ts +49 -0
  16. package/dist/bridge/claude-accounts.js +195 -0
  17. package/dist/bridge/code-routes.js +2 -2
  18. package/dist/bridge/codex-app-server.d.ts +144 -0
  19. package/dist/bridge/codex-app-server.js +319 -0
  20. package/dist/bridge/codex-auth-refresh.d.ts +33 -0
  21. package/dist/bridge/codex-auth-refresh.js +71 -0
  22. package/dist/bridge/codex-hook-trust.d.ts +27 -0
  23. package/dist/bridge/codex-hook-trust.js +237 -0
  24. package/dist/bridge/codex-question-reply.d.ts +16 -0
  25. package/dist/bridge/codex-question-reply.js +57 -0
  26. package/dist/bridge/codex-review-mode.d.ts +10 -0
  27. package/dist/bridge/codex-review-mode.js +74 -0
  28. package/dist/bridge/codex-servers.d.ts +217 -0
  29. package/dist/bridge/codex-servers.js +636 -0
  30. package/dist/bridge/command.js +97 -4
  31. package/dist/bridge/computer-identity.d.ts +75 -0
  32. package/dist/bridge/computer-identity.js +166 -0
  33. package/dist/bridge/conductor-group.d.ts +91 -8
  34. package/dist/bridge/conductor-group.js +105 -9
  35. package/dist/bridge/conductor-role.d.ts +94 -0
  36. package/dist/bridge/conductor-role.js +176 -0
  37. package/dist/bridge/conductor-sets.d.ts +20 -0
  38. package/dist/bridge/conductor-sets.js +59 -0
  39. package/dist/bridge/dispatch-command.d.ts +3 -0
  40. package/dist/bridge/dispatch-command.js +82 -12
  41. package/dist/bridge/dispatch-returns.d.ts +128 -19
  42. package/dist/bridge/dispatch-returns.js +371 -54
  43. package/dist/bridge/dispatch.d.ts +128 -3
  44. package/dist/bridge/dispatch.js +303 -42
  45. package/dist/bridge/fanouts.d.ts +7 -1
  46. package/dist/bridge/fanouts.js +39 -4
  47. package/dist/bridge/folder-trust.d.ts +56 -0
  48. package/dist/bridge/folder-trust.js +195 -0
  49. package/dist/bridge/grants.d.ts +22 -1
  50. package/dist/bridge/grants.js +57 -9
  51. package/dist/bridge/hand-off-queue.d.ts +74 -0
  52. package/dist/bridge/hand-off-queue.js +235 -0
  53. package/dist/bridge/hand-off.d.ts +30 -10
  54. package/dist/bridge/hand-off.js +79 -46
  55. package/dist/bridge/harness-status.d.ts +11 -0
  56. package/dist/bridge/harness-status.js +32 -0
  57. package/dist/bridge/harnesses.d.ts +39 -0
  58. package/dist/bridge/harnesses.js +65 -0
  59. package/dist/bridge/health.d.ts +2 -0
  60. package/dist/bridge/health.js +1 -1
  61. package/dist/bridge/herdr.d.ts +11 -2
  62. package/dist/bridge/herdr.js +98 -23
  63. package/dist/bridge/hook-fast.d.ts +4 -0
  64. package/dist/bridge/hook-fast.js +68 -0
  65. package/dist/bridge/install.d.ts +16 -1
  66. package/dist/bridge/install.js +102 -21
  67. package/dist/bridge/launch-brief.d.ts +96 -0
  68. package/dist/bridge/launch-brief.js +164 -0
  69. package/dist/bridge/model-switch.d.ts +3 -0
  70. package/dist/bridge/model-switch.js +17 -1
  71. package/dist/bridge/models.d.ts +8 -4
  72. package/dist/bridge/models.js +24 -8
  73. package/dist/bridge/mux-wire.d.ts +9 -0
  74. package/dist/bridge/mux-wire.js +19 -0
  75. package/dist/bridge/opencode-pane-server.d.ts +113 -0
  76. package/dist/bridge/opencode-pane-server.js +332 -0
  77. package/dist/bridge/opencode-panes.d.ts +111 -0
  78. package/dist/bridge/opencode-panes.js +295 -0
  79. package/dist/bridge/pane-accounts.d.ts +8 -0
  80. package/dist/bridge/pane-accounts.js +46 -0
  81. package/dist/bridge/pane-status.d.ts +12 -0
  82. package/dist/bridge/pane-status.js +50 -1
  83. package/dist/bridge/prompt-startup.d.ts +5 -0
  84. package/dist/bridge/prompt-startup.js +24 -0
  85. package/dist/bridge/protocol.d.ts +5 -0
  86. package/dist/bridge/protocol.js +4 -0
  87. package/dist/bridge/push.d.ts +11 -4
  88. package/dist/bridge/push.js +27 -4
  89. package/dist/bridge/questions.d.ts +37 -2
  90. package/dist/bridge/questions.js +158 -15
  91. package/dist/bridge/resources.d.ts +9 -3
  92. package/dist/bridge/resources.js +24 -8
  93. package/dist/bridge/schedule-format.d.ts +2 -0
  94. package/dist/bridge/schedule-format.js +3 -0
  95. package/dist/bridge/schedule-launch.d.ts +2 -1
  96. package/dist/bridge/schedule-launch.js +27 -53
  97. package/dist/bridge/schedule-watch.d.ts +24 -1
  98. package/dist/bridge/schedule-watch.js +89 -2
  99. package/dist/bridge/server-launch.d.ts +22 -5
  100. package/dist/bridge/server-launch.js +238 -32
  101. package/dist/bridge/server-overview.d.ts +10 -3
  102. package/dist/bridge/server-overview.js +32 -15
  103. package/dist/bridge/server-pane-routes.d.ts +3 -0
  104. package/dist/bridge/server-pane-routes.js +150 -18
  105. package/dist/bridge/server-routes.d.ts +11 -0
  106. package/dist/bridge/server-routes.js +214 -36
  107. package/dist/bridge/server-stream.d.ts +2 -0
  108. package/dist/bridge/server-stream.js +22 -8
  109. package/dist/bridge/server.d.ts +6 -1
  110. package/dist/bridge/server.js +58 -13
  111. package/dist/bridge/session-activity.d.ts +93 -0
  112. package/dist/bridge/session-activity.js +139 -0
  113. package/dist/bridge/session-rename.d.ts +48 -0
  114. package/dist/bridge/session-rename.js +190 -0
  115. package/dist/bridge/session-servers.js +2 -2
  116. package/dist/bridge/settings-switch.d.ts +60 -0
  117. package/dist/bridge/settings-switch.js +287 -0
  118. package/dist/bridge/speech-voice.d.ts +55 -0
  119. package/dist/bridge/speech-voice.js +132 -0
  120. package/dist/bridge/speech.d.ts +70 -11
  121. package/dist/bridge/speech.js +169 -41
  122. package/dist/bridge/stalls.d.ts +22 -0
  123. package/dist/bridge/stalls.js +57 -0
  124. package/dist/bridge/sudo.d.ts +209 -0
  125. package/dist/bridge/sudo.js +501 -0
  126. package/dist/bridge/terminal-herdr.js +9 -3
  127. package/dist/bridge/terminal-tmux.d.ts +15 -3
  128. package/dist/bridge/terminal-tmux.js +103 -13
  129. package/dist/bridge/terminal.d.ts +27 -4
  130. package/dist/bridge/terminal.js +8 -1
  131. package/dist/bridge/transcript-claude.d.ts +4 -0
  132. package/dist/bridge/transcript-claude.js +186 -16
  133. package/dist/bridge/transcript-codex.d.ts +0 -2
  134. package/dist/bridge/transcript-codex.js +29 -4
  135. package/dist/bridge/transcript-preview.d.ts +1 -0
  136. package/dist/bridge/transcript-preview.js +24 -4
  137. package/dist/bridge/transcripts.d.ts +15 -2
  138. package/dist/bridge/transcripts.js +47 -16
  139. package/dist/bridge/turn-records.d.ts +85 -0
  140. package/dist/bridge/turn-records.js +143 -0
  141. package/dist/bridge/uploads.d.ts +3 -0
  142. package/dist/bridge/uploads.js +14 -0
  143. package/dist/bridge/usage.d.ts +56 -10
  144. package/dist/bridge/usage.js +190 -45
  145. package/dist/bridge-hook.mjs +27975 -20636
  146. package/dist/cli/claude-unmanaged.d.ts +12 -0
  147. package/dist/cli/claude-unmanaged.js +105 -0
  148. package/dist/cli/schedules.js +2 -1
  149. package/dist/cli/session-start.js +10 -1
  150. package/dist/cli/session-stop.js +9 -1
  151. package/dist/cli-registry.js +31 -6
  152. package/dist/data/task-receipts.d.ts +19 -0
  153. package/dist/data/task-receipts.js +68 -0
  154. package/dist/data/tasks.js +4 -1
  155. package/dist/generated/memory-ui-graph.browser.js +63 -63
  156. package/dist/graph-core/model.js +24 -3
  157. package/dist/graph-core/types.d.ts +4 -1
  158. package/dist/graph-core/types.js +1 -0
  159. package/dist/init/init-preset.js +7 -3
  160. package/dist/init/init-uninstall.js +2 -11
  161. package/dist/init/teardown.d.ts +3 -0
  162. package/dist/init/teardown.js +47 -0
  163. package/dist/link/context.js +21 -9
  164. package/dist/mcp/plugin-mode.js +1 -1
  165. package/dist/memory-ui-graph.runtime.js +63 -63
  166. package/dist/modules/code-package.d.ts +1 -0
  167. package/dist/modules/code-package.js +36 -7
  168. package/dist/modules/registry.js +17 -16
  169. package/dist/profile-store.d.ts +6 -0
  170. package/dist/profile-store.js +25 -1
  171. package/dist/shell/graph/glyphs.js +4 -0
  172. package/dist/shell/graph/graph-view.js +2 -0
  173. package/dist/status.js +7 -1
  174. package/dist/sync/task-claim.js +3 -2
  175. package/dist/task/lifecycle.js +25 -4
  176. package/dist/test-global-setup.js +5 -0
  177. package/dist/tools/dispatch.js +52 -4
  178. package/dist/tools/tasks.js +10 -1
  179. package/package.json +1 -1
  180. package/plugins/opencode/phren-transcript.js +87 -4
  181. package/starter/global/AGENTS.md +4 -0
  182. package/starter/global/skills/conductor/SKILL.md +51 -4
@@ -1,14 +1,21 @@
1
+ import { sessionStalls } from "./stalls.js";
1
2
  import { z } from "zod";
2
- import { type Receipt } from "./dispatch.js";
3
+ import { type OriginPane, type Receipt } from "./dispatch.js";
4
+ import { type BriefArrival } from "./launch-brief.js";
5
+ import { findGrant } from "./grants.js";
3
6
  import { peerRequest, type HookPeer } from "./peers.js";
4
7
  import { type Json, type Provider, type Target } from "./protocol.js";
5
8
  import { type FinalTurn } from "./schedule-watch.js";
9
+ import { type TurnRecord } from "./turn-records.js";
10
+ export { truncateUtf8 } from "./turn-records.js";
6
11
  /**
7
12
  * The conductor's returns loop. The worker's computer answers what its
8
- * dispatched panes are doing from the Herdr snapshot its Hook already shares
9
- * (`workerStates`); the dispatching Hook asks each peer once per poll for all
10
- * of its open dispatches, records transitions in the receipts, and tells an
11
- * idle dispatching agent that returns are waiting (`DispatchReturns`).
13
+ * dispatched panes are doing (`workerStates`): from the turn record its
14
+ * agent's own hooks wrote (turn-records.ts) when there is one, else from the
15
+ * Herdr snapshot its Hook already shares and the transcript. The dispatching
16
+ * Hook asks each peer once per poll for all of its open dispatches, records
17
+ * transitions in the receipts, and tells an idle dispatching agent that
18
+ * returns are waiting (`DispatchReturns`).
12
19
  */
13
20
  /** Longest final reply kept in a receipt, in UTF-8 bytes. */
14
21
  export declare const REPLY_LIMIT = 4000;
@@ -18,9 +25,13 @@ export declare const POLL_MS = 15000;
18
25
  export declare const NOTICE_MS = 120000;
19
26
  /** Receipts older than this are no longer watched. */
20
27
  export declare const WATCH_MS: number;
21
- /** An idle worker that was never seen working and has no finished turn is
22
- * counted as done after this long: the prompt may never have been taken. */
23
- export declare const IDLE_GRACE_MS: number;
28
+ /** How long a stopped worker whose harness still runs background tasks is
29
+ * waited on before it counts as done anyway. Measured from the latest Stop,
30
+ * and every task that finishes wakes the worker (a new prompt, a new Stop), so
31
+ * it only elapses when no background task has finished for two hours: a dev
32
+ * server the worker left running. It is then reported done with the count
33
+ * still running. */
34
+ export declare const BACKGROUND_WAIT_MS: number;
24
35
  export declare const workerRequestSchema: z.ZodObject<{
25
36
  targets: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
26
37
  server: z.ZodString;
@@ -35,6 +46,7 @@ export declare const workerRequestSchema: z.ZodObject<{
35
46
  phren: "phren";
36
47
  }>;
37
48
  session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
49
+ dispatch: z.ZodOptional<z.ZodString>;
38
50
  }, z.core.$strip>, z.ZodObject<{
39
51
  server: z.ZodString;
40
52
  workspace: z.ZodString;
@@ -49,6 +61,7 @@ export declare const workerRequestSchema: z.ZodObject<{
49
61
  }>;
50
62
  starting: z.ZodLiteral<true>;
51
63
  startingToken: z.ZodString;
64
+ dispatch: z.ZodOptional<z.ZodString>;
52
65
  }, z.core.$strip>]>>;
53
66
  }, z.core.$strict>;
54
67
  /** What a worker pane shows right now, as its own computer reads it. */
@@ -61,22 +74,81 @@ export interface WorkerObservation {
61
74
  truncated?: boolean;
62
75
  /** The error the harness ended the turn on (Codex's usage limit). */
63
76
  error?: string;
77
+ /** The state comes from the agent's own turn events, not from how the pane looks. */
78
+ hook?: true;
79
+ /** When the turn's Stop arrived, on the worker's clock; names the turn. */
80
+ endedAt?: string;
81
+ /** Background tasks the harness still runs: waited on while `working`,
82
+ * left running when `done` after BACKGROUND_WAIT_MS. */
83
+ background?: number;
84
+ /** The owner stopped the turn in the worker's terminal. */
85
+ interrupted?: true;
86
+ /** A permission request the pane's worker is waiting on, forwarded by its Hook (`AgentHooks.workerApproval`). */
87
+ approval?: Json;
88
+ stalled?: boolean;
89
+ stalledSince?: string;
90
+ stallFor?: number;
64
91
  }
65
92
  export interface WorkerReaders {
66
93
  snapshot: (server: string) => Promise<Json>;
67
94
  identity: (server: string, pane: Json) => Promise<string | undefined>;
68
95
  finalTurn: (source: Provider, session: string) => Promise<FinalTurn | undefined>;
96
+ /** The turn record the pane's agent reported through its hooks (or OpenCode's plugin). */
97
+ turn?: (server: string, pane: Json, source: Provider) => Promise<TurnRecord | undefined>;
98
+ /** What the worker in this conversation is waiting on, from the Hook that runs it. */
99
+ approval?: (target: Target) => Json | undefined;
100
+ now?: () => number;
101
+ stall?: typeof sessionStalls.observe;
69
102
  }
70
- /** `value` cut to at most `limit` UTF-8 bytes on a character boundary. */
71
- export declare function truncateUtf8(value: string, limit?: number): {
72
- text: string;
73
- truncated: boolean;
74
- };
75
- /** Receiving side: the state of each dispatched pane, from the shared snapshot
76
- * and, once the agent has stopped, the final reply in its transcript. */
103
+ /** The default readers with the approval reader of the Hook that runs the workers. */
104
+ export declare const workerReaders: (approval: NonNullable<WorkerReaders["approval"]>) => WorkerReaders;
105
+ /** The receiving side of `/v1/dispatch/workers` on a Hook: leases the panes'
106
+ * permission asks for the dispatching Hook's next polls and reads what each
107
+ * worker is waiting on. */
108
+ export declare function hookWorkers(hooks: {
109
+ leaseDispatch: (targets: readonly {
110
+ server: string;
111
+ pane: string;
112
+ source: string;
113
+ }[]) => void;
114
+ workerApproval: (target: Target) => object | undefined;
115
+ }): (input: unknown) => Promise<{
116
+ workers: WorkerObservation[];
117
+ }>;
118
+ /** Receiving side: the state of each dispatched pane, from its agent's turn
119
+ * record when its hooks wrote one, else from the shared snapshot and, once
120
+ * the agent has stopped, the final reply in its transcript. */
77
121
  export declare function workerStates(input: unknown, readers?: WorkerReaders): Promise<{
78
122
  workers: WorkerObservation[];
79
123
  }>;
124
+ /** A worker's forwarded permission request as its Hook sent it; an invalid one is ignored, not a reason to drop the state. */
125
+ declare const approvalObservation: z.ZodObject<{
126
+ actionId: z.ZodString;
127
+ tool: z.ZodDefault<z.ZodString>;
128
+ title: z.ZodOptional<z.ZodString>;
129
+ request: z.ZodOptional<z.ZodString>;
130
+ requestKind: z.ZodOptional<z.ZodEnum<{
131
+ command: "command";
132
+ edit: "edit";
133
+ other: "other";
134
+ question: "question";
135
+ tool: "tool";
136
+ }>>;
137
+ terminal: z.ZodOptional<z.ZodBoolean>;
138
+ conductor: z.ZodOptional<z.ZodObject<{
139
+ action: z.ZodEnum<{
140
+ dispatch: "dispatch";
141
+ hand_off: "hand_off";
142
+ }>;
143
+ project: z.ZodOptional<z.ZodString>;
144
+ computer: z.ZodOptional<z.ZodString>;
145
+ }, z.core.$strict>>;
146
+ expiresAt: z.ZodOptional<z.ZodString>;
147
+ pushed: z.ZodOptional<z.ZodBoolean>;
148
+ }, z.core.$strip>;
149
+ export type ObservedApproval = z.infer<typeof approvalObservation>;
150
+ /** What the owner is told when the worker's turn was interrupted in its terminal. */
151
+ export declare const INTERRUPTED = "The worker's turn was interrupted in its terminal before it finished.";
80
152
  /** Apply one observation to a receipt. Returns true when the receipt changed. */
81
153
  export declare function observe(receipt: Receipt, value: unknown, now: number): boolean;
82
154
  /** One line for the dispatching agent: who returned, how, and where to read it. */
@@ -94,12 +166,23 @@ export interface DispatchReturnsOptions {
94
166
  /** A recent Herdr snapshot of a local server, to see whether the dispatching agent is idle. */
95
167
  snapshot?: (server: string) => Promise<Json>;
96
168
  identity?: (server: string, pane: Json) => Promise<string | undefined>;
97
- /** Types the notice into the dispatching agent, through the ordinary hand-off path. */
98
- deliver?: (target: Target, text: string) => Promise<{
169
+ /** Types the notice into the dispatching agent, through the ordinary hand-off
170
+ * path; the same notice keeps one delivery id, so a retry is never typed twice. */
171
+ deliver?: (target: Target, text: string, deliveryId: string) => Promise<{
99
172
  delivered: boolean;
100
173
  }>;
174
+ /** What a worker's hooks reported for a brief launched on this computer. */
175
+ localArrival?: (id: string) => Promise<BriefArrival | undefined>;
176
+ /** The standing grant for a conductor call, on this computer. */
177
+ findGrant?: typeof findGrant;
178
+ /** Answers a worker's approval placed on this computer, without SSH (the Hook's own `AgentHooks.answer`). */
179
+ localAnswer?: (target: Target, actionId: string, decision: "approve" | "deny") => Promise<unknown>;
180
+ /** A worker's new forwarded request was recorded. Returns true when this Hook pushed it to its phone. */
181
+ onApproval?: (receipt: Receipt, approval: NonNullable<Receipt["approval"]>) => boolean | void;
101
182
  now?: () => number;
102
183
  }
184
+ /** One notice's delivery id, named by what it reports: the same returns keep the same id on a retry. */
185
+ export declare function noticeDeliveryId(receipts: readonly Receipt[]): string;
103
186
  /** Dispatching side: follows open dispatches and delivers their returns. */
104
187
  export declare class DispatchReturns {
105
188
  private readonly peers;
@@ -109,16 +192,42 @@ export declare class DispatchReturns {
109
192
  private readonly snapshot;
110
193
  private readonly identity;
111
194
  private readonly deliver;
195
+ private readonly localArrival;
112
196
  private readonly now;
197
+ private readonly grant;
198
+ private readonly localAnswer?;
199
+ private readonly onApproval?;
113
200
  private lastPoll;
114
201
  private readonly lastNotice;
202
+ /** A return is waiting for a dispatching agent that was busy: try again on
203
+ * the next tick instead of the next poll. */
204
+ private noticesDue;
115
205
  private running?;
116
206
  constructor(options?: DispatchReturnsOptions);
117
- /** Called from the Hook's activity tick; polls and notifies at most every POLL_MS. */
207
+ /** Send a decision for a worker's request to the Hook that runs it. */
208
+ private sendAnswer;
209
+ /** Answer the permission request a dispatched worker is waiting on. It is
210
+ * cleared from the receipt once answered, or once its Hook says it is no
211
+ * longer pending (answered in the terminal, or timed out). */
212
+ answerApproval(id: string, decision: "approve" | "deny", actionId: string, caller?: OriginPane): Promise<void>;
213
+ /** Called from the Hook's activity tick. Polls peers at most every POLL_MS;
214
+ * a return waiting for its notice is tried on every tick, so one recorded
215
+ * while the dispatching agent was busy reaches it as soon as it stops. */
118
216
  tick(): Promise<void>;
217
+ /**
218
+ * A brief that went with the launch but was not confirmed while the dispatch
219
+ * was placed (a startup screen held it, the agent was slow): ask the
220
+ * worker's computer whether its hook has confirmed it since.
221
+ */
222
+ confirmArrivals(peers: HookPeer[]): Promise<void>;
119
223
  /** Ask each peer, once, about every open dispatch placed on it. */
120
224
  poll(): Promise<void>;
121
- /** Type one line into each idle dispatching agent that has returns it was not told about. */
225
+ /** A conductor call the owner's standing grant covers is answered here at
226
+ * once, and its request is left off the observation so it never becomes a
227
+ * return. Anything else, or an answer that failed, is left for the owner. */
228
+ private grantAnswered;
229
+ /** Type one line into each idle dispatching agent that has returns it was
230
+ * not told about. A pane still working is tried again on the next tick. */
122
231
  notify(): Promise<void>;
123
232
  /** Every unread return, oldest first, marked read as it is handed over. */
124
233
  take(): Promise<Json[]>;