@opengeni/runtime 4.6.0 → 4.7.0-canary.37090756480001

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 (72) hide show
  1. package/dist/agent-instructions/modules/media.d.ts +3 -0
  2. package/dist/anthropic-messages.d.ts +13 -3
  3. package/dist/anthropic-request-error.d.ts +10 -0
  4. package/dist/assets/codemode-client.json +1 -1
  5. package/dist/{chunk-A22BKN4P.js → chunk-LJNCGUMB.js} +3 -3
  6. package/dist/chunk-LJNCGUMB.js.map +1 -0
  7. package/dist/{chunk-GTWKWJ67.js → chunk-P2OVGKDG.js} +505 -100
  8. package/dist/chunk-P2OVGKDG.js.map +1 -0
  9. package/dist/{chunk-D5DPVA2C.js → chunk-R25L27T3.js} +2047 -1275
  10. package/dist/chunk-R25L27T3.js.map +1 -0
  11. package/dist/claude-subscription-usage.d.ts +14 -4
  12. package/dist/context-compaction.d.ts +7 -7
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +13 -3
  15. package/dist/interaction-tools.d.ts +1 -1
  16. package/dist/mcp-network.js +1 -1
  17. package/dist/runtime-skills.d.ts +1 -0
  18. package/dist/sandbox/channel-a.d.ts +3 -0
  19. package/dist/sandbox/index.d.ts +3 -1
  20. package/dist/sandbox/index.js +7 -1
  21. package/dist/sandbox/provider-command-session.d.ts +21 -0
  22. package/dist/sandbox/providers/modal-command-argv.d.ts +4 -0
  23. package/dist/sandbox/providers/modal-command-control.d.ts +17 -5
  24. package/dist/sandbox/providers/modal-command-observation-errors.d.ts +3 -0
  25. package/dist/sandbox/providers/modal-command-raw-page.d.ts +100 -0
  26. package/dist/sandbox/providers/modal-command-router-wire.d.ts +17 -0
  27. package/dist/sandbox/routing/routing-session.d.ts +10 -0
  28. package/dist/sandbox/turn-tool-cancellation.d.ts +4 -0
  29. package/dist/workspace-tool-gateway.js +3 -3
  30. package/package.json +12 -12
  31. package/src/agent-instructions/PROMPT_CHANGELOG.md +23 -1
  32. package/src/agent-instructions/compose.ts +2 -0
  33. package/src/agent-instructions/modules/media.ts +20 -0
  34. package/src/agent-instructions/runtime-mechanics.ts +8 -0
  35. package/src/anthropic-messages.ts +223 -31
  36. package/src/anthropic-request-error.ts +45 -0
  37. package/src/bundled_default_skills/opengeni-client/SKILL.md +9 -7
  38. package/src/bundled_default_skills/opengeni-client/references/agent-recipes.md +1 -1
  39. package/src/bundled_default_skills/opengeni-client/references/api-workflows.md +61 -0
  40. package/src/bundled_default_skills/opengeni-client/references/compatibility-and-troubleshooting.md +86 -0
  41. package/src/bundled_default_skills/opengeni-client/references/data-tools-and-credentials.md +82 -0
  42. package/src/bundled_default_skills/opengeni-client/references/discovery-and-autonomy.md +32 -25
  43. package/src/bundled_default_skills/opengeni-client/references/external-users-and-connect.md +17 -0
  44. package/src/bundled_default_skills/opengeni-client/references/product-shapes-and-ui.md +156 -0
  45. package/src/bundled_schedule_skills/opengeni-schedules/SKILL.md +56 -0
  46. package/src/claude-subscription-usage.ts +55 -9
  47. package/src/context-compaction.ts +16 -9
  48. package/src/index.ts +85 -18
  49. package/src/interaction-tools.ts +113 -3
  50. package/src/lazy-tool-transport.ts +26 -10
  51. package/src/mcp-network.ts +4 -2
  52. package/src/model-provider-client.ts +11 -3
  53. package/src/model-provider-routing.ts +4 -0
  54. package/src/runtime-skills.ts +8 -0
  55. package/src/sandbox/channel-a.ts +3 -0
  56. package/src/sandbox/index.ts +11 -1
  57. package/src/sandbox/provider-command-session.ts +58 -0
  58. package/src/sandbox/provider-errors.ts +43 -9
  59. package/src/sandbox/providers/modal-command-argv.ts +20 -0
  60. package/src/sandbox/providers/modal-command-control.ts +422 -116
  61. package/src/sandbox/providers/modal-command-observation-errors.ts +65 -0
  62. package/src/sandbox/providers/modal-command-raw-page.ts +147 -0
  63. package/src/sandbox/providers/modal-command-router-wire.ts +104 -12
  64. package/src/sandbox/providers/modal-command-session.ts +26 -4
  65. package/src/sandbox/providers/modal-legacy-command-control.ts +2 -9
  66. package/src/sandbox/providers/modal-materialization-verification.ts +70 -6
  67. package/src/sandbox/routing/routing-session.ts +140 -41
  68. package/src/sandbox/run-credentials.ts +62 -19
  69. package/src/sandbox/turn-tool-cancellation.ts +159 -42
  70. package/dist/chunk-A22BKN4P.js.map +0 -1
  71. package/dist/chunk-D5DPVA2C.js.map +0 -1
  72. package/dist/chunk-GTWKWJ67.js.map +0 -1
