@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.
- package/dist/anthropic-OVRWAZRD.js +1 -0
- package/dist/arena/index.js +1 -104
- package/dist/arena-64T2EQD4.js +3 -0
- package/dist/bwrap-PVZMLHZR.js +2 -0
- package/dist/chunk-2EUIMKJA.js +1 -0
- package/dist/chunk-2GJ7H5NC.js +641 -0
- package/dist/chunk-2OD6VR4N.js +2 -0
- package/dist/chunk-3QP5BQ3L.js +1 -0
- package/dist/chunk-A4M2Y42L.js +2 -0
- package/dist/chunk-DEYFK6FP.js +1 -0
- package/dist/chunk-DTPABBSV.js +2 -0
- package/dist/chunk-EU3J7TBP.js +1 -0
- package/dist/chunk-FU7AHZNN.js +1 -0
- package/dist/chunk-L7B2ORID.js +4 -0
- package/dist/chunk-M7VU4YVY.js +49 -0
- package/dist/chunk-MGP35GKD.js +254 -0
- package/dist/chunk-MLCTC53I.js +1 -0
- package/dist/chunk-O5HFCH2U.js +1 -0
- package/dist/chunk-P6JSTIFM.js +1 -0
- package/dist/chunk-Q3RSX66I.js +1 -0
- package/dist/chunk-QTWU7UNA.js +5 -0
- package/dist/chunk-RERBX75D.js +251 -0
- package/dist/chunk-SNFAPSLA.js +1 -0
- package/dist/chunk-T222K6IV.js +18 -0
- package/dist/chunk-TKJA6W36.js +3 -0
- package/dist/chunk-VKKU4LOM.js +3 -0
- package/dist/chunk-WI6FSWGU.js +1 -0
- package/dist/chunk-XXCZE2U2.js +2 -0
- package/dist/chunk-ZSAONDT6.js +2 -0
- package/dist/cli/main.js +303 -22060
- package/dist/cli/onboarding.d.ts +7 -2
- package/dist/client-base-F5FCRSB3.js +1 -0
- package/dist/compaction-L3Y6NG4N.js +1 -0
- package/dist/context/compaction.d.ts +2 -1
- package/dist/data/static-catalogs.d.ts +25 -0
- package/dist/devtools-SGDUOOM4.js +1 -0
- package/dist/engine/engine.d.ts +24 -0
- package/dist/engine/turn-loop.d.ts +20 -0
- package/dist/export-md-U72T7NW7.js +22 -0
- package/dist/file-history-7FQFEQOL.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -347
- package/dist/llm/capabilities/index.d.ts +20 -0
- package/dist/llm/capabilities/rules.d.ts +26 -0
- package/dist/llm/capabilities/types.d.ts +108 -0
- package/dist/llm/model-pool.d.ts +7 -0
- package/dist/llm/provider-catalog.d.ts +2 -0
- package/dist/llm/provider-kinds.d.ts +1 -1
- package/dist/llm/providers/openai.d.ts +22 -0
- package/dist/llm/token-counter.d.ts +17 -0
- package/dist/llm/types.d.ts +8 -0
- package/dist/logging/logger.d.ts +10 -2
- package/dist/logging/session-recorder.d.ts +16 -3
- package/dist/manager-J6FXEUEK.js +1 -0
- package/dist/mcp-manager-27EVBKRT.js +1 -0
- package/dist/memory-BNI4WEWL.js +1 -0
- package/dist/model-cache-HEDXI7UJ.js +1 -0
- package/dist/model-fetcher-X5W5EASG.js +1 -0
- package/dist/off-7SDVMMXW.js +1 -0
- package/dist/openai-3QEADSYL.js +1 -0
- package/dist/openrouter-models-GZVCRWD2.js +1 -0
- package/dist/openrouter-sync-WG4AG5NC.js +1 -0
- package/dist/product/index.js +1 -21
- package/dist/protocol/client.d.ts +1 -1
- package/dist/run/index.js +1 -48
- package/dist/seatbelt-L54CNI2Y.js +37 -0
- package/dist/session/session-manager.d.ts +2 -0
- package/dist/session-manager-AGWS5SMJ.js +1 -0
- package/dist/settings/schema.d.ts +147 -21
- package/dist/tool-summary-V2B3MD5N.js +2 -0
- package/dist/tool-system/builtin/bash.d.ts +7 -1
- package/dist/tool-system/context.d.ts +7 -0
- package/dist/tool-system/executor.d.ts +4 -0
- package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
- package/dist/tool-system/sandbox/index.d.ts +78 -0
- package/dist/tool-system/sandbox/off.d.ts +2 -0
- package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
- package/dist/tool-system/task-guard.d.ts +30 -0
- package/dist/types.d.ts +17 -0
- package/dist/ui/components/SessionPicker.d.ts +2 -0
- package/dist/ui/components/SpinnerWithVerb.d.ts +7 -2
- package/dist/ui/components/StatusLine.d.ts +7 -3
- package/dist/updater-OCNU2K2Z.js +1 -0
- package/package.json +7 -10
- package/dist/anthropic-IBTI4WL2.cjs +0 -10
- package/dist/anthropic-PRZZKHEZ.js +0 -10
- package/dist/arena/index.cjs +0 -104
- package/dist/arena-2LTLIXOL.js +0 -261
- package/dist/arena-ADB7DRFI.cjs +0 -261
- package/dist/chunk-2YW4FPFG.cjs +0 -101
- package/dist/chunk-3OA5G4TM.js +0 -47
- package/dist/chunk-3QO25N6E.js +0 -4711
- package/dist/chunk-3SBSUOWZ.js +0 -447
- package/dist/chunk-52LGZKT3.cjs +0 -47
- package/dist/chunk-55XGPMAP.cjs +0 -146
- package/dist/chunk-6QVAYW7C.cjs +0 -438
- package/dist/chunk-6S4BJ65N.js +0 -113
- package/dist/chunk-76HYEPDM.js +0 -307
- package/dist/chunk-7BI3V74Y.cjs +0 -447
- package/dist/chunk-7EG3V4JY.cjs +0 -113
- package/dist/chunk-7JVTYEEC.js +0 -340
- package/dist/chunk-7QIM3BKD.js +0 -44
- package/dist/chunk-7Y6S3OCX.js +0 -438
- package/dist/chunk-ABRRONJ7.js +0 -107
- package/dist/chunk-BSW22MPA.js +0 -146
- package/dist/chunk-BXCY2FSE.js +0 -203
- package/dist/chunk-BZ5TNE7L.js +0 -5128
- package/dist/chunk-DDB6QOKJ.cjs +0 -1252
- package/dist/chunk-HEKQCI7B.cjs +0 -224
- package/dist/chunk-IK4EWJBP.cjs +0 -203
- package/dist/chunk-ILHE7XLT.cjs +0 -107
- package/dist/chunk-JMR33QVF.cjs +0 -169
- package/dist/chunk-KAQHULYN.js +0 -54
- package/dist/chunk-KE4EQOWA.js +0 -294
- package/dist/chunk-KOVYSDHZ.cjs +0 -340
- package/dist/chunk-KS3RYAYL.cjs +0 -45
- package/dist/chunk-MD32R22I.js +0 -50
- package/dist/chunk-MV7YI4WO.cjs +0 -293
- package/dist/chunk-MY5XHADU.cjs +0 -216
- package/dist/chunk-NUNC3VFB.cjs +0 -307
- package/dist/chunk-PKGRTCCY.js +0 -9092
- package/dist/chunk-QARL3IDQ.js +0 -1252
- package/dist/chunk-S754JHLR.cjs +0 -54
- package/dist/chunk-SFXHZSRF.js +0 -101
- package/dist/chunk-SIHHIQLO.js +0 -224
- package/dist/chunk-T6VYG46N.js +0 -105
- package/dist/chunk-TNLGBJYS.cjs +0 -44
- package/dist/chunk-TUY2T5KP.cjs +0 -105
- package/dist/chunk-UXOCVJJ6.cjs +0 -9092
- package/dist/chunk-VIAGTYYW.js +0 -169
- package/dist/chunk-WASS5YWB.js +0 -215
- package/dist/chunk-WZJV6DJC.cjs +0 -5128
- package/dist/chunk-YIQBXAYU.cjs +0 -264
- package/dist/chunk-YKIAELDZ.cjs +0 -4711
- package/dist/chunk-ZBPSQCPU.js +0 -264
- package/dist/cli/main.cjs +0 -22156
- package/dist/client-base-HTF236ZD.cjs +0 -9
- package/dist/client-base-QKRKCOWB.js +0 -9
- package/dist/compaction-6VU2T643.js +0 -33
- package/dist/compaction-OKUNTCA7.cjs +0 -33
- package/dist/devtools-T2NIZBJK.cjs +0 -6
- package/dist/devtools-YXWHOVKR.js +0 -6
- package/dist/export-md-RXDW6F5W.cjs +0 -135
- package/dist/export-md-XXKZANW5.js +0 -135
- package/dist/file-history-KYPE3ECT.cjs +0 -7
- package/dist/file-history-LF4F7X26.js +0 -7
- package/dist/index.cjs +0 -347
- package/dist/manager-D65VFAPX.js +0 -7
- package/dist/manager-TTF5VHJC.cjs +0 -7
- package/dist/mcp-manager-QMKWPBZ4.js +0 -8
- package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
- package/dist/memory-5LWZ6FI2.cjs +0 -9
- package/dist/memory-VIJLBAMQ.js +0 -9
- package/dist/model-cache-5KIYL5SL.js +0 -13
- package/dist/model-cache-OED3IM4R.cjs +0 -13
- package/dist/model-fetcher-HKGICACL.js +0 -8
- package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
- package/dist/openai-JR2WEKOF.js +0 -10
- package/dist/openai-YBTOET4O.cjs +0 -10
- package/dist/openrouter-models-H56GHBHN.js +0 -15
- package/dist/openrouter-models-TWUFWZ5T.cjs +0 -15
- package/dist/openrouter-sync-5VMGN6C2.cjs +0 -11
- package/dist/openrouter-sync-ALEMF5IU.js +0 -11
- package/dist/product/index.cjs +0 -21
- package/dist/run/index.cjs +0 -48
- package/dist/session-manager-Q22BBMD3.js +0 -8
- package/dist/session-manager-XODQVL3C.cjs +0 -8
- package/dist/tool-summary-63DPIS7G.cjs +0 -31
- package/dist/tool-summary-NP5CDBKG.js +0 -31
- package/dist/updater-I7QBW4DP.cjs +0 -17
- package/dist/updater-NVME5S3Z.js +0 -17
package/dist/chunk-YIQBXAYU.cjs
DELETED
|
@@ -1,264 +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/anthropic.ts
|
|
17
|
-
_chunkKS3RYAYLcjs.init_cjs_shims.call(void 0, );
|
|
18
|
-
var _sdk = require('@anthropic-ai/sdk'); var _sdk2 = _interopRequireDefault(_sdk);
|
|
19
|
-
var AnthropicClient = (_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, _sdk2.default)({
|
|
29
|
-
apiKey: _nullishCoalesce(this.config.apiKey, () => ( process.env.ANTHROPIC_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.messages);
|
|
39
|
-
const tools = options.tools ? 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', _ => _.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', _2 => _2.usage, 'optionalAccess', _3 => _3.promptTokens]),
|
|
53
|
-
completionTokens: _optionalChain([response, 'access', _4 => _4.usage, 'optionalAccess', _5 => _5.completionTokens]),
|
|
54
|
-
cacheReadTokens: _optionalChain([response, 'access', _6 => _6.usage, 'optionalAccess', _7 => _7.cacheReadTokens]),
|
|
55
|
-
cacheCreationTokens: _optionalChain([response, 'access', _8 => _8.usage, 'optionalAccess', _9 => _9.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.messages.create(
|
|
67
|
-
{
|
|
68
|
-
model: this.model,
|
|
69
|
-
max_tokens: _nullishCoalesce(options.maxTokens, () => ( this.maxTokens)),
|
|
70
|
-
system: [
|
|
71
|
-
{
|
|
72
|
-
type: "text",
|
|
73
|
-
text: options.systemPrompt,
|
|
74
|
-
cache_control: { type: "ephemeral" }
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
messages,
|
|
78
|
-
..._optionalChain([tools, 'optionalAccess', _10 => _10.length]) ? { tools } : {},
|
|
79
|
-
...options.temperature !== void 0 ? { temperature: options.temperature } : { temperature: this.temperature }
|
|
80
|
-
},
|
|
81
|
-
{ signal: options.signal }
|
|
82
|
-
);
|
|
83
|
-
const usage = {
|
|
84
|
-
promptTokens: response.usage.input_tokens,
|
|
85
|
-
completionTokens: response.usage.output_tokens,
|
|
86
|
-
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
87
|
-
cacheReadTokens: response.usage.cache_read_input_tokens,
|
|
88
|
-
cacheCreationTokens: response.usage.cache_creation_input_tokens
|
|
89
|
-
};
|
|
90
|
-
this.recordUsage(usage, options);
|
|
91
|
-
return this.processResponse(response, usage);
|
|
92
|
-
} catch (err) {
|
|
93
|
-
this.handleApiError(err);
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async streamMessage(options, messages, tools) {
|
|
98
|
-
try {
|
|
99
|
-
const stream = this.client.messages.stream(
|
|
100
|
-
{
|
|
101
|
-
model: this.model,
|
|
102
|
-
max_tokens: _nullishCoalesce(options.maxTokens, () => ( this.maxTokens)),
|
|
103
|
-
system: [
|
|
104
|
-
{
|
|
105
|
-
type: "text",
|
|
106
|
-
text: options.systemPrompt,
|
|
107
|
-
cache_control: { type: "ephemeral" }
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
messages,
|
|
111
|
-
..._optionalChain([tools, 'optionalAccess', _11 => _11.length]) ? { tools } : {},
|
|
112
|
-
...options.temperature !== void 0 ? { temperature: options.temperature } : { temperature: this.temperature }
|
|
113
|
-
},
|
|
114
|
-
{ signal: options.signal }
|
|
115
|
-
);
|
|
116
|
-
let currentText = "";
|
|
117
|
-
let currentToolName = "";
|
|
118
|
-
let currentToolId = "";
|
|
119
|
-
let currentToolInput = "";
|
|
120
|
-
const streamStartedAt = Date.now();
|
|
121
|
-
let firstByteLogged = false;
|
|
122
|
-
stream.on("text", (text) => {
|
|
123
|
-
if (!firstByteLogged) {
|
|
124
|
-
firstByteLogged = true;
|
|
125
|
-
_chunkIK4EWJBPcjs.logger.debug("llm.first_byte", {
|
|
126
|
-
cat: "llm",
|
|
127
|
-
provider: this.provider,
|
|
128
|
-
model: this.model,
|
|
129
|
-
ttft_ms: Date.now() - streamStartedAt
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
currentText += text;
|
|
133
|
-
_optionalChain([options, 'access', _12 => _12.onChunk, 'optionalCall', _13 => _13({ type: "text", text })]);
|
|
134
|
-
});
|
|
135
|
-
stream.on("contentBlock", (block) => {
|
|
136
|
-
if (block.type === "tool_use") {
|
|
137
|
-
currentToolName = block.name;
|
|
138
|
-
currentToolId = block.id;
|
|
139
|
-
currentToolInput = "";
|
|
140
|
-
_optionalChain([options, 'access', _14 => _14.onChunk, 'optionalCall', _15 => _15({
|
|
141
|
-
type: "tool_use_start",
|
|
142
|
-
toolCall: { id: block.id, toolName: block.name, args: {} }
|
|
143
|
-
})]);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
stream.on("inputJson", (_delta, snapshot) => {
|
|
147
|
-
currentToolInput = JSON.stringify(snapshot);
|
|
148
|
-
if (currentToolId) {
|
|
149
|
-
_optionalChain([options, 'access', _16 => _16.onChunk, 'optionalCall', _17 => _17({
|
|
150
|
-
type: "tool_use_delta",
|
|
151
|
-
toolCall: {
|
|
152
|
-
id: currentToolId,
|
|
153
|
-
toolName: currentToolName,
|
|
154
|
-
args: _nullishCoalesce(snapshot, () => ( {}))
|
|
155
|
-
}
|
|
156
|
-
})]);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
const finalMessage = await stream.finalMessage();
|
|
160
|
-
const usage = {
|
|
161
|
-
promptTokens: finalMessage.usage.input_tokens,
|
|
162
|
-
completionTokens: finalMessage.usage.output_tokens,
|
|
163
|
-
totalTokens: finalMessage.usage.input_tokens + finalMessage.usage.output_tokens,
|
|
164
|
-
cacheReadTokens: finalMessage.usage.cache_read_input_tokens,
|
|
165
|
-
cacheCreationTokens: finalMessage.usage.cache_creation_input_tokens
|
|
166
|
-
};
|
|
167
|
-
this.recordUsage(usage, options);
|
|
168
|
-
_optionalChain([options, 'access', _18 => _18.onChunk, 'optionalCall', _19 => _19({ type: "stop", stopReason: _nullishCoalesce(finalMessage.stop_reason, () => ( void 0)) })]);
|
|
169
|
-
return this.processResponse(finalMessage, usage);
|
|
170
|
-
} catch (err) {
|
|
171
|
-
this.handleApiError(err);
|
|
172
|
-
throw err;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
processResponse(response, usage) {
|
|
176
|
-
let text = "";
|
|
177
|
-
const toolCalls = [];
|
|
178
|
-
for (const block of response.content) {
|
|
179
|
-
if (block.type === "text") {
|
|
180
|
-
text += block.text;
|
|
181
|
-
} else if (block.type === "tool_use") {
|
|
182
|
-
toolCalls.push({
|
|
183
|
-
id: block.id,
|
|
184
|
-
toolName: block.name,
|
|
185
|
-
args: _nullishCoalesce(block.input, () => ( {}))
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
text,
|
|
191
|
-
toolCalls,
|
|
192
|
-
usage,
|
|
193
|
-
stopReason: _nullishCoalesce(response.stop_reason, () => ( void 0))
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
buildMessages(messages) {
|
|
197
|
-
const result = [];
|
|
198
|
-
for (const msg of messages) {
|
|
199
|
-
if (msg.role === "system") continue;
|
|
200
|
-
const role = msg.role === "tool" ? "user" : msg.role;
|
|
201
|
-
if (typeof msg.content === "string") {
|
|
202
|
-
result.push({ role, content: msg.content });
|
|
203
|
-
} else {
|
|
204
|
-
const blocks = [];
|
|
205
|
-
for (const block of msg.content) {
|
|
206
|
-
if (block.type === "text" && block.text) {
|
|
207
|
-
blocks.push({ type: "text", text: block.text });
|
|
208
|
-
} else if (block.type === "tool_use" && block.id && block.name && block.input) {
|
|
209
|
-
blocks.push({
|
|
210
|
-
type: "tool_use",
|
|
211
|
-
id: block.id,
|
|
212
|
-
name: block.name,
|
|
213
|
-
input: block.input
|
|
214
|
-
});
|
|
215
|
-
} else if (block.type === "tool_result" && block.tool_use_id) {
|
|
216
|
-
blocks.push({
|
|
217
|
-
type: "tool_result",
|
|
218
|
-
tool_use_id: block.tool_use_id,
|
|
219
|
-
content: typeof block.content === "string" ? block.content : ""
|
|
220
|
-
});
|
|
221
|
-
} else if (block.type === "image" && block.source) {
|
|
222
|
-
blocks.push({
|
|
223
|
-
type: "image",
|
|
224
|
-
source: {
|
|
225
|
-
type: "base64",
|
|
226
|
-
media_type: block.source.media_type,
|
|
227
|
-
data: block.source.data
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
if (blocks.length > 0) {
|
|
233
|
-
result.push({ role, content: blocks });
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return result;
|
|
238
|
-
}
|
|
239
|
-
convertTools(tools) {
|
|
240
|
-
return tools.map((t) => ({
|
|
241
|
-
name: t.name,
|
|
242
|
-
description: t.description,
|
|
243
|
-
input_schema: t.inputSchema
|
|
244
|
-
}));
|
|
245
|
-
}
|
|
246
|
-
handleApiError(err) {
|
|
247
|
-
if (err instanceof _sdk2.default.APIError) {
|
|
248
|
-
if (err.status === 429) {
|
|
249
|
-
throw new (0, _chunk2YW4FPFGcjs.LLMRateLimitError)("anthropic");
|
|
250
|
-
}
|
|
251
|
-
if (_optionalChain([err, 'access', _20 => _20.message, 'optionalAccess', _21 => _21.includes, 'call', _22 => _22("prompt is too long")]) || _optionalChain([err, 'access', _23 => _23.message, 'optionalAccess', _24 => _24.includes, 'call', _25 => _25("context_length_exceeded")])) {
|
|
252
|
-
throw new (0, _chunk2YW4FPFGcjs.ContextLimitError)("anthropic");
|
|
253
|
-
}
|
|
254
|
-
throw new (0, _chunk2YW4FPFGcjs.LLMError)(`Anthropic API error: ${err.message}`, "anthropic", {
|
|
255
|
-
status: err.status
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
throw err;
|
|
259
|
-
}
|
|
260
|
-
}, _class);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
exports.AnthropicClient = AnthropicClient;
|