@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.
- package/dist/bundler.d.ts +36 -0
- package/dist/bundler.d.ts.map +1 -0
- package/dist/bundler.js +365 -0
- package/dist/bundler.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +92 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +241 -0
- package/dist/protocol.js.map +1 -0
- package/dist/server.d.ts +24 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +3339 -0
- package/dist/server.js.map +1 -0
- package/dist/tick-engine.d.ts +82 -0
- package/dist/tick-engine.d.ts.map +1 -0
- package/dist/tick-engine.js +153 -0
- package/dist/tick-engine.js.map +1 -0
- package/dist/viewer/index.html +1388 -0
- package/package.json +53 -0
- package/src/bundler.ts +429 -0
- package/src/index.ts +26 -0
- package/src/protocol.ts +324 -0
- package/src/server.ts +3738 -0
- package/src/tick-engine.ts +216 -0
- package/src/viewer/index.html +1388 -0
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
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 { spawn } from "child_process";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import * as fs from "fs";
|
|
10
|
+
// ── Subprocess executor ─────────────────────────────────────────────────
|
|
11
|
+
export class SubprocessExecutor {
|
|
12
|
+
proc = null;
|
|
13
|
+
pending = new Map();
|
|
14
|
+
buffer = "";
|
|
15
|
+
seq = 0;
|
|
16
|
+
command;
|
|
17
|
+
args;
|
|
18
|
+
cwd;
|
|
19
|
+
restarting = false;
|
|
20
|
+
constructor(command, args, cwd) {
|
|
21
|
+
this.command = command;
|
|
22
|
+
this.args = args;
|
|
23
|
+
this.cwd = cwd;
|
|
24
|
+
}
|
|
25
|
+
start() {
|
|
26
|
+
if (this.proc)
|
|
27
|
+
return;
|
|
28
|
+
this.proc = spawn(this.command, this.args, {
|
|
29
|
+
cwd: this.cwd,
|
|
30
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
31
|
+
env: { ...process.env },
|
|
32
|
+
});
|
|
33
|
+
this.proc.stdout.on("data", (chunk) => {
|
|
34
|
+
this.buffer += chunk.toString();
|
|
35
|
+
this.processBuffer();
|
|
36
|
+
});
|
|
37
|
+
this.proc.stderr.on("data", (chunk) => {
|
|
38
|
+
const msg = chunk.toString().trim();
|
|
39
|
+
if (msg)
|
|
40
|
+
console.error(`[protocol:${this.command}] ${msg}`);
|
|
41
|
+
});
|
|
42
|
+
this.proc.on("exit", (code) => {
|
|
43
|
+
console.warn(`[protocol] Tool process exited with code ${code}`);
|
|
44
|
+
this.proc = null;
|
|
45
|
+
// Reject all pending requests
|
|
46
|
+
for (const [id, p] of this.pending) {
|
|
47
|
+
p.reject(new Error(`Tool process exited (code ${code})`));
|
|
48
|
+
clearTimeout(p.timer);
|
|
49
|
+
}
|
|
50
|
+
this.pending.clear();
|
|
51
|
+
this.buffer = "";
|
|
52
|
+
// Auto-restart after a short delay
|
|
53
|
+
if (!this.restarting) {
|
|
54
|
+
this.restarting = true;
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
this.restarting = false;
|
|
57
|
+
try {
|
|
58
|
+
this.start();
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
}, 1000);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
this.proc.on("error", (err) => {
|
|
65
|
+
console.error(`[protocol] Failed to spawn tool process: ${err.message}`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
stop() {
|
|
69
|
+
this.restarting = true; // Prevent auto-restart
|
|
70
|
+
if (this.proc) {
|
|
71
|
+
this.proc.kill();
|
|
72
|
+
this.proc = null;
|
|
73
|
+
}
|
|
74
|
+
for (const [, p] of this.pending) {
|
|
75
|
+
p.reject(new Error("Executor stopped"));
|
|
76
|
+
clearTimeout(p.timer);
|
|
77
|
+
}
|
|
78
|
+
this.pending.clear();
|
|
79
|
+
}
|
|
80
|
+
processBuffer() {
|
|
81
|
+
const lines = this.buffer.split("\n");
|
|
82
|
+
this.buffer = lines.pop() || "";
|
|
83
|
+
for (const line of lines) {
|
|
84
|
+
const trimmed = line.trim();
|
|
85
|
+
if (!trimmed)
|
|
86
|
+
continue;
|
|
87
|
+
try {
|
|
88
|
+
const response = JSON.parse(trimmed);
|
|
89
|
+
const pending = this.pending.get(response.id);
|
|
90
|
+
if (pending) {
|
|
91
|
+
clearTimeout(pending.timer);
|
|
92
|
+
this.pending.delete(response.id);
|
|
93
|
+
pending.resolve(response);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
console.warn(`[protocol] Invalid JSON from tool process: ${trimmed.slice(0, 200)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async send(method, params, timeoutMs = 10000) {
|
|
102
|
+
if (!this.proc?.stdin?.writable) {
|
|
103
|
+
throw new Error("Tool process not running");
|
|
104
|
+
}
|
|
105
|
+
const id = `req-${++this.seq}`;
|
|
106
|
+
const request = { id, method, params };
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
const timer = setTimeout(() => {
|
|
109
|
+
this.pending.delete(id);
|
|
110
|
+
reject(new Error(`Tool process timeout after ${timeoutMs}ms`));
|
|
111
|
+
}, timeoutMs);
|
|
112
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
113
|
+
try {
|
|
114
|
+
this.proc.stdin.write(JSON.stringify(request) + "\n");
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
this.pending.delete(id);
|
|
119
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
get running() {
|
|
124
|
+
return this.proc !== null && !this.proc.killed;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// ── Load a protocol experience ──────────────────────────────────────────
|
|
128
|
+
export function isProtocolExperience(entryPath) {
|
|
129
|
+
return entryPath.endsWith("manifest.json");
|
|
130
|
+
}
|
|
131
|
+
export function loadProtocolManifest(manifestPath) {
|
|
132
|
+
const raw = fs.readFileSync(manifestPath, "utf-8");
|
|
133
|
+
const manifest = JSON.parse(raw);
|
|
134
|
+
if (!manifest.id)
|
|
135
|
+
throw new Error("manifest.json: id is required");
|
|
136
|
+
if (!manifest.version)
|
|
137
|
+
throw new Error("manifest.json: version is required");
|
|
138
|
+
if (!manifest.title)
|
|
139
|
+
throw new Error("manifest.json: title is required");
|
|
140
|
+
if (!manifest.toolProcess)
|
|
141
|
+
throw new Error("manifest.json: toolProcess is required");
|
|
142
|
+
if (!Array.isArray(manifest.tools))
|
|
143
|
+
throw new Error("manifest.json: tools must be an array");
|
|
144
|
+
return manifest;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create a synthetic ExperienceModule from a protocol manifest.
|
|
148
|
+
* Tool handlers proxy calls to the subprocess executor.
|
|
149
|
+
*/
|
|
150
|
+
export function createProtocolModule(manifest, executor, manifestDir) {
|
|
151
|
+
// Create tool defs with handlers that proxy to the subprocess
|
|
152
|
+
const tools = manifest.tools.map((t) => ({
|
|
153
|
+
name: t.name,
|
|
154
|
+
description: t.description,
|
|
155
|
+
// Use a plain object as input_schema with a parse method for compatibility
|
|
156
|
+
input_schema: createJsonSchemaValidator(t.input_schema),
|
|
157
|
+
risk: (t.risk || "low"),
|
|
158
|
+
capabilities_required: ["state.write"],
|
|
159
|
+
handler: async (ctx, input) => {
|
|
160
|
+
const response = await executor.send("tool", {
|
|
161
|
+
tool: t.name,
|
|
162
|
+
input,
|
|
163
|
+
state: ctx.state,
|
|
164
|
+
actorId: ctx.actorId,
|
|
165
|
+
roomId: ctx.roomId,
|
|
166
|
+
timestamp: ctx.timestamp,
|
|
167
|
+
});
|
|
168
|
+
if (response.error) {
|
|
169
|
+
throw new Error(response.error.message);
|
|
170
|
+
}
|
|
171
|
+
if (response.result?.state) {
|
|
172
|
+
ctx.setState(response.result.state);
|
|
173
|
+
}
|
|
174
|
+
return response.result?.output ?? {};
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
// Build observe function if manifest specifies observation config
|
|
178
|
+
let observe;
|
|
179
|
+
if (manifest.observe) {
|
|
180
|
+
const { exclude, include } = manifest.observe;
|
|
181
|
+
observe = (state, _event, _actorId) => {
|
|
182
|
+
if (include) {
|
|
183
|
+
const filtered = {};
|
|
184
|
+
for (const key of include) {
|
|
185
|
+
if (key in state)
|
|
186
|
+
filtered[key] = state[key];
|
|
187
|
+
}
|
|
188
|
+
return filtered;
|
|
189
|
+
}
|
|
190
|
+
if (exclude) {
|
|
191
|
+
const filtered = { ...state };
|
|
192
|
+
for (const key of exclude) {
|
|
193
|
+
delete filtered[key];
|
|
194
|
+
}
|
|
195
|
+
return filtered;
|
|
196
|
+
}
|
|
197
|
+
return state;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// Resolve canvas path
|
|
201
|
+
const canvasFile = manifest.canvas || "index.html";
|
|
202
|
+
const canvasPath = path.resolve(manifestDir, canvasFile);
|
|
203
|
+
const hasCanvas = fs.existsSync(canvasPath);
|
|
204
|
+
return {
|
|
205
|
+
manifest: {
|
|
206
|
+
id: manifest.id,
|
|
207
|
+
version: manifest.version,
|
|
208
|
+
title: manifest.title,
|
|
209
|
+
description: manifest.description || "",
|
|
210
|
+
requested_capabilities: ["state.write"],
|
|
211
|
+
agentSlots: manifest.agents,
|
|
212
|
+
participantSlots: manifest.agents?.map((a) => ({ ...a, type: "ai" })),
|
|
213
|
+
netcode: manifest.netcode,
|
|
214
|
+
tickRateMs: manifest.tickRateMs,
|
|
215
|
+
},
|
|
216
|
+
Canvas: (() => null), // Protocol experiences use HTML canvas, not React
|
|
217
|
+
tools,
|
|
218
|
+
observe,
|
|
219
|
+
initialState: manifest.initialState ?? {},
|
|
220
|
+
_executor: executor,
|
|
221
|
+
_canvasPath: hasCanvas ? canvasPath : undefined,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Create a minimal Zod-compatible validator from a JSON Schema.
|
|
226
|
+
* Only needs .parse() for the server's input validation.
|
|
227
|
+
*/
|
|
228
|
+
function createJsonSchemaValidator(schema) {
|
|
229
|
+
return {
|
|
230
|
+
parse: (input) => {
|
|
231
|
+
// Basic type validation for protocol experiences
|
|
232
|
+
if (schema.type === "object" && typeof input !== "object") {
|
|
233
|
+
throw new Error("Expected object input");
|
|
234
|
+
}
|
|
235
|
+
return input;
|
|
236
|
+
},
|
|
237
|
+
// Expose the raw JSON Schema for tool listing
|
|
238
|
+
_jsonSchema: schema,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AA0DzB,2EAA2E;AAE3E,MAAM,OAAO,kBAAkB;IACrB,IAAI,GAAwB,IAAI,CAAC;IACjC,OAAO,GAAG,IAAI,GAAG,EAIrB,CAAC;IACG,MAAM,GAAG,EAAE,CAAC;IACZ,GAAG,GAAG,CAAC,CAAC;IACR,OAAO,CAAS;IAChB,IAAI,CAAW;IACf,GAAG,CAAS;IACZ,UAAU,GAAG,KAAK,CAAC;IAE3B,YAAY,OAAe,EAAE,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AQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,8CAA8C;QAC9C,WAAW,EAAE,MAAM;KACpB,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibevibes/runtime — the server engine for vibevibes experiences.
|
|
3
|
+
*
|
|
4
|
+
* Single-experience architecture with tool gate, WebSocket broadcasts, and room spawning.
|
|
5
|
+
*
|
|
6
|
+
* The server loads one experience from the project root (manifest.json for protocol
|
|
7
|
+
* experiences, or src/index.tsx for TypeScript experiences). Multiple rooms can be
|
|
8
|
+
* spawned, all running the same experience.
|
|
9
|
+
*
|
|
10
|
+
* AI agents join rooms via MCP or HTTP.
|
|
11
|
+
*/
|
|
12
|
+
export interface ServerConfig {
|
|
13
|
+
/** Absolute path to the experience project root (where manifest.json or src/index.tsx lives). */
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
/** Port to listen on. Defaults to 4321 or PORT env var. */
|
|
16
|
+
port?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Set the public tunnel URL (called from dev.ts when --share is active). */
|
|
19
|
+
export declare function setPublicUrl(url: string): void;
|
|
20
|
+
/** Get the base URL clients should use (tunnel URL if sharing, localhost otherwise). */
|
|
21
|
+
export declare function getBaseUrl(): string;
|
|
22
|
+
export declare function startServer(config?: ServerConfig): Promise<import("http").Server>;
|
|
23
|
+
export declare function setProjectRoot(root: string): void;
|
|
24
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkBH,MAAM,WAAW,YAAY;IAC3B,iGAAiG;IACjG,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmgBD,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wFAAwF;AACxF,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AA+gFD,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,MAAM,EAAE,MAAM,CAAC,CAwlBvF;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD"}
|