@nervekit/desktop 0.40.1 → 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 (109) hide show
  1. package/THIRD-PARTY-LICENSES.txt +7 -29
  2. package/dist/{chunk-KSZJ3HGD.js → chunk-2BKMOJYJ.js} +1 -1
  3. package/dist/{chunk-4MMJDHFX.js → chunk-3JJN36GV.js} +70 -71
  4. package/dist/{chunk-2Z5FLMLE.js → chunk-3SSNDIQT.js} +1 -1
  5. package/dist/{chunk-CKVFGRVV.js → chunk-3VZR3ZUY.js} +54 -7
  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-AJGPULMX.js → chunk-6FSDDGFZ.js} +815 -3108
  10. package/dist/chunk-6PACEIUY.js +183 -0
  11. package/dist/{chunk-XNYZEQ3U.js → chunk-6TAN6WG6.js} +1 -1
  12. package/dist/{chunk-55OGZFNA.js → chunk-7FLZA2BD.js} +31 -15
  13. package/dist/{chunk-XBHEYY65.js → chunk-7JQBECUL.js} +1 -1
  14. package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
  15. package/dist/{chunk-H5UKINTD.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-QWTKCUIZ.js → chunk-E4JNHQGT.js} +11 -9
  21. package/dist/chunk-ER2ES2RH.js +64 -0
  22. package/dist/{chunk-SQ7CWNIT.js → chunk-EX63VKXY.js} +1 -1
  23. package/dist/{chunk-KQPEOUCA.js → chunk-F3MHINI6.js} +19 -23
  24. package/dist/{chunk-KAZFF2RD.js → chunk-FGZX4Q7W.js} +137 -113
  25. package/dist/{chunk-I6NVW4NX.js → chunk-FZ5N6WXF.js} +29 -33
  26. package/dist/chunk-H2G55ZPG.js +783 -0
  27. package/dist/chunk-HDBDYGJQ.js +40 -0
  28. package/dist/{chunk-TJR6ASRW.js → chunk-HOCODVKL.js} +22 -24
  29. package/dist/chunk-K2J2VZXO.js +142 -0
  30. package/dist/{chunk-MH3SUHI2.js → chunk-KBNEZR7T.js} +2 -2
  31. package/dist/chunk-KSSM6LUI.js +340 -0
  32. package/dist/{chunk-QFXKQNMT.js → chunk-KTGSBL6T.js} +14 -17
  33. package/dist/chunk-L2DHKP5C.js +42 -0
  34. package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
  35. package/dist/{chunk-KIGB3FK6.js → chunk-MWIKZIAI.js} +9 -8
  36. package/dist/{chunk-AON37AL2.js → chunk-O2652RWY.js} +29 -4
  37. package/dist/chunk-O6U226AI.js +249 -0
  38. package/dist/{chunk-N5B2RRSS.js → chunk-OAEV22IW.js} +47 -26
  39. package/dist/chunk-OANTMDXI.js +29 -0
  40. package/dist/{chunk-UGDIHDAR.js → chunk-ODS5QROC.js} +1 -1
  41. package/dist/{chunk-TW6FURZ7.js → chunk-PST63OUS.js} +5 -5
  42. package/dist/{chunk-S2PITDVA.js → chunk-QBAIDKF6.js} +1 -1
  43. package/dist/chunk-RPLBWENJ.js +224 -0
  44. package/dist/{chunk-CWHAK2HX.js → chunk-S62LLS4I.js} +33 -55
  45. package/dist/chunk-SHEU5KLD.js +32 -0
  46. package/dist/{chunk-FESN7DND.js → chunk-SU2USXTD.js} +1 -1
  47. package/dist/chunk-T6NRMNLQ.js +22 -0
  48. package/dist/{chunk-WXRYBXYR.js → chunk-TGKIV3F4.js} +53 -65
  49. package/dist/{chunk-MN7PZ2PH.js → chunk-TSV3PFU2.js} +2 -2
  50. package/dist/{chunk-24GQ74HM.js → chunk-UDC7NPQJ.js} +3 -3
  51. package/dist/{chunk-CEX2GWGZ.js → chunk-VBM7TD3X.js} +1 -1
  52. package/dist/chunk-VC6TX2Y2.js +359 -0
  53. package/dist/{chunk-V53CETNZ.js → chunk-VTDI5KP7.js} +241 -104
  54. package/dist/{chunk-ONWQH2W6.js → chunk-WIN7KHMV.js} +15 -18
  55. package/dist/chunk-WJULIJOU.js +168 -0
  56. package/dist/{chunk-HKLAYK2Z.js → chunk-WRTA5G57.js} +23 -0
  57. package/dist/{chunk-FOFVPPPV.js → chunk-WYPVD3HW.js} +10 -9
  58. package/dist/{chunk-D7WIIZAV.js → chunk-XE2E2KBP.js} +10 -9
  59. package/dist/chunk-XY53EFK3.js +39 -0
  60. package/dist/chunk-XZYFB566.js +153 -0
  61. package/dist/{chunk-OY6PIAR7.js → chunk-YJT4NXMV.js} +5 -5
  62. package/dist/{chunk-3DGBM7UW.js → chunk-YQFENES6.js} +3 -3
  63. package/dist/chunk-YUO5V75X.js +128 -0
  64. package/dist/daemon.js +15 -10
  65. package/dist/git-isolated-reader-helper.js +1 -1
  66. package/dist/main.js +14 -9
  67. package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-BvXKoCVr.js} +1 -1
  68. package/dist/web/assets/{ConversationsWorkbenchPanel-B6dzWkG1.js → ConversationsWorkbenchPanel-CIfK_e3I.js} +1 -1
  69. package/dist/web/assets/{DiscoverCenterHost-B186WBRA.js → DiscoverCenterHost-Ep8EN9iJ.js} +1 -1
  70. package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-C_7XZAFZ.js} +1 -1
  71. package/dist/web/assets/{FilesWorkbenchPanel-VPvx3Bmi.js → FilesWorkbenchPanel-CtXo7ywG.js} +1 -1
  72. package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-Cr7lqGI_.js} +1 -1
  73. package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-BFbwUgIN.js} +1 -1
  74. package/dist/web/assets/{LaunchConfigurationNotice-5yb4cH27.js → LaunchConfigurationNotice-CJjWkMhv.js} +1 -1
  75. package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-BqzJvsrj.js} +1 -1
  76. package/dist/web/assets/{LogsCenterHost-BXBozCYw.js → LogsCenterHost-BI1fSxFW.js} +1 -1
  77. package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-DVsZB8nB.js} +1 -1
  78. package/dist/web/assets/{MobileFilesBody-Cda_7gDp.js → MobileFilesBody-BJMoaP9I.js} +1 -1
  79. package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-D843vkDF.js} +1 -1
  80. package/dist/web/assets/{MobileLaunchOutputHost-Bsv12o2H.js → MobileLaunchOutputHost-vpltMcar.js} +1 -1
  81. package/dist/web/assets/{MobileLaunchesHost-C9VH-2bn.js → MobileLaunchesHost-CdDrKASg.js} +1 -1
  82. package/dist/web/assets/{MobileLogsHost-BMDXc-WC.js → MobileLogsHost-qK7N-C1y.js} +1 -1
  83. package/dist/web/assets/{MobileNoteEditorHost-BA6WIY1Y.js → MobileNoteEditorHost-Bg1N8o54.js} +1 -1
  84. package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-meLV39Yw.js} +1 -1
  85. package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-A49Fdn54.js} +1 -1
  86. package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-BXpUqS_N.js} +1 -1
  87. package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DPKPajzI.js} +1 -1
  88. package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-izNWGN0i.js} +1 -1
  89. package/dist/web/assets/{MobileSettingsPageScreen-C5rHdrUU.js → MobileSettingsPageScreen-DWMg4fDo.js} +1 -1
  90. package/dist/web/assets/{ProjectSettingsCenterHost-BVXpBixy.js → ProjectSettingsCenterHost-DHeb274m.js} +1 -1
  91. package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-BYkWxXQe.js} +1 -1
  92. package/dist/web/assets/{PullRequestsWorkbenchPanel-BBnZJVnI.js → PullRequestsWorkbenchPanel-ZvGbi1Cr.js} +1 -1
  93. package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-DaC0smfe.js} +1 -1
  94. package/dist/web/assets/{SettingsCenter-7BfrBfiy.js → SettingsCenter-C_NLBsi6.js} +1 -1
  95. package/dist/web/assets/{SettingsCenterHost-Ck5uHILP.js → SettingsCenterHost-jP8MULEj.js} +1 -1
  96. package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-B1hfsfAn.js} +1 -1
  97. package/dist/web/assets/{discover-B3I5g1_G.js → discover-B-aZ504j.js} +1 -1
  98. package/dist/web/assets/{index-FJEmK_L5.js → index-TZ1KAAsX.js} +34 -34
  99. package/dist/web/assets/{settings-page-controllers.svelte-CU0i08wo.js → settings-page-controllers.svelte-D_ydJF8u.js} +1 -1
  100. package/dist/web/assets/{shell-layout.svelte-BT2508sa.js → shell-layout.svelte-OoLFwzzJ.js} +2 -2
  101. package/dist/web/assets/{views-Z-n-GTYY.js → views-ByPCKDiZ.js} +1 -1
  102. package/dist/web/index.html +3 -3
  103. package/dist/web/sw.js +1 -1
  104. package/dist/worker.js +14 -9
  105. package/package.json +8 -9
  106. package/dist/chunk-RUZ2UAYH.js +0 -365
  107. package/dist/resize-worker.js +0 -168
  108. /package/dist/{chunk-CKVFGRVV.js.LEGAL.txt → chunk-3VZR3ZUY.js.LEGAL.txt} +0 -0
  109. /package/dist/{chunk-TW6FURZ7.js.LEGAL.txt → chunk-PST63OUS.js.LEGAL.txt} +0 -0
