meowtail 0.1.0 → 0.2.0-alpha.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/AGENT-COMPONENTS.md +117 -0
- package/ASSISTANT.md +21 -1
- package/JSON.md +8 -1
- package/README.md +109 -8
- package/dist/src/chat/assistant-composer.js +3 -5
- package/dist/src/chat/assistant-content.d.ts +2 -0
- package/dist/src/chat/assistant-content.js +51 -3
- package/dist/src/chat/assistant-types.d.ts +39 -1
- package/dist/src/chat/assistant.d.ts +1 -1
- package/dist/src/chat/assistant.js +6 -3
- package/dist/src/chat/conversation.d.ts +4 -1
- package/dist/src/chat/conversation.js +5 -2
- package/dist/src/chat/index.d.ts +4 -2
- package/dist/src/chat/index.js +1 -0
- package/dist/src/chat/task.d.ts +29 -0
- package/dist/src/chat/task.js +53 -0
- package/dist/src/chat/tool-call.d.ts +33 -8
- package/dist/src/chat/tool-call.js +70 -26
- package/dist/src/components/grid.js +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/inline.js +1 -0
- package/dist/src/components/layout-item.js +2 -1
- package/dist/src/components/layout-types.d.ts +1 -1
- package/dist/src/components/menu.js +5 -5
- package/dist/src/components/output-block.d.ts +5 -3
- package/dist/src/components/output-block.js +32 -22
- package/dist/src/components/stack.js +1 -0
- package/dist/src/components/status.d.ts +16 -0
- package/dist/src/components/status.js +8 -0
- package/dist/src/json/catalog.d.ts +88 -2
- package/dist/src/json/catalog.js +33 -1
- package/dist/src/registry/index.d.ts +17 -2
- package/dist/src/registry/index.js +6 -1
- package/dist/src/shared/execution-state.d.ts +7 -0
- package/dist/src/shared/execution-state.js +36 -0
- package/dist/src/theme/base.styles.js +15 -0
- package/dist/src/theme/chat/assistant.styles.js +21 -9
- package/dist/src/theme/chat/composer.styles.js +2 -1
- package/dist/src/theme/chat/conversation.styles.js +15 -7
- package/dist/src/theme/chat/records.styles.js +79 -7
- package/dist/src/theme/chat/task.styles.d.ts +1 -0
- package/dist/src/theme/chat/task.styles.js +87 -0
- package/dist/src/theme/components/card.styles.js +9 -3
- package/dist/src/theme/components/field.styles.js +4 -0
- package/dist/src/theme/components/list-group.styles.js +9 -11
- package/dist/src/theme/components/output-block.styles.js +8 -0
- package/dist/src/theme/components/resource-card.styles.js +8 -3
- package/dist/src/theme/components/status.styles.d.ts +1 -0
- package/dist/src/theme/components/status.styles.js +25 -0
- package/dist/src/theme/index.d.ts +148 -0
- package/dist/src/theme/index.js +165 -159
- package/dist/src/theme/shared/code-highlight.styles.js +1 -1
- package/package.json +12 -6
|
@@ -4,7 +4,10 @@ export const chatConversationContract = {
|
|
|
4
4
|
name: "chat-conversation",
|
|
5
5
|
parts: ["root", "viewport", "content", "latest"],
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
7
|
+
/** A normal-flow action for hosts that already own transcript scrolling.
|
|
8
|
+
* Place it beside the host viewport in a height-constrained column; the host
|
|
9
|
+
* owns visibility, returning to the end and restoring viewport focus.
|
|
10
|
+
*/
|
|
8
11
|
export const ChatConversationLatest = defineComponent(chatConversationContract, ({ children, ...props }, context) => context.part("latest", "button", { type: "button", ...props }, children ?? "回到最新消息"));
|
|
9
12
|
/** Optional scroll owner for append-only transcripts. Give the root a constrained height.
|
|
10
13
|
* Do not combine with an application-owned scroll controller. Children can use ChatMessageList.
|
|
@@ -57,6 +60,6 @@ export const ChatConversation = defineComponent(chatConversationContract, ({ chi
|
|
|
57
60
|
role: "region",
|
|
58
61
|
"aria-label": ariaLabel,
|
|
59
62
|
tabIndex: 0,
|
|
60
|
-
style: { overflowY: "auto", minHeight: 0,
|
|
63
|
+
style: { overflowY: "auto", minHeight: 0, overflowAnchor: "none" },
|
|
61
64
|
}, context.part("content", "div", { style: { display: "flow-root" } }, children)), context.part("latest", "button", { type: "button", hidden, onClick: () => jump?.() }, latestLabel));
|
|
62
65
|
});
|
package/dist/src/chat/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export { ChatAttachments, type ChatAttachmentItem, type ChatAttachmentsProps, chatAttachmentsContract, } from "./attachments.js";
|
|
2
2
|
export { ChatComposer, type ChatComposerProps, type ChatComposerInput, type ChatComposerSubmit, chatComposerContract, chatComposerOptions, } from "./composer.js";
|
|
3
3
|
export { ChatFrame, type ChatFrameProps, chatFrameContract } from "./frame.js";
|
|
4
|
-
export { AssistantView, assistantViewContract, assistantCopy, type AssistantViewProps, type AssistantDraft, type AssistantAttachment, type AssistantMessage, type AssistantMessagePart, type AssistantProcessStep, type AssistantActivity, type AssistantWork, type AssistantQuestion, type AssistantChoice, type AssistantLabels, } from "./assistant.js";
|
|
4
|
+
export { AssistantView, assistantViewContract, assistantCopy, type AssistantViewProps, type AssistantDraft, type AssistantAttachment, type AssistantMessage, type AssistantMessagePart, type AssistantToolPart, type AssistantTaskPart, type AssistantProcessStep, type AssistantActivity, type AssistantWork, type AssistantQuestion, type AssistantChoice, type AssistantLabels, } from "./assistant.js";
|
|
5
5
|
export { ChatHeader, type ChatHeaderProps, chatHeaderContract } from "./header.js";
|
|
6
6
|
export { ChatMessage, type ChatMessageProps, type ChatMessageRole, type ChatMessageStatus, chatMessageContract, } from "./message.js";
|
|
7
7
|
export { ChatMessageActions, type ChatMessageActionsProps, chatMessageActionsContract, } from "./message-actions.js";
|
|
8
8
|
export { ChatMessageList, ChatMessageListContent, ChatMessageListItem, ChatMessageListDate, type ChatMessageListContentProps, type ChatMessageListDateProps, type ChatMessageListProps, chatMessageListContract, } from "./message-list.js";
|
|
9
9
|
export { ChatStatus, type ChatStatusProps, type ChatStatusTone, chatStatusContract, chatStatusOptions, } from "./status.js";
|
|
10
|
-
export { ChatToolCall, type ChatToolCallProps, type ChatToolCallState, chatToolCallContract, } from "./tool-call.js";
|
|
10
|
+
export { ChatToolCall, type ChatToolCallProps, type ChatToolCallState, type ChatToolCallLabels, chatToolCallContract, } from "./tool-call.js";
|
|
11
|
+
export { ChatTask, chatTaskContract, type ChatTaskProps, type ChatTaskProgress } from "./task.js";
|
|
12
|
+
export type { ChatExecutionState } from "../shared/execution-state.js";
|
|
11
13
|
export { ChatProcess, chatProcessContract, type ChatProcessProps } from "./process.js";
|
|
12
14
|
export { ChatQuestion, chatQuestionContract, type ChatQuestionProps } from "./question.js";
|
|
13
15
|
export { ChatSources, chatSourcesContract, type ChatSourcesProps, type ChatSource, } from "./sources.js";
|
package/dist/src/chat/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { ChatMessageActions, chatMessageActionsContract, } from "./message-actio
|
|
|
8
8
|
export { ChatMessageList, ChatMessageListContent, ChatMessageListItem, ChatMessageListDate, chatMessageListContract, } from "./message-list.js";
|
|
9
9
|
export { ChatStatus, chatStatusContract, chatStatusOptions, } from "./status.js";
|
|
10
10
|
export { ChatToolCall, chatToolCallContract, } from "./tool-call.js";
|
|
11
|
+
export { ChatTask, chatTaskContract } from "./task.js";
|
|
11
12
|
export { ChatProcess, chatProcessContract } from "./process.js";
|
|
12
13
|
export { ChatQuestion, chatQuestionContract } from "./question.js";
|
|
13
14
|
export { ChatSources, chatSourcesContract, } from "./sources.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Child, type MaybeSignal, type Props } from "meowjsx";
|
|
2
|
+
import { type ChatExecutionState } from "../shared/execution-state.js";
|
|
3
|
+
export declare const chatTaskContract: {
|
|
4
|
+
readonly name: "chat-task";
|
|
5
|
+
readonly parts: readonly ["root", "header", "title", "status", "description", "execution", "reply", "progress", "progressLabel", "progressBar", "body", "footer"];
|
|
6
|
+
};
|
|
7
|
+
export interface ChatTaskProgress {
|
|
8
|
+
value: number;
|
|
9
|
+
max: number;
|
|
10
|
+
/** A meaningful fact, for example "Reviewed 2 of 5 files". */
|
|
11
|
+
label: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ChatTaskProps extends Props {
|
|
14
|
+
title: MaybeSignal<string>;
|
|
15
|
+
state?: MaybeSignal<ChatExecutionState>;
|
|
16
|
+
/** Explain the current state, including who or what a waiting task needs. */
|
|
17
|
+
statusLabel?: MaybeSignal<string | undefined>;
|
|
18
|
+
description?: MaybeSignal<string | undefined>;
|
|
19
|
+
/** Execution and a public reply are separate host facts. Neither infers the other. */
|
|
20
|
+
executionText?: MaybeSignal<string | undefined>;
|
|
21
|
+
replyText?: MaybeSignal<string | undefined>;
|
|
22
|
+
/** Explicit host progress only. Missing progress does not imply zero progress. */
|
|
23
|
+
progress?: MaybeSignal<ChatTaskProgress | undefined>;
|
|
24
|
+
/** Compose ordinary buttons and resource links outside the task's content. */
|
|
25
|
+
footer?: Child;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A task record, not an executable task or a whole-card control. */
|
|
29
|
+
export declare const ChatTask: import("meowjsx").Component<ChatTaskProps, "chat-task", "body" | "description" | "execution" | "footer" | "header" | "progress" | "progressBar" | "progressLabel" | "reply" | "root" | "status" | "title">;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineComponent, h, unwrap, } from "meowjsx";
|
|
2
|
+
import { StatusDot } from "../components/status-dot.js";
|
|
3
|
+
import { executionStateLabel, executionStateTone, } from "../shared/execution-state.js";
|
|
4
|
+
export const chatTaskContract = {
|
|
5
|
+
name: "chat-task",
|
|
6
|
+
parts: [
|
|
7
|
+
"root",
|
|
8
|
+
"header",
|
|
9
|
+
"title",
|
|
10
|
+
"status",
|
|
11
|
+
"description",
|
|
12
|
+
"execution",
|
|
13
|
+
"reply",
|
|
14
|
+
"progress",
|
|
15
|
+
"progressLabel",
|
|
16
|
+
"progressBar",
|
|
17
|
+
"body",
|
|
18
|
+
"footer",
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
function checkedProgress(value) {
|
|
22
|
+
if (value !== undefined &&
|
|
23
|
+
(!Number.isFinite(value.value) ||
|
|
24
|
+
!Number.isFinite(value.max) ||
|
|
25
|
+
value.max <= 0 ||
|
|
26
|
+
value.value < 0 ||
|
|
27
|
+
value.value > value.max)) {
|
|
28
|
+
throw new RangeError("ChatTask progress requires finite values with 0 <= value <= max and max > 0.");
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
/** A task record, not an executable task or a whole-card control. */
|
|
33
|
+
export const ChatTask = defineComponent(chatTaskContract, ({ title, state = "unknown", statusLabel, description, executionText, replyText, progress, footer, children, className, ...props }, context) => {
|
|
34
|
+
const derive = (read) => {
|
|
35
|
+
const result = context.signal(read());
|
|
36
|
+
context.effect(() => {
|
|
37
|
+
result.value = read();
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
const currentProgress = derive(() => checkedProgress(unwrap(progress)));
|
|
42
|
+
const text = (part, value) => context.part(part, "p", { hidden: derive(() => !unwrap(value)) }, derive(() => unwrap(value) ?? ""));
|
|
43
|
+
return context.part("root", "section", {
|
|
44
|
+
...props,
|
|
45
|
+
className,
|
|
46
|
+
"aria-label": props["aria-label"] ?? title,
|
|
47
|
+
"data-execution-state": state,
|
|
48
|
+
}, context.part("header", "div", null, context.part("title", "strong", null, title), context.part("status", "span", null, h(StatusDot, { state: derive(() => executionStateTone(unwrap(state))) }), derive(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state))))), text("description", description), text("execution", executionText), text("reply", replyText), context.part("progress", "div", { hidden: derive(() => currentProgress.value === undefined) }, context.part("progressLabel", "span", null, derive(() => currentProgress.value?.label ?? "")), context.part("progressBar", "progress", {
|
|
49
|
+
value: derive(() => currentProgress.value?.value ?? 0),
|
|
50
|
+
max: derive(() => currentProgress.value?.max ?? 1),
|
|
51
|
+
"aria-label": derive(() => currentProgress.value?.label ?? ""),
|
|
52
|
+
})), context.part("body", "div", null, children), context.part("footer", "div", null, footer));
|
|
53
|
+
});
|
|
@@ -1,21 +1,46 @@
|
|
|
1
|
-
import { type Child, type Props } from "meowjsx";
|
|
1
|
+
import { type Child, type MaybeSignal, type Props } from "meowjsx";
|
|
2
|
+
import { type ChatExecutionState } from "../shared/execution-state.js";
|
|
2
3
|
export declare const chatToolCallContract: {
|
|
3
4
|
readonly name: "chat-tool-call";
|
|
4
|
-
readonly parts: readonly ["root", "header", "icon", "label", "summary", "status", "chevron", "detail", "body"];
|
|
5
|
+
readonly parts: readonly ["root", "header", "icon", "label", "summary", "status", "chevron", "detail", "body", "input", "output", "outputSummary", "actions"];
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
/** The complete spelling remains supported for existing tool consumers. */
|
|
8
|
+
export type ChatToolCallState = ChatExecutionState;
|
|
9
|
+
export interface ChatToolCallLabels {
|
|
10
|
+
input: string;
|
|
11
|
+
output: string;
|
|
12
|
+
emptyInput: string;
|
|
13
|
+
emptyOutput: string;
|
|
14
|
+
retry: string;
|
|
15
|
+
cancel: string;
|
|
16
|
+
}
|
|
7
17
|
export interface ChatToolCallProps extends Props {
|
|
8
|
-
label: string
|
|
18
|
+
label: MaybeSignal<string>;
|
|
9
19
|
/** Short target or action summary, visible while collapsed. */
|
|
10
|
-
summary?: string
|
|
11
|
-
state?: ChatToolCallState
|
|
12
|
-
|
|
20
|
+
summary?: MaybeSignal<string | undefined>;
|
|
21
|
+
state?: MaybeSignal<ChatToolCallState>;
|
|
22
|
+
/** State facts, including who or what is being waited on, belong to the host. */
|
|
23
|
+
statusLabel?: MaybeSignal<string | undefined>;
|
|
13
24
|
detail?: Child;
|
|
14
25
|
icon?: Child;
|
|
26
|
+
/** Tool payloads are inert text. Undefined omits a region; an empty string is explicit empty data. */
|
|
27
|
+
input?: MaybeSignal<string | undefined>;
|
|
28
|
+
output?: MaybeSignal<string | undefined>;
|
|
29
|
+
outputSummary?: MaybeSignal<string | undefined>;
|
|
30
|
+
maxLines?: number;
|
|
15
31
|
/** Reveals this row's own body in place. */
|
|
16
32
|
collapsible?: boolean;
|
|
17
33
|
/** Runs the host's own action instead of revealing a body; the row keeps the row chrome. */
|
|
18
34
|
onActivate?: () => void;
|
|
35
|
+
/** Intent only. The host owns execution, pending state, permissions and the resulting status. */
|
|
36
|
+
onRetry?: () => void;
|
|
37
|
+
onCancel?: () => void;
|
|
38
|
+
/** Whether the host currently offers this intent; unlike disabled, false hides it. */
|
|
39
|
+
canRetry?: MaybeSignal<boolean>;
|
|
40
|
+
canCancel?: MaybeSignal<boolean>;
|
|
41
|
+
retryDisabled?: MaybeSignal<boolean>;
|
|
42
|
+
cancelDisabled?: MaybeSignal<boolean>;
|
|
43
|
+
labels?: Partial<ChatToolCallLabels>;
|
|
19
44
|
className?: string;
|
|
20
45
|
}
|
|
21
|
-
export declare const ChatToolCall: import("meowjsx").Component<ChatToolCallProps, "chat-tool-call", "body" | "chevron" | "detail" | "header" | "icon" | "label" | "root" | "status" | "summary">;
|
|
46
|
+
export declare const ChatToolCall: import("meowjsx").Component<ChatToolCallProps, "chat-tool-call", "actions" | "body" | "chevron" | "detail" | "header" | "icon" | "input" | "label" | "output" | "outputSummary" | "root" | "status" | "summary">;
|
|
@@ -1,40 +1,84 @@
|
|
|
1
|
-
import { defineComponent, h } from "meowjsx";
|
|
1
|
+
import { defineComponent, h, unwrap, } from "meowjsx";
|
|
2
2
|
import { Icon } from "../icons/icon.js";
|
|
3
|
+
import { Button } from "../components/button.js";
|
|
4
|
+
import { OutputBlock } from "../components/output-block.js";
|
|
5
|
+
import { executionStateLabel } from "../shared/execution-state.js";
|
|
3
6
|
export const chatToolCallContract = {
|
|
4
7
|
name: "chat-tool-call",
|
|
5
|
-
parts: [
|
|
8
|
+
parts: [
|
|
9
|
+
"root",
|
|
10
|
+
"header",
|
|
11
|
+
"icon",
|
|
12
|
+
"label",
|
|
13
|
+
"summary",
|
|
14
|
+
"status",
|
|
15
|
+
"chevron",
|
|
16
|
+
"detail",
|
|
17
|
+
"body",
|
|
18
|
+
"input",
|
|
19
|
+
"output",
|
|
20
|
+
"outputSummary",
|
|
21
|
+
"actions",
|
|
22
|
+
],
|
|
6
23
|
};
|
|
7
|
-
export const ChatToolCall = defineComponent(chatToolCallContract, ({ children, label, summary, state = "complete", statusLabel, detail, icon, collapsible = false, onActivate, className, ...props }, context) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
export const ChatToolCall = defineComponent(chatToolCallContract, ({ children, label, summary, state = "complete", statusLabel, detail, icon, input, output, outputSummary, maxLines, collapsible = false, onActivate, onRetry, onCancel, canRetry = true, canCancel = true, retryDisabled = false, cancelDisabled = false, labels, className, ...props }, context) => {
|
|
25
|
+
const derived = (read) => {
|
|
26
|
+
const value = context.signal(read());
|
|
27
|
+
context.effect(() => {
|
|
28
|
+
value.value = read();
|
|
29
|
+
});
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
const copy = {
|
|
33
|
+
input: "输入",
|
|
34
|
+
output: "输出",
|
|
35
|
+
emptyInput: "没有输入内容",
|
|
36
|
+
emptyOutput: "输出为空",
|
|
37
|
+
retry: "重试",
|
|
38
|
+
cancel: "取消",
|
|
39
|
+
...labels,
|
|
40
|
+
};
|
|
41
|
+
const status = derived(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state)));
|
|
42
|
+
// Preserve the existing quiet completion default without interpreting missing data as success.
|
|
43
|
+
const quietStatus = derived(() => unwrap(state) === "complete" && !unwrap(statusLabel));
|
|
44
|
+
// One interactive header: activation never also toggles an in-place disclosure.
|
|
14
45
|
const reveals = collapsible && onActivate === undefined;
|
|
15
46
|
const interactive = reveals || onActivate !== undefined;
|
|
47
|
+
const payload = (kind, text) => context.part(kind, "div", { hidden: derived(() => unwrap(text) === undefined) }, h(OutputBlock, {
|
|
48
|
+
title: copy[kind],
|
|
49
|
+
rows: derived(() => {
|
|
50
|
+
const value = unwrap(text);
|
|
51
|
+
return value === undefined || value === "" ? [] : value.split("\n");
|
|
52
|
+
}),
|
|
53
|
+
copyText: derived(() => unwrap(text) ?? ""),
|
|
54
|
+
emptyText: kind === "input" ? copy.emptyInput : copy.emptyOutput,
|
|
55
|
+
maxLines,
|
|
56
|
+
wrap: true,
|
|
57
|
+
}));
|
|
58
|
+
const hasBody = children !== undefined ||
|
|
59
|
+
input !== undefined ||
|
|
60
|
+
output !== undefined ||
|
|
61
|
+
outputSummary !== undefined ||
|
|
62
|
+
onRetry !== undefined ||
|
|
63
|
+
onCancel !== undefined;
|
|
16
64
|
return context.part("root", reveals ? "details" : "div", {
|
|
17
65
|
...props,
|
|
18
66
|
className,
|
|
19
67
|
"data-tool-state": state,
|
|
20
|
-
"data-tool-default-complete": quietStatus ? "true" : undefined,
|
|
68
|
+
"data-tool-default-complete": derived(() => (quietStatus.value ? "true" : undefined)),
|
|
21
69
|
"data-tool-interactive": interactive ? "true" : undefined,
|
|
22
70
|
"data-tool-collapsible": reveals ? "true" : undefined,
|
|
23
|
-
}, context.part("header", onActivate !== undefined ? "button" : reveals ? "summary" : "div", onActivate !== undefined ? { type: "button", onClick: onActivate } : null, context.part("icon", "span", { "aria-hidden": "true" }, icon ?? h(Icon, { name: "wrench" })), context.part("label", "strong", null, label), summary
|
|
71
|
+
}, context.part("header", onActivate !== undefined ? "button" : reveals ? "summary" : "div", onActivate !== undefined ? { type: "button", onClick: onActivate } : null, context.part("icon", "span", { "aria-hidden": "true" }, icon ?? h(Icon, { name: "wrench" })), context.part("label", "strong", null, label), summary !== undefined
|
|
72
|
+
? context.part("summary", "span", { title: summary, hidden: derived(() => !unwrap(summary)) }, summary)
|
|
73
|
+
: null, context.part("status", "span", null, status), interactive
|
|
24
74
|
? context.part("chevron", "span", { "aria-hidden": "true" }, h(Icon, { name: "chevron-right" }))
|
|
25
|
-
: null), detail ? context.part("detail", "p", null, detail) : null,
|
|
75
|
+
: null), detail ? context.part("detail", "p", null, detail) : null, hasBody
|
|
76
|
+
? context.part("body", "div", null, input !== undefined ? payload("input", input) : null, outputSummary !== undefined
|
|
77
|
+
? context.part("outputSummary", "p", { hidden: derived(() => !unwrap(outputSummary)) }, outputSummary)
|
|
78
|
+
: null, output !== undefined ? payload("output", output) : null, children, onRetry || onCancel
|
|
79
|
+
? context.part("actions", "div", {
|
|
80
|
+
hidden: derived(() => !(onRetry && unwrap(canRetry)) && !(onCancel && unwrap(canCancel))),
|
|
81
|
+
}, onRetry ? (h(Button, { variant: "outline", size: "small", hidden: derived(() => !unwrap(canRetry)), disabled: derived(() => !unwrap(canRetry) || unwrap(retryDisabled)), onClick: onRetry }, copy.retry)) : null, onCancel ? (h(Button, { variant: "quiet", size: "small", hidden: derived(() => !unwrap(canCancel)), disabled: derived(() => !unwrap(canCancel) || unwrap(cancelDisabled)), onClick: onCancel }, copy.cancel)) : null)
|
|
82
|
+
: null)
|
|
83
|
+
: null);
|
|
26
84
|
});
|
|
27
|
-
function stateLabel(state) {
|
|
28
|
-
switch (state) {
|
|
29
|
-
case "running":
|
|
30
|
-
return "运行中";
|
|
31
|
-
case "waiting":
|
|
32
|
-
return "等待中";
|
|
33
|
-
case "error":
|
|
34
|
-
return "出错";
|
|
35
|
-
case "unknown":
|
|
36
|
-
return "结果未确认";
|
|
37
|
-
default:
|
|
38
|
-
return "已完成";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -68,6 +68,7 @@ export { SearchBlock, searchBlockContract, type SearchBlockProps, type SearchFil
|
|
|
68
68
|
export { Pill, pillContract, type PillProps } from "./pill.js";
|
|
69
69
|
export { ImagePreview, imagePreviewContract, type ImagePreviewProps } from "./image-preview.js";
|
|
70
70
|
export { StatusDot, type StatusDotProps, type StatusDotState, statusDotContract, statusDotOptions, } from "./status-dot.js";
|
|
71
|
+
export { Status, type StatusProps, statusContract } from "./status.js";
|
|
71
72
|
export { Tag, type TagProps, tagContract, tagOptions } from "./tag.js";
|
|
72
73
|
export { ProcessGroup, type ProcessGroupProps, processGroupContract } from "./process-group.js";
|
|
73
74
|
export { ProcessStep, type ProcessStepProps, processStepContract } from "./process-step.js";
|
|
@@ -67,6 +67,7 @@ export { SearchBlock, searchBlockContract, } from "./search-block.js";
|
|
|
67
67
|
export { Pill, pillContract } from "./pill.js";
|
|
68
68
|
export { ImagePreview, imagePreviewContract } from "./image-preview.js";
|
|
69
69
|
export { StatusDot, statusDotContract, statusDotOptions, } from "./status-dot.js";
|
|
70
|
+
export { Status, statusContract } from "./status.js";
|
|
70
71
|
export { Tag, tagContract, tagOptions } from "./tag.js";
|
|
71
72
|
export { ProcessGroup, processGroupContract } from "./process-group.js";
|
|
72
73
|
export { ProcessStep, processStepContract } from "./process-step.js";
|
|
@@ -9,8 +9,9 @@ export const LayoutItem = defineComponent(layoutItemContract, ({ as = "div", gro
|
|
|
9
9
|
style: layoutStyle(props.style, {
|
|
10
10
|
flexGrow: grow ? 1 : 0,
|
|
11
11
|
flexShrink: shrink ? 1 : 0,
|
|
12
|
-
flexBasis: basis,
|
|
12
|
+
flexBasis: typeof basis === "number" ? `${basis}px` : basis,
|
|
13
13
|
alignSelf,
|
|
14
14
|
minWidth: 0,
|
|
15
|
+
minHeight: 0,
|
|
15
16
|
}),
|
|
16
17
|
}, children));
|
|
@@ -5,7 +5,7 @@ export declare const layoutOptions: import("meowcss").Options<{
|
|
|
5
5
|
readonly rowGap: readonly ["auto", "none", "compact", "normal", "relaxed"];
|
|
6
6
|
readonly columnGap: readonly ["auto", "none", "compact", "normal", "relaxed"];
|
|
7
7
|
}>;
|
|
8
|
-
export type LayoutElement = "div" | "section" | "nav" | "main" | "aside" | "header" | "footer" | "article" | "ol";
|
|
8
|
+
export type LayoutElement = "div" | "span" | "section" | "nav" | "main" | "aside" | "header" | "footer" | "article" | "ol";
|
|
9
9
|
export type LayoutGap = (typeof layoutOptions.axes.gap)[number];
|
|
10
10
|
export type LayoutAlign = "start" | "center" | "end" | "stretch" | "baseline";
|
|
11
11
|
export type LayoutJustify = "start" | "center" | "end" | "between";
|
|
@@ -152,11 +152,11 @@ export const Menu = defineComponent(menuContract, ({ id, trigger, items, open, o
|
|
|
152
152
|
if (event.key === "End")
|
|
153
153
|
next = rows.length - 1;
|
|
154
154
|
if (event.key === "Tab") {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
// Dismiss the whole action surface, then let native Tab continue from
|
|
156
|
+
// its restored trigger. Moving focus must never activate an action.
|
|
157
|
+
request(false);
|
|
158
|
+
closeAncestors?.();
|
|
159
|
+
event.stopPropagation();
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
if (event.key.length === 1 && event.key !== " ") {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { type Child, type Props } from "meowjsx";
|
|
1
|
+
import { type Child, type Props, type MaybeSignal } from "meowjsx";
|
|
2
2
|
export declare const outputBlockContract: {
|
|
3
3
|
readonly name: "output-block";
|
|
4
4
|
readonly parts: readonly ["root", "header", "title", "actions", "body", "line", "fold", "toggle", "feedback"];
|
|
5
5
|
};
|
|
6
6
|
export interface OutputBlockProps extends Props {
|
|
7
7
|
title: Child;
|
|
8
|
-
rows: readonly Child[]
|
|
9
|
-
copyText: string
|
|
8
|
+
rows: MaybeSignal<readonly Child[]>;
|
|
9
|
+
copyText: MaybeSignal<string>;
|
|
10
10
|
maxLines?: number;
|
|
11
|
+
/** Wrap prose-like tool output; code and terminal output keep their existing horizontal scroll. */
|
|
12
|
+
wrap?: boolean;
|
|
11
13
|
emptyText?: string;
|
|
12
14
|
onCopy?: (text: string) => Promise<void>;
|
|
13
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h } from "meowjsx";
|
|
1
|
+
import { defineComponent, h, unwrap, } from "meowjsx";
|
|
2
2
|
import { copyTextToClipboard } from "../clipboard.js";
|
|
3
3
|
export const outputBlockContract = {
|
|
4
4
|
name: "output-block",
|
|
@@ -11,7 +11,14 @@ export function outputWindow(length, maxLines = 16) {
|
|
|
11
11
|
const tail = Math.floor(limit / 2);
|
|
12
12
|
return { head, tail, hidden: Math.max(0, length - limit) };
|
|
13
13
|
}
|
|
14
|
-
export const OutputBlock = defineComponent(outputBlockContract, ({ title, rows, copyText, maxLines, emptyText = "没有内容", onCopy, ...props }, context) => {
|
|
14
|
+
export const OutputBlock = defineComponent(outputBlockContract, ({ title, rows, copyText, maxLines, wrap = false, emptyText = "没有内容", onCopy, ...props }, context) => {
|
|
15
|
+
const derived = (read) => {
|
|
16
|
+
const value = context.signal(read());
|
|
17
|
+
context.effect(() => {
|
|
18
|
+
value.value = read();
|
|
19
|
+
});
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
15
22
|
const feedback = context.signal("");
|
|
16
23
|
const busy = context.signal(false);
|
|
17
24
|
let disposed = false;
|
|
@@ -23,7 +30,7 @@ export const OutputBlock = defineComponent(outputBlockContract, ({ title, rows,
|
|
|
23
30
|
return;
|
|
24
31
|
busy.value = true;
|
|
25
32
|
try {
|
|
26
|
-
await (onCopy ?? copyTextToClipboard)(copyText);
|
|
33
|
+
await (onCopy ?? copyTextToClipboard)(unwrap(copyText));
|
|
27
34
|
if (!disposed)
|
|
28
35
|
feedback.value = "已复制";
|
|
29
36
|
}
|
|
@@ -36,31 +43,34 @@ export const OutputBlock = defineComponent(outputBlockContract, ({ title, rows,
|
|
|
36
43
|
busy.value = false;
|
|
37
44
|
}
|
|
38
45
|
};
|
|
39
|
-
const
|
|
46
|
+
const window = derived(() => outputWindow(unwrap(rows).length, maxLines));
|
|
40
47
|
const renderRows = (items) => items.map((row) => context.part("line", "div", {}, row));
|
|
41
|
-
return context.part("root", "section", props, [
|
|
48
|
+
return context.part("root", "section", { ...props, "data-output-wrap": wrap ? "true" : undefined }, [
|
|
42
49
|
context.part("header", "div", {}, [
|
|
43
50
|
context.part("title", "div", {}, title),
|
|
44
51
|
context.part("actions", "button", { type: "button", disabled: busy, onClick: copy }, "复制"),
|
|
45
52
|
]),
|
|
46
|
-
context.part("body", "div", { tabIndex: 0, "aria-label": "输出内容" },
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
context.part("body", "div", { tabIndex: 0, "aria-label": "输出内容" }, [
|
|
54
|
+
derived(() => {
|
|
55
|
+
const values = unwrap(rows);
|
|
56
|
+
return values.length === 0
|
|
57
|
+
? emptyText
|
|
58
|
+
: renderRows(window.value.hidden ? values.slice(0, window.value.head) : values);
|
|
59
|
+
}),
|
|
60
|
+
context.part("fold", "details", { hidden: derived(() => window.value.hidden === 0) }, [
|
|
61
|
+
context.part("toggle", "summary", {}, [
|
|
62
|
+
h("span", { "data-fold-closed": true }, derived(() => `展开中间 ${window.value.hidden} 行`)),
|
|
63
|
+
h("span", { "data-fold-open": true }, "\u6536\u8D77\u4E2D\u95F4\u884C"),
|
|
64
|
+
]),
|
|
65
|
+
derived(() => {
|
|
66
|
+
const values = unwrap(rows);
|
|
67
|
+
return window.value.hidden
|
|
68
|
+
? renderRows(values.slice(window.value.head, values.length - window.value.tail))
|
|
69
|
+
: null;
|
|
70
|
+
}),
|
|
63
71
|
]),
|
|
72
|
+
derived(() => window.value.hidden ? renderRows(unwrap(rows).slice(-window.value.tail)) : null),
|
|
73
|
+
]),
|
|
64
74
|
context.part("feedback", "span", { role: "status", "aria-live": "polite" }, feedback),
|
|
65
75
|
]);
|
|
66
76
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Child, type Props } from "meowjsx";
|
|
2
|
+
import { type StatusDotProps } from "./status-dot.js";
|
|
3
|
+
export declare const statusContract: {
|
|
4
|
+
readonly name: "status";
|
|
5
|
+
readonly parts: readonly ["root", "label"];
|
|
6
|
+
};
|
|
7
|
+
export interface StatusProps extends Props {
|
|
8
|
+
state?: StatusDotProps["state"];
|
|
9
|
+
/** Supply visible, non-empty content, including when the Child is dynamic. */
|
|
10
|
+
label: Exclude<Child, null | undefined | boolean>;
|
|
11
|
+
size?: never;
|
|
12
|
+
halo?: never;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A state in words with a decorative dot. Use as slot content; composed markers remain owned by WorkCard and Timeline. */
|
|
16
|
+
export declare const Status: import("meowjsx").Component<StatusProps, "status", "label" | "root">;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineComponent, h } from "meowjsx";
|
|
2
|
+
import { StatusDot } from "./status-dot.js";
|
|
3
|
+
export const statusContract = {
|
|
4
|
+
name: "status",
|
|
5
|
+
parts: ["root", "label"],
|
|
6
|
+
};
|
|
7
|
+
/** A state in words with a decorative dot. Use as slot content; composed markers remain owned by WorkCard and Timeline. */
|
|
8
|
+
export const Status = defineComponent(statusContract, ({ state, label, className, children: _children, ...props }, context) => context.part("root", "span", { ...props, className }, h(StatusDot, { state: state }), context.part("label", "span", null, label)));
|
|
@@ -53,7 +53,47 @@ export declare const assistantJsonSchemas: Readonly<{
|
|
|
53
53
|
readonly sizeBytes?: number | undefined;
|
|
54
54
|
})[];
|
|
55
55
|
readonly kind: "attachments";
|
|
56
|
-
} & {})
|
|
56
|
+
} & {}) | ({
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly kind: "tool";
|
|
59
|
+
readonly label: string;
|
|
60
|
+
} & {
|
|
61
|
+
readonly canCancel?: boolean | undefined;
|
|
62
|
+
readonly canRetry?: boolean | undefined;
|
|
63
|
+
readonly cancelDisabled?: boolean | undefined;
|
|
64
|
+
readonly defaultOpen?: boolean | undefined;
|
|
65
|
+
readonly input?: string | undefined;
|
|
66
|
+
readonly maxLines?: number | undefined;
|
|
67
|
+
readonly output?: string | undefined;
|
|
68
|
+
readonly outputSummary?: string | undefined;
|
|
69
|
+
readonly retryDisabled?: boolean | undefined;
|
|
70
|
+
readonly state?: "cancelled" | "complete" | "error" | "queued" | "running" | "success" | "unknown" | "waiting" | undefined;
|
|
71
|
+
readonly statusLabel?: string | undefined;
|
|
72
|
+
readonly summary?: string | undefined;
|
|
73
|
+
}) | ({
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly kind: "task";
|
|
76
|
+
readonly state: "cancelled" | "complete" | "error" | "queued" | "running" | "success" | "unknown" | "waiting";
|
|
77
|
+
readonly title: string;
|
|
78
|
+
} & {
|
|
79
|
+
readonly description?: string | undefined;
|
|
80
|
+
readonly executionText?: string | undefined;
|
|
81
|
+
readonly progress?: ({
|
|
82
|
+
readonly label: string;
|
|
83
|
+
readonly max: number;
|
|
84
|
+
readonly value: number;
|
|
85
|
+
} & {}) | undefined;
|
|
86
|
+
readonly replyText?: string | undefined;
|
|
87
|
+
readonly statusLabel?: string | undefined;
|
|
88
|
+
readonly steps?: readonly ({
|
|
89
|
+
readonly id: string;
|
|
90
|
+
readonly title: string;
|
|
91
|
+
} & {
|
|
92
|
+
readonly description?: string | undefined;
|
|
93
|
+
readonly statusText?: string | undefined;
|
|
94
|
+
readonly tone?: "danger" | "idle" | "processing" | "returned" | "success" | "unknown" | "warning" | undefined;
|
|
95
|
+
})[] | undefined;
|
|
96
|
+
})>;
|
|
57
97
|
message: JsonSchema<{
|
|
58
98
|
readonly author: string;
|
|
59
99
|
readonly id: string;
|
|
@@ -93,7 +133,47 @@ export declare const assistantJsonSchemas: Readonly<{
|
|
|
93
133
|
readonly sizeBytes?: number | undefined;
|
|
94
134
|
})[];
|
|
95
135
|
readonly kind: "attachments";
|
|
96
|
-
} & {})
|
|
136
|
+
} & {}) | ({
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly kind: "tool";
|
|
139
|
+
readonly label: string;
|
|
140
|
+
} & {
|
|
141
|
+
readonly canCancel?: boolean | undefined;
|
|
142
|
+
readonly canRetry?: boolean | undefined;
|
|
143
|
+
readonly cancelDisabled?: boolean | undefined;
|
|
144
|
+
readonly defaultOpen?: boolean | undefined;
|
|
145
|
+
readonly input?: string | undefined;
|
|
146
|
+
readonly maxLines?: number | undefined;
|
|
147
|
+
readonly output?: string | undefined;
|
|
148
|
+
readonly outputSummary?: string | undefined;
|
|
149
|
+
readonly retryDisabled?: boolean | undefined;
|
|
150
|
+
readonly state?: "cancelled" | "complete" | "error" | "queued" | "running" | "success" | "unknown" | "waiting" | undefined;
|
|
151
|
+
readonly statusLabel?: string | undefined;
|
|
152
|
+
readonly summary?: string | undefined;
|
|
153
|
+
}) | ({
|
|
154
|
+
readonly id: string;
|
|
155
|
+
readonly kind: "task";
|
|
156
|
+
readonly state: "cancelled" | "complete" | "error" | "queued" | "running" | "success" | "unknown" | "waiting";
|
|
157
|
+
readonly title: string;
|
|
158
|
+
} & {
|
|
159
|
+
readonly description?: string | undefined;
|
|
160
|
+
readonly executionText?: string | undefined;
|
|
161
|
+
readonly progress?: ({
|
|
162
|
+
readonly label: string;
|
|
163
|
+
readonly max: number;
|
|
164
|
+
readonly value: number;
|
|
165
|
+
} & {}) | undefined;
|
|
166
|
+
readonly replyText?: string | undefined;
|
|
167
|
+
readonly statusLabel?: string | undefined;
|
|
168
|
+
readonly steps?: readonly ({
|
|
169
|
+
readonly id: string;
|
|
170
|
+
readonly title: string;
|
|
171
|
+
} & {
|
|
172
|
+
readonly description?: string | undefined;
|
|
173
|
+
readonly statusText?: string | undefined;
|
|
174
|
+
readonly tone?: "danger" | "idle" | "processing" | "returned" | "success" | "unknown" | "warning" | undefined;
|
|
175
|
+
})[] | undefined;
|
|
176
|
+
}))[];
|
|
97
177
|
readonly role: "assistant" | "system" | "tool" | "user";
|
|
98
178
|
} & {
|
|
99
179
|
readonly status?: "complete" | "error" | "pending" | "streaming" | undefined;
|
|
@@ -164,6 +244,12 @@ export declare const assistantJsonSchemas: Readonly<{
|
|
|
164
244
|
} & {
|
|
165
245
|
readonly disabled?: boolean | undefined;
|
|
166
246
|
}>;
|
|
247
|
+
executionState: JsonSchema<"cancelled" | "complete" | "error" | "queued" | "running" | "success" | "unknown" | "waiting">;
|
|
248
|
+
taskProgress: JsonSchema<{
|
|
249
|
+
readonly label: string;
|
|
250
|
+
readonly max: number;
|
|
251
|
+
readonly value: number;
|
|
252
|
+
} & {}>;
|
|
167
253
|
}>;
|
|
168
254
|
/** A finite catalog of the original public components, not an alternate UI implementation. */
|
|
169
255
|
export declare function createMeowUICatalog(): ReadonlyMap<string, JsonComponentDefinition>;
|