@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
@@ -92,51 +92,59 @@ import {
92
92
  } from "./chunk-YYLKI74V.js";
93
93
  import {
94
94
  resolveHttpProxyUrlForTarget
95
- } from "./chunk-MH3SUHI2.js";
95
+ } from "./chunk-KBNEZR7T.js";
96
+ import {
97
+ hasExceededStrictToolLimits,
98
+ isStrictToolLimitErrorMessage,
99
+ markStrictToolLimitsExceeded
100
+ } from "./chunk-L2DHKP5C.js";
96
101
  import {
97
102
  require_src
98
103
  } from "./chunk-OQC3F6JA.js";
99
- import {
100
- parseStreamingJson,
101
- parseToolCallArguments
102
- } from "./chunk-RUZ2UAYH.js";
104
+ import "./chunk-OANTMDXI.js";
103
105
  import {
104
106
  adjustMaxTokensForThinking,
105
107
  buildBaseOptions,
106
108
  clampMaxTokensToContext,
107
109
  clampReasoning,
108
110
  getJsonSchemaToolParameters,
111
+ prefersJsonSchemaStrictSampling,
109
112
  resolveJsonSchemaStrictSampling,
110
113
  splitErrorToolResultImages,
111
114
  transformMessages
112
- } from "./chunk-N5B2RRSS.js";
115
+ } from "./chunk-OAEV22IW.js";
113
116
  import {
114
117
  sanitizeSurrogates
115
- } from "./chunk-2Z5FLMLE.js";
118
+ } from "./chunk-3SSNDIQT.js";
116
119
  import {
117
120
  normalizeProviderError
118
- } from "./chunk-AON37AL2.js";
121
+ } from "./chunk-O2652RWY.js";
119
122
  import {
120
123
  providerHeadersToRecord
121
- } from "./chunk-CEX2GWGZ.js";
124
+ } from "./chunk-VBM7TD3X.js";
122
125
  import {
123
126
  getProviderEnvValue
124
- } from "./chunk-FESN7DND.js";
127
+ } from "./chunk-SU2USXTD.js";
128
+ import {
129
+ ToolCallArgumentsStream
130
+ } from "./chunk-H2G55ZPG.js";
125
131
  import {
126
132
  calculateCost,
127
133
  collapseSystemMessages,
128
134
  getCurrentTools,
129
135
  getInitialSystemMessage,
130
- getSystemMessageText,
131
136
  withoutInitialSystemMessage
132
- } from "./chunk-WXRYBXYR.js";
137
+ } from "./chunk-TGKIV3F4.js";
133
138
  import {
134
139
  AssistantMessageEventStream,
135
140
  appendAssistantMessageDiagnostic
136
- } from "./chunk-MN7PZ2PH.js";
141
+ } from "./chunk-TSV3PFU2.js";
137
142
  import {
138
143
  getClientVersion
139
- } from "./chunk-24GQ74HM.js";
144
+ } from "./chunk-UDC7NPQJ.js";
145
+ import {
146
+ getSystemMessageText
147
+ } from "./chunk-XY53EFK3.js";
140
148
  import {
141
149
  __commonJS,
142
150
  __esm,
@@ -21379,7 +21387,7 @@ var require_dist_cjs21 = __commonJS({
21379
21387
  }
21380
21388
  });
21381
21389
 
21382
- // 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/bedrock-converse-stream.js
21390
+ // 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/bedrock-converse-stream.js
21383
21391
  var import_client_bedrock_runtime = __toESM(require_dist_cjs21(), 1);
21384
21392
  var import_node_http_handler5 = __toESM(require_dist_cjs8(), 1);
21385
21393
 
@@ -21898,7 +21906,7 @@ function omit2(obj, ...keys) {
21898
21906
  return ret;
21899
21907
  }
21900
21908
 
21901
- // 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/bedrock-converse-stream.js
21909
+ // 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/bedrock-converse-stream.js
21902
21910
  var EMPTY_TEXT_PLACEHOLDER = "<empty>";
21903
21911
  var THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
