@tangle-network/agent-runtime 0.174.1 → 0.177.0

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 (104) hide show
  1. package/README.md +4 -0
  2. package/dist/{activation-CsdJWRXX.js → activation-XVI_z1g3.js} +3 -3
  3. package/dist/{activation-CsdJWRXX.js.map → activation-XVI_z1g3.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{authoring-DsLNInAz.js → authoring-bXmPNfCI.js} +2 -2
  7. package/dist/{authoring-DsLNInAz.js.map → authoring-bXmPNfCI.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +4 -4
  9. package/dist/{candidate-execution-BbMbyhgC.js → candidate-execution-fBNUyWyE.js} +10 -4
  10. package/dist/candidate-execution-fBNUyWyE.js.map +1 -0
  11. package/dist/{conversation-7XGKoDM6.js → conversation-BREx2hi-.js} +3 -3
  12. package/dist/{conversation-7XGKoDM6.js.map → conversation-BREx2hi-.js.map} +1 -1
  13. package/dist/conversation.d.ts +1 -1
  14. package/dist/conversation.js +1 -1
  15. package/dist/coordination-driver-xO1tkxy-.js +3063 -0
  16. package/dist/coordination-driver-xO1tkxy-.js.map +1 -0
  17. package/dist/durable-file-g3YdfEh4.js +131 -0
  18. package/dist/durable-file-g3YdfEh4.js.map +1 -0
  19. package/dist/durable.d.ts +2 -2
  20. package/dist/durable.js +1 -1
  21. package/dist/{environment-provider-DWjbGH8W.d.ts → environment-provider-5E82esWE.d.ts} +6 -3
  22. package/dist/{environment-provider-Bn3652YU.js → environment-provider-DKyMWQJd.js} +121 -17
  23. package/dist/environment-provider-DKyMWQJd.js.map +1 -0
  24. package/dist/environment-provider.d.ts +1 -1
  25. package/dist/environment-provider.js +1 -1
  26. package/dist/{graph-BbeHgLXH.js → graph-DwJXa1Ph.js} +3 -3
  27. package/dist/graph-DwJXa1Ph.js.map +1 -0
  28. package/dist/graph.d.ts +11 -3
  29. package/dist/graph.js +35 -4
  30. package/dist/graph.js.map +1 -1
  31. package/dist/{improvement-cycle-DKGDCukL.js → improvement-cycle-eiSv6aH4.js} +5 -5
  32. package/dist/{improvement-cycle-DKGDCukL.js.map → improvement-cycle-eiSv6aH4.js.map} +1 -1
  33. package/dist/{index-CIhkH7mq.d.ts → index-BnAiQVLD.d.ts} +290 -29
  34. package/dist/{index-CFMB9ux3.d.ts → index-Bs0uhf-y.d.ts} +2 -2
  35. package/dist/{index-Dk5X9eKg.d.ts → index-C9XTLVP1.d.ts} +4 -4
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +13 -13
  38. package/dist/intelligence.d.ts +4 -4
  39. package/dist/intelligence.js +6 -6
  40. package/dist/kernel.d.ts +6 -6
  41. package/dist/kernel.js +13 -11
  42. package/dist/{knowledge-BaAX0HVu.js → knowledge-Bmtj_7u7.js} +5 -5
  43. package/dist/{knowledge-BaAX0HVu.js.map → knowledge-Bmtj_7u7.js.map} +1 -1
  44. package/dist/knowledge.d.ts +1 -1
  45. package/dist/knowledge.js +1 -1
  46. package/dist/{loop-runner-bin-DRYApMiu.d.ts → loop-runner-bin-ChS5deJ0.d.ts} +3 -3
  47. package/dist/{loop-runner-bin-D63Tytdk.js → loop-runner-bin-GTN5wqCt.js} +3 -3
  48. package/dist/{loop-runner-bin-D63Tytdk.js.map → loop-runner-bin-GTN5wqCt.js.map} +1 -1
  49. package/dist/loop-runner-bin.d.ts +1 -1
  50. package/dist/loop-runner-bin.js +1 -1
  51. package/dist/{materialization-Ct3I4wu3.js → materialization-CekWK6OO.js} +5 -3
  52. package/dist/materialization-CekWK6OO.js.map +1 -0
  53. package/dist/mcp/bin.js +3 -3
  54. package/dist/mcp/index.d.ts +3 -3
  55. package/dist/mcp/index.js +5 -4
  56. package/dist/mcp/index.js.map +1 -1
  57. package/dist/{openai-tools-BBgjWYNw.js → openai-tools-BBj1QGJp.js} +2 -2
  58. package/dist/{openai-tools-BBgjWYNw.js.map → openai-tools-BBj1QGJp.js.map} +1 -1
  59. package/dist/{prepare-BAyaNoZu.js → prepare-Tip-2ZoZ.js} +2 -2
  60. package/dist/{prepare-BAyaNoZu.js.map → prepare-Tip-2ZoZ.js.map} +1 -1
  61. package/dist/primeintellect/index.d.ts +1 -1
  62. package/dist/{protected-model-port-T2UWrDNQ.js → protected-model-port-Dd3a1SRm.js} +2 -2
  63. package/dist/{protected-model-port-T2UWrDNQ.js.map → protected-model-port-Dd3a1SRm.js.map} +1 -1
  64. package/dist/provision-supervisor-zA__ayUX.js +1020 -0
  65. package/dist/provision-supervisor-zA__ayUX.js.map +1 -0
  66. package/dist/{redact-DvLf4x1m.d.ts → redact-DkRLcSiE.d.ts} +3 -3
  67. package/dist/run-layout-Cd_l2XWV.js +645 -0
  68. package/dist/run-layout-Cd_l2XWV.js.map +1 -0
  69. package/dist/{runtime-D5u1M6T5.d.ts → runtime-B2eZ76kG.d.ts} +3 -3
  70. package/dist/{runtime-CojgP-hr.js → runtime-CJNlF5wM.js} +16 -1095
  71. package/dist/runtime-CJNlF5wM.js.map +1 -0
  72. package/dist/{spawn-journal-Tgvp5VS5.js → spawn-journal--N8Ten1q.js} +3 -1
  73. package/dist/{spawn-journal-Tgvp5VS5.js.map → spawn-journal--N8Ten1q.js.map} +1 -1
  74. package/dist/{stream-agent-turn-DxQ3GOuR.d.ts → stream-agent-turn-ByY8po9W.d.ts} +2 -2
  75. package/dist/{stream-agent-turn-CKIpCbSq.js → stream-agent-turn-CPj9SqVm.js} +2 -2
  76. package/dist/{stream-agent-turn-CKIpCbSq.js.map → stream-agent-turn-CPj9SqVm.js.map} +1 -1
  77. package/dist/{structural-rollout-BUYA61iV.js → structural-rollout-BeAUK7Ta.js} +4 -4
  78. package/dist/{structural-rollout-BUYA61iV.js.map → structural-rollout-BeAUK7Ta.js.map} +1 -1
  79. package/dist/{supervise-Ci0RfWQF.js → supervise-HsRKOlKY.js} +405 -3374
  80. package/dist/supervise-HsRKOlKY.js.map +1 -0
  81. package/dist/{supervisor-Bt1XLCVq.js → supervisor-ChLgoYhG.js} +1620 -33
  82. package/dist/supervisor-ChLgoYhG.js.map +1 -0
  83. package/dist/testing.d.ts +2 -2
  84. package/dist/testing.js +13 -12
  85. package/dist/testing.js.map +1 -1
  86. package/dist/{top-app-3rYfFPTW.js → top-app-DIBApkt1.js} +25 -9
  87. package/dist/top-app-DIBApkt1.js.map +1 -0
  88. package/dist/tui/bin.js +1 -1
  89. package/dist/tui/index.d.ts +9 -1
  90. package/dist/tui/index.js +3 -2
  91. package/dist/{types-DjVO-p7R.d.ts → types-a2ZZUl80.d.ts} +25 -2
  92. package/dist/{workspace-archive-B0Hqp2eJ.js → workspace-archive-DOZAeeKU.js} +2 -2
  93. package/dist/{workspace-archive-B0Hqp2eJ.js.map → workspace-archive-DOZAeeKU.js.map} +1 -1
  94. package/package.json +5 -4
  95. package/dist/candidate-execution-BbMbyhgC.js.map +0 -1
  96. package/dist/environment-provider-Bn3652YU.js.map +0 -1
  97. package/dist/graph-BbeHgLXH.js.map +0 -1
  98. package/dist/materialization-Ct3I4wu3.js.map +0 -1
  99. package/dist/run-layout-C2jgwsCq.js +0 -393
  100. package/dist/run-layout-C2jgwsCq.js.map +0 -1
  101. package/dist/runtime-CojgP-hr.js.map +0 -1
  102. package/dist/supervise-Ci0RfWQF.js.map +0 -1
  103. package/dist/supervisor-Bt1XLCVq.js.map +0 -1
  104. package/dist/top-app-3rYfFPTW.js.map +0 -1
@@ -0,0 +1,131 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
+ import { closeSync, constants, existsSync, fchmodSync, fsyncSync, linkSync, lstatSync, openSync, renameSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
4
+ //#region src/runtime/supervise/durable-file.ts
5
+ /**
6
+ * Small filesystem durability primitives for Runtime-owned state.
7
+ *
8
+ * Callers must validate their path and parent directory before invoking these functions.
9
+ * The exclusive writer protects a no-clobber publication race; the atomic writer replaces one
10
+ * state file after its temporary contents reach stable storage.
11
+ *
12
+ * @internal
13
+ */
14
+ /** Publish a new file without replacing a concurrent winner. */
15
+ function publishExclusiveDurableFile(filePath, content, options = {}) {
16
+ const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
17
+ let operationFailed = false;
18
+ let operationError;
19
+ let published = false;
20
+ try {
21
+ writeExclusiveDurableFile(temporaryPath, content, options);
22
+ try {
23
+ linkSync(temporaryPath, filePath);
24
+ syncDurableDirectory(dirname(filePath));
25
+ published = true;
26
+ } catch (error) {
27
+ if (!isAlreadyExistsError(error)) throw error;
28
+ }
29
+ } catch (error) {
30
+ operationFailed = true;
31
+ operationError = error;
32
+ }
33
+ let cleanupError;
34
+ try {
35
+ unlinkSync(temporaryPath);
36
+ } catch (error) {
37
+ if (!isNoEntryError(error)) cleanupError = error;
38
+ }
39
+ if (operationFailed) throw operationError;
40
+ if (cleanupError !== void 0) throw cleanupError;
41
+ return published;
42
+ }
43
+ /** Fsync a directory after publishing a durable file entry. */
44
+ function syncDurableDirectory(directoryPath) {
45
+ const fd = openSync(directoryPath, "r");
46
+ try {
47
+ fsyncSync(fd);
48
+ } finally {
49
+ closeSync(fd);
50
+ }
51
+ }
52
+ /** Fsync one durable file after its contents reach stable storage. */
53
+ function syncDurableFile(filePath) {
54
+ const fd = openSync(filePath, "r");
55
+ try {
56
+ fsyncSync(fd);
57
+ } finally {
58
+ closeSync(fd);
59
+ }
60
+ }
61
+ /** Append one record with O_APPEND, then fsync the file and containing directory. */
62
+ function appendDurableFile(filePath, content, options = {}) {
63
+ const fd = openSync(filePath, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), options.mode ?? 384);
64
+ try {
65
+ if (process.platform !== "win32") fchmodSync(fd, options.mode ?? 384);
66
+ const expectedBytes = Buffer.byteLength(content, "utf8");
67
+ const writtenBytes = writeSync(fd, content, void 0, "utf8");
68
+ if (writtenBytes !== expectedBytes) throw new Error(`durable append wrote ${writtenBytes} of ${expectedBytes} bytes to '${filePath}'`);
69
+ fsyncSync(fd);
70
+ } finally {
71
+ closeSync(fd);
72
+ }
73
+ syncDurableDirectory(dirname(filePath));
74
+ }
75
+ /** Reject a path that escapes its run directory or traverses a symbolic link. */
76
+ function assertNoSymlinkDescendant(root, target, label = "path") {
77
+ const base = resolve(root);
78
+ const rel = relative(base, resolve(target));
79
+ if (rel === ".." || rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)) throw new Error(`${label} path escapes its run directory`);
80
+ if (existsSync(base) && lstatSync(base).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${base}`);
81
+ let current = base;
82
+ for (const part of rel.split(/[\\/]/u).filter(Boolean)) {
83
+ current = join(current, part);
84
+ if (!existsSync(current)) continue;
85
+ if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${current}`);
86
+ }
87
+ }
88
+ /** Write, fsync, atomically replace, and fsync one Runtime-owned state file. */
89
+ function writeAtomicDurableFile(filePath, content, options = {}) {
90
+ const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
91
+ let operationFailed = false;
92
+ let operationError;
93
+ try {
94
+ writeExclusiveDurableFile(temporaryPath, content, options);
95
+ renameSync(temporaryPath, filePath);
96
+ syncDurableDirectory(dirname(filePath));
97
+ } catch (error) {
98
+ operationFailed = true;
99
+ operationError = error;
100
+ }
101
+ let cleanupError;
102
+ try {
103
+ unlinkSync(temporaryPath);
104
+ } catch (error) {
105
+ if (!isNoEntryError(error)) cleanupError = error;
106
+ }
107
+ if (operationFailed) throw operationError;
108
+ if (cleanupError !== void 0) throw cleanupError;
109
+ }
110
+ function writeExclusiveDurableFile(filePath, content, options) {
111
+ if (options.mode === void 0) writeFileSync(filePath, content, {
112
+ encoding: "utf8",
113
+ flag: "wx"
114
+ });
115
+ else writeFileSync(filePath, content, {
116
+ encoding: "utf8",
117
+ flag: "wx",
118
+ mode: options.mode
119
+ });
120
+ syncDurableFile(filePath);
121
+ }
122
+ function isAlreadyExistsError(error) {
123
+ return error !== null && typeof error === "object" && "code" in error && error.code === "EEXIST";
124
+ }
125
+ function isNoEntryError(error) {
126
+ return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
127
+ }
128
+ //#endregion
129
+ export { writeAtomicDurableFile as i, assertNoSymlinkDescendant as n, publishExclusiveDurableFile as r, appendDurableFile as t };
130
+
131
+ //# sourceMappingURL=durable-file-g3YdfEh4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-file-g3YdfEh4.js","names":["fsConstants"],"sources":["../src/runtime/supervise/durable-file.ts"],"sourcesContent":["/**\n * Small filesystem durability primitives for Runtime-owned state.\n *\n * Callers must validate their path and parent directory before invoking these functions.\n * The exclusive writer protects a no-clobber publication race; the atomic writer replaces one\n * state file after its temporary contents reach stable storage.\n *\n * @internal\n */\n\nimport { randomUUID } from 'node:crypto'\nimport {\n closeSync,\n existsSync,\n fchmodSync,\n constants as fsConstants,\n fsyncSync,\n linkSync,\n lstatSync,\n openSync,\n renameSync,\n unlinkSync,\n writeFileSync,\n writeSync,\n} from 'node:fs'\nimport { dirname, join, relative, resolve } from 'node:path'\n\nexport interface DurableFileOptions {\n readonly mode?: number\n}\n\n/** Publish a new file without replacing a concurrent winner. */\nexport function publishExclusiveDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions = {},\n): boolean {\n const temporaryPath = `${filePath}.${randomUUID()}.tmp`\n let operationFailed = false\n let operationError: unknown\n let published = false\n try {\n writeExclusiveDurableFile(temporaryPath, content, options)\n try {\n linkSync(temporaryPath, filePath)\n syncDurableDirectory(dirname(filePath))\n published = true\n } catch (error) {\n if (!isAlreadyExistsError(error)) throw error\n }\n } catch (error) {\n operationFailed = true\n operationError = error\n }\n let cleanupError: unknown\n try {\n unlinkSync(temporaryPath)\n } catch (error) {\n if (!isNoEntryError(error)) cleanupError = error\n }\n if (operationFailed) throw operationError\n if (cleanupError !== undefined) throw cleanupError\n return published\n}\n\n/** Fsync a directory after publishing a durable file entry. */\nexport function syncDurableDirectory(directoryPath: string): void {\n const fd = openSync(directoryPath, 'r')\n try {\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n}\n\n/** Fsync one durable file after its contents reach stable storage. */\nexport function syncDurableFile(filePath: string): void {\n const fd = openSync(filePath, 'r')\n try {\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n}\n\n/** Append one record with O_APPEND, then fsync the file and containing directory. */\nexport function appendDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions = {},\n): void {\n const flags =\n fsConstants.O_APPEND |\n fsConstants.O_CREAT |\n fsConstants.O_WRONLY |\n (typeof fsConstants.O_NOFOLLOW === 'number' ? fsConstants.O_NOFOLLOW : 0)\n const fd = openSync(filePath, flags, options.mode ?? 0o600)\n try {\n if (process.platform !== 'win32') fchmodSync(fd, options.mode ?? 0o600)\n const expectedBytes = Buffer.byteLength(content, 'utf8')\n const writtenBytes = writeSync(fd, content, undefined, 'utf8')\n if (writtenBytes !== expectedBytes) {\n throw new Error(\n `durable append wrote ${writtenBytes} of ${expectedBytes} bytes to '${filePath}'`,\n )\n }\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n syncDurableDirectory(dirname(filePath))\n}\n\n/** Reject a path that escapes its run directory or traverses a symbolic link. */\nexport function assertNoSymlinkDescendant(root: string, target: string, label = 'path'): void {\n const base = resolve(root)\n const exact = resolve(target)\n const rel = relative(base, exact)\n if (rel === '..' || rel.startsWith(`..${process.platform === 'win32' ? '\\\\' : '/'}`)) {\n throw new Error(`${label} path escapes its run directory`)\n }\n if (existsSync(base) && lstatSync(base).isSymbolicLink()) {\n throw new Error(`${label} path contains a symbolic link: ${base}`)\n }\n let current = base\n for (const part of rel.split(/[\\\\/]/u).filter(Boolean)) {\n current = join(current, part)\n if (!existsSync(current)) continue\n if (lstatSync(current).isSymbolicLink()) {\n throw new Error(`${label} path contains a symbolic link: ${current}`)\n }\n }\n}\n\n/** Write, fsync, atomically replace, and fsync one Runtime-owned state file. */\nexport function writeAtomicDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions = {},\n): void {\n const temporaryPath = `${filePath}.${randomUUID()}.tmp`\n let operationFailed = false\n let operationError: unknown\n try {\n writeExclusiveDurableFile(temporaryPath, content, options)\n renameSync(temporaryPath, filePath)\n syncDurableDirectory(dirname(filePath))\n } catch (error) {\n operationFailed = true\n operationError = error\n }\n let cleanupError: unknown\n try {\n unlinkSync(temporaryPath)\n } catch (error) {\n if (!isNoEntryError(error)) cleanupError = error\n // A successful rename removes the temporary directory entry.\n }\n if (operationFailed) throw operationError\n if (cleanupError !== undefined) throw cleanupError\n}\n\nfunction writeExclusiveDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions,\n): void {\n if (options.mode === undefined) {\n writeFileSync(filePath, content, { encoding: 'utf8', flag: 'wx' })\n } else {\n writeFileSync(filePath, content, { encoding: 'utf8', flag: 'wx', mode: options.mode })\n }\n syncDurableFile(filePath)\n}\n\nexport function isAlreadyExistsError(error: unknown): boolean {\n return (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code?: unknown }).code === 'EEXIST'\n )\n}\n\nfunction isNoEntryError(error: unknown): boolean {\n return (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code?: unknown }).code === 'ENOENT'\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,4BACd,UACA,SACA,UAA8B,CAAC,GACtB;CACT,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,EAAE;CAClD,IAAI,kBAAkB;CACtB,IAAI;CACJ,IAAI,YAAY;CAChB,IAAI;EACF,0BAA0B,eAAe,SAAS,OAAO;EACzD,IAAI;GACF,SAAS,eAAe,QAAQ;GAChC,qBAAqB,QAAQ,QAAQ,CAAC;GACtC,YAAY;EACd,SAAS,OAAO;GACd,IAAI,CAAC,qBAAqB,KAAK,GAAG,MAAM;EAC1C;CACF,SAAS,OAAO;EACd,kBAAkB;EAClB,i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ACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACT,MAA6B,SAAS;AAE3C"}
package/dist/durable.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { do as SuperviseOptions, ho as supervise, jo as SupervisorProfile } from "./index-CIhkH7mq.js";
1
+ import { Uo as supervise, as as SupervisorProfile, zo as SuperviseOptions } from "./index-BnAiQVLD.js";
2
2
  import { l as RuntimeHooks, o as RuntimeHookEvent, r as RuntimeDecisionPoint } from "./runtime-hooks-Bj6wJHlH.js";
