@vibesdotdev/runtime-client 0.0.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.
Files changed (63) hide show
  1. package/README.md +97 -0
  2. package/SPEC.md +44 -0
  3. package/dist/base.d.ts +49 -0
  4. package/dist/base.d.ts.map +1 -0
  5. package/dist/base.js +86 -0
  6. package/dist/base.js.map +1 -0
  7. package/dist/contract.d.ts +23 -0
  8. package/dist/contract.d.ts.map +1 -0
  9. package/dist/contract.js +2 -0
  10. package/dist/contract.js.map +1 -0
  11. package/dist/docs/runtime-client.api.docs.descriptor.d.ts +8 -0
  12. package/dist/docs/runtime-client.api.docs.descriptor.d.ts.map +1 -0
  13. package/dist/docs/runtime-client.api.docs.descriptor.js +344 -0
  14. package/dist/docs/runtime-client.api.docs.descriptor.js.map +1 -0
  15. package/dist/docs/runtime-client.helpers.docs.descriptor.d.ts +8 -0
  16. package/dist/docs/runtime-client.helpers.docs.descriptor.d.ts.map +1 -0
  17. package/dist/docs/runtime-client.helpers.docs.descriptor.js +352 -0
  18. package/dist/docs/runtime-client.helpers.docs.descriptor.js.map +1 -0
  19. package/dist/docs/runtime-client.surface.docs.descriptor.d.ts +8 -0
  20. package/dist/docs/runtime-client.surface.docs.descriptor.d.ts.map +1 -0
  21. package/dist/docs/runtime-client.surface.docs.descriptor.js +464 -0
  22. package/dist/docs/runtime-client.surface.docs.descriptor.js.map +1 -0
  23. package/dist/docs/types.d.ts +19 -0
  24. package/dist/docs/types.d.ts.map +1 -0
  25. package/dist/docs/types.js +2 -0
  26. package/dist/docs/types.js.map +1 -0
  27. package/dist/helper.d.ts +14 -0
  28. package/dist/helper.d.ts.map +1 -0
  29. package/dist/helper.js +27 -0
  30. package/dist/helper.js.map +1 -0
  31. package/dist/index.d.ts +8 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +8 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/kind.d.ts +10 -0
  36. package/dist/kind.d.ts.map +1 -0
  37. package/dist/kind.js +12 -0
  38. package/dist/kind.js.map +1 -0
  39. package/dist/plugin.d.ts +10 -0
  40. package/dist/plugin.d.ts.map +1 -0
  41. package/dist/plugin.js +17 -0
  42. package/dist/plugin.js.map +1 -0
  43. package/dist/runtime-client.plugin.d.ts +13 -0
  44. package/dist/runtime-client.plugin.d.ts.map +1 -0
  45. package/dist/runtime-client.plugin.js +27 -0
  46. package/dist/runtime-client.plugin.js.map +1 -0
  47. package/dist/schema.d.ts +32 -0
  48. package/dist/schema.d.ts.map +1 -0
  49. package/dist/schema.js +8 -0
  50. package/dist/schema.js.map +1 -0
  51. package/package.json +61 -0
  52. package/src/base.ts +100 -0
  53. package/src/contract.ts +23 -0
  54. package/src/docs/runtime-client.api.docs.descriptor.ts +346 -0
  55. package/src/docs/runtime-client.helpers.docs.descriptor.ts +354 -0
  56. package/src/docs/runtime-client.surface.docs.descriptor.ts +466 -0
  57. package/src/docs/types.ts +18 -0
  58. package/src/helper.ts +32 -0
  59. package/src/index.ts +11 -0
  60. package/src/kind.ts +14 -0
  61. package/src/plugin.ts +19 -0
  62. package/src/runtime-client.plugin.ts +32 -0
  63. package/src/schema.ts +27 -0
