@sisu-ai/mw-tool-calling 9.0.3 → 9.0.5

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
@@ -1,12 +1,6 @@
1
- <div align="right">
2
- <a href="https://github.com/finger-gun/sisu"><img src="https://github.com/finger-gun/sisu/raw/main/sisu-light.svg" alt="ProjectSpecs" width="100" /></a>
3
- </div>
4
-
5
- ---
6
-
7
1
  # @sisu-ai/mw-tool-calling
8
2
 
9
- Native tools API loop for providers that support tool calls.
3
+ Execute provider-native tool call loops with robust iteration, validation, and tool result handling.
10
4
 
11
5
  [![Tests](https://github.com/finger-gun/sisu/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/finger-gun/sisu/actions/workflows/tests.yml)
12
6
  [![CodeQL](https://github.com/finger-gun/sisu/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/finger-gun/sisu/actions/workflows/github-code-scanning/codeql)
package/dist/index.js CHANGED
@@ -29,6 +29,13 @@ function applyAliasesToTools(tools, aliasMap) {
29
29
  }
30
30
  return { aliasedTools, reverseMap };
31
31
  }
32
+ function hasParseSchema(schema) {
33
+ if (!schema || typeof schema !== "object") {
34
+ return false;
35
+ }
36
+ const maybeSchema = schema;
37
+ return typeof maybeSchema.parse === "function";
38
+ }
32
39
  export const toolCalling = async (ctx, next) => {
33
40
  await next();
34
41
  const toolList = ctx.tools.list();
@@ -85,8 +92,9 @@ export const toolCalling = async (ctx, next) => {
85
92
  const key = keyOf(call);
86
93
  let result = cache.get(key);
87
94
  if (result === undefined) {
88
- const args = tool.schema?.parse
89
- ? tool.schema.parse(call.arguments)
95
+ const schema = tool.schema;
96
+ const args = hasParseSchema(schema)
97
+ ? schema.parse(call.arguments)
90
98
  : call.arguments;
91
99
  ctx.log.debug?.("[tool-calling] invoking tool", {
92
100
  aliasName: call.name,
@@ -181,8 +189,9 @@ export const iterativeToolCalling = async (ctx, next) => {
181
189
  const key = keyOf(call);
182
190
  let result = cache.get(key);
183
191
  if (result === undefined) {
184
- const args = tool.schema?.parse
185
- ? tool.schema.parse(call.arguments)
192
+ const schema = tool.schema;
193
+ const args = hasParseSchema(schema)
194
+ ? schema.parse(call.arguments)
186
195
  : call.arguments;
187
196
  ctx.log.debug?.("[iterative-tool-calling] invoking tool", {
188
197
  aliasName: call.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sisu-ai/mw-tool-calling",
3
- "version": "9.0.3",
3
+ "version": "9.0.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "access": "public"
13
13
  },
14
14
  "peerDependencies": {
15
- "@sisu-ai/core": "^2.3.2"
15
+ "@sisu-ai/core": "^2.3.3"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",