@orpc/ai-sdk 0.0.0-next.b312314 → 0.0.0-next.b81d47f
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 +2 -2
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.mjs +15 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
## Documentation
|
|
47
47
|
|
|
48
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
49
49
|
|
|
50
50
|
## Packages
|
|
51
51
|
|
package/dist/index.d.mts
CHANGED
|
@@ -12,11 +12,11 @@ interface AiSdkToolMeta extends Meta {
|
|
|
12
12
|
declare class CreateToolError extends Error {
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Implements [procedure contract](https://orpc.
|
|
15
|
+
* Implements [procedure contract](https://orpc.dev/docs/contract-first/define-contract#procedure-contract)
|
|
16
16
|
* as an [AI SDK Tool](https://ai-sdk.dev/docs/foundations/tools) by leveraging existing contract definitions.
|
|
17
17
|
*
|
|
18
18
|
* @warning Requires a contract with an `input` schema defined.
|
|
19
|
-
* @info Standard [procedures](https://orpc.
|
|
19
|
+
* @info Standard [procedures](https://orpc.dev/docs/procedure) are also compatible with [procedure contracts](https://orpc.dev/docs/contract-first/define-contract).
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
@@ -62,12 +62,10 @@ declare class CreateToolError extends Error {
|
|
|
62
62
|
*/
|
|
63
63
|
declare function implementTool<TOutInput, TInOutput>(contract: ContractProcedure<Schema<any, TOutInput>, Schema<TInOutput, any>, any, AiSdkToolMeta>, ...rest: MaybeOptionalOptions<SetOptional<Tool<TOutInput, TInOutput>, 'inputSchema' | 'outputSchema'>>): Tool<TOutInput, TInOutput>;
|
|
64
64
|
/**
|
|
65
|
-
* Converts a [procedure](https://orpc.
|
|
65
|
+
* Converts a [procedure](https://orpc.dev/docs/procedure) into an [AI SDK Tool](https://ai-sdk.dev/docs/foundations/tools)
|
|
66
66
|
* by leveraging existing procedure definitions.
|
|
67
67
|
*
|
|
68
68
|
* @warning Requires a contract with an `input` schema defined.
|
|
69
|
-
* @warning Validation occurs twice (once for the tool, once for the procedure call).
|
|
70
|
-
* So validation may fail if inputSchema or outputSchema transform the data into different shapes.
|
|
71
69
|
*
|
|
72
70
|
* @example
|
|
73
71
|
* ```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,11 @@ interface AiSdkToolMeta extends Meta {
|
|
|
12
12
|
declare class CreateToolError extends Error {
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Implements [procedure contract](https://orpc.
|
|
15
|
+
* Implements [procedure contract](https://orpc.dev/docs/contract-first/define-contract#procedure-contract)
|
|
16
16
|
* as an [AI SDK Tool](https://ai-sdk.dev/docs/foundations/tools) by leveraging existing contract definitions.
|
|
17
17
|
*
|
|
18
18
|
* @warning Requires a contract with an `input` schema defined.
|
|
19
|
-
* @info Standard [procedures](https://orpc.
|
|
19
|
+
* @info Standard [procedures](https://orpc.dev/docs/procedure) are also compatible with [procedure contracts](https://orpc.dev/docs/contract-first/define-contract).
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
@@ -62,12 +62,10 @@ declare class CreateToolError extends Error {
|
|
|
62
62
|
*/
|
|
63
63
|
declare function implementTool<TOutInput, TInOutput>(contract: ContractProcedure<Schema<any, TOutInput>, Schema<TInOutput, any>, any, AiSdkToolMeta>, ...rest: MaybeOptionalOptions<SetOptional<Tool<TOutInput, TInOutput>, 'inputSchema' | 'outputSchema'>>): Tool<TOutInput, TInOutput>;
|
|
64
64
|
/**
|
|
65
|
-
* Converts a [procedure](https://orpc.
|
|
65
|
+
* Converts a [procedure](https://orpc.dev/docs/procedure) into an [AI SDK Tool](https://ai-sdk.dev/docs/foundations/tools)
|
|
66
66
|
* by leveraging existing procedure definitions.
|
|
67
67
|
*
|
|
68
68
|
* @warning Requires a contract with an `input` schema defined.
|
|
69
|
-
* @warning Validation occurs twice (once for the tool, once for the procedure call).
|
|
70
|
-
* So validation may fail if inputSchema or outputSchema transform the data into different shapes.
|
|
71
69
|
*
|
|
72
70
|
* @example
|
|
73
71
|
* ```ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { call } from '@orpc/server';
|
|
1
|
+
import { Procedure, call } from '@orpc/server';
|
|
2
2
|
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
export { AsyncIteratorClass, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
4
4
|
import { tool } from 'ai';
|
|
@@ -22,9 +22,20 @@ function implementTool(contract, ...rest) {
|
|
|
22
22
|
function createTool(procedure, ...rest) {
|
|
23
23
|
const options = resolveMaybeOptionalOptions(rest);
|
|
24
24
|
return implementTool(procedure, {
|
|
25
|
-
execute: (input) => {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
execute: ((input, callingOptions) => {
|
|
26
|
+
const disabledValidation = new Procedure({
|
|
27
|
+
...procedure["~orpc"],
|
|
28
|
+
inputValidationIndex: Number.NaN,
|
|
29
|
+
// disable input validation
|
|
30
|
+
outputValidationIndex: Number.NaN
|
|
31
|
+
// disable output validation
|
|
32
|
+
});
|
|
33
|
+
return call(
|
|
34
|
+
disabledValidation,
|
|
35
|
+
input,
|
|
36
|
+
{ signal: callingOptions.abortSignal, ...options }
|
|
37
|
+
);
|
|
38
|
+
}),
|
|
28
39
|
...options
|
|
29
40
|
});
|
|
30
41
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/ai-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.b81d47f",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/unnoq/orpc.git",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"ai": ">=5.0.76"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@orpc/
|
|
31
|
-
"@orpc/
|
|
32
|
-
"@orpc/server": "0.0.0-next.
|
|
33
|
-
"@orpc/
|
|
30
|
+
"@orpc/contract": "0.0.0-next.b81d47f",
|
|
31
|
+
"@orpc/shared": "0.0.0-next.b81d47f",
|
|
32
|
+
"@orpc/server": "0.0.0-next.b81d47f",
|
|
33
|
+
"@orpc/client": "0.0.0-next.b81d47f"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"ai": "6.0.0-beta.85",
|