replicas-engine 0.1.725 → 0.1.726

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.
@@ -658,6 +658,11 @@ var CREDENTIAL_TYPE = {
658
658
  OPENROUTER_API_KEY: "openrouter_api_key",
659
659
  AI_GATEWAY_API_KEY: "ai_gateway_api_key"
660
660
  };
661
+ var INFERENCE_PROVIDER_LABELS = {
662
+ [CREDENTIAL_METHOD.OPENCODE_GO]: "OpenCode Go",
663
+ [CREDENTIAL_METHOD.ASTER]: "Aster",
664
+ [CREDENTIAL_METHOD.OPENROUTER]: "OpenRouter"
665
+ };
661
666
  var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
662
667
  [AGENT.CLAUDE]: [
663
668
  { method: CREDENTIAL_METHOD.OAUTH, credentialType: CREDENTIAL_TYPE.CLAUDE_OAUTH },
@@ -5147,6 +5152,27 @@ function parseFxEvents(events) {
5147
5152
  return parseAcpEvents(events, "fx");
5148
5153
  }
5149
5154
 
5155
+ // ../shared/src/display-message/parsers/inference-error.ts
5156
+ var TRANSIENT_HTTP_STATUSES = [408, 429, 500, 502, 503, 504, 529];
5157
+ var SERVER_ERROR_TEXT_PATTERN = /internal ?server ?error|server ?error|service unavailable|bad gateway|gateway timeout|overloaded|too many requests/i;
5158
+ var INFERENCE_ERROR_DETAIL_MAX = 600;
5159
+ var INFERENCE_ERROR_RETRY_HINT = "This is usually temporary \u2014 retry the message.";
5160
+ function formatInferenceError(message, context = {}) {
5161
+ const label = context.provider ? INFERENCE_PROVIDER_LABELS[context.provider] ?? context.provider : null;
5162
+ const source = label ? `${label}${context.model ? ` (${context.model})` : ""} request failed${typeof context.status === "number" ? ` with HTTP ${context.status}` : ""}` : null;
5163
+ let body = source ? message ? `${source}: ${message}` : `${source}.` : message;
5164
+ const detail = context.detail?.trim();
5165
+ if (detail && !body.includes(detail)) {
5166
+ body = `${body}
5167
+ ${detail.length > INFERENCE_ERROR_DETAIL_MAX ? `${detail.slice(0, INFERENCE_ERROR_DETAIL_MAX)}\u2026` : detail}`;
5168
+ }
5169
+ const sniffText = `${message}
5170
+ ${detail ?? ""}`;
5171
+ 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));
5172
+ return transient ? `${body}
5173
+ ${INFERENCE_ERROR_RETRY_HINT}` : body;
5174
+ }
5175
+
5150
5176
  // ../shared/src/display-message/parsers/opencode-parser.ts
