@peer2peer/codex-bridge 0.0.0-stage → 0.1.1
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/LICENSE +201 -0
- package/README.md +216 -2
- package/dist/bridge.d.ts +423 -0
- package/dist/bridge.js +1218 -0
- package/dist/commands.d.ts +47 -0
- package/dist/commands.js +141 -0
- package/dist/confirm.d.ts +68 -0
- package/dist/confirm.js +248 -0
- package/dist/hook.d.ts +33 -0
- package/dist/hook.js +242 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +18 -0
- package/dist/install.d.ts +76 -0
- package/dist/install.js +264 -0
- package/dist/ipc.d.ts +69 -0
- package/dist/ipc.js +302 -0
- package/dist/knobs.d.ts +266 -0
- package/dist/knobs.js +1020 -0
- package/dist/lib.d.ts +438 -0
- package/dist/lib.js +1690 -0
- package/dist/mcp.d.ts +66 -0
- package/dist/mcp.js +181 -0
- package/dist/p2p.d.ts +176 -0
- package/dist/p2p.js +149 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.js +278 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.js +277 -0
- package/dist/trusted.d.ts +59 -0
- package/dist/trusted.js +217 -0
- package/package.json +48 -4
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { type AutoDeliver, type CodexMode, type ModeClass, type PeerRow } from "./lib.js";
|
|
2
|
+
import type { P2P, Whoami } from "./p2p.js";
|
|
3
|
+
import type { TranscriptSource } from "./trusted.js";
|
|
4
|
+
export declare const STATUS_EVERY_MS = 60000;
|
|
5
|
+
export declare const PEERS_EVERY_MS = 60000;
|
|
6
|
+
export declare const SOCIAL_EVERY_MS: number;
|
|
7
|
+
export declare const HOLD_EXPIRY_MS: number;
|
|
8
|
+
/** Without hooks, a session counts busy this long after its last tool call. */
|
|
9
|
+
export declare const BUSY_WITHOUT_HOOKS_MS: number;
|
|
10
|
+
export declare const WATCH_BACKOFF_MS: number[];
|
|
11
|
+
/** L1: turns this user's other devices may start, per 10 minutes. */
|
|
12
|
+
export declare const SELF_TURNS = 5;
|
|
13
|
+
/**
|
|
14
|
+
* Turns this user's other sessions on this same device may start, per 10 minutes: the person's own
|
|
15
|
+
* work, so more than a peer's 3, but still a cap. Constants: nothing a session or its agent sets changes them.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LOCAL_SELF_TURNS = 30;
|
|
18
|
+
/** Turns this user's own sessions may start since the person last typed a prompt here (a slow loop stops too). */
|
|
19
|
+
export declare const OWN_TURNS_UNATTENDED = 10;
|
|
20
|
+
export type InboxState = "pending" | "held" | "released" | "shown" | "declined" | "expired";
|
|
21
|
+
/** Why an item is held: the mode acts without asking, the mode is unknown (re-checked later), a turn cap, or sent to the user. */
|
|
22
|
+
export type HoldKind = "auto" | "unknown" | "cap" | "toUser";
|
|
23
|
+
export type InboxItem = {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: "message" | "notice";
|
|
26
|
+
from: {
|
|
27
|
+
userId: string;
|
|
28
|
+
address: string;
|
|
29
|
+
};
|
|
30
|
+
/** From one of this user's own sessions (any device). */
|
|
31
|
+
fromSelf: boolean;
|
|
32
|
+
/** From one of this user's own sessions that isn't the person at their own terminal: held like a peer's (screenMessage). */
|
|
33
|
+
ownAgent?: boolean;
|
|
34
|
+
/** From another session on this device (not another device). */
|
|
35
|
+
local?: boolean;
|
|
36
|
+
/** The sending device (own sessions only). */
|
|
37
|
+
did?: string;
|
|
38
|
+
/** The held-queue bucket (capHeld) for your own sessions: one per sending session. */
|
|
39
|
+
bucket?: string;
|
|
40
|
+
/** The sender's text (message), or the bridge's own notice line. */
|
|
41
|
+
text: string;
|
|
42
|
+
at: number;
|
|
43
|
+
/** Where a delivery notice goes back to. */
|
|
44
|
+
replyTo: string;
|
|
45
|
+
state: InboxState;
|
|
46
|
+
why?: string;
|
|
47
|
+
heldAt?: number;
|
|
48
|
+
/** Sent to the user rather than to a session: never delivered by itself. */
|
|
49
|
+
toUser?: boolean;
|
|
50
|
+
holdKind?: HoldKind;
|
|
51
|
+
};
|
|
52
|
+
/** One `p2p watch` child: lines as they come, then how it ended. */
|
|
53
|
+
export type WatchRunner = (argv: readonly string[], onLine: (line: string) => void, signal: AbortSignal) => Promise<{
|
|
54
|
+
code: number | null;
|
|
55
|
+
stderr: string;
|
|
56
|
+
}>;
|
|
57
|
+
export interface Clock {
|
|
58
|
+
now(): number;
|
|
59
|
+
every(ms: number, fn: () => void): {
|
|
60
|
+
cancel(): void;
|
|
61
|
+
};
|
|
62
|
+
after(ms: number, fn: () => void): {
|
|
63
|
+
cancel(): void;
|
|
64
|
+
};
|
|
65
|
+
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
export declare const realClock: Clock;
|
|
68
|
+
export interface BridgeDeps {
|
|
69
|
+
p2p: P2P;
|
|
70
|
+
/** The argv that runs `p2p` (for the watch child). */
|
|
71
|
+
bin: readonly string[];
|
|
72
|
+
watch: WatchRunner;
|
|
73
|
+
env: Record<string, string | undefined>;
|
|
74
|
+
clock?: Clock;
|
|
75
|
+
/** `git <args>` in `cwd`: its trimmed stdout, or undefined. */
|
|
76
|
+
git: (cwd: string, args: readonly string[]) => Promise<string | undefined>;
|
|
77
|
+
cwd: string;
|
|
78
|
+
/** Other live local Codex sessions, for the to-the-user rule (sid and when last used). */
|
|
79
|
+
board?: () => Promise<{
|
|
80
|
+
sid: string;
|
|
81
|
+
activeAt: number;
|
|
82
|
+
}[]>;
|
|
83
|
+
/** Hands framed text to an idle Codex thread (`codex queue`), when the person opted in. */
|
|
84
|
+
queue?: (threadId: string, text: string) => Promise<boolean>;
|
|
85
|
+
log?: (line: string) => void;
|
|
86
|
+
/** This thread's own rollout file, once a tool call's _meta named the thread (the trusted mode). */
|
|
87
|
+
transcript?: (threadId: string) => TranscriptSource;
|
|
88
|
+
/** CODEX_HOME: a rollout file under it is trusted only while the sandbox can't write there. */
|
|
89
|
+
codexHome?: string;
|
|
90
|
+
/** Settings the bridge ignored (set outside the user-level config), shown in `p2p codex sessions`. */
|
|
91
|
+
settingsWarnings?: readonly string[];
|
|
92
|
+
/** TMPDIR as Codex (and so its sandbox) sees it; default os.tmpdir(). */
|
|
93
|
+
tmpdir?: string;
|
|
94
|
+
/** P2P_HOME: the person's nonce files and identity live there. */
|
|
95
|
+
p2pHome?: string;
|
|
96
|
+
/** Why the startup settings make this bridge hold everything and refuse every release (knobs.locationPolicy). */
|
|
97
|
+
refusal?: string;
|
|
98
|
+
/** Why releases are refused though delivery may go on (knobs.cwdPolicy: the project couldn't be confirmed). */
|
|
99
|
+
releaseRefusal?: string;
|
|
100
|
+
/** Reads a project's `.codex/config.toml` (default: the file system); null when absent. */
|
|
101
|
+
readConfig?: (path: string) => Promise<string | null>;
|
|
102
|
+
/** The project (cwd, repo root) a project config lives in; the bridge adds the cwd and repo it learns. */
|
|
103
|
+
projectDirs?: readonly string[];
|
|
104
|
+
/** Called whenever what the registry shows about this session changes. */
|
|
105
|
+
onChange?: () => void;
|
|
106
|
+
}
|
|
107
|
+
/** What a hook reports, already reduced by the hook process (no prompt text ever comes here). */
|
|
108
|
+
export type HookReport = {
|
|
109
|
+
event: string;
|
|
110
|
+
sessionId?: string;
|
|
111
|
+
cwd?: string;
|
|
112
|
+
mode?: CodexMode;
|
|
113
|
+
/** PostToolUse: files the tool changed, as the model named them. */
|
|
114
|
+
files?: string[];
|
|
115
|
+
/** PreToolUse: absolute paths the call reaches (a shell command's, an apply_patch's): their projects bind this session. */
|
|
116
|
+
dirs?: string[];
|
|
117
|
+
/** PreToolUse: some path couldn't be resolved, or there were too many: the session is private. */
|
|
118
|
+
over?: boolean;
|
|
119
|
+
/** Why, as the CLI's OverWhy words (`unresolved`, `folders`). */
|
|
120
|
+
overWhy?: string[];
|
|
121
|
+
stopHookActive?: boolean;
|
|
122
|
+
};
|
|
123
|
+
export type HookOutput = Record<string, unknown>;
|
|
124
|
+
export declare function loadThreadDirs(home: string | undefined, threadId: string): string[];
|
|
125
|
+
/**
|
|
126
|
+
* A thread's saved folders, and whether it was already over its cap (and why: the CLI's OverWhy
|
|
127
|
+
* words). A file that exists but can't be read: over (fails closed), `front`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function loadThread(home: string | undefined, threadId: string): {
|
|
130
|
+
dirs: string[];
|
|
131
|
+
over: boolean;
|
|
132
|
+
why: string[];
|
|
133
|
+
};
|
|
134
|
+
export declare function saveThreadDirs(home: string | undefined, threadId: string, dirs: readonly string[], over?: boolean, why?: readonly string[]): void;
|
|
135
|
+
export declare const INBOX_OPEN = "<peer2peer-inbox>";
|
|
136
|
+
export declare class Bridge {
|
|
137
|
+
private readonly deps;
|
|
138
|
+
readonly sid: string;
|
|
139
|
+
ref: string;
|
|
140
|
+
who: Whoami | null;
|
|
141
|
+
isOnline: boolean;
|
|
142
|
+
isPrivate: boolean;
|
|
143
|
+
circle: string | undefined;
|
|
144
|
+
status: "busy" | "idle";
|
|
145
|
+
summary: string | undefined;
|
|
146
|
+
/** Whether the summary came from the model (p2p_status), not the file-list fallback. */
|
|
147
|
+
isSummaryProvided: boolean;
|
|
148
|
+
files: string[];
|
|
149
|
+
cwd: string;
|
|
150
|
+
root: string | undefined;
|
|
151
|
+
repo: string | undefined;
|
|
152
|
+
branch: string | undefined;
|
|
153
|
+
label: string;
|
|
154
|
+
readonly shareStatus: boolean;
|
|
155
|
+
readonly isQueueEnabled: boolean;
|
|
156
|
+
autoDeliver: AutoDeliver;
|
|
157
|
+
/** The latest turn context from this thread's own rollout file (trusted). */
|
|
158
|
+
transcriptMode: CodexMode;
|
|
159
|
+
/** The latest tool call's _meta sandbox and auto-review (trusted). */
|
|
160
|
+
metaMode: CodexMode;
|
|
161
|
+
/** How many turn contexts the rollout file has shown (a new one ends a reported "auto"). */
|
|
162
|
+
private trustedSeq;
|
|
163
|
+
/** A hook reported an auto-approving mode at this trustedSeq: stricter only, until the next turn context. */
|
|
164
|
+
private reportedAutoSeq;
|
|
165
|
+
private trustedCwd;
|
|
166
|
+
/** Why the rollout file itself isn't trusted (two files for the thread, a foreign session_meta, ...), once seen: sticky. */
|
|
167
|
+
private rolloutUntrusted;
|
|
168
|
+
/** The writable folders the rollout's turn contexts declared (any ever), trusted or not: tighten-only. */
|
|
169
|
+
private declaredWritable;
|
|
170
|
+
/** A project config found later (a cwd learned after startup) that touches this server's table. */
|
|
171
|
+
private overrideRefusal;
|
|
172
|
+
/** Every cwd this session has been in, and each one's repo root: all project. */
|
|
173
|
+
private readonly projectSeen;
|
|
174
|
+
/** Paths the session's tool calls reached (hooks): bound to their projects with every send (projects.ts), kept per thread. */
|
|
175
|
+
private readonly touched;
|
|
176
|
+
/** Past a cap, or a path that couldn't be resolved: the CLI keeps this session private (`--project-dirs-over`). */
|
|
177
|
+
isDirsOver: boolean;
|
|
178
|
+
/** Why (the CLI's OverWhy words), so its refusal names the cause. */
|
|
179
|
+
readonly dirsOverWhy: Set<string>;
|
|
180
|
+
/** Where sandboxed commands may write, per the trusted turn context ("all": no sandbox; undefined: unknown). */
|
|
181
|
+
trustedWritable: string[] | "all" | undefined;
|
|
182
|
+
/** Why this thread's rollout file isn't trusted (planted or malformed), once found. */
|
|
183
|
+
untrustedTranscript: string | undefined;
|
|
184
|
+
private transcript;
|
|
185
|
+
/** Files a PostToolUse reported (p2p_status may name them even before they exist). */
|
|
186
|
+
private seenEdits;
|
|
187
|
+
/** Turns this user's own devices started (L1: at most 5 per 10 minutes). */
|
|
188
|
+
private selfTurns;
|
|
189
|
+
/** Turns your own sessions started since the person last typed a prompt here. */
|
|
190
|
+
private ownSinceTyped;
|
|
191
|
+
/** Prompts the person typed, as the trusted rollout counts them (TrustedMode.typed). */
|
|
192
|
+
private trustedTyped;
|
|
193
|
+
threadId: string | undefined;
|
|
194
|
+
hooksSeen: boolean;
|
|
195
|
+
activeAt: number;
|
|
196
|
+
lastToolAt: number;
|
|
197
|
+
peers: PeerRow[];
|
|
198
|
+
inbox: InboxItem[];
|
|
199
|
+
contactRequests: number;
|
|
200
|
+
lastError: string | undefined;
|
|
201
|
+
private peerTurns;
|
|
202
|
+
private flagged;
|
|
203
|
+
private activityNotes;
|
|
204
|
+
private heldMentioned;
|
|
205
|
+
private timers;
|
|
206
|
+
private readonly stop;
|
|
207
|
+
private announcing;
|
|
208
|
+
private isAnnounceQueued;
|
|
209
|
+
private queueTimer;
|
|
210
|
+
private watchDone;
|
|
211
|
+
readonly clock: Clock;
|
|
212
|
+
constructor(deps: BridgeDeps);
|
|
213
|
+
get p2p(): P2P;
|
|
214
|
+
get address(): string;
|
|
215
|
+
private log;
|
|
216
|
+
/** Reads where the session is (repo, branch) and goes online when there is an identity. */
|
|
217
|
+
start(): Promise<void>;
|
|
218
|
+
/** Every folder this session has worked in: each one's project bounds who it reaches (projects.ts). */
|
|
219
|
+
sessionDirs(): string[];
|
|
220
|
+
/** Private from now on, and why. */
|
|
221
|
+
markOver(why: string): void;
|
|
222
|
+
/** What `--project-dirs-over` says: false, or why (an over set without a reason is `front`). */
|
|
223
|
+
dirsOver(): false | string[];
|
|
224
|
+
private goOnline;
|
|
225
|
+
/** Stops the watcher and timers; a final idle status so peers see this session stop. */
|
|
226
|
+
close(): Promise<void>;
|
|
227
|
+
private watchLoop;
|
|
228
|
+
private where;
|
|
229
|
+
/** Paths the session reached: bound (projects.ts), and kept for this thread so a resume stays bound. */
|
|
230
|
+
noteTouched(dirs: readonly string[]): void;
|
|
231
|
+
/** The repo (the git toplevel's folder name), branch and label for `cwd`. */
|
|
232
|
+
setCwd(cwd: string, force?: boolean): Promise<void>;
|
|
233
|
+
/** The summary that goes out: the model's own line, else one made from the files (never from a prompt). */
|
|
234
|
+
sharedSummary(): string | undefined;
|
|
235
|
+
/** Shares this session's status now; coalesces with one already on its way. Never a mode. */
|
|
236
|
+
announce(): void;
|
|
237
|
+
/** Waits for a status on its way (tests, and before answering a tool). */
|
|
238
|
+
settled(): Promise<void>;
|
|
239
|
+
setStatus(next: "busy" | "idle"): void;
|
|
240
|
+
/** Without hooks, busy means "a tool was called lately". */
|
|
241
|
+
private tickBusy;
|
|
242
|
+
/** A tool call: the thread and sandbox it reports, and (without hooks) busy. */
|
|
243
|
+
noteToolCall(info: {
|
|
244
|
+
threadId?: string;
|
|
245
|
+
mode?: CodexMode;
|
|
246
|
+
}): void;
|
|
247
|
+
/** Re-reads this thread's own rollout file (the trusted turn context). */
|
|
248
|
+
refreshTrusted(): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* The writable roots, resolved, symlinks followed. TMPDIR stands for every
|
|
251
|
+
* candidate: the env's (a project config can set it), this process's, and
|
|
252
|
+
* macOS's real per-user temp folder from confstr.
|
|
253
|
+
*/
|
|
254
|
+
private resolveRoots;
|
|
255
|
+
/** Why CODEX_HOME may be writable by the sandbox (so its rollout files could be planted), or undefined. */
|
|
256
|
+
private codexHomeReachable;
|
|
257
|
+
/**
|
|
258
|
+
* The static backstop, whatever any turn context declares writable: the
|
|
259
|
+
* startup refusal (knobs.locationPolicy: HOME, a project config touching
|
|
260
|
+
* this server, an unsafe or non-private Codex home or P2P_HOME), or the
|
|
261
|
+
* Codex home (its rollout files) or P2P_HOME (the person's nonce files,
|
|
262
|
+
* identity and registry) in a temp folder, a folder Codex lets the
|
|
263
|
+
* sandbox write, or any project folder seen since. The bridge then holds
|
|
264
|
+
* everything (own devices and P2P_AUTO_DELIVER senders included) and
|
|
265
|
+
* refuses every release.
|
|
266
|
+
*/
|
|
267
|
+
locationRefusal(p2pHome?: string | undefined): string | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* The dynamic half of the backstop (it is what makes the cwd = ~ exemption
|
|
270
|
+
* safe): when a turn context declares writable a folder holding the Codex
|
|
271
|
+
* home or its config.toml (which sets P2P_AUTO_DELIVER for the next
|
|
272
|
+
* start), or overlapping P2P_HOME, the sandbox could plant either, so the
|
|
273
|
+
* bridge holds everything and refuses releases. A writable folder inside
|
|
274
|
+
* the Codex home (its memories) doesn't count; one inside P2P_HOME does.
|
|
275
|
+
* `danger-full-access` ("all") isn't covered here: it already holds
|
|
276
|
+
* others' messages, and P2P_AUTO_DELIVER exists for such sessions.
|
|
277
|
+
*/
|
|
278
|
+
private sandboxReach;
|
|
279
|
+
private codexHomeRefusal;
|
|
280
|
+
/**
|
|
281
|
+
* Temp folders, the folders Codex lets the sandbox write (memories), and
|
|
282
|
+
* the project as far as the bridge knows it: every cwd it has seen
|
|
283
|
+
* (startup, Codex's own, the rollout's turn contexts, hooks) and each
|
|
284
|
+
* one's repo root. A project config can move the server's cwd, not these.
|
|
285
|
+
*/
|
|
286
|
+
private unsafeRoots;
|
|
287
|
+
/**
|
|
288
|
+
* Whether a release over the socket can be trusted at all: the person's
|
|
289
|
+
* nonce file lives in P2P_HOME, so P2P_HOME must be out of the sandbox's
|
|
290
|
+
* reach (outside every writable root of the trusted turn context). Under
|
|
291
|
+
* danger-full-access, unknown roots or an untrusted rollout: refused.
|
|
292
|
+
*/
|
|
293
|
+
releaseReach(p2pHome: string): {
|
|
294
|
+
ok: true;
|
|
295
|
+
} | {
|
|
296
|
+
ok: false;
|
|
297
|
+
reason: string;
|
|
298
|
+
};
|
|
299
|
+
/** The session's mode class now (see classifyMode); `confirmed` false at UserPromptSubmit. */
|
|
300
|
+
modeClass(confirmed?: boolean): ModeClass;
|
|
301
|
+
/** What the bridge knows of the mode, merged (for the person's `p2p codex sessions`; never published). */
|
|
302
|
+
get mode(): CodexMode;
|
|
303
|
+
/** A repo-relative path that exists inside the repo (symlinks resolved, so none escapes it). */
|
|
304
|
+
private existsInRepo;
|
|
305
|
+
/**
|
|
306
|
+
* Files the session changed: repo-relative only, and only files that
|
|
307
|
+
* exist in the repo or that a PostToolUse already reported (a hook report
|
|
308
|
+
* comes over the local socket, so it is checked too). Anything else is dropped.
|
|
309
|
+
*/
|
|
310
|
+
touch(files: readonly string[], source?: "edit" | "model"): string[];
|
|
311
|
+
/** p2p_status: the model's one-line summary (cleaned), its files and state. */
|
|
312
|
+
setWorkingOn(o: {
|
|
313
|
+
summary?: string;
|
|
314
|
+
files?: string[];
|
|
315
|
+
state?: "busy" | "idle";
|
|
316
|
+
}): {
|
|
317
|
+
summary?: string;
|
|
318
|
+
files: string[];
|
|
319
|
+
isShared: boolean;
|
|
320
|
+
dropped: number;
|
|
321
|
+
};
|
|
322
|
+
refreshPeers(): Promise<PeerRow[]>;
|
|
323
|
+
private refreshContacts;
|
|
324
|
+
/** New (peer session, file) overlaps: one short message to that session each, and a note for the model. */
|
|
325
|
+
checkConflicts(): Promise<void>;
|
|
326
|
+
/** The `<peer-activity>` digest, with any conflicts this session has. */
|
|
327
|
+
activity(): string;
|
|
328
|
+
onLine(line: string): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* What an event says of an own-session origin (the CLI's local record, never the wire): `via` is
|
|
331
|
+
* "person" for the person's own terminal session, anything else (or nothing: another device, an
|
|
332
|
+
* older client) counts as an agent session's. `ownTrusted`: the person ran `p2p own-agents deliver`.
|
|
333
|
+
*/
|
|
334
|
+
private ownOf;
|
|
335
|
+
/** `p2p own-agents` as it stands now, read before each screening (never stamped on an event). Unknown: hold. */
|
|
336
|
+
private ownAgentsSetting;
|
|
337
|
+
refreshOwnAgents(): Promise<void>;
|
|
338
|
+
/** Whether the person's `p2p own-agents` lets this own agent session's message through (the CLI's ownAgentsDeliverFrom). */
|
|
339
|
+
private ownAgentDelivers;
|
|
340
|
+
/** Applies the hold rule to one new item, by this session's own mode as it stands now. */
|
|
341
|
+
private screenNow;
|
|
342
|
+
private hold;
|
|
343
|
+
/** Drops finished items beyond a bounded history. */
|
|
344
|
+
private compact;
|
|
345
|
+
private notice;
|
|
346
|
+
expireHeld(): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* What may reach the model now, framed; marks it shown. Pending items, and
|
|
349
|
+
* items held only because the mode was unknown, are screened again by the
|
|
350
|
+
* mode as it stands now (`confirmed` false at UserPromptSubmit: this
|
|
351
|
+
* turn's context may not be written yet, so only what doesn't depend on
|
|
352
|
+
* the mode goes out there). When the delivery starts a turn (a Stop
|
|
353
|
+
* continuation, `codex queue`), the turn caps apply: past a cap, peers'
|
|
354
|
+
* messages and the user's own sessions' are held until the person
|
|
355
|
+
* releases them (`p2p codex release`).
|
|
356
|
+
*/
|
|
357
|
+
takeDeliverable(o: {
|
|
358
|
+
startsTurn: boolean;
|
|
359
|
+
confirmed?: boolean;
|
|
360
|
+
}): InboxItem[];
|
|
361
|
+
/** Framed items as one block the model reads. */
|
|
362
|
+
frame(items: readonly InboxItem[]): string;
|
|
363
|
+
/** Held items the model has not been told about yet, as one line (no text from them). */
|
|
364
|
+
heldNote(o?: {
|
|
365
|
+
all?: boolean;
|
|
366
|
+
}): string | undefined;
|
|
367
|
+
/** Conflict notes raised since the last time the model was told. */
|
|
368
|
+
takeActivityNotes(): string | undefined;
|
|
369
|
+
/**
|
|
370
|
+
* Held items as metadata only: who, why, when. Never the text: anything
|
|
371
|
+
* running as the user can ask the socket, including a sandboxed command.
|
|
372
|
+
*/
|
|
373
|
+
heldList(): {
|
|
374
|
+
id: string;
|
|
375
|
+
from: string;
|
|
376
|
+
at: number;
|
|
377
|
+
why: string;
|
|
378
|
+
kind: string;
|
|
379
|
+
toUser: boolean;
|
|
380
|
+
}[];
|
|
381
|
+
/** One held item, for the release confirmation the bridge prints to its own terminal. */
|
|
382
|
+
heldItem(id: string): InboxItem | undefined;
|
|
383
|
+
/** The person's release (verified by the server first): delivered at the next chance, never subject to the turn caps. */
|
|
384
|
+
release(id: string): {
|
|
385
|
+
ok: boolean;
|
|
386
|
+
reason?: string;
|
|
387
|
+
};
|
|
388
|
+
decline(id: string): Promise<{
|
|
389
|
+
ok: boolean;
|
|
390
|
+
reason?: string;
|
|
391
|
+
}>;
|
|
392
|
+
/**
|
|
393
|
+
* With P2P_CODEX_QUEUE=1 and a known thread, a deliverable message that
|
|
394
|
+
* arrives while the session is idle starts a turn with `codex queue`
|
|
395
|
+
* (gathered for half a second, within the turn caps). The queued text is
|
|
396
|
+
* the bridge's own pointer ("call p2p_inbox"), never peer text, which
|
|
397
|
+
* would otherwise sit in argv and arrive as a user message. Off by
|
|
398
|
+
* default: `codex queue` is experimental and needs Codex's shared app-server.
|
|
399
|
+
*/
|
|
400
|
+
private scheduleQueue;
|
|
401
|
+
private flushQueue;
|
|
402
|
+
/**
|
|
403
|
+
* One Codex hook, as the hook process reported it over the local socket.
|
|
404
|
+
* A report is untrusted (a sandboxed command can send one too): it may
|
|
405
|
+
* make the mode stricter, never looser, and it never binds the thread.
|
|
406
|
+
* The mode itself comes from this thread's rollout file and _meta.
|
|
407
|
+
*/
|
|
408
|
+
onHook(r: HookReport): Promise<HookOutput>;
|
|
409
|
+
/** What the person sees of this session in `p2p codex sessions`. */
|
|
410
|
+
describe(): Record<string, unknown>;
|
|
411
|
+
}
|
|
412
|
+
/** What `codex queue` puts in an idle thread: the bridge's own words, no peer text. */
|
|
413
|
+
export declare function queuePointer(n: number, senders: readonly string[]): string;
|
|
414
|
+
/**
|
|
415
|
+
* The first (path, root) pair that overlaps in either direction: the path
|
|
416
|
+
* inside a writable root, or a writable root inside the path (so the sandbox
|
|
417
|
+
* could write somewhere under it). Paths and roots are compared as given and
|
|
418
|
+
* with symlinks resolved.
|
|
419
|
+
*/
|
|
420
|
+
export declare function reachHit(roots: readonly string[], paths: readonly string[]): {
|
|
421
|
+
path: string;
|
|
422
|
+
root: string;
|
|
423
|
+
} | undefined;
|