@rynx-ai/runtime 0.1.11-beta.5 → 0.1.11-beta.51
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/claude/executor.d.ts +19 -5
- package/dist/claude/executor.js +56 -12
- package/dist/claude/models.d.ts +0 -5
- package/dist/claude/models.js +1 -7
- package/dist/claude/native-bridge.d.ts +103 -1
- package/dist/claude/native-bridge.js +460 -30
- package/dist/claude/native-hook-main.js +81 -1
- package/dist/claude/native-hooks.js +7 -0
- package/dist/claude/native-integration.d.ts +178 -26
- package/dist/claude/native-integration.js +1571 -170
- package/dist/claude/session-status.d.ts +39 -0
- package/dist/claude/session-status.js +163 -0
- package/dist/claude/transcript-clone.d.ts +18 -0
- package/dist/claude/transcript-clone.js +497 -0
- package/dist/claude/transcript.d.ts +27 -4
- package/dist/claude/transcript.js +183 -46
- package/dist/codex-app-server/client.d.ts +10 -6
- package/dist/codex-app-server/client.js +67 -15
- package/dist/codex-app-server/forwarder.d.ts +96 -3
- package/dist/codex-app-server/forwarder.js +542 -57
- package/dist/codex-app-server/mapping.d.ts +3 -6
- package/dist/codex-app-server/mapping.js +228 -36
- package/dist/codex-app-server/mcp-startup.d.ts +13 -0
- package/dist/codex-app-server/mcp-startup.js +63 -0
- package/dist/codex-app-server/process-registry.d.ts +36 -0
- package/dist/codex-app-server/process-registry.js +320 -0
- package/dist/codex-app-server/protocol.d.ts +68 -7
- package/dist/codex-app-server/transport.d.ts +2 -2
- package/dist/codex-app-server/transport.js +4 -0
- package/dist/codex-app-server/ws-channel.d.ts +8 -1
- package/dist/codex-app-server/ws-channel.js +113 -28
- package/dist/codex-child-env.js +3 -32
- package/dist/codex-home.d.ts +35 -3
- package/dist/codex-home.js +323 -18
- package/dist/codex-session-store.d.ts +23 -0
- package/dist/codex-session-store.js +21 -0
- package/dist/host.d.ts +106 -48
- package/dist/host.js +2024 -640
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/input-resources.d.ts +4 -0
- package/dist/input-resources.js +21 -5
- package/dist/models-catalog.js +12 -3
- package/dist/runner/child.d.ts +105 -28
- package/dist/runner/child.js +1625 -100
- package/dist/runner/manager.d.ts +114 -46
- package/dist/runner/manager.js +1523 -446
- package/dist/runner/protocol.d.ts +212 -24
- package/dist/runner/protocol.js +5 -0
- package/dist/runner/startup-policy.d.ts +7 -0
- package/dist/runner/startup-policy.js +10 -0
- package/dist/runner/transport.d.ts +18 -2
- package/dist/runner/transport.js +82 -3
- package/dist/runner-main.js +8 -3
- package/dist/terminal/codex-tui.d.ts +4 -0
- package/dist/terminal/codex-tui.js +5 -0
- package/dist/terminal/control-parser.d.ts +39 -0
- package/dist/terminal/control-parser.js +172 -0
- package/dist/terminal/registry.d.ts +18 -15
- package/dist/terminal/registry.js +44 -23
- package/dist/terminal/spool.d.ts +47 -0
- package/dist/terminal/spool.js +231 -0
- package/dist/terminal/tmux.d.ts +126 -74
- package/dist/terminal/tmux.js +807 -211
- package/package.json +4 -4
package/dist/runner/manager.d.ts
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
* channel.
|
|
17
17
|
*/
|
|
18
18
|
import { spawn as nodeSpawn, type ChildProcess } from "node:child_process";
|
|
19
|
-
import { type AdmissionReservation, type AgentCapabilities, type AgentRuntimeId, type AppConfig, type CapabilityResult, type ModelListResponse, type ResolvedExecutionSnapshot, type RuntimeUserInput, type SessionInteractionResolution, type SessionEvent, type SessionWorkspaceSnapshot, type ThreadGoal } from "@rynx-ai/core";
|
|
19
|
+
import { type AdmissionReservation, type AgentCapabilities, type AgentRuntimeId, type AppConfig, type CapabilityResult, type ModelListResponse, type LiveSessionFailure, type InjectResult, type ResolvedExecutionSnapshot, type RuntimeTurnOptions, type RuntimeUserInput, type SessionCollaborationMode, type SessionInteractionResolution, type SessionEvent, type SessionWorkspaceSnapshot, type ThreadGoal } from "@rynx-ai/core";
|
|
20
20
|
import { type CodexSessionStore } from "../host.js";
|
|
21
21
|
import type { ResolveInteractionResult } from "../interactions.js";
|
|
22
|
-
import { type
|
|
22
|
+
import { type TerminalOpenErrorCode, type TerminalRole } from "./protocol.js";
|
|
23
23
|
/** Runtime-local context attached to one Session runner process. The provider is
|
|
24
24
|
* intentionally generic: package-specific resources stay in the composition
|
|
25
25
|
* root that implements this port. */
|
|
@@ -43,33 +43,42 @@ export interface RunnerManagerOptions {
|
|
|
43
43
|
runnerEntry?: string;
|
|
44
44
|
/** Idle TTL (ms) after which an unused runner is reaped. */
|
|
45
45
|
idleTtlMs?: number;
|
|
46
|
+
/** Native pane idle window. `<= 0` disables native-pane idle reaping. */
|
|
47
|
+
nativePaneIdleTtlMs?: number;
|
|
48
|
+
/** Recent tmux-output window used as independent native-pane busy evidence. */
|
|
49
|
+
nativePaneOutputBusyWindowMs?: number;
|
|
46
50
|
/** Background reap sweep interval (ms); `0` disables the timer (tests). */
|
|
47
51
|
reapIntervalMs?: number;
|
|
48
52
|
/** Grace period between SIGTERM and SIGKILL during runner shutdown. */
|
|
49
53
|
shutdownGraceMs?: number;
|
|
50
54
|
/** Final bounded wait for child exit after SIGKILL. */
|
|
51
55
|
shutdownKillGraceMs?: number;
|
|
52
|
-
/** Max wait for a setup-pane launch acknowledgement.
|
|
56
|
+
/** Max wait for a legacy setup-pane launch acknowledgement. Codex/Traex use
|
|
57
|
+
* their internal phase deadlines and are not wrapped by this timer. */
|
|
53
58
|
liveStartTimeoutMs?: number;
|
|
54
59
|
/** Max wait for a Provider-native thread to become ready. */
|
|
55
60
|
liveReadyTimeoutMs?: number;
|
|
61
|
+
/** Claude SessionStart deadline. Codex/Traex have no parent-owned startup
|
|
62
|
+
* deadline; their app-server/discovery/injection phases report directly. */
|
|
63
|
+
nativeLiveStartTimeoutMs?: number;
|
|
56
64
|
/** Max wait for a native interrupt acknowledgement before reporting it
|
|
57
65
|
* unproven. Callers may then use the explicit force-stop path. */
|
|
58
66
|
liveInterruptTimeoutMs?: number;
|
|
59
|
-
/** Max wait for an accepted owner TUI submission to become observable as a
|
|
60
|
-
* mirrored response or a published native rotation. */
|
|
61
|
-
terminalInputHandoffTimeoutMs?: number;
|
|
62
|
-
/** Initial exponential backoff for retrying unproven terminal cleanup. */
|
|
63
|
-
terminalInputCleanupRetryMs?: number;
|
|
64
67
|
/** Injected for tests. */
|
|
65
68
|
spawn?: typeof nodeSpawn;
|
|
66
69
|
/** Injected for tests. Defaults to signaling the whole POSIX process group
|
|
67
70
|
* created for the runner child, with direct-child fallback. */
|
|
68
71
|
signalChild?: (child: ChildProcess, signal: NodeJS.Signals, processGroup: boolean) => void;
|
|
69
|
-
/** Injected for tests.
|
|
70
|
-
* server owned by a Session runner. */
|
|
71
|
-
terminateTerminalServer?: (terminalName: string) => boolean | Promise<boolean>;
|
|
72
|
+
/** Injected for tests. Best-effort close of the deterministic private tmux
|
|
73
|
+
* server owned by a Session runner; reference implementation does not verify/retry close. */
|
|
74
|
+
terminateTerminalServer?: (terminalName: string, ownerPid?: number) => boolean | Promise<boolean>;
|
|
75
|
+
/** Injected tmux `#{window_activity}` reader. Returns epoch seconds. */
|
|
76
|
+
terminalWindowActivityAt?: (terminalName: string, ownerPid?: number) => number | null | Promise<number | null>;
|
|
77
|
+
/** Injected tmux attached-client probe. */
|
|
78
|
+
terminalHasAttachedClient?: (terminalName: string, ownerPid?: number) => boolean | Promise<boolean>;
|
|
72
79
|
now?: () => number;
|
|
80
|
+
/** Wall clock used to compare tmux's epoch timestamp. */
|
|
81
|
+
wallNow?: () => number;
|
|
73
82
|
/** Extra env merged into every spawned runner child — e.g. the control-plane
|
|
74
83
|
* URL + token so a claude-native PermissionRequest hook can POST back. */
|
|
75
84
|
childEnv?: Record<string, string>;
|
|
@@ -104,24 +113,39 @@ export interface OpenTerminalOptions {
|
|
|
104
113
|
command?: string;
|
|
105
114
|
args?: string[];
|
|
106
115
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
export interface ParentTerminalRead {
|
|
117
|
+
data: Uint8Array;
|
|
118
|
+
nextOffset: number;
|
|
119
|
+
done: boolean;
|
|
120
|
+
finalOffset?: number;
|
|
121
|
+
}
|
|
122
|
+
export interface ParentTerminalReaderDone {
|
|
123
|
+
finalOffset: number;
|
|
124
|
+
reason: "terminal_exited" | "client_closed" | "backpressure" | "internal";
|
|
125
|
+
exitCode: number;
|
|
126
|
+
}
|
|
127
|
+
/** Parent-side demand-driven terminal handle. `ready` publishes only captured
|
|
128
|
+
* history metadata; the caller must pull every seed byte before `start`. */
|
|
114
129
|
export interface ParentTerminal {
|
|
115
130
|
readonly attachId: string;
|
|
116
131
|
readonly ready: Promise<{
|
|
117
132
|
role: TerminalRole;
|
|
133
|
+
seedBytes: number;
|
|
134
|
+
dimensions?: {
|
|
135
|
+
cols: number;
|
|
136
|
+
rows: number;
|
|
137
|
+
};
|
|
118
138
|
}>;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
readonly readerDone: Promise<ParentTerminalReaderDone>;
|
|
140
|
+
readSeed(offset: number, maxBytes: number): Promise<ParentTerminalRead>;
|
|
141
|
+
start(): Promise<void>;
|
|
142
|
+
read(offset: number, maxBytes: number): Promise<ParentTerminalRead>;
|
|
143
|
+
onResize?(listener: (dimensions: {
|
|
144
|
+
cols: number;
|
|
145
|
+
rows: number;
|
|
122
146
|
}) => void): void;
|
|
123
|
-
write(data: string): void
|
|
124
|
-
resize(cols: number, rows: number): void
|
|
147
|
+
write(data: string | Uint8Array): Promise<void>;
|
|
148
|
+
resize(cols: number, rows: number): Promise<void>;
|
|
125
149
|
close(): void;
|
|
126
150
|
}
|
|
127
151
|
/** A typed attach failure so transport adapters can distinguish an expected
|
|
@@ -136,6 +160,8 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
136
160
|
private readonly sessionStore;
|
|
137
161
|
private readonly runnerEntry;
|
|
138
162
|
private readonly idleTtlMs;
|
|
163
|
+
private readonly nativePaneIdleTtlMs;
|
|
164
|
+
private readonly nativePaneOutputBusyWindowMs;
|
|
139
165
|
private readonly spawn;
|
|
140
166
|
private readonly childEnv;
|
|
141
167
|
private readonly sessionContextProvider;
|
|
@@ -152,15 +178,27 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
152
178
|
private readonly shutdownKillGraceMs;
|
|
153
179
|
private readonly signalChild;
|
|
154
180
|
private readonly terminateTerminalServer;
|
|
181
|
+
private readonly terminalWindowActivityAt;
|
|
182
|
+
private readonly terminalHasAttachedClient;
|
|
183
|
+
private readonly wallNow;
|
|
155
184
|
private readonly liveStartTimeoutMs;
|
|
156
185
|
private readonly liveReadyTimeoutMs;
|
|
186
|
+
private readonly nativeLiveStartTimeoutMs;
|
|
157
187
|
private readonly liveInterruptTimeoutMs;
|
|
158
|
-
private
|
|
159
|
-
private readonly terminalInputCleanupRetryMs;
|
|
188
|
+
private reapPromise;
|
|
160
189
|
private stopping;
|
|
161
190
|
private stopPromise;
|
|
162
191
|
/** Sink for mirrored {@link SessionEvent}s from every session's forwarder. */
|
|
163
192
|
private mirrorListener;
|
|
193
|
+
/** Settles process-local projections only when an ordinary durable item has
|
|
194
|
+
* exhausted its permanent retry budget. */
|
|
195
|
+
private mirrorAbandonListener;
|
|
196
|
+
/** Clears process-live optimistic state when /clear permanently moves the
|
|
197
|
+
* native pane away from the old Session. */
|
|
198
|
+
private mirrorSupersedeListener;
|
|
199
|
+
/** Synchronous persistence hook for native collaboration-mode reflection.
|
|
200
|
+
* It runs before the event reaches the Session bus. */
|
|
201
|
+
private collaborationModeListener;
|
|
164
202
|
/** Sink for session rotations (claude `/clear`·`/fork`) — server records meta. */
|
|
165
203
|
private rotateListener;
|
|
166
204
|
/** Session keys with a live codex forwarder — never reaped while present. */
|
|
@@ -182,16 +220,12 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
182
220
|
private readonly forkOperations;
|
|
183
221
|
private readonly forkBufferedMessages;
|
|
184
222
|
private readonly forkBufferedTerminalInputs;
|
|
185
|
-
/** Owner TUI submissions accepted by the parent but not yet represented by a
|
|
186
|
-
* mirrored response or a durably published native rotation. */
|
|
187
|
-
private readonly terminalInputHandoffs;
|
|
188
223
|
constructor(opts: RunnerManagerOptions);
|
|
189
224
|
/**
|
|
190
225
|
* Open a live terminal on the session's runner child (spawning it if needed).
|
|
191
226
|
* Phase C hosts one terminal ("main") per session; the returned handle is a
|
|
192
|
-
* single attach client
|
|
193
|
-
*
|
|
194
|
-
* bridge calls it directly.
|
|
227
|
+
* single attach client with the requested `owner` (read-write) or `read-only`
|
|
228
|
+
* role. Not part of `AgentExecutor`; the WS bridge calls it directly.
|
|
195
229
|
*/
|
|
196
230
|
openTerminal(localThreadId: string, opts: OpenTerminalOptions): ParentTerminal;
|
|
197
231
|
/**
|
|
@@ -208,27 +242,25 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
208
242
|
* session's persistent codex forwarder (web- AND TUI-initiated turns). The
|
|
209
243
|
* server wires this to `persistSessionEvent` (bus + canonical log).
|
|
210
244
|
*/
|
|
211
|
-
onMirror(listener: (sessionId: string, event: SessionEvent) => void): void;
|
|
245
|
+
onMirror(listener: (sessionId: string, event: SessionEvent) => void | Promise<void>): void;
|
|
246
|
+
onMirrorAbandon(listener: (sessionId: string, token: string) => void): void;
|
|
247
|
+
onMirrorSupersede(listener: (sessionId: string) => void): void;
|
|
248
|
+
onCollaborationMode(listener: (sessionId: string, mode: SessionCollaborationMode) => void): void;
|
|
212
249
|
/** Register the sink for session rotations (claude `/clear`·`/fork`): the server
|
|
213
250
|
* records the new session's meta (carry-over agent/model/title). */
|
|
214
251
|
onRotate(listener: (rotation: RotateInfo) => void | Promise<void>): void;
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
private
|
|
219
|
-
private settleTerminalInputHandoff;
|
|
220
|
-
private settleTerminalRotationHandoff;
|
|
252
|
+
/** Actual transport writes and ownership transfers, independent of turn lifecycle. */
|
|
253
|
+
pendingNativeOperationCount(): number;
|
|
254
|
+
private finishTerminalWrite;
|
|
255
|
+
private finishTerminalWrites;
|
|
221
256
|
private currentTerminalSessionId;
|
|
222
|
-
private finishTerminalInputHandoff;
|
|
223
|
-
private finishAllTerminalInputHandoffs;
|
|
224
|
-
private preserveTerminalInputHandoffsAsActivity;
|
|
225
|
-
private scheduleTerminalInputCleanupRetry;
|
|
226
|
-
private expireTerminalInputHandoffs;
|
|
227
257
|
/**
|
|
228
258
|
* Eagerly bring up a session's codex-native live view (persistent forwarder +
|
|
229
259
|
* detached `codex --remote` TUI) in its runner child, spawning the runner if
|
|
230
|
-
* needed. Idempotent.
|
|
231
|
-
*
|
|
260
|
+
* needed. Idempotent. For Codex-lineage sessions, resolves after backend
|
|
261
|
+
* preload and pane launch; known-thread observer attach and fresh-thread
|
|
262
|
+
* discovery continue in the background. Other providers retain their
|
|
263
|
+
* readiness gate.
|
|
232
264
|
*/
|
|
233
265
|
ensureLiveSession(localThreadId: string, opts: {
|
|
234
266
|
workspace: SessionWorkspaceSnapshot;
|
|
@@ -247,13 +279,14 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
247
279
|
}): Promise<boolean>;
|
|
248
280
|
private requestLiveSession;
|
|
249
281
|
lastLiveSessionError(localThreadId: string): string | undefined;
|
|
282
|
+
lastLiveSessionFailure(localThreadId: string): LiveSessionFailure | undefined;
|
|
250
283
|
/**
|
|
251
284
|
* Inject a user turn into a session's live codex thread — reference implementation's
|
|
252
285
|
* single-writer web send (`turn/start` / `turn/steer`); the forwarder mirrors
|
|
253
286
|
* all output. Resolves true when the app-server accepted the turn, false when
|
|
254
287
|
* the session has no live forwarder (caller falls back to the run path).
|
|
255
288
|
*/
|
|
256
|
-
injectMessage(localThreadId: string, input: RuntimeUserInput | string): Promise<
|
|
289
|
+
injectMessage(localThreadId: string, input: RuntimeUserInput | string, options?: RuntimeTurnOptions): Promise<InjectResult>;
|
|
257
290
|
private injectMessageAdmitted;
|
|
258
291
|
/**
|
|
259
292
|
* Interrupt a session's active live turn — the web Stop button (codex
|
|
@@ -263,6 +296,8 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
263
296
|
interruptLiveSession(localThreadId: string): Promise<boolean>;
|
|
264
297
|
/** Resolve a native question/approval without ever spawning a new runner. */
|
|
265
298
|
resolveInteraction(localThreadId: string, interactionId: string, resolution: SessionInteractionResolution): Promise<ResolveInteractionResult>;
|
|
299
|
+
/** Update a loaded Codex-lineage native thread without spawning a runner. */
|
|
300
|
+
updateCollaborationMode(localThreadId: string, mode: SessionCollaborationMode): Promise<void>;
|
|
266
301
|
listModels(runtime?: AgentRuntimeId): Promise<ModelListResponse | null>;
|
|
267
302
|
getGoal(localThreadId: string): Promise<CapabilityResult<ThreadGoal | null>>;
|
|
268
303
|
setGoal(localThreadId: string, objective: string): Promise<CapabilityResult>;
|
|
@@ -305,12 +340,45 @@ export declare class RunnerManager implements AgentCapabilities {
|
|
|
305
340
|
private bufferForkTargetMessage;
|
|
306
341
|
private reservedForkTarget;
|
|
307
342
|
private deliverForkBufferedMessage;
|
|
343
|
+
private deliverMirrorMessage;
|
|
344
|
+
private releaseMirrorDelivery;
|
|
345
|
+
private failMirrorImageTransfer;
|
|
308
346
|
private deliverRotateMessage;
|
|
347
|
+
/** Bridge ownership is a child-local binding, but the parent is the only
|
|
348
|
+
* process that knows logical target publication committed. Mark that fact
|
|
349
|
+
* durably before allowing the child to apply and expose the alias. */
|
|
350
|
+
private publishNativeRotationBinding;
|
|
351
|
+
private publishNativeRotationRecords;
|
|
352
|
+
private deliverRotateAppliedMessage;
|
|
353
|
+
private finalizeNativeRotation;
|
|
354
|
+
private acknowledgeRotateApplied;
|
|
355
|
+
private releasePendingNativeRotation;
|
|
356
|
+
private publishNativeRotationNotice;
|
|
309
357
|
private spawnHandle;
|
|
310
358
|
private onChildMessage;
|
|
311
359
|
/** Mark a handle dead and reject every pending run/cap with the exit reason. */
|
|
312
360
|
private failHandle;
|
|
313
361
|
private terminateHandle;
|
|
314
362
|
private reapIdle;
|
|
363
|
+
private reapIdleOnce;
|
|
364
|
+
/** Provider-authoritative turn state is the lifecycle truth; attached clients
|
|
365
|
+
* and tmux's own activity clock are independent busy evidence. There is no
|
|
366
|
+
* "user was inactive for an hour" override for an active turn. */
|
|
367
|
+
private reapNativePane;
|
|
368
|
+
private reapNativeTerminal;
|
|
369
|
+
private isNativePaneBusy;
|
|
370
|
+
private isManagedNativeHandle;
|
|
371
|
+
private failActiveResponses;
|
|
372
|
+
private interruptActiveResponses;
|
|
373
|
+
/** Crash/termination compensation is intentionally best-effort because it is
|
|
374
|
+
* a terminal/status edge rather than an ordinary transcript delivery.
|
|
375
|
+
* Still consume an asynchronous persistence rejection so a dying child
|
|
376
|
+
* cannot take the parent daemon down with an unhandled rejection. */
|
|
377
|
+
private emitCompensatingMirror;
|
|
378
|
+
/** Track the provider-authoritative response lifecycle. Native-pane busy
|
|
379
|
+
* classification consumes this level directly; output volume is separately
|
|
380
|
+
* grounded in tmux's own activity clock. */
|
|
381
|
+
private observeHandleRuntimeEvent;
|
|
382
|
+
private isStaleMirrorGeneration;
|
|
315
383
|
private openSessionContext;
|
|
316
384
|
}
|