@opengeni/runtime 3.0.1 → 4.0.0-canary.35585322809001

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 (99) hide show
  1. package/dist/assets/codemode-client.json +1 -0
  2. package/dist/chunk-4A4XTKKX.js +1 -0
  3. package/dist/{chunk-RIJ6DCYS.js → chunk-HCGLD7NH.js} +9817 -9494
  4. package/dist/chunk-HCGLD7NH.js.map +1 -0
  5. package/dist/{chunk-FHGLYLBL.js → chunk-SPT3PLMX.js} +1 -87
  6. package/dist/chunk-SPT3PLMX.js.map +1 -0
  7. package/dist/{chunk-GB763TSV.js → chunk-TE27J65Q.js} +1 -1
  8. package/dist/chunk-TE27J65Q.js.map +1 -0
  9. package/dist/{chunk-46BFUGFL.js → chunk-WIHICNWS.js} +1660 -388
  10. package/dist/chunk-WIHICNWS.js.map +1 -0
  11. package/dist/{chunk-UU6EJR52.js → chunk-YU4VRTR4.js} +2 -2
  12. package/dist/chunk-YU4VRTR4.js.map +1 -0
  13. package/dist/chunk-ZG2YH25H.js +94 -0
  14. package/dist/chunk-ZG2YH25H.js.map +1 -0
  15. package/dist/codex-tool-search.d.ts +5 -4
  16. package/dist/context-compaction.d.ts +19 -0
  17. package/dist/gmail-rest-mcp.js +1 -1
  18. package/dist/index.d.ts +30 -22
  19. package/dist/index.js +25 -5
  20. package/dist/lazy-manifest-OEYEHNVY.js +45 -0
  21. package/dist/lazy-manifest-OEYEHNVY.js.map +1 -0
  22. package/dist/lazy-manifest.d.ts +6 -0
  23. package/dist/lazy-tool-transport.d.ts +3 -2
  24. package/dist/{localSources-PVFCAPN2.js → localSources-TWHTEKGO.js} +3 -2
  25. package/dist/localSources-TWHTEKGO.js.map +1 -0
  26. package/dist/metrics.d.ts +6 -0
  27. package/dist/operational-instructions.d.ts +1 -1
  28. package/dist/prepared-compaction-request.d.ts +8 -0
  29. package/dist/provider-history-adapter.d.ts +2 -2
  30. package/dist/runtime-skills.d.ts +3 -10
  31. package/dist/sandbox/codemode-client.d.ts +17 -0
  32. package/dist/sandbox/codemode-token.d.ts +3 -3
  33. package/dist/sandbox/index.d.ts +2 -1
  34. package/dist/sandbox/index.js +8 -2
  35. package/dist/sandbox/materialization-verification-error.d.ts +27 -0
  36. package/dist/sandbox/provider-command-session.d.ts +44 -2
  37. package/dist/sandbox/providers/modal-command-control.d.ts +32 -29
  38. package/dist/sandbox/providers/modal-command-router-wire.d.ts +49 -0
  39. package/dist/sandbox/providers/modal-command-session.d.ts +2 -1
  40. package/dist/sandbox/providers/modal-legacy-command-control.d.ts +50 -0
  41. package/dist/sandbox/providers/modal-materialization-verification.d.ts +7 -0
  42. package/dist/sandbox/providers/modal.d.ts +0 -8
  43. package/dist/sandbox/routing/routing-session.d.ts +21 -0
  44. package/dist/sandbox/turn-tool-cancellation.d.ts +1 -0
  45. package/dist/skill-library.d.ts +0 -6
  46. package/dist/skill-library.js +1 -1
  47. package/dist/workspace-tool-gateway.js +7 -5
  48. package/package.json +13 -11
  49. package/src/bundled_artifact_skills/opengeni-documents/SKILL.md +19 -0
  50. package/src/bundled_artifact_skills/opengeni-documents/references/api.md +22 -0
  51. package/src/bundled_default_skills/opengeni-client/SKILL.md +349 -0
  52. package/src/bundled_default_skills/opengeni-client/agents/openai.yaml +4 -0
  53. package/src/bundled_default_skills/opengeni-client/references/api-workflows.md +256 -0
  54. package/src/bundled_default_skills/opengeni-client/references/compatibility-and-troubleshooting.md +84 -0
  55. package/src/bundled_default_skills/opengeni-client/references/customer-skill-template.md +96 -0
  56. package/src/bundled_default_skills/opengeni-client/references/data-tools-and-credentials.md +99 -0
  57. package/src/bundled_default_skills/opengeni-client/references/discovery-and-autonomy.md +81 -0
  58. package/src/bundled_default_skills/opengeni-client/references/external-users-and-connect.md +457 -0
  59. package/src/bundled_default_skills/opengeni-client/references/isolation-and-authorization.md +77 -0
  60. package/src/bundled_default_skills/opengeni-client/references/product-integration-shapes.md +232 -0
  61. package/src/bundled_default_skills/opengeni-client/references/product-shapes-and-ui.md +116 -0
  62. package/src/bundled_default_skills/opengeni-client/references/runtime-profile-and-verification.md +157 -0
  63. package/src/bundled_default_skills/opengeni-help/SKILL.md +101 -0
  64. package/src/bundled_management_skills/opengeni-skills/SKILL.md +33 -3
  65. package/src/codex-tool-search.ts +13 -5
  66. package/src/context-compaction.ts +87 -4
  67. package/src/gmail-rest-mcp.ts +1 -2
  68. package/src/index.ts +363 -131
  69. package/src/lazy-manifest.ts +55 -0
  70. package/src/lazy-tool-transport.ts +15 -2
  71. package/src/metrics.ts +6 -0
  72. package/src/model-request-capture.ts +3 -0
  73. package/src/operational-instructions.ts +11 -2
  74. package/src/prepared-compaction-request.ts +51 -0
  75. package/src/provider-history-adapter.ts +12 -3
  76. package/src/runtime-skills.ts +3 -17
  77. package/src/sandbox/codemode-client.ts +204 -0
  78. package/src/sandbox/codemode-token.ts +7 -2
  79. package/src/sandbox/index.ts +7 -0
  80. package/src/sandbox/materialization-verification-error.ts +65 -0
  81. package/src/sandbox/provider-command-session.ts +70 -2
  82. package/src/sandbox/providers/modal-command-control.ts +386 -242
  83. package/src/sandbox/providers/modal-command-router-wire.ts +248 -0
  84. package/src/sandbox/providers/modal-command-session.ts +177 -4
  85. package/src/sandbox/providers/modal-legacy-command-control.ts +351 -0
  86. package/src/sandbox/providers/modal-materialization-verification.ts +122 -0
  87. package/src/sandbox/providers/modal.ts +1 -9
  88. package/src/sandbox/routing/routing-session.ts +417 -79
  89. package/src/sandbox/turn-tool-cancellation.ts +38 -2
  90. package/src/skill-catalog.ts +1 -0
  91. package/src/skill-library.ts +0 -6
  92. package/src/workspace-governance.ts +0 -1
  93. package/src/workspace-skills.ts +114 -74
  94. package/dist/chunk-46BFUGFL.js.map +0 -1
  95. package/dist/chunk-FHGLYLBL.js.map +0 -1
  96. package/dist/chunk-GB763TSV.js.map +0 -1
  97. package/dist/chunk-RIJ6DCYS.js.map +0 -1
  98. package/dist/chunk-UU6EJR52.js.map +0 -1
  99. /package/dist/{localSources-PVFCAPN2.js.map → chunk-4A4XTKKX.js.map} +0 -0
