kernl 0.11.2 → 0.12.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 +62 -0
- package/dist/agent/__tests__/run.test.js +2 -2
- package/dist/context.d.ts +2 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/kernl/kernl.d.ts +1 -1
- package/dist/kernl/kernl.d.ts.map +1 -1
- package/dist/lifecycle/__tests__/hooks.test.js +6 -6
- package/dist/storage/__tests__/in-memory.test.js +1 -1
- package/dist/thread/__tests__/fixtures/mock-model.js +3 -3
- package/dist/thread/__tests__/integration.test.js +14 -14
- package/dist/thread/__tests__/thread-persistence.test.js +6 -6
- package/dist/thread/__tests__/thread.test.js +22 -22
- package/dist/thread/thread.js +5 -5
- package/dist/thread/utils.js +5 -5
- package/dist/tool/__tests__/tool.test.js +4 -4
- package/dist/tool/tool.d.ts +1 -2
- package/dist/tool/tool.d.ts.map +1 -1
- package/dist/tool/tool.js +2 -2
- package/dist/tool/toolkit.d.ts +5 -3
- package/dist/tool/toolkit.d.ts.map +1 -1
- package/dist/tool/toolkit.js +3 -1
- package/dist/tool/types.d.ts +1 -2
- package/dist/tool/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/agent/__tests__/run.test.ts +2 -2
- package/src/context.ts +2 -1
- package/src/kernl/kernl.ts +1 -1
- package/src/lifecycle/__tests__/hooks.test.ts +6 -6
- package/src/storage/__tests__/in-memory.test.ts +1 -1
- package/src/thread/__tests__/fixtures/mock-model.ts +3 -3
- package/src/thread/__tests__/integration.test.ts +18 -18
- package/src/thread/__tests__/thread-persistence.test.ts +6 -6
- package/src/thread/__tests__/thread.test.ts +22 -22
- package/src/thread/thread.ts +5 -5
- package/src/thread/utils.ts +5 -5
- package/src/tool/__tests__/tool.test.ts +4 -8
- package/src/tool/tool.ts +3 -3
- package/src/tool/toolkit.ts +5 -3
- package/src/tool/types.ts +0 -2
|
@@ -186,7 +186,7 @@ describe("FunctionTool", () => {
|
|
|
186
186
|
describe("isEnabled", () => {
|
|
187
187
|
it("should default to enabled", async () => {
|
|
188
188
|
const ctx = mockContext();
|
|
189
|
-
const enabled = await simpleStringTool.isEnabled(ctx
|
|
189
|
+
const enabled = await simpleStringTool.isEnabled(ctx);
|
|
190
190
|
|
|
191
191
|
expect(enabled).toBe(true);
|
|
192
192
|
});
|
|
@@ -201,7 +201,7 @@ describe("FunctionTool", () => {
|
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
const ctx = mockContext();
|
|
204
|
-
const enabled = await disabledTool.isEnabled(ctx
|
|
204
|
+
const enabled = await disabledTool.isEnabled(ctx);
|
|
205
205
|
|
|
206
206
|
expect(enabled).toBe(false);
|
|
207
207
|
});
|
|
@@ -224,12 +224,8 @@ describe("FunctionTool", () => {
|
|
|
224
224
|
const enabledCtx = mockContext<MyContext>({ enabled: true });
|
|
225
225
|
const disabledCtx = mockContext<MyContext>({ enabled: false });
|
|
226
226
|
|
|
227
|
-
expect(await conditionalTool.isEnabled(enabledCtx
|
|
228
|
-
|
|
229
|
-
);
|
|
230
|
-
expect(await conditionalTool.isEnabled(disabledCtx, null as any)).toBe(
|
|
231
|
-
false,
|
|
232
|
-
);
|
|
227
|
+
expect(await conditionalTool.isEnabled(enabledCtx)).toBe(true);
|
|
228
|
+
expect(await conditionalTool.isEnabled(disabledCtx)).toBe(false);
|
|
233
229
|
});
|
|
234
230
|
});
|
|
235
231
|
});
|
package/src/tool/tool.ts
CHANGED
|
@@ -62,7 +62,7 @@ export abstract class BaseTool<TContext = UnknownContext> {
|
|
|
62
62
|
/**
|
|
63
63
|
* Determines whether the tool should be exposed to the model for the current run.
|
|
64
64
|
*/
|
|
65
|
-
abstract isEnabled(context: Context<TContext
|
|
65
|
+
abstract isEnabled(context: Context<TContext>): Promise<boolean>;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Serialize this tool for sending to the model
|
|
@@ -117,10 +117,10 @@ export class FunctionTool<
|
|
|
117
117
|
// setup enabled function
|
|
118
118
|
this.isEnabled =
|
|
119
119
|
typeof config.isEnabled === "function"
|
|
120
|
-
? async (context
|
|
120
|
+
? async (context) => {
|
|
121
121
|
const predicate =
|
|
122
122
|
config.isEnabled as ToolEnabledPredicate<TContext>;
|
|
123
|
-
const result = await predicate({ context
|
|
123
|
+
const result = await predicate({ context });
|
|
124
124
|
return Boolean(result);
|
|
125
125
|
}
|
|
126
126
|
: async () =>
|
package/src/tool/toolkit.ts
CHANGED
|
@@ -30,15 +30,17 @@ export abstract class BaseToolkit<TContext = UnknownContext> {
|
|
|
30
30
|
abstract readonly description: string;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* The agent this toolkit is bound to (if any)
|
|
33
|
+
* The agent this toolkit is bound to (if any).
|
|
34
|
+
* Uses `any` to allow toolkits with different context types
|
|
35
|
+
* to be composed in the same agent.
|
|
34
36
|
*/
|
|
35
|
-
protected agent?: BaseAgent<
|
|
37
|
+
protected agent?: BaseAgent<any>;
|
|
36
38
|
|
|
37
39
|
/**
|
|
38
40
|
* Bind this toolkit to an agent.
|
|
39
41
|
* Called by agent constructor.
|
|
40
42
|
*/
|
|
41
|
-
bind(agent: BaseAgent<
|
|
43
|
+
bind(agent: BaseAgent<any>): void {
|
|
42
44
|
this.agent = agent;
|
|
43
45
|
}
|
|
44
46
|
|
package/src/tool/types.ts
CHANGED
|
@@ -227,12 +227,10 @@ export type ToolApprovalFunction<TParameters extends ToolInputParameters> = (
|
|
|
227
227
|
|
|
228
228
|
export type ToolEnabledFunction<TContext = UnknownContext> = (
|
|
229
229
|
context: Context<TContext>,
|
|
230
|
-
agent: BaseAgent<TContext>,
|
|
231
230
|
) => Promise<boolean>;
|
|
232
231
|
|
|
233
232
|
export type ToolEnabledPredicate<TContext = UnknownContext> = (args: {
|
|
234
233
|
context: Context<TContext>;
|
|
235
|
-
agent: BaseAgent<TContext>;
|
|
236
234
|
}) => boolean | Promise<boolean>;
|
|
237
235
|
|
|
238
236
|
type ToolEnabledOption<Context = UnknownContext> =
|