meowtail 0.1.0 → 0.2.0-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.
Files changed (130) hide show
  1. package/AGENT-COMPONENTS.md +117 -0
  2. package/ASSISTANT.md +39 -19
  3. package/JSON.md +12 -5
  4. package/README.md +462 -349
  5. package/THIRD_PARTY_NOTICES.md +8 -0
  6. package/dist/src/chat/assistant-composer.js +3 -5
  7. package/dist/src/chat/assistant-content.d.ts +2 -0
  8. package/dist/src/chat/assistant-content.js +51 -3
  9. package/dist/src/chat/assistant-types.d.ts +39 -1
  10. package/dist/src/chat/assistant.d.ts +1 -1
  11. package/dist/src/chat/assistant.js +6 -3
  12. package/dist/src/chat/attachments.js +9 -5
  13. package/dist/src/chat/composer-panel.d.ts +17 -0
  14. package/dist/src/chat/composer-panel.js +12 -0
  15. package/dist/src/chat/composer.d.ts +2 -0
  16. package/dist/src/chat/composer.js +5 -2
  17. package/dist/src/chat/conversation.d.ts +4 -1
  18. package/dist/src/chat/conversation.js +7 -4
  19. package/dist/src/chat/index.d.ts +5 -2
  20. package/dist/src/chat/index.js +2 -0
  21. package/dist/src/chat/message-list.js +1 -1
  22. package/dist/src/chat/message.js +3 -3
  23. package/dist/src/chat/question.js +1 -1
  24. package/dist/src/chat/sources.js +1 -1
  25. package/dist/src/chat/task.d.ts +29 -0
  26. package/dist/src/chat/task.js +53 -0
  27. package/dist/src/chat/tool-call.d.ts +33 -8
  28. package/dist/src/chat/tool-call.js +70 -26
  29. package/dist/src/components/action-rail.d.ts +19 -0
  30. package/dist/src/components/action-rail.js +13 -0
  31. package/dist/src/components/add-button.js +1 -1
  32. package/dist/src/components/alert.d.ts +2 -0
  33. package/dist/src/components/alert.js +2 -1
  34. package/dist/src/components/app-bar.d.ts +17 -0
  35. package/dist/src/components/app-bar.js +10 -0
  36. package/dist/src/components/breadcrumb.js +1 -1
  37. package/dist/src/components/choice-select.js +1 -1
  38. package/dist/src/components/code-block.js +6 -6
  39. package/dist/src/components/credential-source.js +12 -12
  40. package/dist/src/components/diff-block.js +1 -1
  41. package/dist/src/components/grid.js +1 -0
  42. package/dist/src/components/hover-card.js +2 -2
  43. package/dist/src/components/image-lightbox.js +3 -3
  44. package/dist/src/components/image-preview.js +1 -1
  45. package/dist/src/components/index.d.ts +4 -0
  46. package/dist/src/components/index.js +4 -0
  47. package/dist/src/components/inline.js +1 -0
  48. package/dist/src/components/json-block.js +2 -2
  49. package/dist/src/components/json-tree.js +3 -3
  50. package/dist/src/components/layout-item.js +2 -1
  51. package/dist/src/components/layout-types.d.ts +1 -1
  52. package/dist/src/components/list-group.d.ts +1 -1
  53. package/dist/src/components/menu.js +5 -5
  54. package/dist/src/components/meta-row.d.ts +33 -0
  55. package/dist/src/components/meta-row.js +45 -0
  56. package/dist/src/components/output-block.d.ts +5 -3
  57. package/dist/src/components/output-block.js +35 -25
  58. package/dist/src/components/page-frame.d.ts +6 -2
  59. package/dist/src/components/page-frame.js +2 -2
  60. package/dist/src/components/path-picker.js +4 -4
  61. package/dist/src/components/process-group.d.ts +2 -2
  62. package/dist/src/components/rail-item.d.ts +2 -2
  63. package/dist/src/components/rail-section.d.ts +1 -1
  64. package/dist/src/components/read-block.js +2 -2
  65. package/dist/src/components/resource-card.d.ts +1 -1
  66. package/dist/src/components/resource-link.d.ts +1 -1
  67. package/dist/src/components/search-block.js +2 -3
  68. package/dist/src/components/stack.js +1 -0
  69. package/dist/src/components/status.d.ts +16 -0
  70. package/dist/src/components/status.js +8 -0
  71. package/dist/src/components/terminal-block.js +6 -6
  72. package/dist/src/components/web-block.js +3 -3
  73. package/dist/src/components/work-card.d.ts +2 -2
  74. package/dist/src/components/work-card.js +1 -1
  75. package/dist/src/icons/README.md +13 -2
  76. package/dist/src/icons/icon-frame.d.ts +11 -0
  77. package/dist/src/icons/icon-frame.js +4 -0
  78. package/dist/src/icons/icon-source.d.ts +17 -0
  79. package/dist/src/icons/icon-source.js +6 -0
  80. package/dist/src/icons/icon.d.ts +44 -37
  81. package/dist/src/icons/icon.js +55 -128
  82. package/dist/src/icons/index.d.ts +1 -0
  83. package/dist/src/icons/index.js +1 -0
  84. package/dist/src/icons/lucide.d.ts +1 -0
  85. package/dist/src/icons/lucide.js +4 -0
  86. package/dist/src/json/catalog.d.ts +88 -2
  87. package/dist/src/json/catalog.js +33 -1
  88. package/dist/src/registry/index.d.ts +54 -4
  89. package/dist/src/registry/index.js +16 -2
  90. package/dist/src/shared/execution-state.d.ts +7 -0
  91. package/dist/src/shared/execution-state.js +36 -0
  92. package/dist/src/theme/base.styles.js +15 -0
  93. package/dist/src/theme/chat/assistant.styles.js +21 -9
  94. package/dist/src/theme/chat/composer-panel.styles.d.ts +1 -0
  95. package/dist/src/theme/chat/composer-panel.styles.js +44 -0
  96. package/dist/src/theme/chat/composer.styles.js +39 -7
  97. package/dist/src/theme/chat/conversation.styles.js +15 -7
  98. package/dist/src/theme/chat/records.styles.js +79 -7
  99. package/dist/src/theme/chat/task.styles.d.ts +1 -0
  100. package/dist/src/theme/chat/task.styles.js +87 -0
  101. package/dist/src/theme/components/action-rail.styles.d.ts +1 -0
  102. package/dist/src/theme/components/action-rail.styles.js +47 -0
  103. package/dist/src/theme/components/alert.styles.js +42 -1
  104. package/dist/src/theme/components/app-bar.styles.d.ts +1 -0
  105. package/dist/src/theme/components/app-bar.styles.js +48 -0
  106. package/dist/src/theme/components/card.styles.js +9 -3
  107. package/dist/src/theme/components/code-block.styles.js +7 -0
  108. package/dist/src/theme/components/dialog.styles.js +7 -0
  109. package/dist/src/theme/components/field.styles.js +4 -0
  110. package/dist/src/theme/components/list-group.styles.js +10 -11
  111. package/dist/src/theme/components/meta-row.styles.d.ts +1 -0
  112. package/dist/src/theme/components/meta-row.styles.js +66 -0
  113. package/dist/src/theme/components/output-block.styles.js +17 -0
  114. package/dist/src/theme/components/page-frame.styles.js +7 -1
  115. package/dist/src/theme/components/page-header.styles.js +7 -0
  116. package/dist/src/theme/components/resource-card.styles.js +15 -3
  117. package/dist/src/theme/components/status.styles.d.ts +1 -0
  118. package/dist/src/theme/components/status.styles.js +25 -0
  119. package/dist/src/theme/components/tag.styles.js +3 -3
  120. package/dist/src/theme/components/toolbar.styles.js +7 -0
  121. package/dist/src/theme/index.d.ts +148 -0
  122. package/dist/src/theme/index.js +173 -159
  123. package/dist/src/theme/palette.d.ts +1 -1
  124. package/dist/src/theme/palette.js +1 -1
  125. package/dist/src/theme/shared/code-highlight.styles.js +1 -1
  126. package/dist/src/theme/shared/code-highlight.tokens.d.ts +6 -6
  127. package/dist/src/theme/shared/code-highlight.tokens.js +6 -6
  128. package/dist/src/theme/tokens.d.ts +7 -7
  129. package/dist/src/theme/tokens.js +14 -8
  130. package/package.json +17 -6
