@vurb/core 3.2.0 → 3.2.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 +677 -677
- package/dist/cli/constants.js +58 -58
- package/dist/cli/templates/config.js +26 -26
- package/dist/cli/templates/core.js +168 -168
- package/dist/cli/templates/middleware.js +25 -25
- package/dist/cli/templates/presenter.js +1 -1
- package/dist/cli/templates/presenter.js.map +1 -1
- package/dist/cli/templates/prompt.js +1 -1
- package/dist/cli/templates/prompt.js.map +1 -1
- 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/cli/templates/vectors/workflow.js +1 -1
- package/dist/cli/templates/vectors/workflow.js.map +1 -1
- package/dist/client/createTypedRegistry.js +1 -1
- package/dist/converters/ConverterBase.d.ts +1 -1
- package/dist/converters/ConverterBase.js +1 -1
- package/dist/core/StandardSchema.d.ts +1 -1
- package/dist/core/StandardSchema.js +1 -1
- package/dist/core/builder/GroupedToolBuilder.d.ts +2 -2
- package/dist/core/builder/GroupedToolBuilder.js +2 -2
- package/dist/core/builder/defineTool.d.ts +1 -1
- package/dist/core/builder/defineTool.js +1 -1
- package/dist/core/createGroup.d.ts +1 -1
- package/dist/core/createGroup.js +1 -1
- package/dist/core/initVurb.d.ts +1 -1
- package/dist/core/initVurb.js +1 -1
- package/dist/core/registry/ToolRegistry.d.ts +1 -1
- package/dist/core/registry/ToolRegistry.js +1 -1
- package/dist/core/response.d.ts +1 -1
- package/dist/core/response.js +1 -1
- package/dist/core/result.d.ts +1 -1
- package/dist/core/result.js +1 -1
- package/dist/domain/Annotations.d.ts +1 -1
- package/dist/domain/Icon.d.ts +1 -1
- package/dist/domain/Prompt.d.ts +1 -1
- package/dist/domain/Prompt.js +1 -1
- package/dist/domain/PromptArgument.d.ts +1 -1
- package/dist/domain/PromptArgument.js +1 -1
- package/dist/domain/Resource.d.ts +1 -1
- package/dist/domain/Resource.js +1 -1
- package/dist/domain/Role.d.ts +1 -1
- package/dist/domain/Role.js +1 -1
- package/dist/domain/Tool.d.ts +1 -1
- package/dist/domain/Tool.js +1 -1
- package/dist/domain/ToolAnnotations.d.ts +1 -1
- package/dist/fsm/StateMachineGate.d.ts +1 -1
- package/dist/fsm/StateMachineGate.js +1 -1
- package/dist/introspection/GovernanceObserver.d.ts +1 -1
- package/dist/introspection/GovernanceObserver.js +1 -1
- package/dist/introspection/SemanticProbe.js +49 -49
- package/dist/observability/DebugObserver.d.ts +1 -1
- package/dist/observability/DebugObserver.js +1 -1
- package/dist/presenter/Presenter.d.ts +4 -4
- package/dist/presenter/Presenter.js +3 -3
- package/dist/presenter/ResponseBuilder.d.ts +2 -2
- package/dist/presenter/ResponseBuilder.js +2 -2
- package/dist/presenter/definePresenter.d.ts +1 -1
- package/dist/presenter/definePresenter.js +1 -1
- package/dist/presenter/suggest.d.ts +1 -1
- package/dist/presenter/suggest.js +1 -1
- package/dist/presenter/typeHelpers.d.ts +1 -1
- package/dist/presenter/typeHelpers.js +1 -1
- package/dist/presenter/ui.d.ts +2 -2
- package/dist/presenter/ui.js +2 -2
- package/dist/prompt/FluentPromptBuilder.d.ts.map +1 -1
- package/dist/prompt/PromptMessage.d.ts +2 -2
- package/dist/prompt/PromptMessage.js +2 -2
- package/dist/prompt/PromptRegistry.d.ts +1 -1
- package/dist/prompt/PromptRegistry.js +1 -1
- package/dist/server/DevServer.d.ts +1 -1
- package/dist/server/DevServer.js +1 -1
- package/dist/server/autoDiscover.js +1 -1
- package/dist/server/startServer.d.ts +1 -1
- package/dist/server/startServer.js +1 -1
- package/dist/testing/MvaMetaSymbol.d.ts +1 -1
- package/dist/testing/MvaMetaSymbol.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,677 +1,677 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/86ae1b28-a938-4e12-af29-bfc60a55dbe8" >
|
|
5
|
-
<img src="https://github.com/user-attachments/assets/86ae1b28-a938-4e12-af29-bfc60a55dbe8" style="border-radius:8px;background:#000000;padding:10px;border:1px solid #414141;" alt="Vurb.ts">
|
|
6
|
-
</picture>
|
|
7
|
-
|
|
8
|
-
**The MVA framework for production MCP servers.**<br>
|
|
9
|
-
Structured perception for AI agents. Zero hallucination. Zero data leaks.
|
|
10
|
-
|
|
11
|
-
[](https://www.typescriptlang.org/)
|
|
14
|
-
[](https://modelcontextprotocol.io/)
|
|
15
|
-
[](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
|
|
16
|
-
|
|
17
|
-
[Documentation](https://vurb.vinkius.com/) · [Quick Start](https://vurb.vinkius.com/quickstart-lightspeed) · [API Reference](https://vurb.vinkius.com/api/)
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Get Started in 5 Seconds
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
|
|
27
|
-
cd my-server && vurb dev
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
That's it. A production-ready MCP server with file-based routing, Presenters, middleware, tests, and pre-configured connections for **Cursor**, **Claude Desktop**, **Claude Code**, **Windsurf**, **Cline**, and **VS Code + GitHub Copilot**.
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
Project name? › my-server
|
|
34
|
-
Transport? › stdio
|
|
35
|
-
Vector? › vanilla
|
|
36
|
-
|
|
37
|
-
● Scaffolding project — 14 files (6ms)
|
|
38
|
-
● Installing dependencies...
|
|
39
|
-
✔ Done — vurb dev to start
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Choose a vector to scaffold exactly the project you need:
|
|
43
|
-
|
|
44
|
-
| Vector | What it scaffolds |
|
|
45
|
-
|---|---|
|
|
46
|
-
| `vanilla` | `autoDiscover()` file-based routing. Zero external deps |
|
|
47
|
-
| `prisma` | Prisma schema + CRUD tools with field-level security |
|
|
48
|
-
| `n8n` | n8n workflow bridge — auto-discover webhooks as tools |
|
|
49
|
-
| `openapi` | OpenAPI 3.x / Swagger 2.0 → full MVA tool generation |
|
|
50
|
-
| `oauth` | RFC 8628 Device Flow authentication |
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Database-driven server with Presenter egress firewall
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# Bridge your n8n workflows to any MCP client
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# REST API → MCP in one command
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Drop a file in `src/tools/`, restart — it's a live MCP tool. No central import file, no merge conflicts:
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
src/tools/
|
|
67
|
-
├── billing/
|
|
68
|
-
│ ├── get_invoice.ts → billing.get_invoice
|
|
69
|
-
│ └── pay.ts → billing.pay
|
|
70
|
-
├── users/
|
|
71
|
-
│ ├── list.ts → users.list
|
|
72
|
-
│ └── ban.ts → users.ban
|
|
73
|
-
└── system/
|
|
74
|
-
└── health.ts → system.health
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Why Vurb.ts Exists
|
|
80
|
-
|
|
81
|
-
Every raw MCP server does the same thing: `JSON.stringify()` the database result and ship it to the LLM. Three catastrophic consequences:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
// What every MCP tutorial teaches
|
|
85
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
86
|
-
const { name, arguments: args } = request.params;
|
|
87
|
-
if (name === 'get_invoice') {
|
|
88
|
-
const invoice = await db.invoices.findUnique(args.id);
|
|
89
|
-
return { content: [{ type: 'text', text: JSON.stringify(invoice) }] };
|
|
90
|
-
// AI receives: { password_hash, internal_margin, customer_ssn, ... }
|
|
91
|
-
}
|
|
92
|
-
// ...50 more if/else branches
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Data exfiltration.** `JSON.stringify(invoice)` sends `password_hash`, `internal_margin`, `customer_ssn` — every column — straight to the LLM provider. One field = one GDPR violation.
|
|
97
|
-
|
|
98
|
-
**Token explosion.** Every tool schema is sent on every turn, even when irrelevant. System prompt rules for every domain entity are sent globally, bloating context with wasted tokens.
|
|
99
|
-
|
|
100
|
-
**Context DDoS.** An unbounded `findMany()` can dump thousands of rows into the context window. The LLM hallucinates. Your API bill explodes.
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## The MVA Solution
|
|
105
|
-
|
|
106
|
-
Vurb.ts replaces `JSON.stringify()` with a **Presenter** — a deterministic perception layer that controls exactly what the agent sees, knows, and can do next.
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
Handler (Model) Presenter (View) Agent (LLM)
|
|
110
|
-
─────────────── ──────────────── ───────────
|
|
111
|
-
Raw DB data → Zod-validated schema → Structured
|
|
112
|
-
{ amount_cents, + System rules perception
|
|
113
|
-
password_hash, + UI blocks (charts) package
|
|
114
|
-
internal_margin, + Suggested next actions
|
|
115
|
-
ssn, ... } + PII redaction
|
|
116
|
-
+ Cognitive guardrails
|
|
117
|
-
- password_hash ← STRIPPED
|
|
118
|
-
- internal_margin ← STRIPPED
|
|
119
|
-
- ssn ← REDACTED
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
The result is not JSON — it's a **Perception Package**:
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
Block 1 — DATA: {"id":"INV-001","amount_cents":45000,"status":"pending"}
|
|
126
|
-
Block 2 — UI: [ECharts gauge chart config]
|
|
127
|
-
Block 3 — RULES: "amount_cents is in CENTS. Divide by 100 for display."
|
|
128
|
-
Block 4 — ACTIONS: → billing.pay: "Invoice is pending — process payment"
|
|
129
|
-
Block 5 — EMBEDS: [Client Presenter + LineItem Presenter composed]
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
No guessing. Undeclared fields rejected. Domain rules travel with data — not in the system prompt. Next actions computed from data state.
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Before vs. After
|
|
137
|
-
|
|
138
|
-
**Before** — raw MCP:
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
case 'get_invoice':
|
|
142
|
-
const invoice = await db.invoices.findUnique(args.id);
|
|
143
|
-
return { content: [{ type: 'text', text: JSON.stringify(invoice) }] };
|
|
144
|
-
// Leaks internal columns. No rules. No guidance.
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**After** — Vurb.ts with MVA:
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
import { createPresenter, suggest, ui, t } from '@vurb/core';
|
|
151
|
-
|
|
152
|
-
const InvoicePresenter = createPresenter('Invoice')
|
|
153
|
-
.schema({
|
|
154
|
-
id: t.string,
|
|
155
|
-
amount_cents: t.number.describe('Amount in cents — divide by 100'),
|
|
156
|
-
status: t.enum('paid', 'pending', 'overdue'),
|
|
157
|
-
})
|
|
158
|
-
.rules(['CRITICAL: amount_cents is in CENTS. Divide by 100 for display.'])
|
|
159
|
-
.redactPII(['*.customer_ssn', '*.credit_card'])
|
|
160
|
-
.ui((inv) => [
|
|
161
|
-
ui.echarts({
|
|
162
|
-
series: [{ type: 'gauge', data: [{ value: inv.amount_cents / 100 }] }],
|
|
163
|
-
}),
|
|
164
|
-
])
|
|
165
|
-
.suggest((inv) =>
|
|
166
|
-
inv.status === 'pending'
|
|
167
|
-
? [suggest('billing.pay', 'Invoice pending — process payment')]
|
|
168
|
-
: [suggest('billing.archive', 'Invoice settled — archive it')]
|
|
169
|
-
)
|
|
170
|
-
.embed('client', ClientPresenter)
|
|
171
|
-
.embed('line_items', LineItemPresenter)
|
|
172
|
-
.limit(50);
|
|
173
|
-
|
|
174
|
-
export default f.query('billing.get_invoice')
|
|
175
|
-
.describe('Get an invoice by ID')
|
|
176
|
-
.withString('id', 'Invoice ID')
|
|
177
|
-
.returns(InvoicePresenter)
|
|
178
|
-
.handle(async (input, ctx) => ctx.db.invoices.findUnique({
|
|
179
|
-
where: { id: input.id },
|
|
180
|
-
include: { client: true, line_items: true },
|
|
181
|
-
}));
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
The handler returns raw data. The Presenter shapes absolutely everything the agent perceives.
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Architecture
|
|
189
|
-
|
|
190
|
-
### Egress Firewall — Schema as Security Boundary
|
|
191
|
-
|
|
192
|
-
The Presenter's Zod schema acts as a whitelist. **Only declared fields pass through.** A database migration that adds `customer_ssn` doesn't change what the agent sees — the new column is invisible unless you explicitly declare it in the schema.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
const UserPresenter = createPresenter('User')
|
|
196
|
-
.schema({ id: t.string, name: t.string, email: t.string });
|
|
197
|
-
// password_hash, tenant_id, internal_flags → STRIPPED at RAM level
|
|
198
|
-
// A developer CANNOT accidentally expose a new column
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### DLP Compliance Engine — PII Redaction
|
|
202
|
-
|
|
203
|
-
GDPR / LGPD / HIPAA compliance built into the framework. `.redactPII()` compiles a V8-optimized redaction function via `fast-redact` that masks sensitive fields **after** UI blocks and rules have been computed (Late Guillotine Pattern) — the LLM receives `[REDACTED]` instead of real values.
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
const PatientPresenter = createPresenter('Patient')
|
|
207
|
-
.schema({ name: t.string, ssn: t.string, diagnosis: t.string })
|
|
208
|
-
.redactPII(['ssn', 'diagnosis'])
|
|
209
|
-
.ui((patient) => [
|
|
210
|
-
ui.markdown(`**Patient:** ${patient.name}`),
|
|
211
|
-
// patient.ssn available for UI logic — but LLM sees [REDACTED]
|
|
212
|
-
]);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
Custom censors, wildcard paths (`'*.email'`, `'patients[*].diagnosis'`), and centralized PII field lists. **Zero-leak guarantee** — the developer cannot accidentally bypass redaction.
|
|
216
|
-
|
|
217
|
-
### 8 Anti-Hallucination Mechanisms
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
① Action Consolidation → groups operations behind fewer tools → ↓ tokens
|
|
221
|
-
② TOON Encoding → pipe-delimited compact descriptions → ↓ tokens
|
|
222
|
-
③ Zod .strict() → rejects hallucinated params at build → ↓ retries
|
|
223
|
-
④ Self-Healing Errors → directed correction prompts → ↓ retries
|
|
224
|
-
⑤ Cognitive Guardrails → .limit() truncates before LLM sees it → ↓ tokens
|
|
225
|
-
⑥ Agentic Affordances → HATEOAS next-action hints from data → ↓ retries
|
|
226
|
-
⑦ JIT Context Rules → rules travel with data, not globally → ↓ tokens
|
|
227
|
-
⑧ State Sync → RFC 7234 cache-control for agents → ↓ requests
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Each mechanism compounds. Fewer tokens in context, fewer requests per task, less hallucination, lower cost.
|
|
231
|
-
|
|
232
|
-
### FSM State Gate — Temporal Anti-Hallucination
|
|
233
|
-
|
|
234
|
-
**The first framework where it is physically impossible for an AI to execute tools out of order.**
|
|
235
|
-
|
|
236
|
-
LLMs are chaotic — even with HATEOAS suggestions, a model can ignore them and call `cart.pay` with an empty cart. The FSM State Gate makes temporal hallucination structurally impossible: if the workflow state is `empty`, the `cart.pay` tool **doesn't exist** in `tools/list`. The LLM literally cannot call it.
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
const gate = f.fsm({
|
|
240
|
-
id: 'checkout',
|
|
241
|
-
initial: 'empty',
|
|
242
|
-
states: {
|
|
243
|
-
empty: { on: { ADD_ITEM: 'has_items' } },
|
|
244
|
-
has_items: { on: { CHECKOUT: 'payment', CLEAR: 'empty' } },
|
|
245
|
-
payment: { on: { PAY: 'confirmed', CANCEL: 'has_items' } },
|
|
246
|
-
confirmed: { type: 'final' },
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const pay = f.mutation('cart.pay')
|
|
251
|
-
.describe('Process payment')
|
|
252
|
-
.bindState('payment', 'PAY') // Visible ONLY in 'payment' state
|
|
253
|
-
.handle(async (input, ctx) => ctx.db.payments.process(input.method));
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
| State | Visible Tools |
|
|
257
|
-
|---|---|
|
|
258
|
-
| `empty` | `cart.add_item`, `cart.view` |
|
|
259
|
-
| `has_items` | `cart.add_item`, `cart.checkout`, `cart.view` |
|
|
260
|
-
| `payment` | `cart.pay`, `cart.view` |
|
|
261
|
-
| `confirmed` | `cart.view` |
|
|
262
|
-
|
|
263
|
-
Three complementary layers: **Format** (Zod validates shape), **Guidance** (HATEOAS suggests the next tool), **Gate** (FSM physically removes wrong tools). XState v5 powered, serverless-ready with `fsmStore`.
|
|
264
|
-
|
|
265
|
-
### Zero-Trust Sandbox — Computation Delegation
|
|
266
|
-
|
|
267
|
-
The LLM sends JavaScript logic to your data instead of shipping data to the LLM. Code runs inside a sealed V8 isolate — **zero access** to `process`, `require`, `fs`, `net`, `fetch`, `Buffer`. Timeout kill, memory cap, output limit, automatic isolate recovery, and AbortSignal kill-switch (Connection Watchdog).
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
export default f.query('analytics.compute')
|
|
271
|
-
.describe('Run a computation on server-side data')
|
|
272
|
-
.sandboxed({ timeout: 3000, memoryLimit: 64 })
|
|
273
|
-
.handle(async (input, ctx) => {
|
|
274
|
-
const data = await ctx.db.records.findMany();
|
|
275
|
-
const engine = f.sandbox({ timeout: 3000, memoryLimit: 64 });
|
|
276
|
-
try {
|
|
277
|
-
const result = await engine.execute(input.expression, data);
|
|
278
|
-
if (!result.ok) return f.error('VALIDATION_ERROR', result.error)
|
|
279
|
-
.suggest('Fix the JavaScript expression and retry.');
|
|
280
|
-
return result.value;
|
|
281
|
-
} finally { engine.dispose(); }
|
|
282
|
-
});
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
`.sandboxed()` auto-injects HATEOAS instructions into the tool description — the LLM knows exactly how to format its code. Prototype pollution contained. `constructor.constructor` escape blocked. One isolate per engine, new pristine context per call.
|
|
286
|
-
|
|
287
|
-
### State Sync — Temporal Awareness for Agents
|
|
288
|
-
|
|
289
|
-
LLMs have no sense of time. After `sprints.list` then `sprints.create`, the agent still believes the list is unchanged. Vurb.ts injects RFC 7234-inspired cache-control signals:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
const listSprints = f.query('sprints.list')
|
|
293
|
-
.stale() // no-store — always re-fetch
|
|
294
|
-
.handle(async (input, ctx) => ctx.db.sprints.findMany());
|
|
295
|
-
|
|
296
|
-
const createSprint = f.action('sprints.create')
|
|
297
|
-
.invalidates('sprints.*', 'tasks.*') // causal cross-domain invalidation
|
|
298
|
-
.withString('name', 'Sprint name')
|
|
299
|
-
.handle(async (input, ctx) => ctx.db.sprints.create(input));
|
|
300
|
-
// After mutation: [System: Cache invalidated for sprints.*, tasks.* — caused by sprints.create]
|
|
301
|
-
// Failed mutations emit nothing — state didn't change.
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Registry-level policies with `f.stateSync()`, glob patterns (`*`, `**`), policy overlap detection, observability hooks, and MCP `notifications/resources/updated` emission.
|
|
305
|
-
|
|
306
|
-
### Prompt Engine — Server-Side Templates
|
|
307
|
-
|
|
308
|
-
MCP Prompts as executable server-side templates with the same Fluent API as tools. Middleware, hydration timeout, schema-informed coercion, interceptors, multi-modal messages, and the Presenter bridge:
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
const IncidentAnalysis = f.prompt('incident_analysis')
|
|
312
|
-
.title('Incident Analysis')
|
|
313
|
-
.describe('Structured analysis of a production incident')
|
|
314
|
-
.tags('engineering', 'ops')
|
|
315
|
-
.input({
|
|
316
|
-
incident_id: { type: 'string', description: 'Incident ticket ID' },
|
|
317
|
-
severity: { enum: ['sev1', 'sev2', 'sev3'] as const },
|
|
318
|
-
})
|
|
319
|
-
.use(requireAuth, requireRole('engineer'))
|
|
320
|
-
.timeout(10_000)
|
|
321
|
-
.handler(async (ctx, { incident_id, severity }) => {
|
|
322
|
-
const incident = await ctx.db.incidents.findUnique({ where: { id: incident_id } });
|
|
323
|
-
return {
|
|
324
|
-
messages: [
|
|
325
|
-
PromptMessage.system(`You are a Senior SRE. Severity: ${severity.toUpperCase()}.`),
|
|
326
|
-
...PromptMessage.fromView(IncidentPresenter.make(incident, ctx)),
|
|
327
|
-
PromptMessage.user('Begin root cause analysis.'),
|
|
328
|
-
],
|
|
329
|
-
};
|
|
330
|
-
});
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
`PromptMessage.fromView()` decomposes any Presenter into prompt messages — same schema, same rules, same affordances in both tools and prompts. Multi-modal with `.image()`, `.audio()`, `.resource()`. Interceptors inject compliance footers after every handler. `PromptRegistry` with filtering, pagination, and lifecycle sync.
|
|
334
|
-
|
|
335
|
-
### Agent Skills — Progressive Instruction Distribution
|
|
336
|
-
|
|
337
|
-
**No other MCP framework has this.** Distribute domain expertise to AI agents on demand via MCP. Three-layer progressive disclosure — the agent searches a lightweight index, loads only the relevant SKILL.md, and reads auxiliary files on demand. Zero context window waste.
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
import { SkillRegistry, autoDiscoverSkills, createSkillTools } from '@vurb/skills';
|
|
341
|
-
|
|
342
|
-
const skills = new SkillRegistry();
|
|
343
|
-
await autoDiscoverSkills(skills, './skills');
|
|
344
|
-
const [search, load, readFile] = createSkillTools(f, skills);
|
|
345
|
-
registry.registerAll(search, load, readFile);
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
Skills follow the [agentskills.io](https://agentskills.io) open standard — SKILL.md with YAML frontmatter. `skills.search` returns the lightweight index. `skills.load` returns full instructions. `skills.read_file` gives access to auxiliary files with **path traversal protection** (only files within the skill's directory). Custom search engines supported.
|
|
349
|
-
|
|
350
|
-
```
|
|
351
|
-
skills/
|
|
352
|
-
├── deployment/
|
|
353
|
-
│ ├── SKILL.md # name, description, full instructions
|
|
354
|
-
│ └── scripts/
|
|
355
|
-
│ └── deploy.sh # accessible via skills.read_file
|
|
356
|
-
└── database-migration/
|
|
357
|
-
└── SKILL.md
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
### Fluent API — Semantic Verbs & Chainable Builders
|
|
361
|
-
|
|
362
|
-
```typescript
|
|
363
|
-
f.query('users.list') // readOnly: true — no side effects
|
|
364
|
-
f.action('users.create') // neutral — creates or updates
|
|
365
|
-
f.mutation('users.delete') // destructive: true — triggers confirmation dialogs
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
Every builder method is chainable and fully typed. Types accumulate as you chain — the final `.handle()` has 100% accurate autocomplete with zero annotations:
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
export const deploy = f.mutation('infra.deploy')
|
|
372
|
-
.describe('Deploy infrastructure')
|
|
373
|
-
.instructions('Use ONLY after the user explicitly requests deployment.')
|
|
374
|
-
.withEnum('env', ['staging', 'production'] as const, 'Target environment')
|
|
375
|
-
.concurrency({ max: 2, queueSize: 5 })
|
|
376
|
-
.egress(1_000_000)
|
|
377
|
-
.idempotent()
|
|
378
|
-
.invalidates('infra.*')
|
|
379
|
-
.returns(DeployPresenter)
|
|
380
|
-
.handle(async function* (input, ctx) {
|
|
381
|
-
yield progress(10, 'Cloning repository...');
|
|
382
|
-
await cloneRepo(ctx.repoUrl);
|
|
383
|
-
yield progress(90, 'Running tests...');
|
|
384
|
-
const results = await runTests();
|
|
385
|
-
yield progress(100, 'Done!');
|
|
386
|
-
return results;
|
|
387
|
-
});
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
`.instructions()` embeds prompt engineering. `.concurrency()` prevents backend overload. `.egress()` caps response size. `yield progress()` streams MCP progress notifications. `.cached()` / `.stale()` / `.invalidates()` control temporal awareness. `.sandboxed()` enables computation delegation. `.bindState()` enables FSM gating.
|
|
391
|
-
|
|
392
|
-
### Middleware — Pre-Compiled, Zero-Allocation
|
|
393
|
-
|
|
394
|
-
tRPC-style context derivation. Middleware chains compiled at registration time into a single nested function — O(1) dispatch, no array iteration, no per-request allocation:
|
|
395
|
-
|
|
396
|
-
```typescript
|
|
397
|
-
const requireAuth = f.middleware(async (ctx) => {
|
|
398
|
-
const user = await db.getUser(ctx.token);
|
|
399
|
-
if (!user) throw new Error('Unauthorized');
|
|
400
|
-
return { user, permissions: user.permissions };
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// ctx.user and ctx.permissions — fully typed downstream. Zero annotations.
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
Stack `.use()` calls for layered derivations: auth → permissions → tenant resolution → audit logging. Same `MiddlewareFn` signature works for both tools and prompts.
|
|
407
|
-
|
|
408
|
-
### Fluent Router — Grouped Tooling
|
|
409
|
-
|
|
410
|
-
```typescript
|
|
411
|
-
const users = f.router('users')
|
|
412
|
-
.describe('User management')
|
|
413
|
-
.use(requireAuth)
|
|
414
|
-
.tags('core');
|
|
415
|
-
|
|
416
|
-
export const listUsers = users.query('list').describe('List users').handle(/* ... */);
|
|
417
|
-
export const banUser = users.mutation('ban').describe('Ban a user').handle(/* ... */);
|
|
418
|
-
// Middleware, tags, prefix — all inherited automatically
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
Discriminator enum compilation. Per-field annotations tell the LLM which parameters belong to which action. Tool exposition: `flat` (independent MCP tools) or `grouped` (one tool with enum discriminator).
|
|
422
|
-
|
|
423
|
-
### tRPC-Style Client — Compile-Time Route Validation
|
|
424
|
-
|
|
425
|
-
```typescript
|
|
426
|
-
import { createVurbClient } from '@vurb/core';
|
|
427
|
-
import type { AppRouter } from './server.js';
|
|
428
|
-
|
|
429
|
-
const client = createVurbClient<AppRouter>(transport);
|
|
430
|
-
|
|
431
|
-
await client.execute('projects.create', { workspace_id: 'ws_1', name: 'V2' });
|
|
432
|
-
// TS error on typos ('projetcs.create'), missing fields, type mismatches.
|
|
433
|
-
// Zero runtime cost. Client middleware (auth, logging). Batch execution.
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
`createTypedRegistry()` is a curried double-generic — first call sets `TContext`, second infers all builder types. `InferRouter` is pure type-level.
|
|
437
|
-
|
|
438
|
-
### Self-Healing Errors
|
|
439
|
-
|
|
440
|
-
```typescript
|
|
441
|
-
// Validation errors → directed correction prompts
|
|
442
|
-
❌ Validation failed for 'users.create':
|
|
443
|
-
• email — Invalid email format. You sent: 'admin@local'.
|
|
444
|
-
Expected: a valid email address (e.g. user@example.com).
|
|
445
|
-
💡 Fix the fields above and call the action again.
|
|
446
|
-
|
|
447
|
-
// Business-logic errors → structured recovery with fluent builder
|
|
448
|
-
return f.error('NOT_FOUND', `Project '${input.id}' not found`)
|
|
449
|
-
.suggest('Call projects.list to find valid IDs')
|
|
450
|
-
.actions('projects.list')
|
|
451
|
-
.build();
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### Capability Governance — Cryptographic Surface Integrity
|
|
455
|
-
|
|
456
|
-
Nine modules for SOC2-auditable AI deployments:
|
|
457
|
-
|
|
458
|
-
```bash
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
- **Capability Lockfile** — deterministic, git-diffable artifact capturing every tool's behavioral contract
|
|
464
|
-
- **Surface Integrity** — SHA-256 behavioral fingerprinting
|
|
465
|
-
- **Contract Diffing** — semantic delta engine with severity classification
|
|
466
|
-
- **Zero-Trust Attestation** — HMAC-SHA256 signing and runtime verification
|
|
467
|
-
- **Blast Radius Analysis** — entitlement scanning (filesystem, network, subprocess) with evasion detection
|
|
468
|
-
- **Token Economics** — cognitive overload profiling
|
|
469
|
-
- **Semantic Probing** — LLM-as-a-Judge for behavioral drift
|
|
470
|
-
- **Self-Healing Context** — contract delta injection into validation errors
|
|
471
|
-
|
|
472
|
-
PR diffs show exactly what changed in the AI-facing surface:
|
|
473
|
-
|
|
474
|
-
```diff
|
|
475
|
-
"invoices": {
|
|
476
|
-
- "integrityDigest": "sha256:f6e5d4c3b2a1...",
|
|
477
|
-
+ "integrityDigest": "sha256:9a8b7c6d5e4f...",
|
|
478
|
-
"behavior": {
|
|
479
|
-
- "systemRulesFingerprint": "static:abc",
|
|
480
|
-
+ "systemRulesFingerprint": "dynamic",
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
---
|
|
486
|
-
|
|
487
|
-
## Code Generators
|
|
488
|
-
|
|
489
|
-
### OpenAPI → MCP in One Command
|
|
490
|
-
|
|
491
|
-
Turn any **REST/OpenAPI 3.x or Swagger 2.0** spec into a working MCP server — code generation or runtime proxy:
|
|
492
|
-
|
|
493
|
-
```bash
|
|
494
|
-
npx openapi-gen generate -i ./petstore.yaml -o ./generated
|
|
495
|
-
API_BASE_URL=https://api.example.com npx tsx ./generated/server.ts
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
Generates `models/` (Zod `.strict()` schemas), `views/` (Presenters), `agents/` (tool definitions with inferred annotations), `server.ts` (bootstrap). HTTP method → MCP annotation inference: `GET` → `readOnly`, `DELETE` → `destructive`, `PUT` → `idempotent`.
|
|
499
|
-
|
|
500
|
-
Runtime proxy mode with `loadOpenAPI()` for instant prototyping — no code generation step.
|
|
501
|
-
|
|
502
|
-
### Prisma → MCP with Field-Level Security
|
|
503
|
-
|
|
504
|
-
A Prisma Generator that produces Vurb.ts tools and Presenters with field-level security, tenant isolation, and OOM protection:
|
|
505
|
-
|
|
506
|
-
```prisma
|
|
507
|
-
generator mcp {
|
|
508
|
-
provider = "vurb-prisma-gen"
|
|
509
|
-
output = "../src/tools/database"
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
model User {
|
|
513
|
-
id String @id @default(uuid())
|
|
514
|
-
email String @unique
|
|
515
|
-
passwordHash String /// @vurb.hide ← physically excluded from schema
|
|
516
|
-
stripeToken String /// @vurb.hide ← physically excluded from schema
|
|
517
|
-
creditScore Int /// @vurb.describe("Score 0-1000. Above 700 is PREMIUM.")
|
|
518
|
-
tenantId String /// @vurb.tenantKey ← injected into every WHERE clause
|
|
519
|
-
}
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
`npx prisma generate` → typed CRUD tools with pagination capped at 50, tenant isolation at the generated code level. Cross-tenant access is structurally impossible.
|
|
523
|
-
|
|
524
|
-
### n8n Workflows → MCP Tools
|
|
525
|
-
|
|
526
|
-
Auto-discover n8n webhook workflows as MCP tools with tag filtering, live polling, and MVA interception:
|
|
527
|
-
|
|
528
|
-
```typescript
|
|
529
|
-
const n8n = await createN8nConnector({
|
|
530
|
-
url: process.env.N8N_URL!,
|
|
531
|
-
apiKey: process.env.N8N_API_KEY!,
|
|
532
|
-
includeTags: ['ai-enabled'],
|
|
533
|
-
pollInterval: 60_000,
|
|
534
|
-
onChange: () => server.notification({ method: 'notifications/tools/list_changed' }),
|
|
535
|
-
});
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
n8n handles the Stripe/Salesforce/webhook logic. Vurb.ts provides typing, Presenters, middleware, and access control.
|
|
539
|
-
|
|
540
|
-
---
|
|
541
|
-
|
|
542
|
-
## Inspector — Real-Time Dashboard
|
|
543
|
-
|
|
544
|
-
```bash
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
┌──────────────────────────────────────────────────────────────┐
|
|
551
|
-
│ ● LIVE: PID 12345 │ RAM: [█████░░░] 28MB │ UP: 01:23 │
|
|
552
|
-
├───────────────────────┬──────────────────────────────────────┤
|
|
553
|
-
│ TOOL LIST │ X-RAY: billing.create_invoice │
|
|
554
|
-
│ ✓ billing.create │ LATE GUILLOTINE: │
|
|
555
|
-
│ ✓ billing.get │ DB Raw : 4.2KB │
|
|
556
|
-
│ ✗ users.delete │ Wire : 1.1KB │
|
|
557
|
-
│ ✓ system.health │ SAVINGS : ████████░░ 73.8% │
|
|
558
|
-
├───────────────────────┴──────────────────────────────────────┤
|
|
559
|
-
│ 19:32:01 ROUTE billing.create │ 19:32:01 EXEC ✓ 45ms│
|
|
560
|
-
└──────────────────────────────────────────────────────────────┘
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
Connects via **Shadow Socket** (Named Pipe / Unix Domain Socket) — no stdio interference, no port conflicts. Real-time tool list, request stream, Late Guillotine visualization.
|
|
564
|
-
|
|
565
|
-
---
|
|
566
|
-
|
|
567
|
-
## Testing — Full Pipeline in RAM
|
|
568
|
-
|
|
569
|
-
`@vurb/testing` runs the actual execution pipeline — same code path as production — and returns `MvaTestResult` with each MVA layer decomposed:
|
|
570
|
-
|
|
571
|
-
```typescript
|
|
572
|
-
import { createVurbTester } from '@vurb/testing';
|
|
573
|
-
|
|
574
|
-
const tester = createVurbTester(registry, {
|
|
575
|
-
contextFactory: () => ({ prisma: mockPrisma, tenantId: 't_42', role: 'ADMIN' }),
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
describe('SOC2 Data Governance', () => {
|
|
579
|
-
it('strips PII before it reaches the LLM', async () => {
|
|
580
|
-
const result = await tester.callAction('db_user', 'find_many', { take: 10 });
|
|
581
|
-
for (const user of result.data) {
|
|
582
|
-
expect(user).not.toHaveProperty('passwordHash');
|
|
583
|
-
expect(user).not.toHaveProperty('tenantId');
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
it('sends governance rules with data', async () => {
|
|
588
|
-
const result = await tester.callAction('db_user', 'find_many', { take: 5 });
|
|
589
|
-
expect(result.systemRules).toContain('Email addresses are PII.');
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
it('blocks guest access', async () => {
|
|
593
|
-
const result = await tester.callAction('db_user', 'find_many', { take: 5 }, { role: 'GUEST' });
|
|
594
|
-
expect(result.isError).toBe(true);
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
Assert every MVA layer: `result.data` (egress firewall), `result.systemRules` (JIT rules), `result.uiBlocks` (server-rendered charts), `result.data.length` (cognitive guardrail), `rawResponse` (HATEOAS hints). Works with Vitest, Jest, Mocha, or `node:test`.
|
|
600
|
-
|
|
601
|
-
---
|
|
602
|
-
|
|
603
|
-
## Deploy Anywhere
|
|
604
|
-
|
|
605
|
-
Every tool is transport-agnostic. Same code on Stdio, SSE, and serverless:
|
|
606
|
-
|
|
607
|
-
### Vercel Functions
|
|
608
|
-
|
|
609
|
-
```typescript
|
|
610
|
-
import { vercelAdapter } from '@vurb/vercel';
|
|
611
|
-
export const POST = vercelAdapter({ registry, contextFactory });
|
|
612
|
-
export const runtime = 'edge'; // global edge distribution
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
### Cloudflare Workers
|
|
616
|
-
|
|
617
|
-
```typescript
|
|
618
|
-
import { cloudflareWorkersAdapter } from '@vurb/cloudflare';
|
|
619
|
-
export default cloudflareWorkersAdapter({ registry, contextFactory });
|
|
620
|
-
// D1 for edge-native SQL, KV for sub-ms reads, waitUntil for telemetry
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
---
|
|
624
|
-
|
|
625
|
-
## Ecosystem
|
|
626
|
-
|
|
627
|
-
### Adapters
|
|
628
|
-
|
|
629
|
-
| Package | Target |
|
|
630
|
-
|---|---|
|
|
631
|
-
| [`@vurb/vercel`](https://vurb.vinkius.com/vercel-adapter) | Vercel Functions (Edge / Node.js) |
|
|
632
|
-
| [`@vurb/cloudflare`](https://vurb.vinkius.com/cloudflare-adapter) | Cloudflare Workers — zero polyfills |
|
|
633
|
-
|
|
634
|
-
### Generators & Connectors
|
|
635
|
-
|
|
636
|
-
| Package | Purpose |
|
|
637
|
-
|---|---|
|
|
638
|
-
| [`@vurb/openapi-gen`](https://vurb.vinkius.com/openapi-gen) | Generate typed tools from OpenAPI 3.x / Swagger 2.0 specs |
|
|
639
|
-
| [`@vurb/prisma-gen`](https://vurb.vinkius.com/prisma-gen) | Generate CRUD tools with field-level security from Prisma |
|
|
640
|
-
| [`@vurb/n8n`](https://vurb.vinkius.com/n8n-connector) | Auto-discover n8n workflows as MCP tools |
|
|
641
|
-
| [`@vurb/aws`](https://vurb.vinkius.com/aws-connector) | Auto-discover AWS Lambda & Step Functions |
|
|
642
|
-
| [`@vurb/skills`](https://vurb.vinkius.com/skills) | Progressive instruction distribution for agents |
|
|
643
|
-
|
|
644
|
-
### Security & Auth
|
|
645
|
-
|
|
646
|
-
| Package | Purpose |
|
|
647
|
-
|---|---|
|
|
648
|
-
| [`@vurb/oauth`](https://vurb.vinkius.com/oauth) | RFC 8628 Device Flow authentication |
|
|
649
|
-
| [`@vurb/jwt`](https://vurb.vinkius.com/jwt) | JWT verification — HS256/RS256/ES256 + JWKS |
|
|
650
|
-
| [`@vurb/api-key`](https://vurb.vinkius.com/api-key) | API key validation with timing-safe comparison |
|
|
651
|
-
|
|
652
|
-
### Developer Experience
|
|
653
|
-
|
|
654
|
-
| Package | Purpose |
|
|
655
|
-
|---|---|
|
|
656
|
-
| [`@vurb/testing`](https://vurb.vinkius.com/testing) | In-memory pipeline testing with MVA layer assertions |
|
|
657
|
-
| [`@vurb/inspector`](https://vurb.vinkius.com/inspector) | Real-time terminal dashboard via Shadow Socket |
|
|
658
|
-
|
|
659
|
-
---
|
|
660
|
-
|
|
661
|
-
## Documentation
|
|
662
|
-
|
|
663
|
-
Full guides, API reference, and cookbook recipes:
|
|
664
|
-
|
|
665
|
-
**[Vurb.ts.vinkius.com](https://vurb.vinkius.com/)**
|
|
666
|
-
|
|
667
|
-
## Contributing
|
|
668
|
-
|
|
669
|
-
See [CONTRIBUTING.md](https://github.com/vinkius-labs/vurb.ts/blob/main/CONTRIBUTING.md) for development setup and PR guidelines.
|
|
670
|
-
|
|
671
|
-
## Security
|
|
672
|
-
|
|
673
|
-
See [SECURITY.md](https://github.com/vinkius-labs/vurb.ts/blob/main/SECURITY.md) for reporting vulnerabilities.
|
|
674
|
-
|
|
675
|
-
## License
|
|
676
|
-
|
|
677
|
-
[Apache 2.0](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/86ae1b28-a938-4e12-af29-bfc60a55dbe8" >
|
|
5
|
+
<img src="https://github.com/user-attachments/assets/86ae1b28-a938-4e12-af29-bfc60a55dbe8" style="border-radius:8px;background:#000000;padding:10px;border:1px solid #414141;" alt="Vurb.ts">
|
|
6
|
+
</picture>
|
|
7
|
+
|
|
8
|
+
**The MVA framework for production MCP servers.**<br>
|
|
9
|
+
Structured perception for AI agents. Zero hallucination. Zero data leaks.
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/@vurb/core)
|
|
12
|
+
[](https://www.npmjs.com/package/@vurb/core)
|
|
13
|
+
[](https://www.typescriptlang.org/)
|
|
14
|
+
[](https://modelcontextprotocol.io/)
|
|
15
|
+
[](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
|
|
16
|
+
|
|
17
|
+
[Documentation](https://vurb.vinkius.com/) · [Quick Start](https://vurb.vinkius.com/quickstart-lightspeed) · [API Reference](https://vurb.vinkius.com/api/)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Get Started in 5 Seconds
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
vurb create my-server
|
|
27
|
+
cd my-server && vurb dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
That's it. A production-ready MCP server with file-based routing, Presenters, middleware, tests, and pre-configured connections for **Cursor**, **Claude Desktop**, **Claude Code**, **Windsurf**, **Cline**, and **VS Code + GitHub Copilot**.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Project name? › my-server
|
|
34
|
+
Transport? › stdio
|
|
35
|
+
Vector? › vanilla
|
|
36
|
+
|
|
37
|
+
● Scaffolding project — 14 files (6ms)
|
|
38
|
+
● Installing dependencies...
|
|
39
|
+
✔ Done — vurb dev to start
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Choose a vector to scaffold exactly the project you need:
|
|
43
|
+
|
|
44
|
+
| Vector | What it scaffolds |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `vanilla` | `autoDiscover()` file-based routing. Zero external deps |
|
|
47
|
+
| `prisma` | Prisma schema + CRUD tools with field-level security |
|
|
48
|
+
| `n8n` | n8n workflow bridge — auto-discover webhooks as tools |
|
|
49
|
+
| `openapi` | OpenAPI 3.x / Swagger 2.0 → full MVA tool generation |
|
|
50
|
+
| `oauth` | RFC 8628 Device Flow authentication |
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Database-driven server with Presenter egress firewall
|
|
54
|
+
vurb create my-api --vector prisma --transport sse --yes
|
|
55
|
+
|
|
56
|
+
# Bridge your n8n workflows to any MCP client
|
|
57
|
+
vurb create ops-bridge --vector n8n --yes
|
|
58
|
+
|
|
59
|
+
# REST API → MCP in one command
|
|
60
|
+
vurb create petstore --vector openapi --yes
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Drop a file in `src/tools/`, restart — it's a live MCP tool. No central import file, no merge conflicts:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
src/tools/
|
|
67
|
+
├── billing/
|
|
68
|
+
│ ├── get_invoice.ts → billing.get_invoice
|
|
69
|
+
│ └── pay.ts → billing.pay
|
|
70
|
+
├── users/
|
|
71
|
+
│ ├── list.ts → users.list
|
|
72
|
+
│ └── ban.ts → users.ban
|
|
73
|
+
└── system/
|
|
74
|
+
└── health.ts → system.health
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Why Vurb.ts Exists
|
|
80
|
+
|
|
81
|
+
Every raw MCP server does the same thing: `JSON.stringify()` the database result and ship it to the LLM. Three catastrophic consequences:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// What every MCP tutorial teaches
|
|
85
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
86
|
+
const { name, arguments: args } = request.params;
|
|
87
|
+
if (name === 'get_invoice') {
|
|
88
|
+
const invoice = await db.invoices.findUnique(args.id);
|
|
89
|
+
return { content: [{ type: 'text', text: JSON.stringify(invoice) }] };
|
|
90
|
+
// AI receives: { password_hash, internal_margin, customer_ssn, ... }
|
|
91
|
+
}
|
|
92
|
+
// ...50 more if/else branches
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Data exfiltration.** `JSON.stringify(invoice)` sends `password_hash`, `internal_margin`, `customer_ssn` — every column — straight to the LLM provider. One field = one GDPR violation.
|
|
97
|
+
|
|
98
|
+
**Token explosion.** Every tool schema is sent on every turn, even when irrelevant. System prompt rules for every domain entity are sent globally, bloating context with wasted tokens.
|
|
99
|
+
|
|
100
|
+
**Context DDoS.** An unbounded `findMany()` can dump thousands of rows into the context window. The LLM hallucinates. Your API bill explodes.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## The MVA Solution
|
|
105
|
+
|
|
106
|
+
Vurb.ts replaces `JSON.stringify()` with a **Presenter** — a deterministic perception layer that controls exactly what the agent sees, knows, and can do next.
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Handler (Model) Presenter (View) Agent (LLM)
|
|
110
|
+
─────────────── ──────────────── ───────────
|
|
111
|
+
Raw DB data → Zod-validated schema → Structured
|
|
112
|
+
{ amount_cents, + System rules perception
|
|
113
|
+
password_hash, + UI blocks (charts) package
|
|
114
|
+
internal_margin, + Suggested next actions
|
|
115
|
+
ssn, ... } + PII redaction
|
|
116
|
+
+ Cognitive guardrails
|
|
117
|
+
- password_hash ← STRIPPED
|
|
118
|
+
- internal_margin ← STRIPPED
|
|
119
|
+
- ssn ← REDACTED
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The result is not JSON — it's a **Perception Package**:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Block 1 — DATA: {"id":"INV-001","amount_cents":45000,"status":"pending"}
|
|
126
|
+
Block 2 — UI: [ECharts gauge chart config]
|
|
127
|
+
Block 3 — RULES: "amount_cents is in CENTS. Divide by 100 for display."
|
|
128
|
+
Block 4 — ACTIONS: → billing.pay: "Invoice is pending — process payment"
|
|
129
|
+
Block 5 — EMBEDS: [Client Presenter + LineItem Presenter composed]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
No guessing. Undeclared fields rejected. Domain rules travel with data — not in the system prompt. Next actions computed from data state.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Before vs. After
|
|
137
|
+
|
|
138
|
+
**Before** — raw MCP:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
case 'get_invoice':
|
|
142
|
+
const invoice = await db.invoices.findUnique(args.id);
|
|
143
|
+
return { content: [{ type: 'text', text: JSON.stringify(invoice) }] };
|
|
144
|
+
// Leaks internal columns. No rules. No guidance.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**After** — Vurb.ts with MVA:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { createPresenter, suggest, ui, t } from '@vurb/core';
|
|
151
|
+
|
|
152
|
+
const InvoicePresenter = createPresenter('Invoice')
|
|
153
|
+
.schema({
|
|
154
|
+
id: t.string,
|
|
155
|
+
amount_cents: t.number.describe('Amount in cents — divide by 100'),
|
|
156
|
+
status: t.enum('paid', 'pending', 'overdue'),
|
|
157
|
+
})
|
|
158
|
+
.rules(['CRITICAL: amount_cents is in CENTS. Divide by 100 for display.'])
|
|
159
|
+
.redactPII(['*.customer_ssn', '*.credit_card'])
|
|
160
|
+
.ui((inv) => [
|
|
161
|
+
ui.echarts({
|
|
162
|
+
series: [{ type: 'gauge', data: [{ value: inv.amount_cents / 100 }] }],
|
|
163
|
+
}),
|
|
164
|
+
])
|
|
165
|
+
.suggest((inv) =>
|
|
166
|
+
inv.status === 'pending'
|
|
167
|
+
? [suggest('billing.pay', 'Invoice pending — process payment')]
|
|
168
|
+
: [suggest('billing.archive', 'Invoice settled — archive it')]
|
|
169
|
+
)
|
|
170
|
+
.embed('client', ClientPresenter)
|
|
171
|
+
.embed('line_items', LineItemPresenter)
|
|
172
|
+
.limit(50);
|
|
173
|
+
|
|
174
|
+
export default f.query('billing.get_invoice')
|
|
175
|
+
.describe('Get an invoice by ID')
|
|
176
|
+
.withString('id', 'Invoice ID')
|
|
177
|
+
.returns(InvoicePresenter)
|
|
178
|
+
.handle(async (input, ctx) => ctx.db.invoices.findUnique({
|
|
179
|
+
where: { id: input.id },
|
|
180
|
+
include: { client: true, line_items: true },
|
|
181
|
+
}));
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The handler returns raw data. The Presenter shapes absolutely everything the agent perceives.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Architecture
|
|
189
|
+
|
|
190
|
+
### Egress Firewall — Schema as Security Boundary
|
|
191
|
+
|
|
192
|
+
The Presenter's Zod schema acts as a whitelist. **Only declared fields pass through.** A database migration that adds `customer_ssn` doesn't change what the agent sees — the new column is invisible unless you explicitly declare it in the schema.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const UserPresenter = createPresenter('User')
|
|
196
|
+
.schema({ id: t.string, name: t.string, email: t.string });
|
|
197
|
+
// password_hash, tenant_id, internal_flags → STRIPPED at RAM level
|
|
198
|
+
// A developer CANNOT accidentally expose a new column
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### DLP Compliance Engine — PII Redaction
|
|
202
|
+
|
|
203
|
+
GDPR / LGPD / HIPAA compliance built into the framework. `.redactPII()` compiles a V8-optimized redaction function via `fast-redact` that masks sensitive fields **after** UI blocks and rules have been computed (Late Guillotine Pattern) — the LLM receives `[REDACTED]` instead of real values.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
const PatientPresenter = createPresenter('Patient')
|
|
207
|
+
.schema({ name: t.string, ssn: t.string, diagnosis: t.string })
|
|
208
|
+
.redactPII(['ssn', 'diagnosis'])
|
|
209
|
+
.ui((patient) => [
|
|
210
|
+
ui.markdown(`**Patient:** ${patient.name}`),
|
|
211
|
+
// patient.ssn available for UI logic — but LLM sees [REDACTED]
|
|
212
|
+
]);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Custom censors, wildcard paths (`'*.email'`, `'patients[*].diagnosis'`), and centralized PII field lists. **Zero-leak guarantee** — the developer cannot accidentally bypass redaction.
|
|
216
|
+
|
|
217
|
+
### 8 Anti-Hallucination Mechanisms
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
① Action Consolidation → groups operations behind fewer tools → ↓ tokens
|
|
221
|
+
② TOON Encoding → pipe-delimited compact descriptions → ↓ tokens
|
|
222
|
+
③ Zod .strict() → rejects hallucinated params at build → ↓ retries
|
|
223
|
+
④ Self-Healing Errors → directed correction prompts → ↓ retries
|
|
224
|
+
⑤ Cognitive Guardrails → .limit() truncates before LLM sees it → ↓ tokens
|
|
225
|
+
⑥ Agentic Affordances → HATEOAS next-action hints from data → ↓ retries
|
|
226
|
+
⑦ JIT Context Rules → rules travel with data, not globally → ↓ tokens
|
|
227
|
+
⑧ State Sync → RFC 7234 cache-control for agents → ↓ requests
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Each mechanism compounds. Fewer tokens in context, fewer requests per task, less hallucination, lower cost.
|
|
231
|
+
|
|
232
|
+
### FSM State Gate — Temporal Anti-Hallucination
|
|
233
|
+
|
|
234
|
+
**The first framework where it is physically impossible for an AI to execute tools out of order.**
|
|
235
|
+
|
|
236
|
+
LLMs are chaotic — even with HATEOAS suggestions, a model can ignore them and call `cart.pay` with an empty cart. The FSM State Gate makes temporal hallucination structurally impossible: if the workflow state is `empty`, the `cart.pay` tool **doesn't exist** in `tools/list`. The LLM literally cannot call it.
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
const gate = f.fsm({
|
|
240
|
+
id: 'checkout',
|
|
241
|
+
initial: 'empty',
|
|
242
|
+
states: {
|
|
243
|
+
empty: { on: { ADD_ITEM: 'has_items' } },
|
|
244
|
+
has_items: { on: { CHECKOUT: 'payment', CLEAR: 'empty' } },
|
|
245
|
+
payment: { on: { PAY: 'confirmed', CANCEL: 'has_items' } },
|
|
246
|
+
confirmed: { type: 'final' },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const pay = f.mutation('cart.pay')
|
|
251
|
+
.describe('Process payment')
|
|
252
|
+
.bindState('payment', 'PAY') // Visible ONLY in 'payment' state
|
|
253
|
+
.handle(async (input, ctx) => ctx.db.payments.process(input.method));
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
| State | Visible Tools |
|
|
257
|
+
|---|---|
|
|
258
|
+
| `empty` | `cart.add_item`, `cart.view` |
|
|
259
|
+
| `has_items` | `cart.add_item`, `cart.checkout`, `cart.view` |
|
|
260
|
+
| `payment` | `cart.pay`, `cart.view` |
|
|
261
|
+
| `confirmed` | `cart.view` |
|
|
262
|
+
|
|
263
|
+
Three complementary layers: **Format** (Zod validates shape), **Guidance** (HATEOAS suggests the next tool), **Gate** (FSM physically removes wrong tools). XState v5 powered, serverless-ready with `fsmStore`.
|
|
264
|
+
|
|
265
|
+
### Zero-Trust Sandbox — Computation Delegation
|
|
266
|
+
|
|
267
|
+
The LLM sends JavaScript logic to your data instead of shipping data to the LLM. Code runs inside a sealed V8 isolate — **zero access** to `process`, `require`, `fs`, `net`, `fetch`, `Buffer`. Timeout kill, memory cap, output limit, automatic isolate recovery, and AbortSignal kill-switch (Connection Watchdog).
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
export default f.query('analytics.compute')
|
|
271
|
+
.describe('Run a computation on server-side data')
|
|
272
|
+
.sandboxed({ timeout: 3000, memoryLimit: 64 })
|
|
273
|
+
.handle(async (input, ctx) => {
|
|
274
|
+
const data = await ctx.db.records.findMany();
|
|
275
|
+
const engine = f.sandbox({ timeout: 3000, memoryLimit: 64 });
|
|
276
|
+
try {
|
|
277
|
+
const result = await engine.execute(input.expression, data);
|
|
278
|
+
if (!result.ok) return f.error('VALIDATION_ERROR', result.error)
|
|
279
|
+
.suggest('Fix the JavaScript expression and retry.');
|
|
280
|
+
return result.value;
|
|
281
|
+
} finally { engine.dispose(); }
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`.sandboxed()` auto-injects HATEOAS instructions into the tool description — the LLM knows exactly how to format its code. Prototype pollution contained. `constructor.constructor` escape blocked. One isolate per engine, new pristine context per call.
|
|
286
|
+
|
|
287
|
+
### State Sync — Temporal Awareness for Agents
|
|
288
|
+
|
|
289
|
+
LLMs have no sense of time. After `sprints.list` then `sprints.create`, the agent still believes the list is unchanged. Vurb.ts injects RFC 7234-inspired cache-control signals:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
const listSprints = f.query('sprints.list')
|
|
293
|
+
.stale() // no-store — always re-fetch
|
|
294
|
+
.handle(async (input, ctx) => ctx.db.sprints.findMany());
|
|
295
|
+
|
|
296
|
+
const createSprint = f.action('sprints.create')
|
|
297
|
+
.invalidates('sprints.*', 'tasks.*') // causal cross-domain invalidation
|
|
298
|
+
.withString('name', 'Sprint name')
|
|
299
|
+
.handle(async (input, ctx) => ctx.db.sprints.create(input));
|
|
300
|
+
// After mutation: [System: Cache invalidated for sprints.*, tasks.* — caused by sprints.create]
|
|
301
|
+
// Failed mutations emit nothing — state didn't change.
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Registry-level policies with `f.stateSync()`, glob patterns (`*`, `**`), policy overlap detection, observability hooks, and MCP `notifications/resources/updated` emission.
|
|
305
|
+
|
|
306
|
+
### Prompt Engine — Server-Side Templates
|
|
307
|
+
|
|
308
|
+
MCP Prompts as executable server-side templates with the same Fluent API as tools. Middleware, hydration timeout, schema-informed coercion, interceptors, multi-modal messages, and the Presenter bridge:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
const IncidentAnalysis = f.prompt('incident_analysis')
|
|
312
|
+
.title('Incident Analysis')
|
|
313
|
+
.describe('Structured analysis of a production incident')
|
|
314
|
+
.tags('engineering', 'ops')
|
|
315
|
+
.input({
|
|
316
|
+
incident_id: { type: 'string', description: 'Incident ticket ID' },
|
|
317
|
+
severity: { enum: ['sev1', 'sev2', 'sev3'] as const },
|
|
318
|
+
})
|
|
319
|
+
.use(requireAuth, requireRole('engineer'))
|
|
320
|
+
.timeout(10_000)
|
|
321
|
+
.handler(async (ctx, { incident_id, severity }) => {
|
|
322
|
+
const incident = await ctx.db.incidents.findUnique({ where: { id: incident_id } });
|
|
323
|
+
return {
|
|
324
|
+
messages: [
|
|
325
|
+
PromptMessage.system(`You are a Senior SRE. Severity: ${severity.toUpperCase()}.`),
|
|
326
|
+
...PromptMessage.fromView(IncidentPresenter.make(incident, ctx)),
|
|
327
|
+
PromptMessage.user('Begin root cause analysis.'),
|
|
328
|
+
],
|
|
329
|
+
};
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`PromptMessage.fromView()` decomposes any Presenter into prompt messages — same schema, same rules, same affordances in both tools and prompts. Multi-modal with `.image()`, `.audio()`, `.resource()`. Interceptors inject compliance footers after every handler. `PromptRegistry` with filtering, pagination, and lifecycle sync.
|
|
334
|
+
|
|
335
|
+
### Agent Skills — Progressive Instruction Distribution
|
|
336
|
+
|
|
337
|
+
**No other MCP framework has this.** Distribute domain expertise to AI agents on demand via MCP. Three-layer progressive disclosure — the agent searches a lightweight index, loads only the relevant SKILL.md, and reads auxiliary files on demand. Zero context window waste.
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import { SkillRegistry, autoDiscoverSkills, createSkillTools } from '@vurb/skills';
|
|
341
|
+
|
|
342
|
+
const skills = new SkillRegistry();
|
|
343
|
+
await autoDiscoverSkills(skills, './skills');
|
|
344
|
+
const [search, load, readFile] = createSkillTools(f, skills);
|
|
345
|
+
registry.registerAll(search, load, readFile);
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Skills follow the [agentskills.io](https://agentskills.io) open standard — SKILL.md with YAML frontmatter. `skills.search` returns the lightweight index. `skills.load` returns full instructions. `skills.read_file` gives access to auxiliary files with **path traversal protection** (only files within the skill's directory). Custom search engines supported.
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
skills/
|
|
352
|
+
├── deployment/
|
|
353
|
+
│ ├── SKILL.md # name, description, full instructions
|
|
354
|
+
│ └── scripts/
|
|
355
|
+
│ └── deploy.sh # accessible via skills.read_file
|
|
356
|
+
└── database-migration/
|
|
357
|
+
└── SKILL.md
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Fluent API — Semantic Verbs & Chainable Builders
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
f.query('users.list') // readOnly: true — no side effects
|
|
364
|
+
f.action('users.create') // neutral — creates or updates
|
|
365
|
+
f.mutation('users.delete') // destructive: true — triggers confirmation dialogs
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Every builder method is chainable and fully typed. Types accumulate as you chain — the final `.handle()` has 100% accurate autocomplete with zero annotations:
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
export const deploy = f.mutation('infra.deploy')
|
|
372
|
+
.describe('Deploy infrastructure')
|
|
373
|
+
.instructions('Use ONLY after the user explicitly requests deployment.')
|
|
374
|
+
.withEnum('env', ['staging', 'production'] as const, 'Target environment')
|
|
375
|
+
.concurrency({ max: 2, queueSize: 5 })
|
|
376
|
+
.egress(1_000_000)
|
|
377
|
+
.idempotent()
|
|
378
|
+
.invalidates('infra.*')
|
|
379
|
+
.returns(DeployPresenter)
|
|
380
|
+
.handle(async function* (input, ctx) {
|
|
381
|
+
yield progress(10, 'Cloning repository...');
|
|
382
|
+
await cloneRepo(ctx.repoUrl);
|
|
383
|
+
yield progress(90, 'Running tests...');
|
|
384
|
+
const results = await runTests();
|
|
385
|
+
yield progress(100, 'Done!');
|
|
386
|
+
return results;
|
|
387
|
+
});
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
`.instructions()` embeds prompt engineering. `.concurrency()` prevents backend overload. `.egress()` caps response size. `yield progress()` streams MCP progress notifications. `.cached()` / `.stale()` / `.invalidates()` control temporal awareness. `.sandboxed()` enables computation delegation. `.bindState()` enables FSM gating.
|
|
391
|
+
|
|
392
|
+
### Middleware — Pre-Compiled, Zero-Allocation
|
|
393
|
+
|
|
394
|
+
tRPC-style context derivation. Middleware chains compiled at registration time into a single nested function — O(1) dispatch, no array iteration, no per-request allocation:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
const requireAuth = f.middleware(async (ctx) => {
|
|
398
|
+
const user = await db.getUser(ctx.token);
|
|
399
|
+
if (!user) throw new Error('Unauthorized');
|
|
400
|
+
return { user, permissions: user.permissions };
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// ctx.user and ctx.permissions — fully typed downstream. Zero annotations.
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Stack `.use()` calls for layered derivations: auth → permissions → tenant resolution → audit logging. Same `MiddlewareFn` signature works for both tools and prompts.
|
|
407
|
+
|
|
408
|
+
### Fluent Router — Grouped Tooling
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
const users = f.router('users')
|
|
412
|
+
.describe('User management')
|
|
413
|
+
.use(requireAuth)
|
|
414
|
+
.tags('core');
|
|
415
|
+
|
|
416
|
+
export const listUsers = users.query('list').describe('List users').handle(/* ... */);
|
|
417
|
+
export const banUser = users.mutation('ban').describe('Ban a user').handle(/* ... */);
|
|
418
|
+
// Middleware, tags, prefix — all inherited automatically
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Discriminator enum compilation. Per-field annotations tell the LLM which parameters belong to which action. Tool exposition: `flat` (independent MCP tools) or `grouped` (one tool with enum discriminator).
|
|
422
|
+
|
|
423
|
+
### tRPC-Style Client — Compile-Time Route Validation
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { createVurbClient } from '@vurb/core';
|
|
427
|
+
import type { AppRouter } from './server.js';
|
|
428
|
+
|
|
429
|
+
const client = createVurbClient<AppRouter>(transport);
|
|
430
|
+
|
|
431
|
+
await client.execute('projects.create', { workspace_id: 'ws_1', name: 'V2' });
|
|
432
|
+
// TS error on typos ('projetcs.create'), missing fields, type mismatches.
|
|
433
|
+
// Zero runtime cost. Client middleware (auth, logging). Batch execution.
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
`createTypedRegistry()` is a curried double-generic — first call sets `TContext`, second infers all builder types. `InferRouter` is pure type-level.
|
|
437
|
+
|
|
438
|
+
### Self-Healing Errors
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
// Validation errors → directed correction prompts
|
|
442
|
+
❌ Validation failed for 'users.create':
|
|
443
|
+
• email — Invalid email format. You sent: 'admin@local'.
|
|
444
|
+
Expected: a valid email address (e.g. user@example.com).
|
|
445
|
+
💡 Fix the fields above and call the action again.
|
|
446
|
+
|
|
447
|
+
// Business-logic errors → structured recovery with fluent builder
|
|
448
|
+
return f.error('NOT_FOUND', `Project '${input.id}' not found`)
|
|
449
|
+
.suggest('Call projects.list to find valid IDs')
|
|
450
|
+
.actions('projects.list')
|
|
451
|
+
.build();
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Capability Governance — Cryptographic Surface Integrity
|
|
455
|
+
|
|
456
|
+
Nine modules for SOC2-auditable AI deployments:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
vurb lock --server ./src/server.ts # Generate vurb.lock
|
|
460
|
+
vurb lock --check --server ./src/server.ts # Gate CI builds
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
- **Capability Lockfile** — deterministic, git-diffable artifact capturing every tool's behavioral contract
|
|
464
|
+
- **Surface Integrity** — SHA-256 behavioral fingerprinting
|
|
465
|
+
- **Contract Diffing** — semantic delta engine with severity classification
|
|
466
|
+
- **Zero-Trust Attestation** — HMAC-SHA256 signing and runtime verification
|
|
467
|
+
- **Blast Radius Analysis** — entitlement scanning (filesystem, network, subprocess) with evasion detection
|
|
468
|
+
- **Token Economics** — cognitive overload profiling
|
|
469
|
+
- **Semantic Probing** — LLM-as-a-Judge for behavioral drift
|
|
470
|
+
- **Self-Healing Context** — contract delta injection into validation errors
|
|
471
|
+
|
|
472
|
+
PR diffs show exactly what changed in the AI-facing surface:
|
|
473
|
+
|
|
474
|
+
```diff
|
|
475
|
+
"invoices": {
|
|
476
|
+
- "integrityDigest": "sha256:f6e5d4c3b2a1...",
|
|
477
|
+
+ "integrityDigest": "sha256:9a8b7c6d5e4f...",
|
|
478
|
+
"behavior": {
|
|
479
|
+
- "systemRulesFingerprint": "static:abc",
|
|
480
|
+
+ "systemRulesFingerprint": "dynamic",
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Code Generators
|
|
488
|
+
|
|
489
|
+
### OpenAPI → MCP in One Command
|
|
490
|
+
|
|
491
|
+
Turn any **REST/OpenAPI 3.x or Swagger 2.0** spec into a working MCP server — code generation or runtime proxy:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
npx openapi-gen generate -i ./petstore.yaml -o ./generated
|
|
495
|
+
API_BASE_URL=https://api.example.com npx tsx ./generated/server.ts
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Generates `models/` (Zod `.strict()` schemas), `views/` (Presenters), `agents/` (tool definitions with inferred annotations), `server.ts` (bootstrap). HTTP method → MCP annotation inference: `GET` → `readOnly`, `DELETE` → `destructive`, `PUT` → `idempotent`.
|
|
499
|
+
|
|
500
|
+
Runtime proxy mode with `loadOpenAPI()` for instant prototyping — no code generation step.
|
|
501
|
+
|
|
502
|
+
### Prisma → MCP with Field-Level Security
|
|
503
|
+
|
|
504
|
+
A Prisma Generator that produces Vurb.ts tools and Presenters with field-level security, tenant isolation, and OOM protection:
|
|
505
|
+
|
|
506
|
+
```prisma
|
|
507
|
+
generator mcp {
|
|
508
|
+
provider = "vurb-prisma-gen"
|
|
509
|
+
output = "../src/tools/database"
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
model User {
|
|
513
|
+
id String @id @default(uuid())
|
|
514
|
+
email String @unique
|
|
515
|
+
passwordHash String /// @vurb.hide ← physically excluded from schema
|
|
516
|
+
stripeToken String /// @vurb.hide ← physically excluded from schema
|
|
517
|
+
creditScore Int /// @vurb.describe("Score 0-1000. Above 700 is PREMIUM.")
|
|
518
|
+
tenantId String /// @vurb.tenantKey ← injected into every WHERE clause
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
`npx prisma generate` → typed CRUD tools with pagination capped at 50, tenant isolation at the generated code level. Cross-tenant access is structurally impossible.
|
|
523
|
+
|
|
524
|
+
### n8n Workflows → MCP Tools
|
|
525
|
+
|
|
526
|
+
Auto-discover n8n webhook workflows as MCP tools with tag filtering, live polling, and MVA interception:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
const n8n = await createN8nConnector({
|
|
530
|
+
url: process.env.N8N_URL!,
|
|
531
|
+
apiKey: process.env.N8N_API_KEY!,
|
|
532
|
+
includeTags: ['ai-enabled'],
|
|
533
|
+
pollInterval: 60_000,
|
|
534
|
+
onChange: () => server.notification({ method: 'notifications/tools/list_changed' }),
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
n8n handles the Stripe/Salesforce/webhook logic. Vurb.ts provides typing, Presenters, middleware, and access control.
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
## Inspector — Real-Time Dashboard
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
vurb inspect # Auto-discover and connect
|
|
546
|
+
vurb inspect --demo # Built-in simulator
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
```
|
|
550
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
551
|
+
│ ● LIVE: PID 12345 │ RAM: [█████░░░] 28MB │ UP: 01:23 │
|
|
552
|
+
├───────────────────────┬──────────────────────────────────────┤
|
|
553
|
+
│ TOOL LIST │ X-RAY: billing.create_invoice │
|
|
554
|
+
│ ✓ billing.create │ LATE GUILLOTINE: │
|
|
555
|
+
│ ✓ billing.get │ DB Raw : 4.2KB │
|
|
556
|
+
│ ✗ users.delete │ Wire : 1.1KB │
|
|
557
|
+
│ ✓ system.health │ SAVINGS : ████████░░ 73.8% │
|
|
558
|
+
├───────────────────────┴──────────────────────────────────────┤
|
|
559
|
+
│ 19:32:01 ROUTE billing.create │ 19:32:01 EXEC ✓ 45ms│
|
|
560
|
+
└──────────────────────────────────────────────────────────────┘
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
Connects via **Shadow Socket** (Named Pipe / Unix Domain Socket) — no stdio interference, no port conflicts. Real-time tool list, request stream, Late Guillotine visualization.
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## Testing — Full Pipeline in RAM
|
|
568
|
+
|
|
569
|
+
`@vurb/testing` runs the actual execution pipeline — same code path as production — and returns `MvaTestResult` with each MVA layer decomposed:
|
|
570
|
+
|
|
571
|
+
```typescript
|
|
572
|
+
import { createVurbTester } from '@vurb/testing';
|
|
573
|
+
|
|
574
|
+
const tester = createVurbTester(registry, {
|
|
575
|
+
contextFactory: () => ({ prisma: mockPrisma, tenantId: 't_42', role: 'ADMIN' }),
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
describe('SOC2 Data Governance', () => {
|
|
579
|
+
it('strips PII before it reaches the LLM', async () => {
|
|
580
|
+
const result = await tester.callAction('db_user', 'find_many', { take: 10 });
|
|
581
|
+
for (const user of result.data) {
|
|
582
|
+
expect(user).not.toHaveProperty('passwordHash');
|
|
583
|
+
expect(user).not.toHaveProperty('tenantId');
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('sends governance rules with data', async () => {
|
|
588
|
+
const result = await tester.callAction('db_user', 'find_many', { take: 5 });
|
|
589
|
+
expect(result.systemRules).toContain('Email addresses are PII.');
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
it('blocks guest access', async () => {
|
|
593
|
+
const result = await tester.callAction('db_user', 'find_many', { take: 5 }, { role: 'GUEST' });
|
|
594
|
+
expect(result.isError).toBe(true);
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Assert every MVA layer: `result.data` (egress firewall), `result.systemRules` (JIT rules), `result.uiBlocks` (server-rendered charts), `result.data.length` (cognitive guardrail), `rawResponse` (HATEOAS hints). Works with Vitest, Jest, Mocha, or `node:test`.
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## Deploy Anywhere
|
|
604
|
+
|
|
605
|
+
Every tool is transport-agnostic. Same code on Stdio, SSE, and serverless:
|
|
606
|
+
|
|
607
|
+
### Vercel Functions
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
import { vercelAdapter } from '@vurb/vercel';
|
|
611
|
+
export const POST = vercelAdapter({ registry, contextFactory });
|
|
612
|
+
export const runtime = 'edge'; // global edge distribution
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### Cloudflare Workers
|
|
616
|
+
|
|
617
|
+
```typescript
|
|
618
|
+
import { cloudflareWorkersAdapter } from '@vurb/cloudflare';
|
|
619
|
+
export default cloudflareWorkersAdapter({ registry, contextFactory });
|
|
620
|
+
// D1 for edge-native SQL, KV for sub-ms reads, waitUntil for telemetry
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## Ecosystem
|
|
626
|
+
|
|
627
|
+
### Adapters
|
|
628
|
+
|
|
629
|
+
| Package | Target |
|
|
630
|
+
|---|---|
|
|
631
|
+
| [`@vurb/vercel`](https://vurb.vinkius.com/vercel-adapter) | Vercel Functions (Edge / Node.js) |
|
|
632
|
+
| [`@vurb/cloudflare`](https://vurb.vinkius.com/cloudflare-adapter) | Cloudflare Workers — zero polyfills |
|
|
633
|
+
|
|
634
|
+
### Generators & Connectors
|
|
635
|
+
|
|
636
|
+
| Package | Purpose |
|
|
637
|
+
|---|---|
|
|
638
|
+
| [`@vurb/openapi-gen`](https://vurb.vinkius.com/openapi-gen) | Generate typed tools from OpenAPI 3.x / Swagger 2.0 specs |
|
|
639
|
+
| [`@vurb/prisma-gen`](https://vurb.vinkius.com/prisma-gen) | Generate CRUD tools with field-level security from Prisma |
|
|
640
|
+
| [`@vurb/n8n`](https://vurb.vinkius.com/n8n-connector) | Auto-discover n8n workflows as MCP tools |
|
|
641
|
+
| [`@vurb/aws`](https://vurb.vinkius.com/aws-connector) | Auto-discover AWS Lambda & Step Functions |
|
|
642
|
+
| [`@vurb/skills`](https://vurb.vinkius.com/skills) | Progressive instruction distribution for agents |
|
|
643
|
+
|
|
644
|
+
### Security & Auth
|
|
645
|
+
|
|
646
|
+
| Package | Purpose |
|
|
647
|
+
|---|---|
|
|
648
|
+
| [`@vurb/oauth`](https://vurb.vinkius.com/oauth) | RFC 8628 Device Flow authentication |
|
|
649
|
+
| [`@vurb/jwt`](https://vurb.vinkius.com/jwt) | JWT verification — HS256/RS256/ES256 + JWKS |
|
|
650
|
+
| [`@vurb/api-key`](https://vurb.vinkius.com/api-key) | API key validation with timing-safe comparison |
|
|
651
|
+
|
|
652
|
+
### Developer Experience
|
|
653
|
+
|
|
654
|
+
| Package | Purpose |
|
|
655
|
+
|---|---|
|
|
656
|
+
| [`@vurb/testing`](https://vurb.vinkius.com/testing) | In-memory pipeline testing with MVA layer assertions |
|
|
657
|
+
| [`@vurb/inspector`](https://vurb.vinkius.com/inspector) | Real-time terminal dashboard via Shadow Socket |
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
## Documentation
|
|
662
|
+
|
|
663
|
+
Full guides, API reference, and cookbook recipes:
|
|
664
|
+
|
|
665
|
+
**[Vurb.ts.vinkius.com](https://vurb.vinkius.com/)**
|
|
666
|
+
|
|
667
|
+
## Contributing
|
|
668
|
+
|
|
669
|
+
See [CONTRIBUTING.md](https://github.com/vinkius-labs/vurb.ts/blob/main/CONTRIBUTING.md) for development setup and PR guidelines.
|
|
670
|
+
|
|
671
|
+
## Security
|
|
672
|
+
|
|
673
|
+
See [SECURITY.md](https://github.com/vinkius-labs/vurb.ts/blob/main/SECURITY.md) for reporting vulnerabilities.
|
|
674
|
+
|
|
675
|
+
## License
|
|
676
|
+
|
|
677
|
+
[Apache 2.0](https://github.com/vinkius-labs/vurb.ts/blob/main/LICENSE)
|