kernl 0.12.0 → 0.12.2
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 +21 -0
- package/dist/api/resources/agents/agents.d.ts +2 -2
- package/dist/api/resources/agents/agents.d.ts.map +1 -1
- package/dist/api/resources/agents/agents.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/kernl/index.d.ts +2 -1
- package/dist/kernl/index.d.ts.map +1 -1
- package/dist/kernl/index.js +1 -0
- package/dist/kernl/kernl.d.ts +4 -4
- package/dist/kernl/kernl.d.ts.map +1 -1
- package/dist/kernl/kernl.js +17 -13
- package/dist/kernl/registry.d.ts +46 -0
- package/dist/kernl/registry.d.ts.map +1 -0
- package/dist/kernl/registry.js +57 -0
- package/dist/kernl/types.d.ts +2 -2
- package/dist/kernl/types.d.ts.map +1 -1
- package/dist/storage/base.d.ts +3 -3
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/in-memory.d.ts +5 -5
- package/dist/storage/in-memory.d.ts.map +1 -1
- package/dist/thread/__tests__/mock.d.ts +2 -3
- package/dist/thread/__tests__/mock.d.ts.map +1 -1
- package/dist/thread/thread.d.ts +4 -0
- package/dist/thread/thread.d.ts.map +1 -1
- package/dist/thread/thread.js +43 -75
- package/dist/thread/types.d.ts +18 -3
- package/dist/thread/types.d.ts.map +1 -1
- package/dist/thread/utils.d.ts +7 -7
- package/dist/thread/utils.d.ts.map +1 -1
- package/dist/thread/utils.js +1 -1
- package/package.json +4 -6
- package/src/api/__tests__/threads.test.ts +3 -3
- package/src/api/resources/agents/agents.ts +3 -3
- package/src/index.ts +4 -2
- package/src/kernl/index.ts +3 -2
- package/src/kernl/kernl.ts +18 -15
- package/src/kernl/registry.ts +69 -0
- package/src/kernl/types.ts +2 -2
- package/src/storage/base.ts +2 -2
- package/src/storage/in-memory.ts +4 -4
- package/src/thread/__tests__/mock.ts +2 -2
- package/src/thread/thread.ts +47 -78
- package/src/thread/types.ts +49 -3
- package/src/thread/utils.ts +14 -7
- package/dist/thread/__tests__/integration.test.d.ts +0 -2
- package/dist/thread/__tests__/integration.test.d.ts.map +0 -1
- package/dist/thread/__tests__/integration.test.js +0 -320
- package/src/thread/__tests__/integration.test.ts +0 -434
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @kernl/core
|
|
2
2
|
|
|
3
|
+
## 0.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 11cf6fd: Add ModelRegistry and AgentRegistry classes to fix hydration issues when threads use model overrides. Models are now auto-registered in spawn/schedule methods.
|
|
8
|
+
|
|
9
|
+
## 0.12.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 58e9db2: Fix provider normalization and ThreadStreamEvent types
|
|
14
|
+
- Normalize AI SDK provider strings (`anthropic.messages` -> `anthropic`, etc.)
|
|
15
|
+
- Export `ThreadStreamEvent` from kernl for consumers
|
|
16
|
+
- Update `toUIMessageStream` to accept `ThreadStreamEvent` from `agent.stream()`
|
|
17
|
+
- Add `kernl` as dependency to `@kernl-sdk/ai` (breaking circular devDep)
|
|
18
|
+
|
|
19
|
+
- 320b76a: Add emit helper and sequence streamed events
|
|
20
|
+
- Thread now yields `ThreadEvent` with `seq` for complete items (messages, tool calls, tool results)
|
|
21
|
+
- Delta and control events remain ephemeral `StreamEvent` without seq
|
|
22
|
+
- Internal `emit()` helper reduces boilerplate in event emission
|
|
23
|
+
|
|
3
24
|
## 0.12.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Agent } from "../../../agent.js";
|
|
2
|
-
import type { BaseAgent } from "../../../agent/base.js";
|
|
3
2
|
import type { AgentOutputType } from "../../../agent/types.js";
|
|
4
3
|
import type { UnknownContext } from "../../../context.js";
|
|
4
|
+
import type { AgentRegistry } from "../../../kernl/registry.js";
|
|
5
5
|
import type { TextOutput } from "../../../thread/types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Agents resource.
|
|
@@ -16,7 +16,7 @@ import type { TextOutput } from "../../../thread/types.js";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class RAgents {
|
|
18
18
|
private readonly registry;
|
|
19
|
-
constructor(registry:
|
|
19
|
+
constructor(registry: AgentRegistry);
|
|
20
20
|
/**
|
|
21
21
|
* Get a live Agent instance by id.
|
|
22
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../../src/api/resources/agents/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../../src/api/resources/agents/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,aAAa;IAEpD;;;;;;;OAOG;IACH,GAAG,CACD,QAAQ,GAAG,cAAc,EACzB,OAAO,SAAS,eAAe,GAAG,UAAU,EAC5C,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,SAAS;IAQnD;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB;;OAEG;IACH,IAAI,IAAI,KAAK,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE;IAMhD;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAGhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Kernl } from "./kernl/index.js";
|
|
2
|
-
export type { KernlOptions, StorageOptions,
|
|
2
|
+
export type { KernlOptions, StorageOptions, IAgentRegistry, IModelRegistry, } from "./kernl/index.js";
|
|
3
|
+
export { AgentRegistry, ModelRegistry } from "./kernl/index.js";
|
|
3
4
|
export { Agent } from "./agent.js";
|
|
4
5
|
export { Context } from "./context.js";
|
|
5
6
|
export type { LifecycleEvent, ThreadStartEvent, ThreadStopEvent, ModelCallStartEvent, ModelCallEndEvent, ToolCallStartEvent, ToolCallEndEvent, } from "./lifecycle.js";
|
|
@@ -10,7 +11,7 @@ export { MCPServerSSE } from "./mcp/sse.js";
|
|
|
10
11
|
export { MCPServerStreamableHttp } from "./mcp/http.js";
|
|
11
12
|
export type { MThread as Thread, MThreadEvent as ThreadEvent, MThreadEventBase as ThreadEventBase, } from "./api/models/index.js";
|
|
12
13
|
export type { RThreadsListParams as ThreadsListParams, RThreadGetOptions as ThreadGetOptions, RThreadHistoryParams as ThreadHistoryParams, RThreadCreateParams as ThreadCreateParams, RThreadUpdateParams as ThreadUpdateParams, } from "./api/resources/threads/index.js";
|
|
13
|
-
export { THREAD_STATES, type ThreadState, type PublicThreadEvent, } from "./thread/types.js";
|
|
14
|
+
export { THREAD_STATES, type ThreadState, type PublicThreadEvent, type ThreadStreamEvent, } from "./thread/types.js";
|
|
14
15
|
export type { ThreadStore, NewThread, ThreadUpdate, ThreadFilter, ThreadHistoryOptions, ThreadInclude, ThreadListOptions, SortOrder, KernlStorage, Transaction, } from "./storage/index.js";
|
|
15
16
|
export { Memory, MemoryByteEncoder } from "./memory/index.js";
|
|
16
17
|
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";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAIrD,YAAY,EACV,OAAO,IAAI,MAAM,EACjB,YAAY,IAAI,WAAW,EAC3B,gBAAgB,IAAI,eAAe,GACpC,MAAM,cAAc,CAAC;AAEtB,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;AAEjC,OAAO,EACL,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AAIxB,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;AAGnB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/kernl/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Kernl } from "./kernl.js";
|
|
2
|
-
export
|
|
2
|
+
export { AgentRegistry, ModelRegistry } from "./registry.js";
|
|
3
|
+
export type { KernlOptions, StorageOptions, MemoryOptions, IAgentRegistry, IModelRegistry, } from "./types.js";
|
|
3
4
|
//# 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,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,
|
|
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,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC"}
|
package/dist/kernl/index.js
CHANGED
package/dist/kernl/kernl.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { KernlHooks } from "../lifecycle.js";
|
|
|
3
3
|
import type { Thread } from "../thread/index.js";
|
|
4
4
|
import type { ResolvedAgentResponse } from "../guardrail.js";
|
|
5
5
|
import { type KernlStorage } from "../storage/index.js";
|
|
6
|
+
import { Memory } from "../memory/index.js";
|
|
6
7
|
import { RThreads } from "../api/resources/threads/index.js";
|
|
7
8
|
import { RAgents } from "../api/resources/agents/index.js";
|
|
8
|
-
import { Memory } from "../memory/index.js";
|
|
9
9
|
import type { ThreadExecuteResult, ThreadStreamEvent } from "../thread/types.js";
|
|
10
10
|
import type { AgentOutputType } from "../agent/types.js";
|
|
11
11
|
import type { KernlOptions } from "./types.js";
|
|
@@ -18,10 +18,10 @@ import type { KernlOptions } from "./types.js";
|
|
|
18
18
|
export declare class Kernl extends KernlHooks {
|
|
19
19
|
private readonly _agents;
|
|
20
20
|
private readonly _models;
|
|
21
|
-
readonly storage: KernlStorage;
|
|
22
|
-
athreads: Map<string, Thread<any, any>>;
|
|
23
21
|
private readonly _memopts;
|
|
24
22
|
private readonly _storopts;
|
|
23
|
+
readonly storage: KernlStorage;
|
|
24
|
+
athreads: Map<string, Thread<any, any>>;
|
|
25
25
|
private warnings;
|
|
26
26
|
readonly threads: RThreads;
|
|
27
27
|
readonly agents: RAgents;
|
|
@@ -58,6 +58,6 @@ export declare class Kernl extends KernlHooks {
|
|
|
58
58
|
*
|
|
59
59
|
* Initialize the memory system based on the storage + memory configuration.
|
|
60
60
|
*/
|
|
61
|
-
private
|
|
61
|
+
private initmem;
|
|
62
62
|
}
|
|
63
63
|
//# sourceMappingURL=kernl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernl.d.ts","sourceRoot":"","sources":["../../src/kernl/kernl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,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;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"kernl.d.ts","sourceRoot":"","sources":["../../src/kernl/kernl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,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;AAC/D,OAAO,EACL,MAAM,EAIP,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,QAAQ,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AmB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAU/D;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO,SAAS,eAAe,EAC1D,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAChC,aAAa,CAAC,iBAAiB,CAAC;IAUnC;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,OAAO,SAAS,eAAe,EAC7D,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAChC,aAAa,CAAC,iBAAiB,CAAC;IAYnC;;;;OAIG;IACH,OAAO,CAAC,OAAO;CA6BhB"}
|
package/dist/kernl/kernl.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { resolveEmbeddingModel } from "@kernl-sdk/retrieval";
|
|
2
2
|
import { KernlHooks } from "../lifecycle.js";
|
|
3
3
|
import { InMemoryStorage } from "../storage/index.js";
|
|
4
|
-
import { RThreads } from "../api/resources/threads/index.js";
|
|
5
|
-
import { RAgents } from "../api/resources/agents/index.js";
|
|
6
4
|
import { Memory, MemoryByteEncoder, MemoryIndexHandle, buildMemoryIndexSchema, } from "../memory/index.js";
|
|
7
5
|
import { logger } from "../lib/logger.js";
|
|
6
|
+
import { RThreads } from "../api/resources/threads/index.js";
|
|
7
|
+
import { RAgents } from "../api/resources/agents/index.js";
|
|
8
|
+
import { AgentRegistry, ModelRegistry } from "./registry.js";
|
|
8
9
|
/**
|
|
9
10
|
* The kernl - manages agent processes, scheduling, and task lifecycle.
|
|
10
11
|
*
|
|
@@ -12,12 +13,12 @@ import { logger } from "../lib/logger.js";
|
|
|
12
13
|
* tracing.
|
|
13
14
|
*/
|
|
14
15
|
export class Kernl extends KernlHooks {
|
|
15
|
-
_agents
|
|
16
|
-
_models
|
|
17
|
-
storage;
|
|
18
|
-
athreads = new Map(); /* active threads */
|
|
16
|
+
_agents;
|
|
17
|
+
_models;
|
|
19
18
|
_memopts;
|
|
20
19
|
_storopts;
|
|
20
|
+
storage;
|
|
21
|
+
athreads = new Map(); /* active threads */
|
|
21
22
|
warnings = {
|
|
22
23
|
embedding: false, // "Embeddings are not configured. If you want memories to auto-embed text content..."
|
|
23
24
|
vector: false, // "No vector storage configured. The memories.search() function will not be..."
|
|
@@ -30,17 +31,19 @@ export class Kernl extends KernlHooks {
|
|
|
30
31
|
super();
|
|
31
32
|
this._memopts = options.memory;
|
|
32
33
|
this._storopts = options.storage;
|
|
34
|
+
this._agents = new AgentRegistry();
|
|
35
|
+
this._models = new ModelRegistry();
|
|
33
36
|
this.storage = options.storage?.db ?? new InMemoryStorage();
|
|
34
37
|
this.storage.bind({ agents: this._agents, models: this._models });
|
|
35
38
|
this.threads = new RThreads(this.storage.threads);
|
|
36
39
|
this.agents = new RAgents(this._agents);
|
|
37
|
-
this.memories = this.
|
|
40
|
+
this.memories = this.initmem();
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
43
|
* Registers a new agent with the kernl instance.
|
|
41
44
|
*/
|
|
42
45
|
register(agent) {
|
|
43
|
-
this._agents.
|
|
46
|
+
this._agents.register(agent);
|
|
44
47
|
agent.bind(this);
|
|
45
48
|
// memory config warnings (log once)
|
|
46
49
|
if (agent.memory.enabled) {
|
|
@@ -57,16 +60,14 @@ export class Kernl extends KernlHooks {
|
|
|
57
60
|
}
|
|
58
61
|
// auto-populate model registry for storage hydration (llm agents only - for now)
|
|
59
62
|
if (agent.kind === "llm") {
|
|
60
|
-
|
|
61
|
-
if (!this._models.has(key)) {
|
|
62
|
-
this._models.set(key, agent.model);
|
|
63
|
-
}
|
|
63
|
+
this._models.register(agent.model);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Spawn a new thread - blocking execution
|
|
68
68
|
*/
|
|
69
69
|
async spawn(thread) {
|
|
70
|
+
this._models.register(thread.model);
|
|
70
71
|
this.athreads.set(thread.tid, thread);
|
|
71
72
|
try {
|
|
72
73
|
return await thread.execute();
|
|
@@ -81,6 +82,7 @@ export class Kernl extends KernlHooks {
|
|
|
81
82
|
* NOTE: just blocks for now
|
|
82
83
|
*/
|
|
83
84
|
async schedule(thread) {
|
|
85
|
+
this._models.register(thread.model);
|
|
84
86
|
this.athreads.set(thread.tid, thread);
|
|
85
87
|
try {
|
|
86
88
|
return await thread.execute();
|
|
@@ -95,6 +97,7 @@ export class Kernl extends KernlHooks {
|
|
|
95
97
|
* Spawn a new thread - streaming execution
|
|
96
98
|
*/
|
|
97
99
|
async *spawnStream(thread) {
|
|
100
|
+
this._models.register(thread.model);
|
|
98
101
|
this.athreads.set(thread.tid, thread);
|
|
99
102
|
try {
|
|
100
103
|
yield* thread.stream();
|
|
@@ -109,6 +112,7 @@ export class Kernl extends KernlHooks {
|
|
|
109
112
|
* Schedule an existing thread - streaming execution
|
|
110
113
|
*/
|
|
111
114
|
async *scheduleStream(thread) {
|
|
115
|
+
this._models.register(thread.model);
|
|
112
116
|
this.athreads.set(thread.tid, thread);
|
|
113
117
|
try {
|
|
114
118
|
yield* thread.stream();
|
|
@@ -123,7 +127,7 @@ export class Kernl extends KernlHooks {
|
|
|
123
127
|
*
|
|
124
128
|
* Initialize the memory system based on the storage + memory configuration.
|
|
125
129
|
*/
|
|
126
|
-
|
|
130
|
+
initmem() {
|
|
127
131
|
const embeddingModel = this._memopts?.embedding;
|
|
128
132
|
const embedder = embeddingModel
|
|
129
133
|
? typeof embeddingModel === "string"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LanguageModel } from "@kernl-sdk/protocol";
|
|
2
|
+
import type { BaseAgent } from "../agent/base.js";
|
|
3
|
+
import type { IAgentRegistry, IModelRegistry } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registry for language models used by threads.
|
|
6
|
+
*
|
|
7
|
+
* Models are keyed by "{provider}/{modelId}" and must be registered before
|
|
8
|
+
* storage can hydrate threads that reference them.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ModelRegistry implements IModelRegistry {
|
|
11
|
+
private readonly models;
|
|
12
|
+
/**
|
|
13
|
+
* Register a model instance. Idempotent - only adds if not already present.
|
|
14
|
+
*/
|
|
15
|
+
register(model: LanguageModel): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get a model by its composite key ("{provider}/{modelId}").
|
|
18
|
+
*/
|
|
19
|
+
get(key: string): LanguageModel | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registry for agents.
|
|
23
|
+
*
|
|
24
|
+
* Agents are keyed by their id and must be registered before threads can
|
|
25
|
+
* reference them.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AgentRegistry implements IAgentRegistry {
|
|
28
|
+
private readonly agents;
|
|
29
|
+
/**
|
|
30
|
+
* Register an agent instance. Replaces existing agent with same id.
|
|
31
|
+
*/
|
|
32
|
+
register(agent: BaseAgent<any>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get an agent by its id.
|
|
35
|
+
*/
|
|
36
|
+
get(id: string): BaseAgent<any> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Unregister an agent by id.
|
|
39
|
+
*/
|
|
40
|
+
unregister(id: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* List all registered agents.
|
|
43
|
+
*/
|
|
44
|
+
values(): IterableIterator<BaseAgent<any>>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/kernl/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEhE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAOpC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;CAG5C;AAED;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IAEjE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI;IAIrC;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS;IAI3C;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI/B;;OAEG;IACH,MAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;CAG3C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for language models used by threads.
|
|
3
|
+
*
|
|
4
|
+
* Models are keyed by "{provider}/{modelId}" and must be registered before
|
|
5
|
+
* storage can hydrate threads that reference them.
|
|
6
|
+
*/
|
|
7
|
+
export class ModelRegistry {
|
|
8
|
+
models = new Map();
|
|
9
|
+
/**
|
|
10
|
+
* Register a model instance. Idempotent - only adds if not already present.
|
|
11
|
+
*/
|
|
12
|
+
register(model) {
|
|
13
|
+
const key = `${model.provider}/${model.modelId}`;
|
|
14
|
+
if (!this.models.has(key)) {
|
|
15
|
+
this.models.set(key, model);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a model by its composite key ("{provider}/{modelId}").
|
|
20
|
+
*/
|
|
21
|
+
get(key) {
|
|
22
|
+
return this.models.get(key);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Registry for agents.
|
|
27
|
+
*
|
|
28
|
+
* Agents are keyed by their id and must be registered before threads can
|
|
29
|
+
* reference them.
|
|
30
|
+
*/
|
|
31
|
+
export class AgentRegistry {
|
|
32
|
+
agents = new Map();
|
|
33
|
+
/**
|
|
34
|
+
* Register an agent instance. Replaces existing agent with same id.
|
|
35
|
+
*/
|
|
36
|
+
register(agent) {
|
|
37
|
+
this.agents.set(agent.id, agent);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get an agent by its id.
|
|
41
|
+
*/
|
|
42
|
+
get(id) {
|
|
43
|
+
return this.agents.get(id);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Unregister an agent by id.
|
|
47
|
+
*/
|
|
48
|
+
unregister(id) {
|
|
49
|
+
return this.agents.delete(id);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List all registered agents.
|
|
53
|
+
*/
|
|
54
|
+
values() {
|
|
55
|
+
return this.agents.values();
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/kernl/types.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export interface KernlOptions {
|
|
|
74
74
|
*
|
|
75
75
|
* Satisfied by Map<string, BaseAgent>.
|
|
76
76
|
*/
|
|
77
|
-
export interface
|
|
77
|
+
export interface IAgentRegistry {
|
|
78
78
|
get(id: string): BaseAgent<any> | undefined;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -86,7 +86,7 @@ export interface AgentRegistry {
|
|
|
86
86
|
* TODO: Create an exhaustive model registry in the protocol package
|
|
87
87
|
* with all supported models and their metadata.
|
|
88
88
|
*/
|
|
89
|
-
export interface
|
|
89
|
+
export interface IModelRegistry {
|
|
90
90
|
get(key: string): LanguageModel | undefined;
|
|
91
91
|
}
|
|
92
92
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/kernl/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE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,MAAM,CAAC,EAAE,WAAW,CAAC;CAKtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;CAC7C"}
|
package/dist/storage/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core storage contracts.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { IAgentRegistry, IModelRegistry } from "../kernl/types.js";
|
|
5
5
|
import type { ThreadStore } from "./thread.js";
|
|
6
6
|
import type { MemoryStore } from "../memory/store.js";
|
|
7
7
|
/**
|
|
@@ -24,8 +24,8 @@ export interface KernlStorage {
|
|
|
24
24
|
* Called by Kernl after construction to wire up agent/model lookups.
|
|
25
25
|
*/
|
|
26
26
|
bind(registries: {
|
|
27
|
-
agents:
|
|
28
|
-
models:
|
|
27
|
+
agents: IAgentRegistry;
|
|
28
|
+
models: IModelRegistry;
|
|
29
29
|
}): void;
|
|
30
30
|
/**
|
|
31
31
|
* Execute a function within a transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/storage/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/storage/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;IAKtB;;;;OAIG;IACH,IAAI,CAAC,UAAU,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI,CAAC;IAE3E;;;;;OAKG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEhE;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAMrB;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { Thread } from "../thread/index.js";
|
|
9
9
|
import type { KernlStorage, Transaction, ThreadStore, NewThread, ThreadUpdate, ThreadInclude, ThreadListOptions, ThreadHistoryOptions } from "../storage/index.js";
|
|
10
10
|
import type { ThreadEvent } from "../thread/types.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { IAgentRegistry, IModelRegistry } from "../kernl/types.js";
|
|
12
12
|
import type { MemoryStore, MemoryRecord, NewMemory, MemoryRecordUpdate, MemoryListOptions } from "../memory/index.js";
|
|
13
13
|
/**
|
|
14
14
|
* In-memory storage implementation.
|
|
@@ -18,8 +18,8 @@ export declare class InMemoryStorage implements KernlStorage {
|
|
|
18
18
|
memories: InMemoryMemoryStore;
|
|
19
19
|
constructor();
|
|
20
20
|
bind(registries: {
|
|
21
|
-
agents:
|
|
22
|
-
models:
|
|
21
|
+
agents: IAgentRegistry;
|
|
22
|
+
models: IModelRegistry;
|
|
23
23
|
}): void;
|
|
24
24
|
transaction<T>(fn: (tx: Transaction) => Promise<T>): Promise<T>;
|
|
25
25
|
init(): Promise<void>;
|
|
@@ -34,8 +34,8 @@ export declare class InMemoryThreadStore implements ThreadStore {
|
|
|
34
34
|
private events;
|
|
35
35
|
private registries;
|
|
36
36
|
bind(registries: {
|
|
37
|
-
agents:
|
|
38
|
-
models:
|
|
37
|
+
agents: IAgentRegistry;
|
|
38
|
+
models: IModelRegistry;
|
|
39
39
|
}): void;
|
|
40
40
|
get(tid: string, include?: ThreadInclude): Promise<Thread | null>;
|
|
41
41
|
list(options?: ThreadListOptions): Promise<Thread[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/storage/in-memory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OA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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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LanguageModel, LanguageModelRequest, LanguageModelResponse } from "@kernl-sdk/protocol";
|
|
2
|
-
import type { ThreadStreamEvent } from "../../thread/types.js";
|
|
1
|
+
import { LanguageModel, LanguageModelRequest, LanguageModelResponse, LanguageModelStreamEvent } from "@kernl-sdk/protocol";
|
|
3
2
|
/**
|
|
4
3
|
* A mock language model that echoes the user input back as an assistant message.
|
|
5
4
|
* Useful for testing the execution flow without calling a real LLM.
|
|
@@ -11,7 +10,7 @@ export declare class MockLanguageModel implements LanguageModel {
|
|
|
11
10
|
readonly provider = "mock";
|
|
12
11
|
readonly modelId = "mock-model";
|
|
13
12
|
generate(request: LanguageModelRequest): Promise<LanguageModelResponse>;
|
|
14
|
-
stream(request: LanguageModelRequest): AsyncIterable<
|
|
13
|
+
stream(request: LanguageModelRequest): AsyncIterable<LanguageModelStreamEvent>;
|
|
15
14
|
/**
|
|
16
15
|
* Extract text from the input (LanguageModelItem[])
|
|
17
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/thread/__tests__/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/thread/__tests__/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EAGrB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAE7B;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACrD,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,QAAQ,CAAC,QAAQ,UAAU;IAC3B,QAAQ,CAAC,OAAO,gBAAgB;IAE1B,QAAQ,CACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAgC1B,MAAM,CACX,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAAC,wBAAwB,CAAC;IAK1C;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,UAAU;CAGnB"}
|
package/dist/thread/thread.d.ts
CHANGED
|
@@ -113,6 +113,10 @@ export declare class Thread<TContext = unknown, TOutput extends AgentOutputType
|
|
|
113
113
|
* TODO: Emit thread.stop when cancelled (neither result nor error set)
|
|
114
114
|
*/
|
|
115
115
|
cancel(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Emit an agent event with common fields auto-filled.
|
|
118
|
+
*/
|
|
119
|
+
private emit;
|
|
116
120
|
/**
|
|
117
121
|
* Perform the actions returned by the model
|
|
118
122
|
*/
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;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