@impulselab/hepha 0.2.665 → 0.2.666
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 +45 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2675,6 +2675,49 @@ var browserToolActivityDescribers = [
|
|
|
2675
2675
|
]
|
|
2676
2676
|
];
|
|
2677
2677
|
|
|
2678
|
+
// ../../packages/agents/src/tool-activity/canonical/tool-execute/mcp-prefix-constants.ts
|
|
2679
|
+
var MCP_ID_PREFIX = "mcp/";
|
|
2680
|
+
var MCP_ENVELOPE_PAIR = /,?"([^"\\]*)":("(?:[^"\\]|\\["\\/bfnrt]|\\u[0-9a-fA-F]{4})*"|true|false|null|-?\d+(?:\.\d+)?)/y;
|
|
2681
|
+
var MCP_ENVELOPE_KEYS = ["server", "reason"];
|
|
2682
|
+
|
|
2683
|
+
// ../../packages/agents/src/tool-activity/canonical/tool-execute/parse-tool-output.ts
|
|
2684
|
+
function parseToolOutput(output) {
|
|
2685
|
+
if (toolInput.isRecord(output)) return output;
|
|
2686
|
+
if (typeof output !== "string") return null;
|
|
2687
|
+
const envelope = {};
|
|
2688
|
+
if (!output.startsWith("{")) return envelope;
|
|
2689
|
+
MCP_ENVELOPE_PAIR.lastIndex = 1;
|
|
2690
|
+
let pair = MCP_ENVELOPE_PAIR.exec(output);
|
|
2691
|
+
while (pair) {
|
|
2692
|
+
const [, key, jsonValue] = pair;
|
|
2693
|
+
const isWantedKey = key !== void 0 && MCP_ENVELOPE_KEYS.includes(key);
|
|
2694
|
+
if (isWantedKey && jsonValue !== void 0 && !(key in envelope)) {
|
|
2695
|
+
envelope[key] = JSON.parse(jsonValue);
|
|
2696
|
+
}
|
|
2697
|
+
pair = MCP_ENVELOPE_PAIR.exec(output);
|
|
2698
|
+
}
|
|
2699
|
+
return envelope;
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
// ../../packages/agents/src/tool-activity/canonical/tool-execute/describe-tool-execute.ts
|
|
2703
|
+
function describeToolExecute(record, output) {
|
|
2704
|
+
const target = toolInput.str(record.tool);
|
|
2705
|
+
if (!target) return labelOnly("Ran an integration tool");
|
|
2706
|
+
if (!target.startsWith(MCP_ID_PREFIX)) {
|
|
2707
|
+
return labelOnly(`Ran ${toolInput.truncate(target, 60)}`);
|
|
2708
|
+
}
|
|
2709
|
+
const rest = target.slice(MCP_ID_PREFIX.length);
|
|
2710
|
+
const tool = rest.slice(rest.indexOf("/") + 1);
|
|
2711
|
+
const result = parseToolOutput(output);
|
|
2712
|
+
const server = toolInput.str(result?.server);
|
|
2713
|
+
const name = toolInput.truncate(tool, 40);
|
|
2714
|
+
const label = server ? `${name} \xB7 ${toolInput.truncate(server, 20)}` : name;
|
|
2715
|
+
if (result?.reason === "mcp_disconnected") {
|
|
2716
|
+
return labelOnly(`${label} failed: MCP disconnected, sign in again`);
|
|
2717
|
+
}
|
|
2718
|
+
return labelOnly(`Ran ${label}`);
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2678
2721
|
// ../../packages/agents/src/tool-activity/canonical/integration-tool-activity-describers.ts
|
|
2679
2722
|
var integrationToolActivityDescribers = [
|
|
2680
2723
|
[
|
|
@@ -2703,12 +2746,7 @@ var integrationToolActivityDescribers = [
|
|
|
2703
2746
|
],
|
|
2704
2747
|
[
|
|
2705
2748
|
"tool_execute",
|
|
2706
|
-
(record) =>
|
|
2707
|
-
const target = toolInput.str(record.tool);
|
|
2708
|
-
return labelOnly(
|
|
2709
|
-
target ? `Ran ${toolInput.truncate(target, 60)}` : "Ran an integration tool"
|
|
2710
|
-
);
|
|
2711
|
-
}
|
|
2749
|
+
(record, state) => describeToolExecute(record, state.output)
|
|
2712
2750
|
]
|
|
2713
2751
|
];
|
|
2714
2752
|
|
|
@@ -3552,6 +3590,7 @@ function toolActivityStateFor(toolName, options) {
|
|
|
3552
3590
|
const isRunning = options?.status === "running";
|
|
3553
3591
|
return {
|
|
3554
3592
|
isRunning,
|
|
3593
|
+
output: options?.output,
|
|
3555
3594
|
hasFailed: options?.status === "failed" || !isRunning && (softFailedCapture(toolName, options?.output) || softFailedBrowser(toolName, options?.output) || softFailedGit(toolName, options?.output))
|
|
3556
3595
|
};
|
|
3557
3596
|
}
|