@@ -1,7 +1,17 @@
1
- type Observer = (providerId: string, response: Response) => void;
2
- type Prepare = (providerId: string, headers: Headers) => Promise<Headers>;
1
+ type Observer = (providerId: string, response: Response, upstreamModelId?: string, requestToken?: string | null) => void;
2
+ type PreparedUsageRequest = {
3
+ headers: Headers;
4
+ observe: Observer;
5
+ };
6
+ type Prepare = (providerId: string, headers: Headers) => Promise<Headers | PreparedUsageRequest>;
7
+ /** The native adapter knows the exact model without reading or cloning the wire body. */
8
+ export declare function withClaudeModelRequest<T>(upstreamModelId: string, run: () => Promise<T>): Promise<T>;
3
9
  /** Like Codex usage headers: free observations within this turn's provider context. */
4
10
  export declare function withClaudeUsageObserver<T>(observer: Observer, run: () => Promise<T>, prepare?: Prepare): Promise<T>;
5
- export declare function prepareClaudeSubscriptionRequest(providerId: string, input: Parameters<typeof fetch>[0], init?: RequestInit): Promise<RequestInit | undefined>;
6
- export declare function observeClaudeUsageResponse(providerId: string, response: Response): void;
11
+ export declare function prepareClaudeSubscriptionRequest(providerId: string, input: Parameters<typeof fetch>[0], init?: RequestInit): Promise<{
12
+ init: RequestInit | undefined;
13
+ observe(response: Response, requestToken?: string | null): void;
14
+ }>;
15
+ export declare function captureClaudeRequestToken(input: Parameters<typeof fetch>[0], init?: RequestInit): string | null | undefined;
16
+ export declare function observeClaudeUsageResponse(providerId: string, response: Response, requestToken?: string | null): void;
7
17
  export {};
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * The checkpoint model sees the current active history plus one fixed
5
5
  * checkpoint prompt, then the active history is rebuilt from the newest real
6
- * user messages within one cumulative 20k-token budget plus one summary.
7
- * Assistant messages, tool calls/results, reasoning, and images are removed
8
- * from the active model-facing history; the database audit rows remain.
6
+ * user/system input messages within one cumulative 20k-token budget plus one summary.
7
+ * Assistant messages, tool calls/results, and reasoning are removed from the
8
+ * active model-facing history; retained input images and database audit rows remain.
9
9
  */
10
10
  export type CompactionItem = Record<string, unknown>;
11
11
  /**
@@ -28,7 +28,7 @@ export declare const COMPACTION_PROMPT: string;
28
28
  export declare const SUMMARY_PREFIX = "Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:";
29
29
  export declare const USER_MESSAGE_TRUNCATION_MARKER = "\n[... middle truncated for context compaction ...]\n";
30
30
  export declare const REMOTE_COMPACTION_TOOL_RESULT_OMISSION = "[OpenGeni omitted tool result body for context compaction retry]";
31
- /** A user-authored `message` item is the only legal turn boundary. */
31
+ /** A real user-role `message` item. */
32
32
  export declare function isUserMessage(item: unknown): boolean;
33
33
  /** True for our synthetic compaction summary item. */
34
34
  export declare function isCompactionSummary(item: unknown): boolean;
