openpond 0.2.0 → 0.2.1

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 (220) hide show
  1. package/dist/chunks/actions-command-QP3NMDK4.js +2 -0
  2. package/dist/chunks/app-layer-N7VFRVJ2.js +3 -0
  3. package/dist/chunks/app-server-runtime-OCLPUI7F.js +2 -0
  4. package/dist/chunks/apps-AMG75TI4.js +2 -0
  5. package/dist/chunks/chunk-22UARBPW.js +3 -0
  6. package/dist/chunks/chunk-3A7HZJNE.js +1 -0
  7. package/dist/chunks/chunk-3M53YXEI.js +2 -0
  8. package/dist/chunks/chunk-3NDRIQTI.js +2 -0
  9. package/dist/chunks/chunk-5BBVEWG3.js +2 -0
  10. package/dist/chunks/chunk-5O7ZVCMV.js +6 -0
  11. package/dist/chunks/chunk-6FA3GG5B.js +33 -0
  12. package/dist/chunks/chunk-6MI4KKWF.js +2 -0
  13. package/dist/chunks/chunk-BBG546O6.js +6 -0
  14. package/dist/chunks/chunk-BX4J2VDU.js +2 -0
  15. package/dist/chunks/chunk-BZMVB3GS.js +2 -0
  16. package/dist/chunks/chunk-C5LOZSVS.js +2 -0
  17. package/dist/chunks/chunk-CWQWV2T3.js +2 -0
  18. package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
  19. package/dist/chunks/chunk-EAPFMACH.js +10 -0
  20. package/dist/chunks/chunk-ES2ISFJC.js +66 -0
  21. package/dist/chunks/chunk-F65NIZLM.js +2199 -0
  22. package/dist/chunks/chunk-FGJ5LFPL.js +5 -0
  23. package/dist/chunks/chunk-FTQLQJQV.js +2 -0
  24. package/dist/chunks/chunk-FY7OQ5RK.js +24 -0
  25. package/dist/chunks/chunk-FYCJSUFV.js +53 -0
  26. package/dist/chunks/chunk-GLUWATL5.js +2 -0
  27. package/dist/chunks/chunk-H7IWJN7L.js +17 -0
  28. package/dist/chunks/chunk-HZP5U2AA.js +3 -0
  29. package/dist/chunks/chunk-I5K74TOH.js +3 -0
  30. package/dist/chunks/chunk-IR3YJWPW.js +7 -0
  31. package/dist/chunks/chunk-KU7QOHFT.js +2872 -0
  32. package/dist/chunks/chunk-KV553EWX.js +16 -0
  33. package/dist/chunks/chunk-MGN6GLNZ.js +2 -0
  34. package/dist/chunks/chunk-OG5Q6NXK.js +28 -0
  35. package/dist/chunks/chunk-OGPHXXCD.js +1 -0
  36. package/dist/chunks/chunk-PI36UHRA.js +18 -0
  37. package/dist/chunks/chunk-RWSAGQTP.js +2 -0
  38. package/dist/chunks/chunk-SAE4OIPC.js +2 -0
  39. package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
  40. package/dist/chunks/chunk-UKUVMXOW.js +12 -0
  41. package/dist/chunks/chunk-VCLCFK3O.js +36 -0
  42. package/dist/chunks/chunk-VYUMTRB3.js +5 -0
  43. package/dist/chunks/chunk-X37KMV27.js +1 -0
  44. package/dist/chunks/chunk-XDHAGACI.js +3 -0
  45. package/dist/chunks/chunk-XEOEKFG6.js +71 -0
  46. package/dist/chunks/chunk-ZF7TEGY5.js +5 -0
  47. package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
  48. package/dist/chunks/cli-M2FG7SSI.js +2 -0
  49. package/dist/chunks/configuration-command-XBKBIZBO.js +2 -0
  50. package/dist/chunks/continual-D75WA7E7.js +7 -0
  51. package/dist/chunks/core-commands-LUZVWXQR.js +2 -0
  52. package/dist/chunks/database-X2CUV732.js +2 -0
  53. package/dist/chunks/desktop-test-KGC4JVJ7.js +3 -0
  54. package/dist/chunks/dist-NKLXFA37.js +2 -0
  55. package/dist/chunks/extension-NQ7N5LEY.js +5 -0
  56. package/dist/chunks/help-MWK66XZK.js +8 -0
  57. package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
  58. package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
  59. package/dist/chunks/opchat-XJZA3QKZ.js +3 -0
  60. package/dist/chunks/organizations-UECDFEYE.js +2 -0
  61. package/dist/chunks/profile-KUMIZURM.js +3 -0
  62. package/dist/chunks/project-agent-NILMJHLV.js +2 -0
  63. package/dist/chunks/sandbox-command-QHH65OSE.js +2 -0
  64. package/dist/chunks/sandbox-template-N7I63PNU.js +10 -0
  65. package/dist/chunks/src-724HF43W.js +82 -0
  66. package/dist/chunks/src-VTKTTKQO.js +319 -0
  67. package/dist/chunks/taskset-PISBOILQ.js +2 -0
  68. package/dist/chunks/teams-bot-UV4RU53M.js +3 -0
  69. package/dist/chunks/training-2NDOWH5S.js +2 -0
  70. package/dist/chunks/workspaces-XXT4KUD3.js +2 -0
  71. package/dist/cli.js +3 -109
  72. package/dist/index.js +1 -31230
  73. package/dist/sandbox-template/manifest.js +1 -18380
  74. package/dist/web/assets/App-DxecRQUL.js +176 -0
  75. package/dist/web/assets/AppDialog-B65Eo3gp.js +1 -0
  76. package/dist/web/assets/AppTerminalPanel-B2EKQM7W.js +2 -0
  77. package/dist/web/assets/{AppsView-B1NUuAIf.js → AppsView-BBoVe7s2.js} +1 -1
  78. package/dist/web/assets/{BrowserSidebar-DOvYxXeP.js → BrowserSidebar-CSM1atSJ.js} +1 -1
  79. package/dist/web/assets/{CartesianChart-pOrYpzBr.js → CartesianChart-CJKfXiEG.js} +1 -1
  80. package/dist/web/assets/{CollaborationTabs-CgbR-MBJ.js → CollaborationTabs-BMZamWFC.js} +1 -1
  81. package/dist/web/assets/{CommandMenu-CrIr4qUX.js → CommandMenu-B3U1z2eo.js} +1 -1
  82. package/dist/web/assets/{CommunityView-CvAVQ_HZ.js → CommunityView-CTyRUcfy.js} +1 -1
  83. package/dist/web/assets/{ComposerCreateImproveStrip-DybcKwwd.js → ComposerCreateImproveStrip-D7usvRtK.js} +1 -1
  84. package/dist/web/assets/GetStartedView-Ibu7oKWJ.js +1 -0
  85. package/dist/web/assets/HostedModelLearningReview-qnzIkT70.js +1 -0
  86. package/dist/web/assets/HostedModelLearningSettings--PKjpYsy.js +1 -0
  87. package/dist/web/assets/LabModelVersionDetailPage-s9uUN6fV.js +1 -0
  88. package/dist/web/assets/{LabSkillSidebar-CuaYrtiu.js → LabSkillSidebar-BKYseMiJ.js} +1 -1
  89. package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
  90. package/dist/web/assets/LabsRoute-DoRs0K6v.js +32 -0
  91. package/dist/web/assets/MainChatThread-DvuyMcMB.js +2 -0
  92. package/dist/web/assets/MainPane-BWwcxgHD.js +8 -0
  93. package/dist/web/assets/{MarkdownText-DOlVQR8a.js → MarkdownText-D8XC5UT_.js} +1 -1
  94. package/dist/web/assets/{Messages-DMubppta.js → Messages-e4A8JUjD.js} +6 -6
  95. package/dist/web/assets/{NativeSkillSidebar-DSFwZ-od.js → NativeSkillSidebar-D2Joh8XB.js} +1 -1
  96. package/dist/web/assets/{NewExperienceSwitcher-Dj0ePIJ-.js → NewExperienceSwitcher-CzGebt2E.js} +1 -1
  97. package/dist/web/assets/{NewProjectDialog-B8NQV-Ji.js → NewProjectDialog-CdMTSxUE.js} +1 -1
  98. package/dist/web/assets/{OutputsPage-D_LDYTgV.js → OutputsPage-m7cSb8dW.js} +1 -1
  99. package/dist/web/assets/{ProjectsPage-xjDYPc_W.js → ProjectsPage-C9mz8W1g.js} +1 -1
  100. package/dist/web/assets/RightChatPanelStack-B4LEqKEj.js +1 -0
  101. package/dist/web/assets/{RightSidebarHomePanel-j0VckZUu.js → RightSidebarHomePanel-DOeUsH7h.js} +1 -1
  102. package/dist/web/assets/{ScheduledWorkPage-1aT4bBY-.js → ScheduledWorkPage-UXZSSWgA.js} +1 -1
  103. package/dist/web/assets/{SettingsView-BSpuMDpv.js → SettingsView-CQm1ai73.js} +7 -7
  104. package/dist/web/assets/TeamChatView-C4haojB7.js +3 -0
  105. package/dist/web/assets/{TerminalOverlay-CrSwUk2d.js → TerminalOverlay-p2GZsuyQ.js} +3 -3
  106. package/dist/web/assets/{TrainingCreationPanel-B4HMRwUg.js → TrainingCreationPanel-BYJSlO8X.js} +1 -1
  107. package/dist/web/assets/{TrainingDraftPanel-D4r1tN3I.js → TrainingDraftPanel-DR5KlayH.js} +1 -1
  108. package/dist/web/assets/{UsageSettingsSection-2aymqwIM.js → UsageSettingsSection-BQToNXE4.js} +5 -5
  109. package/dist/web/assets/{WorkSidebarPanel-B0X0OiR6.js → WorkSidebarPanel--EeytWeg.js} +1 -1
  110. package/dist/web/assets/WorkspaceDiffPanel-BrovSYhn.js +14 -0
  111. package/dist/web/assets/{WorkspaceEnvironmentMenu-OAfMEt7L.js → WorkspaceEnvironmentMenu-l-keRgvj.js} +3 -3
  112. package/dist/web/assets/{WorkspaceGitDialogs-YxcPH2Rq.js → WorkspaceGitDialogs-aicWzaZu.js} +1 -1
  113. package/dist/web/assets/{WorkspaceMonacoEditor-COKTiQZl.js → WorkspaceMonacoEditor-CO_E74jM.js} +36 -36
  114. package/dist/web/assets/{arrow-up-right-_TX-awvK.js → arrow-up-right-rwPXNfVn.js} +1 -1
  115. package/dist/web/assets/chat-file-links-B3jDstSC.js +1 -0
  116. package/dist/web/assets/chevron-up-D089nvYQ.js +1 -0
  117. package/dist/web/assets/{clipboard-CyRSS8Sy.js → clipboard-DwEExyU4.js} +1 -1
  118. package/dist/web/assets/{cloud-upload-uBJBUYTy.js → cloud-upload-D2he0-vQ.js} +1 -1
  119. package/dist/web/assets/{cssMode-BrXSsZYs.js → cssMode-DS4k0NcI.js} +1 -1
  120. package/dist/web/assets/{folder-open-DktdZNW7.js → folder-open-CAOLduKD.js} +1 -1
  121. package/dist/web/assets/{folder-plus-DO06i9Vo.js → folder-plus-D56MrxVT.js} +1 -1
  122. package/dist/web/assets/{git-commit-horizontal-zFSIkPs7.js → git-commit-horizontal-CeNM0oKJ.js} +1 -1
  123. package/dist/web/assets/{htmlMode-X9UMFkjt.js → htmlMode-Xkni5erh.js} +1 -1
  124. package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
  125. package/dist/web/assets/{index-UOGdfLzi.js → index-KwyAyscP.js} +1 -1
  126. package/dist/web/assets/{info-BEJXUqCD.js → info-CcrBaEE_.js} +1 -1
  127. package/dist/web/assets/{jsonMode-DIsB-j2E.js → jsonMode-C4YPbQB7.js} +1 -1
  128. package/dist/web/assets/{lspLanguageFeatures-CmZ17KpA.js → lspLanguageFeatures-CF5oMTz6.js} +1 -1
  129. package/dist/web/assets/{minimize-2-DumTpFtE.js → minimize-2-DzHQnInk.js} +1 -1
  130. package/dist/web/assets/{monaco.contribution-DJ_NmcHu.js → monaco.contribution-0EN4mGCC.js} +2 -2
  131. package/dist/web/assets/{monaco.contribution-YVDfJcG4.js → monaco.contribution-B4qcTP0w.js} +2 -2
  132. package/dist/web/assets/{monaco.contribution-LZEujgny.js → monaco.contribution-CJK_NrBm.js} +2 -2
  133. package/dist/web/assets/{monaco.contribution-D6w5PJji.js → monaco.contribution-CkPGKNd-.js} +2 -2
  134. package/dist/web/assets/{play-CLFeH7CU.js → play-p3-AMTPL.js} +1 -1
  135. package/dist/web/assets/{python-Djbda_qZ.js → python-B0kpTxAZ.js} +1 -1
  136. package/dist/web/assets/{refresh-cw-B4IpQ_7Q.js → refresh-cw-_jbTIzzr.js} +1 -1
  137. package/dist/web/assets/{save-BbTHztnA.js → save-Cy6hEotx.js} +1 -1
  138. package/dist/web/assets/{square-BJrVbmz6.js → square-DKQkcrOH.js} +1 -1
  139. package/dist/web/assets/{toggleHighContrast-BopU5W9S.js → toggleHighContrast-Bnk1VVVq.js} +1 -1
  140. package/dist/web/assets/{tsMode-CH_0_YDX.js → tsMode-BDrSVy7V.js} +1 -1
  141. package/dist/web/assets/{upload-UumVeufu.js → upload-COn0my_O.js} +1 -1
  142. package/dist/web/assets/{useLocalAgentSchedules-BRa23U7O.js → useLocalAgentSchedules-iZNB4Oee.js} +1 -1
  143. package/dist/web/assets/{wifi-off-BWJWivn6.js → wifi-off-Cqt-ZLXY.js} +1 -1
  144. package/dist/web/assets/{workers-pTe8RvSI.js → workers-hu0Ym93h.js} +1 -1
  145. package/dist/web/assets/{yaml-DNLASORn.js → yaml-D-JLDGL6.js} +1 -1
  146. package/dist/web/index.html +2 -2
  147. package/package.json +4 -3
  148. package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
  149. package/dist/chunks/app-layer-F3CGXB33.js +0 -216
  150. package/dist/chunks/app-server-runtime-RHO5TFUC.js +0 -23
  151. package/dist/chunks/apps-L5XCL7QY.js +0 -429
  152. package/dist/chunks/chunk-26AMV5ZI.js +0 -634
  153. package/dist/chunks/chunk-3EB7I67T.js +0 -630
  154. package/dist/chunks/chunk-3ELF4FXY.js +0 -96
  155. package/dist/chunks/chunk-3VEYNDHN.js +0 -669
  156. package/dist/chunks/chunk-4KA25HUP.js +0 -5648
  157. package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
  158. package/dist/chunks/chunk-6SMNG6YA.js +0 -1303
  159. package/dist/chunks/chunk-7RIGZB7N.js +0 -1148
  160. package/dist/chunks/chunk-A6G3PFA5.js +0 -2164
  161. package/dist/chunks/chunk-BVY5JYM6.js +0 -512
  162. package/dist/chunks/chunk-DLQQIWN2.js +0 -648
  163. package/dist/chunks/chunk-FJ2JGB2N.js +0 -1373
  164. package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
  165. package/dist/chunks/chunk-G65WAOJV.js +0 -1643
  166. package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
  167. package/dist/chunks/chunk-K4TZEHAW.js +0 -602
  168. package/dist/chunks/chunk-KCRCIQPD.js +0 -66
  169. package/dist/chunks/chunk-KSRWKXRB.js +0 -12
  170. package/dist/chunks/chunk-MUMPWI4O.js +0 -92
  171. package/dist/chunks/chunk-NTK22KJD.js +0 -10707
  172. package/dist/chunks/chunk-OCBRPU2K.js +0 -629
  173. package/dist/chunks/chunk-PS37DB5F.js +0 -183
  174. package/dist/chunks/chunk-R3C3MNSI.js +0 -140
  175. package/dist/chunks/chunk-SMNFI2FU.js +0 -113
  176. package/dist/chunks/chunk-UACZUFIA.js +0 -47
  177. package/dist/chunks/chunk-UZMVNKXM.js +0 -1275
  178. package/dist/chunks/chunk-VT6BLHMB.js +0 -67198
  179. package/dist/chunks/chunk-W5GKHH77.js +0 -168
  180. package/dist/chunks/chunk-X6F4LBTQ.js +0 -832
  181. package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
  182. package/dist/chunks/chunk-XA4KBDMY.js +0 -13723
  183. package/dist/chunks/chunk-YVCYVDNP.js +0 -746
  184. package/dist/chunks/chunk-ZNQEROWP.js +0 -254
  185. package/dist/chunks/cli-D2MUUBEX.js +0 -23
  186. package/dist/chunks/configuration-command-NR6JYIUD.js +0 -187
  187. package/dist/chunks/continual-37CE4LLJ.js +0 -803
  188. package/dist/chunks/core-commands-SWGIOZLW.js +0 -50
  189. package/dist/chunks/database-DEYUZDIM.js +0 -20
  190. package/dist/chunks/desktop-test-QOS7G5NE.js +0 -148
  191. package/dist/chunks/dist-AKYCQNNF.js +0 -187
  192. package/dist/chunks/extension-HJUJBQAD.js +0 -9378
  193. package/dist/chunks/help-J6PZ23IC.js +0 -67
  194. package/dist/chunks/opchat-ABX5YBAT.js +0 -169
  195. package/dist/chunks/organizations-CPNC47DO.js +0 -806
  196. package/dist/chunks/profile-Q3HB5MIO.js +0 -1136
  197. package/dist/chunks/project-agent-YHUBX4OR.js +0 -516
  198. package/dist/chunks/sandbox-command-YFL5QTWX.js +0 -1661
  199. package/dist/chunks/sandbox-template-Z6P7NTNF.js +0 -1655
  200. package/dist/chunks/src-7XEENEBI.js +0 -3628
  201. package/dist/chunks/src-KBBIV4NT.js +0 -56125
  202. package/dist/chunks/taskset-2TRZBRRT.js +0 -66
  203. package/dist/chunks/teams-bot-WD33NLH5.js +0 -146
  204. package/dist/chunks/training-4XH37UZB.js +0 -17
  205. package/dist/chunks/workspaces-WG2MH2WE.js +0 -99
  206. package/dist/web/assets/App-C9aGkxVg.js +0 -173
  207. package/dist/web/assets/AppDialog-CK6_lg8c.js +0 -1
  208. package/dist/web/assets/AppTerminalPanel-BKqgX4sd.js +0 -2
  209. package/dist/web/assets/GetStartedView-DVInkexN.js +0 -1
  210. package/dist/web/assets/LabModelVersionDetailPage-NaaPElmM.js +0 -1
  211. package/dist/web/assets/LabsRoute-BRR6x3SX.js +0 -2
  212. package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
  213. package/dist/web/assets/MainChatThread-BfkjCZB9.js +0 -2
  214. package/dist/web/assets/MainPane-Gw-YK38n.js +0 -8
  215. package/dist/web/assets/RightChatPanelStack-BktRQ9wg.js +0 -1
  216. package/dist/web/assets/TeamChatView-BPWJbDf1.js +0 -3
  217. package/dist/web/assets/WorkspaceDiffPanel-Pg7GL0br.js +0 -14
  218. package/dist/web/assets/chat-file-links-CWLsRYvW.js +0 -1
  219. package/dist/web/assets/chevron-up--mNnEqha.js +0 -1
  220. package/dist/web/assets/index-BEPmTPIA.js +0 -1
