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
@@ -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,10 +1,9 @@
1
- import { defineComponent, h, unwrap } from "meowjsx";
1
+ import { defineComponent, derived, h, isSignal, unwrap } from "meowjsx";
2
2
  import { ChatComposer } from "./composer.js";
3
3
  import { ChatAttachments } from "./attachments.js";
4
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
- import { assistantDerived } from "./assistant-content.js";
8
7
  import { consumeAssistantDraft, snapshotAssistantDraft } from "./assistant-draft.js";
9
8
  import { assistantCopy as defaultAssistantCopy, } from "./assistant-types.js";
10
9
  export const assistantComposerContract = {
@@ -17,20 +16,19 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
17
16
  if (controlled && !options.onDraftChange && !options.readOnly)
18
17
  throw new Error("A controlled Assistant draft requires onDraftChange or readOnly");
19
18
  const local = context.signal(options.defaultDraft ?? { text: "", attachments: [] });
20
- const draft = assistantDerived(context, () => controlled ? unwrap(options.draft) : local.value);
21
- const text = assistantDerived(context, () => draft.value.text);
19
+ const draft = derived(() => (controlled ? unwrap(options.draft) : local.value));
20
+ const text = derived(() => draft.value.text);
22
21
  const pending = context.signal(false);
23
22
  const attaching = context.signal(false);
24
23
  const feedback = context.signal("");
25
- const disabled = assistantDerived(context, () => options.readOnly || unwrap(options.disabled ?? false));
26
- const submitDisabled = assistantDerived(context, () => disabled.value ||
24
+ const disabled = derived(() => options.readOnly || unwrap(options.disabled ?? false));
25
+ const submitDisabled = derived(() => disabled.value ||
27
26
  pending.value ||
28
27
  !options.onSubmit ||
29
28
  (!draft.value.text.trim() && !draft.value.attachments.length));
30
29
  let textVersion = 0;
31
30
  let previousText = draft.value.text;
32
31
  let disposed = false;
33
- let textarea;
34
32
  let fileInput;
35
33
  const urls = new Set();
36
34
  context.effect(() => {
@@ -46,12 +44,6 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
46
44
  local.value = next;
47
45
  options.onDraftChange?.(next);
48
46
  };
49
- const resize = () => {
50
- if (!textarea)
51
- return;
52
- textarea.style.height = "auto";
53
- textarea.style.height = `${textarea.scrollHeight}px`;
54
- };
55
47
  const send = async (event) => {
56
48
  event.preventDefault();
57
49
  if (pending.value || submitDisabled.value || !options.onSubmit)
@@ -75,10 +67,8 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
75
67
  feedback.value = assistantCopy.submitError;
76
68
  }
77
69
  finally {
78
- if (!disposed) {
70
+ if (!disposed)
79
71
  pending.value = false;
80
- resize();
81
- }
82
72
  }
83
73
  };
84
74
  const attach = async (event) => {
@@ -122,111 +112,81 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
122
112
  });
123
113
  const localModel = context.signal(unwrap(options.models ?? [])[0]?.value ?? "");
124
114
  const localReasoning = context.signal(unwrap(options.reasoningOptions ?? [])[0]?.value ?? "");
125
- const choices = context.part("choices", "div", null, assistantDerived(context, () => {
126
- const models = unwrap(options.models ?? []);
127
- return models.length
128
- ? h(ChoiceSelect, {
129
- options: models,
130
- value: options.model ?? localModel,
131
- "aria-label": assistantCopy.model,
132
- onValueChange: (value) => {
133
- if (options.model === undefined)
134
- localModel.value = value;
135
- options.onModelChange?.(value);
136
- },
137
- placement: "top",
138
- matchTriggerWidth: false,
139
- })
140
- : null;
141
- }), assistantDerived(context, () => {
142
- const reasoning = unwrap(options.reasoningOptions ?? []);
143
- return reasoning.length
144
- ? h(ChoiceSelect, {
145
- options: reasoning,
146
- value: options.reasoning ?? localReasoning,
147
- "aria-label": assistantCopy.reasoning,
148
- onValueChange: (value) => {
149
- if (options.reasoning === undefined)
150
- localReasoning.value = value;
151
- options.onReasoningChange?.(value);
152
- },
153
- placement: "top",
154
- matchTriggerWidth: false,
155
- })
156
- : null;
157
- }), options.composerTrailing);
115
+ const modelsLive = options.models !== undefined && (isSignal(options.models) || options.models.length > 0);
116
+ const reasoningLive = options.reasoningOptions !== undefined &&
117
+ (isSignal(options.reasoningOptions) || options.reasoningOptions.length > 0);
118
+ const choices = context.part("choices", "div", null, modelsLive
119
+ ? h(ChoiceSelect, {
120
+ hidden: derived(() => unwrap(options.models ?? []).length === 0),
121
+ options: derived(() => unwrap(options.models ?? [])),
122
+ value: options.model ?? localModel,
123
+ "aria-label": assistantCopy.model,
124
+ onValueChange: (value) => {
125
+ if (options.model === undefined)
126
+ localModel.value = value;
127
+ options.onModelChange?.(value);
128
+ },
129
+ placement: "top",
130
+ matchTriggerWidth: false,
131
+ })
132
+ : null, reasoningLive
133
+ ? h(ChoiceSelect, {
134
+ hidden: derived(() => unwrap(options.reasoningOptions ?? []).length === 0),
135
+ options: derived(() => unwrap(options.reasoningOptions ?? [])),
136
+ value: options.reasoning ?? localReasoning,
137
+ "aria-label": assistantCopy.reasoning,
138
+ onValueChange: (value) => {
139
+ if (options.reasoning === undefined)
140
+ localReasoning.value = value;
141
+ options.onReasoningChange?.(value);
142
+ },
143
+ placement: "top",
144
+ matchTriggerWidth: false,
145
+ })
146
+ : null, options.composerTrailing);
158
147
  return context.part("root", "div", null, h(ChatComposer, {
159
148
  value: text,
160
149
  placeholder: assistantCopy.placeholder,
161
150
  inputLabel: assistantCopy.composer,
162
151
  submitLabel: assistantCopy.send,
152
+ disabled,
153
+ readOnly: Boolean(options.readOnly),
163
154
  submitDisabled,
164
155
  trailing: choices,
165
- attachments: assistantDerived(context, () => draft.value.attachments.length
166
- ? h(ChatAttachments, {
167
- items: draft.value.attachments.map((attachment) => ({
168
- ...attachment,
169
- onRemove: disabled.value
170
- ? undefined
171
- : () => change({
172
- ...draft.value,
173
- attachments: draft.value.attachments.filter((item) => item !== attachment),
174
- }),
175
- })),
176
- })
177
- : null),
178
- hint: assistantDerived(context, () => unwrap(options.disabledReason ?? "")),
156
+ attachments: h(ChatAttachments, {
157
+ hidden: derived(() => draft.value.attachments.length === 0),
158
+ items: derived(() => draft.value.attachments.map((attachment) => ({
159
+ ...attachment,
160
+ onRemove: disabled.value
161
+ ? undefined
162
+ : () => change({
163
+ ...draft.value,
164
+ attachments: draft.value.attachments.filter((item) => item.id !== attachment.id),
165
+ }),
166
+ }))),
167
+ }),
168
+ hint: derived(() => unwrap(options.disabledReason ?? "")),
179
169
  onSubmit: send,
180
170
  onInput: (event) => {
181
171
  textVersion++;
182
172
  change({ ...draft.value, text: event.target.value });
183
- resize();
184
173
  },
185
174
  onKeyDown: (event) => {
186
- if (event.target === textarea &&
175
+ const target = event.target;
176
+ if (target instanceof HTMLTextAreaElement &&
177
+ target.dataset.chatInput !== undefined &&
187
178
  event.key === "Enter" &&
188
179
  !event.shiftKey &&
189
180
  !event.isComposing &&
190
181
  event.keyCode !== 229)
191
182
  void send(event);
192
183
  },
193
- ref: (form) => {
194
- let active = true;
195
- let stop;
196
- const observer = new ResizeObserver(resize);
197
- observer.observe(form);
198
- // Host refs run before children mount; find the native input after this tree is mounted.
199
- queueMicrotask(() => {
200
- if (!active || disposed || !form.isConnected)
201
- return;
202
- textarea = form.querySelector("textarea");
203
- stop = context.effect(() => {
204
- const value = text.value;
205
- textarea.disabled = !!disabled.value;
206
- textarea.readOnly = !!options.readOnly;
207
- queueMicrotask(() => {
208
- if (!disposed && textarea) {
209
- if (textarea.value !== value)
210
- textarea.value = value;
211
- resize();
212
- }
213
- });
214
- });
215
- resize();
216
- });
217
- return () => {
218
- active = false;
219
- stop?.();
220
- observer.disconnect();
221
- textarea = undefined;
222
- };
223
- },
224
184
  children: options.allowAttachments === false
225
185
  ? []
226
186
  : [
227
187
  h(IconButton, {
228
188
  label: assistantCopy.attach,
229
- disabled: assistantDerived(context, () => disabled.value || attaching.value),
189
+ disabled: derived(() => disabled.value || attaching.value),
230
190
  onClick: () => fileInput?.click(),
231
191
  children: h(Icon, { name: "paperclip" }),
232
192
  }),
@@ -240,5 +200,5 @@ export const AssistantComposer = defineComponent(assistantComposerContract, ({ o
240
200
  },
241
201
  }),
242
202
  ],
243
- }), context.part("feedback", "p", { role: "status", hidden: assistantDerived(context, () => !feedback.value) }, feedback));
203
+ }), context.part("feedback", "p", { role: "status", hidden: derived(() => !feedback.value) }, feedback));
244
204
  });