3
- import { A as ProviderModelExecutionEvidence, J as SpendGap, K as Spend, O as ProfileMaterializationReceipt, T as NodeId, o as ExecutionBindingReceipt, st as WorkerTraceEvidence } from "./types-DjVO-p7R.js";
3
+ import { A as ProviderModelExecutionEvidence, J as SpendGap, K as Spend, O as ProfileMaterializationReceipt, T as NodeId, o as ExecutionBindingReceipt, st as WorkerTraceEvidence } from "./types-a2ZZUl80.js";
4
4
  //#region src/durable/chat-engine.d.ts
5
5
  /**
6
6
  * `handleChatTurn` is a framework-neutral chat-turn HTTP orchestrator.
package/dist/durable.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as cloneSpend, t as addSpend, y as zeroSpend } from "./util-D6ZEuBMi.js";
2
2
  import { i as writeAllBytes, n as parseCommittedJsonLines, r as prepareJsonlAppend, t as isNoEntError } from "./jsonl-file-CDfsCI5s.js";
3
3
  import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
4
- import { n as supervise } from "./supervise-Ci0RfWQF.js";
4
+ import { n as supervise } from "./supervise-HsRKOlKY.js";
5
5
  import { createHash } from "node:crypto";
6
6
  import { resolve } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
@@ -1,5 +1,5 @@
1
1
  import { E as SandboxClient } from "./types-DpdfZoQ3.js";
2
- import { R as Runtime, p as ExecutorFactory } from "./types-DjVO-p7R.js";
2
+ import { R as Runtime, p as ExecutorFactory } from "./types-a2ZZUl80.js";
3
3
  import { AgentProfile, AgentProfileValidationResult } from "@tangle-network/agent-interface";
4
4
  import { BackendType, CreateSandboxOptions, Sandbox } from "@tangle-network/sandbox";
5
5
  import { AgentEnvironment as AgentEnvironment$1, AgentEnvironmentCapabilities, AgentEnvironmentCapabilities as AgentEnvironmentCapabilities$1, AgentEnvironmentEvent, AgentEnvironmentProvider, AgentEnvironmentProvider as AgentEnvironmentProvider$1, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentProfileRef as AgentProfileRef$1, AgentSession, AgentSessionRef, AgentSessionStatus as AgentSessionStatus$1, AgentTurnInput, AgentTurnInput as AgentTurnInput$1, AgentTurnResult as AgentTurnResult$1, CheckpointRef, CheckpointRequest, CreateAgentEnvironmentInput, CreateAgentEnvironmentInput as CreateAgentEnvironmentInput$1, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from "@tangle-network/agent-interface/environment-provider";
@@ -62,7 +62,10 @@ interface SandboxClientProviderOptions {
62
62
  resolveProfile?: (profileId: string) => AgentProfile | Promise<AgentProfile>;
63
63
  mapCreateInput?: (input: CreateAgentEnvironmentInput) => CreateSandboxOptions;
64
64
  }
65
- /** Adapt a `SandboxClient` into the shared `AgentEnvironmentProvider` contract.
65
+ /**
66
+ * Adapt a `SandboxClient` into the shared `AgentEnvironmentProvider` contract.
67
+ * The provider declares the public SDK contract before it creates an environment.
68
+ * Each environment exposes interactive methods only when its deployment declares every required capability.
66
69
  * @experimental */
