@prettier-ai/dsh-client-ui-tool 0.1.2-alpha.1
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +111 -0
- package/README.zh.md +111 -0
- package/lib/client.js +2111 -0
- package/lib/index.js +6 -0
- package/lib/invariant.js +23 -0
- package/lib/types/client/apply.d.ts +9 -0
- package/lib/types/client/contract/slots.d.ts +58 -0
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/locale.d.ts +3 -0
- package/lib/types/client/tool/ToolCallTree.d.ts +9 -0
- package/lib/types/client/tool/ToolDetails.d.ts +9 -0
- package/lib/types/client/tool/components/AskQuestionCard.d.ts +11 -0
- package/lib/types/client/tool/components/ToolRow.d.ts +55 -0
- package/lib/types/client/tool/models/ask-question-card-model.d.ts +22 -0
- package/lib/types/client/tool/models/diff-card-model.d.ts +37 -0
- package/lib/types/client/tool/models/primitive-labels.d.ts +36 -0
- package/lib/types/client/tool/models/raw-tool-call.d.ts +27 -0
- package/lib/types/client/tool/models/read-card-model.d.ts +31 -0
- package/lib/types/client/tool/models/search-card-model.d.ts +23 -0
- package/lib/types/client/tool/models/terminal-card-model.d.ts +81 -0
- package/lib/types/client/tool/models/tool-call-model.d.ts +75 -0
- package/lib/types/client/tool/models/web-card-model.d.ts +14 -0
- package/lib/types/client/tool/toolviews/GenericToolCard.d.ts +7 -0
- package/lib/types/client/tool/toolviews/ask-question-row.d.ts +14 -0
- package/lib/types/client/tool/toolviews/bash-sample.d.ts +14 -0
- package/lib/types/client/tool/toolviews/file-mutation-row.d.ts +16 -0
- package/lib/types/client/tool/toolviews/plan-summary.d.ts +48 -0
- package/lib/types/client/tool/toolviews/read-row.d.ts +16 -0
- package/lib/types/client/tool/toolviews/search-row.d.ts +14 -0
- package/lib/types/client/tool/toolviews/todo-row.d.ts +14 -0
- package/lib/types/client/tool/toolviews/web-row.d.ts +14 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/invariant.d.ts +16 -0
- package/package.json +90 -0
package/lib/index.js
ADDED
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@prettier-ai/dsh-client-ui-tool`.
|
|
4
|
+
* @module @prettier-ai/dsh-client-ui-tool/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@prettier-ai/dsh-client-ui-tool";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "client-ui-tool-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: Tool composition is browser-only and contributes no
|
|
13
|
+
* events or cross-plugin mutable state; slot ownership is checked by ui-slots.
|
|
14
|
+
*/
|
|
15
|
+
const install = () => {};
|
|
16
|
+
/**
|
|
17
|
+
* Register this package's invariant companion.
|
|
18
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
+
*/
|
|
21
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
+
//#endregion
|
|
23
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context as ClientContext } from '@prettier-ai/cordis';
|
|
2
|
+
/** Required services: the slot registry and the Host description used for POSIX `~`. */
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
/**
|
|
5
|
+
* Mount the whole-Tool renderers and built-in atomic Tool registrations.
|
|
6
|
+
* @param ctx - Client root context.
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(ctx: ClientContext): void;
|
|
9
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Tool UI slot declarations and their composed component props. */
|
|
2
|
+
import type { ConnectionGenerationState } from '@prettier-ai/dsh-client-connection/client';
|
|
3
|
+
import type { InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime } from '@prettier-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { ToolCallBlock } from '@prettier-ai/dsh-client-ui-chat/client';
|
|
5
|
+
declare module '@prettier-ai/dsh-client-ui-slots' {
|
|
6
|
+
interface SlotMap {
|
|
7
|
+
/**
|
|
8
|
+
* Keyed atomic Tool call view, dispatched by the wire Tool name. Register
|
|
9
|
+
* with `key: '<tool name>'` to own how one tool's calls render inside a
|
|
10
|
+
* turn — the key domain is open (any wire tool name, including a tool your
|
|
11
|
+
* own package registered), so there is no compile-time key set to pick
|
|
12
|
+
* from and a typo simply never renders.
|
|
13
|
+
*
|
|
14
|
+
* A key the shipped composition already covers is replaced, not shared;
|
|
15
|
+
* an unclaimed key falls back to the generic tool row, so registering is
|
|
16
|
+
* additive for your own tool and a takeover for a shipped one. The owner
|
|
17
|
+
* passes the call's identity, its frozen running-or-settled node, and the
|
|
18
|
+
* expansion state (see ToolCallOwnerProps), so the view stays a pure
|
|
19
|
+
* function of what the turn already knows.
|
|
20
|
+
*/
|
|
21
|
+
'tool.call.toolview': {
|
|
22
|
+
kind: 'keyed';
|
|
23
|
+
scope: 'session';
|
|
24
|
+
owner: ToolCallOwnerProps;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Standard owner currency supplied to every atomic Tool view. */
|
|
29
|
+
export interface ToolCallOwnerProps {
|
|
30
|
+
/** Tool call identity, stable across running and settled forms. */
|
|
31
|
+
callId: string;
|
|
32
|
+
/** Wire Tool name and keyed dispatch value. */
|
|
33
|
+
toolName: string;
|
|
34
|
+
/** Frozen running call or settled result node. */
|
|
35
|
+
block: ToolCallBlock;
|
|
36
|
+
/** Session workspace root for relative summaries. */
|
|
37
|
+
cwd?: string | undefined;
|
|
38
|
+
/** Host account home; POSIX home-rooted summaries display as `~`. */
|
|
39
|
+
home?: string | undefined;
|
|
40
|
+
/** Open a Tool argument path through the Host. */
|
|
41
|
+
openFile: (path: string) => void;
|
|
42
|
+
/** Inspect this call in the trajectory view when available. */
|
|
43
|
+
inspect?: (() => void) | undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Full props of a registered atomic Tool view. */
|
|
46
|
+
export type ToolCallViewProps = PropsRuntime<'tool.call.toolview'>;
|
|
47
|
+
/** Injected Host description for POSIX home-path display. */
|
|
48
|
+
export type ToolConnectionGenerationInjected = {
|
|
49
|
+
hooks: {
|
|
50
|
+
/** Current Connection generation, bound by the slot renderer. */
|
|
51
|
+
connectionGeneration: ConnectionGenerationState;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** Full props of the Tool call-tree renderer registered as a `tool-call` Chat Node. */
|
|
55
|
+
export type ToolTreeProps = PropsRuntime<'conversation.chat.node', 'tool-call'> & PropsRenderSlots<'tool.call.toolview'> & PropsLocale<'conversation'> & InjectFace<ToolConnectionGenerationInjected>;
|
|
56
|
+
/** Full props of the selected Tool output renderer in the details panel. */
|
|
57
|
+
export type ToolDetailsProps = PropsRuntime<'conversation.details.tool'> & PropsLocale<'conversation'> & InjectFace<ToolConnectionGenerationInjected>;
|
|
58
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Browser Tool plugin: whole-call composition and keyed atomic Tool views. */
|
|
2
|
+
export { apply, inject } from './apply.ts';
|
|
3
|
+
export type { ToolCallOwnerProps, ToolCallViewProps, ToolConnectionGenerationInjected, ToolDetailsProps, ToolTreeProps, } from './contract/slots.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolTreeProps } from '../contract/slots.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Render one root Tool call and its recursive children through the same
|
|
4
|
+
* atomic keyed dispatch.
|
|
5
|
+
* @param props - whole-Tool owner data and the Tool-owned child-slot share.
|
|
6
|
+
* @returns the Tool call tree.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ToolCallTree({ renderSlot, node, selectedCallId, cwd, openFile, inspectCall, useConnectionGeneration, t, }: ToolTreeProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ToolCallTree.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolDetailsProps } from '../contract/slots.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Render the selected Tool call's structured output when its raw fields form a
|
|
4
|
+
* supported root card, otherwise preserve the flattened result text.
|
|
5
|
+
* @param props - selected call slice, workspace root, host home, and locale seat.
|
|
6
|
+
* @returns the details output body.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ToolDetails({ block, cwd, useConnectionGeneration, t, }: Pick<ToolDetailsProps, 'block' | 'cwd' | 'useConnectionGeneration' | 't'>): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ToolDetails.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Ask-user transcript rendering from validated plain card data. @module */
|
|
2
|
+
import type { AskQuestionCardModel } from '../models/ask-question-card-model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Render a validated ask-user transcript from plain card data.
|
|
5
|
+
* @param props - Localized transcript card data.
|
|
6
|
+
* @returns the readable answered or unanswered question list.
|
|
7
|
+
*/
|
|
8
|
+
export declare function AskQuestionCard({ card }: {
|
|
9
|
+
card: AskQuestionCardModel;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=AskQuestionCard.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { TranslateNS } from '@prettier-ai/dsh-client-ui-slots';
|
|
3
|
+
import { type DiffCardModel } from '../models/diff-card-model.ts';
|
|
4
|
+
import { type ReadCardModel } from '../models/read-card-model.ts';
|
|
5
|
+
import { type SearchCardModel } from '../models/search-card-model.ts';
|
|
6
|
+
import { type TerminalCardModel } from '../models/terminal-card-model.ts';
|
|
7
|
+
import type { AskQuestionCardModel } from '../models/ask-question-card-model.ts';
|
|
8
|
+
import type { ToolRowState, ToolRowVariant } from '../models/tool-call-model.ts';
|
|
9
|
+
import type { WebCardModelProps } from '../models/web-card-model.ts';
|
|
10
|
+
export interface ToolRowProps {
|
|
11
|
+
t: TranslateNS<'conversation'>;
|
|
12
|
+
variant: ToolRowVariant;
|
|
13
|
+
/** Wire tool name for tool-owned styling layered over the generic variant. */
|
|
14
|
+
toolName?: string | undefined;
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
title: string;
|
|
17
|
+
summary: string;
|
|
18
|
+
/**
|
|
19
|
+
* Trailing summary fragment rendered outside the ellipsized summary text, so
|
|
20
|
+
* a narrow row clips the summary before this. For a fragment whose whole
|
|
21
|
+
* value is surviving that clip — the todo row's parallel-active count.
|
|
22
|
+
* null/absent = the summary is the whole collapsed content. Dropped on an
|
|
23
|
+
* error row, whose collapsed summary is the failure line instead.
|
|
24
|
+
*/
|
|
25
|
+
summarySuffix?: string | null | undefined;
|
|
26
|
+
/** Expanded-body input text; null = no input section. */
|
|
27
|
+
body: string | null;
|
|
28
|
+
/** Flattened result text for the expanded Output section; null/absent = no output section. */
|
|
29
|
+
output?: string | null | undefined;
|
|
30
|
+
/** Ask-user transcript card; card fields are mutually exclusive and replace text sections. */
|
|
31
|
+
askQuestion?: AskQuestionCardModel | null | undefined;
|
|
32
|
+
/** Error first line shown as the collapsed summary on an error row; null/absent = keep `summary`. */
|
|
33
|
+
errorSummary?: string | null | undefined;
|
|
34
|
+
/** Terminal card; card fields are mutually exclusive and replace text sections. */
|
|
35
|
+
terminal?: TerminalCardModel | null | undefined;
|
|
36
|
+
diff?: DiffCardModel | null | undefined;
|
|
37
|
+
read?: ReadCardModel | null | undefined;
|
|
38
|
+
search?: SearchCardModel | null | undefined;
|
|
39
|
+
web?: WebCardModelProps | null | undefined;
|
|
40
|
+
state: ToolRowState;
|
|
41
|
+
/**
|
|
42
|
+
* Filesystem path from tool args; when set with onOpenFile, the summary
|
|
43
|
+
* renders as a hover-underline link that opens the host default app.
|
|
44
|
+
*/
|
|
45
|
+
filePath?: string | undefined;
|
|
46
|
+
/** Open the path with the host OS default application (already cwd-resolved). */
|
|
47
|
+
onOpenFile?: ((path: string) => void) | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Jump to this call in the trajectory view: a hover-revealed Inspect pill
|
|
50
|
+
* over the expanded body. Absent = no affordance.
|
|
51
|
+
*/
|
|
52
|
+
inspect?: (() => void) | undefined;
|
|
53
|
+
}
|
|
54
|
+
export declare function ToolRow({ t, variant, toolName, icon, title, summary, summarySuffix, body, output, askQuestion, errorSummary, terminal, diff, read, search, web, state, filePath, onOpenFile, inspect, }: ToolRowProps): import("react").JSX.Element;
|
|
55
|
+
//# sourceMappingURL=ToolRow.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Pure ask-user transcript card data shared by its presenter and renderer. @module */
|
|
2
|
+
interface AnsweredQuestionCardItem {
|
|
3
|
+
id: string;
|
|
4
|
+
question: string;
|
|
5
|
+
answers: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
interface UnansweredQuestionCardItem {
|
|
8
|
+
id: string;
|
|
9
|
+
question: string;
|
|
10
|
+
}
|
|
11
|
+
/** Validated, localized data rendered by the ask-user transcript card. */
|
|
12
|
+
export type AskQuestionCardModel = {
|
|
13
|
+
kind: 'answered';
|
|
14
|
+
questions: readonly AnsweredQuestionCardItem[];
|
|
15
|
+
skippedLabel: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'unanswered';
|
|
18
|
+
questions: readonly UnansweredQuestionCardItem[];
|
|
19
|
+
verdict: string;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=ask-question-card-model.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Pure diff-card derivation from raw file-mutation calls and result metadata. @module */
|
|
2
|
+
import type { DiffBlockProps } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import type { ToolCallBlock } from './tool-call-model.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Diff-body lines the chat row shows before collapsing the middle — half the
|
|
6
|
+
* primitive's own default, which the details panel keeps. A chat row is a
|
|
7
|
+
* summary surface inside the message flow: the flow must stay scannable across
|
|
8
|
+
* many calls, while the details panel is the single-call reading surface. The
|
|
9
|
+
* same split {@link CHAT_TERMINAL_MAX_LINES} draws for a terminal card, so the
|
|
10
|
+
* two card kinds cap a long body at the same place in the flow. A design
|
|
11
|
+
* constant of this UI's row geometry, not a deployment choice.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CHAT_DIFF_MAX_LINES = 8;
|
|
14
|
+
/**
|
|
15
|
+
* The {@link DiffBlock} props this derivation owns. Picked off the primitive's
|
|
16
|
+
* props so the two stay in step; `maxLines`/`className` belong to each render
|
|
17
|
+
* site.
|
|
18
|
+
*/
|
|
19
|
+
export interface DiffCardModel {
|
|
20
|
+
/**
|
|
21
|
+
* The props {@link DiffBlock} draws. Held as a nested object so a render site
|
|
22
|
+
* spreads exactly the primitive's own surface and can never leak a
|
|
23
|
+
* neighbouring field into it.
|
|
24
|
+
*/
|
|
25
|
+
card: Pick<DiffBlockProps, 'diffs'>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derive running diffs for root write/edit and `str_replace_editor`
|
|
29
|
+
* create/replace calls, plus applied settled diffs for root write/edit calls.
|
|
30
|
+
* A successful write with valid empty metadata uses its argument-derived
|
|
31
|
+
* whole-file diff, matching create and identical-overwrite presentation;
|
|
32
|
+
* `str_replace_editor` settles through Generic because it has no result view.
|
|
33
|
+
* @param block - running or settled Tool block.
|
|
34
|
+
* @returns the diff-card props, or null for the generic path.
|
|
35
|
+
*/
|
|
36
|
+
export declare function diffCardModel(block: ToolCallBlock): DiffCardModel | null;
|
|
37
|
+
//# sourceMappingURL=diff-card-model.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Localized copy adapters for Cordis-free UI primitives used by Tool cards. */
|
|
2
|
+
import type { DiffBlockLabels, MarkdownLabels, ReadBlockLabels, SearchBlockLabels, WebBlockLabels } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import type { TranslateNS } from '@prettier-ai/dsh-client-ui-slots';
|
|
4
|
+
type T = TranslateNS<'conversation'>;
|
|
5
|
+
/**
|
|
6
|
+
* Build localized Markdown chrome labels.
|
|
7
|
+
* @param t - Conversation locale seat.
|
|
8
|
+
* @returns Markdown chrome labels.
|
|
9
|
+
*/
|
|
10
|
+
export declare function markdownLabels(t: T): MarkdownLabels;
|
|
11
|
+
/**
|
|
12
|
+
* Build localized diff-card chrome labels.
|
|
13
|
+
* @param t - Conversation locale seat.
|
|
14
|
+
* @returns Diff-card chrome labels.
|
|
15
|
+
*/
|
|
16
|
+
export declare function diffBlockLabels(t: T): DiffBlockLabels;
|
|
17
|
+
/**
|
|
18
|
+
* Build localized read-card chrome labels.
|
|
19
|
+
* @param t - Conversation locale seat.
|
|
20
|
+
* @returns Read-card chrome labels.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readBlockLabels(t: T): ReadBlockLabels;
|
|
23
|
+
/**
|
|
24
|
+
* Build localized search-card chrome labels.
|
|
25
|
+
* @param t - Conversation locale seat.
|
|
26
|
+
* @returns Search-card chrome labels.
|
|
27
|
+
*/
|
|
28
|
+
export declare function searchBlockLabels(t: T): SearchBlockLabels;
|
|
29
|
+
/**
|
|
30
|
+
* Build localized web-card chrome labels.
|
|
31
|
+
* @param t - Conversation locale seat.
|
|
32
|
+
* @returns Web-card chrome labels.
|
|
33
|
+
*/
|
|
34
|
+
export declare function webBlockLabels(t: T): WebBlockLabels;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=primitive-labels.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Shared narrowing for raw Tool call and result fields consumed by card models. */
|
|
2
|
+
import type { ToolCallBlock, ToolResultNode } from '@prettier-ai/dsh-client-ui-chat/client';
|
|
3
|
+
/** A parsed, in-window Tool call whose arguments are a JSON object. */
|
|
4
|
+
export interface ParsedToolCall {
|
|
5
|
+
name: string;
|
|
6
|
+
args: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse the call head paired with one immutable Tool block.
|
|
10
|
+
* @param block - running or settled Tool block.
|
|
11
|
+
* @returns the Tool name and object arguments, or null when the call head or valid JSON object is unavailable.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parsedToolCall(block: ToolCallBlock): ParsedToolCall | null;
|
|
14
|
+
/**
|
|
15
|
+
* Read the exact single text block consumed by first-party card derivations.
|
|
16
|
+
* @param block - settled Tool result.
|
|
17
|
+
* @returns its text, or undefined for any other content layout.
|
|
18
|
+
*/
|
|
19
|
+
export declare function singleResultText(block: ToolResultNode): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Validate the optional escalation pair shared by first-party shell and file
|
|
22
|
+
* mutation tools.
|
|
23
|
+
* @param args - parsed open-root Tool arguments.
|
|
24
|
+
* @returns whether the declared escalation fields form a valid pair.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validEscalationFields(args: Record<string, unknown>): boolean;
|
|
27
|
+
//# sourceMappingURL=raw-tool-call.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Pure read-card derivation from raw result content and metadata. @module */
|
|
2
|
+
import type { ReadBlockProps } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import { type ToolCallBlock } from './tool-call-model.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Content lines the chat row's resident read body shows before collapsing the
|
|
6
|
+
* middle — half the primitive's own default, which the details panel keeps. A
|
|
7
|
+
* chat row is a summary surface inside the message flow: the flow must stay
|
|
8
|
+
* scannable across many calls, while the details panel is the single-call
|
|
9
|
+
* reading surface. A design constant of this UI's row geometry, not a
|
|
10
|
+
* deployment choice, so it is fixed here rather than a plugin Config field. The
|
|
11
|
+
* same split [`CHAT_TERMINAL_MAX_LINES`](./terminal-card-model.ts) draws for
|
|
12
|
+
* terminal output.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CHAT_READ_MAX_LINES = 8;
|
|
15
|
+
/**
|
|
16
|
+
* The {@link ReadBlock} props this derivation owns. Picked off the primitive's
|
|
17
|
+
* props so the two stay in step; `maxLines`/`className` belong to each render
|
|
18
|
+
* site.
|
|
19
|
+
*/
|
|
20
|
+
export type ReadCardModel = Pick<ReadBlockProps, 'label' | 'lines' | 'totalLines' | 'lang'>;
|
|
21
|
+
/**
|
|
22
|
+
* Derive a settled root read card after validating its persisted metadata and
|
|
23
|
+
* model-facing read envelope.
|
|
24
|
+
* @param block - running or settled Tool block.
|
|
25
|
+
* @param sessionCwd - the session workspace root; a workspace-rooted absolute
|
|
26
|
+
* path label displays relative to it. Absent leaves the path as authored.
|
|
27
|
+
* @param home - host account home; a leftover POSIX home path displays as `~`.
|
|
28
|
+
* @returns the read-card props, or null for the generic path.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readCardModel(block: ToolCallBlock, sessionCwd?: string, home?: string): ReadCardModel | null;
|
|
31
|
+
//# sourceMappingURL=read-card-model.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Pure search-card derivation from raw grep/glob result metadata. @module */
|
|
2
|
+
import type { SearchBlockProps } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import type { ToolCallBlock } from './tool-call-model.ts';
|
|
4
|
+
type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
|
|
5
|
+
/** The {@link SearchBlockProps} union minus each render site's own fields. */
|
|
6
|
+
type SearchBlockModelProps = DistributiveOmit<SearchBlockProps, 'labels' | 'maxLines' | 'className'>;
|
|
7
|
+
/** Result rows retained in a Chat card before its middle collapses. */
|
|
8
|
+
export declare const CHAT_SEARCH_MAX_LINES = 8;
|
|
9
|
+
/** Search-card props plus an optional locator for a capped full result. */
|
|
10
|
+
export interface SearchCardModel {
|
|
11
|
+
/** Props consumed by {@link SearchBlock}. */
|
|
12
|
+
card: SearchBlockModelProps;
|
|
13
|
+
/** Raw result text containing the full-result locator for a capped search. */
|
|
14
|
+
recovery: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Derive a settled root grep/glob card from persisted metadata.
|
|
18
|
+
* @param block - running or settled Tool block.
|
|
19
|
+
* @returns search-card props, or null for the generic path.
|
|
20
|
+
*/
|
|
21
|
+
export declare function searchCardModel(block: ToolCallBlock): SearchCardModel | null;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=search-card-model.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Pure terminal-card derivation from raw Tool call and result fields. @module */
|
|
2
|
+
import type { TerminalBlockLabels, TerminalBlockProps } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import type { TranslateNS } from '@prettier-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { ToolCallBlock } from './tool-call-model.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Build the TerminalBlock display copy from the conversation locale seat —
|
|
7
|
+
* the one place the primitive's label surface pairs with this package's
|
|
8
|
+
* dictionary, shared by every terminal render site (chat row, bash row,
|
|
9
|
+
* details panel).
|
|
10
|
+
* @param t - the render site's conversation locale seat.
|
|
11
|
+
* @returns the full label set for {@link TerminalBlockProps}'s `labels`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function terminalBlockLabels(t: TranslateNS<'conversation'>): TerminalBlockLabels;
|
|
14
|
+
/**
|
|
15
|
+
* The {@link TerminalBlock} props this derivation owns. Picked off the
|
|
16
|
+
* primitive's props so the two stay in step; `maxLines`/`className` belong to
|
|
17
|
+
* each render site.
|
|
18
|
+
*/
|
|
19
|
+
export interface TerminalCardModel {
|
|
20
|
+
/**
|
|
21
|
+
* The locale-neutral props {@link TerminalBlock} draws. The render site adds
|
|
22
|
+
* `command` after resolving {@link copy} through its locale seat.
|
|
23
|
+
*/
|
|
24
|
+
card: Pick<TerminalBlockProps, 'cwd' | 'output' | 'exitCode' | 'signal' | 'running'>;
|
|
25
|
+
/**
|
|
26
|
+
* Verbatim Tool data or semantic `terminal_send` data. Product copy stays
|
|
27
|
+
* unresolved until a render site supplies its locale seat.
|
|
28
|
+
*/
|
|
29
|
+
copy: {
|
|
30
|
+
readonly kind: 'shell';
|
|
31
|
+
readonly command: string;
|
|
32
|
+
readonly description: string | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: 'terminal-send';
|
|
35
|
+
readonly text: string;
|
|
36
|
+
readonly sessionId: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
interface LocalizedTerminalCardModel {
|
|
40
|
+
readonly card: Pick<TerminalBlockProps, 'command' | 'cwd' | 'output' | 'exitCode' | 'signal' | 'running'>;
|
|
41
|
+
readonly description: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve locale-owned `terminal_send` copy while preserving Tool-authored
|
|
45
|
+
* shell commands and descriptions verbatim.
|
|
46
|
+
* @param model - locale-neutral terminal card data.
|
|
47
|
+
* @param t - the render site's conversation locale seat.
|
|
48
|
+
* @returns terminal props and description ready for rendering.
|
|
49
|
+
*/
|
|
50
|
+
export declare function localizeTerminalCardModel(model: TerminalCardModel, t: TranslateNS<'conversation'>): LocalizedTerminalCardModel;
|
|
51
|
+
/**
|
|
52
|
+
* True when a settled terminal card reports a failing exit — a non-zero code
|
|
53
|
+
* or a terminating signal. The bash tool settles a failing command as a
|
|
54
|
+
* completed call (`isError` stays false: the exit status is result data), so
|
|
55
|
+
* this is the collapsed row's only failure signal; without it the red exit
|
|
56
|
+
* pill would be visible only after expanding the card.
|
|
57
|
+
* @param model - a derived terminal card.
|
|
58
|
+
* @returns whether the card's exit status is a failure.
|
|
59
|
+
*/
|
|
60
|
+
export declare function terminalFailed(model: TerminalCardModel): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Identify a settled root call from the persistent Bash or PowerShell tool.
|
|
63
|
+
* Its result stays on the generic input/output path because the persistent
|
|
64
|
+
* shell can report resets and partial output without one process exit status.
|
|
65
|
+
* @param block - running or settled Tool block.
|
|
66
|
+
* @returns whether the block is a settled persistent-shell call.
|
|
67
|
+
*/
|
|
68
|
+
export declare function isSettledPersistentShellCall(block: ToolCallBlock): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Derive terminal props for supported root shell and terminal-send calls.
|
|
71
|
+
* Standard shell results parse their final status marker; persistent shell
|
|
72
|
+
* results, background calls, errors, malformed input, or child dispatches use
|
|
73
|
+
* the generic path. {@link isSettledPersistentShellCall} lets that generic
|
|
74
|
+
* persistent result remain expandable without inventing one process status.
|
|
75
|
+
* @param block - running or settled Tool block.
|
|
76
|
+
* @param sessionCwd - session workspace root used to resolve workdir.
|
|
77
|
+
* @returns locale-neutral terminal-card data, or null for the generic path.
|
|
78
|
+
*/
|
|
79
|
+
export declare function terminalCardModel(block: ToolCallBlock, sessionCwd?: string): TerminalCardModel | null;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=terminal-card-model.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure row-model derivation for tool summary rows: variant classification,
|
|
3
|
+
* one-line summary, expanded-body text, and flattened result output from the
|
|
4
|
+
* frozen call slice. Input material comes from the call ARGUMENTS; output and
|
|
5
|
+
* error material from the settled result node. A supported terminal call gets
|
|
6
|
+
* its expanded body from `terminalCardModel` instead.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolCallBlock, ToolResultNode } from '@prettier-ai/dsh-client-ui-chat/client';
|
|
9
|
+
import type { LocaleKeysOf } from '@prettier-ai/dsh-client-ui-slots';
|
|
10
|
+
export type { ToolCallBlock } from '@prettier-ai/dsh-client-ui-chat/client';
|
|
11
|
+
/** Tool-call row variants selected by the generic atomic renderer. */
|
|
12
|
+
export type ToolRowVariant = 'search' | 'read' | 'bash' | 'write' | 'edit' | 'code' | 'others';
|
|
13
|
+
/** Row state semantic; colors self-supplied via StateDot (design gives none). */
|
|
14
|
+
export type ToolRowState = 'running' | 'ok' | 'error' | 'stopped';
|
|
15
|
+
type ToolTitleKey = Extract<LocaleKeysOf<'conversation'>, `tool.title.${string}`>;
|
|
16
|
+
/** Locale key per generic row variant. */
|
|
17
|
+
export declare const VARIANT_TITLE_KEYS: {
|
|
18
|
+
readonly search: "tool.title.search";
|
|
19
|
+
readonly read: "tool.title.read";
|
|
20
|
+
readonly bash: "tool.title.bash";
|
|
21
|
+
readonly write: "tool.title.write";
|
|
22
|
+
readonly edit: "tool.title.edit";
|
|
23
|
+
readonly code: "tool.title.code";
|
|
24
|
+
readonly others: "tool.title.generic";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Classify a tool name into its row variant.
|
|
28
|
+
* @param toolName - wire tool name.
|
|
29
|
+
* @returns matching variant, others when unknown.
|
|
30
|
+
*/
|
|
31
|
+
export declare function classifyTool(toolName: string): ToolRowVariant;
|
|
32
|
+
/** Everything ToolRow needs, derived once from the frozen slice. */
|
|
33
|
+
export interface ToolRowModel {
|
|
34
|
+
variant: ToolRowVariant;
|
|
35
|
+
titleKey: ToolTitleKey;
|
|
36
|
+
summary: string;
|
|
37
|
+
/**
|
|
38
|
+
* Filesystem path from args (`path` / `file_path`) when the row is a file
|
|
39
|
+
* tool; absent for URL reads and non-file tools. The chat view resolves
|
|
40
|
+
* relative values against the session cwd before opening.
|
|
41
|
+
*/
|
|
42
|
+
filePath: string | undefined;
|
|
43
|
+
/** Expanded-body input text (pretty args); null = no input section. */
|
|
44
|
+
body: string | null;
|
|
45
|
+
/** Flattened result text ({@link resultText}); null while running or when the result carries no text. */
|
|
46
|
+
output: string | null;
|
|
47
|
+
/** First line of the result text on an error row; null for every other state. */
|
|
48
|
+
errorSummary: string | null;
|
|
49
|
+
state: ToolRowState;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Flatten a settled result's content blocks to display text: text blocks
|
|
53
|
+
* verbatim, other block shapes as pretty JSON. Empty content on a failed call
|
|
54
|
+
* falls back to the structured error's `name: code` line.
|
|
55
|
+
* @param node - the settled result node.
|
|
56
|
+
* @returns the flattened result text (may be empty).
|
|
57
|
+
*/
|
|
58
|
+
export declare function resultText(node: ToolResultNode): string;
|
|
59
|
+
/**
|
|
60
|
+
* Strip the workspace root from a workspace-rooted absolute path (display only).
|
|
61
|
+
* @param text - the path to shorten.
|
|
62
|
+
* @param cwd - session workspace root; absent or empty leaves the path unchanged.
|
|
63
|
+
* @returns the path relative to the workspace root, or unchanged when it is not rooted there.
|
|
64
|
+
*/
|
|
65
|
+
export declare function relativizeToCwd(text: string, cwd: string | undefined): string;
|
|
66
|
+
/**
|
|
67
|
+
* Derive the full row model from a frozen call slice.
|
|
68
|
+
* @param toolName - wire tool name (dispatch-supplied; survives windowless results).
|
|
69
|
+
* @param block - RunningToolCall or ToolResultNode off the snapshot caches.
|
|
70
|
+
* @param cwd - session workspace root; workspace-rooted path summaries display relative to it.
|
|
71
|
+
* @param home - host account home; a leftover POSIX home path displays as `~`.
|
|
72
|
+
* @returns the row model.
|
|
73
|
+
*/
|
|
74
|
+
export declare function toolRowModel(toolName: string, block: ToolCallBlock, cwd?: string, home?: string): ToolRowModel;
|
|
75
|
+
//# sourceMappingURL=tool-call-model.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Pure web-card derivation from raw web result metadata. @module */
|
|
2
|
+
import type { WebBlockProps } from '@prettier-ai/dsh-client-ui-primitives';
|
|
3
|
+
import type { ToolCallBlock } from './tool-call-model.ts';
|
|
4
|
+
type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
|
|
5
|
+
/** Web-card data owned by the presenter; render sites add localized labels and classes. */
|
|
6
|
+
export type WebCardModelProps = DistributiveOmit<WebBlockProps, 'labels' | 'className'>;
|
|
7
|
+
/**
|
|
8
|
+
* Derive a settled root web-search or web-fetch card from persisted metadata.
|
|
9
|
+
* @param block - running or settled Tool block.
|
|
10
|
+
* @returns web-card props, or null for the generic path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function webCardModel(block: ToolCallBlock): WebCardModelProps | null;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=web-card-model.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolCallOwnerProps, ToolTreeProps } from '../../contract/slots.ts';
|
|
2
|
+
/** Card props: the owner payload plus the render site's locale seat (plain prop). */
|
|
3
|
+
export interface GenericToolCardProps extends ToolCallOwnerProps {
|
|
4
|
+
t: ToolTreeProps['t'];
|
|
5
|
+
}
|
|
6
|
+
export declare function GenericToolCard({ toolName, block, cwd, home, openFile, inspect, t }: GenericToolCardProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=GenericToolCard.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from '@prettier-ai/cordis';
|
|
2
|
+
import type { PropsLocale } from '@prettier-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { ToolCallViewProps } from '../../contract/slots.ts';
|
|
4
|
+
type AskQuestionRowProps = ToolCallViewProps & PropsLocale<'conversation'>;
|
|
5
|
+
/** Summarizes a pending, answered, cancelled, or interrupted question set. */
|
|
6
|
+
export declare function AskQuestionRow({ toolName, block, inspect, t }: AskQuestionRowProps): import("react").JSX.Element;
|
|
7
|
+
/** Registers the ask-user-question conversation row. */
|
|
8
|
+
export declare const askQuestionToolview: {
|
|
9
|
+
name: string;
|
|
10
|
+
inject: string[];
|
|
11
|
+
apply(ctx: Context): void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=ask-question-row.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context } from '@prettier-ai/cordis';
|
|
2
|
+
import type { PropsLocale } from '@prettier-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { ToolCallViewProps } from '../../contract/slots.ts';
|
|
4
|
+
type BashRowProps = ToolCallViewProps & PropsLocale<'conversation'>;
|
|
5
|
+
/** Renders expandable Bash output with an accessible lifecycle label. */
|
|
6
|
+
export declare function BashRow({ toolName, block, sessionId, useSessions, inspect, t }: BashRowProps): import("react").JSX.Element;
|
|
7
|
+
/** Registers the standalone Bash conversation-row sample. */
|
|
8
|
+
export declare const bashToolviewSample: {
|
|
9
|
+
name: string;
|
|
10
|
+
inject: string[];
|
|
11
|
+
apply(ctx: Context): void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=bash-sample.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from '@prettier-ai/cordis';
|
|
2
|
+
import type { PropsLocale } from '@prettier-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { ToolCallViewProps } from '../../contract/slots.ts';
|
|
4
|
+
type FileMutationRowProps = ToolCallViewProps & PropsLocale<'conversation'>;
|
|
5
|
+
/**
|
|
6
|
+
* Lets users expand an applied file diff and open the reported path.
|
|
7
|
+
*/
|
|
8
|
+
export declare function FileMutationRow({ toolName, block, cwd, home, openFile, inspect, t }: FileMutationRowProps): import("react").JSX.Element;
|
|
9
|
+
/** Registers the edit and write conversation rows. */
|
|
10
|
+
export declare const fileMutationToolview: {
|
|
11
|
+
name: string;
|
|
12
|
+
inject: string[];
|
|
13
|
+
apply(ctx: Context): void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=file-mutation-row.d.ts.map
|