@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
@@ -83,11 +83,21 @@ ACP one-shot tool permissions use DSH's approval UI and policy. Grok questions a
83
83
 
84
84
  Transport reconnects load the same service session and replay the current managed turn. Stable request IDs prevent duplicate execution, and update sequence numbers suppress duplicate output. A browser refresh leaves the Host request running. Stopping a DSH turn sends ACP cancellation. Provider errors fail the turn without automatic resubmission.
85
85
 
86
+ The owned ACP Adapter sanitizes provider failures before the official DSH host normalizes them. Category, provider code, retryability, outcome uncertainty, origin and request identity are persisted in the plugin's `oneagents_acp_diagnostics` domain, using official `storageDomain` and JSON storage plugins. The plugin owns their lifetime so cancellation and A2A drain before storage closes. DSH source, native `LlmFailure` and Session event schemas stay unchanged; its ordinary logs can retain only code and message. Complete diagnostics appear under A2A `metadata['1agents'].error`, with the A2A caller's operation identity. Host error properties and arbitrary in-band metadata cannot supply missing diagnostics.
87
+
88
+ Each attempt is bound to its DSH session, turn/start sequence, step/start sequence, input message identities and native request identity. Only user messages admitted in the current turn establish association; each identity is at most 256 characters and each identity list at most 128 entries. Oversized identities fail before native delivery. Records contain only bounded safe fields, never provider text, credentials or authentication URLs. A newer pending attempt cannot borrow an older failure. The storage owner-token lease rejects concurrent writers and reclaims only demonstrably dead owners after restart. Invalid versions or records fail initialization without deleting evidence. Writes resolve after durability; a storage failure fails the call instead of acknowledging diagnostics that were not saved.
89
+
90
+ Confirmed remote cancellation reports `cancelled` with `outcomeUnknown: false`. A received terminal RPC reply establishes the outcome even when local cancellation races with its delivery; no further output is emitted after cancellation. A submitted request without a terminal reply remains uncertain, while work cancelled before delivery is certain. Claimed disposal without a result remains uncertain. Root teardown waits for the official Agent idle barrier if subscriptions disappear before the final event. Cancellation does not automatically resubmit, and a racing local abort does not replace a received provider error.
91
+
92
+ A2A startup reconciles interrupted tasks using their saved context and exact task/message request identity. A durable plugin failure restores its safe fields; an unfinished submitted attempt stays unknown. Reconciliation records a failed interrupted task and never dispatches execution. Already terminal tasks remain unchanged. Historical host logs without plugin diagnostics cannot reconstruct missing fields, and other DSH providers are not classified from host error text.
93
+
86
94
  This plugin supports **text prompts**. Attachments and specialized external-tool cards are not implemented. Auxiliary DSH title/compaction calls cannot use this adapter; an advertised native compaction command runs in the external Agent. Existing standard-preset sessions that selected an old ACP route must choose a normal DSH model or start a new ACP-preset session.
87
95
 
88
96
  ## Configuration
89
97
 
90
- The bundle's `oneagents-acp` row accepts `serviceUrl`, `serviceMode`, `serviceStartupTimeoutMs`, `serviceShutdownTimeoutMs`, `agents`, `stateDirectory`, `reconnectAttempts` and `reconnectDelayMs`. Change it through the profile's `cordis.patch.yml`, not the DSH repository. Use a new session after changing endpoint or workspace. When `agents` is omitted, plugin startup fetches `GET /agents` from acp-service and registers presets for entries with `chat_ready: true`, using their service-provided names. Discovery runs on the service host. Restart the plugin after installing or removing a harness. An explicit `agents` list bypasses discovery and preserves manual registry selection; `[]` registers no presets. Service startup, connection errors and invalid inventory responses fail plugin initialization instead of selecting fallback agents.
98
+ The bundle's `oneagents-acp` row accepts `serviceUrl`, `serviceMode`, `serviceStartupTimeoutMs`, `serviceShutdownTimeoutMs`, `agents`, `stateDirectory`, `diagnosticsDirectory`, `reconnectAttempts` and `reconnectDelayMs`. Change it through the profile's `cordis.patch.yml`, not the DSH repository. Use a new session after changing endpoint or workspace. When `agents` is omitted, plugin startup fetches `GET /agents` from acp-service and registers presets for entries with `chat_ready: true`, using their service-provided names. Discovery runs on the service host. Restart the plugin after installing or removing a harness. An explicit `agents` list bypasses discovery and preserves manual registry selection; `[]` registers no presets. Service startup, connection errors and invalid inventory responses fail plugin initialization instead of selecting fallback agents.
99
+
100
+ Diagnostic storage defaults to `stateDirectory/diagnostics`; `diagnosticsDirectory` selects a separate explicit location. Keep this directory with the A2A state when moving a host. Its version is independent of DSH Session formats. The plugin privately mounts official storage components; it does not require a shared host storage-domain configuration. Only one plugin instance may write the directory at a time.
91
101
 
92
102
  ### Local service lifecycle
93
103
 
@@ -110,7 +120,7 @@ pnpm build
110
120
  pnpm test:integration
