@cydm/pie 4.13.0 → 4.14.0
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/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +8099 -8101
- package/dist/builtin/extensions/mcp-adapter/index.js +86 -81
- package/dist/builtin/extensions/memory/index.js +30 -7
- package/dist/builtin/extensions/pie-ipc/index.js +13 -18
- package/dist/builtin/extensions/pie-proc/index.js +69 -60
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +6 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-BQWHLYYZ.js → chunk-26KRUYZH.js} +1 -1
- package/dist/chunks/{chunk-5MCIBDAM.js → chunk-BOQIGMGQ.js} +38 -93
- package/dist/chunks/{chunk-AKC7NMP4.js → chunk-EZZTMDWZ.js} +887 -391
- package/dist/chunks/{chunk-5PCLBIOO.js → chunk-FD3KBPDR.js} +110 -75
- package/dist/chunks/{chunk-NOSNHMA2.js → chunk-IK2FR2YF.js} +2 -1
- package/dist/chunks/{chunk-SXBX2P5R.js → chunk-JJH77AUU.js} +1709 -1577
- package/dist/chunks/{chunk-OGGL6LUN.js → chunk-JKO42HZW.js} +1 -1
- package/dist/chunks/{chunk-3CJLYX5J.js → chunk-KGWKRO7Z.js} +2 -2
- package/dist/chunks/{chunk-G2K4GY6N.js → chunk-MCR4JYI6.js} +103 -12
- package/dist/chunks/{chunk-IZ4DYCJ7.js → chunk-UYDS75SI.js} +810 -726
- package/dist/chunks/{host-image-fallback-MZK633DK.js → host-image-fallback-LPHB5CTL.js} +1 -1
- package/dist/chunks/{manager-cli-OTIMAWO6.js → manager-cli-ZV36YNPJ.js} +187 -173
- package/dist/chunks/{memory-git-Q3UBYOJ4.js → memory-git-ZJN6SPIU.js} +5 -5
- package/dist/chunks/{model-registry-QNEPISBJ.js → model-registry-GLBIUOJR.js} +2 -2
- package/dist/chunks/{read-file-understanding-KCJMSOS7.js → read-file-understanding-DFJPTTSB.js} +5 -5
- package/dist/chunks/{src-TIDKYA5F.js → src-76Q33OY5.js} +1 -1
- package/dist/chunks/{src-D5GN4Q5O.js → src-ALHMJZ5R.js} +2 -2
- package/dist/chunks/{src-7MZZJVOG.js → src-KZ7YID3I.js} +11 -3
- package/dist/chunks/{src-QI47K3W3.js → src-LEXKDSFV.js} +24 -6
- package/dist/chunks/{test-stream-JAJHK44G.js → test-stream-OVGDTXOY.js} +1 -1
- package/dist/cli.js +12910 -12631
- package/models.schema.json +12 -3
- package/package.json +1 -1
- package/dist/chunks/{chunk-3GG342QY.js → chunk-TYCKSYUF.js} +19 -19
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
createReadFileUnderstandingHandler,
|
|
7
7
|
modalityForReadFileUnderstandingKind
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EZZTMDWZ.js";
|
|
9
9
|
import {
|
|
10
10
|
getLogger
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MCR4JYI6.js";
|
|
12
12
|
|
|
13
13
|
// src/capabilities/read-file-understanding.ts
|
|
14
14
|
import * as path10 from "node:path";
|
|
@@ -5102,21 +5102,47 @@ function formatResponsesErrorEvent(event) {
|
|
|
5102
5102
|
|
|
5103
5103
|
// ../../packages/ai/src/providers/responses/responses-remote-failure.ts
|
|
5104
5104
|
var MAX_TEXT = 4096;
|
|
5105
|
-
var transientCodes = /* @__PURE__ */ new Set([
|
|
5106
|
-
|
|
5105
|
+
var transientCodes = /* @__PURE__ */ new Set([
|
|
5106
|
+
"server_error",
|
|
5107
|
+
"rate_limit_exceeded",
|
|
5108
|
+
"slow_down",
|
|
5109
|
+
"rate_limit_error",
|
|
5110
|
+
"server_is_overloaded",
|
|
5111
|
+
"service_unavailable_error",
|
|
5112
|
+
"upstream_stream_error",
|
|
5113
|
+
"sse_abort",
|
|
5114
|
+
"upstream_timeout",
|
|
5115
|
+
"gateway_timeout",
|
|
5116
|
+
"request_timeout"
|
|
5117
|
+
]);
|
|
5118
|
+
var QUOTA_OR_BILLING_FIELDS = /billing|insufficient_quota|insufficient_balance|plan_quota_exhausted|credit_protection|credit|usage_limit|spend_limit|arrearage/;
|
|
5119
|
+
var QUOTA_OR_BILLING_MESSAGE = /billing|insufficient[_ ]quota|plan[_ ]quota[_ ](?:exhausted|exceeded|depleted)|fresh plan quota.*required|credit protection|credits are disabled|exceeded[_ ]current[_ ]quota|billing[_ ]hard[_ ]limit|(?:account|monthly|plan) quota (?:has been |is )?(?:exhausted|exceeded|depleted)|exceeded your current quota|insufficient[_ ](?:credit|balance)|credit balance|spend(?:ing)? limit|\barrearage\b|余额不足/;
|
|
5120
|
+
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
|
+
function extractErrorParts(value, status) {
|
|
5107
5122
|
const root = isRecord(value) ? value : {};
|
|
5108
5123
|
const response = isRecord(root.response) ? root.response : {};
|
|
5109
5124
|
const error = isRecord(root.error) ? root.error : isRecord(response.error) ? response.error : root;
|
|
5110
5125
|
const code = typeof error.code === "string" ? error.code.slice(0, 128).toLowerCase() : "";
|
|
5111
5126
|
const type = typeof error.type === "string" ? error.type.slice(0, 128).toLowerCase() : "";
|
|
5112
|
-
const
|
|
5127
|
+
const rawMessage = typeof value === "string" ? value : typeof error.message === "string" ? error.message : typeof root.message === "string" ? root.message : "";
|
|
5128
|
+
const message = rawMessage.slice(0, MAX_TEXT).toLowerCase();
|
|
5113
5129
|
const httpStatus = status ?? root.status ?? root.statusCode;
|
|
5114
|
-
|
|
5130
|
+
return { root, code, type, fields: `${code} ${type}`, message, httpStatus };
|
|
5131
|
+
}
|
|
5132
|
+
function isQuotaOrBillingFailure(value, status) {
|
|
5133
|
+
const { fields, message } = extractErrorParts(value, status);
|
|
5134
|
+
return QUOTA_OR_BILLING_FIELDS.test(fields) || QUOTA_OR_BILLING_MESSAGE.test(message);
|
|
5135
|
+
}
|
|
5136
|
+
function isStreamLossErrorText(text) {
|
|
5137
|
+
return STREAM_LOSS_ERROR_PATTERN.test(text);
|
|
5138
|
+
}
|
|
5139
|
+
function responsesRemoteFailure(value, status, headers) {
|
|
5140
|
+
const { root, code, type, fields, message, httpStatus } = extractErrorParts(value, status);
|
|
5115
5141
|
let category = "other";
|
|
5116
5142
|
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)) category = "context_overflow";
|
|
5117
|
-
else if (
|
|
5118
|
-
else if (typeof httpStatus === "number" && httpStatus >= 400 && httpStatus < 500 && httpStatus !== 429) category = "other";
|
|
5119
|
-
else if (httpStatus === 429 || typeof httpStatus === "number" && httpStatus >= 500 && httpStatus <= 599 || transientCodes.has(code) || transientCodes.has(type) || /server (?:is )?overloaded|temporarily unavailable|internal server error|rate limit (?:exceeded|reached)/.test(message)) category = "transient";
|
|
5143
|
+
else if (QUOTA_OR_BILLING_FIELDS.test(fields) || QUOTA_OR_BILLING_MESSAGE.test(message)) category = "other";
|
|
5144
|
+
else if (typeof httpStatus === "number" && httpStatus >= 400 && httpStatus < 500 && httpStatus !== 429 && httpStatus !== 408) category = "other";
|
|
5145
|
+
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)) category = "transient";
|
|
5120
5146
|
const retryAfterMs = parseRetryAfter(headers ?? root.headers);
|
|
5121
5147
|
return { category, ...retryAfterMs !== void 0 ? { retryAfterMs } : {} };
|
|
5122
5148
|
}
|
|
@@ -5959,6 +5985,14 @@ function normalizeOpenAIUsage(usage) {
|
|
|
5959
5985
|
totalTokens: Math.max(reportedTotalTokens ?? 0, partitionTotal)
|
|
5960
5986
|
};
|
|
5961
5987
|
}
|
|
5988
|
+
function isUpstreamStreamAbortError(error) {
|
|
5989
|
+
if (!error || typeof error !== "object") return false;
|
|
5990
|
+
const record = error;
|
|
5991
|
+
const code = typeof record.code === "string" ? record.code.toLowerCase() : "";
|
|
5992
|
+
const type = typeof record.type === "string" ? record.type.toLowerCase() : "";
|
|
5993
|
+
const message = typeof record.message === "string" ? record.message : "";
|
|
5994
|
+
return code === "sse_abort" || type === "upstream_stream_error" || /upstream stream aborted|clientpayloaderror/i.test(message);
|
|
5995
|
+
}
|
|
5962
5996
|
function formatOpenAIStreamError(error) {
|
|
5963
5997
|
if (!error || typeof error !== "object") {
|
|
5964
5998
|
return typeof error === "string" ? error : "OpenAI-compatible stream returned an error";
|
|
@@ -6067,6 +6101,13 @@ var streamOpenAICompletions = (model, context, options) => {
|
|
|
6067
6101
|
});
|
|
6068
6102
|
if (!response.ok) {
|
|
6069
6103
|
const errorBody = await response.text().catch(() => "");
|
|
6104
|
+
const parsedBody = parseResponsesErrorBody(errorBody);
|
|
6105
|
+
const remote = responsesRemoteFailure(parsedBody, response.status, response.headers);
|
|
6106
|
+
if (isQuotaOrBillingFailure(parsedBody, response.status)) {
|
|
6107
|
+
output.retryable = false;
|
|
6108
|
+
} else if (remote.category === "transient" || remote.category === "context_overflow") {
|
|
6109
|
+
output.remoteFailure = remote;
|
|
6110
|
+
}
|
|
6070
6111
|
throw new Error(`API error ${response.status}: ${errorBody}`);
|
|
6071
6112
|
}
|
|
6072
6113
|
stream2.push({ type: "start", partial: output });
|
|
@@ -6200,6 +6241,14 @@ var streamOpenAICompletions = (model, context, options) => {
|
|
|
6200
6241
|
}
|
|
6201
6242
|
sseDump.record(chunk);
|
|
6202
6243
|
if (chunk?.error) {
|
|
6244
|
+
if (isUpstreamStreamAbortError(chunk.error)) {
|
|
6245
|
+
output.replayClass = output.content.length > 0 ? "stream_lost_partial" : "stream_lost";
|
|
6246
|
+
} else {
|
|
6247
|
+
const remote = responsesRemoteFailure(chunk);
|
|
6248
|
+
if (remote.category === "transient" || remote.category === "context_overflow") {
|
|
6249
|
+
output.remoteFailure = remote;
|
|
6250
|
+
}
|
|
6251
|
+
}
|
|
6203
6252
|
throw new Error(formatOpenAIStreamError(chunk.error));
|
|
6204
6253
|
}
|
|
6205
6254
|
if (chunk.usage) {
|
|
@@ -6434,8 +6483,17 @@ ${entry.partialArgs}`;
|
|
|
6434
6483
|
if (error instanceof Error && error.message.includes("Request timeout (first byte)")) {
|
|
6435
6484
|
noteOpenAICompatFirstByteTimeout(model);
|
|
6436
6485
|
}
|
|
6437
|
-
|
|
6438
|
-
output.
|
|
6486
|
+
const userAborted = options?.signal?.aborted === true;
|
|
6487
|
+
output.stopReason = userAborted ? "aborted" : "error";
|
|
6488
|
+
if (userAborted) {
|
|
6489
|
+
delete output.remoteFailure;
|
|
6490
|
+
delete output.replayClass;
|
|
6491
|
+
delete output.replayEligible;
|
|
6492
|
+
output.retryable = false;
|
|
6493
|
+
output.errorMessage = "Request was aborted";
|
|
6494
|
+
} else {
|
|
6495
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
6496
|
+
}
|
|
6439
6497
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
6440
6498
|
stream2.end();
|
|
6441
6499
|
} finally {
|
|
@@ -6748,6 +6806,7 @@ var streamAnthropic = (model, context, options) => {
|
|
|
6748
6806
|
stopReason: "stop",
|
|
6749
6807
|
timestamp: Date.now()
|
|
6750
6808
|
};
|
|
6809
|
+
let streamStarted = false;
|
|
6751
6810
|
try {
|
|
6752
6811
|
const apiKey = options?.apiKey ?? getEnvApiKey(model.provider, model.apiKeyEnv) ?? "";
|
|
6753
6812
|
const cacheCapability = getModelCacheCapability(model);
|
|
@@ -6761,7 +6820,11 @@ var streamAnthropic = (model, context, options) => {
|
|
|
6761
6820
|
apiKey,
|
|
6762
6821
|
baseURL: model.baseUrl,
|
|
6763
6822
|
dangerouslyAllowBrowser: true,
|
|
6764
|
-
defaultHeaders: headers
|
|
6823
|
+
defaultHeaders: headers,
|
|
6824
|
+
// Host/framework recovery owns retries so terminal quota/billing
|
|
6825
|
+
// failures and single-attempt budgets are never silently replayed
|
|
6826
|
+
// inside the SDK before structured classification runs.
|
|
6827
|
+
maxRetries: 0
|
|
6765
6828
|
});
|
|
6766
6829
|
const params = {
|
|
6767
6830
|
model: model.id,
|
|
@@ -6821,6 +6884,7 @@ var streamAnthropic = (model, context, options) => {
|
|
|
6821
6884
|
{ ...params, stream: true },
|
|
6822
6885
|
{ signal: options?.signal }
|
|
6823
6886
|
);
|
|
6887
|
+
streamStarted = true;
|
|
6824
6888
|
stream2.push({ type: "start", partial: output });
|
|
6825
6889
|
const blocks = output.content;
|
|
6826
6890
|
let hasReportedInputUsage = false;
|
|
@@ -6945,8 +7009,35 @@ var streamAnthropic = (model, context, options) => {
|
|
|
6945
7009
|
} catch (error) {
|
|
6946
7010
|
logEmptyAssistantContentError(error, model, options);
|
|
6947
7011
|
for (const block of output.content) delete block.index;
|
|
6948
|
-
|
|
6949
|
-
output.
|
|
7012
|
+
const userAborted = options?.signal?.aborted === true;
|
|
7013
|
+
output.stopReason = userAborted ? "aborted" : "error";
|
|
7014
|
+
if (userAborted) {
|
|
7015
|
+
delete output.remoteFailure;
|
|
7016
|
+
delete output.replayClass;
|
|
7017
|
+
delete output.replayEligible;
|
|
7018
|
+
output.retryable = false;
|
|
7019
|
+
output.errorMessage = "Request was aborted";
|
|
7020
|
+
} else {
|
|
7021
|
+
const errMsg = error instanceof Error ? error.message : JSON.stringify(error);
|
|
7022
|
+
output.errorMessage = errMsg;
|
|
7023
|
+
const errObj = error && typeof error === "object" ? error : void 0;
|
|
7024
|
+
const status = typeof errObj?.status === "number" ? errObj.status : typeof errObj?.statusCode === "number" ? errObj.statusCode : void 0;
|
|
7025
|
+
if (typeof status === "number" && status >= 400) {
|
|
7026
|
+
const payload = errObj?.error ?? error;
|
|
7027
|
+
if (isQuotaOrBillingFailure(payload, status)) {
|
|
7028
|
+
output.retryable = false;
|
|
7029
|
+
} else {
|
|
7030
|
+
const remote = responsesRemoteFailure(payload, status, errObj?.headers);
|
|
7031
|
+
if (remote.category === "transient" || remote.category === "context_overflow") {
|
|
7032
|
+
output.remoteFailure = remote;
|
|
7033
|
+
}
|
|
7034
|
+
}
|
|
7035
|
+
} else if (isQuotaOrBillingFailure(error)) {
|
|
7036
|
+
output.retryable = false;
|
|
7037
|
+
} else if (streamStarted && isStreamLossErrorText(errMsg)) {
|
|
7038
|
+
output.replayClass = output.content.length > 0 ? "stream_lost_partial" : "stream_lost";
|
|
7039
|
+
}
|
|
7040
|
+
}
|
|
6950
7041
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
6951
7042
|
stream2.end();
|
|
6952
7043
|
}
|