@hheei/pi-ext-ui 0.6.0 → 0.7.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.
- package/README.md +2 -2
- package/dist/background.d.ts +11 -0
- package/dist/background.js +31 -0
- package/dist/extension.js +59 -7
- package/dist/host-transcript-patch.js +176 -58
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/message-view.d.ts +4 -10
- package/dist/message-view.js +29 -16
- package/dist/native-tools.d.ts +69 -0
- package/dist/native-tools.js +414 -0
- package/dist/nested-calls-view.d.ts +6 -2
- package/dist/nested-calls-view.js +58 -73
- package/dist/payload-parser.d.ts +10 -28
- package/dist/payload-parser.js +9 -269
- package/dist/renderer.d.ts +6 -4
- package/dist/renderer.js +242 -181
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +16 -0
- package/dist/settings.d.ts +3 -0
- package/dist/settings.js +18 -1
- package/dist/tool-group-view.d.ts +52 -8
- package/dist/tool-group-view.js +351 -164
- package/dist/tool-view.d.ts +20 -6
- package/dist/tool-view.js +77 -30
- package/dist/tracker.d.ts +36 -17
- package/dist/tracker.js +157 -19
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NestedCallArgsIndex, ToolExecutionTracker } from "./tracker.js";
|
|
2
|
+
/**
|
|
3
|
+
* The mutable state one extension runtime owns: nested-call captures, the session-branch argument
|
|
4
|
+
* index, and the tool background preference. Two Pi runtimes in one process never share it, so a
|
|
5
|
+
* restart, cleanup or settings change in one cannot reach the other.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ToolUiRuntime {
|
|
8
|
+
readonly tracker: ToolExecutionTracker;
|
|
9
|
+
readonly nestedCalls: NestedCallArgsIndex;
|
|
10
|
+
/** Pi-native per-tool backgrounds are opt-in; the default is the quiet transparent row. */
|
|
11
|
+
backgrounds: boolean;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NestedCallArgsIndex, ToolExecutionTracker } from "./tracker.js";
|
|
2
|
+
/**
|
|
3
|
+
* The mutable state one extension runtime owns: nested-call captures, the session-branch argument
|
|
4
|
+
* index, and the tool background preference. Two Pi runtimes in one process never share it, so a
|
|
5
|
+
* restart, cleanup or settings change in one cannot reach the other.
|
|
6
|
+
*/
|
|
7
|
+
export class ToolUiRuntime {
|
|
8
|
+
tracker = new ToolExecutionTracker();
|
|
9
|
+
nestedCalls = new NestedCallArgsIndex();
|
|
10
|
+
/** Pi-native per-tool backgrounds are opt-in; the default is the quiet transparent row. */
|
|
11
|
+
backgrounds = false;
|
|
12
|
+
clear() {
|
|
13
|
+
this.tracker.clear();
|
|
14
|
+
this.nestedCalls.setSource(undefined);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type SettingsProvider, type SettingsState } from "@hheei/pi-ext-core";
|
|
2
2
|
/** Missing or non-boolean values stay on; only an explicit false disables groups. */
|
|
3
3
|
export declare function activityGroupsEnabled(state: SettingsState | undefined): boolean;
|
|
4
|
+
/** Off by default: a tool row only paints Pi's own surface when the reader asks for it. */
|
|
5
|
+
export declare function toolBackgroundsEnabled(state: SettingsState | undefined): boolean;
|
|
4
6
|
export declare function createToolGroupSettings(options: {
|
|
5
7
|
readonly onEnabled: (enabled: boolean) => void;
|
|
8
|
+
readonly onBackgrounds: (enabled: boolean) => void;
|
|
6
9
|
}): SettingsProvider;
|
package/dist/settings.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { createJsonSettingsStorage, } from "@hheei/pi-ext-core";
|
|
2
2
|
const GROUP = "toolGroups";
|
|
3
3
|
const FIELD = "enabled";
|
|
4
|
+
const BACKGROUNDS = "toolBackgrounds";
|
|
4
5
|
/** Missing or non-boolean values stay on; only an explicit false disables groups. */
|
|
5
6
|
export function activityGroupsEnabled(state) {
|
|
6
7
|
const value = state?.[GROUP]?.[FIELD];
|
|
7
8
|
return value !== false;
|
|
8
9
|
}
|
|
10
|
+
/** Off by default: a tool row only paints Pi's own surface when the reader asks for it. */
|
|
11
|
+
export function toolBackgroundsEnabled(state) {
|
|
12
|
+
return state?.[GROUP]?.[BACKGROUNDS] === true;
|
|
13
|
+
}
|
|
9
14
|
export function createToolGroupSettings(options) {
|
|
10
15
|
return {
|
|
11
16
|
id: "pi-ext-ui",
|
|
@@ -24,13 +29,25 @@ export function createToolGroupSettings(options) {
|
|
|
24
29
|
description: "Group consecutive tool, thinking, and notification rows in the TUI transcript.",
|
|
25
30
|
parse: (draft) => draft === "true",
|
|
26
31
|
},
|
|
32
|
+
{
|
|
33
|
+
id: BACKGROUNDS,
|
|
34
|
+
label: "Tool backgrounds",
|
|
35
|
+
type: "boolean",
|
|
36
|
+
defaultValue: false,
|
|
37
|
+
description: "Paint each tool with Pi's own success/error surface, one padding row above and below, and no leading rail. The activity group then stays transparent.",
|
|
38
|
+
parse: (draft) => draft === "true",
|
|
39
|
+
},
|
|
27
40
|
],
|
|
28
41
|
},
|
|
29
42
|
],
|
|
30
43
|
storage: createJsonSettingsStorage({ group: GROUP }),
|
|
31
44
|
onChange(change) {
|
|
32
|
-
if (change.groupId
|
|
45
|
+
if (change.groupId !== GROUP)
|
|
46
|
+
return;
|
|
47
|
+
if (change.fieldId === FIELD)
|
|
33
48
|
options.onEnabled(change.value === true);
|
|
49
|
+
if (change.fieldId === BACKGROUNDS)
|
|
50
|
+
options.onBackgrounds(change.value === true);
|
|
34
51
|
},
|
|
35
52
|
};
|
|
36
53
|
}
|
|
@@ -7,28 +7,60 @@ export interface Usage {
|
|
|
7
7
|
readonly cacheRead: number;
|
|
8
8
|
readonly cacheWrite: number;
|
|
9
9
|
}
|
|
10
|
-
export type MemberKind = "
|
|
10
|
+
export type MemberKind = "thinking" | "tool" | "notice";
|
|
11
11
|
export type Category = "tools" | "thinking" | "notices";
|
|
12
|
+
/**
|
|
13
|
+
* One model request the block owns, in transcript order. A block's requests are not the same set
|
|
14
|
+
* as its displayed members: the assistant text that ends a loop is native content, but its usage
|
|
15
|
+
* still belongs to the block whose work it answers.
|
|
16
|
+
*/
|
|
17
|
+
export interface RequestFact {
|
|
18
|
+
readonly usage?: Usage;
|
|
19
|
+
}
|
|
12
20
|
/** One transcript entry a block owns, reduced to the facts the collapsed frame draws. */
|
|
13
21
|
export interface Member {
|
|
14
22
|
readonly kind: MemberKind;
|
|
15
23
|
readonly component: Component;
|
|
24
|
+
/**
|
|
25
|
+
* Every original component this member stands for. A thinking member is one continuous run, so
|
|
26
|
+
* it can span several assistant messages; the raw view prints them in order.
|
|
27
|
+
*/
|
|
28
|
+
readonly parts?: readonly Component[];
|
|
16
29
|
readonly title?: string;
|
|
17
30
|
readonly summary?: string;
|
|
18
31
|
readonly status?: ToolStatusKind;
|
|
19
32
|
readonly children?: readonly ToolViewChild[];
|
|
20
33
|
/** Nested calls the member made, when `children` is only what fits. */
|
|
21
34
|
readonly childCount?: number;
|
|
35
|
+
/** Full thinking text of the run, kept regardless of the host's hide preference. */
|
|
22
36
|
readonly thinking?: string;
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
|
|
37
|
+
/** Pi hides thinking by default: show one preview row that opens the full text. */
|
|
38
|
+
readonly thinkingHidden?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* A tool enters the block's counts only after its final result arrived. Streaming args, an
|
|
41
|
+
* execution start, and partial results are not completed calls; a cancelled or failed call that
|
|
42
|
+
* did receive its final result is.
|
|
43
|
+
*/
|
|
44
|
+
readonly completed?: boolean;
|
|
45
|
+
/** Rows this member shows directly under its label: a notice body or a preview. */
|
|
46
|
+
readonly content?: (width: number) => readonly string[];
|
|
47
|
+
/** Rows opening this member reveals; its presence is what makes the item expandable. */
|
|
48
|
+
readonly detail?: (width: number) => readonly string[];
|
|
26
49
|
}
|
|
27
|
-
/**
|
|
28
|
-
export interface
|
|
50
|
+
/** Runtime duration of one continuous activity block. */
|
|
51
|
+
export interface ToolGroupClock {
|
|
29
52
|
readonly startedAt: number;
|
|
30
53
|
endedAt?: number;
|
|
31
54
|
}
|
|
55
|
+
/** Every original component of a member, in transcript order. */
|
|
56
|
+
export declare function memberParts(member: Member): readonly Component[];
|
|
57
|
+
export declare class TailUnit implements Component {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(member: Member);
|
|
60
|
+
render(width: number): string[];
|
|
61
|
+
handleMouse(event: Parameters<NonNullable<Component["handleMouse"]>>[0]): import("@earendil-works/pi-tui").TuiMouseEventResult | undefined;
|
|
62
|
+
invalidate(): void;
|
|
63
|
+
}
|
|
32
64
|
/**
|
|
33
65
|
* The collapsed frame of one activity block.
|
|
34
66
|
*
|
|
@@ -38,8 +70,20 @@ export interface ToolGroupRun {
|
|
|
38
70
|
*/
|
|
39
71
|
export declare class ToolGroupView extends Container {
|
|
40
72
|
#private;
|
|
41
|
-
constructor(ui: ExtensionUIContext, redraw: () => void
|
|
42
|
-
|
|
73
|
+
constructor(ui: ExtensionUIContext, redraw: () => void);
|
|
74
|
+
/**
|
|
75
|
+
* Release the block's own lifetime. The projection drops a block when it is evicted, when
|
|
76
|
+
* grouping is disabled, or when the patch unloads; an idempotent dispose keeps that path honest,
|
|
77
|
+
* so a removed block can never ask for a repaint.
|
|
78
|
+
*/
|
|
79
|
+
dispose(): void;
|
|
80
|
+
/**
|
|
81
|
+
* `clock` belongs to this continuous block. Restored history has none until live content joins it.
|
|
82
|
+
*
|
|
83
|
+
* `tail` is the block's last visible unit, which the projection draws outside the group; its calls,
|
|
84
|
+
* requests, and background state still belong to this block.
|
|
85
|
+
*/
|
|
86
|
+
update(members: Member[], tail: Member | undefined, requests: readonly RequestFact[], clock: ToolGroupClock | undefined): void;
|
|
43
87
|
invalidate(): void;
|
|
44
88
|
render(width: number): string[];
|
|
45
89
|
}
|