@hivemagnus/ardent 3.1.3 → 3.2.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.
- package/README.md +504 -16
- package/dist/a2a-client.d.ts +26 -4
- package/dist/a2a-client.js +91 -23
- package/dist/a2a-push-inbox.d.ts +2 -0
- package/dist/a2a-push-inbox.js +7 -0
- package/dist/a2a-push.d.ts +1 -1
- package/dist/a2a-push.js +26 -18
- package/dist/a2a-server.d.ts +17 -0
- package/dist/a2a-server.js +91 -14
- package/dist/a2a.d.ts +19 -1
- package/dist/a2a.js +197 -27
- package/dist/api.d.ts +2 -0
- package/dist/api.js +160 -22
- package/dist/artifact-manifests.d.ts +344 -5
- package/dist/artifact-manifests.js +413 -20
- package/dist/artifact-transfer.d.ts +113 -0
- package/dist/artifact-transfer.js +517 -0
- package/dist/artifacts.d.ts +86 -0
- package/dist/artifacts.js +249 -1
- package/dist/backend-events.d.ts +2 -1
- package/dist/backend-events.js +1 -1
- package/dist/channel-catchup.d.ts +67 -0
- package/dist/channel-catchup.js +108 -0
- package/dist/channels.d.ts +35 -0
- package/dist/channels.js +152 -4
- package/dist/cli.js +28 -3
- package/dist/codex-protocol.d.ts +22 -0
- package/dist/codex-protocol.js +19 -0
- package/dist/codex.d.ts +32 -3
- package/dist/codex.js +91 -17
- package/dist/config.d.ts +25 -2
- package/dist/config.js +41 -4
- package/dist/development.d.ts +6 -6
- package/dist/execution-state.d.ts +245 -0
- package/dist/execution-state.js +236 -0
- package/dist/execution.d.ts +135 -0
- package/dist/execution.js +178 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -3
- package/dist/job-engine.d.ts +2 -1
- package/dist/job-engine.js +33 -4
- package/dist/lineage.d.ts +106 -0
- package/dist/lineage.js +145 -0
- package/dist/llamacpp.d.ts +32 -2
- package/dist/llamacpp.js +69 -33
- package/dist/mattermost.d.ts +8 -0
- package/dist/mattermost.js +250 -36
- package/dist/mission-tools.js +41 -5
- package/dist/missions.d.ts +5 -1
- package/dist/missions.js +10 -5
- package/dist/plugin-evidence.js +2 -1
- package/dist/plugin-sdk.d.ts +3 -0
- package/dist/plugin-sdk.js +3 -0
- package/dist/plugins.d.ts +108 -2
- package/dist/plugins.js +131 -1
- package/dist/preview.d.ts +1 -0
- package/dist/preview.js +4 -1
- package/dist/recovery.d.ts +155 -0
- package/dist/recovery.js +216 -0
- package/dist/research.d.ts +1 -1
- package/dist/retry.d.ts +143 -0
- package/dist/retry.js +127 -0
- package/dist/runtime.d.ts +56 -4
- package/dist/runtime.js +727 -125
- package/dist/store.d.ts +62 -7
- package/dist/store.js +86 -15
- package/dist/team-artifacts.d.ts +130 -112
- package/dist/team-artifacts.js +123 -151
- package/dist/team-child.d.ts +4 -1
- package/dist/team-child.js +21 -2
- package/dist/team-contract.d.ts +1 -1
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.js +83 -47
- package/dist/tool-scheduler.d.ts +84 -0
- package/dist/tool-scheduler.js +226 -0
- package/dist/tools.d.ts +78 -4
- package/dist/tools.js +34 -7
- package/package.json +16 -9
- package/profiles/assistant/config.yaml +2 -1
package/dist/a2a-client.d.ts
CHANGED
|
@@ -2,7 +2,22 @@ import { type AgentCard, type ListTasksResponse, type SendMessageResult, type St
|
|
|
2
2
|
import { type Client } from '@a2a-js/sdk/client';
|
|
3
3
|
import type { ArdentConfig } from './config.js';
|
|
4
4
|
import type { A2APushInbox } from './a2a-push-inbox.js';
|
|
5
|
+
import { type ExecutionContext } from './execution.js';
|
|
6
|
+
import { type AttemptFailure } from './retry.js';
|
|
7
|
+
/**
|
|
8
|
+
* What the last HTTP exchange of one A2A call looked like. The SDK reports failures as plain
|
|
9
|
+
* errors, so the fetch wrapper records the status, `Retry-After` and `x-hive-retry` it saw.
|
|
10
|
+
*/
|
|
11
|
+
export declare class WireObservation {
|
|
12
|
+
failure: AttemptFailure | undefined;
|
|
13
|
+
reset(): void;
|
|
14
|
+
classify: () => AttemptFailure | undefined;
|
|
15
|
+
}
|
|
5
16
|
export declare function fetchHermesTeamCard(card: AgentCard, authorization: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
17
|
+
/** Per-message options. `execution` is the delegating task's context (attribution only). */
|
|
18
|
+
export type A2ASendOptions = {
|
|
19
|
+
execution?: ExecutionContext | undefined;
|
|
20
|
+
};
|
|
6
21
|
export declare class ArdentA2AClient {
|
|
7
22
|
readonly profileDir: string;
|
|
8
23
|
readonly config: ArdentConfig;
|
|
@@ -10,10 +25,12 @@ export declare class ArdentA2AClient {
|
|
|
10
25
|
readonly pushInbox?: A2APushInbox | undefined;
|
|
11
26
|
readonly preferredTransports: string[];
|
|
12
27
|
constructor(profileDir: string, config: ArdentConfig, env?: NodeJS.ProcessEnv, pushInbox?: A2APushInbox | undefined, preferredTransports?: string[]);
|
|
13
|
-
|
|
28
|
+
/** Resolve the peer's card (retried as a read) and build a client whose HTTP exchanges are observed. */
|
|
29
|
+
open(peerId: string, signal?: AbortSignal): Promise<{
|
|
14
30
|
card: AgentCard;
|
|
15
31
|
client: Client;
|
|
16
32
|
authorization: string;
|
|
33
|
+
observation: WireObservation;
|
|
17
34
|
}>;
|
|
18
35
|
teamControl(peerId: string, control: {
|
|
19
36
|
version: '1.0';
|
|
@@ -21,14 +38,19 @@ export declare class ArdentA2AClient {
|
|
|
21
38
|
key: string;
|
|
22
39
|
payload: object;
|
|
23
40
|
}): Promise<Record<string, unknown>>;
|
|
24
|
-
send(peerId: string, prompt: string, signal?: AbortSignal, contextId?: string, taskId?: string): Promise<SendMessageResult>;
|
|
41
|
+
send(peerId: string, prompt: string, signal?: AbortSignal, contextId?: string, taskId?: string, options?: A2ASendOptions): Promise<SendMessageResult>;
|
|
25
42
|
getTask(peerId: string, id: string, historyLength?: number): Promise<Task>;
|
|
26
43
|
listTasks(peerId: string, pageSize?: number, pageToken?: string, contextId?: string): Promise<ListTasksResponse>;
|
|
27
44
|
cancelTask(peerId: string, id: string): Promise<Task>;
|
|
28
45
|
extendedCard(peerId: string): Promise<AgentCard>;
|
|
29
46
|
subscribe(peerId: string, id: string, signal?: AbortSignal): AsyncGenerator<StreamResponse>;
|
|
30
|
-
sendStreaming(peerId: string, prompt: string, signal?: AbortSignal): AsyncGenerator<StreamResponse>;
|
|
31
|
-
|
|
47
|
+
sendStreaming(peerId: string, prompt: string, signal?: AbortSignal, options?: A2ASendOptions): AsyncGenerator<StreamResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Send one message. With `options.execution` (the delegating task's context)
|
|
50
|
+
* the message carries `metadata.hiveExecution`, so the receiving task keeps
|
|
51
|
+
* the root and takes the delegating task as its parent.
|
|
52
|
+
*/
|
|
53
|
+
sendWithReceipt(peerId: string, prompt: string, signal?: AbortSignal, contextId?: string, taskId?: string, options?: A2ASendOptions): Promise<{
|
|
32
54
|
result: SendMessageResult;
|
|
33
55
|
outboundId?: string;
|
|
34
56
|
}>;
|
package/dist/a2a-client.js
CHANGED
|
@@ -5,20 +5,63 @@ import { GrpcTransportFactory } from '@a2a-js/sdk/client/grpc';
|
|
|
5
5
|
import { credentials } from '@grpc/grpc-js';
|
|
6
6
|
import { loadPeers, outboundTokenEnv } from './a2a-peers.js';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { parseExecutionContext } from '@hivemagnus/hive-common/execution';
|
|
9
|
+
import { EXECUTION_METADATA_KEY } from './execution.js';
|
|
10
|
+
import { isTransportError, lastAttemptError, responseFailure, retryWithPolicy } from './retry.js';
|
|
11
|
+
/**
|
|
12
|
+
* What the last HTTP exchange of one A2A call looked like. The SDK reports failures as plain
|
|
13
|
+
* errors, so the fetch wrapper records the status, `Retry-After` and `x-hive-retry` it saw.
|
|
14
|
+
*/
|
|
15
|
+
export class WireObservation {
|
|
16
|
+
failure;
|
|
17
|
+
reset() { this.failure = undefined; }
|
|
18
|
+
classify = () => this.failure;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Repeat one A2A call under `policy`, keeping the SDK's own error when retrying stops.
|
|
22
|
+
* Only HTTP exchanges are observed; a gRPC failure is never repeated.
|
|
23
|
+
*/
|
|
24
|
+
async function retryA2A(policy, observation, operation, options = {}) {
|
|
25
|
+
try {
|
|
26
|
+
return await retryWithPolicy(policy, async () => { observation.reset(); return operation(); }, { ...options, effect: policy === 'a2a_read' ? 'none' : 'idempotent', classify: observation.classify });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw lastAttemptError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
8
32
|
export async function fetchHermesTeamCard(card, authorization, signal) {
|
|
9
33
|
const interfaceUrl = card.supportedInterfaces.find(item => item.protocolBinding.toUpperCase() === 'JSONRPC' && item.protocolVersion === '1.0')?.url;
|
|
10
34
|
if (!interfaceUrl)
|
|
11
35
|
throw new Error('Hermes peer has no JSON-RPC 1.0 interface');
|
|
12
36
|
const url = new URL('/.well-known/hermes-team-card.json', interfaceUrl);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
37
|
+
const observation = new WireObservation();
|
|
38
|
+
const response = await retryA2A('a2a_read', observation, async () => {
|
|
39
|
+
let attempt;
|
|
40
|
+
try {
|
|
41
|
+
attempt = await fetch(url, { redirect: 'manual', headers: { Authorization: authorization, Accept: 'application/json' }, signal: signal ?? AbortSignal.timeout(10_000) });
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (isTransportError(error))
|
|
45
|
+
observation.failure = { network: true };
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (attempt.ok)
|
|
49
|
+
return attempt;
|
|
50
|
+
await attempt.body?.cancel().catch(() => { });
|
|
51
|
+
observation.failure = responseFailure(attempt);
|
|
52
|
+
throw new Error(`Hermes team card HTTP ${attempt.status}`);
|
|
53
|
+
}, signal ? { signal } : {});
|
|
16
54
|
const encoded = await response.text();
|
|
17
55
|
if (Buffer.byteLength(encoded) > 256_000)
|
|
18
56
|
throw new Error('Hermes team card exceeds bound');
|
|
19
57
|
const raw = JSON.parse(encoded);
|
|
20
58
|
return z.record(z.string(), z.unknown()).parse(raw);
|
|
21
59
|
}
|
|
60
|
+
/** Message metadata carrying an execution context as `hiveExecution`; empty without a valid one. */
|
|
61
|
+
function executionMetadata(options) {
|
|
62
|
+
const execution = parseExecutionContext(options.execution);
|
|
63
|
+
return execution ? { [EXECUTION_METADATA_KEY]: execution } : {};
|
|
64
|
+
}
|
|
22
65
|
export class ArdentA2AClient {
|
|
23
66
|
profileDir;
|
|
24
67
|
config;
|
|
@@ -32,7 +75,8 @@ export class ArdentA2AClient {
|
|
|
32
75
|
this.pushInbox = pushInbox;
|
|
33
76
|
this.preferredTransports = preferredTransports;
|
|
34
77
|
}
|
|
35
|
-
|
|
78
|
+
/** Resolve the peer's card (retried as a read) and build a client whose HTTP exchanges are observed. */
|
|
79
|
+
async open(peerId, signal) {
|
|
36
80
|
const { peers } = await loadPeers(this.profileDir, this.config, this.env);
|
|
37
81
|
const peer = peers.find(item => item.id === peerId && item.enabled);
|
|
38
82
|
if (!peer)
|
|
@@ -49,14 +93,24 @@ export class ArdentA2AClient {
|
|
|
49
93
|
return parsed.hostname === base.hostname && !parsed.username && !parsed.password && !parsed.hash && allowedPorts.has(port) &&
|
|
50
94
|
(grpc ? Boolean(parsed.port) : (base.protocol !== 'https:' || parsed.protocol === 'https:'));
|
|
51
95
|
};
|
|
52
|
-
const
|
|
96
|
+
const observation = new WireObservation();
|
|
97
|
+
const safeFetch = async (input, init) => {
|
|
53
98
|
const url = new URL(input instanceof Request ? input.url : String(input));
|
|
54
99
|
if (!sameHost(url.href, false))
|
|
55
100
|
throw new Error('A2A peer card redirected to an unconfigured host or port');
|
|
56
|
-
|
|
101
|
+
try {
|
|
102
|
+
const response = await fetch(input, { ...init, redirect: 'manual', signal: init?.signal ?? AbortSignal.timeout(30000) });
|
|
103
|
+
observation.failure = response.ok ? undefined : responseFailure(response);
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (isTransportError(error))
|
|
108
|
+
observation.failure = { network: true };
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
57
111
|
};
|
|
58
112
|
const resolver = new DefaultAgentCardResolver({ fetchImpl: safeFetch, legacyCompat: { enabled: true } });
|
|
59
|
-
const card = await resolver.resolve(peer.url);
|
|
113
|
+
const card = await retryA2A('a2a_read', observation, () => resolver.resolve(peer.url), signal ? { signal } : {});
|
|
60
114
|
if (!card.supportedInterfaces.length)
|
|
61
115
|
throw new Error('A2A peer card has no interfaces');
|
|
62
116
|
for (const iface of card.supportedInterfaces)
|
|
@@ -67,7 +121,7 @@ export class ArdentA2AClient {
|
|
|
67
121
|
transports: [new JsonRpcTransportFactory({ fetchImpl: safeFetch, legacyCompat: { enabled: true } }), new RestTransportFactory({ fetchImpl: safeFetch, legacyCompat: { enabled: true } }), new GrpcTransportFactory({ legacyCompat: { enabled: true }, grpcChannelCredentials: base.protocol === 'https:' ? credentials.createSsl() : credentials.createInsecure() })],
|
|
68
122
|
preferredTransports: this.preferredTransports
|
|
69
123
|
}));
|
|
70
|
-
return { card, client: await factory.createFromAgentCard(card), authorization: `Bearer ${token}
|
|
124
|
+
return { card, client: await factory.createFromAgentCard(card), authorization: `Bearer ${token}`, observation };
|
|
71
125
|
}
|
|
72
126
|
async teamControl(peerId, control) {
|
|
73
127
|
const { card, authorization } = await this.open(peerId);
|
|
@@ -109,52 +163,64 @@ export class ArdentA2AClient {
|
|
|
109
163
|
const parsed = z.object({ version: z.literal('1.0'), request_digest: z.string().regex(/^[a-f0-9]{64}$/), data: z.record(z.string(), z.unknown()) }).parse(receipt);
|
|
110
164
|
return parsed;
|
|
111
165
|
}
|
|
112
|
-
async send(peerId, prompt, signal, contextId, taskId) {
|
|
113
|
-
return (await this.sendWithReceipt(peerId, prompt, signal, contextId, taskId)).result;
|
|
166
|
+
async send(peerId, prompt, signal, contextId, taskId, options = {}) {
|
|
167
|
+
return (await this.sendWithReceipt(peerId, prompt, signal, contextId, taskId, options)).result;
|
|
114
168
|
}
|
|
115
169
|
async getTask(peerId, id, historyLength) {
|
|
116
|
-
const { client, authorization } = await this.open(peerId);
|
|
117
|
-
return client.getTask({ tenant: '', id, ...(historyLength === undefined ? {} : { historyLength }) }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } });
|
|
170
|
+
const { client, authorization, observation } = await this.open(peerId);
|
|
171
|
+
return retryA2A('a2a_read', observation, () => client.getTask({ tenant: '', id, ...(historyLength === undefined ? {} : { historyLength }) }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } }));
|
|
118
172
|
}
|
|
119
173
|
async listTasks(peerId, pageSize = 50, pageToken = '', contextId = '') {
|
|
120
174
|
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100)
|
|
121
175
|
throw new Error('A2A page size must be 1 to 100');
|
|
122
|
-
const { client, authorization } = await this.open(peerId);
|
|
123
|
-
return client.listTasks({ tenant: '', contextId, status: TaskState.TASK_STATE_UNSPECIFIED, pageSize, pageToken, statusTimestampAfter: undefined }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } });
|
|
176
|
+
const { client, authorization, observation } = await this.open(peerId);
|
|
177
|
+
return retryA2A('a2a_read', observation, () => client.listTasks({ tenant: '', contextId, status: TaskState.TASK_STATE_UNSPECIFIED, pageSize, pageToken, statusTimestampAfter: undefined }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } }));
|
|
124
178
|
}
|
|
125
179
|
async cancelTask(peerId, id) {
|
|
126
180
|
const { client, authorization } = await this.open(peerId);
|
|
127
181
|
return client.cancelTask({ tenant: '', id, metadata: undefined }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } });
|
|
128
182
|
}
|
|
129
183
|
async extendedCard(peerId) {
|
|
130
|
-
const { card, client, authorization } = await this.open(peerId);
|
|
184
|
+
const { card, client, authorization, observation } = await this.open(peerId);
|
|
131
185
|
if (!card.capabilities?.extendedAgentCard)
|
|
132
186
|
throw new Error('A2A peer does not advertise an extended Agent Card');
|
|
133
|
-
return client.getAgentCard({ serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } });
|
|
187
|
+
return retryA2A('a2a_read', observation, () => client.getAgentCard({ serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' } }));
|
|
134
188
|
}
|
|
135
189
|
async *subscribe(peerId, id, signal) {
|
|
136
190
|
const { client, authorization } = await this.open(peerId);
|
|
137
191
|
yield* client.resubscribeTask({ tenant: '', id }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' }, ...(signal ? { signal } : {}) });
|
|
138
192
|
}
|
|
139
|
-
async *sendStreaming(peerId, prompt, signal) {
|
|
193
|
+
async *sendStreaming(peerId, prompt, signal, options = {}) {
|
|
140
194
|
if (!prompt.trim() || prompt.length > 16000)
|
|
141
195
|
throw new Error('A2A prompt must be 1 to 16000 characters');
|
|
142
196
|
const { client, authorization } = await this.open(peerId);
|
|
143
|
-
const message = { messageId: randomUUID(), contextId: '', taskId: '', role: Role.ROLE_USER, parts: [{ content: { $case: 'text', value: prompt }, metadata: undefined, filename: '', mediaType: 'text/plain' }], metadata:
|
|
197
|
+
const message = { messageId: randomUUID(), contextId: '', taskId: '', role: Role.ROLE_USER, parts: [{ content: { $case: 'text', value: prompt }, metadata: undefined, filename: '', mediaType: 'text/plain' }], metadata: executionMetadata(options), extensions: [], referenceTaskIds: [] };
|
|
144
198
|
yield* client.sendMessageStream({ tenant: '', message, configuration: undefined, metadata: undefined }, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' }, ...(signal ? { signal } : {}) });
|
|
145
199
|
}
|
|
146
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Send one message. With `options.execution` (the delegating task's context)
|
|
202
|
+
* the message carries `metadata.hiveExecution`, so the receiving task keeps
|
|
203
|
+
* the root and takes the delegating task as its parent.
|
|
204
|
+
*/
|
|
205
|
+
async sendWithReceipt(peerId, prompt, signal, contextId, taskId, options = {}) {
|
|
147
206
|
if (!prompt.trim() || prompt.length > 16000)
|
|
148
207
|
throw new Error('A2A prompt must be 1 to 16000 characters');
|
|
149
|
-
const { card, client, authorization } = await this.open(peerId);
|
|
150
|
-
const message = { messageId: randomUUID(), contextId: contextId ?? '', taskId: taskId ?? '', role: Role.ROLE_USER, parts: [{ content: { $case: 'text', value: prompt }, metadata: undefined, filename: '', mediaType: 'text/plain' }], metadata:
|
|
208
|
+
const { card, client, authorization, observation } = await this.open(peerId, signal);
|
|
209
|
+
const message = { messageId: randomUUID(), contextId: contextId ?? '', taskId: taskId ?? '', role: Role.ROLE_USER, parts: [{ content: { $case: 'text', value: prompt }, metadata: undefined, filename: '', mediaType: 'text/plain' }], metadata: executionMetadata(options), extensions: [], referenceTaskIds: [] };
|
|
151
210
|
const registered = this.pushInbox && card.capabilities?.pushNotifications ? this.pushInbox.register(peerId, message.messageId) : undefined;
|
|
152
211
|
const request = { tenant: '', message, configuration: registered ? {
|
|
153
212
|
acceptedOutputModes: ['text/plain', 'application/json'], returnImmediately: false,
|
|
154
213
|
taskPushNotificationConfig: { tenant: '', id: '', taskId: '', url: registered.url, token: registered.token, authentication: undefined }
|
|
155
214
|
} : undefined, metadata: undefined };
|
|
215
|
+
let attempts = 0;
|
|
156
216
|
try {
|
|
157
|
-
|
|
217
|
+
// Every attempt sends the same request, so the same messageId: the peer deduplicates on it.
|
|
218
|
+
const result = await retryA2A('a2a_send', observation, () => {
|
|
219
|
+
attempts++;
|
|
220
|
+
return client.sendMessage(request, { serviceParameters: { Authorization: authorization, 'A2A-Version': '1.0' }, ...(signal ? { signal } : {}) });
|
|
221
|
+
}, signal ? { signal } : {});
|
|
222
|
+
if (registered)
|
|
223
|
+
this.pushInbox?.recordAttempts(registered.id, attempts);
|
|
158
224
|
if (registered) {
|
|
159
225
|
if ('id' in result && typeof result.id === 'string')
|
|
160
226
|
this.pushInbox?.bind(registered.id, result.id);
|
|
@@ -164,8 +230,10 @@ export class ArdentA2AClient {
|
|
|
164
230
|
return { result, ...(registered ? { outboundId: registered.id } : {}) };
|
|
165
231
|
}
|
|
166
232
|
catch (error) {
|
|
167
|
-
if (registered)
|
|
233
|
+
if (registered) {
|
|
234
|
+
this.pushInbox?.recordAttempts(registered.id, attempts);
|
|
168
235
|
this.pushInbox?.markFailed(registered.id);
|
|
236
|
+
}
|
|
169
237
|
throw error;
|
|
170
238
|
}
|
|
171
239
|
}
|
package/dist/a2a-push-inbox.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export declare class A2APushInbox {
|
|
|
18
18
|
url: string;
|
|
19
19
|
};
|
|
20
20
|
bind(id: string, taskId: string): void;
|
|
21
|
+
/** How many SendMessage attempts the call took (all with the same messageId). */
|
|
22
|
+
recordAttempts(id: string, attempts: number): void;
|
|
21
23
|
markFailed(id: string): void;
|
|
22
24
|
/** Checks the callback token alone, so an unauthorized sender cannot make the server parse its body. */
|
|
23
25
|
authorize(peerId: string, token: string | undefined): z.infer<typeof Outbound>;
|
package/dist/a2a-push-inbox.js
CHANGED
|
@@ -20,6 +20,9 @@ export class A2APushInbox {
|
|
|
20
20
|
id TEXT PRIMARY KEY, outbound_id TEXT NOT NULL, task_id TEXT NOT NULL,
|
|
21
21
|
event_json TEXT NOT NULL, received_ms INTEGER NOT NULL);
|
|
22
22
|
CREATE INDEX IF NOT EXISTS a2a_inbound_push_outbound ON a2a_inbound_push(outbound_id,received_ms);`);
|
|
23
|
+
const columns = z.array(z.object({ name: z.string() })).parse(db.pragma('table_info(a2a_outbound_calls)'));
|
|
24
|
+
if (!columns.some(column => column.name === 'attempts'))
|
|
25
|
+
db.exec('ALTER TABLE a2a_outbound_calls ADD COLUMN attempts INTEGER');
|
|
23
26
|
}
|
|
24
27
|
register(peerId, messageId) {
|
|
25
28
|
if (!this.peers.some(peer => peer.enabled && peer.id === peerId))
|
|
@@ -45,6 +48,10 @@ export class A2APushInbox {
|
|
|
45
48
|
throw new Error('A2A callback task mismatch');
|
|
46
49
|
this.db.prepare("UPDATE a2a_outbound_calls SET task_id=?,state='bound',updated_ms=? WHERE id=?").run(taskId, Date.now(), id);
|
|
47
50
|
}
|
|
51
|
+
/** How many SendMessage attempts the call took (all with the same messageId). */
|
|
52
|
+
recordAttempts(id, attempts) {
|
|
53
|
+
this.db.prepare('UPDATE a2a_outbound_calls SET attempts=?,updated_ms=? WHERE id=?').run(attempts, Date.now(), id);
|
|
54
|
+
}
|
|
48
55
|
markFailed(id) { this.db.prepare("UPDATE a2a_outbound_calls SET state='failed',updated_ms=? WHERE id=?").run(Date.now(), id); }
|
|
49
56
|
/** Checks the callback token alone, so an unauthorized sender cannot make the server parse its body. */
|
|
50
57
|
authorize(peerId, token) {
|
package/dist/a2a-push.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class SqliteA2APushStore implements PushNotificationStore {
|
|
|
12
12
|
delete(taskId: string, context: ServerCallContext, configId?: string): Promise<void>;
|
|
13
13
|
claimDelivery(id: string, taskId: string, context: ServerCallContext, configId: string): boolean;
|
|
14
14
|
deliveryState(id: string): 'queued' | 'sent' | 'failed' | 'unknown' | undefined;
|
|
15
|
-
setDelivery(id: string, state: 'sent' | 'failed' | 'unknown', httpStatus?: number, error?: string): void;
|
|
15
|
+
setDelivery(id: string, state: 'sent' | 'failed' | 'unknown', httpStatus?: number, error?: string, attempts?: number): void;
|
|
16
16
|
}
|
|
17
17
|
/** Thrown by a `beforeDelivery` hook to refuse a push deterministically (recorded as failed, not unknown). */
|
|
18
18
|
export declare class DeliveryVetoError extends Error {
|
package/dist/a2a-push.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isIP } from 'node:net';
|
|
|
3
3
|
import { StreamResponse as StreamCodec, TaskPushNotificationConfig as PushCodec } from '@a2a-js/sdk';
|
|
4
4
|
import { RequestMalformedError } from '@a2a-js/sdk/errors';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { AttemptError, lastAttemptError, responseFailure, retryWithPolicy } from './retry.js';
|
|
6
7
|
const Row = z.object({ config_json: z.string(), wire_version: z.string() });
|
|
7
8
|
const Delivery = z.object({ state: z.enum(['queued', 'sent', 'failed', 'unknown']) });
|
|
8
9
|
function scope(context) {
|
|
@@ -51,6 +52,8 @@ export class SqliteA2APushStore {
|
|
|
51
52
|
const columns = z.array(z.object({ name: z.string() })).parse(db.pragma('table_info(a2a_push_deliveries)'));
|
|
52
53
|
if (!columns.some(column => column.name === 'error'))
|
|
53
54
|
db.exec('ALTER TABLE a2a_push_deliveries ADD COLUMN error TEXT');
|
|
55
|
+
if (!columns.some(column => column.name === 'attempts'))
|
|
56
|
+
db.exec('ALTER TABLE a2a_push_deliveries ADD COLUMN attempts INTEGER');
|
|
54
57
|
db.prepare("UPDATE a2a_push_deliveries SET state='unknown',updated_ms=? WHERE state='queued'").run(Date.now());
|
|
55
58
|
}
|
|
56
59
|
async save(taskId, context, config) {
|
|
@@ -105,8 +108,9 @@ export class SqliteA2APushStore {
|
|
|
105
108
|
const row = this.db.prepare('SELECT state FROM a2a_push_deliveries WHERE id=?').get(id);
|
|
106
109
|
return row ? Delivery.parse(row).state : undefined;
|
|
107
110
|
}
|
|
108
|
-
setDelivery(id, state, httpStatus, error) {
|
|
109
|
-
this.db.prepare('UPDATE a2a_push_deliveries SET state=?,http_status=?,error=?,updated_ms=? WHERE id=?')
|
|
111
|
+
setDelivery(id, state, httpStatus, error, attempts) {
|
|
112
|
+
this.db.prepare('UPDATE a2a_push_deliveries SET state=?,http_status=?,error=?,attempts=COALESCE(?,attempts),updated_ms=? WHERE id=?')
|
|
113
|
+
.run(state, httpStatus ?? null, error?.slice(0, 300) ?? null, attempts ?? null, Date.now(), id);
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
/** Thrown by a `beforeDelivery` hook to refuse a push deterministically (recorded as failed, not unknown). */
|
|
@@ -154,25 +158,29 @@ export class SafeA2APushSender {
|
|
|
154
158
|
headers['Authorization'] = `${config.authentication.scheme} ${config.authentication.credentials}`;
|
|
155
159
|
else if (config.token)
|
|
156
160
|
headers['X-A2A-Notification-Token'] = config.token;
|
|
161
|
+
// A 429 or 5xx means the callback did not accept the event, so it is repeated under the
|
|
162
|
+
// `a2a_push` policy with `Retry-After` clamped to 1–5 s. A transport failure or timeout
|
|
163
|
+
// may have been accepted and is recorded as unknown, never repeated.
|
|
164
|
+
let attempts = 0;
|
|
157
165
|
try {
|
|
158
|
-
|
|
166
|
+
const response = await retryWithPolicy('a2a_push', async () => {
|
|
167
|
+
attempts++;
|
|
159
168
|
this.beforeDelivery?.(taskId);
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
this.store.setDelivery(id, response.status >= 500 ? 'unknown' : 'failed', response.status);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
169
|
+
const attempt = await fetch(config.url, { method: 'POST', headers, body, redirect: 'error', signal: AbortSignal.timeout(5000) });
|
|
170
|
+
if (attempt.ok)
|
|
171
|
+
return attempt;
|
|
172
|
+
await attempt.body?.cancel().catch(() => { });
|
|
173
|
+
const failure = responseFailure(attempt);
|
|
174
|
+
throw new AttemptError(`A2A push callback HTTP ${attempt.status}`, { ...failure, retryAfterMs: Math.min(5000, Math.max(1000, failure.retryAfterMs ?? 1000)) });
|
|
175
|
+
}, { effect: 'idempotent' });
|
|
176
|
+
this.store.setDelivery(id, 'sent', response.status, undefined, attempts);
|
|
173
177
|
}
|
|
174
|
-
catch (
|
|
175
|
-
|
|
178
|
+
catch (raw) {
|
|
179
|
+
const error = lastAttemptError(raw);
|
|
180
|
+
if (error instanceof AttemptError && error.failure.status !== undefined)
|
|
181
|
+
this.store.setDelivery(id, error.failure.status >= 500 ? 'unknown' : 'failed', error.failure.status, undefined, attempts);
|
|
182
|
+
else
|
|
183
|
+
this.store.setDelivery(id, error instanceof DeliveryVetoError ? 'failed' : 'unknown', undefined, error instanceof Error ? error.message : 'Callback outcome unknown', attempts);
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
});
|
package/dist/a2a-server.d.ts
CHANGED
|
@@ -8,6 +8,22 @@ import type { ArdentRuntime } from './runtime.js';
|
|
|
8
8
|
import { hermesTeamCard } from './hermes-compat.js';
|
|
9
9
|
import { IdempotentA2AHandler } from './a2a-idempotency.js';
|
|
10
10
|
import { PeerTaskGate, TokenBucketLimiter } from './a2a-rate-limit.js';
|
|
11
|
+
/** The transfer-v2 capability this runtime advertises on its Agent Card. */
|
|
12
|
+
export declare function artifactTransferExtension(maxBytes: number): {
|
|
13
|
+
uri: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
params: {
|
|
17
|
+
max_bytes: number;
|
|
18
|
+
range: boolean;
|
|
19
|
+
renditions: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** Publishes the outcome of A2A tasks whose operation execution recovery resumed, held or continued (see `ArdentA2AExecutor.publishRecovered`). */
|
|
23
|
+
export type A2ARecoveryPublisher = {
|
|
24
|
+
idle(): Promise<void>; /** Stop listening for settled tasks. */
|
|
25
|
+
close(): void;
|
|
26
|
+
};
|
|
11
27
|
export type A2ASurface = {
|
|
12
28
|
app: Express;
|
|
13
29
|
grpcServer: GrpcServer;
|
|
@@ -18,6 +34,7 @@ export type A2ASurface = {
|
|
|
18
34
|
pushInbox: A2APushInbox;
|
|
19
35
|
handler: IdempotentA2AHandler;
|
|
20
36
|
taskGate: PeerTaskGate;
|
|
37
|
+
recovery: A2ARecoveryPublisher;
|
|
21
38
|
};
|
|
22
39
|
/** Refresh only discovery freshness; the reviewed runtime identity and digests stay pinned to this process. */
|
|
23
40
|
export declare function freshHermesTeamCard(source: Awaited<ReturnType<typeof hermesTeamCard>>, now?: number): {
|
package/dist/a2a-server.js
CHANGED
|
@@ -17,6 +17,13 @@ import { hermesAlias } from './a2a-hermes-alias.js';
|
|
|
17
17
|
import { ARDENT_VERSION } from './version.js';
|
|
18
18
|
import { clientKey, GatedA2AExecutor, jsonRpcTaskCap, limitRequests, PeerTaskGate, restTaskCap, TokenBucketLimiter } from './a2a-rate-limit.js';
|
|
19
19
|
import { TeamArtifacts } from './team-artifacts.js';
|
|
20
|
+
import { pipeline } from 'node:stream/promises';
|
|
21
|
+
import { ARTIFACT_TRANSFER_V2_URN, formatReprDigest, parseByteRange } from '@hivemagnus/hive-common/artifact';
|
|
22
|
+
/** The transfer-v2 capability this runtime advertises on its Agent Card. */
|
|
23
|
+
export function artifactTransferExtension(maxBytes) {
|
|
24
|
+
return { uri: ARTIFACT_TRANSFER_V2_URN, description: 'Resumable artifact transfer over HTTP Range with SHA-256 verification and renditions',
|
|
25
|
+
required: false, params: { max_bytes: maxBytes, range: true, renditions: true } };
|
|
26
|
+
}
|
|
20
27
|
/** Refresh only discovery freshness; the reviewed runtime identity and digests stay pinned to this process. */
|
|
21
28
|
export function freshHermesTeamCard(source, now = Date.now()) {
|
|
22
29
|
const team = z.object({ discovery: z.object({ observedAt: z.number().int(), expiresAt: z.number().int() }).passthrough() })
|
|
@@ -71,7 +78,7 @@ export async function createA2ASurface(runtime, config, env = process.env) {
|
|
|
71
78
|
supportedInterfaces: interfaces,
|
|
72
79
|
provider: { organization: 'Magnus', url: 'https://github.com/ChefTaco/magnus' },
|
|
73
80
|
version: ARDENT_VERSION,
|
|
74
|
-
capabilities: { streaming: true, pushNotifications: true, extendedAgentCard: true, extensions: [] },
|
|
81
|
+
capabilities: { streaming: true, pushNotifications: true, extendedAgentCard: true, extensions: [artifactTransferExtension(config.artifacts.max_bytes)] },
|
|
75
82
|
securitySchemes: { Bearer: { scheme: { $case: 'httpAuthSecurityScheme', value: { description: 'Peer bearer token', scheme: 'bearer', bearerFormat: '' } } } },
|
|
76
83
|
securityRequirements: bearerRequirement,
|
|
77
84
|
defaultInputModes: ['text/plain', 'text/markdown', 'application/json'],
|
|
@@ -86,7 +93,31 @@ export async function createA2ASurface(runtime, config, env = process.env) {
|
|
|
86
93
|
const taskStore = new SqliteA2ATaskStore(runtime.store.db);
|
|
87
94
|
const limits = config.a2a.rate_limit;
|
|
88
95
|
const taskGate = new PeerTaskGate(limits.enabled ? limits.max_concurrent_tasks_per_peer : Number.MAX_SAFE_INTEGER);
|
|
89
|
-
const
|
|
96
|
+
const executor = new ArdentA2AExecutor(runtime, env);
|
|
97
|
+
// Interrupted peer tasks have no live request left; publish their outcome once now and after each task settles.
|
|
98
|
+
let recoveryPass;
|
|
99
|
+
let again = false;
|
|
100
|
+
let closed = false;
|
|
101
|
+
const publish = () => {
|
|
102
|
+
if (closed)
|
|
103
|
+
return;
|
|
104
|
+
if (recoveryPass) {
|
|
105
|
+
again = true;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
recoveryPass = executor.publishRecovered(taskStore, pushSender).then(() => undefined, () => undefined)
|
|
109
|
+
.finally(() => { recoveryPass = undefined; if (again) {
|
|
110
|
+
again = false;
|
|
111
|
+
publish();
|
|
112
|
+
} });
|
|
113
|
+
};
|
|
114
|
+
const unsubscribe = runtime.onTaskSettled(() => publish());
|
|
115
|
+
const recovery = {
|
|
116
|
+
idle: async () => { while (recoveryPass)
|
|
117
|
+
await recoveryPass; },
|
|
118
|
+
close: () => { closed = true; unsubscribe(); }
|
|
119
|
+
};
|
|
120
|
+
const handler = new IdempotentA2AHandler(runtime.store.db, taskStore, taskGate, card, taskStore, new GatedA2AExecutor(executor, taskGate), undefined, pushStore, pushSender, async (context) => {
|
|
90
121
|
const peerId = context.user?.userName;
|
|
91
122
|
if (!context.user?.isAuthenticated || !peerId || !peers.some(peer => peer.id === peerId && peer.enabled))
|
|
92
123
|
throw new Error('Authenticated configured peer required');
|
|
@@ -116,19 +147,64 @@ export async function createA2ASurface(runtime, config, env = process.env) {
|
|
|
116
147
|
// First in the chain: every route below, authenticated or not, is limited by client address.
|
|
117
148
|
if (limits.enabled)
|
|
118
149
|
app.use(limitRequests(new TokenBucketLimiter({ perMinute: limits.ip_requests_per_minute, burst: limits.ip_burst }), req => clientKey(req.ip)));
|
|
150
|
+
const unavailable = (status) => ({ error: status === 410 ? 'Artifact export revoked or expired' : 'Artifact unavailable' });
|
|
151
|
+
/** Resolve the export for the authenticated peer, or answer the refusal. */
|
|
152
|
+
const exportFor = async (req, res) => {
|
|
153
|
+
try {
|
|
154
|
+
const result = await artifactTransfers.resolve(peerOf(res), String(req.params.id ?? ''), String(req.query.context ?? ''));
|
|
155
|
+
if (result.status === 200)
|
|
156
|
+
return result;
|
|
157
|
+
res.status(result.status).json(unavailable(result.status));
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
res.status(503).json({ error: 'Artifact export state is unavailable' });
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
};
|
|
164
|
+
// Content of one export. Without Range (or with a stale If-Range) this is the
|
|
165
|
+
// v1 full response, verified as it streams; Range answers 206 or 416.
|
|
119
166
|
app.get('/team/artifacts/:id', requirePeer('Authenticated A2A peer required'), peerLimit, async (req, res) => {
|
|
120
|
-
const
|
|
167
|
+
const resolved = await exportFor(req, res);
|
|
168
|
+
if (!resolved)
|
|
169
|
+
return;
|
|
170
|
+
const manifest = resolved.manifest;
|
|
171
|
+
const etag = `"${manifest.sha256}"`;
|
|
172
|
+
const ifRange = req.header('If-Range');
|
|
173
|
+
const range = parseByteRange(ifRange === undefined || ifRange === etag ? req.header('Range') : undefined, manifest.size);
|
|
174
|
+
const common = { 'Accept-Ranges': 'bytes', ETag: etag, 'Repr-Digest': formatReprDigest(manifest.sha256), 'X-Content-SHA256': manifest.sha256,
|
|
175
|
+
'X-Content-Type-Options': 'nosniff', 'Cache-Control': 'private, no-store' };
|
|
176
|
+
if (range === null) {
|
|
177
|
+
res.status(416).set({ ...common, 'Content-Range': `bytes */${manifest.size}` }).json({ error: 'Requested range is not satisfiable' });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
let read;
|
|
181
|
+
try {
|
|
182
|
+
read = await runtime.artifacts.openRead(manifest.sha256, range ?? {}, { verify: !range });
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
res.status(409).json(unavailable(409));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
res.status(range ? 206 : 200).set({ ...common, 'Content-Type': manifest.mime, 'Content-Length': String(read.end - read.start + 1),
|
|
189
|
+
...(range ? { 'Content-Range': `bytes ${read.start}-${read.end}/${manifest.size}` } : {}),
|
|
190
|
+
'Content-Disposition': `attachment; filename="${manifest.name}"`,
|
|
191
|
+
'X-Artifact-Name': encodeURIComponent(manifest.name), 'X-Hermes-Task-Id': manifest.provenance.producer_task_id,
|
|
192
|
+
...(resolved.manifest_1_0 ? { 'X-Hermes-Artifact-Manifest': Buffer.from(JSON.stringify(resolved.manifest_1_0)).toString('base64url') } : {}) });
|
|
193
|
+
// A digest failure mid-stream ends the connection before the final chunk.
|
|
194
|
+
await pipeline(read.stream, res).catch(() => { if (!res.destroyed)
|
|
195
|
+
res.destroy(); });
|
|
196
|
+
});
|
|
197
|
+
app.get('/team/artifacts/:id/manifest', requirePeer('Authenticated A2A peer required'), peerLimit, async (req, res) => {
|
|
198
|
+
const resolved = await exportFor(req, res);
|
|
199
|
+
if (resolved)
|
|
200
|
+
res.set('Cache-Control', 'private, no-store').json({ manifest: resolved.manifest });
|
|
201
|
+
});
|
|
202
|
+
app.get('/team/artifacts/:id/renditions', requirePeer('Authenticated A2A peer required'), peerLimit, async (req, res) => {
|
|
203
|
+
const resolved = await exportFor(req, res);
|
|
204
|
+
if (!resolved)
|
|
205
|
+
return;
|
|
121
206
|
try {
|
|
122
|
-
|
|
123
|
-
if (result.status !== 200 || !result.bytes || !result.descriptor) {
|
|
124
|
-
res.status(result.status).json({ error: result.status === 410 ? 'Artifact export revoked or expired' : 'Artifact unavailable' });
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const descriptor = result.descriptor;
|
|
128
|
-
res.status(200).set({ 'Content-Type': descriptor.mime, 'Content-Length': String(result.bytes.byteLength),
|
|
129
|
-
'X-Artifact-Name': encodeURIComponent(descriptor.name), 'X-Hermes-Task-Id': descriptor.producer_task_id,
|
|
130
|
-
'X-Hermes-Artifact-Manifest': Buffer.from(JSON.stringify(descriptor.artifact_manifest)).toString('base64url'),
|
|
131
|
-
'X-Content-Type-Options': 'nosniff', 'Cache-Control': 'private, no-store' }).end(Buffer.from(result.bytes));
|
|
207
|
+
res.set('Cache-Control', 'private, no-store').json({ renditions: await artifactTransfers.renditions(resolved) });
|
|
132
208
|
}
|
|
133
209
|
catch {
|
|
134
210
|
res.status(503).json({ error: 'Artifact export state is unavailable' });
|
|
@@ -204,7 +280,8 @@ export async function createA2ASurface(runtime, config, env = process.env) {
|
|
|
204
280
|
const raw = call.metadata.get('authorization')[0];
|
|
205
281
|
return limitedGrpcUser(authenticate(typeof raw === 'string' ? raw : undefined), limits.enabled ? peerBucket : undefined);
|
|
206
282
|
} }));
|
|
207
|
-
|
|
283
|
+
publish();
|
|
284
|
+
return { app, grpcServer, card, grpcAddress, grpcListenPort: listenPort + 1, pushSender, pushInbox, handler, taskGate, recovery };
|
|
208
285
|
}
|
|
209
286
|
export async function startA2AGrpc(surface, host = '127.0.0.1') {
|
|
210
287
|
await new Promise((resolve, reject) => {
|
package/dist/a2a.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentExecutor, type ExecutionEventBus, type RequestContext } from '@a2a-js/sdk/server';
|
|
1
|
+
import { type AgentExecutor, type ExecutionEventBus, type PushNotificationSender, type RequestContext, type TaskStore as A2ATaskStore } from '@a2a-js/sdk/server';
|
|
2
2
|
import type { ArdentRuntime } from './runtime.js';
|
|
3
3
|
/** An extracted article is an owner read when its connector result binds the
|
|
4
4
|
* exact request URL, source URL, retrieval time, and content digest. It remains
|
|
@@ -14,6 +14,24 @@ export declare class ArdentA2AExecutor implements AgentExecutor {
|
|
|
14
14
|
readonly runtime: ArdentRuntime;
|
|
15
15
|
readonly env: NodeJS.ProcessEnv;
|
|
16
16
|
constructor(runtime: ArdentRuntime, env?: NodeJS.ProcessEnv);
|
|
17
|
+
/**
|
|
18
|
+
* Tell peers the outcome of A2A tasks whose operation execution recovery
|
|
19
|
+
* resumed, settled, held or continued after a restart; the in-process
|
|
20
|
+
* request that would have published it is gone. Events go through the same
|
|
21
|
+
* task store (GetTask, ListTasks) and push sender as a live request:
|
|
22
|
+
*
|
|
23
|
+
* - resumed: the operation's answer, artifacts and final state, as live;
|
|
24
|
+
* - held awaiting an operator decision: a non-terminal `working` status
|
|
25
|
+
* whose message and `ardentRecovery` metadata give the reason;
|
|
26
|
+
* - continued after a decision: the continuation's outcome, published for
|
|
27
|
+
* the peer's original task (the A2A operation binding moves to the
|
|
28
|
+
* continuation, and `ardentRecovery.continuation_task_id` names it);
|
|
29
|
+
* - unsupported, or abandoned: `failed` with "Execution outcome is unknown".
|
|
30
|
+
*
|
|
31
|
+
* Each final state is claimed once before it is published, so it (and its
|
|
32
|
+
* push) is never published twice. Returns the tasks given a final state.
|
|
33
|
+
*/
|
|
34
|
+
publishRecovered(taskStore: A2ATaskStore, push: PushNotificationSender | undefined): Promise<number>;
|
|
17
35
|
execute(request: RequestContext, bus: ExecutionEventBus): Promise<void>;
|
|
18
36
|
cancelTask(taskId: string, bus: ExecutionEventBus): Promise<void>;
|
|
19
37
|
}
|