meowtail 0.2.0-alpha.0 → 0.2.0-alpha.2

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 (163) hide show
  1. package/AGENT-COMPONENTS.md +65 -65
  2. package/ASSISTANT.md +35 -35
  3. package/JSON.md +11 -11
  4. package/README.md +413 -385
  5. package/THIRD_PARTY_NOTICES.md +8 -0
  6. package/dist/src/chat/assistant-composer.js +58 -98
  7. package/dist/src/chat/assistant-content.d.ts +1 -3
  8. package/dist/src/chat/assistant-content.js +36 -44
  9. package/dist/src/chat/assistant-markdown.js +4 -8
  10. package/dist/src/chat/assistant-question.js +13 -14
  11. package/dist/src/chat/assistant.js +27 -26
  12. package/dist/src/chat/attachments.d.ts +3 -2
  13. package/dist/src/chat/attachments.js +43 -34
  14. package/dist/src/chat/composer-panel.d.ts +16 -0
  15. package/dist/src/chat/composer-panel.js +11 -0
  16. package/dist/src/chat/composer.d.ts +7 -3
  17. package/dist/src/chat/composer.js +71 -22
  18. package/dist/src/chat/conversation.js +2 -2
  19. package/dist/src/chat/index.d.ts +1 -0
  20. package/dist/src/chat/index.js +1 -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.js +9 -15
  26. package/dist/src/chat/tool-call.js +7 -14
  27. package/dist/src/components/accordion.d.ts +24 -0
  28. package/dist/src/components/accordion.js +50 -0
  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/avatar.d.ts +22 -0
  37. package/dist/src/components/avatar.js +44 -0
  38. package/dist/src/components/breadcrumb.js +1 -1
  39. package/dist/src/components/checkbox.d.ts +6 -2
  40. package/dist/src/components/checkbox.js +36 -8
  41. package/dist/src/components/choice-group.d.ts +1 -0
  42. package/dist/src/components/choice-group.js +12 -17
  43. package/dist/src/components/choice-select.d.ts +3 -1
  44. package/dist/src/components/choice-select.js +56 -54
  45. package/dist/src/components/code-block.d.ts +3 -3
  46. package/dist/src/components/code-block.js +31 -27
  47. package/dist/src/components/context-menu.d.ts +16 -0
  48. package/dist/src/components/context-menu.js +49 -0
  49. package/dist/src/components/credential-source.js +12 -12
  50. package/dist/src/components/diff-block.js +1 -1
  51. package/dist/src/components/disclosure.d.ts +2 -2
  52. package/dist/src/components/disclosure.js +1 -1
  53. package/dist/src/components/hover-card.js +2 -2
  54. package/dist/src/components/image-lightbox.js +3 -3
  55. package/dist/src/components/image-preview.js +1 -1
  56. package/dist/src/components/index.d.ts +12 -0
  57. package/dist/src/components/index.js +12 -0
  58. package/dist/src/components/json-block.js +2 -2
  59. package/dist/src/components/json-tree.js +3 -3
  60. package/dist/src/components/link.d.ts +13 -0
  61. package/dist/src/components/link.js +9 -0
  62. package/dist/src/components/list-group.d.ts +1 -1
  63. package/dist/src/components/menu-button.d.ts +13 -0
  64. package/dist/src/components/menu-button.js +10 -0
  65. package/dist/src/components/menu.d.ts +4 -0
  66. package/dist/src/components/menu.js +3 -3
  67. package/dist/src/components/meta-row.d.ts +34 -0
  68. package/dist/src/components/meta-row.js +61 -0
  69. package/dist/src/components/nav-item.js +2 -5
  70. package/dist/src/components/number-input.d.ts +29 -0
  71. package/dist/src/components/number-input.js +137 -0
  72. package/dist/src/components/output-block.js +8 -15
  73. package/dist/src/components/page-frame.d.ts +6 -2
  74. package/dist/src/components/page-frame.js +2 -2
  75. package/dist/src/components/path-picker.js +9 -14
  76. package/dist/src/components/pill.js +2 -5
  77. package/dist/src/components/popover.js +4 -4
  78. package/dist/src/components/process-group.d.ts +2 -2
  79. package/dist/src/components/progress.d.ts +15 -0
  80. package/dist/src/components/progress.js +12 -0
  81. package/dist/src/components/rail-item.d.ts +2 -2
  82. package/dist/src/components/rail-section.d.ts +1 -1
  83. package/dist/src/components/read-block.js +2 -2
  84. package/dist/src/components/resource-card.d.ts +1 -1
  85. package/dist/src/components/resource-link.d.ts +1 -1
  86. package/dist/src/components/risk-confirmation.js +2 -5
  87. package/dist/src/components/search-block.js +2 -3
  88. package/dist/src/components/segmented-control.js +3 -3
  89. package/dist/src/components/skeleton-boundary.js +4 -7
  90. package/dist/src/components/slider.d.ts +22 -0
  91. package/dist/src/components/slider.js +49 -0
  92. package/dist/src/components/table.d.ts +41 -0
  93. package/dist/src/components/table.js +146 -0
  94. package/dist/src/components/tabs.d.ts +1 -1
  95. package/dist/src/components/tabs.js +11 -20
  96. package/dist/src/components/terminal-block.js +6 -6
  97. package/dist/src/components/text-shimmer.js +2 -5
  98. package/dist/src/components/web-block.js +3 -3
  99. package/dist/src/components/work-card.d.ts +2 -2
  100. package/dist/src/components/work-card.js +1 -1
  101. package/dist/src/icons/README.md +13 -2
  102. package/dist/src/icons/icon-frame.d.ts +11 -0
  103. package/dist/src/icons/icon-frame.js +4 -0
  104. package/dist/src/icons/icon-source.d.ts +17 -0
  105. package/dist/src/icons/icon-source.js +6 -0
  106. package/dist/src/icons/icon.d.ts +44 -37
  107. package/dist/src/icons/icon.js +55 -128
  108. package/dist/src/icons/index.d.ts +1 -0
  109. package/dist/src/icons/index.js +1 -0
  110. package/dist/src/icons/lucide.d.ts +1 -0
  111. package/dist/src/icons/lucide.js +4 -0
  112. package/dist/src/registry/index.d.ts +99 -5
  113. package/dist/src/registry/index.js +28 -3
  114. package/dist/src/shared/execution-state.js +7 -7
  115. package/dist/src/theme/chat/composer-panel.styles.d.ts +1 -0
  116. package/dist/src/theme/chat/composer-panel.styles.js +47 -0
  117. package/dist/src/theme/chat/composer.styles.js +69 -60
  118. package/dist/src/theme/chat/task.styles.js +5 -6
  119. package/dist/src/theme/components/accordion.styles.d.ts +1 -0
  120. package/dist/src/theme/components/accordion.styles.js +63 -0
  121. package/dist/src/theme/components/action-rail.styles.d.ts +1 -0
  122. package/dist/src/theme/components/action-rail.styles.js +47 -0
  123. package/dist/src/theme/components/alert.styles.js +42 -1
  124. package/dist/src/theme/components/app-bar.styles.d.ts +1 -0
  125. package/dist/src/theme/components/app-bar.styles.js +48 -0
  126. package/dist/src/theme/components/avatar.styles.d.ts +1 -0
  127. package/dist/src/theme/components/avatar.styles.js +52 -0
  128. package/dist/src/theme/components/button.styles.js +9 -0
  129. package/dist/src/theme/components/card.styles.js +2 -0
  130. package/dist/src/theme/components/code-block.styles.js +7 -0
  131. package/dist/src/theme/components/context-menu.styles.d.ts +1 -0
  132. package/dist/src/theme/components/context-menu.styles.js +14 -0
  133. package/dist/src/theme/components/dialog.styles.js +7 -0
  134. package/dist/src/theme/components/link.styles.d.ts +1 -0
  135. package/dist/src/theme/components/link.styles.js +33 -0
  136. package/dist/src/theme/components/list-group.styles.js +1 -0
  137. package/dist/src/theme/components/menu.styles.js +9 -3
  138. package/dist/src/theme/components/meta-row.styles.d.ts +1 -0
  139. package/dist/src/theme/components/meta-row.styles.js +66 -0
  140. package/dist/src/theme/components/number-input.styles.d.ts +1 -0
  141. package/dist/src/theme/components/number-input.styles.js +106 -0
  142. package/dist/src/theme/components/output-block.styles.js +9 -0
  143. package/dist/src/theme/components/page-frame.styles.js +7 -1
  144. package/dist/src/theme/components/page-header.styles.js +7 -0
  145. package/dist/src/theme/components/progress.styles.d.ts +1 -0
  146. package/dist/src/theme/components/progress.styles.js +71 -0
  147. package/dist/src/theme/components/resource-card.styles.js +7 -0
  148. package/dist/src/theme/components/slider.styles.d.ts +1 -0
  149. package/dist/src/theme/components/slider.styles.js +129 -0
  150. package/dist/src/theme/components/table.styles.d.ts +1 -0
  151. package/dist/src/theme/components/table.styles.js +156 -0
  152. package/dist/src/theme/components/tag.styles.js +3 -3
  153. package/dist/src/theme/components/toggle.styles.js +10 -0
  154. package/dist/src/theme/components/toolbar.styles.js +7 -0
  155. package/dist/src/theme/index.d.ts +15 -15
  156. package/dist/src/theme/index.js +24 -0
  157. package/dist/src/theme/palette.d.ts +1 -1
  158. package/dist/src/theme/palette.js +1 -1
  159. package/dist/src/theme/shared/code-highlight.tokens.d.ts +6 -6
  160. package/dist/src/theme/shared/code-highlight.tokens.js +6 -6
  161. package/dist/src/theme/tokens.d.ts +7 -7
  162. package/dist/src/theme/tokens.js +14 -8
  163. package/package.json +9 -4
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, keyed, unwrap } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed, unwrap } from "meowjsx";
2
2
  import { PageFrame } from "../components/page-frame.js";