5151
5177
  function timestampFromMs(value, fallback) {
5152
5178
  return typeof value === "number" && Number.isFinite(value) ? new Date(value).toISOString() : fallback;
@@ -5160,9 +5186,15 @@ function toolStatus(status) {
5160
5186
  function assistantError(info) {
5161
5187
  if (!isRecord(info) || !isRecord(info.error)) return null;
5162
5188
  const data = isRecord(info.error.data) ? info.error.data : null;
5163
- if (typeof data?.message === "string") return data.message;
5164
- if (typeof info.error.message === "string") return info.error.message;
5165
- return stringifyDisplayValue(info.error) ?? "Opencode run failed";
5189
+ const message = typeof data?.message === "string" ? data.message : typeof info.error.message === "string" ? info.error.message : stringifyDisplayValue(info.error) ?? "Opencode run failed";
5190
+ if (info.error.name === "MessageAbortedError") return message;
5191
+ return formatInferenceError(message, {
5192
+ ...typeof info.providerID === "string" ? { provider: info.providerID } : {},
5193
+ ...typeof info.modelID === "string" ? { model: info.modelID } : {},
5194
+ ...typeof data?.statusCode === "number" ? { status: data.statusCode } : {},
5195
+ ...typeof data?.isRetryable === "boolean" ? { retryable: data.isRetryable } : {},
5196
+ ...typeof data?.responseBody === "string" ? { detail: data.responseBody } : {}
5197
+ });
5166
5198
  }
5167
5199
  function parseOpencodeEvents(events) {
5168
5200
  const messages = [];
@@ -5197,7 +5229,9 @@ function parseOpencodeEvents(events) {
5197
5229
  messages.push({
5198
5230
  id: `opencode-${event.type}-${event.timestamp}`,
5199
5231
  type: "error",
5200
- message,
5232
+ message: formatInferenceError(message, {
5233
+ ...typeof event.payload.status === "number" ? { status: event.payload.status } : {}
5234
+ }),
5201
5235
  timestamp: event.timestamp
5202
5236
  });
5203
5237
  continue;
@@ -5291,7 +5325,11 @@ function toolStatus2(value) {
5291
5325
  }
5292
5326
  function assistantErrorMessage(value) {
5293
5327
  if (!isRecord(value) || value.role !== "assistant" || value.stopReason !== "error") return null;
5294
- return typeof value.errorMessage === "string" && value.errorMessage ? value.errorMessage : "Pi run failed";
5328
+ const message = typeof value.errorMessage === "string" && value.errorMessage ? value.errorMessage : "Pi run failed";
5329
+ return formatInferenceError(message, {
5330
+ ...typeof value.provider === "string" ? { provider: value.provider } : {},
5331
+ ...typeof value.model === "string" ? { model: value.model } : {}
5332
+ });
5295
5333
  }
5296
5334
  function parsePiEvents(events) {
5297
5335
  const messages = [];
@@ -5313,7 +5351,7 @@ function parsePiEvents(events) {
5313
5351
  continue;
5314
5352
  }
5315
5353
  if (event.type === "pi-error") {
5316
- messages.push({ id: `pi-error-${event.timestamp}-${messages.length}`, type: "error", message: String(event.payload.message ?? "Pi run failed"), timestamp: event.timestamp });
5354
+ messages.push({ id: `pi-error-${event.timestamp}-${messages.length}`, type: "error", message: formatInferenceError(String(event.payload.message ?? "Pi run failed")), timestamp: event.timestamp });
5317
5355
  continue;
5318
5356
  }
5319
5357
  if (event.type === "pi-message_end") {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  mayCreatePullRequest
4
- } from "./chunk-FL2J2SZW.js";
4
+ } from "./chunk-DFBYJH6I.js";
5
5
 
6
6
  // src/services/post-tool-pr-notifier.ts
7
7
  async function notifyPostToolUse(toolName, toolInput) {
@@ -12,7 +12,7 @@ import {
12
12
  isValidAgentProvider,
13
13
  parsePosixEnvFile,
14
14
  readReplicasRuntimeEnv
15
- } from "./chunk-FL2J2SZW.js";
15
+ } from "./chunk-DFBYJH6I.js";
16
16
 
17
17
  // src/engine-env.ts
18
18
  import { readFileSync as readFileSync2 } from "fs";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  HOOK_EXEC_MAX_BUFFER_BYTES,
4
4
  isVersionBelow
5
- } from "./chunk-FL2J2SZW.js";
5
+ } from "./chunk-DFBYJH6I.js";
6
6
 
7
7
  // src/utils/presigned-upload.ts
8
8
  import { createReadStream } from "fs";
@@ -267,7 +267,7 @@ var DEFAULT_CODEX_ARGS = [
267
267
  var MIN_CODEX_CLI_VERSION = "0.144.6";
268
268
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
269
269
  var codexCliVersionEnsured = null;
270
- var ENGINE_PACKAGE_VERSION = "0.1.725";
270
+ var ENGINE_PACKAGE_VERSION = "0.1.726";
271
271
  var INITIALIZE_METHOD = "initialize";
272
272
  var INITIALIZED_NOTIFICATION = "initialized";
273
273
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  evaluateCommandProtection
4
- } from "./chunk-WDZ5RUOJ.js";
4
+ } from "./chunk-L3TAK4RD.js";
5
5
  import {
6
6
  isRecord
7
7
  } from "./chunk-2RB7SIP3.js";
8
- import "./chunk-FL2J2SZW.js";
8
+ import "./chunk-DFBYJH6I.js";
9
9
 
10
10
  // src/command-protection-hook.ts
11
11
  var provider = process.argv[2];
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  evaluateCommandProtection
4
- } from "./chunk-WDZ5RUOJ.js";
4
+ } from "./chunk-L3TAK4RD.js";
5
5
  import {
6
6
  notifyPostToolUse
7
- } from "./chunk-YWSBURLX.js";
7
+ } from "./chunk-KZODFP3F.js";
8
8
  import "./chunk-2RB7SIP3.js";