@@ -0,0 +1,183 @@
1
+ import { createRequire as __nerveCreateRequire } from "node:module";
2
+ const require = __nerveCreateRequire(import.meta.url);
3
+ import {
4
+ pollOAuthDeviceCodeFlow
5
+ } from "./chunk-ER2ES2RH.js";
6
+ import "./chunk-CWESUMYQ.js";
7
+
8
+ // 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/auth/oauth/xai.js
9
+ var XAI_CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
10
+ var XAI_SCOPE = "openid profile email offline_access grok-cli:access api:access";
11
+ var XAI_DEVICE_CODE_URL = "https://auth.x.ai/oauth2/device/code";
12
+ var XAI_TOKEN_URL = "https://auth.x.ai/oauth2/token";
13
+ var REFRESH_SKEW_MS = 5 * 60 * 1e3;
14
+ var DEFAULT_TOKEN_LIFETIME_SECONDS = 3600;
15
+ function requiredString(body, field) {
16
+ const value = body[field];
17
+ if (typeof value !== "string" || value.length === 0) {
18
+ throw new Error(`Invalid xAI OAuth response field: ${field}`);
19
+ }
20
+ return value;
21
+ }
22
+ function positiveNumber(body, field) {
23
+ const value = body[field];
24
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
25
+ throw new Error(`Invalid xAI OAuth response field: ${field}`);
26
+ }
27
+ return value;
28
+ }
29
+ function validateVerificationUri(raw) {
30
+ let url;
31
+ try {
32
+ url = new URL(raw);
33
+ } catch {
34
+ throw new Error("Untrusted verification URI in xAI OAuth response");
35
+ }
36
+ if (url.protocol !== "https:") {
37
+ throw new Error("Untrusted verification URI in xAI OAuth response");
38
+ }
39
+ return url.href;
40
+ }
41
+ async function postForm(url, fields, signal) {
42
+ let response;
43
+ try {
44
+ response = await fetch(url, {
45
+ method: "POST",
46
+ headers: {
47
+ Accept: "application/json",
48
+ "Content-Type": "application/x-www-form-urlencoded"
49
+ },
50
+ body: new URLSearchParams(fields),
51
+ signal
52
+ });
53
+ } catch (error) {
54
+ if (signal.aborted) {
55
+ throw new Error("Login cancelled");
56
+ }
57
+ throw error;
58
+ }
59
+ let body;
60
+ try {
61
+ const parsed = await response.json();
62
+ body = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
63
+ } catch {
64
+ if (signal.aborted) {
65
+ throw new Error("Login cancelled");
66
+ }
67
+ throw new Error(`xAI OAuth returned invalid JSON (HTTP ${response.status})`);
68
+ }
69
+ return {
70
+ ok: response.ok,
71
+ status: response.status,
72
+ body
73
+ };
74
+ }
75
+ function requestFailure(action, response) {
76
+ const error = typeof response.body.error === "string" ? response.body.error : void 0;
77
+ const description = typeof response.body.error_description === "string" ? response.body.error_description : void 0;
78
+ const detail = [error, description].filter(Boolean).join(": ");
79
+ return new Error(`xAI OAuth ${action} failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`);
80
+ }
81
+ function parseDeviceCode(body) {
82
+ const interval = body.interval;
83
+ const intervalSeconds = typeof interval === "number" && Number.isFinite(interval) && interval > 0 ? interval : void 0;
84
+ const verificationUriComplete = typeof body.verification_uri_complete === "string" && body.verification_uri_complete.length > 0 ? validateVerificationUri(body.verification_uri_complete) : void 0;
85
+ return {
86
+ deviceCode: requiredString(body, "device_code"),
87
+ userCode: requiredString(body, "user_code"),
88
+ verificationUri: validateVerificationUri(requiredString(body, "verification_uri")),
89
+ verificationUriComplete,
90
+ intervalSeconds,
91
+ expiresInSeconds: positiveNumber(body, "expires_in")
92
+ };
93
+ }
94
+ function credentialsFromTokenResponse(body, previousRefreshToken) {
95
+ const access = requiredString(body, "access_token");
96
+ const refresh = body.refresh_token === void 0 && previousRefreshToken ? previousRefreshToken : requiredString(body, "refresh_token");
97
+ const expiresInSeconds = body.expires_in === void 0 ? DEFAULT_TOKEN_LIFETIME_SECONDS : positiveNumber(body, "expires_in");
98
+ return {
99
+ type: "oauth",
100
+ access,
101
+ refresh,
102
+ expires: Date.now() + expiresInSeconds * 1e3 - REFRESH_SKEW_MS
103
+ };
104
+ }
105
+ async function requestDeviceCode(signal) {
106
+ const response = await postForm(XAI_DEVICE_CODE_URL, {
107
+ client_id: XAI_CLIENT_ID,
108
+ scope: XAI_SCOPE,
109
+ referrer: "pi"
110
+ }, signal);
111
+ if (!response.ok) {
112
+ throw requestFailure("device authorization", response);
113
+ }
114
+ return parseDeviceCode(response.body);
115
+ }
116
+ async function pollForTokens(device, signal) {
117
+ return pollOAuthDeviceCodeFlow({
118
+ intervalSeconds: device.intervalSeconds,
119
+ expiresInSeconds: device.expiresInSeconds,
120
+ waitBeforeFirstPoll: true,
121
+ signal,
122
+ poll: async () => {
123
+ const response = await postForm(XAI_TOKEN_URL, {
124
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
125
+ client_id: XAI_CLIENT_ID,
126
+ device_code: device.deviceCode
127
+ }, signal);
128
+ if (response.ok) {
129
+ return { status: "complete", value: credentialsFromTokenResponse(response.body) };
130
+ }
131
+ const error = response.body.error;
132
+ if (error === "authorization_pending") {
133
+ return { status: "pending" };
134
+ }
135
+ if (error === "slow_down") {
136
+ const interval = response.body.interval;
137
+ return { status: "slow_down", intervalSeconds: typeof interval === "number" ? interval : void 0 };
138
+ }
139
+ if (error === "access_denied" || error === "authorization_denied") {
140
+ return { status: "failed", message: "xAI device authorization was denied" };
141
+ }
142
+ if (error === "expired_token") {
143
+ return { status: "failed", message: "xAI device code expired" };
144
+ }
145
+ return { status: "failed", message: requestFailure("device token polling", response).message };
146
+ }
147
+ });
148
+ }
149
+ async function loginXai(interaction) {
150
+ const device = await requestDeviceCode(interaction.signal);
151
+ interaction.notify({
152
+ type: "device_code",
153
+ userCode: device.userCode,
154
+ verificationUri: device.verificationUriComplete ?? device.verificationUri,
155
+ intervalSeconds: device.intervalSeconds,
156
+ expiresInSeconds: device.expiresInSeconds
157
+ });
158
+ return pollForTokens(device, interaction.signal);
159
+ }
160
+ async function refreshXaiToken(refreshToken, signal) {
161
+ const response = await postForm(XAI_TOKEN_URL, {
162
+ grant_type: "refresh_token",
163
+ client_id: XAI_CLIENT_ID,
164
+ refresh_token: refreshToken
165
+ }, signal);
166
+ if (!response.ok) {
167
+ throw requestFailure("token refresh", response);
168
+ }
169
+ return credentialsFromTokenResponse(response.body, refreshToken);
170
+ }
171
+ var xaiOAuth = {
172
+ name: "xAI (Grok/X subscription)",
173
+ isSubscription: true,
174
+ loginLabel: "Sign in with SuperGrok or X Premium",
175
+ login: loginXai,
176
+ refresh: (credential, signal) => refreshXaiToken(credential.refresh, signal),
177
+ async toAuth(credential) {
178
+ return { apiKey: credential.access };
179
+ }
180
+ };
181
+ export {
182
+ xaiOAuth
183
+ };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
3
 
