@rynx-ai/server 0.1.0 → 0.1.9

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 (63) hide show
  1. package/dist/browser-surface-control-queue.d.ts +42 -0
  2. package/dist/browser-surface-control-queue.js +187 -0
  3. package/dist/browser-surface-ws.d.ts +14 -0
  4. package/dist/browser-surface-ws.js +355 -0
  5. package/dist/control-api.d.ts +59 -4
  6. package/dist/control-api.js +2213 -132
  7. package/dist/control-web/assets/highlighted-body-OFNGDK62-e-w61YLy.js +1 -0
  8. package/dist/control-web/assets/index-BQ7XVBKO.css +32 -0
  9. package/dist/control-web/assets/index-ClpzuBJx.js +606 -0
  10. package/dist/control-web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  11. package/dist/control-web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  12. package/dist/control-web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  13. package/dist/control-web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  14. package/dist/control-web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  15. package/dist/control-web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  16. package/dist/control-web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  17. package/dist/control-web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  18. package/dist/control-web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  19. package/dist/control-web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  20. package/dist/control-web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  21. package/dist/control-web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  22. package/dist/control-web/assets/mermaid-GHXKKRXX-DZn7Hbr2.js +131 -0
  23. package/dist/control-web/assets/rynx-wordmark-LL1QRYHD.png +0 -0
  24. package/dist/control-web/favicon.png +0 -0
  25. package/dist/control-web/favicon.svg +38 -0
  26. package/dist/control-web/index.html +16 -0
  27. package/dist/control-web-dist.d.ts +1 -1
  28. package/dist/control-web-dist.js +19 -14
  29. package/dist/desktop-browser-host.d.ts +153 -0
  30. package/dist/desktop-browser-host.js +936 -0
  31. package/dist/direct-runtime-browser-surface-server.d.ts +74 -0
  32. package/dist/direct-runtime-browser-surface-server.js +821 -0
  33. package/dist/direct-runtime-server.d.ts +137 -0
  34. package/dist/direct-runtime-server.js +1931 -0
  35. package/dist/emulator-surface-ws.d.ts +6 -0
  36. package/dist/emulator-surface-ws.js +197 -0
  37. package/dist/machine-session-service.d.ts +182 -0
  38. package/dist/machine-session-service.js +559 -0
  39. package/dist/provider-cli-host.d.ts +10 -0
  40. package/dist/provider-cli-host.js +1 -0
  41. package/dist/remote-runtime-dispatcher.d.ts +94 -0
  42. package/dist/remote-runtime-dispatcher.js +380 -0
  43. package/dist/remote-runtime-session-projection.d.ts +19 -0
  44. package/dist/remote-runtime-session-projection.js +556 -0
  45. package/dist/remote-runtime.d.ts +22 -0
  46. package/dist/remote-runtime.js +32 -0
  47. package/dist/runtime-web-auth.d.ts +21 -0
  48. package/dist/runtime-web-auth.js +92 -0
  49. package/dist/server.d.ts +292 -10
  50. package/dist/server.js +314 -98
  51. package/dist/session-browser-service.d.ts +218 -0
  52. package/dist/session-browser-service.js +686 -0
  53. package/dist/session-browser-surface-coordinator.d.ts +23 -0
  54. package/dist/session-browser-surface-coordinator.js +563 -0
  55. package/dist/session-emulator-service.d.ts +167 -0
  56. package/dist/session-emulator-service.js +464 -0
  57. package/dist/session-runtime-index.d.ts +17 -0
  58. package/dist/session-runtime-index.js +86 -0
  59. package/dist/session-terminal-host.d.ts +46 -0
  60. package/dist/session-terminal-host.js +252 -0
  61. package/dist/terminal-ws.d.ts +9 -20
  62. package/dist/terminal-ws.js +420 -97
  63. package/package.json +9 -7