@@ -1,7 +1,5 @@
1
- import { type LifecycleScope, type Signal } from "meowjsx";
1
+ import { type Signal } from "meowjsx";
2
2
  import type { AssistantMessage, AssistantMessagePart, AssistantProcessStep, AssistantViewProps } from "./assistant-types.js";
3
- /** All derived values live in their owning component lifecycle. */
4
- export declare function assistantDerived<T>(context: Pick<LifecycleScope, "signal" | "effect">, read: () => T): import("meowjsx").WritableSignal<T>;
5
3
  export declare const assistantStepsContract: {
6
4
  readonly name: "assistant-steps";
7
5
  readonly parts: readonly ["root", "step", "label", "description", "status"];
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, keyed, unwrap, } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed, unwrap } from "meowjsx";
2
2
  import { ChatMessage } from "./message.js";
3
3
  import { ChatAttachments } from "./attachments.js";
4
4
  import { ChatToolCall } from "./tool-call.js";
@@ -7,42 +7,33 @@ import { ProcessGroup } from "../components/process-group.js";
7
7
  import { CodeBlock } from "../components/code-block.js";
8
8
  import { StatusDot } from "../components/status-dot.js";
9
9
  import { AssistantMarkdown } from "./assistant-markdown.js";
10
- /** All derived values live in their owning component lifecycle. */
11
- export function assistantDerived(context, read) {
12
- const value = context.signal(read());
13
- context.effect(() => {
14
- value.value = read();
15
- });
16
- return value;
17
- }
18
10
  export const assistantStepsContract = {
19
11
  name: "assistant-steps",
20
12
  parts: ["root", "step", "label", "description", "status"],
21
13
  };
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 ?? ""))));
14
+ const AssistantStep = defineComponent(assistantStepsContract, ({ value }, context) => context.part("step", "li", null, h(StatusDot, { state: derived(() => value.value.tone ?? "unknown") }), context.part("label", "div", null, h("strong", null, derived(() => value.value.title)), context.part("description", "p", { hidden: derived(() => !value.value.description) }, derived(() => value.value.description ?? ""))), context.part("status", "span", null, derived(() => value.value.statusText ?? ""))));
23
15
  export const AssistantSteps = defineComponent(assistantStepsContract, ({ steps }, context) => context.part("root", "ol", null, keyed(steps, (step) => step.id, (value) => h(AssistantStep, { value }))));
