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,905 @@
|
|
|
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/audit-helpers.ts
|
|
21
|
+
var audit_helpers_exports = {};
|
|
22
|
+
__export(audit_helpers_exports, {
|
|
23
|
+
emitAuditForTransition: () => emitAuditForTransition,
|
|
24
|
+
emitConnectorAttached: () => emitConnectorAttached,
|
|
25
|
+
emitConnectorError: () => emitConnectorError,
|
|
26
|
+
emitConnectorHealth: () => emitConnectorHealth,
|
|
27
|
+
emitPolicyApproved: () => emitPolicyApproved,
|
|
28
|
+
emitPolicyChecked: () => emitPolicyChecked,
|
|
29
|
+
emitPolicyDenied: () => emitPolicyDenied,
|
|
30
|
+
emitTaskCancelled: () => emitTaskCancelled,
|
|
31
|
+
emitTaskCompleted: () => emitTaskCompleted,
|
|
32
|
+
emitTaskFailed: () => emitTaskFailed,
|
|
33
|
+
emitTaskInputRequired: () => emitTaskInputRequired,
|
|
34
|
+
emitTaskProgress: () => emitTaskProgress,
|
|
35
|
+
emitTaskStarted: () => emitTaskStarted,
|
|
36
|
+
emitTaskSubmitted: () => emitTaskSubmitted
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(audit_helpers_exports);
|
|
39
|
+
|
|
40
|
+
// ../../shared/src/a2a/schemas/task-envelope.ts
|
|
41
|
+
var TaskStateEnum = {
|
|
42
|
+
/** Task has been created and is awaiting execution. */
|
|
43
|
+
Submitted: "submitted",
|
|
44
|
+
/** Task is actively being processed by the assignee agent. */
|
|
45
|
+
Working: "working",
|
|
46
|
+
/** The assignee needs additional input before it can continue. */
|
|
47
|
+
InputRequired: "input-required",
|
|
48
|
+
/** Task finished successfully. */
|
|
49
|
+
Completed: "completed",
|
|
50
|
+
/** Task terminated with an error. */
|
|
51
|
+
Failed: "failed",
|
|
52
|
+
/** Task was explicitly cancelled by a requester or operator. */
|
|
53
|
+
Cancelled: "cancelled"
|
|
54
|
+
};
|
|
55
|
+
var TASK_STATES = [
|
|
56
|
+
TaskStateEnum.Submitted,
|
|
57
|
+
TaskStateEnum.Working,
|
|
58
|
+
TaskStateEnum.InputRequired,
|
|
59
|
+
TaskStateEnum.Completed,
|
|
60
|
+
TaskStateEnum.Failed,
|
|
61
|
+
TaskStateEnum.Cancelled
|
|
62
|
+
];
|
|
63
|
+
var TERMINAL_TASK_STATES = /* @__PURE__ */ new Set([
|
|
64
|
+
TaskStateEnum.Completed,
|
|
65
|
+
TaskStateEnum.Failed,
|
|
66
|
+
TaskStateEnum.Cancelled
|
|
67
|
+
]);
|
|
68
|
+
var ALLOWED_STATE_TRANSITIONS = {
|
|
69
|
+
[TaskStateEnum.Submitted]: [TaskStateEnum.Working, TaskStateEnum.Cancelled, TaskStateEnum.Failed],
|
|
70
|
+
[TaskStateEnum.Working]: [
|
|
71
|
+
TaskStateEnum.Completed,
|
|
72
|
+
TaskStateEnum.Failed,
|
|
73
|
+
TaskStateEnum.Cancelled,
|
|
74
|
+
TaskStateEnum.InputRequired
|
|
75
|
+
],
|
|
76
|
+
[TaskStateEnum.InputRequired]: [TaskStateEnum.Working, TaskStateEnum.Cancelled, TaskStateEnum.Failed],
|
|
77
|
+
[TaskStateEnum.Completed]: [],
|
|
78
|
+
[TaskStateEnum.Failed]: [],
|
|
79
|
+
[TaskStateEnum.Cancelled]: []
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// ../../shared/src/a2a/schemas/audit-event.ts
|
|
83
|
+
var AUDIT_EVENT_VERSION = "1.0.0";
|
|
84
|
+
var AuditEventTypeEnum = {
|
|
85
|
+
// -- task lifecycle ---------------------------------------------------------
|
|
86
|
+
/** A new task was submitted. */
|
|
87
|
+
TaskSubmitted: "task.submitted",
|
|
88
|
+
/** Task execution started. */
|
|
89
|
+
TaskStarted: "task.started",
|
|
90
|
+
/** Task made progress (intermediate update). */
|
|
91
|
+
TaskProgress: "task.progress",
|
|
92
|
+
/** Assignee agent needs additional input. */
|
|
93
|
+
TaskInputRequired: "task.input_required",
|
|
94
|
+
/** Task completed successfully. */
|
|
95
|
+
TaskCompleted: "task.completed",
|
|
96
|
+
/** Task failed with an error. */
|
|
97
|
+
TaskFailed: "task.failed",
|
|
98
|
+
/** Task was cancelled. */
|
|
99
|
+
TaskCancelled: "task.cancelled",
|
|
100
|
+
// -- policy decisions -------------------------------------------------------
|
|
101
|
+
/** A policy check was performed. */
|
|
102
|
+
PolicyChecked: "policy.checked",
|
|
103
|
+
/** A policy action was approved (auto or prompt). */
|
|
104
|
+
PolicyApproved: "policy.approved",
|
|
105
|
+
/** A policy action was denied. */
|
|
106
|
+
PolicyDenied: "policy.denied",
|
|
107
|
+
// -- connector events -------------------------------------------------------
|
|
108
|
+
/** A connector was attached to an agent. */
|
|
109
|
+
ConnectorAttached: "connector.attached",
|
|
110
|
+
/** A connector was detached from an agent. */
|
|
111
|
+
ConnectorDetached: "connector.detached",
|
|
112
|
+
/** A connector emitted a diagnostic or health event. */
|
|
113
|
+
ConnectorHealth: "connector.health",
|
|
114
|
+
/** A connector encountered an error. */
|
|
115
|
+
ConnectorError: "connector.error",
|
|
116
|
+
// -- agent registry ---------------------------------------------------------
|
|
117
|
+
/** An agent was registered. */
|
|
118
|
+
AgentRegistered: "agent.registered",
|
|
119
|
+
/** An agent was unregistered. */
|
|
120
|
+
AgentUnregistered: "agent.unregistered",
|
|
121
|
+
/** An agent's capabilities were updated. */
|
|
122
|
+
AgentUpdated: "agent.updated",
|
|
123
|
+
// -- collaboration ----------------------------------------------------------
|
|
124
|
+
/** A collaboration channel was created. */
|
|
125
|
+
ChannelCreated: "collaboration.channel_created",
|
|
126
|
+
/** A collaboration thread was created. */
|
|
127
|
+
ThreadCreated: "collaboration.thread_created",
|
|
128
|
+
/** A message was sent in a collaboration thread. */
|
|
129
|
+
MessageSent: "collaboration.message_sent",
|
|
130
|
+
// -- system -----------------------------------------------------------------
|
|
131
|
+
/** A system-level configuration change. */
|
|
132
|
+
SystemConfig: "system.config",
|
|
133
|
+
/** A system-level error or warning. */
|
|
134
|
+
SystemError: "system.error"
|
|
135
|
+
};
|
|
136
|
+
var AUDIT_EVENT_TYPES = Object.values(AuditEventTypeEnum);
|
|
137
|
+
var AuditActorKindEnum = {
|
|
138
|
+
/** An AI agent. */
|
|
139
|
+
Agent: "agent",
|
|
140
|
+
/** A human user. */
|
|
141
|
+
User: "user",
|
|
142
|
+
/** An internal system service (e.g. policy engine, scheduler). */
|
|
143
|
+
System: "system",
|
|
144
|
+
/** A connector/adapter. */
|
|
145
|
+
Connector: "connector"
|
|
146
|
+
};
|
|
147
|
+
var AuditTargetKindEnum = {
|
|
148
|
+
Task: "task",
|
|
149
|
+
Agent: "agent",
|
|
150
|
+
Connector: "connector",
|
|
151
|
+
Channel: "channel",
|
|
152
|
+
Thread: "thread",
|
|
153
|
+
Message: "message",
|
|
154
|
+
Policy: "policy",
|
|
155
|
+
Workspace: "workspace",
|
|
156
|
+
System: "system"
|
|
157
|
+
};
|
|
158
|
+
var AuditSeverityEnum = {
|
|
159
|
+
/** Informational -- normal operation. */
|
|
160
|
+
Info: "info",
|
|
161
|
+
/** Warning -- something unexpected but not an error. */
|
|
162
|
+
Warning: "warning",
|
|
163
|
+
/** Error -- an operation failed. */
|
|
164
|
+
Error: "error",
|
|
165
|
+
/** Critical -- a severe failure requiring immediate attention. */
|
|
166
|
+
Critical: "critical"
|
|
167
|
+
};
|
|
168
|
+
function createAuditEvent(input) {
|
|
169
|
+
return {
|
|
170
|
+
schema_version: AUDIT_EVENT_VERSION,
|
|
171
|
+
id: input.id,
|
|
172
|
+
event_type: input.event_type,
|
|
173
|
+
severity: input.severity,
|
|
174
|
+
actor: input.actor,
|
|
175
|
+
target: input.target,
|
|
176
|
+
trace_id: input.trace_id,
|
|
177
|
+
parent_event_id: input.parent_event_id,
|
|
178
|
+
workspace_id: input.workspace_id,
|
|
179
|
+
thread_id: input.thread_id,
|
|
180
|
+
task_id: input.task_id,
|
|
181
|
+
timestamp: input.now ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
182
|
+
duration_ms: input.duration_ms,
|
|
183
|
+
policy: input.policy,
|
|
184
|
+
metadata: input.metadata,
|
|
185
|
+
tags: input.tags
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ../../shared/src/a2a/schemas/error-taxonomy.ts
|
|
190
|
+
var A2AErrorSeverityEnum = {
|
|
191
|
+
/** Low impact -- informational or gracefully handled. */
|
|
192
|
+
Low: "low",
|
|
193
|
+
/** Medium impact -- degraded functionality but system continues. */
|
|
194
|
+
Medium: "medium",
|
|
195
|
+
/** High impact -- a key operation failed and needs attention. */
|
|
196
|
+
High: "high",
|
|
197
|
+
/** Critical -- system stability at risk, immediate action required. */
|
|
198
|
+
Critical: "critical"
|
|
199
|
+
};
|
|
200
|
+
var A2AErrorCategoryEnum = {
|
|
201
|
+
/** Errors in the envelope or message format (validation, parsing). */
|
|
202
|
+
Envelope: "envelope",
|
|
203
|
+
/** Errors in the connector/adapter layer. */
|
|
204
|
+
Connector: "connector",
|
|
205
|
+
/** Errors in the policy/approval plane. */
|
|
206
|
+
Policy: "policy",
|
|
207
|
+
/** Errors in the task orchestration layer. */
|
|
208
|
+
Task: "task",
|
|
209
|
+
/** Errors in the agent registry. */
|
|
210
|
+
Registry: "registry",
|
|
211
|
+
/** Errors in the collaboration service. */
|
|
212
|
+
Collaboration: "collaboration",
|
|
213
|
+
/** Transport/network-level errors. */
|
|
214
|
+
Transport: "transport",
|
|
215
|
+
/** Authentication and authorization errors. */
|
|
216
|
+
Auth: "auth",
|
|
217
|
+
/** Rate-limiting and quota errors. */
|
|
218
|
+
RateLimit: "rate_limit",
|
|
219
|
+
/** Internal / unexpected errors. */
|
|
220
|
+
Internal: "internal"
|
|
221
|
+
};
|
|
222
|
+
var A2AErrorCodeEnum = {
|
|
223
|
+
// -- envelope ---------------------------------------------------------------
|
|
224
|
+
/** The envelope failed structural validation. */
|
|
225
|
+
InvalidEnvelope: "INVALID_ENVELOPE",
|
|
226
|
+
/** The envelope version is unsupported. */
|
|
227
|
+
UnsupportedEnvelopeVersion: "UNSUPPORTED_ENVELOPE_VERSION",
|
|
228
|
+
/** A required field is missing from the envelope. */
|
|
229
|
+
MissingEnvelopeField: "MISSING_ENVELOPE_FIELD",
|
|
230
|
+
/** The payload kind is unknown or malformed. */
|
|
231
|
+
InvalidPayload: "INVALID_PAYLOAD",
|
|
232
|
+
/** Compatibility alias used by older gateway/workspace routes. */
|
|
233
|
+
InvalidParams: "INVALID_ENVELOPE",
|
|
234
|
+
// -- connector --------------------------------------------------------------
|
|
235
|
+
/** No connector is attached for the target agent. */
|
|
236
|
+
ConnectorNotFound: "CONNECTOR_NOT_FOUND",
|
|
237
|
+
/** The connector timed out during task execution. */
|
|
238
|
+
ConnectorTimeout: "CONNECTOR_TIMEOUT",
|
|
239
|
+
/** The connector returned an unexpected error. */
|
|
240
|
+
ConnectorError: "CONNECTOR_ERROR",
|
|
241
|
+
/** The connector is temporarily unavailable. */
|
|
242
|
+
ConnectorUnavailable: "CONNECTOR_UNAVAILABLE",
|
|
243
|
+
/** Protocol mismatch between connector and remote agent. */
|
|
244
|
+
ProtocolMismatch: "PROTOCOL_MISMATCH",
|
|
245
|
+
// -- policy -----------------------------------------------------------------
|
|
246
|
+
/** The policy plane denied the requested action. */
|
|
247
|
+
PolicyDenied: "POLICY_DENIED",
|
|
248
|
+
/** No prompt handler is configured for the policy rule. */
|
|
249
|
+
PolicyHandlerMissing: "POLICY_HANDLER_MISSING",
|
|
250
|
+
/** The policy evaluation timed out. */
|
|
251
|
+
PolicyTimeout: "POLICY_TIMEOUT",
|
|
252
|
+
// -- task -------------------------------------------------------------------
|
|
253
|
+
/** The task was not found. */
|
|
254
|
+
TaskNotFound: "TASK_NOT_FOUND",
|
|
255
|
+
/** An invalid state transition was attempted. */
|
|
256
|
+
InvalidStateTransition: "INVALID_STATE_TRANSITION",
|
|
257
|
+
/** The task has already reached a terminal state. */
|
|
258
|
+
TaskAlreadyTerminal: "TASK_ALREADY_TERMINAL",
|
|
259
|
+
/** The task failed during execution. */
|
|
260
|
+
TaskExecutionFailed: "TASK_EXECUTION_FAILED",
|
|
261
|
+
/** The task was cancelled. */
|
|
262
|
+
TaskCancelled: "TASK_CANCELLED",
|
|
263
|
+
// -- registry ---------------------------------------------------------------
|
|
264
|
+
/** The agent was not found in the registry. */
|
|
265
|
+
AgentNotFound: "AGENT_NOT_FOUND",
|
|
266
|
+
/** The agent is already registered. */
|
|
267
|
+
AgentAlreadyRegistered: "AGENT_ALREADY_REGISTERED",
|
|
268
|
+
/** The agent does not have the requested capability. */
|
|
269
|
+
CapabilityNotFound: "CAPABILITY_NOT_FOUND",
|
|
270
|
+
// -- collaboration ----------------------------------------------------------
|
|
271
|
+
/** The channel was not found. */
|
|
272
|
+
ChannelNotFound: "CHANNEL_NOT_FOUND",
|
|
273
|
+
/** The thread was not found. */
|
|
274
|
+
ThreadNotFound: "THREAD_NOT_FOUND",
|
|
275
|
+
/** The message was not found. */
|
|
276
|
+
MessageNotFound: "MESSAGE_NOT_FOUND",
|
|
277
|
+
/** The sender is not a member of the target channel. */
|
|
278
|
+
NotChannelMember: "NOT_CHANNEL_MEMBER",
|
|
279
|
+
// -- transport --------------------------------------------------------------
|
|
280
|
+
/** A network request failed. */
|
|
281
|
+
NetworkError: "NETWORK_ERROR",
|
|
282
|
+
/** The remote endpoint returned an unexpected status. */
|
|
283
|
+
UnexpectedStatus: "UNEXPECTED_STATUS",
|
|
284
|
+
/** The request or response body could not be parsed. */
|
|
285
|
+
SerializationError: "SERIALIZATION_ERROR",
|
|
286
|
+
// -- auth -------------------------------------------------------------------
|
|
287
|
+
/** Authentication failed (invalid or missing credentials). */
|
|
288
|
+
AuthenticationFailed: "AUTHENTICATION_FAILED",
|
|
289
|
+
/** The caller is not authorized for the requested operation. */
|
|
290
|
+
AuthorizationDenied: "AUTHORIZATION_DENIED",
|
|
291
|
+
/** The access token has expired. */
|
|
292
|
+
TokenExpired: "TOKEN_EXPIRED",
|
|
293
|
+
// -- rate limit -------------------------------------------------------------
|
|
294
|
+
/** The caller has exceeded the rate limit. */
|
|
295
|
+
RateLimitExceeded: "RATE_LIMIT_EXCEEDED",
|
|
296
|
+
/** The caller has exceeded their usage quota. */
|
|
297
|
+
QuotaExceeded: "QUOTA_EXCEEDED",
|
|
298
|
+
// -- internal ---------------------------------------------------------------
|
|
299
|
+
/** An unexpected internal error occurred. */
|
|
300
|
+
InternalError: "INTERNAL_ERROR",
|
|
301
|
+
/** A configuration error was detected. */
|
|
302
|
+
ConfigurationError: "CONFIGURATION_ERROR"
|
|
303
|
+
};
|
|
304
|
+
var A2A_ERROR_CODE_REGISTRY = {
|
|
305
|
+
// envelope
|
|
306
|
+
[A2AErrorCodeEnum.InvalidEnvelope]: {
|
|
307
|
+
code: A2AErrorCodeEnum.InvalidEnvelope,
|
|
308
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
309
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
310
|
+
retryable: false,
|
|
311
|
+
description: "The envelope failed structural validation."
|
|
312
|
+
},
|
|
313
|
+
[A2AErrorCodeEnum.UnsupportedEnvelopeVersion]: {
|
|
314
|
+
code: A2AErrorCodeEnum.UnsupportedEnvelopeVersion,
|
|
315
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
316
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
317
|
+
retryable: false,
|
|
318
|
+
description: "The envelope version is not supported by this service."
|
|
319
|
+
},
|
|
320
|
+
[A2AErrorCodeEnum.MissingEnvelopeField]: {
|
|
321
|
+
code: A2AErrorCodeEnum.MissingEnvelopeField,
|
|
322
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
323
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
324
|
+
retryable: false,
|
|
325
|
+
description: "A required field is missing from the envelope."
|
|
326
|
+
},
|
|
327
|
+
[A2AErrorCodeEnum.InvalidPayload]: {
|
|
328
|
+
code: A2AErrorCodeEnum.InvalidPayload,
|
|
329
|
+
category: A2AErrorCategoryEnum.Envelope,
|
|
330
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
331
|
+
retryable: false,
|
|
332
|
+
description: "The payload kind is unknown or malformed."
|
|
333
|
+
},
|
|
334
|
+
// connector
|
|
335
|
+
[A2AErrorCodeEnum.ConnectorNotFound]: {
|
|
336
|
+
code: A2AErrorCodeEnum.ConnectorNotFound,
|
|
337
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
338
|
+
severity: A2AErrorSeverityEnum.High,
|
|
339
|
+
retryable: false,
|
|
340
|
+
description: "No connector is attached for the target agent."
|
|
341
|
+
},
|
|
342
|
+
[A2AErrorCodeEnum.ConnectorTimeout]: {
|
|
343
|
+
code: A2AErrorCodeEnum.ConnectorTimeout,
|
|
344
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
345
|
+
severity: A2AErrorSeverityEnum.High,
|
|
346
|
+
retryable: true,
|
|
347
|
+
description: "The connector timed out during task execution."
|
|
348
|
+
},
|
|
349
|
+
[A2AErrorCodeEnum.ConnectorError]: {
|
|
350
|
+
code: A2AErrorCodeEnum.ConnectorError,
|
|
351
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
352
|
+
severity: A2AErrorSeverityEnum.High,
|
|
353
|
+
retryable: true,
|
|
354
|
+
description: "The connector returned an unexpected error."
|
|
355
|
+
},
|
|
356
|
+
[A2AErrorCodeEnum.ConnectorUnavailable]: {
|
|
357
|
+
code: A2AErrorCodeEnum.ConnectorUnavailable,
|
|
358
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
359
|
+
severity: A2AErrorSeverityEnum.High,
|
|
360
|
+
retryable: true,
|
|
361
|
+
description: "The connector is temporarily unavailable."
|
|
362
|
+
},
|
|
363
|
+
[A2AErrorCodeEnum.ProtocolMismatch]: {
|
|
364
|
+
code: A2AErrorCodeEnum.ProtocolMismatch,
|
|
365
|
+
category: A2AErrorCategoryEnum.Connector,
|
|
366
|
+
severity: A2AErrorSeverityEnum.High,
|
|
367
|
+
retryable: false,
|
|
368
|
+
description: "Protocol mismatch between connector and remote agent."
|
|
369
|
+
},
|
|
370
|
+
// policy
|
|
371
|
+
[A2AErrorCodeEnum.PolicyDenied]: {
|
|
372
|
+
code: A2AErrorCodeEnum.PolicyDenied,
|
|
373
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
374
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
375
|
+
retryable: false,
|
|
376
|
+
description: "The policy plane denied the requested action."
|
|
377
|
+
},
|
|
378
|
+
[A2AErrorCodeEnum.PolicyHandlerMissing]: {
|
|
379
|
+
code: A2AErrorCodeEnum.PolicyHandlerMissing,
|
|
380
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
381
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
382
|
+
retryable: false,
|
|
383
|
+
description: "No prompt handler is configured for the policy rule."
|
|
384
|
+
},
|
|
385
|
+
[A2AErrorCodeEnum.PolicyTimeout]: {
|
|
386
|
+
code: A2AErrorCodeEnum.PolicyTimeout,
|
|
387
|
+
category: A2AErrorCategoryEnum.Policy,
|
|
388
|
+
severity: A2AErrorSeverityEnum.High,
|
|
389
|
+
retryable: true,
|
|
390
|
+
description: "The policy evaluation timed out."
|
|
391
|
+
},
|
|
392
|
+
// task
|
|
393
|
+
[A2AErrorCodeEnum.TaskNotFound]: {
|
|
394
|
+
code: A2AErrorCodeEnum.TaskNotFound,
|
|
395
|
+
category: A2AErrorCategoryEnum.Task,
|
|
396
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
397
|
+
retryable: false,
|
|
398
|
+
description: "The task was not found."
|
|
399
|
+
},
|
|
400
|
+
[A2AErrorCodeEnum.InvalidStateTransition]: {
|
|
401
|
+
code: A2AErrorCodeEnum.InvalidStateTransition,
|
|
402
|
+
category: A2AErrorCategoryEnum.Task,
|
|
403
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
404
|
+
retryable: false,
|
|
405
|
+
description: "An invalid state transition was attempted."
|
|
406
|
+
},
|
|
407
|
+
[A2AErrorCodeEnum.TaskAlreadyTerminal]: {
|
|
408
|
+
code: A2AErrorCodeEnum.TaskAlreadyTerminal,
|
|
409
|
+
category: A2AErrorCategoryEnum.Task,
|
|
410
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
411
|
+
retryable: false,
|
|
412
|
+
description: "The task has already reached a terminal state."
|
|
413
|
+
},
|
|
414
|
+
[A2AErrorCodeEnum.TaskExecutionFailed]: {
|
|
415
|
+
code: A2AErrorCodeEnum.TaskExecutionFailed,
|
|
416
|
+
category: A2AErrorCategoryEnum.Task,
|
|
417
|
+
severity: A2AErrorSeverityEnum.High,
|
|
418
|
+
retryable: true,
|
|
419
|
+
description: "The task failed during execution."
|
|
420
|
+
},
|
|
421
|
+
[A2AErrorCodeEnum.TaskCancelled]: {
|
|
422
|
+
code: A2AErrorCodeEnum.TaskCancelled,
|
|
423
|
+
category: A2AErrorCategoryEnum.Task,
|
|
424
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
425
|
+
retryable: false,
|
|
426
|
+
description: "The task was cancelled."
|
|
427
|
+
},
|
|
428
|
+
// registry
|
|
429
|
+
[A2AErrorCodeEnum.AgentNotFound]: {
|
|
430
|
+
code: A2AErrorCodeEnum.AgentNotFound,
|
|
431
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
432
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
433
|
+
retryable: false,
|
|
434
|
+
description: "The agent was not found in the registry."
|
|
435
|
+
},
|
|
436
|
+
[A2AErrorCodeEnum.AgentAlreadyRegistered]: {
|
|
437
|
+
code: A2AErrorCodeEnum.AgentAlreadyRegistered,
|
|
438
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
439
|
+
severity: A2AErrorSeverityEnum.Low,
|
|
440
|
+
retryable: false,
|
|
441
|
+
description: "The agent is already registered."
|
|
442
|
+
},
|
|
443
|
+
[A2AErrorCodeEnum.CapabilityNotFound]: {
|
|
444
|
+
code: A2AErrorCodeEnum.CapabilityNotFound,
|
|
445
|
+
category: A2AErrorCategoryEnum.Registry,
|
|
446
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
447
|
+
retryable: false,
|
|
448
|
+
description: "The agent does not have the requested capability."
|
|
449
|
+
},
|
|
450
|
+
// collaboration
|
|
451
|
+
[A2AErrorCodeEnum.ChannelNotFound]: {
|
|
452
|
+
code: A2AErrorCodeEnum.ChannelNotFound,
|
|
453
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
454
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
455
|
+
retryable: false,
|
|
456
|
+
description: "The channel was not found."
|
|
457
|
+
},
|
|
458
|
+
[A2AErrorCodeEnum.ThreadNotFound]: {
|
|
459
|
+
code: A2AErrorCodeEnum.ThreadNotFound,
|
|
460
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
461
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
462
|
+
retryable: false,
|
|
463
|
+
description: "The thread was not found."
|
|
464
|
+
},
|
|
465
|
+
[A2AErrorCodeEnum.MessageNotFound]: {
|
|
466
|
+
code: A2AErrorCodeEnum.MessageNotFound,
|
|
467
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
468
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
469
|
+
retryable: false,
|
|
470
|
+
description: "The message was not found."
|
|
471
|
+
},
|
|
472
|
+
[A2AErrorCodeEnum.NotChannelMember]: {
|
|
473
|
+
code: A2AErrorCodeEnum.NotChannelMember,
|
|
474
|
+
category: A2AErrorCategoryEnum.Collaboration,
|
|
475
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
476
|
+
retryable: false,
|
|
477
|
+
description: "The sender is not a member of the target channel."
|
|
478
|
+
},
|
|
479
|
+
// transport
|
|
480
|
+
[A2AErrorCodeEnum.NetworkError]: {
|
|
481
|
+
code: A2AErrorCodeEnum.NetworkError,
|
|
482
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
483
|
+
severity: A2AErrorSeverityEnum.High,
|
|
484
|
+
retryable: true,
|
|
485
|
+
description: "A network request failed."
|
|
486
|
+
},
|
|
487
|
+
[A2AErrorCodeEnum.UnexpectedStatus]: {
|
|
488
|
+
code: A2AErrorCodeEnum.UnexpectedStatus,
|
|
489
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
490
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
491
|
+
retryable: true,
|
|
492
|
+
description: "The remote endpoint returned an unexpected status."
|
|
493
|
+
},
|
|
494
|
+
[A2AErrorCodeEnum.SerializationError]: {
|
|
495
|
+
code: A2AErrorCodeEnum.SerializationError,
|
|
496
|
+
category: A2AErrorCategoryEnum.Transport,
|
|
497
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
498
|
+
retryable: false,
|
|
499
|
+
description: "The request or response body could not be parsed."
|
|
500
|
+
},
|
|
501
|
+
// auth
|
|
502
|
+
[A2AErrorCodeEnum.AuthenticationFailed]: {
|
|
503
|
+
code: A2AErrorCodeEnum.AuthenticationFailed,
|
|
504
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
505
|
+
severity: A2AErrorSeverityEnum.High,
|
|
506
|
+
retryable: false,
|
|
507
|
+
description: "Authentication failed (invalid or missing credentials)."
|
|
508
|
+
},
|
|
509
|
+
[A2AErrorCodeEnum.AuthorizationDenied]: {
|
|
510
|
+
code: A2AErrorCodeEnum.AuthorizationDenied,
|
|
511
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
512
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
513
|
+
retryable: false,
|
|
514
|
+
description: "The caller is not authorized for the requested operation."
|
|
515
|
+
},
|
|
516
|
+
[A2AErrorCodeEnum.TokenExpired]: {
|
|
517
|
+
code: A2AErrorCodeEnum.TokenExpired,
|
|
518
|
+
category: A2AErrorCategoryEnum.Auth,
|
|
519
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
520
|
+
retryable: true,
|
|
521
|
+
description: "The access token has expired."
|
|
522
|
+
},
|
|
523
|
+
// rate limit
|
|
524
|
+
[A2AErrorCodeEnum.RateLimitExceeded]: {
|
|
525
|
+
code: A2AErrorCodeEnum.RateLimitExceeded,
|
|
526
|
+
category: A2AErrorCategoryEnum.RateLimit,
|
|
527
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
528
|
+
retryable: true,
|
|
529
|
+
description: "The caller has exceeded the rate limit."
|
|
530
|
+
},
|
|
531
|
+
[A2AErrorCodeEnum.QuotaExceeded]: {
|
|
532
|
+
code: A2AErrorCodeEnum.QuotaExceeded,
|
|
533
|
+
category: A2AErrorCategoryEnum.RateLimit,
|
|
534
|
+
severity: A2AErrorSeverityEnum.Medium,
|
|
535
|
+
retryable: false,
|
|
536
|
+
description: "The caller has exceeded their usage quota."
|
|
537
|
+
},
|
|
538
|
+
// internal
|
|
539
|
+
[A2AErrorCodeEnum.InternalError]: {
|
|
540
|
+
code: A2AErrorCodeEnum.InternalError,
|
|
541
|
+
category: A2AErrorCategoryEnum.Internal,
|
|
542
|
+
severity: A2AErrorSeverityEnum.Critical,
|
|
543
|
+
retryable: false,
|
|
544
|
+
description: "An unexpected internal error occurred."
|
|
545
|
+
},
|
|
546
|
+
[A2AErrorCodeEnum.ConfigurationError]: {
|
|
547
|
+
code: A2AErrorCodeEnum.ConfigurationError,
|
|
548
|
+
category: A2AErrorCategoryEnum.Internal,
|
|
549
|
+
severity: A2AErrorSeverityEnum.High,
|
|
550
|
+
retryable: false,
|
|
551
|
+
description: "A configuration error was detected."
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/audit-helpers.ts
|
|
556
|
+
function agentActor(agentId, platform, name) {
|
|
557
|
+
return {
|
|
558
|
+
kind: AuditActorKindEnum.Agent,
|
|
559
|
+
id: agentId,
|
|
560
|
+
platform,
|
|
561
|
+
name
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function connectorActor(connectorId, platform, name) {
|
|
565
|
+
return {
|
|
566
|
+
kind: AuditActorKindEnum.Connector,
|
|
567
|
+
id: connectorId,
|
|
568
|
+
platform,
|
|
569
|
+
name
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function systemActor(systemId = "control-plane") {
|
|
573
|
+
return {
|
|
574
|
+
kind: AuditActorKindEnum.System,
|
|
575
|
+
id: systemId,
|
|
576
|
+
name: "A2A Control Plane"
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function taskTarget(taskId) {
|
|
580
|
+
return {
|
|
581
|
+
kind: AuditTargetKindEnum.Task,
|
|
582
|
+
id: taskId
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function connectorTarget(connectorId, name) {
|
|
586
|
+
return {
|
|
587
|
+
kind: AuditTargetKindEnum.Connector,
|
|
588
|
+
id: connectorId,
|
|
589
|
+
name
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function emitTaskSubmitted(input) {
|
|
593
|
+
return createAuditEvent({
|
|
594
|
+
id: input.id,
|
|
595
|
+
event_type: AuditEventTypeEnum.TaskSubmitted,
|
|
596
|
+
severity: AuditSeverityEnum.Info,
|
|
597
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
598
|
+
target: taskTarget(input.task_id),
|
|
599
|
+
trace_id: input.trace_id,
|
|
600
|
+
workspace_id: input.workspace_id,
|
|
601
|
+
thread_id: input.thread_id,
|
|
602
|
+
task_id: input.task_id,
|
|
603
|
+
parent_event_id: input.parent_event_id,
|
|
604
|
+
metadata: input.metadata,
|
|
605
|
+
tags: input.tags,
|
|
606
|
+
now: input.now
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
function emitTaskStarted(input) {
|
|
610
|
+
return createAuditEvent({
|
|
611
|
+
id: input.id,
|
|
612
|
+
event_type: AuditEventTypeEnum.TaskStarted,
|
|
613
|
+
severity: AuditSeverityEnum.Info,
|
|
614
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
615
|
+
target: taskTarget(input.task_id),
|
|
616
|
+
trace_id: input.trace_id,
|
|
617
|
+
workspace_id: input.workspace_id,
|
|
618
|
+
thread_id: input.thread_id,
|
|
619
|
+
task_id: input.task_id,
|
|
620
|
+
parent_event_id: input.parent_event_id,
|
|
621
|
+
metadata: input.metadata,
|
|
622
|
+
tags: input.tags,
|
|
623
|
+
now: input.now
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function emitTaskProgress(input) {
|
|
627
|
+
const metadata = { ...input.metadata };
|
|
628
|
+
if (input.progress_pct !== void 0) {
|
|
629
|
+
metadata.progress_pct = input.progress_pct;
|
|
630
|
+
}
|
|
631
|
+
return createAuditEvent({
|
|
632
|
+
id: input.id,
|
|
633
|
+
event_type: AuditEventTypeEnum.TaskProgress,
|
|
634
|
+
severity: AuditSeverityEnum.Info,
|
|
635
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
636
|
+
target: taskTarget(input.task_id),
|
|
637
|
+
trace_id: input.trace_id,
|
|
638
|
+
workspace_id: input.workspace_id,
|
|
639
|
+
thread_id: input.thread_id,
|
|
640
|
+
task_id: input.task_id,
|
|
641
|
+
parent_event_id: input.parent_event_id,
|
|
642
|
+
metadata,
|
|
643
|
+
tags: input.tags,
|
|
644
|
+
now: input.now
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
function emitTaskInputRequired(input) {
|
|
648
|
+
return createAuditEvent({
|
|
649
|
+
id: input.id,
|
|
650
|
+
event_type: AuditEventTypeEnum.TaskInputRequired,
|
|
651
|
+
severity: AuditSeverityEnum.Info,
|
|
652
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
653
|
+
target: taskTarget(input.task_id),
|
|
654
|
+
trace_id: input.trace_id,
|
|
655
|
+
workspace_id: input.workspace_id,
|
|
656
|
+
thread_id: input.thread_id,
|
|
657
|
+
task_id: input.task_id,
|
|
658
|
+
parent_event_id: input.parent_event_id,
|
|
659
|
+
metadata: input.metadata,
|
|
660
|
+
tags: input.tags,
|
|
661
|
+
now: input.now
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function emitTaskCompleted(input) {
|
|
665
|
+
return createAuditEvent({
|
|
666
|
+
id: input.id,
|
|
667
|
+
event_type: AuditEventTypeEnum.TaskCompleted,
|
|
668
|
+
severity: AuditSeverityEnum.Info,
|
|
669
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
670
|
+
target: taskTarget(input.task_id),
|
|
671
|
+
trace_id: input.trace_id,
|
|
672
|
+
workspace_id: input.workspace_id,
|
|
673
|
+
thread_id: input.thread_id,
|
|
674
|
+
task_id: input.task_id,
|
|
675
|
+
parent_event_id: input.parent_event_id,
|
|
676
|
+
duration_ms: input.duration_ms,
|
|
677
|
+
metadata: input.metadata,
|
|
678
|
+
tags: input.tags,
|
|
679
|
+
now: input.now
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
function emitTaskFailed(input) {
|
|
683
|
+
const metadata = { ...input.metadata };
|
|
684
|
+
if (input.error_code) metadata.error_code = input.error_code;
|
|
685
|
+
if (input.error_message) metadata.error_message = input.error_message;
|
|
686
|
+
return createAuditEvent({
|
|
687
|
+
id: input.id,
|
|
688
|
+
event_type: AuditEventTypeEnum.TaskFailed,
|
|
689
|
+
severity: AuditSeverityEnum.Error,
|
|
690
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
691
|
+
target: taskTarget(input.task_id),
|
|
692
|
+
trace_id: input.trace_id,
|
|
693
|
+
workspace_id: input.workspace_id,
|
|
694
|
+
thread_id: input.thread_id,
|
|
695
|
+
task_id: input.task_id,
|
|
696
|
+
parent_event_id: input.parent_event_id,
|
|
697
|
+
duration_ms: input.duration_ms,
|
|
698
|
+
metadata,
|
|
699
|
+
tags: input.tags,
|
|
700
|
+
now: input.now
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
function emitTaskCancelled(input) {
|
|
704
|
+
const metadata = { ...input.metadata };
|
|
705
|
+
if (input.reason) metadata.cancellation_reason = input.reason;
|
|
706
|
+
return createAuditEvent({
|
|
707
|
+
id: input.id,
|
|
708
|
+
event_type: AuditEventTypeEnum.TaskCancelled,
|
|
709
|
+
severity: AuditSeverityEnum.Info,
|
|
710
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
711
|
+
target: taskTarget(input.task_id),
|
|
712
|
+
trace_id: input.trace_id,
|
|
713
|
+
workspace_id: input.workspace_id,
|
|
714
|
+
thread_id: input.thread_id,
|
|
715
|
+
task_id: input.task_id,
|
|
716
|
+
parent_event_id: input.parent_event_id,
|
|
717
|
+
metadata,
|
|
718
|
+
tags: input.tags,
|
|
719
|
+
now: input.now
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
function emitConnectorAttached(input) {
|
|
723
|
+
return createAuditEvent({
|
|
724
|
+
id: input.id,
|
|
725
|
+
event_type: AuditEventTypeEnum.ConnectorAttached,
|
|
726
|
+
severity: AuditSeverityEnum.Info,
|
|
727
|
+
actor: systemActor(),
|
|
728
|
+
target: connectorTarget(input.connector_id, input.connector_name),
|
|
729
|
+
trace_id: input.trace_id,
|
|
730
|
+
workspace_id: input.workspace_id,
|
|
731
|
+
thread_id: input.thread_id,
|
|
732
|
+
task_id: input.task_id,
|
|
733
|
+
parent_event_id: input.parent_event_id,
|
|
734
|
+
metadata: {
|
|
735
|
+
...input.metadata,
|
|
736
|
+
connector_platform: input.connector_platform
|
|
737
|
+
},
|
|
738
|
+
tags: input.tags,
|
|
739
|
+
now: input.now
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
function emitConnectorHealth(input) {
|
|
743
|
+
return createAuditEvent({
|
|
744
|
+
id: input.id,
|
|
745
|
+
event_type: AuditEventTypeEnum.ConnectorHealth,
|
|
746
|
+
severity: input.healthy ? AuditSeverityEnum.Info : AuditSeverityEnum.Warning,
|
|
747
|
+
actor: connectorActor(input.connector_id, input.connector_platform, input.connector_name),
|
|
748
|
+
target: connectorTarget(input.connector_id, input.connector_name),
|
|
749
|
+
trace_id: input.trace_id,
|
|
750
|
+
workspace_id: input.workspace_id,
|
|
751
|
+
thread_id: input.thread_id,
|
|
752
|
+
task_id: input.task_id,
|
|
753
|
+
parent_event_id: input.parent_event_id,
|
|
754
|
+
metadata: {
|
|
755
|
+
...input.metadata,
|
|
756
|
+
healthy: input.healthy,
|
|
757
|
+
...input.latency_ms !== void 0 ? { latency_ms: input.latency_ms } : {}
|
|
758
|
+
},
|
|
759
|
+
tags: input.tags,
|
|
760
|
+
now: input.now
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
function emitConnectorError(input) {
|
|
764
|
+
return createAuditEvent({
|
|
765
|
+
id: input.id,
|
|
766
|
+
event_type: AuditEventTypeEnum.ConnectorError,
|
|
767
|
+
severity: AuditSeverityEnum.Error,
|
|
768
|
+
actor: connectorActor(input.connector_id, input.connector_platform, input.connector_name),
|
|
769
|
+
target: connectorTarget(input.connector_id, input.connector_name),
|
|
770
|
+
trace_id: input.trace_id,
|
|
771
|
+
workspace_id: input.workspace_id,
|
|
772
|
+
thread_id: input.thread_id,
|
|
773
|
+
task_id: input.task_id,
|
|
774
|
+
parent_event_id: input.parent_event_id,
|
|
775
|
+
metadata: {
|
|
776
|
+
...input.metadata,
|
|
777
|
+
...input.error_code ? { error_code: input.error_code } : {},
|
|
778
|
+
error_message: input.error_message
|
|
779
|
+
},
|
|
780
|
+
tags: input.tags,
|
|
781
|
+
now: input.now
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function emitPolicyChecked(input) {
|
|
785
|
+
const policyContext = {
|
|
786
|
+
action: input.action,
|
|
787
|
+
rule: input.rule,
|
|
788
|
+
approved: input.approved,
|
|
789
|
+
reason: input.reason,
|
|
790
|
+
agent_id: input.agent_id
|
|
791
|
+
};
|
|
792
|
+
return createAuditEvent({
|
|
793
|
+
id: input.id,
|
|
794
|
+
event_type: AuditEventTypeEnum.PolicyChecked,
|
|
795
|
+
severity: AuditSeverityEnum.Info,
|
|
796
|
+
actor: systemActor("policy-engine"),
|
|
797
|
+
target: taskTarget(input.task_id),
|
|
798
|
+
trace_id: input.trace_id,
|
|
799
|
+
workspace_id: input.workspace_id,
|
|
800
|
+
thread_id: input.thread_id,
|
|
801
|
+
task_id: input.task_id,
|
|
802
|
+
parent_event_id: input.parent_event_id,
|
|
803
|
+
duration_ms: input.duration_ms,
|
|
804
|
+
policy: policyContext,
|
|
805
|
+
metadata: input.metadata,
|
|
806
|
+
tags: input.tags,
|
|
807
|
+
now: input.now
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
function emitPolicyApproved(input) {
|
|
811
|
+
return createAuditEvent({
|
|
812
|
+
id: input.id,
|
|
813
|
+
event_type: AuditEventTypeEnum.PolicyApproved,
|
|
814
|
+
severity: AuditSeverityEnum.Info,
|
|
815
|
+
actor: systemActor("policy-engine"),
|
|
816
|
+
target: taskTarget(input.task_id),
|
|
817
|
+
trace_id: input.trace_id,
|
|
818
|
+
workspace_id: input.workspace_id,
|
|
819
|
+
thread_id: input.thread_id,
|
|
820
|
+
task_id: input.task_id,
|
|
821
|
+
parent_event_id: input.parent_event_id,
|
|
822
|
+
duration_ms: input.duration_ms,
|
|
823
|
+
policy: {
|
|
824
|
+
action: input.action,
|
|
825
|
+
rule: input.rule,
|
|
826
|
+
approved: true,
|
|
827
|
+
reason: input.reason,
|
|
828
|
+
agent_id: input.agent_id
|
|
829
|
+
},
|
|
830
|
+
metadata: input.metadata,
|
|
831
|
+
tags: input.tags,
|
|
832
|
+
now: input.now
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
function emitPolicyDenied(input) {
|
|
836
|
+
return createAuditEvent({
|
|
837
|
+
id: input.id,
|
|
838
|
+
event_type: AuditEventTypeEnum.PolicyDenied,
|
|
839
|
+
severity: AuditSeverityEnum.Warning,
|
|
840
|
+
actor: systemActor("policy-engine"),
|
|
841
|
+
target: taskTarget(input.task_id),
|
|
842
|
+
trace_id: input.trace_id,
|
|
843
|
+
workspace_id: input.workspace_id,
|
|
844
|
+
thread_id: input.thread_id,
|
|
845
|
+
task_id: input.task_id,
|
|
846
|
+
parent_event_id: input.parent_event_id,
|
|
847
|
+
duration_ms: input.duration_ms,
|
|
848
|
+
policy: {
|
|
849
|
+
action: input.action,
|
|
850
|
+
rule: input.rule,
|
|
851
|
+
approved: false,
|
|
852
|
+
reason: input.reason,
|
|
853
|
+
agent_id: input.agent_id
|
|
854
|
+
},
|
|
855
|
+
metadata: input.metadata,
|
|
856
|
+
tags: input.tags,
|
|
857
|
+
now: input.now
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
var STATE_TO_EVENT_TYPE = {
|
|
861
|
+
submitted: AuditEventTypeEnum.TaskSubmitted,
|
|
862
|
+
working: AuditEventTypeEnum.TaskStarted,
|
|
863
|
+
"input-required": AuditEventTypeEnum.TaskInputRequired,
|
|
864
|
+
completed: AuditEventTypeEnum.TaskCompleted,
|
|
865
|
+
failed: AuditEventTypeEnum.TaskFailed,
|
|
866
|
+
cancelled: AuditEventTypeEnum.TaskCancelled
|
|
867
|
+
};
|
|
868
|
+
function emitAuditForTransition(input, newState) {
|
|
869
|
+
const eventType = STATE_TO_EVENT_TYPE[newState] ?? AuditEventTypeEnum.TaskProgress;
|
|
870
|
+
const severity = newState === "failed" ? AuditSeverityEnum.Error : newState === "cancelled" ? AuditSeverityEnum.Warning : AuditSeverityEnum.Info;
|
|
871
|
+
return createAuditEvent({
|
|
872
|
+
id: input.id,
|
|
873
|
+
event_type: eventType,
|
|
874
|
+
severity,
|
|
875
|
+
actor: agentActor(input.actor_agent_id, input.actor_platform, input.actor_name),
|
|
876
|
+
target: taskTarget(input.task_id),
|
|
877
|
+
trace_id: input.trace_id,
|
|
878
|
+
workspace_id: input.workspace_id,
|
|
879
|
+
thread_id: input.thread_id,
|
|
880
|
+
task_id: input.task_id,
|
|
881
|
+
parent_event_id: input.parent_event_id,
|
|
882
|
+
duration_ms: input.duration_ms,
|
|
883
|
+
metadata: input.metadata,
|
|
884
|
+
tags: input.tags,
|
|
885
|
+
now: input.now
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
889
|
+
0 && (module.exports = {
|
|
890
|
+
emitAuditForTransition,
|
|
891
|
+
emitConnectorAttached,
|
|
892
|
+
emitConnectorError,
|
|
893
|
+
emitConnectorHealth,
|
|
894
|
+
emitPolicyApproved,
|
|
895
|
+
emitPolicyChecked,
|
|
896
|
+
emitPolicyDenied,
|
|
897
|
+
emitTaskCancelled,
|
|
898
|
+
emitTaskCompleted,
|
|
899
|
+
emitTaskFailed,
|
|
900
|
+
emitTaskInputRequired,
|
|
901
|
+
emitTaskProgress,
|
|
902
|
+
emitTaskStarted,
|
|
903
|
+
emitTaskSubmitted
|
|
904
|
+
});
|
|
905
|
+
//# sourceMappingURL=audit-helpers.js.map
|