@xsai/tool 0.3.3 → 0.3.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/dist/index.d.ts CHANGED
@@ -6,15 +6,18 @@ interface RawToolOptions<T = unknown> {
6
6
  execute: (input: T, options: ToolExecuteOptions) => Promise<ToolExecuteResult> | ToolExecuteResult;
7
7
  name: string;
8
8
  parameters: JsonSchema;
9
+ strict?: boolean;
9
10
  }
10
- declare const rawTool: <T = unknown>({ description, execute, name, parameters }: RawToolOptions<T>) => Tool;
11
+ declare const rawTool: <T = unknown>({ description, execute, name, parameters, strict }: RawToolOptions<T>) => Tool;
11
12
 
12
13
  interface ToolOptions<T extends Schema> {
13
14
  description?: string;
14
15
  execute: (input: InferIn<T>, options: ToolExecuteOptions) => Promise<ToolExecuteResult> | ToolExecuteResult;
15
16
  name: string;
16
17
  parameters: T;
18
+ /** @default true */
19
+ strict?: boolean;
17
20
  }
18
- declare const tool: <T extends Schema>({ description, execute, name, parameters }: ToolOptions<T>) => Promise<Tool>;
21
+ declare const tool: <T extends Schema>({ description, execute, name, parameters, strict }: ToolOptions<T>) => Promise<Tool>;
19
22
 
20
23
  export { type RawToolOptions, type ToolOptions, rawTool, tool };
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { strictJsonSchema, toJsonSchema } from 'xsschema';
2
2
 
3
- const rawTool = ({ description, execute, name, parameters }) => ({
3
+ const rawTool = ({ description, execute, name, parameters, strict }) => ({
4
4
  execute,
5
5
  function: {
6
6
  description,
7
7
  name,
8
- parameters: strictJsonSchema(parameters),
9
- strict: true
8
+ parameters: strict !== false ? strictJsonSchema(parameters) : parameters,
9
+ strict: strict ?? true
10
10
  },
11
11
  type: "function"
12
12
  });
13
13
 
14
- const tool = async ({ description, execute, name, parameters }) => {
14
+ const tool = async ({ description, execute, name, parameters, strict }) => {
15
15
  const schema = await toJsonSchema(parameters);
16
16
  return {
17
17
  execute,
18
18
  function: {
19
19
  description,
20
20
  name,
21
- parameters: strictJsonSchema(schema),
22
- strict: true
21
+ parameters: strict !== false ? strictJsonSchema(schema) : schema,
22
+ strict: strict ?? true
23
23
  },
24
24
  type: "function"
25
25
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/tool",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "description": "extra-small AI SDK.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -29,9 +29,9 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@xsai/shared-chat": "~0.3.3",
33
- "@xsai/shared": "~0.3.3",
34
- "xsschema": "~0.3.3"
32
+ "@xsai/shared": "~0.3.5",
33
+ "xsschema": "~0.3.5",
34
+ "@xsai/shared-chat": "~0.3.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "valibot": "^1.0.0"