4
- // node_modules/.pnpm/@earendil-works+pi-ai@1.4.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_c4dd529f1cf5cdf12d9a6e2070ccac62/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
4
+ // 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/abort-signals.js
5
5
  function combineAbortSignals(signals) {
6
6
  const activeSignals = signals.filter((signal) => signal !== void 0);
7
7
  if (activeSignals.length === 0) {
@@ -1,26 +1,29 @@
1
1
  import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
- import {
4
- parseStreamingJson
5
- } from "./chunk-RUZ2UAYH.js";
6
3
  import {
7
4
  headersToRecord,
8
5
  providerHeadersToRecord
9
- } from "./chunk-CEX2GWGZ.js";
6
+ } from "./chunk-VBM7TD3X.js";
10
7
  import {
11
8
  getProviderEnvValue
12
- } from "./chunk-FESN7DND.js";
9
+ } from "./chunk-SU2USXTD.js";
10
+ import {
11
+ ToolCallArgumentsStream
12
+ } from "./chunk-H2G55ZPG.js";
13
13
  import {
14
14
  AssistantMessageEventStream,
15
15
  appendAssistantMessageDiagnostic,
16
16
  createAssistantMessageDiagnostic
17
- } from "./chunk-MN7PZ2PH.js";
17
+ } from "./chunk-TSV3PFU2.js";
18
18
  import {
19
19
  getIdentityHeaders
20
- } from "./chunk-24GQ74HM.js";
20
+ } from "./chunk-UDC7NPQJ.js";
21
+ import {
22
+ ownedSlice
23
+ } from "./chunk-XY53EFK3.js";
21
24
  import "./chunk-CWESUMYQ.js";
