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.
- package/AGENT-COMPONENTS.md +65 -65
- package/ASSISTANT.md +35 -35
- package/JSON.md +11 -11
- package/README.md +413 -385
- package/THIRD_PARTY_NOTICES.md +8 -0
- package/dist/src/chat/assistant-composer.js +58 -98
- package/dist/src/chat/assistant-content.d.ts +1 -3
- package/dist/src/chat/assistant-content.js +36 -44
- package/dist/src/chat/assistant-markdown.js +4 -8
- package/dist/src/chat/assistant-question.js +13 -14
- package/dist/src/chat/assistant.js +27 -26
- package/dist/src/chat/attachments.d.ts +3 -2
- package/dist/src/chat/attachments.js +43 -34
- package/dist/src/chat/composer-panel.d.ts +16 -0
- package/dist/src/chat/composer-panel.js +11 -0
- package/dist/src/chat/composer.d.ts +7 -3
- package/dist/src/chat/composer.js +71 -22
- package/dist/src/chat/conversation.js +2 -2
- package/dist/src/chat/index.d.ts +1 -0
- package/dist/src/chat/index.js +1 -0
- package/dist/src/chat/message-list.js +1 -1
- package/dist/src/chat/message.js +3 -3
- package/dist/src/chat/question.js +1 -1
- package/dist/src/chat/sources.js +1 -1
- package/dist/src/chat/task.js +9 -15
- package/dist/src/chat/tool-call.js +7 -14
- package/dist/src/components/accordion.d.ts +24 -0
- package/dist/src/components/accordion.js +50 -0
- package/dist/src/components/action-rail.d.ts +19 -0
- package/dist/src/components/action-rail.js +13 -0
- package/dist/src/components/add-button.js +1 -1
- package/dist/src/components/alert.d.ts +2 -0
- package/dist/src/components/alert.js +2 -1
- package/dist/src/components/app-bar.d.ts +17 -0
- package/dist/src/components/app-bar.js +10 -0
- package/dist/src/components/avatar.d.ts +22 -0
- package/dist/src/components/avatar.js +44 -0
- package/dist/src/components/breadcrumb.js +1 -1
- package/dist/src/components/checkbox.d.ts +6 -2
- package/dist/src/components/checkbox.js +36 -8
- package/dist/src/components/choice-group.d.ts +1 -0
- package/dist/src/components/choice-group.js +12 -17
- package/dist/src/components/choice-select.d.ts +3 -1
- package/dist/src/components/choice-select.js +56 -54
- package/dist/src/components/code-block.d.ts +3 -3
- package/dist/src/components/code-block.js +31 -27
- package/dist/src/components/context-menu.d.ts +16 -0
- package/dist/src/components/context-menu.js +49 -0
- package/dist/src/components/credential-source.js +12 -12
- package/dist/src/components/diff-block.js +1 -1
- package/dist/src/components/disclosure.d.ts +2 -2
- package/dist/src/components/disclosure.js +1 -1
- package/dist/src/components/hover-card.js +2 -2
- package/dist/src/components/image-lightbox.js +3 -3
- package/dist/src/components/image-preview.js +1 -1
- package/dist/src/components/index.d.ts +12 -0
- package/dist/src/components/index.js +12 -0
- package/dist/src/components/json-block.js +2 -2
- package/dist/src/components/json-tree.js +3 -3
- package/dist/src/components/link.d.ts +13 -0
- package/dist/src/components/link.js +9 -0
- package/dist/src/components/list-group.d.ts +1 -1
- package/dist/src/components/menu-button.d.ts +13 -0
- package/dist/src/components/menu-button.js +10 -0
- package/dist/src/components/menu.d.ts +4 -0
- package/dist/src/components/menu.js +3 -3
- package/dist/src/components/meta-row.d.ts +34 -0
- package/dist/src/components/meta-row.js +61 -0
- package/dist/src/components/nav-item.js +2 -5
- package/dist/src/components/number-input.d.ts +29 -0
- package/dist/src/components/number-input.js +137 -0
- package/dist/src/components/output-block.js +8 -15
- package/dist/src/components/page-frame.d.ts +6 -2
- package/dist/src/components/page-frame.js +2 -2
- package/dist/src/components/path-picker.js +9 -14
- package/dist/src/components/pill.js +2 -5
- package/dist/src/components/popover.js +4 -4
- package/dist/src/components/process-group.d.ts +2 -2
- package/dist/src/components/progress.d.ts +15 -0
- package/dist/src/components/progress.js +12 -0
- package/dist/src/components/rail-item.d.ts +2 -2
- package/dist/src/components/rail-section.d.ts +1 -1
- package/dist/src/components/read-block.js +2 -2
- package/dist/src/components/resource-card.d.ts +1 -1
- package/dist/src/components/resource-link.d.ts +1 -1
- package/dist/src/components/risk-confirmation.js +2 -5
- package/dist/src/components/search-block.js +2 -3
- package/dist/src/components/segmented-control.js +3 -3
- package/dist/src/components/skeleton-boundary.js +4 -7
- package/dist/src/components/slider.d.ts +22 -0
- package/dist/src/components/slider.js +49 -0
- package/dist/src/components/table.d.ts +41 -0
- package/dist/src/components/table.js +146 -0
- package/dist/src/components/tabs.d.ts +1 -1
- package/dist/src/components/tabs.js +11 -20
- package/dist/src/components/terminal-block.js +6 -6
- package/dist/src/components/text-shimmer.js +2 -5
- package/dist/src/components/web-block.js +3 -3
- package/dist/src/components/work-card.d.ts +2 -2
- package/dist/src/components/work-card.js +1 -1
- package/dist/src/icons/README.md +13 -2
- package/dist/src/icons/icon-frame.d.ts +11 -0
- package/dist/src/icons/icon-frame.js +4 -0
- package/dist/src/icons/icon-source.d.ts +17 -0
- package/dist/src/icons/icon-source.js +6 -0
- package/dist/src/icons/icon.d.ts +44 -37
- package/dist/src/icons/icon.js +55 -128
- package/dist/src/icons/index.d.ts +1 -0
- package/dist/src/icons/index.js +1 -0
- package/dist/src/icons/lucide.d.ts +1 -0
- package/dist/src/icons/lucide.js +4 -0
- package/dist/src/registry/index.d.ts +99 -5
- package/dist/src/registry/index.js +28 -3
- package/dist/src/shared/execution-state.js +7 -7
- package/dist/src/theme/chat/composer-panel.styles.d.ts +1 -0
- package/dist/src/theme/chat/composer-panel.styles.js +47 -0
- package/dist/src/theme/chat/composer.styles.js +69 -60
- package/dist/src/theme/chat/task.styles.js +5 -6
- package/dist/src/theme/components/accordion.styles.d.ts +1 -0
- package/dist/src/theme/components/accordion.styles.js +63 -0
- package/dist/src/theme/components/action-rail.styles.d.ts +1 -0
- package/dist/src/theme/components/action-rail.styles.js +47 -0
- package/dist/src/theme/components/alert.styles.js +42 -1
- package/dist/src/theme/components/app-bar.styles.d.ts +1 -0
- package/dist/src/theme/components/app-bar.styles.js +48 -0
- package/dist/src/theme/components/avatar.styles.d.ts +1 -0
- package/dist/src/theme/components/avatar.styles.js +52 -0
- package/dist/src/theme/components/button.styles.js +9 -0
- package/dist/src/theme/components/card.styles.js +2 -0
- package/dist/src/theme/components/code-block.styles.js +7 -0
- package/dist/src/theme/components/context-menu.styles.d.ts +1 -0
- package/dist/src/theme/components/context-menu.styles.js +14 -0
- package/dist/src/theme/components/dialog.styles.js +7 -0
- package/dist/src/theme/components/link.styles.d.ts +1 -0
- package/dist/src/theme/components/link.styles.js +33 -0
- package/dist/src/theme/components/list-group.styles.js +1 -0
- package/dist/src/theme/components/menu.styles.js +9 -3
- package/dist/src/theme/components/meta-row.styles.d.ts +1 -0
- package/dist/src/theme/components/meta-row.styles.js +66 -0
- package/dist/src/theme/components/number-input.styles.d.ts +1 -0
- package/dist/src/theme/components/number-input.styles.js +106 -0
- package/dist/src/theme/components/output-block.styles.js +9 -0
- package/dist/src/theme/components/page-frame.styles.js +7 -1
- package/dist/src/theme/components/page-header.styles.js +7 -0
- package/dist/src/theme/components/progress.styles.d.ts +1 -0
- package/dist/src/theme/components/progress.styles.js +71 -0
- package/dist/src/theme/components/resource-card.styles.js +7 -0
- package/dist/src/theme/components/slider.styles.d.ts +1 -0
- package/dist/src/theme/components/slider.styles.js +129 -0
- package/dist/src/theme/components/table.styles.d.ts +1 -0
- package/dist/src/theme/components/table.styles.js +156 -0
- package/dist/src/theme/components/tag.styles.js +3 -3
- package/dist/src/theme/components/toggle.styles.js +10 -0
- package/dist/src/theme/components/toolbar.styles.js +7 -0
- package/dist/src/theme/index.d.ts +15 -15
- package/dist/src/theme/index.js +24 -0
- package/dist/src/theme/palette.d.ts +1 -1
- package/dist/src/theme/palette.js +1 -1
- package/dist/src/theme/shared/code-highlight.tokens.d.ts +6 -6
- package/dist/src/theme/shared/code-highlight.tokens.js +6 -6
- package/dist/src/theme/tokens.d.ts +7 -7
- package/dist/src/theme/tokens.js +14 -8
- package/package.json +9 -4
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -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 =
|
|
21
|
-
const 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 =
|
|
26
|
-
const submitDisabled =
|
|
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
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
203
|
+
}), context.part("feedback", "p", { role: "status", hidden: derived(() => !feedback.value) }, feedback));
|
|
244
204
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { type
|
|
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
|
|
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:
|
|
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
|
-
|
|
28
|
-
|
|
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:
|
|
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:
|
|
40
|
-
summary:
|
|
41
|
-
state:
|
|
42
|
-
statusLabel:
|
|
43
|
-
input:
|
|
44
|
-
output:
|
|
45
|
-
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:
|
|
62
|
-
canCancel:
|
|
63
|
-
retryDisabled:
|
|
64
|
-
cancelDisabled:
|
|
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:
|
|
71
|
-
state:
|
|
72
|
-
statusLabel:
|
|
73
|
-
description:
|
|
74
|
-
executionText:
|
|
75
|
-
replyText:
|
|
76
|
-
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:
|
|
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:
|
|
85
|
-
status:
|
|
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:
|
|
79
|
+
steps: derived(() => value.value.steps),
|
|
89
80
|
}),
|
|
90
81
|
});
|
|
91
82
|
}
|
|
92
83
|
else if (initial.kind === "code") {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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 =
|
|
90
|
+
fallback = h(ChatAttachments, {
|
|
91
|
+
items: derived(() => value.value.items),
|
|
92
|
+
});
|
|
101
93
|
}
|
|
102
|
-
const content = custom ?
|
|
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 =
|
|
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,
|
|
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) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[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
|
-
|
|
29
|
-
|
|
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 =
|
|
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:
|
|
40
|
+
question: derived(() => value.value.title),
|
|
42
41
|
label: assistantCopy.questions,
|
|
43
|
-
description:
|
|
44
|
-
feedback:
|
|
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:
|
|
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:
|
|
60
|
+
children: [
|
|
62
61
|
h("option", { value: "" }, assistantCopy.answerPlaceholder),
|
|
63
|
-
|
|
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:
|
|
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:
|
|
87
|
+
disabled: derived(() => sending.value || value.value.state !== "open"),
|
|
89
88
|
onClick: () => onDismiss(value.value.id),
|
|
90
89
|
children: assistantCopy.dismiss,
|
|
91
90
|
})
|