@moxt-ai/mobius 0.0.329 → 0.0.332

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 (91) hide show
  1. package/dist/acp/adapter/pi/agent-connection.d.ts.map +1 -1
  2. package/dist/acp/adapter/pi/agent-connection.js +5 -0
  3. package/dist/acp/adapter/pi/agent-connection.js.map +1 -1
  4. package/dist/acp/harness/pi/endpoint.d.ts +1 -0
  5. package/dist/acp/harness/pi/endpoint.d.ts.map +1 -1
  6. package/dist/acp/harness/pi/endpoint.js +1 -1
  7. package/dist/acp/harness/pi/endpoint.js.map +1 -1
  8. package/dist/cli.js +311 -349
  9. package/dist/cli.js.map +4 -4
  10. package/dist/daemon/control/local-client.d.ts +3 -2
  11. package/dist/daemon/control/local-client.d.ts.map +1 -1
  12. package/dist/daemon/control/local-client.js.map +1 -1
  13. package/dist/daemon/control/local-server.d.ts +2 -1
  14. package/dist/daemon/control/local-server.d.ts.map +1 -1
  15. package/dist/daemon/control/local-server.js.map +1 -1
  16. package/dist/daemon/control/switch-status.d.ts +2 -1
  17. package/dist/daemon/control/switch-status.d.ts.map +1 -1
  18. package/dist/daemon/control/switch-status.js.map +1 -1
  19. package/dist/daemon/lifecycle/manager-client.d.ts +4 -3
  20. package/dist/daemon/lifecycle/manager-client.d.ts.map +1 -1
  21. package/dist/daemon/lifecycle/manager-client.js.map +1 -1
  22. package/dist/daemon/lifecycle/manager.d.ts +2 -1
  23. package/dist/daemon/lifecycle/manager.d.ts.map +1 -1
  24. package/dist/daemon/lifecycle/manager.js.map +1 -1
  25. package/dist/daemon/lifecycle/unhandled-rejection.d.ts +2 -1
  26. package/dist/daemon/lifecycle/unhandled-rejection.d.ts.map +1 -1
  27. package/dist/daemon/lifecycle/unhandled-rejection.js.map +1 -1
  28. package/dist/daemon/lifecycle/worker-lifecycle-log.d.ts +2 -1
  29. package/dist/daemon/lifecycle/worker-lifecycle-log.d.ts.map +1 -1
  30. package/dist/daemon/lifecycle/worker-lifecycle-log.js.map +1 -1
  31. package/dist/daemon/lifecycle/worker.d.ts +2 -1
  32. package/dist/daemon/lifecycle/worker.d.ts.map +1 -1
  33. package/dist/daemon/lifecycle/worker.js.map +1 -1
  34. package/dist/daemon/upgrades/data.d.ts +2 -1
  35. package/dist/daemon/upgrades/data.d.ts.map +1 -1
  36. package/dist/daemon/upgrades/data.js.map +1 -1
  37. package/dist/daemon/upgrades/upgrade.d.ts +3 -2
  38. package/dist/daemon/upgrades/upgrade.d.ts.map +1 -1
  39. package/dist/daemon/upgrades/upgrade.js.map +1 -1
  40. package/dist/runtime/command/registry/session.d.ts +1 -1
  41. package/dist/runtime/command/registry/session.d.ts.map +1 -1
  42. package/dist/runtime/command/registry/session.js +14 -3
  43. package/dist/runtime/command/registry/session.js.map +1 -1
  44. package/dist/runtime/connection/runtime-installation-store.d.ts +2 -1
  45. package/dist/runtime/connection/runtime-installation-store.d.ts.map +1 -1
  46. package/dist/runtime/connection/runtime-installation-store.js.map +1 -1
  47. package/dist/runtime.js +130 -172
  48. package/dist/runtime.js.map +3 -3
  49. package/dist/schema/acp-session-store/execution-receipt.d.ts.map +1 -1
  50. package/dist/schema/acp-session-store/execution-receipt.js +1 -0
  51. package/dist/schema/acp-session-store/execution-receipt.js.map +1 -1
  52. package/dist/session/manager/session-manager.d.ts +5 -5
  53. package/dist/session/manager/session-manager.d.ts.map +1 -1
  54. package/dist/session/manager/session-manager.js +10 -12
  55. package/dist/session/manager/session-manager.js.map +1 -1
  56. package/dist/session/prompt/apply-session-configuration.d.ts +0 -1
  57. package/dist/session/prompt/apply-session-configuration.d.ts.map +1 -1
  58. package/dist/session/prompt/apply-session-configuration.js +1 -1
  59. package/dist/session/prompt/apply-session-configuration.js.map +1 -1
  60. package/dist/session/prompt/execute-prompt.d.ts.map +1 -1
  61. package/dist/session/prompt/execute-prompt.js +10 -17
  62. package/dist/session/prompt/execute-prompt.js.map +1 -1
  63. package/dist/session/prompt/prompt-lifecycle.d.ts.map +1 -1
  64. package/dist/session/prompt/prompt-lifecycle.js +0 -1
  65. package/dist/session/prompt/prompt-lifecycle.js.map +1 -1
  66. package/dist/session/turn/execution-receipts.d.ts +1 -5
  67. package/dist/session/turn/execution-receipts.d.ts.map +1 -1
  68. package/dist/session/turn/execution-receipts.js +20 -75
  69. package/dist/session/turn/execution-receipts.js.map +1 -1
  70. package/dist/storage/daemon/control-token.d.ts +2 -1
  71. package/dist/storage/daemon/control-token.d.ts.map +1 -1
  72. package/dist/storage/daemon/control-token.js.map +1 -1
  73. package/dist/storage/daemon/manager-lock.d.ts +3 -2
  74. package/dist/storage/daemon/manager-lock.d.ts.map +1 -1
  75. package/dist/storage/daemon/manager-lock.js.map +1 -1
  76. package/dist/storage/daemon/version-data.d.ts +6 -5
  77. package/dist/storage/daemon/version-data.d.ts.map +1 -1
  78. package/dist/storage/daemon/version-data.js.map +1 -1
  79. package/dist/storage/installation/installation-files.d.ts +6 -1
  80. package/dist/storage/installation/installation-files.d.ts.map +1 -1
  81. package/dist/storage/installation/installation-files.js +3 -1
  82. package/dist/storage/installation/installation-files.js.map +1 -1
  83. package/dist/storage/session/execution-receipt-table.d.ts +3 -26
  84. package/dist/storage/session/execution-receipt-table.d.ts.map +1 -1
  85. package/dist/storage/session/execution-receipt-table.js +47 -36
  86. package/dist/storage/session/execution-receipt-table.js.map +1 -1
  87. package/dist/storage/state-directory.d.ts +9 -1
  88. package/dist/storage/state-directory.d.ts.map +1 -1
  89. package/dist/storage/state-directory.js +3 -4
  90. package/dist/storage/state-directory.js.map +1 -1
  91. 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.329",
