@moxt-ai/mobius 0.0.340 → 0.0.342

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 (59) hide show
  1. package/dist/acp/adapter/claude/agent-connection.js +1 -1
  2. package/dist/acp/adapter/claude/agent-connection.js.map +1 -1
  3. package/dist/acp/adapter/codex/agent-connection.js +1 -1
  4. package/dist/acp/adapter/codex/agent-connection.js.map +1 -1
  5. package/dist/acp/adapter/codex/tool-event.js +2 -2
  6. package/dist/acp/adapter/codex/tool-event.js.map +1 -1
  7. package/dist/acp/adapter/pi/agent-connection.js +1 -1
  8. package/dist/acp/adapter/pi/agent-connection.js.map +1 -1
  9. package/dist/acp/adapter/session-events.d.ts +2 -1
  10. package/dist/acp/adapter/session-events.d.ts.map +1 -1
  11. package/dist/acp/adapter/session-events.js +66 -89
  12. package/dist/acp/adapter/session-events.js.map +1 -1
  13. package/dist/acp/agent/in-process-endpoint.d.ts +3 -1
  14. package/dist/acp/agent/in-process-endpoint.d.ts.map +1 -1
  15. package/dist/acp/connection/agent-connection.d.ts +2 -2
  16. package/dist/acp/connection/agent-connection.d.ts.map +1 -1
  17. package/dist/acp/content/content-externalizer.d.ts.map +1 -1
  18. package/dist/acp/content/content-externalizer.js +26 -0
  19. package/dist/acp/content/content-externalizer.js.map +1 -1
  20. package/dist/acp/harness/claude/endpoint.js +1 -1
  21. package/dist/acp/harness/claude/endpoint.js.map +1 -1
  22. package/dist/acp/harness/codex/agent.js +3 -3
  23. package/dist/acp/harness/codex/agent.js.map +1 -1
  24. package/dist/acp/harness/codex/owned-agent.d.ts +2 -2
  25. package/dist/acp/harness/codex/owned-agent.d.ts.map +1 -1
  26. package/dist/acp/harness/codex/owned-agent.js +3 -3
  27. package/dist/acp/harness/codex/owned-agent.js.map +1 -1
  28. package/dist/acp/native-history/preview-contract.d.ts +3 -4
  29. package/dist/acp/native-history/preview-contract.d.ts.map +1 -1
  30. package/dist/cli.js +277 -637
  31. package/dist/cli.js.map +4 -4
  32. package/dist/daemon/upgrades/data.js +5 -5
  33. package/dist/daemon/upgrades/data.js.map +1 -1
  34. package/dist/daemon/upgrades/package.js +5 -5
  35. package/dist/daemon/upgrades/package.js.map +1 -1
  36. package/dist/daemon/upgrades/upgrade.js +4 -7
  37. package/dist/daemon/upgrades/upgrade.js.map +1 -1
  38. package/dist/runtime.js +245 -142
  39. package/dist/runtime.js.map +4 -4
  40. package/dist/session/api/session-api.d.ts +3 -2
  41. package/dist/session/api/session-api.d.ts.map +1 -1
  42. package/dist/session/api/session-api.js +1 -1
  43. package/dist/session/api/session-api.js.map +1 -1
  44. package/dist/session/api/session-layer.d.ts +3 -2
  45. package/dist/session/api/session-layer.d.ts.map +1 -1
  46. package/dist/session/api/session-layer.js +4 -4
  47. package/dist/session/api/session-layer.js.map +1 -1
  48. package/dist/session/history/session-event-history-projection.d.ts.map +1 -1
  49. package/dist/session/history/session-event-history-projection.js +7 -0
  50. package/dist/session/history/session-event-history-projection.js.map +1 -1
  51. package/dist/session/live/agent-session.js +1 -1
  52. package/dist/session/live/agent-session.js.map +1 -1
  53. package/dist/session/turn/runtime-turn-activity.d.ts +5 -2
  54. package/dist/session/turn/runtime-turn-activity.d.ts.map +1 -1
  55. package/dist/session/turn/runtime-turn-activity.js +15 -10
  56. package/dist/session/turn/runtime-turn-activity.js.map +1 -1
  57. package/dist/storage/daemon/version-data.js +2 -2
  58. package/dist/storage/daemon/version-data.js.map +1 -1
  59. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2086,7 +2086,7 @@ var init_package = __esm({
2086
2086
  "package.json"() {
2087
2087
  package_default = {
2088
2088
  name: "@moxt-ai/mobius",
2089
- version: "0.0.340",
2089
+ version: "0.0.342",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -62509,6 +62509,114 @@ var init_background_task_notifications = __esm({
62509
62509
  }
62510
62510
  });
62511
62511
 
62512
+ // src/acp/harness/claude/upstream/dist/context-resources.js
62513
+ import { extname } from "node:path";
62514
+ function formatUriAsLink(uri) {
62515
+ if (uri.startsWith("file://")) {
62516
+ const path8 = uri.slice(7);
62517
+ return `[@${path8.split("/").pop() || path8}](${uri})`;
62518
+ }
62519
+ if (uri.startsWith("zed://")) {
62520
+ return `[@${uri.split("/").pop() || uri}](${uri})`;
62521
+ }
62522
+ return uri;
62523
+ }
62524
+ function parseContextBlock(block) {
62525
+ if (block.type !== "text" || typeof block.text !== "string") {
62526
+ return null;
62527
+ }
62528
+ const match = /^\n<context ref="([^"\r\n]+)">\n([\s\S]*)\n<\/context>$/u.exec(block.text);
62529
+ const uri = match?.[1];
62530
+ const text2 = match?.[2];
62531
+ if (uri === void 0 || text2 === void 0 || formatContextBlock(uri, text2) !== block.text) {
62532
+ return null;
62533
+ }
62534
+ return { uri, text: text2 };
62535
+ }
62536
+ function contextMimeType(uri) {
62537
+ let pathname = uri;
62538
+ try {
62539
+ pathname = new URL(uri).pathname;
62540
+ } catch {
62541
+ }
62542
+ switch (extname(pathname).toLowerCase()) {
62543
+ case ".html":
62544
+ case ".htm":
62545
+ return "text/html";
62546
+ case ".js":
62547
+ case ".mjs":
62548
+ case ".cjs":
62549
+ return "text/javascript";
62550
+ case ".css":
62551
+ return "text/css";
62552
+ case ".json":
62553
+ return "application/json";
62554
+ case ".md":
62555
+ case ".markdown":
62556
+ return "text/markdown";
62557
+ case ".xml":
62558
+ return "application/xml";
62559
+ case ".svg":
62560
+ return "image/svg+xml";
62561
+ case ".csv":
62562
+ return "text/csv";
62563
+ default:
62564
+ return "text/plain";
62565
+ }
62566
+ }
62567
+ function replayContextResources(content) {
62568
+ const contexts = [];
62569
+ let contextStart = content.length;
62570
+ for (let index2 = content.length - 1; index2 >= 0; index2 -= 1) {
62571
+ const block = content[index2];
62572
+ const parsed = block === void 0 ? null : parseContextBlock(block);
62573
+ if (parsed === null) {
62574
+ break;
62575
+ }
62576
+ contexts.push(parsed);
62577
+ contextStart = index2;
62578
+ }
62579
+ if (contexts.length === 0) {
62580
+ return null;
62581
+ }
62582
+ contexts.reverse();
62583
+ const links = new Set(contexts.map(({ uri }) => formatUriAsLink(uri)));
62584
+ const resources = /* @__PURE__ */ new Map();
62585
+ let nextContext = 0;
62586
+ for (let index2 = 0; index2 < contextStart; index2 += 1) {
62587
+ const block = content[index2];
62588
+ if (block?.type !== "text" || typeof block.text !== "string") {
62589
+ continue;
62590
+ }
62591
+ if (block.text.startsWith('\n<context ref="')) {
62592
+ return null;
62593
+ }
62594
+ if (!links.has(block.text)) {
62595
+ continue;
62596
+ }
62597
+ const context = contexts[nextContext];
62598
+ if (context === void 0 || block.text !== formatUriAsLink(context.uri)) {
62599
+ return null;
62600
+ }
62601
+ resources.set(index2, {
62602
+ type: "resource",
62603
+ resource: { ...context, mimeType: contextMimeType(context.uri) }
62604
+ });
62605
+ nextContext += 1;
62606
+ }
62607
+ return nextContext === contexts.length ? { contextStart, resources } : null;
62608
+ }
62609
+ var formatContextBlock;
62610
+ var init_context_resources = __esm({
62611
+ "src/acp/harness/claude/upstream/dist/context-resources.js"() {
62612
+ "use strict";
62613
+ formatContextBlock = (uri, text2) => `
62614
+ <context ref="${uri}">
62615
+ ${text2}
62616
+ </context>`;
62617
+ }
62618
+ });
62619
+
62512
62620
  // src/acp/harness/claude/upstream/dist/elicitation.js
62513
62621
  import { randomUUID as randomUUID3 } from "node:crypto";
62514
62622
  import { CreateElicitationResponse } from "@agentclientprotocol/sdk";
@@ -66515,22 +66623,6 @@ function getAvailableSlashCommands(commands, terminalCommands) {
66515
66623
  };
66516
66624
  }).filter((command) => !UNSUPPORTED_COMMANDS.includes(command.name));
66517
66625
  }
66518
- function formatUriAsLink(uri) {
66519
- try {
66520
- if (uri.startsWith("file://")) {
66521
- const path8 = uri.slice(7);
66522
- const name2 = path8.split("/").pop() || path8;
66523
- return `[@${name2}](${uri})`;
66524
- } else if (uri.startsWith("zed://")) {
66525
- const parts = uri.split("/");
66526
- const name2 = parts[parts.length - 1] || uri;
66527
- return `[@${name2}](${uri})`;
66528
- }
66529
- return uri;
66530
- } catch {
66531
- return uri;
66532
- }
66533
- }
66534
66626
  function promptToClaude(prompt) {
66535
66627
  const content = [];
66536
66628
  const context = [];
@@ -66563,10 +66655,7 @@ function promptToClaude(prompt) {
66563
66655
  });
