nolo-cli 0.33.0-alpha.21 → 0.33.0-alpha.23

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 (86) hide show
  1. package/{_executeModel-XKWVTZAY.js → _executeModel-C7G6UGVX.js} +21 -18
  2. package/{agentDeleteCommand-ZU4H6F6M.js → agentDeleteCommand-7T2AQL7Q.js} +24 -21
  3. package/{agentEmailCommands-6ULFXW4A.js → agentEmailCommands-M22DG56U.js} +37 -34
  4. package/{agentListCommands-VN7WCW7Z.js → agentListCommands-HDSQVOTR.js} +23 -20
  5. package/{agentMachineCommands-5PALVQBD.js → agentMachineCommands-B7HAFERS.js} +22 -19
  6. package/{agentRecordCommands-XEB66KRX.js → agentRecordCommands-DNEOXRTE.js} +28 -25
  7. package/{agentRunCommand-OJX27NII.js → agentRunCommand-G55YHYDL.js} +30 -27
  8. package/{agentRuntimeLocal-UWDOE55A.js → agentRuntimeLocal-YQGVUJ57.js} +10 -7
  9. package/{agentSlice-SZRRJ3ZX.js → agentSlice-A56VMSUG.js} +1 -1
  10. package/{appDeleteCommands-R63PZAY7.js → appDeleteCommands-57GIWQQ5.js} +17 -14
  11. package/{appDeployCommands-VNRT54YO.js → appDeployCommands-7IMZSUMQ.js} +17 -14
  12. package/{appDeployStatusCommands-6IPTKLEM.js → appDeployStatusCommands-ZNCK7TDT.js} +17 -14
  13. package/{appGetCommands-JPFVMVAI.js → appGetCommands-AZ4JVCGY.js} +17 -14
  14. package/{appListCommands-B3SLTPII.js → appListCommands-ABRHLEL7.js} +17 -14
  15. package/{authCommand-EX5G5PF4.js → authCommand-T5XN3VP2.js} +10 -10
  16. package/{authCommands-VR6Q6GU2.js → authCommands-W74NRPA6.js} +5 -5
  17. package/{chatQueueReduxAdapter-IEX32ZVP.js → chatQueueReduxAdapter-7CKSPWO5.js} +5 -5
  18. package/{chunk-XS543SNR.js → chunk-25MFIHEP.js} +3 -3
  19. package/{chunk-V4MT7AEN.js → chunk-3CVNNFKF.js} +7 -7
  20. package/chunk-3Z32AD6X.js +22 -0
  21. package/{chunk-PU47HKTF.js → chunk-3Z7GNZLS.js} +13 -13
  22. package/{chunk-XTSVOICC.js → chunk-4LSQNSXE.js} +25 -25
  23. package/{chunk-IHEC7VBF.js → chunk-4ZPH5WGJ.js} +1 -1
  24. package/{chunk-6MSSX7FI.js → chunk-AMKT2XOP.js} +2 -2
  25. package/{chunk-EQ6HOWEJ.js → chunk-EF36FMUE.js} +1 -1
  26. package/{chunk-SBPGB6TF.js → chunk-G3ONB6Y5.js} +5 -5
  27. package/{chunk-U2FRXKC7.js → chunk-JSIQQCPR.js} +1 -1
  28. package/{chunk-46JSKTPF.js → chunk-MIN2TNAM.js} +293 -64
  29. package/{chunk-LLKHGZME.js → chunk-O3LO3MRU.js} +13 -13
  30. package/{chunk-LJGEEYGC.js → chunk-OA7LCLY3.js} +1 -1
  31. package/{chunk-37LDAHQN.js → chunk-OH6MOEZN.js} +10 -10
  32. package/{chunk-REOW4YJX.js → chunk-OLFLSOUV.js} +5 -5
  33. package/{chunk-2UDMTJOM.js → chunk-PFJA4C7K.js} +13 -13
  34. package/{chunk-7BNPRRDS.js → chunk-R7UWXBVG.js} +21 -21
  35. package/{chunk-YH3FPBG6.js → chunk-SEFDSJK4.js} +321 -4
  36. package/chunk-TVXJEOU2.js +78 -0
  37. package/{chunk-GTEHJWXU.js → chunk-TZV6ELNR.js} +1 -1
  38. package/{chunk-RO3AEN3L.js → chunk-UCUCOZXY.js} +2 -2
  39. package/chunk-UOLENXLQ.js +1132 -0
  40. package/{chunk-M2YMQOLC.js → chunk-WHLQYPJZ.js} +12 -12
  41. package/{chunk-V44VE7R4.js → chunk-XLUTBJYU.js} +4 -4
  42. package/{chunk-JL2PUYVS.js → chunk-YBWR3WBJ.js} +12 -12
  43. package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
  44. package/{createAgentAutomationAction-72NNXELT.js → createAgentAutomationAction-YTMO34HZ.js} +6 -6
  45. package/{createDialogAction-3CJ2GXNO.js → createDialogAction-3B3FT7Y7.js} +7 -7
  46. package/{createPageAction-HZHQGQO6.js → createPageAction-WHUA54EI.js} +6 -6
  47. package/{dialogCommands-2BF4ZSWH.js → dialogCommands-OJYXBAR2.js} +16 -13
  48. package/{dialogSlice-5R4O4377.js → dialogSlice-S7CBGXUY.js} +5 -5
  49. package/{docCreateCommands-HMZUBFGL.js → docCreateCommands-LJPAIEMJ.js} +16 -13
  50. package/{docDeleteCommands-DFR7GCOR.js → docDeleteCommands-I7TIHWFQ.js} +17 -14
  51. package/{docReadCommands-YM7RDUAZ.js → docReadCommands-7RUZYEAA.js} +16 -13
  52. package/{docStore-A4SRW2DJ.js → docStore-YZACMKQG.js} +7 -7
  53. package/{docUpdateCommands-TTQBD7IU.js → docUpdateCommands-HTR5Y737.js} +16 -13
  54. package/emscripten-module-EDQBMDVK.js +576 -0
  55. package/emscripten-module-LCBQ7VWY.js +1506 -0
  56. package/emscripten-module-OFHQ7EL3.js +482 -0
  57. package/emscripten-module-XM7NDJQA.js +4536 -0
  58. package/ffi-6ZSX3QJ4.js +80 -0
  59. package/ffi-742Y76PE.js +92 -0
  60. package/ffi-AEYWSYLM.js +80 -0
  61. package/ffi-KQC27OUM.js +92 -0
  62. package/{handleSendMessageAction-CIFBZCI2.js → handleSendMessageAction-HJUPYPBF.js} +5 -5
  63. package/index.js +67 -67
  64. package/{machineCommands-QSW4JKR2.js → machineCommands-IJL73WA5.js} +39 -36
  65. package/{machineWsRunDispatch-X3ZC7DZJ.js → machineWsRunDispatch-7RE5KJRG.js} +26 -23
  66. package/module-ES6BEMUI-AFCVSBMS.js +14 -0
  67. package/module-asyncify-2EFITU5U-DEP2F2QP.js +9 -0
  68. package/package.json +1 -1
  69. package/{readlineWorkspace-J2ARMEUC.js → readlineWorkspace-EGSZ26XS.js} +196 -147
  70. package/{runAgentClientLoop-5I2R74NR.js → runAgentClientLoop-7OD74SBW.js} +12 -12
  71. package/{spaceCommands-EZYMMJJH.js → spaceCommands-5NCZJOOC.js} +23 -20
  72. package/{spaceSlice-TL2FR4AF.js → spaceSlice-KD2BB5GS.js} +6 -6
  73. package/{streamAgentChatTurn-UDYSE2ES.js → streamAgentChatTurn-LDQPG7A3.js} +32 -29
  74. package/{tools-KWYWDJ77.js → tools-XAC2C4LK.js} +10 -10
  75. package/{tuiSummaryLlmCaller-WUVAOIYU.js → tuiSummaryLlmCaller-LAOHMDTM.js} +3 -3
  76. package/{updateDialogTitleAction-NQCOEOLF.js → updateDialogTitleAction-PDIR5IVC.js} +8 -8
  77. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-OPIGFRDO.js} +2 -2
  78. package/{agentPullCommand-TSWAJPS2.js → agentPullCommand-NYHSK6EW.js} +2 -2
  79. package/{chunk-YDTYDA5W.js → chunk-BY53PPQ2.js} +3 -3
  80. package/{chunk-HCOIKLSH.js → chunk-CP4QR2D2.js} +3 -3
  81. package/{chunk-ZHYK3N56.js → chunk-G7HTVVFL.js} +3 -3
  82. package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
  83. package/{chunk-N2WDGMD5.js → chunk-N543Q3VR.js} +12 -12
  84. package/{offlineMarxistsAgentCommand-GEH6SNNA.js → offlineMarxistsAgentCommand-HDIQVGKN.js} +3 -3
  85. package/{runtimeDoctorCommands-KHGQKT3B.js → runtimeDoctorCommands-HT4O2PXL.js} +3 -3
  86. package/{tableCommands-64FZBAI3.js → tableCommands-5OKD2DKN.js} +8 -8
