@morty-build/cli 0.2.0 → 0.4.0

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 (69) hide show
  1. package/dist/{chunk-MBS25BBY.js → chunk-OCDHOJ7L.js} +59 -72
  2. package/dist/{chunk-MBS25BBY.js.map → chunk-OCDHOJ7L.js.map} +4 -4
  3. package/dist/{chunk-ZSUNNLEK.js → chunk-XU65UWFZ.js} +2 -2
  4. package/dist/{chunk-ZSUNNLEK.js.map → chunk-XU65UWFZ.js.map} +1 -1
  5. package/dist/cli/handler/daemon/install.js +3 -3
  6. package/dist/cli/handler/daemon/install.js.map +1 -1
  7. package/dist/cli/handler/daemon/start.js +1 -1
  8. package/dist/cli/handler/daemon/start.js.map +1 -1
  9. package/dist/cli/handler/daemon/upgrade.js +1 -1
  10. package/dist/cli/handler/daemon/upgrade.js.map +1 -1
  11. package/dist/cli/handler/pair/pair.js +1 -1
  12. package/dist/cli/handler/pair/pair.js.map +1 -1
  13. package/dist/{cli-4I5WYVG2.js → cli-AWIX35OG.js} +83 -180
  14. package/dist/{cli-4I5WYVG2.js.map → cli-AWIX35OG.js.map} +3 -3
  15. package/dist/cli.js +2 -2
  16. package/dist/daemon/control/local-client.d.ts +2 -2
  17. package/dist/daemon/control/local-client.d.ts.map +1 -1
  18. package/dist/daemon/control/local-client.js +4 -7
  19. package/dist/daemon/control/local-client.js.map +1 -1
  20. package/dist/daemon/control/local-server.d.ts +1 -1
  21. package/dist/daemon/control/local-server.d.ts.map +1 -1
  22. package/dist/daemon/control/local-server.js +2 -2
  23. package/dist/daemon/control/local-server.js.map +1 -1
  24. package/dist/daemon/control/protocol.d.ts +7 -7
  25. package/dist/daemon/control/protocol.d.ts.map +1 -1
  26. package/dist/daemon/control/protocol.js +6 -13
  27. package/dist/daemon/control/protocol.js.map +1 -1
  28. package/dist/daemon/lifecycle/daemon-client.d.ts +1 -1
  29. package/dist/daemon/lifecycle/daemon-client.d.ts.map +1 -1
  30. package/dist/daemon/lifecycle/daemon-client.js +13 -13
  31. package/dist/daemon/lifecycle/daemon-client.js.map +1 -1
  32. package/dist/daemon/lifecycle/daemon.js +11 -24
  33. package/dist/daemon/lifecycle/daemon.js.map +1 -1
  34. package/dist/engine/runtime/command/native-session-requests.d.ts.map +1 -1
  35. package/dist/engine/runtime/command/native-session-requests.js +2 -4
  36. package/dist/engine/runtime/command/native-session-requests.js.map +1 -1
  37. package/dist/engine/runtime/command/registry/history.d.ts.map +1 -1
  38. package/dist/engine/runtime/command/registry/history.js +1 -0
  39. package/dist/engine/runtime/command/registry/history.js.map +1 -1
  40. package/dist/engine/runtime/command/registry/interactions.js +3 -3
  41. package/dist/engine/runtime/command/registry/interactions.js.map +1 -1
  42. package/dist/engine/runtime/connection/runtime-installation-store.d.ts.map +1 -1
  43. package/dist/engine/runtime/connection/runtime-installation-store.js +5 -13
  44. package/dist/engine/runtime/connection/runtime-installation-store.js.map +1 -1
  45. package/dist/engine/runtime/pairing.d.ts.map +1 -1
  46. package/dist/engine/runtime/pairing.js +6 -11
  47. package/dist/engine/runtime/pairing.js.map +1 -1
  48. package/dist/engine/session/prompt/prompt-lifecycle.d.ts +1 -1
  49. package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
  50. package/dist/engine/session/prompt/prompt-lifecycle.js +4 -1
  51. package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
  52. package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
  53. package/dist/engine/session/turn/active-turn.js +4 -3
  54. package/dist/engine/session/turn/active-turn.js.map +1 -1
  55. package/dist/engine/session/turn/execution-receipts.d.ts +3 -1
  56. package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
  57. package/dist/engine/session/turn/execution-receipts.js +2 -12
  58. package/dist/engine/session/turn/execution-receipts.js.map +1 -1
  59. package/dist/engine/session/turn/session-turns.d.ts +3 -3
  60. package/dist/engine/storage/session/command-cancellation-table.d.ts +1 -1
  61. package/dist/engine/storage/session/command-cancellation-table.d.ts.map +1 -1
  62. package/dist/engine/storage/session/command-cancellation-table.js +1 -1
  63. package/dist/engine/storage/session/command-cancellation-table.js.map +1 -1
  64. package/dist/engine.js +2 -2
  65. package/dist/storage/daemon/daemon-lock.d.ts +6 -4
  66. package/dist/storage/daemon/daemon-lock.d.ts.map +1 -1
  67. package/dist/storage/daemon/daemon-lock.js +30 -140
  68. package/dist/storage/daemon/daemon-lock.js.map +1 -1
  69. package/package.json +1 -1
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-ZSUNNLEK.js";
6
+ } from "./chunk-XU65UWFZ.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -20087,16 +20087,16 @@ var sessionStatusSchema = external_exports.discriminatedUnion("kind", [
20087
20087
  /**
20088
20088
  * Present when the Session's most recent started command failed, while the Runtime retains its receipt, so
20089
20089
  * a client that did not watch it can still show the Session failed until another command starts. It
20090
- * carries what the execution's `lastTurn` reports for that failure. Runtimes before it existed omit it.
20090
+ * carries what the execution's `lastTurn` reports for that failure.
20091
20091
  */
