@polka-codes/core 0.4.2 → 0.4.3
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.js +1127 -480
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __export = (target, all) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// ../../node_modules/@anthropic-ai/sdk/version.mjs
|
|
13
|
-
var VERSION = "0.
|
|
13
|
+
var VERSION = "0.36.2";
|
|
14
14
|
|
|
15
15
|
// ../../node_modules/@anthropic-ai/sdk/_shims/registry.mjs
|
|
16
16
|
var auto = false;
|
|
@@ -295,6 +295,35 @@ LineDecoder.NEWLINE_CHARS = new Set([`
|
|
|
295
295
|
`, "\r"]);
|
|
296
296
|
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
297
297
|
|
|
298
|
+
// ../../node_modules/@anthropic-ai/sdk/internal/stream-utils.mjs
|
|
299
|
+
function ReadableStreamToAsyncIterable(stream) {
|
|
300
|
+
if (stream[Symbol.asyncIterator])
|
|
301
|
+
return stream;
|
|
302
|
+
const reader = stream.getReader();
|
|
303
|
+
return {
|
|
304
|
+
async next() {
|
|
305
|
+
try {
|
|
306
|
+
const result = await reader.read();
|
|
307
|
+
if (result?.done)
|
|
308
|
+
reader.releaseLock();
|
|
309
|
+
return result;
|
|
310
|
+
} catch (e) {
|
|
311
|
+
reader.releaseLock();
|
|
312
|
+
throw e;
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
async return() {
|
|
316
|
+
const cancelPromise = reader.cancel();
|
|
317
|
+
reader.releaseLock();
|
|
318
|
+
await cancelPromise;
|
|
319
|
+
return { done: true, value: undefined };
|
|
320
|
+
},
|
|
321
|
+
[Symbol.asyncIterator]() {
|
|
322
|
+
return this;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
298
327
|
// ../../node_modules/@anthropic-ai/sdk/streaming.mjs
|
|
299
328
|
class Stream {
|
|
300
329
|
constructor(iterator, controller) {
|
|
@@ -352,7 +381,7 @@ class Stream {
|
|
|
352
381
|
let consumed = false;
|
|
353
382
|
async function* iterLines() {
|
|
354
383
|
const lineDecoder = new LineDecoder;
|
|
355
|
-
const iter =
|
|
384
|
+
const iter = ReadableStreamToAsyncIterable(readableStream);
|
|
356
385
|
for await (const chunk of iter) {
|
|
357
386
|
for (const line of lineDecoder.decode(chunk)) {
|
|
358
387
|
yield line;
|
|
@@ -444,7 +473,7 @@ async function* _iterSSEMessages(response, controller) {
|
|
|
444
473
|
}
|
|
445
474
|
const sseDecoder = new SSEDecoder;
|
|
446
475
|
const lineDecoder = new LineDecoder;
|
|
447
|
-
const iter =
|
|
476
|
+
const iter = ReadableStreamToAsyncIterable(response.body);
|
|
448
477
|
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
449
478
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
450
479
|
const sse = sseDecoder.decode(line);
|
|
@@ -543,33 +572,6 @@ function partition(str, delimiter) {
|
|
|
543
572
|
}
|
|
544
573
|
return [str, "", ""];
|
|
545
574
|
}
|
|
546
|
-
function readableStreamAsyncIterable(stream) {
|
|
547
|
-
if (stream[Symbol.asyncIterator])
|
|
548
|
-
return stream;
|
|
549
|
-
const reader = stream.getReader();
|
|
550
|
-
return {
|
|
551
|
-
async next() {
|
|
552
|
-
try {
|
|
553
|
-
const result = await reader.read();
|
|
554
|
-
if (result?.done)
|
|
555
|
-
reader.releaseLock();
|
|
556
|
-
return result;
|
|
557
|
-
} catch (e) {
|
|
558
|
-
reader.releaseLock();
|
|
559
|
-
throw e;
|
|
560
|
-
}
|
|
561
|
-
},
|
|
562
|
-
async return() {
|
|
563
|
-
const cancelPromise = reader.cancel();
|
|
564
|
-
reader.releaseLock();
|
|
565
|
-
await cancelPromise;
|
|
566
|
-
return { done: true, value: undefined };
|
|
567
|
-
},
|
|
568
|
-
[Symbol.asyncIterator]() {
|
|
569
|
-
return this;
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
575
|
|
|
574
576
|
// ../../node_modules/@anthropic-ai/sdk/uploads.mjs
|
|
575
577
|
var isResponseLike = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function";
|
|
@@ -920,7 +922,14 @@ class APIClient {
|
|
|
920
922
|
if (signal)
|
|
921
923
|
signal.addEventListener("abort", () => controller.abort());
|
|
922
924
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
923
|
-
|
|
925
|
+
const fetchOptions = {
|
|
926
|
+
signal: controller.signal,
|
|
927
|
+
...options
|
|
928
|
+
};
|
|
929
|
+
if (fetchOptions.method) {
|
|
930
|
+
fetchOptions.method = fetchOptions.method.toUpperCase();
|
|
931
|
+
}
|
|
932
|
+
return this.fetch.call(undefined, url, fetchOptions).finally(() => {
|
|
924
933
|
clearTimeout(timeout);
|
|
925
934
|
});
|
|
926
935
|
}
|
|
@@ -1380,7 +1389,7 @@ class JSONLDecoder {
|
|
|
1380
1389
|
controller.abort();
|
|
1381
1390
|
throw new AnthropicError(`Attempted to iterate over a response with no body`);
|
|
1382
1391
|
}
|
|
1383
|
-
return new JSONLDecoder(
|
|
1392
|
+
return new JSONLDecoder(ReadableStreamToAsyncIterable(response.body), controller);
|
|
1384
1393
|
}
|
|
1385
1394
|
}
|
|
1386
1395
|
|
|
@@ -1424,6 +1433,19 @@ class Batches extends APIResource {
|
|
|
1424
1433
|
}
|
|
1425
1434
|
});
|
|
1426
1435
|
}
|
|
1436
|
+
delete(messageBatchId, params = {}, options) {
|
|
1437
|
+
if (isRequestOptions(params)) {
|
|
1438
|
+
return this.delete(messageBatchId, {}, params);
|
|
1439
|
+
}
|
|
1440
|
+
const { betas } = params;
|
|
1441
|
+
return this._client.delete(`/v1/messages/batches/${messageBatchId}?beta=true`, {
|
|
1442
|
+
...options,
|
|
1443
|
+
headers: {
|
|
1444
|
+
"anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString(),
|
|
1445
|
+
...options?.headers
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1427
1449
|
cancel(messageBatchId, params = {}, options) {
|
|
1428
1450
|
if (isRequestOptions(params)) {
|
|
1429
1451
|
return this.cancel(messageBatchId, {}, params);
|
|
@@ -1450,6 +1472,7 @@ class Batches extends APIResource {
|
|
|
1450
1472
|
...options,
|
|
1451
1473
|
headers: {
|
|
1452
1474
|
"anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString(),
|
|
1475
|
+
Accept: "application/binary",
|
|
1453
1476
|
...options?.headers
|
|
1454
1477
|
},
|
|
1455
1478
|
__binaryResponse: true
|
|
@@ -1461,92 +1484,6 @@ class BetaMessageBatchesPage extends Page {
|
|
|
1461
1484
|
}
|
|
1462
1485
|
Batches.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
|
1463
1486
|
|
|
1464
|
-
// ../../node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.mjs
|
|
1465
|
-
class Messages extends APIResource {
|
|
1466
|
-
constructor() {
|
|
1467
|
-
super(...arguments);
|
|
1468
|
-
this.batches = new Batches(this._client);
|
|
1469
|
-
}
|
|
1470
|
-
create(params, options) {
|
|
1471
|
-
const { betas, ...body } = params;
|
|
1472
|
-
return this._client.post("/v1/messages?beta=true", {
|
|
1473
|
-
body,
|
|
1474
|
-
timeout: this._client._options.timeout ?? 600000,
|
|
1475
|
-
...options,
|
|
1476
|
-
headers: {
|
|
1477
|
-
...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : undefined,
|
|
1478
|
-
...options?.headers
|
|
1479
|
-
},
|
|
1480
|
-
stream: params.stream ?? false
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
countTokens(params, options) {
|
|
1484
|
-
const { betas, ...body } = params;
|
|
1485
|
-
return this._client.post("/v1/messages/count_tokens?beta=true", {
|
|
1486
|
-
body,
|
|
1487
|
-
...options,
|
|
1488
|
-
headers: {
|
|
1489
|
-
"anthropic-beta": [...betas ?? [], "token-counting-2024-11-01"].toString(),
|
|
1490
|
-
...options?.headers
|
|
1491
|
-
}
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
Messages.Batches = Batches;
|
|
1496
|
-
Messages.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
|
1497
|
-
|
|
1498
|
-
// ../../node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs
|
|
1499
|
-
class Beta extends APIResource {
|
|
1500
|
-
constructor() {
|
|
1501
|
-
super(...arguments);
|
|
1502
|
-
this.models = new Models(this._client);
|
|
1503
|
-
this.messages = new Messages(this._client);
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
Beta.Models = Models;
|
|
1507
|
-
Beta.BetaModelInfosPage = BetaModelInfosPage;
|
|
1508
|
-
Beta.Messages = Messages;
|
|
1509
|
-
// ../../node_modules/@anthropic-ai/sdk/resources/completions.mjs
|
|
1510
|
-
class Completions extends APIResource {
|
|
1511
|
-
create(body, options) {
|
|
1512
|
-
return this._client.post("/v1/complete", {
|
|
1513
|
-
body,
|
|
1514
|
-
timeout: this._client._options.timeout ?? 600000,
|
|
1515
|
-
...options,
|
|
1516
|
-
stream: body.stream ?? false
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
// ../../node_modules/@anthropic-ai/sdk/resources/messages/batches.mjs
|
|
1521
|
-
class Batches2 extends APIResource {
|
|
1522
|
-
create(body, options) {
|
|
1523
|
-
return this._client.post("/v1/messages/batches", { body, ...options });
|
|
1524
|
-
}
|
|
1525
|
-
retrieve(messageBatchId, options) {
|
|
1526
|
-
return this._client.get(`/v1/messages/batches/${messageBatchId}`, options);
|
|
1527
|
-
}
|
|
1528
|
-
list(query = {}, options) {
|
|
1529
|
-
if (isRequestOptions(query)) {
|
|
1530
|
-
return this.list({}, query);
|
|
1531
|
-
}
|
|
1532
|
-
return this._client.getAPIList("/v1/messages/batches", MessageBatchesPage, { query, ...options });
|
|
1533
|
-
}
|
|
1534
|
-
cancel(messageBatchId, options) {
|
|
1535
|
-
return this._client.post(`/v1/messages/batches/${messageBatchId}/cancel`, options);
|
|
1536
|
-
}
|
|
1537
|
-
async results(messageBatchId, options) {
|
|
1538
|
-
const batch = await this.retrieve(messageBatchId);
|
|
1539
|
-
if (!batch.results_url) {
|
|
1540
|
-
throw new AnthropicError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
|
|
1541
|
-
}
|
|
1542
|
-
return this._client.get(batch.results_url, { ...options, __binaryResponse: true })._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller));
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
class MessageBatchesPage extends Page {
|
|
1547
|
-
}
|
|
1548
|
-
Batches2.MessageBatchesPage = MessageBatchesPage;
|
|
1549
|
-
|
|
1550
1487
|
// ../../node_modules/@anthropic-ai/sdk/_vendor/partial-json-parser/parser.mjs
|
|
1551
1488
|
var tokenize = (input) => {
|
|
1552
1489
|
let current = 0;
|
|
@@ -1681,94 +1618,647 @@ var tokenize = (input) => {
|
|
|
1681
1618
|
}
|
|
1682
1619
|
current++;
|
|
1683
1620
|
}
|
|
1684
|
-
return tokens;
|
|
1685
|
-
};
|
|
1686
|
-
var strip = (tokens) => {
|
|
1687
|
-
if (tokens.length === 0) {
|
|
1688
|
-
return tokens;
|
|
1621
|
+
return tokens;
|
|
1622
|
+
};
|
|
1623
|
+
var strip = (tokens) => {
|
|
1624
|
+
if (tokens.length === 0) {
|
|
1625
|
+
return tokens;
|
|
1626
|
+
}
|
|
1627
|
+
let lastToken = tokens[tokens.length - 1];
|
|
1628
|
+
switch (lastToken.type) {
|
|
1629
|
+
case "separator":
|
|
1630
|
+
tokens = tokens.slice(0, tokens.length - 1);
|
|
1631
|
+
return strip(tokens);
|
|
1632
|
+
break;
|
|
1633
|
+
case "number":
|
|
1634
|
+
let lastCharacterOfLastToken = lastToken.value[lastToken.value.length - 1];
|
|
1635
|
+
if (lastCharacterOfLastToken === "." || lastCharacterOfLastToken === "-") {
|
|
1636
|
+
tokens = tokens.slice(0, tokens.length - 1);
|
|
1637
|
+
return strip(tokens);
|
|
1638
|
+
}
|
|
1639
|
+
case "string":
|
|
1640
|
+
let tokenBeforeTheLastToken = tokens[tokens.length - 2];
|
|
1641
|
+
if (tokenBeforeTheLastToken?.type === "delimiter") {
|
|
1642
|
+
tokens = tokens.slice(0, tokens.length - 1);
|
|
1643
|
+
return strip(tokens);
|
|
1644
|
+
} else if (tokenBeforeTheLastToken?.type === "brace" && tokenBeforeTheLastToken.value === "{") {
|
|
1645
|
+
tokens = tokens.slice(0, tokens.length - 1);
|
|
1646
|
+
return strip(tokens);
|
|
1647
|
+
}
|
|
1648
|
+
break;
|
|
1649
|
+
case "delimiter":
|
|
1650
|
+
tokens = tokens.slice(0, tokens.length - 1);
|
|
1651
|
+
return strip(tokens);
|
|
1652
|
+
break;
|
|
1653
|
+
}
|
|
1654
|
+
return tokens;
|
|
1655
|
+
};
|
|
1656
|
+
var unstrip = (tokens) => {
|
|
1657
|
+
let tail = [];
|
|
1658
|
+
tokens.map((token) => {
|
|
1659
|
+
if (token.type === "brace") {
|
|
1660
|
+
if (token.value === "{") {
|
|
1661
|
+
tail.push("}");
|
|
1662
|
+
} else {
|
|
1663
|
+
tail.splice(tail.lastIndexOf("}"), 1);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
if (token.type === "paren") {
|
|
1667
|
+
if (token.value === "[") {
|
|
1668
|
+
tail.push("]");
|
|
1669
|
+
} else {
|
|
1670
|
+
tail.splice(tail.lastIndexOf("]"), 1);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
if (tail.length > 0) {
|
|
1675
|
+
tail.reverse().map((item) => {
|
|
1676
|
+
if (item === "}") {
|
|
1677
|
+
tokens.push({
|
|
1678
|
+
type: "brace",
|
|
1679
|
+
value: "}"
|
|
1680
|
+
});
|
|
1681
|
+
} else if (item === "]") {
|
|
1682
|
+
tokens.push({
|
|
1683
|
+
type: "paren",
|
|
1684
|
+
value: "]"
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
return tokens;
|
|
1690
|
+
};
|
|
1691
|
+
var generate = (tokens) => {
|
|
1692
|
+
let output = "";
|
|
1693
|
+
tokens.map((token) => {
|
|
1694
|
+
switch (token.type) {
|
|
1695
|
+
case "string":
|
|
1696
|
+
output += '"' + token.value + '"';
|
|
1697
|
+
break;
|
|
1698
|
+
default:
|
|
1699
|
+
output += token.value;
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
return output;
|
|
1704
|
+
};
|
|
1705
|
+
var partialParse = (input) => JSON.parse(generate(unstrip(strip(tokenize(input)))));
|
|
1706
|
+
|
|
1707
|
+
// ../../node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs
|
|
1708
|
+
var __classPrivateFieldSet2 = function(receiver, state, value, kind2, f) {
|
|
1709
|
+
if (kind2 === "m")
|
|
1710
|
+
throw new TypeError("Private method is not writable");
|
|
1711
|
+
if (kind2 === "a" && !f)
|
|
1712
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
1713
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1714
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1715
|
+
return kind2 === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1716
|
+
};
|
|
1717
|
+
var __classPrivateFieldGet2 = function(receiver, state, kind2, f) {
|
|
1718
|
+
if (kind2 === "a" && !f)
|
|
1719
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
1720
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1721
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1722
|
+
return kind2 === "m" ? f : kind2 === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1723
|
+
};
|
|
1724
|
+
var _BetaMessageStream_instances;
|
|
1725
|
+
var _BetaMessageStream_currentMessageSnapshot;
|
|
1726
|
+
var _BetaMessageStream_connectedPromise;
|
|
1727
|
+
var _BetaMessageStream_resolveConnectedPromise;
|
|
1728
|
+
var _BetaMessageStream_rejectConnectedPromise;
|
|
1729
|
+
var _BetaMessageStream_endPromise;
|
|
1730
|
+
var _BetaMessageStream_resolveEndPromise;
|
|
1731
|
+
var _BetaMessageStream_rejectEndPromise;
|
|
1732
|
+
var _BetaMessageStream_listeners;
|
|
1733
|
+
var _BetaMessageStream_ended;
|
|
1734
|
+
var _BetaMessageStream_errored;
|
|
1735
|
+
var _BetaMessageStream_aborted;
|
|
1736
|
+
var _BetaMessageStream_catchingPromiseCreated;
|
|
1737
|
+
var _BetaMessageStream_response;
|
|
1738
|
+
var _BetaMessageStream_request_id;
|
|
1739
|
+
var _BetaMessageStream_getFinalMessage;
|
|
1740
|
+
var _BetaMessageStream_getFinalText;
|
|
1741
|
+
var _BetaMessageStream_handleError;
|
|
1742
|
+
var _BetaMessageStream_beginRequest;
|
|
1743
|
+
var _BetaMessageStream_addStreamEvent;
|
|
1744
|
+
var _BetaMessageStream_endRequest;
|
|
1745
|
+
var _BetaMessageStream_accumulateMessage;
|
|
1746
|
+
var JSON_BUF_PROPERTY = "__json_buf";
|
|
1747
|
+
|
|
1748
|
+
class BetaMessageStream {
|
|
1749
|
+
constructor() {
|
|
1750
|
+
_BetaMessageStream_instances.add(this);
|
|
1751
|
+
this.messages = [];
|
|
1752
|
+
this.receivedMessages = [];
|
|
1753
|
+
_BetaMessageStream_currentMessageSnapshot.set(this, undefined);
|
|
1754
|
+
this.controller = new AbortController;
|
|
1755
|
+
_BetaMessageStream_connectedPromise.set(this, undefined);
|
|
1756
|
+
_BetaMessageStream_resolveConnectedPromise.set(this, () => {
|
|
1757
|
+
});
|
|
1758
|
+
_BetaMessageStream_rejectConnectedPromise.set(this, () => {
|
|
1759
|
+
});
|
|
1760
|
+
_BetaMessageStream_endPromise.set(this, undefined);
|
|
1761
|
+
_BetaMessageStream_resolveEndPromise.set(this, () => {
|
|
1762
|
+
});
|
|
1763
|
+
_BetaMessageStream_rejectEndPromise.set(this, () => {
|
|
1764
|
+
});
|
|
1765
|
+
_BetaMessageStream_listeners.set(this, {});
|
|
1766
|
+
_BetaMessageStream_ended.set(this, false);
|
|
1767
|
+
_BetaMessageStream_errored.set(this, false);
|
|
1768
|
+
_BetaMessageStream_aborted.set(this, false);
|
|
1769
|
+
_BetaMessageStream_catchingPromiseCreated.set(this, false);
|
|
1770
|
+
_BetaMessageStream_response.set(this, undefined);
|
|
1771
|
+
_BetaMessageStream_request_id.set(this, undefined);
|
|
1772
|
+
_BetaMessageStream_handleError.set(this, (error) => {
|
|
1773
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_errored, true, "f");
|
|
1774
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
1775
|
+
error = new APIUserAbortError;
|
|
1776
|
+
}
|
|
1777
|
+
if (error instanceof APIUserAbortError) {
|
|
1778
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_aborted, true, "f");
|
|
1779
|
+
return this._emit("abort", error);
|
|
1780
|
+
}
|
|
1781
|
+
if (error instanceof AnthropicError) {
|
|
1782
|
+
return this._emit("error", error);
|
|
1783
|
+
}
|
|
1784
|
+
if (error instanceof Error) {
|
|
1785
|
+
const anthropicError = new AnthropicError(error.message);
|
|
1786
|
+
anthropicError.cause = error;
|
|
1787
|
+
return this._emit("error", anthropicError);
|
|
1788
|
+
}
|
|
1789
|
+
return this._emit("error", new AnthropicError(String(error)));
|
|
1790
|
+
});
|
|
1791
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve, reject) => {
|
|
1792
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve, "f");
|
|
1793
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
1794
|
+
}), "f");
|
|
1795
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve, reject) => {
|
|
1796
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve, "f");
|
|
1797
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
1798
|
+
}), "f");
|
|
1799
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
1800
|
+
});
|
|
1801
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_endPromise, "f").catch(() => {
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
get response() {
|
|
1805
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_response, "f");
|
|
1806
|
+
}
|
|
1807
|
+
get request_id() {
|
|
1808
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_request_id, "f");
|
|
1809
|
+
}
|
|
1810
|
+
async withResponse() {
|
|
1811
|
+
const response = await __classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f");
|
|
1812
|
+
if (!response) {
|
|
1813
|
+
throw new Error("Could not resolve a `Response` object");
|
|
1814
|
+
}
|
|
1815
|
+
return {
|
|
1816
|
+
data: this,
|
|
1817
|
+
response,
|
|
1818
|
+
request_id: response.headers.get("request-id")
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
static fromReadableStream(stream) {
|
|
1822
|
+
const runner = new BetaMessageStream;
|
|
1823
|
+
runner._run(() => runner._fromReadableStream(stream));
|
|
1824
|
+
return runner;
|
|
1825
|
+
}
|
|
1826
|
+
static createMessage(messages, params, options) {
|
|
1827
|
+
const runner = new BetaMessageStream;
|
|
1828
|
+
for (const message of params.messages) {
|
|
1829
|
+
runner._addMessageParam(message);
|
|
1830
|
+
}
|
|
1831
|
+
runner._run(() => runner._createMessage(messages, { ...params, stream: true }, { ...options, headers: { ...options?.headers, "X-Stainless-Helper-Method": "stream" } }));
|
|
1832
|
+
return runner;
|
|
1833
|
+
}
|
|
1834
|
+
_run(executor) {
|
|
1835
|
+
executor().then(() => {
|
|
1836
|
+
this._emitFinal();
|
|
1837
|
+
this._emit("end");
|
|
1838
|
+
}, __classPrivateFieldGet2(this, _BetaMessageStream_handleError, "f"));
|
|
1839
|
+
}
|
|
1840
|
+
_addMessageParam(message) {
|
|
1841
|
+
this.messages.push(message);
|
|
1842
|
+
}
|
|
1843
|
+
_addMessage(message, emit = true) {
|
|
1844
|
+
this.receivedMessages.push(message);
|
|
1845
|
+
if (emit) {
|
|
1846
|
+
this._emit("message", message);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
async _createMessage(messages, params, options) {
|
|
1850
|
+
const signal = options?.signal;
|
|
1851
|
+
if (signal) {
|
|
1852
|
+
if (signal.aborted)
|
|
1853
|
+
this.controller.abort();
|
|
1854
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
1855
|
+
}
|
|
1856
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_beginRequest).call(this);
|
|
1857
|
+
const { response, data: stream } = await messages.create({ ...params, stream: true }, { ...options, signal: this.controller.signal }).withResponse();
|
|
1858
|
+
this._connected(response);
|
|
1859
|
+
for await (const event of stream) {
|
|
1860
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_addStreamEvent).call(this, event);
|
|
1861
|
+
}
|
|
1862
|
+
if (stream.controller.signal?.aborted) {
|
|
1863
|
+
throw new APIUserAbortError;
|
|
1864
|
+
}
|
|
1865
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_endRequest).call(this);
|
|
1866
|
+
}
|
|
1867
|
+
_connected(response) {
|
|
1868
|
+
if (this.ended)
|
|
1869
|
+
return;
|
|
1870
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_response, response, "f");
|
|
1871
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_request_id, response?.headers.get("request-id"), "f");
|
|
1872
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_resolveConnectedPromise, "f").call(this, response);
|
|
1873
|
+
this._emit("connect");
|
|
1874
|
+
}
|
|
1875
|
+
get ended() {
|
|
1876
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_ended, "f");
|
|
1877
|
+
}
|
|
1878
|
+
get errored() {
|
|
1879
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_errored, "f");
|
|
1880
|
+
}
|
|
1881
|
+
get aborted() {
|
|
1882
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_aborted, "f");
|
|
1883
|
+
}
|
|
1884
|
+
abort() {
|
|
1885
|
+
this.controller.abort();
|
|
1886
|
+
}
|
|
1887
|
+
on(event, listener) {
|
|
1888
|
+
const listeners = __classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event] || (__classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event] = []);
|
|
1889
|
+
listeners.push({ listener });
|
|
1890
|
+
return this;
|
|
1891
|
+
}
|
|
1892
|
+
off(event, listener) {
|
|
1893
|
+
const listeners = __classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event];
|
|
1894
|
+
if (!listeners)
|
|
1895
|
+
return this;
|
|
1896
|
+
const index = listeners.findIndex((l) => l.listener === listener);
|
|
1897
|
+
if (index >= 0)
|
|
1898
|
+
listeners.splice(index, 1);
|
|
1899
|
+
return this;
|
|
1900
|
+
}
|
|
1901
|
+
once(event, listener) {
|
|
1902
|
+
const listeners = __classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event] || (__classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event] = []);
|
|
1903
|
+
listeners.push({ listener, once: true });
|
|
1904
|
+
return this;
|
|
1905
|
+
}
|
|
1906
|
+
emitted(event) {
|
|
1907
|
+
return new Promise((resolve, reject) => {
|
|
1908
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
1909
|
+
if (event !== "error")
|
|
1910
|
+
this.once("error", reject);
|
|
1911
|
+
this.once(event, resolve);
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
async done() {
|
|
1915
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
1916
|
+
await __classPrivateFieldGet2(this, _BetaMessageStream_endPromise, "f");
|
|
1917
|
+
}
|
|
1918
|
+
get currentMessage() {
|
|
1919
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_currentMessageSnapshot, "f");
|
|
1920
|
+
}
|
|
1921
|
+
async finalMessage() {
|
|
1922
|
+
await this.done();
|
|
1923
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_getFinalMessage).call(this);
|
|
1924
|
+
}
|
|
1925
|
+
async finalText() {
|
|
1926
|
+
await this.done();
|
|
1927
|
+
return __classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_getFinalText).call(this);
|
|
1928
|
+
}
|
|
1929
|
+
_emit(event, ...args) {
|
|
1930
|
+
if (__classPrivateFieldGet2(this, _BetaMessageStream_ended, "f"))
|
|
1931
|
+
return;
|
|
1932
|
+
if (event === "end") {
|
|
1933
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_ended, true, "f");
|
|
1934
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_resolveEndPromise, "f").call(this);
|
|
1935
|
+
}
|
|
1936
|
+
const listeners = __classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event];
|
|
1937
|
+
if (listeners) {
|
|
1938
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_listeners, "f")[event] = listeners.filter((l) => !l.once);
|
|
1939
|
+
listeners.forEach(({ listener }) => listener(...args));
|
|
1940
|
+
}
|
|
1941
|
+
if (event === "abort") {
|
|
1942
|
+
const error = args[0];
|
|
1943
|
+
if (!__classPrivateFieldGet2(this, _BetaMessageStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
1944
|
+
Promise.reject(error);
|
|
1945
|
+
}
|
|
1946
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_rejectConnectedPromise, "f").call(this, error);
|
|
1947
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_rejectEndPromise, "f").call(this, error);
|
|
1948
|
+
this._emit("end");
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
if (event === "error") {
|
|
1952
|
+
const error = args[0];
|
|
1953
|
+
if (!__classPrivateFieldGet2(this, _BetaMessageStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
1954
|
+
Promise.reject(error);
|
|
1955
|
+
}
|
|
1956
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_rejectConnectedPromise, "f").call(this, error);
|
|
1957
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_rejectEndPromise, "f").call(this, error);
|
|
1958
|
+
this._emit("end");
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
_emitFinal() {
|
|
1962
|
+
const finalMessage = this.receivedMessages.at(-1);
|
|
1963
|
+
if (finalMessage) {
|
|
1964
|
+
this._emit("finalMessage", __classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_getFinalMessage).call(this));
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
async _fromReadableStream(readableStream, options) {
|
|
1968
|
+
const signal = options?.signal;
|
|
1969
|
+
if (signal) {
|
|
1970
|
+
if (signal.aborted)
|
|
1971
|
+
this.controller.abort();
|
|
1972
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
1973
|
+
}
|
|
1974
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_beginRequest).call(this);
|
|
1975
|
+
this._connected(null);
|
|
1976
|
+
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
1977
|
+
for await (const event of stream) {
|
|
1978
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_addStreamEvent).call(this, event);
|
|
1979
|
+
}
|
|
1980
|
+
if (stream.controller.signal?.aborted) {
|
|
1981
|
+
throw new APIUserAbortError;
|
|
1982
|
+
}
|
|
1983
|
+
__classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_endRequest).call(this);
|
|
1984
|
+
}
|
|
1985
|
+
[(_BetaMessageStream_currentMessageSnapshot = new WeakMap, _BetaMessageStream_connectedPromise = new WeakMap, _BetaMessageStream_resolveConnectedPromise = new WeakMap, _BetaMessageStream_rejectConnectedPromise = new WeakMap, _BetaMessageStream_endPromise = new WeakMap, _BetaMessageStream_resolveEndPromise = new WeakMap, _BetaMessageStream_rejectEndPromise = new WeakMap, _BetaMessageStream_listeners = new WeakMap, _BetaMessageStream_ended = new WeakMap, _BetaMessageStream_errored = new WeakMap, _BetaMessageStream_aborted = new WeakMap, _BetaMessageStream_catchingPromiseCreated = new WeakMap, _BetaMessageStream_response = new WeakMap, _BetaMessageStream_request_id = new WeakMap, _BetaMessageStream_handleError = new WeakMap, _BetaMessageStream_instances = new WeakSet, _BetaMessageStream_getFinalMessage = function _BetaMessageStream_getFinalMessage() {
|
|
1986
|
+
if (this.receivedMessages.length === 0) {
|
|
1987
|
+
throw new AnthropicError("stream ended without producing a Message with role=assistant");
|
|
1988
|
+
}
|
|
1989
|
+
return this.receivedMessages.at(-1);
|
|
1990
|
+
}, _BetaMessageStream_getFinalText = function _BetaMessageStream_getFinalText() {
|
|
1991
|
+
if (this.receivedMessages.length === 0) {
|
|
1992
|
+
throw new AnthropicError("stream ended without producing a Message with role=assistant");
|
|
1993
|
+
}
|
|
1994
|
+
const textBlocks = this.receivedMessages.at(-1).content.filter((block) => block.type === "text").map((block) => block.text);
|
|
1995
|
+
if (textBlocks.length === 0) {
|
|
1996
|
+
throw new AnthropicError("stream ended without producing a content block with type=text");
|
|
1997
|
+
}
|
|
1998
|
+
return textBlocks.join(" ");
|
|
1999
|
+
}, _BetaMessageStream_beginRequest = function _BetaMessageStream_beginRequest() {
|
|
2000
|
+
if (this.ended)
|
|
2001
|
+
return;
|
|
2002
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_currentMessageSnapshot, undefined, "f");
|
|
2003
|
+
}, _BetaMessageStream_addStreamEvent = function _BetaMessageStream_addStreamEvent(event) {
|
|
2004
|
+
if (this.ended)
|
|
2005
|
+
return;
|
|
2006
|
+
const messageSnapshot = __classPrivateFieldGet2(this, _BetaMessageStream_instances, "m", _BetaMessageStream_accumulateMessage).call(this, event);
|
|
2007
|
+
this._emit("streamEvent", event, messageSnapshot);
|
|
2008
|
+
switch (event.type) {
|
|
2009
|
+
case "content_block_delta": {
|
|
2010
|
+
const content = messageSnapshot.content.at(-1);
|
|
2011
|
+
if (event.delta.type === "text_delta" && content.type === "text") {
|
|
2012
|
+
this._emit("text", event.delta.text, content.text || "");
|
|
2013
|
+
} else if (event.delta.type === "input_json_delta" && content.type === "tool_use") {
|
|
2014
|
+
if (content.input) {
|
|
2015
|
+
this._emit("inputJson", event.delta.partial_json, content.input);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
break;
|
|
2019
|
+
}
|
|
2020
|
+
case "message_stop": {
|
|
2021
|
+
this._addMessageParam(messageSnapshot);
|
|
2022
|
+
this._addMessage(messageSnapshot, true);
|
|
2023
|
+
break;
|
|
2024
|
+
}
|
|
2025
|
+
case "content_block_stop": {
|
|
2026
|
+
this._emit("contentBlock", messageSnapshot.content.at(-1));
|
|
2027
|
+
break;
|
|
2028
|
+
}
|
|
2029
|
+
case "message_start": {
|
|
2030
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_currentMessageSnapshot, messageSnapshot, "f");
|
|
2031
|
+
break;
|
|
2032
|
+
}
|
|
2033
|
+
case "content_block_start":
|
|
2034
|
+
case "message_delta":
|
|
2035
|
+
break;
|
|
2036
|
+
}
|
|
2037
|
+
}, _BetaMessageStream_endRequest = function _BetaMessageStream_endRequest() {
|
|
2038
|
+
if (this.ended) {
|
|
2039
|
+
throw new AnthropicError(`stream has ended, this shouldn't happen`);
|
|
2040
|
+
}
|
|
2041
|
+
const snapshot = __classPrivateFieldGet2(this, _BetaMessageStream_currentMessageSnapshot, "f");
|
|
2042
|
+
if (!snapshot) {
|
|
2043
|
+
throw new AnthropicError(`request ended without sending any chunks`);
|
|
2044
|
+
}
|
|
2045
|
+
__classPrivateFieldSet2(this, _BetaMessageStream_currentMessageSnapshot, undefined, "f");
|
|
2046
|
+
return snapshot;
|
|
2047
|
+
}, _BetaMessageStream_accumulateMessage = function _BetaMessageStream_accumulateMessage(event) {
|
|
2048
|
+
let snapshot = __classPrivateFieldGet2(this, _BetaMessageStream_currentMessageSnapshot, "f");
|
|
2049
|
+
if (event.type === "message_start") {
|
|
2050
|
+
if (snapshot) {
|
|
2051
|
+
throw new AnthropicError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
|
|
2052
|
+
}
|
|
2053
|
+
return event.message;
|
|
2054
|
+
}
|
|
2055
|
+
if (!snapshot) {
|
|
2056
|
+
throw new AnthropicError(`Unexpected event order, got ${event.type} before "message_start"`);
|
|
2057
|
+
}
|
|
2058
|
+
switch (event.type) {
|
|
2059
|
+
case "message_stop":
|
|
2060
|
+
return snapshot;
|
|
2061
|
+
case "message_delta":
|
|
2062
|
+
snapshot.stop_reason = event.delta.stop_reason;
|
|
2063
|
+
snapshot.stop_sequence = event.delta.stop_sequence;
|
|
2064
|
+
snapshot.usage.output_tokens = event.usage.output_tokens;
|
|
2065
|
+
return snapshot;
|
|
2066
|
+
case "content_block_start":
|
|
2067
|
+
snapshot.content.push(event.content_block);
|
|
2068
|
+
return snapshot;
|
|
2069
|
+
case "content_block_delta": {
|
|
2070
|
+
const snapshotContent = snapshot.content.at(event.index);
|
|
2071
|
+
if (snapshotContent?.type === "text" && event.delta.type === "text_delta") {
|
|
2072
|
+
snapshotContent.text += event.delta.text;
|
|
2073
|
+
} else if (snapshotContent?.type === "tool_use" && event.delta.type === "input_json_delta") {
|
|
2074
|
+
let jsonBuf = snapshotContent[JSON_BUF_PROPERTY] || "";
|
|
2075
|
+
jsonBuf += event.delta.partial_json;
|
|
2076
|
+
Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
|
|
2077
|
+
value: jsonBuf,
|
|
2078
|
+
enumerable: false,
|
|
2079
|
+
writable: true
|
|
2080
|
+
});
|
|
2081
|
+
if (jsonBuf) {
|
|
2082
|
+
snapshotContent.input = partialParse(jsonBuf);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
return snapshot;
|
|
2086
|
+
}
|
|
2087
|
+
case "content_block_stop":
|
|
2088
|
+
return snapshot;
|
|
2089
|
+
}
|
|
2090
|
+
}, Symbol.asyncIterator)]() {
|
|
2091
|
+
const pushQueue = [];
|
|
2092
|
+
const readQueue = [];
|
|
2093
|
+
let done = false;
|
|
2094
|
+
this.on("streamEvent", (event) => {
|
|
2095
|
+
const reader = readQueue.shift();
|
|
2096
|
+
if (reader) {
|
|
2097
|
+
reader.resolve(event);
|
|
2098
|
+
} else {
|
|
2099
|
+
pushQueue.push(event);
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
2102
|
+
this.on("end", () => {
|
|
2103
|
+
done = true;
|
|
2104
|
+
for (const reader of readQueue) {
|
|
2105
|
+
reader.resolve(undefined);
|
|
2106
|
+
}
|
|
2107
|
+
readQueue.length = 0;
|
|
2108
|
+
});
|
|
2109
|
+
this.on("abort", (err) => {
|
|
2110
|
+
done = true;
|
|
2111
|
+
for (const reader of readQueue) {
|
|
2112
|
+
reader.reject(err);
|
|
2113
|
+
}
|
|
2114
|
+
readQueue.length = 0;
|
|
2115
|
+
});
|
|
2116
|
+
this.on("error", (err) => {
|
|
2117
|
+
done = true;
|
|
2118
|
+
for (const reader of readQueue) {
|
|
2119
|
+
reader.reject(err);
|
|
2120
|
+
}
|
|
2121
|
+
readQueue.length = 0;
|
|
2122
|
+
});
|
|
2123
|
+
return {
|
|
2124
|
+
next: async () => {
|
|
2125
|
+
if (!pushQueue.length) {
|
|
2126
|
+
if (done) {
|
|
2127
|
+
return { value: undefined, done: true };
|
|
2128
|
+
}
|
|
2129
|
+
return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: undefined, done: true });
|
|
2130
|
+
}
|
|
2131
|
+
const chunk = pushQueue.shift();
|
|
2132
|
+
return { value: chunk, done: false };
|
|
2133
|
+
},
|
|
2134
|
+
return: async () => {
|
|
2135
|
+
this.abort();
|
|
2136
|
+
return { value: undefined, done: true };
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
toReadableStream() {
|
|
2141
|
+
const stream = new Stream(this[Symbol.asyncIterator].bind(this), this.controller);
|
|
2142
|
+
return stream.toReadableStream();
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
// ../../node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.mjs
|
|
2147
|
+
var DEPRECATED_MODELS = {
|
|
2148
|
+
"claude-1.3": "November 6th, 2024",
|
|
2149
|
+
"claude-1.3-100k": "November 6th, 2024",
|
|
2150
|
+
"claude-instant-1.1": "November 6th, 2024",
|
|
2151
|
+
"claude-instant-1.1-100k": "November 6th, 2024",
|
|
2152
|
+
"claude-instant-1.2": "November 6th, 2024",
|
|
2153
|
+
"claude-3-sonnet-20240229": "July 21st, 2025",
|
|
2154
|
+
"claude-2.1": "July 21st, 2025",
|
|
2155
|
+
"claude-2.0": "July 21st, 2025"
|
|
2156
|
+
};
|
|
2157
|
+
|
|
2158
|
+
class Messages extends APIResource {
|
|
2159
|
+
constructor() {
|
|
2160
|
+
super(...arguments);
|
|
2161
|
+
this.batches = new Batches(this._client);
|
|
2162
|
+
}
|
|
2163
|
+
create(params, options) {
|
|
2164
|
+
const { betas, ...body } = params;
|
|
2165
|
+
if (body.model in DEPRECATED_MODELS) {
|
|
2166
|
+
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS[body.model]}
|
|
2167
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
2168
|
+
}
|
|
2169
|
+
return this._client.post("/v1/messages?beta=true", {
|
|
2170
|
+
body,
|
|
2171
|
+
timeout: this._client._options.timeout ?? 600000,
|
|
2172
|
+
...options,
|
|
2173
|
+
headers: {
|
|
2174
|
+
...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : undefined,
|
|
2175
|
+
...options?.headers
|
|
2176
|
+
},
|
|
2177
|
+
stream: params.stream ?? false
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2180
|
+
stream(body, options) {
|
|
2181
|
+
return BetaMessageStream.createMessage(this, body, options);
|
|
2182
|
+
}
|
|
2183
|
+
countTokens(params, options) {
|
|
2184
|
+
const { betas, ...body } = params;
|
|
2185
|
+
return this._client.post("/v1/messages/count_tokens?beta=true", {
|
|
2186
|
+
body,
|
|
2187
|
+
...options,
|
|
2188
|
+
headers: {
|
|
2189
|
+
"anthropic-beta": [...betas ?? [], "token-counting-2024-11-01"].toString(),
|
|
2190
|
+
...options?.headers
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
Messages.Batches = Batches;
|
|
2196
|
+
Messages.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
|
2197
|
+
|
|
2198
|
+
// ../../node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs
|
|
2199
|
+
class Beta extends APIResource {
|
|
2200
|
+
constructor() {
|
|
2201
|
+
super(...arguments);
|
|
2202
|
+
this.models = new Models(this._client);
|
|
2203
|
+
this.messages = new Messages(this._client);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
Beta.Models = Models;
|
|
2207
|
+
Beta.BetaModelInfosPage = BetaModelInfosPage;
|
|
2208
|
+
Beta.Messages = Messages;
|
|
2209
|
+
// ../../node_modules/@anthropic-ai/sdk/resources/completions.mjs
|
|
2210
|
+
class Completions extends APIResource {
|
|
2211
|
+
create(body, options) {
|
|
2212
|
+
return this._client.post("/v1/complete", {
|
|
2213
|
+
body,
|
|
2214
|
+
timeout: this._client._options.timeout ?? 600000,
|
|
2215
|
+
...options,
|
|
2216
|
+
stream: body.stream ?? false
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
// ../../node_modules/@anthropic-ai/sdk/resources/messages/batches.mjs
|
|
2221
|
+
class Batches2 extends APIResource {
|
|
2222
|
+
create(body, options) {
|
|
2223
|
+
return this._client.post("/v1/messages/batches", { body, ...options });
|
|
1689
2224
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
case "separator":
|
|
1693
|
-
tokens = tokens.slice(0, tokens.length - 1);
|
|
1694
|
-
return strip(tokens);
|
|
1695
|
-
break;
|
|
1696
|
-
case "number":
|
|
1697
|
-
let lastCharacterOfLastToken = lastToken.value[lastToken.value.length - 1];
|
|
1698
|
-
if (lastCharacterOfLastToken === "." || lastCharacterOfLastToken === "-") {
|
|
1699
|
-
tokens = tokens.slice(0, tokens.length - 1);
|
|
1700
|
-
return strip(tokens);
|
|
1701
|
-
}
|
|
1702
|
-
case "string":
|
|
1703
|
-
let tokenBeforeTheLastToken = tokens[tokens.length - 2];
|
|
1704
|
-
if (tokenBeforeTheLastToken?.type === "delimiter") {
|
|
1705
|
-
tokens = tokens.slice(0, tokens.length - 1);
|
|
1706
|
-
return strip(tokens);
|
|
1707
|
-
} else if (tokenBeforeTheLastToken?.type === "brace" && tokenBeforeTheLastToken.value === "{") {
|
|
1708
|
-
tokens = tokens.slice(0, tokens.length - 1);
|
|
1709
|
-
return strip(tokens);
|
|
1710
|
-
}
|
|
1711
|
-
break;
|
|
1712
|
-
case "delimiter":
|
|
1713
|
-
tokens = tokens.slice(0, tokens.length - 1);
|
|
1714
|
-
return strip(tokens);
|
|
1715
|
-
break;
|
|
2225
|
+
retrieve(messageBatchId, options) {
|
|
2226
|
+
return this._client.get(`/v1/messages/batches/${messageBatchId}`, options);
|
|
1716
2227
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
let tail = [];
|
|
1721
|
-
tokens.map((token) => {
|
|
1722
|
-
if (token.type === "brace") {
|
|
1723
|
-
if (token.value === "{") {
|
|
1724
|
-
tail.push("}");
|
|
1725
|
-
} else {
|
|
1726
|
-
tail.splice(tail.lastIndexOf("}"), 1);
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
if (token.type === "paren") {
|
|
1730
|
-
if (token.value === "[") {
|
|
1731
|
-
tail.push("]");
|
|
1732
|
-
} else {
|
|
1733
|
-
tail.splice(tail.lastIndexOf("]"), 1);
|
|
1734
|
-
}
|
|
2228
|
+
list(query = {}, options) {
|
|
2229
|
+
if (isRequestOptions(query)) {
|
|
2230
|
+
return this.list({}, query);
|
|
1735
2231
|
}
|
|
1736
|
-
|
|
1737
|
-
if (tail.length > 0) {
|
|
1738
|
-
tail.reverse().map((item) => {
|
|
1739
|
-
if (item === "}") {
|
|
1740
|
-
tokens.push({
|
|
1741
|
-
type: "brace",
|
|
1742
|
-
value: "}"
|
|
1743
|
-
});
|
|
1744
|
-
} else if (item === "]") {
|
|
1745
|
-
tokens.push({
|
|
1746
|
-
type: "paren",
|
|
1747
|
-
value: "]"
|
|
1748
|
-
});
|
|
1749
|
-
}
|
|
1750
|
-
});
|
|
2232
|
+
return this._client.getAPIList("/v1/messages/batches", MessageBatchesPage, { query, ...options });
|
|
1751
2233
|
}
|
|
1752
|
-
|
|
1753
|
-
};
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
output += token.value;
|
|
1763
|
-
break;
|
|
2234
|
+
delete(messageBatchId, options) {
|
|
2235
|
+
return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
|
|
2236
|
+
}
|
|
2237
|
+
cancel(messageBatchId, options) {
|
|
2238
|
+
return this._client.post(`/v1/messages/batches/${messageBatchId}/cancel`, options);
|
|
2239
|
+
}
|
|
2240
|
+
async results(messageBatchId, options) {
|
|
2241
|
+
const batch = await this.retrieve(messageBatchId);
|
|
2242
|
+
if (!batch.results_url) {
|
|
2243
|
+
throw new AnthropicError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
|
|
1764
2244
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
2245
|
+
return this._client.get(batch.results_url, {
|
|
2246
|
+
...options,
|
|
2247
|
+
headers: {
|
|
2248
|
+
Accept: "application/binary",
|
|
2249
|
+
...options?.headers
|
|
2250
|
+
},
|
|
2251
|
+
__binaryResponse: true
|
|
2252
|
+
})._thenUnwrap((_, props) => JSONLDecoder.fromResponse(props.response, props.controller));
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
class MessageBatchesPage extends Page {
|
|
2257
|
+
}
|
|
2258
|
+
Batches2.MessageBatchesPage = MessageBatchesPage;
|
|
1769
2259
|
|
|
1770
2260
|
// ../../node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs
|
|
1771
|
-
var
|
|
2261
|
+
var __classPrivateFieldSet3 = function(receiver, state, value, kind2, f) {
|
|
1772
2262
|
if (kind2 === "m")
|
|
1773
2263
|
throw new TypeError("Private method is not writable");
|
|
1774
2264
|
if (kind2 === "a" && !f)
|
|
@@ -1777,7 +2267,7 @@ var __classPrivateFieldSet2 = function(receiver, state, value, kind2, f) {
|
|
|
1777
2267
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1778
2268
|
return kind2 === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1779
2269
|
};
|
|
1780
|
-
var
|
|
2270
|
+
var __classPrivateFieldGet3 = function(receiver, state, kind2, f) {
|
|
1781
2271
|
if (kind2 === "a" && !f)
|
|
1782
2272
|
throw new TypeError("Private accessor was defined without a getter");
|
|
1783
2273
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -1797,6 +2287,8 @@ var _MessageStream_ended;
|
|
|
1797
2287
|
var _MessageStream_errored;
|
|
1798
2288
|
var _MessageStream_aborted;
|
|
1799
2289
|
var _MessageStream_catchingPromiseCreated;
|
|
2290
|
+
var _MessageStream_response;
|
|
2291
|
+
var _MessageStream_request_id;
|
|
1800
2292
|
var _MessageStream_getFinalMessage;
|
|
1801
2293
|
var _MessageStream_getFinalText;
|
|
1802
2294
|
var _MessageStream_handleError;
|
|
@@ -1804,7 +2296,7 @@ var _MessageStream_beginRequest;
|
|
|
1804
2296
|
var _MessageStream_addStreamEvent;
|
|
1805
2297
|
var _MessageStream_endRequest;
|
|
1806
2298
|
var _MessageStream_accumulateMessage;
|
|
1807
|
-
var
|
|
2299
|
+
var JSON_BUF_PROPERTY2 = "__json_buf";
|
|
1808
2300
|
|
|
1809
2301
|
class MessageStream {
|
|
1810
2302
|
constructor() {
|
|
@@ -1828,13 +2320,15 @@ class MessageStream {
|
|
|
1828
2320
|
_MessageStream_errored.set(this, false);
|
|
1829
2321
|
_MessageStream_aborted.set(this, false);
|
|
1830
2322
|
_MessageStream_catchingPromiseCreated.set(this, false);
|
|
2323
|
+
_MessageStream_response.set(this, undefined);
|
|
2324
|
+
_MessageStream_request_id.set(this, undefined);
|
|
1831
2325
|
_MessageStream_handleError.set(this, (error) => {
|
|
1832
|
-
|
|
2326
|
+
__classPrivateFieldSet3(this, _MessageStream_errored, true, "f");
|
|
1833
2327
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1834
2328
|
error = new APIUserAbortError;
|
|
1835
2329
|
}
|
|
1836
2330
|
if (error instanceof APIUserAbortError) {
|
|
1837
|
-
|
|
2331
|
+
__classPrivateFieldSet3(this, _MessageStream_aborted, true, "f");
|
|
1838
2332
|
return this._emit("abort", error);
|
|
1839
2333
|
}
|
|
1840
2334
|
if (error instanceof AnthropicError) {
|
|
@@ -1847,19 +2341,36 @@ class MessageStream {
|
|
|
1847
2341
|
}
|
|
1848
2342
|
return this._emit("error", new AnthropicError(String(error)));
|
|
1849
2343
|
});
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
2344
|
+
__classPrivateFieldSet3(this, _MessageStream_connectedPromise, new Promise((resolve, reject) => {
|
|
2345
|
+
__classPrivateFieldSet3(this, _MessageStream_resolveConnectedPromise, resolve, "f");
|
|
2346
|
+
__classPrivateFieldSet3(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
1853
2347
|
}), "f");
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
2348
|
+
__classPrivateFieldSet3(this, _MessageStream_endPromise, new Promise((resolve, reject) => {
|
|
2349
|
+
__classPrivateFieldSet3(this, _MessageStream_resolveEndPromise, resolve, "f");
|
|
2350
|
+
__classPrivateFieldSet3(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
1857
2351
|
}), "f");
|
|
1858
|
-
|
|
2352
|
+
__classPrivateFieldGet3(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
1859
2353
|
});
|
|
1860
|
-
|
|
2354
|
+
__classPrivateFieldGet3(this, _MessageStream_endPromise, "f").catch(() => {
|
|
1861
2355
|
});
|
|
1862
2356
|
}
|
|
2357
|
+
get response() {
|
|
2358
|
+
return __classPrivateFieldGet3(this, _MessageStream_response, "f");
|
|
2359
|
+
}
|
|
2360
|
+
get request_id() {
|
|
2361
|
+
return __classPrivateFieldGet3(this, _MessageStream_request_id, "f");
|
|
2362
|
+
}
|
|
2363
|
+
async withResponse() {
|
|
2364
|
+
const response = await __classPrivateFieldGet3(this, _MessageStream_connectedPromise, "f");
|
|
2365
|
+
if (!response) {
|
|
2366
|
+
throw new Error("Could not resolve a `Response` object");
|
|
2367
|
+
}
|
|
2368
|
+
return {
|
|
2369
|
+
data: this,
|
|
2370
|
+
response,
|
|
2371
|
+
request_id: response.headers.get("request-id")
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
1863
2374
|
static fromReadableStream(stream) {
|
|
1864
2375
|
const runner = new MessageStream;
|
|
1865
2376
|
runner._run(() => runner._fromReadableStream(stream));
|
|
@@ -1877,7 +2388,7 @@ class MessageStream {
|
|
|
1877
2388
|
executor().then(() => {
|
|
1878
2389
|
this._emitFinal();
|
|
1879
2390
|
this._emit("end");
|
|
1880
|
-
},
|
|
2391
|
+
}, __classPrivateFieldGet3(this, _MessageStream_handleError, "f"));
|
|
1881
2392
|
}
|
|
1882
2393
|
_addMessageParam(message) {
|
|
1883
2394
|
this.messages.push(message);
|
|
@@ -1895,42 +2406,44 @@ class MessageStream {
|
|
|
1895
2406
|
this.controller.abort();
|
|
1896
2407
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
1897
2408
|
}
|
|
1898
|
-
|
|
1899
|
-
const stream = await messages.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
1900
|
-
this._connected();
|
|
2409
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_beginRequest).call(this);
|
|
2410
|
+
const { response, data: stream } = await messages.create({ ...params, stream: true }, { ...options, signal: this.controller.signal }).withResponse();
|
|
2411
|
+
this._connected(response);
|
|
1901
2412
|
for await (const event of stream) {
|
|
1902
|
-
|
|
2413
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_addStreamEvent).call(this, event);
|
|
1903
2414
|
}
|
|
1904
2415
|
if (stream.controller.signal?.aborted) {
|
|
1905
2416
|
throw new APIUserAbortError;
|
|
1906
2417
|
}
|
|
1907
|
-
|
|
2418
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_endRequest).call(this);
|
|
1908
2419
|
}
|
|
1909
|
-
_connected() {
|
|
2420
|
+
_connected(response) {
|
|
1910
2421
|
if (this.ended)
|
|
1911
2422
|
return;
|
|
1912
|
-
|
|
2423
|
+
__classPrivateFieldSet3(this, _MessageStream_response, response, "f");
|
|
2424
|
+
__classPrivateFieldSet3(this, _MessageStream_request_id, response?.headers.get("request-id"), "f");
|
|
2425
|
+
__classPrivateFieldGet3(this, _MessageStream_resolveConnectedPromise, "f").call(this, response);
|
|
1913
2426
|
this._emit("connect");
|
|
1914
2427
|
}
|
|
1915
2428
|
get ended() {
|
|
1916
|
-
return
|
|
2429
|
+
return __classPrivateFieldGet3(this, _MessageStream_ended, "f");
|
|
1917
2430
|
}
|
|
1918
2431
|
get errored() {
|
|
1919
|
-
return
|
|
2432
|
+
return __classPrivateFieldGet3(this, _MessageStream_errored, "f");
|
|
1920
2433
|
}
|
|
1921
2434
|
get aborted() {
|
|
1922
|
-
return
|
|
2435
|
+
return __classPrivateFieldGet3(this, _MessageStream_aborted, "f");
|
|
1923
2436
|
}
|
|
1924
2437
|
abort() {
|
|
1925
2438
|
this.controller.abort();
|
|
1926
2439
|
}
|
|
1927
2440
|
on(event, listener) {
|
|
1928
|
-
const listeners =
|
|
2441
|
+
const listeners = __classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event] || (__classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event] = []);
|
|
1929
2442
|
listeners.push({ listener });
|
|
1930
2443
|
return this;
|
|
1931
2444
|
}
|
|
1932
2445
|
off(event, listener) {
|
|
1933
|
-
const listeners =
|
|
2446
|
+
const listeners = __classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event];
|
|
1934
2447
|
if (!listeners)
|
|
1935
2448
|
return this;
|
|
1936
2449
|
const index = listeners.findIndex((l) => l.listener === listener);
|
|
@@ -1939,69 +2452,69 @@ class MessageStream {
|
|
|
1939
2452
|
return this;
|
|
1940
2453
|
}
|
|
1941
2454
|
once(event, listener) {
|
|
1942
|
-
const listeners =
|
|
2455
|
+
const listeners = __classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event] || (__classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event] = []);
|
|
1943
2456
|
listeners.push({ listener, once: true });
|
|
1944
2457
|
return this;
|
|
1945
2458
|
}
|
|
1946
2459
|
emitted(event) {
|
|
1947
2460
|
return new Promise((resolve, reject) => {
|
|
1948
|
-
|
|
2461
|
+
__classPrivateFieldSet3(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
1949
2462
|
if (event !== "error")
|
|
1950
2463
|
this.once("error", reject);
|
|
1951
2464
|
this.once(event, resolve);
|
|
1952
2465
|
});
|
|
1953
2466
|
}
|
|
1954
2467
|
async done() {
|
|
1955
|
-
|
|
1956
|
-
await
|
|
2468
|
+
__classPrivateFieldSet3(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
2469
|
+
await __classPrivateFieldGet3(this, _MessageStream_endPromise, "f");
|
|
1957
2470
|
}
|
|
1958
2471
|
get currentMessage() {
|
|
1959
|
-
return
|
|
2472
|
+
return __classPrivateFieldGet3(this, _MessageStream_currentMessageSnapshot, "f");
|
|
1960
2473
|
}
|
|
1961
2474
|
async finalMessage() {
|
|
1962
2475
|
await this.done();
|
|
1963
|
-
return
|
|
2476
|
+
return __classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_getFinalMessage).call(this);
|
|
1964
2477
|
}
|
|
1965
2478
|
async finalText() {
|
|
1966
2479
|
await this.done();
|
|
1967
|
-
return
|
|
2480
|
+
return __classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_getFinalText).call(this);
|
|
1968
2481
|
}
|
|
1969
2482
|
_emit(event, ...args) {
|
|
1970
|
-
if (
|
|
2483
|
+
if (__classPrivateFieldGet3(this, _MessageStream_ended, "f"))
|
|
1971
2484
|
return;
|
|
1972
2485
|
if (event === "end") {
|
|
1973
|
-
|
|
1974
|
-
|
|
2486
|
+
__classPrivateFieldSet3(this, _MessageStream_ended, true, "f");
|
|
2487
|
+
__classPrivateFieldGet3(this, _MessageStream_resolveEndPromise, "f").call(this);
|
|
1975
2488
|
}
|
|
1976
|
-
const listeners =
|
|
2489
|
+
const listeners = __classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event];
|
|
1977
2490
|
if (listeners) {
|
|
1978
|
-
|
|
2491
|
+
__classPrivateFieldGet3(this, _MessageStream_listeners, "f")[event] = listeners.filter((l) => !l.once);
|
|
1979
2492
|
listeners.forEach(({ listener }) => listener(...args));
|
|
1980
2493
|
}
|
|
1981
2494
|
if (event === "abort") {
|
|
1982
2495
|
const error = args[0];
|
|
1983
|
-
if (!
|
|
2496
|
+
if (!__classPrivateFieldGet3(this, _MessageStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
1984
2497
|
Promise.reject(error);
|
|
1985
2498
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
2499
|
+
__classPrivateFieldGet3(this, _MessageStream_rejectConnectedPromise, "f").call(this, error);
|
|
2500
|
+
__classPrivateFieldGet3(this, _MessageStream_rejectEndPromise, "f").call(this, error);
|
|
1988
2501
|
this._emit("end");
|
|
1989
2502
|
return;
|
|
1990
2503
|
}
|
|
1991
2504
|
if (event === "error") {
|
|
1992
2505
|
const error = args[0];
|
|
1993
|
-
if (!
|
|
2506
|
+
if (!__classPrivateFieldGet3(this, _MessageStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
1994
2507
|
Promise.reject(error);
|
|
1995
2508
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
2509
|
+
__classPrivateFieldGet3(this, _MessageStream_rejectConnectedPromise, "f").call(this, error);
|
|
2510
|
+
__classPrivateFieldGet3(this, _MessageStream_rejectEndPromise, "f").call(this, error);
|
|
1998
2511
|
this._emit("end");
|
|
1999
2512
|
}
|
|
2000
2513
|
}
|
|
2001
2514
|
_emitFinal() {
|
|
2002
2515
|
const finalMessage = this.receivedMessages.at(-1);
|
|
2003
2516
|
if (finalMessage) {
|
|
2004
|
-
this._emit("finalMessage",
|
|
2517
|
+
this._emit("finalMessage", __classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_getFinalMessage).call(this));
|
|
2005
2518
|
}
|
|
2006
2519
|
}
|
|
2007
2520
|
async _fromReadableStream(readableStream, options) {
|
|
@@ -2011,18 +2524,18 @@ class MessageStream {
|
|
|
2011
2524
|
this.controller.abort();
|
|
2012
2525
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
2013
2526
|
}
|
|
2014
|
-
|
|
2015
|
-
this._connected();
|
|
2527
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_beginRequest).call(this);
|
|
2528
|
+
this._connected(null);
|
|
2016
2529
|
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
2017
2530
|
for await (const event of stream) {
|
|
2018
|
-
|
|
2531
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_addStreamEvent).call(this, event);
|
|
2019
2532
|
}
|
|
2020
2533
|
if (stream.controller.signal?.aborted) {
|
|
2021
2534
|
throw new APIUserAbortError;
|
|
2022
2535
|
}
|
|
2023
|
-
|
|
2536
|
+
__classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_endRequest).call(this);
|
|
2024
2537
|
}
|
|
2025
|
-
[(_MessageStream_currentMessageSnapshot = new WeakMap, _MessageStream_connectedPromise = new WeakMap, _MessageStream_resolveConnectedPromise = new WeakMap, _MessageStream_rejectConnectedPromise = new WeakMap, _MessageStream_endPromise = new WeakMap, _MessageStream_resolveEndPromise = new WeakMap, _MessageStream_rejectEndPromise = new WeakMap, _MessageStream_listeners = new WeakMap, _MessageStream_ended = new WeakMap, _MessageStream_errored = new WeakMap, _MessageStream_aborted = new WeakMap, _MessageStream_catchingPromiseCreated = new WeakMap, _MessageStream_handleError = new WeakMap, _MessageStream_instances = new WeakSet, _MessageStream_getFinalMessage = function _MessageStream_getFinalMessage() {
|
|
2538
|
+
[(_MessageStream_currentMessageSnapshot = new WeakMap, _MessageStream_connectedPromise = new WeakMap, _MessageStream_resolveConnectedPromise = new WeakMap, _MessageStream_rejectConnectedPromise = new WeakMap, _MessageStream_endPromise = new WeakMap, _MessageStream_resolveEndPromise = new WeakMap, _MessageStream_rejectEndPromise = new WeakMap, _MessageStream_listeners = new WeakMap, _MessageStream_ended = new WeakMap, _MessageStream_errored = new WeakMap, _MessageStream_aborted = new WeakMap, _MessageStream_catchingPromiseCreated = new WeakMap, _MessageStream_response = new WeakMap, _MessageStream_request_id = new WeakMap, _MessageStream_handleError = new WeakMap, _MessageStream_instances = new WeakSet, _MessageStream_getFinalMessage = function _MessageStream_getFinalMessage() {
|
|
2026
2539
|
if (this.receivedMessages.length === 0) {
|
|
2027
2540
|
throw new AnthropicError("stream ended without producing a Message with role=assistant");
|
|
2028
2541
|
}
|
|
@@ -2039,11 +2552,11 @@ class MessageStream {
|
|
|
2039
2552
|
}, _MessageStream_beginRequest = function _MessageStream_beginRequest() {
|
|
2040
2553
|
if (this.ended)
|
|
2041
2554
|
return;
|
|
2042
|
-
|
|
2555
|
+
__classPrivateFieldSet3(this, _MessageStream_currentMessageSnapshot, undefined, "f");
|
|
2043
2556
|
}, _MessageStream_addStreamEvent = function _MessageStream_addStreamEvent(event) {
|
|
2044
2557
|
if (this.ended)
|
|
2045
2558
|
return;
|
|
2046
|
-
const messageSnapshot =
|
|
2559
|
+
const messageSnapshot = __classPrivateFieldGet3(this, _MessageStream_instances, "m", _MessageStream_accumulateMessage).call(this, event);
|
|
2047
2560
|
this._emit("streamEvent", event, messageSnapshot);
|
|
2048
2561
|
switch (event.type) {
|
|
2049
2562
|
case "content_block_delta": {
|
|
@@ -2067,7 +2580,7 @@ class MessageStream {
|
|
|
2067
2580
|
break;
|
|
2068
2581
|
}
|
|
2069
2582
|
case "message_start": {
|
|
2070
|
-
|
|
2583
|
+
__classPrivateFieldSet3(this, _MessageStream_currentMessageSnapshot, messageSnapshot, "f");
|
|
2071
2584
|
break;
|
|
2072
2585
|
}
|
|
2073
2586
|
case "content_block_start":
|
|
@@ -2078,14 +2591,14 @@ class MessageStream {
|
|
|
2078
2591
|
if (this.ended) {
|
|
2079
2592
|
throw new AnthropicError(`stream has ended, this shouldn't happen`);
|
|
2080
2593
|
}
|
|
2081
|
-
const snapshot =
|
|
2594
|
+
const snapshot = __classPrivateFieldGet3(this, _MessageStream_currentMessageSnapshot, "f");
|
|
2082
2595
|
if (!snapshot) {
|
|
2083
2596
|
throw new AnthropicError(`request ended without sending any chunks`);
|
|
2084
2597
|
}
|
|
2085
|
-
|
|
2598
|
+
__classPrivateFieldSet3(this, _MessageStream_currentMessageSnapshot, undefined, "f");
|
|
2086
2599
|
return snapshot;
|
|
2087
2600
|
}, _MessageStream_accumulateMessage = function _MessageStream_accumulateMessage(event) {
|
|
2088
|
-
let snapshot =
|
|
2601
|
+
let snapshot = __classPrivateFieldGet3(this, _MessageStream_currentMessageSnapshot, "f");
|
|
2089
2602
|
if (event.type === "message_start") {
|
|
2090
2603
|
if (snapshot) {
|
|
2091
2604
|
throw new AnthropicError(`Unexpected event order, got ${event.type} before receiving "message_stop"`);
|
|
@@ -2111,9 +2624,9 @@ class MessageStream {
|
|
|
2111
2624
|
if (snapshotContent?.type === "text" && event.delta.type === "text_delta") {
|
|
2112
2625
|
snapshotContent.text += event.delta.text;
|
|
2113
2626
|
} else if (snapshotContent?.type === "tool_use" && event.delta.type === "input_json_delta") {
|
|
2114
|
-
let jsonBuf = snapshotContent[
|
|
2627
|
+
let jsonBuf = snapshotContent[JSON_BUF_PROPERTY2] || "";
|
|
2115
2628
|
jsonBuf += event.delta.partial_json;
|
|
2116
|
-
Object.defineProperty(snapshotContent,
|
|
2629
|
+
Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY2, {
|
|
2117
2630
|
value: jsonBuf,
|
|
2118
2631
|
enumerable: false,
|
|
2119
2632
|
writable: true
|
|
@@ -2190,8 +2703,8 @@ class Messages2 extends APIResource {
|
|
|
2190
2703
|
this.batches = new Batches2(this._client);
|
|
2191
2704
|
}
|
|
2192
2705
|
create(body, options) {
|
|
2193
|
-
if (body.model in
|
|
2194
|
-
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${
|
|
2706
|
+
if (body.model in DEPRECATED_MODELS2) {
|
|
2707
|
+
console.warn(`The model '${body.model}' is deprecated and will reach end-of-life on ${DEPRECATED_MODELS2[body.model]}
|
|
2195
2708
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);
|
|
2196
2709
|
}
|
|
2197
2710
|
return this._client.post("/v1/messages", {
|
|
@@ -2208,12 +2721,15 @@ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resour
|
|
|
2208
2721
|
return this._client.post("/v1/messages/count_tokens", { body, ...options });
|
|
2209
2722
|
}
|
|
2210
2723
|
}
|
|
2211
|
-
var
|
|
2724
|
+
var DEPRECATED_MODELS2 = {
|
|
2212
2725
|
"claude-1.3": "November 6th, 2024",
|
|
2213
2726
|
"claude-1.3-100k": "November 6th, 2024",
|
|
2214
2727
|
"claude-instant-1.1": "November 6th, 2024",
|
|
2215
2728
|
"claude-instant-1.1-100k": "November 6th, 2024",
|
|
2216
|
-
"claude-instant-1.2": "November 6th, 2024"
|
|
2729
|
+
"claude-instant-1.2": "November 6th, 2024",
|
|
2730
|
+
"claude-3-sonnet-20240229": "July 21st, 2025",
|
|
2731
|
+
"claude-2.1": "July 21st, 2025",
|
|
2732
|
+
"claude-2.0": "July 21st, 2025"
|
|
2217
2733
|
};
|
|
2218
2734
|
Messages2.Batches = Batches2;
|
|
2219
2735
|
Messages2.MessageBatchesPage = MessageBatchesPage;
|
|
@@ -2364,8 +2880,8 @@ class AiServiceBase {
|
|
|
2364
2880
|
for await (const chunk of stream) {
|
|
2365
2881
|
switch (chunk.type) {
|
|
2366
2882
|
case "usage":
|
|
2367
|
-
usage.inputTokens = chunk.inputTokens;
|
|
2368
|
-
usage.outputTokens = chunk.outputTokens;
|
|
2883
|
+
usage.inputTokens = chunk.inputTokens ?? 0;
|
|
2884
|
+
usage.outputTokens = chunk.outputTokens ?? 0;
|
|
2369
2885
|
usage.cacheWriteTokens = chunk.cacheWriteTokens ?? 0;
|
|
2370
2886
|
usage.cacheReadTokens = chunk.cacheReadTokens ?? 0;
|
|
2371
2887
|
usage.totalCost = chunk.totalCost;
|
|
@@ -2446,6 +2962,16 @@ var deepSeekModels = {
|
|
|
2446
2962
|
outputPrice: 0.28,
|
|
2447
2963
|
cacheWritesPrice: 0.14,
|
|
2448
2964
|
cacheReadsPrice: 0.014
|
|
2965
|
+
},
|
|
2966
|
+
"deepseek-reasoner": {
|
|
2967
|
+
maxTokens: 8000,
|
|
2968
|
+
contextWindow: 64000,
|
|
2969
|
+
supportsImages: false,
|
|
2970
|
+
supportsPromptCache: true,
|
|
2971
|
+
inputPrice: 0,
|
|
2972
|
+
outputPrice: 2.19,
|
|
2973
|
+
cacheWritesPrice: 0.55,
|
|
2974
|
+
cacheReadsPrice: 0.14
|
|
2449
2975
|
}
|
|
2450
2976
|
};
|
|
2451
2977
|
|
|
@@ -2461,7 +2987,7 @@ class AnthropicService extends AiServiceBase {
|
|
|
2461
2987
|
apiKey: options.apiKey,
|
|
2462
2988
|
baseURL: options.baseUrl || undefined
|
|
2463
2989
|
});
|
|
2464
|
-
const id = this.#options.
|
|
2990
|
+
const id = this.#options.model ?? anthropicDefaultModelId;
|
|
2465
2991
|
this.model = {
|
|
2466
2992
|
id,
|
|
2467
2993
|
info: anthropicModels[id] ?? anthropicModels[anthropicDefaultModelId]
|
|
@@ -2550,23 +3076,21 @@ class AnthropicService extends AiServiceBase {
|
|
|
2550
3076
|
switch (chunk.type) {
|
|
2551
3077
|
case "message_start": {
|
|
2552
3078
|
const usage = chunk.message.usage;
|
|
2553
|
-
|
|
3079
|
+
yield {
|
|
2554
3080
|
type: "usage",
|
|
2555
|
-
inputTokens: usage.input_tokens
|
|
2556
|
-
outputTokens: usage.output_tokens
|
|
2557
|
-
cacheWriteTokens: usage.cache_creation_input_tokens ||
|
|
2558
|
-
cacheReadTokens: usage.cache_read_input_tokens ||
|
|
3081
|
+
inputTokens: usage.input_tokens,
|
|
3082
|
+
outputTokens: usage.output_tokens,
|
|
3083
|
+
cacheWriteTokens: usage.cache_creation_input_tokens || 0,
|
|
3084
|
+
cacheReadTokens: usage.cache_read_input_tokens || 0
|
|
2559
3085
|
};
|
|
2560
|
-
yield usageInfo;
|
|
2561
3086
|
break;
|
|
2562
3087
|
}
|
|
2563
3088
|
case "message_delta": {
|
|
2564
|
-
|
|
3089
|
+
yield {
|
|
2565
3090
|
type: "usage",
|
|
2566
3091
|
inputTokens: 0,
|
|
2567
|
-
outputTokens: chunk.usage.output_tokens
|
|
3092
|
+
outputTokens: chunk.usage.output_tokens
|
|
2568
3093
|
};
|
|
2569
|
-
yield deltaUsage;
|
|
2570
3094
|
break;
|
|
2571
3095
|
}
|
|
2572
3096
|
case "message_stop":
|
|
@@ -2916,7 +3440,7 @@ function stringify(object, opts = {}) {
|
|
|
2916
3440
|
return joined.length > 0 ? prefix + joined : "";
|
|
2917
3441
|
}
|
|
2918
3442
|
// ../../node_modules/openai/version.mjs
|
|
2919
|
-
var VERSION2 = "4.
|
|
3443
|
+
var VERSION2 = "4.80.0";
|
|
2920
3444
|
|
|
2921
3445
|
// ../../node_modules/openai/_shims/registry.mjs
|
|
2922
3446
|
var auto2 = false;
|
|
@@ -3217,6 +3741,35 @@ LineDecoder2.NEWLINE_CHARS = new Set([`
|
|
|
3217
3741
|
`, "\r"]);
|
|
3218
3742
|
LineDecoder2.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
3219
3743
|
|
|
3744
|
+
// ../../node_modules/openai/internal/stream-utils.mjs
|
|
3745
|
+
function ReadableStreamToAsyncIterable2(stream) {
|
|
3746
|
+
if (stream[Symbol.asyncIterator])
|
|
3747
|
+
return stream;
|
|
3748
|
+
const reader = stream.getReader();
|
|
3749
|
+
return {
|
|
3750
|
+
async next() {
|
|
3751
|
+
try {
|
|
3752
|
+
const result = await reader.read();
|
|
3753
|
+
if (result?.done)
|
|
3754
|
+
reader.releaseLock();
|
|
3755
|
+
return result;
|
|
3756
|
+
} catch (e) {
|
|
3757
|
+
reader.releaseLock();
|
|
3758
|
+
throw e;
|
|
3759
|
+
}
|
|
3760
|
+
},
|
|
3761
|
+
async return() {
|
|
3762
|
+
const cancelPromise = reader.cancel();
|
|
3763
|
+
reader.releaseLock();
|
|
3764
|
+
await cancelPromise;
|
|
3765
|
+
return { done: true, value: undefined };
|
|
3766
|
+
},
|
|
3767
|
+
[Symbol.asyncIterator]() {
|
|
3768
|
+
return this;
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3220
3773
|
// ../../node_modules/openai/streaming.mjs
|
|
3221
3774
|
class Stream2 {
|
|
3222
3775
|
constructor(iterator, controller) {
|
|
@@ -3283,7 +3836,7 @@ class Stream2 {
|
|
|
3283
3836
|
let consumed = false;
|
|
3284
3837
|
async function* iterLines() {
|
|
3285
3838
|
const lineDecoder = new LineDecoder2;
|
|
3286
|
-
const iter =
|
|
3839
|
+
const iter = ReadableStreamToAsyncIterable2(readableStream);
|
|
3287
3840
|
for await (const chunk of iter) {
|
|
3288
3841
|
for (const line of lineDecoder.decode(chunk)) {
|
|
3289
3842
|
yield line;
|
|
@@ -3375,7 +3928,7 @@ async function* _iterSSEMessages2(response, controller) {
|
|
|
3375
3928
|
}
|
|
3376
3929
|
const sseDecoder = new SSEDecoder2;
|
|
3377
3930
|
const lineDecoder = new LineDecoder2;
|
|
3378
|
-
const iter =
|
|
3931
|
+
const iter = ReadableStreamToAsyncIterable2(response.body);
|
|
3379
3932
|
for await (const sseChunk of iterSSEChunks2(iter)) {
|
|
3380
3933
|
for (const line of lineDecoder.decode(sseChunk)) {
|
|
3381
3934
|
const sse = sseDecoder.decode(line);
|
|
@@ -3474,33 +4027,6 @@ function partition2(str, delimiter) {
|
|
|
3474
4027
|
}
|
|
3475
4028
|
return [str, "", ""];
|
|
3476
4029
|
}
|
|
3477
|
-
function readableStreamAsyncIterable2(stream) {
|
|
3478
|
-
if (stream[Symbol.asyncIterator])
|
|
3479
|
-
return stream;
|
|
3480
|
-
const reader = stream.getReader();
|
|
3481
|
-
return {
|
|
3482
|
-
async next() {
|
|
3483
|
-
try {
|
|
3484
|
-
const result = await reader.read();
|
|
3485
|
-
if (result?.done)
|
|
3486
|
-
reader.releaseLock();
|
|
3487
|
-
return result;
|
|
3488
|
-
} catch (e) {
|
|
3489
|
-
reader.releaseLock();
|
|
3490
|
-
throw e;
|
|
3491
|
-
}
|
|
3492
|
-
},
|
|
3493
|
-
async return() {
|
|
3494
|
-
const cancelPromise = reader.cancel();
|
|
3495
|
-
reader.releaseLock();
|
|
3496
|
-
await cancelPromise;
|
|
3497
|
-
return { done: true, value: undefined };
|
|
3498
|
-
},
|
|
3499
|
-
[Symbol.asyncIterator]() {
|
|
3500
|
-
return this;
|
|
3501
|
-
}
|
|
3502
|
-
};
|
|
3503
|
-
}
|
|
3504
4030
|
|
|
3505
4031
|
// ../../node_modules/openai/uploads.mjs
|
|
3506
4032
|
var isResponseLike2 = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function";
|
|
@@ -3591,7 +4117,7 @@ var addFormValue = async (form, key, value) => {
|
|
|
3591
4117
|
};
|
|
3592
4118
|
|
|
3593
4119
|
// ../../node_modules/openai/core.mjs
|
|
3594
|
-
var
|
|
4120
|
+
var __classPrivateFieldSet4 = function(receiver, state, value, kind3, f) {
|
|
3595
4121
|
if (kind3 === "m")
|
|
3596
4122
|
throw new TypeError("Private method is not writable");
|
|
3597
4123
|
if (kind3 === "a" && !f)
|
|
@@ -3600,7 +4126,7 @@ var __classPrivateFieldSet3 = function(receiver, state, value, kind3, f) {
|
|
|
3600
4126
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3601
4127
|
return kind3 === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
3602
4128
|
};
|
|
3603
|
-
var
|
|
4129
|
+
var __classPrivateFieldGet4 = function(receiver, state, kind3, f) {
|
|
3604
4130
|
if (kind3 === "a" && !f)
|
|
3605
4131
|
throw new TypeError("Private accessor was defined without a getter");
|
|
3606
4132
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -3950,7 +4476,7 @@ class APIClient2 {
|
|
|
3950
4476
|
class AbstractPage2 {
|
|
3951
4477
|
constructor(client, response, body, options) {
|
|
3952
4478
|
_AbstractPage_client2.set(this, undefined);
|
|
3953
|
-
|
|
4479
|
+
__classPrivateFieldSet4(this, _AbstractPage_client2, client, "f");
|
|
3954
4480
|
this.options = options;
|
|
3955
4481
|
this.response = response;
|
|
3956
4482
|
this.body = body;
|
|
@@ -3977,7 +4503,7 @@ class AbstractPage2 {
|
|
|
3977
4503
|
nextOptions.query = undefined;
|
|
3978
4504
|
nextOptions.path = nextInfo.url.toString();
|
|
3979
4505
|
}
|
|
3980
|
-
return await
|
|
4506
|
+
return await __classPrivateFieldGet4(this, _AbstractPage_client2, "f").requestAPIList(this.constructor, nextOptions);
|
|
3981
4507
|
}
|
|
3982
4508
|
async* iterPages() {
|
|
3983
4509
|
let page = this;
|
|
@@ -4211,9 +4737,32 @@ function applyHeadersMut2(targetHeaders, newHeaders) {
|
|
|
4211
4737
|
}
|
|
4212
4738
|
}
|
|
4213
4739
|
}
|
|
4740
|
+
var SENSITIVE_HEADERS = new Set(["authorization", "api-key"]);
|
|
4214
4741
|
function debug2(action, ...args) {
|
|
4215
4742
|
if (typeof process !== "undefined" && process?.env?.["DEBUG"] === "true") {
|
|
4216
|
-
|
|
4743
|
+
const modifiedArgs = args.map((arg) => {
|
|
4744
|
+
if (!arg) {
|
|
4745
|
+
return arg;
|
|
4746
|
+
}
|
|
4747
|
+
if (arg["headers"]) {
|
|
4748
|
+
const modifiedArg2 = { ...arg, headers: { ...arg["headers"] } };
|
|
4749
|
+
for (const header in arg["headers"]) {
|
|
4750
|
+
if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
|
|
4751
|
+
modifiedArg2["headers"][header] = "REDACTED";
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
return modifiedArg2;
|
|
4755
|
+
}
|
|
4756
|
+
let modifiedArg = null;
|
|
4757
|
+
for (const header in arg) {
|
|
4758
|
+
if (SENSITIVE_HEADERS.has(header.toLowerCase())) {
|
|
4759
|
+
modifiedArg ?? (modifiedArg = { ...arg });
|
|
4760
|
+
modifiedArg[header] = "REDACTED";
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
return modifiedArg ?? arg;
|
|
4764
|
+
});
|
|
4765
|
+
console.log(`OpenAI:DEBUG:${action}`, ...modifiedArgs);
|
|
4217
4766
|
}
|
|
4218
4767
|
}
|
|
4219
4768
|
var uuid42 = () => {
|
|
@@ -4450,7 +4999,7 @@ var isToolMessage = (message) => {
|
|
|
4450
4999
|
};
|
|
4451
5000
|
|
|
4452
5001
|
// ../../node_modules/openai/lib/EventStream.mjs
|
|
4453
|
-
var
|
|
5002
|
+
var __classPrivateFieldSet5 = function(receiver, state, value, kind3, f) {
|
|
4454
5003
|
if (kind3 === "m")
|
|
4455
5004
|
throw new TypeError("Private method is not writable");
|
|
4456
5005
|
if (kind3 === "a" && !f)
|
|
@@ -4459,7 +5008,7 @@ var __classPrivateFieldSet4 = function(receiver, state, value, kind3, f) {
|
|
|
4459
5008
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
4460
5009
|
return kind3 === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
4461
5010
|
};
|
|
4462
|
-
var
|
|
5011
|
+
var __classPrivateFieldGet5 = function(receiver, state, kind3, f) {
|
|
4463
5012
|
if (kind3 === "a" && !f)
|
|
4464
5013
|
throw new TypeError("Private accessor was defined without a getter");
|
|
4465
5014
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -4499,17 +5048,17 @@ class EventStream {
|
|
|
4499
5048
|
_EventStream_errored.set(this, false);
|
|
4500
5049
|
_EventStream_aborted.set(this, false);
|
|
4501
5050
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
5051
|
+
__classPrivateFieldSet5(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
|
|
5052
|
+
__classPrivateFieldSet5(this, _EventStream_resolveConnectedPromise, resolve, "f");
|
|
5053
|
+
__classPrivateFieldSet5(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
4505
5054
|
}), "f");
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
5055
|
+
__classPrivateFieldSet5(this, _EventStream_endPromise, new Promise((resolve, reject) => {
|
|
5056
|
+
__classPrivateFieldSet5(this, _EventStream_resolveEndPromise, resolve, "f");
|
|
5057
|
+
__classPrivateFieldSet5(this, _EventStream_rejectEndPromise, reject, "f");
|
|
4509
5058
|
}), "f");
|
|
4510
|
-
|
|
5059
|
+
__classPrivateFieldGet5(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
4511
5060
|
});
|
|
4512
|
-
|
|
5061
|
+
__classPrivateFieldGet5(this, _EventStream_endPromise, "f").catch(() => {
|
|
4513
5062
|
});
|
|
4514
5063
|
}
|
|
4515
5064
|
_run(executor) {
|
|
@@ -4517,34 +5066,34 @@ class EventStream {
|
|
|
4517
5066
|
executor().then(() => {
|
|
4518
5067
|
this._emitFinal();
|
|
4519
5068
|
this._emit("end");
|
|
4520
|
-
},
|
|
5069
|
+
}, __classPrivateFieldGet5(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
|
|
4521
5070
|
}, 0);
|
|
4522
5071
|
}
|
|
4523
5072
|
_connected() {
|
|
4524
5073
|
if (this.ended)
|
|
4525
5074
|
return;
|
|
4526
|
-
|
|
5075
|
+
__classPrivateFieldGet5(this, _EventStream_resolveConnectedPromise, "f").call(this);
|
|
4527
5076
|
this._emit("connect");
|
|
4528
5077
|
}
|
|
4529
5078
|
get ended() {
|
|
4530
|
-
return
|
|
5079
|
+
return __classPrivateFieldGet5(this, _EventStream_ended, "f");
|
|
4531
5080
|
}
|
|
4532
5081
|
get errored() {
|
|
4533
|
-
return
|
|
5082
|
+
return __classPrivateFieldGet5(this, _EventStream_errored, "f");
|
|
4534
5083
|
}
|
|
4535
5084
|
get aborted() {
|
|
4536
|
-
return
|
|
5085
|
+
return __classPrivateFieldGet5(this, _EventStream_aborted, "f");
|
|
4537
5086
|
}
|
|
4538
5087
|
abort() {
|
|
4539
5088
|
this.controller.abort();
|
|
4540
5089
|
}
|
|
4541
5090
|
on(event, listener) {
|
|
4542
|
-
const listeners =
|
|
5091
|
+
const listeners = __classPrivateFieldGet5(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet5(this, _EventStream_listeners, "f")[event] = []);
|
|
4543
5092
|
listeners.push({ listener });
|
|
4544
5093
|
return this;
|
|
4545
5094
|
}
|
|
4546
5095
|
off(event, listener) {
|
|
4547
|
-
const listeners =
|
|
5096
|
+
const listeners = __classPrivateFieldGet5(this, _EventStream_listeners, "f")[event];
|
|
4548
5097
|
if (!listeners)
|
|
4549
5098
|
return this;
|
|
4550
5099
|
const index = listeners.findIndex((l) => l.listener === listener);
|
|
@@ -4553,52 +5102,52 @@ class EventStream {
|
|
|
4553
5102
|
return this;
|
|
4554
5103
|
}
|
|
4555
5104
|
once(event, listener) {
|
|
4556
|
-
const listeners =
|
|
5105
|
+
const listeners = __classPrivateFieldGet5(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet5(this, _EventStream_listeners, "f")[event] = []);
|
|
4557
5106
|
listeners.push({ listener, once: true });
|
|
4558
5107
|
return this;
|
|
4559
5108
|
}
|
|
4560
5109
|
emitted(event) {
|
|
4561
5110
|
return new Promise((resolve, reject) => {
|
|
4562
|
-
|
|
5111
|
+
__classPrivateFieldSet5(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
4563
5112
|
if (event !== "error")
|
|
4564
5113
|
this.once("error", reject);
|
|
4565
5114
|
this.once(event, resolve);
|
|
4566
5115
|
});
|
|
4567
5116
|
}
|
|
4568
5117
|
async done() {
|
|
4569
|
-
|
|
4570
|
-
await
|
|
5118
|
+
__classPrivateFieldSet5(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
5119
|
+
await __classPrivateFieldGet5(this, _EventStream_endPromise, "f");
|
|
4571
5120
|
}
|
|
4572
5121
|
_emit(event, ...args) {
|
|
4573
|
-
if (
|
|
5122
|
+
if (__classPrivateFieldGet5(this, _EventStream_ended, "f")) {
|
|
4574
5123
|
return;
|
|
4575
5124
|
}
|
|
4576
5125
|
if (event === "end") {
|
|
4577
|
-
|
|
4578
|
-
|
|
5126
|
+
__classPrivateFieldSet5(this, _EventStream_ended, true, "f");
|
|
5127
|
+
__classPrivateFieldGet5(this, _EventStream_resolveEndPromise, "f").call(this);
|
|
4579
5128
|
}
|
|
4580
|
-
const listeners =
|
|
5129
|
+
const listeners = __classPrivateFieldGet5(this, _EventStream_listeners, "f")[event];
|
|
4581
5130
|
if (listeners) {
|
|
4582
|
-
|
|
5131
|
+
__classPrivateFieldGet5(this, _EventStream_listeners, "f")[event] = listeners.filter((l) => !l.once);
|
|
4583
5132
|
listeners.forEach(({ listener }) => listener(...args));
|
|
4584
5133
|
}
|
|
4585
5134
|
if (event === "abort") {
|
|
4586
5135
|
const error = args[0];
|
|
4587
|
-
if (!
|
|
5136
|
+
if (!__classPrivateFieldGet5(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
4588
5137
|
Promise.reject(error);
|
|
4589
5138
|
}
|
|
4590
|
-
|
|
4591
|
-
|
|
5139
|
+
__classPrivateFieldGet5(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
5140
|
+
__classPrivateFieldGet5(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
4592
5141
|
this._emit("end");
|
|
4593
5142
|
return;
|
|
4594
5143
|
}
|
|
4595
5144
|
if (event === "error") {
|
|
4596
5145
|
const error = args[0];
|
|
4597
|
-
if (!
|
|
5146
|
+
if (!__classPrivateFieldGet5(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
4598
5147
|
Promise.reject(error);
|
|
4599
5148
|
}
|
|
4600
|
-
|
|
4601
|
-
|
|
5149
|
+
__classPrivateFieldGet5(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
5150
|
+
__classPrivateFieldGet5(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
4602
5151
|
this._emit("end");
|
|
4603
5152
|
}
|
|
4604
5153
|
}
|
|
@@ -4606,12 +5155,12 @@ class EventStream {
|
|
|
4606
5155
|
}
|
|
4607
5156
|
}
|
|
4608
5157
|
_EventStream_connectedPromise = new WeakMap, _EventStream_resolveConnectedPromise = new WeakMap, _EventStream_rejectConnectedPromise = new WeakMap, _EventStream_endPromise = new WeakMap, _EventStream_resolveEndPromise = new WeakMap, _EventStream_rejectEndPromise = new WeakMap, _EventStream_listeners = new WeakMap, _EventStream_ended = new WeakMap, _EventStream_errored = new WeakMap, _EventStream_aborted = new WeakMap, _EventStream_catchingPromiseCreated = new WeakMap, _EventStream_instances = new WeakSet, _EventStream_handleError = function _EventStream_handleError2(error) {
|
|
4609
|
-
|
|
5158
|
+
__classPrivateFieldSet5(this, _EventStream_errored, true, "f");
|
|
4610
5159
|
if (error instanceof Error && error.name === "AbortError") {
|
|
4611
5160
|
error = new APIUserAbortError2;
|
|
4612
5161
|
}
|
|
4613
5162
|
if (error instanceof APIUserAbortError2) {
|
|
4614
|
-
|
|
5163
|
+
__classPrivateFieldSet5(this, _EventStream_aborted, true, "f");
|
|
4615
5164
|
return this._emit("abort", error);
|
|
4616
5165
|
}
|
|
4617
5166
|
if (error instanceof OpenAIError) {
|
|
@@ -4711,7 +5260,7 @@ function validateInputTools(tools) {
|
|
|
4711
5260
|
}
|
|
4712
5261
|
|
|
4713
5262
|
// ../../node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
4714
|
-
var
|
|
5263
|
+
var __classPrivateFieldGet6 = function(receiver, state, kind3, f) {
|
|
4715
5264
|
if (kind3 === "a" && !f)
|
|
4716
5265
|
throw new TypeError("Private accessor was defined without a getter");
|
|
4717
5266
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -4771,23 +5320,23 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4771
5320
|
}
|
|
4772
5321
|
async finalContent() {
|
|
4773
5322
|
await this.done();
|
|
4774
|
-
return
|
|
5323
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
4775
5324
|
}
|
|
4776
5325
|
async finalMessage() {
|
|
4777
5326
|
await this.done();
|
|
4778
|
-
return
|
|
5327
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
4779
5328
|
}
|
|
4780
5329
|
async finalFunctionCall() {
|
|
4781
5330
|
await this.done();
|
|
4782
|
-
return
|
|
5331
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
4783
5332
|
}
|
|
4784
5333
|
async finalFunctionCallResult() {
|
|
4785
5334
|
await this.done();
|
|
4786
|
-
return
|
|
5335
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
4787
5336
|
}
|
|
4788
5337
|
async totalUsage() {
|
|
4789
5338
|
await this.done();
|
|
4790
|
-
return
|
|
5339
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this);
|
|
4791
5340
|
}
|
|
4792
5341
|
allChatCompletions() {
|
|
4793
5342
|
return [...this._chatCompletions];
|
|
@@ -4796,20 +5345,20 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4796
5345
|
const completion = this._chatCompletions[this._chatCompletions.length - 1];
|
|
4797
5346
|
if (completion)
|
|
4798
5347
|
this._emit("finalChatCompletion", completion);
|
|
4799
|
-
const finalMessage =
|
|
5348
|
+
const finalMessage = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
4800
5349
|
if (finalMessage)
|
|
4801
5350
|
this._emit("finalMessage", finalMessage);
|
|
4802
|
-
const finalContent =
|
|
5351
|
+
const finalContent = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
4803
5352
|
if (finalContent)
|
|
4804
5353
|
this._emit("finalContent", finalContent);
|
|
4805
|
-
const finalFunctionCall =
|
|
5354
|
+
const finalFunctionCall = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
4806
5355
|
if (finalFunctionCall)
|
|
4807
5356
|
this._emit("finalFunctionCall", finalFunctionCall);
|
|
4808
|
-
const finalFunctionCallResult =
|
|
5357
|
+
const finalFunctionCallResult = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
4809
5358
|
if (finalFunctionCallResult != null)
|
|
4810
5359
|
this._emit("finalFunctionCallResult", finalFunctionCallResult);
|
|
4811
5360
|
if (this._chatCompletions.some((c) => c.usage)) {
|
|
4812
|
-
this._emit("totalUsage",
|
|
5361
|
+
this._emit("totalUsage", __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this));
|
|
4813
5362
|
}
|
|
4814
5363
|
}
|
|
4815
5364
|
async _createChatCompletion(client, params, options) {
|
|
@@ -4819,7 +5368,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4819
5368
|
this.controller.abort();
|
|
4820
5369
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
4821
5370
|
}
|
|
4822
|
-
|
|
5371
|
+
__classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
|
|
4823
5372
|
const chatCompletion = await client.chat.completions.create({ ...params, stream: false }, { ...options, signal: this.controller.signal });
|
|
4824
5373
|
this._connected();
|
|
4825
5374
|
return this._addChatCompletion(parseChatCompletion(chatCompletion, params));
|
|
@@ -4883,7 +5432,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4883
5432
|
continue;
|
|
4884
5433
|
}
|
|
4885
5434
|
const rawContent = await fn.function(parsed, this);
|
|
4886
|
-
const content =
|
|
5435
|
+
const content = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
4887
5436
|
this._addMessage({ role, name, content });
|
|
4888
5437
|
if (singleFunctionToCall)
|
|
4889
5438
|
return;
|
|
@@ -4969,7 +5518,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4969
5518
|
continue;
|
|
4970
5519
|
}
|
|
4971
5520
|
const rawContent = await fn.function(parsed, this);
|
|
4972
|
-
const content =
|
|
5521
|
+
const content = __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
4973
5522
|
this._addMessage({ role, tool_call_id, content });
|
|
4974
5523
|
if (singleFunctionToCall) {
|
|
4975
5524
|
return;
|
|
@@ -4980,7 +5529,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
4980
5529
|
}
|
|
4981
5530
|
}
|
|
4982
5531
|
_AbstractChatCompletionRunner_instances = new WeakSet, _AbstractChatCompletionRunner_getFinalContent = function _AbstractChatCompletionRunner_getFinalContent2() {
|
|
4983
|
-
return
|
|
5532
|
+
return __classPrivateFieldGet6(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
|
|
4984
5533
|
}, _AbstractChatCompletionRunner_getFinalMessage = function _AbstractChatCompletionRunner_getFinalMessage2() {
|
|
4985
5534
|
let i = this.messages.length;
|
|
4986
5535
|
while (i-- > 0) {
|
|
@@ -5287,7 +5836,7 @@ var _parseJSON = (jsonString, allow) => {
|
|
|
5287
5836
|
var partialParse2 = (input) => parseJSON(input, Allow.ALL ^ Allow.NUM);
|
|
5288
5837
|
|
|
5289
5838
|
// ../../node_modules/openai/lib/ChatCompletionStream.mjs
|
|
5290
|
-
var
|
|
5839
|
+
var __classPrivateFieldSet6 = function(receiver, state, value, kind3, f) {
|
|
5291
5840
|
if (kind3 === "m")
|
|
5292
5841
|
throw new TypeError("Private method is not writable");
|
|
5293
5842
|
if (kind3 === "a" && !f)
|
|
@@ -5296,7 +5845,7 @@ var __classPrivateFieldSet5 = function(receiver, state, value, kind3, f) {
|
|
|
5296
5845
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5297
5846
|
return kind3 === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
5298
5847
|
};
|
|
5299
|
-
var
|
|
5848
|
+
var __classPrivateFieldGet7 = function(receiver, state, kind3, f) {
|
|
5300
5849
|
if (kind3 === "a" && !f)
|
|
5301
5850
|
throw new TypeError("Private accessor was defined without a getter");
|
|
5302
5851
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -5323,11 +5872,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5323
5872
|
_ChatCompletionStream_params.set(this, undefined);
|
|
5324
5873
|
_ChatCompletionStream_choiceEventStates.set(this, undefined);
|
|
5325
5874
|
_ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
|
|
5326
|
-
|
|
5327
|
-
|
|
5875
|
+
__classPrivateFieldSet6(this, _ChatCompletionStream_params, params, "f");
|
|
5876
|
+
__classPrivateFieldSet6(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
5328
5877
|
}
|
|
5329
5878
|
get currentChatCompletionSnapshot() {
|
|
5330
|
-
return
|
|
5879
|
+
return __classPrivateFieldGet7(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
5331
5880
|
}
|
|
5332
5881
|
static fromReadableStream(stream) {
|
|
5333
5882
|
const runner = new ChatCompletionStream(null);
|
|
@@ -5347,16 +5896,16 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5347
5896
|
this.controller.abort();
|
|
5348
5897
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
5349
5898
|
}
|
|
5350
|
-
|
|
5899
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
5351
5900
|
const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
5352
5901
|
this._connected();
|
|
5353
5902
|
for await (const chunk of stream) {
|
|
5354
|
-
|
|
5903
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
5355
5904
|
}
|
|
5356
5905
|
if (stream.controller.signal?.aborted) {
|
|
5357
5906
|
throw new APIUserAbortError2;
|
|
5358
5907
|
}
|
|
5359
|
-
return this._addChatCompletion(
|
|
5908
|
+
return this._addChatCompletion(__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
5360
5909
|
}
|
|
5361
5910
|
async _fromReadableStream(readableStream, options) {
|
|
5362
5911
|
const signal = options?.signal;
|
|
@@ -5365,28 +5914,28 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5365
5914
|
this.controller.abort();
|
|
5366
5915
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
5367
5916
|
}
|
|
5368
|
-
|
|
5917
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
5369
5918
|
this._connected();
|
|
5370
5919
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
5371
5920
|
let chatId;
|
|
5372
5921
|
for await (const chunk of stream) {
|
|
5373
5922
|
if (chatId && chatId !== chunk.id) {
|
|
5374
|
-
this._addChatCompletion(
|
|
5923
|
+
this._addChatCompletion(__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
5375
5924
|
}
|
|
5376
|
-
|
|
5925
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
5377
5926
|
chatId = chunk.id;
|
|
5378
5927
|
}
|
|
5379
5928
|
if (stream.controller.signal?.aborted) {
|
|
5380
5929
|
throw new APIUserAbortError2;
|
|
5381
5930
|
}
|
|
5382
|
-
return this._addChatCompletion(
|
|
5931
|
+
return this._addChatCompletion(__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
5383
5932
|
}
|
|
5384
5933
|
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {
|
|
5385
5934
|
if (this.ended)
|
|
5386
5935
|
return;
|
|
5387
|
-
|
|
5936
|
+
__classPrivateFieldSet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
5388
5937
|
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {
|
|
5389
|
-
let state =
|
|
5938
|
+
let state = __classPrivateFieldGet7(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
5390
5939
|
if (state) {
|
|
5391
5940
|
return state;
|
|
5392
5941
|
}
|
|
@@ -5398,12 +5947,12 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5398
5947
|
done_tool_calls: new Set,
|
|
5399
5948
|
current_tool_call_index: null
|
|
5400
5949
|
};
|
|
5401
|
-
|
|
5950
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
5402
5951
|
return state;
|
|
5403
5952
|
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {
|
|
5404
5953
|
if (this.ended)
|
|
5405
5954
|
return;
|
|
5406
|
-
const completion =
|
|
5955
|
+
const completion = __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
5407
5956
|
this._emit("chunk", chunk, completion);
|
|
5408
5957
|
for (const choice of chunk.choices) {
|
|
5409
5958
|
const choiceSnapshot = completion.choices[choice.index];
|
|
@@ -5433,18 +5982,18 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5433
5982
|
snapshot: choiceSnapshot.logprobs?.refusal ?? []
|
|
5434
5983
|
});
|
|
5435
5984
|
}
|
|
5436
|
-
const state =
|
|
5985
|
+
const state = __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
5437
5986
|
if (choiceSnapshot.finish_reason) {
|
|
5438
|
-
|
|
5987
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
5439
5988
|
if (state.current_tool_call_index != null) {
|
|
5440
|
-
|
|
5989
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
5441
5990
|
}
|
|
5442
5991
|
}
|
|
5443
5992
|
for (const toolCall of choice.delta.tool_calls ?? []) {
|
|
5444
5993
|
if (state.current_tool_call_index !== toolCall.index) {
|
|
5445
|
-
|
|
5994
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
5446
5995
|
if (state.current_tool_call_index != null) {
|
|
5447
|
-
|
|
5996
|
+
__classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
5448
5997
|
}
|
|
5449
5998
|
}
|
|
5450
5999
|
state.current_tool_call_index = toolCall.index;
|
|
@@ -5468,7 +6017,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5468
6017
|
}
|
|
5469
6018
|
}
|
|
5470
6019
|
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {
|
|
5471
|
-
const state =
|
|
6020
|
+
const state = __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
5472
6021
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
5473
6022
|
return;
|
|
5474
6023
|
}
|
|
@@ -5480,7 +6029,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5480
6029
|
throw new Error("tool call snapshot missing `type`");
|
|
5481
6030
|
}
|
|
5482
6031
|
if (toolCallSnapshot.type === "function") {
|
|
5483
|
-
const inputTool =
|
|
6032
|
+
const inputTool = __classPrivateFieldGet7(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => tool.type === "function" && tool.function.name === toolCallSnapshot.function.name);
|
|
5484
6033
|
this._emit("tool_calls.function.arguments.done", {
|
|
5485
6034
|
name: toolCallSnapshot.function.name,
|
|
5486
6035
|
index: toolCallIndex,
|
|
@@ -5491,10 +6040,10 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5491
6040
|
assertNever(toolCallSnapshot.type);
|
|
5492
6041
|
}
|
|
5493
6042
|
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {
|
|
5494
|
-
const state =
|
|
6043
|
+
const state = __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
5495
6044
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
5496
6045
|
state.content_done = true;
|
|
5497
|
-
const responseFormat =
|
|
6046
|
+
const responseFormat = __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
|
|
5498
6047
|
this._emit("content.done", {
|
|
5499
6048
|
content: choiceSnapshot.message.content,
|
|
5500
6049
|
parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null
|
|
@@ -5516,25 +6065,25 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5516
6065
|
if (this.ended) {
|
|
5517
6066
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
5518
6067
|
}
|
|
5519
|
-
const snapshot =
|
|
6068
|
+
const snapshot = __classPrivateFieldGet7(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
5520
6069
|
if (!snapshot) {
|
|
5521
6070
|
throw new OpenAIError(`request ended without sending any chunks`);
|
|
5522
6071
|
}
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
return finalizeChatCompletion(snapshot,
|
|
6072
|
+
__classPrivateFieldSet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
6073
|
+
__classPrivateFieldSet6(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
6074
|
+
return finalizeChatCompletion(snapshot, __classPrivateFieldGet7(this, _ChatCompletionStream_params, "f"));
|
|
5526
6075
|
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {
|
|
5527
|
-
const responseFormat =
|
|
6076
|
+
const responseFormat = __classPrivateFieldGet7(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
5528
6077
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
5529
6078
|
return responseFormat;
|
|
5530
6079
|
}
|
|
5531
6080
|
return null;
|
|
5532
6081
|
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {
|
|
5533
6082
|
var _a2, _b, _c, _d;
|
|
5534
|
-
let snapshot =
|
|
6083
|
+
let snapshot = __classPrivateFieldGet7(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
5535
6084
|
const { choices, ...rest } = chunk;
|
|
5536
6085
|
if (!snapshot) {
|
|
5537
|
-
snapshot =
|
|
6086
|
+
snapshot = __classPrivateFieldSet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
|
|
5538
6087
|
...rest,
|
|
5539
6088
|
choices: []
|
|
5540
6089
|
}, "f");
|
|
@@ -5565,7 +6114,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5565
6114
|
}
|
|
5566
6115
|
if (finish_reason) {
|
|
5567
6116
|
choice.finish_reason = finish_reason;
|
|
5568
|
-
if (
|
|
6117
|
+
if (__classPrivateFieldGet7(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet7(this, _ChatCompletionStream_params, "f"))) {
|
|
5569
6118
|
if (finish_reason === "length") {
|
|
5570
6119
|
throw new LengthFinishReasonError;
|
|
5571
6120
|
}
|
|
@@ -5599,7 +6148,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5599
6148
|
}
|
|
5600
6149
|
if (content) {
|
|
5601
6150
|
choice.message.content = (choice.message.content || "") + content;
|
|
5602
|
-
if (!choice.message.refusal &&
|
|
6151
|
+
if (!choice.message.refusal && __classPrivateFieldGet7(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
|
|
5603
6152
|
choice.message.parsed = partialParse2(choice.message.content);
|
|
5604
6153
|
}
|
|
5605
6154
|
}
|
|
@@ -5619,7 +6168,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
5619
6168
|
tool_call.function.name = fn.name;
|
|
5620
6169
|
if (fn?.arguments) {
|
|
5621
6170
|
tool_call.function.arguments += fn.arguments;
|
|
5622
|
-
if (shouldParseToolCall(
|
|
6171
|
+
if (shouldParseToolCall(__classPrivateFieldGet7(this, _ChatCompletionStream_params, "f"), tool_call)) {
|
|
5623
6172
|
tool_call.function.parsed_arguments = partialParse2(tool_call.function.arguments);
|
|
5624
6173
|
}
|
|
5625
6174
|
}
|
|
@@ -5864,14 +6413,14 @@ class Realtime extends APIResource2 {
|
|
|
5864
6413
|
Realtime.Sessions = Sessions;
|
|
5865
6414
|
|
|
5866
6415
|
// ../../node_modules/openai/lib/AssistantStream.mjs
|
|
5867
|
-
var
|
|
6416
|
+
var __classPrivateFieldGet8 = function(receiver, state, kind3, f) {
|
|
5868
6417
|
if (kind3 === "a" && !f)
|
|
5869
6418
|
throw new TypeError("Private accessor was defined without a getter");
|
|
5870
6419
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
5871
6420
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5872
6421
|
return kind3 === "m" ? f : kind3 === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5873
6422
|
};
|
|
5874
|
-
var
|
|
6423
|
+
var __classPrivateFieldSet7 = function(receiver, state, value, kind3, f) {
|
|
5875
6424
|
if (kind3 === "m")
|
|
5876
6425
|
throw new TypeError("Private method is not writable");
|
|
5877
6426
|
if (kind3 === "a" && !f)
|
|
@@ -5985,12 +6534,12 @@ class AssistantStream extends EventStream {
|
|
|
5985
6534
|
this._connected();
|
|
5986
6535
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
5987
6536
|
for await (const event of stream) {
|
|
5988
|
-
|
|
6537
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
5989
6538
|
}
|
|
5990
6539
|
if (stream.controller.signal?.aborted) {
|
|
5991
6540
|
throw new APIUserAbortError2;
|
|
5992
6541
|
}
|
|
5993
|
-
return this._addRun(
|
|
6542
|
+
return this._addRun(__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
5994
6543
|
}
|
|
5995
6544
|
toReadableStream() {
|
|
5996
6545
|
const stream = new Stream2(this[Symbol.asyncIterator].bind(this), this.controller);
|
|
@@ -6018,12 +6567,12 @@ class AssistantStream extends EventStream {
|
|
|
6018
6567
|
});
|
|
6019
6568
|
this._connected();
|
|
6020
6569
|
for await (const event of stream) {
|
|
6021
|
-
|
|
6570
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
6022
6571
|
}
|
|
6023
6572
|
if (stream.controller.signal?.aborted) {
|
|
6024
6573
|
throw new APIUserAbortError2;
|
|
6025
6574
|
}
|
|
6026
|
-
return this._addRun(
|
|
6575
|
+
return this._addRun(__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
6027
6576
|
}
|
|
6028
6577
|
static createThreadAssistantStream(params, thread, options) {
|
|
6029
6578
|
const runner = new AssistantStream;
|
|
@@ -6042,30 +6591,30 @@ class AssistantStream extends EventStream {
|
|
|
6042
6591
|
return runner;
|
|
6043
6592
|
}
|
|
6044
6593
|
currentEvent() {
|
|
6045
|
-
return
|
|
6594
|
+
return __classPrivateFieldGet8(this, _AssistantStream_currentEvent, "f");
|
|
6046
6595
|
}
|
|
6047
6596
|
currentRun() {
|
|
6048
|
-
return
|
|
6597
|
+
return __classPrivateFieldGet8(this, _AssistantStream_currentRunSnapshot, "f");
|
|
6049
6598
|
}
|
|
6050
6599
|
currentMessageSnapshot() {
|
|
6051
|
-
return
|
|
6600
|
+
return __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f");
|
|
6052
6601
|
}
|
|
6053
6602
|
currentRunStepSnapshot() {
|
|
6054
|
-
return
|
|
6603
|
+
return __classPrivateFieldGet8(this, _AssistantStream_currentRunStepSnapshot, "f");
|
|
6055
6604
|
}
|
|
6056
6605
|
async finalRunSteps() {
|
|
6057
6606
|
await this.done();
|
|
6058
|
-
return Object.values(
|
|
6607
|
+
return Object.values(__classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f"));
|
|
6059
6608
|
}
|
|
6060
6609
|
async finalMessages() {
|
|
6061
6610
|
await this.done();
|
|
6062
|
-
return Object.values(
|
|
6611
|
+
return Object.values(__classPrivateFieldGet8(this, _AssistantStream_messageSnapshots, "f"));
|
|
6063
6612
|
}
|
|
6064
6613
|
async finalRun() {
|
|
6065
6614
|
await this.done();
|
|
6066
|
-
if (!
|
|
6615
|
+
if (!__classPrivateFieldGet8(this, _AssistantStream_finalRun, "f"))
|
|
6067
6616
|
throw Error("Final run was not received.");
|
|
6068
|
-
return
|
|
6617
|
+
return __classPrivateFieldGet8(this, _AssistantStream_finalRun, "f");
|
|
6069
6618
|
}
|
|
6070
6619
|
async _createThreadAssistantStream(thread, params, options) {
|
|
6071
6620
|
const signal = options?.signal;
|
|
@@ -6078,12 +6627,12 @@ class AssistantStream extends EventStream {
|
|
|
6078
6627
|
const stream = await thread.createAndRun(body, { ...options, signal: this.controller.signal });
|
|
6079
6628
|
this._connected();
|
|
6080
6629
|
for await (const event of stream) {
|
|
6081
|
-
|
|
6630
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
6082
6631
|
}
|
|
6083
6632
|
if (stream.controller.signal?.aborted) {
|
|
6084
6633
|
throw new APIUserAbortError2;
|
|
6085
6634
|
}
|
|
6086
|
-
return this._addRun(
|
|
6635
|
+
return this._addRun(__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
6087
6636
|
}
|
|
6088
6637
|
async _createAssistantStream(run, threadId, params, options) {
|
|
6089
6638
|
const signal = options?.signal;
|
|
@@ -6096,12 +6645,12 @@ class AssistantStream extends EventStream {
|
|
|
6096
6645
|
const stream = await run.create(threadId, body, { ...options, signal: this.controller.signal });
|
|
6097
6646
|
this._connected();
|
|
6098
6647
|
for await (const event of stream) {
|
|
6099
|
-
|
|
6648
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
6100
6649
|
}
|
|
6101
6650
|
if (stream.controller.signal?.aborted) {
|
|
6102
6651
|
throw new APIUserAbortError2;
|
|
6103
6652
|
}
|
|
6104
|
-
return this._addRun(
|
|
6653
|
+
return this._addRun(__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
6105
6654
|
}
|
|
6106
6655
|
static accumulateDelta(acc, delta) {
|
|
6107
6656
|
for (const [key, deltaValue] of Object.entries(delta)) {
|
|
@@ -6172,8 +6721,8 @@ class AssistantStream extends EventStream {
|
|
|
6172
6721
|
_AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
6173
6722
|
if (this.ended)
|
|
6174
6723
|
return;
|
|
6175
|
-
|
|
6176
|
-
|
|
6724
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentEvent, event, "f");
|
|
6725
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_handleEvent).call(this, event);
|
|
6177
6726
|
switch (event.event) {
|
|
6178
6727
|
case "thread.created":
|
|
6179
6728
|
break;
|
|
@@ -6186,7 +6735,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6186
6735
|
case "thread.run.cancelling":
|
|
6187
6736
|
case "thread.run.cancelled":
|
|
6188
6737
|
case "thread.run.expired":
|
|
6189
|
-
|
|
6738
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_handleRun).call(this, event);
|
|
6190
6739
|
break;
|
|
6191
6740
|
case "thread.run.step.created":
|
|
6192
6741
|
case "thread.run.step.in_progress":
|
|
@@ -6195,14 +6744,14 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6195
6744
|
case "thread.run.step.failed":
|
|
6196
6745
|
case "thread.run.step.cancelled":
|
|
6197
6746
|
case "thread.run.step.expired":
|
|
6198
|
-
|
|
6747
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_handleRunStep).call(this, event);
|
|
6199
6748
|
break;
|
|
6200
6749
|
case "thread.message.created":
|
|
6201
6750
|
case "thread.message.in_progress":
|
|
6202
6751
|
case "thread.message.delta":
|
|
6203
6752
|
case "thread.message.completed":
|
|
6204
6753
|
case "thread.message.incomplete":
|
|
6205
|
-
|
|
6754
|
+
__classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_handleMessage).call(this, event);
|
|
6206
6755
|
break;
|
|
6207
6756
|
case "error":
|
|
6208
6757
|
throw new Error("Encountered an error event in event processing - errors should be processed earlier");
|
|
@@ -6211,13 +6760,13 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6211
6760
|
if (this.ended) {
|
|
6212
6761
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
6213
6762
|
}
|
|
6214
|
-
if (!
|
|
6763
|
+
if (!__classPrivateFieldGet8(this, _AssistantStream_finalRun, "f"))
|
|
6215
6764
|
throw Error("Final run has not been received");
|
|
6216
|
-
return
|
|
6765
|
+
return __classPrivateFieldGet8(this, _AssistantStream_finalRun, "f");
|
|
6217
6766
|
}, _AssistantStream_handleMessage = function _AssistantStream_handleMessage2(event) {
|
|
6218
|
-
const [accumulatedMessage, newContent] =
|
|
6219
|
-
|
|
6220
|
-
|
|
6767
|
+
const [accumulatedMessage, newContent] = __classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_accumulateMessage).call(this, event, __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f"));
|
|
6768
|
+
__classPrivateFieldSet7(this, _AssistantStream_messageSnapshot, accumulatedMessage, "f");
|
|
6769
|
+
__classPrivateFieldGet8(this, _AssistantStream_messageSnapshots, "f")[accumulatedMessage.id] = accumulatedMessage;
|
|
6221
6770
|
for (const content of newContent) {
|
|
6222
6771
|
const snapshotContent = accumulatedMessage.content[content.index];
|
|
6223
6772
|
if (snapshotContent?.type == "text") {
|
|
@@ -6243,46 +6792,46 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6243
6792
|
throw Error("The snapshot associated with this text delta is not text or missing");
|
|
6244
6793
|
}
|
|
6245
6794
|
}
|
|
6246
|
-
if (content.index !=
|
|
6247
|
-
if (
|
|
6248
|
-
switch (
|
|
6795
|
+
if (content.index != __classPrivateFieldGet8(this, _AssistantStream_currentContentIndex, "f")) {
|
|
6796
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentContent, "f")) {
|
|
6797
|
+
switch (__classPrivateFieldGet8(this, _AssistantStream_currentContent, "f").type) {
|
|
6249
6798
|
case "text":
|
|
6250
|
-
this._emit("textDone",
|
|
6799
|
+
this._emit("textDone", __classPrivateFieldGet8(this, _AssistantStream_currentContent, "f").text, __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f"));
|
|
6251
6800
|
break;
|
|
6252
6801
|
case "image_file":
|
|
6253
|
-
this._emit("imageFileDone",
|
|
6802
|
+
this._emit("imageFileDone", __classPrivateFieldGet8(this, _AssistantStream_currentContent, "f").image_file, __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f"));
|
|
6254
6803
|
break;
|
|
6255
6804
|
}
|
|
6256
6805
|
}
|
|
6257
|
-
|
|
6806
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentContentIndex, content.index, "f");
|
|
6258
6807
|
}
|
|
6259
|
-
|
|
6808
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentContent, accumulatedMessage.content[content.index], "f");
|
|
6260
6809
|
}
|
|
6261
6810
|
}
|
|
6262
6811
|
break;
|
|
6263
6812
|
case "thread.message.completed":
|
|
6264
6813
|
case "thread.message.incomplete":
|
|
6265
|
-
if (
|
|
6266
|
-
const currentContent = event.data.content[
|
|
6814
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentContentIndex, "f") !== undefined) {
|
|
6815
|
+
const currentContent = event.data.content[__classPrivateFieldGet8(this, _AssistantStream_currentContentIndex, "f")];
|
|
6267
6816
|
if (currentContent) {
|
|
6268
6817
|
switch (currentContent.type) {
|
|
6269
6818
|
case "image_file":
|
|
6270
|
-
this._emit("imageFileDone", currentContent.image_file,
|
|
6819
|
+
this._emit("imageFileDone", currentContent.image_file, __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f"));
|
|
6271
6820
|
break;
|
|
6272
6821
|
case "text":
|
|
6273
|
-
this._emit("textDone", currentContent.text,
|
|
6822
|
+
this._emit("textDone", currentContent.text, __classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f"));
|
|
6274
6823
|
break;
|
|
6275
6824
|
}
|
|
6276
6825
|
}
|
|
6277
6826
|
}
|
|
6278
|
-
if (
|
|
6827
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_messageSnapshot, "f")) {
|
|
6279
6828
|
this._emit("messageDone", event.data);
|
|
6280
6829
|
}
|
|
6281
|
-
|
|
6830
|
+
__classPrivateFieldSet7(this, _AssistantStream_messageSnapshot, undefined, "f");
|
|
6282
6831
|
}
|
|
6283
6832
|
}, _AssistantStream_handleRunStep = function _AssistantStream_handleRunStep2(event) {
|
|
6284
|
-
const accumulatedRunStep =
|
|
6285
|
-
|
|
6833
|
+
const accumulatedRunStep = __classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_accumulateRunStep).call(this, event);
|
|
6834
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentRunStepSnapshot, accumulatedRunStep, "f");
|
|
6286
6835
|
switch (event.event) {
|
|
6287
6836
|
case "thread.run.step.created":
|
|
6288
6837
|
this._emit("runStepCreated", event.data);
|
|
@@ -6291,16 +6840,16 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6291
6840
|
const delta = event.data.delta;
|
|
6292
6841
|
if (delta.step_details && delta.step_details.type == "tool_calls" && delta.step_details.tool_calls && accumulatedRunStep.step_details.type == "tool_calls") {
|
|
6293
6842
|
for (const toolCall of delta.step_details.tool_calls) {
|
|
6294
|
-
if (toolCall.index ==
|
|
6843
|
+
if (toolCall.index == __classPrivateFieldGet8(this, _AssistantStream_currentToolCallIndex, "f")) {
|
|
6295
6844
|
this._emit("toolCallDelta", toolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index]);
|
|
6296
6845
|
} else {
|
|
6297
|
-
if (
|
|
6298
|
-
this._emit("toolCallDone",
|
|
6846
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f")) {
|
|
6847
|
+
this._emit("toolCallDone", __classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f"));
|
|
6299
6848
|
}
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
if (
|
|
6303
|
-
this._emit("toolCallCreated",
|
|
6849
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentToolCallIndex, toolCall.index, "f");
|
|
6850
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentToolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index], "f");
|
|
6851
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f"))
|
|
6852
|
+
this._emit("toolCallCreated", __classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f"));
|
|
6304
6853
|
}
|
|
6305
6854
|
}
|
|
6306
6855
|
}
|
|
@@ -6310,12 +6859,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6310
6859
|
case "thread.run.step.failed":
|
|
6311
6860
|
case "thread.run.step.cancelled":
|
|
6312
6861
|
case "thread.run.step.expired":
|
|
6313
|
-
|
|
6862
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentRunStepSnapshot, undefined, "f");
|
|
6314
6863
|
const details = event.data.step_details;
|
|
6315
6864
|
if (details.type == "tool_calls") {
|
|
6316
|
-
if (
|
|
6317
|
-
this._emit("toolCallDone",
|
|
6318
|
-
|
|
6865
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f")) {
|
|
6866
|
+
this._emit("toolCallDone", __classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f"));
|
|
6867
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
6319
6868
|
}
|
|
6320
6869
|
}
|
|
6321
6870
|
this._emit("runStepDone", event.data, accumulatedRunStep);
|
|
@@ -6324,34 +6873,34 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6324
6873
|
break;
|
|
6325
6874
|
}
|
|
6326
6875
|
}, _AssistantStream_handleEvent = function _AssistantStream_handleEvent2(event) {
|
|
6327
|
-
|
|
6876
|
+
__classPrivateFieldGet8(this, _AssistantStream_events, "f").push(event);
|
|
6328
6877
|
this._emit("event", event);
|
|
6329
6878
|
}, _AssistantStream_accumulateRunStep = function _AssistantStream_accumulateRunStep2(event) {
|
|
6330
6879
|
switch (event.event) {
|
|
6331
6880
|
case "thread.run.step.created":
|
|
6332
|
-
|
|
6881
|
+
__classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
6333
6882
|
return event.data;
|
|
6334
6883
|
case "thread.run.step.delta":
|
|
6335
|
-
let snapshot =
|
|
6884
|
+
let snapshot = __classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
6336
6885
|
if (!snapshot) {
|
|
6337
6886
|
throw Error("Received a RunStepDelta before creation of a snapshot");
|
|
6338
6887
|
}
|
|
6339
6888
|
let data = event.data;
|
|
6340
6889
|
if (data.delta) {
|
|
6341
6890
|
const accumulated = AssistantStream.accumulateDelta(snapshot, data.delta);
|
|
6342
|
-
|
|
6891
|
+
__classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = accumulated;
|
|
6343
6892
|
}
|
|
6344
|
-
return
|
|
6893
|
+
return __classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
6345
6894
|
case "thread.run.step.completed":
|
|
6346
6895
|
case "thread.run.step.failed":
|
|
6347
6896
|
case "thread.run.step.cancelled":
|
|
6348
6897
|
case "thread.run.step.expired":
|
|
6349
6898
|
case "thread.run.step.in_progress":
|
|
6350
|
-
|
|
6899
|
+
__classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
6351
6900
|
break;
|
|
6352
6901
|
}
|
|
6353
|
-
if (
|
|
6354
|
-
return
|
|
6902
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id])
|
|
6903
|
+
return __classPrivateFieldGet8(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
6355
6904
|
throw new Error("No snapshot available");
|
|
6356
6905
|
}, _AssistantStream_accumulateMessage = function _AssistantStream_accumulateMessage2(event, snapshot) {
|
|
6357
6906
|
let newContent = [];
|
|
@@ -6367,7 +6916,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6367
6916
|
for (const contentElement of data.delta.content) {
|
|
6368
6917
|
if (contentElement.index in snapshot.content) {
|
|
6369
6918
|
let currentContent = snapshot.content[contentElement.index];
|
|
6370
|
-
snapshot.content[contentElement.index] =
|
|
6919
|
+
snapshot.content[contentElement.index] = __classPrivateFieldGet8(this, _AssistantStream_instances, "m", _AssistantStream_accumulateContent).call(this, contentElement, currentContent);
|
|
6371
6920
|
} else {
|
|
6372
6921
|
snapshot.content[contentElement.index] = contentElement;
|
|
6373
6922
|
newContent.push(contentElement);
|
|
@@ -6388,7 +6937,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6388
6937
|
}, _AssistantStream_accumulateContent = function _AssistantStream_accumulateContent2(contentElement, currentContent) {
|
|
6389
6938
|
return AssistantStream.accumulateDelta(currentContent, contentElement);
|
|
6390
6939
|
}, _AssistantStream_handleRun = function _AssistantStream_handleRun2(event) {
|
|
6391
|
-
|
|
6940
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentRunSnapshot, event.data, "f");
|
|
6392
6941
|
switch (event.event) {
|
|
6393
6942
|
case "thread.run.created":
|
|
6394
6943
|
break;
|
|
@@ -6401,10 +6950,10 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
6401
6950
|
case "thread.run.failed":
|
|
6402
6951
|
case "thread.run.completed":
|
|
6403
6952
|
case "thread.run.expired":
|
|
6404
|
-
|
|
6405
|
-
if (
|
|
6406
|
-
this._emit("toolCallDone",
|
|
6407
|
-
|
|
6953
|
+
__classPrivateFieldSet7(this, _AssistantStream_finalRun, event.data, "f");
|
|
6954
|
+
if (__classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f")) {
|
|
6955
|
+
this._emit("toolCallDone", __classPrivateFieldGet8(this, _AssistantStream_currentToolCall, "f"));
|
|
6956
|
+
__classPrivateFieldSet7(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
6408
6957
|
}
|
|
6409
6958
|
break;
|
|
6410
6959
|
case "thread.run.cancelling":
|
|
@@ -7314,7 +7863,7 @@ class DeepSeekService extends AiServiceBase {
|
|
|
7314
7863
|
baseURL: "https://api.deepseek.com/v1",
|
|
7315
7864
|
apiKey: options.apiKey
|
|
7316
7865
|
});
|
|
7317
|
-
const id = options.
|
|
7866
|
+
const id = options.model || deepSeekDefaultModelId;
|
|
7318
7867
|
this.model = {
|
|
7319
7868
|
id,
|
|
7320
7869
|
info: deepSeekModels[id] ?? deepSeekModels[deepSeekDefaultModelId]
|
|
@@ -7365,7 +7914,7 @@ class OllamaService extends AiServiceBase {
|
|
|
7365
7914
|
apiKey: "ollama"
|
|
7366
7915
|
});
|
|
7367
7916
|
this.model = {
|
|
7368
|
-
id: options.
|
|
7917
|
+
id: options.model || "maryasov/qwen2.5-coder-cline:7b",
|
|
7369
7918
|
info: openAiModelInfoSaneDefaults
|
|
7370
7919
|
};
|
|
7371
7920
|
}
|
|
@@ -7425,11 +7974,14 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
7425
7974
|
const results = [];
|
|
7426
7975
|
const toolTags = tools.map((tool) => `${toolNamePrefix}${tool.name}`);
|
|
7427
7976
|
const toolPattern = toolTags.join("|");
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7977
|
+
let remainingMessage = assistantMessage;
|
|
7978
|
+
let match;
|
|
7979
|
+
const tagRegex = new RegExp(`<(${toolPattern})>([\\s\\S]*?)<\\/\\1>`, "s");
|
|
7980
|
+
while (true) {
|
|
7981
|
+
match = tagRegex.exec(remainingMessage);
|
|
7982
|
+
if (match === null)
|
|
7983
|
+
break;
|
|
7984
|
+
const beforeTag = remainingMessage.slice(0, match.index).trim();
|
|
7433
7985
|
if (beforeTag) {
|
|
7434
7986
|
results.push({
|
|
7435
7987
|
type: "text",
|
|
@@ -7439,6 +7991,7 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
7439
7991
|
const tagName = match[1];
|
|
7440
7992
|
const toolName = tagName.replace(toolNamePrefix, "");
|
|
7441
7993
|
const tool = tools.find((t) => t.name === toolName);
|
|
7994
|
+
const fullTagContent = match[0];
|
|
7442
7995
|
if (tool) {
|
|
7443
7996
|
const params = {};
|
|
7444
7997
|
for (const param of tool.parameters) {
|
|
@@ -7461,14 +8014,15 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
7461
8014
|
content: fullTagContent
|
|
7462
8015
|
});
|
|
7463
8016
|
}
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
}
|
|
7471
|
-
}
|
|
8017
|
+
remainingMessage = remainingMessage.slice(match.index + fullTagContent.length);
|
|
8018
|
+
}
|
|
8019
|
+
if (remainingMessage.trim()) {
|
|
8020
|
+
results.push({
|
|
8021
|
+
type: "text",
|
|
8022
|
+
content: remainingMessage.trim()
|
|
8023
|
+
});
|
|
8024
|
+
}
|
|
8025
|
+
if (results.length === 0) {
|
|
7472
8026
|
results.push({
|
|
7473
8027
|
type: "text",
|
|
7474
8028
|
content: assistantMessage
|
|
@@ -7651,8 +8205,8 @@ class AgentBase {
|
|
|
7651
8205
|
for await (const chunk of stream) {
|
|
7652
8206
|
switch (chunk.type) {
|
|
7653
8207
|
case "usage":
|
|
7654
|
-
info.inputTokens = chunk.inputTokens;
|
|
7655
|
-
info.outputTokens = chunk.outputTokens;
|
|
8208
|
+
info.inputTokens = chunk.inputTokens ?? 0;
|
|
8209
|
+
info.outputTokens = chunk.outputTokens ?? 0;
|
|
7656
8210
|
info.cacheWriteTokens = chunk.cacheWriteTokens ?? 0;
|
|
7657
8211
|
info.cacheReadTokens = chunk.cacheReadTokens ?? 0;
|
|
7658
8212
|
info.totalCost = chunk.totalCost;
|
|
@@ -8624,7 +9178,7 @@ The following additional instructions are provided by the user, and should be fo
|
|
|
8624
9178
|
|
|
8625
9179
|
${joined}`;
|
|
8626
9180
|
};
|
|
8627
|
-
var
|
|
9181
|
+
var customScripts = (commands) => {
|
|
8628
9182
|
const joined = Object.entries(commands).map(([name, command]) => {
|
|
8629
9183
|
if (typeof command === "string") {
|
|
8630
9184
|
return `- ${name}
|
|
@@ -8665,7 +9219,7 @@ NON-INTERACTIVE MODE
|
|
|
8665
9219
|
You are in non-interactive mode. This means you will not be able to ask user questions to gather additional information to complete the task. You should try to use available tools to accomplish the task. If unable to precede further, you may try to end the task and provide a reason.
|
|
8666
9220
|
`;
|
|
8667
9221
|
};
|
|
8668
|
-
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions,
|
|
9222
|
+
var fullSystemPrompt = (info, tools, toolNamePrefix, instructions, scripts, interactive) => `
|
|
8669
9223
|
${basePrompt}
|
|
8670
9224
|
${toolUsePrompt(tools, toolNamePrefix)}
|
|
8671
9225
|
${editingFilesPrompt(toolNamePrefix)}
|
|
@@ -8674,7 +9228,7 @@ ${rules(toolNamePrefix)}
|
|
|
8674
9228
|
${objectives(toolNamePrefix)}
|
|
8675
9229
|
${systemInformation(info)}
|
|
8676
9230
|
${customInstructions(instructions)}
|
|
8677
|
-
${
|
|
9231
|
+
${customScripts(scripts)}
|
|
8678
9232
|
${interactiveMode(interactive)}
|
|
8679
9233
|
`;
|
|
8680
9234
|
|
|
@@ -8686,7 +9240,7 @@ class CoderAgent extends AgentBase {
|
|
|
8686
9240
|
const toolNamePrefix = "tool_";
|
|
8687
9241
|
const systemPrompt = fullSystemPrompt({
|
|
8688
9242
|
os: options.os
|
|
8689
|
-
}, tools, toolNamePrefix, options.customInstructions ?? [], options.
|
|
9243
|
+
}, tools, toolNamePrefix, options.customInstructions ?? [], options.scripts ?? {}, options.interactive);
|
|
8690
9244
|
super(options.ai, {
|
|
8691
9245
|
systemPrompt,
|
|
8692
9246
|
tools,
|
|
@@ -8756,6 +9310,97 @@ ${output}`);
|
|
|
8756
9310
|
}
|
|
8757
9311
|
};
|
|
8758
9312
|
|
|
9313
|
+
// src/AiTool/generateGithubPullRequestDetails.ts
|
|
9314
|
+
var prompt2 = `
|
|
9315
|
+
You are given:
|
|
9316
|
+
- A branch name in <tool_input_branch_name>.
|
|
9317
|
+
- An optional context message in <tool_input_context> (which may or may not be present).
|
|
9318
|
+
- All commit messages combined in <tool_input_commit_messages>.
|
|
9319
|
+
- All diffs combined in <tool_input_commit_diff>.
|
|
9320
|
+
|
|
9321
|
+
Your task:
|
|
9322
|
+
1. Consider the optional context (if provided).
|
|
9323
|
+
2. Analyze the combined commit messages and diffs.
|
|
9324
|
+
3. Produce a single GitHub Pull Request title.
|
|
9325
|
+
4. Produce a Pull Request description that explains the changes.
|
|
9326
|
+
|
|
9327
|
+
Output format:
|
|
9328
|
+
<tool_output>
|
|
9329
|
+
<tool_output_pr_title>YOUR PR TITLE HERE</tool_output_pr_title>
|
|
9330
|
+
<tool_output_pr_description>YOUR PR DESCRIPTION HERE</tool_output_pr_description>
|
|
9331
|
+
</tool_output>
|
|
9332
|
+
|
|
9333
|
+
Below is an **example** of the input and output:
|
|
9334
|
+
|
|
9335
|
+
Example Input:
|
|
9336
|
+
<tool_input>
|
|
9337
|
+
<tool_input_branch_name>feature/refactor-logging</tool_input_branch_name>
|
|
9338
|
+
<tool_input_context>Focus on clean code and maintainability</tool_input_context>
|
|
9339
|
+
<tool_input_commit_messages>
|
|
9340
|
+
Remove debug logs
|
|
9341
|
+
Refactor order validation logic
|
|
9342
|
+
</tool_input_commit_messages>
|
|
9343
|
+
<tool_input_commit_diff>
|
|
9344
|
+
diff --git a/user_service.py b/user_service.py
|
|
9345
|
+
- print("Debug info")
|
|
9346
|
+
+ # Removed debug print statements
|
|
9347
|
+
|
|
9348
|
+
diff --git a/order_service.py b/order_service.py
|
|
9349
|
+
- if is_valid_order(order):
|
|
9350
|
+
- process_order(order)
|
|
9351
|
+
+ validate_and_process(order)
|
|
9352
|
+
</tool_input_commit_diff>
|
|
9353
|
+
</tool_input>
|
|
9354
|
+
|
|
9355
|
+
Example Output:
|
|
9356
|
+
<tool_output>
|
|
9357
|
+
<tool_output_pr_title>Refactor Order Validation and Remove Debug Logs</tool_output_pr_title>
|
|
9358
|
+
<tool_output_pr_description>
|
|
9359
|
+
This PR removes unnecessary debug print statements and updates order validation
|
|
9360
|
+
to use the new validate_and_process method for improved maintainability.
|
|
9361
|
+
</tool_output_pr_description>
|
|
9362
|
+
</tool_output>
|
|
9363
|
+
|
|
9364
|
+
---
|
|
9365
|
+
|
|
9366
|
+
Use the above format whenever you receive \`<tool_input>\` that may include a branch name, an optional context, aggregated commit messages in a single tag, and a combined diff in a single tag. Provide your final output strictly in \`<tool_output>\` with \`<tool_output_pr_title>\` and \`<tool_output_pr_description>\`.
|
|
9367
|
+
Only highlight the changed code and avoid including the context around the changes in the description.
|
|
9368
|
+
`;
|
|
9369
|
+
var generateGithubPullRequestDetails_default = {
|
|
9370
|
+
name: "generateGithubPullRequestDetails",
|
|
9371
|
+
description: "Generates a GitHub pull request title and description from git commits",
|
|
9372
|
+
prompt: prompt2,
|
|
9373
|
+
formatInput: (params) => {
|
|
9374
|
+
return `<tool_input>
|
|
9375
|
+
<tool_input_branch_name>${params.branchName}</tool_input_branch_name>${params.context ? `
|
|
9376
|
+
<tool_input_context>${params.context}</tool_input_context>` : ""}
|
|
9377
|
+
<tool_input_commit_messages>${params.commitMessages}</tool_input_commit_messages>
|
|
9378
|
+
<tool_input_commit_diff>${params.commitDiff}</tool_input_commit_diff>
|
|
9379
|
+
</tool_input>`;
|
|
9380
|
+
},
|
|
9381
|
+
parseOutput: (output) => {
|
|
9382
|
+
const regex = /<tool_output>([\s\S]*)<\/tool_output>/gm;
|
|
9383
|
+
const match = regex.exec(output);
|
|
9384
|
+
if (!match) {
|
|
9385
|
+
throw new Error(`Could not parse output:
|
|
9386
|
+
${output}`);
|
|
9387
|
+
}
|
|
9388
|
+
const [, outputContent] = match;
|
|
9389
|
+
const titleRegex = /<tool_output_pr_title>([\s\S]*)<\/tool_output_pr_title>/gm;
|
|
9390
|
+
const titleMatch = titleRegex.exec(outputContent);
|
|
9391
|
+
const descriptionRegex = /<tool_output_pr_description>([\s\S]*)<\/tool_output_pr_description>/gm;
|
|
9392
|
+
const descriptionMatch = descriptionRegex.exec(outputContent);
|
|
9393
|
+
if (titleMatch && descriptionMatch) {
|
|
9394
|
+
return {
|
|
9395
|
+
title: titleMatch[1],
|
|
9396
|
+
description: descriptionMatch[1]
|
|
9397
|
+
};
|
|
9398
|
+
}
|
|
9399
|
+
throw new Error(`Could not parse output:
|
|
9400
|
+
${output}`);
|
|
9401
|
+
}
|
|
9402
|
+
};
|
|
9403
|
+
|
|
8759
9404
|
// src/AiTool/index.ts
|
|
8760
9405
|
var executeTool = async (definition, ai, params) => {
|
|
8761
9406
|
const { response, usage } = await ai.request(definition.prompt, [{ role: "user", content: definition.formatInput(params) }]);
|
|
@@ -8770,6 +9415,7 @@ var makeTool = (definition) => {
|
|
|
8770
9415
|
};
|
|
8771
9416
|
};
|
|
8772
9417
|
var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
|
|
9418
|
+
var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
|
|
8773
9419
|
export {
|
|
8774
9420
|
writeToFile_default as writeToFile,
|
|
8775
9421
|
searchFiles_default as searchFiles,
|
|
@@ -8779,6 +9425,7 @@ export {
|
|
|
8779
9425
|
makeTool,
|
|
8780
9426
|
listFiles_default as listFiles,
|
|
8781
9427
|
listCodeDefinitionNames_default as listCodeDefinitionNames,
|
|
9428
|
+
generateGithubPullRequestDetails,
|
|
8782
9429
|
generateGitCommitMessage,
|
|
8783
9430
|
executeTool,
|
|
8784
9431
|
executeCommand_default as executeCommand,
|