@moxt-ai/mobius 0.0.395 → 0.0.400

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 (36) hide show
  1. package/dist/{chunk-TIEVR6UL.js → chunk-QYYMBZ56.js} +2 -2
  2. package/dist/{chunk-TIEVR6UL.js.map → chunk-QYYMBZ56.js.map} +1 -1
  3. package/dist/{chunk-3CB7GTHC.js → chunk-VAIQ6KYK.js} +186 -148
  4. package/dist/{chunk-3CB7GTHC.js.map → chunk-VAIQ6KYK.js.map} +3 -3
  5. package/dist/{cli-JF52WJNL.js → cli-VJHRRDWH.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/session/live/agent-session.d.ts.map +1 -1
  8. package/dist/engine/session/live/agent-session.js +1 -6
  9. package/dist/engine/session/live/agent-session.js.map +1 -1
  10. package/dist/engine/session/live/session-configurations.d.ts +9 -0
  11. package/dist/engine/session/live/session-configurations.d.ts.map +1 -1
  12. package/dist/engine/session/live/session-configurations.js +32 -25
  13. package/dist/engine/session/live/session-configurations.js.map +1 -1
  14. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  15. package/dist/engine/session/manager/session-manager.js +13 -31
  16. package/dist/engine/session/manager/session-manager.js.map +1 -1
  17. package/dist/engine/session/prompt/apply-session-configuration.d.ts.map +1 -1
  18. package/dist/engine/session/prompt/apply-session-configuration.js +2 -18
  19. package/dist/engine/session/prompt/apply-session-configuration.js.map +1 -1
  20. package/dist/engine/session/prompt/prompt-lifecycle.d.ts +6 -2
  21. package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
  22. package/dist/engine/session/prompt/prompt-lifecycle.js +6 -3
  23. package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
  24. package/dist/engine/session/settings/configuration-dependencies.d.ts +12 -0
  25. package/dist/engine/session/settings/configuration-dependencies.d.ts.map +1 -0
  26. package/dist/engine/session/settings/configuration-dependencies.js +24 -0
  27. package/dist/engine/session/settings/configuration-dependencies.js.map +1 -0
  28. package/dist/engine/session/settings/discover-agent-settings.d.ts.map +1 -1
  29. package/dist/engine/session/settings/discover-agent-settings.js +2 -1
  30. package/dist/engine/session/settings/discover-agent-settings.js.map +1 -1
  31. package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
  32. package/dist/engine/session/turn/execution-receipts.js +129 -85
  33. package/dist/engine/session/turn/execution-receipts.js.map +1 -1
  34. package/dist/engine.js +2 -2
  35. package/package.json +2 -2
  36. /package/dist/{cli-JF52WJNL.js.map → cli-VJHRRDWH.js.map} +0 -0
@@ -80,7 +80,7 @@ var __callDispose = (stack, error, hasError) => {
80
80
  // package.json
81
81
  var package_default = {
82
82
  name: "@moxt-ai/mobius",
83
- version: "0.0.395",
83
+ version: "0.0.400",
84
84
  description: "Mobius CLI for pairing and running local AI agent services.",
85
85
  type: "module",
86
86
  bin: {
@@ -171,4 +171,4 @@ export {
171
171
  __callDispose,
172
172
  package_default
173
173
  };
174
- //# sourceMappingURL=chunk-TIEVR6UL.js.map
174
+ //# sourceMappingURL=chunk-QYYMBZ56.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../package.json"],
4
- "sourcesContent": ["{\n \"name\": \"@moxt-ai/mobius\",\n \"version\": \"0.0.395\",\n \"description\": \"Mobius CLI for pairing and running local AI agent services.\",\n \"type\": \"module\",\n \"bin\": {\n \"mobius\": \"dist/cli.js\"\n },\n \"exports\": {\n \"./engine\": {\n \"mobius-source\": \"./src/exports/engine.ts\",\n \"types\": \"./dist/exports/engine.d.ts\",\n \"default\": \"./dist/engine.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.txt\"\n ],\n \"engines\": {\n \"node\": \">=22.19.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"exports\": {\n \"./engine\": {\n \"types\": \"./dist/exports/engine.d.ts\",\n \"import\": \"./dist/engine.js\",\n \"default\": \"./dist/engine.js\"\n }\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/moxt-ai/mobius.git\",\n \"directory\": \"packages/cli\"\n },\n \"scripts\": {\n \"prebuild\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"build\": \"node scripts/build.ts && tsc --project tsconfig.build.json\",\n \"dev\": \"node --watch src/cli/entrypoint.ts\",\n \"pretypecheck\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"prepack\": \"pnpm build\",\n \"start\": \"node dist/cli.js\",\n \"typecheck\": \"tsc --project tsconfig.json && tsc --project tests/tsconfig.json\",\n \"pretest:controlled\": \"pnpm build\",\n \"test:controlled\": \"vitest run tests/sessions tests/runtime\",\n \"pretest:manual\": \"pnpm pretest:controlled\",\n \"test:manual\": \"vitest run tests/manual\",\n \"pretest:agents\": \"pnpm build\",\n \"test:agents\": \"vitest run tests/agents --maxWorkers=2\",\n \"pretest:pressure\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"test:pressure\": \"node tests/pressure/concurrent-sessions.mjs\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.257\",\n \"commander\": \"15.0.0\",\n \"semver\": \"^7.8.5\",\n \"undici\": \"8.12.2\",\n \"zod\": \"^4.6.7\"\n },\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"0.122.0\",\n \"@moxt-ai/mobius-sdk\": \"workspace:*\",\n \"@moxt-ai/mobius-test\": \"workspace:*\",\n \"@types/node\": \"^24.13.5\",\n \"@types/semver\": \"^7.8.0\",\n \"@types/ws\": \"^8.18.1\",\n \"drizzle-kit\": \"1.0.0-rc.4\",\n \"drizzle-orm\": \"1.0.0-rc.4\",\n \"esbuild\": \"0.28.2\",\n \"valibot\": \"1.5.0\",\n \"ws\": \"^8.21.3\"\n },\n \"keywords\": [],\n \"author\": \"Moxt\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/moxt-ai/mobius/issues\"\n },\n \"homepage\": \"https://github.com/moxt-ai/mobius#readme\"\n}\n"],
4
+ "sourcesContent": ["{\n \"name\": \"@moxt-ai/mobius\",\n \"version\": \"0.0.400\",\n \"description\": \"Mobius CLI for pairing and running local AI agent services.\",\n \"type\": \"module\",\n \"bin\": {\n \"mobius\": \"dist/cli.js\"\n },\n \"exports\": {\n \"./engine\": {\n \"mobius-source\": \"./src/exports/engine.ts\",\n \"types\": \"./dist/exports/engine.d.ts\",\n \"default\": \"./dist/engine.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.txt\"\n ],\n \"engines\": {\n \"node\": \">=22.19.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"exports\": {\n \"./engine\": {\n \"types\": \"./dist/exports/engine.d.ts\",\n \"import\": \"./dist/engine.js\",\n \"default\": \"./dist/engine.js\"\n }\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/moxt-ai/mobius.git\",\n \"directory\": \"packages/cli\"\n },\n \"scripts\": {\n \"prebuild\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"build\": \"node scripts/build.ts && tsc --project tsconfig.build.json\",\n \"dev\": \"node --watch src/cli/entrypoint.ts\",\n \"pretypecheck\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"prepack\": \"pnpm build\",\n \"start\": \"node dist/cli.js\",\n \"typecheck\": \"tsc --project tsconfig.json && tsc --project tests/tsconfig.json\",\n \"pretest:controlled\": \"pnpm build\",\n \"test:controlled\": \"vitest run tests/sessions tests/runtime\",\n \"pretest:manual\": \"pnpm pretest:controlled\",\n \"test:manual\": \"vitest run tests/manual\",\n \"pretest:agents\": \"pnpm build\",\n \"test:agents\": \"vitest run tests/agents --maxWorkers=2\",\n \"pretest:pressure\": \"tsc --project src/engine/acp/harness/claude/upstream/tsconfig.json && tsc --project src/engine/acp/harness/pi/upstream/tsconfig.json\",\n \"test:pressure\": \"node tests/pressure/concurrent-sessions.mjs\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"^1.4.0\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.257\",\n \"commander\": \"15.0.0\",\n \"semver\": \"^7.8.5\",\n \"undici\": \"8.12.2\",\n \"zod\": \"^4.6.7\"\n },\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"0.122.0\",\n \"@moxt-ai/mobius-sdk\": \"workspace:*\",\n \"@moxt-ai/mobius-test\": \"workspace:*\",\n \"@types/node\": \"^24.13.5\",\n \"@types/semver\": \"^7.8.0\",\n \"@types/ws\": \"^8.18.1\",\n \"drizzle-kit\": \"1.0.0-rc.4\",\n \"drizzle-orm\": \"1.0.0-rc.4\",\n \"esbuild\": \"0.28.2\",\n \"valibot\": \"1.5.0\",\n \"ws\": \"^8.21.3\"\n },\n \"keywords\": [],\n \"author\": \"Moxt\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/moxt-ai/mobius/issues\"\n },\n \"homepage\": \"https://github.com/moxt-ai/mobius#readme\"\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACI,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACH,QAAU;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACP,YAAY;AAAA,MACR,iBAAiB;AAAA,MACjB,OAAS;AAAA,MACT,SAAW;AAAA,IACf;AAAA,EACJ;AAAA,EACA,OAAS;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAAA,EACA,SAAW;AAAA,IACP,MAAQ;AAAA,EACZ;AAAA,EACA,eAAiB;AAAA,IACb,QAAU;AAAA,IACV,SAAW;AAAA,MACP,YAAY;AAAA,QACR,OAAS;AAAA,QACT,QAAU;AAAA,QACV,SAAW;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,YAAc;AAAA,IACV,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACjB;AAAA,EACA,SAAW;AAAA,IACP,UAAY;AAAA,IACZ,OAAS;AAAA,IACT,KAAO;AAAA,IACP,cAAgB;AAAA,IAChB,SAAW;AAAA,IACX,OAAS;AAAA,IACT,WAAa;AAAA,IACb,sBAAsB;AAAA,IACtB,mBAAmB;AAAA,IACnB,kBAAkB;AAAA,IAClB,eAAe;AAAA,IACf,kBAAkB;AAAA,IAClB,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,iBAAiB;AAAA,EACrB;AAAA,EACA,cAAgB;AAAA,IACZ,4BAA4B;AAAA,IAC5B,kCAAkC;AAAA,IAClC,WAAa;AAAA,IACb,QAAU;AAAA,IACV,QAAU;AAAA,IACV,KAAO;AAAA,EACX;AAAA,EACA,iBAAmB;AAAA,IACf,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,eAAe;AAAA,IACf,eAAe;AAAA,IACf,SAAW;AAAA,IACX,SAAW;AAAA,IACX,IAAM;AAAA,EACV;AAAA,EACA,UAAY,CAAC;AAAA,EACb,QAAU;AAAA,EACV,SAAW;AAAA,EACX,MAAQ;AAAA,IACJ,KAAO;AAAA,EACX;AAAA,EACA,UAAY;AAChB;",
6
6
  "names": []
7
7
  }
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-TIEVR6UL.js";
6
+ } from "./chunk-QYYMBZ56.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -85920,6 +85920,26 @@ var SessionInteractions = class {
85920
85920
  };
85921
85921
  };
85922
85922
 
85923
+ // src/engine/session/settings/configuration-dependencies.ts
85924
+ function isModelOption(option) {
85925
+ return option.id === "model" || option.category === "model";
85926
+ }
85927
+ function dependencyRank(configId, options) {
85928
+ const category = options.find((option) => option.id === configId)?.category ?? "";
85929
+ if (isModelOption({ category, id: configId })) {
85930
+ return 0;
85931
+ }
85932
+ if (configId === "reasoning_effort" || category === "thought_level") {
85933
+ return 1;
85934
+ }
85935
+ return category === "model_config" ? 2 : 3;
85936
+ }
85937
+ function inDependencyOrder(selections, options) {
85938
+ return selections.toSorted(
85939
+ (left, right) => dependencyRank(left.configId, options) - dependencyRank(right.configId, options) || left.configId.localeCompare(right.configId)
85940
+ );
85941
+ }
85942
+
85923
85943
  // src/engine/session/live/session-configurations.ts
85924
85944
  var storedSessionConfigurationSchema = external_exports.discriminatedUnion("type", [
85925
85945
  external_exports.object({ booleanValue: external_exports.boolean(), configId: external_exports.string().max(128), type: external_exports.literal("boolean") }),
@@ -85929,43 +85949,43 @@ var decodeStoredSessionConfigurations = (value) => external_exports.array(extern
85929
85949
  const decoded = storedSessionConfigurationSchema.safeParse(configuration);
85930
85950
  return decoded.success ? [decoded.data] : [];
85931
85951
  });
85952
+ var storedSessionConfiguration = (option) => option.type === "boolean" ? { booleanValue: option.booleanValue, configId: option.id, type: "boolean" } : { configId: option.id, type: "select", value: option.currentValue };
85953
+ async function replaySessionConfigurations(selections, options, apply, signal) {
85954
+ for (const selection of inDependencyOrder(selections, options())) {
85955
+ const current = options().find((option) => option.id === selection.configId && option.type === selection.type);
85956
+ if (current === void 0) {
85957
+ continue;
85958
+ }
85959
+ if (selection.type === "boolean") {
85960
+ if (current.booleanValue !== selection.booleanValue) {
85961
+ await apply(selection, signal);
85962
+ }
85963
+ continue;
85964
+ }
85965
+ if (current.currentValue !== selection.value && current.values.some((value) => value.value === selection.value)) {
85966
+ await apply(selection, signal);
85967
+ }
85968
+ }
85969
+ }
85932
85970
  var SessionConfigurations = class {
85933
85971
  #selected = [];
85934
85972
  stored = () => this.#selected;
85973
+ /** Follows the Agent's own changes, such as leaving Plan mode, to the settings a user chose. */
85935
85974
  capture = (options) => {
85936
85975
  this.#selected = this.#selected.map((selection) => {
85937
85976
  const current = options.find(
85938
85977
  (option) => option.id === selection.configId && option.type === selection.type
85939
85978
  );
85940
- if (current === void 0) {
85941
- return selection;
85942
- }
85943
- return current.type === "boolean" ? { booleanValue: current.booleanValue, configId: current.id, type: "boolean" } : { configId: current.id, type: "select", value: current.currentValue };
85979
+ return current === void 0 ? selection : storedSessionConfiguration(current);
85944
85980
  });
85945
85981
  };
85946
85982
  select = (option) => {
85947
- const selected = option.type === "boolean" ? { booleanValue: option.booleanValue, configId: option.id, type: "boolean" } : { configId: option.id, type: "select", value: option.currentValue };
85983
+ const selected = storedSessionConfiguration(option);
85948
85984
  this.#selected = [...this.#selected.filter((selection) => selection.configId !== selected.configId), selected];
85949
85985
  };
85950
85986
  restore = async (stored, options, apply, signal) => {
85951
85987
  this.#selected = stored;
85952
- for (const selection of this.#selected) {
85953
- const current = options().find(
85954
- (option) => option.id === selection.configId && option.type === selection.type
85955
- );
85956
- if (current === void 0) {
85957
- continue;
85958
- }
85959
- if (selection.type === "boolean") {
85960
- if (current.booleanValue !== selection.booleanValue) {
85961
- await apply(selection, signal);
85962
- }
85963
- continue;
85964
- }
85965
- if (current.currentValue !== selection.value && current.values.some((value) => value.value === selection.value)) {
85966
- await apply(selection, signal);
85967
- }
85968
- }
85988
+ await replaySessionConfigurations(stored, options, apply, signal);
85969
85989
  };
85970
85990
  };
