@tryarcanist/cli 0.1.15 → 0.1.17

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.
Files changed (2) hide show
  1. package/dist/index.js +78 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -425,6 +425,11 @@ async function messageCommand(sessionId, promptArg, options = {}, command) {
425
425
  console.log(`Message sent to session ${sessionId}.`);
426
426
  }
427
427
 
428
+ // ../../shared/utils/type-guards.ts
429
+ function isRecord(value) {
430
+ return !!value && typeof value === "object" && !Array.isArray(value);
431
+ }
432
+
428
433
  // ../../shared/transcript/projector.ts
429
434
  var DUPLICATE_TEXT_DELTA_MIN_CHARS = 24;
430
435
  var SUBAGENT_EVENT_TYPES = /* @__PURE__ */ new Set(["subagent_start", "subagent_complete", "subagent_tool_call", "subagent_text"]);
@@ -447,9 +452,6 @@ function streamableKey(type, streamId) {
447
452
  function resolveSegmentId(streamId, segmentOrdinal) {
448
453
  return segmentOrdinal === 0 ? streamId : `${streamId}#${segmentOrdinal}`;
449
454
  }
450
- function isRecord(value) {
451
- return !!value && typeof value === "object" && !Array.isArray(value);
452
- }
453
455
  function resolveEventId(data, prefix, index) {
454
456
  return typeof data?.id === "string" ? data.id : `${prefix}-${index}`;
455
457
  }
@@ -828,6 +830,72 @@ function extractSubagentInfo(raw) {
828
830
  return { names, activity, toolToChildSessions, subagentUsage };
829
831
  }
830
832
 
833
+ // ../../shared/types/error-codes.ts
834
+ var ERROR_CODES = [
835
+ "auth",
836
+ "handled_automatically",
837
+ "output_length",
838
+ "context_overflow",
839
+ "aborted",
840
+ "rate_limit",
841
+ "api_error",
842
+ "config_error",
843
+ "doom_loop",
844
+ "tool_limit",
845
+ "failed_edits",
846
+ "empty_completion",
847
+ "followup_not_started",
848
+ "stale_prompt",
849
+ "max_duration_exceeded",
850
+ "spawn_timeout",
851
+ "spawn_preconnect",
852
+ "sandbox_terminated",
853
+ "sandbox_disconnected",
854
+ "sandbox_callback",
855
+ "opencode_startup_timeout",
856
+ "opencode_prompt_dispatch_timeout",
857
+ "opencode_unrecoverable",
858
+ "unknown"
859
+ ];
860
+ var ERROR_CODE_SET = new Set(ERROR_CODES);
861
+ var ERROR_CODE_LABELS = {
862
+ auth: "Authentication failed",
863
+ handled_automatically: "Handled automatically",
864
+ output_length: "Output was too long",
865
+ context_overflow: "Context window exceeded",
866
+ aborted: "Stopped by user",
867
+ rate_limit: "Provider rate limit",
868
+ api_error: "Provider API error",
869
+ config_error: "Configuration error",
870
+ doom_loop: "Repeated failure loop",
871
+ tool_limit: "Tool limit reached",
872
+ failed_edits: "Edit failure",
873
+ empty_completion: "Empty completion",
874
+ followup_not_started: "Follow-up did not start",
875
+ stale_prompt: "Prompt became inactive",
876
+ max_duration_exceeded: "Prompt exceeded maximum duration",
877
+ spawn_timeout: "Sandbox spawn timed out",
878
+ spawn_preconnect: "Sandbox failed before connecting",
879
+ sandbox_terminated: "Sandbox terminated",
880
+ sandbox_disconnected: "Sandbox disconnected",
881
+ sandbox_callback: "Sandbox callback failed",
882
+ opencode_startup_timeout: "OpenCode startup timed out",
883
+ opencode_prompt_dispatch_timeout: "OpenCode prompt dispatch timed out",
884
+ opencode_unrecoverable: "OpenCode unrecoverable failure",
885
+ unknown: "Unknown failure"
886
+ };
887
+ function isErrorCode(value) {
888
+ return typeof value === "string" && ERROR_CODE_SET.has(value);
889
+ }
890
+ function errorCodeLabel(value) {
891
+ return isErrorCode(value) ? ERROR_CODE_LABELS[value] : ERROR_CODE_LABELS.unknown;
892
+ }
893
+ function formatSessionErrorMessage(error, code) {
894
+ if (!code || !isErrorCode(code) || code === "unknown") return error;
895
+ const label = errorCodeLabel(code);
896
+ return error.includes(label) ? error : `${label}: ${error}`;
897
+ }
898
+
831
899
  // src/utils/session-output.ts
832
900
  function formatDate(value) {
833
901
  const date = new Date(value);
@@ -897,7 +965,7 @@ ${event.answer ? `**Answer:** ${event.answer}
897
965
  return `*[switched to branch \`${event.branch}\`]*
898
966
  `;
899
967
  case "session_error":
900
- return `**Error:** ${event.error}
968
+ return `**Error:** ${formatSessionErrorMessage(event.error, event.code)}
901
969
  `;
902
970
  case "raw_opencode":
903
971
  return "";
@@ -1087,7 +1155,7 @@ function renderWatchEvent(event, state) {
1087
1155
  case "branch_changed":
1088
1156
  return { kind: "line", line: `[branch] ${String(data.branch ?? "")}` };
1089
1157
  case "session_error":
1090
- return { kind: "line", line: `[error] ${String(data.error ?? "Unknown error")}` };
1158
+ return { kind: "line", line: `[error] ${formatSessionErrorMessage(String(data.error ?? "Unknown error"), typeof data.code === "string" ? data.code : null)}` };
1091
1159
  case "pr_created":
1092
1160
  case "pr_updated":
1093
1161
  return { kind: "line", line: `[pr] ${String(data.prUrl ?? "")}` };
@@ -1106,15 +1174,17 @@ function renderWatchEvent(event, state) {
1106
1174
  }
1107
1175
  }
1108
1176
 
1177
+ // ../../shared/utils/timing.ts
1178
+ function sleep(ms) {
1179
+ return new Promise((resolve) => setTimeout(resolve, ms));
1180
+ }
1181
+
1109
1182
  // src/constants/watch.ts
1110
1183
  var DEFAULT_WATCH_POLL_INTERVAL_MS = 1e3;
1111
1184
  var WATCH_REPLAY_PAGE_SIZE = 200;
1112
1185
  var WATCH_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["idle", "archived"]);
1113
1186
 
1114
1187
  // src/commands/watch.ts
1115
- function sleep(ms) {
1116
- return new Promise((resolve) => setTimeout(resolve, ms));
1117
- }
1118
1188
  function parsePollInterval(raw) {
1119
1189
  if (!raw) return DEFAULT_WATCH_POLL_INTERVAL_MS;
1120
1190
  if (!/^\d+$/.test(raw)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {