@kenkaiiii/gg-ai 4.3.170 → 4.3.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +57 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +56 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
palsuToolCall: () => palsuToolCall,
|
|
43
43
|
providerRegistry: () => providerRegistry,
|
|
44
44
|
registerPalsuProvider: () => registerPalsuProvider,
|
|
45
|
+
setProviderDiagnostic: () => setProviderDiagnostic,
|
|
45
46
|
stream: () => stream
|
|
46
47
|
});
|
|
47
48
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -733,11 +734,7 @@ function toOpenAIToolChoice(choice) {
|
|
|
733
734
|
if (choice === "required") return "required";
|
|
734
735
|
return { type: "function", function: { name: choice.name } };
|
|
735
736
|
}
|
|
736
|
-
function
|
|
737
|
-
return /^gpt-5\.\d+-pro$/i.test(model);
|
|
738
|
-
}
|
|
739
|
-
function toOpenAIReasoningEffort(level, model) {
|
|
740
|
-
if (isOpenAIProVariant(model) && level === "low") return "medium";
|
|
737
|
+
function toOpenAIReasoningEffort(level, _model) {
|
|
741
738
|
return level;
|
|
742
739
|
}
|
|
743
740
|
function normalizeAnthropicStopReason(reason) {
|
|
@@ -830,16 +827,28 @@ async function* runStream(options) {
|
|
|
830
827
|
...options.temperature != null && !thinking ? { temperature: options.temperature } : {},
|
|
831
828
|
...options.topP != null ? { top_p: options.topP } : {},
|
|
832
829
|
...options.stop ? { stop_sequences: options.stop } : {},
|
|
833
|
-
...options.tools?.length || options.serverTools?.length || options.webSearch ? {
|
|
834
|
-
|
|
835
|
-
|
|
830
|
+
...options.tools?.length || options.serverTools?.length || options.webSearch ? (() => {
|
|
831
|
+
const reservedServerNames = /* @__PURE__ */ new Set();
|
|
832
|
+
if (options.webSearch) reservedServerNames.add("web_search");
|
|
833
|
+
for (const t of options.serverTools ?? []) {
|
|
834
|
+
const name = t.name;
|
|
835
|
+
if (name) reservedServerNames.add(name);
|
|
836
|
+
}
|
|
837
|
+
const clientTools = options.tools?.length ? toAnthropicTools(
|
|
838
|
+
options.tools.filter((t) => !reservedServerNames.has(t.name)),
|
|
839
|
+
{
|
|
836
840
|
...supportsFirstPartyToolExtras && cacheControl ? { cacheControl } : {},
|
|
837
841
|
...supportsFirstPartyToolExtras ? { enableFineGrainedToolStreaming: true } : {}
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
842
|
+
}
|
|
843
|
+
) : [];
|
|
844
|
+
return {
|
|
845
|
+
tools: [
|
|
846
|
+
...clientTools,
|
|
847
|
+
...options.serverTools ?? [],
|
|
848
|
+
...options.webSearch ? [{ type: "web_search_20250305", name: "web_search" }] : []
|
|
849
|
+
]
|
|
850
|
+
};
|
|
851
|
+
})() : {},
|
|
843
852
|
...options.toolChoice && options.tools?.length ? { tool_choice: toAnthropicToolChoice(options.toolChoice) } : {},
|
|
844
853
|
...(() => {
|
|
845
854
|
const contextEdits = [
|
|
@@ -924,7 +933,11 @@ async function* runStream(options) {
|
|
|
924
933
|
accum.raw = block;
|
|
925
934
|
}
|
|
926
935
|
blocks.set(idx, accum);
|
|
927
|
-
|
|
936
|
+
if (block.type === "thinking") {
|
|
937
|
+
yield { type: "thinking_delta", text: "" };
|
|
938
|
+
} else {
|
|
939
|
+
yield keepalive;
|
|
940
|
+
}
|
|
928
941
|
break;
|
|
929
942
|
}
|
|
930
943
|
case "content_block_delta": {
|
|
@@ -1490,6 +1503,17 @@ function toError2(err, provider = "openai") {
|
|
|
1490
1503
|
|
|
1491
1504
|
// src/providers/openai-codex.ts
|
|
1492
1505
|
var import_node_os = __toESM(require("os"), 1);
|
|
1506
|
+
|
|
1507
|
+
// src/utils/diag.ts
|
|
1508
|
+
var _diagFn = null;
|
|
1509
|
+
function setProviderDiagnostic(fn) {
|
|
1510
|
+
_diagFn = fn;
|
|
1511
|
+
}
|
|
1512
|
+
function providerDiag(phase, data) {
|
|
1513
|
+
_diagFn?.(phase, data);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
// src/providers/openai-codex.ts
|
|
1493
1517
|
var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
|
|
1494
1518
|
function streamOpenAICodex(options) {
|
|
1495
1519
|
return new StreamResult(runStream3(options));
|
|
@@ -1548,9 +1572,13 @@ async function* runStream3(options) {
|
|
|
1548
1572
|
const requestId = parsed.requestId ?? response.headers.get("x-request-id") ?? response.headers.get("openai-request-id") ?? void 0;
|
|
1549
1573
|
let hint;
|
|
1550
1574
|
if (response.status === 400 && text.includes("not supported")) {
|
|
1551
|
-
|
|
1575
|
+
if (options.model === "gpt-5.5-pro") {
|
|
1576
|
+
hint = "Use gpt-5.5 instead. OpenAI's Codex model catalog does not list gpt-5.5-pro.";
|
|
1577
|
+
} else {
|
|
1578
|
+
hint = "This model is not available through Codex for the authenticated account. Run /model and choose a model listed for OpenAI Codex, or check your Codex model picker/usage limits.";
|
|
1579
|
+
}
|
|
1552
1580
|
} else if (response.status === 404 && text.includes("does not exist")) {
|
|
1553
|
-
hint = "
|
|
1581
|
+
hint = "This model is not in the current OpenAI Codex catalog for this account. Try gpt-5.5, gpt-5.4, gpt-5.4-mini, or gpt-5.3-codex.";
|
|
1554
1582
|
}
|
|
1555
1583
|
throw new ProviderError("openai", message, {
|
|
1556
1584
|
statusCode: response.status,
|
|
@@ -1567,9 +1595,15 @@ async function* runStream3(options) {
|
|
|
1567
1595
|
let inputTokens = 0;
|
|
1568
1596
|
let outputTokens = 0;
|
|
1569
1597
|
let cacheRead = 0;
|
|
1598
|
+
const diagStart = Date.now();
|
|
1599
|
+
const diagSeen = /* @__PURE__ */ new Set();
|
|
1570
1600
|
for await (const event of parseSSE(response.body)) {
|
|
1571
1601
|
const type = event.type;
|
|
1572
1602
|
if (!type) continue;
|
|
1603
|
+
if (!diagSeen.has(type)) {
|
|
1604
|
+
diagSeen.add(type);
|
|
1605
|
+
providerDiag("codex_event_first", { type, sinceStartMs: Date.now() - diagStart });
|
|
1606
|
+
}
|
|
1573
1607
|
if (type === "error") {
|
|
1574
1608
|
const nested = event.error ?? void 0;
|
|
1575
1609
|
const message = nested?.message ?? event.message ?? "Codex stream emitted an error chunk without a message.";
|
|
@@ -1597,6 +1631,12 @@ async function* runStream3(options) {
|
|
|
1597
1631
|
const delta = event.delta;
|
|
1598
1632
|
yield { type: "thinking_delta", text: delta };
|
|
1599
1633
|
}
|
|
1634
|
+
if (type === "response.output_item.added") {
|
|
1635
|
+
const item = event.item;
|
|
1636
|
+
if (item?.type === "reasoning") {
|
|
1637
|
+
yield { type: "thinking_delta", text: "" };
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1600
1640
|
if (type === "response.output_item.added") {
|
|
1601
1641
|
const item = event.item;
|
|
1602
1642
|
if (item?.type === "function_call") {
|
|
@@ -2117,6 +2157,7 @@ function registerPalsuProvider(config) {
|
|
|
2117
2157
|
palsuToolCall,
|
|
2118
2158
|
providerRegistry,
|
|
2119
2159
|
registerPalsuProvider,
|
|
2160
|
+
setProviderDiagnostic,
|
|
2120
2161
|
stream
|
|
2121
2162
|
});
|
|
2122
2163
|
//# sourceMappingURL=index.cjs.map
|