@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,192 @@
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 memory_exports = {};
20
+ __export(memory_exports, {
21
+ createMemoryRouter: () => createMemoryRouter
22
+ });
23
+ module.exports = __toCommonJS(memory_exports);
24
+ var import_zod_openapi = require("@hono/zod-openapi");
25
+ var import_core = require("@dexto/core");
26
+ var import_responses = require("../schemas/responses.js");
27
+ const MemoryIdParamSchema = import_zod_openapi.z.object({
28
+ id: import_zod_openapi.z.string().min(1, "Memory ID is required").describe("Memory unique identifier")
29
+ }).describe("Path parameters for memory endpoints");
30
+ const ListMemoriesQuerySchema = import_zod_openapi.z.object({
31
+ tags: import_zod_openapi.z.string().optional().transform((val) => val ? val.split(",").map((t) => t.trim()) : void 0).describe("Comma-separated list of tags to filter by"),
32
+ source: import_zod_openapi.z.enum(["user", "system"]).optional().describe("Filter by source (user or system)"),
33
+ pinned: import_zod_openapi.z.string().optional().transform((val) => val === "true" ? true : val === "false" ? false : void 0).describe("Filter by pinned status (true or false)"),
34
+ limit: import_zod_openapi.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).describe("Maximum number of memories to return"),
35
+ offset: import_zod_openapi.z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).describe("Number of memories to skip")
36
+ }).describe("Query parameters for listing and filtering memories");
37
+ const MemoryResponseSchema = import_zod_openapi.z.object({
38
+ ok: import_zod_openapi.z.literal(true).describe("Indicates successful response"),
39
+ memory: import_responses.MemorySchema.describe("The created or retrieved memory")
40
+ }).strict().describe("Single memory response");
41
+ const MemoriesListResponseSchema = import_zod_openapi.z.object({
42
+ ok: import_zod_openapi.z.literal(true).describe("Indicates successful response"),
43
+ memories: import_zod_openapi.z.array(import_responses.MemorySchema).describe("List of memories")
44
+ }).strict().describe("Multiple memories response");
45
+ const MemoryDeleteResponseSchema = import_zod_openapi.z.object({
46
+ ok: import_zod_openapi.z.literal(true).describe("Indicates successful response"),
47
+ message: import_zod_openapi.z.string().describe("Deletion confirmation message")
48
+ }).strict().describe("Memory deletion response");
49
+ function createMemoryRouter(getAgent) {
50
+ const app = new import_zod_openapi.OpenAPIHono();
51
+ const createMemoryRoute = (0, import_zod_openapi.createRoute)({
52
+ method: "post",
53
+ path: "/memory",
54
+ summary: "Create Memory",
55
+ description: "Creates a new memory",
56
+ tags: ["memory"],
57
+ request: {
58
+ body: {
59
+ content: {
60
+ "application/json": {
61
+ schema: import_core.CreateMemoryInputSchema
62
+ }
63
+ }
64
+ }
65
+ },
66
+ responses: {
67
+ 201: {
68
+ description: "Memory created",
69
+ content: { "application/json": { schema: MemoryResponseSchema } }
70
+ }
71
+ }
72
+ });
73
+ const listRoute = (0, import_zod_openapi.createRoute)({
74
+ method: "get",
75
+ path: "/memory",
76
+ summary: "List Memories",
77
+ description: "Retrieves a list of all memories with optional filtering",
78
+ tags: ["memory"],
79
+ request: { query: ListMemoriesQuerySchema },
80
+ responses: {
81
+ 200: {
82
+ description: "List memories",
83
+ content: { "application/json": { schema: MemoriesListResponseSchema } }
84
+ }
85
+ }
86
+ });
87
+ const getRoute = (0, import_zod_openapi.createRoute)({
88
+ method: "get",
89
+ path: "/memory/{id}",
90
+ summary: "Get Memory by ID",
91
+ description: "Retrieves a specific memory by its unique identifier",
92
+ tags: ["memory"],
93
+ request: {
94
+ params: MemoryIdParamSchema
95
+ },
96
+ responses: {
97
+ 200: {
98
+ description: "Memory details",
99
+ content: { "application/json": { schema: MemoryResponseSchema } }
100
+ }
101
+ }
102
+ });
103
+ const updateRoute = (0, import_zod_openapi.createRoute)({
104
+ method: "put",
105
+ path: "/memory/{id}",
106
+ summary: "Update Memory",
107
+ description: "Updates an existing memory. Only provided fields will be updated",
108
+ tags: ["memory"],
109
+ request: {
110
+ params: MemoryIdParamSchema,
111
+ body: {
112
+ content: {
113
+ "application/json": {
114
+ schema: import_core.UpdateMemoryInputSchema
115
+ }
116
+ }
117
+ }
118
+ },
119
+ responses: {
120
+ 200: {
121
+ description: "Memory updated",
122
+ content: { "application/json": { schema: MemoryResponseSchema } }
123
+ }
124
+ }
125
+ });
126
+ const deleteRoute = (0, import_zod_openapi.createRoute)({
127
+ method: "delete",
128
+ path: "/memory/{id}",
129
+ summary: "Delete Memory",
130
+ description: "Permanently deletes a memory. This action cannot be undone",
131
+ tags: ["memory"],
132
+ request: {
133
+ params: MemoryIdParamSchema
134
+ },
135
+ responses: {
136
+ 200: {
137
+ description: "Memory deleted",
138
+ content: { "application/json": { schema: MemoryDeleteResponseSchema } }
139
+ }
140
+ }
141
+ });
142
+ return app.openapi(createMemoryRoute, async (ctx) => {
143
+ const input = ctx.req.valid("json");
144
+ const createInput = {
145
+ content: input.content
146
+ };
147
+ if (input.tags !== void 0 && Array.isArray(input.tags)) {
148
+ createInput.tags = input.tags;
149
+ }
150
+ if (input.metadata !== void 0) {
151
+ createInput.metadata = input.metadata;
152
+ }
153
+ const agent = getAgent();
154
+ const memory = await agent.memoryManager.create(createInput);
155
+ return ctx.json({ ok: true, memory }, 201);
156
+ }).openapi(listRoute, async (ctx) => {
157
+ const query = ctx.req.valid("query");
158
+ const options = {};
159
+ if (query.tags !== void 0) options.tags = query.tags;
160
+ if (query.source !== void 0) options.source = query.source;
161
+ if (query.pinned !== void 0) options.pinned = query.pinned;
162
+ if (query.limit !== void 0) options.limit = query.limit;
163
+ if (query.offset !== void 0) options.offset = query.offset;
164
+ const agent = getAgent();
165
+ const memories = await agent.memoryManager.list(options);
166
+ return ctx.json({ ok: true, memories });
167
+ }).openapi(getRoute, async (ctx) => {
168
+ const { id } = ctx.req.valid("param");
169
+ const agent = getAgent();
170
+ const memory = await agent.memoryManager.get(id);
171
+ return ctx.json({ ok: true, memory });
172
+ }).openapi(updateRoute, async (ctx) => {
173
+ const { id } = ctx.req.valid("param");
174
+ const updatesRaw = ctx.req.valid("json");
175
+ const updates = {};
176
+ if (updatesRaw.content !== void 0) updates.content = updatesRaw.content;
177
+ if (updatesRaw.metadata !== void 0) updates.metadata = updatesRaw.metadata;
178
+ if (updatesRaw.tags !== void 0) updates.tags = updatesRaw.tags;
179
+ const agent = getAgent();
180
+ const memory = await agent.memoryManager.update(id, updates);
181
+ return ctx.json({ ok: true, memory });
182
+ }).openapi(deleteRoute, async (ctx) => {
183
+ const { id } = ctx.req.valid("param");
184
+ const agent = getAgent();
185
+ await agent.memoryManager.delete(id);
186
+ return ctx.json({ ok: true, message: "Memory deleted successfully" });
187
+ });
188
+ }
189
+ // Annotate the CommonJS export names for ESM import in node:
190
+ 0 && (module.exports = {
191
+ createMemoryRouter
192
+ });
@@ -0,0 +1,146 @@
1
+ import { OpenAPIHono, z } from '@hono/zod-openapi';
2
+ import type { DextoAgent } from '@dexto/core';
3
+ export declare function createMemoryRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
4
+ "/memory": {
5
+ $post: {
6
+ input: {
7
+ json: {
8
+ content: string;
9
+ metadata?: z.objectInputType<{
10
+ source: z.ZodOptional<z.ZodEnum<["user", "system"]>>;
11
+ pinned: z.ZodOptional<z.ZodBoolean>;
12
+ }, z.ZodTypeAny, "passthrough"> | undefined;
13
+ tags?: string[] | undefined;
14
+ };
15
+ };
16
+ output: {
17
+ ok: true;
18
+ memory: {
19
+ content: string;
20
+ id: string;
21
+ createdAt: number;
22
+ updatedAt: number;
23
+ metadata?: {
24
+ [x: string]: import("hono/utils/types").JSONValue;
25
+ source?: "system" | "user" | undefined;
26
+ pinned?: boolean | undefined;
27
+ } | undefined;
28
+ tags?: string[] | undefined | undefined;
29
+ };
30
+ };
31
+ outputFormat: "json";
32
+ status: 201;
33
+ };
34
+ };
35
+ } & {
36
+ "/memory": {
37
+ $get: {
38
+ input: {
39
+ query: {
40
+ tags?: string | undefined;
41
+ source?: "system" | "user" | undefined;
42
+ limit?: string | undefined;
43
+ offset?: string | undefined;
44
+ pinned?: string | undefined;
45
+ };
46
+ };
47
+ output: {
48
+ ok: true;
49
+ memories: {
50
+ content: string;
51
+ id: string;
52
+ createdAt: number;
53
+ updatedAt: number;
54
+ metadata?: {
55
+ [x: string]: import("hono/utils/types").JSONValue;
56
+ source?: "system" | "user" | undefined;
57
+ pinned?: boolean | undefined;
58
+ } | undefined;
59
+ tags?: string[] | undefined | undefined;
60
+ }[];
61
+ };
62
+ outputFormat: "json";
63
+ status: 200;
64
+ };
65
+ };
66
+ } & {
67
+ "/memory/:id": {
68
+ $get: {
69
+ input: {
70
+ param: {
71
+ id: string;
72
+ };
73
+ };
74
+ output: {
75
+ ok: true;
76
+ memory: {
77
+ content: string;
78
+ id: string;
79
+ createdAt: number;
80
+ updatedAt: number;
81
+ metadata?: {
82
+ [x: string]: import("hono/utils/types").JSONValue;
83
+ source?: "system" | "user" | undefined;
84
+ pinned?: boolean | undefined;
85
+ } | undefined;
86
+ tags?: string[] | undefined | undefined;
87
+ };
88
+ };
89
+ outputFormat: "json";
90
+ status: 200;
91
+ };
92
+ };
93
+ } & {
94
+ "/memory/:id": {
95
+ $put: {
96
+ input: {
97
+ param: {
98
+ id: string;
99
+ };
100
+ } & {
101
+ json: {
102
+ metadata?: z.objectInputType<{
103
+ source: z.ZodOptional<z.ZodEnum<["user", "system"]>>;
104
+ pinned: z.ZodOptional<z.ZodBoolean>;
105
+ }, z.ZodTypeAny, "passthrough"> | undefined;
106
+ content?: string | undefined;
107
+ tags?: string[] | undefined;
108
+ };
109
+ };
110
+ output: {
111
+ ok: true;
112
+ memory: {
113
+ content: string;
114
+ id: string;
115
+ createdAt: number;
116
+ updatedAt: number;
117
+ metadata?: {
118
+ [x: string]: import("hono/utils/types").JSONValue;
119
+ source?: "system" | "user" | undefined;
120
+ pinned?: boolean | undefined;
121
+ } | undefined;
122
+ tags?: string[] | undefined | undefined;
123
+ };
124
+ };
125
+ outputFormat: "json";
126
+ status: 200;
127
+ };
128
+ };
129
+ } & {
130
+ "/memory/:id": {
131
+ $delete: {
132
+ input: {
133
+ param: {
134
+ id: string;
135
+ };
136
+ };
137
+ output: {
138
+ message: string;
139
+ ok: true;
140
+ };
141
+ outputFormat: "json";
142
+ status: 200;
143
+ };
144
+ };
145
+ }, "/">;
146
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6D9C,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwK5D"}
@@ -0,0 +1,168 @@
1
+ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
+ import { CreateMemoryInputSchema, UpdateMemoryInputSchema } from "@dexto/core";
3
+ import { MemorySchema } from "../schemas/responses.js";
4
+ const MemoryIdParamSchema = z.object({
5
+ id: z.string().min(1, "Memory ID is required").describe("Memory unique identifier")
6
+ }).describe("Path parameters for memory endpoints");
7
+ const ListMemoriesQuerySchema = z.object({
8
+ tags: z.string().optional().transform((val) => val ? val.split(",").map((t) => t.trim()) : void 0).describe("Comma-separated list of tags to filter by"),
9
+ source: z.enum(["user", "system"]).optional().describe("Filter by source (user or system)"),
10
+ pinned: z.string().optional().transform((val) => val === "true" ? true : val === "false" ? false : void 0).describe("Filter by pinned status (true or false)"),
11
+ limit: z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).describe("Maximum number of memories to return"),
12
+ offset: z.string().optional().transform((val) => val ? parseInt(val, 10) : void 0).describe("Number of memories to skip")
13
+ }).describe("Query parameters for listing and filtering memories");
14
+ const MemoryResponseSchema = z.object({
15
+ ok: z.literal(true).describe("Indicates successful response"),
16
+ memory: MemorySchema.describe("The created or retrieved memory")
17
+ }).strict().describe("Single memory response");
18
+ const MemoriesListResponseSchema = z.object({
19
+ ok: z.literal(true).describe("Indicates successful response"),
20
+ memories: z.array(MemorySchema).describe("List of memories")
21
+ }).strict().describe("Multiple memories response");
22
+ const MemoryDeleteResponseSchema = z.object({
23
+ ok: z.literal(true).describe("Indicates successful response"),
24
+ message: z.string().describe("Deletion confirmation message")
25
+ }).strict().describe("Memory deletion response");
26
+ function createMemoryRouter(getAgent) {
27
+ const app = new OpenAPIHono();
28
+ const createMemoryRoute = createRoute({
29
+ method: "post",
30
+ path: "/memory",
31
+ summary: "Create Memory",
32
+ description: "Creates a new memory",
33
+ tags: ["memory"],
34
+ request: {
35
+ body: {
36
+ content: {
37
+ "application/json": {
38
+ schema: CreateMemoryInputSchema
39
+ }
40
+ }
41
+ }
42
+ },
43
+ responses: {
44
+ 201: {
45
+ description: "Memory created",
46
+ content: { "application/json": { schema: MemoryResponseSchema } }
47
+ }
48
+ }
49
+ });
50
+ const listRoute = createRoute({
51
+ method: "get",
52
+ path: "/memory",
53
+ summary: "List Memories",
54
+ description: "Retrieves a list of all memories with optional filtering",
55
+ tags: ["memory"],
56
+ request: { query: ListMemoriesQuerySchema },
57
+ responses: {
58
+ 200: {
59
+ description: "List memories",
60
+ content: { "application/json": { schema: MemoriesListResponseSchema } }
61
+ }
62
+ }
63
+ });
64
+ const getRoute = createRoute({
65
+ method: "get",
66
+ path: "/memory/{id}",
67
+ summary: "Get Memory by ID",
68
+ description: "Retrieves a specific memory by its unique identifier",
69
+ tags: ["memory"],
70
+ request: {
71
+ params: MemoryIdParamSchema
72
+ },
73
+ responses: {
74
+ 200: {
75
+ description: "Memory details",
76
+ content: { "application/json": { schema: MemoryResponseSchema } }
77
+ }
78
+ }
79
+ });
80
+ const updateRoute = createRoute({
81
+ method: "put",
82
+ path: "/memory/{id}",
83
+ summary: "Update Memory",
84
+ description: "Updates an existing memory. Only provided fields will be updated",
85
+ tags: ["memory"],
86
+ request: {
87
+ params: MemoryIdParamSchema,
88
+ body: {
89
+ content: {
90
+ "application/json": {
91
+ schema: UpdateMemoryInputSchema
92
+ }
93
+ }
94
+ }
95
+ },
96
+ responses: {
97
+ 200: {
98
+ description: "Memory updated",
99
+ content: { "application/json": { schema: MemoryResponseSchema } }
100
+ }
101
+ }
102
+ });
103
+ const deleteRoute = createRoute({
104
+ method: "delete",
105
+ path: "/memory/{id}",
106
+ summary: "Delete Memory",
107
+ description: "Permanently deletes a memory. This action cannot be undone",
108
+ tags: ["memory"],
109
+ request: {
110
+ params: MemoryIdParamSchema
111
+ },
112
+ responses: {
113
+ 200: {
114
+ description: "Memory deleted",
115
+ content: { "application/json": { schema: MemoryDeleteResponseSchema } }
116
+ }
117
+ }
118
+ });
119
+ return app.openapi(createMemoryRoute, async (ctx) => {
120
+ const input = ctx.req.valid("json");
121
+ const createInput = {
122
+ content: input.content
123
+ };
124
+ if (input.tags !== void 0 && Array.isArray(input.tags)) {
125
+ createInput.tags = input.tags;
126
+ }
127
+ if (input.metadata !== void 0) {
128
+ createInput.metadata = input.metadata;
129
+ }
130
+ const agent = getAgent();
131
+ const memory = await agent.memoryManager.create(createInput);
132
+ return ctx.json({ ok: true, memory }, 201);
133
+ }).openapi(listRoute, async (ctx) => {
134
+ const query = ctx.req.valid("query");
135
+ const options = {};
136
+ if (query.tags !== void 0) options.tags = query.tags;
137
+ if (query.source !== void 0) options.source = query.source;
138
+ if (query.pinned !== void 0) options.pinned = query.pinned;
139
+ if (query.limit !== void 0) options.limit = query.limit;
140
+ if (query.offset !== void 0) options.offset = query.offset;
141
+ const agent = getAgent();
142
+ const memories = await agent.memoryManager.list(options);
143
+ return ctx.json({ ok: true, memories });
144
+ }).openapi(getRoute, async (ctx) => {
145
+ const { id } = ctx.req.valid("param");
146
+ const agent = getAgent();
147
+ const memory = await agent.memoryManager.get(id);
148
+ return ctx.json({ ok: true, memory });
149
+ }).openapi(updateRoute, async (ctx) => {
150
+ const { id } = ctx.req.valid("param");
151
+ const updatesRaw = ctx.req.valid("json");
152
+ const updates = {};
153
+ if (updatesRaw.content !== void 0) updates.content = updatesRaw.content;
154
+ if (updatesRaw.metadata !== void 0) updates.metadata = updatesRaw.metadata;
155
+ if (updatesRaw.tags !== void 0) updates.tags = updatesRaw.tags;
156
+ const agent = getAgent();
157
+ const memory = await agent.memoryManager.update(id, updates);
158
+ return ctx.json({ ok: true, memory });
159
+ }).openapi(deleteRoute, async (ctx) => {
160
+ const { id } = ctx.req.valid("param");
161
+ const agent = getAgent();
162
+ await agent.memoryManager.delete(id);
163
+ return ctx.json({ ok: true, message: "Memory deleted successfully" });
164
+ });
165
+ }
166
+ export {
167
+ createMemoryRouter
168
+ };