2089
+ version: "0.0.332",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -5605,182 +5605,6 @@ var init_commander = __esm({
5605
5605
  }
5606
5606
  });
5607
5607
 
5608
- // src/util/node-error.ts
5609
- function isNodeError(error62, code) {
5610
- return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
5611
- }
5612
- var init_node_error = __esm({
5613
- "src/util/node-error.ts"() {
5614
- "use strict";
5615
- }
5616
- });
5617
-
5618
- // src/storage/state-root-layout.ts
5619
- var STATE_ROOT_LAYOUT, STATE_ROOT_ENTRY_NAMES;
5620
- var init_state_root_layout = __esm({
5621
- "src/storage/state-root-layout.ts"() {
5622
- "use strict";
5623
- STATE_ROOT_LAYOUT = Object.freeze({
5624
- /** Names the version whose data is current. */
5625
- currentData: "current-data.txt",
5626
- /** Applications' installations: `installations/<application>/<installation>`. */
5627
- installations: "installations",
5628
- /** Managed CLI releases: `npm/<version>`. */
5629
- releases: "npm",
5630
- /** Each CLI version's data: `versions/<version>`. */
5631
- versions: "versions"
5632
- });
5633
- STATE_ROOT_ENTRY_NAMES = new Set(Object.values(STATE_ROOT_LAYOUT));
5634
- }
5635
- });
5636
-
5637
- // src/storage/installation/installation-files.ts
5638
- import { createHash, randomUUID } from "node:crypto";
5639
- import { mkdir, open, readdir, rename, unlink, writeFile } from "node:fs/promises";
5640
- import { dirname, join } from "node:path";
5641
- function applicationDirectory(root, applicationId) {
5642
- return join(root, STATE_ROOT_LAYOUT.installations, applicationId);
5643
- }
5644
- function installationPointerPath(applicationDirectory2) {
5645
- return join(applicationDirectory2, "current.json");
5646
- }
5647
- function installationDirectory(applicationDirectory2, installationId2) {
5648
- return join(applicationDirectory2, installationId2);
5649
- }
5650
- function connectionDirectory(installationDirectory2) {
5651
- return join(installationDirectory2, "connections");
5652
- }
5653
- function connectionFilePath(connectionDirectory2, connectionId2) {
5654
- return join(connectionDirectory2, `${connectionId2}.json`);
5655
- }
5656
- function channelIndexFilePath(installationDirectory2, channelId) {
5657
- return join(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
5658
- }
5659
- async function readInstallationFile(path8) {
5660
- let handle;
5661
- try {
5662
- handle = await open(path8, "r");
5663
- } catch (cause) {
5664
- return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
5665
- }
5666
- try {
5667
- const metadata = await handle.stat();
5668
- if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
5669
- return { kind: "not-a-small-file" };
5670
- }
5671
- return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
5672
- } finally {
5673
- await handle.close();
5674
- }
5675
- }
5676
- async function writeInstallationFile(path8, text2, signal) {
5677
- signal.throwIfAborted();
5678
- const directory = dirname(path8);
5679
- const temporaryPath = join(directory, `.${randomUUID()}.tmp`);
5680
- try {
5681
- await mkdir(directory, { mode: 448, recursive: true });
5682
- signal.throwIfAborted();
5683
- await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
5684
- signal.throwIfAborted();
5685
- await rename(temporaryPath, path8);
5686
- } catch (cause) {
5687
- await unlink(temporaryPath).catch(() => void 0);
5688
- throw cause;
5689
- }
5690
- }
5691
- async function createInstallationFile(path8, text2) {
5692
- await writeFile(path8, text2, { flag: "wx", mode: 384 });
5693
- }
5694
- async function listInstallationFiles(directory) {
5695
- return await readdir(directory);
5696
- }
5697
- async function removeInstallationFile(path8) {
5698
- await unlink(path8);
5699
- }
5700
- var MAXIMUM_FILE_BYTES;
5701
- var init_installation_files = __esm({
5702
- "src/storage/installation/installation-files.ts"() {
5703
- "use strict";
5704
- init_node_error();
5705
- init_state_root_layout();
5706
- MAXIMUM_FILE_BYTES = 16 * 1024;
5707
- }
5708
- });
5709
-
5710
- // src/storage/state-directory.ts
5711
- import { homedir } from "node:os";
5712
- import { join as join2, resolve } from "node:path";
5713
- function readStateDirectory(environment = process.env) {
5714
- const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
5715
- if (configured !== void 0 && configured.length > 0) {
5716
- return resolve(configured);
5717
- }
5718
- return join2(homedir(), ".mobius");
5719
- }
5720
- var init_state_directory = __esm({
5721
- "src/storage/state-directory.ts"() {
5722
- "use strict";
5723
- }
5724
- });
5725
-
5726
- // src/storage/state-root.ts
5727
- import { readFile, stat } from "node:fs/promises";
5728
- import { basename, dirname as dirname2, join as join3 } from "node:path";
5729
- async function exists(path8) {
5730
- return await stat(path8).then(
5731
- () => true,
5732
- () => false
5733
- );
5734
- }
5735
- async function owningRoot(directory) {
5736
- const application = dirname2(directory);
5737
- const installations = dirname2(application);
5738
- if (basename(installations) !== STATE_ROOT_LAYOUT.installations) {
5739
- return null;
5740
- }
5741
- let pointer;
5742
- try {
5743
- pointer = JSON.parse(await readFile(installationPointerPath(application), "utf8"));
5744
- } catch {
5745
- return null;
5746
- }
5747
- if (typeof pointer !== "object" || pointer === null || !("installationId" in pointer) || pointer.installationId !== basename(directory)) {
5748
- return null;
5749
- }
5750
- const container = dirname2(installations);
5751
- return basename(dirname2(container)) === STATE_ROOT_LAYOUT.versions ? dirname2(dirname2(container)) : container;
5752
- }
5753
- async function validateStateRoot(environment) {
5754
- const directory = readStateDirectory(environment);
5755
- if (await exists(join3(directory, STATE_ROOT_LAYOUT.currentData)) || await exists(join3(directory, STATE_ROOT_LAYOUT.versions))) {
5756
- return;
5757
- }
5758
- const root = await owningRoot(directory);
5759
- if (root !== null) {
5760
- throw new StateRootError(directory, root);
5761
- }
5762
- }
5763
- var StateRootError;
5764
- var init_state_root = __esm({
5765
- "src/storage/state-root.ts"() {
5766
- "use strict";
5767
- init_installation_files();
5768
- init_state_directory();
5769
- init_state_root_layout();
5770
- StateRootError = class extends Error {
5771
- code = "state_root_is_installation_data";
5772
- owningRoot;
5773
- constructor(stateDirectory, owningRoot2) {
5774
- super(
5775
- `MOBIUS_STATE_DIRECTORY (${stateDirectory}) is Mobius installation data, not a state root. Use the state root that owns it: MOBIUS_STATE_DIRECTORY=${owningRoot2}`
5776
- );
5777
- this.name = "StateRootError";
5778
- this.owningRoot = owningRoot2;
5779
- }
5780
- };
5781
- }
5782
- });
5783
-
5784
5608
  // ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
