@codexhost/cli-darwin-x64 0.9.1 → 0.10.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.
@@ -776,10 +776,10 @@ function mergeDefs(...defs) {
776
776
  function cloneDef(schema) {
777
777
  return mergeDefs(schema._zod.def);
778
778
  }
779
- function getElementAtPath(obj, path13) {
780
- if (!path13)
779
+ function getElementAtPath(obj, path14) {
780
+ if (!path14)
781
781
  return obj;
782
- return path13.reduce((acc, key) => acc?.[key], obj);
782
+ return path14.reduce((acc, key) => acc?.[key], obj);
783
783
  }
784
784
  function promiseAllObject(promisesObj) {
785
785
  const keys = Object.keys(promisesObj);
@@ -1188,11 +1188,11 @@ function explicitlyAborted(x2, startIndex = 0) {
1188
1188
  }
1189
1189
  return false;
1190
1190
  }
1191
- function prefixIssues(path13, issues) {
1191
+ function prefixIssues(path14, issues) {
1192
1192
  return issues.map((iss) => {
1193
1193
  var _a4;
1194
1194
  (_a4 = iss).path ?? (_a4.path = []);
1195
- iss.path.unshift(path13);
1195
+ iss.path.unshift(path14);
1196
1196
  return iss;
1197
1197
  });
1198
1198
  }
@@ -1339,16 +1339,16 @@ function flattenError(error52, mapper = (issue2) => issue2.message) {
1339
1339
  }
1340
1340
  function formatError(error52, mapper = (issue2) => issue2.message) {
1341
1341
  const fieldErrors = { _errors: [] };
1342
- const processError = (error53, path13 = []) => {
1342
+ const processError = (error53, path14 = []) => {
1343
1343
  for (const issue2 of error53.issues) {
1344
1344
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1345
- issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1345
+ issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1346
1346
  } else if (issue2.code === "invalid_key") {
1347
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1347
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1348
1348
  } else if (issue2.code === "invalid_element") {
1349
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1349
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1350
1350
  } else {
1351
- const fullpath = [...path13, ...issue2.path];
1351
+ const fullpath = [...path14, ...issue2.path];
1352
1352
  if (fullpath.length === 0) {
1353
1353
  fieldErrors._errors.push(mapper(issue2));
1354
1354
  } else {
@@ -1375,17 +1375,17 @@ function formatError(error52, mapper = (issue2) => issue2.message) {
1375
1375
  }
1376
1376
  function treeifyError(error52, mapper = (issue2) => issue2.message) {
1377
1377
  const result = { errors: [] };
1378
- const processError = (error53, path13 = []) => {
1378
+ const processError = (error53, path14 = []) => {
1379
1379
  var _a4, _b2;
1380
1380
  for (const issue2 of error53.issues) {
1381
1381
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1382
- issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1382
+ issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1383
1383
  } else if (issue2.code === "invalid_key") {
1384
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1384
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1385
1385
  } else if (issue2.code === "invalid_element") {
1386
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1386
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1387
1387
  } else {
1388
- const fullpath = [...path13, ...issue2.path];
1388
+ const fullpath = [...path14, ...issue2.path];
1389
1389
  if (fullpath.length === 0) {
1390
1390
  result.errors.push(mapper(issue2));
1391
1391
  continue;
@@ -1417,8 +1417,8 @@ function treeifyError(error52, mapper = (issue2) => issue2.message) {
1417
1417
  }
1418
1418
  function toDotPath(_path) {
1419
1419
  const segs = [];
1420
- const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
- for (const seg of path13) {
1420
+ const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
+ for (const seg of path14) {
1422
1422
  if (typeof seg === "number")
1423
1423
  segs.push(`[${seg}]`);
1424
1424
  else if (typeof seg === "symbol")
@@ -14110,13 +14110,13 @@ function resolveRef(ref, ctx) {
14110
14110
  if (!ref.startsWith("#")) {
14111
14111
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14112
14112
  }
14113
- const path13 = ref.slice(1).split("/").filter(Boolean);
14114
- if (path13.length === 0) {
14113
+ const path14 = ref.slice(1).split("/").filter(Boolean);
14114
+ if (path14.length === 0) {
14115
14115
  return ctx.rootSchema;
14116
14116
  }
14117
14117
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14118
- if (path13[0] === defsKey) {
14119
- const key = path13[1];
14118
+ if (path14[0] === defsKey) {
14119
+ const key = path14[1];
14120
14120
  if (!key || !ctx.defs[key]) {
14121
14121
  throw new Error(`Reference not found: ${ref}`);
14122
14122
  }
@@ -14524,6 +14524,61 @@ function date4(params) {
14524
14524
  // ../../../node_modules/zod/v4/classic/external.js
14525
14525
  config(en_default());
14526
14526
 
14527
+ // ../../shared-contracts/dist/credential-imports.js
14528
+ var credentialSourceSchema = external_exports.object({
14529
+ id: external_exports.string().min(1).max(256),
14530
+ harnessId: external_exports.string().min(1),
14531
+ label: external_exports.string().min(1).max(512),
14532
+ provider: external_exports.enum(["openai-codex", "xai"])
14533
+ }).strict();
14534
+ var credentialImportNameSchema = external_exports.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
14535
+ var credentialImportRecordSchema = external_exports.object({
14536
+ name: credentialImportNameSchema,
14537
+ source: credentialSourceSchema,
14538
+ importedAt: external_exports.string()
14539
+ }).strict();
14540
+ var credentialImportsRequestSchema = external_exports.discriminatedUnion("action", [
14541
+ external_exports.object({ action: external_exports.literal("list") }).strict(),
14542
+ external_exports.object({
14543
+ action: external_exports.literal("import"),
14544
+ sourceId: external_exports.string().min(1).max(256),
14545
+ name: credentialImportNameSchema,
14546
+ confirmed: external_exports.literal(true)
14547
+ }).strict(),
14548
+ external_exports.object({
14549
+ action: external_exports.literal("reimport"),
14550
+ sourceId: external_exports.string().min(1).max(256),
14551
+ name: credentialImportNameSchema,
14552
+ confirmed: external_exports.literal(true)
14553
+ }).strict(),
14554
+ external_exports.object({
14555
+ action: external_exports.literal("remove"),
14556
+ name: credentialImportNameSchema,
14557
+ confirmed: external_exports.literal(true)
14558
+ }).strict()
14559
+ ]);
14560
+ var credentialOtherLoginSchema = external_exports.object({
14561
+ provider: external_exports.string().min(1).max(128),
14562
+ type: external_exports.enum(["oauth", "api_key", "unknown"]),
14563
+ /** Best-effort account label (e.g. the email in a Codex token), derived locally when present. */
14564
+ label: external_exports.string().min(1).max(512).optional(),
14565
+ /** Recognized credential vendor, derived from the OAuth token issuer. Absent when unknown. */
14566
+ vendor: external_exports.enum(["openai-codex", "xai"]).optional()
14567
+ }).strict();
14568
+ var credentialImportsResultSchema = external_exports.object({
14569
+ sources: external_exports.array(credentialSourceSchema),
14570
+ targets: external_exports.array(external_exports.object({
14571
+ harnessId: external_exports.string(),
14572
+ providers: external_exports.array(external_exports.enum(["openai-codex", "xai"])),
14573
+ imports: external_exports.array(credentialImportRecordSchema),
14574
+ others: external_exports.array(credentialOtherLoginSchema).default([])
14575
+ }).strict())
14576
+ }).strict();
14577
+ var credentialImportsParamsSchema = external_exports.object({
14578
+ targetHarnessId: external_exports.string().min(1).max(128).optional(),
14579
+ request: credentialImportsRequestSchema
14580
+ }).strict();
14581
+
14527
14582
  // ../../shared-contracts/dist/version.js
14528
14583
  var WORKSPACE_CONTRACT_VERSION = 1;
14529
14584
 
@@ -15227,10 +15282,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15227
15282
  invocation: commandInvocationSchema,
15228
15283
  label: commandLabelSchema,
15229
15284
  description: commandDescriptionSchema.optional(),
15230
- argumentMode: external_exports.enum(["none", "text"])
15285
+ argumentMode: external_exports.enum(["none", "text"]),
15286
+ /**
15287
+ * Native distinction reported by the Harness. Omitted when the Harness does
15288
+ * not tell skills and commands apart; consumers treat that as "command".
15289
+ */
15290
+ kind: external_exports.enum(["command", "skill"]).optional()
15231
15291
  }).strict();
15232
15292
  var harnessCommandCatalogSchema = external_exports.object({
15233
- commands: external_exports.array(harnessCommandDescriptorSchema)
15293
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15294
+ /**
15295
+ * `live` when the catalog includes what a native Session reports for its
15296
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15297
+ * Omitted by Adapters; set by the Host on inspection results.
15298
+ */
15299
+ source: external_exports.enum(["live", "static"]).optional()
15234
15300
  }).strict().superRefine((catalog, context) => {
15235
15301
  const ids = /* @__PURE__ */ new Set();
15236
15302
  for (const [index, command] of catalog.commands.entries()) {
@@ -15244,7 +15310,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15244
15310
  ids.add(command.id);
15245
15311
  }
15246
15312
  });
15247
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15313
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15314
+ harnessId: harnessIdSchema,
15315
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15316
+ cwd: external_exports.string().min(1).optional()
15317
+ }).strict();
15248
15318
  var threadCommandsInspectParamsSchema = external_exports.object({
15249
15319
  threadId: hostThreadIdSchema
15250
15320
  }).strict();
@@ -15583,6 +15653,124 @@ function parseHostUsage(value) {
15583
15653
  return { ...value };
15584
15654
  }
15585
15655
 
15656
+ // ../../harness-adapter/dist/live-command-catalog.js
15657
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
15658
+ // Session lifecycle
15659
+ "branch",
15660
+ "clear",
15661
+ "exit",
15662
+ "fork",
15663
+ "fresh",
15664
+ "new",
15665
+ "quit",
15666
+ "rename",
15667
+ "rename-chat",
15668
+ "reset",
15669
+ "resume",
15670
+ "rewind",
15671
+ "session",
15672
+ "sessions",
15673
+ // Desktop-owned configuration
15674
+ "autocompact",
15675
+ "color",
15676
+ "config",
15677
+ "effort",
15678
+ "fast",
15679
+ "keybindings",
15680
+ "model",
15681
+ "models",
15682
+ "output-style",
15683
+ "permissions",
15684
+ "settings",
15685
+ "statusline",
15686
+ "terminal-setup",
15687
+ "theme",
15688
+ "vim",
15689
+ // Trust and approval policy
15690
+ "always-approve",
15691
+ "auto-mode-setup",
15692
+ // Native login
15693
+ "login",
15694
+ "logout",
15695
+ // Work outliving the Turn
15696
+ "autopilot",
15697
+ "background",
15698
+ "bg",
15699
+ "goal",
15700
+ "jobs",
15701
+ "loop",
15702
+ "multitask",
15703
+ "queue",
15704
+ "remote-control",
15705
+ "schedule",
15706
+ "steer",
15707
+ // Native terminal UI
15708
+ "copy",
15709
+ "debug",
15710
+ "feedback",
15711
+ "heapdump",
15712
+ "share",
15713
+ "shell",
15714
+ // Plugin and MCP management
15715
+ "marketplace",
15716
+ "mcp",
15717
+ "plugins",
15718
+ "reload-plugins"
15719
+ ]);
15720
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
15721
+ function isExcludedLiveCommand(name, kind, extra = {}) {
15722
+ const normalized = name.trim().replace(/^\//u, "");
15723
+ if (new Set(extra.names ?? []).has(normalized))
15724
+ return true;
15725
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
15726
+ return true;
15727
+ if (kind === "skill")
15728
+ return false;
15729
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
15730
+ }
15731
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
15732
+ if (!commandId.startsWith(idPrefix))
15733
+ return null;
15734
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
15735
+ if (!descriptor)
15736
+ return null;
15737
+ const text = typeof argumentText === "string" ? argumentText.trim() : "";
15738
+ return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
15739
+ }
15740
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
15741
+ if (!live)
15742
+ return builtIns;
15743
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
15744
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
15745
+ const dynamic = [];
15746
+ for (const command of live) {
15747
+ const name = command.name.trim().replace(/^\//u, "");
15748
+ if (!name || /\s/u.test(name))
15749
+ continue;
15750
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
15751
+ continue;
15752
+ const invocation = `/${name}`;
15753
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
15754
+ if (invocations.has(invocation) || ids.has(id))
15755
+ continue;
15756
+ const description = command.description?.trim().slice(0, 512);
15757
+ const parsed = harnessCommandDescriptorSchema.safeParse({
15758
+ id,
15759
+ invocation,
15760
+ label: name.slice(0, 128),
15761
+ ...description ? { description } : {},
15762
+ argumentMode: "text",
15763
+ kind: command.kind
15764
+ });
15765
+ if (!parsed.success)
15766
+ continue;
15767
+ invocations.add(invocation);
15768
+ ids.add(id);
15769
+ dynamic.push(parsed.data);
15770
+ }
15771
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
15772
+ }
15773
+
15586
15774
  // ../../harness-broker/dist/protocol.js
15587
15775
  var HARNESS_BROKER_PROTOCOL_VERSION = 1;
15588
15776
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
@@ -16378,6 +16566,7 @@ var BrokeredHarnessSession = class {
16378
16566
  var BrokeredHarnessAdapter = class {
16379
16567
  #sessions = /* @__PURE__ */ new Set();
16380
16568
  commandCatalog;
16569
+ liveCommandCatalog;
16381
16570
  harnessId;
16382
16571
  #descriptorPath;
16383
16572
  #forwardEnvironment;
@@ -16400,6 +16589,8 @@ var BrokeredHarnessAdapter = class {
16400
16589
  this.#forwardEnvironment = input.forwardDelegationEnvironment === true;
16401
16590
  if (input.commandCatalog)
16402
16591
  this.commandCatalog = input.commandCatalog;
16592
+ if (input.liveCommandCatalog)
16593
+ this.liveCommandCatalog = true;
16403
16594
  this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment, this.harnessId);
16404
16595
  }
16405
16596
  async inspectAccount() {
@@ -16489,7 +16680,7 @@ var BrokeredHarnessAdapter = class {
16489
16680
 
16490
16681
  // dist/claude-code-adapter.js
16491
16682
  import { randomUUID as randomUUID3 } from "node:crypto";
16492
- import path11 from "node:path";
16683
+ import path12 from "node:path";
16493
16684
 
16494
16685
  // ../../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
16495
16686
  import { createRequire as DW } from "node:module";
@@ -20394,8 +20585,8 @@ var qU = v(function(BU) {
20394
20585
  BU._globalThis = void 0;
20395
20586
  BU._globalThis = typeof globalThis === "object" ? globalThis : global;
20396
20587
  });
20397
- var GU = v(function(os6) {
20398
- var Axe = os6 && os6.__createBinding || (Object.create ? function(e, t, r, n) {
20588
+ var GU = v(function(os7) {
20589
+ var Axe = os7 && os7.__createBinding || (Object.create ? function(e, t, r, n) {
20399
20590
  if (n === void 0) n = r;
20400
20591
  Object.defineProperty(e, n, { enumerable: true, get: function() {
20401
20592
  return t[r];
@@ -20403,11 +20594,11 @@ var GU = v(function(os6) {
20403
20594
  } : function(e, t, r, n) {
20404
20595
  if (n === void 0) n = r;
20405
20596
  e[n] = t[r];
20406
- }), kxe = os6 && os6.__exportStar || function(e, t) {
20597
+ }), kxe = os7 && os7.__exportStar || function(e, t) {
20407
20598
  for (var r in e) if (r !== "default" && !Object.prototype.hasOwnProperty.call(t, r)) Axe(t, e, r);
20408
20599
  };
20409
- Object.defineProperty(os6, "__esModule", { value: true });
20410
- kxe(qU(), os6);
20600
+ Object.defineProperty(os7, "__esModule", { value: true });
20601
+ kxe(qU(), os7);
20411
20602
  });
20412
20603
  var WU = v(function(is) {
20413
20604
  var Oxe = is && is.__createBinding || (Object.create ? function(e, t, r, n) {
@@ -43497,6 +43688,9 @@ async function readClaudeTranscript(input) {
43497
43688
 
43498
43689
  // dist/model-catalog.js
43499
43690
  import { Buffer as Buffer2 } from "node:buffer";
43691
+ import { readFile as readFile4 } from "node:fs/promises";
43692
+ import os6 from "node:os";
43693
+ import path9 from "node:path";
43500
43694
 
43501
43695
  // dist/thinking-options.js
43502
43696
  var option = (id, label) => ({
@@ -43536,8 +43730,19 @@ var CLAUDE_MODEL_VALUE_MAX_LENGTH = 512;
43536
43730
  var modelInfoSchema = external_exports.object({
43537
43731
  value: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
43538
43732
  displayName: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH),
43733
+ description: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
43539
43734
  resolvedModel: harnessResolvedModelLabelSchema.optional()
43540
43735
  });
43736
+ var modelPickerOptionSchema = external_exports.object({
43737
+ model: external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH),
43738
+ label: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
43739
+ description: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional(),
43740
+ behavesAs: external_exports.string().trim().min(1).max(HARNESS_MODEL_LABEL_MAX_LENGTH).optional()
43741
+ });
43742
+ var modelPickerSettingsSchema = external_exports.object({
43743
+ options: external_exports.array(external_exports.unknown()).optional(),
43744
+ replaceBuiltInOptions: external_exports.boolean().optional()
43745
+ });
43541
43746
  var CLAUDE_DEFAULT_MODEL_REF = encodeClaudeModelRef("default");
43542
43747
  function encodeClaudeModelRef(value) {
43543
43748
  const parsed = external_exports.string().trim().min(1).max(CLAUDE_MODEL_VALUE_MAX_LENGTH).parse(value);
@@ -43566,6 +43771,127 @@ function decodeClaudeModelRef(ref) {
43566
43771
  }
43567
43772
  return value === "default" ? void 0 : value;
43568
43773
  }
43774
+ function resolveClaudeConfigDirectory(environment = process.env) {
43775
+ return path9.resolve(environment.CLAUDE_CONFIG_DIR ?? path9.join(os6.homedir(), ".claude"));
43776
+ }
43777
+ function parseModelPickerOptions(value) {
43778
+ if (!Array.isArray(value))
43779
+ return [];
43780
+ const options = [];
43781
+ const seen = /* @__PURE__ */ new Set();
43782
+ for (const entry of value) {
43783
+ const parsed = modelPickerOptionSchema.safeParse(entry);
43784
+ if (!parsed.success)
43785
+ continue;
43786
+ if (seen.has(parsed.data.model))
43787
+ continue;
43788
+ seen.add(parsed.data.model);
43789
+ options.push({
43790
+ model: parsed.data.model,
43791
+ ...parsed.data.label ? { label: parsed.data.label } : {},
43792
+ ...parsed.data.description ? { description: parsed.data.description } : {},
43793
+ ...parsed.data.behavesAs ? { behavesAs: parsed.data.behavesAs } : {}
43794
+ });
43795
+ }
43796
+ return options;
43797
+ }
43798
+ function parseClaudeModelPickerSettings(value) {
43799
+ if (value === void 0 || value === null)
43800
+ return void 0;
43801
+ const parsed = modelPickerSettingsSchema.safeParse(value);
43802
+ if (!parsed.success)
43803
+ return void 0;
43804
+ if (parsed.data.options === void 0 && parsed.data.replaceBuiltInOptions === void 0) {
43805
+ return void 0;
43806
+ }
43807
+ const options = parseModelPickerOptions(parsed.data.options);
43808
+ if (Array.isArray(parsed.data.options) && parsed.data.options.length > 0 && options.length === 0) {
43809
+ return void 0;
43810
+ }
43811
+ return {
43812
+ options,
43813
+ replaceBuiltInOptions: parsed.data.replaceBuiltInOptions === true
43814
+ };
43815
+ }
43816
+ async function readClaudeUserModelPicker(environment = process.env) {
43817
+ const settingsPath = path9.join(resolveClaudeConfigDirectory(environment), "settings.json");
43818
+ let raw;
43819
+ try {
43820
+ raw = await readFile4(settingsPath, "utf8");
43821
+ } catch {
43822
+ return void 0;
43823
+ }
43824
+ let document2;
43825
+ try {
43826
+ document2 = JSON.parse(raw);
43827
+ } catch {
43828
+ return void 0;
43829
+ }
43830
+ if (document2 === null || typeof document2 !== "object" || Array.isArray(document2)) {
43831
+ return void 0;
43832
+ }
43833
+ return parseClaudeModelPickerSettings(document2.modelPicker);
43834
+ }
43835
+ function optionToModelInfo(option2) {
43836
+ return {
43837
+ value: option2.model,
43838
+ displayName: option2.label ?? option2.model,
43839
+ ...option2.description ? { description: option2.description } : {},
43840
+ ...option2.behavesAs ? { resolvedModel: option2.behavesAs } : {}
43841
+ };
43842
+ }
43843
+ function readModelValue(row) {
43844
+ if (row === null || typeof row !== "object" || Array.isArray(row))
43845
+ return void 0;
43846
+ const value = row.value;
43847
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
43848
+ }
43849
+ function mergeOptionOntoSdkRow(sdkRow, option2) {
43850
+ const base = sdkRow !== null && typeof sdkRow === "object" && !Array.isArray(sdkRow) ? { ...sdkRow } : {};
43851
+ const overlay = optionToModelInfo(option2);
43852
+ return { ...base, ...overlay };
43853
+ }
43854
+ function mergeClaudeModelPickerOptions(sdkModels, modelPicker) {
43855
+ if (!modelPicker)
43856
+ return sdkModels;
43857
+ const sdkRows = Array.isArray(sdkModels) ? [...sdkModels] : [];
43858
+ const sdkByValue = /* @__PURE__ */ new Map();
43859
+ for (const row of sdkRows) {
43860
+ const value = readModelValue(row);
43861
+ if (value && !sdkByValue.has(value))
43862
+ sdkByValue.set(value, row);
43863
+ }
43864
+ if (modelPicker.replaceBuiltInOptions) {
43865
+ const defaultSdk = sdkByValue.get("default");
43866
+ const merged2 = [
43867
+ defaultSdk !== void 0 ? defaultSdk : { value: "default", displayName: "Default" }
43868
+ ];
43869
+ const included2 = /* @__PURE__ */ new Set(["default"]);
43870
+ for (const option2 of modelPicker.options) {
43871
+ if (included2.has(option2.model)) {
43872
+ if (option2.model === "default") {
43873
+ merged2[0] = mergeOptionOntoSdkRow(merged2[0], option2);
43874
+ }
43875
+ continue;
43876
+ }
43877
+ merged2.push(mergeOptionOntoSdkRow(sdkByValue.get(option2.model), option2));
43878
+ included2.add(option2.model);
43879
+ }
43880
+ return merged2;
43881
+ }
43882
+ const merged = [...sdkRows];
43883
+ const included = new Set(sdkRows.flatMap((row) => {
43884
+ const value = readModelValue(row);
43885
+ return value ? [value] : [];
43886
+ }));
43887
+ for (const option2 of modelPicker.options) {
43888
+ if (included.has(option2.model))
43889
+ continue;
43890
+ merged.push(mergeOptionOntoSdkRow(void 0, option2));
43891
+ included.add(option2.model);
43892
+ }
43893
+ return merged;
43894
+ }
43569
43895
  function uniqueDisplayLabels(rows) {
43570
43896
  const groups = /* @__PURE__ */ new Map();
43571
43897
  for (const row of rows) {
@@ -43707,6 +44033,51 @@ function isClaudePermissionMode(value) {
43707
44033
  // dist/sdk-transport.js
43708
44034
  import { spawn } from "node:child_process";
43709
44035
 
44036
+ // dist/slash-commands.js
44037
+ var DYNAMIC_ID_PREFIX = "claude.slash.";
44038
+ var CLAUDE_EXCLUDED_COMMANDS = [
44039
+ "advisor",
44040
+ "agents",
44041
+ "design-consent",
44042
+ "design-revoke",
44043
+ "doctor",
44044
+ "extra-usage",
44045
+ "import",
44046
+ "team-onboarding",
44047
+ "ultrareview",
44048
+ "usage-credits",
44049
+ "workflow-launch-exec"
44050
+ ];
44051
+ function parseClaudeSlashCommands(value) {
44052
+ if (!Array.isArray(value))
44053
+ return [];
44054
+ return value.flatMap((entry) => {
44055
+ if (typeof entry !== "object" || entry === null)
44056
+ return [];
44057
+ const record2 = entry;
44058
+ const name = typeof record2.name === "string" ? record2.name.trim().replace(/^\//u, "") : "";
44059
+ if (!name)
44060
+ return [];
44061
+ return [
44062
+ {
44063
+ name,
44064
+ description: typeof record2.description === "string" ? record2.description : "",
44065
+ argumentHint: typeof record2.argumentHint === "string" ? record2.argumentHint : ""
44066
+ }
44067
+ ];
44068
+ });
44069
+ }
44070
+ function claudeLiveCommandCatalog(builtIns, snapshot) {
44071
+ return mergeLiveHarnessCommands(builtIns, DYNAMIC_ID_PREFIX, snapshot?.commands.map((command) => ({
44072
+ name: command.name,
44073
+ description: command.description,
44074
+ kind: snapshot.skillNames.has(command.name) ? "skill" : "command"
44075
+ })) ?? null, { names: CLAUDE_EXCLUDED_COMMANDS });
44076
+ }
44077
+ function claudeDynamicCommandPrompt(catalog, commandId, argumentText) {
44078
+ return liveHarnessCommandPrompt(catalog, DYNAMIC_ID_PREFIX, commandId, argumentText);
44079
+ }
44080
+
43710
44081
  // dist/account-usage.js
43711
44082
  function projectClaudeAccountUsage(usage, account) {
43712
44083
  if (!usage.rate_limits_available || !usage.rate_limits)
@@ -43754,7 +44125,7 @@ function projectClaudeAccountUsage(usage, account) {
43754
44125
  }
43755
44126
 
43756
44127
  // dist/file-change.js
43757
- import path9 from "node:path";
44128
+ import path10 from "node:path";
43758
44129
  var hunkSchema = external_exports.object({
43759
44130
  oldStart: external_exports.number().int().nonnegative(),
43760
44131
  oldLines: external_exports.number().int().nonnegative(),
@@ -43802,10 +44173,10 @@ function parseClaudeNativeFileChange(toolName, value) {
43802
44173
  };
43803
44174
  }
43804
44175
  function displayPath(nativePath, cwd) {
43805
- const resolvedCwd = path9.resolve(cwd);
43806
- const resolvedPath = path9.isAbsolute(nativePath) ? path9.resolve(nativePath) : path9.resolve(cwd, nativePath);
43807
- const relative = path9.relative(resolvedCwd, resolvedPath);
43808
- const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path9.sep}`) ? relative : resolvedPath;
44176
+ const resolvedCwd = path10.resolve(cwd);
44177
+ const resolvedPath = path10.isAbsolute(nativePath) ? path10.resolve(nativePath) : path10.resolve(cwd, nativePath);
44178
+ const relative = path10.relative(resolvedCwd, resolvedPath);
44179
+ const selected = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path10.sep}`) ? relative : resolvedPath;
43809
44180
  const normalized = selected.replaceAll("\\", "/");
43810
44181
  return validNativePath(normalized) && normalized !== "." ? normalized : null;
43811
44182
  }
@@ -43817,7 +44188,7 @@ function projectClaudeFileChange(value, cwd) {
43817
44188
  `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
43818
44189
  ...hunk.lines
43819
44190
  ]);
43820
- const absoluteDisplayPath = path9.posix.isAbsolute(normalizedPath);
44191
+ const absoluteDisplayPath = path10.posix.isAbsolute(normalizedPath);
43821
44192
  const oldHeader = value.kind === "add" ? "/dev/null" : absoluteDisplayPath ? normalizedPath : `a/${normalizedPath}`;
43822
44193
  const newHeader = absoluteDisplayPath ? normalizedPath : `b/${normalizedPath}`;
43823
44194
  const unifiedDiff = [`--- ${oldHeader}`, `+++ ${newHeader}`, ...body, ""].join("\n");
@@ -44506,7 +44877,7 @@ var ClaudeNativeTurnAccumulator = class {
44506
44877
 
44507
44878
  // dist/process-fence.js
44508
44879
  import { execFile } from "node:child_process";
44509
- import path10 from "node:path";
44880
+ import path11 from "node:path";
44510
44881
  import { setTimeout as setTimeout2 } from "node:timers/promises";
44511
44882
  import { promisify } from "node:util";
44512
44883
  var executeFile = promisify(execFile);
@@ -44530,9 +44901,9 @@ async function closeClaudeProcessGroup(child, timeoutMs) {
44530
44901
  if (child.exitCode !== null || child.signalCode !== null)
44531
44902
  throw new Error("Claude process tree cannot be confirmed after its Windows root exited");
44532
44903
  const root = process.env.SystemRoot ?? process.env.SYSTEMROOT;
44533
- if (!root || !path10.win32.isAbsolute(root))
44904
+ if (!root || !path11.win32.isAbsolute(root))
44534
44905
  throw new Error("Windows SystemRoot is unavailable");
44535
- await executeFile(path10.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
44906
+ await executeFile(path11.win32.join(root, "System32", "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
44536
44907
  timeout: timeoutMs,
44537
44908
  windowsHide: true
44538
44909
  });
@@ -44789,6 +45160,8 @@ var ClaudeSdkTransport = class {
44789
45160
  #interactionOrdinal = 0;
44790
45161
  #provider;
44791
45162
  #query = null;
45163
+ #slashCommands = null;
45164
+ #skillNames = /* @__PURE__ */ new Set();
44792
45165
  #started = false;
44793
45166
  #backgroundTasks = /* @__PURE__ */ new Set();
44794
45167
  constructor(options) {
@@ -44861,7 +45234,8 @@ var ClaudeSdkTransport = class {
44861
45234
  });
44862
45235
  this.#query = activeQuery;
44863
45236
  try {
44864
- await activeQuery.initializationResult();
45237
+ const initialization = await activeQuery.initializationResult();
45238
+ this.#slashCommands = parseClaudeSlashCommands(initialization.commands);
44865
45239
  this.#provider = (await activeQuery.accountInfo().catch(() => void 0))?.apiProvider;
44866
45240
  } catch (error52) {
44867
45241
  activeQuery.close();
@@ -44871,6 +45245,20 @@ var ClaudeSdkTransport = class {
44871
45245
  this.#started = true;
44872
45246
  this.#consumeTask = this.#consume(activeQuery);
44873
45247
  }
45248
+ slashCommands() {
45249
+ if (!this.#started || this.#slashCommands === null)
45250
+ return null;
45251
+ return { commands: this.#slashCommands, skillNames: this.#skillNames };
45252
+ }
45253
+ #observeSlashCommands(message) {
45254
+ if (!isRecord7(message) || message.type !== "system")
45255
+ return;
45256
+ if (message.subtype === "init" && Array.isArray(message.skills)) {
45257
+ this.#skillNames = new Set(message.skills.filter((name) => typeof name === "string"));
45258
+ } else if (message.subtype === "commands_changed") {
45259
+ this.#slashCommands = parseClaudeSlashCommands(message.commands);
45260
+ }
45261
+ }
44874
45262
  async getContextUsage() {
44875
45263
  const activeQuery = this.#query;
44876
45264
  if (!this.#started || !activeQuery)
@@ -45161,6 +45549,7 @@ var ClaudeSdkTransport = class {
45161
45549
  try {
45162
45550
  for await (const message of activeQuery) {
45163
45551
  this.#observeBackgroundTasks(message);
45552
+ this.#observeSlashCommands(message);
45164
45553
  const permissionMode = permissionModeFromMessage(message);
45165
45554
  if (permissionMode && permissionMode !== this.#permissionMode) {
45166
45555
  this.#permissionMode = permissionMode;
@@ -45334,8 +45723,9 @@ var ClaudeSdkModelInspector = class {
45334
45723
  const candidate = activeQuery;
45335
45724
  const canSelectModel = Array.isArray(initialized.models) && typeof candidate.setModel === "function";
45336
45725
  const canSelectPermissionMode = typeof candidate.setPermissionMode === "function";
45726
+ const modelPicker = await readClaudeUserModelPicker(this.#environment);
45337
45727
  return {
45338
- models: initialized.models,
45728
+ models: mergeClaudeModelPickerOptions(initialized.models, modelPicker),
45339
45729
  canSelectModel,
45340
45730
  canSelectPermissionMode
45341
45731
  };
@@ -46111,7 +46501,7 @@ var ClaudeHarnessSession = class {
46111
46501
  formatVersion: 1
46112
46502
  });
46113
46503
  this.commands = {
46114
- list: async () => ({ ok: true, value: claudeCommandCatalog }),
46504
+ list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
46115
46505
  execute: (command) => this.#executeHarnessCommand(command)
46116
46506
  };
46117
46507
  const durable = this.#openMode === "resume" || options.nativeRef !== void 0;
@@ -46347,11 +46737,17 @@ var ClaudeHarnessSession = class {
46347
46737
  }
46348
46738
  return { ok: true, value: { turnId: command.turnId } };
46349
46739
  }
46740
+ /** Built-ins plus the live commands and skills of the started native Session. */
46741
+ #liveCommandCatalog() {
46742
+ return claudeLiveCommandCatalog(claudeCommandCatalog, this.#transport?.slashCommands?.() ?? null);
46743
+ }
46350
46744
  async #executeHarnessCommand(command) {
46351
46745
  if (this.#phase !== "open") {
46352
46746
  return { ok: false, error: invalidState("Claude Code Session is not open") };
46353
46747
  }
46354
- const parsed = parseClaudeHarnessCommand(command);
46748
+ const argumentText = command.arguments?.text;
46749
+ const dynamicPrompt = claudeDynamicCommandPrompt(this.#liveCommandCatalog(), command.commandId, typeof argumentText === "string" ? argumentText : void 0);
46750
+ const parsed = dynamicPrompt === null ? parseClaudeHarnessCommand(command) : { ok: true, value: { id: "slash", text: dynamicPrompt } };
46355
46751
  if (!parsed.ok)
46356
46752
  return parsed;
46357
46753
  if (this.#acceptingTurn || this.#active || this.#configurationTask || this.#readingHistory) {
@@ -46436,7 +46832,7 @@ var ClaudeHarnessSession = class {
46436
46832
  this.#event({ type: "turn.started", turnId: command.turnId });
46437
46833
  if (item)
46438
46834
  this.#event({ type: "item.started", turnId: command.turnId, item });
46439
- const running = parsed.value.id === "claude.compact" ? transport.compact(nativeTurnKey, parsed.value.text, (event) => this.#handleTurnEvent(active, event)) : parsed.value.id === "claude.init" ? transport.init(nativeTurnKey, (event) => this.#handleTurnEvent(active, event)) : transport.recap(nativeTurnKey, (event) => this.#handleTurnEvent(active, event));
46835
+ const running = parsed.value.id === "claude.compact" ? transport.compact(nativeTurnKey, parsed.value.text, (event) => this.#handleTurnEvent(active, event)) : parsed.value.id === "claude.init" ? transport.init(nativeTurnKey, (event) => this.#handleTurnEvent(active, event)) : parsed.value.id === "slash" ? transport.runTurn(parsed.value.text, nativeTurnKey, (event) => this.#handleTurnEvent(active, event)) : transport.recap(nativeTurnKey, (event) => this.#handleTurnEvent(active, event));
46440
46836
  try {
46441
46837
  void running.then((result) => this.#finishResult(active, result), () => this.#handleTurnTransportFailure(active));
46442
46838
  } catch {
@@ -47745,6 +48141,7 @@ var ClaudeHarnessSession = class {
47745
48141
  };
47746
48142
  var ClaudeCodeAdapter = class {
47747
48143
  commandCatalog = claudeCommandCatalog;
48144
+ liveCommandCatalog = true;
47748
48145
  harnessId = claudeCodeHarnessId2;
47749
48146
  sessionImport = Object.freeze({
47750
48147
  listCandidates: async () => {
@@ -47903,7 +48300,7 @@ var ClaudeCodeAdapter = class {
47903
48300
  error: invalidState("Claude Code Adapter is closing")
47904
48301
  };
47905
48302
  }
47906
- const cwd = path11.resolve(input.cwd ?? process.cwd());
48303
+ const cwd = path12.resolve(input.cwd ?? process.cwd());
47907
48304
  if (!input.refresh) {
47908
48305
  const cached2 = this.#inspectionCache.get(cwd);
47909
48306
  if (cached2)
@@ -48084,7 +48481,7 @@ var ClaudeCodeAdapter = class {
48084
48481
  }
48085
48482
  };
48086
48483
  }
48087
- const cwd = path11.resolve(input.cwd);
48484
+ const cwd = path12.resolve(input.cwd);
48088
48485
  if (input.kind === "rollbackLastTurn") {
48089
48486
  for (const source of this.#sessions) {
48090
48487
  const ready = await source.prepareRollback(input.sourceRef.nativeSessionId);
@@ -48207,7 +48604,7 @@ var ClaudeCodeAdapter = class {
48207
48604
  };
48208
48605
 
48209
48606
  // dist/user-shell-environment.js
48210
- import path12 from "node:path";
48607
+ import path13 from "node:path";
48211
48608
  import { execFile as execFile2 } from "node:child_process";
48212
48609
  var ENVIRONMENT_MARKER = Buffer.from("\0CODEXHOST_USER_SHELL_ENV_V1\0");
48213
48610
  var ENVIRONMENT_COMMAND = "printf '\\0CODEXHOST_USER_SHELL_ENV_V1\\0'; /usr/bin/env -0";
@@ -48250,7 +48647,7 @@ async function withUserShellEnvironment(environment, dependencies) {
48250
48647
  if (platform === "win32" || !environment.HOME)
48251
48648
  return environment;
48252
48649
  const shell = environment.SHELL?.trim() || defaultShell(platform);
48253
- if (!shell || !SUPPORTED_SHELLS.has(path12.basename(shell)))
48650
+ if (!shell || !SUPPORTED_SHELLS.has(path13.basename(shell)))
48254
48651
  return environment;
48255
48652
  const cacheKey = `${platform}\0${shell}\0${environment.HOME}`;
48256
48653
  const cached2 = dependencies ? void 0 : shellEnvironmentCache.get(cacheKey);
@@ -48289,6 +48686,7 @@ async function createHarnessAdapter(context) {
48289
48686
  if (context.platform === "darwin" && context.managedRemoteHost) {
48290
48687
  return new BrokeredHarnessAdapter({
48291
48688
  commandCatalog: claudeCommandCatalog,
48689
+ liveCommandCatalog: true,
48292
48690
  environment,
48293
48691
  ...context.brokerDescriptorPath ? { descriptorPath: context.brokerDescriptorPath } : {}
48294
48692
  });