@1agents/acp-service 0.8.0 → 0.8.2

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 (120) hide show
  1. package/README.md +42 -2
  2. package/dist/bin/a2a.js +3 -2
  3. package/dist/bin/acp-service.js +0 -0
  4. package/dist/src/a2a/executor.d.ts +2 -0
  5. package/dist/src/a2a/executor.js +96 -18
  6. package/dist/src/a2a/gateway.d.ts +407 -14
  7. package/dist/src/a2a/gateway.js +719 -37
  8. package/dist/src/a2a/index.d.ts +9 -1
  9. package/dist/src/a2a/index.js +5 -0
  10. package/dist/src/a2a/lease.d.ts +13 -0
  11. package/dist/src/a2a/lease.js +149 -0
  12. package/dist/src/a2a/notices.d.ts +24 -0
  13. package/dist/src/a2a/notices.js +56 -0
  14. package/dist/src/a2a/preflight.d.ts +52 -0
  15. package/dist/src/a2a/preflight.js +153 -0
  16. package/dist/src/a2a/request-id.d.ts +2 -0
  17. package/dist/src/a2a/request-id.js +6 -0
  18. package/dist/src/a2a/result-metadata.d.ts +59 -0
  19. package/dist/src/a2a/result-metadata.js +156 -0
  20. package/dist/src/a2a/server.js +43 -1
  21. package/dist/src/a2a/session-delivery.d.ts +69 -0
  22. package/dist/src/a2a/session-delivery.js +260 -0
  23. package/dist/src/a2a/session-hosts.d.ts +34 -0
  24. package/dist/src/a2a/session-hosts.js +211 -0
  25. package/dist/src/a2a/store.d.ts +4 -6
  26. package/dist/src/a2a/store.js +17 -115
  27. package/dist/src/a2a/types.d.ts +42 -0
  28. package/dist/src/acp-connection.d.ts +2 -1
  29. package/dist/src/acp-connection.js +52 -9
  30. package/dist/src/bridge.js +38 -39
  31. package/dist/src/execution/delivery-progress.d.ts +108 -0
  32. package/dist/src/execution/delivery-progress.js +57 -0
  33. package/dist/src/execution/ledger.d.ts +235 -0
  34. package/dist/src/execution/ledger.js +396 -0
  35. package/dist/src/execution/ppt-delivery.d.ts +231 -0
  36. package/dist/src/execution/ppt-delivery.js +625 -0
  37. package/dist/src/execution/targets.d.ts +349 -0
  38. package/dist/src/execution/targets.js +428 -0
  39. package/package.json +13 -13
  40. package/skills/acp-service/SKILL.md +9 -2
  41. package/skills/acp-service/references/a2a.md +72 -4
  42. package/vendor/dsh/README.md +12 -2
  43. package/vendor/dsh/a2a-executor.d.ts +9 -2
  44. package/vendor/dsh/a2a-executor.js +84 -16
  45. package/vendor/dsh/a2a.d.ts +2 -1
  46. package/vendor/dsh/a2a.js +10 -5
  47. package/vendor/dsh/adapter.d.ts +3 -1
  48. package/vendor/dsh/adapter.js +144 -16
  49. package/vendor/dsh/client.js +11 -3
  50. package/vendor/dsh/diagnostics.d.ts +42 -0
  51. package/vendor/dsh/diagnostics.js +176 -0
  52. package/vendor/dsh/index.d.ts +1 -0
  53. package/vendor/dsh/index.js +16 -4
  54. package/vendor/runtime/dist/{agent-registry-CMg8LHKY.js → agent-registry-R7A3MSpr.js} +9 -1
  55. package/vendor/runtime/dist/agent-registry-R7A3MSpr.js.map +1 -0
  56. package/vendor/runtime/dist/agent-registry.d.ts +1 -0
  57. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
  58. package/vendor/runtime/dist/agent-registry.js +1 -2
  59. package/vendor/runtime/dist/{cli-DUHyAADv.js → cli-DeOpE2Xz.js} +4 -4
  60. package/vendor/runtime/dist/{cli-DUHyAADv.js.map → cli-DeOpE2Xz.js.map} +1 -1
  61. package/vendor/runtime/dist/cli.d.ts +2 -1
  62. package/vendor/runtime/dist/cli.js +10 -10
  63. package/vendor/runtime/dist/cli.js.map +1 -1
  64. package/vendor/runtime/dist/{client-DjkWknf7.d.ts → client-VQsqcIOJ.d.ts} +2 -2
  65. package/vendor/runtime/dist/{client-DjkWknf7.d.ts.map → client-VQsqcIOJ.d.ts.map} +1 -1
  66. package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
  67. package/vendor/runtime/dist/docs-site/CLI.html +833 -0
  68. package/vendor/runtime/dist/docs-site/VISION.html +415 -0
  69. package/vendor/runtime/dist/docs-site/agents.html +391 -0
  70. package/vendor/runtime/dist/docs-site/compare.html +359 -0
  71. package/vendor/runtime/dist/docs-site/config.html +450 -0
  72. package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
  73. package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
  74. package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
  75. package/vendor/runtime/dist/docs-site/flows.html +498 -0
  76. package/vendor/runtime/dist/docs-site/index.html +367 -0
  77. package/vendor/runtime/dist/docs-site/install.html +386 -0
  78. package/vendor/runtime/dist/docs-site/llms.txt +36 -0
  79. package/vendor/runtime/dist/docs-site/output-formats.html +407 -0
  80. package/vendor/runtime/dist/docs-site/permissions.html +422 -0
  81. package/vendor/runtime/dist/docs-site/prompting.html +460 -0
  82. package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
  83. package/vendor/runtime/dist/docs-site/releasing.html +341 -0
  84. package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
  85. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +335 -0
  86. package/vendor/runtime/dist/docs-site/safe-errors.html +323 -0
  87. package/vendor/runtime/dist/docs-site/session-control.html +408 -0
  88. package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
  89. package/vendor/runtime/dist/docs-site/sessions.html +488 -0
  90. package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
  91. package/vendor/runtime/dist/{flows-CiJSCy4D.js → flows-oaBGn31w.js} +5 -5
  92. package/vendor/runtime/dist/{flows-CiJSCy4D.js.map → flows-oaBGn31w.js.map} +1 -1
  93. package/vendor/runtime/dist/flows.d.ts +2 -2
  94. package/vendor/runtime/dist/flows.d.ts.map +1 -1
  95. package/vendor/runtime/dist/flows.js +1 -2
  96. package/vendor/runtime/dist/{invocation-options-BlIySxIw.js → invocation-options-CUDEE8vW.js} +5 -5
  97. package/vendor/runtime/dist/{invocation-options-BlIySxIw.js.map → invocation-options-CUDEE8vW.js.map} +1 -1
  98. package/vendor/runtime/dist/{ipc-BlljKR2b.js → ipc-BQQpcEdP.js} +356 -20
  99. package/vendor/runtime/dist/ipc-BQQpcEdP.js.map +1 -0
  100. package/vendor/runtime/dist/{output-BzXQKArM.js → output-CFv3jcOQ.js} +86 -22
  101. package/vendor/runtime/dist/output-CFv3jcOQ.js.map +1 -0
  102. package/vendor/runtime/dist/{queue-owner-runtime-DSFdsS_y.js → queue-owner-runtime-DvMJiGbP.js} +86 -27
  103. package/vendor/runtime/dist/queue-owner-runtime-DvMJiGbP.js.map +1 -0
  104. package/vendor/runtime/dist/runtime.d.ts +28 -15
  105. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  106. package/vendor/runtime/dist/runtime.js +131 -63
  107. package/vendor/runtime/dist/runtime.js.map +1 -1
  108. package/vendor/runtime/dist/{session-options-ORCchZGk.d.ts → session-options-NjpFwf-c.d.ts} +22 -2
  109. package/vendor/runtime/dist/session-options-NjpFwf-c.d.ts.map +1 -0
  110. package/vendor/runtime/dist/{session-watch-BiBTBMz4.js → session-watch-Di-wIdCH.js} +4 -4
  111. package/vendor/runtime/dist/{session-watch-BiBTBMz4.js.map → session-watch-Di-wIdCH.js.map} +1 -1
  112. package/vendor/runtime/dist/{watch-iYiP-lOo.js → watch-CIpoMaWD.js} +2 -2
  113. package/vendor/runtime/dist/{watch-iYiP-lOo.js.map → watch-CIpoMaWD.js.map} +1 -1
  114. package/vendor/runtime/package.json +1 -1
  115. package/vendor/runtime/skills/acpx/SKILL.md +8 -2
  116. package/vendor/runtime/dist/agent-registry-CMg8LHKY.js.map +0 -1
  117. package/vendor/runtime/dist/ipc-BlljKR2b.js.map +0 -1
  118. package/vendor/runtime/dist/output-BzXQKArM.js.map +0 -1
  119. package/vendor/runtime/dist/queue-owner-runtime-DSFdsS_y.js.map +0 -1
  120. package/vendor/runtime/dist/session-options-ORCchZGk.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { AcpAgentInspection, AcpAgentInspectionOptions, AcpAgentRegistry, AcpInspectableAgentRegistry, DEFAULT_AGENT_NAME, createAgentRegistry } from "./agent-registry.js";
