@zmdb/ai-vercel 1.0.0-beta.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.
- package/LICENSE +10 -0
- package/README.md +47 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
- package/src/index.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
@zmdb/ai-vercel is free software licensed under the GNU General Public License,
|
|
5
|
+
version 3 or (at your option) any later version.
|
|
6
|
+
|
|
7
|
+
The complete license text is published by the Free Software Foundation at:
|
|
8
|
+
https://www.gnu.org/licenses/gpl-3.0.txt
|
|
9
|
+
|
|
10
|
+
SPDX-License-Identifier: GPL-3.0-or-later
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @zmdb/ai-vercel
|
|
2
|
+
|
|
3
|
+
`@zmdb/ai-vercel` adapts a provider-neutral zmdb tool document to the Vercel AI SDK's branded `inputSchema` contract. The application supplies its installed SDK's `jsonSchema` factory, so this package
|
|
4
|
+
neither imports the SDK at runtime nor fabricates its schema brand with a cast.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
yarn add @zmdb/ai @zmdb/ai-vercel ai@^7.0.93
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
> **Prerelease** (`1.0.0-beta.1`). Requires **Node.js 26+** and is **ESM-only**. The supported and tested peer floor is exact AI SDK `7.0.93`.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { jsonSchema, tool } from 'ai';
|
|
18
|
+
import { aiSdkTool } from '@zmdb/ai-vercel';
|
|
19
|
+
|
|
20
|
+
const createUser = tool(
|
|
21
|
+
aiSdkTool('create_user', users, {
|
|
22
|
+
jsonSchema,
|
|
23
|
+
description: 'Create a user',
|
|
24
|
+
validate: input => assert<CreateDTO<User>>(input),
|
|
25
|
+
execute: async dto => ({ email: dto.email }),
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`validate` runs before `execute`. Validation failures become bounded, value-free tool-result text that a model can correct; handler and infrastructure errors still throw.
|
|
31
|
+
|
|
32
|
+
## Public API
|
|
33
|
+
|
|
34
|
+
- `aiSdkTool`
|
|
35
|
+
- `AiSdkToolFields`
|
|
36
|
+
- `AiSdkToolOptions`
|
|
37
|
+
- `ToolAdapterOptions`
|
|
38
|
+
|
|
39
|
+
The package depends only on `@zmdb/ai`. `ai` is an optional peer because the package returns a structural tool object and receives the branded factory from the caller.
|
|
40
|
+
|
|
41
|
+
## Non-goals
|
|
42
|
+
|
|
43
|
+
This package does not own model clients, provider packages, streaming UI state, persistence, `useChat`, or a runtime schema library.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
GNU General Public License v3.0 or later (GPL-3.0-or-later) — see [LICENSE](./LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ToolSchema } from '@zmdb/ai';
|
|
2
|
+
import { type ToolAdapterOptions } from '@zmdb/ai/tool-runtime';
|
|
3
|
+
export interface AiSdkToolOptions<T, Output, Schema> extends ToolAdapterOptions<T, Output> {
|
|
4
|
+
/**
|
|
5
|
+
* The AI SDK's branded `jsonSchema` factory. Injecting it keeps the brand
|
|
6
|
+
* owned by the installed peer and avoids a cast or a runtime schema library.
|
|
7
|
+
*/
|
|
8
|
+
readonly jsonSchema: (schema: unknown) => Schema;
|
|
9
|
+
}
|
|
10
|
+
/** The fields accepted by the AI SDK's `tool(...)` helper. */
|
|
11
|
+
export interface AiSdkToolFields<Schema, Output> {
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly inputSchema: Schema;
|
|
14
|
+
readonly execute: (input: unknown) => Promise<Output | string>;
|
|
15
|
+
}
|
|
16
|
+
export declare function aiSdkTool<T, Output, Schema>(name: string, schema: ToolSchema, options: AiSdkToolOptions<T, Output, Schema>): AiSdkToolFields<Schema, Output>;
|
|
17
|
+
export type { ToolAdapterOptions } from '@zmdb/ai/tool-runtime';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAE,SAAQ,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC;IACxF;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;CAClD;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe,CAAC,MAAM,EAAE,MAAM;IAC7C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAChE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EACzC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAC3C,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CASjC;AAED,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { toolFromSchema } from '@zmdb/ai';
|
|
2
|
+
import { executeToolAdapter } from '@zmdb/ai/tool-runtime';
|
|
3
|
+
export function aiSdkTool(name, schema, options) {
|
|
4
|
+
const inputSchema = options.jsonSchema(toolFromSchema(name, schema).parameters);
|
|
5
|
+
return {
|
|
6
|
+
description: options.description,
|
|
7
|
+
inputSchema,
|
|
8
|
+
async execute(input) {
|
|
9
|
+
return executeToolAdapter(name, input, options);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAA2B,MAAM,uBAAuB,CAAC;AAiBpF,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,MAAkB,EAClB,OAA4C;IAE5C,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IAChF,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW;QACX,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,OAAO,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zmdb/ai-vercel",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "Vercel AI SDK tool integration for provider-neutral zmdb AI contracts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"function-calling",
|
|
8
|
+
"typescript",
|
|
9
|
+
"vercel",
|
|
10
|
+
"zmdb"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/ambasta/zmdb#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ambasta/zmdb/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "GPL-3.0-or-later",
|
|
17
|
+
"author": "zmdb contributors",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ambasta/zmdb.git",
|
|
21
|
+
"directory": "packages/ai-vercel"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"tag": "beta"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@zmdb/ai": "1.0.0-beta.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"ai": "^7.0.93"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"ai": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=26"
|
|
52
|
+
},
|
|
53
|
+
"main": "./dist/index.js",
|
|
54
|
+
"types": "./dist/index.d.ts"
|
|
55
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { toolFromSchema, type ToolSchema } from '@zmdb/ai';
|
|
2
|
+
import { executeToolAdapter, type ToolAdapterOptions } from '@zmdb/ai/tool-runtime';
|
|
3
|
+
|
|
4
|
+
export interface AiSdkToolOptions<T, Output, Schema> extends ToolAdapterOptions<T, Output> {
|
|
5
|
+
/**
|
|
6
|
+
* The AI SDK's branded `jsonSchema` factory. Injecting it keeps the brand
|
|
7
|
+
* owned by the installed peer and avoids a cast or a runtime schema library.
|
|
8
|
+
*/
|
|
9
|
+
readonly jsonSchema: (schema: unknown) => Schema;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The fields accepted by the AI SDK's `tool(...)` helper. */
|
|
13
|
+
export interface AiSdkToolFields<Schema, Output> {
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly inputSchema: Schema;
|
|
16
|
+
readonly execute: (input: unknown) => Promise<Output | string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function aiSdkTool<T, Output, Schema>(
|
|
20
|
+
name: string,
|
|
21
|
+
schema: ToolSchema,
|
|
22
|
+
options: AiSdkToolOptions<T, Output, Schema>,
|
|
23
|
+
): AiSdkToolFields<Schema, Output> {
|
|
24
|
+
const inputSchema = options.jsonSchema(toolFromSchema(name, schema).parameters);
|
|
25
|
+
return {
|
|
26
|
+
description: options.description,
|
|
27
|
+
inputSchema,
|
|
28
|
+
async execute(input) {
|
|
29
|
+
return executeToolAdapter(name, input, options);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type { ToolAdapterOptions } from '@zmdb/ai/tool-runtime';
|