@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
|
@@ -11,23 +11,14 @@
|
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
13
|
* createTool<AppContext>('platform')
|
|
14
|
-
* .group('users', 'User management', g =>
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* name: 'ban',
|
|
23
|
-
* destructive: true,
|
|
24
|
-
* schema: z.object({ user_id: z.string() }),
|
|
25
|
-
* handler: async (ctx, args) => {
|
|
26
|
-
* await ctx.db.users.ban(args.user_id);
|
|
27
|
-
* return success('User banned');
|
|
28
|
-
* },
|
|
29
|
-
* });
|
|
30
|
-
* });
|
|
14
|
+
* .group('users', 'User management', g => g
|
|
15
|
+
* .use(requireAdmin)
|
|
16
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
17
|
+
* .mutation('ban', async (ctx, args) => {
|
|
18
|
+
* await ctx.db.users.ban(args.user_id);
|
|
19
|
+
* return success('User banned');
|
|
20
|
+
* })
|
|
21
|
+
* );
|
|
31
22
|
* ```
|
|
32
23
|
*
|
|
33
24
|
* @see {@link GroupedToolBuilder.group} for creating groups
|
|
@@ -87,10 +78,11 @@ export class ActionGroupBuilder {
|
|
|
87
78
|
*
|
|
88
79
|
* @example
|
|
89
80
|
* ```typescript
|
|
90
|
-
* builder.group('admin', 'Admin operations', g =>
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
81
|
+
* builder.group('admin', 'Admin operations', (g) => g
|
|
82
|
+
* .use(requireAdmin)
|
|
83
|
+
* .query('list', listHandler)
|
|
84
|
+
* .mutation('reset', resetHandler)
|
|
85
|
+
* );
|
|
94
86
|
* ```
|
|
95
87
|
*
|
|
96
88
|
* @see {@link MiddlewareFn} for the middleware signature
|
|
@@ -112,17 +104,67 @@ export class ActionGroupBuilder {
|
|
|
112
104
|
*
|
|
113
105
|
* @example
|
|
114
106
|
* ```typescript
|
|
115
|
-
* builder.group('profile', 'User profile', g =>
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
107
|
+
* builder.group('profile', 'User profile', (g) => g
|
|
108
|
+
* .omitCommon('workspace_id')
|
|
109
|
+
* .query('me', meHandler)
|
|
110
|
+
* );
|
|
119
111
|
* ```
|
|
120
112
|
*/
|
|
121
113
|
omitCommon(...fields) {
|
|
122
114
|
this._groupOmitCommon.push(...fields);
|
|
123
115
|
return this;
|
|
124
116
|
}
|
|
125
|
-
|
|
117
|
+
// ── Semantic Verb Shortcuts ──────────────────────────
|
|
118
|
+
/**
|
|
119
|
+
* Register a **read-only** action (readOnly: true).
|
|
120
|
+
*
|
|
121
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
122
|
+
* The action name is automatically prefixed with the group name
|
|
123
|
+
* (e.g., `"list"` in group `"users"` → `"users.list"`).
|
|
124
|
+
*
|
|
125
|
+
* @param name - Action name (must not contain dots)
|
|
126
|
+
* @param handler - Handler function
|
|
127
|
+
* @returns `this` for chaining
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* builder.group('users', 'User management', (g) => g
|
|
132
|
+
* .query('list', async (ctx) => success(await ctx.db.users.findMany()))
|
|
133
|
+
* .query('get', async (ctx, args) => success(await ctx.db.users.find(args.id)))
|
|
134
|
+
* );
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
query(name, handler) {
|
|
138
|
+
return this.action({ name, readOnly: true, handler });
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Register a **destructive** action (destructive: true).
|
|
142
|
+
*
|
|
143
|
+
* Semantic shortcut — eliminates the need for config objects.
|
|
144
|
+
* Signals to the LLM that this action has irreversible side effects.
|
|
145
|
+
*
|
|
146
|
+
* @param name - Action name (must not contain dots)
|
|
147
|
+
* @param handler - Handler function
|
|
148
|
+
* @returns `this` for chaining
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* builder.group('users', 'User management', (g) => g
|
|
153
|
+
* .mutation('ban', async (ctx, args) => {
|
|
154
|
+
* await ctx.db.users.ban(args.user_id);
|
|
155
|
+
* return success('User banned');
|
|
156
|
+
* })
|
|
157
|
+
* );
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
mutation(name, handler) {
|
|
161
|
+
return this.action({ name, destructive: true, handler });
|
|
162
|
+
}
|
|
163
|
+
action(configOrName, maybeHandler) {
|
|
164
|
+
// 2-arg shorthand: action('invite', inviteHandler)
|
|
165
|
+
const config = typeof configOrName === 'string'
|
|
166
|
+
? { name: configOrName, handler: maybeHandler }
|
|
167
|
+
: configOrName;
|
|
126
168
|
if (config.name.includes('.')) {
|
|
127
169
|
throw new Error(`Action name "${config.name}" must not contain dots. ` +
|
|
128
170
|
`The framework uses dots internally for group.action compound keys.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionGroupBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ActionGroupBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ActionGroupBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAoC,MAAM,KAAK,CAAC;AACvD,OAAO,EAKN,MAAM,aAAa,CAAC;AAsBrB,4DAA4D;AAE5D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CACnC,MAA8B,EAC9B,gBAAsC;IAKtC,OAAO;QACH,UAAU,EAAE,MAAM,CAAC,IAAI;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,SAAS;QAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;QAClC,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,SAAS;QAC5C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,SAAS;QAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,SAAS;QACtC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,gBAAgB,EAAE,CAAC,gBAAgB,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS;QACpF,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,SAAS;KACvC,CAAC;AACN,CAAC;AAUD,4DAA4D;AAE5D,MAAM,OAAO,kBAAkB;IAC3B,gBAAgB;IACP,QAAQ,GAA+B,EAAE,CAAC;IAClC,UAAU,CAAS;IACnB,iBAAiB,CAAS;IAC1B,iBAAiB,GAA6B,EAAE,CAAC;IAC1D,gBAAgB,GAAa,EAAE,CAAC;IAExC,YAAY,SAAiB,EAAE,WAAoB;QAC/C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,WAAW,IAAI,EAAE,CAAC;IAC/C,CAAC;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,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAE1E,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACf,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,EAAE;YACxC,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;YACxC,GAAG,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;YAC9C,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;gBAC1C,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS;SAChD,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ErrorCode, ErrorSeverity, ToolResponse } from '../response.js';
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBuilder — Fluent API for Self-Healing Errors
|
|
4
|
+
*
|
|
5
|
+
* Provides a chaining interface to construct structured tool errors
|
|
6
|
+
* with recovery suggestions, available actions, and metadata.
|
|
7
|
+
*
|
|
8
|
+
* Designed to be used via `f.error()` in a tool handler.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* return f.error('NOT_FOUND', `Project "${id}" missing`)
|
|
13
|
+
* .suggest('Check the ID and try again')
|
|
14
|
+
* .actions('projects.list')
|
|
15
|
+
* .critical();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class ErrorBuilder {
|
|
19
|
+
private _message;
|
|
20
|
+
private _code;
|
|
21
|
+
private _suggestion?;
|
|
22
|
+
private _actions;
|
|
23
|
+
private _severity;
|
|
24
|
+
private _details;
|
|
25
|
+
private _retryAfter?;
|
|
26
|
+
/** @internal Cached build result — invalidated by any setter */
|
|
27
|
+
private _cached;
|
|
28
|
+
constructor(code: ErrorCode, message: string);
|
|
29
|
+
/** Add a recovery suggestion for the LLM agent */
|
|
30
|
+
suggest(suggestion: string): this;
|
|
31
|
+
/** List tool names the agent should try instead */
|
|
32
|
+
actions(...names: string[]): this;
|
|
33
|
+
/** Set error severity (default: 'error') */
|
|
34
|
+
severity(level: ErrorSeverity): this;
|
|
35
|
+
/** Set severity to 'critical' (stops agent execution) */
|
|
36
|
+
critical(): this;
|
|
37
|
+
/** Set severity to 'warning' (non-fatal guidance) */
|
|
38
|
+
warning(): this;
|
|
39
|
+
/** Add structured metadata details about the error */
|
|
40
|
+
details(data: Record<string, string | number | boolean>): this;
|
|
41
|
+
/** Suggest a retry delay in seconds for transient errors */
|
|
42
|
+
retryAfter(seconds: number): this;
|
|
43
|
+
/**
|
|
44
|
+
* Build the final {@link ToolResponse}.
|
|
45
|
+
*
|
|
46
|
+
* Note: The execution pipeline also accepts the builder instance
|
|
47
|
+
* directly and calls this method automatically.
|
|
48
|
+
*/
|
|
49
|
+
build(): ToolResponse;
|
|
50
|
+
/** @internal Ensure the response is built and cached */
|
|
51
|
+
private _ensureBuilt;
|
|
52
|
+
/** Implementation of ToolResponse for direct return in handlers */
|
|
53
|
+
get content(): readonly {
|
|
54
|
+
readonly type: "text";
|
|
55
|
+
readonly text: string;
|
|
56
|
+
}[];
|
|
57
|
+
get isError(): boolean | undefined;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ErrorBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/ErrorBuilder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,gEAAgE;IAChE,OAAO,CAAC,OAAO,CAAuC;gBAE1C,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM;IAK5C,kDAAkD;IAClD,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAMjC,mDAAmD;IACnD,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAMjC,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAMpC,yDAAyD;IACzD,QAAQ,IAAI,IAAI;IAEhB,qDAAqD;IACrD,OAAO,IAAI,IAAI;IAEf,sDAAsD;IACtD,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAQ9D,4DAA4D;IAC5D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;;OAKG;IACH,KAAK,IAAI,YAAY;IAmBrB,wDAAwD;IACxD,OAAO,CAAC,YAAY;IAKpB,mEAAmE;IACnE,IAAI,OAAO;;;QAA0C;IACrD,IAAI,OAAO,wBAA0C;CACxD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { toolError } from '../response.js';
|
|
2
|
+
/**
|
|
3
|
+
* ErrorBuilder — Fluent API for Self-Healing Errors
|
|
4
|
+
*
|
|
5
|
+
* Provides a chaining interface to construct structured tool errors
|
|
6
|
+
* with recovery suggestions, available actions, and metadata.
|
|
7
|
+
*
|
|
8
|
+
* Designed to be used via `f.error()` in a tool handler.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* return f.error('NOT_FOUND', `Project "${id}" missing`)
|
|
13
|
+
* .suggest('Check the ID and try again')
|
|
14
|
+
* .actions('projects.list')
|
|
15
|
+
* .critical();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class ErrorBuilder {
|
|
19
|
+
_message;
|
|
20
|
+
_code;
|
|
21
|
+
_suggestion;
|
|
22
|
+
_actions = [];
|
|
23
|
+
_severity = 'error';
|
|
24
|
+
_details = {};
|
|
25
|
+
_retryAfter;
|
|
26
|
+
/** @internal Cached build result — invalidated by any setter */
|
|
27
|
+
_cached = undefined;
|
|
28
|
+
constructor(code, message) {
|
|
29
|
+
this._code = code;
|
|
30
|
+
this._message = message;
|
|
31
|
+
}
|
|
32
|
+
/** Add a recovery suggestion for the LLM agent */
|
|
33
|
+
suggest(suggestion) {
|
|
34
|
+
this._suggestion = suggestion;
|
|
35
|
+
this._cached = undefined;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** List tool names the agent should try instead */
|
|
39
|
+
actions(...names) {
|
|
40
|
+
this._actions.push(...names);
|
|
41
|
+
this._cached = undefined;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/** Set error severity (default: 'error') */
|
|
45
|
+
severity(level) {
|
|
46
|
+
this._severity = level;
|
|
47
|
+
this._cached = undefined;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/** Set severity to 'critical' (stops agent execution) */
|
|
51
|
+
critical() { return this.severity('critical'); }
|
|
52
|
+
/** Set severity to 'warning' (non-fatal guidance) */
|
|
53
|
+
warning() { return this.severity('warning'); }
|
|
54
|
+
/** Add structured metadata details about the error */
|
|
55
|
+
details(data) {
|
|
56
|
+
for (const [key, value] of Object.entries(data)) {
|
|
57
|
+
this._details[key] = String(value);
|
|
58
|
+
}
|
|
59
|
+
this._cached = undefined;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/** Suggest a retry delay in seconds for transient errors */
|
|
63
|
+
retryAfter(seconds) {
|
|
64
|
+
this._retryAfter = seconds;
|
|
65
|
+
this._cached = undefined;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the final {@link ToolResponse}.
|
|
70
|
+
*
|
|
71
|
+
* Note: The execution pipeline also accepts the builder instance
|
|
72
|
+
* directly and calls this method automatically.
|
|
73
|
+
*/
|
|
74
|
+
build() {
|
|
75
|
+
const opts = {
|
|
76
|
+
message: this._message,
|
|
77
|
+
severity: this._severity,
|
|
78
|
+
};
|
|
79
|
+
if (this._suggestion)
|
|
80
|
+
opts.suggestion = this._suggestion;
|
|
81
|
+
if (this._actions.length > 0)
|
|
82
|
+
opts.availableActions = this._actions;
|
|
83
|
+
if (Object.keys(this._details).length > 0)
|
|
84
|
+
opts.details = this._details;
|
|
85
|
+
if (this._retryAfter !== undefined)
|
|
86
|
+
opts.retryAfter = this._retryAfter;
|
|
87
|
+
return toolError(this._code, opts);
|
|
88
|
+
}
|
|
89
|
+
/** @internal Ensure the response is built and cached */
|
|
90
|
+
_ensureBuilt() {
|
|
91
|
+
if (!this._cached)
|
|
92
|
+
this._cached = this.build();
|
|
93
|
+
return this._cached;
|
|
94
|
+
}
|
|
95
|
+
/** Implementation of ToolResponse for direct return in handlers */
|
|
96
|
+
get content() { return this._ensureBuilt().content; }
|
|
97
|
+
get isError() { return this._ensureBuilt().isError; }
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=ErrorBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBuilder.js","sourceRoot":"","sources":["../../../src/core/builder/ErrorBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACb,QAAQ,CAAS;IACjB,KAAK,CAAY;IACjB,WAAW,CAAU;IACrB,QAAQ,GAAa,EAAE,CAAC;IACxB,SAAS,GAAkB,OAAO,CAAC;I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entRouter — Prefix Grouping for Fluent Tools
|
|
3
|
+
*
|
|
4
|
+
* Eliminates repetitive `'users.'` prefixes across dozens of tools.
|
|
5
|
+
* A router shares a common prefix, description, and middleware chain
|
|
6
|
+
* across all child tools.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const f = initFusion<AppContext>();
|
|
11
|
+
*
|
|
12
|
+
* const users = f.router('users')
|
|
13
|
+
* .describe('User management')
|
|
14
|
+
* .use(requireAuth);
|
|
15
|
+
*
|
|
16
|
+
* // Tool name: "users", action: "list"
|
|
17
|
+
* const listUsers = users.query('list')
|
|
18
|
+
* .input({ limit: f.number() })
|
|
19
|
+
* .resolve(async ({ input }) => { ... });
|
|
20
|
+
*
|
|
21
|
+
* // Tool name: "users", action: "delete"
|
|
22
|
+
* const deleteUser = users.mutation('delete')
|
|
23
|
+
* .input({ id: f.string() })
|
|
24
|
+
* .resolve(async ({ input }) => { ... });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { type MiddlewareFn } from '../types.js';
|
|
30
|
+
import { FluentToolBuilder } from './FluentToolBuilder.js';
|
|
31
|
+
/**
|
|
32
|
+
* Fluent router that shares prefix, description, and middleware
|
|
33
|
+
* across child tools created via `.query()`, `.mutation()`, `.action()`.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TContext - Base application context
|
|
36
|
+
*/
|
|
37
|
+
export declare class FluentRouter<TContext> {
|
|
38
|
+
/** @internal */ readonly _prefix: string;
|
|
39
|
+
/** @internal */ _description?: string;
|
|
40
|
+
/** @internal */ _middlewares: MiddlewareFn<TContext>[];
|
|
41
|
+
/** @internal */ _tags: string[];
|
|
42
|
+
constructor(prefix: string);
|
|
43
|
+
/**
|
|
44
|
+
* Set the shared description for all tools in this router.
|
|
45
|
+
*
|
|
46
|
+
* @param text - Human-readable description
|
|
47
|
+
* @returns `this` for chaining
|
|
48
|
+
*/
|
|
49
|
+
describe(text: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Add middleware shared by all tools in this router.
|
|
52
|
+
*
|
|
53
|
+
* @param mw - Middleware function
|
|
54
|
+
* @returns `this` for chaining
|
|
55
|
+
*/
|
|
56
|
+
use(mw: MiddlewareFn<TContext>): this;
|
|
57
|
+
/**
|
|
58
|
+
* Set capability tags shared by all tools in this router.
|
|
59
|
+
*
|
|
60
|
+
* @param tags - Tag strings for filtering
|
|
61
|
+
* @returns `this` for chaining
|
|
62
|
+
*/
|
|
63
|
+
tags(...tags: string[]): this;
|
|
64
|
+
/**
|
|
65
|
+
* Create a read-only query tool under this router's prefix.
|
|
66
|
+
*
|
|
67
|
+
* @param action - Action name (e.g. `'list'` → tool name `'prefix.list'`)
|
|
68
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
69
|
+
*/
|
|
70
|
+
query(action: string): FluentToolBuilder<TContext>;
|
|
71
|
+
/**
|
|
72
|
+
* Create a destructive mutation tool under this router's prefix.
|
|
73
|
+
*
|
|
74
|
+
* @param action - Action name (e.g. `'delete'` → tool name `'prefix.delete'`)
|
|
75
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
76
|
+
*/
|
|
77
|
+
mutation(action: string): FluentToolBuilder<TContext>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a neutral action tool under this router's prefix.
|
|
80
|
+
*
|
|
81
|
+
* @param action - Action name (e.g. `'update'` → tool name `'prefix.update'`)
|
|
82
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
83
|
+
*/
|
|
84
|
+
action(action: string): FluentToolBuilder<TContext>;
|
|
85
|
+
/**
|
|
86
|
+
* Create a FluentToolBuilder with inherited router config.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
private _createBuilder;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=FluentRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FluentRouter.d.ts","sourceRoot":"","sources":["../../../src/core/builder/FluentRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACH,iBAAiB,EAIpB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,qBAAa,YAAY,CAAC,QAAQ;IAC9B,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1C,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACvC,gBAAgB,CAAC,YAAY,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAM;IAC7D,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,CAAM;gBAE1B,MAAM,EAAE,MAAM;IAI1B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK5B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI;IAKrC;;;;;OAKG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAK7B;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAIlD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAIrD;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAInD;;;OAGG;IACH,OAAO,CAAC,cAAc;CAwBzB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluentRouter — Prefix Grouping for Fluent Tools
|
|
3
|
+
*
|
|
4
|
+
* Eliminates repetitive `'users.'` prefixes across dozens of tools.
|
|
5
|
+
* A router shares a common prefix, description, and middleware chain
|
|
6
|
+
* across all child tools.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const f = initFusion<AppContext>();
|
|
11
|
+
*
|
|
12
|
+
* const users = f.router('users')
|
|
13
|
+
* .describe('User management')
|
|
14
|
+
* .use(requireAuth);
|
|
15
|
+
*
|
|
16
|
+
* // Tool name: "users", action: "list"
|
|
17
|
+
* const listUsers = users.query('list')
|
|
18
|
+
* .input({ limit: f.number() })
|
|
19
|
+
* .resolve(async ({ input }) => { ... });
|
|
20
|
+
*
|
|
21
|
+
* // Tool name: "users", action: "delete"
|
|
22
|
+
* const deleteUser = users.mutation('delete')
|
|
23
|
+
* .input({ id: f.string() })
|
|
24
|
+
* .resolve(async ({ input }) => { ... });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import {} from '../types.js';
|
|
30
|
+
import { FluentToolBuilder, QUERY_DEFAULTS, MUTATION_DEFAULTS, ACTION_DEFAULTS, } from './FluentToolBuilder.js';
|
|
31
|
+
/**
|
|
32
|
+
* Fluent router that shares prefix, description, and middleware
|
|
33
|
+
* across child tools created via `.query()`, `.mutation()`, `.action()`.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam TContext - Base application context
|
|
36
|
+
*/
|
|
37
|
+
export class FluentRouter {
|
|
38
|
+
/** @internal */ _prefix;
|
|
39
|
+
/** @internal */ _description;
|
|
40
|
+
/** @internal */ _middlewares = [];
|
|
41
|
+
/** @internal */ _tags = [];
|
|
42
|
+
constructor(prefix) {
|
|
43
|
+
this._prefix = prefix;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set the shared description for all tools in this router.
|
|
47
|
+
*
|
|
48
|
+
* @param text - Human-readable description
|
|
49
|
+
* @returns `this` for chaining
|
|
50
|
+
*/
|
|
51
|
+
describe(text) {
|
|
52
|
+
this._description = text;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Add middleware shared by all tools in this router.
|
|
57
|
+
*
|
|
58
|
+
* @param mw - Middleware function
|
|
59
|
+
* @returns `this` for chaining
|
|
60
|
+
*/
|
|
61
|
+
use(mw) {
|
|
62
|
+
this._middlewares.push(mw);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Set capability tags shared by all tools in this router.
|
|
67
|
+
*
|
|
68
|
+
* @param tags - Tag strings for filtering
|
|
69
|
+
* @returns `this` for chaining
|
|
70
|
+
*/
|
|
71
|
+
tags(...tags) {
|
|
72
|
+
this._tags = tags;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a read-only query tool under this router's prefix.
|
|
77
|
+
*
|
|
78
|
+
* @param action - Action name (e.g. `'list'` → tool name `'prefix.list'`)
|
|
79
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
80
|
+
*/
|
|
81
|
+
query(action) {
|
|
82
|
+
return this._createBuilder(action, QUERY_DEFAULTS);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a destructive mutation tool under this router's prefix.
|
|
86
|
+
*
|
|
87
|
+
* @param action - Action name (e.g. `'delete'` → tool name `'prefix.delete'`)
|
|
88
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
89
|
+
*/
|
|
90
|
+
mutation(action) {
|
|
91
|
+
return this._createBuilder(action, MUTATION_DEFAULTS);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a neutral action tool under this router's prefix.
|
|
95
|
+
*
|
|
96
|
+
* @param action - Action name (e.g. `'update'` → tool name `'prefix.update'`)
|
|
97
|
+
* @returns A `FluentToolBuilder` with the prefixed name and inherited config
|
|
98
|
+
*/
|
|
99
|
+
action(action) {
|
|
100
|
+
return this._createBuilder(action, ACTION_DEFAULTS);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a FluentToolBuilder with inherited router config.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
_createBuilder(action, defaults) {
|
|
107
|
+
const builder = new FluentToolBuilder(`${this._prefix}.${action}`, defaults);
|
|
108
|
+
// Inherit router middleware
|
|
109
|
+
builder._middlewares.push(...this._middlewares);
|
|
110
|
+
// Inherit router tags
|
|
111
|
+
if (this._tags.length > 0) {
|
|
112
|
+
builder._tags.push(...this._tags);
|
|
113
|
+
}
|
|
114
|
+
// Inherit router description as fallback
|
|
115
|
+
if (this._description && !builder._description) {
|
|
116
|
+
builder._description = this._description;
|
|
117
|
+
}
|
|
118
|
+
return builder;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=FluentRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FluentRouter.js","sourceRoot":"","sources":["../../../src/core/builder/FluentRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAqB,MAAM,aAAa,CAAC;AAChD,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,eAAe,GAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACrB,gBAAgB,CAAU,OAAO,CAAS;IAC1C,gBAAgB,CAAC,YAAY,CAAU;IACvC,gBAAgB,CAAC,YAAY,GAA6B,EAAE,CAAC;IAC7D,gBAAgB,CAAC,KAAK,GAAa,EAAE,CAAC;IAEtC,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,IAAY;QACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,EAA0B;QAC1B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CA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