85971
85991
 
@@ -86475,11 +86495,8 @@ var AgentSession = class _AgentSession {
86475
86495
  }
86476
86496
  };
86477
86497
  restoreStoredConfigurations = async (session, signal, intent = "restore") => {
86478
- const configurations = intent === "fork" ? session.configurations.toSorted(
86479
- (left, right) => Number(right.configId === "model") - Number(left.configId === "model")
86480
- ) : session.configurations;
86481
86498
  await this.#sessionConfigurations.restore(
86482
- configurations,
86499
+ session.configurations,
86483
86500
  () => this.#configOptions,
86484
86501
  this.#applyConfiguration,
86485
86502
  signal
@@ -87372,35 +87389,21 @@ var SessionManager2 = class {
87372
87389
  )
87373
87390
  );
87374
87391
  try {
87375
- for (const desired of desiredConfigOptions) {
87376
- const current = runtime.prepared().configOptions.find((option) => option.id === desired.id);
87377
- if (current === void 0 || current.type !== desired.type) {
87378
- continue;
87379
- }
87380
- if (desired.type === "boolean") {
87381
- if (current.booleanValue !== desired.booleanValue) {
87382
- await runtime.applyConfiguration({
87383
- ...options,
87384
- booleanValue: desired.booleanValue,
87385
- configId: desired.id,
87386
- requestId: `execution-prepare-${desired.id}`,
87387
- value: "",
87388
- valueType: "boolean"
87389
- });
87390
- }
87391
- continue;
87392
- }
87393
- if (current.currentValue !== desired.currentValue && current.values.some((value) => value.value === desired.currentValue)) {
87392
+ await replaySessionConfigurations(
87393
+ desiredConfigOptions.map(storedSessionConfiguration),
87394
+ () => runtime.prepared().configOptions,
87395
+ async (desired) => {
87394
87396
  await runtime.applyConfiguration({
87395
87397
  ...options,
87396
- booleanValue: false,
87397
- configId: desired.id,
87398
- requestId: `execution-prepare-${desired.id}`,
87399
- value: desired.currentValue,
87400
- valueType: "select"
87398
+ booleanValue: desired.type === "boolean" && desired.booleanValue,
87399
+ configId: desired.configId,
87400
+ requestId: `execution-prepare-${desired.configId}`,
87401
+ value: desired.type === "select" ? desired.value : "",
87402
+ valueType: desired.type
87401
87403
  });
87402
- }
87403
- }
87404
+ },
87405
+ options.signal
87406
+ );
87404
87407
  } catch (error62) {
87405
87408
  await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.close());
