@agentick/core 0.3.0 → 0.4.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/README.md +22 -10
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/agentick-instance.js +1 -1
- package/dist/agentick-instance.js.map +1 -1
- package/dist/app/session.d.ts +1 -1
- package/dist/app/session.d.ts.map +1 -1
- package/dist/app/session.js +25 -25
- package/dist/app/session.js.map +1 -1
- package/dist/app/types.d.ts +33 -33
- package/dist/app/types.d.ts.map +1 -1
- package/dist/engine/tool-executor.js +3 -3
- package/dist/engine/tool-executor.js.map +1 -1
- package/dist/procedure/index.d.ts.map +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/{test-environment.d.ts → test-runner.d.ts} +19 -19
- package/dist/testing/test-runner.d.ts.map +1 -0
- package/dist/testing/{test-environment.js → test-runner.js} +13 -13
- package/dist/testing/test-runner.js.map +1 -0
- package/dist/tool/tool.d.ts +47 -1
- package/dist/tool/tool.d.ts.map +1 -1
- package/dist/tool/tool.js +51 -14
- package/dist/tool/tool.js.map +1 -1
- package/package.json +3 -3
- package/dist/testing/test-environment.d.ts.map +0 -1
- package/dist/testing/test-environment.js.map +0 -1
package/README.md
CHANGED
|
@@ -592,6 +592,18 @@ const WeatherTool = createTool({
|
|
|
592
592
|
render: (tickState, ctx) => <Section id="weather-info">Last checked: {lastChecked}</Section>,
|
|
593
593
|
});
|
|
594
594
|
|
|
595
|
+
// Tools can capture tree-scoped context via use():
|
|
596
|
+
const ShellTool = createTool({
|
|
597
|
+
name: "shell",
|
|
598
|
+
description: "Execute a command in the sandbox",
|
|
599
|
+
input: z.object({ command: z.string() }),
|
|
600
|
+
use: () => ({ sandbox: useSandbox() }), // runs at render time
|
|
601
|
+
handler: async ({ command }, deps) => {
|
|
602
|
+
const result = await deps!.sandbox.exec(command);
|
|
603
|
+
return [{ type: "text", text: result.stdout }];
|
|
604
|
+
},
|
|
605
|
+
});
|
|
606
|
+
|
|
595
607
|
// Use in your app
|
|
596
608
|
function App() {
|
|
597
609
|
return (
|
|
@@ -626,7 +638,7 @@ const app = createApp(MyApp, {
|
|
|
626
638
|
devTools: true, // Enable DevTools emission
|
|
627
639
|
tools: [ExternalTool], // Additional tools (merged with JSX <Tool>s)
|
|
628
640
|
mcpServers: { ... }, // MCP server configs
|
|
629
|
-
|
|
641
|
+
runner: myRunner, // Execution runner (see below)
|
|
630
642
|
});
|
|
631
643
|
```
|
|
632
644
|
|
|
@@ -961,14 +973,14 @@ await run(<Agent query="default" />, { props: { query: "override" }, model, mess
|
|
|
961
973
|
|
|
962
974
|
`createApp` takes a component function and returns a reusable app with session management, persistence, and middleware support.
|
|
963
975
|
|
|
964
|
-
## Execution
|
|
976
|
+
## Execution Runners
|
|
965
977
|
|
|
966
|
-
An `
|
|
978
|
+
An `ExecutionRunner` controls the execution backend — how compiled context reaches the model and how tool calls are routed. The default is the standard model → tool_use protocol. Swap in a different runner to change the entire execution model without touching your agent code.
|
|
967
979
|
|
|
968
980
|
```tsx
|
|
969
|
-
import { createApp, type
|
|
981
|
+
import { createApp, type ExecutionRunner } from "@agentick/core";
|
|
970
982
|
|
|
971
|
-
const
|
|
983
|
+
const replRunner: ExecutionRunner = {
|
|
972
984
|
name: "repl",
|
|
973
985
|
|
|
974
986
|
// Transform what the model sees — replace tool schemas with prose descriptions,
|
|
@@ -1008,10 +1020,10 @@ const replEnvironment: ExecutionEnvironment = {
|
|
|
1008
1020
|
};
|
|
1009
1021
|
|
|
1010
1022
|
// Same agent, different execution model
|
|
1011
|
-
const app = createApp(MyAgent, { model,
|
|
1023
|
+
const app = createApp(MyAgent, { model, runner: replRunner });
|
|
1012
1024
|
```
|
|
1013
1025
|
|
|
1014
|
-
The agent's JSX — its `<System>`, `<Timeline>`, `<Tool>` components — stays identical. The
|
|
1026
|
+
The agent's JSX — its `<System>`, `<Timeline>`, `<Tool>` components — stays identical. The runner transforms how that compiled context is consumed and how tool calls execute. This means you can build one agent and run it against multiple backends: standard tool_use for production, a sandboxed REPL for code execution, a human-in-the-loop gateway for approval workflows.
|
|
1015
1027
|
|
|
1016
1028
|
### Interface
|
|
1017
1029
|
|
|
@@ -1022,8 +1034,8 @@ All methods are optional. Omitted methods use default behavior.
|
|
|
1022
1034
|
| `prepareModelInput` | Transform compiled context before the model sees it | Per tick |
|
|
1023
1035
|
| `executeToolCall` | Intercept, transform, or replace tool execution | Per tool call |
|
|
1024
1036
|
| `onSessionInit` | Set up per-session resources (sandbox, workspace) | Once |
|
|
1025
|
-
| `onPersist` | Add
|
|
1026
|
-
| `onRestore` | Restore
|
|
1037
|
+
| `onPersist` | Add runner state to session snapshot | Per save |
|
|
1038
|
+
| `onRestore` | Restore runner state from snapshot | Once |
|
|
1027
1039
|
| `onDestroy` | Clean up resources | Once |
|
|
1028
1040
|
|
|
1029
1041
|
### Use Cases
|
|
@@ -1031,7 +1043,7 @@ All methods are optional. Omitted methods use default behavior.
|
|
|
1031
1043
|
- **REPL/Code Execution**: Replace tool schemas with command descriptions, route `execute` calls to a sandboxed runtime, persist sandbox state across sessions.
|
|
1032
1044
|
- **Human-in-the-Loop**: Transform tool calls into approval requests, gate execution on human confirmation, log decisions.
|
|
1033
1045
|
- **Sandboxing**: Run tools in isolated containers, inject security boundaries, audit tool invocations.
|
|
1034
|
-
- **Testing**: Intercept specific tools to return canned responses, track all lifecycle calls for assertions. See `
|
|
1046
|
+
- **Testing**: Intercept specific tools to return canned responses, track all lifecycle calls for assertions. See `createTestRunner()` in `@agentick/core/testing`.
|
|
1035
1047
|
|
|
1036
1048
|
## DevTools Integration
|
|
1037
1049
|
|