bridge-agent 0.4.8 → 0.4.9
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/bridge-mcp.cjs +188 -21
- package/dist/index.js +45 -35
- package/package.json +1 -1
package/dist/bridge-mcp.cjs
CHANGED
|
@@ -1299,21 +1299,21 @@ var require_errors = __commonJS({
|
|
|
1299
1299
|
function extendErrors({ gen, keyword, schemaValue, data, errsCount, it }) {
|
|
1300
1300
|
if (errsCount === void 0)
|
|
1301
1301
|
throw new Error("ajv implementation error");
|
|
1302
|
-
const
|
|
1302
|
+
const err4 = gen.name("err");
|
|
1303
1303
|
gen.forRange("i", errsCount, names_1.default.errors, (i) => {
|
|
1304
|
-
gen.const(
|
|
1305
|
-
gen.if((0, codegen_1._)`${
|
|
1306
|
-
gen.assign((0, codegen_1._)`${
|
|
1304
|
+
gen.const(err4, (0, codegen_1._)`${names_1.default.vErrors}[${i}]`);
|
|
1305
|
+
gen.if((0, codegen_1._)`${err4}.instancePath === undefined`, () => gen.assign((0, codegen_1._)`${err4}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath)));
|
|
1306
|
+
gen.assign((0, codegen_1._)`${err4}.schemaPath`, (0, codegen_1.str)`${it.errSchemaPath}/${keyword}`);
|
|
1307
1307
|
if (it.opts.verbose) {
|
|
1308
|
-
gen.assign((0, codegen_1._)`${
|
|
1309
|
-
gen.assign((0, codegen_1._)`${
|
|
1308
|
+
gen.assign((0, codegen_1._)`${err4}.schema`, schemaValue);
|
|
1309
|
+
gen.assign((0, codegen_1._)`${err4}.data`, data);
|
|
1310
1310
|
}
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
1313
|
exports2.extendErrors = extendErrors;
|
|
1314
1314
|
function addError(gen, errObj) {
|
|
1315
|
-
const
|
|
1316
|
-
gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${
|
|
1315
|
+
const err4 = gen.const("err", errObj);
|
|
1316
|
+
gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${err4}]`), (0, codegen_1._)`${names_1.default.vErrors}.push(${err4})`);
|
|
1317
1317
|
gen.code((0, codegen_1._)`${names_1.default.errors}++`);
|
|
1318
1318
|
}
|
|
1319
1319
|
function returnErrors(it, errs) {
|
|
@@ -7541,8 +7541,8 @@ var ZodType = class {
|
|
|
7541
7541
|
} : {
|
|
7542
7542
|
issues: ctx.common.issues
|
|
7543
7543
|
};
|
|
7544
|
-
} catch (
|
|
7545
|
-
if (
|
|
7544
|
+
} catch (err4) {
|
|
7545
|
+
if (err4?.message?.toLowerCase()?.includes("encountered")) {
|
|
7546
7546
|
this["~standard"].async = true;
|
|
7547
7547
|
}
|
|
7548
7548
|
ctx.common = {
|
|
@@ -21243,16 +21243,16 @@ var handleFetchError = (e) => new Response(null, {
|
|
|
21243
21243
|
status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500
|
|
21244
21244
|
});
|
|
21245
21245
|
var handleResponseError = (e, outgoing) => {
|
|
21246
|
-
const
|
|
21247
|
-
if (
|
|
21246
|
+
const err4 = e instanceof Error ? e : new Error("unknown error", { cause: e });
|
|
21247
|
+
if (err4.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
21248
21248
|
console.info("The user aborted a request.");
|
|
21249
21249
|
} else {
|
|
21250
21250
|
console.error(e);
|
|
21251
21251
|
if (!outgoing.headersSent) {
|
|
21252
21252
|
outgoing.writeHead(500, { "Content-Type": "text/plain" });
|
|
21253
21253
|
}
|
|
21254
|
-
outgoing.end(`Error: ${
|
|
21255
|
-
outgoing.destroy(
|
|
21254
|
+
outgoing.end(`Error: ${err4.message}`);
|
|
21255
|
+
outgoing.destroy(err4);
|
|
21256
21256
|
}
|
|
21257
21257
|
};
|
|
21258
21258
|
var flushHeaders = (outgoing) => {
|
|
@@ -21309,8 +21309,8 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
21309
21309
|
if (options.errorHandler) {
|
|
21310
21310
|
try {
|
|
21311
21311
|
res = await res;
|
|
21312
|
-
} catch (
|
|
21313
|
-
const errRes = await options.errorHandler(
|
|
21312
|
+
} catch (err4) {
|
|
21313
|
+
const errRes = await options.errorHandler(err4);
|
|
21314
21314
|
if (!errRes) {
|
|
21315
21315
|
return;
|
|
21316
21316
|
}
|
|
@@ -22414,6 +22414,40 @@ async function getProjectEvents(ctx, opts) {
|
|
|
22414
22414
|
projectPath(ctx, `/events${qs ? "?" + qs : ""}`, opts?.projectId)
|
|
22415
22415
|
);
|
|
22416
22416
|
}
|
|
22417
|
+
async function listPersonas(ctx, opts) {
|
|
22418
|
+
const params = new URLSearchParams();
|
|
22419
|
+
if (opts.projectId) params.set("projectId", opts.projectId);
|
|
22420
|
+
if (opts.scope) params.set("scope", opts.scope);
|
|
22421
|
+
if (opts.includeArchived) params.set("includeArchived", "true");
|
|
22422
|
+
if (opts.agentKey) params.set("agentKey", opts.agentKey);
|
|
22423
|
+
if (opts.role) params.set("role", opts.role);
|
|
22424
|
+
if (opts.tag) params.set("tag", opts.tag);
|
|
22425
|
+
if (opts.q) params.set("q", opts.q);
|
|
22426
|
+
if (opts.limit) params.set("pageSize", String(opts.limit));
|
|
22427
|
+
const qs = params.toString();
|
|
22428
|
+
return request(ctx, "GET", workspacePath(ctx, `/personas${qs ? "?" + qs : ""}`));
|
|
22429
|
+
}
|
|
22430
|
+
async function getPersona(ctx, params) {
|
|
22431
|
+
return request(ctx, "GET", workspacePath(ctx, `/personas/${encodeURIComponent(params.id)}`));
|
|
22432
|
+
}
|
|
22433
|
+
async function createPersona(ctx, params) {
|
|
22434
|
+
const body = { ...params, scope: params.projectId ? "project" : "workspace" };
|
|
22435
|
+
return request(ctx, "POST", workspacePath(ctx, "/personas"), body);
|
|
22436
|
+
}
|
|
22437
|
+
async function updatePersona(ctx, params) {
|
|
22438
|
+
const { id, ...body } = params;
|
|
22439
|
+
return request(ctx, "PATCH", workspacePath(ctx, `/personas/${encodeURIComponent(id)}`), body);
|
|
22440
|
+
}
|
|
22441
|
+
async function archivePersona(ctx, id) {
|
|
22442
|
+
return request(ctx, "POST", workspacePath(ctx, `/personas/${encodeURIComponent(id)}/archive`));
|
|
22443
|
+
}
|
|
22444
|
+
async function launchPersona(ctx, params) {
|
|
22445
|
+
const { id, projectId, ...rest } = params;
|
|
22446
|
+
const trimmed = projectId?.trim();
|
|
22447
|
+
const pid = trimmed || ctx.projectId;
|
|
22448
|
+
const body = pid ? { ...rest, projectId: pid } : rest;
|
|
22449
|
+
return request(ctx, "POST", workspacePath(ctx, `/personas/${encodeURIComponent(id)}/launch`), body);
|
|
22450
|
+
}
|
|
22417
22451
|
|
|
22418
22452
|
// ../mcp-server/src/tools/plan.ts
|
|
22419
22453
|
function registerPlanTools(server, ctx) {
|
|
@@ -22542,6 +22576,31 @@ function registerTodoTools(server, ctx) {
|
|
|
22542
22576
|
);
|
|
22543
22577
|
}
|
|
22544
22578
|
|
|
22579
|
+
// ../shared/dist/types.js
|
|
22580
|
+
var ALL_AGENT_KEYS = [
|
|
22581
|
+
"sh",
|
|
22582
|
+
"claude",
|
|
22583
|
+
"codex",
|
|
22584
|
+
"qwen",
|
|
22585
|
+
"kimi",
|
|
22586
|
+
"gemini",
|
|
22587
|
+
"ollama",
|
|
22588
|
+
"aider",
|
|
22589
|
+
"forge",
|
|
22590
|
+
"sim_ios"
|
|
22591
|
+
];
|
|
22592
|
+
var AGENT_ROLES = [
|
|
22593
|
+
"developer",
|
|
22594
|
+
"reviewer",
|
|
22595
|
+
"planner",
|
|
22596
|
+
"executor",
|
|
22597
|
+
"shell",
|
|
22598
|
+
"runner",
|
|
22599
|
+
"orchestrator"
|
|
22600
|
+
];
|
|
22601
|
+
var USER_ASSIGNABLE_ROLES = AGENT_ROLES.filter((r) => r !== "orchestrator");
|
|
22602
|
+
var EVENT_ROLES = [...AGENT_ROLES, "system"];
|
|
22603
|
+
|
|
22545
22604
|
// ../mcp-server/src/tools/orchestration.ts
|
|
22546
22605
|
function ok(data) {
|
|
22547
22606
|
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
@@ -22612,7 +22671,7 @@ function registerOrchestrationTools(server, ctx) {
|
|
|
22612
22671
|
{
|
|
22613
22672
|
agentKey: external_exports.string().describe("Agent type: claude, codex, sh, qwen, gemini, ollama, aider"),
|
|
22614
22673
|
daemonId: external_exports.string().optional().describe("Target machine ID. Omit to use the workspace default machine."),
|
|
22615
|
-
role: external_exports.
|
|
22674
|
+
role: external_exports.enum(USER_ASSIGNABLE_ROLES).optional().describe(`Panel role: ${USER_ASSIGNABLE_ROLES.join(", ")}`),
|
|
22616
22675
|
cmd: external_exports.string().max(512).optional().describe('Command to run after spawn (sh panels only, e.g. "npm run dev"). Sets role to runner automatically.')
|
|
22617
22676
|
},
|
|
22618
22677
|
({ agentKey, daemonId, role, cmd }) => safe(() => spawnAgent(ctx, agentKey, daemonId, role, cmd))
|
|
@@ -22797,6 +22856,113 @@ function registerWorkspaceTools(server, ctx) {
|
|
|
22797
22856
|
);
|
|
22798
22857
|
}
|
|
22799
22858
|
|
|
22859
|
+
// ../mcp-server/src/tools/personas.ts
|
|
22860
|
+
function ok3(data) {
|
|
22861
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
22862
|
+
}
|
|
22863
|
+
function err3(message) {
|
|
22864
|
+
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: message }) }] };
|
|
22865
|
+
}
|
|
22866
|
+
async function safe3(fn) {
|
|
22867
|
+
try {
|
|
22868
|
+
return ok3(await fn());
|
|
22869
|
+
} catch (e) {
|
|
22870
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
22871
|
+
if (e instanceof Error && (e.name === "TypeError" || e.name === "ReferenceError")) {
|
|
22872
|
+
console.error("[mcp-bridge] unexpected error in persona tool handler", { name: e.name, message, stack: e.stack });
|
|
22873
|
+
}
|
|
22874
|
+
return err3(message);
|
|
22875
|
+
}
|
|
22876
|
+
}
|
|
22877
|
+
var ListPersonasSchema = external_exports.object({
|
|
22878
|
+
projectId: external_exports.string().min(1).optional().describe("Filter to project scope. Defaults to caller panel's project."),
|
|
22879
|
+
scope: external_exports.enum(["personal", "workspace", "project", "all"]).optional().describe("Scope filter (default: all)"),
|
|
22880
|
+
includeArchived: external_exports.boolean().optional(),
|
|
22881
|
+
agentKey: external_exports.enum(ALL_AGENT_KEYS).optional(),
|
|
22882
|
+
role: external_exports.enum(USER_ASSIGNABLE_ROLES).optional(),
|
|
22883
|
+
tag: external_exports.string().optional(),
|
|
22884
|
+
q: external_exports.string().optional().describe("Substring search on name+description"),
|
|
22885
|
+
limit: external_exports.number().int().min(1).max(200).optional()
|
|
22886
|
+
});
|
|
22887
|
+
var GetPersonaSchema = external_exports.object({
|
|
22888
|
+
id: external_exports.string().min(1).describe("Persona id (UUID)"),
|
|
22889
|
+
projectId: external_exports.string().min(1).optional()
|
|
22890
|
+
});
|
|
22891
|
+
var CreatePersonaSchema = external_exports.object({
|
|
22892
|
+
name: external_exports.string().min(1).max(80),
|
|
22893
|
+
slug: external_exports.string().min(1).max(63).regex(/^[a-z][a-z0-9_]*$/),
|
|
22894
|
+
description: external_exports.string().max(200).optional(),
|
|
22895
|
+
agentKey: external_exports.enum(ALL_AGENT_KEYS),
|
|
22896
|
+
role: external_exports.enum(USER_ASSIGNABLE_ROLES),
|
|
22897
|
+
systemPrompt: external_exports.string().max(4e3).optional(),
|
|
22898
|
+
defaultCwd: external_exports.string().optional(),
|
|
22899
|
+
defaultDaemonId: external_exports.string().optional(),
|
|
22900
|
+
color: external_exports.string().regex(/^#[0-9a-f]{6}$/i).optional(),
|
|
22901
|
+
emoji: external_exports.string().optional(),
|
|
22902
|
+
tags: external_exports.array(external_exports.string()).max(10).optional(),
|
|
22903
|
+
projectId: external_exports.string().min(1).optional().describe("Make this a project-scoped persona. Omit for workspace-scoped.")
|
|
22904
|
+
});
|
|
22905
|
+
var UpdatePersonaSchema = external_exports.object({
|
|
22906
|
+
id: external_exports.string().min(1),
|
|
22907
|
+
name: external_exports.string().min(1).max(80).optional(),
|
|
22908
|
+
description: external_exports.string().max(200).optional(),
|
|
22909
|
+
systemPrompt: external_exports.string().max(4e3).optional(),
|
|
22910
|
+
defaultCwd: external_exports.string().optional(),
|
|
22911
|
+
defaultDaemonId: external_exports.string().optional(),
|
|
22912
|
+
color: external_exports.string().regex(/^#[0-9a-f]{6}$/i).optional(),
|
|
22913
|
+
emoji: external_exports.string().optional(),
|
|
22914
|
+
tags: external_exports.array(external_exports.string()).max(10).optional()
|
|
22915
|
+
});
|
|
22916
|
+
var ArchivePersonaSchema = external_exports.object({
|
|
22917
|
+
id: external_exports.string().min(1)
|
|
22918
|
+
});
|
|
22919
|
+
var LaunchPersonaSchema = external_exports.object({
|
|
22920
|
+
id: external_exports.string().min(1).describe("Persona id"),
|
|
22921
|
+
projectId: external_exports.string().min(1).optional().describe("Target project for the spawned panel. Required from orchestrator."),
|
|
22922
|
+
daemonId: external_exports.string().min(1).optional(),
|
|
22923
|
+
cwd: external_exports.string().optional(),
|
|
22924
|
+
cols: external_exports.number().int().optional(),
|
|
22925
|
+
rows: external_exports.number().int().optional()
|
|
22926
|
+
});
|
|
22927
|
+
function registerPersonaTools(server, ctx) {
|
|
22928
|
+
server.tool(
|
|
22929
|
+
"bridge_list_personas",
|
|
22930
|
+
"Query personas in the workspace. Returns lightweight list \u2014 call bridge_get_persona for full systemPrompt. Pass projectId to filter to a specific project. From the orchestrator (workspace scope) optionally pass projectId; per-project workers default to ctx.projectId.",
|
|
22931
|
+
ListPersonasSchema.shape,
|
|
22932
|
+
(opts) => safe3(() => listPersonas(ctx, opts))
|
|
22933
|
+
);
|
|
22934
|
+
server.tool(
|
|
22935
|
+
"bridge_get_persona",
|
|
22936
|
+
"Fetch a single persona by id. Returns full systemPrompt and all fields.",
|
|
22937
|
+
GetPersonaSchema.shape,
|
|
22938
|
+
(params) => safe3(() => getPersona(ctx, params))
|
|
22939
|
+
);
|
|
22940
|
+
server.tool(
|
|
22941
|
+
"bridge_create_persona",
|
|
22942
|
+
"Create a new persona. Required from the orchestrator: pass projectId if creating a project-scoped persona; omit for workspace-scoped.",
|
|
22943
|
+
CreatePersonaSchema.shape,
|
|
22944
|
+
(params) => safe3(() => createPersona(ctx, params))
|
|
22945
|
+
);
|
|
22946
|
+
server.tool(
|
|
22947
|
+
"bridge_update_persona",
|
|
22948
|
+
"Update fields of an existing persona. Pass only the fields you want to change.",
|
|
22949
|
+
UpdatePersonaSchema.shape,
|
|
22950
|
+
(params) => safe3(() => updatePersona(ctx, params))
|
|
22951
|
+
);
|
|
22952
|
+
server.tool(
|
|
22953
|
+
"bridge_archive_persona",
|
|
22954
|
+
"Soft-archive a persona. Removes it from the active list but preserves audit trail.",
|
|
22955
|
+
ArchivePersonaSchema.shape,
|
|
22956
|
+
({ id }) => safe3(() => archivePersona(ctx, id))
|
|
22957
|
+
);
|
|
22958
|
+
server.tool(
|
|
22959
|
+
"bridge_launch_persona",
|
|
22960
|
+
"Spawn a live panel from a persona. Returns the new agentId.",
|
|
22961
|
+
LaunchPersonaSchema.shape,
|
|
22962
|
+
(params) => safe3(() => launchPersona(ctx, params))
|
|
22963
|
+
);
|
|
22964
|
+
}
|
|
22965
|
+
|
|
22800
22966
|
// ../mcp-server/src/index.ts
|
|
22801
22967
|
var sessions = /* @__PURE__ */ new Map();
|
|
22802
22968
|
function buildMcpServer(ctx) {
|
|
@@ -22806,6 +22972,7 @@ function buildMcpServer(ctx) {
|
|
|
22806
22972
|
registerOrchestrationTools(srv, ctx);
|
|
22807
22973
|
registerMessagingTools(srv, ctx);
|
|
22808
22974
|
registerWorkspaceTools(srv, ctx);
|
|
22975
|
+
registerPersonaTools(srv, ctx);
|
|
22809
22976
|
return srv;
|
|
22810
22977
|
}
|
|
22811
22978
|
async function parseBody(req) {
|
|
@@ -22909,8 +23076,8 @@ function startHttpServer() {
|
|
|
22909
23076
|
const mcpServer = buildMcpServer(ctx);
|
|
22910
23077
|
await mcpServer.connect(transport);
|
|
22911
23078
|
await transport.handleRequest(req, res, body);
|
|
22912
|
-
} catch (
|
|
22913
|
-
console.error("[bridge-mcp] request error:",
|
|
23079
|
+
} catch (err4) {
|
|
23080
|
+
console.error("[bridge-mcp] request error:", err4);
|
|
22914
23081
|
if (!res.headersSent) {
|
|
22915
23082
|
res.writeHead(500, { "Content-Type": "application/json" });
|
|
22916
23083
|
res.end(JSON.stringify({ error: "Internal server error" }));
|
|
@@ -22944,8 +23111,8 @@ async function startStdioServer() {
|
|
|
22944
23111
|
if (process.env["HTTP_MODE"] !== "false") {
|
|
22945
23112
|
startHttpServer();
|
|
22946
23113
|
} else {
|
|
22947
|
-
startStdioServer().catch((
|
|
22948
|
-
console.error("[bridge-mcp] fatal:",
|
|
23114
|
+
startStdioServer().catch((err4) => {
|
|
23115
|
+
console.error("[bridge-mcp] fatal:", err4);
|
|
22949
23116
|
process.exit(1);
|
|
22950
23117
|
});
|
|
22951
23118
|
}
|