22
25
 
23
- // node_modules/.pnpm/@earendil-works+pi-ai@1.4.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_c4dd529f1cf5cdf12d9a6e2070ccac62/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js
26
+ // 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/api/pi-messages.js
24
27
  var PiMessagesResponseError = class extends Error {
25
28
  code;
26
29
  diagnosticDetails;
@@ -42,7 +45,7 @@ function parsePiMessagesErrorBody(body) {
42
45
  }
43
46
  function truncateDiagnosticString(value) {
44
47
  const maxLength = 8192;
45
- return value.length > maxLength ? `${value.slice(0, maxLength)}\u2026` : value;
48
+ return value.length > maxLength ? `${ownedSlice(value, 0, maxLength)}\u2026` : value;
46
49
  }
47
50
  function formatPiMessagesResponseError(response, body, errorBody) {
48
51
  const message = typeof errorBody?.error?.message === "string" ? errorBody.error.message : void 0;
@@ -97,8 +100,15 @@ function createEventConverter(model) {
97
100
  stopReason: "pending",
98
101
  timestamp: Date.now()
99
102
  };
100
- const toolJson = /* @__PURE__ */ new Map();
103
+ const toolArguments = /* @__PURE__ */ new Map();
101
104
  return (event) => {
105
+ if ("contentIndex" in event) {
106
+ const index = event.contentIndex;
107
+ const limit = event.type.endsWith("_start") ? partial.content.length : partial.content.length - 1;
108
+ if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > limit) {
109
+ throw new Error(`Invalid contentIndex ${JSON.stringify(index)} in pi-messages ${event.type} event`);
110
+ }
111
+ }
102
112
  switch (event.type) {
103
113
  case "done":
104
114
  Object.assign(partial, {
@@ -106,6 +116,9 @@ function createEventConverter(model) {
106
116
  usage: event.usage,
107
117
  responseId: event.responseId
108
118
  });
119
+ if (event.responseModel !== void 0) {
120
+ partial.responseModel = event.responseModel;
121
+ }
109
122
  if (event.providerThinkingLevel !== void 0) {
110
123
  partial.providerThinkingLevel = event.providerThinkingLevel;
111
124
  }
@@ -118,6 +131,9 @@ function createEventConverter(model) {
118
131
  errorMessage: event.errorMessage,
119
132
  responseId: event.responseId
120
133
  });
134
+ if (event.responseModel !== void 0) {
135
+ partial.responseModel = event.responseModel;
136
+ }
121
137
  if (event.providerThinkingLevel !== void 0) {
122
138
  partial.providerThinkingLevel = event.providerThinkingLevel;
123
139
  }
@@ -157,17 +173,17 @@ function createEventConverter(model) {
157
173
  name: event.toolName,
158
174
  arguments: {}
159
175
  };
160
- toolJson.set(event.contentIndex, "");
176
+ toolArguments.set(event.contentIndex, new ToolCallArgumentsStream());
161
177
  break;
162
178
  case "toolcall_delta": {
163
- const json = `${toolJson.get(event.contentIndex) ?? ""}${event.delta}`;
164
- toolJson.set(event.contentIndex, json);
165
- partial.content[event.contentIndex].arguments = parseStreamingJson(json);
179
+ const args = toolArguments.get(event.contentIndex);
180
+ if (args !== void 0)
181
+ partial.content[event.contentIndex].arguments = args.append(event.delta);
166
182
  break;
167
183
  }
168
184
  case "toolcall_end":
169
185
  Object.assign(partial.content[event.contentIndex], event.toolCall);
170
- toolJson.delete(event.contentIndex);
186
+ toolArguments.delete(event.contentIndex);
171
187
  return {
172
188
  type: "toolcall_end",
173
189
  contentIndex: event.contentIndex,
@@ -31,7 +31,7 @@ import {
31
31
  retryRename,
32
32
  storagePaths,
33
33
  validateName
34
- } from "./chunk-AJGPULMX.js";
34
+ } from "./chunk-6FSDDGFZ.js";
35
35
  import {
36
36
  __toESM
37
37
  } from "./chunk-CWESUMYQ.js";
@@ -1,13 +1,5 @@
1
1
  import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
- import {
4
- child_process,
5
- crypto,
6
- fs,
7
- path,
8
- stream,
9
- util
10
- } from "./chunk-RPEWYMBU.js";
11
3
  import {
12
4
  AnthropicError,
13
5
  DEFAULT_MEMORY_SYNC_INTERVAL_MS,
@@ -21,7 +13,15 @@ import {
21
13
  isStatus,
22
14
  loggerFor,
23
15
  promiseWithResolvers
24
- } from "./chunk-DBXMYYPJ.js";
16
+ } from "./chunk-M3ELKCNA.js";
17
+ import {
18
+ child_process,
19
+ crypto,
20
+ fs,
21
+ path,
22
+ stream,
23
+ util
24
+ } from "./chunk-RPEWYMBU.js";
25
25
  import "./chunk-CWESUMYQ.js";
26
26
 
27
27
  // node_modules/.pnpm/@anthropic-ai+sdk@0.129.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs
@@ -2,31 +2,33 @@ import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
3
  import {
4
4
  shortHash
5
- } from "./chunk-KSZJ3HGD.js";
6
- import {
7
- parseStreamingJson,
8
- parseToolCallArguments
9
- } from "./chunk-RUZ2UAYH.js";
5
+ } from "./chunk-2BKMOJYJ.js";
10
6
  import {
11
7
  appendGrammarToolInputJsonDelta,
8
+ closeGrammarToolInputJson,
12
9
  getGrammarToolInput,
13
10
  getJsonSchemaToolParameters,
14
11
  resolveGrammarConstrainedSampling,
15
12
  resolveJsonSchemaStrictSampling,
16
13
  transformMessages
17
- } from "./chunk-N5B2RRSS.js";
14
+ } from "./chunk-OAEV22IW.js";
18
15
  import {
19
16
  sanitizeSurrogates
20
- } from "./chunk-2Z5FLMLE.js";
17
+ } from "./chunk-3SSNDIQT.js";
18
+ import {
19
+ ToolCallArgumentsStream
20
+ } from "./chunk-H2G55ZPG.js";
21
21
  import {
22
22
  calculateCost,
23
- getSystemMessageText,
24
- renderSystemMessageUpdate,
25
23
  resolveTranscript,
26
24
  resolveTranscriptTools
27
- } from "./chunk-WXRYBXYR.js";
25
+ } from "./chunk-TGKIV3F4.js";
26
+ import {
27
+ getSystemMessageText,
28
+ renderSystemMessageUpdate
29
+ } from "./chunk-XY53EFK3.js";
28
30
 