@@ -0,0 +1,92 @@
1
+ import { randomBytes, timingSafeEqual } from "node:crypto";
2
+ export const RUNTIME_WEB_CAPABILITY_HEADER = "x-rynx-runtime-capability";
3
+ export const RUNTIME_WEB_CAPABILITY_QUERY = "capability";
4
+ /**
5
+ * Process-lifetime CSRF capability shared by the Runtime HTTP BFF and its
6
+ * browser WebSocket upgrades. It is not a daemon-management credential.
7
+ */
8
+ export const RUNTIME_WEB_CAPABILITY = randomBytes(32).toString("base64url");
9
+ /**
10
+ * Authorize a browser request before any Runtime lease or terminal is opened.
11
+ * Socket address and the original Host header are both checked to resist DNS
12
+ * rebinding; mutation metadata and the capability provide the CSRF fence.
13
+ */
14
+ export function authorizeRuntimeWebRequest(request, options = {}) {
15
+ if (!isLoopbackAddress(request.socket.remoteAddress)) {
16
+ return { status: 403, error: "loopback_only" };
17
+ }
18
+ const host = originalHostHeader(request);
19
+ if (!host || !isLoopbackHostAuthority(host)) {
20
+ return { status: 403, error: "invalid_host" };
21
+ }
22
+ if (!options.mutation)
23
+ return undefined;
24
+ if (!isSameOriginBrowserMutation(request, host)) {
25
+ return { status: 403, error: "cross_origin" };
26
+ }
27
+ if (!safeTokenEquals(options.capability ?? "", RUNTIME_WEB_CAPABILITY)) {
28
+ return { status: 401, error: "invalid_runtime_capability" };
29
+ }
30
+ return undefined;
31
+ }
32
+ function isLoopbackAddress(value) {
33
+ const normalized = value?.startsWith("::ffff:") ? value.slice("::ffff:".length) : value;
34
+ return normalized === "127.0.0.1" || normalized === "::1";
35
+ }
36
+ /** Read the HTTP/1 Host header exactly as received; duplicate Hosts fail closed. */
37
+ function originalHostHeader(request) {
38
+ let host;
39
+ const raw = request.rawHeaders;
40
+ for (let index = 0; index < raw.length; index += 2) {
41
+ if (raw[index]?.toLowerCase() !== "host")
42
+ continue;
43
+ if (host !== undefined)
44
+ return undefined;
45
+ host = raw[index + 1];
46
+ }
47
+ return host;
48
+ }
49
+ function isLoopbackHostAuthority(value) {
50
+ if (value.length === 0 || value !== value.trim())
51
+ return false;
52
+ const match = /^(?:localhost|127\.0\.0\.1|\[::1\])(?::(\d{1,5}))?$/i.exec(value);
53
+ if (!match)
54
+ return false;
55
+ if (match[1] === undefined)
56
+ return true;
57
+ const port = Number(match[1]);
58
+ return Number.isInteger(port) && port >= 1 && port <= 65_535;
59
+ }
60
+ function isSameOriginBrowserMutation(request, host) {
61
+ const fetchSite = singleHeader(request.headers["sec-fetch-site"]).trim().toLowerCase();
62
+ if (fetchSite && fetchSite !== "same-origin")
63
+ return false;
64
+ const origin = singleHeader(request.headers.origin).trim();
65
+ if (origin) {
66
+ try {
67
+ const parsed = new URL(origin);
68
+ const directScheme = request.socket.encrypted ? "https" : "http";
69
+ const expected = new URL(`${directScheme}://${host}`);
70
+ if (parsed.username ||
71
+ parsed.password ||
72
+ parsed.pathname !== "/" ||
73
+ parsed.search ||
74
+ parsed.hash ||
75
+ parsed.origin !== expected.origin) {
76
+ return false;
77
+ }
78
+ }
79
+ catch {
80
+ return false;
81
+ }
82
+ }
83
+ return fetchSite === "same-origin" || origin.length > 0;
84
+ }
85
+ function singleHeader(value) {
86
+ return typeof value === "string" ? value : "";
87
+ }
88
+ function safeTokenEquals(actual, expected) {
89
+ const left = Buffer.from(actual, "utf8");
90
+ const right = Buffer.from(expected, "utf8");
91
+ return left.byteLength === right.byteLength && timingSafeEqual(left, right);
92
+ }
package/dist/server.d.ts CHANGED
@@ -1,11 +1,47 @@
1
+ import type { Server as HttpServer } from "node:http";
1
2
  import Koa from "koa";