67
70
  declare function sandboxClientAsProvider(client: SandboxClient, options?: SandboxClientProviderOptions): AgentEnvironmentProvider;
68
71
  /** Options for running a provider as a supervise-mode executor.
@@ -83,4 +86,4 @@ interface ProviderExecutorOptions {
83
86
  declare function providerAsExecutor(provider: AgentEnvironmentProvider, options?: ProviderExecutorOptions): ExecutorFactory<unknown>;
84
87
  //#endregion
85
88
  export { providerAsSandboxClient as A, ProviderAsSandboxClientOptions as C, WorkspaceRequest as D, SandboxClientProviderOptions as E, createTangleSandboxExactProcessProvider as F, sandboxClientAsProvider as M, CreateTangleSandboxExactProcessProviderOptions as N, createAgentEnvironmentProviderRegistry as O, SandboxControlClient as P, PlacementInfo as S, ResourceRequest as T, CheckpointRequest as _, AgentEnvironmentProviderRef as a, ExecResult as b, AgentEnvironmentStatus as c, AgentSession as d, AgentSessionRef as f, CheckpointRef as g, AgentTurnResult$1 as h, AgentEnvironmentProvider$1 as i, resolveAgentEnvironmentProvider as j, providerAsExecutor as k, AgentEnvironmentSummary as l, AgentTurnInput$1 as m, AgentEnvironmentCapabilities$1 as n, AgentEnvironmentProviderRegistry as o, AgentSessionStatus$1 as p, AgentEnvironmentEvent as r, AgentEnvironmentQuery as s, AgentEnvironment$1 as t, AgentProfileRef$1 as u, CreateAgentEnvironmentInput$1 as v, ProviderExecutorOptions as w, ForkRequest as x, ExecRequest as y };
86
- //# sourceMappingURL=environment-provider-DWjbGH8W.d.ts.map
89
+ //# sourceMappingURL=environment-provider-5E82esWE.d.ts.map
@@ -1,8 +1,9 @@
1
- import { I as awaitAbortable, J as sameControlCoordinates, X as promptFromAgentTurnInput, Z as promptOptionsFromAgentTurnInput, o as finalizeRuntimeOwnedPendingExecutor, r as attestRuntimeOwnedPendingExecutor, u as newExecutionAttemptId } from "./materialization-Ct3I4wu3.js";
1
+ import { I as awaitAbortable, J as sameControlCoordinates, X as promptFromAgentTurnInput, Z as promptOptionsFromAgentTurnInput, o as finalizeRuntimeOwnedPendingExecutor, r as attestRuntimeOwnedPendingExecutor, u as newExecutionAttemptId } from "./materialization-CekWK6OO.js";
2
+ import { n as detachedSnapshot } from "./snapshot-CTAf4uuA.js";
2
3
  import { b as zeroTokenUsage } from "./util-D6ZEuBMi.js";
3
4
  import { a as isSandboxTerminalEvent, d as sandboxTerminalUsageField, n as canonicalStreamEventFromSandboxEvent, r as createSandboxToolPartState, u as sandboxProgressEvents } from "./sandbox-events-BVjstFgb.js";
4
5
  import { a as concreteProfileModel, c as profileModelExecutionSettings, o as enforceTokenLimits } from "./model-policy-Sw4ywhtL.js";
5
- import { AgentExactRunControlRefSchema, AgentRunCancellationRequestSchema, harnessSystemPromptIntents } from "@tangle-network/agent-interface";
6
+ import { AgentExactRunControlRefSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentRunCancellationRequestSchema, agentInteractiveSessionRefMatchesStart, canonicalCandidateDigest, harnessSystemPromptIntents } from "@tangle-network/agent-interface";
6
7
  import { randomUUID } from "node:crypto";
7
8
  import { isDeepStrictEqual } from "node:util";
8
9
  //#region src/runtime/supervise/abortable.ts
@@ -573,24 +574,35 @@ function providerAsSandboxClient(provider, options = {}) {
573
574
  return environmentAsSandboxInstance(environment, { requireTerminalEvent: options.requireTerminalEvent ?? true });
574
575
  } };
575
576
  }
576
- /** Adapt a `SandboxClient` into the shared `AgentEnvironmentProvider` contract.
577
+ /**
578
+ * Adapt a `SandboxClient` into the shared `AgentEnvironmentProvider` contract.
579
+ * The provider declares the public SDK contract before it creates an environment.
580
+ * Each environment exposes interactive methods only when its deployment declares every required capability.
577
581
  * @experimental */
