@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 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
- environment: myEnv, // Execution environment (see below)
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 Environments
976
+ ## Execution Runners
965
977
 
966
- An `ExecutionEnvironment` 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 environment to change the entire execution model without touching your agent code.
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 ExecutionEnvironment } from "@agentick/core";
981
+ import { createApp, type ExecutionRunner } from "@agentick/core";
970
982
 
971
- const replEnvironment: ExecutionEnvironment = {
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, environment: replEnvironment });
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 environment 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.
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 environment state to session snapshot | Per save |
1026
- | `onRestore` | Restore environment state from snapshot | Once |
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 `createTestEnvironment()` in `@agentick/core/testing`.
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