66564
66656
  context.push({
66565
66657
  type: "text",
66566
- text: `
66567
- <context ref="${chunk.resource.uri}">
66568
- ${chunk.resource.text}
66569
- </context>`
66658
+ text: formatContextBlock(chunk.resource.uri, chunk.resource.text)
66570
66659
  });
66571
66660
  }
66572
66661
  break;
@@ -66735,8 +66824,13 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
66735
66824
  const toolUseResult = options?.toolUseResult !== void 0 && content.filter((c) => typeof c === "object" && c !== null && c.type === "tool_result").length === 1 ? options.toolUseResult : void 0;
66736
66825
  const toolResultMeta = parseToolResultMeta(options?.toolResultMeta);
66737
66826
  const output2 = [];
66738
- for (const chunk of content) {
66827
+ const replayedResources = role === "user" && options.historical === true ? replayContextResources(content) : null;
66828
+ for (const [index2, chunk] of content.entries()) {
66829
+ if (replayedResources !== null && index2 >= replayedResources.contextStart) {
66830
+ break;
66831
+ }
66739
66832
  let update = null;
66833
+ const resource = replayedResources?.resources.get(index2);
66740
66834
  switch (chunk.type) {
66741
66835
  case "text":
66742
66836
  case "text_delta": {
@@ -66745,7 +66839,7 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
66745
66839
  update = {
66746
66840
  sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
66747
66841
  messageId,
66748
- content: {
66842
+ content: resource ?? {
66749
66843
  type: "text",
66750
66844
  text: chunk.text
66751
66845
  }
@@ -67216,6 +67310,7 @@ var init_acp_agent = __esm({
67216
67310
  "use strict";
67217
67311
  init_sdk();
67218
67312
  init_background_task_notifications();
67313
+ init_context_resources();
67219
67314
  init_elicitation();
67220
67315
  init_environment_session_fork();
67221
67316
  init_environment_session_list();
@@ -67327,14 +67422,15 @@ var init_acp_agent = __esm({
67327
67422
  providerUpdate = null;
67328
67423
  exitPlan;
67329
67424
  environment;
67330
- backgroundSessions = /* @__PURE__ */ new Set();
67331
- reportBackgroundActivity(session, active) {
67332
- if (active) {
67333
- this.backgroundSessions.add(session);
67334
- } else {
67425
+ backgroundSessions = /* @__PURE__ */ new Map();
67426
+ reportBackgroundActivity(session, activity) {
67427
+ if (activity === "none") {
67335
67428
  this.backgroundSessions.delete(session);
67429
+ } else {
67430
+ this.backgroundSessions.set(session, activity);
67336
67431
  }
67337
- this.onBackgroundActivity?.(this.backgroundSessions.size > 0);
67432
+ const activities = new Set(this.backgroundSessions.values());
67433
+ this.onBackgroundActivity?.(activities.has("running") ? "running" : activities.has("awaiting-results") ? "awaiting-results" : "none");
67338
67434
  }
67339
67435
  /** Grace period before a `session/cancel` forces a wedged prompt loop to
67340
67436
  * return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
@@ -67959,7 +68055,7 @@ var init_acp_agent = __esm({
67959
68055
  const awaitingBackgroundResults = /* @__PURE__ */ new Set();
67960
68056
  let processingBackgroundResults = /* @__PURE__ */ new Set();
67961
68057
  let hasBackgroundLevel = false;
67962
- const reportBackgroundActivity = () => this.reportBackgroundActivity(session, backgroundTasks.size > 0 || awaitingBackgroundResults.size > 0);
68058
+ const reportBackgroundActivity = () => this.reportBackgroundActivity(session, backgroundTasks.size > 0 ? "running" : awaitingBackgroundResults.size > 0 ? "awaiting-results" : "none");
67963
68059
  let lastAssistantTotalUsage = null;
67964
68060
  let lastAssistantUsage = null;
67965
68061
  let lastAssistantModel = null;
@@ -69296,7 +69392,7 @@ ${message.api_refusal_explanation}` : "";
69296
69392
  session.settingsManager.dispose();
69297
69393
  session.input.end();
69298
69394
  session.query.close();
69299
- this.reportBackgroundActivity(session, false);
69395
+ this.reportBackgroundActivity(session, "none");
69300
69396
  }
69301
69397
  /** Cleanly tear down a session: cancel in-flight work, release stream
69302
69398
  * resources, and remove it from the session map. */
@@ -70375,7 +70471,7 @@ var init_endpoint = __esm({
70375
70471
  CLAUDE_CODE_EXECUTABLE: options.command
70376
70472
  }),
70377
70473
  onSessionUpdate: options.onSessionUpdate,
70378
- onBackgroundActivity: (active) => options.onBackgroundActivity?.(active),
70474
+ onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity),
70379
70475
  onConnect: (connection) => {
70380
70476
  this.#connection = connection;
70381
70477
  }
@@ -70420,7 +70516,7 @@ var init_agent_connection = __esm({
70420
70516
  onSessionUpdate: async (notification) => {
70421
70517
  await options.client.onUpdate(notification);
70422
70518
  },
70423
- onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
70519
+ onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
70424
70520
  });
70425
70521
  super(endpoint, options.client);
70426
70522
  }
@@ -70959,7 +71055,7 @@ var init_process_error = __esm({
70959
71055
  // src/util/process/platform/windows.ts
70960
71056
  import { execFile as execFile4 } from "node:child_process";
70961
71057
  import { readFile as readFile5, realpath as realpath5 } from "node:fs/promises";
70962
- import { dirname as dirname7, extname, join as join16, resolve as resolve8 } from "node:path";
71058
+ import { dirname as dirname7, extname as extname2, join as join16, resolve as resolve8 } from "node:path";
70963
71059
  function environmentValue2(environment, name2) {
70964
71060
  return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
70965
71061
  }
@@ -70974,14 +71070,14 @@ function executableExtensions(executableName, environment) {
70974
71070
  async function resolveExecutableTarget(path8) {
70975
71071
  let resolvedPath;
70976
71072
  try {
70977
- resolvedPath = await realpath5(extname(path8) === "" ? `${path8}.cmd` : path8);
71073
+ resolvedPath = await realpath5(extname2(path8) === "" ? `${path8}.cmd` : path8);
70978
71074
  } catch (cause) {
70979
- if (extname(path8) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
71075
+ if (extname2(path8) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
70980
71076
  throw cause;
70981
71077
  }
70982
71078
  resolvedPath = await realpath5(path8);
70983
71079
  }
70984
- if (extname(resolvedPath).toLowerCase() === ".cmd") {
71080
+ if (extname2(resolvedPath).toLowerCase() === ".cmd") {
70985
71081
  const shim = await readFile5(resolvedPath, "utf8");
70986
71082
  if (shim.includes('SET "NPM_CLI_JS=%~dp0\\node_modules\\npm\\bin\\npm-cli.js"') && shim.includes('"%NODE_EXE%" "%NPM_CLI_JS%" %*')) {
70987
71083
  return await realpath5(resolve8(dirname7(resolvedPath), "node_modules/npm/bin/npm-cli.js"));
@@ -73432,7 +73528,7 @@ var init_owned_agent = __esm({
73432
73528
  await this.#enqueue(async () => {
73433
73529
  if (item.type === "commandExecution" && method === "item/started") {
73434
73530
  this.#runningCommands.set(item.id, "foreground");
73435
- this.#context.onBackgroundActivity?.(true);
73531
+ this.#context.onBackgroundActivity?.("running");
73436
73532
  }
73437
73533
  if (method === "item/started") {
73438
73534
  await this.#context.emit({ ...update, sessionUpdate: "tool_call" });
@@ -73453,7 +73549,7 @@ var init_owned_agent = __esm({
73453
73549
  }
73454
73550
  if (item.type === "commandExecution" && method === "item/completed") {
73455
73551
  this.#runningCommands.delete(item.id);
73456
- this.#context.onBackgroundActivity?.(this.#runningCommands.size > 0);
73552
+ this.#context.onBackgroundActivity?.(this.#runningCommands.size > 0 ? "running" : "none");
73457
73553
  }
73458
73554
  });
73459
73555
  }
@@ -73874,16 +73970,6 @@ var init_mobius_api = __esm({
73874
73970
  }
73875
73971
  });
73876
73972
 
73877
- // ../mobius-sdk/src/protocol/platform/project-location.ts
73878
- var PROJECT_LOCATION_HINTS, projectLocationHints;
73879
- var init_project_location = __esm({
73880
- "../mobius-sdk/src/protocol/platform/project-location.ts"() {
73881
- "use strict";
73882
- PROJECT_LOCATION_HINTS = ["wnam", "enam", "sam", "weur", "eeur", "apac", "apac-ne", "apac-se", "oc", "afr", "me"];
73883
- projectLocationHints = new Set(PROJECT_LOCATION_HINTS);
73884
- }
73885
- });
73886
-
73887
73973
  // ../mobius-sdk/src/protocol/shared/identifier.ts
73888
73974
  function isIdentifier(value) {
73889
73975
  return identifierSchema.safeParse(value).success;
@@ -74111,13 +74197,14 @@ var init_liveness = __esm({
74111
74197
  });
74112
74198
 
74113
74199
  // ../mobius-sdk/src/protocol/runtime/upgrade.ts
74114
- var runtimeUpgradeVersionSchema, runtimeUpgradeResultSchema, decodeRuntimeUpgradeResult, encodeRuntimeUpgradeResult;
74200
+ var runtimeUpgradeVersionSchema, decodeRuntimeUpgradeVersion, runtimeUpgradeResultSchema, decodeRuntimeUpgradeResult, encodeRuntimeUpgradeResult;
74115
74201
  var init_upgrade = __esm({
74116
74202
  "../mobius-sdk/src/protocol/runtime/upgrade.ts"() {
74117
74203
  "use strict";
74118
74204
  init_zod();
74119
74205
  init_identifier();
74120
74206
  runtimeUpgradeVersionSchema = external_exports.string().max(128).regex(/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/);
74207
+ decodeRuntimeUpgradeVersion = (value) => runtimeUpgradeVersionSchema.parse(value);
74121
74208
  runtimeUpgradeResultSchema = external_exports.strictObject({
74122
74209
  kind: external_exports.literal("runtime.upgrade.result"),
74123
74210
  requestId: external_exports.custom(isIdentifier),
@@ -74147,25 +74234,6 @@ var init_upgrade = __esm({
74147
74234
  }
74148
74235
  });
74149
74236
 
74150
- // ../mobius-sdk/src/protocol/session/access/index.ts
74151
- var MAXIMUM_LIFETIME_MILLISECONDS, claimsSchema;
74152
- var init_access = __esm({
74153
- "../mobius-sdk/src/protocol/session/access/index.ts"() {
74154
- "use strict";
74155
- init_zod();
74156
- init_identifier();
74157
- MAXIMUM_LIFETIME_MILLISECONDS = 15 * 60 * 1e3;
74158
- claimsSchema = external_exports.object({
74159
- expiresAtEpochMilliseconds: external_exports.number().int().nonnegative(),
74160
- issuedAtEpochMilliseconds: external_exports.number().int().nonnegative(),
74161
- projectId: identifierStringSchema,
74162
- purpose: external_exports.literal("session-access"),
74163
- runtimeId: identifierStringSchema,
74164
- sessionId: identifierStringSchema
74165
- }).readonly();
74166
- }
74167
- });
74168
-
74169
74237
  // ../mobius-sdk/src/protocol/session/agent/catalog.ts
74170
74238
  var AGENT_CATALOG_DISCOVER_KIND, AGENT_CATALOG_DISCOVERED_KIND, AGENT_CATALOG_DISCOVERY_FAILED_KIND, catalogedAgentSchema, agentCatalogDiscoverCommandSchema, agentCatalogDiscoveredEventSchema, agentCatalogDiscoveryFailedEventSchema, decodeAgentCatalogDiscoverCommand, encodeAgentCatalogDiscoverCommand, decodeAgentCatalogDiscoveredEvent, encodeAgentCatalogDiscoveredEvent, decodeAgentCatalogDiscoveryFailedEvent, encodeAgentCatalogDiscoveryFailedEvent;
74171
74239
  var init_catalog = __esm({
@@ -74537,7 +74605,7 @@ function boundedJsonIssue(value, depth = 0) {
74537
74605
  }
74538
74606
  return "Value is not bounded JSON";
74539
74607
  }
74540
- var MAX_CONTENT_LENGTH, MAX_COLLECTION_SIZE, MAX_JSON_DEPTH, MAX_JSON_KEYS, boundedString, boundedJsonSchema, toolCallLocationSchema;
74608
+ var MAX_CONTENT_LENGTH, MAX_COLLECTION_SIZE, MAX_JSON_DEPTH, MAX_JSON_KEYS, boundedString, boundedJsonSchema, isBoundedJson, toolCallLocationSchema;
74541
74609
  var init_tool_input = __esm({
74542
74610
  "../mobius-sdk/src/protocol/shared/tool-input.ts"() {
74543
74611
  "use strict";
@@ -74553,6 +74621,7 @@ var init_tool_input = __esm({
74553
74621
  context.addIssue({ code: "custom", message: issue2 });
74554
74622
  }
74555
74623
  });
74624
+ isBoundedJson = (value) => boundedJsonIssue(value) === null;
74556
74625
  toolCallLocationSchema = external_exports.object({
74557
74626
  line: external_exports.number().int().nonnegative().safe().nullable().optional(),
74558
74627
  path: boundedString
@@ -74723,7 +74792,6 @@ var init_events = __esm({
74723
74792
  init_zod();
74724
74793
  init_directory();
74725
74794
  init_tool_input();
74726
- init_tool_input();
74727
74795
  init_identifier();
74728
74796
  init_message_codec();
74729
74797
  init_interactions();
@@ -75283,73 +75351,6 @@ var init_files = __esm({
75283
75351
  }
75284
75352
  });
75285
75353
 
75286
- // ../mobius-sdk/src/protocol/session/interactions/model.ts
75287
- var timestampSchema, permissionRequestSchema, elicitationRequestSchema, interactionRequestSchema, interactionResponseSchema, interactionStateSchema, interactionSchema;
75288
- var init_model = __esm({
75289
- "../mobius-sdk/src/protocol/session/interactions/model.ts"() {
75290
- "use strict";
75291
- init_zod();
75292
- init_identifier();
75293
- init_interactions();
75294
- timestampSchema = external_exports.string().datetime({ offset: true });
75295
- permissionRequestSchema = external_exports.object({
75296
- kind: external_exports.literal("permission"),
75297
- options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
75298
- title: external_exports.string().min(1).max(500),
75299
- toolCallId: external_exports.string().min(1).max(255),
75300
- toolKind: external_exports.string().max(64)
75301
- }).readonly();
75302
- elicitationRequestSchema = external_exports.object({
75303
- elicitationId: external_exports.string().max(255),
75304
- fields: external_exports.array(elicitationFieldSchema).max(100).readonly(),
75305
- kind: external_exports.literal("elicitation"),
75306
- message: external_exports.string().min(1).max(2e3),
75307
- mode: external_exports.enum(["form", "url"]),
75308
- url: external_exports.string().max(4096)
75309
- }).readonly();
75310
- interactionRequestSchema = external_exports.discriminatedUnion("kind", [permissionRequestSchema, elicitationRequestSchema]);
75311
- interactionResponseSchema = external_exports.object({
75312
- content: external_exports.string().max(1e5),
75313
- kind: external_exports.enum(["permission", "elicitation"])
75314
- }).readonly();
75315
- interactionStateSchema = external_exports.discriminatedUnion("kind", [
75316
- external_exports.object({ kind: external_exports.literal("pending") }).readonly(),
75317
- external_exports.object({
75318
- kind: external_exports.literal("responded"),
75319
- respondedAt: timestampSchema,
75320
- responderId: identifierSchema,
75321
- response: interactionResponseSchema
75322
- }).readonly(),
75323
- external_exports.object({
75324
- kind: external_exports.literal("resolved"),
75325
- resolution: external_exports.discriminatedUnion("kind", [
75326
- external_exports.object({ kind: external_exports.literal("without_response") }).readonly(),
75327
- external_exports.object({
75328
- kind: external_exports.literal("response_applied"),
75329
- respondedAt: timestampSchema,
75330
- responderId: identifierSchema,
75331
- response: interactionResponseSchema
75332
- }).readonly()
75333
- ]),
75334
- resolvedAt: timestampSchema
75335
- }).readonly(),
75336
- external_exports.object({ expiredAt: timestampSchema, kind: external_exports.literal("expired") }).readonly(),
75337
- external_exports.object({
75338
- cancelledAt: timestampSchema,
75339
- kind: external_exports.literal("cancelled")
75340
- }).readonly()
75341
- ]);
75342
- interactionSchema = external_exports.object({
75343
- attemptId: identifierSchema,
75344
- interactionId: identifierSchema,
75345
- request: interactionRequestSchema,
75346
- sessionId: identifierSchema,
75347
- state: interactionStateSchema,
75348
- turnId: identifierSchema
75349
- }).readonly();
75350
- }
75351
- });
75352
-
75353
75354
  // ../mobius-sdk/src/protocol/session/lifecycle/index.ts
75354
75355
  var SESSION_PREPARE_KIND, SESSION_READY_KIND, SESSION_LIST_KIND, SESSION_LISTED_KIND, SESSION_QUERY_KIND, SESSION_QUERIED_KIND, SESSION_RESTORE_KIND, SESSION_RESTORED_KIND, SESSION_CLOSE_KIND, SESSION_CLOSED_KIND, SESSION_CLOSE_NOTICE_KIND, SESSION_CLOSED_ERROR_CODE, SESSION_STATUS_CHANGED_KIND, SESSION_COMMANDS_UPDATED_KIND, SESSION_INFO_UPDATED_KIND, SESSION_OPERATION_FAILED_KIND, sessionStatusChangedEventSchema, sessionMetadataSchema, sessionListCommandSchema, sessionsListedEventSchema, sessionQueryCommandSchema, sessionsQueriedEventSchema, sessionRestoreCommandSchema, sessionCloseCommandSchema, sessionPrepareCommandSchema, runtimeTimingsSchema, sessionReadyEventSchema, sessionRestoredEventSchema, sessionClosedEventSchema, sessionCloseNoticeEventSchema, sessionCommandsUpdatedEventSchema, sessionInfoUpdatedEventSchema, sessionOperationFailedEventSchema, decodeSessionListCommand, encodeSessionListCommand, decodeSessionsListedEvent, encodeSessionsListedEvent, decodeSessionQueryCommand, encodeSessionQueryCommand, decodeSessionsQueriedEvent, encodeSessionsQueriedEvent, decodeSessionRestoreCommand, encodeSessionRestoreCommand, decodeSessionRestoredEvent, encodeSessionRestoredEvent, decodeSessionCloseCommand, encodeSessionCloseCommand, decodeSessionClosedEvent, encodeSessionClosedEvent, decodeSessionCloseNoticeEvent, encodeSessionCloseNoticeEvent, decodeSessionStatusChangedEvent, encodeSessionStatusChangedEvent, decodeSessionPrepareCommand, encodeSessionPrepareCommand, decodeSessionReadyEvent, encodeSessionReadyEvent, decodeSessionInfoUpdatedEvent, encodeSessionInfoUpdatedEvent, decodeSessionOperationFailedEvent, encodeSessionOperationFailedEvent;
75355
75356
  var init_lifecycle = __esm({
@@ -75982,370 +75983,6 @@ var init_usage = __esm({
75982
75983
  }
75983
75984
  });
75984
75985
 
75985
- // ../mobius-sdk/src/protocol/session/recording/recorded-lifecycle-status.ts
75986
- var init_recorded_lifecycle_status = __esm({
75987
- "../mobius-sdk/src/protocol/session/recording/recorded-lifecycle-status.ts"() {
75988
- "use strict";
75989
- }
75990
- });
75991
-
75992
- // ../mobius-sdk/src/protocol/session/recording/recording.ts
75993
- var sessionRecordingWriteSchema, sessionRecordingWireWriteSchema, sessionRecordingHistorySchema, sessionRecordingStatusSchema, recordingCursorSchema, sessionRecordingHistoryPageSchema, sessionRecordingSummaryFields, sessionRecordingSummaryV2Schema, sessionRecordingDirectoryV2Schema, sessionRecordingSummarySchema, sessionRecordingDirectorySchema;
75994
- var init_recording = __esm({
75995
- "../mobius-sdk/src/protocol/session/recording/recording.ts"() {
75996
- "use strict";
75997
- init_zod();
75998
- init_directory();
75999
- init_identifier();
76000
- init_events();
76001
- sessionRecordingWriteSchema = external_exports.object({
76002
- envelope: sessionEventEnvelopeSchema,
76003
- projectId: identifierStringSchema,
76004
- runtimeId: identifierStringSchema
76005
- }).readonly();
76006
- sessionRecordingWireWriteSchema = external_exports.object({
76007
- envelope: sessionWireEnvelopeSchema,
76008
- projectId: identifierStringSchema,
76009
- runtimeId: identifierStringSchema
76010
- }).readonly();
76011
- sessionRecordingHistorySchema = external_exports.object({
76012
- events: external_exports.array(sessionLiveEventSchema).readonly(),
76013
- sessionId: identifierStringSchema
76014
- }).readonly();
76015
- sessionRecordingStatusSchema = external_exports.enum(["running", "idle", "failed"]);
76016
- recordingCursorSchema = external_exports.string().regex(/^v2:[1-9][0-9]*:(?:0|[1-9][0-9]*)$/);
76017
- sessionRecordingHistoryPageSchema = external_exports.object({
76018
- events: external_exports.array(sessionLiveEventSchema).max(1e4).readonly(),
76019
- // The append-order cursor after this page, or null when the caller has caught up.
76020
- nextCursor: recordingCursorSchema.nullable(),
76021
- // The append-order cursor at the newest recorded event, so an idle poller can compare one token.
76022
- tailCursor: recordingCursorSchema,
76023
- // True when a Session generation changed after the caller's cursor and it must replace its
76024
- // reconstructed state rather than append this page.
76025
- generationReset: external_exports.boolean(),
76026
- sessionId: identifierStringSchema,
76027
- truncated: external_exports.boolean(),
76028
- version: external_exports.literal(2)
76029
- }).readonly();
76030
- sessionRecordingSummaryFields = {
76031
- additionalDirectoryIds: external_exports.array(DIRECTORY_IDENTIFIER).max(16).readonly(),
76032
- agentId: identifierStringSchema,
76033
- directoryId: DIRECTORY_IDENTIFIER,
76034
- runtimeId: identifierStringSchema,
76035
- sessionId: identifierStringSchema,
76036
- title: external_exports.string().max(1e3),
76037
- updatedAt: external_exports.iso.datetime({ offset: true })
76038
- };
76039
- sessionRecordingSummaryV2Schema = external_exports.object(sessionRecordingSummaryFields).readonly();
76040
- sessionRecordingDirectoryV2Schema = external_exports.object({ sessions: external_exports.array(sessionRecordingSummaryV2Schema).max(1e5).readonly() }).readonly();
76041
- sessionRecordingSummarySchema = external_exports.object({ ...sessionRecordingSummaryFields, status: sessionRecordingStatusSchema }).readonly();
76042
- sessionRecordingDirectorySchema = external_exports.object({
76043
- sessions: external_exports.array(sessionRecordingSummarySchema).max(1e5).readonly()
76044
- }).readonly();
76045
- }
76046
- });
76047
-
76048
- // ../mobius-sdk/src/protocol/session/recording/turn-history.ts
76049
- var SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS, SESSION_RECORDING_TURN_ITEM_ID_MAX_LENGTH, isoTimestamp, shortText, itemText, turnCursorSchema, turnItemCursorSchema, attemptTiming, promptSucceededOutcome, promptCancelledOutcome, promptFailedOutcome, sessionRecordingTurnAttemptSchema, turnItemBase, textItemFields, sessionRecordingToolDetailSchema, sessionRecordingTurnItemSchema, sessionRecordingTurnPromptSchema, sessionRecordingTurnPrecedingSchema, sessionRecordingTurnSchema, sessionRecordingInteractionSchema, SESSION_RECORDING_EXECUTION_COMMAND_MAX_LIMIT, recordingActiveCommandsSchema, sessionRecordingExecutionCommandSchema, sessionRecordingExecutionSchema, sessionRecordingTurnPageSchema, sessionRecordingTurnItemPageSchema, sessionRecordingTurnItemDetailSchema;
76050
- var init_turn_history = __esm({
76051
- "../mobius-sdk/src/protocol/session/recording/turn-history.ts"() {
76052
- "use strict";
76053
- init_zod();
76054
- init_identifier();
76055
- init_events();
76056
- init_interactions();
76057
- init_recording();
76058
- SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS = 1e4;
76059
- SESSION_RECORDING_TURN_ITEM_ID_MAX_LENGTH = 4200;
76060
- isoTimestamp = external_exports.iso.datetime({ offset: true });
76061
- shortText = external_exports.string().max(2048);
76062
- itemText = external_exports.string().max(5e7);
76063
- turnCursorSchema = external_exports.string().regex(/^turn:[1-9][0-9]*$/);
76064
- turnItemCursorSchema = external_exports.string().regex(/^(?:before|after):item:(?:0|[1-9][0-9]*)$/);
76065
- attemptTiming = {
76066
- attemptId: identifierStringSchema.optional(),
76067
- startedAt: isoTimestamp.optional()
76068
- };
76069
- promptSucceededOutcome = { completedAt: isoTimestamp, stopReason: shortText };
76070
- promptCancelledOutcome = { cancelledAt: isoTimestamp };
76071
- promptFailedOutcome = {
76072
- code: identifierStringSchema,
76073
- failedAt: isoTimestamp,
76074
- message: external_exports.string().min(1).max(500)
76075
- };
76076
- sessionRecordingTurnAttemptSchema = external_exports.discriminatedUnion("kind", [
76077
- external_exports.object({ kind: external_exports.literal("none") }).readonly(),
76078
- external_exports.object({ ...attemptTiming, kind: external_exports.literal("running") }).readonly(),
76079
- external_exports.object({
76080
- ...attemptTiming,
76081
- interactionIds: external_exports.array(identifierStringSchema).min(1).max(100).readonly(),
76082
- kind: external_exports.literal("waiting_input")
76083
- }).readonly(),
76084
- external_exports.object({ ...attemptTiming, ...promptSucceededOutcome, kind: external_exports.literal("succeeded") }).readonly(),
76085
- external_exports.object({ ...attemptTiming, ...promptCancelledOutcome, kind: external_exports.literal("cancelled") }).readonly(),
76086
- external_exports.object({ ...attemptTiming, ...promptFailedOutcome, kind: external_exports.literal("failed") }).readonly(),
76087
- // A Session generation change restarted the local Agent process before this attempt ended.
76088
- external_exports.object({
76089
- ...attemptTiming,
76090
- detectedAt: isoTimestamp,
76091
- kind: external_exports.literal("indeterminate"),
76092
- reason: external_exports.literal("session_generation_changed")
76093
- }).readonly()
76094
- ]);
76095
- turnItemBase = {
76096
- // Opaque and stable for the life of the item; derived from the event, message, or tool call it merges.
76097
- itemId: external_exports.string().min(1).max(SESSION_RECORDING_TURN_ITEM_ID_MAX_LENGTH),
76098
- // Creation order inside the Turn; answer, thought, and tool items share one sequence.
76099
- sequence: external_exports.number().int().nonnegative().safe()
76100
- };
76101
- textItemFields = {
76102
- omittedCharacters: external_exports.number().int().nonnegative().safe(),
76103
- text: itemText
76104
- };
76105
- sessionRecordingToolDetailSchema = external_exports.discriminatedUnion("kind", [
76106
- external_exports.object({
76107
- content: external_exports.array(toolCallContentSchema).max(1e3).readonly(),
76108
- kind: external_exports.literal("inline"),
76109
- rawInput: boundedJsonSchema.optional(),
76110
- rawOutput: boundedJsonSchema.optional()
76111
- }).readonly(),
76112
- // The detail exceeded the page bound; a full item read returns it inline.
76113
- external_exports.object({ kind: external_exports.literal("omitted") }).readonly()
76114
- ]);
76115
- sessionRecordingTurnItemSchema = external_exports.discriminatedUnion("kind", [
76116
- external_exports.object({ ...turnItemBase, ...textItemFields, kind: external_exports.literal("answer") }).readonly(),
76117
- external_exports.object({ ...turnItemBase, ...textItemFields, kind: external_exports.literal("thought") }).readonly(),
76118
- external_exports.object({
76119
- ...turnItemBase,
76120
- attemptId: identifierStringSchema.optional(),
76121
- detail: sessionRecordingToolDetailSchema,
76122
- kind: external_exports.literal("tool"),
76123
- locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly(),
76124
- name: shortText.nullable(),
76125
- status: toolStatusSchema.nullable(),
76126
- title: itemText,
76127
- toolCallId: shortText,
76128
- toolKind: toolKindSchema.nullable()
76129
- }).readonly()
76130
- ]);
76131
- sessionRecordingTurnPromptSchema = external_exports.object({
76132
- content: external_exports.array(contentBlockSchema).min(1).max(100).readonly(),
76133
- disposition: shortText.optional(),
76134
- targetCommandId: identifierStringSchema.optional()
76135
- }).readonly();
76136
- sessionRecordingTurnPrecedingSchema = external_exports.object({
76137
- commandId: identifierStringSchema,
76138
- itemCount: external_exports.number().int().nonnegative().safe()
76139
- }).readonly();
76140
- sessionRecordingTurnSchema = external_exports.object({
76141
- answerLength: external_exports.number().int().nonnegative().safe(),
76142
- attempt: sessionRecordingTurnAttemptSchema,
76143
- commandId: identifierStringSchema,
76144
- createdAt: isoTimestamp,
76145
- generationId: identifierStringSchema,
76146
- itemCount: external_exports.number().int().nonnegative().safe(),
76147
- items: external_exports.array(sessionRecordingTurnItemSchema).max(SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS).readonly(),
76148
- // Continues this Turn's items before the listed run, or null when every item is listed. A
76149
- // page starts from the end of a Turn's sequence, so what it leaves out is the work that
76150
- // produced the conclusion it does show; this cursor reads that work back.
76151
- itemsCursor: turnItemCursorSchema.nullable(),
76152
- messageId: shortText.nullable(),
76153
- // Creation order of Turns in the Session; newer Turns have larger orders.
76154
- order: external_exports.number().int().positive().safe(),
76155
- // Null when the Recording holds Agent output for a command whose prompt it never recorded.
76156
- prompt: sessionRecordingTurnPromptSchema.nullable(),
76157
- // The command whose work was running when this prompt was requested and how many items it had
76158
- // by then, so a prompt that records no work of its own (a steer) can be placed where it was sent.
76159
- // Null when no other command was running.
76160
- preceding: sessionRecordingTurnPrecedingSchema.nullable()
76161
- }).readonly();
76162
- sessionRecordingInteractionSchema = external_exports.discriminatedUnion("kind", [
76163
- external_exports.object({
76164
- commandId: identifierStringSchema,
76165
- event: sessionPermissionRequestedEventSchema,
76166
- interactionId: identifierStringSchema,
76167
- kind: external_exports.literal("permission")
76168
- }).readonly(),
76169
- external_exports.object({
76170
- commandId: identifierStringSchema,
76171
- event: sessionElicitationRequestedEventSchema,
76172
- interactionId: identifierStringSchema,
76173
- kind: external_exports.literal("elicitation")
76174
- }).readonly()
76175
- ]);
76176
- SESSION_RECORDING_EXECUTION_COMMAND_MAX_LIMIT = 100;
76177
- recordingActiveCommandsSchema = external_exports.object({
76178
- commandIds: external_exports.array(identifierStringSchema).max(1e3).readonly(),
76179
- generationId: identifierStringSchema
76180
- }).readonly().nullable();
76181
- sessionRecordingExecutionCommandSchema = external_exports.object({
76182
- attempt: sessionRecordingTurnAttemptSchema,
76183
- commandId: identifierStringSchema,
76184
- generationId: identifierStringSchema
76185
- }).readonly();
76186
- sessionRecordingExecutionSchema = external_exports.object({
76187
- activeCommands: recordingActiveCommandsSchema,
76188
- commands: external_exports.array(sessionRecordingExecutionCommandSchema).max(SESSION_RECORDING_EXECUTION_COMMAND_MAX_LIMIT).readonly(),
76189
- sessionId: identifierStringSchema,
76190
- tailCursor: recordingCursorSchema,
76191
- version: external_exports.literal(1)
76192
- }).readonly();
76193
- sessionRecordingTurnPageSchema = external_exports.object({
76194
- // Commands that own Agent output in the newest Session generation, innermost last.
76195
- activeCommands: external_exports.object({
76196
- commandIds: external_exports.array(identifierStringSchema).max(1e3).readonly(),
76197
- generationId: identifierStringSchema
76198
- }).readonly().nullable(),
76199
- // Requests still waiting for an answer in a Turn that can still receive one.
76200
- interactions: external_exports.array(sessionRecordingInteractionSchema).max(1e3).readonly(),
76201
- // Continues with older Turns, or null when the oldest Turn is listed.
76202
- nextCursor: turnCursorSchema.nullable(),
76203
- sessionId: identifierStringSchema,
76204
- // The Recording cursor at the last event this snapshot includes; live reads continue after it.
76205
- tailCursor: recordingCursorSchema,
76206
- title: external_exports.string().max(1e3).nullable(),
76207
- turns: external_exports.array(sessionRecordingTurnSchema).max(SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS).readonly(),
76208
- version: external_exports.literal(1)
76209
- }).readonly();
76210
- sessionRecordingTurnItemPageSchema = external_exports.object({
76211
- commandId: identifierStringSchema,
76212
- items: external_exports.array(sessionRecordingTurnItemSchema).max(SESSION_RECORDING_TURN_PAGE_DECODE_MAX_ELEMENTS).readonly(),
76213
- // Continues from the edge of this page in the direction it was read: `before` reads back
76214
- // toward a Turn's earlier work, `after` forward toward the work it is still producing. Null
76215
- // when the run reached that end of the Turn.
76216
- nextCursor: turnItemCursorSchema.nullable(),
76217
- sessionId: identifierStringSchema,
76218
- version: external_exports.literal(1)
76219
- }).readonly();
76220
- sessionRecordingTurnItemDetailSchema = external_exports.object({
76221
- commandId: identifierStringSchema,
76222
- item: sessionRecordingTurnItemSchema,
76223
- sessionId: identifierStringSchema,
76224
- version: external_exports.literal(1)
76225
- }).readonly();
76226
- }
76227
- });
76228
-
76229
- // ../mobius-sdk/src/protocol/session/recording/webhooks.ts
76230
- var isoTimestamp2, shortText2, promptSucceededOutcome2, promptCancelledOutcome2, promptFailedOutcome2, sessionStatusWebhookCommandSchema, sessionStatusWebhookBodyFields, sessionStatusWebhookBodySchema, consumedSessionStatusWebhookBodySchema;
76231
- var init_webhooks = __esm({
76232
- "../mobius-sdk/src/protocol/session/recording/webhooks.ts"() {
76233
- "use strict";
76234
- init_zod();
76235
- init_identifier();
76236
- init_recording();
76237
- isoTimestamp2 = external_exports.iso.datetime({ offset: true });
76238
- shortText2 = external_exports.string().max(2048);
76239
- promptSucceededOutcome2 = { completedAt: isoTimestamp2, stopReason: shortText2 };
76240
- promptCancelledOutcome2 = { cancelledAt: isoTimestamp2 };
76241
- promptFailedOutcome2 = {
76242
- code: identifierStringSchema,
76243
- failedAt: isoTimestamp2,
76244
- message: external_exports.string().min(1).max(500)
76245
- };
76246
- sessionStatusWebhookCommandSchema = external_exports.discriminatedUnion("outcome", [
76247
- external_exports.object({
76248
- ...promptSucceededOutcome2,
76249
- commandId: identifierStringSchema,
76250
- outcome: external_exports.literal("succeeded")
76251
- }).readonly(),
76252
- external_exports.object({
76253
- ...promptCancelledOutcome2,
76254
- commandId: identifierStringSchema,
76255
- outcome: external_exports.literal("cancelled")
76256
- }).readonly(),
76257
- external_exports.object({
76258
- ...promptFailedOutcome2,
76259
- commandId: identifierStringSchema,
76260
- outcome: external_exports.literal("failed")
76261
- }).readonly()
76262
- ]);
76263
- sessionStatusWebhookBodyFields = {
76264
- appId: identifierStringSchema,
76265
- projectId: identifierStringSchema,
76266
- runtimeId: identifierStringSchema,
76267
- sessionId: identifierStringSchema,
76268
- status: sessionRecordingStatusSchema
76269
- };
76270
- sessionStatusWebhookBodySchema = external_exports.object({
76271
- ...sessionStatusWebhookBodyFields,
76272
- commands: external_exports.array(sessionStatusWebhookCommandSchema).min(1).readonly()
76273
- }).readonly();
76274
- consumedSessionStatusWebhookBodySchema = external_exports.object({
76275
- ...sessionStatusWebhookBodyFields,
76276
- commands: external_exports.array(sessionStatusWebhookCommandSchema).readonly()
76277
- }).readonly();
76278
- }
76279
- });
76280
-
76281
- // ../mobius-sdk/src/protocol/session/turn/index.ts
76282
- var timestampSchema2, domainErrorSchema, executionResultSchema, reconciliationSchema, terminalTurnStateSchema, turnStateSchema, promptTurnRequestSchema, notRetainedTurnRequestSchema, turnRequestSchema, turnIdentitySchema, turnSchema2;
76283
- var init_turn = __esm({
76284
- "../mobius-sdk/src/protocol/session/turn/index.ts"() {
76285
- "use strict";
76286
- init_zod();
76287
- init_identifier();
76288
- init_configuration();
76289
- timestampSchema2 = external_exports.string().datetime({ offset: true });
76290
- domainErrorSchema = external_exports.object({
76291
- code: identifierSchema,
76292
- message: external_exports.string().min(1).max(2e3),
76293
- retryable: external_exports.boolean()
76294
- }).readonly();
76295
- executionResultSchema = external_exports.object({
76296
- kind: external_exports.literal("agent_result"),
76297
- stopReason: external_exports.string().min(1).max(128)
76298
- }).readonly();
76299
- reconciliationSchema = external_exports.object({
76300
- detectedAt: timestampSchema2,
76301
- reason: external_exports.enum(["connection_lost", "dispatch_indeterminate", "runtime_restarted"])
76302
- }).readonly();
76303
- terminalTurnStateSchema = external_exports.discriminatedUnion("kind", [
76304
- external_exports.object({
76305
- completedAt: timestampSchema2,
76306
- kind: external_exports.literal("succeeded"),
76307
- result: executionResultSchema
76308
- }).readonly(),
76309
- external_exports.object({
76310
- error: domainErrorSchema,
76311
- failedAt: timestampSchema2,
76312
- kind: external_exports.literal("failed")
76313
- }).readonly(),
76314
- external_exports.object({
76315
- cancelledAt: timestampSchema2,
76316
- kind: external_exports.literal("cancelled")
76317
- }).readonly()
76318
- ]);
76319
- turnStateSchema = external_exports.discriminatedUnion("kind", [
76320
- external_exports.object({ kind: external_exports.literal("queued") }).readonly(),
76321
- external_exports.object({ kind: external_exports.literal("running"), startedAt: timestampSchema2 }).readonly(),
76322
- ...terminalTurnStateSchema.options,
76323
- external_exports.object({
76324
- kind: external_exports.literal("indeterminate"),
76325
- reconciliation: reconciliationSchema
76326
- }).readonly()
76327
- ]);
76328
- promptTurnRequestSchema = external_exports.object({
76329
- content: external_exports.string().max(1e5),
76330
- kind: external_exports.literal("prompt"),
76331
- sessionConfigurations: sessionConfigurationSelectionsSchema.default([])
76332
- }).readonly();
76333
- notRetainedTurnRequestSchema = external_exports.object({ kind: external_exports.literal("not_retained") }).readonly();
76334
- turnRequestSchema = external_exports.discriminatedUnion("kind", [promptTurnRequestSchema, notRetainedTurnRequestSchema]);
76335
- turnIdentitySchema = external_exports.object({
76336
- acceptedAt: timestampSchema2,
76337
- bindingId: identifierSchema,
76338
- idempotencyKey: identifierSchema,
76339
- sessionId: identifierSchema,
76340
- turnId: identifierSchema
76341
- });
76342
- turnSchema2 = external_exports.union([
76343
- turnIdentitySchema.extend({ request: promptTurnRequestSchema, state: turnStateSchema }).readonly(),
76344
- turnIdentitySchema.extend({ request: notRetainedTurnRequestSchema, state: terminalTurnStateSchema }).readonly()
76345
- ]);
76346
- }
76347
- });
76348
-
76349
75986
  // ../mobius-sdk/src/protocol/session/workspace/index.ts
76350
75987
  var WORKSPACE_LIST_KIND, WORKSPACE_ENTRIES_KIND, RUNTIME_WORKSPACE_BINDING_ID, workspaceListCommandSchema, workspaceEntriesEventSchema, decodeWorkspaceListCommand, encodeWorkspaceListCommand, decodeWorkspaceEntriesEvent, encodeWorkspaceEntriesEvent;
76351
75988
  var init_workspace = __esm({
@@ -76693,11 +76330,8 @@ var init_protocol = __esm({
76693
76330
  "../mobius-sdk/src/protocol/index.ts"() {
76694
76331
  "use strict";
76695
76332
  init_mobius_api();
76696
- init_project_location();
76697
- init_diagnostics();
76698
76333
  init_liveness();
76699
76334
  init_upgrade();
76700
- init_access();
76701
76335
  init_catalog();
76702
76336
  init_settings2();
76703
76337
  init_configuration();
@@ -76705,19 +76339,15 @@ var init_protocol = __esm({
76705
76339
  init_events();
76706
76340
  init_files();
76707
76341
  init_interactions();
76708
- init_model();
76709
76342
  init_lifecycle();
76710
76343
  init_native();
76711
76344
  init_history2();
76712
76345
  init_commands();
76713
76346
  init_usage();
76714
- init_recorded_lifecycle_status();
76715
- init_turn_history();
76716
- init_webhooks();
76717
- init_turn();
76718
76347
  init_workspace();
76719
76348
  init_directory();
76720
76349
  init_identifier();
76350
+ init_tool_input();
76721
76351
  init_daemon_transport();
76722
76352
  }
76723
76353
  });
@@ -77226,9 +76856,9 @@ var init_agent = __esm({
77226
76856
  threadId: () => this.#nativeSessionId,
77227
76857
  connection: () => this.#connection,
77228
76858
  emit: this.#emit,
77229
- onBackgroundActivity: (active) => {
76859
+ onBackgroundActivity: (activity) => {
77230
76860
  if (this.#closePromise === null) {
77231
- this.#onBackgroundActivity?.(active);
76861
+ this.#onBackgroundActivity?.(activity);
77232
76862
  }
77233
76863
  },
77234
76864
  close: this.close
@@ -77376,7 +77006,7 @@ var init_agent = __esm({
77376
77006
  await stopProcessTree(child, captured);
77377
77007
  } finally {
77378
77008
  this.#connection?.close();
77379
- this.#onBackgroundActivity?.(false);
77009
+ this.#onBackgroundActivity?.("none");
77380
77010
  }
77381
77011
  })();
77382
77012
  }
@@ -77481,7 +77111,7 @@ var init_agent_connection2 = __esm({
77481
77111
  cwd: options.cwd,
77482
77112
  environment: options.environment,
77483
77113
  onSessionUpdate: options.client.onUpdate,
77484
- onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
77114
+ onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
77485
77115
  });
77486
77116
  super(endpoint, options.client);
77487
77117
  }
@@ -81578,7 +81208,7 @@ var init_agent_connection3 = __esm({
81578
81208
  await options.client.onUpdate({ ...notification, update });
81579
81209
  }
81580
81210
  },
81581
- onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
81211
+ onBackgroundActivity: (activity) => options.onBackgroundActivity?.(activity)
81582
81212
  });
81583
81213
  super(endpoint, options.client);
81584
81214
  }
@@ -82859,24 +82489,7 @@ var init_agent_update_stream = __esm({
82859
82489
 
82860
82490
  // src/acp/adapter/session-events.ts
82861
82491
  import { setImmediate as yieldToRuntime2 } from "node:timers/promises";
82862
- function* reasoningWireUpdates(update) {
82863
- if (update.sessionUpdate !== "agent_thought_chunk" || update.content.type !== "text" || update.content.text.length <= MAXIMUM_REASONING_UPDATE_CHARACTERS) {
82864
- yield update;
82865
- return;
82866
- }
82867
- const text2 = update.content.text;
82868
- for (let start = 0; start < text2.length; ) {
82869
- let end = Math.min(start + MAXIMUM_REASONING_UPDATE_CHARACTERS, text2.length);
82870
- const last = text2.charCodeAt(end - 1);
82871
- const next = text2.charCodeAt(end);
82872
- if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) {
82873
- end -= 1;
82874
- }
82875
- yield { ...update, content: { ...update.content, text: text2.slice(start, end) } };
82876
- start = end;
82877
- }
82878
- }
82879
- var MAXIMUM_REASONING_UPDATE_CHARACTERS, AdapterSessionConnection, AcpSessionConnector;
82492
+ var AdapterSessionConnection, AcpSessionConnector;
82880
82493
  var init_session_events = __esm({
82881
82494
  "src/acp/adapter/session-events.ts"() {
82882
82495
  "use strict";
@@ -82885,12 +82498,11 @@ var init_session_events = __esm({
82885
82498
  init_acp_error();
82886
82499
  init_agent_update_stream();
82887
82500
  init_session_config_protocol();
82888
- MAXIMUM_REASONING_UPDATE_CHARACTERS = 1e6;
82889
82501
  AdapterSessionConnection = class {
82890
82502
  #connection;
82891
82503
  #onBackgroundActivity;
82892
- #backgroundActivity = false;
82893
- hasBackgroundActivity = () => this.#backgroundActivity;
82504
+ #backgroundActivity = "none";
82505
+ hasBackgroundActivity = () => this.#backgroundActivity !== "none";
82894
82506
  #updates;
82895
82507
  #lifetime = new AbortController();
82896
82508
  #onClosed;
@@ -82906,68 +82518,66 @@ var init_session_events = __esm({
82906
82518
  throw new AcpExecutionError("ACP agent referenced an unknown session", {}, "invalid_agent_session");
82907
82519
  }
82908
82520
  const signal = AbortSignal.any([this.#lifetime.signal, AbortSignal.timeout(3e4)]);
82909
- for (const incoming of reasoningWireUpdates(notification.update)) {
82910
- const externalized = await externalizer.update(options.sessionId(), incoming, signal);
82911
- signal.throwIfAborted();
82912
- const update = externalized.agent;
82913
- const eventUpdate = externalized.event;
82914
- const backgroundTask = update._meta?.["mobius.backgroundTask"];
82915
- const payload = decodeAcpSessionUpdate(
82916
- JSON.stringify(
82917
- normalizeEvent(
82918
- (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") && backgroundTask !== void 0 && typeof eventUpdate === "object" && eventUpdate !== null ? { ...eventUpdate, backgroundTask } : eventUpdate
82919
- )
82521
+ const externalized = await externalizer.update(options.sessionId(), notification.update, signal);
82522
+ signal.throwIfAborted();
82523
+ const update = externalized.agent;
82524
+ const eventUpdate = externalized.event;
82525
+ const backgroundTask = update._meta?.["mobius.backgroundTask"];
82526
+ const payload = decodeAcpSessionUpdate(
82527
+ JSON.stringify(
82528
+ normalizeEvent(
82529
+ (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") && backgroundTask !== void 0 && typeof eventUpdate === "object" && eventUpdate !== null ? { ...eventUpdate, backgroundTask } : eventUpdate
82920
82530
  )
82921
- );
82922
- let event;
82923
- switch (update.sessionUpdate) {
82924
- case "available_commands_update":
82925
- event = {
82926
- kind: "commands",
82927
- payload,
82928
- commands: update.availableCommands.slice(0, 500).map((command) => ({
82929
- description: truncate(command.description, 500),
82930
- inputHint: truncate(command.input?.hint ?? "", 255),
82931
- name: truncate(command.name, 128)
82932
- })).filter((command) => command.name.length > 0)
82933
- };
82934
- break;
82935
- case "config_option_update":
82936
- event = {
82937
- kind: "configuration",
82938
- payload,
82939
- configOptions: protocol.normalizeUpdate(options.configOptions(), update.configOptions)
82940
- };
82941
- break;
82942
- case "current_mode_update":
82943
- event = { kind: "mode", payload, modeId: update.currentModeId };
82944
- break;
82945
- case "session_info_update": {
82946
- const changes = [];
82947
- if (Object.hasOwn(update, "title")) {
82948
- changes.push({ kind: "title", value: truncate(update.title ?? "", 500) });
82949
- }
82950
- if (Object.hasOwn(update, "updatedAt")) {
82951
- changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
82952
- }
82953
- event = { kind: "info", payload, changes };
82954
- break;
82531
+ )
82532
+ );
82533
+ let event;
82534
+ switch (update.sessionUpdate) {
82535
+ case "available_commands_update":
82536
+ event = {
82537
+ kind: "commands",
82538
+ payload,
82539
+ commands: update.availableCommands.slice(0, 500).map((command) => ({
82540
+ description: truncate(command.description, 500),
82541
+ inputHint: truncate(command.input?.hint ?? "", 255),
82542
+ name: truncate(command.name, 128)
82543
+ })).filter((command) => command.name.length > 0)
82544
+ };
82545
+ break;
82546
+ case "config_option_update":
82547
+ event = {
82548
+ kind: "configuration",
82549
+ payload,
82550
+ configOptions: protocol.normalizeUpdate(options.configOptions(), update.configOptions)
82551
+ };
82552
+ break;
82553
+ case "current_mode_update":
82554
+ event = { kind: "mode", payload, modeId: update.currentModeId };
82555
+ break;
82556
+ case "session_info_update": {
82557
+ const changes = [];
82558
+ if (Object.hasOwn(update, "title")) {
82559
+ changes.push({ kind: "title", value: truncate(update.title ?? "", 500) });
82955
82560
  }
82956
- case "user_message_chunk":
82957
- case "agent_message_chunk":
82958
- case "agent_thought_chunk":
82959
- case "tool_call":
82960
- case "tool_call_update":
82961
- case "plan":
82962
- case "plan_update":
82963
- case "plan_removed":
82964
- event = { kind: "content", payload };
82965
- break;
82966
- default:
82967
- event = { kind: "other", payload };
82561
+ if (Object.hasOwn(update, "updatedAt")) {
82562
+ changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
82563
+ }
82564
+ event = { kind: "info", payload, changes };
82565
+ break;
82968
82566
  }
82969
- await options.onEvent(event);
82567
+ case "user_message_chunk":
82568
+ case "agent_message_chunk":
82569
+ case "agent_thought_chunk":
82570
+ case "tool_call":
82571
+ case "tool_call_update":
82572
+ case "plan":
82573
+ case "plan_update":
82574
+ case "plan_removed":
82575
+ event = { kind: "content", payload };
82576
+ break;
82577
+ default:
82578
+ event = { kind: "other", payload };
82970
82579
  }
82580
+ await options.onEvent(event);
82971
82581
  });
82972
82582
  this.events = this.#updates;
82973
82583
  const client2 = {
@@ -82996,12 +82606,12 @@ var init_session_events = __esm({
82996
82606
  this.#connection = options.agent.createConnection({
82997
82607
  cwd: options.cwd,
82998
82608
  client: client2,
82999
- onBackgroundActivity: (active) => {
82609
+ onBackgroundActivity: (activity) => {
83000
82610
  if (this.#lifetime.signal.aborted) {
83001
82611
  return;
83002
82612
  }
83003
- this.#backgroundActivity = active;
83004
- this.#onBackgroundActivity(active);
82613
+ this.#backgroundActivity = activity;
82614
+ this.#onBackgroundActivity(activity);
83005
82615
  }
83006
82616
  });
83007
82617
  }
@@ -83020,8 +82630,8 @@ var init_session_events = __esm({
83020
82630
  await this.#updates.drained().catch(() => void 0);
83021
82631
  } finally {
83022
82632
  this.#onClosed();
83023
- this.#backgroundActivity = false;
83024
- this.#onBackgroundActivity(false);
82633
+ this.#backgroundActivity = "none";
82634
+ this.#onBackgroundActivity("none");
83025
82635
  }
83026
82636
  }
83027
82637
  };
@@ -83466,6 +83076,9 @@ function mergeTextChunk(previous, incoming) {
83466
83076
  if (previous.sessionUpdate !== "agent_message_chunk" && previous.sessionUpdate !== "agent_thought_chunk" && previous.sessionUpdate !== "user_message_chunk" || incoming.sessionUpdate !== previous.sessionUpdate || previous.messageId !== incoming.messageId || previous.content.type !== "text" || incoming.content.type !== "text") {
83467
83077
  return null;
83468
83078
  }
83079
+ if (previous.sessionUpdate !== "agent_thought_chunk" && previous.content.text.length + incoming.content.text.length > MAXIMUM_PROJECTED_MESSAGE_CHARACTERS) {
83080
+ return null;
83081
+ }
83469
83082
  const content = { text: `${previous.content.text}${incoming.content.text}`, type: "text" };
83470
83083
  if (previous.sessionUpdate === "agent_thought_chunk" && incoming.sessionUpdate === "agent_thought_chunk") {
83471
83084
  return boundReasoning({
@@ -83476,11 +83089,12 @@ function mergeTextChunk(previous, incoming) {
83476
83089
  }
83477
83090
  return { ...previous, content };
83478
83091
  }
83479
- var MAXIMUM_PROJECTED_REASONING_BYTES, SessionEventHistoryProjection;
83092
+ var MAXIMUM_PROJECTED_REASONING_BYTES, MAXIMUM_PROJECTED_MESSAGE_CHARACTERS, SessionEventHistoryProjection;
83480
83093
  var init_session_event_history_projection = __esm({
83481
83094
  "src/session/history/session-event-history-projection.ts"() {
83482
83095
  "use strict";
83483
83096
  MAXIMUM_PROJECTED_REASONING_BYTES = 24 * 1024;
83097
+ MAXIMUM_PROJECTED_MESSAGE_CHARACTERS = 1e6;
83484
83098
  SessionEventHistoryProjection = class {
83485
83099
  #toolCallEventIds = /* @__PURE__ */ new Map();
83486
83100
  #latestEvent = null;
@@ -90335,7 +89949,7 @@ function prepareCodexToolUpdate(update) {
90335
89949
  };
90336
89950
  }
90337
89951
  function fitPayload(value) {
90338
- if (value === void 0 || boundedJsonSchema.safeParse(value).success) {
89952
+ if (value === void 0 || isBoundedJson(value)) {
90339
89953
  return value;
90340
89954
  }
90341
89955
  return { truncated: true, text: payloadText(value) };
@@ -90564,6 +90178,28 @@ var init_registry = __esm({
90564
90178
  });
90565
90179
 
90566
90180
  // src/acp/content/content-externalizer.ts
90181
+ function boundedText2(text2) {
90182
+ if (text2.length <= MAXIMUM_TEXT_CHARACTERS) {
90183
+ return text2;
90184
+ }
90185
+ const marker = (start2) => `... [omit ${text2.length - start2} characters since ${start2}]`;
90186
+ let start = 0;
90187
+ let upper = MAXIMUM_TEXT_CHARACTERS;
90188
+ while (start < upper) {
90189
+ const candidate = Math.ceil((start + upper) / 2);
90190
+ if (candidate + marker(candidate).length <= MAXIMUM_TEXT_CHARACTERS) {
90191
+ start = candidate;
90192
+ } else {
90193
+ upper = candidate - 1;
90194
+ }
90195
+ }
90196
+ const last = text2.charCodeAt(start - 1);
90197
+ const next = text2.charCodeAt(start);
90198
+ if (last >= 55296 && last <= 56319 && next >= 56320 && next <= 57343) {
90199
+ start -= 1;
90200
+ }
90201
+ return text2.slice(0, start) + marker(start);
90202
+ }
90567
90203
  function decodeBase64(data) {
90568
90204
  if (data.length > MAXIMUM_ENCODED_CONTENT_CHARACTERS || data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(data)) {
90569
90205
  throw new Error("The ACP embedded content is not valid bounded base64");
@@ -90577,13 +90213,14 @@ function decodeBase64(data) {
90577
90213
  function isRecord6(value) {
90578
90214
  return typeof value === "object" && value !== null && !Array.isArray(value);
90579
90215
  }
90580
- var MAXIMUM_ENCODED_CONTENT_CHARACTERS, embeddedImageSchema, inlineImageUrlSchema, toolImageSchema, AcpContentExternalizer;
90216
+ var MAXIMUM_ENCODED_CONTENT_CHARACTERS, MAXIMUM_TEXT_CHARACTERS, embeddedImageSchema, inlineImageUrlSchema, toolImageSchema, AcpContentExternalizer;
90581
90217
  var init_content_externalizer = __esm({
90582
90218
  "src/acp/content/content-externalizer.ts"() {
90583
90219
  "use strict";
90584
90220
  init_zod();
90585
90221
  init_raster();
90586
90222
  MAXIMUM_ENCODED_CONTENT_CHARACTERS = 4e6;
90223
+ MAXIMUM_TEXT_CHARACTERS = 1e6;
90587
90224
  embeddedImageSchema = external_exports.looseObject({
90588
90225
  type: external_exports.literal("image"),
90589
90226
  data: external_exports.string(),
@@ -90615,6 +90252,7 @@ var init_content_externalizer = __esm({
90615
90252
  async #content(sessionId, content, signal) {
90616
90253
  switch (content.type) {
90617
90254
  case "text":
90255
+ return { agent: content, event: { ...content, text: boundedText2(content.text) } };
90618
90256
  case "resource_link":
90619
90257
  return { agent: content, event: content };
90620
90258
  case "image": {
@@ -91741,7 +91379,7 @@ async function readCurrentDataVersion(root, signal) {
91741
91379
  if (!value.startsWith("versions/")) {
91742
91380
  throw new DataInheritanceError("The current data pointer must name a version directory");
91743
91381
  }
91744
- return runtimeUpgradeVersionSchema.parse(value.slice("versions/".length));
91382
+ return decodeRuntimeUpgradeVersion(value.slice("versions/".length));
91745
91383
  } catch (cause) {
91746
91384
  if (isNodeError(cause, "ENOENT")) {
91747
91385
  return null;
@@ -92713,7 +92351,7 @@ var init_switch_status = __esm({
92713
92351
  async function prepareVersionData(version2, signal, environment = process.env, fallbackVersion = null) {
92714
92352
  signal.throwIfAborted();
92715
92353
  const root = readStateDirectory(environment);
92716
- const targetVersion = runtimeUpgradeVersionSchema.parse(version2);
92354
+ const targetVersion = decodeRuntimeUpgradeVersion(version2);
92717
92355
  const current = await readCurrentDataVersion(root, signal);
92718
92356
  let previous;
92719
92357
  if (current !== null) {
@@ -92728,7 +92366,7 @@ async function prepareVersionData(version2, signal, environment = process.env, f
92728
92366
  }
92729
92367
  previous = fallbackVersion;
92730
92368
  }
92731
- const leftBehind = await copyVersionData(root, runtimeUpgradeVersionSchema.parse(previous), targetVersion, signal);
92369
+ const leftBehind = await copyVersionData(root, decodeRuntimeUpgradeVersion(previous), targetVersion, signal);
92732
92370
  for (const entry of leftBehind) {
92733
92371
  process.stderr.write(
92734
92372
  `Mobius did not carry ${entry} into version ${targetVersion}: an earlier Mobius ran with that installation as its state root.
@@ -92737,10 +92375,10 @@ async function prepareVersionData(version2, signal, environment = process.env, f
92737
92375
  }
92738
92376
  }
92739
92377
  async function discardRolledBackData(version2, signal) {
92740
- await discardVersionData(readStateDirectory(), runtimeUpgradeVersionSchema.parse(version2), signal);
92378
+ await discardVersionData(readStateDirectory(), decodeRuntimeUpgradeVersion(version2), signal);
92741
92379
  }
92742
92380
  async function recordCurrentData(version2, signal) {
92743
- await writeCurrentDataVersion(readStateDirectory(), runtimeUpgradeVersionSchema.parse(version2), signal);
92381
+ await writeCurrentDataVersion(readStateDirectory(), decodeRuntimeUpgradeVersion(version2), signal);
92744
92382
  }
92745
92383
  async function prepareUpgradeData(controlDirectory, version2, signal) {
92746
92384
  const transition2 = await readSwitchStatus(controlDirectory, signal);
@@ -93488,7 +93126,7 @@ var init_release_files = __esm({
93488
93126
  // src/daemon/upgrades/package.ts
93489
93127
  import { isAbsolute as isAbsolute16, join as join34, relative as relative4 } from "node:path";
93490
93128
  async function prepareDaemonReleaseVersion(version2, signal) {
93491
- runtimeUpgradeVersionSchema.parse(version2);
93129
+ decodeRuntimeUpgradeVersion(version2);
93492
93130
  signal.throwIfAborted();
93493
93131
  const prefix = releasePrefix(version2);
93494
93132
  let installed;
@@ -93518,7 +93156,7 @@ async function prepareDaemonReleaseVersion(version2, signal) {
93518
93156
  }
93519
93157
  }
93520
93158
  async function installDaemonReleaseVersion(version2, signal) {
93521
- runtimeUpgradeVersionSchema.parse(version2);
93159
+ decodeRuntimeUpgradeVersion(version2);
93522
93160
  const npm = await findExecutableOnPath("npm", process.env);
93523
93161
  if (npm === null) {
93524
93162
  throw new DaemonReleaseUpgradeError("npm_unavailable", "npm is required to download the new daemon");
@@ -93616,7 +93254,7 @@ async function findNewDaemonReleaseVersion(currentVersion, signal) {
93616
93254
  timeoutMilliseconds: 3e4,
93617
93255
  outputLimitBytes: 4096
93618
93256
  });
93619
- const version2 = npmViewVersionSchema.parse(JSON.parse(result.stdout));
93257
+ const version2 = decodeRuntimeUpgradeVersion(npmViewVersionSchema.parse(JSON.parse(result.stdout)));
93620
93258
  return (0, import_semver.gt)(version2, currentVersion) ? version2 : null;
93621
93259
  } catch (cause) {
93622
93260
  signal.throwIfAborted();
@@ -93645,7 +93283,7 @@ var init_package2 = __esm({
93645
93283
  this.code = code;
93646
93284
  }
93647
93285
  };
93648
- npmViewVersionSchema = external_exports.union([runtimeUpgradeVersionSchema, external_exports.tuple([runtimeUpgradeVersionSchema])]).transform((value) => typeof value === "string" ? value : value[0]);
93286
+ npmViewVersionSchema = external_exports.union([external_exports.string(), external_exports.tuple([external_exports.string()])]).transform((value) => typeof value === "string" ? value : value[0]);
93649
93287
  }
93650
93288
  });
93651
93289
 
@@ -94269,7 +93907,7 @@ var init_session_api = __esm({
94269
93907
  "src/session/api/session-api.ts"() {
94270
93908
  "use strict";
94271
93909
  NullSessionObserver = class {
94272
- onBackgroundActivity = (_source, _active) => {
93910
+ onBackgroundActivity = (_source, _activity) => {
94273
93911
  };
94274
93912
  onSessionEvent = (_event) => Promise.resolve();
94275
93913
  onCommands = () => Promise.resolve();
@@ -95468,7 +95106,7 @@ var init_agent_session = __esm({
95468
95106
  ...scope,
95469
95107
  additionalDirectories: this.#additionalDirectories,
95470
95108
  capabilities: () => this.#capabilities,
95471
- onBackgroundActivity: (active) => this.#getObserver().onBackgroundActivity?.(this, active),
95109
+ onBackgroundActivity: (activity) => this.#getObserver().onBackgroundActivity?.(this, activity),
95472
95110
  interactions: {
95473
95111
  onPermission: this.#interactions.onPermission,
95474
95112
  onElicitation: this.#interactions.onElicitation,
@@ -97710,25 +97348,30 @@ var init_runtime_turn_activity = __esm({
97710
97348
  "use strict";
97711
97349
  RuntimeTurnActivity = class {
97712
97350
  #turns = /* @__PURE__ */ new Set();
97713
- #backgroundSources = /* @__PURE__ */ new Set();
97351
+ #backgroundSources = /* @__PURE__ */ new Map();
97714
97352
  #idleWaiters = /* @__PURE__ */ new Set();
97715
97353
  // When work last started or stopped; the quiet period is measured from here.
97716
97354
  #changedAt = Date.now();
97717
97355
  #reserved = false;
97718
97356
  acceptsPrompts = () => !this.#reserved;
97719
97357
  count = () => this.#turns.size + this.#backgroundSources.size;
97720
- describe = () => ({
97721
- turns: this.#turns.size,
97722
- backgroundSources: this.#backgroundSources.size
97723
- });
97724
- setBackgroundActivity = (source, active) => {
97725
- if (active === this.#backgroundSources.has(source)) {
97358
+ /** Why admission is held: prompts running or queued, native tasks running, results not yet handled. */
97359
+ describe = () => {
97360
+ const activities = [...this.#backgroundSources.values()];
97361
+ return {
97362
+ turns: this.#turns.size,
97363
+ backgroundRunning: activities.filter((activity) => activity === "running").length,
97364
+ backgroundAwaitingResults: activities.filter((activity) => activity === "awaiting-results").length
97365
+ };
97366
+ };
97367
+ setBackgroundActivity = (source, activity) => {
97368
+ if (activity === (this.#backgroundSources.get(source) ?? "none")) {
97726
97369
  return;
97727
97370
  }
97728
- if (active) {
97729
- this.#backgroundSources.add(source);
97730
- } else {
97371
+ if (activity === "none") {
97731
97372
  this.#backgroundSources.delete(source);
97373
+ } else {
97374
+ this.#backgroundSources.set(source, activity);
97732
97375
  }
97733
97376
  this.#changed();
97734
97377
  };
@@ -98300,8 +97943,8 @@ function buildSessionLayer(options) {
98300
97943
  eventProjection.record(event);
98301
97944
  },
98302
97945
  sink.publishInfo,
98303
- (source, active) => {
98304
- options.turnActivity?.setBackgroundActivity(source, active);
97946
+ (source, activity) => {
97947
+ options.turnActivity?.setBackgroundActivity(source, activity);
98305
97948
  options.processes.notifyChanged();
98306
97949
  }
98307
97950
  ),
@@ -98391,8 +98034,8 @@ var init_session_layer = __esm({
98391
98034
  this.#publishInfo = publishInfo;
98392
98035
  this.#record = record2;
98393
98036
  }
98394
- onBackgroundActivity = (source, active) => {
98395
- this.#backgroundActivity(source, active);
98037
+ onBackgroundActivity = (source, activity) => {
98038
+ this.#backgroundActivity(source, activity);
98396
98039
  };
98397
98040
  onSessionEvent = (event) => {
98398
98041
  this.#record(event);
@@ -100027,7 +99670,7 @@ var init_content_write = __esm({
100027
99670
  });
100028
99671
 
100029
99672
  // src/session/content/session-files.ts
100030
- import { basename as basename9, extname as extname2, isAbsolute as isAbsolute18, join as join39, normalize as normalize3, resolve as resolve18 } from "node:path";
99673
+ import { basename as basename9, extname as extname3, isAbsolute as isAbsolute18, join as join39, normalize as normalize3, resolve as resolve18 } from "node:path";
100031
99674
  import { fileURLToPath as fileURLToPath2 } from "node:url";
100032
99675
  function requestedPath(value) {
100033
99676
  if (value.includes("\0")) {
@@ -100083,7 +99726,7 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
100083
99726
  send2({
100084
99727
  byteLength: before.size,
100085
99728
  kind: FILE_BEGIN_KIND,
100086
- mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
99729
+ mediaType: external?.mediaType ?? raster?.mimeType ?? (extname3(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
100087
99730
  modifiedAt: before.modifiedAt.toISOString(),
100088
99731
  name: external?.name ?? (basename9(target) || "file"),
100089
99732
  requestId: command.requestId,
@@ -102794,16 +102437,13 @@ async function checkDaemonReleaseUpgrade(signal, activity) {
102794
102437
  const launch = await installDaemonReleaseVersion(version2, signal);
102795
102438
  let reservation = activity.reserveIfQuiet(UPGRADE_QUIET_MILLISECONDS);
102796
102439
  if (reservation === null) {
102797
- new RuntimeDiagnosticLog(control.stateDirectory).record(
102798
- `Mobius daemon diagnostic ${JSON.stringify({
102799
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
102800
- event: "daemon_upgrade_deferred",
102801
- version: version2,
102802
- activeWork: activity.count(),
102803
- ...activity.describe()
102804
- })}`
102440
+ const diagnostics = new RuntimeDiagnosticLog(control.stateDirectory);
102441
+ const record2 = (event, details = {}) => diagnostics.record(
102442
+ `Mobius daemon diagnostic ${JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), event, version: version2, ...details })}`
102805
102443
  );
102444
+ record2("daemon_upgrade_deferred", { activeWork: activity.count(), ...activity.describe() });
102806
102445
  reservation = await reserveWhenQuiet(activity, signal);
102446
+ record2("daemon_upgrade_released");
102807
102447
  }
102808
102448
  const _reservation = __using(_stack, reservation);
102809
102449
  signal.throwIfAborted();