@ngosangns/ns-bridge 0.1.6 → 0.1.8
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/refresh-entry.js +251 -268
- package/package.json +1 -1
package/dist/refresh-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ngosangns/ns-bridge 0.1.
|
|
1
|
+
// @ngosangns/ns-bridge 0.1.8 — catalog refresh bundle.
|
|
2
2
|
import { createRequire as __nsBridgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __nsBridgeCreateRequire(import.meta.url);
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1820,21 +1820,21 @@ var init_uuid = __esm({
|
|
|
1820
1820
|
});
|
|
1821
1821
|
|
|
1822
1822
|
// ../../node_modules/.pnpm/@anthropic-ai+sdk@0.129.0_zod@4.5.4/node_modules/@anthropic-ai/sdk/internal/tslib.mjs
|
|
1823
|
-
function __classPrivateFieldSet(receiver,
|
|
1823
|
+
function __classPrivateFieldSet(receiver, state2, value, kind, f3) {
|
|
1824
1824
|
if (kind === "m")
|
|
1825
1825
|
throw new TypeError("Private method is not writable");
|
|
1826
1826
|
if (kind === "a" && !f3)
|
|
1827
1827
|
throw new TypeError("Private accessor was defined without a setter");
|
|
1828
|
-
if (typeof
|
|
1828
|
+
if (typeof state2 === "function" ? receiver !== state2 || !f3 : !state2.has(receiver))
|
|
1829
1829
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1830
|
-
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value :
|
|
1830
|
+
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state2.set(receiver, value), value;
|
|
1831
1831
|
}
|
|
1832
|
-
function __classPrivateFieldGet(receiver,
|
|
1832
|
+
function __classPrivateFieldGet(receiver, state2, kind, f3) {
|
|
1833
1833
|
if (kind === "a" && !f3)
|
|
1834
1834
|
throw new TypeError("Private accessor was defined without a getter");
|
|
1835
|
-
if (typeof
|
|
1835
|
+
if (typeof state2 === "function" ? receiver !== state2 || !f3 : !state2.has(receiver))
|
|
1836
1836
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1837
|
-
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value :
|
|
1837
|
+
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state2.get(receiver);
|
|
1838
1838
|
}
|
|
1839
1839
|
var init_tslib = __esm({
|
|
1840
1840
|
"../../node_modules/.pnpm/@anthropic-ai+sdk@0.129.0_zod@4.5.4/node_modules/@anthropic-ai/sdk/internal/tslib.mjs"() {
|
|
@@ -18933,8 +18933,8 @@ function getBunSandboxEnvValue(name) {
|
|
|
18933
18933
|
if (procEnvCache === null) {
|
|
18934
18934
|
procEnvCache = /* @__PURE__ */ new Map();
|
|
18935
18935
|
try {
|
|
18936
|
-
const { readFileSync:
|
|
18937
|
-
const data =
|
|
18936
|
+
const { readFileSync: readFileSync8 } = __require("node:fs");
|
|
18937
|
+
const data = readFileSync8("/proc/self/environ", "utf-8");
|
|
18938
18938
|
for (const entry of data.split("\0")) {
|
|
18939
18939
|
const idx = entry.indexOf("=");
|
|
18940
18940
|
if (idx > 0) {
|
|
@@ -19850,25 +19850,25 @@ function getAnthropicFederation(model, apiKey, headers, env3) {
|
|
|
19850
19850
|
}
|
|
19851
19851
|
};
|
|
19852
19852
|
}
|
|
19853
|
-
function flushSseEvent(
|
|
19854
|
-
if (!
|
|
19853
|
+
function flushSseEvent(state2) {
|
|
19854
|
+
if (!state2.event && state2.data.length === 0) {
|
|
19855
19855
|
return null;
|
|
19856
19856
|
}
|
|
19857
19857
|
const event = {
|
|
19858
|
-
event:
|
|
19859
|
-
data:
|
|
19860
|
-
raw: [...
|
|
19858
|
+
event: state2.event,
|
|
19859
|
+
data: state2.data.join("\n"),
|
|
19860
|
+
raw: [...state2.raw]
|
|
19861
19861
|
};
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19862
|
+
state2.event = null;
|
|
19863
|
+
state2.data = [];
|
|
19864
|
+
state2.raw = [];
|
|
19865
19865
|
return event;
|
|
19866
19866
|
}
|
|
19867
|
-
function decodeSseLine(line,
|
|
19867
|
+
function decodeSseLine(line, state2) {
|
|
19868
19868
|
if (line === "") {
|
|
19869
|
-
return flushSseEvent(
|
|
19869
|
+
return flushSseEvent(state2);
|
|
19870
19870
|
}
|
|
19871
|
-
|
|
19871
|
+
state2.raw.push(line);
|
|
19872
19872
|
if (line.startsWith(":")) {
|
|
19873
19873
|
return null;
|
|
19874
19874
|
}
|
|
@@ -19879,9 +19879,9 @@ function decodeSseLine(line, state3) {
|
|
|
19879
19879
|
value = value.slice(1);
|
|
19880
19880
|
}
|
|
19881
19881
|
if (fieldName === "event") {
|
|
19882
|
-
|
|
19882
|
+
state2.event = value;
|
|
19883
19883
|
} else if (fieldName === "data") {
|
|
19884
|
-
|
|
19884
|
+
state2.data.push(value);
|
|
19885
19885
|
}
|
|
19886
19886
|
return null;
|
|
19887
19887
|
}
|
|
@@ -19913,7 +19913,7 @@ function consumeLine(text) {
|
|
|
19913
19913
|
async function* iterateSseMessages(body, signal) {
|
|
19914
19914
|
const reader = body.getReader();
|
|
19915
19915
|
const decoder = new TextDecoder();
|
|
19916
|
-
const
|
|
19916
|
+
const state2 = { event: null, data: [], raw: [] };
|
|
19917
19917
|
let buffer = "";
|
|
19918
19918
|
try {
|
|
19919
19919
|
while (true) {
|
|
@@ -19928,7 +19928,7 @@ async function* iterateSseMessages(body, signal) {
|
|
|
19928
19928
|
let consumed2 = consumeLine(buffer);
|
|
19929
19929
|
while (consumed2) {
|
|
19930
19930
|
buffer = consumed2.rest;
|
|
19931
|
-
const event = decodeSseLine(consumed2.line,
|
|
19931
|
+
const event = decodeSseLine(consumed2.line, state2);
|
|
19932
19932
|
if (event) {
|
|
19933
19933
|
yield event;
|
|
19934
19934
|
}
|
|
@@ -19939,19 +19939,19 @@ async function* iterateSseMessages(body, signal) {
|
|
|
19939
19939
|
let consumed = consumeLine(buffer);
|
|
19940
19940
|
while (consumed) {
|
|
19941
19941
|
buffer = consumed.rest;
|
|
19942
|
-
const event = decodeSseLine(consumed.line,
|
|
19942
|
+
const event = decodeSseLine(consumed.line, state2);
|
|
19943
19943
|
if (event) {
|
|
19944
19944
|
yield event;
|
|
19945
19945
|
}
|
|
19946
19946
|
consumed = consumeLine(buffer);
|
|
19947
19947
|
}
|
|
19948
19948
|
if (buffer.length > 0) {
|
|
19949
|
-
const event = decodeSseLine(buffer,
|
|
19949
|
+
const event = decodeSseLine(buffer, state2);
|
|
19950
19950
|
if (event) {
|
|
19951
19951
|
yield event;
|
|
19952
19952
|
}
|
|
19953
19953
|
}
|
|
19954
|
-
const trailingEvent = flushSseEvent(
|
|
19954
|
+
const trailingEvent = flushSseEvent(state2);
|
|
19955
19955
|
if (trailingEvent) {
|
|
19956
19956
|
yield trailingEvent;
|
|
19957
19957
|
}
|
|
@@ -20883,21 +20883,21 @@ var init_anthropic_messages = __esm({
|
|
|
20883
20883
|
});
|
|
20884
20884
|
|
|
20885
20885
|
// ../../node_modules/.pnpm/openai@7.19.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+signature-v4@5.7.4_undici@8.10.2_ws@8.21.3_zod@4.5.4/node_modules/openai/internal/tslib.mjs
|
|
20886
|
-
function __classPrivateFieldSet2(receiver,
|
|
20886
|
+
function __classPrivateFieldSet2(receiver, state2, value, kind, f3) {
|
|
20887
20887
|
if (kind === "m")
|
|
20888
20888
|
throw new TypeError("Private method is not writable");
|
|
20889
20889
|
if (kind === "a" && !f3)
|
|
20890
20890
|
throw new TypeError("Private accessor was defined without a setter");
|
|
20891
|
-
if (typeof
|
|
20891
|
+
if (typeof state2 === "function" ? receiver !== state2 || !f3 : !state2.has(receiver))
|
|
20892
20892
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
20893
|
-
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value :
|
|
20893
|
+
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state2.set(receiver, value), value;
|
|
20894
20894
|
}
|
|
20895
|
-
function __classPrivateFieldGet2(receiver,
|
|
20895
|
+
function __classPrivateFieldGet2(receiver, state2, kind, f3) {
|
|
20896
20896
|
if (kind === "a" && !f3)
|
|
20897
20897
|
throw new TypeError("Private accessor was defined without a getter");
|
|
20898
|
-
if (typeof
|
|
20898
|
+
if (typeof state2 === "function" ? receiver !== state2 || !f3 : !state2.has(receiver))
|
|
20899
20899
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20900
|
-
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value :
|
|
20900
|
+
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state2.get(receiver);
|
|
20901
20901
|
}
|
|
20902
20902
|
var init_tslib2 = __esm({
|
|
20903
20903
|
"../../node_modules/.pnpm/openai@7.19.0_@aws-sdk+credential-provider-node@3.972.84_@smithy+signature-v4@5.7.4_undici@8.10.2_ws@8.21.3_zod@4.5.4/node_modules/openai/internal/tslib.mjs"() {
|
|
@@ -27398,18 +27398,18 @@ function createPartialJSONParseState() {
|
|
|
27398
27398
|
pending_high_surrogate: false
|
|
27399
27399
|
};
|
|
27400
27400
|
}
|
|
27401
|
-
function recordPartialJSONFragment(
|
|
27401
|
+
function recordPartialJSONFragment(state2, budget, fragment, validationWorkBudget) {
|
|
27402
27402
|
if (budget.fragments >= MAX_PARTIAL_JSON_FRAGMENTS) {
|
|
27403
27403
|
throw new OpenAIError("Chat completion stream exceeded its structured JSON fragment limit");
|
|
27404
27404
|
}
|
|
27405
27405
|
let bytes = 0;
|
|
27406
|
-
let { depth, escaped, has_non_whitespace: hasNonWhitespace, in_string: inString } =
|
|
27406
|
+
let { depth, escaped, has_non_whitespace: hasNonWhitespace, in_string: inString } = state2;
|
|
27407
27407
|
let completed = false;
|
|
27408
27408
|
let firstCharacter = true;
|
|
27409
27409
|
for (const character of fragment) {
|
|
27410
27410
|
const previousBytes = bytes;
|
|
27411
27411
|
const codePoint = character.codePointAt(0);
|
|
27412
|
-
if (firstCharacter &&
|
|
27412
|
+
if (firstCharacter && state2.pending_high_surrogate && codePoint >= 56320 && codePoint <= 57343) {
|
|
27413
27413
|
bytes += 1;
|
|
27414
27414
|
} else if (codePoint <= 127) {
|
|
27415
27415
|
bytes += 1;
|
|
@@ -27454,15 +27454,15 @@ function recordPartialJSONFragment(state3, budget, fragment, validationWorkBudge
|
|
|
27454
27454
|
completed || (completed = depth === 0);
|
|
27455
27455
|
}
|
|
27456
27456
|
}
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
|
|
27457
|
+
state2.bytes += bytes;
|
|
27458
|
+
state2.fragments += 1;
|
|
27459
|
+
state2.depth = depth;
|
|
27460
|
+
state2.escaped = escaped;
|
|
27461
|
+
state2.has_non_whitespace = hasNonWhitespace;
|
|
27462
|
+
state2.in_string = inString;
|
|
27463
27463
|
if (fragment.length > 0) {
|
|
27464
27464
|
const finalCodeUnit = fragment.codePointAt(fragment.length - 1) ?? 0;
|
|
27465
|
-
|
|
27465
|
+
state2.pending_high_surrogate = finalCodeUnit >= 55296 && finalCodeUnit <= 56319;
|
|
27466
27466
|
}
|
|
27467
27467
|
budget.bytes += bytes;
|
|
27468
27468
|
budget.fragments += 1;
|
|
@@ -27472,19 +27472,19 @@ function recordPartialJSONFragment(state3, budget, fragment, validationWorkBudge
|
|
|
27472
27472
|
if (!hasNonWhitespace || bytes === 0) {
|
|
27473
27473
|
return false;
|
|
27474
27474
|
}
|
|
27475
|
-
const minimumGrowth = Math.max(EAGER_PARTIAL_JSON_BYTES, Math.floor(
|
|
27476
|
-
if (
|
|
27475
|
+
const minimumGrowth = Math.max(EAGER_PARTIAL_JSON_BYTES, Math.floor(state2.last_parsed_bytes / 2));
|
|
27476
|
+
if (state2.bytes > EAGER_PARTIAL_JSON_BYTES && !completed && state2.bytes - state2.last_parsed_bytes < minimumGrowth) {
|
|
27477
27477
|
return false;
|
|
27478
27478
|
}
|
|
27479
27479
|
return true;
|
|
27480
27480
|
}
|
|
27481
|
-
function reservePartialJSONParse(
|
|
27482
|
-
if (budget.work +
|
|
27481
|
+
function reservePartialJSONParse(state2, budget) {
|
|
27482
|
+
if (budget.work + state2.bytes > MAX_PARTIAL_JSON_PARSE_WORK) {
|
|
27483
27483
|
return false;
|
|
27484
27484
|
}
|
|
27485
|
-
budget.work +=
|
|
27486
|
-
|
|
27487
|
-
|
|
27485
|
+
budget.work += state2.bytes;
|
|
27486
|
+
state2.work += state2.bytes;
|
|
27487
|
+
state2.last_parsed_bytes = state2.bytes;
|
|
27488
27488
|
return true;
|
|
27489
27489
|
}
|
|
27490
27490
|
function captureStructuredJSONSnapshot(snapshot, property) {
|
|
@@ -27563,10 +27563,10 @@ function mapCapturedSnapshotArray(array, maximum, kind, map) {
|
|
|
27563
27563
|
return mapped;
|
|
27564
27564
|
}
|
|
27565
27565
|
function validateStructuredJSONSnapshot(value, budget, validationWorkBudget) {
|
|
27566
|
-
const
|
|
27566
|
+
const state2 = createPartialJSONParseState();
|
|
27567
27567
|
const parseBudget = budget ?? { bytes: 0, fragments: 0, work: 0 };
|
|
27568
|
-
recordPartialJSONFragment(
|
|
27569
|
-
if (!reservePartialJSONParse(
|
|
27568
|
+
recordPartialJSONFragment(state2, parseBudget, value, validationWorkBudget);
|
|
27569
|
+
if (!reservePartialJSONParse(state2, parseBudget)) {
|
|
27570
27570
|
throw new OpenAIError("Chat completion stream exceeded its structured JSON parse-work limit");
|
|
27571
27571
|
}
|
|
27572
27572
|
return value;
|
|
@@ -28358,11 +28358,11 @@ var init_ChatCompletionStream = __esm({
|
|
|
28358
28358
|
__classPrivateFieldSet2(this, _ChatCompletionStream_currentChatCompletionSnapshot, void 0, "f");
|
|
28359
28359
|
__classPrivateFieldSet2(this, _ChatCompletionStream_partialJSONParseBudget, { bytes: 0, fragments: 0, work: 0 }, "f");
|
|
28360
28360
|
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState2(choice) {
|
|
28361
|
-
let
|
|
28362
|
-
if (
|
|
28363
|
-
return
|
|
28361
|
+
let state2 = __classPrivateFieldGet2(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
28362
|
+
if (state2) {
|
|
28363
|
+
return state2;
|
|
28364
28364
|
}
|
|
28365
|
-
|
|
28365
|
+
state2 = {
|
|
28366
28366
|
content_done: false,
|
|
28367
28367
|
content_parse_state: void 0,
|
|
28368
28368
|
refusal_done: false,
|
|
@@ -28373,8 +28373,8 @@ var init_ChatCompletionStream = __esm({
|
|
|
28373
28373
|
tool_call_parse_states: /* @__PURE__ */ new Map(),
|
|
28374
28374
|
tool_call_identities: /* @__PURE__ */ new Map()
|
|
28375
28375
|
};
|
|
28376
|
-
__classPrivateFieldGet2(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] =
|
|
28377
|
-
return
|
|
28376
|
+
__classPrivateFieldGet2(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state2;
|
|
28377
|
+
return state2;
|
|
28378
28378
|
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk2(chunk) {
|
|
28379
28379
|
if (this.ended) {
|
|
28380
28380
|
return;
|
|
@@ -28419,21 +28419,21 @@ var init_ChatCompletionStream = __esm({
|
|
|
28419
28419
|
snapshot: choiceSnapshot.logprobs?.refusal ?? []
|
|
28420
28420
|
});
|
|
28421
28421
|
}
|
|
28422
|
-
const
|
|
28422
|
+
const state2 = __classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
28423
28423
|
if (choiceSnapshot.finish_reason) {
|
|
28424
28424
|
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
28425
|
-
if (
|
|
28426
|
-
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot,
|
|
28425
|
+
if (state2.current_tool_call_index != null) {
|
|
28426
|
+
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state2.current_tool_call_index);
|
|
28427
28427
|
}
|
|
28428
28428
|
}
|
|
28429
28429
|
for (const toolCall of capturedToolCalls) {
|
|
28430
|
-
if (
|
|
28430
|
+
if (state2.current_tool_call_index !== toolCall.index) {
|
|
28431
28431
|
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
28432
|
-
if (
|
|
28433
|
-
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot,
|
|
28432
|
+
if (state2.current_tool_call_index != null) {
|
|
28433
|
+
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state2.current_tool_call_index);
|
|
28434
28434
|
}
|
|
28435
28435
|
}
|
|
28436
|
-
|
|
28436
|
+
state2.current_tool_call_index = toolCall.index;
|
|
28437
28437
|
}
|
|
28438
28438
|
for (const toolCallDelta of capturedToolCalls) {
|
|
28439
28439
|
const toolCallSnapshot = messageSnapshot.tool_calls?.[toolCallDelta.index];
|
|
@@ -28441,7 +28441,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
28441
28441
|
continue;
|
|
28442
28442
|
}
|
|
28443
28443
|
if (toolCallSnapshot.type === "function") {
|
|
28444
|
-
const boundIdentity =
|
|
28444
|
+
const boundIdentity = state2.tool_call_identities.get(toolCallDelta.index);
|
|
28445
28445
|
let argumentsSnapshot;
|
|
28446
28446
|
if (boundIdentity?.parseable) {
|
|
28447
28447
|
const capturedArguments = captureStructuredJSONSnapshot(toolCallSnapshot.function, "arguments");
|
|
@@ -28465,8 +28465,8 @@ var init_ChatCompletionStream = __esm({
|
|
|
28465
28465
|
}
|
|
28466
28466
|
}
|
|
28467
28467
|
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent2(choiceSnapshot, toolCallIndex) {
|
|
28468
|
-
const
|
|
28469
|
-
if (
|
|
28468
|
+
const state2 = __classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
28469
|
+
if (state2.done_tool_calls.has(toolCallIndex)) {
|
|
28470
28470
|
return;
|
|
28471
28471
|
}
|
|
28472
28472
|
const messageSnapshot = __classPrivateFieldGet2(this, _ChatCompletionStream_hasAutoParseableTool, "f") ? captureStructuredMessageSnapshot(choiceSnapshot) : choiceSnapshot.message;
|
|
@@ -28474,7 +28474,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
28474
28474
|
if (!toolCallSnapshot) {
|
|
28475
28475
|
throw new Error("no tool call snapshot");
|
|
28476
28476
|
}
|
|
28477
|
-
const boundIdentity =
|
|
28477
|
+
const boundIdentity = state2.tool_call_identities.get(toolCallIndex);
|
|
28478
28478
|
if (boundIdentity) {
|
|
28479
28479
|
assertBoundToolCallIdentity(toolCallSnapshot, boundIdentity);
|
|
28480
28480
|
}
|
|
@@ -28504,7 +28504,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
28504
28504
|
parsedArguments = parseResponseFormatContent({ type: "json_schema", $parseRaw: void 0 }, validateStructuredJSONSnapshot(argumentsSnapshot));
|
|
28505
28505
|
}
|
|
28506
28506
|
if (choiceSnapshot.finish_reason) {
|
|
28507
|
-
|
|
28507
|
+
state2.done_tool_calls.add(toolCallIndex);
|
|
28508
28508
|
}
|
|
28509
28509
|
this._emit("tool_calls.function.arguments.done", {
|
|
28510
28510
|
name: toolCallSnapshot.function.name,
|
|
@@ -28516,33 +28516,33 @@ var init_ChatCompletionStream = __esm({
|
|
|
28516
28516
|
assertNever(toolCallSnapshot);
|
|
28517
28517
|
}
|
|
28518
28518
|
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents2(choiceSnapshot) {
|
|
28519
|
-
const
|
|
28519
|
+
const state2 = __classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
28520
28520
|
const structuredResponse = isParseableResponseFormat(__classPrivateFieldGet2(this, _ChatCompletionStream_params, "f")?.response_format);
|
|
28521
28521
|
const boundedSnapshot = structuredResponse || __classPrivateFieldGet2(this, _ChatCompletionStream_hasAutoParseableTool, "f");
|
|
28522
28522
|
const messageSnapshot = boundedSnapshot ? captureStructuredMessageSnapshot(choiceSnapshot) : choiceSnapshot.message;
|
|
28523
28523
|
const refusal = boundedSnapshot ? captureStructuredJSONSnapshot(messageSnapshot, "refusal") : messageSnapshot.refusal;
|
|
28524
28524
|
const parseableContent = !refusal && structuredResponse;
|
|
28525
28525
|
const content = parseableContent ? captureStructuredJSONSnapshot(messageSnapshot, "content") : messageSnapshot.content;
|
|
28526
|
-
if (content != null && (content !== "" || !refusal && !messageSnapshot.tool_calls?.length && !messageSnapshot.function_call) && !
|
|
28526
|
+
if (content != null && (content !== "" || !refusal && !messageSnapshot.tool_calls?.length && !messageSnapshot.function_call) && !state2.content_done) {
|
|
28527
28527
|
if (parseableContent && __classPrivateFieldGet2(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f")) {
|
|
28528
28528
|
__classPrivateFieldGet2(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_validateStructuredSnapshots).call(this, __classPrivateFieldGet2(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f"));
|
|
28529
28529
|
}
|
|
28530
|
-
|
|
28530
|
+
state2.content_done = true;
|
|
28531
28531
|
this._emit("content.done", {
|
|
28532
28532
|
content,
|
|
28533
28533
|
parsed: refusal ? null : parseResponseFormatContent(__classPrivateFieldGet2(this, _ChatCompletionStream_params, "f")?.response_format, parseableContent ? validateStructuredJSONSnapshot(content) : content)
|
|
28534
28534
|
});
|
|
28535
28535
|
}
|
|
28536
|
-
if (refusal && !
|
|
28537
|
-
|
|
28536
|
+
if (refusal && !state2.refusal_done) {
|
|
28537
|
+
state2.refusal_done = true;
|
|
28538
28538
|
this._emit("refusal.done", { refusal });
|
|
28539
28539
|
}
|
|
28540
|
-
if (choiceSnapshot.logprobs?.content && !
|
|
28541
|
-
|
|
28540
|
+
if (choiceSnapshot.logprobs?.content && !state2.logprobs_content_done) {
|
|
28541
|
+
state2.logprobs_content_done = true;
|
|
28542
28542
|
this._emit("logprobs.content.done", { content: choiceSnapshot.logprobs.content });
|
|
28543
28543
|
}
|
|
28544
|
-
if (choiceSnapshot.logprobs?.refusal && !
|
|
28545
|
-
|
|
28544
|
+
if (choiceSnapshot.logprobs?.refusal && !state2.logprobs_refusal_done) {
|
|
28545
|
+
state2.logprobs_refusal_done = true;
|
|
28546
28546
|
this._emit("logprobs.refusal.done", { refusal: choiceSnapshot.logprobs.refusal });
|
|
28547
28547
|
}
|
|
28548
28548
|
}, _ChatCompletionStream_validateStructuredSnapshots = function _ChatCompletionStream_validateStructuredSnapshots2(snapshot) {
|
|
@@ -28570,11 +28570,11 @@ var init_ChatCompletionStream = __esm({
|
|
|
28570
28570
|
toolCallCollection: toolCalls,
|
|
28571
28571
|
toolCalls: validatedTools
|
|
28572
28572
|
}));
|
|
28573
|
-
const
|
|
28573
|
+
const state2 = __classPrivateFieldGet2(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
28574
28574
|
if (parseableContent && !refusal && typeof content === "string") {
|
|
28575
28575
|
validateStructuredJSONSnapshot(content, finalJSONBudget, __classPrivateFieldGet2(this, _ChatCompletionStream_partialJSONParseBudget, "f"));
|
|
28576
28576
|
}
|
|
28577
|
-
for (const [index, identity] of
|
|
28577
|
+
for (const [index, identity] of state2?.tool_call_identities ?? []) {
|
|
28578
28578
|
const toolCall = toolCalls && captureSnapshotArrayItem(toolCalls, index);
|
|
28579
28579
|
if (!toolCall) {
|
|
28580
28580
|
throw new OpenAIError("Chat completion stream contains a changed tool call identity");
|
|
@@ -32503,7 +32503,7 @@ var init_agent_session_stream = __esm({
|
|
|
32503
32503
|
externalSignal?.addEventListener("abort", abort, { once: true });
|
|
32504
32504
|
this.controller.signal.addEventListener("abort", abort, { once: true });
|
|
32505
32505
|
const options = { ...__classPrivateFieldGet2(this, _AgentSessionStream_options, "f"), signal: this.controller.signal };
|
|
32506
|
-
const
|
|
32506
|
+
const state2 = new TurnState();
|
|
32507
32507
|
try {
|
|
32508
32508
|
if (externalSignal?.aborted) {
|
|
32509
32509
|
this.abort(externalSignal.reason);
|
|
@@ -32529,11 +32529,11 @@ var init_agent_session_stream = __esm({
|
|
|
32529
32529
|
__classPrivateFieldSet2(this, _AgentSessionStream_reading, true, "f");
|
|
32530
32530
|
for await (const event of __classPrivateFieldGet2(this, _AgentSessionStream_stream, "f")) {
|
|
32531
32531
|
__classPrivateFieldGet2(this, _AgentSessionStream_instances, "m", _AgentSessionStream_checkAbort).call(this);
|
|
32532
|
-
if (!
|
|
32532
|
+
if (!state2.accept(event)) {
|
|
32533
32533
|
continue;
|
|
32534
32534
|
}
|
|
32535
|
-
const terminal =
|
|
32536
|
-
const pendingCall =
|
|
32535
|
+
const terminal = state2.terminal(event);
|
|
32536
|
+
const pendingCall = state2.call(event);
|
|
32537
32537
|
const handler = pendingCall && __classPrivateFieldGet2(this, _AgentSessionStream_handlers, "f").get(pendingCall.name);
|
|
32538
32538
|
const call = pendingCall && handler ? structuredClone(pendingCall) : void 0;
|
|
32539
32539
|
if (terminal) {
|
|
@@ -45117,9 +45117,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
45117
45117
|
if (this._closeRequested) {
|
|
45118
45118
|
throw new TypeError("The stream has already been closed; do not close it again!");
|
|
45119
45119
|
}
|
|
45120
|
-
const
|
|
45121
|
-
if (
|
|
45122
|
-
throw new TypeError(`The stream (in ${
|
|
45120
|
+
const state2 = this._controlledReadableByteStream._state;
|
|
45121
|
+
if (state2 !== "readable") {
|
|
45122
|
+
throw new TypeError(`The stream (in ${state2} state) is not in the readable state and cannot be closed`);
|
|
45123
45123
|
}
|
|
45124
45124
|
ReadableByteStreamControllerClose(this);
|
|
45125
45125
|
}
|
|
@@ -45140,9 +45140,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
45140
45140
|
if (this._closeRequested) {
|
|
45141
45141
|
throw new TypeError("stream is closed or draining");
|
|
45142
45142
|
}
|
|
45143
|
-
const
|
|
45144
|
-
if (
|
|
45145
|
-
throw new TypeError(`The stream (in ${
|
|
45143
|
+
const state2 = this._controlledReadableByteStream._state;
|
|
45144
|
+
if (state2 !== "readable") {
|
|
45145
|
+
throw new TypeError(`The stream (in ${state2} state) is not in the readable state and cannot be enqueued to`);
|
|
45146
45146
|
}
|
|
45147
45147
|
ReadableByteStreamControllerEnqueue(this, chunk);
|
|
45148
45148
|
}
|
|
@@ -45460,8 +45460,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
45460
45460
|
function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
45461
45461
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
45462
45462
|
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
45463
|
-
const
|
|
45464
|
-
if (
|
|
45463
|
+
const state2 = controller._controlledReadableByteStream._state;
|
|
45464
|
+
if (state2 === "closed") {
|
|
45465
45465
|
ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
|
|
45466
45466
|
} else {
|
|
45467
45467
|
ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
|
|
@@ -45587,19 +45587,19 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
45587
45587
|
return controller._byobRequest;
|
|
45588
45588
|
}
|
|
45589
45589
|
function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
45590
|
-
const
|
|
45591
|
-
if (
|
|
45590
|
+
const state2 = controller._controlledReadableByteStream._state;
|
|
45591
|
+
if (state2 === "errored") {
|
|
45592
45592
|
return null;
|
|
45593
45593
|
}
|
|
45594
|
-
if (
|
|
45594
|
+
if (state2 === "closed") {
|
|
45595
45595
|
return 0;
|
|
45596
45596
|
}
|
|
45597
45597
|
return controller._strategyHWM - controller._queueTotalSize;
|
|
45598
45598
|
}
|
|
45599
45599
|
function ReadableByteStreamControllerRespond(controller, bytesWritten) {
|
|
45600
45600
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
45601
|
-
const
|
|
45602
|
-
if (
|
|
45601
|
+
const state2 = controller._controlledReadableByteStream._state;
|
|
45602
|
+
if (state2 === "closed") {
|
|
45603
45603
|
if (bytesWritten !== 0) {
|
|
45604
45604
|
throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
|
|
45605
45605
|
}
|
|
@@ -45616,8 +45616,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
45616
45616
|
}
|
|
45617
45617
|
function ReadableByteStreamControllerRespondWithNewView(controller, view) {
|
|
45618
45618
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
45619
|
-
const
|
|
45620
|
-
if (
|
|
45619
|
+
const state2 = controller._controlledReadableByteStream._state;
|
|
45620
|
+
if (state2 === "closed") {
|
|
45621
45621
|
if (view.byteLength !== 0) {
|
|
45622
45622
|
throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
|
|
45623
45623
|
}
|
|
@@ -46124,15 +46124,15 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46124
46124
|
}
|
|
46125
46125
|
stream11._writableStreamController._abortReason = reason;
|
|
46126
46126
|
(_a8 = stream11._writableStreamController._abortController) === null || _a8 === void 0 ? void 0 : _a8.abort(reason);
|
|
46127
|
-
const
|
|
46128
|
-
if (
|
|
46127
|
+
const state2 = stream11._state;
|
|
46128
|
+
if (state2 === "closed" || state2 === "errored") {
|
|
46129
46129
|
return promiseResolvedWith(void 0);
|
|
46130
46130
|
}
|
|
46131
46131
|
if (stream11._pendingAbortRequest !== void 0) {
|
|
46132
46132
|
return stream11._pendingAbortRequest._promise;
|
|
46133
46133
|
}
|
|
46134
46134
|
let wasAlreadyErroring = false;
|
|
46135
|
-
if (
|
|
46135
|
+
if (state2 === "erroring") {
|
|
46136
46136
|
wasAlreadyErroring = true;
|
|
46137
46137
|
reason = void 0;
|
|
46138
46138
|
}
|
|
@@ -46152,9 +46152,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46152
46152
|
return promise;
|
|
46153
46153
|
}
|
|
46154
46154
|
function WritableStreamClose(stream11) {
|
|
46155
|
-
const
|
|
46156
|
-
if (
|
|
46157
|
-
return promiseRejectedWith(new TypeError(`The stream (in ${
|
|
46155
|
+
const state2 = stream11._state;
|
|
46156
|
+
if (state2 === "closed" || state2 === "errored") {
|
|
46157
|
+
return promiseRejectedWith(new TypeError(`The stream (in ${state2} state) is not in the writable state and cannot be closed`));
|
|
46158
46158
|
}
|
|
46159
46159
|
const promise = newPromise((resolve2, reject) => {
|
|
46160
46160
|
const closeRequest = {
|
|
@@ -46164,7 +46164,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46164
46164
|
stream11._closeRequest = closeRequest;
|
|
46165
46165
|
});
|
|
46166
46166
|
const writer = stream11._writer;
|
|
46167
|
-
if (writer !== void 0 && stream11._backpressure &&
|
|
46167
|
+
if (writer !== void 0 && stream11._backpressure && state2 === "writable") {
|
|
46168
46168
|
defaultWriterReadyPromiseResolve(writer);
|
|
46169
46169
|
}
|
|
46170
46170
|
WritableStreamDefaultControllerClose(stream11._writableStreamController);
|
|
@@ -46181,8 +46181,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46181
46181
|
return promise;
|
|
46182
46182
|
}
|
|
46183
46183
|
function WritableStreamDealWithRejection(stream11, error) {
|
|
46184
|
-
const
|
|
46185
|
-
if (
|
|
46184
|
+
const state2 = stream11._state;
|
|
46185
|
+
if (state2 === "writable") {
|
|
46186
46186
|
WritableStreamStartErroring(stream11, error);
|
|
46187
46187
|
return;
|
|
46188
46188
|
}
|
|
@@ -46242,8 +46242,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46242
46242
|
function WritableStreamFinishInFlightClose(stream11) {
|
|
46243
46243
|
stream11._inFlightCloseRequest._resolve(void 0);
|
|
46244
46244
|
stream11._inFlightCloseRequest = void 0;
|
|
46245
|
-
const
|
|
46246
|
-
if (
|
|
46245
|
+
const state2 = stream11._state;
|
|
46246
|
+
if (state2 === "erroring") {
|
|
46247
46247
|
stream11._storedError = void 0;
|
|
46248
46248
|
if (stream11._pendingAbortRequest !== void 0) {
|
|
46249
46249
|
stream11._pendingAbortRequest._resolve();
|
|
@@ -46314,18 +46314,18 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46314
46314
|
}
|
|
46315
46315
|
this._ownerWritableStream = stream11;
|
|
46316
46316
|
stream11._writer = this;
|
|
46317
|
-
const
|
|
46318
|
-
if (
|
|
46317
|
+
const state2 = stream11._state;
|
|
46318
|
+
if (state2 === "writable") {
|
|
46319
46319
|
if (!WritableStreamCloseQueuedOrInFlight(stream11) && stream11._backpressure) {
|
|
46320
46320
|
defaultWriterReadyPromiseInitialize(this);
|
|
46321
46321
|
} else {
|
|
46322
46322
|
defaultWriterReadyPromiseInitializeAsResolved(this);
|
|
46323
46323
|
}
|
|
46324
46324
|
defaultWriterClosedPromiseInitialize(this);
|
|
46325
|
-
} else if (
|
|
46325
|
+
} else if (state2 === "erroring") {
|
|
46326
46326
|
defaultWriterReadyPromiseInitializeAsRejected(this, stream11._storedError);
|
|
46327
46327
|
defaultWriterClosedPromiseInitialize(this);
|
|
46328
|
-
} else if (
|
|
46328
|
+
} else if (state2 === "closed") {
|
|
46329
46329
|
defaultWriterReadyPromiseInitializeAsResolved(this);
|
|
46330
46330
|
defaultWriterClosedPromiseInitializeAsResolved(this);
|
|
46331
46331
|
} else {
|
|
@@ -46471,11 +46471,11 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46471
46471
|
}
|
|
46472
46472
|
function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
|
|
46473
46473
|
const stream11 = writer._ownerWritableStream;
|
|
46474
|
-
const
|
|
46475
|
-
if (WritableStreamCloseQueuedOrInFlight(stream11) ||
|
|
46474
|
+
const state2 = stream11._state;
|
|
46475
|
+
if (WritableStreamCloseQueuedOrInFlight(stream11) || state2 === "closed") {
|
|
46476
46476
|
return promiseResolvedWith(void 0);
|
|
46477
46477
|
}
|
|
46478
|
-
if (
|
|
46478
|
+
if (state2 === "errored") {
|
|
46479
46479
|
return promiseRejectedWith(stream11._storedError);
|
|
46480
46480
|
}
|
|
46481
46481
|
return WritableStreamDefaultWriterClose(writer);
|
|
@@ -46496,11 +46496,11 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46496
46496
|
}
|
|
46497
46497
|
function WritableStreamDefaultWriterGetDesiredSize(writer) {
|
|
46498
46498
|
const stream11 = writer._ownerWritableStream;
|
|
46499
|
-
const
|
|
46500
|
-
if (
|
|
46499
|
+
const state2 = stream11._state;
|
|
46500
|
+
if (state2 === "errored" || state2 === "erroring") {
|
|
46501
46501
|
return null;
|
|
46502
46502
|
}
|
|
46503
|
-
if (
|
|
46503
|
+
if (state2 === "closed") {
|
|
46504
46504
|
return 0;
|
|
46505
46505
|
}
|
|
46506
46506
|
return WritableStreamDefaultControllerGetDesiredSize(stream11._writableStreamController);
|
|
@@ -46520,14 +46520,14 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46520
46520
|
if (stream11 !== writer._ownerWritableStream) {
|
|
46521
46521
|
return promiseRejectedWith(defaultWriterLockException("write to"));
|
|
46522
46522
|
}
|
|
46523
|
-
const
|
|
46524
|
-
if (
|
|
46523
|
+
const state2 = stream11._state;
|
|
46524
|
+
if (state2 === "errored") {
|
|
46525
46525
|
return promiseRejectedWith(stream11._storedError);
|
|
46526
46526
|
}
|
|
46527
|
-
if (WritableStreamCloseQueuedOrInFlight(stream11) ||
|
|
46527
|
+
if (WritableStreamCloseQueuedOrInFlight(stream11) || state2 === "closed") {
|
|
46528
46528
|
return promiseRejectedWith(new TypeError("The stream is closing or closed and cannot be written to"));
|
|
46529
46529
|
}
|
|
46530
|
-
if (
|
|
46530
|
+
if (state2 === "erroring") {
|
|
46531
46531
|
return promiseRejectedWith(stream11._storedError);
|
|
46532
46532
|
}
|
|
46533
46533
|
const promise = WritableStreamAddWriteRequest(stream11);
|
|
@@ -46575,8 +46575,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46575
46575
|
if (!IsWritableStreamDefaultController(this)) {
|
|
46576
46576
|
throw defaultControllerBrandCheckException$2("error");
|
|
46577
46577
|
}
|
|
46578
|
-
const
|
|
46579
|
-
if (
|
|
46578
|
+
const state2 = this._controlledWritableStream._state;
|
|
46579
|
+
if (state2 !== "writable") {
|
|
46580
46580
|
return;
|
|
46581
46581
|
}
|
|
46582
46582
|
WritableStreamDefaultControllerError(this, e2);
|
|
@@ -46711,8 +46711,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46711
46711
|
if (stream11._inFlightWriteRequest !== void 0) {
|
|
46712
46712
|
return;
|
|
46713
46713
|
}
|
|
46714
|
-
const
|
|
46715
|
-
if (
|
|
46714
|
+
const state2 = stream11._state;
|
|
46715
|
+
if (state2 === "erroring") {
|
|
46716
46716
|
WritableStreamFinishErroring(stream11);
|
|
46717
46717
|
return;
|
|
46718
46718
|
}
|
|
@@ -46751,9 +46751,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
46751
46751
|
const sinkWritePromise = controller._writeAlgorithm(chunk);
|
|
46752
46752
|
uponPromise(sinkWritePromise, () => {
|
|
46753
46753
|
WritableStreamFinishInFlightWrite(stream11);
|
|
46754
|
-
const
|
|
46754
|
+
const state2 = stream11._state;
|
|
46755
46755
|
DequeueValue(controller);
|
|
46756
|
-
if (!WritableStreamCloseQueuedOrInFlight(stream11) &&
|
|
46756
|
+
if (!WritableStreamCloseQueuedOrInFlight(stream11) && state2 === "writable") {
|
|
46757
46757
|
const backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
|
|
46758
46758
|
WritableStreamUpdateBackpressure(stream11, backpressure);
|
|
46759
46759
|
}
|
|
@@ -47252,11 +47252,11 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
47252
47252
|
ReadableStreamError(stream11, e2);
|
|
47253
47253
|
}
|
|
47254
47254
|
function ReadableStreamDefaultControllerGetDesiredSize(controller) {
|
|
47255
|
-
const
|
|
47256
|
-
if (
|
|
47255
|
+
const state2 = controller._controlledReadableStream._state;
|
|
47256
|
+
if (state2 === "errored") {
|
|
47257
47257
|
return null;
|
|
47258
47258
|
}
|
|
47259
|
-
if (
|
|
47259
|
+
if (state2 === "closed") {
|
|
47260
47260
|
return 0;
|
|
47261
47261
|
}
|
|
47262
47262
|
return controller._strategyHWM - controller._queueTotalSize;
|
|
@@ -47268,8 +47268,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
47268
47268
|
return true;
|
|
47269
47269
|
}
|
|
47270
47270
|
function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
|
|
47271
|
-
const
|
|
47272
|
-
if (!controller._closeRequested &&
|
|
47271
|
+
const state2 = controller._controlledReadableStream._state;
|
|
47272
|
+
if (!controller._closeRequested && state2 === "readable") {
|
|
47273
47273
|
return true;
|
|
47274
47274
|
}
|
|
47275
47275
|
return false;
|
|
@@ -48461,8 +48461,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
48461
48461
|
const backpressureChangePromise = stream11._backpressureChangePromise;
|
|
48462
48462
|
return transformPromiseWith(backpressureChangePromise, () => {
|
|
48463
48463
|
const writable = stream11._writable;
|
|
48464
|
-
const
|
|
48465
|
-
if (
|
|
48464
|
+
const state2 = writable._state;
|
|
48465
|
+
if (state2 === "erroring") {
|
|
48466
48466
|
throw writable._storedError;
|
|
48467
48467
|
}
|
|
48468
48468
|
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
|
|
@@ -49293,7 +49293,7 @@ var init_multipart_parser = __esm({
|
|
|
49293
49293
|
let i2 = 0;
|
|
49294
49294
|
const length_ = data.length;
|
|
49295
49295
|
let previousIndex = this.index;
|
|
49296
|
-
let { lookbehind, boundary, boundaryChars, index, state:
|
|
49296
|
+
let { lookbehind, boundary, boundaryChars, index, state: state2, flags } = this;
|
|
49297
49297
|
const boundaryLength = this.boundary.length;
|
|
49298
49298
|
const boundaryEnd = boundaryLength - 1;
|
|
49299
49299
|
const bufferLength = data.length;
|
|
@@ -49325,7 +49325,7 @@ var init_multipart_parser = __esm({
|
|
|
49325
49325
|
};
|
|
49326
49326
|
for (i2 = 0; i2 < length_; i2++) {
|
|
49327
49327
|
c = data[i2];
|
|
49328
|
-
switch (
|
|
49328
|
+
switch (state2) {
|
|
49329
49329
|
case S.START_BOUNDARY:
|
|
49330
49330
|
if (index === boundary.length - 2) {
|
|
49331
49331
|
if (c === HYPHEN) {
|
|
@@ -49337,12 +49337,12 @@ var init_multipart_parser = __esm({
|
|
|
49337
49337
|
break;
|
|
49338
49338
|
} else if (index - 1 === boundary.length - 2) {
|
|
49339
49339
|
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
|
49340
|
-
|
|
49340
|
+
state2 = S.END;
|
|
49341
49341
|
flags = 0;
|
|
49342
49342
|
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
|
49343
49343
|
index = 0;
|
|
49344
49344
|
callback("onPartBegin");
|
|
49345
|
-
|
|
49345
|
+
state2 = S.HEADER_FIELD_START;
|
|
49346
49346
|
} else {
|
|
49347
49347
|
return;
|
|
49348
49348
|
}
|
|
@@ -49356,14 +49356,14 @@ var init_multipart_parser = __esm({
|
|
|
49356
49356
|
}
|
|
49357
49357
|
break;
|
|
49358
49358
|
case S.HEADER_FIELD_START:
|
|
49359
|
-
|
|
49359
|
+
state2 = S.HEADER_FIELD;
|
|
49360
49360
|
mark("onHeaderField");
|
|
49361
49361
|
index = 0;
|
|
49362
49362
|
// falls through
|
|
49363
49363
|
case S.HEADER_FIELD:
|
|
49364
49364
|
if (c === CR) {
|
|
49365
49365
|
clear("onHeaderField");
|
|
49366
|
-
|
|
49366
|
+
state2 = S.HEADERS_ALMOST_DONE;
|
|
49367
49367
|
break;
|
|
49368
49368
|
}
|
|
49369
49369
|
index++;
|
|
@@ -49375,7 +49375,7 @@ var init_multipart_parser = __esm({
|
|
|
49375
49375
|
return;
|
|
49376
49376
|
}
|
|
49377
49377
|
dataCallback("onHeaderField", true);
|
|
49378
|
-
|
|
49378
|
+
state2 = S.HEADER_VALUE_START;
|
|
49379
49379
|
break;
|
|
49380
49380
|
}
|
|
49381
49381
|
cl = lower(c);
|
|
@@ -49388,30 +49388,30 @@ var init_multipart_parser = __esm({
|
|
|
49388
49388
|
break;
|
|
49389
49389
|
}
|
|
49390
49390
|
mark("onHeaderValue");
|
|
49391
|
-
|
|
49391
|
+
state2 = S.HEADER_VALUE;
|
|
49392
49392
|
// falls through
|
|
49393
49393
|
case S.HEADER_VALUE:
|
|
49394
49394
|
if (c === CR) {
|
|
49395
49395
|
dataCallback("onHeaderValue", true);
|
|
49396
49396
|
callback("onHeaderEnd");
|
|
49397
|
-
|
|
49397
|
+
state2 = S.HEADER_VALUE_ALMOST_DONE;
|
|
49398
49398
|
}
|
|
49399
49399
|
break;
|
|
49400
49400
|
case S.HEADER_VALUE_ALMOST_DONE:
|
|
49401
49401
|
if (c !== LF) {
|
|
49402
49402
|
return;
|
|
49403
49403
|
}
|
|
49404
|
-
|
|
49404
|
+
state2 = S.HEADER_FIELD_START;
|
|
49405
49405
|
break;
|
|
49406
49406
|
case S.HEADERS_ALMOST_DONE:
|
|
49407
49407
|
if (c !== LF) {
|
|
49408
49408
|
return;
|
|
49409
49409
|
}
|
|
49410
49410
|
callback("onHeadersEnd");
|
|
49411
|
-
|
|
49411
|
+
state2 = S.PART_DATA_START;
|
|
49412
49412
|
break;
|
|
49413
49413
|
case S.PART_DATA_START:
|
|
49414
|
-
|
|
49414
|
+
state2 = S.PART_DATA;
|
|
49415
49415
|
mark("onPartData");
|
|
49416
49416
|
// falls through
|
|
49417
49417
|
case S.PART_DATA:
|
|
@@ -49449,13 +49449,13 @@ var init_multipart_parser = __esm({
|
|
|
49449
49449
|
flags &= ~F.PART_BOUNDARY;
|
|
49450
49450
|
callback("onPartEnd");
|
|
49451
49451
|
callback("onPartBegin");
|
|
49452
|
-
|
|
49452
|
+
state2 = S.HEADER_FIELD_START;
|
|
49453
49453
|
break;
|
|
49454
49454
|
}
|
|
49455
49455
|
} else if (flags & F.LAST_BOUNDARY) {
|
|
49456
49456
|
if (c === HYPHEN) {
|
|
49457
49457
|
callback("onPartEnd");
|
|
49458
|
-
|
|
49458
|
+
state2 = S.END;
|
|
49459
49459
|
flags = 0;
|
|
49460
49460
|
} else {
|
|
49461
49461
|
index = 0;
|
|
@@ -49477,14 +49477,14 @@ var init_multipart_parser = __esm({
|
|
|
49477
49477
|
case S.END:
|
|
49478
49478
|
break;
|
|
49479
49479
|
default:
|
|
49480
|
-
throw new Error(`Unexpected state entered: ${
|
|
49480
|
+
throw new Error(`Unexpected state entered: ${state2}`);
|
|
49481
49481
|
}
|
|
49482
49482
|
}
|
|
49483
49483
|
dataCallback("onHeaderField");
|
|
49484
49484
|
dataCallback("onHeaderValue");
|
|
49485
49485
|
dataCallback("onPartData");
|
|
49486
49486
|
this.index = index;
|
|
49487
|
-
this.state =
|
|
49487
|
+
this.state = state2;
|
|
49488
49488
|
this.flags = flags;
|
|
49489
49489
|
}
|
|
49490
49490
|
end() {
|
|
@@ -65693,8 +65693,8 @@ function tBatchJobName(apiClient, name) {
|
|
|
65693
65693
|
throw new Error(`Invalid batch job name: ${nameString}.`);
|
|
65694
65694
|
}
|
|
65695
65695
|
}
|
|
65696
|
-
function tJobState(
|
|
65697
|
-
const stateString =
|
|
65696
|
+
function tJobState(state2) {
|
|
65697
|
+
const stateString = state2;
|
|
65698
65698
|
if (stateString === "BATCH_STATE_UNSPECIFIED") {
|
|
65699
65699
|
return "JOB_STATE_UNSPECIFIED";
|
|
65700
65700
|
} else if (stateString === "BATCH_STATE_PENDING") {
|
|
@@ -75063,7 +75063,7 @@ function findBoundary(buf, len, from) {
|
|
|
75063
75063
|
}
|
|
75064
75064
|
return null;
|
|
75065
75065
|
}
|
|
75066
|
-
function parseMessage2(chunk, parse,
|
|
75066
|
+
function parseMessage2(chunk, parse, state2, dataRequired) {
|
|
75067
75067
|
const text = new TextDecoder().decode(chunk);
|
|
75068
75068
|
const lines = text.split(/\r\n|\r|\n/);
|
|
75069
75069
|
const dataLines = [];
|
|
@@ -75085,14 +75085,14 @@ function parseMessage2(chunk, parse, state3, dataRequired) {
|
|
|
75085
75085
|
else if (field === "event")
|
|
75086
75086
|
ret.event = value;
|
|
75087
75087
|
else if (field === "id" && !value.includes("\0"))
|
|
75088
|
-
|
|
75088
|
+
state2.eventId = value;
|
|
75089
75089
|
else if (field === "retry" && /^\d+$/.test(value)) {
|
|
75090
75090
|
ret.retry = Number(value);
|
|
75091
75091
|
}
|
|
75092
75092
|
}
|
|
75093
75093
|
if (ignore)
|
|
75094
75094
|
return;
|
|
75095
|
-
ret.id =
|
|
75095
|
+
ret.id = state2.eventId;
|
|
75096
75096
|
if (dataLines.length)
|
|
75097
75097
|
ret.data = dataLines.join("\n");
|
|
75098
75098
|
else if (dataRequired)
|
|
@@ -75222,7 +75222,7 @@ function unpackHeaders(headers) {
|
|
|
75222
75222
|
return out;
|
|
75223
75223
|
}
|
|
75224
75224
|
function resolveSecurity(...options) {
|
|
75225
|
-
const
|
|
75225
|
+
const state2 = {
|
|
75226
75226
|
basic: {},
|
|
75227
75227
|
headers: {},
|
|
75228
75228
|
queryParams: {},
|
|
@@ -75261,46 +75261,46 @@ function resolveSecurity(...options) {
|
|
|
75261
75261
|
const { type } = spec;
|
|
75262
75262
|
switch (type) {
|
|
75263
75263
|
case "apiKey:header":
|
|
75264
|
-
|
|
75264
|
+
state2.headers[spec.fieldName] = spec.value;
|
|
75265
75265
|
break;
|
|
75266
75266
|
case "apiKey:query":
|
|
75267
|
-
|
|
75267
|
+
state2.queryParams[spec.fieldName] = spec.value;
|
|
75268
75268
|
break;
|
|
75269
75269
|
case "apiKey:cookie":
|
|
75270
|
-
|
|
75270
|
+
state2.cookies[spec.fieldName] = spec.value;
|
|
75271
75271
|
break;
|
|
75272
75272
|
case "http:basic":
|
|
75273
|
-
applyBasic(
|
|
75273
|
+
applyBasic(state2, spec);
|
|
75274
75274
|
break;
|
|
75275
75275
|
case "http:custom":
|
|
75276
75276
|
break;
|
|
75277
75277
|
case "http:bearer":
|
|
75278
|
-
applyBearer(
|
|
75278
|
+
applyBearer(state2, spec);
|
|
75279
75279
|
break;
|
|
75280
75280
|
case "oauth2":
|
|
75281
|
-
applyBearer(
|
|
75281
|
+
applyBearer(state2, spec);
|
|
75282
75282
|
break;
|
|
75283
75283
|
case "oauth2:password":
|
|
75284
|
-
applyBearer(
|
|
75284
|
+
applyBearer(state2, spec);
|
|
75285
75285
|
break;
|
|
75286
75286
|
case "oauth2:client_credentials":
|
|
75287
75287
|
break;
|
|
75288
75288
|
case "openIdConnect":
|
|
75289
|
-
applyBearer(
|
|
75289
|
+
applyBearer(state2, spec);
|
|
75290
75290
|
break;
|
|
75291
75291
|
default:
|
|
75292
75292
|
throw SecurityError.unrecognizedType(type);
|
|
75293
75293
|
}
|
|
75294
75294
|
});
|
|
75295
|
-
return
|
|
75295
|
+
return state2;
|
|
75296
75296
|
}
|
|
75297
|
-
function applyBasic(
|
|
75297
|
+
function applyBasic(state2, spec) {
|
|
75298
75298
|
if (spec.value == null) {
|
|
75299
75299
|
return;
|
|
75300
75300
|
}
|
|
75301
|
-
|
|
75301
|
+
state2.basic = spec.value;
|
|
75302
75302
|
}
|
|
75303
|
-
function applyBearer(
|
|
75303
|
+
function applyBearer(state2, spec) {
|
|
75304
75304
|
if (typeof spec.value !== "string" || !spec.value) {
|
|
75305
75305
|
return;
|
|
75306
75306
|
}
|
|
@@ -75309,7 +75309,7 @@ function applyBearer(state3, spec) {
|
|
|
75309
75309
|
value = `Bearer ${value}`;
|
|
75310
75310
|
}
|
|
75311
75311
|
if (spec.fieldName !== void 0) {
|
|
75312
|
-
|
|
75312
|
+
state2.headers[spec.fieldName] = value;
|
|
75313
75313
|
}
|
|
75314
75314
|
}
|
|
75315
75315
|
function resolveGlobalSecurity(security, allowedFields) {
|
|
@@ -85318,7 +85318,7 @@ var init_node3 = __esm({
|
|
|
85318
85318
|
let buffer = new Uint8Array(4096);
|
|
85319
85319
|
let bufferLen = 0;
|
|
85320
85320
|
let searchStart = 0;
|
|
85321
|
-
const
|
|
85321
|
+
const state2 = { eventId: void 0 };
|
|
85322
85322
|
const dataRequired = (_a7 = opts === null || opts === void 0 ? void 0 : opts.dataRequired) !== null && _a7 !== void 0 ? _a7 : true;
|
|
85323
85323
|
super({
|
|
85324
85324
|
async pull(downstream) {
|
|
@@ -85348,7 +85348,7 @@ var init_node3 = __esm({
|
|
|
85348
85348
|
buffer = shrunk;
|
|
85349
85349
|
}
|
|
85350
85350
|
searchStart = 0;
|
|
85351
|
-
const item = parseMessage2(message, parse,
|
|
85351
|
+
const item = parseMessage2(message, parse, state2, dataRequired);
|
|
85352
85352
|
if (item && !item.done)
|
|
85353
85353
|
return downstream.enqueue(item.value);
|
|
85354
85354
|
if (item === null || item === void 0 ? void 0 : item.done) {
|
|
@@ -92177,10 +92177,10 @@ function wireQuestion(name, question) {
|
|
|
92177
92177
|
return { type: "predicate", name, instructions: predicateInstructions(question) };
|
|
92178
92178
|
}
|
|
92179
92179
|
function wireInput(context) {
|
|
92180
|
-
const
|
|
92180
|
+
const state2 = JSON.stringify(context.state);
|
|
92181
92181
|
const images = context.images ?? [];
|
|
92182
92182
|
if (images.length === 0)
|
|
92183
|
-
return
|
|
92183
|
+
return state2;
|
|
92184
92184
|
if (images.length > MAX_IMAGES) {
|
|
92185
92185
|
throw new Error(`${LABEL2} accepts at most ${MAX_IMAGES} images, got ${images.length}`);
|
|
92186
92186
|
}
|
|
@@ -92188,7 +92188,7 @@ function wireInput(context) {
|
|
|
92188
92188
|
{
|
|
92189
92189
|
role: "user",
|
|
92190
92190
|
content: [
|
|
92191
|
-
{ type: "input_text", text:
|
|
92191
|
+
{ type: "input_text", text: state2 },
|
|
92192
92192
|
...images.map((image) => ({
|
|
92193
92193
|
type: "input_image",
|
|
92194
92194
|
image_url: `data:${image.mimeType};base64,${image.data}`
|
|
@@ -92324,8 +92324,8 @@ var init_typesafe_system_one = __esm({
|
|
|
92324
92324
|
|
|
92325
92325
|
// ../kiro-core/dist/debug.js
|
|
92326
92326
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
92327
|
-
import { homedir as
|
|
92328
|
-
import { dirname as dirname5, join as
|
|
92327
|
+
import { homedir as homedir6 } from "node:os";
|
|
92328
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
92329
92329
|
function debugLog(section, data) {
|
|
92330
92330
|
if (!ENABLED)
|
|
92331
92331
|
return;
|
|
@@ -92361,7 +92361,7 @@ var init_debug = __esm({
|
|
|
92361
92361
|
"../kiro-core/dist/debug.js"() {
|
|
92362
92362
|
"use strict";
|
|
92363
92363
|
ENABLED = !!process.env.KIRO_DEBUG && process.env.KIRO_DEBUG !== "0";
|
|
92364
|
-
LOG_FILE = process.env.KIRO_DEBUG_LOG ||
|
|
92364
|
+
LOG_FILE = process.env.KIRO_DEBUG_LOG || join7(homedir6(), ".ns-kiro-provider", "logs", "kiro-debug.log");
|
|
92365
92365
|
dirReady = false;
|
|
92366
92366
|
PROFILE_ARN_PATTERN = /arn:[a-z0-9-]+:codewhisperer:[^:\s"']*:[^:\s"']*:profile\/[^\s"',}\]]+/gi;
|
|
92367
92367
|
BEARER_TOKEN_PATTERN = /(\bBearer\s+)[^\s"',}\]]+/gi;
|
|
@@ -92434,13 +92434,13 @@ __export(kiro_cli_exports, {
|
|
|
92434
92434
|
import { execFileSync, execSync } from "node:child_process";
|
|
92435
92435
|
import { existsSync as existsSync3 } from "node:fs";
|
|
92436
92436
|
import { createRequire } from "node:module";
|
|
92437
|
-
import { homedir as
|
|
92438
|
-
import { join as
|
|
92437
|
+
import { homedir as homedir7, platform } from "node:os";
|
|
92438
|
+
import { join as join8 } from "node:path";
|
|
92439
92439
|
function getKiroCliDbPath() {
|
|
92440
92440
|
const p = platform();
|
|
92441
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
92442
|
-
const roamingAppData = process.env.APPDATA ||
|
|
92443
|
-
const candidates = p === "win32" ? [
|
|
92441
|
+
const localAppData = process.env.LOCALAPPDATA || join8(homedir7(), "AppData", "Local");
|
|
92442
|
+
const roamingAppData = process.env.APPDATA || join8(homedir7(), "AppData", "Roaming");
|
|
92443
|
+
const candidates = p === "win32" ? [join8(localAppData, "Kiro-Cli", "data.sqlite3"), join8(roamingAppData, "kiro-cli", "data.sqlite3")] : p === "darwin" ? [join8(homedir7(), "Library", "Application Support", "kiro-cli", "data.sqlite3")] : [join8(homedir7(), ".local", "share", "kiro-cli", "data.sqlite3")];
|
|
92444
92444
|
return candidates.find((candidate) => existsSync3(candidate));
|
|
92445
92445
|
}
|
|
92446
92446
|
function getKiroCliExternalIdpCredentials() {
|
|
@@ -92821,14 +92821,14 @@ var init_http = __esm({
|
|
|
92821
92821
|
});
|
|
92822
92822
|
|
|
92823
92823
|
// ../kiro-core/dist/kiro-ide.js
|
|
92824
|
-
import { existsSync as existsSync4, readFileSync as
|
|
92825
|
-
import { homedir as
|
|
92826
|
-
import { join as
|
|
92824
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
|
|
92825
|
+
import { homedir as homedir8 } from "node:os";
|
|
92826
|
+
import { join as join9 } from "node:path";
|
|
92827
92827
|
function readKiroIdeToken(allowExpired) {
|
|
92828
92828
|
try {
|
|
92829
92829
|
if (!existsSync4(KIRO_IDE_TOKEN_PATH))
|
|
92830
92830
|
return void 0;
|
|
92831
|
-
const tokenData = JSON.parse(
|
|
92831
|
+
const tokenData = JSON.parse(readFileSync6(KIRO_IDE_TOKEN_PATH, "utf-8"));
|
|
92832
92832
|
if (!tokenData.accessToken || !tokenData.refreshToken)
|
|
92833
92833
|
return void 0;
|
|
92834
92834
|
const expiresAt = new Date(tokenData.expiresAt).getTime();
|
|
@@ -92838,10 +92838,10 @@ function readKiroIdeToken(allowExpired) {
|
|
|
92838
92838
|
let clientId = "";
|
|
92839
92839
|
let clientSecret = "";
|
|
92840
92840
|
if (tokenData.clientIdHash) {
|
|
92841
|
-
const regPath =
|
|
92841
|
+
const regPath = join9(SSO_CACHE_DIR, `${tokenData.clientIdHash}.json`);
|
|
92842
92842
|
if (existsSync4(regPath)) {
|
|
92843
92843
|
try {
|
|
92844
|
-
const reg = JSON.parse(
|
|
92844
|
+
const reg = JSON.parse(readFileSync6(regPath, "utf-8"));
|
|
92845
92845
|
clientId = reg.clientId ?? "";
|
|
92846
92846
|
clientSecret = reg.clientSecret ?? "";
|
|
92847
92847
|
} catch {
|
|
@@ -92873,8 +92873,8 @@ var SSO_CACHE_DIR, KIRO_IDE_TOKEN_PATH;
|
|
|
92873
92873
|
var init_kiro_ide = __esm({
|
|
92874
92874
|
"../kiro-core/dist/kiro-ide.js"() {
|
|
92875
92875
|
"use strict";
|
|
92876
|
-
SSO_CACHE_DIR =
|
|
92877
|
-
KIRO_IDE_TOKEN_PATH =
|
|
92876
|
+
SSO_CACHE_DIR = join9(homedir8(), ".aws", "sso", "cache");
|
|
92877
|
+
KIRO_IDE_TOKEN_PATH = join9(SSO_CACHE_DIR, "kiro-auth-token.json");
|
|
92878
92878
|
}
|
|
92879
92879
|
});
|
|
92880
92880
|
|
|
@@ -96416,6 +96416,11 @@ async function refreshDevinModels(options = {}) {
|
|
|
96416
96416
|
return { models: getCachedModels().map(toPiDevinModel), fromCache };
|
|
96417
96417
|
}
|
|
96418
96418
|
|
|
96419
|
+
// ../pi-provider/src/grok/register.ts
|
|
96420
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
96421
|
+
import { homedir as homedir5 } from "node:os";
|
|
96422
|
+
import { join as join6 } from "node:path";
|
|
96423
|
+
|
|
96419
96424
|
// ../grok-core/dist/catalog.js
|
|
96420
96425
|
var GROK_BOOTSTRAP_MODEL_IDS = ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"];
|
|
96421
96426
|
var GROK_DEFAULT_CONTEXT_WINDOW = 5e5;
|
|
@@ -96638,7 +96643,26 @@ async function resolveGrokBinary(env3 = process.env) {
|
|
|
96638
96643
|
|
|
96639
96644
|
// ../grok-core/dist/agent/models.js
|
|
96640
96645
|
import { execFile as execFile2 } from "node:child_process";
|
|
96641
|
-
function
|
|
96646
|
+
function grokContextWindowsFromCache(raw) {
|
|
96647
|
+
const windows = /* @__PURE__ */ new Map();
|
|
96648
|
+
if (!raw?.trim())
|
|
96649
|
+
return windows;
|
|
96650
|
+
try {
|
|
96651
|
+
const parsed = JSON.parse(raw);
|
|
96652
|
+
const models = parsed?.models;
|
|
96653
|
+
if (!models || typeof models !== "object")
|
|
96654
|
+
return windows;
|
|
96655
|
+
for (const [id, entry] of Object.entries(models)) {
|
|
96656
|
+
const info = entry?.info;
|
|
96657
|
+
const window2 = info?.context_window;
|
|
96658
|
+
if (typeof window2 === "number" && Number.isInteger(window2) && window2 > 0)
|
|
96659
|
+
windows.set(id, window2);
|
|
96660
|
+
}
|
|
96661
|
+
} catch {
|
|
96662
|
+
}
|
|
96663
|
+
return windows;
|
|
96664
|
+
}
|
|
96665
|
+
function parseGrokModelsOutput(stdout, contextWindows) {
|
|
96642
96666
|
const models = [];
|
|
96643
96667
|
const seen = /* @__PURE__ */ new Set();
|
|
96644
96668
|
const bullet = /^\s*[*•-]\s+(\S+)/;
|
|
@@ -96649,31 +96673,28 @@ function parseGrokModelsOutput(stdout) {
|
|
|
96649
96673
|
const id = m2[1].replace(/[(),]+$/g, "");
|
|
96650
96674
|
if (!seen.has(id)) {
|
|
96651
96675
|
seen.add(id);
|
|
96652
|
-
models.push(
|
|
96653
|
-
id,
|
|
96654
|
-
name: id,
|
|
96655
|
-
contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96656
|
-
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96657
|
-
supportsReasoningEffort: true
|
|
96658
|
-
});
|
|
96676
|
+
models.push(describe(id, contextWindows));
|
|
96659
96677
|
}
|
|
96660
96678
|
continue;
|
|
96661
96679
|
}
|
|
96662
96680
|
const d = line.match(defaultLine);
|
|
96663
96681
|
if (d && !seen.has(d[1])) {
|
|
96664
96682
|
seen.add(d[1]);
|
|
96665
|
-
models.unshift(
|
|
96666
|
-
id: d[1],
|
|
96667
|
-
name: d[1],
|
|
96668
|
-
contextWindow: GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96669
|
-
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96670
|
-
supportsReasoningEffort: true
|
|
96671
|
-
});
|
|
96683
|
+
models.unshift(describe(d[1], contextWindows));
|
|
96672
96684
|
}
|
|
96673
96685
|
}
|
|
96674
96686
|
return models;
|
|
96675
96687
|
}
|
|
96676
|
-
|
|
96688
|
+
function describe(id, contextWindows) {
|
|
96689
|
+
return {
|
|
96690
|
+
id,
|
|
96691
|
+
name: id,
|
|
96692
|
+
contextWindow: contextWindows?.get(id) ?? GROK_DEFAULT_CONTEXT_WINDOW,
|
|
96693
|
+
maxTokens: GROK_DEFAULT_MAX_TOKENS,
|
|
96694
|
+
supportsReasoningEffort: true
|
|
96695
|
+
};
|
|
96696
|
+
}
|
|
96697
|
+
async function discoverGrokModels(binary, contextWindows) {
|
|
96677
96698
|
try {
|
|
96678
96699
|
const bin = binary ?? await resolveGrokBinary();
|
|
96679
96700
|
const stdout = await new Promise((resolve2, reject) => {
|
|
@@ -96684,7 +96705,7 @@ async function discoverGrokModels(binary) {
|
|
|
96684
96705
|
resolve2(out);
|
|
96685
96706
|
});
|
|
96686
96707
|
});
|
|
96687
|
-
const parsed = parseGrokModelsOutput(stdout);
|
|
96708
|
+
const parsed = parseGrokModelsOutput(stdout, contextWindows);
|
|
96688
96709
|
if (parsed.length === 0) {
|
|
96689
96710
|
return { models: [], source: "fallback", error: "empty model list from CLI" };
|
|
96690
96711
|
}
|
|
@@ -96722,8 +96743,8 @@ function fallbackModels() {
|
|
|
96722
96743
|
supportsReasoningEffort: model.reasoning
|
|
96723
96744
|
}));
|
|
96724
96745
|
}
|
|
96725
|
-
async function discoverModels(binary) {
|
|
96726
|
-
const discovered = await discoverGrokModels(binary);
|
|
96746
|
+
async function discoverModels(binary, contextCache) {
|
|
96747
|
+
const discovered = await discoverGrokModels(binary, grokContextWindowsFromCache(contextCache));
|
|
96727
96748
|
if (discovered.source === "live") return discovered;
|
|
96728
96749
|
return { ...discovered, models: fallbackModels() };
|
|
96729
96750
|
}
|
|
@@ -98515,50 +98536,6 @@ function registerBuiltInApiProviders() {
|
|
|
98515
98536
|
registerBuiltInApiProviders();
|
|
98516
98537
|
var compatModels = builtinModels();
|
|
98517
98538
|
|
|
98518
|
-
// ../pi-provider/src/grok/prompt.ts
|
|
98519
|
-
var GROK_BRIDGE_NOTE = [
|
|
98520
|
-
"[grok bridge] You are the Grok coding agent, running behind an external coding harness that only relays your messages.",
|
|
98521
|
-
"Tools named in the harness instructions below (read, bash, edit, write, \u2026) are not callable from here.",
|
|
98522
|
-
"Use your own built-in tools (read_file, grep, search_replace, write, run_terminal_command, \u2026) directly in the working directory.",
|
|
98523
|
-
"When the task needs file changes or commands, perform them with those tools instead of describing them or writing tool calls as text."
|
|
98524
|
-
].join("\n");
|
|
98525
|
-
|
|
98526
|
-
// ../pi-provider/src/grok/session-scope.ts
|
|
98527
|
-
var state2 = {
|
|
98528
|
-
cwd: process.cwd(),
|
|
98529
|
-
sessionFile: void 0,
|
|
98530
|
-
sessionId: void 0,
|
|
98531
|
-
generation: 0
|
|
98532
|
-
};
|
|
98533
|
-
|
|
98534
|
-
// ../pi-provider/src/grok/tool-activity.ts
|
|
98535
|
-
var MAX_OUTPUT = 64 * 1024;
|
|
98536
|
-
|
|
98537
|
-
// ../pi-provider/src/grok/host-tools.ts
|
|
98538
|
-
var REPLACE_SCRIPT = [
|
|
98539
|
-
"import json,sys,base64,pathlib",
|
|
98540
|
-
"p=json.loads(base64.b64decode(sys.argv[2]))",
|
|
98541
|
-
"path=p['path']",
|
|
98542
|
-
"old=p['old']",
|
|
98543
|
-
"new=p['new']",
|
|
98544
|
-
"replace_all=bool(p.get('all'))",
|
|
98545
|
-
"file=pathlib.Path(path)",
|
|
98546
|
-
"text=file.read_text()",
|
|
98547
|
-
"if old=='':",
|
|
98548
|
-
" sys.stderr.write('old text is empty\\n')",
|
|
98549
|
-
" sys.exit(1)",
|
|
98550
|
-
"count=text.count(old)",
|
|
98551
|
-
"if count==0:",
|
|
98552
|
-
" sys.stderr.write('old text not found\\n')",
|
|
98553
|
-
" sys.exit(1)",
|
|
98554
|
-
"if not replace_all and count!=1:",
|
|
98555
|
-
" sys.stderr.write('old text appears %d times\\n' % count)",
|
|
98556
|
-
" sys.exit(1)",
|
|
98557
|
-
"updated=text.replace(old, new) if replace_all else text.replace(old, new, 1)",
|
|
98558
|
-
"file.write_text(updated)",
|
|
98559
|
-
"print('Updated '+path)"
|
|
98560
|
-
].join("\n");
|
|
98561
|
-
|
|
98562
98539
|
// ../pi-provider/src/grok/register.ts
|
|
98563
98540
|
var GROK_PROVIDER_ID = "grok";
|
|
98564
98541
|
var GROK_API = "grok-cli";
|
|
@@ -98630,7 +98607,13 @@ async function refreshGrokModels(options = {}) {
|
|
|
98630
98607
|
} catch {
|
|
98631
98608
|
binary = void 0;
|
|
98632
98609
|
}
|
|
98633
|
-
|
|
98610
|
+
let contextCache;
|
|
98611
|
+
try {
|
|
98612
|
+
contextCache = readFileSync5(join6(homedir5(), ".grok", "models_cache.json"), "utf8");
|
|
98613
|
+
} catch {
|
|
98614
|
+
contextCache = void 0;
|
|
98615
|
+
}
|
|
98616
|
+
const discovered = await discoverModels(binary, contextCache);
|
|
98634
98617
|
const catalog = descriptorsToCatalog(discovered.models);
|
|
98635
98618
|
cache.store(GROK_PROVIDER_ID, catalog, { version: "grok-cli-v1" });
|
|
98636
98619
|
return {
|
|
@@ -98733,9 +98716,9 @@ async function resolveKiroRequestCredentials(hostKey) {
|
|
|
98733
98716
|
|
|
98734
98717
|
// ../kiro-core/dist/models.js
|
|
98735
98718
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
98736
|
-
import { existsSync as existsSync5, readFileSync as
|
|
98737
|
-
import { homedir as
|
|
98738
|
-
import { join as
|
|
98719
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
98720
|
+
import { homedir as homedir9 } from "node:os";
|
|
98721
|
+
import { join as join10 } from "node:path";
|
|
98739
98722
|
|
|
98740
98723
|
// ../kiro-core/dist/types.js
|
|
98741
98724
|
var KIRO_EFFORT_ORDER = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
@@ -98803,7 +98786,7 @@ function getKiroEffortConfig(schema, kiroModelId) {
|
|
|
98803
98786
|
init_endpoints();
|
|
98804
98787
|
var KIRO_MANAGEMENT_CACHE_VERSION = 1;
|
|
98805
98788
|
var KIRO_MANAGEMENT_CACHE_SOURCE = "ns-kiro-provider-management";
|
|
98806
|
-
var KIRO_MANAGEMENT_CACHE_PATH =
|
|
98789
|
+
var KIRO_MANAGEMENT_CACHE_PATH = join10(homedir9(), ".ns-kiro-provider-models-cache.json");
|
|
98807
98790
|
var CACHE_MAX_AGE_MS = 36e5;
|
|
98808
98791
|
var DEFAULT_CONTEXT_WINDOW3 = 2e5;
|
|
98809
98792
|
var DEFAULT_MAX_TOKENS3 = 8192;
|
|
@@ -99076,7 +99059,7 @@ function readManagementCache() {
|
|
|
99076
99059
|
if (!existsSync5(KIRO_MANAGEMENT_CACHE_PATH))
|
|
99077
99060
|
return void 0;
|
|
99078
99061
|
try {
|
|
99079
|
-
return parseManagementCache(
|
|
99062
|
+
return parseManagementCache(readFileSync7(KIRO_MANAGEMENT_CACHE_PATH, "utf-8"));
|
|
99080
99063
|
} catch {
|
|
99081
99064
|
return void 0;
|
|
99082
99065
|
}
|
|
@@ -99280,10 +99263,10 @@ init_oauth();
|
|
|
99280
99263
|
init_token_type();
|
|
99281
99264
|
|
|
99282
99265
|
// ../kiro-core/dist/transport.js
|
|
99283
|
-
import { homedir as
|
|
99284
|
-
import { join as
|
|
99285
|
-
var CAPACITY_LOG_DIR =
|
|
99286
|
-
var CAPACITY_LOG_FILE =
|
|
99266
|
+
import { homedir as homedir10 } from "node:os";
|
|
99267
|
+
import { join as join11 } from "node:path";
|
|
99268
|
+
var CAPACITY_LOG_DIR = join11(homedir10(), ".ns-kiro-provider", "logs");
|
|
99269
|
+
var CAPACITY_LOG_FILE = join11(CAPACITY_LOG_DIR, "capacity-retries.log");
|
|
99287
99270
|
|
|
99288
99271
|
// ../kiro-core/dist/usage-tracking.js
|
|
99289
99272
|
var DEFAULT_USD_PER_CREDIT = 0.04;
|