@codeworksh/aikit 0.1.0 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanchit Kudari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @codeworksh/aikit
2
2
 
3
- Bun-native AI toolkit for building AI agents and coding-agent workflows.
3
+ Toolkit for Building AI Agents and Workflows.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- bun add @codeworksh/aikit
8
+ npm install @codeworksh/aikit
9
9
  ```
10
10
 
11
11
  ## Quick Start
@@ -70,7 +70,7 @@ const message = await stream.complete(
70
70
 
71
71
  ### Agent
72
72
 
73
- `agent.loop(...)` runs a full assistant turn loop on top of model streaming. It handles tool calls, validates arguments, mutates tool-call parts in-place, and emits higher-level agent events.
73
+ `agent.run(...)` runs a full assistant turn loop on top of model streaming. It handles tool calls, validates arguments, mutates tool-call parts in-place, and emits higher-level agent events.
74
74
 
75
75
  ```ts
76
76
  import { Type } from "@sinclair/typebox";
@@ -80,7 +80,7 @@ const calculatorParams = Type.Object({
80
80
  expression: Type.String(),
81
81
  });
82
82
 
83
- const calculatorTool: Agent.AgentTool<typeof calculatorParams> = {
83
+ const calculatorTool = Agent.defineTool({
84
84
  name: "calculator",
85
85
  label: "Calculator",
86
86
  description: "Evaluate a math expression",
@@ -94,7 +94,7 @@ const calculatorTool: Agent.AgentTool<typeof calculatorParams> = {
94
94
  },
95
95
  };
96
96
  },
97
- };
97
+ });
98
98
 
99
99
  const model = await llm("anthropic", "claude-haiku-4-5-20251001");
100
100
  if (!model) throw new Error("Missing model");
@@ -105,7 +105,7 @@ const prompt: Message.UserMessage = {
105
105
  parts: [{ type: "text", text: "Use the calculator tool for 2 + 2." }],
106
106
  };
107
107
 
108
- const run = agent.loop(
108
+ const run = agent.run(
109
109
  {
110
110
  model,
111
111
  convertToLlm: async (messages) => messages,
@@ -137,7 +137,8 @@ console.log(messages.at(-1));
137
137
 
138
138
  Use `stream(...)` when you want raw provider events and manual control over tool handling.
139
139
 
140
- Use `agent.loop(...)` when you want a higher-level runtime that:
140
+ Use `agent.run(...)` when you want a higher-level runtime that:
141
+
141
142
  - streams assistant message lifecycle events
142
143
  - validates tool arguments
143
144
  - executes tools sequentially or in parallel
@@ -192,7 +193,7 @@ const searchTool: Agent.AgentTool<typeof searchParams, { progress: number }, { h
192
193
  description: "Search indexed documents",
193
194
  parameters: searchParams,
194
195
  async execute(callID, params, signal, onUpdate) {
195
- onUpdate?.({
196
+ await onUpdate?.({
196
197
  status: "running",
197
198
  partial: {
198
199
  content: [{ type: "text", text: `Searching for ${params.query}` }],
@@ -220,7 +221,7 @@ const prompt: Message.UserMessage = {
220
221
  parts: [{ type: "text", text: "Search for agent loop documentation." }],
221
222
  };
222
223
 
223
- const run = agent.loop(
224
+ const run = agent.run(
224
225
  {
225
226
  model,
226
227
  apiKey: process.env.ANTHROPIC_API_KEY,
@@ -258,7 +259,7 @@ Tool execution mode is configurable with `toolExecution`:
258
259
  - `sequential`: prepares and executes each tool call one by one. Use this when tools depend on shared state, rate limits, or side effects that should not overlap.
259
260
 
260
261
  ```ts
261
- const run = agent.loop(
262
+ const run = agent.run(
262
263
  {
263
264
  model,
264
265
  convertToLlm: async (messages) => messages,
@@ -276,7 +277,7 @@ const run = agent.loop(
276
277
  Use it to inspect validated params, enforce policy, or block execution.
277
278
 
278
279
  ```ts
279
- const run = agent.loop(
280
+ const run = agent.run(
280
281
  {
281
282
  model,
282
283
  convertToLlm: async (messages) => messages,
@@ -303,7 +304,7 @@ Returning `{ block: true }` prevents the tool from running and turns that assist
303
304
  Use it to normalize output, attach metadata, or override the final tool result.
304
305
 
305
306
  ```ts
306
- const run = agent.loop(
307
+ const run = agent.run(
307
308
  {
308
309
  model,
309
310
  convertToLlm: async (messages) => messages,