2
- import { ConversationRuntime, type AppConfig, type ChannelFactory, type ChannelInstanceDescriptor, type SessionBus, type SessionLogStore, type SessionRegistry } from "@rynx-ai/core";
3
- import { RunnerManager, type CodexSessionStore } from "@rynx-ai/runtime";
3
+ import { ConversationRuntime, type AgentCapabilities, type AgentSessionStore, type AppConfig, type ChannelInstanceDescriptor, type SessionEvent, type SessionBus, type SessionLogStore, type SessionRegistry } from "@rynx-ai/core";
4
+ import type { SessionInteractionResolution } from "@rynx-ai/protocol";
5
+ import type { ControlRuntimeShareAddress } from "@rynx-ai/protocol/control";
6
+ import type { PairingOffer } from "@rynx-ai/protocol/direct-runtime";
7
+ import type { DaemonStatus } from "@rynx-ai/protocol/remote-runtime";
8
+ import type { RuntimeBrowserBootstrapCredential, RuntimeBrowserEndpointDescriptor } from "@rynx-ai/protocol/runtime-browser-bootstrap";
9
+ import type { RuntimeBrowserSurfaceClientFrame, RuntimeBrowserSurfaceImageFrame, RuntimeBrowserSurfaceOpenFrame, RuntimeBrowserSurfaceReadyFrame, RuntimeBrowserSurfaceServerFrame } from "@rynx-ai/protocol/runtime-browser-surface";
10
+ import type { RuntimeEmulatorSurfaceImageFrame, RuntimeEmulatorSurfaceReadyFrame } from "@rynx-ai/protocol/runtime-emulator-surface";
11
+ import type { RemoteRuntimeRpcMethod, RemoteRuntimeRpcParams, RemoteRuntimeRpcResultFor, RemoteRuntimeSequencedSessionEvent } from "@rynx-ai/protocol/remote-runtime-rpc";
12
+ import type { PluginAgentSummary, PluginResolvedSessionExecution, PluginSessionExecutionSnapshot } from "@rynx-ai/plugin-sdk";
13
+ import { RunnerManager, type CodexSessionStore, type RunnerSessionContextProvider } from "@rynx-ai/runtime";
4
14
  import { ChannelManager } from "./channel-manager.js";
5
- import { type ControlPlaneDeps } from "./control-api.js";
15
+ import { type ControlPlaneDeps, type SessionResourceLifecycle } from "./control-api.js";
16
+ import type { DaemonRuntimeHost } from "./remote-runtime.js";
17
+ import { type AttachDesktopBrowserHostServerOptions } from "./desktop-browser-host.js";
18
+ import { SessionRuntimeIndex } from "./session-runtime-index.js";
19
+ import type { SessionEmulatorService } from "./session-emulator-service.js";
20
+ import type { ProviderCliManagementHost } from "./provider-cli-host.js";
6
21
  export { ChannelManager } from "./channel-manager.js";
7
22
  export type { ChannelInstanceStatus } from "./channel-manager.js";
