@opengeni/runtime 4.6.0 → 4.7.0-canary.37111190284001

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 (75) 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-D5DPVA2C.js → chunk-3QG5IL64.js} +2436 -1355
  6. package/dist/chunk-3QG5IL64.js.map +1 -0
  7. package/dist/{chunk-A22BKN4P.js → chunk-LJNCGUMB.js} +3 -3
  8. package/dist/chunk-LJNCGUMB.js.map +1 -0
  9. package/dist/{chunk-GTWKWJ67.js → chunk-YLRVEUJ7.js} +527 -103
  10. package/dist/chunk-YLRVEUJ7.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 +17 -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 +4 -1
  20. package/dist/sandbox/index.js +11 -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 +40 -0
  27. package/dist/sandbox/providers/modal-native-create-preparation.d.ts +208 -0
  28. package/dist/sandbox/routing/routing-session.d.ts +10 -0
  29. package/dist/sandbox/turn-tool-cancellation.d.ts +4 -0
  30. package/dist/workspace-tool-gateway.js +3 -3
  31. package/package.json +12 -12
  32. package/src/agent-instructions/PROMPT_CHANGELOG.md +23 -1
  33. package/src/agent-instructions/compose.ts +2 -0
  34. package/src/agent-instructions/modules/media.ts +20 -0
  35. package/src/agent-instructions/runtime-mechanics.ts +8 -0
  36. package/src/anthropic-messages.ts +223 -31
  37. package/src/anthropic-request-error.ts +45 -0
  38. package/src/bundled_default_skills/opengeni-client/SKILL.md +14 -9
  39. package/src/bundled_default_skills/opengeni-client/references/agent-recipes.md +17 -1
  40. package/src/bundled_default_skills/opengeni-client/references/api-workflows.md +61 -0
  41. package/src/bundled_default_skills/opengeni-client/references/compatibility-and-troubleshooting.md +86 -0
  42. package/src/bundled_default_skills/opengeni-client/references/configure-the-agent.md +19 -0
  43. package/src/bundled_default_skills/opengeni-client/references/data-tools-and-credentials.md +82 -0
  44. package/src/bundled_default_skills/opengeni-client/references/discovery-and-autonomy.md +32 -25
  45. package/src/bundled_default_skills/opengeni-client/references/external-users-and-connect.md +17 -0
  46. package/src/bundled_default_skills/opengeni-client/references/product-shapes-and-ui.md +157 -1
  47. package/src/bundled_schedule_skills/opengeni-schedules/SKILL.md +56 -0
  48. package/src/claude-subscription-usage.ts +55 -9
  49. package/src/context-compaction.ts +16 -9
  50. package/src/index.ts +120 -21
  51. package/src/interaction-tools.ts +113 -3
  52. package/src/lazy-tool-transport.ts +26 -10
  53. package/src/mcp-network.ts +4 -2
  54. package/src/model-provider-client.ts +11 -3
  55. package/src/model-provider-routing.ts +4 -0
  56. package/src/runtime-skills.ts +8 -0
  57. package/src/sandbox/channel-a.ts +3 -0
  58. package/src/sandbox/index.ts +19 -1
  59. package/src/sandbox/provider-command-session.ts +58 -0
  60. package/src/sandbox/provider-errors.ts +43 -9
  61. package/src/sandbox/providers/modal-command-argv.ts +20 -0
  62. package/src/sandbox/providers/modal-command-control.ts +422 -116
  63. package/src/sandbox/providers/modal-command-observation-errors.ts +65 -0
  64. package/src/sandbox/providers/modal-command-raw-page.ts +147 -0
  65. package/src/sandbox/providers/modal-command-router-wire.ts +202 -12
  66. package/src/sandbox/providers/modal-command-session.ts +26 -4
  67. package/src/sandbox/providers/modal-legacy-command-control.ts +2 -9
  68. package/src/sandbox/providers/modal-materialization-verification.ts +70 -6
  69. package/src/sandbox/providers/modal-native-create-preparation.ts +338 -0
  70. package/src/sandbox/routing/routing-session.ts +140 -41
  71. package/src/sandbox/run-credentials.ts +62 -19
  72. package/src/sandbox/turn-tool-cancellation.ts +159 -42
  73. package/dist/chunk-A22BKN4P.js.map +0 -1
  74. package/dist/chunk-D5DPVA2C.js.map +0 -1
  75. 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-YLRVEUJ7.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,
