@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
package/dist/host.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { type ResolvedExecutionSnapshot, type ResolvedExecutionBudget, type RuntimeUserInput, type SessionWorkspaceSnapshot, type SessionInteractionResolution, type SessionEvent } from "@rynx-ai/core";
1
+ import { type ResolvedExecutionSnapshot, type ResolvedExecutionBudget, type RuntimeTurnOptions, type RuntimeUserInput, type SessionCollaborationMode, type LiveSessionFailure, type SessionWorkspaceSnapshot, type SessionInteractionResolution, type SessionEvent } from "@rynx-ai/core";
2
2
  import { type AgentRuntimeId } from "@rynx-ai/core";
3
3
  import { type AppConfig } from "@rynx-ai/core";
4
4
  import { createCodexChildEnv } from "./codex-child-env.js";
5
- import type { InjectOutcome } from "./runner/protocol.js";
5
+ import type { InjectResult } from "./runner/protocol.js";
6
6
  import type { ResolveInteractionResult } from "./interactions.js";
7
7
  import { CodexAppServerClient } from "./codex-app-server/client.js";
8
8
  import type { ModelListResponse, ThreadGoal } from "./codex-app-server/protocol.js";
@@ -125,6 +125,9 @@ export declare class LocalAgentHost implements CodexCapabilities {
125
125
  private readonly clock;
126
126
  private readonly backendIdleTtlMs;
127
127
  private readonly forwarderClientFactory;
128
+ private readonly preloadClientFactory;
129
+ /** Builds one short-lived message/interrupt client. */
130
+ private readonly injectionClientFactory;
128
131
  private readonly backends;
129
132
  private readonly sessionId;
130
133
  private readonly runtimeHomeSessionId;
@@ -133,6 +136,10 @@ export declare class LocalAgentHost implements CodexCapabilities {
133
136
  private readonly runtimeHomes;
134
137
  private readonly liveSessions;
135
138
  private readonly liveClaudeSessions;
139
+ /** Exact pre-live startup failure, retained after the partial handle has been
140
+ * cleaned up so Core/plugin callers receive the failed phase, not a generic
141
+ * `live session unavailable` wrapper. */
142
+ private readonly liveStartupErrors;
136
143
  /** Claude forwarders stopped before their terminal is killed. Runner shutdown
137
144
  * finalizes these synchronously afterwards to scrub raw interaction answers. */
138
145
  private readonly pendingClaudeFinalizers;
@@ -141,7 +148,7 @@ export declare class LocalAgentHost implements CodexCapabilities {
141
148
  /** Short-lived dedupe for managed fork notifications delivered after the
142
149
  * `thread/fork` response. Values are expected source Provider thread ids. */
143
150
  private readonly managedForkThreadStarts;
144
- constructor({ config, commandRunner, sessionStore, allowedRoots, appServerClient, now, backendIdleTtlMs, forwarderClientFactory, sessionId, runtimeHomeSessionId, }: {
151
+ constructor({ config, commandRunner, sessionStore, allowedRoots, appServerClient, now, backendIdleTtlMs, forwarderClientFactory, preloadClientFactory, injectionClientFactory, sessionId, runtimeHomeSessionId, }: {
145
152
  config: AppConfig;
146
153
  commandRunner?: CodexCommandRunner;
147
154
  sessionStore?: CodexSessionStore;
@@ -153,6 +160,10 @@ export declare class LocalAgentHost implements CodexCapabilities {
153
160
  backendIdleTtlMs?: number;
154
161
  /** Override the live-session forwarder connection factory (tests inject a fake). */
155
162
  forwarderClientFactory?: (appServerUrl: string) => CodexAppServerClient;
163
+ /** Override the short-lived known-thread preload connection factory. */
164
+ preloadClientFactory?: (appServerUrl: string) => CodexAppServerClient;
165
+ /** Override the short-lived message/interrupt connection factory. */
166
+ injectionClientFactory?: (appServerUrl: string) => CodexAppServerClient;
156
167
  /** The rynx session (localThreadId) this host serves — a per-session runner
157
168
  * child sets it from `RYNX_RUNNER_SESSION` so the private CODEX_HOME is
158
169
  * session-scoped. The shared `__cap__` child / tests fall back to a sentinel
@@ -178,6 +189,16 @@ export declare class LocalAgentHost implements CodexCapabilities {
178
189
  private createAppServerClient;
179
190
  /** Resolve a pending native question/approval without opening a new Turn. */
180
191
  resolveInteraction(localThreadId: string, interactionId: string, resolution: SessionInteractionResolution): Promise<ResolveInteractionResult>;
192
+ /** Apply collaboration mode to an already-loaded Codex-lineage thread. The
193
+ * caller persists only after this native RPC succeeds. */
194
+ updateCollaborationMode(localThreadId: string, mode: SessionCollaborationMode): Promise<void>;
195
+ /** Apply one explicit collaboration mode to the current native thread and
196
+ * remember only a successful RPC. A supplied client is already initialized
197
+ * and remains owned by its caller (used by cold-resume preload). */
198
+ private applyLiveCollaborationMode;
199
+ /** Apply pending explicit model/effort settings and, when requested, one
200
+ * collaboration mode in a single native update. */
201
+ private applyLiveThreadSettings;
181
202
  /**
182
203
  * The command to run in a session's live terminal so it co-drives the codex
183
204
  * app-server thread (Phase D). Returns `null` when live-terminal is off, the
@@ -191,6 +212,7 @@ export declare class LocalAgentHost implements CodexCapabilities {
191
212
  args: string[];
192
213
  cwd: string;
193
214
  env?: Record<string, string>;
215
+ skipTraexStartupPrompts?: boolean;
194
216
  } | null>;
195
217
  /**
196
218
  * Bring up (idempotently) a session's persistent codex forwarder and emit its
@@ -211,26 +233,43 @@ export declare class LocalAgentHost implements CodexCapabilities {
211
233
  /** Bind a session's codex thread id once known (TUI broadcast or store): persist
212
234
  * it, unblock injection, and kick off the resume-subscribe loop (once). */
213
235
  private onLiveThreadStarted;
236
+ /** Start the known-thread observer after the replacement TUI has launched.
237
+ * Fresh sessions already connected their discovery listener before launch;
238
+ * this is therefore an idempotent no-op for them and for a healthy observer. */
239
+ startLiveCodexObserver(localThreadId: string): void;
240
+ /** reference implementation treats the forwarder as a required component of one native
241
+ * lifecycle: if its transport dies, it closes the app-server instead of
242
+ * accepting turns that can no longer reach the canonical mirror. */
243
+ private failObserverLifecycle;
214
244
  private shouldIgnoreManagedForkThreadStarted;
215
245
  private rememberManagedForkThreadStart;
216
246
  /**
217
247
  * Subscribe the forwarder connection to a thread (reference implementation's
218
248
  * `_subscribe_until_ready`). A fresh TUI thread has no rollout until its first
219
249
  * turn, so `thread/resume` is retried: park until the forwarder observes the
220
- * thread active, then retry WITHOUT `excludeTurns` so the response backfills the
221
- * first turn's items (replayed, deduped against the live stream). Once resume
222
- * succeeds, subsequent turns arrive as live notifications on this connection.
250
+ * thread active, then retry. Like reference implementation, the first attempt always uses
251
+ * `excludeTurns`: a known-session cold resume therefore never reconstructs
252
+ * historical running/completed state. Only a fresh thread whose first attempt
253
+ * failed as not-ready retries without `excludeTurns`, backfilling the newly
254
+ * materialized first turn and de-duplicating it against live notifications.
223
255
  */
224
256
  private subscribeUntilReady;
225
- /** Await a live session's thread binding (bounded). Returns false on timeout /
257
+ /** Await a live session's thread binding. `null` leaves the deadline to the
258
+ * caller; a number keeps the Provider-local bound. Returns false on timeout /
226
259
  * no live session. Injection and the runner's `live.ready` gate on this. */
227
- waitLiveReady(localThreadId: string, timeoutMs?: number): Promise<boolean>;
228
- /** Await the stronger Terminal gate: another app-server connection has
229
- * successfully resumed the thread, so the detached TUI cannot race rollout
230
- * discovery or indexing. */
231
- waitTerminalReady(localThreadId: string, timeoutMs?: number): Promise<boolean>;
260
+ waitLiveReady(localThreadId: string, timeoutMs?: number | null): Promise<boolean>;
261
+ /** Await the observer subscription diagnostic. Codex/Traex Terminal startup
262
+ * deliberately does not gate on this promise: the dedicated preload owns resume,
263
+ * while the independent observer attaches in the background. */
264
+ waitTerminalReady(localThreadId: string, timeoutMs?: number | null): Promise<boolean>;
232
265
  /** Diagnostic from the provider adapter when native discovery/resume failed. */
233
266
  liveSessionError(localThreadId: string): string | undefined;
267
+ /** Structured phase + concrete cause used by the runner wire protocol. */
268
+ liveSessionFailure(localThreadId: string): LiveSessionFailure | undefined;
269
+ /** Publish the background TUI/thread discovery failure so an executor
270
+ * already waiting in the 60s bridge window exits immediately with the exact
271
+ * 30s discovery cause. */
272
+ failLiveStartup(localThreadId: string, error: Error): boolean;
234
273
  /**
235
274
  * Inject a user turn into a session's live codex thread — reference implementation's
236
275
  * single-writer web send. `turn/steer` when a turn is open (mid-turn
@@ -238,13 +277,13 @@ export declare class LocalAgentHost implements CodexCapabilities {
238
277
  * resumed from the persisted native id. Serialized per session so two
239
278
  * injects can't double-open a turn.
240
279
  *
241
- * Returns an {@link InjectOutcome}: `notLive` when this session has no live
280
+ * Returns an {@link InjectResult}: `notLive` when this session has no live
242
281
  * forwarder (caller may use the run path); `notReady`/`failed` are hard errors
243
282
  * the caller reports WITHOUT re-running (re-running double-writes alongside the
244
283
  * forwarder). Park-until-ready (~60s), aligning reference implementation's executor waiting for
245
284
  * the bridge instead of a short race that falls back to a second output path.
246
285
  */
247
- injectMessage(localThreadId: string, input: RuntimeUserInput | string): Promise<InjectOutcome>;
286
+ injectMessage(localThreadId: string, input: RuntimeUserInput | string, options?: RuntimeTurnOptions): Promise<InjectResult>;
248
287
  /**
249
288
  * Interrupt the session's active turn — the web Stop button. codex: the
250
289
  * app-server `turn/interrupt` on the active `{threadId, turnId}` (exactly what
@@ -258,6 +297,11 @@ export declare class LocalAgentHost implements CodexCapabilities {
258
297
  stopLiveCodexSession(localThreadId: string, opts?: {
259
298
  deferClaudeInteractionCleanup?: boolean;
260
299
  }): void;
300
+ /** Tear down one codex-lineage native runtime without deleting its durable
301
+ * session-store binding. reference implementation couples its auxiliary Terminal, observer,
302
+ * forwarder and per-session app-server as one disposable runtime envelope;
303
+ * the next message recreates that envelope and cold-resumes the native id. */
304
+ teardownLiveCodexSession(localThreadId: string, error?: Error): boolean;
261
305
  /** Complete the second shutdown phase after the runner has killed all native
262
306
  * terminals and hook subprocesses. Must run before the runner process exits. */
263
307
  finalizeStoppedLiveSessions(): void;
@@ -279,7 +323,7 @@ export declare class LocalAgentHost implements CodexCapabilities {
279
323
  * serialized per session. Parks until the thread is ready AND the tmux injector
280
324
  * is (re)attached, then pastes; `injectViaTerminal` RAISES if the prompt never
281
325
  * appears (reference implementation RAISE), so a not-ready pane is a hard error — NOT a
282
- * fall-through-to-run signal. Returns {@link InjectOutcome}. */
326
+ * fall-through-to-run signal. Returns {@link InjectResult}. */
283
327
  private injectClaude;
284
328
  /** Park until the claude session's tmux injector is (re)attached by the
285
329
  * runner-child, or the deadline passes. Pane relaunch re-attaches it via
@@ -287,9 +331,12 @@ export declare class LocalAgentHost implements CodexCapabilities {
287
331
  * would fail and (pre-reference implementation) fall through to a second output path. */
288
332
  private waitInjector;
289
333
  /** Attach a session's tmux pane injector (from the runner-child, which owns the
290
- * terminal registry — the host does not hold tmux). Ignored for codex sessions
291
- * (they inject via the app-server). Idempotent. */
334
+ * terminal registry — the host does not hold tmux). Claude uses it for normal
335
+ * message injection; Codex uses it only to dismiss the exact TUI-local Plan
336
+ * picker after its synthetic Web form is submitted. Idempotent. */
292
337
  attachTerminalInjector(localThreadId: string, injector: TerminalInjector): void;
338
+ /** Close an active native response when its terminal or runner disappears. */
339
+ failLiveSession(localThreadId: string, error: Error): boolean;
293
340
  /** List the models a runtime exposes (App Server for codex/traex; static for claude). */
294
341
  listModels(runtime?: AgentRuntimeId): Promise<ModelListResponse | null>;
295
342
  /**
@@ -318,7 +365,3 @@ export declare function isUnsupportedMethodError(error: unknown): boolean;
318
365
  * — a fresh TUI thread before its first turn. Retryable (park until active).
319
366
  * Mirrors reference implementation's `_is_thread_not_ready_error`. */
320
367
  export declare function isThreadNotReadyError(error: unknown): boolean;
321
- /** A persisted thread id that a freshly started app-server cannot load yet.
322
- * During startup, both errors can be transient while the rollout index catches
323
- * up. Retry the same id; never use either error as permission to replace it. */
324
- export declare function isRetryableThreadResumeError(error: unknown): boolean;