@codexhost/cli-linux-arm64 0.7.1 → 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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +16 -0
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/desktop-controller.mjs +185 -47
  5. package/app/host-runtime.mjs +5084 -3890
  6. package/app/plugins/antigravity/plugin.mjs +71 -62
  7. package/app/plugins/claude-code/plugin.mjs +512 -217
  8. package/app/plugins/codebuddy/plugin.mjs +103 -70
  9. package/app/plugins/cursor-cli/plugin.mjs +70 -51
  10. package/app/plugins/deepseek-harness/plugin.mjs +82 -54
  11. package/app/plugins/enabled.json +4 -1
  12. package/app/plugins/grok/plugin.mjs +70 -48
  13. package/app/plugins/hermes/manifest.json +11 -0
  14. package/app/plugins/hermes/plugin.mjs +21680 -0
  15. package/app/plugins/kiro-cli/plugin.mjs +77 -50
  16. package/app/plugins/omp/plugin.mjs +80 -53
  17. package/app/plugins/opencode/plugin.mjs +139 -94
  18. package/app/plugins/pi/plugin.mjs +80 -53
  19. package/app/plugins/qoder/assets/icon.svg +1 -0
  20. package/app/plugins/qoder/manifest.json +12 -0
  21. package/app/plugins/qoder/plugin.mjs +52260 -0
  22. package/app/plugins/qoder-cn/assets/icon.svg +1 -0
  23. package/app/plugins/qoder-cn/manifest.json +12 -0
  24. package/app/plugins/qoder-cn/plugin.mjs +52258 -0
  25. package/app/renderer-extension.js +3389 -1036
  26. package/bin/codexhost +0 -0
  27. package/libexec/codexhost-shim +0 -0
  28. package/libexec/codexhost-updater +0 -0
  29. package/licenses/Qoder-Agent-SDK-LICENSE.txt +7 -0
  30. package/licenses/QoderCN-Agent-SDK-LICENSE.txt +7 -0
  31. package/licenses/opencodex-LICENSE.txt +21 -0
  32. package/licenses/tailwindcss-LICENSE.txt +21 -0
  33. 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, path12) {
780
- if (!path12)
779
+ function getElementAtPath(obj, path13) {
780
+ if (!path13)
781
781
  return obj;
782
- return path12.reduce((acc, key) => acc?.[key], obj);
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(path12, issues) {
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(path12);
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, path12 = []) => {
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 }, [...path12, ...issue2.path]));
1345
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1346
1346
  } else if (issue2.code === "invalid_key") {
1347
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1347
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1348
1348
  } else if (issue2.code === "invalid_element") {
1349
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1349
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1350
1350
  } else {
1351
- const fullpath = [...path12, ...issue2.path];
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, path12 = []) => {
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 }, [...path12, ...issue2.path]));
1382
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1383
1383
  } else if (issue2.code === "invalid_key") {
1384
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1384
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1385
1385
  } else if (issue2.code === "invalid_element") {
1386
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1386
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1387
1387
  } else {
1388
- const fullpath = [...path12, ...issue2.path];
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 path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
- for (const seg of path12) {
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 path12 = ref.slice(1).split("/").filter(Boolean);
14114
- if (path12.length === 0) {
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 (path12[0] === defsKey) {
14119
- const key = path12[1];
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"
@@ -14631,12 +14671,21 @@ var harnessAccountSnapshotSchema = external_exports.object({
14631
14671
  plan: external_exports.string().trim().min(1).max(128).optional(),
14632
14672
  credits: accountCreditsSnapshotSchema
14633
14673
  }).strict();
14634
- var harnessAccountListParamsSchema = external_exports.object({}).strict();
14674
+ var harnessAccountIdentityShape = {
14675
+ harnessId: harnessIdSchema,
14676
+ harnessName: external_exports.string().trim().min(1).max(128)
14677
+ };
14678
+ var harnessAccountSourceSchema = external_exports.object(harnessAccountIdentityShape).strict();
14679
+ var harnessAccountSourceListParamsSchema = external_exports.object({}).strict();
14680
+ var harnessAccountSourceListResultSchema = external_exports.object({ sources: external_exports.array(harnessAccountSourceSchema).max(128) }).strict();
14681
+ var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
14682
+ var harnessAccountInspectResultSchema = external_exports.object({
14683
+ ...harnessAccountIdentityShape,
14684
+ account: harnessAccountSnapshotSchema.nullable()
14685
+ }).strict();
14686
+ var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
14635
14687
  var harnessAccountListResultSchema = external_exports.object({
14636
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend({
14637
- harnessId: harnessIdSchema,
14638
- harnessName: external_exports.string().min(1)
14639
- })).max(128)
14688
+ accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
14640
14689
  }).strict();
14641
14690
 
14642
14691
  // ../../shared-contracts/dist/json-value.js
@@ -14929,7 +14978,6 @@ var threadInspectionParamsSchema = external_exports.object({
14929
14978
  }).strict();
14930
14979
  var codexThreadInspectionSchema = external_exports.object({
14931
14980
  owner: external_exports.literal("codex"),
14932
- accountId: nonBlankTextSchema2.optional(),
14933
14981
  locked: external_exports.literal(true)
14934
14982
  }).strict();
14935
14983
  var externalThreadInspectionSchema = external_exports.object({
@@ -15067,52 +15115,24 @@ var codexAccountSchema = external_exports.object({
15067
15115
  accountId: accountIdSchema,
15068
15116
  label: nonBlankTextSchema3.max(256),
15069
15117
  email: external_exports.string().email().max(320).optional(),
15070
- planType: codexAccountPlanTypeSchema.optional(),
15071
- codexHome: nonBlankTextSchema3.max(16384),
15072
- active: external_exports.boolean(),
15073
- isDefault: external_exports.boolean()
15118
+ planType: codexAccountPlanTypeSchema.optional()
15074
15119
  }).strict();
15075
- var codexAccountListResultSchema = external_exports.object({ accounts: external_exports.array(codexAccountSchema).max(128) }).strict();
15076
- var codexAccountCreateParamsSchema = external_exports.object({ label: nonBlankTextSchema3.max(256).optional() }).strict();
15077
- var codexAccountActivateParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15078
- var codexAccountDeleteParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15079
- var codexAccountDeleteResultSchema = external_exports.object({ deletedAccountId: accountIdSchema }).strict();
15080
- var codexAccountMutationResultSchema = external_exports.object({ account: codexAccountSchema }).strict();
15081
- var codexAccountLoginStartParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15082
- var codexAccountLoginStartResultSchema = external_exports.object({
15083
- accountId: accountIdSchema,
15084
- loginId: nonBlankTextSchema3.max(1024),
15085
- verificationUrl: external_exports.string().url().max(16384),
15086
- userCode: nonBlankTextSchema3.max(1024)
15087
- }).strict();
15088
- var codexAccountLoginCancelParamsSchema = external_exports.object({ accountId: accountIdSchema.optional(), loginId: nonBlankTextSchema3.max(1024) }).strict();
15089
- var codexAccountLoginCancelResultSchema = external_exports.object({ cancelled: external_exports.boolean() }).strict();
15090
- var codexAccountLoginCompletedSchema = external_exports.object({
15091
- accountId: accountIdSchema,
15092
- loginId: nonBlankTextSchema3.max(1024),
15093
- success: external_exports.boolean(),
15094
- error: external_exports.string().max(4096).nullable()
15120
+ var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15121
+ var codexAccountListResultSchema = external_exports.object({
15122
+ version: external_exports.literal(2),
15123
+ currentAccountId: accountIdSchema.nullable(),
15124
+ phase: codexAccountPhaseSchema,
15125
+ revision: external_exports.number().int().nonnegative(),
15126
+ instanceId: nonBlankTextSchema3.max(1024).optional(),
15127
+ accounts: external_exports.array(codexAccountSchema).max(1)
15095
15128
  }).strict();
15096
- var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15129
+ var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
15097
15130
  var codexAccountUsageResultSchema = external_exports.object({
15098
15131
  accountId: accountIdSchema,
15099
15132
  usage: threadUsageSnapshotSchema.nullable(),
15100
- accountCredits: accountCreditsSnapshotSchema.optional()
15101
- }).strict();
15102
- var codexAccountResetCreditConsumeParamsSchema = external_exports.object({
15103
- accountId: accountIdSchema,
15104
- idempotencyKey: external_exports.string().uuid().optional()
15105
- }).strict();
15106
- var codexAccountResetCreditConsumeOutcomeSchema = external_exports.enum([
15107
- "reset",
15108
- "nothingToReset",
15109
- "noCredit",
15110
- "alreadyRedeemed"
15111
- ]);
15112
- var codexAccountResetCreditConsumeResultSchema = external_exports.object({
15113
- accountId: accountIdSchema,
15114
- outcome: codexAccountResetCreditConsumeOutcomeSchema,
15115
- accountCredits: accountCreditsSnapshotSchema.optional()
15133
+ accountCredits: accountCreditsSnapshotSchema.optional(),
15134
+ freshness: external_exports.enum(["live", "cached"]),
15135
+ observedAt: external_exports.string().datetime().nullable()
15116
15136
  }).strict();
15117
15137
 
15118
15138
  // ../../shared-contracts/dist/harness-session-import.js
@@ -16454,7 +16474,7 @@ var BrokeredHarnessAdapter = class {
16454
16474
 
16455
16475
  // dist/claude-code-adapter.js
16456
16476
  import { randomUUID as randomUUID3 } from "node:crypto";
16457
- import path10 from "node:path";
16477
+ import path11 from "node:path";
16458
16478
 
16459
16479
  // ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
16460
16480
  import { createRequire as DW } from "node:module";
@@ -20359,8 +20379,8 @@ var qU = v(function(BU) {
20359
20379
  BU._globalThis = void 0;
20360
20380
  BU._globalThis = typeof globalThis === "object" ? globalThis : global;
20361
20381
  });
20362
- var GU = v(function(os5) {
20363
- var Axe = os5 && os5.__createBinding || (Object.create ? function(e, t, r, n) {
20382
+ var GU = v(function(os6) {
20383
+ var Axe = os6 && os6.__createBinding || (Object.create ? function(e, t, r, n) {
20364
20384
  if (n === void 0) n = r;
20365
20385
  Object.defineProperty(e, n, { enumerable: true, get: function() {
20366
20386
  return t[r];
@@ -20368,11 +20388,11 @@ var GU = v(function(os5) {
20368
20388
  } : function(e, t, r, n) {
20369
20389
  if (n === void 0) n = r;
20370
20390
  e[n] = t[r];
20371
- }), kxe = os5 && os5.__exportStar || function(e, t) {
20391
+ }), kxe = os6 && os6.__exportStar || function(e, t) {
20372
20392
  for (var r in e) if (r !== "default" && !Object.prototype.hasOwnProperty.call(t, r)) Axe(t, e, r);
20373
20393
  };
20374
- Object.defineProperty(os5, "__esModule", { value: true });
20375
- kxe(qU(), os5);
20394
+ Object.defineProperty(os6, "__esModule", { value: true });
20395
+ kxe(qU(), os6);
20376
20396
  });
20377
20397
  var WU = v(function(is) {
20378
20398
  var Oxe = is && is.__createBinding || (Object.create ? function(e, t, r, n) {
@@ -42145,14 +42165,225 @@ var ClaudeBackgroundOccupancy = class {
42145
42165
  }
42146
42166
  };
42147
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
+
42148
42379
  // dist/command.js
42149
- import path4 from "node:path";
42380
+ import path5 from "node:path";
42150
42381
 
42151
42382
  // ../../harness-discovery/dist/environment.js
42152
42383
  import fs from "node:fs";
42153
- import path2 from "node:path";
42384
+ import path3 from "node:path";
42154
42385
  function targetPath(platform) {
42155
- return platform === "win32" ? path2.win32 : path2.posix;
42386
+ return platform === "win32" ? path3.win32 : path3.posix;
42156
42387
  }
42157
42388
  function environmentValue(environment, name) {
42158
42389
  const lowered = name.toLowerCase();
@@ -42195,11 +42426,11 @@ function newestFirst(names) {
42195
42426
  }
42196
42427
 
42197
42428
  // ../../harness-discovery/dist/node-runtime.js
42198
- import path3 from "node:path";
42429
+ import path4 from "node:path";
42199
42430
  function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
42200
42431
  const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
42201
42432
  const delimiter = platform === "win32" ? ";" : ":";
42202
- const runtimeDirectory = path3.dirname(runtimeExecutable);
42433
+ const runtimeDirectory = path4.dirname(runtimeExecutable);
42203
42434
  const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
42204
42435
  const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
42205
42436
  if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
@@ -42209,7 +42440,7 @@ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath
42209
42440
  }
42210
42441
 
42211
42442
  // ../../harness-discovery/dist/resolve.js
42212
- import os2 from "node:os";
42443
+ import os3 from "node:os";
42213
42444
 
42214
42445
  // ../../harness-discovery/dist/version-managers.js
42215
42446
  function versionManagerBinaryDirectories(context) {
@@ -42275,7 +42506,7 @@ function installRootExtensions(platform) {
42275
42506
  return platform === "win32" ? [".exe", ".cmd"] : [""];
42276
42507
  }
42277
42508
  function resolveHomeDirectory(input) {
42278
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os2.homedir();
42509
+ return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os3.homedir();
42279
42510
  }
42280
42511
  function templateVariables(environment, platform, home) {
42281
42512
  const pathFlavor = targetPath(platform);
@@ -42417,14 +42648,14 @@ function resolveClaudeCodeExecutable(input = {}, dependencies = {}) {
42417
42648
  }, dependencies);
42418
42649
  if (!resolution)
42419
42650
  throw new ClaudeCodeExecutableError("Claude Code is not installed");
42420
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
42651
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
42421
42652
  }
42422
42653
 
42423
42654
  // dist/pending-session.js
42424
42655
  import { randomUUID as randomUUID2 } from "node:crypto";
42425
- import { mkdir, open, readFile as readFile2, rename, rm as rm2, stat, unlink } from "node:fs/promises";
42426
- import os3 from "node:os";
42427
- import path5 from "node:path";
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";
42428
42659
  var reservationSchema = external_exports.strictObject({
42429
42660
  version: external_exports.literal(1),
42430
42661
  sessionId: external_exports.uuid(),
@@ -42437,13 +42668,13 @@ function isPendingClaudeSession(ref) {
42437
42668
  var ClaudePendingSessions = class {
42438
42669
  #directory;
42439
42670
  constructor(environment) {
42440
- this.#directory = path5.join(path5.resolve(environment.CLAUDE_CONFIG_DIR ?? path5.join(os3.homedir(), ".claude")), "codexhost", "pending-sessions");
42671
+ this.#directory = path6.join(path6.resolve(environment.CLAUDE_CONFIG_DIR ?? path6.join(os4.homedir(), ".claude")), "codexhost", "pending-sessions");
42441
42672
  }
42442
42673
  #path(ref, cwd) {
42443
- if (ref.harnessId !== "claude-code" || !external_exports.uuid().safeParse(ref.nativeSessionId).success || !external_exports.strictObject({ pendingSession: external_exports.literal(1) }).safeParse(ref.locator).success || !path5.isAbsolute(cwd)) {
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)) {
42444
42675
  throw new Error("Claude Code pending Session identity is invalid");
42445
42676
  }
42446
- return path5.join(this.#directory, ref.nativeSessionId);
42677
+ return path6.join(this.#directory, ref.nativeSessionId);
42447
42678
  }
42448
42679
  async create(cwd, configuration) {
42449
42680
  const ref = nativeSessionRefSchema.parse({
@@ -42462,7 +42693,7 @@ var ClaudePendingSessions = class {
42462
42693
  await mkdir(this.#directory, { recursive: true, mode: 448 });
42463
42694
  await mkdir(directory, { mode: 448 });
42464
42695
  try {
42465
- const file2 = await open(path5.join(directory, "session.json"), "wx", 384);
42696
+ const file2 = await open(path6.join(directory, "session.json"), "wx", 384);
42466
42697
  try {
42467
42698
  await file2.writeFile(JSON.stringify(reservation));
42468
42699
  await file2.sync();
@@ -42479,13 +42710,13 @@ var ClaudePendingSessions = class {
42479
42710
  }
42480
42711
  async read(ref, cwd) {
42481
42712
  const directory = this.#path(ref, cwd);
42482
- const reservation = reservationSchema.parse(JSON.parse(await readFile2(path5.join(directory, "session.json"), "utf8")));
42713
+ const reservation = reservationSchema.parse(JSON.parse(await readFile2(path6.join(directory, "session.json"), "utf8")));
42483
42714
  if (reservation.sessionId !== ref.nativeSessionId || reservation.cwd !== cwd) {
42484
42715
  throw new Error("Claude Code pending Session does not belong to this working directory");
42485
42716
  }
42486
42717
  let started = false;
42487
42718
  try {
42488
- const claim = await stat(path5.join(directory, "started"));
42719
+ const claim = await stat2(path6.join(directory, "started"));
42489
42720
  if (!claim.isFile())
42490
42721
  throw new Error("Claude Code pending Session claim is invalid");
42491
42722
  started = true;
@@ -42498,7 +42729,7 @@ var ClaudePendingSessions = class {
42498
42729
  async saveConfiguration(ref, cwd, configuration) {
42499
42730
  await this.read(ref, cwd);
42500
42731
  const directory = this.#path(ref, cwd);
42501
- const temporary = path5.join(directory, `${randomUUID2()}.tmp`);
42732
+ const temporary = path6.join(directory, `${randomUUID2()}.tmp`);
42502
42733
  try {
42503
42734
  const file2 = await open(temporary, "wx", 384);
42504
42735
  try {
@@ -42512,7 +42743,7 @@ var ClaudePendingSessions = class {
42512
42743
  } finally {
42513
42744
  await file2.close();
42514
42745
  }
42515
- await rename(temporary, path5.join(directory, "session.json"));
42746
+ await rename(temporary, path6.join(directory, "session.json"));
42516
42747
  await this.#sync(directory);
42517
42748
  } finally {
42518
42749
  await rm2(temporary, { force: true });
@@ -42530,7 +42761,7 @@ var ClaudePendingSessions = class {
42530
42761
  }
42531
42762
  async claim(ref, cwd) {
42532
42763
  await this.read(ref, cwd);
42533
- const claim = await open(path5.join(this.#path(ref, cwd), "started"), "wx", 384);
42764
+ const claim = await open(path6.join(this.#path(ref, cwd), "started"), "wx", 384);
42534
42765
  try {
42535
42766
  await claim.sync();
42536
42767
  } finally {
@@ -42540,7 +42771,7 @@ var ClaudePendingSessions = class {
42540
42771
  }
42541
42772
  /** Only the claim owner may release, after proven close and before submitting any native input. */
42542
42773
  async release(ref, cwd) {
42543
- await unlink(path5.join(this.#path(ref, cwd), "started"));
42774
+ await unlink(path6.join(this.#path(ref, cwd), "started"));
42544
42775
  await this.#sync(this.#path(ref, cwd));
42545
42776
  }
42546
42777
  async discard(ref, cwd) {
@@ -42549,7 +42780,7 @@ var ClaudePendingSessions = class {
42549
42780
  };
42550
42781
 
42551
42782
  // dist/claude-fork.js
42552
- import path6 from "node:path";
42783
+ import path7 from "node:path";
42553
42784
  import { isDeepStrictEqual } from "node:util";
42554
42785
 
42555
42786
  // dist/item-identity.js
@@ -42559,7 +42790,7 @@ function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
42559
42790
 
42560
42791
  // dist/claude-history.js
42561
42792
  var claudeCodeHarnessId = harnessIdSchema.parse("claude-code");
42562
- function isRecord2(value) {
42793
+ function isRecord3(value) {
42563
42794
  return typeof value === "object" && value !== null && !Array.isArray(value);
42564
42795
  }
42565
42796
  function textParts(value) {
@@ -42567,12 +42798,12 @@ function textParts(value) {
42567
42798
  return value.length > 0 ? [value] : [];
42568
42799
  if (!Array.isArray(value))
42569
42800
  return [];
42570
- return value.flatMap((part) => isRecord2(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
42801
+ return value.flatMap((part) => isRecord3(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
42571
42802
  }
42572
42803
  function thinkingParts(value) {
42573
42804
  if (!Array.isArray(value))
42574
42805
  return [];
42575
- return value.flatMap((part) => isRecord2(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
42806
+ return value.flatMap((part) => isRecord3(part) && part.type === "thinking" && typeof part.thinking === "string" ? [part.thinking] : []);
42576
42807
  }
42577
42808
  var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
42578
42809
  var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
@@ -42607,7 +42838,7 @@ function localCommandStdoutText(text) {
42607
42838
  return match[1] ?? "";
42608
42839
  }
42609
42840
  function isTaskNotificationOrigin(value) {
42610
- return isRecord2(value.origin) && value.origin.kind === "task-notification";
42841
+ return isRecord3(value.origin) && value.origin.kind === "task-notification";
42611
42842
  }
42612
42843
  function visibleUserTextParts(message) {
42613
42844
  if (message.type !== "user" || message.syntheticUser)
@@ -42618,24 +42849,24 @@ function visibleUserTextParts(message) {
42618
42849
  return parts.filter((part) => !isLocalCommandRecord(part) && !isTaskNotificationRecord(part));
42619
42850
  }
42620
42851
  function isInterruptionRecord(value, promptId) {
42621
- if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord2(value.message))
42852
+ if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord3(value.message))
42622
42853
  return false;
42623
42854
  const content = value.message.content;
42624
42855
  if (!Array.isArray(content) || content.length !== 1)
42625
42856
  return false;
42626
42857
  const part = content[0];
42627
- return isRecord2(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
42858
+ return isRecord3(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
42628
42859
  }
42629
42860
  function conversationMessages(values, sessionId) {
42630
42861
  const messages = [];
42631
42862
  const ids = /* @__PURE__ */ new Set();
42632
42863
  let promptId = null;
42633
42864
  for (const value of values) {
42634
- if (!isRecord2(value))
42865
+ if (!isRecord3(value))
42635
42866
  throw new Error("Claude history contains a malformed message");
42636
42867
  if (value.type === "system")
42637
42868
  continue;
42638
- if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !isRecord2(value.message) || value.message.role !== value.type) {
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) {
42639
42870
  throw new Error("Claude history contains an invalid message identity");
42640
42871
  }
42641
42872
  if (ids.has(value.uuid))
@@ -42767,7 +42998,7 @@ function mapClaudeSnapshot(values, sessionId) {
42767
42998
  let projectedReasoning = false;
42768
42999
  let projectedText = false;
42769
43000
  for (const [blockIndex, block] of content.entries()) {
42770
- if (!isRecord2(block))
43001
+ if (!isRecord3(block))
42771
43002
  continue;
42772
43003
  if (block.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
42773
43004
  items.push({
@@ -42810,7 +43041,7 @@ function mapClaudeSnapshot(values, sessionId) {
42810
43041
  }
42811
43042
  } : { status: "succeeded" };
42812
43043
  const itemId = hostItemIdSchema.parse(`claude-item-v1-${message.uuid}-tool-${blockIndex}`);
42813
- if (block.name === "Bash" && isRecord2(block.input) && typeof block.input.command === "string") {
43044
+ if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
42814
43045
  items.push({
42815
43046
  item: {
42816
43047
  type: "commandExecution",
@@ -42848,7 +43079,7 @@ function toolResultBlocks(messages) {
42848
43079
  if (message.type !== "user" || !Array.isArray(message.message.content))
42849
43080
  continue;
42850
43081
  for (const block of message.message.content) {
42851
- if (isRecord2(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
43082
+ if (isRecord3(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
42852
43083
  results.set(block.tool_use_id, block);
42853
43084
  }
42854
43085
  }
@@ -42863,7 +43094,7 @@ function toolResultOutput(block) {
42863
43094
  }
42864
43095
  function resultSubagentId(value, block) {
42865
43096
  const nativeResult = value.tool_use_result;
42866
- if (isRecord2(nativeResult)) {
43097
+ if (isRecord3(nativeResult)) {
42867
43098
  const structured = nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id;
42868
43099
  if (typeof structured === "string" && structured.length > 0)
42869
43100
  return structured;
@@ -42874,13 +43105,13 @@ function resultSubagentId(value, block) {
42874
43105
  function subagentPrompt(values, nativeSubagentId2) {
42875
43106
  const toolUses = /* @__PURE__ */ new Map();
42876
43107
  for (const value of values) {
42877
- if (!isRecord2(value) || !isRecord2(value.message) || !Array.isArray(value.message.content)) {
43108
+ if (!isRecord3(value) || !isRecord3(value.message) || !Array.isArray(value.message.content)) {
42878
43109
  continue;
42879
43110
  }
42880
43111
  for (const block of value.message.content) {
42881
- if (!isRecord2(block))
43112
+ if (!isRecord3(block))
42882
43113
  continue;
42883
- if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") && isRecord2(block.input) && typeof block.input.prompt === "string" && block.input.prompt.length > 0) {
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) {
42884
43115
  toolUses.set(block.id, block.input.prompt);
42885
43116
  continue;
42886
43117
  }
@@ -42894,7 +43125,7 @@ function subagentPrompt(values, nativeSubagentId2) {
42894
43125
  return void 0;
42895
43126
  }
42896
43127
  function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, parentValues = []) {
42897
- const messages = conversationMessages(values.map((value) => isRecord2(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
43128
+ const messages = conversationMessages(values.map((value) => isRecord3(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
42898
43129
  const turns = [];
42899
43130
  for (let index = 0; index < messages.length; ) {
42900
43131
  const first = messages[index];
@@ -42921,7 +43152,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
42921
43152
  const content = Array.isArray(message.message.content) ? message.message.content : [{ type: "text", text: message.message.content }];
42922
43153
  for (let blockIndex = 0; blockIndex < content.length; blockIndex += 1) {
42923
43154
  const block = content[blockIndex];
42924
- if (!isRecord2(block))
43155
+ if (!isRecord3(block))
42925
43156
  continue;
42926
43157
  const itemId = hostItemIdSchema.parse(`claude-subagent-item-v2-${nativeSubagentId2}-${message.uuid}-${blockIndex}`);
42927
43158
  if (block.type === "thinking" && typeof block.thinking === "string") {
@@ -42958,7 +43189,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
42958
43189
  retryable: false
42959
43190
  }
42960
43191
  } : { status: "succeeded" };
42961
- if (block.name === "Bash" && isRecord2(block.input) && typeof block.input.command === "string") {
43192
+ if (block.name === "Bash" && isRecord3(block.input) && typeof block.input.command === "string") {
42962
43193
  items.push({
42963
43194
  item: {
42964
43195
  type: "commandExecution",
@@ -43088,7 +43319,7 @@ async function forkClaudeSession(input) {
43088
43319
  error: error51("protocolError", "Claude Code Session working directory is unavailable", false)
43089
43320
  };
43090
43321
  }
43091
- if (path6.resolve(sourceInfo.cwd) !== input.cwd) {
43322
+ if (path7.resolve(sourceInfo.cwd) !== input.cwd) {
43092
43323
  return {
43093
43324
  ok: false,
43094
43325
  error: error51("unsupported", "Claude Code cannot Fork across working directories", false)
@@ -43188,26 +43419,26 @@ async function forkClaudeSession(input) {
43188
43419
  }
43189
43420
 
43190
43421
  // dist/claude-transcript.js
43191
- import os4 from "node:os";
43192
- import path7 from "node:path";
43193
- import { readFile as readFile3, readdir, stat as stat2 } from "node:fs/promises";
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";
43194
43425
  function projectDirectoryName(cwd) {
43195
43426
  return cwd.replace(/[^A-Za-z0-9]/gu, "-");
43196
43427
  }
43197
43428
  function configDirectory(environment) {
43198
- return environment.CLAUDE_CONFIG_DIR ? path7.resolve(environment.CLAUDE_CONFIG_DIR) : path7.join(os4.homedir(), ".claude");
43429
+ return environment.CLAUDE_CONFIG_DIR ? path8.resolve(environment.CLAUDE_CONFIG_DIR) : path8.join(os5.homedir(), ".claude");
43199
43430
  }
43200
43431
  async function existingFile(file2) {
43201
43432
  try {
43202
- return (await stat2(file2)).isFile();
43433
+ return (await stat3(file2)).isFile();
43203
43434
  } catch {
43204
43435
  return false;
43205
43436
  }
43206
43437
  }
43207
43438
  async function findTranscript(input) {
43208
- const projectsDirectory = path7.join(configDirectory(input.environment), "projects");
43439
+ const projectsDirectory = path8.join(configDirectory(input.environment), "projects");
43209
43440
  const name = `${input.sessionId}.jsonl`;
43210
- const expected = path7.join(projectsDirectory, projectDirectoryName(input.cwd), name);
43441
+ const expected = path8.join(projectsDirectory, projectDirectoryName(input.cwd), name);
43211
43442
  if (await existingFile(expected))
43212
43443
  return expected;
43213
43444
  let projects;
@@ -43217,13 +43448,13 @@ async function findTranscript(input) {
43217
43448
  return null;
43218
43449
  }
43219
43450
  for (const project of projects) {
43220
- const candidate = path7.join(projectsDirectory, project, name);
43451
+ const candidate = path8.join(projectsDirectory, project, name);
43221
43452
  if (await existingFile(candidate))
43222
43453
  return candidate;
43223
43454
  }
43224
43455
  return null;
43225
43456
  }
43226
- function isRecord3(value) {
43457
+ function isRecord4(value) {
43227
43458
  return typeof value === "object" && value !== null && !Array.isArray(value);
43228
43459
  }
43229
43460
  async function readClaudeTranscript(input) {
@@ -43241,7 +43472,7 @@ async function readClaudeTranscript(input) {
43241
43472
  } catch {
43242
43473
  continue;
43243
43474
  }
43244
- if (!isRecord3(entry) || entry.type !== "user" && entry.type !== "assistant" || typeof entry.uuid !== "string" || !isRecord3(entry.message)) {
43475
+ if (!isRecord4(entry) || entry.type !== "user" && entry.type !== "assistant" || typeof entry.uuid !== "string" || !isRecord4(entry.message)) {
43245
43476
  continue;
43246
43477
  }
43247
43478
  messages.push({ ...entry, session_id: input.sessionId });
@@ -43508,7 +43739,7 @@ function projectClaudeAccountUsage(usage, account) {
43508
43739
  }
43509
43740
 
43510
43741
  // dist/file-change.js
43511
- import path8 from "node:path";
43742
+ import path9 from "node:path";
43512
43743
  var hunkSchema = external_exports.object({
43513
43744
  oldStart: external_exports.number().int().nonnegative(),
43514
43745
  oldLines: external_exports.number().int().nonnegative(),
@@ -43516,7 +43747,7 @@ var hunkSchema = external_exports.object({
43516
43747
  newLines: external_exports.number().int().nonnegative(),
43517
43748
  lines: external_exports.array(external_exports.string())
43518
43749
  }).strict();
43519
- function isRecord4(value) {
43750
+ function isRecord5(value) {
43520
43751
  return typeof value === "object" && value !== null && !Array.isArray(value);
43521
43752
  }
43522
43753
  function validNativePath(value) {
@@ -43540,7 +43771,7 @@ function validHunk(value) {
43540
43771
  return hunk;
43541
43772
  }
43542
43773
  function parseClaudeNativeFileChange(toolName, value) {
43543
- if (toolName !== "Edit" && toolName !== "Write" || !isRecord4(value))
43774
+ if (toolName !== "Edit" && toolName !== "Write" || !isRecord5(value))
43544
43775
  return null;
43545
43776
  if (!validNativePath(value.filePath) || !Array.isArray(value.structuredPatch))
43546
43777
  return null;
@@ -43556,10 +43787,10 @@ function parseClaudeNativeFileChange(toolName, value) {
43556
43787
  };
43557
43788
  }
43558
43789
  function displayPath(nativePath, cwd) {
43559
- const resolvedCwd = path8.resolve(cwd);
43560
- const resolvedPath = path8.isAbsolute(nativePath) ? path8.resolve(nativePath) : path8.resolve(cwd, nativePath);
43561
- const relative = path8.relative(resolvedCwd, resolvedPath);
43562
- const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`) ? relative : resolvedPath;
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;
43563
43794
  const normalized = selected.replaceAll("\\", "/");
43564
43795
  return validNativePath(normalized) && normalized !== "." ? normalized : null;
43565
43796
  }
@@ -43571,7 +43802,7 @@ function projectClaudeFileChange(value, cwd) {
43571
43802
  `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
43572
43803
  ...hunk.lines
43573
43804
  ]);
43574
- const absoluteDisplayPath = path8.posix.isAbsolute(normalizedPath);
43805
+ const absoluteDisplayPath = path9.posix.isAbsolute(normalizedPath);
43575
43806
  const oldHeader = value.kind === "add" ? "/dev/null" : absoluteDisplayPath ? normalizedPath : `a/${normalizedPath}`;
43576
43807
  const newHeader = absoluteDisplayPath ? normalizedPath : `b/${normalizedPath}`;
43577
43808
  const unifiedDiff = [`--- ${oldHeader}`, `+++ ${newHeader}`, ...body, ""].join("\n");
@@ -43584,7 +43815,7 @@ var AUTHENTICATION_ERRORS = /* @__PURE__ */ new Set(["authentication_failed", "o
43584
43815
  var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task", "SendMessage"]);
43585
43816
  var SUBAGENT_DESCRIPTION_LIMIT = 500;
43586
43817
  var SUBAGENT_SUMMARY_LIMIT = 2e3;
43587
- function isRecord5(value) {
43818
+ function isRecord6(value) {
43588
43819
  return typeof value === "object" && value !== null && !Array.isArray(value);
43589
43820
  }
43590
43821
  function nativeUuid(message) {
@@ -43594,12 +43825,12 @@ function parentToolUseId(message) {
43594
43825
  return typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0 ? message.parent_tool_use_id : null;
43595
43826
  }
43596
43827
  function assistantNativeMessageId(message) {
43597
- if (!isRecord5(message.message))
43828
+ if (!isRecord6(message.message))
43598
43829
  return null;
43599
43830
  return typeof message.message.id === "string" && message.message.id.length > 0 ? message.message.id : null;
43600
43831
  }
43601
43832
  function assistantContent(message) {
43602
- if (message.type !== "assistant" || !isRecord5(message.message))
43833
+ if (message.type !== "assistant" || !isRecord6(message.message))
43603
43834
  return null;
43604
43835
  return Array.isArray(message.message.content) ? message.message.content : null;
43605
43836
  }
@@ -43607,10 +43838,10 @@ function assistantText(message) {
43607
43838
  const content = assistantContent(message);
43608
43839
  if (!content)
43609
43840
  return null;
43610
- return content.flatMap((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
43841
+ return content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
43611
43842
  }
43612
43843
  function assistantError(message) {
43613
- return isRecord5(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
43844
+ return isRecord6(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
43614
43845
  }
43615
43846
  function boundedString(value, limit) {
43616
43847
  if (typeof value !== "string")
@@ -43621,25 +43852,25 @@ function boundedString(value, limit) {
43621
43852
  return trimmed.slice(0, limit);
43622
43853
  }
43623
43854
  function subagentDescription(argumentsValue, toolName) {
43624
- if (!isRecord5(argumentsValue))
43855
+ if (!isRecord6(argumentsValue))
43625
43856
  return `${toolName} delegation`;
43626
43857
  return boundedString(argumentsValue.description, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.summary, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.name, SUBAGENT_DESCRIPTION_LIMIT) ?? `${toolName} delegation`;
43627
43858
  }
43628
43859
  function subagentPrompt2(argumentsValue) {
43629
- if (!isRecord5(argumentsValue))
43860
+ if (!isRecord6(argumentsValue))
43630
43861
  return void 0;
43631
43862
  return boundedString(argumentsValue.prompt ?? argumentsValue.message, SUBAGENT_SUMMARY_LIMIT);
43632
43863
  }
43633
43864
  function subagentRole(argumentsValue) {
43634
- if (!isRecord5(argumentsValue))
43865
+ if (!isRecord6(argumentsValue))
43635
43866
  return void 0;
43636
43867
  return boundedString(argumentsValue.subagent_type ?? argumentsValue.agent_type, SUBAGENT_DESCRIPTION_LIMIT);
43637
43868
  }
43638
43869
  function subagentBackground(argumentsValue) {
43639
- return isRecord5(argumentsValue) && argumentsValue.run_in_background === true;
43870
+ return isRecord6(argumentsValue) && argumentsValue.run_in_background === true;
43640
43871
  }
43641
43872
  function targetedSubagentId(argumentsValue) {
43642
- if (!isRecord5(argumentsValue))
43873
+ if (!isRecord6(argumentsValue))
43643
43874
  return void 0;
43644
43875
  return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
43645
43876
  }
@@ -43659,11 +43890,11 @@ function finiteNonNegativeNumber(value) {
43659
43890
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
43660
43891
  }
43661
43892
  function parseResultModelUsage(value) {
43662
- if (!isRecord5(value))
43893
+ if (!isRecord6(value))
43663
43894
  return void 0;
43664
43895
  const usage = [];
43665
43896
  for (const entry of Object.values(value)) {
43666
- if (!isRecord5(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
43897
+ if (!isRecord6(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
43667
43898
  return void 0;
43668
43899
  }
43669
43900
  usage.push({ inputTokens: entry.inputTokens, outputTokens: entry.outputTokens });
@@ -43671,7 +43902,7 @@ function parseResultModelUsage(value) {
43671
43902
  return usage;
43672
43903
  }
43673
43904
  function parseLastRequestUsage(value, attribution = {}) {
43674
- if (!isRecord5(value))
43905
+ if (!isRecord6(value))
43675
43906
  return void 0;
43676
43907
  const inputTokens = value.input_tokens;
43677
43908
  const outputTokens = value.output_tokens;
@@ -43694,7 +43925,7 @@ function parseLastRequestUsage(value, attribution = {}) {
43694
43925
  };
43695
43926
  }
43696
43927
  function assistantRequestUsage(message, provider) {
43697
- if (!isRecord5(message.message))
43928
+ if (!isRecord6(message.message))
43698
43929
  return void 0;
43699
43930
  return parseLastRequestUsage(message.message.usage, {
43700
43931
  requestId: message.message.id ?? message.request_id,
@@ -43717,7 +43948,7 @@ function parseResultUsageEvent(message) {
43717
43948
  };
43718
43949
  }
43719
43950
  function parsePlanLimitWindow(value) {
43720
- if (!isRecord5(value))
43951
+ if (!isRecord6(value))
43721
43952
  return void 0;
43722
43953
  const utilization = value.utilization;
43723
43954
  if (typeof utilization !== "number" || !Number.isFinite(utilization) || utilization < 0) {
@@ -43729,12 +43960,12 @@ function parsePlanLimitWindow(value) {
43729
43960
  return { utilizationPercent, ...resetsAtUnix !== void 0 ? { resetsAtUnix } : {} };
43730
43961
  }
43731
43962
  function parseClaudePlanLimitEvent(message) {
43732
- if (!isRecord5(message) || message.type !== "rate_limit_event")
43963
+ if (!isRecord6(message) || message.type !== "rate_limit_event")
43733
43964
  return null;
43734
43965
  const info = message.rate_limit_info;
43735
- if (!isRecord5(info))
43966
+ if (!isRecord6(info))
43736
43967
  return null;
43737
- const windows = isRecord5(info.unifiedWindows) ? info.unifiedWindows : void 0;
43968
+ const windows = isRecord6(info.unifiedWindows) ? info.unifiedWindows : void 0;
43738
43969
  let fiveHour = parsePlanLimitWindow(windows?.five_hour);
43739
43970
  let sevenDay = parsePlanLimitWindow(windows?.seven_day);
43740
43971
  if (!fiveHour && !sevenDay) {
@@ -43752,7 +43983,7 @@ function parseClaudePlanLimitEvent(message) {
43752
43983
  };
43753
43984
  }
43754
43985
  function nativeSubagentId(nativeResult, outputText) {
43755
- if (isRecord5(nativeResult)) {
43986
+ if (isRecord6(nativeResult)) {
43756
43987
  const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id, SUBAGENT_DESCRIPTION_LIMIT);
43757
43988
  if (structured)
43758
43989
  return structured;
@@ -43760,7 +43991,7 @@ function nativeSubagentId(nativeResult, outputText) {
43760
43991
  return boundedString(/agentId:\s*([A-Za-z0-9_-]+)/u.exec(outputText ?? "")?.[1], SUBAGENT_DESCRIPTION_LIMIT);
43761
43992
  }
43762
43993
  function subagentContinuesInBackground(nativeResult, outputText) {
43763
- if (isRecord5(nativeResult)) {
43994
+ if (isRecord6(nativeResult)) {
43764
43995
  if (nativeResult.isAsync === true || nativeResult.is_async === true)
43765
43996
  return true;
43766
43997
  if (nativeResult.status === "async_launched")
@@ -43773,11 +44004,11 @@ function resultText(content, nativeResult) {
43773
44004
  if (typeof content === "string") {
43774
44005
  text = content;
43775
44006
  } else if (Array.isArray(content)) {
43776
- text = content.flatMap((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44007
+ text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
43777
44008
  }
43778
44009
  if (text.length > 0)
43779
44010
  return text;
43780
- if (!isRecord5(nativeResult))
44011
+ if (!isRecord6(nativeResult))
43781
44012
  return void 0;
43782
44013
  const stdout = typeof nativeResult.stdout === "string" ? nativeResult.stdout : "";
43783
44014
  const stderr = typeof nativeResult.stderr === "string" ? nativeResult.stderr : "";
@@ -43789,13 +44020,13 @@ function userMessageText(content) {
43789
44020
  return content;
43790
44021
  if (!Array.isArray(content))
43791
44022
  return null;
43792
- const text = content.flatMap((block) => isRecord5(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
44023
+ const text = content.flatMap((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
43793
44024
  return text.length > 0 ? text : null;
43794
44025
  }
43795
44026
  function parseClaudeTaskNotification(message) {
43796
- if (!isRecord5(message) || message.type !== "user" || !isRecord5(message.message))
44027
+ if (!isRecord6(message) || message.type !== "user" || !isRecord6(message.message))
43797
44028
  return null;
43798
- if (isRecord5(message.origin) && message.origin.kind !== "task-notification")
44029
+ if (isRecord6(message.origin) && message.origin.kind !== "task-notification")
43799
44030
  return null;
43800
44031
  const content = userMessageText(message.message.content);
43801
44032
  if (!content || !content.includes("<task-notification>"))
@@ -43854,7 +44085,7 @@ var ClaudeNativeTurnAccumulator = class {
43854
44085
  this.#cancelRequested = true;
43855
44086
  }
43856
44087
  consume(message) {
43857
- if (this.#completed || !isRecord5(message))
44088
+ if (this.#completed || !isRecord6(message))
43858
44089
  return { events: [] };
43859
44090
  const events = [];
43860
44091
  this.#consumeSegmentLevel(message, events);
@@ -43868,7 +44099,7 @@ var ClaudeNativeTurnAccumulator = class {
43868
44099
  this.#consumeCompaction(message, events);
43869
44100
  this.#consumeLocalCommandOutput(message, events);
43870
44101
  }
43871
- if (message.type === "stream_event" && isRecord5(message.event)) {
44102
+ if (message.type === "stream_event" && isRecord6(message.event)) {
43872
44103
  if (!nested)
43873
44104
  this.#consumeStreamEvent(message, events);
43874
44105
  } else if (message.type === "tool_progress") {
@@ -43975,7 +44206,7 @@ var ClaudeNativeTurnAccumulator = class {
43975
44206
  if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
43976
44207
  return;
43977
44208
  const nativeSubagentIds = message.tasks.flatMap((task) => {
43978
- if (!isRecord5(task))
44209
+ if (!isRecord6(task))
43979
44210
  return [];
43980
44211
  const taskId = boundedString(task.task_id, SUBAGENT_DESCRIPTION_LIMIT);
43981
44212
  return taskId ? [taskId] : [];
@@ -44035,7 +44266,7 @@ var ClaudeNativeTurnAccumulator = class {
44035
44266
  });
44036
44267
  return;
44037
44268
  }
44038
- if (message.subtype === "task_updated" && isRecord5(message.patch)) {
44269
+ if (message.subtype === "task_updated" && isRecord6(message.patch)) {
44039
44270
  const status = taskStatus(message.patch.status);
44040
44271
  if (!status)
44041
44272
  return;
@@ -44054,14 +44285,14 @@ var ClaudeNativeTurnAccumulator = class {
44054
44285
  }
44055
44286
  #consumeStreamEvent(message, events) {
44056
44287
  const event = message.event;
44057
- if (!isRecord5(event))
44288
+ if (!isRecord6(event))
44058
44289
  return;
44059
- if (event.type === "message_start" && isRecord5(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
44290
+ if (event.type === "message_start" && isRecord6(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
44060
44291
  this.#activeRootStreamMessageId = event.message.id;
44061
44292
  this.#messageState(event.message.id);
44062
44293
  return;
44063
44294
  }
44064
- if (event.type !== "content_block_delta" || !isRecord5(event.delta))
44295
+ if (event.type !== "content_block_delta" || !isRecord6(event.delta))
44065
44296
  return;
44066
44297
  const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
44067
44298
  if (!this.#activeRootStreamMessageId)
@@ -44137,7 +44368,7 @@ var ClaudeNativeTurnAccumulator = class {
44137
44368
  }
44138
44369
  #consumeToolUseBlocks(message, events, ignoreKnownIds) {
44139
44370
  for (const block of assistantContent(message) ?? []) {
44140
- if (!isRecord5(block) || block.type !== "tool_use")
44371
+ if (!isRecord6(block) || block.type !== "tool_use")
44141
44372
  continue;
44142
44373
  const argumentsResult = jsonValueSchema.safeParse(block.input);
44143
44374
  if (typeof block.id !== "string" || block.id.length === 0 || typeof block.name !== "string" || block.name.length === 0 || !argumentsResult.success) {
@@ -44189,9 +44420,9 @@ var ClaudeNativeTurnAccumulator = class {
44189
44420
  events.push(settled);
44190
44421
  }
44191
44422
  #consumeToolResults(message, events, ignoreUnknown) {
44192
- if (!isRecord5(message.message) || !Array.isArray(message.message.content))
44423
+ if (!isRecord6(message.message) || !Array.isArray(message.message.content))
44193
44424
  return;
44194
- const resultBlocks = message.message.content.filter((block) => isRecord5(block) && block.type === "tool_result");
44425
+ const resultBlocks = message.message.content.filter((block) => isRecord6(block) && block.type === "tool_result");
44195
44426
  if (resultBlocks.length === 0)
44196
44427
  return;
44197
44428
  if (resultBlocks.length > 1 && message.tool_use_result !== void 0) {
@@ -44260,7 +44491,7 @@ var ClaudeNativeTurnAccumulator = class {
44260
44491
 
44261
44492
  // dist/process-fence.js
44262
44493
  import { execFile } from "node:child_process";
44263
- import path9 from "node:path";
44494
+ import path10 from "node:path";
44264
44495
  import { setTimeout as setTimeout2 } from "node:timers/promises";
44265
44496
  import { promisify } from "node:util";
44266
44497
  var executeFile = promisify(execFile);
@@ -44284,9 +44515,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
44284
44515
  if (child.exitCode !== null || child.signalCode !== null)
44285
44516
  throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
44286
44517
  const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
44287
- if (!root || !path9.win32.isAbsolute(root))
44518
+ if (!root || !path10.win32.isAbsolute(root))
44288
44519
  throw new Error("Windows SystemRoot is unavailable");
44289
- await executeFile(path9.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
44520
+ await executeFile(path10.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
44290
44521
  timeout: timeoutMs,
44291
44522
  windowsHide: true
44292
44523
  });
@@ -44313,6 +44544,7 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
44313
44544
 
44314
44545
  // dist/sdk-transport.js
44315
44546
  var CLIENT_APP = "codexhost-claude-code-adapter/0.0.0";
44547
+ var SESSION_ENTRYPOINT = "codexhost-sdk";
44316
44548
  var APPROVAL_TITLE_MAX_LENGTH = 120;
44317
44549
  var APPROVAL_DESCRIPTION_MAX_LENGTH = 500;
44318
44550
  var DEFAULT_ABORT_TIMEOUT_MS = 2e3;
@@ -44372,17 +44604,17 @@ function allowsDangerouslySkipPermissions(getuid = process.getuid) {
44372
44604
  function processExited(child) {
44373
44605
  return child.exitCode !== null || child.signalCode !== null;
44374
44606
  }
44375
- function isRecord6(value) {
44607
+ function isRecord7(value) {
44376
44608
  return typeof value === "object" && value !== null && !Array.isArray(value);
44377
44609
  }
44378
44610
  function permissionModeFromMessage(value) {
44379
- if (!isRecord6(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
44611
+ if (!isRecord7(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
44380
44612
  return void 0;
44381
44613
  }
44382
44614
  return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
44383
44615
  }
44384
44616
  function parseContextUsage(value) {
44385
- if (!isRecord6(value))
44617
+ if (!isRecord7(value))
44386
44618
  throw new Error("Claude SDK context Usage is invalid");
44387
44619
  const usedTokens = value.totalTokens;
44388
44620
  const maxTokens = value.maxTokens;
@@ -44399,7 +44631,7 @@ function parseQuestions(input) {
44399
44631
  const questions = [];
44400
44632
  const questionTexts = /* @__PURE__ */ new Set();
44401
44633
  for (const value of input.questions) {
44402
- if (!isRecord6(value))
44634
+ if (!isRecord7(value))
44403
44635
  return null;
44404
44636
  const question = value.question;
44405
44637
  const header = value.header;
@@ -44410,7 +44642,7 @@ function parseQuestions(input) {
44410
44642
  const labels = /* @__PURE__ */ new Set();
44411
44643
  const options = [];
44412
44644
  for (const option2 of value.options) {
44413
- if (!isRecord6(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
44645
+ if (!isRecord7(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
44414
44646
  return null;
44415
44647
  }
44416
44648
  labels.add(option2.label);
@@ -44452,7 +44684,7 @@ function permissionUpdateDestination(value) {
44452
44684
  return void 0;
44453
44685
  }
44454
44686
  function isPermissionUpdate(value) {
44455
- if (!isRecord6(value) || !permissionUpdateDestination(value.destination))
44687
+ if (!isRecord7(value) || !permissionUpdateDestination(value.destination))
44456
44688
  return false;
44457
44689
  if (value.type === "setMode") {
44458
44690
  return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
@@ -44461,7 +44693,7 @@ function isPermissionUpdate(value) {
44461
44693
  return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
44462
44694
  }
44463
44695
  if (value.type === "addRules" || value.type === "replaceRules" || value.type === "removeRules") {
44464
- return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord6(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
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"));
44465
44697
  }
44466
44698
  return false;
44467
44699
  }
@@ -44606,6 +44838,7 @@ var ClaudeSdkTransport = class {
44606
44838
  forwardSubagentText: true,
44607
44839
  env: withNodeRuntimeOnPath({
44608
44840
  ...this.#environment,
44841
+ CLAUDE_CODE_ENTRYPOINT: SESSION_ENTRYPOINT,
44609
44842
  CLAUDE_AGENT_SDK_CLIENT_APP: CLIENT_APP
44610
44843
  }),
44611
44844
  spawnClaudeCodeProcess: (options) => this.#spawn(options)
@@ -44899,10 +45132,10 @@ var ClaudeSdkTransport = class {
44899
45132
  }
44900
45133
  }
44901
45134
  #observeBackgroundTasks(message) {
44902
- if (!isRecord6(message) || message.type !== "system")
45135
+ if (!isRecord7(message) || message.type !== "system")
44903
45136
  return;
44904
45137
  if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
44905
- this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord6(task) && typeof task.task_id === "string" ? [task.task_id] : []));
45138
+ this.#backgroundTasks = new Set(message.tasks.flatMap((task) => isRecord7(task) && typeof task.task_id === "string" ? [task.task_id] : []));
44906
45139
  } else if (message.subtype === "task_started" && typeof message.task_id === "string") {
44907
45140
  this.#backgroundTasks.add(message.task_id);
44908
45141
  } else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
@@ -44951,7 +45184,7 @@ var ClaudeSdkTransport = class {
44951
45184
  events: [],
44952
45185
  nativeTurnKey: null
44953
45186
  });
44954
- if (autonomous.nativeTurnKey === null && isRecord6(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) {
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) {
44955
45188
  autonomous.nativeTurnKey = message.uuid;
44956
45189
  }
44957
45190
  const interpreted = autonomous.accumulator.consume(message);
@@ -45293,11 +45526,11 @@ var ClaudeSubagentLifecycle = class {
45293
45526
  };
45294
45527
 
45295
45528
  // dist/task-tracker.js
45296
- function isRecord7(value) {
45529
+ function isRecord8(value) {
45297
45530
  return typeof value === "object" && value !== null && !Array.isArray(value);
45298
45531
  }
45299
45532
  function stringField(value, keys) {
45300
- if (!isRecord7(value))
45533
+ if (!isRecord8(value))
45301
45534
  return void 0;
45302
45535
  for (const key of keys) {
45303
45536
  const field = value[key];
@@ -45332,7 +45565,7 @@ var ClaudeTaskTracker = class {
45332
45565
  };
45333
45566
  }
45334
45567
  #create(args, result) {
45335
- if (!isRecord7(result) || !isRecord7(result.task))
45568
+ if (!isRecord8(result) || !isRecord8(result.task))
45336
45569
  return;
45337
45570
  const id = stringField(result.task, ["id"]);
45338
45571
  const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
@@ -45350,7 +45583,7 @@ var ClaudeTaskTracker = class {
45350
45583
  const id = stringField(args, ["taskId", "id", "task_id"]);
45351
45584
  if (!id)
45352
45585
  return;
45353
- const status = isRecord7(args) ? taskStatus2(args.status) : void 0;
45586
+ const status = isRecord8(args) ? taskStatus2(args.status) : void 0;
45354
45587
  if (status === "deleted") {
45355
45588
  this.#tasks.delete(id);
45356
45589
  return;
@@ -45368,13 +45601,13 @@ var ClaudeTaskTracker = class {
45368
45601
  });
45369
45602
  }
45370
45603
  #replace(result) {
45371
- if (!isRecord7(result) || !Array.isArray(result.tasks))
45604
+ if (!isRecord8(result) || !Array.isArray(result.tasks))
45372
45605
  return;
45373
45606
  const next = /* @__PURE__ */ new Map();
45374
45607
  for (const value of result.tasks) {
45375
45608
  const id = stringField(value, ["id"]);
45376
45609
  const subject = stringField(value, ["subject"]);
45377
- const status = isRecord7(value) ? taskStatus2(value.status) : void 0;
45610
+ const status = isRecord8(value) ? taskStatus2(value.status) : void 0;
45378
45611
  if (!id || !subject || !status || status === "deleted")
45379
45612
  continue;
45380
45613
  const existing = this.#tasks.get(id);
@@ -45392,11 +45625,11 @@ var ClaudeTaskTracker = class {
45392
45625
  };
45393
45626
 
45394
45627
  // dist/tool-lifecycle.js
45395
- function isRecord8(value) {
45628
+ function isRecord9(value) {
45396
45629
  return typeof value === "object" && value !== null && !Array.isArray(value);
45397
45630
  }
45398
45631
  function stringField2(value, key) {
45399
- return isRecord8(value) && typeof value[key] === "string" ? value[key] : void 0;
45632
+ return isRecord9(value) && typeof value[key] === "string" ? value[key] : void 0;
45400
45633
  }
45401
45634
  function toolFailure(toolName) {
45402
45635
  return {
@@ -45497,6 +45730,7 @@ var ClaudeToolLifecycle = class {
45497
45730
  const fileItem = {
45498
45731
  type: "fileChange",
45499
45732
  itemId: this.#newItemId(),
45733
+ sourceItemIds: [tool.item.itemId],
45500
45734
  changes: [change]
45501
45735
  };
45502
45736
  this.#emit({ type: "item.started", turnId, item: fileItem });
@@ -45643,7 +45877,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
45643
45877
  var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
45644
45878
  var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
45645
45879
  var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
45646
- function isRecord9(value) {
45880
+ function isRecord10(value) {
45647
45881
  return typeof value === "object" && value !== null && !Array.isArray(value);
45648
45882
  }
45649
45883
  function safeNonNegativeInteger2(value) {
@@ -45652,7 +45886,7 @@ function safeNonNegativeInteger2(value) {
45652
45886
  function transcriptRequestUsage(messages, messageId) {
45653
45887
  for (let index = messages.length - 1; index >= 0; index -= 1) {
45654
45888
  const entry = messages[index];
45655
- if (!isRecord9(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord9(entry.message) || entry.message.id !== messageId || !isRecord9(entry.message.usage)) {
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)) {
45656
45890
  continue;
45657
45891
  }
45658
45892
  const inputTokens = entry.message.usage.input_tokens;
@@ -45904,7 +46138,7 @@ var ClaudeHarnessSession = class {
45904
46138
  cwd: this.#cwd,
45905
46139
  sessionId: this.#sessionId
45906
46140
  });
45907
- const ids = new Set(messages.flatMap((message) => isRecord9(message) && typeof message.uuid === "string" ? [message.uuid] : []));
46141
+ const ids = new Set(messages.flatMap((message) => isRecord10(message) && typeof message.uuid === "string" ? [message.uuid] : []));
45908
46142
  if (this.#unpersistedMessageIds.every((id) => ids.has(id))) {
45909
46143
  this.#unpersistedMessageIds = [];
45910
46144
  break;
@@ -46073,6 +46307,7 @@ var ClaudeHarnessSession = class {
46073
46307
  usageTokensCalibrated: false,
46074
46308
  usageCostCalibrated: false,
46075
46309
  held: false,
46310
+ rootSegmentActive: true,
46076
46311
  completion,
46077
46312
  resolveCompletion
46078
46313
  };
@@ -46177,6 +46412,7 @@ var ClaudeHarnessSession = class {
46177
46412
  usageTokensCalibrated: false,
46178
46413
  usageCostCalibrated: false,
46179
46414
  held: false,
46415
+ rootSegmentActive: true,
46180
46416
  completion,
46181
46417
  resolveCompletion
46182
46418
  };
@@ -46215,7 +46451,7 @@ var ClaudeHarnessSession = class {
46215
46451
  return this.#closePromise;
46216
46452
  }
46217
46453
  async #selectModel(command) {
46218
- if (this.#acceptingTurn || this.#active || this.#configurationTask || this.#readingHistory) {
46454
+ if (this.#acceptingTurn || this.#configurationTask || this.#readingHistory) {
46219
46455
  return {
46220
46456
  ok: false,
46221
46457
  error: {
@@ -46273,7 +46509,7 @@ var ClaudeHarnessSession = class {
46273
46509
  }
46274
46510
  }
46275
46511
  async #selectThinking(command) {
46276
- if (this.#acceptingTurn || this.#active || this.#configurationTask || this.#readingHistory) {
46512
+ if (this.#acceptingTurn || this.#configurationTask || this.#readingHistory) {
46277
46513
  return {
46278
46514
  ok: false,
46279
46515
  error: {
@@ -46690,12 +46926,14 @@ var ClaudeHarnessSession = class {
46690
46926
  return;
46691
46927
  switch (event.type) {
46692
46928
  case "segment.started":
46693
- this.#observeRootOutput();
46929
+ this.#observeRootOutput(active);
46694
46930
  return;
46695
46931
  case "subagents.live":
46696
46932
  this.#occupancy.observeLive(event.nativeSubagentIds);
46933
+ this.#armContinuationQuiescence(active);
46697
46934
  return;
46698
46935
  case "compaction.started":
46936
+ this.#observeRootOutput(active);
46699
46937
  this.#startCompaction(active);
46700
46938
  return;
46701
46939
  case "compaction.completed":
@@ -46703,12 +46941,12 @@ var ClaudeHarnessSession = class {
46703
46941
  return;
46704
46942
  case "text.delta":
46705
46943
  if (event.delta.length > 0)
46706
- this.#observeRootOutput();
46944
+ this.#observeRootOutput(active);
46707
46945
  this.#appendText(active, event.messageId, event.delta);
46708
46946
  return;
46709
46947
  case "reasoning.delta":
46710
46948
  if (event.delta.length > 0)
46711
- this.#observeRootOutput();
46949
+ this.#observeRootOutput(active);
46712
46950
  this.#activateAssistantMessage(active, event.messageId);
46713
46951
  this.#appendReasoning(active, event.messageId, event.delta);
46714
46952
  return;
@@ -46716,6 +46954,7 @@ var ClaudeHarnessSession = class {
46716
46954
  this.#completeReasoning(active, event.messageId, { status: "succeeded" });
46717
46955
  return;
46718
46956
  case "message.completed": {
46957
+ this.#observeRootOutput(active);
46719
46958
  if (event.lastRequestUsage) {
46720
46959
  this.#requestUsageBoundary += 1;
46721
46960
  this.#applyLatestRequestUsage(active, event.lastRequestUsage);
@@ -46732,7 +46971,7 @@ var ClaudeHarnessSession = class {
46732
46971
  return;
46733
46972
  }
46734
46973
  case "tool.started":
46735
- this.#observeRootOutput();
46974
+ this.#observeRootOutput(active);
46736
46975
  for (const messageId of [...active.reasoningItems.keys()]) {
46737
46976
  this.#completeReasoning(active, messageId, { status: "succeeded" });
46738
46977
  }
@@ -46746,7 +46985,7 @@ var ClaudeHarnessSession = class {
46746
46985
  active.tools.complete(active.command.turnId, event, active.cancellationRequested);
46747
46986
  return;
46748
46987
  case "subagent.started":
46749
- this.#observeRootOutput();
46988
+ this.#observeRootOutput(active);
46750
46989
  for (const messageId of [...active.reasoningItems.keys()]) {
46751
46990
  this.#completeReasoning(active, messageId, { status: "succeeded" });
46752
46991
  }
@@ -46797,6 +47036,7 @@ var ClaudeHarnessSession = class {
46797
47036
  return;
46798
47037
  }
46799
47038
  case "interaction.requested":
47039
+ this.#observeRootOutput(active);
46800
47040
  this.#startInteraction(active, event.request);
46801
47041
  return;
46802
47042
  case "interaction.closed":
@@ -47073,6 +47313,7 @@ var ClaudeHarnessSession = class {
47073
47313
  usageTokensCalibrated: false,
47074
47314
  usageCostCalibrated: false,
47075
47315
  held: false,
47316
+ rootSegmentActive: true,
47076
47317
  completion,
47077
47318
  resolveCompletion
47078
47319
  };
@@ -47091,6 +47332,9 @@ var ClaudeHarnessSession = class {
47091
47332
  }
47092
47333
  #settleBackgroundSubagent(status, nativeSubagentId2, callId, resultSummary) {
47093
47334
  this.#occupancy.notify(callId, nativeSubagentId2);
47335
+ const active = this.#active;
47336
+ if (active?.held)
47337
+ this.#armContinuationQuiescence(active);
47094
47338
  if (!nativeSubagentId2)
47095
47339
  return;
47096
47340
  this.#event({
@@ -47108,6 +47352,7 @@ var ClaudeHarnessSession = class {
47108
47352
  #finishResult(active, result) {
47109
47353
  if (this.#active !== active || this.#hardCancelTask)
47110
47354
  return;
47355
+ active.rootSegmentActive = false;
47111
47356
  if (result.status === "succeeded" && (active.tools.size > 0 || active.subagents.size > 0)) {
47112
47357
  this.#finishFailed(active, transportFailure("protocol"));
47113
47358
  } else if (result.status === "succeeded") {
@@ -47341,13 +47586,15 @@ var ClaudeHarnessSession = class {
47341
47586
  }
47342
47587
  /** Completes held work after a quiet period with no further Root output. */
47343
47588
  #armContinuationQuiescence(active) {
47344
- this.#clearContinuationQuiescence();
47345
- if (!this.#occupancy.awaitingContinuation)
47589
+ if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open" || !this.#occupancy.awaitingContinuation) {
47346
47590
  return;
47591
+ }
47592
+ this.#clearContinuationQuiescence();
47347
47593
  const quiescence = setTimeout(() => {
47348
47594
  this.#continuationQuiescence = null;
47349
- if (this.#active !== active || !active.held || this.#phase !== "open")
47595
+ if (this.#active !== active || !active.held || active.rootSegmentActive || this.#phase !== "open") {
47350
47596
  return;
47597
+ }
47351
47598
  this.#occupancy.releaseContinuations();
47352
47599
  if (this.#occupancy.unsettled)
47353
47600
  return;
@@ -47362,7 +47609,8 @@ var ClaudeHarnessSession = class {
47362
47609
  clearTimeout(this.#continuationQuiescence);
47363
47610
  this.#continuationQuiescence = null;
47364
47611
  }
47365
- #observeRootOutput() {
47612
+ #observeRootOutput(active) {
47613
+ active.rootSegmentActive = true;
47366
47614
  this.#clearContinuationQuiescence();
47367
47615
  }
47368
47616
  #finish(active, outcome) {
@@ -47483,6 +47731,25 @@ var ClaudeHarnessSession = class {
47483
47731
  var ClaudeCodeAdapter = class {
47484
47732
  commandCatalog = claudeCommandCatalog;
47485
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
+ });
47486
47753
  subagents = {
47487
47754
  readSnapshot: async (input) => {
47488
47755
  if (input.parent.harnessId !== this.harnessId || input.nativeSubagentId.trim().length === 0) {
@@ -47526,6 +47793,9 @@ var ClaudeCodeAdapter = class {
47526
47793
  #cancelTimeoutMs;
47527
47794
  #closeTimeoutMs;
47528
47795
  #dependencies;
47796
+ #importAbort = new AbortController();
47797
+ #importIndex;
47798
+ #importRequests = /* @__PURE__ */ new Set();
47529
47799
  #pendingSessions;
47530
47800
  #toolOutputLimit;
47531
47801
  #continuationQuiescenceMs;
@@ -47537,7 +47807,9 @@ var ClaudeCodeAdapter = class {
47537
47807
  #latestPlanLimit = null;
47538
47808
  #accountInspection = null;
47539
47809
  constructor(options = {}, dependencies) {
47540
- this.#pendingSessions = new ClaudePendingSessions(options.environment ?? process.env);
47810
+ const environment = options.environment ?? process.env;
47811
+ this.#importIndex = new ClaudeSessionImportIndex(environment);
47812
+ this.#pendingSessions = new ClaudePendingSessions(environment);
47541
47813
  this.#closeTimeoutMs = options.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
47542
47814
  this.#cancelTimeoutMs = options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS;
47543
47815
  if (!Number.isSafeInteger(this.#cancelTimeoutMs) || this.#cancelTimeoutMs <= 0) {
@@ -47591,6 +47863,24 @@ var ClaudeCodeAdapter = class {
47591
47863
  readSubagentMessages: ({ cwd, sessionId, nativeSubagentId: nativeSubagentId2 }) => jkt(sessionId, nativeSubagentId2, { dir: cwd })
47592
47864
  };
47593
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
+ }
47594
47884
  async inspect(input = {}) {
47595
47885
  if (this.#closePromise) {
47596
47886
  return {
@@ -47598,7 +47888,7 @@ var ClaudeCodeAdapter = class {
47598
47888
  error: invalidState("Claude Code Adapter is closing")
47599
47889
  };
47600
47890
  }
47601
- const cwd = path10.resolve(input.cwd ?? process.cwd());
47891
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
47602
47892
  if (!input.refresh) {
47603
47893
  const cached2 = this.#inspectionCache.get(cwd);
47604
47894
  if (cached2)
@@ -47779,7 +48069,7 @@ var ClaudeCodeAdapter = class {
47779
48069
  }
47780
48070
  };
47781
48071
  }
47782
- const cwd = path10.resolve(input.cwd);
48072
+ const cwd = path11.resolve(input.cwd);
47783
48073
  if (input.kind === "rollbackLastTurn") {
47784
48074
  for (const source of this.#sessions) {
47785
48075
  const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
@@ -47888,8 +48178,10 @@ var ClaudeCodeAdapter = class {
47888
48178
  }
47889
48179
  close() {
47890
48180
  if (!this.#closePromise) {
48181
+ this.#importAbort.abort();
47891
48182
  this.#inspectionCache.clear();
47892
48183
  this.#closePromise = Promise.all([
48184
+ ...this.#importRequests,
47893
48185
  ...[...this.#inspectors].map((inspector) => inspector.close()),
47894
48186
  ...[...this.#sessions].map((session) => session.close()),
47895
48187
  ...this.#inspectionInFlight.values()
@@ -47900,8 +48192,8 @@ var ClaudeCodeAdapter = class {
47900
48192
  };
47901
48193
 
47902
48194
  // dist/user-shell-environment.js
47903
- import path11 from "node:path";
47904
- import { spawnSync } from "node:child_process";
48195
+ import path12 from "node:path";
48196
+ import { execFile as execFile2 } from "node:child_process";
47905
48197
  var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
47906
48198
  var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
47907
48199
  var SHELL_ENVIRONMENT_TIMEOUT_MS = 3e3;
@@ -47938,24 +48230,27 @@ function mergeMissingEnvironment(environment, shellEnvironment) {
47938
48230
  }
47939
48231
  return merged;
47940
48232
  }
47941
- function withUserShellEnvironment(environment, dependencies) {
48233
+ async function withUserShellEnvironment(environment, dependencies) {
47942
48234
  const platform = dependencies?.platform ?? process.platform;
47943
48235
  if (platform === "win32" || !environment.HOME)
47944
48236
  return environment;
47945
48237
  const shell = environment.SHELL?.trim() || defaultShell(platform);
47946
- if (!shell || !SUPPORTED_SHELLS.has(path11.basename(shell)))
48238
+ if (!shell || !SUPPORTED_SHELLS.has(path12.basename(shell)))
47947
48239
  return environment;
47948
48240
  const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
47949
48241
  const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);
47950
48242
  if (cached2)
47951
48243
  return mergeMissingEnvironment(environment, cached2);
47952
- const run = dependencies?.run ?? ((command, arguments_, options) => spawnSync(command, arguments_, {
47953
- ...options,
47954
- encoding: "buffer",
47955
- stdio: ["ignore", "pipe", "ignore"]
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();
47956
48251
  }));
47957
48252
  try {
47958
- const result = run(shell, ["-ilc", ENVIRONMENT_COMMAND], {
48253
+ const result = await run(shell, ["-ilc", ENVIRONMENT_COMMAND], {
47959
48254
  env: environment,
47960
48255
  maxBuffer: SHELL_ENVIRONMENT_MAX_BYTES,
47961
48256
  timeout: SHELL_ENVIRONMENT_TIMEOUT_MS,
@@ -47974,8 +48269,8 @@ function withUserShellEnvironment(environment, dependencies) {
47974
48269
 
47975
48270
  // dist/plugin.js
47976
48271
  var CLAUDE_CODE_COMMAND_ENV = "CODEXHOST_CLAUDE_COMMAND";
47977
- function createHarnessAdapter(context) {
47978
- const environment = withUserShellEnvironment({ ...context.environment });
48272
+ async function createHarnessAdapter(context) {
48273
+ const environment = await withUserShellEnvironment({ ...context.environment });
47979
48274
  if (context.platform === "darwin" && context.managedRemoteHost) {
47980
48275
  return new BrokeredHarnessAdapter({
47981
48276
  commandCatalog: claudeCommandCatalog,