20092
- failedTurn: external_exports.object({ code: identifierStringSchema, commandId: identifierStringSchema, message: external_exports.string().min(1).max(500) }).readonly().optional().catch(void 0)
20092
+ failedTurn: external_exports.object({ code: identifierStringSchema, commandId: identifierStringSchema, message: external_exports.string().min(1).max(500) }).readonly().optional()
20093
20093
  }).readonly(),
20094
20094
  external_exports.object({
20095
20095
  commandId: identifierStringSchema,
20096
20096
  kind: external_exports.literal("working")
20097
20097
  }).readonly()
20098
20098
  ]);
20099
- var sessionCapabilitiesSchema = external_exports.object({
20099
+ var sessionCapabilitiesSchema = external_exports.strictObject({
20100
20100
  additionalDirectories: external_exports.boolean(),
20101
20101
  audioPrompt: external_exports.boolean(),
20102
20102
  closeSession: external_exports.boolean(),
@@ -20105,11 +20105,11 @@ var sessionCapabilitiesSchema = external_exports.object({
20105
20105
  imagePrompt: external_exports.boolean(),
20106
20106
  listSessions: external_exports.boolean(),
20107
20107
  loadSession: external_exports.boolean(),
20108
- promptQueueing: external_exports.boolean().default(false),
20109
- renameSession: external_exports.boolean().default(false),
20108
+ promptQueueing: external_exports.boolean(),
20109
+ renameSession: external_exports.boolean(),
20110
20110
  resumeSession: external_exports.boolean(),
20111
- steering: external_exports.boolean().default(false),
20112
- unstableForkSession: external_exports.boolean().default(false)
20111
+ steering: external_exports.boolean(),
20112
+ unstableForkSession: external_exports.boolean()
20113
20113
  }).readonly();
20114
20114
  var sessionCommandSchema = external_exports.object({
20115
20115
  description: SHORT_TEXT,
@@ -20162,13 +20162,12 @@ var agentModelEffortSchema = external_exports.object({
20162
20162
  effortSettingId: external_exports.string().max(128),
20163
20163
  modelSettingId: external_exports.string().max(128),
20164
20164
  resolution: agentModelEffortResolutionSchema,
20165
- unsupportedModelIds: external_exports.array(external_exports.string().min(1).max(500)).max(500).readonly().default([]),
20165
+ unsupportedModelIds: external_exports.array(external_exports.string().min(1).max(500)).max(500).readonly(),
20166
20166
  valuesByModel: external_exports.record(external_exports.string().min(1).max(500), external_exports.array(configValueSchema).max(500).readonly()).readonly()
20167
20167
  }).readonly();
20168
20168
  var agentSettingsDiscoverCommandSchema = external_exports.object({
20169
20169
  agentId: identifierStringSchema,
20170
- // The directory a Session would start in, whose project settings the Agent reads. Omitted, the Runtime's
20171
- // default directory. A Runtime that predates this field ignores it; see the discovered event's `directoryId`.
20170
+ // The directory whose project settings the Agent reads. Omitted means the default directory.
20172
20171
  directoryId: DIRECTORY_IDENTIFIER.optional(),
20173
20172
  kind: external_exports.literal(AGENT_SETTINGS_DISCOVER_KIND),
20174
20173
  model: external_exports.string().min(1).max(500).optional(),
@@ -20178,9 +20177,8 @@ var agentSettingsDiscoveredEventSchema = external_exports.object({
20178
20177
  agentId: identifierStringSchema,
20179
20178
  agentName: external_exports.string().max(255),
20180
20179
  agentVersion: external_exports.string().max(128),
20181
- // The directory the settings were discovered in. Absent from older Runtimes, which always discover in the
20182
- // Runtime's default directory whatever the command named.
20183
- directoryId: DIRECTORY_IDENTIFIER.optional(),
20180
+ // The directory actually inspected.
20181
+ directoryId: DIRECTORY_IDENTIFIER,
20184
20182
  kind: external_exports.literal(AGENT_SETTINGS_DISCOVERED_KIND),
20185
20183
  modelEffort: agentModelEffortSchema,
20186
20184
  requestId: identifierStringSchema,
@@ -20435,12 +20433,11 @@ var elicitationFieldSchema = external_exports.object({
20435
20433
  }).readonly();
20436
20434
  var sessionPermissionRequestedEventSchema = external_exports.object({
20437
20435
  commandId: identifierStringSchema,
20438
- // Absent only for events from older runtimes and saved history.
20439
20436
  details: external_exports.object({
20440
20437
  cwd: external_exports.string().min(1).max(4096),
20441
20438
  rawInput: boundedJsonSchema.optional(),
20442
20439
  locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly()
20443
- }).readonly().optional(),
20440
+ }).readonly(),
20444
20441
  interactionId: identifierStringSchema,
20445
20442
  kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
20446
20443
  options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
@@ -20898,9 +20895,8 @@ var promptMessageOutcomeSchema = external_exports.object({
20898
20895
  var sessionEventLogPageSchema = external_exports.object({
20899
20896
  events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
20900
20897
  nextCursor: external_exports.string().min(1).max(512).nullable(),
20901
- // The settled prompts, among those the Runtime still retains, whose user message is on this page. Absent from
20902
- // older Runtimes and from pages that are not a Session's own history.
20903
- promptOutcomes: external_exports.array(promptMessageOutcomeSchema).max(MAX_EVENT_COUNT).readonly().optional(),
20898
+ // Retained settled prompts whose user message is on this page; empty outside Session history.
20899
+ promptOutcomes: external_exports.array(promptMessageOutcomeSchema).max(MAX_EVENT_COUNT).readonly(),
20904
20900
  sessionGenerationId: identifierStringSchema,
20905
20901
  tailCursor: external_exports.string().max(512),
20906
20902
  // The generation-scoped live position covered by this snapshot, including
@@ -21156,7 +21152,7 @@ var sessionMetadataSchema = external_exports.object({
21156
21152
  directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
21157
21153
  prompted: external_exports.boolean(),
21158
21154
  sessionId: identifierStringSchema,
21159
- status: sessionStatusSchema.default({ kind: "idle" }),
21155
+ status: sessionStatusSchema,
21160
21156
  title: external_exports.string().max(500),
21161
21157
  updatedAt: external_exports.iso.datetime({ offset: true })
21162
21158
  }).readonly();
@@ -21345,7 +21341,7 @@ var promptAttachmentSchema = external_exports.object({
21345
21341
  var decodePromptAttachmentsValue = (value) => decodeZodValue(value, external_exports.array(promptAttachmentSchema).max(16).readonly());
21346
21342
  function readPromptDisposition(value) {
21347
21343
  const field = value["disposition"];
21348
- if (field === void 0 || field === SessionPromptDisposition.Reject) {
21344
+ if (field === SessionPromptDisposition.Reject) {
21349
21345
  return SessionPromptDisposition.Reject;
21350
21346
  }
21351
21347
  if (field === SessionPromptDisposition.Queue) {
@@ -21370,8 +21366,7 @@ function decodeSessionPromptCommand(encoded) {
21370
21366
  throw new ProtocolMessageError("Prompt must contain content");
21371
21367
  }
21372
21368
  const disposition = readPromptDisposition(value);
21373
- const rawTargetCommandId = value["targetCommandId"];
21374
- const targetCommandId = rawTargetCommandId === void 0 ? "" : readText(value, "targetCommandId", 128);
21369
+ const targetCommandId = readText(value, "targetCommandId", 128);
21375
21370
  if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !isIdentifier(targetCommandId)) {
21376
21371
  throw new ProtocolMessageError("Prompt disposition has an invalid target command");
21377
21372
  }
@@ -21387,9 +21382,7 @@ function decodeSessionPromptCommand(encoded) {
21387
21382
  directoryId: readDirectoryIdentifier(value, "directoryId"),
21388
21383
  disposition,
21389
21384
  attachments,
21390
- ...value["historyPolicy"] === void 0 ? {} : {
21391
- historyPolicy: readHistoryPolicy(value)
21392
- },
21385
+ historyPolicy: readHistoryPolicy(value),
21393
21386
  kind: SESSION_PROMPT_KIND,
21394
21387
  prompt,
21395
21388
  ...hasSessionConfigurations ? { sessionConfigurations } : {},
@@ -21459,8 +21452,8 @@ var activeTurnSnapshotSchema = external_exports.object({
21459
21452
  epoch: identifierStringSchema,
21460
21453
  interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
21461
21454
  sequence: external_exports.number().int().nonnegative(),
21462
- // When the turn started, as the Runtime recorded it. Absent from older Runtimes.
21463
- startedAt: external_exports.iso.datetime({ offset: true }).optional(),
21455
+ // When the Runtime recorded the start of this running turn.
21456
+ startedAt: external_exports.iso.datetime({ offset: true }),
21464
21457
  state: external_exports.literal("running")
21465
21458
  }).readonly();
21466
21459
  var commandDeliverySchema = external_exports.discriminatedUnion("state", [
@@ -22663,15 +22656,11 @@ function decodeInstallationPointer(value) {
22663
22656
  }
22664
22657
  return { installationId: validateInstallationId(storedInstallationId) };
22665
22658
  }
22666
- function retainedFields(value, keys) {
22667
- return Object.fromEntries(keys.filter((key) => Object.hasOwn(value, key)).map((key) => [key, value[key]]));
22668
- }
22669
- function decodeChannelIndex(input2) {
22670
- if (!isRecord3(input2)) {
22659
+ function decodeChannelIndex(value) {
22660
+ if (!isRecord3(value)) {
22671
22661
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
22672
22662
  }
22673
- const value = input2["version"] === 1 ? retainedFields(input2, CHANNEL_INDEX_KEYS) : input2;
22674
- if (!hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1 && value["version"] !== 2) {
22663
+ if (!hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 2) {
22675
22664
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
22676
22665
  }
22677
22666
  const channelId = value["channelId"];
@@ -22687,7 +22676,7 @@ function decodeChannelIndex(input2) {
22687
22676
  };
22688
22677
  }
22689
22678
  function decodeVerifiedConnection(value) {
22690
- if (!hasExactKeys(value, VERIFIED_CONNECTION_KEYS) || value["version"] !== 5 && value["version"] !== 6 || value["kind"] !== "verified") {
22679
+ if (!hasExactKeys(value, VERIFIED_CONNECTION_KEYS) || value["version"] !== 6 || value["kind"] !== "verified") {
22691
22680
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
22692
22681
  }
22693
22682
  const activation = value["activation"];
@@ -22720,7 +22709,7 @@ function decodeConnection(value) {
22720
22709
  if (!isRecord3(value)) {
22721
22710
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
22722
22711
  }
22723
- return decodeVerifiedConnection(value["version"] === 5 ? retainedFields(value, VERIFIED_CONNECTION_KEYS) : value);
22712
+ return decodeVerifiedConnection(value);
22724
22713
  }
22725
22714
  async function readJsonFile(path7, signal, missingCode) {
22726
22715
  signal.throwIfAborted();
@@ -88629,7 +88618,6 @@ async function unchangedIdentity(agent2, signal) {
88629
88618
  var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
88630
88619
  var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
88631
88620
  var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
88632
- var CLAIM_RESPONSE_KEYS = ["appId", "channelId", "daemonToken", "runtimeId"];
88633
88621
  var REDEEM_RESPONSE_KEYS = ["appId", "channelId", "runtimeCredential", "runtimeId"];
88634
88622
  var PairingClientError = class extends Error {
88635
88623
  code;
@@ -88722,13 +88710,13 @@ function readRelayError(value) {
88722
88710
  }
88723
88711
  return new PairingClientError("pairing_failed", "The relay could not pair this machine");
88724
88712
  }
88725
- function decodePairingResponse(value, credentialField, expectedKeys) {
88726
- if (!isRecord5(value) || !hasExactKeys2(value, expectedKeys)) {
88713
+ function decodePairingResponse(value) {
88714
+ if (!isRecord5(value) || !hasExactKeys2(value, REDEEM_RESPONSE_KEYS)) {
88727
88715
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
88728
88716
  }
88729
88717
  const appId = value["appId"];
88730
88718
  const channelId = value["channelId"];
88731
- const runtimeCredential2 = value[credentialField];
88719
+ const runtimeCredential2 = value["runtimeCredential"];
88732
88720
  const runtimeId = value["runtimeId"];
88733
88721
  if (typeof appId !== "string" || !isIdentifier(appId) || typeof channelId !== "string" || !isIdentifier(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !isIdentifier(runtimeId)) {
88734
88722
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
@@ -88743,7 +88731,10 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
88743
88731
  id: agent2.id,
88744
88732
  label: agent2.label
88745
88733
  }));
88746
- const endpoint = options.pairingId.length > 0 ? mortyApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mortyApiUrl(options.relayOrigin, "/pairings/claim");
88734
+ const endpoint = mortyApiUrl(
88735
+ options.relayOrigin,
88736
+ `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`
88737
+ );
88747
88738
  let response;
88748
88739
  try {
88749
88740
  response = await fetch3(endpoint, {
@@ -88766,7 +88757,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
88766
88757
  if (!response.ok) {
88767
88758
  throw readRelayError(value);
88768
88759
  }
88769
- return options.pairingId.length > 0 ? decodePairingResponse(value, "runtimeCredential", REDEEM_RESPONSE_KEYS) : decodePairingResponse(value, "daemonToken", CLAIM_RESPONSE_KEYS);
88760
+ return decodePairingResponse(value);
88770
88761
  }
88771
88762
  function buildSavedRuntimeConfig(connection, defaultWorkspace, inventory, localContext) {
88772
88763
  const relayUrl = mortyApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
@@ -88835,7 +88826,7 @@ async function pairRuntimeConnection(installation, options, signal, environment)
88835
88826
  installation,
88836
88827
  {
88837
88828
  code: parsePairingCode(options.pairingCode),
88838
- pairingId: options.pairingId.length === 0 ? "" : validatePairingId(options.pairingId),
88829
+ pairingId: validatePairingId(options.pairingId),
88839
88830
  relayOrigin: parseRelayOrigin2(options.relayOrigin),
88840
88831
  workspace: options.defaultWorkspace
88841
88832
  },
@@ -92319,6 +92310,14 @@ var NativeSessionService = class {
92319
92310
  };
92320
92311
  };
92321
92312
 
92313
+ // src/engine/session/api/session-error.ts
92314
+ var SessionError = class extends OperationError {
92315
+ constructor(code, message, options = {}) {
92316
+ super(code, message, options);
92317
+ this.name = "SessionError";
92318
+ }
92319
+ };
92320
+
92322
92321
  // src/engine/session/prompt/prompt-artifacts.ts
92323
92322
  import { createHash as createHash7 } from "node:crypto";
92324
92323
  import { pathToFileURL as pathToFileURL2 } from "node:url";
@@ -92501,7 +92500,7 @@ var PromptLifecycle = class {
92501
92500
  /**
92502
92501
  * Publishes again an outcome a receipt already holds, for clients that missed it. The restatement is marked, so
92503
92502
  * status notifications do not take it for a new outcome, and it does not settle the receipt again. It keeps the
92504
- * time the outcome was recorded, which receivers that predate the marker report as when it ended; only an outcome
92503
+ * time the outcome was recorded; only an outcome
92505
92504
  * a receipt recorded is marked as such, so Recording can settle a Turn it missed from it and never from an
92506
92505
  * acknowledgement composed now.
92507
92506
  */
@@ -92587,6 +92586,11 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
92587
92586
  case "restated":
92588
92587
  projection.restateOutcome(cancellation.sessionId, cancelled.outcome);
92589
92588
  return;
92589
+ case "expired":
92590
+ throw new SessionError(
92591
+ "command_result_expired",
92592
+ "The command executed but its result is no longer retained"
92593
+ );
92590
92594
  case "unavailable":
92591
92595
  break;
92592
92596
  }
@@ -92896,16 +92900,7 @@ var ExecutionReceipts = class {
92896
92900
  return outcome2 === void 0 ? { kind: "unavailable" } : { kind: "restated", outcome: outcome2 };
92897
92901
  }
92898
92902
  case "expired":
92899
- return {
92900
- kind: "restated",
92901
- outcome: {
92902
- event: {
92903
- type: "lifecycle-metadata",
92904
- payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
92905
- },
92906
- recordedAt: void 0
92907
- }
92908
- };
92903
+ return { kind: "expired" };
92909
92904
  case "cancelled":
92910
92905
  return {
92911
92906
  kind: "restated",
@@ -93245,16 +93240,16 @@ var ActiveRuntimeTurn = class {
93245
93240
  return event;
93246
93241
  };
93247
93242
  snapshot = () => {
93248
- if (!this.#started()) {
93243
+ const startedAt = this.#startedAt();
93244
+ if (startedAt === void 0) {
93249
93245
  return null;
93250
93246
  }
93251
- const startedAt = this.#startedAt();
93252
93247
  return {
93253
93248
  commandId: decodeIdentifier(this.command.commandId),
93254
93249
  epoch: this.epoch,
93255
93250
  interaction: this.#interaction,
93256
93251
  sequence: this.#sequence,
93257
- ...startedAt === void 0 ? {} : { startedAt },
93252
+ startedAt,
93258
93253
  state: "running"
93259
93254
  };
93260
93255
  };
@@ -94634,14 +94629,6 @@ function createAgentCatalogCommands(context) {
94634
94629
  // src/engine/runtime/command/agent-settings-discovery.ts
94635
94630
  import { WebSocket as WebSocket4 } from "undici";
94636
94631
 
94637
- // src/engine/session/api/session-error.ts
94638
- var SessionError = class extends OperationError {
94639
- constructor(code, message, options = {}) {
94640
- super(code, message, options);
94641
- this.name = "SessionError";
94642
- }
94643
- };
94644
-
94645
94632
  // src/engine/session/settings/discover-agent-settings.ts
94646
94633
  import { createHash as createHash10 } from "node:crypto";
94647
94634
 
@@ -95438,6 +95425,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, queuedPromp
95438
95425
  return {
95439
95426
  events: {
95440
95427
  events: orderedEvents.map(({ event }) => event),
95428
+ promptOutcomes: [],
95441
95429
  nextCursor,
95442
95430
  sessionGenerationId,
95443
95431
  tailCursor: orderedEvents.at(-1)?.event.eventId ?? "",
@@ -95596,14 +95584,14 @@ var previewHistoryPageLoadCommand = {
95596
95584
  // src/engine/runtime/command/registry/interactions.ts
95597
95585
  var sessionCancelCommand = {
95598
95586
  kind: SESSION_CANCEL_KIND,
95599
- handle: ({ eventProjection, operations, sessions, sessionTurns, signal }, message) => {
95587
+ handle: ({ eventProjection, operations, sessions, sessionTurns, signal, socket }, message) => {
95600
95588
  if (message.kind !== SESSION_CANCEL_KIND) {
95601
95589
  throw new Error("Command kind mismatch");
95602
95590
  }
95603
95591
  const turn = sessionTurns.get(message.commandId, message.sessionId);
95604
95592
  if (turn === void 0) {
95605
95593
  void settleAbandonedTurn(eventProjection, operations, message).catch((error62) => {
95606
- console.error("Could not settle abandoned turn", error62);
95594
+ reportOperationFailure(socket, message.commandId, message.sessionId, error62);
95607
95595
  });
95608
95596
  return;
95609
95597
  }
@@ -95634,7 +95622,7 @@ var sessionCancelBeforeStartCommand = {
95634
95622
  const turn = sessionTurns.get(message.commandId, message.sessionId);
95635
95623
  if (turn === void 0) {
95636
95624
  const cancelled = operations.recordCancellationBeforeAdmission(message.commandId, message.sessionId);
95637
- const outcome = cancelled.kind === "unavailable" ? void 0 : cancelled.kind === "restated" ? cancelled.outcome.event : cancelled.outcome;
95625
+ const outcome = cancelled.kind === "unavailable" || cancelled.kind === "expired" ? void 0 : cancelled.kind === "restated" ? cancelled.outcome.event : cancelled.outcome;
95638
95626
  if (outcome?.type === "lifecycle-metadata" && outcome.payload.kind === "prompt.completed" && promptCompletion(outcome.payload).kind === "cancelled") {
95639
95627
  if (cancelled.kind === "restated") {
95640
95628
  eventProjection.restateOutcome(message.sessionId, cancelled.outcome);
@@ -95728,8 +95716,7 @@ function createNativeSessionRequestHandler(dependencies) {
95728
95716
  };
95729
95717
  const handle = (command) => {
95730
95718
  const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
95731
- const parallelRead = command.action === "active-turn";
95732
- if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
95719
+ if (pending.has(command.requestId) || pending.size >= 4) {
95733
95720
  reportOperationFailure(
95734
95721
  socket,
95735
95722
  command.requestId,
@@ -97937,4 +97924,4 @@ export {
97937
97924
  * MIT Licensed
97938
97925
  *)
97939
97926
  */
97940
- //# sourceMappingURL=chunk-MBS25BBY.js.map
97927
+ //# sourceMappingURL=chunk-OCDHOJ7L.js.map