kernl 0.6.2 → 0.7.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 (193) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-check-types.log +1 -1
  3. package/CHANGELOG.md +44 -0
  4. package/dist/agent/__tests__/concurrency.test.js +1 -1
  5. package/dist/agent/__tests__/run.test.js +1 -1
  6. package/dist/agent/__tests__/systools.test.d.ts +2 -0
  7. package/dist/agent/__tests__/systools.test.d.ts.map +1 -0
  8. package/dist/agent/__tests__/systools.test.js +121 -0
  9. package/dist/{types/agent.d.ts → agent/types.d.ts} +19 -2
  10. package/dist/agent/types.d.ts.map +1 -0
  11. package/dist/agent.d.ts +48 -6
  12. package/dist/agent.d.ts.map +1 -1
  13. package/dist/agent.js +100 -13
  14. package/dist/api/models/thread.d.ts +1 -1
  15. package/dist/api/resources/agents/agents.d.ts +38 -0
  16. package/dist/api/resources/agents/agents.d.ts.map +1 -0
  17. package/dist/api/resources/agents/agents.js +44 -0
  18. package/dist/api/resources/agents/index.d.ts +2 -0
  19. package/dist/api/resources/agents/index.d.ts.map +1 -0
  20. package/dist/api/resources/agents/index.js +1 -0
  21. package/dist/api/resources/threads/threads.d.ts +1 -1
  22. package/dist/api/resources/threads/threads.d.ts.map +1 -1
  23. package/dist/api/resources/threads/threads.js +1 -1
  24. package/dist/api/resources/threads/types.d.ts +2 -2
  25. package/dist/api/resources/threads/types.d.ts.map +1 -1
  26. package/dist/context.d.ts +10 -4
  27. package/dist/context.d.ts.map +1 -1
  28. package/dist/context.js +5 -0
  29. package/dist/guardrail.d.ts +2 -2
  30. package/dist/index.d.ts +5 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -3
  33. package/dist/internal.d.ts +2 -2
  34. package/dist/internal.js +1 -1
  35. package/dist/kernl/index.d.ts +1 -1
  36. package/dist/kernl/index.d.ts.map +1 -1
  37. package/dist/kernl/index.js +0 -1
  38. package/dist/kernl/kernl.d.ts +11 -20
  39. package/dist/kernl/kernl.d.ts.map +1 -1
  40. package/dist/kernl/kernl.js +37 -34
  41. package/dist/kernl/types.d.ts +91 -0
  42. package/dist/kernl/types.d.ts.map +1 -0
  43. package/dist/lib/error.d.ts +2 -2
  44. package/dist/lifecycle.d.ts +2 -2
  45. package/dist/memory/codec.d.ts +32 -0
  46. package/dist/memory/codec.d.ts.map +1 -0
  47. package/dist/memory/codec.js +97 -0
  48. package/dist/memory/codecs/domain.d.ts +34 -0
  49. package/dist/memory/codecs/domain.d.ts.map +1 -0
  50. package/dist/memory/codecs/domain.js +99 -0
  51. package/dist/memory/codecs/identity.d.ts +12 -0
  52. package/dist/memory/codecs/identity.d.ts.map +1 -0
  53. package/dist/memory/codecs/identity.js +17 -0
  54. package/dist/memory/codecs/index.d.ts +31 -0
  55. package/dist/memory/codecs/index.d.ts.map +1 -0
  56. package/dist/memory/codecs/index.js +39 -0
  57. package/dist/memory/codecs/tpuf.d.ts +38 -0
  58. package/dist/memory/codecs/tpuf.d.ts.map +1 -0
  59. package/dist/memory/codecs/tpuf.js +90 -0
  60. package/dist/memory/encoder.d.ts +29 -0
  61. package/dist/memory/encoder.d.ts.map +1 -0
  62. package/dist/memory/encoder.js +45 -0
  63. package/dist/memory/handle.d.ts +89 -0
  64. package/dist/memory/handle.d.ts.map +1 -0
  65. package/dist/memory/handle.js +128 -0
  66. package/dist/memory/index.d.ts +12 -0
  67. package/dist/memory/index.d.ts.map +1 -0
  68. package/dist/memory/index.js +7 -0
  69. package/dist/memory/indexes.d.ts +91 -0
  70. package/dist/memory/indexes.d.ts.map +1 -0
  71. package/dist/memory/indexes.js +7 -0
  72. package/dist/memory/memory.d.ts +55 -0
  73. package/dist/memory/memory.d.ts.map +1 -0
  74. package/dist/memory/memory.js +113 -0
  75. package/dist/memory/schema.d.ts +41 -0
  76. package/dist/memory/schema.d.ts.map +1 -0
  77. package/dist/memory/schema.js +112 -0
  78. package/dist/memory/store.d.ts +36 -0
  79. package/dist/memory/store.d.ts.map +1 -0
  80. package/dist/memory/store.js +4 -0
  81. package/dist/memory/types.d.ts +250 -0
  82. package/dist/memory/types.d.ts.map +1 -0
  83. package/dist/memory/types.js +4 -0
  84. package/dist/storage/base.d.ts +6 -1
  85. package/dist/storage/base.d.ts.map +1 -1
  86. package/dist/storage/in-memory.d.ts +24 -2
  87. package/dist/storage/in-memory.d.ts.map +1 -1
  88. package/dist/storage/in-memory.js +131 -0
  89. package/dist/storage/thread.d.ts +1 -1
  90. package/dist/thread/__tests__/integration.test.js +1 -1
  91. package/dist/thread/__tests__/mock.d.ts +1 -1
  92. package/dist/thread/__tests__/namespace.test.js +1 -1
  93. package/dist/thread/__tests__/thread.test.js +1 -1
  94. package/dist/thread/thread.d.ts +2 -2
  95. package/dist/thread/thread.d.ts.map +1 -1
  96. package/dist/thread/thread.js +3 -1
  97. package/dist/{types/thread.d.ts → thread/types.d.ts} +2 -2
  98. package/dist/thread/types.d.ts.map +1 -0
  99. package/dist/thread/utils.d.ts +2 -2
  100. package/dist/thread/utils.d.ts.map +1 -1
  101. package/dist/tool/index.d.ts +1 -0
  102. package/dist/tool/index.d.ts.map +1 -1
  103. package/dist/tool/index.js +2 -0
  104. package/dist/tool/sys/index.d.ts +7 -0
  105. package/dist/tool/sys/index.d.ts.map +1 -0
  106. package/dist/tool/sys/index.js +6 -0
  107. package/dist/tool/sys/memory.d.ts +14 -0
  108. package/dist/tool/sys/memory.d.ts.map +1 -0
  109. package/dist/tool/sys/memory.js +103 -0
  110. package/dist/tool/tool.d.ts +1 -1
  111. package/dist/tool/tool.d.ts.map +1 -1
  112. package/dist/tool/tool.js +2 -2
  113. package/package.json +4 -2
  114. package/src/agent/__tests__/systools.test.ts +146 -0
  115. package/src/{types/agent.ts → agent/types.ts} +22 -1
  116. package/src/agent.ts +144 -36
  117. package/src/api/__tests__/threads.test.ts +2 -2
  118. package/src/api/models/thread.ts +1 -1
  119. package/src/api/resources/agents/agents.ts +56 -0
  120. package/src/api/resources/agents/index.ts +1 -0
  121. package/src/api/resources/threads/events.ts +1 -1
  122. package/src/api/resources/threads/threads.ts +2 -2
  123. package/src/api/resources/threads/types.ts +2 -2
  124. package/src/context.ts +14 -136
  125. package/src/guardrail.ts +2 -2
  126. package/src/index.ts +35 -6
  127. package/src/internal.ts +2 -2
  128. package/src/kernl/index.ts +8 -0
  129. package/src/{kernl.ts → kernl/kernl.ts} +50 -10
  130. package/src/kernl/types.ts +106 -0
  131. package/src/lib/error.ts +2 -2
  132. package/src/lifecycle.ts +2 -2
  133. package/src/memory/codecs/domain.ts +115 -0
  134. package/src/memory/codecs/identity.ts +28 -0
  135. package/src/memory/codecs/index.ts +61 -0
  136. package/src/memory/codecs/tpuf.ts +115 -0
  137. package/src/memory/encoder.ts +56 -0
  138. package/src/memory/handle.ts +189 -0
  139. package/src/memory/index.ts +49 -0
  140. package/src/memory/indexes.ts +108 -0
  141. package/src/memory/memory.ts +151 -0
  142. package/src/memory/schema.ts +142 -0
  143. package/src/memory/store.ts +47 -0
  144. package/src/memory/types.ts +282 -0
  145. package/src/storage/__tests__/in-memory.test.ts +1 -1
  146. package/src/storage/base.ts +7 -1
  147. package/src/storage/in-memory.ts +170 -2
  148. package/src/storage/thread.ts +1 -1
  149. package/src/thread/__tests__/integration.test.ts +1 -1
  150. package/src/thread/__tests__/mock.ts +1 -1
  151. package/src/thread/__tests__/thread.test.ts +1 -1
  152. package/src/thread/thread.ts +5 -3
  153. package/src/{types/thread.ts → thread/types.ts} +1 -1
  154. package/src/thread/utils.ts +2 -2
  155. package/src/tool/index.ts +3 -0
  156. package/src/tool/sys/index.ts +7 -0
  157. package/src/tool/sys/memory.ts +120 -0
  158. package/src/tool/tool.ts +8 -4
  159. package/tsconfig.tsbuildinfo +1 -0
  160. package/dist/api/__tests__/cursor-page.test.d.ts +0 -2
  161. package/dist/api/__tests__/cursor-page.test.d.ts.map +0 -1
  162. package/dist/api/__tests__/cursor-page.test.js +0 -414
  163. package/dist/api/__tests__/offset-page.test.d.ts +0 -2
  164. package/dist/api/__tests__/offset-page.test.d.ts.map +0 -1
  165. package/dist/api/__tests__/offset-page.test.js +0 -510
  166. package/dist/api/pagination/base.d.ts +0 -48
  167. package/dist/api/pagination/base.d.ts.map +0 -1
  168. package/dist/api/pagination/base.js +0 -45
  169. package/dist/api/pagination/cursor.d.ts +0 -44
  170. package/dist/api/pagination/cursor.d.ts.map +0 -1
  171. package/dist/api/pagination/cursor.js +0 -52
  172. package/dist/api/pagination/offset.d.ts +0 -42
  173. package/dist/api/pagination/offset.d.ts.map +0 -1
  174. package/dist/api/pagination/offset.js +0 -55
  175. package/dist/kernl/threads.d.ts +0 -110
  176. package/dist/kernl/threads.d.ts.map +0 -1
  177. package/dist/kernl/threads.js +0 -126
  178. package/dist/kernl.d.ts +0 -51
  179. package/dist/kernl.d.ts.map +0 -1
  180. package/dist/kernl.js +0 -91
  181. package/dist/types/agent.d.ts.map +0 -1
  182. package/dist/types/kernl.d.ts +0 -42
  183. package/dist/types/kernl.d.ts.map +0 -1
  184. package/dist/types/thread.d.ts.map +0 -1
  185. package/src/api/__tests__/cursor-page.test.ts +0 -512
  186. package/src/api/__tests__/offset-page.test.ts +0 -624
  187. package/src/api/pagination/base.ts +0 -79
  188. package/src/api/pagination/cursor.ts +0 -86
  189. package/src/api/pagination/offset.ts +0 -89
  190. package/src/types/kernl.ts +0 -51
  191. /package/dist/{types/agent.js → agent/types.js} +0 -0
  192. /package/dist/{types/kernl.js → kernl/types.js} +0 -0
  193. /package/dist/{types/thread.js → thread/types.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { ThreadStore } from "../../../storage/index.js";
2
2
  import type { MThread, MThreadEvent } from "../../../api/models/index.js";
3
- import { CursorPage } from "../../../api/pagination/cursor.js";
3
+ import { CursorPage } from "@kernl-sdk/shared";
4
4
  import { RThreadEvents } from "./events.js";
5
5
  import type { RThreadCreateParams, RThreadGetOptions, RThreadHistoryParams, RThreadsListParams, RThreadUpdateParams } from "./types.js";
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../../src/api/resources/threads/threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAA2B,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB;;;;GAIG;AACH,qBAAa,QAAQ;IAGP,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;gBAEF,KAAK,EAAE,WAAW;IAI/C;;;;;OAKG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAgB5E;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAqC3D;;;;;;;;;;;OAWG;IACG,IAAI,CACR,MAAM,GAAE,kBAAuB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAkDnD;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC;;;;OAIG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,YAAY,EAAE,CAAC;IAY1B;;;;;OAKG;IACG,MAAM,CACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,O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AAG,IAAI,CAAC;CAyD3B"}
@@ -2,7 +2,7 @@ import { isPublicEvent } from "../../../thread/utils.js";
2
2
  import { Context } from "../../../context.js";
3
3
  import { randomID } from "@kernl-sdk/shared/lib";
4
4
  import { RUNNING } from "@kernl-sdk/protocol";
5
- import { CursorPage } from "../../../api/pagination/cursor.js";
5
+ import { CursorPage } from "@kernl-sdk/shared";
6
6
  import { RThreadEvents } from "./events.js";
7
7
  import { MThreadCodec, ThreadsFilterCodec, ThreadsOrderCodec } from "./utils.js";
8
8
  /**
@@ -1,6 +1,6 @@
1
- import type { ThreadState } from "../../../types/thread.js";
1
+ import type { ThreadState } from "../../../thread/types.js";
2
2
  import type { SortOrder } from "../../../storage/index.js";
3
- import type { CursorPageParams } from "../../../api/pagination/cursor.js";
3
+ import type { CursorPageParams } from "@kernl-sdk/shared";
4
4
  export interface RThreadHistoryParams {
5
5
  /**
6
6
  * Only return events with seq greater than this value.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/api/resources/threads/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,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AAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
package/dist/context.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import type { Agent } from "./agent.js";
1
2
  /**
2
- * Status of a tool call approval.
3
+ * Context that is being passed around as part of the session is unknown
3
4
  */
4
- export type ApprovalStatus = "approved" | "rejected" | "pending";
5
+ export type UnknownContext = unknown;
5
6
  /**
6
7
  * A propagation mechanism which carries execution-scoped values across API boundaries and between logically associated
7
8
  * execution units.
@@ -15,6 +16,11 @@ export declare class Context<TContext = UnknownContext> {
15
16
  * The inner context object.
16
17
  */
17
18
  context: TContext;
19
+ /**
20
+ * The agent executing this context.
21
+ * Set by the thread during execution.
22
+ */
23
+ agent?: Agent<TContext, any>;
18
24
  /**
19
25
  * Map of tool call IDs to their approval status.
20
26
  * (TEMPORARY) Used until the actions system is refined.
@@ -68,7 +74,7 @@ export declare class Context<TContext = UnknownContext> {
68
74
  };
69
75
  }
70
76
  /**
71
- * Context that is being passed around as part of the session is unknown
77
+ * Status of a tool call approval.
72
78
  */
73
- export type UnknownContext = unknown;
79
+ export type ApprovalStatus = "approved" | "rejected" | "pending";
74
80
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjE;;;GAGG;AACH,qBAAa,OAAO,CAAC,QAAQ,GAAG,cAAc;IAC5C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;IAMlB;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEvC;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7B;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;gBAyB1B,SAAS,GAAE,MAAgB,EAC3B,OAAO,GAAE,QAAyB;IAUpC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM;IAevC;;;;;;;;;;;;;;OAcG;IACH,EAAE,IAAI,MAAM;IAIZ;;;;;;;;;;OAUG;IACH,IAAI,IAAI,MAAM;IAId,MAAM,IAAI;QACR,OAAO,EAAE,GAAG,CAAC;KAGd;CAsIF;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;AAErC;;;GAGG;AACH,qBAAa,OAAO,CAAC,QAAQ,GAAG,cAAc;IAC5C;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAM7B;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEvC;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7B;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;gBAwBhB,SAAS,GAAE,MAAgB,EAAE,OAAO,GAAE,QAAyB;IAS3E;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM;IAevC;;;;;;;;;;;;;;OAcG;IACH,EAAE,IAAI,MAAM;IAIZ;;;;;;;;;;OAUG;IACH,IAAI,IAAI,MAAM;IAId,MAAM,IAAI;QACR,OAAO,EAAE,GAAG,CAAC;KAGd;CAOF;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC"}
package/dist/context.js CHANGED
@@ -11,6 +11,11 @@ export class Context {
11
11
  * The inner context object.
12
12
  */
13
13
  context;
14
+ /**
15
+ * The agent executing this context.
16
+ * Set by the thread during execution.
17
+ */
18
+ agent;
14
19
  // ----------------------
15
20
  // TEMPORARY: Tool approval tracking until actions system is refined
16
21
  // ----------------------
@@ -2,8 +2,8 @@ import { z, type ZodType } from "zod";
2
2
  import { LanguageModelResponse } from "@kernl-sdk/protocol";
3
3
  import { Agent } from "./agent.js";
4
4
  import { Context, UnknownContext } from "./context.js";
5
- import type { AgentResponseType } from "./types/agent.js";
6
- import type { TextResponse, ThreadEvent } from "./types/thread.js";
5
+ import type { AgentResponseType } from "./agent/types.js";
6
+ import type { TextResponse, ThreadEvent } from "./thread/types.js";
7
7
  /**
8
8
  * Resolves the agent output type based on the response type.
9
9
  * - If TResponse is "text" → output is string
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { Kernl } from "./kernl.js";
2
- export type { KernlOptions, StorageOptions, AgentRegistry, ModelRegistry, } from "./types/kernl.js";
1
+ export { Kernl } from "./kernl/index.js";
2
+ export type { KernlOptions, StorageOptions, AgentRegistry, ModelRegistry, } from "./kernl/index.js";
3
3
  export { Agent } from "./agent.js";
4
4
  export { Context } from "./context.js";
5
5
  export { tool, Toolkit, FunctionToolkit, MCPToolkit } from "./tool/index.js";
@@ -8,6 +8,8 @@ export { MCPServerStdio } from "./mcp/stdio.js";
8
8
  export { MCPServerStreamableHttp } from "./mcp/http.js";
9
9
  export type { MThread as Thread, MThreadEvent as ThreadEvent, MThreadEventBase as ThreadEventBase, } from "./api/models/index.js";
10
10
  export type { RThreadsListParams as ThreadsListParams, RThreadGetOptions as ThreadGetOptions, RThreadHistoryParams as ThreadHistoryParams, RThreadCreateParams as ThreadCreateParams, RThreadUpdateParams as ThreadUpdateParams, } from "./api/resources/threads/index.js";
11
- export { THREAD_STATES, type ThreadState, type PublicThreadEvent, } from "./types/thread.js";
11
+ export { THREAD_STATES, type ThreadState, type PublicThreadEvent, } from "./thread/types.js";
12
12
  export type { ThreadStore, NewThread, ThreadUpdate, ThreadFilter, ThreadHistoryOptions, ThreadInclude, ThreadListOptions, SortOrder, KernlStorage, Transaction, } from "./storage/index.js";
13
+ export { Memory, MemoryByteEncoder } from "./memory/index.js";
14
+ export type { MemoryStore, MemoryScope, NewMemory, MemoryConfig, MemoryReindexParams, MemoryRecord, MemoryKind, MemoryRecordUpdate, MemoryFilter, MemoryListOptions, MemorySearchQuery, WorkingMemorySnapshot, ShortTermMemorySnapshot, MemoryIndexBase, MemorySearchIndex, MemoryGraphIndex, MemoryArchiveIndex, GraphTraversalQuery, GraphTraversalResult, ArchiveQuery, ArchiveResult, MemoryByte, MemoryByteCodec, } from "./memory/index.js";
13
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAGrD,YAAY,EACV,OAAO,IAAI,MAAM,EACjB,YAAY,IAAI,WAAW,EAC3B,gBAAgB,IAAI,eAAe,GACpC,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,kBAAkB,IAAI,iBAAiB,EACvC,iBAAiB,IAAI,gBAAgB,EACrC,oBAAoB,IAAI,mBAAmB,EAC3C,mBAAmB,IAAI,kBAAkB,EACzC,mBAAmB,IAAI,kBAAkB,GAC1C,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO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AChB,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { Kernl } from "./kernl.js";
1
+ export { Kernl } from "./kernl/index.js";
2
2
  export { Agent } from "./agent.js";
3
3
  export { Context } from "./context.js";
4
4
  // --- tools --
@@ -6,5 +6,6 @@ export { tool, Toolkit, FunctionToolkit, MCPToolkit } from "./tool/index.js";
6
6
  export { MCPServerSSE } from "./mcp/sse.js";
7
7
  export { MCPServerStdio } from "./mcp/stdio.js";
8
8
  export { MCPServerStreamableHttp } from "./mcp/http.js";
9
- // --- thread state enums ---
10
- export { THREAD_STATES, } from "./types/thread.js";
9
+ export { THREAD_STATES, } from "./thread/types.js";
10
+ // --- memory ---
11
+ export { Memory, MemoryByteEncoder } from "./memory/index.js";
@@ -1,4 +1,4 @@
1
1
  export { Thread } from "./thread/thread.js";
2
- export type { IThread, ThreadEvent, ThreadEventBase, ThreadEventInner, ThreadSystemEvent, ThreadState, PublicThreadEvent, } from "./types/thread.js";
3
- export { THREAD_STATES } from "./types/thread.js";
2
+ export type { IThread, ThreadEvent, ThreadEventBase, ThreadEventInner, ThreadSystemEvent, ThreadState, PublicThreadEvent, } from "./thread/types.js";
3
+ export { THREAD_STATES } from "./thread/types.js";
4
4
  //# sourceMappingURL=internal.d.ts.map
package/dist/internal.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Thread } from "./thread/thread.js";
2
- export { THREAD_STATES } from "./types/thread.js";
2
+ export { THREAD_STATES } from "./thread/types.js";
@@ -1,3 +1,3 @@
1
1
  export { Kernl } from "./kernl.js";
2
- export { ThreadsResource, type ThreadsListParams, type ThreadGetOptions } from "./threads.js";
2
+ export type { KernlOptions, StorageOptions, MemoryOptions, AgentRegistry, ModelRegistry, } from "./types.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kernl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC"}
@@ -1,2 +1 @@
1
1
  export { Kernl } from "./kernl.js";
2
- export { ThreadsResource } from "./threads.js";
@@ -4,10 +4,12 @@ import { KernlHooks } from "../lifecycle.js";
4
4
  import type { Thread } from "../thread/index.js";
5
5
  import type { ResolvedAgentResponse } from "../guardrail.js";
6
6
  import { type KernlStorage } from "../storage/index.js";
7
- import type { KernlOptions } from "../types/kernl.js";
8
- import type { ThreadExecuteResult, ThreadStreamEvent } from "../types/thread.js";
9
- import type { AgentResponseType } from "../types/agent.js";
10
- import { ThreadsResource } from "./threads.js";
7
+ import { RThreads } from "../api/resources/threads/index.js";
8
+ import { RAgents } from "../api/resources/agents/index.js";
9
+ import { Memory } from "../memory/index.js";
10
+ import type { ThreadExecuteResult, ThreadStreamEvent } from "../thread/types.js";
11
+ import type { AgentResponseType } from "../agent/types.js";
12
+ import type { KernlOptions } from "./types.js";
11
13
  /**
12
14
  * The kernl - manages agent processes, scheduling, and task lifecycle.
13
15
  *
@@ -15,16 +17,13 @@ import { ThreadsResource } from "./threads.js";
15
17
  * tracing.
16
18
  */
17
19
  export declare class Kernl extends KernlHooks<UnknownContext, AgentResponseType> {
18
- private agents;
19
- private models;
20
+ private readonly _agents;
21
+ private readonly _models;
20
22
  readonly storage: KernlStorage;
21
23
  athreads: Map<string, Thread<any, any>>;
22
- private initPromise;
23
- /**
24
- * Thread management API.
25
- * Provides methods to get, list, and delete threads.
26
- */
27
- readonly threads: ThreadsResource;
24
+ readonly threads: RThreads;
25
+ readonly agents: RAgents;
26
+ readonly memories: Memory;
28
27
  constructor(options?: KernlOptions);
29
28
  /**
30
29
  * Registers a new agent with the kernl instance.
@@ -52,13 +51,5 @@ export declare class Kernl extends KernlHooks<UnknownContext, AgentResponseType>
52
51
  * Schedule an existing thread - streaming execution
53
52
  */
54
53
  scheduleStream<TContext, TResponse extends AgentResponseType>(thread: Thread<TContext, TResponse>): AsyncIterable<ThreadStreamEvent>;
55
- /**
56
- * Ensure the underlying storage backend has been initialized.
57
- *
58
- * This is called lazily on first use so that callers do not need to worry
59
- * about calling storage.init() themselves. Safe and idempotent to call
60
- * multiple times; concurrent calls share the same initialization promise.
61
- */
62
- private ensureInitialized;
63
54
  }
64
55
  //# sourceMappingURL=kernl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kernl.d.ts","sourceRoot":"","sources":["../../src/kernl/kernl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;GAKG;AACH,qBAAa,KAAM,SAAQ,UAAU,CAAC,cAAc,EAAE,iBAAiB,CAAC;IACtE,OAAO,CAAC,MAAM,CAAiC;IAC/C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AClC,OAAO,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IASjE;;;;OAIG;IACG,QAAQ,CAAC,QAAQ,EAAE,SAAS,SAAS,iBAAiB,EAC1D,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAClC,OAAO,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IASjE;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,SAAS,SAAS,iBAAiB,EAC9D,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAClC,aAAa,CAAC,iBAAiB,CAAC;IASnC;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,SAAS,SAAS,iBAAiB,EACjE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAClC,aAAa,CAAC,iBAAiB,CAAC;CAQpC"}
@@ -1,6 +1,9 @@
1
+ import { resolveEmbeddingModel } from "@kernl-sdk/retrieval";
1
2
  import { KernlHooks } from "../lifecycle.js";
2
3
  import { InMemoryStorage } from "../storage/index.js";
3
- import { ThreadsResource } from "./threads.js";
4
+ import { RThreads } from "../api/resources/threads/index.js";
5
+ import { RAgents } from "../api/resources/agents/index.js";
6
+ import { Memory, MemoryByteEncoder, MemoryIndexHandle, buildMemoryIndexSchema, } from "../memory/index.js";
4
7
  /**
5
8
  * The kernl - manages agent processes, scheduling, and task lifecycle.
6
9
  *
@@ -8,41 +11,61 @@ import { ThreadsResource } from "./threads.js";
8
11
  * tracing.
9
12
  */
10
13
  export class Kernl extends KernlHooks {
11
- agents = new Map();
12
- models = new Map();
14
+ _agents = new Map();
15
+ _models = new Map();
13
16
  storage;
14
17
  athreads = new Map(); /* active threads */
15
- initPromise = null;
16
- /**
17
- * Thread management API.
18
- * Provides methods to get, list, and delete threads.
19
- */
18
+ // --- public API ---
20
19
  threads;
20
+ agents;
21
+ memories;
21
22
  constructor(options = {}) {
22
23
  super();
23
24
  this.storage = options.storage?.db ?? new InMemoryStorage();
24
- this.storage.bind({ agents: this.agents, models: this.models });
25
- this.threads = new ThreadsResource(this.storage.threads);
25
+ this.storage.bind({ agents: this._agents, models: this._models });
26
+ this.threads = new RThreads(this.storage.threads);
27
+ this.agents = new RAgents(this._agents);
28
+ // initialize memory
29
+ const embeddingModel = options.memory?.embeddingModel ?? "openai/text-embedding-3-small";
30
+ const embedder = typeof embeddingModel === "string"
31
+ ? resolveEmbeddingModel(embeddingModel)
32
+ : embeddingModel;
33
+ const encoder = new MemoryByteEncoder(embedder);
34
+ const vector = options.storage?.vector;
35
+ const indexId = options.memory?.indexId ?? "memories_sindex";
36
+ const dimensions = options.memory?.dimensions ?? 1536;
37
+ const providerOptions = options.memory?.indexProviderOptions ?? { schema: "kernl" };
38
+ this.memories = new Memory({
39
+ store: this.storage.memories,
40
+ search: vector !== undefined
41
+ ? new MemoryIndexHandle({
42
+ index: vector,
43
+ indexId,
44
+ schema: buildMemoryIndexSchema({ dimensions }),
45
+ providerOptions,
46
+ })
47
+ : undefined,
48
+ encoder,
49
+ });
26
50
  }
27
51
  /**
28
52
  * Registers a new agent with the kernl instance.
29
53
  */
30
54
  register(agent) {
31
- this.agents.set(agent.id, agent);
55
+ this._agents.set(agent.id, agent);
32
56
  agent.bind(this);
33
57
  // (TODO): implement exhaustive model registry in protocol/ package
34
58
  //
35
59
  // auto-populate model registry for storage hydration
36
60
  const key = `${agent.model.provider}/${agent.model.modelId}`;
37
- if (!this.models.has(key)) {
38
- this.models.set(key, agent.model);
61
+ if (!this._models.has(key)) {
62
+ this._models.set(key, agent.model);
39
63
  }
40
64
  }
41
65
  /**
42
66
  * Spawn a new thread - blocking execution
43
67
  */
44
68
  async spawn(thread) {
45
- await this.ensureInitialized();
46
69
  this.athreads.set(thread.tid, thread);
47
70
  try {
48
71
  return await thread.execute();
@@ -57,7 +80,6 @@ export class Kernl extends KernlHooks {
57
80
  * NOTE: just blocks for now
58
81
  */
59
82
  async schedule(thread) {
60
- await this.ensureInitialized();
61
83
  this.athreads.set(thread.tid, thread);
62
84
  try {
63
85
  return await thread.execute();
@@ -72,7 +94,6 @@ export class Kernl extends KernlHooks {
72
94
  * Spawn a new thread - streaming execution
73
95
  */
74
96
  async *spawnStream(thread) {
75
- await this.ensureInitialized();
76
97
  this.athreads.set(thread.tid, thread);
77
98
  try {
78
99
  yield* thread.stream();
@@ -87,7 +108,6 @@ export class Kernl extends KernlHooks {
87
108
  * Schedule an existing thread - streaming execution
88
109
  */
89
110
  async *scheduleStream(thread) {
90
- await this.ensureInitialized();
91
111
  this.athreads.set(thread.tid, thread);
92
112
  try {
93
113
  yield* thread.stream();
@@ -96,21 +116,4 @@ export class Kernl extends KernlHooks {
96
116
  this.athreads.delete(thread.tid);
97
117
  }
98
118
  }
99
- /**
100
- * Ensure the underlying storage backend has been initialized.
101
- *
102
- * This is called lazily on first use so that callers do not need to worry
103
- * about calling storage.init() themselves. Safe and idempotent to call
104
- * multiple times; concurrent calls share the same initialization promise.
105
- */
106
- async ensureInitialized() {
107
- if (!this.initPromise) {
108
- this.initPromise = this.storage.init().catch((error) => {
109
- // Allow a retry if initialization fails.
110
- this.initPromise = null;
111
- throw error;
112
- });
113
- }
114
- await this.initPromise;
115
- }
116
119
  }
@@ -0,0 +1,91 @@
1
+ import { LanguageModel, EmbeddingModel } from "@kernl-sdk/protocol";
2
+ import { SearchIndex } from "@kernl-sdk/retrieval";
3
+ import { Agent } from "../agent.js";
4
+ import { KernlStorage } from "../storage/index.js";
5
+ /**
6
+ * Storage configuration for Kernl.
7
+ */
8
+ export interface StorageOptions {
9
+ /**
10
+ * Relational database storage (threads, tasks, traces).
11
+ */
12
+ db?: KernlStorage;
13
+ /**
14
+ * Vector search index for semantic memory search.
15
+ * Supports pgvector, Turbopuffer, etc.
16
+ */
17
+ vector?: SearchIndex;
18
+ }
19
+ /**
20
+ * Memory system configuration.
21
+ */
22
+ export interface MemoryOptions {
23
+ /**
24
+ * Embedding model for memory encoding.
25
+ *
26
+ * Can be:
27
+ * - A string like "openai/text-embedding-3-small" (resolved via provider registry)
28
+ * - An EmbeddingModel instance
29
+ *
30
+ * @default "openai/text-embedding-3-small"
31
+ */
32
+ embeddingModel?: string | EmbeddingModel<string>;
33
+ /**
34
+ * Logical index ID used by the search backend.
35
+ * - For pgvector: becomes the table name (with schema from indexProviderOptions)
36
+ * - For Turbopuffer: becomes the namespace
37
+ * @default "kernl_memories_index"
38
+ */
39
+ indexId?: string;
40
+ /**
41
+ * Backend-specific options passed to SearchIndex.createIndex().
42
+ * - For pgvector: { schema?: string } controls schema (default: "kernl")
43
+ * - For Turbopuffer: not used
44
+ */
45
+ indexProviderOptions?: Record<string, unknown>;
46
+ /**
47
+ * Vector dimensions for embeddings.
48
+ * Only needed if embedding model doesn't provide this automatically.
49
+ * @default 1536
50
+ */
51
+ dimensions?: number;
52
+ /**
53
+ * Similarity metric for vector search.
54
+ * @default "cosine"
55
+ */
56
+ similarity?: "cosine" | "euclidean" | "dot_product";
57
+ }
58
+ /**
59
+ * Configuration options for creating a Kernl instance.
60
+ */
61
+ export interface KernlOptions {
62
+ /**
63
+ * Storage configuration for persisting threads, tasks, and traces.
64
+ */
65
+ storage?: StorageOptions;
66
+ /**
67
+ * Memory system configuration.
68
+ */
69
+ memory?: MemoryOptions;
70
+ }
71
+ /**
72
+ * Agent registry interface.
73
+ *
74
+ * Satisfied by Map<string, Agent>.
75
+ */
76
+ export interface AgentRegistry {
77
+ get(id: string): Agent<any> | undefined;
78
+ }
79
+ /**
80
+ * Model registry interface.
81
+ *
82
+ * Satisfied by Map<string, LanguageModel>.
83
+ * Key format: "provider/modelId"
84
+ *
85
+ * TODO: Create an exhaustive model registry in the protocol package
86
+ * with all supported models and their metadata.
87
+ */
88
+ export interface ModelRegistry {
89
+ get(key: string): LanguageModel | undefined;
90
+ }
91
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot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uardrailResult } from "../guardrail.js";
2
2
  type SerializedThread = any;
3
- import { AgentResponseType } from "../types/agent.js";
4
- import { TextResponse } from "../types/thread.js";
3
+ import { AgentResponseType } from "../agent/types.js";
4
+ import { TextResponse } from "../thread/types.js";
5
5
  /**
6
6
  * Abstract base class for all `kernl` errors
7
7
  * Requires subclasses to implement JSON serialization
@@ -3,8 +3,8 @@ import { Agent } from "./agent.js";
3
3
  import { Context, UnknownContext } from "./context.js";
4
4
  import { Tool } from "./tool/index.js";
5
5
  import type { ToolCall } from "@kernl-sdk/protocol";
6
- import { AgentResponseType } from "./types/agent.js";
7
- import { TextResponse } from "./types/thread.js";
6
+ import { AgentResponseType } from "./agent/types.js";
7
+ import { TextResponse } from "./thread/types.js";
8
8
  export type EventEmitterEvents = Record<string, any[]>;
9
9
  /**
10
10
  * Generic typed event emitter that wraps Node's EventEmitter with type safety
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Memory codecs.
3
+ */
4
+ import type { Codec, AsyncCodec } from "@kernl-sdk/shared/lib";
5
+ import type { Filter as SearchFilter } from "@kernl-sdk/retrieval";
6
+ import type { MemoryFilter, MemoryRecord, MemoryRecordUpdate, IndexMemoryRecord, IndexMemoryRecordPatch, MemoryByteCodec } from "./types.js";
7
+ /**
8
+ * Codec for converting MemoryFilter to retrieval Filter.
9
+ *
10
+ * - scope.namespace → namespace
11
+ * - scope.entityId → entityId
12
+ * - scope.agentId → agentId
13
+ * - collections → collection: { $in: [...] }
14
+ * - after/before → timestamp: { $gt/$lt }
15
+ *
16
+ * Content field filtering (text, metadata, kind) is not currently supported.
17
+ * Text relevance is handled via vector similarity in the query, not filters.
18
+ */
19
+ export declare const MEMORY_FILTER: Codec<MemoryFilter, SearchFilter>;
20
+ /**
21
+ * Create a codec for MemoryRecord -> IndexMemoryRecord.
22
+ */
23
+ export declare function recordCodec(bytecodec: MemoryByteCodec): AsyncCodec<MemoryRecord, IndexMemoryRecord>;
24
+ /**
25
+ * Codec for converting MemoryRecordUpdate to IndexMemoryRecordPatch.
26
+ *
27
+ * Maps patchable fields from domain update to index patch format.
28
+ * wmem/smem are store-only fields and are not included.
29
+ * content changes require full re-index, not a patch.
30
+ */
31
+ export declare const PATCH_CODEC: Codec<MemoryRecordUpdate, IndexMemoryRecordPatch>;
32
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/memory/codec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,YAAY,EAAE,YAAY,CA0B3D,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,GACzB,UAAU,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAqB7C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,CAqBzE,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Memory codecs.
3
+ */
4
+ /**
5
+ * Codec for converting MemoryFilter to retrieval Filter.
6
+ *
7
+ * - scope.namespace → namespace
8
+ * - scope.entityId → entityId
9
+ * - scope.agentId → agentId
10
+ * - collections → collection: { $in: [...] }
11
+ * - after/before → timestamp: { $gt/$lt }
12
+ *
13
+ * Content field filtering (text, metadata, kind) is not currently supported.
14
+ * Text relevance is handled via vector similarity in the query, not filters.
15
+ */
16
+ export const MEMORY_FILTER = {
17
+ encode(mf) {
18
+ const sf = {};
19
+ // scope
20
+ if (mf.scope?.namespace !== undefined)
21
+ sf.namespace = mf.scope.namespace;
22
+ if (mf.scope?.entityId !== undefined)
23
+ sf.entityId = mf.scope.entityId;
24
+ if (mf.scope?.agentId !== undefined)
25
+ sf.agentId = mf.scope.agentId;
26
+ if (mf.collections && mf.collections.length > 0) {
27
+ sf.collection = { $in: mf.collections };
28
+ }
29
+ if (mf.after !== undefined || mf.before !== undefined) {
30
+ const ts = {};
31
+ if (mf.after !== undefined)
32
+ ts.$gt = mf.after;
33
+ if (mf.before !== undefined)
34
+ ts.$lt = mf.before;
35
+ sf.timestamp = ts;
36
+ }
37
+ return sf;
38
+ },
39
+ decode(_filter) {
40
+ throw new Error("MEMORY_FILTER.decode not implemented");
41
+ },
42
+ };
43
+ /**
44
+ * Create a codec for MemoryRecord -> IndexMemoryRecord.
45
+ */
46
+ export function recordCodec(bytecodec) {
47
+ return {
48
+ async encode(record) {
49
+ const indexable = await bytecodec.encode(record.content);
50
+ return {
51
+ id: record.id,
52
+ namespace: record.scope.namespace ?? null,
53
+ entityId: record.scope.entityId ?? null,
54
+ agentId: record.scope.agentId ?? null,
55
+ kind: record.kind,
56
+ collection: record.collection,
57
+ timestamp: record.timestamp,
58
+ createdAt: record.createdAt,
59
+ updatedAt: record.updatedAt,
60
+ ...indexable,
61
+ };
62
+ },
63
+ async decode() {
64
+ throw new Error("createRecordCodec.decode not implemented");
65
+ },
66
+ };
67
+ }
68
+ /**
69
+ * Codec for converting MemoryRecordUpdate to IndexMemoryRecordPatch.
70
+ *
71
+ * Maps patchable fields from domain update to index patch format.
72
+ * wmem/smem are store-only fields and are not included.
73
+ * content changes require full re-index, not a patch.
74
+ */
75
+ export const PATCH_CODEC = {
76
+ encode(update) {
77
+ const patch = { id: update.id };
78
+ if (update.scope?.namespace !== undefined)
79
+ patch.namespace = update.scope.namespace;
80
+ if (update.scope?.entityId !== undefined)
81
+ patch.entityId = update.scope.entityId;
82
+ if (update.scope?.agentId !== undefined)
83
+ patch.agentId = update.scope.agentId;
84
+ if (update.collection !== undefined)
85
+ patch.collection = update.collection;
86
+ if (update.timestamp !== undefined)
87
+ patch.timestamp = update.timestamp;
88
+ if (update.updatedAt !== undefined)
89
+ patch.updatedAt = update.updatedAt;
90
+ if (update.metadata !== undefined)
91
+ patch.metadata = update.metadata;
92
+ return patch;
93
+ },
94
+ decode(_patch) {
95
+ throw new Error("PATCH_CODEC.decode not implemented");
96
+ },
97
+ };