24
16
  export const AssistantPartView = defineComponent({ name: "assistant-part", parts: ["root"] }, ({ value, message, renderPart, onToolAction }, context) => {
25
17
  // The keyed identity includes kind, so this component's structural variant is stable.
26
18
  const initial = value.value;
27
- const custom = renderPart
28
- ? assistantDerived(context, () => renderPart(value.value, message.value))
29
- : undefined;
19
+ // Host slots may return a node. Component fallbacks stay mounted and take signals instead.
20
+ const custom = renderPart ? derived(() => renderPart(value.value, message.value)) : undefined;
30
21
  let fallback;
31
22
  if (initial.kind === "text") {
32
23
  fallback = h(AssistantMarkdown, {
33
- text: assistantDerived(context, () => value.value.text),
24
+ text: derived(() => value.value.text),
34
25
  });
35
26
  }
36
27
  else if (initial.kind === "tool") {
37
28
  const tool = () => value.value;
38
29
  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),
30
+ label: derived(() => tool().label),
31
+ summary: derived(() => tool().summary),
32
+ state: derived(() => tool().state ?? "unknown"),
33
+ statusLabel: derived(() => tool().statusLabel),
34
+ input: derived(() => tool().input),
35
+ output: derived(() => tool().output),
36
+ outputSummary: derived(() => tool().outputSummary),
46
37
  maxLines: initial.maxLines,
47
38
  collapsible: true,
48
39
  open: initial.defaultOpen ?? false,
@@ -58,56 +49,57 @@ export const AssistantPartView = defineComponent({ name: "assistant-part", parts
58
49
  onToolAction(message.value.id, tool().id, "cancel");
59
50
  }
60
51
  : 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),
52
+ canRetry: derived(() => tool().canRetry ?? false),
53
+ canCancel: derived(() => tool().canCancel ?? false),
54
+ retryDisabled: derived(() => tool().retryDisabled ?? false),
55
+ cancelDisabled: derived(() => tool().cancelDisabled ?? false),
65
56
  });