87406
87409
  throw error62;
@@ -87534,9 +87537,7 @@ var SessionManager2 = class {
87534
87537
  const prepared = runtime.prepared();
87535
87538
  const discoveredModelEffort = runtime.agentSettingsModelEffort();
87536
87539
  const model = options2.model;
87537
- const modelOption2 = prepared.configOptions.find(
87538
- (option) => option.id === "model" || option.category === "model"
87539
- );
87540
+ const modelOption2 = prepared.configOptions.find(isModelOption);
87540
87541
  const modelIsFixed = modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model;
87541
87542
  const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.applyConfiguration({
87542
87543
  ...options2,
@@ -88614,10 +88615,13 @@ var PromptLifecycle = class {
88614
88615
  );
88615
88616
  }
88616
88617
  };
88617
- /** Settles a failed command; whether it failed before or after starting is its receipt's fact. */
88618
+ /**
88619
+ * Settles a failed command; whether it failed before or after starting is its receipt's fact. The unsettled
88620
+ * receipt, not the queue registration, admits the failure: a turn that ended without recording its terminal
88621
+ * event has already left the queue, and its abandonment must still settle it.
88622
+ */
88618
88623
  failed = async (sessionId, commandId, attemptId, code, message) => {
88619
- const request = this.#queued.get(commandId);
88620
- if (request?.sessionId !== sessionId || this.#executions.isTerminalExecution(commandId, sessionId)) {
88624
+ if (this.#executions.findUnsettledAttemptId(commandId, sessionId) === null) {
88621
88625
  return;
88622
88626
  }
88623
88627
  const recorded = await this.#recordLifecycle(sessionId, {
@@ -88684,6 +88688,13 @@ function cancelledBeforeStart(state) {
88684
88688
  const outcome = decodeKnownSessionEventPayload(JSON.parse(state.outcome));
88685
88689
  return outcome?.type === "lifecycle-metadata" && outcome.payload.kind === "prompt.completed" && promptCompletion(outcome.payload).kind === "cancelled";
88686
88690
  }
88691
+ function restartedBeforeStart(state) {
88692
+ if (state.kind !== "settled-before-start") {
88693
+ return false;
88694
+ }
88695
+ const outcome = decodeKnownSessionEventPayload(JSON.parse(state.outcome));
88696
+ return outcome?.type === "lifecycle-metadata" && outcome.payload.kind === "prompt.failed-before-start" && outcome.payload.code === "runtime_restarted";
88697
+ }
88687
88698
  function executionOutcome(state) {
88688
88699
  switch (state.kind) {
88689
88700
  case "pending":
@@ -88701,6 +88712,31 @@ function executionOutcome(state) {
88701
88712
  function settledExecution(state, outcome) {
88702
88713
  return { kind: executionStarted(state) ? "settled-after-start" : "settled-before-start", outcome };
88703
88714
  }
88715
+ function commandStanding({ receipt, identity: identity2, cancellation }, sessionId) {
88716
+ if (receipt !== void 0) {
88717
+ if (receipt.sessionId !== sessionId) {
88718
+ return { kind: "foreign" };
88719
+ }
88720
+ if (!executionStarted(receipt.state) && !cancelledBeforeStart(receipt.state) && cancellation?.sessionId === sessionId) {
88721
+ return { kind: "cancelled", receipt };
88722
+ }
88723
+ return restartedBeforeStart(receipt.state) ? { kind: "retryable", receipt } : { kind: "retained", receipt };
88724
+ }
88725
+ if (identity2 !== void 0) {
88726
+ return identity2.sessionId === sessionId ? { kind: "expired", commandHash: identity2.commandHash } : { kind: "foreign" };
88727
+ }
88728
+ if (cancellation !== void 0) {
88729
+ return cancellation.sessionId === sessionId ? { kind: "cancelled", receipt: void 0 } : { kind: "foreign" };
88730
+ }
88731
+ return { kind: "unseen" };
88732
+ }
88733
+ var cancelledBeforeStartOutcome = (commandId) => ({
88734
+ type: "lifecycle-metadata",
88735
+ payload: { kind: "prompt.completed", commandId, stopReason: "cancelled", execution: "not-started" }
88736
+ });
88737
+ var unexpectedStanding = (standing) => {
88738
+ throw new Error("Unexpected command standing", { cause: standing });
88739
+ };
88704
88740
  var ExecutionReceipts = class {
88705
88741
  #executions = /* @__PURE__ */ new Map();
88706
88742
  #recoveredCommands = /* @__PURE__ */ new Set();
@@ -88727,6 +88763,19 @@ var ExecutionReceipts = class {
88727
88763
  }
88728
88764
  cancellations.retain(retained);
88729
88765
  }
88766
+ /** Reads every ledger that can still change the answer and classifies the identifier for the Session. */
88767
+ #standing = (commandId, sessionId) => {
88768
+ const receipt = this.#executions.get(commandId);
88769
+ const final = receipt !== void 0 && (executionStarted(receipt.state) || cancelledBeforeStart(receipt.state));
88770
+ return commandStanding(
88771
+ {
88772
+ receipt,
88773
+ identity: receipt === void 0 ? this.#table.identity(commandId) : void 0,
88774
+ cancellation: final ? void 0 : this.#cancellations.read(commandId)
88775
+ },
88776
+ sessionId
88777
+ );
88778
+ };
88730
88779
  #remember = (commandId, receipt, evicted) => {
88731
88780
  this.#executions.set(commandId, receipt);
88732
88781
  for (const evictedCommandId of evicted) {
@@ -88776,14 +88825,22 @@ var ExecutionReceipts = class {
88776
88825
  };
88777
88826
  /** The command's delivery as these receipts know it; another Session's command reads as unknown. */
88778
88827
  delivery = (commandId, sessionId) => {
88779
- const receipt = this.#executions.get(commandId);
88780
- if (receipt === void 0) {
88781
- return this.#table.identity(commandId)?.sessionId === sessionId || this.#cancellations.read(commandId)?.sessionId === sessionId ? { state: "expired" } : { state: "unknown" };
88782
- }
88783
- if (receipt.sessionId !== sessionId) {
88784
- return { state: "unknown" };
88828
+ const standing = this.#standing(commandId, sessionId);
88829
+ switch (standing.kind) {
88830
+ case "unseen":
88831
+ case "foreign":
88832
+ return { state: "unknown" };
88833
+ case "expired":
88834
+ return { state: "expired" };
88835
+ case "cancelled":
88836
+ return { state: "completed", stopReason: "cancelled" };
88837
+ case "retryable":
88838
+ case "retained":
88839
+ break;
88840
+ default:
88841
+ return unexpectedStanding(standing);
88785
88842
  }
88786
- if (executionOutcome(receipt.state) === null) {
88843
+ if (executionOutcome(standing.receipt.state) === null) {
88787
88844
  return { state: "accepted" };
88788
88845
  }
88789
88846
  const outcome = this.outcome(commandId);
@@ -88836,38 +88893,43 @@ var ExecutionReceipts = class {
88836
88893
  };
88837
88894
  /** Started identities remain authoritative after their detailed receipt is evicted. */
88838
88895
  hasStarted = (commandId, sessionId) => {
88839
- const receipt = this.#executions.get(commandId);
88840
- return receipt?.sessionId === sessionId && executionStarted(receipt.state) || this.#table.identity(commandId)?.sessionId === sessionId;
88896
+ const standing = this.#standing(commandId, sessionId);
88897
+ switch (standing.kind) {
88898
+ case "unseen":
88899
+ case "foreign":
88900
+ case "cancelled":
88901
+ case "retryable":
88902
+ return false;
88903
+ case "expired":
88904
+ return true;
88905
+ case "retained":
88906
+ return executionStarted(standing.receipt.state);
88907
+ default:
88908
+ return unexpectedStanding(standing);
88909
+ }
88841
88910
  };
88842
88911
  /** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
88843
88912
  recordCancellationBeforeAdmission = (commandId, sessionId) => {
88844
- const existing = this.#executions.get(commandId);
88845
- if (existing !== void 0) {
88846
- return existing.sessionId === sessionId ? this.outcome(commandId) : void 0;
88847
- }
88848
- const identity2 = this.#table.identity(commandId);
88849
- if (identity2 !== void 0) {
88850
- return identity2.sessionId === sessionId ? {
88851
- type: "lifecycle-metadata",
88852
- payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
88853
- } : void 0;
88854
- }
88855
- const cancellation = this.#cancellations.read(commandId);
88856
- if (cancellation !== void 0) {
88857
- return cancellation.sessionId === sessionId ? {
88858
- type: "lifecycle-metadata",
88859
- payload: {
88860
- kind: "prompt.completed",
88861
- commandId,
88862
- stopReason: "cancelled",
88863
- execution: "not-started"
88864
- }
88865
- } : void 0;
88913
+ const standing = this.#standing(commandId, sessionId);
88914
+ switch (standing.kind) {
88915
+ case "foreign":
88916
+ return void 0;
88917
+ case "retryable":
88918
+ case "retained":
88919
+ return this.outcome(commandId);
88920
+ case "expired":
88921
+ return {
88922
+ type: "lifecycle-metadata",
88923
+ payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
88924
+ };
88925
+ case "cancelled":
88926
+ return cancelledBeforeStartOutcome(commandId);
88927
+ case "unseen":
88928
+ break;
88929
+ default:
88930
+ return unexpectedStanding(standing);
88866
88931
  }
88867
- const outcome = {
88868
- type: "lifecycle-metadata",
88869
- payload: { kind: "prompt.completed", commandId, stopReason: "cancelled", execution: "not-started" }
88870
- };
88932
+ const outcome = cancelledBeforeStartOutcome(commandId);
88871
88933
  const commandHash = createHash8("sha256").update(
88872
88934
  encodeSessionCancelBeforeStartCommand({
88873
88935
  commandId,
@@ -88923,16 +88985,8 @@ var ExecutionReceipts = class {
88923
88985
  const recovered = [];
88924
88986
  for (const [commandId, receipt] of [...this.#executions]) {
88925
88987
  const outcome = executionOutcome(receipt.state);
88926
- const restoreCancellation = !this.hasStarted(commandId, receipt.sessionId) && !cancelledBeforeStart(receipt.state) && this.#cancellations.read(commandId)?.sessionId === receipt.sessionId;
88927
- const event = restoreCancellation ? {
88928
- type: "lifecycle-metadata",
88929
- payload: {
88930
- kind: "prompt.completed",
88931
- commandId,
88932
- stopReason: "cancelled",
88933
- execution: "not-started"
88934
- }
88935
- } : outcome === null ? {
88988
+ const restoreCancellation = this.#standing(commandId, receipt.sessionId).kind === "cancelled";
88989
+ const event = restoreCancellation ? cancelledBeforeStartOutcome(commandId) : outcome === null ? {
88936
88990
  type: "lifecycle-metadata",
88937
88991
  payload: executionStarted(receipt.state) ? {
88938
88992
  kind: "prompt.failed",
@@ -88963,31 +89017,32 @@ var ExecutionReceipts = class {
88963
89017
  };
88964
89018
  claimExecution = (commandId, sessionId, commandJson) => {
88965
89019
  const commandHash = createHash8("sha256").update(commandJson).digest("hex");
88966
- let existing = this.#executions.get(commandId);
88967
- const previous = this.outcome(commandId);
88968
- if (existing?.sessionId === sessionId && !executionStarted(existing.state) && previous?.type === "lifecycle-metadata" && previous.payload.kind === "prompt.failed-before-start" && previous.payload.code === "runtime_restarted") {
88969
- this.#table.remove(commandId);
88970
- this.#executions.delete(commandId);
88971
- this.#recoveredCommands.delete(commandId);
88972
- existing = void 0;
88973
- }
88974
- if (existing !== void 0) {
88975
- if (existing.sessionId !== sessionId || existing.commandHash !== commandHash) {
89020
+ const standing = this.#standing(commandId, sessionId);
89021
+ switch (standing.kind) {
89022
+ case "foreign":
89023
+ case "cancelled":
88976
89024
  return { kind: "conflict" };
88977
- }
88978
- return {
88979
- attemptId: existing.attemptId,
88980
- commandId,
88981
- kind: "duplicate",
88982
- outcome: this.#recoveredCommands.has(commandId) ? this.outcome(commandId) : void 0
88983
- };
88984
- }
88985
- const identity2 = this.#table.identity(commandId);
88986
- if (identity2 !== void 0) {
88987
- return identity2.sessionId === sessionId && identity2.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
88988
- }
88989
- if (this.#cancellations.read(commandId) !== void 0) {
88990
- return { kind: "conflict" };
89025
+ case "retained":
89026
+ if (standing.receipt.commandHash !== commandHash) {
89027
+ return { kind: "conflict" };
89028
+ }
89029
+ return {
89030
+ attemptId: standing.receipt.attemptId,
89031
+ commandId,
89032
+ kind: "duplicate",
89033
+ outcome: this.#recoveredCommands.has(commandId) ? this.outcome(commandId) : void 0
89034
+ };
89035
+ case "expired":
89036
+ return standing.commandHash === commandHash ? { kind: "expired" } : { kind: "conflict" };
89037
+ case "retryable":
89038
+ this.#table.remove(commandId);
89039
+ this.#executions.delete(commandId);
89040
+ this.#recoveredCommands.delete(commandId);
89041
+ return this.claimExecution(commandId, sessionId, commandJson);
89042
+ case "unseen":
89043
+ break;
89044
+ default:
89045
+ return unexpectedStanding(standing);
88991
89046
  }
88992
89047
  const attemptId = randomUUID15();
88993
89048
  this.#save(commandId, {
@@ -90771,7 +90826,7 @@ function withoutUnsupportedModels(settings, modelSettingId, unsupportedModelIds2
90771
90826
  });
90772
90827
  }
90773
90828
  function modelOption(options) {
90774
- return options.find((option) => option.id === "model" || option.category === "model");
90829
+ return options.find(isModelOption);
90775
90830
  }
90776
90831
  function effortOption(options) {
90777
90832
  return options.find((option) => option.id === "reasoning_effort" || option.category === "thought_level");
@@ -91803,19 +91858,6 @@ function sessionConfigurationMatches(option, selection) {
91803
91858
  validateSessionConfigurationSelection(option, selection);
91804
91859
  return option.type === "boolean" ? option.booleanValue === selection.booleanValue : option.currentValue === selection.value;
91805
91860
  }
91806
- function sessionConfigurationPriority(selection, options) {
91807
- const option = options.find((candidate) => candidate.id === selection.configId);
91808
- if (selection.configId === "model" || option?.category === "model") {
91809
- return 0;
91810
- }
91811
- if (selection.configId === "reasoning_effort" || option?.category === "thought_level") {
91812
- return 1;
91813
- }
91814
- if (option?.category === "model_config") {
91815
- return 2;
91816
- }
91817
- return 3;
91818
- }
91819
91861
  function assertAppliedSessionConfiguration(options, selections) {
91820
91862
  const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
91821
91863
  for (const option of options) {
@@ -91906,11 +91948,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
91906
91948
  }
91907
91949
  async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, adapter, cwd, additionalDirectories, commandId, sessionId, signal) {
91908
91950
  let options = initialOptions;
91909
- const orderedSelections = selections.toSorted((left, right) => {
91910
- const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
91911
- return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
91912
- });
91913
- for (const selection of orderedSelections) {
91951
+ for (const selection of inDependencyOrder(selections, initialOptions)) {
91914
91952
  options = await applySessionConfigurationSelection(
91915
91953
  sessions,
91916
91954
  options,
@@ -93839,4 +93877,4 @@ export {
93839
93877
  * MIT Licensed
93840
93878
  *)
93841
93879
  */
93842
- //# sourceMappingURL=chunk-3CB7GTHC.js.map
93880
+ //# sourceMappingURL=chunk-VAIQ6KYK.js.map