@groundnuty/macf-channel-server 0.2.28 → 0.2.32

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.
@@ -0,0 +1,286 @@
1
+ /**
2
+ * A2A v1.0 protocol types for inbound JSON-RPC `message/send` handling.
3
+ *
4
+ * Hand-rolled Zod schemas per A2A v1.0 spec sections:
5
+ * - § 4.1.1 Task
6
+ * - § 4.1.2 TaskStatus
7
+ * - § 4.1.3 TaskState (8-state enum, SCREAMING_SNAKE_CASE)
8
+ * - § 4.1.4 Message
9
+ * - § 4.1.5 Part (OneOf semantics: text | file | data; v1.0 dropped the `kind` discriminator per Appendix A.2.1)
10
+ * - § 9 JSON-RPC Protocol Binding (method `"message/send"`)
11
+ *
12
+ * **SDK choice**: continuing hand-rolled (per Phase 1 #370 + #385 decision).
13
+ * `@a2a-js/sdk` is still v0.3.13 (A2A v0.3 target); v1.0 not released.
14
+ * Re-evaluate at Phase 3 (outbound A2A) when the bidirectional surface
15
+ * pushes the build-vs-buy delta further.
16
+ *
17
+ * **Verified against spec text**: 2026-05-19 via a2a-protocol.org WebFetch.
18
+ * Section references in JSDoc above each schema preserve the citation
19
+ * trail for future re-verification.
20
+ *
21
+ * **macf#390 Phase 2a scope**: full 8-state TaskState enum + Message
22
+ * schema + Part text-variant; happy-path SUBMITTED → WORKING → COMPLETED.
23
+ * INPUT_REQUIRED / AUTH_REQUIRED transitions + file/data Part variants
24
+ * declared in types but exercised in Phase 2b.
25
+ */
26
+ import { z } from 'zod';
27
+ // ---------------------------------------------------------------------------
28
+ // TaskState — § 4.1.3 (SCREAMING_SNAKE_CASE per v1.0 enum convention)
29
+ // ---------------------------------------------------------------------------
30
+ export const TaskStateSchema = z.enum([
31
+ 'TASK_STATE_SUBMITTED',
32
+ 'TASK_STATE_WORKING',
33
+ 'TASK_STATE_INPUT_REQUIRED',
34
+ 'TASK_STATE_AUTH_REQUIRED',
35
+ 'TASK_STATE_COMPLETED',
36
+ 'TASK_STATE_FAILED',
37
+ 'TASK_STATE_CANCELED',
38
+ 'TASK_STATE_REJECTED',
39
+ ]);
40
+ /** Terminal states — no further transitions allowed once entered. */
41
+ export const TERMINAL_TASK_STATES = new Set([
42
+ 'TASK_STATE_COMPLETED',
43
+ 'TASK_STATE_FAILED',
44
+ 'TASK_STATE_CANCELED',
45
+ 'TASK_STATE_REJECTED',
46
+ ]);
47
+ /** Interrupted states — task pauses awaiting client follow-up via `Message.taskId`. */
48
+ export const INTERRUPTED_TASK_STATES = new Set([
49
+ 'TASK_STATE_INPUT_REQUIRED',
50
+ 'TASK_STATE_AUTH_REQUIRED',
51
+ ]);
52
+ // ---------------------------------------------------------------------------
53
+ // Role — § 4.1.4 (SCREAMING_SNAKE_CASE per v1.0)
54
+ // ---------------------------------------------------------------------------
55
+ export const RoleSchema = z.enum(['ROLE_USER', 'ROLE_AGENT']);
56
+ // ---------------------------------------------------------------------------
57
+ // Part — § 4.1.5 + canonical proto (spec/a2a.proto)
58
+ // ---------------------------------------------------------------------------
59
+ //
60
+ // Per the canonical proto (single authoritative source per spec § 1.4 —
61
+ // "spec/a2a.proto is the single authoritative normative definition"):
62
+ //
63
+ // message Part {
64
+ // oneof content {
65
+ // string text = 1;
66
+ // bytes raw = 2;
67
+ // string url = 3;
68
+ // google.protobuf.Value data = 4;
69
+ // }
70
+ // google.protobuf.Struct metadata = 5;
71
+ // string filename = 6;
72
+ // string media_type = 7;
73
+ // }
74
+ //
75
+ // Four `oneof content` variants (text / raw / url / data) — exactly one
76
+ // present. Optional top-level `metadata` + `filename` + `mediaType`
77
+ // (NOT inside a nested FilePart wrapper; v1.0 flattened the v0.3 shape).
78
+ //
79
+ // JSON wire-form names per protobuf-to-JSON canonical mapping:
80
+ // - `media_type` (proto snake_case) → `mediaType` (JSON camelCase)
81
+ // - `filename` → `filename` (single word, no transform)
82
+ // - `raw` is `bytes` in the proto → base64-encoded string on JSON wire
83
+ // - `data` is `google.protobuf.Value` → arbitrary JSON value
84
+ //
85
+ // Encoded as `z.union` of 4 separate variants (matching the proto's
86
+ // oneof discipline) rather than a single object with refine — clearer
87
+ // type discrimination for downstream consumers.
88
+ //
89
+ // Phase 2a only exercises the text variant; declaring the full proto
90
+ // shape so Phase 2b / Phase 3 don't need to refactor.
91
+ /** Shared optional fields present on all Part variants per proto §§ 5–7. */
92
+ const PartCommonFields = {
93
+ metadata: z.record(z.string(), z.unknown()).optional(),
94
+ filename: z.string().optional(),
95
+ mediaType: z.string().optional(),
96
+ };
97
+ const TextPartSchema = z.object({
98
+ text: z.string(),
99
+ ...PartCommonFields,
100
+ });
101
+ const RawPartSchema = z.object({
102
+ raw: z.string(), // base64-encoded bytes per proto3 JSON mapping
103
+ ...PartCommonFields,
104
+ });
105
+ const UrlPartSchema = z.object({
106
+ url: z.string(),
107
+ ...PartCommonFields,
108
+ });
109
+ // `data: z.unknown()` would accept undefined (Zod treats z.unknown as
110
+ // also-undefined), making empty objects pass DataPartSchema spuriously.
111
+ // The refine pins the key-presence requirement so the union correctly
112
+ // rejects `{}` + `{ filename: '...' }`-only inputs.
113
+ const DataPartSchema = z
114
+ .object({
115
+ data: z.unknown(),
116
+ ...PartCommonFields,
117
+ })
118
+ .refine((obj) => Object.prototype.hasOwnProperty.call(obj, 'data'), {
119
+ message: 'Part: `data` property must be present (oneof discriminator)',
120
+ });
121
+ export const PartSchema = z.union([
122
+ TextPartSchema,
123
+ RawPartSchema,
124
+ UrlPartSchema,
125
+ DataPartSchema,
126
+ ]);
127
+ // ---------------------------------------------------------------------------
128
+ // Message — § 4.1.4
129
+ // ---------------------------------------------------------------------------
130
+ export const MessageSchema = z.object({
131
+ messageId: z.string().min(1),
132
+ role: RoleSchema,
133
+ parts: z.array(PartSchema).min(1),
134
+ contextId: z.string().optional(),
135
+ /**
136
+ * `taskId` — canonical A2A v1.0 resume reference. When set, the receiver
137
+ * dispatches to the existing task (used for INPUT_REQUIRED / AUTH_REQUIRED
138
+ * resume flows in Phase 2b). Phase 2a creates fresh tasks; the field
139
+ * lands in the schema but isn't exercised yet.
140
+ */
141
+ taskId: z.string().optional(),
142
+ metadata: z.record(z.string(), z.unknown()).optional(),
143
+ extensions: z.array(z.string()).optional(),
144
+ referenceTaskIds: z.array(z.string()).optional(),
145
+ });
146
+ // ---------------------------------------------------------------------------
147
+ // TaskStatus — § 4.1.2
148
+ // ---------------------------------------------------------------------------
149
+ export const TaskStatusSchema = z.object({
150
+ state: TaskStateSchema,
151
+ /** Optional human-readable message accompanying the state. */
152
+ message: MessageSchema.optional(),
153
+ /** RFC 3339 / ISO 8601 timestamp of the last state change. */
154
+ timestamp: z.string().optional(),
155
+ });
156
+ // ---------------------------------------------------------------------------
157
+ // Task — § 4.1.1
158
+ // ---------------------------------------------------------------------------
159
+ export const TaskSchema = z.object({
160
+ id: z.string().min(1),
161
+ status: TaskStatusSchema,
162
+ contextId: z.string().optional(),
163
+ /** History of all messages exchanged on this task. */
164
+ history: z.array(MessageSchema).optional(),
165
+ /** Artifacts produced by the agent (responses, files, etc.). */
166
+ artifacts: z.array(z.unknown()).optional(),
167
+ metadata: z.record(z.string(), z.unknown()).optional(),
168
+ });
169
+ // ---------------------------------------------------------------------------
170
+ // JSON-RPC 2.0 envelope — § 9 (`method: "message/send"`)
171
+ // ---------------------------------------------------------------------------
172
+ /** JSON-RPC 2.0 request envelope. `id` is required for `message/send` (not a notification). */
173
+ export const JsonRpcRequestSchema = z.object({
174
+ jsonrpc: z.literal('2.0'),
175
+ method: z.string().min(1),
176
+ id: z.union([z.string(), z.number()]),
177
+ params: z.unknown().optional(),
178
+ });
179
+ /** Params for `message/send` — wraps a Message. */
180
+ export const MessageSendParamsSchema = z.object({
181
+ message: MessageSchema,
182
+ /** Optional `configuration` / `metadata` keys per spec § 9.4.1 (not exercised in Phase 2a). */
183
+ configuration: z.record(z.string(), z.unknown()).optional(),
184
+ metadata: z.record(z.string(), z.unknown()).optional(),
185
+ });
186
+ // ---------------------------------------------------------------------------
187
+ // tasks/get + tasks/cancel params — § 9 + canonical proto (macf#398 Phase 2d)
188
+ // ---------------------------------------------------------------------------
189
+ //
190
+ // Per canonical proto (a2a.proto):
191
+ // message GetTaskRequest { string name = 1; ... }
192
+ // message CancelTaskRequest { string name = 1; ... }
193
+ //
194
+ // `name` is the resource path "tasks/{id}". The JSON-RPC binding in
195
+ // practice accepts EITHER the bare `id` form (canonical in most A2A
196
+ // client SDKs surveyed) OR the proto-canonical `name` form. We accept
197
+ // both by branching on which key is present; the route handler reduces
198
+ // to the bare taskId for TaskStore lookup.
199
+ //
200
+ // Why accept both: the Python a2a-sdk v1.0.3 client surface emits
201
+ // `params: { id }` for tasks/get; the protobuf-canonical wire form
202
+ // emits `params: { name: "tasks/{id}" }`. Rejecting either would break
203
+ // a real client.
204
+ /** Params for `tasks/get` + `tasks/cancel`. Accepts `{ id }` or proto-canonical `{ name: "tasks/{id}" }`. */
205
+ export const TaskIdParamsSchema = z
206
+ .object({
207
+ id: z.string().min(1).optional(),
208
+ name: z.string().min(1).optional(),
209
+ metadata: z.record(z.string(), z.unknown()).optional(),
210
+ })
211
+ .refine((obj) => (obj.id !== undefined) || (obj.name !== undefined), { message: 'Params: one of `id` or `name` must be present' });
212
+ /**
213
+ * Resolve a TaskIdParams to the bare task id. `id` takes precedence
214
+ * over `name`; if only `name` is present, strip the `tasks/` resource
215
+ * prefix per the proto canonical mapping. Returns `undefined` if
216
+ * neither was present (the refine should have rejected, but defensive).
217
+ */
218
+ export function resolveTaskId(params) {
219
+ if (params.id !== undefined && params.id.length > 0)
220
+ return params.id;
221
+ if (params.name !== undefined && params.name.length > 0) {
222
+ return params.name.startsWith('tasks/') ? params.name.slice('tasks/'.length) : params.name;
223
+ }
224
+ return undefined;
225
+ }
226
+ /**
227
+ * JSON-RPC 2.0 success response envelope. `result` for `message/send`
228
+ * is either a Task or a Message per spec § 9.4.1 — Phase 2a always
229
+ * returns a Task (synchronous happy-path COMPLETED).
230
+ */
231
+ export const JsonRpcSuccessResponseSchema = z.object({
232
+ jsonrpc: z.literal('2.0'),
233
+ id: z.union([z.string(), z.number(), z.null()]),
234
+ result: TaskSchema,
235
+ });
236
+ /**
237
+ * JSON-RPC 2.0 error envelope. Per A2A v1.0 spec § 9 (and v1.0 change
238
+ * notes), errors use the `google.rpc.Status` representation with
239
+ * `ErrorInfo` extensions: `reason` in UPPER_SNAKE_CASE + domain
240
+ * `"a2a-protocol.org"`.
241
+ *
242
+ * Standard JSON-RPC `code`/`message` + `data.reason`/`data.domain` for
243
+ * the A2A-specific reason classification.
244
+ */
245
+ export const JsonRpcErrorResponseSchema = z.object({
246
+ jsonrpc: z.literal('2.0'),
247
+ id: z.union([z.string(), z.number(), z.null()]),
248
+ error: z.object({
249
+ code: z.number(),
250
+ message: z.string(),
251
+ data: z
252
+ .object({
253
+ reason: z.string().optional(),
254
+ domain: z.string().optional(),
255
+ })
256
+ .passthrough()
257
+ .optional(),
258
+ }),
259
+ });
260
+ // ---------------------------------------------------------------------------
261
+ // JSON-RPC error code constants (spec § 9 + JSON-RPC 2.0 §5.1)
262
+ // ---------------------------------------------------------------------------
263
+ /** JSON-RPC 2.0 standard error codes. */
264
+ export const JSONRPC_PARSE_ERROR = -32700;
265
+ export const JSONRPC_INVALID_REQUEST = -32600;
266
+ export const JSONRPC_METHOD_NOT_FOUND = -32601;
267
+ export const JSONRPC_INVALID_PARAMS = -32602;
268
+ export const JSONRPC_INTERNAL_ERROR = -32603;
269
+ /** A2A-specific reason codes (UPPER_SNAKE_CASE per v1.0 § 9 ErrorInfo). */
270
+ export const A2A_ERROR_DOMAIN = 'a2a-protocol.org';
271
+ export const A2A_REASON_INVALID_MESSAGE = 'INVALID_MESSAGE';
272
+ export const A2A_REASON_TASK_NOT_FOUND = 'TASK_NOT_FOUND';
273
+ export const A2A_REASON_METHOD_NOT_SUPPORTED = 'METHOD_NOT_SUPPORTED';
274
+ /** Resume attempted against a terminal task (COMPLETED/FAILED/CANCELED/REJECTED) — macf#392 Phase 2b. */
275
+ export const A2A_REASON_TASK_TERMINAL_STATE = 'TASK_TERMINAL_STATE';
276
+ /** Resume attempted with non-resumable from-state (only INPUT_REQUIRED + AUTH_REQUIRED accept resume) — macf#392 Phase 2b. */
277
+ export const A2A_REASON_TASK_NOT_RESUMABLE = 'TASK_NOT_RESUMABLE';
278
+ /** Canonical JSON-RPC method string for the inbound message exchange (spec § 9 examples). */
279
+ export const A2A_METHOD_MESSAGE_SEND = 'message/send';
280
+ /** Canonical JSON-RPC method string for task lookup (macf#398 Phase 2d). */
281
+ export const A2A_METHOD_TASKS_GET = 'tasks/get';
282
+ /** Canonical JSON-RPC method string for task cancellation (macf#398 Phase 2d). */
283
+ export const A2A_METHOD_TASKS_CANCEL = 'tasks/cancel';
284
+ /** Canonical AgentCard.url path for this server's A2A endpoint. */
285
+ export const A2A_ENDPOINT_PATH = '/a2a/v1';
286
+ //# sourceMappingURL=a2a-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2a-types.js","sourceRoot":"","sources":["../src/a2a-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,sBAAsB;IACtB,oBAAoB;IACpB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,mBAAmB;IACnB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC,CAAC;AAIH,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAA2B,IAAI,GAAG,CAAC;IAClE,sBAAsB;IACtB,mBAAmB;IACnB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC,CAAC;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAA2B,IAAI,GAAG,CAAC;IACrE,2BAA2B;IAC3B,0BAA0B;CAC3B,CAAC,CAAC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EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAEhD,kFAAkF;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAEtD,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC"}
@@ -35,21 +35,48 @@
35
35
  */
