ai-tool-set 0.1.0-alpha.4 → 1.0.0
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 +8 -8
- package/dist/index.d.mts +3 -3
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -467,35 +467,35 @@ type MyUIMessage = UIMessage<unknown, any, InferUIToolSet<typeof toolSet>>;
|
|
|
467
467
|
// message.parts[0].output // typed as search tool's return type
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
### `
|
|
470
|
+
### `InferActiveTools`
|
|
471
471
|
|
|
472
472
|
Extract the tool names tracked as active from an immutable `ToolSet` instance. Tracks tools from `.activate()` and `.deactivateWhen()`.
|
|
473
473
|
|
|
474
474
|
> [!NOTE]
|
|
475
|
-
> `
|
|
475
|
+
> `InferActiveTools` returns `never` for mutable toolsets, since TypeScript cannot track type changes on the same reference across method calls.
|
|
476
476
|
|
|
477
477
|
```ts
|
|
478
|
-
import type {
|
|
478
|
+
import type { InferActiveTools } from 'ai-tool-set';
|
|
479
479
|
|
|
480
480
|
const toolSet = createToolSet({ tools }).deactivate(['cancel_order']);
|
|
481
481
|
|
|
482
|
-
type Active =
|
|
482
|
+
type Active = InferActiveTools<typeof toolSet>;
|
|
483
483
|
// 'search' | 'list_orders'
|
|
484
484
|
```
|
|
485
485
|
|
|
486
|
-
### `
|
|
486
|
+
### `InferInactiveTools`
|
|
487
487
|
|
|
488
488
|
Extract the tool names tracked as inactive from an immutable `ToolSet` instance. Tracks tools from `.deactivate()` and `.activateWhen()`.
|
|
489
489
|
|
|
490
490
|
> [!NOTE]
|
|
491
|
-
> `
|
|
491
|
+
> `InferInactiveTools` returns `never` for mutable toolsets, since TypeScript cannot track type changes on the same reference across method calls.
|
|
492
492
|
|
|
493
493
|
```ts
|
|
494
|
-
import type {
|
|
494
|
+
import type { InferInactiveTools } from 'ai-tool-set';
|
|
495
495
|
|
|
496
496
|
const toolSet = createToolSet({ tools }).deactivate(['cancel_order']);
|
|
497
497
|
|
|
498
|
-
type Inactive =
|
|
498
|
+
type Inactive = InferInactiveTools<typeof toolSet>;
|
|
499
499
|
// 'cancel_order'
|
|
500
500
|
```
|
|
501
501
|
|
package/dist/index.d.mts
CHANGED
|
@@ -15,12 +15,12 @@ type InferUIToolSet<T extends ToolRecord | AnyToolSet> = { [K in keyof InferTool
|
|
|
15
15
|
* Extract tool names tracked as active from an ImmutableToolSet instance.
|
|
16
16
|
* Returns `never` for MutableToolSet (cannot be determined at compile time).
|
|
17
17
|
*/
|
|
18
|
-
type
|
|
18
|
+
type InferActiveTools<T extends AnyToolSet> = T extends ImmutableToolSet<any, any, any, infer A, any> ? A : never;
|
|
19
19
|
/**
|
|
20
20
|
* Extract tool names tracked as inactive from an ImmutableToolSet instance.
|
|
21
21
|
* Returns `never` for MutableToolSet (cannot be determined at compile time).
|
|
22
22
|
*/
|
|
23
|
-
type
|
|
23
|
+
type InferInactiveTools<T extends AnyToolSet> = T extends ImmutableToolSet<any, any, any, any, infer D> ? D : never;
|
|
24
24
|
/**
|
|
25
25
|
* Input passed to activation predicates.
|
|
26
26
|
* Use `ActivationInput<MyMsg>` to get per-tool narrowing in callbacks.
|
|
@@ -152,4 +152,4 @@ declare function createToolSet<const TOOLS extends ToolRecord, MESSAGE extends M
|
|
|
152
152
|
mutable?: false;
|
|
153
153
|
}): ImmutableToolSet<TOOLS, MESSAGE, CONTEXT, keyof TOOLS & string>;
|
|
154
154
|
//#endregion
|
|
155
|
-
export { type ActivationInput, type
|
|
155
|
+
export { type ActivationInput, type InferActiveTools, type InferInactiveTools, type InferToolSet, type InferUIToolSet, createToolSet };
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-tool-set",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"keywords": [
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI SDK: Manage tool activation with type-safe, chainable tool sets",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"ai-sdk",
|
|
8
|
+
"tools",
|
|
9
|
+
"toolset"
|
|
10
|
+
],
|
|
6
11
|
"license": "MIT",
|
|
7
12
|
"author": "Chris Cook",
|
|
8
13
|
"repository": {
|