kernl 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-check-types.log +1 -1
  3. package/CHANGELOG.md +44 -0
  4. package/dist/agent/__tests__/concurrency.test.js +1 -1
  5. package/dist/agent/__tests__/run.test.js +1 -1
  6. package/dist/agent/__tests__/systools.test.d.ts +2 -0
  7. package/dist/agent/__tests__/systools.test.d.ts.map +1 -0
  8. package/dist/agent/__tests__/systools.test.js +121 -0
  9. package/dist/{types/agent.d.ts → agent/types.d.ts} +19 -2
  10. package/dist/agent/types.d.ts.map +1 -0
  11. package/dist/agent.d.ts +48 -6
  12. package/dist/agent.d.ts.map +1 -1
  13. package/dist/agent.js +100 -13
  14. package/dist/api/models/thread.d.ts +1 -1
  15. package/dist/api/resources/agents/agents.d.ts +38 -0
  16. package/dist/api/resources/agents/agents.d.ts.map +1 -0
  17. package/dist/api/resources/agents/agents.js +44 -0
  18. package/dist/api/resources/agents/index.d.ts +2 -0
  19. package/dist/api/resources/agents/index.d.ts.map +1 -0
  20. package/dist/api/resources/agents/index.js +1 -0
  21. package/dist/api/resources/threads/threads.d.ts +1 -1
  22. package/dist/api/resources/threads/threads.d.ts.map +1 -1
  23. package/dist/api/resources/threads/threads.js +1 -1
  24. package/dist/api/resources/threads/types.d.ts +2 -2
  25. package/dist/api/resources/threads/types.d.ts.map +1 -1
  26. package/dist/context.d.ts +10 -4
  27. package/dist/context.d.ts.map +1 -1
  28. package/dist/context.js +5 -0
  29. package/dist/guardrail.d.ts +2 -2
  30. package/dist/index.d.ts +5 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +4 -3
  33. package/dist/internal.d.ts +2 -2
  34. package/dist/internal.js +1 -1
  35. package/dist/kernl/index.d.ts +1 -1
  36. package/dist/kernl/index.d.ts.map +1 -1
  37. package/dist/kernl/index.js +0 -1
  38. package/dist/kernl/kernl.d.ts +11 -20
  39. package/dist/kernl/kernl.d.ts.map +1 -1
  40. package/dist/kernl/kernl.js +37 -34
  41. package/dist/kernl/types.d.ts +91 -0
  42. package/dist/kernl/types.d.ts.map +1 -0
  43. package/dist/lib/error.d.ts +2 -2
  44. package/dist/lifecycle.d.ts +2 -2
  45. package/dist/memory/codec.d.ts +32 -0
  46. package/dist/memory/codec.d.ts.map +1 -0
  47. package/dist/memory/codec.js +97 -0
  48. package/dist/memory/codecs/domain.d.ts +34 -0
  49. package/dist/memory/codecs/domain.d.ts.map +1 -0
  50. package/dist/memory/codecs/domain.js +99 -0
  51. package/dist/memory/codecs/identity.d.ts +12 -0
  52. package/dist/memory/codecs/identity.d.ts.map +1 -0
  53. package/dist/memory/codecs/identity.js +17 -0
  54. package/dist/memory/codecs/index.d.ts +31 -0
  55. package/dist/memory/codecs/index.d.ts.map +1 -0
  56. package/dist/memory/codecs/index.js +39 -0
  57. package/dist/memory/codecs/tpuf.d.ts +38 -0
  58. package/dist/memory/codecs/tpuf.d.ts.map +1 -0
  59. package/dist/memory/codecs/tpuf.js +90 -0
  60. package/dist/memory/encoder.d.ts +29 -0
  61. package/dist/memory/encoder.d.ts.map +1 -0
  62. package/dist/memory/encoder.js +45 -0
  63. package/dist/memory/handle.d.ts +89 -0
  64. package/dist/memory/handle.d.ts.map +1 -0
  65. package/dist/memory/handle.js +128 -0
  66. package/dist/memory/index.d.ts +12 -0
  67. package/dist/memory/index.d.ts.map +1 -0
  68. package/dist/memory/index.js +7 -0
  69. package/dist/memory/indexes.d.ts +91 -0
  70. package/dist/memory/indexes.d.ts.map +1 -0
  71. package/dist/memory/indexes.js +7 -0
  72. package/dist/memory/memory.d.ts +55 -0
  73. package/dist/memory/memory.d.ts.map +1 -0
  74. package/dist/memory/memory.js +113 -0
  75. package/dist/memory/schema.d.ts +41 -0
  76. package/dist/memory/schema.d.ts.map +1 -0
  77. package/dist/memory/schema.js +112 -0
  78. package/dist/memory/store.d.ts +36 -0
  79. package/dist/memory/store.d.ts.map +1 -0
  80. package/dist/memory/store.js +4 -0
  81. package/dist/memory/types.d.ts +250 -0
  82. package/dist/memory/types.d.ts.map +1 -0
  83. package/dist/memory/types.js +4 -0
  84. package/dist/storage/base.d.ts +6 -1
  85. package/dist/storage/base.d.ts.map +1 -1
  86. package/dist/storage/in-memory.d.ts +24 -2
  87. package/dist/storage/in-memory.d.ts.map +1 -1
  88. package/dist/storage/in-memory.js +131 -0
  89. package/dist/storage/thread.d.ts +1 -1
  90. package/dist/thread/__tests__/integration.test.js +1 -1
  91. package/dist/thread/__tests__/mock.d.ts +1 -1
  92. package/dist/thread/__tests__/namespace.test.js +1 -1
  93. package/dist/thread/__tests__/thread.test.js +1 -1
  94. package/dist/thread/thread.d.ts +2 -2
  95. package/dist/thread/thread.d.ts.map +1 -1
  96. package/dist/thread/thread.js +3 -1
  97. package/dist/{types/thread.d.ts → thread/types.d.ts} +2 -2
  98. package/dist/thread/types.d.ts.map +1 -0
  99. package/dist/thread/utils.d.ts +2 -2
  100. package/dist/thread/utils.d.ts.map +1 -1
  101. package/dist/tool/index.d.ts +1 -0
  102. package/dist/tool/index.d.ts.map +1 -1
  103. package/dist/tool/index.js +2 -0
  104. package/dist/tool/sys/index.d.ts +7 -0
  105. package/dist/tool/sys/index.d.ts.map +1 -0
  106. package/dist/tool/sys/index.js +6 -0
  107. package/dist/tool/sys/memory.d.ts +14 -0
  108. package/dist/tool/sys/memory.d.ts.map +1 -0
  109. package/dist/tool/sys/memory.js +103 -0
  110. package/dist/tool/tool.d.ts +1 -1
  111. package/dist/tool/tool.d.ts.map +1 -1
  112. package/dist/tool/tool.js +2 -2
  113. package/package.json +4 -2
  114. package/src/agent/__tests__/systools.test.ts +146 -0
  115. package/src/{types/agent.ts → agent/types.ts} +22 -1
  116. package/src/agent.ts +144 -36
  117. package/src/api/__tests__/threads.test.ts +2 -2
  118. package/src/api/models/thread.ts +1 -1
  119. package/src/api/resources/agents/agents.ts +56 -0
  120. package/src/api/resources/agents/index.ts +1 -0
  121. package/src/api/resources/threads/events.ts +1 -1
  122. package/src/api/resources/threads/threads.ts +2 -2
  123. package/src/api/resources/threads/types.ts +2 -2
  124. package/src/context.ts +14 -136
  125. package/src/guardrail.ts +2 -2
  126. package/src/index.ts +35 -6
  127. package/src/internal.ts +2 -2
  128. package/src/kernl/index.ts +8 -0
  129. package/src/{kernl.ts → kernl/kernl.ts} +50 -10
  130. package/src/kernl/types.ts +106 -0
  131. package/src/lib/error.ts +2 -2
  132. package/src/lifecycle.ts +2 -2
  133. package/src/memory/codecs/domain.ts +115 -0
  134. package/src/memory/codecs/identity.ts +28 -0
  135. package/src/memory/codecs/index.ts +61 -0
  136. package/src/memory/codecs/tpuf.ts +115 -0
  137. package/src/memory/encoder.ts +56 -0
  138. package/src/memory/handle.ts +189 -0
  139. package/src/memory/index.ts +49 -0
  140. package/src/memory/indexes.ts +108 -0
  141. package/src/memory/memory.ts +151 -0
  142. package/src/memory/schema.ts +142 -0
  143. package/src/memory/store.ts +47 -0
  144. package/src/memory/types.ts +282 -0
  145. package/src/storage/__tests__/in-memory.test.ts +1 -1
  146. package/src/storage/base.ts +7 -1
  147. package/src/storage/in-memory.ts +170 -2
  148. package/src/storage/thread.ts +1 -1
  149. package/src/thread/__tests__/integration.test.ts +1 -1
  150. package/src/thread/__tests__/mock.ts +1 -1
  151. package/src/thread/__tests__/thread.test.ts +1 -1
  152. package/src/thread/thread.ts +5 -3
  153. package/src/{types/thread.ts → thread/types.ts} +1 -1
  154. package/src/thread/utils.ts +2 -2
  155. package/src/tool/index.ts +3 -0
  156. package/src/tool/sys/index.ts +7 -0
  157. package/src/tool/sys/memory.ts +120 -0
  158. package/src/tool/tool.ts +8 -4
  159. package/tsconfig.tsbuildinfo +1 -0
  160. package/dist/api/__tests__/cursor-page.test.d.ts +0 -2
  161. package/dist/api/__tests__/cursor-page.test.d.ts.map +0 -1
  162. package/dist/api/__tests__/cursor-page.test.js +0 -414
  163. package/dist/api/__tests__/offset-page.test.d.ts +0 -2
  164. package/dist/api/__tests__/offset-page.test.d.ts.map +0 -1
  165. package/dist/api/__tests__/offset-page.test.js +0 -510
  166. package/dist/api/pagination/base.d.ts +0 -48
  167. package/dist/api/pagination/base.d.ts.map +0 -1
  168. package/dist/api/pagination/base.js +0 -45
  169. package/dist/api/pagination/cursor.d.ts +0 -44
  170. package/dist/api/pagination/cursor.d.ts.map +0 -1
  171. package/dist/api/pagination/cursor.js +0 -52
  172. package/dist/api/pagination/offset.d.ts +0 -42
  173. package/dist/api/pagination/offset.d.ts.map +0 -1
  174. package/dist/api/pagination/offset.js +0 -55
  175. package/dist/kernl/threads.d.ts +0 -110
  176. package/dist/kernl/threads.d.ts.map +0 -1
  177. package/dist/kernl/threads.js +0 -126
  178. package/dist/kernl.d.ts +0 -51
  179. package/dist/kernl.d.ts.map +0 -1
  180. package/dist/kernl.js +0 -91
  181. package/dist/types/agent.d.ts.map +0 -1
  182. package/dist/types/kernl.d.ts +0 -42
  183. package/dist/types/kernl.d.ts.map +0 -1
  184. package/dist/types/thread.d.ts.map +0 -1
  185. package/src/api/__tests__/cursor-page.test.ts +0 -512
  186. package/src/api/__tests__/offset-page.test.ts +0 -624
  187. package/src/api/pagination/base.ts +0 -79
  188. package/src/api/pagination/cursor.ts +0 -86
  189. package/src/api/pagination/offset.ts +0 -89
  190. package/src/types/kernl.ts +0 -51
  191. /package/dist/{types/agent.js → agent/types.js} +0 -0
  192. /package/dist/{types/kernl.js → kernl/types.js} +0 -0
  193. /package/dist/{types/thread.js → thread/types.js} +0 -0