29
- // node_modules/.pnpm/@earendil-works+pi-ai@1.4.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_c4dd529f1cf5cdf12d9a6e2070ccac62/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
31
+ // 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/api/openai-responses-shared.js
30
32
  function encodeTextSignatureV1(id, phase) {
31
33
  const payload = { v: 1, id };
32
34
  if (phase)
@@ -338,24 +340,10 @@ function convertResponsesTools(tools, options) {
338
340
  return functionTool;
339
341
  });
340
342
  }
341
- function getCustomToolCallInput(block) {
342
- const property = block.customInput?.property;
343
- if (property === void 0)
344
- return "";
345
- const value = block.arguments[property];
346
- return typeof value === "string" ? value : "";
347
- }
348
- function appendCustomToolCallInput(block, nextInput, close) {
349
- const customInput = block.customInput;
350
- if (!customInput)
351
- return void 0;
352
- const delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);
353
- block.arguments = { [customInput.property]: nextInput };
354
- return delta;
355
- }
356
343
  async function processResponsesStream(openaiStream, output, stream, model, options) {
357
344
  let sawTerminalResponseEvent = false;
358
345
  const outputSlots = /* @__PURE__ */ new Map();
346
+ const unfinishedToolCalls = /* @__PURE__ */ new Set();
359
347
  const reasoningBlocksById = /* @__PURE__ */ new Map();
360
348
  const applyMessagePhaseStopReason = (item) => {
361
349
  if (item.type === "message" && item.phase === "final_answer") {
@@ -399,19 +387,21 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
399
387
  return slot;
400
388
  }
401
389
  if (item.type === "function_call") {
390
+ const args = new ToolCallArgumentsStream();
402
391
  const block = {
403
392
  type: "toolCall",
404
393
  id: `${item.call_id}|${item.id}`,
405
394
  name: item.name,
406
- arguments: {},
407
- ...item.namespace !== void 0 ? { namespace: item.namespace } : {},
408
- partialJson: item.arguments || ""
395
+ arguments: item.arguments ? args.append(item.arguments) : {},
396
+ ...item.namespace !== void 0 ? { namespace: item.namespace } : {}
409
397
  };
410
398
  output.content.push(block);
399
+ unfinishedToolCalls.add(block);
411
400
  const slot = {
412
401
  type: "toolCall",
413
402
  block,
414
- contentIndex: output.content.length - 1
403
+ contentIndex: output.content.length - 1,
404
+ input: { kind: "json", arguments: args }
415
405
  };
416
406
  outputSlots.set(outputIndex, slot);
417
407
  stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
@@ -425,17 +415,15 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
425
415
  id: `${item.call_id}|${item.id}`,
426
416
  name: item.name,
427
417
  arguments: { [inputProperty]: input },
428
- ...item.namespace !== void 0 ? { namespace: item.namespace } : {},
429
- customInput: {
430
- property: inputProperty,
431
- jsonBuffer: { input: "", started: false, closed: false }
432
- }
418
+ ...item.namespace !== void 0 ? { namespace: item.namespace } : {}
433
419
  };
434
420
  output.content.push(block);
421
+ unfinishedToolCalls.add(block);
435
422
  const slot = {
436
423
  type: "toolCall",
437
424
  block,
438
- contentIndex: output.content.length - 1
425
+ contentIndex: output.content.length - 1,
426
+ input: customInput(inputProperty, input)
439
427
  };
440
428
  outputSlots.set(outputIndex, slot);
441
429
  stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
@@ -565,33 +553,28 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
565
553
  });
