@vurb/core 3.5.0 → 3.6.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/README.md +726 -677
- package/dist/cli/constants.js +59 -59
- package/dist/cli/scaffold.js +2 -0
- package/dist/cli/scaffold.js.map +1 -1
- package/dist/cli/templates/config.js +27 -27
- package/dist/cli/templates/config.js.map +1 -1
- package/dist/cli/templates/constants.d.ts +1 -1
- package/dist/cli/templates/constants.js +1 -1
- package/dist/cli/templates/core.js +95 -95
- package/dist/cli/templates/index.d.ts +1 -0
- package/dist/cli/templates/index.d.ts.map +1 -1
- package/dist/cli/templates/index.js +2 -0
- package/dist/cli/templates/index.js.map +1 -1
- package/dist/cli/templates/middleware.js +25 -25
- package/dist/cli/templates/model.d.ts +7 -0
- package/dist/cli/templates/model.d.ts.map +1 -0
- package/dist/cli/templates/model.js +31 -0
- package/dist/cli/templates/model.js.map +1 -0
- package/dist/cli/templates/presenter.d.ts.map +1 -1
- package/dist/cli/templates/presenter.js +4 -9
- package/dist/cli/templates/presenter.js.map +1 -1
- package/dist/cli/templates/readme.d.ts.map +1 -1
- package/dist/cli/templates/readme.js +144 -142
- package/dist/cli/templates/readme.js.map +1 -1
- package/dist/cli/templates/testing.js +84 -84
- package/dist/cli/templates/tools.js +46 -46
- package/dist/cli/templates/vectors/database.js +69 -69
- package/dist/cli/templates/vectors/oauth.js +63 -63
- package/dist/cli/templates/vectors/openapi.js +97 -97
- package/dist/core/builder/BuildPipeline.d.ts +56 -0
- package/dist/core/builder/BuildPipeline.d.ts.map +1 -0
- package/dist/core/builder/BuildPipeline.js +139 -0
- package/dist/core/builder/BuildPipeline.js.map +1 -0
- package/dist/core/builder/FluentToolBuilder.d.ts +64 -19
- package/dist/core/builder/FluentToolBuilder.d.ts.map +1 -1
- package/dist/core/builder/FluentToolBuilder.js +116 -114
- package/dist/core/builder/FluentToolBuilder.js.map +1 -1
- package/dist/core/builder/ProxyHandler.d.ts +26 -0
- package/dist/core/builder/ProxyHandler.d.ts.map +1 -0
- package/dist/core/builder/ProxyHandler.js +65 -0
- package/dist/core/builder/ProxyHandler.js.map +1 -0
- package/dist/core/builder/SemanticDefaults.d.ts +25 -0
- package/dist/core/builder/SemanticDefaults.d.ts.map +1 -0
- package/dist/core/builder/SemanticDefaults.js +16 -0
- package/dist/core/builder/SemanticDefaults.js.map +1 -0
- package/dist/core/builder/index.d.ts +2 -1
- package/dist/core/builder/index.d.ts.map +1 -1
- package/dist/core/builder/index.js +1 -0
- package/dist/core/builder/index.js.map +1 -1
- package/dist/core/middleware/AuditTrail.d.ts.map +1 -1
- package/dist/core/middleware/AuditTrail.js +6 -2
- package/dist/core/middleware/AuditTrail.js.map +1 -1
- package/dist/core/middleware/RateLimiter.d.ts.map +1 -1
- package/dist/core/middleware/RateLimiter.js +3 -1
- package/dist/core/middleware/RateLimiter.js.map +1 -1
- package/dist/fsm/StateMachineGate.d.ts +3 -0
- package/dist/fsm/StateMachineGate.d.ts.map +1 -1
- package/dist/fsm/StateMachineGate.js +12 -0
- package/dist/fsm/StateMachineGate.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/introspection/SemanticProbe.js +49 -49
- package/dist/model/defineModel.d.ts +167 -0
- package/dist/model/defineModel.d.ts.map +1 -0
- package/dist/model/defineModel.js +345 -0
- package/dist/model/defineModel.js.map +1 -0
- package/dist/model/index.d.ts +8 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +7 -0
- package/dist/model/index.js.map +1 -0
- package/dist/observability/TelemetryBus.d.ts.map +1 -1
- package/dist/observability/TelemetryBus.js +14 -13
- package/dist/observability/TelemetryBus.js.map +1 -1
- package/dist/presenter/Presenter.d.ts +21 -0
- package/dist/presenter/Presenter.d.ts.map +1 -1
- package/dist/presenter/Presenter.js +17 -8
- package/dist/presenter/Presenter.js.map +1 -1
- package/dist/presenter/PresenterPipeline.d.ts +2 -0
- package/dist/presenter/PresenterPipeline.d.ts.map +1 -1
- package/dist/presenter/PresenterPipeline.js +4 -0
- package/dist/presenter/PresenterPipeline.js.map +1 -1
- package/dist/presenter/definePresenter.d.ts.map +1 -1
- package/dist/presenter/definePresenter.js +13 -3
- package/dist/presenter/definePresenter.js.map +1 -1
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -1
- package/dist/resource/ResourceRegistry.d.ts +3 -0
- package/dist/resource/ResourceRegistry.d.ts.map +1 -1
- package/dist/resource/ResourceRegistry.js +8 -2
- package/dist/resource/ResourceRegistry.js.map +1 -1
- package/dist/sandbox/SandboxGuard.js +7 -4
- package/dist/sandbox/SandboxGuard.js.map +1 -1
- package/dist/server/ServerAttachment.d.ts.map +1 -1
- package/dist/server/ServerAttachment.js +48 -9
- package/dist/server/ServerAttachment.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BuildPipeline — Compiles FluentToolBuilder state into a GroupedToolBuilder.
|
|
3
|
+
*
|
|
4
|
+
* Extracts the `_build()` pipeline from FluentToolBuilder into a
|
|
5
|
+
* standalone function for SRP compliance. Handles:
|
|
6
|
+
* - Name parsing (`domain.action`)
|
|
7
|
+
* - Description compilation (instructions + sandbox prompting)
|
|
8
|
+
* - Semantic defaults resolution
|
|
9
|
+
* - Handler wrapping (implicit `success()`)
|
|
10
|
+
* - GroupedToolBuilder assembly + middleware propagation
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import {} from 'zod';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { GroupedToolBuilder } from './GroupedToolBuilder.js';
|
|
17
|
+
import {} from '../types.js';
|
|
18
|
+
import { success, TOOL_RESPONSE_BRAND } from '../response.js';
|
|
19
|
+
import {} from '../../presenter/Presenter.js';
|
|
20
|
+
import {} from '../execution/ConcurrencyGuard.js';
|
|
21
|
+
import {} from '../../sandbox/SandboxEngine.js';
|
|
22
|
+
import { SANDBOX_SYSTEM_INSTRUCTION } from '../../sandbox/index.js';
|
|
23
|
+
import {} from './SemanticDefaults.js';
|
|
24
|
+
/**
|
|
25
|
+
* Compile FluentToolBuilder state into a GroupedToolBuilder.
|
|
26
|
+
*
|
|
27
|
+
* @param config - Assembled configuration from builder state
|
|
28
|
+
* @returns A `GroupedToolBuilder` ready for registration
|
|
29
|
+
*/
|
|
30
|
+
export function buildToolFromFluent(config) {
|
|
31
|
+
// Build accumulated with* params into ZodObject
|
|
32
|
+
let inputSchema;
|
|
33
|
+
if (Object.keys(config.withParams).length > 0) {
|
|
34
|
+
inputSchema = z.object(config.withParams);
|
|
35
|
+
}
|
|
36
|
+
// Parse name: 'domain.action' → tool='domain', action='action'
|
|
37
|
+
const dotIndex = config.name.indexOf('.');
|
|
38
|
+
// Bug #109 fix: reject multi-dot names early with a clear error.
|
|
39
|
+
if (dotIndex > 0 && config.name.indexOf('.', dotIndex + 1) !== -1) {
|
|
40
|
+
throw new Error(`Tool name '${config.name}' has too many dot-separated segments. ` +
|
|
41
|
+
`Only one dot is allowed (e.g. 'group.action'). Use f.router() for nested prefixes.`);
|
|
42
|
+
}
|
|
43
|
+
const toolName = dotIndex > 0 ? config.name.slice(0, dotIndex) : config.name;
|
|
44
|
+
const actionName = dotIndex > 0 ? config.name.slice(dotIndex + 1) : 'default';
|
|
45
|
+
// Compile description: instructions + description
|
|
46
|
+
const descParts = [];
|
|
47
|
+
if (config.instructions) {
|
|
48
|
+
descParts.push(`[INSTRUCTIONS] ${config.instructions}`);
|
|
49
|
+
}
|
|
50
|
+
if (config.description) {
|
|
51
|
+
descParts.push(config.description);
|
|
52
|
+
}
|
|
53
|
+
// HATEOAS Auto-Prompting: teach the LLM about sandbox capability
|
|
54
|
+
if (config.sandboxConfig) {
|
|
55
|
+
descParts.push(SANDBOX_SYSTEM_INSTRUCTION.trim());
|
|
56
|
+
}
|
|
57
|
+
const compiledDescription = descParts.length > 0 ? descParts.join('\n\n') : undefined;
|
|
58
|
+
// Resolve semantic defaults + overrides
|
|
59
|
+
const readOnly = config.readOnly ?? config.semanticDefaults.readOnly;
|
|
60
|
+
const destructive = config.destructive ?? config.semanticDefaults.destructive;
|
|
61
|
+
const idempotent = config.idempotent ?? config.semanticDefaults.idempotent;
|
|
62
|
+
// Wrap handler: (input, ctx) → (ctx, args)
|
|
63
|
+
const resolvedHandler = config.handler;
|
|
64
|
+
const wrappedHandler = async (ctx, args) => {
|
|
65
|
+
const result = await resolvedHandler(args, ctx);
|
|
66
|
+
// Guard: void/null handlers → safe fallback (Bug #41)
|
|
67
|
+
if (result === undefined || result === null) {
|
|
68
|
+
return success('OK');
|
|
69
|
+
}
|
|
70
|
+
// Auto-wrap non-ToolResponse results (implicit success)
|
|
71
|
+
// Primary: check brand symbol stamped by success()/error()/toolError() helpers.
|
|
72
|
+
// Fallback: shape-based heuristic for manually constructed ToolResponse objects.
|
|
73
|
+
if (typeof result === 'object' && result !== null) {
|
|
74
|
+
// Brand check — reliable, no false positives (Bug #127)
|
|
75
|
+
if (TOOL_RESPONSE_BRAND in result) {
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
// Shape heuristic — backward compat for manually constructed ToolResponse
|
|
79
|
+
if ('content' in result &&
|
|
80
|
+
Array.isArray(result.content) &&
|
|
81
|
+
result.content.length > 0 &&
|
|
82
|
+
result.content[0]?.type === 'text' &&
|
|
83
|
+
typeof result.content[0]?.text === 'string' &&
|
|
84
|
+
Object.keys(result).every(k => k === 'content' || k === 'isError')) {
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Implicit success() — the dev just returns raw data!
|
|
89
|
+
return success(result);
|
|
90
|
+
};
|
|
91
|
+
// Build via GroupedToolBuilder for consistency with existing pipeline
|
|
92
|
+
const builder = new GroupedToolBuilder(toolName);
|
|
93
|
+
if (compiledDescription)
|
|
94
|
+
builder.description(compiledDescription);
|
|
95
|
+
if (config.tags.length > 0)
|
|
96
|
+
builder.tags(...config.tags);
|
|
97
|
+
if (config.toonMode)
|
|
98
|
+
builder.toonDescription();
|
|
99
|
+
if (config.annotations)
|
|
100
|
+
builder.annotations(config.annotations);
|
|
101
|
+
// Propagate state sync hints
|
|
102
|
+
if (config.invalidatesPatterns.length > 0) {
|
|
103
|
+
builder.invalidates(...config.invalidatesPatterns);
|
|
104
|
+
}
|
|
105
|
+
if (config.cacheControl) {
|
|
106
|
+
config.cacheControl === 'immutable' ? builder.cached() : builder.stale();
|
|
107
|
+
}
|
|
108
|
+
// Propagate runtime guards
|
|
109
|
+
if (config.concurrency) {
|
|
110
|
+
builder.concurrency(config.concurrency);
|
|
111
|
+
}
|
|
112
|
+
if (config.egressMaxBytes !== undefined) {
|
|
113
|
+
builder.maxPayloadBytes(config.egressMaxBytes);
|
|
114
|
+
}
|
|
115
|
+
// Propagate sandbox config
|
|
116
|
+
if (config.sandboxConfig) {
|
|
117
|
+
builder.sandbox(config.sandboxConfig);
|
|
118
|
+
}
|
|
119
|
+
// Propagate FSM state gate
|
|
120
|
+
if (config.fsmStates) {
|
|
121
|
+
builder.bindState(config.fsmStates, config.fsmTransition);
|
|
122
|
+
}
|
|
123
|
+
// Apply middleware
|
|
124
|
+
for (const mw of config.middlewares) {
|
|
125
|
+
builder.use(mw);
|
|
126
|
+
}
|
|
127
|
+
// Register the single action
|
|
128
|
+
builder.action({
|
|
129
|
+
name: actionName,
|
|
130
|
+
handler: wrappedHandler,
|
|
131
|
+
...(inputSchema ? { schema: inputSchema } : {}),
|
|
132
|
+
...(readOnly !== undefined ? { readOnly } : {}),
|
|
133
|
+
...(destructive !== undefined ? { destructive } : {}),
|
|
134
|
+
...(idempotent !== undefined ? { idempotent } : {}),
|
|
135
|
+
...(config.returns ? { returns: config.returns } : {}),
|
|
136
|
+
});
|
|
137
|
+
return builder;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=BuildPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
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CAAC;IACpB,CAAC;IAED,6BAA6B;IAC7B,OAAO,CAAC,MAAM,CAAC;QACX,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,cAAc;QACvB,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -26,27 +26,15 @@
|
|
|
26
26
|
* @module
|
|
27
27
|
*/
|
|
28
28
|
import { type ZodType, type ZodObject, type ZodRawShape } from 'zod';
|
|
29
|
+
import { type Model } from '../../model/defineModel.js';
|
|
29
30
|
import { GroupedToolBuilder } from './GroupedToolBuilder.js';
|
|
30
31
|
import { type ToolResponse, type MiddlewareFn } from '../types.js';
|
|
31
32
|
import { type Presenter } from '../../presenter/Presenter.js';
|
|
32
33
|
import { type ConcurrencyConfig } from '../execution/ConcurrencyGuard.js';
|
|
33
34
|
import { type SandboxConfig } from '../../sandbox/SandboxEngine.js';
|
|
34
35
|
import { type MiddlewareDefinition } from '../middleware/ContextDerivation.js';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
export interface SemanticDefaults {
|
|
40
|
-
readonly readOnly?: boolean;
|
|
41
|
-
readonly destructive?: boolean;
|
|
42
|
-
readonly idempotent?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/** Defaults for `f.query()` — read-only, no side effects */
|
|
45
|
-
export declare const QUERY_DEFAULTS: SemanticDefaults;
|
|
46
|
-
/** Defaults for `f.mutation()` — destructive, irreversible */
|
|
47
|
-
export declare const MUTATION_DEFAULTS: SemanticDefaults;
|
|
48
|
-
/** Defaults for `f.action()` — neutral, no assumptions */
|
|
49
|
-
export declare const ACTION_DEFAULTS: SemanticDefaults;
|
|
36
|
+
import { type SemanticDefaults } from './SemanticDefaults.js';
|
|
37
|
+
export { type SemanticDefaults, QUERY_DEFAULTS, MUTATION_DEFAULTS, ACTION_DEFAULTS } from './SemanticDefaults.js';
|
|
50
38
|
/**
|
|
51
39
|
* Fluent builder that accumulates types at each step.
|
|
52
40
|
*
|
|
@@ -54,13 +42,14 @@ export declare const ACTION_DEFAULTS: SemanticDefaults;
|
|
|
54
42
|
* @typeParam TInput - Accumulated input type (built by `with*()` methods)
|
|
55
43
|
* @typeParam TCtx - Accumulated context type (enriched by `.use()`)
|
|
56
44
|
*/
|
|
57
|
-
export declare class FluentToolBuilder<TContext, TInput =
|
|
45
|
+
export declare class FluentToolBuilder<TContext, TInput = Record<string, never>, TCtx = TContext> {
|
|
58
46
|
/** @internal */ readonly _name: string;
|
|
59
47
|
/** @internal */ _description?: string;
|
|
60
48
|
/** @internal */ _instructions?: string;
|
|
61
49
|
/** @internal */ _inputSchema?: ZodObject<ZodRawShape>;
|
|
62
50
|
/** @internal */ _withParams: Record<string, ZodType>;
|
|
63
51
|
/** @internal */ _tags: string[];
|
|
52
|
+
/** @internal */ _modelRef?: Model;
|
|
64
53
|
/**
|
|
65
54
|
* @internal Bug #118 fix: reject duplicate parameter names.
|
|
66
55
|
* All `withXxx()` methods delegate to this instead of assigning directly.
|
|
@@ -411,6 +400,27 @@ export declare class FluentToolBuilder<TContext, TInput = void, TCtx = TContext>
|
|
|
411
400
|
withOptionalArrays<I extends 'string' | 'number' | 'boolean', R extends Record<string, string>>(itemType: I, fields: R): FluentToolBuilder<TContext, TInput & {
|
|
412
401
|
[K in keyof R & string]?: (I extends 'string' ? string : I extends 'number' ? number : boolean)[] | undefined;
|
|
413
402
|
}, TCtx>;
|
|
403
|
+
/**
|
|
404
|
+
* Derive tool input parameters from a Model's fillable profile.
|
|
405
|
+
*
|
|
406
|
+
* Reads the specified operation from `model.input` (fillable profiles),
|
|
407
|
+
* then adds each field as a parameter using the type and description from
|
|
408
|
+
* the Model's casts. For `create`, fields respect their schema optionality.
|
|
409
|
+
* For `update` and `filter`, all fields become optional.
|
|
410
|
+
*
|
|
411
|
+
* @param model - A `Model` from `defineModel()`
|
|
412
|
+
* @param operation - The fillable profile name (e.g. `'create'`, `'update'`, `'filter'`)
|
|
413
|
+
* @returns Builder with additional parameters from the Model
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* f.mutation('task.create')
|
|
418
|
+
* .fromModel(TaskModel, 'create')
|
|
419
|
+
* .withStrings({ company_slug: '...', project_slug: '...' })
|
|
420
|
+
* .handle(async (input, ctx) => { ... });
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
fromModel<M extends Model>(model: M, operation: string): FluentToolBuilder<TContext, TInput & Record<string, any>, TCtx>;
|
|
414
424
|
/**
|
|
415
425
|
* Add context-derivation middleware (tRPC-style).
|
|
416
426
|
*
|
|
@@ -456,7 +466,7 @@ export declare class FluentToolBuilder<TContext, TInput = void, TCtx = TContext>
|
|
|
456
466
|
* @param presenter - A Presenter instance
|
|
457
467
|
* @returns `this` for chaining
|
|
458
468
|
*/
|
|
459
|
-
returns(presenter: Presenter<
|
|
469
|
+
returns(presenter: Presenter<any>): FluentToolBuilder<TContext, TInput, TCtx>;
|
|
460
470
|
/**
|
|
461
471
|
* Add capability tags for selective tool exposure.
|
|
462
472
|
*
|
|
@@ -593,13 +603,48 @@ export declare class FluentToolBuilder<TContext, TInput = void, TCtx = TContext>
|
|
|
593
603
|
* });
|
|
594
604
|
* ```
|
|
595
605
|
*/
|
|
596
|
-
handle(handler: (input: TInput extends
|
|
606
|
+
handle(handler: (input: [TInput] extends [Record<string, never>] ? Record<string, any> : TInput, ctx: TCtx) => Promise<ToolResponse | unknown>): GroupedToolBuilder<TContext>;
|
|
607
|
+
/**
|
|
608
|
+
* Auto-generate a handler that proxies to `ctx.client` HTTP methods.
|
|
609
|
+
*
|
|
610
|
+
* Eliminates boilerplate by deriving the HTTP method from the semantic
|
|
611
|
+
* verb (`query` → GET, `mutation` → POST) and passing model input
|
|
612
|
+
* directly as query params or request body.
|
|
613
|
+
*
|
|
614
|
+
* For tools with non-trivial logic (data transformation, multi-step
|
|
615
|
+
* calls, conditional behavior), use `.handle()` instead.
|
|
616
|
+
*
|
|
617
|
+
* @param endpoint - API path (e.g. `'companies/standup/summary'`)
|
|
618
|
+
* @param options - Optional overrides
|
|
619
|
+
* @param options.method - Force HTTP method (`'GET'`, `'POST'`, `'PUT'`, `'DELETE'`)
|
|
620
|
+
* @param options.unwrap - Auto-unwrap `response.data` (default: `true`)
|
|
621
|
+
* @returns A `GroupedToolBuilder` ready for registration
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```typescript
|
|
625
|
+
* const pulse = analytics.query('pulse')
|
|
626
|
+
* .fromModel(AnalyticsModel, 'query')
|
|
627
|
+
* .proxy('companies/manager-dashboard/pulse');
|
|
628
|
+
*
|
|
629
|
+
* const create = note.mutation('create')
|
|
630
|
+
* .fromModel(NoteModel, 'create')
|
|
631
|
+
* .proxy('notes');
|
|
632
|
+
*
|
|
633
|
+
* const update = note.mutation('update')
|
|
634
|
+
* .fromModel(NoteModel, 'update')
|
|
635
|
+
* .proxy('notes/:uuid', { method: 'PUT' });
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
proxy(endpoint: string, options?: {
|
|
639
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
640
|
+
unwrap?: boolean;
|
|
641
|
+
}): GroupedToolBuilder<TContext>;
|
|
597
642
|
/**
|
|
598
643
|
* Alias for `.handle()` — for backward compatibility.
|
|
599
644
|
* @internal
|
|
600
645
|
*/
|
|
601
646
|
resolve(handler: (args: {
|
|
602
|
-
input: TInput extends
|
|
647
|
+
input: [TInput] extends [Record<string, never>] ? Record<string, any> : TInput;
|
|
603
648
|
ctx: TCtx;
|
|
604
649
|
}) => Promise<ToolResponse | unknown>): GroupedToolBuilder<TContext>;
|
|
605
650
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FluentToolBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/FluentToolBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAK,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"FluentToolBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/builder/FluentToolBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAK,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AACxE,OAAO,EAAE,KAAK,KAAK,EAAwB,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAA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C,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,KAClG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,GACrC,kBAAkB,CAAC,QAAQ,CAAC;IAO/B,gBAAgB;IAChB,OAAO,CAAC,MAAM;CAwCjB"}
|
|
@@ -26,20 +26,18 @@
|
|
|
26
26
|
* @module
|
|
27
27
|
*/
|
|
28
28
|
import { z } from 'zod';
|
|
29
|
+
import { compileFieldForInput } from '../../model/defineModel.js';
|
|
29
30
|
import { GroupedToolBuilder } from './GroupedToolBuilder.js';
|
|
30
31
|
import {} from '../types.js';
|
|
31
|
-
import { success, TOOL_RESPONSE_BRAND } from '../response.js';
|
|
32
32
|
import {} from '../../presenter/Presenter.js';
|
|
33
33
|
import {} from '../execution/ConcurrencyGuard.js';
|
|
34
34
|
import {} from '../../sandbox/SandboxEngine.js';
|
|
35
|
-
import { SANDBOX_SYSTEM_INSTRUCTION } from '../../sandbox/index.js';
|
|
36
35
|
import {} from '../middleware/ContextDerivation.js';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
export const ACTION_DEFAULTS = {};
|
|
36
|
+
import {} from './SemanticDefaults.js';
|
|
37
|
+
import { createProxyHandler } from './ProxyHandler.js';
|
|
38
|
+
import { buildToolFromFluent } from './BuildPipeline.js';
|
|
39
|
+
// Re-export SemanticDefaults for backward compatibility
|
|
40
|
+
export { QUERY_DEFAULTS, MUTATION_DEFAULTS, ACTION_DEFAULTS } from './SemanticDefaults.js';
|
|
43
41
|
// ── Array Item Type Resolution ───────────────────────────
|
|
44
42
|
/** Resolve Zod type from array item type string */
|
|
45
43
|
function resolveArrayItemType(itemType) {
|
|
@@ -64,6 +62,7 @@ export class FluentToolBuilder {
|
|
|
64
62
|
/** @internal */ _inputSchema;
|
|
65
63
|
/** @internal */ _withParams = {};
|
|
66
64
|
/** @internal */ _tags = [];
|
|
65
|
+
/** @internal */ _modelRef;
|
|
67
66
|
/**
|
|
68
67
|
* @internal Bug #118 fix: reject duplicate parameter names.
|
|
69
68
|
* All `withXxx()` methods delegate to this instead of assigning directly.
|
|
@@ -73,7 +72,7 @@ export class FluentToolBuilder {
|
|
|
73
72
|
throw new Error(`Empty parameter name on tool "${this._name}". ` +
|
|
74
73
|
`Each parameter must have a non-empty name.`);
|
|
75
74
|
}
|
|
76
|
-
if (
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(this._withParams, name)) {
|
|
77
76
|
throw new Error(`Duplicate parameter name "${name}" on tool "${this._name}". ` +
|
|
78
77
|
`Each parameter must have a unique name.`);
|
|
79
78
|
}
|
|
@@ -525,6 +524,51 @@ export class FluentToolBuilder {
|
|
|
525
524
|
}
|
|
526
525
|
return this;
|
|
527
526
|
}
|
|
527
|
+
// ── Model Integration ─────────────────────────────────
|
|
528
|
+
/**
|
|
529
|
+
* Derive tool input parameters from a Model's fillable profile.
|
|
530
|
+
*
|
|
531
|
+
* Reads the specified operation from `model.input` (fillable profiles),
|
|
532
|
+
* then adds each field as a parameter using the type and description from
|
|
533
|
+
* the Model's casts. For `create`, fields respect their schema optionality.
|
|
534
|
+
* For `update` and `filter`, all fields become optional.
|
|
535
|
+
*
|
|
536
|
+
* @param model - A `Model` from `defineModel()`
|
|
537
|
+
* @param operation - The fillable profile name (e.g. `'create'`, `'update'`, `'filter'`)
|
|
538
|
+
* @returns Builder with additional parameters from the Model
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* f.mutation('task.create')
|
|
543
|
+
* .fromModel(TaskModel, 'create')
|
|
544
|
+
* .withStrings({ company_slug: '...', project_slug: '...' })
|
|
545
|
+
* .handle(async (input, ctx) => { ... });
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Model fields are runtime-defined; `any` avoids forced casting
|
|
549
|
+
fromModel(model, operation) {
|
|
550
|
+
const fieldNames = model.input[operation];
|
|
551
|
+
if (!fieldNames) {
|
|
552
|
+
throw new Error(`Model "${model.name}" has no fillable profile "${operation}". ` +
|
|
553
|
+
`Available: ${Object.keys(model.input).join(', ') || 'none'}`);
|
|
554
|
+
}
|
|
555
|
+
// Determine if all fields should be forced optional (update/filter semantics)
|
|
556
|
+
const forceOptional = operation !== 'create';
|
|
557
|
+
for (const fieldName of fieldNames) {
|
|
558
|
+
const fieldDef = model.fields[fieldName];
|
|
559
|
+
if (!fieldDef) {
|
|
560
|
+
throw new Error(`Model "${model.name}" fillable profile "${operation}" references ` +
|
|
561
|
+
`field "${fieldName}" which is not defined in casts.`);
|
|
562
|
+
}
|
|
563
|
+
// Compile FieldDef → Zod schema for input context
|
|
564
|
+
const schema = compileFieldForInput(fieldDef, forceOptional);
|
|
565
|
+
this._addParam(fieldName, schema);
|
|
566
|
+
}
|
|
567
|
+
// Store Model reference for .proxy() alias resolution
|
|
568
|
+
this._modelRef = model;
|
|
569
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
528
572
|
use(mw) {
|
|
529
573
|
// Handle MiddlewareDefinition from f.middleware()
|
|
530
574
|
if (typeof mw === 'object' && mw !== null && '__brand' in mw && mw.__brand === 'MiddlewareDefinition') {
|
|
@@ -563,6 +607,7 @@ export class FluentToolBuilder {
|
|
|
563
607
|
* @param presenter - A Presenter instance
|
|
564
608
|
* @returns `this` for chaining
|
|
565
609
|
*/
|
|
610
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- covariant: accept any Presenter subtype
|
|
566
611
|
returns(presenter) {
|
|
567
612
|
this._returns = presenter;
|
|
568
613
|
return this;
|
|
@@ -753,6 +798,46 @@ export class FluentToolBuilder {
|
|
|
753
798
|
handle(handler) {
|
|
754
799
|
return this._build(handler);
|
|
755
800
|
}
|
|
801
|
+
// ── Terminal: proxy() ────────────────────────────────
|
|
802
|
+
/**
|
|
803
|
+
* Auto-generate a handler that proxies to `ctx.client` HTTP methods.
|
|
804
|
+
*
|
|
805
|
+
* Eliminates boilerplate by deriving the HTTP method from the semantic
|
|
806
|
+
* verb (`query` → GET, `mutation` → POST) and passing model input
|
|
807
|
+
* directly as query params or request body.
|
|
808
|
+
*
|
|
809
|
+
* For tools with non-trivial logic (data transformation, multi-step
|
|
810
|
+
* calls, conditional behavior), use `.handle()` instead.
|
|
811
|
+
*
|
|
812
|
+
* @param endpoint - API path (e.g. `'companies/standup/summary'`)
|
|
813
|
+
* @param options - Optional overrides
|
|
814
|
+
* @param options.method - Force HTTP method (`'GET'`, `'POST'`, `'PUT'`, `'DELETE'`)
|
|
815
|
+
* @param options.unwrap - Auto-unwrap `response.data` (default: `true`)
|
|
816
|
+
* @returns A `GroupedToolBuilder` ready for registration
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
* ```typescript
|
|
820
|
+
* const pulse = analytics.query('pulse')
|
|
821
|
+
* .fromModel(AnalyticsModel, 'query')
|
|
822
|
+
* .proxy('companies/manager-dashboard/pulse');
|
|
823
|
+
*
|
|
824
|
+
* const create = note.mutation('create')
|
|
825
|
+
* .fromModel(NoteModel, 'create')
|
|
826
|
+
* .proxy('notes');
|
|
827
|
+
*
|
|
828
|
+
* const update = note.mutation('update')
|
|
829
|
+
* .fromModel(NoteModel, 'update')
|
|
830
|
+
* .proxy('notes/:uuid', { method: 'PUT' });
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
proxy(endpoint, options) {
|
|
834
|
+
const httpMethod = options?.method
|
|
835
|
+
?? (this._semanticDefaults.readOnly ? 'GET' : 'POST');
|
|
836
|
+
const shouldUnwrap = options?.unwrap ?? true;
|
|
837
|
+
const handler = createProxyHandler(endpoint, httpMethod, shouldUnwrap, this._modelRef);
|
|
838
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
839
|
+
return this._build(handler);
|
|
840
|
+
}
|
|
756
841
|
/**
|
|
757
842
|
* Alias for `.handle()` — for backward compatibility.
|
|
758
843
|
* @internal
|
|
@@ -770,112 +855,29 @@ export class FluentToolBuilder {
|
|
|
770
855
|
`Each FluentToolBuilder can only have one handler.`);
|
|
771
856
|
}
|
|
772
857
|
this._handlerSet = true;
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
if (this._sandboxConfig) {
|
|
796
|
-
descParts.push(SANDBOX_SYSTEM_INSTRUCTION.trim());
|
|
797
|
-
}
|
|
798
|
-
const compiledDescription = descParts.length > 0 ? descParts.join('\n\n') : undefined;
|
|
799
|
-
// Resolve semantic defaults + overrides
|
|
800
|
-
const readOnly = this._readOnly ?? this._semanticDefaults.readOnly;
|
|
801
|
-
const destructive = this._destructive ?? this._semanticDefaults.destructive;
|
|
802
|
-
const idempotent = this._idempotent ?? this._semanticDefaults.idempotent;
|
|
803
|
-
// Wrap handler: (input, ctx) → (ctx, args)
|
|
804
|
-
const resolvedHandler = handler;
|
|
805
|
-
const wrappedHandler = async (ctx, args) => {
|
|
806
|
-
const result = await resolvedHandler(args, ctx);
|
|
807
|
-
// Guard: void/null handlers → safe fallback (Bug #41)
|
|
808
|
-
if (result === undefined || result === null) {
|
|
809
|
-
return success('OK');
|
|
810
|
-
}
|
|
811
|
-
// Auto-wrap non-ToolResponse results (implicit success)
|
|
812
|
-
// Primary: check brand symbol stamped by success()/error()/toolError() helpers.
|
|
813
|
-
// Fallback: shape-based heuristic for manually constructed ToolResponse objects.
|
|
814
|
-
if (typeof result === 'object' && result !== null) {
|
|
815
|
-
// Brand check — reliable, no false positives (Bug #127)
|
|
816
|
-
if (TOOL_RESPONSE_BRAND in result) {
|
|
817
|
-
return result;
|
|
818
|
-
}
|
|
819
|
-
// Shape heuristic — backward compat for manually constructed ToolResponse
|
|
820
|
-
if ('content' in result &&
|
|
821
|
-
Array.isArray(result.content) &&
|
|
822
|
-
result.content.length > 0 &&
|
|
823
|
-
result.content[0]?.type === 'text' &&
|
|
824
|
-
typeof result.content[0]?.text === 'string' &&
|
|
825
|
-
Object.keys(result).every(k => k === 'content' || k === 'isError')) {
|
|
826
|
-
return result;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
// Implicit success() — the dev just returns raw data!
|
|
830
|
-
return success(result);
|
|
831
|
-
};
|
|
832
|
-
// Build via GroupedToolBuilder for consistency with existing pipeline
|
|
833
|
-
const builder = new GroupedToolBuilder(toolName);
|
|
834
|
-
if (compiledDescription)
|
|
835
|
-
builder.description(compiledDescription);
|
|
836
|
-
if (this._tags.length > 0)
|
|
837
|
-
builder.tags(...this._tags);
|
|
838
|
-
if (this._toonMode)
|
|
839
|
-
builder.toonDescription();
|
|
840
|
-
if (this._annotations)
|
|
841
|
-
builder.annotations(this._annotations);
|
|
842
|
-
// Propagate state sync hints
|
|
843
|
-
if (this._invalidatesPatterns.length > 0) {
|
|
844
|
-
builder.invalidates(...this._invalidatesPatterns);
|
|
845
|
-
}
|
|
846
|
-
if (this._cacheControl) {
|
|
847
|
-
this._cacheControl === 'immutable' ? builder.cached() : builder.stale();
|
|
848
|
-
}
|
|
849
|
-
// Propagate runtime guards
|
|
850
|
-
if (this._concurrency) {
|
|
851
|
-
builder.concurrency(this._concurrency);
|
|
852
|
-
}
|
|
853
|
-
if (this._egressMaxBytes !== undefined) {
|
|
854
|
-
builder.maxPayloadBytes(this._egressMaxBytes);
|
|
855
|
-
}
|
|
856
|
-
// Propagate sandbox config
|
|
857
|
-
if (this._sandboxConfig) {
|
|
858
|
-
builder.sandbox(this._sandboxConfig);
|
|
859
|
-
}
|
|
860
|
-
// Propagate FSM state gate
|
|
861
|
-
if (this._fsmStates) {
|
|
862
|
-
builder.bindState(this._fsmStates, this._fsmTransition);
|
|
863
|
-
}
|
|
864
|
-
// Apply middleware
|
|
865
|
-
for (const mw of this._middlewares) {
|
|
866
|
-
builder.use(mw);
|
|
867
|
-
}
|
|
868
|
-
// Register the single action
|
|
869
|
-
builder.action({
|
|
870
|
-
name: actionName,
|
|
871
|
-
handler: wrappedHandler,
|
|
872
|
-
...(this._inputSchema ? { schema: this._inputSchema } : {}),
|
|
873
|
-
...(readOnly !== undefined ? { readOnly } : {}),
|
|
874
|
-
...(destructive !== undefined ? { destructive } : {}),
|
|
875
|
-
...(idempotent !== undefined ? { idempotent } : {}),
|
|
876
|
-
...(this._returns ? { returns: this._returns } : {}),
|
|
858
|
+
return buildToolFromFluent({
|
|
859
|
+
name: this._name,
|
|
860
|
+
description: this._description,
|
|
861
|
+
instructions: this._instructions,
|
|
862
|
+
withParams: this._withParams,
|
|
863
|
+
tags: this._tags,
|
|
864
|
+
middlewares: this._middlewares,
|
|
865
|
+
returns: this._returns,
|
|
866
|
+
semanticDefaults: this._semanticDefaults,
|
|
867
|
+
readOnly: this._readOnly,
|
|
868
|
+
destructive: this._destructive,
|
|
869
|
+
idempotent: this._idempotent,
|
|
870
|
+
toonMode: this._toonMode,
|
|
871
|
+
annotations: this._annotations,
|
|
872
|
+
invalidatesPatterns: this._invalidatesPatterns,
|
|
873
|
+
cacheControl: this._cacheControl,
|
|
874
|
+
concurrency: this._concurrency,
|
|
875
|
+
egressMaxBytes: this._egressMaxBytes,
|
|
876
|
+
sandboxConfig: this._sandboxConfig,
|
|
877
|
+
fsmStates: this._fsmStates,
|
|
878
|
+
fsmTransition: this._fsmTransition,
|
|
879
|
+
handler: handler,
|
|
877
880
|
});
|
|
878
|
-
return builder;
|
|
879
881
|
}
|
|
880
882
|
}
|
|
881
883
|
//# sourceMappingURL=FluentToolBuilder.js.map
|