@pyxis-llm/react 0.0.0-stage → 0.5.3
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/dist/AgentProfileEditor.d.ts +48 -0
- package/dist/AgentProfileEditor.d.ts.map +1 -0
- package/dist/AgentProfileEditor.js +122 -0
- package/dist/AgentProfileList.d.ts +17 -0
- package/dist/AgentProfileList.d.ts.map +1 -0
- package/dist/AgentProfileList.js +46 -0
- package/dist/AskCardAnswerChip.d.ts +8 -0
- package/dist/AskCardAnswerChip.d.ts.map +1 -0
- package/dist/AskCardAnswerChip.js +21 -0
- package/dist/AskCardView.d.ts +85 -0
- package/dist/AskCardView.d.ts.map +1 -0
- package/dist/AskCardView.js +158 -0
- package/dist/CatalogColumnBrowser.d.ts +33 -0
- package/dist/CatalogColumnBrowser.d.ts.map +1 -0
- package/dist/CatalogColumnBrowser.js +219 -0
- package/dist/CatalogModelPicker.d.ts +68 -0
- package/dist/CatalogModelPicker.d.ts.map +1 -0
- package/dist/CatalogModelPicker.js +119 -0
- package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
- package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
- package/dist/CatalogModelPickerMenuContent.js +103 -0
- package/dist/CatalogPickerMenuItem.d.ts +17 -0
- package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
- package/dist/CatalogPickerMenuItem.js +15 -0
- package/dist/CatalogTreePickerOptions.d.ts +52 -0
- package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
- package/dist/CatalogTreePickerOptions.js +248 -0
- package/dist/ChatMessage.d.ts +172 -0
- package/dist/ChatMessage.d.ts.map +1 -0
- package/dist/ChatMessage.js +295 -0
- package/dist/ChatPanel.d.ts +252 -0
- package/dist/ChatPanel.d.ts.map +1 -0
- package/dist/ChatPanel.js +247 -0
- package/dist/ChatTranscriptFind.d.ts +19 -0
- package/dist/ChatTranscriptFind.d.ts.map +1 -0
- package/dist/ChatTranscriptFind.js +224 -0
- package/dist/ChatTranscriptFindBar.d.ts +15 -0
- package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
- package/dist/ChatTranscriptFindBar.js +22 -0
- package/dist/Composer.d.ts +43 -0
- package/dist/Composer.d.ts.map +1 -0
- package/dist/Composer.js +45 -0
- package/dist/ComposerAttachments.d.ts +101 -0
- package/dist/ComposerAttachments.d.ts.map +1 -0
- package/dist/ComposerAttachments.js +126 -0
- package/dist/DisplayCards.d.ts +18 -0
- package/dist/DisplayCards.d.ts.map +1 -0
- package/dist/DisplayCards.js +72 -0
- package/dist/ErrorBoundary.d.ts +27 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +107 -0
- package/dist/ImageDisplayCard.d.ts +6 -0
- package/dist/ImageDisplayCard.d.ts.map +1 -0
- package/dist/ImageDisplayCard.js +57 -0
- package/dist/MarkdownCodeComponents.d.ts +23 -0
- package/dist/MarkdownCodeComponents.d.ts.map +1 -0
- package/dist/MarkdownCodeComponents.js +256 -0
- package/dist/MermaidDiagram.d.ts +18 -0
- package/dist/MermaidDiagram.d.ts.map +1 -0
- package/dist/MermaidDiagram.js +66 -0
- package/dist/MessageContentWithPastes.d.ts +14 -0
- package/dist/MessageContentWithPastes.d.ts.map +1 -0
- package/dist/MessageContentWithPastes.js +44 -0
- package/dist/PastePill.d.ts +16 -0
- package/dist/PastePill.d.ts.map +1 -0
- package/dist/PastePill.js +43 -0
- package/dist/ProviderAuthTerminal.d.ts +12 -0
- package/dist/ProviderAuthTerminal.d.ts.map +1 -0
- package/dist/ProviderAuthTerminal.js +50 -0
- package/dist/ProviderConnectForm.d.ts +62 -0
- package/dist/ProviderConnectForm.d.ts.map +1 -0
- package/dist/ProviderConnectForm.js +206 -0
- package/dist/ProviderList.d.ts +18 -0
- package/dist/ProviderList.d.ts.map +1 -0
- package/dist/ProviderList.js +67 -0
- package/dist/QueueStrip.d.ts +17 -0
- package/dist/QueueStrip.d.ts.map +1 -0
- package/dist/QueueStrip.js +60 -0
- package/dist/SettingsScreen.d.ts +10 -0
- package/dist/SettingsScreen.d.ts.map +1 -0
- package/dist/SettingsScreen.js +26 -0
- package/dist/StreamingMarkdown.d.ts +47 -0
- package/dist/StreamingMarkdown.d.ts.map +1 -0
- package/dist/StreamingMarkdown.js +103 -0
- package/dist/TurnTimer.d.ts +72 -0
- package/dist/TurnTimer.d.ts.map +1 -0
- package/dist/TurnTimer.js +114 -0
- package/dist/VegaChart.d.ts +36 -0
- package/dist/VegaChart.d.ts.map +1 -0
- package/dist/VegaChart.js +180 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +18 -0
- package/dist/catalogColumnBrowserTree.d.ts +9 -0
- package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
- package/dist/catalogColumnBrowserTree.js +48 -0
- package/dist/catalogPickerMenuStyles.d.ts +81 -0
- package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
- package/dist/catalogPickerMenuStyles.js +130 -0
- package/dist/charts.d.ts +12 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +45 -0
- package/dist/chatMessageScroll.d.ts +40 -0
- package/dist/chatMessageScroll.d.ts.map +1 -0
- package/dist/chatMessageScroll.js +62 -0
- package/dist/chatModelOptions.d.ts +28 -0
- package/dist/chatModelOptions.d.ts.map +1 -0
- package/dist/chatModelOptions.js +59 -0
- package/dist/chatTranscriptFindHighlights.d.ts +9 -0
- package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
- package/dist/chatTranscriptFindHighlights.js +88 -0
- package/dist/draftStore.d.ts +13 -0
- package/dist/draftStore.d.ts.map +1 -0
- package/dist/draftStore.js +38 -0
- package/dist/highlight.d.ts +4 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +47 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/keyboardShortcuts.d.ts +5 -0
- package/dist/keyboardShortcuts.d.ts.map +1 -0
- package/dist/keyboardShortcuts.js +19 -0
- package/dist/markdownClipboard.d.ts +22 -0
- package/dist/markdownClipboard.d.ts.map +1 -0
- package/dist/markdownClipboard.js +98 -0
- package/dist/markdownPlugins.d.ts +31 -0
- package/dist/markdownPlugins.d.ts.map +1 -0
- package/dist/markdownPlugins.js +32 -0
- package/dist/mermaid.d.ts +17 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +11 -0
- package/dist/mermaidRuntime.d.ts +21 -0
- package/dist/mermaidRuntime.d.ts.map +1 -0
- package/dist/mermaidRuntime.js +140 -0
- package/dist/modelCatalogHelpers.d.ts +14 -0
- package/dist/modelCatalogHelpers.d.ts.map +1 -0
- package/dist/modelCatalogHelpers.js +65 -0
- package/dist/modelCatalogSource.d.ts +22 -0
- package/dist/modelCatalogSource.d.ts.map +1 -0
- package/dist/modelCatalogSource.js +26 -0
- package/dist/modelCatalogTree.d.ts +24 -0
- package/dist/modelCatalogTree.d.ts.map +1 -0
- package/dist/modelCatalogTree.js +77 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +13 -0
- package/dist/pasteFences.d.ts +20 -0
- package/dist/pasteFences.d.ts.map +1 -0
- package/dist/pasteFences.js +157 -0
- package/dist/pasteFormat.d.ts +5 -0
- package/dist/pasteFormat.d.ts.map +1 -0
- package/dist/pasteFormat.js +18 -0
- package/dist/plugins.d.ts +110 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +98 -0
- package/dist/remarkAlerts.d.ts +12 -0
- package/dist/remarkAlerts.d.ts.map +1 -0
- package/dist/remarkAlerts.js +52 -0
- package/dist/sendMode.d.ts +69 -0
- package/dist/sendMode.d.ts.map +1 -0
- package/dist/sendMode.js +66 -0
- package/dist/useLlmdChatDriver.d.ts +367 -0
- package/dist/useLlmdChatDriver.d.ts.map +1 -0
- package/dist/useLlmdChatDriver.js +1739 -0
- package/dist/useLlmdModelCatalog.d.ts +23 -0
- package/dist/useLlmdModelCatalog.d.ts.map +1 -0
- package/dist/useLlmdModelCatalog.js +89 -0
- package/dist/useLlmdSessionModel.d.ts +34 -0
- package/dist/useLlmdSessionModel.d.ts.map +1 -0
- package/dist/useLlmdSessionModel.js +79 -0
- package/dist/useProviderAuthCommand.d.ts +26 -0
- package/dist/useProviderAuthCommand.d.ts.map +1 -0
- package/dist/useProviderAuthCommand.js +80 -0
- package/dist/vegaRuntime.d.ts +83 -0
- package/dist/vegaRuntime.d.ts.map +1 -0
- package/dist/vegaRuntime.js +314 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
- package/dist/vendor/llmd-types/conversationEvents.js +98 -0
- package/dist/vendor/llmd-types/index.d.ts +4 -0
- package/dist/vendor/llmd-types/index.d.ts.map +1 -0
- package/dist/vendor/llmd-types/index.js +5 -0
- package/dist/vendor/llmd-types/messages.d.ts +67 -0
- package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
- package/dist/vendor/llmd-types/messages.js +71 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
- package/dist/vendor/llmd-types/sessionQueue.js +40 -0
- package/package.json +120 -4
- package/styles.css +389 -0
- package/README.md +0 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { LlmdAgentProfile, LlmdAgentProfileSpec } from '@pyxis-llm/client';
|
|
2
|
+
import type { ChatModelOption } from './chatModelOptions.js';
|
|
3
|
+
/** Numeric values of llm.v1.ToolPolicy (kept local so no runtime client import is needed). */
|
|
4
|
+
export declare const AGENT_TOOL_POLICY: {
|
|
5
|
+
readonly UNSPECIFIED: 0;
|
|
6
|
+
readonly INHERIT_SERVER_WIDE: 1;
|
|
7
|
+
readonly PROFILE_ONLY: 2;
|
|
8
|
+
};
|
|
9
|
+
/** Id of the system prompt section the editor's Instructions box reads and writes. */
|
|
10
|
+
export declare const INSTRUCTIONS_SECTION_ID = "agent.instructions";
|
|
11
|
+
/**
|
|
12
|
+
* Reserved by llmd for the section it builds from the profile's name and
|
|
13
|
+
* description (internal/agentprofile.IdentitySectionID); profiles may not use it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const IDENTITY_SECTION_ID = "agent.identity";
|
|
16
|
+
type SectionDraft = {
|
|
17
|
+
id: string;
|
|
18
|
+
content: string;
|
|
19
|
+
tags: string[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The sections to save: instructions first (when set), then the additional
|
|
23
|
+
* sections with fully empty rows dropped. Returns an error message instead
|
|
24
|
+
* when an additional section would be refused or silently lost.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildProfileSections(instructions: string, additional: SectionDraft[]): {
|
|
27
|
+
sections: SectionDraft[];
|
|
28
|
+
} | {
|
|
29
|
+
error: string;
|
|
30
|
+
};
|
|
31
|
+
/** A tool the profile can map (e.g. from `ListTools`). */
|
|
32
|
+
export type AgentProfileToolOption = {
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
};
|
|
36
|
+
export type AgentProfileEditorProps = {
|
|
37
|
+
/** The profile to edit; omit to create a new one. */
|
|
38
|
+
profile?: LlmdAgentProfile;
|
|
39
|
+
tools: AgentProfileToolOption[];
|
|
40
|
+
modelOptions: ChatModelOption[];
|
|
41
|
+
modelsLoading?: boolean;
|
|
42
|
+
/** Persist the spec (create when `profile` is absent, otherwise update). */
|
|
43
|
+
onSave: (spec: LlmdAgentProfileSpec, profile?: LlmdAgentProfile) => Promise<void> | void;
|
|
44
|
+
onCancel?: () => void;
|
|
45
|
+
};
|
|
46
|
+
export declare function AgentProfileEditor({ profile, tools, modelOptions, modelsLoading, onSave, onCancel, }: AgentProfileEditorProps): import("react").JSX.Element;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=AgentProfileEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentProfileEditor.d.ts","sourceRoot":"","sources":["../src/AgentProfileEditor.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,8FAA8F;AAC9F,eAAO,MAAM,iBAAiB;;;;CAAuE,CAAC;AAEtG,sFAAsF;AACtF,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,KAAK,YAAY,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,YAAY,EAAE,GACzB;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAclD;AAED,0DAA0D;AAC1D,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,uBAAuB,GAAG;IACpC,qDAAqD;IACrD,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,MAAM,EAAE,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACzF,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAIF,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,QAAQ,GACT,EAAE,uBAAuB,+BAsQzB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Edits one agent profile: name, description, instructions, any additional
|
|
7
|
+
* system prompt sections, provider + model (catalog picker), memory, tool
|
|
8
|
+
* mapping and tool policy. Name and description reach the model too: llmd puts
|
|
9
|
+
* them in the identity section of every session created from the profile.
|
|
10
|
+
* Instructions are the section with id INSTRUCTIONS_SECTION_ID.
|
|
11
|
+
* Static (code-defined) profiles render read-only. Transport-agnostic: the
|
|
12
|
+
* host supplies the available tools (ListTools), the model options and the
|
|
13
|
+
* save callback.
|
|
14
|
+
*/
|
|
15
|
+
import { useState } from 'react';
|
|
16
|
+
import { Alert, Button, Checkbox, Collapse, Group, NativeSelect, Paper, Stack, Switch, Text, Textarea, TextInput, } from '@mantine/core';
|
|
17
|
+
import { CatalogModelPicker } from './CatalogModelPicker.js';
|
|
18
|
+
/** Numeric values of llm.v1.ToolPolicy (kept local so no runtime client import is needed). */
|
|
19
|
+
export const AGENT_TOOL_POLICY = { UNSPECIFIED: 0, INHERIT_SERVER_WIDE: 1, PROFILE_ONLY: 2 };
|
|
20
|
+
/** Id of the system prompt section the editor's Instructions box reads and writes. */
|
|
21
|
+
export const INSTRUCTIONS_SECTION_ID = 'agent.instructions';
|
|
22
|
+
/**
|
|
23
|
+
* Reserved by llmd for the section it builds from the profile's name and
|
|
24
|
+
* description (internal/agentprofile.IdentitySectionID); profiles may not use it.
|
|
25
|
+
*/
|
|
26
|
+
export const IDENTITY_SECTION_ID = 'agent.identity';
|
|
27
|
+
/**
|
|
28
|
+
* The sections to save: instructions first (when set), then the additional
|
|
29
|
+
* sections with fully empty rows dropped. Returns an error message instead
|
|
30
|
+
* when an additional section would be refused or silently lost.
|
|
31
|
+
*/
|
|
32
|
+
export function buildProfileSections(instructions, additional) {
|
|
33
|
+
const out = [];
|
|
34
|
+
if (instructions.trim())
|
|
35
|
+
out.push({ id: INSTRUCTIONS_SECTION_ID, content: instructions, tags: [] });
|
|
36
|
+
for (const [i, s] of additional.entries()) {
|
|
37
|
+
const id = s.id.trim();
|
|
38
|
+
const hasContent = s.content.trim() !== '';
|
|
39
|
+
if (!id && !hasContent)
|
|
40
|
+
continue;
|
|
41
|
+
if (!id)
|
|
42
|
+
return { error: `Additional section ${i + 1} needs an id.` };
|
|
43
|
+
if (id === INSTRUCTIONS_SECTION_ID || id === IDENTITY_SECTION_ID) {
|
|
44
|
+
return { error: `Additional section ${i + 1}: the id "${id}" is reserved.` };
|
|
45
|
+
}
|
|
46
|
+
out.push({ ...s, id });
|
|
47
|
+
}
|
|
48
|
+
return { sections: out };
|
|
49
|
+
}
|
|
50
|
+
export function AgentProfileEditor({ profile, tools, modelOptions, modelsLoading, onSave, onCancel, }) {
|
|
51
|
+
const readOnly = profile?.isStatic === true;
|
|
52
|
+
const [name, setName] = useState(profile?.name ?? '');
|
|
53
|
+
const [description, setDescription] = useState(profile?.description ?? '');
|
|
54
|
+
const initialSections = profile?.systemPromptSections ?? [];
|
|
55
|
+
const [instructions, setInstructions] = useState(() => initialSections.find((s) => s.id === INSTRUCTIONS_SECTION_ID)?.content ?? '');
|
|
56
|
+
const [sections, setSections] = useState(() => initialSections
|
|
57
|
+
.filter((s) => s.id !== INSTRUCTIONS_SECTION_ID)
|
|
58
|
+
.map((s) => ({ ...s, tags: [...(s.tags ?? [])] })));
|
|
59
|
+
const [showAdditional, setShowAdditional] = useState(false);
|
|
60
|
+
const [providerId, setProviderId] = useState(profile?.llmProviderId || null);
|
|
61
|
+
const [modelId, setModelId] = useState(profile?.defaultModel || null);
|
|
62
|
+
const [memory, setMemory] = useState(profile?.memoryEnabled === true);
|
|
63
|
+
const [policy, setPolicy] = useState(profile?.toolPolicy ?? 0);
|
|
64
|
+
const [mapping, setMapping] = useState(() => Object.fromEntries((profile?.toolMapping ?? []).map((m) => [m.toolName, m.enabled])));
|
|
65
|
+
const [busy, setBusy] = useState(false);
|
|
66
|
+
const [error, setError] = useState(null);
|
|
67
|
+
const toolState = (n) => n in mapping ? (mapping[n] ? 'enabled' : 'disabled') : 'default';
|
|
68
|
+
const setToolState = (n, s) => setMapping((prev) => {
|
|
69
|
+
const next = { ...prev };
|
|
70
|
+
if (s === 'default')
|
|
71
|
+
delete next[n];
|
|
72
|
+
else
|
|
73
|
+
next[n] = s === 'enabled';
|
|
74
|
+
return next;
|
|
75
|
+
});
|
|
76
|
+
const updateSection = (i, patch) => setSections((prev) => prev.map((s, j) => (j === i ? { ...s, ...patch } : s)));
|
|
77
|
+
const submit = async () => {
|
|
78
|
+
if (readOnly || !name.trim())
|
|
79
|
+
return;
|
|
80
|
+
const built = buildProfileSections(instructions, sections);
|
|
81
|
+
if ('error' in built) {
|
|
82
|
+
setError(new Error(built.error));
|
|
83
|
+
setShowAdditional(true);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setBusy(true);
|
|
87
|
+
setError(null);
|
|
88
|
+
try {
|
|
89
|
+
await onSave({
|
|
90
|
+
name: name.trim(),
|
|
91
|
+
description,
|
|
92
|
+
systemPromptSections: built.sections,
|
|
93
|
+
...(providerId ? { llmProviderId: providerId } : {}),
|
|
94
|
+
...(modelId ? { defaultModel: modelId } : {}),
|
|
95
|
+
memoryEnabled: memory,
|
|
96
|
+
toolMapping: Object.entries(mapping).map(([toolName, enabled]) => ({ toolName, enabled })),
|
|
97
|
+
toolPolicy: policy,
|
|
98
|
+
}, profile);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
setBusy(false);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return (_jsxs(Stack, { gap: "sm", "data-testid": "agent-profile-editor", children: [readOnly ? (_jsx(Alert, { color: "gray", children: "This profile is defined in code and is read-only." })) : null, error ? (_jsx(Alert, { color: "red", title: "Save failed", children: error.message })) : null, _jsx(TextInput, { label: "Name", value: name, disabled: readOnly, onChange: (e) => setName(e.currentTarget.value) }), _jsx(Textarea, { label: "Description", description: "Shown in lists, and sent to the agent as a description of itself.", value: description, disabled: readOnly, onChange: (e) => setDescription(e.currentTarget.value) }), _jsx(Textarea, { label: "Instructions", description: "What the agent does and how it should behave. Sent as its system prompt.", autosize: true, minRows: 6, value: instructions, disabled: readOnly, onChange: (e) => setInstructions(e.currentTarget.value) }), _jsxs(Stack, { gap: "xs", children: [_jsx(Group, { children: _jsxs(Button, { size: "xs", variant: "subtle", "aria-expanded": showAdditional, onClick: () => setShowAdditional((v) => !v), children: [showAdditional ? 'Hide' : 'Show', " additional sections (", sections.length, ")"] }) }), _jsx(Collapse, { in: showAdditional, children: _jsxs(Stack, { gap: "xs", children: [sections.map((s, i) => (_jsx(Paper, { withBorder: true, p: "xs", "data-testid": `section-${i}`, children: _jsxs(Stack, { gap: "xs", children: [_jsx(TextInput, { label: "Section id", value: s.id, disabled: readOnly, onChange: (e) => updateSection(i, { id: e.currentTarget.value }) }), _jsx(Textarea, { label: "Section content", autosize: true, minRows: 2, value: s.content, disabled: readOnly, onChange: (e) => updateSection(i, { content: e.currentTarget.value }) }), readOnly ? null : (_jsx(Button, { size: "xs", variant: "subtle", color: "red", onClick: () => setSections((prev) => prev.filter((_, j) => j !== i)), children: "Remove section" }))] }) }, i))), readOnly ? null : (_jsx(Group, { children: _jsx(Button, { size: "xs", variant: "default", onClick: () => setSections((prev) => [...prev, { id: '', content: '', tags: [] }]), children: "Add section" }) }))] }) })] }), _jsxs(Stack, { gap: 4, children: [_jsx(Text, { fw: 600, children: "Provider and model" }), readOnly ? (_jsx(Text, { size: "sm", children: providerId && modelId ? `${providerId}: ${modelId}` : 'Not pinned' })) : (_jsx(CatalogModelPicker, { options: modelOptions, loading: modelsLoading, selectedProviderId: providerId, selectedModelId: modelId, emptyLabel: "Server default", tooltip: "Model for sessions created from this profile", onSelect: (p, m) => {
|
|
108
|
+
setProviderId(p);
|
|
109
|
+
setModelId(m);
|
|
110
|
+
} })), !readOnly && providerId ? (_jsx(Group, { children: _jsx(Button, { size: "xs", variant: "subtle", onClick: () => {
|
|
111
|
+
setProviderId(null);
|
|
112
|
+
setModelId(null);
|
|
113
|
+
}, children: "Clear model" }) })) : null] }), _jsx(Switch, { label: "Memory enabled", checked: memory, disabled: readOnly, onChange: (e) => setMemory(e.currentTarget.checked) }), _jsx(NativeSelect, { label: "Tool policy", value: String(policy), disabled: readOnly, onChange: (e) => setPolicy(Number(e.currentTarget.value)), data: [
|
|
114
|
+
{ value: String(AGENT_TOOL_POLICY.UNSPECIFIED), label: 'Server default' },
|
|
115
|
+
{ value: String(AGENT_TOOL_POLICY.INHERIT_SERVER_WIDE), label: 'Inherit server-wide tools' },
|
|
116
|
+
{ value: String(AGENT_TOOL_POLICY.PROFILE_ONLY), label: 'Profile tools only' },
|
|
117
|
+
] }), _jsxs(Stack, { gap: 4, children: [_jsx(Text, { fw: 600, children: "Tool mapping" }), tools.length === 0 ? (_jsx(Text, { size: "sm", c: "dimmed", children: "No tools available." })) : null, tools.map((t) => (_jsxs(Group, { justify: "space-between", wrap: "nowrap", children: [_jsx(Checkbox, { readOnly: true, checked: toolState(t.name) === 'enabled', indeterminate: toolState(t.name) === 'default', label: t.name, description: t.description, disabled: readOnly, onChange: () => undefined }), _jsx(NativeSelect, { "aria-label": `Tool ${t.name}`, value: toolState(t.name), disabled: readOnly, onChange: (e) => setToolState(t.name, e.currentTarget.value), data: [
|
|
118
|
+
{ value: 'default', label: 'Default' },
|
|
119
|
+
{ value: 'enabled', label: 'Enabled' },
|
|
120
|
+
{ value: 'disabled', label: 'Disabled' },
|
|
121
|
+
] })] }, t.name)))] }), _jsxs(Group, { children: [readOnly ? null : (_jsx(Button, { disabled: busy || !name.trim(), onClick: () => void submit(), children: "Save" })), onCancel ? (_jsx(Button, { variant: "default", onClick: onCancel, children: readOnly ? 'Close' : 'Cancel' })) : null] })] }));
|
|
122
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LlmdAgentProfile, LlmdAgentProfileSpec } from '@pyxis-llm/client';
|
|
2
|
+
import { type AgentProfileToolOption } from './AgentProfileEditor.js';
|
|
3
|
+
import type { ChatModelOption } from './chatModelOptions.js';
|
|
4
|
+
export type AgentProfileListProps = {
|
|
5
|
+
profiles: LlmdAgentProfile[];
|
|
6
|
+
tools: AgentProfileToolOption[];
|
|
7
|
+
modelOptions: ChatModelOption[];
|
|
8
|
+
modelsLoading?: boolean;
|
|
9
|
+
/** e.g. `createLlmdAgentProfile`. */
|
|
10
|
+
onCreate: (spec: LlmdAgentProfileSpec) => Promise<void> | void;
|
|
11
|
+
/** e.g. `updateLlmdAgentProfile`. */
|
|
12
|
+
onUpdate: (id: string, spec: LlmdAgentProfileSpec) => Promise<void> | void;
|
|
13
|
+
/** e.g. `deleteLlmdAgentProfile`. */
|
|
14
|
+
onDelete: (id: string) => Promise<void> | void;
|
|
15
|
+
};
|
|
16
|
+
export declare function AgentProfileList({ profiles, tools, modelOptions, modelsLoading, onCreate, onUpdate, onDelete, }: AgentProfileListProps): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=AgentProfileList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentProfileList.d.ts","sourceRoot":"","sources":["../src/AgentProfileList.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAsB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qCAAqC;IACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/D,qCAAqC;IACrC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3E,qCAAqC;IACrC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChD,CAAC;AAIF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE,qBAAqB,+BAqGvB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Lists agent profiles with create / edit / delete flows built on
|
|
7
|
+
* AgentProfileEditor. Static profiles open read-only and cannot be deleted.
|
|
8
|
+
* Transport-agnostic: the host wires callbacks to its @pyxis-llm/client calls.
|
|
9
|
+
*/
|
|
10
|
+
import { useState } from 'react';
|
|
11
|
+
import { Alert, Badge, Button, Group, Paper, Stack, Text } from '@mantine/core';
|
|
12
|
+
import { AgentProfileEditor } from './AgentProfileEditor.js';
|
|
13
|
+
export function AgentProfileList({ profiles, tools, modelOptions, modelsLoading, onCreate, onUpdate, onDelete, }) {
|
|
14
|
+
const [editing, setEditing] = useState(null);
|
|
15
|
+
const [busy, setBusy] = useState(false);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const remove = async (id) => {
|
|
18
|
+
setBusy(true);
|
|
19
|
+
setError(null);
|
|
20
|
+
try {
|
|
21
|
+
await onDelete(id);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
setError(e instanceof Error ? e : new Error(String(e)));
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
setBusy(false);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const save = async (spec) => {
|
|
31
|
+
if (!editing)
|
|
32
|
+
return;
|
|
33
|
+
if (editing.mode === 'create')
|
|
34
|
+
await onCreate(spec);
|
|
35
|
+
else
|
|
36
|
+
await onUpdate(editing.profile.id, spec);
|
|
37
|
+
setEditing(null);
|
|
38
|
+
};
|
|
39
|
+
if (editing) {
|
|
40
|
+
return (_jsx(AgentProfileEditor, { profile: editing.mode === 'edit' ? editing.profile : undefined, tools: tools, modelOptions: modelOptions, modelsLoading: modelsLoading, onSave: save, onCancel: () => setEditing(null) }, editing.mode === 'edit' ? editing.profile.id : 'new'));
|
|
41
|
+
}
|
|
42
|
+
return (_jsxs(Stack, { gap: "sm", children: [error ? (_jsx(Alert, { color: "red", title: "Profile action failed", children: error.message })) : null, profiles.length === 0 ? _jsx(Text, { c: "dimmed", children: "No agent profiles." }) : null, profiles.map((p) => (_jsx(Paper, { withBorder: true, p: "sm", "data-testid": `agent-profile-${p.id}`, children: _jsxs(Group, { justify: "space-between", children: [_jsxs(Stack, { gap: 0, children: [_jsxs(Group, { gap: "xs", children: [_jsx(Text, { fw: 600, children: p.name }), p.isStatic ? (_jsx(Badge, { variant: "light", color: "gray", children: "static" })) : null] }), p.description ? (_jsx(Text, { size: "sm", c: "dimmed", children: p.description })) : null] }), _jsxs(Group, { gap: "xs", children: [_jsx(Button, { size: "xs", variant: "subtle", "aria-label": `${p.isStatic ? 'View' : 'Edit'} ${p.name}`, onClick: () => setEditing({ mode: 'edit', profile: p }), children: p.isStatic ? 'View' : 'Edit' }), p.isStatic ? null : (_jsx(Button, { size: "xs", variant: "subtle", color: "red", disabled: busy, "aria-label": `Delete ${p.name}`, onClick: () => void remove(p.id), children: "Delete" }))] })] }) }, p.id))), _jsx(Group, { children: _jsx(Button, { onClick: () => {
|
|
43
|
+
setError(null);
|
|
44
|
+
setEditing({ mode: 'create' });
|
|
45
|
+
}, children: "New profile" }) })] }));
|
|
46
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AskCard, AskCardResponse } from '@pyxis-llm/core';
|
|
2
|
+
export type AskCardAnswerChipProps = {
|
|
3
|
+
/** The card answered (when still in the index); the chip degrades to the answer alone without it. */
|
|
4
|
+
card?: AskCard;
|
|
5
|
+
response: AskCardResponse;
|
|
6
|
+
};
|
|
7
|
+
export declare function AskCardAnswerChip({ card, response }: AskCardAnswerChipProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=AskCardAnswerChip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskCardAnswerChip.d.ts","sourceRoot":"","sources":["../src/AskCardAnswerChip.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhE,MAAM,MAAM,sBAAsB,GAAG;IACnC,qGAAqG;IACrG,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,sBAAsB,+BA6C3E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The trace an answered ask card leaves in the transcript: a small chip on the
|
|
8
|
+
* "Answer to: …" user message, naming the question; click it to see the
|
|
9
|
+
* question and the answer that was sent. The card itself stops rendering once
|
|
10
|
+
* answered (see @pyxis-llm/core's appendAnchorlessCardMessages) — it is a prompt,
|
|
11
|
+
* not content, and re-showing it under every new message was the bug.
|
|
12
|
+
*/
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { Badge, Popover, Stack, Text } from '@mantine/core';
|
|
15
|
+
import { IconMessageQuestion } from '@tabler/icons-react';
|
|
16
|
+
import { answerSummary } from './AskCardView.js';
|
|
17
|
+
export function AskCardAnswerChip({ card, response }) {
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const title = card?.title?.trim() || 'Question';
|
|
20
|
+
return (_jsxs(Popover, { opened: open, onChange: setOpen, position: "bottom-start", withArrow: true, shadow: "md", width: 320, children: [_jsx(Popover.Target, { children: _jsx(Badge, { component: "button", type: "button", variant: "light", color: "gray", radius: "sm", size: "sm", leftSection: _jsx(IconMessageQuestion, { size: 12, stroke: 1.75 }), onClick: () => setOpen((v) => !v), style: { cursor: 'pointer', textTransform: 'none', fontWeight: 500 }, className: "ask-card-chip", "aria-label": `Answered question: ${title}`, "data-testid": `ask-card-chip-${response.cardId}`, children: title }) }), _jsx(Popover.Dropdown, { children: _jsxs(Stack, { gap: 4, "data-testid": `ask-card-chip-detail-${response.cardId}`, children: [_jsx(Text, { fw: 600, size: "sm", children: title }), card?.text && (_jsx(Text, { size: "sm", c: "dimmed", children: card.text })), _jsx(Text, { size: "sm", fw: 500, children: answerSummary(response) }), response.type !== 'text' && response.additionalText?.trim() && (_jsx(Text, { size: "sm", c: "dimmed", children: response.additionalText }))] }) })] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in renderer for llmd's first-class AskCard/AskCardResponse
|
|
3
|
+
* conversational primitive. Unlike host-defined attachment kinds (which
|
|
4
|
+
* always go through `renderAttachmentCard`), ask cards are rendered by
|
|
5
|
+
* @pyxis-llm/react automatically — the whole point of making them first-class
|
|
6
|
+
* llmd vocabulary is that a host never has to re-implement this UI.
|
|
7
|
+
*
|
|
8
|
+
* Two render modes, chosen purely by whether a response is present:
|
|
9
|
+
* - Unanswered: an interactive form (choice/text/file) with two submit
|
|
10
|
+
* buttons: "Answer & continue" (primary; the agent's next turn may run
|
|
11
|
+
* tools) and "Answer & stop" (the agent replies without running tools).
|
|
12
|
+
* - Answered: a read-only summary of what was submitted.
|
|
13
|
+
*
|
|
14
|
+
* `onSubmit` is host-supplied because ANSWERING requires persisting the
|
|
15
|
+
* response (an UpsertSessionAttachment call) — this component only builds
|
|
16
|
+
* the typed AskCardResponse and hands it off; it never talks to llmd itself.
|
|
17
|
+
*/
|
|
18
|
+
import { Component, type ErrorInfo, type ReactNode } from 'react';
|
|
19
|
+
import type { AskCard, AskCardResponse } from '@pyxis-llm/core';
|
|
20
|
+
/**
|
|
21
|
+
* How the agent should proceed after an ask-card answer. Passed alongside the
|
|
22
|
+
* response by `AskCardView` and threaded to llmd's AnswerAskCard.
|
|
23
|
+
*/
|
|
24
|
+
export type AskCardSubmitOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* true ("Answer & continue"): the answer's turn may run tools, so the agent
|
|
27
|
+
* carries on working. false ("Answer & stop"): it replies without tools.
|
|
28
|
+
*/
|
|
29
|
+
continueWithTools: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type AskCardViewProps = {
|
|
32
|
+
card: AskCard;
|
|
33
|
+
/** The persisted response, if this card has already been answered. */
|
|
34
|
+
response?: AskCardResponse | null;
|
|
35
|
+
/** Called with the built response when the user submits. Omit to render read-only. */
|
|
36
|
+
onSubmit?: (response: AskCardResponse, options: AskCardSubmitOptions) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Dismisses the card as though it was never asked (shown as an ✕ on an
|
|
39
|
+
* unanswered card). Omit to hide the ✕.
|
|
40
|
+
*/
|
|
41
|
+
onDismiss?: () => void;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** The ✕ that dismisses an ask card. Shared by the card and its fallbacks. */
|
|
45
|
+
export declare function AskCardDismissButton({ cardId, onDismiss }: {
|
|
46
|
+
cardId: string;
|
|
47
|
+
onDismiss: () => void;
|
|
48
|
+
}): import("react").JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* A muted one-liner for a card that cannot be shown (undecodable payload, or
|
|
51
|
+
* it crashed while rendering), with the ✕ when dismissing is wired, so a
|
|
52
|
+
* broken card can still be cleared away.
|
|
53
|
+
*/
|
|
54
|
+
export declare function AskCardUnavailable({ cardId, label, onDismiss, }: {
|
|
55
|
+
cardId: string;
|
|
56
|
+
label: string;
|
|
57
|
+
onDismiss?: () => void;
|
|
58
|
+
}): import("react").JSX.Element;
|
|
59
|
+
type AskCardErrorBoundaryProps = {
|
|
60
|
+
cardId: string;
|
|
61
|
+
onDismiss?: () => void;
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Keeps one broken card from taking down the whole transcript: if the card
|
|
66
|
+
* throws while rendering, it is replaced by a dismissable "failed to render"
|
|
67
|
+
* line and the rest of the chat carries on.
|
|
68
|
+
*/
|
|
69
|
+
export declare class AskCardErrorBoundary extends Component<AskCardErrorBoundaryProps, {
|
|
70
|
+
failed: boolean;
|
|
71
|
+
}> {
|
|
72
|
+
state: {
|
|
73
|
+
failed: boolean;
|
|
74
|
+
};
|
|
75
|
+
static getDerivedStateFromError(): {
|
|
76
|
+
failed: boolean;
|
|
77
|
+
};
|
|
78
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
79
|
+
render(): ReactNode;
|
|
80
|
+
}
|
|
81
|
+
/** One-line, human-readable summary of an answer ("Selected: A", "Uploaded: f.pdf", or the text). */
|
|
82
|
+
export declare function answerSummary(response: AskCardResponse): string;
|
|
83
|
+
export declare function AskCardView({ card, response, onSubmit, onDismiss, disabled }: AskCardViewProps): import("react").JSX.Element;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=AskCardView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskCardView.d.ts","sourceRoot":"","sources":["../src/AskCardView.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAY5E,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAiCjF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,sEAAsE;IACtE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC9E;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,IAAI,CAAA;CAAE,+BAUpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,KAAK,EACL,SAAS,GACV,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,+BASA;AAED,KAAK,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAC;AAEjG;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CAAC,yBAAyB,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;IACjG,KAAK;;MAAqB;IAE1B,MAAM,CAAC,wBAAwB,IAAI;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE;IAItD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAKtD,MAAM,IAAI,SAAS;CAYpB;AAqBD,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAU/D;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,+BAqL9F"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Built-in renderer for llmd's first-class AskCard/AskCardResponse
|
|
8
|
+
* conversational primitive. Unlike host-defined attachment kinds (which
|
|
9
|
+
* always go through `renderAttachmentCard`), ask cards are rendered by
|
|
10
|
+
* @pyxis-llm/react automatically — the whole point of making them first-class
|
|
11
|
+
* llmd vocabulary is that a host never has to re-implement this UI.
|
|
12
|
+
*
|
|
13
|
+
* Two render modes, chosen purely by whether a response is present:
|
|
14
|
+
* - Unanswered: an interactive form (choice/text/file) with two submit
|
|
15
|
+
* buttons: "Answer & continue" (primary; the agent's next turn may run
|
|
16
|
+
* tools) and "Answer & stop" (the agent replies without running tools).
|
|
17
|
+
* - Answered: a read-only summary of what was submitted.
|
|
18
|
+
*
|
|
19
|
+
* `onSubmit` is host-supplied because ANSWERING requires persisting the
|
|
20
|
+
* response (an UpsertSessionAttachment call) — this component only builds
|
|
21
|
+
* the typed AskCardResponse and hands it off; it never talks to llmd itself.
|
|
22
|
+
*/
|
|
23
|
+
import { Component, useState } from 'react';
|
|
24
|
+
import { Button, Checkbox, CloseButton, FileInput, Group, Radio, Stack, Text, Textarea, } from '@mantine/core';
|
|
25
|
+
/**
|
|
26
|
+
* The explanation under one choice: its one-line description, then (for the
|
|
27
|
+
* recommended option) the reason it is recommended, so neither has to be dug
|
|
28
|
+
* out of the card's text. Spans, not divs: Mantine renders `description`
|
|
29
|
+
* inside a <p>.
|
|
30
|
+
*/
|
|
31
|
+
function optionExplanation(cardId, option) {
|
|
32
|
+
if (!option || (!option.description && !option.recommendation))
|
|
33
|
+
return undefined;
|
|
34
|
+
return (_jsxs(_Fragment, { children: [option.description && (_jsx("span", { style: { display: 'block' }, "data-testid": `ask-card-${cardId}-desc-${option.label}`, children: option.description })), option.recommendation && (_jsxs(Text, { component: "span", size: "xs", fw: 500, c: "teal", style: { display: 'block' }, "data-testid": `ask-card-${cardId}-rec-${option.label}`, children: ["\u2605 Recommended: ", option.recommendation] }))] }));
|
|
35
|
+
}
|
|
36
|
+
/** The ✕ that dismisses an ask card. Shared by the card and its fallbacks. */
|
|
37
|
+
export function AskCardDismissButton({ cardId, onDismiss }) {
|
|
38
|
+
return (_jsx(CloseButton, { size: "sm", onClick: onDismiss, title: "Dismiss this question", "aria-label": "Dismiss this question", "data-testid": `ask-card-${cardId}-dismiss` }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A muted one-liner for a card that cannot be shown (undecodable payload, or
|
|
42
|
+
* it crashed while rendering), with the ✕ when dismissing is wired, so a
|
|
43
|
+
* broken card can still be cleared away.
|
|
44
|
+
*/
|
|
45
|
+
export function AskCardUnavailable({ cardId, label, onDismiss, }) {
|
|
46
|
+
return (_jsxs(Group, { gap: 4, wrap: "nowrap", "data-testid": `ask-card-${cardId}-unavailable`, children: [_jsx("span", { title: `Ask card: ${cardId}`, style: { opacity: 0.6, fontStyle: 'italic' }, children: label }), onDismiss && _jsx(AskCardDismissButton, { cardId: cardId, onDismiss: onDismiss })] }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Keeps one broken card from taking down the whole transcript: if the card
|
|
50
|
+
* throws while rendering, it is replaced by a dismissable "failed to render"
|
|
51
|
+
* line and the rest of the chat carries on.
|
|
52
|
+
*/
|
|
53
|
+
export class AskCardErrorBoundary extends Component {
|
|
54
|
+
state = { failed: false };
|
|
55
|
+
static getDerivedStateFromError() {
|
|
56
|
+
return { failed: true };
|
|
57
|
+
}
|
|
58
|
+
componentDidCatch(error, info) {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.error(`AskCardView: card ${this.props.cardId} failed to render`, error, info.componentStack);
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
if (this.state.failed) {
|
|
64
|
+
return (_jsx(AskCardUnavailable, { cardId: this.props.cardId, label: "[this question failed to render]", onDismiss: this.props.onDismiss }));
|
|
65
|
+
}
|
|
66
|
+
return this.props.children;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function fileToBase64(file) {
|
|
70
|
+
const buf = await file.arrayBuffer();
|
|
71
|
+
const bytes = new Uint8Array(buf);
|
|
72
|
+
let binary = '';
|
|
73
|
+
for (let i = 0; i < bytes.byteLength; i++)
|
|
74
|
+
binary += String.fromCharCode(bytes[i]);
|
|
75
|
+
return btoa(binary);
|
|
76
|
+
}
|
|
77
|
+
function isAnswerable(card, selected, text, file) {
|
|
78
|
+
if (card.type === 'choice')
|
|
79
|
+
return selected.length > 0;
|
|
80
|
+
if (card.type === 'file')
|
|
81
|
+
return file != null;
|
|
82
|
+
return text.trim().length > 0;
|
|
83
|
+
}
|
|
84
|
+
/** One-line, human-readable summary of an answer ("Selected: A", "Uploaded: f.pdf", or the text). */
|
|
85
|
+
export function answerSummary(response) {
|
|
86
|
+
if (response.type === 'choice' && response.choice) {
|
|
87
|
+
return response.choice.selected.length > 0
|
|
88
|
+
? `Selected: ${response.choice.selected.join(', ')}`
|
|
89
|
+
: 'No option selected';
|
|
90
|
+
}
|
|
91
|
+
if (response.type === 'file' && response.file) {
|
|
92
|
+
return `Uploaded: ${response.file.fileName}`;
|
|
93
|
+
}
|
|
94
|
+
return response.additionalText?.trim() || '(no answer)';
|
|
95
|
+
}
|
|
96
|
+
export function AskCardView({ card, response, onSubmit, onDismiss, disabled }) {
|
|
97
|
+
const [selected, setSelected] = useState([]);
|
|
98
|
+
const [text, setText] = useState('');
|
|
99
|
+
const [additional, setAdditional] = useState('');
|
|
100
|
+
const [file, setFile] = useState(null);
|
|
101
|
+
const [submitting, setSubmitting] = useState(false);
|
|
102
|
+
const answered = response != null;
|
|
103
|
+
// Explanations by label (choices and options share labels, same order).
|
|
104
|
+
const optionByLabel = new Map((card.choice?.options ?? []).map((o) => [o.label, o]));
|
|
105
|
+
async function handleSubmit(continueWithTools) {
|
|
106
|
+
if (!onSubmit || submitting)
|
|
107
|
+
return;
|
|
108
|
+
setSubmitting(true);
|
|
109
|
+
try {
|
|
110
|
+
let built;
|
|
111
|
+
if (card.type === 'choice') {
|
|
112
|
+
built = {
|
|
113
|
+
cardId: card.id,
|
|
114
|
+
type: 'choice',
|
|
115
|
+
choice: { selected },
|
|
116
|
+
...(card.allowAdditionalText && additional.trim()
|
|
117
|
+
? { additionalText: additional.trim() }
|
|
118
|
+
: {}),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
else if (card.type === 'file') {
|
|
122
|
+
if (!file)
|
|
123
|
+
return;
|
|
124
|
+
built = {
|
|
125
|
+
cardId: card.id,
|
|
126
|
+
type: 'file',
|
|
127
|
+
file: {
|
|
128
|
+
fileName: file.name,
|
|
129
|
+
mimeType: file.type,
|
|
130
|
+
sizeBytes: file.size,
|
|
131
|
+
contentBase64: await fileToBase64(file),
|
|
132
|
+
},
|
|
133
|
+
...(card.allowAdditionalText && additional.trim()
|
|
134
|
+
? { additionalText: additional.trim() }
|
|
135
|
+
: {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
built = { cardId: card.id, type: 'text', additionalText: text.trim() };
|
|
140
|
+
}
|
|
141
|
+
onSubmit(built, { continueWithTools });
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
setSubmitting(false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (answered) {
|
|
148
|
+
return (_jsxs(Stack, { gap: 4, className: "ask-card ask-card--answered", "data-testid": `ask-card-${card.id}`, children: [_jsx(Text, { fw: 600, size: "sm", children: card.title }), card.text && (_jsx(Text, { size: "sm", c: "dimmed", children: card.text })), _jsx(Text, { size: "sm", fw: 500, "data-testid": `ask-card-answer-${card.id}`, children: answerSummary(response) }), response.type !== 'text' && response.additionalText?.trim() && (_jsx(Text, { size: "sm", c: "dimmed", children: response.additionalText }))] }));
|
|
149
|
+
}
|
|
150
|
+
return (_jsxs(Stack, { gap: 6, className: "ask-card", "data-testid": `ask-card-${card.id}`, children: [_jsxs(Group, { justify: "space-between", wrap: "nowrap", align: "flex-start", gap: "xs", children: [_jsx(Text, { fw: 600, size: "sm", children: card.title }), onDismiss && _jsx(AskCardDismissButton, { cardId: card.id, onDismiss: onDismiss })] }), card.text && (_jsx(Text, { size: "sm", c: "dimmed", children: card.text })), card.type === 'choice' &&
|
|
151
|
+
card.choice &&
|
|
152
|
+
(card.choice.allowMultiple ? (_jsx(Stack, { gap: 6, children: card.choice.choices.map((choice) => (_jsx(Checkbox, { label: choice, description: optionExplanation(card.id, optionByLabel.get(choice)), checked: selected.includes(choice), disabled: disabled || submitting, onChange: (e) => {
|
|
153
|
+
// Read now: the updater runs later, after React has nulled
|
|
154
|
+
// the event's currentTarget.
|
|
155
|
+
const checked = e.currentTarget.checked;
|
|
156
|
+
setSelected((prev) => checked ? [...prev, choice] : prev.filter((c) => c !== choice));
|
|
157
|
+
}, "data-testid": `ask-card-${card.id}-choice-${choice}` }, choice))) })) : (_jsx(Radio.Group, { value: selected[0] ?? '', onChange: (v) => setSelected([v]), children: _jsx(Stack, { gap: 6, children: card.choice.choices.map((choice) => (_jsx(Radio, { value: choice, label: choice, description: optionExplanation(card.id, optionByLabel.get(choice)), disabled: disabled || submitting, "data-testid": `ask-card-${card.id}-choice-${choice}` }, choice))) }) }))), card.type === 'text' && (_jsx(Textarea, { value: text, onChange: (e) => setText(e.currentTarget.value), disabled: disabled || submitting, "data-testid": `ask-card-${card.id}-text` })), card.type === 'file' && (_jsx(FileInput, { value: file, onChange: setFile, disabled: disabled || submitting, accept: card.file?.acceptedMimeTypes?.join(',') || undefined, "data-testid": `ask-card-${card.id}-file` })), card.allowAdditionalText && card.type !== 'text' && (_jsx(Textarea, { placeholder: "Additional notes (optional)", value: additional, onChange: (e) => setAdditional(e.currentTarget.value), disabled: disabled || submitting, "data-testid": `ask-card-${card.id}-additional` })), _jsxs(Group, { justify: "flex-end", gap: "xs", children: [_jsx(Button, { size: "xs", variant: "light", color: "orange", onClick: () => void handleSubmit(false), disabled: disabled || submitting || !isAnswerable(card, selected, text, file), title: "Send the answer; the agent replies without running any tools", "data-testid": `ask-card-${card.id}-submit-stop`, children: "Answer & stop" }), _jsx(Button, { size: "xs", onClick: () => void handleSubmit(true), disabled: disabled || submitting || !isAnswerable(card, selected, text, file), title: "Send the answer and let the agent keep working", "data-testid": `ask-card-${card.id}-submit`, children: "Answer & continue" })] })] }));
|
|
158
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CatalogTreeNode } from './modelCatalogTree.js';
|
|
2
|
+
import type { ChatModelOption } from './chatModelOptions.js';
|
|
3
|
+
export type CatalogColumnBrowserHandle = {
|
|
4
|
+
/**
|
|
5
|
+
* Forward a keyboard event from the parent (e.g. from the filter TextInput).
|
|
6
|
+
* Handles ArrowUp / ArrowDown / ArrowRight / ArrowLeft / Enter.
|
|
7
|
+
* Returns true if the event was consumed (caller should preventDefault).
|
|
8
|
+
*/
|
|
9
|
+
handleKeyDown(key: string): boolean;
|
|
10
|
+
};
|
|
11
|
+
export type CatalogColumnBrowserProps = {
|
|
12
|
+
roots: CatalogTreeNode[];
|
|
13
|
+
optionByModelId: Map<string, ChatModelOption>;
|
|
14
|
+
providerId: string;
|
|
15
|
+
multiProvider?: boolean;
|
|
16
|
+
onSelect: (providerId: string, modelId: string) => void;
|
|
17
|
+
isOptionSelected?: (opt: ChatModelOption) => boolean;
|
|
18
|
+
/** Bumps navigation back to the top level when changed (e.g. menu open). */
|
|
19
|
+
resetKey?: string | number;
|
|
20
|
+
/** Notifies parent when the browser switches between one and two columns. */
|
|
21
|
+
onColumnLayoutChange?: (twoColumns: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* When provided, renders a "Reload models" row fixed at the bottom of the
|
|
24
|
+
* pane showing a specific provider's models (regardless of how many models
|
|
25
|
+
* it currently has) — a manual, per-provider escape hatch instead of
|
|
26
|
+
* auto-refreshing every provider on every picker open.
|
|
27
|
+
*/
|
|
28
|
+
onReloadProvider?: (providerId: string) => void | Promise<void>;
|
|
29
|
+
/** Show nodes in the order given instead of sorting them by label (a host that orders its own tree). */
|
|
30
|
+
keepOrder?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare const CatalogColumnBrowser: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<CatalogColumnBrowserProps & import("react").RefAttributes<CatalogColumnBrowserHandle>>>;
|
|
33
|
+
//# sourceMappingURL=CatalogColumnBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatalogColumnBrowser.d.ts","sourceRoot":"","sources":["../src/CatalogColumnBrowser.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAkB7D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC;IACrD,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACrD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,wGAAwG;IACxG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AA0ZF,eAAO,MAAM,oBAAoB,uKAAsC,CAAC"}
|