2
- import { A as GrokAskUserAnswers, C as PermissionPolicy, D as GrokExitPlanModeRequest, E as PromptInput, M as GrokAskUserQuestionResponse, O as GrokExitPlanModeResponse, S as PermissionMode, T as SessionRecord, _ as AcpProcessSpawnFailure, a as AcpElicitationHandler, b as McpServer$1, c as AcpElicitationResponse, d as AcpPermissionHandler, f as AcpPermissionRequest, g as AcpProcessLifecycle, h as AcpProcessLaunchScope, i as AcpElicitationContext, j as GrokAskUserQuestionRequest, k as GrokExitPlanOutcome, l as AcpJsonRpcMessage, m as AcpProcessLaunch, n as SystemPromptOption, o as AcpElicitationMode, p as AcpProcessExit, s as AcpElicitationRequest, t as SessionAgentOptions, u as AcpPermissionDecision, v as AcpProcessStarted, x as NonInteractivePermissionPolicy, y as AuthPolicy } from "./session-options-ORCchZGk.js";
3
- import { n as AcpControlAuthority, t as AcpClient } from "./client-DjkWknf7.js";
2
+ import { A as GrokExitPlanModeRequest, C as PermissionPolicy, D as SafeErrorOrigin, E as SafeErrorCategory, F as GrokAskUserQuestionResponse, M as GrokExitPlanOutcome, N as GrokAskUserAnswers, O as SessionRecord, P as GrokAskUserQuestionRequest, S as PermissionMode, T as SafeError, _ as AcpProcessSpawnFailure, a as AcpElicitationHandler, b as McpServer$1, c as AcpElicitationResponse, d as AcpPermissionHandler, f as AcpPermissionRequest, g as AcpProcessLifecycle, h as AcpProcessLaunchScope, i as AcpElicitationContext, j as GrokExitPlanModeResponse, k as PromptInput, l as AcpJsonRpcMessage, m as AcpProcessLaunch, n as SystemPromptOption, o as AcpElicitationMode, p as AcpProcessExit, s as AcpElicitationRequest, t as SessionAgentOptions, u as AcpPermissionDecision, v as AcpProcessStarted, x as NonInteractivePermissionPolicy, y as AuthPolicy } from "./session-options-NjpFwf-c.js";
3
+ import { n as AcpControlAuthority, t as AcpClient } from "./client-VQsqcIOJ.js";
4
4
  import { z } from "zod";
