@kuralle-agents/core 0.2.0 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- import { buildToolSet } from '../tools/effect/defineTool.js';
1
+ import { buildToolSet, rawToolsFromSet } from '../tools/effect/defineTool.js';
2
2
  export function resolveInstructions(instructions, state) {
3
3
  if (typeof instructions === 'string') {
4
4
  return instructions;
@@ -30,6 +30,9 @@ export function resolveReplyNode(node, state) {
30
30
  node,
31
31
  prompt: buildNodePrompt(node, state),
32
32
  tools,
33
+ // Recover the raw executors from the node's `buildToolSet` tools so they run
34
+ // in-flow (with run context) — without also needing `agent.effectTools`.
35
+ localTools: rawToolsFromSet(tools),
33
36
  };
34
37
  }
35
38
  export function resolveCollectExtractionNode(collectNode, missing, state, submitTool) {
@@ -17,4 +17,6 @@ export declare function defineTool<S extends z.ZodTypeAny | StandardSchemaV1 | u
17
17
  }): Tool<InferToolInput<S>, R>;
18
18
  export declare function toolToAiSdk<TInput = unknown, TOutput = unknown>(def: Tool<TInput, TOutput>): AiTool<TInput, TOutput>;
19
19
  export declare function buildToolSet(tools: Record<string, AnyTool>): ToolSet;
20
+ /** Recover the raw effect tools (with executors) from a `buildToolSet` output. */
21
+ export declare function rawToolsFromSet(set: ToolSet): Record<string, AnyTool> | undefined;
20
22
  export {};
@@ -21,14 +21,27 @@ export function toolToAiSdk(def) {
21
21
  }
22
22
  return aiTool(spec);
23
23
  }
24
+ // `buildToolSet` produces a model-facing ToolSet whose entries are schema-only
25
+ // (`toolToAiSdk` strips `execute`). Stash the raw effect tools (with executors),
26
+ // keyed by the returned ToolSet, so a flow node can recover its executors for
27
+ // in-flow execution without separately registering them on `agent.effectTools`
28
+ // (see `resolveReplyNode`). The WeakMap is GC-friendly and invisible to callers.
29
+ const rawToolsBySet = new WeakMap();
24
30
  export function buildToolSet(tools) {
25
31
  const set = {};
32
+ const byName = {};
26
33
  for (const [key, def] of Object.entries(tools)) {
27
34
  const name = def.name || key;
28
35
  set[name] = toolToAiSdk(def);
36
+ byName[name] = def;
29
37
  }
38
+ rawToolsBySet.set(set, byName);
30
39
  return set;
31
40
  }
41
+ /** Recover the raw effect tools (with executors) from a `buildToolSet` output. */
42
+ export function rawToolsFromSet(set) {
43
+ return rawToolsBySet.get(set);
44
+ }
32
45
  function inferToolName(description) {
33
46
  const slug = description
34
47
  .toLowerCase()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuralle-agents/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A framework for structured conversational AI agents",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -84,6 +84,7 @@
84
84
  "zod": "^3.0.0"
85
85
  },
86
86
  "devDependencies": {
87
+ "@kuralle-agents/realtime-audio": "workspace:*",
87
88
  "@ai-sdk/openai": "^3.0.0",
88
89
  "@types/node": "^20.11.0",
89
90
  "ai": "^6.0.0",
@@ -91,18 +92,14 @@
91
92
  "dotenv": "^16.4.0",
92
93
  "tsx": "^4.7.0",
93
94
  "typescript": "^5.3.0",
94
- "zod": "^3.23.0",
95
- "@kuralle-agents/realtime-audio": "0.2.0"
96
- },
97
- "dependencies": {
98
- "chrono-node": "^2.6.0",
99
- "zod-to-json-schema": "^3.24.0"
95
+ "zod": "^3.23.0"
100
96
  },
101
97
  "scripts": {
102
98
  "prebuild": "rm -rf dist",
103
99
  "build": "tsc -p tsconfig.json",
104
100
  "typecheck:examples": "tsc --noEmit -p tsconfig.examples.json",
105
101
  "clean": "rm -rf dist",
102
+ "prepublishOnly": "npm run clean && npm run build",
106
103
  "test": "bun test test",
107
104
  "smoke:textdriver": "bun test ./test/core-channel/textdriver.smoke.ts",
108
105
  "smoke:flow": "bun test ./test/core-flow/flow.smoke.ts",
@@ -110,5 +107,9 @@
110
107
  "smoke:approval": "bun test ./test/core-policy/approval.smoke.ts",
111
108
  "smoke:knowledge": "bun test ./test/core-grounding/knowledge.smoke.ts",
112
109
  "smoke:realtime": "bun test ./test/core-voice/realtime.smoke.ts"
110
+ },
111
+ "dependencies": {
112
+ "chrono-node": "^2.6.0",
113
+ "zod-to-json-schema": "^3.24.0"
113
114
  }
114
- }
115
+ }