@phren/cli 0.3.72 → 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 +1 -1
- package/dist/bridge/browser-env.js +34 -10
- 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 +68 -2
- package/dist/bridge/dispatch.js +839 -25
- 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 +29 -3
- package/dist/bridge/install.d.ts +1 -1
- package/dist/bridge/install.js +8 -4
- package/dist/bridge/launch-worktree.d.ts +2 -0
- package/dist/bridge/launch-worktree.js +5 -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.js +18 -2
- package/dist/bridge/server.js +12 -1
- package/dist/bridge/status-line-fast.d.ts +9 -0
- package/dist/bridge/status-line-fast.js +56 -0
- package/dist/bridge/terminal-herdr.d.ts +5 -1
- package/dist/bridge/terminal-herdr.js +65 -1
- package/dist/bridge/terminal-tmux.d.ts +2 -0
- package/dist/bridge/terminal-tmux.js +27 -6
- 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-hook.mjs +20857 -18606
- package/dist/cli/browser-hint.d.ts +2 -0
- package/dist/cli/browser-hint.js +21 -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-registry.js +5 -3
- package/dist/modules/registry.js +1 -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,12 +1,15 @@
|
|
|
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"];
|
|
@@ -49,6 +52,9 @@ export declare const dispatchSchema: z.ZodObject<{
|
|
|
49
52
|
}>>>;
|
|
50
53
|
prompt: z.ZodString;
|
|
51
54
|
label: z.ZodString;
|
|
55
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
56
|
+
worktree: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
52
58
|
closeOnFinish: z.ZodOptional<z.ZodBoolean>;
|
|
53
59
|
integrator: z.ZodOptional<z.ZodObject<{
|
|
54
60
|
computer: z.ZodOptional<z.ZodString>;
|
|
@@ -162,6 +168,9 @@ declare const receiptSchema: z.ZodObject<{
|
|
|
162
168
|
publish: "publish";
|
|
163
169
|
}>>>;
|
|
164
170
|
label: z.ZodString;
|
|
171
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
172
|
+
worktree: z.ZodOptional<z.ZodBoolean>;
|
|
173
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
165
174
|
closeOnFinish: z.ZodOptional<z.ZodBoolean>;
|
|
166
175
|
integrator: z.ZodOptional<z.ZodObject<{
|
|
167
176
|
computer: z.ZodOptional<z.ZodString>;
|
|
@@ -316,10 +325,26 @@ declare const receiptSchema: z.ZodObject<{
|
|
|
316
325
|
terminal: z.ZodString;
|
|
317
326
|
}, z.core.$strict>>;
|
|
318
327
|
closedAt: z.ZodOptional<z.ZodString>;
|
|
328
|
+
cancelRequestedAt: z.ZodOptional<z.ZodString>;
|
|
319
329
|
closePending: z.ZodOptional<z.ZodObject<{
|
|
320
330
|
at: z.ZodString;
|
|
321
331
|
turn: z.ZodOptional<z.ZodString>;
|
|
322
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>;
|
|
323
348
|
worker: z.ZodOptional<z.ZodObject<{
|
|
324
349
|
state: z.ZodEnum<{
|
|
325
350
|
blocked: "blocked";
|
|
@@ -437,13 +462,45 @@ export declare function dispatchProjectDirectory(project: unknown, home?: string
|
|
|
437
462
|
* when `change` returns true. Updates run one at a time in this process, and a
|
|
438
463
|
* receipt still being placed (launching or sending) is never touched.
|
|
439
464
|
*/
|
|
440
|
-
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>;
|
|
441
468
|
/** Hand over all open worker routes using the receipt writer's own lock and
|
|
442
469
|
* update path. Commit the role last; any failure restores the old origins.
|
|
443
470
|
* Placing receipts are refused because placement can still overwrite them. */
|
|
444
471
|
export declare function repointDispatchOrigins(from: Pick<ConductorRecord, "server" | "pane" | "terminal">, to: NonNullable<Receipt["origin"]>, commit: () => Promise<void>): Promise<void>;
|
|
445
472
|
/** One bounded line for a log or a receipt: a Bridge message, an errno code, or the error's first line. */
|
|
446
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>;
|
|
447
504
|
export declare function dispatchStatus(): Promise<Receipt[]>;
|
|
448
505
|
/** `caller` (a conductor's name and host key) asks a peer whether it links this computer back:
|
|
449
506
|
* `outside` is a peer in another set, which a conductor does not dispatch to. */
|
|
@@ -515,6 +572,15 @@ export declare class DispatchService {
|
|
|
515
572
|
* Herdr variables name it; a pane without a running agent is left out.
|
|
516
573
|
* `continues` names the dispatch whose worker hit its usage limit (account-failover.ts). */
|
|
517
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;
|
|
518
584
|
/** Owner continuation: use the same pinned transport and launch/arrival
|
|
519
585
|
* protocol as dispatch, without turning the new chat into a worker. */
|
|
520
586
|
continueChat(peer: DispatchHost, project: string, to: z.infer<typeof moveToSchema>, brief: {
|