@@ -264,17 +264,17 @@ export declare function omitOpaqueArtifactsFromPortableCompactionHistory(items:
264
264
  export declare function prepareCompactionPromptInput(items: readonly CompactionItem[], maxInputTokens: number): PreparedCompactionPromptInput;
265
265
  /**
266
266
  * Build the active history after compaction:
267
- * the newest real user messages that fit one cumulative, model-bounded budget
267
+ * the newest user/system input messages that fit one cumulative, model-bounded budget
268
268
  * (prior summaries excluded, retained images preserved) plus one marked summary item.
269
269
  */
270
270
  export declare function buildCompactionReplacementHistory(items: readonly CompactionItem[], summaryBody: string, retainedItemTokens?: (item: CompactionItem) => number, retainedMessageBudgetTokens?: number): CompactionItem[];
271
271
  /** True for a Codex remote-compaction output item with opaque encrypted content. */
272
272
  export declare function isRemoteCompactionItem(item: unknown): item is CompactionItem;
273
- /** Messages retained beside a remote v2 compaction blob (user + developer). */
273
+ /** Messages retained beside a remote v2 compaction blob (user + system + developer). */
274
274
  export declare function isRetainedRemoteV2Message(item: unknown): boolean;
275
275
  /**
276
276
  * Build the active history after Codex remote compaction v2:
277
- * newest retained user/developer messages within the CLI 64k budget plus the
277
+ * newest retained user/system/developer messages within the CLI 64k budget plus the
278
278
  * opaque `{ type: "compaction", encrypted_content }` item.
279
279
  *
280
280
  * Both modes preserve retained image parts. Charge their projected image
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { preparedCompactionRequest, queuePreparedCompaction } from "./prepared-compaction-request.js";
2
+ export { AnthropicProviderRejection } from "./anthropic-messages.js";
2
3
  import type { ModelProviderApi, ResolvedModelProvider, Settings } from "@opengeni/config";
3
4
  import { RunMcpCredentials } from "./mcp-run-credentials.js";
4
5
  export { RunMcpCredentials, RunMcpCredentialError } from "./mcp-run-credentials.js";
6
+ export { AnthropicRequestError } from "./anthropic-request-error.js";
5
7
  import { type McpOperationPersistence } from "./mcp-operation-dispatch.js";
6
8
  export { captureMcpOperationDispatch, hasActiveRecoverableMcpOperation, McpOperationOutcomeUnknownError, runRecoverableMcpOperation, type CapturedMcpOperation, type McpOperationPersistence, type RecoverableMcpOperation, } from "./mcp-operation-dispatch.js";
7
9
  export { assertMcpOperationObservationAuthority, observeMcpOperation, runMcpOperationObservationWithAuthority, type McpOperationObservationAuthority, type McpObservationBinding, type McpObservationReceipt, } from "./mcp-operation-observation.js";
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  AGENT_PROMPT_MODULES,
3
+ AnthropicProviderRejection,
4
+ AnthropicRequestError,
3
5
  AssistantMessagePhaseTracker,
4
6
  CODEMODE_PROGRAMMATIC_DIRECTIVE,
5
7
  CODE_SEARCH_DIRECTIVE,
@@ -294,7 +296,7 @@ import {
294
296
  workspaceEnvironmentInstructions,
295
297
  wrapAttemptToolDefinitions,
296
298
  wrapAttemptToolExecute
297
- } from "./chunk-GTWKWJ67.js";
299
+ } from "./chunk-P2OVGKDG.js";
298
300
  import {
299
301
  ActiveBackendUnresolvableError,
300
302
  BROWSER_CONTROL_ADMIN_TOKEN_FILE,
@@ -345,6 +347,7 @@ import {
345
347
  OpenSandboxClient,
346
348
  OpenSandboxSession,
347
349
  PROVIDER_REGISTRY,
350
+ ProviderCommandObservationUnavailableError,
348
351
  ProviderCommandStartOutcomeUnknownError,
349
352
  REPOSITORY_DISCOVERY_LIMIT,
350
353
  RecordingError,
@@ -464,6 +467,7 @@ import {
464
467
  isModalTaskExecStartPreDispatchUnavailableError,
465
468
  isOpenSandboxLifecycleProxyPath,
466
469
  isProviderApiThrottleError,
470
+ isProviderCommandObservationUnavailableError,
467
471
  isProviderSandboxGoneDuringRoutedOperation,
468
472
  isProviderSandboxNotFoundError,
469
473
  isProviderSandboxTransientError,
@@ -507,6 +511,7 @@ import {
507
511
  readWorkspaceArchiveFromEnvelopeSessionState,
508
512
  recordingStorageKey,
509
513
  redactOpenSandboxSignedUriPath,
514
+ reduceModalRawOutputPage,
510
515
  relativeConnectedMachinePath,
511
516
  renderRoutingMutationOutcomeUnknownToolResult,
512
517
  renderSelfhostedFault,
@@ -576,7 +581,7 @@ import {
576
581
  withRunCredentialsClient,
577
582
  withRunCredentialsSession,
578
583
  withoutSandboxProviderIdentity
579
- } from "./chunk-D5DPVA2C.js";
584
+ } from "./chunk-R25L27T3.js";
580
585
  import "./chunk-7KVMU7O3.js";
581
586
  import "./chunk-4A4XTKKX.js";
582
587
  import "./chunk-GUJMCB7F.js";
@@ -593,7 +598,7 @@ import {
593
598
  skillArtifactContentSha256,
594
599
  skillLibraryRepositoryUrl
595
600
  } from "./chunk-KAPAZSUC.js";
596
- import "./chunk-A22BKN4P.js";
601
+ import "./chunk-LJNCGUMB.js";
597
602
  import {
598
603
  GMAIL_REST_API_BASE,
599
604
  GMAIL_REST_MCP_TOOLS,
@@ -609,6 +614,8 @@ import "./chunk-PZ5AY32C.js";
609
614
  export {
610
615
  AGENT_PROMPT_MODULES,
611
616
  ActiveBackendUnresolvableError,
617
+ AnthropicProviderRejection,
618
+ AnthropicRequestError,
612
619
  AssistantMessagePhaseTracker,
613
620
  BROWSER_CONTROL_ADMIN_TOKEN_FILE,
614
621
  BROWSER_CONTROL_PORT,
@@ -715,6 +722,7 @@ export {
715
722
  PROVIDER_QUOTA_EXHAUSTED_CODE,
716
723
  PROVIDER_REGISTRY,
717
724
  PrefixedMcpServer,
725
+ ProviderCommandObservationUnavailableError,
718
726
  ProviderCommandStartOutcomeUnknownError,
719
727
  ProviderHistoryIncompatibleError,
720
728
  REMOTE_COMPACTION_TOOL_RESULT_OMISSION,
@@ -965,6 +973,7 @@ export {
965
973
  isOfficialGmailMcpConfig,
966
974
  isOpenSandboxLifecycleProxyPath,
967
975
  isProviderApiThrottleError,
976
+ isProviderCommandObservationUnavailableError,
968
977
  isProviderSandboxGoneDuringRoutedOperation,
969
978
  isProviderSandboxNotFoundError,
970
979
  isProviderSandboxTransientError,
@@ -1063,6 +1072,7 @@ export {
1063
1072
  recordModelPreparationMeasurement,
1064
1073
  recordingStorageKey,
1065
1074
  redactOpenSandboxSignedUriPath,
1075
+ reduceModalRawOutputPage,
1066
1076
  refreshCodemodeTokenFile,
1067
1077
  refreshGitCredentialBindingTokenFiles,
1068
1078
  refreshGitProviderTokenFiles,
@@ -3,7 +3,7 @@ import { type Settings } from "@opengeni/config";
3
3
  import type { AttemptToolDefinition, AttemptToolScope } from "@opengeni/codemode";
4
4
  import { type InteractionTransport } from "@opengeni/sdk";
5
5
  import { z } from "zod";
6
- export declare const INTERACTION_ATTEMPT_TOOL_NAMES: readonly ["interaction_discover", "browser_open", "browser_tabs", "browser_observe", "browser_read", "browser_screenshot", "browser_act", "browser_clipboard", "browser_debug", "browser_auth", "interaction_request_human", "browser_identity", "browser_publish", "browser_lifecycle", "computer_open", "computer_targets", "computer_observe", "computer_clipboard", "computer_act", "computer_lifecycle"];
6
+ export declare const INTERACTION_ATTEMPT_TOOL_NAMES: readonly ["interaction_discover", "browser_open", "browser_tabs", "browser_observe", "browser_read", "browser_screenshot", "browser_act", "browser_clipboard", "browser_debug", "browser_downloads", "browser_download_save", "browser_auth", "interaction_request_human", "browser_identity", "browser_publish", "browser_lifecycle", "computer_open", "computer_targets", "computer_observe", "computer_clipboard", "computer_act", "computer_lifecycle"];
7
7
  export type InteractionAttemptToolName = (typeof INTERACTION_ATTEMPT_TOOL_NAMES)[number];
8
8
  export type InteractionInterventionResume = {
9
9
  toolCallId: string;
@@ -30,7 +30,7 @@ import {
30
30
  mcpSerializedSizeBytes,
31
31
  mcpTransportRequestFailureDiagnostic,
32
32
  undiciFetch
33
- } from "./chunk-A22BKN4P.js";
33
+ } from "./chunk-LJNCGUMB.js";
34
34
  import "./chunk-PZ5AY32C.js";
35
35
  export {
36
36
  MCP_DEFAULT_OUTER_CONNECT_TIMEOUT_MS,
@@ -33,6 +33,7 @@ export type NativeToolSkillSet = Readonly<{
33
33
  defaults?: boolean;
34
34
  editableArtifacts: boolean;
35
35
  sites?: boolean;
36
+ schedules?: boolean;
36
37
  videoGeneration: boolean;
37
38
  }>;
38
39
  export type EffectiveSkillSelection = Readonly<{
@@ -66,6 +66,7 @@ export type ChannelASession = ProviderCommandSession & {
66
66
  chars?: string;
67
67
  yieldTimeMs?: number;
68
68
  maxOutputTokens?: number;
69
+ signal?: AbortSignal;
69
70
  }): Promise<string>;
70
71
  writeStdinForProcessMutation?(args: {
71
72
  sessionId: number;
@@ -81,6 +82,8 @@ export type ChannelASession = ProviderCommandSession & {
81
82
  }): Promise<string>;
82
83
  cancelExecCommand?(opId: string): Promise<boolean>;
83
84
  hasRetainedProcess?(providerSessionId: number): boolean;
85
+ /** Cleanup only: forget the local route after exact durable terminal proof. */
86
+ reconcileRetainedProcess?(providerSessionId: number): Promise<boolean>;
84
87
  retainedProcessHasTypedHandleLoss?(providerSessionId: number): boolean;
85
88
  execCommandForProcessControl?(providerSessionId: number, args: ChannelAExecArgs): Promise<string>;
86
89
  createEditor?(runAs?: string): ChannelAEditor;
@@ -1,7 +1,9 @@
1
1
  export type { ProviderCommandPersistence, ProviderCommandSession, } from "./provider-command-session.js";
2
- export { ProviderCommandStartOutcomeUnknownError } from "./provider-command-session.js";
2
+ export { ProviderCommandStartOutcomeUnknownError, ProviderCommandObservationUnavailableError, isProviderCommandObservationUnavailableError, } from "./provider-command-session.js";
3
3
  import type { Settings } from "@opengeni/config";
4
4
  export type { WorkspaceArchiveSpool, VerifiedHostWorkspaceArchive } from "./archive-spool.js";
5
+ export { reduceModalRawOutputPage } from "./providers/modal-command-raw-page.js";
6
+ export type { ModalRawOutputPage, ModalRawOutputStreams, ModalRawOutputExit, } from "./providers/modal-command-raw-page.js";
5
7
  import type { WorkspaceArchiveSpool } from "./archive-spool.js";
6
8
  export { captureWorkspaceArchiveForStorage, disposeWorkspaceArchive, type VerifiedWorkspaceArchivePayload, } from "./workspace-archive.js";
7
9
  import { type WorkspaceArchiveObjectRef, type SandboxBackend, type SandboxProviderContinuityRecovery } from "@opengeni/contracts";
@@ -48,6 +48,7 @@ import {
48
48
  OpenSandboxClient,
49
49
  OpenSandboxSession,
50
50
  PROVIDER_REGISTRY,
51
+ ProviderCommandObservationUnavailableError,
51
52
  ProviderCommandStartOutcomeUnknownError,
52
53
  REPOSITORY_DISCOVERY_LIMIT,
53
54
  RecordingError,
@@ -166,6 +167,7 @@ import {
166
167
  isModalTaskExecStartPreDispatchUnavailableError,
167
168
  isOpenSandboxLifecycleProxyPath,
168
169
  isProviderApiThrottleError,
170
+ isProviderCommandObservationUnavailableError,
169
171
  isProviderSandboxGoneDuringRoutedOperation,
170
172
  isProviderSandboxNotFoundError,
171
173
  isProviderSandboxTransientError,
@@ -208,6 +210,7 @@ import {
208
210
  readWorkspaceArchiveFromEnvelopeSessionState,
209
211
  recordingStorageKey,
210
212
  redactOpenSandboxSignedUriPath,
213
+ reduceModalRawOutputPage,
211
214
  relativeConnectedMachinePath,
212
215
  renderRoutingMutationOutcomeUnknownToolResult,
213
216
  renderSelfhostedFault,
@@ -277,7 +280,7 @@ import {
277
280
  withRunCredentialsClient,
278
281
  withRunCredentialsSession,
279
282
  withoutSandboxProviderIdentity
280
- } from "../chunk-D5DPVA2C.js";
283
+ } from "../chunk-R25L27T3.js";
281
284
  import "../chunk-7KVMU7O3.js";
282
285
  import "../chunk-4A4XTKKX.js";
283
286
  import "../chunk-GUJMCB7F.js";
@@ -333,6 +336,7 @@ export {
333
336
  OpenSandboxClient,
334
337
  OpenSandboxSession,
335
338
  PROVIDER_REGISTRY,
339
+ ProviderCommandObservationUnavailableError,
336
340
  ProviderCommandStartOutcomeUnknownError,
337
341
  REPOSITORY_DISCOVERY_LIMIT,
338
342
  RecordingError,
@@ -451,6 +455,7 @@ export {
451
455
  isModalTaskExecStartPreDispatchUnavailableError,
452
456
  isOpenSandboxLifecycleProxyPath,
453
457
  isProviderApiThrottleError,
458
+ isProviderCommandObservationUnavailableError,
454
459
  isProviderSandboxGoneDuringRoutedOperation,
455
460
  isProviderSandboxNotFoundError,
456
461
  isProviderSandboxTransientError,
@@ -493,6 +498,7 @@ export {
493
498
  readWorkspaceArchiveFromEnvelopeSessionState,
494
499
  recordingStorageKey,
495
500
  redactOpenSandboxSignedUriPath,
501
+ reduceModalRawOutputPage,
496
502
  relativeConnectedMachinePath,
497
503
  renderRoutingMutationOutcomeUnknownToolResult,
498
504
  renderSelfhostedFault,
@@ -43,6 +43,27 @@ export declare class ProviderCommandStartOutcomeUnknownError extends Error {
43
43
  readonly command: ModalRouterProviderCommand;
44
44
  constructor(command: ModalRouterProviderCommand, cause: unknown);
45
45
  }
46
+ /** A reserved stdin byte range was sent once but its acknowledgement was lost.
47
+ * The original process remains observation authority, never input replay authority. */
48
+ export declare class ProviderCommandInputOutcomeUnknownError extends Error {
49
+ readonly command: SandboxProviderCommand;
50
+ readonly byteOffset: number;
51
+ readonly byteLength: number;
52
+ constructor(command: SandboxProviderCommand, byteOffset: number, byteLength: number, cause: unknown);
53
+ }
54
+ /** An already-dispatched invocation could not be observed within this read's
55
+ * budget. The exact locator is read authority, never Start/input replay authority. */
56
+ export declare class ProviderCommandObservationUnavailableError extends Error {
57
+ readonly command: SandboxProviderCommand;
58
+ /** Mixed or unreadable provider graphs can contain observation failure
59
+ * without proving that an automatic read retry is safe. */
60
+ readonly readRetryAllowed: boolean;
61
+ constructor(command: SandboxProviderCommand, cause: unknown,
62
+ /** Mixed or unreadable provider graphs can contain observation failure
63
+ * without proving that an automatic read retry is safe. */
64
+ readRetryAllowed?: boolean);
65
+ }
66
+ export declare function isProviderCommandObservationUnavailableError(error: unknown): boolean;
46
67
  export type ProviderCommandSession = {
47
68
  verifyCommandSupervisionCapability?(): Promise<{
48
69
  sandboxId: string;
@@ -0,0 +1,4 @@
1
+ import type { ChannelAExecArgs } from "../channel-a.js";
2
+ /** Keep the command payload once in argv. Embedding it in each run-as branch
3
+ * multiplies large lifecycle scripts past the provider's aggregate limit. */
4
+ export declare function modalCommandArgv(args: ChannelAExecArgs): string[];
@@ -1,11 +1,16 @@
1
- import { SandboxProviderCommand, CommandSupervisionReceipt, type ModalRouterProviderCommand } from "@opengeni/contracts";
1
+ import { SandboxProviderCommand, CommandSupervisionReceipt, ModalRouterProviderCommand } from "@opengeni/contracts";
2
2
  import type { ChannelAExecArgs } from "../channel-a.js";
3
3
  import type { ProviderCommandOutput } from "../provider-command-session.js";
4
4
  import { commandControlPlane } from "./modal-legacy-command-control.js";
5
+ import { type ModalRawOutputPage } from "./modal-command-raw-page.js";
5
6
  export { modalCommandAbortMiddleware } from "./modal-legacy-command-control.js";
6
7
  export type ModalProviderCommand = SandboxProviderCommand;
7
8
  export type ModalProviderOutputPage = ProviderCommandOutput;
8
9
  type Client = Parameters<typeof commandControlPlane>[0];
10
+ type SupervisionControlResult = {
11
+ state: "idle" | "running" | "quiescent";
12
+ receipt?: CommandSupervisionReceipt;
13
+ };
9
14
  /** New commands use replayable task-router byte offsets. Legacy identifiers
10
15
  * never cross that protocol boundary and are never used for new starts. */
11
16
  export declare class ModalCommandControl {
@@ -13,6 +18,8 @@ export declare class ModalCommandControl {
13
18
  private readonly root;
14
19
  private readonly environment;
15
20
  private readonly routers;
21
+ private readonly routerLookups;
22
+ private readonly controlHelpers;
16
23
  private readonly client;
17
24
  private readonly legacy;
18
25
  private closed;
@@ -38,11 +45,16 @@ export declare class ModalCommandControl {
38
45
  verifyExecReadiness(signal: AbortSignal): Promise<number>;
39
46
  /** Separate authenticated provider execution of the installed control helper.
40
47
  * User command streams are never inspected for control evidence. */
41
- supervisionControl(command: ModalRouterProviderCommand, action: "release" | "cancel" | "status" | "ack", receiptId?: string): Promise<{
42
- state: "idle" | "running" | "quiescent";
43
- receipt?: CommandSupervisionReceipt;
44
- }>;
48
+ supervisionControl(command: ModalRouterProviderCommand, action: "release" | "cancel" | "status" | "ack", receiptId?: string): Promise<SupervisionControlResult>;
49
+ /** These fixed helpers already started once. Observe only their original
50
+ * invocation within the caller's existing five-second budget. */
51
+ private readControlOutput;
45
52
  read(command: ModalProviderCommand, waitMs: number, signal?: AbortSignal): Promise<ModalProviderOutputPage>;
53
+ /** Native capture plumbing only. Raw bytes are acquired by the same joined
54
+ * read/poll path as read(); no legacy locator or new command is admitted. */
55
+ readRaw(command: ModalRouterProviderCommand, waitMs: number, signal?: AbortSignal): Promise<ModalRawOutputPage>;
56
+ private readNative;
57
+ private readRouterPage;
46
58
  readProbe(command: ModalProviderCommand, waitMs: number, cancellation: AbortController): Promise<ModalProviderOutputPage>;
47
59
  write(command: ModalProviderCommand, chars: string, index: number): Promise<void>;
48
60
  }
@@ -0,0 +1,3 @@
1
+ /** Only used inside a read-only provider RPC boundary. This is deliberately
2
+ * not a Start classifier: remote DNS prose never proves non-dispatch. */
3
+ export declare function isModalCommandObservationTransportError(error: unknown): boolean;
@@ -0,0 +1,100 @@
1
+ import { z } from "zod";
2
+ import { ModalRouterProviderCommand } from "@opengeni/contracts";
3
+ import type { ProviderCommandOutput } from "../provider-command-session.js";
4
+ declare const RawPage: z.ZodObject<{
5
+ protocol: z.ZodLiteral<"modal-router-raw-page-v1">;
6
+ expected: z.ZodObject<{
7
+ kind: z.ZodLiteral<"modal-router-v1">;
8
+ sandboxId: z.ZodString;
9
+ taskId: z.ZodString;
10
+ execId: z.ZodString;
11
+ pty: z.ZodOptional<z.ZodBoolean>;
12
+ supervision: z.ZodOptional<z.ZodObject<{
13
+ protocol: z.ZodLiteral<"native-subreaper-v1">;
14
+ invocationId: z.ZodString;
15
+ nonce: z.ZodString;
16
+ controlPath: z.ZodString;
17
+ }, z.core.$strict>>;
18
+ streams: z.ZodObject<{
19
+ stdout: z.ZodObject<{
20
+ byteOffset: z.ZodNumber;
21
+ utf8Remainder: z.ZodString;
22
+ eof: z.ZodBoolean;
23
+ exitCode: z.ZodNullable<z.ZodNumber>;
24
+ }, z.core.$strict>;
25
+ stderr: z.ZodObject<{
26
+ byteOffset: z.ZodNumber;
27
+ utf8Remainder: z.ZodString;
28
+ eof: z.ZodBoolean;
29
+ exitCode: z.ZodNullable<z.ZodNumber>;
30
+ }, z.core.$strict>;
31
+ }, z.core.$strict>;
32
+ }, z.core.$strict>;
33
+ command: z.ZodObject<{
34
+ kind: z.ZodLiteral<"modal-router-v1">;
35
+ sandboxId: z.ZodString;
36
+ taskId: z.ZodString;
37
+ execId: z.ZodString;
38
+ pty: z.ZodOptional<z.ZodBoolean>;
39
+ supervision: z.ZodOptional<z.ZodObject<{
40
+ protocol: z.ZodLiteral<"native-subreaper-v1">;
41
+ invocationId: z.ZodString;
42
+ nonce: z.ZodString;
43
+ controlPath: z.ZodString;
44
+ }, z.core.$strict>>;
45
+ streams: z.ZodObject<{
46
+ stdout: z.ZodObject<{
47
+ byteOffset: z.ZodNumber;
48
+ utf8Remainder: z.ZodString;
49
+ eof: z.ZodBoolean;
50
+ exitCode: z.ZodNullable<z.ZodNumber>;
51
+ }, z.core.$strict>;
52
+ stderr: z.ZodObject<{
53
+ byteOffset: z.ZodNumber;
54
+ utf8Remainder: z.ZodString;
55
+ eof: z.ZodBoolean;
56
+ exitCode: z.ZodNullable<z.ZodNumber>;
57
+ }, z.core.$strict>;
58
+ }, z.core.$strict>;
59
+ }, z.core.$strict>;
60
+ streams: z.ZodObject<{
61
+ stdout: z.ZodObject<{
62
+ bytes: z.ZodPipe<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>;
63
+ eof: z.ZodBoolean;
64
+ }, z.core.$strict>;
65
+ stderr: z.ZodObject<{
66
+ bytes: z.ZodPipe<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>;
67
+ eof: z.ZodBoolean;
68
+ }, z.core.$strict>;
69
+ }, z.core.$strict>;
70
+ exit: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ source: z.ZodLiteral<"router_poll">;
72
+ code: z.ZodNullable<z.ZodNumber>;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ source: z.ZodLiteral<"retained_terminal">;
75
+ code: z.ZodNumber;
76
+ }, z.core.$strict>], "source">;
77
+ }, z.core.$strict>;
78
+ /** Bounded native RPC bytes and their exact cursor projection. The source tag
79
+ * distinguishes a fresh poll from previously captured terminal evidence; it
80
+ * does not authenticate an object supplied by a caller. No Start, custody,
81
+ * database settlement or parent completion authority is conveyed. */
82
+ export type ModalRawOutputPage = z.infer<typeof RawPage>;
83
+ export type ModalRawOutputStreams = ModalRawOutputPage["streams"];
84
+ export type ModalRawOutputExit = ModalRawOutputPage["exit"];
85
+ type NativeOutput = ProviderCommandOutput & {
86
+ expected: ModalRouterProviderCommand;
87
+ command: ModalRouterProviderCommand;
88
+ };
89
+ /** Provider-private construction from joined read/poll replies. Keep the SDK
90
+ * projection unchanged; this pure helper itself is not provider proof. */
91
+ export declare function collectModalRawOutputPage(command: ModalRouterProviderCommand, streams: ModalRawOutputStreams, exit: ModalRawOutputExit): {
92
+ raw: ModalRawOutputPage;
93
+ output: NativeOutput;
94
+ };
95
+ /** Recompute decoded output from exact bytes, never caller-decoded text. The
96
+ * current cursor must come from the caller's authoritative store. Equality
97
+ * checks are not a database CAS; coherent bytes still need trusted acquisition
98
+ * and atomic capture by the owner. */
99
+ export declare function reduceModalRawOutputPage(input: ModalRawOutputPage, current: ModalRouterProviderCommand): NativeOutput;
100
+ export {};
@@ -50,17 +50,33 @@ export type ModalRouterStart = ModalRouterIdentity & {
50
50
  noTerminateOnIdleStdin: boolean;
51
51
  };
52
52
  };
53
+ declare const preparedStartBrand: unique symbol;
54
+ /** An in-memory, single-use request on its issuing transport, NOT command
55
+ * admission or durable dispatch authority. Copies/serialized identities cannot
56
+ * be dispatched. The caller still owns authorization before physical Start. */
57
+ export type ModalRouterPreparedStart = Readonly<ModalRouterIdentity> & {
58
+ readonly [preparedStartBrand]: true;
59
+ };
53
60
  /** A single authenticated transport, owned and closed by its command adapter.
54
61
  * Reads may stop at a byte boundary because the next read resumes at that exact
55
62
  * offset. Mutations are never retried by this layer, including ambiguous starts.
56
63
  */
57
64
  export declare class ModalCommandRouterWire {
65
+ #private;
58
66
  private readonly client;
59
67
  private readonly metadata;
60
68
  private closed;
61
69
  constructor(access: ModalRouterAccess, trustedRoots?: Buffer);
62
70
  close(): void;
63
71
  private unary;
72
+ /** Read-only transport preparation. It sends neither Start nor stdin and
73
+ * does not invoke a caller's dispatch/admission callback. Prevalidation is not
74
+ * wire proof: gRPC still serializes at RPC invocation after dispatch begins. */
75
+ prepareStart(request: ModalRouterStart, signal?: AbortSignal): Promise<ModalRouterPreparedStart>;
76
+ /** No readiness, route lookup or retry here. Consume the authentic local
77
+ * handle synchronously before RPC, including when cancellation/closure wins.
78
+ * Once spent it never resets, even if no acknowledgement was received. */
79
+ dispatchPreparedStart(prepared: ModalRouterPreparedStart, signal?: AbortSignal): Promise<void>;
64
80
  start(request: ModalRouterStart, signal?: AbortSignal): Promise<void>;
65
81
  write(identity: ModalRouterIdentity, offset: number, data: Uint8Array, signal?: AbortSignal): Promise<void>;
66
82
  poll(identity: ModalRouterIdentity, signal?: AbortSignal): Promise<number | null>;
@@ -69,3 +85,4 @@ export declare class ModalCommandRouterWire {
69
85
  eof: boolean;
70
86
  }>;
71
87
  }
88
+ export {};
@@ -205,6 +205,12 @@ export interface RoutingSandboxSessionDeps {
205
205
  process: RoutingRetainedProcess;
206
206
  proof: RoutingRetainedProcessTerminalProof;
207
207
  }) => Promise<void>;
208
+ /** Read terminal truth for this exact copied process/backend. Missing rows,
209
+ * failed observations and active rows must never count as physical proof. */
210
+ isProcessSettled?: (input: {
211
+ backend: ResolvedActiveBackend;
212
+ process: RoutingRetainedProcess;
213
+ }) => Promise<boolean>;
208
214
  /** A terminal result is being returned to the model, not merely drained by
209
215
  * control/reaper work. Never invoke this for a running receipt. */
210
216
  observeProcessTerminal?: (input: {
@@ -486,6 +492,10 @@ export declare class RoutingSandboxSession implements RoutableBackendSession {
486
492
  * backend that yielded it. This synchronous probe is used only to select the
487
493
  * process-aware routing surface; it is not itself durable authority. */
488
494
  hasRetainedProcess(providerSessionId: number): boolean;
495
+ /** A reaper may have settled the command while a local capture/control receipt
496
+ * remained pending. Cleanup may consume that same durable proof without
497
+ * replaying a provider operation or accepting pending output into the model. */
498
+ reconcileRetainedProcess(providerSessionId: number): Promise<boolean>;
489
499
  /** Local, Docker, and OpenSandbox process ids address an in-memory table on one worker
490
500
  * session object. They are not valid durable locators for the independently
491
501
  * scheduled reaper, so their yielded handles stay turn-owned until terminal
@@ -9,6 +9,7 @@ type CommandCancellationSession = {
9
9
  supportsPty?(): boolean;
10
10
  supportsCommandInput?(providerSessionId: number): boolean;
11
11
  hasRetainedProcess?(providerSessionId: number): boolean;
12
+ reconcileRetainedProcess?(providerSessionId: number): Promise<boolean>;
12
13
  retainedProcessHasTypedHandleLoss?(providerSessionId: number): boolean;
13
14
  /** Whether the provider locator remains controllable from another worker
14
15
  * process after this turn returns. */
@@ -23,18 +24,21 @@ type CommandCancellationSession = {
23
24
  chars?: string;
24
25
  yieldTimeMs?: number;
25
26
  maxOutputTokens?: number;
27
+ signal?: AbortSignal;
26
28
  }): Promise<string>;
27
29
  writeStdinForProcessMutation?(args: {
28
30
  sessionId: number;
29
31
  chars?: string;
30
32
  yieldTimeMs?: number;
31
33
  maxOutputTokens?: number;
34
+ signal?: AbortSignal;
32
35
  }): Promise<string>;
33
36
  writeStdinForProcessControl?(args: {
34
37
  sessionId: number;
35
38
  chars?: string;
36
39
  yieldTimeMs?: number;
37
40
  maxOutputTokens?: number;
41
+ signal?: AbortSignal;
38
42
  }): Promise<string>;
39
43
  execCommandForProcessControl?(providerSessionId: number, args: TurnSandboxCommandArgs): Promise<string>;
40
44
  };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  prepareAgentTools
3
- } from "./chunk-GTWKWJ67.js";
4
- import "./chunk-D5DPVA2C.js";
3
+ } from "./chunk-P2OVGKDG.js";
4
+ import "./chunk-R25L27T3.js";
5
5
  import "./chunk-7KVMU7O3.js";
6
6
  import "./chunk-4A4XTKKX.js";
7
7
  import "./chunk-GUJMCB7F.js";
8
8
  import "./chunk-KAPAZSUC.js";
9
- import "./chunk-A22BKN4P.js";
9
+ import "./chunk-LJNCGUMB.js";
10
10
  import "./chunk-YU4VRTR4.js";
11
11
  import "./chunk-ISNIWRWB.js";
12
12
  import "./chunk-PZ5AY32C.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "4.6.0",
3
+ "version": "4.7.0-canary.37090756480001",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,17 +63,17 @@
63
63
  "@openai/agents": "0.14.3",
64
64
  "@openai/agents-core": "0.14.3",
65
65
  "@openai/agents-extensions": "0.14.3",
66
- "@opengeni/agent-proto": "^0.6.1",
67
- "@opengeni/capabilities": "^0.3.5",
68
- "@opengeni/codemode": "^0.6.8",
69
- "@opengeni/codex": "^0.2.31",
70
- "@opengeni/config": "^3.2.1",
71
- "@opengeni/contracts": "^5.6.0",
72
- "@opengeni/network": "^0.3.1",
73
- "@opengeni/observability": "^0.8.37",
74
- "@opengeni/sdk": "^7.6.1",
75
- "@opengeni/tool-gateway": "^0.1.18",
76
- "@opengeni/xai-subscription": "^0.1.5",
66
+ "@opengeni/agent-proto": "^0.6.1-canary.37090756480001",
67
+ "@opengeni/capabilities": "^0.3.6-canary.37090756480001",
68
+ "@opengeni/codemode": "^0.7.0-canary.37090756480001",
69
+ "@opengeni/codex": "^0.2.32-canary.37090756480001",
70
+ "@opengeni/config": "^3.3.0-canary.37090756480001",
71
+ "@opengeni/contracts": "^5.7.0-canary.37090756480001",
72
+ "@opengeni/network": "^0.3.1-canary.37090756480001",
73
+ "@opengeni/observability": "^0.8.38-canary.37090756480001",
74
+ "@opengeni/sdk": "^7.7.0-canary.37090756480001",
75
+ "@opengeni/tool-gateway": "^0.1.19-canary.37090756480001",
76
+ "@opengeni/xai-subscription": "^0.1.5-canary.37090756480001",
77
77
  "debug": "4.4.3",
78
78
  "modal": "0.9.0",
79
79
  "openai": "6.47.0",