@codexhost/cli-darwin-x64 0.21.0 → 0.22.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/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +1 -0
- package/app/console-web.js +1 -0
- package/app/desktop-controller.mjs +4 -1
- package/app/host-runtime.mjs +86 -21
- package/app/plugins/antigravity/plugin.mjs +1144 -1254
- package/app/plugins/claude-code/plugin.mjs +389 -84
- package/app/plugins/codebuddy/plugin.mjs +1 -0
- package/app/plugins/codex-usage/plugin.mjs +1 -0
- package/app/plugins/copilot/plugin.mjs +1 -0
- package/app/plugins/cursor-cli/plugin.mjs +1 -0
- package/app/plugins/deepseek-harness/plugin.mjs +1 -0
- package/app/plugins/devin/plugin.mjs +1 -0
- package/app/plugins/grok/plugin.mjs +192 -177
- package/app/plugins/hermes/plugin.mjs +1 -0
- package/app/plugins/kimi-code/plugin.mjs +1 -0
- package/app/plugins/kiro-cli/plugin.mjs +1 -0
- package/app/plugins/omp/plugin.mjs +108 -22
- package/app/plugins/opencode/plugin.mjs +1 -0
- package/app/plugins/pi/plugin.mjs +119 -23
- package/app/plugins/qoder/plugin.mjs +1 -0
- package/app/plugins/qoder-cn/plugin.mjs +1 -0
- package/app/plugins/qwen-code/plugin.mjs +1 -0
- package/app/plugins/workbuddy/plugin.mjs +1 -0
- package/app/plugins/zcode/plugin.mjs +1 -0
- package/app/renderer-extension.js +1 -0
- package/app/web/assets/index-CN4a4sj0.js +201 -0
- package/app/web/codexhost-settings.js +1 -0
- package/app/web/index.html +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +6 -6
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +1 -1
- package/app/web-modules/server.mjs +130 -74
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BdmZfTRW.js +0 -201
|
@@ -14851,6 +14851,11 @@ var harnessModelSchema = external_exports.object({
|
|
|
14851
14851
|
fastModel: harnessModelRefSchema.optional(),
|
|
14852
14852
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14853
14853
|
}).strict();
|
|
14854
|
+
function catalogModelForRef(catalog, ref) {
|
|
14855
|
+
if (!ref)
|
|
14856
|
+
return void 0;
|
|
14857
|
+
return catalog?.models.find((model2) => model2.ref.id === ref.id || model2.fastModel?.id === ref.id);
|
|
14858
|
+
}
|
|
14854
14859
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
14855
14860
|
const ids = /* @__PURE__ */ new Set();
|
|
14856
14861
|
for (const [index, option2] of options.entries()) {
|
|
@@ -16435,6 +16440,19 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16435
16440
|
status: updateStatusSchema.nullable()
|
|
16436
16441
|
});
|
|
16437
16442
|
|
|
16443
|
+
// ../../shared-contracts/dist/desktop-attachments.js
|
|
16444
|
+
var ATTACHED_FILES_HEADING = /^\s*# Files mentioned by the user:[ \t]*(?:\r?\n|$)/u;
|
|
16445
|
+
var REQUEST_HEADING = /(?:^|\n)## My request:[ \t]*(?:\r?\n|$)/u;
|
|
16446
|
+
var IMAGE_ATTACHMENT_PATTERN = /(?:^|\n)## [^\r\n]+: ((?:\/|[A-Za-z]:[\\/]|\\\\)[^\r\n]+)\r?\nImage attachment: true(?=\r?\n|$)/gu;
|
|
16447
|
+
var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f]/u;
|
|
16448
|
+
function desktopImageAttachmentPaths(text2) {
|
|
16449
|
+
const end = text2.search(REQUEST_HEADING);
|
|
16450
|
+
const context = end < 0 ? text2 : text2.slice(0, end);
|
|
16451
|
+
if (!ATTACHED_FILES_HEADING.test(context))
|
|
16452
|
+
return [];
|
|
16453
|
+
return [...context.matchAll(IMAGE_ATTACHMENT_PATTERN)].map((match) => match[1] ?? "").filter((path18) => path18.length > 0 && !CONTROL_CHARACTER_PATTERN.test(path18));
|
|
16454
|
+
}
|
|
16455
|
+
|
|
16438
16456
|
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
16439
16457
|
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
16440
16458
|
"completed",
|
|
@@ -16506,6 +16524,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16506
16524
|
message: "A history continuation requires its connection epoch"
|
|
16507
16525
|
}).optional()
|
|
16508
16526
|
}),
|
|
16527
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
16509
16528
|
external_exports.strictObject({
|
|
16510
16529
|
kind: external_exports.literal("configure"),
|
|
16511
16530
|
...thread,
|
|
@@ -18602,6 +18621,7 @@ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix
|
|
|
18602
18621
|
// dist/claude-code-adapter.js
|
|
18603
18622
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
18604
18623
|
import path15 from "node:path";
|
|
18624
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
18605
18625
|
|
|
18606
18626
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
18607
18627
|
import { createRequire as jre } from "node:module";
|
|
@@ -55787,7 +55807,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55787
55807
|
if (message.type !== "system")
|
|
55788
55808
|
return;
|
|
55789
55809
|
if (message.subtype === "init") {
|
|
55790
|
-
|
|
55810
|
+
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) => isRecord7(server) && typeof server.name === "string" ? [server.name] : []) : void 0;
|
|
55811
|
+
events.push({ type: "segment.started", ...mcpServers ? { mcpServers } : {} });
|
|
55791
55812
|
return;
|
|
55792
55813
|
}
|
|
55793
55814
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
@@ -56194,6 +56215,31 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56194
56215
|
}
|
|
56195
56216
|
};
|
|
56196
56217
|
|
|
56218
|
+
// dist/claude-tool-item.js
|
|
56219
|
+
function mcpServerSegment(server) {
|
|
56220
|
+
const segment = server.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
56221
|
+
return server.startsWith("claude.ai ") ? segment.replace(/_+/g, "_").replace(/^_|_$/g, "") : segment;
|
|
56222
|
+
}
|
|
56223
|
+
function mcpTool(toolName, servers) {
|
|
56224
|
+
if (!toolName.startsWith("mcp__"))
|
|
56225
|
+
return null;
|
|
56226
|
+
const known = servers.map((server2) => `mcp__${mcpServerSegment(server2)}__`).filter((prefix) => toolName.length > prefix.length && toolName.startsWith(prefix)).sort((left, right) => right.length - left.length)[0];
|
|
56227
|
+
if (known)
|
|
56228
|
+
return { server: known.slice(5, -2), tool: toolName.slice(known.length) };
|
|
56229
|
+
const [, server, ...tool] = toolName.split("__");
|
|
56230
|
+
const name = tool.join("__");
|
|
56231
|
+
return server && name ? { server, tool: name } : null;
|
|
56232
|
+
}
|
|
56233
|
+
function claudeToolItem(itemId, toolName, args, mcpServers = []) {
|
|
56234
|
+
const mcp = mcpTool(toolName, mcpServers);
|
|
56235
|
+
if (mcp)
|
|
56236
|
+
return { type: "mcpToolCall", itemId, ...mcp, arguments: args };
|
|
56237
|
+
if (toolName === "WebSearch" && typeof args === "object" && args !== null && !Array.isArray(args) && typeof args.query === "string" && args.query.length > 0) {
|
|
56238
|
+
return { type: "webSearch", itemId, query: args.query };
|
|
56239
|
+
}
|
|
56240
|
+
return { type: "toolExecution", itemId, toolName, arguments: args };
|
|
56241
|
+
}
|
|
56242
|
+
|
|
56197
56243
|
// dist/item-identity.js
|
|
56198
56244
|
function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
56199
56245
|
return hostItemIdSchema.parse(`claude-item-v2-${nativeTurnKey}-${kind}-${ordinal}`);
|
|
@@ -56208,10 +56254,18 @@ function readClaudeQueuedCommand(value, sessionId) {
|
|
|
56208
56254
|
if (value.type !== "attachment" || !isRecord8(attachment) || attachment.type !== "queued_command" || attachment.commandMode !== "prompt" || !isRecord8(attachment.origin) || attachment.origin.kind !== "human" || attachment.humanTurn === false || attachment.isMeta === true || attachment.isSynthetic === true || value.isMeta === true || value.isSynthetic === true || value.isSidechain === true || isRecord8(value.origin) && value.origin.kind !== "human" || typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0 || value.sessionId !== void 0 && value.sessionId !== sessionId || value.session_id !== sessionId) {
|
|
56209
56255
|
return null;
|
|
56210
56256
|
}
|
|
56211
|
-
|
|
56257
|
+
const prompt = promptText(attachment.prompt);
|
|
56258
|
+
if (typeof value.uuid !== "string" || value.uuid.length === 0 || typeof attachment.source_uuid !== "string" || attachment.source_uuid.length === 0 || prompt.length === 0) {
|
|
56212
56259
|
throw new Error("Claude queued human input has an invalid identity or text prompt");
|
|
56213
56260
|
}
|
|
56214
|
-
return { uuid: value.uuid, sourceUuid: attachment.source_uuid, prompt
|
|
56261
|
+
return { uuid: value.uuid, sourceUuid: attachment.source_uuid, prompt };
|
|
56262
|
+
}
|
|
56263
|
+
function promptText(prompt) {
|
|
56264
|
+
if (typeof prompt === "string")
|
|
56265
|
+
return prompt;
|
|
56266
|
+
if (!Array.isArray(prompt))
|
|
56267
|
+
return "";
|
|
56268
|
+
return prompt.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
56215
56269
|
}
|
|
56216
56270
|
|
|
56217
56271
|
// dist/claude-history.js
|
|
@@ -56482,10 +56536,10 @@ function itemOutcome(outcome) {
|
|
|
56482
56536
|
function isCheckpointCandidate(message) {
|
|
56483
56537
|
return !message.nested && (message.type === "assistant" || message.interrupted || hasRootToolResult(message));
|
|
56484
56538
|
}
|
|
56485
|
-
function mapClaudeSnapshot(values, sessionId) {
|
|
56486
|
-
return mapClaudeSnapshotWithCheckpointIds(values, sessionId).snapshot;
|
|
56539
|
+
function mapClaudeSnapshot(values, sessionId, mcpServers) {
|
|
56540
|
+
return mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers).snapshot;
|
|
56487
56541
|
}
|
|
56488
|
-
function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
56542
|
+
function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers) {
|
|
56489
56543
|
const messages = conversationMessages(values, sessionId);
|
|
56490
56544
|
const turns = [];
|
|
56491
56545
|
const turnCheckpointIds = [];
|
|
@@ -56635,15 +56689,8 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56635
56689
|
});
|
|
56636
56690
|
continue;
|
|
56637
56691
|
}
|
|
56638
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56639
56692
|
items.push({
|
|
56640
|
-
item:
|
|
56641
|
-
type: "toolExecution",
|
|
56642
|
-
itemId,
|
|
56643
|
-
toolName: block.name,
|
|
56644
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56645
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56646
|
-
},
|
|
56693
|
+
item: historyToolItem(itemId, block.name, block.input, output, mcpServers),
|
|
56647
56694
|
outcome: toolOutcome
|
|
56648
56695
|
});
|
|
56649
56696
|
}
|
|
@@ -56655,6 +56702,11 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId) {
|
|
|
56655
56702
|
}
|
|
56656
56703
|
return { snapshot: { turns }, turnCheckpointIds };
|
|
56657
56704
|
}
|
|
56705
|
+
function historyToolItem(itemId, toolName, input, output, mcpServers) {
|
|
56706
|
+
const argumentsResult = jsonValueSchema.safeParse(input);
|
|
56707
|
+
const item = claudeToolItem(itemId, toolName, argumentsResult.success ? argumentsResult.data : null, mcpServers);
|
|
56708
|
+
return output ? { ...item, output: { content: [{ type: "text", text: output }] } } : item;
|
|
56709
|
+
}
|
|
56658
56710
|
function toolResultBlocks(messages) {
|
|
56659
56711
|
const results = /* @__PURE__ */ new Map();
|
|
56660
56712
|
for (const message of messages) {
|
|
@@ -56788,15 +56840,8 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
56788
56840
|
});
|
|
56789
56841
|
continue;
|
|
56790
56842
|
}
|
|
56791
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56792
56843
|
items.push({
|
|
56793
|
-
item:
|
|
56794
|
-
type: "toolExecution",
|
|
56795
|
-
itemId,
|
|
56796
|
-
toolName: block.name,
|
|
56797
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56798
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56799
|
-
},
|
|
56844
|
+
item: historyToolItem(itemId, block.name, block.input, output),
|
|
56800
56845
|
outcome: toolOutcome
|
|
56801
56846
|
});
|
|
56802
56847
|
}
|
|
@@ -57197,6 +57242,37 @@ var CLAUDE_THINKING_OPTIONS = [
|
|
|
57197
57242
|
];
|
|
57198
57243
|
var CLAUDE_THINKING_OPTION_IDS = CLAUDE_THINKING_OPTIONS.map(({ id: id2 }) => id2);
|
|
57199
57244
|
var CLAUDE_DEFAULT_THINKING_OPTION_ID = harnessThinkingOptionIdSchema.parse("auto");
|
|
57245
|
+
function claudeSupportedThinkingOptionIds(model2) {
|
|
57246
|
+
if (model2.supportsEffort === void 0 && model2.supportedEffortLevels === void 0 && model2.supportsAdaptiveThinking === void 0 && model2.supportsThinkingOff === void 0) {
|
|
57247
|
+
return [...CLAUDE_THINKING_OPTION_IDS];
|
|
57248
|
+
}
|
|
57249
|
+
const efforts = new Set(model2.supportsEffort === false ? [] : model2.supportedEffortLevels ?? []);
|
|
57250
|
+
return CLAUDE_THINKING_OPTION_IDS.filter((id2) => {
|
|
57251
|
+
if (id2 === "off")
|
|
57252
|
+
return model2.supportsThinkingOff !== false;
|
|
57253
|
+
if (id2 === "auto")
|
|
57254
|
+
return true;
|
|
57255
|
+
if (id2 === "ultracode")
|
|
57256
|
+
return efforts.has("xhigh");
|
|
57257
|
+
return efforts.has(id2);
|
|
57258
|
+
});
|
|
57259
|
+
}
|
|
57260
|
+
var CLAUDE_EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"];
|
|
57261
|
+
function fitClaudeThinkingOptionId(requested, supported) {
|
|
57262
|
+
if (!supported || supported.includes(requested))
|
|
57263
|
+
return requested;
|
|
57264
|
+
const ceiling = CLAUDE_EFFORT_ORDER.indexOf(requested === "ultracode" ? "xhigh" : requested);
|
|
57265
|
+
let best = CLAUDE_DEFAULT_THINKING_OPTION_ID;
|
|
57266
|
+
let bestRank = -1;
|
|
57267
|
+
for (const id2 of supported) {
|
|
57268
|
+
const rank = CLAUDE_EFFORT_ORDER.indexOf(id2);
|
|
57269
|
+
if (rank > bestRank && rank <= ceiling) {
|
|
57270
|
+
best = id2;
|
|
57271
|
+
bestRank = rank;
|
|
57272
|
+
}
|
|
57273
|
+
}
|
|
57274
|
+
return best;
|
|
57275
|
+
}
|
|
57200
57276
|
function parseClaudeThinkingOptionId(value) {
|
|
57201
57277
|
const id2 = harnessThinkingOptionIdSchema.parse(value);
|
|
57202
57278
|
if (!CLAUDE_THINKING_OPTION_IDS.includes(id2)) {
|
|
@@ -57229,7 +57305,13 @@ var modelInfoSchema = external_exports.object({
|
|
|
57229
57305
|
value: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
57230
57306
|
displayName: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
57231
57307
|
description: external_exports.string().trim().max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
|
|
57232
|
-
resolvedModel: harnessResolvedModelLabelSchema.optional()
|
|
57308
|
+
resolvedModel: harnessResolvedModelLabelSchema.optional(),
|
|
57309
|
+
// Malformed capability fields count as unreported instead of failing the whole catalog;
|
|
57310
|
+
// unknown effort levels are ignored when mapping Thinking options.
|
|
57311
|
+
supportsEffort: external_exports.boolean().optional().catch(void 0),
|
|
57312
|
+
supportedEffortLevels: external_exports.array(external_exports.string()).optional().catch(void 0),
|
|
57313
|
+
supportsAdaptiveThinking: external_exports.boolean().optional().catch(void 0),
|
|
57314
|
+
supportsThinkingOff: external_exports.boolean().optional().catch(void 0)
|
|
57233
57315
|
});
|
|
57234
57316
|
var modelPickerOptionSchema = external_exports.object({
|
|
57235
57317
|
model: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
@@ -57412,12 +57494,17 @@ function uniqueDisplayLabels(rows) {
|
|
|
57412
57494
|
}
|
|
57413
57495
|
return labels;
|
|
57414
57496
|
}
|
|
57497
|
+
function canonicalRow(row) {
|
|
57498
|
+
if (row.supportedEffortLevels === void 0)
|
|
57499
|
+
return row;
|
|
57500
|
+
return { ...row, supportedEffortLevels: [...new Set(row.supportedEffortLevels)].sort() };
|
|
57501
|
+
}
|
|
57415
57502
|
function normalizeRows(value) {
|
|
57416
57503
|
if (!Array.isArray(value))
|
|
57417
57504
|
throw new Error("Claude Code Model catalog is not an array");
|
|
57418
57505
|
const byValue = /* @__PURE__ */ new Map();
|
|
57419
57506
|
for (const nativeRow of value) {
|
|
57420
|
-
const row = modelInfoSchema.parse(nativeRow);
|
|
57507
|
+
const row = canonicalRow(modelInfoSchema.parse(nativeRow));
|
|
57421
57508
|
const existing = byValue.get(row.value);
|
|
57422
57509
|
if (existing && JSON.stringify(existing) !== JSON.stringify(row)) {
|
|
57423
57510
|
throw new Error("Claude Code Model catalog contains conflicting selectable values");
|
|
@@ -57442,7 +57529,7 @@ function normalizeClaudeModelCatalog(snapshot) {
|
|
|
57442
57529
|
ref: encodeClaudeModelRef(row.value),
|
|
57443
57530
|
label: labels.get(row.value) ?? row.displayName,
|
|
57444
57531
|
...row.resolvedModel ? { resolvedModelLabel: row.resolvedModel } : {},
|
|
57445
|
-
supportedThinkingOptionIds:
|
|
57532
|
+
supportedThinkingOptionIds: claudeSupportedThinkingOptionIds(row)
|
|
57446
57533
|
};
|
|
57447
57534
|
});
|
|
57448
57535
|
models.sort((left, right) => {
|
|
@@ -58059,7 +58146,10 @@ var ClaudeSdkTransport = class {
|
|
|
58059
58146
|
// Adaptive Thinking is redacted by default: the API streams `thinking_delta`
|
|
58060
58147
|
// frames carrying only token estimates and empty text, so no Reasoning Item
|
|
58061
58148
|
// would ever start. Summarized display is the official channel for readable
|
|
58062
|
-
// Thinking and is what Claude Code's own TUI renders.
|
|
58149
|
+
// Thinking and is what Claude Code's own TUI renders. The SDK passes this as
|
|
58150
|
+
// `--thinking adaptive`, which only turns Thinking on: Claude Code sends adaptive
|
|
58151
|
+
// Thinking to Models that support it and a token budget to the rest. The caller
|
|
58152
|
+
// fits the effort to the Model's catalog levels.
|
|
58063
58153
|
thinking: thinking.enabled ? { type: "adaptive", display: "summarized" } : { type: "disabled" },
|
|
58064
58154
|
...thinking.effort ? { effort: thinking.effort } : {},
|
|
58065
58155
|
pathToClaudeCodeExecutable: executable,
|
|
@@ -58162,13 +58252,23 @@ var ClaudeSdkTransport = class {
|
|
|
58162
58252
|
throw new Error("Claude SDK transport is not started");
|
|
58163
58253
|
return this.#permissionMode;
|
|
58164
58254
|
}
|
|
58165
|
-
async setModel(model2) {
|
|
58255
|
+
async setModel(model2, thinkingOptionId = this.#thinkingOptionId) {
|
|
58166
58256
|
const activeQuery = this.#query;
|
|
58167
58257
|
if (!this.#started || !activeQuery)
|
|
58168
58258
|
throw new Error("Claude SDK transport is not started");
|
|
58169
|
-
const
|
|
58259
|
+
const id2 = parseClaudeThinkingOptionId(thinkingOptionId);
|
|
58260
|
+
const previous = claudeThinkingConfiguration(this.#thinkingOptionId);
|
|
58261
|
+
const thinking = claudeThinkingConfiguration(id2);
|
|
58170
58262
|
const previousModel = this.#currentModel;
|
|
58171
58263
|
await activeQuery.setModel(model2);
|
|
58264
|
+
if (id2 !== this.#thinkingOptionId && !thinking.ultracode) {
|
|
58265
|
+
try {
|
|
58266
|
+
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(thinking, previous));
|
|
58267
|
+
} catch (error52) {
|
|
58268
|
+
await this.#restoreOrFault(() => activeQuery.setModel(previousModel));
|
|
58269
|
+
throw error52;
|
|
58270
|
+
}
|
|
58271
|
+
}
|
|
58172
58272
|
if (thinking.ultracode) {
|
|
58173
58273
|
try {
|
|
58174
58274
|
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(thinking, thinking));
|
|
@@ -58176,13 +58276,14 @@ var ClaudeSdkTransport = class {
|
|
|
58176
58276
|
} catch (error52) {
|
|
58177
58277
|
await this.#restoreOrFault(async () => {
|
|
58178
58278
|
await activeQuery.setModel(previousModel);
|
|
58179
|
-
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(
|
|
58180
|
-
await this.#verifyUltracode(activeQuery);
|
|
58279
|
+
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(previous, thinking));
|
|
58280
|
+
await (previous.ultracode ? this.#verifyUltracode(activeQuery) : this.#verifyUltracodeOff(activeQuery));
|
|
58181
58281
|
});
|
|
58182
58282
|
throw error52;
|
|
58183
58283
|
}
|
|
58184
58284
|
}
|
|
58185
58285
|
this.#currentModel = model2;
|
|
58286
|
+
this.#thinkingOptionId = id2;
|
|
58186
58287
|
}
|
|
58187
58288
|
async setThinkingOption(thinkingOptionId) {
|
|
58188
58289
|
const activeQuery = this.#query;
|
|
@@ -58254,7 +58355,7 @@ var ClaudeSdkTransport = class {
|
|
|
58254
58355
|
recap(userMessageId, onEvent) {
|
|
58255
58356
|
return this.runTurn("/recap", userMessageId, onEvent);
|
|
58256
58357
|
}
|
|
58257
|
-
runTurn(
|
|
58358
|
+
runTurn(content, userMessageId, onEvent) {
|
|
58258
58359
|
if (this.#closePromise || !this.#started || !this.#query) {
|
|
58259
58360
|
return Promise.reject(new Error("Claude SDK transport is not started"));
|
|
58260
58361
|
}
|
|
@@ -58276,7 +58377,7 @@ var ClaudeSdkTransport = class {
|
|
|
58276
58377
|
onEvent(event);
|
|
58277
58378
|
this.#input.push({
|
|
58278
58379
|
type: "user",
|
|
58279
|
-
message: { role: "user", content
|
|
58380
|
+
message: { role: "user", content },
|
|
58280
58381
|
parent_tool_use_id: null,
|
|
58281
58382
|
session_id: this.sessionId,
|
|
58282
58383
|
uuid: userMessageId,
|
|
@@ -58293,7 +58394,7 @@ var ClaudeSdkTransport = class {
|
|
|
58293
58394
|
* The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
|
|
58294
58395
|
* after a bounded wait so callers that serialize requests are never held indefinitely.
|
|
58295
58396
|
*/
|
|
58296
|
-
steer(
|
|
58397
|
+
steer(content, messageId, onTakeover) {
|
|
58297
58398
|
if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
|
|
58298
58399
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
58299
58400
|
}
|
|
@@ -58303,7 +58404,7 @@ var ClaudeSdkTransport = class {
|
|
|
58303
58404
|
try {
|
|
58304
58405
|
this.#input.push({
|
|
58305
58406
|
type: "user",
|
|
58306
|
-
message: { role: "user", content
|
|
58407
|
+
message: { role: "user", content },
|
|
58307
58408
|
parent_tool_use_id: null,
|
|
58308
58409
|
session_id: this.sessionId,
|
|
58309
58410
|
uuid: messageId,
|
|
@@ -59550,6 +59651,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59550
59651
|
#onDetached;
|
|
59551
59652
|
#outputLimit;
|
|
59552
59653
|
#taskTracker;
|
|
59654
|
+
#mcpServers;
|
|
59553
59655
|
#nativeTurnKey;
|
|
59554
59656
|
#tools = /* @__PURE__ */ new Map();
|
|
59555
59657
|
#toolOrdinal = 0;
|
|
@@ -59560,6 +59662,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59560
59662
|
this.#onDetached = options.onDetached;
|
|
59561
59663
|
this.#outputLimit = options.outputLimit;
|
|
59562
59664
|
this.#taskTracker = options.taskTracker;
|
|
59665
|
+
this.#mcpServers = options.mcpServers ?? (() => []);
|
|
59563
59666
|
this.#nativeTurnKey = options.nativeTurnKey;
|
|
59564
59667
|
}
|
|
59565
59668
|
get size() {
|
|
@@ -59575,12 +59678,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59575
59678
|
itemId,
|
|
59576
59679
|
command,
|
|
59577
59680
|
cwd: this.#cwd
|
|
59578
|
-
} : {
|
|
59579
|
-
type: "toolExecution",
|
|
59580
|
-
itemId,
|
|
59581
|
-
toolName: isClaudeTaskTool(event.toolName) ? "Todo" : event.toolName,
|
|
59582
|
-
arguments: isClaudeTaskTool(event.toolName) ? {} : event.arguments
|
|
59583
|
-
};
|
|
59681
|
+
} : isClaudeTaskTool(event.toolName) ? { type: "toolExecution", itemId, toolName: "Todo", arguments: {} } : claudeToolItem(itemId, event.toolName, event.arguments, this.#mcpServers());
|
|
59584
59682
|
this.#tools.set(event.callId, {
|
|
59585
59683
|
item,
|
|
59586
59684
|
nativeName: event.toolName,
|
|
@@ -59625,6 +59723,8 @@ var ClaudeToolLifecycle = class {
|
|
|
59625
59723
|
} : {},
|
|
59626
59724
|
durationMs
|
|
59627
59725
|
};
|
|
59726
|
+
} else if (tool.item.type === "webSearch") {
|
|
59727
|
+
tool.item = { ...tool.item, ...output ? { output } : {} };
|
|
59628
59728
|
} else {
|
|
59629
59729
|
tool.item = { ...tool.item, ...output ? { output } : {}, durationMs };
|
|
59630
59730
|
}
|
|
@@ -59653,7 +59753,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59653
59753
|
for (const [callId, tool] of this.#tools) {
|
|
59654
59754
|
this.#tools.delete(callId);
|
|
59655
59755
|
const durationMs = Math.max(tool.elapsedMs, Date.now() - tool.startedAtMs, 0);
|
|
59656
|
-
this.#completeItem(turnId, { ...tool.item, durationMs }, outcome);
|
|
59756
|
+
this.#completeItem(turnId, tool.item.type === "webSearch" ? tool.item : { ...tool.item, durationMs }, outcome);
|
|
59657
59757
|
}
|
|
59658
59758
|
}
|
|
59659
59759
|
#completeItem(turnId, item, outcome) {
|
|
@@ -59705,6 +59805,135 @@ function estimateClaudeRequestCostUsd(usage) {
|
|
|
59705
59805
|
return Number.isFinite(cost) && cost >= 0 ? cost : void 0;
|
|
59706
59806
|
}
|
|
59707
59807
|
|
|
59808
|
+
// dist/turn-input.js
|
|
59809
|
+
import { constants as constants3 } from "node:fs";
|
|
59810
|
+
import { open as open5 } from "node:fs/promises";
|
|
59811
|
+
var MAX_IMAGE_FILE_BYTES = 20 * 1024 * 1024;
|
|
59812
|
+
var MAX_STEER_BASE64_BYTES = 5 * 1024 * 1024;
|
|
59813
|
+
var MAX_STEER_IMAGE_SIDE = 2e3;
|
|
59814
|
+
var HEADER_BYTES = 32;
|
|
59815
|
+
function imageMediaType(data) {
|
|
59816
|
+
if (data.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) {
|
|
59817
|
+
return "image/png";
|
|
59818
|
+
}
|
|
59819
|
+
if (data.subarray(0, 3).equals(Buffer.from([255, 216, 255])))
|
|
59820
|
+
return "image/jpeg";
|
|
59821
|
+
const head = data.subarray(0, 12).toString("latin1");
|
|
59822
|
+
if (head.startsWith("GIF87a") || head.startsWith("GIF89a"))
|
|
59823
|
+
return "image/gif";
|
|
59824
|
+
if (head.startsWith("RIFF") && head.slice(8) === "WEBP")
|
|
59825
|
+
return "image/webp";
|
|
59826
|
+
return null;
|
|
59827
|
+
}
|
|
59828
|
+
function jpegDimensions(data) {
|
|
59829
|
+
let offset = 2;
|
|
59830
|
+
while (offset + 9 <= data.length) {
|
|
59831
|
+
if (data[offset] !== 255)
|
|
59832
|
+
return null;
|
|
59833
|
+
const marker = data[offset + 1] ?? 0;
|
|
59834
|
+
if (marker === 255) {
|
|
59835
|
+
offset += 1;
|
|
59836
|
+
continue;
|
|
59837
|
+
}
|
|
59838
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
59839
|
+
return { height: data.readUInt16BE(offset + 5), width: data.readUInt16BE(offset + 7) };
|
|
59840
|
+
}
|
|
59841
|
+
if (marker === 1 || marker >= 208 && marker <= 216) {
|
|
59842
|
+
offset += 2;
|
|
59843
|
+
continue;
|
|
59844
|
+
}
|
|
59845
|
+
offset += 2 + data.readUInt16BE(offset + 2);
|
|
59846
|
+
}
|
|
59847
|
+
return null;
|
|
59848
|
+
}
|
|
59849
|
+
function imageDimensions(data, mediaType) {
|
|
59850
|
+
if (data.length < 30)
|
|
59851
|
+
return null;
|
|
59852
|
+
switch (mediaType) {
|
|
59853
|
+
case "image/png":
|
|
59854
|
+
return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
|
|
59855
|
+
case "image/gif":
|
|
59856
|
+
return { width: data.readUInt16LE(6), height: data.readUInt16LE(8) };
|
|
59857
|
+
case "image/webp": {
|
|
59858
|
+
const chunk = data.toString("latin1", 12, 16);
|
|
59859
|
+
if (chunk === "VP8 ") {
|
|
59860
|
+
return { width: data.readUInt16LE(26) & 16383, height: data.readUInt16LE(28) & 16383 };
|
|
59861
|
+
}
|
|
59862
|
+
if (chunk === "VP8L") {
|
|
59863
|
+
const bits = data.readUInt32LE(21);
|
|
59864
|
+
return { width: (bits & 16383) + 1, height: (bits >>> 14 & 16383) + 1 };
|
|
59865
|
+
}
|
|
59866
|
+
if (chunk === "VP8X") {
|
|
59867
|
+
return { width: data.readUIntLE(24, 3) + 1, height: data.readUIntLE(27, 3) + 1 };
|
|
59868
|
+
}
|
|
59869
|
+
return null;
|
|
59870
|
+
}
|
|
59871
|
+
case "image/jpeg":
|
|
59872
|
+
return jpegDimensions(data);
|
|
59873
|
+
}
|
|
59874
|
+
}
|
|
59875
|
+
function fitsSteer(data, mediaType) {
|
|
59876
|
+
if (Math.ceil(data.length / 3) * 4 > MAX_STEER_BASE64_BYTES)
|
|
59877
|
+
return false;
|
|
59878
|
+
const size = imageDimensions(data, mediaType);
|
|
59879
|
+
return size !== null && size.width > 0 && size.height > 0 && size.width <= MAX_STEER_IMAGE_SIDE && size.height <= MAX_STEER_IMAGE_SIDE;
|
|
59880
|
+
}
|
|
59881
|
+
async function imageBlock(file2, steer) {
|
|
59882
|
+
let handle;
|
|
59883
|
+
try {
|
|
59884
|
+
handle = await open5(file2, constants3.O_RDONLY | constants3.O_NONBLOCK);
|
|
59885
|
+
} catch {
|
|
59886
|
+
return null;
|
|
59887
|
+
}
|
|
59888
|
+
try {
|
|
59889
|
+
const stats = await handle.stat();
|
|
59890
|
+
if (!stats.isFile() || stats.size > MAX_IMAGE_FILE_BYTES)
|
|
59891
|
+
return null;
|
|
59892
|
+
if (steer && Math.ceil(stats.size / 3) * 4 > MAX_STEER_BASE64_BYTES)
|
|
59893
|
+
return null;
|
|
59894
|
+
const header = Buffer.alloc(HEADER_BYTES);
|
|
59895
|
+
const { bytesRead } = await handle.read(header, 0, HEADER_BYTES, 0);
|
|
59896
|
+
if (!imageMediaType(header.subarray(0, bytesRead)))
|
|
59897
|
+
return null;
|
|
59898
|
+
const buffer = Buffer.alloc(stats.size + 1);
|
|
59899
|
+
let length = 0;
|
|
59900
|
+
while (length < buffer.length) {
|
|
59901
|
+
const read = await handle.read(buffer, length, buffer.length - length, length);
|
|
59902
|
+
if (read.bytesRead === 0)
|
|
59903
|
+
break;
|
|
59904
|
+
length += read.bytesRead;
|
|
59905
|
+
}
|
|
59906
|
+
if (length > stats.size)
|
|
59907
|
+
return null;
|
|
59908
|
+
const data = buffer.subarray(0, length);
|
|
59909
|
+
const mediaType = imageMediaType(data.subarray(0, HEADER_BYTES));
|
|
59910
|
+
if (!mediaType)
|
|
59911
|
+
return null;
|
|
59912
|
+
if (steer && !fitsSteer(data, mediaType))
|
|
59913
|
+
return null;
|
|
59914
|
+
return {
|
|
59915
|
+
type: "image",
|
|
59916
|
+
source: { type: "base64", media_type: mediaType, data: data.toString("base64") }
|
|
59917
|
+
};
|
|
59918
|
+
} catch {
|
|
59919
|
+
return null;
|
|
59920
|
+
} finally {
|
|
59921
|
+
await handle.close().catch(() => void 0);
|
|
59922
|
+
}
|
|
59923
|
+
}
|
|
59924
|
+
async function claudeUserContent(text2, { steer = false } = {}) {
|
|
59925
|
+
const paths = [...new Set(desktopImageAttachmentPaths(text2))];
|
|
59926
|
+
if (paths.length === 0)
|
|
59927
|
+
return text2;
|
|
59928
|
+
const content = [{ type: "text", text: text2 }];
|
|
59929
|
+
for (const file2 of paths) {
|
|
59930
|
+
const block = await imageBlock(file2, steer);
|
|
59931
|
+
if (block)
|
|
59932
|
+
content.push(block);
|
|
59933
|
+
}
|
|
59934
|
+
return content.length > 1 ? content : text2;
|
|
59935
|
+
}
|
|
59936
|
+
|
|
59708
59937
|
// dist/claude-code-adapter.js
|
|
59709
59938
|
var claudeCodeHarnessId2 = harnessIdSchema.parse("claude-code");
|
|
59710
59939
|
var claudeCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
@@ -59996,12 +60225,16 @@ var ClaudeHarnessSession = class {
|
|
|
59996
60225
|
#requestedModel;
|
|
59997
60226
|
#requestedPermissionModeId;
|
|
59998
60227
|
#requestedThinkingOptionId;
|
|
60228
|
+
/** This Session's folder's inspected catalog, which says what Thinking each Model accepts. */
|
|
60229
|
+
#modelCatalog;
|
|
59999
60230
|
#readSessionMessages;
|
|
60000
60231
|
#sessionId;
|
|
60001
60232
|
#toolOutputLimit;
|
|
60002
60233
|
#backgroundCommands;
|
|
60003
60234
|
#continuationQuiescenceMs;
|
|
60004
60235
|
#taskTracker = new ClaudeTaskTracker();
|
|
60236
|
+
/** MCP server names the latest native Segment reported; they disambiguate MCP Tool names. */
|
|
60237
|
+
#mcpServers = [];
|
|
60005
60238
|
#acceptingTurn = false;
|
|
60006
60239
|
#active = null;
|
|
60007
60240
|
#closePromise = null;
|
|
@@ -60053,7 +60286,8 @@ var ClaudeHarnessSession = class {
|
|
|
60053
60286
|
this.#openMode = options.openMode;
|
|
60054
60287
|
this.#requestedModel = options.requestedModel;
|
|
60055
60288
|
this.#requestedPermissionModeId = options.requestedPermissionModeId;
|
|
60056
|
-
this.#
|
|
60289
|
+
this.#modelCatalog = options.modelCatalog;
|
|
60290
|
+
this.#requestedThinkingOptionId = fitClaudeThinkingOptionId(options.requestedThinkingOptionId, this.#supportedThinkingOptionIds(options.requestedModel ?? (this.#openMode === "create" ? CLAUDE_DEFAULT_MODEL_REF : void 0)));
|
|
60057
60291
|
this.#sessionId = options.sessionId;
|
|
60058
60292
|
this.#toolOutputLimit = options.toolOutputLimit;
|
|
60059
60293
|
this.#backgroundCommands = new ClaudeBackgroundCommandItems({
|
|
@@ -60121,39 +60355,56 @@ var ClaudeHarnessSession = class {
|
|
|
60121
60355
|
this.#readingHistory = true;
|
|
60122
60356
|
try {
|
|
60123
60357
|
let messages;
|
|
60124
|
-
|
|
60125
|
-
|
|
60126
|
-
|
|
60358
|
+
const deadline = Date.now() + this.#closeTimeoutMs;
|
|
60359
|
+
for (; ; ) {
|
|
60360
|
+
try {
|
|
60127
60361
|
messages = await this.#readSessionMessages({
|
|
60128
60362
|
cwd: this.#cwd,
|
|
60129
60363
|
sessionId: this.#sessionId
|
|
60130
60364
|
}) ?? [];
|
|
60131
|
-
|
|
60132
|
-
|
|
60133
|
-
|
|
60134
|
-
|
|
60135
|
-
|
|
60136
|
-
|
|
60137
|
-
|
|
60138
|
-
|
|
60139
|
-
|
|
60140
|
-
code: "sessionBusy",
|
|
60141
|
-
message: "Claude Code history is still being persisted",
|
|
60142
|
-
retryable: true
|
|
60143
|
-
}
|
|
60144
|
-
};
|
|
60145
|
-
}
|
|
60146
|
-
await delay2(25);
|
|
60365
|
+
} catch {
|
|
60366
|
+
return {
|
|
60367
|
+
ok: false,
|
|
60368
|
+
error: {
|
|
60369
|
+
code: "nativeFailure",
|
|
60370
|
+
message: "Claude Code history could not be read",
|
|
60371
|
+
retryable: true
|
|
60372
|
+
}
|
|
60373
|
+
};
|
|
60147
60374
|
}
|
|
60148
|
-
|
|
60149
|
-
|
|
60150
|
-
|
|
60151
|
-
|
|
60152
|
-
|
|
60153
|
-
|
|
60154
|
-
|
|
60155
|
-
}
|
|
60156
|
-
}
|
|
60375
|
+
let ids;
|
|
60376
|
+
try {
|
|
60377
|
+
ids = new Set(messages.flatMap((message) => {
|
|
60378
|
+
if (!isRecord15(message) || typeof message.uuid !== "string")
|
|
60379
|
+
return [];
|
|
60380
|
+
const queued = readClaudeQueuedCommand(message, this.#sessionId);
|
|
60381
|
+
return queued ? [message.uuid, queued.sourceUuid] : [message.uuid];
|
|
60382
|
+
}));
|
|
60383
|
+
} catch {
|
|
60384
|
+
return {
|
|
60385
|
+
ok: false,
|
|
60386
|
+
error: {
|
|
60387
|
+
code: "protocolError",
|
|
60388
|
+
message: "Claude Code history is invalid",
|
|
60389
|
+
retryable: false
|
|
60390
|
+
}
|
|
60391
|
+
};
|
|
60392
|
+
}
|
|
60393
|
+
if (this.#unpersistedMessageIds.every((id2) => isPersistedClaudeMessageId(id2, ids))) {
|
|
60394
|
+
this.#unpersistedMessageIds = [];
|
|
60395
|
+
break;
|
|
60396
|
+
}
|
|
60397
|
+
if (Date.now() >= deadline || this.#phase !== "open") {
|
|
60398
|
+
return {
|
|
60399
|
+
ok: false,
|
|
60400
|
+
error: {
|
|
60401
|
+
code: "sessionBusy",
|
|
60402
|
+
message: "Claude Code history is still being persisted",
|
|
60403
|
+
retryable: true
|
|
60404
|
+
}
|
|
60405
|
+
};
|
|
60406
|
+
}
|
|
60407
|
+
await delay2(25);
|
|
60157
60408
|
}
|
|
60158
60409
|
if (messages.length === 0 && isPendingClaudeSession(this.#nativeRef)) {
|
|
60159
60410
|
try {
|
|
@@ -60184,7 +60435,10 @@ var ClaudeHarnessSession = class {
|
|
|
60184
60435
|
try {
|
|
60185
60436
|
return {
|
|
60186
60437
|
ok: true,
|
|
60187
|
-
value: {
|
|
60438
|
+
value: {
|
|
60439
|
+
...mapClaudeSnapshot(messages, this.#sessionId, this.#mcpServers),
|
|
60440
|
+
state: this.#state
|
|
60441
|
+
}
|
|
60188
60442
|
};
|
|
60189
60443
|
} catch {
|
|
60190
60444
|
return {
|
|
@@ -60238,6 +60492,7 @@ var ClaudeHarnessSession = class {
|
|
|
60238
60492
|
};
|
|
60239
60493
|
}
|
|
60240
60494
|
this.#acceptingTurn = true;
|
|
60495
|
+
const content = await claudeUserContent(text2);
|
|
60241
60496
|
const startingTransport = this.#transport === null;
|
|
60242
60497
|
let transport;
|
|
60243
60498
|
try {
|
|
@@ -60296,6 +60551,7 @@ var ClaudeHarnessSession = class {
|
|
|
60296
60551
|
cwd: this.#cwd,
|
|
60297
60552
|
outputLimit: this.#toolOutputLimit,
|
|
60298
60553
|
taskTracker: this.#taskTracker,
|
|
60554
|
+
mcpServers: () => this.#mcpServers,
|
|
60299
60555
|
nativeTurnKey,
|
|
60300
60556
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60301
60557
|
emit: (event) => this.#event(event),
|
|
@@ -60334,7 +60590,7 @@ var ClaudeHarnessSession = class {
|
|
|
60334
60590
|
nativeTurnKey,
|
|
60335
60591
|
formatVersion: 1
|
|
60336
60592
|
});
|
|
60337
|
-
const running = transport.runTurn(
|
|
60593
|
+
const running = transport.runTurn(content, nativeTurnRef.nativeTurnKey, (event) => {
|
|
60338
60594
|
this.#handleTurnEvent(active, event);
|
|
60339
60595
|
});
|
|
60340
60596
|
active.userMessageId = nativeTurnRef.nativeTurnKey;
|
|
@@ -60346,13 +60602,6 @@ var ClaudeHarnessSession = class {
|
|
|
60346
60602
|
return { ok: true, value: { turnId: command.turnId } };
|
|
60347
60603
|
}
|
|
60348
60604
|
async #steer(command) {
|
|
60349
|
-
const active = this.#active;
|
|
60350
|
-
if (!active || active.command.turnId !== command.turnId) {
|
|
60351
|
-
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
60352
|
-
}
|
|
60353
|
-
if (active.cancellationRequested) {
|
|
60354
|
-
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
60355
|
-
}
|
|
60356
60605
|
const text2 = command.input.map((input) => input.text).join("\n");
|
|
60357
60606
|
if (text2.length === 0) {
|
|
60358
60607
|
return {
|
|
@@ -60364,6 +60613,14 @@ var ClaudeHarnessSession = class {
|
|
|
60364
60613
|
}
|
|
60365
60614
|
};
|
|
60366
60615
|
}
|
|
60616
|
+
const content = await claudeUserContent(text2, { steer: true });
|
|
60617
|
+
const active = this.#active;
|
|
60618
|
+
if (!active || active.command.turnId !== command.turnId) {
|
|
60619
|
+
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
60620
|
+
}
|
|
60621
|
+
if (active.cancellationRequested) {
|
|
60622
|
+
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
60623
|
+
}
|
|
60367
60624
|
const transport = this.#transport;
|
|
60368
60625
|
if (!transport) {
|
|
60369
60626
|
return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
|
|
@@ -60381,7 +60638,7 @@ var ClaudeHarnessSession = class {
|
|
|
60381
60638
|
const messageId = this.#randomUUID();
|
|
60382
60639
|
active.steersAwaitingNative.add(messageId);
|
|
60383
60640
|
try {
|
|
60384
|
-
await transport.steer(
|
|
60641
|
+
await transport.steer(content, messageId, (started) => this.#takeOverSteer(active, messageId, started));
|
|
60385
60642
|
} catch (error52) {
|
|
60386
60643
|
if (error52 instanceof ClaudeSteerMissedTurnError) {
|
|
60387
60644
|
this.#takeOverSteer(active, messageId, false);
|
|
@@ -60474,6 +60731,7 @@ var ClaudeHarnessSession = class {
|
|
|
60474
60731
|
cwd: this.#cwd,
|
|
60475
60732
|
outputLimit: this.#toolOutputLimit,
|
|
60476
60733
|
taskTracker: this.#taskTracker,
|
|
60734
|
+
mcpServers: () => this.#mcpServers,
|
|
60477
60735
|
nativeTurnKey,
|
|
60478
60736
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60479
60737
|
emit: (event) => this.#event(event),
|
|
@@ -60590,10 +60848,11 @@ var ClaudeHarnessSession = class {
|
|
|
60590
60848
|
resolveConfiguration = resolve5;
|
|
60591
60849
|
});
|
|
60592
60850
|
try {
|
|
60851
|
+
const thinkingOptionId = fitClaudeThinkingOptionId(this.#requestedThinkingOptionId, this.#supportedThinkingOptionIds(command.model));
|
|
60593
60852
|
const transport = this.#transport;
|
|
60594
60853
|
if (transport) {
|
|
60595
60854
|
try {
|
|
60596
|
-
await transport.setModel(model2);
|
|
60855
|
+
await transport.setModel(model2, thinkingOptionId);
|
|
60597
60856
|
} catch (error52) {
|
|
60598
60857
|
return {
|
|
60599
60858
|
ok: false,
|
|
@@ -60606,6 +60865,7 @@ var ClaudeHarnessSession = class {
|
|
|
60606
60865
|
}
|
|
60607
60866
|
}
|
|
60608
60867
|
this.#requestedModel = command.model;
|
|
60868
|
+
this.#requestedThinkingOptionId = thinkingOptionId;
|
|
60609
60869
|
const persistenceError = await this.#savePendingConfiguration();
|
|
60610
60870
|
if (persistenceError)
|
|
60611
60871
|
return { ok: false, error: persistenceError };
|
|
@@ -60640,6 +60900,17 @@ var ClaudeHarnessSession = class {
|
|
|
60640
60900
|
}
|
|
60641
60901
|
};
|
|
60642
60902
|
}
|
|
60903
|
+
const supported = this.#supportedThinkingOptionIds(this.#effectiveModelRef());
|
|
60904
|
+
if (supported && !supported.includes(thinkingOptionId)) {
|
|
60905
|
+
return {
|
|
60906
|
+
ok: false,
|
|
60907
|
+
error: {
|
|
60908
|
+
code: "invalidRequest",
|
|
60909
|
+
message: "Claude Code Thinking option is unavailable for the selected Model",
|
|
60910
|
+
retryable: false
|
|
60911
|
+
}
|
|
60912
|
+
};
|
|
60913
|
+
}
|
|
60643
60914
|
this.#usageGeneration += 1;
|
|
60644
60915
|
this.#contextUsageFreshUntilMs = 0;
|
|
60645
60916
|
this.#contextUsageCooldownUntilMs = 0;
|
|
@@ -61106,15 +61377,39 @@ var ClaudeHarnessSession = class {
|
|
|
61106
61377
|
}
|
|
61107
61378
|
}
|
|
61108
61379
|
#configuredState(nativeReady = this.#state.nativeRef !== void 0) {
|
|
61109
|
-
const effectiveModel = this.#
|
|
61380
|
+
const effectiveModel = this.#effectiveModelRef();
|
|
61381
|
+
const supported = this.#supportedThinkingOptionIds(effectiveModel);
|
|
61110
61382
|
return {
|
|
61111
61383
|
...nativeReady ? { nativeRef: this.#nativeRef } : {},
|
|
61112
61384
|
...effectiveModel ? { effectiveModel } : {},
|
|
61113
61385
|
effectiveThinkingOptionId: this.#requestedThinkingOptionId,
|
|
61114
|
-
|
|
61386
|
+
// A live Claude Code keeps running a choice made before the catalog arrived; it stays
|
|
61387
|
+
// listed until the next Model switch fits it.
|
|
61388
|
+
availableThinkingOptions: CLAUDE_THINKING_OPTIONS.filter(({ id: id2 }) => !supported || supported.includes(id2) || id2 === this.#requestedThinkingOptionId),
|
|
61115
61389
|
effectivePermissionModeId: this.#requestedPermissionModeId
|
|
61116
61390
|
};
|
|
61117
61391
|
}
|
|
61392
|
+
#effectiveModelRef() {
|
|
61393
|
+
return this.#requestedModel ?? (this.#openMode === "create" ? CLAUDE_DEFAULT_MODEL_REF : this.#state.effectiveModel);
|
|
61394
|
+
}
|
|
61395
|
+
#supportedThinkingOptionIds(model2) {
|
|
61396
|
+
return catalogModelForRef(this.#modelCatalog(), model2)?.supportedThinkingOptionIds;
|
|
61397
|
+
}
|
|
61398
|
+
/**
|
|
61399
|
+
* Fits the requested Thinking to a catalog inspected after this Session opened, so the choice
|
|
61400
|
+
* Claude Code starts with is the one shown. A live Claude Code already runs the earlier choice.
|
|
61401
|
+
*/
|
|
61402
|
+
refitThinking(cwd) {
|
|
61403
|
+
if (this.#phase !== "open" || cwd !== this.#cwd || this.#transport)
|
|
61404
|
+
return;
|
|
61405
|
+
this.#requestedThinkingOptionId = fitClaudeThinkingOptionId(this.#requestedThinkingOptionId, this.#supportedThinkingOptionIds(this.#effectiveModelRef()));
|
|
61406
|
+
if (this.#state.effectiveThinkingOptionId === void 0)
|
|
61407
|
+
return;
|
|
61408
|
+
const state = this.#configuredState();
|
|
61409
|
+
if (state.effectiveThinkingOptionId !== this.#state.effectiveThinkingOptionId || !isDeepStrictEqual2(state.availableThinkingOptions, this.#state.availableThinkingOptions)) {
|
|
61410
|
+
this.#publishState(state);
|
|
61411
|
+
}
|
|
61412
|
+
}
|
|
61118
61413
|
#publishState(state = this.#state) {
|
|
61119
61414
|
this.#state = state;
|
|
61120
61415
|
this.#statePublished = true;
|
|
@@ -61139,6 +61434,8 @@ var ClaudeHarnessSession = class {
|
|
|
61139
61434
|
return;
|
|
61140
61435
|
switch (event.type) {
|
|
61141
61436
|
case "segment.started":
|
|
61437
|
+
if (event.mcpServers)
|
|
61438
|
+
this.#mcpServers = event.mcpServers;
|
|
61142
61439
|
this.#observeRootOutput(active);
|
|
61143
61440
|
if (active.cancellation && !active.cancellation.interrupting) {
|
|
61144
61441
|
this.#interruptCancelledSegment(active).catch(() => this.#hardCancel(active));
|
|
@@ -61567,6 +61864,7 @@ var ClaudeHarnessSession = class {
|
|
|
61567
61864
|
cwd: this.#cwd,
|
|
61568
61865
|
outputLimit: this.#toolOutputLimit,
|
|
61569
61866
|
taskTracker: this.#taskTracker,
|
|
61867
|
+
mcpServers: () => this.#mcpServers,
|
|
61570
61868
|
nativeTurnKey,
|
|
61571
61869
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
61572
61870
|
emit: (event) => this.#event(event),
|
|
@@ -62258,8 +62556,11 @@ var ClaudeCodeAdapter = class {
|
|
|
62258
62556
|
if (current)
|
|
62259
62557
|
return current;
|
|
62260
62558
|
const inspection = this.#inspectModels(cwd).then((result) => {
|
|
62261
|
-
if (result.status === "ready")
|
|
62559
|
+
if (result.status === "ready") {
|
|
62262
62560
|
this.#inspectionCache.set(cwd, result);
|
|
62561
|
+
for (const session of this.#sessions)
|
|
62562
|
+
session.refitThinking(cwd);
|
|
62563
|
+
}
|
|
62263
62564
|
return result;
|
|
62264
62565
|
});
|
|
62265
62566
|
this.#inspectionInFlight.set(cwd, inspection);
|
|
@@ -62541,6 +62842,10 @@ var ClaudeCodeAdapter = class {
|
|
|
62541
62842
|
...requestedModel ? { requestedModel } : {},
|
|
62542
62843
|
requestedPermissionModeId,
|
|
62543
62844
|
requestedThinkingOptionId,
|
|
62845
|
+
modelCatalog: () => {
|
|
62846
|
+
const inspection = this.#inspectionCache.get(cwd);
|
|
62847
|
+
return inspection?.status === "ready" ? inspection.catalog : void 0;
|
|
62848
|
+
},
|
|
62544
62849
|
toolOutputLimit: this.#toolOutputLimit,
|
|
62545
62850
|
cancelTimeoutMs: this.#cancelTimeoutMs,
|
|
62546
62851
|
continuationQuiescenceMs: this.#continuationQuiescenceMs
|