@moxt-ai/mobius 0.0.166 → 0.0.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/acp/agent-query-processes.d.ts +2 -1
  2. package/dist/acp/agent-query-processes.d.ts.map +1 -1
  3. package/dist/acp/agent-query-processes.js +6 -4
  4. package/dist/acp/agent-query-processes.js.map +1 -1
  5. package/dist/acp/agent-runtime-manager.d.ts +2 -1
  6. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  7. package/dist/acp/agent-runtime-manager.js +11 -6
  8. package/dist/acp/agent-runtime-manager.js.map +1 -1
  9. package/dist/acp/agent-session.d.ts +3 -2
  10. package/dist/acp/agent-session.d.ts.map +1 -1
  11. package/dist/acp/agent-session.js +9 -6
  12. package/dist/acp/agent-session.js.map +1 -1
  13. package/dist/artifacts/local-file-streamer.d.ts +2 -1
  14. package/dist/artifacts/local-file-streamer.d.ts.map +1 -1
  15. package/dist/artifacts/local-file-streamer.js +6 -5
  16. package/dist/artifacts/local-file-streamer.js.map +1 -1
  17. package/dist/cli.js +387 -94
  18. package/dist/cli.js.map +4 -4
  19. package/dist/config.d.ts +1 -1
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/config.js +1 -1
  22. package/dist/config.js.map +1 -1
  23. package/dist/daemon-command-handler.d.ts +3 -1
  24. package/dist/daemon-command-handler.d.ts.map +1 -1
  25. package/dist/daemon-command-handler.js +2 -2
  26. package/dist/daemon-command-handler.js.map +1 -1
  27. package/dist/external-content/acp-content-externalizer.d.ts +8 -0
  28. package/dist/external-content/acp-content-externalizer.d.ts.map +1 -0
  29. package/dist/external-content/acp-content-externalizer.js +131 -0
  30. package/dist/external-content/acp-content-externalizer.js.map +1 -0
  31. package/dist/external-content/local-external-content-store.d.ts +32 -0
  32. package/dist/external-content/local-external-content-store.d.ts.map +1 -0
  33. package/dist/external-content/local-external-content-store.js +88 -0
  34. package/dist/external-content/local-external-content-store.js.map +1 -0
  35. package/dist/index.js +445 -158
  36. package/dist/index.js.map +4 -4
  37. package/dist/relay-connection/run-relay-connection.d.ts +3 -1
  38. package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
  39. package/dist/relay-connection/run-relay-connection.js +2 -1
  40. package/dist/relay-connection/run-relay-connection.js.map +1 -1
  41. package/dist/run-daemon.d.ts.map +1 -1
  42. package/dist/run-daemon.js +5 -1
  43. package/dist/run-daemon.js.map +1 -1
  44. package/dist/runtime.d.ts +2 -1
  45. package/dist/runtime.d.ts.map +1 -1
  46. package/dist/runtime.js +386 -98
  47. package/dist/runtime.js.map +4 -4
  48. package/package.json +16 -10
package/dist/index.js CHANGED
@@ -21215,6 +21215,7 @@ var MAX_JSON_KEYS = 1e3;
21215
21215
  var SESSION_EVENT_V2_KIND = "session.event.v2";
21216
21216
  var boundedString = external_exports.string().max(MAX_CONTENT_LENGTH);
21217
21217
  var shortString = external_exports.string().max(2048);