@@ -25,3 +25,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
25
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
26
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
27
  SOFTWARE.
28
+
29
+ # Lucide
30
+
31
+ Functional icon geometry in `Icon` and the `meowtail/icons/lucide` pass-through
32
+ is provided by Lucide (https://lucide.dev), version 1.59.0, under the ISC
33
+ license; icons derived from the Feather project are under the MIT license. The
34
+ full license text, including the Feather attribution list, ships in
35
+ `dist/src/icons/LUCIDE-LICENSE` and in the installed `lucide` package.
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, h, unwrap } from "meowjsx";
2
2
  import { ChatComposer } from "./composer.js";
3
3
  import { ChatAttachments } from "./attachments.js";
4
- import { Button } from "../components/button.js";
4
+ import { IconButton } from "../components/icon-button.js";
5
5
  import { ChoiceSelect } from "../components/choice-select.js";
6
6
  import { Icon } from "../icons/icon.js";
7
7
  import { assistantDerived } from "./assistant-content.js";
@@ -224,10 +224,8 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
224
224
  children: options.allowAttachments === false
225
225
  ? []
226
226
  : [
227
- h(Button, {
228
- variant: "quiet",
229
- size: "small",
230
- "aria-label": assistantCopy.attach,
227
+ h(IconButton, {
228
+ label: assistantCopy.attach,
231
229
  disabled: assistantDerived(context, () => disabled.value || attaching.value),
232
230
  onClick: () => fileInput?.click(),
233
231
  children: h(Icon, { name: "paperclip" }),
@@ -13,8 +13,10 @@ export declare const AssistantPartView: import("meowjsx").Component<{
13
13
  value: Signal<AssistantMessagePart>;
14
14
  message: Signal<AssistantMessage>;
15
15
  renderPart?: AssistantViewProps["renderPart"];
16
+ onToolAction?: AssistantViewProps["onToolAction"];
16
17
  }, "assistant-part", "root">;
17
18
  export declare const AssistantMessageView: import("meowjsx").Component<{
18
19
  value: Signal<AssistantMessage>;
19
20
  renderPart?: AssistantViewProps["renderPart"];
21
+ onToolAction?: AssistantViewProps["onToolAction"];
20
22
  }, "assistant-message", "root">;
@@ -1,6 +1,8 @@
1
1
  import { defineComponent, h, keyed, unwrap, } from "meowjsx";
2
2
  import { ChatMessage } from "./message.js";
3
3
  import { ChatAttachments } from "./attachments.js";
4
+ import { ChatToolCall } from "./tool-call.js";
5
+ import { ChatTask } from "./task.js";
4
6
  import { ProcessGroup } from "../components/process-group.js";
5
7
  import { CodeBlock } from "../components/code-block.js";
6
8
  import { StatusDot } from "../components/status-dot.js";
@@ -19,7 +21,7 @@ export const assistantStepsContract = {
19
21
  };
20
22
  const AssistantStep = defineComponent(assistantStepsContract, ({ value }, context) => context.part("step", "li", null, h(StatusDot, { state: assistantDerived(context, () => value.value.tone ?? "unknown") }), context.part("label", "div", null, h("strong", null, assistantDerived(context, () => value.value.title)), context.part("description", "p", { hidden: assistantDerived(context, () => !value.value.description) }, assistantDerived(context, () => value.value.description ?? ""))), context.part("status", "span", null, assistantDerived(context, () => value.value.statusText ?? ""))));
21
23
  export const AssistantSteps = defineComponent(assistantStepsContract, ({ steps }, context) => context.part("root", "ol", null, keyed(steps, (step) => step.id, (value) => h(AssistantStep, { value }))));
22
- export const AssistantPartView = defineComponent({ name: "assistant-part", parts: ["root"] }, ({ value, message, renderPart }, context) => {
24
+ export const AssistantPartView = defineComponent({ name: "assistant-part", parts: ["root"] }, ({ value, message, renderPart, onToolAction }, context) => {
23
25
  // The keyed identity includes kind, so this component's structural variant is stable.
24
26
  const initial = value.value;
25
27
  const custom = renderPart
@@ -31,6 +33,52 @@ export const AssistantPartView = defineComponent({ name: "assistant-part", parts
31
33
  text: assistantDerived(context, () => value.value.text),
32
34
  });
33
35
  }
36
+ else if (initial.kind === "tool") {
37
+ const tool = () => value.value;
38
+ fallback = h(ChatToolCall, {
39
+ label: assistantDerived(context, () => tool().label),
40
+ summary: assistantDerived(context, () => tool().summary),
41
+ state: assistantDerived(context, () => tool().state ?? "unknown"),
42
+ statusLabel: assistantDerived(context, () => tool().statusLabel),
43
+ input: assistantDerived(context, () => tool().input),
44
+ output: assistantDerived(context, () => tool().output),
45
+ outputSummary: assistantDerived(context, () => tool().outputSummary),
46
+ maxLines: initial.maxLines,
47
+ collapsible: true,
48
+ open: initial.defaultOpen ?? false,
49
+ onRetry: onToolAction
50
+ ? () => {
51
+ if (tool().canRetry && !tool().retryDisabled)
52
+ onToolAction(message.value.id, tool().id, "retry");
53
+ }
54
+ : undefined,
55
+ onCancel: onToolAction
56
+ ? () => {
57
+ if (tool().canCancel && !tool().cancelDisabled)
58
+ onToolAction(message.value.id, tool().id, "cancel");
59
+ }
60
+ : undefined,
61
+ canRetry: assistantDerived(context, () => tool().canRetry ?? false),
62
+ canCancel: assistantDerived(context, () => tool().canCancel ?? false),
63
+ retryDisabled: assistantDerived(context, () => tool().retryDisabled ?? false),
64
+ cancelDisabled: assistantDerived(context, () => tool().cancelDisabled ?? false),
65
+ });
66
+ }
67
+ else if (initial.kind === "task") {
68
+ const task = () => value.value;
69
+ fallback = h(ChatTask, {
70
+ title: assistantDerived(context, () => task().title),
71
+ state: assistantDerived(context, () => task().state),
72
+ statusLabel: assistantDerived(context, () => task().statusLabel),
73
+ description: assistantDerived(context, () => task().description),
74
+ executionText: assistantDerived(context, () => task().executionText),
75
+ replyText: assistantDerived(context, () => task().replyText),
76
+ progress: assistantDerived(context, () => task().progress),
77
+ children: h(AssistantSteps, {
78
+ steps: assistantDerived(context, () => task().steps ?? []),
79
+ }),
80
+ });
81
+ }
34
82
  else if (initial.kind === "process") {
35
83
  fallback = h(ProcessGroup, {
36
84
  title: assistantDerived(context, () => value.value.title),
@@ -54,13 +102,13 @@ export const AssistantPartView = defineComponent({ name: "assistant-part", parts
54
102
  const content = custom ? assistantDerived(context, () => unwrap(custom) ?? fallback) : fallback;
55
103
  return context.part("root", "div", { "data-assistant-part-id": initial.id, "data-kind": initial.kind }, content);
56
104
  });
57
- export const AssistantMessageView = defineComponent({ name: "assistant-message", parts: ["root"] }, ({ value, renderPart }, context) => {
105
+ export const AssistantMessageView = defineComponent({ name: "assistant-message", parts: ["root"] }, ({ value, renderPart, onToolAction }, context) => {
58
106
  const parts = assistantDerived(context, () => value.value.parts);
59
107
  return context.part("root", "div", { "data-assistant-message-id": value.value.id }, h(ChatMessage, {
60
108
  role: value.value.role,
61
109
  author: "",
62
110
  header: h("div", { "data-assistant-message-header": true }, h("strong", null, assistantDerived(context, () => value.value.author)), h("time", null, assistantDerived(context, () => value.value.timestamp ?? "")), h("span", { role: "status" }, assistantDerived(context, () => value.value.status && value.value.status !== "complete" ? value.value.status : ""))),
63
111
  surface: "none",
64
- children: keyed(parts, (part) => `${part.id}:${part.kind}`, (part) => h(AssistantPartView, { value: part, message: value, renderPart })),
112
+ children: keyed(parts, (part) => `${part.id}:${part.kind}`, (part) => h(AssistantPartView, { value: part, message: value, renderPart, onToolAction })),
65
113
  }));
66
114
  });
@@ -2,6 +2,7 @@ import type { Child, MaybeSignal, Props } from "meowjsx";
2
2
  import type { ChatAttachmentItem } from "./attachments.js";
3
3
  import type { ChatMessageRole, ChatMessageStatus } from "./message.js";
4
4
  import type { StatusDotState } from "../components/status-dot.js";
5
+ import type { ChatExecutionState } from "../shared/execution-state.js";
5
6
  export interface AssistantAttachment extends Omit<ChatAttachmentItem, "onRemove"> {
6
7
  /** Optional local source. The component never uploads or persists files. */
7
8
  file?: File;
@@ -17,7 +18,42 @@ export interface AssistantProcessStep {
17
18
  statusText?: string;
18
19
  tone?: StatusDotState;
19
20
  }
20
- export type AssistantMessagePart = {
21
+ /** Serializable tool data. Actions only notify the host; they never execute the tool. */
22
+ export interface AssistantToolPart {
23
+ id: string;
24
+ kind: "tool";
25
+ label: string;
26
+ summary?: string;
27
+ state?: ChatExecutionState;
28
+ statusLabel?: string;
29
+ input?: string;
30
+ output?: string;
31
+ outputSummary?: string;
32
+ maxLines?: number;
33
+ defaultOpen?: boolean;
34
+ canRetry?: boolean;
35
+ canCancel?: boolean;
36
+ retryDisabled?: boolean;
37
+ cancelDisabled?: boolean;
38
+ }
39
+ /** Execution and reply facts are independent, including after a task succeeds. */
40
+ export interface AssistantTaskPart {
41
+ id: string;
42
+ kind: "task";
43
+ title: string;
44
+ state: ChatExecutionState;
45
+ statusLabel?: string;
46
+ description?: string;
47
+ executionText?: string;
48
+ replyText?: string;
49
+ progress?: {
50
+ value: number;
51
+ max: number;
52
+ label: string;
53
+ };
54
+ steps?: readonly AssistantProcessStep[];
55
+ }
56
+ export type AssistantMessagePart = AssistantToolPart | AssistantTaskPart | {
21
57
  id: string;
22
58
  kind: "text";
23
59
  text: string;
@@ -118,6 +154,8 @@ export interface AssistantViewProps extends Props {
118
154
  onReasoningChange?: (value: string) => void;
119
155
  onAnswer?: (questionId: string, answer: string) => void | Promise<void>;
120
156
  onDismissQuestion?: (questionId: string) => void;
157
+ /** An explicit host intent. The host owns availability, execution and subsequent state. */
158
+ onToolAction?: (messageId: string, partId: string, action: "retry" | "cancel") => void;
121
159
  onRefreshWork?: (workId: string) => void;
122
160
  onLoadOlder?: () => void;
123
161
  loadingOlder?: MaybeSignal<boolean>;
@@ -5,5 +5,5 @@ export declare const assistantViewContract: {
5
5
  };
6
6
  /** A complete default Assistant surface. Data, permissions, network and business lifetime stay with the host. */
7
7
  export declare const AssistantView: import("meowjsx").Component<AssistantViewProps, "assistant-view", "activity" | "activityBody" | "activityHeader" | "composer" | "content" | "empty" | "feedback" | "latest" | "layout" | "messages" | "root" | "section" | "status" | "viewport" | "workDetail">;
8
- export type { AssistantViewProps, AssistantDraft, AssistantAttachment, AssistantMessage, AssistantMessagePart, AssistantProcessStep, AssistantActivity, AssistantWork, AssistantQuestion, AssistantChoice, AssistantLabels, } from "./assistant-types.js";
8
+ export type { AssistantViewProps, AssistantDraft, AssistantAttachment, AssistantMessage, AssistantMessagePart, AssistantToolPart, AssistantTaskPart, AssistantProcessStep, AssistantActivity, AssistantWork, AssistantQuestion, AssistantChoice, AssistantLabels, } from "./assistant-types.js";
9
9
  export { assistantCopy } from "./assistant-types.js";
@@ -141,7 +141,11 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
141
141
  if (dialog?.open)
142
142
  dialog.close();
143
143
  });
144
- const transcript = keyed(messages, (message) => message.id, (value) => h(AssistantMessageView, { value, renderPart: options.renderPart }));
144
+ const transcript = keyed(messages, (message) => message.id, (value) => h(AssistantMessageView, {
145
+ value,
146
+ renderPart: options.renderPart,
147
+ onToolAction: options.onToolAction,
148
+ }));
145
149
  const messageRegion = context.part("messages", "section", null, context.part("viewport", "div", {
146
150
  role: "region",
147
151
  "aria-label": assistantCopy.messages,
@@ -191,10 +195,9 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
191
195
  ? assistantCopy.loading
192
196
  : assistantCopy.readError))), context.part("empty", "div", {
193
197
  hidden: assistantDerived(context, () => messages.value.length > 0 || unwrap(options.readState ?? "ready") !== "ready"),
194
- }, h("h2", null, assistantCopy.empty), h("p", null, assistantCopy.emptyDescription)), h(ChatMessageList, { ariaLabel: assistantCopy.messages, children: transcript }))), context.part("latest", "div", null, h(Button, {
198
+ }, h("h2", null, assistantCopy.empty), h("p", null, assistantCopy.emptyDescription)), h(ChatMessageList, { ariaLabel: assistantCopy.messages, children: transcript }))), context.part("latest", "div", { hidden: latestHidden }, h(Button, {
195
199
  variant: "outline",
196
200
  size: "small",
197
- hidden: latestHidden,
198
201
  onClick: () => scroll?.latest(),
199
202
  children: assistantCopy.latest,
200
203
  })));
@@ -18,7 +18,7 @@ export const chatAttachmentsContract = {
18
18
  "remove",
19
19
  ],
20
20
  };
21
- export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items, label = "消息附件", className, ...props }, context) => context.part("root", "div", {
21
+ export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items, label = "Message attachments", className, ...props }, context) => context.part("root", "div", {
22
22
  ...props,
23
23
  className,
24
24
  role: "group",
@@ -28,7 +28,7 @@ export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items
28
28
  ? context.part("remove", "button", {
29
29
  type: "button",
30
30
  onClick: item.onRemove,
31
- "aria-label": `移除 ${item.name}`,
31
+ "aria-label": `Remove ${item.name}`,
32
32
  }, h(Icon, { name: "x" }))
33
33
  : null;
34
34
  return item.mediaType.startsWith("image/")
@@ -36,13 +36,13 @@ export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items
36
36
  ? {
37
37
  type: "button",
38
38
  onClick: item.onPreview,
39
- "aria-label": `预览 ${item.name}`,
39
+ "aria-label": `Preview ${item.name}`,
40
40
  }
41
41
  : {
42
42
  href: item.url,
43
43
  target: "_blank",
44
44
  rel: "noreferrer",
45
- "aria-label": `打开图片 ${item.name}`,
45
+ "aria-label": `Open image ${item.name}`,
46
46
  }, context.part("preview", "span", null, h(ImagePreview, { src: item.url, alt: item.name }))), remove)
47
47
  : context.part("entry", "div", { key: item.id, "data-kind": "file" }, context.part("file", "a", {
48
48
  key: item.id,
@@ -64,7 +64,11 @@ export const ChatAttachments = defineComponent(chatAttachmentsContract, ({ items
64
64
  .filter(Boolean)
65
65
  .join(" "))
66
66
  : null)), item.onPreview
67
- ? context.part("previewButton", "button", { type: "button", onClick: item.onPreview, "aria-label": `预览 ${item.name}` }, "预览")
67
+ ? context.part("previewButton", "button", {
68
+ type: "button",
69
+ onClick: item.onPreview,
70
+ "aria-label": `Preview ${item.name}`,
71
+ }, "Preview")
68
72
  : null, remove);
69
73
  })));
70
74
  function formatBytes(value) {
@@ -0,0 +1,17 @@
1
+ import { type Child } from "meowjsx";
2
+ import { type ChatComposerProps } from "./composer.js";
3
+ export declare const composerPanelContract: {
4
+ readonly name: "composer-panel";
5
+ readonly parts: readonly ["root", "surface", "meta"];
6
+ };
7
+ export interface ComposerPanelProps extends Omit<ChatComposerProps, "surface" | "className"> {
8
+ /** Page-level facts below the writing surface, usually a MetaRow. */
9
+ meta?: Child;
10
+ className?: string;
11
+ }
12
+ /**
13
+ * Composer chrome: one surface around a bare ChatComposer, plus an optional
14
+ * page-level meta row below it. Behavior, draft and submission stay in
15
+ * ChatComposer; this component only owns the surrounding composition.
16
+ */
17
+ export declare const ComposerPanel: import("meowjsx").Component<ComposerPanelProps, "composer-panel", "meta" | "root" | "surface">;
@@ -0,0 +1,12 @@
1
+ import { defineComponent, h } from "meowjsx";
2
+ import { ChatComposer } from "./composer.js";
3
+ export const composerPanelContract = {
4
+ name: "composer-panel",
5
+ parts: ["root", "surface", "meta"],
6
+ };
7
+ /**
8
+ * Composer chrome: one surface around a bare ChatComposer, plus an optional
9
+ * page-level meta row below it. Behavior, draft and submission stay in
10
+ * ChatComposer; this component only owns the surrounding composition.
11
+ */
12
+ export const ComposerPanel = defineComponent(composerPanelContract, ({ meta, className, ...props }, context) => context.part("root", "div", { className, "data-pattern": "composer-panel" }, context.part("surface", "div", null, h(ChatComposer, { ...props, surface: "none" })), meta !== undefined && meta !== null ? context.part("meta", "div", null, meta) : null));
@@ -2,12 +2,14 @@ import { type ThemedProps } from "meowcss/meowjsx";
2
2
  import { type Child, type MaybeSignal, type Props } from "meowjsx";
3
3
  export declare const chatComposerOptions: import("meowcss").Options<{
4
4
  readonly layout: readonly ["stacked", "inline", "hero"];
5
+ readonly surface: readonly ["default", "none"];
5
6
  }>;
6
7
  export declare const chatComposerContract: {
7
8
  readonly name: "chat-composer";
8
9
  readonly parts: readonly ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"];
9
10
  readonly styleProps: import("meowcss/meowjsx").StylePropsBinding<import("meowcss").Options<{
10
11
  readonly layout: readonly ["stacked", "inline", "hero"];
12
+ readonly surface: readonly ["default", "none"];
11
13
  }>>;
12
14
  };
13
15
  export type ChatComposerSubmit = (event: SubmitEvent) => void;
@@ -4,13 +4,16 @@ import { defineComponent, h } from "meowjsx";
4
4
  import { Icon } from "../icons/icon.js";
5
5
  export const chatComposerOptions = defineOptions("chat-composer", {
6
6
  layout: ["stacked", "inline", "hero"],
7
+ surface: ["default", "none"],
7
8
  });
8
9
  export const chatComposerContract = {
9
10
  name: "chat-composer",
10
11
  parts: ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"],
11
- styleProps: defineStyleProps(chatComposerOptions, { defaults: { layout: "stacked" } }),
12
+ styleProps: defineStyleProps(chatComposerOptions, {
13
+ defaults: { layout: "stacked", surface: "default" },
14
+ }),
12
15
  };
13
- export const ChatComposer = defineComponent(chatComposerContract, ({ value = "", placeholder = "写下消息…", inputLabel = "消息", attachments, trailing, hint, hintId, submitLabel = "发送", submitContent, disabled = false, submitDisabled = false, onSubmit, onInput, children, className, ...props }, context) => context.part("root", "form", {
16
+ export const ChatComposer = defineComponent(chatComposerContract, ({ value = "", placeholder = "Write a message…", inputLabel = "Message", attachments, trailing, hint, hintId, submitLabel = "Send", submitContent, disabled = false, submitDisabled = false, onSubmit, onInput, children, className, ...props }, context) => context.part("root", "form", {
14
17
  ...props,
15
18
  className,
16
19
  onSubmit,
@@ -8,7 +8,10 @@ export interface ChatConversationProps extends Props {
8
8
  latestLabel?: string;
9
9
  className?: string;
10
10
  }
11
- /** Presentation only, for hosts that already own transcript scrolling. */
11
+ /** A normal-flow action for hosts that already own transcript scrolling.
12
+ * Place it beside the host viewport in a height-constrained column; the host
13
+ * owns visibility, returning to the end and restoring viewport focus.
14
+ */
12
15
  export declare const ChatConversationLatest: import("meowjsx").Component<Props, "chat-conversation", "content" | "latest" | "root" | "viewport">;
13
16
  /** Optional scroll owner for append-only transcripts. Give the root a constrained height.
14
17
  * Do not combine with an application-owned scroll controller. Children can use ChatMessageList.
@@ -4,12 +4,15 @@ export const chatConversationContract = {
4
4
  name: "chat-conversation",
5
5
  parts: ["root", "viewport", "content", "latest"],
6
6
  };
7
- /** Presentation only, for hosts that already own transcript scrolling. */
8
- export const ChatConversationLatest = defineComponent(chatConversationContract, ({ children, ...props }, context) => context.part("latest", "button", { type: "button", ...props }, children ?? "回到最新消息"));
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
+ */
11
+ export const ChatConversationLatest = defineComponent(chatConversationContract, ({ children, ...props }, context) => context.part("latest", "button", { type: "button", ...props }, children ?? "Back to latest message"));
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.
11
14
  */
12
- export const ChatConversation = defineComponent(chatConversationContract, ({ children, ariaLabel = "对话阅读区", latestLabel = "回到最新消息", className, ...props }, context) => {
15
+ export const ChatConversation = defineComponent(chatConversationContract, ({ children, ariaLabel = "Conversation reading area", latestLabel = "Back to latest message", className, ...props }, context) => {
13
16
  const hidden = context.signal(true);
14
17
  let jump;
15
18
  const mount = (root) => {
@@ -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, height: "100%", overflowAnchor: "none" },
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
  });
@@ -1,13 +1,16 @@
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
+ export { ComposerPanel, type ComposerPanelProps, composerPanelContract } from "./composer-panel.js";
3
4
  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";
5
+ 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
6
  export { ChatHeader, type ChatHeaderProps, chatHeaderContract } from "./header.js";
6
7
  export { ChatMessage, type ChatMessageProps, type ChatMessageRole, type ChatMessageStatus, chatMessageContract, } from "./message.js";
7
8
  export { ChatMessageActions, type ChatMessageActionsProps, chatMessageActionsContract, } from "./message-actions.js";
8
9
  export { ChatMessageList, ChatMessageListContent, ChatMessageListItem, ChatMessageListDate, type ChatMessageListContentProps, type ChatMessageListDateProps, type ChatMessageListProps, chatMessageListContract, } from "./message-list.js";
9
10
  export { ChatStatus, type ChatStatusProps, type ChatStatusTone, chatStatusContract, chatStatusOptions, } from "./status.js";
10
- export { ChatToolCall, type ChatToolCallProps, type ChatToolCallState, chatToolCallContract, } from "./tool-call.js";
11
+ export { ChatToolCall, type ChatToolCallProps, type ChatToolCallState, type ChatToolCallLabels, chatToolCallContract, } from "./tool-call.js";
12
+ export { ChatTask, chatTaskContract, type ChatTaskProps, type ChatTaskProgress } from "./task.js";
13
+ export type { ChatExecutionState } from "../shared/execution-state.js";
11
14
  export { ChatProcess, chatProcessContract, type ChatProcessProps } from "./process.js";
12
15
  export { ChatQuestion, chatQuestionContract, type ChatQuestionProps } from "./question.js";
13
16
  export { ChatSources, chatSourcesContract, type ChatSourcesProps, type ChatSource, } from "./sources.js";
@@ -1,5 +1,6 @@
1
1
  export { ChatAttachments, chatAttachmentsContract, } from "./attachments.js";
2
2
  export { ChatComposer, chatComposerContract, chatComposerOptions, } from "./composer.js";
3
+ export { ComposerPanel, composerPanelContract } from "./composer-panel.js";
3
4
  export { ChatFrame, chatFrameContract } from "./frame.js";
4
5
  export { AssistantView, assistantViewContract, assistantCopy, } from "./assistant.js";
5
6
  export { ChatHeader, chatHeaderContract } from "./header.js";
@@ -8,6 +9,7 @@ export { ChatMessageActions, chatMessageActionsContract, } from "./message-actio
8
9
  export { ChatMessageList, ChatMessageListContent, ChatMessageListItem, ChatMessageListDate, chatMessageListContract, } from "./message-list.js";
9
10
  export { ChatStatus, chatStatusContract, chatStatusOptions, } from "./status.js";
10
11
  export { ChatToolCall, chatToolCallContract, } from "./tool-call.js";
12
+ export { ChatTask, chatTaskContract } from "./task.js";
11
13
  export { ChatProcess, chatProcessContract } from "./process.js";
12
14
  export { ChatQuestion, chatQuestionContract } from "./question.js";
13
15
  export { ChatSources, chatSourcesContract, } from "./sources.js";
@@ -3,7 +3,7 @@ export const chatMessageListContract = {
3
3
  name: "chat-message-list",
4
4
  parts: ["root", "content", "item", "date"],
5
5
  };
6
- export const ChatMessageList = defineComponent(chatMessageListContract, ({ children, className, ariaLabel = "消息记录", ...props }, context) => context.part("root", "div", {
6
+ export const ChatMessageList = defineComponent(chatMessageListContract, ({ children, className, ariaLabel = "Message log", ...props }, context) => context.part("root", "div", {
7
7
  ...props,
8
8
  className,
9
9
  role: "log",
@@ -29,8 +29,8 @@ export const ChatMessage = defineComponent(chatMessageContract, ({ children, rol
29
29
  ? context.part("header", "div", null, header)
30
30
  : context.part("meta", "div", null, context.part("author", "strong", null, author), timestamp ? context.part("time", "time", { datetime: dateTime }, timestamp) : null, status !== "complete"
31
31
  ? context.part("status", "span", null, status === "streaming"
32
- ? "生成中"
32
+ ? "Generating"
33
33
  : status === "pending"
34
- ? "等待中"
35
- : "未完成")
34
+ ? "Waiting"
35
+ : "Incomplete")
36
36
  : null), context.part("content", "div", null, surface === "none" ? children : h(ChatBubble, null, children)), footer !== undefined ? context.part("footer", "div", null, footer) : null, actions ? context.part("actions", "div", null, actions) : null)))));
@@ -4,4 +4,4 @@ export const chatQuestionContract = {
4
4
  parts: ["root", "eyebrow", "title", "description", "content", "feedback", "actions"],
5
5
  };
6
6
  /** Presentation only: submission, cancellation and question lifetime belong to the host. */
7
- export const ChatQuestion = defineComponent(chatQuestionContract, ({ label = "需要你回答", question, questionId, description, feedback, actions, children, ...props }, context) => context.part("root", "section", { ...props, "aria-labelledby": questionId ?? props["aria-labelledby"] }, context.part("eyebrow", "div", null, label), question ? context.part("title", "p", { id: questionId }, question) : null, description ? context.part("description", "p", null, description) : null, context.part("content", "div", null, children), feedback ? context.part("feedback", "div", { role: "status" }, feedback) : null, actions ? context.part("actions", "div", null, actions) : null));
7
+ export const ChatQuestion = defineComponent(chatQuestionContract, ({ label = "Needs your answer", question, questionId, description, feedback, actions, children, ...props }, context) => context.part("root", "section", { ...props, "aria-labelledby": questionId ?? props["aria-labelledby"] }, context.part("eyebrow", "div", null, label), question ? context.part("title", "p", { id: questionId }, question) : null, description ? context.part("description", "p", null, description) : null, context.part("content", "div", null, children), feedback ? context.part("feedback", "div", { role: "status" }, feedback) : null, actions ? context.part("actions", "div", null, actions) : null));
@@ -4,7 +4,7 @@ export const chatSourcesContract = {
4
4
  name: "chat-sources",
5
5
  parts: ["root", "summary", "icon", "list", "item", "link", "description"],
6
6
  };
7
- export const ChatSources = defineComponent(chatSourcesContract, ({ items, label = "来源", ...props }, context) => {
7
+ export const ChatSources = defineComponent(chatSourcesContract, ({ items, label = "Sources", ...props }, context) => {
8
8
  const links = items.filter(({ url }) => {
9
9
  try {
10
10
  return ["http:", "https:"].includes(new URL(url).protocol);
@@ -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
- export type ChatToolCallState = "running" | "complete" | "waiting" | "error" | "unknown";
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
- statusLabel?: string;
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">;