@rynx-ai/runtime 0.1.11-beta.3 → 0.1.11-beta.30

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.
Files changed (44) hide show
  1. package/dist/claude/executor.d.ts +19 -5
  2. package/dist/claude/executor.js +56 -12
  3. package/dist/claude/models.d.ts +0 -5
  4. package/dist/claude/models.js +1 -7
  5. package/dist/claude/native-bridge.d.ts +2 -0
  6. package/dist/claude/native-bridge.js +23 -0
  7. package/dist/claude/native-hook-main.js +62 -0
  8. package/dist/claude/native-integration.d.ts +50 -10
  9. package/dist/claude/native-integration.js +262 -37
  10. package/dist/claude/session-status.d.ts +39 -0
  11. package/dist/claude/session-status.js +163 -0
  12. package/dist/claude/transcript.js +27 -17
  13. package/dist/codex-app-server/client.d.ts +10 -6
  14. package/dist/codex-app-server/client.js +67 -15
  15. package/dist/codex-app-server/forwarder.d.ts +92 -3
  16. package/dist/codex-app-server/forwarder.js +509 -56
  17. package/dist/codex-app-server/mapping.d.ts +3 -6
  18. package/dist/codex-app-server/mapping.js +174 -28
  19. package/dist/codex-app-server/mcp-startup.d.ts +13 -0
  20. package/dist/codex-app-server/mcp-startup.js +63 -0
  21. package/dist/codex-app-server/protocol.d.ts +64 -7
  22. package/dist/codex-app-server/ws-channel.js +19 -19
  23. package/dist/codex-home.js +2 -4
  24. package/dist/host.d.ts +64 -21
  25. package/dist/host.js +1330 -441
  26. package/dist/index.d.ts +1 -1
  27. package/dist/input-resources.d.ts +4 -0
  28. package/dist/input-resources.js +21 -5
  29. package/dist/models-catalog.d.ts +2 -1
  30. package/dist/models-catalog.js +94 -6
  31. package/dist/runner/child.d.ts +48 -21
  32. package/dist/runner/child.js +550 -48
  33. package/dist/runner/manager.d.ts +54 -13
  34. package/dist/runner/manager.js +479 -114
  35. package/dist/runner/protocol.d.ts +62 -19
  36. package/dist/runner/protocol.js +5 -0
  37. package/dist/runner/startup-policy.d.ts +7 -0
  38. package/dist/runner/startup-policy.js +10 -0
  39. package/dist/terminal/claude-tui.d.ts +3 -1
  40. package/dist/terminal/claude-tui.js +3 -1
  41. package/dist/terminal/registry.js +3 -2
  42. package/dist/terminal/tmux.d.ts +50 -7
  43. package/dist/terminal/tmux.js +168 -47
  44. package/package.json +4 -3
@@ -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 InjectOutcome, type TerminalOpenErrorCode, type TerminalRole } from "./protocol.js";
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,45 @@ 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
67
  /** Max wait for an accepted owner TUI submission to become observable as a
60
68
  * mirrored response or a published native rotation. */
61
69
  terminalInputHandoffTimeoutMs?: number;
62
- /** Initial exponential backoff for retrying unproven terminal cleanup. */
63
- terminalInputCleanupRetryMs?: number;
64
70
  /** Injected for tests. */
65
71
  spawn?: typeof nodeSpawn;
66
72
  /** Injected for tests. Defaults to signaling the whole POSIX process group
67
73
  * created for the runner child, with direct-child fallback. */
68
74
  signalChild?: (child: ChildProcess, signal: NodeJS.Signals, processGroup: boolean) => void;
69
- /** Injected for tests. Kills and verifies the deterministic private tmux
70
- * server owned by a Session runner. */
75
+ /** Injected for tests. Best-effort close of the deterministic private tmux
76
+ * server owned by a Session runner; reference implementation does not verify/retry close. */
71
77
  terminateTerminalServer?: (terminalName: string) => boolean | Promise<boolean>;
