@agentick/core 0.3.0 → 0.5.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 +58 -13
- package/dist/.tsbuildinfo.build +1 -1
- package/dist/agentick-instance.d.ts.map +1 -1
- package/dist/agentick-instance.js +3 -2
- package/dist/agentick-instance.js.map +1 -1
- package/dist/app/session.d.ts +6 -1
- package/dist/app/session.d.ts.map +1 -1
- package/dist/app/session.js +80 -53
- package/dist/app/session.js.map +1 -1
- package/dist/app/types.d.ts +53 -37
- package/dist/app/types.d.ts.map +1 -1
- package/dist/com/object-model.d.ts.map +1 -1
- package/dist/com/object-model.js +8 -3
- package/dist/com/object-model.js.map +1 -1
- package/dist/compiler/collector.d.ts.map +1 -1
- package/dist/compiler/collector.js +14 -5
- package/dist/compiler/collector.js.map +1 -1
- package/dist/compiler/fiber-compiler.d.ts +2 -0
- package/dist/compiler/fiber-compiler.d.ts.map +1 -1
- package/dist/compiler/fiber-compiler.js +29 -1
- package/dist/compiler/fiber-compiler.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/structure-renderer.d.ts.map +1 -1
- package/dist/compiler/structure-renderer.js +4 -15
- package/dist/compiler/structure-renderer.js.map +1 -1
- package/dist/compiler/types.d.ts +2 -10
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/compiler/types.js.map +1 -1
- package/dist/engine/tool-executor.js +3 -3
- package/dist/engine/tool-executor.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/knob.d.ts +12 -0
- package/dist/hooks/knob.d.ts.map +1 -1
- package/dist/hooks/knob.js +32 -2
- package/dist/hooks/knob.js.map +1 -1
- package/dist/hooks/knobs-component.d.ts +1 -0
- package/dist/hooks/knobs-component.d.ts.map +1 -1
- package/dist/hooks/knobs-component.js +5 -1
- package/dist/hooks/knobs-component.js.map +1 -1
- package/dist/hooks/lifecycle.d.ts +21 -14
- package/dist/hooks/lifecycle.d.ts.map +1 -1
- package/dist/hooks/lifecycle.js +32 -13
- package/dist/hooks/lifecycle.js.map +1 -1
- package/dist/hooks/runtime-context.d.ts +12 -1
- package/dist/hooks/runtime-context.d.ts.map +1 -1
- package/dist/hooks/runtime-context.js +21 -0
- package/dist/hooks/runtime-context.js.map +1 -1
- package/dist/hooks/types.d.ts +8 -0
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/hooks/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-runtime.d.ts +6 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.js.map +1 -1
- package/dist/procedure/index.d.ts.map +1 -1
- package/dist/testing/compile-agent.d.ts +4 -3
- package/dist/testing/compile-agent.d.ts.map +1 -1
- package/dist/testing/compile-agent.js +2 -2
- package/dist/testing/compile-agent.js.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} +26 -26
- package/dist/testing/test-runner.d.ts.map +1 -0
- package/dist/testing/{test-environment.js → test-runner.js} +21 -21
- package/dist/testing/test-runner.js.map +1 -0
- package/dist/tool/tool.d.ts +60 -2
- package/dist/tool/tool.d.ts.map +1 -1
- package/dist/tool/tool.js +90 -20
- package/dist/tool/tool.js.map +1 -1
- package/dist/utils/token-estimate.d.ts +4 -3
- package/dist/utils/token-estimate.d.ts.map +1 -1
- package/dist/utils/token-estimate.js +16 -15
- package/dist/utils/token-estimate.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 (
|
|
@@ -604,6 +616,39 @@ function App() {
|
|
|
604
616
|
}
|
|
605
617
|
```
|
|
606
618
|
|
|
619
|
+
### Prop Overrides
|
|
620
|
+
|
|
621
|
+
Customize pre-built tool metadata via JSX props without creating new tools:
|
|
622
|
+
|
|
623
|
+
```tsx
|
|
624
|
+
<WeatherTool description="Check weather. Always include units." />
|
|
625
|
+
<ShellTool name="bash" requiresConfirmation={true} />
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
### Tool Sources
|
|
629
|
+
|
|
630
|
+
Tools merge from four sources (lowest → highest priority):
|
|
631
|
+
|
|
632
|
+
```tsx
|
|
633
|
+
// 1. App-level — available to all sessions
|
|
634
|
+
const app = createApp(Agent, { tools: [SearchTool] });
|
|
635
|
+
|
|
636
|
+
// 2. Session-level — available for this session
|
|
637
|
+
const session = await app.session({ tools: [FileTool] });
|
|
638
|
+
|
|
639
|
+
// 3. Per-execution — available only during this send()
|
|
640
|
+
await session.send({ messages: [...], tools: [DynamicTool] });
|
|
641
|
+
|
|
642
|
+
// 4. JSX-reconciled — highest priority, re-evaluated each tick
|
|
643
|
+
function Agent() {
|
|
644
|
+
return <SearchTool description="Custom desc" />;
|
|
645
|
+
}
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
On each tick, tools merge in order: app → session → execution → JSX. Last-in wins by name.
|
|
649
|
+
|
|
650
|
+
Spawned sessions (`session.spawn()`) start fresh — they do **not** inherit parent tools. Each child defines its own toolset via JSX and app-level tools.
|
|
651
|
+
|
|
607
652
|
## App & Session
|
|
608
653
|
|
|
609
654
|
### Creating an App
|
|
@@ -626,7 +671,7 @@ const app = createApp(MyApp, {
|
|
|
626
671
|
devTools: true, // Enable DevTools emission
|
|
627
672
|
tools: [ExternalTool], // Additional tools (merged with JSX <Tool>s)
|
|
628
673
|
mcpServers: { ... }, // MCP server configs
|
|
629
|
-
|
|
674
|
+
runner: myRunner, // Execution runner (see below)
|
|
630
675
|
});
|
|
631
676
|
```
|
|
632
677
|
|
|
@@ -961,19 +1006,19 @@ await run(<Agent query="default" />, { props: { query: "override" }, model, mess
|
|
|
961
1006
|
|
|
962
1007
|
`createApp` takes a component function and returns a reusable app with session management, persistence, and middleware support.
|
|
963
1008
|
|
|
964
|
-
## Execution
|
|
1009
|
+
## Execution Runners
|
|
965
1010
|
|
|
966
|
-
An `
|
|
1011
|
+
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
1012
|
|
|
968
1013
|
```tsx
|
|
969
|
-
import { createApp, type
|
|
1014
|
+
import { createApp, type ExecutionRunner } from "@agentick/core";
|
|
970
1015
|
|
|
971
|
-
const
|
|
1016
|
+
const replRunner: ExecutionRunner = {
|
|
972
1017
|
name: "repl",
|
|
973
1018
|
|
|
974
|
-
// Transform
|
|
1019
|
+
// Transform the compiled structure — replace tool schemas with prose descriptions,
|
|
975
1020
|
// expose a single "execute" tool, restructure sections, anything.
|
|
976
|
-
|
|
1021
|
+
transformCompiled(compiled, tools) {
|
|
977
1022
|
const commandList = tools
|
|
978
1023
|
.map((t) => `- ${t.metadata?.name}: ${t.metadata?.description}`)
|
|
979
1024
|
.join("\n");
|
|
@@ -1008,10 +1053,10 @@ const replEnvironment: ExecutionEnvironment = {
|
|
|
1008
1053
|
};
|
|
1009
1054
|
|
|
1010
1055
|
// Same agent, different execution model
|
|
1011
|
-
const app = createApp(MyAgent, { model,
|
|
1056
|
+
const app = createApp(MyAgent, { model, runner: replRunner });
|
|
1012
1057
|
```
|
|
1013
1058
|
|
|
1014
|
-
The agent's JSX — its `<System>`, `<Timeline>`, `<Tool>` components — stays identical. The
|
|
1059
|
+
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
1060
|
|
|
1016
1061
|
### Interface
|
|
1017
1062
|
|
|
@@ -1019,11 +1064,11 @@ All methods are optional. Omitted methods use default behavior.
|
|
|
1019
1064
|
|
|
1020
1065
|
| Hook | Purpose | Timing |
|
|
1021
1066
|
| ------------------- | --------------------------------------------------- | ------------- |
|
|
1022
|
-
| `
|
|
1067
|
+
| `transformCompiled` | Transform compiled context before the model sees it | Per tick |
|
|
1023
1068
|
| `executeToolCall` | Intercept, transform, or replace tool execution | Per tool call |
|
|
1024
1069
|
| `onSessionInit` | Set up per-session resources (sandbox, workspace) | Once |
|
|
1025
|
-
| `onPersist` | Add
|
|
1026
|
-
| `onRestore` | Restore
|
|
1070
|
+
| `onPersist` | Add runner state to session snapshot | Per save |
|
|
1071
|
+
| `onRestore` | Restore runner state from snapshot | Once |
|
|
1027
1072
|
| `onDestroy` | Clean up resources | Once |
|
|
1028
1073
|
|
|
1029
1074
|
### Use Cases
|
|
@@ -1031,7 +1076,7 @@ All methods are optional. Omitted methods use default behavior.
|
|
|
1031
1076
|
- **REPL/Code Execution**: Replace tool schemas with command descriptions, route `execute` calls to a sandboxed runtime, persist sandbox state across sessions.
|
|
1032
1077
|
- **Human-in-the-Loop**: Transform tool calls into approval requests, gate execution on human confirmation, log decisions.
|
|
1033
1078
|
- **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 `
|
|
1079
|
+
- **Testing**: Intercept specific tools to return canned responses, track all lifecycle calls for assertions. See `createTestRunner()` in `@agentick/core/testing`.
|
|
1035
1080
|
|
|
1036
1081
|
## DevTools Integration
|
|
1037
1082
|
|