23
+ export type { ProviderCliManagementHost, ProviderCliStatusHost, } from "./provider-cli-host.js";
24
+ export { MachineSessionService, MachineSessionServiceFailure, MachineSessionServiceInputError, synthesizeSessionTitle, } from "./machine-session-service.js";
25
+ export type { MachineSessionAgentCatalogPort, MachineSessionCreateInput, MachineSessionCreateResult, MachineSessionDeleteResult, MachineSessionInterruptPort, MachineSessionInterruptResult, MachineSessionInteractionResult, MachineSessionListInput, MachineSessionListPage, MachineSessionMessageResult, MachineSessionRunnerPort, MachineSessionRuntimeStatePort, MachineSessionServiceFailureCode, MachineSessionServiceOptions, MachineSessionServicePorts, MachineSessionSnapshotInput, MachineSessionSnapshotPage, MachineSessionWatch, } from "./machine-session-service.js";
26
+ export { SessionBrowserHostError, SessionBrowserService, SessionBrowserServiceError, SessionBrowserSurfaceUnsupportedError, } from "./session-browser-service.js";
27
+ export type { SessionBrowserHost, SessionBrowserHostCreateInput, SessionBrowserHostErrorCode, SessionBrowserHostEvent, SessionBrowserHostHandle, SessionBrowserHostPage, SessionBrowserHostSurfaceFrame, SessionBrowserHostSurfaceOpenInput, SessionBrowserHostSurfaceSource, SessionBrowserHostSurfaceTrustedInput, SessionBrowserHostSurfaceViewport, SessionBrowserHostSnapshot, SessionBrowserRegistryPort, SessionBrowserServiceErrorCode, SessionBrowserServiceOptions, SessionBrowserServicePorts, SessionBrowserSurfaceOpenInput, SessionBrowserSurfaceSource, } from "./session-browser-service.js";
28
+ export { SessionEmulatorBindingConflictError, SessionEmulatorService, SessionEmulatorServiceError, } from "./session-emulator-service.js";
29
+ export type { SessionEmulatorBindingRecord, SessionEmulatorBindingStore, SessionEmulatorServiceErrorCode, SessionEmulatorServiceOptions, SessionEmulatorSurface, } from "./session-emulator-service.js";
30
+ export { SessionBrowserSurfaceCoordinator } from "./session-browser-surface-coordinator.js";
31
+ export type { SessionBrowserSurfaceCoordinatorOptions, } from "./session-browser-surface-coordinator.js";
32
+ export { attachDesktopBrowserHostServer, createDesktopFirstSessionBrowserHost, DesktopBrowserHostAbsentError, DesktopBrowserHostProtocolError, DesktopBrowserHostRegistry, } from "./desktop-browser-host.js";
33
+ export type { AttachDesktopBrowserHostServerOptions, DesktopBrowserHostRegistryOptions, } from "./desktop-browser-host.js";
8
34
  export type { ControlPlaneDeps, StoredSessionMeta } from "./control-api.js";
35
+ export { createDaemonRuntimeHost, encodeDaemonStatus } from "./remote-runtime.js";
36
+ export type { DaemonRuntimeHost, DaemonRuntimeSnapshot } from "./remote-runtime.js";
37
+ export { DIRECT_RUNTIME_CONTROL_PATH, DirectRuntimeConnectionHub, startDirectRuntimeServer, } from "./direct-runtime-server.js";
38
+ export type { DirectRuntimeAuthenticationResult, DirectRuntimeAuthenticator, DirectRuntimeEmulatorSurfaceAttachment, DirectRuntimeEmulatorSurfaceHost, DirectRuntimePeer, DirectRuntimeServer, DirectRuntimeServerLimits, StartDirectRuntimeServerOptions, } from "./direct-runtime-server.js";
39
+ export { attachDirectRuntimeBrowserSurfaceServer, DirectRuntimeBrowserSurfaceHostError, } from "./direct-runtime-browser-surface-server.js";
40
+ export type { AttachDirectRuntimeBrowserSurfaceServerOptions, DirectRuntimeBrowserSurfaceAttachment, DirectRuntimeBrowserSurfaceAttachmentEvent, DirectRuntimeBrowserSurfaceConnectionHub, DirectRuntimeBrowserSurfaceHost, DirectRuntimeBrowserSurfaceServer, DirectRuntimeBrowserSurfaceServerLimits, DirectRuntimeBrowserSurfaceTransportCloseReason, } from "./direct-runtime-browser-surface-server.js";
41
+ export { RemoteRuntimeDispatcher } from "./remote-runtime-dispatcher.js";
42
+ export type { AuthenticatedRuntimeSubject, RemoteRuntimeEmulatorHost, RemoteRuntimeSessionEmulatorHost, RemoteRuntimeDispatchContext, RemoteRuntimeDispatcherOptions, } from "./remote-runtime-dispatcher.js";
43
+ export { createRunnerSessionTerminalHost, SessionTerminalOpenError, SessionTerminalStreamError, } from "./session-terminal-host.js";
44
+ export type { RunnerSessionTerminalHostOptions, SessionTerminalAttachment, SessionTerminalCloseInfo, SessionTerminalCloseReason, SessionTerminalHost, SessionTerminalOpenErrorCode, SessionTerminalOpenOptions, SessionTerminalRole, } from "./session-terminal-host.js";
9
45
  export type { ControlChannel, ControlChannelType, ControlInstanceConfig, ControlInstanceStatus, ControlAgentSummary, } from "@rynx-ai/protocol/control";
