@vibevibes/runtime 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Experience bundler — produces server and client bundles from src/index.tsx.
3
+ *
4
+ * Server bundle: CJS, eval'd via new Function() to extract tools + manifest.
5
+ * Client bundle: ESM, loaded in browser via blob URL + dynamic import().
6
+ *
7
+ * Extracted from create-experience/runtime/bundler.ts into @vibevibes/runtime.
8
+ */
9
+ /**
10
+ * Bundle for server-side tool execution (Node.js eval).
11
+ * Returns the raw ExperienceModule extracted via new Function().
12
+ */
13
+ export declare function bundleForServer(entryPath: string): Promise<string>;
14
+ /**
15
+ * Evaluate a server bundle and extract the ExperienceModule.
16
+ */
17
+ export declare function evalServerBundle(serverCode: string): Promise<unknown>;
18
+ /**
19
+ * Bundle for client-side Canvas rendering (browser eval).
20
+ * Returns ESM source string that can be loaded via blob URL + dynamic import().
21
+ */
22
+ export declare function bundleForClient(entryPath: string): Promise<string>;
23
+ /**
24
+ * Build both bundles from an entry file.
25
+ */
26
+ export declare function buildExperience(entryPath: string): Promise<{
27
+ serverCode: string;
28
+ clientCode: string;
29
+ }>;
30
+ /**
31
+ * Validate a client bundle for common issues that would crash at runtime.
32
+ * Checks: syntax errors (SyntaxError), duplicate declarations, unresolved numbered references.
33
+ * Returns null if OK, or an error message string.
34
+ */
35
+ export declare function validateClientBundle(code: string): string | null;
36
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsKH;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmDxE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmC3E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyFxE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAM5G;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+ChE"}
@@ -0,0 +1,365 @@
1
+ /**
2
+ * Experience bundler — produces server and client bundles from src/index.tsx.
3
+ *
4
+ * Server bundle: CJS, eval'd via new Function() to extract tools + manifest.
5
+ * Client bundle: ESM, loaded in browser via blob URL + dynamic import().
6
+ *
7
+ * Extracted from create-experience/runtime/bundler.ts into @vibevibes/runtime.
8
+ */
9
+ import * as esbuild from "esbuild";
10
+ const EXTERNALS = ["react", "react/jsx-runtime", "react-dom", "react-dom/client", "yjs", "zod", "@vibevibes/sdk"];
11
+ // Additional externals for server-only bundles — heavy rendering libraries that
12
+ // aren't needed for tool/test execution. Canvas components are never called server-side.
13
+ const SERVER_ONLY_EXTERNALS = [
14
+ ...EXTERNALS,
15
+ "three", "three/*",
16
+ "@react-three/fiber", "@react-three/fiber/*",
17
+ "@react-three/drei", "@react-three/drei/*",
18
+ ];
19
+ /**
20
+ * Strip esbuild's CJS annotation: `0 && (module.exports = {...})`.
21
+ * Uses brace-depth counting to handle nested objects/functions in the annotation,
22
+ * unlike a simple `[^}]*` regex which breaks on nested braces.
23
+ */
24
+ function stripCjsAnnotation(code) {
25
+ const marker = /0\s*&&\s*\(module\.exports\s*=\s*\{/g;
26
+ let match;
27
+ let result = code;
28
+ while ((match = marker.exec(code)) !== null) {
29
+ const start = match.index;
30
+ let depth = 1; // we matched the opening `{`
31
+ let i = match.index + match[0].length;
32
+ while (i < code.length && depth > 0) {
33
+ if (code[i] === "{")
34
+ depth++;
35
+ else if (code[i] === "}")
36
+ depth--;
37
+ i++;
38
+ }
39
+ // Skip the closing `)` and optional `;`
40
+ if (i < code.length && code[i] === ")")
41
+ i++;
42
+ if (i < code.length && code[i] === ";")
43
+ i++;
44
+ result = result.slice(0, start) + "/* [vibevibes] stripped CJS annotation */" + result.slice(i);
45
+ break; // Only one annotation per bundle
46
+ }
47
+ return result;
48
+ }
49
+ /**
50
+ * Strip import/export statements for external packages.
51
+ * The runtime provides these via globalThis (browser) or function args (server).
52
+ */
53
+ function stripExternalImports(code, externals = EXTERNALS) {
54
+ let result = code;
55
+ for (const ext of externals) {
56
+ // Handle wildcard patterns like "three/*" → match "three/anything"
57
+ let escaped;
58
+ if (ext.endsWith("/*")) {
59
+ const base = ext.slice(0, -2).replace(/[.*+?^${}()|[\]\\\/]/g, "\\$&");
60
+ escaped = `${base}\\/[^"']+`;
61
+ }
62
+ else {
63
+ escaped = ext.replace(/[.*+?^${}()|[\]\\\/]/g, "\\$&");
64
+ }
65
+ // ESM: import X from "pkg"; or import { X } from "pkg";
66
+ result = result.replace(new RegExp(`import\\s+[^;]*?from\\s+["']${escaped}["'];?`, "g"), "");
67
+ // Type-only imports
68
+ result = result.replace(new RegExp(`import\\s+type\\s+[^;]*?from\\s+["']${escaped}["'];?`, "g"), "");
69
+ // CJS: var import_X = __toESM(require("pkg"), N); or var import_X = require("pkg");
70
+ // Match the entire statement including optional __toESM wrapper and trailing args.
71
+ // Uses [^;]{0,500} instead of [\s\S]*? to prevent O(n²) backtracking on large bundles
72
+ // while still handling multi-line __toESM() calls (500 chars is more than enough).
73
+ result = result.replace(new RegExp(`var\\s+\\w+\\s*=\\s*(?:__toESM\\()?require\\(["']${escaped}["']\\)[^;]{0,500};`, "g"), "");
74
+ }
75
+ return result;
76
+ }
77
+ /**
78
+ * Base CJS shim definitions for esbuild-generated variable references.
79
+ * esbuild uses the last path segment: "react" → import_react, "zod" → import_zod, etc.
80
+ */
81
+ const SDK_CORE_SHIM = "{ defineExperience: defineExperience, defineTool: defineTool, defineTest: defineTest, defineStream: defineStream, createChatTools: createChatTools, default: { defineExperience: defineExperience, defineTool: defineTool, defineTest: defineTest, defineStream: defineStream, createChatTools: createChatTools } }";
82
+ const CJS_BASE_SHIMS = {
83
+ import_react: "{ default: React, __esModule: true, createElement: React.createElement, Fragment: React.Fragment, useState: React.useState, useEffect: React.useEffect, useCallback: React.useCallback, useMemo: React.useMemo, useRef: React.useRef, useContext: React.useContext, useReducer: React.useReducer, createContext: React.createContext, forwardRef: React.forwardRef, memo: React.memo }",
84
+ import_zod: "{ z: z, default: z }",
85
+ import_yjs: "{ default: Y }",
86
+ import_sdk: SDK_CORE_SHIM,
87
+ import_vibevibes_sdk: SDK_CORE_SHIM,
88
+ // react-dom stubs (R3F imports react-dom; esbuild generates import_react_dom / import_client)
89
+ import_react_dom: "{ default: {}, __esModule: true, createRoot: function(){}, flushSync: function(fn){ if(fn) fn(); } }",
90
+ import_client: "{ default: {}, __esModule: true, createRoot: function(){}, flushSync: function(fn){ if(fn) fn(); } }",
91
+ // Stubs for heavy rendering libraries (server-side only — Canvas is never called)
92
+ import_three: "(new Proxy({}, { get: (_, p) => typeof p === 'string' ? function(){} : undefined }))",
93
+ import_fiber: "(new Proxy({}, { get: (_, p) => typeof p === 'string' ? function(){} : undefined }))",
94
+ import_drei: "(new Proxy({}, { get: (_, p) => typeof p === 'string' ? function(){} : undefined }))",
95
+ };
96
+ /**
97
+ * Inject CJS shim variables so that esbuild's generated references resolve correctly.
98
+ * When multiple files import the same external, esbuild creates numbered variants
99
+ * (import_react2, import_react3, etc). We detect those and alias them to the base shim.
100
+ */
101
+ function injectCjsShims(code) {
102
+ const lines = [];
103
+ // Emit base shims
104
+ for (const [name, value] of Object.entries(CJS_BASE_SHIMS)) {
105
+ lines.push(`var ${name} = ${value};`);
106
+ }
107
+ // Scan for numbered variants (e.g. import_react2, import_zod3) and alias them
108
+ for (const baseName of Object.keys(CJS_BASE_SHIMS)) {
109
+ const pattern = new RegExp(`\\b(${baseName}(\\d+))\\b`, "g");
110
+ const seen = new Set();
111
+ let match;
112
+ while ((match = pattern.exec(code)) !== null) {
113
+ const numberedName = match[1];
114
+ if (!seen.has(numberedName)) {
115
+ seen.add(numberedName);
116
+ lines.push(`var ${numberedName} = ${baseName};`);
117
+ }
118
+ }
119
+ }
120
+ return lines.join("\n");
121
+ }
122
+ /**
123
+ * Format esbuild errors into actionable messages with file:line and suggestions.
124
+ */
125
+ function formatEsbuildError(err, target) {
126
+ const buildErr = err;
127
+ if (buildErr.errors && Array.isArray(buildErr.errors)) {
128
+ const formatted = buildErr.errors.map((e) => {
129
+ const loc = e.location
130
+ ? `${e.location.file}:${e.location.line}:${e.location.column}`
131
+ : "unknown location";
132
+ return ` ${loc}: ${e.text}`;
133
+ }).join("\n");
134
+ return new Error(`Build failed (${target} bundle):\n${formatted}\n\n` +
135
+ `Common fixes:\n` +
136
+ `- Check for syntax errors at the indicated location\n` +
137
+ `- Ensure all imports resolve to existing files in src/\n` +
138
+ `- Verify @vibevibes/sdk imports match the available exports`);
139
+ }
140
+ return err instanceof Error ? err : new Error(String(err));
141
+ }
142
+ /**
143
+ * Bundle for server-side tool execution (Node.js eval).
144
+ * Returns the raw ExperienceModule extracted via new Function().
145
+ */
146
+ export async function bundleForServer(entryPath) {
147
+ let result;
148
+ try {
149
+ result = await esbuild.build({
150
+ entryPoints: [entryPath],
151
+ bundle: true,
152
+ format: "cjs",
153
+ platform: "node",
154
+ target: "es2022",
155
+ write: false,
156
+ external: SERVER_ONLY_EXTERNALS,
157
+ jsx: "transform",
158
+ jsxFactory: "React.createElement",
159
+ jsxFragment: "React.Fragment",
160
+ logLevel: "silent",
161
+ });
162
+ }
163
+ catch (err) {
164
+ throw formatEsbuildError(err, "server");
165
+ }
166
+ const outputFile = result.outputFiles?.[0];
167
+ if (!outputFile)
168
+ throw new Error("esbuild produced no output files for server bundle");
169
+ let code = outputFile.text;
170
+ code = stripExternalImports(code, SERVER_ONLY_EXTERNALS);
171
+ // Strip user-code React hook destructuring (already provided by CJS shims)
172
+ code = code.replace(/(?:const|let|var)\s+\{[^}]*?\b(?:useState|useEffect|useCallback|useMemo|useRef|useContext|useReducer)\b[^}]*?\}\s*=\s*(?:React|import_react\w*)\s*;/g, "/* [vibevibes] stripped duplicate React destructuring */");
173
+ // Inject CJS shims for esbuild-generated variable references
174
+ // Pass code so we can detect numbered variants (import_react2, etc.)
175
+ code = injectCjsShims(code) + "\n" + code;
176
+ // Strip esbuild's CJS annotation `0 && (module.exports = {...})` — dead code that
177
+ // causes syntax errors when module.exports is replaced with var assignment.
178
+ // Uses brace-depth counting to handle nested objects/functions in the annotation.
179
+ code = stripCjsAnnotation(code);
180
+ // Replace module.exports/export default with variable assignment
181
+ code = code.replace(/module\.exports\s*=\s*/g, "var __experience_export__ = ");
182
+ code = code.replace(/exports\.default(?!\w)\s*=\s*/g, "var __experience_export__ = ");
183
+ return code;
184
+ }
185
+ /**
186
+ * Evaluate a server bundle and extract the ExperienceModule.
187
+ */
188
+ export async function evalServerBundle(serverCode) {
189
+ const sdk = await import("@vibevibes/sdk");
190
+ const { defineExperience, defineTool, defineTest, defineStream, createChatTools } = sdk;
191
+ const noop = () => null;
192
+ const stubReact = {
193
+ createElement: noop, Fragment: "Fragment",
194
+ useState: (init) => [typeof init === "function" ? init() : init, noop],
195
+ useEffect: noop, useCallback: (fn) => fn,
196
+ useMemo: (fn) => fn(), useRef: (init) => ({ current: init ?? null }),
197
+ useContext: noop, useReducer: noop,
198
+ createContext: noop, forwardRef: noop, memo: (x) => x,
199
+ };
200
+ const zodModule = await import("zod");
201
+ const z = zodModule.z ?? zodModule.default ?? zodModule;
202
+ const fn = new Function("globalThis", "process", "global", "React", "Y", "z", "defineExperience", "defineTool", "defineTest", "defineStream", "createChatTools", "require", "exports", "module", "console", `"use strict";\n${serverCode}\nreturn typeof __experience_export__ !== 'undefined' ? __experience_export__ : (typeof module !== 'undefined' ? module.exports : undefined);`);
203
+ const fakeModule = { exports: {} };
204
+ const sandboxGlobal = Object.create(null);
205
+ const sandboxProcess = { env: { NODE_ENV: "production" } };
206
+ const result = fn(sandboxGlobal, sandboxProcess, sandboxGlobal, stubReact, {}, z, defineExperience, defineTool, defineTest, defineStream, createChatTools, (id) => { throw new Error(`require('${id}') is not supported in the vibevibes server sandbox. Add '${id}' to EXTERNALS in bundler.ts.`); }, fakeModule.exports, fakeModule, console);
207
+ const exports = fakeModule.exports;
208
+ return result?.default ?? result ?? exports?.default ?? exports;
209
+ }
210
+ /**
211
+ * Bundle for client-side Canvas rendering (browser eval).
212
+ * Returns ESM source string that can be loaded via blob URL + dynamic import().
213
+ */
214
+ export async function bundleForClient(entryPath) {
215
+ let result;
216
+ try {
217
+ result = await esbuild.build({
218
+ entryPoints: [entryPath],
219
+ bundle: true,
220
+ format: "esm",
221
+ platform: "browser",
222
+ target: "es2020",
223
+ write: false,
224
+ external: EXTERNALS,
225
+ jsx: "transform",
226
+ jsxFactory: "React.createElement",
227
+ jsxFragment: "React.Fragment",
228
+ logLevel: "silent",
229
+ });
230
+ }
231
+ catch (err) {
232
+ throw formatEsbuildError(err, "client");
233
+ }
234
+ const clientOutputFile = result.outputFiles?.[0];
235
+ if (!clientOutputFile)
236
+ throw new Error("esbuild produced no output files for client bundle");
237
+ let code = clientOutputFile.text;
238
+ code = stripExternalImports(code);
239
+ // Strip user-code React hook destructuring that would collide with injected globals.
240
+ code = code.replace(/(?:const|let|var)\s+\{[^}]*?\b(?:useState|useEffect|useCallback|useMemo|useRef|useContext|useReducer)\b[^}]*?\}\s*=\s*React\d*\s*;/g, "/* [vibevibes] stripped duplicate React destructuring */");
241
+ // Inject globalThis accessors at the top
242
+ const baseGlobals = `
243
+ const React = globalThis.React;
244
+ const ReactDOM = globalThis.ReactDOM || {};
245
+ const { useState, useEffect, useCallback, useMemo, useRef, useContext, useReducer, createContext, forwardRef, memo, Fragment, createElement } = React;
246
+ // JSX Runtime (used when esbuild generates jsx-runtime imports)
247
+ function jsx(type, props, key) {
248
+ const { children, ...rest } = props || {};
249
+ if (key !== undefined) rest.key = key;
250
+ return Array.isArray(children)
251
+ ? createElement(type, rest, ...children)
252
+ : children !== undefined
253
+ ? createElement(type, rest, children)
254
+ : createElement(type, rest);
255
+ }
256
+ function jsxs(type, props, key) { return jsx(type, props, key); }
257
+ function jsxDEV(type, props, key) { return jsx(type, props, key); }
258
+ const Y = globalThis.Y || {};
259
+ const z = globalThis.z;
260
+ const defineExperience = globalThis.defineExperience || ((m) => m);
261
+ const defineTool = globalThis.defineTool || ((c) => ({ risk: "low", capabilities_required: [], ...c }));
262
+ const defineTest = globalThis.defineTest || ((c) => c);
263
+ const defineStream = globalThis.defineStream || ((c) => c);
264
+ const createChatTools = globalThis.createChatTools || (() => []);
265
+ `;
266
+ // When multiple files import the same external, esbuild ESM creates numbered
267
+ // variable references (React2, z2, etc). Alias them back to the base global.
268
+ const esmAliases = {};
269
+ {
270
+ const constAssign = /\bconst\s+(\w+)\s*=/g;
271
+ const constDestructure = /\bconst\s+\{([^}]+)\}/g;
272
+ const funcDecl = /\bfunction\s+(\w+)\s*\(/g;
273
+ let m;
274
+ while ((m = constAssign.exec(baseGlobals)) !== null)
275
+ esmAliases[m[1]] = m[1];
276
+ while ((m = constDestructure.exec(baseGlobals)) !== null) {
277
+ for (const name of m[1].split(",").map(s => s.trim()).filter(Boolean)) {
278
+ esmAliases[name] = name;
279
+ }
280
+ }
281
+ while ((m = funcDecl.exec(baseGlobals)) !== null)
282
+ esmAliases[m[1]] = m[1];
283
+ }
284
+ const aliasLines = [];
285
+ for (const [baseName, target] of Object.entries(esmAliases)) {
286
+ const pattern = new RegExp(`\\b(${baseName}(\\d+))\\b`, "g");
287
+ const seen = new Set();
288
+ let match;
289
+ while ((match = pattern.exec(code)) !== null) {
290
+ const numbered = match[1];
291
+ if (!seen.has(numbered)) {
292
+ seen.add(numbered);
293
+ aliasLines.push(`const ${numbered} = ${target};`);
294
+ }
295
+ }
296
+ }
297
+ return baseGlobals + aliasLines.join("\n") + "\n" + code;
298
+ }
299
+ /**
300
+ * Build both bundles from an entry file.
301
+ */
302
+ export async function buildExperience(entryPath) {
303
+ const [serverCode, clientCode] = await Promise.all([
304
+ bundleForServer(entryPath),
305
+ bundleForClient(entryPath),
306
+ ]);
307
+ return { serverCode, clientCode };
308
+ }
309
+ /**
310
+ * Validate a client bundle for common issues that would crash at runtime.
311
+ * Checks: syntax errors (SyntaxError), duplicate declarations, unresolved numbered references.
312
+ * Returns null if OK, or an error message string.
313
+ */
314
+ export function validateClientBundle(code) {
315
+ // 1. Syntax check — strip ESM exports so new Function() can parse it
316
+ const cleaned = code
317
+ .replace(/\bexport\s*\{[^}]*\}/g, "")
318
+ .replace(/\bexport\s+default\s+/g, "var __default = ")
319
+ .replace(/\bexport\s+(const|let|var|function|class)\s/g, "$1 ");
320
+ try {
321
+ new Function(cleaned);
322
+ }
323
+ catch (err) {
324
+ return `SyntaxError in client bundle: ${err.message}\n\nThis usually means:\n- A duplicate variable declaration (check for conflicting imports)\n- Invalid JSX syntax in your Canvas component\n\nTry: npm run build to see the full error with file locations.`;
325
+ }
326
+ // 2. Unresolved numbered references check — only for known SDK/React globals.
327
+ // Large bundles (e.g. with Three.js inlined) have many naturally numbered
328
+ // variables (vec2, mat3, port1) that trigger false positives. We only check
329
+ // names that actually come from the SDK/React global injection.
330
+ const KNOWN_BASES = new Set([
331
+ "React", "useState", "useEffect", "useCallback", "useMemo", "useRef",
332
+ "useContext", "useReducer", "createContext", "forwardRef", "memo",
333
+ "Fragment", "createElement", "defineExperience", "defineTool", "defineTest",
334
+ "defineStream", "createChatTools", "jsx", "jsxs", "jsxDEV",
335
+ ]);
336
+ const definedNames = new Set();
337
+ const lines = code.split("\n");
338
+ for (const line of lines) {
339
+ let m;
340
+ if ((m = line.match(/\b(?:const|let|var)\s+(\w+)\s*=/)))
341
+ definedNames.add(m[1]);
342
+ if ((m = line.match(/\bfunction\s+(\w+)\s*\(/)))
343
+ definedNames.add(m[1]);
344
+ if ((m = line.match(/\b(?:const|let|var)\s+\{([^}]+)\}/))) {
345
+ for (const n of m[1].split(",").map((s) => s.trim()).filter(Boolean))
346
+ definedNames.add(n);
347
+ }
348
+ }
349
+ const refPattern = /\b([A-Za-z_]\w*?)(\d+)\b/g;
350
+ const unresolved = [];
351
+ let match;
352
+ while ((match = refPattern.exec(code)) !== null) {
353
+ const numbered = match[0];
354
+ const base = match[1];
355
+ if (!definedNames.has(numbered) && KNOWN_BASES.has(base)) {
356
+ if (!unresolved.includes(numbered))
357
+ unresolved.push(numbered);
358
+ }
359
+ }
360
+ if (unresolved.length > 0) {
361
+ return `Unresolved references (will crash at runtime): ${unresolved.join(", ")}\n\nCommon cause: multiple files import the same function from @vibevibes/sdk, creating numbered variants (e.g. useState2).\nFix: Import from @vibevibes/sdk once per file. Don't re-export React hooks.`;
362
+ }
363
+ return null;
364
+ }
365
+ //# sourceMappingURL=bundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAElH,gFAAgF;AAChF,yFAAyF;AACzF,MAAM,qBAAqB,GAAG;IAC5B,GAAG,SAAS;IACZ,OAAO,EAAE,SAAS;IAClB,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;CAC3C,CAAC;AAEF;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACtC,MAAM,MAAM,GAAG,sCAAsC,CAAC;IACtD,IAAI,KAA6B,CAAC;IAClC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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AK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,kDAAkD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,0MAA0M,CAAC;IAC3R,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @vibevibes/runtime — server engine for vibevibes experiences.
3
+ *
4
+ * Provides the runtime server (rooms, state, tools, WebSocket, bundler)
5
+ * that powers local dev and will power the hosted platform.
6
+ *
7
+ * Re-exports @vibevibes/sdk so experience authors only need one package.
8
+ */
9
+ export { startServer, setPublicUrl, getBaseUrl, setProjectRoot } from "./server.js";
10
+ export type { ServerConfig } from "./server.js";
11
+ export { bundleForServer, bundleForClient, evalServerBundle, buildExperience, validateClientBundle } from "./bundler.js";
12
+ export { TickEngine } from "./tick-engine.js";
13
+ export type { TickRoom, TickExperience } from "./tick-engine.js";
14
+ export { defineExperience, defineTool, defineTest, defineStream, createChatTools } from "@vibevibes/sdk";
15
+ export type { ToolDef, ToolCtx, ToolRisk, ToolEvent, CanvasProps, ExperienceModule, ExperienceManifest, StreamDef, TestDef, TestHelpers, AgentSlot, ParticipantSlot, ParticipantDetail, RoomConfigDef, SpawnRoomOpts, SpawnRoomResult, ZodFactory, CallToolFn, } from "@vibevibes/sdk";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzG,YAAY,EACV,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EACrC,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EACjD,SAAS,EAAE,OAAO,EAAE,WAAW,EAC/B,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAC7C,aAAa,EAAE,aAAa,EAAE,eAAe,EAC7C,UAAU,EAAE,UAAU,GACvB,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @vibevibes/runtime — server engine for vibevibes experiences.
3
+ *
4
+ * Provides the runtime server (rooms, state, tools, WebSocket, bundler)
5
+ * that powers local dev and will power the hosted platform.
6
+ *
7
+ * Re-exports @vibevibes/sdk so experience authors only need one package.
8
+ */
9
+ // Runtime
10
+ export { startServer, setPublicUrl, getBaseUrl, setProjectRoot } from "./server.js";
11
+ export { bundleForServer, bundleForClient, evalServerBundle, buildExperience, validateClientBundle } from "./bundler.js";
12
+ export { TickEngine } from "./tick-engine.js";
13
+ // Re-export SDK
14
+ export { defineExperience, defineTool, defineTest, defineStream, createChatTools } from "@vibevibes/sdk";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,UAAU;AACV,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Protocol experience support.
3
+ *
4
+ * Loads experiences defined as manifest.json + subprocess tool handler.
5
+ * The subprocess communicates via newline-delimited JSON over stdin/stdout.
6
+ */
7
+ import type { ExperienceModule } from "@vibevibes/sdk";
8
+ export interface ProtocolManifest {
9
+ id: string;
10
+ version: string;
11
+ title: string;
12
+ description?: string;
13
+ initialState?: Record<string, any>;
14
+ tools: ProtocolToolDef[];
15
+ toolProcess: {
16
+ command: string;
17
+ args?: string[];
18
+ };
19
+ agents?: Array<{
20
+ role: string;
21
+ systemPrompt: string;
22
+ allowedTools?: string[];
23
+ autoSpawn?: boolean;
24
+ maxInstances?: number;
25
+ }>;
26
+ observe?: {
27
+ exclude?: string[];
28
+ include?: string[];
29
+ };
30
+ canvas?: string;
31
+ netcode?: "default" | "tick";
32
+ tickRateMs?: number;
33
+ streams?: Array<{
34
+ name: string;
35
+ input_schema: Record<string, any>;
36
+ rateLimit?: number;
37
+ }>;
38
+ roomConfig?: {
39
+ schema: Record<string, any>;
40
+ defaults?: Record<string, any>;
41
+ presets?: Record<string, Record<string, any>>;
42
+ description?: string;
43
+ };
44
+ }
45
+ interface ProtocolToolDef {
46
+ name: string;
47
+ description: string;
48
+ input_schema: Record<string, any>;
49
+ risk?: "low" | "medium" | "high";
50
+ }
51
+ interface RpcRequest {
52
+ id: string;
53
+ method: "tool" | "observe" | "stream" | "init" | "ping";
54
+ params: Record<string, any>;
55
+ }
56
+ interface RpcResponse {
57
+ id: string;
58
+ result?: Record<string, any>;
59
+ error?: {
60
+ message: string;
61
+ code?: string;
62
+ };
63
+ }
64
+ export declare class SubprocessExecutor {
65
+ private proc;
66
+ private pending;
67
+ private buffer;
68
+ private seq;
69
+ private command;
70
+ private args;
71
+ private cwd;
72
+ private restarting;
73
+ constructor(command: string, args: string[], cwd: string);
74
+ start(): void;
75
+ stop(): void;
76
+ private processBuffer;
77
+ send(method: RpcRequest["method"], params: Record<string, any>, timeoutMs?: number): Promise<RpcResponse>;
78
+ get running(): boolean;
79
+ }
80
+ export declare function isProtocolExperience(entryPath: string): boolean;
81
+ export declare function loadProtocolManifest(manifestPath: string): ProtocolManifest;
82
+ /**
83
+ * Create a synthetic ExperienceModule from a protocol manifest.
84
+ * Tool handlers proxy calls to the subprocess executor.
85
+ */
86
+ export declare function createProtocolModule(manifest: ProtocolManifest, executor: SubprocessExecutor, manifestDir: string): ExperienceModule & {
87
+ initialState?: Record<string, any>;
88
+ _executor: SubprocessExecutor;
89
+ _canvasPath?: string;
90
+ };
91
+ export {};
92
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAA+B,MAAM,gBAAgB,CAAC;AAIpF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,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