@cjhyy/code-shell 0.1.6 → 0.2.0

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 (171) hide show
  1. package/dist/anthropic-OVRWAZRD.js +1 -0
  2. package/dist/arena/index.js +1 -104
  3. package/dist/arena-64T2EQD4.js +3 -0
  4. package/dist/bwrap-PVZMLHZR.js +2 -0
  5. package/dist/chunk-2EUIMKJA.js +1 -0
  6. package/dist/chunk-2GJ7H5NC.js +641 -0
  7. package/dist/chunk-2OD6VR4N.js +2 -0
  8. package/dist/chunk-3QP5BQ3L.js +1 -0
  9. package/dist/chunk-A4M2Y42L.js +2 -0
  10. package/dist/chunk-DEYFK6FP.js +1 -0
  11. package/dist/chunk-DTPABBSV.js +2 -0
  12. package/dist/chunk-EU3J7TBP.js +1 -0
  13. package/dist/chunk-FU7AHZNN.js +1 -0
  14. package/dist/chunk-L7B2ORID.js +4 -0
  15. package/dist/chunk-M7VU4YVY.js +49 -0
  16. package/dist/chunk-MGP35GKD.js +254 -0
  17. package/dist/chunk-MLCTC53I.js +1 -0
  18. package/dist/chunk-O5HFCH2U.js +1 -0
  19. package/dist/chunk-P6JSTIFM.js +1 -0
  20. package/dist/chunk-Q3RSX66I.js +1 -0
  21. package/dist/chunk-QTWU7UNA.js +5 -0
  22. package/dist/chunk-RERBX75D.js +251 -0
  23. package/dist/chunk-SNFAPSLA.js +1 -0
  24. package/dist/chunk-T222K6IV.js +18 -0
  25. package/dist/chunk-TKJA6W36.js +3 -0
  26. package/dist/chunk-VKKU4LOM.js +3 -0
  27. package/dist/chunk-WI6FSWGU.js +1 -0
  28. package/dist/chunk-XXCZE2U2.js +2 -0
  29. package/dist/chunk-ZSAONDT6.js +2 -0
  30. package/dist/cli/main.js +303 -22060
  31. package/dist/cli/onboarding.d.ts +7 -2
  32. package/dist/client-base-F5FCRSB3.js +1 -0
  33. package/dist/compaction-L3Y6NG4N.js +1 -0
  34. package/dist/context/compaction.d.ts +2 -1
  35. package/dist/data/static-catalogs.d.ts +25 -0
  36. package/dist/devtools-SGDUOOM4.js +1 -0
  37. package/dist/engine/engine.d.ts +24 -0
  38. package/dist/engine/turn-loop.d.ts +20 -0
  39. package/dist/export-md-U72T7NW7.js +22 -0
  40. package/dist/file-history-7FQFEQOL.js +1 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.js +1 -347
  43. package/dist/llm/capabilities/index.d.ts +20 -0
  44. package/dist/llm/capabilities/rules.d.ts +26 -0
  45. package/dist/llm/capabilities/types.d.ts +108 -0
  46. package/dist/llm/model-pool.d.ts +7 -0
  47. package/dist/llm/provider-catalog.d.ts +2 -0
  48. package/dist/llm/provider-kinds.d.ts +1 -1
  49. package/dist/llm/providers/openai.d.ts +22 -0
  50. package/dist/llm/token-counter.d.ts +17 -0
  51. package/dist/llm/types.d.ts +8 -0
  52. package/dist/logging/logger.d.ts +10 -2
  53. package/dist/logging/session-recorder.d.ts +16 -3
  54. package/dist/manager-J6FXEUEK.js +1 -0
  55. package/dist/mcp-manager-27EVBKRT.js +1 -0
  56. package/dist/memory-BNI4WEWL.js +1 -0
  57. package/dist/model-cache-HEDXI7UJ.js +1 -0
  58. package/dist/model-fetcher-X5W5EASG.js +1 -0
  59. package/dist/off-7SDVMMXW.js +1 -0
  60. package/dist/openai-3QEADSYL.js +1 -0
  61. package/dist/openrouter-models-GZVCRWD2.js +1 -0
  62. package/dist/openrouter-sync-WG4AG5NC.js +1 -0
  63. package/dist/product/index.js +1 -21
  64. package/dist/protocol/client.d.ts +1 -1
  65. package/dist/run/index.js +1 -48
  66. package/dist/seatbelt-L54CNI2Y.js +37 -0
  67. package/dist/session/session-manager.d.ts +2 -0
  68. package/dist/session-manager-AGWS5SMJ.js +1 -0
  69. package/dist/settings/schema.d.ts +147 -21
  70. package/dist/tool-summary-V2B3MD5N.js +2 -0
  71. package/dist/tool-system/builtin/bash.d.ts +7 -1
  72. package/dist/tool-system/context.d.ts +7 -0
  73. package/dist/tool-system/executor.d.ts +4 -0
  74. package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
  75. package/dist/tool-system/sandbox/index.d.ts +78 -0
  76. package/dist/tool-system/sandbox/off.d.ts +2 -0
  77. package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
  78. package/dist/tool-system/task-guard.d.ts +30 -0
  79. package/dist/types.d.ts +17 -0
  80. package/dist/ui/components/SessionPicker.d.ts +2 -0
  81. package/dist/ui/components/SpinnerWithVerb.d.ts +7 -2
  82. package/dist/ui/components/StatusLine.d.ts +7 -3
  83. package/dist/updater-OCNU2K2Z.js +1 -0
  84. package/package.json +7 -10
  85. package/dist/anthropic-IBTI4WL2.cjs +0 -10
  86. package/dist/anthropic-PRZZKHEZ.js +0 -10
  87. package/dist/arena/index.cjs +0 -104
  88. package/dist/arena-2LTLIXOL.js +0 -261
  89. package/dist/arena-ADB7DRFI.cjs +0 -261
  90. package/dist/chunk-2YW4FPFG.cjs +0 -101
  91. package/dist/chunk-3OA5G4TM.js +0 -47
  92. package/dist/chunk-3QO25N6E.js +0 -4711
  93. package/dist/chunk-3SBSUOWZ.js +0 -447
  94. package/dist/chunk-52LGZKT3.cjs +0 -47
  95. package/dist/chunk-55XGPMAP.cjs +0 -146
  96. package/dist/chunk-6QVAYW7C.cjs +0 -438
  97. package/dist/chunk-6S4BJ65N.js +0 -113
  98. package/dist/chunk-76HYEPDM.js +0 -307
  99. package/dist/chunk-7BI3V74Y.cjs +0 -447
  100. package/dist/chunk-7EG3V4JY.cjs +0 -113
  101. package/dist/chunk-7JVTYEEC.js +0 -340
  102. package/dist/chunk-7QIM3BKD.js +0 -44
  103. package/dist/chunk-7Y6S3OCX.js +0 -438
  104. package/dist/chunk-ABRRONJ7.js +0 -107
  105. package/dist/chunk-BSW22MPA.js +0 -146
  106. package/dist/chunk-BXCY2FSE.js +0 -203
  107. package/dist/chunk-BZ5TNE7L.js +0 -5128
  108. package/dist/chunk-DDB6QOKJ.cjs +0 -1252
  109. package/dist/chunk-HEKQCI7B.cjs +0 -224
  110. package/dist/chunk-IK4EWJBP.cjs +0 -203
  111. package/dist/chunk-ILHE7XLT.cjs +0 -107
  112. package/dist/chunk-JMR33QVF.cjs +0 -169
  113. package/dist/chunk-KAQHULYN.js +0 -54
  114. package/dist/chunk-KE4EQOWA.js +0 -294
  115. package/dist/chunk-KOVYSDHZ.cjs +0 -340
  116. package/dist/chunk-KS3RYAYL.cjs +0 -45
  117. package/dist/chunk-MD32R22I.js +0 -50
  118. package/dist/chunk-MV7YI4WO.cjs +0 -293
  119. package/dist/chunk-MY5XHADU.cjs +0 -216
  120. package/dist/chunk-NUNC3VFB.cjs +0 -307
  121. package/dist/chunk-PKGRTCCY.js +0 -9092
  122. package/dist/chunk-QARL3IDQ.js +0 -1252
  123. package/dist/chunk-S754JHLR.cjs +0 -54
  124. package/dist/chunk-SFXHZSRF.js +0 -101
  125. package/dist/chunk-SIHHIQLO.js +0 -224
  126. package/dist/chunk-T6VYG46N.js +0 -105
  127. package/dist/chunk-TNLGBJYS.cjs +0 -44
  128. package/dist/chunk-TUY2T5KP.cjs +0 -105
  129. package/dist/chunk-UXOCVJJ6.cjs +0 -9092
  130. package/dist/chunk-VIAGTYYW.js +0 -169
  131. package/dist/chunk-WASS5YWB.js +0 -215
  132. package/dist/chunk-WZJV6DJC.cjs +0 -5128
  133. package/dist/chunk-YIQBXAYU.cjs +0 -264
  134. package/dist/chunk-YKIAELDZ.cjs +0 -4711
  135. package/dist/chunk-ZBPSQCPU.js +0 -264
  136. package/dist/cli/main.cjs +0 -22156
  137. package/dist/client-base-HTF236ZD.cjs +0 -9
  138. package/dist/client-base-QKRKCOWB.js +0 -9
  139. package/dist/compaction-6VU2T643.js +0 -33
  140. package/dist/compaction-OKUNTCA7.cjs +0 -33
  141. package/dist/devtools-T2NIZBJK.cjs +0 -6
  142. package/dist/devtools-YXWHOVKR.js +0 -6
  143. package/dist/export-md-RXDW6F5W.cjs +0 -135
  144. package/dist/export-md-XXKZANW5.js +0 -135
  145. package/dist/file-history-KYPE3ECT.cjs +0 -7
  146. package/dist/file-history-LF4F7X26.js +0 -7
  147. package/dist/index.cjs +0 -347
  148. package/dist/manager-D65VFAPX.js +0 -7
  149. package/dist/manager-TTF5VHJC.cjs +0 -7
  150. package/dist/mcp-manager-QMKWPBZ4.js +0 -8
  151. package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
  152. package/dist/memory-5LWZ6FI2.cjs +0 -9
  153. package/dist/memory-VIJLBAMQ.js +0 -9
  154. package/dist/model-cache-5KIYL5SL.js +0 -13
  155. package/dist/model-cache-OED3IM4R.cjs +0 -13
  156. package/dist/model-fetcher-HKGICACL.js +0 -8
  157. package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
  158. package/dist/openai-JR2WEKOF.js +0 -10
  159. package/dist/openai-YBTOET4O.cjs +0 -10
  160. package/dist/openrouter-models-H56GHBHN.js +0 -15
  161. package/dist/openrouter-models-TWUFWZ5T.cjs +0 -15
  162. package/dist/openrouter-sync-5VMGN6C2.cjs +0 -11
  163. package/dist/openrouter-sync-ALEMF5IU.js +0 -11
  164. package/dist/product/index.cjs +0 -21
  165. package/dist/run/index.cjs +0 -48
  166. package/dist/session-manager-Q22BBMD3.js +0 -8
  167. package/dist/session-manager-XODQVL3C.cjs +0 -8
  168. package/dist/tool-summary-63DPIS7G.cjs +0 -31
  169. package/dist/tool-summary-NP5CDBKG.js +0 -31
  170. package/dist/updater-I7QBW4DP.cjs +0 -17
  171. package/dist/updater-NVME5S3Z.js +0 -17