@@ -11,24 +11,32 @@ import {
11
11
  deleteDialog,
12
12
  resetMsgs,
13
13
  toast
14
- } from "./chunk-JL2PUYVS.js";
14
+ } from "./chunk-YBWR3WBJ.js";
15
15
  import {
16
16
  deleteServerSyncedCredential
17
- } from "./chunk-XS543SNR.js";
17
+ } from "./chunk-25MFIHEP.js";
18
18
  import {
19
19
  require_date_fns
20
20
  } from "./chunk-M76ECQRD.js";
21
21
  import {
22
22
  createFileCredentialBroker
23
23
  } from "./chunk-RQFO3CAF.js";
24
+ import {
25
+ toErrorMessage
26
+ } from "./chunk-HNMXYYJR.js";
27
+ import {
28
+ UNCATEGORIZED_ID,
29
+ addContentAction,
30
+ checkSpaceMembership,
31
+ createSpaceKey,
32
+ localSpaceAuthorityPatchStamp,
33
+ normalizeSpaceId
34
+ } from "./chunk-KMMQFY5O.js";
24
35
  import {
25
36
  clearPendingAttachments,
26
37
  clearPendingUserInputQueue,
27
38
  require_react
28
39
  } from "./chunk-MRWGHF56.js";
29
- import {
30
- toErrorMessage
31
- } from "./chunk-HNMXYYJR.js";
32
40
  import {
33
41
  isSystemAdmin,
34
42
  selectRemoteServer,
@@ -37,14 +45,6 @@ import {
37
45
  import {
38
46
  asRecordOrEmpty
39
47
  } from "./chunk-KX6YBIHG.js";
40
- import {
41
- UNCATEGORIZED_ID,
42
- addContentAction,
43
- checkSpaceMembership,
44
- createSpaceKey,
45
- localSpaceAuthorityPatchStamp,
46
- normalizeSpaceId
47
- } from "./chunk-KMMQFY5O.js";
48
48
  import {
49
49
  patch,
50
50
  read,
@@ -21,6 +21,9 @@ import {
21
21
  readPageFunctionSchema,
22
22
  slateToSimplifiedMarkdown
23
23
  } from "./chunk-KIL7V27H.js";
24
+ import {
25
+ setDialogExtraReferencesAction
26
+ } from "./chunk-L5XKDBSH.js";
24
27
  import {
25
28
  markdownToSlate
26
29
  } from "./chunk-INZZJSQF.js";
@@ -35,17 +38,14 @@ import {
35
38
  } from "./chunk-VF4K2QE6.js";
36
39
  import {
37
40
  createDocState
38
- } from "./chunk-SBPGB6TF.js";
39
- import {
40
- setDialogExtraReferencesAction
41
- } from "./chunk-L5XKDBSH.js";
41
+ } from "./chunk-G3ONB6Y5.js";
42
42
  import {
43
43
  BUILTIN_OBJECT_SKILL_IDS,
44
44
  buildBuiltinObjectSkillConfig,
45
45
  buildBuiltinObjectSkillDbKey,
46
46
  buildBuiltinObjectSkillPageContent,
47
47
  createDialogAction
48
- } from "./chunk-RO3AEN3L.js";
48
+ } from "./chunk-UCUCOZXY.js";
49
49
  import {
50
50
  addCategory,
51
51
  addContentToSpace,
@@ -65,7 +65,7 @@ import {
65
65
  loadTableRows,
66
66
  updateContentCategory,
67
67
  updateContentTitle
68
- } from "./chunk-2UDMTJOM.js";
68
+ } from "./chunk-PFJA4C7K.js";
69
69
  import {
70
70
  incrementFailedSteps,
71
71
  incrementStepsExecuted,
@@ -79,13 +79,13 @@ import {
79
79
  uiAskChoiceFunc,
80
80
  uiAskChoiceFunctionSchema,
81
81
  updateStep
82
- } from "./chunk-JL2PUYVS.js";
82
+ } from "./chunk-YBWR3WBJ.js";
83
83
  import {
84
84
  createAgent,
85
85
  runLlm,
86
86
  streamAgentChatTurn,
87
87
  updateAgent
88
- } from "./chunk-XS543SNR.js";
88
+ } from "./chunk-25MFIHEP.js";
89
89
  import {
90
90
  NOLO_WORKSPACE_TOOL_NAMES,
91
91
  buildAgentRuntimeAgentLookupKeys,
@@ -103,10 +103,18 @@ import {
103
103
  } from "./chunk-ADLYMQB6.js";
104
104
  import {
105
105
  buildDatabaseFileContentUrl
106
- } from "./chunk-HCOIKLSH.js";
106
+ } from "./chunk-CP4QR2D2.js";
107
107
  import {
108
108
  DEFAULT_MODEL
109
109
  } from "./chunk-7SLMYTSF.js";