36
36
  import { z } from 'zod';
37
37
  /**
38
- * AgentSkill — per spec § 4.4.5. Required: id, name. Optional:
39
- * description, tags, examples, inputModes, outputModes, metadata,
40
- * extensions.
38
+ * AgentSkill — per canonical proto (`a2aproject/A2A:specification/a2a.proto`
39
+ * `message AgentSkill`). Required per proto: id, name, description, tags.
40
+ * Optional: examples, input_modes, output_modes, security_requirements.
41
+ *
42
+ * JSON wire form uses canonical lowerCamelCase mapping from proto
43
+ * snake_case (`input_modes` → `inputModes`, etc.) per proto3 JSON spec.
44
+ *
45
+ * **macf#393 Phase 2c**: `description` + `tags` upgraded from optional
46
+ * (Phase 1's lenient shape) to required per proto. Strict-validating
47
+ * external A2A clients (Bedrock AgentCore, Microsoft Agent Framework,
48
+ * etc.) reject AgentCards with skill entries missing required fields.
41
49
  */
42
50
  export declare const AgentSkillSchema: z.ZodObject<{
43
51
  id: z.ZodString;
44
52
  name: z.ZodString;
45
- description: z.ZodOptional<z.ZodString>;
46
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ description: z.ZodString;
54
+ tags: z.ZodArray<z.ZodString>;
47
55
  examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
56
  inputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
49
57
  outputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
50
58
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
51
59
  }, z.core.$strip>;
