@vurb/core 3.2.3 → 3.3.4
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 +677 -677
- package/dist/cli/constants.js +59 -59
- package/dist/cli/templates/config.js +26 -26
- 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.d.ts.map +1 -1
- package/dist/cli/templates/core.js +96 -169
- package/dist/cli/templates/core.js.map +1 -1
- package/dist/cli/templates/middleware.js +25 -25
- package/dist/cli/templates/readme.js +142 -142
- 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/middleware/AuditTrail.d.ts +128 -0
- package/dist/core/middleware/AuditTrail.d.ts.map +1 -0
- package/dist/core/middleware/AuditTrail.js +94 -0
- package/dist/core/middleware/AuditTrail.js.map +1 -0
- package/dist/core/middleware/InputFirewall.d.ts +95 -0
- package/dist/core/middleware/InputFirewall.d.ts.map +1 -0
- package/dist/core/middleware/InputFirewall.js +104 -0
- package/dist/core/middleware/InputFirewall.js.map +1 -0
- package/dist/core/middleware/RateLimiter.d.ts +151 -0
- package/dist/core/middleware/RateLimiter.d.ts.map +1 -0
- package/dist/core/middleware/RateLimiter.js +121 -0
- package/dist/core/middleware/RateLimiter.js.map +1 -0
- package/dist/core/middleware/index.d.ts +6 -0
- package/dist/core/middleware/index.d.ts.map +1 -1
- package/dist/core/middleware/index.js +4 -0
- package/dist/core/middleware/index.js.map +1 -1
- package/dist/index.d.ts +28 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/introspection/SemanticProbe.js +49 -49
- package/dist/observability/TelemetryEvent.d.ts +61 -1
- package/dist/observability/TelemetryEvent.d.ts.map +1 -1
- package/dist/presenter/JudgeChain.d.ts +129 -0
- package/dist/presenter/JudgeChain.d.ts.map +1 -0
- package/dist/presenter/JudgeChain.js +215 -0
- package/dist/presenter/JudgeChain.js.map +1 -0
- package/dist/presenter/PostProcessor.d.ts.map +1 -1
- package/dist/presenter/PostProcessor.js +11 -66
- package/dist/presenter/PostProcessor.js.map +1 -1
- package/dist/presenter/Presenter.d.ts +175 -37
- package/dist/presenter/Presenter.d.ts.map +1 -1
- package/dist/presenter/Presenter.js +265 -154
- package/dist/presenter/Presenter.js.map +1 -1
- package/dist/presenter/PresenterPipeline.d.ts +147 -0
- package/dist/presenter/PresenterPipeline.d.ts.map +1 -0
- package/dist/presenter/PresenterPipeline.js +271 -0
- package/dist/presenter/PresenterPipeline.js.map +1 -0
- package/dist/presenter/PromptFirewall.d.ts +160 -0
- package/dist/presenter/PromptFirewall.d.ts.map +1 -0
- package/dist/presenter/PromptFirewall.js +228 -0
- package/dist/presenter/PromptFirewall.js.map +1 -0
- package/dist/presenter/ResponseBuilder.d.ts +13 -0
- package/dist/presenter/ResponseBuilder.d.ts.map +1 -1
- package/dist/presenter/ResponseBuilder.js +28 -1
- package/dist/presenter/ResponseBuilder.js.map +1 -1
- package/dist/presenter/TelemetryCollector.d.ts +48 -0
- package/dist/presenter/TelemetryCollector.d.ts.map +1 -0
- package/dist/presenter/TelemetryCollector.js +93 -0
- package/dist/presenter/TelemetryCollector.js.map +1 -0
- package/dist/presenter/definePresenter.d.ts +112 -0
- package/dist/presenter/definePresenter.d.ts.map +1 -1
- package/dist/presenter/definePresenter.js +110 -0
- package/dist/presenter/definePresenter.js.map +1 -1
- package/dist/presenter/index.d.ts +6 -2
- package/dist/presenter/index.d.ts.map +1 -1
- package/dist/presenter/index.js +5 -1
- package/dist/presenter/index.js.map +1 -1
- package/dist/presenter/ui.d.ts +31 -8
- package/dist/presenter/ui.d.ts.map +1 -1
- package/dist/presenter/ui.js +16 -16
- package/dist/presenter/ui.js.map +1 -1
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -1
- package/dist/resource/ResourceBuilder.d.ts +129 -0
- package/dist/resource/ResourceBuilder.d.ts.map +1 -0
- package/dist/resource/ResourceBuilder.js +93 -0
- package/dist/resource/ResourceBuilder.js.map +1 -0
- package/dist/resource/ResourceRegistry.d.ts +147 -0
- package/dist/resource/ResourceRegistry.d.ts.map +1 -0
- package/dist/resource/ResourceRegistry.js +234 -0
- package/dist/resource/ResourceRegistry.js.map +1 -0
- package/dist/resource/SubscriptionManager.d.ts +67 -0
- package/dist/resource/SubscriptionManager.d.ts.map +1 -0
- package/dist/resource/SubscriptionManager.js +86 -0
- package/dist/resource/SubscriptionManager.js.map +1 -0
- package/dist/resource/index.d.ts +13 -0
- package/dist/resource/index.d.ts.map +1 -0
- package/dist/resource/index.js +13 -0
- package/dist/resource/index.js.map +1 -0
- package/dist/server/ServerAttachment.d.ts +26 -0
- package/dist/server/ServerAttachment.d.ts.map +1 -1
- package/dist/server/ServerAttachment.js +70 -2
- package/dist/server/ServerAttachment.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/startServer.d.ts +22 -1
- package/dist/server/startServer.d.ts.map +1 -1
- package/dist/server/startServer.js +98 -5
- package/dist/server/startServer.js.map +1 -1
- package/package.json +1 -1
|
@@ -94,6 +94,116 @@ export function definePresenter(config) {
|
|
|
94
94
|
if (config.redactPII) {
|
|
95
95
|
presenter.redactPII(config.redactPII.paths, config.redactPII.censor);
|
|
96
96
|
}
|
|
97
|
+
if (config.collectionSuggestions) {
|
|
98
|
+
presenter.collectionSuggestActions(config.collectionSuggestions);
|
|
99
|
+
}
|
|
100
|
+
if (config.collectionRules) {
|
|
101
|
+
presenter.collectionRules(config.collectionRules);
|
|
102
|
+
}
|
|
103
|
+
// Async callbacks
|
|
104
|
+
if (config.asyncUi) {
|
|
105
|
+
presenter.asyncUiBlocks(config.asyncUi);
|
|
106
|
+
}
|
|
107
|
+
if (config.asyncCollectionUi) {
|
|
108
|
+
presenter.asyncCollectionUiBlocks(config.asyncCollectionUi);
|
|
109
|
+
}
|
|
110
|
+
if (config.asyncRules) {
|
|
111
|
+
presenter.asyncRules(config.asyncRules);
|
|
112
|
+
}
|
|
113
|
+
if (config.asyncSuggestActions) {
|
|
114
|
+
presenter.asyncSuggestActions(config.asyncSuggestActions);
|
|
115
|
+
}
|
|
97
116
|
return presenter;
|
|
98
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Implementation
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export function extendPresenter(base, overrides) {
|
|
123
|
+
const merged = {
|
|
124
|
+
// Name and schema: override always wins
|
|
125
|
+
name: overrides.name,
|
|
126
|
+
// Auto-rules: override wins when explicitly set
|
|
127
|
+
autoRules: overrides.autoRules ?? base.autoRules,
|
|
128
|
+
// Rules: merge strategy
|
|
129
|
+
rules: _mergeRules(base.rules, overrides.rules),
|
|
130
|
+
// UI: override wins if defined
|
|
131
|
+
ui: overrides.ui ?? base.ui,
|
|
132
|
+
collectionUi: overrides.collectionUi ?? base.collectionUi,
|
|
133
|
+
// Agent limit: override wins if defined
|
|
134
|
+
agentLimit: overrides.agentLimit ?? base.agentLimit,
|
|
135
|
+
// Suggestions: override wins if defined
|
|
136
|
+
suggestActions: overrides.suggestActions ?? base.suggestActions,
|
|
137
|
+
collectionSuggestions: overrides.collectionSuggestions ?? base.collectionSuggestions,
|
|
138
|
+
// Collection rules: override wins if defined
|
|
139
|
+
collectionRules: overrides.collectionRules ?? base.collectionRules,
|
|
140
|
+
// Embeds: merge (additive)
|
|
141
|
+
embeds: [
|
|
142
|
+
...(base.embeds ?? []),
|
|
143
|
+
...(overrides.embeds ?? []),
|
|
144
|
+
],
|
|
145
|
+
// Redaction: merge paths
|
|
146
|
+
redactPII: _mergeRedactPII(base.redactPII, overrides.redactPII),
|
|
147
|
+
// Async callbacks: override wins if defined
|
|
148
|
+
asyncUi: overrides.asyncUi ?? base.asyncUi,
|
|
149
|
+
asyncCollectionUi: overrides.asyncCollectionUi ?? base.asyncCollectionUi,
|
|
150
|
+
asyncRules: overrides.asyncRules ?? base.asyncRules,
|
|
151
|
+
asyncSuggestActions: overrides.asyncSuggestActions ?? base.asyncSuggestActions,
|
|
152
|
+
};
|
|
153
|
+
// Schema: override wins, set only if defined (exactOptionalPropertyTypes)
|
|
154
|
+
const schema = overrides.schema ?? base.schema;
|
|
155
|
+
if (schema)
|
|
156
|
+
merged['schema'] = schema;
|
|
157
|
+
// Remove undefined values to satisfy exactOptionalPropertyTypes
|
|
158
|
+
for (const key of Object.keys(merged)) {
|
|
159
|
+
if (merged[key] === undefined)
|
|
160
|
+
delete merged[key];
|
|
161
|
+
}
|
|
162
|
+
return definePresenter(merged);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Merge two rules configs: static arrays are concatenated, dynamic functions are chained.
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
function _mergeRules(base, override) {
|
|
169
|
+
if (!base)
|
|
170
|
+
return override;
|
|
171
|
+
if (!override)
|
|
172
|
+
return base;
|
|
173
|
+
const baseIsStatic = typeof base !== 'function';
|
|
174
|
+
const overrideIsStatic = typeof override !== 'function';
|
|
175
|
+
// Both static: concatenate
|
|
176
|
+
if (baseIsStatic && overrideIsStatic) {
|
|
177
|
+
return [...base, ...override];
|
|
178
|
+
}
|
|
179
|
+
// Mix or both dynamic: chain
|
|
180
|
+
const baseFn = baseIsStatic
|
|
181
|
+
? () => [...base]
|
|
182
|
+
: base;
|
|
183
|
+
const overrideFn = overrideIsStatic
|
|
184
|
+
? () => [...override]
|
|
185
|
+
: override;
|
|
186
|
+
return (data, ctx) => [
|
|
187
|
+
...baseFn(data, ctx),
|
|
188
|
+
...overrideFn(data, ctx),
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Merge two redactPII configurations by concatenating paths.
|
|
193
|
+
* The override's censor function takes priority.
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
function _mergeRedactPII(base, override) {
|
|
197
|
+
if (!base)
|
|
198
|
+
return override;
|
|
199
|
+
if (!override)
|
|
200
|
+
return base;
|
|
201
|
+
const result = {
|
|
202
|
+
paths: [...base.paths, ...override.paths],
|
|
203
|
+
};
|
|
204
|
+
const censor = override.censor ?? base.censor;
|
|
205
|
+
if (censor !== undefined)
|
|
206
|
+
result.censor = censor;
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
99
209
|
//# sourceMappingURL=definePresenter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definePresenter.js","sourceRoot":"","sources":["../../src/presenter/definePresenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAgB,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"definePresenter.js","sourceRoot":"","sources":["../../src/presenter/definePresenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAgB,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAgB,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAiPtE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAgC;IAC5D,MAAM,SAAS,GAAG,IAAI,SAAS,CAAU,MAAM,CAAC,IAAI,CAAC,CAAC;IAEtD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,SAAS,CAAC,MAAM,CAA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C,CAAC,IAA2D,CAAC;IAClE,MAAM,UAAU,GAAG,gBAAgB;QAC/B,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAI,QAA8B,CAAC;QAC5C,CAAC,CAAC,QAA+D,CAAC;IAEtE,OAAO,CAAC,IAAa,EAAE,GAAa,EAAE,EAAE,CAAC;QACrC,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;QACpB,GAAG,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;KAC3B,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CACpB,IAA4C,EAC5C,QAAgD;IAEhD,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC3B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,MAAM,MAAM,GAAwE;QAChF,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC;KAC5C,CAAC;IACF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAC9C,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACjD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
export { ResponseBuilder, response, isResponseBuilder } from './ResponseBuilder.js';
|
|
7
7
|
export type { ActionSuggestion } from './ResponseBuilder.js';
|
|
8
8
|
export { ui } from './ui.js';
|
|
9
|
-
export type { UiBlock } from './ui.js';
|
|
9
|
+
export type { UiBlock, UiBlockMeta } from './ui.js';
|
|
10
10
|
export { Presenter, createPresenter, isPresenter } from './Presenter.js';
|
|
11
|
-
export { definePresenter } from './definePresenter.js';
|
|
11
|
+
export { definePresenter, extendPresenter } from './definePresenter.js';
|
|
12
12
|
export type { PresenterConfig, AgentLimitDef, EmbedDef } from './definePresenter.js';
|
|
13
13
|
export { extractZodDescriptions } from './ZodDescriptionExtractor.js';
|
|
14
14
|
export { PresenterValidationError } from './PresenterValidationError.js';
|
|
@@ -18,4 +18,8 @@ export { postProcessResult, isToolResponse } from './PostProcessor.js';
|
|
|
18
18
|
export { extractZodKeys, pickFields, applySelectFilter } from './SelectUtils.js';
|
|
19
19
|
export { compileRedactor, initRedactEngine } from './RedactEngine.js';
|
|
20
20
|
export type { RedactConfig, RedactFn } from './RedactEngine.js';
|
|
21
|
+
export { createJudgeChain } from './JudgeChain.js';
|
|
22
|
+
export type { JudgeChain, JudgeChainConfig, JudgeChainResult, JudgeResult, JudgeStrategy, } from './JudgeChain.js';
|
|
23
|
+
export { evaluateRules, buildFirewallPrompt, parseFirewallVerdict } from './PromptFirewall.js';
|
|
24
|
+
export type { PromptFirewallConfig, FirewallVerdict, FirewallRejection, } from './PromptFirewall.js';
|
|
21
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presenter/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpF,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presenter/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpF,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACxE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGjF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EACR,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAC9C,WAAW,EAAE,aAAa,GAC7B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,YAAY,EACR,oBAAoB,EAAE,eAAe,EAAE,iBAAiB,GAC3D,MAAM,qBAAqB,CAAC"}
|
package/dist/presenter/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { ui } from './ui.js';
|
|
|
10
10
|
// ── Presenter ────────────────────────────────────────────
|
|
11
11
|
export { Presenter, createPresenter, isPresenter } from './Presenter.js';
|
|
12
12
|
// ── Declarative Presenter ────────────────────────────────
|
|
13
|
-
export { definePresenter } from './definePresenter.js';
|
|
13
|
+
export { definePresenter, extendPresenter } from './definePresenter.js';
|
|
14
14
|
// ── Zod Description Extraction ───────────────────────────
|
|
15
15
|
export { extractZodDescriptions } from './ZodDescriptionExtractor.js';
|
|
16
16
|
// ── Validation Error ─────────────────────────────────────
|
|
@@ -25,4 +25,8 @@ export { postProcessResult, isToolResponse } from './PostProcessor.js';
|
|
|
25
25
|
export { extractZodKeys, pickFields, applySelectFilter } from './SelectUtils.js';
|
|
26
26
|
// ── DLP Compliance (PII Redaction) ───────────────────────
|
|
27
27
|
export { compileRedactor, initRedactEngine } from './RedactEngine.js';
|
|
28
|
+
// ── JudgeChain (Multi-Adapter LLM Evaluation) ───────────
|
|
29
|
+
export { createJudgeChain } from './JudgeChain.js';
|
|
30
|
+
// ── PromptFirewall (Output Protection) ──────────────────
|
|
31
|
+
export { evaluateRules, buildFirewallPrompt, parseFirewallVerdict } from './PromptFirewall.js';
|
|
28
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/presenter/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGpF,4DAA4D;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG7B,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzE,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/presenter/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGpF,4DAA4D;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG7B,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzE,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGxE,4DAA4D;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,4DAA4D;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,4DAA4D;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEvE,4DAA4D;AAC5D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEjF,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGtE,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMnD,2DAA2D;AAC3D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/presenter/ui.d.ts
CHANGED
|
@@ -24,6 +24,27 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
|
+
/**
|
|
28
|
+
* Optional metadata for a UI block — layout hints and presentation context.
|
|
29
|
+
*
|
|
30
|
+
* Metadata is rendered as XML attributes on the `<ui_passthrough>` wrapper,
|
|
31
|
+
* providing downstream clients and AI agents with structured display hints
|
|
32
|
+
* without altering the content payload.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* ui.echarts(chartConfig, { title: 'Revenue', width: 'half' });
|
|
37
|
+
* ui.table(headers, rows, { title: 'Invoices', priority: 1 });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface UiBlockMeta {
|
|
41
|
+
/** Human-readable label for the block (e.g. chart title, section name) */
|
|
42
|
+
readonly title?: string;
|
|
43
|
+
/** Layout width hint for rendering clients */
|
|
44
|
+
readonly width?: 'full' | 'half' | 'third';
|
|
45
|
+
/** Rendering priority (lower = rendered first). Default: insertion order */
|
|
46
|
+
readonly priority?: number;
|
|
47
|
+
}
|
|
27
48
|
/**
|
|
28
49
|
* A structured UI block produced by a Presenter's SSR layer.
|
|
29
50
|
*
|
|
@@ -35,6 +56,8 @@ export interface UiBlock {
|
|
|
35
56
|
readonly type: string;
|
|
36
57
|
/** Ready-to-transport content string */
|
|
37
58
|
readonly content: string;
|
|
59
|
+
/** Optional layout and presentation metadata */
|
|
60
|
+
readonly meta?: UiBlockMeta;
|
|
38
61
|
}
|
|
39
62
|
/**
|
|
40
63
|
* Generate an ECharts UI block from a configuration object.
|
|
@@ -54,7 +77,7 @@ export interface UiBlock {
|
|
|
54
77
|
* });
|
|
55
78
|
* ```
|
|
56
79
|
*/
|
|
57
|
-
declare function echarts(config: Record<string, unknown
|
|
80
|
+
declare function echarts(config: Record<string, unknown>, meta?: UiBlockMeta): UiBlock;
|
|
58
81
|
/**
|
|
59
82
|
* Generate a Mermaid diagram UI block.
|
|
60
83
|
*
|
|
@@ -66,7 +89,7 @@ declare function echarts(config: Record<string, unknown>): UiBlock;
|
|
|
66
89
|
* ui.mermaid('graph TD; A["Start"] --> B["Process"] --> C["End"]');
|
|
67
90
|
* ```
|
|
68
91
|
*/
|
|
69
|
-
declare function mermaid(diagram: string): UiBlock;
|
|
92
|
+
declare function mermaid(diagram: string, meta?: UiBlockMeta): UiBlock;
|
|
70
93
|
/**
|
|
71
94
|
* Generate a raw Markdown UI block.
|
|
72
95
|
*
|
|
@@ -81,7 +104,7 @@ declare function mermaid(diagram: string): UiBlock;
|
|
|
81
104
|
* ui.markdown('| Task | Status |\n|---|---|\n| Deploy | ✅ Done |');
|
|
82
105
|
* ```
|
|
83
106
|
*/
|
|
84
|
-
declare function markdown(md: string): UiBlock;
|
|
107
|
+
declare function markdown(md: string, meta?: UiBlockMeta): UiBlock;
|
|
85
108
|
/**
|
|
86
109
|
* Generate a generic fenced code block UI block.
|
|
87
110
|
*
|
|
@@ -98,7 +121,7 @@ declare function markdown(md: string): UiBlock;
|
|
|
98
121
|
* ui.codeBlock('xml', '<root><item>value</item></root>');
|
|
99
122
|
* ```
|
|
100
123
|
*/
|
|
101
|
-
declare function codeBlock(lang: string, code: string): UiBlock;
|
|
124
|
+
declare function codeBlock(lang: string, code: string, meta?: UiBlockMeta): UiBlock;
|
|
102
125
|
/**
|
|
103
126
|
* Generate a Markdown table UI block from headers and row data.
|
|
104
127
|
*
|
|
@@ -121,7 +144,7 @@ declare function codeBlock(lang: string, code: string): UiBlock;
|
|
|
121
144
|
* );
|
|
122
145
|
* ```
|
|
123
146
|
*/
|
|
124
|
-
declare function table(headers: readonly string[], rows: readonly (readonly string[])[]): UiBlock;
|
|
147
|
+
declare function table(headers: readonly string[], rows: readonly (readonly string[])[], meta?: UiBlockMeta): UiBlock;
|
|
125
148
|
/**
|
|
126
149
|
* Generate a Markdown bullet list UI block.
|
|
127
150
|
*
|
|
@@ -136,7 +159,7 @@ declare function table(headers: readonly string[], rows: readonly (readonly stri
|
|
|
136
159
|
* // → "- Deploy API server\n- Run database migrations\n- Verify health checks"
|
|
137
160
|
* ```
|
|
138
161
|
*/
|
|
139
|
-
declare function list(items: readonly string[]): UiBlock;
|
|
162
|
+
declare function list(items: readonly string[], meta?: UiBlockMeta): UiBlock;
|
|
140
163
|
/**
|
|
141
164
|
* Generate a fenced JSON code block UI block.
|
|
142
165
|
*
|
|
@@ -151,7 +174,7 @@ declare function list(items: readonly string[]): UiBlock;
|
|
|
151
174
|
* ui.json({ host: 'api.example.com', port: 3000, ssl: true });
|
|
152
175
|
* ```
|
|
153
176
|
*/
|
|
154
|
-
declare function json(data: unknown): UiBlock;
|
|
177
|
+
declare function json(data: unknown, meta?: UiBlockMeta): UiBlock;
|
|
155
178
|
/**
|
|
156
179
|
* Generate a summary UI block for collection overviews.
|
|
157
180
|
*
|
|
@@ -166,7 +189,7 @@ declare function json(data: unknown): UiBlock;
|
|
|
166
189
|
* ui.summary('3 invoices totaling $5,700.00. 2 paid, 1 pending.');
|
|
167
190
|
* ```
|
|
168
191
|
*/
|
|
169
|
-
declare function summary(text: string): UiBlock;
|
|
192
|
+
declare function summary(text: string, meta?: UiBlockMeta): UiBlock;
|
|
170
193
|
/**
|
|
171
194
|
* UI block helpers for Server-Side Rendering (SSR) in Presenters.
|
|
172
195
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/presenter/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/presenter/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3C,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAA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G;AACH,iBAAS,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAE1D;AAID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,EAAE;;;;;;;;;CAKL,CAAC"}
|
package/dist/presenter/ui.js
CHANGED
|
@@ -55,8 +55,8 @@ function fence(lang, body) {
|
|
|
55
55
|
* });
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
function echarts(config) {
|
|
59
|
-
return { type: 'echarts', content: fence('echarts', JSON.stringify(config, null, 2)) };
|
|
58
|
+
function echarts(config, meta) {
|
|
59
|
+
return { type: 'echarts', content: fence('echarts', JSON.stringify(config, null, 2)), ...(meta ? { meta } : {}) };
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Generate a Mermaid diagram UI block.
|
|
@@ -69,8 +69,8 @@ function echarts(config) {
|
|
|
69
69
|
* ui.mermaid('graph TD; A["Start"] --> B["Process"] --> C["End"]');
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
function mermaid(diagram) {
|
|
73
|
-
return { type: 'mermaid', content: fence('mermaid', diagram) };
|
|
72
|
+
function mermaid(diagram, meta) {
|
|
73
|
+
return { type: 'mermaid', content: fence('mermaid', diagram), ...(meta ? { meta } : {}) };
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Generate a raw Markdown UI block.
|
|
@@ -86,8 +86,8 @@ function mermaid(diagram) {
|
|
|
86
86
|
* ui.markdown('| Task | Status |\n|---|---|\n| Deploy | ✅ Done |');
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
function markdown(md) {
|
|
90
|
-
return { type: 'markdown', content: md };
|
|
89
|
+
function markdown(md, meta) {
|
|
90
|
+
return { type: 'markdown', content: md, ...(meta ? { meta } : {}) };
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* Generate a generic fenced code block UI block.
|
|
@@ -105,8 +105,8 @@ function markdown(md) {
|
|
|
105
105
|
* ui.codeBlock('xml', '<root><item>value</item></root>');
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
|
-
function codeBlock(lang, code) {
|
|
109
|
-
return { type: lang, content: fence(lang, code) };
|
|
108
|
+
function codeBlock(lang, code, meta) {
|
|
109
|
+
return { type: lang, content: fence(lang, code), ...(meta ? { meta } : {}) };
|
|
110
110
|
}
|
|
111
111
|
// ── DX Helpers ───────────────────────────────────────────
|
|
112
112
|
/**
|
|
@@ -131,11 +131,11 @@ function codeBlock(lang, code) {
|
|
|
131
131
|
* );
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
|
-
function table(headers, rows) {
|
|
134
|
+
function table(headers, rows, meta) {
|
|
135
135
|
const headerRow = `| ${headers.join(' | ')} |`;
|
|
136
136
|
const separator = `| ${headers.map(() => '---').join(' | ')} |`;
|
|
137
137
|
const bodyRows = rows.map(row => `| ${row.join(' | ')} |`).join('\n');
|
|
138
|
-
return { type: 'markdown', content: `${headerRow}\n${separator}\n${bodyRows}
|
|
138
|
+
return { type: 'markdown', content: `${headerRow}\n${separator}\n${bodyRows}`, ...(meta ? { meta } : {}) };
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Generate a Markdown bullet list UI block.
|
|
@@ -151,8 +151,8 @@ function table(headers, rows) {
|
|
|
151
151
|
* // → "- Deploy API server\n- Run database migrations\n- Verify health checks"
|
|
152
152
|
* ```
|
|
153
153
|
*/
|
|
154
|
-
function list(items) {
|
|
155
|
-
return { type: 'markdown', content: items.map(item => `- ${item}`).join('\n') };
|
|
154
|
+
function list(items, meta) {
|
|
155
|
+
return { type: 'markdown', content: items.map(item => `- ${item}`).join('\n'), ...(meta ? { meta } : {}) };
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Generate a fenced JSON code block UI block.
|
|
@@ -168,8 +168,8 @@ function list(items) {
|
|
|
168
168
|
* ui.json({ host: 'api.example.com', port: 3000, ssl: true });
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
|
-
function json(data) {
|
|
172
|
-
return { type: 'json', content: fence('json', JSON.stringify(data, null, 2)) };
|
|
171
|
+
function json(data, meta) {
|
|
172
|
+
return { type: 'json', content: fence('json', JSON.stringify(data, null, 2)), ...(meta ? { meta } : {}) };
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* Generate a summary UI block for collection overviews.
|
|
@@ -185,8 +185,8 @@ function json(data) {
|
|
|
185
185
|
* ui.summary('3 invoices totaling $5,700.00. 2 paid, 1 pending.');
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
188
|
-
function summary(text) {
|
|
189
|
-
return { type: 'summary', content: `📊 **Summary**: ${text}
|
|
188
|
+
function summary(text, meta) {
|
|
189
|
+
return { type: 'summary', content: `📊 **Summary**: ${text}`, ...(meta ? { meta } : {}) };
|
|
190
190
|
}
|
|
191
191
|
// ── Public Namespace ─────────────────────────────────────
|
|
192
192
|
/**
|
package/dist/presenter/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/presenter/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/presenter/ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAyCH,4DAA4D;AAE5D;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,IAAY,EAAE,IAAY;IACrC,OAAO,SAAS,IAAI,KAAK,IAAI,UAAU,CAAC;AAC5C,CAAC;AAED,4DAA4D;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,OAAO,CAAC,MAA+B,EAAE,IAAkB;IAChE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAA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AAE,GAAG,IAAI;IAMrD;;;;;OAKG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;IAQ7B;;;;;;;;;;;;;;;;;;;;;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;;;;;uBAQihK,CAAC;oBAA+B,CAAC;;;IAJvkK,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;CAG9E"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResourceBuilder — Fluent Builder for MCP Resources
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent API for defining MCP Resources that expose
|
|
5
|
+
* data to LLMs. Resources can optionally be subscribable, enabling
|
|
6
|
+
* push notifications when data changes.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { defineResource } from '@vurb/core';
|
|
11
|
+
*
|
|
12
|
+
* const stockPrice = defineResource<AppContext>('stock_price', {
|
|
13
|
+
* uri: 'stock://prices/{symbol}',
|
|
14
|
+
* mimeType: 'application/json',
|
|
15
|
+
* description: 'Real-time stock price for a given symbol',
|
|
16
|
+
* subscribable: true,
|
|
17
|
+
* handler: async (uri, ctx) => {
|
|
18
|
+
* const symbol = uri.match(/stock:\/\/prices\/(.+)/)?.[1];
|
|
19
|
+
* const price = await ctx.stockApi.getPrice(symbol);
|
|
20
|
+
* return { text: JSON.stringify(price) };
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see {@link ResourceRegistry} for registration and routing
|
|
26
|
+
* @see {@link SubscriptionManager} for subscription tracking
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Content returned by a resource read handler.
|
|
32
|
+
*
|
|
33
|
+
* Mirrors the MCP `ReadResourceResult.contents[0]` shape.
|
|
34
|
+
*/
|
|
35
|
+
export interface ResourceContent {
|
|
36
|
+
/** Textual content of the resource (UTF-8) */
|
|
37
|
+
readonly text?: string;
|
|
38
|
+
/** Base64-encoded binary content (mutually exclusive with `text`) */
|
|
39
|
+
readonly blob?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Handler function invoked when a client reads a resource.
|
|
43
|
+
*
|
|
44
|
+
* @param uri - The fully resolved URI requested by the client
|
|
45
|
+
* @param ctx - Application context (from contextFactory)
|
|
46
|
+
* @returns The resource content
|
|
47
|
+
*/
|
|
48
|
+
export type ResourceHandler<TContext> = (uri: string, ctx: TContext) => ResourceContent | Promise<ResourceContent>;
|
|
49
|
+
/**
|
|
50
|
+
* Configuration for defining a resource.
|
|
51
|
+
*/
|
|
52
|
+
export interface ResourceConfig<TContext> {
|
|
53
|
+
/** URI or URI template (with `{placeholders}`) identifying this resource */
|
|
54
|
+
readonly uri: string;
|
|
55
|
+
/** Human-readable description shown to AI agents */
|
|
56
|
+
readonly description?: string;
|
|
57
|
+
/** MIME type of the resource content */
|
|
58
|
+
readonly mimeType?: string;
|
|
59
|
+
/** Optional tags for filtering */
|
|
60
|
+
readonly tags?: string[];
|
|
61
|
+
/** Whether AI agents can subscribe to push notifications for this resource */
|
|
62
|
+
readonly subscribable?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* MCP resource annotations for audience, priority, and freshness.
|
|
65
|
+
*
|
|
66
|
+
* @see https://spec.modelcontextprotocol.io/2025-03-26/server/resources/#resource-annotations
|
|
67
|
+
*/
|
|
68
|
+
readonly annotations?: {
|
|
69
|
+
readonly audience?: Array<'user' | 'assistant'>;
|
|
70
|
+
readonly priority?: number;
|
|
71
|
+
};
|
|
72
|
+
/** Handler called when a client reads this resource */
|
|
73
|
+
readonly handler: ResourceHandler<TContext>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Compiled resource definition for MCP `resources/list`.
|
|
77
|
+
*/
|
|
78
|
+
export interface McpResourceDef {
|
|
79
|
+
readonly uri: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly description?: string;
|
|
82
|
+
readonly mimeType?: string;
|
|
83
|
+
readonly annotations?: {
|
|
84
|
+
readonly audience?: Array<'user' | 'assistant'>;
|
|
85
|
+
readonly priority?: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Public interface for a resource builder.
|
|
90
|
+
*
|
|
91
|
+
* Consumed by {@link ResourceRegistry} for registration and routing.
|
|
92
|
+
*/
|
|
93
|
+
export interface ResourceBuilder<TContext = void> {
|
|
94
|
+
/** Get the resource name (unique identifier) */
|
|
95
|
+
getName(): string;
|
|
96
|
+
/** Get the URI or URI template */
|
|
97
|
+
getUri(): string;
|
|
98
|
+
/** Get optional tags for filtering */
|
|
99
|
+
getTags(): string[];
|
|
100
|
+
/** Whether this resource supports subscriptions */
|
|
101
|
+
isSubscribable(): boolean;
|
|
102
|
+
/** Build the MCP resource definition for `resources/list` */
|
|
103
|
+
buildResourceDefinition(): McpResourceDef;
|
|
104
|
+
/** Read the resource content for a given URI */
|
|
105
|
+
read(uri: string, ctx: TContext): Promise<ResourceContent>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Define a new MCP Resource.
|
|
109
|
+
*
|
|
110
|
+
* @param name - Unique resource name (used as identifier)
|
|
111
|
+
* @param config - Resource configuration
|
|
112
|
+
* @returns A resource builder for registration in {@link ResourceRegistry}
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const deployStatus = defineResource<AppContext>('deploy_status', {
|
|
117
|
+
* uri: 'deploy://status/{environment}',
|
|
118
|
+
* description: 'Real-time deploy pipeline status',
|
|
119
|
+
* subscribable: true,
|
|
120
|
+
* handler: async (uri, ctx) => {
|
|
121
|
+
* const env = uri.match(/deploy:\/\/status\/(.+)/)?.[1];
|
|
122
|
+
* const status = await ctx.deployService.getStatus(env);
|
|
123
|
+
* return { text: JSON.stringify(status) };
|
|
124
|
+
* },
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function defineResource<TContext = void>(name: string, config: ResourceConfig<TContext>): ResourceBuilder<TContext>;
|
|
129
|
+
//# sourceMappingURL=ResourceBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceBuilder.d.ts","sourceRoot":"","sources":["../../src/resource/ResourceBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE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AQ,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACL;AAID;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,GAAG,IAAI;IAC5C,gDAAgD;IAChD,OAAO,IAAI,MAAM,CAAC;IAClB,kCAAkC;IAClC,MAAM,IAAI,MAAM,CAAC;IACjB,sCAAsC;IACtC,OAAO,IAAI,MAAM,EAAE,CAAC;IACpB,mDAAmD;IACnD,cAAc,IAAI,OAAO,CAAC;IAC1B,6DAA6D;IAC7D,uBAAuB,IAAI,cAAc,CAAC;IAC1C,gDAAgD;IAChD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9D;AAgDD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,QAAQ,GAAG,IAAI,EAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GACjC,eAAe,CAAC,QAAQ,CAAC,CAE3B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResourceBuilder — Fluent Builder for MCP Resources
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent API for defining MCP Resources that expose
|
|
5
|
+
* data to LLMs. Resources can optionally be subscribable, enabling
|
|
6
|
+
* push notifications when data changes.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { defineResource } from '@vurb/core';
|
|
11
|
+
*
|
|
12
|
+
* const stockPrice = defineResource<AppContext>('stock_price', {
|
|
13
|
+
* uri: 'stock://prices/{symbol}',
|
|
14
|
+
* mimeType: 'application/json',
|
|
15
|
+
* description: 'Real-time stock price for a given symbol',
|
|
16
|
+
* subscribable: true,
|
|
17
|
+
* handler: async (uri, ctx) => {
|
|
18
|
+
* const symbol = uri.match(/stock:\/\/prices\/(.+)/)?.[1];
|
|
19
|
+
* const price = await ctx.stockApi.getPrice(symbol);
|
|
20
|
+
* return { text: JSON.stringify(price) };
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see {@link ResourceRegistry} for registration and routing
|
|
26
|
+
* @see {@link SubscriptionManager} for subscription tracking
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
// ── Implementation ───────────────────────────────────────
|
|
31
|
+
class ResourceBuilderImpl {
|
|
32
|
+
_name;
|
|
33
|
+
_uri;
|
|
34
|
+
_description;
|
|
35
|
+
_mimeType;
|
|
36
|
+
_tags;
|
|
37
|
+
_subscribable;
|
|
38
|
+
_annotations;
|
|
39
|
+
_handler;
|
|
40
|
+
constructor(name, config) {
|
|
41
|
+
this._name = name;
|
|
42
|
+
this._uri = config.uri;
|
|
43
|
+
this._description = config.description;
|
|
44
|
+
this._mimeType = config.mimeType ?? 'application/json';
|
|
45
|
+
this._tags = config.tags ?? [];
|
|
46
|
+
this._subscribable = config.subscribable ?? false;
|
|
47
|
+
this._annotations = config.annotations;
|
|
48
|
+
this._handler = config.handler;
|
|
49
|
+
}
|
|
50
|
+
getName() { return this._name; }
|
|
51
|
+
getUri() { return this._uri; }
|
|
52
|
+
getTags() { return this._tags; }
|
|
53
|
+
isSubscribable() { return this._subscribable; }
|
|
54
|
+
buildResourceDefinition() {
|
|
55
|
+
const def = {
|
|
56
|
+
uri: this._uri,
|
|
57
|
+
name: this._name,
|
|
58
|
+
...(this._description ? { description: this._description } : {}),
|
|
59
|
+
...(this._mimeType ? { mimeType: this._mimeType } : {}),
|
|
60
|
+
...(this._annotations ? { annotations: this._annotations } : {}),
|
|
61
|
+
};
|
|
62
|
+
return def;
|
|
63
|
+
}
|
|
64
|
+
async read(uri, ctx) {
|
|
65
|
+
return this._handler(uri, ctx);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// ── Factory ──────────────────────────────────────────────
|
|
69
|
+
/**
|
|
70
|
+
* Define a new MCP Resource.
|
|
71
|
+
*
|
|
72
|
+
* @param name - Unique resource name (used as identifier)
|
|
73
|
+
* @param config - Resource configuration
|
|
74
|
+
* @returns A resource builder for registration in {@link ResourceRegistry}
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const deployStatus = defineResource<AppContext>('deploy_status', {
|
|
79
|
+
* uri: 'deploy://status/{environment}',
|
|
80
|
+
* description: 'Real-time deploy pipeline status',
|
|
81
|
+
* subscribable: true,
|
|
82
|
+
* handler: async (uri, ctx) => {
|
|
83
|
+
* const env = uri.match(/deploy:\/\/status\/(.+)/)?.[1];
|
|
84
|
+
* const status = await ctx.deployService.getStatus(env);
|
|
85
|
+
* return { text: JSON.stringify(status) };
|
|
86
|
+
* },
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export function defineResource(name, config) {
|
|
91
|
+
return new ResourceBuilderImpl(name, config);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ResourceBuilder.js.map
|