10
46
  export interface CreateAppOptions {
11
47
  config?: AppConfig;
@@ -20,16 +56,25 @@ export interface CreateAppOptions {
20
56
  sessionLog?: SessionLogStore;
21
57
  runnerManager?: RunnerManager;
22
58
  sessionStore?: CodexSessionStore;
59
+ pluginRuntimeStatus?: () => unknown;
60
+ pluginRuntimeReload?: (pluginId: string) => Promise<unknown>;
61
+ pluginRuntimeEnsure?: (pluginId: string) => Promise<unknown>;
62
+ daemonManagement?: DaemonManagementHost;
63
+ remoteRuntime?: DaemonRuntimeHost;
64
+ remoteRuntimeAdmin?: RemoteRuntimeAdminHost;
65
+ runtimeTargetControl?: RuntimeTargetControlHost;
66
+ runtimeConnectionResolver?: RuntimeConnectionResolverHost;
67
+ sessionEmulators?: SessionEmulatorService;
68
+ /** Host lifecycle signal for ending SSE/video streams before drain. */
69
+ shutdownSignal?: AbortSignal;
70
+ sessionRuntimeIndex?: SessionRuntimeIndex;
71
+ sessionLifecycle?: SessionResourceLifecycle;
72
+ runtimeLocalBrowser?: RuntimeLocalBrowserAutomationHost;
73
+ providerClis?: ProviderCliManagementHost;
23
74
  };
24
75
  }