3
3
  import { Button } from "../components/button.js";
4
4
  import { WorkCard } from "../components/work-card.js";
@@ -7,7 +7,7 @@ import { Dialog } from "../components/dialog.js";
7
7
  import { ChatHeader } from "./header.js";
8
8
  import { ChatMessageList } from "./message-list.js";
9
9
  import { AssistantComposer } from "./assistant-composer.js";
10
- import { AssistantMessageView, AssistantSteps, assistantDerived } from "./assistant-content.js";
10
+ import { AssistantMessageView, AssistantSteps } from "./assistant-content.js";
11
11
  import { AssistantQuestionView } from "./assistant-question.js";
12
12
  import { AssistantMarkdown } from "./assistant-markdown.js";
13
13
  import { assistantScroll } from "./assistant-scroll.js";
@@ -32,18 +32,18 @@ export const assistantViewContract = {
32
32
  "status",
33
33
  ],
34
34
  };
35
- const AssistantWorkRow = defineComponent({ name: "assistant-work-row", parts: ["root"] }, ({ value, onOpen, actionLabel }, context) => h(WorkCard, {
35
+ const AssistantWorkRow = defineComponent({ name: "assistant-work-row", parts: ["root"] }, ({ value, onOpen, actionLabel }) => h(WorkCard, {
36
36
  action: actionLabel,
37
- title: assistantDerived(context, () => value.value.title),
38
- state: assistantDerived(context, () => value.value.tone ?? "unknown"),
39
- status: assistantDerived(context, () => value.value.statusText),
40
- detail: assistantDerived(context, () => [value.value.executionText, value.value.replyText].filter(Boolean).join(" · ")),
37
+ title: derived(() => value.value.title),
38
+ state: derived(() => value.value.tone ?? "unknown"),
39
+ status: derived(() => value.value.statusText),
40
+ detail: derived(() => [value.value.executionText, value.value.replyText].filter(Boolean).join(" · ")),
41
41
  onClick: (event) => onOpen(value.value.id, event.currentTarget),
42
42
  }));
43
43
  const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", parts: ["root", "feedback", "facts"] }, ({ value, options }, context) => {
44
44
  const assistantCopy = { ...defaultAssistantCopy, ...options.labels };
45
- const hidden = assistantDerived(context, () => value.value?.readState === "unavailable");
46
- const feedback = assistantDerived(context, () => {
45
+ const hidden = derived(() => value.value?.readState === "unavailable");
46
+ const feedback = derived(() => {
47
47
  const work = value.value;
48
48
  return (work?.feedback ||
49
49
  (work?.readState === "unavailable"
@@ -55,16 +55,17 @@ const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", par
55
55
  : ""));
56
56
  });
57
57
  const detail = h(AssistantMarkdown, {
58
- text: assistantDerived(context, () => value.value?.readState === "unavailable"
58
+ text: derived(() => value.value?.readState === "unavailable"
59
59
  ? ""
60
60
  : (value.value?.detail ?? value.value?.summary ?? "")),
61
61
  });
62
+ // The host detail slot may return a node. The default markdown view stays mounted otherwise.
62
63
  const custom = options.renderWorkDetail
63
- ? assistantDerived(context, () => value.value && value.value.readState !== "unavailable"
64
+ ? derived(() => value.value && value.value.readState !== "unavailable"
64
65
  ? (options.renderWorkDetail(value.value) ?? detail)
65
66
  : null)
66
67
  : detail;
67
- return context.part("root", "section", null, context.part("feedback", "p", { role: "status", hidden: assistantDerived(context, () => !feedback.value) }, feedback), context.part("facts", "div", { hidden }, h("h3", null, assistantDerived(context, () => value.value?.title ?? "")), h("p", null, h(StatusDot, { state: assistantDerived(context, () => value.value?.tone ?? "unknown") }), " ", assistantDerived(context, () => value.value?.statusText ?? "")), h("p", null, assistantDerived(context, () => value.value?.executionText ?? "")), h("p", null, assistantDerived(context, () => value.value?.replyText ?? "")), custom, h(AssistantSteps, { steps: assistantDerived(context, () => value.value?.steps ?? []) })), options.onRefreshWork
68
+ return context.part("root", "section", null, context.part("feedback", "p", { role: "status", hidden: derived(() => !feedback.value) }, feedback), context.part("facts", "div", { hidden }, h("h3", null, derived(() => value.value?.title ?? "")), h("p", null, h(StatusDot, { state: derived(() => value.value?.tone ?? "unknown") }), " ", derived(() => value.value?.statusText ?? "")), h("p", null, derived(() => value.value?.executionText ?? "")), h("p", null, derived(() => value.value?.replyText ?? "")), custom, h(AssistantSteps, { steps: derived(() => value.value?.steps ?? []) })), options.onRefreshWork
68
69
  ? h(Button, {
69
70
  variant: "outline",
70
71
  size: "small",
@@ -79,16 +80,16 @@ const AssistantWorkDetail = defineComponent({ name: "assistant-work-detail", par
79
80
  /** A complete default Assistant surface. Data, permissions, network and business lifetime stay with the host. */
80
81
  export const AssistantView = defineComponent(assistantViewContract, (options, context) => {
81
82
  const assistantCopy = { ...defaultAssistantCopy, ...options.labels };
82
- const messages = assistantDerived(context, () => unwrap(options.messages));
83
- const work = assistantDerived(context, () => unwrap(options.work ?? []));
84
- const questions = assistantDerived(context, () => unwrap(options.questions ?? []));
85
- const activity = assistantDerived(context, () => unwrap(options.activity));
83
+ const messages = derived(() => unwrap(options.messages));
84
+ const work = derived(() => unwrap(options.work ?? []));
85
+ const questions = derived(() => unwrap(options.questions ?? []));
86
+ const activity = derived(() => unwrap(options.activity));
86
87
  const panelOpen = context.signal(false);
87
88
  const selected = context.signal("");
88
- const selectedWork = assistantDerived(context, () => work.value.find((item) => item.id === selected.value));
89
+ const selectedWork = derived(() => work.value.find((item) => item.id === selected.value));
89
90
  const latestHidden = context.signal(true);
90
- const bodyHidden = assistantDerived(context, () => !!selected.value);
91
- const detailHidden = assistantDerived(context, () => !selected.value);
91
+ const bodyHidden = derived(() => !!selected.value);
92
+ const detailHidden = derived(() => !selected.value);
92
93
  let content;
93
94
  let scroll;
94
95
  let dialog;
@@ -189,19 +190,19 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
189
190
  })
190
191
  : null, context.part("feedback", "p", {
191
192
  role: "status",
192
- hidden: assistantDerived(context, () => unwrap(options.readState ?? "ready") === "ready"),
193
- }, assistantDerived(context, () => unwrap(options.readFeedback ?? "") ||
193
+ hidden: derived(() => unwrap(options.readState ?? "ready") === "ready"),
194
+ }, derived(() => unwrap(options.readFeedback ?? "") ||
194
195
  (unwrap(options.readState ?? "ready") === "loading"
195
196
  ? assistantCopy.loading
196
197
  : assistantCopy.readError))), context.part("empty", "div", {
197
- hidden: assistantDerived(context, () => messages.value.length > 0 || unwrap(options.readState ?? "ready") !== "ready"),
198
+ hidden: derived(() => messages.value.length > 0 || unwrap(options.readState ?? "ready") !== "ready"),
198
199
  }, 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, {
199
200
  variant: "outline",
200
201
  size: "small",
201
202
  onClick: () => scroll?.latest(),
202
203
  children: assistantCopy.latest,
203
204
  })));
204
- const activityList = context.part("activityBody", "div", { hidden: bodyHidden }, context.part("section", "section", null, h("h3", null, assistantCopy.current), context.part("status", "p", null, h(StatusDot, { state: assistantDerived(context, () => activity.value?.tone ?? "idle") }), assistantDerived(context, () => activity.value?.statusText ?? assistantCopy.noActivity)), h("strong", null, assistantDerived(context, () => activity.value?.title ?? "")), h("p", null, assistantDerived(context, () => activity.value?.description ?? "")), h(AssistantSteps, { steps: assistantDerived(context, () => activity.value?.steps ?? []) })), context.part("section", "section", null, h("h3", null, assistantCopy.background), h("p", { hidden: assistantDerived(context, () => work.value.length > 0) }, assistantCopy.noWork), keyed(work, (item) => item.id, (value) => h(AssistantWorkRow, {
205
+ const activityList = context.part("activityBody", "div", { hidden: bodyHidden }, context.part("section", "section", null, h("h3", null, assistantCopy.current), context.part("status", "p", null, h(StatusDot, { state: derived(() => activity.value?.tone ?? "idle") }), derived(() => activity.value?.statusText ?? assistantCopy.noActivity)), h("strong", null, derived(() => activity.value?.title ?? "")), h("p", null, derived(() => activity.value?.description ?? "")), h(AssistantSteps, { steps: derived(() => activity.value?.steps ?? []) })), context.part("section", "section", null, h("h3", null, assistantCopy.background), h("p", { hidden: derived(() => work.value.length > 0) }, assistantCopy.noWork), keyed(work, (item) => item.id, (value) => h(AssistantWorkRow, {
205
206
  value,
206
207
  actionLabel: assistantCopy.details,
207
208
  onOpen: (id, button) => {
@@ -212,7 +213,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
212
213
  dialog?.querySelector("[data-assistant-back]")?.focus();
213
214
  });
214
215
  },
215
- }))), context.part("section", "section", { hidden: assistantDerived(context, () => questions.value.length === 0) }, h("h3", null, assistantCopy.questions), keyed(questions, (question) => question.id, (value) => h(AssistantQuestionView, {
216
+ }))), context.part("section", "section", { hidden: derived(() => questions.value.length === 0) }, h("h3", null, assistantCopy.questions), keyed(questions, (question) => question.id, (value) => h(AssistantQuestionView, {
216
217
  value,
217
218
  labels: options.labels,
218
219
  onAnswer: options.onAnswer,
@@ -260,7 +261,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
260
261
  style: options.style,
261
262
  "aria-label": options["aria-label"],
262
263
  className: options.className,
263
- "data-activity-open": assistantDerived(context, () => String(panelOpen.value)),
264
+ "data-activity-open": derived(() => String(panelOpen.value)),
264
265
  ref: (element) => {
265
266
  root = element;
266
267
  const observer = new ResizeObserver(syncDialog);
@@ -280,7 +281,7 @@ export const AssistantView = defineComponent(assistantViewContract, (options, co
280
281
  h(Button, {
281
282
  variant: "quiet",
282
283
  size: "small",
283
- "aria-expanded": assistantDerived(context, () => String(panelOpen.value)),
284
+ "aria-expanded": derived(() => String(panelOpen.value)),
284
285
  ref: (element) => {
285
286
  activityTrigger = element;
286
287
  },
@@ -1,4 +1,4 @@
1
- import { type Props } from "meowjsx";
1
+ import { type MaybeSignal, type Props } from "meowjsx";
2
2
  export declare const chatAttachmentsContract: {
3
3
  readonly name: "chat-attachments";
4
4
  readonly parts: readonly ["root", "image", "preview", "file", "icon", "details", "name", "size", "entry", "previewButton", "remove"];
@@ -16,7 +16,8 @@ export interface ChatAttachmentItem {
16
16
  onRemove?: () => void;
17
17
  }
18
18
  export interface ChatAttachmentsProps extends Props {
19
- items: readonly ChatAttachmentItem[];
19
+ /** Plain arrays are fixed for the mount. A signal updates rows in place. */
20
+ items: MaybeSignal<readonly ChatAttachmentItem[]>;
20
21
  label?: string;
21
22
  className?: string;
22
23
  }
@@ -1,4 +1,4 @@
1
- import { defineComponent, h } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed, } from "meowjsx";
2
2
  import { Icon } from "../icons/icon.js";
3
3
  import { FileTypeIcon, fileExtension } from "../icons/file-type-icon.js";
4
4
  import { ImagePreview } from "../components/image-preview.js";
@@ -18,53 +18,62 @@ 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",
25
25
  "aria-label": label,
26
- }, items.map((item) => {
27
- const remove = item.onRemove
26
+ }, keyed(items, (item) => [
27
+ item.id,
28
+ item.mediaType.startsWith("image/") ? "image" : "file",
29
+ item.onRemove ? "remove" : "keep",
30
+ item.onPreview ? "preview" : "plain",
31
+ ].join(":"), (item) => {
32
+ const current = item.value;
33
+ const remove = current.onRemove
28
34
  ? context.part("remove", "button", {
29
35
  type: "button",
30
- onClick: item.onRemove,
31
- "aria-label": `移除 ${item.name}`,
36
+ onClick: () => item.value.onRemove?.(),
37
+ "aria-label": derived(() => `Remove ${item.value.name}`),
32
38
  }, h(Icon, { name: "x" }))
33
39
  : null;
34
- return item.mediaType.startsWith("image/")
35
- ? context.part("entry", "div", { key: item.id, "data-kind": "image" }, context.part("image", item.onPreview ? "button" : "a", item.onPreview
40
+ const size = derived(() => {
41
+ const bytes = item.value.sizeBytes;
42
+ if (bytes === undefined || !Number.isFinite(bytes) || bytes < 0)
43
+ return null;
44
+ return context.part("size", "small", null, [fileExtension(item.value.name).toUpperCase().slice(0, 8), formatBytes(bytes)]
45
+ .filter(Boolean)
46
+ .join(" "));
47
+ });
48
+ return current.mediaType.startsWith("image/")
49
+ ? context.part("entry", "div", { "data-kind": "image" }, context.part("image", current.onPreview ? "button" : "a", current.onPreview
36
50
  ? {
37
51
  type: "button",
38
- onClick: item.onPreview,
39
- "aria-label": `预览 ${item.name}`,
52
+ onClick: () => item.value.onPreview?.(),
53
+ "aria-label": derived(() => `Preview ${item.value.name}`),
40
54
  }
41
55
  : {
42
- href: item.url,
56
+ href: derived(() => item.value.url),
43
57
  target: "_blank",
44
58
  rel: "noreferrer",
45
- "aria-label": `打开图片 ${item.name}`,
46
- }, context.part("preview", "span", null, h(ImagePreview, { src: item.url, alt: item.name }))), remove)
47
- : context.part("entry", "div", { key: item.id, "data-kind": "file" }, context.part("file", "a", {
48
- key: item.id,
49
- href: item.url,
50
- download: item.name,
51
- onClick: item.onDownload
52
- ? (event) => {
53
- event.preventDefault();
54
- item.onDownload();
55
- }
56
- : undefined,
57
- }, context.part("icon", "span", { "aria-hidden": "true" }, h(FileTypeIcon, { path: item.name })), context.part("details", "span", null, context.part("name", "strong", null, item.name), item.sizeBytes !== undefined &&
58
- Number.isFinite(item.sizeBytes) &&
59
- item.sizeBytes >= 0
60
- ? context.part("size", "small", null, [
61
- fileExtension(item.name).toUpperCase().slice(0, 8),
62
- formatBytes(item.sizeBytes),
63
- ]
64
- .filter(Boolean)
65
- .join(" "))
66
- : null)), item.onPreview
67
- ? context.part("previewButton", "button", { type: "button", onClick: item.onPreview, "aria-label": `预览 ${item.name}` }, "预览")
59
+ "aria-label": derived(() => `Open image ${item.value.name}`),
60
+ }, context.part("preview", "span", null, h(ImagePreview, { src: current.url, alt: current.name }))), remove)
61
+ : context.part("entry", "div", { "data-kind": "file" }, context.part("file", "a", {
62
+ href: derived(() => item.value.url),
63
+ download: derived(() => item.value.name),
64
+ onClick: (event) => {
65
+ const download = item.value.onDownload;
66
+ if (!download)
67
+ return;
68
+ event.preventDefault();
69
+ download();
70
+ },
71
+ }, context.part("icon", "span", { "aria-hidden": "true" }, h(FileTypeIcon, { path: current.name })), context.part("details", "span", null, context.part("name", "strong", null, derived(() => item.value.name)), size)), current.onPreview
72
+ ? context.part("previewButton", "button", {
73
+ type: "button",
74
+ onClick: () => item.value.onPreview?.(),
75
+ "aria-label": derived(() => `Preview ${item.value.name}`),
76
+ }, "Preview")
68
77
  : null, remove);
69
78
  })));
70
79
  function formatBytes(value) {
@@ -0,0 +1,16 @@
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
+ * A ChatComposer and optional page-level meta row. The composer keeps its single
14
+ * writing surface and external hint; this panel owns the surrounding composition.
15
+ */
16
+ export declare const ComposerPanel: import("meowjsx").Component<ComposerPanelProps, "composer-panel", "meta" | "root" | "surface">;
@@ -0,0 +1,11 @@
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
+ * A ChatComposer and optional page-level meta row. The composer keeps its single
9
+ * writing surface and external hint; this panel owns the surrounding composition.
10
+ */
11
+ 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)), 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
- readonly parts: readonly ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"];
9
+ readonly parts: readonly ["root", "surface", "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;
@@ -21,16 +23,18 @@ export interface ChatComposerProps extends Props, ThemedProps<typeof chatCompose
21
23
  attachments?: Child;
22
24
  /** Model/provider selection beside the send action; options and state belong to the host. */
23
25
  trailing?: Child;
26
+ /** Supporting instructions below the writing surface, associated through hintId. */
24
27
  hint?: Child;
25
28
  hintId?: string;
26
29
  submitLabel?: string;
27
30
  /** Visible action content; the accessible name always comes from submitLabel. */
28
31
  submitContent?: Child;
29
- disabled?: boolean;
32
+ disabled?: MaybeSignal<boolean>;
33
+ readOnly?: MaybeSignal<boolean>;
30
34
  /** Prevent another submission while keeping the draft editable. */
31
35
  submitDisabled?: MaybeSignal<boolean>;
32
36
  onSubmit?: ChatComposerSubmit;
33
37
  onInput?: ChatComposerInput;
34
38
  className?: string;
35
39
  }
36
- export declare const ChatComposer: import("meowjsx").Component<ChatComposerProps, "chat-composer", "actions" | "attachments" | "field" | "hint" | "input" | "root" | "submit" | "trailing">;
40
+ export declare const ChatComposer: import("meowjsx").Component<ChatComposerProps, "chat-composer", "actions" | "attachments" | "field" | "hint" | "input" | "root" | "submit" | "surface" | "trailing">;
@@ -1,31 +1,80 @@
1
1
  import { defineOptions } from "meowcss";
2
2
  import { defineStyleProps } from "meowcss/meowjsx";
3
- import { defineComponent, h } from "meowjsx";
3
+ import { defineComponent, derived, h, unwrap, } 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
- parts: ["root", "attachments", "field", "input", "hint", "actions", "trailing", "submit"],
11
- styleProps: defineStyleProps(chatComposerOptions, { defaults: { layout: "stacked" } }),
11
+ parts: [
12
+ "root",
13
+ "surface",
14
+ "attachments",
15
+ "field",
16
+ "input",
17
+ "hint",
18
+ "actions",
19
+ "trailing",
20
+ "submit",
21
+ ],
22
+ styleProps: defineStyleProps(chatComposerOptions, {
23
+ defaults: { layout: "stacked", surface: "default" },
24
+ }),
12
25
  };
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", {
14
- ...props,
15
- className,
16
- onSubmit,
17
- }, attachments ? context.part("attachments", "div", null, attachments) : null, context.part("field", "div", null, context.part("input", "textarea", {
18
- "data-chat-input": true,
19
- name: "message",
20
- rows: 1,
21
- value,
22
- placeholder,
23
- "aria-label": inputLabel,
24
- "aria-describedby": hint && hintId ? hintId : undefined,
25
- disabled,
26
- onInput,
27
- }), hint ? context.part("hint", "span", hintId ? { id: hintId } : null, hint) : null), context.part("actions", "div", null, children, trailing ? context.part("trailing", "div", null, trailing) : null, context.part("submit", "button", {
28
- type: "submit",
29
- disabled: disabled ? true : submitDisabled,
30
- "aria-label": submitLabel,
31
- }, submitContent ?? h(Icon, { name: "arrow-up" })))));
26
+ export const ChatComposer = defineComponent(chatComposerContract, ({ value = "", placeholder = "Write a message…", inputLabel = "Message", attachments, trailing, hint, hintId, submitLabel = "Send", submitContent, disabled = false, readOnly = false, submitDisabled = false, onSubmit, onInput, children, className, ...props }, context) => {
27
+ const submitBlocked = disabled === true
28
+ ? true
29
+ : typeof disabled === "boolean"
30
+ ? submitDisabled
31
+ : derived(() => Boolean(unwrap(disabled)) || Boolean(unwrap(submitDisabled)));
32
+ let field;
33
+ const resize = () => {
34
+ if (!field?.isConnected)
35
+ return;
36
+ field.style.height = "auto";
37
+ field.style.height = `${field.scrollHeight}px`;
38
+ };
39
+ return context.part("root", "form", {
40
+ ...props,
41
+ className,
42
+ onSubmit,
43
+ }, context.part("surface", "div", null, attachments ? context.part("attachments", "div", null, attachments) : null, context.part("field", "div", null, context.part("input", "textarea", {
44
+ "data-chat-input": true,
45
+ name: "message",
46
+ rows: 1,
47
+ value,
48
+ placeholder,
49
+ "aria-label": inputLabel,
50
+ "aria-describedby": hint && hintId ? hintId : undefined,
51
+ disabled,
52
+ readOnly,
53
+ onInput,
54
+ ref: (textarea) => {
55
+ field = textarea;
56
+ const stop = context.effect(() => {
57
+ unwrap(value);
58
+ resize();
59
+ });
60
+ const onResizeInput = () => resize();
61
+ textarea.addEventListener("input", onResizeInput);
62
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(resize) : undefined;
63
+ observer?.observe(textarea);
64
+ queueMicrotask(() => {
65
+ if (textarea.isConnected)
66
+ resize();
67
+ });
68
+ return () => {
69
+ stop();
70
+ textarea.removeEventListener("input", onResizeInput);
71
+ observer?.disconnect();
72
+ field = undefined;
73
+ };
74
+ },
75
+ })), context.part("actions", "div", null, children, trailing ? context.part("trailing", "div", null, trailing) : null, context.part("submit", "button", {
76
+ type: "submit",
77
+ disabled: submitBlocked,
78
+ "aria-label": submitLabel,
79
+ }, submitContent ?? h(Icon, { name: "arrow-up" })))), hint ? context.part("hint", "span", hintId ? { id: hintId } : null, hint) : null);
80
+ });
@@ -8,11 +8,11 @@ export const chatConversationContract = {
8
8
  * Place it beside the host viewport in a height-constrained column; the host
9
9
  * owns visibility, returning to the end and restoring viewport focus.
10
10
  */
11
- export const ChatConversationLatest = defineComponent(chatConversationContract, ({ children, ...props }, context) => context.part("latest", "button", { type: "button", ...props }, children ?? "回到最新消息"));
11
+ export const ChatConversationLatest = defineComponent(chatConversationContract, ({ children, ...props }, context) => context.part("latest", "button", { type: "button", ...props }, children ?? "Back to latest message"));
12
12
  /** Optional scroll owner for append-only transcripts. Give the root a constrained height.
13
13
  * Do not combine with an application-owned scroll controller. Children can use ChatMessageList.
14
14
  */
15
- 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) => {
16
16
  const hidden = context.signal(true);
17
17
  let jump;
18
18
  const mount = (root) => {
@@ -1,5 +1,6 @@
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
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";
@@ -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";
@@ -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);
@@ -1,4 +1,5 @@
1
- import { defineComponent, h, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
+ import { Progress } from "../components/progress.js";
2
3
  import { StatusDot } from "../components/status-dot.js";
3
4
  import { executionStateLabel, executionStateTone, } from "../shared/execution-state.js";
4
5
  export const chatTaskContract = {
@@ -31,23 +32,16 @@ function checkedProgress(value) {
31
32
  }
32
33
  /** A task record, not an executable task or a whole-card control. */
33
34
  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) ?? ""));
35
+ const currentProgress = derived(() => checkedProgress(unwrap(progress)));
36
+ const text = (part, value) => context.part(part, "p", { hidden: derived(() => !unwrap(value)) }, derived(() => unwrap(value) ?? ""));
43
37
  return context.part("root", "section", {
44
38
  ...props,
45
39
  className,
46
40
  "aria-label": props["aria-label"] ?? title,
47
41
  "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));
42
+ }, context.part("header", "div", null, context.part("title", "strong", null, title), context.part("status", "span", null, h(StatusDot, { state: derived(() => executionStateTone(unwrap(state))) }), derived(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state))))), text("description", description), text("execution", executionText), text("reply", replyText), context.part("progress", "div", { hidden: derived(() => currentProgress.value === undefined) }, context.part("progressLabel", "span", null, derived(() => currentProgress.value?.label ?? "")), context.part("progressBar", "div", null, h(Progress, {
43
+ value: derived(() => currentProgress.value?.value ?? 0),
44
+ max: derived(() => currentProgress.value?.max ?? 1),
45
+ label: derived(() => currentProgress.value?.label ?? ""),
46
+ }))), context.part("body", "div", null, children), context.part("footer", "div", null, footer));
53
47
  });
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, unwrap, } from "meowjsx";
2
2
  import { Icon } from "../icons/icon.js";
3
3
  import { Button } from "../components/button.js";
4
4
  import { OutputBlock } from "../components/output-block.js";
@@ -22,20 +22,13 @@ export const chatToolCallContract = {
22
22
  ],
23
23
  };
24
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
25
  const copy = {
33
- input: "输入",
34
- output: "输出",
35
- emptyInput: "没有输入内容",
36
- emptyOutput: "输出为空",
37
- retry: "重试",
38
- cancel: "取消",
26
+ input: "Input",
27
+ output: "Output",
28
+ emptyInput: "No input content",
29
+ emptyOutput: "Empty output",
30
+ retry: "Retry",
31
+ cancel: "Cancel",
39
32
  ...labels,
40
33
  };
41
34
  const status = derived(() => unwrap(statusLabel) ?? executionStateLabel(unwrap(state)));
@@ -0,0 +1,24 @@
1
+ import { type Child, type MaybeSignal, type Props } from "meowjsx";
2
+ export declare const accordionContract: {
3
+ readonly name: "accordion";
4
+ readonly parts: readonly ["root", "item"];
5
+ };
6
+ export interface AccordionItem {
7
+ id: string;
8
+ summary: Child;
9
+ content: Child;
10
+ }
11
+ export type AccordionType = "single" | "multiple";
12
+ export type AccordionValue = string | readonly string[];
13
+ export interface AccordionProps extends Props {
14
+ items: readonly AccordionItem[];
15
+ /** `single` keeps one section open; `multiple` lets several stay open. */
16
+ type?: AccordionType;
17
+ value?: MaybeSignal<AccordionValue>;
18
+ defaultValue?: AccordionValue;
19
+ onValueChange?: (value: AccordionValue) => void;
20
+ label?: string;
21
+ className?: string;
22
+ }
23
+ /** Grouped disclosures. Items are fixed for the mount. Expansion is handed to the caller when `value` is set. */
24
+ export declare const Accordion: import("meowjsx").Component<AccordionProps, "accordion", "item" | "root">;