@cydm/pie 4.14.1 → 4.15.1
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/README.md +5 -5
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +964 -269
- package/dist/builtin/extensions/memory/index.js +6 -6
- package/dist/builtin/extensions/memory/package.json +1 -2
- package/dist/builtin/extensions/pie-proc/index.js +6 -6
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-IQDVL34H.js → chunk-6AYPNTCO.js} +8 -8
- package/dist/chunks/{chunk-SYZR74QO.js → chunk-J6EZ335F.js} +8 -7
- package/dist/chunks/{chunk-X3ZVZB2R.js → chunk-JE53PC46.js} +633 -148
- package/dist/chunks/{chunk-2WLKAMOH.js → chunk-LIA52LJU.js} +3 -3
- package/dist/chunks/{chunk-SAXKBFX3.js → chunk-MTH6QSYD.js} +1 -1
- package/dist/chunks/{chunk-TTSQWGAT.js → chunk-NAMH667S.js} +10 -15
- package/dist/chunks/{chunk-DJ4LO7PQ.js → chunk-VWDCKHCC.js} +1 -1
- package/dist/chunks/{chunk-IM7DLPPY.js → chunk-YKV45EMY.js} +239 -141
- package/dist/chunks/{chunk-OQCKDEEE.js → chunk-ZBIR5YS7.js} +1 -1
- package/dist/chunks/{chunk-TNRZEQD5.js → chunk-ZH6EAKVM.js} +2 -2
- package/dist/chunks/{host-image-fallback-AEKY2LSZ.js → host-image-fallback-GX2KXZXQ.js} +1 -1
- package/dist/chunks/{memory-git-G56IXFWU.js → memory-git-BJMYZHIE.js} +5 -5
- package/dist/chunks/{model-registry-4LM2I6FR.js → model-registry-T6EMM66I.js} +2 -2
- package/dist/chunks/{read-file-understanding-GTNZHAK5.js → read-file-understanding-ZRE5KDG3.js} +5 -5
- package/dist/chunks/{src-3YJ4UVEC.js → src-DLAIQCKP.js} +3 -3
- package/dist/chunks/{src-APNP4M4N.js → src-FWL3LCBK.js} +2 -2
- package/dist/chunks/{src-T6AUO53N.js → src-OP6LFLR6.js} +8 -4
- package/dist/chunks/{src-TNUD7EDH.js → src-XJKZIY3S.js} +11 -1
- package/dist/chunks/{test-stream-EF2DHEHV.js → test-stream-P3CUEGEE.js} +1 -1
- package/dist/cli.js +408 -52
- package/models.schema.json +4 -0
- package/package.json +2 -2
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
createSharedWebSearchTool,
|
|
11
11
|
defaultShellKindForPlatform,
|
|
12
12
|
interpretShellExit
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JE53PC46.js";
|
|
14
14
|
import {
|
|
15
15
|
classifyDefaultFailure,
|
|
16
16
|
isDefaultContextOverflowError,
|
|
17
17
|
requestInteraction
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-J6EZ335F.js";
|
|
19
19
|
import {
|
|
20
20
|
getLogger
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-YKV45EMY.js";
|
|
22
22
|
import {
|
|
23
23
|
Type
|
|
24
24
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -6,14 +6,16 @@ import {
|
|
|
6
6
|
ACTIVE_THINKING_LEVELS,
|
|
7
7
|
ALL_THINKING_LEVELS,
|
|
8
8
|
MODEL_CLASS_FALLBACK_ORDER,
|
|
9
|
+
deepMergePlainRecords,
|
|
9
10
|
getModelThinkingCapabilities,
|
|
10
11
|
isDisableWireCompatibleWithApi,
|
|
11
12
|
isThinkingModeCompatibleWithApi,
|
|
12
13
|
isThinkingSelectionLevel,
|
|
14
|
+
mergeModelCompat,
|
|
13
15
|
modelSupportsToolPurpose,
|
|
14
16
|
requiredCapabilityForToolPurpose,
|
|
15
17
|
sortToolModelCandidatesByCapability
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YKV45EMY.js";
|
|
17
19
|
|
|
18
20
|
// src/core/model-registry.ts
|
|
19
21
|
import * as fs2 from "fs";
|
|
@@ -34,16 +36,6 @@ function captureRegistryBaseline(state) {
|
|
|
34
36
|
auth: state.authStorage.snapshotProviderConfig()
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
function deepMergePlainRecords(base, patch) {
|
|
38
|
-
const isPlain = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
39
|
-
const result = isPlain(base) ? { ...base } : {};
|
|
40
|
-
if (!isPlain(patch)) return result;
|
|
41
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
42
|
-
const current = result[key];
|
|
43
|
-
result[key] = isPlain(current) && isPlain(value) ? deepMergePlainRecords(current, value) : value;
|
|
44
|
-
}
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
39
|
function restoreRegistryBaseline(baseline, target) {
|
|
48
40
|
target.models = cloneModelsMap(baseline.models);
|
|
49
41
|
target.modelOrder = baseline.order.slice();
|
|
@@ -664,6 +656,7 @@ function validateCompat(value, label) {
|
|
|
664
656
|
"supportsReasoningSummary",
|
|
665
657
|
"reasoningSummary",
|
|
666
658
|
"timeoutReplay",
|
|
659
|
+
"supportsPromptCacheKey",
|
|
667
660
|
"supportsStore",
|
|
668
661
|
"supportsDeveloperRole",
|
|
669
662
|
"supportsReasoningEffort",
|
|
@@ -689,6 +682,7 @@ function validateCompat(value, label) {
|
|
|
689
682
|
"responsesContinuation",
|
|
690
683
|
"supportsReasoningSummary",
|
|
691
684
|
"timeoutReplay",
|
|
685
|
+
"supportsPromptCacheKey",
|
|
692
686
|
"supportsStore",
|
|
693
687
|
"supportsDeveloperRole",
|
|
694
688
|
"supportsReasoningEffort",
|
|
@@ -1544,7 +1538,7 @@ var ModelRegistry = class {
|
|
|
1544
1538
|
if (providerConfig.apiKey) stagedApiKeys.set(provider, providerConfig.apiKey);
|
|
1545
1539
|
if (providerConfig.apiKeyEnv) stagedEnvVars.set(provider, providerConfig.apiKeyEnv);
|
|
1546
1540
|
const existing = this.models.get(provider);
|
|
1547
|
-
if (existing && (providerConfig.baseUrl || providerConfig.api || providerConfig.headers || providerConfig.transport)) {
|
|
1541
|
+
if (existing && (providerConfig.baseUrl || providerConfig.api || providerConfig.headers || providerConfig.transport || providerConfig.compat)) {
|
|
1548
1542
|
for (const model of existing.values()) {
|
|
1549
1543
|
this.upsert({
|
|
1550
1544
|
...model,
|
|
@@ -1555,6 +1549,7 @@ var ModelRegistry = class {
|
|
|
1555
1549
|
displayName: providerConfig.displayName || model.displayName || provider,
|
|
1556
1550
|
filePlatform: providerConfig.filePlatform || model.filePlatform,
|
|
1557
1551
|
attachmentPlatform: providerConfig.attachmentPlatform || model.attachmentPlatform,
|
|
1552
|
+
compat: mergeModelCompat(model.compat, providerConfig.compat),
|
|
1558
1553
|
cacheCapability: providerConfig.cacheCapability || model.cacheCapability,
|
|
1559
1554
|
webSearch: providerConfig.webSearch || model.webSearch,
|
|
1560
1555
|
fileCapabilities: providerConfig.fileCapabilities || model.fileCapabilities,
|
|
@@ -1581,7 +1576,7 @@ var ModelRegistry = class {
|
|
|
1581
1576
|
attachmentPlatform: customModel.attachmentPlatform || providerConfig.attachmentPlatform || baseModel?.attachmentPlatform,
|
|
1582
1577
|
headers: providerConfig.headers ? { ...baseModel?.headers, ...providerConfig.headers, ...customModel.headers } : customModel.headers || baseModel?.headers,
|
|
1583
1578
|
transport: customModel.transport ?? providerConfig.transport ?? baseModel?.transport,
|
|
1584
|
-
compat:
|
|
1579
|
+
compat: mergeModelCompat(baseModel?.compat, providerConfig.compat, customModel.compat),
|
|
1585
1580
|
cacheCapability: customModel.cacheCapability || providerConfig.cacheCapability || baseModel?.cacheCapability,
|
|
1586
1581
|
webSearch: customModel.webSearch || providerConfig.webSearch || baseModel?.webSearch,
|
|
1587
1582
|
fileCapabilities: customModel.fileCapabilities || providerConfig.fileCapabilities || baseModel?.fileCapabilities
|
|
@@ -1699,7 +1694,7 @@ var ModelRegistry = class {
|
|
|
1699
1694
|
attachmentPlatform: customModel.attachmentPlatform || providerConfig.attachmentPlatform,
|
|
1700
1695
|
headers: { ...providerConfig.headers, ...customModel.headers },
|
|
1701
1696
|
transport: customModel.transport ?? providerConfig.transport,
|
|
1702
|
-
compat:
|
|
1697
|
+
compat: mergeModelCompat(providerConfig.compat, customModel.compat),
|
|
1703
1698
|
cacheCapability: customModel.cacheCapability || providerConfig.cacheCapability,
|
|
1704
1699
|
webSearch: customModel.webSearch || providerConfig.webSearch,
|
|
1705
1700
|
fileCapabilities: customModel.fileCapabilities || providerConfig.fileCapabilities
|
|
@@ -2193,7 +2188,7 @@ var ModelRegistry = class {
|
|
|
2193
2188
|
displayName: customModel.displayName || baseModel?.displayName || provider,
|
|
2194
2189
|
headers: customHeaders,
|
|
2195
2190
|
transport: customModel.transport ?? config.transport ?? baseModel?.transport,
|
|
2196
|
-
compat: customModel.compat
|
|
2191
|
+
compat: routeChanged ? mergeModelCompat(customModel.compat) : mergeModelCompat(baseModel?.compat, customModel.compat),
|
|
2197
2192
|
cacheCapability: customModel.cacheCapability || baseModel?.cacheCapability,
|
|
2198
2193
|
webSearch: customModel.webSearch || baseModel?.webSearch,
|
|
2199
2194
|
fileCapabilities: customModel.fileCapabilities || baseModel?.fileCapabilities
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
redactText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JE53PC46.js";
|
|
5
5
|
|
|
6
6
|
// src/commands/memory-git.ts
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
@@ -5099,6 +5099,31 @@ function formatResponsesErrorEvent(event) {
|
|
|
5099
5099
|
}
|
|
5100
5100
|
return metadata.length > 0 ? `${message} (${metadata.join(", ")})` : message;
|
|
5101
5101
|
}
|
|
5102
|
+
function extractResponsesOutputText(parsed) {
|
|
5103
|
+
if (!isRecord(parsed)) return "";
|
|
5104
|
+
if (typeof parsed.output_text === "string" && parsed.output_text.trim()) {
|
|
5105
|
+
return parsed.output_text.trim();
|
|
5106
|
+
}
|
|
5107
|
+
if (Array.isArray(parsed.output)) {
|
|
5108
|
+
const parts = [];
|
|
5109
|
+
for (const item of parsed.output) {
|
|
5110
|
+
if (!isRecord(item)) continue;
|
|
5111
|
+
if (item.type !== void 0 && item.type !== "message") continue;
|
|
5112
|
+
if (typeof item.content === "string") {
|
|
5113
|
+
if (item.content.trim()) parts.push(item.content);
|
|
5114
|
+
continue;
|
|
5115
|
+
}
|
|
5116
|
+
if (!Array.isArray(item.content)) continue;
|
|
5117
|
+
for (const part of item.content) {
|
|
5118
|
+
if (!isRecord(part)) continue;
|
|
5119
|
+
if (part.type !== void 0 && part.type !== "output_text" && part.type !== "text") continue;
|
|
5120
|
+
if (typeof part.text === "string" && part.text.trim()) parts.push(part.text);
|
|
5121
|
+
}
|
|
5122
|
+
}
|
|
5123
|
+
return parts.join("\n").trim();
|
|
5124
|
+
}
|
|
5125
|
+
return "";
|
|
5126
|
+
}
|
|
5102
5127
|
|
|
5103
5128
|
// ../../packages/ai/src/providers/responses/responses-remote-failure.ts
|
|
5104
5129
|
var MAX_TEXT = 4096;
|
|
@@ -5115,16 +5140,28 @@ var transientCodes = /* @__PURE__ */ new Set([
|
|
|
5115
5140
|
"gateway_timeout",
|
|
5116
5141
|
"request_timeout"
|
|
5117
5142
|
]);
|
|
5118
|
-
var QUOTA_OR_BILLING_FIELDS = /
|
|
5119
|
-
var QUOTA_OR_BILLING_MESSAGE = /
|
|
5143
|
+
var QUOTA_OR_BILLING_FIELDS = /billing_(?:hard_limit|not_active|limit|error)|insufficient_quota|insufficient_balance|insufficient_credit|plan_quota_(?:exhausted|exceeded|depleted)|credit_protection|credit_balance|spend_limit|arrearage/;
|
|
5144
|
+
var QUOTA_OR_BILLING_MESSAGE = /insufficient[_ ]quota|plan[_ ]quota[_ ](?:exhausted|exceeded|depleted)|fresh plan quota.*required|credit[_ ]protection|credits are disabled|exceeded[_ ]current[_ ]quota|exceeded your current quota|billing[_ ]hard[_ ]limit|billing[_ ](?:limit|not active|disabled|required)|(?:account|monthly|billing|plan) quota (?:has been |is )?(?:exhausted|exceeded|depleted)|insufficient[_ ](?:credit|balance)|credit balance(?: is)? (?:too low|exhausted|depleted|insufficient)|spend(?:ing)? limit|\barrearage\b|余额不足|周限额|月限额|套餐配额|(?:您)?已达到.{0,12}(?:5\s*小时|每周|每月|本周|本月).{0,6}(?:使用)?上限|\b(?:5[\s-]?hour|5h|weekly|monthly)\s+(?:plan\s+|subscription\s+)?(?:usage\s+)?limit\b|\bplan\s+usage\s+limit\b/;
|
|
5120
5145
|
var STREAM_LOSS_ERROR_PATTERN = /(?:sse|upstream) stream (?:aborted|closed before end|ended before response completed)|upstream_stream_error|\bsse_abort\b|ClientPayloadError|premature close|socket hang up|other side closed|(?:read\s+)?ECONNRESET|ETIMEDOUT|terminated/i;
|
|
5121
5146
|
function extractErrorParts(value, status) {
|
|
5122
|
-
|
|
5147
|
+
let normalizedValue = value;
|
|
5148
|
+
if (typeof value === "string" && value.trimStart().startsWith("{")) {
|
|
5149
|
+
const parsed = parseResponsesErrorBody(value);
|
|
5150
|
+
if (isRecord(parsed)) normalizedValue = parsed;
|
|
5151
|
+
}
|
|
5152
|
+
const root = isRecord(normalizedValue) ? normalizedValue : {};
|
|
5123
5153
|
const response = isRecord(root.response) ? root.response : {};
|
|
5124
|
-
const error = isRecord(root.error) ? root.error : isRecord(response.error) ? response.error : root;
|
|
5154
|
+
const error = isRecord(root.error) ? root.error : isRecord(response.error) ? response.error : isRecord(root.detail) ? root.detail : root;
|
|
5125
5155
|
const code = typeof error.code === "string" ? error.code.slice(0, 128).toLowerCase() : "";
|
|
5126
5156
|
const type = typeof error.type === "string" ? error.type.slice(0, 128).toLowerCase() : "";
|
|
5127
|
-
const rawMessage = typeof
|
|
5157
|
+
const rawMessage = typeof normalizedValue === "string" ? normalizedValue : [
|
|
5158
|
+
error.message,
|
|
5159
|
+
error.detail,
|
|
5160
|
+
root.message,
|
|
5161
|
+
root.error,
|
|
5162
|
+
response.error,
|
|
5163
|
+
root.detail
|
|
5164
|
+
].filter((part) => typeof part === "string" && part.length > 0).join(" ");
|
|
5128
5165
|
const message = rawMessage.slice(0, MAX_TEXT).toLowerCase();
|
|
5129
5166
|
const httpStatus = status ?? root.status ?? root.statusCode;
|
|
5130
5167
|
return { root, code, type, fields: `${code} ${type}`, message, httpStatus };
|
|
@@ -5139,12 +5176,23 @@ function isStreamLossErrorText(text) {
|
|
|
5139
5176
|
function responsesRemoteFailure(value, status, headers) {
|
|
5140
5177
|
const { root, code, type, fields, message, httpStatus } = extractErrorParts(value, status);
|
|
5141
5178
|
let category = "other";
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
else if (
|
|
5179
|
+
let quotaExhausted = false;
|
|
5180
|
+
if (/context_length_exceeded|context_window_exceeded|context_overflow/.test(fields) || /context (?:length|window).{0,60}(?:exceed|too (?:long|large))|maximum context length|exceeds.{0,30}context window/.test(message)) {
|
|
5181
|
+
category = "context_overflow";
|
|
5182
|
+
} else if (QUOTA_OR_BILLING_FIELDS.test(fields) || QUOTA_OR_BILLING_MESSAGE.test(message)) {
|
|
5183
|
+
category = "other";
|
|
5184
|
+
quotaExhausted = true;
|
|
5185
|
+
} else if (typeof httpStatus === "number" && httpStatus >= 400 && httpStatus < 500 && httpStatus !== 429 && httpStatus !== 408) {
|
|
5186
|
+
category = "other";
|
|
5187
|
+
} else if (httpStatus === 429 || httpStatus === 408 || typeof httpStatus === "number" && httpStatus >= 500 && httpStatus <= 599 && httpStatus !== 501 || transientCodes.has(code) || transientCodes.has(type) || /server (?:is )?overloaded|temporarily unavailable|internal server error|rate limit (?:exceeded|reached)|upstream stream aborted|clientpayloaderror/.test(message)) {
|
|
5188
|
+
category = "transient";
|
|
5189
|
+
}
|
|
5146
5190
|
const retryAfterMs = parseRetryAfter(headers ?? root.headers);
|
|
5147
|
-
return {
|
|
5191
|
+
return {
|
|
5192
|
+
category,
|
|
5193
|
+
...quotaExhausted ? { quotaExhausted: true } : {},
|
|
5194
|
+
...retryAfterMs !== void 0 ? { retryAfterMs } : {}
|
|
5195
|
+
};
|
|
5148
5196
|
}
|
|
5149
5197
|
function parseRetryAfter(headers) {
|
|
5150
5198
|
if (!headers || typeof headers !== "object") return void 0;
|
|
@@ -5655,15 +5703,15 @@ ${delta}`;
|
|
|
5655
5703
|
this.diagnostics.terminalType = "response.incomplete";
|
|
5656
5704
|
const response = this.requireTerminalResponse(raw);
|
|
5657
5705
|
const reason = response?.incomplete_details?.reason;
|
|
5658
|
-
if (reason === "
|
|
5659
|
-
this.terminal = {
|
|
5660
|
-
reason: "error",
|
|
5661
|
-
response,
|
|
5662
|
-
errorText: reason === "steered" ? "Response ended incomplete with reason 'steered' but no steering was sent." : `Response ended incomplete${reason ? ` (${reason})` : " without a reason"}.`
|
|
5663
|
-
};
|
|
5706
|
+
if (reason === "max_output_tokens" || reason === "max_tokens" || reason === "max_messages") {
|
|
5707
|
+
this.terminal = { reason: "length", response };
|
|
5664
5708
|
return this.closeResponse("response.incomplete");
|
|
5665
5709
|
}
|
|
5666
|
-
this.terminal = {
|
|
5710
|
+
this.terminal = {
|
|
5711
|
+
reason: "error",
|
|
5712
|
+
response,
|
|
5713
|
+
errorText: reason === "steered" ? "Response ended incomplete with reason 'steered' but no steering was sent." : `Response ended incomplete${reason ? ` (${reason})` : " without a reason"}.`
|
|
5714
|
+
};
|
|
5667
5715
|
return this.closeResponse("response.incomplete");
|
|
5668
5716
|
}
|
|
5669
5717
|
failedText(raw) {
|
|
@@ -7164,12 +7212,144 @@ function getResponsesCompat(model) {
|
|
|
7164
7212
|
responsesContinuation: compat.responsesContinuation ?? false,
|
|
7165
7213
|
supportsReasoningSummary: compat.supportsReasoningSummary ?? false,
|
|
7166
7214
|
reasoningSummary: compat.reasoningSummary ?? "auto",
|
|
7167
|
-
timeoutReplay: compat.timeoutReplay ?? false
|
|
7215
|
+
timeoutReplay: compat.timeoutReplay ?? false,
|
|
7216
|
+
supportsPromptCacheKey: compat.supportsPromptCacheKey ?? false
|
|
7168
7217
|
};
|
|
7169
7218
|
}
|
|
7170
7219
|
|
|
7220
|
+
// ../../packages/ai/src/providers/responses/responses-continuation.ts
|
|
7221
|
+
function jsonSha256(value) {
|
|
7222
|
+
return hashJson(value);
|
|
7223
|
+
}
|
|
7224
|
+
function hashJson(value, parts) {
|
|
7225
|
+
const utf8 = tryCreateUtf8Sha256Hasher();
|
|
7226
|
+
try {
|
|
7227
|
+
const hash = utf8 ? void 0 : createSha256Hasher();
|
|
7228
|
+
const bytes = new Uint8Array(utf8 ? 0 : 8192);
|
|
7229
|
+
let fragments = "";
|
|
7230
|
+
let used = 0;
|
|
7231
|
+
const byte = (n) => {
|
|
7232
|
+
bytes[used++] = n;
|
|
7233
|
+
if (used === bytes.length) {
|
|
7234
|
+
hash.update(bytes);
|
|
7235
|
+
used = 0;
|
|
7236
|
+
}
|
|
7237
|
+
};
|
|
7238
|
+
const emit = (text) => {
|
|
7239
|
+
if (utf8) {
|
|
7240
|
+
if (fragments.length + text.length > 8192) {
|
|
7241
|
+
if (fragments) utf8.updateUtf8(fragments);
|
|
7242
|
+
fragments = "";
|
|
7243
|
+
}
|
|
7244
|
+
if (text.length >= 8192) utf8.updateUtf8(text);
|
|
7245
|
+
else fragments += text;
|
|
7246
|
+
return;
|
|
7247
|
+
}
|
|
7248
|
+
for (let i = 0; i < text.length; i++) {
|
|
7249
|
+
const cp = text.codePointAt(i);
|
|
7250
|
+
if (cp < 128) byte(cp);
|
|
7251
|
+
else if (cp < 2048) {
|
|
7252
|
+
byte(192 | cp >> 6);
|
|
7253
|
+
byte(128 | cp & 63);
|
|
7254
|
+
} else if (cp < 65536) {
|
|
7255
|
+
byte(224 | cp >> 12);
|
|
7256
|
+
byte(128 | cp >> 6 & 63);
|
|
7257
|
+
byte(128 | cp & 63);
|
|
7258
|
+
} else {
|
|
7259
|
+
byte(240 | cp >> 18);
|
|
7260
|
+
byte(128 | cp >> 12 & 63);
|
|
7261
|
+
byte(128 | cp >> 6 & 63);
|
|
7262
|
+
byte(128 | cp & 63);
|
|
7263
|
+
i++;
|
|
7264
|
+
}
|
|
7265
|
+
}
|
|
7266
|
+
};
|
|
7267
|
+
const string = (text) => {
|
|
7268
|
+
emit('"');
|
|
7269
|
+
for (let start = 0; start < text.length; ) {
|
|
7270
|
+
let end = Math.min(start + 2048, text.length);
|
|
7271
|
+
if (end < text.length && text.charCodeAt(end - 1) >= 55296 && text.charCodeAt(end - 1) <= 56319) end--;
|
|
7272
|
+
const escaped = JSON.stringify(text.slice(start, end));
|
|
7273
|
+
emit(escaped.slice(1, -1));
|
|
7274
|
+
start = end;
|
|
7275
|
+
}
|
|
7276
|
+
emit('"');
|
|
7277
|
+
};
|
|
7278
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
7279
|
+
const omitted = (v) => v === void 0 || typeof v === "function" || typeof v === "symbol";
|
|
7280
|
+
const visit = (v) => {
|
|
7281
|
+
if (typeof v === "string") {
|
|
7282
|
+
string(v);
|
|
7283
|
+
return;
|
|
7284
|
+
}
|
|
7285
|
+
if (v === null || typeof v !== "object") {
|
|
7286
|
+
const encoded = JSON.stringify(v);
|
|
7287
|
+
if (encoded === void 0) throw new TypeError("Not a JSON value");
|
|
7288
|
+
emit(encoded);
|
|
7289
|
+
return;
|
|
7290
|
+
}
|
|
7291
|
+
const prototype = Object.getPrototypeOf(v);
|
|
7292
|
+
if (!Array.isArray(v) && prototype !== Object.prototype && prototype !== null || typeof v.toJSON === "function") throw new TypeError("Not a JSON snapshot");
|
|
7293
|
+
if (ancestors.has(v)) throw new TypeError("Circular JSON snapshot");
|
|
7294
|
+
ancestors.add(v);
|
|
7295
|
+
if (Array.isArray(v)) {
|
|
7296
|
+
emit("[");
|
|
7297
|
+
for (let i = 0; i < v.length; i++) {
|
|
7298
|
+
if (Object.getOwnPropertyDescriptor(v, i)?.get) throw new TypeError("Not a JSON snapshot");
|
|
7299
|
+
if (i) emit(",");
|
|
7300
|
+
visit(omitted(v[i]) ? null : v[i]);
|
|
7301
|
+
}
|
|
7302
|
+
emit("]");
|
|
7303
|
+
} else {
|
|
7304
|
+
emit("{");
|
|
7305
|
+
let first = true;
|
|
7306
|
+
for (const key of Object.keys(v)) {
|
|
7307
|
+
if (Object.getOwnPropertyDescriptor(v, key)?.get) throw new TypeError("Not a JSON snapshot");
|
|
7308
|
+
const entry = v[key];
|
|
7309
|
+
if (omitted(entry)) continue;
|
|
7310
|
+
if (!first) emit(",");
|
|
7311
|
+
first = false;
|
|
7312
|
+
string(key);
|
|
7313
|
+
emit(":");
|
|
7314
|
+
visit(entry);
|
|
7315
|
+
}
|
|
7316
|
+
emit("}");
|
|
7317
|
+
}
|
|
7318
|
+
ancestors.delete(v);
|
|
7319
|
+
};
|
|
7320
|
+
if (parts) {
|
|
7321
|
+
emit("[");
|
|
7322
|
+
for (let i = 0; i < parts.count + parts.output.length; i++) {
|
|
7323
|
+
if (i) emit(",");
|
|
7324
|
+
const item = i < parts.count ? parts.input[i] : parts.output[i - parts.count];
|
|
7325
|
+
visit(omitted(item) ? null : item);
|
|
7326
|
+
}
|
|
7327
|
+
emit("]");
|
|
7328
|
+
} else visit(value);
|
|
7329
|
+
if (utf8) {
|
|
7330
|
+
if (fragments) utf8.updateUtf8(fragments);
|
|
7331
|
+
return utf8.digestHex();
|
|
7332
|
+
}
|
|
7333
|
+
if (used) hash.update(bytes.subarray(0, used));
|
|
7334
|
+
return hash.digestHex();
|
|
7335
|
+
} finally {
|
|
7336
|
+
utf8?.dispose();
|
|
7337
|
+
}
|
|
7338
|
+
}
|
|
7339
|
+
function inputSha256(input, count = input.length, output = []) {
|
|
7340
|
+
return hashJson(void 0, { input, count, output });
|
|
7341
|
+
}
|
|
7342
|
+
|
|
7171
7343
|
// ../../packages/ai/src/providers/responses/responses-request.ts
|
|
7172
7344
|
var MAX_REASONING_ENVELOPE_BYTES = 512 * 1024;
|
|
7345
|
+
var MAX_PROMPT_CACHE_KEY_LEN = 64;
|
|
7346
|
+
var SAFE_PROMPT_CACHE_KEY_RE = /^[\x21-\x7E]{1,64}$/;
|
|
7347
|
+
function normalizePromptCacheKey(sessionId) {
|
|
7348
|
+
const trimmed = sessionId.trim();
|
|
7349
|
+
if (!trimmed) return void 0;
|
|
7350
|
+
if (SAFE_PROMPT_CACHE_KEY_RE.test(trimmed)) return trimmed;
|
|
7351
|
+
return `pie-${jsonSha256(trimmed).slice(0, MAX_PROMPT_CACHE_KEY_LEN - 4)}`;
|
|
7352
|
+
}
|
|
7173
7353
|
function decodeReasoningEnvelope(signature) {
|
|
7174
7354
|
if (typeof signature !== "string" || signature.length === 0 || signature.length > MAX_REASONING_ENVELOPE_BYTES) {
|
|
7175
7355
|
return null;
|
|
@@ -7318,6 +7498,10 @@ function buildResponsesRequest(model, context, options, compat = getResponsesCom
|
|
|
7318
7498
|
if (compat.supportsStore) {
|
|
7319
7499
|
params.store = compat.store;
|
|
7320
7500
|
}
|
|
7501
|
+
if (compat.supportsPromptCacheKey && options?.cacheRetention !== "none" && typeof options?.sessionId === "string") {
|
|
7502
|
+
const cacheKey = normalizePromptCacheKey(options.sessionId);
|
|
7503
|
+
if (cacheKey) params.prompt_cache_key = cacheKey;
|
|
7504
|
+
}
|
|
7321
7505
|
if (options?.maxTokens !== void 0 && options.maxTokens > 0) {
|
|
7322
7506
|
params.max_output_tokens = options.maxTokens;
|
|
7323
7507
|
}
|
|
@@ -7675,129 +7859,6 @@ function streamResponsesSSE(model, context, options) {
|
|
|
7675
7859
|
return stream2;
|
|
7676
7860
|
}
|
|
7677
7861
|
|
|
7678
|
-
// ../../packages/ai/src/providers/responses/responses-continuation.ts
|
|
7679
|
-
function jsonSha256(value) {
|
|
7680
|
-
return hashJson(value);
|
|
7681
|
-
}
|
|
7682
|
-
function hashJson(value, parts) {
|
|
7683
|
-
const utf8 = tryCreateUtf8Sha256Hasher();
|
|
7684
|
-
try {
|
|
7685
|
-
const hash = utf8 ? void 0 : createSha256Hasher();
|
|
7686
|
-
const bytes = new Uint8Array(utf8 ? 0 : 8192);
|
|
7687
|
-
let fragments = "";
|
|
7688
|
-
let used = 0;
|
|
7689
|
-
const byte = (n) => {
|
|
7690
|
-
bytes[used++] = n;
|
|
7691
|
-
if (used === bytes.length) {
|
|
7692
|
-
hash.update(bytes);
|
|
7693
|
-
used = 0;
|
|
7694
|
-
}
|
|
7695
|
-
};
|
|
7696
|
-
const emit = (text) => {
|
|
7697
|
-
if (utf8) {
|
|
7698
|
-
if (fragments.length + text.length > 8192) {
|
|
7699
|
-
if (fragments) utf8.updateUtf8(fragments);
|
|
7700
|
-
fragments = "";
|
|
7701
|
-
}
|
|
7702
|
-
if (text.length >= 8192) utf8.updateUtf8(text);
|
|
7703
|
-
else fragments += text;
|
|
7704
|
-
return;
|
|
7705
|
-
}
|
|
7706
|
-
for (let i = 0; i < text.length; i++) {
|
|
7707
|
-
const cp = text.codePointAt(i);
|
|
7708
|
-
if (cp < 128) byte(cp);
|
|
7709
|
-
else if (cp < 2048) {
|
|
7710
|
-
byte(192 | cp >> 6);
|
|
7711
|
-
byte(128 | cp & 63);
|
|
7712
|
-
} else if (cp < 65536) {
|
|
7713
|
-
byte(224 | cp >> 12);
|
|
7714
|
-
byte(128 | cp >> 6 & 63);
|
|
7715
|
-
byte(128 | cp & 63);
|
|
7716
|
-
} else {
|
|
7717
|
-
byte(240 | cp >> 18);
|
|
7718
|
-
byte(128 | cp >> 12 & 63);
|
|
7719
|
-
byte(128 | cp >> 6 & 63);
|
|
7720
|
-
byte(128 | cp & 63);
|
|
7721
|
-
i++;
|
|
7722
|
-
}
|
|
7723
|
-
}
|
|
7724
|
-
};
|
|
7725
|
-
const string = (text) => {
|
|
7726
|
-
emit('"');
|
|
7727
|
-
for (let start = 0; start < text.length; ) {
|
|
7728
|
-
let end = Math.min(start + 2048, text.length);
|
|
7729
|
-
if (end < text.length && text.charCodeAt(end - 1) >= 55296 && text.charCodeAt(end - 1) <= 56319) end--;
|
|
7730
|
-
const escaped = JSON.stringify(text.slice(start, end));
|
|
7731
|
-
emit(escaped.slice(1, -1));
|
|
7732
|
-
start = end;
|
|
7733
|
-
}
|
|
7734
|
-
emit('"');
|
|
7735
|
-
};
|
|
7736
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
7737
|
-
const omitted = (v) => v === void 0 || typeof v === "function" || typeof v === "symbol";
|
|
7738
|
-
const visit = (v) => {
|
|
7739
|
-
if (typeof v === "string") {
|
|
7740
|
-
string(v);
|
|
7741
|
-
return;
|
|
7742
|
-
}
|
|
7743
|
-
if (v === null || typeof v !== "object") {
|
|
7744
|
-
const encoded = JSON.stringify(v);
|
|
7745
|
-
if (encoded === void 0) throw new TypeError("Not a JSON value");
|
|
7746
|
-
emit(encoded);
|
|
7747
|
-
return;
|
|
7748
|
-
}
|
|
7749
|
-
const prototype = Object.getPrototypeOf(v);
|
|
7750
|
-
if (!Array.isArray(v) && prototype !== Object.prototype && prototype !== null || typeof v.toJSON === "function") throw new TypeError("Not a JSON snapshot");
|
|
7751
|
-
if (ancestors.has(v)) throw new TypeError("Circular JSON snapshot");
|
|
7752
|
-
ancestors.add(v);
|
|
7753
|
-
if (Array.isArray(v)) {
|
|
7754
|
-
emit("[");
|
|
7755
|
-
for (let i = 0; i < v.length; i++) {
|
|
7756
|
-
if (Object.getOwnPropertyDescriptor(v, i)?.get) throw new TypeError("Not a JSON snapshot");
|
|
7757
|
-
if (i) emit(",");
|
|
7758
|
-
visit(omitted(v[i]) ? null : v[i]);
|
|
7759
|
-
}
|
|
7760
|
-
emit("]");
|
|
7761
|
-
} else {
|
|
7762
|
-
emit("{");
|
|
7763
|
-
let first = true;
|
|
7764
|
-
for (const key of Object.keys(v)) {
|
|
7765
|
-
if (Object.getOwnPropertyDescriptor(v, key)?.get) throw new TypeError("Not a JSON snapshot");
|
|
7766
|
-
const entry = v[key];
|
|
7767
|
-
if (omitted(entry)) continue;
|
|
7768
|
-
if (!first) emit(",");
|
|
7769
|
-
first = false;
|
|
7770
|
-
string(key);
|
|
7771
|
-
emit(":");
|
|
7772
|
-
visit(entry);
|
|
7773
|
-
}
|
|
7774
|
-
emit("}");
|
|
7775
|
-
}
|
|
7776
|
-
ancestors.delete(v);
|
|
7777
|
-
};
|
|
7778
|
-
if (parts) {
|
|
7779
|
-
emit("[");
|
|
7780
|
-
for (let i = 0; i < parts.count + parts.output.length; i++) {
|
|
7781
|
-
if (i) emit(",");
|
|
7782
|
-
const item = i < parts.count ? parts.input[i] : parts.output[i - parts.count];
|
|
7783
|
-
visit(omitted(item) ? null : item);
|
|
7784
|
-
}
|
|
7785
|
-
emit("]");
|
|
7786
|
-
} else visit(value);
|
|
7787
|
-
if (utf8) {
|
|
7788
|
-
if (fragments) utf8.updateUtf8(fragments);
|
|
7789
|
-
return utf8.digestHex();
|
|
7790
|
-
}
|
|
7791
|
-
if (used) hash.update(bytes.subarray(0, used));
|
|
7792
|
-
return hash.digestHex();
|
|
7793
|
-
} finally {
|
|
7794
|
-
utf8?.dispose();
|
|
7795
|
-
}
|
|
7796
|
-
}
|
|
7797
|
-
function inputSha256(input, count = input.length, output = []) {
|
|
7798
|
-
return hashJson(void 0, { input, count, output });
|
|
7799
|
-
}
|
|
7800
|
-
|
|
7801
7862
|
// ../../packages/ai/src/providers/responses/responses-ws.ts
|
|
7802
7863
|
var owners = /* @__PURE__ */ new WeakMap();
|
|
7803
7864
|
var DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
|
|
@@ -8438,6 +8499,38 @@ var streamSimpleResponses = (model, context, options) => {
|
|
|
8438
8499
|
});
|
|
8439
8500
|
};
|
|
8440
8501
|
|
|
8502
|
+
// ../../packages/ai/src/compat-merge.ts
|
|
8503
|
+
var FORBIDDEN_MERGE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
8504
|
+
function isPlainRecord(value) {
|
|
8505
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
8506
|
+
const proto = Object.getPrototypeOf(value);
|
|
8507
|
+
return proto === Object.prototype || proto === null;
|
|
8508
|
+
}
|
|
8509
|
+
function deepMergePlainRecords(base, patch) {
|
|
8510
|
+
const result = {};
|
|
8511
|
+
if (isPlainRecord(base)) {
|
|
8512
|
+
for (const [key, value] of Object.entries(base)) {
|
|
8513
|
+
if (FORBIDDEN_MERGE_KEYS.has(key)) continue;
|
|
8514
|
+
result[key] = isPlainRecord(value) ? deepMergePlainRecords({}, value) : value;
|
|
8515
|
+
}
|
|
8516
|
+
}
|
|
8517
|
+
if (!isPlainRecord(patch)) return result;
|
|
8518
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
8519
|
+
if (FORBIDDEN_MERGE_KEYS.has(key)) continue;
|
|
8520
|
+
const current = result[key];
|
|
8521
|
+
result[key] = isPlainRecord(current) && isPlainRecord(value) ? deepMergePlainRecords(current, value) : isPlainRecord(value) ? deepMergePlainRecords({}, value) : value;
|
|
8522
|
+
}
|
|
8523
|
+
return result;
|
|
8524
|
+
}
|
|
8525
|
+
function mergeModelCompat(...layers) {
|
|
8526
|
+
let merged;
|
|
8527
|
+
for (const layer of layers) {
|
|
8528
|
+
if (!isPlainRecord(layer)) continue;
|
|
8529
|
+
merged = merged ? deepMergePlainRecords(merged, layer) : deepMergePlainRecords({}, layer);
|
|
8530
|
+
}
|
|
8531
|
+
return merged;
|
|
8532
|
+
}
|
|
8533
|
+
|
|
8441
8534
|
// ../../packages/ai/src/stream.ts
|
|
8442
8535
|
function resolveApiProvider(api) {
|
|
8443
8536
|
const provider = getApiProvider(api);
|
|
@@ -12000,6 +12093,9 @@ export {
|
|
|
12000
12093
|
logEmptyAssistantContentError,
|
|
12001
12094
|
RESPONSES_PROTOCOL_ERROR_CODE,
|
|
12002
12095
|
ResponsesProtocolError,
|
|
12096
|
+
extractResponsesOutputText,
|
|
12097
|
+
isQuotaOrBillingFailure,
|
|
12098
|
+
parseResponsesErrorBody,
|
|
12003
12099
|
OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
|
|
12004
12100
|
OpenAICompatProtocolError,
|
|
12005
12101
|
streamOpenAICompletions,
|
|
@@ -12010,6 +12106,8 @@ export {
|
|
|
12010
12106
|
disposeModelTransports,
|
|
12011
12107
|
streamResponses,
|
|
12012
12108
|
streamSimpleResponses,
|
|
12109
|
+
deepMergePlainRecords,
|
|
12110
|
+
mergeModelCompat,
|
|
12013
12111
|
stream,
|
|
12014
12112
|
complete,
|
|
12015
12113
|
streamSimple,
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
createReadFileUnderstandingHandler,
|
|
7
7
|
modalityForReadFileUnderstandingKind
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JE53PC46.js";
|
|
9
9
|
import {
|
|
10
10
|
getLogger
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YKV45EMY.js";
|
|
12
12
|
|
|
13
13
|
// src/capabilities/read-file-understanding.ts
|
|
14
14
|
import * as path10 from "node:path";
|
|
@@ -5,7 +5,7 @@ import "./chunk-LZQXQOPJ.js";
|
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
async function describeImageViaUnderstandingChain(options) {
|
|
7
7
|
try {
|
|
8
|
-
const { understandReadFile } = await import("./read-file-understanding-
|
|
8
|
+
const { understandReadFile } = await import("./read-file-understanding-ZRE5KDG3.js");
|
|
9
9
|
const ext = options.filePath.toLowerCase().split(".").pop() ?? "";
|
|
10
10
|
const mimeType = ext === "png" ? "image/png" : ext === "gif" ? "image/gif" : ext === "webp" ? "image/webp" : "image/jpeg";
|
|
11
11
|
const result = await understandReadFile(
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
ensureMemoryGitIgnore,
|
|
5
5
|
isMemoryGitInitialized,
|
|
6
6
|
readCuratedMemoryGitLog
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-VWDCKHCC.js";
|
|
8
|
+
import "./chunk-JE53PC46.js";
|
|
9
|
+
import "./chunk-J6EZ335F.js";
|
|
10
|
+
import "./chunk-MTH6QSYD.js";
|
|
11
|
+
import "./chunk-YKV45EMY.js";
|
|
12
12
|
import "./chunk-XXGYUYXI.js";
|
|
13
13
|
import "./chunk-LZQXQOPJ.js";
|
|
14
14
|
export {
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
validateModelsDocumentShape,
|
|
9
9
|
validateProfileConfig,
|
|
10
10
|
validatedRemoteCatalogs
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NAMH667S.js";
|
|
12
12
|
import "./chunk-CBDQJMUI.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-YKV45EMY.js";
|
|
14
14
|
import "./chunk-XXGYUYXI.js";
|
|
15
15
|
import "./chunk-LZQXQOPJ.js";
|
|
16
16
|
export {
|