mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 09:07:46 +02:00
fix(hermes): project native completion and tool activity
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
300afb3fe3
commit
f628d54bc8
12 files changed
+225
-12
No files matched your search
@@ -118,6 +118,30 @@ describe("provider notice presentation", () => {
|
||||
});
|
||||
|
||||
describe("nativeRunEventsToTranscript", () => {
|
||||
it.each(["command", "cmd"])("uses native %s arguments for process previews and preserves plain results", (key) => {
|
||||
const input = { [key]: "printf 'native output'", cwd: "/workspace" };
|
||||
const transcript = nativeRunEventsToTranscript([
|
||||
event(1, "tool.execution.started", {
|
||||
schema: "paperclip.tool.execution.v1", executionId: "hermes-terminal",
|
||||
transport: "process", operation: "execute", name: "terminal", status: "running",
|
||||
}),
|
||||
itemEvent(2, "item.started", "hermes-terminal", {
|
||||
item: { type: "tool_use", id: "hermes-terminal", name: "terminal", input: JSON.stringify(input) },
|
||||
}),
|
||||
event(3, "tool.execution.completed", {
|
||||
schema: "paperclip.tool.execution.v1", executionId: "hermes-terminal",
|
||||
transport: "process", operation: "execute", name: "terminal", status: "completed",
|
||||
}),
|
||||
itemEvent(4, "item.completed", "hermes-terminal", {
|
||||
item: { type: "tool_result", tool_use_id: "hermes-terminal", result: "native output\nnext line" },
|
||||
}),
|
||||
]);
|
||||
expect(transcript).toMatchObject([
|
||||
{ kind: "tool_call", toolUseId: "hermes-terminal", name: "Bash", input },
|
||||
{ kind: "tool_result", toolUseId: "hermes-terminal", content: "native output\nnext line", isError: false },
|
||||
]);
|
||||
});
|
||||
|
||||
describe("accepted response-wake authority", () => {
|
||||
function fixture() {
|
||||
const result = {
|
||||
|
||||
@@ -547,6 +547,7 @@ function nativeToolItemDetails(
|
||||
|
||||
function serializedNativeToolResult(item: NativeToolItemDetails): string {
|
||||
if (item.result === undefined) return "";
|
||||
if (typeof item.result === "string") return item.result;
|
||||
try {
|
||||
return JSON.stringify(item.result) ?? "";
|
||||
} catch {
|
||||
@@ -562,6 +563,14 @@ function toolPresentation(
|
||||
const operation = text(payload.operation);
|
||||
const reportedName = text(payload.name) ?? item?.name ?? null;
|
||||
if (transport === "process") {
|
||||
let input = item?.input;
|
||||
if (typeof input === "string") {
|
||||
try { input = JSON.parse(input); } catch { /* Keep the reported invocation fallback. */ }
|
||||
}
|
||||
const argumentsRecord = record(input);
|
||||
if (text(argumentsRecord?.command) || text(argumentsRecord?.cmd)) {
|
||||
return { name: "Bash", input };
|
||||
}
|
||||
return {
|
||||
name: "Bash",
|
||||
input: reportedName ? { command: reportedName } : { operation: operation ?? "execute" },
|
||||
|
||||
Reference in new issue
Block a user