66
57
  }
67
58
  else if (initial.kind === "task") {
68
59
  const task = () => value.value;
69
60
  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),
61
+ title: derived(() => task().title),
62
+ state: derived(() => task().state),
63
+ statusLabel: derived(() => task().statusLabel),
64
+ description: derived(() => task().description),
65
+ executionText: derived(() => task().executionText),
66
+ replyText: derived(() => task().replyText),
67
+ progress: derived(() => task().progress),
77
68
  children: h(AssistantSteps, {
78
- steps: assistantDerived(context, () => task().steps ?? []),
69
+ steps: derived(() => task().steps ?? []),
79
70
  }),
80
71
  });
81
72
  }
82
73
  else if (initial.kind === "process") {
83
74
  fallback = h(ProcessGroup, {
84
- title: assistantDerived(context, () => value.value.title),
85
- status: assistantDerived(context, () => value.value.statusText),
75
+ title: derived(() => value.value.title),
76
+ status: derived(() => value.value.statusText),
86
77
  open: initial.defaultOpen ?? false,
87
78
  children: h(AssistantSteps, {
88
- steps: assistantDerived(context, () => value.value.steps),
79
+ steps: derived(() => value.value.steps),
89
80
  }),
90
81
  });
91
82
  }
92
83
  else if (initial.kind === "code") {
93
- // CodeBlock owns its copy/wrap/highlight lifecycle. Replace only this block on code changes.
94
- fallback = assistantDerived(context, () => {
95
- const part = value.value;
96
- return h(CodeBlock, { code: part.code, language: part.language });
84
+ fallback = h(CodeBlock, {
85
+ code: derived(() => value.value.code),
86
+ language: derived(() => value.value.language),
97
87
  });
98
88
  }
99
89
  else {
100
- fallback = assistantDerived(context, () => h(ChatAttachments, { items: value.value.items }));
90
+ fallback = h(ChatAttachments, {
91
+ items: derived(() => value.value.items),
92
+ });
101
93
  }
102
- const content = custom ? assistantDerived(context, () => unwrap(custom) ?? fallback) : fallback;
94
+ const content = custom ? derived(() => unwrap(custom) ?? fallback) : fallback;
103
95
  return context.part("root", "div", { "data-assistant-part-id": initial.id, "data-kind": initial.kind }, content);
104
96
  });