@@ -418,6 +421,7 @@ import {
418
421
  codemodeTokenFileForSession,
419
422
  codemodeTokenFileFromEnvironment,
420
423
  collectSandboxEnvironment,
424
+ compileNativeFreshCreate,
421
425
  connectedMachinePathWithinRoot,
422
426
  connectedMachineWorkspaceRootsEqual,
423
427
  contentTypeForCodec,
@@ -433,6 +437,7 @@ import {
433
437
  deleteModalCheckpointSnapshot,
434
438
  deleteRecordingArtifacts,
435
439
  describeLegacyNativeSnapshotArchive,
440
+ describeNativeFreshCreate,
436
441
  describeNativeSnapshotArchive,
437
442
  deserializeSandboxSessionStateEnvelope,
438
443
  desktopCapableBackend,
@@ -464,6 +469,7 @@ import {
464
469
  isModalTaskExecStartPreDispatchUnavailableError,
465
470
  isOpenSandboxLifecycleProxyPath,
466
471
  isProviderApiThrottleError,
472
+ isProviderCommandObservationUnavailableError,
467
473
  isProviderSandboxGoneDuringRoutedOperation,
468
474
  isProviderSandboxNotFoundError,
469
475
  isProviderSandboxTransientError,
@@ -507,6 +513,7 @@ import {
507
513
  readWorkspaceArchiveFromEnvelopeSessionState,
508
514
  recordingStorageKey,
509
515
  redactOpenSandboxSignedUriPath,
516
+ reduceModalRawOutputPage,
510
517
  relativeConnectedMachinePath,
511
518
  renderRoutingMutationOutcomeUnknownToolResult,
512
519
  renderSelfhostedFault,
@@ -576,7 +583,7 @@ import {
576
583
  withRunCredentialsClient,
577
584
  withRunCredentialsSession,
578
585
  withoutSandboxProviderIdentity
579
- } from "./chunk-D5DPVA2C.js";
586
+ } from "./chunk-3QG5IL64.js";
580
587
  import "./chunk-7KVMU7O3.js";
581
588
  import "./chunk-4A4XTKKX.js";
582
589
  import "./chunk-GUJMCB7F.js";
@@ -593,7 +600,7 @@ import {
593
600
  skillArtifactContentSha256,
594
601
  skillLibraryRepositoryUrl
595
602
  } from "./chunk-KAPAZSUC.js";
596
- import "./chunk-A22BKN4P.js";
603
+ import "./chunk-LJNCGUMB.js";
597
604
  import {
598
605
  GMAIL_REST_API_BASE,
599
606
  GMAIL_REST_MCP_TOOLS,
@@ -609,6 +616,8 @@ import "./chunk-PZ5AY32C.js";
609
616
  export {
610
617
  AGENT_PROMPT_MODULES,
611
618
  ActiveBackendUnresolvableError,
619
+ AnthropicProviderRejection,
620
+ AnthropicRequestError,
612
621
  AssistantMessagePhaseTracker,
613
622
  BROWSER_CONTROL_ADMIN_TOKEN_FILE,
614
623
  BROWSER_CONTROL_PORT,
@@ -715,6 +724,7 @@ export {
715
724
  PROVIDER_QUOTA_EXHAUSTED_CODE,
716
725
  PROVIDER_REGISTRY,
717
726
  PrefixedMcpServer,
727
+ ProviderCommandObservationUnavailableError,
718
728
  ProviderCommandStartOutcomeUnknownError,
719
729
  ProviderHistoryIncompatibleError,
720
730
  REMOTE_COMPACTION_TOOL_RESULT_OMISSION,
@@ -860,6 +870,7 @@ export {
860
870
  compactionResponseDiagnostics,
861
871
  compactionSummaryOutputTokens,
862
872
  compactionThresholdTokens,
873
+ compileNativeFreshCreate,
863
874
  composeAgentInstructions,
864
875
  composeModularAgentInstructions,
865
876
  composeOperationalContract,
@@ -893,6 +904,7 @@ export {
893
904
  deleteRecordingArtifacts,
894
905
  describeCompactionProviderRejection,
895
906
  describeLegacyNativeSnapshotArchive,
907
+ describeNativeFreshCreate,
896
908
  describeNativeSnapshotArchive,
897
909
  deserializeSandboxSessionStateEnvelope,
898
910
  desktopCapableBackend,
@@ -965,6 +977,7 @@ export {
965
977
  isOfficialGmailMcpConfig,
966
978
  isOpenSandboxLifecycleProxyPath,
967
979
  isProviderApiThrottleError,
980
+ isProviderCommandObservationUnavailableError,
968
981
  isProviderSandboxGoneDuringRoutedOperation,
969
982
  isProviderSandboxNotFoundError,
970
983
  isProviderSandboxTransientError,
@@ -1063,6 +1076,7 @@ export {
1063
1076
  recordModelPreparationMeasurement,
1064
1077
  recordingStorageKey,
1065
1078
  redactOpenSandboxSignedUriPath,
1079
+ reduceModalRawOutputPage,
1066
1080
  refreshCodemodeTokenFile,
1067
1081
  refreshGitCredentialBindingTokenFiles,
1068
1082
  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";
@@ -22,6 +24,7 @@ export { classifyProviderSandboxFailure, isProviderSandboxGoneDuringRoutedOperat
22
24
  export { WORKSPACE_ARCHIVE_DESCRIPTOR_VERSION, WorkspaceArchiveIntegrityError, captureVerifiedWorkspaceArchive, decodeNativeSnapshotRef, encodeNativeSnapshotRef, describeLegacyNativeSnapshotArchive, describeNativeSnapshotArchive, fingerprintSandboxWorkspace, inlineWorkspaceArchiveForRestore, parseWorkspaceArchiveDescriptor, readVerifiedWorkspaceArchive, verifyRestoredWorkspace, type NativeSnapshotDescriptor, type NativeSnapshotProvider, type NativeSnapshotRef, type TarWorkspaceArchiveDescriptor, type VerifiedWorkspaceArchive, type WorkspaceArchiveDescriptor, type WorkspaceArchiveIntegrityCode, type WorkspaceTreeFingerprint, } from "./workspace-archive.js";
23
25
  export { ensureModalRegistryImage, deleteModalCheckpointSnapshot, inspectModalSandboxLifecycle, isModalTaskExecStartPreDispatchUnavailableError, isModalCommandStartOutcomeUnknownError, modalSessionMatchesCheckpointProviderBinding, modalSandboxAttributionEnvironment, modalSandboxAttributionTags, resolveModalCheckpointProviderBinding, findModalProviderCreateReceipt, resolveModalCheckpointProviderBindingForLiveSandbox, resolveModalCheckpointProviderBindingForSession, sweepModalOrphanSandboxes, tagModalSandbox, terminateModalSandboxById, type LiveModalSandboxLeaseAttribution, type ModalModuleLoader, type ModalCheckpointProviderBinding, type ModalOrphanSweepResult, type ModalOrphanSweepTermination, type ModalSandboxAttribution, type RevalidateModalOrphanTermination, } from "./providers/modal.js";
24
26
  export { getModalCommandStartInvocation, withModalCommandStartSignal, type ModalCommandStartInvocation, } from "./providers/modal-command-start-errors.js";
27
+ export { compileNativeFreshCreate, describeNativeFreshCreate, type NativeFreshCreateSpec, type NativeFreshCreatePreparation, type NativeFreshCreateCompilation, } from "./providers/modal-native-create-preparation.js";
25
28
  export { OpenSandboxClient, OpenSandboxSession, setOpenSandboxApplyDiff, type OpenSandboxApplyDiff, type OpenSandboxClientOptions, type OpenSandboxEditor, type OpenSandboxSessionState, } from "./providers/opensandbox-adapter.js";
26
29
  export { selectBackend, sdkBackendIdForSandboxBackend, sandboxBackendForSdkBackendId, backendSupportsOs, desktopCapableBackend, negotiateCapabilities, type NegotiationContext, } from "./select.js";
27
30
  export { STREAM_TOKEN_DEFAULT_TTL_SECONDS, mintStreamToken, verifyStreamToken, StreamTokenPayload, type MintStreamTokenInput, type StreamTokenPayloadType, } from "./stream-token.js";
@@ -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,
@@ -120,6 +121,7 @@ import {
120
121
  codemodeTokenFileForSession,
121
122
  codemodeTokenFileFromEnvironment,
122
123
  collectSandboxEnvironment,
124
+ compileNativeFreshCreate,
123
125
  connectedMachinePathWithinRoot,
124
126
  connectedMachineWorkspaceRootsEqual,
125
127
  contentTypeForCodec,
@@ -135,6 +137,7 @@ import {
135
137
  deleteModalCheckpointSnapshot,
136
138
  deleteRecordingArtifacts,
137
139
  describeLegacyNativeSnapshotArchive,
140
+ describeNativeFreshCreate,
138
141
  describeNativeSnapshotArchive,
139
142
  deserializeSandboxSessionStateEnvelope,
140
143
  desktopCapableBackend,
@@ -166,6 +169,7 @@ import {
166
169
  isModalTaskExecStartPreDispatchUnavailableError,
167
170
  isOpenSandboxLifecycleProxyPath,
168
171
  isProviderApiThrottleError,
172
+ isProviderCommandObservationUnavailableError,
169
173
  isProviderSandboxGoneDuringRoutedOperation,
170
174
  isProviderSandboxNotFoundError,
171
175
  isProviderSandboxTransientError,
@@ -208,6 +212,7 @@ import {
208
212
  readWorkspaceArchiveFromEnvelopeSessionState,
209
213
  recordingStorageKey,
210
214
  redactOpenSandboxSignedUriPath,
215
+ reduceModalRawOutputPage,
211
216
  relativeConnectedMachinePath,
212
217
  renderRoutingMutationOutcomeUnknownToolResult,
213
218
  renderSelfhostedFault,
@@ -277,7 +282,7 @@ import {
277
282
  withRunCredentialsClient,
278
283
  withRunCredentialsSession,
279
284
  withoutSandboxProviderIdentity
280
- } from "../chunk-D5DPVA2C.js";
285
+ } from "../chunk-3QG5IL64.js";
281
286
  import "../chunk-7KVMU7O3.js";
282
287
  import "../chunk-4A4XTKKX.js";
283
288
  import "../chunk-GUJMCB7F.js";
@@ -333,6 +338,7 @@ export {
333
338
  OpenSandboxClient,
334
339
  OpenSandboxSession,
335
340
  PROVIDER_REGISTRY,
341
+ ProviderCommandObservationUnavailableError,
336
342
  ProviderCommandStartOutcomeUnknownError,
337
343
  REPOSITORY_DISCOVERY_LIMIT,
338
344
  RecordingError,
@@ -405,6 +411,7 @@ export {
405
411
  codemodeTokenFileForSession,
406
412
  codemodeTokenFileFromEnvironment,
407
413
  collectSandboxEnvironment,
414
+ compileNativeFreshCreate,
408
415
  connectedMachinePathWithinRoot,
409
416
  connectedMachineWorkspaceRootsEqual,
410
417
  contentTypeForCodec,
@@ -420,6 +427,7 @@ export {
420
427
  deleteModalCheckpointSnapshot,
421
428
  deleteRecordingArtifacts,
422
429
  describeLegacyNativeSnapshotArchive,
430
+ describeNativeFreshCreate,
423
431
  describeNativeSnapshotArchive,
424
432
  deserializeSandboxSessionStateEnvelope,
425
433
  desktopCapableBackend,
@@ -451,6 +459,7 @@ export {
451
459
  isModalTaskExecStartPreDispatchUnavailableError,
452
460
  isOpenSandboxLifecycleProxyPath,
453
461
  isProviderApiThrottleError,
462
+ isProviderCommandObservationUnavailableError,
454
463
  isProviderSandboxGoneDuringRoutedOperation,
455
464
  isProviderSandboxNotFoundError,
456
465
  isProviderSandboxTransientError,
@@ -493,6 +502,7 @@ export {
493
502
  readWorkspaceArchiveFromEnvelopeSessionState,
494
503
  recordingStorageKey,
495
504
  redactOpenSandboxSignedUriPath,
505
+ reduceModalRawOutputPage,
496
506
  relativeConnectedMachinePath,
497
507
  renderRoutingMutationOutcomeUnknownToolResult,
498
508
  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,56 @@ 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
+ };
60
+ /** Nonsecret preflight integrity/correlation only. This recipe identifies ONLY
61
+ * ['/bin/true'], /tmp, empty env, stdout/stderr config 1 and no PTY/extras.
62
+ * It grants no dispatch, retry, settlement or readiness-completion authority.
63
+ * Provider instance/namespace must come from a trusted original-context join. */
64
+ export type ModalRouterPreparedStartDescriptor = Readonly<ModalRouterIdentity> & {
65
+ readonly descriptorProtocol: "modal-prepared-start-descriptor";
66
+ readonly descriptorVersion: 1;
67
+ readonly readinessRecipe: "modal-exec-readiness-bin-true-v1";
68
+ readonly readinessRecipeVersion: 1;
69
+ readonly startMessage: "Start";
70
+ readonly rpcMethod: "/modal.task_command_router.TaskCommandRouter/TaskExecStart";
71
+ readonly encoderVersion: "protobufjs@7.6.5";
72
+ readonly preflight: Readonly<{
73
+ encoding: "modal-start-protobuf-preflight-v1";
74
+ sha256: string;
75
+ byteLength: number;
76
+ encoderFingerprint: string;
77
+ }>;
78
+ };
53
79
  /** A single authenticated transport, owned and closed by its command adapter.
54
80
  * Reads may stop at a byte boundary because the next read resumes at that exact
55
81
  * offset. Mutations are never retried by this layer, including ambiguous starts.
56
82
  */
57
83
  export declare class ModalCommandRouterWire {
84
+ #private;
58
85
  private readonly client;
59
86
  private readonly metadata;
60
87
  private closed;
61
88
  constructor(access: ModalRouterAccess, trustedRoots?: Buffer);
62
89
  close(): void;
63
90
  private unary;
91
+ /** Read-only transport preparation. It sends neither Start nor stdin and
92
+ * does not invoke a caller's dispatch/admission callback. Prevalidation is not
93
+ * wire proof: gRPC still serializes at RPC invocation after dispatch begins. */
94
+ prepareStart(request: ModalRouterStart, signal?: AbortSignal): Promise<ModalRouterPreparedStart>;
95
+ /** Passive, synchronous read on the same open issuing transport. Neither
96
+ * consumes the handle nor performs readiness/encoding/RPC/callback work.
97
+ * Every refusal is generic: no genuine non-dispatch or recovery proof. */
98
+ describePreparedStart(prepared: ModalRouterPreparedStart): ModalRouterPreparedStartDescriptor;
99
+ /** No readiness, route lookup or retry here. Consume the authentic local
100
+ * handle synchronously before RPC, including when cancellation/closure wins.
101
+ * Once spent it never resets, even if no acknowledgement was received. */
102
+ dispatchPreparedStart(prepared: ModalRouterPreparedStart, signal?: AbortSignal): Promise<void>;
64
103
  start(request: ModalRouterStart, signal?: AbortSignal): Promise<void>;
65
104
  write(identity: ModalRouterIdentity, offset: number, data: Uint8Array, signal?: AbortSignal): Promise<void>;
66
105
  poll(identity: ModalRouterIdentity, signal?: AbortSignal): Promise<number | null>;
@@ -69,3 +108,4 @@ export declare class ModalCommandRouterWire {
69
108
  eof: boolean;
70
109
  }>;
71
110
  }
111
+ export {};