@dexto/server 1.2.5

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 (174) hide show
  1. package/LICENSE +44 -0
  2. package/dist/a2a/adapters/index.cjs +42 -0
  3. package/dist/a2a/adapters/index.d.ts +10 -0
  4. package/dist/a2a/adapters/index.d.ts.map +1 -0
  5. package/dist/a2a/adapters/index.js +12 -0
  6. package/dist/a2a/adapters/message.cjs +193 -0
  7. package/dist/a2a/adapters/message.d.ts +50 -0
  8. package/dist/a2a/adapters/message.d.ts.map +1 -0
  9. package/dist/a2a/adapters/message.js +167 -0
  10. package/dist/a2a/adapters/state.cjs +57 -0
  11. package/dist/a2a/adapters/state.d.ts +36 -0
  12. package/dist/a2a/adapters/state.d.ts.map +1 -0
  13. package/dist/a2a/adapters/state.js +32 -0
  14. package/dist/a2a/adapters/task-view.cjs +85 -0
  15. package/dist/a2a/adapters/task-view.d.ts +58 -0
  16. package/dist/a2a/adapters/task-view.d.ts.map +1 -0
  17. package/dist/a2a/adapters/task-view.js +60 -0
  18. package/dist/a2a/index.cjs +51 -0
  19. package/dist/a2a/index.d.ts +15 -0
  20. package/dist/a2a/index.d.ts.map +1 -0
  21. package/dist/a2a/index.js +30 -0
  22. package/dist/a2a/jsonrpc/index.cjs +38 -0
  23. package/dist/a2a/jsonrpc/index.d.ts +11 -0
  24. package/dist/a2a/jsonrpc/index.d.ts.map +1 -0
  25. package/dist/a2a/jsonrpc/index.js +10 -0
  26. package/dist/a2a/jsonrpc/methods.cjs +183 -0
  27. package/dist/a2a/jsonrpc/methods.d.ts +110 -0
  28. package/dist/a2a/jsonrpc/methods.d.ts.map +1 -0
  29. package/dist/a2a/jsonrpc/methods.js +159 -0
  30. package/dist/a2a/jsonrpc/server.cjs +199 -0
  31. package/dist/a2a/jsonrpc/server.d.ts +100 -0
  32. package/dist/a2a/jsonrpc/server.d.ts.map +1 -0
  33. package/dist/a2a/jsonrpc/server.js +175 -0
  34. package/dist/a2a/jsonrpc/types.cjs +47 -0
  35. package/dist/a2a/jsonrpc/types.d.ts +91 -0
  36. package/dist/a2a/jsonrpc/types.d.ts.map +1 -0
  37. package/dist/a2a/jsonrpc/types.js +21 -0
  38. package/dist/a2a/types.cjs +16 -0
  39. package/dist/a2a/types.d.ts +250 -0
  40. package/dist/a2a/types.d.ts.map +1 -0
  41. package/dist/a2a/types.js +0 -0
  42. package/dist/approval/approval-coordinator.cjs +87 -0
  43. package/dist/approval/approval-coordinator.d.ts +52 -0
  44. package/dist/approval/approval-coordinator.d.ts.map +1 -0
  45. package/dist/approval/approval-coordinator.js +63 -0
  46. package/dist/approval/manual-approval-handler.cjs +100 -0
  47. package/dist/approval/manual-approval-handler.d.ts +32 -0
  48. package/dist/approval/manual-approval-handler.d.ts.map +1 -0
  49. package/dist/approval/manual-approval-handler.js +76 -0
  50. package/dist/events/a2a-sse-subscriber.cjs +271 -0
  51. package/dist/events/a2a-sse-subscriber.d.ts +94 -0
  52. package/dist/events/a2a-sse-subscriber.d.ts.map +1 -0
  53. package/dist/events/a2a-sse-subscriber.js +247 -0
  54. package/dist/events/types.cjs +16 -0
  55. package/dist/events/types.d.ts +15 -0
  56. package/dist/events/types.d.ts.map +1 -0
  57. package/dist/events/types.js +0 -0
  58. package/dist/events/webhook-subscriber.cjs +301 -0
  59. package/dist/events/webhook-subscriber.d.ts +64 -0
  60. package/dist/events/webhook-subscriber.d.ts.map +1 -0
  61. package/dist/events/webhook-subscriber.js +269 -0
  62. package/dist/events/webhook-types.cjs +16 -0
  63. package/dist/events/webhook-types.d.ts +91 -0
  64. package/dist/events/webhook-types.d.ts.map +1 -0
  65. package/dist/events/webhook-types.js +0 -0
  66. package/dist/hono/__tests__/test-fixtures.cjs +236 -0
  67. package/dist/hono/__tests__/test-fixtures.d.ts +65 -0
  68. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -0
  69. package/dist/hono/__tests__/test-fixtures.js +197 -0
  70. package/dist/hono/index.cjs +166 -0
  71. package/dist/hono/index.d.ts +2783 -0
  72. package/dist/hono/index.d.ts.map +1 -0
  73. package/dist/hono/index.js +141 -0
  74. package/dist/hono/middleware/auth.cjs +75 -0
  75. package/dist/hono/middleware/auth.d.ts +3 -0
  76. package/dist/hono/middleware/auth.d.ts.map +1 -0
  77. package/dist/hono/middleware/auth.js +51 -0
  78. package/dist/hono/middleware/cors.cjs +57 -0
  79. package/dist/hono/middleware/cors.d.ts +9 -0
  80. package/dist/hono/middleware/cors.d.ts.map +1 -0
  81. package/dist/hono/middleware/cors.js +33 -0
  82. package/dist/hono/middleware/error.cjs +131 -0
  83. package/dist/hono/middleware/error.d.ts +5 -0
  84. package/dist/hono/middleware/error.d.ts.map +1 -0
  85. package/dist/hono/middleware/error.js +105 -0
  86. package/dist/hono/middleware/redaction.cjs +45 -0
  87. package/dist/hono/middleware/redaction.d.ts +4 -0
  88. package/dist/hono/middleware/redaction.d.ts.map +1 -0
  89. package/dist/hono/middleware/redaction.js +20 -0
  90. package/dist/hono/node/index.cjs +139 -0
  91. package/dist/hono/node/index.d.ts +19 -0
  92. package/dist/hono/node/index.d.ts.map +1 -0
  93. package/dist/hono/node/index.js +115 -0
  94. package/dist/hono/routes/a2a-jsonrpc.cjs +119 -0
  95. package/dist/hono/routes/a2a-jsonrpc.d.ts +46 -0
  96. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -0
  97. package/dist/hono/routes/a2a-jsonrpc.js +95 -0
  98. package/dist/hono/routes/a2a-tasks.cjs +315 -0
  99. package/dist/hono/routes/a2a-tasks.d.ts +530 -0
  100. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -0
  101. package/dist/hono/routes/a2a-tasks.js +291 -0
  102. package/dist/hono/routes/a2a.cjs +36 -0
  103. package/dist/hono/routes/a2a.d.ts +4 -0
  104. package/dist/hono/routes/a2a.d.ts.map +1 -0
  105. package/dist/hono/routes/a2a.js +12 -0
  106. package/dist/hono/routes/agents.cjs +735 -0
  107. package/dist/hono/routes/agents.d.ts +650 -0
  108. package/dist/hono/routes/agents.d.ts.map +1 -0
  109. package/dist/hono/routes/agents.js +711 -0
  110. package/dist/hono/routes/approvals.cjs +125 -0
  111. package/dist/hono/routes/approvals.d.ts +89 -0
  112. package/dist/hono/routes/approvals.d.ts.map +1 -0
  113. package/dist/hono/routes/approvals.js +101 -0
  114. package/dist/hono/routes/greeting.cjs +60 -0
  115. package/dist/hono/routes/greeting.d.ts +19 -0
  116. package/dist/hono/routes/greeting.d.ts.map +1 -0
  117. package/dist/hono/routes/greeting.js +36 -0
  118. package/dist/hono/routes/health.cjs +45 -0
  119. package/dist/hono/routes/health.d.ts +17 -0
  120. package/dist/hono/routes/health.d.ts.map +1 -0
  121. package/dist/hono/routes/health.js +21 -0
  122. package/dist/hono/routes/llm.cjs +298 -0
  123. package/dist/hono/routes/llm.d.ts +294 -0
  124. package/dist/hono/routes/llm.d.ts.map +1 -0
  125. package/dist/hono/routes/llm.js +287 -0
  126. package/dist/hono/routes/mcp.cjs +356 -0
  127. package/dist/hono/routes/mcp.d.ts +246 -0
  128. package/dist/hono/routes/mcp.d.ts.map +1 -0
  129. package/dist/hono/routes/mcp.js +332 -0
  130. package/dist/hono/routes/memory.cjs +192 -0
  131. package/dist/hono/routes/memory.d.ts +146 -0
  132. package/dist/hono/routes/memory.d.ts.map +1 -0
  133. package/dist/hono/routes/memory.js +168 -0
  134. package/dist/hono/routes/messages.cjs +320 -0
  135. package/dist/hono/routes/messages.d.ts +163 -0
  136. package/dist/hono/routes/messages.d.ts.map +1 -0
  137. package/dist/hono/routes/messages.js +296 -0
  138. package/dist/hono/routes/prompts.cjs +228 -0
  139. package/dist/hono/routes/prompts.d.ts +150 -0
  140. package/dist/hono/routes/prompts.d.ts.map +1 -0
  141. package/dist/hono/routes/prompts.js +204 -0
  142. package/dist/hono/routes/resources.cjs +110 -0
  143. package/dist/hono/routes/resources.d.ts +76 -0
  144. package/dist/hono/routes/resources.d.ts.map +1 -0
  145. package/dist/hono/routes/resources.js +86 -0
  146. package/dist/hono/routes/search.cjs +109 -0
  147. package/dist/hono/routes/search.d.ts +137 -0
  148. package/dist/hono/routes/search.d.ts.map +1 -0
  149. package/dist/hono/routes/search.js +85 -0
  150. package/dist/hono/routes/sessions.cjs +366 -0
  151. package/dist/hono/routes/sessions.d.ts +229 -0
  152. package/dist/hono/routes/sessions.d.ts.map +1 -0
  153. package/dist/hono/routes/sessions.js +342 -0
  154. package/dist/hono/routes/webhooks.cjs +228 -0
  155. package/dist/hono/routes/webhooks.d.ts +127 -0
  156. package/dist/hono/routes/webhooks.d.ts.map +1 -0
  157. package/dist/hono/routes/webhooks.js +204 -0
  158. package/dist/hono/schemas/responses.cjs +276 -0
  159. package/dist/hono/schemas/responses.d.ts +1418 -0
  160. package/dist/hono/schemas/responses.d.ts.map +1 -0
  161. package/dist/hono/schemas/responses.js +227 -0
  162. package/dist/hono/types.cjs +16 -0
  163. package/dist/hono/types.d.ts +6 -0
  164. package/dist/hono/types.d.ts.map +1 -0
  165. package/dist/hono/types.js +0 -0
  166. package/dist/index.cjs +38 -0
  167. package/dist/index.d.ts +11 -0
  168. package/dist/index.d.ts.map +1 -0
  169. package/dist/index.js +9 -0
  170. package/dist/mcp/mcp-handler.cjs +145 -0
  171. package/dist/mcp/mcp-handler.d.ts +14 -0
  172. package/dist/mcp/mcp-handler.d.ts.map +1 -0
  173. package/dist/mcp/mcp-handler.js +118 -0
  174. package/package.json +59 -0