@@ -1,832 +0,0 @@
1
- import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import {
3
- acquireFileLock,
4
- assertHomeCompatible,
5
- atomicWriteFile,
6
- readJsonFile,
7
- readOptionalFile,
8
- withFileLock
9
- } from "./chunk-4KA25HUP.js";
10
- import {
11
- PersistenceError,
12
- resolveOpenPondHome,
13
- storagePaths,
14
- withOpenPondHome
15
- } from "./chunk-ZNQEROWP.js";
16
- import {
17
- external_exports
18
- } from "./chunk-FQS2QL5F.js";
19
-
20
- // ../server/src/runtime/home-runtime-owner.ts
21
- import path from "node:path";
22
- import { AsyncLocalStorage } from "node:async_hooks";
23
- import { promises as fs } from "node:fs";
24
- var startupDisposers = new AsyncLocalStorage();
25
- function onStartupFailure(dispose, replacesEarlier = false) {
26
- const disposers = startupDisposers.getStore();
27
- if (!disposers) return;
28
- if (replacesEarlier) disposers.length = 0;
29
- disposers.push(dispose);
30
- }
31
- async function ownHomeRuntime(home, start) {
32
- await assertHomeCompatible(home);
33
- let release;
34
- try {
35
- release = await acquireFileLock(path.join(storagePaths(home).runtime, "server-owner"), 100);
36
- } catch (error) {
37
- if (error instanceof PersistenceError && error.issue.code === "STORAGE_BUSY") {
38
- const endpoint = await readJsonFile(path.join(storagePaths(home).runtime, "endpoint.json"), () => null);
39
- throw new PersistenceError({
40
- code: "RUNTIME_ALREADY_RUNNING",
41
- path: home,
42
- message: "An OpenPond runtime already owns this home.",
43
- action: endpoint?.url ? `Connect to the existing runtime at ${endpoint.url}, or stop it before starting another.` : "Stop the existing runtime before starting another with this home."
44
- });
45
- }
46
- throw error;
47
- }
48
- const disposers = [];
49
- try {
50
- const runtime = await withOpenPondHome(home, () => startupDisposers.run(disposers, start)), close = runtime.close.bind(runtime);
51
- disposers.length = 0;
52
- let closing;
53
- return { ...runtime, close: () => closing ??= (async () => {
54
- try {
55
- await withOpenPondHome(home, close);
56
- } finally {
57
- await fs.rm(path.join(storagePaths(home).runtime, "endpoint.json"), { force: true });
58
- await release();
59
- }
60
- })() };
61
- } catch (error) {
62
- try {
63
- for (const dispose of disposers.reverse()) await Promise.resolve().then(() => withOpenPondHome(home, dispose)).catch(() => void 0);
64
- await fs.rm(path.join(storagePaths(home).runtime, "endpoint.json"), { force: true });
65
- } finally {
66
- await release();
67
- }
68
- throw error;
69
- }
70
- }
71
- async function publishRuntimeEndpoint(home, url, serverId) {
72
- await atomicWriteFile(path.join(storagePaths(home).runtime, "endpoint.json"), JSON.stringify({ schemaVersion: "openpond.runtimeEndpoint.v1", pid: process.pid, url, serverId }));
73
- }
74
-
75
- // ../../packages/agent-runtime/dist/compaction.js
76
- function agentCompactionDecision(input) {
77
- if (!input.maxContextTokens || !input.usableContextTokens) {
78
- return {
79
- shouldCompact: false,
80
- projectedTokens: input.projectedTokens,
81
- thresholdTokens: Number.MAX_SAFE_INTEGER,
82
- usableContextTokens: 0,
83
- maxContextTokens: 0,
84
- tokenSource: "heuristic"
85
- };
86
- }
87
- const triggerRatio = Math.max(0.01, Math.min(1, (input.triggerPercent ?? 85) / 100));
88
- const thresholdTokens = Math.max(1, Math.floor(input.usableContextTokens * triggerRatio));
89
- return {
90
- shouldCompact: input.projectedTokens >= thresholdTokens,
91
- projectedTokens: input.projectedTokens,
92
- thresholdTokens,
93
- usableContextTokens: input.usableContextTokens,
94
- maxContextTokens: input.maxContextTokens,
95
- tokenSource: "heuristic"
96
- };
97
- }
98
- async function runAgentCompaction(host) {
99
- await host.started();
100
- try {
101
- return await host.compact();
102
- } catch (error) {
103
- await host.failed(error);
104
- throw error;
105
- }
106
- }
107
- async function runAgentCompactionProgram(input) {
108
- const projectionEvents = input.host.projectEvents(input.events);
109
- const selection = input.host.selectEvents(projectionEvents, input.maxContextTokens);
110
- const { summaryEvents, preservedEvents, preservedEventIds } = selection;
111
- if (summaryEvents.length === 0) {
112
- throw new Error("There is not enough prior context to compact.");
113
- }
114
- const summaryRecords = input.host.normalizeRecords(summaryEvents);
115
- const preservedRecords = input.host.normalizeRecords(preservedEvents);
116
- const fileLedger = input.host.buildFileLedger(input.host.normalizeRecords(projectionEvents));
117
- const serialized = input.host.serializeRecords(summaryRecords, input.host.inputCharBudget(input.maxContextTokens));
118
- if (!serialized.text.trim()) {
119
- throw new Error("There is not enough prior context to compact.");
120
- }
121
- const messages = input.host.buildSummaryMessages({
122
- serializedHistory: serialized.text,
123
- fileLedger
124
- });
125
- const startedAtMs = Date.now();
126
- const summary = (await input.host.streamSummary({
127
- model: input.model,
128
- messages,
129
- signal: input.signal
130
- })).trim();
131
- const durationMs = Date.now() - startedAtMs;
132
- if (!summary)
133
- throw new Error("Compaction summary was empty.");
134
- const projection = input.host.estimateProjection({
135
- events: projectionEvents,
136
- preservedEvents,
137
- summary
138
- });
139
- const metrics = input.host.createMetrics({
140
- sourceEvents: projectionEvents.length,
141
- summarizedEvents: summaryEvents.length,
142
- preservedEvents: preservedEvents.length,
143
- sourceRecords: serialized.sourceRecordCount,
144
- includedRecords: serialized.includedRecordCount,
145
- omittedRecords: serialized.omittedRecordCount,
146
- preservedRecords: preservedRecords.length,
147
- truncatedRecords: serialized.truncatedRecordCount,
148
- summaryInputTruncated: serialized.inputTruncated,
149
- sourceSelectionStrategy: serialized.selectionStrategy,
150
- summaryInputChars: serialized.inputChars,
151
- retainedTailTokens: selection.retainedTailTokens,
152
- retainedTailBudgetTokens: selection.retainedTailBudgetTokens,
153
- finalProviderContextTokens: projection.inputTokensAfter,
154
- durationMs,
155
- fileLedgerEntries: fileLedger.length,
156
- splitTurnId: selection.splitTurnId
157
- });
158
- return {
159
- summary,
160
- model: input.model,
161
- compactedThroughEventId: projectionEvents[projectionEvents.length - 1]?.id ?? null,
162
- compactedThroughTurnId: input.host.lastTurnId(projectionEvents),
163
- preservedFromEventId: preservedEvents[0]?.id ?? null,
164
- preservedEventIds,
165
- preservedResourceRefs: input.host.durableResourceRefs(input.events),
166
- sourceEventCount: summaryEvents.length,
167
- preservedEventCount: preservedEvents.length,
168
- fileLedger,
169
- inputTokensBefore: projection.inputTokensBefore,
170
- inputTokensAfter: projection.inputTokensAfter,
171
- maxContextTokens: input.maxContextTokens,
172
- tokenSource: "heuristic",
173
- metrics
174
- };
175
- }
176
-
177
- // ../../packages/agent-runtime/dist/canonical.js
178
- import { createHash } from "node:crypto";
179
- function canonicalJson(value) {
180
- if (value === null || typeof value === "boolean" || typeof value === "string") {
181
- return value;
182
- }
183
- if (typeof value === "number") {
184
- if (!Number.isFinite(value))
185
- throw new Error("Canonical JSON cannot encode a non-finite number.");
186
- return value;
187
- }
188
- if (Array.isArray(value))
189
- return value.map(canonicalJson);
190
- if (typeof value === "object") {
191
- const output = {};
192
- for (const key of Object.keys(value).sort()) {
193
- const member = value[key];
194
- if (member !== void 0)
195
- output[key] = canonicalJson(member);
196
- }
197
- return output;
198
- }
199
- throw new Error(`Canonical JSON cannot encode ${typeof value}.`);
200
- }
201
- function canonicalHash(value) {
202
- return createHash("sha256").update(JSON.stringify(canonicalJson(value)), "utf8").digest("hex");
203
- }
204
-
205
- // ../../packages/agent-runtime/dist/events.js
206
- var AgentEventNameSchema = external_exports.enum([
207
- "thread.started",
208
- "thread.resumed",
209
- "turn.started",
210
- "turn.steered",
211
- "turn.interrupted",
212
- "turn.completed",
213
- "turn.failed",
214
- "item.started",
215
- "item.delta",
216
- "item.completed",
217
- "assistant.reasoning.delta",
218
- "assistant.delta",
219
- "tool.started",
220
- "tool.completed",
221
- "approval.requested",
222
- "approval.resolved",
223
- "user_input.requested",
224
- "user_input.resolved",
225
- "compaction.started",
226
- "compaction.completed",
227
- "harness.admitted",
228
- "harness.refiner.queued",
229
- "harness.refiner.started",
230
- "harness.refiner.completed",
231
- "harness.refiner.failed",
232
- "diagnostic"
233
- ]);
234
- var CanonicalAgentEventSchema = external_exports.object({
235
- sequence: external_exports.number().int().nonnegative(),
236
- name: AgentEventNameSchema,
237
- source: external_exports.enum(["runtime", "provider", "tool", "host", "refiner"]),
238
- status: external_exports.string().trim().min(1).nullable().default(null),
239
- threadId: external_exports.string().trim().min(1),
240
- turnId: external_exports.string().trim().min(1).nullable().default(null),
241
- callId: external_exports.string().trim().min(1).nullable().default(null),
242
- output: external_exports.string().nullable().default(null),
243
- error: external_exports.string().nullable().default(null),
244
- data: external_exports.record(external_exports.string(), external_exports.unknown()).default({})
245
- }).strict();
246
- function canonicalEventHash(event) {
247
- return canonicalHash(CanonicalAgentEventSchema.parse(event));
248
- }
249
-
250
- // ../../packages/agent-runtime/dist/protocol.js
251
- var AGENT_PROTOCOL_VERSION = "2026-08-26";
252
- var AGENT_RPC_METHODS = [
253
- "initialize",
254
- "initialized",
255
- "runtime/capabilities",
256
- "thread/start",
257
- "thread/resume",
258
- "thread/read",
259
- "turn/start",
260
- "turn/steer",
261
- "turn/interrupt",
262
- "approval/resolve",
263
- "userInput/resolve",
264
- "harness/inspect",
265
- "harness/proposalReview",
266
- "harness/review",
267
- "harness/acceptEvaluationReview",
268
- "harness/materializeEvaluationTaskset",
269
- "harness/runEvaluationBaseline",
270
- "harness/validate",
271
- "harness/backgroundReview",
272
- "harness/diff",
273
- "harness/rollback",
274
- "refiner/inspect",
275
- "refiner/update",
276
- "refiner/activate",
277
- "refiner/rollback"
278
- ];
279
- var JsonRpcRequestSchema = external_exports.object({
280
- jsonrpc: external_exports.literal("2.0"),
281
- id: external_exports.union([external_exports.string(), external_exports.number()]),
282
- method: external_exports.string().trim().min(1),
283
- params: external_exports.unknown().optional()
284
- }).strict();
285
- var JsonRpcNotificationSchema = external_exports.object({
286
- jsonrpc: external_exports.literal("2.0"),
287
- method: external_exports.string().trim().min(1),
288
- params: external_exports.unknown().optional()
289
- }).strict();
290
- var JsonRpcSuccessSchema = external_exports.object({
291
- jsonrpc: external_exports.literal("2.0"),
292
- id: external_exports.union([external_exports.string(), external_exports.number()]),
293
- result: external_exports.unknown()
294
- }).strict();
295
- var JsonRpcErrorSchema = external_exports.object({
296
- jsonrpc: external_exports.literal("2.0"),
297
- id: external_exports.union([external_exports.string(), external_exports.number(), external_exports.null()]),
298
- error: external_exports.object({
299
- code: external_exports.number().int(),
300
- message: external_exports.string(),
301
- data: external_exports.unknown().optional()
302
- }).strict()
303
- }).strict();
304
- var AgentProtocolEnvelopeSchema = external_exports.union([
305
- JsonRpcRequestSchema,
306
- JsonRpcNotificationSchema,
307
- JsonRpcSuccessSchema,
308
- JsonRpcErrorSchema
309
- ]);
310
- var InitializeParamsSchema = external_exports.object({
311
- protocolVersion: external_exports.string().trim().min(1),
312
- client: external_exports.object({
313
- name: external_exports.string().trim().min(1),
314
- version: external_exports.string().trim().min(1)
315
- }).strict(),
316
- capabilities: external_exports.record(external_exports.string(), external_exports.unknown()).default({})
317
- }).strict();
318
- var AgentJsonRpcDispatcher = class {
319
- #host;
320
- #initializeParams = null;
321
- #initialized = false;
322
- constructor(host) {
323
- this.#host = host;
324
- }
325
- get initialized() {
326
- return this.#initialized;
327
- }
328
- async handle(value) {
329
- const notification = JsonRpcNotificationSchema.safeParse(value);
330
- if (notification.success && !("id" in value)) {
331
- if (notification.data.method === "initialized") {
332
- if (!this.#initializeParams)
333
- throw new JsonRpcDispatchError(-32002, "initialize must be called first");
334
- this.#initialized = true;
335
- }
336
- return null;
337
- }
338
- const parsed = JsonRpcRequestSchema.safeParse(value);
339
- if (!parsed.success)
340
- return jsonRpcError(null, -32600, "Invalid Request", parsed.error.flatten());
341
- const request = parsed.data;
342
- try {
343
- const result = await this.#dispatch(request.method, request.params);
344
- return { jsonrpc: "2.0", id: request.id, result };
345
- } catch (error) {
346
- const dispatchError = error instanceof JsonRpcDispatchError ? error : new JsonRpcDispatchError(-32603, error instanceof Error ? error.message : String(error));
347
- return jsonRpcError(request.id, dispatchError.code, dispatchError.message, dispatchError.data);
348
- }
349
- }
350
- async #dispatch(method, params) {
351
- if (method === "initialize") {
352
- const input = InitializeParamsSchema.parse(params);
353
- if (input.protocolVersion !== AGENT_PROTOCOL_VERSION) {
354
- throw new JsonRpcDispatchError(-32001, "Incompatible agent protocol version", {
355
- requested: input.protocolVersion,
356
- supported: AGENT_PROTOCOL_VERSION
357
- });
358
- }
359
- this.#initializeParams = input;
360
- return {
361
- protocolVersion: AGENT_PROTOCOL_VERSION,
362
- server: { name: "openpond-app-server", version: "1" },
363
- capabilities: await this.#host.capabilities()
364
- };
365
- }
366
- if (!this.#initialized)
367
- throw new JsonRpcDispatchError(-32002, "initialized notification is required");
368
- switch (method) {
369
- case "runtime/capabilities":
370
- return this.#host.capabilities(params);
371
- case "thread/start":
372
- return this.#host.threadStart(params);
373
- case "thread/resume":
374
- return this.#host.threadResume(params);
375
- case "thread/read":
376
- return this.#host.threadRead(params);
377
- case "turn/start":
378
- return this.#host.turnStart(params);
379
- case "turn/steer":
380
- return this.#host.turnSteer(params);
381
- case "turn/interrupt":
382
- return this.#host.turnInterrupt(params);
383
- case "approval/resolve":
384
- return this.#host.approvalResolve(params);
385
- case "userInput/resolve":
386
- return this.#host.userInputResolve(params);
387
- case "harness/inspect":
388
- return this.#host.harnessInspect(params);
389
- case "harness/proposalReview":
390
- return this.#host.harnessProposalReview(params);
391
- case "harness/review":
392
- return this.#host.harnessReview(params);
393
- case "harness/acceptEvaluationReview":
394
- return this.#host.harnessAcceptEvaluationReview(params);
395
- case "harness/materializeEvaluationTaskset":
396
- return this.#host.harnessMaterializeEvaluationTaskset(params);
397
- case "harness/runEvaluationBaseline":
398
- return this.#host.harnessRunEvaluationBaseline(params);
399
- case "harness/validate":
400
- return this.#host.harnessValidate(params);
401
- case "harness/backgroundReview":
402
- return this.#host.harnessBackgroundReview(params);
403
- case "harness/diff":
404
- return this.#host.harnessDiff(params);
405
- case "harness/rollback":
406
- return this.#host.harnessRollback(params);
407
- case "refiner/inspect":
408
- return this.#host.refinerInspect(params);
409
- case "refiner/update":
410
- return this.#host.refinerUpdate(params);
411
- case "refiner/activate":
412
- return this.#host.refinerActivate(params);
413
- case "refiner/rollback":
414
- return this.#host.refinerRollback(params);
415
- default:
416
- throw new JsonRpcDispatchError(-32601, `Method not found: ${method}`);
417
- }
418
- }
419
- };
420
- var JsonRpcDispatchError = class extends Error {
421
- code;
422
- data;
423
- constructor(code, message, data) {
424
- super(message);
425
- this.code = code;
426
- this.data = data;
427
- }
428
- };
429
- function jsonRpcError(id, code, message, data) {
430
- return {
431
- jsonrpc: "2.0",
432
- id,
433
- error: { code, message, ...data === void 0 ? {} : { data } }
434
- };
435
- }
436
-
437
- // ../../packages/agent-runtime/dist/jsonl.js
438
- import { once } from "node:events";
439
- import { createInterface } from "node:readline";
440
- async function runAgentJsonlServer(input) {
441
- const dispatcher = new AgentJsonRpcDispatcher(input.host);
442
- let writeChain = Promise.resolve();
443
- const pendingNotifications = [];
444
- const write = (message) => {
445
- writeChain = writeChain.then(async () => {
446
- if (!input.writable.write(`${JSON.stringify(message)}
447
- `))
448
- await once(input.writable, "drain");
449
- });
450
- return writeChain;
451
- };
452
- const flushPendingNotifications = () => {
453
- if (!dispatcher.initialized || pendingNotifications.length === 0)
454
- return;
455
- for (const notification of pendingNotifications.splice(0))
456
- void write(notification);
457
- };
458
- const unsubscribe = input.host.subscribe?.((notification) => {
459
- if (!dispatcher.initialized) {
460
- pendingNotifications.push(notification);
461
- return;
462
- }
463
- void write(notification);
464
- });
465
- const inFlight = /* @__PURE__ */ new Set();
466
- const lines = createInterface({ input: input.readable, crlfDelay: Infinity });
467
- try {
468
- for await (const line of lines) {
469
- if (!line.trim())
470
- continue;
471
- let parsed;
472
- try {
473
- parsed = JSON.parse(line);
474
- } catch {
475
- await write({
476
- jsonrpc: "2.0",
477
- id: null,
478
- error: { code: -32700, message: "Parse error" }
479
- });
480
- continue;
481
- }
482
- const operation = (async () => {
483
- const response = await dispatcher.handle(parsed);
484
- if (response)
485
- await write(response);
486
- flushPendingNotifications();
487
- })();
488
- const method = parsed && typeof parsed === "object" && "method" in parsed ? parsed.method : null;
489
- if (method === "initialize" || method === "initialized") {
490
- await operation;
491
- continue;
492
- }
493
- inFlight.add(operation);
494
- void operation.finally(() => inFlight.delete(operation));
495
- }
496
- await Promise.all(inFlight);
497
- await writeChain;
498
- } finally {
499
- unsubscribe?.();
500
- }
501
- }
502
-
503
- // ../../packages/agent-runtime/dist/provider-loop.js
504
- async function* providerRoundSequence(input) {
505
- if (!Number.isInteger(input.maxRounds) || input.maxRounds < 1) {
506
- throw new Error("Provider maxRounds must be a positive integer.");
507
- }
508
- for (let index = 0; index < input.maxRounds; index += 1) {
509
- if (input.signal.aborted)
510
- throw input.signal.reason ?? new Error("Provider loop interrupted.");
511
- yield {
512
- index,
513
- requestId: `${input.turnId}:model:${index}`,
514
- signal: input.signal
515
- };
516
- }
517
- }
518
- async function runProviderRoundLoop(input) {
519
- for await (const round of providerRoundSequence(input)) {
520
- const decision = await input.runRound(round);
521
- if (decision.type === "complete")
522
- return decision.result;
523
- }
524
- return input.onExhausted();
525
- }
526
- async function runProviderRound(input) {
527
- let text = "";
528
- let reasoningText = "";
529
- let usage;
530
- let continuation = null;
531
- let finishReason;
532
- const toolCallBatches = [];
533
- try {
534
- for await (const delta of input.stream) {
535
- await input.onDelta?.(delta);
536
- if (input.signal.aborted) {
537
- throw input.signal.reason ?? new Error("Provider round interrupted.");
538
- }
539
- if (delta.text)
540
- text += delta.text;
541
- if (delta.reasoningText)
542
- reasoningText += delta.reasoningText;
543
- if (delta.usage !== void 0)
544
- usage = delta.usage;
545
- if (delta.continuation !== void 0)
546
- continuation = delta.continuation;
547
- if (delta.toolCalls)
548
- toolCallBatches.push([...delta.toolCalls]);
549
- if (delta.finishReason !== void 0)
550
- finishReason = delta.finishReason;
551
- }
552
- const result = {
553
- text,
554
- reasoningText,
555
- usage,
556
- continuation,
557
- toolCallBatches,
558
- finishReason
559
- };
560
- await input.onCompleted?.(result);
561
- return result;
562
- } catch (error) {
563
- await input.onFailed?.(error);
564
- throw error;
565
- }
566
- }
567
-
568
- // ../../packages/agent-runtime/dist/service.js
569
- var ThreadIdParamsSchema = external_exports.object({ threadId: external_exports.string().trim().min(1) }).passthrough();
570
- var ThreadStartParamsSchema = external_exports.object({ session: external_exports.unknown() }).strict();
571
- var TurnParamsSchema = ThreadIdParamsSchema.extend({ input: external_exports.unknown() });
572
- var InterruptParamsSchema = ThreadIdParamsSchema.extend({ reason: external_exports.string().trim().min(1).optional() });
573
- var ApprovalParamsSchema = external_exports.object({ approvalId: external_exports.string().trim().min(1), input: external_exports.unknown() }).strict();
574
- function createAgentRuntimeService(ports) {
575
- const run = async (method, threadId, operation) => {
576
- const startedAt = performance.now();
577
- ports.telemetry?.({ method, phase: "started", threadId, durationMs: null, errorClass: null });
578
- try {
579
- const result = await operation();
580
- ports.telemetry?.({
581
- method,
582
- phase: "completed",
583
- threadId,
584
- durationMs: performance.now() - startedAt,
585
- errorClass: null
586
- });
587
- return result;
588
- } catch (error) {
589
- ports.telemetry?.({
590
- method,
591
- phase: "failed",
592
- threadId,
593
- durationMs: performance.now() - startedAt,
594
- errorClass: error instanceof Error ? error.name : "UnknownError"
595
- });
596
- throw error;
597
- }
598
- };
599
- const threadRead = async (params, method = "thread/read") => {
600
- const { threadId } = ThreadIdParamsSchema.parse(params);
601
- return run(method, threadId, async () => {
602
- const [thread, turns, events] = await Promise.all([
603
- ports.readThread(threadId),
604
- ports.listTurns(threadId),
605
- ports.listEvents(threadId)
606
- ]);
607
- return { thread, turns, events };
608
- });
609
- };
610
- return {
611
- capabilities: (params) => run("runtime/capabilities", null, () => ports.capabilities(params)),
612
- threadStart: async (params) => run("thread/start", null, async () => ({
613
- thread: await ports.createThread(ThreadStartParamsSchema.parse(params).session)
614
- })),
615
- threadResume: (params) => threadRead(params, "thread/resume"),
616
- threadRead,
617
- turnStart: async (params) => {
618
- const input = TurnParamsSchema.parse(params);
619
- return run("turn/start", input.threadId, async () => ({
620
- turn: await ports.startTurn(input.threadId, input.input)
621
- }));
622
- },
623
- turnSteer: async (params) => {
624
- const input = TurnParamsSchema.parse(params);
625
- return run("turn/steer", input.threadId, async () => {
626
- if (ports.isTurnActive(input.threadId)) {
627
- await ports.waitForTurnSettlement(input.threadId);
628
- }
629
- return { turn: await ports.startTurn(input.threadId, input.input) };
630
- });
631
- },
632
- turnInterrupt: async (params) => {
633
- const input = InterruptParamsSchema.parse(params);
634
- return run("turn/interrupt", input.threadId, async () => ({
635
- turn: await ports.interruptTurn(input.threadId, input.reason)
636
- }));
637
- },
638
- approvalResolve: async (params) => {
639
- const input = ApprovalParamsSchema.parse(params);
640
- return run("approval/resolve", null, async () => ({
641
- approval: await ports.resolveApproval(input.approvalId, input.input)
642
- }));
643
- },
644
- userInputResolve: async (params) => {
645
- const input = TurnParamsSchema.parse(params);
646
- return run("userInput/resolve", input.threadId, async () => {
647
- if (ports.isTurnActive(input.threadId)) {
648
- await ports.waitForTurnSettlement(input.threadId);
649
- }
650
- return { turn: await ports.startTurn(input.threadId, input.input) };
651
- });
652
- },
653
- harnessInspect: () => run("harness/inspect", null, () => ports.inspectHarness()),
654
- harnessProposalReview: (params) => run("harness/proposalReview", null, () => ports.reviewHarnessProposal(params)),
655
- harnessReview: (params) => run("harness/review", null, () => ports.reviewHarness(params)),
656
- harnessAcceptEvaluationReview: (params) => run("harness/acceptEvaluationReview", null, () => ports.acceptHarnessEvaluationReview(params)),
657
- harnessMaterializeEvaluationTaskset: (params) => run("harness/materializeEvaluationTaskset", null, () => ports.materializeHarnessEvaluationTaskset(params)),
658
- harnessRunEvaluationBaseline: (params) => run("harness/runEvaluationBaseline", null, () => ports.runHarnessEvaluationBaseline(params)),
659
- harnessValidate: () => run("harness/validate", null, () => ports.validateHarness()),
660
- harnessBackgroundReview: (params) => run("harness/backgroundReview", null, () => ports.updateHarnessBackgroundReview(params)),
661
- harnessDiff: (params) => run("harness/diff", null, () => ports.diffHarness(params)),
662
- harnessRollback: (params) => run("harness/rollback", null, () => ports.rollbackHarness(params)),
663
- refinerInspect: () => run("refiner/inspect", null, () => ports.inspectRefiner()),
664
- refinerUpdate: (params) => run("refiner/update", null, () => ports.updateRefiner(params)),
665
- refinerActivate: (params) => run("refiner/activate", null, () => ports.activateRefiner(params)),
666
- refinerRollback: (params) => run("refiner/rollback", null, () => ports.rollbackRefiner(params)),
667
- subscribe: ports.subscribeEvents && ports.eventNotification ? (listener) => ports.subscribeEvents((event) => listener(ports.eventNotification(event))) : void 0
668
- };
669
- }
670
-
671
- // ../../packages/agent-runtime/dist/snapshots.js
672
- var HashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
673
- var AgentEffectiveSurfaceSchema = external_exports.object({
674
- harnessReleaseHash: HashSchema,
675
- instructionsHash: HashSchema,
676
- skillHashes: external_exports.record(external_exports.string(), HashSchema),
677
- agentAssetHashes: external_exports.record(external_exports.string(), HashSchema),
678
- toolCatalogHash: HashSchema,
679
- memoryRevision: external_exports.number().int().nonnegative().nullable()
680
- }).strict();
681
- var AgentCheckpointSchema = external_exports.object({
682
- protocolVersion: external_exports.string().trim().min(1),
683
- threadId: external_exports.string().trim().min(1),
684
- turnId: external_exports.string().trim().min(1),
685
- harnessReleaseHash: HashSchema,
686
- toolCatalogHash: HashSchema,
687
- context: external_exports.record(external_exports.string(), external_exports.unknown()),
688
- pendingInteraction: external_exports.record(external_exports.string(), external_exports.unknown()).nullable(),
689
- usage: external_exports.record(external_exports.string(), external_exports.unknown())
690
- }).strict();
691
- function checkpointHash(checkpoint) {
692
- return canonicalHash(AgentCheckpointSchema.parse(checkpoint));
693
- }
694
- function materializeAgentPrompt(input) {
695
- return [
696
- input.system,
697
- ...input.harnessInstructions,
698
- ...input.skillInstructions,
699
- ...input.hostInstructions ?? []
700
- ].map((part) => part.trim()).filter(Boolean).join("\n\n");
701
- }
702
-
703
- // ../../packages/agent-runtime/dist/tools.js
704
- function createAgentToolCatalogProjection(definitions) {
705
- const names = /* @__PURE__ */ new Set();
706
- const tools = [...definitions].map((definition) => {
707
- const name = definition.name.trim();
708
- if (!name)
709
- throw new Error("Agent tool names cannot be empty.");
710
- if (names.has(name))
711
- throw new Error(`Duplicate agent tool: ${name}.`);
712
- names.add(name);
713
- if (!definition.unavailableReason && !definition.executorAvailable) {
714
- throw new Error(`Agent tool ${name} is declared as available without an executor.`);
715
- }
716
- return { ...definition, name };
717
- }).sort((left, right) => left.name.localeCompare(right.name));
718
- const modelTools = tools.filter((tool) => !tool.unavailableReason).map((tool) => ({
719
- name: tool.name,
720
- description: tool.description,
721
- inputSchema: tool.inputSchema
722
- }));
723
- const capabilities = tools.map((tool) => ({
724
- name: tool.name,
725
- displayLabel: tool.displayLabel ?? tool.name,
726
- placement: tool.placement,
727
- available: !tool.unavailableReason,
728
- unavailableReason: tool.unavailableReason ?? null
729
- }));
730
- return {
731
- byName: new Map(tools.map((tool) => [tool.name, tool])),
732
- tools,
733
- modelTools,
734
- capabilities,
735
- hash: canonicalHash({ modelTools, capabilities })
736
- };
737
- }
738
- async function executeProjectedAgentTool(catalog, input) {
739
- const definition = catalog.byName.get(input.name);
740
- if (!definition)
741
- throw new Error(`Unknown agent tool: ${input.name}.`);
742
- if (definition.unavailableReason) {
743
- throw new Error(`Agent tool ${input.name} is unavailable: ${definition.unavailableReason}`);
744
- }
745
- if (!definition.execute)
746
- throw new Error(`Agent tool ${input.name} has no executor.`);
747
- const validated = definition.validateArguments ? definition.validateArguments(input.arguments) : input.arguments;
748
- return definition.execute(validated, input.context);
749
- }
750
-
751
- // ../../packages/app-server/dist/index.js
752
- function createAppServer(input) {
753
- return attachAppServer({
754
- runtime: createAgentRuntimeService(input.ports),
755
- close: input.close
756
- });
757
- }
758
- function attachAppServer(input) {
759
- let closed = false;
760
- return {
761
- runtime: input.runtime,
762
- close: async () => {
763
- if (closed)
764
- return;
765
- closed = true;
766
- await input.close?.();
767
- }
768
- };
769
- }
770
- async function runAppServerJsonl(input) {
771
- try {
772
- await runAgentJsonlServer({
773
- host: input.appServer.runtime,
774
- readable: input.readable,
775
- writable: input.writable
776
- });
777
- } finally {
778
- await input.appServer.close();
779
- }
780
- }
781
-
782
- // ../server/src/paths.ts
783
- import { randomBytes } from "node:crypto";
784
- function appDataDir() {
785
- return resolveOpenPondHome();
786
- }
787
- function providersConfigPath(storeDir) {
788
- return storagePaths(storeDir).config;
789
- }
790
- function providerSecretsConfigPath(storeDir) {
791
- return storagePaths(storeDir).credentials;
792
- }
793
- function providerSecretsKeyPath(storeDir) {
794
- return storagePaths(storeDir).key;
795
- }
796
- async function ensureCapabilityToken(storeDir) {
797
- const tokenFile = storagePaths(storeDir).token;
798
- return withFileLock(tokenFile, async () => {
799
- const existing = (await readOptionalFile(tokenFile))?.trim();
800
- const token = process.env.OPENPOND_APP_TOKEN || existing || randomBytes(32).toString("base64url");
801
- if (token !== existing) await atomicWriteFile(tokenFile, token);
802
- return { token, tokenFile };
803
- });
804
- }
805
-
806
- export {
807
- onStartupFailure,
808
- ownHomeRuntime,
809
- publishRuntimeEndpoint,
810
- canonicalHash,
811
- agentCompactionDecision,
812
- runAgentCompaction,
813
- runAgentCompactionProgram,
814
- CanonicalAgentEventSchema,
815
- canonicalEventHash,
816
- AGENT_PROTOCOL_VERSION,
817
- AGENT_RPC_METHODS,
818
- runProviderRoundLoop,
819
- runProviderRound,
820
- AgentCheckpointSchema,
821
- checkpointHash,
822
- materializeAgentPrompt,
823
- createAgentToolCatalogProjection,
824
- executeProjectedAgentTool,
825
- createAppServer,
826
- runAppServerJsonl,
827
- appDataDir,
828
- providersConfigPath,
829
- providerSecretsConfigPath,
830
- providerSecretsKeyPath,
831
- ensureCapabilityToken
832
- };