@phren/cli 0.3.71 → 0.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/agent-hooks.js +11 -1
- package/dist/bridge/browser-env.d.ts +5 -0
- package/dist/bridge/browser-env.js +110 -0
- package/dist/bridge/browser-protocol.d.ts +120 -0
- package/dist/bridge/browser-protocol.js +70 -0
- package/dist/bridge/browser-recordings.d.ts +63 -0
- package/dist/bridge/browser-recordings.js +148 -0
- package/dist/bridge/browser-registry.d.ts +64 -0
- package/dist/bridge/browser-registry.js +262 -0
- package/dist/bridge/browser-routes.d.ts +4 -0
- package/dist/bridge/browser-routes.js +39 -0
- package/dist/bridge/browser-shim/phren-playwright.cjs +184 -0
- package/dist/bridge/browser-socket.d.ts +2 -0
- package/dist/bridge/browser-socket.js +10 -0
- package/dist/bridge/browser-stream.d.ts +3 -0
- package/dist/bridge/browser-stream.js +129 -0
- package/dist/bridge/browser-watch.d.ts +12 -0
- package/dist/bridge/browser-watch.js +83 -0
- package/dist/bridge/claude-account-setup.js +3 -1
- package/dist/bridge/claude-accounts.d.ts +5 -1
- package/dist/bridge/claude-accounts.js +36 -6
- package/dist/bridge/codex-servers.d.ts +2 -0
- package/dist/bridge/codex-servers.js +1 -1
- package/dist/bridge/command.js +24 -5
- package/dist/bridge/dispatch-clone.d.ts +33 -0
- package/dist/bridge/dispatch-clone.js +176 -0
- package/dist/bridge/dispatch-command.d.ts +14 -0
- package/dist/bridge/dispatch-command.js +98 -13
- package/dist/bridge/dispatch-idempotency.d.ts +85 -0
- package/dist/bridge/dispatch-idempotency.js +235 -0
- package/dist/bridge/dispatch-returns.d.ts +6 -0
- package/dist/bridge/dispatch-returns.js +131 -1
- package/dist/bridge/dispatch-wait.d.ts +32 -0
- package/dist/bridge/dispatch-wait.js +177 -0
- package/dist/bridge/dispatch.d.ts +78 -2
- package/dist/bridge/dispatch.js +841 -25
- package/dist/bridge/dream-schedule.d.ts +133 -0
- package/dist/bridge/dream-schedule.js +322 -0
- package/dist/bridge/fanouts.js +20 -3
- package/dist/bridge/files.d.ts +1 -1
- package/dist/bridge/git-credential.d.ts +44 -0
- package/dist/bridge/git-credential.js +113 -0
- package/dist/bridge/git-host-auth.d.ts +9 -1
- package/dist/bridge/git-host-auth.js +18 -5
- package/dist/bridge/git-host-gitboy.js +8 -1
- package/dist/bridge/git-hosts.d.ts +12 -1
- package/dist/bridge/git-publish.js +3 -2
- package/dist/bridge/herdr.d.ts +4 -0
- package/dist/bridge/herdr.js +44 -9
- package/dist/bridge/install.d.ts +1 -1
- package/dist/bridge/install.js +12 -4
- package/dist/bridge/launch-brief.d.ts +11 -0
- package/dist/bridge/launch-brief.js +22 -0
- package/dist/bridge/launch-worktree.d.ts +2 -0
- package/dist/bridge/launch-worktree.js +5 -1
- package/dist/bridge/pane-status.js +1 -1
- package/dist/bridge/protocol.d.ts +7 -0
- package/dist/bridge/schedule-watch.js +13 -2
- package/dist/bridge/server-launch.d.ts +2 -0
- package/dist/bridge/server-launch.js +251 -145
- package/dist/bridge/server-routes.d.ts +3 -0
- package/dist/bridge/server-routes.js +33 -17
- package/dist/bridge/server-stream.d.ts +4 -0
- package/dist/bridge/server-stream.js +24 -5
- package/dist/bridge/server.js +35 -4
- package/dist/bridge/session-move.d.ts +10 -4
- package/dist/bridge/session-move.js +65 -34
- package/dist/bridge/simulator-stream.d.ts +2 -0
- package/dist/bridge/simulator-stream.js +2 -0
- package/dist/bridge/status-line-fast.d.ts +9 -0
- package/dist/bridge/status-line-fast.js +56 -0
- package/dist/bridge/tab-activity.d.ts +2 -0
- package/dist/bridge/tab-activity.js +15 -2
- package/dist/bridge/task-routes.d.ts +20 -16
- package/dist/bridge/task-routes.js +1 -1
- package/dist/bridge/terminal-herdr.d.ts +5 -1
- package/dist/bridge/terminal-herdr.js +67 -2
- package/dist/bridge/terminal-tmux.d.ts +2 -0
- package/dist/bridge/terminal-tmux.js +29 -7
- package/dist/bridge/terminal.d.ts +5 -1
- package/dist/bridge/transcript-claude.js +192 -112
- package/dist/bridge/transcript-preview.d.ts +2 -1
- package/dist/bridge/transcript-preview.js +85 -3
- package/dist/bridge/transcripts.js +17 -11
- package/dist/bridge/turn-records.js +16 -4
- package/dist/bridge/usage.d.ts +7 -1
- package/dist/bridge/usage.js +47 -31
- package/dist/bridge/worker-close.d.ts +15 -0
- package/dist/bridge/worker-close.js +304 -3
- package/dist/bridge/worker-identity.d.ts +51 -0
- package/dist/bridge/worker-identity.js +289 -0
- package/dist/bridge/worker-reports.js +15 -3
- package/dist/bridge-hook.mjs +39990 -36152
- package/dist/capabilities/mcp.js +1 -1
- package/dist/cli/browser-hint.d.ts +2 -0
- package/dist/cli/browser-hint.js +21 -0
- package/dist/cli/config-dreaming.d.ts +7 -0
- package/dist/cli/config-dreaming.js +72 -0
- package/dist/cli/config.js +6 -0
- package/dist/cli/dream.d.ts +59 -0
- package/dist/cli/dream.js +315 -0
- package/dist/cli/hooks-context.d.ts +2 -2
- package/dist/cli/hooks-context.js +3 -3
- package/dist/cli/hooks.js +20 -11
- package/dist/cli/namespaces-tasks.js +14 -0
- package/dist/cli-registry.js +28 -3
- package/dist/config/dreaming.d.ts +82 -0
- package/dist/config/dreaming.js +195 -0
- package/dist/config/resolve.js +11 -0
- package/dist/config/schema.d.ts +4 -4
- package/dist/config/schema.js +157 -1
- package/dist/content/citation-freshness.js +6 -0
- package/dist/content/learning.d.ts +1 -0
- package/dist/content/learning.js +2 -0
- package/dist/data/access.d.ts +1 -1
- package/dist/data/access.js +3 -1
- package/dist/data/task-contract.d.ts +5 -4
- package/dist/data/tasks.d.ts +5 -0
- package/dist/data/tasks.js +28 -2
- package/dist/dream/apply.d.ts +69 -0
- package/dist/dream/apply.js +372 -0
- package/dist/dream/budget.d.ts +78 -0
- package/dist/dream/budget.js +180 -0
- package/dist/dream/collect.d.ts +86 -0
- package/dist/dream/collect.js +449 -0
- package/dist/dream/eval/dream-adapter.d.ts +16 -0
- package/dist/dream/eval/dream-adapter.js +21 -0
- package/dist/dream/eval/fixture.d.ts +53 -0
- package/dist/dream/eval/fixture.js +172 -0
- package/dist/dream/eval/index.d.ts +40 -0
- package/dist/dream/eval/index.js +78 -0
- package/dist/dream/eval/score.d.ts +34 -0
- package/dist/dream/eval/score.js +99 -0
- package/dist/dream/eval/scripted-model.d.ts +19 -0
- package/dist/dream/eval/scripted-model.js +70 -0
- package/dist/dream/pages.d.ts +68 -0
- package/dist/dream/pages.js +220 -0
- package/dist/dream/privacy.d.ts +3 -0
- package/dist/dream/privacy.js +18 -0
- package/dist/dream/prompt.d.ts +13 -0
- package/dist/dream/prompt.js +84 -0
- package/dist/dream/run.d.ts +98 -0
- package/dist/dream/run.js +317 -0
- package/dist/dream/types.d.ts +74 -0
- package/dist/dream/types.js +4 -0
- package/dist/finding/lifecycle.d.ts +2 -2
- package/dist/finding/lifecycle.js +5 -2
- package/dist/finding/versions.d.ts +4 -0
- package/dist/finding/versions.js +28 -0
- package/dist/index.js +1 -0
- package/dist/modules/registry.js +10 -8
- package/dist/project-config.d.ts +3 -0
- package/dist/task/merge-links.d.ts +38 -0
- package/dist/task/merge-links.js +45 -0
- package/dist/task/reconcile.d.ts +39 -0
- package/dist/task/reconcile.js +201 -0
- package/dist/task/report-links.d.ts +10 -0
- package/dist/task/report-links.js +47 -0
- package/dist/tools/config.js +46 -4
- package/dist/tools/dispatch.js +2 -1
- package/dist/tools/dream.d.ts +3 -0
- package/dist/tools/dream.js +123 -0
- package/dist/tools/tasks.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { hookRequest } from "./client.js";
|
|
2
|
+
import type { Json } from "./protocol.js";
|
|
3
|
+
/**
|
|
4
|
+
* `phren dispatch wait`: follow one local dispatch to its end. It peeks at the
|
|
5
|
+
* Hook's returns (never taking them), filters to this dispatch, and reads the
|
|
6
|
+
* worker's live state to tell a gone pane from one still working. The output
|
|
7
|
+
* is NDJSON: one line per state change, then one final line. Only the final
|
|
8
|
+
* dispatch's own return is acknowledged, so a conductor's returns on the same
|
|
9
|
+
* Hook stay unread.
|
|
10
|
+
*/
|
|
11
|
+
/** How long an id the Hook does not know gets before it is "unknown dispatch". */
|
|
12
|
+
export declare const WAIT_GRACE_MS = 30000;
|
|
13
|
+
/** Continuous Hook unavailability before the wait ends failed. */
|
|
14
|
+
export declare const WAIT_UNAVAILABLE_MS: number;
|
|
15
|
+
/** Longest wait a caller may ask for. */
|
|
16
|
+
export declare const WAIT_MAX_MS: number;
|
|
17
|
+
export interface DispatchWaitOptions {
|
|
18
|
+
/** No timeout by default. Capped at seven days. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
request?: typeof hookRequest;
|
|
21
|
+
out?: (line: Json) => void;
|
|
22
|
+
now?: () => number;
|
|
23
|
+
sleep?: (ms: number) => Promise<void>;
|
|
24
|
+
/** First poll interval; it backs off to 10 s. */
|
|
25
|
+
intervalMs?: number;
|
|
26
|
+
jitter?: boolean;
|
|
27
|
+
graceMs?: number;
|
|
28
|
+
unavailableMs?: number;
|
|
29
|
+
}
|
|
30
|
+
/** About 2 s at first, backing off to 10 s, with jitter. */
|
|
31
|
+
export declare function waitDelay(attempt: number, baseMs?: number, jitter?: boolean): number;
|
|
32
|
+
export declare function waitForDispatch(id: string, options?: DispatchWaitOptions): Promise<number>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { setTimeout as sleepTimer } from "node:timers/promises";
|
|
2
|
+
import { hookRequest } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* `phren dispatch wait`: follow one local dispatch to its end. It peeks at the
|
|
5
|
+
* Hook's returns (never taking them), filters to this dispatch, and reads the
|
|
6
|
+
* worker's live state to tell a gone pane from one still working. The output
|
|
7
|
+
* is NDJSON: one line per state change, then one final line. Only the final
|
|
8
|
+
* dispatch's own return is acknowledged, so a conductor's returns on the same
|
|
9
|
+
* Hook stay unread.
|
|
10
|
+
*/
|
|
11
|
+
/** How long an id the Hook does not know gets before it is "unknown dispatch". */
|
|
12
|
+
export const WAIT_GRACE_MS = 30_000;
|
|
13
|
+
/** Continuous Hook unavailability before the wait ends failed. */
|
|
14
|
+
export const WAIT_UNAVAILABLE_MS = 5 * 60_000;
|
|
15
|
+
/** Longest wait a caller may ask for. */
|
|
16
|
+
export const WAIT_MAX_MS = 7 * 24 * 60 * 60 * 1000;
|
|
17
|
+
function objects(value) {
|
|
18
|
+
return Array.isArray(value) ? value.filter((item) => !!item && typeof item === "object" && !Array.isArray(item)) : [];
|
|
19
|
+
}
|
|
20
|
+
function object(value) {
|
|
21
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
22
|
+
}
|
|
23
|
+
function reason(error) {
|
|
24
|
+
const message = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
25
|
+
return message.replace(/[\x00-\x1f\x7f]/g, " ").slice(0, 200);
|
|
26
|
+
}
|
|
27
|
+
function questionOf(value) {
|
|
28
|
+
if (!value)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (typeof value.question === "string" && value.question)
|
|
31
|
+
return value.question;
|
|
32
|
+
const approval = object(value.approval);
|
|
33
|
+
for (const key of ["request", "title", "tool"])
|
|
34
|
+
if (typeof approval[key] === "string" && approval[key])
|
|
35
|
+
return String(approval[key]);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/** About 2 s at first, backing off to 10 s, with jitter. */
|
|
39
|
+
export function waitDelay(attempt, baseMs = 2_000, jitter = true) {
|
|
40
|
+
const target = Math.min(10_000, baseMs * 1.5 ** Math.max(0, attempt - 1));
|
|
41
|
+
return Math.max(1, Math.round(target * (jitter ? 0.8 + Math.random() * 0.4 : 1)));
|
|
42
|
+
}
|
|
43
|
+
export async function waitForDispatch(id, options = {}) {
|
|
44
|
+
const request = options.request ?? hookRequest;
|
|
45
|
+
const out = options.out ?? ((line) => console.log(JSON.stringify(line)));
|
|
46
|
+
const now = options.now ?? Date.now;
|
|
47
|
+
const sleep = options.sleep ?? ((ms) => sleepTimer(ms));
|
|
48
|
+
const base = options.intervalMs ?? 2_000;
|
|
49
|
+
const jitter = options.jitter ?? true;
|
|
50
|
+
const grace = options.graceMs ?? WAIT_GRACE_MS;
|
|
51
|
+
const unavailableLimit = options.unavailableMs ?? WAIT_UNAVAILABLE_MS;
|
|
52
|
+
const timeoutMs = options.timeoutMs === undefined ? undefined : Math.min(Math.max(0, options.timeoutMs), WAIT_MAX_MS);
|
|
53
|
+
const started = now();
|
|
54
|
+
let lastState;
|
|
55
|
+
let unknownSince;
|
|
56
|
+
let failingSince;
|
|
57
|
+
let lastWorkingAt;
|
|
58
|
+
let attempt = 0;
|
|
59
|
+
const emit = (state, extra = {}) => {
|
|
60
|
+
if (state === lastState)
|
|
61
|
+
return;
|
|
62
|
+
lastState = state;
|
|
63
|
+
out({ dispatch: id, state, ...extra, at: new Date(now()).toISOString() });
|
|
64
|
+
};
|
|
65
|
+
const final = (state, extra = {}) => out({ dispatch: id, state, final: true, ...extra });
|
|
66
|
+
for (;;) {
|
|
67
|
+
if (timeoutMs !== undefined && now() - started >= timeoutMs) {
|
|
68
|
+
final("timeout");
|
|
69
|
+
return 124;
|
|
70
|
+
}
|
|
71
|
+
let receipt, returned, worker, peeked;
|
|
72
|
+
let listError, peekError, workerError;
|
|
73
|
+
try {
|
|
74
|
+
const list = await request("/v1/dispatch");
|
|
75
|
+
receipt = objects(list.dispatches).find(row => row.id === id);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
listError = error;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const peek = await request("/v1/dispatch/returns?peek=1", {});
|
|
82
|
+
peeked = objects(peek.returns).find(row => row.id === id);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
peekError = error;
|
|
86
|
+
}
|
|
87
|
+
if (!listError) {
|
|
88
|
+
if (receipt)
|
|
89
|
+
unknownSince = undefined;
|
|
90
|
+
else if (unknownSince === undefined)
|
|
91
|
+
unknownSince = now();
|
|
92
|
+
}
|
|
93
|
+
const fromReceipt = receipt?.returned ? object(receipt.returned) : undefined;
|
|
94
|
+
// A return the conductor already read is still this dispatch's latest;
|
|
95
|
+
// use whichever of the peek and the receipt names the newer one.
|
|
96
|
+
returned = fromReceipt && String(fromReceipt.at ?? "") > String(peeked?.at ?? "") ? fromReceipt : peeked ?? fromReceipt;
|
|
97
|
+
// Live state is read on every poll, even when a return exists: a historical
|
|
98
|
+
// needs-you return must not mask a worker that has resumed.
|
|
99
|
+
if (receipt?.target) {
|
|
100
|
+
try {
|
|
101
|
+
const answer = await request("/v1/dispatch/workers", { targets: [{ ...object(receipt.target), dispatch: id }] });
|
|
102
|
+
worker = objects(answer.workers)[0];
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
workerError = error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (listError || peekError || workerError) {
|
|
109
|
+
if (failingSince === undefined)
|
|
110
|
+
failingSince = now();
|
|
111
|
+
else if (now() - failingSince >= unavailableLimit) {
|
|
112
|
+
final("failed", { error: `Phren Hook unavailable: ${reason(workerError ?? peekError ?? listError)}` });
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
failingSince = undefined;
|
|
118
|
+
if (!listError && !receipt && !returned && unknownSince !== undefined && now() - unknownSince >= grace) {
|
|
119
|
+
final("failed", { error: "unknown dispatch" });
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
const acknowledge = async () => {
|
|
123
|
+
const own = receipt?.returned ? object(receipt.returned) : undefined;
|
|
124
|
+
if (!peeked && own?.read !== false)
|
|
125
|
+
return;
|
|
126
|
+
await request("/v1/dispatch/returns/ack", { dispatch: id }).catch(() => undefined);
|
|
127
|
+
};
|
|
128
|
+
// A placement that failed before any worker existed has no return of its own.
|
|
129
|
+
if (!returned && receipt?.state === "failed") {
|
|
130
|
+
final("failed", { ...(typeof receipt.error === "string" ? { error: receipt.error } : {}) });
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
const state = typeof returned?.state === "string" ? returned.state : undefined;
|
|
134
|
+
if (state === "done") {
|
|
135
|
+
final("done", { ...(typeof returned.reply === "string" ? { final_reply: returned.reply } : {}), ...(returned.prs ? { prs: returned.prs } : {}) });
|
|
136
|
+
await acknowledge();
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
if (state === "failed") {
|
|
140
|
+
final("failed", { ...(typeof returned.error === "string" ? { error: returned.error } : {}) });
|
|
141
|
+
await acknowledge();
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
if (state === "gone") {
|
|
145
|
+
final("gone");
|
|
146
|
+
await acknowledge();
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
const workerState = typeof worker?.state === "string" ? worker.state : typeof object(receipt?.worker).state === "string" ? String(object(receipt?.worker).state) : undefined;
|
|
150
|
+
if (workerState === "working")
|
|
151
|
+
lastWorkingAt = now();
|
|
152
|
+
const returnedAt = Date.parse(String(returned?.at ?? ""));
|
|
153
|
+
// A needs-you return from before the worker was last seen working is historical.
|
|
154
|
+
const needsYou = (state === "needs-you" || state === "blocked")
|
|
155
|
+
&& (lastWorkingAt === undefined || !Number.isFinite(returnedAt) || returnedAt >= lastWorkingAt);
|
|
156
|
+
if (workerState === "working") {
|
|
157
|
+
emit("running");
|
|
158
|
+
}
|
|
159
|
+
else if (workerState === "gone" || workerState === "closed") {
|
|
160
|
+
final("gone");
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
else if (needsYou) {
|
|
164
|
+
const question = questionOf(returned);
|
|
165
|
+
emit("needs_you", question ? { question } : {});
|
|
166
|
+
}
|
|
167
|
+
else if (workerState === "needs-you" || workerState === "blocked") {
|
|
168
|
+
const question = questionOf(worker);
|
|
169
|
+
emit("needs_you", question ? { question } : {});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
emit("running");
|
|
173
|
+
}
|
|
174
|
+
attempt++;
|
|
175
|
+
await sleep(waitDelay(attempt, base, jitter));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type ConductorRecord } from "./conductor-role.js";
|
|
3
3
|
import { type DispatchHost } from "./dispatch-hosts.js";
|
|
4
|
-
import { type Json, type Provider, type Target } from "./protocol.js";
|
|
4
|
+
import { type Json, type Provider, type StartingTarget, type Target } from "./protocol.js";
|
|
5
5
|
import { type HarnessInventory } from "./harnesses.js";
|
|
6
6
|
import { type AccountRoom, type WindowRoom } from "./account-choice.js";
|
|
7
7
|
import { type PolicyRoom, type PoolRule } from "./account-policy.js";
|
|
8
8
|
import { type BriefArrival } from "./launch-brief.js";
|
|
9
|
+
import { type IdempotencyRecord } from "./dispatch-idempotency.js";
|
|
9
10
|
export declare const projectName: z.ZodString;
|
|
11
|
+
/** The longest worker brief a dispatch takes, in characters. */
|
|
12
|
+
export declare const DISPATCH_PROMPT_LIMIT = 32768;
|
|
10
13
|
/** The harnesses a dispatch, a code note's hand-off or a schedule can start. */
|
|
11
14
|
export declare const PEER_COPILOT_REASON = "Copilot cannot continue on another computer: its harness does not confirm launch-brief arrival. Continue locally or choose another harness.";
|
|
12
15
|
export declare const DISPATCH_HARNESSES: readonly ["codex", "claude", "opencode", "copilot"];
|
|
13
16
|
export declare const dispatchSchema: z.ZodObject<{
|
|
14
17
|
computer: z.ZodUnion<readonly [z.ZodLiteral<"anywhere">, z.ZodString]>;
|
|
18
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
storeId: z.ZodString;
|
|
20
|
+
project: z.ZodString;
|
|
21
|
+
stableId: z.ZodString;
|
|
22
|
+
}, z.core.$strict>>;
|
|
15
23
|
project: z.ZodString;
|
|
16
24
|
harness: z.ZodEnum<{
|
|
17
25
|
claude: "claude";
|
|
@@ -44,6 +52,9 @@ export declare const dispatchSchema: z.ZodObject<{
|
|
|
44
52
|
}>>>;
|
|
45
53
|
prompt: z.ZodString;
|
|
46
54
|
label: z.ZodString;
|
|
55
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
56
|
+
worktree: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
47
58
|
closeOnFinish: z.ZodOptional<z.ZodBoolean>;
|
|
48
59
|
integrator: z.ZodOptional<z.ZodObject<{
|
|
49
60
|
computer: z.ZodOptional<z.ZodString>;
|
|
@@ -121,6 +132,11 @@ export declare const workerStates: readonly ["working", "done", "needs-you", "fa
|
|
|
121
132
|
export type WorkerState = typeof workerStates[number];
|
|
122
133
|
declare const receiptSchema: z.ZodObject<{
|
|
123
134
|
computer: z.ZodUnion<readonly [z.ZodLiteral<"anywhere">, z.ZodString]>;
|
|
135
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
136
|
+
storeId: z.ZodString;
|
|
137
|
+
project: z.ZodString;
|
|
138
|
+
stableId: z.ZodString;
|
|
139
|
+
}, z.core.$strict>>;
|
|
124
140
|
project: z.ZodString;
|
|
125
141
|
harness: z.ZodEnum<{
|
|
126
142
|
claude: "claude";
|
|
@@ -152,6 +168,9 @@ declare const receiptSchema: z.ZodObject<{
|
|
|
152
168
|
publish: "publish";
|
|
153
169
|
}>>>;
|
|
154
170
|
label: z.ZodString;
|
|
171
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
172
|
+
worktree: z.ZodOptional<z.ZodBoolean>;
|
|
173
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
155
174
|
closeOnFinish: z.ZodOptional<z.ZodBoolean>;
|
|
156
175
|
integrator: z.ZodOptional<z.ZodObject<{
|
|
157
176
|
computer: z.ZodOptional<z.ZodString>;
|
|
@@ -306,10 +325,26 @@ declare const receiptSchema: z.ZodObject<{
|
|
|
306
325
|
terminal: z.ZodString;
|
|
307
326
|
}, z.core.$strict>>;
|
|
308
327
|
closedAt: z.ZodOptional<z.ZodString>;
|
|
328
|
+
cancelRequestedAt: z.ZodOptional<z.ZodString>;
|
|
309
329
|
closePending: z.ZodOptional<z.ZodObject<{
|
|
310
330
|
at: z.ZodString;
|
|
311
331
|
turn: z.ZodOptional<z.ZodString>;
|
|
312
332
|
}, z.core.$strict>>;
|
|
333
|
+
agentTokenFile: z.ZodOptional<z.ZodString>;
|
|
334
|
+
cloneDir: z.ZodOptional<z.ZodString>;
|
|
335
|
+
gitConfigFile: z.ZodOptional<z.ZodString>;
|
|
336
|
+
workerFile: z.ZodOptional<z.ZodString>;
|
|
337
|
+
retainedUntil: z.ZodOptional<z.ZodString>;
|
|
338
|
+
endedAt: z.ZodOptional<z.ZodString>;
|
|
339
|
+
launchOutcome: z.ZodOptional<z.ZodEnum<{
|
|
340
|
+
ambiguous: "ambiguous";
|
|
341
|
+
"not-started": "not-started";
|
|
342
|
+
started: "started";
|
|
343
|
+
}>>;
|
|
344
|
+
startingToken: z.ZodOptional<z.ZodString>;
|
|
345
|
+
launchServer: z.ZodOptional<z.ZodString>;
|
|
346
|
+
scanSince: z.ZodOptional<z.ZodString>;
|
|
347
|
+
submittedAt: z.ZodOptional<z.ZodString>;
|
|
313
348
|
worker: z.ZodOptional<z.ZodObject<{
|
|
314
349
|
state: z.ZodEnum<{
|
|
315
350
|
blocked: "blocked";
|
|
@@ -427,13 +462,45 @@ export declare function dispatchProjectDirectory(project: unknown, home?: string
|
|
|
427
462
|
* when `change` returns true. Updates run one at a time in this process, and a
|
|
428
463
|
* receipt still being placed (launching or sending) is never touched.
|
|
429
464
|
*/
|
|
430
|
-
export declare function updateReceipt(receiptID: string, change: (receipt: Receipt) => boolean
|
|
465
|
+
export declare function updateReceipt(receiptID: string, change: (receipt: Receipt) => boolean, options?: {
|
|
466
|
+
duringPlacement?: boolean;
|
|
467
|
+
}): Promise<Receipt | undefined>;
|
|
431
468
|
/** Hand over all open worker routes using the receipt writer's own lock and
|
|
432
469
|
* update path. Commit the role last; any failure restores the old origins.
|
|
433
470
|
* Placing receipts are refused because placement can still overwrite them. */
|
|
434
471
|
export declare function repointDispatchOrigins(from: Pick<ConductorRecord, "server" | "pane" | "terminal">, to: NonNullable<Receipt["origin"]>, commit: () => Promise<void>): Promise<void>;
|
|
435
472
|
/** One bounded line for a log or a receipt: a Bridge message, an errno code, or the error's first line. */
|
|
436
473
|
export declare function failureReason(error: unknown): string;
|
|
474
|
+
/** A fresh terminal snapshot proves the bound worker gone; a failed snapshot does not. */
|
|
475
|
+
export declare function boundWorkerGone(receipt: Receipt): Promise<boolean>;
|
|
476
|
+
/** A worker that may still run has no termination time; drop any stale retention clock. */
|
|
477
|
+
export declare function clearWorkerEnded(id: string): Promise<void>;
|
|
478
|
+
export type StartingScan = {
|
|
479
|
+
ok: true;
|
|
480
|
+
pane?: Json;
|
|
481
|
+
} | {
|
|
482
|
+
ok: false;
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* A successful terminal snapshot on the launch's server, and the pane carrying
|
|
486
|
+
* this launch's starting token. `ok: false` means the snapshot or an identity
|
|
487
|
+
* read failed, so no conclusion can be drawn.
|
|
488
|
+
*/
|
|
489
|
+
export declare function scanStartingToken(receipt: Receipt): Promise<StartingScan>;
|
|
490
|
+
/** The exact binding for a pane that carries the launch's starting token. */
|
|
491
|
+
export declare function startingTargetFromPane(receipt: Receipt, pane: Json): Target | StartingTarget | undefined;
|
|
492
|
+
/** A key cancelled before its receipt existed: settle it as failed/cancelled without launching. */
|
|
493
|
+
export declare function settleCancelledReservation(record: IdempotencyRecord): Promise<Receipt>;
|
|
494
|
+
/**
|
|
495
|
+
* A reservation stuck in `reserved` or `launching` for five minutes with no
|
|
496
|
+
* target and no live worker is an interrupted launch. It becomes a failed
|
|
497
|
+
* receipt with "launch interrupted"; nothing is relaunched automatically.
|
|
498
|
+
*/
|
|
499
|
+
export declare function reconcileIdempotencyRecord(record: IdempotencyRecord): Promise<void>;
|
|
500
|
+
/** Reconcile every live reservation; called on Hook start. */
|
|
501
|
+
export declare function reconcileInterruptedDispatches(): Promise<void>;
|
|
502
|
+
/** The durable record for a key after reconciliation, for cancel-by-key and dispatch retries. */
|
|
503
|
+
export declare function reconcileIdempotencyKey(key: string): Promise<IdempotencyRecord | undefined>;
|
|
437
504
|
export declare function dispatchStatus(): Promise<Receipt[]>;
|
|
438
505
|
/** `caller` (a conductor's name and host key) asks a peer whether it links this computer back:
|
|
439
506
|
* `outside` is a peer in another set, which a conductor does not dispatch to. */
|
|
@@ -505,6 +572,15 @@ export declare class DispatchService {
|
|
|
505
572
|
* Herdr variables name it; a pane without a running agent is left out.
|
|
506
573
|
* `continues` names the dispatch whose worker hit its usage limit (account-failover.ts). */
|
|
507
574
|
dispatch(input: unknown, originValue?: unknown, continues?: string): Promise<Json>;
|
|
575
|
+
/**
|
|
576
|
+
* The gitboy path: a caller that may retry after a crash names a key and
|
|
577
|
+
* gets the dispatch that key already started. The dispatch id is generated
|
|
578
|
+
* before the reservation, and the reservation is published atomically, so
|
|
579
|
+
* two concurrent calls start one agent; the loser returns the winner's
|
|
580
|
+
* receipt.
|
|
581
|
+
*/
|
|
582
|
+
private dispatchKeyed;
|
|
583
|
+
private place;
|
|
508
584
|
/** Owner continuation: use the same pinned transport and launch/arrival
|
|
509
585
|
* protocol as dispatch, without turning the new chat into a worker. */
|
|
510
586
|
continueChat(peer: DispatchHost, project: string, to: z.infer<typeof moveToSchema>, brief: {
|