566
554
  } else if (event.type === "response.function_call_arguments.delta") {
567
555
  const slot = getSlot(event.output_index, "toolCall");
568
- if (!slot || slot.block.partialJson === void 0)
556
+ if (slot?.input.kind !== "json")
569
557
  continue;
570
- slot.block.partialJson += event.delta;
571
- slot.block.arguments = parseStreamingJson(slot.block.partialJson);
558
+ slot.block.arguments = slot.input.arguments.append(event.delta);
572
559
  pushToolCallDelta(slot, event.delta);
573
560
  } else if (event.type === "response.function_call_arguments.done") {
574
561
  const slot = getSlot(event.output_index, "toolCall");
575
- if (!slot || slot.block.partialJson === void 0)
562
+ if (slot?.input.kind !== "json")
576
563
  continue;
577
- const previousPartialJson = slot.block.partialJson;
578
- slot.block.partialJson = event.arguments;
579
- slot.block.arguments = parseStreamingJson(slot.block.partialJson);
580
- if (event.arguments.startsWith(previousPartialJson)) {
581
- const delta = event.arguments.slice(previousPartialJson.length);
582
- if (delta.length > 0)
583
- pushToolCallDelta(slot, delta);
584
- }
564
+ const replaced = slot.input.arguments.replace(event.arguments);
565
+ slot.block.arguments = replaced.arguments;
566
+ if (replaced.delta)
567
+ pushToolCallDelta(slot, replaced.delta);
585
568
  } else if (event.type === "response.custom_tool_call_input.delta") {
586
569
  const slot = getSlot(event.output_index, "toolCall");
587
- if (!slot || !slot.block.customInput)
570
+ if (slot?.input.kind !== "custom")
588
571
  continue;
589
- pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, getCustomToolCallInput(slot.block) + event.delta, false));
572
+ pushToolCallDelta(slot, appendCustomInput(slot.block, slot.input, event.delta));
590
573
  } else if (event.type === "response.custom_tool_call_input.done") {
591
574
  const slot = getSlot(event.output_index, "toolCall");
592
- if (!slot || !slot.block.customInput)
575
+ if (slot?.input.kind !== "custom")
593
576
  continue;
594
- pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, event.input, true));
577
+ pushToolCallDelta(slot, closeCustomInput(slot.block, slot.input, event.input));
595
578
  } else if (event.type === "response.output_item.done") {
596
579
  const item = event.item;
597
580
  applyMessagePhaseStopReason(item);
@@ -619,11 +602,13 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
619
602
  partial: output
620
603
  });