@@ -0,0 +1,464 @@
1
+ /**
2
+ * Descriptor for runtime-client.surface
3
+ * How surfaces (CLI, SSR, browser, worker) initialize runtime clients
4
+ */
5
+ const descriptor = {
6
+ kind: 'docs/topic',
7
+ id: 'runtime-client.surface',
8
+ title: 'Surface Initialization',
9
+ summary: 'How different surfaces (CLI, SSR, browser, worker) initialize runtime clients',
10
+ body: {
11
+ type: 'markdown',
12
+ sourceType: 'raw',
13
+ source: `---
14
+ title: Surface Initialization
15
+ summary: How different surfaces (CLI, SSR, browser, worker) initialize runtime clients
16
+ tags: [runtime-client, surfaces, initialization, cli, ssr, browser, worker]
17
+ parent: runtime-client
18
+ order: 3
19
+ surfaces: [cli, web, in-app]
20
+ hardware: [consumer, cloud]
21
+ ---
22
+
23
+ # Surface Initialization
24
+
25
+ Runtime clients are initialized differently depending on the **surface** (CLI, SSR, browser, worker) and **hardware** (consumer, cloud). This guide covers initialization patterns for each surface type.
26
+
27
+ ## Surface Types
28
+
29
+ The Vibes runtime supports four surface types:
30
+
31
+ | Surface | Description | Typical Use | Hardware |
32
+ |---------|-------------|-------------|----------|
33
+ | \`cli\` | Command-line interface | CLI commands, scripts | consumer |
34
+ | \`ssr\` | Server-side rendering | SvelteKit +page.server.ts | consumer |
35
+ | \`browser\` | Client-side browser | SvelteKit +page.svelte | consumer |
36
+ | \`worker\` | Cloudflare Workers | Edge functions, queues | cloud |
37
+
38
+ Each surface gets its own runtime instance with appropriate scope bindings:
39
+
40
+ \`\`\`ts
41
+ runtime.scope;
42
+ // {
43
+ // surface: 'cli' | 'ssr' | 'browser' | 'worker',
44
+ // hardware: 'consumer' | 'cloud',
45
+ // purpose?: 'direct' | 'embedded'
46
+ // }
47
+ \`\`\`
48
+
49
+ ## CLI Surface
50
+
51
+ ### Bootstrap Flow
52
+
53
+ The CLI bootstrap is defined in \`@vibesdotdev/cli/bootstrap\`:
54
+
55
+ \`\`\`ts
56
+ // packages/cli/src/bootstrap.ts
57
+ import { getVibesRuntime } from '@vibesdotdev/runtime';
58
+ import { CLISurface } from './surface';
59
+
60
+ export async function createVibesCliApp() {
61
+ const runtime = getVibesRuntime();
62
+
63
+ // Set CLI scope
64
+ runtime.setScope({
65
+ surface: 'cli',
66
+ hardware: 'consumer',
67
+ purpose: 'direct'
68
+ });
69
+
70
+ // Register core plugins (order matters)
71
+ await registerCorePlugins(runtime);
72
+
73
+ // Register project plugins
74
+ // ...
75
+
76
+ // Activate plugins (fires onActivate hooks)
77
+ await runtime.activatePlugins();
78
+
79
+ // Create CLI surface
80
+ const cli = new CLISurface(runtime, program);
81
+
82
+ return { runtime, program, cli };
83
+ }
84
+
85
+ async function registerCorePlugins(runtime: VibesRuntime) {
86
+ // Order: context → cli → runtime-client → hooks → logging → runtime.docs
87
+ const runtimeClientPlugin = (
88
+ await import('@vibesdotdev/runtime-client/plugin')
89
+ ).default;
90
+ await runtime.registerPlugin(runtimeClientPlugin);
91
+
92
+ // ... other plugins
93
+ }
94
+ \`\`\`
95
+
96
+ ### Key Points
97
+
98
+ 1. **runtime-client plugin registered early** — Before module plugins (ai, tools, etc.)
99
+ 2. **Plugin activation deferred** — \`activatePlugins()\` fires after all plugins registered
100
+ 3. **Module plugins register loaders** — In \`onActivate()\` hook, they register \`runtime/client\` loaders
101
+
102
+ ### Module Plugin Pattern
103
+
104
+ \`\`\`ts
105
+ // packages/ai/src/ai.plugin.ts
106
+ import { createRuntimePlugin } from '@vibesdotdev/runtime';
107
+
108
+ export const aiPlugin = createRuntimePlugin({
109
+ id: 'ai',
110
+ name: 'AI Module',
111
+ dependencies: ['runtime-client'], // Declare dependency
112
+
113
+ onActivate(runtime) {
114
+ // Register per-id loader for runtime/client kind
115
+ runtime.registerLoader('runtime/client', 'ai', async () => {
116
+ const { AIClient } = await import('./client/ai-client');
117
+ return new AIClient({
118
+ kind: 'runtime/client',
119
+ id: 'ai',
120
+ configManifestId: 'ai/config'
121
+ });
122
+ });
123
+ }
124
+ });
125
+ \`\`\`
126
+
127
+ ### Usage in CLI Commands
128
+
129
+ \`\`\`ts
130
+ // packages/cli/src/commands/ai/generate.ts
131
+ import { getVibesClient } from '@vibesdotdev/runtime-client';
132
+
133
+ export async function generateCommand(options: { prompt: string }) {
134
+ // Resolve client (runtime already bootstrapped by CLI)
135
+ const ai = await getVibesClient('ai');
136
+
137
+ // Generate
138
+ const response = await ai.generate({ prompt: options.prompt });
139
+ console.log(response);
140
+ }
141
+ \`\`\`
142
+
143
+ ## SSR Surface (SvelteKit)
144
+
145
+ ### Bootstrap Flow
146
+
147
+ SSR surfaces bootstrap in SvelteKit's \`hooks.server.ts\`:
148
+
149
+ \`\`\`ts
150
+ // apps/ai-web/src/hooks.server.ts
151
+ import { bootstrapVibesRuntime } from '@vibesdotdev/runtime';
152
+ import { consumerRuntimePlugin } from './runtime/consumer.plugin';
153
+
154
+ export async function handle({ event, resolve }) {
155
+ // Bootstrap runtime once per request (or use singleton)
156
+ await bootstrapVibesRuntime({
157
+ plugins: [consumerRuntimePlugin],
158
+ scope: {
159
+ surface: 'ssr',
160
+ hardware: 'consumer',
161
+ purpose: 'direct'
162
+ }
163
+ });
164
+
165
+ return resolve(event);
166
+ }
167
+ \`\`\`
168
+
169
+ ### Usage in +page.server.ts
170
+
171
+ \`\`\`ts
172
+ // apps/ai-web/src/routes/chat/+page.server.ts
173
+ import { getVibesClient } from '@vibesdotdev/runtime-client';
174
+ import type { PageServerLoad } from './$types';
175
+
176
+ export const load: PageServerLoad = async () => {
177
+ // Resolve client (runtime bootstrapped in hooks.server.ts)
178
+ const ai = await getVibesClient('ai');
179
+
180
+ // Use client
181
+ const models = await ai.listModels();
182
+
183
+ return { models };
184
+ };
185
+ \`\`\`
186
+
187
+ ### SSR-Specific Considerations
188
+
189
+ 1. **Request isolation** — Each request may get its own runtime instance
190
+ 2. **No global state** — Don't store client references in module scope
191
+ 3. **Lazy initialization** — Clients initialize on first use
192
+ 4. **Config loading** — Happens per-request if not cached
193
+
194
+ ## Browser Surface
195
+
196
+ ### Bootstrap Flow
197
+
198
+ Browser surfaces bootstrap in SvelteKit's \`+layout.svelte\` or \`app.html\`:
199
+
200
+ \`\`\`ts
201
+ // apps/ai-web/src/routes/+layout.svelte
202
+ <script lang="ts">
203
+ import { onMount } from 'svelte';
204
+ import { bootstrapVibesRuntime } from '@vibesdotdev/runtime';
205
+ import { browserRuntimePlugin } from '$lib/runtime/browser.plugin';
206
+
207
+ onMount(async () => {
208
+ await bootstrapVibesRuntime({
209
+ plugins: [browserRuntimePlugin],
210
+ scope: {
211
+ surface: 'browser',
212
+ hardware: 'consumer',
213
+ purpose: 'direct'
214
+ }
215
+ });
216
+ });
217
+ </script>
218
+
219
+ <slot />
220
+ \`\`\`
221
+
222
+ ### Usage in +page.svelte
223
+
224
+ \`\`\`ts
225
+ // apps/ai-web/src/routes/chat/+page.svelte
226
+ <script lang="ts">
227
+ import { onMount } from 'svelte';
228
+ import { getVibesClient } from '@vibesdotdev/runtime-client';
229
+ import type { AIClient } from '@vibesdotdev/ai/client';
230
+
231
+ let aiClient: AIClient | null = null;
232
+
233
+ onMount(async () => {
234
+ // Resolve client (runtime bootstrapped in +layout.svelte)
235
+ aiClient = await getVibesClient<AIClient>('ai');
236
+ });
237
+
238
+ async function generate(prompt: string) {
239
+ if (!aiClient) return;
240
+ const response = await aiClient.generate({ prompt });
241
+ // Handle response...
242
+ }
243
+ </script>
244
+
245
+ <button on:click={() => generate('Hello')}>Generate</button>
246
+ \`\`\`
247
+
248
+ ### Browser-Specific Considerations
249
+
250
+ 1. **Client-side only** — Browser surface can't access server-only plugins
251
+ 2. **API boundaries** — Use bridge pattern for server operations
252
+ 3. **Memory constraints** — Dispose clients on unmount if needed
253
+ 4. **Network latency** — Client methods may involve network calls
254
+
255
+ ## Worker Surface (Cloudflare)
256
+
257
+ ### Bootstrap Flow
258
+
259
+ Worker surfaces bootstrap in worker entrypoint:
260
+
261
+ \`\`\`ts
262
+ // workers/jobs/src/entrypoint.ts
263
+ import { bootstrapVibesRuntime } from '@vibesdotdev/runtime';
264
+ import { runtimeClientPlugin } from '@vibesdotdev/runtime-client';
265
+ import { workersPlugin } from '@vibesdotdev/workers';
266
+
267
+ export default {
268
+ async fetch(request, env, ctx) {
269
+ // Bootstrap runtime
270
+ await bootstrapVibesRuntime({
271
+ plugins: [runtimeClientPlugin, workersPlugin],
272
+ scope: {
273
+ surface: 'worker',
274
+ hardware: 'cloud',
275
+ purpose: 'direct'
276
+ },
277
+ env // Cloudflare env bindings
278
+ });
279
+
280
+ // Handle request
281
+ const runtime = getVibesRuntime();
282
+ const workers = await runtime
283
+ .query('runtime/client')
284
+ .withId('workers')
285
+ .resolve();
286
+
287
+ // ...
288
+ }
289
+ };
290
+ \`\`\`
291
+
292
+ ### Worker-Specific Considerations
293
+
294
+ 1. **Cold starts** — First request pays bootstrap cost
295
+ 2. **Stateless** — No persistent memory between requests
296
+ 3. **Env bindings** — Pass Cloudflare env to bootstrap
297
+ 4. **Limited plugins** — Only cloud-compatible plugins work
298
+
299
+ ## Cross-Surface Patterns
300
+
301
+ ### Pattern 1: Surface-Agnostic Services
302
+
303
+ Write services that work in any surface:
304
+
305
+ \`\`\`ts
306
+ // packages/my-lib/src/content-generator.ts
307
+ import { getVibesClient } from '@vibesdotdev/runtime-client';
308
+ import type { AIClient } from '@vibesdotdev/ai/client';
309
+
310
+ export class ContentGenerator {
311
+ async generate(topic: string): Promise<string> {
312
+ // Works in CLI, SSR, browser, worker
313
+ const ai = await getVibesClient<AIClient>('ai');
314
+ return ai.generate({
315
+ prompt: \`Write about \${topic}\`
316
+ });
317
+ }
318
+ }
319
+ \`\`\`
320
+
321
+ ### Pattern 2: Surface Detection
322
+
323
+ Detect current surface via runtime scope:
324
+
325
+ \`\`\`ts
326
+ import { getVibesRuntime } from '@vibesdotdev/runtime';
327
+
328
+ const runtime = getVibesRuntime();
329
+ const { surface, hardware } = runtime.scope;
330
+
331
+ if (surface === 'browser') {
332
+ // Browser-specific logic
333
+ } else if (surface === 'ssr') {
334
+ // SSR-specific logic
335
+ }
336
+ \`\`\`
337
+
338
+ ### Pattern 3: Surface-Specific Implementations
339
+
340
+ Register different implementations per surface:
341
+
342
+ \`\`\`ts
343
+ // packages/storage/src/storage.plugin.ts
344
+ import { createRuntimePlugin } from '@vibesdotdev/runtime';
345
+
346
+ export const storagePlugin = createRuntimePlugin({
347
+ id: 'storage',
348
+ onActivate(runtime) {
349
+ const { surface, hardware } = runtime.scope;
350
+
351
+ if (hardware === 'cloud') {
352
+ // Cloud implementation
353
+ runtime.registerLoader('runtime/client', 'storage', async () => {
354
+ const { CloudStorageClient } = await import('./client/cloud');
355
+ return new CloudStorageClient();
356
+ });
357
+ } else {
358
+ // Consumer implementation
359
+ runtime.registerLoader('runtime/client', 'storage', async () => {
360
+ const { LocalStorageClient } = await import('./client/local');
361
+ return new LocalStorageClient();
362
+ });
363
+ }
364
+ }
365
+ });
366
+ \`\`\`
367
+
368
+ ## WRONG patterns
369
+
370
+ :::card{title="Anti-patterns"}
371
+ - ❌ **Manual runtime instantiation** — Use \`bootstrapVibesRuntime()\` or surface helpers
372
+ - ❌ **Cross-surface state sharing** — Each surface has its own runtime instance
373
+ - ❌ **Storing clients in module scope** — Resolve at call site with \`getVibesClient()\`
374
+ - ❌ **Assuming surface** — Check \`runtime.scope\` if behavior differs
375
+ - ❌ **Skipping plugin activation** — Call \`activatePlugins()\` after registration
376
+ :::
377
+
378
+ ## Example: Multi-surface service
379
+
380
+ \`\`\`ts
381
+ // packages/notification-service/src/index.ts
382
+ import { getVibesRuntime, getVibesClient } from '@vibesdotdev/runtime';
383
+ import type { AIClient } from '@vibesdotdev/ai/client';
384
+
385
+ export class NotificationService {
386
+ async sendNotification(
387
+ userId: string,
388
+ message: string
389
+ ): Promise<void> {
390
+ const runtime = getVibesRuntime();
391
+ const { surface, hardware } = runtime.scope;
392
+
393
+ // Surface-specific notification strategy
394
+ if (surface === 'browser') {
395
+ // Browser: show toast notification
396
+ this.showBrowserNotification(message);
397
+ } else if (surface === 'ssr') {
398
+ // SSR: send email via server
399
+ const ai = await getVibesClient<AIClient>('ai');
400
+ const emailBody = await ai.generate({
401
+ prompt: \`Write email: \${message}\`
402
+ });
403
+ await this.sendEmail(userId, emailBody);
404
+ } else if (surface === 'worker') {
405
+ // Worker: queue notification job
406
+ await this.queueNotification(userId, message);
407
+ }
408
+ }
409
+
410
+ private showBrowserNotification(message: string) {
411
+ // Browser-specific: toast, badge, etc.
412
+ }
413
+
414
+ private async sendEmail(userId: string, body: string) {
415
+ // SSR-specific: email service
416
+ }
417
+
418
+ private async queueNotification(userId: string, message: string) {
419
+ // Worker-specific: job queue
420
+ }
421
+ }
422
+ \`\`\`
423
+
424
+ ## Code paths
425
+
426
+ - CLI bootstrap: [\`packages/cli/src/bootstrap.ts\`](https://github.com/vibesdotdev/monorepo/tree/main/packages/cli/src/bootstrap.ts)
427
+ - Runtime bootstrap: [\`packages/runtime/src/bootstrap/index.ts\`](https://github.com/vibesdotdev/monorepo/tree/main/packages/runtime/src/bootstrap/index.ts)
428
+ - Helper: [\`packages/runtime-client/src/helper.ts\`](https://github.com/vibesdotdev/monorepo/tree/main/packages/runtime-client/src/helper.ts)
429
+ - Plugin: [\`packages/runtime-client/src/plugin.ts\`](https://github.com/vibesdotdev/monorepo/tree/main/packages/runtime-client/src/plugin.ts)
430
+
431
+ :::card{title="See also"}
432
+ - [\`runtime-client.api\`](runtime-client.api) — BaseRuntimeClient and extension patterns
433
+ - [\`runtime-client.helpers\`](runtime-client.helpers) — getVibesClient() helper functions
434
+ - [\`runtime.scopes\`](runtime.scopes) — Consumer vs cloud scopes
435
+ - [\`bootstrapVibesRuntime\`](bootstrap) — Runtime bootstrap API
436
+ :::
437
+ `
438
+ },
439
+ parent: 'runtime-client',
440
+ order: 3,
441
+ tags: ['runtime-client', 'surfaces', 'initialization', 'cli', 'ssr', 'browser', 'worker'],
442
+ surfaces: ['cli', 'web', 'in-app'],
443
+ hardware: ['consumer', 'cloud'],
444
+ enabled: true,
445
+ man: {
446
+ name: 'runtime-client.surface — surface initialization patterns',
447
+ section: 1,
448
+ synopsis: 'vibes man runtime-client.surface',
449
+ options: [],
450
+ examples: [
451
+ {
452
+ description: 'CLI surface bootstrap',
453
+ command: 'await createVibesCliApp()'
454
+ },
455
+ {
456
+ description: 'SSR surface in SvelteKit',
457
+ command: 'await bootstrapVibesRuntime({ scope: { surface: "ssr" } })'
458
+ }
459
+ ],
460
+ seeAlso: ['runtime-client.api', 'runtime-client.helpers', 'runtime.scopes']
461
+ }
462
+ };
463
+ export default descriptor;
464
+ //# sourceMappingURL=runtime-client.surface.docs.descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-client.surface.docs.descriptor.js","sourceRoot":"","sources":["../../src/docs/runtime-client.surface.docs.descriptor.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,GAAwB;IACtC,IAAI,EAAE,YAAY;IAClB,EAAE,EAAE,wBAAwB;IAC5B,KAAK,EAAE,wBAAwB;IAC/B,OAAO,EAAE,+EAA+E;IACxF,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwaX;KACE;IACD,MAAM,EAAE,gBAAgB;IACxB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC;IACzF,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC;IAClC,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE,IAAI;IACb,GAAG,EAAE;QACH,IAAI,EAAE,0DAA0D;QAChE,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,kCAAkC;QAC5C,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE;YACR;gBACE,WAAW,EAAE,uBAAuB;gBACpC,OAAO,EAAE,2BAA2B;aACrC;YACD;gBACE,WAAW,EAAE,0BAA0B;gBACvC,OAAO,EAAE,4DAA4D;aACtE;SACF;QACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,wBAAwB,EAAE,gBAAgB,CAAC;KAC5E;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type DocsTopicDescriptor = {
2
+ kind: 'docs/topic';
3
+ id: string;
4
+ title: string;
5
+ summary?: string;
6
+ body: {
7
+ type: 'markdown';
8
+ sourceType: 'raw';
9
+ source: string;
10
+ };
11
+ parent?: string;
12
+ order?: number;
13
+ enabled?: boolean;
14
+ man?: unknown;
15
+ tags?: string[];
16
+ surfaces?: string[];
17
+ hardware?: string[];
18
+ };
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QACL,IAAI,EAAE,UAAU,CAAC;QACjB,UAAU,EAAE,KAAK,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/docs/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { RuntimeClient } from './contract.ts';
2
+ /**
3
+ * Ambient helper to resolve a module-level client by id.
4
+ *
5
+ * ```ts
6
+ * const ai = await getVibesClient<AIClient>('ai');
7
+ * const response = await ai.generate({ prompt: 'Hello' });
8
+ * ```
9
+ *
10
+ * Equivalent to calling `runtime.query('runtime/client').withId(id).resolve()`
11
+ * on the ambient runtime, with a clearer error when the client isn't registered.
12
+ */
13
+ export declare function getVibesClient<T extends RuntimeClient = RuntimeClient>(id: string): Promise<T>;
14
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAC3E,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,CAAC,CAAC,CAcZ"}
package/dist/helper.js ADDED
@@ -0,0 +1,27 @@
1
+ import { getVibesRuntime } from '@vibesdotdev/runtime';
2
+ import { runtimeClientPlugin } from "./plugin.js";
3
+ /**
4
+ * Ambient helper to resolve a module-level client by id.
5
+ *
6
+ * ```ts
7
+ * const ai = await getVibesClient<AIClient>('ai');
8
+ * const response = await ai.generate({ prompt: 'Hello' });
9
+ * ```
10
+ *
11
+ * Equivalent to calling `runtime.query('runtime/client').withId(id).resolve()`
12
+ * on the ambient runtime, with a clearer error when the client isn't registered.
13
+ */
14
+ export async function getVibesClient(id) {
15
+ const runtime = getVibesRuntime();
16
+ if (!runtime.hasKind('runtime/client')) {
17
+ await runtime.registerPlugin(runtimeClientPlugin);
18
+ }
19
+ const client = await runtime.query('runtime/client').withId(id).resolve();
20
+ if (!client) {
21
+ throw new Error(`No runtime client registered with id "${id}". ` +
22
+ `Compose the owning module's plugin (e.g. aiPlugin for id="ai") before use, ` +
23
+ `and ensure runtimeClientPlugin is registered.`);
24
+ }
25
+ return client;
26
+ }
27
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,EAAU;IAEV,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACxC,MAAM,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1E,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACd,yCAAyC,EAAE,KAAK;YAC/C,6EAA6E;YAC7E,+CAA+C,CAChD,CAAC;IACH,CAAC;IACD,OAAO,MAAW,CAAC;AACpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { runtimeClientPlugin } from './plugin.ts';
2
+ export { runtimeClientKind } from './kind.ts';
3
+ export { BaseRuntimeClient } from './base.ts';
4
+ export { getVibesClient } from './helper.ts';
5
+ export type { RuntimeClient } from './contract.ts';
6
+ export type { RuntimeClientDescriptor } from './schema.ts';
7
+ export { RuntimeClientDescriptorSchema } from './schema.ts';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // @vibesdotdev/runtime-client
2
+ // One-client-per-module pattern: shared base, kind, and resolver helper.
3
+ export { runtimeClientPlugin } from "./plugin.js";
4
+ export { runtimeClientKind } from "./kind.js";
5
+ export { BaseRuntimeClient } from "./base.js";
6
+ export { getVibesClient } from "./helper.js";
7
+ export { RuntimeClientDescriptorSchema } from "./schema.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,yEAAyE;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC"}
package/dist/kind.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { RuntimeKindDescriptorRecord } from '@vibesdotdev/runtime';
2
+ import type { RuntimeClient } from './contract.ts';
3
+ /**
4
+ * `runtime/client` kind descriptor record.
5
+ *
6
+ * No `defaultImplementation` — each module registers its own class via a
7
+ * per-descriptor loader (see `runtime.registerLoader('runtime/client', '<id>', …)`).
8
+ */
9
+ export declare const runtimeClientKind: RuntimeKindDescriptorRecord<RuntimeClient>;
10
+ //# sourceMappingURL=kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../src/kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CAAC,aAAa,CAGxE,CAAC"}
package/dist/kind.js ADDED
@@ -0,0 +1,12 @@
1
+ import { RuntimeClientDescriptorSchema } from "./schema.js";
2
+ /**
3
+ * `runtime/client` kind descriptor record.
4
+ *
5
+ * No `defaultImplementation` — each module registers its own class via a
6
+ * per-descriptor loader (see `runtime.registerLoader('runtime/client', '<id>', …)`).
7
+ */
8
+ export const runtimeClientKind = {
9
+ id: 'runtime/client',
10
+ descriptorSchema: RuntimeClientDescriptorSchema
11
+ };
12
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../src/kind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAG5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA+C;IAC5E,EAAE,EAAE,gBAAgB;IACpB,gBAAgB,EAAE,6BAA6B;CAC/C,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Registers the `runtime/client` kind.
3
+ *
4
+ * Compose this plugin once at app bootstrap. Module plugins (ai, tools,
5
+ * knowledge, …) declare `dependencies: ['runtime-client', …]` and register
6
+ * their per-id loaders in their `onRegister` hook.
7
+ */
8
+ export declare const runtimeClientPlugin: import("@vibesdotdev/runtime").RuntimePlugin;
9
+ export default runtimeClientPlugin;
10
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,8CAM9B,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,17 @@
1
+ import { createRuntimePlugin } from '@vibesdotdev/runtime';
2
+ import { runtimeClientKind } from "./kind.js";
3
+ /**
4
+ * Registers the `runtime/client` kind.
5
+ *
6
+ * Compose this plugin once at app bootstrap. Module plugins (ai, tools,
7
+ * knowledge, …) declare `dependencies: ['runtime-client', …]` and register
8
+ * their per-id loaders in their `onRegister` hook.
9
+ */
10
+ export const runtimeClientPlugin = createRuntimePlugin({
11
+ id: 'runtime-client',
12
+ name: 'Runtime Client',
13
+ description: 'Shared `runtime/client` kind. Each module registers one descriptor; consumers resolve via `runtime.query(\"runtime/client\").withId(\"ai\")`.',
14
+ kinds: [runtimeClientKind]
15
+ });
16
+ export default runtimeClientPlugin;
17
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;IACtD,EAAE,EAAE,gBAAgB;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACV,+IAA+I;IAChJ,KAAK,EAAE,CAAC,iBAAiB,CAAC;CAC1B,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Runtime Client Docs Plugin
3
+ *
4
+ * Registers documentation descriptors for runtime-client APIs:
5
+ * - runtime-client.api — BaseRuntimeClient class, client patterns, how to extend
6
+ * - runtime-client.helpers — getVibesClient() helper functions, surface detection
7
+ * - runtime-client.surface — How surfaces (CLI, SSR, browser, worker) initialize clients
8
+ *
9
+ * This plugin is surface-neutral — docs descriptors work in CLI, SSR, and worker contexts.
10
+ */
11
+ export declare const runtimeClientDocsPlugin: import("@vibesdotdev/runtime").RuntimePlugin;
12
+ export default runtimeClientDocsPlugin;
13
+ //# sourceMappingURL=runtime-client.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-client.plugin.d.ts","sourceRoot":"","sources":["../src/runtime-client.plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,eAAO,MAAM,uBAAuB,8CAWlC,CAAC;AAEH,eAAe,uBAAuB,CAAC"}