kernl 0.12.1 → 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.
@@ -1,4 +1,4 @@
1
1
 
2
- > kernl@0.12.1 build /home/runner/work/kernl/kernl/packages/kernl
2
+ > kernl@0.12.2 build /home/runner/work/kernl/kernl/packages/kernl
3
3
  > tsc && tsc-alias --resolve-full-paths
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.12.1
4
10
 
5
11
  ### Patch 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: Map<string, BaseAgent>);
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,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,K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M,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"}
@@ -45,6 +45,6 @@ export class RAgents {
45
45
  * Unregister an agent at runtime.
46
46
  */
47
47
  unregister(id) {
48
- return this.registry.delete(id);
48
+ return this.registry.unregister(id);
49
49
  }
50
50
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { Kernl } from "./kernl/index.js";
2
- export type { KernlOptions, StorageOptions, AgentRegistry, ModelRegistry, } from "./kernl/index.js";
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";
@@ -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,SAAS,CAAC;AACjB,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,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,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
@@ -1,4 +1,5 @@
1
1
  export { Kernl } from "./kernl/index.js";
2
+ export { AgentRegistry, ModelRegistry } from "./kernl/index.js";
2
3
  export { Agent } from "./agent.js";
3
4
  export { Context } from "./context.js";
4
5
  // --- realtime ---
@@ -1,3 +1,4 @@
1
1
  export { Kernl } from "./kernl.js";
2
- export type { KernlOptions, StorageOptions, MemoryOptions, AgentRegistry, ModelRegistry, } from "./types.js";
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,aAAa,EACb,aAAa,GACd,MAAM,SAAS,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,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"}
@@ -1 +1,2 @@
1
1
  export { Kernl } from "./kernl.js";
2
+ export { AgentRegistry, ModelRegistry } from "./registry.js";
@@ -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 initializeMemory;
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;AACz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AAM,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"}
@@ -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 = new Map();
16
- _models = new Map();
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.initializeMemory();
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.set(agent.id, agent);
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
- const key = `${agent.model.provider}/${agent.model.modelId}`;
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
- initializeMemory() {
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
+ }
@@ -74,7 +74,7 @@ export interface KernlOptions {
74
74
  *
75
75
  * Satisfied by Map<string, BaseAgent>.
76
76
  */
77
- export interface AgentRegistry {
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 ModelRegistry {
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,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,EAAE,CAAC,EAAE,YAAY,CAAC;IAElB;;;OAGG;IACH,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,oBAA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,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"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Core storage contracts.
3
3
  */
4
- import type { AgentRegistry, ModelRegistry } from "../kernl/types.js";
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: AgentRegistry;
28
- models: ModelRegistry;
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,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,g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AI,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 { AgentRegistry, ModelRegistry } from "../kernl/types.js";
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: AgentRegistry;
22
- models: ModelRegistry;
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: AgentRegistry;
38
- models: ModelRegistry;
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,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EAGrB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,eAAgB,YAAW,YAAY;IAClD,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;;IAO9B,IAAI,CAAC,UAAU,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAIlE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAM/D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,KAAK,IAAI,OA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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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kernl",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "A modern AI agent framework",
5
5
  "keywords": [
6
6
  "kernl",
@@ -35,8 +35,8 @@
35
35
  "@modelcontextprotocol/sdk": "^1.20.2",
36
36
  "yaml": "^2.8.2",
37
37
  "@kernl-sdk/protocol": "0.5.0",
38
- "@kernl-sdk/retrieval": "0.1.9",
39
- "@kernl-sdk/shared": "^0.4.0"
38
+ "@kernl-sdk/shared": "^0.4.0",
39
+ "@kernl-sdk/retrieval": "0.1.9"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "zod": "^4.1.8"
@@ -4,7 +4,7 @@ import { message, RUNNING } from "@kernl-sdk/protocol";
4
4
 
5
5
  import { Agent } from "@/agent";
6
6
  import { InMemoryThreadStore } from "@/storage/in-memory";
7
- import type { AgentRegistry, ModelRegistry } from "@/kernl/types";
7
+ import type { IAgentRegistry, IModelRegistry } from "@/kernl/types";
8
8
  import type { NewThread } from "@/storage";
9
9
  import { tevent } from "@/thread/utils";
10
10
  import type { ThreadEvent } from "@/thread/types";
@@ -14,8 +14,8 @@ import type { MThread } from "@/api/models";
14
14
  function createTestStore() {
15
15
  const store = new InMemoryThreadStore();
16
16
 
17
- const agents: AgentRegistry & Map<string, Agent> = new Map();
18
- const models: ModelRegistry & Map<string, any> = new Map();
17
+ const agents: IAgentRegistry & Map<string, Agent> = new Map();
18
+ const models: IModelRegistry & Map<string, any> = new Map();
19
19
 
20
20
  const model = {
21
21
  spec: "1.0" as const,
@@ -1,7 +1,7 @@
1
1
  import { Agent } from "@/agent";
2
- import type { BaseAgent } from "@/agent/base";
3
2
  import type { AgentOutputType } from "@/agent/types";
4
3
  import type { UnknownContext } from "@/context";
4
+ import type { AgentRegistry } from "@/kernl/registry";
5
5
  import type { TextOutput } from "@/thread/types";
6
6
 
7
7
  /**
@@ -16,7 +16,7 @@ import type { TextOutput } from "@/thread/types";
16
16
  * to realtime agents is needed, add a separate `kernl.realtimeAgents` resource.
17
17
  */
18
18
  export class RAgents {
19
- constructor(private readonly registry: Map<string, BaseAgent>) {}
19
+ constructor(private readonly registry: AgentRegistry) {}
20
20
 
21
21
  /**
22
22
  * Get a live Agent instance by id.
@@ -57,6 +57,6 @@ export class RAgents {
57
57
  * Unregister an agent at runtime.
58
58
  */
59
59
  unregister(id: string): boolean {
60
- return this.registry.delete(id);
60
+ return this.registry.unregister(id);
61
61
  }
62
62
  }
package/src/index.ts CHANGED
@@ -2,9 +2,10 @@ export { Kernl } from "./kernl";
2
2
  export type {
3
3
  KernlOptions,
4
4
  StorageOptions,
5
- AgentRegistry,
6
- ModelRegistry,
5
+ IAgentRegistry,
6
+ IModelRegistry,
7
7
  } from "./kernl";
8
+ export { AgentRegistry, ModelRegistry } from "./kernl";
8
9
  export { Agent } from "./agent";
9
10
  export { Context } from "./context";
10
11
 
@@ -1,8 +1,9 @@
1
1
  export { Kernl } from "./kernl";
2
+ export { AgentRegistry, ModelRegistry } from "./registry";
2
3
  export type {
3
4
  KernlOptions,
4
5
  StorageOptions,
5
6
  MemoryOptions,
6
- AgentRegistry,
7
- ModelRegistry,
7
+ IAgentRegistry,
8
+ IModelRegistry,
8
9
  } from "./types";
@@ -6,8 +6,6 @@ import { KernlHooks } from "@/lifecycle";
6
6
  import type { Thread } from "@/thread";
7
7
  import type { ResolvedAgentResponse } from "@/guardrail";
8
8
  import { InMemoryStorage, type KernlStorage } from "@/storage";
9
- import { RThreads } from "@/api/resources/threads";
10
- import { RAgents } from "@/api/resources/agents";
11
9
  import {
12
10
  Memory,
13
11
  MemoryByteEncoder,
@@ -16,10 +14,13 @@ import {
16
14
  } from "@/memory";
17
15
 
18
16
  import { logger } from "@/lib/logger";
19
-
17
+ import { RThreads } from "@/api/resources/threads";
18
+ import { RAgents } from "@/api/resources/agents";
20
19
  import type { ThreadExecuteResult, ThreadStreamEvent } from "@/thread/types";
21
20
  import type { AgentOutputType } from "@/agent/types";
21
+
22
22
  import type { KernlOptions, MemoryOptions, StorageOptions } from "./types";
23
+ import { AgentRegistry, ModelRegistry } from "./registry";
23
24
 
24
25
  /**
25
26
  * The kernl - manages agent processes, scheduling, and task lifecycle.
@@ -28,15 +29,14 @@ import type { KernlOptions, MemoryOptions, StorageOptions } from "./types";
28
29
  * tracing.
29
30
  */
30
31
  export class Kernl extends KernlHooks {
31
- private readonly _agents: Map<string, BaseAgent> = new Map();
32
- private readonly _models: Map<string, LanguageModel> = new Map();
32
+ private readonly _agents: AgentRegistry;
33
+ private readonly _models: ModelRegistry;
34
+ private readonly _memopts: MemoryOptions | undefined;
35
+ private readonly _storopts: StorageOptions | undefined;
33
36
 
34
37
  readonly storage: KernlStorage;
35
38
  athreads: Map<string, Thread<any, any>> = new Map(); /* active threads */
36
39
 
37
- private readonly _memopts: MemoryOptions | undefined;
38
- private readonly _storopts: StorageOptions | undefined;
39
-
40
40
  private warnings = {
41
41
  embedding: false, // "Embeddings are not configured. If you want memories to auto-embed text content..."
42
42
  vector: false, // "No vector storage configured. The memories.search() function will not be..."
@@ -53,18 +53,20 @@ export class Kernl extends KernlHooks {
53
53
  this._memopts = options.memory;
54
54
  this._storopts = options.storage;
55
55
 
56
+ this._agents = new AgentRegistry();
57
+ this._models = new ModelRegistry();
56
58
  this.storage = options.storage?.db ?? new InMemoryStorage();
57
59
  this.storage.bind({ agents: this._agents, models: this._models });
58
60
  this.threads = new RThreads(this.storage.threads);
59
61
  this.agents = new RAgents(this._agents);
60
- this.memories = this.initializeMemory();
62
+ this.memories = this.initmem();
61
63
  }
62
64
 
63
65
  /**
64
66
  * Registers a new agent with the kernl instance.
65
67
  */
66
68
  register(agent: BaseAgent<any>): void {
67
- this._agents.set(agent.id, agent);
69
+ this._agents.register(agent);
68
70
  agent.bind(this);
69
71
 
70
72
  // memory config warnings (log once)
@@ -88,10 +90,7 @@ export class Kernl extends KernlHooks {
88
90
 
89
91
  // auto-populate model registry for storage hydration (llm agents only - for now)
90
92
  if (agent.kind === "llm") {
91
- const key = `${agent.model.provider}/${agent.model.modelId}`;
92
- if (!this._models.has(key)) {
93
- this._models.set(key, agent.model as LanguageModel);
94
- }
93
+ this._models.register(agent.model as LanguageModel);
95
94
  }
96
95
  }
97
96
 
@@ -101,6 +100,7 @@ export class Kernl extends KernlHooks {
101
100
  async spawn<TContext, TOutput extends AgentOutputType>(
102
101
  thread: Thread<TContext, TOutput>,
103
102
  ): Promise<ThreadExecuteResult<ResolvedAgentResponse<TOutput>>> {
103
+ this._models.register(thread.model);
104
104
  this.athreads.set(thread.tid, thread);
105
105
  try {
106
106
  return await thread.execute();
@@ -117,6 +117,7 @@ export class Kernl extends KernlHooks {
117
117
  async schedule<TContext, TOutput extends AgentOutputType>(
118
118
  thread: Thread<TContext, TOutput>,
119
119
  ): Promise<ThreadExecuteResult<ResolvedAgentResponse<TOutput>>> {
120
+ this._models.register(thread.model);
120
121
  this.athreads.set(thread.tid, thread);
121
122
  try {
122
123
  return await thread.execute();
@@ -133,6 +134,7 @@ export class Kernl extends KernlHooks {
133
134
  async *spawnStream<TContext, TOutput extends AgentOutputType>(
134
135
  thread: Thread<TContext, TOutput>,
135
136
  ): AsyncIterable<ThreadStreamEvent> {
137
+ this._models.register(thread.model);
136
138
  this.athreads.set(thread.tid, thread);
137
139
  try {
138
140
  yield* thread.stream();
@@ -149,6 +151,7 @@ export class Kernl extends KernlHooks {
149
151
  async *scheduleStream<TContext, TOutput extends AgentOutputType>(
150
152
  thread: Thread<TContext, TOutput>,
151
153
  ): AsyncIterable<ThreadStreamEvent> {
154
+ this._models.register(thread.model);
152
155
  this.athreads.set(thread.tid, thread);
153
156
  try {
154
157
  yield* thread.stream();
@@ -164,7 +167,7 @@ export class Kernl extends KernlHooks {
164
167
  *
165
168
  * Initialize the memory system based on the storage + memory configuration.
166
169
  */
167
- private initializeMemory(): Memory {
170
+ private initmem(): Memory {
168
171
  const embeddingModel = this._memopts?.embedding;
169
172
  const embedder = embeddingModel
170
173
  ? typeof embeddingModel === "string"
@@ -0,0 +1,69 @@
1
+ import type { LanguageModel } from "@kernl-sdk/protocol";
2
+
3
+ import type { BaseAgent } from "@/agent/base";
4
+ import type { IAgentRegistry, IModelRegistry } from "./types";
5
+
6
+ /**
7
+ * Registry for language models used by threads.
8
+ *
9
+ * Models are keyed by "{provider}/{modelId}" and must be registered before
10
+ * storage can hydrate threads that reference them.
11
+ */
12
+ export class ModelRegistry implements IModelRegistry {
13
+ private readonly models: Map<string, LanguageModel> = new Map();
14
+
15
+ /**
16
+ * Register a model instance. Idempotent - only adds if not already present.
17
+ */
18
+ register(model: LanguageModel): void {
19
+ const key = `${model.provider}/${model.modelId}`;
20
+ if (!this.models.has(key)) {
21
+ this.models.set(key, model);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Get a model by its composite key ("{provider}/{modelId}").
27
+ */
28
+ get(key: string): LanguageModel | undefined {
29
+ return this.models.get(key);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Registry for agents.
35
+ *
36
+ * Agents are keyed by their id and must be registered before threads can
37
+ * reference them.
38
+ */
39
+ export class AgentRegistry implements IAgentRegistry {
40
+ private readonly agents: Map<string, BaseAgent<any>> = new Map();
41
+
42
+ /**
43
+ * Register an agent instance. Replaces existing agent with same id.
44
+ */
45
+ register(agent: BaseAgent<any>): void {
46
+ this.agents.set(agent.id, agent);
47
+ }
48
+
49
+ /**
50
+ * Get an agent by its id.
51
+ */
52
+ get(id: string): BaseAgent<any> | undefined {
53
+ return this.agents.get(id);
54
+ }
55
+
56
+ /**
57
+ * Unregister an agent by id.
58
+ */
59
+ unregister(id: string): boolean {
60
+ return this.agents.delete(id);
61
+ }
62
+
63
+ /**
64
+ * List all registered agents.
65
+ */
66
+ values(): IterableIterator<BaseAgent<any>> {
67
+ return this.agents.values();
68
+ }
69
+ }
@@ -89,7 +89,7 @@ export interface KernlOptions {
89
89
  *
90
90
  * Satisfied by Map<string, BaseAgent>.
91
91
  */
92
- export interface AgentRegistry {
92
+ export interface IAgentRegistry {
93
93
  get(id: string): BaseAgent<any> | undefined;
94
94
  }
95
95
 
@@ -102,6 +102,6 @@ export interface AgentRegistry {
102
102
  * TODO: Create an exhaustive model registry in the protocol package
103
103
  * with all supported models and their metadata.
104
104
  */
105
- export interface ModelRegistry {
105
+ export interface IModelRegistry {
106
106
  get(key: string): LanguageModel | undefined;
107
107
  }
@@ -2,7 +2,7 @@
2
2
  * Core storage contracts.
3
3
  */
4
4
 
5
- import type { AgentRegistry, ModelRegistry } from "@/kernl/types";
5
+ import type { IAgentRegistry, IModelRegistry } from "@/kernl/types";
6
6
  import type { ThreadStore } from "./thread";
7
7
  import type { MemoryStore } from "@/memory/store";
8
8
 
@@ -30,7 +30,7 @@ export interface KernlStorage {
30
30
  *
31
31
  * Called by Kernl after construction to wire up agent/model lookups.
32
32
  */
33
- bind(registries: { agents: AgentRegistry; models: ModelRegistry }): void;
33
+ bind(registries: { agents: IAgentRegistry; models: IModelRegistry }): void;
34
34
 
35
35
  /**
36
36
  * Execute a function within a transaction.
@@ -25,7 +25,7 @@ import type {
25
25
  SortOrder,
26
26
  } from "@/storage";
27
27
  import type { ThreadEvent, ThreadState } from "@/thread/types";
28
- import type { AgentRegistry, ModelRegistry } from "@/kernl/types";
28
+ import type { IAgentRegistry, IModelRegistry } from "@/kernl/types";
29
29
  import type {
30
30
  MemoryStore,
31
31
  MemoryRecord,
@@ -47,7 +47,7 @@ export class InMemoryStorage implements KernlStorage {
47
47
  this.memories = new InMemoryMemoryStore();
48
48
  }
49
49
 
50
- bind(registries: { agents: AgentRegistry; models: ModelRegistry }): void {
50
+ bind(registries: { agents: IAgentRegistry; models: IModelRegistry }): void {
51
51
  this.threads.bind(registries);
52
52
  }
53
53
 
@@ -93,10 +93,10 @@ interface ThreadData {
93
93
  export class InMemoryThreadStore implements ThreadStore {
94
94
  private threads = new Map<string, ThreadData>();
95
95
  private events = new Map<string, ThreadEvent[]>(); // tid -> events
96
- private registries: { agents: AgentRegistry; models: ModelRegistry } | null =
96
+ private registries: { agents: IAgentRegistry; models: IModelRegistry } | null =
97
97
  null;
98
98
 
99
- bind(registries: { agents: AgentRegistry; models: ModelRegistry }): void {
99
+ bind(registries: { agents: IAgentRegistry; models: IModelRegistry }): void {
100
100
  this.registries = registries;
101
101
  }
102
102