mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-17 18:02:32 +00:00
move pi-mono into companion-cloud as apps/companion-os
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
0250f72976
579 changed files with 206942 additions and 0 deletions
121
packages/web-ui/src/tools/renderers/DefaultRenderer.ts
Normal file
121
packages/web-ui/src/tools/renderers/DefaultRenderer.ts
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import type { ToolResultMessage } from "@mariozechner/pi-ai";
|
||||
import { html } from "lit";
|
||||
import { Code } from "lucide";
|
||||
import { i18n } from "../../utils/i18n.js";
|
||||
import { renderHeader } from "../renderer-registry.js";
|
||||
import type { ToolRenderer, ToolRenderResult } from "../types.js";
|
||||
|
||||
export class DefaultRenderer implements ToolRenderer {
|
||||
render(
|
||||
params: any | undefined,
|
||||
result: ToolResultMessage | undefined,
|
||||
isStreaming?: boolean,
|
||||
): ToolRenderResult {
|
||||
const state = result
|
||||
? result.isError
|
||||
? "error"
|
||||
: "complete"
|
||||
: isStreaming
|
||||
? "inprogress"
|
||||
: "complete";
|
||||
|
||||
// Format params as JSON
|
||||
let paramsJson = "";
|
||||
if (params) {
|
||||
try {
|
||||
paramsJson = JSON.stringify(JSON.parse(params), null, 2);
|
||||
} catch {
|
||||
try {
|
||||
paramsJson = JSON.stringify(params, null, 2);
|
||||
} catch {
|
||||
paramsJson = String(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// With result: show header + params + result
|
||||
if (result) {
|
||||
let outputJson =
|
||||
result.content
|
||||
?.filter((c) => c.type === "text")
|
||||
.map((c: any) => c.text)
|
||||
.join("\n") || i18n("(no output)");
|
||||
let outputLanguage = "text";
|
||||
|
||||
// Try to parse and pretty-print if it's valid JSON
|
||||
try {
|
||||
const parsed = JSON.parse(outputJson);
|
||||
outputJson = JSON.stringify(parsed, null, 2);
|
||||
outputLanguage = "json";
|
||||
} catch {
|
||||
// Not valid JSON, leave as-is and use text highlighting
|
||||
}
|
||||
|
||||
return {
|
||||
content: html`
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Code, "Tool Call")}
|
||||
${paramsJson
|
||||
? html`<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">
|
||||
${i18n("Input")}
|
||||
</div>
|
||||
<code-block .code=${paramsJson} language="json"></code-block>
|
||||
</div>`
|
||||
: ""}
|
||||
<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">
|
||||
${i18n("Output")}
|
||||
</div>
|
||||
<code-block
|
||||
.code=${outputJson}
|
||||
language="${outputLanguage}"
|
||||
></code-block>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Just params (streaming or waiting for result)
|
||||
if (params) {
|
||||
if (
|
||||
isStreaming &&
|
||||
(!paramsJson || paramsJson === "{}" || paramsJson === "null")
|
||||
) {
|
||||
return {
|
||||
content: html`
|
||||
<div>
|
||||
${renderHeader(state, Code, "Preparing tool parameters...")}
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
content: html`
|
||||
<div class="space-y-3">
|
||||
${renderHeader(state, Code, "Tool Call")}
|
||||
<div>
|
||||
<div class="text-xs font-medium mb-1 text-muted-foreground">
|
||||
${i18n("Input")}
|
||||
</div>
|
||||
<code-block .code=${paramsJson} language="json"></code-block>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
|
||||
// No params or result yet
|
||||
return {
|
||||
content: html`
|
||||
<div>${renderHeader(state, Code, "Preparing tool...")}</div>
|
||||
`,
|
||||
isCustom: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue