@rynx-ai/runtime 0.1.11-beta.5 → 0.1.11-beta.50

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 (65) 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 +103 -1
  6. package/dist/claude/native-bridge.js +460 -30
  7. package/dist/claude/native-hook-main.js +81 -1
  8. package/dist/claude/native-hooks.js +7 -0
  9. package/dist/claude/native-integration.d.ts +178 -26
  10. package/dist/claude/native-integration.js +1571 -170
  11. package/dist/claude/session-status.d.ts +39 -0
  12. package/dist/claude/session-status.js +163 -0
  13. package/dist/claude/transcript-clone.d.ts +18 -0
  14. package/dist/claude/transcript-clone.js +497 -0
  15. package/dist/claude/transcript.d.ts +27 -4
  16. package/dist/claude/transcript.js +183 -46
  17. package/dist/codex-app-server/client.d.ts +10 -6
  18. package/dist/codex-app-server/client.js +67 -15
  19. package/dist/codex-app-server/forwarder.d.ts +96 -3
  20. package/dist/codex-app-server/forwarder.js +542 -57
  21. package/dist/codex-app-server/mapping.d.ts +3 -6
  22. package/dist/codex-app-server/mapping.js +228 -36
  23. package/dist/codex-app-server/mcp-startup.d.ts +13 -0
  24. package/dist/codex-app-server/mcp-startup.js +63 -0
  25. package/dist/codex-app-server/process-registry.d.ts +36 -0
  26. package/dist/codex-app-server/process-registry.js +320 -0
  27. package/dist/codex-app-server/protocol.d.ts +68 -7
  28. package/dist/codex-app-server/transport.d.ts +2 -2
  29. package/dist/codex-app-server/transport.js +4 -0
  30. package/dist/codex-app-server/ws-channel.d.ts +8 -1
  31. package/dist/codex-app-server/ws-channel.js +113 -28
  32. package/dist/codex-child-env.js +3 -32
  33. package/dist/codex-home.d.ts +35 -3
  34. package/dist/codex-home.js +323 -18
  35. package/dist/codex-session-store.d.ts +23 -0
  36. package/dist/codex-session-store.js +21 -0
  37. package/dist/host.d.ts +106 -48
  38. package/dist/host.js +2024 -640
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.js +1 -1
  41. package/dist/input-resources.d.ts +4 -0
  42. package/dist/input-resources.js +21 -5
  43. package/dist/models-catalog.js +12 -3
  44. package/dist/runner/child.d.ts +105 -28
  45. package/dist/runner/child.js +1625 -100
  46. package/dist/runner/manager.d.ts +114 -46
  47. package/dist/runner/manager.js +1523 -446
  48. package/dist/runner/protocol.d.ts +212 -24
  49. package/dist/runner/protocol.js +5 -0
  50. package/dist/runner/startup-policy.d.ts +7 -0
  51. package/dist/runner/startup-policy.js +10 -0
  52. package/dist/runner/transport.d.ts +18 -2
  53. package/dist/runner/transport.js +82 -3
  54. package/dist/runner-main.js +8 -3
  55. package/dist/terminal/codex-tui.d.ts +4 -0
  56. package/dist/terminal/codex-tui.js +5 -0
  57. package/dist/terminal/control-parser.d.ts +39 -0
  58. package/dist/terminal/control-parser.js +172 -0
  59. package/dist/terminal/registry.d.ts +18 -15
  60. package/dist/terminal/registry.js +44 -23
  61. package/dist/terminal/spool.d.ts +47 -0
  62. package/dist/terminal/spool.js +231 -0
  63. package/dist/terminal/tmux.d.ts +126 -74
  64. package/dist/terminal/tmux.js +807 -211
  65. package/package.json +4 -4
@@ -23,20 +23,39 @@
23
23
  */
24
24
  import type { AgentEvent, UserContentPart } from "@rynx-ai/core";
25
25
  import type { CodexAppServerClient } from "./client.js";
26
- import type { ResumedTurn } from "./protocol.js";
26
+ import type { McpStartupPlan } from "./mcp-startup.js";
27
+ import type { CollaborationModeKind, ReasoningEffort, ResumedTurn } from "./protocol.js";
27
28
  export interface CodexForwarderSink {
28
29
  /** A turn began. `turnId` is codex's turn id, used to derive a stable
29
30
  * `responseId`. Start a fresh normalizer/response. */
30
31
  onTurnStart(turnId?: string): void;
32
+ /** The observer received the provider's authoritative `turn/started` edge.
33
+ * Unlike `onTurnStart`, this is not fired early by turn/start acceptance. */
34
+ onTurnObserved?(turnId?: string): void;
31
35
  /** One mapped event within the current turn. */
32
36
  onEvent(event: AgentEvent): void;
37
+ /** Turn-scoped content arrived while no Provider Turn is active. Attach it
38
+ * to that response without opening a Turn or changing Session status. */
39
+ onTurnContentEvent?(turnId: string | undefined, event: AgentEvent): void;
40
+ /** Provider startup is session status, not a model item. Hosts that already
41
+ * published the response can forward it without synthesizing another start. */
42
+ onStatus?(note: string | undefined, statusKind?: "startup"): void;
33
43
  /** The current turn finished; `usage` is the runtime's raw snapshot if any. */
34
- onTurnEnd(usage?: Record<string, unknown>): void;
44
+ onTurnEnd(usage?: Record<string, unknown>, reason?: "superseded"): void;
45
+ /** The provider confirmed that the active turn was explicitly interrupted. */
46
+ onTurnInterrupted?(usage?: Record<string, unknown>): void;
47
+ /** Resume proved that the newest turn is terminal even though its live edge
48
+ * was missed. This updates session state without replaying historical items. */
49
+ onRecoveredTurnStatus?(status: "idle" | "failed", turnId: string | undefined, error?: Error): void;
35
50
  /** A turn failed on the runtime. */
36
51
  onTurnError(error: Error): void;
52
+ /** A steer rejection proves a recorded turn is inactive, without its outcome. */
53
+ onTurnInactive?(turnId: string): void;
37
54
  /** The user's turn text (sourced from codex's `userMessage` item), so a
38
55
  * co-driving TUI's prompt is recorded even though this process never injected it. */
39
56
  onUserMessage?(content: string | UserContentPart[]): void;
57
+ /** Out-of-lifecycle counterpart of `onUserMessage`, scoped when possible. */
58
+ onTurnContentUserMessage?(turnId: string | undefined, content: string | UserContentPart[]): void;
40
59
  /** A managed Core fork also broadcasts `thread/started`, but does not switch
41
60
  * the source TUI. Discard that notification before changing the bound thread. */
42
61
  shouldIgnoreThreadStarted?(threadId: string, forkedFromId?: string): boolean;
@@ -46,6 +65,22 @@ export interface CodexForwarderSink {
46
65
  /** The thread showed activity (a turn/item began, so its rollout now exists).
47
66
  * Fired once; lets a parked `thread/resume` retry (reference implementation's ready signal). */
48
67
  onThreadActive?(): void;
68
+ /** The native TUI or another app-server client changed collaboration mode. */
69
+ onCollaborationModeChanged?(mode: CollaborationModeKind): void;
70
+ /** Full mutable settings reported by the native thread. In particular, a
71
+ * TUI `/model` switch must become the model used by the next mode snapshot. */
72
+ onThreadSettingsChanged?(settings: {
73
+ model?: string;
74
+ reasoningEffort?: ReasoningEffort | null;
75
+ }): void;
76
+ /** Codex's terminal-local Plan picker is not emitted by app-server today.
77
+ * Synthesize it only after a live Plan item and its Turn both complete. */
78
+ onPlanImplementationPrompt?(prompt: CodexPlanImplementationPrompt): void;
79
+ }
80
+ export interface CodexPlanImplementationPrompt {
81
+ threadId: string;
82
+ turnId: string;
83
+ text: string;
49
84
  }
50
85
  export interface CodexSessionForwarderOptions {
51
86
  /** Some Codex-lineage runtimes publish the final item one frame after
@@ -58,6 +93,9 @@ export interface CodexSessionForwarderOptions {
58
93
  assistantMessageGraceMs?: number;
59
94
  /** Surface Traex's provider-capacity queue as a canonical running status. */
60
95
  surfaceQueueStatus?: boolean;
96
+ /** Provider-configured MCP servers. Their startup round is synthesized because
97
+ * Codex currently sends per-server edges only to the thread-owning TUI. */
98
+ mcpStartup?: McpStartupPlan | null;
61
99
  }
62
100
  export declare class CodexSessionForwarder {
63
101
  private readonly client;
@@ -69,9 +107,16 @@ export declare class CodexSessionForwarder {
69
107
  private currentThreadIdValue;
70
108
  private activeSignaled;
71
109
  private completionTimer;
110
+ /** Turn id retained only for late-item dedup while a terminal response waits
111
+ * for its bounded output-ordering grace. It is not an active provider turn. */
112
+ private pendingCompletionTurnId;
72
113
  private assistantMessageTimer;
73
114
  private deferredAssistantMessage;
74
115
  private pendingCompletion;
116
+ private readonly pendingMcpServers;
117
+ private readonly failedMcpServers;
118
+ private mcpStartupTimer;
119
+ private lastMcpStatusNote;
75
120
  /** Completed-item dedup keys already mirrored (live vs resume backfill). Key =
76
121
  * `threadId:turnId:item.id`; anonymous items use a per-(thread,turn) position
77
122
  * counter. Mirrors reference implementation `_completed_item_key` + `synced_item_keys`. */
@@ -79,16 +124,40 @@ export declare class CodexSessionForwarder {
79
124
  /** Per-(thread,turn) position counter for items lacking a stable codex id
80
125
  * (peek-then-advance; advanced only on a successful claim). reference implementation anon path. */
81
126
  private readonly anonCounters;
127
+ private pendingPlanImplementation;
128
+ /** Latest aggregate diff per Turn. Codex republishes the complete diff after
129
+ * every edit; only the terminal snapshot belongs in transcript history. */
130
+ private readonly turnDiffByTurn;
131
+ private replayingBackfill;
82
132
  constructor(client: CodexAppServerClient, sink: CodexForwarderSink, options?: CodexSessionForwarderOptions);
83
133
  /** Begin mirroring. Idempotent. */
84
134
  start(): void;
85
135
  stop(): void;
86
- /** True while a turn is open — injection uses `turn/steer` then, else `turn/start`. */
136
+ /** True while the provider owns an active turn, including the short interval
137
+ * between injection acceptance and observer confirmation. */
87
138
  isTurnOpen(): boolean;
88
139
  /** The current turn's codex id (only meaningful while {@link isTurnOpen}). */
89
140
  currentTurnId(): string | null;
141
+ /** Reconcile a proven stale steer without clearing a newer observed turn. */
142
+ clearActiveTurnIfMatches(turnId: string): void;
143
+ /**
144
+ * Record a turn accepted by the injection connection before the independent
145
+ * observer receives `turn/started`. This closes the read-decide-RPC-write race:
146
+ * another web message arriving in that window must steer this turn, not start
147
+ * a second one.
148
+ */
149
+ noteTurnAccepted(turnId: string): void;
150
+ hasPendingMcpStartup(): boolean;
151
+ /** Mark and return the startup servers cancelled by a web Stop. */
152
+ cancelMcpStartup(): string[];
153
+ /** Diagnostic suffix for an injection failure during Provider startup. */
154
+ mcpStartupDetail(): string | null;
90
155
  /** The bound codex thread id captured from `thread/started` (null until then). */
91
156
  threadId(): string | null;
157
+ /** Seed an already-persisted/resumed thread binding. The bridge retains this
158
+ * state even when app-server does not rebroadcast `thread/started`, so
159
+ * terminal-boundary recovery must know it too. */
160
+ noteThreadBound(threadId: string): void;
92
161
  /**
93
162
  * Replay the backlog turns from a `thread/resume` response as if they were live
94
163
  * `item/completed` notifications — the fresh-thread first-turn backfill. Each
@@ -97,11 +166,21 @@ export declare class CodexSessionForwarder {
97
166
  * not doubled.
98
167
  */
99
168
  replayBackfill(turns: ResumedTurn[]): void;
169
+ /** Suppress our synthesized picker when a future app-server emits the native
170
+ * `plan_implementation` request itself. */
171
+ noteNativePlanImplementationPrompt(turnId?: string): void;
172
+ /** Fail an open response exactly once when its observer or terminal exits. */
173
+ failOpenTurn(error: Error): boolean;
100
174
  private handle;
101
175
  private scheduleCompletion;
102
176
  private refreshCompletionGrace;
103
177
  private flushPendingCompletion;
104
178
  private settle;
179
+ private handleMcpStartupStatus;
180
+ private settleMcpStartup;
181
+ private clearMcpStartupTimer;
182
+ private emitMcpStartupStatus;
183
+ private emitMcpStatus;
105
184
  /** Map + emit one completed codex item, deduped by a TOTAL key and routing the
106
185
  * user echo to {@link CodexForwarderSink.onUserMessage}. Shared by live + backfill. */
107
186
  private processCompletedItem;
@@ -118,4 +197,18 @@ export declare class CodexSessionForwarder {
118
197
  private completedItemKey;
119
198
  private advanceAnonCounter;
120
199
  private ensureTurn;
200
+ private consumeTurnDiff;
201
+ /** Start (or confirm) the app-server's authoritative active turn. A newer
202
+ * start supersedes an older response whose terminal edge arrived late; a
203
+ * pending Traex completion is flushed first so its final item grace remains
204
+ * intact. */
205
+ private beginTurn;
206
+ /** Active-turn clearing contract:
207
+ *
208
+ * - an identified active turn is closed only by the same id;
209
+ * - an id-less boundary cannot close an identified active turn;
210
+ * - with no observed active turn, an identified boundary may recover a
211
+ * missed start only when it carries the currently-bound thread id. */
212
+ private terminalBoundaryMatchesActiveTurn;
213
+ private notificationMatchesCurrentThread;
121
214
  }