vovk 3.0.0-draft.252 → 3.0.0-draft.255
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/cjs/createVovkApp.js +2 -1
- package/cjs/types.d.ts +11 -4
- package/cjs/utils/createLLMTools.d.ts +14 -0
- package/cjs/utils/createLLMTools.js +11 -10
- package/cjs/utils/withStandard.d.ts +7 -0
- package/cjs/utils/withValidationLibrary.d.ts +7 -0
- package/mjs/createVovkApp.js +2 -1
- package/mjs/types.d.ts +11 -4
- package/mjs/utils/createLLMTools.d.ts +14 -0
- package/mjs/utils/createLLMTools.js +11 -10
- package/mjs/utils/withStandard.d.ts +7 -0
- package/mjs/utils/withValidationLibrary.d.ts +7 -0
- package/package.json +1 -1
package/cjs/createVovkApp.js
CHANGED
|
@@ -31,7 +31,8 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
|
|
|
31
31
|
originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
|
|
32
32
|
const schema = originalMethod._sourceMethod._getSchema?.(controller);
|
|
33
33
|
originalMethod.schema = schema;
|
|
34
|
-
originalMethod.
|
|
34
|
+
originalMethod.fn = originalMethod._sourceMethod?.fn;
|
|
35
|
+
originalMethod.models = originalMethod._sourceMethod?.models;
|
|
35
36
|
controller._handlers = {
|
|
36
37
|
...controller._handlers,
|
|
37
38
|
[propertyKey]: {
|
package/cjs/types.d.ts
CHANGED
|
@@ -220,10 +220,17 @@ export interface VovkLLMTool {
|
|
|
220
220
|
name: string;
|
|
221
221
|
description: string;
|
|
222
222
|
parameters?: {
|
|
223
|
-
type:
|
|
224
|
-
properties
|
|
225
|
-
required
|
|
226
|
-
additionalProperties
|
|
223
|
+
type: 'object';
|
|
224
|
+
properties?: Record<string, KnownAny>;
|
|
225
|
+
required?: string[];
|
|
226
|
+
additionalProperties?: boolean;
|
|
227
|
+
};
|
|
228
|
+
models?: {
|
|
229
|
+
body?: KnownAny;
|
|
230
|
+
query?: KnownAny;
|
|
231
|
+
params?: KnownAny;
|
|
232
|
+
output?: KnownAny;
|
|
233
|
+
iteration?: KnownAny;
|
|
227
234
|
};
|
|
228
235
|
type: 'function';
|
|
229
236
|
}
|
|
@@ -3,6 +3,13 @@ type Handler = ((...args: KnownAny[]) => KnownAny) & {
|
|
|
3
3
|
fn?: (input: KnownAny) => KnownAny;
|
|
4
4
|
isRPC?: boolean;
|
|
5
5
|
schema?: VovkHandlerSchema;
|
|
6
|
+
models?: {
|
|
7
|
+
body?: KnownAny;
|
|
8
|
+
query?: KnownAny;
|
|
9
|
+
params?: KnownAny;
|
|
10
|
+
output?: KnownAny;
|
|
11
|
+
iteration?: KnownAny;
|
|
12
|
+
};
|
|
6
13
|
};
|
|
7
14
|
type CallerInput = {
|
|
8
15
|
handler: Handler;
|
|
@@ -10,6 +17,13 @@ type CallerInput = {
|
|
|
10
17
|
query: KnownAny;
|
|
11
18
|
params: KnownAny;
|
|
12
19
|
schema: VovkHandlerSchema;
|
|
20
|
+
models: {
|
|
21
|
+
body?: KnownAny;
|
|
22
|
+
query?: KnownAny;
|
|
23
|
+
params?: KnownAny;
|
|
24
|
+
output?: KnownAny;
|
|
25
|
+
iteration?: KnownAny;
|
|
26
|
+
} | undefined;
|
|
13
27
|
init?: RequestInit;
|
|
14
28
|
meta?: Record<string, KnownAny>;
|
|
15
29
|
handlerName: string;
|
|
@@ -9,7 +9,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
9
9
|
if (!handler) {
|
|
10
10
|
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
11
11
|
}
|
|
12
|
-
const { schema } = handler;
|
|
12
|
+
const { schema, models } = handler;
|
|
13
13
|
if (!schema || !schema.openapi) {
|
|
14
14
|
throw new Error(`Handler "${handlerName}" in module "${moduleName}" does not have a valid schema.`);
|
|
15
15
|
}
|
|
@@ -17,6 +17,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
17
17
|
const { body, query, params } = input;
|
|
18
18
|
const callerInput = {
|
|
19
19
|
schema,
|
|
20
|
+
models,
|
|
20
21
|
handler,
|
|
21
22
|
body,
|
|
22
23
|
query,
|
|
@@ -51,17 +52,17 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
51
52
|
type: 'function',
|
|
52
53
|
execute,
|
|
53
54
|
name: `${moduleName}__${handlerName}`,
|
|
54
|
-
description:
|
|
55
|
-
|
|
55
|
+
description: schema.openapi?.['x-tool-description'] ??
|
|
56
|
+
([schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName),
|
|
57
|
+
parameters: Object.keys(parametersProperties).length
|
|
56
58
|
? {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
additionalProperties: false,
|
|
62
|
-
},
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: parametersProperties,
|
|
61
|
+
required: Object.keys(parametersProperties),
|
|
62
|
+
additionalProperties: false,
|
|
63
63
|
}
|
|
64
|
-
: {}
|
|
64
|
+
: { type: 'object' },
|
|
65
|
+
models,
|
|
65
66
|
};
|
|
66
67
|
};
|
|
67
68
|
async function defaultCaller({ handler, body, query, params, init },
|
|
@@ -25,6 +25,13 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
|
|
|
25
25
|
isRPC?: boolean;
|
|
26
26
|
} & {
|
|
27
27
|
schema: import("../types").VovkHandlerSchema;
|
|
28
|
+
models: {
|
|
29
|
+
body?: BODY | undefined;
|
|
30
|
+
query?: QUERY | undefined;
|
|
31
|
+
params?: PARAMS | undefined;
|
|
32
|
+
output?: OUTPUT | undefined;
|
|
33
|
+
iteration?: ITERATION | undefined;
|
|
34
|
+
};
|
|
28
35
|
} & {
|
|
29
36
|
fn: {
|
|
30
37
|
<RETURN_TYPE = ReturnType<VovkTypedMethod<T, BODY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<BODY> : any, QUERY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<QUERY> : any, PARAMS extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<PARAMS> : any, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM extends true ? true : any>>>(input?: ((undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? {
|
|
@@ -26,6 +26,13 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
26
26
|
}) => KnownAny;
|
|
27
27
|
}): T & {
|
|
28
28
|
schema: VovkHandlerSchema;
|
|
29
|
+
models: {
|
|
30
|
+
body?: BODY_MODEL;
|
|
31
|
+
query?: QUERY_MODEL;
|
|
32
|
+
params?: PARAMS_MODEL;
|
|
33
|
+
output?: OUTPUT_MODEL;
|
|
34
|
+
iteration?: ITERATION_MODEL;
|
|
35
|
+
};
|
|
29
36
|
} & {
|
|
30
37
|
fn: {
|
|
31
38
|
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? {
|
package/mjs/createVovkApp.js
CHANGED
|
@@ -31,7 +31,8 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
|
|
|
31
31
|
originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
|
|
32
32
|
const schema = originalMethod._sourceMethod._getSchema?.(controller);
|
|
33
33
|
originalMethod.schema = schema;
|
|
34
|
-
originalMethod.
|
|
34
|
+
originalMethod.fn = originalMethod._sourceMethod?.fn;
|
|
35
|
+
originalMethod.models = originalMethod._sourceMethod?.models;
|
|
35
36
|
controller._handlers = {
|
|
36
37
|
...controller._handlers,
|
|
37
38
|
[propertyKey]: {
|
package/mjs/types.d.ts
CHANGED
|
@@ -220,10 +220,17 @@ export interface VovkLLMTool {
|
|
|
220
220
|
name: string;
|
|
221
221
|
description: string;
|
|
222
222
|
parameters?: {
|
|
223
|
-
type:
|
|
224
|
-
properties
|
|
225
|
-
required
|
|
226
|
-
additionalProperties
|
|
223
|
+
type: 'object';
|
|
224
|
+
properties?: Record<string, KnownAny>;
|
|
225
|
+
required?: string[];
|
|
226
|
+
additionalProperties?: boolean;
|
|
227
|
+
};
|
|
228
|
+
models?: {
|
|
229
|
+
body?: KnownAny;
|
|
230
|
+
query?: KnownAny;
|
|
231
|
+
params?: KnownAny;
|
|
232
|
+
output?: KnownAny;
|
|
233
|
+
iteration?: KnownAny;
|
|
227
234
|
};
|
|
228
235
|
type: 'function';
|
|
229
236
|
}
|
|
@@ -3,6 +3,13 @@ type Handler = ((...args: KnownAny[]) => KnownAny) & {
|
|
|
3
3
|
fn?: (input: KnownAny) => KnownAny;
|
|
4
4
|
isRPC?: boolean;
|
|
5
5
|
schema?: VovkHandlerSchema;
|
|
6
|
+
models?: {
|
|
7
|
+
body?: KnownAny;
|
|
8
|
+
query?: KnownAny;
|
|
9
|
+
params?: KnownAny;
|
|
10
|
+
output?: KnownAny;
|
|
11
|
+
iteration?: KnownAny;
|
|
12
|
+
};
|
|
6
13
|
};
|
|
7
14
|
type CallerInput = {
|
|
8
15
|
handler: Handler;
|
|
@@ -10,6 +17,13 @@ type CallerInput = {
|
|
|
10
17
|
query: KnownAny;
|
|
11
18
|
params: KnownAny;
|
|
12
19
|
schema: VovkHandlerSchema;
|
|
20
|
+
models: {
|
|
21
|
+
body?: KnownAny;
|
|
22
|
+
query?: KnownAny;
|
|
23
|
+
params?: KnownAny;
|
|
24
|
+
output?: KnownAny;
|
|
25
|
+
iteration?: KnownAny;
|
|
26
|
+
} | undefined;
|
|
13
27
|
init?: RequestInit;
|
|
14
28
|
meta?: Record<string, KnownAny>;
|
|
15
29
|
handlerName: string;
|
|
@@ -9,7 +9,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
9
9
|
if (!handler) {
|
|
10
10
|
throw new Error(`Handler "${handlerName}" not found in module "${moduleName}".`);
|
|
11
11
|
}
|
|
12
|
-
const { schema } = handler;
|
|
12
|
+
const { schema, models } = handler;
|
|
13
13
|
if (!schema || !schema.openapi) {
|
|
14
14
|
throw new Error(`Handler "${handlerName}" in module "${moduleName}" does not have a valid schema.`);
|
|
15
15
|
}
|
|
@@ -17,6 +17,7 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
17
17
|
const { body, query, params } = input;
|
|
18
18
|
const callerInput = {
|
|
19
19
|
schema,
|
|
20
|
+
models,
|
|
20
21
|
handler,
|
|
21
22
|
body,
|
|
22
23
|
query,
|
|
@@ -51,17 +52,17 @@ const createLLMTool = ({ moduleName, handlerName, caller, module, init, meta, on
|
|
|
51
52
|
type: 'function',
|
|
52
53
|
execute,
|
|
53
54
|
name: `${moduleName}__${handlerName}`,
|
|
54
|
-
description:
|
|
55
|
-
|
|
55
|
+
description: schema.openapi?.['x-tool-description'] ??
|
|
56
|
+
([schema.openapi?.summary ?? '', schema.openapi?.description ?? ''].filter(Boolean).join('\n') || handlerName),
|
|
57
|
+
parameters: Object.keys(parametersProperties).length
|
|
56
58
|
? {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
additionalProperties: false,
|
|
62
|
-
},
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: parametersProperties,
|
|
61
|
+
required: Object.keys(parametersProperties),
|
|
62
|
+
additionalProperties: false,
|
|
63
63
|
}
|
|
64
|
-
: {}
|
|
64
|
+
: { type: 'object' },
|
|
65
|
+
models,
|
|
65
66
|
};
|
|
66
67
|
};
|
|
67
68
|
async function defaultCaller({ handler, body, query, params, init },
|
|
@@ -25,6 +25,13 @@ export declare function withStandard<T extends (req: REQ, params: PARAMS extends
|
|
|
25
25
|
isRPC?: boolean;
|
|
26
26
|
} & {
|
|
27
27
|
schema: import("../types").VovkHandlerSchema;
|
|
28
|
+
models: {
|
|
29
|
+
body?: BODY | undefined;
|
|
30
|
+
query?: QUERY | undefined;
|
|
31
|
+
params?: PARAMS | undefined;
|
|
32
|
+
output?: OUTPUT | undefined;
|
|
33
|
+
iteration?: ITERATION | undefined;
|
|
34
|
+
};
|
|
28
35
|
} & {
|
|
29
36
|
fn: {
|
|
30
37
|
<RETURN_TYPE = ReturnType<VovkTypedMethod<T, BODY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<BODY> : any, QUERY extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<QUERY> : any, PARAMS extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<PARAMS> : any, OUTPUT extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<OUTPUT> : any, ITERATION extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferOutput<ITERATION> : any, IS_FORM extends true ? true : any>>>(input?: ((undefined extends BODY | undefined ? undefined extends QUERY | undefined ? undefined extends PARAMS | undefined ? true : false : false : false) extends true ? {
|
|
@@ -26,6 +26,13 @@ export declare function withValidationLibrary<T extends VovkTypedMethod<(req: Kn
|
|
|
26
26
|
}) => KnownAny;
|
|
27
27
|
}): T & {
|
|
28
28
|
schema: VovkHandlerSchema;
|
|
29
|
+
models: {
|
|
30
|
+
body?: BODY_MODEL;
|
|
31
|
+
query?: QUERY_MODEL;
|
|
32
|
+
params?: PARAMS_MODEL;
|
|
33
|
+
output?: OUTPUT_MODEL;
|
|
34
|
+
iteration?: ITERATION_MODEL;
|
|
35
|
+
};
|
|
29
36
|
} & {
|
|
30
37
|
fn: {
|
|
31
38
|
<RETURN_TYPE = ReturnType<T>>(input?: (undefined extends BODY_MODEL | undefined ? undefined extends QUERY_MODEL | undefined ? undefined extends PARAMS_MODEL | undefined ? true : false : false : false) extends true ? {
|