aieo 0.1.17 → 0.1.19
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/index.cjs +8 -2144
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -2142
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3387,7 +3387,7 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
|
3387
3387
|
allOf,
|
|
3388
3388
|
anyOf,
|
|
3389
3389
|
oneOf,
|
|
3390
|
-
format
|
|
3390
|
+
format,
|
|
3391
3391
|
const: constValue,
|
|
3392
3392
|
minLength,
|
|
3393
3393
|
enum: enumValues
|
|
@@ -3397,8 +3397,8 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
|
3397
3397
|
result.description = description;
|
|
3398
3398
|
if (required)
|
|
3399
3399
|
result.required = required;
|
|
3400
|
-
if (
|
|
3401
|
-
result.format =
|
|
3400
|
+
if (format)
|
|
3401
|
+
result.format = format;
|
|
3402
3402
|
if (constValue !== void 0) {
|
|
3403
3403
|
result.enum = [constValue];
|
|
3404
3404
|
}
|
|
@@ -8181,2147 +8181,8 @@ function createOpenAI(options = {}) {
|
|
|
8181
8181
|
}
|
|
8182
8182
|
var openai = createOpenAI();
|
|
8183
8183
|
|
|
8184
|
-
// node_modules/ai-sdk-provider-claude-code/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
8185
|
-
var z45 = __toESM(require("zod/v4"), 1);
|
|
8186
|
-
var createIdGenerator2 = ({
|
|
8187
|
-
prefix,
|
|
8188
|
-
size = 16,
|
|
8189
|
-
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
8190
|
-
separator = "-"
|
|
8191
|
-
} = {}) => {
|
|
8192
|
-
const generator = () => {
|
|
8193
|
-
const alphabetLength = alphabet.length;
|
|
8194
|
-
const chars = new Array(size);
|
|
8195
|
-
for (let i = 0; i < size; i++) {
|
|
8196
|
-
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
8197
|
-
}
|
|
8198
|
-
return chars.join("");
|
|
8199
|
-
};
|
|
8200
|
-
if (prefix == null) {
|
|
8201
|
-
return generator;
|
|
8202
|
-
}
|
|
8203
|
-
if (alphabet.includes(separator)) {
|
|
8204
|
-
throw new InvalidArgumentError({
|
|
8205
|
-
argument: "separator",
|
|
8206
|
-
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
8207
|
-
});
|
|
8208
|
-
}
|
|
8209
|
-
return () => `${prefix}${separator}${generator()}`;
|
|
8210
|
-
};
|
|
8211
|
-
var generateId2 = createIdGenerator2();
|
|
8212
|
-
var validatorSymbol2 = Symbol.for("vercel.ai.validator");
|
|
8213
|
-
var schemaSymbol2 = Symbol.for("vercel.ai.schema");
|
|
8214
|
-
var { btoa: btoa2, atob: atob2 } = globalThis;
|
|
8215
|
-
|
|
8216
|
-
// node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
8217
|
-
function createScanner(text, ignoreTrivia = false) {
|
|
8218
|
-
const len = text.length;
|
|
8219
|
-
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
8220
|
-
function scanHexDigits(count, exact) {
|
|
8221
|
-
let digits = 0;
|
|
8222
|
-
let value2 = 0;
|
|
8223
|
-
while (digits < count || !exact) {
|
|
8224
|
-
let ch = text.charCodeAt(pos);
|
|
8225
|
-
if (ch >= 48 && ch <= 57) {
|
|
8226
|
-
value2 = value2 * 16 + ch - 48;
|
|
8227
|
-
} else if (ch >= 65 && ch <= 70) {
|
|
8228
|
-
value2 = value2 * 16 + ch - 65 + 10;
|
|
8229
|
-
} else if (ch >= 97 && ch <= 102) {
|
|
8230
|
-
value2 = value2 * 16 + ch - 97 + 10;
|
|
8231
|
-
} else {
|
|
8232
|
-
break;
|
|
8233
|
-
}
|
|
8234
|
-
pos++;
|
|
8235
|
-
digits++;
|
|
8236
|
-
}
|
|
8237
|
-
if (digits < count) {
|
|
8238
|
-
value2 = -1;
|
|
8239
|
-
}
|
|
8240
|
-
return value2;
|
|
8241
|
-
}
|
|
8242
|
-
function setPosition(newPosition) {
|
|
8243
|
-
pos = newPosition;
|
|
8244
|
-
value = "";
|
|
8245
|
-
tokenOffset = 0;
|
|
8246
|
-
token = 16;
|
|
8247
|
-
scanError = 0;
|
|
8248
|
-
}
|
|
8249
|
-
function scanNumber() {
|
|
8250
|
-
let start = pos;
|
|
8251
|
-
if (text.charCodeAt(pos) === 48) {
|
|
8252
|
-
pos++;
|
|
8253
|
-
} else {
|
|
8254
|
-
pos++;
|
|
8255
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
8256
|
-
pos++;
|
|
8257
|
-
}
|
|
8258
|
-
}
|
|
8259
|
-
if (pos < text.length && text.charCodeAt(pos) === 46) {
|
|
8260
|
-
pos++;
|
|
8261
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
8262
|
-
pos++;
|
|
8263
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
8264
|
-
pos++;
|
|
8265
|
-
}
|
|
8266
|
-
} else {
|
|
8267
|
-
scanError = 3;
|
|
8268
|
-
return text.substring(start, pos);
|
|
8269
|
-
}
|
|
8270
|
-
}
|
|
8271
|
-
let end = pos;
|
|
8272
|
-
if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
8273
|
-
pos++;
|
|
8274
|
-
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
|
|
8275
|
-
pos++;
|
|
8276
|
-
}
|
|
8277
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
8278
|
-
pos++;
|
|
8279
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
8280
|
-
pos++;
|
|
8281
|
-
}
|
|
8282
|
-
end = pos;
|
|
8283
|
-
} else {
|
|
8284
|
-
scanError = 3;
|
|
8285
|
-
}
|
|
8286
|
-
}
|
|
8287
|
-
return text.substring(start, end);
|
|
8288
|
-
}
|
|
8289
|
-
function scanString() {
|
|
8290
|
-
let result = "", start = pos;
|
|
8291
|
-
while (true) {
|
|
8292
|
-
if (pos >= len) {
|
|
8293
|
-
result += text.substring(start, pos);
|
|
8294
|
-
scanError = 2;
|
|
8295
|
-
break;
|
|
8296
|
-
}
|
|
8297
|
-
const ch = text.charCodeAt(pos);
|
|
8298
|
-
if (ch === 34) {
|
|
8299
|
-
result += text.substring(start, pos);
|
|
8300
|
-
pos++;
|
|
8301
|
-
break;
|
|
8302
|
-
}
|
|
8303
|
-
if (ch === 92) {
|
|
8304
|
-
result += text.substring(start, pos);
|
|
8305
|
-
pos++;
|
|
8306
|
-
if (pos >= len) {
|
|
8307
|
-
scanError = 2;
|
|
8308
|
-
break;
|
|
8309
|
-
}
|
|
8310
|
-
const ch2 = text.charCodeAt(pos++);
|
|
8311
|
-
switch (ch2) {
|
|
8312
|
-
case 34:
|
|
8313
|
-
result += '"';
|
|
8314
|
-
break;
|
|
8315
|
-
case 92:
|
|
8316
|
-
result += "\\";
|
|
8317
|
-
break;
|
|
8318
|
-
case 47:
|
|
8319
|
-
result += "/";
|
|
8320
|
-
break;
|
|
8321
|
-
case 98:
|
|
8322
|
-
result += "\b";
|
|
8323
|
-
break;
|
|
8324
|
-
case 102:
|
|
8325
|
-
result += "\f";
|
|
8326
|
-
break;
|
|
8327
|
-
case 110:
|
|
8328
|
-
result += "\n";
|
|
8329
|
-
break;
|
|
8330
|
-
case 114:
|
|
8331
|
-
result += "\r";
|
|
8332
|
-
break;
|
|
8333
|
-
case 116:
|
|
8334
|
-
result += " ";
|
|
8335
|
-
break;
|
|
8336
|
-
case 117:
|
|
8337
|
-
const ch3 = scanHexDigits(4, true);
|
|
8338
|
-
if (ch3 >= 0) {
|
|
8339
|
-
result += String.fromCharCode(ch3);
|
|
8340
|
-
} else {
|
|
8341
|
-
scanError = 4;
|
|
8342
|
-
}
|
|
8343
|
-
break;
|
|
8344
|
-
default:
|
|
8345
|
-
scanError = 5;
|
|
8346
|
-
}
|
|
8347
|
-
start = pos;
|
|
8348
|
-
continue;
|
|
8349
|
-
}
|
|
8350
|
-
if (ch >= 0 && ch <= 31) {
|
|
8351
|
-
if (isLineBreak(ch)) {
|
|
8352
|
-
result += text.substring(start, pos);
|
|
8353
|
-
scanError = 2;
|
|
8354
|
-
break;
|
|
8355
|
-
} else {
|
|
8356
|
-
scanError = 6;
|
|
8357
|
-
}
|
|
8358
|
-
}
|
|
8359
|
-
pos++;
|
|
8360
|
-
}
|
|
8361
|
-
return result;
|
|
8362
|
-
}
|
|
8363
|
-
function scanNext() {
|
|
8364
|
-
value = "";
|
|
8365
|
-
scanError = 0;
|
|
8366
|
-
tokenOffset = pos;
|
|
8367
|
-
lineStartOffset = lineNumber;
|
|
8368
|
-
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
8369
|
-
if (pos >= len) {
|
|
8370
|
-
tokenOffset = len;
|
|
8371
|
-
return token = 17;
|
|
8372
|
-
}
|
|
8373
|
-
let code = text.charCodeAt(pos);
|
|
8374
|
-
if (isWhiteSpace(code)) {
|
|
8375
|
-
do {
|
|
8376
|
-
pos++;
|
|
8377
|
-
value += String.fromCharCode(code);
|
|
8378
|
-
code = text.charCodeAt(pos);
|
|
8379
|
-
} while (isWhiteSpace(code));
|
|
8380
|
-
return token = 15;
|
|
8381
|
-
}
|
|
8382
|
-
if (isLineBreak(code)) {
|
|
8383
|
-
pos++;
|
|
8384
|
-
value += String.fromCharCode(code);
|
|
8385
|
-
if (code === 13 && text.charCodeAt(pos) === 10) {
|
|
8386
|
-
pos++;
|
|
8387
|
-
value += "\n";
|
|
8388
|
-
}
|
|
8389
|
-
lineNumber++;
|
|
8390
|
-
tokenLineStartOffset = pos;
|
|
8391
|
-
return token = 14;
|
|
8392
|
-
}
|
|
8393
|
-
switch (code) {
|
|
8394
|
-
// tokens: []{}:,
|
|
8395
|
-
case 123:
|
|
8396
|
-
pos++;
|
|
8397
|
-
return token = 1;
|
|
8398
|
-
case 125:
|
|
8399
|
-
pos++;
|
|
8400
|
-
return token = 2;
|
|
8401
|
-
case 91:
|
|
8402
|
-
pos++;
|
|
8403
|
-
return token = 3;
|
|
8404
|
-
case 93:
|
|
8405
|
-
pos++;
|
|
8406
|
-
return token = 4;
|
|
8407
|
-
case 58:
|
|
8408
|
-
pos++;
|
|
8409
|
-
return token = 6;
|
|
8410
|
-
case 44:
|
|
8411
|
-
pos++;
|
|
8412
|
-
return token = 5;
|
|
8413
|
-
// strings
|
|
8414
|
-
case 34:
|
|
8415
|
-
pos++;
|
|
8416
|
-
value = scanString();
|
|
8417
|
-
return token = 10;
|
|
8418
|
-
// comments
|
|
8419
|
-
case 47:
|
|
8420
|
-
const start = pos - 1;
|
|
8421
|
-
if (text.charCodeAt(pos + 1) === 47) {
|
|
8422
|
-
pos += 2;
|
|
8423
|
-
while (pos < len) {
|
|
8424
|
-
if (isLineBreak(text.charCodeAt(pos))) {
|
|
8425
|
-
break;
|
|
8426
|
-
}
|
|
8427
|
-
pos++;
|
|
8428
|
-
}
|
|
8429
|
-
value = text.substring(start, pos);
|
|
8430
|
-
return token = 12;
|
|
8431
|
-
}
|
|
8432
|
-
if (text.charCodeAt(pos + 1) === 42) {
|
|
8433
|
-
pos += 2;
|
|
8434
|
-
const safeLength = len - 1;
|
|
8435
|
-
let commentClosed = false;
|
|
8436
|
-
while (pos < safeLength) {
|
|
8437
|
-
const ch = text.charCodeAt(pos);
|
|
8438
|
-
if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
8439
|
-
pos += 2;
|
|
8440
|
-
commentClosed = true;
|
|
8441
|
-
break;
|
|
8442
|
-
}
|
|
8443
|
-
pos++;
|
|
8444
|
-
if (isLineBreak(ch)) {
|
|
8445
|
-
if (ch === 13 && text.charCodeAt(pos) === 10) {
|
|
8446
|
-
pos++;
|
|
8447
|
-
}
|
|
8448
|
-
lineNumber++;
|
|
8449
|
-
tokenLineStartOffset = pos;
|
|
8450
|
-
}
|
|
8451
|
-
}
|
|
8452
|
-
if (!commentClosed) {
|
|
8453
|
-
pos++;
|
|
8454
|
-
scanError = 1;
|
|
8455
|
-
}
|
|
8456
|
-
value = text.substring(start, pos);
|
|
8457
|
-
return token = 13;
|
|
8458
|
-
}
|
|
8459
|
-
value += String.fromCharCode(code);
|
|
8460
|
-
pos++;
|
|
8461
|
-
return token = 16;
|
|
8462
|
-
// numbers
|
|
8463
|
-
case 45:
|
|
8464
|
-
value += String.fromCharCode(code);
|
|
8465
|
-
pos++;
|
|
8466
|
-
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
8467
|
-
return token = 16;
|
|
8468
|
-
}
|
|
8469
|
-
// found a minus, followed by a number so
|
|
8470
|
-
// we fall through to proceed with scanning
|
|
8471
|
-
// numbers
|
|
8472
|
-
case 48:
|
|
8473
|
-
case 49:
|
|
8474
|
-
case 50:
|
|
8475
|
-
case 51:
|
|
8476
|
-
case 52:
|
|
8477
|
-
case 53:
|
|
8478
|
-
case 54:
|
|
8479
|
-
case 55:
|
|
8480
|
-
case 56:
|
|
8481
|
-
case 57:
|
|
8482
|
-
value += scanNumber();
|
|
8483
|
-
return token = 11;
|
|
8484
|
-
// literals and unknown symbols
|
|
8485
|
-
default:
|
|
8486
|
-
while (pos < len && isUnknownContentCharacter(code)) {
|
|
8487
|
-
pos++;
|
|
8488
|
-
code = text.charCodeAt(pos);
|
|
8489
|
-
}
|
|
8490
|
-
if (tokenOffset !== pos) {
|
|
8491
|
-
value = text.substring(tokenOffset, pos);
|
|
8492
|
-
switch (value) {
|
|
8493
|
-
case "true":
|
|
8494
|
-
return token = 8;
|
|
8495
|
-
case "false":
|
|
8496
|
-
return token = 9;
|
|
8497
|
-
case "null":
|
|
8498
|
-
return token = 7;
|
|
8499
|
-
}
|
|
8500
|
-
return token = 16;
|
|
8501
|
-
}
|
|
8502
|
-
value += String.fromCharCode(code);
|
|
8503
|
-
pos++;
|
|
8504
|
-
return token = 16;
|
|
8505
|
-
}
|
|
8506
|
-
}
|
|
8507
|
-
function isUnknownContentCharacter(code) {
|
|
8508
|
-
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
8509
|
-
return false;
|
|
8510
|
-
}
|
|
8511
|
-
switch (code) {
|
|
8512
|
-
case 125:
|
|
8513
|
-
case 93:
|
|
8514
|
-
case 123:
|
|
8515
|
-
case 91:
|
|
8516
|
-
case 34:
|
|
8517
|
-
case 58:
|
|
8518
|
-
case 44:
|
|
8519
|
-
case 47:
|
|
8520
|
-
return false;
|
|
8521
|
-
}
|
|
8522
|
-
return true;
|
|
8523
|
-
}
|
|
8524
|
-
function scanNextNonTrivia() {
|
|
8525
|
-
let result;
|
|
8526
|
-
do {
|
|
8527
|
-
result = scanNext();
|
|
8528
|
-
} while (result >= 12 && result <= 15);
|
|
8529
|
-
return result;
|
|
8530
|
-
}
|
|
8531
|
-
return {
|
|
8532
|
-
setPosition,
|
|
8533
|
-
getPosition: () => pos,
|
|
8534
|
-
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
8535
|
-
getToken: () => token,
|
|
8536
|
-
getTokenValue: () => value,
|
|
8537
|
-
getTokenOffset: () => tokenOffset,
|
|
8538
|
-
getTokenLength: () => pos - tokenOffset,
|
|
8539
|
-
getTokenStartLine: () => lineStartOffset,
|
|
8540
|
-
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
8541
|
-
getTokenError: () => scanError
|
|
8542
|
-
};
|
|
8543
|
-
}
|
|
8544
|
-
function isWhiteSpace(ch) {
|
|
8545
|
-
return ch === 32 || ch === 9;
|
|
8546
|
-
}
|
|
8547
|
-
function isLineBreak(ch) {
|
|
8548
|
-
return ch === 10 || ch === 13;
|
|
8549
|
-
}
|
|
8550
|
-
function isDigit(ch) {
|
|
8551
|
-
return ch >= 48 && ch <= 57;
|
|
8552
|
-
}
|
|
8553
|
-
var CharacterCodes;
|
|
8554
|
-
(function(CharacterCodes2) {
|
|
8555
|
-
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
8556
|
-
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
8557
|
-
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
8558
|
-
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
8559
|
-
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
8560
|
-
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
8561
|
-
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
8562
|
-
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
8563
|
-
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
8564
|
-
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
8565
|
-
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
8566
|
-
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
8567
|
-
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
8568
|
-
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
8569
|
-
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
8570
|
-
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
8571
|
-
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
8572
|
-
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
8573
|
-
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
8574
|
-
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
8575
|
-
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
8576
|
-
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
8577
|
-
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
8578
|
-
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
8579
|
-
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
8580
|
-
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
8581
|
-
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
8582
|
-
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
8583
|
-
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
8584
|
-
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
8585
|
-
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
8586
|
-
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
8587
|
-
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
8588
|
-
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
8589
|
-
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
8590
|
-
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
8591
|
-
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
8592
|
-
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
8593
|
-
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
8594
|
-
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
8595
|
-
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
8596
|
-
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
8597
|
-
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
8598
|
-
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
8599
|
-
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
8600
|
-
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
8601
|
-
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
8602
|
-
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
8603
|
-
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
8604
|
-
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
8605
|
-
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
8606
|
-
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
8607
|
-
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
8608
|
-
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
8609
|
-
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
8610
|
-
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
8611
|
-
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
8612
|
-
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
8613
|
-
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
8614
|
-
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
8615
|
-
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
8616
|
-
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
8617
|
-
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
8618
|
-
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
8619
|
-
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
8620
|
-
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
8621
|
-
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
8622
|
-
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
8623
|
-
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
8624
|
-
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
8625
|
-
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
8626
|
-
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
8627
|
-
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
8628
|
-
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
8629
|
-
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
8630
|
-
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
8631
|
-
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
8632
|
-
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
8633
|
-
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
8634
|
-
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
8635
|
-
})(CharacterCodes || (CharacterCodes = {}));
|
|
8636
|
-
|
|
8637
|
-
// node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
8638
|
-
var cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
8639
|
-
return " ".repeat(index);
|
|
8640
|
-
});
|
|
8641
|
-
var maxCachedValues = 200;
|
|
8642
|
-
var cachedBreakLinesWithSpaces = {
|
|
8643
|
-
" ": {
|
|
8644
|
-
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8645
|
-
return "\n" + " ".repeat(index);
|
|
8646
|
-
}),
|
|
8647
|
-
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8648
|
-
return "\r" + " ".repeat(index);
|
|
8649
|
-
}),
|
|
8650
|
-
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8651
|
-
return "\r\n" + " ".repeat(index);
|
|
8652
|
-
})
|
|
8653
|
-
},
|
|
8654
|
-
" ": {
|
|
8655
|
-
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8656
|
-
return "\n" + " ".repeat(index);
|
|
8657
|
-
}),
|
|
8658
|
-
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8659
|
-
return "\r" + " ".repeat(index);
|
|
8660
|
-
}),
|
|
8661
|
-
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
8662
|
-
return "\r\n" + " ".repeat(index);
|
|
8663
|
-
})
|
|
8664
|
-
}
|
|
8665
|
-
};
|
|
8666
|
-
|
|
8667
|
-
// node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
8668
|
-
var ParseOptions;
|
|
8669
|
-
(function(ParseOptions2) {
|
|
8670
|
-
ParseOptions2.DEFAULT = {
|
|
8671
|
-
allowTrailingComma: false
|
|
8672
|
-
};
|
|
8673
|
-
})(ParseOptions || (ParseOptions = {}));
|
|
8674
|
-
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
8675
|
-
let currentProperty = null;
|
|
8676
|
-
let currentParent = [];
|
|
8677
|
-
const previousParents = [];
|
|
8678
|
-
function onValue(value) {
|
|
8679
|
-
if (Array.isArray(currentParent)) {
|
|
8680
|
-
currentParent.push(value);
|
|
8681
|
-
} else if (currentProperty !== null) {
|
|
8682
|
-
currentParent[currentProperty] = value;
|
|
8683
|
-
}
|
|
8684
|
-
}
|
|
8685
|
-
const visitor = {
|
|
8686
|
-
onObjectBegin: () => {
|
|
8687
|
-
const object = {};
|
|
8688
|
-
onValue(object);
|
|
8689
|
-
previousParents.push(currentParent);
|
|
8690
|
-
currentParent = object;
|
|
8691
|
-
currentProperty = null;
|
|
8692
|
-
},
|
|
8693
|
-
onObjectProperty: (name14) => {
|
|
8694
|
-
currentProperty = name14;
|
|
8695
|
-
},
|
|
8696
|
-
onObjectEnd: () => {
|
|
8697
|
-
currentParent = previousParents.pop();
|
|
8698
|
-
},
|
|
8699
|
-
onArrayBegin: () => {
|
|
8700
|
-
const array = [];
|
|
8701
|
-
onValue(array);
|
|
8702
|
-
previousParents.push(currentParent);
|
|
8703
|
-
currentParent = array;
|
|
8704
|
-
currentProperty = null;
|
|
8705
|
-
},
|
|
8706
|
-
onArrayEnd: () => {
|
|
8707
|
-
currentParent = previousParents.pop();
|
|
8708
|
-
},
|
|
8709
|
-
onLiteralValue: onValue,
|
|
8710
|
-
onError: (error, offset, length) => {
|
|
8711
|
-
errors.push({ error, offset, length });
|
|
8712
|
-
}
|
|
8713
|
-
};
|
|
8714
|
-
visit(text, visitor, options);
|
|
8715
|
-
return currentParent[0];
|
|
8716
|
-
}
|
|
8717
|
-
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
8718
|
-
const _scanner = createScanner(text, false);
|
|
8719
|
-
const _jsonPath = [];
|
|
8720
|
-
let suppressedCallbacks = 0;
|
|
8721
|
-
function toNoArgVisit(visitFunction) {
|
|
8722
|
-
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
8723
|
-
}
|
|
8724
|
-
function toOneArgVisit(visitFunction) {
|
|
8725
|
-
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
8726
|
-
}
|
|
8727
|
-
function toOneArgVisitWithPath(visitFunction) {
|
|
8728
|
-
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
8729
|
-
}
|
|
8730
|
-
function toBeginVisit(visitFunction) {
|
|
8731
|
-
return visitFunction ? () => {
|
|
8732
|
-
if (suppressedCallbacks > 0) {
|
|
8733
|
-
suppressedCallbacks++;
|
|
8734
|
-
} else {
|
|
8735
|
-
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
8736
|
-
if (cbReturn === false) {
|
|
8737
|
-
suppressedCallbacks = 1;
|
|
8738
|
-
}
|
|
8739
|
-
}
|
|
8740
|
-
} : () => true;
|
|
8741
|
-
}
|
|
8742
|
-
function toEndVisit(visitFunction) {
|
|
8743
|
-
return visitFunction ? () => {
|
|
8744
|
-
if (suppressedCallbacks > 0) {
|
|
8745
|
-
suppressedCallbacks--;
|
|
8746
|
-
}
|
|
8747
|
-
if (suppressedCallbacks === 0) {
|
|
8748
|
-
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
8749
|
-
}
|
|
8750
|
-
} : () => true;
|
|
8751
|
-
}
|
|
8752
|
-
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
8753
|
-
const disallowComments = options && options.disallowComments;
|
|
8754
|
-
const allowTrailingComma = options && options.allowTrailingComma;
|
|
8755
|
-
function scanNext() {
|
|
8756
|
-
while (true) {
|
|
8757
|
-
const token = _scanner.scan();
|
|
8758
|
-
switch (_scanner.getTokenError()) {
|
|
8759
|
-
case 4:
|
|
8760
|
-
handleError(
|
|
8761
|
-
14
|
|
8762
|
-
/* ParseErrorCode.InvalidUnicode */
|
|
8763
|
-
);
|
|
8764
|
-
break;
|
|
8765
|
-
case 5:
|
|
8766
|
-
handleError(
|
|
8767
|
-
15
|
|
8768
|
-
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
8769
|
-
);
|
|
8770
|
-
break;
|
|
8771
|
-
case 3:
|
|
8772
|
-
handleError(
|
|
8773
|
-
13
|
|
8774
|
-
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
8775
|
-
);
|
|
8776
|
-
break;
|
|
8777
|
-
case 1:
|
|
8778
|
-
if (!disallowComments) {
|
|
8779
|
-
handleError(
|
|
8780
|
-
11
|
|
8781
|
-
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
8782
|
-
);
|
|
8783
|
-
}
|
|
8784
|
-
break;
|
|
8785
|
-
case 2:
|
|
8786
|
-
handleError(
|
|
8787
|
-
12
|
|
8788
|
-
/* ParseErrorCode.UnexpectedEndOfString */
|
|
8789
|
-
);
|
|
8790
|
-
break;
|
|
8791
|
-
case 6:
|
|
8792
|
-
handleError(
|
|
8793
|
-
16
|
|
8794
|
-
/* ParseErrorCode.InvalidCharacter */
|
|
8795
|
-
);
|
|
8796
|
-
break;
|
|
8797
|
-
}
|
|
8798
|
-
switch (token) {
|
|
8799
|
-
case 12:
|
|
8800
|
-
case 13:
|
|
8801
|
-
if (disallowComments) {
|
|
8802
|
-
handleError(
|
|
8803
|
-
10
|
|
8804
|
-
/* ParseErrorCode.InvalidCommentToken */
|
|
8805
|
-
);
|
|
8806
|
-
} else {
|
|
8807
|
-
onComment();
|
|
8808
|
-
}
|
|
8809
|
-
break;
|
|
8810
|
-
case 16:
|
|
8811
|
-
handleError(
|
|
8812
|
-
1
|
|
8813
|
-
/* ParseErrorCode.InvalidSymbol */
|
|
8814
|
-
);
|
|
8815
|
-
break;
|
|
8816
|
-
case 15:
|
|
8817
|
-
case 14:
|
|
8818
|
-
break;
|
|
8819
|
-
default:
|
|
8820
|
-
return token;
|
|
8821
|
-
}
|
|
8822
|
-
}
|
|
8823
|
-
}
|
|
8824
|
-
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
8825
|
-
onError(error);
|
|
8826
|
-
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
8827
|
-
let token = _scanner.getToken();
|
|
8828
|
-
while (token !== 17) {
|
|
8829
|
-
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
8830
|
-
scanNext();
|
|
8831
|
-
break;
|
|
8832
|
-
} else if (skipUntil.indexOf(token) !== -1) {
|
|
8833
|
-
break;
|
|
8834
|
-
}
|
|
8835
|
-
token = scanNext();
|
|
8836
|
-
}
|
|
8837
|
-
}
|
|
8838
|
-
}
|
|
8839
|
-
function parseString(isValue) {
|
|
8840
|
-
const value = _scanner.getTokenValue();
|
|
8841
|
-
if (isValue) {
|
|
8842
|
-
onLiteralValue(value);
|
|
8843
|
-
} else {
|
|
8844
|
-
onObjectProperty(value);
|
|
8845
|
-
_jsonPath.push(value);
|
|
8846
|
-
}
|
|
8847
|
-
scanNext();
|
|
8848
|
-
return true;
|
|
8849
|
-
}
|
|
8850
|
-
function parseLiteral() {
|
|
8851
|
-
switch (_scanner.getToken()) {
|
|
8852
|
-
case 11:
|
|
8853
|
-
const tokenValue = _scanner.getTokenValue();
|
|
8854
|
-
let value = Number(tokenValue);
|
|
8855
|
-
if (isNaN(value)) {
|
|
8856
|
-
handleError(
|
|
8857
|
-
2
|
|
8858
|
-
/* ParseErrorCode.InvalidNumberFormat */
|
|
8859
|
-
);
|
|
8860
|
-
value = 0;
|
|
8861
|
-
}
|
|
8862
|
-
onLiteralValue(value);
|
|
8863
|
-
break;
|
|
8864
|
-
case 7:
|
|
8865
|
-
onLiteralValue(null);
|
|
8866
|
-
break;
|
|
8867
|
-
case 8:
|
|
8868
|
-
onLiteralValue(true);
|
|
8869
|
-
break;
|
|
8870
|
-
case 9:
|
|
8871
|
-
onLiteralValue(false);
|
|
8872
|
-
break;
|
|
8873
|
-
default:
|
|
8874
|
-
return false;
|
|
8875
|
-
}
|
|
8876
|
-
scanNext();
|
|
8877
|
-
return true;
|
|
8878
|
-
}
|
|
8879
|
-
function parseProperty() {
|
|
8880
|
-
if (_scanner.getToken() !== 10) {
|
|
8881
|
-
handleError(3, [], [
|
|
8882
|
-
2,
|
|
8883
|
-
5
|
|
8884
|
-
/* SyntaxKind.CommaToken */
|
|
8885
|
-
]);
|
|
8886
|
-
return false;
|
|
8887
|
-
}
|
|
8888
|
-
parseString(false);
|
|
8889
|
-
if (_scanner.getToken() === 6) {
|
|
8890
|
-
onSeparator(":");
|
|
8891
|
-
scanNext();
|
|
8892
|
-
if (!parseValue()) {
|
|
8893
|
-
handleError(4, [], [
|
|
8894
|
-
2,
|
|
8895
|
-
5
|
|
8896
|
-
/* SyntaxKind.CommaToken */
|
|
8897
|
-
]);
|
|
8898
|
-
}
|
|
8899
|
-
} else {
|
|
8900
|
-
handleError(5, [], [
|
|
8901
|
-
2,
|
|
8902
|
-
5
|
|
8903
|
-
/* SyntaxKind.CommaToken */
|
|
8904
|
-
]);
|
|
8905
|
-
}
|
|
8906
|
-
_jsonPath.pop();
|
|
8907
|
-
return true;
|
|
8908
|
-
}
|
|
8909
|
-
function parseObject() {
|
|
8910
|
-
onObjectBegin();
|
|
8911
|
-
scanNext();
|
|
8912
|
-
let needsComma = false;
|
|
8913
|
-
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
8914
|
-
if (_scanner.getToken() === 5) {
|
|
8915
|
-
if (!needsComma) {
|
|
8916
|
-
handleError(4, [], []);
|
|
8917
|
-
}
|
|
8918
|
-
onSeparator(",");
|
|
8919
|
-
scanNext();
|
|
8920
|
-
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
8921
|
-
break;
|
|
8922
|
-
}
|
|
8923
|
-
} else if (needsComma) {
|
|
8924
|
-
handleError(6, [], []);
|
|
8925
|
-
}
|
|
8926
|
-
if (!parseProperty()) {
|
|
8927
|
-
handleError(4, [], [
|
|
8928
|
-
2,
|
|
8929
|
-
5
|
|
8930
|
-
/* SyntaxKind.CommaToken */
|
|
8931
|
-
]);
|
|
8932
|
-
}
|
|
8933
|
-
needsComma = true;
|
|
8934
|
-
}
|
|
8935
|
-
onObjectEnd();
|
|
8936
|
-
if (_scanner.getToken() !== 2) {
|
|
8937
|
-
handleError(7, [
|
|
8938
|
-
2
|
|
8939
|
-
/* SyntaxKind.CloseBraceToken */
|
|
8940
|
-
], []);
|
|
8941
|
-
} else {
|
|
8942
|
-
scanNext();
|
|
8943
|
-
}
|
|
8944
|
-
return true;
|
|
8945
|
-
}
|
|
8946
|
-
function parseArray() {
|
|
8947
|
-
onArrayBegin();
|
|
8948
|
-
scanNext();
|
|
8949
|
-
let isFirstElement = true;
|
|
8950
|
-
let needsComma = false;
|
|
8951
|
-
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
8952
|
-
if (_scanner.getToken() === 5) {
|
|
8953
|
-
if (!needsComma) {
|
|
8954
|
-
handleError(4, [], []);
|
|
8955
|
-
}
|
|
8956
|
-
onSeparator(",");
|
|
8957
|
-
scanNext();
|
|
8958
|
-
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
8959
|
-
break;
|
|
8960
|
-
}
|
|
8961
|
-
} else if (needsComma) {
|
|
8962
|
-
handleError(6, [], []);
|
|
8963
|
-
}
|
|
8964
|
-
if (isFirstElement) {
|
|
8965
|
-
_jsonPath.push(0);
|
|
8966
|
-
isFirstElement = false;
|
|
8967
|
-
} else {
|
|
8968
|
-
_jsonPath[_jsonPath.length - 1]++;
|
|
8969
|
-
}
|
|
8970
|
-
if (!parseValue()) {
|
|
8971
|
-
handleError(4, [], [
|
|
8972
|
-
4,
|
|
8973
|
-
5
|
|
8974
|
-
/* SyntaxKind.CommaToken */
|
|
8975
|
-
]);
|
|
8976
|
-
}
|
|
8977
|
-
needsComma = true;
|
|
8978
|
-
}
|
|
8979
|
-
onArrayEnd();
|
|
8980
|
-
if (!isFirstElement) {
|
|
8981
|
-
_jsonPath.pop();
|
|
8982
|
-
}
|
|
8983
|
-
if (_scanner.getToken() !== 4) {
|
|
8984
|
-
handleError(8, [
|
|
8985
|
-
4
|
|
8986
|
-
/* SyntaxKind.CloseBracketToken */
|
|
8987
|
-
], []);
|
|
8988
|
-
} else {
|
|
8989
|
-
scanNext();
|
|
8990
|
-
}
|
|
8991
|
-
return true;
|
|
8992
|
-
}
|
|
8993
|
-
function parseValue() {
|
|
8994
|
-
switch (_scanner.getToken()) {
|
|
8995
|
-
case 3:
|
|
8996
|
-
return parseArray();
|
|
8997
|
-
case 1:
|
|
8998
|
-
return parseObject();
|
|
8999
|
-
case 10:
|
|
9000
|
-
return parseString(true);
|
|
9001
|
-
default:
|
|
9002
|
-
return parseLiteral();
|
|
9003
|
-
}
|
|
9004
|
-
}
|
|
9005
|
-
scanNext();
|
|
9006
|
-
if (_scanner.getToken() === 17) {
|
|
9007
|
-
if (options.allowEmptyContent) {
|
|
9008
|
-
return true;
|
|
9009
|
-
}
|
|
9010
|
-
handleError(4, [], []);
|
|
9011
|
-
return false;
|
|
9012
|
-
}
|
|
9013
|
-
if (!parseValue()) {
|
|
9014
|
-
handleError(4, [], []);
|
|
9015
|
-
return false;
|
|
9016
|
-
}
|
|
9017
|
-
if (_scanner.getToken() !== 17) {
|
|
9018
|
-
handleError(9, [], []);
|
|
9019
|
-
}
|
|
9020
|
-
return true;
|
|
9021
|
-
}
|
|
9022
|
-
|
|
9023
|
-
// node_modules/jsonc-parser/lib/esm/main.js
|
|
9024
|
-
var ScanError;
|
|
9025
|
-
(function(ScanError2) {
|
|
9026
|
-
ScanError2[ScanError2["None"] = 0] = "None";
|
|
9027
|
-
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
9028
|
-
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
9029
|
-
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
9030
|
-
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
9031
|
-
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
9032
|
-
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
9033
|
-
})(ScanError || (ScanError = {}));
|
|
9034
|
-
var SyntaxKind;
|
|
9035
|
-
(function(SyntaxKind2) {
|
|
9036
|
-
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
9037
|
-
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
9038
|
-
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
9039
|
-
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
9040
|
-
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
9041
|
-
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
9042
|
-
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
9043
|
-
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
9044
|
-
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
9045
|
-
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
9046
|
-
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
9047
|
-
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
9048
|
-
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
9049
|
-
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
9050
|
-
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
9051
|
-
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
9052
|
-
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
9053
|
-
})(SyntaxKind || (SyntaxKind = {}));
|
|
9054
|
-
var parse2 = parse;
|
|
9055
|
-
var ParseErrorCode;
|
|
9056
|
-
(function(ParseErrorCode2) {
|
|
9057
|
-
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
9058
|
-
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
9059
|
-
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
9060
|
-
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
9061
|
-
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
9062
|
-
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
9063
|
-
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
9064
|
-
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
9065
|
-
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
9066
|
-
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
9067
|
-
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
9068
|
-
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
9069
|
-
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
9070
|
-
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
9071
|
-
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
9072
|
-
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
9073
|
-
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
9074
|
-
|
|
9075
|
-
// node_modules/ai-sdk-provider-claude-code/dist/index.js
|
|
9076
|
-
var import_zod4 = require("zod");
|
|
9077
|
-
var import_fs2 = require("fs");
|
|
9078
|
-
|
|
9079
|
-
// node_modules/@anthropic-ai/claude-code/sdk.mjs
|
|
9080
|
-
var import_child_process = require("child_process");
|
|
9081
|
-
var import_path = require("path");
|
|
9082
|
-
var import_url = require("url");
|
|
9083
|
-
var import_readline = require("readline");
|
|
9084
|
-
var import_fs = require("fs");
|
|
9085
|
-
var import_events = require("events");
|
|
9086
|
-
var import_meta = {};
|
|
9087
|
-
var Stream = class {
|
|
9088
|
-
returned;
|
|
9089
|
-
queue = [];
|
|
9090
|
-
readResolve;
|
|
9091
|
-
readReject;
|
|
9092
|
-
isDone = false;
|
|
9093
|
-
hasError;
|
|
9094
|
-
started = false;
|
|
9095
|
-
constructor(returned) {
|
|
9096
|
-
this.returned = returned;
|
|
9097
|
-
}
|
|
9098
|
-
[Symbol.asyncIterator]() {
|
|
9099
|
-
if (this.started) {
|
|
9100
|
-
throw new Error("Stream can only be iterated once");
|
|
9101
|
-
}
|
|
9102
|
-
this.started = true;
|
|
9103
|
-
return this;
|
|
9104
|
-
}
|
|
9105
|
-
next() {
|
|
9106
|
-
if (this.queue.length > 0) {
|
|
9107
|
-
return Promise.resolve({
|
|
9108
|
-
done: false,
|
|
9109
|
-
value: this.queue.shift()
|
|
9110
|
-
});
|
|
9111
|
-
}
|
|
9112
|
-
if (this.isDone) {
|
|
9113
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
9114
|
-
}
|
|
9115
|
-
if (this.hasError) {
|
|
9116
|
-
return Promise.reject(this.hasError);
|
|
9117
|
-
}
|
|
9118
|
-
return new Promise((resolve2, reject) => {
|
|
9119
|
-
this.readResolve = resolve2;
|
|
9120
|
-
this.readReject = reject;
|
|
9121
|
-
});
|
|
9122
|
-
}
|
|
9123
|
-
enqueue(value) {
|
|
9124
|
-
if (this.readResolve) {
|
|
9125
|
-
const resolve2 = this.readResolve;
|
|
9126
|
-
this.readResolve = void 0;
|
|
9127
|
-
this.readReject = void 0;
|
|
9128
|
-
resolve2({ done: false, value });
|
|
9129
|
-
} else {
|
|
9130
|
-
this.queue.push(value);
|
|
9131
|
-
}
|
|
9132
|
-
}
|
|
9133
|
-
done() {
|
|
9134
|
-
this.isDone = true;
|
|
9135
|
-
if (this.readResolve) {
|
|
9136
|
-
const resolve2 = this.readResolve;
|
|
9137
|
-
this.readResolve = void 0;
|
|
9138
|
-
this.readReject = void 0;
|
|
9139
|
-
resolve2({ done: true, value: void 0 });
|
|
9140
|
-
}
|
|
9141
|
-
}
|
|
9142
|
-
error(error) {
|
|
9143
|
-
this.hasError = error;
|
|
9144
|
-
if (this.readReject) {
|
|
9145
|
-
const reject = this.readReject;
|
|
9146
|
-
this.readResolve = void 0;
|
|
9147
|
-
this.readReject = void 0;
|
|
9148
|
-
reject(error);
|
|
9149
|
-
}
|
|
9150
|
-
}
|
|
9151
|
-
return() {
|
|
9152
|
-
this.isDone = true;
|
|
9153
|
-
if (this.returned) {
|
|
9154
|
-
this.returned();
|
|
9155
|
-
}
|
|
9156
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
9157
|
-
}
|
|
9158
|
-
};
|
|
9159
|
-
var DEFAULT_MAX_LISTENERS = 50;
|
|
9160
|
-
function createAbortController(maxListeners = DEFAULT_MAX_LISTENERS) {
|
|
9161
|
-
const controller = new AbortController();
|
|
9162
|
-
(0, import_events.setMaxListeners)(maxListeners, controller.signal);
|
|
9163
|
-
return controller;
|
|
9164
|
-
}
|
|
9165
|
-
function query({
|
|
9166
|
-
prompt,
|
|
9167
|
-
options: {
|
|
9168
|
-
abortController = createAbortController(),
|
|
9169
|
-
allowedTools = [],
|
|
9170
|
-
appendSystemPrompt,
|
|
9171
|
-
customSystemPrompt,
|
|
9172
|
-
cwd,
|
|
9173
|
-
disallowedTools = [],
|
|
9174
|
-
executable = isRunningWithBun() ? "bun" : "node",
|
|
9175
|
-
executableArgs = [],
|
|
9176
|
-
maxTurns,
|
|
9177
|
-
mcpServers,
|
|
9178
|
-
pathToClaudeCodeExecutable,
|
|
9179
|
-
permissionMode = "default",
|
|
9180
|
-
permissionPromptToolName,
|
|
9181
|
-
canUseTool,
|
|
9182
|
-
continue: continueConversation,
|
|
9183
|
-
resume,
|
|
9184
|
-
model,
|
|
9185
|
-
fallbackModel,
|
|
9186
|
-
strictMcpConfig,
|
|
9187
|
-
stderr,
|
|
9188
|
-
env
|
|
9189
|
-
} = {}
|
|
9190
|
-
}) {
|
|
9191
|
-
if (!env) {
|
|
9192
|
-
env = { ...process.env };
|
|
9193
|
-
}
|
|
9194
|
-
if (!env.CLAUDE_CODE_ENTRYPOINT) {
|
|
9195
|
-
env.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
|
|
9196
|
-
}
|
|
9197
|
-
if (pathToClaudeCodeExecutable === void 0) {
|
|
9198
|
-
const filename = (0, import_url.fileURLToPath)(import_meta.url);
|
|
9199
|
-
const dirname = (0, import_path.join)(filename, "..");
|
|
9200
|
-
pathToClaudeCodeExecutable = (0, import_path.join)(dirname, "cli.js");
|
|
9201
|
-
}
|
|
9202
|
-
const args = ["--output-format", "stream-json", "--verbose"];
|
|
9203
|
-
if (customSystemPrompt)
|
|
9204
|
-
args.push("--system-prompt", customSystemPrompt);
|
|
9205
|
-
if (appendSystemPrompt)
|
|
9206
|
-
args.push("--append-system-prompt", appendSystemPrompt);
|
|
9207
|
-
if (maxTurns)
|
|
9208
|
-
args.push("--max-turns", maxTurns.toString());
|
|
9209
|
-
if (model)
|
|
9210
|
-
args.push("--model", model);
|
|
9211
|
-
if (canUseTool) {
|
|
9212
|
-
if (typeof prompt === "string") {
|
|
9213
|
-
throw new Error("canUseTool callback requires --input-format stream-json. Please set prompt as an AsyncIterable.");
|
|
9214
|
-
}
|
|
9215
|
-
if (permissionPromptToolName) {
|
|
9216
|
-
throw new Error("canUseTool callback cannot be used with permissionPromptToolName. Please use one or the other.");
|
|
9217
|
-
}
|
|
9218
|
-
permissionPromptToolName = "stdio";
|
|
9219
|
-
}
|
|
9220
|
-
if (permissionPromptToolName) {
|
|
9221
|
-
args.push("--permission-prompt-tool", permissionPromptToolName);
|
|
9222
|
-
}
|
|
9223
|
-
if (continueConversation)
|
|
9224
|
-
args.push("--continue");
|
|
9225
|
-
if (resume)
|
|
9226
|
-
args.push("--resume", resume);
|
|
9227
|
-
if (allowedTools.length > 0) {
|
|
9228
|
-
args.push("--allowedTools", allowedTools.join(","));
|
|
9229
|
-
}
|
|
9230
|
-
if (disallowedTools.length > 0) {
|
|
9231
|
-
args.push("--disallowedTools", disallowedTools.join(","));
|
|
9232
|
-
}
|
|
9233
|
-
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
|
9234
|
-
args.push("--mcp-config", JSON.stringify({ mcpServers }));
|
|
9235
|
-
}
|
|
9236
|
-
if (strictMcpConfig) {
|
|
9237
|
-
args.push("--strict-mcp-config");
|
|
9238
|
-
}
|
|
9239
|
-
if (permissionMode !== "default") {
|
|
9240
|
-
args.push("--permission-mode", permissionMode);
|
|
9241
|
-
}
|
|
9242
|
-
if (fallbackModel) {
|
|
9243
|
-
if (model && fallbackModel === model) {
|
|
9244
|
-
throw new Error("Fallback model cannot be the same as the main model. Please specify a different model for fallbackModel option.");
|
|
9245
|
-
}
|
|
9246
|
-
args.push("--fallback-model", fallbackModel);
|
|
9247
|
-
}
|
|
9248
|
-
if (typeof prompt === "string") {
|
|
9249
|
-
args.push("--print");
|
|
9250
|
-
args.push("--", prompt.trim());
|
|
9251
|
-
} else {
|
|
9252
|
-
args.push("--input-format", "stream-json");
|
|
9253
|
-
}
|
|
9254
|
-
if (!(0, import_fs.existsSync)(pathToClaudeCodeExecutable)) {
|
|
9255
|
-
throw new ReferenceError(`Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`);
|
|
9256
|
-
}
|
|
9257
|
-
logDebug(`Spawning Claude Code process: ${executable} ${[...executableArgs, pathToClaudeCodeExecutable, ...args].join(" ")}`);
|
|
9258
|
-
const stderrMode = env.DEBUG || stderr ? "pipe" : "ignore";
|
|
9259
|
-
const child = (0, import_child_process.spawn)(executable, [...executableArgs, pathToClaudeCodeExecutable, ...args], {
|
|
9260
|
-
cwd,
|
|
9261
|
-
stdio: ["pipe", "pipe", stderrMode],
|
|
9262
|
-
signal: abortController.signal,
|
|
9263
|
-
env
|
|
9264
|
-
});
|
|
9265
|
-
let childStdin;
|
|
9266
|
-
if (typeof prompt === "string") {
|
|
9267
|
-
child.stdin.end();
|
|
9268
|
-
} else {
|
|
9269
|
-
streamToStdin(prompt, child.stdin, abortController);
|
|
9270
|
-
childStdin = child.stdin;
|
|
9271
|
-
}
|
|
9272
|
-
if (env.DEBUG || stderr) {
|
|
9273
|
-
child.stderr.on("data", (data) => {
|
|
9274
|
-
if (env.DEBUG) {
|
|
9275
|
-
console.error("Claude Code stderr:", data.toString());
|
|
9276
|
-
}
|
|
9277
|
-
if (stderr) {
|
|
9278
|
-
stderr(data.toString());
|
|
9279
|
-
}
|
|
9280
|
-
});
|
|
9281
|
-
}
|
|
9282
|
-
const cleanup = () => {
|
|
9283
|
-
if (!child.killed) {
|
|
9284
|
-
child.kill("SIGTERM");
|
|
9285
|
-
}
|
|
9286
|
-
};
|
|
9287
|
-
abortController.signal.addEventListener("abort", cleanup);
|
|
9288
|
-
process.on("exit", cleanup);
|
|
9289
|
-
const processExitPromise = new Promise((resolve2) => {
|
|
9290
|
-
child.on("close", (code) => {
|
|
9291
|
-
if (abortController.signal.aborted) {
|
|
9292
|
-
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
9293
|
-
}
|
|
9294
|
-
if (code !== 0) {
|
|
9295
|
-
query2.setError(new Error(`Claude Code process exited with code ${code}`));
|
|
9296
|
-
} else {
|
|
9297
|
-
resolve2();
|
|
9298
|
-
}
|
|
9299
|
-
});
|
|
9300
|
-
});
|
|
9301
|
-
const query2 = new Query(childStdin, child.stdout, processExitPromise, canUseTool);
|
|
9302
|
-
child.on("error", (error) => {
|
|
9303
|
-
if (abortController.signal.aborted) {
|
|
9304
|
-
query2.setError(new AbortError("Claude Code process aborted by user"));
|
|
9305
|
-
} else {
|
|
9306
|
-
query2.setError(new Error(`Failed to spawn Claude Code process: ${error.message}`));
|
|
9307
|
-
}
|
|
9308
|
-
});
|
|
9309
|
-
processExitPromise.finally(() => {
|
|
9310
|
-
cleanup();
|
|
9311
|
-
abortController.signal.removeEventListener("abort", cleanup);
|
|
9312
|
-
});
|
|
9313
|
-
return query2;
|
|
9314
|
-
}
|
|
9315
|
-
var Query = class {
|
|
9316
|
-
childStdin;
|
|
9317
|
-
childStdout;
|
|
9318
|
-
processExitPromise;
|
|
9319
|
-
canUseTool;
|
|
9320
|
-
pendingControlResponses = /* @__PURE__ */ new Map();
|
|
9321
|
-
sdkMessages;
|
|
9322
|
-
inputStream = new Stream();
|
|
9323
|
-
intialization;
|
|
9324
|
-
constructor(childStdin, childStdout, processExitPromise, canUseTool) {
|
|
9325
|
-
this.childStdin = childStdin;
|
|
9326
|
-
this.childStdout = childStdout;
|
|
9327
|
-
this.processExitPromise = processExitPromise;
|
|
9328
|
-
this.canUseTool = canUseTool;
|
|
9329
|
-
this.readMessages();
|
|
9330
|
-
this.sdkMessages = this.readSdkMessages();
|
|
9331
|
-
if (this.childStdin) {
|
|
9332
|
-
this.intialization = this.initialize();
|
|
9333
|
-
}
|
|
9334
|
-
}
|
|
9335
|
-
setError(error) {
|
|
9336
|
-
this.inputStream.error(error);
|
|
9337
|
-
}
|
|
9338
|
-
next(...[value]) {
|
|
9339
|
-
return this.sdkMessages.next(...[value]);
|
|
9340
|
-
}
|
|
9341
|
-
return(value) {
|
|
9342
|
-
return this.sdkMessages.return(value);
|
|
9343
|
-
}
|
|
9344
|
-
throw(e) {
|
|
9345
|
-
return this.sdkMessages.throw(e);
|
|
9346
|
-
}
|
|
9347
|
-
[Symbol.asyncIterator]() {
|
|
9348
|
-
return this.sdkMessages;
|
|
9349
|
-
}
|
|
9350
|
-
[Symbol.asyncDispose]() {
|
|
9351
|
-
return this.sdkMessages[Symbol.asyncDispose]();
|
|
9352
|
-
}
|
|
9353
|
-
async readMessages() {
|
|
9354
|
-
const rl = (0, import_readline.createInterface)({ input: this.childStdout });
|
|
9355
|
-
try {
|
|
9356
|
-
for await (const line of rl) {
|
|
9357
|
-
if (line.trim()) {
|
|
9358
|
-
const message = JSON.parse(line);
|
|
9359
|
-
if (message.type === "control_response") {
|
|
9360
|
-
const handler = this.pendingControlResponses.get(message.response.request_id);
|
|
9361
|
-
if (handler) {
|
|
9362
|
-
handler(message.response);
|
|
9363
|
-
}
|
|
9364
|
-
continue;
|
|
9365
|
-
} else if (message.type === "control_request") {
|
|
9366
|
-
this.handleControlRequest(message);
|
|
9367
|
-
continue;
|
|
9368
|
-
}
|
|
9369
|
-
this.inputStream.enqueue(message);
|
|
9370
|
-
}
|
|
9371
|
-
}
|
|
9372
|
-
await this.processExitPromise;
|
|
9373
|
-
} catch (error) {
|
|
9374
|
-
this.inputStream.error(error);
|
|
9375
|
-
} finally {
|
|
9376
|
-
this.inputStream.done();
|
|
9377
|
-
rl.close();
|
|
9378
|
-
}
|
|
9379
|
-
}
|
|
9380
|
-
async handleControlRequest(request) {
|
|
9381
|
-
try {
|
|
9382
|
-
const response = await this.processControlRequest(request);
|
|
9383
|
-
const controlResponse = {
|
|
9384
|
-
type: "control_response",
|
|
9385
|
-
response: {
|
|
9386
|
-
subtype: "success",
|
|
9387
|
-
request_id: request.request_id,
|
|
9388
|
-
response
|
|
9389
|
-
}
|
|
9390
|
-
};
|
|
9391
|
-
this.childStdin?.write(JSON.stringify(controlResponse) + `
|
|
9392
|
-
`);
|
|
9393
|
-
} catch (error) {
|
|
9394
|
-
const controlErrorResponse = {
|
|
9395
|
-
type: "control_response",
|
|
9396
|
-
response: {
|
|
9397
|
-
subtype: "error",
|
|
9398
|
-
request_id: request.request_id,
|
|
9399
|
-
error: error.message || String(error)
|
|
9400
|
-
}
|
|
9401
|
-
};
|
|
9402
|
-
this.childStdin?.write(JSON.stringify(controlErrorResponse) + `
|
|
9403
|
-
`);
|
|
9404
|
-
}
|
|
9405
|
-
}
|
|
9406
|
-
async processControlRequest(request) {
|
|
9407
|
-
if (request.request.subtype === "can_use_tool") {
|
|
9408
|
-
if (!this.canUseTool) {
|
|
9409
|
-
throw new Error("canUseTool callback is not provided.");
|
|
9410
|
-
}
|
|
9411
|
-
return this.canUseTool(request.request.tool_name, request.request.input);
|
|
9412
|
-
}
|
|
9413
|
-
throw new Error("Unsupported control request subtype: " + request.request.subtype);
|
|
9414
|
-
}
|
|
9415
|
-
async *readSdkMessages() {
|
|
9416
|
-
for await (const message of this.inputStream) {
|
|
9417
|
-
yield message;
|
|
9418
|
-
}
|
|
9419
|
-
}
|
|
9420
|
-
async initialize() {
|
|
9421
|
-
if (!this.childStdin) {
|
|
9422
|
-
throw new Error("Cannot initialize without child stdin");
|
|
9423
|
-
}
|
|
9424
|
-
const initRequest = {
|
|
9425
|
-
subtype: "initialize"
|
|
9426
|
-
};
|
|
9427
|
-
const response = await this.request(initRequest, this.childStdin);
|
|
9428
|
-
return response.response;
|
|
9429
|
-
}
|
|
9430
|
-
async interrupt() {
|
|
9431
|
-
if (!this.childStdin) {
|
|
9432
|
-
throw new Error("Interrupt requires --input-format stream-json");
|
|
9433
|
-
}
|
|
9434
|
-
await this.request({
|
|
9435
|
-
subtype: "interrupt"
|
|
9436
|
-
}, this.childStdin);
|
|
9437
|
-
}
|
|
9438
|
-
request(request, childStdin) {
|
|
9439
|
-
const requestId = Math.random().toString(36).substring(2, 15);
|
|
9440
|
-
const sdkRequest = {
|
|
9441
|
-
request_id: requestId,
|
|
9442
|
-
type: "control_request",
|
|
9443
|
-
request
|
|
9444
|
-
};
|
|
9445
|
-
return new Promise((resolve2, reject) => {
|
|
9446
|
-
this.pendingControlResponses.set(requestId, (response) => {
|
|
9447
|
-
if (response.subtype === "success") {
|
|
9448
|
-
resolve2(response);
|
|
9449
|
-
} else {
|
|
9450
|
-
reject(new Error(response.error));
|
|
9451
|
-
}
|
|
9452
|
-
});
|
|
9453
|
-
childStdin.write(JSON.stringify(sdkRequest) + `
|
|
9454
|
-
`);
|
|
9455
|
-
});
|
|
9456
|
-
}
|
|
9457
|
-
async supportedCommands() {
|
|
9458
|
-
if (!this.intialization) {
|
|
9459
|
-
throw new Error("Interrupt requires --input-format stream-json");
|
|
9460
|
-
}
|
|
9461
|
-
return (await this.intialization).commands;
|
|
9462
|
-
}
|
|
9463
|
-
};
|
|
9464
|
-
async function streamToStdin(stream, stdin, abortController) {
|
|
9465
|
-
for await (const message of stream) {
|
|
9466
|
-
if (abortController.signal.aborted)
|
|
9467
|
-
break;
|
|
9468
|
-
stdin.write(JSON.stringify(message) + `
|
|
9469
|
-
`);
|
|
9470
|
-
}
|
|
9471
|
-
stdin.end();
|
|
9472
|
-
}
|
|
9473
|
-
function logDebug(message) {
|
|
9474
|
-
if (process.env.DEBUG) {
|
|
9475
|
-
console.debug(message);
|
|
9476
|
-
}
|
|
9477
|
-
}
|
|
9478
|
-
function isRunningWithBun() {
|
|
9479
|
-
return process.versions.bun !== void 0 || process.env.BUN_INSTALL !== void 0;
|
|
9480
|
-
}
|
|
9481
|
-
var AbortError = class extends Error {
|
|
9482
|
-
};
|
|
9483
|
-
|
|
9484
|
-
// node_modules/ai-sdk-provider-claude-code/dist/index.js
|
|
9485
|
-
function convertToClaudeCodeMessages(prompt, mode = { type: "regular" }, jsonSchema) {
|
|
9486
|
-
const messages = [];
|
|
9487
|
-
const warnings = [];
|
|
9488
|
-
let systemPrompt;
|
|
9489
|
-
for (const message of prompt) {
|
|
9490
|
-
switch (message.role) {
|
|
9491
|
-
case "system":
|
|
9492
|
-
systemPrompt = message.content;
|
|
9493
|
-
break;
|
|
9494
|
-
case "user":
|
|
9495
|
-
if (typeof message.content === "string") {
|
|
9496
|
-
messages.push(message.content);
|
|
9497
|
-
} else {
|
|
9498
|
-
const textParts = message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
9499
|
-
if (textParts) {
|
|
9500
|
-
messages.push(textParts);
|
|
9501
|
-
}
|
|
9502
|
-
const imageParts = message.content.filter((part) => part.type === "image");
|
|
9503
|
-
if (imageParts.length > 0) {
|
|
9504
|
-
warnings.push("Claude Code SDK does not support image inputs. Images will be ignored.");
|
|
9505
|
-
}
|
|
9506
|
-
}
|
|
9507
|
-
break;
|
|
9508
|
-
case "assistant": {
|
|
9509
|
-
let assistantContent = "";
|
|
9510
|
-
if (typeof message.content === "string") {
|
|
9511
|
-
assistantContent = message.content;
|
|
9512
|
-
} else {
|
|
9513
|
-
const textParts = message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
9514
|
-
if (textParts) {
|
|
9515
|
-
assistantContent = textParts;
|
|
9516
|
-
}
|
|
9517
|
-
const toolCalls = message.content.filter((part) => part.type === "tool-call");
|
|
9518
|
-
if (toolCalls.length > 0) {
|
|
9519
|
-
assistantContent += `
|
|
9520
|
-
[Tool calls made]`;
|
|
9521
|
-
}
|
|
9522
|
-
}
|
|
9523
|
-
messages.push(`Assistant: ${assistantContent}`);
|
|
9524
|
-
break;
|
|
9525
|
-
}
|
|
9526
|
-
case "tool":
|
|
9527
|
-
for (const tool2 of message.content) {
|
|
9528
|
-
const resultText = tool2.output.type === "text" ? tool2.output.value : JSON.stringify(tool2.output.value);
|
|
9529
|
-
messages.push(`Tool Result (${tool2.toolName}): ${resultText}`);
|
|
9530
|
-
}
|
|
9531
|
-
break;
|
|
9532
|
-
}
|
|
9533
|
-
}
|
|
9534
|
-
let finalPrompt = "";
|
|
9535
|
-
if (systemPrompt) {
|
|
9536
|
-
finalPrompt = systemPrompt;
|
|
9537
|
-
}
|
|
9538
|
-
if (messages.length === 0) {
|
|
9539
|
-
return { messagesPrompt: finalPrompt, systemPrompt };
|
|
9540
|
-
}
|
|
9541
|
-
const formattedMessages = [];
|
|
9542
|
-
for (let i = 0; i < messages.length; i++) {
|
|
9543
|
-
const msg = messages[i];
|
|
9544
|
-
if (msg.startsWith("Assistant:") || msg.startsWith("Tool Result")) {
|
|
9545
|
-
formattedMessages.push(msg);
|
|
9546
|
-
} else {
|
|
9547
|
-
formattedMessages.push(`Human: ${msg}`);
|
|
9548
|
-
}
|
|
9549
|
-
}
|
|
9550
|
-
if (finalPrompt) {
|
|
9551
|
-
finalPrompt = finalPrompt + "\n\n" + formattedMessages.join("\n\n");
|
|
9552
|
-
} else {
|
|
9553
|
-
finalPrompt = formattedMessages.join("\n\n");
|
|
9554
|
-
}
|
|
9555
|
-
if (mode?.type === "object-json" && jsonSchema) {
|
|
9556
|
-
const schemaStr = JSON.stringify(jsonSchema, null, 2);
|
|
9557
|
-
finalPrompt = `CRITICAL: You MUST respond with ONLY a JSON object. NO other text, NO explanations, NO questions.
|
|
9558
|
-
|
|
9559
|
-
Your response MUST start with { and end with }
|
|
9560
|
-
|
|
9561
|
-
The JSON MUST match this EXACT schema:
|
|
9562
|
-
${schemaStr}
|
|
9563
|
-
|
|
9564
|
-
Now, based on the following conversation, generate ONLY the JSON object with the exact fields specified above:
|
|
9565
|
-
|
|
9566
|
-
${finalPrompt}
|
|
9567
|
-
|
|
9568
|
-
Remember: Your ENTIRE response must be ONLY the JSON object, starting with { and ending with }`;
|
|
9569
|
-
}
|
|
9570
|
-
return {
|
|
9571
|
-
messagesPrompt: finalPrompt,
|
|
9572
|
-
systemPrompt,
|
|
9573
|
-
...warnings.length > 0 && { warnings }
|
|
9574
|
-
};
|
|
9575
|
-
}
|
|
9576
|
-
function extractJson(text) {
|
|
9577
|
-
let content = text.trim();
|
|
9578
|
-
const fenceMatch = /```(?:json)?\s*([\s\S]*?)\s*```/i.exec(content);
|
|
9579
|
-
if (fenceMatch) {
|
|
9580
|
-
content = fenceMatch[1];
|
|
9581
|
-
}
|
|
9582
|
-
const varMatch = /^\s*(?:const|let|var)\s+\w+\s*=\s*([\s\S]*)/i.exec(content);
|
|
9583
|
-
if (varMatch) {
|
|
9584
|
-
content = varMatch[1];
|
|
9585
|
-
if (content.trim().endsWith(";")) {
|
|
9586
|
-
content = content.trim().slice(0, -1);
|
|
9587
|
-
}
|
|
9588
|
-
}
|
|
9589
|
-
const firstObj = content.indexOf("{");
|
|
9590
|
-
const firstArr = content.indexOf("[");
|
|
9591
|
-
if (firstObj === -1 && firstArr === -1) {
|
|
9592
|
-
return text;
|
|
9593
|
-
}
|
|
9594
|
-
const start = firstArr === -1 ? firstObj : firstObj === -1 ? firstArr : Math.min(firstObj, firstArr);
|
|
9595
|
-
content = content.slice(start);
|
|
9596
|
-
const tryParse = (value) => {
|
|
9597
|
-
const errors = [];
|
|
9598
|
-
try {
|
|
9599
|
-
const result = parse2(value, errors, { allowTrailingComma: true });
|
|
9600
|
-
if (errors.length === 0) {
|
|
9601
|
-
return JSON.stringify(result, null, 2);
|
|
9602
|
-
}
|
|
9603
|
-
} catch {
|
|
9604
|
-
}
|
|
9605
|
-
return void 0;
|
|
9606
|
-
};
|
|
9607
|
-
const parsed = tryParse(content);
|
|
9608
|
-
if (parsed !== void 0) {
|
|
9609
|
-
return parsed;
|
|
9610
|
-
}
|
|
9611
|
-
const openChar = content[0];
|
|
9612
|
-
const closeChar = openChar === "{" ? "}" : "]";
|
|
9613
|
-
const closingPositions = [];
|
|
9614
|
-
let depth = 0;
|
|
9615
|
-
let inString = false;
|
|
9616
|
-
let escapeNext = false;
|
|
9617
|
-
for (let i = 0; i < content.length; i++) {
|
|
9618
|
-
const char = content[i];
|
|
9619
|
-
if (escapeNext) {
|
|
9620
|
-
escapeNext = false;
|
|
9621
|
-
continue;
|
|
9622
|
-
}
|
|
9623
|
-
if (char === "\\") {
|
|
9624
|
-
escapeNext = true;
|
|
9625
|
-
continue;
|
|
9626
|
-
}
|
|
9627
|
-
if (char === '"' && !inString) {
|
|
9628
|
-
inString = true;
|
|
9629
|
-
continue;
|
|
9630
|
-
}
|
|
9631
|
-
if (char === '"' && inString) {
|
|
9632
|
-
inString = false;
|
|
9633
|
-
continue;
|
|
9634
|
-
}
|
|
9635
|
-
if (inString) continue;
|
|
9636
|
-
if (char === openChar) {
|
|
9637
|
-
depth++;
|
|
9638
|
-
} else if (char === closeChar) {
|
|
9639
|
-
depth--;
|
|
9640
|
-
if (depth === 0) {
|
|
9641
|
-
closingPositions.push(i + 1);
|
|
9642
|
-
}
|
|
9643
|
-
}
|
|
9644
|
-
}
|
|
9645
|
-
for (let i = closingPositions.length - 1; i >= 0; i--) {
|
|
9646
|
-
const attempt = tryParse(content.slice(0, closingPositions[i]));
|
|
9647
|
-
if (attempt !== void 0) {
|
|
9648
|
-
return attempt;
|
|
9649
|
-
}
|
|
9650
|
-
}
|
|
9651
|
-
const searchStart = Math.max(0, content.length - 1e3);
|
|
9652
|
-
for (let end = content.length - 1; end > searchStart; end--) {
|
|
9653
|
-
const attempt = tryParse(content.slice(0, end));
|
|
9654
|
-
if (attempt !== void 0) {
|
|
9655
|
-
return attempt;
|
|
9656
|
-
}
|
|
9657
|
-
}
|
|
9658
|
-
return text;
|
|
9659
|
-
}
|
|
9660
|
-
function createAPICallError({
|
|
9661
|
-
message,
|
|
9662
|
-
code,
|
|
9663
|
-
exitCode,
|
|
9664
|
-
stderr,
|
|
9665
|
-
promptExcerpt,
|
|
9666
|
-
isRetryable = false
|
|
9667
|
-
}) {
|
|
9668
|
-
const metadata = {
|
|
9669
|
-
code,
|
|
9670
|
-
exitCode,
|
|
9671
|
-
stderr,
|
|
9672
|
-
promptExcerpt
|
|
9673
|
-
};
|
|
9674
|
-
return new APICallError({
|
|
9675
|
-
message,
|
|
9676
|
-
isRetryable,
|
|
9677
|
-
url: "claude-code-cli://command",
|
|
9678
|
-
requestBodyValues: promptExcerpt ? { prompt: promptExcerpt } : void 0,
|
|
9679
|
-
data: metadata
|
|
9680
|
-
});
|
|
9681
|
-
}
|
|
9682
|
-
function createAuthenticationError({
|
|
9683
|
-
message
|
|
9684
|
-
}) {
|
|
9685
|
-
return new LoadAPIKeyError({
|
|
9686
|
-
message: message || "Authentication failed. Please ensure Claude Code SDK is properly authenticated."
|
|
9687
|
-
});
|
|
9688
|
-
}
|
|
9689
|
-
function createTimeoutError({
|
|
9690
|
-
message,
|
|
9691
|
-
promptExcerpt,
|
|
9692
|
-
timeoutMs
|
|
9693
|
-
}) {
|
|
9694
|
-
const metadata = {
|
|
9695
|
-
code: "TIMEOUT",
|
|
9696
|
-
promptExcerpt
|
|
9697
|
-
};
|
|
9698
|
-
return new APICallError({
|
|
9699
|
-
message,
|
|
9700
|
-
isRetryable: true,
|
|
9701
|
-
url: "claude-code-cli://command",
|
|
9702
|
-
requestBodyValues: promptExcerpt ? { prompt: promptExcerpt } : void 0,
|
|
9703
|
-
data: timeoutMs !== void 0 ? { ...metadata, timeoutMs } : metadata
|
|
9704
|
-
});
|
|
9705
|
-
}
|
|
9706
|
-
function mapClaudeCodeFinishReason(subtype) {
|
|
9707
|
-
switch (subtype) {
|
|
9708
|
-
case "success":
|
|
9709
|
-
return "stop";
|
|
9710
|
-
case "error_max_turns":
|
|
9711
|
-
return "length";
|
|
9712
|
-
case "error_during_execution":
|
|
9713
|
-
return "error";
|
|
9714
|
-
default:
|
|
9715
|
-
return "stop";
|
|
9716
|
-
}
|
|
9717
|
-
}
|
|
9718
|
-
var loggerFunctionSchema = import_zod4.z.object({
|
|
9719
|
-
warn: import_zod4.z.any().refine((val) => typeof val === "function", {
|
|
9720
|
-
message: "warn must be a function"
|
|
9721
|
-
}),
|
|
9722
|
-
error: import_zod4.z.any().refine((val) => typeof val === "function", {
|
|
9723
|
-
message: "error must be a function"
|
|
9724
|
-
})
|
|
9725
|
-
});
|
|
9726
|
-
var claudeCodeSettingsSchema = import_zod4.z.object({
|
|
9727
|
-
pathToClaudeCodeExecutable: import_zod4.z.string().optional(),
|
|
9728
|
-
customSystemPrompt: import_zod4.z.string().optional(),
|
|
9729
|
-
appendSystemPrompt: import_zod4.z.string().optional(),
|
|
9730
|
-
maxTurns: import_zod4.z.number().int().min(1).max(100).optional(),
|
|
9731
|
-
maxThinkingTokens: import_zod4.z.number().int().positive().max(1e5).optional(),
|
|
9732
|
-
cwd: import_zod4.z.string().refine(
|
|
9733
|
-
(val) => {
|
|
9734
|
-
if (typeof process === "undefined" || !process.versions?.node) {
|
|
9735
|
-
return true;
|
|
9736
|
-
}
|
|
9737
|
-
return !val || (0, import_fs2.existsSync)(val);
|
|
9738
|
-
},
|
|
9739
|
-
{ message: "Working directory must exist" }
|
|
9740
|
-
).optional(),
|
|
9741
|
-
executable: import_zod4.z.enum(["bun", "deno", "node"]).optional(),
|
|
9742
|
-
executableArgs: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
9743
|
-
permissionMode: import_zod4.z.enum(["default", "acceptEdits", "bypassPermissions", "plan"]).optional(),
|
|
9744
|
-
permissionPromptToolName: import_zod4.z.string().optional(),
|
|
9745
|
-
continue: import_zod4.z.boolean().optional(),
|
|
9746
|
-
resume: import_zod4.z.string().optional(),
|
|
9747
|
-
allowedTools: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
9748
|
-
disallowedTools: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
9749
|
-
mcpServers: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.union([
|
|
9750
|
-
// McpStdioServerConfig
|
|
9751
|
-
import_zod4.z.object({
|
|
9752
|
-
type: import_zod4.z.literal("stdio").optional(),
|
|
9753
|
-
command: import_zod4.z.string(),
|
|
9754
|
-
args: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
9755
|
-
env: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.string()).optional()
|
|
9756
|
-
}),
|
|
9757
|
-
// McpSSEServerConfig
|
|
9758
|
-
import_zod4.z.object({
|
|
9759
|
-
type: import_zod4.z.literal("sse"),
|
|
9760
|
-
url: import_zod4.z.string(),
|
|
9761
|
-
headers: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.string()).optional()
|
|
9762
|
-
})
|
|
9763
|
-
])).optional(),
|
|
9764
|
-
verbose: import_zod4.z.boolean().optional(),
|
|
9765
|
-
logger: import_zod4.z.union([
|
|
9766
|
-
import_zod4.z.literal(false),
|
|
9767
|
-
loggerFunctionSchema
|
|
9768
|
-
]).optional()
|
|
9769
|
-
}).strict();
|
|
9770
|
-
function validateModelId(modelId) {
|
|
9771
|
-
const knownModels = ["opus", "sonnet"];
|
|
9772
|
-
if (!modelId || modelId.trim() === "") {
|
|
9773
|
-
throw new Error("Model ID cannot be empty");
|
|
9774
|
-
}
|
|
9775
|
-
if (!knownModels.includes(modelId)) {
|
|
9776
|
-
return `Unknown model ID: '${modelId}'. Proceeding with custom model. Known models are: ${knownModels.join(", ")}`;
|
|
9777
|
-
}
|
|
9778
|
-
return void 0;
|
|
9779
|
-
}
|
|
9780
|
-
function validateSettings(settings) {
|
|
9781
|
-
const warnings = [];
|
|
9782
|
-
const errors = [];
|
|
9783
|
-
try {
|
|
9784
|
-
const result = claudeCodeSettingsSchema.safeParse(settings);
|
|
9785
|
-
if (!result.success) {
|
|
9786
|
-
const errorObject = result.error;
|
|
9787
|
-
const issues = errorObject.errors || errorObject.issues || [];
|
|
9788
|
-
issues.forEach((err) => {
|
|
9789
|
-
const path = err.path.join(".");
|
|
9790
|
-
errors.push(`${path ? `${path}: ` : ""}${err.message}`);
|
|
9791
|
-
});
|
|
9792
|
-
return { valid: false, warnings, errors };
|
|
9793
|
-
}
|
|
9794
|
-
const validSettings = result.data;
|
|
9795
|
-
if (validSettings.maxTurns && validSettings.maxTurns > 20) {
|
|
9796
|
-
warnings.push(`High maxTurns value (${validSettings.maxTurns}) may lead to long-running conversations`);
|
|
9797
|
-
}
|
|
9798
|
-
if (validSettings.maxThinkingTokens && validSettings.maxThinkingTokens > 5e4) {
|
|
9799
|
-
warnings.push(`Very high maxThinkingTokens (${validSettings.maxThinkingTokens}) may increase response time`);
|
|
9800
|
-
}
|
|
9801
|
-
if (validSettings.allowedTools && validSettings.disallowedTools) {
|
|
9802
|
-
warnings.push("Both allowedTools and disallowedTools are specified. Only allowedTools will be used.");
|
|
9803
|
-
}
|
|
9804
|
-
const validateToolNames = (tools, type) => {
|
|
9805
|
-
tools.forEach((tool2) => {
|
|
9806
|
-
if (!/^[a-zA-Z_][a-zA-Z0-9_]*(\([^)]*\))?$/.test(tool2) && !tool2.startsWith("mcp__")) {
|
|
9807
|
-
warnings.push(`Unusual ${type} tool name format: '${tool2}'`);
|
|
9808
|
-
}
|
|
9809
|
-
});
|
|
9810
|
-
};
|
|
9811
|
-
if (validSettings.allowedTools) {
|
|
9812
|
-
validateToolNames(validSettings.allowedTools, "allowed");
|
|
9813
|
-
}
|
|
9814
|
-
if (validSettings.disallowedTools) {
|
|
9815
|
-
validateToolNames(validSettings.disallowedTools, "disallowed");
|
|
9816
|
-
}
|
|
9817
|
-
return { valid: true, warnings, errors };
|
|
9818
|
-
} catch (error) {
|
|
9819
|
-
errors.push(`Validation error: ${error instanceof Error ? error.message : String(error)}`);
|
|
9820
|
-
return { valid: false, warnings, errors };
|
|
9821
|
-
}
|
|
9822
|
-
}
|
|
9823
|
-
function validatePrompt(prompt) {
|
|
9824
|
-
const MAX_PROMPT_LENGTH = 1e5;
|
|
9825
|
-
if (prompt.length > MAX_PROMPT_LENGTH) {
|
|
9826
|
-
return `Very long prompt (${prompt.length} characters) may cause performance issues or timeouts`;
|
|
9827
|
-
}
|
|
9828
|
-
return void 0;
|
|
9829
|
-
}
|
|
9830
|
-
function validateSessionId(sessionId) {
|
|
9831
|
-
if (sessionId && !/^[a-zA-Z0-9-_]+$/.test(sessionId)) {
|
|
9832
|
-
return `Unusual session ID format. This may cause issues with session resumption.`;
|
|
9833
|
-
}
|
|
9834
|
-
return void 0;
|
|
9835
|
-
}
|
|
9836
|
-
var defaultLogger = {
|
|
9837
|
-
warn: (message) => console.warn(message),
|
|
9838
|
-
error: (message) => console.error(message)
|
|
9839
|
-
};
|
|
9840
|
-
var noopLogger = {
|
|
9841
|
-
warn: () => {
|
|
9842
|
-
},
|
|
9843
|
-
error: () => {
|
|
9844
|
-
}
|
|
9845
|
-
};
|
|
9846
|
-
function getLogger(logger) {
|
|
9847
|
-
if (logger === false) {
|
|
9848
|
-
return noopLogger;
|
|
9849
|
-
}
|
|
9850
|
-
if (logger === void 0) {
|
|
9851
|
-
return defaultLogger;
|
|
9852
|
-
}
|
|
9853
|
-
return logger;
|
|
9854
|
-
}
|
|
9855
|
-
var modelMap = {
|
|
9856
|
-
"opus": "opus",
|
|
9857
|
-
"sonnet": "sonnet"
|
|
9858
|
-
};
|
|
9859
|
-
var ClaudeCodeLanguageModel = class {
|
|
9860
|
-
specificationVersion = "v2";
|
|
9861
|
-
defaultObjectGenerationMode = "json";
|
|
9862
|
-
supportsImageUrls = false;
|
|
9863
|
-
supportedUrls = {};
|
|
9864
|
-
supportsStructuredOutputs = false;
|
|
9865
|
-
modelId;
|
|
9866
|
-
settings;
|
|
9867
|
-
sessionId;
|
|
9868
|
-
modelValidationWarning;
|
|
9869
|
-
settingsValidationWarnings;
|
|
9870
|
-
logger;
|
|
9871
|
-
constructor(options) {
|
|
9872
|
-
this.modelId = options.id;
|
|
9873
|
-
this.settings = options.settings ?? {};
|
|
9874
|
-
this.settingsValidationWarnings = options.settingsValidationWarnings ?? [];
|
|
9875
|
-
this.logger = getLogger(this.settings.logger);
|
|
9876
|
-
if (!this.modelId || typeof this.modelId !== "string" || this.modelId.trim() === "") {
|
|
9877
|
-
throw new NoSuchModelError({
|
|
9878
|
-
modelId: this.modelId,
|
|
9879
|
-
modelType: "languageModel"
|
|
9880
|
-
});
|
|
9881
|
-
}
|
|
9882
|
-
this.modelValidationWarning = validateModelId(this.modelId);
|
|
9883
|
-
if (this.modelValidationWarning) {
|
|
9884
|
-
this.logger.warn(`Claude Code Model: ${this.modelValidationWarning}`);
|
|
9885
|
-
}
|
|
9886
|
-
}
|
|
9887
|
-
get provider() {
|
|
9888
|
-
return "claude-code";
|
|
9889
|
-
}
|
|
9890
|
-
getModel() {
|
|
9891
|
-
const mapped = modelMap[this.modelId];
|
|
9892
|
-
return mapped ?? this.modelId;
|
|
9893
|
-
}
|
|
9894
|
-
generateAllWarnings(options, prompt) {
|
|
9895
|
-
const warnings = [];
|
|
9896
|
-
const unsupportedParams = [];
|
|
9897
|
-
if (options.temperature !== void 0) unsupportedParams.push("temperature");
|
|
9898
|
-
if (options.topP !== void 0) unsupportedParams.push("topP");
|
|
9899
|
-
if (options.topK !== void 0) unsupportedParams.push("topK");
|
|
9900
|
-
if (options.presencePenalty !== void 0) unsupportedParams.push("presencePenalty");
|
|
9901
|
-
if (options.frequencyPenalty !== void 0) unsupportedParams.push("frequencyPenalty");
|
|
9902
|
-
if (options.stopSequences !== void 0 && options.stopSequences.length > 0) unsupportedParams.push("stopSequences");
|
|
9903
|
-
if (options.seed !== void 0) unsupportedParams.push("seed");
|
|
9904
|
-
if (unsupportedParams.length > 0) {
|
|
9905
|
-
for (const param of unsupportedParams) {
|
|
9906
|
-
warnings.push({
|
|
9907
|
-
type: "unsupported-setting",
|
|
9908
|
-
setting: param,
|
|
9909
|
-
details: `Claude Code SDK does not support the ${param} parameter. It will be ignored.`
|
|
9910
|
-
});
|
|
9911
|
-
}
|
|
9912
|
-
}
|
|
9913
|
-
if (this.modelValidationWarning) {
|
|
9914
|
-
warnings.push({
|
|
9915
|
-
type: "other",
|
|
9916
|
-
message: this.modelValidationWarning
|
|
9917
|
-
});
|
|
9918
|
-
}
|
|
9919
|
-
this.settingsValidationWarnings.forEach((warning) => {
|
|
9920
|
-
warnings.push({
|
|
9921
|
-
type: "other",
|
|
9922
|
-
message: warning
|
|
9923
|
-
});
|
|
9924
|
-
});
|
|
9925
|
-
const promptWarning = validatePrompt(prompt);
|
|
9926
|
-
if (promptWarning) {
|
|
9927
|
-
warnings.push({
|
|
9928
|
-
type: "other",
|
|
9929
|
-
message: promptWarning
|
|
9930
|
-
});
|
|
9931
|
-
}
|
|
9932
|
-
return warnings;
|
|
9933
|
-
}
|
|
9934
|
-
createQueryOptions(abortController) {
|
|
9935
|
-
return {
|
|
9936
|
-
model: this.getModel(),
|
|
9937
|
-
abortController,
|
|
9938
|
-
resume: this.settings.resume ?? this.sessionId,
|
|
9939
|
-
pathToClaudeCodeExecutable: this.settings.pathToClaudeCodeExecutable,
|
|
9940
|
-
customSystemPrompt: this.settings.customSystemPrompt,
|
|
9941
|
-
appendSystemPrompt: this.settings.appendSystemPrompt,
|
|
9942
|
-
maxTurns: this.settings.maxTurns,
|
|
9943
|
-
maxThinkingTokens: this.settings.maxThinkingTokens,
|
|
9944
|
-
cwd: this.settings.cwd,
|
|
9945
|
-
executable: this.settings.executable,
|
|
9946
|
-
executableArgs: this.settings.executableArgs,
|
|
9947
|
-
permissionMode: this.settings.permissionMode,
|
|
9948
|
-
permissionPromptToolName: this.settings.permissionPromptToolName,
|
|
9949
|
-
continue: this.settings.continue,
|
|
9950
|
-
allowedTools: this.settings.allowedTools,
|
|
9951
|
-
disallowedTools: this.settings.disallowedTools,
|
|
9952
|
-
mcpServers: this.settings.mcpServers
|
|
9953
|
-
};
|
|
9954
|
-
}
|
|
9955
|
-
handleClaudeCodeError(error, messagesPrompt) {
|
|
9956
|
-
if (error instanceof AbortError) {
|
|
9957
|
-
throw error;
|
|
9958
|
-
}
|
|
9959
|
-
const isErrorWithMessage = (err) => {
|
|
9960
|
-
return typeof err === "object" && err !== null && "message" in err;
|
|
9961
|
-
};
|
|
9962
|
-
const isErrorWithCode = (err) => {
|
|
9963
|
-
return typeof err === "object" && err !== null;
|
|
9964
|
-
};
|
|
9965
|
-
const authErrorPatterns = [
|
|
9966
|
-
"not logged in",
|
|
9967
|
-
"authentication",
|
|
9968
|
-
"unauthorized",
|
|
9969
|
-
"auth failed",
|
|
9970
|
-
"please login",
|
|
9971
|
-
"claude login"
|
|
9972
|
-
];
|
|
9973
|
-
const errorMessage = isErrorWithMessage(error) && error.message ? error.message.toLowerCase() : "";
|
|
9974
|
-
const exitCode = isErrorWithCode(error) && typeof error.exitCode === "number" ? error.exitCode : void 0;
|
|
9975
|
-
const isAuthError = authErrorPatterns.some((pattern) => errorMessage.includes(pattern)) || exitCode === 401;
|
|
9976
|
-
if (isAuthError) {
|
|
9977
|
-
return createAuthenticationError({
|
|
9978
|
-
message: isErrorWithMessage(error) && error.message ? error.message : "Authentication failed. Please ensure Claude Code SDK is properly authenticated."
|
|
9979
|
-
});
|
|
9980
|
-
}
|
|
9981
|
-
const errorCode = isErrorWithCode(error) && typeof error.code === "string" ? error.code : "";
|
|
9982
|
-
if (errorCode === "ETIMEDOUT" || errorMessage.includes("timeout")) {
|
|
9983
|
-
return createTimeoutError({
|
|
9984
|
-
message: isErrorWithMessage(error) && error.message ? error.message : "Request timed out",
|
|
9985
|
-
promptExcerpt: messagesPrompt.substring(0, 200)
|
|
9986
|
-
// Don't specify timeoutMs since we don't know the actual timeout value
|
|
9987
|
-
// It's controlled by the consumer via AbortSignal
|
|
9988
|
-
});
|
|
9989
|
-
}
|
|
9990
|
-
const isRetryable = errorCode === "ENOENT" || errorCode === "ECONNREFUSED" || errorCode === "ETIMEDOUT" || errorCode === "ECONNRESET";
|
|
9991
|
-
return createAPICallError({
|
|
9992
|
-
message: isErrorWithMessage(error) && error.message ? error.message : "Claude Code SDK error",
|
|
9993
|
-
code: errorCode || void 0,
|
|
9994
|
-
exitCode,
|
|
9995
|
-
stderr: isErrorWithCode(error) && typeof error.stderr === "string" ? error.stderr : void 0,
|
|
9996
|
-
promptExcerpt: messagesPrompt.substring(0, 200),
|
|
9997
|
-
isRetryable
|
|
9998
|
-
});
|
|
9999
|
-
}
|
|
10000
|
-
setSessionId(sessionId) {
|
|
10001
|
-
this.sessionId = sessionId;
|
|
10002
|
-
const warning = validateSessionId(sessionId);
|
|
10003
|
-
if (warning) {
|
|
10004
|
-
this.logger.warn(`Claude Code Session: ${warning}`);
|
|
10005
|
-
}
|
|
10006
|
-
}
|
|
10007
|
-
validateJsonExtraction(originalText, extractedJson) {
|
|
10008
|
-
if (extractedJson === originalText) {
|
|
10009
|
-
return {
|
|
10010
|
-
valid: false,
|
|
10011
|
-
warning: {
|
|
10012
|
-
type: "other",
|
|
10013
|
-
message: "JSON extraction from model response may be incomplete or modified. The model may not have returned valid JSON."
|
|
10014
|
-
}
|
|
10015
|
-
};
|
|
10016
|
-
}
|
|
10017
|
-
try {
|
|
10018
|
-
JSON.parse(extractedJson);
|
|
10019
|
-
return { valid: true };
|
|
10020
|
-
} catch {
|
|
10021
|
-
return {
|
|
10022
|
-
valid: false,
|
|
10023
|
-
warning: {
|
|
10024
|
-
type: "other",
|
|
10025
|
-
message: "JSON extraction resulted in invalid JSON. The response may be malformed."
|
|
10026
|
-
}
|
|
10027
|
-
};
|
|
10028
|
-
}
|
|
10029
|
-
}
|
|
10030
|
-
async doGenerate(options) {
|
|
10031
|
-
const mode = options.responseFormat?.type === "json" ? { type: "object-json" } : { type: "regular" };
|
|
10032
|
-
const { messagesPrompt, warnings: messageWarnings } = convertToClaudeCodeMessages(
|
|
10033
|
-
options.prompt,
|
|
10034
|
-
mode,
|
|
10035
|
-
options.responseFormat?.type === "json" ? options.responseFormat.schema : void 0
|
|
10036
|
-
);
|
|
10037
|
-
const abortController = new AbortController();
|
|
10038
|
-
let abortListener;
|
|
10039
|
-
if (options.abortSignal) {
|
|
10040
|
-
abortListener = () => abortController.abort();
|
|
10041
|
-
options.abortSignal.addEventListener("abort", abortListener, { once: true });
|
|
10042
|
-
}
|
|
10043
|
-
const queryOptions = this.createQueryOptions(abortController);
|
|
10044
|
-
let text = "";
|
|
10045
|
-
let usage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
10046
|
-
let finishReason = "stop";
|
|
10047
|
-
let costUsd;
|
|
10048
|
-
let durationMs;
|
|
10049
|
-
let rawUsage;
|
|
10050
|
-
const warnings = this.generateAllWarnings(options, messagesPrompt);
|
|
10051
|
-
if (messageWarnings) {
|
|
10052
|
-
messageWarnings.forEach((warning) => {
|
|
10053
|
-
warnings.push({
|
|
10054
|
-
type: "other",
|
|
10055
|
-
message: warning
|
|
10056
|
-
});
|
|
10057
|
-
});
|
|
10058
|
-
}
|
|
10059
|
-
try {
|
|
10060
|
-
const response = query({
|
|
10061
|
-
prompt: messagesPrompt,
|
|
10062
|
-
options: queryOptions
|
|
10063
|
-
});
|
|
10064
|
-
for await (const message of response) {
|
|
10065
|
-
if (message.type === "assistant") {
|
|
10066
|
-
text += message.message.content.map(
|
|
10067
|
-
(c) => c.type === "text" ? c.text : ""
|
|
10068
|
-
).join("");
|
|
10069
|
-
} else if (message.type === "result") {
|
|
10070
|
-
this.setSessionId(message.session_id);
|
|
10071
|
-
costUsd = message.total_cost_usd;
|
|
10072
|
-
durationMs = message.duration_ms;
|
|
10073
|
-
if ("usage" in message) {
|
|
10074
|
-
rawUsage = message.usage;
|
|
10075
|
-
usage = {
|
|
10076
|
-
inputTokens: (message.usage.cache_creation_input_tokens ?? 0) + (message.usage.cache_read_input_tokens ?? 0) + (message.usage.input_tokens ?? 0),
|
|
10077
|
-
outputTokens: message.usage.output_tokens ?? 0,
|
|
10078
|
-
totalTokens: (message.usage.cache_creation_input_tokens ?? 0) + (message.usage.cache_read_input_tokens ?? 0) + (message.usage.input_tokens ?? 0) + (message.usage.output_tokens ?? 0)
|
|
10079
|
-
};
|
|
10080
|
-
}
|
|
10081
|
-
finishReason = mapClaudeCodeFinishReason(message.subtype);
|
|
10082
|
-
} else if (message.type === "system" && message.subtype === "init") {
|
|
10083
|
-
this.setSessionId(message.session_id);
|
|
10084
|
-
}
|
|
10085
|
-
}
|
|
10086
|
-
} catch (error) {
|
|
10087
|
-
if (error instanceof AbortError) {
|
|
10088
|
-
throw options.abortSignal?.aborted ? options.abortSignal.reason : error;
|
|
10089
|
-
}
|
|
10090
|
-
throw this.handleClaudeCodeError(error, messagesPrompt);
|
|
10091
|
-
} finally {
|
|
10092
|
-
if (options.abortSignal && abortListener) {
|
|
10093
|
-
options.abortSignal.removeEventListener("abort", abortListener);
|
|
10094
|
-
}
|
|
10095
|
-
}
|
|
10096
|
-
if (options.responseFormat?.type === "json" && text) {
|
|
10097
|
-
const extracted = extractJson(text);
|
|
10098
|
-
const validation = this.validateJsonExtraction(text, extracted);
|
|
10099
|
-
if (!validation.valid && validation.warning) {
|
|
10100
|
-
warnings.push(validation.warning);
|
|
10101
|
-
}
|
|
10102
|
-
text = extracted;
|
|
10103
|
-
}
|
|
10104
|
-
return {
|
|
10105
|
-
content: [{ type: "text", text }],
|
|
10106
|
-
usage,
|
|
10107
|
-
finishReason,
|
|
10108
|
-
warnings,
|
|
10109
|
-
response: {
|
|
10110
|
-
id: generateId2(),
|
|
10111
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
10112
|
-
modelId: this.modelId
|
|
10113
|
-
},
|
|
10114
|
-
request: {
|
|
10115
|
-
body: messagesPrompt
|
|
10116
|
-
},
|
|
10117
|
-
providerMetadata: {
|
|
10118
|
-
"claude-code": {
|
|
10119
|
-
...this.sessionId !== void 0 && { sessionId: this.sessionId },
|
|
10120
|
-
...costUsd !== void 0 && { costUsd },
|
|
10121
|
-
...durationMs !== void 0 && { durationMs },
|
|
10122
|
-
...rawUsage !== void 0 && { rawUsage }
|
|
10123
|
-
}
|
|
10124
|
-
}
|
|
10125
|
-
};
|
|
10126
|
-
}
|
|
10127
|
-
async doStream(options) {
|
|
10128
|
-
const mode = options.responseFormat?.type === "json" ? { type: "object-json" } : { type: "regular" };
|
|
10129
|
-
const { messagesPrompt, warnings: messageWarnings } = convertToClaudeCodeMessages(
|
|
10130
|
-
options.prompt,
|
|
10131
|
-
mode,
|
|
10132
|
-
options.responseFormat?.type === "json" ? options.responseFormat.schema : void 0
|
|
10133
|
-
);
|
|
10134
|
-
const abortController = new AbortController();
|
|
10135
|
-
let abortListener;
|
|
10136
|
-
if (options.abortSignal) {
|
|
10137
|
-
abortListener = () => abortController.abort();
|
|
10138
|
-
options.abortSignal.addEventListener("abort", abortListener, { once: true });
|
|
10139
|
-
}
|
|
10140
|
-
const queryOptions = this.createQueryOptions(abortController);
|
|
10141
|
-
const warnings = this.generateAllWarnings(options, messagesPrompt);
|
|
10142
|
-
if (messageWarnings) {
|
|
10143
|
-
messageWarnings.forEach((warning) => {
|
|
10144
|
-
warnings.push({
|
|
10145
|
-
type: "other",
|
|
10146
|
-
message: warning
|
|
10147
|
-
});
|
|
10148
|
-
});
|
|
10149
|
-
}
|
|
10150
|
-
const stream = new ReadableStream({
|
|
10151
|
-
start: async (controller) => {
|
|
10152
|
-
try {
|
|
10153
|
-
controller.enqueue({ type: "stream-start", warnings });
|
|
10154
|
-
const response = query({
|
|
10155
|
-
prompt: messagesPrompt,
|
|
10156
|
-
options: queryOptions
|
|
10157
|
-
});
|
|
10158
|
-
let usage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
10159
|
-
let accumulatedText = "";
|
|
10160
|
-
let textPartId;
|
|
10161
|
-
for await (const message of response) {
|
|
10162
|
-
if (message.type === "assistant") {
|
|
10163
|
-
const text = message.message.content.map((c) => c.type === "text" ? c.text : "").join("");
|
|
10164
|
-
if (text) {
|
|
10165
|
-
accumulatedText += text;
|
|
10166
|
-
if (options.responseFormat?.type !== "json") {
|
|
10167
|
-
if (!textPartId) {
|
|
10168
|
-
textPartId = generateId2();
|
|
10169
|
-
controller.enqueue({
|
|
10170
|
-
type: "text-start",
|
|
10171
|
-
id: textPartId
|
|
10172
|
-
});
|
|
10173
|
-
}
|
|
10174
|
-
controller.enqueue({
|
|
10175
|
-
type: "text-delta",
|
|
10176
|
-
id: textPartId,
|
|
10177
|
-
delta: text
|
|
10178
|
-
});
|
|
10179
|
-
}
|
|
10180
|
-
}
|
|
10181
|
-
} else if (message.type === "result") {
|
|
10182
|
-
let rawUsage;
|
|
10183
|
-
if ("usage" in message) {
|
|
10184
|
-
rawUsage = message.usage;
|
|
10185
|
-
usage = {
|
|
10186
|
-
inputTokens: (message.usage.cache_creation_input_tokens ?? 0) + (message.usage.cache_read_input_tokens ?? 0) + (message.usage.input_tokens ?? 0),
|
|
10187
|
-
outputTokens: message.usage.output_tokens ?? 0,
|
|
10188
|
-
totalTokens: (message.usage.cache_creation_input_tokens ?? 0) + (message.usage.cache_read_input_tokens ?? 0) + (message.usage.input_tokens ?? 0) + (message.usage.output_tokens ?? 0)
|
|
10189
|
-
};
|
|
10190
|
-
}
|
|
10191
|
-
const finishReason = mapClaudeCodeFinishReason(message.subtype);
|
|
10192
|
-
this.setSessionId(message.session_id);
|
|
10193
|
-
if (options.responseFormat?.type === "json" && accumulatedText) {
|
|
10194
|
-
const extractedJson = extractJson(accumulatedText);
|
|
10195
|
-
this.validateJsonExtraction(accumulatedText, extractedJson);
|
|
10196
|
-
const jsonTextId = generateId2();
|
|
10197
|
-
controller.enqueue({
|
|
10198
|
-
type: "text-start",
|
|
10199
|
-
id: jsonTextId
|
|
10200
|
-
});
|
|
10201
|
-
controller.enqueue({
|
|
10202
|
-
type: "text-delta",
|
|
10203
|
-
id: jsonTextId,
|
|
10204
|
-
delta: extractedJson
|
|
10205
|
-
});
|
|
10206
|
-
controller.enqueue({
|
|
10207
|
-
type: "text-end",
|
|
10208
|
-
id: jsonTextId
|
|
10209
|
-
});
|
|
10210
|
-
} else if (textPartId) {
|
|
10211
|
-
controller.enqueue({
|
|
10212
|
-
type: "text-end",
|
|
10213
|
-
id: textPartId
|
|
10214
|
-
});
|
|
10215
|
-
}
|
|
10216
|
-
controller.enqueue({
|
|
10217
|
-
type: "finish",
|
|
10218
|
-
finishReason,
|
|
10219
|
-
usage,
|
|
10220
|
-
providerMetadata: {
|
|
10221
|
-
"claude-code": {
|
|
10222
|
-
sessionId: message.session_id,
|
|
10223
|
-
...message.total_cost_usd !== void 0 && { costUsd: message.total_cost_usd },
|
|
10224
|
-
...message.duration_ms !== void 0 && { durationMs: message.duration_ms },
|
|
10225
|
-
...rawUsage !== void 0 && { rawUsage }
|
|
10226
|
-
}
|
|
10227
|
-
}
|
|
10228
|
-
});
|
|
10229
|
-
} else if (message.type === "system" && message.subtype === "init") {
|
|
10230
|
-
this.setSessionId(message.session_id);
|
|
10231
|
-
controller.enqueue({
|
|
10232
|
-
type: "response-metadata",
|
|
10233
|
-
id: message.session_id,
|
|
10234
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
10235
|
-
modelId: this.modelId
|
|
10236
|
-
});
|
|
10237
|
-
}
|
|
10238
|
-
}
|
|
10239
|
-
controller.close();
|
|
10240
|
-
} catch (error) {
|
|
10241
|
-
let errorToEmit;
|
|
10242
|
-
if (error instanceof AbortError) {
|
|
10243
|
-
errorToEmit = options.abortSignal?.aborted ? options.abortSignal.reason : error;
|
|
10244
|
-
} else {
|
|
10245
|
-
errorToEmit = this.handleClaudeCodeError(error, messagesPrompt);
|
|
10246
|
-
}
|
|
10247
|
-
controller.enqueue({
|
|
10248
|
-
type: "error",
|
|
10249
|
-
error: errorToEmit
|
|
10250
|
-
});
|
|
10251
|
-
controller.close();
|
|
10252
|
-
} finally {
|
|
10253
|
-
if (options.abortSignal && abortListener) {
|
|
10254
|
-
options.abortSignal.removeEventListener("abort", abortListener);
|
|
10255
|
-
}
|
|
10256
|
-
}
|
|
10257
|
-
},
|
|
10258
|
-
cancel: () => {
|
|
10259
|
-
if (options.abortSignal && abortListener) {
|
|
10260
|
-
options.abortSignal.removeEventListener("abort", abortListener);
|
|
10261
|
-
}
|
|
10262
|
-
}
|
|
10263
|
-
});
|
|
10264
|
-
return {
|
|
10265
|
-
stream,
|
|
10266
|
-
request: {
|
|
10267
|
-
body: messagesPrompt
|
|
10268
|
-
}
|
|
10269
|
-
};
|
|
10270
|
-
}
|
|
10271
|
-
};
|
|
10272
|
-
function createClaudeCode(options = {}) {
|
|
10273
|
-
const logger = getLogger(options.defaultSettings?.logger);
|
|
10274
|
-
if (options.defaultSettings) {
|
|
10275
|
-
const validation = validateSettings(options.defaultSettings);
|
|
10276
|
-
if (!validation.valid) {
|
|
10277
|
-
throw new Error(`Invalid default settings: ${validation.errors.join(", ")}`);
|
|
10278
|
-
}
|
|
10279
|
-
if (validation.warnings.length > 0) {
|
|
10280
|
-
validation.warnings.forEach((warning) => logger.warn(`Claude Code Provider: ${warning}`));
|
|
10281
|
-
}
|
|
10282
|
-
}
|
|
10283
|
-
const createModel = (modelId, settings = {}) => {
|
|
10284
|
-
const mergedSettings = {
|
|
10285
|
-
...options.defaultSettings,
|
|
10286
|
-
...settings
|
|
10287
|
-
};
|
|
10288
|
-
const validation = validateSettings(mergedSettings);
|
|
10289
|
-
if (!validation.valid) {
|
|
10290
|
-
throw new Error(`Invalid settings: ${validation.errors.join(", ")}`);
|
|
10291
|
-
}
|
|
10292
|
-
return new ClaudeCodeLanguageModel({
|
|
10293
|
-
id: modelId,
|
|
10294
|
-
settings: mergedSettings,
|
|
10295
|
-
settingsValidationWarnings: validation.warnings
|
|
10296
|
-
});
|
|
10297
|
-
};
|
|
10298
|
-
const provider = function(modelId, settings) {
|
|
10299
|
-
if (new.target) {
|
|
10300
|
-
throw new Error(
|
|
10301
|
-
"The Claude Code model function cannot be called with the new keyword."
|
|
10302
|
-
);
|
|
10303
|
-
}
|
|
10304
|
-
return createModel(modelId, settings);
|
|
10305
|
-
};
|
|
10306
|
-
provider.languageModel = createModel;
|
|
10307
|
-
provider.chat = createModel;
|
|
10308
|
-
provider.textEmbeddingModel = (modelId) => {
|
|
10309
|
-
throw new NoSuchModelError({
|
|
10310
|
-
modelId,
|
|
10311
|
-
modelType: "textEmbeddingModel"
|
|
10312
|
-
});
|
|
10313
|
-
};
|
|
10314
|
-
provider.imageModel = (modelId) => {
|
|
10315
|
-
throw new NoSuchModelError({
|
|
10316
|
-
modelId,
|
|
10317
|
-
modelType: "imageModel"
|
|
10318
|
-
});
|
|
10319
|
-
};
|
|
10320
|
-
return provider;
|
|
10321
|
-
}
|
|
10322
|
-
var claudeCode = createClaudeCode();
|
|
10323
|
-
|
|
10324
8184
|
// src/provider.ts
|
|
8185
|
+
var import_ai_sdk_provider_claude_code = require("ai-sdk-provider-claude-code");
|
|
10325
8186
|
var PROVIDERS = [
|
|
10326
8187
|
"anthropic",
|
|
10327
8188
|
"google",
|
|
@@ -10352,7 +8213,7 @@ async function getModel(provider, apiKey, cwd) {
|
|
|
10352
8213
|
});
|
|
10353
8214
|
return openai2(SOTA[provider]);
|
|
10354
8215
|
case "claude_code":
|
|
10355
|
-
const customProvider = createClaudeCode({
|
|
8216
|
+
const customProvider = (0, import_ai_sdk_provider_claude_code.createClaudeCode)({
|
|
10356
8217
|
defaultSettings: {
|
|
10357
8218
|
// Skip permission prompts for all operations
|
|
10358
8219
|
permissionMode: "bypassPermissions",
|
|
@@ -10360,6 +8221,9 @@ async function getModel(provider, apiKey, cwd) {
|
|
|
10360
8221
|
cwd
|
|
10361
8222
|
}
|
|
10362
8223
|
});
|
|
8224
|
+
if (cwd) {
|
|
8225
|
+
console.log("creating claude code model at", cwd);
|
|
8226
|
+
}
|
|
10363
8227
|
return customProvider(SOTA[provider]);
|
|
10364
8228
|
default:
|
|
10365
8229
|
throw new Error(`Unsupported provider: ${provider}`);
|