@codexhost/cli-win32-arm64 0.14.0 → 0.15.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 +51 -6
- package/app/console-web.js +212 -64
- package/app/desktop-controller.mjs +48 -3
- package/app/host-runtime.mjs +358 -79
- package/app/plugins/antigravity/plugin.mjs +340 -53
- package/app/plugins/claude-code/plugin.mjs +373 -132
- package/app/plugins/codebuddy/plugin.mjs +205 -46
- package/app/plugins/codex-usage/plugin.mjs +73 -28
- package/app/plugins/copilot/plugin.mjs +98 -53
- package/app/plugins/cursor-cli/plugin.mjs +205 -46
- package/app/plugins/deepseek-harness/plugin.mjs +77 -32
- package/app/plugins/grok/plugin.mjs +352 -84
- package/app/plugins/hermes/plugin.mjs +48 -3
- package/app/plugins/kimi-code/plugin.mjs +60 -15
- package/app/plugins/kiro-cli/plugin.mjs +60 -15
- package/app/plugins/omp/plugin.mjs +80 -35
- package/app/plugins/opencode/plugin.mjs +102 -57
- package/app/plugins/pi/plugin.mjs +113 -43
- package/app/plugins/qoder/plugin.mjs +70 -25
- package/app/plugins/qoder-cn/plugin.mjs +70 -25
- package/app/plugins/workbuddy/plugin.mjs +205 -46
- package/app/plugins/zcode/plugin.mjs +99 -29
- package/app/renderer-extension.js +944 -249
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +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, path18) {
|
|
781
|
+
if (!path18)
|
|
782
782
|
return obj;
|
|
783
|
-
return
|
|
783
|
+
return path18.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(path18, 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(path18);
|
|
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, path18 = []) => {
|
|
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 }, [...path18, ...issue2.path]));
|
|
1347
1347
|
} else if (issue2.code === "invalid_key") {
|
|
1348
|
-
processError({ issues: issue2.issues }, [...
|
|
1348
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1349
1349
|
} else if (issue2.code === "invalid_element") {
|
|
1350
|
-
processError({ issues: issue2.issues }, [...
|
|
1350
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1351
1351
|
} else {
|
|
1352
|
-
const fullpath = [...
|
|
1352
|
+
const fullpath = [...path18, ...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, path18 = []) => {
|
|
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 }, [...path18, ...issue2.path]));
|
|
1384
1384
|
} else if (issue2.code === "invalid_key") {
|
|
1385
|
-
processError({ issues: issue2.issues }, [...
|
|
1385
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1386
1386
|
} else if (issue2.code === "invalid_element") {
|
|
1387
|
-
processError({ issues: issue2.issues }, [...
|
|
1387
|
+
processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
|
|
1388
1388
|
} else {
|
|
1389
|
-
const fullpath = [...
|
|
1389
|
+
const fullpath = [...path18, ...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 path18 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1422
|
+
for (const seg of path18) {
|
|
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 path18 = ref.slice(1).split("/").filter(Boolean);
|
|
14115
|
+
if (path18.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 (path18[0] === defsKey) {
|
|
14120
|
+
const key = path18[1];
|
|
14121
14121
|
if (!key || !ctx.defs[key]) {
|
|
14122
14122
|
throw new Error(`Reference not found: ${ref}`);
|
|
14123
14123
|
}
|
|
@@ -14790,6 +14790,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
|
14790
14790
|
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
14791
14791
|
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
14792
14792
|
|
|
14793
|
+
// ../../shared-contracts/dist/thread-questions.js
|
|
14794
|
+
var field = external_exports.discriminatedUnion("type", [
|
|
14795
|
+
external_exports.object({
|
|
14796
|
+
id: external_exports.string().min(1),
|
|
14797
|
+
type: external_exports.literal("choice"),
|
|
14798
|
+
prompt: external_exports.string(),
|
|
14799
|
+
options: external_exports.array(external_exports.object({
|
|
14800
|
+
value: external_exports.string().min(1),
|
|
14801
|
+
label: external_exports.string(),
|
|
14802
|
+
description: external_exports.string().optional()
|
|
14803
|
+
})).min(1),
|
|
14804
|
+
multiple: external_exports.boolean(),
|
|
14805
|
+
allowOther: external_exports.boolean(),
|
|
14806
|
+
optional: external_exports.boolean()
|
|
14807
|
+
}),
|
|
14808
|
+
external_exports.object({
|
|
14809
|
+
id: external_exports.string().min(1),
|
|
14810
|
+
type: external_exports.literal("text"),
|
|
14811
|
+
prompt: external_exports.string(),
|
|
14812
|
+
multiline: external_exports.boolean(),
|
|
14813
|
+
secret: external_exports.literal(false),
|
|
14814
|
+
optional: external_exports.boolean(),
|
|
14815
|
+
placeholder: external_exports.string().optional(),
|
|
14816
|
+
prefill: external_exports.string().optional()
|
|
14817
|
+
})
|
|
14818
|
+
]);
|
|
14819
|
+
var threadQuestionSchema = external_exports.object({
|
|
14820
|
+
interactionId: external_exports.string().min(1),
|
|
14821
|
+
turnId: external_exports.string().min(1),
|
|
14822
|
+
title: external_exports.string().optional(),
|
|
14823
|
+
questions: external_exports.array(field).min(1)
|
|
14824
|
+
}).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
|
|
14825
|
+
message: "Shared cards require at least one multi-select question"
|
|
14826
|
+
});
|
|
14827
|
+
var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
|
|
14828
|
+
var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
|
|
14829
|
+
var threadQuestionRespondParamsSchema = external_exports.strictObject({
|
|
14830
|
+
threadId: external_exports.string().min(1),
|
|
14831
|
+
turnId: external_exports.string().min(1),
|
|
14832
|
+
interactionId: external_exports.string().min(1),
|
|
14833
|
+
answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
14834
|
+
cancelled: external_exports.boolean().default(false)
|
|
14835
|
+
});
|
|
14836
|
+
var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
|
|
14837
|
+
|
|
14793
14838
|
// ../../shared-contracts/dist/console.js
|
|
14794
14839
|
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
14795
14840
|
title: external_exports.string().trim().min(1).max(200),
|
|
@@ -16111,26 +16156,26 @@ function parseHostUsage(value) {
|
|
|
16111
16156
|
}
|
|
16112
16157
|
}
|
|
16113
16158
|
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
16114
|
-
for (const
|
|
16159
|
+
for (const field2 of [
|
|
16115
16160
|
"totalCredits",
|
|
16116
16161
|
"contextUsagePercent",
|
|
16117
16162
|
"apiOutputTokensPerSecond"
|
|
16118
16163
|
]) {
|
|
16119
|
-
const candidate = value[
|
|
16164
|
+
const candidate = value[field2];
|
|
16120
16165
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16121
|
-
throw new Error(`Harness Usage '${
|
|
16166
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
16122
16167
|
}
|
|
16123
16168
|
}
|
|
16124
|
-
for (const
|
|
16125
|
-
const candidate = value[
|
|
16169
|
+
for (const field2 of tokenFields) {
|
|
16170
|
+
const candidate = value[field2];
|
|
16126
16171
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16127
|
-
throw new Error(`Harness Usage '${
|
|
16172
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16128
16173
|
}
|
|
16129
16174
|
}
|
|
16130
|
-
for (const
|
|
16131
|
-
const candidate = value[
|
|
16175
|
+
for (const field2 of safeIntegerFields) {
|
|
16176
|
+
const candidate = value[field2];
|
|
16132
16177
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16133
|
-
throw new Error(`Harness Usage '${
|
|
16178
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
16134
16179
|
}
|
|
16135
16180
|
}
|
|
16136
16181
|
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
@@ -16139,10 +16184,10 @@ function parseHostUsage(value) {
|
|
|
16139
16184
|
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
16140
16185
|
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
16141
16186
|
}
|
|
16142
|
-
for (const
|
|
16143
|
-
const candidate = value[
|
|
16187
|
+
for (const field2 of percentFields) {
|
|
16188
|
+
const candidate = value[field2];
|
|
16144
16189
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
16145
|
-
throw new Error(`Harness Usage '${
|
|
16190
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
16146
16191
|
}
|
|
16147
16192
|
}
|
|
16148
16193
|
if (value.sessionCacheUsage !== void 0) {
|
|
@@ -16213,19 +16258,19 @@ function parseHostUsageRequest(value) {
|
|
|
16213
16258
|
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
16214
16259
|
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
16215
16260
|
}
|
|
16216
|
-
for (const
|
|
16217
|
-
const candidate = value[
|
|
16261
|
+
for (const field2 of ["model", "provider"]) {
|
|
16262
|
+
const candidate = value[field2];
|
|
16218
16263
|
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
16219
|
-
throw new Error(`Harness Usage request '${
|
|
16264
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
16220
16265
|
}
|
|
16221
16266
|
}
|
|
16222
16267
|
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
16223
16268
|
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
16224
16269
|
}
|
|
16225
|
-
for (const
|
|
16226
|
-
const candidate = value[
|
|
16270
|
+
for (const field2 of requestTokenFields) {
|
|
16271
|
+
const candidate = value[field2];
|
|
16227
16272
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
16228
|
-
throw new Error(`Harness Usage request '${
|
|
16273
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
16229
16274
|
}
|
|
16230
16275
|
}
|
|
16231
16276
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
@@ -16373,6 +16418,7 @@ var HARNESS_BROKER_PROTOCOL_VERSION = 1;
|
|
|
16373
16418
|
var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
16374
16419
|
var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
|
|
16375
16420
|
var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
|
|
16421
|
+
var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
|
|
16376
16422
|
var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
16377
16423
|
var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
|
|
16378
16424
|
var harnessBrokerMethodSchema = external_exports.enum([
|
|
@@ -16380,6 +16426,8 @@ var harnessBrokerMethodSchema = external_exports.enum([
|
|
|
16380
16426
|
"adapter.inspectAccount",
|
|
16381
16427
|
"adapter.credits",
|
|
16382
16428
|
"adapter.open",
|
|
16429
|
+
"adapter.sessionImport.list",
|
|
16430
|
+
"adapter.sessionImport.resolve",
|
|
16383
16431
|
"adapter.subagent.readSnapshot",
|
|
16384
16432
|
"session.readSnapshot",
|
|
16385
16433
|
"session.readCapabilities",
|
|
@@ -16482,30 +16530,6 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
16482
16530
|
});
|
|
16483
16531
|
}
|
|
16484
16532
|
|
|
16485
|
-
// ../../harness-broker/dist/paths.js
|
|
16486
|
-
import os from "node:os";
|
|
16487
|
-
import path from "node:path";
|
|
16488
|
-
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
16489
|
-
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
16490
|
-
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
16491
|
-
const home = environment.HOME || os.homedir();
|
|
16492
|
-
return path.join(home, ".codexhost", "harness-broker");
|
|
16493
|
-
}
|
|
16494
|
-
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
16495
|
-
harnessPluginIdSchema.parse(harnessId);
|
|
16496
|
-
if (harnessId !== "claude-code")
|
|
16497
|
-
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
16498
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
16499
|
-
}
|
|
16500
|
-
function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
|
|
16501
|
-
harnessPluginIdSchema.parse(harnessId);
|
|
16502
|
-
return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
|
|
16503
|
-
}
|
|
16504
|
-
function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
|
|
16505
|
-
const home = environment.HOME || os.homedir();
|
|
16506
|
-
return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
|
|
16507
|
-
}
|
|
16508
|
-
|
|
16509
16533
|
// ../../harness-broker/dist/validation.js
|
|
16510
16534
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
16511
16535
|
var brokerEnvironmentSchema = external_exports.object({
|
|
@@ -16556,7 +16580,31 @@ var brokerOpenInputSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16556
16580
|
forkSchema,
|
|
16557
16581
|
rollbackSchema
|
|
16558
16582
|
]);
|
|
16559
|
-
var brokerInspectInputSchema = external_exports.object({
|
|
16583
|
+
var brokerInspectInputSchema = external_exports.object({
|
|
16584
|
+
cwd: cwdSchema.optional(),
|
|
16585
|
+
refresh: external_exports.boolean().optional(),
|
|
16586
|
+
purpose: external_exports.literal("availability").optional()
|
|
16587
|
+
}).strict();
|
|
16588
|
+
var brokerSessionImportListParamsSchema = external_exports.object({
|
|
16589
|
+
offset: external_exports.number().int().nonnegative().safe(),
|
|
16590
|
+
limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
|
|
16591
|
+
}).strict();
|
|
16592
|
+
var brokerSessionImportResolveParamsSchema = external_exports.object({ nativeSessionId: harnessSessionImportIdSchema }).strict();
|
|
16593
|
+
var brokerSessionImportPageSchema = external_exports.object({
|
|
16594
|
+
candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE),
|
|
16595
|
+
total: external_exports.number().int().nonnegative().safe()
|
|
16596
|
+
}).strict();
|
|
16597
|
+
var brokerSessionImportSourceSchema = external_exports.object({
|
|
16598
|
+
candidate: harnessSessionImportCandidateSchema,
|
|
16599
|
+
nativeRef: nativeSessionRefSchema
|
|
16600
|
+
}).strict().superRefine((source, context) => {
|
|
16601
|
+
if (source.nativeRef.nativeSessionId !== source.candidate.nativeSessionId) {
|
|
16602
|
+
context.addIssue({
|
|
16603
|
+
code: "custom",
|
|
16604
|
+
message: "Session import source identity does not match"
|
|
16605
|
+
});
|
|
16606
|
+
}
|
|
16607
|
+
});
|
|
16560
16608
|
var textInputSchema = external_exports.object({ type: external_exports.literal("text"), text: external_exports.string().max(4e6) }).strict();
|
|
16561
16609
|
var turnStartSchema = external_exports.object({
|
|
16562
16610
|
type: external_exports.literal("turn.start"),
|
|
@@ -16727,6 +16775,107 @@ var harnessOutputSchema = external_exports.custom((value) => {
|
|
|
16727
16775
|
return false;
|
|
16728
16776
|
});
|
|
16729
16777
|
|
|
16778
|
+
// ../../harness-broker/dist/session-import-client.js
|
|
16779
|
+
function createBrokerSessionImportCapability(input) {
|
|
16780
|
+
let listing = null;
|
|
16781
|
+
const closed = () => ({
|
|
16782
|
+
ok: false,
|
|
16783
|
+
error: { code: "invalidState", message: "Harness broker adapter is closed", retryable: false }
|
|
16784
|
+
});
|
|
16785
|
+
const invalid = () => ({
|
|
16786
|
+
ok: false,
|
|
16787
|
+
error: {
|
|
16788
|
+
code: "protocolError",
|
|
16789
|
+
message: "Harness broker returned invalid Session import metadata",
|
|
16790
|
+
retryable: false
|
|
16791
|
+
}
|
|
16792
|
+
});
|
|
16793
|
+
const list = async () => {
|
|
16794
|
+
try {
|
|
16795
|
+
const candidates = [];
|
|
16796
|
+
const identities = /* @__PURE__ */ new Set();
|
|
16797
|
+
let total;
|
|
16798
|
+
for (; ; ) {
|
|
16799
|
+
if (input.isClosed())
|
|
16800
|
+
return closed();
|
|
16801
|
+
const result = await input.request("adapter.sessionImport.list", {
|
|
16802
|
+
offset: candidates.length,
|
|
16803
|
+
limit: HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE
|
|
16804
|
+
});
|
|
16805
|
+
if (input.isClosed())
|
|
16806
|
+
return closed();
|
|
16807
|
+
if (!result.ok)
|
|
16808
|
+
return result;
|
|
16809
|
+
const page = brokerSessionImportPageSchema.safeParse(result.value);
|
|
16810
|
+
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)
|
|
16811
|
+
return invalid();
|
|
16812
|
+
total = page.data.total;
|
|
16813
|
+
for (const candidate of page.data.candidates) {
|
|
16814
|
+
if (identities.has(candidate.nativeSessionId))
|
|
16815
|
+
return invalid();
|
|
16816
|
+
identities.add(candidate.nativeSessionId);
|
|
16817
|
+
candidates.push(candidate);
|
|
16818
|
+
}
|
|
16819
|
+
if (candidates.length === total)
|
|
16820
|
+
return { ok: true, value: candidates };
|
|
16821
|
+
}
|
|
16822
|
+
} catch (error52) {
|
|
16823
|
+
return { ok: false, error: input.error(error52) };
|
|
16824
|
+
}
|
|
16825
|
+
};
|
|
16826
|
+
return {
|
|
16827
|
+
listCandidates() {
|
|
16828
|
+
if (input.isClosed())
|
|
16829
|
+
return Promise.resolve(closed());
|
|
16830
|
+
listing ??= list().finally(() => {
|
|
16831
|
+
listing = null;
|
|
16832
|
+
});
|
|
16833
|
+
return listing;
|
|
16834
|
+
},
|
|
16835
|
+
async resolveCandidate(nativeSessionId) {
|
|
16836
|
+
if (input.isClosed())
|
|
16837
|
+
return closed();
|
|
16838
|
+
try {
|
|
16839
|
+
const result = await input.request("adapter.sessionImport.resolve", { nativeSessionId });
|
|
16840
|
+
if (input.isClosed())
|
|
16841
|
+
return closed();
|
|
16842
|
+
if (!result.ok)
|
|
16843
|
+
return result;
|
|
16844
|
+
const source = brokerSessionImportSourceSchema.safeParse(result.value);
|
|
16845
|
+
if (!source.success || source.data.nativeRef.harnessId !== input.harnessId || source.data.candidate.nativeSessionId !== nativeSessionId)
|
|
16846
|
+
return invalid();
|
|
16847
|
+
return { ok: true, value: source.data };
|
|
16848
|
+
} catch (error52) {
|
|
16849
|
+
return { ok: false, error: input.error(error52) };
|
|
16850
|
+
}
|
|
16851
|
+
}
|
|
16852
|
+
};
|
|
16853
|
+
}
|
|
16854
|
+
|
|
16855
|
+
// ../../harness-broker/dist/paths.js
|
|
16856
|
+
import os from "node:os";
|
|
16857
|
+
import path from "node:path";
|
|
16858
|
+
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
16859
|
+
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
16860
|
+
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
16861
|
+
const home = environment.HOME || os.homedir();
|
|
16862
|
+
return path.join(home, ".codexhost", "harness-broker");
|
|
16863
|
+
}
|
|
16864
|
+
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
16865
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
16866
|
+
if (harnessId !== "claude-code")
|
|
16867
|
+
return path.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
16868
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
16869
|
+
}
|
|
16870
|
+
function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
|
|
16871
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
16872
|
+
return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
|
|
16873
|
+
}
|
|
16874
|
+
function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
|
|
16875
|
+
const home = environment.HOME || os.homedir();
|
|
16876
|
+
return path.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
|
|
16877
|
+
}
|
|
16878
|
+
|
|
16730
16879
|
// ../../harness-broker/dist/client.js
|
|
16731
16880
|
function unavailable(message, retryable = true) {
|
|
16732
16881
|
return { code: "unavailable", message, retryable, stage: "harnessBroker" };
|
|
@@ -17263,6 +17412,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
17263
17412
|
commandCatalog;
|
|
17264
17413
|
liveCommandCatalog;
|
|
17265
17414
|
harnessId;
|
|
17415
|
+
sessionImport;
|
|
17266
17416
|
credits;
|
|
17267
17417
|
refreshCredits;
|
|
17268
17418
|
#descriptorPath;
|
|
@@ -17285,6 +17435,14 @@ var BrokeredHarnessAdapter = class {
|
|
|
17285
17435
|
};
|
|
17286
17436
|
constructor(input = {}) {
|
|
17287
17437
|
this.harnessId = harnessPluginIdSchema.parse(input.harnessId ?? "claude-code");
|
|
17438
|
+
if (input.sessionImport) {
|
|
17439
|
+
this.sessionImport = createBrokerSessionImportCapability({
|
|
17440
|
+
harnessId: this.harnessId,
|
|
17441
|
+
request: async (method, params) => parseHarnessResult(await this.#request(method, params, method === "adapter.sessionImport.resolve")),
|
|
17442
|
+
isClosed: () => this.#closed,
|
|
17443
|
+
error: (error52) => this.#error(error52)
|
|
17444
|
+
});
|
|
17445
|
+
}
|
|
17288
17446
|
if (input.accountCredits !== false) {
|
|
17289
17447
|
this.credits = () => this.#credits;
|
|
17290
17448
|
this.refreshCredits = () => this.#refreshAccountCredits();
|
|
@@ -17748,7 +17906,7 @@ function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix
|
|
|
17748
17906
|
|
|
17749
17907
|
// dist/claude-code-adapter.js
|
|
17750
17908
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
17751
|
-
import
|
|
17909
|
+
import path15 from "node:path";
|
|
17752
17910
|
|
|
17753
17911
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
17754
17912
|
import { createRequire as jre } from "node:module";
|
|
@@ -54388,7 +54546,6 @@ var ClaudePendingSessions = class {
|
|
|
54388
54546
|
};
|
|
54389
54547
|
|
|
54390
54548
|
// dist/claude-fork.js
|
|
54391
|
-
import path12 from "node:path";
|
|
54392
54549
|
import { isDeepStrictEqual } from "node:util";
|
|
54393
54550
|
|
|
54394
54551
|
// dist/file-change.js
|
|
@@ -54530,6 +54687,17 @@ function targetedSubagentId(argumentsValue) {
|
|
|
54530
54687
|
return void 0;
|
|
54531
54688
|
return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
|
|
54532
54689
|
}
|
|
54690
|
+
function claudeSendMessageFailed(nativeResult, outputText) {
|
|
54691
|
+
if (isRecord7(nativeResult) && typeof nativeResult.success === "boolean") {
|
|
54692
|
+
return nativeResult.success === false;
|
|
54693
|
+
}
|
|
54694
|
+
try {
|
|
54695
|
+
const parsed = JSON.parse(outputText ?? "");
|
|
54696
|
+
return isRecord7(parsed) && parsed.success === false;
|
|
54697
|
+
} catch {
|
|
54698
|
+
return false;
|
|
54699
|
+
}
|
|
54700
|
+
}
|
|
54533
54701
|
function includesAuthenticationFailure(errors) {
|
|
54534
54702
|
return errors.some((error52) => AUTHENTICATION_ERRORS.has(error52));
|
|
54535
54703
|
}
|
|
@@ -55260,7 +55428,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
55260
55428
|
events.push({
|
|
55261
55429
|
type: "subagent.completed",
|
|
55262
55430
|
callId,
|
|
55263
|
-
isError,
|
|
55431
|
+
isError: isError || tool.name === "SendMessage" && claudeSendMessageFailed(nativeResult, outputText),
|
|
55264
55432
|
...subagentContinuesInBackground(nativeResult, outputText) ? { continuesInBackground: true } : {},
|
|
55265
55433
|
...agentId ? { nativeSubagentId: agentId } : {},
|
|
55266
55434
|
...resultSummary ? { resultSummary } : {}
|
|
@@ -55393,7 +55561,7 @@ function conversationMessages(values, sessionId) {
|
|
|
55393
55561
|
let promptId = null;
|
|
55394
55562
|
const occupancy = new ClaudeBackgroundOccupancy();
|
|
55395
55563
|
let accumulator = new ClaudeNativeTurnAccumulator();
|
|
55396
|
-
const sends = /* @__PURE__ */ new
|
|
55564
|
+
const sends = /* @__PURE__ */ new Map();
|
|
55397
55565
|
let pendingNotification = false;
|
|
55398
55566
|
for (const value of values) {
|
|
55399
55567
|
if (!isRecord8(value))
|
|
@@ -55426,17 +55594,19 @@ function conversationMessages(values, sessionId) {
|
|
|
55426
55594
|
for (const event of accumulator.consume(value).events) {
|
|
55427
55595
|
if (event.type === "subagent.started") {
|
|
55428
55596
|
if (event.operation === "send") {
|
|
55429
|
-
sends.
|
|
55430
|
-
if (event.nativeSubagentId)
|
|
55431
|
-
occupancy.occupyAgent(event.nativeSubagentId);
|
|
55597
|
+
sends.set(event.callId, event.nativeSubagentId);
|
|
55432
55598
|
} else if (event.background)
|
|
55433
55599
|
occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
55434
55600
|
} else if (event.type === "subagent.completed") {
|
|
55435
|
-
if (
|
|
55601
|
+
if (sends.has(event.callId)) {
|
|
55602
|
+
const agentId = event.nativeSubagentId ?? sends.get(event.callId);
|
|
55603
|
+
if (!event.isError && agentId)
|
|
55604
|
+
occupancy.occupyAgent(agentId);
|
|
55605
|
+
sends.delete(event.callId);
|
|
55606
|
+
} else if (!event.isError && event.continuesInBackground) {
|
|
55436
55607
|
occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
55437
55608
|
} else
|
|
55438
55609
|
occupancy.release(event.callId, event.nativeSubagentId);
|
|
55439
|
-
sends.delete(event.callId);
|
|
55440
55610
|
} else if (event.type === "workflow.launched" && event.background && !event.isError) {
|
|
55441
55611
|
occupancy.occupySpawn(event.callId, event.taskId);
|
|
55442
55612
|
} else if (event.type === "subagent.settled") {
|
|
@@ -55613,7 +55783,7 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
55613
55783
|
if (!result)
|
|
55614
55784
|
continue;
|
|
55615
55785
|
const output = toolResultOutput(result);
|
|
55616
|
-
const failed = result.is_error === true;
|
|
55786
|
+
const failed = result.is_error === true || block.name === "SendMessage" && claudeSendMessageFailed(void 0, output);
|
|
55617
55787
|
const toolOutcome = failed ? {
|
|
55618
55788
|
status: "failed",
|
|
55619
55789
|
error: {
|
|
@@ -55908,12 +56078,6 @@ async function forkClaudeSession(input) {
|
|
|
55908
56078
|
error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
|
|
55909
56079
|
};
|
|
55910
56080
|
}
|
|
55911
|
-
if (path12.resolve(sourceInfo.cwd) !== input.cwd) {
|
|
55912
|
-
return {
|
|
55913
|
-
ok: false,
|
|
55914
|
-
error: error51("unsupported", "Claude Code cannot Fork across working directories", false)
|
|
55915
|
-
};
|
|
55916
|
-
}
|
|
55917
56081
|
const source = await readSnapshot(input.dependencies, input.cwd, sourceRef.data.nativeSessionId);
|
|
55918
56082
|
if (!source.ok)
|
|
55919
56083
|
return source;
|
|
@@ -56013,13 +56177,13 @@ import { readFile as readFile6, rename as rename4, rm as rm5, stat as stat5, wri
|
|
|
56013
56177
|
|
|
56014
56178
|
// dist/claude-transcript.js
|
|
56015
56179
|
import os6 from "node:os";
|
|
56016
|
-
import
|
|
56180
|
+
import path12 from "node:path";
|
|
56017
56181
|
import { readFile as readFile5, readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
56018
56182
|
function projectDirectoryName(cwd) {
|
|
56019
56183
|
return cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
56020
56184
|
}
|
|
56021
56185
|
function configDirectory(environment) {
|
|
56022
|
-
return environment.CLAUDE_CONFIG_DIR ?
|
|
56186
|
+
return environment.CLAUDE_CONFIG_DIR ? path12.resolve(environment.CLAUDE_CONFIG_DIR) : path12.join(os6.homedir(), ".claude");
|
|
56023
56187
|
}
|
|
56024
56188
|
async function existingFile(file2) {
|
|
56025
56189
|
try {
|
|
@@ -56029,9 +56193,9 @@ async function existingFile(file2) {
|
|
|
56029
56193
|
}
|
|
56030
56194
|
}
|
|
56031
56195
|
async function findClaudeTranscript(input) {
|
|
56032
|
-
const projectsDirectory =
|
|
56196
|
+
const projectsDirectory = path12.join(configDirectory(input.environment), "projects");
|
|
56033
56197
|
const name = `${input.sessionId}.jsonl`;
|
|
56034
|
-
const expected =
|
|
56198
|
+
const expected = path12.join(projectsDirectory, projectDirectoryName(input.cwd), name);
|
|
56035
56199
|
if (await existingFile(expected))
|
|
56036
56200
|
return expected;
|
|
56037
56201
|
let projects;
|
|
@@ -56041,7 +56205,7 @@ async function findClaudeTranscript(input) {
|
|
|
56041
56205
|
return null;
|
|
56042
56206
|
}
|
|
56043
56207
|
for (const project2 of projects) {
|
|
56044
|
-
const candidate =
|
|
56208
|
+
const candidate = path12.join(projectsDirectory, project2, name);
|
|
56045
56209
|
if (await existingFile(candidate))
|
|
56046
56210
|
return candidate;
|
|
56047
56211
|
}
|
|
@@ -56151,7 +56315,7 @@ async function remapForkedSessionReferences(input) {
|
|
|
56151
56315
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
56152
56316
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
56153
56317
|
import os7 from "node:os";
|
|
56154
|
-
import
|
|
56318
|
+
import path13 from "node:path";
|
|
56155
56319
|
|
|
56156
56320
|
// dist/thinking-options.js
|
|
56157
56321
|
var option = (id2, label) => ({
|
|
@@ -56244,7 +56408,7 @@ function decodeClaudeModelRef(ref) {
|
|
|
56244
56408
|
return value === "default" ? void 0 : value;
|
|
56245
56409
|
}
|
|
56246
56410
|
function resolveClaudeConfigDirectory(environment = process.env) {
|
|
56247
|
-
return
|
|
56411
|
+
return path13.resolve(environment.CLAUDE_CONFIG_DIR ?? path13.join(os7.homedir(), ".claude"));
|
|
56248
56412
|
}
|
|
56249
56413
|
function parseModelPickerOptions(value) {
|
|
56250
56414
|
if (!Array.isArray(value))
|
|
@@ -56286,7 +56450,7 @@ function parseClaudeModelPickerSettings(value) {
|
|
|
56286
56450
|
};
|
|
56287
56451
|
}
|
|
56288
56452
|
async function readClaudeUserModelPicker(environment = process.env) {
|
|
56289
|
-
const settingsPath =
|
|
56453
|
+
const settingsPath = path13.join(resolveClaudeConfigDirectory(environment), "settings.json");
|
|
56290
56454
|
let raw;
|
|
56291
56455
|
try {
|
|
56292
56456
|
raw = await readFile7(settingsPath, "utf8");
|
|
@@ -56632,7 +56796,7 @@ function projectClaudeAccountUsage(usage, account) {
|
|
|
56632
56796
|
|
|
56633
56797
|
// dist/process-fence.js
|
|
56634
56798
|
import { execFile as execFile3 } from "node:child_process";
|
|
56635
|
-
import
|
|
56799
|
+
import path14 from "node:path";
|
|
56636
56800
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
56637
56801
|
import { promisify } from "node:util";
|
|
56638
56802
|
var executeFile = promisify(execFile3);
|
|
@@ -56656,9 +56820,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
|
|
|
56656
56820
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
56657
56821
|
throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
|
|
56658
56822
|
const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
|
|
56659
|
-
if (!root || !
|
|
56823
|
+
if (!root || !path14.win32.isAbsolute(root))
|
|
56660
56824
|
throw new Error("Windows SystemRoot is unavailable");
|
|
56661
|
-
await executeFile(
|
|
56825
|
+
await executeFile(path14.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
|
|
56662
56826
|
timeout: timeoutMs,
|
|
56663
56827
|
windowsHide: true
|
|
56664
56828
|
});
|
|
@@ -56958,6 +57122,8 @@ var ClaudeSdkTransport = class {
|
|
|
56958
57122
|
/** Root tool calls of the requested Turn that have started and not yet returned a result. */
|
|
56959
57123
|
#rootToolCalls = /* @__PURE__ */ new Set();
|
|
56960
57124
|
#pendingSteers = /* @__PURE__ */ new Map();
|
|
57125
|
+
/** Written steers Claude has not yet drained into a native turn, by message ID. */
|
|
57126
|
+
#steerTakeovers = /* @__PURE__ */ new Map();
|
|
56961
57127
|
#autonomous = null;
|
|
56962
57128
|
#autonomousTurnHandler = null;
|
|
56963
57129
|
#idleHandler = null;
|
|
@@ -57081,9 +57247,16 @@ var ClaudeSdkTransport = class {
|
|
|
57081
57247
|
* `priority: "next"` joins after the current tool call, and a tool result is always followed by
|
|
57082
57248
|
* another model request. So a steer written while a root tool call runs folds into this Turn;
|
|
57083
57249
|
* one written while Claude streams its final text may instead run as the next Turn.
|
|
57250
|
+
*
|
|
57251
|
+
* A held Turn's continuation steers as well: while its idle stream is live, the pushed input
|
|
57252
|
+
* runs as that Turn's next Segment, and the background work the Turn waits on keeps running.
|
|
57084
57253
|
*/
|
|
57085
57254
|
canSteerActiveTurn() {
|
|
57086
|
-
|
|
57255
|
+
if (!this.#nativeSteer)
|
|
57256
|
+
return false;
|
|
57257
|
+
if (this.#active !== null)
|
|
57258
|
+
return this.#rootToolCalls.size > 0;
|
|
57259
|
+
return this.#idleLive && this.#idleHandler !== null;
|
|
57087
57260
|
}
|
|
57088
57261
|
#observeRootToolCalls(message) {
|
|
57089
57262
|
if (!isRecord11(message) || message.parent_tool_use_id != null)
|
|
@@ -57259,7 +57432,7 @@ var ClaudeSdkTransport = class {
|
|
|
57259
57432
|
* The Turn ending first therefore does not reject it, and a missing `queued` receipt resolves
|
|
57260
57433
|
* after a bounded wait so callers that serialize requests are never held indefinitely.
|
|
57261
57434
|
*/
|
|
57262
|
-
steer(text2, messageId) {
|
|
57435
|
+
steer(text2, messageId, onTakeover) {
|
|
57263
57436
|
if (this.#closePromise || !this.#started || !this.#query || !this.canSteerActiveTurn()) {
|
|
57264
57437
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
57265
57438
|
}
|
|
@@ -57280,9 +57453,14 @@ var ClaudeSdkTransport = class {
|
|
|
57280
57453
|
this.#pendingSteers.delete(messageId);
|
|
57281
57454
|
return Promise.reject(new ClaudeSteerMissedTurnError());
|
|
57282
57455
|
}
|
|
57456
|
+
if (onTakeover)
|
|
57457
|
+
this.#steerTakeovers.set(messageId, onTakeover);
|
|
57283
57458
|
const pending = this.#pendingSteers.get(messageId);
|
|
57284
57459
|
if (pending) {
|
|
57285
|
-
pending.timer = setTimeout(() =>
|
|
57460
|
+
pending.timer = setTimeout(() => {
|
|
57461
|
+
this.#acceptSteer(messageId);
|
|
57462
|
+
this.#takeOverSteer(messageId, false);
|
|
57463
|
+
}, this.#steerQueuedTimeoutMs);
|
|
57286
57464
|
pending.timer.unref?.();
|
|
57287
57465
|
}
|
|
57288
57466
|
return promise2;
|
|
@@ -57295,6 +57473,13 @@ var ClaudeSdkTransport = class {
|
|
|
57295
57473
|
clearTimeout(pending.timer);
|
|
57296
57474
|
pending.resolve();
|
|
57297
57475
|
}
|
|
57476
|
+
#takeOverSteer(messageId, started) {
|
|
57477
|
+
const onTakeover = this.#steerTakeovers.get(messageId);
|
|
57478
|
+
if (!onTakeover)
|
|
57479
|
+
return;
|
|
57480
|
+
this.#steerTakeovers.delete(messageId);
|
|
57481
|
+
onTakeover(started);
|
|
57482
|
+
}
|
|
57298
57483
|
respondToInteraction(response) {
|
|
57299
57484
|
const pending = this.#interactions.get(response.requestId);
|
|
57300
57485
|
if (!pending) {
|
|
@@ -57576,6 +57761,9 @@ var ClaudeSdkTransport = class {
|
|
|
57576
57761
|
}
|
|
57577
57762
|
}
|
|
57578
57763
|
#rejectPendingSteers() {
|
|
57764
|
+
for (const messageId of [...this.#steerTakeovers.keys()]) {
|
|
57765
|
+
this.#takeOverSteer(messageId, false);
|
|
57766
|
+
}
|
|
57579
57767
|
const pending = [...this.#pendingSteers.values()];
|
|
57580
57768
|
this.#pendingSteers.clear();
|
|
57581
57769
|
const error52 = new Error("Claude Code steer receipt was lost after input was written");
|
|
@@ -57584,16 +57772,24 @@ var ClaudeSdkTransport = class {
|
|
|
57584
57772
|
entry.reject(error52);
|
|
57585
57773
|
}
|
|
57586
57774
|
}
|
|
57587
|
-
/**
|
|
57775
|
+
/**
|
|
57776
|
+
* `queued` is Claude's acceptance of this message into the running Session. `started` is its
|
|
57777
|
+
* drain into a native turn, folded into the running one or run as the next; a terminal state
|
|
57778
|
+
* without `started` means no native turn takes it over.
|
|
57779
|
+
*/
|
|
57588
57780
|
#observeSteer(message) {
|
|
57589
|
-
if (this.#pendingSteers.size === 0 || !isRecord11(message) || message.type !== "command_lifecycle") {
|
|
57781
|
+
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !isRecord11(message) || message.type !== "command_lifecycle") {
|
|
57590
57782
|
return;
|
|
57591
57783
|
}
|
|
57592
|
-
if (message.state !== "queued")
|
|
57593
|
-
return;
|
|
57594
57784
|
if (typeof message.command_uuid !== "string" || message.command_uuid.length === 0)
|
|
57595
57785
|
return;
|
|
57596
|
-
|
|
57786
|
+
if (message.state === "queued") {
|
|
57787
|
+
this.#acceptSteer(message.command_uuid);
|
|
57788
|
+
return;
|
|
57789
|
+
}
|
|
57790
|
+
if (["started", "completed", "cancelled", "discarded", "refused"].includes(String(message.state))) {
|
|
57791
|
+
this.#takeOverSteer(message.command_uuid, message.state === "started");
|
|
57792
|
+
}
|
|
57597
57793
|
}
|
|
57598
57794
|
#observeBackgroundTasks(message) {
|
|
57599
57795
|
if (!isRecord11(message) || message.type !== "system")
|
|
@@ -57706,13 +57902,13 @@ var ClaudeSdkTransport = class {
|
|
|
57706
57902
|
throw new Error("Claude SDK Query ended unexpectedly");
|
|
57707
57903
|
} catch (error52) {
|
|
57708
57904
|
const active = this.#active;
|
|
57905
|
+
if (!this.#closePromise)
|
|
57906
|
+
this.#onFault(error52);
|
|
57709
57907
|
this.#closeInteractions("all", "cancelled");
|
|
57710
57908
|
this.#rejectPendingSteers();
|
|
57711
57909
|
this.#rootToolCalls.clear();
|
|
57712
57910
|
this.#active = null;
|
|
57713
57911
|
active?.reject(error52);
|
|
57714
|
-
if (!this.#closePromise)
|
|
57715
|
-
this.#onFault(error52);
|
|
57716
57912
|
}
|
|
57717
57913
|
}
|
|
57718
57914
|
#spawn(options) {
|
|
@@ -58009,7 +58205,7 @@ var ClaudeSubagentLifecycle = class {
|
|
|
58009
58205
|
});
|
|
58010
58206
|
const outcome = cancellationRequested ? { status: "cancelled", reason: "Cancelled by user" } : event.isError ? { status: "failed", error: subagentFailure() } : { status: "succeeded" };
|
|
58011
58207
|
this.#emit({ type: "item.completed", turnId, snapshot: { item, outcome } });
|
|
58012
|
-
return subagent;
|
|
58208
|
+
return { operation: active.item.operation, subagent };
|
|
58013
58209
|
}
|
|
58014
58210
|
finalize(turnId, outcome) {
|
|
58015
58211
|
for (const [callId, active] of this.#delegations) {
|
|
@@ -58217,9 +58413,9 @@ function stringField(value, keys) {
|
|
|
58217
58413
|
if (!isRecord12(value))
|
|
58218
58414
|
return void 0;
|
|
58219
58415
|
for (const key of keys) {
|
|
58220
|
-
const
|
|
58221
|
-
if (typeof
|
|
58222
|
-
return
|
|
58416
|
+
const field2 = value[key];
|
|
58417
|
+
if (typeof field2 === "string" && field2.length > 0)
|
|
58418
|
+
return field2;
|
|
58223
58419
|
}
|
|
58224
58420
|
return void 0;
|
|
58225
58421
|
}
|
|
@@ -58905,10 +59101,12 @@ var ClaudeHarnessSession = class {
|
|
|
58905
59101
|
},
|
|
58906
59102
|
history: { fork: true, forkAcrossCwd: false, rollbackLastTurn: true },
|
|
58907
59103
|
subagents: { observe: true, readTranscript: true },
|
|
58908
|
-
// Read live: native delivery joins this Turn
|
|
58909
|
-
// on a CLI that confirms steers
|
|
59104
|
+
// Read live: native delivery joins this Turn while a root tool call runs, or while a held
|
|
59105
|
+
// Turn's continuation waits on background work, on a CLI that confirms steers
|
|
59106
|
+
// (`msg_lifecycle_v1`). A Turn whose cancellation is in flight must not take more input;
|
|
59107
|
+
// every other case stops and restarts.
|
|
58910
59108
|
get steer() {
|
|
58911
|
-
return session.#transport?.canSteerActiveTurn?.() === true;
|
|
59109
|
+
return session.#transport?.canSteerActiveTurn?.() === true && session.#active?.cancellationRequested !== true;
|
|
58912
59110
|
}
|
|
58913
59111
|
}))(this);
|
|
58914
59112
|
commands;
|
|
@@ -59235,6 +59433,7 @@ var ClaudeHarnessSession = class {
|
|
|
59235
59433
|
nativeTurnKey,
|
|
59236
59434
|
nativeTurnRef: null,
|
|
59237
59435
|
cancellationRequested: false,
|
|
59436
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
59238
59437
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
59239
59438
|
estimatedInputTokens: 0,
|
|
59240
59439
|
estimatedOutputTokens: 0,
|
|
@@ -59271,9 +59470,13 @@ var ClaudeHarnessSession = class {
|
|
|
59271
59470
|
return { ok: true, value: { turnId: command.turnId } };
|
|
59272
59471
|
}
|
|
59273
59472
|
async #steer(command) {
|
|
59274
|
-
|
|
59473
|
+
const active = this.#active;
|
|
59474
|
+
if (!active || active.command.turnId !== command.turnId) {
|
|
59275
59475
|
return { ok: false, error: invalidState("Claude Code steer target is not the active Turn") };
|
|
59276
59476
|
}
|
|
59477
|
+
if (active.cancellationRequested) {
|
|
59478
|
+
return { ok: false, error: invalidState("Claude Code steer target is being cancelled") };
|
|
59479
|
+
}
|
|
59277
59480
|
const text2 = command.input.map((input) => input.text).join("\n");
|
|
59278
59481
|
if (text2.length === 0) {
|
|
59279
59482
|
return {
|
|
@@ -59299,10 +59502,13 @@ var ClaudeHarnessSession = class {
|
|
|
59299
59502
|
}
|
|
59300
59503
|
};
|
|
59301
59504
|
}
|
|
59505
|
+
const messageId = this.#randomUUID();
|
|
59506
|
+
active.steersAwaitingNative.add(messageId);
|
|
59302
59507
|
try {
|
|
59303
|
-
await transport.steer(text2, this.#
|
|
59508
|
+
await transport.steer(text2, messageId, (started) => this.#takeOverSteer(active, messageId, started));
|
|
59304
59509
|
} catch (error52) {
|
|
59305
59510
|
if (error52 instanceof ClaudeSteerMissedTurnError) {
|
|
59511
|
+
this.#takeOverSteer(active, messageId, false);
|
|
59306
59512
|
return { ok: false, error: invalidState("Claude Code steer missed the active Turn") };
|
|
59307
59513
|
}
|
|
59308
59514
|
throw error52;
|
|
@@ -59405,6 +59611,7 @@ var ClaudeHarnessSession = class {
|
|
|
59405
59611
|
nativeTurnKey,
|
|
59406
59612
|
nativeTurnRef: null,
|
|
59407
59613
|
cancellationRequested: false,
|
|
59614
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
59408
59615
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
59409
59616
|
estimatedInputTokens: 0,
|
|
59410
59617
|
estimatedOutputTokens: 0,
|
|
@@ -59766,7 +59973,7 @@ var ClaudeHarnessSession = class {
|
|
|
59766
59973
|
active.cancellationRequested = true;
|
|
59767
59974
|
const transport = this.#transport;
|
|
59768
59975
|
const taskIds = this.#backgroundTaskIds(active);
|
|
59769
|
-
if (transport && (taskIds.length > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation))) {
|
|
59976
|
+
if (transport && (taskIds.length > 0 || active.held && (active.rootSegmentActive || this.#occupancy.awaitingContinuation || active.steersAwaitingNative.size > 0))) {
|
|
59770
59977
|
await this.#cancelBackgroundWork(active, transport, taskIds);
|
|
59771
59978
|
return { ok: true, value: { cancellationRequested: true } };
|
|
59772
59979
|
}
|
|
@@ -59841,6 +60048,11 @@ var ClaudeHarnessSession = class {
|
|
|
59841
60048
|
return;
|
|
59842
60049
|
if (cancellation.stopping || cancellation.interrupting || active.rootSegmentActive)
|
|
59843
60050
|
return;
|
|
60051
|
+
if (active.steersAwaitingNative.size > 0) {
|
|
60052
|
+
this.#armCancelEscalation(active);
|
|
60053
|
+
return;
|
|
60054
|
+
}
|
|
60055
|
+
this.#clearCancelEscalation();
|
|
59844
60056
|
this.#clearCancellationQuiet(cancellation);
|
|
59845
60057
|
const quiet = setTimeout(() => {
|
|
59846
60058
|
cancellation.quiet = null;
|
|
@@ -60120,10 +60332,7 @@ var ClaudeHarnessSession = class {
|
|
|
60120
60332
|
}
|
|
60121
60333
|
this.#completeAgentItem(active, { status: "succeeded" }, false);
|
|
60122
60334
|
active.subagents.start(active.command.turnId, event);
|
|
60123
|
-
if (event.operation === "
|
|
60124
|
-
if (event.nativeSubagentId)
|
|
60125
|
-
this.#occupancy.occupyAgent(event.nativeSubagentId);
|
|
60126
|
-
} else if (event.background) {
|
|
60335
|
+
if (event.operation === "spawn" && event.background) {
|
|
60127
60336
|
this.#occupancy.occupySpawn(event.callId, event.nativeSubagentId);
|
|
60128
60337
|
}
|
|
60129
60338
|
return;
|
|
@@ -60142,7 +60351,13 @@ var ClaudeHarnessSession = class {
|
|
|
60142
60351
|
}
|
|
60143
60352
|
return;
|
|
60144
60353
|
case "subagent.completed": {
|
|
60145
|
-
const subagent = active.subagents.complete(active.command.turnId, event, active.cancellationRequested);
|
|
60354
|
+
const { operation, subagent } = active.subagents.complete(active.command.turnId, event, active.cancellationRequested);
|
|
60355
|
+
if (operation === "send") {
|
|
60356
|
+
if (subagent.status === "running" && subagent.nativeSubagentId) {
|
|
60357
|
+
this.#occupancy.occupyAgent(subagent.nativeSubagentId);
|
|
60358
|
+
}
|
|
60359
|
+
return;
|
|
60360
|
+
}
|
|
60146
60361
|
if (subagent.status === "running") {
|
|
60147
60362
|
this.#occupancy.occupySpawn(event.callId, subagent.nativeSubagentId);
|
|
60148
60363
|
return;
|
|
@@ -60454,6 +60669,7 @@ var ClaudeHarnessSession = class {
|
|
|
60454
60669
|
const active = {
|
|
60455
60670
|
command: { type: "turn.start", turnId, input: [] },
|
|
60456
60671
|
compactionItem: null,
|
|
60672
|
+
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
60457
60673
|
item,
|
|
60458
60674
|
agentMessageOrdinal: 1,
|
|
60459
60675
|
assistantMessageId: null,
|
|
@@ -60842,7 +61058,7 @@ var ClaudeHarnessSession = class {
|
|
|
60842
61058
|
this.#clearContinuationQuiescence();
|
|
60843
61059
|
const quiescence = setTimeout(() => {
|
|
60844
61060
|
this.#continuationQuiescence = null;
|
|
60845
|
-
if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open") {
|
|
61061
|
+
if (this.#active !== active || !active.held || active.rootSegmentActive || active.steersAwaitingNative.size > 0 || this.#phase !== "open") {
|
|
60846
61062
|
return;
|
|
60847
61063
|
}
|
|
60848
61064
|
this.#occupancy.releaseContinuations();
|
|
@@ -60863,6 +61079,30 @@ var ClaudeHarnessSession = class {
|
|
|
60863
61079
|
active.rootSegmentActive = true;
|
|
60864
61080
|
this.#clearContinuationQuiescence();
|
|
60865
61081
|
}
|
|
61082
|
+
/**
|
|
61083
|
+
* A drained steer runs in a native turn whose result still reaches this Turn, folded into the
|
|
61084
|
+
* running Root Segment or as the held Turn's next one. A steer that ends without one releases
|
|
61085
|
+
* its keep-open, so a Turn held only for it settles as if the steer had never been written.
|
|
61086
|
+
*/
|
|
61087
|
+
#takeOverSteer(active, messageId, started) {
|
|
61088
|
+
if (!active.steersAwaitingNative.delete(messageId) || this.#active !== active)
|
|
61089
|
+
return;
|
|
61090
|
+
if (started) {
|
|
61091
|
+
this.#handleTurnEvent(active, { type: "segment.started" });
|
|
61092
|
+
return;
|
|
61093
|
+
}
|
|
61094
|
+
if (active.cancellation) {
|
|
61095
|
+
this.#settleCancellation(active);
|
|
61096
|
+
return;
|
|
61097
|
+
}
|
|
61098
|
+
if (!active.held || active.rootSegmentActive || active.steersAwaitingNative.size > 0 || this.#phase !== "open") {
|
|
61099
|
+
return;
|
|
61100
|
+
}
|
|
61101
|
+
if (this.#occupancy.awaitingContinuation)
|
|
61102
|
+
this.#armContinuationQuiescence(active);
|
|
61103
|
+
else if (!this.#occupancy.unsettled)
|
|
61104
|
+
this.#finish(active, { status: "succeeded" });
|
|
61105
|
+
}
|
|
60866
61106
|
#finish(active, outcome) {
|
|
60867
61107
|
if (this.#active !== active)
|
|
60868
61108
|
return;
|
|
@@ -60873,7 +61113,7 @@ var ClaudeHarnessSession = class {
|
|
|
60873
61113
|
active.cancellation = null;
|
|
60874
61114
|
}
|
|
60875
61115
|
this.#clearContinuationQuiescence();
|
|
60876
|
-
const hold = outcome.status === "succeeded" && !active.cancellationRequested && this.#occupancy.unsettled;
|
|
61116
|
+
const hold = outcome.status === "succeeded" && !active.cancellationRequested && (this.#occupancy.unsettled || active.steersAwaitingNative.size > 0);
|
|
60877
61117
|
this.#closeActiveInteractions(active, outcome.status === "succeeded" ? "superseded" : "cancelled", hold);
|
|
60878
61118
|
const itemOutcome2 = outcome;
|
|
60879
61119
|
if (active.compactionItem)
|
|
@@ -61139,7 +61379,7 @@ var ClaudeCodeAdapter = class {
|
|
|
61139
61379
|
error: invalidState("Claude Code Adapter is closing")
|
|
61140
61380
|
};
|
|
61141
61381
|
}
|
|
61142
|
-
const cwd =
|
|
61382
|
+
const cwd = path15.resolve(input.cwd ?? process.cwd());
|
|
61143
61383
|
if (!input.refresh) {
|
|
61144
61384
|
const cached2 = this.#inspectionCache.get(cwd);
|
|
61145
61385
|
if (cached2)
|
|
@@ -61343,7 +61583,7 @@ var ClaudeCodeAdapter = class {
|
|
|
61343
61583
|
}
|
|
61344
61584
|
requestedPermissionModeId = CLAUDE_DEFAULT_PERMISSION_MODE_ID;
|
|
61345
61585
|
}
|
|
61346
|
-
const cwd =
|
|
61586
|
+
const cwd = path15.resolve(input.cwd);
|
|
61347
61587
|
if (input.kind === "rollbackLastTurn") {
|
|
61348
61588
|
for (const source of this.#sessions) {
|
|
61349
61589
|
const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
|
|
@@ -61503,7 +61743,7 @@ var ClaudeCodeAdapter = class {
|
|
|
61503
61743
|
// dist/installation.js
|
|
61504
61744
|
import { readFile as readFile8, realpath as realpath5 } from "node:fs/promises";
|
|
61505
61745
|
import { homedir as homedir2 } from "node:os";
|
|
61506
|
-
import
|
|
61746
|
+
import path16 from "node:path";
|
|
61507
61747
|
async function readSettings(file2) {
|
|
61508
61748
|
const text2 = await readFile8(file2, "utf8").catch((error52) => {
|
|
61509
61749
|
if (error52.code === "ENOENT")
|
|
@@ -61524,9 +61764,9 @@ function createClaudeInstallation(environment, command) {
|
|
|
61524
61764
|
...command ? { command } : {}
|
|
61525
61765
|
});
|
|
61526
61766
|
const home = environment.HOME ?? environment.USERPROFILE ?? homedir2();
|
|
61527
|
-
const config2 = environment.CLAUDE_CONFIG_DIR ?
|
|
61528
|
-
const managedFile = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : process.platform === "win32" ?
|
|
61529
|
-
const user = await readSettings(
|
|
61767
|
+
const config2 = environment.CLAUDE_CONFIG_DIR ? path16.resolve(home, environment.CLAUDE_CONFIG_DIR) : path16.join(home, ".claude");
|
|
61768
|
+
const managedFile = process.platform === "darwin" ? "/Library/Application Support/ClaudeCode/managed-settings.json" : process.platform === "win32" ? path16.join(environment.ProgramFiles ?? "C:\\Program Files", "ClaudeCode", "managed-settings.json") : "/etc/claude-code/managed-settings.json";
|
|
61769
|
+
const user = await readSettings(path16.join(config2, "settings.json"));
|
|
61530
61770
|
const managed = await readSettings(managedFile);
|
|
61531
61771
|
const settings = { ...user, ...managed, env: { ...user.env, ...managed.env } };
|
|
61532
61772
|
const env = { ...environment, ...settings.env };
|
|
@@ -61539,10 +61779,10 @@ function createClaudeInstallation(environment, command) {
|
|
|
61539
61779
|
throw new Error("Unknown Claude release channel");
|
|
61540
61780
|
const latestVersion = installationVersion(await fetchInstallationText(`https://downloads.claude.ai/claude-code-releases/${channel}`));
|
|
61541
61781
|
const npm = await npmInstallation(executable, ["@anthropic-ai/claude-code"], env);
|
|
61542
|
-
const launcher =
|
|
61782
|
+
const launcher = path16.join(home, ".local", "bin", process.platform === "win32" ? "claude.exe" : "claude");
|
|
61543
61783
|
const selected = await realpath5(executable);
|
|
61544
|
-
const versions =
|
|
61545
|
-
const native =
|
|
61784
|
+
const versions = path16.join(home, ".local", "share", "claude", "versions") + path16.sep;
|
|
61785
|
+
const native = path16.resolve(executable) === launcher && (selected.startsWith(versions) || process.platform === "win32" && selected === launcher);
|
|
61546
61786
|
const blocked = !!env.DISABLE_UPDATES && env.DISABLE_UPDATES !== "0" || !!settings.minimumVersion && newerInstallationVersion(latestVersion, installationVersion(settings.minimumVersion)) || !!settings.requiredMaximumVersion && newerInstallationVersion(installationVersion(settings.requiredMaximumVersion), latestVersion);
|
|
61547
61787
|
const canUpdate = !blocked && (npm?.canUpdate ?? native);
|
|
61548
61788
|
update = async () => {
|
|
@@ -61573,7 +61813,7 @@ function createClaudeInstallation(environment, command) {
|
|
|
61573
61813
|
}
|
|
61574
61814
|
|
|
61575
61815
|
// dist/user-shell-environment.js
|
|
61576
|
-
import
|
|
61816
|
+
import path17 from "node:path";
|
|
61577
61817
|
import { execFile as execFile4 } from "node:child_process";
|
|
61578
61818
|
var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
|
|
61579
61819
|
var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
|
|
@@ -61616,7 +61856,7 @@ async function withUserShellEnvironment(environment, dependencies) {
|
|
|
61616
61856
|
if (platform === "win32" || !environment.HOME)
|
|
61617
61857
|
return environment;
|
|
61618
61858
|
const shell = environment.SHELL?.trim() || defaultShell(platform);
|
|
61619
|
-
if (!shell || !SUPPORTED_SHELLS.has(
|
|
61859
|
+
if (!shell || !SUPPORTED_SHELLS.has(path17.basename(shell)))
|
|
61620
61860
|
return environment;
|
|
61621
61861
|
const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
|
|
61622
61862
|
const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);
|
|
@@ -61654,6 +61894,7 @@ async function createHarnessAdapter(context) {
|
|
|
61654
61894
|
const environment = await withUserShellEnvironment({ ...context.environment });
|
|
61655
61895
|
if (context.platform === "darwin" && context.managedRemoteHost) {
|
|
61656
61896
|
return new BrokeredHarnessAdapter({
|
|
61897
|
+
sessionImport: true,
|
|
61657
61898
|
forwardDelegationEnvironment: true,
|
|
61658
61899
|
commandCatalog: claudeCommandCatalog,
|
|
61659
61900
|
liveCommandCatalog: true,
|