@codexhost/cli-darwin-x64 0.9.2 → 0.10.1

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.
@@ -527,6 +527,7 @@ function splitLines(text) {
527
527
 
528
528
  // dist/omp-adapter.js
529
529
  import { randomUUID as randomUUID2 } from "node:crypto";
530
+ import { realpath as realpath2, stat } from "node:fs/promises";
530
531
  import path4 from "node:path";
531
532
 
532
533
  // ../../../node_modules/zod/v4/classic/external.js
@@ -15801,10 +15802,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15801
15802
  invocation: commandInvocationSchema,
15802
15803
  label: commandLabelSchema,
15803
15804
  description: commandDescriptionSchema.optional(),
15804
- argumentMode: external_exports.enum(["none", "text"])
15805
+ argumentMode: external_exports.enum(["none", "text"]),
15806
+ /**
15807
+ * Native distinction reported by the Harness. Omitted when the Harness does
15808
+ * not tell skills and commands apart; consumers treat that as "command".
15809
+ */
15810
+ kind: external_exports.enum(["command", "skill"]).optional()
15805
15811
  }).strict();
15806
15812
  var harnessCommandCatalogSchema = external_exports.object({
15807
- commands: external_exports.array(harnessCommandDescriptorSchema)
15813
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15814
+ /**
15815
+ * `live` when the catalog includes what a native Session reports for its
15816
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15817
+ * Omitted by Adapters; set by the Host on inspection results.
15818
+ */
15819
+ source: external_exports.enum(["live", "static"]).optional()
15808
15820
  }).strict().superRefine((catalog, context) => {
15809
15821
  const ids = /* @__PURE__ */ new Set();
15810
15822
  for (const [index, command] of catalog.commands.entries()) {
@@ -15818,7 +15830,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15818
15830
  ids.add(command.id);
15819
15831
  }
15820
15832
  });
15821
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15833
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15834
+ harnessId: harnessIdSchema,
15835
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15836
+ cwd: external_exports.string().min(1).optional()
15837
+ }).strict();
15822
15838
  var threadCommandsInspectParamsSchema = external_exports.object({
15823
15839
  threadId: hostThreadIdSchema
15824
15840
  }).strict();
@@ -16157,6 +16173,155 @@ function parseHostUsage(value) {
16157
16173
  return { ...value };
16158
16174
  }
16159
16175
 
16176
+ // ../../harness-adapter/dist/live-command-catalog.js
16177
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
16178
+ // Session lifecycle
16179
+ "branch",
16180
+ "clear",
16181
+ "exit",
16182
+ "fork",
16183
+ "fresh",
16184
+ "new",
16185
+ "quit",
16186
+ "rename",
16187
+ "rename-chat",
16188
+ "reset",
16189
+ "resume",
16190
+ "rewind",
16191
+ "session",
16192
+ "sessions",
16193
+ // Desktop-owned configuration
16194
+ "autocompact",
16195
+ "color",
16196
+ "config",
16197
+ "effort",
16198
+ "fast",
16199
+ "keybindings",
16200
+ "model",
16201
+ "models",
16202
+ "output-style",
16203
+ "permissions",
16204
+ "settings",
16205
+ "statusline",
16206
+ "terminal-setup",
16207
+ "theme",
16208
+ "vim",
16209
+ // Trust and approval policy
16210
+ "always-approve",
16211
+ "auto-mode-setup",
16212
+ // Native login
16213
+ "login",
16214
+ "logout",
16215
+ // Work outliving the Turn
16216
+ "autopilot",
16217
+ "background",
16218
+ "bg",
16219
+ "goal",
16220
+ "jobs",
16221
+ "loop",
16222
+ "multitask",
16223
+ "queue",
16224
+ "remote-control",
16225
+ "schedule",
16226
+ "steer",
16227
+ // Native terminal UI
16228
+ "copy",
16229
+ "debug",
16230
+ "feedback",
16231
+ "heapdump",
16232
+ "share",
16233
+ "shell",
16234
+ // Plugin and MCP management
16235
+ "marketplace",
16236
+ "mcp",
16237
+ "plugins",
16238
+ "reload-plugins"
16239
+ ]);
16240
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
16241
+ function isExcludedLiveCommand(name, kind, extra = {}) {
16242
+ const normalized = name.trim().replace(/^\//u, "");
16243
+ if (new Set(extra.names ?? []).has(normalized))
16244
+ return true;
16245
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
16246
+ return true;
16247
+ if (kind === "skill")
16248
+ return false;
16249
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
16250
+ }
16251
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
16252
+ if (!commandId.startsWith(idPrefix))
16253
+ return null;
16254
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
16255
+ if (!descriptor)
16256
+ return null;
16257
+ const text = typeof argumentText === "string" ? argumentText.trim() : "";
16258
+ return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
16259
+ }
16260
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
16261
+ if (!live)
16262
+ return builtIns;
16263
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
16264
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
16265
+ const dynamic = [];
16266
+ for (const command of live) {
16267
+ const name = command.name.trim().replace(/^\//u, "");
16268
+ if (!name || /\s/u.test(name))
16269
+ continue;
16270
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
16271
+ continue;
16272
+ const invocation = `/${name}`;
16273
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
16274
+ if (invocations.has(invocation) || ids.has(id))
16275
+ continue;
16276
+ const description = command.description?.trim().slice(0, 512);
16277
+ const parsed = harnessCommandDescriptorSchema.safeParse({
16278
+ id,
16279
+ invocation,
16280
+ label: name.slice(0, 128),
16281
+ ...description ? { description } : {},
16282
+ argumentMode: "text",
16283
+ kind: command.kind
16284
+ });
16285
+ if (!parsed.success)
16286
+ continue;
16287
+ invocations.add(invocation);
16288
+ ids.add(id);
16289
+ dynamic.push(parsed.data);
16290
+ }
16291
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
16292
+ }
16293
+
16294
+ // dist/omp-slash-commands.js
16295
+ var OMP_LIVE_COMMAND_ID_PREFIX = "omp.slash.";
16296
+ function isRecord2(value) {
16297
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16298
+ }
16299
+ function parseOmpAvailableCommands(value) {
16300
+ if (!Array.isArray(value))
16301
+ return [];
16302
+ return value.flatMap((entry) => {
16303
+ if (!isRecord2(entry))
16304
+ return [];
16305
+ const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
16306
+ if (!name)
16307
+ return [];
16308
+ return [
16309
+ {
16310
+ name,
16311
+ description: typeof entry.description === "string" ? entry.description : "",
16312
+ source: typeof entry.source === "string" ? entry.source : null
16313
+ }
16314
+ ];
16315
+ });
16316
+ }
16317
+ function ompLiveCommands(native) {
16318
+ return native.filter(({ source }) => source !== "builtin").map((command) => ({
16319
+ name: command.name,
16320
+ description: command.description,
16321
+ kind: command.source === "skill" ? "skill" : "command"
16322
+ }));
16323
+ }
16324
+
16160
16325
  // dist/omp-model-catalog.js
