@codexhost/cli-linux-arm64 0.13.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14662,10 +14662,19 @@ var model = external_exports.string().min(1).max(512);
14662
14662
  var project = external_exports.string().min(1).max(4096);
14663
14663
  var usageStatisticsParamsSchema = external_exports.strictObject({
14664
14664
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14665
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
14666
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
14667
+ try {
14668
+ new Intl.DateTimeFormat("en", { timeZone: value });
14669
+ return true;
14670
+ } catch {
14671
+ return false;
14672
+ }
14673
+ }, "Unsupported usage statistics timezone").optional(),
14665
14674
  harness: harness.optional(),
14666
14675
  model: model.nullable().optional(),
14667
14676
  project: project.nullable().optional(),
14668
- /** One local date inside the range. */
14677
+ /** One date in the query timezone inside the range. */
14669
14678
  date: localDate.optional()
14670
14679
  });
14671
14680
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -14701,7 +14710,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
14701
14710
  });
14702
14711
  var usageStatisticsResultSchema = external_exports.strictObject({
14703
14712
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
14704
- /** First local date of the range; null for all time. */
14713
+ /** First date in the query timezone (Host local when omitted); null for all time. */
14705
14714
  from: localDate.nullable(),
14706
14715
  to: localDate,
14707
14716
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -14741,7 +14750,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
14741
14750
  totals: usageStatisticsTotalsSchema,
14742
14751
  /** Each date and Harness of the range: every filter except the day. */
14743
14752
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
14744
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
14753
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
14745
14754
  hourly: external_exports.array(external_exports.strictObject({
14746
14755
  weekday: external_exports.number().int().min(0).max(6),
14747
14756
  hour: external_exports.number().int().min(0).max(23),
@@ -14801,6 +14810,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
14801
14810
  "codexhost/harness/display-settings/set",
14802
14811
  "codexhost/harness/inspect",
14803
14812
  "codexhost/harness/installation",
14813
+ "codexhost/harness/installation/start",
14814
+ "codexhost/harness/installation/status",
14804
14815
  "codexhost/harness/launch-settings/get",
14805
14816
  "codexhost/harness/launch-settings/set",
14806
14817
  "codexhost/harness/web-ui/open",
@@ -14876,7 +14887,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
14876
14887
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14877
14888
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14878
14889
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14890
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
14891
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
14892
+ kind: external_exports.literal("countdown"),
14893
+ id: external_exports.string().min(1).max(64),
14894
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
14895
+ label: indicatorTextSchema(256).optional(),
14896
+ tooltip: indicatorTextSchema(1024).optional()
14897
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
14898
+ message: "Composer indicator IDs must be unique"
14899
+ });
14879
14900
  var threadUsageSnapshotSchema = external_exports.object({
14901
+ composerIndicators: composerIndicatorsSchema.optional(),
14880
14902
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
14881
14903
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
14882
14904
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15284,7 +15306,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15284
15306
  }).strict().optional(),
15285
15307
  autonomousTurns: external_exports.object({
15286
15308
  observe: external_exports.boolean()
15287
- }).strict().optional()
15309
+ }).strict().optional(),
15310
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15311
+ steer: external_exports.boolean().optional()
15288
15312
  }).strict();
