@trops/dash-core 0.1.631 → 0.1.632
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/electron/index.js +129 -0
- package/dist/electron/index.js.map +1 -1
- package/package.json +2 -2
package/dist/electron/index.js
CHANGED
|
@@ -74770,6 +74770,113 @@ var toolLoopEngineExports = toolLoopEngine$2.exports;
|
|
|
74770
74770
|
|
|
74771
74771
|
var claudeAgentEngine$2 = {exports: {}};
|
|
74772
74772
|
|
|
74773
|
+
/**
|
|
74774
|
+
* agentToolBridge.js
|
|
74775
|
+
*
|
|
74776
|
+
* Bridges a bot's configured MCP tools into the Claude Agent SDK engine
|
|
74777
|
+
* (PRD FR-007). The SDK's `tool()` wants a Zod raw shape, while the bot's MCP
|
|
74778
|
+
* tools carry JSON-Schema `inputSchema`; this converts one to the other and
|
|
74779
|
+
* wraps them in an in-process SDK MCP server whose handlers proxy back to the
|
|
74780
|
+
* runner's `ctx.executeTool` (which runs the real MCP call via mcpController).
|
|
74781
|
+
*
|
|
74782
|
+
* Pure (NFR-006): both the SDK helpers (`createSdkMcpServer`, `tool`) and the
|
|
74783
|
+
* `zod` module are injected, so nothing vendor-specific loads here.
|
|
74784
|
+
*/
|
|
74785
|
+
|
|
74786
|
+
const BOT_MCP_SERVER$1 = "bot-mcp";
|
|
74787
|
+
|
|
74788
|
+
/**
|
|
74789
|
+
* Convert one JSON-Schema property to a Zod validator.
|
|
74790
|
+
* @param {object} prop
|
|
74791
|
+
* @param {*} z the zod module
|
|
74792
|
+
*/
|
|
74793
|
+
function zodTypeFor(prop, z) {
|
|
74794
|
+
const p = prop || {};
|
|
74795
|
+
if (
|
|
74796
|
+
Array.isArray(p.enum) &&
|
|
74797
|
+
p.enum.length &&
|
|
74798
|
+
p.enum.every((v) => typeof v === "string")
|
|
74799
|
+
) {
|
|
74800
|
+
return z.enum([...p.enum]);
|
|
74801
|
+
}
|
|
74802
|
+
switch (p.type) {
|
|
74803
|
+
case "string":
|
|
74804
|
+
return z.string();
|
|
74805
|
+
case "number":
|
|
74806
|
+
case "integer":
|
|
74807
|
+
return z.number();
|
|
74808
|
+
case "boolean":
|
|
74809
|
+
return z.boolean();
|
|
74810
|
+
case "array":
|
|
74811
|
+
return z.array(p.items ? zodTypeFor(p.items, z) : z.any());
|
|
74812
|
+
case "object":
|
|
74813
|
+
return z.object(jsonSchemaToZodShape(p, z));
|
|
74814
|
+
default:
|
|
74815
|
+
return z.any();
|
|
74816
|
+
}
|
|
74817
|
+
}
|
|
74818
|
+
|
|
74819
|
+
/**
|
|
74820
|
+
* Convert a JSON-Schema object (`{type:"object", properties, required}`) to a
|
|
74821
|
+
* Zod raw shape (`{ [key]: ZodType }`) as SDK `tool()` expects.
|
|
74822
|
+
* @param {object} schema
|
|
74823
|
+
* @param {*} z the zod module
|
|
74824
|
+
* @returns {object}
|
|
74825
|
+
*/
|
|
74826
|
+
function jsonSchemaToZodShape(schema, z) {
|
|
74827
|
+
const props = (schema && schema.properties) || {};
|
|
74828
|
+
const required = new Set((schema && schema.required) || []);
|
|
74829
|
+
const shape = {};
|
|
74830
|
+
for (const [key, prop] of Object.entries(props)) {
|
|
74831
|
+
let zt = zodTypeFor(prop, z);
|
|
74832
|
+
if (!required.has(key)) zt = zt.optional();
|
|
74833
|
+
shape[key] = zt;
|
|
74834
|
+
}
|
|
74835
|
+
return shape;
|
|
74836
|
+
}
|
|
74837
|
+
|
|
74838
|
+
/**
|
|
74839
|
+
* Build an in-process SDK MCP server exposing the bot's MCP tools, or null if
|
|
74840
|
+
* the bot has none.
|
|
74841
|
+
* @param {object} ctx RunContext (uses ctx.tools + ctx.executeTool)
|
|
74842
|
+
* @param {{ createSdkMcpServer: Function, tool: Function }} sdk
|
|
74843
|
+
* @param {*} z the zod module
|
|
74844
|
+
* @returns {object|null} McpServerConfig for options.mcpServers, or null
|
|
74845
|
+
*/
|
|
74846
|
+
function buildBotMcpServer$1(ctx, sdk, z) {
|
|
74847
|
+
const tools = (ctx && Array.isArray(ctx.tools) ? ctx.tools : []).filter(
|
|
74848
|
+
(t) => t && t.name,
|
|
74849
|
+
);
|
|
74850
|
+
if (!tools.length) return null;
|
|
74851
|
+
|
|
74852
|
+
const sdkTools = tools.map((t) =>
|
|
74853
|
+
sdk.tool(
|
|
74854
|
+
t.name,
|
|
74855
|
+
t.description || "",
|
|
74856
|
+
jsonSchemaToZodShape(t.inputSchema, z),
|
|
74857
|
+
async (args) => {
|
|
74858
|
+
const r = await ctx.executeTool(t.name, args);
|
|
74859
|
+
return {
|
|
74860
|
+
content: [{ type: "text", text: (r && r.text) || "" }],
|
|
74861
|
+
isError: !!(r && r.isError),
|
|
74862
|
+
};
|
|
74863
|
+
},
|
|
74864
|
+
),
|
|
74865
|
+
);
|
|
74866
|
+
|
|
74867
|
+
return sdk.createSdkMcpServer({
|
|
74868
|
+
name: BOT_MCP_SERVER$1,
|
|
74869
|
+
version: "1.0.0",
|
|
74870
|
+
tools: sdkTools,
|
|
74871
|
+
});
|
|
74872
|
+
}
|
|
74873
|
+
|
|
74874
|
+
var agentToolBridge = {
|
|
74875
|
+
BOT_MCP_SERVER: BOT_MCP_SERVER$1,
|
|
74876
|
+
jsonSchemaToZodShape,
|
|
74877
|
+
buildBotMcpServer: buildBotMcpServer$1,
|
|
74878
|
+
};
|
|
74879
|
+
|
|
74773
74880
|
/**
|
|
74774
74881
|
* claudeAgentEngine.js
|
|
74775
74882
|
*
|
|
@@ -74791,6 +74898,7 @@ var claudeAgentEngine$2 = {exports: {}};
|
|
|
74791
74898
|
*/
|
|
74792
74899
|
|
|
74793
74900
|
const { createEventStream } = eventStream;
|
|
74901
|
+
const { BOT_MCP_SERVER, buildBotMcpServer } = agentToolBridge;
|
|
74794
74902
|
|
|
74795
74903
|
// Test seam: injected fake `query` implementation (see __setQueryForTest).
|
|
74796
74904
|
let _queryImpl = null;
|
|
@@ -74892,6 +75000,27 @@ async function _runAgent(ctx, stream) {
|
|
|
74892
75000
|
if (ctx.workingDir) options.cwd = ctx.workingDir;
|
|
74893
75001
|
if (ctx.session && ctx.session.id) options.resume = ctx.session.id;
|
|
74894
75002
|
|
|
75003
|
+
// Bridge the bot's configured MCP tools into the SDK as an in-process MCP
|
|
75004
|
+
// server (proxying to ctx.executeTool). Best-effort — on failure the bot
|
|
75005
|
+
// still gets the SDK's built-in tools. canUseTool gates these too.
|
|
75006
|
+
if (ctx.tools && ctx.tools.length) {
|
|
75007
|
+
try {
|
|
75008
|
+
const [sdkMod, zodMod] = await Promise.all([
|
|
75009
|
+
import('@anthropic-ai/claude-agent-sdk'),
|
|
75010
|
+
import('zod'),
|
|
75011
|
+
]);
|
|
75012
|
+
const z = zodMod.z || zodMod.default || zodMod;
|
|
75013
|
+
const server = buildBotMcpServer(
|
|
75014
|
+
ctx,
|
|
75015
|
+
{ createSdkMcpServer: sdkMod.createSdkMcpServer, tool: sdkMod.tool },
|
|
75016
|
+
z,
|
|
75017
|
+
);
|
|
75018
|
+
if (server) options.mcpServers = { [BOT_MCP_SERVER]: server };
|
|
75019
|
+
} catch (_e) {
|
|
75020
|
+
// Fall back to built-in tools only.
|
|
75021
|
+
}
|
|
75022
|
+
}
|
|
75023
|
+
|
|
74895
75024
|
const q = query({ prompt: ctx.prompt || "", options });
|
|
74896
75025
|
|
|
74897
75026
|
// Cooperative cancellation → SDK interrupt.
|