110
+ import {
111
+ toErrorMessage
112
+ } from "./chunk-HNMXYYJR.js";
113
+ import {
114
+ addContentAction,
115
+ createSpaceKey,
116
+ normalizeSpaceId
117
+ } from "./chunk-KMMQFY5O.js";
110
118
  import {
111
119
  CODING_SKILL_SLUGS,
112
120
  buildCodingSkillConfig,
@@ -155,9 +163,6 @@ import {
155
163
  formatStopRunCard,
156
164
  resolveRunLabel
157
165
  } from "./chunk-KXKQO4Q6.js";
158
- import {
159
- toErrorMessage
160
- } from "./chunk-HNMXYYJR.js";
161
166
  import {
162
167
  shareResourceAction
163
168
  } from "./chunk-DDET6246.js";
@@ -172,11 +177,6 @@ import {
172
177
  import {
173
178
  asRecordOrEmpty
174
179
  } from "./chunk-KX6YBIHG.js";
175
- import {
176
- addContentAction,
177
- createSpaceKey,
178
- normalizeSpaceId
179
- } from "./chunk-KMMQFY5O.js";
180
180
  import {
181
181
  patch,
182
182
  read,
@@ -14907,7 +14907,7 @@ async function deleteDialogsFunc(args, thunkApi) {
14907
14907
  const deletedDialogIds = [];
14908
14908
  const deletedDialogKeys = [];
14909
14909
  const failures = [];
14910
- const { deleteDialog } = await import("./dialogSlice-5R4O4377.js");
14910
+ const { deleteDialog } = await import("./dialogSlice-S7CBGXUY.js");
14911
14911
  for (const target of targets) {
14912
14912
  try {
14913
14913
  await thunkApi.dispatch(deleteDialog(target.dbKey)).unwrap();
@@ -24434,7 +24434,7 @@ var executeToolRun = createAsyncThunk(
24434
24434
  if (!executionInput) {
24435
24435
  throw new Error(`ToolRun ${id} has no input to execute with.`);
24436
24436
  }
24437
- const { findToolExecutor: findToolExecutor2 } = await import("./tools-KWYWDJ77.js");
24437
+ const { findToolExecutor: findToolExecutor2 } = await import("./tools-XAC2C4LK.js");
24438
24438
  const { executor } = findToolExecutor2(run.toolName);
24439
24439
  toolRunStarted({
24440
24440
  id: run.id,
@@ -24458,7 +24458,7 @@ var executeToolRun = createAsyncThunk(
24458
24458
  const latestState = thunkApi.getState();
24459
24459
  const userId = latestState.auth?.currentUser?.userId;
24460
24460
  if (userId) {
24461
- const { fetchUserSpaceMemberships } = await import("./spaceSlice-TL2FR4AF.js");
24461
+ const { fetchUserSpaceMemberships } = await import("./spaceSlice-KD2BB5GS.js");
24462
24462
  await thunkApi.dispatch(fetchUserSpaceMemberships(userId));
24463
24463
  }
24464
24464
  }
@@ -26941,7 +26941,7 @@ async function updateDocFunc(args, thunkApi) {
26941
26941
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
26942
26942
  };
26943
26943
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
26944
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-A4SRW2DJ.js");
26944
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-YZACMKQG.js");
26945
26945
  if (getDocState().pageKey === id) {
26946
26946
  applyExternalDocUpdate({
26947
26947
  slateData: finalSlateData,
@@ -18,11 +18,14 @@ import {
18
18
  formatMessagesForSummaryWithTruncation,
19
19
  planCompression,
20
20
  planContextUsage
21
- } from "./chunk-HCOIKLSH.js";
21
+ } from "./chunk-CP4QR2D2.js";
22
22
  import {
23
23
  findModelConfig,
24
24
  getProviderByModelName
25
25
  } from "./chunk-7SLMYTSF.js";
26
+ import {
27
+ toErrorMessage
28
+ } from "./chunk-HNMXYYJR.js";
26
29
  import {
27
30
  buildDialogSummaryLayer
28
31
  } from "./chunk-3AOLVADY.js";
@@ -33,9 +36,6 @@ import {
33
36
  canonicalizeToolName,
34
37
  canonicalizeToolNames
35
38
  } from "./chunk-ZZ2MH7LE.js";
36
- import {
37
- toErrorMessage
38
- } from "./chunk-HNMXYYJR.js";
39
39
  import {
40
40
  asRecordOrEmpty
41
41
  } from "./chunk-KX6YBIHG.js";
@@ -1709,6 +1709,307 @@ function createCapabilitySdk(args) {
1709
1709
  };
1710
1710
  }
1711
1711
 
1712
+ // packages/agent-runtime/capabilities/ptcExecutionContext.ts
1713
+ import { isAbsolute } from "node:path";
1714
+ var PtcContextValidationError = class extends Error {
1715
+ constructor(message) {
1716
+ super(`PTC context validation failed: ${message}`);
1717
+ this.name = "PtcContextValidationError";
1718
+ }
1719
+ };
1720
+ function createPtcFailClosedContext(input) {
1721
+ if (!input || typeof input !== "object") {
1722
+ throw new PtcContextValidationError("Turn context object is required for PTC execution.");
1723
+ }
1724
+ const raw = input;
1725
+ if (typeof raw.workspaceRoot !== "string" || !raw.workspaceRoot.trim()) {
1726
+ throw new PtcContextValidationError(
1727
+ "PTC execution requires an explicit, non-empty 'workspaceRoot'. Fallback to process.cwd() is strictly forbidden."
1728
+ );
1729
+ }
1730
+ if (!isAbsolute(raw.workspaceRoot.trim())) {
1731
+ throw new PtcContextValidationError(
1732
+ `PTC execution requires an absolute path for 'workspaceRoot' (received "${raw.workspaceRoot}").`
1733
+ );
1734
+ }
1735
+ if (!raw.abortSignal || !(raw.abortSignal instanceof AbortSignal) || typeof raw.abortSignal.aborted !== "boolean" || typeof raw.abortSignal.addEventListener !== "function") {
1736
+ throw new PtcContextValidationError(
1737
+ "PTC execution requires an explicit 'abortSignal' (AbortSignal) from current turn context."
1738
+ );
1739
+ }
1740
+ if (typeof raw.restrictToWorkspace !== "boolean") {
1741
+ throw new PtcContextValidationError(
1742
+ "PTC execution requires an explicit boolean 'restrictToWorkspace' setting."
1743
+ );
1744
+ }
1745
+ if (typeof raw.enableDestructiveShellGuard !== "boolean") {
1746
+ throw new PtcContextValidationError(
1747
+ "PTC execution requires an explicit boolean 'enableDestructiveShellGuard' setting."
1748
+ );
1749
+ }
1750
+ const validated = {
1751
+ workspaceRoot: raw.workspaceRoot.trim(),
1752
+ abortSignal: raw.abortSignal,
1753
+ restrictToWorkspace: raw.restrictToWorkspace,
1754
+ enableDestructiveShellGuard: raw.enableDestructiveShellGuard,
1755
+ blockDestructiveWithoutConfirmation: typeof raw.blockDestructiveWithoutConfirmation === "boolean" ? raw.blockDestructiveWithoutConfirmation : void 0,
1756
+ confirmDestructiveAction: typeof raw.confirmDestructiveAction === "function" ? raw.confirmDestructiveAction : void 0,
1757
+ commandTimeoutMs: typeof raw.commandTimeoutMs === "number" ? raw.commandTimeoutMs : void 0,
1758
+ commandOutputLimit: typeof raw.commandOutputLimit === "number" ? raw.commandOutputLimit : void 0,
1759
+ commandPrefix: Array.isArray(raw.commandPrefix) ? raw.commandPrefix : void 0,
1760
+ detachMs: typeof raw.detachMs === "number" ? raw.detachMs : void 0,
1761
+ confirmed: typeof raw.confirmed === "boolean" ? raw.confirmed : void 0,
1762
+ agentRunService: raw.agentRunService,
1763
+ onInvoke: typeof raw.onInvoke === "function" ? raw.onInvoke : void 0,
1764
+ activityContext: raw.activityContext,
1765
+ onActivity: typeof raw.onActivity === "function" ? raw.onActivity : void 0
1766
+ };
1767
+ return validated;
1768
+ }
1769
+ function createPtcCapabilitySdk(args) {
1770
+ const strictContext = createPtcFailClosedContext(args.turnContext);
1771
+ const sdk = createCapabilitySdk({
1772
+ context: strictContext,
1773
+ capabilities: args.capabilities ?? BUILTIN_CAPABILITIES
1774
+ });
1775
+ return {
1776
+ sdk,
1777
+ context: strictContext
1778
+ };
1779
+ }
1780
+
1781
+ // node_modules/quickjs-emscripten-core/dist/index.mjs
1782
+ async function newQuickJSWASMModuleFromVariant(variantOrPromise) {
1783
+ let variant2 = smartUnwrap(await variantOrPromise), [wasmModuleLoader, QuickJSFFI, { QuickJSWASMModule: QuickJSWASMModule2 }] = await Promise.all([variant2.importModuleLoader().then(smartUnwrap), variant2.importFFI(), import("./module-ES6BEMUI-AFCVSBMS.js").then(smartUnwrap)]), wasmModule = await wasmModuleLoader();
1784
+ wasmModule.type = "sync";
1785
+ let ffi = new QuickJSFFI(wasmModule);
1786
+ return new QuickJSWASMModule2(wasmModule, ffi);
1787
+ }
1788
+ function smartUnwrap(val) {
1789
+ return val && "default" in val && val.default ? val.default && "default" in val.default && val.default.default ? val.default.default : val.default : val;
1790
+ }
1791
+
1792
+ // node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs
1793
+ var variant = { type: "sync", importFFI: () => import("./ffi-AEYWSYLM.js").then((mod) => mod.QuickJSFFI), importModuleLoader: () => import("./emscripten-module-OFHQ7EL3.js").then((mod) => mod.default) };
1794
+ var src_default = variant;
1795
+
1796
+ // node_modules/quickjs-emscripten/dist/chunk-OHAYRCBA.mjs
1797
+ async function newQuickJSWASMModule(variantOrPromise = src_default) {
1798
+ return newQuickJSWASMModuleFromVariant(variantOrPromise);
1799
+ }
1800
+
1801
+ // packages/agent-runtime/ptcQuickJsPrototype.ts
1802
+ function marshalJsonToQuickJs(vm, data) {
1803
+ const jsonStr = JSON.stringify(data ?? null);
1804
+ const strHandle = vm.newString(jsonStr);
1805
+ const jsonHandle = vm.getProp(vm.global, "JSON");
1806
+ const parseHandle = vm.getProp(jsonHandle, "parse");
1807
+ const res = vm.callFunction(parseHandle, jsonHandle, strHandle);
1808
+ strHandle.dispose();
1809
+ jsonHandle.dispose();
1810
+ parseHandle.dispose();
1811
+ return vm.unwrapResult(res);
1812
+ }
1813
+ async function executePtcQuickJsPrototype(options) {
1814
+ const QuickJS = await newQuickJSWASMModule();
1815
+ const runtime = QuickJS.newRuntime();
1816
+ if (options.memoryLimitBytes) {
1817
+ runtime.setMemoryLimit(options.memoryLimitBytes);
1818
+ } else {
1819
+ runtime.setMemoryLimit(16 * 1024 * 1024);
1820
+ }
1821
+ const executionController = new AbortController();
1822
+ const onParentAbort = () => {
1823
+ executionController.abort(options.abortSignal?.reason);
1824
+ };
1825
+ if (options.abortSignal) {
1826
+ if (options.abortSignal.aborted) {
1827
+ executionController.abort(options.abortSignal.reason);
1828
+ } else {
1829
+ options.abortSignal.addEventListener("abort", onParentAbort, { once: true });
1830
+ }
1831
+ }
1832
+ let wasInterrupted = false;
1833
+ const startTime = Date.now();
1834
+ const timeoutMs = options.timeoutMs ?? 5e3;
1835
+ const deadline = startTime + timeoutMs;
1836
+ runtime.setInterruptHandler(() => {
1837
+ if (executionController.signal.aborted || options.abortSignal?.aborted) {
1838
+ wasInterrupted = true;
1839
+ return true;
1840
+ }
1841
+ if (Date.now() > deadline) {
1842
+ wasInterrupted = true;
1843
+ executionController.abort(new Error("Execution timed out."));
1844
+ return true;
1845
+ }
1846
+ return false;
1847
+ });
1848
+ const vm = runtime.newContext();
1849
+ const activeHandles = [];
1850
+ const activePromises = /* @__PURE__ */ new Set();
1851
+ const trackHandle = (h) => {
1852
+ activeHandles.push(h);
1853
+ return h;
1854
+ };
1855
+ try {
1856
+ const toolsHandle = vm.newObject();
1857
+ if (options.tools?.execShell) {
1858
+ const execShellHost = options.tools.execShell;
1859
+ const execShellFn = vm.newFunction("execShell", (argHandle) => {
1860
+ const promiseObj = vm.newPromise();
1861
+ activePromises.add(promiseObj);
1862
+ const input = vm.dump(argHandle);
1863
+ execShellHost(input, { signal: executionController.signal }).then((res) => {
1864
+ if (vm.alive) {
1865
+ const val = marshalJsonToQuickJs(vm, res);
1866
+ promiseObj.resolve(val);
1867
+ val.dispose();
1868
+ runtime.executePendingJobs();
1869
+ }
1870
+ }).catch((err) => {
1871
+ if (vm.alive) {
1872
+ const errHandle = vm.newError(err?.message ?? String(err));
1873
+ promiseObj.reject(errHandle);
1874
+ errHandle.dispose();
1875
+ runtime.executePendingJobs();
1876
+ }
1877
+ }).finally(() => {
1878
+ activePromises.delete(promiseObj);
1879
+ try {
1880
+ promiseObj.dispose();
1881
+ } catch {
1882
+ }
1883
+ });
1884
+ return promiseObj.handle;
1885
+ });
1886
+ vm.setProp(toolsHandle, "execShell", execShellFn);
1887
+ execShellFn.dispose();
1888
+ }
1889
+ const agentsHandle = vm.newObject();
1890
+ if (options.tools?.agents?.run) {
1891
+ const agentsRunHost = options.tools.agents.run;
1892
+ const agentsRunFn = vm.newFunction("run", (argHandle) => {
1893
+ const promiseObj = vm.newPromise();
1894
+ activePromises.add(promiseObj);
1895
+ const input = vm.dump(argHandle);
1896
+ agentsRunHost(input, { signal: executionController.signal }).then((res) => {
1897
+ if (vm.alive) {
1898
+ const val = marshalJsonToQuickJs(vm, res);
1899
+ promiseObj.resolve(val);
1900
+ val.dispose();
1901
+ runtime.executePendingJobs();
1902
+ }
1903
+ }).catch((err) => {
1904
+ if (vm.alive) {
1905
+ const errHandle = vm.newError(err?.message ?? String(err));
1906
+ promiseObj.reject(errHandle);
1907
+ errHandle.dispose();
1908
+ runtime.executePendingJobs();
1909
+ }
1910
+ }).finally(() => {
1911
+ activePromises.delete(promiseObj);
1912
+ try {
1913
+ promiseObj.dispose();
1914
+ } catch {
1915
+ }
1916
+ });
1917
+ return promiseObj.handle;
1918
+ });
1919
+ vm.setProp(agentsHandle, "run", agentsRunFn);
1920
+ agentsRunFn.dispose();
1921
+ }
1922
+ vm.setProp(toolsHandle, "agents", agentsHandle);
1923
+ agentsHandle.dispose();
1924
+ vm.setProp(vm.global, "tools", toolsHandle);
1925
+ toolsHandle.dispose();
1926
+ const wrapper = `
1927
+ ${options.code}
1928
+ ;(async () => {
1929
+ if (typeof main !== "function") {
1930
+ throw new Error("Entrypoint 'main(tools)' function not found.");
1931
+ }
1932
+ return await main(tools);
1933
+ })();
1934
+ `;
1935
+ const evalRes = vm.evalCode(wrapper);
1936
+ if (evalRes.error) {
1937
+ const errorDump = vm.dump(evalRes.error);
1938
+ evalRes.error.dispose();
1939
+ const errorMsg = typeof errorDump === "object" && errorDump !== null ? errorDump.message || JSON.stringify(errorDump) : String(errorDump);
1940
+ const isOom = errorMsg.includes("out of memory");
1941
+ const isInterrupted = errorMsg.includes("interrupted") || wasInterrupted;
1942
+ return {
1943
+ ok: false,
1944
+ error: errorMsg,
1945
+ interrupted: isInterrupted,
1946
+ outOfMemory: isOom
1947
+ };
1948
+ }
1949
+ const mainPromiseHandle = trackHandle(vm.unwrapResult(evalRes));
1950
+ while (true) {
1951
+ if (options.abortSignal?.aborted || executionController.signal.aborted) {
1952
+ return { ok: false, error: "Execution aborted by AbortSignal.", interrupted: true };
1953
+ }
1954
+ if (Date.now() > deadline) {
1955
+ executionController.abort(new Error("Execution timed out."));
1956
+ return { ok: false, error: "Execution timed out.", interrupted: true };
1957
+ }
1958
+ runtime.executePendingJobs();
1959
+ const state = vm.getPromiseState(mainPromiseHandle);
1960
+ if (state.type === "fulfilled") {
1961
+ const val = vm.dump(state.value);
1962
+ state.value.dispose();
1963
+ return { ok: true, result: val };
1964
+ } else if (state.type === "rejected") {
1965
+ const err = vm.dump(state.error);
1966
+ state.error.dispose();
1967
+ const errorMsg = typeof err === "object" && err !== null ? err.message || JSON.stringify(err) : String(err);
1968
+ const isOom = errorMsg.includes("out of memory");
1969
+ const isInterrupted = errorMsg.includes("interrupted") || wasInterrupted;
1970
+ return {
1971
+ ok: false,
1972
+ error: errorMsg,
1973
+ interrupted: isInterrupted,
1974
+ outOfMemory: isOom
1975
+ };
1976
+ }
1977
+ await new Promise((r) => setTimeout(r, 10));
1978
+ }
1979
+ } catch (err) {
1980
+ return { ok: false, error: err?.message ?? String(err) };
1981
+ } finally {
1982
+ if (options.abortSignal) {
1983
+ options.abortSignal.removeEventListener("abort", onParentAbort);
1984
+ }
1985
+ try {
1986
+ executionController.abort(new Error("Sandbox context disposed."));
1987
+ } catch {
1988
+ }
1989
+ for (const p of activePromises) {
1990
+ try {
1991
+ p.dispose();
1992
+ } catch {
1993
+ }
1994
+ }
1995
+ activePromises.clear();
1996
+ for (const h of activeHandles) {
1997
+ try {
1998
+ if (h.alive) h.dispose();
1999
+ } catch {
2000
+ }
2001
+ }
2002
+ try {
2003
+ vm.dispose();
2004
+ } catch {
2005
+ }
2006
+ try {
2007
+ runtime.dispose();
2008
+ } catch {
2009
+ }
2010
+ }
2011
+ }
2012
+
1712
2013
  // packages/agent-runtime/toolCallPairing.ts
1713
2014
  function readToolCallId(message) {
1714
2015
  if (typeof message.tool_call_id === "string" && message.tool_call_id) {
@@ -2721,6 +3022,22 @@ async function runLocalAgentTurn(input) {
2721
3022
  ...typeof input.runtimeContext?.blockDestructiveWithoutConfirmation === "boolean" ? { blockDestructiveWithoutConfirmation: input.runtimeContext.blockDestructiveWithoutConfirmation } : {}
2722
3023
  });
2723
3024
  const tools = createLocalCapabilitySdk(input.adapter, execShellContext);
3025
+ if (input.__testPtcProgram) {
3026
+ const { sdk: ptcSdk, context: ptcContext } = createPtcCapabilitySdk({
3027
+ turnContext: {
3028
+ ...execShellContext,
3029
+ agentRunService: createHostToolAgentRunService(input.adapter.executeTool)
3030
+ }
3031
+ });
3032
+ const ptcResult = await executePtcQuickJsPrototype({
3033
+ code: input.__testPtcProgram.code,
3034
+ tools: ptcSdk,
3035
+ abortSignal: ptcContext.abortSignal,
3036
+ timeoutMs: input.__testPtcProgram.timeoutMs,
3037
+ memoryLimitBytes: input.__testPtcProgram.memoryLimitBytes
3038
+ });
3039
+ input.__testPtcProgram.onResult?.(ptcResult);
3040
+ }
2724
3041
  if (input.__testProgram) {
2725
3042
  await input.__testProgram(tools);
2726
3043
  }
@@ -0,0 +1,78 @@
1
+ import {
2
+ Lifetime,
3
+ QuickJSContext,
4
+ QuickJSNotImplemented,
5
+ QuickJSRuntime,
6
+ QuickJSWASMModule,
7
+ Scope,
8
+ applyBaseRuntimeOptions,
9
+ applyModuleEvalRuntimeOptions,
10
+ evalOptionsToFlags,
11
+ intrinsicsToFlags
12
+ } from "./chunk-UOLENXLQ.js";
13
+
14
+ // node_modules/quickjs-emscripten-core/dist/chunk-TAV5CUKK.mjs
15
+ var QuickJSAsyncContext = class extends QuickJSContext {
16
+ async evalCodeAsync(code, filename = "eval.js", options) {
17
+ let detectModule = options === void 0 ? 1 : 0, flags = evalOptionsToFlags(options), resultPtr = 0;
18
+ try {
19
+ resultPtr = await this.memory.newHeapCharPointer(code).consume((charHandle) => this.ffi.QTS_Eval_MaybeAsync(this.ctx.value, charHandle.value.ptr, charHandle.value.strlen, filename, detectModule, flags));
20
+ } catch (error) {
21
+ throw this.runtime.debugLog("QTS_Eval_MaybeAsync threw", error), error;
22
+ }
23
+ let errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr);
24
+ return errorPtr ? (this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr), this.fail(this.memory.heapValueHandle(errorPtr))) : this.success(this.memory.heapValueHandle(resultPtr));
25
+ }
26
+ newAsyncifiedFunction(name, fn) {
27
+ return this.newFunction(name, fn);
28
+ }
29
+ };
30
+ var QuickJSAsyncRuntime = class extends QuickJSRuntime {
31
+ constructor(args) {
32
+ super(args);
33
+ }
34
+ newContext(options = {}) {
35
+ let intrinsics = intrinsicsToFlags(options.intrinsics), ctx = new Lifetime(this.ffi.QTS_NewContext(this.rt.value, intrinsics), void 0, (ctx_ptr) => {
36
+ this.contextMap.delete(ctx_ptr), this.callbacks.deleteContext(ctx_ptr), this.ffi.QTS_FreeContext(ctx_ptr);
37
+ }), context = new QuickJSAsyncContext({ module: this.module, ctx, ffi: this.ffi, rt: this.rt, ownedLifetimes: [], runtime: this, callbacks: this.callbacks });
38
+ return this.contextMap.set(ctx.value, context), context;
39
+ }
40
+ setModuleLoader(moduleLoader, moduleNormalizer) {
41
+ super.setModuleLoader(moduleLoader, moduleNormalizer);
42
+ }
43
+ setMaxStackSize(stackSize) {
44
+ return super.setMaxStackSize(stackSize);
45
+ }
46
+ };
47
+ var QuickJSAsyncWASMModule = class extends QuickJSWASMModule {
48
+ constructor(module, ffi) {
49
+ super(module, ffi);
50
+ this.ffi = ffi, this.module = module;
51
+ }
52
+ newRuntime(options = {}) {
53
+ let rt = new Lifetime(this.ffi.QTS_NewRuntime(), void 0, (rt_ptr) => {
54
+ this.callbacks.deleteRuntime(rt_ptr), this.ffi.QTS_FreeRuntime(rt_ptr);
55
+ }), runtime = new QuickJSAsyncRuntime({ module: this.module, ffi: this.ffi, rt, callbacks: this.callbacks });
56
+ return applyBaseRuntimeOptions(runtime, options), options.moduleLoader && runtime.setModuleLoader(options.moduleLoader), runtime;
57
+ }
58
+ newContext(options = {}) {
59
+ let runtime = this.newRuntime(), lifetimes = options.ownedLifetimes ? options.ownedLifetimes.concat([runtime]) : [runtime], context = runtime.newContext({ ...options, ownedLifetimes: lifetimes });
60
+ return runtime.context = context, context;
61
+ }
62
+ evalCode() {
63
+ throw new QuickJSNotImplemented("QuickJSWASMModuleAsyncify.evalCode: use evalCodeAsync instead");
64
+ }
65
+ evalCodeAsync(code, options) {
66
+ return Scope.withScopeAsync(async (scope) => {
67
+ let vm = scope.manage(this.newContext());
68
+ applyModuleEvalRuntimeOptions(vm.runtime, options);
69
+ let result = await vm.evalCodeAsync(code, "eval.js");
70
+ if (options.memoryLimitBytes !== void 0 && vm.runtime.setMemoryLimit(-1), result.error) throw vm.dump(scope.manage(result.error));
71
+ return vm.dump(scope.manage(result.value));
72
+ });
73
+ }
74
+ };
75
+
76
+ export {
77
+ QuickJSAsyncWASMModule
78
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireTokenUser
3
- } from "./chunk-V4MT7AEN.js";
3
+ } from "./chunk-3CVNNFKF.js";
4
4
  import {
5
5
  resolveServerUrl
6
6
  } from "./chunk-A7GB5UGH.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-2UDMTJOM.js";
3
+ } from "./chunk-PFJA4C7K.js";
4
4
  import {
5
5
  prepareAndPersistMessage,
6
6
  uiAskChoiceFunc,
7
7
  uiAskChoiceFunctionSchema
8
- } from "./chunk-JL2PUYVS.js";
8
+ } from "./chunk-YBWR3WBJ.js";
9
9
  import {
10
10
  require_date_fns
11
11
  } from "./chunk-M76ECQRD.js";