5
5
  import { SetSessionConfigOptionResponse, ToolCallContent, ToolCallLocation, ToolKind } from "@1agents/acp-runtime-sdk";
6
6
  //#region src/acp/model-support.d.ts
@@ -393,19 +393,10 @@ type AcpRuntimeEvent = {
393
393
  * Compatibility failure event emitted by runTurn(...). startTurn(...).events
394
394
  * does not emit terminal events; use AcpRuntimeTurn.result instead.
395
395
  */
396
- {
396
+ ({
397
397
  type: "error";
398
- message: string;
399
- code?: string;
400
- detailCode?: string;
401
- retryable?: boolean;
402
- };
403
- type AcpRuntimeTurnResultError = {
404
- message: string;
405
- code?: string;
406
- detailCode?: string;
407
- retryable?: boolean;
408
- };
398
+ } & AcpRuntimeTurnResultError);
399
+ type AcpRuntimeTurnResultError = Pick<SafeError, "message"> & Partial<Omit<SafeError, "message">>;
409
400
  type AcpRuntimeTurnResult = {
410
401
  status: "completed";
411
402
  stopReason?: string;
@@ -688,6 +679,10 @@ type RuntimeEnsureInput = {
688
679
  };
689
680
  type RuntimeTurnTaskState = {
690
681
  pendingCancel: boolean;
682
+ promptWritten: boolean;
683
+ authorityFailure?: {
684
+ error: unknown;
685
+ };
691
686
  turnActive: boolean;
692
687
  activeController: ActiveSessionController | null;
693
688
  };
@@ -767,6 +762,8 @@ declare class AcpRuntimeManager {
767
762
  private reuseRuntimeSession;
768
763
  private closeConflictingPersistentSession;
769
764
  private createOwnedRuntimeSession;
765
+ private abandonInitializingSessionOwner;
766
+ private settleRetiredSessionRecord;
770
767
  private prepareInitialRuntimeRecord;
771
768
  private retainInitializedSessionOwner;
772
769
  startTurn(input: RuntimeTurnTask["input"]): AcpRuntimeTurn;
@@ -843,6 +840,7 @@ declare class AcpRuntimeManager {
843
840
  discardPersistentState?: boolean;
844
841
  }): Promise<void>;
845
842
  private closeRuntimeSession;
843
+ private saveClosedRuntimeRecord;
846
844
  adoptSession(input: {
847
845
  handle: AcpRuntimeHandle;
848
846
  sessionKey: string;
@@ -951,6 +949,21 @@ export declare class AcpRuntimeError extends Error {
951
949
  }
952
950
  export declare function isAcpRuntimeError(value: unknown): value is AcpRuntimeError;
953
951
  //#endregion
952
+ //#region src/acp/error-normalization.d.ts
953
+ type SafeErrorOptions = {
954
+ origin?: SafeErrorOrigin;
955
+ /** A caller-owned request identifier, never a provider message. */
956
+ operationId?: string;
957
+ outcomeUnknown?: boolean;
958
+ /** Decode only a direct safe record from an owned boundary, never provider data. */
959
+ trustedProjection?: boolean;
960
+ };
961
+ /**
962
+ * Public bridge projection. No provider text, URLs, arbitrary data or unknown
963
+ * codes are copied. Resource categories describe failures, not retry policy.
964
+ */
965
+ export declare function toSafeError(error: unknown, options?: SafeErrorOptions): SafeError;
966
+ //#endregion
954
967
  //#region src/runtime/public/shared.d.ts
955
968
  type AcpxHandleState = {
956
969
  name: string;
@@ -1160,5 +1173,5 @@ export declare function createRuntimeStore(options: {
1160
1173
  stateDir: string;
1161
1174
  }): AcpSessionStore;
1162
1175
  //#endregion
1163
- export { type AcpAgentInspection, type AcpAgentInspectionOptions, type AcpAgentRegistry, type AcpElicitationContext, type AcpElicitationHandler, type AcpElicitationMode, type AcpElicitationRequest, type AcpElicitationResponse, type AcpFileSessionStoreOptions, type AcpInspectableAgentRegistry, type AcpPermissionDecision, type AcpPermissionHandler, type AcpPermissionRequest, type AcpProcessExit, type AcpProcessLaunch, type AcpProcessLaunchScope, type AcpProcessLifecycle, type AcpProcessSpawnFailure, type AcpProcessStarted, type AcpRuntime, type AcpRuntimeAvailableCommand, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePlanEntry, type AcpRuntimePromptMode, type AcpRuntimeSessionContext, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeSessionPermissions, type AcpRuntimeSessionUsage, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpRuntimeUsageBreakdown, type AcpRuntimeUsageCost, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, type AcpTextDeltaOriginMeta, type AcpTurnJournalMutation, type AcpTurnJournalRecordResult, type AcpTurnJournalSnapshot, type AcpTurnJournalStatus, type AcpTurnJournalTurn, DEFAULT_AGENT_NAME, type InspectAgentModelsOptions, type PermissionPolicy, type RequestedModelUnsupportedErrorCode, type RequestedModelUnsupportedReason, type SessionAgentOptions, type SessionWatchEvent, type SessionWatchResult, type SharedAcpRuntimeOptions, type SystemPromptOption, createAgentRegistry };
1176
+ export { type AcpAgentInspection, type AcpAgentInspectionOptions, type AcpAgentRegistry, type AcpElicitationContext, type AcpElicitationHandler, type AcpElicitationMode, type AcpElicitationRequest, type AcpElicitationResponse, type AcpFileSessionStoreOptions, type AcpInspectableAgentRegistry, type AcpPermissionDecision, type AcpPermissionHandler, type AcpPermissionRequest, type AcpProcessExit, type AcpProcessLaunch, type AcpProcessLaunchScope, type AcpProcessLifecycle, type AcpProcessSpawnFailure, type AcpProcessStarted, type AcpRuntime, type AcpRuntimeAvailableCommand, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePlanEntry, type AcpRuntimePromptMode, type AcpRuntimeSessionContext, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeSessionPermissions, type AcpRuntimeSessionUsage, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpRuntimeUsageBreakdown, type AcpRuntimeUsageCost, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, type AcpTextDeltaOriginMeta, type AcpTurnJournalMutation, type AcpTurnJournalRecordResult, type AcpTurnJournalSnapshot, type AcpTurnJournalStatus, type AcpTurnJournalTurn, DEFAULT_AGENT_NAME, type InspectAgentModelsOptions, type PermissionPolicy, type RequestedModelUnsupportedErrorCode, type RequestedModelUnsupportedReason, type SafeError, type SafeErrorCategory, type SafeErrorOrigin, type SessionAgentOptions, type SessionWatchEvent, type SessionWatchResult, type SharedAcpRuntimeOptions, type SystemPromptOption, createAgentRegistry };
1164
1177
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","names":[],"sources":["../src/acp/model-support.ts","../src/acp/config-option-support.ts","../src/acp/mode-support.ts","../src/session/journal.ts","../src/runtime/public/contract.ts","../src/runtime/public/probe.ts","../src/runtime/engine/turn.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/turn-journal.ts","../src/runtime/public/errors.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime/shared.ts","../src/runtime.ts"],"mappings":";;;;;;qBAea;KAED,4CAA4C;qBAE3C;KAKD,0CAA0C;qBAEzC,uCAAuC;WACzC;WACA,QAAQ;WACR;EAGP,YAAA,iBACA,QAAQ,iCACR;IAAY;;;wBAoBA,iCACd,iBACC,SAAS;;;KCxDA;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA,SAAS;;;;KCXC;EACV;EACA;EACA;;KAGU;EACV;EACA,gBAAgB;;;;KCIN;EAEN;EACA;EACA,QAAQ;;EAGR;EACA;IAAS;IAAiB;IAAe;IAAqB;;;KAGxD;EAAsB;;EAC5B;EAAiB;EAA0B,SAAS;;EACpD;EAAsB;;EACtB;EAAqB;EAAmB,QAAQ;;;;;;;;;KCuC1C;KAEA;KAEA;KAaA;KAMA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,MAAM;EACN;EACA;;;;;;;;;EASA,iBAAiB;;EAEjB;;EAEA,kBAAkB;;KAGR;;;;;EAKV;EACA;;;;;;KAOU,sBAAsB;EAChC,QAAQ;EACR;EACA,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MACE;EAQJ,YAAY;UAeE;UAkBA;UAmBN;UAcA;;wBA+BM,iBAAiB,SAAS,oBAAoB;wBAI9C,mBAAmB;EAAW;IAAqB"}
1
+ {"version":3,"file":"runtime.d.ts","names":["McpServer","_$__public_contract_js0.AcpRuntimeEvent","_$__public_contract_js0.AcpRuntimeStatus","_$___runtime_js0.SessionWatchEvent","_$__runtime_js0.AcpRuntimeTurnResult"],"sources":["../src/acp/model-support.ts","../src/acp/config-option-support.ts","../src/acp/mode-support.ts","../src/session/journal.ts","../src/runtime/public/contract.ts","../src/runtime/public/probe.ts","../src/runtime/engine/turn.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/turn-journal.ts","../src/runtime/public/errors.ts","../src/acp/error-normalization.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime/shared.ts","../src/runtime.ts"],"mappings":";;;;;;qBAea;KAED,4CAA4C;qBAE3C;KAKD,0CAA0C;qBAEzC,uCAAuC;WACzC;WACA,QAAQ;WACR;EAGP,YAAA,iBACA,QAAQ,iCACR;IAAY;;;wBAoBA,iCACd,iBACC,SAAS;;;KCxDA;EACV;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA,SAAS;;;;KCXC;EACV;EACA;EACA;;KAGU;EACV;EACA,gBAAgB;;;;KCUN;EAEN;EACA;EACA,QAAQ;;EAGR;EACA;IAAS;IAAiB;IAAe;IAAqB;;;KAGxD;EAAsB;;EAC5B;EAAiB;EAA0B,SAAS;;EACpD;EAAsB;;EACtB;EAAqB;EAAmB,QAAQ;;;;;;;;;KCkC1C;KAEA;KAEA;KAaA;KAMA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,MAAM;EACN;EACA;;;;;;;;;EASA,iBAAiB;;EAEjB;;EAEA,kBAAkB;;KAGR;;;;;EAKV;EACA;;;;;;KAOU,sBAAsB;EAChC,QAAQ;EACR;EACA,cAAc;EACd,MAAM;EACN;EACA;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,OAAO;IAAS,QAAQ;IAAkB;MAAoB;EAM9D,oBAAoB;IAAS,QAAQ;MAAqB;EAM1D,MAAM;IACV,QAAQ;IACR;IACA;MACE;EAQJ,YAAY;UAeE;UAkBA;UAmBN;UAcA;;wBA+BM,iBAAiB,SAAS,oBAAoB;wBAI9C,mBAAmB;EAAW;IAAqB"}
@@ -1,28 +1,13 @@
1
- import { A as findSession, B as assertPersistedKeyPolicy, C as textPrompt, Ct as normalizeOutputError, H as serializeSessionRecordForDisk, L as readSessionRecord, R as resolveSessionRecord, Tt as isAcpResourceNotFoundError, V as parseSessionRecord, gt as writePrivateJsonFile, t as tryCancelOnRunningOwner, ut as defaultSessionEventLog, wt as extractAcpError } from "./ipc-BlljKR2b.js";
2
- import { a as createAgentRegistry, i as DEFAULT_AGENT_NAME, k as normalizeAgentCommandInput } from "./agent-registry-CMg8LHKY.js";
3
- import { $ as isRequestedModelUnsupportedError, A as applyInitialModelSelection, B as reconcileAgentSessionId, C as setSessionModeOnOwner, D as connectAndLoadSession, E as withConnectedSession, F as persistSessionOptions, G as recordSessionUpdate, I as sessionOptionsFromRecord, J as advertisedModelState, K as trimConversationForRuntime, L as applyConversation, M as applyRequestedModelIfAdvertised, N as setDesiredModeId, O as applyConfigOptionSelection, P as normalizeSessionOptionShape, Q as RequestedModelUnsupportedError, R as applyLifecycleSnapshotToRecord, T as setSessionModelOnOwner, U as recordClientOperation, V as cloneSessionConversation, W as recordPromptSubmission, X as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, Y as AcpClient, Z as REQUESTED_MODEL_UNSUPPORTED_REASONS, _ as cancelSessionPrompt, c as LiveSessionCheckpoint, dt as TimeoutError, et as resolveRequestedConfigOption, ft as assertControlAuthority, h as ensureSession, j as applyModelSelection, k as applyConfigOptionsToRecord, l as runPromptTurn, mt as withTimeout, q as cloneSessionAcpxState, r as sendSession, s as DISCARD_OUTPUT_FORMATTER, tt as resolveRequestedModelId, v as closeSession, x as setSessionConfigOptionOnOwner, z as createInitialSessionRecord } from "./queue-owner-runtime-DSFdsS_y.js";
4
- import { t as watchSession } from "./watch-iYiP-lOo.js";
1
+ import { A as findSession, At as extractAcpError, B as assertPersistedKeyPolicy, Bt as isAcpRuntimeError, C as textPrompt, Dt as normalizeOutputError, L as readSessionRecord, Ot as safeErrorRejection, R as resolveSessionRecord, U as serializeSessionRecordForDisk, V as parseSessionRecord, bt as writePrivateJsonFile, ft as defaultSessionEventLog, jt as isAcpResourceNotFoundError, kt as toSafeError, t as tryCancelOnRunningOwner, zt as AcpRuntimeError } from "./ipc-BQQpcEdP.js";
2
+ import { a as createAgentRegistry, i as DEFAULT_AGENT_NAME, k as normalizeAgentCommandInput } from "./agent-registry-R7A3MSpr.js";
3
+ import { $ as isRequestedModelUnsupportedError, A as applyInitialModelSelection, B as reconcileAgentSessionId, C as setSessionModeOnOwner, D as connectAndLoadSession, E as withConnectedSession, F as persistSessionOptions, G as recordSessionUpdate, I as sessionOptionsFromRecord, J as advertisedModelState, K as trimConversationForRuntime, L as applyConversation, M as applyRequestedModelIfAdvertised, N as setDesiredModeId, O as applyConfigOptionSelection, P as normalizeSessionOptionShape, Q as RequestedModelUnsupportedError, R as applyLifecycleSnapshotToRecord, T as setSessionModelOnOwner, U as recordClientOperation, V as cloneSessionConversation, W as recordPromptSubmission, X as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, Y as AcpClient, Z as REQUESTED_MODEL_UNSUPPORTED_REASONS, _ as cancelSessionPrompt, c as LiveSessionCheckpoint, dt as TimeoutError, et as resolveRequestedConfigOption, ft as assertControlAuthority, h as ensureSession, j as applyModelSelection, k as applyConfigOptionsToRecord, l as runPromptTurn, mt as withTimeout, q as cloneSessionAcpxState, r as sendSession, s as DISCARD_OUTPUT_FORMATTER, tt as resolveRequestedModelId, v as closeSession, x as setSessionConfigOptionOnOwner, z as createInitialSessionRecord } from "./queue-owner-runtime-DvMJiGbP.js";
4
+ import { t as watchSession } from "./watch-CIpoMaWD.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "node:path";
7
7
  import fs from "node:fs/promises";
8
8
  import { z } from "zod";
9
9
  import { createHash, randomUUID } from "node:crypto";
10
10
  import { isDeepStrictEqual } from "node:util";
11
- //#region src/runtime/public/errors.ts
12
- var AcpRuntimeError = class extends Error {
13
- code;
14
- cause;
15
- constructor(code, message, options) {
16
- super(message);
17
- this.name = "AcpRuntimeError";
18
- this.code = code;
19
- this.cause = options?.cause;
20
- }
21
- };
22
- function isAcpRuntimeError(value) {
23
- return value instanceof AcpRuntimeError;
24
- }
25
- //#endregion
26
11
  //#region src/runtime/engine/controls.ts
27
12
  function advertisedConfigOptionIds(record) {
28
13
  const configOptions = record?.acpx?.config_options;
@@ -1209,8 +1194,30 @@ async function startRuntimeClient(client, agent, timeoutMs) {
1209
1194
  await withTimeout(client.start(), timeoutMs);
1210
1195
  } catch (error) {
1211
1196
  if (!(error instanceof TimeoutError)) throw error;
1212
- throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", `ACP agent ${path.basename(agent.agentArgv?.[0] ?? agent.agentCommand.split(/\s+/)[0])} did not complete ACP initialization within ${timeoutMs}ms. Check that the configured command starts an ACP server.`, { cause: error });
1197
+ const executable = path.basename(agent.agentArgv?.[0] ?? agent.agentCommand.split(/\s+/)[0]);
1198
+ throw new AcpRuntimeError("ACP_SESSION_INIT_FAILED", `ACP agent ${executable} did not complete ACP initialization within ${timeoutMs}ms. Check that the configured command starts an ACP server.`, { cause: error });
1199
+ }
1200
+ }
1201
+ function observeTurnAuthority(input, state) {
1202
+ if (!input.assertActive) return input;
1203
+ return {
1204
+ ...input,
1205
+ assertActive: () => {
1206
+ try {
1207
+ input.assertActive?.();
1208
+ } catch (error) {
1209
+ state.authorityFailure = { error };
1210
+ throw error;
1211
+ }
1212
+ }
1213
+ };
1214
+ }
1215
+ function runtimeFailureRejection(task, error, safe) {
1216
+ if (task.state.authorityFailure && task.state.authorityFailure.error === error) {
1217
+ if (error instanceof Error) safe.message = error.message;
1218
+ return error;
1213
1219
  }
1220
+ return safeErrorRejection(safe);
1214
1221
  }
1215
1222
  async function createOrLoadRuntimeSession(client, resumeSessionId, cwd) {
1216
1223
  if (resumeSessionId) {
@@ -1399,7 +1406,7 @@ var AcpRuntimeManager = class {
1399
1406
  owner.client.setEventHandlers({ onSessionUpdate: (notification) => this.routeOwnedSessionUpdate(owner, notification) });
1400
1407
  }
1401
1408
  async saveSessionOwner(owner) {
1402
- if (!owner.recordId) return;
1409
+ if (!owner.recordId || owner.pendingResetRecord) return;
1403
1410
  const active = owner.activeTurn?.turn;
1404
1411
  const target = active ?? owner.projection;
1405
1412
  if (!target) return;
@@ -1502,11 +1509,18 @@ var AcpRuntimeManager = class {
1502
1509
  const flushAttempt = await settleAttempt(async () => this.flushSessionOwner(owner));
1503
1510
  const closeAttempt = await settleAttempt(async () => this.closeClient(owner.client));
1504
1511
  if (!closeAttempt.ok) this.retiringSessionOwners.add(owner);
1512
+ const finalFlushAttempt = await settleAttempt(async () => owner.checkpoint.flush());
1513
+ const clearAttempt = await settleAttempt(() => owner.client.clearEventHandlers());
1514
+ const settleRecordAttempt = await settleAttempt(async () => {
1515
+ if (closeAttempt.ok) await this.settleRetiredSessionRecord(owner);
1516
+ });
1517
+ if (!settleRecordAttempt.ok) this.retiringSessionOwners.add(owner);
1505
1518
  return firstFailedAttempt([
1506
1519
  flushAttempt,
1507
1520
  closeAttempt,
1508
- await settleAttempt(async () => owner.checkpoint.flush()),
1509
- await settleAttempt(() => owner.client.clearEventHandlers())
1521
+ finalFlushAttempt,
1522
+ clearAttempt,
1523
+ settleRecordAttempt
1510
1524
  ]);
1511
1525
  }
1512
1526
  async retrySessionCleanup(recordId) {
@@ -1514,7 +1528,8 @@ var AcpRuntimeManager = class {
1514
1528
  owner.retirement ??= this.finalizeSessionConnection({
1515
1529
  client: owner.client,
1516
1530
  owner
1517
- }).then(() => {
1531
+ }).then(async () => {
1532
+ await this.settleRetiredSessionRecord(owner);
1518
1533
  this.retiringSessionOwners.delete(owner);
1519
1534
  }).finally(() => {
1520
1535
  owner.retirement = void 0;
@@ -1708,6 +1723,7 @@ var AcpRuntimeManager = class {
1708
1723
  return await this.withManagerLock(this.runtimeOperationLocks, input.sessionKey, async () => this.acquireRuntimeSession(input, agent));
1709
1724
  }
1710
1725
  async reuseCompatiblePersistentSession(input, agent) {
1726
+ await this.retrySessionCleanup(input.sessionKey);
1711
1727
  const controlled = this.controlSessionRecords.get(input.sessionKey);
1712
1728
  const record = controlled ? controlled.record : await this.findSession(input.sessionKey);
1713
1729
  if (!record || this.closingActiveRecords.has(input.sessionKey) || !shouldReuseExistingRecord(record, {
@@ -1804,7 +1820,6 @@ var AcpRuntimeManager = class {
1804
1820
  sessionKey: input.sessionKey,
1805
1821
  mode: input.mode
1806
1822
  });
1807
- let retained = false;
1808
1823
  try {
1809
1824
  await startRuntimeClient(client, agent, this.options.timeoutMs);
1810
1825
  this.assertOpen();
@@ -1820,22 +1835,39 @@ var AcpRuntimeManager = class {
1820
1835
  });
1821
1836
  this.setTransientCredentials(record.acpxRecordId, input.authCredentials);
1822
1837
  await this.retainInitializedSessionOwner(owner, record);
1823
- retained = true;
1824
1838
  return record;
1825
- } finally {
1826
- if (!retained) {
1827
- owner.recordId = void 0;
1828
- client.clearEventHandlers();
1829
- await this.closeClient(client);
1830
- }
1839
+ } catch (error) {
1840
+ await settleAttempt(async () => this.abandonInitializingSessionOwner(owner));
1841
+ throw error;
1831
1842
  }
1832
1843
  }
1844
+ async abandonInitializingSessionOwner(owner) {
1845
+ const record = owner.recordId ? owner.projection?.record : void 0;
1846
+ owner.pendingResetRecord = record;
1847
+ await settleAttempt(() => owner.client.clearEventHandlers());
1848
+ const closeAttempt = await settleAttempt(async () => this.closeClient(owner.client));
1849
+ if (!record) return;
1850
+ this.retiringSessionOwners.add(owner);
1851
+ if (closeAttempt.ok) {
1852
+ await this.settleRetiredSessionRecord(owner);
1853
+ this.retiringSessionOwners.delete(owner);
1854
+ }
1855
+ }
1856
+ async settleRetiredSessionRecord(owner) {
1857
+ const record = owner.pendingResetRecord;
1858
+ if (!record) return;
1859
+ applyLifecycleSnapshotToRecord(record, owner.client.getAgentLifecycleSnapshot());
1860
+ await this.saveClosedRuntimeRecord(record, true);
1861
+ owner.pendingResetRecord = void 0;
1862
+ owner.recordId = void 0;
1863
+ }
1833
1864
  async prepareInitialRuntimeRecord(params) {
1834
1865
  const { input, client, owner, agentCommand, agentArgv, cwd, session } = params;
1835
1866
  const record = createInitialSessionRecord({
1836
1867
  recordId: createRecordId(input.sessionKey, input.mode),
1837
1868
  name: input.sessionKey,
1838
1869
  sessionId: session.sessionId,
1870
+ sessionOrigin: input.resumeSessionId ? "resume" : "new",
1839
1871
  agentCommand,
1840
1872
  agentArgv,
1841
1873
  cwd,
@@ -1889,6 +1921,7 @@ var AcpRuntimeManager = class {
1889
1921
  let resultSettled = false;
1890
1922
  const state = {
1891
1923
  pendingCancel: false,
1924
+ promptWritten: false,
1892
1925
  turnActive: true,
1893
1926
  activeController: null
1894
1927
  };
@@ -1915,7 +1948,7 @@ var AcpRuntimeManager = class {
1915
1948
  };
1916
1949
  if (input.signal && !input.signal.aborted) input.signal.addEventListener("abort", abortHandler, { once: true });
1917
1950
  this.queueSessionTask(input.handle.acpxRecordId ?? input.handle.sessionKey, async () => this.runRuntimeTurnTask({
1918
- input,
1951
+ input: observeTurnAuthority(input, state),
1919
1952
  promptInput,
1920
1953
  queue,
1921
1954
  promptStarted,
@@ -1983,16 +2016,18 @@ var AcpRuntimeManager = class {
1983
2016
  * turn-results snapshot because that save would fail too.
1984
2017
  */
1985
2018
  finalizationFailureResult(task, error) {
1986
- task.promptStarted.reject(error);
1987
- task.sessionReady.reject(error);
1988
- const normalized = normalizeOutputError(error, { origin: "runtime" });
2019
+ const normalized = toSafeError(error, {
2020
+ origin: "runtime",
2021
+ operationId: task.input.requestId
2022
+ });
2023
+ const rejection = runtimeFailureRejection(task, error, normalized);
2024
+ task.promptStarted.reject(rejection);
2025
+ task.sessionReady.reject(rejection);
1989
2026
  return {
1990
2027
  status: "failed",
1991
2028
  error: {
1992
- message: normalized.message,
1993
- ...normalized.code ? { code: normalized.code } : {},
1994
- ...normalized.detailCode ? { detailCode: normalized.detailCode } : {},
1995
- ...normalized.retryable !== void 0 ? { retryable: normalized.retryable } : {}
2029
+ code: "RUNTIME",
2030
+ ...normalized
1996
2031
  }
1997
2032
  };
1998
2033
  }
@@ -2011,7 +2046,10 @@ var AcpRuntimeManager = class {
2011
2046
  timeoutMs: task.input.timeoutMs ?? this.options.timeoutMs,
2012
2047
  conversation: turn.conversation,
2013
2048
  promptMessageId: turn.promptMessageId,
2014
- onPromptRequestWritten: () => task.promptStarted.resolve(),
2049
+ onPromptRequestWritten: () => {
2050
+ task.state.promptWritten = true;
2051
+ task.promptStarted.resolve();
2052
+ },
2015
2053
  onElicitation: task.input.onElicitation,
2016
2054
  onPermissionRequest: task.input.onPermissionRequest,
2017
2055
  authority: task.input
@@ -2247,6 +2285,7 @@ var AcpRuntimeManager = class {
2247
2285
  record: turn.record,
2248
2286
  resumePolicy: resumePolicyForSessionMode(task.input.sessionMode),
2249
2287
  timeoutMs: this.options.timeoutMs,
2288
+ promptRecorded: true,
2250
2289
  activeController: task.state.activeController,
2251
2290
  onClientAvailable: () => this.publishRuntimeTurnController(task, turn),
2252
2291
  onConnectedRecord: (connectedRecord) => {
@@ -2306,17 +2345,20 @@ var AcpRuntimeManager = class {
2306
2345
  await this.saveCompletedRuntimeTurn(turn);
2307
2346
  }
2308
2347
  async failRuntimeTurn(task, turn, error) {
2309
- task.promptStarted.reject(error);
2310
- task.sessionReady.reject(error);
2311
- const normalized = normalizeOutputError(error, { origin: "runtime" });
2348
+ const normalized = toSafeError(error, {
2349
+ origin: "runtime",
2350
+ operationId: task.input.requestId,
2351
+ outcomeUnknown: task.state.promptWritten && !extractAcpError(error)
2352
+ });
2353
+ const rejection = runtimeFailureRejection(task, error, normalized);
2354
+ task.promptStarted.reject(rejection);
2355
+ task.sessionReady.reject(rejection);
2312
2356
  if (turn) await this.saveTerminalRuntimeTurn(turn, "failed", "runtime_error", normalized.code ?? normalized.detailCode).catch(() => {});
2313
2357
  return {
2314
2358
  status: "failed",
2315
2359
  error: {
2316
- message: normalized.message,
2317
- ...normalized.code ? { code: normalized.code } : {},
2318
- ...normalized.detailCode ? { detailCode: normalized.detailCode } : {},
2319
- ...normalized.retryable !== void 0 ? { retryable: normalized.retryable } : {}
2360
+ code: "RUNTIME",
2361
+ ...normalized
2320
2362
  }
2321
2363
  };
2322
2364
  }
@@ -2381,7 +2423,11 @@ var AcpRuntimeManager = class {
2381
2423
  async *runTurn(input) {
2382
2424
  const turn = this.startTurn(input);
2383
2425
  yield* turn.events;
2384
- yield legacyTerminalEventFromTurnResult(await turn.result);
2426
+ const result = await turn.result;
2427
+ yield result.status === "failed" ? {
2428
+ type: "error",
2429
+ ...result.error
2430
+ } : legacyTerminalEventFromTurnResult(result);
2385
2431
  }
2386
2432
  getStatus(handle) {
2387
2433
  this.assertOpen();
@@ -2534,9 +2580,22 @@ var AcpRuntimeManager = class {
2534
2580
  const record = await this.resolveRuntimeRecordForClose(recordId);
2535
2581
  this.markActiveRuntimeRecordClosing(record);
2536
2582
  if (intent !== "prepare-fresh") await this.cancelSessionTasks(recordId);
2537
- await this.closeRuntimeRecordOwnership(record, intent);
2583
+ const closeFailure = await this.closeRuntimeRecordOwnership(record, intent);
2584
+ if (intent === "discard") {
2585
+ if (closeFailure) throw closeFailure.error;
2586
+ return;
2587
+ }
2588
+ const saveAttempt = await settleAttempt(async () => this.saveClosedRuntimeRecord(record, intent !== "release"));
2589
+ const failure = closeFailure ?? firstFailedAttempt([saveAttempt]);
2590
+ if (failure) throw failure.error;
2591
+ }
2592
+ async saveClosedRuntimeRecord(record, reset) {
2538
2593
  record.closed = true;
2539
2594
  record.closedAt = isoNow();
2595
+ if (reset) record.acpx = {
2596
+ ...record.acpx,
2597
+ reset_on_next_ensure: true
2598
+ };
2540
2599
  await this.options.sessionStore.save(record);
2541
2600
  this.transientCredentials.delete(record.acpxRecordId);
2542
2601
  }
@@ -2611,7 +2670,7 @@ var AcpRuntimeManager = class {
2611
2670
  if (this.activeControllers.has(record.acpxRecordId)) this.closingActiveRecords.add(record.acpxRecordId);
2612
2671
  }
2613
2672
  async closeRuntimeRecordOwnership(record, intent) {
2614
- if (intent === "discard") await this.closeBackendSession(record);
2673
+ if (intent === "discard") return await this.closeBackendSession(record);
2615
2674
  else if (intent === "prepare-fresh") {
2616
2675
  const owner = this.retainedSessionOwners.get(record.acpxRecordId);
2617
2676
  if (owner) {
@@ -2620,20 +2679,29 @@ var AcpRuntimeManager = class {
2620
2679
  }
2621
2680
  await this.retrySessionCleanup(record.acpxRecordId);
2622
2681
  } else await this.closeRetainedSessionOwner(record.acpxRecordId);
2623
- if (intent !== "release") record.acpx = {
2624
- ...record.acpx,
2625
- reset_on_next_ensure: true
2626
- };
2627
2682
  }
2628
2683
  async closeBackendSession(record) {
2629
2684
  const connection = await this.acquireBackendCloseConnection(record);
2630
- try {
2631
- await this.requestBackendSessionClose(record, connection);
2632
- } catch (error) {
2633
- this.handleBackendSessionCloseError(record, error);
2634
- } finally {
2635
- await this.finalizeSessionConnection(connection);
2636
- }
2685
+ const requestAttempt = await settleAttempt(async () => {
2686
+ try {
2687
+ await this.requestBackendSessionClose(record, connection);
2688
+ } catch (error) {
2689
+ this.handleBackendSessionCloseError(record, error);
2690
+ }
2691
+ });
2692
+ const owner = connection.owner ?? this.createSessionOwner({
2693
+ client: connection.client,
2694
+ sessionKey: record.acpxRecordId,
2695
+ mode: "persistent"
2696
+ });
2697
+ owner.recordId = record.acpxRecordId;
2698
+ const finalizeAttempt = await settleAttempt(async () => this.finalizeSessionConnection(connection));
2699
+ owner.pendingResetRecord = record;
2700
+ this.retiringSessionOwners.add(owner);
2701
+ if (!finalizeAttempt.ok) throw finalizeAttempt.error;
2702
+ const saveAttempt = await settleAttempt(async () => this.settleRetiredSessionRecord(owner));
2703
+ if (saveAttempt.ok) this.retiringSessionOwners.delete(owner);
2704
+ return firstFailedAttempt([requestAttempt, saveAttempt]);
2637
2705
  }
2638
2706
  async finalizeSessionConnection(connection) {
2639
2707
  const failure = firstFailedAttempt([
@@ -3672,6 +3740,6 @@ function createRuntimeStore(options) {
3672
3740
  return createFileSessionStore(options);
3673
3741
  }
3674
3742
  //#endregion
3675
- export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, SharedAcpRuntime, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, createSharedAcpRuntime, createTurnJournal, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, inspectAgentModels, isAcpRuntimeError, isRequestedModelUnsupportedError };
3743
+ export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, SharedAcpRuntime, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, createSharedAcpRuntime, createTurnJournal, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, inspectAgentModels, isAcpRuntimeError, isRequestedModelUnsupportedError, toSafeError };
3676
3744
 
3677
3745
  //# sourceMappingURL=runtime.js.map