@pizzapi/cli-darwin-arm64 0.1.0

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tool HTML renderer for custom tools in HTML export.
3
+ *
4
+ * Renders custom tool calls and results to HTML by invoking their TUI renderers
5
+ * and converting the ANSI output to HTML.
6
+ */
7
+ import type { Theme } from "../../modes/interactive/theme/theme.js";
8
+ import type { ToolDefinition } from "../extensions/types.js";
9
+ export interface ToolHtmlRendererDeps {
10
+ /** Function to look up tool definition by name */
11
+ getToolDefinition: (name: string) => ToolDefinition | undefined;
12
+ /** Theme for styling */
13
+ theme: Theme;
14
+ /** Terminal width for rendering (default: 100) */
15
+ width?: number;
16
+ }
17
+ export interface ToolHtmlRenderer {
18
+ /** Render a tool call to HTML. Returns undefined if tool has no custom renderer. */
19
+ renderCall(toolName: string, args: unknown): string | undefined;
20
+ /** Render a tool result to HTML. Returns undefined if tool has no custom renderer. */
21
+ renderResult(toolName: string, result: Array<{
22
+ type: string;
23
+ text?: string;
24
+ data?: string;
25
+ mimeType?: string;
26
+ }>, details: unknown, isError: boolean): string | undefined;
27
+ }
28
+ /**
29
+ * Create a tool HTML renderer.
30
+ *
31
+ * The renderer looks up tool definitions and invokes their renderCall/renderResult
32
+ * methods, converting the resulting TUI Component output (ANSI) to HTML.
33
+ */
34
+ export declare function createToolHtmlRenderer(deps: ToolHtmlRendererDeps): ToolHtmlRenderer;
35
+ //# sourceMappingURL=tool-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-renderer.d.ts","sourceRoot":"","sources":["../../../src/core/export-html/tool-renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,MAAM,WAAW,oBAAoB;IACpC,kDAAkD;IAClD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;IAChE,wBAAwB;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAChC,oFAAoF;IACpF,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAChE,sFAAsF;IACtF,YAAY,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAChF,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACd,MAAM,GAAG,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,gBAAgB,CAkDnF","sourcesContent":["/**\n * Tool HTML renderer for custom tools in HTML export.\n *\n * Renders custom tool calls and results to HTML by invoking their TUI renderers\n * and converting the ANSI output to HTML.\n */\n\nimport type { ImageContent, TextContent } from \"@mariozechner/pi-ai\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { ToolDefinition } from \"../extensions/types.js\";\nimport { ansiLinesToHtml } from \"./ansi-to-html.js\";\n\nexport interface ToolHtmlRendererDeps {\n\t/** Function to look up tool definition by name */\n\tgetToolDefinition: (name: string) => ToolDefinition | undefined;\n\t/** Theme for styling */\n\ttheme: Theme;\n\t/** Terminal width for rendering (default: 100) */\n\twidth?: number;\n}\n\nexport interface ToolHtmlRenderer {\n\t/** Render a tool call to HTML. Returns undefined if tool has no custom renderer. */\n\trenderCall(toolName: string, args: unknown): string | undefined;\n\t/** Render a tool result to HTML. Returns undefined if tool has no custom renderer. */\n\trenderResult(\n\t\ttoolName: string,\n\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\tdetails: unknown,\n\t\tisError: boolean,\n\t): string | undefined;\n}\n\n/**\n * Create a tool HTML renderer.\n *\n * The renderer looks up tool definitions and invokes their renderCall/renderResult\n * methods, converting the resulting TUI Component output (ANSI) to HTML.\n */\nexport function createToolHtmlRenderer(deps: ToolHtmlRendererDeps): ToolHtmlRenderer {\n\tconst { getToolDefinition, theme, width = 100 } = deps;\n\n\treturn {\n\t\trenderCall(toolName: string, args: unknown): string | undefined {\n\t\t\ttry {\n\t\t\t\tconst toolDef = getToolDefinition(toolName);\n\t\t\t\tif (!toolDef?.renderCall) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst component = toolDef.renderCall(args, theme);\n\t\t\t\tconst lines = component.render(width);\n\t\t\t\treturn ansiLinesToHtml(lines);\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined to trigger JSON fallback\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\n\t\trenderResult(\n\t\t\ttoolName: string,\n\t\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\t\tdetails: unknown,\n\t\t\tisError: boolean,\n\t\t): string | undefined {\n\t\t\ttry {\n\t\t\t\tconst toolDef = getToolDefinition(toolName);\n\t\t\t\tif (!toolDef?.renderResult) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\t// Build AgentToolResult from content array\n\t\t\t\t// Cast content since session storage uses generic object types\n\t\t\t\tconst agentToolResult = {\n\t\t\t\t\tcontent: result as (TextContent | ImageContent)[],\n\t\t\t\t\tdetails,\n\t\t\t\t\tisError,\n\t\t\t\t};\n\n\t\t\t\t// Always render expanded, client-side will apply truncation\n\t\t\t\tconst component = toolDef.renderResult(agentToolResult, { expanded: true, isPartial: false }, theme);\n\t\t\t\tconst lines = component.render(width);\n\t\t\t\treturn ansiLinesToHtml(lines);\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined to trigger JSON fallback\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Tool HTML renderer for custom tools in HTML export.
3
+ *
4
+ * Renders custom tool calls and results to HTML by invoking their TUI renderers
5
+ * and converting the ANSI output to HTML.
6
+ */
7
+ import { ansiLinesToHtml } from "./ansi-to-html.js";
8
+ /**
9
+ * Create a tool HTML renderer.
10
+ *
11
+ * The renderer looks up tool definitions and invokes their renderCall/renderResult
12
+ * methods, converting the resulting TUI Component output (ANSI) to HTML.
13
+ */
14
+ export function createToolHtmlRenderer(deps) {
15
+ const { getToolDefinition, theme, width = 100 } = deps;
16
+ return {
17
+ renderCall(toolName, args) {
18
+ try {
19
+ const toolDef = getToolDefinition(toolName);
20
+ if (!toolDef?.renderCall) {
21
+ return undefined;
22
+ }
23
+ const component = toolDef.renderCall(args, theme);
24
+ const lines = component.render(width);
25
+ return ansiLinesToHtml(lines);
26
+ }
27
+ catch {
28
+ // On error, return undefined to trigger JSON fallback
29
+ return undefined;
30
+ }
31
+ },
32
+ renderResult(toolName, result, details, isError) {
33
+ try {
34
+ const toolDef = getToolDefinition(toolName);
35
+ if (!toolDef?.renderResult) {
36
+ return undefined;
37
+ }
38
+ // Build AgentToolResult from content array
39
+ // Cast content since session storage uses generic object types
40
+ const agentToolResult = {
41
+ content: result,
42
+ details,
43
+ isError,
44
+ };
45
+ // Always render expanded, client-side will apply truncation
46
+ const component = toolDef.renderResult(agentToolResult, { expanded: true, isPartial: false }, theme);
47
+ const lines = component.render(width);
48
+ return ansiLinesToHtml(lines);
49
+ }
50
+ catch {
51
+ // On error, return undefined to trigger JSON fallback
52
+ return undefined;
53
+ }
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=tool-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-renderer.js","sourceRoot":"","sources":["../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AAS,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;gBACrG,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACR,sDAAsD;gBACtD,OAAO,SAAS,CAAC;YAClB,CAAC;QAAA,CACD;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Tool HTML renderer for custom tools in HTML export.\n *\n * Renders custom tool calls and results to HTML by invoking their TUI renderers\n * and converting the ANSI output to HTML.\n */\n\nimport type { ImageContent, TextContent } from \"@mariozechner/pi-ai\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\nimport type { ToolDefinition } from \"../extensions/types.js\";\nimport { ansiLinesToHtml } from \"./ansi-to-html.js\";\n\nexport interface ToolHtmlRendererDeps {\n\t/** Function to look up tool definition by name */\n\tgetToolDefinition: (name: string) => ToolDefinition | undefined;\n\t/** Theme for styling */\n\ttheme: Theme;\n\t/** Terminal width for rendering (default: 100) */\n\twidth?: number;\n}\n\nexport interface ToolHtmlRenderer {\n\t/** Render a tool call to HTML. Returns undefined if tool has no custom renderer. */\n\trenderCall(toolName: string, args: unknown): string | undefined;\n\t/** Render a tool result to HTML. Returns undefined if tool has no custom renderer. */\n\trenderResult(\n\t\ttoolName: string,\n\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\tdetails: unknown,\n\t\tisError: boolean,\n\t): string | undefined;\n}\n\n/**\n * Create a tool HTML renderer.\n *\n * The renderer looks up tool definitions and invokes their renderCall/renderResult\n * methods, converting the resulting TUI Component output (ANSI) to HTML.\n */\nexport function createToolHtmlRenderer(deps: ToolHtmlRendererDeps): ToolHtmlRenderer {\n\tconst { getToolDefinition, theme, width = 100 } = deps;\n\n\treturn {\n\t\trenderCall(toolName: string, args: unknown): string | undefined {\n\t\t\ttry {\n\t\t\t\tconst toolDef = getToolDefinition(toolName);\n\t\t\t\tif (!toolDef?.renderCall) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst component = toolDef.renderCall(args, theme);\n\t\t\t\tconst lines = component.render(width);\n\t\t\t\treturn ansiLinesToHtml(lines);\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined to trigger JSON fallback\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\n\t\trenderResult(\n\t\t\ttoolName: string,\n\t\t\tresult: Array<{ type: string; text?: string; data?: string; mimeType?: string }>,\n\t\t\tdetails: unknown,\n\t\t\tisError: boolean,\n\t\t): string | undefined {\n\t\t\ttry {\n\t\t\t\tconst toolDef = getToolDefinition(toolName);\n\t\t\t\tif (!toolDef?.renderResult) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\t// Build AgentToolResult from content array\n\t\t\t\t// Cast content since session storage uses generic object types\n\t\t\t\tconst agentToolResult = {\n\t\t\t\t\tcontent: result as (TextContent | ImageContent)[],\n\t\t\t\t\tdetails,\n\t\t\t\t\tisError,\n\t\t\t\t};\n\n\t\t\t\t// Always render expanded, client-side will apply truncation\n\t\t\t\tconst component = toolDef.renderResult(agentToolResult, { expanded: true, isPartial: false }, theme);\n\t\t\t\tconst lines = component.render(width);\n\t\t\t\treturn ansiLinesToHtml(lines);\n\t\t\t} catch {\n\t\t\t\t// On error, return undefined to trigger JSON fallback\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t};\n}\n"]}