@@ -1,340 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
-
3
- var _chunk7EG3V4JYcjs = require('./chunk-7EG3V4JY.cjs');
4
-
5
-
6
-
7
-
8
- var _chunk2YW4FPFGcjs = require('./chunk-2YW4FPFG.cjs');
9
-
10
-
11
- var _chunkIK4EWJBPcjs = require('./chunk-IK4EWJBP.cjs');
12
-
13
-
14
- var _chunkKS3RYAYLcjs = require('./chunk-KS3RYAYL.cjs');
15
-
16
- // src/llm/providers/openai.ts
17
- _chunkKS3RYAYLcjs.init_cjs_shims.call(void 0, );
18
- var _openai = require('openai'); var _openai2 = _interopRequireDefault(_openai);
19
- var OpenAIClient = (_class = class extends _chunk7EG3V4JYcjs.LLMClientBase {
20
- __init() {this._client = null}
21
- constructor(config) {
22
- super(config);_class.prototype.__init.call(this);;
23
- }
24
- initClient() {
25
- }
26
- get client() {
27
- if (!this._client) {
28
- this._client = new (0, _openai2.default)({
29
- apiKey: _nullishCoalesce(this.config.apiKey, () => ( process.env.OPENAI_API_KEY)),
30
- ...this.config.baseUrl ? { baseURL: this.config.baseUrl } : {},
31
- timeout: this.timeout
32
- });
33
- }
34
- return this._client;
35
- }
36
- async createMessage(options) {
37
- return this.withRetry(async () => {
38
- const messages = this.buildMessages(options.systemPrompt, options.messages);
39
- const tools = _optionalChain([options, 'access', _ => _.tools, 'optionalAccess', _2 => _2.length]) ? this.convertTools(options.tools) : void 0;
40
- const span = _chunkIK4EWJBPcjs.logger.span("llm.request", {
41
- cat: "llm",
42
- provider: this.provider,
43
- model: this.model,
44
- stream: !!(options.stream && options.onChunk),
45
- messageCount: messages.length,
46
- toolCount: _nullishCoalesce(_optionalChain([tools, 'optionalAccess', _3 => _3.length]), () => ( 0))
47
- });
48
- try {
49
- const response = options.stream && options.onChunk ? await this.streamMessage(options, messages, tools) : await this.nonStreamMessage(options, messages, tools);
50
- span.end({
51
- stopReason: response.stopReason,
52
- promptTokens: _optionalChain([response, 'access', _4 => _4.usage, 'optionalAccess', _5 => _5.promptTokens]),
53
- completionTokens: _optionalChain([response, 'access', _6 => _6.usage, 'optionalAccess', _7 => _7.completionTokens]),
54
- cacheReadTokens: _optionalChain([response, 'access', _8 => _8.usage, 'optionalAccess', _9 => _9.cacheReadTokens]),
55
- cacheCreationTokens: _optionalChain([response, 'access', _10 => _10.usage, 'optionalAccess', _11 => _11.cacheCreationTokens])
56
- });
57
- return response;
58
- } catch (err) {
59
- span.fail(err);
60
- throw err;
61
- }
62
- });
63
- }
64
- async nonStreamMessage(options, messages, tools) {
65
- try {
66
- const response = await this.client.chat.completions.create(
67
- {
68
- model: this.model,
69
- max_tokens: _nullishCoalesce(options.maxTokens, () => ( this.maxTokens)),
70
- messages,
71
- ...tools ? { tools } : {},
72
- ...options.temperature !== void 0 ? { temperature: options.temperature } : { temperature: this.temperature }
73
- },
74
- { signal: options.signal }
75
- );
76
- const choice = response.choices[0];
77
- if (!choice) throw new (0, _chunk2YW4FPFGcjs.LLMError)("No response from OpenAI", "openai");
78
- const usage = {
79
- promptTokens: _nullishCoalesce(_optionalChain([response, 'access', _12 => _12.usage, 'optionalAccess', _13 => _13.prompt_tokens]), () => ( 0)),
80
- completionTokens: _nullishCoalesce(_optionalChain([response, 'access', _14 => _14.usage, 'optionalAccess', _15 => _15.completion_tokens]), () => ( 0)),
81
- totalTokens: _nullishCoalesce(_optionalChain([response, 'access', _16 => _16.usage, 'optionalAccess', _17 => _17.total_tokens]), () => ( 0))
82
- };
83
- this.recordUsage(usage, options);
84
- return this.processChoice(choice, usage);
85
- } catch (err) {
86
- this.handleApiError(err);
87
- throw err;
88
- }
89
- }
90
- async streamMessage(options, messages, tools) {
91
- try {
92
- const stream = await this.client.chat.completions.create(
93
- {
94
- model: this.model,
95
- max_tokens: _nullishCoalesce(options.maxTokens, () => ( this.maxTokens)),
96
- messages,
97
- stream: true,
98
- stream_options: { include_usage: true },
99
- ...tools ? { tools } : {},
100
- ...options.temperature !== void 0 ? { temperature: options.temperature } : { temperature: this.temperature }
101
- },
102
- { signal: options.signal }
103
- );
104
- let text = "";
105
- let reasoningContent = "";
106
- const toolCallsMap = /* @__PURE__ */ new Map();
107
- let streamUsage;
108
- const streamStartedAt = Date.now();
109
- let firstByteLogged = false;
110
- for await (const chunk of stream) {
111
- if (chunk.usage) {
112
- streamUsage = chunk.usage;
113
- }
114
- const delta = _optionalChain([chunk, 'access', _18 => _18.choices, 'access', _19 => _19[0], 'optionalAccess', _20 => _20.delta]);
115
- if (!delta) continue;
116
- const reasoningDelta = delta.reasoning_content;
117
- if (typeof reasoningDelta === "string" && reasoningDelta.length > 0) {
118
- reasoningContent += reasoningDelta;
119
- }
120
- if (delta.content) {
121
- if (!firstByteLogged) {
122
- firstByteLogged = true;
123
- _chunkIK4EWJBPcjs.logger.debug("llm.first_byte", {
124
- cat: "llm",
125
- provider: this.provider,
126
- model: this.model,
127
- ttft_ms: Date.now() - streamStartedAt
128
- });
129
- }
130
- text += delta.content;
131
- _optionalChain([options, 'access', _21 => _21.onChunk, 'optionalCall', _22 => _22({ type: "text", text: delta.content })]);
132
- }
133
- if (delta.tool_calls) {
134
- for (const tc of delta.tool_calls) {
135
- const idx = tc.index;
136
- if (!toolCallsMap.has(idx)) {
137
- toolCallsMap.set(idx, { id: _nullishCoalesce(tc.id, () => ( "")), name: _nullishCoalesce(_optionalChain([tc, 'access', _23 => _23.function, 'optionalAccess', _24 => _24.name]), () => ( "")), args: "" });
138
- _optionalChain([options, 'access', _25 => _25.onChunk, 'optionalCall', _26 => _26({
139
- type: "tool_use_start",
140
- toolCall: { id: tc.id, toolName: _optionalChain([tc, 'access', _27 => _27.function, 'optionalAccess', _28 => _28.name]) }
141
- })]);
142
- }
143
- const existing = toolCallsMap.get(idx);
144
- if (tc.id) existing.id = tc.id;
145
- if (_optionalChain([tc, 'access', _29 => _29.function, 'optionalAccess', _30 => _30.name])) existing.name = tc.function.name;
146
- if (_optionalChain([tc, 'access', _31 => _31.function, 'optionalAccess', _32 => _32.arguments])) {
147
- existing.args += tc.function.arguments;
148
- if (existing.id) {
149
- try {
150
- const parsed = JSON.parse(existing.args || "{}");
151
- _optionalChain([options, 'access', _33 => _33.onChunk, 'optionalCall', _34 => _34({
152
- type: "tool_use_delta",
153
- toolCall: { id: existing.id, toolName: existing.name, args: parsed }
154
- })]);
155
- } catch (e) {
156
- }
157
- }
158
- }
159
- }
160
- }
161
- if (_optionalChain([chunk, 'access', _35 => _35.choices, 'access', _36 => _36[0], 'optionalAccess', _37 => _37.finish_reason])) {
162
- _optionalChain([options, 'access', _38 => _38.onChunk, 'optionalCall', _39 => _39({ type: "stop", stopReason: chunk.choices[0].finish_reason })]);
163
- }
164
- }
165
- const toolCalls = [];
166
- for (const [, tc] of toolCallsMap) {
167
- let args = {};
168
- try {
169
- args = JSON.parse(tc.args || "{}");
170
- } catch (e2) {
171
- }
172
- toolCalls.push({ id: tc.id, toolName: tc.name, args });
173
- }
174
- const usage = {
175
- promptTokens: _nullishCoalesce(_optionalChain([streamUsage, 'optionalAccess', _40 => _40.prompt_tokens]), () => ( 0)),
176
- completionTokens: _nullishCoalesce(_optionalChain([streamUsage, 'optionalAccess', _41 => _41.completion_tokens]), () => ( 0)),
177
- totalTokens: _nullishCoalesce(_optionalChain([streamUsage, 'optionalAccess', _42 => _42.total_tokens]), () => ( 0))
178
- };
179
- this.recordUsage(usage, options);
180
- return {
181
- text,
182
- toolCalls,
183
- usage,
184
- stopReason: "stop",
185
- ...reasoningContent ? { reasoningContent } : {}
186
- };
187
- } catch (err) {
188
- this.handleApiError(err);
189
- throw err;
190
- }
191
- }
192
- processChoice(choice, usage) {
193
- const text = _nullishCoalesce(choice.message.content, () => ( ""));
194
- const toolCalls = [];
195
- if (choice.message.tool_calls) {
196
- for (const tc of choice.message.tool_calls) {
197
- let args = {};
198
- try {
199
- args = JSON.parse(tc.function.arguments || "{}");
200
- } catch (e3) {
201
- }
202
- toolCalls.push({
203
- id: tc.id,
204
- toolName: tc.function.name,
205
- args
206
- });
207
- }
208
- }
209
- const reasoningContent = extractReasoningContent(
210
- choice.message
211
- );
212
- return {
213
- text,
214
- toolCalls,
215
- usage,
216
- stopReason: _nullishCoalesce(choice.finish_reason, () => ( void 0)),
217
- ...reasoningContent ? { reasoningContent } : {}
218
- };
219
- }
220
- buildMessages(systemPrompt, messages) {
221
- const result = [{ role: "system", content: systemPrompt }];
222
- const needsReasoningBackfill = isDeepSeekThinkingModel(this.model);
223
- for (const msg of messages) {
224
- if (msg.role === "system") continue;
225
- if (msg.role === "assistant") {
226
- const param = { role: "assistant" };
227
- let reasoningContent;
228
- if (typeof msg.content === "string") {
229
- param.content = msg.content;
230
- } else {
231
- const textParts = [];
232
- const toolCalls = [];
233
- for (const block of msg.content) {
234
- if (block.type === "text" && block.text) {
235
- textParts.push(block.text);
236
- } else if (block.type === "tool_use" && block.id && block.name) {
237
- toolCalls.push({
238
- id: block.id,
239
- type: "function",
240
- function: {
241
- name: block.name,
242
- arguments: JSON.stringify(_nullishCoalesce(block.input, () => ( {})))
243
- }
244
- });
245
- } else if (block.type === "reasoning" && block.reasoningContent) {
246
- reasoningContent = block.reasoningContent;
247
- }
248
- if (!reasoningContent && block.reasoningContent) {
249
- reasoningContent = block.reasoningContent;
250
- }
251
- }
252
- if (textParts.length) param.content = textParts.join("\n");
253
- if (toolCalls.length) param.tool_calls = toolCalls;
254
- }
255
- if (!reasoningContent && needsReasoningBackfill) {
256
- reasoningContent = "";
257
- }
258
- if (reasoningContent !== void 0) {
259
- param.reasoning_content = reasoningContent;
260
- }
261
- result.push(param);
262
- } else if (msg.role === "tool") {
263
- result.push({
264
- role: "tool",
265
- tool_call_id: _nullishCoalesce(msg.tool_call_id, () => ( "")),
266
- content: typeof msg.content === "string" ? msg.content : ""
267
- });
268
- } else {
269
- if (typeof msg.content === "string") {
270
- result.push({ role: "user", content: msg.content });
271
- } else {
272
- const textParts = [];
273
- const toolResults = [];
274
- for (const block of msg.content) {
275
- if (block.type === "tool_result" && block.tool_use_id) {
276
- toolResults.push({
277
- tool_use_id: block.tool_use_id,
278
- content: typeof block.content === "string" ? block.content : ""
279
- });
280
- } else if (block.type === "text" && block.text) {
281
- textParts.push(block.text);
282
- }
283
- }
284
- for (const tr of toolResults) {
285
- result.push({
286
- role: "tool",
287
- tool_call_id: tr.tool_use_id,
288
- content: tr.content
289
- });
290
- }
291
- if (textParts.length > 0) {
292
- result.push({ role: "user", content: textParts.join("\n") });
293
- }
294
- }
295
- }
296
- }
297
- return result;
298
- }
299
- convertTools(tools) {
300
- return tools.map((t) => ({
301
- type: "function",
302
- function: {
303
- name: t.name,
304
- description: t.description,
305
- parameters: t.inputSchema
306
- }
307
- }));
308
- }
309
- handleApiError(err) {
310
- if (err instanceof _openai2.default.APIError) {
311
- if (err.status === 429) {
312
- throw new (0, _chunk2YW4FPFGcjs.LLMRateLimitError)("openai");
313
- }
314
- const msg = (_nullishCoalesce(err.message, () => ( ""))).toLowerCase();
315
- if (msg.includes("context_length_exceeded") || msg.includes("maximum context length") || msg.includes("too many tokens") || msg.includes("prompt is too long")) {
316
- throw new (0, _chunk2YW4FPFGcjs.ContextLimitError)("openai");
317
- }
318
- if (err.status === 401 && msg.includes("provider returned error")) {
319
- throw new (0, _chunk2YW4FPFGcjs.LLMError)(
320
- `OpenAI-compatible endpoint returned 401 "Provider returned error". Two likely causes: (1) the API key is invalid/revoked, or (2) the upstream provider rejects tool calls for this model (common on OpenRouter's gpt-4o-mini route). Verify the key, then try a tool-capable model such as openai/gpt-4.1-mini or anthropic/claude-3.5-haiku.`,
321
- "openai",
322
- { status: err.status }
323
- );
324
- }
325
- throw new (0, _chunk2YW4FPFGcjs.LLMError)(`OpenAI API error: ${err.message}`, "openai", { status: err.status });
326
- }
327
- throw err;
328
- }
329
- }, _class);
330
- function extractReasoningContent(msg) {
331
- const candidate = _nullishCoalesce(msg.reasoning_content, () => ( msg.reasoning));
332
- return typeof candidate === "string" && candidate.length > 0 ? candidate : void 0;
333
- }
334
- function isDeepSeekThinkingModel(model) {
335
- return /^deepseek-v4(?:-|$)/i.test(model);
336
- }
337
-
338
-
339
-
340
- exports.OpenAIClient = OpenAIClient;
@@ -1,45 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
- }) : x)(function(x) {
8
- if (typeof require !== "undefined") return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
- var __esm = (fn, res) => function __init() {
12
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
- };
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
-
28
- // node_modules/.pnpm/tsup@8.5.1_postcss@8.5.8_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
29
- var getImportMetaUrl, importMetaUrl;
30
- var init_cjs_shims = __esm({
31
- "node_modules/.pnpm/tsup@8.5.1_postcss@8.5.8_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js"() {
32
- "use strict";
33
- getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
34
- importMetaUrl = exports.importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
35
- }
36
- });
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
- exports.__require = __require; exports.__esm = __esm; exports.__export = __export; exports.__toCommonJS = __toCommonJS; exports.importMetaUrl = importMetaUrl; exports.init_cjs_shims = init_cjs_shims;
@@ -1,50 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
- }) : x)(function(x) {
8
- if (typeof require !== "undefined") return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
10
- });
11
- var __esm = (fn, res) => function __init() {
12
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
- };
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
-
28
- // node_modules/.pnpm/tsup@8.5.1_postcss@8.5.8_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js
29
- import path from "path";
30
- import { fileURLToPath } from "url";
31
- var getFilename, getDirname, __dirname, __filename;
32
- var init_esm_shims = __esm({
33
- "node_modules/.pnpm/tsup@8.5.1_postcss@8.5.8_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js"() {
34
- "use strict";
35
- getFilename = () => fileURLToPath(import.meta.url);
36
- getDirname = () => path.dirname(getFilename());
37
- __dirname = /* @__PURE__ */ getDirname();
38
- __filename = /* @__PURE__ */ getFilename();
39
- }
40
- });
41
-
42
- export {
43
- __require,
44
- __esm,
45
- __export,
46
- __toCommonJS,
47
- __dirname,
48
- __filename,
49
- init_esm_shims
50
- };