25
76
  export interface StartServerOptions {
26
77
  config?: AppConfig;
27
- /**
28
- * Legacy: channel plugins to mount as one shared-context batch. Kept for
29
- * back-compat (and tests); the daemon now uses {@link loadInstances} so each
30
- * instance gets its own context. Empty ⇒ a pure `/health` server.
31
- */
32
- channelFactories?: ChannelFactory[];
33
78
  /** Static set of channel instances to mount, each with its own context. */
34
79
  channelInstances?: ChannelInstanceDescriptor[];
35
80
  /**
@@ -55,7 +100,244 @@ export interface StartServerOptions {
55
100
  * per session; the control plane lists every session uniformly from it.
56
101
  */
57
102
  sessionRegistry?: SessionRegistry;
103
+ /** Trusted daemon-side bridge for isolated plugin runners. Installed plugin
104
+ * code never receives these objects; the bridge projects capability-gated
105
+ * JSON RPC from them. */
106
+ pluginRuntime?: PluginRuntimeLifecycle;
107
+ /** Narrow, loopback-only bridge for resident-daemon management clients. */
108
+ daemonManagement?: DaemonManagementHost;
109
+ /** Transport-independent Remote Runtime application port. */
110
+ remoteRuntime?: DaemonRuntimeHost;
111
+ /** Loopback-only enrollment and client-grant administration. */
112
+ remoteRuntimeAdmin?: RemoteRuntimeAdminHost;
113
+ /** Local BFF authority for explicit Local or Direct Runtime targets. */
114
+ runtimeTargetControl?: RuntimeTargetControlHost;
115
+ /** Secret-owning backend resolver for explicit Local or Direct Runtime calls. */
116
+ runtimeConnectionResolver?: RuntimeConnectionResolverHost;
117
+ /** Runtime-owned Session Emulator binding authority for Local compatibility routes. */
118
+ sessionEmulators?: SessionEmulatorService;
119
+ /** Pre-composed daemon-owned Session runtime. Supplying this lets the daemon
120
+ * inject the same application service into Local HTTP and Direct Runtime
121
+ * adapters without mirroring Session state into another owner. */
122
+ sessionRuntimeServices?: SessionRuntimeServices;
123
+ /** Shared fence for Session-owned resources on canonical and legacy deletes. */
124
+ sessionLifecycle?: SessionResourceLifecycle;
125
+ /** Runtime-local, Session-capability-authorized CDP bootstrap. Never remote. */
126
+ runtimeLocalBrowser?: RuntimeLocalBrowserAutomationHost;
127
+ /** Runtime-owned provider CLI inspection and local lifecycle operations. */
128
+ providerClis?: ProviderCliManagementHost;
129
+ /** Private resident-app Browser Host socket, authenticated by daemonManagement. */
130
+ desktopBrowserHost?: Omit<AttachDesktopBrowserHostServerOptions, "managementToken">;
131
+ }
132
+ export interface SessionRuntimeServices {
133
+ sessionStore: CodexSessionStore;
134
+ runnerManager: RunnerManager;
135
+ sessionBus: SessionBus;
136
+ sessionRuntimeIndex: SessionRuntimeIndex;
137
+ conversationRuntime: ConversationRuntime;
138
+ }
139
+ export interface PluginRuntimeHostServices {
140
+ conversationRuntime: ConversationRuntime;
141
+ capabilities: AgentCapabilities;
142
+ sessionStore: AgentSessionStore;
143
+ sessionRegistry: SessionRegistry;
144
+ agentCatalog: {
145
+ list(): Promise<PluginAgentSummary[]>;
146
+ get(id: string): Promise<PluginAgentSummary | null>;
147
+ resolveExecution(input: {
148
+ defaultAgent?: string;
149
+ session: PluginSessionExecutionSnapshot;
150
+ }): Promise<PluginResolvedSessionExecution>;
151
+ };
152
+ interruptSession(sessionId: string): Promise<boolean>;
153
+ resolveSessionInteraction(sessionId: string, interactionId: string, resolution: SessionInteractionResolution): Promise<{
154
+ disposition: "applied" | "already_resolved" | "not_found" | "invalid";
155
+ }>;
156
+ }
157
+ export interface PluginRuntimeLifecycle {
158
+ bindHostServices(services: PluginRuntimeHostServices): void;
159
+ startPluginRuntimes(): Promise<void>;
160
+ reloadPluginRuntime(pluginId: string): Promise<unknown>;
161
+ ensurePluginRuntime(pluginId: string): Promise<unknown>;
162
+ /** Cached process/contribution health; must not block on plugin RPC. */
163
+ statusSnapshot(): unknown;
164
+ dispose(): Promise<void>;
165
+ }
166
+ export interface DaemonControlIdentity {
167
+ installationId: string;
168
+ algorithm: "Ed25519";
169
+ publicKey: string;
170
+ }
171
+ export interface PluginCliInvocationInput {
172
+ pluginId: string;
173
+ args: string[];
174
+ stdin?: string;
175
+ }
176
+ export interface PluginCliInvocationOutput {
177
+ code: number;
178
+ stdout: string;
179
+ stderr: string;
180
+ truncated: boolean;
181
+ }
182
+ export interface DaemonManagementInvocationContext {
183
+ signal: AbortSignal;
184
+ }
185
+ /** The complete local management authority injected by the daemon composition root. */
186
+ export interface DaemonManagementHost {
187
+ managementToken: string;
188
+ identity(): DaemonControlIdentity;
189
+ invokePluginCli(input: PluginCliInvocationInput, context: DaemonManagementInvocationContext): Promise<PluginCliInvocationOutput>;
190
+ }
191
+ /**
192
+ * Runtime-local Browser automation bootstrap. Returning `undefined` means the
193
+ * Session capability was not accepted; implementations must not reveal which
194
+ * half of the credential was wrong.
195
+ */
196
+ export interface RuntimeLocalBrowserAutomationHost {
197
+ authorizeCredential(credential: RuntimeBrowserBootstrapCredential): boolean | Promise<boolean>;
198
+ endpointForCredential(credential: RuntimeBrowserBootstrapCredential): Promise<RuntimeBrowserEndpointDescriptor | undefined>;
199
+ endpointForSession(sessionId: string): Promise<RuntimeBrowserEndpointDescriptor>;
200
+ }
201
+ export interface RemoteRuntimeClientGrantView {
202
+ grantId: string;
203
+ clientId: string;
204
+ clientLabel: string | null;
205
+ clientKeyFingerprint: string;
206
+ authorities: string[];
207
+ createdAt: string;
208
+ revokedAt: string | null;
209
+ lastUsedAt: string | null;
210
+ }
211
+ /** Local operator authority for enabling new Direct clients and revoking them. */
212
+ export interface RemoteRuntimeAdminHost {
213
+ listShareAddresses(): ControlRuntimeShareAddress[];
214
+ createPairingOffer(input?: {
215
+ clientLabel?: string;
216
+ /** Host or ws(s) endpoint advertised by this individual access link. */
217
+ address?: string;
218
+ }): PairingOffer;
219
+ listClientGrants(): RemoteRuntimeClientGrantView[];
220
+ revokeClientGrant(grantId: string): {
221
+ revoked: boolean;
222
+ closedConnections: number;
223
+ };
224
+ }
225
+ /** Secret-free Runtime target projection safe for the local Control Plane UI. */
226
+ export interface RuntimeTargetView {
227
+ /** Client-local selector: the reserved `local` selector or an opaque daemon id. */
228
+ selector: string;
229
+ daemonId: string;
230
+ displayName: string;
231
+ binding: "local" | "direct";
232
+ endpoint?: string;
233
+ identityKeyFingerprint?: string;
234
+ createdAt?: string;
235
+ }
236
+ export interface RuntimeTargetTestResult {
237
+ target: RuntimeTargetView;
238
+ status: DaemonStatus;
239
+ }
240
+ export interface RuntimeTargetPairResult {
241
+ target: RuntimeTargetView;
242
+ /** Authenticated status probe completed before the target is reported paired. */
243
+ status: DaemonStatus;
244
+ }
245
+ /** Local backend seam; credentials and pinned identity keys never cross it. */
246
+ export interface RuntimeTargetControlHost {
247
+ list(): RuntimeTargetView[] | Promise<RuntimeTargetView[]>;
248
+ pair(input: {
249
+ offer: unknown;
250
+ displayName?: string;
251
+ }): RuntimeTargetPairResult | Promise<RuntimeTargetPairResult>;
252
+ test(selector: string): RuntimeTargetTestResult | Promise<RuntimeTargetTestResult>;
253
+ forget(daemonId: string): {
254
+ forgotten: true;
255
+ } | Promise<{
256
+ forgotten: true;
257
+ }>;
258
+ }
259
+ /** Secret-free logical Runtime connection leased by the local Control Plane BFF. */
260
+ export interface RuntimeConnectionLease {
261
+ readonly target: {
262
+ selector: string;
263
+ daemonId: string;
264
+ };
265
+ call<M extends RemoteRuntimeRpcMethod>(method: M, params: RemoteRuntimeRpcParams<M>, options?: {
266
+ signal?: AbortSignal;
267
+ timeoutMs?: number;
268
+ }): Promise<RemoteRuntimeRpcResultFor<M>>;
269
+ subscribeSessionEvents(sessionId: string, options?: {
270
+ signal?: AbortSignal;
271
+ timeoutMs?: number;
272
+ }): Promise<RuntimeSessionEventsSubscription>;
273
+ openSessionTerminal(sessionId: string, options: {
274
+ role: "owner" | "read-only";
275
+ cols: number;
276
+ rows: number;
277
+ signal?: AbortSignal;
278
+ timeoutMs?: number;
279
+ }): Promise<import("./session-terminal-host.js").SessionTerminalAttachment>;
280
+ openBrowserSurface(frame: RuntimeBrowserSurfaceOpenFrame, options?: {
281
+ signal?: AbortSignal;
282
+ timeoutMs?: number;
283
+ }): Promise<RuntimeBrowserSurfaceConnection>;
284
+ openEmulatorSurface(sessionId: string, bindingId: string, options?: {
285
+ signal?: AbortSignal;
286
+ timeoutMs?: number;
287
+ maximumFrameRate?: number;
288
+ }): Promise<RuntimeEmulatorSurfaceConnection>;
289
+ release(): void;
290
+ }
291
+ /** Secret-free Browser presentation stream owned by one selected Runtime. */
292
+ export interface RuntimeBrowserSurfaceConnection extends AsyncIterable<RuntimeBrowserSurfaceEvent> {
293
+ readonly ready: RuntimeBrowserSurfaceReadyFrame;
294
+ send(frame: Exclude<RuntimeBrowserSurfaceClientFrame, RuntimeBrowserSurfaceOpenFrame>): Promise<void>;
295
+ close(): Promise<void>;
58
296
  }