21904
21912
  var REDACTED_THINKING_PLACEHOLDER = "[Reasoning redacted]";
@@ -21923,7 +21931,7 @@ var stream = (model, context, options = {}) => {
21923
21931
  stopReason: "pending",
21924
21932
  timestamp: Date.now()
21925
21933
  };
21926
- const blocks = output.content;
21934
+ const openBlocks = /* @__PURE__ */ new Map();
21927
21935
  const optionsProfile = options.profile || options.env?.AWS_PROFILE;
21928
21936
  const config = {
21929
21937
  profile: optionsProfile || getProviderEnvValue("AWS_PROFILE", options.env),
@@ -21994,24 +22002,43 @@ var stream = (model, context, options = {}) => {
21994
22002
  const inferenceMaxTokens = options.maxTokens ?? (isAnthropicClaudeModel(model) ? model.maxTokens : void 0);
21995
22003
  const initialSystemMessage = getInitialSystemMessage(normalizedContext.messages);
21996
22004
  const initialSystemPrompt = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : void 0;
21997
- let commandInput = {
21998
- modelId: model.id,
21999
- messages: convertMessages(normalizedContext, model, cacheRetention, options.env),
22000
- system: buildSystemPrompt(initialSystemPrompt, model, cacheRetention, options.env),
22001
- inferenceConfig: {
22002
- ...inferenceMaxTokens !== void 0 && { maxTokens: inferenceMaxTokens },
22003
- ...options.temperature !== void 0 && { temperature: options.temperature }
22004
- },
22005
- toolConfig: convertToolConfig(getCurrentTools(normalizedContext.messages), options.toolChoice, supportsStrictMode),
22006
- additionalModelRequestFields: buildAdditionalModelRequestFields(model, options),
22007
- ...options.requestMetadata !== void 0 && { requestMetadata: options.requestMetadata }
22008
- };
22009
- const nextCommandInput = await options?.onPayload?.(commandInput, model);
22010
- if (nextCommandInput !== void 0) {
22011
- commandInput = nextCommandInput;
22005
+ let disablePreferredStrictTools = hasExceededStrictToolLimits(options.sessionId);
22006
+ let response;
22007
+ for (; ; ) {
22008
+ const tools = convertToolConfig(getCurrentTools(normalizedContext.messages), options.toolChoice, supportsStrictMode, disablePreferredStrictTools);
22009
+ let commandInput = {
22010
+ modelId: model.id,
22011
+ messages: convertMessages(normalizedContext, model, cacheRetention, options.env),
22012
+ system: buildSystemPrompt(initialSystemPrompt, model, cacheRetention, options.env),
22013
+ inferenceConfig: {
22014
+ ...inferenceMaxTokens !== void 0 && { maxTokens: inferenceMaxTokens },
22015
+ ...options.temperature !== void 0 && { temperature: options.temperature }
22016
+ },
22017
+ toolConfig: tools.toolConfig,
22018
+ additionalModelRequestFields: buildAdditionalModelRequestFields(model, options),
22019
+ ...options.requestMetadata !== void 0 && { requestMetadata: options.requestMetadata }
22020
+ };
22021
+ const nextCommandInput = await options?.onPayload?.(commandInput, model);
22022
+ if (nextCommandInput !== void 0) {
22023
+ commandInput = nextCommandInput;
22024
+ }
22025
+ try {
22026
+ response = await client.send(new import_client_bedrock_runtime.ConverseStreamCommand(commandInput), { abortSignal: options.signal });
22027
+ break;
22028
+ } catch (error) {
22029
+ if (options.signal?.aborted || disablePreferredStrictTools || !tools.hasPreferredStrictTools || !(error instanceof import_client_bedrock_runtime.BedrockRuntimeServiceException) || error.name !== "ValidationException" || !isStrictToolLimitErrorMessage(error.message)) {
22030
+ throw error;
22031
+ }
22032
+ disablePreferredStrictTools = true;
22033
+ markStrictToolLimitsExceeded(options.sessionId);
22034
+ appendAssistantMessageDiagnostic(output, {
22035
+ type: "bedrock_strict_tools_fallback",
22036
+ timestamp: Date.now(),
22037
+ error: { message: error.message },
22038
+ details: { reason: "strict_tool_limits_exceeded" }
22039
+ });
22040
+ }
22012
22041
  }
22013
- const command5 = new import_client_bedrock_runtime.ConverseStreamCommand(commandInput);
22014
- const response = await client.send(command5, { abortSignal: options.signal });
22015
22042
  responseRequestId = normalizeDiagnosticValue(response.$metadata.requestId);
22016
22043
  if (!observedRawResponse && response.$metadata.httpStatusCode !== void 0) {
22017
22044
  const responseHeaders = {};
@@ -22028,11 +22055,11 @@ var stream = (model, context, options = {}) => {
22028
22055
  }
22029
22056
  stream2.push({ type: "start", partial: output });
22030
22057
  } else if (item.contentBlockStart) {
22031
- handleContentBlockStart(item.contentBlockStart, blocks, output, stream2);
22058
+ handleContentBlockStart(item.contentBlockStart, openBlocks, output, stream2);
22032
22059
  } else if (item.contentBlockDelta) {
22033
- handleContentBlockDelta(item.contentBlockDelta, blocks, output, stream2);
22060
+ handleContentBlockDelta(item.contentBlockDelta, openBlocks, output, stream2);
22034
22061
  } else if (item.contentBlockStop) {
22035
- handleContentBlockStop(item.contentBlockStop, blocks, output, stream2);
22062
+ handleContentBlockStop(item.contentBlockStop, openBlocks, output, stream2);
22036
22063
  } else if (item.messageStop) {
22037
22064
  output.rawStopReason = item.messageStop.stopReason;
22038
22065
  const { stopReason, errorMessage } = mapStopReason(item.messageStop.stopReason);
@@ -22063,14 +22090,11 @@ var stream = (model, context, options = {}) => {
22063
22090
  if (output.stopReason === "error" || output.stopReason === "aborted") {
22064
22091
  throw new Error(output.errorMessage || "An unknown error occurred");
22065
22092
  }
22066
- for (const block of output.content)
22067
- finalizeStreamingBlock(block);
22093
+ flushOpenBlocks(openBlocks, output);
22068
22094
  stream2.push({ type: "done", reason: output.stopReason, message: output });
22069
22095
  stream2.end();
22070
22096
  } catch (error) {
22071
- for (const block of output.content) {
22072
- finalizeStreamingBlock(block);
22073
- }
22097
+ flushOpenBlocks(openBlocks, output);
22074
22098
  output.stopReason = options.signal?.aborted ? "aborted" : "error";
22075
22099
  output.errorMessage = formatBedrockError(error);
22076
22100
  if (output.stopReason === "error") {
@@ -22212,56 +22236,57 @@ var streamSimple = (model, context, options) => {
22212
22236
  thinkingBudgets: options.thinkingBudgets
22213
22237
  });
22214
22238
  };
22215
- function handleContentBlockStart(event, blocks, output, stream2) {
22216
- const index = event.contentBlockIndex;
22239
+ function handleContentBlockStart(event, openBlocks, output, stream2) {
22217
22240
  const start = event.start;
22218
22241
  if (start?.toolUse) {
22219
- const block = {
22242
+ output.content.push({
22220
22243
  type: "toolCall",
22221
22244
  id: start.toolUse.toolUseId || "",
22222
22245
  name: start.toolUse.name || "",
22223
- arguments: {},
22224
- partialJson: "",
22225
- index
22226
- };
22227
- output.content.push(block);
22228
- stream2.push({ type: "toolcall_start", contentIndex: blocks.length - 1, partial: output });
22246
+ arguments: {}
22247
+ });
22248
+ const contentIndex = output.content.length - 1;
22249
+ openBlocks.set(event.contentBlockIndex, { contentIndex, arguments: new ToolCallArgumentsStream() });
22250
+ stream2.push({ type: "toolcall_start", contentIndex, partial: output });
22229
22251
  }
22230
22252
  }
22231
- function handleContentBlockDelta(event, blocks, output, stream2) {
22253
+ function handleContentBlockDelta(event, openBlocks, output, stream2) {
22232
22254
  const contentBlockIndex = event.contentBlockIndex;
22233
22255
  const delta = event.delta;
22234
- let index = blocks.findIndex((b5) => b5.index === contentBlockIndex);
22235
- let block = blocks[index];
22256
+ let open = openBlocks.get(contentBlockIndex);
22257
+ let block = open === void 0 ? void 0 : output.content[open.contentIndex];
22236
22258
  if (delta?.text !== void 0) {
22237
- if (!block) {
22238
- const newBlock = { type: "text", text: "", index: contentBlockIndex };
22239
- output.content.push(newBlock);
22240
- index = blocks.length - 1;
22241
- block = blocks[index];
22242
- stream2.push({ type: "text_start", contentIndex: index, partial: output });
22259
+ if (!open) {
22260
+ output.content.push({ type: "text", text: "" });
22261
+ open = { contentIndex: output.content.length - 1 };
22262
+ openBlocks.set(contentBlockIndex, open);
22263
+ block = output.content[open.contentIndex];
22264
+ stream2.push({ type: "text_start", contentIndex: open.contentIndex, partial: output });
22243
22265
  }
22244
- if (block.type === "text") {
22266
+ if (block?.type === "text") {
22245
22267
  block.text += delta.text;
22246
- stream2.push({ type: "text_delta", contentIndex: index, delta: delta.text, partial: output });
22268
+ stream2.push({ type: "text_delta", contentIndex: open.contentIndex, delta: delta.text, partial: output });
22247
22269
  }
22248
- } else if (delta?.toolUse && block?.type === "toolCall") {
22249
- block.partialJson = (block.partialJson || "") + (delta.toolUse.input || "");
22250
- block.arguments = parseStreamingJson(block.partialJson);
22251
- stream2.push({ type: "toolcall_delta", contentIndex: index, delta: delta.toolUse.input || "", partial: output });
22270
+ } else if (delta?.toolUse && block?.type === "toolCall" && open?.arguments !== void 0) {
22271
+ block.arguments = open.arguments.append(delta.toolUse.input || "");
22272
+ stream2.push({
22273
+ type: "toolcall_delta",
22274
+ contentIndex: open.contentIndex,
22275
+ delta: delta.toolUse.input || "",
22276
+ partial: output
22277
+ });
22252
22278
  } else if (delta?.reasoningContent) {
22253
- let thinkingBlock = block;
22254
- let thinkingIndex = index;
22255
- if (!thinkingBlock) {
22256
- const newBlock = { type: "thinking", thinking: "", thinkingSignature: "", index: contentBlockIndex };
22257
- output.content.push(newBlock);
22258
- thinkingIndex = blocks.length - 1;
22259
- thinkingBlock = blocks[thinkingIndex];
22260
- stream2.push({ type: "thinking_start", contentIndex: thinkingIndex, partial: output });
22279
+ if (!open) {
22280
+ output.content.push({ type: "thinking", thinking: "", thinkingSignature: "" });
22281
+ open = { contentIndex: output.content.length - 1 };
22282
+ openBlocks.set(contentBlockIndex, open);
22283
+ block = output.content[open.contentIndex];
22284
+ stream2.push({ type: "thinking_start", contentIndex: open.contentIndex, partial: output });
22261
22285
  }
22262
- if (thinkingBlock?.type === "thinking") {
22286
+ if (block?.type === "thinking") {
22287
+ const thinkingIndex = open.contentIndex;
22263
22288
  if (delta.reasoningContent.text) {
22264
- thinkingBlock.thinking += delta.reasoningContent.text;
22289
+ block.thinking += delta.reasoningContent.text;
22265
22290
  stream2.push({
22266
22291
  type: "thinking_delta",
22267
22292
  contentIndex: thinkingIndex,
@@ -22269,14 +22294,14 @@ function handleContentBlockDelta(event, blocks, output, stream2) {
22269
22294
  partial: output
22270
22295
  });
22271
22296
  }
22272
- if (delta.reasoningContent.signature && !thinkingBlock.redacted) {
22273
- thinkingBlock.thinkingSignature = (thinkingBlock.thinkingSignature || "") + delta.reasoningContent.signature;
22297
+ if (delta.reasoningContent.signature && !block.redacted) {
22298
+ block.thinkingSignature = (block.thinkingSignature || "") + delta.reasoningContent.signature;
22274
22299
  }
22275
22300
  if (delta.reasoningContent.redactedContent?.length) {
22276
- if (!thinkingBlock.redacted) {
22277
- thinkingBlock.redacted = true;
22278
- thinkingBlock.thinkingSignature = "";
22279
- thinkingBlock.thinking += REDACTED_THINKING_PLACEHOLDER;
22301
+ if (!block.redacted) {
22302
+ block.redacted = true;
22303
+ block.thinkingSignature = "";
22304
+ block.thinking += REDACTED_THINKING_PLACEHOLDER;
22280
22305
  stream2.push({
22281
22306
  type: "thinking_delta",
22282
22307
  contentIndex: thinkingIndex,
@@ -22284,22 +22309,23 @@ function handleContentBlockDelta(event, blocks, output, stream2) {
22284
22309
  partial: output
22285
22310
  });
22286
22311
  }
22287
- thinkingBlock.redactedChunks ??= [];
22288
- thinkingBlock.redactedChunks.push(delta.reasoningContent.redactedContent);
22312
+ open.redactedChunks ??= [];
22313
+ open.redactedChunks.push(delta.reasoningContent.redactedContent);
22289
22314
  }
22290
22315
  }
22291
22316
  }
22292
22317
  }
22293
- function flushRedactedContent(block) {
22294
- if (block.type !== "thinking" || !block.redactedChunks)
22318
+ function flushRedactedContent(open, output) {
22319
+ const block = output.content[open.contentIndex];
22320
+ if (block?.type !== "thinking" || !open.redactedChunks)
22295
22321
  return;
22296
- block.thinkingSignature = bytesToBase64(block.redactedChunks);
22297
- delete block.redactedChunks;
22322
+ block.thinkingSignature = bytesToBase64(open.redactedChunks);
22323
+ open.redactedChunks = void 0;
22298
22324
  }
22299
- function finalizeStreamingBlock(block) {
22300
- delete block.index;
22301
- delete block.partialJson;
22302
- flushRedactedContent(block);
22325
+ function flushOpenBlocks(openBlocks, output) {
22326
+ for (const open of openBlocks.values())
22327
+ flushRedactedContent(open, output);
22328
+ openBlocks.clear();
22303
22329
  }
22304
22330
  function handleMetadata(event, model, output) {
22305
22331
  if (event.usage) {
@@ -22312,23 +22338,24 @@ function handleMetadata(event, model, output) {
22312
22338
  calculateCost(model, output.usage);
22313
22339
  }
22314
22340
  }
22315
- function handleContentBlockStop(event, blocks, output, stream2) {
22316
- const index = blocks.findIndex((b5) => b5.index === event.contentBlockIndex);
22317
- const block = blocks[index];
22318
- if (!block)
22341
+ function handleContentBlockStop(event, openBlocks, output, stream2) {
22342
+ const open = openBlocks.get(event.contentBlockIndex);
22343
+ if (!open)
22319
22344
  return;
22320
- delete block.index;
22345
+ openBlocks.delete(event.contentBlockIndex);
22346
+ const index = open.contentIndex;
22347
+ const block = output.content[index];
22321
22348
  switch (block.type) {
22322
22349
  case "text":
22323
22350
  stream2.push({ type: "text_end", contentIndex: index, content: block.text, partial: output });
22324
22351
  break;
22325
22352
  case "thinking":
22326
- flushRedactedContent(block);
22353
+ flushRedactedContent(open, output);
22327
22354
  stream2.push({ type: "thinking_end", contentIndex: index, content: block.thinking, partial: output });
22328
22355
  break;
22329
22356
  case "toolCall":
22330
- Object.assign(block, parseToolCallArguments(block.partialJson));
22331
- delete block.partialJson;
22357
+ if (open.arguments !== void 0)
22358
+ Object.assign(block, open.arguments.finish());
22332
22359
  stream2.push({ type: "toolcall_end", contentIndex: index, toolCall: block, partial: output });
22333
22360
  break;
22334
22361
  }
@@ -22588,13 +22615,15 @@ function convertMessages(context, model, cacheRetention, env2) {
22588
22615
  }
22589
22616
  return result;
22590
22617
  }
22591
- function convertToolConfig(tools, toolChoice, supportsStrictMode) {
22592
- if (!tools?.length)
22593
- return void 0;
22594
- if (toolChoice === "none")
22595
- return void 0;
22618
+ function convertToolConfig(tools, toolChoice, supportsStrictMode, disablePreferredStrictTools) {
22619
+ if (!tools?.length || toolChoice === "none")
22620
+ return { toolConfig: void 0, hasPreferredStrictTools: false };
22621
+ let hasPreferredStrictTools = false;
22596
22622
  const bedrockTools = tools.map((tool) => {
22597
- const strict = resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
22623
+ const preferred = prefersJsonSchemaStrictSampling(tool);
22624
+ const strict = disablePreferredStrictTools && preferred ? void 0 : resolveJsonSchemaStrictSampling(tool, supportsStrictMode);
22625
+ if (strict === true && preferred)
22626
+ hasPreferredStrictTools = true;
22598
22627
  return {
22599
22628
  toolSpec: {
22600
22629
  name: tool.name,
@@ -22617,7 +22646,7 @@ function convertToolConfig(tools, toolChoice, supportsStrictMode) {
22617
22646
  bedrockToolChoice = { tool: { name: toolChoice.name } };
22618
22647
  }
22619
22648
  }
22620
- return { tools: bedrockTools, toolChoice: bedrockToolChoice };
22649
+ return { toolConfig: { tools: bedrockTools, toolChoice: bedrockToolChoice }, hasPreferredStrictTools };
22621
22650
  }
22622
22651
  function mapStopReason(reason) {
22623
22652
  switch (reason) {
@@ -22793,12 +22822,7 @@ function bytesToBase64(chunks) {
22793
22822
  }
22794
22823
  return btoa(binary);
22795
22824
  }
22796
-
22797
- // 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/bedrock-provider.js
22798
- var bedrockProviderModule = {
22825
+ export {
22799
22826
  stream,
22800
22827
  streamSimple
22801
22828
  };
22802
- export {
22803
- bedrockProviderModule
22804
- };
@@ -2,64 +2,60 @@ import { createRequire as __nerveCreateRequire } from "node:module";
2
2
  const require = __nerveCreateRequire(import.meta.url);
3
3
  import {
4
4
  resolveHttpProxyUrlForTarget
5
- } from "./chunk-MH3SUHI2.js";
5
+ } from "./chunk-KBNEZR7T.js";
6
6
  import {
7
7
  combineAbortSignals
8
- } from "./chunk-XNYZEQ3U.js";
8
+ } from "./chunk-6TAN6WG6.js";
9
9
  import {
10
10
  convertResponsesMessages,
11
11
  convertResponsesTools,
12
12
  getResponsesToolSupport,
13
13
  processResponsesStream
14
- } from "./chunk-H5UKINTD.js";
14
+ } from "./chunk-ANI6J75M.js";
15
+ import {
16
+ registerSessionResourceCleanup
17
+ } from "./chunk-OANTMDXI.js";
15
18
  import {
16
19
  clampOpenAIPromptCacheKey
17
- } from "./chunk-UGDIHDAR.js";
18
- import "./chunk-KSZJ3HGD.js";
19
- import "./chunk-RUZ2UAYH.js";
20
+ } from "./chunk-ODS5QROC.js";
21
+ import "./chunk-2BKMOJYJ.js";
20
22
  import {
21
23
  buildBaseOptions,
22
24
  createGrammarToolInputProperties
23
- } from "./chunk-N5B2RRSS.js";
24
- import "./chunk-2Z5FLMLE.js";
25
+ } from "./chunk-OAEV22IW.js";
26
+ import "./chunk-3SSNDIQT.js";
25
27
  import {
26
28
  formatProviderError,
27
29
  normalizeProviderError
28
- } from "./chunk-AON37AL2.js";
30
+ } from "./chunk-O2652RWY.js";
29
31
  import {
30
32
  headersToRecord
31
- } from "./chunk-CEX2GWGZ.js";
32
- import "./chunk-FESN7DND.js";
33
+ } from "./chunk-VBM7TD3X.js";
34
+ import "./chunk-SU2USXTD.js";
35
+ import "./chunk-H2G55ZPG.js";
33
36
  import {
34
37
  clampThinkingLevel,
35
38
  getDeclaredTools,
36
39
  getInitialSystemMessage,
37
- getSystemMessageText,
38
40
  normalizeContext,
39
41
  resolveTranscript,
40
42
  resolveTranscriptTools
41
- } from "./chunk-WXRYBXYR.js";
43
+ } from "./chunk-TGKIV3F4.js";
42
44
  import {
43
45
  AssistantMessageEventStream,
44
46
  appendAssistantMessageDiagnostic,
45
47
  createAssistantMessageDiagnostic,
46
48
  formatThrownValue
47
- } from "./chunk-MN7PZ2PH.js";
49
+ } from "./chunk-TSV3PFU2.js";
48
50
  import {
49
51
  getIdentityHeaders
50
- } from "./chunk-24GQ74HM.js";
52
+ } from "./chunk-UDC7NPQJ.js";
53
+ import {
54
+ getSystemMessageText
55
+ } from "./chunk-XY53EFK3.js";
51
56
  import "./chunk-CWESUMYQ.js";
52
57
 
53
- // 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/session-resources.js
54
- var sessionResourceCleanups = /* @__PURE__ */ new Set();
55
- function registerSessionResourceCleanup(cleanup) {
56
- sessionResourceCleanups.add(cleanup);
57
- return () => {
58
- sessionResourceCleanups.delete(cleanup);
59
- };
60
- }
61
-
62
- // 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/uuid.js
58
+ // 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/uuid.js
63
59
  var MAX_UUID_V7_TIMESTAMP = 281474976710655;
64
60
  var MAX_SEQUENCE = (1n << 41n) - 1n;
65
61
  var lastOrdinaryTimestamp = -1;
@@ -95,7 +91,7 @@ function uuidv7(timestampMs) {
95
91
  return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
96
92
  }
97
93
 
98
- // 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-codex-responses.js
94
+ // 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-codex-responses.js
99
95
  var DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api";
100
96
  var JWT_CLAIM_PATH = "https://api.openai.com/auth";
101
97
  var DEFAULT_MAX_RETRIES = 0;
@@ -172,11 +168,15 @@ function sleep(ms, signal) {
172
168
  reject(new Error("Request was aborted"));
173
169
  return;
174
170
  }
175
- const timeout = setTimeout(resolve, ms);
176
- signal?.addEventListener("abort", () => {
171
+ const onAbort = () => {
177
172
  clearTimeout(timeout);
178
173
  reject(new Error("Request was aborted"));
179
- });
174
+ };
175
+ const timeout = setTimeout(() => {
176
+ signal?.removeEventListener("abort", onAbort);
177
+ resolve();
178
+ }, ms);
179
+ signal?.addEventListener("abort", onAbort, { once: true });
180
180
  });
181
181
  }
182
182
  function normalizeTimeoutMs(value) {
@@ -391,10 +391,6 @@ var stream = (model, context, options) => {
391
391
  stream2.push({ type: "done", reason: output.stopReason, message: output });
392
392
  stream2.end();
393
393
  } catch (error) {
394
- for (const block of output.content) {
395
- delete block.partialJson;
396
- delete block.customInput;
397
- }
398
394
  output.stopReason = options?.signal?.aborted ? "aborted" : "error";
399
395
  output.errorMessage = formatProviderError(normalizeProviderError(error));
400
396
  stream2.push({ type: "error", reason: output.stopReason, error: output });