apcore-a2a 0.3.0 → 0.4.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.
Files changed (53) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +15 -13
  3. package/dist/adapters/agent-card.d.ts.map +1 -1
  4. package/dist/adapters/agent-card.js +44 -5
  5. package/dist/adapters/agent-card.js.map +1 -1
  6. package/dist/adapters/errors.d.ts +3 -1
  7. package/dist/adapters/errors.d.ts.map +1 -1
  8. package/dist/adapters/errors.js +39 -11
  9. package/dist/adapters/errors.js.map +1 -1
  10. package/dist/adapters/parts.d.ts +2 -1
  11. package/dist/adapters/parts.d.ts.map +1 -1
  12. package/dist/adapters/parts.js +16 -12
  13. package/dist/adapters/parts.js.map +1 -1
  14. package/dist/adapters/schema.d.ts +0 -2
  15. package/dist/adapters/schema.d.ts.map +1 -1
  16. package/dist/adapters/schema.js +8 -40
  17. package/dist/adapters/schema.js.map +1 -1
  18. package/dist/adapters/skill-mapper.d.ts +3 -0
  19. package/dist/adapters/skill-mapper.d.ts.map +1 -1
  20. package/dist/adapters/skill-mapper.js +10 -1
  21. package/dist/adapters/skill-mapper.js.map +1 -1
  22. package/dist/auth/jwt.d.ts.map +1 -1
  23. package/dist/auth/jwt.js +27 -6
  24. package/dist/auth/jwt.js.map +1 -1
  25. package/dist/auth/middleware.d.ts.map +1 -1
  26. package/dist/auth/middleware.js +1 -0
  27. package/dist/auth/middleware.js.map +1 -1
  28. package/dist/cli.js +1 -1
  29. package/dist/cli.js.map +1 -1
  30. package/dist/client/card-fetcher.js +1 -1
  31. package/dist/client/card-fetcher.js.map +1 -1
  32. package/dist/client/client.d.ts +2 -0
  33. package/dist/client/client.d.ts.map +1 -1
  34. package/dist/client/client.js +4 -0
  35. package/dist/client/client.js.map +1 -1
  36. package/dist/explorer/index.html +1 -1
  37. package/dist/index.d.ts +10 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +14 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/serve.d.ts +2 -0
  42. package/dist/serve.d.ts.map +1 -1
  43. package/dist/serve.js +25 -2
  44. package/dist/serve.js.map +1 -1
  45. package/dist/server/executor.d.ts +10 -2
  46. package/dist/server/executor.d.ts.map +1 -1
  47. package/dist/server/executor.js +203 -70
  48. package/dist/server/executor.js.map +1 -1
  49. package/dist/server/factory.d.ts +3 -1
  50. package/dist/server/factory.d.ts.map +1 -1
  51. package/dist/server/factory.js +92 -8
  52. package/dist/server/factory.js.map +1 -1
  53. package/package.json +4 -3
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 AI Perceivable Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md CHANGED
@@ -19,15 +19,16 @@ It solves a common problem: **you've built AI capabilities with apcore modules,
19
19
 