111
121
  ```
112
122
 
113
- The DSH checkout must already have its dependencies installed and declaration outputs built. Development type checking links its matching packages into `node_modules/@deepseek-ai`; generated JavaScript has no runtime imports of those packages and uses the Host's provided services. Tests cover real-WebSocket streaming, permissions, questions, cancellation, reconnection and saved bindings.
123
+ The DSH checkout must already have its dependencies installed and declaration outputs built. Development type checking links its matching packages into `node_modules/@deepseek-ai`; generated JavaScript uses the Host's public packages and services. The `dsh-zod` dependency alias pins the record-schema dialect to Zod 4.4.3 for the tested official DSH 0.1.7-rc.2 API, independently of the service's Zod dependency. A different DSH version requires its own compile and lifecycle compatibility checks. Tests cover real-WebSocket streaming, permissions, questions, cancellation, reconnection and saved bindings.
114
124
 
115
125
  For manual service debugging on this machine, start it from `../service` with:
116
126
 
@@ -1,11 +1,18 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
- import type { A2ABackend, A2APrepareInput, A2ARunResult, A2ATarget } from '@1agents/acp-service/a2a';
2
+ import { type A2ABackend, type A2APreflightInput, type A2APrepareInput, type A2ARunResult, type A2ATarget } from '@1agents/acp-service/a2a';
3
+ import type { Diagnostics } from './diagnostics.js';
3
4
  /** Uses public session-controller and inbox events to account for one A2A prompt's exact DSH turn. */
4
5
  export declare class DshA2ABackend implements A2ABackend {
5
6
  private readonly ctx;
7
+ private readonly diagnostics?;
6
8
  private readonly executions;
7
9
  /** @param ctx DSH plugin context that owns session-controller and execution event registrations. */
8
- constructor(ctx: Context);
10
+ constructor(ctx: Context, diagnostics?: Diagnostics | undefined);
11
+ /** Restart reconciliation reads the plugin domain and never dispatches another prompt. */
12
+ recover(target: A2ATarget, options: {
13
+ requestId: string;
14
+ }): Promise<import("@1agents/acp-service/runtime").SafeError | undefined>;
15
+ preflight(input: A2APreflightInput): Promise<import("@1agents/acp-service/a2a").A2APreflightReport>;
9
16
  /** Create a new session or restore an explicitly addressed session without changing its workspace or preset.
10
17
  * @param input Remote host directory, preset, and optional existing DSH session identity.
11
18
  * @returns The resolved DSH session and its durable workspace and preset.
@@ -1,19 +1,26 @@
1
1
  /** DSH session execution behind the shared A2A service's transport-independent backend. */
2
2
  import { realpath, stat } from 'node:fs/promises';
3
3
  import { isAbsolute } from 'node:path';
4
- function resultOf(reason, text, finalAnswerExpected) {
4
+ import { A2APreflightError, runA2APreflight } from '@1agents/acp-service/a2a';
5
+ import { toSafeError } from '@1agents/acp-service/runtime';
6
+ function resultOf(reason, text, finalAnswerExpected, operationId, diagnostic) {
5
7
  switch (reason.kind) {
6
8
  case 'completed': return finalAnswerExpected && !text.trim()
7
- ? { outcome: 'failed', text, detail: 'DSH completed the task without a final answer; ACP final-answer metadata contained no final output' }
9
+ ? { outcome: 'failed', text, failureReason: 'missing-final-answer', detail: 'DSH completed the task without a final answer; ACP final-answer metadata contained no final output' }
8
10
  : { outcome: 'completed', text };
9
11
  case 'blocked': return { outcome: 'input-required', text, detail: 'DSH blocked the task before its next model step' };
10
- case 'error': return { outcome: 'failed', text, detail: reason.error.message };
11
- case 'max-tokens': return { outcome: 'failed', text, detail: 'DSH reached the model output token limit' };
12
- case 'aborted': return { outcome: 'failed', text, detail: 'DSH task execution was canceled' };
13
- case 'interrupted': return { outcome: 'failed', text, detail: 'DSH task execution was interrupted' };
14
- case 'forked': return { outcome: 'failed', text, detail: 'DSH task turn was closed by a session fork' };
12
+ case 'error': {
13
+ const error = diagnostic ?? toSafeError(undefined, { origin: 'dsh', operationId });
14
+ return { outcome: 'failed', text, detail: error.message, error };
15
+ }
16
+ case 'max-tokens': return { outcome: 'failed', text, failureReason: 'max-tokens', detail: 'DSH reached the model output token limit' };
17
+ case 'aborted': return { outcome: 'failed', text, failureReason: 'aborted', detail: 'DSH task execution was canceled',
18
+ error: diagnostic ?? toSafeError(new DOMException('ACP execution cancelled.', 'AbortError'), { origin: 'dsh', operationId, outcomeUnknown: true }) };
19
+ case 'interrupted': return { outcome: 'failed', text, failureReason: 'interrupted', detail: 'DSH task execution was interrupted',
20
+ error: toSafeError(undefined, { origin: 'dsh', operationId, outcomeUnknown: true }) };
21
+ case 'forked': return { outcome: 'failed', text, failureReason: 'forked', detail: 'DSH task turn was closed by a session fork' };
15
22
  // DSH's turn reasons are merge-extensible; an unknown ending cannot report success.
16
- default: return { outcome: 'failed', text, detail: 'DSH returned an unsupported turn ending' };
23
+ default: return { outcome: 'failed', text, failureReason: 'unsupported-ending', detail: 'DSH returned an unsupported turn ending' };
17
24
  }
18
25
  }
19
26
  /** Read durable ACP metadata, leaving ordinary DSH messages compatible. */
@@ -32,10 +39,19 @@ function answerOf(content, turn) {
32
39
  /** Uses public session-controller and inbox events to account for one A2A prompt's exact DSH turn. */
33
40
  export class DshA2ABackend {
34
41
  ctx;
42
+ diagnostics;
35
43
  executions = new Map();
36
44
  /** @param ctx DSH plugin context that owns session-controller and execution event registrations. */
37
- constructor(ctx) {
45
+ constructor(ctx, diagnostics) {
38
46
  this.ctx = ctx;
47
+ this.diagnostics = diagnostics;
48
+ }
49
+ /** Restart reconciliation reads the plugin domain and never dispatches another prompt. */
50
+ async recover(target, options) {
51
+ return this.diagnostics?.find(target.sessionId, options.requestId);
52
+ }
53
+ async preflight(input) {
54
+ return runA2APreflight(input);
39
55
  }
40
56
  /** Create a new session or restore an explicitly addressed session without changing its workspace or preset.
41
57
  * @param input Remote host directory, preset, and optional existing DSH session identity.
@@ -45,16 +61,38 @@ export class DshA2ABackend {
45
61
  const previous = input.sessionId === undefined
46
62
  ? undefined
47
63
  : await this.ctx.sessionController.inspect(input.sessionId);
64
+ if (input.sessionId !== undefined && previous == null)
65
+ throw new Error(`Session ${input.sessionId} not found`);
66
+ if (previous !== undefined && previous.meta.id !== input.sessionId)
67
+ throw new Error('Existing session identity conflicts');
48
68
  const requestedCwd = input.cwd ?? previous?.meta.cwd ?? process.cwd();
49
69
  if (!isAbsolute(requestedCwd))
50
70
  throw new Error('A2A cwd must be an absolute directory on the DSH host');
51
71
  const cwd = await realpath(requestedCwd);
52
72
  if (!(await stat(cwd)).isDirectory())
53
73
  throw new Error('A2A cwd must point to a directory on the DSH host');
74
+ const preflight = await this.preflight({ ...input.preflight, cwd });
75
+ if (!preflight.ok)
76
+ throw new A2APreflightError(preflight);
54
77
  const agentPreset = input.agentPreset ?? previous?.meta.agentPreset;
78
+ if (input.sessionId !== undefined && previous !== undefined) {
79
+ if (previous.meta.cwd === undefined || await realpath(previous.meta.cwd) !== cwd)
80
+ throw new Error('Existing session cwd conflicts');
81
+ if (input.agentPreset !== undefined && input.agentPreset !== previous.meta.agentPreset)
82
+ throw new Error('Existing session preset conflicts');
83
+ // create() only reuses blank Sessions on current DSH; resolve the saved
84
+ // identity directly so an active or completed context keeps its queue.
85
+ const agent = await this.agent(input.sessionId);
86
+ if (agent.id !== input.sessionId || agent.session.id !== input.sessionId)
87
+ throw new Error('Existing session identity conflicts');
88
+ if (agent.session.header.cwd === undefined || await realpath(agent.session.header.cwd) !== cwd)
89
+ throw new Error('Existing session cwd conflicts');
90
+ if (agent.session.header.agentPreset !== previous.meta.agentPreset)
91
+ throw new Error('Existing session preset conflicts');
92
+ return { sessionId: input.sessionId, cwd, ...(agentPreset === undefined ? {} : { agentPreset }), preflight };
93
+ }
55
94
  const created = await this.ctx.sessionController.create({
56
95
  cwd,
57
- ...(input.sessionId === undefined ? {} : { sessionId: input.sessionId }),
58
96
  ...(agentPreset === undefined ? {} : { agentPreset }),
59
97
  });
60
98
  const agent = await this.agent(created.sessionId);
@@ -62,6 +100,7 @@ export class DshA2ABackend {
62
100
  sessionId: created.sessionId,
63
101
  cwd: agent.session.header.cwd ?? cwd,
64
102
  ...(created.agentPreset === undefined ? {} : { agentPreset: created.agentPreset }),
103
+ preflight,
65
104
  };
66
105
  }
67
106
  /** Admit one identified queued prompt and wait only for its own turn, independent of the HTTP connection.
@@ -111,13 +150,40 @@ export class DshA2ABackend {
111
150
  options.signal.removeEventListener('abort', cancel);
112
151
  completion.resolve(result);
113
152
  };
153
+ const finishTurn = (reason) => {
154
+ const start = agent.session.snapshotEvents().findLast(event => event.type === 'turn/start' && event.data.turn === turn);
155
+ let diagnostic;
156
+ try {
157
+ diagnostic = this.diagnostics?.find(agent.id, options.requestId, turn, start?.seq);
158
+ }
159
+ catch { /* A stopping storage provider cannot supply durable diagnostics. */ }
160
+ settle(resultOf(reason, text, finalAnswerExpected, options.requestId, diagnostic));
161
+ };
114
162
  const cancel = () => {
115
163
  if (settled)
116
164
  return;
117
- if (turn !== undefined)
165
+ if (turn !== undefined) {
118
166
  agent.cancel({ kind: 'user' }, { keepInbox: true });
119
- else if (messageId !== undefined)
120
- agent.inbox.remove(messageId);
167
+ // Root shutdown can remove event subscriptions before the final turn is
168
+ // published. The public idle barrier still drains that exact activity.
169
+ void agent.whenIdle().then(() => {
170
+ if (settled)
171
+ return;
172
+ const ended = agent.session.snapshotEvents().findLast(event => event.type === 'turn/end' && event.data.turn === turn);
173
+ if (ended?.type === 'turn/end')
174
+ finishTurn(ended.data.reason);
175
+ else
176
+ settle({ outcome: 'failed', text, failureReason: 'disposed',
177
+ error: toSafeError(undefined, { origin: 'dsh', operationId: options.requestId, outcomeUnknown: true }) });
178
+ }, () => {
179
+ settle({ outcome: 'failed', text, failureReason: 'disposed',
180
+ error: toSafeError(undefined, { origin: 'dsh', operationId: options.requestId, outcomeUnknown: true }) });
181
+ });
182
+ }
183
+ else if (messageId !== undefined && agent.inbox.remove(messageId)) {
184
+ settle({ outcome: 'failed', text, failureReason: 'discarded',
185
+ error: toSafeError(new DOMException('ACP execution cancelled.', 'AbortError'), { origin: 'dsh', operationId: options.requestId, outcomeUnknown: false }) });
186
+ }
121
187
  };
122
188
  // The session owns these temporary listeners until its turn settles. Plugin
123
189
  // unloading removes plugin effects concurrently with the server's cancel/drain.
@@ -138,12 +204,14 @@ export class DshA2ABackend {
138
204
  }));
139
205
  listeners.push(agent.ctx.on('agent/inbox/discarded', event => {
140
206
  if (event.agent === agent && owns(event.message)) {
141
- settle({ outcome: 'failed', text, detail: 'DSH discarded the queued task before execution' });
207
+ settle({ outcome: 'failed', text, failureReason: 'discarded', detail: 'DSH discarded the queued task before execution',
208
+ ...(options.signal.aborted ? { error: toSafeError(new DOMException('ACP execution cancelled.', 'AbortError'), { origin: 'dsh', operationId: options.requestId, outcomeUnknown: false }) } : {}) });
142
209
  }
143
210
  }));
144
211
  listeners.push(agent.ctx.on('agent/disposed', event => {
145
212
  if (event.agent === agent)
146
- settle({ outcome: 'failed', text, detail: 'DSH session was disposed before the task finished' });
213
+ settle({ outcome: 'failed', text, failureReason: 'disposed', detail: 'DSH session was disposed before the task finished',
214
+ error: toSafeError(undefined, { origin: 'dsh', operationId: options.requestId, outcomeUnknown: turn !== undefined }) });
147
215
  }));
148
216
  listeners.push(agent.ctx.on('session/event', (session, event) => {
149
217
  if (session !== agent.session || turn === undefined)
@@ -163,7 +231,7 @@ export class DshA2ABackend {
163
231
  text = next.text;
164
232
  }
165
233
  else if (event.type === 'turn/end' && event.data.turn === turn) {
166
- settle(resultOf(event.data.reason, text, finalAnswerExpected));
234
+ finishTurn(event.data.reason);
167
235
  }
168
236
  }));
169
237
  options.signal.addEventListener('abort', cancel, { once: true });
@@ -1,6 +1,7 @@
1
1
  /** Mount the shared A2A implementation on the current DSH web host. */
2
2
  import { type A2AServerOptions } from '@1agents/acp-service/a2a';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
+ import type { Diagnostics } from './diagnostics.js';
4
5
  /** Optional host configuration; omitted configuration leaves A2A disabled. */
5
6
  export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token' | 'stateDirectory' | 'publicUrl'> {
6
7
  enabled?: boolean;
@@ -12,4 +13,4 @@ export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token
12
13
  publicUrl?: string;
13
14
  }
14
15
  /** Routes and in-flight turns are released with the owning Cordis plugin. */
15
- export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string): Promise<void>;
16
+ export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string, diagnostics?: Diagnostics): Promise<() => Promise<void>>;
package/vendor/dsh/a2a.js CHANGED
@@ -2,20 +2,22 @@
2
2
  import { createA2AServer } from '@1agents/acp-service/a2a';
3
3
  import { DshA2ABackend } from './a2a-executor.js';
4
4
  /** Routes and in-flight turns are released with the owning Cordis plugin. */
5
- export async function mountDshA2A(ctx, options, stateDirectory) {
5
+ export async function mountDshA2A(ctx, options, stateDirectory, diagnostics) {
6
6
  if (options.enabled === false)
7
- return;
7
+ return async () => { };
8
8
  const token = options.token ?? process.env[options.tokenEnv ?? 'DSH_A2A_TOKEN'];
9
9
  if (!token)
10
10
  throw new Error('Set DSH_A2A_TOKEN or a2a.token before enabling DSH A2A');
11
+ let close = async () => { };
11
12
  await ctx.effect(async () => {
12
- const server = await createA2AServer({ ...options, token, backend: new DshA2ABackend(ctx),
13
+ const server = await createA2AServer({ ...options, token, backend: new DshA2ABackend(ctx, diagnostics),
13
14
  stateDirectory: options.stateDirectory ?? stateDirectory,
14
15
  publicUrl: options.publicUrl ?? `http://127.0.0.1:${ctx.webServer.port}` });
