@vinkius-core/mcp-fusion 2.9.0 → 2.12.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/dist/cli/fusion.d.ts +3 -0
- package/dist/cli/fusion.d.ts.map +1 -1
- package/dist/cli/fusion.js +125 -3
- package/dist/cli/fusion.js.map +1 -1
- package/dist/cli/templates/config.js +3 -3
- package/dist/cli/templates/config.js.map +1 -1
- package/dist/cli/templates/constants.d.ts +1 -1
- package/dist/cli/templates/constants.d.ts.map +1 -1
- package/dist/cli/templates/constants.js +1 -1
- package/dist/cli/templates/constants.js.map +1 -1
- package/dist/cli/templates/core.js +5 -5
- package/dist/cli/templates/middleware.d.ts +1 -1
- package/dist/cli/templates/middleware.d.ts.map +1 -1
- package/dist/cli/templates/middleware.js +16 -13
- package/dist/cli/templates/middleware.js.map +1 -1
- package/dist/cli/templates/readme.d.ts.map +1 -1
- package/dist/cli/templates/readme.js +14 -18
- package/dist/cli/templates/readme.js.map +1 -1
- package/dist/cli/templates/tools.d.ts +4 -0
- package/dist/cli/templates/tools.d.ts.map +1 -1
- package/dist/cli/templates/tools.js +26 -29
- package/dist/cli/templates/tools.js.map +1 -1
- package/dist/cli/templates/vectors/database.d.ts.map +1 -1
- package/dist/cli/templates/vectors/database.js +14 -19
- package/dist/cli/templates/vectors/database.js.map +1 -1
- package/dist/cli/templates/vectors/oauth.d.ts.map +1 -1
- package/dist/cli/templates/vectors/oauth.js +4 -5
- package/dist/cli/templates/vectors/oauth.js.map +1 -1
- package/dist/cli/templates/vectors/openapi.js +2 -2
- package/dist/cli/templates/vectors/workflow.js +1 -1
- package/dist/cli/templates/vectors/workflow.js.map +1 -1
- package/dist/client/FusionClient.d.ts +55 -0
- package/dist/client/FusionClient.d.ts.map +1 -1
- package/dist/client/FusionClient.js +30 -0
- package/dist/client/FusionClient.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/core/builder/ActionGroupBuilder.d.ts +86 -46
- package/dist/core/builder/ActionGroupBuilder.d.ts.map +1 -1
- package/dist/core/builder/ActionGroupBuilder.js +68 -26
- package/dist/core/builder/ActionGroupBuilder.js.map +1 -1
- package/dist/core/builder/ErrorBuilder.d.ts +59 -0
- package/dist/core/builder/ErrorBuilder.d.ts.map +1 -0
- package/dist/core/builder/ErrorBuilder.js +99 -0
- package/dist/core/builder/ErrorBuilder.js.map +1 -0
- package/dist/core/builder/FluentRouter.d.ts +91 -0
- package/dist/core/builder/FluentRouter.d.ts.map +1 -0
- package/dist/core/builder/FluentRouter.js +121 -0
- package/dist/core/builder/FluentRouter.js.map +1 -0
- package/dist/core/builder/FluentSchemaHelpers.d.ts +237 -0
- package/dist/core/builder/FluentSchemaHelpers.d.ts.map +1 -0
- package/dist/core/builder/FluentSchemaHelpers.js +227 -0
- package/dist/core/builder/FluentSchemaHelpers.js.map +1 -0
- package/dist/core/builder/FluentToolBuilder.d.ts +347 -0
- package/dist/core/builder/FluentToolBuilder.d.ts.map +1 -0
- package/dist/core/builder/FluentToolBuilder.js +525 -0
- package/dist/core/builder/FluentToolBuilder.js.map +1 -0
- package/dist/core/builder/GroupedToolBuilder.d.ts +91 -1
- package/dist/core/builder/GroupedToolBuilder.d.ts.map +1 -1
- package/dist/core/builder/GroupedToolBuilder.js +122 -4
- package/dist/core/builder/GroupedToolBuilder.js.map +1 -1
- package/dist/core/builder/ToolDefinitionCompiler.d.ts +1 -0
- package/dist/core/builder/ToolDefinitionCompiler.d.ts.map +1 -1
- package/dist/core/builder/ToolDefinitionCompiler.js +1 -1
- package/dist/core/builder/ToolDefinitionCompiler.js.map +1 -1
- package/dist/core/builder/index.d.ts +4 -0
- package/dist/core/builder/index.d.ts.map +1 -1
- package/dist/core/builder/index.js +7 -0
- package/dist/core/builder/index.js.map +1 -1
- package/dist/core/execution/EgressGuard.js +1 -1
- package/dist/core/execution/EgressGuard.js.map +1 -1
- package/dist/core/execution/ExecutionPipeline.d.ts +8 -2
- package/dist/core/execution/ExecutionPipeline.d.ts.map +1 -1
- package/dist/core/execution/ExecutionPipeline.js +18 -9
- package/dist/core/execution/ExecutionPipeline.js.map +1 -1
- package/dist/core/execution/PipelineHooks.d.ts +0 -6
- package/dist/core/execution/PipelineHooks.d.ts.map +1 -1
- package/dist/core/execution/PipelineHooks.js +7 -3
- package/dist/core/execution/PipelineHooks.js.map +1 -1
- package/dist/core/index.d.ts +5 -7
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/initFusion.d.ts +119 -87
- package/dist/core/initFusion.d.ts.map +1 -1
- package/dist/core/initFusion.js +56 -66
- package/dist/core/initFusion.js.map +1 -1
- package/dist/core/registry/ToolRegistry.d.ts +1 -1
- package/dist/core/registry/ToolRegistry.d.ts.map +1 -1
- package/dist/core/registry/ToolRegistry.js +1 -1
- package/dist/core/registry/ToolRegistry.js.map +1 -1
- package/dist/core/schema/SchemaGenerator.d.ts +1 -1
- package/dist/core/schema/SchemaGenerator.d.ts.map +1 -1
- package/dist/core/schema/SchemaGenerator.js +38 -1
- package/dist/core/schema/SchemaGenerator.js.map +1 -1
- package/dist/core/types.d.ts +19 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/exposition/ExpositionCompiler.d.ts.map +1 -1
- package/dist/exposition/ExpositionCompiler.js +25 -2
- package/dist/exposition/ExpositionCompiler.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/introspection/BehaviorDigest.d.ts +2 -2
- package/dist/introspection/BehaviorDigest.d.ts.map +1 -1
- package/dist/introspection/BehaviorDigest.js +38 -36
- package/dist/introspection/BehaviorDigest.js.map +1 -1
- package/dist/introspection/CapabilityLockfile.d.ts +2 -2
- package/dist/introspection/CapabilityLockfile.d.ts.map +1 -1
- package/dist/introspection/CapabilityLockfile.js +9 -9
- package/dist/introspection/CapabilityLockfile.js.map +1 -1
- package/dist/introspection/CryptoAttestation.d.ts.map +1 -1
- package/dist/introspection/CryptoAttestation.js +27 -36
- package/dist/introspection/CryptoAttestation.js.map +1 -1
- package/dist/introspection/ToolContract.d.ts +2 -2
- package/dist/introspection/ToolContract.d.ts.map +1 -1
- package/dist/introspection/ToolContract.js +9 -9
- package/dist/introspection/ToolContract.js.map +1 -1
- package/dist/introspection/canonicalize.d.ts +16 -1
- package/dist/introspection/canonicalize.d.ts.map +1 -1
- package/dist/introspection/canonicalize.js +24 -3
- package/dist/introspection/canonicalize.js.map +1 -1
- package/dist/presenter/PostProcessor.d.ts +4 -2
- package/dist/presenter/PostProcessor.d.ts.map +1 -1
- package/dist/presenter/PostProcessor.js +10 -10
- package/dist/presenter/PostProcessor.js.map +1 -1
- package/dist/presenter/Presenter.d.ts +112 -6
- package/dist/presenter/Presenter.d.ts.map +1 -1
- package/dist/presenter/Presenter.js +134 -40
- package/dist/presenter/Presenter.js.map +1 -1
- package/dist/presenter/SelectUtils.d.ts +78 -0
- package/dist/presenter/SelectUtils.d.ts.map +1 -0
- package/dist/presenter/SelectUtils.js +141 -0
- package/dist/presenter/SelectUtils.js.map +1 -0
- package/dist/presenter/index.d.ts +3 -0
- package/dist/presenter/index.d.ts.map +1 -1
- package/dist/presenter/index.js +6 -0
- package/dist/presenter/index.js.map +1 -1
- package/dist/presenter/suggest.d.ts +39 -0
- package/dist/presenter/suggest.d.ts.map +1 -0
- package/dist/presenter/suggest.js +41 -0
- package/dist/presenter/suggest.js.map +1 -0
- package/dist/presenter/typeHelpers.d.ts +147 -0
- package/dist/presenter/typeHelpers.d.ts.map +1 -0
- package/dist/presenter/typeHelpers.js +152 -0
- package/dist/presenter/typeHelpers.js.map +1 -0
- package/dist/prompt/FluentPromptBuilder.d.ts +155 -0
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -0
- package/dist/prompt/FluentPromptBuilder.js +193 -0
- package/dist/prompt/FluentPromptBuilder.js.map +1 -0
- package/dist/prompt/index.d.ts +1 -0
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -0
- package/dist/prompt/index.js.map +1 -1
- package/dist/server/DevServer.js +8 -8
- package/dist/server/DevServer.js.map +1 -1
- package/dist/server/ServerAttachment.d.ts +1 -1
- package/dist/server/ServerAttachment.d.ts.map +1 -1
- package/dist/server/ServerAttachment.js +57 -4
- package/dist/server/ServerAttachment.js.map +1 -1
- package/dist/state-sync/ResponseDecorator.d.ts +1 -1
- package/dist/state-sync/StateSyncBuilder.d.ts +75 -0
- package/dist/state-sync/StateSyncBuilder.d.ts.map +1 -0
- package/dist/state-sync/StateSyncBuilder.js +123 -0
- package/dist/state-sync/StateSyncBuilder.js.map +1 -0
- package/dist/state-sync/index.d.ts +1 -0
- package/dist/state-sync/index.d.ts.map +1 -1
- package/dist/state-sync/index.js +1 -0
- package/dist/state-sync/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Helpers — Zod-Backed Namespace for Presenter Schemas
|
|
3
|
+
*
|
|
4
|
+
* Inspired by ElysiaJS (`t.String`), Convex (`v.string()`), and
|
|
5
|
+
* Encore.ts (native TS types). Provides a compact namespace that
|
|
6
|
+
* eliminates the need to import Zod directly.
|
|
7
|
+
*
|
|
8
|
+
* Every `t.*` value IS a ZodType — zero abstraction leakage.
|
|
9
|
+
* Developers who need advanced Zod features can use `t.zod` escape hatch
|
|
10
|
+
* or mix `t.*` with raw Zod schemas freely.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPresenter, t, ui } from '@vinkius-core/mcp-fusion';
|
|
15
|
+
*
|
|
16
|
+
* const InvoicePresenter = createPresenter('Invoice')
|
|
17
|
+
* .schema({
|
|
18
|
+
* id: t.string,
|
|
19
|
+
* amount_cents: t.number.describe('CENTS — divide by 100'),
|
|
20
|
+
* status: t.enum('draft', 'sent', 'paid', 'overdue'),
|
|
21
|
+
* tags: t.array(t.string),
|
|
22
|
+
* metadata: t.optional(t.record(t.string)),
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import { z, type ZodType, type ZodRawShape } from 'zod';
|
|
29
|
+
/**
|
|
30
|
+
* Compact type namespace for Presenter schema definitions.
|
|
31
|
+
*
|
|
32
|
+
* Eliminates `import { z } from 'zod'` for 95% of use cases.
|
|
33
|
+
* Every value is a real ZodType — `.describe()`, `.optional()`,
|
|
34
|
+
* `.nullable()`, `.default()` all work natively.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* .schema({
|
|
39
|
+
* id: t.string,
|
|
40
|
+
* count: t.number,
|
|
41
|
+
* active: t.boolean,
|
|
42
|
+
* role: t.enum('admin', 'user', 'guest'),
|
|
43
|
+
* tags: t.array(t.string),
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const t: {
|
|
48
|
+
/** String type — equivalent to `z.string()` */
|
|
49
|
+
readonly string: z.ZodString;
|
|
50
|
+
/** Number type — equivalent to `z.number()` */
|
|
51
|
+
readonly number: z.ZodNumber;
|
|
52
|
+
/** Boolean type — equivalent to `z.boolean()` */
|
|
53
|
+
readonly boolean: z.ZodBoolean;
|
|
54
|
+
/** Date type — equivalent to `z.date()` */
|
|
55
|
+
readonly date: z.ZodDate;
|
|
56
|
+
/**
|
|
57
|
+
* Create an enum type from string literals.
|
|
58
|
+
*
|
|
59
|
+
* @param values - At least one enum value
|
|
60
|
+
* @returns A Zod enum schema
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* t.enum('active', 'archived') // z.enum(['active', 'archived'])
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
readonly enum: <V extends string>(values_0: V, ...values: V[]) => z.ZodEnum<[V, ...V[]]>;
|
|
68
|
+
/**
|
|
69
|
+
* Create an array type.
|
|
70
|
+
*
|
|
71
|
+
* @param item - The schema for array items
|
|
72
|
+
* @returns A Zod array schema
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* t.array(t.string) // z.array(z.string())
|
|
77
|
+
* t.array(t.number) // z.array(z.number())
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
readonly array: <T extends ZodType>(item: T) => z.ZodArray<T, "many">;
|
|
81
|
+
/**
|
|
82
|
+
* Create a nested object type.
|
|
83
|
+
*
|
|
84
|
+
* @param shape - Object shape with ZodType values
|
|
85
|
+
* @returns A Zod object schema
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* t.object({ lat: t.number, lng: t.number }) // z.object({...})
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
readonly object: <T extends ZodRawShape>(shape: T) => z.ZodObject<T, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
93
|
+
/**
|
|
94
|
+
* Create a record (dictionary) type.
|
|
95
|
+
*
|
|
96
|
+
* @param valueType - Schema for record values
|
|
97
|
+
* @returns A Zod record schema
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* t.record(t.string) // z.record(z.string())
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
readonly record: <T extends ZodType>(valueType: T) => z.ZodRecord<z.ZodString, T>;
|
|
105
|
+
/**
|
|
106
|
+
* Make a type optional.
|
|
107
|
+
*
|
|
108
|
+
* @param type - Any ZodType to make optional
|
|
109
|
+
* @returns An optional variant of the given type
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* t.optional(t.string) // z.string().optional()
|
|
114
|
+
* t.optional(t.number) // z.number().optional()
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
readonly optional: <T extends ZodType>(type: T) => z.ZodOptional<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Make a type nullable.
|
|
120
|
+
*
|
|
121
|
+
* @param type - Any ZodType to make nullable
|
|
122
|
+
* @returns A nullable variant of the given type
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* t.nullable(t.string) // z.string().nullable()
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
readonly nullable: <T extends ZodType>(type: T) => z.ZodNullable<T>;
|
|
130
|
+
/**
|
|
131
|
+
* Direct access to Zod for advanced use cases.
|
|
132
|
+
*
|
|
133
|
+
* Use when `t.*` helpers don't cover your needs:
|
|
134
|
+
* regex, transforms, refinements, unions, discriminated unions, etc.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* .schema({
|
|
139
|
+
* id: t.string,
|
|
140
|
+
* email: t.zod.string().email().min(5), // Zod power features
|
|
141
|
+
* role: t.zod.union([t.zod.literal('admin'), t.zod.literal('user')]),
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
readonly zod: typeof z;
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=typeHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeHelpers.d.ts","sourceRoot":"","sources":["../../src/presenter/typeHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAIxD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,CAAC;IAGV,+CAA+C;;IAG/C,+CAA+C;;IAG/C,iDAAiD;;IAGjD,2CAA2C;;IAK3C;;;;;;;;;;OAUG;oBACI,CAAC,SAAS,MAAM;IAGvB;;;;;;;;;;;OAWG;qBACK,CAAC,SAAS,OAAO,QAAQ,CAAC;IAGlC;;;;;;;;;;OAUG;sBACM,CAAC,SAAS,WAAW,SAAS,CAAC;IAGxC;;;;;;;;;;OAUG;sBACM,CAAC,SAAS,OAAO,aAAa,CAAC;IAKxC;;;;;;;;;;;OAWG;wBACQ,CAAC,SAAS,OAAO,QAAQ,CAAC;IAGrC;;;;;;;;;;OAUG;wBACQ,CAAC,SAAS,OAAO,QAAQ,CAAC;IAKrC;;;;;;;;;;;;;;OAcG;;CAEG,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Helpers — Zod-Backed Namespace for Presenter Schemas
|
|
3
|
+
*
|
|
4
|
+
* Inspired by ElysiaJS (`t.String`), Convex (`v.string()`), and
|
|
5
|
+
* Encore.ts (native TS types). Provides a compact namespace that
|
|
6
|
+
* eliminates the need to import Zod directly.
|
|
7
|
+
*
|
|
8
|
+
* Every `t.*` value IS a ZodType — zero abstraction leakage.
|
|
9
|
+
* Developers who need advanced Zod features can use `t.zod` escape hatch
|
|
10
|
+
* or mix `t.*` with raw Zod schemas freely.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPresenter, t, ui } from '@vinkius-core/mcp-fusion';
|
|
15
|
+
*
|
|
16
|
+
* const InvoicePresenter = createPresenter('Invoice')
|
|
17
|
+
* .schema({
|
|
18
|
+
* id: t.string,
|
|
19
|
+
* amount_cents: t.number.describe('CENTS — divide by 100'),
|
|
20
|
+
* status: t.enum('draft', 'sent', 'paid', 'overdue'),
|
|
21
|
+
* tags: t.array(t.string),
|
|
22
|
+
* metadata: t.optional(t.record(t.string)),
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
// ── Type Helpers Namespace ─────────────────────────────────
|
|
30
|
+
/**
|
|
31
|
+
* Compact type namespace for Presenter schema definitions.
|
|
32
|
+
*
|
|
33
|
+
* Eliminates `import { z } from 'zod'` for 95% of use cases.
|
|
34
|
+
* Every value is a real ZodType — `.describe()`, `.optional()`,
|
|
35
|
+
* `.nullable()`, `.default()` all work natively.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* .schema({
|
|
40
|
+
* id: t.string,
|
|
41
|
+
* count: t.number,
|
|
42
|
+
* active: t.boolean,
|
|
43
|
+
* role: t.enum('admin', 'user', 'guest'),
|
|
44
|
+
* tags: t.array(t.string),
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export const t = {
|
|
49
|
+
// ── Primitives (singleton instances) ──────────────────
|
|
50
|
+
/** String type — equivalent to `z.string()` */
|
|
51
|
+
string: z.string(),
|
|
52
|
+
/** Number type — equivalent to `z.number()` */
|
|
53
|
+
number: z.number(),
|
|
54
|
+
/** Boolean type — equivalent to `z.boolean()` */
|
|
55
|
+
boolean: z.boolean(),
|
|
56
|
+
/** Date type — equivalent to `z.date()` */
|
|
57
|
+
date: z.date(),
|
|
58
|
+
// ── Composites (factory functions) ────────────────────
|
|
59
|
+
/**
|
|
60
|
+
* Create an enum type from string literals.
|
|
61
|
+
*
|
|
62
|
+
* @param values - At least one enum value
|
|
63
|
+
* @returns A Zod enum schema
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* t.enum('active', 'archived') // z.enum(['active', 'archived'])
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
enum: (...values) => z.enum(values),
|
|
71
|
+
/**
|
|
72
|
+
* Create an array type.
|
|
73
|
+
*
|
|
74
|
+
* @param item - The schema for array items
|
|
75
|
+
* @returns A Zod array schema
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* t.array(t.string) // z.array(z.string())
|
|
80
|
+
* t.array(t.number) // z.array(z.number())
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
array: (item) => z.array(item),
|
|
84
|
+
/**
|
|
85
|
+
* Create a nested object type.
|
|
86
|
+
*
|
|
87
|
+
* @param shape - Object shape with ZodType values
|
|
88
|
+
* @returns A Zod object schema
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* t.object({ lat: t.number, lng: t.number }) // z.object({...})
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
object: (shape) => z.object(shape),
|
|
96
|
+
/**
|
|
97
|
+
* Create a record (dictionary) type.
|
|
98
|
+
*
|
|
99
|
+
* @param valueType - Schema for record values
|
|
100
|
+
* @returns A Zod record schema
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* t.record(t.string) // z.record(z.string())
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
record: (valueType) => z.record(valueType),
|
|
108
|
+
// ── Modifiers (wrappers) ─────────────────────────────
|
|
109
|
+
/**
|
|
110
|
+
* Make a type optional.
|
|
111
|
+
*
|
|
112
|
+
* @param type - Any ZodType to make optional
|
|
113
|
+
* @returns An optional variant of the given type
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* t.optional(t.string) // z.string().optional()
|
|
118
|
+
* t.optional(t.number) // z.number().optional()
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
optional: (type) => type.optional(),
|
|
122
|
+
/**
|
|
123
|
+
* Make a type nullable.
|
|
124
|
+
*
|
|
125
|
+
* @param type - Any ZodType to make nullable
|
|
126
|
+
* @returns A nullable variant of the given type
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* t.nullable(t.string) // z.string().nullable()
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
nullable: (type) => type.nullable(),
|
|
134
|
+
// ── Escape Hatch ─────────────────────────────────────
|
|
135
|
+
/**
|
|
136
|
+
* Direct access to Zod for advanced use cases.
|
|
137
|
+
*
|
|
138
|
+
* Use when `t.*` helpers don't cover your needs:
|
|
139
|
+
* regex, transforms, refinements, unions, discriminated unions, etc.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* .schema({
|
|
144
|
+
* id: t.string,
|
|
145
|
+
* email: t.zod.string().email().min(5), // Zod power features
|
|
146
|
+
* role: t.zod.union([t.zod.literal('admin'), t.zod.literal('user')]),
|
|
147
|
+
* })
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
zod: z,
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=typeHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeHelpers.js","sourceRoot":"","sources":["../../src/presenter/typeHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,CAAC,EAAkC,MAAM,KAAK,CAAC;AAExD,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,CAAC,GAAG;IACb,yDAAyD;IAEzD,+CAA+C;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAElB,+CAA+C;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAElB,iDAAiD;IACjD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IAEpB,2CAA2C;IAC3C,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;IAEd,yDAAyD;IAEzD;;;;;;;;;;OAUG;IACH,IAAI,EAAE,CAAmB,GAAG,MAAmB,EAAE,EAAE,CAC/C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAElB;;;;;;;;;;;OAWG;IACH,KAAK,EAAE,CAAoB,IAAO,EAAE,EAAE,CAClC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAEjB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,CAAwB,KAAQ,EAAE,EAAE,CACxC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,CAAoB,SAAY,EAAE,EAAE,CACxC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IAEvB,wDAAwD;IAExD;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,CAAoB,IAAO,EAAE,EAAE,CACrC,IAAI,CAAC,QAAQ,EAAE;IAEnB;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,CAAoB,IAAO,EAAE,EAAE,CACrC,IAAI,CAAC,QAAQ,EAAE;IAEnB,wDAAwD;IAExD;;;;;;;;;;;;;;OAcG;IACH,GAAG,EAAE,CAAC;CACA,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluentPromptBuilder — Chainable Prompt Definition API
|
|
3
|
+
*
|
|
4
|
+
* Provides a builder-pattern alternative to the config-bag `definePrompt()`.
|
|
5
|
+
* Follows the same architectural pattern as `FluentToolBuilder`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const greet = f.prompt('greet')
|
|
10
|
+
* .describe('Greet a user by name')
|
|
11
|
+
* .input({ name: f.string() })
|
|
12
|
+
* .handler(async (ctx, { name }) => ({
|
|
13
|
+
* messages: [PromptMessage.user(`Hello ${name}!`)],
|
|
14
|
+
* }));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
20
|
+
import { type PromptBuilder, type PromptResult, type PromptParamsMap, type LoopbackContext } from './types.js';
|
|
21
|
+
import { type MiddlewareFn } from '../core/types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Chainable builder for MCP Prompts.
|
|
24
|
+
*
|
|
25
|
+
* Each setter returns `this` for chaining. Finalisation happens lazily
|
|
26
|
+
* when the `PromptBuilder` interface methods are accessed — this means
|
|
27
|
+
* you can pass a `FluentPromptBuilder` directly to `PromptRegistry.register()`.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam TContext - Application context type (inherited from `initFusion`)
|
|
30
|
+
* @typeParam TArgs - Inferred argument type from the schema
|
|
31
|
+
*/
|
|
32
|
+
export declare class FluentPromptBuilder<TContext = void, TArgs extends Record<string, unknown> = Record<string, unknown>> implements PromptBuilder<TContext> {
|
|
33
|
+
private readonly _name;
|
|
34
|
+
private _title?;
|
|
35
|
+
private _description?;
|
|
36
|
+
private _icons?;
|
|
37
|
+
private _tags;
|
|
38
|
+
private _middlewares;
|
|
39
|
+
private _args?;
|
|
40
|
+
private _hydrationTimeout?;
|
|
41
|
+
private _handler?;
|
|
42
|
+
/** @internal Cached delegate built on first access to PromptBuilder methods */
|
|
43
|
+
private _delegate;
|
|
44
|
+
constructor(name: string);
|
|
45
|
+
/**
|
|
46
|
+
* Set a human-readable title for UI display.
|
|
47
|
+
*
|
|
48
|
+
* @param title - The prompt title
|
|
49
|
+
* @returns `this` for chaining
|
|
50
|
+
*/
|
|
51
|
+
title(title: string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Set the prompt description shown in the slash command palette.
|
|
54
|
+
*
|
|
55
|
+
* @param description - Human-readable description
|
|
56
|
+
* @returns `this` for chaining
|
|
57
|
+
*/
|
|
58
|
+
describe(description: string): this;
|
|
59
|
+
/**
|
|
60
|
+
* Set icons for light/dark themes.
|
|
61
|
+
*
|
|
62
|
+
* @param icons - Icon paths for light and/or dark themes
|
|
63
|
+
* @returns `this` for chaining
|
|
64
|
+
*/
|
|
65
|
+
icons(icons: {
|
|
66
|
+
light?: string;
|
|
67
|
+
dark?: string;
|
|
68
|
+
}): this;
|
|
69
|
+
/**
|
|
70
|
+
* Set capability tags for selective exposure.
|
|
71
|
+
*
|
|
72
|
+
* @param tags - Tag strings for filtering
|
|
73
|
+
* @returns `this` for chaining
|
|
74
|
+
*/
|
|
75
|
+
tags(...tags: string[]): this;
|
|
76
|
+
/**
|
|
77
|
+
* Define the input schema for prompt arguments.
|
|
78
|
+
*
|
|
79
|
+
* Accepts the same formats as `FluentToolBuilder.input()`:
|
|
80
|
+
* - Fluent param descriptors (`f.string()`, `f.number()`, etc.) — zero imports
|
|
81
|
+
* - Zod schema for power users
|
|
82
|
+
*
|
|
83
|
+
* @returns `this` for chaining
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Fluent descriptors (recommended — zero Zod imports)
|
|
88
|
+
* f.prompt('greet')
|
|
89
|
+
* .input({ name: f.string(), age: f.number().optional() })
|
|
90
|
+
* .handler(async (ctx, { name, age }) => ({ ... }));
|
|
91
|
+
*
|
|
92
|
+
* // Zod schema (advanced)
|
|
93
|
+
* f.prompt('search')
|
|
94
|
+
* .input(z.object({ query: z.string().min(1) }))
|
|
95
|
+
* .handler(async (ctx, { query }) => ({ ... }));
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
input<S extends ZodRawShape>(schema: ZodObject<S>): FluentPromptBuilder<TContext, ZodObject<S>['_output']>;
|
|
99
|
+
input(params: PromptParamsMap): this;
|
|
100
|
+
/**
|
|
101
|
+
* Add middleware to the prompt's execution pipeline.
|
|
102
|
+
*
|
|
103
|
+
* Middleware runs in registration order around the handler
|
|
104
|
+
* (same onion model as tool middleware).
|
|
105
|
+
*
|
|
106
|
+
* @param fns - Middleware functions
|
|
107
|
+
* @returns `this` for chaining
|
|
108
|
+
*/
|
|
109
|
+
use(...fns: MiddlewareFn<TContext>[]): this;
|
|
110
|
+
/**
|
|
111
|
+
* Set the maximum hydration time in milliseconds.
|
|
112
|
+
*
|
|
113
|
+
* If the handler doesn't complete within this time,
|
|
114
|
+
* the framework returns a graceful SYSTEM ALERT.
|
|
115
|
+
*
|
|
116
|
+
* @param ms - Timeout in milliseconds
|
|
117
|
+
* @returns `this` for chaining
|
|
118
|
+
*/
|
|
119
|
+
timeout(ms: number): this;
|
|
120
|
+
/**
|
|
121
|
+
* Set the hydration handler.
|
|
122
|
+
*
|
|
123
|
+
* This is the terminal method — after calling `.handler()`,
|
|
124
|
+
* the builder is ready to be registered.
|
|
125
|
+
*
|
|
126
|
+
* @param fn - Handler function receiving `(ctx, args)` → `PromptResult`
|
|
127
|
+
* @returns `this` for chaining
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* .handler(async (ctx, { name }) => ({
|
|
132
|
+
* messages: [PromptMessage.user(`Hello ${name}!`)],
|
|
133
|
+
* }))
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
handler(fn: (ctx: TContext & LoopbackContext, args: TArgs) => Promise<PromptResult>): this;
|
|
137
|
+
/** @internal Build the underlying PromptBuilder delegate lazily */
|
|
138
|
+
private _build;
|
|
139
|
+
getName(): string;
|
|
140
|
+
getDescription(): string | undefined;
|
|
141
|
+
getTags(): string[];
|
|
142
|
+
hasMiddleware(): boolean;
|
|
143
|
+
getHydrationTimeout(): number | undefined;
|
|
144
|
+
buildPromptDefinition(): {
|
|
145
|
+
name: string;
|
|
146
|
+
description?: string;
|
|
147
|
+
arguments?: Array<{
|
|
148
|
+
name: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
required?: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
execute(ctx: TContext, args: Record<string, string>): Promise<PromptResult>;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=FluentPromptBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FluentPromptBuilder.d.ts","sourceRoot":"","sources":["../../src/prompt/FluentProm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AE,GAAG,IAAI;IAM7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1G,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAQpC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,IAAI;IAM3C;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMzB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,GAAG,eAAe,EAAE,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAQ1F,mEAAmE;IACnE,OAAO,CAAC,MAAM;IAuBd,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM,GAAG,SAAS;IAIpC,OAAO,IAAI,MAAM,EAAE;IAInB,aAAa,IAAI,OAAO;IAIxB,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAIzC,qBAAqB;;;;;uBAQ6/J,CAAC;oBAA8B,CAAC;;;IAJljK,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;CAG9E"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluentPromptBuilder — Chainable Prompt Definition API
|
|
3
|
+
*
|
|
4
|
+
* Provides a builder-pattern alternative to the config-bag `definePrompt()`.
|
|
5
|
+
* Follows the same architectural pattern as `FluentToolBuilder`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const greet = f.prompt('greet')
|
|
10
|
+
* .describe('Greet a user by name')
|
|
11
|
+
* .input({ name: f.string() })
|
|
12
|
+
* .handler(async (ctx, { name }) => ({
|
|
13
|
+
* messages: [PromptMessage.user(`Hello ${name}!`)],
|
|
14
|
+
* }));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
import {} from 'zod';
|
|
20
|
+
import {} from './types.js';
|
|
21
|
+
import {} from '../core/types.js';
|
|
22
|
+
import { definePrompt } from './definePrompt.js';
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// FluentPromptBuilder
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Chainable builder for MCP Prompts.
|
|
28
|
+
*
|
|
29
|
+
* Each setter returns `this` for chaining. Finalisation happens lazily
|
|
30
|
+
* when the `PromptBuilder` interface methods are accessed — this means
|
|
31
|
+
* you can pass a `FluentPromptBuilder` directly to `PromptRegistry.register()`.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam TContext - Application context type (inherited from `initFusion`)
|
|
34
|
+
* @typeParam TArgs - Inferred argument type from the schema
|
|
35
|
+
*/
|
|
36
|
+
export class FluentPromptBuilder {
|
|
37
|
+
_name;
|
|
38
|
+
_title;
|
|
39
|
+
_description;
|
|
40
|
+
_icons;
|
|
41
|
+
_tags = [];
|
|
42
|
+
_middlewares = [];
|
|
43
|
+
_args;
|
|
44
|
+
_hydrationTimeout;
|
|
45
|
+
_handler;
|
|
46
|
+
/** @internal Cached delegate built on first access to PromptBuilder methods */
|
|
47
|
+
_delegate;
|
|
48
|
+
constructor(name) {
|
|
49
|
+
this._name = name;
|
|
50
|
+
}
|
|
51
|
+
// ── Chainable Setters ────────────────────────────────
|
|
52
|
+
/**
|
|
53
|
+
* Set a human-readable title for UI display.
|
|
54
|
+
*
|
|
55
|
+
* @param title - The prompt title
|
|
56
|
+
* @returns `this` for chaining
|
|
57
|
+
*/
|
|
58
|
+
title(title) {
|
|
59
|
+
this._title = title;
|
|
60
|
+
this._delegate = undefined;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set the prompt description shown in the slash command palette.
|
|
65
|
+
*
|
|
66
|
+
* @param description - Human-readable description
|
|
67
|
+
* @returns `this` for chaining
|
|
68
|
+
*/
|
|
69
|
+
describe(description) {
|
|
70
|
+
this._description = description;
|
|
71
|
+
this._delegate = undefined;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Set icons for light/dark themes.
|
|
76
|
+
*
|
|
77
|
+
* @param icons - Icon paths for light and/or dark themes
|
|
78
|
+
* @returns `this` for chaining
|
|
79
|
+
*/
|
|
80
|
+
icons(icons) {
|
|
81
|
+
this._icons = icons;
|
|
82
|
+
this._delegate = undefined;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set capability tags for selective exposure.
|
|
87
|
+
*
|
|
88
|
+
* @param tags - Tag strings for filtering
|
|
89
|
+
* @returns `this` for chaining
|
|
90
|
+
*/
|
|
91
|
+
tags(...tags) {
|
|
92
|
+
this._tags = tags;
|
|
93
|
+
this._delegate = undefined;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
input(schemaOrParams) {
|
|
98
|
+
this._args = schemaOrParams;
|
|
99
|
+
this._delegate = undefined;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Add middleware to the prompt's execution pipeline.
|
|
104
|
+
*
|
|
105
|
+
* Middleware runs in registration order around the handler
|
|
106
|
+
* (same onion model as tool middleware).
|
|
107
|
+
*
|
|
108
|
+
* @param fns - Middleware functions
|
|
109
|
+
* @returns `this` for chaining
|
|
110
|
+
*/
|
|
111
|
+
use(...fns) {
|
|
112
|
+
this._middlewares.push(...fns);
|
|
113
|
+
this._delegate = undefined;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Set the maximum hydration time in milliseconds.
|
|
118
|
+
*
|
|
119
|
+
* If the handler doesn't complete within this time,
|
|
120
|
+
* the framework returns a graceful SYSTEM ALERT.
|
|
121
|
+
*
|
|
122
|
+
* @param ms - Timeout in milliseconds
|
|
123
|
+
* @returns `this` for chaining
|
|
124
|
+
*/
|
|
125
|
+
timeout(ms) {
|
|
126
|
+
this._hydrationTimeout = ms;
|
|
127
|
+
this._delegate = undefined;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Set the hydration handler.
|
|
132
|
+
*
|
|
133
|
+
* This is the terminal method — after calling `.handler()`,
|
|
134
|
+
* the builder is ready to be registered.
|
|
135
|
+
*
|
|
136
|
+
* @param fn - Handler function receiving `(ctx, args)` → `PromptResult`
|
|
137
|
+
* @returns `this` for chaining
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* .handler(async (ctx, { name }) => ({
|
|
142
|
+
* messages: [PromptMessage.user(`Hello ${name}!`)],
|
|
143
|
+
* }))
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
handler(fn) {
|
|
147
|
+
this._handler = fn;
|
|
148
|
+
this._delegate = undefined;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
// ── PromptBuilder Interface (delegation) ─────────────
|
|
152
|
+
/** @internal Build the underlying PromptBuilder delegate lazily */
|
|
153
|
+
_build() {
|
|
154
|
+
if (this._delegate)
|
|
155
|
+
return this._delegate;
|
|
156
|
+
if (!this._handler) {
|
|
157
|
+
throw new Error(`FluentPromptBuilder('${this._name}'): .handler() must be called before the prompt can be used.`);
|
|
158
|
+
}
|
|
159
|
+
this._delegate = definePrompt(this._name, {
|
|
160
|
+
title: this._title,
|
|
161
|
+
description: this._description,
|
|
162
|
+
icons: this._icons,
|
|
163
|
+
tags: this._tags.length > 0 ? this._tags : undefined,
|
|
164
|
+
middleware: this._middlewares.length > 0 ? this._middlewares : undefined,
|
|
165
|
+
args: this._args,
|
|
166
|
+
hydrationTimeout: this._hydrationTimeout,
|
|
167
|
+
handler: this._handler,
|
|
168
|
+
});
|
|
169
|
+
return this._delegate;
|
|
170
|
+
}
|
|
171
|
+
getName() {
|
|
172
|
+
return this._name;
|
|
173
|
+
}
|
|
174
|
+
getDescription() {
|
|
175
|
+
return this._description;
|
|
176
|
+
}
|
|
177
|
+
getTags() {
|
|
178
|
+
return this._tags;
|
|
179
|
+
}
|
|
180
|
+
hasMiddleware() {
|
|
181
|
+
return this._middlewares.length > 0;
|
|
182
|
+
}
|
|
183
|
+
getHydrationTimeout() {
|
|
184
|
+
return this._hydrationTimeout;
|
|
185
|
+
}
|
|
186
|
+
buildPromptDefinition() {
|
|
187
|
+
return this._build().buildPromptDefinition();
|
|
188
|
+
}
|
|
189
|
+
execute(ctx, args) {
|
|
190
|
+
return this._build().execute(ctx, args);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=FluentPromptBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FluentPromptBuilder.js","sourceRoot":"","sources":["../../src/prompt/FluentPromptBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAoC,MAAM,KAAK,CAAC;AACvD,OAAO,EAKN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAqB,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAmB;IAGX,KAAK,CAAS;IACvB,MAAM,CAAU;IAChB,YAAY,CAAU;IACtB,MAAM,CAAqC;IAC3C,KAAK,GAAa,EAAE,CAAC;IACrB,YAAY,GAA6B,EAAE,CAAC;IAC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AC,YAAY,CAAC;IAC7B,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,aAAa;QACT,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAED,qBAAqB;QACjB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,qBAAqB,EAAE,CAAC;IACjD,CAAC;IAED,OAAO,CAAC,GAAa,EAAE,IAA4B;QAC/C,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACJ"}
|
package/dist/prompt/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
export type { PromptMessagePayload, PromptResult, PromptParamDef, PromptParamsMap, PromptBuilder, PromptConfig, ToolInvocationResult, LoopbackContext, PromptInterceptorFn, InterceptorBuilder, PromptMeta, } from './types.js';
|
|
8
8
|
export { PromptMessage } from './PromptMessage.js';
|
|
9
9
|
export { definePrompt } from './definePrompt.js';
|
|
10
|
+
export { FluentPromptBuilder } from './FluentPromptBuilder.js';
|
|
10
11
|
export { assertFlatSchema, coercePromptArgs, } from './PromptExecutionPipeline.js';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACR,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompt/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACR,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EACH,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,8BAA8B,CAAC"}
|