@sanity-labs/nuum 0.2.0 → 0.2.2
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/index.js +82 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34518,9 +34518,10 @@ function scanSubdirectories(dir, skills) {
|
|
|
34518
34518
|
}
|
|
34519
34519
|
} catch {}
|
|
34520
34520
|
}
|
|
34521
|
-
function discoverSkills(
|
|
34521
|
+
function discoverSkills(options = {}) {
|
|
34522
|
+
const cwd = options.cwd ?? process.cwd();
|
|
34523
|
+
const home = options.home ?? homedir2();
|
|
34522
34524
|
const skills = new Map;
|
|
34523
|
-
const home = homedir2();
|
|
34524
34525
|
scanDirectory(cwd, skills);
|
|
34525
34526
|
scanSubdirectories(cwd, skills);
|
|
34526
34527
|
if (cwd !== home) {
|
|
@@ -34564,7 +34565,7 @@ var cachedSkills = null;
|
|
|
34564
34565
|
var cachedCwd = null;
|
|
34565
34566
|
function getSkills(cwd = process.cwd()) {
|
|
34566
34567
|
if (cachedSkills === null || cachedCwd !== cwd) {
|
|
34567
|
-
cachedSkills = discoverSkills(cwd);
|
|
34568
|
+
cachedSkills = discoverSkills({ cwd });
|
|
34568
34569
|
cachedCwd = cwd;
|
|
34569
34570
|
}
|
|
34570
34571
|
return cachedSkills;
|
|
@@ -34747,6 +34748,26 @@ function formatIdRange(firstId, lastId, timestamp) {
|
|
|
34747
34748
|
}
|
|
34748
34749
|
return `[${formatTimestamp(timestamp)} id:${firstId}...${lastId}]`;
|
|
34749
34750
|
}
|
|
34751
|
+
function ensureAllToolCallsHaveResults(toolCalls, toolResults) {
|
|
34752
|
+
if (toolResults.length >= toolCalls.length) {
|
|
34753
|
+
return toolResults;
|
|
34754
|
+
}
|
|
34755
|
+
const completeResults = [...toolResults];
|
|
34756
|
+
for (let i = toolResults.length;i < toolCalls.length; i++) {
|
|
34757
|
+
const call = toolCalls[i];
|
|
34758
|
+
log4.warn("synthesizing error result for orphaned tool call", {
|
|
34759
|
+
toolCallId: call.toolCallId,
|
|
34760
|
+
toolName: call.toolName
|
|
34761
|
+
});
|
|
34762
|
+
completeResults.push({
|
|
34763
|
+
type: "tool-result",
|
|
34764
|
+
toolCallId: call.toolCallId,
|
|
34765
|
+
toolName: call.toolName,
|
|
34766
|
+
result: "Error: Tool execution failed (no result recorded - possible crash or disk full)"
|
|
34767
|
+
});
|
|
34768
|
+
}
|
|
34769
|
+
return completeResults;
|
|
34770
|
+
}
|
|
34750
34771
|
function processMessageForTurn(message, allMessages, currentIdx) {
|
|
34751
34772
|
const turns = [];
|
|
34752
34773
|
switch (message.type) {
|
|
@@ -34805,13 +34826,12 @@ function processMessageForTurn(message, allMessages, currentIdx) {
|
|
|
34805
34826
|
content: assistantContent
|
|
34806
34827
|
};
|
|
34807
34828
|
turns.push(assistantMsg);
|
|
34808
|
-
|
|
34809
|
-
|
|
34810
|
-
|
|
34811
|
-
|
|
34812
|
-
|
|
34813
|
-
|
|
34814
|
-
}
|
|
34829
|
+
const completeResults = ensureAllToolCallsHaveResults(toolCalls, toolResults);
|
|
34830
|
+
const toolMsg = {
|
|
34831
|
+
role: "tool",
|
|
34832
|
+
content: completeResults
|
|
34833
|
+
};
|
|
34834
|
+
turns.push(toolMsg);
|
|
34815
34835
|
} else {
|
|
34816
34836
|
turns.push({ role: "assistant", content: formatWithId(message.id, message.createdAt, message.content) });
|
|
34817
34837
|
}
|
|
@@ -34867,13 +34887,12 @@ function processMessageForTurn(message, allMessages, currentIdx) {
|
|
|
34867
34887
|
content: assistantContent
|
|
34868
34888
|
};
|
|
34869
34889
|
turns.push(assistantMsg);
|
|
34870
|
-
|
|
34871
|
-
|
|
34872
|
-
|
|
34873
|
-
|
|
34874
|
-
|
|
34875
|
-
|
|
34876
|
-
}
|
|
34890
|
+
const completeResults = ensureAllToolCallsHaveResults(toolCalls, toolResults);
|
|
34891
|
+
const toolMsg = {
|
|
34892
|
+
role: "tool",
|
|
34893
|
+
content: completeResults
|
|
34894
|
+
};
|
|
34895
|
+
turns.push(toolMsg);
|
|
34877
34896
|
}
|
|
34878
34897
|
return { turns, nextIdx };
|
|
34879
34898
|
}
|
|
@@ -44282,7 +44301,10 @@ var Mcp;
|
|
|
44282
44301
|
headers: exports_external.record(exports_external.string()).optional(),
|
|
44283
44302
|
transport: exports_external.enum(["http", "sse"]).optional().default("http"),
|
|
44284
44303
|
disabled: exports_external.boolean().optional().default(false),
|
|
44285
|
-
timeout: exports_external.number().optional().default(30000)
|
|
44304
|
+
timeout: exports_external.number().optional().default(30000),
|
|
44305
|
+
maxRetries: exports_external.number().optional().default(5),
|
|
44306
|
+
initialReconnectionDelay: exports_external.number().optional().default(1000),
|
|
44307
|
+
maxReconnectionDelay: exports_external.number().optional().default(60000)
|
|
44286
44308
|
});
|
|
44287
44309
|
Mcp.ServerConfigSchema = exports_external.union([
|
|
44288
44310
|
Mcp.StdioServerConfigSchema,
|
|
@@ -44340,7 +44362,13 @@ var Mcp;
|
|
|
44340
44362
|
});
|
|
44341
44363
|
} else {
|
|
44342
44364
|
return new StreamableHTTPClientTransport(new URL(config2.url), {
|
|
44343
|
-
requestInit: config2.headers ? { headers: config2.headers } : undefined
|
|
44365
|
+
requestInit: config2.headers ? { headers: config2.headers } : undefined,
|
|
44366
|
+
reconnectionOptions: {
|
|
44367
|
+
maxRetries: config2.maxRetries ?? 5,
|
|
44368
|
+
initialReconnectionDelay: config2.initialReconnectionDelay ?? 1000,
|
|
44369
|
+
maxReconnectionDelay: config2.maxReconnectionDelay ?? 60000,
|
|
44370
|
+
reconnectionDelayGrowFactor: 1.5
|
|
44371
|
+
}
|
|
44344
44372
|
});
|
|
44345
44373
|
}
|
|
44346
44374
|
}
|
|
@@ -44371,13 +44399,24 @@ var Mcp;
|
|
|
44371
44399
|
]);
|
|
44372
44400
|
const toolsResult = await client.listTools();
|
|
44373
44401
|
const tools = toolsResult.tools;
|
|
44374
|
-
|
|
44402
|
+
let sessionId;
|
|
44403
|
+
if (transport instanceof StreamableHTTPClientTransport) {
|
|
44404
|
+
sessionId = transport.sessionId;
|
|
44405
|
+
if (sessionId) {
|
|
44406
|
+
console.error(`[mcp:${name17}] Connected with session ${sessionId.slice(0, 8)}..., ${tools.length} tools available`);
|
|
44407
|
+
} else {
|
|
44408
|
+
console.error(`[mcp:${name17}] Connected (no session), ${tools.length} tools available`);
|
|
44409
|
+
}
|
|
44410
|
+
} else {
|
|
44411
|
+
console.error(`[mcp:${name17}] Connected, ${tools.length} tools available`);
|
|
44412
|
+
}
|
|
44375
44413
|
return {
|
|
44376
44414
|
name: name17,
|
|
44377
44415
|
config: config2,
|
|
44378
44416
|
client,
|
|
44379
44417
|
tools,
|
|
44380
|
-
status: "connected"
|
|
44418
|
+
status: "connected",
|
|
44419
|
+
sessionId
|
|
44381
44420
|
};
|
|
44382
44421
|
} catch (e) {
|
|
44383
44422
|
const error2 = e instanceof Error ? e.message : String(e);
|
|
@@ -44444,16 +44483,28 @@ var Mcp;
|
|
|
44444
44483
|
description: mcpTool.description ?? `MCP tool: ${mcpTool.name}`,
|
|
44445
44484
|
parameters: jsonSchema(mcpTool.inputSchema),
|
|
44446
44485
|
execute: async (args) => {
|
|
44447
|
-
|
|
44448
|
-
|
|
44449
|
-
|
|
44450
|
-
|
|
44451
|
-
|
|
44452
|
-
|
|
44453
|
-
|
|
44486
|
+
try {
|
|
44487
|
+
const result = await client.callTool({
|
|
44488
|
+
name: mcpTool.name,
|
|
44489
|
+
arguments: args
|
|
44490
|
+
});
|
|
44491
|
+
if ("isError" in result && result.isError) {
|
|
44492
|
+
const content = "content" in result && Array.isArray(result.content) ? result.content : [];
|
|
44493
|
+
const errorContent = content.filter((c) => c.type === "text").map((c) => c.text).join(`
|
|
44454
44494
|
`);
|
|
44495
|
+
return `Error: ${errorContent || "Tool execution failed"}`;
|
|
44496
|
+
}
|
|
44497
|
+
if ("content" in result && Array.isArray(result.content)) {
|
|
44498
|
+
const textParts = result.content.filter((c) => c.type === "text").map((c) => c.text);
|
|
44499
|
+
return textParts.join(`
|
|
44500
|
+
`);
|
|
44501
|
+
}
|
|
44502
|
+
return JSON.stringify(result);
|
|
44503
|
+
} catch (error2) {
|
|
44504
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
44505
|
+
console.error(`[mcp:${serverName}] Tool ${mcpTool.name} failed: ${message}`);
|
|
44506
|
+
return `Error: MCP tool call failed - ${message}. The server may be temporarily unavailable.`;
|
|
44455
44507
|
}
|
|
44456
|
-
return JSON.stringify(result);
|
|
44457
44508
|
}
|
|
44458
44509
|
});
|
|
44459
44510
|
}
|
|
@@ -47357,8 +47408,8 @@ async function runRepl(options) {
|
|
|
47357
47408
|
}
|
|
47358
47409
|
|
|
47359
47410
|
// src/version.ts
|
|
47360
|
-
var VERSION = "0.2.
|
|
47361
|
-
var GIT_HASH = "
|
|
47411
|
+
var VERSION = "0.2.2";
|
|
47412
|
+
var GIT_HASH = "0764a52";
|
|
47362
47413
|
var VERSION_STRING = `miriad-code v${VERSION} (${GIT_HASH})`;
|
|
47363
47414
|
|
|
47364
47415
|
// src/cli/index.ts
|