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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +24 -0
- package/dist/agent/__tests__/systools.test.js +13 -9
- package/dist/agent/types.d.ts +20 -12
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent.d.ts +12 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -14
- package/dist/api/resources/agents/agents.d.ts +5 -5
- package/dist/api/resources/agents/agents.d.ts.map +1 -1
- package/dist/api/resources/agents/agents.js +1 -1
- package/dist/guardrail.d.ts +19 -19
- package/dist/guardrail.d.ts.map +1 -1
- package/dist/kernl/kernl.d.ts +6 -6
- package/dist/kernl/kernl.d.ts.map +1 -1
- package/dist/lib/error.d.ts +3 -3
- package/dist/lib/error.d.ts.map +1 -1
- package/dist/lifecycle.d.ts +6 -6
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/memory/__tests__/encoder.test.d.ts +2 -0
- package/dist/memory/__tests__/encoder.test.d.ts.map +1 -0
- package/dist/memory/__tests__/encoder.test.js +120 -0
- package/dist/memory/codecs/domain.d.ts +5 -0
- package/dist/memory/codecs/domain.d.ts.map +1 -1
- package/dist/memory/codecs/domain.js +6 -0
- package/dist/memory/encoder.d.ts +25 -2
- package/dist/memory/encoder.d.ts.map +1 -1
- package/dist/memory/encoder.js +46 -5
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/schema.d.ts.map +1 -1
- package/dist/memory/schema.js +5 -0
- package/dist/memory/types.d.ts +21 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/storage/in-memory.d.ts.map +1 -1
- package/dist/storage/in-memory.js +4 -2
- package/dist/thread/__tests__/integration.test.js +1 -1
- package/dist/thread/__tests__/thread.test.js +8 -8
- package/dist/thread/thread.d.ts +5 -5
- package/dist/thread/thread.d.ts.map +1 -1
- package/dist/thread/thread.js +13 -2
- package/dist/thread/types.d.ts +9 -6
- package/dist/thread/types.d.ts.map +1 -1
- package/dist/thread/utils.d.ts +7 -6
- package/dist/thread/utils.d.ts.map +1 -1
- package/dist/thread/utils.js +9 -8
- package/dist/tool/sys/memory.d.ts +1 -1
- package/dist/tool/sys/memory.d.ts.map +1 -1
- package/dist/tool/sys/memory.js +29 -8
- package/package.json +4 -3
- package/src/agent/__tests__/systools.test.ts +13 -9
- package/src/agent/types.ts +25 -29
- package/src/agent.ts +29 -28
- package/src/api/resources/agents/agents.ts +8 -8
- package/src/guardrail.ts +28 -28
- package/src/kernl/kernl.ts +12 -12
- package/src/lib/error.ts +3 -3
- package/src/lifecycle.ts +6 -6
- package/src/memory/__tests__/encoder.test.ts +153 -0
- package/src/memory/codecs/domain.ts +6 -0
- package/src/memory/encoder.ts +51 -6
- package/src/memory/index.ts +2 -1
- package/src/memory/schema.ts +5 -0
- package/src/memory/types.ts +20 -4
- package/src/storage/in-memory.ts +6 -2
- package/src/thread/__tests__/integration.test.ts +130 -146
- package/src/thread/__tests__/thread.test.ts +8 -8
- package/src/thread/thread.ts +21 -7
- package/src/thread/types.ts +9 -6
- package/src/thread/utils.ts +15 -14
- package/src/tool/sys/memory.ts +33 -9
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { MemoryByteEncoder, ObjectTextCodec } from "../encoder.js";
|
|
3
|
+
// Mock embedder that returns predictable vectors
|
|
4
|
+
function createMockEmbedder() {
|
|
5
|
+
return {
|
|
6
|
+
provider: "test",
|
|
7
|
+
modelId: "test-embedder",
|
|
8
|
+
embed: vi.fn(async ({ values }) => ({
|
|
9
|
+
embeddings: values.map((v) => [v.length, 0, 0]), // simple: [length, 0, 0]
|
|
10
|
+
})),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
describe("ObjectTextCodec", () => {
|
|
14
|
+
it("encodes simple object to YAML", () => {
|
|
15
|
+
const obj = { name: "Tony", preference: "coffee" };
|
|
16
|
+
const result = ObjectTextCodec.encode(obj);
|
|
17
|
+
expect(result).toContain("name: Tony");
|
|
18
|
+
expect(result).toContain("preference: coffee");
|
|
19
|
+
});
|
|
20
|
+
it("sorts keys for determinism", () => {
|
|
21
|
+
const obj1 = { z: 1, a: 2, m: 3 };
|
|
22
|
+
const obj2 = { a: 2, m: 3, z: 1 };
|
|
23
|
+
expect(ObjectTextCodec.encode(obj1)).toBe(ObjectTextCodec.encode(obj2));
|
|
24
|
+
});
|
|
25
|
+
it("truncates long objects with ellipsis", () => {
|
|
26
|
+
const longValue = "x".repeat(4000);
|
|
27
|
+
const obj = { data: longValue };
|
|
28
|
+
const result = ObjectTextCodec.encode(obj);
|
|
29
|
+
expect(result.length).toBeLessThanOrEqual(3005); // 3000 + "\n..."
|
|
30
|
+
expect(result.endsWith("\n...")).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it("handles nested objects", () => {
|
|
33
|
+
const obj = {
|
|
34
|
+
user: {
|
|
35
|
+
name: "Tony",
|
|
36
|
+
prefs: { coffee: { shots: 2 } },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const result = ObjectTextCodec.encode(obj);
|
|
40
|
+
expect(result).toContain("user:");
|
|
41
|
+
expect(result).toContain("name: Tony");
|
|
42
|
+
expect(result).toContain("shots: 2");
|
|
43
|
+
});
|
|
44
|
+
it("handles arrays", () => {
|
|
45
|
+
const obj = { items: ["a", "b", "c"] };
|
|
46
|
+
const result = ObjectTextCodec.encode(obj);
|
|
47
|
+
expect(result).toContain("items:");
|
|
48
|
+
expect(result).toContain("- a");
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe("MemoryByteEncoder", () => {
|
|
52
|
+
describe("encode", () => {
|
|
53
|
+
it("encodes text-only content", async () => {
|
|
54
|
+
const embedder = createMockEmbedder();
|
|
55
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
56
|
+
const byte = { text: "Hello world" };
|
|
57
|
+
const result = await encoder.encode(byte);
|
|
58
|
+
expect(result.text).toBe("Hello world");
|
|
59
|
+
expect(result.objtext).toBeUndefined();
|
|
60
|
+
expect(result.tvec).toBeDefined();
|
|
61
|
+
expect(embedder.embed).toHaveBeenCalledWith({ values: ["Hello world"] });
|
|
62
|
+
});
|
|
63
|
+
it("encodes object-only content with projection", async () => {
|
|
64
|
+
const embedder = createMockEmbedder();
|
|
65
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
66
|
+
const byte = {
|
|
67
|
+
object: { preference: "coffee", shots: 2 },
|
|
68
|
+
};
|
|
69
|
+
const result = await encoder.encode(byte);
|
|
70
|
+
// text falls back to objtext projection
|
|
71
|
+
expect(result.text).toContain("preference: coffee");
|
|
72
|
+
expect(result.objtext).toContain("preference: coffee");
|
|
73
|
+
expect(result.tvec).toBeDefined();
|
|
74
|
+
});
|
|
75
|
+
it("combines text and object for embedding", async () => {
|
|
76
|
+
const embedder = createMockEmbedder();
|
|
77
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
78
|
+
const byte = {
|
|
79
|
+
text: "Tony likes coffee",
|
|
80
|
+
object: { shots: 2, sugar: false },
|
|
81
|
+
};
|
|
82
|
+
const result = await encoder.encode(byte);
|
|
83
|
+
expect(result.text).toBe("Tony likes coffee");
|
|
84
|
+
expect(result.objtext).toContain("shots: 2");
|
|
85
|
+
// embedding should be called with combined text
|
|
86
|
+
const embedCall = embedder.embed.mock
|
|
87
|
+
.calls[0][0];
|
|
88
|
+
expect(embedCall.values[0]).toContain("Tony likes coffee");
|
|
89
|
+
expect(embedCall.values[0]).toContain("shots: 2");
|
|
90
|
+
});
|
|
91
|
+
it("does not set metadata (handled by domain codec)", async () => {
|
|
92
|
+
const embedder = createMockEmbedder();
|
|
93
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
94
|
+
const byte = {
|
|
95
|
+
text: "test",
|
|
96
|
+
object: { key: "value" },
|
|
97
|
+
};
|
|
98
|
+
const result = await encoder.encode(byte);
|
|
99
|
+
expect(result.metadata).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
it("returns undefined tvec when no content", async () => {
|
|
102
|
+
const embedder = createMockEmbedder();
|
|
103
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
104
|
+
const byte = {};
|
|
105
|
+
const result = await encoder.encode(byte);
|
|
106
|
+
expect(result.text).toBeUndefined();
|
|
107
|
+
expect(result.objtext).toBeUndefined();
|
|
108
|
+
expect(result.tvec).toBeUndefined();
|
|
109
|
+
expect(embedder.embed).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe("embed", () => {
|
|
113
|
+
it("exposes embed method for query embedding", async () => {
|
|
114
|
+
const embedder = createMockEmbedder();
|
|
115
|
+
const encoder = new MemoryByteEncoder(embedder);
|
|
116
|
+
const vec = await encoder.embed("search query");
|
|
117
|
+
expect(vec).toEqual([12, 0, 0]); // "search query".length = 12
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -21,6 +21,11 @@ import type { MemoryFilter, MemoryRecord, MemoryRecordUpdate, IndexMemoryRecord,
|
|
|
21
21
|
export declare const MEMORY_FILTER: Codec<MemoryFilter, SearchFilter>;
|
|
22
22
|
/**
|
|
23
23
|
* Create a codec for MemoryRecord -> IndexMemoryRecord.
|
|
24
|
+
*
|
|
25
|
+
* Combines:
|
|
26
|
+
* - Record scope/timestamps from MemoryRecord
|
|
27
|
+
* - Indexed content (text, object projection, embeddings) from byte codec
|
|
28
|
+
* - User metadata from record.metadata (not from content.object)
|
|
24
29
|
*/
|
|
25
30
|
export declare function recordCodec(bytecodec: MemoryByteCodec): AsyncCodec<MemoryRecord, IndexMemoryRecord>;
|
|
26
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/memory/codecs/domain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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,UAAU,CAAC;AAElB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,YAAY,EAAE,YAAY,CA0B3D,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/memory/codecs/domain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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,UAAU,CAAC;AAElB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,YAAY,EAAE,YAAY,CA0B3D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,GACzB,UAAU,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAsB7C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,CAqBzE,CAAC"}
|
|
@@ -44,6 +44,11 @@ export const MEMORY_FILTER = {
|
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Create a codec for MemoryRecord -> IndexMemoryRecord.
|
|
47
|
+
*
|
|
48
|
+
* Combines:
|
|
49
|
+
* - Record scope/timestamps from MemoryRecord
|
|
50
|
+
* - Indexed content (text, object projection, embeddings) from byte codec
|
|
51
|
+
* - User metadata from record.metadata (not from content.object)
|
|
47
52
|
*/
|
|
48
53
|
export function recordCodec(bytecodec) {
|
|
49
54
|
return {
|
|
@@ -60,6 +65,7 @@ export function recordCodec(bytecodec) {
|
|
|
60
65
|
createdAt: record.createdAt,
|
|
61
66
|
updatedAt: record.updatedAt,
|
|
62
67
|
...indexable,
|
|
68
|
+
metadata: record.metadata ?? null, // user metadata, not content.object
|
|
63
69
|
};
|
|
64
70
|
},
|
|
65
71
|
async decode() {
|
package/dist/memory/encoder.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MemoryByte encoder - converts MemoryByte to IndexableByte with embeddings.
|
|
3
3
|
*/
|
|
4
|
-
import type { EmbeddingModel } from "@kernl-sdk/protocol";
|
|
4
|
+
import type { EmbeddingModel, JSONObject } from "@kernl-sdk/protocol";
|
|
5
5
|
import type { MemoryByte, IndexableByte, MemoryByteCodec } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Codec for converting JSONObject to a canonical text representation.
|
|
8
|
+
*
|
|
9
|
+
* Uses YAML for human-readable, deterministic output suitable for:
|
|
10
|
+
* - Full-text search indexing
|
|
11
|
+
* - Embedding input (combined with text field)
|
|
12
|
+
*
|
|
13
|
+
* TODO: Allow users to pass custom codec via MemoryOptions.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ObjectTextCodec: {
|
|
16
|
+
/**
|
|
17
|
+
* Encode a JSONObject to canonical text.
|
|
18
|
+
* Uses YAML with sorted keys for determinism.
|
|
19
|
+
* Truncates at MAX_OBJECT_TEXT_LENGTH chars.
|
|
20
|
+
*/
|
|
21
|
+
encode(obj: JSONObject): string;
|
|
22
|
+
};
|
|
6
23
|
/**
|
|
7
24
|
* Encoder that converts MemoryByte to IndexableByte.
|
|
8
25
|
*
|
|
@@ -13,7 +30,13 @@ export declare class MemoryByteEncoder implements MemoryByteCodec {
|
|
|
13
30
|
constructor(embedder: EmbeddingModel<string>);
|
|
14
31
|
/**
|
|
15
32
|
* Encode a MemoryByte to IndexableByte.
|
|
16
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* - Produces `objtext` string projection for FTS indexing
|
|
35
|
+
* - Combines text + objtext for embedding input
|
|
36
|
+
* - Returns text (fallback to objtext if no text provided)
|
|
37
|
+
*
|
|
38
|
+
* Note: metadata is NOT set here - it comes from record.metadata
|
|
39
|
+
* via the domain codec, not from MemoryByte.object.
|
|
17
40
|
*/
|
|
18
41
|
encode(byte: MemoryByte): Promise<IndexableByte>;
|
|
19
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/memory/encoder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/memory/encoder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAQ1E;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;OAIG;gBACS,UAAU,GAAG,MAAM;CAOhC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAEtC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC;IAI5C;;;;;;;;;OASG;IACG,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAwBtD;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;IAI5D;;;OAGG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAI7C"}
|
package/dist/memory/encoder.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MemoryByte encoder - converts MemoryByte to IndexableByte with embeddings.
|
|
3
3
|
*/
|
|
4
|
+
import { stringify as yamlStringify } from "yaml";
|
|
5
|
+
// ---------------------
|
|
6
|
+
// ObjectTextCodec
|
|
7
|
+
// ---------------------
|
|
8
|
+
const MAX_OBJECT_TEXT_LENGTH = 3000;
|
|
9
|
+
/**
|
|
10
|
+
* Codec for converting JSONObject to a canonical text representation.
|
|
11
|
+
*
|
|
12
|
+
* Uses YAML for human-readable, deterministic output suitable for:
|
|
13
|
+
* - Full-text search indexing
|
|
14
|
+
* - Embedding input (combined with text field)
|
|
15
|
+
*
|
|
16
|
+
* TODO: Allow users to pass custom codec via MemoryOptions.
|
|
17
|
+
*/
|
|
18
|
+
export const ObjectTextCodec = {
|
|
19
|
+
/**
|
|
20
|
+
* Encode a JSONObject to canonical text.
|
|
21
|
+
* Uses YAML with sorted keys for determinism.
|
|
22
|
+
* Truncates at MAX_OBJECT_TEXT_LENGTH chars.
|
|
23
|
+
*/
|
|
24
|
+
encode(obj) {
|
|
25
|
+
const yaml = yamlStringify(obj, { sortMapEntries: true });
|
|
26
|
+
if (yaml.length <= MAX_OBJECT_TEXT_LENGTH) {
|
|
27
|
+
return yaml;
|
|
28
|
+
}
|
|
29
|
+
return yaml.slice(0, MAX_OBJECT_TEXT_LENGTH) + "\n...";
|
|
30
|
+
},
|
|
31
|
+
};
|
|
4
32
|
/**
|
|
5
33
|
* Encoder that converts MemoryByte to IndexableByte.
|
|
6
34
|
*
|
|
@@ -13,19 +41,32 @@ export class MemoryByteEncoder {
|
|
|
13
41
|
}
|
|
14
42
|
/**
|
|
15
43
|
* Encode a MemoryByte to IndexableByte.
|
|
16
|
-
*
|
|
44
|
+
*
|
|
45
|
+
* - Produces `objtext` string projection for FTS indexing
|
|
46
|
+
* - Combines text + objtext for embedding input
|
|
47
|
+
* - Returns text (fallback to objtext if no text provided)
|
|
48
|
+
*
|
|
49
|
+
* Note: metadata is NOT set here - it comes from record.metadata
|
|
50
|
+
* via the domain codec, not from MemoryByte.object.
|
|
17
51
|
*/
|
|
18
52
|
async encode(byte) {
|
|
19
|
-
const
|
|
20
|
-
|
|
53
|
+
const objtext = byte.object
|
|
54
|
+
? ObjectTextCodec.encode(byte.object) // encode object as embeddable string
|
|
55
|
+
: undefined;
|
|
56
|
+
// (TODO): this behavior deserves consideration - do we always want to merge text + object?
|
|
57
|
+
//
|
|
58
|
+
// combine text + object for richer embedding
|
|
59
|
+
const combined = [byte.text, objtext].filter(Boolean).join("\n");
|
|
60
|
+
const tvec = combined ? await this.embed(combined) : undefined;
|
|
21
61
|
// TODO: embed other modalities (image, audio, video)
|
|
62
|
+
//
|
|
22
63
|
// const ivec = byte.image ? await this.embedImage(byte.image) : undefined;
|
|
23
64
|
// const avec = byte.audio ? await this.embedAudio(byte.audio) : undefined;
|
|
24
65
|
// const vvec = byte.video ? await this.embedVideo(byte.video) : undefined;
|
|
25
66
|
return {
|
|
26
|
-
text,
|
|
67
|
+
text: byte.text ?? objtext, // fallback to projection if no text
|
|
68
|
+
objtext,
|
|
27
69
|
tvec,
|
|
28
|
-
metadata: byte.object ?? null,
|
|
29
70
|
};
|
|
30
71
|
}
|
|
31
72
|
/**
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Memory module.
|
|
3
3
|
*/
|
|
4
4
|
export { Memory } from "./memory.js";
|
|
5
|
-
export { MemoryByteEncoder } from "./encoder.js";
|
|
5
|
+
export { MemoryByteEncoder, ObjectTextCodec } from "./encoder.js";
|
|
6
6
|
export { buildMemoryIndexSchema } from "./schema.js";
|
|
7
7
|
export { MemoryIndexHandle } from "./handle.js";
|
|
8
8
|
export type { MemoryIndexHandleConfig } from "./handle.js";
|
|
9
|
-
export type { TextByte, ImageByte, AudioByte, VideoByte, MemoryByte, IndexableByte, MemoryByteCodec, MemoryScope, MemoryKind, NewMemory, AgentMemoryCreate, MemoryConfig, MemoryReindexParams, MemoryRecord, MemoryRecordUpdate, MemoryFilter, MemoryListOptions, MemorySearchQuery, IndexMemoryRecord, IndexMemoryRecordPatch, WorkingMemorySnapshot, ShortTermMemorySnapshot, } from "./types.js";
|
|
9
|
+
export type { TextByte, ImageByte, AudioByte, VideoByte, MemoryByte, IndexableByte, MemoryByteCodec, MemoryScope, MemoryKind, NewMemory, AgentMemoryCreate, AgentMemoryUpdate, MemoryConfig, MemoryReindexParams, MemoryRecord, MemoryRecordUpdate, MemoryFilter, MemoryListOptions, MemorySearchQuery, IndexMemoryRecord, IndexMemoryRecordPatch, WorkingMemorySnapshot, ShortTermMemorySnapshot, } from "./types.js";
|
|
10
10
|
export type { MemoryStore } from "./store.js";
|
|
11
11
|
export type { MemoryIndexBase, MemorySearchIndex, MemoryGraphIndex, MemoryArchiveIndex, GraphTraversalQuery, GraphTraversalResult, ArchiveQuery, ArchiveResult, } from "./indexes.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,YAAY,EAEV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EAEf,WAAW,EACX,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,aAAa,GACd,MAAM,WAAW,CAAC"}
|
package/dist/memory/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Memory module.
|
|
3
3
|
*/
|
|
4
4
|
export { Memory } from "./memory.js";
|
|
5
|
-
export { MemoryByteEncoder } from "./encoder.js";
|
|
5
|
+
export { MemoryByteEncoder, ObjectTextCodec } from "./encoder.js";
|
|
6
6
|
export { buildMemoryIndexSchema } from "./schema.js";
|
|
7
7
|
export { MemoryIndexHandle } from "./handle.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/memory/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/memory/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqG7B"}
|
package/dist/memory/schema.js
CHANGED
package/dist/memory/types.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface MemoryByte {
|
|
|
51
51
|
*/
|
|
52
52
|
export interface IndexableByte {
|
|
53
53
|
text?: string;
|
|
54
|
+
objtext?: string;
|
|
54
55
|
tvec?: number[];
|
|
55
56
|
ivec?: number[];
|
|
56
57
|
avec?: number[];
|
|
@@ -102,7 +103,7 @@ export interface NewMemory {
|
|
|
102
103
|
id: string;
|
|
103
104
|
scope: MemoryScope;
|
|
104
105
|
kind: MemoryKind;
|
|
105
|
-
collection
|
|
106
|
+
collection?: string;
|
|
106
107
|
content: MemoryByte;
|
|
107
108
|
wmem?: boolean;
|
|
108
109
|
smem?: {
|
|
@@ -123,7 +124,7 @@ export interface AgentMemoryCreate {
|
|
|
123
124
|
id?: string;
|
|
124
125
|
namespace?: string;
|
|
125
126
|
entityId?: string;
|
|
126
|
-
collection
|
|
127
|
+
collection?: string;
|
|
127
128
|
content: MemoryByte;
|
|
128
129
|
wmem?: boolean;
|
|
129
130
|
smem?: {
|
|
@@ -132,6 +133,22 @@ export interface AgentMemoryCreate {
|
|
|
132
133
|
timestamp?: number;
|
|
133
134
|
metadata?: JSONObject | null;
|
|
134
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Simplified input for agent-scoped memory updates.
|
|
138
|
+
*
|
|
139
|
+
* Allows updating content, collection, and memory layer flags.
|
|
140
|
+
* Scope (namespace, entityId, agentId) cannot be changed after creation.
|
|
141
|
+
*/
|
|
142
|
+
export interface AgentMemoryUpdate {
|
|
143
|
+
id: string;
|
|
144
|
+
content?: MemoryByte;
|
|
145
|
+
collection?: string;
|
|
146
|
+
wmem?: boolean;
|
|
147
|
+
smem?: {
|
|
148
|
+
expiresAt: number | null;
|
|
149
|
+
};
|
|
150
|
+
metadata?: JSONObject | null;
|
|
151
|
+
}
|
|
135
152
|
/**
|
|
136
153
|
* Base memory record fields.
|
|
137
154
|
*/
|
|
@@ -139,7 +156,7 @@ interface BaseMemoryRecord {
|
|
|
139
156
|
id: string;
|
|
140
157
|
scope: MemoryScope;
|
|
141
158
|
kind: MemoryKind;
|
|
142
|
-
collection: string;
|
|
159
|
+
collection: string | null;
|
|
143
160
|
content: MemoryByte;
|
|
144
161
|
wmem: boolean;
|
|
145
162
|
smem: {
|
|
@@ -227,7 +244,7 @@ export interface IndexMemoryRecord extends IndexableByte {
|
|
|
227
244
|
entityId: string | null;
|
|
228
245
|
agentId: string | null;
|
|
229
246
|
kind: MemoryKind;
|
|
230
|
-
collection: string;
|
|
247
|
+
collection: string | null;
|
|
231
248
|
timestamp: number;
|
|
232
249
|
createdAt: number;
|
|
233
250
|
updatedAt: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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AgCf;;OAEG;IACH,OAAO,CAAC,aAAa;IAyCrB;;OAEG;IACH,OAAO,CAAC,YAAY;IA2CpB;;OAEG;IACH,OAAO,CAAC,YAAY;CA6BrB;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IACrD,OAAO,CAAC,QAAQ,CAAmC;IAE7C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAI7C,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAkB1D,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBhD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBpE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3C;;OAEG;IACH,OAAO,CAAC,YAAY;IAmEpB;;OAEG;IACH,OAAO,CAAC,YAAY;CASrB"}
|
|
@@ -312,7 +312,7 @@ export class InMemoryMemoryStore {
|
|
|
312
312
|
id: memory.id,
|
|
313
313
|
scope: memory.scope,
|
|
314
314
|
kind: memory.kind,
|
|
315
|
-
collection: memory.collection,
|
|
315
|
+
collection: memory.collection ?? null,
|
|
316
316
|
content: memory.content,
|
|
317
317
|
wmem: memory.wmem ?? false,
|
|
318
318
|
smem: memory.smem ?? { expiresAt: null },
|
|
@@ -371,7 +371,9 @@ export class InMemoryMemoryStore {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
// Filter by collections
|
|
374
|
-
if (filter.collections &&
|
|
374
|
+
if (filter.collections &&
|
|
375
|
+
(record.collection === null ||
|
|
376
|
+
!filter.collections.includes(record.collection))) {
|
|
375
377
|
return false;
|
|
376
378
|
}
|
|
377
379
|
// Filter by wmem
|
|
@@ -288,7 +288,7 @@ describe.skipIf(SKIP_INTEGRATION_TESTS)("Thread streaming integration", () => {
|
|
|
288
288
|
name: "Test Structured Agent",
|
|
289
289
|
instructions: "You are a helpful assistant. Return JSON with name and age fields.",
|
|
290
290
|
model,
|
|
291
|
-
|
|
291
|
+
output: responseSchema,
|
|
292
292
|
});
|
|
293
293
|
const input = [
|
|
294
294
|
{
|
|
@@ -937,7 +937,7 @@ describe("Thread", () => {
|
|
|
937
937
|
});
|
|
938
938
|
});
|
|
939
939
|
describe("Final Output Parsing", () => {
|
|
940
|
-
it("should return text output when
|
|
940
|
+
it("should return text output when output is 'text'", async () => {
|
|
941
941
|
const model = createMockModel(async (req) => {
|
|
942
942
|
return {
|
|
943
943
|
content: [
|
|
@@ -962,7 +962,7 @@ describe("Thread", () => {
|
|
|
962
962
|
name: "Test",
|
|
963
963
|
instructions: "Test agent",
|
|
964
964
|
model,
|
|
965
|
-
|
|
965
|
+
output: "text",
|
|
966
966
|
});
|
|
967
967
|
const kernl = new Kernl();
|
|
968
968
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1005,7 +1005,7 @@ describe("Thread", () => {
|
|
|
1005
1005
|
name: "Test",
|
|
1006
1006
|
instructions: "Test agent",
|
|
1007
1007
|
model,
|
|
1008
|
-
|
|
1008
|
+
output: responseSchema,
|
|
1009
1009
|
});
|
|
1010
1010
|
const kernl = new Kernl();
|
|
1011
1011
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1049,7 +1049,7 @@ describe("Thread", () => {
|
|
|
1049
1049
|
name: "Test",
|
|
1050
1050
|
instructions: "Test agent",
|
|
1051
1051
|
model,
|
|
1052
|
-
|
|
1052
|
+
output: responseSchema,
|
|
1053
1053
|
});
|
|
1054
1054
|
const kernl = new Kernl();
|
|
1055
1055
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1089,7 +1089,7 @@ describe("Thread", () => {
|
|
|
1089
1089
|
name: "Test",
|
|
1090
1090
|
instructions: "Test agent",
|
|
1091
1091
|
model,
|
|
1092
|
-
|
|
1092
|
+
output: responseSchema,
|
|
1093
1093
|
});
|
|
1094
1094
|
const kernl = new Kernl();
|
|
1095
1095
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1130,7 +1130,7 @@ describe("Thread", () => {
|
|
|
1130
1130
|
name: "Test",
|
|
1131
1131
|
instructions: "Test agent",
|
|
1132
1132
|
model,
|
|
1133
|
-
|
|
1133
|
+
output: responseSchema,
|
|
1134
1134
|
});
|
|
1135
1135
|
const kernl = new Kernl();
|
|
1136
1136
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1184,7 +1184,7 @@ describe("Thread", () => {
|
|
|
1184
1184
|
name: "Test",
|
|
1185
1185
|
instructions: "Test agent",
|
|
1186
1186
|
model,
|
|
1187
|
-
|
|
1187
|
+
output: responseSchema,
|
|
1188
1188
|
});
|
|
1189
1189
|
const kernl = new Kernl();
|
|
1190
1190
|
const thread = new Thread({ agent, input: userMessage("test") });
|
|
@@ -1245,7 +1245,7 @@ describe("Thread", () => {
|
|
|
1245
1245
|
name: "Test",
|
|
1246
1246
|
instructions: "Test agent",
|
|
1247
1247
|
model,
|
|
1248
|
-
|
|
1248
|
+
output: "text",
|
|
1249
1249
|
});
|
|
1250
1250
|
const kernl = new Kernl();
|
|
1251
1251
|
const thread = new Thread({ agent, input: userMessage("test") });
|
package/dist/thread/thread.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Task } from "../task.js";
|
|
|
4
4
|
import type { ResolvedAgentResponse } from "../guardrail.js";
|
|
5
5
|
import { LanguageModel } from "@kernl-sdk/protocol";
|
|
6
6
|
import type { ThreadEvent, ThreadState, ThreadOptions, ThreadEventInner, ThreadStreamEvent, ThreadExecuteResult } from "./types.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { AgentOutputType } from "../agent/types.js";
|
|
8
8
|
/**
|
|
9
9
|
* A thread drives the execution loop for an agent.
|
|
10
10
|
*
|
|
@@ -45,10 +45,10 @@ import type { AgentResponseType } from "../agent/types.js";
|
|
|
45
45
|
* If a storage implementation is present, `persist(...)` is expected to throw on failure, and
|
|
46
46
|
* that error should bubble out of `_execute()` / `stream()` and stop the thread.
|
|
47
47
|
*/
|
|
48
|
-
export declare class Thread<TContext = unknown,
|
|
48
|
+
export declare class Thread<TContext = unknown, TOutput extends AgentOutputType = "text"> {
|
|
49
49
|
readonly tid: string;
|
|
50
50
|
readonly namespace: string;
|
|
51
|
-
readonly agent: Agent<TContext,
|
|
51
|
+
readonly agent: Agent<TContext, TOutput>;
|
|
52
52
|
readonly context: Context<TContext>;
|
|
53
53
|
readonly model: LanguageModel;
|
|
54
54
|
readonly parent: Task<TContext> | null;
|
|
@@ -63,11 +63,11 @@ export declare class Thread<TContext = unknown, TResponse extends AgentResponseT
|
|
|
63
63
|
private history;
|
|
64
64
|
private abort?;
|
|
65
65
|
private storage?;
|
|
66
|
-
constructor(options: ThreadOptions<TContext,
|
|
66
|
+
constructor(options: ThreadOptions<TContext, TOutput>);
|
|
67
67
|
/**
|
|
68
68
|
* Blocking execution - runs until terminal state or interruption
|
|
69
69
|
*/
|
|
70
|
-
execute(): Promise<ThreadExecuteResult<ResolvedAgentResponse<
|
|
70
|
+
execute(): Promise<ThreadExecuteResult<ResolvedAgentResponse<TOutput>>>;
|
|
71
71
|
/**
|
|
72
72
|
* Streaming execution - returns async iterator of events
|
|
73
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/thread/thread.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/thread/thread.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE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AAE,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC;IAgCrD;;OAEG;IACG,OAAO,IAAI,OAAO,CACtB,mBAAmB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CACpD;IAoBD;;OAEG;IACI,MAAM,IAAI,aAAa,CAAC,iBAAiB,CAAC;IAuBjD;;;;;OAKG;YACY,QAAQ;IAgEvB;;;;;OAKG;YACY,IAAI;IA8BnB;;;;;OAKG;YACW,UAAU;IAuCxB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,KAAK,EAAE,gBAAgB,EAAE,GAAG,WAAW,EAAE;IAiBnD;;OAEG;IACH,MAAM;IAQN;;OAEG;YACW,cAAc;IAyC5B;;;;OAIG;YACW,YAAY;IA4C1B;;OAEG;YACW,mBAAmB;CAsDlC"}
|
package/dist/thread/thread.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
+
import * as z from "zod";
|
|
2
3
|
import { Context } from "../context.js";
|
|
3
4
|
import { logger } from "../lib/logger.js";
|
|
4
5
|
import { FAILED, RUNNING, STOPPED, message, } from "@kernl-sdk/protocol";
|
|
@@ -108,7 +109,7 @@ export class Thread {
|
|
|
108
109
|
});
|
|
109
110
|
const text = getFinalResponse(items);
|
|
110
111
|
assert(text, "_execute continues until text !== null"); // (TODO): consider preventing infinite loops here
|
|
111
|
-
const parsed = parseFinalResponse(text, this.agent.
|
|
112
|
+
const parsed = parseFinalResponse(text, this.agent.output);
|
|
112
113
|
return { response: parsed, state: this.state };
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
@@ -322,7 +323,7 @@ export class Thread {
|
|
|
322
323
|
if (e.kind === "tool-result" &&
|
|
323
324
|
e.state === "requires_approval" // (TODO): fix this
|
|
324
325
|
) {
|
|
325
|
-
//
|
|
326
|
+
// find the original tool call for this pending approval
|
|
326
327
|
const call = intentions.toolCalls.find((c) => c.callId === e.callId);
|
|
327
328
|
call && pendingApprovals.push(call);
|
|
328
329
|
}
|
|
@@ -403,10 +404,20 @@ export class Thread {
|
|
|
403
404
|
const all = await this.agent.tools(this.context);
|
|
404
405
|
const enabled = await filter(all, async (tool) => await tool.isEnabled(this.context, this.agent));
|
|
405
406
|
const tools = enabled.map((tool) => tool.serialize());
|
|
407
|
+
// derive responseType from agent.output
|
|
408
|
+
let responseType;
|
|
409
|
+
if (this.agent.output && this.agent.output !== "text") {
|
|
410
|
+
const schema = this.agent.output;
|
|
411
|
+
responseType = {
|
|
412
|
+
kind: "json",
|
|
413
|
+
schema: z.toJSONSchema(schema, { target: "draft-7" }),
|
|
414
|
+
};
|
|
415
|
+
}
|
|
406
416
|
return {
|
|
407
417
|
input: filtered,
|
|
408
418
|
settings,
|
|
409
419
|
tools,
|
|
420
|
+
responseType,
|
|
410
421
|
};
|
|
411
422
|
}
|
|
412
423
|
}
|