@@ -0,0 +1,85 @@
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
+ var task_view_exports = {};
20
+ __export(task_view_exports, {
21
+ TaskView: () => TaskView,
22
+ createTaskView: () => createTaskView
23
+ });
24
+ module.exports = __toCommonJS(task_view_exports);
25
+ var import_message = require("./message.js");
26
+ var import_state = require("./state.js");
27
+ class TaskView {
28
+ constructor(session) {
29
+ this.session = session;
30
+ }
31
+ /**
32
+ * Convert the wrapped session to an A2A Task.
33
+ *
34
+ * This reads the session history and converts it to A2A format.
35
+ * State is derived from message patterns, not stored separately.
36
+ *
37
+ * @returns A2A protocol task structure
38
+ */
39
+ async toA2ATask() {
40
+ const history = await this.session.getHistory();
41
+ const a2aMessages = (0, import_message.internalMessagesToA2A)(history, this.session.id, this.session.id);
42
+ const state = (0, import_state.deriveTaskState)(history);
43
+ const status = {
44
+ state,
45
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
46
+ };
47
+ const task = {
48
+ id: this.session.id,
49
+ // taskId === sessionId
50
+ contextId: this.session.id,
51
+ // For now, contextId === taskId (could be enhanced for multi-task contexts)
52
+ status,
53
+ history: a2aMessages,
54
+ kind: "task",
55
+ metadata: {
56
+ dexto: {
57
+ sessionId: this.session.id
58
+ }
59
+ }
60
+ };
61
+ return task;
62
+ }
63
+ /**
64
+ * Get the underlying session ID.
65
+ * Since taskId === sessionId, this is the same as the task ID.
66
+ */
67
+ get sessionId() {
68
+ return this.session.id;
69
+ }
70
+ /**
71
+ * Get the underlying session (for advanced use).
72
+ */
73
+ get session_() {
74
+ return this.session;
75
+ }
76
+ }
77
+ async function createTaskView(sessionId, agent) {
78
+ const session = await agent.createSession(sessionId);
79
+ return new TaskView(session);
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ TaskView,
84
+ createTaskView
85
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A2A TaskView Adapter
3
+ *
4
+ * Wraps a Dexto ChatSession to present it as an A2A Task.
5
+ * This is a pure adapter - no storage, no persistence, just a view.
6
+ *
7
+ * Key principle: taskId === sessionId
8
+ */
9
+ import type { ChatSession } from '@dexto/core';
10
+ import type { Task } from '../types.js';
11
+ /**
12
+ * TaskView wraps a ChatSession to provide A2A-compliant task interface.
13
+ *
14
+ * This is a lightweight adapter that converts session state to A2A format
15
+ * on-demand. No state is cached or stored.
16
+ *
17
+ * Usage:
18
+ * ```typescript
19
+ * const session = await agent.createSession(taskId);
20
+ * const taskView = new TaskView(session);
21
+ * const task = await taskView.toA2ATask();
22
+ * ```
23
+ */
24
+ export declare class TaskView {
25
+ private session;
26
+ constructor(session: ChatSession);
27
+ /**
28
+ * Convert the wrapped session to an A2A Task.
29
+ *
30
+ * This reads the session history and converts it to A2A format.
31
+ * State is derived from message patterns, not stored separately.
32
+ *
33
+ * @returns A2A protocol task structure
34
+ */
35
+ toA2ATask(): Promise<Task>;
36
+ /**
37
+ * Get the underlying session ID.
38
+ * Since taskId === sessionId, this is the same as the task ID.
39
+ */
40
+ get sessionId(): string;
41
+ /**
42
+ * Get the underlying session (for advanced use).
43
+ */
44
+ get session_(): ChatSession;
45
+ }
46
+ /**
47
+ * Create a TaskView from a session ID and agent.
48
+ *
49
+ * Convenience factory function.
50
+ *
51
+ * @param sessionId Session/Task ID
52
+ * @param agent DextoAgent instance
53
+ * @returns TaskView wrapper
54
+ */
55
+ export declare function createTaskView(sessionId: string, agent: {
56
+ createSession(id: string): Promise<ChatSession>;
57
+ }): Promise<TaskView>;
58
+ //# sourceMappingURL=task-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-view.d.ts","sourceRoot":"","sources":["../../../src/a2a/adapters/task-view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;AAIpD;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAQ;IACL,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW;IAExC;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAiChC;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAE1B;CACJ;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE;IAAE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAAE,GAC3D,OAAO,CAAC,QAAQ,CAAC,CAGnB"}
@@ -0,0 +1,60 @@
1
+ import { internalMessagesToA2A } from "./message.js";
2
+ import { deriveTaskState } from "./state.js";
3
+ class TaskView {
4
+ constructor(session) {
5
+ this.session = session;
6
+ }
7
+ /**
8
+ * Convert the wrapped session to an A2A Task.
9
+ *
10
+ * This reads the session history and converts it to A2A format.
11
+ * State is derived from message patterns, not stored separately.
12
+ *
13
+ * @returns A2A protocol task structure
14
+ */
15
+ async toA2ATask() {
16
+ const history = await this.session.getHistory();
17
+ const a2aMessages = internalMessagesToA2A(history, this.session.id, this.session.id);
18
+ const state = deriveTaskState(history);
19
+ const status = {
20
+ state,
21
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
22
+ };
23
+ const task = {
24
+ id: this.session.id,
25
+ // taskId === sessionId
26
+ contextId: this.session.id,
27
+ // For now, contextId === taskId (could be enhanced for multi-task contexts)
28
+ status,
29
+ history: a2aMessages,
30
+ kind: "task",
31
+ metadata: {
32
+ dexto: {
33
+ sessionId: this.session.id
34
+ }
35
+ }
36
+ };
37
+ return task;
38
+ }
39
+ /**
40
+ * Get the underlying session ID.
41
+ * Since taskId === sessionId, this is the same as the task ID.
42
+ */
43
+ get sessionId() {
44
+ return this.session.id;
45
+ }
46
+ /**
47
+ * Get the underlying session (for advanced use).
48
+ */
49
+ get session_() {
50
+ return this.session;
51
+ }
52
+ }
53
+ async function createTaskView(sessionId, agent) {
54
+ const session = await agent.createSession(sessionId);
55
+ return new TaskView(session);
56
+ }
57
+ export {
58
+ TaskView,
59
+ createTaskView
60
+ };
@@ -0,0 +1,51 @@
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
+ var a2a_exports = {};
20
+ __export(a2a_exports, {
21
+ A2AMethodHandlers: () => import_jsonrpc.A2AMethodHandlers,
22
+ JsonRpcErrorCode: () => import_jsonrpc.JsonRpcErrorCode,
23
+ JsonRpcServer: () => import_jsonrpc.JsonRpcServer,
24
+ TaskView: () => import_adapters.TaskView,
25
+ a2aToInternalMessage: () => import_adapters.a2aToInternalMessage,
26
+ createTaskView: () => import_adapters.createTaskView,
27
+ deriveTaskState: () => import_adapters.deriveTaskState,
28
+ deriveTaskStateFromA2A: () => import_adapters.deriveTaskStateFromA2A,
29
+ internalMessagesToA2A: () => import_adapters.internalMessagesToA2A,
30
+ internalToA2AMessage: () => import_adapters.internalToA2AMessage,
31
+ isJsonRpcError: () => import_jsonrpc.isJsonRpcError,
32
+ isJsonRpcSuccess: () => import_jsonrpc.isJsonRpcSuccess
33
+ });
34
+ module.exports = __toCommonJS(a2a_exports);
35
+ var import_adapters = require("./adapters/index.js");
36
+ var import_jsonrpc = require("./jsonrpc/index.js");
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ A2AMethodHandlers,
40
+ JsonRpcErrorCode,
41
+ JsonRpcServer,
42
+ TaskView,
43
+ a2aToInternalMessage,
44
+ createTaskView,
45
+ deriveTaskState,
46
+ deriveTaskStateFromA2A,
47
+ internalMessagesToA2A,
48
+ internalToA2AMessage,
49
+ isJsonRpcError,
50
+ isJsonRpcSuccess
51
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A2A Protocol Implementation
3
+ *
4
+ * Server-layer implementation of A2A Protocol v0.3.0.
5
+ * Exposes DextoAgent capabilities through A2A-compliant interfaces.
6
+ *
7
+ * Specification: https://a2a-protocol.org/latest/specification
8
+ *
9
+ * @module a2a
10
+ */
11
+ export type { Task, TaskState, TaskStatus, Message, MessageRole, Part, TextPart, FilePart, DataPart, FileWithBytes, FileWithUri, Artifact, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, MessageSendParams, MessageSendConfiguration, TaskQueryParams, ListTasksParams, ListTasksResult, TaskIdParams, ConvertedMessage, } from './types.js';
12
+ export { TaskView, createTaskView, a2aToInternalMessage, internalToA2AMessage, internalMessagesToA2A, deriveTaskState, deriveTaskStateFromA2A, } from './adapters/index.js';
13
+ export { JsonRpcServer, A2AMethodHandlers, JsonRpcErrorCode, isJsonRpcError, isJsonRpcSuccess, } from './jsonrpc/index.js';
14
+ export type { JsonRpcRequest, JsonRpcResponse, JsonRpcError, JsonRpcMethodHandler, JsonRpcServerOptions, } from './jsonrpc/index.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACR,IAAI,EACJ,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,GACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACH,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACR,cAAc,EACd,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,GACvB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import {
2
+ TaskView,
3
+ createTaskView,
4
+ a2aToInternalMessage,
5
+ internalToA2AMessage,
6
+ internalMessagesToA2A,
7
+ deriveTaskState,
8
+ deriveTaskStateFromA2A
9
+ } from "./adapters/index.js";
10
+ import {
11
+ JsonRpcServer,
12
+ A2AMethodHandlers,
13
+ JsonRpcErrorCode,
14
+ isJsonRpcError,
15
+ isJsonRpcSuccess
16
+ } from "./jsonrpc/index.js";
17
+ export {
18
+ A2AMethodHandlers,
19
+ JsonRpcErrorCode,
20
+ JsonRpcServer,
21
+ TaskView,
22
+ a2aToInternalMessage,
23
+ createTaskView,
24
+ deriveTaskState,
25
+ deriveTaskStateFromA2A,
26
+ internalMessagesToA2A,
27
+ internalToA2AMessage,
28
+ isJsonRpcError,
29
+ isJsonRpcSuccess
30
+ };
@@ -0,0 +1,38 @@
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
+ var jsonrpc_exports = {};
20
+ __export(jsonrpc_exports, {
21
+ A2AMethodHandlers: () => import_methods.A2AMethodHandlers,
22
+ JsonRpcErrorCode: () => import_types.JsonRpcErrorCode,
23
+ JsonRpcServer: () => import_server.JsonRpcServer,
24
+ isJsonRpcError: () => import_types.isJsonRpcError,
25
+ isJsonRpcSuccess: () => import_types.isJsonRpcSuccess
26
+ });
27
+ module.exports = __toCommonJS(jsonrpc_exports);
28
+ var import_server = require("./server.js");
29
+ var import_methods = require("./methods.js");
30
+ var import_types = require("./types.js");
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ A2AMethodHandlers,
34
+ JsonRpcErrorCode,
35
+ JsonRpcServer,
36
+ isJsonRpcError,
37
+ isJsonRpcSuccess
38
+ });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A2A JSON-RPC 2.0 Implementation
3
+ *
4
+ * JSON-RPC transport layer for A2A Protocol.
5
+ */
6
+ export { JsonRpcServer } from './server.js';
7
+ export type { JsonRpcMethodHandler, JsonRpcServerOptions } from './server.js';
8
+ export { A2AMethodHandlers } from './methods.js';
9
+ export type { JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcError, JsonRpcBatchRequest, JsonRpcBatchResponse, } from './types.js';
10
+ export { JsonRpcErrorCode, isJsonRpcError, isJsonRpcSuccess } from './types.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/a2a/jsonrpc/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EACR,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { JsonRpcServer } from "./server.js";
2
+ import { A2AMethodHandlers } from "./methods.js";
3
+ import { JsonRpcErrorCode, isJsonRpcError, isJsonRpcSuccess } from "./types.js";
4
+ export {
5
+ A2AMethodHandlers,
6
+ JsonRpcErrorCode,
7
+ JsonRpcServer,
8
+ isJsonRpcError,
9
+ isJsonRpcSuccess
10
+ };
@@ -0,0 +1,183 @@
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
+ var methods_exports = {};
20
+ __export(methods_exports, {
21
+ A2AMethodHandlers: () => A2AMethodHandlers
22
+ });
23
+ module.exports = __toCommonJS(methods_exports);
24
+ var import_task_view = require("../adapters/task-view.js");
25
+ var import_message = require("../adapters/message.js");
26
+ class A2AMethodHandlers {
27
+ constructor(agent) {
28
+ this.agent = agent;
29
+ }
30
+ /**
31
+ * message/send - Send a message to the agent
32
+ *
33
+ * This is the primary method for interacting with an agent.
34
+ * Creates a task if taskId not provided in message, or adds to existing task.
35
+ *
36
+ * @param params Message send parameters
37
+ * @returns Task or Message depending on configuration.blocking
38
+ */
39
+ async messageSend(params) {
40
+ if (!params?.message) {
41
+ throw new Error("message is required");
42
+ }
43
+ const { message } = params;
44
+ const taskId = message.taskId;
45
+ const session = await this.agent.createSession(taskId);
46
+ const { text, image, file } = (0, import_message.a2aToInternalMessage)(message);
47
+ await this.agent.run(text, image, file, session.id);
48
+ const taskView = new import_task_view.TaskView(session);
49
+ const task = await taskView.toA2ATask();
50
+ return task;
51
+ }
52
+ /**
53
+ * tasks/get - Retrieve a task by ID
54
+ *
55
+ * @param params Parameters containing task ID
56
+ * @returns Task details
57
+ * @throws Error if task not found
58
+ */
59
+ async tasksGet(params) {
60
+ if (!params?.id) {
61
+ throw new Error("id is required");
62
+ }
63
+ const session = await this.agent.getSession(params.id);
64
+ if (!session) {
65
+ throw new Error(`Task not found: ${params.id}`);
66
+ }
67
+ const taskView = new import_task_view.TaskView(session);
68
+ return await taskView.toA2ATask();
69
+ }
70
+ /**
71
+ * tasks/list - List all tasks (optional filters)
72
+ *
73
+ * Note: This implementation loads all sessions, applies filters, then paginates.
74
+ * For production with many sessions, consider filtering at the session manager level.
75
+ *
76
+ * @param params Optional filter parameters
77
+ * @returns List of tasks with pagination info
78
+ */
79
+ async tasksList(params) {
80
+ const sessionIds = await this.agent.listSessions();
81
+ const allTasks = [];
82
+ for (const sessionId of sessionIds) {
83
+ const session = await this.agent.getSession(sessionId);
84
+ if (!session) {
85
+ continue;
86
+ }
87
+ const taskView = new import_task_view.TaskView(session);
88
+ const task = await taskView.toA2ATask();
89
+ if (params?.status && task.status.state !== params.status) {
90
+ continue;
91
+ }
92
+ if (params?.contextId && task.contextId !== params.contextId) {
93
+ continue;
94
+ }
95
+ allTasks.push(task);
96
+ }
97
+ const pageSize = Math.min(params?.pageSize ?? 50, 100);
98
+ const offset = 0;
99
+ const paginatedTasks = allTasks.slice(offset, offset + pageSize);
100
+ return {
101
+ tasks: paginatedTasks,
102
+ totalSize: allTasks.length,
103
+ // Total matching tasks before pagination
104
+ pageSize,
105
+ nextPageToken: ""
106
+ // TODO: Implement pagination tokens
107
+ };
108
+ }
109
+ /**
110
+ * tasks/cancel - Cancel a running task
111
+ *
112
+ * @param params Parameters containing task ID
113
+ * @returns Updated task (in canceled state)
114
+ * @throws Error if task not found
115
+ */
116
+ async tasksCancel(params) {
117
+ if (!params?.id) {
118
+ throw new Error("id is required");
119
+ }
120
+ const session = await this.agent.getSession(params.id);
121
+ if (!session) {
122
+ throw new Error(`Task not found: ${params.id}`);
123
+ }
124
+ session.cancel();
125
+ const taskView = new import_task_view.TaskView(session);
126
+ return await taskView.toA2ATask();
127
+ }
128
+ /**
129
+ * message/stream - Send a message with streaming response
130
+ *
131
+ * This is a streaming variant of message/send. Instead of returning a complete Task,
132
+ * it returns a stream of TaskStatusUpdateEvent and TaskArtifactUpdateEvent as the
133
+ * agent processes the message.
134
+ *
135
+ * **ARCHITECTURE NOTE**: This method is designed as a lightweight handler that returns
136
+ * a taskId immediately. The actual message processing happens at the transport layer:
137
+ *
138
+ * - **JSON-RPC Transport** (packages/server/src/hono/routes/a2a-jsonrpc.ts:72-112):
139
+ * The route intercepts 'message/stream' requests BEFORE calling this handler,
140
+ * processes the message directly (lines 96-99), and returns an SSE stream.
141
+ * This handler is registered but never actually invoked for JSON-RPC streaming.
142
+ *
143
+ * - **REST Transport** (packages/server/src/hono/routes/a2a-tasks.ts:206-244):
144
+ * Similar pattern - route processes message and returns SSE stream directly.
145
+ *
146
+ * This design separates concerns:
147
+ * - Handler provides taskId for API compatibility
148
+ * - Transport layer manages SSE streaming and message processing
149
+ * - Event bus broadcasts updates to connected SSE clients
150
+ *
151
+ * @param params Message send parameters (same as message/send)
152
+ * @returns Task ID for streaming (transport layer handles actual SSE stream and message processing)
153
+ */
154
+ async messageStream(params) {
155
+ if (!params?.message) {
156
+ throw new Error("message is required");
157
+ }
158
+ const { message } = params;
159
+ const taskId = message.taskId;
160
+ const session = await this.agent.createSession(taskId);
161
+ return { taskId: session.id };
162
+ }
163
+ /**
164
+ * Get all method handlers as a Record for JsonRpcServer
165
+ *
166
+ * Returns methods with A2A-compliant names (slash notation).
167
+ *
168
+ * @returns Map of method names to handlers
169
+ */
170
+ getMethods() {
171
+ return {
172
+ "message/send": this.messageSend.bind(this),
173
+ "message/stream": this.messageStream.bind(this),
174
+ "tasks/get": this.tasksGet.bind(this),
175
+ "tasks/list": this.tasksList.bind(this),
176
+ "tasks/cancel": this.tasksCancel.bind(this)
177
+ };
178
+ }
179
+ }
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ A2AMethodHandlers
183
+ });
@@ -0,0 +1,110 @@
1
+ /**
2
+ * A2A Protocol JSON-RPC Method Handlers
3
+ *
4
+ * Implements A2A Protocol v0.3.0 RPC methods by calling DextoAgent.
5
+ * These are thin wrappers that translate between A2A protocol and DextoAgent API.
6
+ *
7
+ * Method names per spec:
8
+ * - message/send - Send a message to the agent
9
+ * - message/stream - Send a message with streaming response
10
+ * - tasks/get - Retrieve a specific task
11
+ * - tasks/list - List tasks with optional filtering
12
+ * - tasks/cancel - Cancel an in-progress task
13
+ */
14
+ import type { DextoAgent } from '@dexto/core';
15
+ import type { Task, Message, MessageSendParams, TaskQueryParams, ListTasksParams, ListTasksResult, TaskIdParams } from '../types.js';
16
+ /**
17
+ * A2A Method Handlers
18
+ *
19
+ * Implements all A2A Protocol JSON-RPC methods.
20
+ * Each method:
21
+ * 1. Validates params
22
+ * 2. Calls DextoAgent methods
23
+ * 3. Converts response to A2A format using TaskView
24
+ *
25
+ * Usage:
26
+ * ```typescript
27
+ * const handlers = new A2AMethodHandlers(agent);
28
+ * const server = new JsonRpcServer({
29
+ * methods: handlers.getMethods()
30
+ * });
31
+ * ```
32
+ */
33
+ export declare class A2AMethodHandlers {
34
+ private agent;
35
+ constructor(agent: DextoAgent);
36
+ /**
37
+ * message/send - Send a message to the agent
38
+ *
39
+ * This is the primary method for interacting with an agent.
40
+ * Creates a task if taskId not provided in message, or adds to existing task.
41
+ *
42
+ * @param params Message send parameters
43
+ * @returns Task or Message depending on configuration.blocking
44
+ */
45
+ messageSend(params: MessageSendParams): Promise<Task | Message>;
46
+ /**
47
+ * tasks/get - Retrieve a task by ID
48
+ *
49
+ * @param params Parameters containing task ID
50
+ * @returns Task details
51
+ * @throws Error if task not found
52
+ */
53
+ tasksGet(params: TaskQueryParams): Promise<Task>;
54
+ /**
55
+ * tasks/list - List all tasks (optional filters)
56
+ *
57
+ * Note: This implementation loads all sessions, applies filters, then paginates.
58
+ * For production with many sessions, consider filtering at the session manager level.
59
+ *
60
+ * @param params Optional filter parameters
61
+ * @returns List of tasks with pagination info
62
+ */
63
+ tasksList(params?: ListTasksParams): Promise<ListTasksResult>;
64
+ /**
65
+ * tasks/cancel - Cancel a running task
66
+ *
67
+ * @param params Parameters containing task ID
68
+ * @returns Updated task (in canceled state)
69
+ * @throws Error if task not found
70
+ */
71
+ tasksCancel(params: TaskIdParams): Promise<Task>;
72
+ /**
73
+ * message/stream - Send a message with streaming response
74
+ *
75
+ * This is a streaming variant of message/send. Instead of returning a complete Task,
76
+ * it returns a stream of TaskStatusUpdateEvent and TaskArtifactUpdateEvent as the
77
+ * agent processes the message.
78
+ *
79
+ * **ARCHITECTURE NOTE**: This method is designed as a lightweight handler that returns
80
+ * a taskId immediately. The actual message processing happens at the transport layer:
81
+ *
82
+ * - **JSON-RPC Transport** (packages/server/src/hono/routes/a2a-jsonrpc.ts:72-112):
83
+ * The route intercepts 'message/stream' requests BEFORE calling this handler,
84
+ * processes the message directly (lines 96-99), and returns an SSE stream.
85
+ * This handler is registered but never actually invoked for JSON-RPC streaming.
86
+ *
87
+ * - **REST Transport** (packages/server/src/hono/routes/a2a-tasks.ts:206-244):
88
+ * Similar pattern - route processes message and returns SSE stream directly.
89
+ *
90
+ * This design separates concerns:
91
+ * - Handler provides taskId for API compatibility
92
+ * - Transport layer manages SSE streaming and message processing
93
+ * - Event bus broadcasts updates to connected SSE clients
94
+ *
95
+ * @param params Message send parameters (same as message/send)
96
+ * @returns Task ID for streaming (transport layer handles actual SSE stream and message processing)
97
+ */
98
+ messageStream(params: MessageSendParams): Promise<{
99
+ taskId: string;
100
+ }>;
101
+ /**
102
+ * Get all method handlers as a Record for JsonRpcServer
103
+ *
104
+ * Returns methods with A2A-compliant names (slash notation).
105
+ *
106
+ * @returns Map of method names to handlers
107
+ */
108
+ getMethods(): Record<string, (params: any) => Promise<any>>;
109
+ }
110
+ //# sourceMappingURL=methods.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../../src/a2a/jsonrpc/methods.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EACR,IAAI,EACJ,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EACf,MAAM,aAAa,CAAC;AAIrB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAiB;IACd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,UAAU;IAErC;;;;;;;;OAQG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;IA2BrE;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBtD;;;;;;;;OAQG;IACG,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IA0CnE;;;;;;OAMG;IACG,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAmB3E;;;;;;OAMG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CAS9D"}