@@ -0,0 +1,65 @@
1
+ export type MaterializationFailureReason =
2
+ | "path_not_visible"
3
+ | "command_failed"
4
+ | "command_pending"
5
+ | "invalid_response"
6
+ | "command_error";
7
+
8
+ /** Exact diagnostics belong only in authenticated durable session events.
9
+ * Metrics receive the closed reason vocabulary, never paths or provider output. */
10
+ export type MaterializationVerificationDiagnostic = {
11
+ reason: MaterializationFailureReason;
12
+ path: string;
13
+ workdir: string;
14
+ command: string;
15
+ output: string | null;
16
+ exitCode: number | null;
17
+ providerSessionId: number | null;
18
+ /** Exact ephemeral read-only probe identity, never a retained command alias. */
19
+ providerExecution?: { sandboxId: string; taskId: string; execId: string };
20
+ causeMessage?: string;
21
+ };
22
+
23
+ const EXPLANATIONS: Record<MaterializationFailureReason, string> = {
24
+ path_not_visible: "the provider could not see the destination path",
25
+ command_failed: "the visibility-check command exited unsuccessfully",
26
+ command_pending: "the visibility-check command was still running; path visibility is unconfirmed",
27
+ invalid_response: "the visibility check returned no valid success confirmation",
28
+ command_error: "the provider could not complete the visibility-check command",
29
+ };
30
+
31
+ export class SandboxMaterializationVerificationError extends Error {
32
+ readonly code = "sandbox_materialization_verification_failed";
33
+
34
+ constructor(
35
+ readonly diagnostic: MaterializationVerificationDiagnostic,
36
+ options?: ErrorOptions,
37
+ ) {
38
+ super(
39
+ `Sandbox materialization verification failed: ${EXPLANATIONS[diagnostic.reason]}: ${diagnostic.path}`,
40
+ options,
41
+ );
42
+ this.name = "SandboxMaterializationVerificationError";
43
+ }
44
+ }
45
+
46
+ const providerDiagnostics = new WeakMap<object, MaterializationVerificationDiagnostic>();
47
+
48
+ /** Keep cancellation, route-loss, and provider retry identities unchanged. */
49
+ export function retainMaterializationVerificationDiagnostic(
50
+ error: unknown,
51
+ diagnostic: MaterializationVerificationDiagnostic,
52
+ ): void {
53
+ if (error !== null && (typeof error === "object" || typeof error === "function")) {
54
+ providerDiagnostics.set(error, diagnostic);
55
+ }
56
+ }
57
+
58
+ export function materializationVerificationDiagnostic(
59
+ error: unknown,
60
+ ): MaterializationVerificationDiagnostic | undefined {
61
+ if (error instanceof SandboxMaterializationVerificationError) return error.diagnostic;
62
+ return error !== null && (typeof error === "object" || typeof error === "function")
63
+ ? providerDiagnostics.get(error)
64
+ : undefined;
65
+ }
@@ -1,8 +1,14 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import type { SandboxProviderCommand } from "@opengeni/contracts";
2
+ import type {
3
+ SandboxProviderCommand,
4
+ ModalRouterProviderCommand,
5
+ CommandSupervisionReceipt,
6
+ } from "@opengeni/contracts";
3
7
 
