replicas-cli 0.2.595 → 0.2.596
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 +83 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7789,6 +7789,11 @@ var CREDENTIAL_TYPE = {
|
|
|
7789
7789
|
OPENROUTER_API_KEY: "openrouter_api_key",
|
|
7790
7790
|
AI_GATEWAY_API_KEY: "ai_gateway_api_key"
|
|
7791
7791
|
};
|
|
7792
|
+
var INFERENCE_PROVIDER_LABELS = {
|
|
7793
|
+
[CREDENTIAL_METHOD.OPENCODE_GO]: "OpenCode Go",
|
|
7794
|
+
[CREDENTIAL_METHOD.ASTER]: "Aster",
|
|
7795
|
+
[CREDENTIAL_METHOD.OPENROUTER]: "OpenRouter"
|
|
7796
|
+
};
|
|
7792
7797
|
var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
|
|
7793
7798
|
[AGENT.CLAUDE]: [
|
|
7794
7799
|
{ method: CREDENTIAL_METHOD.OAUTH, credentialType: CREDENTIAL_TYPE.CLAUDE_OAUTH },
|
|
@@ -24508,8 +24513,46 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
|
|
|
24508
24513
|
}))
|
|
24509
24514
|
});
|
|
24510
24515
|
|
|
24516
|
+
// ../shared/src/errors.ts
|
|
24517
|
+
var TRANSIENT_NETWORK_ERROR_PATTERNS = [
|
|
24518
|
+
/socket connection was closed unexpectedly/,
|
|
24519
|
+
/fetch failed/,
|
|
24520
|
+
/network error/,
|
|
24521
|
+
/network request failed/,
|
|
24522
|
+
/econnreset/,
|
|
24523
|
+
/econnrefused/,
|
|
24524
|
+
/etimedout/,
|
|
24525
|
+
/enotfound/,
|
|
24526
|
+
/eai_again/,
|
|
24527
|
+
/und_err_socket/,
|
|
24528
|
+
/und_err_connect_timeout/,
|
|
24529
|
+
/headers timeout/,
|
|
24530
|
+
/body timeout/,
|
|
24531
|
+
/connection reset/,
|
|
24532
|
+
/connection closed/,
|
|
24533
|
+
/closed unexpectedly/
|
|
24534
|
+
];
|
|
24535
|
+
var HTTP_CONTEXT_PATTERN = /(api error|request|response|status|http)/;
|
|
24536
|
+
var HTTP_STATUS_PATTERN = /(^|[^0-9])([1-5][0-9]{2})(?=$|[^0-9])/g;
|
|
24537
|
+
function isTransientErrorText(text, options = {}) {
|
|
24538
|
+
const normalized = text.toLowerCase();
|
|
24539
|
+
if (!normalized) return false;
|
|
24540
|
+
if (TRANSIENT_NETWORK_ERROR_PATTERNS.some((pattern) => pattern.test(normalized))) return true;
|
|
24541
|
+
if (options.includeRateLimit && /rate limit/.test(normalized)) return true;
|
|
24542
|
+
if (options.extraPatterns?.some((pattern) => pattern.test(normalized))) return true;
|
|
24543
|
+
const httpStatuses = new Set(options.httpStatuses ?? []);
|
|
24544
|
+
const httpStatusClasses = new Set(options.httpStatusClasses ?? []);
|
|
24545
|
+
if (httpStatuses.size === 0 && httpStatusClasses.size === 0) return false;
|
|
24546
|
+
if (options.requireHttpContext !== false && !HTTP_CONTEXT_PATTERN.test(normalized)) return false;
|
|
24547
|
+
for (const match of normalized.matchAll(HTTP_STATUS_PATTERN)) {
|
|
24548
|
+
const status = Number(match[2]);
|
|
24549
|
+
if (httpStatuses.has(status) || httpStatusClasses.has(Math.floor(status / 100))) return true;
|
|
24550
|
+
}
|
|
24551
|
+
return false;
|
|
24552
|
+
}
|
|
24553
|
+
|
|
24511
24554
|
// ../shared/src/cli-version.ts
|
|
24512
|
-
var CLI_VERSION = "0.2.
|
|
24555
|
+
var CLI_VERSION = "0.2.596";
|
|
24513
24556
|
|
|
24514
24557
|
// ../shared/src/version.ts
|
|
24515
24558
|
function compareVersions(v1, v2) {
|
|
@@ -26063,6 +26106,27 @@ function parseFxEvents(events) {
|
|
|
26063
26106
|
return parseAcpEvents(events, "fx");
|
|
26064
26107
|
}
|
|
26065
26108
|
|
|
26109
|
+
// ../shared/src/display-message/parsers/inference-error.ts
|
|
26110
|
+
var TRANSIENT_HTTP_STATUSES = [408, 429, 500, 502, 503, 504, 529];
|
|
26111
|
+
var SERVER_ERROR_TEXT_PATTERN = /internal ?server ?error|server ?error|service unavailable|bad gateway|gateway timeout|overloaded|too many requests/i;
|
|
26112
|
+
var INFERENCE_ERROR_DETAIL_MAX = 600;
|
|
26113
|
+
var INFERENCE_ERROR_RETRY_HINT = "This is usually temporary \u2014 retry the message.";
|
|
26114
|
+
function formatInferenceError(message, context = {}) {
|
|
26115
|
+
const label = context.provider ? INFERENCE_PROVIDER_LABELS[context.provider] ?? context.provider : null;
|
|
26116
|
+
const source = label ? `${label}${context.model ? ` (${context.model})` : ""} request failed${typeof context.status === "number" ? ` with HTTP ${context.status}` : ""}` : null;
|
|
26117
|
+
let body = source ? message ? `${source}: ${message}` : `${source}.` : message;
|
|
26118
|
+
const detail = context.detail?.trim();
|
|
26119
|
+
if (detail && !body.includes(detail)) {
|
|
26120
|
+
body = `${body}
|
|
26121
|
+
${detail.length > INFERENCE_ERROR_DETAIL_MAX ? `${detail.slice(0, INFERENCE_ERROR_DETAIL_MAX)}\u2026` : detail}`;
|
|
26122
|
+
}
|
|
26123
|
+
const sniffText = `${message}
|
|
26124
|
+
${detail ?? ""}`;
|
|
26125
|
+
const transient = context.retryable ?? (typeof context.status === "number" ? TRANSIENT_HTTP_STATUSES.includes(context.status) || context.status >= 500 : isTransientErrorText(sniffText, { httpStatuses: TRANSIENT_HTTP_STATUSES, includeRateLimit: true }) || SERVER_ERROR_TEXT_PATTERN.test(sniffText));
|
|
26126
|
+
return transient ? `${body}
|
|
26127
|
+
${INFERENCE_ERROR_RETRY_HINT}` : body;
|
|
26128
|
+
}
|
|
26129
|
+
|
|
26066
26130
|
// ../shared/src/display-message/parsers/opencode-parser.ts
|
|
26067
26131
|
function timestampFromMs(value, fallback) {
|
|
26068
26132
|
return typeof value === "number" && Number.isFinite(value) ? new Date(value).toISOString() : fallback;
|
|
@@ -26076,9 +26140,15 @@ function toolStatus(status) {
|
|
|
26076
26140
|
function assistantError(info) {
|
|
26077
26141
|
if (!isRecord(info) || !isRecord(info.error)) return null;
|
|
26078
26142
|
const data = isRecord(info.error.data) ? info.error.data : null;
|
|
26079
|
-
|
|
26080
|
-
if (
|
|
26081
|
-
return
|
|
26143
|
+
const message = typeof data?.message === "string" ? data.message : typeof info.error.message === "string" ? info.error.message : stringifyDisplayValue(info.error) ?? "Opencode run failed";
|
|
26144
|
+
if (info.error.name === "MessageAbortedError") return message;
|
|
26145
|
+
return formatInferenceError(message, {
|
|
26146
|
+
...typeof info.providerID === "string" ? { provider: info.providerID } : {},
|
|
26147
|
+
...typeof info.modelID === "string" ? { model: info.modelID } : {},
|
|
26148
|
+
...typeof data?.statusCode === "number" ? { status: data.statusCode } : {},
|
|
26149
|
+
...typeof data?.isRetryable === "boolean" ? { retryable: data.isRetryable } : {},
|
|
26150
|
+
...typeof data?.responseBody === "string" ? { detail: data.responseBody } : {}
|
|
26151
|
+
});
|
|
26082
26152
|
}
|
|
26083
26153
|
function parseOpencodeEvents(events) {
|
|
26084
26154
|
const messages = [];
|
|
@@ -26113,7 +26183,9 @@ function parseOpencodeEvents(events) {
|
|
|
26113
26183
|
messages.push({
|
|
26114
26184
|
id: `opencode-${event.type}-${event.timestamp}`,
|
|
26115
26185
|
type: "error",
|
|
26116
|
-
message,
|
|
26186
|
+
message: formatInferenceError(message, {
|
|
26187
|
+
...typeof event.payload.status === "number" ? { status: event.payload.status } : {}
|
|
26188
|
+
}),
|
|
26117
26189
|
timestamp: event.timestamp
|
|
26118
26190
|
});
|
|
26119
26191
|
continue;
|
|
@@ -26207,7 +26279,11 @@ function toolStatus2(value) {
|
|
|
26207
26279
|
}
|
|
26208
26280
|
function assistantErrorMessage(value) {
|
|
26209
26281
|
if (!isRecord(value) || value.role !== "assistant" || value.stopReason !== "error") return null;
|
|
26210
|
-
|
|
26282
|
+
const message = typeof value.errorMessage === "string" && value.errorMessage ? value.errorMessage : "Pi run failed";
|
|
26283
|
+
return formatInferenceError(message, {
|
|
26284
|
+
...typeof value.provider === "string" ? { provider: value.provider } : {},
|
|
26285
|
+
...typeof value.model === "string" ? { model: value.model } : {}
|
|
26286
|
+
});
|
|
26211
26287
|
}
|
|
26212
26288
|
function parsePiEvents(events) {
|
|
26213
26289
|
const messages = [];
|
|
@@ -26229,7 +26305,7 @@ function parsePiEvents(events) {
|
|
|
26229
26305
|
continue;
|
|
26230
26306
|
}
|
|
26231
26307
|
if (event.type === "pi-error") {
|
|
26232
|
-
messages.push({ id: `pi-error-${event.timestamp}-${messages.length}`, type: "error", message: String(event.payload.message ?? "Pi run failed"), timestamp: event.timestamp });
|
|
26308
|
+
messages.push({ id: `pi-error-${event.timestamp}-${messages.length}`, type: "error", message: formatInferenceError(String(event.payload.message ?? "Pi run failed")), timestamp: event.timestamp });
|
|
26233
26309
|
continue;
|
|
26234
26310
|
}
|
|
26235
26311
|
if (event.type === "pi-message_end") {
|