20
20
  Built on [`@a2a-js/sdk`](https://www.npmjs.com/package/@a2a-js/sdk) and [Express 5](https://expressjs.com/).
21
21
 
22
- > **Also available in Python:** [`apcore-a2a` (PyPI)](https://github.com/aiperceivable/apcore-a2a-python)
22
+ > **Also available in:** [Python](https://github.com/aiperceivable/apcore-a2a-python) | [Rust](https://github.com/aiperceivable/apcore-a2a-rust)
23
23
 
24
24
  ## Features
25
25
 
26
26
  - **One-call server** — launch a compliant A2A server with `serve(registry)`
27
- - **Automatic Agent Card** — `/.well-known/agent.json` generated from module metadata
27
+ - **Automatic Agent Card** — `/.well-known/agent-card.json` (A2A 1.0 primary; `/.well-known/agent.json` 0.3 alias) generated from module metadata
28
28
  - **Skill mapping** — apcore modules become A2A Skills with names, descriptions, tags, and examples; `metadata.display.a2a` overrides surface-facing fields (§5.13)
29
29
  - **Full task lifecycle** — submitted, working, completed, failed, canceled, input-required
30
30
  - **SSE streaming** — `message/stream` with real-time status and artifact updates
31
+ - **Push notifications** — optional webhook delivery of task state changes
31
32
  - **JWT authentication** — tokens bridged to apcore's Identity context
32
33
  - **A2A Explorer UI** — browser UI for discovering and testing skills, with auth bar and cURL generation
33
34
  - **Built-in client** — `A2AClient` for calling remote A2A agents
@@ -39,7 +40,7 @@ Built on [`@a2a-js/sdk`](https://www.npmjs.com/package/@a2a-js/sdk) and [Express
39
40
  ## Requirements
40
41
 
41
42
  - Node.js >= 18.0.0
42
- - `apcore-js` >= 0.14.0
43
+ - `apcore-js` >= 0.22.0
43
44
 
44
45
  ---
45
46
 
@@ -61,10 +62,13 @@ import { serve } from "apcore-a2a";
61
62
 
62
63
  const registry = new Registry({ extensionsDir: "./extensions" });
63
64
 
65
+ // Discover modules before serving (requires top-level await or an async function)
66
+ await registry.discover();
67
+
64
68
  serve(registry); // Starts on http://0.0.0.0:8000
65
69
  ```
66
70
 
67
- Your agent is now live at `http://localhost:8000/.well-known/agent.json`.
71
+ Your agent is now live at `http://localhost:8000/.well-known/agent-card.json` (the A2A 1.0 primary endpoint; `/.well-known/agent.json` is also served as the 0.3 alias).
68
72
 
69
73
  ### CLI (zero-code)
70
74
 
@@ -93,14 +97,12 @@ const card = await client.discover();
93
97
  console.log(`Agent: ${card.name}, Skills: ${card.skills.length}`);
94
98
 
95
99
  // Send a message
96
- const task = await client.sendMessage(
97
- { role: "user", parts: [{ kind: "text", text: "hello" }] },
98
- { contextId: "ctx-1" },
99
- );
100
+ const message = { role: "user", parts: [{ kind: "text", text: "hello" }] };
101
+ const task = await client.sendMessage(message, { contextId: "ctx-1" });
100
102
  console.log(`Result: ${task.status.state}`);
101
103
 
102
104
  // Or stream the response
103
- for await (const event of client.streamMessage(message)) {
105
+ for await (const event of client.streamMessage(message, { contextId: "ctx-1" })) {
104
106
  console.log(event);
105
107
  }
106
108
 
@@ -151,7 +153,7 @@ serve(registryOrExecutor, {
151
153
  corsOrigins: ["http://localhost:3000"],
152
154
  explorer: true, // Enable A2A Explorer UI
153
155
  explorerPrefix: "/explorer",
154
- executionTimeout: 300_000, // ms (default: 300000)
156
+ executionTimeout: 300, // seconds (default: 300)
155
157
  metrics: true, // Enable /metrics endpoint
156
158
  shutdownTimeout: 30, // Graceful shutdown timeout in seconds
157
159
  });
@@ -173,7 +175,7 @@ const app = await asyncServe(registryOrExecutor, options);
173
175
  Default in-memory task store. Implement the `TaskStore` interface (`save`, `load`) for persistent backends.
174
176
 
175
177
  ```typescript
176
- import { InMemoryTaskStore } from "apcore-a2a/storage";
178
+ import { InMemoryTaskStore } from "@a2a-js/sdk/server";
177
179
 
178
180
  const store = new InMemoryTaskStore();
179
181
  serve(registry, { taskStore: store });
@@ -238,8 +240,8 @@ See [`examples/README.md`](examples/README.md) for details on class-based vs pro
238
240
  ```bash
239
241
  git clone https://github.com/aiperceivable/apcore-a2a-typescript.git
240
242
  cd apcore-a2a-typescript
241
- npm install
242
- npm test
243
+ pnpm install
244
+ pnpm test
243
245
  ```
244
246
 
245
247
  ## Documentation
@@ -1 +1 @@
1
- {"version":3,"file":"agent-card.d.ts","sourceRoot":"","sources":["../../src/adapters/agent-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,QAAQ;IACvB,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IACzD,QAAQ,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;CACxD;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAA0B;gBAEhC,WAAW,EAAE,WAAW;IAIpC,KAAK,CACH,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,iBAAiB,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC3C,GACA,SAAS;IAqBZ,gBAAgB,CACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,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AAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,iBAAiB,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC3C,GACA,SAAS;IAKZ,aAAa,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS;IAI7C,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,WAAW;CAapB"}
@@ -1,3 +1,22 @@
1
+ /**
2
+ * Convert a flat security-scheme dict (the shape `JWTAuthenticator.securitySchemes()`
3
+ * returns, e.g. `{type:"http",scheme,bearerFormat}`) into the A2A 1.0 protobuf-JSON
4
+ * `oneof` shape served by the reference a2a-sdk, e.g.
5
+ * `{httpAuthSecurityScheme:{scheme,bearerFormat}}`. This keeps the served
6
+ * `securitySchemes` byte-identical across the Python/TS/Rust SDKs (the proto3 JSON
7
+ * mapping is the canonical A2A 1.0 wire shape; the flat OpenAPI-style form is not).
8
+ */
9
+ function toA2ASecurityScheme(scheme) {
10
+ if (scheme.type === "http") {
11
+ const http = { scheme: scheme.scheme ?? "bearer" };
12
+ // proto3 JSON omits empty fields; only emit bearerFormat when present.
13
+ if (scheme.bearerFormat)
14
+ http.bearerFormat = scheme.bearerFormat;
15
+ return { httpAuthSecurityScheme: http };
16
+ }
17
+ // Unknown scheme types map to an empty SecurityScheme (matches the Python builder).
18
+ return {};
19
+ }
1
20
  export class AgentCardBuilder {
2
21
  skillMapper;
3
22
  cachedCard = null;
@@ -6,18 +25,36 @@ export class AgentCardBuilder {
6
25
  }
7
26
  build(registry, opts) {
8
27
  const skills = this.buildSkills(registry);
28
+ // a2a-js 1.0 AgentCard: `url` is replaced by `supportedInterfaces`, and the
29
+ // protocol version lives on each interface. extendedAgentCard moves to
30
+ // capabilities.
9
31
  const card = {
10
32
  name: opts.name,
11
33
  description: opts.description,
12
34
  version: opts.version,
13
- url: opts.url,
14
- protocolVersion: "0.2.1",
35
+ supportedInterfaces: [
36
+ {
37
+ url: opts.url,
38
+ protocolBinding: "JSONRPC",
39
+ tenant: "",
40
+ protocolVersion: "1.0",
41
+ },
42
+ ],
43
+ provider: undefined,
15
44
  skills,
45
+ // extendedAgentCard is decided by the caller (the factory sets it to
46
+ // `auth != null`, matching Python/Rust). Do not derive it from
47
+ // securitySchemes — that diverges for a custom authenticator that
48
+ // returns no schemes while auth is configured.
16
49
  capabilities: opts.capabilities,
17
50
  defaultInputModes: ["text/plain", "application/json"],
18
51
  defaultOutputModes: ["text/plain", "application/json"],
19
- securitySchemes: opts.securitySchemes,
20
- supportsAuthenticatedExtendedCard: opts.securitySchemes != null,
52
+ securitySchemes: Object.fromEntries(Object.entries(opts.securitySchemes ?? {}).map(([k, v]) => [
53
+ k,
54
+ toA2ASecurityScheme(v),
55
+ ])),
56
+ securityRequirements: [],
57
+ signatures: [],
21
58
  };
22
59
  this.cachedCard = card;
23
60
  return card;
@@ -37,8 +74,10 @@ export class AgentCardBuilder {
37
74
  const skills = [];
38
75
  for (const moduleId of registry.list()) {
39
76
  const descriptor = registry.getDefinition(moduleId);
40
- if (!descriptor?.description)
77
+ if (!descriptor?.description?.trim()) {
78
+ console.warn(`Skipping module ${moduleId}: missing description`);
41
79
  continue;
80
+ }
42
81
  const skill = this.skillMapper.toSkill(descriptor, moduleId);
43
82
  if (skill)
44
83
  skills.push(skill);
@@ -1 +1 @@
1
- {"version":3,"file":"agent-card.js","sourceRoot":"","sources":["../../src/adapters/agent-card.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,gBAAgB;IACnB,WAAW,CAAc;IACzB,UAAU,GAAqB,IAAI,CAAC;IAE5C,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,KAAK,CACH,QAAkB,EAClB,IAOC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE1C,MAAM,IAAI,GAAc;YACtB,IA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AAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAC7D,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -3,8 +3,10 @@ export interface JsonRpcError {
3
3
  message: string;
4
4
  }
5
5
  export declare class ErrorMapper {
6
+ /** ErrorFormatter interface for apcore ErrorFormatterRegistry. */
7
+ format(error: unknown, _context?: unknown): Record<string, unknown>;
6
8
  toJsonRpcError(error: unknown): JsonRpcError;
7
9
  private handleApcoreError;
8
- sanitizeMessage(message: string): string;
10
+ private sanitizeMessage;
9
11
  }
10
12
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,WAAW;IACtB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAgB5C,OAAO,CAAC,iBAAiB;IAmCzB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAGzC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,WAAW;IACtB,kEAAkE;IAClE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKnE,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAqB5C,OAAO,CAAC,iBAAiB;IAuDzB,OAAO,CAAC,eAAe;CAOxB"}
@@ -1,9 +1,19 @@
1
+ import { ErrorCodes } from "apcore-js";
1
2
  const CODE_METHOD_NOT_FOUND = -32601;
2
3
  const CODE_INVALID_PARAMS = -32602;
3
4
  const CODE_INTERNAL_ERROR = -32603;
4
5
  const CODE_TASK_NOT_FOUND = -32001;
5
6
  export class ErrorMapper {
7
+ /** ErrorFormatter interface for apcore ErrorFormatterRegistry. */
8
+ format(error, _context) {
9
+ const rpcError = this.toJsonRpcError(error);
10
+ return { code: rpcError.code, message: rpcError.message };
11
+ }
6
12
  toJsonRpcError(error) {
13
+ // Sanitization rule 4: log the full, unsanitized error at ERROR level for
14
+ // server-side diagnostics before any sanitization is applied (matches the
15
+ // Python binding).
16
+ console.error("Mapping error to JSON-RPC error:", error);
7
17
  if (error instanceof Error) {
8
18
  const code = error.code;
9
19
  if (code) {
@@ -16,33 +26,51 @@ export class ErrorMapper {
16
26
  return { code: CODE_INTERNAL_ERROR, message: "Internal server error" };
17
27
  }
18
28
  handleApcoreError(error, errorCode) {
19
- if (errorCode === "MODULE_NOT_FOUND") {
29
+ if (errorCode === ErrorCodes.MODULE_NOT_FOUND) {
20
30
  const message = this.sanitizeMessage(error.message);
21
31
  return { code: CODE_METHOD_NOT_FOUND, message };
22
32
  }
23
- if (errorCode === "SCHEMA_VALIDATION_ERROR") {
33
+ if (errorCode === ErrorCodes.SCHEMA_VALIDATION_ERROR) {
24
34
  const message = this.sanitizeMessage(error.message);
25
35
  return { code: CODE_INVALID_PARAMS, message };
26
36
  }
27
- if (errorCode === "ACL_DENIED") {
37
+ if (errorCode === ErrorCodes.GENERAL_INVALID_INPUT) {
38
+ const description = this.sanitizeMessage(error.message);
39
+ return { code: CODE_INVALID_PARAMS, message: `Invalid input: ${description}` };
40
+ }
41
+ if (errorCode === ErrorCodes.ACL_DENIED) {
28
42
  return { code: CODE_TASK_NOT_FOUND, message: "Task not found" };
29
43
  }
30
- if (errorCode === "MODULE_TIMEOUT" || errorCode === "EXECUTION_TIMEOUT") {
44
+ if (errorCode === ErrorCodes.MODULE_TIMEOUT) {
31
45
  return { code: CODE_INTERNAL_ERROR, message: "Execution timeout" };
32
46
  }
33
- if (errorCode === "CALL_DEPTH_EXCEEDED" ||
34
- errorCode === "CIRCULAR_CALL" ||
35
- errorCode === "CALL_FREQUENCY_EXCEEDED") {
47
+ if (errorCode === ErrorCodes.EXECUTION_CANCELLED) {
48
+ return { code: CODE_INTERNAL_ERROR, message: "Execution cancelled" };
49
+ }
50
+ if (errorCode === ErrorCodes.CALL_DEPTH_EXCEEDED ||
51
+ errorCode === ErrorCodes.CIRCULAR_CALL ||
52
+ errorCode === ErrorCodes.CALL_FREQUENCY_EXCEEDED) {
36
53
  return { code: CODE_INTERNAL_ERROR, message: "Safety limit exceeded" };
37
54
  }
38
- if (errorCode === "INVALID_INPUT") {
39
- const description = this.sanitizeMessage(error.message);
40
- return { code: CODE_INVALID_PARAMS, message: `Invalid input: ${description}` };
55
+ if (errorCode === ErrorCodes.CIRCUIT_BREAKER_OPEN || errorCode === ErrorCodes.TASK_LIMIT_EXCEEDED) {
56
+ return { code: CODE_INTERNAL_ERROR, message: "Service temporarily unavailable" };
57
+ }
58
+ if (errorCode === ErrorCodes.MODULE_DISABLED) {
59
+ return { code: CODE_INTERNAL_ERROR, message: "Module is currently disabled" };
60
+ }
61
+ if (errorCode === ErrorCodes.CONFIG_NAMESPACE_DUPLICATE ||
62
+ errorCode === ErrorCodes.CONFIG_MOUNT_ERROR ||
63
+ errorCode === ErrorCodes.CONFIG_BIND_ERROR) {
64
+ return { code: CODE_INTERNAL_ERROR, message: "Configuration error" };
41
65
  }
42
66
  return { code: CODE_INTERNAL_ERROR, message: "Internal server error" };
43
67
  }
44
68
  sanitizeMessage(message) {
45
- return message.replace(/~?\/\S*/g, "").replace(/\s+/g, " ").trim().slice(0, 500);
69
+ // Strip file paths (Unix absolute paths and ~ paths)
70
+ let sanitized = message.replace(/~?\/\S*/g, "");
71
+ // Strip traceback lines (matching Python's behavior)
72
+ sanitized = sanitized.replace(/^.*(?:Traceback|File "|line \d+).*$/gm, "");
73
+ return sanitized.replace(/\s+/g, " ").trim().slice(0, 500);
46
74
  }
47
75
  }
48
76
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,CAAC,KAAK,CAAC;AACrC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AACnC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AACnC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AAOnC,MAAM,OAAO,WAAW;IACtB,cAAc,CAAC,KAAc;QAC3B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAI,KAA2B,CAAC,IAAI,CAAC;YAE/C,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAC7C,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC/E,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;YACrE,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACzE,CAAC;IAEO,iBAAiB,CAAC,KAAY,EAAE,SAAiB;QACvD,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAE,KAA6B,CAAC,OAAO,CAAC,CAAC;YAC7E,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,CAAC;QAClD,CAAC;QAED,IAAI,SAAS,KAAK,yBAAyB,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,C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,UAAU,CAAC,mBAAmB,EAAE,CAAC;YAClG,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;QACnF,CAAC;QAED,IAAI,SAAS,KAAK,UAAU,CAAC,eAAe,EAAE,CAAC;YAC7C,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;QAChF,CAAC;QAED,IACE,SAAS,KAAK,UAAU,CAAC,0BAA0B;YACnD,SAAS,KAAK,UAAU,CAAC,kBAAkB;YAC3C,SAAS,KAAK,UAAU,CAAC,iBAAiB,EAC1C,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;QACvE,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACzE,CAAC;IAEO,eAAe,CAAC,OAAe;QACrC,qDAAqD;QACrD,IAAI,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAChD,qDAAqD;QACrD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,uCAAuC,EAAE,EAAE,CAAC,CAAC;QAC3E,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -1,4 +1,5 @@
1
- import type { Artifact, Part } from "@a2a-js/sdk";
1
+ import { Artifact } from "@a2a-js/sdk";
2
+ import type { Part } from "@a2a-js/sdk";
2
3
  import { SchemaConverter } from "./schema.js";
3
4
  import type { ModuleDescriptor } from "./skill-mapper.js";
4
5
  export declare class PartConverter {
@@ -1 +1 @@
1
- {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/adapters/parts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,qBAAa,aAAa;IACxB,OAAO,CAAC,eAAe,CAAkB;gBAE7B,eAAe,CAAC,EAAE,eAAe;IAI7C,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAkClG,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ;CAqB1D"}
1
+ {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/adapters/parts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,qBAAa,aAAa;IACxB,OAAO,CAAC,eAAe,CAAkB;gBAE7B,eAAe,CAAC,EAAE,eAAe;IAI7C,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAqClG,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ;CAqB1D"}
@@ -1,4 +1,5 @@
1
1
  import { v4 as uuidv4 } from "uuid";
2
+ import { Artifact } from "@a2a-js/sdk";
2
3
  import { SchemaConverter } from "./schema.js";
3
4
  export class PartConverter {
4
5
  schemaConverter;
@@ -13,42 +14,45 @@ export class PartConverter {
13
14
  throw new Error("Multiple parts are not supported; expected exactly one Part");
14
15
  }
15
16
  const part = parts[0];
16
- if (part.kind === "text") {
17
+ // a2a-js 1.0 Part is a protobuf oneof: part.content = { $case, value }.
18
+ const content = part.content;
19
+ if (content?.$case === "text") {
20
+ const text = content.value;
17
21
  const inputSchema = descriptor?.input_schema ?? descriptor?.inputSchema ?? null;
18
22
  const rootType = this.schemaConverter.detectRootType(inputSchema);
19
23
  if (rootType === "object") {
20
24
  try {
21
- return JSON.parse(part.text);
25
+ return JSON.parse(text);
22
26
  }
23
27
  catch (e) {
24
28
  throw new Error(`TextPart text is not valid JSON: ${e}`);
25
29
  }
26
30
  }
27
- return part.text;
31
+ return text;
28
32
  }
29
- if (part.kind === "data") {
30
- return part.data;
33
+ if (content?.$case === "data") {
34
+ return content.value;
31
35
  }
32
- if (part.kind === "file") {
36
+ if (content?.$case === "raw" || content?.$case === "url") {
33
37
  throw new Error("FilePart is not supported");
34
38
  }
35
- throw new Error(`Unsupported part type: ${part.kind}`);
39
+ throw new Error("Unsupported part type: empty or unknown content");
36
40
  }
37
41
  outputToParts(output, taskId) {
38
42
  const artifactId = `art-${taskId || uuidv4()}`;
39
43
  if (output === null || output === undefined) {
40
- return { artifactId, parts: [] };
44
+ return Artifact.fromJSON({ artifactId, parts: [] });
41
45
  }
42
46
  if (typeof output === "string") {
43
- return { artifactId, parts: [{ kind: "text", text: output }] };
47
+ return Artifact.fromJSON({ artifactId, parts: [{ text: output }] });
44
48
  }
45
49
  if (Array.isArray(output)) {
46
- return { artifactId, parts: [{ kind: "text", text: JSON.stringify(output) }] };
50
+ return Artifact.fromJSON({ artifactId, parts: [{ text: JSON.stringify(output) }] });
47
51
  }
48
52
  if (typeof output === "object") {
49
- return { artifactId, parts: [{ kind: "data", data: output }] };
53
+ return Artifact.fromJSON({ artifactId, parts: [{ data: output }] });
50
54
  }
51
- return { artifactId, parts: [{ kind: "text", text: String(output) }] };
55
+ return Artifact.fromJSON({ artifactId, parts: [{ text: String(output) }] });
52
56
  }
53
57
  }
54
58
  //# sourceMappingURL=parts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parts.js","sourceRoot":"","sources":["../../src/adapters/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,OAAO,aAAa;IAChB,eAAe,CAAkB;IAEzC,YAAY,eAAiC;QAC3C,IAAI,CAAC,eAAe,GAAG,eAAe,IAAI,IAAI,eAAe,EAAE,CAAC;IAClE,CAAC;IAED,YAAY,CAAC,KAAa,EAAE,UAAmC;QAC7D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,MAAM,WAAW,GAAG,UAAU,EAAE,YAAY,IAAI,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC;YAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAClE,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAA4B,CAAC;gBAC1D,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,EAAE,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;YACD,OAAO,IAA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AK,QAAQ,EAAE,CAAC;YAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -8,8 +8,6 @@ export declare class SchemaConverter {
8
8
  }): JsonSchema;
9
9
  detectRootType(schema: JsonSchema | null | undefined): "string" | "object" | "unknown";
10
10
  private convertSchema;
11
- private inlineRefs;
12
- private resolveRef;
13
11
  private ensureObjectType;
14
12
  }
15
13
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAIjD,qBAAa,eAAe;IAC1B,kBAAkB,CAAC,UAAU,EAAE;QAAE,YAAY,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,UAAU;IAIzE,mBAAmB,CAAC,UAAU,EAAE;QAAE,aAAa,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,UAAU;IAI3E,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS;IAOtF,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,UAAU;IAqClB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,gBAAgB;CASzB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/adapters/schema.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,qBAAa,eAAe;IAC1B,kBAAkB,CAAC,UAAU,EAAE;QAAE,YAAY,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,UAAU;IAIzE,mBAAmB,CAAC,UAAU,EAAE;QAAE,aAAa,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,UAAU;IAI3E,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS;IAOtF,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,gBAAgB;CASzB"}