@tryarcanist/cli 0.1.195 → 0.1.197
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.js +81 -51
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,6 +17,36 @@ function normalizeBaseUrl(url) {
|
|
|
17
17
|
return url.replace(/\/+$/, "");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// src/utils/api-error.ts
|
|
21
|
+
function parseApiErrorBody(body) {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(body);
|
|
24
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
25
|
+
const record = parsed;
|
|
26
|
+
const topLevelMessage = typeof record.message === "string" && record.message ? record.message : void 0;
|
|
27
|
+
if (typeof record.error === "string" && record.error) {
|
|
28
|
+
return {
|
|
29
|
+
serverCode: typeof record.code === "string" && record.code ? record.code : record.error,
|
|
30
|
+
rawError: record.error,
|
|
31
|
+
message: topLevelMessage ?? record.error
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (record.error && typeof record.error === "object") {
|
|
35
|
+
const error = record.error;
|
|
36
|
+
const message = typeof error.message === "string" && error.message ? error.message : topLevelMessage;
|
|
37
|
+
const serverCode = typeof error.code === "string" && error.code ? error.code : void 0;
|
|
38
|
+
return message || serverCode ? {
|
|
39
|
+
...message ? { message } : {},
|
|
40
|
+
...serverCode ? { serverCode } : {},
|
|
41
|
+
...serverCode ? { rawError: serverCode } : {}
|
|
42
|
+
} : null;
|
|
43
|
+
}
|
|
44
|
+
return topLevelMessage ? { message: topLevelMessage } : null;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
20
50
|
// src/errors.ts
|
|
21
51
|
var EXIT_CODE_INTERRUPTED = 130;
|
|
22
52
|
var CliError = class extends Error {
|
|
@@ -82,33 +112,6 @@ function messageForApiError(status, body, parsed = parseApiErrorBody(body)) {
|
|
|
82
112
|
if (parsed?.serverCode) return parsed.serverCode;
|
|
83
113
|
return body ? `API error ${status}: ${body}` : `API error ${status}`;
|
|
84
114
|
}
|
|
85
|
-
function parseApiErrorBody(body) {
|
|
86
|
-
try {
|
|
87
|
-
const parsed = JSON.parse(body);
|
|
88
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
89
|
-
const error = parsed.error;
|
|
90
|
-
if (typeof error === "string" && error.length > 0) {
|
|
91
|
-
const message2 = parsed.message;
|
|
92
|
-
const code = parsed.code;
|
|
93
|
-
return {
|
|
94
|
-
serverCode: typeof code === "string" && code ? code : error,
|
|
95
|
-
...typeof message2 === "string" && message2 ? { message: message2 } : { message: error }
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
if (error && typeof error === "object") {
|
|
99
|
-
const code = error.code;
|
|
100
|
-
const message2 = error.message;
|
|
101
|
-
return {
|
|
102
|
-
...typeof message2 === "string" && message2 ? { message: message2 } : {},
|
|
103
|
-
...typeof code === "string" && code ? { serverCode: code } : {}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const message = parsed.message;
|
|
107
|
-
return typeof message === "string" && message.length > 0 ? { message } : null;
|
|
108
|
-
} catch {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
115
|
function hintForHttpStatus(status, resourceNoun) {
|
|
113
116
|
if (status === 401 || status === 403) return "Run `arcanist auth login` or set `ARCANIST_TOKEN`.";
|
|
114
117
|
if (status === 404) {
|
|
@@ -645,6 +648,7 @@ var OpenAIModel = {
|
|
|
645
648
|
var AnthropicModel = {
|
|
646
649
|
Opus48: "claude-opus-4-8",
|
|
647
650
|
Sonnet46: "claude-sonnet-4-6",
|
|
651
|
+
Sonnet5: "claude-sonnet-5",
|
|
648
652
|
Fable5: "claude-fable-5"
|
|
649
653
|
};
|
|
650
654
|
var BasetenModel = {
|
|
@@ -655,6 +659,20 @@ var MODEL_PROVIDERS_SET = /* @__PURE__ */ new Set([
|
|
|
655
659
|
"anthropic",
|
|
656
660
|
"baseten"
|
|
657
661
|
]);
|
|
662
|
+
var BACKEND_DESKTOP_IMAGE_FEEDBACK_CONFIGS = {
|
|
663
|
+
[CODEX_AGENT_RUNTIME_BACKEND]: {
|
|
664
|
+
backend: CODEX_AGENT_RUNTIME_BACKEND,
|
|
665
|
+
fixture: "known_image_fixture",
|
|
666
|
+
deliveryPath: "synthetic_image_context",
|
|
667
|
+
verifiedAt: "2026-07-07"
|
|
668
|
+
},
|
|
669
|
+
[CLAUDE_CODE_AGENT_RUNTIME_BACKEND]: {
|
|
670
|
+
backend: CLAUDE_CODE_AGENT_RUNTIME_BACKEND,
|
|
671
|
+
fixture: "known_image_fixture",
|
|
672
|
+
deliveryPath: "native_mcp_tool_result_image",
|
|
673
|
+
verifiedAt: "2026-07-07"
|
|
674
|
+
}
|
|
675
|
+
};
|
|
658
676
|
var MODEL_REGISTRY = [
|
|
659
677
|
{
|
|
660
678
|
id: OpenAIModel.GPT54,
|
|
@@ -861,6 +879,21 @@ var MODEL_REGISTRY = [
|
|
|
861
879
|
pricing: { inputPerMillion: 3, outputPerMillion: 15, cacheReadPerMillion: 0.3, cacheWritePerMillion: 3.75 },
|
|
862
880
|
sessionStart: { eligible: true }
|
|
863
881
|
},
|
|
882
|
+
{
|
|
883
|
+
id: AnthropicModel.Sonnet5,
|
|
884
|
+
name: "Claude Sonnet 5",
|
|
885
|
+
provider: "anthropic",
|
|
886
|
+
backends: [CLAUDE_CODE_AGENT_RUNTIME_BACKEND],
|
|
887
|
+
contextWindow: 1e6,
|
|
888
|
+
// Verified 2026-07-12 against Anthropic's Sonnet 5 launch documentation:
|
|
889
|
+
// adaptive thinking supports low/medium/high/xhigh/max; "none" omits the
|
|
890
|
+
// SDK effort option and lets Claude use its adaptive default.
|
|
891
|
+
reasoning: { efforts: ["none", "low", "medium", "high", "xhigh", "max"], default: "high" },
|
|
892
|
+
// Bridge cost-estimate only; authoritative Anthropic Messages pricing lives
|
|
893
|
+
// in apps/control-plane-worker/src/anthropic/cost.ts.
|
|
894
|
+
pricing: { inputPerMillion: 3, outputPerMillion: 15, cacheReadPerMillion: 0.3, cacheWritePerMillion: 3.75 },
|
|
895
|
+
sessionStart: { eligible: true }
|
|
896
|
+
},
|
|
864
897
|
{
|
|
865
898
|
id: AnthropicModel.Fable5,
|
|
866
899
|
name: "Claude Fable 5",
|
|
@@ -889,6 +922,12 @@ var MODEL_REGISTRY = [
|
|
|
889
922
|
// context/output, OpenAI SDK compatible, MIT license, tool calling
|
|
890
923
|
// supported for all Model APIs.
|
|
891
924
|
providerModelId: "moonshotai/Kimi-K2.7-Code",
|
|
925
|
+
desktopImageFeedback: {
|
|
926
|
+
backend: OPENCODE_AGENT_RUNTIME_BACKEND,
|
|
927
|
+
fixture: "known_image_fixture",
|
|
928
|
+
deliveryPath: "native_mcp_tool_result_image",
|
|
929
|
+
verifiedAt: "2026-07-07"
|
|
930
|
+
},
|
|
892
931
|
pricing: { inputPerMillion: 0.95, outputPerMillion: 4, cacheReadPerMillion: 0.16 },
|
|
893
932
|
sessionStart: { eligible: true, isDefault: true }
|
|
894
933
|
}
|
|
@@ -1206,27 +1245,14 @@ function mapAutomationApiError(err) {
|
|
|
1206
1245
|
if (!(err instanceof ApiError)) {
|
|
1207
1246
|
return err instanceof CliError ? err : new CliError("server", stringifyError(err));
|
|
1208
1247
|
}
|
|
1209
|
-
const parsed =
|
|
1210
|
-
const serverCode = parsed?.
|
|
1248
|
+
const parsed = parseApiErrorBody(err.body);
|
|
1249
|
+
const serverCode = parsed?.rawError ?? parsed?.serverCode;
|
|
1211
1250
|
return new CliError(codeForHttpStatus(err.status), parsed?.message || serverCode || err.message, {
|
|
1212
1251
|
exitCode: err.exitCode,
|
|
1213
1252
|
hint: serverCode ? AUTOMATION_ERROR_HINTS[serverCode] : void 0,
|
|
1214
1253
|
requestId: err.requestId
|
|
1215
1254
|
});
|
|
1216
1255
|
}
|
|
1217
|
-
function parseApiErrorBody2(body) {
|
|
1218
|
-
try {
|
|
1219
|
-
const parsed = JSON.parse(body);
|
|
1220
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
1221
|
-
const record = parsed;
|
|
1222
|
-
return {
|
|
1223
|
-
error: typeof record.error === "string" ? record.error : void 0,
|
|
1224
|
-
message: typeof record.message === "string" ? record.message : void 0
|
|
1225
|
-
};
|
|
1226
|
-
} catch {
|
|
1227
|
-
return null;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
1256
|
function printAutomationRule(rule) {
|
|
1231
1257
|
console.log(`ID: ${rule.id}`);
|
|
1232
1258
|
console.log(`Repo: ${rule.repoOwner}/${rule.repoName}`);
|
|
@@ -1578,6 +1604,11 @@ function normalizeUploadedFileOptions(files) {
|
|
|
1578
1604
|
return Array.isArray(files) ? files : [files];
|
|
1579
1605
|
}
|
|
1580
1606
|
|
|
1607
|
+
// src/utils/poll-interval.ts
|
|
1608
|
+
function clampPollInterval(ms, minimum) {
|
|
1609
|
+
return Math.max(ms, minimum);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1581
1612
|
// ../../shared/session/no-change-outcome.ts
|
|
1582
1613
|
function isNoChangesPromptResult(result) {
|
|
1583
1614
|
return typeof result === "object" && result !== null && "noChanges" in result && result.noChanges === true;
|
|
@@ -3003,6 +3034,11 @@ function renderWatchEvent(event, state) {
|
|
|
3003
3034
|
}
|
|
3004
3035
|
}
|
|
3005
3036
|
|
|
3037
|
+
// src/utils/session-payload.ts
|
|
3038
|
+
function unwrapSessionState(payload) {
|
|
3039
|
+
return payload.session && typeof payload.session === "object" ? payload.session : payload;
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3006
3042
|
// src/commands/model-options.ts
|
|
3007
3043
|
function resolveModelAndBackend(options) {
|
|
3008
3044
|
let agentRuntimeBackend = CODEX_AGENT_RUNTIME_BACKEND;
|
|
@@ -3246,7 +3282,7 @@ async function fetchCreatedPromptStatus(config, sessionId, promptId) {
|
|
|
3246
3282
|
return selectCreatedPrompt(promptList.prompts, promptId);
|
|
3247
3283
|
}
|
|
3248
3284
|
async function waitForCreatedPromptToSettle(config, sessionId, promptId, pollIntervalMs) {
|
|
3249
|
-
const effectivePollIntervalMs =
|
|
3285
|
+
const effectivePollIntervalMs = clampPollInterval(pollIntervalMs, MIN_WATCH_POLL_INTERVAL_MS);
|
|
3250
3286
|
while (true) {
|
|
3251
3287
|
const createdPrompt = await fetchCreatedPromptStatus(config, sessionId, promptId);
|
|
3252
3288
|
if (createdPrompt && PROMPT_TERMINAL_STATUSES.has(createdPrompt.status)) {
|
|
@@ -3288,15 +3324,12 @@ async function waitForCreatedPrompt(sessionId, promptId, sessionUrl, pollInterva
|
|
|
3288
3324
|
);
|
|
3289
3325
|
}
|
|
3290
3326
|
}
|
|
3291
|
-
function unwrapSessionState(payload) {
|
|
3292
|
-
return payload.session && typeof payload.session === "object" ? payload.session : payload;
|
|
3293
|
-
}
|
|
3294
3327
|
async function fetchSessionResultFields(config, sessionId) {
|
|
3295
3328
|
const sessionPayload = await apiFetch(config, `/api/sessions/${sessionId}`);
|
|
3296
3329
|
return extractSessionResultFields(unwrapSessionState(sessionPayload));
|
|
3297
3330
|
}
|
|
3298
3331
|
async function fetchSettledSessionResultFields(config, sessionId, pollIntervalMs) {
|
|
3299
|
-
const effectivePollIntervalMs =
|
|
3332
|
+
const effectivePollIntervalMs = clampPollInterval(pollIntervalMs, MIN_WATCH_POLL_INTERVAL_MS);
|
|
3300
3333
|
let latest = {};
|
|
3301
3334
|
for (let attempt = 0; attempt < RESULT_FETCH_ATTEMPTS; attempt++) {
|
|
3302
3335
|
latest = await fetchSessionResultFields(config, sessionId);
|
|
@@ -3607,9 +3640,6 @@ async function loginCommand(options, command) {
|
|
|
3607
3640
|
}
|
|
3608
3641
|
|
|
3609
3642
|
// src/commands/message.ts
|
|
3610
|
-
function unwrapSessionState2(payload) {
|
|
3611
|
-
return payload.session && typeof payload.session === "object" ? payload.session : payload;
|
|
3612
|
-
}
|
|
3613
3643
|
async function messageCommand(sessionId, promptArg, options = {}, command) {
|
|
3614
3644
|
const runtime = getRuntimeOptions(command, options);
|
|
3615
3645
|
assertArcanistSessionMutationAllowed("send");
|
|
@@ -3641,7 +3671,7 @@ async function messageCommand(sessionId, promptArg, options = {}, command) {
|
|
|
3641
3671
|
}
|
|
3642
3672
|
try {
|
|
3643
3673
|
const sessionPayload = await apiFetch(config, `/api/sessions/${sessionId}`);
|
|
3644
|
-
const resultLine = formatSessionResult(
|
|
3674
|
+
const resultLine = formatSessionResult(unwrapSessionState(sessionPayload));
|
|
3645
3675
|
if (resultLine) console.log(resultLine);
|
|
3646
3676
|
} catch {
|
|
3647
3677
|
}
|