@codexhost/cli-linux-arm64 0.20.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 +27 -6
- package/app/console-web.js +35 -7
- package/app/desktop-controller.mjs +166 -52
- package/app/host-runtime.mjs +35350 -28799
- package/app/plugins/antigravity/assets/icon.svg +1 -1
- package/app/plugins/antigravity/plugin.mjs +411 -231
- package/app/plugins/claude-code/plugin.mjs +538 -109
- package/app/plugins/codebuddy/plugin.mjs +36 -6
- package/app/plugins/codex-usage/plugin.mjs +36 -6
- package/app/plugins/copilot/plugin.mjs +28 -6
- package/app/plugins/cursor-cli/plugin.mjs +28 -6
- package/app/plugins/deepseek-harness/plugin.mjs +53 -11
- package/app/plugins/devin/plugin.mjs +28 -6
- package/app/plugins/grok/plugin.mjs +255 -192
- package/app/plugins/hermes/plugin.mjs +28 -6
- package/app/plugins/kimi-code/plugin.mjs +53 -16
- package/app/plugins/kiro-cli/plugin.mjs +28 -6
- package/app/plugins/omp/plugin.mjs +143 -28
- package/app/plugins/opencode/plugin.mjs +54 -15
- package/app/plugins/pi/plugin.mjs +154 -29
- package/app/plugins/qoder/plugin.mjs +43 -6
- package/app/plugins/qoder-cn/plugin.mjs +43 -6
- package/app/plugins/qwen-code/plugin.mjs +28 -6
- package/app/plugins/workbuddy/plugin.mjs +36 -6
- package/app/plugins/zcode/plugin.mjs +36 -6
- package/app/renderer-extension.js +27 -6
- package/app/web/assets/index-CN4a4sj0.js +201 -0
- package/app/web/assets/{index-D6-hvggd.css → index-DJW4bmyx.css} +1 -1
- package/app/web/codexhost-settings.js +35 -7
- package/app/web/index.html +2 -2
- 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 +7 -7
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +6 -6
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +22 -22
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +2 -2
- package/app/web-modules/server.mjs +1123 -722
- 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-D85gPBbQ.js +0 -201
|
@@ -14663,7 +14663,7 @@ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonneg
|
|
|
14663
14663
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
14664
14664
|
var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
14665
14665
|
var usageOutputTimingSchema = external_exports.object({
|
|
14666
|
-
version: external_exports.literal(3).optional(),
|
|
14666
|
+
version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
|
|
14667
14667
|
requestId: external_exports.string().min(1),
|
|
14668
14668
|
turnId: external_exports.string().min(1).max(1024),
|
|
14669
14669
|
outputTokens: nonNegativeSafeIntegerSchema,
|
|
@@ -14671,16 +14671,16 @@ var usageOutputTimingSchema = external_exports.object({
|
|
|
14671
14671
|
completedAtMs: nonNegativeSafeIntegerSchema
|
|
14672
14672
|
}).strict().refine((value) => value.completedAtMs > value.startedAtMs);
|
|
14673
14673
|
var usageMeasurementSchema = external_exports.object({
|
|
14674
|
-
version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
|
|
14674
|
+
version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
|
|
14675
14675
|
value: finiteNonNegativeNumberSchema,
|
|
14676
14676
|
turnId: external_exports.string().min(1).max(1024),
|
|
14677
14677
|
at: nonNegativeSafeIntegerSchema
|
|
14678
14678
|
}).strict();
|
|
14679
14679
|
var usageMeasurementsSchema = external_exports.object({
|
|
14680
|
-
//
|
|
14681
|
-
outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version ===
|
|
14680
|
+
// Older intervals can omit hidden thinking time; do not restore them into averages.
|
|
14681
|
+
outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
|
|
14682
14682
|
// Retain independent TTFT facts when dropping incompatible speed measurements.
|
|
14683
|
-
outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version ===
|
|
14683
|
+
outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
|
|
14684
14684
|
timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
|
|
14685
14685
|
}).strict();
|
|
14686
14686
|
var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
|
|
@@ -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()) {
|
|
@@ -15146,6 +15151,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
15146
15151
|
cursor: clientChannelCursorSchema,
|
|
15147
15152
|
cwd: external_exports.string().optional()
|
|
15148
15153
|
}),
|
|
15154
|
+
external_exports.object({
|
|
15155
|
+
type: external_exports.literal("harness-inspection-changed"),
|
|
15156
|
+
cursor: clientChannelCursorSchema,
|
|
15157
|
+
harnessId: external_exports.string().min(1)
|
|
15158
|
+
}),
|
|
15149
15159
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
15150
15160
|
external_exports.object({
|
|
15151
15161
|
type: external_exports.literal("preferences-changed"),
|
|
@@ -15217,6 +15227,8 @@ var clientItemTruncationSchema = external_exports.object({
|
|
|
15217
15227
|
var clientTurnSchema = external_exports.object({
|
|
15218
15228
|
id: external_exports.string().min(1),
|
|
15219
15229
|
status: external_exports.string().min(1),
|
|
15230
|
+
/** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
|
|
15231
|
+
codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
|
|
15220
15232
|
items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
|
|
15221
15233
|
/** Original file operations, independent of the cumulative Desktop fileChange card.
|
|
15222
15234
|
* Insert before the named non-file Item; null appends at the end of the Turn.
|
|
@@ -16428,11 +16440,25 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16428
16440
|
status: updateStatusSchema.nullable()
|
|
16429
16441
|
});
|
|
16430
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
|
+
|
|
16431
16456
|
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
16432
16457
|
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
16433
16458
|
"completed",
|
|
16434
16459
|
"failed",
|
|
16435
16460
|
"interrupted",
|
|
16461
|
+
"needsInput",
|
|
16436
16462
|
"timedOut",
|
|
16437
16463
|
"unreadable",
|
|
16438
16464
|
"notFound"
|
|
@@ -16479,13 +16505,26 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
|
|
|
16479
16505
|
var thread = { ...target, threadId: identity };
|
|
16480
16506
|
var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
16481
16507
|
external_exports.strictObject({ kind: external_exports.literal("hosts") }),
|
|
16508
|
+
external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
|
|
16482
16509
|
external_exports.strictObject({
|
|
16483
16510
|
kind: external_exports.literal("list"),
|
|
16484
16511
|
...target,
|
|
16485
16512
|
cursor: external_exports.string().nullable(),
|
|
16486
16513
|
archived: external_exports.boolean()
|
|
16487
16514
|
}),
|
|
16488
|
-
external_exports.strictObject({
|
|
16515
|
+
external_exports.strictObject({
|
|
16516
|
+
kind: external_exports.literal("read"),
|
|
16517
|
+
...thread,
|
|
16518
|
+
page: external_exports.strictObject({
|
|
16519
|
+
cursor: external_exports.string().min(1).max(8192).nullable(),
|
|
16520
|
+
epoch: identity.optional(),
|
|
16521
|
+
sortDirection: external_exports.enum(["asc", "desc"]).optional(),
|
|
16522
|
+
limit: external_exports.number().int().min(1).max(20).optional()
|
|
16523
|
+
}).refine((page) => page.cursor === null || page.epoch !== void 0, {
|
|
16524
|
+
message: "A history continuation requires its connection epoch"
|
|
16525
|
+
}).optional()
|
|
16526
|
+
}),
|
|
16527
|
+
external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
|
|
16489
16528
|
external_exports.strictObject({
|
|
16490
16529
|
kind: external_exports.literal("configure"),
|
|
16491
16530
|
...thread,
|
|
@@ -16852,6 +16891,7 @@ var requestTokenFields = [
|
|
|
16852
16891
|
"cacheWrite1hInputTokens",
|
|
16853
16892
|
"outputTokens",
|
|
16854
16893
|
"reasoningOutputTokens",
|
|
16894
|
+
"timedOutputTokens",
|
|
16855
16895
|
"startedAtMs",
|
|
16856
16896
|
"completedAtMs"
|
|
16857
16897
|
];
|
|
@@ -16904,6 +16944,14 @@ function parseHostUsageRequest(value) {
|
|
|
16904
16944
|
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
16905
16945
|
throw new Error("Harness Usage request timing fields must be provided together");
|
|
16906
16946
|
}
|
|
16947
|
+
if (request.timedOutputTokens !== void 0) {
|
|
16948
|
+
if (request.startedAtMs === void 0) {
|
|
16949
|
+
throw new Error("Harness Usage request 'timedOutputTokens' requires timing fields");
|
|
16950
|
+
}
|
|
16951
|
+
if (request.timedOutputTokens > request.outputTokens) {
|
|
16952
|
+
throw new Error("Harness Usage request 'timedOutputTokens' must not exceed 'outputTokens'");
|
|
16953
|
+
}
|
|
16954
|
+
}
|
|
16907
16955
|
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
16908
16956
|
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
16909
16957
|
}
|
|
@@ -18573,6 +18621,7 @@ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix
|
|
|
18573
18621
|
// dist/claude-code-adapter.js
|
|
18574
18622
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
18575
18623
|
import path15 from "node:path";
|
|
18624
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
18576
18625
|
|
|
18577
18626
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
18578
18627
|
import { createRequire as jre } from "node:module";
|
|
@@ -55611,6 +55660,8 @@ function parseClaudeWorkflowAgents(value) {
|
|
|
55611
55660
|
var ClaudeNativeTurnAccumulator = class {
|
|
55612
55661
|
#provider;
|
|
55613
55662
|
#activeRootStreamMessageId = null;
|
|
55663
|
+
/** Native record UUIDs already published, across stream and request message IDs. */
|
|
55664
|
+
#publishedCheckpointIds = /* @__PURE__ */ new Set();
|
|
55614
55665
|
#assistantErrors = [];
|
|
55615
55666
|
#cancelRequested = false;
|
|
55616
55667
|
#compactionState = "idle";
|
|
@@ -55756,7 +55807,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55756
55807
|
if (message.type !== "system")
|
|
55757
55808
|
return;
|
|
55758
55809
|
if (message.subtype === "init") {
|
|
55759
|
-
|
|
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 } : {} });
|
|
55760
55812
|
return;
|
|
55761
55813
|
}
|
|
55762
55814
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
@@ -55947,6 +55999,25 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55947
55999
|
const messageId = this.#activeRootStreamMessageId ?? nativeMessageId ?? checkpointId ?? this.#nextMessageId();
|
|
55948
56000
|
const state = this.#messageState(messageId);
|
|
55949
56001
|
if (state.completed) {
|
|
56002
|
+
const splitText = checkpointId && !this.#publishedCheckpointIds.has(checkpointId) ? assistantText(message) : null;
|
|
56003
|
+
if (checkpointId && splitText) {
|
|
56004
|
+
this.#publishedCheckpointIds.add(checkpointId);
|
|
56005
|
+
state.text += splitText;
|
|
56006
|
+
events.push({ type: "text.delta", messageId, delta: splitText });
|
|
56007
|
+
this.#consumeToolUseBlocks(message, events, true);
|
|
56008
|
+
if (!this.#protocolConflict && !this.#textConflict) {
|
|
56009
|
+
const usage2 = state.usagePublished ? void 0 : assistantRequestUsage(message, this.#provider);
|
|
56010
|
+
if (usage2)
|
|
56011
|
+
state.usagePublished = true;
|
|
56012
|
+
events.push({
|
|
56013
|
+
type: "message.completed",
|
|
56014
|
+
messageId,
|
|
56015
|
+
checkpointId,
|
|
56016
|
+
...usage2 ? { lastRequestUsage: usage2 } : {}
|
|
56017
|
+
});
|
|
56018
|
+
}
|
|
56019
|
+
return;
|
|
56020
|
+
}
|
|
55950
56021
|
this.#consumeToolUseBlocks(message, events, true);
|
|
55951
56022
|
const usage = assistantRequestUsage(message, this.#provider);
|
|
55952
56023
|
if (usage && !state.usagePublished) {
|
|
@@ -55987,6 +56058,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55987
56058
|
});
|
|
55988
56059
|
}
|
|
55989
56060
|
state.completed = true;
|
|
56061
|
+
if (checkpointId)
|
|
56062
|
+
this.#publishedCheckpointIds.add(checkpointId);
|
|
55990
56063
|
if (this.#activeRootStreamMessageId === messageId)
|
|
55991
56064
|
this.#activeRootStreamMessageId = null;
|
|
55992
56065
|
}
|
|
@@ -56127,7 +56200,12 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56127
56200
|
const existing = this.#messages.get(messageId);
|
|
56128
56201
|
if (existing)
|
|
56129
56202
|
return existing;
|
|
56130
|
-
const created = {
|
|
56203
|
+
const created = {
|
|
56204
|
+
completed: false,
|
|
56205
|
+
reasoning: "",
|
|
56206
|
+
text: "",
|
|
56207
|
+
usagePublished: false
|
|
56208
|
+
};
|
|
56131
56209
|
this.#messages.set(messageId, created);
|
|
56132
56210
|
return created;
|
|
56133
56211
|
}
|
|
@@ -56137,6 +56215,31 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
56137
56215
|
}
|
|
56138
56216
|
};
|
|
56139
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
|
+
|
|
56140
56243
|
// dist/item-identity.js
|
|
56141
56244
|
function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
56142
56245
|
return hostItemIdSchema.parse(`claude-item-v2-${nativeTurnKey}-${kind}-${ordinal}`);
|
|
@@ -56151,14 +56254,41 @@ function readClaudeQueuedCommand(value, sessionId) {
|
|
|
56151
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) {
|
|
56152
56255
|
return null;
|
|
56153
56256
|
}
|
|
56154
|
-
|
|
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) {
|
|
56155
56259
|
throw new Error("Claude queued human input has an invalid identity or text prompt");
|
|
56156
56260
|
}
|
|
56157
|
-
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");
|
|
56158
56269
|
}
|
|
56159
56270
|
|
|
56160
56271
|
// dist/claude-history.js
|
|
56161
56272
|
var claudeCodeHarnessId = harnessIdSchema.parse("claude-code");
|
|
56273
|
+
var CLAUDE_BLOCK_SPLIT_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-0{8}[0-9a-f]{4}$/iu;
|
|
56274
|
+
function matchesClaudeCheckpointId(persistedId, expectedId) {
|
|
56275
|
+
if (persistedId === expectedId)
|
|
56276
|
+
return true;
|
|
56277
|
+
if (!CLAUDE_BLOCK_SPLIT_UUID_PATTERN.test(expectedId))
|
|
56278
|
+
return false;
|
|
56279
|
+
return persistedId.length === 36 && persistedId.slice(0, 24).toLowerCase() === expectedId.slice(0, 24).toLowerCase();
|
|
56280
|
+
}
|
|
56281
|
+
function isPersistedClaudeMessageId(expectedId, persistedIds) {
|
|
56282
|
+
if (persistedIds.has(expectedId))
|
|
56283
|
+
return true;
|
|
56284
|
+
if (!CLAUDE_BLOCK_SPLIT_UUID_PATTERN.test(expectedId))
|
|
56285
|
+
return false;
|
|
56286
|
+
for (const id2 of persistedIds) {
|
|
56287
|
+
if (matchesClaudeCheckpointId(id2, expectedId))
|
|
56288
|
+
return true;
|
|
56289
|
+
}
|
|
56290
|
+
return false;
|
|
56291
|
+
}
|
|
56162
56292
|
function isRecord9(value) {
|
|
56163
56293
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
56164
56294
|
}
|
|
@@ -56232,6 +56362,12 @@ function visibleUserTextParts(message) {
|
|
|
56232
56362
|
return [];
|
|
56233
56363
|
return parts.filter((part) => !isLocalCommandRecord(part) && !isTaskNotificationRecord(part));
|
|
56234
56364
|
}
|
|
56365
|
+
function hasRootToolResult(message) {
|
|
56366
|
+
if (message.type !== "user" || message.nested || !Array.isArray(message.message.content)) {
|
|
56367
|
+
return false;
|
|
56368
|
+
}
|
|
56369
|
+
return message.message.content.some((block) => isRecord9(block) && block.type === "tool_result");
|
|
56370
|
+
}
|
|
56235
56371
|
function isInterruptionRecord(value, promptId) {
|
|
56236
56372
|
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord9(value.message))
|
|
56237
56373
|
return false;
|
|
@@ -56291,7 +56427,7 @@ function conversationMessages(values, sessionId) {
|
|
|
56291
56427
|
interrupted,
|
|
56292
56428
|
startsTurn: false,
|
|
56293
56429
|
...isRecord9(value.forkedFrom) && typeof value.forkedFrom.messageUuid === "string" ? { forkSourceUuid: value.forkedFrom.messageUuid } : {},
|
|
56294
|
-
syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
|
|
56430
|
+
syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || value.isCompactSummary === true || value.isVisibleInTranscriptOnly === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
|
|
56295
56431
|
};
|
|
56296
56432
|
const notification = message.type === "user" && !message.nested && (isTaskNotificationOrigin(value) || textParts(message.message.content).some(isTaskNotificationRecord));
|
|
56297
56433
|
message.startsTurn = isHumanUser(message) || notification && !occupancy.unsettled && !pendingNotification;
|
|
@@ -56397,9 +56533,16 @@ function itemOutcome(outcome) {
|
|
|
56397
56533
|
}
|
|
56398
56534
|
return { status: "succeeded" };
|
|
56399
56535
|
}
|
|
56400
|
-
function
|
|
56536
|
+
function isCheckpointCandidate(message) {
|
|
56537
|
+
return !message.nested && (message.type === "assistant" || message.interrupted || hasRootToolResult(message));
|
|
56538
|
+
}
|
|
56539
|
+
function mapClaudeSnapshot(values, sessionId, mcpServers) {
|
|
56540
|
+
return mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers).snapshot;
|
|
56541
|
+
}
|
|
56542
|
+
function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers) {
|
|
56401
56543
|
const messages = conversationMessages(values, sessionId);
|
|
56402
56544
|
const turns = [];
|
|
56545
|
+
const turnCheckpointIds = [];
|
|
56403
56546
|
for (let index = 0; index < messages.length; ) {
|
|
56404
56547
|
const user = messages[index];
|
|
56405
56548
|
if (!user || !user.startsTurn) {
|
|
@@ -56414,12 +56557,13 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
56414
56557
|
const turnMessages = messages.slice(index, end);
|
|
56415
56558
|
const outcome = turnOutcome(turnMessages);
|
|
56416
56559
|
const results = toolResultBlocks(turnMessages);
|
|
56417
|
-
const checkpointIndex = turnMessages.findLastIndex(
|
|
56560
|
+
const checkpointIndex = turnMessages.findLastIndex(isCheckpointCandidate);
|
|
56418
56561
|
const lastSteering = turnMessages.findLastIndex(({ type }) => type === "steering");
|
|
56419
56562
|
const checkpointMessage = checkpointIndex > lastSteering ? turnMessages[checkpointIndex] : void 0;
|
|
56420
56563
|
let agentMessageOrdinal = 0;
|
|
56421
56564
|
let reasoningOrdinal = 0;
|
|
56422
56565
|
let toolOrdinal = 0;
|
|
56566
|
+
turnCheckpointIds.push(turnMessages.filter(isCheckpointCandidate).map((message) => message.uuid));
|
|
56423
56567
|
turns.push({
|
|
56424
56568
|
nativeTurnRef: nativeTurnRefSchema.parse({
|
|
56425
56569
|
harnessId: claudeCodeHarnessId,
|
|
@@ -56545,15 +56689,8 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
56545
56689
|
});
|
|
56546
56690
|
continue;
|
|
56547
56691
|
}
|
|
56548
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56549
56692
|
items.push({
|
|
56550
|
-
item:
|
|
56551
|
-
type: "toolExecution",
|
|
56552
|
-
itemId,
|
|
56553
|
-
toolName: block.name,
|
|
56554
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56555
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56556
|
-
},
|
|
56693
|
+
item: historyToolItem(itemId, block.name, block.input, output, mcpServers),
|
|
56557
56694
|
outcome: toolOutcome
|
|
56558
56695
|
});
|
|
56559
56696
|
}
|
|
@@ -56563,7 +56700,12 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
56563
56700
|
});
|
|
56564
56701
|
index = end;
|
|
56565
56702
|
}
|
|
56566
|
-
return { turns };
|
|
56703
|
+
return { snapshot: { turns }, turnCheckpointIds };
|
|
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;
|
|
56567
56709
|
}
|
|
56568
56710
|
function toolResultBlocks(messages) {
|
|
56569
56711
|
const results = /* @__PURE__ */ new Map();
|
|
@@ -56698,15 +56840,8 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
56698
56840
|
});
|
|
56699
56841
|
continue;
|
|
56700
56842
|
}
|
|
56701
|
-
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
56702
56843
|
items.push({
|
|
56703
|
-
item:
|
|
56704
|
-
type: "toolExecution",
|
|
56705
|
-
itemId,
|
|
56706
|
-
toolName: block.name,
|
|
56707
|
-
arguments: argumentsResult.success ? argumentsResult.data : null,
|
|
56708
|
-
...output ? { output: { content: [{ type: "text", text: output }] } } : {}
|
|
56709
|
-
},
|
|
56844
|
+
item: historyToolItem(itemId, block.name, block.input, output),
|
|
56710
56845
|
outcome: toolOutcome
|
|
56711
56846
|
});
|
|
56712
56847
|
}
|
|
@@ -56762,6 +56897,10 @@ function nativeIds(snapshot) {
|
|
|
56762
56897
|
]));
|
|
56763
56898
|
}
|
|
56764
56899
|
async function readSnapshot(dependencies, cwd, sessionId) {
|
|
56900
|
+
const history = await readHistory(dependencies, cwd, sessionId);
|
|
56901
|
+
return history.ok ? { ok: true, value: history.value.snapshot } : history;
|
|
56902
|
+
}
|
|
56903
|
+
async function readHistory(dependencies, cwd, sessionId) {
|
|
56765
56904
|
let messages;
|
|
56766
56905
|
try {
|
|
56767
56906
|
messages = await dependencies.readSessionMessages({ cwd, sessionId }) ?? [];
|
|
@@ -56778,7 +56917,7 @@ async function readSnapshot(dependencies, cwd, sessionId) {
|
|
|
56778
56917
|
};
|
|
56779
56918
|
}
|
|
56780
56919
|
try {
|
|
56781
|
-
return { ok: true, value:
|
|
56920
|
+
return { ok: true, value: mapClaudeSnapshotWithCheckpointIds(messages, sessionId) };
|
|
56782
56921
|
} catch {
|
|
56783
56922
|
return {
|
|
56784
56923
|
ok: false,
|
|
@@ -56818,9 +56957,10 @@ async function forkClaudeSession(input) {
|
|
|
56818
56957
|
error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
|
|
56819
56958
|
};
|
|
56820
56959
|
}
|
|
56821
|
-
const
|
|
56822
|
-
if (!
|
|
56823
|
-
return
|
|
56960
|
+
const sourceHistory = await readHistory(input.dependencies, input.cwd, sourceRef.data.nativeSessionId);
|
|
56961
|
+
if (!sourceHistory.ok)
|
|
56962
|
+
return sourceHistory;
|
|
56963
|
+
const source = { ok: true, value: sourceHistory.value.snapshot };
|
|
56824
56964
|
if (input.kind === "rollbackLastTurn" && source.value.turns.length === 0) {
|
|
56825
56965
|
return {
|
|
56826
56966
|
ok: false,
|
|
@@ -56850,7 +56990,12 @@ async function forkClaudeSession(input) {
|
|
|
56850
56990
|
value: { sessionId: nativeRef.nativeSessionId, nativeRef, openMode: "create" }
|
|
56851
56991
|
};
|
|
56852
56992
|
}
|
|
56853
|
-
const boundaryIndex = input.kind === "rollbackLastTurn" ? source.value.turns.length - 2 :
|
|
56993
|
+
const boundaryIndex = input.kind === "rollbackLastTurn" ? source.value.turns.length - 2 : (
|
|
56994
|
+
// A live checkpoint names the last root Assistant record seen while the Turn ran;
|
|
56995
|
+
// the persisted Turn checkpoint can be a later root tool_result of the same Turn.
|
|
56996
|
+
// Fork at that Turn's final checkpoint so the native prefix keeps the whole Turn.
|
|
56997
|
+
sourceHistory.value.turnCheckpointIds.findIndex((ids, index) => checkpoint?.success && source.value.turns[index]?.checkpoint !== void 0 && ids.some((id2) => matchesClaudeCheckpointId(id2, checkpoint.data.checkpointId)))
|
|
56998
|
+
);
|
|
56854
56999
|
const retained = source.value.turns[boundaryIndex];
|
|
56855
57000
|
const boundaryId = retained?.checkpoint?.checkpointId ?? (input.kind === "rollbackLastTurn" ? retained?.nativeTurnRef.nativeTurnKey : void 0);
|
|
56856
57001
|
if (boundaryIndex < 0 || !boundaryId) {
|
|
@@ -56913,12 +57058,13 @@ async function forkClaudeSession(input) {
|
|
|
56913
57058
|
|
|
56914
57059
|
// dist/claude-fork-references.js
|
|
56915
57060
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
56916
|
-
import { readFile as
|
|
57061
|
+
import { readFile as readFile5, rename as rename4, rm as rm5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
|
|
56917
57062
|
|
|
56918
57063
|
// dist/claude-transcript.js
|
|
57064
|
+
import { createReadStream as createReadStream4 } from "node:fs";
|
|
56919
57065
|
import os6 from "node:os";
|
|
56920
57066
|
import path12 from "node:path";
|
|
56921
|
-
import {
|
|
57067
|
+
import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
56922
57068
|
function projectDirectoryName(cwd) {
|
|
56923
57069
|
return cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
56924
57070
|
}
|
|
@@ -56951,6 +57097,28 @@ async function findClaudeTranscript(input) {
|
|
|
56951
57097
|
}
|
|
56952
57098
|
return null;
|
|
56953
57099
|
}
|
|
57100
|
+
async function* transcriptLines(transcript) {
|
|
57101
|
+
const stream = createReadStream4(transcript, { encoding: "utf8" });
|
|
57102
|
+
let pending = "";
|
|
57103
|
+
try {
|
|
57104
|
+
for await (const chunk of stream) {
|
|
57105
|
+
const contents = chunk;
|
|
57106
|
+
let start = 0;
|
|
57107
|
+
let newline;
|
|
57108
|
+
while ((newline = contents.indexOf("\n", start)) !== -1) {
|
|
57109
|
+
const line = pending + contents.slice(start, newline);
|
|
57110
|
+
pending = "";
|
|
57111
|
+
yield line;
|
|
57112
|
+
start = newline + 1;
|
|
57113
|
+
}
|
|
57114
|
+
pending += contents.slice(start);
|
|
57115
|
+
}
|
|
57116
|
+
if (pending.length > 0)
|
|
57117
|
+
yield pending;
|
|
57118
|
+
} finally {
|
|
57119
|
+
stream.destroy();
|
|
57120
|
+
}
|
|
57121
|
+
}
|
|
56954
57122
|
function isRecord10(value) {
|
|
56955
57123
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
56956
57124
|
}
|
|
@@ -56958,9 +57126,8 @@ async function readClaudeTranscript(input) {
|
|
|
56958
57126
|
const transcript = await findClaudeTranscript(input);
|
|
56959
57127
|
if (!transcript)
|
|
56960
57128
|
return null;
|
|
56961
|
-
const contents = await readFile5(transcript, "utf8");
|
|
56962
57129
|
const messages = /* @__PURE__ */ new Map();
|
|
56963
|
-
for (const line of
|
|
57130
|
+
for await (const line of transcriptLines(transcript)) {
|
|
56964
57131
|
if (line.trim().length === 0)
|
|
56965
57132
|
continue;
|
|
56966
57133
|
let entry;
|
|
@@ -57013,7 +57180,7 @@ async function remapForkedSessionReferences(input) {
|
|
|
57013
57180
|
const transcript = await findClaudeTranscript(input);
|
|
57014
57181
|
if (!transcript)
|
|
57015
57182
|
return 0;
|
|
57016
|
-
const contents = await
|
|
57183
|
+
const contents = await readFile5(transcript, "utf8");
|
|
57017
57184
|
if (!contents.includes('"sameAs"'))
|
|
57018
57185
|
return 0;
|
|
57019
57186
|
const lines = contents.split("\n");
|
|
@@ -57053,7 +57220,7 @@ async function remapForkedSessionReferences(input) {
|
|
|
57053
57220
|
|
|
57054
57221
|
// dist/model-catalog.js
|
|
57055
57222
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
57056
|
-
import { readFile as
|
|
57223
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
57057
57224
|
import os7 from "node:os";
|
|
57058
57225
|
import path13 from "node:path";
|
|
57059
57226
|
|
|
@@ -57075,6 +57242,37 @@ var CLAUDE_THINKING_OPTIONS = [
|
|
|
57075
57242
|
];
|
|
57076
57243
|
var CLAUDE_THINKING_OPTION_IDS = CLAUDE_THINKING_OPTIONS.map(({ id: id2 }) => id2);
|
|
57077
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
|
+
}
|
|
57078
57276
|
function parseClaudeThinkingOptionId(value) {
|
|
57079
57277
|
const id2 = harnessThinkingOptionIdSchema.parse(value);
|
|
57080
57278
|
if (!CLAUDE_THINKING_OPTION_IDS.includes(id2)) {
|
|
@@ -57106,8 +57304,14 @@ var CLAUDE_MODEL_VALUE_MAX_LENGTH = 512;
|
|
|
57106
57304
|
var modelInfoSchema = external_exports.object({
|
|
57107
57305
|
value: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
57108
57306
|
displayName: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
57109
|
-
description: external_exports.string().trim().
|
|
57110
|
-
resolvedModel: harnessResolvedModelLabelSchema.optional()
|
|
57307
|
+
description: external_exports.string().trim().max(HARNESS_MODEL_LABEL_MAX_LENGTH).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)
|
|
57111
57315
|
});
|
|
57112
57316
|
var modelPickerOptionSchema = external_exports.object({
|
|
57113
57317
|
model: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
|
|
@@ -57193,7 +57397,7 @@ async function readClaudeUserModelPicker(environment = process.env) {
|
|
|
57193
57397
|
const settingsPath = path13.join(resolveClaudeConfigDirectory(environment), "settings.json");
|
|
57194
57398
|
let raw;
|
|
57195
57399
|
try {
|
|
57196
|
-
raw = await
|
|
57400
|
+
raw = await readFile6(settingsPath, "utf8");
|
|
57197
57401
|
} catch {
|
|
57198
57402
|
return void 0;
|
|
57199
57403
|
}
|
|
@@ -57290,12 +57494,17 @@ function uniqueDisplayLabels(rows) {
|
|
|
57290
57494
|
}
|
|
57291
57495
|
return labels;
|
|
57292
57496
|
}
|
|
57497
|
+
function canonicalRow(row) {
|
|
57498
|
+
if (row.supportedEffortLevels === void 0)
|
|
57499
|
+
return row;
|
|
57500
|
+
return { ...row, supportedEffortLevels: [...new Set(row.supportedEffortLevels)].sort() };
|
|
57501
|
+
}
|
|
57293
57502
|
function normalizeRows(value) {
|
|
57294
57503
|
if (!Array.isArray(value))
|
|
57295
57504
|
throw new Error("Claude Code Model catalog is not an array");
|
|
57296
57505
|
const byValue = /* @__PURE__ */ new Map();
|
|
57297
57506
|
for (const nativeRow of value) {
|
|
57298
|
-
const row = modelInfoSchema.parse(nativeRow);
|
|
57507
|
+
const row = canonicalRow(modelInfoSchema.parse(nativeRow));
|
|
57299
57508
|
const existing = byValue.get(row.value);
|
|
57300
57509
|
if (existing && JSON.stringify(existing) !== JSON.stringify(row)) {
|
|
57301
57510
|
throw new Error("Claude Code Model catalog contains conflicting selectable values");
|
|
@@ -57320,7 +57529,7 @@ function normalizeClaudeModelCatalog(snapshot) {
|
|
|
57320
57529
|
ref: encodeClaudeModelRef(row.value),
|
|
57321
57530
|
label: labels.get(row.value) ?? row.displayName,
|
|
57322
57531
|
...row.resolvedModel ? { resolvedModelLabel: row.resolvedModel } : {},
|
|
57323
|
-
supportedThinkingOptionIds:
|
|
57532
|
+
supportedThinkingOptionIds: claudeSupportedThinkingOptionIds(row)
|
|
57324
57533
|
};
|
|
57325
57534
|
});
|
|
57326
57535
|
models.sort((left, right) => {
|
|
@@ -57937,7 +58146,10 @@ var ClaudeSdkTransport = class {
|
|
|
57937
58146
|
// Adaptive Thinking is redacted by default: the API streams `thinking_delta`
|
|
57938
58147
|
// frames carrying only token estimates and empty text, so no Reasoning Item
|
|
57939
58148
|
// would ever start. Summarized display is the official channel for readable
|
|
57940
|
-
// 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.
|
|
57941
58153
|
thinking: thinking.enabled ? { type: "adaptive", display: "summarized" } : { type: "disabled" },
|
|
57942
58154
|
...thinking.effort ? { effort: thinking.effort } : {},
|
|
57943
58155
|
pathToClaudeCodeExecutable: executable,
|
|
@@ -58040,13 +58252,23 @@ var ClaudeSdkTransport = class {
|
|
|
58040
58252
|
throw new Error("Claude SDK transport is not started");
|
|
58041
58253
|
return this.#permissionMode;
|
|
58042
58254
|
}
|
|
58043
|
-
async setModel(model2) {
|
|
58255
|
+
async setModel(model2, thinkingOptionId = this.#thinkingOptionId) {
|
|
58044
58256
|
const activeQuery = this.#query;
|
|
58045
58257
|
if (!this.#started || !activeQuery)
|
|
58046
58258
|
throw new Error("Claude SDK transport is not started");
|
|
58047
|
-
const
|
|
58259
|
+
const id2 = parseClaudeThinkingOptionId(thinkingOptionId);
|
|
58260
|
+
const previous = claudeThinkingConfiguration(this.#thinkingOptionId);
|
|
58261
|
+
const thinking = claudeThinkingConfiguration(id2);
|
|
58048
58262
|
const previousModel = this.#currentModel;
|
|
58049
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
|
+
}
|
|
58050
58272
|
if (thinking.ultracode) {
|
|
58051
58273
|
try {
|
|
58052
58274
|
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(thinking, thinking));
|
|
@@ -58054,13 +58276,14 @@ var ClaudeSdkTransport = class {
|
|
|
58054
58276
|
} catch (error52) {
|
|
58055
58277
|
await this.#restoreOrFault(async () => {
|
|
58056
58278
|
await activeQuery.setModel(previousModel);
|
|
58057
|
-
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(
|
|
58058
|
-
await this.#verifyUltracode(activeQuery);
|
|
58279
|
+
await activeQuery.applyFlagSettings(claudeThinkingFlagSettings(previous, thinking));
|
|
58280
|
+
await (previous.ultracode ? this.#verifyUltracode(activeQuery) : this.#verifyUltracodeOff(activeQuery));
|
|
58059
58281
|
});
|
|
58060
58282
|
throw error52;
|
|
58061
58283
|
}
|
|
58062
58284
|
}
|
|
58063
58285
|
this.#currentModel = model2;
|
|
58286
|
+
this.#thinkingOptionId = id2;
|
|
58064
58287
|
}
|
|
58065
58288
|
async setThinkingOption(thinkingOptionId) {
|
|
58066
58289
|
const activeQuery = this.#query;
|
|
@@ -58132,7 +58355,7 @@ var ClaudeSdkTransport = class {
|
|
|
58132
58355
|
recap(userMessageId, onEvent) {
|
|
58133
58356
|
return this.runTurn("/recap", userMessageId, onEvent);
|
|
58134
58357
|
}
|
|
58135
|
-
runTurn(
|
|
58358
|
+
runTurn(content, userMessageId, onEvent) {
|
|
58136
58359
|
if (this.#closePromise || !this.#started || !this.#query) {
|
|
58137
58360
|
return Promise.reject(new Error("Claude SDK transport is not started"));
|
|
58138
58361
|
}
|
|
@@ -58154,7 +58377,7 @@ var ClaudeSdkTransport = class {
|
|
|
58154
58377
|
onEvent(event);
|
|
58155
58378
|
this.#input.push({
|
|
58156
58379
|
type: "user",
|
|
58157
|
-
message: { role: "user", content
|
|
58380
|
+
message: { role: "user", content },
|
|
58158
58381
|
parent_tool_use_id: null,
|
|
58159
58382
|
session_id: this.sessionId,
|
|
58160
58383
|
uuid: userMessageId,
|
|
@@ -58171,7 +58394,7 @@ var ClaudeSdkTransport = class {
|
|
|
58171
58394
|
* The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
|
|
58172
58395
|
* after a bounded wait so callers that serialize requests are never held indefinitely.
|
|
58173
58396
|
*/
|
|
58174
|
-
steer(
|
|
58397
|
+
steer(content, messageId, onTakeover) {
|
|
58175
58398
|
if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
|
|
58176
58399
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
58177
58400
|
}
|
|
@@ -58181,7 +58404,7 @@ var ClaudeSdkTransport = class {
|
|
|
58181
58404
|
try {
|
|
58182
58405
|
this.#input.push({
|
|
58183
58406
|
type: "user",
|
|
58184
|
-
message: { role: "user", content
|
|
58407
|
+
message: { role: "user", content },
|
|
58185
58408
|
parent_tool_use_id: null,
|
|
58186
58409
|
session_id: this.sessionId,
|
|
58187
58410
|
uuid: messageId,
|
|
@@ -59428,6 +59651,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59428
59651
|
#onDetached;
|
|
59429
59652
|
#outputLimit;
|
|
59430
59653
|
#taskTracker;
|
|
59654
|
+
#mcpServers;
|
|
59431
59655
|
#nativeTurnKey;
|
|
59432
59656
|
#tools = /* @__PURE__ */ new Map();
|
|
59433
59657
|
#toolOrdinal = 0;
|
|
@@ -59438,6 +59662,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59438
59662
|
this.#onDetached = options.onDetached;
|
|
59439
59663
|
this.#outputLimit = options.outputLimit;
|
|
59440
59664
|
this.#taskTracker = options.taskTracker;
|
|
59665
|
+
this.#mcpServers = options.mcpServers ?? (() => []);
|
|
59441
59666
|
this.#nativeTurnKey = options.nativeTurnKey;
|
|
59442
59667
|
}
|
|
59443
59668
|
get size() {
|
|
@@ -59453,12 +59678,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59453
59678
|
itemId,
|
|
59454
59679
|
command,
|
|
59455
59680
|
cwd: this.#cwd
|
|
59456
|
-
} : {
|
|
59457
|
-
type: "toolExecution",
|
|
59458
|
-
itemId,
|
|
59459
|
-
toolName: isClaudeTaskTool(event.toolName) ? "Todo" : event.toolName,
|
|
59460
|
-
arguments: isClaudeTaskTool(event.toolName) ? {} : event.arguments
|
|
59461
|
-
};
|
|
59681
|
+
} : isClaudeTaskTool(event.toolName) ? { type: "toolExecution", itemId, toolName: "Todo", arguments: {} } : claudeToolItem(itemId, event.toolName, event.arguments, this.#mcpServers());
|
|
59462
59682
|
this.#tools.set(event.callId, {
|
|
59463
59683
|
item,
|
|
59464
59684
|
nativeName: event.toolName,
|
|
@@ -59503,6 +59723,8 @@ var ClaudeToolLifecycle = class {
|
|
|
59503
59723
|
} : {},
|
|
59504
59724
|
durationMs
|
|
59505
59725
|
};
|
|
59726
|
+
} else if (tool.item.type === "webSearch") {
|
|
59727
|
+
tool.item = { ...tool.item, ...output ? { output } : {} };
|
|
59506
59728
|
} else {
|
|
59507
59729
|
tool.item = { ...tool.item, ...output ? { output } : {}, durationMs };
|
|
59508
59730
|
}
|
|
@@ -59531,7 +59753,7 @@ var ClaudeToolLifecycle = class {
|
|
|
59531
59753
|
for (const [callId, tool] of this.#tools) {
|
|
59532
59754
|
this.#tools.delete(callId);
|
|
59533
59755
|
const durationMs = Math.max(tool.elapsedMs, Date.now() - tool.startedAtMs, 0);
|
|
59534
|
-
this.#completeItem(turnId, { ...tool.item, durationMs }, outcome);
|
|
59756
|
+
this.#completeItem(turnId, tool.item.type === "webSearch" ? tool.item : { ...tool.item, durationMs }, outcome);
|
|
59535
59757
|
}
|
|
59536
59758
|
}
|
|
59537
59759
|
#completeItem(turnId, item, outcome) {
|
|
@@ -59583,6 +59805,135 @@ function estimateClaudeRequestCostUsd(usage) {
|
|
|
59583
59805
|
return Number.isFinite(cost) && cost >= 0 ? cost : void 0;
|
|
59584
59806
|
}
|
|
59585
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
|
+
|
|
59586
59937
|
// dist/claude-code-adapter.js
|
|
59587
59938
|
var claudeCodeHarnessId2 = harnessIdSchema.parse("claude-code");
|
|
59588
59939
|
var claudeCommandCatalog = harnessCommandCatalogSchema.parse({
|
|
@@ -59670,6 +60021,7 @@ var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
|
|
|
59670
60021
|
function isRecord15(value) {
|
|
59671
60022
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59672
60023
|
}
|
|
60024
|
+
var SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN = /^autonomous-\d+$/u;
|
|
59673
60025
|
function safeNonNegativeInteger2(value) {
|
|
59674
60026
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
59675
60027
|
}
|
|
@@ -59873,12 +60225,16 @@ var ClaudeHarnessSession = class {
|
|
|
59873
60225
|
#requestedModel;
|
|
59874
60226
|
#requestedPermissionModeId;
|
|
59875
60227
|
#requestedThinkingOptionId;
|
|
60228
|
+
/** This Session's folder's inspected catalog, which says what Thinking each Model accepts. */
|
|
60229
|
+
#modelCatalog;
|
|
59876
60230
|
#readSessionMessages;
|
|
59877
60231
|
#sessionId;
|
|
59878
60232
|
#toolOutputLimit;
|
|
59879
60233
|
#backgroundCommands;
|
|
59880
60234
|
#continuationQuiescenceMs;
|
|
59881
60235
|
#taskTracker = new ClaudeTaskTracker();
|
|
60236
|
+
/** MCP server names the latest native Segment reported; they disambiguate MCP Tool names. */
|
|
60237
|
+
#mcpServers = [];
|
|
59882
60238
|
#acceptingTurn = false;
|
|
59883
60239
|
#active = null;
|
|
59884
60240
|
#closePromise = null;
|
|
@@ -59930,7 +60286,8 @@ var ClaudeHarnessSession = class {
|
|
|
59930
60286
|
this.#openMode = options.openMode;
|
|
59931
60287
|
this.#requestedModel = options.requestedModel;
|
|
59932
60288
|
this.#requestedPermissionModeId = options.requestedPermissionModeId;
|
|
59933
|
-
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)));
|
|
59934
60291
|
this.#sessionId = options.sessionId;
|
|
59935
60292
|
this.#toolOutputLimit = options.toolOutputLimit;
|
|
59936
60293
|
this.#backgroundCommands = new ClaudeBackgroundCommandItems({
|
|
@@ -59998,39 +60355,56 @@ var ClaudeHarnessSession = class {
|
|
|
59998
60355
|
this.#readingHistory = true;
|
|
59999
60356
|
try {
|
|
60000
60357
|
let messages;
|
|
60001
|
-
|
|
60002
|
-
|
|
60003
|
-
|
|
60358
|
+
const deadline = Date.now() + this.#closeTimeoutMs;
|
|
60359
|
+
for (; ; ) {
|
|
60360
|
+
try {
|
|
60004
60361
|
messages = await this.#readSessionMessages({
|
|
60005
60362
|
cwd: this.#cwd,
|
|
60006
60363
|
sessionId: this.#sessionId
|
|
60007
60364
|
}) ?? [];
|
|
60008
|
-
|
|
60009
|
-
|
|
60010
|
-
|
|
60011
|
-
|
|
60012
|
-
|
|
60013
|
-
|
|
60014
|
-
|
|
60015
|
-
|
|
60016
|
-
|
|
60017
|
-
code: "sessionBusy",
|
|
60018
|
-
message: "Claude Code history is still being persisted",
|
|
60019
|
-
retryable: true
|
|
60020
|
-
}
|
|
60021
|
-
};
|
|
60022
|
-
}
|
|
60023
|
-
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
|
+
};
|
|
60024
60374
|
}
|
|
60025
|
-
|
|
60026
|
-
|
|
60027
|
-
|
|
60028
|
-
|
|
60029
|
-
|
|
60030
|
-
|
|
60031
|
-
|
|
60032
|
-
}
|
|
60033
|
-
}
|
|
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);
|
|
60034
60408
|
}
|
|
60035
60409
|
if (messages.length === 0 && isPendingClaudeSession(this.#nativeRef)) {
|
|
60036
60410
|
try {
|
|
@@ -60061,7 +60435,10 @@ var ClaudeHarnessSession = class {
|
|
|
60061
60435
|
try {
|
|
60062
60436
|
return {
|
|
60063
60437
|
ok: true,
|
|
60064
|
-
value: {
|
|
60438
|
+
value: {
|
|
60439
|
+
...mapClaudeSnapshot(messages, this.#sessionId, this.#mcpServers),
|
|
60440
|
+
state: this.#state
|
|
60441
|
+
}
|
|
60065
60442
|
};
|
|
60066
60443
|
} catch {
|
|
60067
60444
|
return {
|
|
@@ -60115,6 +60492,7 @@ var ClaudeHarnessSession = class {
|
|
|
60115
60492
|
};
|
|
60116
60493
|
}
|
|
60117
60494
|
this.#acceptingTurn = true;
|
|
60495
|
+
const content = await claudeUserContent(text2);
|
|
60118
60496
|
const startingTransport = this.#transport === null;
|
|
60119
60497
|
let transport;
|
|
60120
60498
|
try {
|
|
@@ -60173,6 +60551,7 @@ var ClaudeHarnessSession = class {
|
|
|
60173
60551
|
cwd: this.#cwd,
|
|
60174
60552
|
outputLimit: this.#toolOutputLimit,
|
|
60175
60553
|
taskTracker: this.#taskTracker,
|
|
60554
|
+
mcpServers: () => this.#mcpServers,
|
|
60176
60555
|
nativeTurnKey,
|
|
60177
60556
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60178
60557
|
emit: (event) => this.#event(event),
|
|
@@ -60211,7 +60590,7 @@ var ClaudeHarnessSession = class {
|
|
|
60211
60590
|
nativeTurnKey,
|
|
60212
60591
|
formatVersion: 1
|
|
60213
60592
|
});
|
|
60214
|
-
const running = transport.runTurn(
|
|
60593
|
+
const running = transport.runTurn(content, nativeTurnRef.nativeTurnKey, (event) => {
|
|
60215
60594
|
this.#handleTurnEvent(active, event);
|
|
60216
60595
|
});
|
|
60217
60596
|
active.userMessageId = nativeTurnRef.nativeTurnKey;
|
|
@@ -60223,13 +60602,6 @@ var ClaudeHarnessSession = class {
|
|
|
60223
60602
|
return { ok: true, value: { turnId: command.turnId } };
|
|
60224
60603
|
}
|
|
60225
60604
|
async #steer(command) {
|
|
60226
|
-
const active = this.#active;
|
|
60227
|
-
if (!active || active.command.turnId !== command.turnId) {
|
|
60228
|
-
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
60229
|
-
}
|
|
60230
|
-
if (active.cancellationRequested) {
|
|
60231
|
-
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
60232
|
-
}
|
|
60233
60605
|
const text2 = command.input.map((input) => input.text).join("\n");
|
|
60234
60606
|
if (text2.length === 0) {
|
|
60235
60607
|
return {
|
|
@@ -60241,6 +60613,14 @@ var ClaudeHarnessSession = class {
|
|
|
60241
60613
|
}
|
|
60242
60614
|
};
|
|
60243
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
|
+
}
|
|
60244
60624
|
const transport = this.#transport;
|
|
60245
60625
|
if (!transport) {
|
|
60246
60626
|
return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
|
|
@@ -60258,7 +60638,7 @@ var ClaudeHarnessSession = class {
|
|
|
60258
60638
|
const messageId = this.#randomUUID();
|
|
60259
60639
|
active.steersAwaitingNative.add(messageId);
|
|
60260
60640
|
try {
|
|
60261
|
-
await transport.steer(
|
|
60641
|
+
await transport.steer(content, messageId, (started) => this.#takeOverSteer(active, messageId, started));
|
|
60262
60642
|
} catch (error52) {
|
|
60263
60643
|
if (error52 instanceof ClaudeSteerMissedTurnError) {
|
|
60264
60644
|
this.#takeOverSteer(active, messageId, false);
|
|
@@ -60351,6 +60731,7 @@ var ClaudeHarnessSession = class {
|
|
|
60351
60731
|
cwd: this.#cwd,
|
|
60352
60732
|
outputLimit: this.#toolOutputLimit,
|
|
60353
60733
|
taskTracker: this.#taskTracker,
|
|
60734
|
+
mcpServers: () => this.#mcpServers,
|
|
60354
60735
|
nativeTurnKey,
|
|
60355
60736
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
60356
60737
|
emit: (event) => this.#event(event),
|
|
@@ -60467,10 +60848,11 @@ var ClaudeHarnessSession = class {
|
|
|
60467
60848
|
resolveConfiguration = resolve5;
|
|
60468
60849
|
});
|
|
60469
60850
|
try {
|
|
60851
|
+
const thinkingOptionId = fitClaudeThinkingOptionId(this.#requestedThinkingOptionId, this.#supportedThinkingOptionIds(command.model));
|
|
60470
60852
|
const transport = this.#transport;
|
|
60471
60853
|
if (transport) {
|
|
60472
60854
|
try {
|
|
60473
|
-
await transport.setModel(model2);
|
|
60855
|
+
await transport.setModel(model2, thinkingOptionId);
|
|
60474
60856
|
} catch (error52) {
|
|
60475
60857
|
return {
|
|
60476
60858
|
ok: false,
|
|
@@ -60483,6 +60865,7 @@ var ClaudeHarnessSession = class {
|
|
|
60483
60865
|
}
|
|
60484
60866
|
}
|
|
60485
60867
|
this.#requestedModel = command.model;
|
|
60868
|
+
this.#requestedThinkingOptionId = thinkingOptionId;
|
|
60486
60869
|
const persistenceError = await this.#savePendingConfiguration();
|
|
60487
60870
|
if (persistenceError)
|
|
60488
60871
|
return { ok: false, error: persistenceError };
|
|
@@ -60517,6 +60900,17 @@ var ClaudeHarnessSession = class {
|
|
|
60517
60900
|
}
|
|
60518
60901
|
};
|
|
60519
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
|
+
}
|
|
60520
60914
|
this.#usageGeneration += 1;
|
|
60521
60915
|
this.#contextUsageFreshUntilMs = 0;
|
|
60522
60916
|
this.#contextUsageCooldownUntilMs = 0;
|
|
@@ -60983,15 +61377,39 @@ var ClaudeHarnessSession = class {
|
|
|
60983
61377
|
}
|
|
60984
61378
|
}
|
|
60985
61379
|
#configuredState(nativeReady = this.#state.nativeRef !== void 0) {
|
|
60986
|
-
const effectiveModel = this.#
|
|
61380
|
+
const effectiveModel = this.#effectiveModelRef();
|
|
61381
|
+
const supported = this.#supportedThinkingOptionIds(effectiveModel);
|
|
60987
61382
|
return {
|
|
60988
61383
|
...nativeReady ? { nativeRef: this.#nativeRef } : {},
|
|
60989
61384
|
...effectiveModel ? { effectiveModel } : {},
|
|
60990
61385
|
effectiveThinkingOptionId: this.#requestedThinkingOptionId,
|
|
60991
|
-
|
|
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),
|
|
60992
61389
|
effectivePermissionModeId: this.#requestedPermissionModeId
|
|
60993
61390
|
};
|
|
60994
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
|
+
}
|
|
60995
61413
|
#publishState(state = this.#state) {
|
|
60996
61414
|
this.#state = state;
|
|
60997
61415
|
this.#statePublished = true;
|
|
@@ -61016,6 +61434,8 @@ var ClaudeHarnessSession = class {
|
|
|
61016
61434
|
return;
|
|
61017
61435
|
switch (event.type) {
|
|
61018
61436
|
case "segment.started":
|
|
61437
|
+
if (event.mcpServers)
|
|
61438
|
+
this.#mcpServers = event.mcpServers;
|
|
61019
61439
|
this.#observeRootOutput(active);
|
|
61020
61440
|
if (active.cancellation && !active.cancellation.interrupting) {
|
|
61021
61441
|
this.#interruptCancelledSegment(active).catch(() => this.#hardCancel(active));
|
|
@@ -61444,6 +61864,7 @@ var ClaudeHarnessSession = class {
|
|
|
61444
61864
|
cwd: this.#cwd,
|
|
61445
61865
|
outputLimit: this.#toolOutputLimit,
|
|
61446
61866
|
taskTracker: this.#taskTracker,
|
|
61867
|
+
mcpServers: () => this.#mcpServers,
|
|
61447
61868
|
nativeTurnKey,
|
|
61448
61869
|
newItemId: () => hostItemIdSchema.parse(this.#randomUUID()),
|
|
61449
61870
|
emit: (event) => this.#event(event),
|
|
@@ -61887,11 +62308,12 @@ var ClaudeHarnessSession = class {
|
|
|
61887
62308
|
checkpointId: active.checkpointId,
|
|
61888
62309
|
formatVersion: 1
|
|
61889
62310
|
}) : null;
|
|
61890
|
-
|
|
62311
|
+
const trackUserMessageId = active.userMessageId !== null && !SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN.test(active.userMessageId) && (outcome.status !== "cancelled" || active.checkpointId !== null);
|
|
62312
|
+
if (trackUserMessageId || active.checkpointId) {
|
|
61891
62313
|
this.#unpersistedMessageIds = [
|
|
61892
62314
|
.../* @__PURE__ */ new Set([
|
|
61893
62315
|
...this.#unpersistedMessageIds,
|
|
61894
|
-
...active.userMessageId ? [active.userMessageId] : [],
|
|
62316
|
+
...trackUserMessageId && active.userMessageId ? [active.userMessageId] : [],
|
|
61895
62317
|
...active.checkpointId ? [active.checkpointId] : []
|
|
61896
62318
|
])
|
|
61897
62319
|
];
|
|
@@ -62134,8 +62556,11 @@ var ClaudeCodeAdapter = class {
|
|
|
62134
62556
|
if (current)
|
|
62135
62557
|
return current;
|
|
62136
62558
|
const inspection = this.#inspectModels(cwd).then((result) => {
|
|
62137
|
-
if (result.status === "ready")
|
|
62559
|
+
if (result.status === "ready") {
|
|
62138
62560
|
this.#inspectionCache.set(cwd, result);
|
|
62561
|
+
for (const session of this.#sessions)
|
|
62562
|
+
session.refitThinking(cwd);
|
|
62563
|
+
}
|
|
62139
62564
|
return result;
|
|
62140
62565
|
});
|
|
62141
62566
|
this.#inspectionInFlight.set(cwd, inspection);
|
|
@@ -62417,6 +62842,10 @@ var ClaudeCodeAdapter = class {
|
|
|
62417
62842
|
...requestedModel ? { requestedModel } : {},
|
|
62418
62843
|
requestedPermissionModeId,
|
|
62419
62844
|
requestedThinkingOptionId,
|
|
62845
|
+
modelCatalog: () => {
|
|
62846
|
+
const inspection = this.#inspectionCache.get(cwd);
|
|
62847
|
+
return inspection?.status === "ready" ? inspection.catalog : void 0;
|
|
62848
|
+
},
|
|
62420
62849
|
toolOutputLimit: this.#toolOutputLimit,
|
|
62421
62850
|
cancelTimeoutMs: this.#cancelTimeoutMs,
|
|
62422
62851
|
continuationQuiescenceMs: this.#continuationQuiescenceMs
|
|
@@ -62486,11 +62915,11 @@ var ClaudeCodeAdapter = class {
|
|
|
62486
62915
|
};
|
|
62487
62916
|
|
|
62488
62917
|
// dist/installation.js
|
|
62489
|
-
import { readFile as
|
|
62918
|
+
import { readFile as readFile7, realpath as realpath5 } from "node:fs/promises";
|
|
62490
62919
|
import { homedir as homedir2 } from "node:os";
|
|
62491
62920
|
import path16 from "node:path";
|
|
62492
62921
|
async function readSettings(file2) {
|
|
62493
|
-
const text2 = await
|
|
62922
|
+
const text2 = await readFile7(file2, "utf8").catch((error52) => {
|
|
62494
62923
|
if (error52.code === "ENOENT")
|
|
62495
62924
|
return "{}";
|
|
62496
62925
|
throw error52;
|