@phren/cli 0.3.59 → 0.3.61
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/account-usage.d.ts +11 -4
- package/dist/bridge/account-usage.js +60 -7
- package/dist/bridge/claude-credits.d.ts +3 -1
- package/dist/bridge/claude-credits.js +15 -2
- package/dist/bridge/codex-threads.js +50 -2
- package/dist/bridge/continuation-launch.d.ts +32 -0
- package/dist/bridge/continuation-launch.js +112 -1
- package/dist/bridge/git-hosts.d.ts +8 -0
- package/dist/bridge/git-hosts.js +16 -2
- package/dist/bridge/git-publish.js +18 -2
- package/dist/bridge/git.d.ts +8 -0
- package/dist/bridge/git.js +24 -1
- package/dist/bridge/owner-inbox-sources.d.ts +12 -1
- package/dist/bridge/owner-inbox-sources.js +127 -49
- package/dist/bridge/peers.d.ts +2 -0
- package/dist/bridge/peers.js +35 -4
- package/dist/bridge/prompt-deliveries.d.ts +43 -4
- package/dist/bridge/prompt-deliveries.js +213 -35
- package/dist/bridge/server-routes.d.ts +3 -0
- package/dist/bridge/server-routes.js +33 -9
- package/dist/bridge/server-stream.js +6 -4
- package/dist/bridge/session-move.d.ts +11 -0
- package/dist/bridge/session-move.js +49 -5
- package/dist/bridge/usage.d.ts +17 -0
- package/dist/bridge/usage.js +3 -2
- package/dist/bridge-hook.mjs +745 -298
- package/dist/modules/registry.js +3 -3
- package/dist/tools/dispatch.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { AgentHooks } from "./agent-hooks.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Receipt } from "./dispatch.js";
|
|
3
|
+
import { type InboxSnapshot, type InboxSource } from "./owner-inbox.js";
|
|
3
4
|
/** Read the actual panes and pending asks, never a stored inbox's live flag.
|
|
4
5
|
* Called on reads and on the Hook's five-second activity tick. */
|
|
5
6
|
export declare function ownerInboxSources(hooks: AgentHooks): Promise<InboxSnapshot>;
|
|
7
|
+
/** How often the inbox asks another computer about its receipts past the returns loop's watch, failed or not. */
|
|
8
|
+
export declare const AGED_CHECK_MS: number;
|
|
9
|
+
/** Forgets the hourly answers (tests). */
|
|
10
|
+
export declare function resetAgedChecks(): void;
|
|
11
|
+
/**
|
|
12
|
+
* A dispatch on another computer, within the returns loop's watch, as that loop last saw it, with no SSH of its
|
|
13
|
+
* own: waiting on an approval it forwarded (blocked, answerable by its `actionId`), blocked, or stopped with a
|
|
14
|
+
* question for the owner. A worker the loop saw back at work, or gone, has no row.
|
|
15
|
+
*/
|
|
16
|
+
export declare function remoteSource(receipt: Receipt): InboxSource | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dispatchStatus } from "./dispatch.js";
|
|
1
|
+
import { dispatchStatus, updateReceipt } from "./dispatch.js";
|
|
2
2
|
import { isLocalComputer } from "./dispatch-hosts.js";
|
|
3
|
-
import { workerReaders, workerStates } from "./dispatch-returns.js";
|
|
3
|
+
import { WATCH_MS, workerReaders, workerStates } from "./dispatch-returns.js";
|
|
4
4
|
import { paneChatState, recentServers, snapshot } from "./herdr.js";
|
|
5
5
|
import { inboxTargetSchema } from "./owner-inbox.js";
|
|
6
6
|
import { hookPeers, peerRequest } from "./peers.js";
|
|
@@ -38,57 +38,135 @@ export async function ownerInboxSources(hooks) {
|
|
|
38
38
|
...(actionId ? { actionId } : {}) });
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
// A saved return/approval is only a candidate
|
|
42
|
-
//
|
|
43
|
-
|
|
41
|
+
// A saved return/approval is only a candidate. A worker on this computer is re-observed here, without SSH, so a
|
|
42
|
+
// closed pane never stays live because its last return waits. This runs on every five-second tick, and an SSH
|
|
43
|
+
// login per tick per computer (forever, for receipts the returns loop stopped watching) crowded a peer's sshd, so
|
|
44
|
+
// a worker on another computer is asked about at most once an hour, and only past the returns loop's watch:
|
|
45
|
+
// within it, its row comes from what that loop last observed and stored on the receipt (`remoteSource`),
|
|
46
|
+
// refreshed every POLL_MS.
|
|
47
|
+
const candidates = (await dispatchStatus()).filter(receipt => !receipt.closedAt && receipt.target && receipt.worker?.state !== "gone"
|
|
44
48
|
&& receipt.returned && ["needs-you", "blocked"].includes(receipt.returned.state));
|
|
45
|
-
const
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
const local = [], aged = new Map();
|
|
46
51
|
for (const receipt of candidates) {
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
if (isLocalComputer(receipt.computer)) {
|
|
53
|
+
local.push(receipt);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (now - Date.parse(receipt.createdAt) >= WATCH_MS) {
|
|
57
|
+
aged.set(receipt.computer, [...aged.get(receipt.computer) ?? [], receipt]);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const source = remoteSource(receipt);
|
|
61
|
+
if (source)
|
|
62
|
+
sources.push(source);
|
|
49
63
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
const answered = async (receipt, seen, computer) => {
|
|
65
|
+
if (!seen || ["unavailable", "unknown"].includes(String(seen.state))) {
|
|
66
|
+
unavailableDispatches.push(receipt.id);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (["gone", "closed"].includes(String(seen.state))) {
|
|
70
|
+
// A closed worker, or one gone after the returns loop stopped watching it, is closed on its receipt so it
|
|
71
|
+
// stops being a candidate at all, unless its return is still unread: then a conductor taking over is still
|
|
72
|
+
// handed it (conductor-succession.ts skips closed receipts).
|
|
73
|
+
if (seen.state === "closed" || (now - Date.parse(receipt.createdAt) >= WATCH_MS && receipt.returned?.read !== false))
|
|
74
|
+
await closeReceipt(receipt.id, now);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const source = liveSource(receipt, seen, computer);
|
|
78
|
+
if (!source)
|
|
79
|
+
return;
|
|
80
|
+
// The local prompt and dispatch return describe the same wait. Keep
|
|
81
|
+
// the dispatch's project/receipt metadata as well as its live target.
|
|
82
|
+
const prompt = computer ? -1 : sources.findIndex(row => JSON.stringify(row.target) === JSON.stringify(source.target) && !row.computer);
|
|
83
|
+
if (prompt >= 0)
|
|
84
|
+
sources.splice(prompt, 1);
|
|
85
|
+
sources.push(source);
|
|
86
|
+
};
|
|
87
|
+
for (let offset = 0; offset < local.length; offset += 64) {
|
|
88
|
+
const batch = local.slice(offset, offset + 64);
|
|
89
|
+
const input = { targets: batch.map(receipt => ({ ...receipt.target, dispatch: receipt.id })) };
|
|
90
|
+
let workers;
|
|
91
|
+
try {
|
|
92
|
+
workers = objects((await workerStates(input, { ...workerReaders(target => hooks.workerApproval(target)), snapshot })).workers);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
workers = [];
|
|
96
|
+
}
|
|
97
|
+
for (const [index, receipt] of batch.entries())
|
|
98
|
+
await answered(receipt, workers[index]);
|
|
99
|
+
}
|
|
100
|
+
if (aged.size) {
|
|
101
|
+
const peers = await hookPeers().catch(() => []);
|
|
102
|
+
for (const [computer, receipts] of aged) {
|
|
103
|
+
const seen = await agedStates(computer, receipts, peers.find(peer => peer.name === computer), now);
|
|
104
|
+
for (const receipt of receipts)
|
|
105
|
+
await answered(receipt, seen?.get(receipt.id), computer);
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
return { sources, unavailableDispatches };
|
|
94
109
|
}
|
|
110
|
+
/** A live worker observation as an inbox row: an approval it waits on, blocked, or stopped with a question. */
|
|
111
|
+
function liveSource(receipt, seen, computer) {
|
|
112
|
+
const approval = object(seen.approval);
|
|
113
|
+
const actionId = typeof approval.actionId === "string" ? approval.actionId : undefined;
|
|
114
|
+
const question = ["idle", "done"].includes(String(seen.state)) && seen.completed && !seen.error && !seen.interrupted
|
|
115
|
+
? (typeof seen.reply === "string" ? ownerQuestion(seen.reply) : undefined) ?? seen.unfinished : undefined;
|
|
116
|
+
if (!actionId && seen.state !== "blocked" && !question)
|
|
117
|
+
return undefined;
|
|
118
|
+
return { source: `dispatch:${receipt.id}:${actionId ?? "waiting"}`, kind: actionId || seen.state === "blocked" ? "blocked" : "needs-you",
|
|
119
|
+
title: clean(approval.request ?? question ?? `${receipt.label} needs input`),
|
|
120
|
+
project: receipt.project, ...(computer ? { computer } : {}), target: receipt.target, dispatch: receipt.id,
|
|
121
|
+
...(actionId ? { actionId } : {}) };
|
|
122
|
+
}
|
|
123
|
+
/** How often the inbox asks another computer about its receipts past the returns loop's watch, failed or not. */
|
|
124
|
+
export const AGED_CHECK_MS = 60 * 60 * 1000;
|
|
125
|
+
const agedChecks = new Map();
|
|
126
|
+
/** Forgets the hourly answers (tests). */
|
|
127
|
+
export function resetAgedChecks() { agedChecks.clear(); }
|
|
128
|
+
/**
|
|
129
|
+
* What another computer says of receipts the returns loop no longer watches: asked once per `AGED_CHECK_MS` per
|
|
130
|
+
* computer (one request, at most 64 receipts), the answer kept until the next, and a failure waited out as long.
|
|
131
|
+
* A receipt that aged into the set since keeps no answer until then: hidden, not resolved, and no SSH.
|
|
132
|
+
*/
|
|
133
|
+
async function agedStates(computer, receipts, peer, now) {
|
|
134
|
+
const hit = agedChecks.get(computer);
|
|
135
|
+
if (hit && now - hit.at < AGED_CHECK_MS)
|
|
136
|
+
return hit.seen;
|
|
137
|
+
const entry = { at: now };
|
|
138
|
+
agedChecks.set(computer, entry);
|
|
139
|
+
if (!peer)
|
|
140
|
+
return undefined;
|
|
141
|
+
const batch = receipts.slice(0, 64);
|
|
142
|
+
try {
|
|
143
|
+
const workers = objects((await peerRequest(peer, "/v1/dispatch/workers", { targets: batch.map(receipt => ({ ...receipt.target, dispatch: receipt.id })) })).workers);
|
|
144
|
+
entry.seen = new Map(batch.flatMap((receipt, index) => workers[index] ? [[receipt.id, workers[index]]] : []));
|
|
145
|
+
}
|
|
146
|
+
catch { /* waited out until the next check */ }
|
|
147
|
+
return entry.seen;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A dispatch on another computer, within the returns loop's watch, as that loop last saw it, with no SSH of its
|
|
151
|
+
* own: waiting on an approval it forwarded (blocked, answerable by its `actionId`), blocked, or stopped with a
|
|
152
|
+
* question for the owner. A worker the loop saw back at work, or gone, has no row.
|
|
153
|
+
*/
|
|
154
|
+
export function remoteSource(receipt) {
|
|
155
|
+
const approval = receipt.approval, state = receipt.worker?.state ?? receipt.returned?.state;
|
|
156
|
+
if (!approval && state !== "blocked" && state !== "needs-you")
|
|
157
|
+
return undefined;
|
|
158
|
+
const actionId = approval?.actionId;
|
|
159
|
+
return { source: `dispatch:${receipt.id}:${actionId ?? "waiting"}`, kind: actionId || state === "blocked" ? "blocked" : "needs-you",
|
|
160
|
+
title: clean(approval?.request ?? approval?.title ?? receipt.returned?.question ?? `${receipt.label} needs input`),
|
|
161
|
+
project: receipt.project, computer: receipt.computer, target: receipt.target, dispatch: receipt.id,
|
|
162
|
+
...(actionId ? { actionId } : {}) };
|
|
163
|
+
}
|
|
164
|
+
/** Records a receipt closed, under the receipt lock, unless something closed it first. */
|
|
165
|
+
async function closeReceipt(id, now) {
|
|
166
|
+
await updateReceipt(id, current => {
|
|
167
|
+
if (current.closedAt)
|
|
168
|
+
return false;
|
|
169
|
+
current.closedAt = new Date(now).toISOString();
|
|
170
|
+
return true;
|
|
171
|
+
}).catch(() => undefined);
|
|
172
|
+
}
|
package/dist/bridge/peers.d.ts
CHANGED
|
@@ -33,4 +33,6 @@ export declare function peerSSHArgs(peer: HookPeer, knownHosts: string, key: str
|
|
|
33
33
|
export declare function peerOfflineMessage(diagnostic: string, exitCode: number | null | undefined): string;
|
|
34
34
|
/** A pin is supplied out of band; dispatch never learns or replaces host keys. */
|
|
35
35
|
export declare function peerRequest(peer: HookPeer, route: string, data?: Json, timeout?: number): Promise<Json>;
|
|
36
|
+
/** Removes `peer-*` known_hosts folders a stopped Hook left behind: no request runs anywhere near this long. */
|
|
37
|
+
export declare function sweepPeerTemps(root?: string, now?: number, maxAgeMs?: number): Promise<number>;
|
|
36
38
|
export {};
|
package/dist/bridge/peers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { lstat, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { lstat, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Duplex } from "node:stream";
|
|
5
5
|
import { dump, load } from "js-yaml";
|
|
@@ -144,6 +144,7 @@ export async function peerRequest(peer, route, data, timeout) {
|
|
|
144
144
|
const info = await lstat(key).catch(() => undefined);
|
|
145
145
|
if (!info?.isFile() || info.isSymbolicLink() || (info.mode & 0o077))
|
|
146
146
|
throw new BridgeError(409, "Run phren bridge enroll-computer on this computer first (private key mode 0600).", { code: "dispatch-key-missing" });
|
|
147
|
+
sweepPeerTempsSometimes(root);
|
|
147
148
|
const temporary = await mkdtemp(path.join(root, "peer-"));
|
|
148
149
|
let child, stream;
|
|
149
150
|
try {
|
|
@@ -187,8 +188,38 @@ export async function peerRequest(peer, route, data, timeout) {
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
finally {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
// The pinned known_hosts folder goes on every exit (an answer, a timeout, an SSH that could not start), even
|
|
192
|
+
// when stopping the stream or the process throws.
|
|
193
|
+
try {
|
|
194
|
+
stream?.destroy();
|
|
195
|
+
child?.kill();
|
|
196
|
+
}
|
|
197
|
+
catch { /* already gone */ }
|
|
198
|
+
await rm(temporary, { recursive: true, force: true }).catch(() => undefined);
|
|
193
199
|
}
|
|
194
200
|
}
|
|
201
|
+
/** How old a request's known_hosts folder must be to count as left behind (by a Hook stopped mid-request). */
|
|
202
|
+
const PEER_TEMP_MAX_AGE_MS = 10 * 60_000;
|
|
203
|
+
let lastSweep = 0;
|
|
204
|
+
/** Removes `peer-*` known_hosts folders a stopped Hook left behind: no request runs anywhere near this long. */
|
|
205
|
+
export async function sweepPeerTemps(root = bridgeRoot(), now = Date.now(), maxAgeMs = PEER_TEMP_MAX_AGE_MS) {
|
|
206
|
+
let removed = 0;
|
|
207
|
+
for (const name of await readdir(root).catch(() => [])) {
|
|
208
|
+
if (!/^peer-[A-Za-z0-9]{6}$/.test(name))
|
|
209
|
+
continue;
|
|
210
|
+
const folder = path.join(root, name);
|
|
211
|
+
const info = await lstat(folder).catch(() => undefined);
|
|
212
|
+
if (!info?.isDirectory() || now - info.mtimeMs < maxAgeMs)
|
|
213
|
+
continue;
|
|
214
|
+
await rm(folder, { recursive: true, force: true }).then(() => { removed++; }, () => undefined);
|
|
215
|
+
}
|
|
216
|
+
return removed;
|
|
217
|
+
}
|
|
218
|
+
/** At most one sweep per `PEER_TEMP_MAX_AGE_MS`, in the background of a request. */
|
|
219
|
+
function sweepPeerTempsSometimes(root) {
|
|
220
|
+
const now = Date.now();
|
|
221
|
+
if (now - lastSweep < PEER_TEMP_MAX_AGE_MS)
|
|
222
|
+
return;
|
|
223
|
+
lastSweep = now;
|
|
224
|
+
void sweepPeerTemps(root, now).catch(() => undefined);
|
|
225
|
+
}
|
|
@@ -7,16 +7,28 @@ export type DeliveryOutcome = "delivered" | "pending";
|
|
|
7
7
|
* and may still turn `delivered` if the agent takes it late. */
|
|
8
8
|
export type DeliveryState = "queued" | "delivered" | "failed";
|
|
9
9
|
/** A transcript row carrying a message's words: its byte offset, and whether the agent fires UserPromptSubmit for it (a user row does; a mid-turn queue removal does not). */
|
|
10
|
+
/** A transcript row with a message's words: its byte offset, whether it is a user row, when it was stamped, and
|
|
11
|
+
* the row's own id where the harness writes one (Claude's `uuid`). */
|
|
10
12
|
export interface TranscriptEntry {
|
|
11
13
|
offset: number;
|
|
12
14
|
hook: boolean;
|
|
13
15
|
at?: number;
|
|
16
|
+
uuid?: string;
|
|
17
|
+
/** The row the conversation stream shows for this one, when that is another (a Codex rollout's user item). */
|
|
18
|
+
shown?: number;
|
|
14
19
|
}
|
|
15
20
|
export type TrackedState = DeliveryState | "unknown";
|
|
21
|
+
/** The transcript row a delivered message landed as: the line the conversation stream numbers it by (`Entry.line`,
|
|
22
|
+
* 0-based) and, for Claude, the row's `uuid`. A phone matches its pending send to that row, not to its text. */
|
|
23
|
+
export interface LandedRow {
|
|
24
|
+
line: number;
|
|
25
|
+
uuid?: string;
|
|
26
|
+
}
|
|
16
27
|
export interface DeliveryStatus {
|
|
17
28
|
state: TrackedState;
|
|
18
29
|
reason?: string;
|
|
19
30
|
session?: string;
|
|
31
|
+
landed?: LandedRow;
|
|
20
32
|
}
|
|
21
33
|
/** A message is kept this long, by its id, so a late status or a retry still
|
|
22
34
|
* finds it: a busy Codex turn can run far past the old ten minutes. */
|
|
@@ -59,6 +71,9 @@ export declare class PromptDeliveries {
|
|
|
59
71
|
private cursors;
|
|
60
72
|
/** The size of a conversation's transcript: 0 before it has one, undefined when it cannot be read. */
|
|
61
73
|
private size;
|
|
74
|
+
/** The line (0-based) of the row at a byte offset in a conversation's transcript, when one still starts there
|
|
75
|
+
* (and carries `uuid`, when given). */
|
|
76
|
+
private lineOf;
|
|
62
77
|
constructor(file?: string | undefined, now?: () => number, landed?: (record: {
|
|
63
78
|
source: Provider;
|
|
64
79
|
session: string;
|
|
@@ -67,7 +82,10 @@ export declare class PromptDeliveries {
|
|
|
67
82
|
}) => Promise<TranscriptEntry[]>, size?: (record: {
|
|
68
83
|
source: Provider;
|
|
69
84
|
session: string;
|
|
70
|
-
}) => Promise<number | undefined
|
|
85
|
+
}) => Promise<number | undefined>, lineOf?: (record: {
|
|
86
|
+
source: Provider;
|
|
87
|
+
session: string;
|
|
88
|
+
}, offset: number, uuid?: string) => Promise<number | undefined>);
|
|
71
89
|
private samePane;
|
|
72
90
|
private byId;
|
|
73
91
|
private prune;
|
|
@@ -130,7 +148,15 @@ export declare class PromptDeliveries {
|
|
|
130
148
|
* (typed or queued) are matched: a failed one could take the lines of messages that are held, and a late
|
|
131
149
|
* take of a failed message stays its own hook's to report. */
|
|
132
150
|
private settleJoined;
|
|
133
|
-
/**
|
|
151
|
+
/** `record` takes transcript row `row` as its own: the entry no other message with these words may take, and,
|
|
152
|
+
* for a phone message, the row its receipt names (`landed`), whose line is counted in the background. */
|
|
153
|
+
private claim;
|
|
154
|
+
/** Phone messages whose row's line is being counted. */
|
|
155
|
+
private locating;
|
|
156
|
+
/** Counts the line of the row the stream shows for a phone message's claimed entry, once, and keeps it.
|
|
157
|
+
* In the background: a long transcript is read from its start. */
|
|
158
|
+
private locate;
|
|
159
|
+
/** Marks `record` delivered, in `session` when given. */
|
|
134
160
|
private settle;
|
|
135
161
|
/** Whether the transcript shows the agent took `record`'s message, claiming the entry it settled with.
|
|
136
162
|
* An entry settles one message: the table of records' `entry` offsets (per conversation) is the only
|
|
@@ -142,14 +168,21 @@ export declare class PromptDeliveries {
|
|
|
142
168
|
private taken;
|
|
143
169
|
/** Whether a Codex transcript row can be `record`'s own: written after it was registered. A row at or past
|
|
144
170
|
* its cursor was; one before it only if stamped after registration (written while the cursor was read),
|
|
145
|
-
* which a row without a timestamp
|
|
146
|
-
*
|
|
171
|
+
* which a row without a timestamp never is. A materialized Codex 0.155 thread's copy is append-only, so a row
|
|
172
|
+
* past the cursor was copied after registration, but not necessarily created after it: an older item the copy
|
|
173
|
+
* had not reached yet lands there too. Its rows are stamped with when the item was created (codex-threads.ts),
|
|
174
|
+
* and the scan drops any row stamped more than `ENTRY_SLACK_MS` before registration, which is what keeps an
|
|
175
|
+
* earlier identical message from being taken for this one. */
|
|
147
176
|
private static codexRowIsOwn;
|
|
148
177
|
/** Rows of `record`'s words in its conversation, oldest first, and where the scan of them began: rows
|
|
149
178
|
* before `start` are out of sight, so whether they exist cannot be told. */
|
|
150
179
|
private codexRows;
|
|
151
180
|
/** Rows with `record`'s words in its conversation claimed by other messages. */
|
|
152
181
|
private codexClaimed;
|
|
182
|
+
/** A Claude phone message its hook settled before its row was written takes the row once it appears: the first
|
|
183
|
+
* unclaimed user row with its words stamped from when it was typed to `HOOK_ROW_MS` after its hook, the rule
|
|
184
|
+
* `taken` applies to hook-settled messages. Only the receipt's `landed` depends on it. */
|
|
185
|
+
private claimClaudeRow;
|
|
153
186
|
/** A Codex message its hook settled takes the first free row written after it was registered. */
|
|
154
187
|
private claimCodexRow;
|
|
155
188
|
/** Whether Codex took `record`'s message: a row written after it was registered (`codexRowIsOwn`) that no
|
|
@@ -178,6 +211,12 @@ export declare function transcriptSize(record: {
|
|
|
178
211
|
source: Provider;
|
|
179
212
|
session: string;
|
|
180
213
|
}): Promise<number | undefined>;
|
|
214
|
+
/** The 0-based line of the row starting at byte `offset`: the newlines before it, as the transcript index counts
|
|
215
|
+
* rows (transcript-index.ts), so it is the `line` the conversation stream gives that row. */
|
|
216
|
+
export declare function transcriptLine(record: {
|
|
217
|
+
source: Provider;
|
|
218
|
+
session: string;
|
|
219
|
+
}, offset: number, uuid?: string): Promise<number | undefined>;
|
|
181
220
|
/** A transcript row's user-typed text: Claude's user rows, Codex's
|
|
182
221
|
* user_message events and user response items. */
|
|
183
222
|
export declare function userTexts(row: Json): string[];
|