vovk 3.2.2 → 3.4.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/dist/internal.d.ts +2 -1
- package/dist/internal.js +2 -0
- package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +21 -1
- package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +37 -12
- package/dist/openapi/openAPIToVovkSchema/index.js +3 -2
- package/dist/tools/createTool.d.ts +32 -32
- package/dist/tools/createToolFactory.d.ts +33 -33
- package/dist/tools/deriveTools.d.ts +5 -5
- package/dist/tools/deriveTools.js +5 -6
- package/dist/types/standard-tool.d.ts +17 -0
- package/dist/types/standard-tool.js +1 -0
- package/dist/types/tools.d.ts +20 -16
- package/dist/validation/createStandardValidation.d.ts +32 -32
- package/dist/validation/procedure.d.ts +32 -32
- package/dist/validation/validationSchemasObjectToSingleValidationSchema.d.ts +17 -0
- package/dist/validation/validationSchemasObjectToSingleValidationSchema.js +92 -0
- package/package.json +1 -1
package/dist/internal.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export { deepExtend } from './utils/deepExtend.js';
|
|
|
2
2
|
export { resolveGeneratorConfigValues } from './core/resolveGeneratorConfigValues.js';
|
|
3
3
|
export { createCodeSamples } from './samples/createCodeSamples.js';
|
|
4
4
|
export { withValidationLibrary } from './validation/withValidationLibrary.js';
|
|
5
|
+
export { validationSchemasObjectToSingleValidationSchema } from './validation/validationSchemasObjectToSingleValidationSchema.js';
|
|
5
6
|
export { operation } from './openapi/operation.js';
|
|
6
7
|
export { openAPIToVovkSchema } from './openapi/openAPIToVovkSchema/index.js';
|
|
8
|
+
export { applyComponentsSchemas, reattachMixinDefs, } from './openapi/openAPIToVovkSchema/applyComponentsSchemas.js';
|
|
7
9
|
export { vovkSchemaToOpenAPI } from './openapi/vovkSchemaToOpenAPI.js';
|
|
8
10
|
export { readableStreamToAsyncIterable } from './client/defaultStreamHandler.js';
|
|
9
11
|
export { VovkSchemaIdEnum } from './types/enums.js';
|
|
10
|
-
export type { VovkToolDerived, VovkToolNonDerived } from './types/tools.js';
|
|
11
12
|
export type { MCPModelOutput } from './tools/toModelOutputMCP.js';
|
|
12
13
|
export type { VovkErrorResponse, VovkMetaSchema, VovkSegmentSchema, VovkControllerSchema, VovkHandlerSchema, VovkValidationType, } from './types/core.js';
|
|
13
14
|
export type { VovkTypedProcedure } from './types/validation.js';
|
package/dist/internal.js
CHANGED
|
@@ -3,8 +3,10 @@ export { deepExtend } from './utils/deepExtend.js';
|
|
|
3
3
|
export { resolveGeneratorConfigValues } from './core/resolveGeneratorConfigValues.js';
|
|
4
4
|
export { createCodeSamples } from './samples/createCodeSamples.js';
|
|
5
5
|
export { withValidationLibrary } from './validation/withValidationLibrary.js';
|
|
6
|
+
export { validationSchemasObjectToSingleValidationSchema } from './validation/validationSchemasObjectToSingleValidationSchema.js';
|
|
6
7
|
export { operation } from './openapi/operation.js';
|
|
7
8
|
export { openAPIToVovkSchema } from './openapi/openAPIToVovkSchema/index.js';
|
|
9
|
+
export { applyComponentsSchemas, reattachMixinDefs, } from './openapi/openAPIToVovkSchema/applyComponentsSchemas.js';
|
|
8
10
|
export { vovkSchemaToOpenAPI } from './openapi/vovkSchemaToOpenAPI.js';
|
|
9
11
|
export { readableStreamToAsyncIterable } from './client/defaultStreamHandler.js';
|
|
10
12
|
export { VovkSchemaIdEnum } from './types/enums.js';
|
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
import type { ComponentsObject } from 'openapi3-ts/oas31';
|
|
2
2
|
import type { VovkJSONSchemaBase } from '../../types/json-schema.js';
|
|
3
|
-
export declare function applyComponentsSchemas(schema: VovkJSONSchemaBase, components: ComponentsObject['schemas'], mixinName: string
|
|
3
|
+
export declare function applyComponentsSchemas(schema: VovkJSONSchemaBase, components: ComponentsObject['schemas'], mixinName: string,
|
|
4
|
+
/**
|
|
5
|
+
* true (default): embed the ref closure in `$defs` (self-contained — for AJV + Rust).
|
|
6
|
+
* false: keep `#/components/schemas/X`, emit no `$defs` (response slots, typed via
|
|
7
|
+
* `x-tsType`) — avoids the per-handler dup that overflows JSON.stringify on big specs.
|
|
8
|
+
*/
|
|
9
|
+
emitDefs?: boolean): VovkJSONSchemaBase | VovkJSONSchemaBase[];
|
|
10
|
+
/**
|
|
11
|
+
* Re-attach a response slot's `$defs` closure at render time, for generators that
|
|
12
|
+
* resolve `$ref` against a self-contained schema (Rust). Pulls components from the
|
|
13
|
+
* segment's shared meta → identical to the `emitDefs=true` slot. No-op for non-mixin.
|
|
14
|
+
*/
|
|
15
|
+
export declare function reattachMixinDefs(slot: VovkJSONSchemaBase | undefined, segment: {
|
|
16
|
+
segmentType?: string;
|
|
17
|
+
segmentName: string;
|
|
18
|
+
meta?: {
|
|
19
|
+
openAPIObject?: {
|
|
20
|
+
components?: ComponentsObject;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}): VovkJSONSchemaBase | VovkJSONSchemaBase[] | undefined;
|
|
@@ -14,14 +14,22 @@ function cloneJSON(obj) {
|
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
|
-
export function applyComponentsSchemas(schema, components, mixinName
|
|
17
|
+
export function applyComponentsSchemas(schema, components, mixinName,
|
|
18
|
+
/**
|
|
19
|
+
* true (default): embed the ref closure in `$defs` (self-contained — for AJV + Rust).
|
|
20
|
+
* false: keep `#/components/schemas/X`, emit no `$defs` (response slots, typed via
|
|
21
|
+
* `x-tsType`) — avoids the per-handler dup that overflows JSON.stringify on big specs.
|
|
22
|
+
*/
|
|
23
|
+
emitDefs = true) {
|
|
18
24
|
const key = 'components/schemas';
|
|
19
25
|
if (!components || !Object.keys(components).length)
|
|
20
26
|
return schema;
|
|
21
27
|
// Create a deep copy of the schema
|
|
22
28
|
const result = cloneJSON(schema);
|
|
23
|
-
// Initialize $defs
|
|
24
|
-
|
|
29
|
+
// Initialize $defs only when embedding (self-contained slots).
|
|
30
|
+
if (emitDefs) {
|
|
31
|
+
result.$defs = result.$defs || {};
|
|
32
|
+
}
|
|
25
33
|
// Set to track components we've added to $defs
|
|
26
34
|
const addedComponents = new Set();
|
|
27
35
|
// Process a schema object and replace $refs
|
|
@@ -38,18 +46,22 @@ export function applyComponentsSchemas(schema, components, mixinName) {
|
|
|
38
46
|
if ($ref && typeof $ref === 'string' && $ref.startsWith(`#/${key}/`)) {
|
|
39
47
|
const componentName = $ref.replace(`#/${key}/`, '');
|
|
40
48
|
if (components?.[componentName]) {
|
|
41
|
-
|
|
49
|
+
// Set `x-tsType` so TS resolves the ref without local `$defs`.
|
|
42
50
|
newObj['x-tsType'] ??= `Mixins.${upperFirst(camelCase(mixinName))}.${upperFirst(camelCase(componentName))}`;
|
|
51
|
+
if (emitDefs) {
|
|
52
|
+
// Self-contained slot: local $defs + embedded closure.
|
|
53
|
+
newObj.$ref = `#/$defs/${componentName}`;
|
|
54
|
+
if (!addedComponents.has(componentName)) {
|
|
55
|
+
addedComponents.add(componentName);
|
|
56
|
+
if (result.$defs) {
|
|
57
|
+
result.$defs[componentName] = processSchema(cloneJSON(components[componentName]));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// emitDefs === false: keep `#/components/schemas/X`, no `$defs` (lives once in meta).
|
|
43
62
|
}
|
|
44
63
|
else {
|
|
45
|
-
delete newObj.$ref; //
|
|
46
|
-
}
|
|
47
|
-
// Add the component to $defs if not already added
|
|
48
|
-
if (!addedComponents.has(componentName) && components?.[componentName]) {
|
|
49
|
-
addedComponents.add(componentName);
|
|
50
|
-
if (result.$defs) {
|
|
51
|
-
result.$defs[componentName] = processSchema(cloneJSON(components[componentName]));
|
|
52
|
-
}
|
|
64
|
+
delete newObj.$ref; // $ref to a component not in components (e.g. Telegram API)
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
67
|
// Process properties recursively
|
|
@@ -63,3 +75,16 @@ export function applyComponentsSchemas(schema, components, mixinName) {
|
|
|
63
75
|
// Process the main schema
|
|
64
76
|
return processSchema(result);
|
|
65
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Re-attach a response slot's `$defs` closure at render time, for generators that
|
|
80
|
+
* resolve `$ref` against a self-contained schema (Rust). Pulls components from the
|
|
81
|
+
* segment's shared meta → identical to the `emitDefs=true` slot. No-op for non-mixin.
|
|
82
|
+
*/
|
|
83
|
+
export function reattachMixinDefs(slot, segment) {
|
|
84
|
+
if (!slot || segment?.segmentType !== 'mixin')
|
|
85
|
+
return slot;
|
|
86
|
+
const components = segment.meta?.openAPIObject?.components?.schemas;
|
|
87
|
+
if (!components)
|
|
88
|
+
return slot;
|
|
89
|
+
return applyComponentsSchemas(slot, components, segment.segmentName, true);
|
|
90
|
+
}
|
|
@@ -140,10 +140,11 @@ export function openAPIToVovkSchema({ apiRoot, source: { object: openAPIObject }
|
|
|
140
140
|
body: applyComponentsSchemas(body, componentsSchemas, segmentName),
|
|
141
141
|
}),
|
|
142
142
|
...(output && {
|
|
143
|
-
|
|
143
|
+
// Response slot: not validated + typed via x-tsType → skip $defs (dedup).
|
|
144
|
+
output: applyComponentsSchemas(output, componentsSchemas, segmentName, false),
|
|
144
145
|
}),
|
|
145
146
|
...(iteration && {
|
|
146
|
-
iteration: applyComponentsSchemas(iteration, componentsSchemas, segmentName),
|
|
147
|
+
iteration: applyComponentsSchemas(iteration, componentsSchemas, segmentName, false),
|
|
147
148
|
}),
|
|
148
149
|
},
|
|
149
150
|
};
|
|
@@ -7,120 +7,120 @@ export declare const createTool: {
|
|
|
7
7
|
name: string;
|
|
8
8
|
title?: string;
|
|
9
9
|
description: string;
|
|
10
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
11
|
-
onError?: ((error: Error, tool: import("../
|
|
10
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
11
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
12
12
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
13
13
|
} & {
|
|
14
14
|
inputSchema: import("../types/validation.js").CombinedSpec<TInput, TInput>;
|
|
15
15
|
} & {
|
|
16
16
|
outputSchema: import("../types/validation.js").CombinedSpec<TOutput, TOutput>;
|
|
17
17
|
} & {
|
|
18
|
-
execute: (input: TInput, processingMeta?:
|
|
18
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
19
19
|
toModelOutput: TToModelOutput;
|
|
20
|
-
}): import("../
|
|
20
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
21
21
|
<TInput, TOutput>(options: {
|
|
22
22
|
name: string;
|
|
23
23
|
title?: string;
|
|
24
24
|
description: string;
|
|
25
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
26
|
-
onError?: ((error: Error, tool: import("../
|
|
25
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
26
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
27
27
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
28
28
|
} & {
|
|
29
29
|
inputSchema: import("../types/validation.js").CombinedSpec<TInput, TInput>;
|
|
30
30
|
} & {
|
|
31
31
|
outputSchema: import("../types/validation.js").CombinedSpec<TOutput, TOutput>;
|
|
32
32
|
} & {
|
|
33
|
-
execute: (input: TInput, processingMeta?:
|
|
33
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
34
34
|
toModelOutput?: undefined;
|
|
35
|
-
}): import("../
|
|
35
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
36
36
|
<TInput, TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
37
37
|
name: string;
|
|
38
38
|
title?: string;
|
|
39
39
|
description: string;
|
|
40
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
41
|
-
onError?: ((error: Error, tool: import("../
|
|
40
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
41
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
42
42
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
43
43
|
} & {
|
|
44
44
|
inputSchema: import("../types/validation.js").CombinedSpec<TInput, TInput>;
|
|
45
45
|
} & {
|
|
46
46
|
outputSchema?: undefined;
|
|
47
47
|
} & {
|
|
48
|
-
execute: (input: TInput, processingMeta?:
|
|
48
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
49
49
|
toModelOutput: TToModelOutput;
|
|
50
|
-
}): import("../
|
|
50
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
51
51
|
<TInput, TOutput>(options: {
|
|
52
52
|
name: string;
|
|
53
53
|
title?: string;
|
|
54
54
|
description: string;
|
|
55
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
56
|
-
onError?: ((error: Error, tool: import("../
|
|
55
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
56
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
57
57
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
58
58
|
} & {
|
|
59
59
|
inputSchema: import("../types/validation.js").CombinedSpec<TInput, TInput>;
|
|
60
60
|
} & {
|
|
61
61
|
outputSchema?: undefined;
|
|
62
62
|
} & {
|
|
63
|
-
execute: (input: TInput, processingMeta?:
|
|
63
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
64
64
|
toModelOutput?: undefined;
|
|
65
|
-
}): import("../
|
|
65
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
66
66
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
67
67
|
name: string;
|
|
68
68
|
title?: string;
|
|
69
69
|
description: string;
|
|
70
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
71
|
-
onError?: ((error: Error, tool: import("../
|
|
70
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
71
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
72
72
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
73
73
|
} & {
|
|
74
74
|
inputSchema?: undefined;
|
|
75
75
|
} & {
|
|
76
76
|
outputSchema: import("../types/validation.js").CombinedSpec<TOutput, TOutput>;
|
|
77
77
|
} & {
|
|
78
|
-
execute: (input: null, processingMeta?:
|
|
78
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
79
79
|
toModelOutput: TToModelOutput;
|
|
80
|
-
}): import("../
|
|
80
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
81
81
|
<TOutput>(options: {
|
|
82
82
|
name: string;
|
|
83
83
|
title?: string;
|
|
84
84
|
description: string;
|
|
85
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
86
|
-
onError?: ((error: Error, tool: import("../
|
|
85
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
86
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
87
87
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
88
88
|
} & {
|
|
89
89
|
inputSchema?: undefined;
|
|
90
90
|
} & {
|
|
91
91
|
outputSchema: import("../types/validation.js").CombinedSpec<TOutput, TOutput>;
|
|
92
92
|
} & {
|
|
93
|
-
execute: (input: null, processingMeta?:
|
|
93
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
94
94
|
toModelOutput?: undefined;
|
|
95
|
-
}): import("../
|
|
95
|
+
}): import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
96
96
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
97
97
|
name: string;
|
|
98
98
|
title?: string;
|
|
99
99
|
description: string;
|
|
100
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
101
|
-
onError?: ((error: Error, tool: import("../
|
|
100
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
101
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
102
102
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
103
103
|
} & {
|
|
104
104
|
inputSchema?: undefined;
|
|
105
105
|
} & {
|
|
106
106
|
outputSchema?: undefined;
|
|
107
107
|
} & {
|
|
108
|
-
execute: (input: null, processingMeta?:
|
|
108
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
109
109
|
toModelOutput: TToModelOutput;
|
|
110
|
-
}): import("../
|
|
110
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("./toModelOutputDefault.js").ToModelOutputDefaultFn ? import("./toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
111
111
|
<TOutput>(options: {
|
|
112
112
|
name: string;
|
|
113
113
|
title?: string;
|
|
114
114
|
description: string;
|
|
115
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
116
|
-
onError?: ((error: Error, tool: import("../
|
|
115
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
116
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
117
117
|
target?: import("../types/validation.js").CombinedSpec.Target;
|
|
118
118
|
} & {
|
|
119
119
|
inputSchema?: undefined;
|
|
120
120
|
} & {
|
|
121
121
|
outputSchema?: undefined;
|
|
122
122
|
} & {
|
|
123
|
-
execute: (input: null, processingMeta?:
|
|
123
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
124
124
|
toModelOutput?: undefined;
|
|
125
|
-
}): import("../
|
|
125
|
+
}): import("../index.js").VovkTool<null, TOutput, import("./toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
126
126
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VovkValidationType } from '../types/core.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { VovkTool } from '../types/tools.js';
|
|
3
3
|
import type { DefaultModelOutput, ToModelOutputDefaultFn } from './toModelOutputDefault.js';
|
|
4
4
|
import type { CombinedSpec } from '../types/validation.js';
|
|
5
5
|
import type { KnownAny } from '../types/utils.js';
|
|
@@ -15,121 +15,121 @@ export declare function createToolFactory({ toJSONSchema, }: {
|
|
|
15
15
|
name: string;
|
|
16
16
|
title?: string;
|
|
17
17
|
description: string;
|
|
18
|
-
onExecute?: ((result: unknown, tool:
|
|
19
|
-
onError?: ((error: Error, tool:
|
|
18
|
+
onExecute?: ((result: unknown, tool: VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
19
|
+
onError?: ((error: Error, tool: VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
20
20
|
target?: CombinedSpec.Target;
|
|
21
21
|
} & {
|
|
22
22
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
23
23
|
} & {
|
|
24
24
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
25
25
|
} & {
|
|
26
|
-
execute: (input: TInput, processingMeta?:
|
|
26
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
27
27
|
toModelOutput: TToModelOutput;
|
|
28
|
-
}):
|
|
28
|
+
}): VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>;
|
|
29
29
|
<TInput, TOutput>(options: {
|
|
30
30
|
name: string;
|
|
31
31
|
title?: string;
|
|
32
32
|
description: string;
|
|
33
|
-
onExecute?: ((result: unknown, tool:
|
|
34
|
-
onError?: ((error: Error, tool:
|
|
33
|
+
onExecute?: ((result: unknown, tool: VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
34
|
+
onError?: ((error: Error, tool: VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
35
35
|
target?: CombinedSpec.Target;
|
|
36
36
|
} & {
|
|
37
37
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
38
38
|
} & {
|
|
39
39
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
40
40
|
} & {
|
|
41
|
-
execute: (input: TInput, processingMeta?:
|
|
41
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
42
42
|
toModelOutput?: undefined;
|
|
43
|
-
}):
|
|
43
|
+
}): VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>;
|
|
44
44
|
<TInput, TOutput, TToModelOutput extends AnyToModelOutputFn>(options: {
|
|
45
45
|
name: string;
|
|
46
46
|
title?: string;
|
|
47
47
|
description: string;
|
|
48
|
-
onExecute?: ((result: unknown, tool:
|
|
49
|
-
onError?: ((error: Error, tool:
|
|
48
|
+
onExecute?: ((result: unknown, tool: VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
49
|
+
onError?: ((error: Error, tool: VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
50
50
|
target?: CombinedSpec.Target;
|
|
51
51
|
} & {
|
|
52
52
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
53
53
|
} & {
|
|
54
54
|
outputSchema?: undefined;
|
|
55
55
|
} & {
|
|
56
|
-
execute: (input: TInput, processingMeta?:
|
|
56
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
57
57
|
toModelOutput: TToModelOutput;
|
|
58
|
-
}):
|
|
58
|
+
}): VovkTool<TInput, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>;
|
|
59
59
|
<TInput, TOutput>(options: {
|
|
60
60
|
name: string;
|
|
61
61
|
title?: string;
|
|
62
62
|
description: string;
|
|
63
|
-
onExecute?: ((result: unknown, tool:
|
|
64
|
-
onError?: ((error: Error, tool:
|
|
63
|
+
onExecute?: ((result: unknown, tool: VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
64
|
+
onError?: ((error: Error, tool: VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
65
65
|
target?: CombinedSpec.Target;
|
|
66
66
|
} & {
|
|
67
67
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
68
68
|
} & {
|
|
69
69
|
outputSchema?: undefined;
|
|
70
70
|
} & {
|
|
71
|
-
execute: (input: TInput, processingMeta?:
|
|
71
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
72
72
|
toModelOutput?: undefined;
|
|
73
|
-
}):
|
|
73
|
+
}): VovkTool<TInput, TOutput, DefaultModelOutput<TOutput>>;
|
|
74
74
|
<TOutput, TToModelOutput extends AnyToModelOutputFn>(options: {
|
|
75
75
|
name: string;
|
|
76
76
|
title?: string;
|
|
77
77
|
description: string;
|
|
78
|
-
onExecute?: ((result: unknown, tool:
|
|
79
|
-
onError?: ((error: Error, tool:
|
|
78
|
+
onExecute?: ((result: unknown, tool: VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
79
|
+
onError?: ((error: Error, tool: VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
80
80
|
target?: CombinedSpec.Target;
|
|
81
81
|
} & {
|
|
82
82
|
inputSchema?: undefined;
|
|
83
83
|
} & {
|
|
84
84
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
85
85
|
} & {
|
|
86
|
-
execute: (input: null, processingMeta?:
|
|
86
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
87
87
|
toModelOutput: TToModelOutput;
|
|
88
|
-
}):
|
|
88
|
+
}): VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>;
|
|
89
89
|
<TOutput>(options: {
|
|
90
90
|
name: string;
|
|
91
91
|
title?: string;
|
|
92
92
|
description: string;
|
|
93
|
-
onExecute?: ((result: unknown, tool:
|
|
94
|
-
onError?: ((error: Error, tool:
|
|
93
|
+
onExecute?: ((result: unknown, tool: VovkTool<null, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
94
|
+
onError?: ((error: Error, tool: VovkTool<null, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
95
95
|
target?: CombinedSpec.Target;
|
|
96
96
|
} & {
|
|
97
97
|
inputSchema?: undefined;
|
|
98
98
|
} & {
|
|
99
99
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
100
100
|
} & {
|
|
101
|
-
execute: (input: null, processingMeta?:
|
|
101
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
102
102
|
toModelOutput?: undefined;
|
|
103
|
-
}):
|
|
103
|
+
}): VovkTool<null, TOutput, DefaultModelOutput<TOutput>>;
|
|
104
104
|
<TOutput, TToModelOutput extends AnyToModelOutputFn>(options: {
|
|
105
105
|
name: string;
|
|
106
106
|
title?: string;
|
|
107
107
|
description: string;
|
|
108
|
-
onExecute?: ((result: unknown, tool:
|
|
109
|
-
onError?: ((error: Error, tool:
|
|
108
|
+
onExecute?: ((result: unknown, tool: VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
109
|
+
onError?: ((error: Error, tool: VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>) => void) | undefined;
|
|
110
110
|
target?: CombinedSpec.Target;
|
|
111
111
|
} & {
|
|
112
112
|
inputSchema?: undefined;
|
|
113
113
|
} & {
|
|
114
114
|
outputSchema?: undefined;
|
|
115
115
|
} & {
|
|
116
|
-
execute: (input: null, processingMeta?:
|
|
116
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
117
117
|
toModelOutput: TToModelOutput;
|
|
118
|
-
}):
|
|
118
|
+
}): VovkTool<null, TOutput, InferFormattedOutput<TToModelOutput, TOutput>>;
|
|
119
119
|
<TOutput>(options: {
|
|
120
120
|
name: string;
|
|
121
121
|
title?: string;
|
|
122
122
|
description: string;
|
|
123
|
-
onExecute?: ((result: unknown, tool:
|
|
124
|
-
onError?: ((error: Error, tool:
|
|
123
|
+
onExecute?: ((result: unknown, tool: VovkTool<null, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
124
|
+
onError?: ((error: Error, tool: VovkTool<null, TOutput, DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
125
125
|
target?: CombinedSpec.Target;
|
|
126
126
|
} & {
|
|
127
127
|
inputSchema?: undefined;
|
|
128
128
|
} & {
|
|
129
129
|
outputSchema?: undefined;
|
|
130
130
|
} & {
|
|
131
|
-
execute: (input: null, processingMeta?:
|
|
131
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
132
132
|
toModelOutput?: undefined;
|
|
133
|
-
}):
|
|
133
|
+
}): VovkTool<null, TOutput, DefaultModelOutput<TOutput>>;
|
|
134
134
|
};
|
|
135
135
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DefaultModelOutput } from './toModelOutputDefault.js';
|
|
2
2
|
import type { VovkRequest } from '../types/request.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { VovkTool, ToModelOutputFn } from '../types/tools.js';
|
|
4
4
|
type DerivedToolInput = {
|
|
5
5
|
body?: unknown;
|
|
6
6
|
query?: unknown;
|
|
@@ -9,12 +9,12 @@ type DerivedToolInput = {
|
|
|
9
9
|
type DeriveToolsBaseOptions<TOutput = unknown, TFormattedOutput = unknown> = {
|
|
10
10
|
modules: Record<string, object>;
|
|
11
11
|
meta?: Record<string, unknown>;
|
|
12
|
-
onExecute?: (result: unknown, tool:
|
|
13
|
-
onError?: (error: Error, tool:
|
|
12
|
+
onExecute?: (result: unknown, tool: VovkTool<DerivedToolInput, TOutput, TFormattedOutput>, req: Pick<VovkRequest, 'vovk'> | null) => void;
|
|
13
|
+
onError?: (error: Error, tool: VovkTool<DerivedToolInput, TOutput, TFormattedOutput>, req: Pick<VovkRequest, 'vovk'> | null) => void;
|
|
14
14
|
};
|
|
15
15
|
type DeriveToolsResult<TOutput, TFormattedOutput> = {
|
|
16
|
-
tools:
|
|
17
|
-
toolsByName: Record<string,
|
|
16
|
+
tools: VovkTool<DerivedToolInput, TOutput, TFormattedOutput>[];
|
|
17
|
+
toolsByName: Record<string, VovkTool<DerivedToolInput, TOutput, TFormattedOutput>>;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Derives AI tools from controllers and RPC modules.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ToModelOutput } from './ToModelOutput.js';
|
|
2
|
+
import { validationSchemasObjectToSingleValidationSchema } from '../validation/validationSchemasObjectToSingleValidationSchema.js';
|
|
2
3
|
async function caller({ handler, handlerName, body, query, params, meta, toModelOutput }, tool) {
|
|
3
4
|
if (!handler.isRPC && !handler.fn) {
|
|
4
5
|
throw new Error('Handler is not a valid RPC or controller method');
|
|
@@ -27,10 +28,7 @@ async function caller({ handler, handlerName, body, query, params, meta, toModel
|
|
|
27
28
|
else {
|
|
28
29
|
throw new Error(`Unable to call handler "${handlerName}". It's neither RPC nor controller method with "fn" interface.`);
|
|
29
30
|
}
|
|
30
|
-
return [
|
|
31
|
-
await toModelOutput(result, tool, req),
|
|
32
|
-
req,
|
|
33
|
-
];
|
|
31
|
+
return [await toModelOutput(result, tool, req), req];
|
|
34
32
|
}
|
|
35
33
|
catch (e) {
|
|
36
34
|
return [await toModelOutput(e, tool, null), null];
|
|
@@ -46,7 +44,8 @@ const makeTool = ({ moduleName, handlerName, module, meta, toModelOutput, onExec
|
|
|
46
44
|
}
|
|
47
45
|
const { schema, definition } = handler;
|
|
48
46
|
const inputSchemas = Object.fromEntries(['body', 'query', 'params'].map((key) => [key, definition?.[key]]).filter(([, value]) => Boolean(value)));
|
|
49
|
-
|
|
47
|
+
const inputSchema = Object.keys(inputSchemas).length > 0 ? validationSchemasObjectToSingleValidationSchema(inputSchemas) : undefined;
|
|
48
|
+
if (!schema?.operationObject) {
|
|
50
49
|
throw new Error(`Handler "${handlerName}" in module "${moduleName}" does not have a valid schema.`);
|
|
51
50
|
}
|
|
52
51
|
const execute = async (input) => {
|
|
@@ -93,7 +92,7 @@ const makeTool = ({ moduleName, handlerName, module, meta, toModelOutput, onExec
|
|
|
93
92
|
type: 'function',
|
|
94
93
|
execute,
|
|
95
94
|
name: schema.operationObject?.['x-tool']?.name ?? `${moduleName}_${handlerName}`,
|
|
96
|
-
inputSchema:
|
|
95
|
+
inputSchema: inputSchema,
|
|
97
96
|
outputSchema: definition?.output,
|
|
98
97
|
title: schema.operationObject?.['x-tool']?.title ?? schema.operationObject?.summary,
|
|
99
98
|
description: schema.operationObject?.['x-tool']?.description ??
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CombinedSpec } from './validation.js';
|
|
2
|
+
import type { KnownAny } from './utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `standard-tool` convention (https://github.com/finom/standard-tool): a neutral LLM tool shape —
|
|
5
|
+
* `name`, `description`, optional `inputSchema`/`outputSchema`, `execute`. Vendored as a type only
|
|
6
|
+
* (no logic) so `VovkTool` can extend it with zero added dependencies. Kept identical to the
|
|
7
|
+
* `StandardTool` type published by `standard-tool` (`meta` is `KnownAny`, i.e. its `any`).
|
|
8
|
+
*/
|
|
9
|
+
export interface StandardTool<Input = unknown, Output = unknown, FormattedOutput = Output | {
|
|
10
|
+
error: string;
|
|
11
|
+
}> {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema?: CombinedSpec<Input>;
|
|
15
|
+
outputSchema?: CombinedSpec<Output>;
|
|
16
|
+
execute(input: Input, meta?: KnownAny): FormattedOutput | Promise<FormattedOutput>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { VovkJSONSchemaBase } from './json-schema.js';
|
|
2
2
|
import type { VovkRequest } from './request.js';
|
|
3
3
|
import type { CombinedSpec } from './validation.js';
|
|
4
|
+
import type { StandardTool } from './standard-tool.js';
|
|
4
5
|
import type { KnownAny } from './utils.js';
|
|
5
6
|
export type ToModelOutputFn<TInput, TOutput, TFormattedOutput> = (result: TOutput | Error, tool: VovkTool<TInput, TOutput, unknown>, req: Pick<VovkRequest, 'vovk'> | null) => TFormattedOutput | Promise<TFormattedOutput>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Vovk tool — produced by both `deriveTools` (procedures → tools) and
|
|
9
|
+
* `createTool` (standalone tools); both return the same shape. Extends the
|
|
10
|
+
* {@link StandardTool} convention with Vovk specifics (`title`, `parameters`, `type`).
|
|
11
|
+
* @see https://vovk.dev/tools
|
|
12
|
+
*/
|
|
13
|
+
export interface VovkTool<TInput = KnownAny, TOutput = KnownAny, TFormattedOutput = KnownAny> extends StandardTool<TInput, TOutput, TFormattedOutput> {
|
|
9
14
|
title: string | undefined;
|
|
10
|
-
description: string;
|
|
11
15
|
parameters: {
|
|
12
16
|
type?: 'object';
|
|
13
17
|
properties?: {
|
|
@@ -18,26 +22,26 @@ interface VovkToolCommon<TInput = unknown, TOutput = unknown, TFormattedOutput =
|
|
|
18
22
|
required?: ('body' | 'query' | 'params')[];
|
|
19
23
|
additionalProperties?: false;
|
|
20
24
|
};
|
|
21
|
-
inputSchema:
|
|
22
|
-
outputSchema:
|
|
23
|
-
|
|
25
|
+
inputSchema: TInput extends undefined ? undefined : CombinedSpec<TInput>;
|
|
26
|
+
outputSchema: TOutput extends undefined ? undefined : CombinedSpec<TOutput>;
|
|
27
|
+
/**
|
|
28
|
+
* Per-slot Standard Schemas, populated only when the tool was built via
|
|
29
|
+
* `deriveTools` from a procedure. Always `undefined` for tools built via
|
|
30
|
+
* `createTool`.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use {@link VovkTool.inputSchema} (a merged Standard Schema)
|
|
33
|
+
* instead. This field will be removed in the next major version.
|
|
34
|
+
*/
|
|
35
|
+
inputSchemas?: {
|
|
24
36
|
body?: CombinedSpec;
|
|
25
37
|
query?: CombinedSpec;
|
|
26
38
|
params?: CombinedSpec;
|
|
27
|
-
}
|
|
39
|
+
};
|
|
28
40
|
type: 'function';
|
|
29
41
|
}
|
|
30
|
-
export type VovkToolDerived<TInput, TOutput, TFormattedOutput> = VovkToolCommon<TInput, TOutput, TFormattedOutput, true>;
|
|
31
|
-
export type VovkToolNonDerived<TInput, TOutput, TFormattedOutput> = VovkToolCommon<TInput, TOutput, TFormattedOutput, false>;
|
|
32
|
-
/**
|
|
33
|
-
* Vovk tool type, which can be either derived or non-derived.
|
|
34
|
-
* @see https://vovk.dev/tools
|
|
35
|
-
*/
|
|
36
|
-
export type VovkTool<TInput = KnownAny, TOutput = KnownAny, TFormattedOutput = KnownAny> = VovkToolDerived<TInput, TOutput, TFormattedOutput> | VovkToolNonDerived<TInput, TOutput, TFormattedOutput>;
|
|
37
42
|
export type VovkToolOptions = {
|
|
38
43
|
hidden?: boolean;
|
|
39
44
|
name?: string;
|
|
40
45
|
title?: string;
|
|
41
46
|
description?: string;
|
|
42
47
|
};
|
|
43
|
-
export {};
|
|
@@ -147,122 +147,122 @@ export declare function createStandardValidation({ toJSONSchema, }: {
|
|
|
147
147
|
name: string;
|
|
148
148
|
title?: string;
|
|
149
149
|
description: string;
|
|
150
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
151
|
-
onError?: ((error: Error, tool: import("../
|
|
150
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
151
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
152
152
|
target?: CombinedSpec.Target;
|
|
153
153
|
} & {
|
|
154
154
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
155
155
|
} & {
|
|
156
156
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
157
157
|
} & {
|
|
158
|
-
execute: (input: TInput, processingMeta?:
|
|
158
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
159
159
|
toModelOutput: TToModelOutput;
|
|
160
|
-
}): import("../
|
|
160
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
161
161
|
<TInput, TOutput>(options: {
|
|
162
162
|
name: string;
|
|
163
163
|
title?: string;
|
|
164
164
|
description: string;
|
|
165
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
166
|
-
onError?: ((error: Error, tool: import("../
|
|
165
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
166
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
167
167
|
target?: CombinedSpec.Target;
|
|
168
168
|
} & {
|
|
169
169
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
170
170
|
} & {
|
|
171
171
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
172
172
|
} & {
|
|
173
|
-
execute: (input: TInput, processingMeta?:
|
|
173
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
174
174
|
toModelOutput?: undefined;
|
|
175
|
-
}): import("../
|
|
175
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
176
176
|
<TInput, TOutput, TToModelOutput extends (...args: KnownAny[]) => KnownAny>(options: {
|
|
177
177
|
name: string;
|
|
178
178
|
title?: string;
|
|
179
179
|
description: string;
|
|
180
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
181
|
-
onError?: ((error: Error, tool: import("../
|
|
180
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
181
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
182
182
|
target?: CombinedSpec.Target;
|
|
183
183
|
} & {
|
|
184
184
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
185
185
|
} & {
|
|
186
186
|
outputSchema?: undefined;
|
|
187
187
|
} & {
|
|
188
|
-
execute: (input: TInput, processingMeta?:
|
|
188
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
189
189
|
toModelOutput: TToModelOutput;
|
|
190
|
-
}): import("../
|
|
190
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
191
191
|
<TInput, TOutput>(options: {
|
|
192
192
|
name: string;
|
|
193
193
|
title?: string;
|
|
194
194
|
description: string;
|
|
195
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
196
|
-
onError?: ((error: Error, tool: import("../
|
|
195
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
196
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
197
197
|
target?: CombinedSpec.Target;
|
|
198
198
|
} & {
|
|
199
199
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
200
200
|
} & {
|
|
201
201
|
outputSchema?: undefined;
|
|
202
202
|
} & {
|
|
203
|
-
execute: (input: TInput, processingMeta?:
|
|
203
|
+
execute: (input: TInput, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
204
204
|
toModelOutput?: undefined;
|
|
205
|
-
}): import("../
|
|
205
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
206
206
|
<TOutput, TToModelOutput extends (...args: KnownAny[]) => KnownAny>(options: {
|
|
207
207
|
name: string;
|
|
208
208
|
title?: string;
|
|
209
209
|
description: string;
|
|
210
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
211
|
-
onError?: ((error: Error, tool: import("../
|
|
210
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
211
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
212
212
|
target?: CombinedSpec.Target;
|
|
213
213
|
} & {
|
|
214
214
|
inputSchema?: undefined;
|
|
215
215
|
} & {
|
|
216
216
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
217
217
|
} & {
|
|
218
|
-
execute: (input: null, processingMeta?:
|
|
218
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
219
219
|
toModelOutput: TToModelOutput;
|
|
220
|
-
}): import("../
|
|
220
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
221
221
|
<TOutput>(options: {
|
|
222
222
|
name: string;
|
|
223
223
|
title?: string;
|
|
224
224
|
description: string;
|
|
225
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
226
|
-
onError?: ((error: Error, tool: import("../
|
|
225
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
226
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
227
227
|
target?: CombinedSpec.Target;
|
|
228
228
|
} & {
|
|
229
229
|
inputSchema?: undefined;
|
|
230
230
|
} & {
|
|
231
231
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
232
232
|
} & {
|
|
233
|
-
execute: (input: null, processingMeta?:
|
|
233
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
234
234
|
toModelOutput?: undefined;
|
|
235
|
-
}): import("../
|
|
235
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
236
236
|
<TOutput, TToModelOutput extends (...args: KnownAny[]) => KnownAny>(options: {
|
|
237
237
|
name: string;
|
|
238
238
|
title?: string;
|
|
239
239
|
description: string;
|
|
240
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
241
|
-
onError?: ((error: Error, tool: import("../
|
|
240
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
241
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
242
242
|
target?: CombinedSpec.Target;
|
|
243
243
|
} & {
|
|
244
244
|
inputSchema?: undefined;
|
|
245
245
|
} & {
|
|
246
246
|
outputSchema?: undefined;
|
|
247
247
|
} & {
|
|
248
|
-
execute: (input: null, processingMeta?:
|
|
248
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
249
249
|
toModelOutput: TToModelOutput;
|
|
250
|
-
}): import("../
|
|
250
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
251
251
|
<TOutput>(options: {
|
|
252
252
|
name: string;
|
|
253
253
|
title?: string;
|
|
254
254
|
description: string;
|
|
255
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
256
|
-
onError?: ((error: Error, tool: import("../
|
|
255
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
256
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
257
257
|
target?: CombinedSpec.Target;
|
|
258
258
|
} & {
|
|
259
259
|
inputSchema?: undefined;
|
|
260
260
|
} & {
|
|
261
261
|
outputSchema?: undefined;
|
|
262
262
|
} & {
|
|
263
|
-
execute: (input: null, processingMeta?:
|
|
263
|
+
execute: (input: null, processingMeta?: KnownAny) => TOutput | Promise<TOutput>;
|
|
264
264
|
toModelOutput?: undefined;
|
|
265
|
-
}): import("../
|
|
265
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
266
266
|
};
|
|
267
267
|
};
|
|
268
268
|
export {};
|
|
@@ -141,121 +141,121 @@ export declare const procedure: (<TBody extends CombinedSpec, TQuery extends Com
|
|
|
141
141
|
name: string;
|
|
142
142
|
title?: string;
|
|
143
143
|
description: string;
|
|
144
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
145
|
-
onError?: ((error: Error, tool: import("../
|
|
144
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
145
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
146
146
|
target?: CombinedSpec.Target;
|
|
147
147
|
} & {
|
|
148
148
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
149
149
|
} & {
|
|
150
150
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
151
151
|
} & {
|
|
152
|
-
execute: (input: TInput, processingMeta?:
|
|
152
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
153
153
|
toModelOutput: TToModelOutput;
|
|
154
|
-
}): import("../
|
|
154
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
155
155
|
<TInput, TOutput>(options: {
|
|
156
156
|
name: string;
|
|
157
157
|
title?: string;
|
|
158
158
|
description: string;
|
|
159
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
160
|
-
onError?: ((error: Error, tool: import("../
|
|
159
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
160
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
161
161
|
target?: CombinedSpec.Target;
|
|
162
162
|
} & {
|
|
163
163
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
164
164
|
} & {
|
|
165
165
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
166
166
|
} & {
|
|
167
|
-
execute: (input: TInput, processingMeta?:
|
|
167
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
168
168
|
toModelOutput?: undefined;
|
|
169
|
-
}): import("../
|
|
169
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
170
170
|
<TInput, TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
171
171
|
name: string;
|
|
172
172
|
title?: string;
|
|
173
173
|
description: string;
|
|
174
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
175
|
-
onError?: ((error: Error, tool: import("../
|
|
174
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
175
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
176
176
|
target?: CombinedSpec.Target;
|
|
177
177
|
} & {
|
|
178
178
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
179
179
|
} & {
|
|
180
180
|
outputSchema?: undefined;
|
|
181
181
|
} & {
|
|
182
|
-
execute: (input: TInput, processingMeta?:
|
|
182
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
183
183
|
toModelOutput: TToModelOutput;
|
|
184
|
-
}): import("../
|
|
184
|
+
}): import("../index.js").VovkTool<TInput, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
185
185
|
<TInput, TOutput>(options: {
|
|
186
186
|
name: string;
|
|
187
187
|
title?: string;
|
|
188
188
|
description: string;
|
|
189
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
190
|
-
onError?: ((error: Error, tool: import("../
|
|
189
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
190
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
191
191
|
target?: CombinedSpec.Target;
|
|
192
192
|
} & {
|
|
193
193
|
inputSchema: CombinedSpec<TInput, TInput>;
|
|
194
194
|
} & {
|
|
195
195
|
outputSchema?: undefined;
|
|
196
196
|
} & {
|
|
197
|
-
execute: (input: TInput, processingMeta?:
|
|
197
|
+
execute: (input: TInput, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
198
198
|
toModelOutput?: undefined;
|
|
199
|
-
}): import("../
|
|
199
|
+
}): import("../index.js").VovkTool<TInput, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
200
200
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
201
201
|
name: string;
|
|
202
202
|
title?: string;
|
|
203
203
|
description: string;
|
|
204
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
205
|
-
onError?: ((error: Error, tool: import("../
|
|
204
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
205
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
206
206
|
target?: CombinedSpec.Target;
|
|
207
207
|
} & {
|
|
208
208
|
inputSchema?: undefined;
|
|
209
209
|
} & {
|
|
210
210
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
211
211
|
} & {
|
|
212
|
-
execute: (input: null, processingMeta?:
|
|
212
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
213
213
|
toModelOutput: TToModelOutput;
|
|
214
|
-
}): import("../
|
|
214
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
215
215
|
<TOutput>(options: {
|
|
216
216
|
name: string;
|
|
217
217
|
title?: string;
|
|
218
218
|
description: string;
|
|
219
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
220
|
-
onError?: ((error: Error, tool: import("../
|
|
219
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
220
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
221
221
|
target?: CombinedSpec.Target;
|
|
222
222
|
} & {
|
|
223
223
|
inputSchema?: undefined;
|
|
224
224
|
} & {
|
|
225
225
|
outputSchema: CombinedSpec<TOutput, TOutput>;
|
|
226
226
|
} & {
|
|
227
|
-
execute: (input: null, processingMeta?:
|
|
227
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
228
228
|
toModelOutput?: undefined;
|
|
229
|
-
}): import("../
|
|
229
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
230
230
|
<TOutput, TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => import("../types/utils.js").KnownAny>(options: {
|
|
231
231
|
name: string;
|
|
232
232
|
title?: string;
|
|
233
233
|
description: string;
|
|
234
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
235
|
-
onError?: ((error: Error, tool: import("../
|
|
234
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
235
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>) => void) | undefined;
|
|
236
236
|
target?: CombinedSpec.Target;
|
|
237
237
|
} & {
|
|
238
238
|
inputSchema?: undefined;
|
|
239
239
|
} & {
|
|
240
240
|
outputSchema?: undefined;
|
|
241
241
|
} & {
|
|
242
|
-
execute: (input: null, processingMeta?:
|
|
242
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
243
243
|
toModelOutput: TToModelOutput;
|
|
244
|
-
}): import("../
|
|
244
|
+
}): import("../index.js").VovkTool<null, TOutput, TToModelOutput extends import("../tools/toModelOutputDefault.js").ToModelOutputDefaultFn ? import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput> : TToModelOutput extends (...args: import("../types/utils.js").KnownAny[]) => infer R ? R extends Promise<infer U> ? U : R : unknown>;
|
|
245
245
|
<TOutput>(options: {
|
|
246
246
|
name: string;
|
|
247
247
|
title?: string;
|
|
248
248
|
description: string;
|
|
249
|
-
onExecute?: ((result: unknown, tool: import("../
|
|
250
|
-
onError?: ((error: Error, tool: import("../
|
|
249
|
+
onExecute?: ((result: unknown, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
250
|
+
onError?: ((error: Error, tool: import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>) => void) | undefined;
|
|
251
251
|
target?: CombinedSpec.Target;
|
|
252
252
|
} & {
|
|
253
253
|
inputSchema?: undefined;
|
|
254
254
|
} & {
|
|
255
255
|
outputSchema?: undefined;
|
|
256
256
|
} & {
|
|
257
|
-
execute: (input: null, processingMeta?:
|
|
257
|
+
execute: (input: null, processingMeta?: import("../types/utils.js").KnownAny) => TOutput | Promise<TOutput>;
|
|
258
258
|
toModelOutput?: undefined;
|
|
259
|
-
}): import("../
|
|
259
|
+
}): import("../index.js").VovkTool<null, TOutput, import("../tools/toModelOutputDefault.js").DefaultModelOutput<TOutput>>;
|
|
260
260
|
};
|
|
261
261
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CombinedSpec } from '../types/validation.js';
|
|
2
|
+
type SchemasObject = {
|
|
3
|
+
body?: CombinedSpec;
|
|
4
|
+
query?: CombinedSpec;
|
|
5
|
+
params?: CombinedSpec;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Combine optional `body` / `query` / `params` Standard Schemas into a single
|
|
9
|
+
* `CombinedSpec` whose `~standard` interface fully conforms to Standard Schema
|
|
10
|
+
* + Standard JSON Schema. Top-level validation (object shape, key presence,
|
|
11
|
+
* rejection of unknown keys) is handled here; per-slot value validation and
|
|
12
|
+
* JSON Schema conversion are delegated to the slot schemas.
|
|
13
|
+
*
|
|
14
|
+
* Internal helper. Not exported from the public `vovk` entrypoint.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validationSchemasObjectToSingleValidationSchema<TSchemas extends SchemasObject>(schemas: TSchemas): CombinedSpec & TSchemas;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const SLOT_KEYS = ['body', 'query', 'params'];
|
|
2
|
+
function isThenable(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && typeof value.then === 'function';
|
|
4
|
+
}
|
|
5
|
+
function prefixIssues(issues, slot) {
|
|
6
|
+
return issues.map((issue) => ({
|
|
7
|
+
message: issue.message,
|
|
8
|
+
path: [{ key: slot }, ...(issue.path ?? [])],
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Combine optional `body` / `query` / `params` Standard Schemas into a single
|
|
13
|
+
* `CombinedSpec` whose `~standard` interface fully conforms to Standard Schema
|
|
14
|
+
* + Standard JSON Schema. Top-level validation (object shape, key presence,
|
|
15
|
+
* rejection of unknown keys) is handled here; per-slot value validation and
|
|
16
|
+
* JSON Schema conversion are delegated to the slot schemas.
|
|
17
|
+
*
|
|
18
|
+
* Internal helper. Not exported from the public `vovk` entrypoint.
|
|
19
|
+
*/
|
|
20
|
+
export function validationSchemasObjectToSingleValidationSchema(schemas) {
|
|
21
|
+
const definedSlots = SLOT_KEYS.filter((key) => schemas[key] !== undefined);
|
|
22
|
+
const definedSlotSet = new Set(definedSlots);
|
|
23
|
+
const validate = (input) => {
|
|
24
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
|
|
25
|
+
return { issues: [{ message: 'Expected object', path: [] }] };
|
|
26
|
+
}
|
|
27
|
+
const topLevelIssues = [];
|
|
28
|
+
const inputRecord = input;
|
|
29
|
+
for (const slot of definedSlots) {
|
|
30
|
+
if (!(slot in inputRecord)) {
|
|
31
|
+
topLevelIssues.push({ message: 'Required', path: [{ key: slot }] });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const key of Object.keys(inputRecord)) {
|
|
35
|
+
if (!definedSlotSet.has(key)) {
|
|
36
|
+
topLevelIssues.push({ message: 'Unexpected key', path: [{ key }] });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const pending = [];
|
|
40
|
+
for (const slot of definedSlots) {
|
|
41
|
+
if (slot in inputRecord) {
|
|
42
|
+
pending.push({ slot, result: schemas[slot]['~standard'].validate(inputRecord[slot]) });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const combine = (resolved) => {
|
|
46
|
+
const issues = [...topLevelIssues];
|
|
47
|
+
const value = {};
|
|
48
|
+
for (const { slot, result } of resolved) {
|
|
49
|
+
if (result.issues?.length) {
|
|
50
|
+
issues.push(...prefixIssues(result.issues, slot));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
value[slot] = result.value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return issues.length > 0 ? { issues } : { value };
|
|
57
|
+
};
|
|
58
|
+
if (pending.some(({ result }) => isThenable(result))) {
|
|
59
|
+
return Promise.all(pending.map(async ({ slot, result }) => ({ slot, result: await result }))).then(combine);
|
|
60
|
+
}
|
|
61
|
+
return combine(pending);
|
|
62
|
+
};
|
|
63
|
+
const buildJSONSchema = (options, direction) => {
|
|
64
|
+
const properties = {};
|
|
65
|
+
for (const slot of definedSlots) {
|
|
66
|
+
properties[slot] = schemas[slot]['~standard'].jsonSchema?.[direction](options) ?? {};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties,
|
|
71
|
+
required: [...definedSlots],
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const standard = {
|
|
76
|
+
version: 1,
|
|
77
|
+
vendor: 'vovk',
|
|
78
|
+
validate,
|
|
79
|
+
jsonSchema: {
|
|
80
|
+
input: (options) => buildJSONSchema(options, 'input'),
|
|
81
|
+
output: (options) => buildJSONSchema(options, 'output'),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const result = { '~standard': standard };
|
|
85
|
+
if (schemas.body !== undefined)
|
|
86
|
+
result.body = schemas.body;
|
|
87
|
+
if (schemas.query !== undefined)
|
|
88
|
+
result.query = schemas.query;
|
|
89
|
+
if (schemas.params !== undefined)
|
|
90
|
+
result.params = schemas.params;
|
|
91
|
+
return result;
|
|
92
|
+
}
|