15
16
  const routes = [];
16
17
  try {
17
18
  routes.push(ctx.webServer.register({ kind: 'exact', path: '/.well-known/agent-card.json', handler: server.cardHandler }));
18
19
  routes.push(ctx.webServer.register({ kind: 'exact', path: server.path, handler: server.handler }));
20
+ routes.push(ctx.webServer.register({ kind: 'exact', path: `${server.path}/preflight`, handler: server.handler }));
19
21
  }
20
22
  catch (error) {
21
23
  for (const dispose of routes.reverse())
@@ -23,10 +25,13 @@ export async function mountDshA2A(ctx, options, stateDirectory) {
23
25
  await server.close();
24
26
  throw error;
25
27
  }
26
- return async () => {
28
+ let closing;
29
+ close = () => closing ??= (async () => {
27
30
  for (const dispose of routes.reverse())
28
31
  dispose();
29
32
  await server.close();
30
- };
33
+ })();
34
+ return close;
31
35
  });
36
+ return close;
32
37
  }
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { Agent } from '@deepseek-ai/dsh-agent';
3
3
  import type { LlmAdapter, GenerateOptions, StreamChunk, LlmModelInfo } from '@deepseek-ai/dsh-llm';
4
+ import type { Diagnostics } from './diagnostics.js';
4
5
  import type { SessionConfigOption, SessionModeState, AvailableCommand } from '@agentclientprotocol/sdk';
