kernl 0.7.3 → 0.8.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 (72) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +24 -0
  3. package/dist/agent/__tests__/systools.test.js +13 -9
  4. package/dist/agent/types.d.ts +20 -12
  5. package/dist/agent/types.d.ts.map +1 -1
  6. package/dist/agent.d.ts +12 -8
  7. package/dist/agent.d.ts.map +1 -1
  8. package/dist/agent.js +14 -14
  9. package/dist/api/resources/agents/agents.d.ts +5 -5
  10. package/dist/api/resources/agents/agents.d.ts.map +1 -1
  11. package/dist/api/resources/agents/agents.js +1 -1
  12. package/dist/guardrail.d.ts +19 -19
  13. package/dist/guardrail.d.ts.map +1 -1
  14. package/dist/kernl/kernl.d.ts +6 -6
  15. package/dist/kernl/kernl.d.ts.map +1 -1
  16. package/dist/lib/error.d.ts +3 -3
  17. package/dist/lib/error.d.ts.map +1 -1
  18. package/dist/lifecycle.d.ts +6 -6
  19. package/dist/lifecycle.d.ts.map +1 -1
  20. package/dist/memory/__tests__/encoder.test.d.ts +2 -0
  21. package/dist/memory/__tests__/encoder.test.d.ts.map +1 -0
  22. package/dist/memory/__tests__/encoder.test.js +120 -0
  23. package/dist/memory/codecs/domain.d.ts +5 -0
  24. package/dist/memory/codecs/domain.d.ts.map +1 -1
  25. package/dist/memory/codecs/domain.js +6 -0
  26. package/dist/memory/encoder.d.ts +25 -2
  27. package/dist/memory/encoder.d.ts.map +1 -1
  28. package/dist/memory/encoder.js +46 -5
  29. package/dist/memory/index.d.ts +2 -2
  30. package/dist/memory/index.d.ts.map +1 -1
  31. package/dist/memory/index.js +1 -1
  32. package/dist/memory/schema.d.ts.map +1 -1
  33. package/dist/memory/schema.js +5 -0
  34. package/dist/memory/types.d.ts +21 -4
  35. package/dist/memory/types.d.ts.map +1 -1
  36. package/dist/storage/in-memory.d.ts.map +1 -1
  37. package/dist/storage/in-memory.js +4 -2
  38. package/dist/thread/__tests__/integration.test.js +1 -1
  39. package/dist/thread/__tests__/thread.test.js +8 -8
  40. package/dist/thread/thread.d.ts +5 -5
  41. package/dist/thread/thread.d.ts.map +1 -1
  42. package/dist/thread/thread.js +13 -2
  43. package/dist/thread/types.d.ts +9 -6
  44. package/dist/thread/types.d.ts.map +1 -1
  45. package/dist/thread/utils.d.ts +7 -6
  46. package/dist/thread/utils.d.ts.map +1 -1
  47. package/dist/thread/utils.js +9 -8
  48. package/dist/tool/sys/memory.d.ts +1 -1
  49. package/dist/tool/sys/memory.d.ts.map +1 -1
  50. package/dist/tool/sys/memory.js +29 -8
  51. package/package.json +4 -3
  52. package/src/agent/__tests__/systools.test.ts +13 -9
  53. package/src/agent/types.ts +25 -29
  54. package/src/agent.ts +29 -28
  55. package/src/api/resources/agents/agents.ts +8 -8
  56. package/src/guardrail.ts +28 -28
  57. package/src/kernl/kernl.ts +12 -12
  58. package/src/lib/error.ts +3 -3
  59. package/src/lifecycle.ts +6 -6
  60. package/src/memory/__tests__/encoder.test.ts +153 -0
  61. package/src/memory/codecs/domain.ts +6 -0
  62. package/src/memory/encoder.ts +51 -6
  63. package/src/memory/index.ts +2 -1
  64. package/src/memory/schema.ts +5 -0
  65. package/src/memory/types.ts +20 -4
  66. package/src/storage/in-memory.ts +6 -2
  67. package/src/thread/__tests__/integration.test.ts +130 -146
  68. package/src/thread/__tests__/thread.test.ts +8 -8
  69. package/src/thread/thread.ts +21 -7
  70. package/src/thread/types.ts +9 -6
  71. package/src/thread/utils.ts +15 -14
  72. package/src/tool/sys/memory.ts +33 -9
@@ -11,13 +11,11 @@ import { z } from "zod";
11
11
  import { tool } from "../tool";
12
12
  import { Toolkit } from "../toolkit";
13
13
 
14
- // --- Tools ---
15
-
16
14
  /**
17
15
  * Search memories for relevant information using natural language.
18
16
  */
19
17
  const search = tool({
20
- id: "memories.search",
18
+ id: "search_memories",
21
19
  description:
22
20
  "Search your memories. " +
23
21
  "Use this to recall facts, preferences, or context you've previously stored.",
@@ -50,7 +48,7 @@ const search = tool({
50
48
  * Store a new memory to persist across conversations.
51
49
  */
52
50
  const create = tool({
53
- id: "memories.create",
51
+ id: "create_memory",
54
52
  description:
55
53
  "Store a new memory. Use this to remember important facts, user preferences, " +
56
54
  "or context that should persist across conversations.",
@@ -59,13 +57,13 @@ const create = tool({
59
57
  collection: z
60
58
  .string()
61
59
  .optional()
62
- .describe("Category for organizing memories (default: 'facts')"),
60
+ .describe("Category for organizing memories"),
63
61
  }),
64
62
  execute: async (ctx, { content, collection }) => {
65
63
  assert(ctx.agent, "ctx.agent required for memory tools");
66
64
 
67
65
  const mem = await ctx.agent.memories.create({
68
- collection: collection ?? "facts",
66
+ collection,
69
67
  content: { text: content },
70
68
  });
71
69
 
@@ -73,11 +71,37 @@ const create = tool({
73
71
  },
74
72
  });
75
73
 
74
+ /**
75
+ * Update an existing memory.
76
+ */
77
+ const update = tool({
78
+ id: "update_memory",
79
+ description:
80
+ "Update an existing memory. Use this to correct or modify previously " +
81
+ "stored facts or preferences.",
82
+ parameters: z.object({
83
+ id: z.string().describe("ID of the memory to update"),
84
+ content: z.string().optional().describe("New text content"),
85
+ collection: z.string().optional().describe("New collection category"),
86
+ }),
87
+ execute: async (ctx, { id, content, collection }) => {
88
+ assert(ctx.agent, "ctx.agent required for memory tools");
89
+
90
+ const mem = await ctx.agent.memories.update({
91
+ id,
92
+ content: content ? { text: content } : undefined,
93
+ collection,
94
+ });
95
+
96
+ return { id: mem.id, updated: true };
97
+ },
98
+ });
99
+
76
100
  /**
77
101
  * List stored memories, optionally filtered by collection.
78
102
  */
79
103
  const list = tool({
80
- id: "memories.list",
104
+ id: "list_memories",
81
105
  description:
82
106
  "List your stored memories. Use this to see what you've remembered, " +
83
107
  "optionally filtered by collection.",
@@ -111,10 +135,10 @@ const list = tool({
111
135
  /**
112
136
  * Memory system toolkit.
113
137
  *
114
- * Provides memories.search, memories.create, and memories.list tools.
138
+ * Provides list_memories, create_memory, update_memory, and search_memories tools.
115
139
  */
116
140
  export const memory = new Toolkit({
117
141
  id: "sys.memory",
118
142
  description: "Tools for storing and retrieving agent memories",
119
- tools: [list, create, search],
143
+ tools: [list, create, update, search],
120
144
  });