@nervekit/desktop 0.40.0 → 0.40.2

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 (114) hide show
  1. package/THIRD-PARTY-LICENSES.txt +5087 -485
  2. package/dist/{chunk-KSZJ3HGD.js → chunk-2BKMOJYJ.js} +1 -1
  3. package/dist/{chunk-5UT23MT6.js → chunk-3JJN36GV.js} +70 -71
  4. package/dist/{chunk-2Z5FLMLE.js → chunk-3SSNDIQT.js} +1 -1
  5. package/dist/{chunk-PUM6UCBT.js → chunk-3VZR3ZUY.js} +55 -8
  6. package/dist/{chunk-BXVRC3HF.js → chunk-4H3WR7IT.js} +1 -1
  7. package/dist/{chunk-QVHYARC2.js → chunk-4VPX67B7.js} +3 -1
  8. package/dist/chunk-5NN7JAJ2.js +258 -0
  9. package/dist/{chunk-BPOIFVQO.js → chunk-6FSDDGFZ.js} +731 -605
  10. package/dist/chunk-6PACEIUY.js +183 -0
  11. package/dist/{chunk-XNYZEQ3U.js → chunk-6TAN6WG6.js} +1 -1
  12. package/dist/{chunk-RWLLVZ7I.js → chunk-7FLZA2BD.js} +31 -15
  13. package/dist/{chunk-WTHP3VH6.js → chunk-7JQBECUL.js} +1 -1
  14. package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
  15. package/dist/{chunk-UN3GLM4U.js → chunk-ANI6J75M.js} +68 -65
  16. package/dist/chunk-B4IE2GAM.js +14 -0
  17. package/dist/chunk-BNVMNV4O.js +69 -0
  18. package/dist/{chunk-L3YB2QLN.js → chunk-C6RO4LP3.js} +2 -2
  19. package/dist/chunk-DTGL5P2V.js +250 -0
  20. package/dist/{chunk-U4DBQKHO.js → chunk-E4JNHQGT.js} +11 -9
  21. package/dist/chunk-EJM4HMEL.js +45 -0
  22. package/dist/chunk-ER2ES2RH.js +64 -0
  23. package/dist/{chunk-SQ7CWNIT.js → chunk-EX63VKXY.js} +1 -1
  24. package/dist/{chunk-JDI4D5EM.js → chunk-F3MHINI6.js} +19 -23
  25. package/dist/chunk-FGZX4Q7W.js +22828 -0
  26. package/dist/{chunk-LPCHTKEK.js → chunk-FZ5N6WXF.js} +31 -160
  27. package/dist/chunk-H2G55ZPG.js +783 -0
  28. package/dist/chunk-HDBDYGJQ.js +40 -0
  29. package/dist/{chunk-RU6S57LK.js → chunk-HOCODVKL.js} +22 -24
  30. package/dist/chunk-JCF3ZRP4.js +481 -0
  31. package/dist/chunk-K2J2VZXO.js +142 -0
  32. package/dist/chunk-KBNEZR7T.js +135 -0
  33. package/dist/chunk-KSSM6LUI.js +340 -0
  34. package/dist/{chunk-HHUSIAK3.js → chunk-KTGSBL6T.js} +14 -17
  35. package/dist/chunk-L2DHKP5C.js +42 -0
  36. package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
  37. package/dist/chunk-M7WTH5K5.js +822 -0
  38. package/dist/{chunk-LZRPWVVJ.js → chunk-MWIKZIAI.js} +9 -8
  39. package/dist/{chunk-AON37AL2.js → chunk-O2652RWY.js} +29 -4
  40. package/dist/chunk-O6U226AI.js +249 -0
  41. package/dist/{chunk-5R3UAHXF.js → chunk-OAEV22IW.js} +48 -26
  42. package/dist/chunk-OANTMDXI.js +29 -0
  43. package/dist/{chunk-UGDIHDAR.js → chunk-ODS5QROC.js} +1 -1
  44. package/dist/{chunk-Q7LPOIKN.js → chunk-OQC3F6JA.js} +3 -471
  45. package/dist/{chunk-YA2WJRUO.js → chunk-PST63OUS.js} +5 -5
  46. package/dist/{chunk-S2PITDVA.js → chunk-QBAIDKF6.js} +1 -1
  47. package/dist/chunk-RPLBWENJ.js +224 -0
  48. package/dist/{chunk-GCSWN326.js → chunk-S62LLS4I.js} +33 -55
  49. package/dist/chunk-SHEU5KLD.js +32 -0
  50. package/dist/{chunk-FESN7DND.js → chunk-SU2USXTD.js} +1 -1
  51. package/dist/chunk-T6NRMNLQ.js +22 -0
  52. package/dist/{chunk-NSA42OOT.js → chunk-TGKIV3F4.js} +53 -65
  53. package/dist/{chunk-MN7PZ2PH.js → chunk-TSV3PFU2.js} +2 -2
  54. package/dist/{chunk-D5WJKB4R.js → chunk-UDC7NPQJ.js} +4 -3
  55. package/dist/{chunk-CEX2GWGZ.js → chunk-VBM7TD3X.js} +1 -1
  56. package/dist/chunk-VC6TX2Y2.js +359 -0
  57. package/dist/{chunk-7FI3LC3O.js → chunk-VTDI5KP7.js} +241 -104
  58. package/dist/{chunk-P2GSKP6N.js → chunk-WIN7KHMV.js} +15 -18
  59. package/dist/chunk-WJULIJOU.js +168 -0
  60. package/dist/{chunk-HKLAYK2Z.js → chunk-WRTA5G57.js} +23 -0
  61. package/dist/{chunk-4ZNLXHTH.js → chunk-WYPVD3HW.js} +10 -9
  62. package/dist/{chunk-V7EAFXAX.js → chunk-XE2E2KBP.js} +10 -9
  63. package/dist/chunk-XY53EFK3.js +39 -0
  64. package/dist/chunk-XZYFB566.js +153 -0
  65. package/dist/{chunk-H4CDZRIE.js → chunk-YJT4NXMV.js} +5 -5
  66. package/dist/{chunk-ET5RYBGZ.js → chunk-YQFENES6.js} +3 -3
  67. package/dist/chunk-YUO5V75X.js +128 -0
  68. package/dist/chunk-YYLKI74V.js +8778 -0
  69. package/dist/daemon.js +15 -10
  70. package/dist/git-isolated-reader-helper.js +1 -1
  71. package/dist/main.js +14 -9
  72. package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-BvXKoCVr.js} +1 -1
  73. package/dist/web/assets/{ConversationsWorkbenchPanel-B6dzWkG1.js → ConversationsWorkbenchPanel-CIfK_e3I.js} +1 -1
  74. package/dist/web/assets/{DiscoverCenterHost-B186WBRA.js → DiscoverCenterHost-Ep8EN9iJ.js} +1 -1
  75. package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-C_7XZAFZ.js} +1 -1
  76. package/dist/web/assets/{FilesWorkbenchPanel-VPvx3Bmi.js → FilesWorkbenchPanel-CtXo7ywG.js} +1 -1
  77. package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-Cr7lqGI_.js} +1 -1
  78. package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-BFbwUgIN.js} +1 -1
  79. package/dist/web/assets/{LaunchConfigurationNotice-5yb4cH27.js → LaunchConfigurationNotice-CJjWkMhv.js} +1 -1
  80. package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-BqzJvsrj.js} +1 -1
  81. package/dist/web/assets/{LogsCenterHost-BXBozCYw.js → LogsCenterHost-BI1fSxFW.js} +1 -1
  82. package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-DVsZB8nB.js} +1 -1
  83. package/dist/web/assets/{MobileFilesBody-Cda_7gDp.js → MobileFilesBody-BJMoaP9I.js} +1 -1
  84. package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-D843vkDF.js} +1 -1
  85. package/dist/web/assets/{MobileLaunchOutputHost-Bsv12o2H.js → MobileLaunchOutputHost-vpltMcar.js} +1 -1
  86. package/dist/web/assets/{MobileLaunchesHost-C9VH-2bn.js → MobileLaunchesHost-CdDrKASg.js} +1 -1
  87. package/dist/web/assets/{MobileLogsHost-BMDXc-WC.js → MobileLogsHost-qK7N-C1y.js} +1 -1
  88. package/dist/web/assets/{MobileNoteEditorHost-BA6WIY1Y.js → MobileNoteEditorHost-Bg1N8o54.js} +1 -1
  89. package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-meLV39Yw.js} +1 -1
  90. package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-A49Fdn54.js} +1 -1
  91. package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-BXpUqS_N.js} +1 -1
  92. package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DPKPajzI.js} +1 -1
  93. package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-izNWGN0i.js} +1 -1
  94. package/dist/web/assets/{MobileSettingsPageScreen-C5rHdrUU.js → MobileSettingsPageScreen-DWMg4fDo.js} +1 -1
  95. package/dist/web/assets/{ProjectSettingsCenterHost-BVXpBixy.js → ProjectSettingsCenterHost-DHeb274m.js} +1 -1
  96. package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-BYkWxXQe.js} +1 -1
  97. package/dist/web/assets/{PullRequestsWorkbenchPanel-BBnZJVnI.js → PullRequestsWorkbenchPanel-ZvGbi1Cr.js} +1 -1
  98. package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-DaC0smfe.js} +1 -1
  99. package/dist/web/assets/{SettingsCenter-7BfrBfiy.js → SettingsCenter-C_NLBsi6.js} +1 -1
  100. package/dist/web/assets/{SettingsCenterHost-Ck5uHILP.js → SettingsCenterHost-jP8MULEj.js} +1 -1
  101. package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-B1hfsfAn.js} +1 -1
  102. package/dist/web/assets/{discover-B3I5g1_G.js → discover-B-aZ504j.js} +1 -1
  103. package/dist/web/assets/{index-FJEmK_L5.js → index-TZ1KAAsX.js} +34 -34
  104. package/dist/web/assets/{settings-page-controllers.svelte-CU0i08wo.js → settings-page-controllers.svelte-D_ydJF8u.js} +1 -1
  105. package/dist/web/assets/{shell-layout.svelte-BT2508sa.js → shell-layout.svelte-OoLFwzzJ.js} +2 -2
  106. package/dist/web/assets/{views-Z-n-GTYY.js → views-ByPCKDiZ.js} +1 -1
  107. package/dist/web/index.html +3 -3
  108. package/dist/web/sw.js +1 -1
  109. package/dist/worker.js +14 -9
  110. package/package.json +8 -9
  111. package/dist/chunk-RUZ2UAYH.js +0 -365
  112. package/dist/resize-worker.js +0 -168
  113. /package/dist/{chunk-PUM6UCBT.js.LEGAL.txt → chunk-3VZR3ZUY.js.LEGAL.txt} +0 -0
  114. /package/dist/{chunk-YA2WJRUO.js.LEGAL.txt → chunk-PST63OUS.js.LEGAL.txt} +0 -0
