@vibevibes/mcp 0.3.2 → 0.4.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/dist/bundler.js +4 -4
- package/dist/index.js +2 -2
- package/dist/server.js +1 -22
- package/package.json +1 -1
package/dist/bundler.js
CHANGED
|
@@ -74,7 +74,7 @@ function stripExternalImports(code, externals = EXTERNALS) {
|
|
|
74
74
|
* CJS shim definitions for server-side eval (new Function()).
|
|
75
75
|
* Maps esbuild-generated variable names to runtime-provided globals.
|
|
76
76
|
*/
|
|
77
|
-
const SDK_CORE_SHIM = "{ defineExperience: defineExperience, defineTool: defineTool, defineTest: defineTest, defineStream: defineStream,
|
|
77
|
+
const SDK_CORE_SHIM = "{ defineExperience: defineExperience, defineTool: defineTool, defineTest: defineTest, defineStream: defineStream, default: { defineExperience: defineExperience, defineTool: defineTool, defineTest: defineTest, defineStream: defineStream } }";
|
|
78
78
|
const CJS_BASE_SHIMS = {
|
|
79
79
|
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 }",
|
|
80
80
|
import_zod: "{ z: z, default: z }",
|
|
@@ -182,7 +182,7 @@ export async function bundleForServer(entryPath) {
|
|
|
182
182
|
*/
|
|
183
183
|
export async function evalServerBundle(serverCode) {
|
|
184
184
|
const sdk = await import("@vibevibes/sdk");
|
|
185
|
-
const { defineExperience, defineTool, defineTest, defineStream
|
|
185
|
+
const { defineExperience, defineTool, defineTest, defineStream } = sdk;
|
|
186
186
|
const noop = () => null;
|
|
187
187
|
const stubReact = {
|
|
188
188
|
createElement: noop, Fragment: "Fragment",
|
|
@@ -194,11 +194,11 @@ export async function evalServerBundle(serverCode) {
|
|
|
194
194
|
};
|
|
195
195
|
const zodModule = await import("zod");
|
|
196
196
|
const z = zodModule.z ?? zodModule.default ?? zodModule;
|
|
197
|
-
const fn = new Function("globalThis", "process", "global", "React", "Y", "z", "defineExperience", "defineTool", "defineTest", "defineStream", "
|
|
197
|
+
const fn = new Function("globalThis", "process", "global", "React", "Y", "z", "defineExperience", "defineTool", "defineTest", "defineStream", "require", "exports", "module", "console", `"use strict";\n${serverCode}\nreturn typeof __experience_export__ !== 'undefined' ? __experience_export__ : (typeof module !== 'undefined' ? module.exports : undefined);`);
|
|
198
198
|
const fakeModule = { exports: {} };
|
|
199
199
|
const sandboxGlobal = Object.create(null);
|
|
200
200
|
const sandboxProcess = { env: { NODE_ENV: "production" } };
|
|
201
|
-
const result = fn(sandboxGlobal, sandboxProcess, sandboxGlobal, stubReact, {}, z, defineExperience, defineTool, defineTest, defineStream,
|
|
201
|
+
const result = fn(sandboxGlobal, sandboxProcess, sandboxGlobal, stubReact, {}, z, defineExperience, defineTool, defineTest, defineStream, (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);
|
|
202
202
|
const exports = fakeModule.exports;
|
|
203
203
|
return result?.default ?? result ?? exports?.default ?? exports;
|
|
204
204
|
}
|
package/dist/index.js
CHANGED
|
@@ -480,10 +480,10 @@ Call this first, then use act to interact. The stop hook keeps you present.`, {
|
|
|
480
480
|
outputParts.push(`BEHAVIOR MODE:`, ` You are a behavior-only agent. All actions run autonomously via the tick engine.`, ` No stop hook — you will NOT receive wake-up events.`, ` Set up behaviors now, then disconnect. The tick engine runs them automatically.`, ``);
|
|
481
481
|
}
|
|
482
482
|
else if (agentMode === "manual") {
|
|
483
|
-
outputParts.push(`MANUAL MODE:`, ` You are a manual agent. Use act() for all decisions. No behaviors.`, ` The stop hook keeps you present — use act to interact.`, `
|
|
483
|
+
outputParts.push(`MANUAL MODE:`, ` You are a manual agent. Use act() for all decisions. No behaviors.`, ` The stop hook keeps you present — use act to interact.`, ` Use act() to interact. The stop hook keeps you present.`, ``);
|
|
484
484
|
}
|
|
485
485
|
else {
|
|
486
|
-
outputParts.push(`FAST BRAIN / SLOW BRAIN:`, ` Fast brain: Register behaviors via _behavior.set for reactive, per-tick actions that run automatically.`, ` Slow brain: Use act() for strategic decisions and adapting to new situations.`, ` Set up your fast brain FIRST, then use your slow brain to observe and adapt.`, `
|
|
486
|
+
outputParts.push(`FAST BRAIN / SLOW BRAIN:`, ` Fast brain: Register behaviors via _behavior.set for reactive, per-tick actions that run automatically.`, ` Slow brain: Use act() for strategic decisions and adapting to new situations.`, ` Set up your fast brain FIRST, then use your slow brain to observe and adapt.`, ` Use act() to interact. The stop hook keeps you present.`, ``, `You are now a live participant. The stop hook keeps you present — use act to interact.`);
|
|
487
487
|
}
|
|
488
488
|
// Register the stop hook so Claude Code wakes us on events
|
|
489
489
|
ensureStopHook();
|
package/dist/server.js
CHANGED
|
@@ -11,13 +11,12 @@ import http from "http";
|
|
|
11
11
|
import path from "path";
|
|
12
12
|
import fs from "fs";
|
|
13
13
|
import { fileURLToPath } from "url";
|
|
14
|
-
import {
|
|
14
|
+
import { ZodError } from "zod";
|
|
15
15
|
import { EventEmitter } from "events";
|
|
16
16
|
import { bundleForServer, bundleForClient, evalServerBundle, validateClientBundle } from "./bundler.js";
|
|
17
17
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
18
18
|
import { TickEngine } from "./tick-engine.js";
|
|
19
19
|
import { isProtocolExperience, loadProtocolManifest, createProtocolModule, SubprocessExecutor } from "./protocol.js";
|
|
20
|
-
import { createChatTools } from "@vibevibes/sdk";
|
|
21
20
|
function formatZodError(err, toolName, tool) {
|
|
22
21
|
const issues = err.issues.map((issue) => {
|
|
23
22
|
const path = issue.path.length > 0 ? `'${issue.path.join(".")}'` : "input";
|
|
@@ -375,9 +374,6 @@ async function loadExperience() {
|
|
|
375
374
|
if (!mod?.manifest || !mod?.tools) {
|
|
376
375
|
throw new Error(`Experience at ${entryPath} missing manifest or tools`);
|
|
377
376
|
}
|
|
378
|
-
if (!mod.tools.some((t) => t.name === '_chat.send')) {
|
|
379
|
-
mod.tools.push(...createChatTools(z));
|
|
380
|
-
}
|
|
381
377
|
const clientError = validateClientBundle(cCode);
|
|
382
378
|
if (clientError) {
|
|
383
379
|
throw new Error(`Client bundle validation failed for ${entryPath}: ${clientError}`);
|
|
@@ -405,9 +401,6 @@ async function loadProtocolExperience(manifestPath) {
|
|
|
405
401
|
}
|
|
406
402
|
catch { }
|
|
407
403
|
const mod = createProtocolModule(manifest, executor, manifestDir);
|
|
408
|
-
if (!mod.tools.some((t) => t.name === '_chat.send')) {
|
|
409
|
-
mod.tools.push(...createChatTools(z));
|
|
410
|
-
}
|
|
411
404
|
loadedExperience = {
|
|
412
405
|
module: mod,
|
|
413
406
|
clientBundle: "",
|
|
@@ -461,20 +454,6 @@ export function defineExperience(c) { return c; }
|
|
|
461
454
|
export function defineTool(c) { return { risk: "low", capabilities_required: [], ...c }; }
|
|
462
455
|
export function defineTest(c) { return c; }
|
|
463
456
|
export function defineStream(c) { return c; }
|
|
464
|
-
export function createChatTools(z) {
|
|
465
|
-
return [
|
|
466
|
-
{ name: "_chat.send", description: "Send a chat message", risk: "low", capabilities_required: ["state.write"],
|
|
467
|
-
input_schema: z.object({ message: z.string() }),
|
|
468
|
-
handler: async (ctx, input) => {
|
|
469
|
-
const chat = Array.isArray(ctx.state._chat) ? ctx.state._chat : [];
|
|
470
|
-
ctx.setState({ ...ctx.state, _chat: [...chat.slice(-99), { actorId: ctx.actorId, message: input.message, ts: Date.now() }] });
|
|
471
|
-
return { sent: true };
|
|
472
|
-
}},
|
|
473
|
-
{ name: "_chat.clear", description: "Clear chat", risk: "low", capabilities_required: ["state.write"],
|
|
474
|
-
input_schema: z.object({}),
|
|
475
|
-
handler: async (ctx) => { ctx.setState({ ...ctx.state, _chat: [] }); return { cleared: true }; }},
|
|
476
|
-
];
|
|
477
|
-
}
|
|
478
457
|
`);
|
|
479
458
|
});
|
|
480
459
|
// ── State endpoint ─────────────────────────────────────────
|