@x1a0f3n9/dsh-client-ui-tool 0.1.5-rc.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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +115 -0
- package/README.zh.md +115 -0
- package/lib/client.js +2394 -0
- package/lib/index.js +6 -0
- package/lib/types/client/apply.d.ts +10 -0
- package/lib/types/client/contract/slots.d.ts +100 -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/components/AskQuestionCard.d.ts +11 -0
- package/lib/types/client/tool/components/ToolRow.d.ts +75 -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/image-card-model.d.ts +45 -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 +43 -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 +87 -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-family-row.d.ts +26 -0
- package/lib/types/client/tool/toolviews/read-image-row.d.ts +24 -0
- package/lib/types/client/tool/toolviews/read-row.d.ts +17 -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/package.json +81 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Register the Tool call tree, details renderer, and built-in atomic views. */
|
|
2
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
3
|
+
/** Required services: the slot registry and the Remote face carrying the Host home used for POSIX `~`. */
|
|
4
|
+
export declare const inject: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Mount the whole-Tool renderers and built-in atomic Tool registrations.
|
|
7
|
+
* @param ctx - Client root context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function apply(ctx: ClientContext): void;
|
|
10
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** Tool UI slot declarations and their composed component props. */
|
|
2
|
+
import type { HostObservable, InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime } from '@x1a0f3n9/dsh-client-ui-slots';
|
|
3
|
+
import type { RemoteHostFacts } from '@x1a0f3n9/dsh-api-remotes/client';
|
|
4
|
+
import type { OpenFileOptions, ToolCallBlock } from '@x1a0f3n9/dsh-client-ui-chat/client';
|
|
5
|
+
import type { MessageImageLoader, MessageImageSource } from '@x1a0f3n9/dsh-client-ui-conversation/client';
|
|
6
|
+
declare module '@x1a0f3n9/dsh-client-ui-slots' {
|
|
7
|
+
interface SlotMap {
|
|
8
|
+
/**
|
|
9
|
+
* Keyed atomic Tool call view, dispatched by the wire Tool name. Register
|
|
10
|
+
* with `key: '<tool name>'` to own how one tool's calls render inside a
|
|
11
|
+
* turn — the key domain is open (any wire tool name, including a tool your
|
|
12
|
+
* own package registered), so there is no compile-time key set to pick
|
|
13
|
+
* from and a typo simply never renders.
|
|
14
|
+
*
|
|
15
|
+
* A key the shipped composition already covers is replaced, not shared;
|
|
16
|
+
* an unclaimed key falls back to the generic tool row, so registering is
|
|
17
|
+
* additive for your own tool and a takeover for a shipped one. The owner
|
|
18
|
+
* passes the call's identity, its frozen running-or-settled node, and the
|
|
19
|
+
* expansion state (see ToolCallOwnerProps), so the view stays a pure
|
|
20
|
+
* function of what the turn already knows.
|
|
21
|
+
*/
|
|
22
|
+
'tool.call.toolview': {
|
|
23
|
+
kind: 'keyed';
|
|
24
|
+
scope: 'session';
|
|
25
|
+
owner: ToolCallOwnerProps;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Durable images of a settled image-bearing Tool call, rendered through
|
|
29
|
+
* the attachment presentation plugin. The Tool layer never imports an
|
|
30
|
+
* attachment implementation: a toolview declares this slot as a child and
|
|
31
|
+
* renders it with the image card's references plus the session-authorized
|
|
32
|
+
* loader it received in its owner, and the attachment plugin fills the
|
|
33
|
+
* gallery. Composing no attachment presentation plugin renders nothing,
|
|
34
|
+
* which is why the image card keeps its own envelope text beside the
|
|
35
|
+
* gallery. A child slot is declared by exactly one entry: registering a
|
|
36
|
+
* second toolview that declares the same child throws at load, so a
|
|
37
|
+
* future image-bearing tool must reuse this entry or own a distinct
|
|
38
|
+
* slot.
|
|
39
|
+
*/
|
|
40
|
+
'tool.call.images': {
|
|
41
|
+
kind: 'single';
|
|
42
|
+
scope: 'session';
|
|
43
|
+
owner: ToolImagesOwnerProps;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Owner currency of the Tool image gallery slot: references plus the loader. */
|
|
48
|
+
export interface ToolImagesOwnerProps {
|
|
49
|
+
/** Durable references or submission-echo previews in result order. */
|
|
50
|
+
images: readonly MessageImageSource[];
|
|
51
|
+
/** Session-authorized image URL loader for the durable arm. */
|
|
52
|
+
loadImage: MessageImageLoader;
|
|
53
|
+
/** Horizontal placement inside the owning record. */
|
|
54
|
+
align: 'start' | 'end';
|
|
55
|
+
}
|
|
56
|
+
/** Standard owner currency supplied to every atomic Tool view. */
|
|
57
|
+
export interface ToolCallOwnerProps {
|
|
58
|
+
/** Tool call identity, stable across running and settled forms. */
|
|
59
|
+
callId: string;
|
|
60
|
+
/** Wire Tool name and keyed dispatch value. */
|
|
61
|
+
toolName: string;
|
|
62
|
+
/** Frozen running call or settled result node. */
|
|
63
|
+
block: ToolCallBlock;
|
|
64
|
+
/** Session workspace root for relative summaries. */
|
|
65
|
+
cwd?: string | undefined;
|
|
66
|
+
/** Host account home; POSIX home-rooted summaries display as `~`. */
|
|
67
|
+
home?: string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Open a Tool argument path. A view that knows which line the call was about
|
|
70
|
+
* passes it, and the opened surface lands there.
|
|
71
|
+
*/
|
|
72
|
+
openFile: (path: string, options?: OpenFileOptions) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Session-authorized image loader for the `tool.call.images` slot, supplied
|
|
75
|
+
* by the chat node that owns this call. A composed chat node always
|
|
76
|
+
* supplies it (`ChatNodeOwnerProps.loadImage` is required), so the tool
|
|
77
|
+
* layer never imports an attachment implementation nor handles URL
|
|
78
|
+
* authorization.
|
|
79
|
+
*/
|
|
80
|
+
loadImage: MessageImageLoader;
|
|
81
|
+
/** Inspect this call in the trajectory view when available. */
|
|
82
|
+
inspect?: (() => void) | undefined;
|
|
83
|
+
}
|
|
84
|
+
/** Full props of a registered atomic Tool view. */
|
|
85
|
+
export type ToolCallViewProps = PropsRuntime<'tool.call.toolview'>;
|
|
86
|
+
/** Injected Host description for POSIX home-path display. */
|
|
87
|
+
export type ToolHostInfoInjected = {
|
|
88
|
+
hooks: {
|
|
89
|
+
/**
|
|
90
|
+
* Fixed Host facts, reached through a hook rather than injected as values:
|
|
91
|
+
* the renderer memoizes an entry's inject result for the registration's
|
|
92
|
+
* lifetime, so facts read there would freeze at whatever the first render
|
|
93
|
+
* saw. Select the field the view needs (`info => info.home`).
|
|
94
|
+
*/
|
|
95
|
+
hostInfo: HostObservable<RemoteHostFacts>;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/** Full props of the Tool call-tree renderer registered as a `tool-call` Chat Node. */
|
|
99
|
+
export type ToolTreeProps = PropsRuntime<'conversation.chat.node', 'tool-call'> & PropsRenderSlots<'tool.call.toolview'> & PropsLocale<'conversation'> & InjectFace<ToolHostInfoInjected>;
|
|
100
|
+
//# 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, ToolHostInfoInjected, 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, cwd, openFile, inspectCall, loadImage, useHostInfo, t, }: ToolTreeProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ToolCallTree.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,75 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { PropsRenderSlots, TranslateNS } from '@x1a0f3n9/dsh-client-ui-slots';
|
|
3
|
+
import type { OpenFileOptions } from '@x1a0f3n9/dsh-client-ui-chat/client';
|
|
4
|
+
import type { MessageImageLoader } from '@x1a0f3n9/dsh-client-ui-conversation/client';
|
|
5
|
+
import { type DiffCardModel } from '../models/diff-card-model.ts';
|
|
6
|
+
import { type ReadCardModel } from '../models/read-card-model.ts';
|
|
7
|
+
import type { ImageCardModel } from '../models/image-card-model.ts';
|
|
8
|
+
import { type SearchCardModel } from '../models/search-card-model.ts';
|
|
9
|
+
import { type TerminalCardModel } from '../models/terminal-card-model.ts';
|
|
10
|
+
import type { AskQuestionCardModel } from '../models/ask-question-card-model.ts';
|
|
11
|
+
import { type ToolRowState, type ToolRowVariant } from '../models/tool-call-model.ts';
|
|
12
|
+
import type { WebCardModelProps } from '../models/web-card-model.ts';
|
|
13
|
+
export interface ToolRowProps {
|
|
14
|
+
t: TranslateNS<'conversation'>;
|
|
15
|
+
variant: ToolRowVariant;
|
|
16
|
+
/** Wire tool name for tool-owned styling layered over the generic variant. */
|
|
17
|
+
toolName?: string | undefined;
|
|
18
|
+
icon: ReactNode;
|
|
19
|
+
title: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
/**
|
|
22
|
+
* Trailing summary fragment rendered outside the ellipsized summary text, so
|
|
23
|
+
* a narrow row clips the summary before this. For a fragment whose whole
|
|
24
|
+
* value is surviving that clip — the todo row's parallel-active count.
|
|
25
|
+
* null/absent = the summary is the whole collapsed content. Dropped on an
|
|
26
|
+
* error row, whose collapsed summary is the failure line instead.
|
|
27
|
+
*/
|
|
28
|
+
summarySuffix?: string | null | undefined;
|
|
29
|
+
/** Original argument JSON formatted only while the row is expanded. */
|
|
30
|
+
bodyRaw?: string | null | undefined;
|
|
31
|
+
/** Flattened result text for the expanded Output section; null/absent = no output section. */
|
|
32
|
+
output?: string | null | undefined;
|
|
33
|
+
/** Ask-user transcript card; card fields are mutually exclusive and replace text sections. */
|
|
34
|
+
askQuestion?: AskQuestionCardModel | null | undefined;
|
|
35
|
+
/** Error first line shown as the collapsed summary on an error row; null/absent = keep `summary`. */
|
|
36
|
+
errorSummary?: string | null | undefined;
|
|
37
|
+
/** Terminal card; card fields are mutually exclusive and replace text sections. */
|
|
38
|
+
terminal?: TerminalCardModel | null | undefined;
|
|
39
|
+
diff?: DiffCardModel | null | undefined;
|
|
40
|
+
read?: ReadCardModel | null | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Image-card material for a call whose result is an image (derived by
|
|
43
|
+
* `imageCardModel`). Rendered through the `tool.call.images` slot, so the
|
|
44
|
+
* tool layer never imports an attachment implementation nor handles URL
|
|
45
|
+
* authorization.
|
|
46
|
+
*/
|
|
47
|
+
image?: ImageCardModel | null | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Dispatch the image gallery through the tool-owned `tool.call.images`
|
|
50
|
+
* slot, supplied by the toolview that owns this row together with the
|
|
51
|
+
* session-authorized loader.
|
|
52
|
+
*/
|
|
53
|
+
renderSlot?: PropsRenderSlots<'tool.call.images'>['renderSlot'] | undefined;
|
|
54
|
+
/** Session-authorized image URL loader for the gallery slot. */
|
|
55
|
+
loadImage?: MessageImageLoader | undefined;
|
|
56
|
+
search?: SearchCardModel | null | undefined;
|
|
57
|
+
web?: WebCardModelProps | null | undefined;
|
|
58
|
+
state: ToolRowState;
|
|
59
|
+
/**
|
|
60
|
+
* Filesystem path from tool args; when set with onOpenFile, the summary
|
|
61
|
+
* renders as a hover-underline link that opens the host default app.
|
|
62
|
+
*/
|
|
63
|
+
filePath?: string | undefined;
|
|
64
|
+
/** 1-based line the call was about; absent = open the file at its beginning. */
|
|
65
|
+
filePathLine?: number | undefined;
|
|
66
|
+
/** Open the path (already cwd-resolved), landing on `filePathLine` when given. */
|
|
67
|
+
onOpenFile?: ((path: string, options?: OpenFileOptions) => void) | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Jump to this call in the trajectory view: a hover-revealed Inspect pill
|
|
70
|
+
* over the expanded body. Absent = no affordance.
|
|
71
|
+
*/
|
|
72
|
+
inspect?: (() => void) | undefined;
|
|
73
|
+
}
|
|
74
|
+
export declare function ToolRow({ t, variant, toolName, icon, title, summary, summarySuffix, bodyRaw, output, askQuestion, errorSummary, terminal, diff, read, image, renderSlot, loadImage, search, web, state, filePath, filePathLine, onOpenFile, inspect, }: ToolRowProps): import("react").JSX.Element;
|
|
75
|
+
//# 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 '@x1a0f3n9/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,45 @@
|
|
|
1
|
+
/** Pure image-card derivation from raw result content and metadata. @module */
|
|
2
|
+
import type { ImageAttachmentRef } from '@x1a0f3n9/dsh-attachment';
|
|
3
|
+
import type { ToolCallBlock } from './tool-call-model.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The image-card material one settled call contributes: the display label plus
|
|
6
|
+
* the durable references the attachment slot renders as a gallery.
|
|
7
|
+
*
|
|
8
|
+
* The bytes are not here. `attachmentId` is opaque and provider-owned, so a UI
|
|
9
|
+
* resolves it to a session-authorized URL at render time; this model never parses
|
|
10
|
+
* it nor derives a path from it.
|
|
11
|
+
*/
|
|
12
|
+
export interface ImageCardModel {
|
|
13
|
+
/** Card label: the read path, shortened the way every other card's is. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** The durable images this result returned, in result order. */
|
|
16
|
+
images: readonly {
|
|
17
|
+
readonly attachment: ImageAttachmentRef;
|
|
18
|
+
}[];
|
|
19
|
+
/**
|
|
20
|
+
* The model-facing envelope text, for the line under the gallery.
|
|
21
|
+
*
|
|
22
|
+
* Taken from the result's own text block rather than the row's flattened
|
|
23
|
+
* result text: an image read's content is `[text envelope, image block]`, and
|
|
24
|
+
* flattening JSON.stringifies the image block, which would print the raw
|
|
25
|
+
* attachment object under the picture — the symptom this card exists to remove.
|
|
26
|
+
*/
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derive a settled image card after validating the call head, persisted
|
|
31
|
+
* metadata (or its argument fallback), and the model-facing image envelope.
|
|
32
|
+
*
|
|
33
|
+
* The card is result-side only: a call carries no content until `execute`
|
|
34
|
+
* returns, so a running `read_image` has none and this returns null for it.
|
|
35
|
+
* Both root and nested calls settle as ToolResultNode; the nested one (a
|
|
36
|
+
* read_image dispatched from inside run_code) persists no presentationMeta, so
|
|
37
|
+
* its label falls back to the call's own `file_path` argument.
|
|
38
|
+
* @param block - running or settled Tool block.
|
|
39
|
+
* @param sessionCwd - the session workspace root; a workspace-rooted absolute
|
|
40
|
+
* path label displays relative to it. Absent leaves the path as authored.
|
|
41
|
+
* @param home - host account home; a leftover POSIX home path displays as `~`.
|
|
42
|
+
* @returns the image-card props, or null for the generic path.
|
|
43
|
+
*/
|
|
44
|
+
export declare function imageCardModel(block: ToolCallBlock, sessionCwd?: string, home?: string): ImageCardModel | null;
|
|
45
|
+
//# sourceMappingURL=image-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 '@x1a0f3n9/dsh-client-ui-primitives';
|
|
3
|
+
import type { TranslateNS } from '@x1a0f3n9/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 '@x1a0f3n9/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,43 @@
|
|
|
1
|
+
/** Pure read-card derivation from raw result content and metadata. @module */
|
|
2
|
+
import type { ReadBlockProps } from '@x1a0f3n9/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
|
+
* The line one `read` call was about, from its arguments.
|
|
23
|
+
*
|
|
24
|
+
* `offset` is the read tool's own 1-based start line, so opening the path can
|
|
25
|
+
* land where the model looked. Available while the call is still running,
|
|
26
|
+
* unlike the persisted metadata, because the arguments carry it. The arguments
|
|
27
|
+
* are model-produced JSON: only an integer of at least 1 is a line, and a call
|
|
28
|
+
* whose `offset` is anything else names none.
|
|
29
|
+
* @param block - running or settled Tool block.
|
|
30
|
+
* @returns the 1-based line, or undefined when the call named none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readCallLine(block: ToolCallBlock): number | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Derive a settled root read card after validating its persisted metadata and
|
|
35
|
+
* model-facing read envelope.
|
|
36
|
+
* @param block - running or settled Tool block.
|
|
37
|
+
* @param sessionCwd - the session workspace root; a workspace-rooted absolute
|
|
38
|
+
* path label displays relative to it. Absent leaves the path as authored.
|
|
39
|
+
* @param home - host account home; a leftover POSIX home path displays as `~`.
|
|
40
|
+
* @returns the read-card props, or null for the generic path.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readCardModel(block: ToolCallBlock, sessionCwd?: string, home?: string): ReadCardModel | null;
|
|
43
|
+
//# 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 '@x1a0f3n9/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,87 @@
|
|
|
1
|
+
/** Pure terminal-card derivation from raw Tool call and result fields. @module */
|
|
2
|
+
import type { TerminalBlockLabels, TerminalBlockProps } from '@x1a0f3n9/dsh-client-ui-primitives';
|
|
3
|
+
import type { TranslateNS } from '@x1a0f3n9/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
|
+
* Identify a settled foreground shell preview whose spill footer can hide the exit marker.
|
|
71
|
+
* @param block - running or settled Tool block.
|
|
72
|
+
* @returns whether the shell output must remain generic without an inferred exit status.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isSpilledShellCall(block: ToolCallBlock): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Derive terminal props for supported shell and terminal-send calls, including
|
|
77
|
+
* nested Code Dispatch calls. Standard shell results parse their final status
|
|
78
|
+
* marker; persistent shell results, spill previews, background calls, errors,
|
|
79
|
+
* and malformed input use the generic path. {@link isSettledPersistentShellCall} lets that generic
|
|
80
|
+
* persistent result remain expandable without inventing one process status.
|
|
81
|
+
* @param block - running or settled Tool block.
|
|
82
|
+
* @param sessionCwd - session workspace root used to resolve workdir.
|
|
83
|
+
* @returns locale-neutral terminal-card data, or null for the generic path.
|
|
84
|
+
*/
|
|
85
|
+
export declare function terminalCardModel(block: ToolCallBlock, sessionCwd?: string): TerminalCardModel | null;
|
|
86
|
+
export {};
|
|
87
|
+
//# 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, expansion-time body input, and flattened result output
|
|
4
|
+
* from the frozen call slice. Input material comes from the call ARGUMENTS;
|
|
5
|
+
* output and error material from the settled result node. A supported terminal
|
|
6
|
+
* call gets its expanded body from `terminalCardModel` instead.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolCallBlock, ToolResultNode } from '@x1a0f3n9/dsh-client-ui-chat/client';
|
|
9
|
+
import type { LocaleKeysOf } from '@x1a0f3n9/dsh-client-ui-slots';
|
|
10
|
+
export type { ToolCallBlock } from '@x1a0f3n9/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
|
+
/** Original argument JSON retained for expansion-time body formatting. */
|
|
44
|
+
bodyRaw: 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
|
+
* Format one argument payload when its generic input body becomes visible.
|
|
61
|
+
* @param variant - row presentation selected for the Tool name.
|
|
62
|
+
* @param argsRaw - original argument JSON or incomplete raw text.
|
|
63
|
+
* @returns display body, or null for empty input.
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatToolBody(variant: ToolRowVariant, argsRaw: string): string | null;
|
|
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 '@x1a0f3n9/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
|