15289
15313
  var harnessConfigurationStateSchema = external_exports.object({
15290
15314
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15331,7 +15355,9 @@ var harnessInspectionSchema = external_exports.union([
15331
15355
  var harnessInspectParamsSchema = external_exports.object({
15332
15356
  harnessId: harnessIdSchema,
15333
15357
  cwd: nonBlankTextSchema2.max(16384).optional(),
15334
- refresh: external_exports.boolean().optional()
15358
+ refresh: external_exports.boolean().optional(),
15359
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15360
+ purpose: external_exports.literal("availability").optional()
15335
15361
  }).strict();
15336
15362
  var harnessWebUiOpenParamsSchema = external_exports.object({
15337
15363
  harnessId: harnessIdSchema
@@ -15414,6 +15440,15 @@ var threadOwnershipListResultSchema = external_exports.object({
15414
15440
  seen.add(thread.threadId);
15415
15441
  }
15416
15442
  });
15443
+ var threadSteeringInspectParamsSchema = external_exports.object({
15444
+ threadId: hostThreadIdSchema,
15445
+ /** The text about to be steered; a Harness command always stops and restarts. */
15446
+ text: external_exports.string().optional()
15447
+ }).strict();
15448
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15449
+ var threadSteeringInspectResultSchema = external_exports.object({
15450
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15451
+ }).strict();
15417
15452
 
15418
15453
  // ../../shared-contracts/dist/harness-plugins.js
15419
15454
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
@@ -15515,6 +15550,10 @@ var harnessInstallationStateSchema = external_exports.object({
15515
15550
  latestVersion: external_exports.string().min(1).max(128),
15516
15551
  updateAvailable: external_exports.boolean(),
15517
15552
  canUpdate: external_exports.boolean(),
15553
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
15554
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
15555
+ /** Official download opened by the user; does not imply an automatic installation. */
15556
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
15518
15557
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15519
15558
  message: external_exports.string().max(2048).optional(),
15520
15559
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -15522,6 +15561,20 @@ var harnessInstallationStateSchema = external_exports.object({
15522
15561
  notice: harnessLocalizedTextSchema.optional(),
15523
15562
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15524
15563
  }).strict();
15564
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
15565
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
15566
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
15567
+ external_exports.object({
15568
+ taskId: external_exports.string().uuid(),
15569
+ status: external_exports.literal("succeeded"),
15570
+ result: harnessInstallationStateSchema
15571
+ }).strict(),
15572
+ external_exports.object({
15573
+ taskId: external_exports.string().uuid(),
15574
+ status: external_exports.literal("failed"),
15575
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
15576
+ }).strict()
15577
+ ]);
15525
15578
 
15526
15579
  // ../../shared-contracts/dist/codex-accounts.js
15527
15580
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -16024,6 +16077,18 @@ function sanitizeDiagnosticTail(value) {
16024
16077
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16025
16078
  }
16026
16079
 
16080
+ // ../../harness-adapter/dist/steer.js
16081
+ function unsupportedSteer(harnessLabel) {
16082
+ return {
16083
+ ok: false,
16084
+ error: {
16085
+ code: "unsupported",
16086
+ message: `${harnessLabel} cannot steer an active Turn natively`,
16087
+ retryable: false
16088
+ }
16089
+ };
16090
+ }
16091
+
16027
16092
  // ../../harness-adapter/dist/usage.js
16028
16093
  var tokenFields = [
16029
16094
  "inputTokens",
@@ -16051,6 +16116,7 @@ var usageFields = /* @__PURE__ */ new Set([
16051
16116
  ...safeIntegerFields,
16052
16117
  ...percentFields,
16053
16118
  "sessionCacheUsage",
16119
+ "composerIndicators",
16054
16120
  "totalCostUsd",
16055
16121
  "totalCredits",
16056
16122
  "contextUsagePercent",
@@ -16073,6 +16139,7 @@ function parseHostUsage(value) {
16073
16139
  throw new Error(`Harness Usage contains unknown field '${key}'`);
16074
16140
  }
16075
16141
  }
16142
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
16076
16143
  for (const field of [
16077
16144
  "totalCredits",
16078
16145
  "contextUsagePercent",
@@ -16143,9 +16210,9 @@ function parseHostUsage(value) {
16143
16210
  if (value.costSource !== "publicPrice") {
16144
16211
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
16145
16212
  }
16146
- return { ...value, unpricedModels: [...models] };
16213
+ return { ...value, ...indicators, unpricedModels: [...models] };
16147
16214
  }
16148
- return { ...value };
16215
+ return { ...value, ...indicators };
16149
16216
  }
16150
16217
  var requestTokenFields = [
16151
16218
  "inputTokens",
@@ -16302,6 +16369,7 @@ var harnessBrokerMethodSchema = external_exports.enum([
16302
16369
  "adapter.open",
16303
16370
  "adapter.subagent.readSnapshot",
16304
16371
  "session.readSnapshot",
16372
+ "session.readCapabilities",
16305
16373
  "session.refreshUsage",
16306
16374
  "session.execute",
16307
16375
  "session.commands.list",
@@ -16482,6 +16550,11 @@ var turnStartSchema = external_exports.object({
16482
16550
  turnId: hostTurnIdSchema,
16483
16551
  input: external_exports.array(textInputSchema)
16484
16552
  }).strict();
16553
+ var turnSteerSchema = external_exports.object({
16554
+ type: external_exports.literal("turn.steer"),
16555
+ turnId: hostTurnIdSchema,
16556
+ input: external_exports.array(textInputSchema)
16557
+ }).strict();
16485
16558
  var turnCancelSchema = external_exports.object({ type: external_exports.literal("turn.cancel"), turnId: hostTurnIdSchema }).strict();
16486
16559
  var interactionResponseSchema = external_exports.union([
16487
16560
  external_exports.object({
@@ -16507,6 +16580,7 @@ var permissionSelectSchema = external_exports.object({
16507
16580
  }).strict();
16508
16581
  var brokerHostCommandSchema = external_exports.discriminatedUnion("type", [
16509
16582
  turnStartSchema,
16583
+ turnSteerSchema,
16510
16584
  turnCancelSchema,
16511
16585
  interactionRespondSchema,
16512
16586
  modelSelectSchema,
@@ -16699,6 +16773,7 @@ function parseSessionMetadata(value) {
16699
16773
  sessionId: candidate.sessionId,
16700
16774
  sessionGeneration: candidate.sessionGeneration,
16701
16775
  capabilities: harnessSessionCapabilitiesSchema.parse(candidate.capabilities),
16776
+ readCapabilities: candidate.readCapabilities === true,
16702
16777
  initialState: state,
16703
16778
  initialUsage: candidate.initialUsage === null ? null : parseHostUsage(candidate.initialUsage),
16704
16779
  commands: candidate.commands === true
@@ -17050,6 +17125,11 @@ var BrokeredHarnessSession = class {
17050
17125
  event: { type: "session.faulted", error: unavailable(error51.message) }
17051
17126
  });
17052
17127
  }
17128
+ async readCapabilities() {
17129
+ if (!this.#metadata.readCapabilities)
17130
+ return { ...this.capabilities, steer: false };
17131
+ return harnessSessionCapabilitiesSchema.parse(await this.#request("session.readCapabilities", {}));
17132
+ }
17053
17133
  async refreshUsage() {
17054
17134
  await this.#request("session.refreshUsage", {});
17055
17135
  }
@@ -17081,6 +17161,8 @@ var BrokeredHarnessSession = class {
17081
17161
  try {
17082
17162
  return parseHarnessResult(await this.#request("session.execute", { command }));
17083
17163
  } catch (error51) {
17164
+ if (command.type === "turn.steer")
17165
+ throw error51;
17084
17166
  return {
17085
17167
  ok: false,
17086
17168
  error: unavailable(error51 instanceof Error ? error51.message : String(error51))
@@ -17391,10 +17473,13 @@ function usageSessionTitle(value) {
17391
17473
  return void 0;
17392
17474
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
17393
17475
  return normalized;
17394
- const characters = [...normalized];
17395
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
17396
- return normalized;
17397
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
17476
+ let title = "";
17477
+ for (const character of normalized) {
17478
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
17479
+ break;
17480
+ title += character;
17481
+ }
17482
+ return `${title.trimEnd()}…`;
17398
17483
  }
17399
17484
  function sessionIdOk(value) {
17400
17485
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -19036,7 +19121,7 @@ function createCodeBuddyUsageStatistics(environment, profile) {
19036
19121
  import { stat as stat3 } from "node:fs/promises";
19037
19122
 
19038
19123
  // ../codebuddy/dist/acp-client.js
19039
- import { execFile as execFile2, spawn } from "node:child_process";
19124
+ import { execFile as execFile3, spawn } from "node:child_process";
19040
19125
  import { Readable as Readable2, Writable } from "node:stream";
19041
19126
 
19042
19127
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -23201,9 +23286,23 @@ var ClientSideConnection = class {
23201
23286
 
23202
23287
  // ../codebuddy/dist/copy-cleanup.js
23203
23288
  import { randomBytes } from "node:crypto";
23289
+
23290
+ // ../codebuddy/dist/acp-stdio.js
23204
23291
  import { createInterface as createInterface2 } from "node:readline";
23205
- import { stripVTControlCharacters } from "node:util";
23206
23292
  import { Readable } from "node:stream";
23293
+ import { stripVTControlCharacters } from "node:util";
23294
+ function codeBuddyAcpOutput(stdout, onLine) {
23295
+ return Readable.from((async function* () {
23296
+ for await (const line of createInterface2({ input: stdout })) {
23297
+ onLine?.(stripVTControlCharacters(line));
23298
+ if (line.trimStart().startsWith("{"))
23299
+ yield Buffer.from(`${line}
23300
+ `);
23301
+ }
23302
+ })());
23303
+ }
23304
+
23305
+ // ../codebuddy/dist/copy-cleanup.js
23207
23306
  var CodeBuddyCopyCleanup = class {
23208
23307
  copyId;
23209
23308
  cwd;
@@ -23233,17 +23332,11 @@ var CodeBuddyCopyCleanup = class {
23233
23332
  }
23234
23333
  /** Native --serve banners include its password; never pass them to the ACP parser/logs. */
23235
23334
  protocolOutput(stdout) {
23236
- return Readable.from(this.#protocolLines(stdout));
23237
- }
23238
- async *#protocolLines(stdout) {
23239
- for await (const line of createInterface2({ input: stdout })) {
23240
- const endpoint = /^\s*Endpoint\s+(http:\/\/127\.0\.0\.1:\d+)\s*$/u.exec(stripVTControlCharacters(line));
23335
+ return codeBuddyAcpOutput(stdout, (line) => {
23336
+ const endpoint = /^\s*Endpoint\s+(http:\/\/127\.0\.0\.1:\d+)\s*$/u.exec(line);
23241
23337
  if (endpoint)
23242
23338
  this.#endpoint = endpoint[1];
23243
- if (line.trimStart().startsWith("{"))
23244
- yield Buffer.from(`${line}
23245
- `);
23246
- }
23339
+ });
23247
23340
  }
23248
23341
  async remove() {
23249
23342
  if (!this.#endpoint)
@@ -23508,6 +23601,88 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
23508
23601
  return void 0;
23509
23602
  }
23510
23603
 
23604
+ // ../../harness-discovery/dist/installation.js
23605
+ import { execFile as execFile2 } from "node:child_process";
23606
+ import { homedir as homedir2 } from "node:os";
23607
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
23608
+ const env = withNodeRuntimeOnPath(environment);
23609
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
23610
+ return new Promise((resolve, reject) => {
23611
+ const child = execFile2(invocation.command, invocation.arguments, {
23612
+ env,
23613
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir2(),
23614
+ encoding: "utf8",
23615
+ timeout,
23616
+ killSignal: "SIGKILL",
23617
+ maxBuffer: 1024 * 1024,
23618
+ windowsHide: true,
23619
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
23620
+ }, (error51, stdout, stderr) => {
23621
+ if (error51)
23622
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
23623
+ else
23624
+ resolve((stdout || stderr).trim());
23625
+ });
23626
+ child.stdin?.end();
23627
+ });
23628
+ }
23629
+ function installationVersion(value) {
23630
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
23631
+ throw new Error("Harness returned an invalid version");
23632
+ return value.trim().replace(/^v/, "");
23633
+ }
23634
+ function versionFromOutput(output) {
23635
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
23636
+ }
23637
+ function newerInstallationVersion(current, latest) {
23638
+ const a = installationVersion(current).replace(/\+.*/, "");
23639
+ const b = installationVersion(latest).replace(/\+.*/, "");
23640
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
23641
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
23642
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
23643
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
23644
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
23645
+ }
23646
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
23647
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
23648
+ if (!preA.length || !preB.length)
23649
+ return !!preA.length && !preB.length;
23650
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
23651
+ const x = preA[i];
23652
+ const y = preB[i];
23653
+ if (x === y)
23654
+ continue;
23655
+ if (x === void 0 || y === void 0)
23656
+ return x === void 0;
23657
+ const numericX = /^\d+$/.test(x);
23658
+ const numericY = /^\d+$/.test(y);
23659
+ if (numericX && numericY) {
23660
+ if (BigInt(x) === BigInt(y))
23661
+ continue;
23662
+ return BigInt(y) > BigInt(x);
23663
+ }
23664
+ if (numericX !== numericY)
23665
+ return numericX;
23666
+ return y > x;
23667
+ }
23668
+ return false;
23669
+ }
23670
+ async function fetchInstallationText(url2) {
23671
+ const request = async () => {
23672
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
23673
+ if (!response.ok)
23674
+ throw new Error("Could not check the latest Harness version");
23675
+ return response.text();
23676
+ };
23677
+ try {
23678
+ return await request();
23679
+ } catch (error51) {
23680
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
23681
+ throw error51;
23682
+ return request();
23683
+ }
23684
+ }
23685
+
23511
23686
  // ../codebuddy/dist/command.js
23512
23687
  var codeBuddyDiscoverySpec = {
23513
23688
  id: "codebuddy",
@@ -23607,7 +23782,7 @@ var CodeBuddyAcpClient = class {
23607
23782
  return { outcome: "cancelled" };
23608
23783
  return options.handlers.question(params);
23609
23784
  }
23610
- }), ndJsonStream2(Writable.toWeb(this.#child.stdin), Readable2.toWeb(this.#copyCleanup?.protocolOutput(this.#child.stdout) ?? this.#child.stdout)));
23785
+ }), ndJsonStream2(Writable.toWeb(this.#child.stdin), Readable2.toWeb(this.#copyCleanup?.protocolOutput(this.#child.stdout) ?? (invocation.arguments.includes("--serve") ? codeBuddyAcpOutput(this.#child.stdout) : this.#child.stdout))));
23611
23786
  void this.#connection.closed.then(() => {
23612
23787
  this.#fault(new CodeBuddyError("processExited", "ACP connection closed"));
23613
23788
  }).catch((error51) => {
@@ -23700,7 +23875,7 @@ var CodeBuddyAcpClient = class {
23700
23875
  }
23701
23876
  const pid = this.#child.pid;
23702
23877
  if (pid && process.platform === "win32") {
23703
- await new Promise((resolve) => execFile2("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => resolve()));
23878
+ await new Promise((resolve) => execFile3("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => resolve()));
23704
23879
  } else if (pid) {
23705
23880
  try {
23706
23881
  process.kill(-pid, "SIGKILL");
@@ -23713,7 +23888,7 @@ var CodeBuddyAcpClient = class {
23713
23888
 
23714
23889
  // ../codebuddy/dist/derivation.js
23715
23890
  import { randomUUID as randomUUID3 } from "node:crypto";
23716
- import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
23891
+ import { execFile as execFile4, spawn as spawn2 } from "node:child_process";
23717
23892
  import { lstat as lstat3, mkdir, readFile as readFile3, realpath as realpath4, unlink, writeFile } from "node:fs/promises";
23718
23893
  import path8 from "node:path";
23719
23894
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
@@ -23963,7 +24138,7 @@ async function copyCodeBuddySession(cwd, sourceId, targetId, environment, signal
23963
24138
  child.stderr.destroy();
23964
24139
  } else if (process.platform === "win32" && child.pid) {
23965
24140
  termination = new Promise((done) => {
23966
- execFile3("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => {
24141
+ execFile4("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => {
23967
24142
  child.kill();
23968
24143
  done();
23969
24144
  });
@@ -25634,6 +25809,8 @@ var CodeBuddySession = class {
25634
25809
  async #execute(command, nativeCommand = false) {
25635
25810
  if (this.#closed || this.#fault)
25636
25811
  return failure("invalidState", "Session is closed or faulted", this.profile);
25812
+ if (command.type === "turn.steer")
25813
+ return unsupportedSteer(this.profile.displayName);
25637
25814
  if (command.type === "interaction.respond")
25638
25815
  return this.#interactions.respond(command);
25639
25816
  if (command.type === "turn.cancel") {
@@ -25992,8 +26169,9 @@ var CodeBuddyAdapter = class {
25992
26169
  };
25993
26170
 
25994
26171
  // dist/command.js
25995
- import { lstatSync } from "node:fs";
25996
- import { homedir as homedir2 } from "node:os";
26172
+ import { lstatSync, statSync } from "node:fs";
26173
+ import { randomBytes as randomBytes2 } from "node:crypto";
26174
+ import { homedir as homedir3 } from "node:os";
25997
26175
 
25998
26176
  // dist/delegation.js
25999
26177
  var DELEGATION_ENVIRONMENT_KEYS = [
@@ -26068,8 +26246,57 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
26068
26246
  socketPath = path.join(directory, "c");
26069
26247
  }
26070
26248
  const cleanup = () => {
26249
+ clearTimeout(readyTimer);
26250
+ readyServer && readyServer.close();
26251
+ for (const connection of readyConnections) connection.destroy();
26071
26252
  if (directory) try { fs.rmSync(directory, {recursive:true,force:true}); } catch {}
26072
26253
  };
26254
+ const needsReady = process.argv.includes("--serve");
26255
+ let credentialReady = false;
26256
+ let runtimeReady = !needsReady;
26257
+ let readyTimer;
26258
+ let readyServer;
26259
+ const readyConnections = new Set();
26260
+ const cleanupWhenReady = () => {
26261
+ if (!credentialReady || !runtimeReady) return;
26262
+ cleanup();
26263
+ process.removeListener("exit", cleanup);
26264
+ };
26265
+ if (needsReady) {
26266
+ readyServer = net.createServer(connection => {
26267
+ readyConnections.add(connection);
26268
+ connection.once("close", () => readyConnections.delete(connection));
26269
+ connection.on("error", () => connection.destroy());
26270
+ let input = "";
26271
+ connection.on("data", chunk => {
26272
+ input += chunk;
26273
+ if (input.length > 4096) return connection.destroy();
26274
+ if (!input.includes("\n")) return;
26275
+ try {
26276
+ const request = JSON.parse(input.slice(0, input.indexOf("\n")));
26277
+ const params = request.params;
26278
+ if (request.jsonrpc !== "2.0" || request.method !== "session.ready" ||
26279
+ typeof request.id !== "string" || params?.protocolVersion !== 1 ||
26280
+ params.token !== token || params.sessionId !== sessionId || params.pid !== process.pid ||
26281
+ !Number.isInteger(params.port) || params.port < 1 || params.port > 65535) {
26282
+ connection.destroy();
26283
+ return;
26284
+ }
26285
+ runtimeReady = true;
26286
+ connection.end(JSON.stringify({jsonrpc:"2.0",id:request.id,result:{ok:true}}) + "\n", cleanupWhenReady);
26287
+ } catch { connection.destroy(); }
26288
+ });
26289
+ });
26290
+ readyServer.once("error", () => {
26291
+ process.stderr.write("WorkBuddy runtime readiness listener failed\n");
26292
+ process.exit(1);
26293
+ });
26294
+ readyServer.listen(socketPath + "-ready");
26295
+ readyTimer = setTimeout(() => {
26296
+ process.stderr.write("WorkBuddy runtime readiness timed out\n");
26297
+ process.exit(1);
26298
+ }, 15000);
26299
+ }
26073
26300
  process.once("exit", cleanup);
26074
26301
  Object.assign(env, {
26075
26302
  WORKBUDDY_AT_REST_ENCRYPTION: "fields",
@@ -26092,8 +26319,8 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
26092
26319
  clearTimeout(timer);
26093
26320
  socket && socket.destroy();
26094
26321
  message = "";
26095
- cleanup();
26096
- process.removeListener("exit", cleanup);
26322
+ credentialReady = success;
26323
+ if (success) cleanupWhenReady();
26097
26324
  if (!success) {
26098
26325
  process.stderr.write("WorkBuddy credential bootstrap failed\n");
26099
26326
  process.exit(1);
@@ -26232,7 +26459,7 @@ function bundledProductConfigPath(environment, platform, dependencies) {
26232
26459
  function workBuddyEnvironment(environment, platform = process.platform) {
26233
26460
  const paths = targetPath(platform);
26234
26461
  const configuredRoot = environment.WORKBUDDY_CONFIG_DIR;
26235
- const root = paths.resolve(configuredRoot?.trim() ? configuredRoot : paths.join(environment.HOME || environment.USERPROFILE || homedir2(), ".workbuddy-ai"));
26462
+ const root = paths.resolve(configuredRoot?.trim() ? configuredRoot : paths.join(environment.HOME || environment.USERPROFILE || homedir3(), ".workbuddy-ai"));
26236
26463
  return {
26237
26464
  ...environment,
26238
26465
  // The bundled core reads CODEBUDDY_CONFIG_DIR. Force both names to one
@@ -26242,9 +26469,7 @@ function workBuddyEnvironment(environment, platform = process.platform) {
26242
26469
  DISABLE_AUTOUPDATER: environment.DISABLE_AUTOUPDATER ?? "1"
26243
26470
  };
26244
26471
  }
26245
- function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {}, argumentsOverride) {
26246
- const dependencies = Array.isArray(dependenciesOrArguments) ? {} : dependenciesOrArguments;
26247
- const nativeArguments = Array.isArray(dependenciesOrArguments) ? dependenciesOrArguments : argumentsOverride;
26472
+ function resolveWorkBuddyLaunch(environment, dependencies = {}) {
26248
26473
  const platform = dependencies.platform ?? process.platform;
26249
26474
  const configured = environmentValue(environment, "CODEXHOST_WORKBUDDY_COMMAND")?.trim() || void 0;
26250
26475
  if (!configured && platform !== "darwin" && platform !== "win32")
@@ -26257,6 +26482,29 @@ function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {
26257
26482
  const executable = configured && !explicitDesktop && !configuredDirectory ? explicitExecutable : bundle?.executable;
26258
26483
  if (!executable)
26259
26484
  throw new CodeBuddyError("notInstalled", "WorkBuddy AI app or its bundled CLI is unavailable");
26485
+ return { executable, bundle };
26486
+ }
26487
+ function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {}, argumentsOverride) {
26488
+ const dependencies = Array.isArray(dependenciesOrArguments) ? {} : dependenciesOrArguments;
26489
+ const nativeArguments = Array.isArray(dependenciesOrArguments) ? dependenciesOrArguments : argumentsOverride;
26490
+ const platform = dependencies.platform ?? process.platform;
26491
+ const { executable, bundle } = resolveWorkBuddyLaunch(environment, dependencies);
26492
+ const paths = targetPath(platform);
26493
+ const cliDist = bundle && paths.join(paths.dirname(paths.dirname(bundle.cli)), "dist");
26494
+ const isFile = dependencies.isFile ?? ((candidate) => {
26495
+ try {
26496
+ return statSync(candidate).isFile();
26497
+ } catch {
26498
+ return false;
26499
+ }
26500
+ });
26501
+ const liteOnly = Boolean(cliDist && isFile(paths.join(cliDist, "codebuddy-lite-wb.mjs")) && !isFile(paths.join(cliDist, "codebuddy.js")) && !isFile(paths.join(cliDist, "codebuddy-headless.js")));
26502
+ const acpArguments = nativeArguments ?? [
26503
+ "--acp",
26504
+ ...ephemeral ? ["--no-session-persistence"] : [],
26505
+ ...workBuddyDelegationArguments(environment, ephemeral)
26506
+ ];
26507
+ const serve = liteOnly && acpArguments.includes("--acp") && !acpArguments.includes("--serve");
26260
26508
  const configuredEnvironment = withNodeRuntimeOnPath(workBuddyEnvironment(environment, platform), process.execPath, platform);
26261
26509
  const productConfigPath = bundle ? bundledProductConfigPath(configuredEnvironment, platform, dependencies) : void 0;
26262
26510
  const childEnvironment = bundle ? {
@@ -26265,17 +26513,20 @@ function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {
26265
26513
  // waits for its telemetry channel before copying; normal ACP keeps its policy.
26266
26514
  ...nativeArguments?.includes("--print") && nativeArguments.includes("--fork-session") && configuredEnvironment.DISABLE_TELEMETRY === void 0 ? { DISABLE_TELEMETRY: "1" } : {},
26267
26515
  ...productConfigPath ? { [WORKBUDDY_PRODUCT_CONFIG_PATH_ENV]: productConfigPath } : {},
26516
+ ...liteOnly ? { CODEBUDDY_FORCE_LITE_WB_BUNDLE: "1" } : {},
26517
+ ...serve ? {
26518
+ CODEBUDDY_GATEWAY_AUTH: "password",
26519
+ CODEBUDDY_GATEWAY_PASSWORD: randomBytes2(32).toString("base64url"),
26520
+ CODEBUDDY_GATEWAY_BASE_PATH: ""
26521
+ } : {},
26268
26522
  ELECTRON_RUN_AS_NODE: "1"
26269
26523
  } : configuredEnvironment;
26270
26524
  return {
26271
26525
  ...commandInvocation(executable, [
26272
26526
  ...bundle ? ["--eval", `${WORKBUDDY_CREDENTIAL_PRELOAD}
26273
26527
  require(process.argv[1]);`, bundle.cli] : [],
26274
- ...nativeArguments ?? [
26275
- "--acp",
26276
- ...ephemeral ? ["--no-session-persistence"] : [],
26277
- ...workBuddyDelegationArguments(childEnvironment, ephemeral)
26278
- ]
26528
+ ...acpArguments,
26529
+ ...serve ? ["--serve", "--host", "127.0.0.1", "--port", "0", "--auth", "password"] : []
26279
26530
  ], childEnvironment, platform),
26280
26531
  environment: childEnvironment
26281
26532
  };
@@ -26480,10 +26731,90 @@ var WorkBuddyAdapter = class extends CodeBuddyAdapter {
26480
26731
  }
26481
26732
  };
26482
26733
 
26734
+ // dist/installation.js
26735
+ import { readFile as readFile6, stat as stat5 } from "node:fs/promises";
26736
+ var applicationNotice = {
26737
+ en: "These are WorkBuddy desktop app versions. Its bundled CLI updates with the app. Download the official installer, complete installation, then reopen Connections to verify the version. Existing sessions keep their running CLI.",
26738
+ "zh-CN": "此处显示 WorkBuddy 桌面应用版本,内置 CLI 随应用更新。请下载官方安装包并完成安装,再重新打开连接页确认版本。已有会话继续使用运行中的 CLI。"
26739
+ };
26740
+ function appVersion(value) {
26741
+ const version2 = installationVersion(value);
26742
+ return version2.replace(/^(\d+\.\d+\.\d+)\.\d+$/u, "$1");
26743
+ }
26744
+ async function readProduct(file2) {
26745
+ const metadata = await stat5(file2);
26746
+ if (!metadata.isFile() || metadata.size <= 0 || metadata.size > 8 * 1024 * 1024)
26747
+ throw new Error("WorkBuddy product metadata is unavailable");
26748
+ return JSON.parse(await readFile6(file2, "utf8"));
26749
+ }
26750
+ function createWorkBuddyInstallation(environment, dependencies = {}) {
26751
+ const platform = dependencies.platform ?? process.platform;
26752
+ const arch = dependencies.arch ?? process.arch;
26753
+ return async (action) => {
26754
+ if (action === "update")
26755
+ throw new Error("Complete the update with WorkBuddy's official desktop installer");
26756
+ const { executable, bundle } = resolveWorkBuddyLaunch(environment, { platform });
26757
+ if (!bundle)
26758
+ return {
26759
+ currentVersion: versionFromOutput(await runInstallationCommand(executable, ["--version"], environment)),
26760
+ latestVersion: "Unknown",
26761
+ latestVersionKind: "unknown",
26762
+ updateAvailable: false,
26763
+ canUpdate: false,
26764
+ notice: {
26765
+ en: "This is a custom CLI. Use its original installer to update; WorkBuddy desktop releases do not identify this CLI's latest version.",
26766
+ "zh-CN": "当前使用自定义 CLI,请通过原安装方式更新;WorkBuddy 桌面应用版本不代表此 CLI 的最新版本。"
26767
+ }
26768
+ };
26769
+ const paths = targetPath(platform);
26770
+ const product = await (dependencies.readProduct ?? readProduct)(paths.join(paths.dirname(paths.dirname(bundle.cli)), "product.json"));
26771
+ const currentVersion = appVersion(product.genieVersion);
26772
+ const unknown2 = {
26773
+ currentVersion,
26774
+ versionKind: "application",
26775
+ latestVersion: "Unknown",
26776
+ latestVersionKind: "unknown",
26777
+ updateAvailable: false,
26778
+ canUpdate: false,
26779
+ notice: {
26780
+ en: "The installed WorkBuddy desktop app version is shown. Check and install updates in WorkBuddy itself; this installation's update channel could not be checked here.",
26781
+ "zh-CN": "此处显示已安装的 WorkBuddy 桌面应用版本。当前无法查询此安装的更新渠道,请在 WorkBuddy 应用内检查并安装更新。"
26782
+ }
26783
+ };
26784
+ const root = product.applicationName === "workbuddy-ai" && product.updateUrl === "https://www.workbuddy.ai" ? "https://www.workbuddy.ai" : product.applicationName === "workbuddy" && product.updateUrl === "https://www.workbuddy.cn" ? "https://www.workbuddy.cn" : void 0;
26785
+ const target = platform === "darwin" && (arch === "arm64" || arch === "x64") ? `darwin-${arch}` : platform === "win32" && arch === "x64" ? "win32-x64-user" : void 0;
26786
+ if (!root || !target || environment.WORKBUDDY_UPDATE_URL?.trim() && environment.WORKBUDDY_UPDATE_URL.trim() !== root)
26787
+ return unknown2;
26788
+ try {
26789
+ const feed = JSON.parse(await (dependencies.fetchText ?? fetchInstallationText)(`${root}/v2/update?platform=workbuddy-${target}`));
26790
+ const feedVersion = installationVersion(feed.version);
26791
+ const latestVersion = appVersion(feedVersion);
26792
+ const download = new URL(typeof feed.url === "string" ? feed.url : "");
26793
+ const downloadHost = root.endsWith(".ai") ? "download.codebuddy.ai" : "download.codebuddy.cn";
26794
+ if (download.origin !== `https://${downloadHost}` || download.username || download.password || download.search || download.hash || !download.pathname.startsWith(`/workbuddy/saas/${target}/WorkBuddy-${target}-${feedVersion}-`) || !download.pathname.endsWith(platform === "darwin" ? ".zip" : ".exe"))
26795
+ throw new Error("WorkBuddy update feed returned an invalid installer URL");
26796
+ if (platform === "darwin")
26797
+ download.pathname = download.pathname.replace(/\.zip$/u, ".dmg");
26798
+ const updateAvailable = newerInstallationVersion(currentVersion, latestVersion);
26799
+ return {
26800
+ currentVersion,
26801
+ versionKind: "application",
26802
+ latestVersion,
26803
+ updateAvailable,
26804
+ canUpdate: false,
26805
+ ...updateAvailable ? { manualUpdateUrl: download.href } : {},
26806
+ notice: applicationNotice
26807
+ };
26808
+ } catch {
26809
+ return unknown2;
26810
+ }
26811
+ };
26812
+ }
26813
+
26483
26814
  // dist/plugin.js
26484
26815
  function createHarnessAdapter(context) {
26485
26816
  if (context.platform === "darwin" && context.managedRemoteHost) {
26486
- const environment = {
26817
+ const environment2 = {
26487
26818
  ...context.environment,
26488
26819
  ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
26489
26820
  };
@@ -26495,7 +26826,7 @@ function createHarnessAdapter(context) {
26495
26826
  environment: { ...context.environment },
26496
26827
  isInstalled: () => {
26497
26828
  try {
26498
- workBuddyInvocation(environment, true);
26829
+ workBuddyInvocation(environment2, true);
26499
26830
  return true;
26500
26831
  } catch (error51) {
26501
26832
  return !(error51 instanceof CodeBuddyError && error51.code === "notInstalled");
@@ -26504,11 +26835,12 @@ function createHarnessAdapter(context) {
26504
26835
  ...context.brokerDescriptorPath ? { descriptorPath: context.brokerDescriptorPath } : {}
26505
26836
  });
26506
26837
  }
26507
- return new WorkBuddyAdapter({
26508
- environment: {
26509
- ...context.environment,
26510
- ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
26511
- }
26838
+ const environment = {
26839
+ ...context.environment,
26840
+ ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
26841
+ };
26842
+ return Object.assign(new WorkBuddyAdapter({ environment }), {
26843
+ installation: createWorkBuddyInstallation(environment)
26512
26844
  });
26513
26845
  }
26514
26846
  export {