78
+ /** Injected tmux `#{window_activity}` reader. Returns epoch seconds. */
79
+ terminalWindowActivityAt?: (terminalName: string) => number | null | Promise<number | null>;
80
+ /** Injected tmux attached-client probe. */
81
+ terminalHasAttachedClient?: (terminalName: string) => boolean | Promise<boolean>;
72
82
  now?: () => number;
83
+ /** Wall clock used to compare tmux's epoch timestamp. */
84
+ wallNow?: () => number;
73
85
  /** Extra env merged into every spawned runner child — e.g. the control-plane
74
86
  * URL + token so a claude-native PermissionRequest hook can POST back. */
75
87
  childEnv?: Record<string, string>;
@@ -136,6 +148,8 @@ export declare class RunnerManager implements AgentCapabilities {
136
148
  private readonly sessionStore;
137
149
  private readonly runnerEntry;
138
150
  private readonly idleTtlMs;
151
+ private readonly nativePaneIdleTtlMs;
152
+ private readonly nativePaneOutputBusyWindowMs;
139
153
  private readonly spawn;
140
154
  private readonly childEnv;
141
155
  private readonly sessionContextProvider;
@@ -152,15 +166,22 @@ export declare class RunnerManager implements AgentCapabilities {
152
166
  private readonly shutdownKillGraceMs;
153
167
  private readonly signalChild;
154
168
  private readonly terminateTerminalServer;
169
+ private readonly terminalWindowActivityAt;
170
+ private readonly terminalHasAttachedClient;
171
+ private readonly wallNow;
155
172
  private readonly liveStartTimeoutMs;
156
173
  private readonly liveReadyTimeoutMs;
174
+ private readonly nativeLiveStartTimeoutMs;
157
175
  private readonly liveInterruptTimeoutMs;
158
176
  private readonly terminalInputHandoffTimeoutMs;
159
- private readonly terminalInputCleanupRetryMs;
177
+ private reapPromise;
160
178
  private stopping;
161
179
  private stopPromise;
162
180
  /** Sink for mirrored {@link SessionEvent}s from every session's forwarder. */
163
181
  private mirrorListener;
182
+ /** Synchronous persistence hook for native collaboration-mode reflection.
183
+ * It runs before the event reaches the Session bus. */
184
+ private collaborationModeListener;
164
185
  /** Sink for session rotations (claude `/clear`·`/fork`) — server records meta. */
165
186
  private rotateListener;
166
187
  /** Session keys with a live codex forwarder — never reaped while present. */
@@ -208,7 +229,8 @@ export declare class RunnerManager implements AgentCapabilities {
208
229
  * session's persistent codex forwarder (web- AND TUI-initiated turns). The
209
230
  * server wires this to `persistSessionEvent` (bus + canonical log).
210
231
  */
211
- onMirror(listener: (sessionId: string, event: SessionEvent) => void): void;
232
+ onMirror(listener: (sessionId: string, event: SessionEvent) => void | Promise<void>): void;
233
+ onCollaborationMode(listener: (sessionId: string, mode: SessionCollaborationMode) => void): void;
212
234
  /** Register the sink for session rotations (claude `/clear`·`/fork`): the server
213
235
  * records the new session's meta (carry-over agent/model/title). */
214
236
  onRotate(listener: (rotation: RotateInfo) => void | Promise<void>): void;
@@ -222,13 +244,14 @@ export declare class RunnerManager implements AgentCapabilities {
222
244
  private finishTerminalInputHandoff;
223
245
  private finishAllTerminalInputHandoffs;
224
246
  private preserveTerminalInputHandoffsAsActivity;
225
- private scheduleTerminalInputCleanupRetry;
226
247
  private expireTerminalInputHandoffs;
227
248
  /**
228
249
  * Eagerly bring up a session's codex-native live view (persistent forwarder +
229
250
  * detached `codex --remote` TUI) in its runner child, spawning the runner if
230
- * needed. Idempotent. Resolves true once the codex thread is bound; false for a
231
- * non-codex / non-live session (the caller then uses the normal run path).
251
+ * needed. Idempotent. For Codex-lineage sessions, resolves after backend
252
+ * preload and pane launch; known-thread observer attach and fresh-thread
253
+ * discovery continue in the background. Other providers retain their
254
+ * readiness gate.
232
255
  */
233
256
  ensureLiveSession(localThreadId: string, opts: {
234
257
  workspace: SessionWorkspaceSnapshot;
@@ -247,13 +270,14 @@ export declare class RunnerManager implements AgentCapabilities {
247
270
  }): Promise<boolean>;
248
271
  private requestLiveSession;
249
272
  lastLiveSessionError(localThreadId: string): string | undefined;
273
+ lastLiveSessionFailure(localThreadId: string): LiveSessionFailure | undefined;
250
274
  /**
251
275
  * Inject a user turn into a session's live codex thread — reference implementation's
252
276
  * single-writer web send (`turn/start` / `turn/steer`); the forwarder mirrors
253
277
  * all output. Resolves true when the app-server accepted the turn, false when
254
278
  * the session has no live forwarder (caller falls back to the run path).
255
279
  */
256
- injectMessage(localThreadId: string, input: RuntimeUserInput | string): Promise<InjectOutcome>;
280
+ injectMessage(localThreadId: string, input: RuntimeUserInput | string, options?: RuntimeTurnOptions): Promise<InjectResult>;
257
281
  private injectMessageAdmitted;
258
282
  /**
259
283
  * Interrupt a session's active live turn — the web Stop button (codex
@@ -263,6 +287,8 @@ export declare class RunnerManager implements AgentCapabilities {
263
287
  interruptLiveSession(localThreadId: string): Promise<boolean>;
264
288
  /** Resolve a native question/approval without ever spawning a new runner. */
265
289
  resolveInteraction(localThreadId: string, interactionId: string, resolution: SessionInteractionResolution): Promise<ResolveInteractionResult>;
290
+ /** Update a loaded Codex-lineage native thread without spawning a runner. */
291
+ updateCollaborationMode(localThreadId: string, mode: SessionCollaborationMode): Promise<void>;
266
292
  listModels(runtime?: AgentRuntimeId): Promise<ModelListResponse | null>;
267
293
  getGoal(localThreadId: string): Promise<CapabilityResult<ThreadGoal | null>>;
268
294
  setGoal(localThreadId: string, objective: string): Promise<CapabilityResult>;
@@ -305,6 +331,8 @@ export declare class RunnerManager implements AgentCapabilities {
305
331
  private bufferForkTargetMessage;
306
332
  private reservedForkTarget;
307
333
  private deliverForkBufferedMessage;
334
+ private deliverMirrorMessage;
335
+ private failMirrorImageTransfer;
308
336
  private deliverRotateMessage;
309
337
  private spawnHandle;
310
338
  private onChildMessage;
@@ -312,5 +340,18 @@ export declare class RunnerManager implements AgentCapabilities {
312
340
  private failHandle;
313
341
  private terminateHandle;
314
342
  private reapIdle;
343
+ private reapIdleOnce;
344
+ /** Provider-authoritative turn state is the lifecycle truth; attached clients
345
+ * and tmux's own activity clock are independent busy evidence. There is no
346
+ * "user was inactive for an hour" override for an active turn. */
347
+ private reapNativePane;
348
+ private isNativePaneBusy;
349
+ private isManagedNativeHandle;
350
+ private failActiveResponses;
351
+ private interruptActiveResponses;
352
+ /** Track the provider-authoritative response lifecycle. Native-pane busy
353
+ * classification consumes this level directly; output volume is separately
354
+ * grounded in tmux's own activity clock. */
355
+ private observeHandleRuntimeEvent;
315
356
  private openSessionContext;
316
357
  }