5
6
  import { type Binding } from './state.js';
6
7
  export interface Config {
@@ -21,6 +22,7 @@ export interface Capabilities {
21
22
  export declare class AcpAdapter implements LlmAdapter {
22
23
  private ctx;
23
24
  private config;
25
+ private readonly diagnostics?;
24
26
  private state;
25
27
  private controllers;
26
28
  private jobs;
@@ -32,7 +34,7 @@ export declare class AcpAdapter implements LlmAdapter {
32
34
  private commandDisposers;
33
35
  private output;
34
36
  private lifetime;
35
- constructor(ctx: Context, config: Config);
37
+ constructor(ctx: Context, config: Config, diagnostics?: Diagnostics | undefined);
36
38
  providerInfo(provider: string): {
37
39
  id: string;
38
40
  name: string;
@@ -2,9 +2,46 @@
2
2
  import { createHash } from 'node:crypto';
3
3
  import { randomUUID } from 'node:crypto';
4
4
  import { setTimeout as delay } from 'node:timers/promises';
5
+ import { LlmError } from '@deepseek-ai/dsh-llm';
6
+ import { RequestError } from '@agentclientprotocol/sdk';
5
7
  import { connect, object } from './transport.js';
6
8
  import { State, hasActiveWriter } from './state.js';
7
9
  import { mergeTool } from './tool-events.js';
10
+ import { toSafeError } from '@1agents/acp-service/runtime';
11
+ /** Only the negotiated service's direct canonical error data is a projection. */
12
+ function serviceProjection(error) {
13
+ if (!(error instanceof RequestError) || error.code !== -32000
14
+ || !error.data || typeof error.data !== 'object' || Array.isArray(error.data))
15
+ return;
16
+ const data = error.data;
17
+ if (typeof data.category !== 'string' || !['quota', 'rate_limit', 'budget', 'auth', 'cancelled', 'timeout', 'permission', 'unknown'].includes(data.category))
18
+ return;
19
+ if (typeof data.origin !== 'string' || !['cli', 'runtime', 'queue', 'acp', 'service', 'transport', 'dsh', 'a2a'].includes(data.origin))
20
+ return;
21
+ if (typeof data.retryable !== 'boolean' || typeof data.outcomeUnknown !== 'boolean')
22
+ return;
23
+ return data;
24
+ }
25
+ /** Only actual cancellation rejections may replace a racing provider failure. */
26
+ function isCancellationRejection(error, signal) {
27
+ if (!signal.aborted)
28
+ return false;
29
+ if (error === signal.reason)
30
+ return true;
31
+ // The SDK leaves a canceled request pending for the peer's reply. A real
32
+ // service error can still arrive; only its cancellation reply is an abort.
33
+ if (error instanceof RequestError)
34
+ return error.code === -32800;
35
+ // node:timers/promises rejects its canceled reconnect delay with this cause.
36
+ return error instanceof Error && error.name === 'AbortError' && error.cause === signal.reason;
37
+ }
38
+ const ownedFailures = new WeakMap();
39
+ /** The official host receives its normal error; complete facts live in the plugin domain. */
40
+ function publicFailure(safe, _requestId) {
41
+ const error = Object.assign(new LlmError(safe.message, safe.code ?? 'ACP_TURN_FAILED'), safe);
42
+ ownedFailures.set(error, safe);
43
+ return error;
44
+ }
8
45
  /** Producer/consumer queue; errors are delivered after already received chunks. */
9
46
  class Queue {
10
47
  values = [];
@@ -30,6 +67,7 @@ class Queue {
30
67
  export class AcpAdapter {
31
68
  ctx;
32
69
  config;
70
+ diagnostics;
33
71
  state;
34
72
  controllers = new Map();
35
73
  jobs = new Set();
@@ -41,9 +79,10 @@ export class AcpAdapter {
41
79
  commandDisposers = new Map();
42
80
  output = new Map();
43
81
  lifetime = new AbortController();
44
- constructor(ctx, config) {
82
+ constructor(ctx, config, diagnostics) {
45
83
  this.ctx = ctx;
46
84
  this.config = config;
85
+ this.diagnostics = diagnostics;
47
86
  this.state = new State(config.stateDirectory);
48
87
  }
49
88
  providerInfo(provider) { return { id: provider, name: 'ACP Agents' }; }
@@ -231,14 +270,28 @@ export class AcpAdapter {
231
270
  if (!this.commandContexts.has(agent.id)) {
232
271
  const fiber = await agent.ctx.inject(['commands'], scope => {
233
272
  this.commandContexts.set(agent.id, scope);
234
- scope.effect(() => () => {
235
- this.controllers.get(agent.id)?.abort();
236
- void this.links.get(agent.id)?.then(link => link.close(), () => { });
237
- this.links.delete(agent.id);
238
- this.commandContexts.delete(agent.id);
239
- this.commandScopes.delete(agent.id);
240
- this.capabilities.delete(agent.id);
241
- this.commandDisposers.delete(agent.id);
273
+ scope.effect(() => async () => {
274
+ const link = this.links.get(agent.id), active = this.controllers.get(agent.id);
275
+ active?.abort();
276
+ // Keep the response transport alive while the official loop drains
277
+ // cancellation and the plugin commits its diagnostic receipt.
278
+ if (active)
279
+ try {
280
+ await agent.whenIdle();
281
+ }
282
+ catch { /* The loop also reports a failed disposal. */ }
283
+ try {
284
+ (await link)?.close();
285
+ }
286
+ catch { /* Connection setup already failed. */ }
287
+ if (this.links.get(agent.id) === link)
288
+ this.links.delete(agent.id);
289
+ if (this.commandContexts.get(agent.id) === scope) {
290
+ this.commandContexts.delete(agent.id);
291
+ this.commandScopes.delete(agent.id);
292
+ this.capabilities.delete(agent.id);
293
+ this.commandDisposers.delete(agent.id);
294
+ }
242
295
  });
243
296
  });
244
297
  this.commandScopes.set(agent.id, async () => fiber.dispose());
@@ -443,10 +496,38 @@ export class AcpAdapter {
443
496
  }
444
497
  };
445
498
  let active;
499
+ let requestSent = false, nativeConfirmed = false;
500
+ const save = async (action) => {
501
+ try {
502
+ await action();
503
+ }
504
+ catch {
505
+ throw publicFailure(toSafeError(undefined, { origin: 'dsh', operationId: requestId,
506
+ outcomeUnknown: requestSent && !nativeConfirmed }), requestId);
507
+ }
508
+ };
509
+ let diagnosticId;
510
+ const cancelled = (outcomeUnknown, origin = 'dsh') => publicFailure(toSafeError(new DOMException('ACP execution cancelled.', 'AbortError'), { origin, operationId: requestId, outcomeUnknown }), requestId);
446
511
  const cancel = () => { if (binding?.sessionId)
447
512
  void active?.rpc.notify('session/cancel', { sessionId: binding.sessionId }).catch(() => { }); };
448
513
  signal.addEventListener('abort', cancel, { once: true });
449
514
  try {
515
+ if (this.diagnostics)
516
+ await save(async () => {
517
+ const turnStartSeq = boundary?.openTurnStartSeq;
518
+ if (turnStartSeq == null)
519
+ throw new Error('ACP diagnostic turn boundary is unavailable');
520
+ // Old failed turns may have no assistant message separating their input.
521
+ // Only this turn's admitted user messages can own this attempt's facts.
522
+ const admittedIds = new Set(agent.session.snapshotEvents().flatMap(event => event.type === 'user/message' && event.seq > turnStartSeq ? [event.data.id] : []));
523
+ const admitted = input.filter(message => message.id !== undefined && admittedIds.has(message.id));
524
+ diagnosticId = await this.diagnostics.begin({ sessionId: agent.id, turn,
525
+ turnStartSeq, stepStartSeq: boundary?.lastStepStartSeq ?? 0, nativeRequestId: requestId,
526
+ messageIds: [...new Set(admitted.flatMap(m => m.id === undefined ? [] : [m.id]))],
527
+ requestIds: [...new Set(admitted.flatMap(m => m.role === 'user' && m.source?.kind === 'user' && 'rpcId' in m.source
528
+ && typeof m.source.rpcId === 'string' ? [m.source.rpcId] : []))],
529
+ });
530
+ });
450
531
  for (let attempt = 0;; attempt++) {
451
532
  signal.throwIfAborted();
452
533
  try {
@@ -454,9 +535,19 @@ export class AcpAdapter {
454
535
  active = await this.connection(agent);
455
536
  binding = this.state.get(agent.id);
456
537
  signal.throwIfAborted();
538
+ if (diagnosticId)
539
+ await save(() => this.diagnostics.submitted(diagnosticId));
540
+ signal.throwIfAborted();
541
+ requestSent = true;
457
542
  const result = await active.rpc.request('session/prompt', { sessionId: binding.sessionId, prompt: [{ type: 'text', text }],
458
543
  _meta: { '1agents': { turnManaged: true, turnId: requestId, requestId } } }, { cancellationSignal: signal });
459
- signal.throwIfAborted();
544
+ nativeConfirmed = true;
545
+ if (diagnosticId)
546
+ await save(() => this.diagnostics.confirmed(diagnosticId));
547
+ // A received terminal reply establishes the outcome even if the consumer
548
+ // just aborted. Preserve cancellation without emitting any more chunks.
549
+ if (signal.aborted)
550
+ throw cancelled(false, result.stopReason === 'cancelled' ? 'acp' : 'dsh');
460
551
  const meta = result._meta?.['1agents'];
461
552
  if (typeof meta?.finalAnswer === 'string' && (!answer || (hasPhasedText && !streamedFinalAnswer))) {
462
553
  emit('text', meta.finalAnswer, { messagePhase: 'final_answer' });
@@ -470,19 +561,38 @@ export class AcpAdapter {
470
561
  queue.push({ type: 'block-end', index, block });
471
562
  index++;
472
563
  }
473
- queue.push(result.stopReason === 'cancelled' ? { type: 'finish', reason: { kind: 'aborted', failure: { code: 'ABORTED', message: 'ACP turn cancelled' } } } : { type: 'finish', reason: result.stopReason === 'max_tokens' ? { kind: 'max-tokens' } : { kind: 'stop' } });
564
+ if (result.stopReason === 'cancelled')
565
+ throw cancelled(false, 'acp');
566
+ queue.push({ type: 'finish', reason: result.stopReason === 'max_tokens' ? { kind: 'max-tokens' } : { kind: 'stop' } });
474
567
  return;
475
568
  }
476
569
  catch (error) {
477
- if (signal.aborted) {
570
+ if (error instanceof LlmError)
571
+ throw error;
572
+ if (isCancellationRejection(error, signal)) {
478
573
  endBlock();
479
- queue.push({ type: 'finish', reason: { kind: 'aborted', failure: { code: 'ABORTED', message: 'ACP turn cancelled' } } });
480
- return;
574
+ throw cancelled(requestSent);
481
575
  }
482
576
  // Only transport loss is retried. The managed request ID makes an
483
577
  // uncertain delivery idempotent; provider errors remain errors.
484
- if ((active && active.ws.readyState === 1) || attempt >= this.config.reconnectAttempts)
485
- throw error;
578
+ if (error instanceof RequestError || (active && active.ws.readyState === 1) || attempt >= this.config.reconnectAttempts) {
579
+ const transportLost = !active || active.ws.readyState !== 1;
580
+ // The negotiated service sends its canonical projection directly in
581
+ // RequestError.data. Other native and transport errors remain raw.
582
+ const projected = serviceProjection(error);
583
+ const safe = toSafeError(projected ?? error, { trustedProjection: projected !== undefined,
584
+ origin: transportLost ? 'transport' : 'dsh', operationId: requestId,
585
+ outcomeUnknown: projected ? projected.outcomeUnknown === true : transportLost && requestSent });
586
+ // A pending import has no service identity while its original
587
+ // writer owns the native session. Retain that local explanation
588
+ // without copying the failed restoration's provider message.
589
+ if (!requestSent && binding?.imported && !binding.sessionId && safe.category === 'unknown') {
590
+ safe.message = 'The imported ACP session is not ready; check for an active writer before retrying.';
591
+ }
592
+ // Complete facts are saved in the plugin domain before the official
593
+ // host normalizes this ordinary LlmError.
594
+ throw publicFailure(safe, requestId);
595
+ }
486
596
  await delay(this.config.reconnectDelayMs, undefined, { signal });
487
597
  }
488
598
  finally {
@@ -490,6 +600,24 @@ export class AcpAdapter {
490
600
  }
491
601
  }
492
602
  }
603
+ catch (error) {
604
+ const failure = isCancellationRejection(error, signal) ? cancelled(requestSent && !nativeConfirmed) : error;
605
+ if (diagnosticId) {
606
+ const safe = failure instanceof Error && ownedFailures.get(failure) || toSafeError(failure, {
607
+ origin: 'dsh', operationId: requestId, outcomeUnknown: requestSent && !nativeConfirmed
608
+ });
609
+ try {
610
+ await this.diagnostics.settle(diagnosticId, safe);
611
+ }
612
+ catch {
613
+ throw publicFailure(toSafeError(undefined, { origin: 'dsh', operationId: requestId,
614
+ outcomeUnknown: requestSent && !nativeConfirmed }), requestId);
615
+ }
616
+ }
617
+ throw failure instanceof Error && ownedFailures.has(failure) ? failure : publicFailure(toSafeError(failure, {
618
+ origin: 'dsh', operationId: requestId, outcomeUnknown: requestSent && !nativeConfirmed
619
+ }), requestId);
620
+ }
493
621
  finally {
494
622
  signal.removeEventListener('abort', cancel);
495
623
  this.output.delete(agent.id);
@@ -176,6 +176,10 @@ var toolConversationDefinition = {
176
176
  var import_react = __toESM(require("react"), 1);
177
177
  var h = import_react.default.createElement;
178
178
  var toolKeys = { Bash: "bash", Read: "read", Edit: "edit", Write: "write", Search: "search", Fetch: "web_fetch" };
179
+ var assistantContentFactories = {
180
+ "conversation.chat.reasoning.body": "conversation.chat.reasoning.content",
181
+ "conversation.chat.message.images": "conversation.images.content"
182
+ };
179
183
  function ToolGroup({ roots, owner, renderTool, label }) {
180
184
  const { expanded, toggle } = owner.useDisclosure();
181
185
  return h(
@@ -197,7 +201,11 @@ function ToolGroup({ roots, owner, renderTool, label }) {
197
201
  function installTranscriptView(ctx) {
198
202
  ctx.slots.inject("conversation.chat.node", () => {
199
203
  const native = [...ctx.slots.entries("conversation.chat.node")].reverse().find((entry) => entry.options.key === "assistant-step");
200
- if (!native || native.children) throw new Error("DSH native assistant renderer is unavailable");
204
+ if (!native) throw new Error("DSH native assistant renderer is unavailable");
205
+ const renderAssistant = (props) => h(native.component, native.children ? {
206
+ ...props,
207
+ renderSlot: (key, owner) => props.renderFactorySlot(assistantContentFactories[key], owner)
208
+ } : props);
201
209
  const tTool = ctx.locale.bind("conversation");
202
210
  const t = ctx.locale.bind("oneagentsAcp");
203
211
  const renderTool = (root, owner) => {
@@ -234,10 +242,10 @@ function installTranscriptView(ctx) {
234
242
  acpTranscript: void 0,
235
243
  blocks: [{ kind: group.kind, text: group.text }]
236
244
  } };
237
- return h(native.component, { ...props, key: group.key, node, groupPart: void 0, turnProcess: void 0 });
245
+ return renderAssistant({ ...props, key: group.key, node, groupPart: void 0, turnProcess: void 0 });
238
246
  }));
239
247
  const preset = ctx.sessions.binding(props.sessionId)?.session.projections.faceOf("agentPreset").getSnapshot();
240
- return projected && typeof preset === "string" && preset.startsWith("oneagents-acp-") ? h("span", { hidden: true, "data-oneagents-acp-original": "" }) : h(native.component, props);
248
+ return projected && typeof preset === "string" && preset.startsWith("oneagents-acp-") ? h("span", { hidden: true, "data-oneagents-acp-original": "" }) : renderAssistant(props);
241
249
  }
242
250
  return ctx.slots.register({
243
251
  name: "conversation.chat.node",
@@ -0,0 +1,42 @@
1
+ import { z } from 'dsh-zod';
2
+ import { type DomainFacility } from '@deepseek-ai/dsh-storage-domain';
3
+ import { type SafeError } from '@1agents/acp-service/runtime';
4
+ declare const identitySchema: z.ZodObject<{
5
+ sessionId: z.ZodString;
6
+ turn: z.ZodNumber;
7
+ turnStartSeq: z.ZodNumber;
8
+ stepStartSeq: z.ZodNumber;
9
+ nativeRequestId: z.ZodString;
10
+ messageIds: z.ZodArray<z.ZodString>;
11
+ requestIds: z.ZodArray<z.ZodString>;
12
+ }, z.core.$strict>;
13
+ export type DiagnosticIdentity = z.infer<typeof identitySchema>;
14
+ /** Shared by the owned Adapter and A2A backend; every mutating method awaits durability. */
15
+ export declare class Diagnostics {
16
+ private readonly domain;
17
+ private serial;
18
+ private chain;
19
+ private closed;
20
+ private constructor();
21
+ /** Open the plugin's schema-validated domain using the configured official storage facility. */
22
+ static open(facility: DomainFacility): Promise<Diagnostics>;
23
+ private write;
24
+ /** Persist admission before starting a native delivery attempt. */
25
+ begin(identity: DiagnosticIdentity): Promise<string>;
26
+ /** Mark a conservative delivery attempt, before asking the cooperative SDK to send. */
27
+ submitted(id: string): Promise<void>;
28
+ /** Persist a received terminal reply before allowing host output or cancellation to settle. */
29
+ confirmed(id: string): Promise<void>;
30
+ /** Save only the safe whitelist before any failure is given to the official host. */
31
+ settle(id: string, error?: SafeError): Promise<void>;
32
+ /** Resolve only this request's newest owned attempt; a pending retry never borrows an older failure. */
33
+ find(sessionId: string, requestId: string, turn?: number, turnStartSeq?: number): SafeError | undefined;
34
+ /** Drain writes before unloading; the owner first drains A2A and the Adapter. */
35
+ close(): Promise<void>;
36
+ }
37
+ /** Own the official storage plugins until A2A and native calls have drained. */
38
+ export declare function openDiagnostics(directory: string): Promise<{
39
+ diagnostics: Diagnostics;
40
+ close: () => Promise<void>;
41
+ }>;
42
+ export {};