578
582
  function sandboxClientAsProvider(client, options = {}) {
579
583
  const providerName = options.name ?? "tangle-sandbox";
584
+ const providerCapabilities = async () => {
585
+ const resolved = await (options.capabilities ? typeof options.capabilities === "function" ? options.capabilities() : options.capabilities : defaultTangleSandboxCapabilities({
586
+ namedProfiles: options.resolveProfile !== void 0,
587
+ rediscover: hasGet(client)
588
+ }));
589
+ if (hasGet(client)) return resolved;
590
+ const { interactiveAgent: _interactiveAgent, ...withoutInteractive } = resolved;
591
+ return withoutInteractive;
592
+ };
580
593
  return {
581
594
  name: providerName,
582
- capabilities: async () => {
583
- if (options.capabilities) return typeof options.capabilities === "function" ? options.capabilities() : options.capabilities;
584
- return defaultTangleSandboxCapabilities({ namedProfiles: options.resolveProfile !== void 0 });
585
- },
595
+ capabilities: providerCapabilities,
586
596
  ...options.validateProfile ? { validateProfile: options.validateProfile } : {},
587
597
  async create(input) {
588
598
  const createOptions = options.mapCreateInput?.(input) ?? await sandboxOptionsFromCreateInput(input, options.defaultBackend ?? "opencode", options.resolveProfile);
589
- return sandboxInstanceAsEnvironment(await client.create(createOptions, input.signal === void 0 ? void 0 : { signal: input.signal }), providerName, client);
599
+ const capabilities = await providerCapabilities();
600
+ return sandboxInstanceAsEnvironment(await client.create(createOptions, input.signal === void 0 ? void 0 : { signal: input.signal }), providerName, client, capabilities);
590
601
  },
591
602
  ...hasGet(client) ? { async get(id) {
603
+ const capabilities = await providerCapabilities();
592
604
  const box = await client.get(id);
593
- return box ? sandboxInstanceAsEnvironment(box, providerName, client) : null;
605
+ return box ? sandboxInstanceAsEnvironment(box, providerName, client, capabilities) : null;
594
606
  } } : {},
595
607
  ...hasList(client) ? { async list(query) {
596
608
  return (await client.list(query?.providerOptions)).map((box) => ({
@@ -792,7 +804,7 @@ function createInputFromSandboxOptions(options) {
792
804
  ...Object.keys(workspace).length > 0 ? { workspace } : {},
793
805
  ...options?.resources ? { resources: options.resources } : {},
794
806
  ...options?.env ? { env: options.env } : {},
795
- ...options?.secrets ? { secrets: options.secrets } : {},
807
+ ...Array.isArray(options?.secrets) ? { secrets: options.secrets } : {},
796
808
  ...options?.metadata ? { metadata: options.metadata } : {},
797
809
  ...options?.name ? { name: options.name } : {},
798
810
  ...options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {},
@@ -830,7 +842,7 @@ async function sandboxOptionsFromCreateInput(input, defaultBackend, resolveProfi
830
842
  };
831
843
  }
832
844
  function assertSandboxSecretNames(secrets) {
833
- if (secrets !== void 0 && (!Array.isArray(secrets) || secrets.some((secret) => typeof secret !== "string" || secret.trim().length === 0))) throw new ValidationError("Tangle Sandbox secret names must be non-empty strings; secret values are unsupported");
845
+ if (secrets !== void 0 && secrets !== "all" && (!Array.isArray(secrets) || secrets.some((secret) => typeof secret !== "string" || secret.trim().length === 0))) throw new ValidationError("Tangle Sandbox secret names must be non-empty strings; secret values are unsupported");
834
846
  }
835
847
  function sandboxEnvironmentFromWorkspace(workspace) {
836
848
  if (workspace.environment !== void 0 && workspace.image !== void 0 && workspace.environment !== workspace.image) throw new ValidationError("Tangle Sandbox accepts one environment value; workspace.environment and workspace.image must match");
@@ -953,10 +965,13 @@ function environmentAsSandboxInstance(environment, options) {
953
965
  }
954
966
  };
955
967
  }
956
- function sandboxInstanceAsEnvironment(box, providerName, client) {
968
+ async function sandboxInstanceAsEnvironment(box, providerName, client, providerCapabilities) {
969
+ const capabilities = await sandboxEnvironmentCapabilities(box, providerCapabilities);
970
+ const interactiveAgent = capabilities.interactiveAgent;
957
971
  return {
958
972
  id: String(box.id),
959
973
  provider: providerName,
974
+ capabilities,
960
975
  ...typeof box.name === "string" ? { name: box.name } : {},
961
976
  ...readBoxMetadata(box) ? { metadata: readBoxMetadata(box) } : {},
962
977
  async status() {
@@ -977,6 +992,50 @@ function sandboxInstanceAsEnvironment(box, providerName, client) {
977
992
  return (await box.session(command.binding.sessionId).respondToInteraction(command, options)).acknowledgement;
978
993
  }
979
994
  } : {},
995
+ ...interactiveAgent ? {
996
+ async startInteractive(request, options) {
997
+ const exactRequest = AgentInteractiveSessionStartSchema.parse(request);
998
+ assertSandboxInteractiveBinding(exactRequest.run, box, providerName);
999
+ const result = await box.session(exactRequest.run.sessionId).interactive().start(exactRequest, options);
1000
+ if (result.state !== "running") throw new ValidationError("sandbox interactive process settled before attachment");
1001
+ const ref = detachedSnapshot(AgentInteractiveSessionRefSchema.parse(result.ref), "sandbox interactive start reference");
1002
+ if (!agentInteractiveSessionRefMatchesStart(exactRequest, ref)) throw new ValidationError("sandbox interactive start returned a different exact process");
1003
+ return ref;
1004
+ },
1005
+ interactive(ref) {
1006
+ const exactRef = detachedSnapshot(AgentInteractiveSessionRefSchema.parse(ref), "sandbox interactive reference");
1007
+ assertSandboxInteractiveBinding(exactRef.run, box, providerName);
1008
+ const session = box.session(exactRef.run.sessionId).interactive({ ref: exactRef });
1009
+ const controlledSessions = /* @__PURE__ */ new Map();
1010
+ const controlledSession = (control) => {
1011
+ const key = canonicalCandidateDigest(control);
1012
+ const existing = controlledSessions.get(key);
1013
+ if (existing) return existing;
1014
+ const created = box.session(exactRef.run.sessionId).interactive({
1015
+ ref: exactRef,
1016
+ control
1017
+ });
1018
+ controlledSessions.set(key, created);
1019
+ return created;
1020
+ };
1021
+ return {
1022
+ ref: exactRef,
1023
+ claimControl: (request, options) => session.claimControl(request, options),
1024
+ async status(options) {
1025
+ const status = await session.status(options);
1026
+ if (status === null) throw new ValidationError(`sandbox interactive session "${exactRef.run.sessionId}" is unavailable`);
1027
+ return status;
1028
+ },
1029
+ attach: (request, options) => {
1030
+ const controlled = controlledSession(request.control);
1031
+ if (typeof controlled.attachAgentTerminal !== "function") return Promise.reject(new ValidationError("sandbox interactive session does not expose the exact terminal adapter"));
1032
+ return controlled.attachAgentTerminal(request, options);
1033
+ },
1034
+ sendPrompt: (command, options) => controlledSession(command.control).sendPrompt(command, options),
1035
+ stop: (command, options) => controlledSession(command.control).stop(command, options)
1036
+ };
1037
+ }
1038
+ } : {},
980
1039
  ...hasRead(box) ? { read: box.read.bind(box) } : {},
981
1040
  ...hasWrite(box) ? { write: box.write.bind(box) } : {},
982
1041
  ...hasExec(box) ? { async exec(command, options) {
@@ -995,7 +1054,7 @@ function sandboxInstanceAsEnvironment(box, providerName, client) {
995
1054
  fromSandboxId: String(box.id),
996
1055
  ...options?.name ? { name: options.name } : {},
997
1056
  ...options?.metadata ? { metadata: options.metadata } : {}
998
- }), providerName, client);
1057
+ }), providerName, client, providerCapabilities);
999
1058
  },
1000
1059
  async placement() {
1001
1060
  return placementInfoFromLoopPlacement(client.describePlacement?.(box), box);
@@ -1478,6 +1537,50 @@ function placementInfoFromLoopPlacement(placement, box) {
1478
1537
  ...placement.machineId ? { machineId: placement.machineId } : {}
1479
1538
  };
1480
1539
  }
1540
+ const completeInteractiveAgentCapabilities = {
1541
+ start: true,
1542
+ control: true,
1543
+ status: true,
1544
+ attach: true,
1545
+ reattach: true,
1546
+ sendPrompt: true,
1547
+ input: true,
1548
+ resize: true,
1549
+ stop: true
1550
+ };
1551
+ async function sandboxEnvironmentCapabilities(box, providerCapabilities) {
1552
+ const { interactiveAgent: providerInteractive, ...baseCapabilities } = providerCapabilities;
1553
+ if (!hasCompleteInteractiveAgentCapabilities(providerInteractive)) return baseCapabilities;
1554
+ let deployed;
1555
+ try {
1556
+ deployed = await box.capabilities();
1557
+ } catch {
1558
+ return baseCapabilities;
1559
+ }
1560
+ if (!hasCompleteInteractiveAgentCapabilities(deployed?.interactiveAgent)) return baseCapabilities;
1561
+ if (!hasExactInteractiveTerminalAdapter(box)) return baseCapabilities;
1562
+ return {
1563
+ ...baseCapabilities,
1564
+ interactiveAgent: { ...completeInteractiveAgentCapabilities }
1565
+ };
1566
+ }
1567
+ function hasExactInteractiveTerminalAdapter(box) {
1568
+ if (!hasSession(box)) return false;
1569
+ try {
1570
+ const session = box.session("__runtime-capability-probe__");
1571
+ const interactive = session.interactive;
1572
+ if (typeof interactive !== "function") return false;
1573
+ return typeof interactive.call(session).attachAgentTerminal === "function";
1574
+ } catch {
1575
+ return false;
1576
+ }
1577
+ }
1578
+ function hasCompleteInteractiveAgentCapabilities(value) {
1579
+ return value?.start === true && value.control === true && value.status === true && value.attach === true && value.reattach === true && value.sendPrompt === true && value.input === true && value.resize === true && value.stop === true;
1580
+ }
1581
+ function assertSandboxInteractiveBinding(run, box, providerName) {
1582
+ if (run.provider !== providerName || run.environmentId !== String(box.id)) throw new ValidationError("sandbox interactive request targets another environment");
1583
+ }
1481
1584
  function defaultTangleSandboxCapabilities(options) {
1482
1585
  return {
1483
1586
  profile: {
@@ -1521,12 +1624,13 @@ function defaultTangleSandboxCapabilities(options) {
1521
1624
  download: true
1522
1625
  },
1523
1626
  branching: {
1524
- checkpoint: true,
1525
- fork: true
1627
+ checkpoint: false,
1628
+ fork: false
1526
1629
  },
1630
+ ...options.rediscover ? { interactiveAgent: { ...completeInteractiveAgentCapabilities } } : {},
1527
1631
  placement: true,
1528
1632
  usage: true,
1529
- confidential: true
1633
+ confidential: false
1530
1634
  };
1531
1635
  }
1532
1636
  function contentRef(prefix, value) {
@@ -1567,4 +1671,4 @@ function hasExec(box) {
1567
1671
  //#endregion
1568
1672
  export { sandboxClientAsProvider as a, linkAbort as c, resolveAgentEnvironmentProvider as i, runAbortable as l, providerAsExecutor as n, createTangleSandboxExactProcessProvider as o, providerAsSandboxClient as r, abortError as s, createAgentEnvironmentProviderRegistry as t };
1569
1673
 
1570
- //# sourceMappingURL=environment-provider-Bn3652YU.js.map
1674
+ //# sourceMappingURL=environment-provider-DKyMWQJd.js.map