4
8
  export type ProviderCommandOutput = {
5
9
  command: SandboxProviderCommand;
10
+ /** Exact read baseline for atomic byte-offset capture; absent for legacy pages. */
11
+ expected?: ModalRouterProviderCommand;
6
12
  chunks: Array<{ stream: "stdout" | "stderr"; chunkId: string; text: string }>;
7
13
  exitCode: number | null;
8
14
  streamFidelity?: "separate" | "merged";
@@ -11,12 +17,36 @@ export type ProviderCommandOutput = {
11
17
  /** These callbacks are supplied by the control plane after exact-route
12
18
  * retention/adoption. They are never accepted as command arguments. */
13
19
  export type ProviderCommandPersistence = {
20
+ rejectSupervisedLaunch?(command: ModalRouterProviderCommand): Promise<void>;
14
21
  load(): Promise<SandboxProviderCommand | null>;
15
22
  acknowledge(command: SandboxProviderCommand): Promise<SandboxProviderCommand>;
16
- reserveInput(): Promise<number>;
23
+ reserveInput(byteLength?: number): Promise<number>;
24
+ recordSupervisionReceipt?(receipt: CommandSupervisionReceipt): Promise<void>;
25
+ loadSupervisionReceipt?(): Promise<CommandSupervisionReceipt | null>;
26
+ requestCancellation?(reason: "provider_deadline" | "explicit_stop"): Promise<void>;
27
+ cancellationRequested?(): Promise<boolean>;
28
+ captureRouterPage?(page: {
29
+ expected: ModalRouterProviderCommand;
30
+ command: ModalRouterProviderCommand;
31
+ stdout: string;
32
+ stderr: string;
33
+ }): Promise<{ command: ModalRouterProviderCommand; captured: boolean }>;
17
34
  };
18
35
 
36
+ export class ProviderCommandStartRejectedError extends Error {
37
+ constructor(cause: unknown) {
38
+ super("Provider rejected command before start", { cause });
39
+ this.name = "ProviderCommandStartRejectedError";
40
+ }
41
+ }
42
+
19
43
  export type ProviderCommandSession = {
44
+ verifyCommandSupervisionCapability?(): Promise<{ sandboxId: string; taskId: string }>;
45
+ releaseSupervisedCommand?(handle: number): Promise<void>;
46
+ cancelSupervisedCommand?(
47
+ handle: number,
48
+ reason: "provider_deadline" | "explicit_stop",
49
+ ): Promise<boolean>;
20
50
  /** Abort only starts/initial observations still owned by this session call. */
21
51
  cancelPendingExecCommand?(): Promise<void>;
22
52
  getProviderCommand?(handle: number): SandboxProviderCommand | null;
@@ -27,9 +57,47 @@ export type ProviderCommandSession = {
27
57
  ): void;
28
58
  getProviderCommandOutput?(result: unknown): ProviderCommandOutput | null;
29
59
  acknowledgeCommandOutput?(result: string): Promise<void>;
60
+ /** Returns false for a legacy receipt. True means bytes and offsets committed
61
+ * together (or the page lost a cursor CAS and was safely discarded). */
62
+ captureCommandOutput?(result: string): Promise<boolean>;
30
63
  };
31
64
 
32
65
  const admission = new AsyncLocalStorage<number>();
66
+ export type PendingCommandSupervision = { managed: boolean };
67
+ const pendingSupervision = new AsyncLocalStorage<PendingCommandSupervision>();
68
+ export function withPendingCommandSupervision<T>(
69
+ state: PendingCommandSupervision | undefined,
70
+ fn: () => T,
71
+ ): T {
72
+ return state ? pendingSupervision.run(state, fn) : fn();
73
+ }
74
+ /** Called only by the provider adapter before dispatching an idle supervisor. */
75
+ export function markPendingCommandSupervised(): void {
76
+ const state = pendingSupervision.getStore();
77
+ if (state) state.managed = true;
78
+ }
79
+ const supervisionReady = new AsyncLocalStorage<boolean>();
80
+ type SupervisedLaunchReservation = {
81
+ reserve(command: ModalRouterProviderCommand): Promise<void>;
82
+ };
83
+ const supervisedLaunch = new AsyncLocalStorage<SupervisedLaunchReservation>();
84
+ export function withSupervisedLaunchReservation<T>(
85
+ reservation: SupervisedLaunchReservation,
86
+ fn: () => T,
87
+ ): T {
88
+ return supervisedLaunch.run(reservation, fn);
89
+ }
90
+ export async function reserveSupervisedLaunch(command: ModalRouterProviderCommand): Promise<void> {
91
+ const reservation = supervisedLaunch.getStore();
92
+ if (!reservation) throw new Error("Supervised launch requires durable pre-dispatch reservation");
93
+ await reservation.reserve(command);
94
+ }
95
+ export function withCommandSupervisionReady<T>(ready: boolean, fn: () => T): T {
96
+ return supervisionReady.run(ready, fn);
97
+ }
98
+ export function admittedCommandSupervisionReady(): boolean {
99
+ return supervisionReady.getStore() === true;
100
+ }
33
101
  export const MAX_PROVIDER_COMMAND_HANDLE = 2147483647;
34
102
 
35
103
  /** The alias is allocated by serialized workspace mutation admission, not by