5785
5609
  var util_exports = {};
5786
5610
  __export(util_exports, {
@@ -10432,7 +10256,7 @@ function isBackEdge(ctx, value) {
10432
10256
  const backEdges = ctx[STATE]?.backEdges;
10433
10257
  return backEdges !== void 0 && isRef(value) && backEdges.has(value);
10434
10258
  }
10435
- var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open2, memo;
10259
+ var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open, memo;
10436
10260
  var init_memoizer = __esm({
10437
10261
  "../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js"() {
10438
10262
  init_util();
@@ -10448,7 +10272,7 @@ var init_memoizer = __esm({
10448
10272
  NONE = 0;
10449
10273
  ASSUMED = 1;
10450
10274
  PROVEN = 2;
10451
- open2 = [];
10275
+ open = [];
10452
10276
  memo = {
10453
10277
  alloc(_inst, payload, empty) {
10454
10278
  const bucket = handoff;
@@ -10457,7 +10281,7 @@ var init_memoizer = __esm({
10457
10281
  handoff = void 0;
10458
10282
  const entry = { value: empty, issues: null };
10459
10283
  bucket.set(payload.value, entry);
10460
- open2.push(entry);
10284
+ open.push(entry);
10461
10285
  return empty;
10462
10286
  },
10463
10287
  guard(inst) {
@@ -10528,10 +10352,10 @@ var init_memoizer = __esm({
10528
10352
  return payload;
10529
10353
  }
10530
10354
  handoff = bucket;
10531
- const depth = open2.length;
10355
+ const depth = open.length;
10532
10356
  const result = base(payload, ctx);
10533
10357
  handoff = void 0;
10534
- const entry = open2.length > depth ? open2.pop() : void 0;
10358
+ const entry = open.length > depth ? open.pop() : void 0;
10535
10359
  if (result instanceof Promise) {
10536
10360
  return result.then((r) => {
10537
10361
  if (entry)
@@ -26140,6 +25964,186 @@ var init_zod = __esm({
26140
25964
  }
26141
25965
  });
26142
25966
 
25967
+ // src/util/node-error.ts
25968
+ function isNodeError(error62, code) {
25969
+ return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
25970
+ }
25971
+ var init_node_error = __esm({
25972
+ "src/util/node-error.ts"() {
25973
+ "use strict";
25974
+ }
25975
+ });
25976
+
25977
+ // src/storage/state-root-layout.ts
25978
+ var STATE_ROOT_LAYOUT, STATE_ROOT_ENTRY_NAMES;
25979
+ var init_state_root_layout = __esm({
25980
+ "src/storage/state-root-layout.ts"() {
25981
+ "use strict";
25982
+ STATE_ROOT_LAYOUT = Object.freeze({
25983
+ /** Names the version whose data is current. */
25984
+ currentData: "current-data.txt",
25985
+ /** Applications' installations: `installations/<application>/<installation>`. */
25986
+ installations: "installations",
25987
+ /** Managed CLI releases: `npm/<version>`. */
25988
+ releases: "npm",
25989
+ /** Each CLI version's data: `versions/<version>`. */
25990
+ versions: "versions"
25991
+ });
25992
+ STATE_ROOT_ENTRY_NAMES = new Set(Object.values(STATE_ROOT_LAYOUT));
25993
+ }
25994
+ });
25995
+
25996
+ // src/storage/installation/installation-files.ts
25997
+ import { createHash, randomUUID } from "node:crypto";
25998
+ import { mkdir, open as open2, readdir, rename, unlink, writeFile } from "node:fs/promises";
25999
+ import { dirname, join } from "node:path";
26000
+ function applicationDirectory(root, applicationId) {
26001
+ return join(root, STATE_ROOT_LAYOUT.installations, applicationId);
26002
+ }
26003
+ function installationPointerPath(applicationDirectory2) {
26004
+ return join(applicationDirectory2, "current.json");
26005
+ }
26006
+ function installationDirectory(applicationDirectory2, installationId2) {
26007
+ return installationDirectorySchema.parse(join(applicationDirectory2, installationId2));
26008
+ }
26009
+ function connectionDirectory(installationDirectory2) {
26010
+ return join(installationDirectory2, "connections");
26011
+ }
26012
+ function connectionFilePath(connectionDirectory2, connectionId2) {
26013
+ return join(connectionDirectory2, `${connectionId2}.json`);
26014
+ }
26015
+ function channelIndexFilePath(installationDirectory2, channelId) {
26016
+ return join(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
26017
+ }
26018
+ async function readInstallationFile(path8) {
26019
+ let handle;
26020
+ try {
26021
+ handle = await open2(path8, "r");
26022
+ } catch (cause) {
26023
+ return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
26024
+ }
26025
+ try {
26026
+ const metadata = await handle.stat();
26027
+ if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
26028
+ return { kind: "not-a-small-file" };
26029
+ }
26030
+ return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
26031
+ } finally {
26032
+ await handle.close();
26033
+ }
26034
+ }
26035
+ async function writeInstallationFile(path8, text2, signal) {
26036
+ signal.throwIfAborted();
26037
+ const directory = dirname(path8);
26038
+ const temporaryPath = join(directory, `.${randomUUID()}.tmp`);
26039
+ try {
26040
+ await mkdir(directory, { mode: 448, recursive: true });
26041
+ signal.throwIfAborted();
26042
+ await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
26043
+ signal.throwIfAborted();
26044
+ await rename(temporaryPath, path8);
26045
+ } catch (cause) {
26046
+ await unlink(temporaryPath).catch(() => void 0);
26047
+ throw cause;
26048
+ }
26049
+ }
26050
+ async function createInstallationFile(path8, text2) {
26051
+ await writeFile(path8, text2, { flag: "wx", mode: 384 });
26052
+ }
26053
+ async function listInstallationFiles(directory) {
26054
+ return await readdir(directory);
26055
+ }
26056
+ async function removeInstallationFile(path8) {
26057
+ await unlink(path8);
26058
+ }
26059
+ var MAXIMUM_FILE_BYTES, installationDirectorySchema;
26060
+ var init_installation_files = __esm({
26061
+ "src/storage/installation/installation-files.ts"() {
26062
+ "use strict";
26063
+ init_zod();
26064
+ init_node_error();
26065
+ init_state_root_layout();
26066
+ MAXIMUM_FILE_BYTES = 16 * 1024;
26067
+ installationDirectorySchema = external_exports.string().brand();
26068
+ }
26069
+ });
26070
+
26071
+ // src/storage/state-directory.ts
26072
+ import { homedir } from "node:os";
26073
+ import { join as join2, resolve } from "node:path";
26074
+ function readStateDirectory(environment = process.env) {
26075
+ const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
26076
+ return stateRootSchema.parse(
26077
+ configured !== void 0 && configured.length > 0 ? resolve(configured) : join2(homedir(), ".mobius")
26078
+ );
26079
+ }
26080
+ var stateRootSchema;
26081
+ var init_state_directory = __esm({
26082
+ "src/storage/state-directory.ts"() {
26083
+ "use strict";
26084
+ init_zod();
26085
+ stateRootSchema = external_exports.string().brand();
26086
+ }
26087
+ });
26088
+
26089
+ // src/storage/state-root.ts
26090
+ import { readFile, stat } from "node:fs/promises";
26091
+ import { basename, dirname as dirname2, join as join3 } from "node:path";
26092
+ async function exists(path8) {
26093
+ return await stat(path8).then(
26094
+ () => true,
26095
+ () => false
26096
+ );
26097
+ }
26098
+ async function owningRoot(directory) {
26099
+ const application = dirname2(directory);
26100
+ const installations = dirname2(application);
26101
+ if (basename(installations) !== STATE_ROOT_LAYOUT.installations) {
26102
+ return null;
26103
+ }
26104
+ let pointer;
26105
+ try {
26106
+ pointer = JSON.parse(await readFile(installationPointerPath(application), "utf8"));
26107
+ } catch {
26108
+ return null;
26109
+ }
26110
+ if (typeof pointer !== "object" || pointer === null || !("installationId" in pointer) || pointer.installationId !== basename(directory)) {
26111
+ return null;
26112
+ }
26113
+ const container = dirname2(installations);
26114
+ return basename(dirname2(container)) === STATE_ROOT_LAYOUT.versions ? dirname2(dirname2(container)) : container;
26115
+ }
26116
+ async function validateStateRoot(environment) {
26117
+ const directory = readStateDirectory(environment);
26118
+ if (await exists(join3(directory, STATE_ROOT_LAYOUT.currentData)) || await exists(join3(directory, STATE_ROOT_LAYOUT.versions))) {
26119
+ return;
26120
+ }
26121
+ const root = await owningRoot(directory);
26122
+ if (root !== null) {
26123
+ throw new StateRootError(directory, root);
26124
+ }
26125
+ }
26126
+ var StateRootError;
26127
+ var init_state_root = __esm({
26128
+ "src/storage/state-root.ts"() {
26129
+ "use strict";
26130
+ init_installation_files();
26131
+ init_state_directory();
26132
+ init_state_root_layout();
26133
+ StateRootError = class extends Error {
26134
+ code = "state_root_is_installation_data";
26135
+ owningRoot;
26136
+ constructor(stateDirectory, owningRoot2) {
26137
+ super(
26138
+ `MOBIUS_STATE_DIRECTORY (${stateDirectory}) is Mobius installation data, not a state root. Use the state root that owns it: MOBIUS_STATE_DIRECTORY=${owningRoot2}`
26139
+ );
26140
+ this.name = "StateRootError";
26141
+ this.owningRoot = owningRoot2;
26142
+ }
26143
+ };
26144
+ }
26145
+ });
26146
+
26143
26147
  // src/util/value-utils.ts
26144
26148
  function truncate(value, maximumLength) {
26145
26149
  return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
@@ -80382,6 +80386,7 @@ var init_agent2 = __esm({
80382
80386
  }
80383
80387
  async promptSubmission(params, submission) {
80384
80388
  const session = await this.restoreSession(params.sessionId);
80389
+ this.conn.startUserMessage();
80385
80390
  for (const content of params.prompt) {
80386
80391
  if (submission.aborted) {
80387
80392
  return { stopReason: "cancelled" };
@@ -80841,6 +80846,7 @@ ${JSON.stringify(stats, null, 2)}`;
80841
80846
  case "idle":
80842
80847
  return { outcome: "promptRequired", reason: "noRunningTurn" };
80843
80848
  case "injected": {
80849
+ this.conn.startUserMessage();
80844
80850
  for (const content of parsed.data.prompt) {
80845
80851
  signal.throwIfAborted();
80846
80852
  await this.conn.sessionUpdate({
@@ -81235,11 +81241,12 @@ ${JSON.stringify(stats, null, 2)}`;
81235
81241
 
81236
81242
  // src/acp/harness/pi/upstream/dist/acp/client.js
81237
81243
  import { methods as methods5 } from "@agentclientprotocol/sdk";
81238
- function createPiAcpClient(connection, onSessionUpdate) {
81244
+ function createPiAcpClient(connection, onSessionUpdate, onUserMessageStart = () => void 0) {
81239
81245
  return {
81240
81246
  requestElicitation: async (request, signal) => await connection.client.request(methods5.client.elicitation.create, request, { cancellationSignal: signal }),
81241
81247
  requestPermission: async (request) => await connection.client.request(methods5.client.session.requestPermission, request),
81242
- sessionUpdate: onSessionUpdate
81248
+ sessionUpdate: onSessionUpdate,
81249
+ startUserMessage: onUserMessageStart
81243
81250
  };
81244
81251
  }
81245
81252
  var init_client = __esm({
@@ -81284,7 +81291,10 @@ var init_endpoint2 = __esm({
81284
81291
  let piAgent = null;
81285
81292
  this.#app = createAgentApp2({ name: "mobius-pi" }).onConnect((connection) => {
81286
81293
  this.#connection = connection;
81287
- piAgent = new PiAcpAgent(createPiAcpClient(connection, options.onSessionUpdate), { environment });
81294
+ piAgent = new PiAcpAgent(
81295
+ createPiAcpClient(connection, options.onSessionUpdate, options.onUserMessageStart),
81296
+ { environment }
81297
+ );
81288
81298
  this.#agent = piAgent;
81289
81299
  }).onRequest(
81290
81300
  methods6.agent.initialize,
@@ -81371,6 +81381,11 @@ var init_agent_connection3 = __esm({
81371
81381
  command: options.command,
81372
81382
  cwd: options.cwd,
81373
81383
  environment: options.environment,
81384
+ // Raw Pi owns submission boundaries, while synthetic identity stays here.
81385
+ // Adjacent blocks within one submission still share the allocated ID.
81386
+ onUserMessageStart: () => {
81387
+ message = { kind: "none" };
81388
+ },
81374
81389
  onSessionUpdate: async (notification) => {
81375
81390
  const update = notification.update;
81376
81391
  switch (update.sessionUpdate) {
@@ -93672,6 +93687,7 @@ var init_execution_receipt = __esm({
93672
93687
  sessionId: text("session_id").notNull(),
93673
93688
  commandHash: text("command_hash").notNull(),
93674
93689
  attemptId: text("attempt_id").notNull(),
93690
+ // Compatibility projection for older Runtimes; started and outcome own the facts.
93675
93691
  state: text("state").notNull(),
93676
93692
  started: integer2("started", { mode: "boolean" }).notNull(),
93677
93693
  outcome: text("outcome"),
@@ -93749,29 +93765,30 @@ var init_acp_session_table = __esm({
93749
93765
  });
93750
93766
 
93751
93767
  // src/storage/session/execution-receipt-table.ts
93752
- var receiptFields, receiptSchema, identitySchema, ExecutionReceiptTable;
93768
+ function legacyState(receipt) {
93769
+ if (receipt.outcome === null) {
93770
+ return receipt.started ? "running" : "dispatching";
93771
+ }
93772
+ const event = sessionEventPayloadSchema.parse(JSON.parse(receipt.outcome));
93773
+ return event.type === "lifecycle-metadata" && event.payload.kind === "prompt.completed" ? event.payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed";
93774
+ }
93775
+ var receiptSchema, identitySchema, ExecutionReceiptTable;
93753
93776
  var init_execution_receipt_table = __esm({
93754
93777
  "src/storage/session/execution-receipt-table.ts"() {
93755
93778
  "use strict";
93779
+ init_protocol();
93756
93780
  init_drizzle_orm();
93757
93781
  init_zod();
93758
93782
  init_acp_session_store();
93759
- receiptFields = external_exports.object({
93783
+ receiptSchema = external_exports.object({
93760
93784
  commandId: external_exports.string(),
93761
93785
  sessionId: external_exports.string(),
93762
93786
  commandHash: external_exports.string(),
93763
93787
  attemptId: external_exports.string(),
93764
- updatedAt: external_exports.string()
93765
- });
93766
- receiptSchema = external_exports.discriminatedUnion("state", [
93767
- receiptFields.extend({ state: external_exports.literal("dispatching"), started: external_exports.literal(false), outcome: external_exports.null() }),
93768
- receiptFields.extend({ state: external_exports.literal("running"), started: external_exports.literal(true), outcome: external_exports.string().nullable() }),
93769
- receiptFields.extend({
93770
- state: external_exports.enum(["succeeded", "failed", "cancelled"]),
93771
- started: external_exports.boolean(),
93772
- outcome: external_exports.string().nullable()
93773
- })
93774
- ]).readonly();
93788
+ updatedAt: external_exports.string(),
93789
+ started: external_exports.boolean(),
93790
+ outcome: external_exports.string().nullable()
93791
+ }).readonly();
93775
93792
  identitySchema = external_exports.object({ sessionId: external_exports.string(), commandHash: external_exports.string() }).readonly();
93776
93793
  ExecutionReceiptTable = class {
93777
93794
  #database;
@@ -93785,32 +93802,27 @@ var init_execution_receipt_table = __esm({
93785
93802
  list = () => receiptSchema.array().parse(
93786
93803
  this.#database.orm.select().from(executionReceipt).orderBy(asc(executionReceipt.updatedAt), asc(executionReceipt.commandId)).all()
93787
93804
  );
93788
- save = (receipt) => {
93789
- this.#database.transaction(() => {
93790
- this.#database.orm.insert(executionReceipt).values(receipt).onConflictDoUpdate({ target: executionReceipt.commandId, set: receipt }).run();
93791
- if (receipt.state === "dispatching" || receipt.state === "running") {
93792
- return;
93793
- }
93794
- const retained = this.#database.orm.select({ commandId: executionReceipt.commandId }).from(executionReceipt).where(
93805
+ save = (receipt, terminalLimit) => this.#database.transaction(() => {
93806
+ const row = { ...receipt, state: legacyState(receipt) };
93807
+ this.#database.orm.insert(executionReceipt).values(row).onConflictDoUpdate({ target: executionReceipt.commandId, set: row }).run();
93808
+ if (receipt.outcome === null) {
93809
+ return [];
93810
+ }
93811
+ const retained = this.#database.orm.select({ commandId: executionReceipt.commandId }).from(executionReceipt).where(and(eq2(executionReceipt.sessionId, receipt.sessionId), isNotNull(executionReceipt.outcome))).orderBy(desc(executionReceipt.updatedAt), desc(executionReceipt.commandId)).limit(terminalLimit).all();
93812
+ if (retained.length === terminalLimit) {
93813
+ return this.#remove(
93795
93814
  and(
93796
93815
  eq2(executionReceipt.sessionId, receipt.sessionId),
93797
- inArray(executionReceipt.state, ["succeeded", "failed", "cancelled"])
93798
- )
93799
- ).orderBy(desc(executionReceipt.updatedAt), desc(executionReceipt.commandId)).limit(1024).all();
93800
- if (retained.length === 1024) {
93801
- this.#remove(
93802
- and(
93803
- eq2(executionReceipt.sessionId, receipt.sessionId),
93804
- inArray(executionReceipt.state, ["succeeded", "failed", "cancelled"]),
93805
- notInArray(
93806
- executionReceipt.commandId,
93807
- retained.map((row) => row.commandId)
93808
- )
93816
+ isNotNull(executionReceipt.outcome),
93817
+ notInArray(
93818
+ executionReceipt.commandId,
93819
+ retained.map((row2) => row2.commandId)
93809
93820
  )
93810
- );
93811
- }
93812
- });
93813
- };
93821
+ )
93822
+ );
93823
+ }
93824
+ return [];
93825
+ });
93814
93826
  remove = (commandId) => {
93815
93827
  this.#database.transaction(() => this.#remove(eq2(executionReceipt.commandId, commandId)));
93816
93828
  };
@@ -93825,7 +93837,7 @@ var init_execution_receipt_table = __esm({
93825
93837
  commandHash: executionReceipt.commandHash
93826
93838
  }).from(executionReceipt).where(and(condition, eq2(executionReceipt.started, true)))
93827
93839
  ).onConflictDoNothing().run();
93828
- this.#database.orm.delete(executionReceipt).where(condition).run();
93840
+ return this.#database.orm.delete(executionReceipt).where(condition).returning({ commandId: executionReceipt.commandId }).all().map((row) => row.commandId);
93829
93841
  };
93830
93842
  };
93831
93843
  }
@@ -96256,34 +96268,18 @@ var init_session_manager = __esm({
96256
96268
  return await runtime.configure(options2);
96257
96269
  });
96258
96270
  });
96259
- renameSession = async (sessionId, title2, signal) => await this.#executionProcesses.use(
96260
- sessionId,
96261
- async () => this.#operations.run({ sessionId, signal }, async (options) => {
96262
- this.#assertOpen(options.sessionId);
96263
- const runtime = this.#executionProcesses.get(options.sessionId);
96264
- if (runtime !== void 0) {
96265
- return await runtime.renameSession(title2, options.signal);
96266
- }
96267
- const stored = this.#store.read(options.sessionId);
96268
- if (!(stored instanceof FoundStoredSession)) {
96269
- throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
96270
- }
96271
- const normalized = title2.slice(0, 500);
96272
- const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
96273
- this.#store.write(
96274
- new StoredSession(
96275
- stored.session.sessionId,
96276
- stored.session.agentId,
96277
- stored.session.nativeSessionId,
96278
- stored.session.cwd,
96279
- stored.session.additionalDirectories,
96280
- stored.session.prompted,
96281
- normalized,
96282
- updatedAt,
96283
- stored.session.configurations
96284
- )
96285
- );
96286
- return { title: normalized, updatedAt };
96271
+ renameSession = async (options, title2) => await this.#executionProcesses.use(
96272
+ options.sessionId,
96273
+ async () => this.#operations.run(options, async (options2) => {
96274
+ this.#assertOpen(options2.sessionId);
96275
+ if (this.#executionProcesses.get(options2.sessionId) === void 0) {
96276
+ await this.#prepareSession(options2, { kind: "interactive-only" }, "keep-closed");
96277
+ }
96278
+ const runtime = this.#executionProcesses.get(options2.sessionId);
96279
+ if (runtime === void 0) {
96280
+ throw new AcpExecutionError("ACP session did not start");
96281
+ }
96282
+ return await runtime.renameSession(title2, options2.signal);
96287
96283
  })
96288
96284
  );
96289
96285
  cancelPrompt = async (sessionId, signal = AbortSignal.timeout(3e4)) => this.#operations.run({ signal }, async ({ signal: signal2 }) => {
@@ -97070,7 +97066,6 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
97070
97066
  "agent_execution_abandoned",
97071
97067
  "The local Agent execution was abandoned before it completed"
97072
97068
  );
97073
- operations.transitionExecution(cancellation.commandId, "failed");
97074
97069
  projection.publishTerminal(cancellation.sessionId, cancellation.commandId);
97075
97070
  }
97076
97071
  var PromptLifecycle;
@@ -97217,9 +97212,6 @@ var init_prompt_lifecycle = __esm({
97217
97212
 
97218
97213
  // src/session/turn/execution-receipts.ts
97219
97214
  import { createHash as createHash7, randomUUID as randomUUID16 } from "node:crypto";
97220
- function isTerminal(state) {
97221
- return state === "succeeded" || state === "failed" || state === "cancelled";
97222
- }
97223
97215
  var MAX_TERMINAL_RECEIPTS, ExecutionReceipts;
97224
97216
  var init_execution_receipts = __esm({
97225
97217
  "src/session/turn/execution-receipts.ts"() {
@@ -97230,7 +97222,6 @@ var init_execution_receipts = __esm({
97230
97222
  ExecutionReceipts = class {
97231
97223
  #executions = /* @__PURE__ */ new Map();
97232
97224
  #recoveredCommands = /* @__PURE__ */ new Set();
97233
- #terminalCountBySession = /* @__PURE__ */ new Map();
97234
97225
  #table;
97235
97226
  #closing = false;
97236
97227
  #activeCount = 0;
@@ -97241,36 +97232,22 @@ var init_execution_receipts = __esm({
97241
97232
  for (const row of table.list()) {
97242
97233
  this.#executions.set(row.commandId, row);
97243
97234
  this.#recoveredCommands.add(row.commandId);
97244
- if (!isTerminal(row.state)) {
97235
+ if (row.outcome === null) {
97245
97236
  this.#activeCount += 1;
97246
97237
  }
97247
- if (isTerminal(row.state)) {
97248
- this.#terminalCountBySession.set(
97249
- row.sessionId,
97250
- (this.#terminalCountBySession.get(row.sessionId) ?? 0) + 1
97251
- );
97252
- }
97253
97238
  }
97254
97239
  }
97255
97240
  #save = (commandId, receipt) => {
97256
- if (!this.#closing) {
97257
- this.#table.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
97258
- }
97241
+ const evicted = this.#closing ? [] : this.#table.save({ ...receipt, commandId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, MAX_TERMINAL_RECEIPTS);
97259
97242
  const previous = this.#executions.get(commandId);
97260
- const wasActive = previous !== void 0 && !isTerminal(previous.state);
97261
- if (isTerminal(receipt.state)) {
97262
- this.#executions.delete(commandId);
97263
- }
97243
+ const wasActive = previous?.outcome === null;
97264
97244
  this.#executions.set(commandId, receipt);
97265
- this.#activeCount += Number(!isTerminal(receipt.state)) - Number(wasActive);
97266
- this.#onCount(this.#activeCount);
97267
- if (isTerminal(receipt.state) && (previous === void 0 || !isTerminal(previous.state))) {
97268
- this.#terminalCountBySession.set(
97269
- receipt.sessionId,
97270
- (this.#terminalCountBySession.get(receipt.sessionId) ?? 0) + 1
97271
- );
97272
- this.pruneTerminalReceipts(receipt.sessionId);
97245
+ for (const evictedCommandId of evicted) {
97246
+ this.#executions.delete(evictedCommandId);
97247
+ this.#recoveredCommands.delete(evictedCommandId);
97273
97248
  }
97249
+ this.#activeCount += Number(receipt.outcome === null) - Number(wasActive);
97250
+ this.#onCount(this.#activeCount);
97274
97251
  };
97275
97252
  beginShutdown = () => {
97276
97253
  this.#closing = true;
@@ -97283,7 +97260,7 @@ var init_execution_receipts = __esm({
97283
97260
  recordCancellationBeforeAdmission = (commandId, sessionId) => {
97284
97261
  const existing = this.#executions.get(commandId);
97285
97262
  if (existing !== void 0) {
97286
- return existing.sessionId === sessionId && isTerminal(existing.state) ? this.outcome(commandId) : void 0;
97263
+ return existing.sessionId === sessionId ? this.outcome(commandId) : void 0;
97287
97264
  }
97288
97265
  const outcome = {
97289
97266
  type: "lifecycle-metadata",
@@ -97300,7 +97277,6 @@ var init_execution_receipts = __esm({
97300
97277
  attemptId: randomUUID16(),
97301
97278
  commandHash,
97302
97279
  sessionId,
97303
- state: "cancelled",
97304
97280
  started: false,
97305
97281
  outcome: JSON.stringify({ ...outcome, recordedAt: (/* @__PURE__ */ new Date()).toISOString() })
97306
97282
  });
@@ -97321,7 +97297,6 @@ var init_execution_receipts = __esm({
97321
97297
  const sanitized = payload.kind === "prompt.completed" ? payload : { ...payload, message: "The local Agent could not complete the request" };
97322
97298
  this.#save(payload.commandId, {
97323
97299
  ...receipt,
97324
- state: payload.kind === "prompt.completed" ? payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed",
97325
97300
  outcome: JSON.stringify({ type: "lifecycle-metadata", payload: sanitized, recordedAt: event.recordedAt })
97326
97301
  });
97327
97302
  };
@@ -97345,9 +97320,8 @@ var init_execution_receipts = __esm({
97345
97320
  } : sessionEventPayloadSchema.parse(JSON.parse(receipt.outcome));
97346
97321
  const recordedAt = receipt.outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(receipt.outcome)).recordedAt;
97347
97322
  recovered.push({ sessionId: receipt.sessionId, event, recordedAt });
97348
- if (!isTerminal(receipt.state)) {
97349
- const state = event.type === "lifecycle-metadata" && event.payload.kind === "prompt.completed" ? event.payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed";
97350
- this.#save(commandId, { ...receipt, state, outcome: JSON.stringify({ ...event, recordedAt }) });
97323
+ if (receipt.outcome === null) {
97324
+ this.#save(commandId, { ...receipt, outcome: JSON.stringify({ ...event, recordedAt }) });
97351
97325
  }
97352
97326
  }
97353
97327
  return recovered;
@@ -97360,10 +97334,6 @@ var init_execution_receipts = __esm({
97360
97334
  this.#table.remove(commandId);
97361
97335
  this.#executions.delete(commandId);
97362
97336
  this.#recoveredCommands.delete(commandId);
97363
- this.#terminalCountBySession.set(
97364
- sessionId,
97365
- Math.max(0, (this.#terminalCountBySession.get(sessionId) ?? 1) - 1)
97366
- );
97367
97337
  existing = void 0;
97368
97338
  }
97369
97339
  if (existing !== void 0) {
@@ -97374,7 +97344,6 @@ var init_execution_receipts = __esm({
97374
97344
  attemptId: existing.attemptId,
97375
97345
  commandId,
97376
97346
  kind: "duplicate",
97377
- state: existing.state,
97378
97347
  outcome: this.#recoveredCommands.has(commandId) ? this.outcome(commandId) : void 0
97379
97348
  };
97380
97349
  }
@@ -97387,66 +97356,37 @@ var init_execution_receipts = __esm({
97387
97356
  attemptId,
97388
97357
  commandHash,
97389
97358
  sessionId,
97390
- state: "dispatching",
97391
97359
  started: false,
97392
97360
  outcome: null
97393
97361
  });
97394
- return { attemptId, commandId, kind: "accepted", state: "dispatching" };
97362
+ return { attemptId, commandId, kind: "accepted" };
97395
97363
  };
97396
- transitionExecution = (commandId, state) => {
97364
+ markExecutionStarted = (commandId) => {
97397
97365
  const current = this.#executions.get(commandId);
97398
97366
  if (current === void 0) {
97399
97367
  throw new Error("The runtime execution receipt does not exist");
97400
97368
  }
97401
- if (current.state === state) {
97402
- return;
97403
- }
97404
- const allowed = current.state === "dispatching" && (state === "running" || state === "failed" || state === "cancelled") || current.state === "running" && isTerminal(state);
97405
- if (!allowed) {
97369
+ if (current.outcome !== null) {
97406
97370
  throw new Error("The runtime execution transition is invalid");
97407
97371
  }
97408
- if (state === "running") {
97409
- this.#save(commandId, { ...current, state, started: true });
97410
- } else if (isTerminal(state)) {
97411
- this.#save(commandId, { ...current, state });
97372
+ if (!current.started) {
97373
+ this.#save(commandId, { ...current, started: true });
97412
97374
  }
97413
97375
  };
97414
97376
  /** Only commands without a terminal result can still be cancelled. */
97415
97377
  findUnsettledAttemptId = (commandId, sessionId) => {
97416
97378
  const receipt = this.#executions.get(commandId);
97417
- return receipt?.sessionId === sessionId && !isTerminal(receipt.state) ? receipt.attemptId : null;
97379
+ return receipt?.sessionId === sessionId && receipt.outcome === null ? receipt.attemptId : null;
97418
97380
  };
97419
97381
  isTerminalExecution = (commandId, sessionId) => {
97420
97382
  const receipt = this.#executions.get(commandId);
97421
- return receipt?.sessionId === sessionId && isTerminal(receipt.state);
97383
+ return receipt?.sessionId === sessionId && receipt.outcome !== null;
97422
97384
  };
97423
97385
  close = () => {
97424
97386
  this.#executions.clear();
97425
97387
  this.#recoveredCommands.clear();
97426
- this.#terminalCountBySession.clear();
97427
97388
  this.#activeCount = 0;
97428
97389
  };
97429
- pruneTerminalReceipts = (sessionId) => {
97430
- if ((this.#terminalCountBySession.get(sessionId) ?? 0) <= MAX_TERMINAL_RECEIPTS) {
97431
- return;
97432
- }
97433
- for (const [commandId, receipt] of this.#executions) {
97434
- if (receipt.sessionId === sessionId && isTerminal(receipt.state)) {
97435
- this.#table.remove(commandId);
97436
- this.#executions.delete(commandId);
97437
- this.#recoveredCommands.delete(commandId);
97438
- const remaining = (this.#terminalCountBySession.get(sessionId) ?? 1) - 1;
97439
- if (remaining > 0) {
97440
- this.#terminalCountBySession.set(sessionId, remaining);
97441
- } else {
97442
- this.#terminalCountBySession.delete(sessionId);
97443
- }
97444
- if ((this.#terminalCountBySession.get(sessionId) ?? 0) <= MAX_TERMINAL_RECEIPTS) {
97445
- return;
97446
- }
97447
- }
97448
- }
97449
- };
97450
97390
  };
97451
97391
  }
97452
97392
  });
@@ -100722,26 +100662,22 @@ async function executePrompt({
100722
100662
  recovery
100723
100663
  };
100724
100664
  let prepared = await sessions.prepareExecutionSession(preparation);
100725
- if (command.sessionConfigurations !== void 0) {
100726
- if (availability.disposition === SessionPromptDisposition.Steer) {
100727
- assertAppliedSessionConfiguration(prepared.configOptions, sessionConfigurations ?? []);
100728
- } else {
100729
- await applyCompleteSessionConfiguration(
100730
- sessions,
100731
- prepared.configOptions,
100732
- sessionConfigurations ?? [],
100733
- executionAgent,
100734
- adapter,
100735
- resolved.cwd,
100736
- resolved.additionalDirectories,
100737
- command.commandId,
100738
- command.sessionId,
100739
- signal
100740
- );
100741
- prepared = await sessions.prepareExecutionSession(preparation);
100742
- }
100665
+ if (command.sessionConfigurations !== void 0 && availability.disposition !== SessionPromptDisposition.Steer) {
100666
+ await applyCompleteSessionConfiguration(
100667
+ sessions,
100668
+ prepared.configOptions,
100669
+ sessionConfigurations ?? [],
100670
+ executionAgent,
100671
+ adapter,
100672
+ resolved.cwd,
100673
+ resolved.additionalDirectories,
100674
+ command.commandId,
100675
+ command.sessionId,
100676
+ signal
100677
+ );
100678
+ prepared = await sessions.prepareExecutionSession(preparation);
100743
100679
  }
100744
- operations.transitionExecution(command.commandId, "running");
100680
+ operations.markExecutionStarted(command.commandId);
100745
100681
  if (availability.disposition === SessionPromptDisposition.Steer) {
100746
100682
  if (!recordSteeringPrompt()) {
100747
100683
  throw new AcpExecutionError(
@@ -100797,18 +100733,15 @@ async function executePrompt({
100797
100733
  stopReason = result.stopReason;
100798
100734
  }
100799
100735
  await eventProjection.completed(command.sessionId, command.commandId, stopReason);
100800
- operations.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
100801
100736
  } catch (error62) {
100802
100737
  if (signal.aborted && cancellationRequested()) {
100803
100738
  await eventProjection.completed(command.sessionId, command.commandId, "cancelled");
100804
- operations.transitionExecution(command.commandId, "cancelled");
100805
100739
  return;
100806
100740
  }
100807
100741
  const code = operationErrorCode(error62);
100808
100742
  const failureCode = code === "session_operation_failed" ? "agent_execution_failed" : code;
100809
100743
  const failureMessage = code === "session_operation_failed" ? "The local agent could not complete the request" : operationErrorMessage(error62);
100810
100744
  await eventProjection.failed(command.sessionId, command.commandId, failureCode, failureMessage);
100811
- operations.transitionExecution(command.commandId, "failed");
100812
100745
  reportFailure("session_prompt_failed", command.commandId, {
100813
100746
  agentId: command.agentId,
100814
100747
  code: failureCode,
@@ -101129,9 +101062,29 @@ async function executeSessionRestore(socket, command, config2, resolveAgent, dir
101129
101062
  reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
101130
101063
  }
101131
101064
  }
101132
- async function executeSessionRename(socket, command, sessions, signal) {
101065
+ async function executeSessionRename(socket, command, config2, resolveAgent, directories, sessions, nativeSessions, signal) {
101133
101066
  try {
101134
- const renamed = await sessions.renameSession(command.sessionId, command.title, signal);
101067
+ const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
101068
+ if (entry === void 0) {
101069
+ throw new SessionError("session_not_found", "The Session was not found");
101070
+ }
101071
+ const resolved = await resolveSessionDirectories(
101072
+ directories,
101073
+ config2.bindingId,
101074
+ entry.directoryId,
101075
+ entry.additionalDirectories.map((directory) => directory.directoryId),
101076
+ signal
101077
+ );
101078
+ const renamed = await sessions.renameSession(
101079
+ {
101080
+ additionalDirectories: resolved.additionalDirectories,
101081
+ ...await resolveAgent(entry.agentId, signal, command.sessionId),
101082
+ cwd: resolved.cwd,
101083
+ sessionId: command.sessionId,
101084
+ signal
101085
+ },
101086
+ command.title
101087
+ );
101135
101088
  send(socket, {
101136
101089
  kind: "session.renamed",
101137
101090
  requestId: command.requestId,
@@ -101314,7 +101267,16 @@ var init_session5 = __esm({
101314
101267
  if (message.kind !== SESSION_RENAME_KIND) {
101315
101268
  throw new Error("Command kind mismatch");
101316
101269
  }
101317
- void executeSessionRename(context.socket, message, context.sessions, context.signal);
101270
+ void executeSessionRename(
101271
+ context.socket,
101272
+ message,
101273
+ context.config,
101274
+ context.resolveAgent,
101275
+ context.directories,
101276
+ context.sessions,
101277
+ context.nativeSessions,
101278
+ context.signal
101279
+ );
101318
101280
  }
101319
101281
  };
101320
101282
  sessionConfigReadCommand = {