16161
16326
  var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
16162
16327
  var OMP_DRAFT_THINKING_OPTION_IDS = [
@@ -16272,11 +16437,11 @@ function normalizeOmpModelCatalog(nativeModels, effectiveModel, thinkingLevels,
16272
16437
  }
16273
16438
 
16274
16439
  // dist/omp-tool-presentation.js
16275
- function isRecord2(value) {
16440
+ function isRecord3(value) {
16276
16441
  return typeof value === "object" && value !== null && !Array.isArray(value);
16277
16442
  }
16278
16443
  function stringField(value, key) {
16279
- return isRecord2(value) && typeof value[key] === "string" ? value[key] : void 0;
16444
+ return isRecord3(value) && typeof value[key] === "string" ? value[key] : void 0;
16280
16445
  }
16281
16446
  function toolCommand(toolName, argumentsValue) {
16282
16447
  if (toolName === "bash") {
@@ -16298,7 +16463,7 @@ function projectOmpToolItem(input) {
16298
16463
 
16299
16464
  // dist/omp-history.js
16300
16465
  var ompHarnessId = harnessIdSchema.parse("omp");
16301
- function isRecord3(value) {
16466
+ function isRecord4(value) {
16302
16467
  return typeof value === "object" && value !== null && !Array.isArray(value);
16303
16468
  }
16304
16469
  function textContent(value) {
@@ -16306,12 +16471,12 @@ function textContent(value) {
16306
16471
  return value;
16307
16472
  if (!Array.isArray(value))
16308
16473
  return "";
16309
- return value.filter((part) => isRecord3(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
16474
+ return value.filter((part) => isRecord4(part) && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("");
16310
16475
  }
16311
16476
  function thinkingContent(value) {
16312
16477
  if (!Array.isArray(value))
16313
16478
  return "";
16314
- return value.filter((part) => isRecord3(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
16479
+ return value.filter((part) => isRecord4(part) && part.type === "thinking" && typeof part.thinking === "string").map((part) => part.thinking).join("");
16315
16480
  }
16316
16481
  function validatedEntry(value) {
16317
16482
  if (typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
@@ -16342,7 +16507,7 @@ function activeOmpEntries(history) {
16342
16507
  return reversed.reverse();
16343
16508
  }
16344
16509
  function message(entry) {
16345
- return entry.type === "message" && isRecord3(entry.message) ? entry.message : null;
16510
+ return entry.type === "message" && isRecord4(entry.message) ? entry.message : null;
16346
16511
  }
16347
16512
  function messageRole(entry) {
16348
16513
  const value = message(entry)?.role;
@@ -16404,7 +16569,7 @@ function snapshotItems(entries, outcome) {
16404
16569
  let projectedText = false;
16405
16570
  let projectedReasoning = false;
16406
16571
  for (const [ordinal, part] of content.entries()) {
16407
- if (!isRecord3(part))
16572
+ if (!isRecord4(part))
16408
16573
  continue;
16409
16574
  if (part.type === "thinking" && !projectedReasoning && reasoning.length > 0) {
16410
16575
  const item2 = {
@@ -16542,6 +16707,100 @@ function resolveOmpForkBoundary(history, checkpointId) {
16542
16707
  };
16543
16708
  }
16544
16709
 
16710
+ // dist/omp-session-file.js
16711
+ import { createReadStream } from "node:fs";
16712
+ import { open, realpath } from "node:fs/promises";
16713
+ import readline from "node:readline";
16714
+ var MAX_SESSION_HEADER_BYTES = 64 * 1024;
16715
+ var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
16716
+ function isRecord5(value) {
16717
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16718
+ }
16719
+ function historyEntry(value) {
16720
+ if (!isRecord5(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
16721
+ return null;
16722
+ }
16723
+ return value;
16724
+ }
16725
+ async function readOmpSessionHistory(sessionFile, maxBytes) {
16726
+ const entries = [];
16727
+ let leafId = null;
16728
+ const lines = readline.createInterface({
16729
+ input: createReadStream(sessionFile, {
16730
+ encoding: "utf8",
16731
+ ...maxBytes === void 0 ? {} : { end: maxBytes - 1 }
16732
+ }),
16733
+ crlfDelay: Number.POSITIVE_INFINITY
16734
+ });
16735
+ try {
16736
+ for await (const line of lines) {
16737
+ if (line.length === 0)
16738
+ continue;
16739
+ let parsed;
16740
+ try {
16741
+ parsed = JSON.parse(line);
16742
+ } catch {
16743
+ continue;
16744
+ }
16745
+ const entry = historyEntry(parsed);
16746
+ if (!entry)
16747
+ continue;
16748
+ entries.push(entry);
16749
+ leafId = entry.id;
16750
+ }
16751
+ } finally {
16752
+ lines.close();
16753
+ }
16754
+ return { entries, leafId };
16755
+ }
16756
+ async function readOmpSessionHeader(sessionFile) {
16757
+ const handle = await open(sessionFile, "r");
16758
+ try {
16759
+ const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
16760
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
16761
+ const contents = buffer.subarray(0, bytesRead);
16762
+ const newline = contents.indexOf(10);
16763
+ if (newline < 0 && bytesRead === buffer.length) {
16764
+ throw new Error("Omp Session header exceeds the supported size");
16765
+ }
16766
+ const contentsText = utf8Decoder.decode(contents);
16767
+ for (const line of contentsText.split("\n")) {
16768
+ if (line.length === 0)
16769
+ continue;
16770
+ let parsed;
16771
+ try {
16772
+ parsed = JSON.parse(line);
16773
+ } catch {
16774
+ continue;
16775
+ }
16776
+ if (!isRecord5(parsed) || parsed.type !== "session")
16777
+ continue;
16778
+ if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
16779
+ throw new Error("Omp Session header is invalid");
16780
+ }
16781
+ return { type: "session", id: parsed.id, cwd: parsed.cwd };
16782
+ }
16783
+ throw new Error("Omp Session header is invalid");
16784
+ } finally {
16785
+ await handle.close();
16786
+ }
16787
+ }
16788
+ async function verifyOmpSessionCwd(input) {
16789
+ if (!input.sessionFile)
16790
+ throw new Error("Omp Fork Session has no persisted Session file");
16791
+ const header = await readOmpSessionHeader(input.sessionFile);
16792
+ if (header.id !== input.sessionId) {
16793
+ throw new Error("Omp Fork Session header identity does not match RPC state");
16794
+ }
16795
+ const [actualCwd, expectedCwd] = await Promise.all([
16796
+ realpath(header.cwd),
16797
+ realpath(input.expectedCwd)
16798
+ ]);
16799
+ if (actualCwd !== expectedCwd) {
16800
+ throw new Error("Omp Fork Session did not bind the requested cwd");
16801
+ }
16802
+ }
16803
+
16545
16804
  // dist/omp-last-turn-rollback.js
16546
16805
  function modelFromState(state) {
16547
16806
  if (state.provider === null && state.modelId === null)
@@ -16849,14 +17108,14 @@ function resolveOmpExecutable(input, dependencies = {}) {
16849
17108
  }
16850
17109
 
16851
17110
  // dist/omp-usage.js
16852
- function isRecord4(value) {
17111
+ function isRecord6(value) {
16853
17112
  return typeof value === "object" && value !== null && !Array.isArray(value);
16854
17113
  }
16855
17114
  function nonNegativeSafeInteger(value) {
16856
17115
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
16857
17116
  }
16858
17117
  function optionalOmpCacheHitRatePercent(value) {
16859
- if (!isRecord4(value) || value.role !== "assistant" || !isRecord4(value.usage))
17118
+ if (!isRecord6(value) || value.role !== "assistant" || !isRecord6(value.usage))
16860
17119
  return null;
16861
17120
  const input = nonNegativeSafeInteger(value.usage.input);
16862
17121
  const cacheRead = nonNegativeSafeInteger(value.usage.cacheRead);
@@ -16869,20 +17128,20 @@ function optionalOmpCacheHitRatePercent(value) {
16869
17128
  function latestOmpCacheHitRatePercent(history) {
16870
17129
  let latest = null;
16871
17130
  for (const entry of activeOmpEntries(history)) {
16872
- if (entry.type === "message" && isRecord4(entry.message) && entry.message.role === "assistant") {
17131
+ if (entry.type === "message" && isRecord6(entry.message) && entry.message.role === "assistant") {
16873
17132
  latest = optionalOmpCacheHitRatePercent(entry.message);
16874
17133
  }
16875
17134
  }
16876
17135
  return latest;
16877
17136
  }
16878
17137
  function responseData(response, operation) {
16879
- if (!isRecord4(response.data)) {
17138
+ if (!isRecord6(response.data)) {
16880
17139
  throw new Error(`Omp RPC ${operation} response has no data`);
16881
17140
  }
16882
17141
  return response.data;
16883
17142
  }
16884
17143
  function contextUsage(value) {
16885
- if (!isRecord4(value))
17144
+ if (!isRecord6(value))
16886
17145
  throw new Error("Omp RPC context Usage is invalid");
16887
17146
  return parseHostUsage({
16888
17147
  contextUsedTokens: value.tokens,
@@ -16892,15 +17151,15 @@ function contextUsage(value) {
16892
17151
  function parseOmpSessionUsage(response) {
16893
17152
  const data = responseData(response, "Session stats");
16894
17153
  const tokens = data.tokens;
16895
- if (tokens !== void 0 && !isRecord4(tokens)) {
17154
+ if (tokens !== void 0 && !isRecord6(tokens)) {
16896
17155
  throw new Error("Omp RPC Session stats tokens are invalid");
16897
17156
  }
16898
17157
  return parseHostUsage({
16899
- ...isRecord4(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
16900
- ...isRecord4(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
16901
- ...isRecord4(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
16902
- ...isRecord4(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
16903
- ...isRecord4(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
17158
+ ...isRecord6(tokens) && tokens.input !== void 0 ? { inputTokens: tokens.input } : {},
17159
+ ...isRecord6(tokens) && tokens.cacheRead !== void 0 ? { cachedInputTokens: tokens.cacheRead } : {},
17160
+ ...isRecord6(tokens) && tokens.cacheWrite !== void 0 ? { cacheWriteInputTokens: tokens.cacheWrite } : {},
17161
+ ...isRecord6(tokens) && tokens.output !== void 0 ? { outputTokens: tokens.output } : {},
17162
+ ...isRecord6(tokens) && tokens.total !== void 0 ? { totalTokens: tokens.total } : {},
16904
17163
  ...data.cost !== void 0 ? { totalCostUsd: data.cost } : {},
16905
17164
  ...data.contextUsage !== void 0 ? contextUsage(data.contextUsage) : {}
16906
17165
  });
@@ -16919,97 +17178,6 @@ function optionalOmpStateContextUsage(value) {
16919
17178
  }
16920
17179
  }
16921
17180
 
16922
- // dist/omp-session-file.js
16923
- import { createReadStream } from "node:fs";
16924
- import { open, realpath } from "node:fs/promises";
16925
- import readline from "node:readline";
16926
- var MAX_SESSION_HEADER_BYTES = 64 * 1024;
16927
- var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
16928
- function isRecord5(value) {
16929
- return typeof value === "object" && value !== null && !Array.isArray(value);
16930
- }
16931
- function historyEntry(value) {
16932
- if (!isRecord5(value) || value.type === "title" || value.type === "session" || typeof value.id !== "string" || value.id.length === 0 || value.parentId !== null && typeof value.parentId !== "string" || typeof value.type !== "string") {
16933
- return null;
16934
- }
16935
- return value;
16936
- }
16937
- async function readOmpSessionHistory(sessionFile) {
16938
- const entries = [];
16939
- let leafId = null;
16940
- const lines = readline.createInterface({
16941
- input: createReadStream(sessionFile, { encoding: "utf8" }),
16942
- crlfDelay: Number.POSITIVE_INFINITY
16943
- });
16944
- try {
16945
- for await (const line of lines) {
16946
- if (line.length === 0)
16947
- continue;
16948
- let parsed;
16949
- try {
16950
- parsed = JSON.parse(line);
16951
- } catch {
16952
- continue;
16953
- }
16954
- const entry = historyEntry(parsed);
16955
- if (!entry)
16956
- continue;
16957
- entries.push(entry);
16958
- leafId = entry.id;
16959
- }
16960
- } finally {
16961
- lines.close();
16962
- }
16963
- return { entries, leafId };
16964
- }
16965
- async function readOmpSessionHeader(sessionFile) {
16966
- const handle = await open(sessionFile, "r");
16967
- try {
16968
- const buffer = Buffer.allocUnsafe(MAX_SESSION_HEADER_BYTES);
16969
- const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
16970
- const contents = buffer.subarray(0, bytesRead);
16971
- const newline = contents.indexOf(10);
16972
- if (newline < 0 && bytesRead === buffer.length) {
16973
- throw new Error("Omp Session header exceeds the supported size");
16974
- }
16975
- const contentsText = utf8Decoder.decode(contents);
16976
- for (const line of contentsText.split("\n")) {
16977
- if (line.length === 0)
16978
- continue;
16979
- let parsed;
16980
- try {
16981
- parsed = JSON.parse(line);
16982
- } catch {
16983
- continue;
16984
- }
16985
- if (!isRecord5(parsed) || parsed.type !== "session")
16986
- continue;
16987
- if (typeof parsed.id !== "string" || parsed.id.length === 0 || typeof parsed.cwd !== "string" || parsed.cwd.length === 0) {
16988
- throw new Error("Omp Session header is invalid");
16989
- }
16990
- return { type: "session", id: parsed.id, cwd: parsed.cwd };
16991
- }
16992
- throw new Error("Omp Session header is invalid");
16993
- } finally {
16994
- await handle.close();
16995
- }
16996
- }
16997
- async function verifyOmpSessionCwd(input) {
16998
- if (!input.sessionFile)
16999
- throw new Error("Omp Fork Session has no persisted Session file");
17000
- const header = await readOmpSessionHeader(input.sessionFile);
17001
- if (header.id !== input.sessionId) {
17002
- throw new Error("Omp Fork Session header identity does not match RPC state");
17003
- }
17004
- const [actualCwd, expectedCwd] = await Promise.all([
17005
- realpath(header.cwd),
17006
- realpath(input.expectedCwd)
17007
- ]);
17008
- if (actualCwd !== expectedCwd) {
17009
- throw new Error("Omp Fork Session did not bind the requested cwd");
17010
- }
17011
- }
17012
-
17013
17181
  // dist/omp-protocol.js
17014
17182
  var MAX_FRAME_BYTES = 1024 * 1024;
17015
17183
  var MAX_REASSEMBLED_BYTES = 64 * 1024 * 1024;
@@ -17106,7 +17274,7 @@ var OmpRpcUnsupportedCommandError = class extends Error {
17106
17274
  }
17107
17275
  };
17108
17276
  var textDecoder = new TextDecoder("utf-8", { fatal: true });
17109
- function isRecord6(value) {
17277
+ function isRecord7(value) {
17110
17278
  return typeof value === "object" && value !== null && !Array.isArray(value);
17111
17279
  }
17112
17280
  function message2(value) {
@@ -17118,13 +17286,13 @@ function nonBlankString(value) {
17118
17286
  function parseNativeModel(value, context) {
17119
17287
  if (value === null || value === void 0)
17120
17288
  return null;
17121
- if (!isRecord6(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
17289
+ if (!isRecord7(value) || !nonBlankString(value.provider) || !nonBlankString(value.id)) {
17122
17290
  throw new OmpRpcFaultError("protocolError", `Omp RPC returned an invalid ${context} Model`);
17123
17291
  }
17124
17292
  return { provider: value.provider, id: value.id };
17125
17293
  }
17126
17294
  function sessionStateData(response) {
17127
- const data = isRecord6(response.data) ? response.data : null;
17295
+ const data = isRecord7(response.data) ? response.data : null;
17128
17296
  if (!data)
17129
17297
  throw new OmpRpcFaultError("protocolError", "Omp RPC state response has no data");
17130
17298
  return data;
@@ -17139,7 +17307,7 @@ function parseSessionState(response) {
17139
17307
  if (thinkingLevel !== null && !thinkingLevel.success) {
17140
17308
  throw new OmpRpcFaultError("protocolError", "Omp RPC state has an invalid Thinking level");
17141
17309
  }
17142
- const thinking = isRecord6(data.model) && isRecord6(data.model.thinking) ? data.model.thinking : null;
17310
+ const thinking = isRecord7(data.model) && isRecord7(data.model.thinking) ? data.model.thinking : null;
17143
17311
  const availableThinkingLevels = thinking && Array.isArray(thinking.efforts) ? thinking.efforts.flatMap((level) => {
17144
17312
  const parsed = harnessThinkingOptionIdSchema.safeParse(level);
17145
17313
  return parsed.success ? [parsed.data] : [];
@@ -17162,25 +17330,25 @@ function parseSessionStreaming(response) {
17162
17330
  return isStreaming;
17163
17331
  }
17164
17332
  function parseAvailableModels(response) {
17165
- const data = isRecord6(response.data) ? response.data : null;
17333
+ const data = isRecord7(response.data) ? response.data : null;
17166
17334
  if (!data || !Array.isArray(data.models)) {
17167
17335
  throw new OmpRpcFaultError("protocolError", "Omp RPC Model catalog response has no models");
17168
17336
  }
17169
17337
  return data.models.map((model) => {
17170
17338
  const parsed = parseNativeModel(model, "catalog");
17171
- if (!parsed || !isRecord6(model) || typeof model.reasoning !== "boolean") {
17339
+ if (!parsed || !isRecord7(model) || typeof model.reasoning !== "boolean") {
17172
17340
  throw new OmpRpcFaultError("protocolError", "Omp RPC catalog contains a Model without reasoning capability");
17173
17341
  }
17174
17342
  return { ...parsed, reasoning: model.reasoning };
17175
17343
  });
17176
17344
  }
17177
17345
  function parseSubagentMessages(response) {
17178
- const data = isRecord6(response.data) ? response.data : null;
17346
+ const data = isRecord7(response.data) ? response.data : null;
17179
17347
  if (!data || !nonBlankString(data.sessionFile) || !Number.isSafeInteger(data.fromByte) || !Number.isSafeInteger(data.nextByte) || data.fromByte < 0 || data.nextByte < data.fromByte || typeof data.reset !== "boolean" || !Array.isArray(data.entries) || !Array.isArray(data.messages)) {
17180
17348
  throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript response is invalid");
17181
17349
  }
17182
- const entries = data.entries.flatMap((value) => isRecord6(value) ? [value] : []);
17183
- const messages = data.messages.flatMap((value) => isRecord6(value) ? [value] : []);
17350
+ const entries = data.entries.flatMap((value) => isRecord7(value) ? [value] : []);
17351
+ const messages = data.messages.flatMap((value) => isRecord7(value) ? [value] : []);
17184
17352
  if (entries.length !== data.entries.length || messages.length !== data.messages.length) {
17185
17353
  throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent transcript contains invalid data");
17186
17354
  }
@@ -17201,17 +17369,17 @@ function subagentStatus(value) {
17201
17369
  throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent status is invalid");
17202
17370
  }
17203
17371
  function assistantText(value) {
17204
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
17372
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
17205
17373
  return null;
17206
- return value.content.filter((content) => isRecord6(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
17374
+ return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map((content) => content.text).join("");
17207
17375
  }
17208
17376
  function assistantMessageId(value) {
17209
- if (!isRecord6(value) || value.role !== "assistant")
17377
+ if (!isRecord7(value) || value.role !== "assistant")
17210
17378
  return null;
17211
17379
  return nonBlankString(value.responseId) ? value.responseId : null;
17212
17380
  }
17213
17381
  function extractReasoningText(content) {
17214
- if (!isRecord6(content))
17382
+ if (!isRecord7(content))
17215
17383
  return null;
17216
17384
  const type = String(content.type ?? "");
17217
17385
  if (type === "thinking" || type === "reasoning" || type === "thought") {
@@ -17221,12 +17389,12 @@ function extractReasoningText(content) {
17221
17389
  return null;
17222
17390
  }
17223
17391
  function assistantReasoning(value) {
17224
- if (!isRecord6(value) || value.role !== "assistant" || !Array.isArray(value.content))
17392
+ if (!isRecord7(value) || value.role !== "assistant" || !Array.isArray(value.content))
17225
17393
  return null;
17226
17394
  return value.content.map(extractReasoningText).filter((text) => typeof text === "string").join("");
17227
17395
  }
17228
17396
  function assistantFailure(value) {
17229
- if (!isRecord6(value) || value.role !== "assistant")
17397
+ if (!isRecord7(value) || value.role !== "assistant")
17230
17398
  return void 0;
17231
17399
  if (value.stopReason !== "error" && value.stopReason !== "aborted")
17232
17400
  return null;
@@ -17246,7 +17414,7 @@ function signalProcessTree(child, signal) {
17246
17414
  try {
17247
17415
  process.kill(-child.pid, signal);
17248
17416
  } catch (error51) {
17249
- if (!isRecord6(error51) || error51.code !== "ESRCH")
17417
+ if (!isRecord7(error51) || error51.code !== "ESRCH")
17250
17418
  throw error51;
17251
17419
  }
17252
17420
  }
@@ -17323,6 +17491,7 @@ var OmpRpcSession = class {
17323
17491
  #failed = false;
17324
17492
  #pending = /* @__PURE__ */ new Map();
17325
17493
  #state = null;
17494
+ #availableCommands = null;
17326
17495
  #latestCacheHitRatePercent;
17327
17496
  #manualCompaction = null;
17328
17497
  #stderrTail = "";
@@ -17383,7 +17552,7 @@ var OmpRpcSession = class {
17383
17552
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
17384
17553
  });
17385
17554
  child.once("error", (error51) => {
17386
- const kind = isRecord6(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
17555
+ const kind = isRecord7(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
17387
17556
  this.#fail(new OmpRpcFaultError(kind, `Omp RPC failed to start: ${error51.message}`, this.stderrTail));
17388
17557
  });
17389
17558
  child.once("exit", (code, signal) => {
@@ -17403,6 +17572,9 @@ var OmpRpcSession = class {
17403
17572
  new Promise((_resolve, reject) => setTimeout(() => reject(new Error("Omp RPC ready signal timed out")), this.#options.commandTimeoutMs))
17404
17573
  ]);
17405
17574
  await this.#send("negotiate_protocol", { protocolVersion: 2 }).catch(() => void 0);
17575
+ if (this.#options.subscribeSubagentEvents !== false) {
17576
+ await this.#send("set_subagent_subscription", { level: "events" }).catch(() => void 0);
17577
+ }
17406
17578
  try {
17407
17579
  this.#state = parseSessionState(await this.#send("get_state", {}));
17408
17580
  } catch (error51) {
@@ -17418,17 +17590,17 @@ var OmpRpcSession = class {
17418
17590
  return await readOmpSessionHistory(this.state.sessionFile);
17419
17591
  }
17420
17592
  const response = await this.#send("get_messages", {});
17421
- const data = isRecord6(response.data) ? response.data : null;
17593
+ const data = isRecord7(response.data) ? response.data : null;
17422
17594
  if (!data || !Array.isArray(data.messages)) {
17423
17595
  throw new OmpRpcFaultError("protocolError", "Omp RPC messages response has no messages");
17424
17596
  }
17425
17597
  let branchEntryIds = null;
17426
17598
  try {
17427
17599
  const branchResponse = await this.#send("get_branch_messages", {});
17428
- const branchData = isRecord6(branchResponse.data) ? branchResponse.data : null;
17600
+ const branchData = isRecord7(branchResponse.data) ? branchResponse.data : null;
17429
17601
  if (branchData && Array.isArray(branchData.messages)) {
17430
17602
  const parsed = branchData.messages.flatMap((entry) => {
17431
- if (!isRecord6(entry) || !nonBlankString(entry.entryId))
17603
+ if (!isRecord7(entry) || !nonBlankString(entry.entryId))
17432
17604
  return [];
17433
17605
  return [entry.entryId];
17434
17606
  });
@@ -17442,11 +17614,11 @@ var OmpRpcSession = class {
17442
17614
  let userIndex = 0;
17443
17615
  let parentId = null;
17444
17616
  const entries = data.messages.map((nativeMessage, index) => {
17445
- const role = isRecord6(nativeMessage) ? nativeMessage.role : void 0;
17617
+ const role = isRecord7(nativeMessage) ? nativeMessage.role : void 0;
17446
17618
  const branchId = role === "user" ? branchEntryIds?.[userIndex] : void 0;
17447
17619
  if (branchId)
17448
17620
  userIndex += 1;
17449
- const id = branchId ?? (isRecord6(nativeMessage) && nonBlankString(nativeMessage.id) ? nativeMessage.id : `omp-message-${index}`);
17621
+ const id = branchId ?? (isRecord7(nativeMessage) && nonBlankString(nativeMessage.id) ? nativeMessage.id : `omp-message-${index}`);
17450
17622
  const entry = { id, parentId, type: "message", message: nativeMessage };
17451
17623
  parentId = id;
17452
17624
  return entry;
@@ -17526,7 +17698,7 @@ var OmpRpcSession = class {
17526
17698
  throw new Error("Omp RPC Fork requires an Entry identity");
17527
17699
  try {
17528
17700
  const response = await this.#send("branch", { entryId });
17529
- const data = isRecord6(response.data) ? response.data : null;
17701
+ const data = isRecord7(response.data) ? response.data : null;
17530
17702
  if (!data || data.cancelled === true) {
17531
17703
  throw new OmpRpcFaultError("unavailable", "Omp RPC Fork was cancelled");
17532
17704
  }
@@ -17719,7 +17891,7 @@ var OmpRpcSession = class {
17719
17891
  continue;
17720
17892
  }
17721
17893
  const value = decoded;
17722
- if (!isRecord6(value) || typeof value.type !== "string") {
17894
+ if (!isRecord7(value) || typeof value.type !== "string") {
17723
17895
  throw new OmpRpcFaultError("protocolError", "Omp RPC returned an invalid envelope");
17724
17896
  }
17725
17897
  this.#handle(value);
@@ -17729,9 +17901,17 @@ var OmpRpcSession = class {
17729
17901
  newline = this.#buffer.indexOf(10);
17730
17902
  }
17731
17903
  }
17904
+ /** Latest `available_commands_update` of the running process, if any. */
17905
+ get availableCommands() {
17906
+ return this.#availableCommands;
17907
+ }
17732
17908
  #handle(value) {
17733
17909
  if (this.#closed || this.#failed)
17734
17910
  return;
17911
+ if (value.type === "available_commands_update") {
17912
+ this.#availableCommands = parseOmpAvailableCommands(value.commands);
17913
+ return;
17914
+ }
17735
17915
  if (value.type === "ready") {
17736
17916
  this.#readyResolve?.();
17737
17917
  this.#readyResolve = null;
@@ -17770,7 +17950,7 @@ var OmpRpcSession = class {
17770
17950
  this.#armCommandTimeout(id, pending);
17771
17951
  }
17772
17952
  }
17773
- const outcome = value.aborted === true ? "cancelled" : isRecord6(value.result) ? "succeeded" : "failed";
17953
+ const outcome = value.aborted === true ? "cancelled" : isRecord7(value.result) ? "succeeded" : "failed";
17774
17954
  const event = {
17775
17955
  type: "compaction.completed",
17776
17956
  outcome,
@@ -17803,12 +17983,12 @@ var OmpRpcSession = class {
17803
17983
  this.#startAssistantMessage(active, value.message);
17804
17984
  return;
17805
17985
  }
17806
- if (value.type === "message_update" && isRecord6(value.assistantMessageEvent)) {
17986
+ if (value.type === "message_update" && isRecord7(value.assistantMessageEvent)) {
17807
17987
  const event = value.assistantMessageEvent;
17808
17988
  const eventType = String(event.type ?? "");
17809
17989
  const isThinking = eventType === "thinking_delta" || eventType === "reasoning_delta" || eventType === "thought_delta" || eventType === "thinking" || eventType === "reasoning";
17810
17990
  const isText = eventType === "text_delta" || eventType === "text" || eventType === "content_block_delta";
17811
- const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord6(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord6(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
17991
+ const delta = typeof event.delta === "string" ? event.delta : typeof event.thinking === "string" ? event.thinking : typeof event.reasoning === "string" ? event.reasoning : typeof event.text === "string" ? event.text : isRecord7(event.delta) && typeof event.delta.thinking === "string" ? event.delta.thinking : isRecord7(event.delta) && typeof event.delta.text === "string" ? event.delta.text : null;
17812
17992
  if (isThinking && delta !== null && delta.length > 0) {
17813
17993
  const messageId = this.#ensureAssistantMessage(active, value.message);
17814
17994
  active.reasoningMessageOpen = true;
@@ -17848,7 +18028,7 @@ var OmpRpcSession = class {
17848
18028
  if (value.type === "agent_end" && Array.isArray(value.messages)) {
17849
18029
  for (let index = value.messages.length - 1; index >= 0; index -= 1) {
17850
18030
  const message3 = value.messages[index];
17851
- if (!isRecord6(message3) || message3.role !== "assistant")
18031
+ if (!isRecord7(message3) || message3.role !== "assistant")
17852
18032
  continue;
17853
18033
  this.#finalizeAssistantMessage(active, message3);
17854
18034
  break;
@@ -17865,8 +18045,8 @@ var OmpRpcSession = class {
17865
18045
  if (value.type !== "subagent_lifecycle" && value.type !== "subagent_progress" && value.type !== "subagent_event") {
17866
18046
  return false;
17867
18047
  }
17868
- const payload = isRecord6(value.payload) ? value.payload : null;
17869
- const progressPayload = value.type === "subagent_progress" && payload && isRecord6(payload.progress) ? payload.progress : null;
18048
+ const payload = isRecord7(value.payload) ? value.payload : null;
18049
+ const progressPayload = value.type === "subagent_progress" && payload && isRecord7(payload.progress) ? payload.progress : null;
17870
18050
  const nativeIdValue = progressPayload?.id ?? payload?.id;
17871
18051
  if (!payload || !nonBlankString(nativeIdValue)) {
17872
18052
  throw new OmpRpcFaultError("protocolError", "Omp RPC Subagent frame has no stable ID");
@@ -18443,7 +18623,7 @@ var ompCommandCatalog = harnessCommandCatalogSchema.parse({
18443
18623
  ]
18444
18624
  });
18445
18625
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
18446
- function isRecord7(value) {
18626
+ function isRecord8(value) {
18447
18627
  return typeof value === "object" && value !== null && !Array.isArray(value);
18448
18628
  }
18449
18629
  function errorMessage(error51) {
@@ -18458,7 +18638,7 @@ var OmpAdapterFaultError = class extends Error {
18458
18638
  }
18459
18639
  };
18460
18640
  function normalizedError(error51, fallbackCode) {
18461
- if (isRecord7(error51) && error51.code === "ENOENT") {
18641
+ if (isRecord8(error51) && error51.code === "ENOENT") {
18462
18642
  return { code: "notInstalled", message: errorMessage(error51), retryable: false };
18463
18643
  }
18464
18644
  if (error51 instanceof OmpAdapterFaultError)
@@ -18535,11 +18715,51 @@ function nativeModelForHistory(state) {
18535
18715
  return nativeModelFromState(state);
18536
18716
  }
18537
18717
  function sessionFileFromRef(ref) {
18538
- if (ref.harnessId !== ompHarnessId2 || !isRecord7(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
18718
+ if (ref.harnessId !== ompHarnessId2 || !isRecord8(ref.locator) || typeof ref.locator.sessionFile !== "string" || ref.locator.sessionFile.length === 0) {
18539
18719
  throw new Error("Omp Native Session Ref has no resumable Session file");
18540
18720
  }
18541
18721
  return ref.locator.sessionFile;
18542
18722
  }
18723
+ var MAX_SUBAGENT_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
18724
+ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
18725
+ if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
18726
+ throw new Error("Omp Subagent ID is not a plain transcript file name");
18727
+ }
18728
+ if (!parentSessionFile.endsWith(".jsonl") || !path4.isAbsolute(parentSessionFile)) {
18729
+ return null;
18730
+ }
18731
+ return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
18732
+ }
18733
+ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
18734
+ const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
18735
+ if (transcriptFile === null)
18736
+ return { status: "missing" };
18737
+ const parentDirectory = path4.dirname(transcriptFile);
18738
+ let metadata;
18739
+ try {
18740
+ metadata = await stat(transcriptFile);
18741
+ } catch (error51) {
18742
+ if (error51.code === "ENOENT")
18743
+ return { status: "missing" };
18744
+ throw error51;
18745
+ }
18746
+ if (!metadata.isFile())
18747
+ return { status: "missing" };
18748
+ if (metadata.size > MAX_SUBAGENT_TRANSCRIPT_BYTES) {
18749
+ throw new Error("Omp Subagent transcript exceeds the supported size");
18750
+ }
18751
+ const [resolvedTranscript, resolvedParentDirectory] = await Promise.all([
18752
+ realpath2(transcriptFile),
18753
+ realpath2(parentDirectory)
18754
+ ]);
18755
+ if (path4.dirname(resolvedTranscript) !== resolvedParentDirectory) {
18756
+ throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
18757
+ }
18758
+ return {
18759
+ status: "read",
18760
+ history: await readOmpSessionHistory(transcriptFile, MAX_SUBAGENT_TRANSCRIPT_BYTES)
18761
+ };
18762
+ }
18543
18763
  function toolFailure(toolName) {
18544
18764
  return {
18545
18765
  code: "nativeFailure",
@@ -18550,9 +18770,9 @@ function toolFailure(toolName) {
18550
18770
  function nativeText(value) {
18551
18771
  if (typeof value === "string")
18552
18772
  return value;
18553
- if (!isRecord7(value) || !Array.isArray(value.content))
18773
+ if (!isRecord8(value) || !Array.isArray(value.content))
18554
18774
  return "";
18555
- return value.content.filter((content) => isRecord7(content) && content.type === "text" && typeof content.text === "string").map(({ text }) => text).join("");
18775
+ return value.content.filter((content) => isRecord8(content) && content.type === "text" && typeof content.text === "string").map(({ text }) => text).join("");
18556
18776
  }
18557
18777
  function boundedOutput(value, limit) {
18558
18778
  const text = nativeText(value);
@@ -18568,17 +18788,17 @@ function outputText(output) {
18568
18788
  return output?.content.filter((content) => content.type === "text").map(({ text }) => text).join("") ?? "";
18569
18789
  }
18570
18790
  function stringField2(value, key) {
18571
- if (!isRecord7(value))
18791
+ if (!isRecord8(value))
18572
18792
  return void 0;
18573
18793
  const field = value[key];
18574
18794
  if (typeof field === "string" && field.length > 0)
18575
18795
  return field;
18576
- if (isRecord7(value.input)) {
18796
+ if (isRecord8(value.input)) {
18577
18797
  const nested = value.input[key];
18578
18798
  if (typeof nested === "string" && nested.length > 0)
18579
18799
  return nested;
18580
18800
  }
18581
- if (isRecord7(value.arguments)) {
18801
+ if (isRecord8(value.arguments)) {
18582
18802
  const nested = value.arguments[key];
18583
18803
  if (typeof nested === "string" && nested.length > 0)
18584
18804
  return nested;
@@ -18586,7 +18806,7 @@ function stringField2(value, key) {
18586
18806
  return void 0;
18587
18807
  }
18588
18808
  function numberField(value, key) {
18589
- if (!isRecord7(value))
18809
+ if (!isRecord8(value))
18590
18810
  return void 0;
18591
18811
  const field = value[key];
18592
18812
  return typeof field === "number" || field === null ? field : void 0;
@@ -18625,7 +18845,7 @@ function fileMutatingKind(toolName) {
18625
18845
  return null;
18626
18846
  }
18627
18847
  function nestedToolString(value, keys) {
18628
- if (!isRecord7(value))
18848
+ if (!isRecord8(value))
18629
18849
  return void 0;
18630
18850
  for (const key of keys) {
18631
18851
  const field = value[key];
@@ -18640,14 +18860,14 @@ function nestedToolString(value, keys) {
18640
18860
  return void 0;
18641
18861
  }
18642
18862
  function patchFromResult(result) {
18643
- if (!isRecord7(result))
18863
+ if (!isRecord8(result))
18644
18864
  return void 0;
18645
18865
  for (const key of ["patch", "diff", "unifiedDiff"]) {
18646
18866
  const field = result[key];
18647
18867
  if (typeof field === "string" && field.length > 0)
18648
18868
  return field;
18649
18869
  }
18650
- if (isRecord7(result.details)) {
18870
+ if (isRecord8(result.details)) {
18651
18871
  for (const key of ["patch", "diff", "unifiedDiff"]) {
18652
18872
  const field = result.details[key];
18653
18873
  if (typeof field === "string" && field.length > 0)
@@ -18798,7 +19018,7 @@ var OmpHarnessSession = class {
18798
19018
  subagents: { observe: true, readTranscript: true }
18799
19019
  };
18800
19020
  this.commands = {
18801
- list: async () => ({ ok: true, value: ompCommandCatalog }),
19021
+ list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
18802
19022
  execute: (command) => this.#executeHarnessCommand(command)
18803
19023
  };
18804
19024
  this.#transport = options.startedTransport ?? null;
@@ -19446,7 +19666,24 @@ var OmpHarnessSession = class {
19446
19666
  return { ok: false, error: normalized };
19447
19667
  }
19448
19668
  }
19669
+ /**
19670
+ * Built-ins plus the skills and extension commands of the running process.
19671
+ * Never starts the process just to list commands.
19672
+ */
19673
+ #liveCommandCatalog() {
19674
+ const native = this.#transport?.availableCommands ?? null;
19675
+ return mergeLiveHarnessCommands(ompCommandCatalog, OMP_LIVE_COMMAND_ID_PREFIX, native ? ompLiveCommands(native) : null);
19676
+ }
19449
19677
  async #executeHarnessCommand(command) {
19678
+ const livePrompt = liveHarnessCommandPrompt(this.#liveCommandCatalog(), OMP_LIVE_COMMAND_ID_PREFIX, command.commandId, command.arguments?.text);
19679
+ if (livePrompt !== null) {
19680
+ const started = await this.execute({
19681
+ type: "turn.start",
19682
+ turnId: command.turnId,
19683
+ input: [{ type: "text", text: livePrompt }]
19684
+ });
19685
+ return started.ok ? { ok: true, value: { turnId: command.turnId } } : started;
19686
+ }
19450
19687
  if (command.commandId !== "omp.compact") {
19451
19688
  return {
19452
19689
  ok: false,
@@ -20110,6 +20347,7 @@ var OmpHarnessSession = class {
20110
20347
  };
20111
20348
  var OmpAdapter = class {
20112
20349
  commandCatalog = ompCommandCatalog;
20350
+ liveCommandCatalog = true;
20113
20351
  harnessId = ompHarnessId2;
20114
20352
  subagents = {
20115
20353
  readSnapshot: async (input) => {
@@ -20125,9 +20363,18 @@ var OmpAdapter = class {
20125
20363
  }
20126
20364
  let transport;
20127
20365
  try {
20366
+ const transcriptFile = await readSubagentTranscriptFile(sessionFileFromRef(input.parent), input.nativeSubagentId);
20367
+ if (transcriptFile.status === "read") {
20368
+ const snapshot2 = mapOmpSnapshot(transcriptFile.history, {
20369
+ sessionId: input.parent.nativeSessionId,
20370
+ model: null
20371
+ });
20372
+ return { ok: true, value: snapshot2 };
20373
+ }
20128
20374
  transport = this.#createTransport({
20129
20375
  cwd: input.cwd,
20130
20376
  sessionFile: sessionFileFromRef(input.parent),
20377
+ subscribeSubagentEvents: false,
20131
20378
  onFault: () => void 0
20132
20379
  });
20133
20380
  await transport.start();
@@ -20199,7 +20446,11 @@ var OmpAdapter = class {
20199
20446
  async #inspectCwd(cwd) {
20200
20447
  const startedAt = Date.now();
20201
20448
  let stage = "spawn";
20202
- const transport = this.#createTransport({ cwd, onFault: () => void 0 });
20449
+ const transport = this.#createTransport({
20450
+ cwd,
20451
+ subscribeSubagentEvents: false,
20452
+ onFault: () => void 0
20453
+ });
20203
20454
  this.#inspections.add(transport);
20204
20455
  try {
20205
20456
  stage = "startup";