297
+ export type RuntimeBrowserSurfaceEvent = Exclude<RuntimeBrowserSurfaceServerFrame, RuntimeBrowserSurfaceReadyFrame> | RuntimeBrowserSurfaceImageFrame;
298
+ export interface RuntimeEmulatorSurfaceConnection extends AsyncIterable<RuntimeEmulatorSurfaceImageFrame> {
299
+ readonly ready: RuntimeEmulatorSurfaceReadyFrame;
300
+ sendTouch(point: {
301
+ phase: "begin" | "move" | "end";
302
+ x: number;
303
+ y: number;
304
+ }): Promise<void>;
305
+ close(): Promise<void>;
306
+ }
307
+ /** One Runtime-owned live Session tail. The lease must outlive this handle. */
308
+ export interface RuntimeSessionEventsSubscription extends AsyncIterable<RemoteRuntimeSequencedSessionEvent> {
309
+ readonly sessionId: string;
310
+ readonly daemonInstanceId: string;
311
+ close(): Promise<void>;
312
+ }
313
+ /** Application-facing half of the daemon-owned connection manager. */
314
+ export interface RuntimeConnectionResolverHost {
315
+ acquire(selector: string, options?: {
316
+ signal?: AbortSignal;
317
+ }): Promise<RuntimeConnectionLease>;
318
+ }
319
+ /** HTTP server plus an idempotent join point for all daemon-owned resources. */
320
+ export interface RynxServer extends HttpServer {
321
+ shutdown(): Promise<void>;
322
+ }
323
+ /** Preserve one session's mirror order without serializing unrelated sessions. */
324
+ export declare class SessionMirrorQueue {
325
+ private readonly persist;
326
+ private readonly tails;
327
+ constructor(persist: (sessionId: string, event: SessionEvent) => Promise<void>);
328
+ enqueue(sessionId: string, event: SessionEvent): Promise<void>;
329
+ }
330
+ /**
331
+ * Compose the process-owned Session runtime once. The daemon may call this
332
+ * before creating its Direct dispatcher; {@link startServer} accepts the same
333
+ * bundle and therefore does not create a second bus, runtime index, or runner.
334
+ */
335
+ export declare function createSessionRuntimeServices(input: {
336
+ config: AppConfig;
337
+ sessionLog?: SessionLogStore;
338
+ onMirrorError?: (error: unknown, sessionId: string) => void;
339
+ sessionContextProvider?: RunnerSessionContextProvider;
340
+ }): SessionRuntimeServices;
59
341
  /**
60
342
  * The HTTP surface is just a liveness probe for container orchestration — all
61
343
  * agent capabilities are forwarded through the mounted channel plugins (the
@@ -63,4 +345,4 @@ export interface StartServerOptions {
63
345
  * no agent request / response / SSE endpoints are exposed here.
64
346
  */
65
347
  export declare function createApp({ control }?: CreateAppOptions): Koa<Koa.DefaultState, Koa.DefaultContext>;
66
- export declare function startServer({ config, channelFactories, channelInstances, loadInstances, control, sessionLog, sessionRegistry, }?: StartServerOptions): Promise<import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>>;
348
+ export declare function startServer({ config, channelInstances, loadInstances, control, sessionLog, sessionRegistry, pluginRuntime, daemonManagement, remoteRuntime, remoteRuntimeAdmin, runtimeTargetControl, runtimeConnectionResolver, sessionEmulators, sessionRuntimeServices, sessionLifecycle, runtimeLocalBrowser, providerClis, desktopBrowserHost, }?: StartServerOptions): Promise<RynxServer>;