@hheei/pi-ext-ui 0.8.2 → 0.8.3

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.
@@ -1,4 +1,4 @@
1
- import { AssistantMessageComponent, InteractiveMode, ToolExecutionComponent, VERSION, } from "@earendil-works/pi-coding-agent";
1
+ import { AssistantMessageComponent, InteractiveMode, ToolExecutionComponent, } from "@earendil-works/pi-coding-agent";
2
2
  import { Container, stripTerminalSequences, Text } from "@earendil-works/pi-tui";
3
3
  import { MessageView } from "./message-view.js";
4
4
  import { memberParts, TailUnit, ToolGroupView, } from "./tool-group-view.js";
@@ -7,8 +7,8 @@ const SEAMS = ["getRegisteredToolDefinition", "showExtensionNotify"];
7
7
  function record(value) {
8
8
  return typeof value === "object" && value !== null;
9
9
  }
10
- // Audited Pi >=1.0.1 compiles these TS-private members to ordinary JS properties.
11
- // All host-private access stays here; VERSION comes from the running host virtual module.
10
+ // Audited Pi >=1.5.0 compiles these TS-private members to ordinary JS properties.
11
+ // All host-private access stays here.
12
12
  function readHost(value) {
13
13
  if (!record(value))
14
14
  throw new Error("Invalid InteractiveMode instance");
@@ -518,12 +518,6 @@ function patchState() {
518
518
  }
519
519
  /** Private to pi-ext-ui: two process hooks, scoped by the actual host UI facade. */
520
520
  export function installHostToolGroups(context, background, outputPad) {
521
- const parts = VERSION.split(".").map(Number);
522
- const [major = 0, minor = 0, patch = 0] = parts;
523
- if (parts.length !== 3 ||
524
- !parts.every(Number.isInteger) ||
525
- !(major > 1 || (major === 1 && (minor > 0 || (minor === 0 && patch >= 1)))))
526
- throw new Error(`Tool grouping requires Pi >=1.0.1; running ${VERSION}`);
527
521
  const state = patchState();
528
522
  const ui = context.ui;
529
523
  if (state.owners.has(ui))
@@ -3,8 +3,9 @@ import { resolve } from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { getLanguageFromPath, } from "@earendil-works/pi-coding-agent";
5
5
  import { getCapabilities, hyperlink, stripTerminalSequences } from "@earendil-works/pi-tui";
6
+ import { isRecord } from "@hheei/pi-ext-core";
6
7
  import { diffStats } from "./diff-view.js";
7
- import { formatTimeoutFact, isRecord, parseCallArgs, } from "./payload-parser.js";
8
+ import { formatTimeoutFact, parseCallArgs } from "./payload-parser.js";
8
9
  /**
9
10
  * The single owner of Pi's own tool vocabulary in this UI. Concrete tool packages state their own
10
11
  * semantics through ext-core's presentation point; this module is the explicit adapter for the tools
@@ -1,6 +1,6 @@
1
1
  import { type Theme, type ToolRenderers } from "@earendil-works/pi-coding-agent";
2
2
  import { type Component, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
3
- import type { ToolPresentationProvider } from "@hheei/pi-ext-core";
3
+ import { type ToolPresentationProvider } from "@hheei/pi-ext-core";
4
4
  import type { NestedCallRecord, ToolRenderContext } from "./renderer.js";
5
5
  import { type Collapsible } from "./tool-view.js";
6
6
  import type { CapturedToolCall } from "./tracker.js";
@@ -1,13 +1,12 @@
1
1
  import { copyToClipboard as copyToSystemClipboard, getLanguageFromPath, highlightCode, } from "@earendil-works/pi-coding-agent";
2
2
  import { stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
3
+ import { isRecord } from "@hheei/pi-ext-core";
3
4
  import { extractChildToolCopyText, inlinePresentation, nativeRequestCopy } from "./native-tools.js";
5
+ import { formatDurationMs } from "./payload-parser.js";
4
6
  import { formatToolHeaderText, TOOL_SPINNER_INTERVAL_MS, ToolView, toContentRows, toolSpinnerFrame, transitionFoldLevel, } from "./tool-view.js";
5
7
  function truncate(text, width) {
6
8
  return truncateToWidth(text, Math.max(1, width));
7
9
  }
8
- function isRecord(value) {
9
- return typeof value === "object" && value !== null && !Array.isArray(value);
10
- }
11
10
  /**
12
11
  * A call without a final result is still running: its row carries the live spinner frame. A persisted
13
12
  * record states its own status, so a recovered board never animates a call that already ended.
@@ -27,11 +26,6 @@ function copyText(text, request) {
27
26
  }
28
27
  return request + stripTerminalSequences(text.slice(request.length));
29
28
  }
30
- function formatDuration(ms) {
31
- if (ms === undefined || !Number.isFinite(ms))
32
- return "";
33
- return ms < 1000 ? `${String(Math.round(ms))}ms` : `${(ms / 1000).toFixed(1)}s`;
34
- }
35
29
  export const NESTED_CALLS_EXPANDED_KEY = "__pi_ext_ui_nested_expanded__";
36
30
  export const NESTED_CALLS_COPIED_KEY = "__pi_ext_ui_nested_copied__";
37
31
  export class NestedCallsView {
@@ -264,7 +258,7 @@ export class NestedCallsView {
264
258
  title: toolName,
265
259
  summary: childSummary,
266
260
  ...(ownSummary === undefined || ownSummary === "" ? {} : { summaryStyled: true }),
267
- meta: formatDuration(call.durationMs),
261
+ meta: formatDurationMs(call.durationMs),
268
262
  }, theme);
269
263
  const isCopied = this.#copiedIndex === i;
270
264
  const copyIcon = this.#failedIndex === i
@@ -20,7 +20,6 @@ export interface NestedCallRecord {
20
20
  readonly cost?: number | undefined;
21
21
  readonly error?: string | undefined;
22
22
  }
23
- export declare function isRecord(value: unknown): value is Record<string, unknown>;
24
23
  export declare function estimateStreamingTokens(args: unknown): number;
25
24
  export declare function formatDurationMs(ms: number | undefined): string;
26
25
  export declare function formatCostUsd(cost: number | undefined): string;
@@ -1,7 +1,5 @@
1
+ import { isRecord } from "@hheei/pi-ext-core";
1
2
  export const RESOLVED_CALLS_KEY = "__piExtUiResolvedCalls";
2
- export function isRecord(value) {
3
- return typeof value === "object" && value !== null && !Array.isArray(value);
4
- }
5
3
  export function estimateStreamingTokens(args) {
6
4
  if (args === undefined || args === null)
7
5
  return 0;
@@ -1,10 +1,7 @@
1
1
  import { type ExtensionAPI, type ToolRendererResolver, type ToolRenderers } from "@earendil-works/pi-coding-agent";
2
2
  import type { ToolUiRuntime } from "./runtime.js";
3
- /** Optional host metadata is absent on early supported Pi versions. */
4
- export type ToolRenderContext = Parameters<NonNullable<ToolRenderers["renderCall"]>>[2] & {
5
- readonly durationMs?: number | undefined;
6
- readonly outputPad?: number | undefined;
7
- };
3
+ /** Everything the host hands a tool renderer for one call. */
4
+ export type ToolRenderContext = Parameters<NonNullable<ToolRenderers["renderCall"]>>[2];
8
5
  /**
9
6
  * Upstream tools whose call and result views pi-ext-ui still frames itself. Concrete tool packages
10
7
  * own their own presentation through ext-core's optional renderer point, so their names never
package/dist/renderer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { highlightCode, } from "@earendil-works/pi-coding-agent";
2
2
  import { stripTerminalSequences } from "@earendil-works/pi-tui";
3
- import { agentResultText, getRegisteredToolPresentationProvider, getRegisteredToolRenderers, getToolPresentationProvider, hasOptionalToolRenderers, } from "@hheei/pi-ext-core";
3
+ import { agentResultText, getRegisteredToolPresentationProvider, getRegisteredToolRenderers, getToolPresentationProvider, hasOptionalToolRenderers, isRecord, } from "@hheei/pi-ext-core";
4
4
  import { DiffView } from "./diff-view.js";
5
5
  import { NestedCallsView } from "./nested-calls-view.js";
6
6
  import { formatToolHeaderText, ToolView, } from "./tool-view.js";
@@ -11,7 +11,7 @@ import { formatToolHeaderText, ToolView, } from "./tool-view.js";
11
11
  */
12
12
  export const SPECIALIZED_TOOL_RENDERERS = ["codemode"];
13
13
  import { inlinePresentation, nativeHeaderSummary, nativeHeavyRequest, nativeOutputLanguage, nativeRequestBlock, nativeResultText, nativeTimeoutFact, } from "./native-tools.js";
14
- import { callStatsParts, estimateStreamingTokens, extractNestedCalls, formatCostUsd, formatDurationMs, isRecord, RESOLVED_CALLS_KEY, resolveContainerStatus, } from "./payload-parser.js";
14
+ import { callStatsParts, estimateStreamingTokens, extractNestedCalls, formatCostUsd, formatDurationMs, RESOLVED_CALLS_KEY, resolveContainerStatus, } from "./payload-parser.js";
15
15
  export { extractChildToolCopyText, inlinePresentation } from "./native-tools.js";
16
16
  export { estimateStreamingTokens, } from "./payload-parser.js";
17
17
  const SPECIALIZED_TOOL_SET = new Set(SPECIALIZED_TOOL_RENDERERS);
package/dist/tool-view.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { copyToClipboard as copyToSystemClipboard, } from "@earendil-works/pi-coding-agent";
3
3
  import { truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
4
+ import { isRecord } from "@hheei/pi-ext-core";
4
5
  import { surfaceBlock } from "./background.js";
5
6
  /** Pi native tool surfaces: a failure outranks work in progress, which outranks a settled tool. */
6
7
  function nativeSurface(status) {
@@ -28,9 +29,6 @@ const DEFAULT_MAX_SECTION_LINES = 9;
28
29
  export const MAX_LEVEL2_SECTION_LINES = 500;
29
30
  export const MAX_LEVEL2_BYTES = 64 * 1024;
30
31
  const DEFAULT_COPY_FEEDBACK_MS = 1200;
31
- function isRecord(value) {
32
- return typeof value === "object" && value !== null && !Array.isArray(value);
33
- }
34
32
  export function transitionFoldLevel(current, ctrlKey) {
35
33
  if (current === 0) {
36
34
  return ctrlKey ? 2 : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hheei/pi-ext-ui",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Collapsible tool rendering frame and tool renderer pilot for Pi.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,15 +35,15 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@hheei/pi-ext-core": "^0.8.0"
38
+ "@hheei/pi-ext-core": "^0.8.1"
39
39
  },
40
40
  "peerDependencies": {
41
- "@earendil-works/pi-coding-agent": ">=1.0.1",
42
- "@earendil-works/pi-tui": ">=1.0.1"
41
+ "@earendil-works/pi-coding-agent": ">=1.5.0",
42
+ "@earendil-works/pi-tui": ">=1.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@earendil-works/pi-coding-agent": "^1.4.0",
46
- "@earendil-works/pi-tui": "^1.4.0"
45
+ "@earendil-works/pi-coding-agent": "^1.5.0",
46
+ "@earendil-works/pi-tui": "^1.5.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "node -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json"