621
604
  outputSlots.delete(event.output_index);
622
- } else if (item.type === "function_call" && slot?.type === "toolCall" && slot.block.partialJson !== void 0) {
623
- Object.assign(slot.block, parseToolCallArguments(item.arguments || slot.block.partialJson));
605
+ } else if (item.type === "function_call" && slot?.type === "toolCall" && slot.input.kind === "json") {
606
+ if (item.arguments)
607
+ slot.input.arguments.replace(item.arguments);
608
+ Object.assign(slot.block, slot.input.arguments.finish());
624
609
  if (item.namespace !== void 0)
625
610
  slot.block.namespace = item.namespace;
626
- delete slot.block.partialJson;
611
+ unfinishedToolCalls.delete(slot.block);
627
612
  stream.push({
628
613
  type: "toolcall_end",
629
614
  contentIndex: slot.contentIndex,
@@ -631,11 +616,11 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
631
616
  partial: output
632
617
  });
633
618
  outputSlots.delete(event.output_index);
634
- } else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.block.customInput) {
635
- pushToolCallDelta(slot, appendCustomToolCallInput(slot.block, item.input ?? getCustomToolCallInput(slot.block), true));
619
+ } else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.input.kind === "custom") {
620
+ pushToolCallDelta(slot, closeCustomInput(slot.block, slot.input, item.input));
636
621
  if (item.namespace !== void 0)
637
622
  slot.block.namespace = item.namespace;
638
- delete slot.block.customInput;
623
+ unfinishedToolCalls.delete(slot.block);
639
624
  stream.push({
640
625
  type: "toolcall_end",
641
626
  contentIndex: slot.contentIndex,
@@ -661,16 +646,34 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
661
646
  throw new Error("OpenAI Responses stream ended before a terminal response event");
662
647
  }
663
648
  if (output.stopReason === "toolUse") {
664
- for (const block of output.content) {
665
- if (block.type !== "toolCall")
666
- continue;
667
- const toolCall = block;
668
- if (toolCall.partialJson !== void 0 || toolCall.customInput !== void 0) {
669
- throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${toolCall.name} (${toolCall.id})`);
670
- }
649
+ for (const toolCall of unfinishedToolCalls) {
650
+ throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${toolCall.name} (${toolCall.id})`);
671
651
  }
672
652
  }
673
653
  }
654
+ function customInput(property, initialInput) {
655
+ const buffer = { input: "", started: false, closed: false };
656
+ return {
657
+ kind: "custom",
658
+ property,
659
+ buffer,
660
+ unsent: appendGrammarToolInputJsonDelta(buffer, property, initialInput) ?? ""
661
+ };
662
+ }
663
+ function appendCustomInput(block, input, delta) {
664
+ return sendCustomInput(block, input, appendGrammarToolInputJsonDelta(input.buffer, input.property, delta));
665
+ }
666
+ function closeCustomInput(block, input, finalInput) {
667
+ return sendCustomInput(block, input, closeGrammarToolInputJson(input.buffer, input.property, finalInput));
668
+ }
669
+ function sendCustomInput(block, input, jsonDelta) {
670
+ block.arguments = { [input.property]: input.buffer.input };
671
+ if (input.unsent === "")
672
+ return jsonDelta;
673
+ const sent = input.unsent + (jsonDelta ?? "");
674
+ input.unsent = "";
675
+ return sent;
676
+ }
674
677
  function mapStopReason(status, incompleteReason) {
675
678
  if (!status)
676
679
  return { stopReason: "stop" };
@@ -0,0 +1,14 @@
1
+ import { createRequire as __nerveCreateRequire } from "node:module";
2
+ const require = __nerveCreateRequire(import.meta.url);
3
+
4
+ // 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/auth/oauth/trusted-url.js
5
+ function trustedHttpUrl(value) {
6
+ if (typeof value !== "string" || !URL.canParse(value))
7
+ return null;
8
+ const url = new URL(value);
9
+ return url.protocol === "https:" || url.protocol === "http:" ? url.href : null;
10
+ }
11
+
12
+ export {
13
+ trustedHttpUrl
14
+ };
@@ -0,0 +1,69 @@
1
+ import { createRequire as __nerveCreateRequire } from "node:module";
2
+ const require = __nerveCreateRequire(import.meta.url);
3
+ import {
4
+ ownedSlice
5
+ } from "./chunk-XY53EFK3.js";
6
+
7
+ // 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/providers/radius-config.js
8
+ var DEFAULT_RADIUS_GATEWAY = "https://radius.pi.dev";
9
+ function isRadiusGatewayModel(value) {
10
+ if (typeof value !== "object" || value === null || Array.isArray(value))
11
+ return false;
12
+ const model = value;
13
+ return typeof model.id === "string" && typeof model.name === "string" && typeof model.reasoning === "boolean" && Array.isArray(model.input) && typeof model.cost === "object" && model.cost !== null && !Array.isArray(model.cost) && typeof model.contextWindow === "number" && typeof model.maxTokens === "number";
14
+ }
15
+ function sanitizeRadiusGatewayConfig(config) {
16
+ if (typeof config !== "object" || config === null || Array.isArray(config))
17
+ return void 0;
18
+ const { baseUrl, models } = config;
19
+ if (typeof baseUrl !== "string" || !Array.isArray(models))
20
+ return void 0;
21
+ return {
22
+ baseUrl,
23
+ models: models.filter(isRadiusGatewayModel).map((model) => ({ ...model }))
24
+ };
25
+ }
26
+ function normalizeRadiusGatewayUrl(value) {
27
+ const withScheme = /^https?:\/\//iu.test(value) ? value : `https://${value}`;
28
+ return withScheme.replace(/\/+$/u, "");
29
+ }
30
+ function getRadiusCredentialConfig(credential) {
31
+ return sanitizeRadiusGatewayConfig(credential?.gatewayConfig);
32
+ }
33
+ function getRadiusModelsFromConfig(providerId, config) {
34
+ return config.models.map((model) => ({
35
+ ...model,
36
+ api: "pi-messages",
37
+ provider: providerId,
38
+ baseUrl: config.baseUrl
39
+ }));
40
+ }
41
+ function getRadiusModels(providerId, credential) {
42
+ const config = getRadiusCredentialConfig(credential);
43
+ return config ? getRadiusModelsFromConfig(providerId, config) : [];
44
+ }
45
+ function truncateHttpBody(body) {
46
+ const trimmed = body.trim();
47
+ return trimmed.length > 512 ? `${ownedSlice(trimmed, 0, 512)}\u2026` : trimmed;
48
+ }
49
+ async function loadRadiusGatewayConfig(gateway, apiKey, signal) {
50
+ const headers = { accept: "application/json" };
51
+ if (apiKey)
52
+ headers.authorization = `Bearer ${apiKey}`;
53
+ const response = await fetch(new URL("/v1/config", gateway), { headers, signal });
54
+ if (!response.ok) {
55
+ throw new Error(`Could not load Radius config from ${gateway}: ${response.status}: ${truncateHttpBody(await response.text())}`);
56
+ }
57
+ const config = sanitizeRadiusGatewayConfig(await response.json());
58
+ if (!config)
59
+ throw new Error(`Invalid Radius config from ${gateway}`);
60
+ return config;
61
+ }
62
+
63
+ export {
64
+ DEFAULT_RADIUS_GATEWAY,
65
+ normalizeRadiusGatewayUrl,
66
+ getRadiusModelsFromConfig,
67
+ getRadiusModels,
68
+ loadRadiusGatewayConfig
69
+ };
@@ -2,9 +2,9 @@ import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
3
  import {
4
4
  getProviderEnvValue
5
- } from "./chunk-FESN7DND.js";
5
+ } from "./chunk-SU2USXTD.js";
6
6
 
7
- // node_modules/.pnpm/@earendil-works+pi-ai@1.4.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_c4dd529f1cf5cdf12d9a6e2070ccac62/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js
7
+ // 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/api/azure-openai-config.js
8
8
  var DEFAULT_AZURE_API_VERSION = "v1";
9
9
  function parseDeploymentNameMap(value) {
10
10
  const map = /* @__PURE__ */ new Map();