52
60
  export type AgentSkill = z.infer<typeof AgentSkillSchema>;
61
+ /**
62
+ * AgentInterface — per canonical proto `message AgentInterface`.
63
+ * Per AgentCard `supported_interfaces` (proto field 3, REQUIRED): the
64
+ * endpoint URL + protocol binding the agent serves. v1.0 moves the
65
+ * endpoint URL OUT of AgentCard top-level into the (repeated)
66
+ * AgentInterface entries.
67
+ *
68
+ * Required per proto: url, protocol_binding, protocol_version.
69
+ * Optional: tenant.
70
+ *
71
+ * JSON wire form: `protocolBinding` (lowerCamelCase) + `protocolVersion`.
72
+ */
73
+ export declare const AgentInterfaceSchema: z.ZodObject<{
74
+ url: z.ZodString;
75
+ protocolBinding: z.ZodString;
76
+ tenant: z.ZodOptional<z.ZodString>;
77
+ protocolVersion: z.ZodString;
78
+ }, z.core.$strip>;
79
+ export type AgentInterface = z.infer<typeof AgentInterfaceSchema>;
53
80
  /**
54
81
  * MutualTlsSecurityScheme — per spec § 4.5.6. Type discriminator
55
82
  * `mutualTls`. No additional fields required at the scheme level;
@@ -84,42 +111,67 @@ export declare const AgentCapabilitiesSchema: z.ZodObject<{
84
111
  }, z.core.$catchall<z.ZodUnknown>>;
85
112
  export type AgentCapabilities = z.infer<typeof AgentCapabilitiesSchema>;
86
113
  /**
87
- * AgentCard — per spec § 4.4.1. Required: id, name, url, version,
88
- * provider, capabilities, securitySchemes. Optional: description,
89
- * defaultInputModes, defaultOutputModes, skills, extensions, security,
90
- * metadata.
114
+ * AgentCard — per canonical proto `message AgentCard` (verified verbatim
115
+ * from `a2aproject/A2A:specification/a2a.proto` 2026-05-19).
116
+ *
117
+ * Required per proto: name, description, supported_interfaces,
118
+ * version, capabilities, default_input_modes, default_output_modes, skills.
119
+ * Optional: provider, documentation_url, security_schemes,
120
+ * security_requirements, signatures, icon_url.
121
+ *
122
+ * JSON wire form uses canonical lowerCamelCase mapping from proto
123
+ * snake_case (`supported_interfaces` → `supportedInterfaces`, etc.).
124
+ *
125
+ * **macf#393 Phase 2c** — schema realignment to canonical proto:
126
+ * - REMOVED top-level `id` (no such field in proto)
127
+ * - REMOVED top-level `url` (moves to `supportedInterfaces[0].url`)
128
+ * - ADDED `description` as required (was optional in Phase 1)
129
+ * - ADDED `supportedInterfaces` as required (endpoint URL lives here per v1.0)
130
+ * - ADDED `defaultInputModes` + `defaultOutputModes` as required
131
+ * - `skills` upgraded from optional to required (proto says REQUIRED)
132
+ *
133
+ * The schema change is structurally breaking for any consumer that parsed
134
+ * Phase 1's AgentCard shape; pre-flight grep on 2026-05-19 confirmed zero
135
+ * external consumers (Phase 1 shipped ~24h prior). Migration documented
136
+ * in DR-022 Amendment M.
91
137
  */
