@liberseek/boft-cli-win32-arm64 0.7.4 → 0.7.6

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.
@@ -771,10 +771,10 @@ function mergeDefs(...defs) {
771
771
  function cloneDef(schema) {
772
772
  return mergeDefs(schema._zod.def);
773
773
  }
774
- function getElementAtPath(obj, path8) {
775
- if (!path8)
774
+ function getElementAtPath(obj, path9) {
775
+ if (!path9)
776
776
  return obj;
777
- return path8.reduce((acc, key) => acc?.[key], obj);
777
+ return path9.reduce((acc, key) => acc?.[key], obj);
778
778
  }
779
779
  function promiseAllObject(promisesObj) {
780
780
  const keys = Object.keys(promisesObj);
@@ -1183,11 +1183,11 @@ function explicitlyAborted(x, startIndex = 0) {
1183
1183
  }
1184
1184
  return false;
1185
1185
  }
1186
- function prefixIssues(path8, issues) {
1186
+ function prefixIssues(path9, issues) {
1187
1187
  return issues.map((iss) => {
1188
1188
  var _a3;
1189
1189
  (_a3 = iss).path ?? (_a3.path = []);
1190
- iss.path.unshift(path8);
1190
+ iss.path.unshift(path9);
1191
1191
  return iss;
1192
1192
  });
1193
1193
  }
@@ -1334,16 +1334,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1334
1334
  }
1335
1335
  function formatError(error51, mapper = (issue2) => issue2.message) {
1336
1336
  const fieldErrors = { _errors: [] };
1337
- const processError = (error52, path8 = []) => {
1337
+ const processError = (error52, path9 = []) => {
1338
1338
  for (const issue2 of error52.issues) {
1339
1339
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1340
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1340
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1341
1341
  } else if (issue2.code === "invalid_key") {
1342
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1342
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1343
1343
  } else if (issue2.code === "invalid_element") {
1344
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1344
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1345
1345
  } else {
1346
- const fullpath = [...path8, ...issue2.path];
1346
+ const fullpath = [...path9, ...issue2.path];
1347
1347
  if (fullpath.length === 0) {
1348
1348
  fieldErrors._errors.push(mapper(issue2));
1349
1349
  } else {
@@ -1370,17 +1370,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1370
1370
  }
1371
1371
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1372
1372
  const result = { errors: [] };
1373
- const processError = (error52, path8 = []) => {
1373
+ const processError = (error52, path9 = []) => {
1374
1374
  var _a3, _b;
1375
1375
  for (const issue2 of error52.issues) {
1376
1376
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1377
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1377
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1378
1378
  } else if (issue2.code === "invalid_key") {
1379
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1379
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1380
1380
  } else if (issue2.code === "invalid_element") {
1381
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1381
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1382
1382
  } else {
1383
- const fullpath = [...path8, ...issue2.path];
1383
+ const fullpath = [...path9, ...issue2.path];
1384
1384
  if (fullpath.length === 0) {
1385
1385
  result.errors.push(mapper(issue2));
1386
1386
  continue;
@@ -1412,8 +1412,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1412
1412
  }
1413
1413
  function toDotPath(_path) {
1414
1414
  const segs = [];
1415
- const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1416
- for (const seg of path8) {
1415
+ const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1416
+ for (const seg of path9) {
1417
1417
  if (typeof seg === "number")
1418
1418
  segs.push(`[${seg}]`);
1419
1419
  else if (typeof seg === "symbol")
@@ -14105,13 +14105,13 @@ function resolveRef(ref, ctx) {
14105
14105
  if (!ref.startsWith("#")) {
14106
14106
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14107
14107
  }
14108
- const path8 = ref.slice(1).split("/").filter(Boolean);
14109
- if (path8.length === 0) {
14108
+ const path9 = ref.slice(1).split("/").filter(Boolean);
14109
+ if (path9.length === 0) {
14110
14110
  return ctx.rootSchema;
14111
14111
  }
14112
14112
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14113
- if (path8[0] === defsKey) {
14114
- const key = path8[1];
14113
+ if (path9[0] === defsKey) {
14114
+ const key = path9[1];
14115
14115
  if (!key || !ctx.defs[key]) {
14116
14116
  throw new Error(`Reference not found: ${ref}`);
14117
14117
  }
@@ -14574,6 +14574,55 @@ var credentialImportsParamsSchema = external_exports.object({
14574
14574
  request: credentialImportsRequestSchema
14575
14575
  }).strict();
14576
14576
 
14577
+ // ../../shared-contracts/dist/harness-display-settings.js
14578
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
14579
+ agent: external_exports.string().min(1).max(128),
14580
+ section: external_exports.enum(["main", "more", "auto"])
14581
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
14582
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
14583
+ entries: harnessDisplayEntriesSchema.nullable()
14584
+ });
14585
+ var harnessDisplayGetSchema = external_exports.strictObject({});
14586
+ var harnessDisplaySetSchema = external_exports.strictObject({
14587
+ entries: harnessDisplayEntriesSchema,
14588
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
14589
+ initializeOnly: external_exports.boolean().optional()
14590
+ });
14591
+
14592
+ // ../../shared-contracts/dist/console.js
14593
+ var consoleAnnouncementSchema = external_exports.strictObject({
14594
+ title: external_exports.string().trim().min(1).max(200),
14595
+ type: external_exports.enum(["info", "warning", "danger"]),
14596
+ body: external_exports.string().trim().min(1).max(16 * 1024)
14597
+ });
14598
+ var consoleOpenParamsSchema = external_exports.strictObject({});
14599
+ var consoleOpenResultSchema = external_exports.strictObject({
14600
+ /** The console address. */
14601
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
14602
+ });
14603
+ var CONSOLE_HOST_METHODS = Object.freeze([
14604
+ "codexhost/harness/plugins/list",
14605
+ "codexhost/harness/display-settings/get",
14606
+ "codexhost/harness/display-settings/set",
14607
+ "codexhost/harness/inspect",
14608
+ "codexhost/harness/launch-settings/get",
14609
+ "codexhost/harness/launch-settings/set",
14610
+ "codexhost/harness/web-ui/open",
14611
+ "codexhost/harness/accounts/sources",
14612
+ "codexhost/harness/accounts/list",
14613
+ "codexhost/harness/accounts/inspect",
14614
+ "codexhost/harness/credential-imports",
14615
+ "codexhost/harness/session-import/sources",
14616
+ "codexhost/harness/session-import/list",
14617
+ "codexhost/harness/session-import/import",
14618
+ "codexhost/account/list",
14619
+ "codexhost/account/refresh",
14620
+ "codexhost/account/usage/inspect",
14621
+ "codexhost/update/check",
14622
+ "codexhost/update/start",
14623
+ "codexhost/update/status"
14624
+ ]);
14625
+
14577
14626
  // ../../shared-contracts/dist/version.js
14578
14627
  var WORKSPACE_CONTRACT_VERSION = 1;
14579
14628
 
@@ -14627,6 +14676,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
14627
14676
  var hostItemIdSchema = opaqueIdSchema.brand();
14628
14677
  var hostInteractionIdSchema = opaqueIdSchema.brand();
14629
14678
 
14679
+ // ../../shared-contracts/dist/manual-compaction.js
14680
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
14681
+ threadId: hostThreadIdSchema,
14682
+ turnId: hostTurnIdSchema
14683
+ });
14684
+
14630
14685
  // ../../shared-contracts/dist/thread-usage.js
14631
14686
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14632
14687
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -14687,6 +14742,10 @@ var threadUsageSnapshotSchema = external_exports.object({
14687
14742
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
14688
14743
  var accountCreditsProductUsageSchema = external_exports.object({
14689
14744
  product: external_exports.string().min(1),
14745
+ used: external_exports.number().finite().nonnegative().optional(),
14746
+ // Zero is a real empty cap, not an absent field.
14747
+ limit: external_exports.number().finite().nonnegative().optional(),
14748
+ unit: external_exports.string().min(1).max(32).optional(),
14690
14749
  usagePercent: usagePercentSchema,
14691
14750
  resetsAt: external_exports.string().min(1).optional()
14692
14751
  }).strict();
@@ -14696,11 +14755,14 @@ var accountResetCreditsSchema = external_exports.object({
14696
14755
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
14697
14756
  }).strict();
14698
14757
  var accountCreditsSnapshotSchema = external_exports.object({
14758
+ used: external_exports.number().finite().nonnegative().optional(),
14759
+ // Zero is a real empty cap, not an absent field.
14760
+ limit: external_exports.number().finite().nonnegative().optional(),
14761
+ unit: external_exports.string().trim().min(1).max(32).optional(),
14699
14762
  /** Native label when the primary limit is scoped to a model or product group. */
14700
14763
  label: external_exports.string().min(1).optional(),
14701
14764
  usedPercent: usagePercentSchema.optional(),
14702
14765
  remaining: external_exports.number().finite().optional(),
14703
- unit: external_exports.string().trim().min(1).max(32).optional(),
14704
14766
  resetsAt: external_exports.string().min(1).optional(),
14705
14767
  periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
14706
14768
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
@@ -14731,12 +14793,27 @@ var threadUsageInspectionSchema = external_exports.object({
14731
14793
  }).strict();
14732
14794
 
14733
14795
  // ../../shared-contracts/dist/harness-accounts.js
14734
- var harnessAccountSnapshotSchema = external_exports.object({
14796
+ var accountBalanceSnapshotSchema = external_exports.object({
14797
+ amount: external_exports.number().finite().nonnegative(),
14798
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
14799
+ currency: external_exports.string().trim().min(1).max(8),
14800
+ /** Native label when the Harness exposes several Billing Sources. */
14801
+ label: external_exports.string().trim().min(1).max(128).optional()
14802
+ }).strict();
14803
+ var harnessAccountSnapshotObject = external_exports.object({
14735
14804
  email: external_exports.string().trim().min(1).max(320).optional(),
14736
14805
  label: external_exports.string().trim().min(1).max(256).optional(),
14737
14806
  plan: external_exports.string().trim().min(1).max(128).optional(),
14738
- credits: accountCreditsSnapshotSchema
14807
+ credits: accountCreditsSnapshotSchema.optional(),
14808
+ balance: accountBalanceSnapshotSchema.optional()
14739
14809
  }).strict();
14810
+ function requireReportedQuota(schema) {
14811
+ return schema.refine((value) => {
14812
+ const reported = value;
14813
+ return reported.credits !== void 0 || reported.balance !== void 0;
14814
+ }, { message: "Account must report either credits or a balance" });
14815
+ }
14816
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
14740
14817
  var harnessAccountIdentityShape = {
14741
14818
  harnessId: harnessIdSchema,
14742
14819
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -14747,11 +14824,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
14747
14824
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
14748
14825
  var harnessAccountInspectResultSchema = external_exports.object({
14749
14826
  ...harnessAccountIdentityShape,
14750
- account: harnessAccountSnapshotSchema.nullable()
14827
+ account: harnessAccountSnapshotSchema.nullable(),
14828
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
14829
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
14751
14830
  }).strict();
14752
14831
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
14753
14832
  var harnessAccountListResultSchema = external_exports.object({
14754
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
14833
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
14755
14834
  }).strict();
14756
14835
 
14757
14836
  // ../../shared-contracts/dist/json-value.js
@@ -14889,6 +14968,8 @@ var harnessModelSchema = external_exports.object({
14889
14968
  ref: harnessModelRefSchema,
14890
14969
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
14891
14970
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
14971
+ /** Optional opaque selection for this same Model with priority processing enabled. */
14972
+ fastModel: harnessModelRefSchema.optional(),
14892
14973
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
14893
14974
  }).strict();
14894
14975
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -14921,6 +15002,16 @@ var harnessModelCatalogSchema = external_exports.object({
14921
15002
  });
14922
15003
  }
14923
15004
  refs.add(model.ref.id);
15005
+ if (model.fastModel) {
15006
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15007
+ context.addIssue({
15008
+ code: "custom",
15009
+ message: "Fast Model refs must be distinct and unique",
15010
+ path: ["models", index, "fastModel"]
15011
+ });
15012
+ }
15013
+ refs.add(model.fastModel.id);
15014
+ }
14924
15015
  const supportedThinkingIds = /* @__PURE__ */ new Set();
14925
15016
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
14926
15017
  if (supportedThinkingIds.has(optionId)) {
@@ -15043,11 +15134,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
15043
15134
  thinkingOptionId: harnessThinkingOptionIdSchema
15044
15135
  }).strict();
15045
15136
  var threadInspectionParamsSchema = external_exports.object({
15046
- threadId: hostThreadIdSchema
15137
+ threadId: hostThreadIdSchema,
15138
+ includeReferenceCapability: external_exports.boolean().optional()
15047
15139
  }).strict();
15048
15140
  var codexThreadInspectionSchema = external_exports.object({
15049
15141
  owner: external_exports.literal("codex"),
15050
- locked: external_exports.literal(true)
15142
+ locked: external_exports.literal(true),
15143
+ supportsThreadReferences: external_exports.literal(true).optional()
15051
15144
  }).strict();
15052
15145
  var externalThreadInspectionSchema = external_exports.object({
15053
15146
  owner: external_exports.literal("external"),
@@ -15175,10 +15268,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
15175
15268
  restartRequired: external_exports.boolean()
15176
15269
  }).strict();
15177
15270
 
15271
+ // ../../shared-contracts/dist/harness-installation.js
15272
+ var harnessInstallationParamsSchema = external_exports.object({
15273
+ harnessId: harnessIdSchema,
15274
+ action: external_exports.enum(["check", "update"])
15275
+ }).strict();
15276
+ var harnessInstallationStateSchema = external_exports.object({
15277
+ currentVersion: external_exports.string().min(1).max(128),
15278
+ latestVersion: external_exports.string().min(1).max(128),
15279
+ updateAvailable: external_exports.boolean(),
15280
+ canUpdate: external_exports.boolean(),
15281
+ message: external_exports.string().max(2048).optional()
15282
+ }).strict();
15283
+
15178
15284
  // ../../shared-contracts/dist/codex-accounts.js
15179
15285
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15180
15286
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15181
15287
  var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
15288
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
15289
+ function isCodexAccountSiteUrl(value) {
15290
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
15291
+ }
15292
+ var externalUrlOpenParamsSchema = external_exports.object({
15293
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
15294
+ }).strict();
15295
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
15182
15296
  var codexAccountPlanTypeSchema = external_exports.enum([
15183
15297
  "free",
15184
15298
  "go",
@@ -15204,7 +15318,8 @@ var codexAccountSchema = external_exports.object({
15204
15318
  email: external_exports.string().email().max(320).optional(),
15205
15319
  planType: codexAccountPlanTypeSchema.optional(),
15206
15320
  authKind: codexAccountAuthKindSchema.optional(),
15207
- authIdentity: nonBlankTextSchema3.max(256).optional()
15321
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
15322
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
15208
15323
  }).strict();
15209
15324
  var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15210
15325
  var codexAccountListResultSchema = external_exports.object({
@@ -15906,7 +16021,7 @@ function commandPrompt(command, catalog, profile = CODEBUDDY_RUNTIME_PROFILE) {
15906
16021
  import { stat as stat2 } from "node:fs/promises";
15907
16022
 
15908
16023
  // dist/acp-client.js
15909
- import { execFile, spawn } from "node:child_process";
16024
+ import { execFile as execFile2, spawn } from "node:child_process";
15910
16025
  import { Readable as Readable2, Writable } from "node:stream";
15911
16026
 
15912
16027
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -20371,6 +20486,195 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
20371
20486
  return void 0;
20372
20487
  }
20373
20488
 
20489
+ // ../../harness-discovery/dist/installation.js
20490
+ import { execFile } from "node:child_process";
20491
+ import { homedir } from "node:os";
20492
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
20493
+ const env = withNodeRuntimeOnPath(environment);
20494
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
20495
+ return new Promise((resolve, reject) => {
20496
+ const child = execFile(invocation.command, invocation.arguments, {
20497
+ env,
20498
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
20499
+ encoding: "utf8",
20500
+ timeout,
20501
+ killSignal: "SIGKILL",
20502
+ maxBuffer: 1024 * 1024,
20503
+ windowsHide: true,
20504
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
20505
+ }, (error51, stdout, stderr) => {
20506
+ if (error51)
20507
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
20508
+ else
20509
+ resolve((stdout || stderr).trim());
20510
+ });
20511
+ child.stdin?.end();
20512
+ });
20513
+ }
20514
+ function installationVersion(value) {
20515
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
20516
+ throw new Error("Harness returned an invalid version");
20517
+ return value.trim().replace(/^v/, "");
20518
+ }
20519
+ function versionFromOutput(output) {
20520
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
20521
+ }
20522
+ function newerInstallationVersion(current, latest) {
20523
+ const a = installationVersion(current).replace(/\+.*/, "");
20524
+ const b = installationVersion(latest).replace(/\+.*/, "");
20525
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
20526
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
20527
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
20528
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
20529
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
20530
+ }
20531
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
20532
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
20533
+ if (!preA.length || !preB.length)
20534
+ return !!preA.length && !preB.length;
20535
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
20536
+ const x = preA[i];
20537
+ const y = preB[i];
20538
+ if (x === y)
20539
+ continue;
20540
+ if (x === void 0 || y === void 0)
20541
+ return x === void 0;
20542
+ const numericX = /^\d+$/.test(x);
20543
+ const numericY = /^\d+$/.test(y);
20544
+ if (numericX && numericY) {
20545
+ if (BigInt(x) === BigInt(y))
20546
+ continue;
20547
+ return BigInt(y) > BigInt(x);
20548
+ }
20549
+ if (numericX !== numericY)
20550
+ return numericX;
20551
+ return y > x;
20552
+ }
20553
+ return false;
20554
+ }
20555
+ function createInstallationManager(options) {
20556
+ let checking;
20557
+ let updating;
20558
+ const check2 = () => checking ??= options.check().finally(() => {
20559
+ checking = void 0;
20560
+ });
20561
+ return (action) => {
20562
+ if (updating)
20563
+ return updating;
20564
+ if (action === "check")
20565
+ return check2();
20566
+ updating = (async () => {
20567
+ const before = await check2();
20568
+ if (!before.updateAvailable)
20569
+ return before;
20570
+ if (!before.canUpdate)
20571
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
20572
+ await options.update(before);
20573
+ const after = await check2();
20574
+ if (after.currentVersion === before.currentVersion)
20575
+ throw new Error("The Harness version did not change; check the native updater and retry");
20576
+ return after;
20577
+ })().finally(() => {
20578
+ updating = void 0;
20579
+ });
20580
+ return updating;
20581
+ };
20582
+ }
20583
+ async function fetchInstallationText(url2) {
20584
+ const request = async () => {
20585
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
20586
+ if (!response.ok)
20587
+ throw new Error("Could not check the latest Harness version");
20588
+ return response.text();
20589
+ };
20590
+ try {
20591
+ return await request();
20592
+ } catch (error51) {
20593
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
20594
+ throw error51;
20595
+ return request();
20596
+ }
20597
+ }
20598
+
20599
+ // ../../harness-discovery/dist/npm-installation.js
20600
+ import { readFile, realpath } from "node:fs/promises";
20601
+ import path4 from "node:path";
20602
+ function referencesNpmBin(shim, name, bin) {
20603
+ if (bin.includes(".."))
20604
+ return false;
20605
+ const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
20606
+ const text2 = shim.replaceAll("\\", "/").toLowerCase();
20607
+ return text2.includes(`%dp0%/${target}"`) || text2.includes(`%~dp0/${target}"`);
20608
+ }
20609
+ async function npmInstallation(command, packages, environment) {
20610
+ let selected = await realpath(command);
20611
+ if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
20612
+ const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
20613
+ const root = path4.dirname(selected);
20614
+ for (const name of packages) {
20615
+ const directory2 = path4.join(root, "node_modules", ...name.split("/"));
20616
+ const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
20617
+ const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
20618
+ const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
20619
+ if (bin) {
20620
+ selected = await realpath(path4.join(directory2, bin));
20621
+ break;
20622
+ }
20623
+ }
20624
+ }
20625
+ let directory = path4.dirname(selected);
20626
+ for (let depth = 0; depth < 8; depth++) {
20627
+ const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text2) => JSON.parse(text2)).catch(() => null);
20628
+ if (metadata?.name && packages.includes(metadata.name)) {
20629
+ const name = metadata.name;
20630
+ const currentVersion = installationVersion(metadata.version);
20631
+ const segments = name.split("/");
20632
+ let modules = directory;
20633
+ for (let index = 0; index < segments.length; index++)
20634
+ modules = path4.dirname(modules);
20635
+ const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
20636
+ const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
20637
+ const env = withNodeRuntimeOnPath(environment);
20638
+ const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
20639
+ let globalInstall = modules === globalRoot;
20640
+ if (process.platform === "win32") {
20641
+ const project = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
20642
+ const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
20643
+ const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
20644
+ if (path4.basename(bin) !== bin || entry.includes(".."))
20645
+ return false;
20646
+ const target = await realpath(path4.join(directory, entry)).catch(() => "");
20647
+ if (target.toLowerCase() !== selected.toLowerCase())
20648
+ return false;
20649
+ const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
20650
+ return referencesNpmBin(shim, name, entry);
20651
+ }));
20652
+ globalInstall = globalInstall && !project && launchers.some(Boolean);
20653
+ }
20654
+ const canUpdate = globalInstall && !!npm;
20655
+ return {
20656
+ prefix,
20657
+ currentVersion,
20658
+ canUpdate,
20659
+ latest: async () => {
20660
+ const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
20661
+ return installationVersion(data.version);
20662
+ },
20663
+ update: async (version2) => {
20664
+ if (!canUpdate || !npm)
20665
+ throw new Error("Use the original package manager to update this installation");
20666
+ await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
20667
+ }
20668
+ };
20669
+ }
20670
+ const parent = path4.dirname(directory);
20671
+ if (parent === directory)
20672
+ break;
20673
+ directory = parent;
20674
+ }
20675
+ return null;
20676
+ }
20677
+
20374
20678
  // dist/command.js
20375
20679
  var codeBuddyDiscoverySpec = {
20376
20680
  id: "codebuddy",
@@ -20563,7 +20867,7 @@ var CodeBuddyAcpClient = class {
20563
20867
  }
20564
20868
  const pid = this.#child.pid;
20565
20869
  if (pid && process.platform === "win32") {
20566
- await new Promise((resolve) => execFile("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => resolve()));
20870
+ await new Promise((resolve) => execFile2("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => resolve()));
20567
20871
  } else if (pid) {
20568
20872
  try {
20569
20873
  process.kill(-pid, "SIGKILL");
@@ -20655,17 +20959,17 @@ function confirmedConfiguration(response, id, value, profile = CODEBUDDY_RUNTIME
20655
20959
 
20656
20960
  // dist/derivation.js
20657
20961
  import { randomUUID } from "node:crypto";
20658
- import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
20659
- import { lstat, mkdir, readFile as readFile2, realpath as realpath4, unlink, writeFile } from "node:fs/promises";
20660
- import path5 from "node:path";
20962
+ import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
20963
+ import { lstat, mkdir, readFile as readFile3, realpath as realpath5, unlink, writeFile } from "node:fs/promises";
20964
+ import path6 from "node:path";
20661
20965
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
20662
20966
 
20663
20967
  // dist/history.js
20664
20968
  import { createHash } from "node:crypto";
20665
20969
  import { realpathSync } from "node:fs";
20666
- import { access, readdir, realpath as realpath2 } from "node:fs/promises";
20667
- import { homedir } from "node:os";
20668
- import path4 from "node:path";
20970
+ import { access, readdir, realpath as realpath3 } from "node:fs/promises";
20971
+ import { homedir as homedir2 } from "node:os";
20972
+ import path5 from "node:path";
20669
20973
  import { isDeepStrictEqual } from "node:util";
20670
20974
 
20671
20975
  // ../../../node_modules/diff/libesm/diff/base.js
@@ -20768,16 +21072,16 @@ var Diff = class {
20768
21072
  }
20769
21073
  }
20770
21074
  }
20771
- addToPath(path8, added, removed, oldPosInc, options) {
20772
- const last = path8.lastComponent;
21075
+ addToPath(path9, added, removed, oldPosInc, options) {
21076
+ const last = path9.lastComponent;
20773
21077
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20774
21078
  return {
20775
- oldPos: path8.oldPos + oldPosInc,
21079
+ oldPos: path9.oldPos + oldPosInc,
20776
21080
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20777
21081
  };
20778
21082
  } else {
20779
21083
  return {
20780
- oldPos: path8.oldPos + oldPosInc,
21084
+ oldPos: path9.oldPos + oldPosInc,
20781
21085
  lastComponent: { count: 1, added, removed, previousComponent: last }
20782
21086
  };
20783
21087
  }
@@ -21329,9 +21633,9 @@ function codeBuddyDelegation(callId, input, status, childId, displayName = "Code
21329
21633
  }
21330
21634
 
21331
21635
  // dist/file-observation.js
21332
- import { readFile, realpath, stat } from "node:fs/promises";
21636
+ import { readFile as readFile2, realpath as realpath2, stat } from "node:fs/promises";
21333
21637
  async function codeBuddyFileVersion(file2) {
21334
- const [realFile, value] = await Promise.all([realpath(file2), stat(file2, { bigint: true })]);
21638
+ const [realFile, value] = await Promise.all([realpath2(file2), stat(file2, { bigint: true })]);
21335
21639
  return {
21336
21640
  realFile,
21337
21641
  fingerprint: `${value.dev}:${value.ino}:${value.size}:${value.mtimeNs}:${value.ctimeNs}`,
@@ -21345,7 +21649,7 @@ async function readCodeBuddyVersionedText(file2, maximumBytes, tooLargeMessage,
21345
21649
  const observedBefore = before ?? await codeBuddyFileVersion(file2);
21346
21650
  if (observedBefore.size > maximumBytes)
21347
21651
  throw new CodeBuddyError("unsupported", tooLargeMessage);
21348
- const contents = await readFile(file2, "utf8"), after = await codeBuddyFileVersion(file2), bytesRead = Buffer.byteLength(contents), reusableVersion = sameCodeBuddyFileVersion(observedBefore, after) && bytesRead === after.size ? after : void 0;
21652
+ const contents = await readFile2(file2, "utf8"), after = await codeBuddyFileVersion(file2), bytesRead = Buffer.byteLength(contents), reusableVersion = sameCodeBuddyFileVersion(observedBefore, after) && bytesRead === after.size ? after : void 0;
21349
21653
  if (bytesRead > maximumBytes || after.size > maximumBytes)
21350
21654
  throw new CodeBuddyError("unsupported", tooLargeMessage);
21351
21655
  return { contents, reusableVersion };
@@ -21362,15 +21666,15 @@ function codeBuddyCanonicalCwd(cwd) {
21362
21666
  try {
21363
21667
  return realpathSync.native(cwd);
21364
21668
  } catch {
21365
- return path4.resolve(cwd);
21669
+ return path5.resolve(cwd);
21366
21670
  }
21367
21671
  }
21368
21672
  function codeBuddyConfigRoot(environment, profile) {
21369
21673
  const configuredRoot = profile.configDirectoryEnvironmentVariables.map((name) => environment[name]).find((value) => typeof value === "string" && value.trim().length > 0);
21370
- return configuredRoot || path4.join(environment.HOME || environment.USERPROFILE || homedir(), profile.defaultConfigDirectoryName);
21674
+ return configuredRoot || path5.join(environment.HOME || environment.USERPROFILE || homedir2(), profile.defaultConfigDirectoryName);
21371
21675
  }
21372
21676
  function codeBuddyPrimaryHistoryPath(cwd, ref, environment, profile = CODEBUDDY_RUNTIME_PROFILE) {
21373
- return path4.join(codeBuddyConfigRoot(environment, profile), "projects", codeBuddyProjectSlug(cwd, profile), `${ref.nativeSessionId}.jsonl`);
21677
+ return path5.join(codeBuddyConfigRoot(environment, profile), "projects", codeBuddyProjectSlug(cwd, profile), `${ref.nativeSessionId}.jsonl`);
21374
21678
  }
21375
21679
  function derivedLocator(ref) {
21376
21680
  const locator = record2(ref.locator);
@@ -21404,8 +21708,8 @@ function validateNativeRef(ref, profile = CODEBUDDY_RUNTIME_PROFILE) {
21404
21708
  }
21405
21709
  }
21406
21710
  async function sameCwd(left, right) {
21407
- const b = await realpath2(right);
21408
- const a = await realpath2(left).catch((error51) => {
21711
+ const b = await realpath3(right);
21712
+ const a = await realpath3(left).catch((error51) => {
21409
21713
  if (["ENOENT", "ENOTDIR"].includes(String(record2(error51).code)))
21410
21714
  throw new CodeBuddyError("invalidRequest", "Native Session historical working directory is unavailable; ownership cannot be verified");
21411
21715
  throw error51;
@@ -21413,9 +21717,9 @@ async function sameCwd(left, right) {
21413
21717
  return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
21414
21718
  }
21415
21719
  async function matchesAnyHistoricalCwd(value, candidates) {
21416
- const resolved = path4.resolve(value);
21720
+ const resolved = path5.resolve(value);
21417
21721
  for (const candidate of candidates) {
21418
- const other = path4.resolve(candidate);
21722
+ const other = path5.resolve(candidate);
21419
21723
  if (process.platform === "win32" ? resolved.toLowerCase() === other.toLowerCase() : resolved === other)
21420
21724
  return true;
21421
21725
  try {
@@ -21439,9 +21743,9 @@ async function codeBuddyLiveNativeHistory(cwd, ref, environment, profile = CODEB
21439
21743
  async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, profile, transaction) {
21440
21744
  validateNativeRef(ref, profile);
21441
21745
  const configRoot = codeBuddyConfigRoot(environment, profile);
21442
- const root = path4.join(configRoot, "projects");
21746
+ const root = path5.join(configRoot, "projects");
21443
21747
  const slug = codeBuddyProjectSlug(cwd, profile);
21444
- const primary = path4.join(root, slug, `${ref.nativeSessionId}.jsonl`);
21748
+ const primary = path5.join(root, slug, `${ref.nativeSessionId}.jsonl`);
21445
21749
  const provenance = derivedLocator(ref);
21446
21750
  let candidates = [];
21447
21751
  try {
@@ -21460,7 +21764,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
21460
21764
  for (const directory of directories) {
21461
21765
  if (!directory.isDirectory())
21462
21766
  continue;
21463
- const file3 = path4.join(root, directory.name, `${ref.nativeSessionId}.jsonl`);
21767
+ const file3 = path5.join(root, directory.name, `${ref.nativeSessionId}.jsonl`);
21464
21768
  try {
21465
21769
  await access(file3);
21466
21770
  candidates.push(file3);
@@ -21475,7 +21779,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
21475
21779
  const file2 = candidates[0];
21476
21780
  if (!file2)
21477
21781
  throw new CodeBuddyError("sessionNotFound", "Native Session history was not found");
21478
- if (profile.historyCapabilities?.fork && !transaction && path4.resolve(file2) !== path4.resolve(primary))
21782
+ if (profile.historyCapabilities?.fork && !transaction && path5.resolve(file2) !== path5.resolve(primary))
21479
21783
  throw new CodeBuddyError("invalidRequest", "Native Session is not stored in the requested working directory");
21480
21784
  const source = await readCodeBuddyVersionedText(file2, 64e6, "Native history exceeds the supported 64 MB snapshot size"), parsed = parseJsonl(source.contents, tolerateIncompleteTail);
21481
21785
  const checkedDirectories = /* @__PURE__ */ new Set();
@@ -21504,7 +21808,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
21504
21808
  }
21505
21809
  }
21506
21810
  } else if (provenance) {
21507
- if (!await sameCwd(provenance.boundCwd, cwd) || provenance.targetProjectSlug !== slug || path4.resolve(file2) !== path4.resolve(primary))
21811
+ if (!await sameCwd(provenance.boundCwd, cwd) || provenance.targetProjectSlug !== slug || path5.resolve(file2) !== path5.resolve(primary))
21508
21812
  throw new CodeBuddyError("invalidRequest", "Derived Native Session target binding changed");
21509
21813
  const active = nativeHistoryRows(parsed.contents);
21510
21814
  if (provenance.inheritedPrefixRows > active.length || nativeRowsDigest(active.slice(0, provenance.inheritedPrefixRows)) !== provenance.inheritedPrefixSha256)
@@ -21798,7 +22102,7 @@ function historyUsage(contents) {
21798
22102
 
21799
22103
  // dist/child-provenance.js
21800
22104
  import { createHash as createHash2 } from "node:crypto";
21801
- import { realpath as realpath3 } from "node:fs/promises";
22105
+ import { realpath as realpath4 } from "node:fs/promises";
21802
22106
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
21803
22107
  var CODEBUDDY_CHILD_MAX_BYTES = 8e6;
21804
22108
  var equalPath = (left, right) => process.platform === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
@@ -21866,7 +22170,7 @@ function codeBuddyInheritedChild(parent, childId) {
21866
22170
  async function canonicalCwds(cwds) {
21867
22171
  const result = /* @__PURE__ */ new Map();
21868
22172
  for (const cwd of new Set(cwds)) {
21869
- const canonical = await realpath3(cwd).catch((error51) => {
22173
+ const canonical = await realpath4(cwd).catch((error51) => {
21870
22174
  if (["ENOENT", "ENOTDIR"].includes(String(record2(error51).code)))
21871
22175
  throw new CodeBuddyError("invalidRequest", "Subagent historical working directory is unavailable; ownership cannot be verified");
21872
22176
  throw error51;
@@ -21905,7 +22209,7 @@ async function validateCodeBuddyChildContents(contents, parent, childId, cwd, to
21905
22209
  throw new CodeBuddyError("protocolError", "Inherited Subagent identity changed");
21906
22210
  inheritedEntries = prefixParsed.entries;
21907
22211
  }
21908
- const target = await realpath3(cwd);
22212
+ const target = await realpath4(cwd);
21909
22213
  const inheritedCwds = inheritedEntries.flatMap((row) => typeof row.cwd === "string" ? [row.cwd] : []);
21910
22214
  const suffixCwds = parsed.entries.slice(inheritedEntries.length).flatMap((row) => typeof row.cwd === "string" ? [row.cwd] : []);
21911
22215
  const canonical = await canonicalCwds(suffixCwds);
@@ -22041,7 +22345,7 @@ async function copyCodeBuddySession(cwd, sourceId, targetId, environment, signal
22041
22345
  child.stderr.destroy();
22042
22346
  } else if (process.platform === "win32" && child.pid) {
22043
22347
  termination = new Promise((done) => {
22044
- execFile2("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => {
22348
+ execFile3("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => {
22045
22349
  child.kill();
22046
22350
  done();
22047
22351
  });
@@ -22148,20 +22452,20 @@ async function bridgeCopyToTarget(sourceCwd, targetCwd, ref, contents, environme
22148
22452
  const targetFile = codeBuddyPrimaryHistoryPath(targetCwd, ref, environment, profile);
22149
22453
  if (sameResolvedPath(sourceFile, targetFile))
22150
22454
  return void 0;
22151
- const targetDirectory = path5.dirname(targetFile);
22152
- const projectsDirectory = path5.dirname(targetDirectory);
22455
+ const targetDirectory = path6.dirname(targetFile);
22456
+ const projectsDirectory = path6.dirname(targetDirectory);
22153
22457
  await mkdir(targetDirectory, { recursive: true });
22154
22458
  const [realProjects, realTargetDirectory] = await Promise.all([
22155
- realpath4(projectsDirectory),
22156
- realpath4(targetDirectory)
22459
+ realpath5(projectsDirectory),
22460
+ realpath5(targetDirectory)
22157
22461
  ]);
22158
- if (!sameResolvedPath(realTargetDirectory, path5.join(realProjects, codeBuddyProjectSlug(targetCwd, profile))))
22462
+ if (!sameResolvedPath(realTargetDirectory, path6.join(realProjects, codeBuddyProjectSlug(targetCwd, profile))))
22159
22463
  throw new CodeBuddyError("invalidRequest", "Cross-directory history bridge target escaped the native projects root");
22160
22464
  const expected = Buffer.from(contents, "utf8");
22161
22465
  await writeFile(targetFile, expected, { flag: "wx", mode: 384 });
22162
22466
  const bridge = { file: targetFile, expected };
22163
22467
  try {
22164
- const persisted = await readFile2(targetFile);
22468
+ const persisted = await readFile3(targetFile);
22165
22469
  if (!isDeepStrictEqual3(persisted, expected))
22166
22470
  throw new CodeBuddyError("nativeFailure", "Cross-directory history bridge changed native bytes");
22167
22471
  return bridge;
@@ -22176,7 +22480,7 @@ async function cleanupBridge(bridge) {
22176
22480
  const info = await lstat(bridge.file);
22177
22481
  if (!info.isFile() || process.platform !== "win32" && (info.mode & 63) !== 0)
22178
22482
  return;
22179
- if (!isDeepStrictEqual3(await readFile2(bridge.file), bridge.expected))
22483
+ if (!isDeepStrictEqual3(await readFile3(bridge.file), bridge.expected))
22180
22484
  return;
22181
22485
  await unlink(bridge.file);
22182
22486
  } catch (error51) {
@@ -22262,7 +22566,7 @@ function assertChildRanges(rows2, child) {
22262
22566
  }
22263
22567
  }
22264
22568
  async function plainDirectory(parent, name) {
22265
- const directory = path5.join(parent, name);
22569
+ const directory = path6.join(parent, name);
22266
22570
  await mkdir(directory, { mode: 448 }).catch((error51) => {
22267
22571
  if (record2(error51).code !== "EEXIST")
22268
22572
  throw error51;
@@ -22270,7 +22574,7 @@ async function plainDirectory(parent, name) {
22270
22574
  const info = await lstat(directory);
22271
22575
  if (!info.isDirectory() || info.isSymbolicLink() || process.platform !== "win32" && (info.mode & 18) !== 0)
22272
22576
  throw new CodeBuddyError("invalidRequest", "Redirected native Subagent directory");
22273
- const actual = await realpath4(directory);
22577
+ const actual = await realpath5(directory);
22274
22578
  if (!sameResolvedPath(actual, directory))
22275
22579
  throw new CodeBuddyError("invalidRequest", "Redirected native Subagent directory");
22276
22580
  return directory;
@@ -22279,7 +22583,7 @@ async function verifiedChildFile(file2, expected) {
22279
22583
  const info = await lstat(file2);
22280
22584
  if (!info.isFile() || info.isSymbolicLink() || process.platform !== "win32" && (info.mode & 63) !== 0)
22281
22585
  throw new CodeBuddyError("invalidRequest", "Unsafe derived Subagent transcript");
22282
- if (!sameResolvedPath(await realpath4(file2), file2))
22586
+ if (!sameResolvedPath(await realpath5(file2), file2))
22283
22587
  throw new CodeBuddyError("invalidRequest", "Redirected derived Subagent transcript");
22284
22588
  const before = await codeBuddyFileVersion(file2);
22285
22589
  const actual = await readCodeBuddyVersionedText(file2, CODEBUDDY_CHILD_MAX_BYTES, "Subagent transcript exceeds 8 MB", before);
@@ -22307,19 +22611,19 @@ async function copyInheritedChildren(options) {
22307
22611
  const { references } = options;
22308
22612
  if (!references.length)
22309
22613
  return { descriptors: [], created: [] };
22310
- const sourceHistoryFile = await realpath4(options.sourceHistoryFile);
22311
- const sourceProject = path5.dirname(sourceHistoryFile);
22312
- if (!sameResolvedPath(sourceHistoryFile, path5.join(sourceProject, `${options.sourceRef.nativeSessionId}.jsonl`)))
22614
+ const sourceHistoryFile = await realpath5(options.sourceHistoryFile);
22615
+ const sourceProject = path6.dirname(sourceHistoryFile);
22616
+ if (!sameResolvedPath(sourceHistoryFile, path6.join(sourceProject, `${options.sourceRef.nativeSessionId}.jsonl`)))
22313
22617
  throw new CodeBuddyError("invalidRequest", "Unexpected source history location");
22314
- const sourceDirectory = path5.join(sourceProject, options.sourceRef.nativeSessionId, "subagents");
22618
+ const sourceDirectory = path6.join(sourceProject, options.sourceRef.nativeSessionId, "subagents");
22315
22619
  const sourceDirectoryInfo = await lstat(sourceDirectory);
22316
22620
  if (!sourceDirectoryInfo.isDirectory() || sourceDirectoryInfo.isSymbolicLink())
22317
22621
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent directory");
22318
- if (!sameResolvedPath(await realpath4(sourceDirectory), sourceDirectory))
22622
+ if (!sameResolvedPath(await realpath5(sourceDirectory), sourceDirectory))
22319
22623
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent directory");
22320
- const targetHistoryFile = await realpath4(options.targetHistoryFile);
22321
- const targetProject = path5.dirname(targetHistoryFile);
22322
- if (!sameResolvedPath(targetHistoryFile, path5.join(targetProject, `${options.targetRef.nativeSessionId}.jsonl`)))
22624
+ const targetHistoryFile = await realpath5(options.targetHistoryFile);
22625
+ const targetProject = path6.dirname(targetHistoryFile);
22626
+ if (!sameResolvedPath(targetHistoryFile, path6.join(targetProject, `${options.targetRef.nativeSessionId}.jsonl`)))
22323
22627
  throw new CodeBuddyError("invalidRequest", "Unexpected target history location");
22324
22628
  const targetSessionDirectory = await plainDirectory(targetProject, options.targetRef.nativeSessionId);
22325
22629
  const targetDirectory = await plainDirectory(targetSessionDirectory, "subagents");
@@ -22327,7 +22631,7 @@ async function copyInheritedChildren(options) {
22327
22631
  const created = [];
22328
22632
  try {
22329
22633
  for (const reference of references) {
22330
- const sourceFile = path5.join(sourceDirectory, `${reference.childId}.jsonl`);
22634
+ const sourceFile = path6.join(sourceDirectory, `${reference.childId}.jsonl`);
22331
22635
  const sourceInfo = await lstat(sourceFile);
22332
22636
  if (!sourceInfo.isFile() || sourceInfo.isSymbolicLink())
22333
22637
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent transcript");
@@ -22346,7 +22650,7 @@ async function copyInheritedChildren(options) {
22346
22650
  throw new CodeBuddyError("protocolError", "Missing Agent result child range");
22347
22651
  const prefix = await codeBuddyChildPrefixThrough(source.contents, last, validated);
22348
22652
  const expected = Buffer.from(prefix.contents, "utf8");
22349
- const targetFile = path5.join(targetDirectory, `${reference.childId}.jsonl`);
22653
+ const targetFile = path6.join(targetDirectory, `${reference.childId}.jsonl`);
22350
22654
  const copy = await persistChildCopy(targetFile, expected);
22351
22655
  if (copy)
22352
22656
  created.push(copy);
@@ -22725,8 +23029,8 @@ var CodeBuddyInteractions = class {
22725
23029
  };
22726
23030
 
22727
23031
  // dist/subagent-history.js
22728
- import { readdir as readdir2, realpath as realpath5 } from "node:fs/promises";
22729
- import path6 from "node:path";
23032
+ import { readdir as readdir2, realpath as realpath6 } from "node:fs/promises";
23033
+ import path7 from "node:path";
22730
23034
  var equalPath2 = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
22731
23035
  var MAX_CACHED_CHILDREN = 16;
22732
23036
  var CodeBuddyChildObserver = class {
@@ -22753,9 +23057,9 @@ var CodeBuddyChildObserver = class {
22753
23057
  throw new CodeBuddyError("invalidRequest", "Subagent observer is closed");
22754
23058
  }
22755
23059
  async #validateWorkspaces(cwds) {
22756
- const expected = await realpath5(this.cwd);
23060
+ const expected = await realpath6(this.cwd);
22757
23061
  for (const cwd of new Set(cwds)) {
22758
- const actual = await realpath5(cwd).catch((error51) => {
23062
+ const actual = await realpath6(cwd).catch((error51) => {
22759
23063
  if (["ENOENT", "ENOTDIR"].includes(String(record2(error51).code)))
22760
23064
  throw new CodeBuddyError("invalidRequest", "Native Session historical working directory is unavailable; ownership cannot be verified");
22761
23065
  throw error51;
@@ -22790,9 +23094,9 @@ var CodeBuddyChildObserver = class {
22790
23094
  }
22791
23095
  async #directory() {
22792
23096
  const history = await this.#parentHistory();
22793
- const project = path6.dirname(await realpath5(history.file));
22794
- const expected = path6.join(project, this.parent.nativeSessionId, "subagents");
22795
- const actual = await realpath5(expected);
23097
+ const project = path7.dirname(await realpath6(history.file));
23098
+ const expected = path7.join(project, this.parent.nativeSessionId, "subagents");
23099
+ const actual = await realpath6(expected);
22796
23100
  this.#assertOpen();
22797
23101
  if (!equalPath2(actual, expected))
22798
23102
  throw new CodeBuddyError("invalidRequest", `Redirected ${this.profile.displayName} Subagent directory`);
@@ -22801,7 +23105,7 @@ var CodeBuddyChildObserver = class {
22801
23105
  async #child(directory, childId) {
22802
23106
  if (!validCodeBuddyChildId(childId))
22803
23107
  throw new CodeBuddyError("invalidRequest", "Invalid native Subagent ID");
22804
- const file2 = path6.join(directory, `${childId}.jsonl`);
23108
+ const file2 = path7.join(directory, `${childId}.jsonl`);
22805
23109
  const before = await codeBuddyFileVersion(file2);
22806
23110
  if (!equalPath2(before.realFile, file2))
22807
23111
  throw new CodeBuddyError("invalidRequest", "Redirected Subagent transcript");
@@ -23686,9 +23990,40 @@ var CodeBuddyAdapter = class {
23686
23990
  }
23687
23991
  };
23688
23992
 
23993
+ // dist/installation.js
23994
+ function createCodeBuddyInstallation(environment) {
23995
+ let update;
23996
+ return createInstallationManager({
23997
+ async check() {
23998
+ const resolved = resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment });
23999
+ if (!resolved)
24000
+ throw new Error("CodeBuddy is not installed");
24001
+ const currentVersion = versionFromOutput(await runInstallationCommand(resolved.executable, ["--version"], environment));
24002
+ const npm = await npmInstallation(resolved.executable, ["@tencent-ai/codebuddy-code"], environment);
24003
+ update = npm?.update;
24004
+ const latestVersion = npm ? await npm.latest() : "Unknown";
24005
+ const canUpdate = npm?.canUpdate ?? false;
24006
+ return {
24007
+ currentVersion,
24008
+ latestVersion,
24009
+ updateAvailable: !!npm && newerInstallationVersion(currentVersion, latestVersion),
24010
+ canUpdate,
24011
+ ...!canUpdate ? {
24012
+ message: "Use CodeBuddy's native updater or original package manager for this installation. Latest-version checks here require an identified npm installation."
24013
+ } : {}
24014
+ };
24015
+ },
24016
+ async update(state) {
24017
+ if (!update)
24018
+ throw new Error("This CodeBuddy installation requires a manual update");
24019
+ await update(state.latestVersion);
24020
+ }
24021
+ });
24022
+ }
24023
+
23689
24024
  // ../../harness-broker/dist/client.js
23690
24025
  import { randomUUID as randomUUID2 } from "node:crypto";
23691
- import { lstat as lstat2, readFile as readFile3 } from "node:fs/promises";
24026
+ import { lstat as lstat2, readFile as readFile4 } from "node:fs/promises";
23692
24027
  import net, {} from "node:net";
23693
24028
 
23694
24029
  // ../../harness-broker/dist/protocol.js
@@ -23806,24 +24141,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
23806
24141
 
23807
24142
  // ../../harness-broker/dist/paths.js
23808
24143
  import os2 from "node:os";
23809
- import path7 from "node:path";
24144
+ import path8 from "node:path";
23810
24145
  var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
23811
24146
  var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
23812
24147
  function defaultHarnessBrokerDirectory(environment = process.env) {
23813
24148
  const home = environment.HOME || os2.homedir();
23814
- return path7.join(home, ".codexhost", "harness-broker");
24149
+ return path8.join(home, ".codexhost", "harness-broker");
23815
24150
  }
23816
24151
  function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
23817
24152
  harnessPluginIdSchema.parse(harnessId);
23818
24153
  if (harnessId !== "claude-code")
23819
- return path7.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
23820
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path7.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
24154
+ return path8.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
24155
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path8.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
23821
24156
  }
23822
24157
 
23823
24158
  // ../../harness-broker/dist/validation.js
23824
24159
  var cwdSchema = external_exports.string().min(1).max(16384);
23825
24160
  var brokerEnvironmentSchema = external_exports.object({
23826
24161
  CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
24162
+ CODEXHOST_CLI_NODE_PATH: external_exports.string().max(16384).optional(),
23827
24163
  CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
23828
24164
  CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
23829
24165
  CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
@@ -23999,6 +24335,7 @@ var eventKeys = /* @__PURE__ */ new Map([
23999
24335
  ["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
24000
24336
  ["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
24001
24337
  ["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
24338
+ ["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
24002
24339
  ["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
24003
24340
  ["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome", "completedAtMs"])],
24004
24341
  ["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
@@ -24127,7 +24464,7 @@ async function readDescriptor(descriptorPath) {
24127
24464
  throw new Error("Aqua Harness broker descriptor belongs to another user");
24128
24465
  }
24129
24466
  }
24130
- const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile3(descriptorPath, "utf8")));
24467
+ const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile4(descriptorPath, "utf8")));
24131
24468
  if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
24132
24469
  throw new Error("Aqua Harness broker socket path is too long for macOS");
24133
24470
  }
@@ -24646,6 +24983,7 @@ var BrokeredHarnessAdapter = class {
24646
24983
  if (this.#forwardEnvironment && input.environment) {
24647
24984
  const allowed = [
24648
24985
  "CODEXHOST_CLI_PATH",
24986
+ "CODEXHOST_CLI_NODE_PATH",
24649
24987
  "CODEXHOST_RUNTIME_ENDPOINT",
24650
24988
  "CODEXHOST_RUNTIME_TOKEN",
24651
24989
  "CODEXHOST_THREAD_ID"
@@ -24711,7 +25049,10 @@ function createHarnessAdapter(context) {
24711
25049
  liveCommandCatalog: true,
24712
25050
  environment: { ...context.environment }
24713
25051
  });
24714
- return new CodeBuddyAdapter({ environment: { ...context.environment } });
25052
+ const environment = { ...context.environment };
25053
+ return Object.assign(new CodeBuddyAdapter({ environment }), {
25054
+ installation: createCodeBuddyInstallation(environment)
25055
+ });
24715
25056
  }
24716
25057
  export {
24717
25058
  createHarnessAdapter