@codexhost/cli-darwin-x64 0.8.0 → 0.9.1-test.2
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/THIRD_PARTY_NOTICES.txt +12 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/desktop-controller.mjs +66 -26
- package/app/host-runtime.mjs +3760 -6598
- package/app/plugins/antigravity/plugin.mjs +46 -92
- package/app/plugins/claude-code/plugin.mjs +464 -238
- package/app/plugins/codebuddy/plugin.mjs +78 -100
- package/app/plugins/cursor-cli/plugin.mjs +45 -81
- package/app/plugins/deepseek-harness/plugin.mjs +57 -84
- package/app/plugins/enabled.json +3 -1
- package/app/plugins/grok/plugin.mjs +45 -78
- package/app/plugins/hermes/plugin.mjs +42 -80
- package/app/plugins/kiro-cli/plugin.mjs +52 -80
- package/app/plugins/omp/plugin.mjs +55 -83
- package/app/plugins/opencode/plugin.mjs +94 -123
- package/app/plugins/pi/plugin.mjs +55 -83
- package/app/plugins/qoder/assets/icon.svg +1 -0
- package/app/plugins/qoder/manifest.json +12 -0
- package/app/plugins/qoder/plugin.mjs +52260 -0
- package/app/plugins/qoder-cn/assets/icon.svg +1 -0
- package/app/plugins/qoder-cn/manifest.json +12 -0
- package/app/plugins/qoder-cn/plugin.mjs +52258 -0
- package/app/renderer-extension.js +2893 -914
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/licenses/Qoder-Agent-SDK-LICENSE.txt +7 -0
- package/licenses/QoderCN-Agent-SDK-LICENSE.txt +7 -0
- package/licenses/tailwindcss-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -776,10 +776,10 @@ function mergeDefs(...defs) {
|
|
|
776
776
|
function cloneDef(schema) {
|
|
777
777
|
return mergeDefs(schema._zod.def);
|
|
778
778
|
}
|
|
779
|
-
function getElementAtPath(obj,
|
|
780
|
-
if (!
|
|
779
|
+
function getElementAtPath(obj, path13) {
|
|
780
|
+
if (!path13)
|
|
781
781
|
return obj;
|
|
782
|
-
return
|
|
782
|
+
return path13.reduce((acc, key) => acc?.[key], obj);
|
|
783
783
|
}
|
|
784
784
|
function promiseAllObject(promisesObj) {
|
|
785
785
|
const keys = Object.keys(promisesObj);
|
|
@@ -1188,11 +1188,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
return false;
|
|
1190
1190
|
}
|
|
1191
|
-
function prefixIssues(
|
|
1191
|
+
function prefixIssues(path13, issues) {
|
|
1192
1192
|
return issues.map((iss) => {
|
|
1193
1193
|
var _a4;
|
|
1194
1194
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
1195
|
-
iss.path.unshift(
|
|
1195
|
+
iss.path.unshift(path13);
|
|
1196
1196
|
return iss;
|
|
1197
1197
|
});
|
|
1198
1198
|
}
|
|
@@ -1339,16 +1339,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
1341
1341
|
const fieldErrors = { _errors: [] };
|
|
1342
|
-
const processError = (error53,
|
|
1342
|
+
const processError = (error53, path13 = []) => {
|
|
1343
1343
|
for (const issue2 of error53.issues) {
|
|
1344
1344
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1345
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1345
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
1346
1346
|
} else if (issue2.code === "invalid_key") {
|
|
1347
|
-
processError({ issues: issue2.issues }, [...
|
|
1347
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1348
1348
|
} else if (issue2.code === "invalid_element") {
|
|
1349
|
-
processError({ issues: issue2.issues }, [...
|
|
1349
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1350
1350
|
} else {
|
|
1351
|
-
const fullpath = [...
|
|
1351
|
+
const fullpath = [...path13, ...issue2.path];
|
|
1352
1352
|
if (fullpath.length === 0) {
|
|
1353
1353
|
fieldErrors._errors.push(mapper(issue2));
|
|
1354
1354
|
} else {
|
|
@@ -1375,17 +1375,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
1377
1377
|
const result = { errors: [] };
|
|
1378
|
-
const processError = (error53,
|
|
1378
|
+
const processError = (error53, path13 = []) => {
|
|
1379
1379
|
var _a4, _b2;
|
|
1380
1380
|
for (const issue2 of error53.issues) {
|
|
1381
1381
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1382
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1382
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
1383
1383
|
} else if (issue2.code === "invalid_key") {
|
|
1384
|
-
processError({ issues: issue2.issues }, [...
|
|
1384
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1385
1385
|
} else if (issue2.code === "invalid_element") {
|
|
1386
|
-
processError({ issues: issue2.issues }, [...
|
|
1386
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1387
1387
|
} else {
|
|
1388
|
-
const fullpath = [...
|
|
1388
|
+
const fullpath = [...path13, ...issue2.path];
|
|
1389
1389
|
if (fullpath.length === 0) {
|
|
1390
1390
|
result.errors.push(mapper(issue2));
|
|
1391
1391
|
continue;
|
|
@@ -1417,8 +1417,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
function toDotPath(_path) {
|
|
1419
1419
|
const segs = [];
|
|
1420
|
-
const
|
|
1421
|
-
for (const seg of
|
|
1420
|
+
const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1421
|
+
for (const seg of path13) {
|
|
1422
1422
|
if (typeof seg === "number")
|
|
1423
1423
|
segs.push(`[${seg}]`);
|
|
1424
1424
|
else if (typeof seg === "symbol")
|
|
@@ -14110,13 +14110,13 @@ function resolveRef(ref, ctx) {
|
|
|
14110
14110
|
if (!ref.startsWith("#")) {
|
|
14111
14111
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14112
14112
|
}
|
|
14113
|
-
const
|
|
14114
|
-
if (
|
|
14113
|
+
const path13 = ref.slice(1).split("/").filter(Boolean);
|
|
14114
|
+
if (path13.length === 0) {
|
|
14115
14115
|
return ctx.rootSchema;
|
|
14116
14116
|
}
|
|
14117
14117
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14118
|
-
if (
|
|
14119
|
-
const key =
|
|
14118
|
+
if (path13[0] === defsKey) {
|
|
14119
|
+
const key = path13[1];
|
|
14120
14120
|
if (!key || !ctx.defs[key]) {
|
|
14121
14121
|
throw new Error(`Reference not found: ${ref}`);
|
|
14122
14122
|
}
|
|
@@ -14527,6 +14527,46 @@ config(en_default());
|
|
|
14527
14527
|
// ../../shared-contracts/dist/version.js
|
|
14528
14528
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
14529
14529
|
|
|
14530
|
+
// ../../shared-contracts/dist/idle-release.js
|
|
14531
|
+
var IDLE_RELEASE_TIMEOUT_MINUTES_MIN = 5;
|
|
14532
|
+
var IDLE_RELEASE_TIMEOUT_MINUTES_MAX = 1440;
|
|
14533
|
+
var idleReleaseSettingsSchema = external_exports.strictObject({
|
|
14534
|
+
enabled: external_exports.boolean(),
|
|
14535
|
+
timeoutMinutes: external_exports.number().int().min(IDLE_RELEASE_TIMEOUT_MINUTES_MIN).max(IDLE_RELEASE_TIMEOUT_MINUTES_MAX)
|
|
14536
|
+
});
|
|
14537
|
+
var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
|
|
14538
|
+
enabled: false,
|
|
14539
|
+
timeoutMinutes: 30
|
|
14540
|
+
});
|
|
14541
|
+
|
|
14542
|
+
// ../../shared-contracts/dist/loaded-sessions.js
|
|
14543
|
+
var loadedSessionStateSchema = external_exports.enum([
|
|
14544
|
+
"idle",
|
|
14545
|
+
"running",
|
|
14546
|
+
"busy",
|
|
14547
|
+
"closing",
|
|
14548
|
+
"failed",
|
|
14549
|
+
"blocked"
|
|
14550
|
+
]);
|
|
14551
|
+
var loadedSessionReasonSchema = external_exports.enum([
|
|
14552
|
+
"none",
|
|
14553
|
+
"disabled",
|
|
14554
|
+
"timeout",
|
|
14555
|
+
"operation",
|
|
14556
|
+
"background",
|
|
14557
|
+
"identity",
|
|
14558
|
+
"persistence",
|
|
14559
|
+
"closeFailed"
|
|
14560
|
+
]);
|
|
14561
|
+
var loadedSessionsSchema = external_exports.array(external_exports.strictObject({
|
|
14562
|
+
threadId: external_exports.string(),
|
|
14563
|
+
title: external_exports.string(),
|
|
14564
|
+
harnessId: external_exports.string(),
|
|
14565
|
+
state: loadedSessionStateSchema,
|
|
14566
|
+
reason: loadedSessionReasonSchema,
|
|
14567
|
+
inactiveMs: external_exports.number().nonnegative()
|
|
14568
|
+
}));
|
|
14569
|
+
|
|
14530
14570
|
// ../../shared-contracts/dist/ids.js
|
|
14531
14571
|
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
14532
14572
|
message: "Identifier must not be empty or whitespace"
|
|
@@ -15077,75 +15117,15 @@ var codexAccountSchema = external_exports.object({
|
|
|
15077
15117
|
email: external_exports.string().email().max(320).optional(),
|
|
15078
15118
|
planType: codexAccountPlanTypeSchema.optional()
|
|
15079
15119
|
}).strict();
|
|
15080
|
-
var codexAccountPhaseSchema = external_exports.enum(["ready", "
|
|
15081
|
-
var codexAccountPendingOperationSchema = external_exports.object({
|
|
15082
|
-
operationId: nonBlankTextSchema3.max(1024),
|
|
15083
|
-
kind: external_exports.enum(["login", "switch", "logout", "recovery"])
|
|
15084
|
-
}).strict();
|
|
15085
|
-
var codexAccountCapabilitiesSchema = external_exports.object({
|
|
15086
|
-
manage: external_exports.boolean(),
|
|
15087
|
-
switch: external_exports.boolean(),
|
|
15088
|
-
login: external_exports.boolean(),
|
|
15089
|
-
delete: external_exports.boolean(),
|
|
15090
|
-
recover: external_exports.boolean().optional(),
|
|
15091
|
-
logout: external_exports.boolean().optional(),
|
|
15092
|
-
reason: external_exports.enum([
|
|
15093
|
-
"ssh-single-account",
|
|
15094
|
-
"unsupported-storage",
|
|
15095
|
-
"unsupported-version",
|
|
15096
|
-
"recovery-required",
|
|
15097
|
-
"keyring-unavailable",
|
|
15098
|
-
"migration-required"
|
|
15099
|
-
]).optional()
|
|
15100
|
-
}).strict();
|
|
15120
|
+
var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
|
|
15101
15121
|
var codexAccountListResultSchema = external_exports.object({
|
|
15102
15122
|
version: external_exports.literal(2),
|
|
15103
15123
|
currentAccountId: accountIdSchema.nullable(),
|
|
15104
15124
|
phase: codexAccountPhaseSchema,
|
|
15105
15125
|
revision: external_exports.number().int().nonnegative(),
|
|
15106
15126
|
instanceId: nonBlankTextSchema3.max(1024).optional(),
|
|
15107
|
-
|
|
15108
|
-
/** Credentials were adopted; other native homes/history remain unmerged. */
|
|
15109
|
-
legacyHistoryPreserved: external_exports.boolean().optional(),
|
|
15110
|
-
pendingOperation: codexAccountPendingOperationSchema.optional(),
|
|
15111
|
-
capabilities: codexAccountCapabilitiesSchema,
|
|
15112
|
-
accounts: external_exports.array(codexAccountSchema).max(128)
|
|
15113
|
-
}).strict();
|
|
15114
|
-
var codexAccountActivateParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
|
|
15115
|
-
var codexAccountSwitchParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
|
|
15116
|
-
var codexAccountReadyMutationResultShape = {
|
|
15117
|
-
phase: external_exports.literal("ready"),
|
|
15118
|
-
revision: external_exports.number().int().nonnegative()
|
|
15119
|
-
};
|
|
15120
|
-
var codexAccountSwitchResultSchema = external_exports.object({
|
|
15121
|
-
currentAccountId: accountIdSchema,
|
|
15122
|
-
...codexAccountReadyMutationResultShape
|
|
15123
|
-
}).strict();
|
|
15124
|
-
var codexAccountDeleteParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
|
|
15125
|
-
var codexAccountDeleteResultSchema = external_exports.object({ deletedAccountId: accountIdSchema }).strict();
|
|
15126
|
-
var codexAccountLoginStartParamsSchema = external_exports.object({ accountId: accountIdSchema.optional() }).strict();
|
|
15127
|
-
var codexAccountLoginStartResultSchema = external_exports.object({
|
|
15128
|
-
accountId: accountIdSchema,
|
|
15129
|
-
loginId: nonBlankTextSchema3.max(1024),
|
|
15130
|
-
verificationUrl: external_exports.string().url().max(16384),
|
|
15131
|
-
userCode: nonBlankTextSchema3.max(1024)
|
|
15132
|
-
}).strict();
|
|
15133
|
-
var codexAccountLoginCancelParamsSchema = external_exports.object({ loginId: nonBlankTextSchema3.max(1024) }).strict();
|
|
15134
|
-
var codexAccountLoginCancelResultSchema = external_exports.object({ cancelled: external_exports.boolean() }).strict();
|
|
15135
|
-
var codexAccountLoginCompletedSchema = external_exports.object({
|
|
15136
|
-
accountId: accountIdSchema,
|
|
15137
|
-
loginId: nonBlankTextSchema3.max(1024),
|
|
15138
|
-
success: external_exports.boolean(),
|
|
15139
|
-
error: external_exports.string().max(4096).nullable(),
|
|
15140
|
-
saved: external_exports.boolean().optional(),
|
|
15141
|
-
cleanupRequired: external_exports.boolean().optional()
|
|
15127
|
+
accounts: external_exports.array(codexAccountSchema).max(1)
|
|
15142
15128
|
}).strict();
|
|
15143
|
-
var codexAccountLogoutParamsSchema = external_exports.object({}).strict();
|
|
15144
|
-
var codexAccountLogoutResultSchema = external_exports.object({
|
|
15145
|
-
currentAccountId: external_exports.null(),
|
|
15146
|
-
...codexAccountReadyMutationResultShape
|
|
15147
|
-
}).strict();
|
|
15148
|
-
var codexAccountRecoverParamsSchema = external_exports.object({}).strict();
|
|
15149
15129
|
var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
15150
15130
|
var codexAccountUsageResultSchema = external_exports.object({
|
|
15151
15131
|
accountId: accountIdSchema,
|
|
@@ -15154,21 +15134,6 @@ var codexAccountUsageResultSchema = external_exports.object({
|
|
|
15154
15134
|
freshness: external_exports.enum(["live", "cached"]),
|
|
15155
15135
|
observedAt: external_exports.string().datetime().nullable()
|
|
15156
15136
|
}).strict();
|
|
15157
|
-
var codexAccountResetCreditConsumeParamsSchema = external_exports.object({
|
|
15158
|
-
accountId: accountIdSchema,
|
|
15159
|
-
idempotencyKey: external_exports.string().uuid().optional()
|
|
15160
|
-
}).strict();
|
|
15161
|
-
var codexAccountResetCreditConsumeOutcomeSchema = external_exports.enum([
|
|
15162
|
-
"reset",
|
|
15163
|
-
"nothingToReset",
|
|
15164
|
-
"noCredit",
|
|
15165
|
-
"alreadyRedeemed"
|
|
15166
|
-
]);
|
|
15167
|
-
var codexAccountResetCreditConsumeResultSchema = external_exports.object({
|
|
15168
|
-
accountId: accountIdSchema,
|
|
15169
|
-
outcome: codexAccountResetCreditConsumeOutcomeSchema,
|
|
15170
|
-
accountCredits: accountCreditsSnapshotSchema.optional()
|
|
15171
|
-
}).strict();
|
|
15172
15137
|
|
|
15173
15138
|
// ../../shared-contracts/dist/harness-session-import.js
|
|
15174
15139
|
var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
|
|
@@ -16509,7 +16474,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
16509
16474
|
|
|
16510
16475
|
// dist/claude-code-adapter.js
|
|
16511
16476
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
16512
|
-
import
|
|
16477
|
+
import path11 from "node:path";
|
|
16513
16478
|
|
|
16514
16479
|
// ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
16515
16480
|
import { createRequire as DW } from "node:module";
|
|
@@ -20414,8 +20379,8 @@ var qU = v(function(BU) {
|
|
|
20414
20379
|
BU._globalThis = void 0;
|
|
20415
20380
|
BU._globalThis = typeof globalThis === "object" ? globalThis : global;
|
|
20416
20381
|
});
|
|
20417
|
-
var GU = v(function(
|
|
20418
|
-
var Axe =
|
|
20382
|
+
var GU = v(function(os6) {
|
|
20383
|
+
var Axe = os6 && os6.__createBinding || (Object.create ? function(e, t, r, n) {
|
|
20419
20384
|
if (n === void 0) n = r;
|
|
20420
20385
|
Object.defineProperty(e, n, { enumerable: true, get: function() {
|
|
20421
20386
|
return t[r];
|
|
@@ -20423,11 +20388,11 @@ var GU = v(function(os5) {
|
|
|
20423
20388
|
} : function(e, t, r, n) {
|
|
20424
20389
|
if (n === void 0) n = r;
|
|
20425
20390
|
e[n] = t[r];
|
|
20426
|
-
}), kxe =
|
|
20391
|
+
}), kxe = os6 && os6.__exportStar || function(e, t) {
|
|
20427
20392
|
for (var r in e) if (r !== "default" && !Object.prototype.hasOwnProperty.call(t, r)) Axe(t, e, r);
|
|
20428
20393
|
};
|
|
20429
|
-
Object.defineProperty(
|
|
20430
|
-
kxe(qU(),
|
|
20394
|
+
Object.defineProperty(os6, "__esModule", { value: true });
|
|
20395
|
+
kxe(qU(), os6);
|
|
20431
20396
|
});
|
|
20432
20397
|
var WU = v(function(is) {
|
|
20433
20398
|
var Oxe = is && is.__createBinding || (Object.create ? function(e, t, r, n) {
|
|
@@ -42200,14 +42165,225 @@ var ClaudeBackgroundOccupancy = class {
|
|
|
42200
42165
|
}
|
|
42201
42166
|
};
|
|
42202
42167
|
|
|
42168
|
+
// dist/claude-session-import.js
|
|
42169
|
+
import { createReadStream } from "node:fs";
|
|
42170
|
+
import { opendir, realpath, stat } from "node:fs/promises";
|
|
42171
|
+
import os2 from "node:os";
|
|
42172
|
+
import path2 from "node:path";
|
|
42173
|
+
import { createInterface } from "node:readline";
|
|
42174
|
+
var CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH = 120;
|
|
42175
|
+
var CLAUDE_INTERNAL_USER_TEXT = /^<(?:local-command-|command-)/u;
|
|
42176
|
+
var ClaudeSessionChangedError = class extends Error {
|
|
42177
|
+
constructor() {
|
|
42178
|
+
super("Claude Code Session changed during discovery; refresh and retry");
|
|
42179
|
+
}
|
|
42180
|
+
};
|
|
42181
|
+
function isRecord2(value) {
|
|
42182
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
42183
|
+
}
|
|
42184
|
+
function missing(error52) {
|
|
42185
|
+
return isRecord2(error52) && error52.code === "ENOENT";
|
|
42186
|
+
}
|
|
42187
|
+
function sameFile(left, right) {
|
|
42188
|
+
return left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs && left.ino === right.ino && left.dev === right.dev;
|
|
42189
|
+
}
|
|
42190
|
+
function cleanText(value) {
|
|
42191
|
+
if (typeof value !== "string")
|
|
42192
|
+
return null;
|
|
42193
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
42194
|
+
if (!normalized)
|
|
42195
|
+
return null;
|
|
42196
|
+
const characters = [...normalized];
|
|
42197
|
+
if (characters.length <= CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH)
|
|
42198
|
+
return normalized;
|
|
42199
|
+
return `${characters.slice(0, CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH - 1).join("").trimEnd()}…`;
|
|
42200
|
+
}
|
|
42201
|
+
function userText(message) {
|
|
42202
|
+
if (!isRecord2(message) || message.role !== "user")
|
|
42203
|
+
return null;
|
|
42204
|
+
const { content } = message;
|
|
42205
|
+
const text = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ")) : null;
|
|
42206
|
+
return text && !CLAUDE_INTERNAL_USER_TEXT.test(text) ? text : null;
|
|
42207
|
+
}
|
|
42208
|
+
function claudeProjectsDirectory(environment) {
|
|
42209
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
42210
|
+
return path2.join(path2.resolve(environment.CLAUDE_CONFIG_DIR ?? path2.join(home, ".claude")), "projects");
|
|
42211
|
+
}
|
|
42212
|
+
async function sessionFiles(directory, signal) {
|
|
42213
|
+
signal.throwIfAborted();
|
|
42214
|
+
const projects = await opendir(directory).catch((error52) => {
|
|
42215
|
+
if (missing(error52))
|
|
42216
|
+
return null;
|
|
42217
|
+
throw error52;
|
|
42218
|
+
});
|
|
42219
|
+
if (!projects)
|
|
42220
|
+
return [];
|
|
42221
|
+
const files = [];
|
|
42222
|
+
for await (const project of projects) {
|
|
42223
|
+
signal.throwIfAborted();
|
|
42224
|
+
if (!project.isDirectory())
|
|
42225
|
+
continue;
|
|
42226
|
+
const entries = await opendir(path2.join(directory, project.name)).catch((error52) => {
|
|
42227
|
+
if (missing(error52))
|
|
42228
|
+
return null;
|
|
42229
|
+
throw error52;
|
|
42230
|
+
});
|
|
42231
|
+
if (!entries)
|
|
42232
|
+
continue;
|
|
42233
|
+
for await (const entry of entries) {
|
|
42234
|
+
signal.throwIfAborted();
|
|
42235
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
42236
|
+
files.push(path2.join(directory, project.name, entry.name));
|
|
42237
|
+
}
|
|
42238
|
+
}
|
|
42239
|
+
}
|
|
42240
|
+
return files;
|
|
42241
|
+
}
|
|
42242
|
+
async function readCandidate(file2, signal) {
|
|
42243
|
+
const nativeSessionId = path2.basename(file2, ".jsonl");
|
|
42244
|
+
if (!external_exports.uuid().safeParse(nativeSessionId).success)
|
|
42245
|
+
return null;
|
|
42246
|
+
const before = await stat(file2);
|
|
42247
|
+
if (!before.isFile() || before.size === 0)
|
|
42248
|
+
return null;
|
|
42249
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal, end: before.size - 1 });
|
|
42250
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
42251
|
+
let cwd = null;
|
|
42252
|
+
let customTitle = null;
|
|
42253
|
+
let generatedTitle = null;
|
|
42254
|
+
let firstPrompt = null;
|
|
42255
|
+
let hasConversation = false;
|
|
42256
|
+
try {
|
|
42257
|
+
for await (const line of lines) {
|
|
42258
|
+
signal.throwIfAborted();
|
|
42259
|
+
if (!line.trim())
|
|
42260
|
+
continue;
|
|
42261
|
+
let entry;
|
|
42262
|
+
try {
|
|
42263
|
+
entry = JSON.parse(line);
|
|
42264
|
+
} catch {
|
|
42265
|
+
continue;
|
|
42266
|
+
}
|
|
42267
|
+
if (!isRecord2(entry))
|
|
42268
|
+
continue;
|
|
42269
|
+
if (typeof entry.sessionId === "string" && entry.sessionId !== nativeSessionId)
|
|
42270
|
+
return null;
|
|
42271
|
+
if (entry.isSidechain === true)
|
|
42272
|
+
continue;
|
|
42273
|
+
if (typeof entry.cwd === "string" && path2.isAbsolute(entry.cwd))
|
|
42274
|
+
cwd = entry.cwd;
|
|
42275
|
+
if (entry.type === "custom-title") {
|
|
42276
|
+
customTitle = cleanText(entry.customTitle);
|
|
42277
|
+
} else if (entry.type === "ai-title") {
|
|
42278
|
+
generatedTitle = cleanText(entry.aiTitle);
|
|
42279
|
+
} else if (entry.type === "summary") {
|
|
42280
|
+
generatedTitle = cleanText(entry.summary) ?? generatedTitle;
|
|
42281
|
+
} else if (entry.type === "user" || entry.type === "assistant") {
|
|
42282
|
+
hasConversation = true;
|
|
42283
|
+
if (!firstPrompt && entry.type === "user")
|
|
42284
|
+
firstPrompt = userText(entry.message);
|
|
42285
|
+
}
|
|
42286
|
+
}
|
|
42287
|
+
} finally {
|
|
42288
|
+
lines.close();
|
|
42289
|
+
stream.destroy();
|
|
42290
|
+
}
|
|
42291
|
+
if (!hasConversation || !cwd)
|
|
42292
|
+
return null;
|
|
42293
|
+
const after = await stat(file2);
|
|
42294
|
+
if (!sameFile(before, after))
|
|
42295
|
+
throw new ClaudeSessionChangedError();
|
|
42296
|
+
const resolvedCwd = await realpath(cwd);
|
|
42297
|
+
if (!(await stat(resolvedCwd)).isDirectory())
|
|
42298
|
+
return null;
|
|
42299
|
+
const candidate = harnessSessionImportCandidateSchema.safeParse({
|
|
42300
|
+
nativeSessionId,
|
|
42301
|
+
title: customTitle ?? generatedTitle ?? firstPrompt,
|
|
42302
|
+
updatedAt: Math.floor(before.mtimeMs),
|
|
42303
|
+
cwd: resolvedCwd,
|
|
42304
|
+
running: null
|
|
42305
|
+
});
|
|
42306
|
+
const nativeRef = nativeSessionRefSchema.safeParse({
|
|
42307
|
+
harnessId: "claude-code",
|
|
42308
|
+
nativeSessionId,
|
|
42309
|
+
formatVersion: 1
|
|
42310
|
+
});
|
|
42311
|
+
return candidate.success && nativeRef.success ? { candidate: candidate.data, nativeRef: nativeRef.data } : null;
|
|
42312
|
+
}
|
|
42313
|
+
var ClaudeSessionImportIndex = class {
|
|
42314
|
+
#directory;
|
|
42315
|
+
#cache = /* @__PURE__ */ new Map();
|
|
42316
|
+
#listing;
|
|
42317
|
+
constructor(environment) {
|
|
42318
|
+
this.#directory = claudeProjectsDirectory(environment);
|
|
42319
|
+
}
|
|
42320
|
+
list(signal) {
|
|
42321
|
+
this.#listing ??= this.#scan(signal).finally(() => {
|
|
42322
|
+
this.#listing = void 0;
|
|
42323
|
+
});
|
|
42324
|
+
return this.#listing;
|
|
42325
|
+
}
|
|
42326
|
+
async #scan(signal) {
|
|
42327
|
+
const next = /* @__PURE__ */ new Map();
|
|
42328
|
+
const identities = /* @__PURE__ */ new Set();
|
|
42329
|
+
const sources = [];
|
|
42330
|
+
for (const file2 of await sessionFiles(this.#directory, signal)) {
|
|
42331
|
+
signal.throwIfAborted();
|
|
42332
|
+
try {
|
|
42333
|
+
const fingerprint = await stat(file2);
|
|
42334
|
+
const cached2 = this.#cache.get(file2);
|
|
42335
|
+
const source = cached2 && sameFile(cached2.fingerprint, fingerprint) ? cached2.source : await readCandidate(file2, signal);
|
|
42336
|
+
if (!source)
|
|
42337
|
+
continue;
|
|
42338
|
+
if (!(await stat(source.candidate.cwd)).isDirectory())
|
|
42339
|
+
continue;
|
|
42340
|
+
if (identities.has(source.candidate.nativeSessionId)) {
|
|
42341
|
+
throw new Error("Claude Code Session identity is ambiguous across files");
|
|
42342
|
+
}
|
|
42343
|
+
identities.add(source.candidate.nativeSessionId);
|
|
42344
|
+
next.set(file2, { fingerprint, source });
|
|
42345
|
+
sources.push(source);
|
|
42346
|
+
} catch (error52) {
|
|
42347
|
+
if (!missing(error52) && !(error52 instanceof ClaudeSessionChangedError))
|
|
42348
|
+
throw error52;
|
|
42349
|
+
}
|
|
42350
|
+
}
|
|
42351
|
+
this.#cache = next;
|
|
42352
|
+
return structuredClone(sources.sort((left, right) => right.candidate.updatedAt - left.candidate.updatedAt));
|
|
42353
|
+
}
|
|
42354
|
+
async resolve(nativeSessionId, signal) {
|
|
42355
|
+
if (!external_exports.uuid().safeParse(nativeSessionId).success)
|
|
42356
|
+
return null;
|
|
42357
|
+
let selected;
|
|
42358
|
+
for (const file2 of await sessionFiles(this.#directory, signal)) {
|
|
42359
|
+
signal.throwIfAborted();
|
|
42360
|
+
if (path2.basename(file2, ".jsonl") !== nativeSessionId)
|
|
42361
|
+
continue;
|
|
42362
|
+
if (selected)
|
|
42363
|
+
throw new Error("Claude Code Session identity is ambiguous across files");
|
|
42364
|
+
selected = file2;
|
|
42365
|
+
}
|
|
42366
|
+
if (!selected)
|
|
42367
|
+
return null;
|
|
42368
|
+
try {
|
|
42369
|
+
const source = await readCandidate(selected, signal);
|
|
42370
|
+
return source?.candidate.nativeSessionId === nativeSessionId ? source : null;
|
|
42371
|
+
} catch (error52) {
|
|
42372
|
+
if (missing(error52))
|
|
42373
|
+
return null;
|
|
42374
|
+
throw error52;
|
|
42375
|
+
}
|
|
42376
|
+
}
|
|
42377
|
+
};
|
|
42378
|
+
|
|
42203
42379
|
// dist/command.js
|
|
42204
|
-
import
|
|
42380
|
+
import path5 from "node:path";
|
|
42205
42381
|
|
|
42206
42382
|
// ../../harness-discovery/dist/environment.js
|
|
42207
42383
|
import fs from "node:fs";
|
|
42208
|
-
import
|
|
42384
|
+
import path3 from "node:path";
|
|
42209
42385
|
function targetPath(platform) {
|
|
42210
|
-
return platform === "win32" ?
|
|
42386
|
+
return platform === "win32" ? path3.win32 : path3.posix;
|
|
42211
42387
|
}
|
|
42212
42388
|
function environmentValue(environment, name) {
|
|
42213
42389
|
const lowered = name.toLowerCase();
|
|
@@ -42250,11 +42426,11 @@ function newestFirst(names) {
|
|
|
42250
42426
|
}
|
|
42251
42427
|
|
|
42252
42428
|
// ../../harness-discovery/dist/node-runtime.js
|
|
42253
|
-
import
|
|
42429
|
+
import path4 from "node:path";
|
|
42254
42430
|
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
42255
42431
|
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
42256
42432
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
42257
|
-
const runtimeDirectory =
|
|
42433
|
+
const runtimeDirectory = path4.dirname(runtimeExecutable);
|
|
42258
42434
|
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
42259
42435
|
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
42260
42436
|
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
@@ -42264,7 +42440,7 @@ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath
|
|
|
42264
42440
|
}
|
|
42265
42441
|
|
|
42266
42442
|
// ../../harness-discovery/dist/resolve.js
|
|
42267
|
-
import
|
|
42443
|
+
import os3 from "node:os";
|
|
42268
42444
|
|
|
42269
42445
|
// ../../harness-discovery/dist/version-managers.js
|
|
42270
42446
|
function versionManagerBinaryDirectories(context) {
|
|
@@ -42330,7 +42506,7 @@ function installRootExtensions(platform) {
|
|
|
42330
42506
|
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
42331
42507
|
}
|
|
42332
42508
|
function resolveHomeDirectory(input) {
|
|
42333
|
-
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ??
|
|
42509
|
+
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os3.homedir();
|
|
42334
42510
|
}
|
|
42335
42511
|
function templateVariables(environment, platform, home) {
|
|
42336
42512
|
const pathFlavor = targetPath(platform);
|
|
@@ -42472,14 +42648,14 @@ function resolveClaudeCodeExecutable(input = {}, dependencies = {}) {
|
|
|
42472
42648
|
}, dependencies);
|
|
42473
42649
|
if (!resolution)
|
|
42474
42650
|
throw new ClaudeCodeExecutableError("Claude Code is not installed");
|
|
42475
|
-
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable :
|
|
42651
|
+
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
|
|
42476
42652
|
}
|
|
42477
42653
|
|
|
42478
42654
|
// dist/pending-session.js
|
|
42479
42655
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
42480
|
-
import { mkdir, open, readFile as readFile2, rename, rm as rm2, stat, unlink } from "node:fs/promises";
|
|
42481
|
-
import
|
|
42482
|
-
import
|
|
42656
|
+
import { mkdir, open, readFile as readFile2, rename, rm as rm2, stat as stat2, unlink } from "node:fs/promises";
|
|
42657
|
+
import os4 from "node:os";
|
|
42658
|
+
import path6 from "node:path";
|
|
42483
42659
|
var reservationSchema = external_exports.strictObject({
|
|
42484
42660
|
version: external_exports.literal(1),
|
|
42485
42661
|
sessionId: external_exports.uuid(),
|
|
@@ -42492,13 +42668,13 @@ function isPendingClaudeSession(ref) {
|
|
|
42492
42668
|
var ClaudePendingSessions = class {
|
|
42493
42669
|
#directory;
|
|
42494
42670
|
constructor(environment) {
|
|
42495
|
-
this.#directory =
|
|
42671
|
+
this.#directory = path6.join(path6.resolve(environment.CLAUDE_CONFIG_DIR ?? path6.join(os4.homedir(), ".claude")), "codexhost", "pending-sessions");
|
|
42496
42672
|
}
|
|
42497
42673
|
#path(ref, cwd) {
|
|
42498
|
-
if (ref.harnessId !== "claude-code" || !external_exports.uuid().safeParse(ref.nativeSessionId).success || !external_exports.strictObject({ pendingSession: external_exports.literal(1) }).safeParse(ref.locator).success || !
|
|
42674
|
+
if (ref.harnessId !== "claude-code" || !external_exports.uuid().safeParse(ref.nativeSessionId).success || !external_exports.strictObject({ pendingSession: external_exports.literal(1) }).safeParse(ref.locator).success || !path6.isAbsolute(cwd)) {
|
|
42499
42675
|
throw new Error("Claude Code pending Session identity is invalid");
|
|
42500
42676
|
}
|
|
42501
|
-
return
|
|
42677
|
+
return path6.join(this.#directory, ref.nativeSessionId);
|
|
42502
42678
|
}
|
|
42503
42679
|
async create(cwd, configuration) {
|
|
42504
42680
|
const ref = nativeSessionRefSchema.parse({
|
|
@@ -42517,7 +42693,7 @@ var ClaudePendingSessions = class {
|
|
|
42517
42693
|
await mkdir(this.#directory, { recursive: true, mode: 448 });
|
|
42518
42694
|
await mkdir(directory, { mode: 448 });
|
|
42519
42695
|
try {
|
|
42520
|
-
const file2 = await open(
|
|
42696
|
+
const file2 = await open(path6.join(directory, "session.json"), "wx", 384);
|
|
42521
42697
|
try {
|
|
42522
42698
|
await file2.writeFile(JSON.stringify(reservation));
|
|
42523
42699
|
await file2.sync();
|
|
@@ -42534,13 +42710,13 @@ var ClaudePendingSessions = class {
|
|
|
42534
42710
|
}
|
|
42535
42711
|
async read(ref, cwd) {
|
|
42536
42712
|
const directory = this.#path(ref, cwd);
|
|
42537
|
-
const reservation = reservationSchema.parse(JSON.parse(await readFile2(
|
|
42713
|
+
const reservation = reservationSchema.parse(JSON.parse(await readFile2(path6.join(directory, "session.json"), "utf8")));
|
|
42538
42714
|
if (reservation.sessionId !== ref.nativeSessionId || reservation.cwd !== cwd) {
|
|
42539
42715
|
throw new Error("Claude Code pending Session does not belong to this working directory");
|
|
42540
42716
|
}
|
|
42541
42717
|
let started = false;
|
|
42542
42718
|
try {
|
|
42543
|
-
const claim = await
|
|
42719
|
+
const claim = await stat2(path6.join(directory, "started"));
|
|
42544
42720
|
if (!claim.isFile())
|
|
42545
42721
|
throw new Error("Claude Code pending Session claim is invalid");
|
|
42546
42722
|
started = true;
|
|
@@ -42553,7 +42729,7 @@ var ClaudePendingSessions = class {
|
|
|
42553
42729
|
async saveConfiguration(ref, cwd, configuration) {
|
|
42554
42730
|
await this.read(ref, cwd);
|
|
42555
42731
|
const directory = this.#path(ref, cwd);
|
|
42556
|
-
const temporary =
|
|
42732
|
+
const temporary = path6.join(directory, `${randomUUID2()}.tmp`);
|
|
42557
42733
|
try {
|
|
42558
42734
|
const file2 = await open(temporary, "wx", 384);
|
|
42559
42735
|
try {
|
|
@@ -42567,7 +42743,7 @@ var ClaudePendingSessions = class {
|
|
|
42567
42743
|
} finally {
|
|
42568
42744
|
await file2.close();
|
|
42569
42745
|
}
|
|
42570
|
-
await rename(temporary,
|
|
42746
|
+
await rename(temporary, path6.join(directory, "session.json"));
|
|
42571
42747
|
await this.#sync(directory);
|
|
42572
42748
|
} finally {
|
|
42573
42749
|
await rm2(temporary, { force: true });
|
|
@@ -42585,7 +42761,7 @@ var ClaudePendingSessions = class {
|
|
|
42585
42761
|
}
|
|
42586
42762
|
async claim(ref, cwd) {
|
|
42587
42763
|
await this.read(ref, cwd);
|
|
42588
|
-
const claim = await open(
|
|
42764
|
+
const claim = await open(path6.join(this.#path(ref, cwd), "started"), "wx", 384);
|
|
42589
42765
|
try {
|
|
42590
42766
|
await claim.sync();
|
|
42591
42767
|
} finally {
|
|
@@ -42595,7 +42771,7 @@ var ClaudePendingSessions = class {
|
|
|
42595
42771
|
}
|
|
42596
42772
|
/** Only the claim owner may release, after proven close and before submitting any native input. */
|
|
42597
42773
|
async release(ref, cwd) {
|
|
42598
|
-
await unlink(
|
|
42774
|
+
await unlink(path6.join(this.#path(ref, cwd), "started"));
|
|
42599
42775
|
await this.#sync(this.#path(ref, cwd));
|
|
42600
42776
|
}
|
|
42601
42777
|
async discard(ref, cwd) {
|
|
@@ -42604,7 +42780,7 @@ var ClaudePendingSessions = class {
|
|
|
42604
42780
|
};
|
|
42605
42781
|
|
|
42606
42782
|
// dist/claude-fork.js
|
|
42607
|
-
import
|
|
42783
|
+
import path7 from "node:path";
|
|
42608
42784
|
import { isDeepStrictEqual } from "node:util";
|
|
42609
42785
|
|
|
42610
42786
|
// dist/item-identity.js
|
|
@@ -42614,7 +42790,7 @@ function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
|
42614
42790
|
|
|
42615
42791
|
// dist/claude-history.js
|
|
42616
42792
|
var claudeCodeHarnessId = harnessIdSchema.parse("claude-code");
|
|
42617
|
-
function
|
|
42793
|
+
function isRecord3(value) {
|
|
42618
42794
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
42619
42795
|
}
|
|
42620
42796
|
function textParts(value) {
|
|
@@ -42622,12 +42798,12 @@ function textParts(value) {
|
|
|
42622
42798
|
return value.length > 0 ? [value] : [];
|
|
42623
42799
|
if (!Array.isArray(value))
|
|
42624
42800
|
return [];
|
|
42625
|
-
return value.flatMap((part) =>
|
|
42801
|
+
return value.flatMap((part) => isRecord3(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
|
|
42626
42802
|
}
|
|
42627
42803
|
function thinkingParts(value) {
|
|
42628
42804
|
if (!Array.isArray(value))
|
|
42629
42805
|
return [];
|
|
42630
|
-
return value.flatMap((part) =>
|
|
42806
|
+
return value.flatMap((part) => isRecord3(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
|
|
42631
42807
|
}
|
|
42632
42808
|
var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
|
|
42633
42809
|
var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
|
|
@@ -42662,7 +42838,7 @@ function localCommandStdoutText(text) {
|
|
|
42662
42838
|
return match[1] ?? "";
|
|
42663
42839
|
}
|
|
42664
42840
|
function isTaskNotificationOrigin(value) {
|
|
42665
|
-
return
|
|
42841
|
+
return isRecord3(value.origin) && value.origin.kind === "task-notification";
|
|
42666
42842
|
}
|
|
42667
42843
|
function visibleUserTextParts(message) {
|
|
42668
42844
|
if (message.type !== "user" || message.syntheticUser)
|
|
@@ -42673,24 +42849,24 @@ function visibleUserTextParts(message) {
|
|
|
42673
42849
|
return parts.filter((part) => !isLocalCommandRecord(part) && !isTaskNotificationRecord(part));
|
|
42674
42850
|
}
|
|
42675
42851
|
function isInterruptionRecord(value, promptId) {
|
|
42676
|
-
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !
|
|
42852
|
+
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord3(value.message))
|
|
42677
42853
|
return false;
|
|
42678
42854
|
const content = value.message.content;
|
|
42679
42855
|
if (!Array.isArray(content) || content.length !== 1)
|
|
42680
42856
|
return false;
|
|
42681
42857
|
const part = content[0];
|
|
42682
|
-
return
|
|
42858
|
+
return isRecord3(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
|
|
42683
42859
|
}
|
|
42684
42860
|
function conversationMessages(values, sessionId) {
|
|
42685
42861
|
const messages = [];
|
|
42686
42862
|
const ids = /* @__PURE__ */ new Set();
|
|
42687
42863
|
let promptId = null;
|
|
42688
42864
|
for (const value of values) {
|
|
42689
|
-
if (!
|
|
42865
|
+
if (!isRecord3(value))
|
|
42690
42866
|
throw new Error("Claude history contains a malformed message");
|
|
42691
42867
|
if (value.type === "system")
|
|
42692
42868
|
continue;
|
|
42693
|
-
if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !
|
|
42869
|
+
if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !isRecord3(value.message) || value.message.role !== value.type) {
|
|
42694
42870
|
throw new Error("Claude history contains an invalid message identity");
|
|
42695
42871
|
}
|
|
42696
42872
|
if (ids.has(value.uuid))
|
|
@@ -42822,7 +42998,7 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
42822
42998
|
let projectedReasoning = false;
|
|
42823
42999
|
let projectedText = false;
|
|
42824
43000
|
for (const [blockIndex, block] of content.entries()) {
|
|
42825
|
-
if (!
|
|
43001
|
+
if (!isRecord3(block))
|
|
42826
43002
|
continue;
|
|
42827
43003
|
if (block.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
|
|
42828
43004
|
items.push({
|
|
@@ -42865,7 +43041,7 @@ function mapClaudeSnapshot(values, sessionId) {
|
|
|
42865
43041
|
}
|
|
42866
43042
|
} : { status: "succeeded" };
|
|
42867
43043
|
const itemId = hostItemIdSchema.parse(`claude-item-v1-${message.uuid}-tool-${blockIndex}`);
|
|
42868
|
-
if (block.name === "Bash" &&
|
|
43044
|
+
if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
|
|
42869
43045
|
items.push({
|
|
42870
43046
|
item: {
|
|
42871
43047
|
type: "commandExecution",
|
|
@@ -42903,7 +43079,7 @@ function toolResultBlocks(messages) {
|
|
|
42903
43079
|
if (message.type !== "user" || !Array.isArray(message.message.content))
|
|
42904
43080
|
continue;
|
|
42905
43081
|
for (const block of message.message.content) {
|
|
42906
|
-
if (
|
|
43082
|
+
if (isRecord3(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
|
|
42907
43083
|
results.set(block.tool_use_id, block);
|
|
42908
43084
|
}
|
|
42909
43085
|
}
|
|
@@ -42918,7 +43094,7 @@ function toolResultOutput(block) {
|
|
|
42918
43094
|
}
|
|
42919
43095
|
function resultSubagentId(value, block) {
|
|
42920
43096
|
const nativeResult = value.tool_use_result;
|
|
42921
|
-
if (
|
|
43097
|
+
if (isRecord3(nativeResult)) {
|
|
42922
43098
|
const structured = nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id;
|
|
42923
43099
|
if (typeof structured === "string" && structured.length > 0)
|
|
42924
43100
|
return structured;
|
|
@@ -42929,13 +43105,13 @@ function resultSubagentId(value, block) {
|
|
|
42929
43105
|
function subagentPrompt(values, nativeSubagentId2) {
|
|
42930
43106
|
const toolUses = /* @__PURE__ */ new Map();
|
|
42931
43107
|
for (const value of values) {
|
|
42932
|
-
if (!
|
|
43108
|
+
if (!isRecord3(value) || !isRecord3(value.message) || !Array.isArray(value.message.content)) {
|
|
42933
43109
|
continue;
|
|
42934
43110
|
}
|
|
42935
43111
|
for (const block of value.message.content) {
|
|
42936
|
-
if (!
|
|
43112
|
+
if (!isRecord3(block))
|
|
42937
43113
|
continue;
|
|
42938
|
-
if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") &&
|
|
43114
|
+
if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") && isRecord3(block.input) && typeof block.input.prompt === "string" && block.input.prompt.length > 0) {
|
|
42939
43115
|
toolUses.set(block.id, block.input.prompt);
|
|
42940
43116
|
continue;
|
|
42941
43117
|
}
|
|
@@ -42949,7 +43125,7 @@ function subagentPrompt(values, nativeSubagentId2) {
|
|
|
42949
43125
|
return void 0;
|
|
42950
43126
|
}
|
|
42951
43127
|
function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, parentValues = []) {
|
|
42952
|
-
const messages = conversationMessages(values.map((value) =>
|
|
43128
|
+
const messages = conversationMessages(values.map((value) => isRecord3(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
|
|
42953
43129
|
const turns = [];
|
|
42954
43130
|
for (let index = 0; index < messages.length; ) {
|
|
42955
43131
|
const first = messages[index];
|
|
@@ -42976,7 +43152,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
42976
43152
|
const content = Array.isArray(message.message.content) ? message.message.content : [{ type: "text", text: message.message.content }];
|
|
42977
43153
|
for (let blockIndex = 0; blockIndex < content.length; blockIndex += 1) {
|
|
42978
43154
|
const block = content[blockIndex];
|
|
42979
|
-
if (!
|
|
43155
|
+
if (!isRecord3(block))
|
|
42980
43156
|
continue;
|
|
42981
43157
|
const itemId = hostItemIdSchema.parse(`claude-subagent-item-v2-${nativeSubagentId2}-${message.uuid}-${blockIndex}`);
|
|
42982
43158
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
@@ -43013,7 +43189,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
43013
43189
|
retryable: false
|
|
43014
43190
|
}
|
|
43015
43191
|
} : { status: "succeeded" };
|
|
43016
|
-
if (block.name === "Bash" &&
|
|
43192
|
+
if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
|
|
43017
43193
|
items.push({
|
|
43018
43194
|
item: {
|
|
43019
43195
|
type: "commandExecution",
|
|
@@ -43143,7 +43319,7 @@ async function forkClaudeSession(input) {
|
|
|
43143
43319
|
error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
|
|
43144
43320
|
};
|
|
43145
43321
|
}
|
|
43146
|
-
if (
|
|
43322
|
+
if (path7.resolve(sourceInfo.cwd) !== input.cwd) {
|
|
43147
43323
|
return {
|
|
43148
43324
|
ok: false,
|
|
43149
43325
|
error: error51("unsupported", "Claude Code cannot Fork across working directories", false)
|
|
@@ -43243,26 +43419,26 @@ async function forkClaudeSession(input) {
|
|
|
43243
43419
|
}
|
|
43244
43420
|
|
|
43245
43421
|
// dist/claude-transcript.js
|
|
43246
|
-
import
|
|
43247
|
-
import
|
|
43248
|
-
import { readFile as readFile3, readdir, stat as
|
|
43422
|
+
import os5 from "node:os";
|
|
43423
|
+
import path8 from "node:path";
|
|
43424
|
+
import { readFile as readFile3, readdir, stat as stat3 } from "node:fs/promises";
|
|
43249
43425
|
function projectDirectoryName(cwd) {
|
|
43250
43426
|
return cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
43251
43427
|
}
|
|
43252
43428
|
function configDirectory(environment) {
|
|
43253
|
-
return environment.CLAUDE_CONFIG_DIR ?
|
|
43429
|
+
return environment.CLAUDE_CONFIG_DIR ? path8.resolve(environment.CLAUDE_CONFIG_DIR) : path8.join(os5.homedir(), ".claude");
|
|
43254
43430
|
}
|
|
43255
43431
|
async function existingFile(file2) {
|
|
43256
43432
|
try {
|
|
43257
|
-
return (await
|
|
43433
|
+
return (await stat3(file2)).isFile();
|
|
43258
43434
|
} catch {
|
|
43259
43435
|
return false;
|
|
43260
43436
|
}
|
|
43261
43437
|
}
|
|
43262
43438
|
async function findTranscript(input) {
|
|
43263
|
-
const projectsDirectory =
|
|
43439
|
+
const projectsDirectory = path8.join(configDirectory(input.environment), "projects");
|
|
43264
43440
|
const name = `${input.sessionId}.jsonl`;
|
|
43265
|
-
const expected =
|
|
43441
|
+
const expected = path8.join(projectsDirectory, projectDirectoryName(input.cwd), name);
|
|
43266
43442
|
if (await existingFile(expected))
|
|
43267
43443
|
return expected;
|
|
43268
43444
|
let projects;
|
|
@@ -43272,13 +43448,13 @@ async function findTranscript(input) {
|
|
|
43272
43448
|
return null;
|
|
43273
43449
|
}
|
|
43274
43450
|
for (const project of projects) {
|
|
43275
|
-
const candidate =
|
|
43451
|
+
const candidate = path8.join(projectsDirectory, project, name);
|
|
43276
43452
|
if (await existingFile(candidate))
|
|
43277
43453
|
return candidate;
|
|
43278
43454
|
}
|
|
43279
43455
|
return null;
|
|
43280
43456
|
}
|
|
43281
|
-
function
|
|
43457
|
+
function isRecord4(value) {
|
|
43282
43458
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43283
43459
|
}
|
|
43284
43460
|
async function readClaudeTranscript(input) {
|
|
@@ -43296,7 +43472,7 @@ async function readClaudeTranscript(input) {
|
|
|
43296
43472
|
} catch {
|
|
43297
43473
|
continue;
|
|
43298
43474
|
}
|
|
43299
|
-
if (!
|
|
43475
|
+
if (!isRecord4(entry) || entry.type !== "user" && entry.type !== "assistant" || typeof entry.uuid !== "string" || !isRecord4(entry.message)) {
|
|
43300
43476
|
continue;
|
|
43301
43477
|
}
|
|
43302
43478
|
messages.push({ ...entry, session_id: input.sessionId });
|
|
@@ -43563,7 +43739,7 @@ function projectClaudeAccountUsage(usage, account) {
|
|
|
43563
43739
|
}
|
|
43564
43740
|
|
|
43565
43741
|
// dist/file-change.js
|
|
43566
|
-
import
|
|
43742
|
+
import path9 from "node:path";
|
|
43567
43743
|
var hunkSchema = external_exports.object({
|
|
43568
43744
|
oldStart: external_exports.number().int().nonnegative(),
|
|
43569
43745
|
oldLines: external_exports.number().int().nonnegative(),
|
|
@@ -43571,7 +43747,7 @@ var hunkSchema = external_exports.object({
|
|
|
43571
43747
|
newLines: external_exports.number().int().nonnegative(),
|
|
43572
43748
|
lines: external_exports.array(external_exports.string())
|
|
43573
43749
|
}).strict();
|
|
43574
|
-
function
|
|
43750
|
+
function isRecord5(value) {
|
|
43575
43751
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43576
43752
|
}
|
|
43577
43753
|
function validNativePath(value) {
|
|
@@ -43595,7 +43771,7 @@ function validHunk(value) {
|
|
|
43595
43771
|
return hunk;
|
|
43596
43772
|
}
|
|
43597
43773
|
function parseClaudeNativeFileChange(toolName, value) {
|
|
43598
|
-
if (toolName !== "Edit" && toolName !== "Write" || !
|
|
43774
|
+
if (toolName !== "Edit" && toolName !== "Write" || !isRecord5(value))
|
|
43599
43775
|
return null;
|
|
43600
43776
|
if (!validNativePath(value.filePath) || !Array.isArray(value.structuredPatch))
|
|
43601
43777
|
return null;
|
|
@@ -43611,10 +43787,10 @@ function parseClaudeNativeFileChange(toolName, value) {
|
|
|
43611
43787
|
};
|
|
43612
43788
|
}
|
|
43613
43789
|
function displayPath(nativePath, cwd) {
|
|
43614
|
-
const resolvedCwd =
|
|
43615
|
-
const resolvedPath =
|
|
43616
|
-
const relative =
|
|
43617
|
-
const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${
|
|
43790
|
+
const resolvedCwd = path9.resolve(cwd);
|
|
43791
|
+
const resolvedPath = path9.isAbsolute(nativePath) ? path9.resolve(nativePath) : path9.resolve(cwd, nativePath);
|
|
43792
|
+
const relative = path9.relative(resolvedCwd, resolvedPath);
|
|
43793
|
+
const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path9.sep}`) ? relative : resolvedPath;
|
|
43618
43794
|
const normalized = selected.replaceAll("\\", "/");
|
|
43619
43795
|
return validNativePath(normalized) && normalized !== "." ? normalized : null;
|
|
43620
43796
|
}
|
|
@@ -43626,7 +43802,7 @@ function projectClaudeFileChange(value, cwd) {
|
|
|
43626
43802
|
`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
|
|
43627
43803
|
...hunk.lines
|
|
43628
43804
|
]);
|
|
43629
|
-
const absoluteDisplayPath =
|
|
43805
|
+
const absoluteDisplayPath = path9.posix.isAbsolute(normalizedPath);
|
|
43630
43806
|
const oldHeader = value.kind === "add" ? "/dev/null" : absoluteDisplayPath ? normalizedPath : `a/${normalizedPath}`;
|
|
43631
43807
|
const newHeader = absoluteDisplayPath ? normalizedPath : `b/${normalizedPath}`;
|
|
43632
43808
|
const unifiedDiff = [`--- ${oldHeader}`, `+++ ${newHeader}`, ...body, ""].join("\n");
|
|
@@ -43639,7 +43815,7 @@ var AUTHENTICATION_ERRORS = /* @__PURE__ */ new Set(["authentication_failed", "o
|
|
|
43639
43815
|
var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task", "SendMessage"]);
|
|
43640
43816
|
var SUBAGENT_DESCRIPTION_LIMIT = 500;
|
|
43641
43817
|
var SUBAGENT_SUMMARY_LIMIT = 2e3;
|
|
43642
|
-
function
|
|
43818
|
+
function isRecord6(value) {
|
|
43643
43819
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43644
43820
|
}
|
|
43645
43821
|
function nativeUuid(message) {
|
|
@@ -43649,12 +43825,12 @@ function parentToolUseId(message) {
|
|
|
43649
43825
|
return typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0 ? message.parent_tool_use_id : null;
|
|
43650
43826
|
}
|
|
43651
43827
|
function assistantNativeMessageId(message) {
|
|
43652
|
-
if (!
|
|
43828
|
+
if (!isRecord6(message.message))
|
|
43653
43829
|
return null;
|
|
43654
43830
|
return typeof message.message.id === "string" && message.message.id.length > 0 ? message.message.id : null;
|
|
43655
43831
|
}
|
|
43656
43832
|
function assistantContent(message) {
|
|
43657
|
-
if (message.type !== "assistant" || !
|
|
43833
|
+
if (message.type !== "assistant" || !isRecord6(message.message))
|
|
43658
43834
|
return null;
|
|
43659
43835
|
return Array.isArray(message.message.content) ? message.message.content : null;
|
|
43660
43836
|
}
|
|
@@ -43662,10 +43838,10 @@ function assistantText(message) {
|
|
|
43662
43838
|
const content = assistantContent(message);
|
|
43663
43839
|
if (!content)
|
|
43664
43840
|
return null;
|
|
43665
|
-
return content.flatMap((block) =>
|
|
43841
|
+
return content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
43666
43842
|
}
|
|
43667
43843
|
function assistantError(message) {
|
|
43668
|
-
return
|
|
43844
|
+
return isRecord6(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
|
|
43669
43845
|
}
|
|
43670
43846
|
function boundedString(value, limit) {
|
|
43671
43847
|
if (typeof value !== "string")
|
|
@@ -43676,25 +43852,25 @@ function boundedString(value, limit) {
|
|
|
43676
43852
|
return trimmed.slice(0, limit);
|
|
43677
43853
|
}
|
|
43678
43854
|
function subagentDescription(argumentsValue, toolName) {
|
|
43679
|
-
if (!
|
|
43855
|
+
if (!isRecord6(argumentsValue))
|
|
43680
43856
|
return `${toolName} delegation`;
|
|
43681
43857
|
return boundedString(argumentsValue.description, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.summary, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.name, SUBAGENT_DESCRIPTION_LIMIT) ?? `${toolName} delegation`;
|
|
43682
43858
|
}
|
|
43683
43859
|
function subagentPrompt2(argumentsValue) {
|
|
43684
|
-
if (!
|
|
43860
|
+
if (!isRecord6(argumentsValue))
|
|
43685
43861
|
return void 0;
|
|
43686
43862
|
return boundedString(argumentsValue.prompt ?? argumentsValue.message, SUBAGENT_SUMMARY_LIMIT);
|
|
43687
43863
|
}
|
|
43688
43864
|
function subagentRole(argumentsValue) {
|
|
43689
|
-
if (!
|
|
43865
|
+
if (!isRecord6(argumentsValue))
|
|
43690
43866
|
return void 0;
|
|
43691
43867
|
return boundedString(argumentsValue.subagent_type ?? argumentsValue.agent_type, SUBAGENT_DESCRIPTION_LIMIT);
|
|
43692
43868
|
}
|
|
43693
43869
|
function subagentBackground(argumentsValue) {
|
|
43694
|
-
return
|
|
43870
|
+
return isRecord6(argumentsValue) && argumentsValue.run_in_background === true;
|
|
43695
43871
|
}
|
|
43696
43872
|
function targetedSubagentId(argumentsValue) {
|
|
43697
|
-
if (!
|
|
43873
|
+
if (!isRecord6(argumentsValue))
|
|
43698
43874
|
return void 0;
|
|
43699
43875
|
return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
|
|
43700
43876
|
}
|
|
@@ -43714,11 +43890,11 @@ function finiteNonNegativeNumber(value) {
|
|
|
43714
43890
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
43715
43891
|
}
|
|
43716
43892
|
function parseResultModelUsage(value) {
|
|
43717
|
-
if (!
|
|
43893
|
+
if (!isRecord6(value))
|
|
43718
43894
|
return void 0;
|
|
43719
43895
|
const usage = [];
|
|
43720
43896
|
for (const entry of Object.values(value)) {
|
|
43721
|
-
if (!
|
|
43897
|
+
if (!isRecord6(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
|
|
43722
43898
|
return void 0;
|
|
43723
43899
|
}
|
|
43724
43900
|
usage.push({ inputTokens: entry.inputTokens, outputTokens: entry.outputTokens });
|
|
@@ -43726,7 +43902,7 @@ function parseResultModelUsage(value) {
|
|
|
43726
43902
|
return usage;
|
|
43727
43903
|
}
|
|
43728
43904
|
function parseLastRequestUsage(value, attribution = {}) {
|
|
43729
|
-
if (!
|
|
43905
|
+
if (!isRecord6(value))
|
|
43730
43906
|
return void 0;
|
|
43731
43907
|
const inputTokens = value.input_tokens;
|
|
43732
43908
|
const outputTokens = value.output_tokens;
|
|
@@ -43749,7 +43925,7 @@ function parseLastRequestUsage(value, attribution = {}) {
|
|
|
43749
43925
|
};
|
|
43750
43926
|
}
|
|
43751
43927
|
function assistantRequestUsage(message, provider) {
|
|
43752
|
-
if (!
|
|
43928
|
+
if (!isRecord6(message.message))
|
|
43753
43929
|
return void 0;
|
|
43754
43930
|
return parseLastRequestUsage(message.message.usage, {
|
|
43755
43931
|
requestId: message.message.id ?? message.request_id,
|
|
@@ -43772,7 +43948,7 @@ function parseResultUsageEvent(message) {
|
|
|
43772
43948
|
};
|
|
43773
43949
|
}
|
|
43774
43950
|
function parsePlanLimitWindow(value) {
|
|
43775
|
-
if (!
|
|
43951
|
+
if (!isRecord6(value))
|
|
43776
43952
|
return void 0;
|
|
43777
43953
|
const utilization = value.utilization;
|
|
43778
43954
|
if (typeof utilization !== "number" || !Number.isFinite(utilization) || utilization < 0) {
|
|
@@ -43784,12 +43960,12 @@ function parsePlanLimitWindow(value) {
|
|
|
43784
43960
|
return { utilizationPercent, ...resetsAtUnix !== void 0 ? { resetsAtUnix } : {} };
|
|
43785
43961
|
}
|
|
43786
43962
|
function parseClaudePlanLimitEvent(message) {
|
|
43787
|
-
if (!
|
|
43963
|
+
if (!isRecord6(message) || message.type !== "rate_limit_event")
|
|
43788
43964
|
return null;
|
|
43789
43965
|
const info = message.rate_limit_info;
|
|
43790
|
-
if (!
|
|
43966
|
+
if (!isRecord6(info))
|
|
43791
43967
|
return null;
|
|
43792
|
-
const windows =
|
|
43968
|
+
const windows = isRecord6(info.unifiedWindows) ? info.unifiedWindows : void 0;
|
|
43793
43969
|
let fiveHour = parsePlanLimitWindow(windows?.five_hour);
|
|
43794
43970
|
let sevenDay = parsePlanLimitWindow(windows?.seven_day);
|
|
43795
43971
|
if (!fiveHour && !sevenDay) {
|
|
@@ -43807,7 +43983,7 @@ function parseClaudePlanLimitEvent(message) {
|
|
|
43807
43983
|
};
|
|
43808
43984
|
}
|
|
43809
43985
|
function nativeSubagentId(nativeResult, outputText) {
|
|
43810
|
-
if (
|
|
43986
|
+
if (isRecord6(nativeResult)) {
|
|
43811
43987
|
const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
43812
43988
|
if (structured)
|
|
43813
43989
|
return structured;
|
|
@@ -43815,7 +43991,7 @@ function nativeSubagentId(nativeResult, outputText) {
|
|
|
43815
43991
|
return boundedString(/agentId:\s*([A-Za-z0-9_-]+)/u.exec(outputText ?? "")?.[1], SUBAGENT_DESCRIPTION_LIMIT);
|
|
43816
43992
|
}
|
|
43817
43993
|
function subagentContinuesInBackground(nativeResult, outputText) {
|
|
43818
|
-
if (
|
|
43994
|
+
if (isRecord6(nativeResult)) {
|
|
43819
43995
|
if (nativeResult.isAsync === true || nativeResult.is_async === true)
|
|
43820
43996
|
return true;
|
|
43821
43997
|
if (nativeResult.status === "async_launched")
|
|
@@ -43828,11 +44004,11 @@ function resultText(content, nativeResult) {
|
|
|
43828
44004
|
if (typeof content === "string") {
|
|
43829
44005
|
text = content;
|
|
43830
44006
|
} else if (Array.isArray(content)) {
|
|
43831
|
-
text = content.flatMap((block) =>
|
|
44007
|
+
text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
43832
44008
|
}
|
|
43833
44009
|
if (text.length > 0)
|
|
43834
44010
|
return text;
|
|
43835
|
-
if (!
|
|
44011
|
+
if (!isRecord6(nativeResult))
|
|
43836
44012
|
return void 0;
|
|
43837
44013
|
const stdout = typeof nativeResult.stdout === "string" ? nativeResult.stdout : "";
|
|
43838
44014
|
const stderr = typeof nativeResult.stderr === "string" ? nativeResult.stderr : "";
|
|
@@ -43844,13 +44020,13 @@ function userMessageText(content) {
|
|
|
43844
44020
|
return content;
|
|
43845
44021
|
if (!Array.isArray(content))
|
|
43846
44022
|
return null;
|
|
43847
|
-
const text = content.flatMap((block) =>
|
|
44023
|
+
const text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
43848
44024
|
return text.length > 0 ? text : null;
|
|
43849
44025
|
}
|
|
43850
44026
|
function parseClaudeTaskNotification(message) {
|
|
43851
|
-
if (!
|
|
44027
|
+
if (!isRecord6(message) || message.type !== "user" || !isRecord6(message.message))
|
|
43852
44028
|
return null;
|
|
43853
|
-
if (
|
|
44029
|
+
if (isRecord6(message.origin) && message.origin.kind !== "task-notification")
|
|
43854
44030
|
return null;
|
|
43855
44031
|
const content = userMessageText(message.message.content);
|
|
43856
44032
|
if (!content || !content.includes("<task-notification>"))
|
|
@@ -43909,7 +44085,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
43909
44085
|
this.#cancelRequested = true;
|
|
43910
44086
|
}
|
|
43911
44087
|
consume(message) {
|
|
43912
|
-
if (this.#completed || !
|
|
44088
|
+
if (this.#completed || !isRecord6(message))
|
|
43913
44089
|
return { events: [] };
|
|
43914
44090
|
const events = [];
|
|
43915
44091
|
this.#consumeSegmentLevel(message, events);
|
|
@@ -43923,7 +44099,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
43923
44099
|
this.#consumeCompaction(message, events);
|
|
43924
44100
|
this.#consumeLocalCommandOutput(message, events);
|
|
43925
44101
|
}
|
|
43926
|
-
if (message.type === "stream_event" &&
|
|
44102
|
+
if (message.type === "stream_event" && isRecord6(message.event)) {
|
|
43927
44103
|
if (!nested)
|
|
43928
44104
|
this.#consumeStreamEvent(message, events);
|
|
43929
44105
|
} else if (message.type === "tool_progress") {
|
|
@@ -44030,7 +44206,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44030
44206
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
44031
44207
|
return;
|
|
44032
44208
|
const nativeSubagentIds = message.tasks.flatMap((task) => {
|
|
44033
|
-
if (!
|
|
44209
|
+
if (!isRecord6(task))
|
|
44034
44210
|
return [];
|
|
44035
44211
|
const taskId = boundedString(task.task_id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
44036
44212
|
return taskId ? [taskId] : [];
|
|
@@ -44090,7 +44266,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44090
44266
|
});
|
|
44091
44267
|
return;
|
|
44092
44268
|
}
|
|
44093
|
-
if (message.subtype === "task_updated" &&
|
|
44269
|
+
if (message.subtype === "task_updated" && isRecord6(message.patch)) {
|
|
44094
44270
|
const status = taskStatus(message.patch.status);
|
|
44095
44271
|
if (!status)
|
|
44096
44272
|
return;
|
|
@@ -44109,14 +44285,14 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44109
44285
|
}
|
|
44110
44286
|
#consumeStreamEvent(message, events) {
|
|
44111
44287
|
const event = message.event;
|
|
44112
|
-
if (!
|
|
44288
|
+
if (!isRecord6(event))
|
|
44113
44289
|
return;
|
|
44114
|
-
if (event.type === "message_start" &&
|
|
44290
|
+
if (event.type === "message_start" && isRecord6(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
|
|
44115
44291
|
this.#activeRootStreamMessageId = event.message.id;
|
|
44116
44292
|
this.#messageState(event.message.id);
|
|
44117
44293
|
return;
|
|
44118
44294
|
}
|
|
44119
|
-
if (event.type !== "content_block_delta" || !
|
|
44295
|
+
if (event.type !== "content_block_delta" || !isRecord6(event.delta))
|
|
44120
44296
|
return;
|
|
44121
44297
|
const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
|
|
44122
44298
|
if (!this.#activeRootStreamMessageId)
|
|
@@ -44192,7 +44368,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44192
44368
|
}
|
|
44193
44369
|
#consumeToolUseBlocks(message, events, ignoreKnownIds) {
|
|
44194
44370
|
for (const block of assistantContent(message) ?? []) {
|
|
44195
|
-
if (!
|
|
44371
|
+
if (!isRecord6(block) || block.type !== "tool_use")
|
|
44196
44372
|
continue;
|
|
44197
44373
|
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
44198
44374
|
if (typeof block.id !== "string" || block.id.length === 0 || typeof block.name !== "string" || block.name.length === 0 || !argumentsResult.success) {
|
|
@@ -44244,9 +44420,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44244
44420
|
events.push(settled);
|
|
44245
44421
|
}
|
|
44246
44422
|
#consumeToolResults(message, events, ignoreUnknown) {
|
|
44247
|
-
if (!
|
|
44423
|
+
if (!isRecord6(message.message) || !Array.isArray(message.message.content))
|
|
44248
44424
|
return;
|
|
44249
|
-
const resultBlocks = message.message.content.filter((block) =>
|
|
44425
|
+
const resultBlocks = message.message.content.filter((block) => isRecord6(block) && block.type === "tool_result");
|
|
44250
44426
|
if (resultBlocks.length === 0)
|
|
44251
44427
|
return;
|
|
44252
44428
|
if (resultBlocks.length > 1 && message.tool_use_result !== void 0) {
|
|
@@ -44315,7 +44491,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
44315
44491
|
|
|
44316
44492
|
// dist/process-fence.js
|
|
44317
44493
|
import { execFile } from "node:child_process";
|
|
44318
|
-
import
|
|
44494
|
+
import path10 from "node:path";
|
|
44319
44495
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
44320
44496
|
import { promisify } from "node:util";
|
|
44321
44497
|
var executeFile = promisify(execFile);
|
|
@@ -44339,9 +44515,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
|
|
|
44339
44515
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
44340
44516
|
throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
|
|
44341
44517
|
const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
|
|
44342
|
-
if (!root || !
|
|
44518
|
+
if (!root || !path10.win32.isAbsolute(root))
|
|
44343
44519
|
throw new Error("Windows SystemRoot is unavailable");
|
|
44344
|
-
await executeFile(
|
|
44520
|
+
await executeFile(path10.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
|
|
44345
44521
|
timeout: timeoutMs,
|
|
44346
44522
|
windowsHide: true
|
|
44347
44523
|
});
|
|
@@ -44368,6 +44544,7 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
|
|
|
44368
44544
|
|
|
44369
44545
|
// dist/sdk-transport.js
|
|
44370
44546
|
var CLIENT_APP = "codexhost-claude-code-adapter/0.0.0";
|
|
44547
|
+
var SESSION_ENTRYPOINT = "codexhost-sdk";
|
|
44371
44548
|
var APPROVAL_TITLE_MAX_LENGTH = 120;
|
|
44372
44549
|
var APPROVAL_DESCRIPTION_MAX_LENGTH = 500;
|
|
44373
44550
|
var DEFAULT_ABORT_TIMEOUT_MS = 2e3;
|
|
@@ -44427,17 +44604,17 @@ function allowsDangerouslySkipPermissions(getuid = process.getuid) {
|
|
|
44427
44604
|
function processExited(child) {
|
|
44428
44605
|
return child.exitCode !== null || child.signalCode !== null;
|
|
44429
44606
|
}
|
|
44430
|
-
function
|
|
44607
|
+
function isRecord7(value) {
|
|
44431
44608
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44432
44609
|
}
|
|
44433
44610
|
function permissionModeFromMessage(value) {
|
|
44434
|
-
if (!
|
|
44611
|
+
if (!isRecord7(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
|
|
44435
44612
|
return void 0;
|
|
44436
44613
|
}
|
|
44437
44614
|
return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
|
|
44438
44615
|
}
|
|
44439
44616
|
function parseContextUsage(value) {
|
|
44440
|
-
if (!
|
|
44617
|
+
if (!isRecord7(value))
|
|
44441
44618
|
throw new Error("Claude SDK context Usage is invalid");
|
|
44442
44619
|
const usedTokens = value.totalTokens;
|
|
44443
44620
|
const maxTokens = value.maxTokens;
|
|
@@ -44454,7 +44631,7 @@ function parseQuestions(input) {
|
|
|
44454
44631
|
const questions = [];
|
|
44455
44632
|
const questionTexts = /* @__PURE__ */ new Set();
|
|
44456
44633
|
for (const value of input.questions) {
|
|
44457
|
-
if (!
|
|
44634
|
+
if (!isRecord7(value))
|
|
44458
44635
|
return null;
|
|
44459
44636
|
const question = value.question;
|
|
44460
44637
|
const header = value.header;
|
|
@@ -44465,7 +44642,7 @@ function parseQuestions(input) {
|
|
|
44465
44642
|
const labels = /* @__PURE__ */ new Set();
|
|
44466
44643
|
const options = [];
|
|
44467
44644
|
for (const option2 of value.options) {
|
|
44468
|
-
if (!
|
|
44645
|
+
if (!isRecord7(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
|
|
44469
44646
|
return null;
|
|
44470
44647
|
}
|
|
44471
44648
|
labels.add(option2.label);
|
|
@@ -44507,7 +44684,7 @@ function permissionUpdateDestination(value) {
|
|
|
44507
44684
|
return void 0;
|
|
44508
44685
|
}
|
|
44509
44686
|
function isPermissionUpdate(value) {
|
|
44510
|
-
if (!
|
|
44687
|
+
if (!isRecord7(value) || !permissionUpdateDestination(value.destination))
|
|
44511
44688
|
return false;
|
|
44512
44689
|
if (value.type === "setMode") {
|
|
44513
44690
|
return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
|
|
@@ -44516,7 +44693,7 @@ function isPermissionUpdate(value) {
|
|
|
44516
44693
|
return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
|
|
44517
44694
|
}
|
|
44518
44695
|
if (value.type === "addRules" || value.type === "replaceRules" || value.type === "removeRules") {
|
|
44519
|
-
return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) =>
|
|
44696
|
+
return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord7(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
|
|
44520
44697
|
}
|
|
44521
44698
|
return false;
|
|
44522
44699
|
}
|
|
@@ -44661,6 +44838,7 @@ var ClaudeSdkTransport = class {
|
|
|
44661
44838
|
forwardSubagentText: true,
|
|
44662
44839
|
env: withNodeRuntimeOnPath({
|
|
44663
44840
|
...this.#environment,
|
|
44841
|
+
CLAUDE_CODE_ENTRYPOINT: SESSION_ENTRYPOINT,
|
|
44664
44842
|
CLAUDE_AGENT_SDK_CLIENT_APP: CLIENT_APP
|
|
44665
44843
|
}),
|
|
44666
44844
|
spawnClaudeCodeProcess: (options) => this.#spawn(options)
|
|
@@ -44954,10 +45132,10 @@ var ClaudeSdkTransport = class {
|
|
|
44954
45132
|
}
|
|
44955
45133
|
}
|
|
44956
45134
|
#observeBackgroundTasks(message) {
|
|
44957
|
-
if (!
|
|
45135
|
+
if (!isRecord7(message) || message.type !== "system")
|
|
44958
45136
|
return;
|
|
44959
45137
|
if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
|
|
44960
|
-
this.#backgroundTasks = new Set(message.tasks.flatMap((task) =>
|
|
45138
|
+
this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord7(task) && typeof task.task_id === "string" ? [task.task_id] : []));
|
|
44961
45139
|
} else if (message.subtype === "task_started" && typeof message.task_id === "string") {
|
|
44962
45140
|
this.#backgroundTasks.add(message.task_id);
|
|
44963
45141
|
} else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
|
|
@@ -45006,7 +45184,7 @@ var ClaudeSdkTransport = class {
|
|
|
45006
45184
|
events: [],
|
|
45007
45185
|
nativeTurnKey: null
|
|
45008
45186
|
});
|
|
45009
|
-
if (autonomous.nativeTurnKey === null &&
|
|
45187
|
+
if (autonomous.nativeTurnKey === null && isRecord7(message) && message.type === "user" && (message.parent_tool_use_id === null || message.parent_tool_use_id === void 0) && typeof message.uuid === "string" && message.uuid.length > 0) {
|
|
45010
45188
|
autonomous.nativeTurnKey = message.uuid;
|
|
45011
45189
|
}
|
|
45012
45190
|
const interpreted = autonomous.accumulator.consume(message);
|
|
@@ -45348,11 +45526,11 @@ var ClaudeSubagentLifecycle = class {
|
|
|
45348
45526
|
};
|
|
45349
45527
|
|
|
45350
45528
|
// dist/task-tracker.js
|
|
45351
|
-
function
|
|
45529
|
+
function isRecord8(value) {
|
|
45352
45530
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45353
45531
|
}
|
|
45354
45532
|
function stringField(value, keys) {
|
|
45355
|
-
if (!
|
|
45533
|
+
if (!isRecord8(value))
|
|
45356
45534
|
return void 0;
|
|
45357
45535
|
for (const key of keys) {
|
|
45358
45536
|
const field = value[key];
|
|
@@ -45387,7 +45565,7 @@ var ClaudeTaskTracker = class {
|
|
|
45387
45565
|
};
|
|
45388
45566
|
}
|
|
45389
45567
|
#create(args, result) {
|
|
45390
|
-
if (!
|
|
45568
|
+
if (!isRecord8(result) || !isRecord8(result.task))
|
|
45391
45569
|
return;
|
|
45392
45570
|
const id = stringField(result.task, ["id"]);
|
|
45393
45571
|
const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
|
|
@@ -45405,7 +45583,7 @@ var ClaudeTaskTracker = class {
|
|
|
45405
45583
|
const id = stringField(args, ["taskId", "id", "task_id"]);
|
|
45406
45584
|
if (!id)
|
|
45407
45585
|
return;
|
|
45408
|
-
const status =
|
|
45586
|
+
const status = isRecord8(args) ? taskStatus2(args.status) : void 0;
|
|
45409
45587
|
if (status === "deleted") {
|
|
45410
45588
|
this.#tasks.delete(id);
|
|
45411
45589
|
return;
|
|
@@ -45423,13 +45601,13 @@ var ClaudeTaskTracker = class {
|
|
|
45423
45601
|
});
|
|
45424
45602
|
}
|
|
45425
45603
|
#replace(result) {
|
|
45426
|
-
if (!
|
|
45604
|
+
if (!isRecord8(result) || !Array.isArray(result.tasks))
|
|
45427
45605
|
return;
|
|
45428
45606
|
const next = /* @__PURE__ */ new Map();
|
|
45429
45607
|
for (const value of result.tasks) {
|
|
45430
45608
|
const id = stringField(value, ["id"]);
|
|
45431
45609
|
const subject = stringField(value, ["subject"]);
|
|
45432
|
-
const status =
|
|
45610
|
+
const status = isRecord8(value) ? taskStatus2(value.status) : void 0;
|
|
45433
45611
|
if (!id || !subject || !status || status === "deleted")
|
|
45434
45612
|
continue;
|
|
45435
45613
|
const existing = this.#tasks.get(id);
|
|
@@ -45447,11 +45625,11 @@ var ClaudeTaskTracker = class {
|
|
|
45447
45625
|
};
|
|
45448
45626
|
|
|
45449
45627
|
// dist/tool-lifecycle.js
|
|
45450
|
-
function
|
|
45628
|
+
function isRecord9(value) {
|
|
45451
45629
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45452
45630
|
}
|
|
45453
45631
|
function stringField2(value, key) {
|
|
45454
|
-
return
|
|
45632
|
+
return isRecord9(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
45455
45633
|
}
|
|
45456
45634
|
function toolFailure(toolName) {
|
|
45457
45635
|
return {
|
|
@@ -45552,6 +45730,7 @@ var ClaudeToolLifecycle = class {
|
|
|
45552
45730
|
const fileItem = {
|
|
45553
45731
|
type: "fileChange",
|
|
45554
45732
|
itemId: this.#newItemId(),
|
|
45733
|
+
sourceItemIds: [tool.item.itemId],
|
|
45555
45734
|
changes: [change]
|
|
45556
45735
|
};
|
|
45557
45736
|
this.#emit({ type: "item.started", turnId, item: fileItem });
|
|
@@ -45698,7 +45877,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
|
|
|
45698
45877
|
var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
|
|
45699
45878
|
var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
|
|
45700
45879
|
var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
|
|
45701
|
-
function
|
|
45880
|
+
function isRecord10(value) {
|
|
45702
45881
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45703
45882
|
}
|
|
45704
45883
|
function safeNonNegativeInteger2(value) {
|
|
@@ -45707,7 +45886,7 @@ function safeNonNegativeInteger2(value) {
|
|
|
45707
45886
|
function transcriptRequestUsage(messages, messageId) {
|
|
45708
45887
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
45709
45888
|
const entry = messages[index];
|
|
45710
|
-
if (!
|
|
45889
|
+
if (!isRecord10(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord10(entry.message) || entry.message.id !== messageId || !isRecord10(entry.message.usage)) {
|
|
45711
45890
|
continue;
|
|
45712
45891
|
}
|
|
45713
45892
|
const inputTokens = entry.message.usage.input_tokens;
|
|
@@ -45959,7 +46138,7 @@ var ClaudeHarnessSession = class {
|
|
|
45959
46138
|
cwd: this.#cwd,
|
|
45960
46139
|
sessionId: this.#sessionId
|
|
45961
46140
|
});
|
|
45962
|
-
const ids = new Set(messages.flatMap((message) =>
|
|
46141
|
+
const ids = new Set(messages.flatMap((message) => isRecord10(message) && typeof message.uuid === "string" ? [message.uuid] : []));
|
|
45963
46142
|
if (this.#unpersistedMessageIds.every((id) => ids.has(id))) {
|
|
45964
46143
|
this.#unpersistedMessageIds = [];
|
|
45965
46144
|
break;
|
|
@@ -46272,7 +46451,7 @@ var ClaudeHarnessSession = class {
|
|
|
46272
46451
|
return this.#closePromise;
|
|
46273
46452
|
}
|
|
46274
46453
|
async #selectModel(command) {
|
|
46275
|
-
if (this.#acceptingTurn || this.#
|
|
46454
|
+
if (this.#acceptingTurn || this.#configurationTask || this.#readingHistory) {
|
|
46276
46455
|
return {
|
|
46277
46456
|
ok: false,
|
|
46278
46457
|
error: {
|
|
@@ -46330,7 +46509,7 @@ var ClaudeHarnessSession = class {
|
|
|
46330
46509
|
}
|
|
46331
46510
|
}
|
|
46332
46511
|
async #selectThinking(command) {
|
|
46333
|
-
if (this.#acceptingTurn || this.#
|
|
46512
|
+
if (this.#acceptingTurn || this.#configurationTask || this.#readingHistory) {
|
|
46334
46513
|
return {
|
|
46335
46514
|
ok: false,
|
|
46336
46515
|
error: {
|
|
@@ -47552,6 +47731,25 @@ var ClaudeHarnessSession = class {
|
|
|
47552
47731
|
var ClaudeCodeAdapter = class {
|
|
47553
47732
|
commandCatalog = claudeCommandCatalog;
|
|
47554
47733
|
harnessId = claudeCodeHarnessId2;
|
|
47734
|
+
sessionImport = Object.freeze({
|
|
47735
|
+
listCandidates: async () => {
|
|
47736
|
+
const result = await this.#readImport((signal) => this.#importIndex.list(signal));
|
|
47737
|
+
return result.ok ? { ok: true, value: result.value.map(({ candidate }) => candidate) } : result;
|
|
47738
|
+
},
|
|
47739
|
+
resolveCandidate: async (nativeSessionId) => {
|
|
47740
|
+
const result = await this.#readImport((signal) => this.#importIndex.resolve(nativeSessionId, signal));
|
|
47741
|
+
if (!result.ok)
|
|
47742
|
+
return result;
|
|
47743
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
47744
|
+
ok: false,
|
|
47745
|
+
error: {
|
|
47746
|
+
code: "sessionNotFound",
|
|
47747
|
+
message: "Claude Code Session is no longer importable",
|
|
47748
|
+
retryable: false
|
|
47749
|
+
}
|
|
47750
|
+
};
|
|
47751
|
+
}
|
|
47752
|
+
});
|
|
47555
47753
|
subagents = {
|
|
47556
47754
|
readSnapshot: async (input) => {
|
|
47557
47755
|
if (input.parent.harnessId !== this.harnessId || input.nativeSubagentId.trim().length === 0) {
|
|
@@ -47595,6 +47793,9 @@ var ClaudeCodeAdapter = class {
|
|
|
47595
47793
|
#cancelTimeoutMs;
|
|
47596
47794
|
#closeTimeoutMs;
|
|
47597
47795
|
#dependencies;
|
|
47796
|
+
#importAbort = new AbortController();
|
|
47797
|
+
#importIndex;
|
|
47798
|
+
#importRequests = /* @__PURE__ */ new Set();
|
|
47598
47799
|
#pendingSessions;
|
|
47599
47800
|
#toolOutputLimit;
|
|
47600
47801
|
#continuationQuiescenceMs;
|
|
@@ -47606,7 +47807,9 @@ var ClaudeCodeAdapter = class {
|
|
|
47606
47807
|
#latestPlanLimit = null;
|
|
47607
47808
|
#accountInspection = null;
|
|
47608
47809
|
constructor(options = {}, dependencies) {
|
|
47609
|
-
|
|
47810
|
+
const environment = options.environment ?? process.env;
|
|
47811
|
+
this.#importIndex = new ClaudeSessionImportIndex(environment);
|
|
47812
|
+
this.#pendingSessions = new ClaudePendingSessions(environment);
|
|
47610
47813
|
this.#closeTimeoutMs = options.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
47611
47814
|
this.#cancelTimeoutMs = options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS;
|
|
47612
47815
|
if (!Number.isSafeInteger(this.#cancelTimeoutMs) || this.#cancelTimeoutMs <= 0) {
|
|
@@ -47660,6 +47863,24 @@ var ClaudeCodeAdapter = class {
|
|
|
47660
47863
|
readSubagentMessages: ({ cwd, sessionId, nativeSubagentId: nativeSubagentId2 }) => jkt(sessionId, nativeSubagentId2, { dir: cwd })
|
|
47661
47864
|
};
|
|
47662
47865
|
}
|
|
47866
|
+
#readImport(operation) {
|
|
47867
|
+
if (this.#importAbort.signal.aborted) {
|
|
47868
|
+
return Promise.resolve({
|
|
47869
|
+
ok: false,
|
|
47870
|
+
error: invalidState("Claude Code Adapter is closed")
|
|
47871
|
+
});
|
|
47872
|
+
}
|
|
47873
|
+
const request = operation(this.#importAbort.signal).then((value) => ({ ok: true, value })).catch(() => ({
|
|
47874
|
+
ok: false,
|
|
47875
|
+
error: {
|
|
47876
|
+
code: "unavailable",
|
|
47877
|
+
message: "Claude Code Session discovery failed; check storage access and duplicate Session identities, then retry after closing native clients",
|
|
47878
|
+
retryable: true
|
|
47879
|
+
}
|
|
47880
|
+
})).finally(() => this.#importRequests.delete(request));
|
|
47881
|
+
this.#importRequests.add(request);
|
|
47882
|
+
return request;
|
|
47883
|
+
}
|
|
47663
47884
|
async inspect(input = {}) {
|
|
47664
47885
|
if (this.#closePromise) {
|
|
47665
47886
|
return {
|
|
@@ -47667,7 +47888,7 @@ var ClaudeCodeAdapter = class {
|
|
|
47667
47888
|
error: invalidState("Claude Code Adapter is closing")
|
|
47668
47889
|
};
|
|
47669
47890
|
}
|
|
47670
|
-
const cwd =
|
|
47891
|
+
const cwd = path11.resolve(input.cwd ?? process.cwd());
|
|
47671
47892
|
if (!input.refresh) {
|
|
47672
47893
|
const cached2 = this.#inspectionCache.get(cwd);
|
|
47673
47894
|
if (cached2)
|
|
@@ -47848,7 +48069,7 @@ var ClaudeCodeAdapter = class {
|
|
|
47848
48069
|
}
|
|
47849
48070
|
};
|
|
47850
48071
|
}
|
|
47851
|
-
const cwd =
|
|
48072
|
+
const cwd = path11.resolve(input.cwd);
|
|
47852
48073
|
if (input.kind === "rollbackLastTurn") {
|
|
47853
48074
|
for (const source of this.#sessions) {
|
|
47854
48075
|
const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
|
|
@@ -47957,8 +48178,10 @@ var ClaudeCodeAdapter = class {
|
|
|
47957
48178
|
}
|
|
47958
48179
|
close() {
|
|
47959
48180
|
if (!this.#closePromise) {
|
|
48181
|
+
this.#importAbort.abort();
|
|
47960
48182
|
this.#inspectionCache.clear();
|
|
47961
48183
|
this.#closePromise = Promise.all([
|
|
48184
|
+
...this.#importRequests,
|
|
47962
48185
|
...[...this.#inspectors].map((inspector) => inspector.close()),
|
|
47963
48186
|
...[...this.#sessions].map((session) => session.close()),
|
|
47964
48187
|
...this.#inspectionInFlight.values()
|
|
@@ -47969,8 +48192,8 @@ var ClaudeCodeAdapter = class {
|
|
|
47969
48192
|
};
|
|
47970
48193
|
|
|
47971
48194
|
// dist/user-shell-environment.js
|
|
47972
|
-
import
|
|
47973
|
-
import {
|
|
48195
|
+
import path12 from "node:path";
|
|
48196
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
47974
48197
|
var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
|
|
47975
48198
|
var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
|
|
47976
48199
|
var SHELL_ENVIRONMENT_TIMEOUT_MS = 3e3;
|
|
@@ -48007,24 +48230,27 @@ function mergeMissingEnvironment(environment, shellEnvironment) {
|
|
|
48007
48230
|
}
|
|
48008
48231
|
return merged;
|
|
48009
48232
|
}
|
|
48010
|
-
function withUserShellEnvironment(environment, dependencies) {
|
|
48233
|
+
async function withUserShellEnvironment(environment, dependencies) {
|
|
48011
48234
|
const platform = dependencies?.platform ?? process.platform;
|
|
48012
48235
|
if (platform === "win32" || !environment.HOME)
|
|
48013
48236
|
return environment;
|
|
48014
48237
|
const shell = environment.SHELL?.trim() || defaultShell(platform);
|
|
48015
|
-
if (!shell || !SUPPORTED_SHELLS.has(
|
|
48238
|
+
if (!shell || !SUPPORTED_SHELLS.has(path12.basename(shell)))
|
|
48016
48239
|
return environment;
|
|
48017
48240
|
const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
|
|
48018
48241
|
const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);
|
|
48019
48242
|
if (cached2)
|
|
48020
48243
|
return mergeMissingEnvironment(environment, cached2);
|
|
48021
|
-
const run = dependencies?.run ?? ((command, arguments_, options) =>
|
|
48022
|
-
|
|
48023
|
-
|
|
48024
|
-
|
|
48244
|
+
const run = dependencies?.run ?? ((command, arguments_, options) => new Promise((resolve2) => {
|
|
48245
|
+
const child = execFile2(command, arguments_, {
|
|
48246
|
+
...options,
|
|
48247
|
+
encoding: "buffer",
|
|
48248
|
+
killSignal: "SIGKILL"
|
|
48249
|
+
}, (error52, stdout) => resolve2({ status: error52 ? 1 : 0, stdout }));
|
|
48250
|
+
child.stdin?.end();
|
|
48025
48251
|
}));
|
|
48026
48252
|
try {
|
|
48027
|
-
const result = run(shell, ["-ilc", ENVIRONMENT_COMMAND], {
|
|
48253
|
+
const result = await run(shell, ["-ilc", ENVIRONMENT_COMMAND], {
|
|
48028
48254
|
env: environment,
|
|
48029
48255
|
maxBuffer: SHELL_ENVIRONMENT_MAX_BYTES,
|
|
48030
48256
|
timeout: SHELL_ENVIRONMENT_TIMEOUT_MS,
|
|
@@ -48043,8 +48269,8 @@ function withUserShellEnvironment(environment, dependencies) {
|
|
|
48043
48269
|
|
|
48044
48270
|
// dist/plugin.js
|
|
48045
48271
|
var CLAUDE_CODE_COMMAND_ENV = "CODEXHOST_CLAUDE_COMMAND";
|
|
48046
|
-
function createHarnessAdapter(context) {
|
|
48047
|
-
const environment = withUserShellEnvironment({ ...context.environment });
|
|
48272
|
+
async function createHarnessAdapter(context) {
|
|
48273
|
+
const environment = await withUserShellEnvironment({ ...context.environment });
|
|
48048
48274
|
if (context.platform === "darwin" && context.managedRemoteHost) {
|
|
48049
48275
|
return new BrokeredHarnessAdapter({
|
|
48050
48276
|
commandCatalog: claudeCommandCatalog,
|