92
138
  export declare const AgentCardSchema: z.ZodObject<{
93
- id: z.ZodString;
94
139
  name: z.ZodString;
95
- url: z.ZodString;
140
+ description: z.ZodString;
141
+ supportedInterfaces: z.ZodArray<z.ZodObject<{
142
+ url: z.ZodString;
143
+ protocolBinding: z.ZodString;
144
+ tenant: z.ZodOptional<z.ZodString>;
145
+ protocolVersion: z.ZodString;
146
+ }, z.core.$strip>>;
96
147
  version: z.ZodString;
97
- provider: z.ZodObject<{
148
+ provider: z.ZodOptional<z.ZodObject<{
98
149
  organization: z.ZodString;
99
150
  url: z.ZodOptional<z.ZodString>;
100
- }, z.core.$strip>;
151
+ }, z.core.$strip>>;
101
152
  capabilities: z.ZodObject<{
102
153
  streaming: z.ZodOptional<z.ZodBoolean>;
103
154
  pushNotifications: z.ZodOptional<z.ZodBoolean>;
104
155
  }, z.core.$catchall<z.ZodUnknown>>;
105
- securitySchemes: z.ZodRecord<z.ZodString, z.ZodObject<{
156
+ securitySchemes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
106
157
  type: z.ZodLiteral<"mutualTls">;
107
158
  description: z.ZodOptional<z.ZodString>;
108
- }, z.core.$strip>>;
109
- description: z.ZodOptional<z.ZodString>;
110
- defaultInputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
- defaultOutputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
112
- skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
159
+ }, z.core.$strip>>>;
160
+ defaultInputModes: z.ZodArray<z.ZodString>;
161
+ defaultOutputModes: z.ZodArray<z.ZodString>;
162
+ skills: z.ZodArray<z.ZodObject<{
113
163
  id: z.ZodString;
114
164
  name: z.ZodString;
115
- description: z.ZodOptional<z.ZodString>;
116
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
165
+ description: z.ZodString;
166
+ tags: z.ZodArray<z.ZodString>;
117
167
  examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
168
  inputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
119
169
  outputModes: z.ZodOptional<z.ZodArray<z.ZodString>>;
120
170
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
121
- }, z.core.$strip>>>;
171
+ }, z.core.$strip>>;
122
172
  security: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
