recoder-a2a-sdk 1.0.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/dist/audit-helpers.d.mts +209 -0
- package/dist/audit-helpers.d.ts +209 -0
- package/dist/audit-helpers.js +905 -0
- package/dist/audit-helpers.js.map +1 -0
- package/dist/audit-helpers.mjs +34 -0
- package/dist/audit-helpers.mjs.map +1 -0
- package/dist/chunk-7GY5FFBI.mjs +117 -0
- package/dist/chunk-7GY5FFBI.mjs.map +1 -0
- package/dist/chunk-AGD6G5N6.mjs +141 -0
- package/dist/chunk-AGD6G5N6.mjs.map +1 -0
- package/dist/chunk-BWCRJDUB.mjs +357 -0
- package/dist/chunk-BWCRJDUB.mjs.map +1 -0
- package/dist/chunk-DPFH2JIC.mjs +141 -0
- package/dist/chunk-DPFH2JIC.mjs.map +1 -0
- package/dist/chunk-EP2GHC3R.mjs +116 -0
- package/dist/chunk-EP2GHC3R.mjs.map +1 -0
- package/dist/chunk-JOZQDX7A.mjs +359 -0
- package/dist/chunk-JOZQDX7A.mjs.map +1 -0
- package/dist/chunk-MAA7JZ2Q.mjs +142 -0
- package/dist/chunk-MAA7JZ2Q.mjs.map +1 -0
- package/dist/chunk-QVOOBAUA.mjs +140 -0
- package/dist/chunk-QVOOBAUA.mjs.map +1 -0
- package/dist/chunk-T5GUBIFZ.mjs +358 -0
- package/dist/chunk-T5GUBIFZ.mjs.map +1 -0
- package/dist/chunk-WLNW7Y2H.mjs +636 -0
- package/dist/chunk-WLNW7Y2H.mjs.map +1 -0
- package/dist/chunk-XSELW6DU.mjs +356 -0
- package/dist/chunk-XSELW6DU.mjs.map +1 -0
- package/dist/envelope-builders.d.mts +189 -0
- package/dist/envelope-builders.d.ts +189 -0
- package/dist/envelope-builders.js +652 -0
- package/dist/envelope-builders.js.map +1 -0
- package/dist/envelope-builders.mjs +20 -0
- package/dist/envelope-builders.mjs.map +1 -0
- package/dist/error-mapping.d.mts +132 -0
- package/dist/error-mapping.d.ts +132 -0
- package/dist/error-mapping.js +642 -0
- package/dist/error-mapping.js.map +1 -0
- package/dist/error-mapping.mjs +16 -0
- package/dist/error-mapping.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1798 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +153 -0
- package/dist/index.mjs.map +1 -0
- package/dist/state-mapping.d.mts +139 -0
- package/dist/state-mapping.d.ts +139 -0
- package/dist/state-mapping.js +641 -0
- package/dist/state-mapping.js.map +1 -0
- package/dist/state-mapping.mjs +28 -0
- package/dist/state-mapping.mjs.map +1 -0
- package/dist/validation.d.mts +117 -0
- package/dist/validation.d.ts +117 -0
- package/dist/validation.js +850 -0
- package/dist/validation.js.map +1 -0
- package/dist/validation.mjs +22 -0
- package/dist/validation.mjs.map +1 -0
- package/package.json +18 -0
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/envelope-builders.ts
|
|
21
|
+
var envelope_builders_exports = {};
|
|
22
|
+
__export(envelope_builders_exports, {
|
|
23
|
+
a2aErrorToTaskErrorInfo: () => a2aErrorToTaskErrorInfo,
|
|
24
|
+
buildClaudeEnvelope: () => buildClaudeEnvelope,
|
|
25
|
+
buildCodexEnvelope: () => buildCodexEnvelope,
|
|
26
|
+
cancelEnvelope: () => cancelEnvelope,
|
|
27
|
+
completeEnvelope: () => completeEnvelope,
|
|
28
|
+
failEnvelope: () => failEnvelope,
|
|
29
|
+
startEnvelope: () => startEnvelope
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(envelope_builders_exports);
|
|
32
|
+
|
|
33
|
+
// ../../shared/src/a2a/schemas/task-envelope.ts
|
|
34
|
+
var TASK_ENVELOPE_VERSION = "1.0.0";
|
|
35
|
+
var TaskStateEnum = {
|
|
36
|
+
/** Task has been created and is awaiting execution. */
|
|
37
|
+
Submitted: "submitted",
|
|
38
|
+
/** Task is actively being processed by the assignee agent. */
|
|
39
|
+
Working: "working",
|
|
40
|
+
/** The assignee needs additional input before it can continue. */
|
|
41
|
+
InputRequired: "input-required",
|
|
42
|
+
/** Task finished successfully. */
|
|
43
|
+
Completed: "completed",
|
|
44
|
+
/** Task terminated with an error. */
|
|
45
|
+
Failed: "failed",
|
|
46
|
+
/** Task was explicitly cancelled by a requester or operator. */
|
|
47
|
+
Cancelled: "cancelled"
|
|
48
|
+
};
|
|
49
|
+
var TASK_STATES = [
|
|
50
|
+
TaskStateEnum.Submitted,
|
|
51
|
+
TaskStateEnum.Working,
|
|
52
|
+
TaskStateEnum.InputRequired,
|
|
53
|
+
TaskStateEnum.Completed,
|
|
54
|
+
TaskStateEnum.Failed,
|
|
55
|
+
TaskStateEnum.Cancelled
|
|
56
|
+
];
|
|
57
|
+
var TERMINAL_TASK_STATES = /* @__PURE__ */ new Set([
|
|
58
|
+
TaskStateEnum.Completed,
|
|
59
|
+
TaskStateEnum.Failed,
|
|
60
|
+
TaskStateEnum.Cancelled
|
|
61
|
+
]);
|
|
62
|
+
function createTaskEnvelope(input) {
|
|
63
|
+
const now = input.now ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
64
|
+
return {
|
|
65
|
+
envelope_version: TASK_ENVELOPE_VERSION,
|
|
66
|
+
id: input.id,
|
|
67
|
+
workspace_id: input.workspace_id,
|
|
68
|
+
thread_id: input.thread_id,
|
|
69
|
+
trace_id: input.trace_id,
|
|
70
|
+
parent_id: input.parent_id,
|
|
71
|
+
state: input.initial_state ?? TaskStateEnum.Submitted,
|
|
72
|
+
history: [],
|
|
73
|
+
requester: input.requester,
|
|
74
|
+
assignee: input.assignee,
|
|
75
|
+
connector: input.connector,
|
|
76
|
+
payload: input.payload,
|
|
77
|
+
created_at: now,
|
|
78
|
+
updated_at: now,
|
|
79
|
+
metadata: input.metadata,
|
|
80
|
+
tags: input.tags
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
var ALLOWED_STATE_TRANSITIONS = {
|
|
84
|
+
[TaskStateEnum.Submitted]: [TaskStateEnum.Working, TaskStateEnum.Cancelled, TaskStateEnum.Failed],
|
|
85
|
+
[TaskStateEnum.Working]: [
|
|
86
|
+
TaskStateEnum.Completed,
|
|
87
|
+
TaskStateEnum.Failed,
|
|
88
|
+
TaskStateEnum.Cancelled,
|
|
89
|
+
TaskStateEnum.InputRequired
|
|
90
|
+
],
|
|
91
|
+
[TaskStateEnum.InputRequired]: [TaskStateEnum.Working, TaskStateEnum.Cancelled, TaskStateEnum.Failed],
|
|
92
|
+
[TaskStateEnum.Completed]: [],
|
|
93
|
+
[TaskStateEnum.Failed]: [],
|
|
94
|
+
[TaskStateEnum.Cancelled]: []
|
|
95
|
+
};
|
|
96
|
+
function isValidTransition(from, to) {
|
|
97
|
+
return (ALLOWED_STATE_TRANSITIONS[from] ?? []).includes(to);
|
|
98
|
+
}
|
|
99
|
+
function transitionTaskEnvelope(envelope, to, options) {
|
|
100
|
+
if (!isValidTransition(envelope.state, to)) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Invalid task state transition: ${envelope.state} -> ${to} (task ${envelope.id})`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const now = options?.now ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
106
|
+
const transition = {
|
|
107
|
+
from: envelope.state,
|
|
108
|
+
to,
|
|
109
|
+
transitioned_at: now,
|
|
110
|
+
reason: options?.reason,
|
|
111
|
+
triggered_by: options?.triggered_by
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
...envelope,
|
|
115
|
+
state: to,
|
|
116
|
+
updated_at: now,
|
|
117
|
+
history: [...envelope.history ?? [], transition]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ../../shared/src/a2a/schemas/audit-event.ts
|
|
122
|
+
var AuditEventTypeEnum = {
|
|
123
|
+
// -- task lifecycle ---------------------------------------------------------
|
|
124
|
+
/** A new task was submitted. */
|
|
125
|
+
TaskSubmitted: "task.submitted",
|
|
126
|
+
/** Task execution started. */
|
|
127
|
+
TaskStarted: "task.started",
|
|
128
|
+
/** Task made progress (intermediate update). */
|
|
129
|
+
TaskProgress: "task.progress",
|
|
130
|
+
/** Assignee agent needs additional input. */
|
|
131
|
+
TaskInputRequired: "task.input_required",
|
|
132
|
+
/** Task completed successfully. */
|
|
133
|
+
TaskCompleted: "task.completed",
|
|
134
|
+
/** Task failed with an error. */
|
|
135
|
+
TaskFailed: "task.failed",
|
|
136
|
+
/** Task was cancelled. */
|
|
137
|
+
TaskCancelled: "task.cancelled",
|
|
138
|
+
// -- policy decisions -------------------------------------------------------
|
|
139
|
+
/** A policy check was performed. */
|
|
140
|
+
PolicyChecked: "policy.checked",
|
|
141
|
+
/** A policy action was approved (auto or prompt). */
|
|
142
|
+
PolicyApproved: "policy.approved",
|
|
143
|
+
/** A policy action was denied. */
|
|
144
|
+
PolicyDenied: "policy.denied",
|
|
145
|
+
// -- connector events -------------------------------------------------------
|
|
146
|
+
/** A connector was attached to an agent. */
|
|
147
|
+
ConnectorAttached: "connector.attached",
|
|
148
|
+
/** A connector was detached from an agent. */
|
|
149
|
+
ConnectorDetached: "connector.detached",
|
|
150
|
+
/** A connector emitted a diagnostic or health event. */
|
|
151
|
+
ConnectorHealth: "connector.health",
|
|
152
|
+
/** A connector encountered an error. */
|
|
153
|
+
ConnectorError: "connector.error",
|
|
154
|
+
// -- agent registry ---------------------------------------------------------
|
|
155
|
+
/** An agent was registered. */
|
|
156
|
+
AgentRegistered: "agent.registered",
|
|
157
|
+
/** An agent was unregistered. */
|
|
158
|
+
AgentUnregistered: "agent.unregistered",
|
|
159
|
+
/** An agent's capabilities were updated. */
|
|
160
|
+
AgentUpdated: "agent.updated",
|
|
161
|
+
// -- collaboration ----------------------------------------------------------
|
|
162
|
+
/** A collaboration channel was created. */
|
|
163
|
+
ChannelCreated: "collaboration.channel_created",
|
|
164
|
+
/** A collaboration thread was created. */
|
|
165
|
+
ThreadCreated: "collaboration.thread_created",
|
|
166
|
+
/** A message was sent in a collaboration thread. */
|
|
167
|
+
MessageSent: "collaboration.message_sent",
|
|
168
|
+
// -- system -----------------------------------------------------------------
|
|
169
|
+
/** A system-level configuration change. */
|
|
170
|
+
SystemConfig: "system.config",
|
|
171
|
+
/** A system-level error or warning. */
|
|
172
|
+
SystemError: "system.error"
|
|
173
|
+
};
|
|
174
|
+
var AUDIT_EVENT_TYPES = Object.values(AuditEventTypeEnum);
|
|
175
|
+
|
|
176
|
+
// ../../shared/src/a2a/schemas/error-taxonomy.ts
|
|
177
|
+
var A2AErrorSeverityEnum = {
|
|
178
|
+
/** Low impact -- informational or gracefully handled. */
|
|
179
|
+
Low: "low",
|
|
180
|
+
/** Medium impact -- degraded functionality but system continues. */
|
|
181
|
+
Medium: "medium",
|
|
182
|
+
/** High impact -- a key operation failed and needs attention. */
|
|
183
|
+
High: "high",
|
|
184
|
+
/** Critical -- system stability at risk, immediate action required. */
|
|
185
|
+
Critical: "critical"
|
|
186
|
+
};
|
|
187
|
+
var A2AErrorCategoryEnum = {
|
|
188
|
+
/** Errors in the envelope or message format (validation, parsing). */
|
|
189
|
+
Envelope: "envelope",
|
|
190
|
+
/** Errors in the connector/adapter layer. */
|
|
191
|
+
Connector: "connector",
|
|
192
|
+
/** Errors in the policy/approval plane. */
|
|
193
|
+
Policy: "policy",
|
|
194
|
+
/** Errors in the task orchestration layer. */
|
|
195
|
+
Task: "task",
|
|
196
|
+
/** Errors in the agent registry. */
|
|
197
|
+
Registry: "registry",
|
|
198
|
+
/** Errors in the collaboration service. */
|
|
199
|
+
Collaboration: "collaboration",
|
|
200
|
+
/** Transport/network-level errors. */
|
|
201
|
+
Transport: "transport",
|
|
202
|
+
/** Authentication and authorization errors. */
|
|
203
|
+
Auth: "auth",
|
|
204
|
+
/** Rate-limiting and quota errors. */
|
|
205
|
+
RateLimit: "rate_limit",
|
|
206
|
+
/** Internal / unexpected errors. */
|
|
207
|
+
Internal: "internal"
|
|
208
|
+
};
|
|
209
|
+
var A2AErrorCodeEnum = {
|
|
210
|
+
// -- envelope ---------------------------------------------------------------
|
|
211
|
+
/** The envelope failed structural validation. */
|
|
212
|
+
InvalidEnvelope: "INVALID_ENVELOPE",
|
|
213
|
+
/** The envelope version is unsupported. */
|
|
214
|
+
UnsupportedEnvelopeVersion: "UNSUPPORTED_ENVELOPE_VERSION",
|
|
215
|
+
/** A required field is missing from the envelope. */
|
|
216
|
+
MissingEnvelopeField: "MISSING_ENVELOPE_FIELD",
|
|
217
|
+
/** The payload kind is unknown or malformed. */
|
|
218
|
+
InvalidPayload: "INVALID_PAYLOAD",
|
|
219
|
+
/** Compatibility alias used by older gateway/workspace routes. */
|
|
220
|
+
InvalidParams: "INVALID_ENVELOPE",
|
|
221
|
+
// -- connector --------------------------------------------------------------
|
|
222
|
+
/** No connector is attached for the target agent. */
|
|
223
|
+
ConnectorNotFound: "CONNECTOR_NOT_FOUND",
|
|
224
|
+
/** The connector timed out during task execution. */
|
|
225
|
+
ConnectorTimeout: "CONNECTOR_TIMEOUT",
|
|
226
|
+
/** The connector returned an unexpected error. */
|
|
227
|
+
ConnectorError: "CONNECTOR_ERROR",
|
|
228
|
+
/** The connector is temporarily unavailable. */
|
|
229
|
+
ConnectorUnavailable: "CONNECTOR_UNAVAILABLE",
|
|
230
|
+
/** Protocol mismatch between connector and remote agent. */
|
|
231
|
+
ProtocolMismatch: "PROTOCOL_MISMATCH",
|
|
232
|
+
// -- policy -----------------------------------------------------------------
|
|
233
|
+
/** The policy plane denied the requested action. */
|
|
234
|
+
PolicyDenied: "POLICY_DENIED",
|
|
235
|
+
/** No prompt handler is configured for the policy rule. */
|
|
236
|
+
PolicyHandlerMissing: "POLICY_HANDLER_MISSING",
|
|
237
|
+
/** The policy evaluation timed out. */
|
|
238
|
+
PolicyTimeout: "POLICY_TIMEOUT",
|
|
239
|
+
// -- task -------------------------------------------------------------------
|
|
240
|
+
/** The task was not found. */
|
|
241
|
+
TaskNotFound: "TASK_NOT_FOUND",
|
|
242
|
+
/** An invalid state transition was attempted. */
|
|
243
|
+
InvalidStateTransition: "INVALID_STATE_TRANSITION",
|
|
244
|
+
/** The task has already reached a terminal state. */
|
|
245
|
+
TaskAlreadyTerminal: "TASK_ALREADY_TERMINAL",
|
|
246
|
+
/** The task failed during execution. */
|
|
247
|
+
TaskExecutionFailed: "TASK_EXECUTION_FAILED",
|
|
248
|
+
/** The task was cancelled. */
|
|
249
|
+
TaskCancelled: "TASK_CANCELLED",
|
|
250
|
+
// -- registry ---------------------------------------------------------------
|
|
251
|
+
/** The agent was not found in the registry. */
|
|
252
|
+
AgentNotFound: "AGENT_NOT_FOUND",
|
|
253
|
+
/** The agent is already registered. */
|
|
254
|
+
AgentAlreadyRegistered: "AGENT_ALREADY_REGISTERED",
|
|
255
|
+
/** The agent does not have the requested capability. */
|
|
256
|
+
CapabilityNotFound: "CAPABILITY_NOT_FOUND",
|
|
257
|
+
// -- collaboration ----------------------------------------------------------
|
|
258
|
+
/** The channel was not found. */
|
|
259
|
+
ChannelNotFound: "CHANNEL_NOT_FOUND",
|
|
260
|
+
/** The thread was not found. */
|
|
261
|
+
ThreadNotFound: "THREAD_NOT_FOUND",
|
|
262
|
+
/** The message was not found. */
|
|
263
|
+
MessageNotFound: "MESSAGE_NOT_FOUND",
|
|
264
|
+
/** The sender is not a member of the target channel. */
|
|
265
|
+
NotChannelMember: "NOT_CHANNEL_MEMBER",
|
|
266
|
+
// -- transport --------------------------------------------------------------
|
|
267
|
+
/** A network request failed. */
|
|
268
|
+
NetworkError: "NETWORK_ERROR",
|
|
269
|
+
/** The remote endpoint returned an unexpected status. */
|
|
270
|
+
UnexpectedStatus: "UNEXPECTED_STATUS",
|
|
271
|
+
/** The request or response body could not be parsed. */
|
|
272
|
+
SerializationError: "SERIALIZATION_ERROR",
|
|
273
|
+
// -- auth -------------------------------------------------------------------
|
|
274
|
+
/** Authentication failed (invalid or missing credentials). */
|
|
275
|
+
AuthenticationFailed: "AUTHENTICATION_FAILED",
|
|
276
|
+
/** The caller is not authorized for the requested operation. */
|
|
277
|
+
AuthorizationDenied: "AUTHORIZATION_DENIED",
|
|
278
|
+
/** The access token has expired. */
|
|
279
|
+
TokenExpired: "TOKEN_EXPIRED",
|
|
280
|
+
// -- rate limit -------------------------------------------------------------
|
|
281
|
+
/** The caller has exceeded the rate limit. */
|
|
282
|
+
RateLimitExceeded: "RATE_LIMIT_EXCEEDED",
|
|
283
|
+
/** The caller has exceeded their usage quota. */
|
|
284
|
+
QuotaExceeded: "QUOTA_EXCEEDED",
|
|
285
|
+
// -- internal ---------------------------------------------------------------
|
|
286
|
+
/** An unexpected internal error occurred. */
|
|
287
|
+
InternalError: "INTERNAL_ERROR",
|
|
288
|
+
/** A configuration error was detected. */
|
|
289
|
+
ConfigurationError: "CONFIGURATION_ERROR"
|
|
290
|
+
};
|
|
291
|
+
var A2A_ERROR_CODE_REGISTRY = {
|
|
292
|
+
// envelope
|
|
293
|
+
[A2AErrorCodeEnum.InvalidEnvelope]: {
|
|
294
|
+
code: A2AErrorCodeEnum.InvalidEnvelope,
|
|
295
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
296
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
297
|
+
retryable: false,
|
|
298
|
+
description: "The envelope failed structural validation."
|
|
299
|
+
},
|
|
300
|
+
[A2AErrorCodeEnum.UnsupportedEnvelopeVersion]: {
|
|
301
|
+
code: A2AErrorCodeEnum.UnsupportedEnvelopeVersion,
|
|
302
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
303
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
304
|
+
retryable: false,
|
|
305
|
+
description: "The envelope version is not supported by this service."
|
|
306
|
+
},
|
|
307
|
+
[A2AErrorCodeEnum.MissingEnvelopeField]: {
|
|
308
|
+
code: A2AErrorCodeEnum.MissingEnvelopeField,
|
|
309
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
310
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
311
|
+
retryable: false,
|
|
312
|
+
description: "A required field is missing from the envelope."
|
|
313
|
+
},
|
|
314
|
+
[A2AErrorCodeEnum.InvalidPayload]: {
|
|
315
|
+
code: A2AErrorCodeEnum.InvalidPayload,
|
|
316
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
317
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
318
|
+
retryable: false,
|
|
319
|
+
description: "The payload kind is unknown or malformed."
|
|
320
|
+
},
|
|
321
|
+
// connector
|
|
322
|
+
[A2AErrorCodeEnum.ConnectorNotFound]: {
|
|
323
|
+
code: A2AErrorCodeEnum.ConnectorNotFound,
|
|
324
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
325
|
+
severity: A2AErrorSeverityEnum.High,
|
|
326
|
+
retryable: false,
|
|
327
|
+
description: "No connector is attached for the target agent."
|
|
328
|
+
},
|
|
329
|
+
[A2AErrorCodeEnum.ConnectorTimeout]: {
|
|
330
|
+
code: A2AErrorCodeEnum.ConnectorTimeout,
|
|
331
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
332
|
+
severity: A2AErrorSeverityEnum.High,
|
|
333
|
+
retryable: true,
|
|
334
|
+
description: "The connector timed out during task execution."
|
|
335
|
+
},
|
|
336
|
+
[A2AErrorCodeEnum.ConnectorError]: {
|
|
337
|
+
code: A2AErrorCodeEnum.ConnectorError,
|
|
338
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
339
|
+
severity: A2AErrorSeverityEnum.High,
|
|
340
|
+
retryable: true,
|
|
341
|
+
description: "The connector returned an unexpected error."
|
|
342
|
+
},
|
|
343
|
+
[A2AErrorCodeEnum.ConnectorUnavailable]: {
|
|
344
|
+
code: A2AErrorCodeEnum.ConnectorUnavailable,
|
|
345
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
346
|
+
severity: A2AErrorSeverityEnum.High,
|
|
347
|
+
retryable: true,
|
|
348
|
+
description: "The connector is temporarily unavailable."
|
|
349
|
+
},
|
|
350
|
+
[A2AErrorCodeEnum.ProtocolMismatch]: {
|
|
351
|
+
code: A2AErrorCodeEnum.ProtocolMismatch,
|
|
352
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
353
|
+
severity: A2AErrorSeverityEnum.High,
|
|
354
|
+
retryable: false,
|
|
355
|
+
description: "Protocol mismatch between connector and remote agent."
|
|
356
|
+
},
|
|
357
|
+
// policy
|
|
358
|
+
[A2AErrorCodeEnum.PolicyDenied]: {
|
|
359
|
+
code: A2AErrorCodeEnum.PolicyDenied,
|
|
360
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
361
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
362
|
+
retryable: false,
|
|
363
|
+
description: "The policy plane denied the requested action."
|
|
364
|
+
},
|
|
365
|
+
[A2AErrorCodeEnum.PolicyHandlerMissing]: {
|
|
366
|
+
code: A2AErrorCodeEnum.PolicyHandlerMissing,
|
|
367
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
368
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
369
|
+
retryable: false,
|
|
370
|
+
description: "No prompt handler is configured for the policy rule."
|
|
371
|
+
},
|
|
372
|
+
[A2AErrorCodeEnum.PolicyTimeout]: {
|
|
373
|
+
code: A2AErrorCodeEnum.PolicyTimeout,
|
|
374
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
375
|
+
severity: A2AErrorSeverityEnum.High,
|
|
376
|
+
retryable: true,
|
|
377
|
+
description: "The policy evaluation timed out."
|
|
378
|
+
},
|
|
379
|
+
// task
|
|
380
|
+
[A2AErrorCodeEnum.TaskNotFound]: {
|
|
381
|
+
code: A2AErrorCodeEnum.TaskNotFound,
|
|
382
|
+
category: A2AErrorCategoryEnum.Task,
|
|
383
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
384
|
+
retryable: false,
|
|
385
|
+
description: "The task was not found."
|
|
386
|
+
},
|
|
387
|
+
[A2AErrorCodeEnum.InvalidStateTransition]: {
|
|
388
|
+
code: A2AErrorCodeEnum.InvalidStateTransition,
|
|
389
|
+
category: A2AErrorCategoryEnum.Task,
|
|
390
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
391
|
+
retryable: false,
|
|
392
|
+
description: "An invalid state transition was attempted."
|
|
393
|
+
},
|
|
394
|
+
[A2AErrorCodeEnum.TaskAlreadyTerminal]: {
|
|
395
|
+
code: A2AErrorCodeEnum.TaskAlreadyTerminal,
|
|
396
|
+
category: A2AErrorCategoryEnum.Task,
|
|
397
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
398
|
+
retryable: false,
|
|
399
|
+
description: "The task has already reached a terminal state."
|
|
400
|
+
},
|
|
401
|
+
[A2AErrorCodeEnum.TaskExecutionFailed]: {
|
|
402
|
+
code: A2AErrorCodeEnum.TaskExecutionFailed,
|
|
403
|
+
category: A2AErrorCategoryEnum.Task,
|
|
404
|
+
severity: A2AErrorSeverityEnum.High,
|
|
405
|
+
retryable: true,
|
|
406
|
+
description: "The task failed during execution."
|
|
407
|
+
},
|
|
408
|
+
[A2AErrorCodeEnum.TaskCancelled]: {
|
|
409
|
+
code: A2AErrorCodeEnum.TaskCancelled,
|
|
410
|
+
category: A2AErrorCategoryEnum.Task,
|
|
411
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
412
|
+
retryable: false,
|
|
413
|
+
description: "The task was cancelled."
|
|
414
|
+
},
|
|
415
|
+
// registry
|
|
416
|
+
[A2AErrorCodeEnum.AgentNotFound]: {
|
|
417
|
+
code: A2AErrorCodeEnum.AgentNotFound,
|
|
418
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
419
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
420
|
+
retryable: false,
|
|
421
|
+
description: "The agent was not found in the registry."
|
|
422
|
+
},
|
|
423
|
+
[A2AErrorCodeEnum.AgentAlreadyRegistered]: {
|
|
424
|
+
code: A2AErrorCodeEnum.AgentAlreadyRegistered,
|
|
425
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
426
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
427
|
+
retryable: false,
|
|
428
|
+
description: "The agent is already registered."
|
|
429
|
+
},
|
|
430
|
+
[A2AErrorCodeEnum.CapabilityNotFound]: {
|
|
431
|
+
code: A2AErrorCodeEnum.CapabilityNotFound,
|
|
432
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
433
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
434
|
+
retryable: false,
|
|
435
|
+
description: "The agent does not have the requested capability."
|
|
436
|
+
},
|
|
437
|
+
// collaboration
|
|
438
|
+
[A2AErrorCodeEnum.ChannelNotFound]: {
|
|
439
|
+
code: A2AErrorCodeEnum.ChannelNotFound,
|
|
440
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
441
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
442
|
+
retryable: false,
|
|
443
|
+
description: "The channel was not found."
|
|
444
|
+
},
|
|
445
|
+
[A2AErrorCodeEnum.ThreadNotFound]: {
|
|
446
|
+
code: A2AErrorCodeEnum.ThreadNotFound,
|
|
447
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
448
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
449
|
+
retryable: false,
|
|
450
|
+
description: "The thread was not found."
|
|
451
|
+
},
|
|
452
|
+
[A2AErrorCodeEnum.MessageNotFound]: {
|
|
453
|
+
code: A2AErrorCodeEnum.MessageNotFound,
|
|
454
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
455
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
456
|
+
retryable: false,
|
|
457
|
+
description: "The message was not found."
|
|
458
|
+
},
|
|
459
|
+
[A2AErrorCodeEnum.NotChannelMember]: {
|
|
460
|
+
code: A2AErrorCodeEnum.NotChannelMember,
|
|
461
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
462
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
463
|
+
retryable: false,
|
|
464
|
+
description: "The sender is not a member of the target channel."
|
|
465
|
+
},
|
|
466
|
+
// transport
|
|
467
|
+
[A2AErrorCodeEnum.NetworkError]: {
|
|
468
|
+
code: A2AErrorCodeEnum.NetworkError,
|
|
469
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
470
|
+
severity: A2AErrorSeverityEnum.High,
|
|
471
|
+
retryable: true,
|
|
472
|
+
description: "A network request failed."
|
|
473
|
+
},
|
|
474
|
+
[A2AErrorCodeEnum.UnexpectedStatus]: {
|
|
475
|
+
code: A2AErrorCodeEnum.UnexpectedStatus,
|
|
476
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
477
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
478
|
+
retryable: true,
|
|
479
|
+
description: "The remote endpoint returned an unexpected status."
|
|
480
|
+
},
|
|
481
|
+
[A2AErrorCodeEnum.SerializationError]: {
|
|
482
|
+
code: A2AErrorCodeEnum.SerializationError,
|
|
483
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
484
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
485
|
+
retryable: false,
|
|
486
|
+
description: "The request or response body could not be parsed."
|
|
487
|
+
},
|
|
488
|
+
// auth
|
|
489
|
+
[A2AErrorCodeEnum.AuthenticationFailed]: {
|
|
490
|
+
code: A2AErrorCodeEnum.AuthenticationFailed,
|
|
491
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
492
|
+
severity: A2AErrorSeverityEnum.High,
|
|
493
|
+
retryable: false,
|
|
494
|
+
description: "Authentication failed (invalid or missing credentials)."
|
|
495
|
+
},
|
|
496
|
+
[A2AErrorCodeEnum.AuthorizationDenied]: {
|
|
497
|
+
code: A2AErrorCodeEnum.AuthorizationDenied,
|
|
498
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
499
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
500
|
+
retryable: false,
|
|
501
|
+
description: "The caller is not authorized for the requested operation."
|
|
502
|
+
},
|
|
503
|
+
[A2AErrorCodeEnum.TokenExpired]: {
|
|
504
|
+
code: A2AErrorCodeEnum.TokenExpired,
|
|
505
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
506
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
507
|
+
retryable: true,
|
|
508
|
+
description: "The access token has expired."
|
|
509
|
+
},
|
|
510
|
+
// rate limit
|
|
511
|
+
[A2AErrorCodeEnum.RateLimitExceeded]: {
|
|
512
|
+
code: A2AErrorCodeEnum.RateLimitExceeded,
|
|
513
|
+
category: A2AErrorCategoryEnum.RateLimit,
|
|
514
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
515
|
+
retryable: true,
|
|
516
|
+
description: "The caller has exceeded the rate limit."
|
|
517
|
+
},
|
|
518
|
+
[A2AErrorCodeEnum.QuotaExceeded]: {
|
|
519
|
+
code: A2AErrorCodeEnum.QuotaExceeded,
|
|
520
|
+
category: A2AErrorCategoryEnum.RateLimit,
|
|
521
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
522
|
+
retryable: false,
|
|
523
|
+
description: "The caller has exceeded their usage quota."
|
|
524
|
+
},
|
|
525
|
+
// internal
|
|
526
|
+
[A2AErrorCodeEnum.InternalError]: {
|
|
527
|
+
code: A2AErrorCodeEnum.InternalError,
|
|
528
|
+
category: A2AErrorCategoryEnum.Internal,
|
|
529
|
+
severity: A2AErrorSeverityEnum.Critical,
|
|
530
|
+
retryable: false,
|
|
531
|
+
description: "An unexpected internal error occurred."
|
|
532
|
+
},
|
|
533
|
+
[A2AErrorCodeEnum.ConfigurationError]: {
|
|
534
|
+
code: A2AErrorCodeEnum.ConfigurationError,
|
|
535
|
+
category: A2AErrorCategoryEnum.Internal,
|
|
536
|
+
severity: A2AErrorSeverityEnum.High,
|
|
537
|
+
retryable: false,
|
|
538
|
+
description: "A configuration error was detected."
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/envelope-builders.ts
|
|
543
|
+
function buildCodexEnvelope(input, options) {
|
|
544
|
+
const connectorMeta = {
|
|
545
|
+
...options?.connector_metadata
|
|
546
|
+
};
|
|
547
|
+
if (options?.model) connectorMeta.model = options.model;
|
|
548
|
+
if (options?.endpoint) connectorMeta.endpoint = options.endpoint;
|
|
549
|
+
const connector = {
|
|
550
|
+
platform: "codex",
|
|
551
|
+
protocol: "jsonrpc",
|
|
552
|
+
connector_id: options?.connector_id ?? "codex-v1",
|
|
553
|
+
name: "Codex Adapter",
|
|
554
|
+
metadata: Object.keys(connectorMeta).length > 0 ? connectorMeta : void 0
|
|
555
|
+
};
|
|
556
|
+
const assignee = input.assignee ?? {
|
|
557
|
+
agent_id: `codex-agent-${input.workspace_id}`,
|
|
558
|
+
platform: "codex",
|
|
559
|
+
name: "Codex Agent"
|
|
560
|
+
};
|
|
561
|
+
return createTaskEnvelope({
|
|
562
|
+
id: input.id,
|
|
563
|
+
workspace_id: input.workspace_id,
|
|
564
|
+
thread_id: input.thread_id,
|
|
565
|
+
trace_id: input.trace_id,
|
|
566
|
+
parent_id: input.parent_id,
|
|
567
|
+
requester: input.requester,
|
|
568
|
+
assignee,
|
|
569
|
+
connector,
|
|
570
|
+
payload: input.payload,
|
|
571
|
+
metadata: input.metadata,
|
|
572
|
+
tags: input.tags,
|
|
573
|
+
initial_state: input.initial_state,
|
|
574
|
+
now: input.now
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
function buildClaudeEnvelope(input, options) {
|
|
578
|
+
const connectorMeta = {
|
|
579
|
+
...options?.connector_metadata
|
|
580
|
+
};
|
|
581
|
+
if (options?.model) connectorMeta.model = options.model;
|
|
582
|
+
if (options?.endpoint) connectorMeta.endpoint = options.endpoint;
|
|
583
|
+
if (options?.max_tokens !== void 0) connectorMeta.max_tokens = options.max_tokens;
|
|
584
|
+
const connector = {
|
|
585
|
+
platform: "claude_code",
|
|
586
|
+
protocol: "jsonrpc",
|
|
587
|
+
connector_id: options?.connector_id ?? "claude-code-v1",
|
|
588
|
+
name: "Claude Code Adapter",
|
|
589
|
+
metadata: Object.keys(connectorMeta).length > 0 ? connectorMeta : void 0
|
|
590
|
+
};
|
|
591
|
+
const assignee = input.assignee ?? {
|
|
592
|
+
agent_id: `claude-agent-${input.workspace_id}`,
|
|
593
|
+
platform: "claude_code",
|
|
594
|
+
name: "Claude Code Agent"
|
|
595
|
+
};
|
|
596
|
+
return createTaskEnvelope({
|
|
597
|
+
id: input.id,
|
|
598
|
+
workspace_id: input.workspace_id,
|
|
599
|
+
thread_id: input.thread_id,
|
|
600
|
+
trace_id: input.trace_id,
|
|
601
|
+
parent_id: input.parent_id,
|
|
602
|
+
requester: input.requester,
|
|
603
|
+
assignee,
|
|
604
|
+
connector,
|
|
605
|
+
payload: input.payload,
|
|
606
|
+
metadata: input.metadata,
|
|
607
|
+
tags: input.tags,
|
|
608
|
+
initial_state: input.initial_state,
|
|
609
|
+
now: input.now
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function completeEnvelope(envelope, result, options) {
|
|
613
|
+
const transitioned = transitionTaskEnvelope(envelope, TaskStateEnum.Completed, options);
|
|
614
|
+
return {
|
|
615
|
+
...transitioned,
|
|
616
|
+
result
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function failEnvelope(envelope, error, options) {
|
|
620
|
+
const transitioned = transitionTaskEnvelope(envelope, TaskStateEnum.Failed, options);
|
|
621
|
+
return {
|
|
622
|
+
...transitioned,
|
|
623
|
+
error
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function cancelEnvelope(envelope, options) {
|
|
627
|
+
return transitionTaskEnvelope(envelope, TaskStateEnum.Cancelled, options);
|
|
628
|
+
}
|
|
629
|
+
function startEnvelope(envelope, options) {
|
|
630
|
+
return transitionTaskEnvelope(envelope, TaskStateEnum.Working, options);
|
|
631
|
+
}
|
|
632
|
+
function a2aErrorToTaskErrorInfo(a2aError) {
|
|
633
|
+
return {
|
|
634
|
+
code: a2aError.code,
|
|
635
|
+
category: a2aError.category,
|
|
636
|
+
message: a2aError.message,
|
|
637
|
+
severity: a2aError.severity,
|
|
638
|
+
retryable: a2aError.retryable,
|
|
639
|
+
details: a2aError.details
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
643
|
+
0 && (module.exports = {
|
|
644
|
+
a2aErrorToTaskErrorInfo,
|
|
645
|
+
buildClaudeEnvelope,
|
|
646
|
+
buildCodexEnvelope,
|
|
647
|
+
cancelEnvelope,
|
|
648
|
+
completeEnvelope,
|
|
649
|
+
failEnvelope,
|
|
650
|
+
startEnvelope
|
|
651
|
+
});
|
|
652
|
+
//# sourceMappingURL=envelope-builders.js.map
|