21218
+ var externalContentKeySchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
21218
21219
  function boundedJsonIssue(value, depth = 0) {
21219
21220
  if (depth > MAX_JSON_DEPTH) {
21220
21221
  return "JSON nesting exceeds the maximum depth";
@@ -21282,6 +21283,30 @@ var imageContentSchema = external_exports.object({
21282
21283
  uri: boundedString.nullable().optional()
21283
21284
  }).readonly();
21284
21285
  var audioContentSchema = external_exports.object({ ...contentFields, data: boundedString, mimeType: shortString, type: external_exports.literal("audio") }).readonly();
21286
+ var externalImageContentSchema = external_exports.strictObject({
21287
+ ...contentFields,
21288
+ byteLength: external_exports.number().int().positive().safe(),
21289
+ imageKey: externalContentKeySchema,
21290
+ mimeType: shortString,
21291
+ type: external_exports.literal("external_image"),
21292
+ uri: boundedString.nullable().optional()
21293
+ }).readonly();
21294
+ var externalAudioContentSchema = external_exports.strictObject({
21295
+ ...contentFields,
21296
+ audioKey: externalContentKeySchema,
21297
+ byteLength: external_exports.number().int().positive().safe(),
21298
+ mimeType: shortString,
21299
+ type: external_exports.literal("external_audio")
21300
+ }).readonly();
21301
+ var externalResourceContentSchema = external_exports.strictObject({
21302
+ ...contentFields,
21303
+ byteLength: external_exports.number().int().positive().safe(),
21304
+ encoding: external_exports.enum(["binary", "text"]),
21305
+ mimeType: shortString.nullable().optional(),
21306
+ resourceKey: externalContentKeySchema,
21307
+ type: external_exports.literal("external_resource"),
21308
+ uri: boundedString
21309
+ }).readonly();
21285
21310
  var resourceLinkSchema = external_exports.object({
21286
21311
  ...contentFields,
21287
21312
  description: boundedString.nullable().optional(),
@@ -21314,7 +21339,10 @@ var contentBlockV2Schema = external_exports.discriminatedUnion("type", [
21314
21339
  imageContentSchema,
21315
21340
  audioContentSchema,
21316
21341
  resourceLinkSchema,
21317
- embeddedResourceSchema
21342
+ embeddedResourceSchema,
21343
+ externalImageContentSchema,
21344
+ externalAudioContentSchema,
21345
+ externalResourceContentSchema
21318
21346
  ]);
21319
21347
  var toolCallContentSchema = external_exports.discriminatedUnion("type", [
21320
21348
  external_exports.object({ _meta: optionalMetadata, content: contentBlockV2Schema, type: external_exports.literal("content") }).readonly(),
@@ -26365,7 +26393,7 @@ function sql(strings, ...params) {
26365
26393
  return new SQL([new StringChunk(str)]);
26366
26394
  }
26367
26395
  sql2.raw = raw;
26368
- function join19(chunks, separator) {
26396
+ function join20(chunks, separator) {
26369
26397
  const result = [];
26370
26398
  for (const [i, chunk] of chunks.entries()) {
26371
26399
  if (i > 0 && separator !== void 0) {
@@ -26375,7 +26403,7 @@ function sql(strings, ...params) {
26375
26403
  }
26376
26404
  return new SQL(result);
26377
26405
  }
26378
- sql2.join = join19;
26406
+ sql2.join = join20;
26379
26407
  function identifier(value) {
26380
26408
  return new Name(value);
26381
26409
  }
@@ -28919,7 +28947,7 @@ var SQLiteSelectQueryBuilderBase = class extends TypedQueryBuilder {
28919
28947
  const baseTableName = this.tableName;
28920
28948
  const tableName = getTableLikeName(table);
28921
28949
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
28922
- if (typeof tableName === "string" && this.config.joins?.some((join19) => join19.alias === tableName)) {
28950
+ if (typeof tableName === "string" && this.config.joins?.some((join20) => join20.alias === tableName)) {
28923
28951
  throw new Error(`Alias "${tableName}" is already used in this query`);
28924
28952
  }
28925
28953
  if (!this.isPartialSelect) {
@@ -29778,7 +29806,7 @@ var SQLiteUpdateBase = class extends QueryPromise {
29778
29806
  createJoin(joinType) {
29779
29807
  return (table, on) => {
29780
29808
  const tableName = getTableLikeName(table);
29781
- if (typeof tableName === "string" && this.config.joins.some((join19) => join19.alias === tableName)) {
29809
+ if (typeof tableName === "string" && this.config.joins.some((join20) => join20.alias === tableName)) {
29782
29810
  throw new Error(`Alias "${tableName}" is already used in this query`);
29783
29811
  }
29784
29812
  if (typeof on === "function") {
@@ -31101,6 +31129,7 @@ function recordsEqual(left, right) {
31101
31129
  }
31102
31130
  var AgentSession = class _AgentSession {
31103
31131
  #connection;
31132
+ #contentExternalizer;
31104
31133
  #interactions;
31105
31134
  #additionalDirectories;
31106
31135
  #agentId;
@@ -31128,7 +31157,7 @@ var AgentSession = class _AgentSession {
31128
31157
  #sessionTitle = null;
31129
31158
  #sessionUpdatedAt = "";
31130
31159
  #turn = new IdleAcpTurn();
31131
- constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics) {
31160
+ constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics, contentExternalizer) {
31132
31161
  this.#updates = new AgentUpdateStream((notification) => this.#processUpdate(notification));
31133
31162
  this.#additionalDirectories = [...additionalDirectories];
31134
31163
  this.#agentId = agent.id;
@@ -31148,8 +31177,9 @@ var AgentSession = class _AgentSession {
31148
31177
  observer: getObserver
31149
31178
  });
31150
31179
  this.#connection = new AgentConnection(agent, cwd, this);
31180
+ this.#contentExternalizer = contentExternalizer;
31151
31181
  }
31152
- static async #start(options, getObserver, store, initialize, metrics) {
31182
+ static async #start(options, getObserver, store, initialize, metrics, contentExternalizer) {
31153
31183
  for (let attempt = 1; attempt <= 2; attempt += 1) {
31154
31184
  options.signal.throwIfAborted();
31155
31185
  const unchanged = await metrics.measure(
@@ -31177,7 +31207,8 @@ var AgentSession = class _AgentSession {
31177
31207
  options.sessionId,
31178
31208
  getObserver,
31179
31209
  store,
31180
- metrics
31210
+ metrics,
31211
+ contentExternalizer
31181
31212
  )
31182
31213
  );
31183
31214
  try {
@@ -31200,19 +31231,21 @@ var AgentSession = class _AgentSession {
31200
31231
  }
31201
31232
  throw new AcpExecutionError("ACP agent initialization failed");
31202
31233
  }
31203
- static start = async (options, getObserver, store, metrics = unmeasuredOperationMetrics) => await _AgentSession.#start(
31234
+ static start = async (options, getObserver, store, metrics, contentExternalizer) => await _AgentSession.#start(
31204
31235
  options,
31205
31236
  getObserver,
31206
31237
  store,
31207
31238
  async (runtime) => await runtime.initialize(options.signal, options.origin),
31208
- metrics
31239
+ metrics,
31240
+ contentExternalizer
31209
31241
  );
31210
- static startNativeSessionBrowser = async (options, getObserver, store) => await _AgentSession.#start(
31242
+ static startNativeSessionBrowser = async (options, getObserver, store, contentExternalizer) => await _AgentSession.#start(
31211
31243
  options,
31212
31244
  getObserver,
31213
31245
  store,
31214
31246
  async (runtime) => await runtime.#initializeAgent(options.signal),
31215
- unmeasuredOperationMetrics
31247
+ unmeasuredOperationMetrics,
31248
+ contentExternalizer
31216
31249
  );
31217
31250
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
31218
31251
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
@@ -31917,7 +31950,12 @@ var AgentSession = class _AgentSession {
31917
31950
  #processUpdate = async (notification) => {
31918
31951
  this.assertNativeSession(notification.sessionId);
31919
31952
  const update = notification.update;
31920
- const rawUpdate = decodeAcpSessionUpdateV2(JSON.stringify(update));
31953
+ const externalized = await this.#contentExternalizer.update(
31954
+ this.#mobiusSessionId,
31955
+ update,
31956
+ AbortSignal.timeout(3e4)
31957
+ );
31958
+ const rawUpdate = decodeAcpSessionUpdateV2(JSON.stringify(externalized));
31921
31959
  if (this.#sessionLoad.kind === "capturing") {
31922
31960
  await this.#sessionLoad.history.record(update, rawUpdate);
31923
31961
  } else {
@@ -32204,8 +32242,10 @@ var AgentQueryProcesses = class {
32204
32242
  #processes;
32205
32243
  #observer = new NullAcpSessionObserver();
32206
32244
  #store = new MemoryAcpSessionStore();
32207
- constructor(processes) {
32245
+ #contentExternalizer;
32246
+ constructor(processes, contentExternalizer) {
32208
32247
  this.#processes = processes;
32248
+ this.#contentExternalizer = contentExternalizer;
32209
32249
  this.#processesByQuery = new RetainedAgentProcesses({
32210
32250
  touch: processes.touch,
32211
32251
  changed: processes.notifyChanged
@@ -32221,7 +32261,12 @@ var AgentQueryProcesses = class {
32221
32261
  async #startRetained(options) {
32222
32262
  const runtime = await this.#processes.startRetained(
32223
32263
  options.signal,
32224
- () => AgentSession.startNativeSessionBrowser(options, () => this.#observer, this.#store),
32264
+ () => AgentSession.startNativeSessionBrowser(
32265
+ options,
32266
+ () => this.#observer,
32267
+ this.#store,
32268
+ this.#contentExternalizer
32269
+ ),
32225
32270
  {
32226
32271
  isBusy: () => this.#processesByQuery.isBusy(options.sessionId),
32227
32272
  retire: (runtime2) => this.retire(options.sessionId, runtime2)
@@ -32297,7 +32342,8 @@ var AgentQueryProcesses = class {
32297
32342
  async () => await AgentSession.startNativeSessionBrowser(
32298
32343
  options,
32299
32344
  () => this.#observer,
32300
- new MemoryAcpSessionStore()
32345
+ new MemoryAcpSessionStore(),
32346
+ this.#contentExternalizer
32301
32347
  ),
32302
32348
  async (runtime) => {
32303
32349
  runtime.selectNativeSession(nativeSessionId);
@@ -32312,7 +32358,8 @@ var AgentQueryProcesses = class {
32312
32358
  async () => await AgentSession.startNativeSessionBrowser(
32313
32359
  options,
32314
32360
  () => this.#observer,
32315
- new MemoryAcpSessionStore()
32361
+ new MemoryAcpSessionStore(),
32362
+ this.#contentExternalizer
32316
32363
  ),
32317
32364
  async (runtime) => {
32318
32365
  runtime.selectNativeSession(nativeSessionId);
@@ -32328,6 +32375,220 @@ var AgentQueryProcesses = class {
32328
32375
  };
32329
32376
  };
32330
32377
 
32378
+ // src/external-content/acp-content-externalizer.ts
32379
+ var MAXIMUM_ENCODED_CONTENT_CHARACTERS = 4e6;
32380
+ function decodeBase64(data) {
32381
+ if (data.length > MAXIMUM_ENCODED_CONTENT_CHARACTERS || data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(data)) {
32382
+ throw new Error("The ACP embedded content is not valid bounded base64");
32383
+ }
32384
+ return Buffer.from(data, "base64");
32385
+ }
32386
+ var AcpContentExternalizer = class {
32387
+ #store;
32388
+ constructor(store) {
32389
+ this.#store = store;
32390
+ }
32391
+ async #content(sessionId, content, signal) {
32392
+ switch (content.type) {
32393
+ case "text":
32394
+ case "resource_link":
32395
+ return content;
32396
+ case "image": {
32397
+ if (content.data.length === 0) {
32398
+ return content;
32399
+ }
32400
+ const stored = await this.#store.put({
32401
+ bytes: decodeBase64(content.data),
32402
+ kind: "image",
32403
+ mediaType: content.mimeType,
32404
+ name: "image",
32405
+ sessionId,
32406
+ signal
32407
+ });
32408
+ return {
32409
+ _meta: content._meta,
32410
+ annotations: content.annotations,
32411
+ byteLength: stored.byteLength,
32412
+ imageKey: stored.key,
32413
+ mimeType: content.mimeType,
32414
+ type: "external_image",
32415
+ uri: content.uri
32416
+ };
32417
+ }
32418
+ case "audio": {
32419
+ if (content.data.length === 0) {
32420
+ return content;
32421
+ }
32422
+ const stored = await this.#store.put({
32423
+ bytes: decodeBase64(content.data),
32424
+ kind: "audio",
32425
+ mediaType: content.mimeType,
32426
+ name: "audio",
32427
+ sessionId,
32428
+ signal
32429
+ });
32430
+ return {
32431
+ _meta: content._meta,
32432
+ annotations: content.annotations,
32433
+ audioKey: stored.key,
32434
+ byteLength: stored.byteLength,
32435
+ mimeType: content.mimeType,
32436
+ type: "external_audio"
32437
+ };
32438
+ }
32439
+ case "resource": {
32440
+ const embedded = content.resource;
32441
+ const encoding = "text" in embedded ? "text" : "binary";
32442
+ const bytes = "text" in embedded ? Buffer.from(embedded.text, "utf8") : decodeBase64(embedded.blob);
32443
+ if (bytes.byteLength === 0) {
32444
+ return content;
32445
+ }
32446
+ const mediaType = embedded.mimeType ?? "application/octet-stream";
32447
+ const stored = await this.#store.put({
32448
+ bytes,
32449
+ kind: "resource",
32450
+ mediaType,
32451
+ name: "resource",
32452
+ sessionId,
32453
+ signal
32454
+ });
32455
+ return {
32456
+ _meta: content._meta,
32457
+ annotations: content.annotations,
32458
+ byteLength: stored.byteLength,
32459
+ encoding,
32460
+ mimeType: embedded.mimeType,
32461
+ resourceKey: stored.key,
32462
+ type: "external_resource",
32463
+ uri: embedded.uri
32464
+ };
32465
+ }
32466
+ }
32467
+ }
32468
+ async #toolContent(sessionId, item, signal) {
32469
+ return item.type === "content" ? { ...item, content: await this.#content(sessionId, item.content, signal) } : item;
32470
+ }
32471
+ update = async (sessionId, update, signal) => {
32472
+ switch (update.sessionUpdate) {
32473
+ case "user_message_chunk":
32474
+ case "agent_message_chunk":
32475
+ case "agent_thought_chunk":
32476
+ case "compaction_summary_chunk":
32477
+ return { ...update, content: await this.#content(sessionId, update.content, signal) };
32478
+ case "tool_call":
32479
+ case "tool_call_update":
32480
+ return update.content === void 0 || update.content === null ? update : {
32481
+ ...update,
32482
+ content: await Promise.all(
32483
+ update.content.map(async (item) => await this.#toolContent(sessionId, item, signal))
32484
+ )
32485
+ };
32486
+ case "compaction_update":
32487
+ return update.summary === void 0 || update.summary === null ? update : {
32488
+ ...update,
32489
+ summary: await Promise.all(
32490
+ update.summary.map(async (content) => await this.#content(sessionId, content, signal))
32491
+ )
32492
+ };
32493
+ case "plan":
32494
+ case "plan_update":
32495
+ case "plan_removed":
32496
+ case "available_commands_update":
32497
+ case "current_mode_update":
32498
+ case "config_option_update":
32499
+ case "session_info_update":
32500
+ case "usage_update":
32501
+ return update;
32502
+ }
32503
+ };
32504
+ };
32505
+
32506
+ // src/external-content/local-external-content-store.ts
32507
+ import { createHash, randomUUID } from "node:crypto";
32508
+ import { lstat, mkdir, readFile as readFile3, realpath as realpath3, rename, rm, stat as stat3, writeFile } from "node:fs/promises";
32509
+ import { dirname as dirname2, join as join4 } from "node:path";
32510
+ var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
32511
+ var metadataSchema2 = external_exports.strictObject({
32512
+ kind: external_exports.enum(["image", "audio", "resource"]),
32513
+ mediaType: external_exports.string().min(1).max(2048).regex(/^[\u0020-\u007e]+$/u),
32514
+ name: external_exports.string().min(1).max(500)
32515
+ });
32516
+ var UnretainedExternalContentStore = class {
32517
+ put = async ({ bytes, signal }) => {
32518
+ signal.throwIfAborted();
32519
+ return { byteLength: bytes.byteLength, key: createHash("sha256").update(bytes).digest("hex") };
32520
+ };
32521
+ resolve = (_sessionId, _request, signal) => {
32522
+ signal.throwIfAborted();
32523
+ return Promise.resolve(null);
32524
+ };
32525
+ };
32526
+ function sessionScope(sessionId) {
32527
+ return createHash("sha256").update(sessionId).digest("hex");
32528
+ }
32529
+ async function atomicWrite(path2, bytes, signal) {
32530
+ const temporary = `${path2}.${randomUUID()}.tmp`;
32531
+ try {
32532
+ await writeFile(temporary, bytes, { mode: 384, signal });
32533
+ signal.throwIfAborted();
32534
+ await rename(temporary, path2);
32535
+ } finally {
32536
+ await rm(temporary, { force: true });
32537
+ }
32538
+ }
32539
+ var LocalExternalContentStore = class {
32540
+ #root;
32541
+ constructor(stateDirectory) {
32542
+ this.#root = join4(stateDirectory, "tmp", "session-content");
32543
+ }
32544
+ put = async ({ bytes, kind, mediaType, name, sessionId, signal }) => {
32545
+ signal.throwIfAborted();
32546
+ const key = createHash("sha256").update(bytes).digest("hex");
32547
+ const directory = join4(this.#root, sessionScope(sessionId), kind);
32548
+ await mkdir(directory, { mode: 448, recursive: true });
32549
+ signal.throwIfAborted();
32550
+ const path2 = join4(directory, key);
32551
+ await atomicWrite(path2, bytes, signal);
32552
+ await atomicWrite(
32553
+ `${path2}.json`,
32554
+ Buffer.from(JSON.stringify(metadataSchema2.parse({ kind, mediaType, name })), "utf8"),
32555
+ signal
32556
+ );
32557
+ return { byteLength: bytes.byteLength, key };
32558
+ };
32559
+ resolve = async (sessionId, request, signal) => {
32560
+ const matched = contentRequest.exec(request);
32561
+ if (matched === null) {
32562
+ return null;
32563
+ }
32564
+ const kind = matched[1];
32565
+ const key = matched[2];
32566
+ if (kind !== "image" && kind !== "audio" && kind !== "resource" || key === void 0) {
32567
+ return null;
32568
+ }
32569
+ const directory = join4(this.#root, sessionScope(sessionId), kind);
32570
+ const path2 = join4(directory, key);
32571
+ try {
32572
+ const [resolvedDirectory, resolvedPath, file2, metadata] = await Promise.all([
32573
+ realpath3(directory),
32574
+ realpath3(path2),
32575
+ lstat(path2),
32576
+ readFile3(`${path2}.json`, "utf8").then((value) => metadataSchema2.parse(JSON.parse(value)))
32577
+ ]);
32578
+ signal.throwIfAborted();
32579
+ if (!file2.isFile() || dirname2(resolvedPath) !== resolvedDirectory || metadata.kind !== kind) {
32580
+ return null;
32581
+ }
32582
+ await stat3(resolvedPath);
32583
+ signal.throwIfAborted();
32584
+ return { mediaType: metadata.mediaType, name: metadata.name, path: resolvedPath };
32585
+ } catch {
32586
+ signal.throwIfAborted();
32587
+ return null;
32588
+ }
32589
+ };
32590
+ };
32591
+
32331
32592
  // src/native-sessions/chat-agent.ts
32332
32593
  function supportsNativeChat(agentId) {
32333
32594
  return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
@@ -32544,7 +32805,7 @@ var AgentRuntimeManager = class {
32544
32805
  touch: this.#processes.touch,
32545
32806
  changed: this.#processes.notifyChanged
32546
32807
  });
32547
- #queryProcesses = new AgentQueryProcesses(this.#processes);
32808
+ #queryProcesses;
32548
32809
  #executions = new ActiveExecutions();
32549
32810
  #agentSettingsObserver = new NullAcpSessionObserver();
32550
32811
  #nativeOperations = /* @__PURE__ */ new Set();
@@ -32552,13 +32813,16 @@ var AgentRuntimeManager = class {
32552
32813
  #nativeHistoryReader;
32553
32814
  #sessionIdentity;
32554
32815
  #onSessionStatusChanged;
32816
+ #contentExternalizer;
32555
32817
  #observer;
32556
- constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0) {
32818
+ constructor(observer = new NullAcpSessionObserver(), store = new MemoryAcpSessionStore(), nativeHistoryReader = null, sessionIdentity = "assigned", onSessionStatusChanged = () => void 0, contentExternalizer = new AcpContentExternalizer(new UnretainedExternalContentStore())) {
32557
32819
  this.#observer = observer;
32558
32820
  this.#store = store;
32559
32821
  this.#nativeHistoryReader = nativeHistoryReader;
32560
32822
  this.#sessionIdentity = sessionIdentity;
32561
32823
  this.#onSessionStatusChanged = onSessionStatusChanged;
32824
+ this.#contentExternalizer = contentExternalizer;
32825
+ this.#queryProcesses = new AgentQueryProcesses(this.#processes, contentExternalizer);
32562
32826
  }
32563
32827
  setObserver = (observer) => {
32564
32828
  this.#observer = observer;
@@ -32599,7 +32863,8 @@ var AgentRuntimeManager = class {
32599
32863
  options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
32600
32864
  () => this.#observer,
32601
32865
  this.#store,
32602
- metrics
32866
+ metrics,
32867
+ this.#contentExternalizer
32603
32868
  )
32604
32869
  );
32605
32870
  });
@@ -32614,7 +32879,13 @@ var AgentRuntimeManager = class {
32614
32879
  this.#store.remove(options.sessionId);
32615
32880
  return await this.#startRetainedSessionProcess(
32616
32881
  options,
32617
- async () => await AgentSession.start(options, () => this.#observer, this.#store, metrics)
32882
+ async () => await AgentSession.start(
32883
+ options,
32884
+ () => this.#observer,
32885
+ this.#store,
32886
+ metrics,
32887
+ this.#contentExternalizer
32888
+ )
32618
32889
  );
32619
32890
  });
32620
32891
  }
@@ -32624,7 +32895,13 @@ var AgentRuntimeManager = class {
32624
32895
  await this.#retireSessionProcess(options.sessionId, existing, async () => await existing.close());
32625
32896
  const runtime = await this.#startRetainedSessionProcess(
32626
32897
  options,
32627
- async () => await AgentSession.start(options, () => this.#observer, this.#store)
32898
+ async () => await AgentSession.start(
32899
+ options,
32900
+ () => this.#observer,
32901
+ this.#store,
32902
+ unmeasuredOperationMetrics,
32903
+ this.#contentExternalizer
32904
+ )
32628
32905
  );
32629
32906
  try {
32630
32907
  for (const desired of desiredConfigOptions) {
@@ -32720,7 +32997,9 @@ var AgentRuntimeManager = class {
32720
32997
  sessionId: `agent-settings-${crypto.randomUUID()}`
32721
32998
  },
32722
32999
  () => this.#agentSettingsObserver,
32723
- new MemoryAcpSessionStore()
33000
+ new MemoryAcpSessionStore(),
33001
+ unmeasuredOperationMetrics,
33002
+ this.#contentExternalizer
32724
33003
  ),
32725
33004
  async (runtime) => {
32726
33005
  const prepared = runtime.prepared();
@@ -33250,7 +33529,7 @@ var LocalAuthorizationError = class extends Error {
33250
33529
  };
33251
33530
 
33252
33531
  // src/pairing/pair-local-machine.ts
33253
- import { mkdir as mkdir5, realpath as realpath7, stat as stat6 } from "node:fs/promises";
33532
+ import { mkdir as mkdir6, realpath as realpath8, stat as stat7 } from "node:fs/promises";
33254
33533
  import { hostname as hostname3 } from "node:os";
33255
33534
  import { basename as basename3, resolve as resolve5 } from "node:path";
33256
33535
  import { fetch as fetch2 } from "undici";
@@ -33395,8 +33674,8 @@ var LocalAgentInventory = class {
33395
33674
  };
33396
33675
 
33397
33676
  // src/agent-installation/managed-npm-package.ts
33398
- import { mkdir, mkdtemp, open as open3, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
33399
- import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
33677
+ import { mkdir as mkdir2, mkdtemp, open as open3, realpath as realpath4, rename as rename2, rm as rm2, stat as stat4 } from "node:fs/promises";
33678
+ import { delimiter, dirname as dirname3, isAbsolute as isAbsolute2, join as join5, relative, sep } from "node:path";
33400
33679
  var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
33401
33680
  var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
33402
33681
  var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
@@ -33447,7 +33726,7 @@ function isRecord6(value) {
33447
33726
  return typeof value === "object" && value !== null && !Array.isArray(value);
33448
33727
  }
33449
33728
  function packagePath(root, packageName) {
33450
- return join4(root, "node_modules", ...packageName.split("/"));
33729
+ return join5(root, "node_modules", ...packageName.split("/"));
33451
33730
  }
33452
33731
  function isContainedPath(root, candidate) {
33453
33732
  const difference = relative(root, candidate);
@@ -33552,14 +33831,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
33552
33831
  }
33553
33832
  }
33554
33833
  async function verifyRequiredDependency(rootPath, lock, definition) {
33555
- const dependencyRoot = await realpath3(packagePath(rootPath, definition.packageName));
33834
+ const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
33556
33835
  if (!isContainedPath(rootPath, dependencyRoot)) {
33557
33836
  throw new ManagedNpmPackageError(
33558
33837
  "managed_package_verification_failed",
33559
33838
  "The required managed npm dependency escaped its private cache"
33560
33839
  );
33561
33840
  }
33562
- const metadata = await readJsonRecord(join4(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33841
+ const metadata = await readJsonRecord(join5(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33563
33842
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
33564
33843
  throw new ManagedNpmPackageError(
33565
33844
  "managed_package_verification_failed",
@@ -33581,15 +33860,15 @@ async function validateManagedNpmPackage(root, definition) {
33581
33860
  }
33582
33861
  }
33583
33862
  async function validateManagedNpmPackageContents(root, definition) {
33584
- const rootPath = await realpath3(root);
33585
- const packageRoot = await realpath3(packagePath(rootPath, definition.packageName));
33863
+ const rootPath = await realpath4(root);
33864
+ const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
33586
33865
  if (!isContainedPath(rootPath, packageRoot)) {
33587
33866
  throw new ManagedNpmPackageError(
33588
33867
  "managed_package_verification_failed",
33589
33868
  "The managed npm package escaped its private cache"
33590
33869
  );
33591
33870
  }
33592
- const metadata = await readJsonRecord(join4(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33871
+ const metadata = await readJsonRecord(join5(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33593
33872
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
33594
33873
  throw new ManagedNpmPackageError(
33595
33874
  "managed_package_verification_failed",
@@ -33597,14 +33876,14 @@ async function validateManagedNpmPackageContents(root, definition) {
33597
33876
  );
33598
33877
  }
33599
33878
  if (definition instanceof SriManagedNpmPackageDefinition) {
33600
- const lock = await readJsonRecord(join4(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
33879
+ const lock = await readJsonRecord(join5(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
33601
33880
  verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
33602
33881
  for (const dependency of definition.requiredDependencies) {
33603
33882
  await verifyRequiredDependency(rootPath, lock, dependency);
33604
33883
  }
33605
33884
  }
33606
33885
  const declaredBin = readBinPath(metadata, definition.executableName);
33607
- const executable = await resolveExecutablePath(join4(packageRoot, declaredBin));
33886
+ const executable = await resolveExecutablePath(join5(packageRoot, declaredBin));
33608
33887
  if (executable === null || !isContainedPath(rootPath, executable.path)) {
33609
33888
  throw new ManagedNpmPackageError(
33610
33889
  "managed_package_verification_failed",
@@ -33617,7 +33896,7 @@ var ManagedNpmPackageInstaller = class {
33617
33896
  install = async (root, definition, environment, signal) => {
33618
33897
  signal.throwIfAborted();
33619
33898
  try {
33620
- const metadata = await stat3(root);
33899
+ const metadata = await stat4(root);
33621
33900
  if (metadata.isDirectory()) {
33622
33901
  return await validateManagedNpmPackage(root, definition);
33623
33902
  }
@@ -33626,9 +33905,9 @@ var ManagedNpmPackageInstaller = class {
33626
33905
  throw error62;
33627
33906
  }
33628
33907
  }
33629
- const parent = dirname2(root);
33630
- await mkdir(parent, { mode: 448, recursive: true });
33631
- const staging = await mkdtemp(join4(parent, `.${definition.version}.staging-`));
33908
+ const parent = dirname3(root);
33909
+ await mkdir2(parent, { mode: 448, recursive: true });
33910
+ const staging = await mkdtemp(join5(parent, `.${definition.version}.staging-`));
33632
33911
  try {
33633
33912
  const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
33634
33913
  if (npm === null) {
@@ -33654,14 +33933,14 @@ var ManagedNpmPackageInstaller = class {
33654
33933
  `${definition.packageName}@${definition.version}`
33655
33934
  );
33656
33935
  const installEnvironment = {
33657
- HOME: join4(staging, "home"),
33936
+ HOME: join5(staging, "home"),
33658
33937
  NPM_CONFIG_AUDIT: "false",
33659
- NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
33938
+ NPM_CONFIG_CACHE: join5(staging, ".npm-cache"),
33660
33939
  NPM_CONFIG_FUND: "false",
33661
33940
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
33662
33941
  NPM_CONFIG_PACKAGE_LOCK: "true",
33663
33942
  NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
33664
- PATH: `${dirname2(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
33943
+ PATH: `${dirname3(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
33665
33944
  };
33666
33945
  if (definition.includeOptionalDependencies) {
33667
33946
  installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
@@ -33678,12 +33957,12 @@ var ManagedNpmPackageInstaller = class {
33678
33957
  timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
33679
33958
  });
33680
33959
  await Promise.all([
33681
- rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
33682
- rm(join4(staging, "home"), { force: true, recursive: true })
33960
+ rm2(join5(staging, ".npm-cache"), { force: true, recursive: true }),
33961
+ rm2(join5(staging, "home"), { force: true, recursive: true })
33683
33962
  ]);
33684
33963
  await validateManagedNpmPackage(staging, definition);
33685
33964
  try {
33686
- await rename(staging, root);
33965
+ await rename2(staging, root);
33687
33966
  } catch (error62) {
33688
33967
  try {
33689
33968
  return await validateManagedNpmPackage(root, definition);
@@ -33709,13 +33988,13 @@ var ManagedNpmPackageInstaller = class {
33709
33988
  { cause: error62 }
33710
33989
  );
33711
33990
  } finally {
33712
- await rm(staging, { force: true, recursive: true });
33991
+ await rm2(staging, { force: true, recursive: true });
33713
33992
  }
33714
33993
  };
33715
33994
  };
33716
33995
 
33717
33996
  // src/agent-catalog/agent-specification.ts
33718
- import { join as join5 } from "node:path";
33997
+ import { join as join6 } from "node:path";
33719
33998
 
33720
33999
  // src/agent-catalog/version-output.ts
33721
34000
  function normalizeVersionOutput(output2) {
@@ -33738,7 +34017,7 @@ var LocalAgentSpecification = class {
33738
34017
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
33739
34018
  signal.throwIfAborted();
33740
34019
  const executable = await resolveExecutablePath(
33741
- join5(stateDirectory, ...this.managedAgentExecutablePath),
34020
+ join6(stateDirectory, ...this.managedAgentExecutablePath),
33742
34021
  platform
33743
34022
  );
33744
34023
  signal.throwIfAborted();
@@ -35664,7 +35943,7 @@ var AgentProbeError = class extends Error {
35664
35943
  };
35665
35944
 
35666
35945
  // src/agent-catalog/agents/resolve-user-local-executable.ts
35667
- import { isAbsolute as isAbsolute3, join as join6 } from "node:path";
35946
+ import { isAbsolute as isAbsolute3, join as join7 } from "node:path";
35668
35947
  async function resolveUserLocalExecutable(executableName, context) {
35669
35948
  context.signal.throwIfAborted();
35670
35949
  const platform = context.platform ?? process.platform;
@@ -35672,7 +35951,7 @@ async function resolveUserLocalExecutable(executableName, context) {
35672
35951
  if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
35673
35952
  return [];
35674
35953
  }
35675
- const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
35954
+ const executable = await resolveExecutablePath(join7(homeDirectory, ".local", "bin", executableName), platform);
35676
35955
  context.signal.throwIfAborted();
35677
35956
  return executable === null ? [] : [executable];
35678
35957
  }
@@ -35761,8 +36040,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35761
36040
  };
35762
36041
 
35763
36042
  // src/agent-catalog/agents/deepseek-harness-agent.ts
35764
- import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
35765
- import { isAbsolute as isAbsolute4, join as join7, normalize as normalize2 } from "node:path";
36043
+ import { mkdir as mkdir3, realpath as realpath5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
36044
+ import { isAbsolute as isAbsolute4, join as join8, normalize as normalize2 } from "node:path";
35766
36045
 
35767
36046
  // src/agent-installation/deepseek-managed-package.ts
35768
36047
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -35791,15 +36070,15 @@ async function prepareAgentHome(path2, imagePrompts) {
35791
36070
  }
35792
36071
  try {
35793
36072
  if (imagePrompts) {
35794
- await mkdir2(path2, { mode: 448, recursive: true });
36073
+ await mkdir3(path2, { mode: 448, recursive: true });
35795
36074
  }
35796
- const resolved = await realpath4(path2);
35797
- const metadata = await stat4(resolved);
36075
+ const resolved = await realpath5(path2);
36076
+ const metadata = await stat5(resolved);
35798
36077
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
35799
36078
  throw new Error("Agent home is not a user-owned directory");
35800
36079
  }
35801
36080
  if (imagePrompts) {
35802
- await writeFile(join7(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
36081
+ await writeFile2(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
35803
36082
  mode: 384
35804
36083
  });
35805
36084
  }
@@ -35847,7 +36126,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
35847
36126
  context.signal
35848
36127
  );
35849
36128
  if (managed.path === agent.path) {
35850
- selectedHome = join7(readStateDirectory(context.environment), "agents", this.id, "home");
36129
+ selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
35851
36130
  managedHome = true;
35852
36131
  }
35853
36132
  } catch {
@@ -35863,7 +36142,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
35863
36142
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
35864
36143
  signal.throwIfAborted();
35865
36144
  const executable = await validateManagedNpmPackage(
35866
- join7(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
36145
+ join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
35867
36146
  DEEPSEEK_HARNESS_PACKAGE
35868
36147
  );
35869
36148
  signal.throwIfAborted();
@@ -35917,8 +36196,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
35917
36196
  };
35918
36197
 
35919
36198
  // src/agent-catalog/agents/grok-build-agent.ts
35920
- import { realpath as realpath5 } from "node:fs/promises";
35921
- import { isAbsolute as isAbsolute5, join as join8, relative as relative2, sep as sep2 } from "node:path";
36199
+ import { realpath as realpath6 } from "node:fs/promises";
36200
+ import { isAbsolute as isAbsolute5, join as join9, relative as relative2, sep as sep2 } from "node:path";
35922
36201
  import {
35923
36202
  RequestError as RequestError2
35924
36203
  } from "@agentclientprotocol/sdk";
@@ -36013,8 +36292,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
36013
36292
  );
36014
36293
  if (managed.path === agent.path) {
36015
36294
  return Object.freeze({
36016
- GROK_HOME: await realpath5(
36017
- join8(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
36295
+ GROK_HOME: await realpath6(
36296
+ join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
36018
36297
  )
36019
36298
  });
36020
36299
  }
@@ -36025,9 +36304,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
36025
36304
  };
36026
36305
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
36027
36306
  signal.throwIfAborted();
36028
- const versionRoot = await realpath5(join8(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
36029
- await validateManagedNpmPackage(join8(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
36030
- const executable = await resolveExecutablePath(join8(versionRoot, "home", "bin", "grok"), platform);
36307
+ const versionRoot = await realpath6(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
36308
+ await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
36309
+ const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
36031
36310
  signal.throwIfAborted();
36032
36311
  if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
36033
36312
  throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
@@ -36127,13 +36406,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
36127
36406
  };
36128
36407
 
36129
36408
  // src/agent-catalog/agents/opencode-agent.ts
36130
- import { join as join10 } from "node:path";
36409
+ import { join as join11 } from "node:path";
36131
36410
 
36132
36411
  // src/agent-installation/managed-agent-archive.ts
36133
- import { createHash } from "node:crypto";
36412
+ import { createHash as createHash2 } from "node:crypto";
36134
36413
  import { createReadStream } from "node:fs";
36135
- import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open4, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
36136
- import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute6, join as join9, relative as relative3, sep as sep3 } from "node:path";
36414
+ import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath7, rename as rename3, rm as rm3, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
36415
+ import { delimiter as delimiter2, dirname as dirname4, isAbsolute as isAbsolute6, join as join10, relative as relative3, sep as sep3 } from "node:path";
36137
36416
 
36138
36417
  // src/agent-installation/verified-download.ts
36139
36418
  import { fetch } from "undici";
@@ -36243,7 +36522,7 @@ function isContainedPath3(root, candidate) {
36243
36522
  }
36244
36523
  async function hashFile(path2, signal) {
36245
36524
  signal.throwIfAborted();
36246
- const digest = createHash("sha256");
36525
+ const digest = createHash2("sha256");
36247
36526
  const stream = createReadStream(path2, { signal });
36248
36527
  try {
36249
36528
  for await (const chunk of stream) {
@@ -36313,16 +36592,16 @@ async function readManifest(path2) {
36313
36592
  }
36314
36593
  async function validateManagedAgentArchive(root, definition, signal) {
36315
36594
  try {
36316
- const rootPath = await realpath6(root);
36317
- const rootMetadata = await stat5(rootPath);
36595
+ const rootPath = await realpath7(root);
36596
+ const rootMetadata = await stat6(rootPath);
36318
36597
  if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
36319
36598
  throw new Error("Managed Agent root is not user-owned");
36320
36599
  }
36321
- const manifest = await readManifest(join9(rootPath, "archive.json"));
36600
+ const manifest = await readManifest(join10(rootPath, "archive.json"));
36322
36601
  if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
36323
36602
  throw new Error("Managed Agent archive identity is invalid");
36324
36603
  }
36325
- const executable = await resolveExecutablePath(join9(rootPath, "bin", definition.executableName));
36604
+ const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
36326
36605
  if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
36327
36606
  throw new Error("Managed Agent executable is invalid");
36328
36607
  }
@@ -36514,7 +36793,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
36514
36793
  return Object.freeze(environment);
36515
36794
  };
36516
36795
  resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
36517
- join10(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
36796
+ join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
36518
36797
  openCodeManagedArchive(platform, process.arch),
36519
36798
  signal
36520
36799
  );
@@ -36532,7 +36811,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
36532
36811
  };
36533
36812
 
36534
36813
  // src/agent-catalog/agents/pi-agent.ts
36535
- import { join as join11 } from "node:path";
36814
+ import { join as join12 } from "node:path";
36536
36815
  import {
36537
36816
  methods as methods7
36538
36817
  } from "@agentclientprotocol/sdk";
@@ -36591,7 +36870,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36591
36870
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
36592
36871
  signal.throwIfAborted();
36593
36872
  const executable = await validateManagedNpmPackage(
36594
- join11(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
36873
+ join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
36595
36874
  PI_AGENT_PACKAGE
36596
36875
  );
36597
36876
  signal.throwIfAborted();
@@ -36629,7 +36908,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36629
36908
  };
36630
36909
 
36631
36910
  // src/agent-catalog/agents/workbuddy-agent.ts
36632
- import { isAbsolute as isAbsolute7, join as join12 } from "node:path";
36911
+ import { isAbsolute as isAbsolute7, join as join13 } from "node:path";
36633
36912
 
36634
36913
  // src/agent-installation/workbuddy-managed-package.ts
36635
36914
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -36684,7 +36963,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36684
36963
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
36685
36964
  signal.throwIfAborted();
36686
36965
  const executable = await validateManagedNpmPackage(
36687
- join12(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
36966
+ join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
36688
36967
  WORKBUDDY_MANAGED_PACKAGE
36689
36968
  );
36690
36969
  signal.throwIfAborted();
@@ -36695,10 +36974,10 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36695
36974
  if ((context.platform ?? process.platform) !== "darwin") {
36696
36975
  return [];
36697
36976
  }
36698
- const requestedPaths = [join12("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
36977
+ const requestedPaths = [join13("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
36699
36978
  const homeDirectory = context.environment["HOME"];
36700
36979
  if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
36701
- requestedPaths.unshift(join12(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
36980
+ requestedPaths.unshift(join13(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
36702
36981
  }
36703
36982
  const executables = [];
36704
36983
  for (const requestedPath2 of requestedPaths) {
@@ -37033,10 +37312,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
37033
37312
  }
37034
37313
 
37035
37314
  // src/agent-catalog/executable-discovery.ts
37036
- import { isAbsolute as isAbsolute8, join as join14 } from "node:path";
37315
+ import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
37037
37316
 
37038
37317
  // src/agent-installation/managed-adapter-installer.ts
37039
- import { join as join13 } from "node:path";
37318
+ import { join as join14 } from "node:path";
37040
37319
  var ManagedAdapterInstallError = class extends Error {
37041
37320
  code;
37042
37321
  constructor(code, message, options = {}) {
@@ -37093,7 +37372,7 @@ var ManagedAdapterInstaller = class {
37093
37372
  this.#stateDirectory = options.stateDirectory;
37094
37373
  }
37095
37374
  install = async (specification, signal) => {
37096
- const root = join13(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
37375
+ const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
37097
37376
  try {
37098
37377
  return await this.#npmInstaller.install(
37099
37378
  root,
@@ -37127,7 +37406,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
37127
37406
  let managed;
37128
37407
  try {
37129
37408
  managed = await validateManagedAdapter(
37130
- join14(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
37409
+ join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
37131
37410
  specification
37132
37411
  );
37133
37412
  } catch {
@@ -37441,9 +37720,9 @@ async function discoverLocalAgentInventory(options) {
37441
37720
  }
37442
37721
 
37443
37722
  // src/storage/runtime-installation-store.ts
37444
- import { createHash as createHash2, randomUUID } from "node:crypto";
37445
- import { mkdir as mkdir4, open as open5, readdir as readdir2, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
37446
- import { dirname as dirname4, join as join15, resolve as resolve4 } from "node:path";
37723
+ import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
37724
+ import { mkdir as mkdir5, open as open5, readdir as readdir2, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
37725
+ import { dirname as dirname5, join as join16, resolve as resolve4 } from "node:path";
37447
37726
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
37448
37727
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
37449
37728
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
@@ -37571,13 +37850,13 @@ function parseRelayOrigin(value) {
37571
37850
  return origin;
37572
37851
  }
37573
37852
  function connectionId() {
37574
- return `mcn_${randomUUID().replaceAll("-", "")}`;
37853
+ return `mcn_${randomUUID2().replaceAll("-", "")}`;
37575
37854
  }
37576
37855
  function installationId() {
37577
- return `min_${randomUUID().replaceAll("-", "")}`;
37856
+ return `min_${randomUUID2().replaceAll("-", "")}`;
37578
37857
  }
37579
37858
  function channelIndexFileName(channelId) {
37580
- return `mci_${createHash2("sha256").update(channelId).digest("hex")}.json`;
37859
+ return `mci_${createHash3("sha256").update(channelId).digest("hex")}.json`;
37581
37860
  }
37582
37861
  function decodeInstallationPointer(value) {
37583
37862
  if (!isRecord8(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
@@ -37685,15 +37964,15 @@ async function readJsonFile(path2, signal, missingCode) {
37685
37964
  }
37686
37965
  async function writeJsonAtomically(path2, value, signal) {
37687
37966
  signal.throwIfAborted();
37688
- const directory = dirname4(path2);
37689
- const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
37967
+ const directory = dirname5(path2);
37968
+ const temporaryPath = join16(directory, `.${randomUUID2()}.tmp`);
37690
37969
  try {
37691
- await mkdir4(directory, { mode: 448, recursive: true });
37970
+ await mkdir5(directory, { mode: 448, recursive: true });
37692
37971
  signal.throwIfAborted();
37693
- await writeFile3(temporaryPath, `${JSON.stringify(value, null, 2)}
37972
+ await writeFile4(temporaryPath, `${JSON.stringify(value, null, 2)}
37694
37973
  `, { flag: "wx", mode: 384 });
37695
37974
  signal.throwIfAborted();
37696
- await rename3(temporaryPath, path2);
37975
+ await rename4(temporaryPath, path2);
37697
37976
  } catch (cause) {
37698
37977
  await unlink(temporaryPath).catch(() => void 0);
37699
37978
  signal.throwIfAborted();
@@ -37712,16 +37991,16 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37712
37991
  this.applicationId = applicationId;
37713
37992
  this.installationId = installationId2;
37714
37993
  this.stateDirectory = stateDirectory;
37715
- this.#channelDirectory = join15(stateDirectory, "channels");
37716
- this.#connectionDirectory = join15(stateDirectory, "connections");
37994
+ this.#channelDirectory = join16(stateDirectory, "channels");
37995
+ this.#connectionDirectory = join16(stateDirectory, "connections");
37717
37996
  }
37718
37997
  static open = async (options, signal) => {
37719
37998
  signal.throwIfAborted();
37720
37999
  const applicationId = validateApplicationId(options.applicationId);
37721
38000
  const rootDirectory = resolve4(options.stateDirectory);
37722
- const applicationDirectory = join15(rootDirectory, "installations", applicationId);
38001
+ const applicationDirectory = join16(rootDirectory, "installations", applicationId);
37723
38002
  try {
37724
- await mkdir4(applicationDirectory, { mode: 448, recursive: true });
38003
+ await mkdir5(applicationDirectory, { mode: 448, recursive: true });
37725
38004
  } catch (cause) {
37726
38005
  throw new RuntimeInstallationStoreError(
37727
38006
  "installation_unavailable",
@@ -37732,9 +38011,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37732
38011
  );
37733
38012
  }
37734
38013
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
37735
- const stateDirectory = join15(applicationDirectory, storedInstallationId);
38014
+ const stateDirectory = join16(applicationDirectory, storedInstallationId);
37736
38015
  try {
37737
- await mkdir4(stateDirectory, { mode: 448, recursive: true });
38016
+ await mkdir5(stateDirectory, { mode: 448, recursive: true });
37738
38017
  } catch (cause) {
37739
38018
  throw new RuntimeInstallationStoreError(
37740
38019
  "installation_unavailable",
@@ -37747,8 +38026,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37747
38026
  signal.throwIfAborted();
37748
38027
  return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
37749
38028
  };
37750
- connectionPath = (connectionId2) => join15(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
37751
- channelIndexPath = (channelId) => join15(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
38029
+ connectionPath = (connectionId2) => join16(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
38030
+ channelIndexPath = (channelId) => join16(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
37752
38031
  readConnection = async (connectionId2, signal) => {
37753
38032
  const stored = decodeConnection(
37754
38033
  await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
@@ -37910,7 +38189,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37910
38189
  };
37911
38190
  };
37912
38191
  async function readOrCreateInstallationId(applicationDirectory, signal) {
37913
- const pointerPath = join15(applicationDirectory, "current.json");
38192
+ const pointerPath = join16(applicationDirectory, "current.json");
37914
38193
  try {
37915
38194
  return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
37916
38195
  } catch (cause) {
@@ -37920,7 +38199,7 @@ async function readOrCreateInstallationId(applicationDirectory, signal) {
37920
38199
  }
37921
38200
  const candidate = installationId();
37922
38201
  try {
37923
- await writeFile3(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
38202
+ await writeFile4(pointerPath, `${JSON.stringify({ installationId: candidate, version: 1 })}
37924
38203
  `, {
37925
38204
  flag: "wx",
37926
38205
  mode: 384
@@ -38050,9 +38329,9 @@ function parseResumeConnectionId(arguments_) {
38050
38329
  async function resolveDefaultWorkspace(path2) {
38051
38330
  const requestedWorkspace = resolve5(path2);
38052
38331
  try {
38053
- await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
38054
- const defaultWorkspace = await realpath7(requestedWorkspace);
38055
- const metadata = await stat6(defaultWorkspace);
38332
+ await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
38333
+ const defaultWorkspace = await realpath8(requestedWorkspace);
38334
+ const metadata = await stat7(defaultWorkspace);
38056
38335
  if (!metadata.isDirectory()) {
38057
38336
  throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
38058
38337
  }
@@ -38276,8 +38555,8 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
38276
38555
  }
38277
38556
 
38278
38557
  // src/run-daemon.ts
38279
- import { createHash as createHash7, randomUUID as randomUUID7 } from "node:crypto";
38280
- import { join as join18 } from "node:path";
38558
+ import { createHash as createHash8, randomUUID as randomUUID8 } from "node:crypto";
38559
+ import { join as join19 } from "node:path";
38281
38560
  import { styleText } from "node:util";
38282
38561
 
38283
38562
  // src/agent-catalog/publish-agent-catalog.ts
@@ -38853,9 +39132,9 @@ var FixedInstallationExecutor = class {
38853
39132
  };
38854
39133
 
38855
39134
  // src/authorization/workspace-directory.ts
38856
- import { readdir as readdir3, realpath as realpath8, stat as stat7 } from "node:fs/promises";
39135
+ import { readdir as readdir3, realpath as realpath9, stat as stat8 } from "node:fs/promises";
38857
39136
  import { homedir as homedir2 } from "node:os";
38858
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute9, join as join16, normalize as normalize3, relative as relative4 } from "node:path";
39137
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute9, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38859
39138
  var WorkspaceDirectoryListing = class {
38860
39139
  directoryId;
38861
39140
  directoryLabel;
@@ -38923,9 +39202,9 @@ var WorkspaceDirectoryService = class {
38923
39202
  throw new LocalAuthorizationError("The local directory path is invalid");
38924
39203
  }
38925
39204
  try {
38926
- const target = await realpath8(requested);
39205
+ const target = await realpath9(requested);
38927
39206
  signal.throwIfAborted();
38928
- const metadata = await stat7(target);
39207
+ const metadata = await stat8(target);
38929
39208
  signal.throwIfAborted();
38930
39209
  if (!isAbsolute9(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38931
39210
  throw new LocalAuthorizationError("The selected location is not a directory");
@@ -38973,7 +39252,7 @@ var WorkspaceDirectoryService = class {
38973
39252
  continue;
38974
39253
  }
38975
39254
  try {
38976
- const path2 = await this.resolvePath(join16(target, child2.name), signal);
39255
+ const path2 = await this.resolvePath(join17(target, child2.name), signal);
38977
39256
  entries.push({ directoryId: encodePath(path2), name: child2.name });
38978
39257
  } catch (cause) {
38979
39258
  signal.throwIfAborted();
@@ -38983,7 +39262,7 @@ var WorkspaceDirectoryService = class {
38983
39262
  }
38984
39263
  }
38985
39264
  entries.sort((a, b) => a.name.localeCompare(b.name));
38986
- const parent = dirname5(target);
39265
+ const parent = dirname6(target);
38987
39266
  return new WorkspaceDirectoryListing(
38988
39267
  id,
38989
39268
  this.label(target),
@@ -39009,15 +39288,15 @@ var WorkspaceDirectoryService = class {
39009
39288
 
39010
39289
  // src/daemon-diagnostic-log.ts
39011
39290
  import { appendFileSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
39012
- import { join as join17 } from "node:path";
39291
+ import { join as join18 } from "node:path";
39013
39292
  var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
39014
39293
  var DaemonDiagnosticLog = class {
39015
39294
  #directory;
39016
39295
  #path;
39017
39296
  #maximumBytes;
39018
39297
  constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
39019
- this.#directory = join17(stateDirectory, "logs");
39020
- this.#path = join17(this.#directory, "daemon.log");
39298
+ this.#directory = join18(stateDirectory, "logs");
39299
+ this.#path = join18(this.#directory, "daemon.log");
39021
39300
  this.#maximumBytes = maximumBytes;
39022
39301
  }
39023
39302
  record = (diagnostic) => {
@@ -39062,7 +39341,7 @@ import { WebSocket as WebSocket2 } from "undici";
39062
39341
  import { WebSocket } from "undici";
39063
39342
 
39064
39343
  // src/prompt-artifact-resolver.ts
39065
- import { createHash as createHash3 } from "node:crypto";
39344
+ import { createHash as createHash4 } from "node:crypto";
39066
39345
  import { fetch as fetch4 } from "undici";
39067
39346
  var ARTIFACT_SCHEME = "mobius-artifact:";
39068
39347
  var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
@@ -39200,7 +39479,7 @@ async function download(config2, command, reference, signal) {
39200
39479
  );
39201
39480
  }
39202
39481
  const bytes = await responseBytes(response, reference.byteLength, requestSignal);
39203
- if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
39482
+ if (createHash4("sha256").update(bytes).digest("hex") !== reference.sha256) {
39204
39483
  throw new PromptArtifactError(
39205
39484
  "artifact_integrity_failed",
39206
39485
  "The prompt artifact failed integrity validation"
@@ -39505,7 +39784,7 @@ var DaemonInstallationObserver = class {
39505
39784
  };
39506
39785
 
39507
39786
  // src/daemon-active-turn.ts
39508
- import { randomUUID as randomUUID2 } from "node:crypto";
39787
+ import { randomUUID as randomUUID3 } from "node:crypto";
39509
39788
  function activeMessageCharacters(message) {
39510
39789
  return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
39511
39790
  }
@@ -39539,7 +39818,7 @@ var ActiveDaemonTurn = class {
39539
39818
  #timeline;
39540
39819
  #sequence = 0;
39541
39820
  #interaction = null;
39542
- #epoch = decodeIdentifier(randomUUID2());
39821
+ #epoch = decodeIdentifier(randomUUID3());
39543
39822
  constructor(command, attemptId) {
39544
39823
  this.attemptId = attemptId;
39545
39824
  this.command = command;
@@ -39601,7 +39880,7 @@ var ActiveDaemonTurn = class {
39601
39880
  if (!this.#activities.has(event.activityId)) {
39602
39881
  this.#timeline = [
39603
39882
  ...this.#timeline,
39604
- { activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
39883
+ { activityId: event.activityId, id: decodeIdentifier(randomUUID3()), kind: "activity" }
39605
39884
  ];
39606
39885
  }
39607
39886
  this.#activities.set(event.activityId, {
@@ -39622,7 +39901,7 @@ var ActiveDaemonTurn = class {
39622
39901
  if (previous === void 0) {
39623
39902
  this.#timeline = [
39624
39903
  ...this.#timeline,
39625
- { activityId: event.activityId, id: decodeIdentifier(randomUUID2()), kind: "activity" }
39904
+ { activityId: event.activityId, id: decodeIdentifier(randomUUID3()), kind: "activity" }
39626
39905
  ];
39627
39906
  }
39628
39907
  this.#activities.set(event.activityId, {
@@ -39647,7 +39926,7 @@ var ActiveDaemonTurn = class {
39647
39926
  ...this.#timeline,
39648
39927
  {
39649
39928
  content: /* @__PURE__ */ new Map([[event.contentId, event.content]]),
39650
- id: decodeIdentifier(randomUUID2()),
39929
+ id: decodeIdentifier(randomUUID3()),
39651
39930
  kind: "message",
39652
39931
  sourceMessageId: event.messageId,
39653
39932
  text: ""
@@ -39687,7 +39966,7 @@ var ActiveDaemonTurn = class {
39687
39966
  ...this.#timeline,
39688
39967
  {
39689
39968
  content: /* @__PURE__ */ new Map(),
39690
- id: decodeIdentifier(randomUUID2()),
39969
+ id: decodeIdentifier(randomUUID3()),
39691
39970
  kind: "message",
39692
39971
  sourceMessageId: messageId,
39693
39972
  text: remaining.slice(0, ACTIVE_TURN_TEXT_CHUNK_LIMIT)
@@ -40663,7 +40942,7 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
40663
40942
  });
40664
40943
 
40665
40944
  // src/native-sessions/service.ts
40666
- import { randomUUID as randomUUID3 } from "node:crypto";
40945
+ import { randomUUID as randomUUID4 } from "node:crypto";
40667
40946
  import { basename as basename5 } from "node:path";
40668
40947
 
40669
40948
  // src/native-sessions/acp-history.ts
@@ -40878,7 +41157,7 @@ var NativeSessionService = class {
40878
41157
  if (authorized === null) {
40879
41158
  return null;
40880
41159
  }
40881
- const entryId = decodeIdentifier(randomUUID3());
41160
+ const entryId = decodeIdentifier(randomUUID4());
40882
41161
  if (this.#entries.size >= 5e3) {
40883
41162
  this.#entries.clear();
40884
41163
  }
@@ -40934,7 +41213,7 @@ var NativeSessionService = class {
40934
41213
  "invalid_native_session_response"
40935
41214
  );
40936
41215
  }
40937
- nextCursor = decodeIdentifier(randomUUID3());
41216
+ nextCursor = decodeIdentifier(randomUUID4());
40938
41217
  if (this.#cursors.size >= 500) {
40939
41218
  this.#cursors.clear();
40940
41219
  }
@@ -41216,7 +41495,7 @@ var NativeSessionService = class {
41216
41495
  };
41217
41496
 
41218
41497
  // src/relay-connection/daemon-operation-state.ts
41219
- import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
41498
+ import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
41220
41499
  var MAX_TERMINAL_RECEIPTS = 1024;
41221
41500
  function isTerminal(state) {
41222
41501
  return state === "succeeded" || state === "failed" || state === "cancelled";
@@ -41225,7 +41504,7 @@ var DaemonOperationState = class {
41225
41504
  #executions = /* @__PURE__ */ new Map();
41226
41505
  #terminalCount = 0;
41227
41506
  claimExecution = (commandId, sessionId, commandJson) => {
41228
- const commandHash = createHash4("sha256").update(commandJson).digest("hex");
41507
+ const commandHash = createHash5("sha256").update(commandJson).digest("hex");
41229
41508
  const existing = this.#executions.get(commandId);
41230
41509
  if (existing !== void 0) {
41231
41510
  if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
@@ -41233,7 +41512,7 @@ var DaemonOperationState = class {
41233
41512
  }
41234
41513
  return { attemptId: existing.attemptId, commandId, kind: "duplicate", state: existing.state };
41235
41514
  }
41236
- const attemptId = randomUUID4();
41515
+ const attemptId = randomUUID5();
41237
41516
  this.#executions.set(commandId, { attemptId, commandHash, sessionId, state: "dispatching" });
41238
41517
  return { attemptId, commandId, kind: "accepted", state: "dispatching" };
41239
41518
  };
@@ -41569,7 +41848,7 @@ function createAgentCatalogRefreshHandler(dependencies) {
41569
41848
  import { WebSocket as WebSocket4 } from "undici";
41570
41849
 
41571
41850
  // src/agent-catalog/discover-agent-settings.ts
41572
- import { createHash as createHash5 } from "node:crypto";
41851
+ import { createHash as createHash6 } from "node:crypto";
41573
41852
 
41574
41853
  // src/agent-catalog/agent-settings-base.ts
41575
41854
  var AgentSettingsConfigurationError = class extends Error {
@@ -42033,7 +42312,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
42033
42312
  unsupportedModelIds: modelEffort.unsupportedModelIds,
42034
42313
  valuesByModel: {}
42035
42314
  };
42036
- return createHash5("sha256").update(
42315
+ return createHash6("sha256").update(
42037
42316
  JSON.stringify({
42038
42317
  adapterVersion: agent.kind === "acp-adapter-process" ? agent.adapterVersion : agent.agentVersion,
42039
42318
  agentId: agent.id,
@@ -42184,7 +42463,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
42184
42463
 
42185
42464
  // src/artifacts/local-file-streamer.ts
42186
42465
  import { createReadStream as createReadStream2 } from "node:fs";
42187
- import { realpath as realpath9, stat as stat8 } from "node:fs/promises";
42466
+ import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
42188
42467
  import { basename as basename6, isAbsolute as isAbsolute10, normalize as normalize4, resolve as resolve7 } from "node:path";
42189
42468
  import { fileURLToPath as fileURLToPath2 } from "node:url";
42190
42469
  var CHUNK_BYTES = 192 * 1024;
@@ -42212,7 +42491,7 @@ async function resolveFile(value, workingDirectory, signal) {
42212
42491
  return null;
42213
42492
  }
42214
42493
  try {
42215
- const target = await realpath9(requested);
42494
+ const target = await realpath10(requested);
42216
42495
  signal.throwIfAborted();
42217
42496
  return isAbsolute10(target) && normalize4(target) === target ? target : null;
42218
42497
  } catch {
@@ -42220,23 +42499,24 @@ async function resolveFile(value, workingDirectory, signal) {
42220
42499
  return null;
42221
42500
  }
42222
42501
  }
42223
- async function streamLocalFile(command, send2, signal, workingDirectory) {
42224
- const target = await resolveFile(command.path, workingDirectory, signal);
42502
+ async function streamLocalFile(command, send2, signal, workingDirectory, externalContent) {
42503
+ const external = await externalContent.resolve(command.sessionId, command.path, signal);
42504
+ const target = external?.path ?? await resolveFile(command.path, workingDirectory, signal);
42225
42505
  if (target === null) {
42226
42506
  throw new Error("The local file is unavailable");
42227
42507
  }
42228
- const before = await stat8(target);
42508
+ const before = await stat9(target);
42229
42509
  signal.throwIfAborted();
42230
42510
  if (!before.isFile() || before.size < 1 || before.size > command.maxBytes) {
42231
42511
  throw new Error("The local file is too large to read");
42232
42512
  }
42233
- const raster = await readLocalRaster(target, signal);
42513
+ const raster = external === null ? await readLocalRaster(target, signal) : null;
42234
42514
  send2({
42235
42515
  byteLength: before.size,
42236
42516
  kind: FILE_BEGIN_KIND,
42237
- mediaType: raster?.mimeType ?? "application/octet-stream",
42517
+ mediaType: external?.mediaType ?? raster?.mimeType ?? "application/octet-stream",
42238
42518
  modifiedAt: before.mtime.toISOString(),
42239
- name: basename6(target) || "file",
42519
+ name: external?.name ?? (basename6(target) || "file"),
42240
42520
  requestId: command.requestId,
42241
42521
  sessionId: command.sessionId
42242
42522
  });
@@ -42253,7 +42533,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory) {
42253
42533
  });
42254
42534
  sequence += 1;
42255
42535
  }
42256
- const after = await stat8(target);
42536
+ const after = await stat9(target);
42257
42537
  signal.throwIfAborted();
42258
42538
  if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
42259
42539
  throw new Error("The local file changed during transfer");
@@ -42266,7 +42546,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory) {
42266
42546
  }
42267
42547
 
42268
42548
  // src/daemon-history-commands.ts
42269
- import { createHash as createHash6 } from "node:crypto";
42549
+ import { createHash as createHash7 } from "node:crypto";
42270
42550
 
42271
42551
  // src/authorization/resolve-session-directories.ts
42272
42552
  import { basename as basename7 } from "node:path";
@@ -42660,7 +42940,7 @@ async function executeSessionLiveHistoryPageLoad(socket, command, config2, direc
42660
42940
  }
42661
42941
  function replayEvent(sessionId, position, update) {
42662
42942
  const encoded = JSON.stringify(update);
42663
- const eventId = `native-${createHash6("sha256").update(sessionId).update(":").update(position.toString()).update(":").update(encoded).digest("hex")}`;
42943
+ const eventId = `native-${createHash7("sha256").update(sessionId).update(":").update(position.toString()).update(":").update(encoded).digest("hex")}`;
42664
42944
  return {
42665
42945
  eventId,
42666
42946
  payload: update,
@@ -42743,7 +43023,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
42743
43023
  }
42744
43024
 
42745
43025
  // src/acp/session-config/apply-session-configuration.ts
42746
- import { randomUUID as randomUUID5 } from "node:crypto";
43026
+ import { randomUUID as randomUUID6 } from "node:crypto";
42747
43027
  function invalidSessionConfiguration(message) {
42748
43028
  return new AcpExecutionError(message, {}, "invalid_session_configuration");
42749
43029
  }
@@ -42884,7 +43164,7 @@ async function applySessionConfigurationSelection(sessions, audit, options, sele
42884
43164
  booleanValue: selection.booleanValue,
42885
43165
  configId: selection.configId,
42886
43166
  cwd,
42887
- requestId: `cfg_${randomUUID5()}`,
43167
+ requestId: `cfg_${randomUUID6()}`,
42888
43168
  sessionId,
42889
43169
  signal,
42890
43170
  value: selection.value,
@@ -43558,6 +43838,7 @@ function createDaemonCommandHandler({
43558
43838
  operations,
43559
43839
  publisher,
43560
43840
  eventLogV2,
43841
+ externalContent,
43561
43842
  activeTurns,
43562
43843
  diagnostics,
43563
43844
  socket,
@@ -43666,7 +43947,8 @@ function createDaemonCommandHandler({
43666
43947
  command2,
43667
43948
  (message2) => send(socket, message2),
43668
43949
  signal,
43669
- sessions.findSessions([command2.sessionId])[0]?.cwd ?? null
43950
+ sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
43951
+ externalContent
43670
43952
  ).catch((error62) => {
43671
43953
  if (socket.readyState !== WebSocket6.OPEN || signal.aborted) {
43672
43954
  return;
@@ -43985,7 +44267,7 @@ function connectRelay(url2, signal) {
43985
44267
  }
43986
44268
 
43987
44269
  // src/relay-connection/liveness.ts
43988
- import { randomUUID as randomUUID6 } from "node:crypto";
44270
+ import { randomUUID as randomUUID7 } from "node:crypto";
43989
44271
  var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
43990
44272
  var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
43991
44273
  var RelayLivenessState = class {
@@ -44074,7 +44356,7 @@ var RelayConnectionLiveness = class {
44074
44356
  }
44075
44357
  throw new Error("Heartbeat was scheduled in an invalid state");
44076
44358
  }
44077
- const heartbeatId = randomUUID6();
44359
+ const heartbeatId = randomUUID7();
44078
44360
  this.#state = new AwaitingHeartbeatAckState(
44079
44361
  heartbeatId,
44080
44362
  this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
@@ -44114,6 +44396,7 @@ async function runRelayConnection({
44114
44396
  operations,
44115
44397
  publisher,
44116
44398
  eventLogV2,
44399
+ externalContent,
44117
44400
  activeTurns,
44118
44401
  connectionEpoch,
44119
44402
  diagnostics,
@@ -44137,6 +44420,7 @@ async function runRelayConnection({
44137
44420
  operations,
44138
44421
  publisher,
44139
44422
  eventLogV2,
44423
+ externalContent,
44140
44424
  activeTurns,
44141
44425
  diagnostics,
44142
44426
  socket,
@@ -44615,7 +44899,7 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
44615
44899
  {
44616
44900
  agentId: agent.id,
44617
44901
  kind: AGENT_INSTALL_REQUEST_KIND,
44618
- requestId: `automatic-integration-${randomUUID7()}`
44902
+ requestId: `automatic-integration-${randomUUID8()}`
44619
44903
  },
44620
44904
  signal
44621
44905
  );
@@ -44634,8 +44918,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44634
44918
  stateDirectory
44635
44919
  });
44636
44920
  const sessionStore = new SqliteAcpSessionStore(
44637
- join18(stateDirectory, "sessions", `${createHash7("sha256").update(config2.channelId).digest("hex")}.sqlite`)
44921
+ join19(stateDirectory, "sessions", `${createHash8("sha256").update(config2.channelId).digest("hex")}.sqlite`)
44638
44922
  );
44923
+ const externalContent = new LocalExternalContentStore(stateDirectory);
44639
44924
  const operations = new DaemonOperationState();
44640
44925
  const publisher = new DaemonSessionEventPublisher(sessionStore);
44641
44926
  const eventLogV2 = new DaemonSessionEventLogV2(publisher, sessionStore);
@@ -44656,7 +44941,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44656
44941
  )).history : null
44657
44942
  },
44658
44943
  "native",
44659
- publisher.publishStatus
44944
+ publisher.publishStatus,
44945
+ new AcpContentExternalizer(externalContent)
44660
44946
  );
44661
44947
  const directories = new WorkspaceDirectoryService(config2.bindingId, config2.defaultWorkspace);
44662
44948
  const installationObserver = new DaemonInstallationObserver();
@@ -44770,6 +45056,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44770
45056
  operations,
44771
45057
  publisher,
44772
45058
  eventLogV2,
45059
+ externalContent,
44773
45060
  activeTurns,
44774
45061
  connectionEpoch,
44775
45062
  diagnostics,
@@ -44826,7 +45113,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44826
45113
  }
44827
45114
 
44828
45115
  // src/runtime.ts
44829
- import { mkdir as mkdir6, realpath as realpath10, stat as stat9 } from "node:fs/promises";
45116
+ import { mkdir as mkdir7, realpath as realpath11, stat as stat10 } from "node:fs/promises";
44830
45117
  import { resolve as resolve8 } from "node:path";
44831
45118
  var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
44832
45119
  var MobiusRuntimeConfigurationError = class extends Error {
@@ -44892,9 +45179,9 @@ function loadMobiusRuntimeConnection(environment = process.env) {
44892
45179
  async function resolveWorkspace(path2) {
44893
45180
  const requested = resolve8(path2);
44894
45181
  try {
44895
- await mkdir6(requested, { recursive: true, mode: 448 });
44896
- const resolved = await realpath10(requested);
44897
- const metadata = await stat9(resolved);
45182
+ await mkdir7(requested, { recursive: true, mode: 448 });
45183
+ const resolved = await realpath11(requested);
45184
+ const metadata = await stat10(resolved);
44898
45185
  if (!metadata.isDirectory()) {
44899
45186
  throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
44900
45187
  }