173
+ documentationUrl: z.ZodOptional<z.ZodString>;
174
+ iconUrl: z.ZodOptional<z.ZodString>;
123
175
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
124
176
  }, z.core.$strip>;
125
177
  export type AgentCard = z.infer<typeof AgentCardSchema>;
@@ -149,10 +201,25 @@ export interface AgentCardInputs {
149
201
  * clients SHOULD NOT depend on it. A source-level test in
150
202
  * `test/agent-card.test.ts` pins this invariant.
151
203
  *
152
- * Skills in Phase 1: empty array. The MACF coordination surfaces
153
- * (POST /notify for inbound peer notifications) are framework-internal,
154
- * not user-invocable agent skills in the A2A sense. Phase 2+ may add
155
- * skills as A2A's task lifecycle surfaces materialize.
204
+ * Skills in Phase 2a (macf#390): MACF domain capabilities what the
205
+ * agent can DO, not what JSON-RPC methods it serves. Per spec § 4.4.5,
206
+ * skills describe agent-specific actions on top of the A2A protocol
207
+ * methods. Initial mapping (Phase 2a):
208
+ *
209
+ * - `macf.notify_peer` — Cross-Agent Notification (the canonical MACF
210
+ * coordination primitive; #267)
211
+ * - `macf.checkpoint_to_memory` — Persist Context to Memory (the PreCompact
212
+ * checkpoint MCP tool; #271 DR-023 §UC-3)
213
+ *
214
+ * Phase 3+ will add role-specific skills if the MACF MCP-tool surface
215
+ * grows. `/macf/sign` is intentionally absent — live cryptographic
216
+ * attestation stays MACF-only per DR-010 Path 2 + #371; a source-level
217
+ * test pins this invariant.
218
+ *
219
+ * `url` field: Phase 2a points AgentCard.url to the JSON-RPC endpoint
220
+ * (`<inputs.url>/a2a/v1`). A2A clients discover via
221
+ * `/.well-known/agent-card.json` then POST `message/send` to the
222
+ * advertised url.
156
223
  */
157
224
  export declare function buildAgentCard(inputs: AgentCardInputs): AgentCard;
158
225
  //# sourceMappingURL=agent-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../src/agent-card.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;iBAS3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;kCAGZ,CAAC;AAEzB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB1B,CAAC;AAEH,MAAM,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