@@ -1,86 +0,0 @@
1
- import { AbstractPage, type PageParamsBase } from "./base";
2
-
3
- export interface CursorPageParams extends PageParamsBase {
4
- /**
5
- * Pagination cursor returned from a previous page.
6
- * If omitted, starts from the beginning of the collection.
7
- */
8
- cursor?: string;
9
- }
10
-
11
- export interface CursorPageResponse<T> {
12
- data: T[];
13
- /**
14
- * Cursor for the next page, or null if there is no next page.
15
- */
16
- next: string | null;
17
- /**
18
- * True if this is the last page (no further pages).
19
- */
20
- last: boolean;
21
- }
22
-
23
- export class CursorPage<
24
- T,
25
- TParams extends CursorPageParams = CursorPageParams,
26
- > extends AbstractPage<T, TParams, CursorPageResponse<T>> {
27
- data: T[];
28
- private readonly _next: string | null;
29
- private readonly _last: boolean;
30
-
31
- constructor(args: {
32
- params: TParams;
33
- response: CursorPageResponse<T>;
34
- loader: (params: TParams) => Promise<CursorPageResponse<T>>;
35
- }) {
36
- super(args);
37
- this.data = args.response.data ?? [];
38
- this._next = args.response.next;
39
- this._last = args.response.last;
40
- }
41
-
42
- /**
43
- * All items contained in this page.
44
- */
45
- get items(): T[] {
46
- return this.data;
47
- }
48
-
49
- /**
50
- * True if this is the last page in the sequence.
51
- *
52
- * When `last` is true, `next()` will return null.
53
- */
54
- get last(): boolean {
55
- if (this._last) return true;
56
- if (!this._next) return true;
57
- return this.data.length === 0;
58
- }
59
-
60
- /**
61
- * Fetch the next page, or null if there is no next page.
62
- */
63
- async next(): Promise<this | null> {
64
- if (this.last) {
65
- return null;
66
- }
67
-
68
- if (!this._next) {
69
- return null;
70
- }
71
-
72
- const nextParams: TParams = {
73
- ...(this.params as TParams),
74
- cursor: this._next,
75
- };
76
-
77
- const res = await this.loader(nextParams);
78
- const page = new CursorPage<T, TParams>({
79
- params: nextParams,
80
- response: res,
81
- loader: this.loader,
82
- }) as this;
83
-
84
- return page;
85
- }
86
- }
@@ -1,89 +0,0 @@
1
- import { AbstractPage, type PageParamsBase } from "./base";
2
-
3
- export interface OffsetPageParams extends PageParamsBase {
4
- /**
5
- * Number of items to skip from the beginning of the collection.
6
- */
7
- offset?: number;
8
- }
9
-
10
- export interface OffsetPageResponse<T> {
11
- data: T[];
12
- offset: number;
13
- limit: number;
14
- /**
15
- * Optional total count when the underlying store can provide it.
16
- */
17
- total?: number;
18
- }
19
-
20
- export class OffsetPage<
21
- T,
22
- TParams extends OffsetPageParams = OffsetPageParams,
23
- > extends AbstractPage<T, TParams, OffsetPageResponse<T>> {
24
- data: T[];
25
- offset: number;
26
- limit: number;
27
- total?: number;
28
-
29
- constructor(args: {
30
- params: TParams;
31
- response: OffsetPageResponse<T>;
32
- loader: (params: TParams) => Promise<OffsetPageResponse<T>>;
33
- }) {
34
- super(args);
35
- this.data = args.response.data ?? [];
36
- this.offset = args.response.offset;
37
- this.limit = args.response.limit;
38
- this.total = args.response.total;
39
- }
40
-
41
- /**
42
- * All items contained in this page.
43
- */
44
- get items(): T[] {
45
- return this.data;
46
- }
47
-
48
- /**
49
- * True if this is the last page in the sequence.
50
- *
51
- * When `last` is true, `next()` will return null.
52
- */
53
- get last(): boolean {
54
- if (this.data.length === 0) {
55
- return true;
56
- }
57
-
58
- const next = (this.offset ?? 0) + (this.limit ?? 0);
59
- if (this.total != null && next >= this.total) {
60
- return true;
61
- }
62
-
63
- return false;
64
- }
65
-
66
- /**
67
- * Fetch the next page, or null if there is no next page.
68
- */
69
- async next(): Promise<this | null> {
70
- if (this.last) {
71
- return null;
72
- }
73
-
74
- const next = (this.offset ?? 0) + (this.limit ?? 0);
75
- const nextParams: TParams = {
76
- ...(this.params as TParams),
77
- offset: next,
78
- };
79
-
80
- const res = await this.loader(nextParams);
81
- const page = new OffsetPage<T, TParams>({
82
- params: nextParams,
83
- response: res,
84
- loader: this.loader,
85
- }) as this;
86
-
87
- return page;
88
- }
89
- }
@@ -1,51 +0,0 @@
1
- import { LanguageModel } from "@kernl-sdk/protocol";
2
-
3
- import { Agent } from "@/agent";
4
- import { KernlStorage } from "@/storage";
5
-
6
- /**
7
- * Storage configuration for Kernl.
8
- */
9
- export interface StorageOptions {
10
- /**
11
- * Relational database storage (threads, tasks, traces).
12
- */
13
- db?: KernlStorage;
14
-
15
- // Future storage layers (deferred):
16
- // vector?: VectorStore;
17
- // blob?: BlobStore;
18
- // lake?: DataLake;
19
- }
20
-
21
- /**
22
- * Configuration options for creating a Kernl instance.
23
- */
24
- export interface KernlOptions {
25
- /**
26
- * Storage configuration for persisting threads, tasks, and traces.
27
- */
28
- storage?: StorageOptions;
29
- }
30
-
31
- /**
32
- * Agent registry interface.
33
- *
34
- * Satisfied by Map<string, Agent>.
35
- */
36
- export interface AgentRegistry {
37
- get(id: string): Agent<any> | undefined;
38
- }
39
-
40
- /**
41
- * Model registry interface.
42
- *
43
- * Satisfied by Map<string, LanguageModel>.
44
- * Key format: "provider/modelId"
45
- *
46
- * TODO: Create an exhaustive model registry in the protocol package
47
- * with all supported models and their metadata.
48
- */
49
- export interface ModelRegistry {
50
- get(key: string): LanguageModel | undefined;
51
- }
File without changes
File without changes
File without changes