105
97
  export const AssistantMessageView = defineComponent({ name: "assistant-message", parts: ["root"] }, ({ value, renderPart, onToolAction }, context) => {
106
- const parts = assistantDerived(context, () => value.value.parts);
98
+ const parts = derived(() => value.value.parts);
107
99
  return context.part("root", "div", { "data-assistant-message-id": value.value.id }, h(ChatMessage, {
108
100
  role: value.value.role,
109
101
  author: "",
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 : ""))),
102
+ header: h("div", { "data-assistant-message-header": true }, h("strong", null, derived(() => value.value.author)), h("time", null, derived(() => value.value.timestamp ?? "")), h("span", { role: "status" }, derived(() => value.value.status && value.value.status !== "complete" ? value.value.status : ""))),
111
103
  surface: "none",
112
104
  children: keyed(parts, (part) => `${part.id}:${part.kind}`, (part) => h(AssistantPartView, { value: part, message: value, renderPart, onToolAction })),
113
105
  }));
@@ -1,4 +1,4 @@
1
- import { defineComponent } from "meowjsx";
1
+ import { defineComponent, derived } from "meowjsx";
2
2
  import { Marked, Renderer } from "marked";
3
3
  const escape = (text) => text.replace(/[&<>"']/g, (value) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[value]);
4
4
  export function assistantSafeLink(href) {
@@ -24,10 +24,6 @@ const markdown = new Marked({ renderer, gfm: true, breaks: true });
24
24
  /** Raw HTML and images are text. Only explicit safe external links become navigation. */
25
25
  export const assistantMarkdown = (text) => markdown.parse(text, { async: false });
26
26
  export const assistantMarkdownContract = { name: "assistant-markdown", parts: ["root"] };
27
- export const AssistantMarkdown = defineComponent(assistantMarkdownContract, ({ text }, context) => {
28
- const html = context.signal({ __html: assistantMarkdown(text.value) });
29
- context.effect(() => {
30
- html.value = { __html: assistantMarkdown(text.value) };
31
- });
32
- return context.part("root", "div", { dangerouslySetInnerHTML: html });
33
- });
27
+ export const AssistantMarkdown = defineComponent(assistantMarkdownContract, ({ text }, context) => context.part("root", "div", {
28
+ dangerouslySetInnerHTML: derived(() => ({ __html: assistantMarkdown(text.value) })),
29
+ }));
@@ -1,8 +1,7 @@
1
- import { defineComponent, h } from "meowjsx";
1
+ import { defineComponent, derived, h, keyed } from "meowjsx";
2
2
  import { ChatQuestion } from "./question.js";
3
3
  import { Button } from "../components/button.js";
4
4
  import { Select } from "../components/select.js";
5
- import { assistantDerived } from "./assistant-content.js";
6
5
  import { assistantCopy as defaultAssistantCopy, } from "./assistant-types.js";
7
6
  export const assistantQuestionContract = {
8
7
  name: "assistant-question",
@@ -13,7 +12,7 @@ export const AssistantQuestionView = defineComponent(assistantQuestionContract,
13
12
  const answer = context.signal("");
14
13
  const sending = context.signal(false);
15
14
  const error = context.signal("");
16
- const disabled = assistantDerived(context, () => sending.value || value.value.state !== "open" || !onAnswer);
15
+ const disabled = derived(() => sending.value || value.value.state !== "open" || !onAnswer);
17
16
  let disposed = false;
18
17
  context.onCleanup(() => {
19
18
  disposed = true;
@@ -38,10 +37,10 @@ export const AssistantQuestionView = defineComponent(assistantQuestionContract,
38
37
  // Question state and answer acceptance remain facts supplied by the host.
39
38
  };
40
39
  return context.part("root", "form", { onSubmit: submit }, h(ChatQuestion, {
41
- question: assistantDerived(context, () => value.value.title),
40
+ question: derived(() => value.value.title),
42
41
  label: assistantCopy.questions,
43
- description: assistantDerived(context, () => value.value.description),
44
- feedback: assistantDerived(context, () => error.value ||
42
+ description: derived(() => value.value.description),
43
+ feedback: derived(() => error.value ||
45
44
  value.value.feedback ||
46
45
  (value.value.state === "submitting"
47
46
  ? assistantCopy.questionSubmitting
@@ -51,22 +50,22 @@ export const AssistantQuestionView = defineComponent(assistantQuestionContract,
51
50
  ? assistantCopy.questionUnavailable
52
51
  : "")),
53
52
  children: [
54
- context.part("options", "div", { hidden: assistantDerived(context, () => !value.value.options?.length) }, h(Select, {
53
+ context.part("options", "div", { hidden: derived(() => !value.value.options?.length) }, h(Select, {
55
54
  value: answer,
56
55
  disabled,
57
- "aria-label": value.value.title,
56
+ "aria-label": derived(() => value.value.title),
58
57
  onChange: (event) => {
59
58
  answer.value = event.currentTarget.value;
60
59
  },
61
- children: assistantDerived(context, () => [
60
+ children: [
62
61
  h("option", { value: "" }, assistantCopy.answerPlaceholder),
63
- ...(value.value.options ?? []).map((option) => h("option", { value: option.value }, option.label)),
64
- ]),
62
+ keyed(derived(() => value.value.options ?? []), (option) => option.value, (option) => h("option", { value: derived(() => option.value.value) }, derived(() => option.value.label))),
63
+ ],
65
64
  })),
66
65
  context.part("answer", "textarea", {
67
66
  value: answer,
68
67
  rows: 2,
69
- "aria-label": `${assistantCopy.answer}: ${value.value.title}`,
68
+ "aria-label": derived(() => `${assistantCopy.answer}: ${value.value.title}`),
70
69
  placeholder: assistantCopy.answerPlaceholder,
71
70
  disabled,
72
71
  onInput: (event) => {
@@ -78,14 +77,14 @@ export const AssistantQuestionView = defineComponent(assistantQuestionContract,
78
77
  h(Button, {
79
78
  type: "submit",
80
79
  size: "small",
81
- disabled: assistantDerived(context, () => disabled.value || !answer.value.trim()),
80
+ disabled: derived(() => disabled.value || !answer.value.trim()),
82
81
  children: assistantCopy.answer,
83
82
  }),
84
83
  onDismiss
85
84
  ? h(Button, {
86
85
  variant: "quiet",
87
86
  size: "small",
88
- disabled: assistantDerived(context, () => sending.value || value.value.state !== "open"),
87
+ disabled: derived(() => sending.value || value.value.state !== "open"),
89
88
  onClick: () => onDismiss(value.value.id),
90
89
  children: assistantCopy.dismiss,
91
90
  })