@liberseek/boft-cli-linux-x64 0.8.4 → 0.8.5
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 +59 -8
- package/app/console-web.js +278 -63
- package/app/desktop-controller.mjs +641 -33
- package/app/host-runtime.mjs +1811 -685
- package/app/plugins/antigravity/plugin.mjs +346 -54
- package/app/plugins/claude-code/plugin.mjs +391 -259
- package/app/plugins/codebuddy/plugin.mjs +231 -134
- package/app/plugins/codex-usage/plugin.mjs +82 -32
- package/app/plugins/copilot/plugin.mjs +107 -57
- package/app/plugins/cursor-cli/plugin.mjs +193 -131
- package/app/plugins/deepseek-harness/plugin.mjs +112 -42
- package/app/plugins/grok/plugin.mjs +371 -115
- package/app/plugins/hermes/plugin.mjs +54 -4
- package/app/plugins/kimi-code/plugin.mjs +69 -19
- package/app/plugins/kiro-cli/plugin.mjs +69 -19
- package/app/plugins/muse/plugin.mjs +59 -9
- package/app/plugins/omp/plugin.mjs +89 -39
- package/app/plugins/opencode/plugin.mjs +111 -61
- package/app/plugins/pi/plugin.mjs +185 -68
- package/app/plugins/qoder/plugin.mjs +79 -29
- package/app/plugins/qoder-cn/plugin.mjs +79 -29
- package/app/plugins/workbuddy/plugin.mjs +231 -134
- package/app/plugins/zcode/plugin.mjs +108 -33
- package/app/renderer-extension.js +2634 -329
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +1 -1
|
@@ -777,10 +777,10 @@ function mergeDefs(...defs) {
|
|
|
777
777
|
function cloneDef(schema) {
|
|
778
778
|
return mergeDefs(schema._zod.def);
|
|
779
779
|
}
|
|
780
|
-
function getElementAtPath(obj,
|
|
781
|
-
if (!
|
|
780
|
+
function getElementAtPath(obj, path20) {
|
|
781
|
+
if (!path20)
|
|
782
782
|
return obj;
|
|
783
|
-
return
|
|
783
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
784
784
|
}
|
|
785
785
|
function promiseAllObject(promisesObj) {
|
|
786
786
|
const keys = Object.keys(promisesObj);
|
|
@@ -1189,11 +1189,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
return false;
|
|
1191
1191
|
}
|
|
1192
|
-
function prefixIssues(
|
|
1192
|
+
function prefixIssues(path20, issues) {
|
|
1193
1193
|
return issues.map((iss) => {
|
|
1194
1194
|
var _a4;
|
|
1195
1195
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
1196
|
-
iss.path.unshift(
|
|
1196
|
+
iss.path.unshift(path20);
|
|
1197
1197
|
return iss;
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
@@ -1340,16 +1340,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
1342
1342
|
const fieldErrors = { _errors: [] };
|
|
1343
|
-
const processError = (error53,
|
|
1343
|
+
const processError = (error53, path20 = []) => {
|
|
1344
1344
|
for (const issue2 of error53.issues) {
|
|
1345
1345
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1346
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1346
|
+
issue2.errors.map((issues) => processError({ issues }, [...path20, ...issue2.path]));
|
|
1347
1347
|
} else if (issue2.code === "invalid_key") {
|
|
1348
|
-
processError({ issues: issue2.issues }, [...
|
|
1348
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
1349
1349
|
} else if (issue2.code === "invalid_element") {
|
|
1350
|
-
processError({ issues: issue2.issues }, [...
|
|
1350
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
1351
1351
|
} else {
|
|
1352
|
-
const fullpath = [...
|
|
1352
|
+
const fullpath = [...path20, ...issue2.path];
|
|
1353
1353
|
if (fullpath.length === 0) {
|
|
1354
1354
|
fieldErrors._errors.push(mapper(issue2));
|
|
1355
1355
|
} else {
|
|
@@ -1376,17 +1376,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
1378
1378
|
const result = { errors: [] };
|
|
1379
|
-
const processError = (error53,
|
|
1379
|
+
const processError = (error53, path20 = []) => {
|
|
1380
1380
|
var _a4, _b2;
|
|
1381
1381
|
for (const issue2 of error53.issues) {
|
|
1382
1382
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1383
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1383
|
+
issue2.errors.map((issues) => processError({ issues }, [...path20, ...issue2.path]));
|
|
1384
1384
|
} else if (issue2.code === "invalid_key") {
|
|
1385
|
-
processError({ issues: issue2.issues }, [...
|
|
1385
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
1386
1386
|
} else if (issue2.code === "invalid_element") {
|
|
1387
|
-
processError({ issues: issue2.issues }, [...
|
|
1387
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
1388
1388
|
} else {
|
|
1389
|
-
const fullpath = [...
|
|
1389
|
+
const fullpath = [...path20, ...issue2.path];
|
|
1390
1390
|
if (fullpath.length === 0) {
|
|
1391
1391
|
result.errors.push(mapper(issue2));
|
|
1392
1392
|
continue;
|
|
@@ -1418,8 +1418,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1418
1418
|
}
|
|
1419
1419
|
function toDotPath(_path) {
|
|
1420
1420
|
const segs = [];
|
|
1421
|
-
const
|
|
1422
|
-
for (const seg of
|
|
1421
|
+
const path20 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1422
|
+
for (const seg of path20) {
|
|
1423
1423
|
if (typeof seg === "number")
|
|
1424
1424
|
segs.push(`[${seg}]`);
|
|
1425
1425
|
else if (typeof seg === "symbol")
|
|
@@ -3040,10 +3040,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3040
3040
|
const shape = def.shape;
|
|
3041
3041
|
const propValues = {};
|
|
3042
3042
|
for (const key in shape) {
|
|
3043
|
-
const
|
|
3044
|
-
if (
|
|
3043
|
+
const field2 = shape[key]._zod;
|
|
3044
|
+
if (field2.values) {
|
|
3045
3045
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
3046
|
-
for (const v of
|
|
3046
|
+
for (const v of field2.values)
|
|
3047
3047
|
propValues[key].add(v);
|
|
3048
3048
|
}
|
|
3049
3049
|
}
|
|
@@ -14111,13 +14111,13 @@ function resolveRef(ref, ctx) {
|
|
|
14111
14111
|
if (!ref.startsWith("#")) {
|
|
14112
14112
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14113
14113
|
}
|
|
14114
|
-
const
|
|
14115
|
-
if (
|
|
14114
|
+
const path20 = ref.slice(1).split("/").filter(Boolean);
|
|
14115
|
+
if (path20.length === 0) {
|
|
14116
14116
|
return ctx.rootSchema;
|
|
14117
14117
|
}
|
|
14118
14118
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14119
|
-
if (
|
|
14120
|
-
const key =
|
|
14119
|
+
if (path20[0] === defsKey) {
|
|
14120
|
+
const key = path20[1];
|
|
14121
14121
|
if (!key || !ctx.defs[key]) {
|
|
14122
14122
|
throw new Error(`Reference not found: ${ref}`);
|
|
14123
14123
|
}
|
|
@@ -14683,6 +14683,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
|
14683
14683
|
cachedInputTokens: count,
|
|
14684
14684
|
cacheWriteInputTokens: count,
|
|
14685
14685
|
cacheKnownInputTokens: count,
|
|
14686
|
+
cacheHitCachedInputTokens: count,
|
|
14687
|
+
cacheHitInputTokens: count,
|
|
14686
14688
|
outputTokens: count,
|
|
14687
14689
|
reasoningOutputTokens: count,
|
|
14688
14690
|
/** USD at the public price, summed over the priced requests only. */
|
|
@@ -14790,6 +14792,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
14790
14792
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
14791
14793
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
14792
14794
|
|
|
14795
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
14796
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
14797
|
+
external_exports.object({
|
|
14798
|
+
id: external_exports.string().min(1),
|
|
14799
|
+
type: external_exports.literal("choice"),
|
|
14800
|
+
prompt: external_exports.string(),
|
|
14801
|
+
options: external_exports.array(external_exports.object({
|
|
14802
|
+
value: external_exports.string().min(1),
|
|
14803
|
+
label: external_exports.string(),
|
|
14804
|
+
description: external_exports.string().optional()
|
|
14805
|
+
})).min(1),
|
|
14806
|
+
multiple: external_exports.boolean(),
|
|
14807
|
+
allowOther: external_exports.boolean(),
|
|
14808
|
+
optional: external_exports.boolean()
|
|
14809
|
+
}),
|
|
14810
|
+
external_exports.object({
|
|
14811
|
+
id: external_exports.string().min(1),
|
|
14812
|
+
type: external_exports.literal("text"),
|
|
14813
|
+
prompt: external_exports.string(),
|
|
14814
|
+
multiline: external_exports.boolean(),
|
|
14815
|
+
secret: external_exports.literal(false),
|
|
14816
|
+
optional: external_exports.boolean(),
|
|
14817
|
+
placeholder: external_exports.string().optional(),
|
|
14818
|
+
prefill: external_exports.string().optional()
|
|
14819
|
+
})
|
|
14820
|
+
]);
|
|
14821
|
+
var threadQuestionSchema = external_exports.object({
|
|
14822
|
+
interactionId: external_exports.string().min(1),
|
|
14823
|
+
turnId: external_exports.string().min(1),
|
|
14824
|
+
title: external_exports.string().optional(),
|
|
14825
|
+
questions: external_exports.array(field).min(1)
|
|
14826
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
14827
|
+
message: "Shared cards require at least one multi-select question"
|
|
14828
|
+
});
|
|
14829
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
14830
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
14831
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
14832
|
+
threadId: external_exports.string().min(1),
|
|
14833
|
+
turnId: external_exports.string().min(1),
|
|
14834
|
+
interactionId: external_exports.string().min(1),
|
|
14835
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
14836
|
+
cancelled: external_exports.boolean().default(false)
|
|
14837
|
+
});
|
|
14838
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
14839
|
+
|
|
14793
14840
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
14794
14841
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
14795
14842
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15559,7 +15606,10 @@ var harnessPluginRouteSchema = external_exports.object({
|
|
|
15559
15606
|
harnessId: harnessPluginIdSchema,
|
|
15560
15607
|
model: harnessModelRefSchema.optional(),
|
|
15561
15608
|
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
15562
|
-
permissionModeId: harnessPermissionModeIdSchema.optional()
|
|
15609
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
15610
|
+
/** A draft prewarm create: stays unsubmitted until the user's first Turn.
|
|
15611
|
+
* Desktop forwards only the Model of a main-process prewarm to thread/start. */
|
|
15612
|
+
prewarm: external_exports.literal(true).optional()
|
|
15563
15613
|
}).strict();
|
|
15564
15614
|
|
|
15565
15615
|
// ../../shared-contracts/dist/harness-launch-settings.js
|
|
@@ -16158,26 +16208,26 @@ function parseHostUsage(value) {
|
|
|
16158
16208
|
}
|
|
16159
16209
|
}
|
|
16160
16210
|
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
16161
|
-
for (const
|
|
16211
|
+
for (const field2 of [
|
|
16162
16212
|
"totalCredits",
|
|
16163
16213
|
"contextUsagePercent",
|
|
16164
16214
|
"apiOutputTokensPerSecond"
|
|
16165
16215
|
]) {
|
|
16166
|
-
const candidate = value[
|
|
16216
|
+
const candidate = value[field2];
|
|
16167
16217
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16168
|
-
throw new Error(`Harness Usage '${
|
|
16218
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
16169
16219
|
}
|
|
16170
16220
|
}
|
|
16171
|
-
for (const
|
|
16172
|
-
const candidate = value[
|
|
16221
|
+
for (const field2 of tokenFields) {
|
|
16222
|
+
const candidate = value[field2];
|
|
16173
16223
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16174
|
-
throw new Error(`Harness Usage '${
|
|
16224
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16175
16225
|
}
|
|
16176
16226
|
}
|
|
16177
|
-
for (const
|
|
16178
|
-
const candidate = value[
|
|
16227
|
+
for (const field2 of safeIntegerFields) {
|
|
16228
|
+
const candidate = value[field2];
|
|
16179
16229
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16180
|
-
throw new Error(`Harness Usage '${
|
|
16230
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16181
16231
|
}
|
|
16182
16232
|
}
|
|
16183
16233
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -16186,16 +16236,16 @@ function parseHostUsage(value) {
|
|
|
16186
16236
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16187
16237
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16188
16238
|
}
|
|
16189
|
-
for (const
|
|
16190
|
-
const candidate = value[
|
|
16239
|
+
for (const field2 of ["totalCredits", "contextUsagePercent"]) {
|
|
16240
|
+
const candidate = value[field2];
|
|
16191
16241
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16192
|
-
throw new Error(`Harness Usage '${
|
|
16242
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
16193
16243
|
}
|
|
16194
16244
|
}
|
|
16195
|
-
for (const
|
|
16196
|
-
const candidate = value[
|
|
16245
|
+
for (const field2 of percentFields) {
|
|
16246
|
+
const candidate = value[field2];
|
|
16197
16247
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16198
|
-
throw new Error(`Harness Usage '${
|
|
16248
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
16199
16249
|
}
|
|
16200
16250
|
}
|
|
16201
16251
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -16266,19 +16316,19 @@ function parseHostUsageRequest(value) {
|
|
|
16266
16316
|
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
16267
16317
|
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
16268
16318
|
}
|
|
16269
|
-
for (const
|
|
16270
|
-
const candidate = value[
|
|
16319
|
+
for (const field2 of ["model", "provider"]) {
|
|
16320
|
+
const candidate = value[field2];
|
|
16271
16321
|
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
16272
|
-
throw new Error(`Harness Usage request '${
|
|
16322
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
16273
16323
|
}
|
|
16274
16324
|
}
|
|
16275
16325
|
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
16276
16326
|
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
16277
16327
|
}
|
|
16278
|
-
for (const
|
|
16279
|
-
const candidate = value[
|
|
16328
|
+
for (const field2 of requestTokenFields) {
|
|
16329
|
+
const candidate = value[field2];
|
|
16280
16330
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16281
|
-
throw new Error(`Harness Usage request '${
|
|
16331
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
16282
16332
|
}
|
|
16283
16333
|
}
|
|
16284
16334
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
@@ -16538,30 +16588,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
16538
16588
|
});
|
|
16539
16589
|
}
|
|
16540
16590
|
|
|
16541
|
-
// ../../harness-broker/dist/paths.js
|
|
16542
|
-
import os from "node:os";
|
|
16543
|
-
import path from "node:path";
|
|
16544
|
-
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
16545
|
-
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
16546
|
-
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
16547
|
-
const home = environment.HOME || os.homedir();
|
|
16548
|
-
return path.join(home, ".codexhost", "harness-broker");
|
|
16549
|
-
}
|
|
16550
|
-
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
16551
|
-
harnessPluginIdSchema.parse(harnessId);
|
|
16552
|
-
if (harnessId !== "claude-code")
|
|
16553
|
-
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
16554
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
16555
|
-
}
|
|
16556
|
-
function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
|
|
16557
|
-
harnessPluginIdSchema.parse(harnessId);
|
|
16558
|
-
return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
|
|
16559
|
-
}
|
|
16560
|
-
function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
|
|
16561
|
-
const home = environment.HOME || os.homedir();
|
|
16562
|
-
return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
|
|
16563
|
-
}
|
|
16564
|
-
|
|
16565
16591
|
// ../../harness-broker/dist/validation.js
|
|
16566
16592
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
16567
16593
|
var brokerEnvironmentSchema = external_exports.object({
|
|
@@ -16612,7 +16638,11 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16612
16638
|
forkSchema,
|
|
16613
16639
|
rollbackSchema
|
|
16614
16640
|
]);
|
|
16615
|
-
var brokerInspectInputSchema = external_exports.object({
|
|
16641
|
+
var brokerInspectInputSchema = external_exports.object({
|
|
16642
|
+
cwd: cwdSchema.optional(),
|
|
16643
|
+
refresh: external_exports.boolean().optional(),
|
|
16644
|
+
purpose: external_exports.literal("availability").optional()
|
|
16645
|
+
}).strict();
|
|
16616
16646
|
var brokerSessionImportListParamsSchema = external_exports.object({
|
|
16617
16647
|
offset: external_exports.number().int().nonnegative().safe(),
|
|
16618
16648
|
limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
|
|
@@ -16627,10 +16657,10 @@ var brokerSessionImportSourceSchema = external_exports.object({
|
|
|
16627
16657
|
candidate: harnessSessionImportCandidateSchema,
|
|
16628
16658
|
nativeRef: nativeSessionRefSchema
|
|
16629
16659
|
}).strict().superRefine((source, context) => {
|
|
16630
|
-
if (source.nativeRef.
|
|
16660
|
+
if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
|
|
16631
16661
|
context.addIssue({
|
|
16632
16662
|
code: "custom",
|
|
16633
|
-
message: "
|
|
16663
|
+
message: "Session import source identity does not match"
|
|
16634
16664
|
});
|
|
16635
16665
|
}
|
|
16636
16666
|
});
|
|
@@ -16804,6 +16834,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
|
|
|
16804
16834
|
return false;
|
|
16805
16835
|
});
|
|
16806
16836
|
|
|
16837
|
+
// ../../harness-broker/dist/session-import-client.js
|
|
16838
|
+
function createBrokerSessionImportCapability(input) {
|
|
16839
|
+
let listing = null;
|
|
16840
|
+
const closed = () => ({
|
|
16841
|
+
ok: false,
|
|
16842
|
+
error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
|
|
16843
|
+
});
|
|
16844
|
+
const invalid = () => ({
|
|
16845
|
+
ok: false,
|
|
16846
|
+
error: {
|
|
16847
|
+
code: "protocolError",
|
|
16848
|
+
message: "Harness broker returned invalid Session import metadata",
|
|
16849
|
+
retryable: false
|
|
16850
|
+
}
|
|
16851
|
+
});
|
|
16852
|
+
const list = async () => {
|
|
16853
|
+
try {
|
|
16854
|
+
const candidates = [];
|
|
16855
|
+
const identities = /* @__PURE__ */ new Set();
|
|
16856
|
+
let total;
|
|
16857
|
+
for (; ; ) {
|
|
16858
|
+
if (input.isClosed())
|
|
16859
|
+
return closed();
|
|
16860
|
+
const result = await input.request("adapter.sessionImport.list", {
|
|
16861
|
+
offset: candidates.length,
|
|
16862
|
+
limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
|
|
16863
|
+
});
|
|
16864
|
+
if (input.isClosed())
|
|
16865
|
+
return closed();
|
|
16866
|
+
if (!result.ok)
|
|
16867
|
+
return result;
|
|
16868
|
+
const page = brokerSessionImportPageSchema.safeParse(result.value);
|
|
16869
|
+
if (!page.success || total !== void 0 && total !== page.data.total || page.data.total < candidates.length + page.data.candidates.length || page.data.candidates.length === 0 && candidates.length < page.data.total)
|
|
16870
|
+
return invalid();
|
|
16871
|
+
total = page.data.total;
|
|
16872
|
+
for (const candidate of page.data.candidates) {
|
|
16873
|
+
if (identities.has(candidate.nativeSessionId))
|
|
16874
|
+
return invalid();
|
|
16875
|
+
identities.add(candidate.nativeSessionId);
|
|
16876
|
+
candidates.push(candidate);
|
|
16877
|
+
}
|
|
16878
|
+
if (candidates.length === total)
|
|
16879
|
+
return { ok: true, value: candidates };
|
|
16880
|
+
}
|
|
16881
|
+
} catch (error52) {
|
|
16882
|
+
return { ok: false, error: input.error(error52) };
|
|
16883
|
+
}
|
|
16884
|
+
};
|
|
16885
|
+
return {
|
|
16886
|
+
listCandidates() {
|
|
16887
|
+
if (input.isClosed())
|
|
16888
|
+
return Promise.resolve(closed());
|
|
16889
|
+
listing ??= list().finally(() => {
|
|
16890
|
+
listing = null;
|
|
16891
|
+
});
|
|
16892
|
+
return listing;
|
|
16893
|
+
},
|
|
16894
|
+
async resolveCandidate(nativeSessionId) {
|
|
16895
|
+
if (input.isClosed())
|
|
16896
|
+
return closed();
|
|
16897
|
+
try {
|
|
16898
|
+
const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
|
|
16899
|
+
if (input.isClosed())
|
|
16900
|
+
return closed();
|
|
16901
|
+
if (!result.ok)
|
|
16902
|
+
return result;
|
|
16903
|
+
const source = brokerSessionImportSourceSchema.safeParse(result.value);
|
|
16904
|
+
if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
|
|
16905
|
+
return invalid();
|
|
16906
|
+
return { ok: true, value: source.data };
|
|
16907
|
+
} catch (error52) {
|
|
16908
|
+
return { ok: false, error: input.error(error52) };
|
|
16909
|
+
}
|
|
16910
|
+
}
|
|
16911
|
+
};
|
|
16912
|
+
}
|
|
16913
|
+
|
|
16914
|
+
// ../../harness-broker/dist/paths.js
|
|
16915
|
+
import os from "node:os";
|
|
16916
|
+
import path from "node:path";
|
|
16917
|
+
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
16918
|
+
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
16919
|
+
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
16920
|
+
const home = environment.HOME || os.homedir();
|
|
16921
|
+
return path.join(home, ".codexhost", "harness-broker");
|
|
16922
|
+
}
|
|
16923
|
+
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
16924
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
16925
|
+
if (harnessId !== "claude-code")
|
|
16926
|
+
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
16927
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
16928
|
+
}
|
|
16929
|
+
function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
|
|
16930
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
16931
|
+
return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
|
|
16932
|
+
}
|
|
16933
|
+
function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
|
|
16934
|
+
const home = environment.HOME || os.homedir();
|
|
16935
|
+
return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
|
|
16936
|
+
}
|
|
16937
|
+
|
|
16807
16938
|
// ../../harness-broker/dist/client.js
|
|
16808
16939
|
function unavailable(message, retryable = true) {
|
|
16809
16940
|
return { code: "unavailable", message, retryable, stage: "harnessBroker" };
|
|
@@ -17340,6 +17471,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
17340
17471
|
commandCatalog;
|
|
17341
17472
|
liveCommandCatalog;
|
|
17342
17473
|
harnessId;
|
|
17474
|
+
sessionImport;
|
|
17343
17475
|
credits;
|
|
17344
17476
|
refreshCredits;
|
|
17345
17477
|
#descriptorPath;
|
|
@@ -17349,7 +17481,6 @@ var BrokeredHarnessAdapter = class {
|
|
|
17349
17481
|
#startTimeoutMs;
|
|
17350
17482
|
#connection = null;
|
|
17351
17483
|
#closed = false;
|
|
17352
|
-
#sessionImportListing = null;
|
|
17353
17484
|
#credits = null;
|
|
17354
17485
|
#creditsRefresh = null;
|
|
17355
17486
|
subagents = {
|
|
@@ -17361,86 +17492,16 @@ var BrokeredHarnessAdapter = class {
|
|
|
17361
17492
|
}
|
|
17362
17493
|
}
|
|
17363
17494
|
};
|
|
17364
|
-
sessionImport = Object.freeze({
|
|
17365
|
-
listCandidates: () => {
|
|
17366
|
-
this.#sessionImportListing ??= this.#listSessionImportCandidates().finally(() => {
|
|
17367
|
-
this.#sessionImportListing = null;
|
|
17368
|
-
});
|
|
17369
|
-
return this.#sessionImportListing;
|
|
17370
|
-
},
|
|
17371
|
-
resolveCandidate: async (nativeSessionId) => {
|
|
17372
|
-
if (this.#closed) {
|
|
17373
|
-
return {
|
|
17374
|
-
ok: false,
|
|
17375
|
-
error: unavailable("Claude Aqua broker adapter is closed", false)
|
|
17376
|
-
};
|
|
17377
|
-
}
|
|
17378
|
-
try {
|
|
17379
|
-
const result = parseHarnessResult(await (await this.#connect()).request("adapter.sessionImport.resolve", {
|
|
17380
|
-
nativeSessionId
|
|
17381
|
-
}));
|
|
17382
|
-
if (!result.ok)
|
|
17383
|
-
return result;
|
|
17384
|
-
const parsed = brokerSessionImportSourceSchema.safeParse(result.value);
|
|
17385
|
-
if (!parsed.success || parsed.data.candidate.nativeSessionId !== nativeSessionId) {
|
|
17386
|
-
return {
|
|
17387
|
-
ok: false,
|
|
17388
|
-
error: {
|
|
17389
|
-
...unavailable("Harness broker returned an invalid Session source", false),
|
|
17390
|
-
code: "protocolError"
|
|
17391
|
-
}
|
|
17392
|
-
};
|
|
17393
|
-
}
|
|
17394
|
-
return { ok: true, value: parsed.data };
|
|
17395
|
-
} catch (error52) {
|
|
17396
|
-
this.#connection = null;
|
|
17397
|
-
return {
|
|
17398
|
-
ok: false,
|
|
17399
|
-
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
17400
|
-
};
|
|
17401
|
-
}
|
|
17402
|
-
}
|
|
17403
|
-
});
|
|
17404
|
-
async #listSessionImportCandidates() {
|
|
17405
|
-
if (this.#closed) {
|
|
17406
|
-
return {
|
|
17407
|
-
ok: false,
|
|
17408
|
-
error: unavailable("Claude Aqua broker adapter is closed", false)
|
|
17409
|
-
};
|
|
17410
|
-
}
|
|
17411
|
-
try {
|
|
17412
|
-
const candidates = [];
|
|
17413
|
-
for (; ; ) {
|
|
17414
|
-
const result = parseHarnessResult(await (await this.#connect()).request("adapter.sessionImport.list", {
|
|
17415
|
-
offset: candidates.length,
|
|
17416
|
-
limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
|
|
17417
|
-
}));
|
|
17418
|
-
if (!result.ok)
|
|
17419
|
-
return result;
|
|
17420
|
-
const parsed = brokerSessionImportPageSchema.safeParse(result.value);
|
|
17421
|
-
if (!parsed.success || parsed.data.total < candidates.length + parsed.data.candidates.length || parsed.data.candidates.length === 0 && candidates.length < parsed.data.total) {
|
|
17422
|
-
return {
|
|
17423
|
-
ok: false,
|
|
17424
|
-
error: {
|
|
17425
|
-
...unavailable("Harness broker returned invalid Session candidates", false),
|
|
17426
|
-
code: "protocolError"
|
|
17427
|
-
}
|
|
17428
|
-
};
|
|
17429
|
-
}
|
|
17430
|
-
candidates.push(...parsed.data.candidates);
|
|
17431
|
-
if (candidates.length === parsed.data.total)
|
|
17432
|
-
return { ok: true, value: candidates };
|
|
17433
|
-
}
|
|
17434
|
-
} catch (error52) {
|
|
17435
|
-
this.#connection = null;
|
|
17436
|
-
return {
|
|
17437
|
-
ok: false,
|
|
17438
|
-
error: unavailable(error52 instanceof Error ? error52.message : String(error52))
|
|
17439
|
-
};
|
|
17440
|
-
}
|
|
17441
|
-
}
|
|
17442
17495
|
constructor(input = {}) {
|
|
17443
17496
|
this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
|
|
17497
|
+
if (input.sessionImport) {
|
|
17498
|
+
this.sessionImport = createBrokerSessionImportCapability({
|
|
17499
|
+
harnessId: this.harnessId,
|
|
17500
|
+
request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
|
|
17501
|
+
isClosed: () => this.#closed,
|
|
17502
|
+
error: (error52) => this.#error(error52)
|
|
17503
|
+
});
|
|
17504
|
+
}
|
|
17444
17505
|
if (input.accountCredits !== false) {
|
|
17445
17506
|
this.credits = () => this.#credits;
|
|
17446
17507
|
this.refreshCredits = () => this.#refreshAccountCredits();
|
|
@@ -17904,7 +17965,7 @@ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix
|
|
|
17904
17965
|
|
|
17905
17966
|
// dist/claude-code-adapter.js
|
|
17906
17967
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17907
|
-
import
|
|
17968
|
+
import path17 from "node:path";
|
|
17908
17969
|
|
|
17909
17970
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
17910
17971
|
import { createRequire as jre } from "node:module";
|
|
@@ -54664,7 +54725,6 @@ var ClaudePendingSessions = class {
|
|
|
54664
54725
|
};
|
|
54665
54726
|
|
|
54666
54727
|
// dist/claude-fork.js
|
|
54667
|
-
import path11 from "node:path";
|
|
54668
54728
|
import { isDeepStrictEqual } from "node:util";
|
|
54669
54729
|
|
|
54670
54730
|
// dist/file-change.js
|
|
@@ -54806,6 +54866,17 @@ function targetedSubagentId(argumentsValue) {
|
|
|
54806
54866
|
return void 0;
|
|
54807
54867
|
return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
|
|
54808
54868
|
}
|
|
54869
|
+
function claudeSendMessageFailed(nativeResult, outputText) {
|
|
54870
|
+
if (isRecord6(nativeResult) && typeof nativeResult.success === "boolean") {
|
|
54871
|
+
return nativeResult.success === false;
|
|
54872
|
+
}
|
|
54873
|
+
try {
|
|
54874
|
+
const parsed = JSON.parse(outputText ?? "");
|
|
54875
|
+
return isRecord6(parsed) && parsed.success === false;
|
|
54876
|
+
} catch {
|
|
54877
|
+
return false;
|
|
54878
|
+
}
|
|
54879
|
+
}
|
|
54809
54880
|
function includesAuthenticationFailure(errors) {
|
|
54810
54881
|
return errors.some((error52) => AUTHENTICATION_ERRORS.has(error52));
|
|
54811
54882
|
}
|
|
@@ -55538,7 +55609,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55538
55609
|
events.push({
|
|
55539
55610
|
type: "subagent.completed",
|
|
55540
55611
|
callId,
|
|
55541
|
-
isError,
|
|
55612
|
+
isError: isError || tool.name === "SendMessage" && claudeSendMessageFailed(nativeResult, outputText),
|
|
55542
55613
|
...subagentContinuesInBackground(nativeResult, outputText) ? { continuesInBackground: true } : {},
|
|
55543
55614
|
...agentId ? { nativeSubagentId: agentId } : {},
|
|
55544
55615
|
...resultSummary ? { resultSummary } : {}
|
|
@@ -55693,7 +55764,7 @@ function conversationMessages(values, sessionId) {
|
|
|
55693
55764
|
let promptId = null;
|
|
55694
55765
|
const occupancy = new ClaudeBackgroundOccupancy();
|
|
55695
55766
|
let accumulator = new ClaudeNativeTurnAccumulator();
|
|
55696
|
-
const sends = /* @__PURE__ */ new
|
|
55767
|
+
const sends = /* @__PURE__ */ new Map();
|
|
55697
55768
|
let pendingNotification = false;
|
|
55698
55769
|
for (const value of values) {
|
|
55699
55770
|
if (!isRecord7(value))
|
|
@@ -55727,17 +55798,19 @@ function conversationMessages(values, sessionId) {
|
|
|
55727
55798
|
for (const event of accumulator.consume(value).events) {
|
|
55728
55799
|
if (event.type === "subagent.started") {
|
|
55729
55800
|
if (event.operation === "send") {
|
|
55730
|
-
sends.
|
|
55731
|
-
if (event.nativeSubagentId)
|
|
55732
|
-
occupancy.occupyAgent(event.nativeSubagentId);
|
|
55801
|
+
sends.set(event.callId, event.nativeSubagentId);
|
|
55733
55802
|
} else if (event.background)
|
|
55734
55803
|
occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
55735
55804
|
} else if (event.type === "subagent.completed") {
|
|
55736
|
-
if (
|
|
55805
|
+
if (sends.has(event.callId)) {
|
|
55806
|
+
const agentId = event.nativeSubagentId ?? sends.get(event.callId);
|
|
55807
|
+
if (!event.isError && agentId)
|
|
55808
|
+
occupancy.occupyAgent(agentId);
|
|
55809
|
+
sends.delete(event.callId);
|
|
55810
|
+
} else if (!event.isError && event.continuesInBackground) {
|
|
55737
55811
|
occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
55738
55812
|
} else
|
|
55739
55813
|
occupancy.release(event.callId, event.nativeSubagentId);
|
|
55740
|
-
sends.delete(event.callId);
|
|
55741
55814
|
} else if (event.type === "workflow.launched" && event.background && !event.isError) {
|
|
55742
55815
|
occupancy.occupySpawn(event.callId, event.taskId);
|
|
55743
55816
|
} else if (event.type === "subagent.settled") {
|
|
@@ -55924,7 +55997,7 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
55924
55997
|
if (!result)
|
|
55925
55998
|
continue;
|
|
55926
55999
|
const output = toolResultOutput(result.block);
|
|
55927
|
-
const failed = result.block.is_error === true;
|
|
56000
|
+
const failed = result.block.is_error === true || block.name === "SendMessage" && claudeSendMessageFailed(void 0, output);
|
|
55928
56001
|
const toolDurationMs = elapsedMs(message.timestampMs, result.timestampMs);
|
|
55929
56002
|
const toolOutcome = failed ? {
|
|
55930
56003
|
status: "failed",
|
|
@@ -56241,12 +56314,6 @@ async function forkClaudeSession(input) {
|
|
|
56241
56314
|
error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
|
|
56242
56315
|
};
|
|
56243
56316
|
}
|
|
56244
|
-
if (path11.resolve(sourceInfo.cwd) !== input.cwd) {
|
|
56245
|
-
return {
|
|
56246
|
-
ok: false,
|
|
56247
|
-
error: error51("unsupported", "Claude Code cannot Fork across working directories", false)
|
|
56248
|
-
};
|
|
56249
|
-
}
|
|
56250
56317
|
const source = await readSnapshot(input.dependencies, input.cwd, sourceRef.data.nativeSessionId);
|
|
56251
56318
|
if (!source.ok)
|
|
56252
56319
|
return source;
|
|
@@ -56342,7 +56409,7 @@ async function forkClaudeSession(input) {
|
|
|
56342
56409
|
|
|
56343
56410
|
// dist/claude-session-import.js
|
|
56344
56411
|
import { realpath as realpath4, stat as stat3 } from "node:fs/promises";
|
|
56345
|
-
import
|
|
56412
|
+
import path11 from "node:path";
|
|
56346
56413
|
function titleFromMetadata(metadata) {
|
|
56347
56414
|
for (const value of [metadata.customTitle, metadata.summary, metadata.firstPrompt]) {
|
|
56348
56415
|
if (typeof value !== "string")
|
|
@@ -56364,7 +56431,7 @@ async function sourceFromMetadata(metadata, isRunning, signal, canonicalCwds, pr
|
|
|
56364
56431
|
];
|
|
56365
56432
|
let cwd = null;
|
|
56366
56433
|
for (const candidate2 of new Set(candidates)) {
|
|
56367
|
-
if (!
|
|
56434
|
+
if (!path11.isAbsolute(candidate2))
|
|
56368
56435
|
continue;
|
|
56369
56436
|
let canonical = canonicalCwds.get(candidate2);
|
|
56370
56437
|
if (!canonical) {
|
|
@@ -56441,7 +56508,7 @@ var ClaudeSessionImportIndex = class {
|
|
|
56441
56508
|
if (!metadata || metadata.sessionId !== nativeSessionId)
|
|
56442
56509
|
return null;
|
|
56443
56510
|
const preferredCwds = [];
|
|
56444
|
-
if (typeof metadata.cwd === "string" &&
|
|
56511
|
+
if (typeof metadata.cwd === "string" && path11.isAbsolute(metadata.cwd)) {
|
|
56445
56512
|
try {
|
|
56446
56513
|
const messages = await this.#dependencies.readSessionMessages({
|
|
56447
56514
|
cwd: metadata.cwd,
|
|
@@ -56456,7 +56523,7 @@ var ClaudeSessionImportIndex = class {
|
|
|
56456
56523
|
continue;
|
|
56457
56524
|
}
|
|
56458
56525
|
const cwd = message.cwd;
|
|
56459
|
-
if (
|
|
56526
|
+
if (path11.isAbsolute(cwd) && !preferredCwds.includes(cwd))
|
|
56460
56527
|
preferredCwds.push(cwd);
|
|
56461
56528
|
}
|
|
56462
56529
|
} catch {
|
|
@@ -56472,13 +56539,13 @@ import { readFile as readFile6, rename as rename4, rm as rm5, stat as stat5, wri
|
|
|
56472
56539
|
|
|
56473
56540
|
// dist/claude-transcript.js
|
|
56474
56541
|
import os5 from "node:os";
|
|
56475
|
-
import
|
|
56542
|
+
import path12 from "node:path";
|
|
56476
56543
|
import { readFile as readFile5, readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
56477
56544
|
function projectDirectoryName(cwd) {
|
|
56478
56545
|
return cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
56479
56546
|
}
|
|
56480
56547
|
function configDirectory(environment) {
|
|
56481
|
-
return environment.CLAUDE_CONFIG_DIR ?
|
|
56548
|
+
return environment.CLAUDE_CONFIG_DIR ? path12.resolve(environment.CLAUDE_CONFIG_DIR) : path12.join(os5.homedir(), ".claude");
|
|
56482
56549
|
}
|
|
56483
56550
|
async function existingFile(file2) {
|
|
56484
56551
|
try {
|
|
@@ -56488,8 +56555,8 @@ async function existingFile(file2) {
|
|
|
56488
56555
|
}
|
|
56489
56556
|
}
|
|
56490
56557
|
async function findTranscriptFile(environment, cwd, relativeName) {
|
|
56491
|
-
const projectsDirectory =
|
|
56492
|
-
const expected =
|
|
56558
|
+
const projectsDirectory = path12.join(configDirectory(environment), "projects");
|
|
56559
|
+
const expected = path12.join(projectsDirectory, projectDirectoryName(cwd), relativeName);
|
|
56493
56560
|
if (await existingFile(expected))
|
|
56494
56561
|
return expected;
|
|
56495
56562
|
let projects;
|
|
@@ -56499,7 +56566,7 @@ async function findTranscriptFile(environment, cwd, relativeName) {
|
|
|
56499
56566
|
return null;
|
|
56500
56567
|
}
|
|
56501
56568
|
for (const project2 of projects) {
|
|
56502
|
-
const candidate =
|
|
56569
|
+
const candidate = path12.join(projectsDirectory, project2, relativeName);
|
|
56503
56570
|
if (await existingFile(candidate))
|
|
56504
56571
|
return candidate;
|
|
56505
56572
|
}
|
|
@@ -56536,7 +56603,7 @@ async function readClaudeTranscript(input) {
|
|
|
56536
56603
|
return parseTranscriptRecords(await readFile5(transcript, "utf8"), input.sessionId);
|
|
56537
56604
|
}
|
|
56538
56605
|
async function readClaudeSubagentTranscript(input) {
|
|
56539
|
-
const relativeName =
|
|
56606
|
+
const relativeName = path12.join(input.sessionId, "subagents", `agent-${input.nativeSubagentId}.jsonl`);
|
|
56540
56607
|
const transcript = await findTranscriptFile(input.environment, input.cwd, relativeName);
|
|
56541
56608
|
if (!transcript)
|
|
56542
56609
|
return null;
|
|
@@ -56621,13 +56688,13 @@ async function remapForkedSessionReferences(input) {
|
|
|
56621
56688
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
56622
56689
|
import { mkdir as mkdir4, readFile as readFile7, rename as rename5, rm as rm6, writeFile as writeFile3 } from "node:fs/promises";
|
|
56623
56690
|
import os6 from "node:os";
|
|
56624
|
-
import
|
|
56691
|
+
import path13 from "node:path";
|
|
56625
56692
|
var MILLION_CONTEXT_MODELS = [{ id: "claude-opus-5-5", aliases: ["claude-opus-5.5"] }];
|
|
56626
56693
|
var MILLION_CONTEXT_MODEL_IDS = new Set(MILLION_CONTEXT_MODELS.flatMap((model2) => [model2.id, ...model2.aliases]));
|
|
56627
56694
|
var MILLION_CONTEXT_SUFFIX = /\[1m\]$/iu;
|
|
56628
56695
|
function claudeLongContextFile(environment) {
|
|
56629
|
-
const root = environment.CODEXHOST_DATA_DIR ?
|
|
56630
|
-
return
|
|
56696
|
+
const root = environment.CODEXHOST_DATA_DIR ? path13.resolve(environment.CODEXHOST_DATA_DIR) : path13.join(os6.homedir(), ".codexhost");
|
|
56697
|
+
return path13.join(root, "claude-code-long-context.json");
|
|
56631
56698
|
}
|
|
56632
56699
|
async function readClaudeLongContext(environment) {
|
|
56633
56700
|
try {
|
|
@@ -56641,7 +56708,7 @@ async function readClaudeLongContext(environment) {
|
|
|
56641
56708
|
}
|
|
56642
56709
|
async function writeClaudeLongContext(environment, enabled) {
|
|
56643
56710
|
const file2 = claudeLongContextFile(environment);
|
|
56644
|
-
await mkdir4(
|
|
56711
|
+
await mkdir4(path13.dirname(file2), { recursive: true, mode: 448 });
|
|
56645
56712
|
const temporary = `${file2}.${randomUUID5()}.tmp`;
|
|
56646
56713
|
try {
|
|
56647
56714
|
await writeFile3(temporary, `${JSON.stringify({ enabled })}
|
|
@@ -56665,7 +56732,7 @@ function claudeSessionModel(model2, enabled) {
|
|
|
56665
56732
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
56666
56733
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
56667
56734
|
import os7 from "node:os";
|
|
56668
|
-
import
|
|
56735
|
+
import path14 from "node:path";
|
|
56669
56736
|
|
|
56670
56737
|
// dist/thinking-options.js
|
|
56671
56738
|
var option = (id2, label) => ({
|
|
@@ -56758,7 +56825,7 @@ function decodeClaudeModelRef(ref) {
|
|
|
56758
56825
|
return value === "default" ? void 0 : value;
|
|
56759
56826
|
}
|
|
56760
56827
|
function resolveClaudeConfigDirectory(environment = process.env) {
|
|
56761
|
-
return
|
|
56828
|
+
return path14.resolve(environment.CLAUDE_CONFIG_DIR ?? path14.join(os7.homedir(), ".claude"));
|
|
56762
56829
|
}
|
|
56763
56830
|
function parseModelPickerOptions(value) {
|
|
56764
56831
|
if (!Array.isArray(value))
|
|
@@ -56800,7 +56867,7 @@ function parseClaudeModelPickerSettings(value) {
|
|
|
56800
56867
|
};
|
|
56801
56868
|
}
|
|
56802
56869
|
async function readClaudeUserModelPicker(environment = process.env) {
|
|
56803
|
-
const settingsPath =
|
|
56870
|
+
const settingsPath = path14.join(resolveClaudeConfigDirectory(environment), "settings.json");
|
|
56804
56871
|
let raw;
|
|
56805
56872
|
try {
|
|
56806
56873
|
raw = await readFile8(settingsPath, "utf8");
|
|
@@ -57146,7 +57213,7 @@ function projectClaudeAccountUsage(usage, account) {
|
|
|
57146
57213
|
|
|
57147
57214
|
// dist/gateway-models.js
|
|
57148
57215
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
57149
|
-
import
|
|
57216
|
+
import path15 from "node:path";
|
|
57150
57217
|
var GATEWAY_MODELS_TIMEOUT_MS = 3e3;
|
|
57151
57218
|
var GATEWAY_MODELS_MAX_BYTES = 2 * 1024 * 1024;
|
|
57152
57219
|
var OFFICIAL_ANTHROPIC_HOST = "api.anthropic.com";
|
|
@@ -57188,14 +57255,14 @@ function claudeConfigDirectory(environment) {
|
|
|
57188
57255
|
if (configured)
|
|
57189
57256
|
return configured;
|
|
57190
57257
|
const home = trimmedEnv(environment, "HOME") ?? trimmedEnv(environment, "USERPROFILE");
|
|
57191
|
-
return home ?
|
|
57258
|
+
return home ? path15.join(home, ".claude") : void 0;
|
|
57192
57259
|
}
|
|
57193
57260
|
async function readClaudeUserSettingsEnv(environment) {
|
|
57194
57261
|
const configDir = claudeConfigDirectory(environment);
|
|
57195
57262
|
if (!configDir)
|
|
57196
57263
|
return {};
|
|
57197
57264
|
try {
|
|
57198
|
-
const raw = await readFile9(
|
|
57265
|
+
const raw = await readFile9(path15.join(configDir, "settings.json"), "utf8");
|
|
57199
57266
|
const parsed = JSON.parse(raw);
|
|
57200
57267
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
57201
57268
|
return {};
|
|
@@ -57328,7 +57395,7 @@ async function applyGatewayModelCatalog(snapshot, environment, dependencies = {}
|
|
|
57328
57395
|
|
|
57329
57396
|
// dist/process-fence.js
|
|
57330
57397
|
import { execFile as execFile3 } from "node:child_process";
|
|
57331
|
-
import
|
|
57398
|
+
import path16 from "node:path";
|
|
57332
57399
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
57333
57400
|
import { promisify } from "node:util";
|
|
57334
57401
|
var executeFile = promisify(execFile3);
|
|
@@ -57352,9 +57419,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
|
|
|
57352
57419
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
57353
57420
|
throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
|
|
57354
57421
|
const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
|
|
57355
|
-
if (!root || !
|
|
57422
|
+
if (!root || !path16.win32.isAbsolute(root))
|
|
57356
57423
|
throw new Error("Windows SystemRoot is unavailable");
|
|
57357
|
-
await executeFile(
|
|
57424
|
+
await executeFile(path16.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
|
|
57358
57425
|
timeout: timeoutMs,
|
|
57359
57426
|
windowsHide: true
|
|
57360
57427
|
});
|
|
@@ -57683,6 +57750,8 @@ var ClaudeSdkTransport = class {
|
|
|
57683
57750
|
/** Root tool calls of the requested Turn that have started and not yet returned a result. */
|
|
57684
57751
|
#rootToolCalls = /* @__PURE__ */ new Set();
|
|
57685
57752
|
#pendingSteers = /* @__PURE__ */ new Map();
|
|
57753
|
+
/** Written steers Claude has not yet drained into a native turn, by message ID. */
|
|
57754
|
+
#steerTakeovers = /* @__PURE__ */ new Map();
|
|
57686
57755
|
#autonomous = null;
|
|
57687
57756
|
#autonomousTurnHandler = null;
|
|
57688
57757
|
#idleHandler = null;
|
|
@@ -57806,9 +57875,16 @@ var ClaudeSdkTransport = class {
|
|
|
57806
57875
|
* `priority: "next"` joins after the current tool call, and a tool result is always followed by
|
|
57807
57876
|
* another model request. So a steer written while a root tool call runs folds into this Turn;
|
|
57808
57877
|
* one written while Claude streams its final text may instead run as the next Turn.
|
|
57878
|
+
*
|
|
57879
|
+
* A held Turn's continuation steers as well: while its idle stream is live, the pushed input
|
|
57880
|
+
* runs as that Turn's next Segment, and the background work the Turn waits on keeps running.
|
|
57809
57881
|
*/
|
|
57810
57882
|
canSteerActiveTurn() {
|
|
57811
|
-
|
|
57883
|
+
if (!this.#nativeSteer)
|
|
57884
|
+
return false;
|
|
57885
|
+
if (this.#active !== null)
|
|
57886
|
+
return this.#rootToolCalls.size > 0;
|
|
57887
|
+
return this.#idleLive && this.#idleHandler !== null;
|
|
57812
57888
|
}
|
|
57813
57889
|
#observeRootToolCalls(message) {
|
|
57814
57890
|
if (!isRecord10(message) || message.parent_tool_use_id != null)
|
|
@@ -57842,11 +57918,11 @@ var ClaudeSdkTransport = class {
|
|
|
57842
57918
|
this.#slashCommands = parseClaudeSlashCommands(message.commands);
|
|
57843
57919
|
}
|
|
57844
57920
|
}
|
|
57845
|
-
async getContextUsage() {
|
|
57921
|
+
async getContextUsage(detail = "full") {
|
|
57846
57922
|
const activeQuery = this.#query;
|
|
57847
57923
|
if (!this.#started || !activeQuery)
|
|
57848
57924
|
return null;
|
|
57849
|
-
return parseContextUsage(await activeQuery.getContextUsage());
|
|
57925
|
+
return parseContextUsage(await activeQuery.getContextUsage({ detail }));
|
|
57850
57926
|
}
|
|
57851
57927
|
getPermissionMode() {
|
|
57852
57928
|
if (!this.#started || !this.#query)
|
|
@@ -57984,7 +58060,7 @@ var ClaudeSdkTransport = class {
|
|
|
57984
58060
|
* The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
|
|
57985
58061
|
* after a bounded wait so callers that serialize requests are never held indefinitely.
|
|
57986
58062
|
*/
|
|
57987
|
-
steer(text2, messageId) {
|
|
58063
|
+
steer(text2, messageId, onTakeover) {
|
|
57988
58064
|
if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
|
|
57989
58065
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
57990
58066
|
}
|
|
@@ -58005,9 +58081,14 @@ var ClaudeSdkTransport = class {
|
|
|
58005
58081
|
this.#pendingSteers.delete(messageId);
|
|
58006
58082
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
58007
58083
|
}
|
|
58084
|
+
if (onTakeover)
|
|
58085
|
+
this.#steerTakeovers.set(messageId, onTakeover);
|
|
58008
58086
|
const pending = this.#pendingSteers.get(messageId);
|
|
58009
58087
|
if (pending) {
|
|
58010
|
-
pending.timer = setTimeout(() =>
|
|
58088
|
+
pending.timer = setTimeout(() => {
|
|
58089
|
+
this.#acceptSteer(messageId);
|
|
58090
|
+
this.#takeOverSteer(messageId, false);
|
|
58091
|
+
}, this.#steerQueuedTimeoutMs);
|
|
58011
58092
|
pending.timer.unref?.();
|
|
58012
58093
|
}
|
|
58013
58094
|
return promise2;
|
|
@@ -58020,6 +58101,13 @@ var ClaudeSdkTransport = class {
|
|
|
58020
58101
|
clearTimeout(pending.timer);
|
|
58021
58102
|
pending.resolve();
|
|
58022
58103
|
}
|
|
58104
|
+
#takeOverSteer(messageId, started) {
|
|
58105
|
+
const onTakeover = this.#steerTakeovers.get(messageId);
|
|
58106
|
+
if (!onTakeover)
|
|
58107
|
+
return;
|
|
58108
|
+
this.#steerTakeovers.delete(messageId);
|
|
58109
|
+
onTakeover(started);
|
|
58110
|
+
}
|
|
58023
58111
|
respondToInteraction(response) {
|
|
58024
58112
|
const pending = this.#interactions.get(response.requestId);
|
|
58025
58113
|
if (!pending) {
|
|
@@ -58301,6 +58389,9 @@ var ClaudeSdkTransport = class {
|
|
|
58301
58389
|
}
|
|
58302
58390
|
}
|
|
58303
58391
|
#rejectPendingSteers() {
|
|
58392
|
+
for (const messageId of [...this.#steerTakeovers.keys()]) {
|
|
58393
|
+
this.#takeOverSteer(messageId, false);
|
|
58394
|
+
}
|
|
58304
58395
|
const pending = [...this.#pendingSteers.values()];
|
|
58305
58396
|
this.#pendingSteers.clear();
|
|
58306
58397
|
const error52 = new Error("Claude Code steer receipt was lost after input was written");
|
|
@@ -58309,16 +58400,24 @@ var ClaudeSdkTransport = class {
|
|
|
58309
58400
|
entry.reject(error52);
|
|
58310
58401
|
}
|
|
58311
58402
|
}
|
|
58312
|
-
/**
|
|
58403
|
+
/**
|
|
58404
|
+
* `queued` is Claude's acceptance of this message into the running Session. `started` is its
|
|
58405
|
+
* drain into a native turn, folded into the running one or run as the next; a terminal state
|
|
58406
|
+
* without `started` means no native turn takes it over.
|
|
58407
|
+
*/
|
|
58313
58408
|
#observeSteer(message) {
|
|
58314
|
-
if (this.#pendingSteers.size === 0 || !isRecord10(message) || message.type !== "command_lifecycle") {
|
|
58409
|
+
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !isRecord10(message) || message.type !== "command_lifecycle") {
|
|
58315
58410
|
return;
|
|
58316
58411
|
}
|
|
58317
|
-
if (message.state !== "queued")
|
|
58318
|
-
return;
|
|
58319
58412
|
if (typeof message.command_uuid !== "string" || message.command_uuid.length === 0)
|
|
58320
58413
|
return;
|
|
58321
|
-
|
|
58414
|
+
if (message.state === "queued") {
|
|
58415
|
+
this.#acceptSteer(message.command_uuid);
|
|
58416
|
+
return;
|
|
58417
|
+
}
|
|
58418
|
+
if (["started", "completed", "cancelled", "discarded", "refused"].includes(String(message.state))) {
|
|
58419
|
+
this.#takeOverSteer(message.command_uuid, message.state === "started");
|
|
58420
|
+
}
|
|
58322
58421
|
}
|
|
58323
58422
|
#observeBackgroundTasks(message) {
|
|
58324
58423
|
if (!isRecord10(message) || message.type !== "system")
|
|
@@ -58431,13 +58530,13 @@ var ClaudeSdkTransport = class {
|
|
|
58431
58530
|
throw new Error("Claude SDK Query ended unexpectedly");
|
|
58432
58531
|
} catch (error52) {
|
|
58433
58532
|
const active = this.#active;
|
|
58533
|
+
if (!this.#closePromise)
|
|
58534
|
+
this.#onFault(error52);
|
|
58434
58535
|
this.#closeInteractions("all", "cancelled");
|
|
58435
58536
|
this.#rejectPendingSteers();
|
|
58436
58537
|
this.#rootToolCalls.clear();
|
|
58437
58538
|
this.#active = null;
|
|
58438
58539
|
active?.reject(error52);
|
|
58439
|
-
if (!this.#closePromise)
|
|
58440
|
-
this.#onFault(error52);
|
|
58441
58540
|
}
|
|
58442
58541
|
}
|
|
58443
58542
|
#spawn(options) {
|
|
@@ -58738,7 +58837,7 @@ var ClaudeSubagentLifecycle = class {
|
|
|
58738
58837
|
});
|
|
58739
58838
|
const outcome = cancellationRequested ? { status: "cancelled", reason: "Cancelled by user" } : event.isError ? { status: "failed", error: subagentFailure() } : { status: "succeeded" };
|
|
58740
58839
|
this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
|
|
58741
|
-
return subagent;
|
|
58840
|
+
return { operation: active.item.operation, subagent };
|
|
58742
58841
|
}
|
|
58743
58842
|
finalize(turnId, outcome) {
|
|
58744
58843
|
for (const [callId, active] of this.#delegations) {
|
|
@@ -58946,9 +59045,9 @@ function stringField(value, keys) {
|
|
|
58946
59045
|
if (!isRecord11(value))
|
|
58947
59046
|
return void 0;
|
|
58948
59047
|
for (const key of keys) {
|
|
58949
|
-
const
|
|
58950
|
-
if (typeof
|
|
58951
|
-
return
|
|
59048
|
+
const field2 = value[key];
|
|
59049
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
59050
|
+
return field2;
|
|
58952
59051
|
}
|
|
58953
59052
|
return void 0;
|
|
58954
59053
|
}
|
|
@@ -59635,10 +59734,12 @@ var ClaudeHarnessSession = class {
|
|
|
59635
59734
|
input: { image: true },
|
|
59636
59735
|
history: { fork: true, forkAcrossCwd: false, rollbackLastTurn: true },
|
|
59637
59736
|
subagents: { observe: true, readTranscript: true },
|
|
59638
|
-
// Read live: native delivery joins this Turn
|
|
59639
|
-
// on a CLI that confirms steers
|
|
59737
|
+
// Read live: native delivery joins this Turn while a root tool call runs, or while a held
|
|
59738
|
+
// Turn's continuation waits on background work, on a CLI that confirms steers
|
|
59739
|
+
// (`msg_lifecycle_v1`). A Turn whose cancellation is in flight must not take more input;
|
|
59740
|
+
// every other case stops and restarts.
|
|
59640
59741
|
get steer() {
|
|
59641
|
-
return session.#transport?.canSteerActiveTurn?.() === true;
|
|
59742
|
+
return session.#transport?.canSteerActiveTurn?.() === true && session.#active?.cancellationRequested !== true;
|
|
59642
59743
|
}
|
|
59643
59744
|
}))(this);
|
|
59644
59745
|
commands;
|
|
@@ -59690,7 +59791,6 @@ var ClaudeHarnessSession = class {
|
|
|
59690
59791
|
#lastAssistantResponseAtUnix;
|
|
59691
59792
|
#accountCreditsSupported;
|
|
59692
59793
|
#minimumContextUsedTokens = null;
|
|
59693
|
-
#latestRequestModel = null;
|
|
59694
59794
|
#calibratedInputTokens = 0;
|
|
59695
59795
|
#calibratedCachedInputTokens = 0;
|
|
59696
59796
|
#calibratedCacheWriteInputTokens = 0;
|
|
@@ -59983,6 +60083,7 @@ var ClaudeHarnessSession = class {
|
|
|
59983
60083
|
nativeTurnKey,
|
|
59984
60084
|
nativeTurnRef: null,
|
|
59985
60085
|
cancellationRequested: false,
|
|
60086
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
59986
60087
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
59987
60088
|
estimatedInputTokens: 0,
|
|
59988
60089
|
estimatedCachedInputTokens: 0,
|
|
@@ -60023,9 +60124,13 @@ var ClaudeHarnessSession = class {
|
|
|
60023
60124
|
return { ok: true, value: { turnId: command.turnId } };
|
|
60024
60125
|
}
|
|
60025
60126
|
async #steer(command) {
|
|
60026
|
-
|
|
60127
|
+
const active = this.#active;
|
|
60128
|
+
if (!active || active.command.turnId !== command.turnId) {
|
|
60027
60129
|
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
60028
60130
|
}
|
|
60131
|
+
if (active.cancellationRequested) {
|
|
60132
|
+
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
60133
|
+
}
|
|
60029
60134
|
const text2 = command.input.map((input) => input.text).join("\n");
|
|
60030
60135
|
if (text2.length === 0) {
|
|
60031
60136
|
return {
|
|
@@ -60051,10 +60156,13 @@ var ClaudeHarnessSession = class {
|
|
|
60051
60156
|
}
|
|
60052
60157
|
};
|
|
60053
60158
|
}
|
|
60159
|
+
const messageId = this.#randomUUID();
|
|
60160
|
+
active.steersAwaitingNative.add(messageId);
|
|
60054
60161
|
try {
|
|
60055
|
-
await transport.steer(text2, this.#
|
|
60162
|
+
await transport.steer(text2, messageId, (started) => this.#takeOverSteer(active, messageId, started));
|
|
60056
60163
|
} catch (error52) {
|
|
60057
60164
|
if (error52 instanceof ClaudeSteerMissedTurnError) {
|
|
60165
|
+
this.#takeOverSteer(active, messageId, false);
|
|
60058
60166
|
return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
|
|
60059
60167
|
}
|
|
60060
60168
|
throw error52;
|
|
@@ -60157,6 +60265,7 @@ var ClaudeHarnessSession = class {
|
|
|
60157
60265
|
nativeTurnKey,
|
|
60158
60266
|
nativeTurnRef: null,
|
|
60159
60267
|
cancellationRequested: false,
|
|
60268
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
60160
60269
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
60161
60270
|
estimatedInputTokens: 0,
|
|
60162
60271
|
estimatedCachedInputTokens: 0,
|
|
@@ -60232,15 +60341,16 @@ var ClaudeHarnessSession = class {
|
|
|
60232
60341
|
this.#contextUsageCooldownUntilMs = 0;
|
|
60233
60342
|
this.#requestContextUsage(transport, void 0, CONTEXT_USAGE_RETRY_DELAYS_MS);
|
|
60234
60343
|
}
|
|
60235
|
-
refreshUsage() {
|
|
60344
|
+
async refreshUsage() {
|
|
60345
|
+
await this.#contextRefreshInFlight;
|
|
60236
60346
|
if (this.#phase !== "open" || !this.#transport)
|
|
60237
|
-
return
|
|
60347
|
+
return;
|
|
60238
60348
|
const now = Date.now();
|
|
60239
60349
|
if (now < this.#contextUsageFreshUntilMs || now < this.#contextUsageCooldownUntilMs) {
|
|
60240
|
-
return
|
|
60350
|
+
return;
|
|
60241
60351
|
}
|
|
60242
60352
|
this.#requestContextUsage(this.#transport, this.#active?.command.turnId, CONTEXT_USAGE_RETRY_DELAYS_MS);
|
|
60243
|
-
|
|
60353
|
+
await this.#contextRefreshInFlight;
|
|
60244
60354
|
}
|
|
60245
60355
|
blocksRollback(sessionId) {
|
|
60246
60356
|
return this.#sessionId === sessionId && (this.#phase !== "open" || this.#active !== null || this.#acceptingTurn || this.#configurationTask !== null || this.#readingHistory);
|
|
@@ -60547,7 +60657,7 @@ var ClaudeHarnessSession = class {
|
|
|
60547
60657
|
active.cancellationRequested = true;
|
|
60548
60658
|
const transport = this.#transport;
|
|
60549
60659
|
const taskIds = this.#backgroundTaskIds(active);
|
|
60550
|
-
if (transport && (taskIds.length > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation))) {
|
|
60660
|
+
if (transport && (taskIds.length > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation || active.steersAwaitingNative.size > 0))) {
|
|
60551
60661
|
await this.#cancelBackgroundWork(active, transport, taskIds);
|
|
60552
60662
|
return { ok: true, value: { cancellationRequested: true } };
|
|
60553
60663
|
}
|
|
@@ -60622,6 +60732,11 @@ var ClaudeHarnessSession = class {
|
|
|
60622
60732
|
return;
|
|
60623
60733
|
if (cancellation.stopping || cancellation.interrupting || active.rootSegmentActive)
|
|
60624
60734
|
return;
|
|
60735
|
+
if (active.steersAwaitingNative.size > 0) {
|
|
60736
|
+
this.#armCancelEscalation(active);
|
|
60737
|
+
return;
|
|
60738
|
+
}
|
|
60739
|
+
this.#clearCancelEscalation();
|
|
60625
60740
|
this.#clearCancellationQuiet(cancellation);
|
|
60626
60741
|
const quiet = setTimeout(() => {
|
|
60627
60742
|
cancellation.quiet = null;
|
|
@@ -60902,10 +61017,7 @@ var ClaudeHarnessSession = class {
|
|
|
60902
61017
|
}
|
|
60903
61018
|
this.#completeAgentItem(active, { status: "succeeded" }, false);
|
|
60904
61019
|
active.subagents.start(active.command.turnId, event);
|
|
60905
|
-
if (event.operation === "
|
|
60906
|
-
if (event.nativeSubagentId)
|
|
60907
|
-
this.#occupancy.occupyAgent(event.nativeSubagentId);
|
|
60908
|
-
} else if (event.background) {
|
|
61020
|
+
if (event.operation === "spawn" && event.background) {
|
|
60909
61021
|
this.#occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
60910
61022
|
}
|
|
60911
61023
|
return;
|
|
@@ -60924,7 +61036,13 @@ var ClaudeHarnessSession = class {
|
|
|
60924
61036
|
}
|
|
60925
61037
|
return;
|
|
60926
61038
|
case "subagent.completed": {
|
|
60927
|
-
const subagent = active.subagents.complete(active.command.turnId, event, active.cancellationRequested);
|
|
61039
|
+
const { operation, subagent } = active.subagents.complete(active.command.turnId, event, active.cancellationRequested);
|
|
61040
|
+
if (operation === "send") {
|
|
61041
|
+
if (subagent.status === "running" && subagent.nativeSubagentId) {
|
|
61042
|
+
this.#occupancy.occupyAgent(subagent.nativeSubagentId);
|
|
61043
|
+
}
|
|
61044
|
+
return;
|
|
61045
|
+
}
|
|
60928
61046
|
if (subagent.status === "running") {
|
|
60929
61047
|
this.#occupancy.occupySpawn(event.callId, subagent.nativeSubagentId);
|
|
60930
61048
|
return;
|
|
@@ -61254,6 +61372,7 @@ var ClaudeHarnessSession = class {
|
|
|
61254
61372
|
const active = {
|
|
61255
61373
|
command: { type: "turn.start", turnId, input: [] },
|
|
61256
61374
|
compactionItem: null,
|
|
61375
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
61257
61376
|
item,
|
|
61258
61377
|
agentMessageOrdinal: 1,
|
|
61259
61378
|
assistantMessageId: null,
|
|
@@ -61395,7 +61514,7 @@ var ClaudeHarnessSession = class {
|
|
|
61395
61514
|
this.#finishFailed(active, transportFailure(result.kind));
|
|
61396
61515
|
}
|
|
61397
61516
|
}
|
|
61398
|
-
#requestContextUsage(transport, turnId, retryDelaysMs) {
|
|
61517
|
+
#requestContextUsage(transport, turnId, retryDelaysMs, detail = "full") {
|
|
61399
61518
|
if (this.#phase !== "open" || this.#transport !== transport)
|
|
61400
61519
|
return;
|
|
61401
61520
|
if (this.#contextRefreshInFlight)
|
|
@@ -61404,7 +61523,8 @@ var ClaudeHarnessSession = class {
|
|
|
61404
61523
|
transport,
|
|
61405
61524
|
...turnId !== void 0 ? { turnId } : {},
|
|
61406
61525
|
generation: this.#usageGeneration,
|
|
61407
|
-
retryDelaysMs
|
|
61526
|
+
retryDelaysMs,
|
|
61527
|
+
detail
|
|
61408
61528
|
};
|
|
61409
61529
|
this.#contextRefreshInFlight = this.#drainContextUsage();
|
|
61410
61530
|
}
|
|
@@ -61430,14 +61550,16 @@ var ClaudeHarnessSession = class {
|
|
|
61430
61550
|
return;
|
|
61431
61551
|
}
|
|
61432
61552
|
try {
|
|
61433
|
-
const context = await request.transport.getContextUsage();
|
|
61553
|
+
const context = await request.transport.getContextUsage(request.detail);
|
|
61434
61554
|
if (this.#phase !== "open" || this.#transport !== request.transport || this.#usageGeneration !== request.generation || this.#contextRefreshPending !== null) {
|
|
61435
61555
|
return;
|
|
61436
61556
|
}
|
|
61437
61557
|
if (context === null)
|
|
61438
61558
|
continue;
|
|
61439
|
-
|
|
61440
|
-
|
|
61559
|
+
if (request.detail === "full") {
|
|
61560
|
+
this.#contextUsageFreshUntilMs = Date.now() + CONTEXT_USAGE_TTL_MS;
|
|
61561
|
+
this.#contextUsageCooldownUntilMs = 0;
|
|
61562
|
+
}
|
|
61441
61563
|
const delta = {
|
|
61442
61564
|
contextUsedTokens: Math.max(context.usedTokens, this.#minimumContextUsedTokens ?? 0),
|
|
61443
61565
|
contextWindowTokens: context.maxTokens
|
|
@@ -61452,7 +61574,7 @@ var ClaudeHarnessSession = class {
|
|
|
61452
61574
|
} catch {
|
|
61453
61575
|
}
|
|
61454
61576
|
}
|
|
61455
|
-
if (this.#phase === "open" && this.#transport === request.transport && this.#usageGeneration === request.generation) {
|
|
61577
|
+
if (request.detail === "full" && this.#phase === "open" && this.#transport === request.transport && this.#usageGeneration === request.generation) {
|
|
61456
61578
|
this.#contextUsageCooldownUntilMs = Date.now() + CONTEXT_USAGE_FAILURE_COOLDOWN_MS;
|
|
61457
61579
|
}
|
|
61458
61580
|
}
|
|
@@ -61533,8 +61655,6 @@ var ClaudeHarnessSession = class {
|
|
|
61533
61655
|
const promptTokens = usage.inputTokens + usage.cacheCreationInputTokens + usage.cacheReadInputTokens;
|
|
61534
61656
|
if (promptTokens > 0)
|
|
61535
61657
|
this.#minimumContextUsedTokens = promptTokens;
|
|
61536
|
-
if (usage.model)
|
|
61537
|
-
this.#latestRequestModel = usage.model;
|
|
61538
61658
|
const cacheHitRatePercent = this.#cacheHitRatePercent(usage);
|
|
61539
61659
|
const contextWindowTokens = this.#latestUsage?.contextWindowTokens;
|
|
61540
61660
|
this.#mergeAndPublishUsage({
|
|
@@ -61599,24 +61719,11 @@ var ClaudeHarnessSession = class {
|
|
|
61599
61719
|
if (cacheHitRatePercent !== void 0)
|
|
61600
61720
|
delta.cacheHitRatePercent = cacheHitRatePercent;
|
|
61601
61721
|
}
|
|
61602
|
-
if (this.#
|
|
61603
|
-
|
|
61604
|
-
if (contextWindowTokens !== void 0) {
|
|
61605
|
-
delta.contextUsedTokens = this.#minimumContextUsedTokens;
|
|
61606
|
-
delta.contextWindowTokens = contextWindowTokens;
|
|
61607
|
-
}
|
|
61722
|
+
if (this.#transport && this.#minimumContextUsedTokens !== null && event.modelUsage?.some(({ contextWindowTokens }) => contextWindowTokens !== void 0)) {
|
|
61723
|
+
this.#requestContextUsage(this.#transport, active.command.turnId, [0], "summary");
|
|
61608
61724
|
}
|
|
61609
61725
|
this.#mergeAndPublishUsage(delta, active.command.turnId);
|
|
61610
61726
|
}
|
|
61611
|
-
/** The latest request's Model, else the Model that carried the most prompt tokens. */
|
|
61612
|
-
#resultContextWindow(modelUsage) {
|
|
61613
|
-
if (!modelUsage?.length)
|
|
61614
|
-
return void 0;
|
|
61615
|
-
const latest = this.#latestRequestModel;
|
|
61616
|
-
const matched = latest ? modelUsage.find(({ model: model2 }) => model2 === latest) : void 0;
|
|
61617
|
-
const main = matched ?? modelUsage.reduce((best, entry) => (entry.promptTokens ?? entry.inputTokens) > (best.promptTokens ?? best.inputTokens) ? entry : best);
|
|
61618
|
-
return main.contextWindowTokens;
|
|
61619
|
-
}
|
|
61620
61727
|
/**
|
|
61621
61728
|
* Plan usage is account-wide, not Thread-scoped, so every observation is
|
|
61622
61729
|
* offered to the Adapter's shared cache regardless of this Session's own
|
|
@@ -61695,7 +61802,7 @@ var ClaudeHarnessSession = class {
|
|
|
61695
61802
|
this.#clearContinuationQuiescence();
|
|
61696
61803
|
const quiescence = setTimeout(() => {
|
|
61697
61804
|
this.#continuationQuiescence = null;
|
|
61698
|
-
if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open") {
|
|
61805
|
+
if (this.#active !== active || !active.held || active.rootSegmentActive || active.steersAwaitingNative.size > 0 || this.#phase !== "open") {
|
|
61699
61806
|
return;
|
|
61700
61807
|
}
|
|
61701
61808
|
this.#occupancy.releaseContinuations();
|
|
@@ -61716,6 +61823,30 @@ var ClaudeHarnessSession = class {
|
|
|
61716
61823
|
active.rootSegmentActive = true;
|
|
61717
61824
|
this.#clearContinuationQuiescence();
|
|
61718
61825
|
}
|
|
61826
|
+
/**
|
|
61827
|
+
* A drained steer runs in a native turn whose result still reaches this Turn, folded into the
|
|
61828
|
+
* running Root Segment or as the held Turn's next one. A steer that ends without one releases
|
|
61829
|
+
* its keep-open, so a Turn held only for it settles as if the steer had never been written.
|
|
61830
|
+
*/
|
|
61831
|
+
#takeOverSteer(active, messageId, started) {
|
|
61832
|
+
if (!active.steersAwaitingNative.delete(messageId) || this.#active !== active)
|
|
61833
|
+
return;
|
|
61834
|
+
if (started) {
|
|
61835
|
+
this.#handleTurnEvent(active, { type: "segment.started" });
|
|
61836
|
+
return;
|
|
61837
|
+
}
|
|
61838
|
+
if (active.cancellation) {
|
|
61839
|
+
this.#settleCancellation(active);
|
|
61840
|
+
return;
|
|
61841
|
+
}
|
|
61842
|
+
if (!active.held || active.rootSegmentActive || active.steersAwaitingNative.size > 0 || this.#phase !== "open") {
|
|
61843
|
+
return;
|
|
61844
|
+
}
|
|
61845
|
+
if (this.#occupancy.awaitingContinuation)
|
|
61846
|
+
this.#armContinuationQuiescence(active);
|
|
61847
|
+
else if (!this.#occupancy.unsettled)
|
|
61848
|
+
this.#finish(active, { status: "succeeded" });
|
|
61849
|
+
}
|
|
61719
61850
|
#finish(active, outcome) {
|
|
61720
61851
|
if (this.#active !== active)
|
|
61721
61852
|
return;
|
|
@@ -61726,7 +61857,7 @@ var ClaudeHarnessSession = class {
|
|
|
61726
61857
|
active.cancellation = null;
|
|
61727
61858
|
}
|
|
61728
61859
|
this.#clearContinuationQuiescence();
|
|
61729
|
-
const hold = outcome.status === "succeeded" && !active.cancellationRequested && this.#occupancy.unsettled;
|
|
61860
|
+
const hold = outcome.status === "succeeded" && !active.cancellationRequested && (this.#occupancy.unsettled || active.steersAwaitingNative.size > 0);
|
|
61730
61861
|
this.#closeActiveInteractions(active, outcome.status === "succeeded" ? "superseded" : "cancelled", hold);
|
|
61731
61862
|
const itemOutcome2 = outcome;
|
|
61732
61863
|
if (active.compactionItem)
|
|
@@ -62008,7 +62139,7 @@ var ClaudeCodeAdapter = class {
|
|
|
62008
62139
|
error: invalidState("Claude Code Adapter is closing")
|
|
62009
62140
|
};
|
|
62010
62141
|
}
|
|
62011
|
-
const cwd =
|
|
62142
|
+
const cwd = path17.resolve(input.cwd ?? process.cwd());
|
|
62012
62143
|
if (!input.refresh) {
|
|
62013
62144
|
const cached2 = this.#inspectionCache.get(cwd);
|
|
62014
62145
|
if (cached2)
|
|
@@ -62213,7 +62344,7 @@ var ClaudeCodeAdapter = class {
|
|
|
62213
62344
|
}
|
|
62214
62345
|
requestedPermissionModeId = CLAUDE_DEFAULT_PERMISSION_MODE_ID;
|
|
62215
62346
|
}
|
|
62216
|
-
const cwd =
|
|
62347
|
+
const cwd = path17.resolve(input.cwd);
|
|
62217
62348
|
if (input.kind === "rollbackLastTurn") {
|
|
62218
62349
|
for (const source of this.#sessions) {
|
|
62219
62350
|
const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
|
|
@@ -62382,7 +62513,7 @@ var ClaudeCodeAdapter = class {
|
|
|
62382
62513
|
// dist/installation.js
|
|
62383
62514
|
import { readFile as readFile10, realpath as realpath5 } from "node:fs/promises";
|
|
62384
62515
|
import { homedir as homedir2 } from "node:os";
|
|
62385
|
-
import
|
|
62516
|
+
import path18 from "node:path";
|
|
62386
62517
|
async function readSettings(file2) {
|
|
62387
62518
|
const text2 = await readFile10(file2, "utf8").catch((error52) => {
|
|
62388
62519
|
if (error52.code === "ENOENT")
|
|
@@ -62403,9 +62534,9 @@ function createClaudeInstallation(environment, command) {
|
|
|
62403
62534
|
...command ? { command } : {}
|
|
62404
62535
|
});
|
|
62405
62536
|
const home = environment.HOME ?? environment.USERPROFILE ?? homedir2();
|
|
62406
|
-
const config2 = environment.CLAUDE_CONFIG_DIR ?
|
|
62407
|
-
const managedFile = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : process.platform === "win32" ?
|
|
62408
|
-
const user = await readSettings(
|
|
62537
|
+
const config2 = environment.CLAUDE_CONFIG_DIR ? path18.resolve(home, environment.CLAUDE_CONFIG_DIR) : path18.join(home, ".claude");
|
|
62538
|
+
const managedFile = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : process.platform === "win32" ? path18.join(environment.ProgramFiles ?? "C:\\Program Files", "ClaudeCode", "managed-settings.json") : "/etc/claude-code/managed-settings.json";
|
|
62539
|
+
const user = await readSettings(path18.join(config2, "settings.json"));
|
|
62409
62540
|
const managed = await readSettings(managedFile);
|
|
62410
62541
|
const settings = { ...user, ...managed, env: { ...user.env, ...managed.env } };
|
|
62411
62542
|
const env = { ...environment, ...settings.env };
|
|
@@ -62418,10 +62549,10 @@ function createClaudeInstallation(environment, command) {
|
|
|
62418
62549
|
throw new Error("Unknown Claude release channel");
|
|
62419
62550
|
const latestVersion = installationVersion(await fetchInstallationText(`https://downloads.claude.ai/claude-code-releases/${channel}`));
|
|
62420
62551
|
const npm = await npmInstallation(executable, ["@anthropic-ai/claude-code"], env);
|
|
62421
|
-
const launcher =
|
|
62552
|
+
const launcher = path18.join(home, ".local", "bin", process.platform === "win32" ? "claude.exe" : "claude");
|
|
62422
62553
|
const selected = await realpath5(executable);
|
|
62423
|
-
const versions =
|
|
62424
|
-
const native =
|
|
62554
|
+
const versions = path18.join(home, ".local", "share", "claude", "versions") + path18.sep;
|
|
62555
|
+
const native = path18.resolve(executable) === launcher && (selected.startsWith(versions) || process.platform === "win32" && selected === launcher);
|
|
62425
62556
|
const blocked = !!env.DISABLE_UPDATES && env.DISABLE_UPDATES !== "0" || !!settings.minimumVersion && newerInstallationVersion(latestVersion, installationVersion(settings.minimumVersion)) || !!settings.requiredMaximumVersion && newerInstallationVersion(installationVersion(settings.requiredMaximumVersion), latestVersion);
|
|
62426
62557
|
const canUpdate = !blocked && (npm?.canUpdate ?? native);
|
|
62427
62558
|
update = async () => {
|
|
@@ -62452,7 +62583,7 @@ function createClaudeInstallation(environment, command) {
|
|
|
62452
62583
|
}
|
|
62453
62584
|
|
|
62454
62585
|
// dist/user-shell-environment.js
|
|
62455
|
-
import
|
|
62586
|
+
import path19 from "node:path";
|
|
62456
62587
|
import { execFile as execFile4 } from "node:child_process";
|
|
62457
62588
|
var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
|
|
62458
62589
|
var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
|
|
@@ -62495,7 +62626,7 @@ async function withUserShellEnvironment(environment, dependencies) {
|
|
|
62495
62626
|
if (platform === "win32" || !environment.HOME)
|
|
62496
62627
|
return environment;
|
|
62497
62628
|
const shell = environment.SHELL?.trim() || defaultShell(platform);
|
|
62498
|
-
if (!shell || !SUPPORTED_SHELLS.has(
|
|
62629
|
+
if (!shell || !SUPPORTED_SHELLS.has(path19.basename(shell)))
|
|
62499
62630
|
return environment;
|
|
62500
62631
|
const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
|
|
62501
62632
|
const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);
|
|
@@ -62533,6 +62664,7 @@ async function createHarnessAdapter(context) {
|
|
|
62533
62664
|
const environment = await withUserShellEnvironment({ ...context.environment });
|
|
62534
62665
|
if (context.platform === "darwin" && context.managedRemoteHost) {
|
|
62535
62666
|
return new BrokeredHarnessAdapter({
|
|
62667
|
+
sessionImport: true,
|
|
62536
62668
|
forwardDelegationEnvironment: true,
|
|
62537
62669
|
commandCatalog: claudeCommandCatalog,
|
|
62538
62670
|
liveCommandCatalog: true,
|