@@ -0,0 +1,783 @@
1
+ import { createRequire as __nerveCreateRequire } from "node:module";
2
+ const require = __nerveCreateRequire(import.meta.url);
3
+ import {
4
+ __commonJS,
5
+ __toESM
6
+ } from "./chunk-CWESUMYQ.js";
7
+
8
+ // node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/options.js
9
+ var require_options = __commonJS({
10
+ "node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/options.js"(exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
14
+ exports.STR = 1;
15
+ exports.NUM = 2;
16
+ exports.ARR = 4;
17
+ exports.OBJ = 8;
18
+ exports.NULL = 16;
19
+ exports.BOOL = 32;
20
+ exports.NAN = 64;
21
+ exports.INFINITY = 128;
22
+ exports._INFINITY = 256;
23
+ exports.INF = exports.INFINITY | exports._INFINITY;
24
+ exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
25
+ exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
26
+ exports.COLLECTION = exports.ARR | exports.OBJ;
27
+ exports.ALL = exports.ATOM | exports.COLLECTION;
28
+ exports.Allow = { STR: exports.STR, NUM: exports.NUM, ARR: exports.ARR, OBJ: exports.OBJ, NULL: exports.NULL, BOOL: exports.BOOL, NAN: exports.NAN, INFINITY: exports.INFINITY, _INFINITY: exports._INFINITY, INF: exports.INF, SPECIAL: exports.SPECIAL, ATOM: exports.ATOM, COLLECTION: exports.COLLECTION, ALL: exports.ALL };
29
+ exports.default = exports.Allow;
30
+ }
31
+ });
32
+
33
+ // node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/index.js
34
+ var require_dist = __commonJS({
35
+ "node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/index.js"(exports) {
36
+ "use strict";
37
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
38
+ if (k2 === void 0) k2 = k;
39
+ var desc = Object.getOwnPropertyDescriptor(m, k);
40
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
41
+ desc = { enumerable: true, get: function() {
42
+ return m[k];
43
+ } };
44
+ }
45
+ Object.defineProperty(o, k2, desc);
46
+ }) : (function(o, m, k, k2) {
47
+ if (k2 === void 0) k2 = k;
48
+ o[k2] = m[k];
49
+ }));
50
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
51
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
55
+ var options_1 = require_options();
56
+ Object.defineProperty(exports, "Allow", { enumerable: true, get: function() {
57
+ return options_1.Allow;
58
+ } });
59
+ __exportStar(require_options(), exports);
60
+ var PartialJSON = class extends Error {
61
+ };
62
+ exports.PartialJSON = PartialJSON;
63
+ var MalformedJSON = class extends Error {
64
+ };
65
+ exports.MalformedJSON = MalformedJSON;
66
+ function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
67
+ if (typeof jsonString !== "string") {
68
+ throw new TypeError(`expecting str, got ${typeof jsonString}`);
69
+ }
70
+ if (!jsonString.trim()) {
71
+ throw new Error(`${jsonString} is empty`);
72
+ }
73
+ return _parseJSON(jsonString.trim(), allowPartial);
74
+ }
75
+ exports.parseJSON = parseJSON;
76
+ var _parseJSON = (jsonString, allow) => {
77
+ const length = jsonString.length;
78
+ let index = 0;
79
+ const markPartialJSON = (msg) => {
80
+ throw new PartialJSON(`${msg} at position ${index}`);
81
+ };
82
+ const throwMalformedError = (msg) => {
83
+ throw new MalformedJSON(`${msg} at position ${index}`);
84
+ };
85
+ const parseAny = () => {
86
+ skipBlank();
87
+ if (index >= length)
88
+ markPartialJSON("Unexpected end of input");
89
+ if (jsonString[index] === '"')
90
+ return parseStr();
91
+ if (jsonString[index] === "{")
92
+ return parseObj();
93
+ if (jsonString[index] === "[")
94
+ return parseArr();
95
+ if (jsonString.substring(index, index + 4) === "null" || options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index))) {
96
+ index += 4;
97
+ return null;
98
+ }
99
+ if (jsonString.substring(index, index + 4) === "true" || options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index))) {
100
+ index += 4;
101
+ return true;
102
+ }
103
+ if (jsonString.substring(index, index + 5) === "false" || options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index))) {
104
+ index += 5;
105
+ return false;
106
+ }
107
+ if (jsonString.substring(index, index + 8) === "Infinity" || options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index))) {
108
+ index += 8;
109
+ return Infinity;
110
+ }
111
+ if (jsonString.substring(index, index + 9) === "-Infinity" || options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index))) {
112
+ index += 9;
113
+ return -Infinity;
114
+ }
115
+ if (jsonString.substring(index, index + 3) === "NaN" || options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index))) {
116
+ index += 3;
117
+ return NaN;
118
+ }
119
+ return parseNum();
120
+ };
121
+ const parseStr = () => {
122
+ const start = index;
123
+ let escape = false;
124
+ index++;
125
+ while (index < length && (jsonString[index] !== '"' || escape && jsonString[index - 1] === "\\")) {
126
+ escape = jsonString[index] === "\\" ? !escape : false;
127
+ index++;
128
+ }
129
+ if (jsonString.charAt(index) == '"') {
130
+ try {
131
+ return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
132
+ } catch (e) {
133
+ throwMalformedError(String(e));
134
+ }
135
+ } else if (options_1.Allow.STR & allow) {
136
+ try {
137
+ return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
138
+ } catch (e) {
139
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
140
+ }
141
+ }
142
+ markPartialJSON("Unterminated string literal");
143
+ };
144
+ const parseObj = () => {
145
+ index++;
146
+ skipBlank();
147
+ const obj = {};
148
+ try {
149
+ while (jsonString[index] !== "}") {
150
+ skipBlank();
151
+ if (index >= length && options_1.Allow.OBJ & allow)
152
+ return obj;
153
+ const key = parseStr();
154
+ skipBlank();
155
+ index++;
156
+ try {
157
+ const value = parseAny();
158
+ obj[key] = value;
159
+ } catch (e) {
160
+ if (options_1.Allow.OBJ & allow)
161
+ return obj;
162
+ else
163
+ throw e;
164
+ }
165
+ skipBlank();
166
+ if (jsonString[index] === ",")
167
+ index++;
168
+ }
169
+ } catch (e) {
170
+ if (options_1.Allow.OBJ & allow)
171
+ return obj;
172
+ else
173
+ markPartialJSON("Expected '}' at end of object");
174
+ }
175
+ index++;
176
+ return obj;
177
+ };
178
+ const parseArr = () => {
179
+ index++;
180
+ const arr = [];
181
+ try {
182
+ while (jsonString[index] !== "]") {
183
+ arr.push(parseAny());
184
+ skipBlank();
185
+ if (jsonString[index] === ",") {
186
+ index++;
187
+ }
188
+ }
189
+ } catch (e) {
190
+ if (options_1.Allow.ARR & allow) {
191
+ return arr;
192
+ }
193
+ markPartialJSON("Expected ']' at end of array");
194
+ }
195
+ index++;
196
+ return arr;
197
+ };
198
+ const parseNum = () => {
199
+ if (index === 0) {
200
+ if (jsonString === "-")
201
+ throwMalformedError("Not sure what '-' is");
202
+ try {
203
+ return JSON.parse(jsonString);
204
+ } catch (e) {
205
+ if (options_1.Allow.NUM & allow)
206
+ try {
207
+ return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
208
+ } catch (e2) {
209
+ }
210
+ throwMalformedError(String(e));
211
+ }
212
+ }
213
+ const start = index;
214
+ if (jsonString[index] === "-")
215
+ index++;
216
+ while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1)
217
+ index++;
218
+ if (index == length && !(options_1.Allow.NUM & allow))
219
+ markPartialJSON("Unterminated number literal");
220
+ try {
221
+ return JSON.parse(jsonString.substring(start, index));
222
+ } catch (e) {
223
+ if (jsonString.substring(start, index) === "-")
224
+ markPartialJSON("Not sure what '-' is");
225
+ try {
226
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
227
+ } catch (e2) {
228
+ throwMalformedError(String(e2));
229
+ }
230
+ }
231
+ };
232
+ const skipBlank = () => {
233
+ while (index < length && " \n\r ".includes(jsonString[index])) {
234
+ index++;
235
+ }
236
+ };
237
+ return parseAny();
238
+ };
239
+ var parse = parseJSON;
240
+ exports.parse = parse;
241
+ }
242
+ });
243
+
244
+ // node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
245
+ var import_partial_json = __toESM(require_dist(), 1);
246
+ var VALID_JSON_ESCAPES = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t"]);
247
+ function isControlCharacter(char) {
248
+ const codePoint = char.codePointAt(0);
249
+ return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
250
+ }
251
+ function escapeControlCharacter(char) {
252
+ switch (char) {
253
+ case "\b":
254
+ return "\\b";
255
+ case "\f":
256
+ return "\\f";
257
+ case "\n":
258
+ return "\\n";
259
+ case "\r":
260
+ return "\\r";
261
+ case " ":
262
+ return "\\t";
263
+ default:
264
+ return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
265
+ }
266
+ }
267
+ function repairJson(json) {
268
+ let repaired = "";
269
+ let inString = false;
270
+ for (let index = 0; index < json.length; index++) {
271
+ const char = json[index];
272
+ if (!inString) {
273
+ repaired += char;
274
+ if (char === '"') {
275
+ inString = true;
276
+ }
277
+ continue;
278
+ }
279
+ if (char === '"') {
280
+ repaired += char;
281
+ inString = false;
282
+ continue;
283
+ }
284
+ if (char === "\\") {
285
+ const nextChar = json[index + 1];
286
+ if (nextChar === void 0) {
287
+ repaired += "\\\\";
288
+ continue;
289
+ }
290
+ if (nextChar === "u") {
291
+ const unicodeDigits = json.slice(index + 2, index + 6);
292
+ if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
293
+ repaired += `\\u${unicodeDigits}`;
294
+ index += 5;
295
+ continue;
296
+ }
297
+ }
298
+ if (VALID_JSON_ESCAPES.has(nextChar)) {
299
+ repaired += `\\${nextChar}`;
300
+ index += 1;
301
+ continue;
302
+ }
303
+ repaired += "\\\\";
304
+ continue;
305
+ }
306
+ repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
307
+ }
308
+ return repaired;
309
+ }
310
+ function parseJsonWithRepair(json) {
311
+ try {
312
+ return JSON.parse(json);
313
+ } catch (error) {
314
+ const repairedJson = repairJson(json);
315
+ if (repairedJson !== json) {
316
+ return JSON.parse(repairedJson);
317
+ }
318
+ throw error;
319
+ }
320
+ }
321
+ function parseToolCallArguments(json) {
322
+ if (!json?.trim())
323
+ return { arguments: {} };
324
+ try {
325
+ const parsed = parseJsonWithRepair(json);
326
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
327
+ throw new Error("Tool arguments must be a JSON object");
328
+ }
329
+ return { arguments: parsed };
330
+ } catch (error) {
331
+ return {
332
+ arguments: {},
333
+ argumentsError: `${error instanceof Error ? error.message : String(error)}
334
+
335
+ Received arguments:
336
+ ${json}`
337
+ };
338
+ }
339
+ }
340
+
341
+ // node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js
342
+ var MAX_REPORTED_DEPTH = 32;
343
+ var ROOT_SLOT = { kind: "root" };
344
+ var CREDIT_PER_APPEND = 256;
345
+ var CREDIT_PER_CHARACTER = 8;
346
+ var MAX_PENDING_SCALAR_LENGTH = 64;
347
+ var NUMBER = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
348
+ var NUMBER_WITHOUT_EXPONENT_DIGITS = /^(-?(?:0|[1-9]\d*)(?:\.\d+)?)[eE][+-]?$/;
349
+ var LITERALS = [
350
+ ["true", true],
351
+ ["false", false],
352
+ ["null", null]
353
+ ];
354
+ var QUOTE = 34;
355
+ var BACKSLASH = 92;
356
+ var StreamingJsonParser = class {
357
+ #root = void 0;
358
+ #done = false;
359
+ #stack = [];
360
+ #string = void 0;
361
+ #scalar = "";
362
+ #scalarSlot = void 0;
363
+ /** Sum of `size + 1` over the open path: what a fresh snapshot copies. */
364
+ #pathCost = 0;
365
+ #credit = 0;
366
+ #dirty = false;
367
+ #snapshot = void 0;
368
+ /** Changes of the piece being read. */
369
+ #changes = [];
370
+ /**
371
+ * Read the next piece of text; returns the changes it made, in order. Costs time linear in `text.length`.
372
+ */
373
+ append(text) {
374
+ this.#credit += CREDIT_PER_APPEND + CREDIT_PER_CHARACTER * text.length;
375
+ this.#changes = [];
376
+ if (this.#string !== void 0)
377
+ this.#string.change = void 0;
378
+ let index = 0;
379
+ while (index < text.length && !this.#done) {
380
+ const open = this.#string;
381
+ if (open !== void 0)
382
+ index = this.#readString(open, text, index);
383
+ else if (this.#scalar !== "")
384
+ index = this.#readScalar(text, index);
385
+ else
386
+ this.#structural(text[index++]);
387
+ }
388
+ return this.#changes;
389
+ }
390
+ /**
391
+ * The value of the text read so far: `undefined` before a value starts, otherwise a plain JSON value that never
392
+ * changes afterwards. Returns the previous snapshot while the text read since did not change the value, or while a
393
+ * fresh copy of the open path is not yet paid for (see the module comment).
394
+ */
395
+ snapshot() {
396
+ if (!this.#dirty)
397
+ return this.#snapshot;
398
+ const pending = this.#pendingScalar();
399
+ const cost = this.#pathCost + (pending === void 0 ? 0 : 1);
400
+ if (cost > this.#credit)
401
+ return this.#snapshot;
402
+ this.#credit -= cost;
403
+ this.#dirty = false;
404
+ this.#snapshot = this.#copyOpenPath(pending);
405
+ return this.#snapshot;
406
+ }
407
+ /** Read string characters from `start` until the string ends or the text does; returns the next index. */
408
+ #readString(open, text, start) {
409
+ let runStart = start;
410
+ for (let index = start; index < text.length; index++) {
411
+ const code = text.charCodeAt(index);
412
+ if (open.escape !== "") {
413
+ if (this.#continueEscape(open, text[index])) {
414
+ runStart = index + 1;
415
+ continue;
416
+ }
417
+ runStart = index;
418
+ }
419
+ if (code === QUOTE) {
420
+ if (index > runStart)
421
+ this.#appendString(open, text.slice(runStart, index));
422
+ this.#endString(open);
423
+ return index + 1;
424
+ }
425
+ if (code === BACKSLASH) {
426
+ if (index > runStart)
427
+ this.#appendString(open, text.slice(runStart, index));
428
+ open.escape = "\\";
429
+ runStart = index + 1;
430
+ }
431
+ }
432
+ if (text.length > runStart)
433
+ this.#appendString(open, text.slice(runStart));
434
+ return text.length;
435
+ }
436
+ /** Read number or literal characters from `start` up to the next delimiter; returns the delimiter's index. */
437
+ #readScalar(text, start) {
438
+ let end = start;
439
+ while (end < text.length && !isDelimiter(text[end]))
440
+ end++;
441
+ if (end > start) {
442
+ this.#scalar += text.slice(start, end);
443
+ if (this.#scalarSlot !== void 0)
444
+ this.#dirty = true;
445
+ }
446
+ if (end < text.length)
447
+ this.#endScalar();
448
+ return end;
449
+ }
450
+ /** Handle one character outside strings. */
451
+ #structural(char) {
452
+ switch (char) {
453
+ case " ":
454
+ case " ":
455
+ case "\n":
456
+ case "\r":
457
+ return;
458
+ case '"':
459
+ this.#startString();
460
+ return;
461
+ case "{":
462
+ case "[":
463
+ this.#openContainer(char === "{" ? {} : []);
464
+ return;
465
+ case "}":
466
+ case "]":
467
+ this.#closeContainer();
468
+ return;
469
+ case ":": {
470
+ const frame = this.#stack.at(-1);
471
+ if (frame !== void 0 && !Array.isArray(frame.container) && frame.phase === "colon")
472
+ frame.phase = "value";
473
+ return;
474
+ }
475
+ case ",": {
476
+ const frame = this.#stack.at(-1);
477
+ if (frame !== void 0)
478
+ frame.phase = Array.isArray(frame.container) ? "value" : "key";
479
+ return;
480
+ }
481
+ default:
482
+ this.#scalar = char;
483
+ this.#scalarSlot = this.#valueSlot();
484
+ if (this.#scalarSlot !== void 0)
485
+ this.#dirty = true;
486
+ }
487
+ }
488
+ /** Where a value starting now goes, or `undefined` when this position takes no value. */
489
+ #valueSlot() {
490
+ const frame = this.#stack.at(-1);
491
+ if (frame === void 0)
492
+ return this.#root === void 0 ? ROOT_SLOT : void 0;
493
+ if (Array.isArray(frame.container))
494
+ return { kind: "element", index: frame.container.length };
495
+ if ((frame.phase === "value" || frame.phase === "colon") && frame.key !== void 0) {
496
+ return { kind: "member", key: frame.key };
497
+ }
498
+ return void 0;
499
+ }
500
+ #startString() {
501
+ const frame = this.#stack.at(-1);
502
+ if (frame !== void 0 && !Array.isArray(frame.container) && (frame.phase === "key" || frame.phase === "comma")) {
503
+ this.#string = { target: "key", slot: void 0, text: "", escape: "", path: void 0, change: void 0 };
504
+ return;
505
+ }
506
+ const slot = this.#valueSlot();
507
+ const path = this.#reportedPath(slot);
508
+ this.#string = { target: "value", slot, text: "", escape: "", path, change: void 0 };
509
+ this.#place(slot, "");
510
+ if (path !== void 0)
511
+ this.#string.change = this.#report({ kind: "set", path, value: "" });
512
+ }
513
+ /** The path of a value at `slot` in the innermost open container, when its changes are reported. */
514
+ #reportedPath(slot) {
515
+ if (slot === void 0)
516
+ return void 0;
517
+ if (slot.kind === "root")
518
+ return [];
519
+ const frame = this.#stack.at(-1);
520
+ if (!frame.reportsInside)
521
+ return void 0;
522
+ return [...frame.path, slot.kind === "member" ? slot.key : slot.index];
523
+ }
524
+ #report(change) {
525
+ this.#changes.push(change);
526
+ return change;
527
+ }
528
+ /** Continue an escape with `char`; returns false when `char` is not part of it and must be read normally. */
529
+ #continueEscape(open, char) {
530
+ if (open.escape === "\\") {
531
+ const decoded = SIMPLE_ESCAPES[char];
532
+ if (decoded !== void 0) {
533
+ open.escape = "";
534
+ this.#appendString(open, decoded);
535
+ return true;
536
+ }
537
+ if (char === "u") {
538
+ open.escape = "\\u";
539
+ return true;
540
+ }
541
+ open.escape = "";
542
+ this.#appendString(open, "\\");
543
+ return false;
544
+ }
545
+ if (isHexDigit(char)) {
546
+ open.escape += char;
547
+ if (open.escape.length < 6)
548
+ return true;
549
+ const decoded = String.fromCharCode(Number.parseInt(open.escape.slice(2), 16));
550
+ open.escape = "";
551
+ this.#appendString(open, decoded);
552
+ return true;
553
+ }
554
+ const literal = open.escape;
555
+ open.escape = "";
556
+ this.#appendString(open, literal);
557
+ return false;
558
+ }
559
+ #appendString(open, text) {
560
+ open.text += text;
561
+ if (open.target !== "value")
562
+ return;
563
+ this.#place(open.slot, open.text);
564
+ if (open.path === void 0)
565
+ return;
566
+ const change = open.change;
567
+ if (change !== void 0 && this.#changes.at(-1) === change) {
568
+ if (change.kind === "set")
569
+ change.value = change.value + text;
570
+ else
571
+ change.text += text;
572
+ return;
573
+ }
574
+ open.change = this.#report({ kind: "append", path: open.path, text });
575
+ }
576
+ #endString(open) {
577
+ this.#string = void 0;
578
+ const frame = this.#stack.at(-1);
579
+ if (open.target === "key") {
580
+ if (frame === void 0)
581
+ return;
582
+ frame.key = open.text;
583
+ frame.phase = "colon";
584
+ return;
585
+ }
586
+ this.#valueEnded(frame);
587
+ }
588
+ #endScalar() {
589
+ const token = this.#scalar;
590
+ const slot = this.#scalarSlot;
591
+ this.#scalar = "";
592
+ this.#scalarSlot = void 0;
593
+ const value = scalarValue(token);
594
+ if (value !== void 0) {
595
+ this.#place(slot, value);
596
+ const path = this.#reportedPath(slot);
597
+ if (path !== void 0)
598
+ this.#report({ kind: "set", path, value });
599
+ }
600
+ this.#valueEnded(this.#stack.at(-1));
601
+ }
602
+ /** The value of the unterminated scalar at the end of the text, if it shows. */
603
+ #pendingScalar() {
604
+ const slot = this.#scalarSlot;
605
+ const token = this.#scalar;
606
+ if (slot === void 0 || token === "" || token.length > MAX_PENDING_SCALAR_LENGTH)
607
+ return void 0;
608
+ const value = pendingScalarValue(token);
609
+ return value === void 0 ? void 0 : { slot, value };
610
+ }
611
+ #openContainer(container) {
612
+ const slot = this.#valueSlot();
613
+ const path = this.#reportedPath(slot);
614
+ this.#place(slot, container);
615
+ this.#stack.push({
616
+ container,
617
+ slot,
618
+ path,
619
+ reportsInside: path !== void 0 && path.length < MAX_REPORTED_DEPTH,
620
+ size: 0,
621
+ key: void 0,
622
+ phase: Array.isArray(container) ? "value" : "key"
623
+ });
624
+ this.#pathCost += 1;
625
+ this.#dirty = true;
626
+ if (path !== void 0)
627
+ this.#report({ kind: "set", path, value: Array.isArray(container) ? [] : {} });
628
+ }
629
+ #closeContainer() {
630
+ const frame = this.#stack.pop();
631
+ if (frame === void 0)
632
+ return;
633
+ this.#pathCost -= frame.size + 1;
634
+ this.#dirty = true;
635
+ if (frame.path !== void 0 && !frame.reportsInside) {
636
+ this.#report({ kind: "set", path: frame.path, value: frame.container });
637
+ }
638
+ this.#valueEnded(this.#stack.at(-1));
639
+ }
640
+ /** A value in `frame`, or the root value when there is no frame, has ended. */
641
+ #valueEnded(frame) {
642
+ if (frame === void 0) {
643
+ if (this.#root !== void 0)
644
+ this.#done = true;
645
+ return;
646
+ }
647
+ frame.phase = "comma";
648
+ }
649
+ /** Set the value at `slot` in the open path; nothing for a value in an invalid position. */
650
+ #place(slot, value) {
651
+ if (slot === void 0)
652
+ return;
653
+ this.#dirty = true;
654
+ if (slot.kind === "root") {
655
+ this.#root = value;
656
+ return;
657
+ }
658
+ const frame = this.#stack.at(-1);
659
+ if (slot.kind === "element") {
660
+ const elements = frame.container;
661
+ if (slot.index === elements.length) {
662
+ frame.size++;
663
+ this.#pathCost++;
664
+ }
665
+ elements[slot.index] = value;
666
+ return;
667
+ }
668
+ const members = frame.container;
669
+ if (!Object.hasOwn(members, slot.key)) {
670
+ frame.size++;
671
+ this.#pathCost++;
672
+ }
673
+ setMember(members, slot.key, value);
674
+ }
675
+ /** A fresh snapshot: copies of the open containers, innermost first, each holding the copy of its open child. */
676
+ #copyOpenPath(pending) {
677
+ if (this.#stack.length === 0)
678
+ return pending?.slot.kind === "root" ? pending.value : this.#root;
679
+ let child;
680
+ let childSlot;
681
+ for (let depth = this.#stack.length - 1; depth >= 0; depth--) {
682
+ const frame = this.#stack[depth];
683
+ const copy = Array.isArray(frame.container) ? frame.container.slice() : { ...frame.container };
684
+ if (depth === this.#stack.length - 1 && pending !== void 0)
685
+ setSlot(copy, pending.slot, pending.value);
686
+ if (child !== void 0 && childSlot !== void 0)
687
+ setSlot(copy, childSlot, child);
688
+ child = copy;
689
+ childSlot = frame.slot;
690
+ }
691
+ return childSlot?.kind === "root" ? child : this.#root;
692
+ }
693
+ };
694
+ var ToolCallArgumentsStream = class {
695
+ #text = "";
696
+ #parser = new StreamingJsonParser();
697
+ #snapshot = void 0;
698
+ #arguments = {};
699
+ /** The raw argument text received so far. */
700
+ get text() {
701
+ return this.#text;
702
+ }
703
+ /** Append a piece of argument text; returns the partial arguments, a new object whenever they changed. */
704
+ append(delta) {
705
+ this.#text += delta;
706
+ this.#parser.append(delta);
707
+ return this.#partial();
708
+ }
709
+ /**
710
+ * Take the provider's complete argument text. When it continues the text so far, returns the missing piece as
711
+ * `delta`; otherwise starts over with `text`. Either way returns the partial arguments of `text`.
712
+ */
713
+ replace(text) {
714
+ if (text.startsWith(this.#text)) {
715
+ const delta = text.slice(this.#text.length);
716
+ return { delta, arguments: delta === "" ? this.#partial() : this.append(delta) };
717
+ }
718
+ this.#text = "";
719
+ this.#parser = new StreamingJsonParser();
720
+ return { delta: void 0, arguments: this.append(text) };
721
+ }
722
+ /** The final arguments: one full parse of the complete text, which reports malformed arguments. */
723
+ finish() {
724
+ return parseToolCallArguments(this.#text);
725
+ }
726
+ #partial() {
727
+ const snapshot = this.#parser.snapshot();
728
+ if (snapshot === this.#snapshot)
729
+ return this.#arguments;
730
+ this.#snapshot = snapshot;
731
+ this.#arguments = typeof snapshot === "object" && snapshot !== null && !Array.isArray(snapshot) ? snapshot : {};
732
+ return this.#arguments;
733
+ }
734
+ };
735
+ var SIMPLE_ESCAPES = {
736
+ '"': '"',
737
+ "\\": "\\",
738
+ "/": "/",
739
+ b: "\b",
740
+ f: "\f",
741
+ n: "\n",
742
+ r: "\r",
743
+ t: " "
744
+ };
745
+ function isDelimiter(char) {
746
+ return char === " " || char === " " || char === "\n" || char === "\r" || char === "," || char === ":" || char === "{" || char === "}" || char === "[" || char === "]" || char === '"';
747
+ }
748
+ function isHexDigit(char) {
749
+ return char >= "0" && char <= "9" || char >= "a" && char <= "f" || char >= "A" && char <= "F";
750
+ }
751
+ function scalarValue(token) {
752
+ for (const [literal, value] of LITERALS)
753
+ if (token === literal)
754
+ return value;
755
+ return NUMBER.test(token) ? Number(token) : void 0;
756
+ }
757
+ function pendingScalarValue(token) {
758
+ for (const [literal, value] of LITERALS)
759
+ if (literal.startsWith(token))
760
+ return value;
761
+ if (NUMBER.test(token))
762
+ return Number(token);
763
+ const mantissa = NUMBER_WITHOUT_EXPONENT_DIGITS.exec(token);
764
+ return mantissa === null ? void 0 : Number(mantissa[1]);
765
+ }
766
+ function setSlot(container, slot, value) {
767
+ if (slot.kind === "element")
768
+ container[slot.index] = value;
769
+ else if (slot.kind === "member")
770
+ setMember(container, slot.key, value);
771
+ }
772
+ function setMember(members, key, value) {
773
+ if (key === "__proto__") {
774
+ Object.defineProperty(members, key, { value, writable: true, enumerable: true, configurable: true });
775
+ } else {
776
+ members[key] = value;
777
+ }
778
+ }
779
+
780
+ export {
781
+ parseJsonWithRepair,
782
+ ToolCallArgumentsStream
783
+ };