@kuralle-agents/core 0.4.1 → 0.6.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 +12 -3
- package/dist/ai-sdk/uiMessageStream.d.ts +51 -0
- package/dist/ai-sdk/uiMessageStream.js +164 -0
- package/dist/events/TurnHandle.js +7 -0
- package/dist/flow/nodeBuilders.d.ts +1 -1
- package/dist/flow/nodeBuilders.js +5 -3
- package/dist/index.d.ts +14 -4
- package/dist/index.js +8 -2
- package/dist/memory/blocks/FilePersistentMemoryStore.d.ts +1 -1
- package/dist/memory/blocks/FilePersistentMemoryStore.js +9 -0
- package/dist/memory/blocks/InMemoryPersistentMemoryStore.d.ts +8 -0
- package/dist/memory/blocks/InMemoryPersistentMemoryStore.js +25 -0
- package/dist/memory/blocks/RoutedPersistentMemoryStore.d.ts +18 -0
- package/dist/memory/blocks/RoutedPersistentMemoryStore.js +35 -0
- package/dist/memory/blocks/TieredPersistentMemoryStore.d.ts +10 -0
- package/dist/memory/blocks/TieredPersistentMemoryStore.js +30 -0
- package/dist/memory/blocks/memoryBlockTool.d.ts +5 -5
- package/dist/memory/blocks/testing.d.ts +11 -0
- package/dist/memory/blocks/testing.js +59 -0
- package/dist/memory/index.d.ts +4 -0
- package/dist/memory/index.js +3 -0
- package/dist/runtime/Runtime.d.ts +3 -0
- package/dist/runtime/Runtime.js +47 -5
- package/dist/runtime/agentReply.js +2 -1
- package/dist/runtime/channels/TextDriver.js +3 -2
- package/dist/runtime/channels/VoiceDriver.js +3 -3
- package/dist/runtime/channels/extractionTurn.js +1 -1
- package/dist/runtime/ctx.d.ts +2 -0
- package/dist/runtime/ctx.js +1 -0
- package/dist/runtime/grounding/defaultStoreRegistry.d.ts +3 -0
- package/dist/runtime/grounding/defaultStoreRegistry.js +10 -0
- package/dist/runtime/grounding/index.d.ts +1 -0
- package/dist/runtime/grounding/index.js +1 -0
- package/dist/runtime/grounding/workingMemory.d.ts +19 -0
- package/dist/runtime/grounding/workingMemory.js +80 -0
- package/dist/runtime/resolveAgentWorkspace.d.ts +10 -0
- package/dist/runtime/resolveAgentWorkspace.js +9 -0
- package/dist/skills/SkillsCapability.d.ts +10 -0
- package/dist/skills/SkillsCapability.js +52 -0
- package/dist/skills/collectSkills.d.ts +17 -0
- package/dist/skills/collectSkills.js +56 -0
- package/dist/skills/index.d.ts +5 -0
- package/dist/skills/index.js +4 -0
- package/dist/skills/inlineSkillStore.d.ts +9 -0
- package/dist/skills/inlineSkillStore.js +37 -0
- package/dist/skills/wireAgentSkills.d.ts +10 -0
- package/dist/skills/wireAgentSkills.js +25 -0
- package/dist/testing/mocks.js +7 -0
- package/dist/tools/effect/defineTool.js +1 -1
- package/dist/tools/effect/index.d.ts +1 -0
- package/dist/tools/effect/index.js +1 -0
- package/dist/tools/effect/wrapAiSdkTool.d.ts +3 -0
- package/dist/tools/effect/wrapAiSdkTool.js +12 -0
- package/dist/tools/fs/createFsTool.d.ts +30 -0
- package/dist/tools/fs/createFsTool.js +200 -0
- package/dist/types/agentConfig.d.ts +16 -3
- package/dist/types/filesystem.d.ts +85 -0
- package/dist/types/filesystem.js +6 -0
- package/dist/types/grounding.d.ts +12 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/run-context.d.ts +11 -2
- package/dist/types/skills.d.ts +19 -0
- package/dist/types/skills.js +1 -0
- package/dist/types/stream.d.ts +3 -0
- package/guides/AGENTS.md +2 -3
- package/guides/FLOWS.md +2 -2
- package/guides/RUNTIME.md +18 -1
- package/guides/TOOLS.md +69 -2
- package/package.json +12 -3
package/guides/TOOLS.md
CHANGED
|
@@ -2,6 +2,74 @@
|
|
|
2
2
|
|
|
3
3
|
Kuralle tools use the Vercel AI SDK `tool(...)` API. Tools are how agents read data, write state, and trigger flow transitions.
|
|
4
4
|
|
|
5
|
+
## Durable agent tools
|
|
6
|
+
|
|
7
|
+
Agent-level `tools` is a `Record<string, AnyTool>` from `defineTool` — every call is journaled (exactly-once on replay). Flow nodes use `buildToolSet({ ... })` for model-visible schema; executors come from the agent registry and flow-local tools.
|
|
8
|
+
|
|
9
|
+
For third-party AI SDK tools, use `wrapAiSdkTool(name, aiTool)` — it captures `execute` and routes through the same journal:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineTool, wrapAiSdkTool } from '@kuralle-agents/core';
|
|
13
|
+
import { tool } from 'ai';
|
|
14
|
+
|
|
15
|
+
const native = defineTool({ name: 'lookup', description: '...', input: z.object({ id: z.string() }), execute: async ({ id }) => ({ id }) });
|
|
16
|
+
|
|
17
|
+
const sdk = tool({ description: 'Legacy SDK tool', inputSchema: z.object({ id: z.string() }), execute: async ({ id }) => ({ id }) });
|
|
18
|
+
|
|
19
|
+
const agent = defineAgent({
|
|
20
|
+
id: 'a',
|
|
21
|
+
model,
|
|
22
|
+
tools: { lookup: native, legacy: wrapAiSdkTool('legacy', sdk) },
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Agent workspace
|
|
27
|
+
|
|
28
|
+
Set `workspace` to a portable `FileSystem` (from `@kuralle-agents/fs`) to auto-register the durable `workspace` tool (`ls`, `cat`, `grep`, `find`, `read`, `write`, `edit`). The same instance is exposed on `RunContext.fs` for flow `action` nodes.
|
|
29
|
+
|
|
30
|
+
**Read-only by default** (ADR 0006): a bare `FileSystem` is mounted read-only and exposed in `globalTools` (safe for every speaking turn). Pass `{ fs, readOnly: false }` for a writable scratchpad — the executor is registered, but the tool is **not** auto-added to `globalTools` (mutating tools stay flow-gated).
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { InMemoryFs } from '@kuralle-agents/fs';
|
|
34
|
+
|
|
35
|
+
const agent = defineAgent({
|
|
36
|
+
id: 'kb',
|
|
37
|
+
model,
|
|
38
|
+
workspace: new InMemoryFs({ '/docs/faq.md': '# FAQ' }),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Writable scratchpad (not in globalTools):
|
|
42
|
+
// workspace: { fs: new InMemoryFs({ '/scratch': '' }), readOnly: false },
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires `@kuralle-agents/fs` when using `workspace`.
|
|
46
|
+
|
|
47
|
+
## Working memory blocks
|
|
48
|
+
|
|
49
|
+
Cross-session markdown blocks (`USER`, `MEMORY`, …) via `agent.memory.workingMemory`. Blocks load at session start, inject into the system prompt, and are editable with the auto-registered `memory_block` tool.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { defineAgent, FilePersistentMemoryStore } from '@kuralle-agents/core';
|
|
53
|
+
|
|
54
|
+
const agent = defineAgent({
|
|
55
|
+
id: 'support',
|
|
56
|
+
model,
|
|
57
|
+
memory: {
|
|
58
|
+
workingMemory: {
|
|
59
|
+
store: new FilePersistentMemoryStore(),
|
|
60
|
+
autoLoad: [
|
|
61
|
+
{ scope: 'user', key: 'USER', template: 'name:\npreferences:' },
|
|
62
|
+
{ scope: 'agent', key: 'MEMORY' },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
On Workers, pass an explicit `store` (or `HarnessConfig.defaultWorkingMemoryStore`). Semantic recall (`preload` / `ingest`) is unchanged — working memory is an additional axis.
|
|
70
|
+
|
|
71
|
+
See [examples/agents/working-memory.ts](../examples/agents/working-memory.ts) for a live cross-session demo.
|
|
72
|
+
|
|
5
73
|
## Tool Basics
|
|
6
74
|
|
|
7
75
|
```ts
|
|
@@ -70,8 +138,7 @@ const lead = defineAgent({
|
|
|
70
138
|
instructions:
|
|
71
139
|
'Research assistant. Use consult_weather for weather questions. Combine answers clearly.',
|
|
72
140
|
model,
|
|
73
|
-
tools:
|
|
74
|
-
effectTools: { consult_weather: consultWeather },
|
|
141
|
+
tools: { consult_weather: consultWeather },
|
|
75
142
|
});
|
|
76
143
|
|
|
77
144
|
const runtime = createRuntime({
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "git+https://github.com/kuralle/kuralle-agents.git",
|
|
7
7
|
"directory": "packages/kuralle-core"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.6.0",
|
|
10
10
|
"description": "A framework for structured conversational AI agents",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
@@ -72,6 +72,10 @@
|
|
|
72
72
|
"types": "./dist/memory/index.d.ts",
|
|
73
73
|
"default": "./dist/memory/index.js"
|
|
74
74
|
},
|
|
75
|
+
"./memory/testing": {
|
|
76
|
+
"types": "./dist/memory/blocks/testing.d.ts",
|
|
77
|
+
"default": "./dist/memory/blocks/testing.js"
|
|
78
|
+
},
|
|
75
79
|
"./foundation": {
|
|
76
80
|
"types": "./dist/foundation/index.d.ts",
|
|
77
81
|
"default": "./dist/foundation/index.js"
|
|
@@ -90,14 +94,16 @@
|
|
|
90
94
|
"zod": "^3.0.0"
|
|
91
95
|
},
|
|
92
96
|
"devDependencies": {
|
|
97
|
+
"@cloudflare/vitest-pool-workers": "^0.12.7",
|
|
93
98
|
"@ai-sdk/openai": "^3.0.0",
|
|
94
99
|
"@types/node": "^20.11.0",
|
|
95
100
|
"ai": "^6.0.0",
|
|
96
101
|
"bun-types": "^1.3.0",
|
|
97
102
|
"dotenv": "^16.4.0",
|
|
98
103
|
"typescript": "^5.3.0",
|
|
104
|
+
"vitest": "^3.2.4",
|
|
99
105
|
"zod": "^3.23.0",
|
|
100
|
-
"@kuralle-agents/realtime-audio": "0.
|
|
106
|
+
"@kuralle-agents/realtime-audio": "0.6.0"
|
|
101
107
|
},
|
|
102
108
|
"dependencies": {
|
|
103
109
|
"chrono-node": "^2.6.0",
|
|
@@ -108,7 +114,10 @@
|
|
|
108
114
|
"build": "tsc -p tsconfig.json",
|
|
109
115
|
"typecheck:examples": "tsc --noEmit -p tsconfig.examples.json",
|
|
110
116
|
"clean": "rm -rf dist",
|
|
111
|
-
"test": "bun test test",
|
|
117
|
+
"test": "bun test ./test && vitest run --config vitest.config.ts",
|
|
118
|
+
"test:journal-key-workers": "vitest run --config vitest.config.ts",
|
|
119
|
+
"test:workspace-autoregister": "bun test ./test/core-workspace/workspace-autoregister.test.ts",
|
|
120
|
+
"test:skill-wire": "bun test ./test/core-skills/skill-wire.test.ts",
|
|
112
121
|
"smoke:textdriver": "bun test ./test/core-channel/textdriver.smoke.ts",
|
|
113
122
|
"smoke:flow": "bun test ./test/core-flow/flow.smoke.ts",
|
|
114
123
|
"smoke:agent": "bun test ./test/core-agent/agent.smoke.ts",
|