9
- import "./chunk-FL2J2SZW.js";
9
+ import "./chunk-DFBYJH6I.js";
10
10
 
11
11
  // src/deepseek-command-protection-plugin.ts
12
12
  function replicasCommandProtection(context) {
@@ -4,12 +4,12 @@ import {
4
4
  buildCodexAgentEnv,
5
5
  putPresignedFile,
6
6
  recoverCompletedTurn
7
- } from "./chunk-N26NDLI2.js";
7
+ } from "./chunk-QL2YWG6O.js";
8
8
  import {
9
9
  AGENT,
10
10
  getMemoryOutputSafetyViolation,
11
11
  headlessAgentRequestSchema
12
- } from "./chunk-FL2J2SZW.js";
12
+ } from "./chunk-DFBYJH6I.js";
13
13
 
14
14
  // src/headless-agent.ts
15
15
  import { createHash } from "crypto";
package/dist/src/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  monolithService,
9
9
  reportCommandProtectionBlock,
10
10
  setAgentCredentialSnapshot
11
- } from "./chunk-WDZ5RUOJ.js";
11
+ } from "./chunk-L3TAK4RD.js";
12
12
  import {
13
13
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
14
14
  AGENT_MESSAGE_DELTA_METHOD,
@@ -35,7 +35,7 @@ import {
35
35
  execFileAsync,
36
36
  putPresignedFile,
37
37
  recoverCompletedTurn
38
- } from "./chunk-N26NDLI2.js";
38
+ } from "./chunk-QL2YWG6O.js";
39
39
  import {
40
40
  isRecord as isRecord2
41
41
  } from "./chunk-2RB7SIP3.js";
@@ -216,7 +216,7 @@ import {
216
216
  shellQuotePosix,
217
217
  stripAgentDiagnosticErrors,
218
218
  withTimeout
219
- } from "./chunk-FL2J2SZW.js";
219
+ } from "./chunk-DFBYJH6I.js";
220
220
 
221
221
  // src/index.ts
222
222
  import { serve } from "@hono/node-server";
@@ -9637,9 +9637,12 @@ function opencodeErrorMessage(error) {
9637
9637
  function opencodeErrorPayload(error) {
9638
9638
  const message = opencodeErrorMessage(error) ?? String(error);
9639
9639
  const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : void 0;
9640
+ const cause = error instanceof Error && isRecord2(error.cause) ? error.cause : null;
9641
+ const status = typeof cause?.status === "number" ? cause.status : void 0;
9640
9642
  return {
9641
9643
  message: code === "ENOENT" ? `Failed to start Opencode server binary (${message}).` : message,
9642
- ...code ? { code } : {}
9644
+ ...code ? { code } : {},
9645
+ ...status !== void 0 ? { status } : {}
9643
9646
  };
9644
9647
  }
9645
9648
  function opencodeFetch(input, init) {
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  notifyPostToolUse
4
- } from "./chunk-YWSBURLX.js";
4
+ } from "./chunk-KZODFP3F.js";
5
5
  import {
6
6
  isRecord
7
7
  } from "./chunk-2RB7SIP3.js";
8
- import "./chunk-FL2J2SZW.js";
8
+ import "./chunk-DFBYJH6I.js";
9
9
 
10
10
  // src/post-tool-pr-hook.ts
11
11
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.725",
3
+ "version": "0.1.726",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",