slexkit 0.2.0
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/AGENTS.slexkit.md +29 -0
- package/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/README.zh-CN.md +165 -0
- package/dist/ai/llms-authoring.txt +44 -0
- package/dist/ai/llms-components.txt +669 -0
- package/dist/ai/llms-full.txt +6586 -0
- package/dist/ai/llms-runtime.txt +1475 -0
- package/dist/ai/llms-toolhost.txt +295 -0
- package/dist/ai/llms.txt +69 -0
- package/dist/ai/slexkit-ai-manifest.json +2922 -0
- package/dist/base.css +621 -0
- package/dist/chunks/accordion-5f0nvjjm.js +376 -0
- package/dist/chunks/accordion-830dw78f.js +221 -0
- package/dist/chunks/accordion-cfjyxw93.js +630 -0
- package/dist/chunks/accordion-cw5r75jm.js +424 -0
- package/dist/chunks/accordion-ehnhpeca.js +492 -0
- package/dist/chunks/accordion-hzyrngd6.js +2377 -0
- package/dist/chunks/accordion-nw12ytps.js +6823 -0
- package/dist/components/accordion.js +163 -0
- package/dist/components/badge.js +80 -0
- package/dist/components/button.css +114 -0
- package/dist/components/button.js +16 -0
- package/dist/components/callout.js +154 -0
- package/dist/components/card.js +95 -0
- package/dist/components/checkbox.js +114 -0
- package/dist/components/choice.css +165 -0
- package/dist/components/code-block.js +264 -0
- package/dist/components/collapsible.js +111 -0
- package/dist/components/column.js +49 -0
- package/dist/components/content.css +474 -0
- package/dist/components/disclosure.css +162 -0
- package/dist/components/display.css +259 -0
- package/dist/components/divider.js +98 -0
- package/dist/components/feedback.css +219 -0
- package/dist/components/grid.js +67 -0
- package/dist/components/index.js +13364 -0
- package/dist/components/input.css +1247 -0
- package/dist/components/input.js +384 -0
- package/dist/components/link.js +77 -0
- package/dist/components/progress.js +111 -0
- package/dist/components/radio-group.js +189 -0
- package/dist/components/row.js +200 -0
- package/dist/components/section.js +161 -0
- package/dist/components/select.css +260 -0
- package/dist/components/select.js +16 -0
- package/dist/components/slider.css +125 -0
- package/dist/components/slider.js +175 -0
- package/dist/components/specs.js +1090 -0
- package/dist/components/stat.js +178 -0
- package/dist/components/submit.css +9 -0
- package/dist/components/submit.js +77 -0
- package/dist/components/switch.css +114 -0
- package/dist/components/switch.js +114 -0
- package/dist/components/table.js +157 -0
- package/dist/components/tabs.css +192 -0
- package/dist/components/tabs.js +17 -0
- package/dist/components/text-input.css +245 -0
- package/dist/components/text.js +50 -0
- package/dist/components/toast.js +240 -0
- package/dist/components/tooling.css +1009 -0
- package/dist/components/tooling.js +48951 -0
- package/dist/runtime.cjs +3728 -0
- package/dist/runtime.js +3686 -0
- package/dist/slexkit.cjs +18539 -0
- package/dist/slexkit.css +4776 -0
- package/dist/slexkit.js +18497 -0
- package/dist/tooling.js +59141 -0
- package/dist/types/components/accordion.d.ts +2 -0
- package/dist/types/components/badge.d.ts +2 -0
- package/dist/types/components/button.d.ts +2 -0
- package/dist/types/components/callout.d.ts +2 -0
- package/dist/types/components/card.d.ts +2 -0
- package/dist/types/components/checkbox.d.ts +2 -0
- package/dist/types/components/code-block.d.ts +2 -0
- package/dist/types/components/collapsible.d.ts +2 -0
- package/dist/types/components/column.d.ts +2 -0
- package/dist/types/components/divider.d.ts +2 -0
- package/dist/types/components/entries/accordion.d.ts +3 -0
- package/dist/types/components/entries/badge.d.ts +3 -0
- package/dist/types/components/entries/button.d.ts +3 -0
- package/dist/types/components/entries/callout.d.ts +3 -0
- package/dist/types/components/entries/card.d.ts +3 -0
- package/dist/types/components/entries/checkbox.d.ts +3 -0
- package/dist/types/components/entries/code-block.d.ts +3 -0
- package/dist/types/components/entries/collapsible.d.ts +3 -0
- package/dist/types/components/entries/column.d.ts +3 -0
- package/dist/types/components/entries/divider.d.ts +3 -0
- package/dist/types/components/entries/grid.d.ts +3 -0
- package/dist/types/components/entries/input.d.ts +3 -0
- package/dist/types/components/entries/link.d.ts +3 -0
- package/dist/types/components/entries/progress.d.ts +3 -0
- package/dist/types/components/entries/radio-group.d.ts +3 -0
- package/dist/types/components/entries/row.d.ts +3 -0
- package/dist/types/components/entries/section.d.ts +3 -0
- package/dist/types/components/entries/select.d.ts +3 -0
- package/dist/types/components/entries/slider.d.ts +3 -0
- package/dist/types/components/entries/specs.d.ts +1 -0
- package/dist/types/components/entries/stat.d.ts +3 -0
- package/dist/types/components/entries/submit.d.ts +3 -0
- package/dist/types/components/entries/switch.d.ts +3 -0
- package/dist/types/components/entries/table.d.ts +3 -0
- package/dist/types/components/entries/tabs.d.ts +3 -0
- package/dist/types/components/entries/text.d.ts +3 -0
- package/dist/types/components/entries/toast.d.ts +3 -0
- package/dist/types/components/entries/tooling.d.ts +1 -0
- package/dist/types/components/grid.d.ts +2 -0
- package/dist/types/components/index.d.ts +6 -0
- package/dist/types/components/input.d.ts +2 -0
- package/dist/types/components/link.d.ts +2 -0
- package/dist/types/components/progress.d.ts +2 -0
- package/dist/types/components/radio-group.d.ts +2 -0
- package/dist/types/components/row.d.ts +2 -0
- package/dist/types/components/section.d.ts +2 -0
- package/dist/types/components/select.d.ts +2 -0
- package/dist/types/components/slider.d.ts +2 -0
- package/dist/types/components/spec-helpers.d.ts +23 -0
- package/dist/types/components/spec-registry.d.ts +12 -0
- package/dist/types/components/spec-schema.d.ts +74 -0
- package/dist/types/components/specs.d.ts +2 -0
- package/dist/types/components/stat.d.ts +2 -0
- package/dist/types/components/submit.d.ts +2 -0
- package/dist/types/components/svelte/adapter.d.ts +3 -0
- package/dist/types/components/svelte/bindProps.d.ts +2 -0
- package/dist/types/components/svelte/helpers.d.ts +33 -0
- package/dist/types/components/svelte/layout/balancedTiles.d.ts +14 -0
- package/dist/types/components/svelte/types.d.ts +12 -0
- package/dist/types/components/switch.d.ts +2 -0
- package/dist/types/components/table.d.ts +2 -0
- package/dist/types/components/tabs.d.ts +2 -0
- package/dist/types/components/text.d.ts +2 -0
- package/dist/types/components/toast.d.ts +2 -0
- package/dist/types/components/tooling.d.ts +2 -0
- package/dist/types/components-svelte.d.ts +5 -0
- package/dist/types/engine/component-scope.d.ts +14 -0
- package/dist/types/engine/component-state.d.ts +9 -0
- package/dist/types/engine/diagnostics.d.ts +24 -0
- package/dist/types/engine/engineering.d.ts +11 -0
- package/dist/types/engine/eval.d.ts +5 -0
- package/dist/types/engine/index.d.ts +26 -0
- package/dist/types/engine/markdown-runtime.d.ts +33 -0
- package/dist/types/engine/merge.d.ts +1 -0
- package/dist/types/engine/reactive.d.ts +11 -0
- package/dist/types/engine/registry.d.ts +4 -0
- package/dist/types/engine/renderer.d.ts +6 -0
- package/dist/types/engine/sandbox-runner.d.ts +2 -0
- package/dist/types/engine/secure-runtime.d.ts +214 -0
- package/dist/types/engine/store.d.ts +12 -0
- package/dist/types/engine/types.d.ts +58 -0
- package/dist/types/icons/manager.d.ts +17 -0
- package/dist/types/icons/phosphor.d.ts +45 -0
- package/dist/types/index.d.ts +61 -0
- package/dist/types/runtime.d.ts +32 -0
- package/dist/types/toolhost/index.d.ts +78 -0
- package/dist/types/tooling-umd.d.ts +47 -0
- package/dist/types/version.d.ts +8 -0
- package/dist/umd/slexkit.tooling.umd.js +66553 -0
- package/dist/umd/slexkit.umd.js +18552 -0
- package/package.json +136 -0
- package/scripts/cli.mjs +47 -0
- package/skills/slexkit/SKILL.md +27 -0
- package/skills/slexkit-author/SKILL.md +50 -0
- package/skills/slexkit-host-integration/SKILL.md +33 -0
- package/skills/slexkit-secure-runtime/SKILL.md +31 -0
- package/skills/slexkit-toolhost/SKILL.md +38 -0
- package/skills/slexkit-update/SKILL.md +23 -0
- package/src/components/svelte/InlineIcon.svelte +66 -0
- package/src/components/svelte/adapter.ts +76 -0
- package/src/components/svelte/bindProps.ts +9 -0
- package/src/components/svelte/content/Badge.svelte +19 -0
- package/src/components/svelte/content/Callout.svelte +57 -0
- package/src/components/svelte/content/CodeBlock.svelte +130 -0
- package/src/components/svelte/content/Divider.svelte +21 -0
- package/src/components/svelte/content/Link.svelte +21 -0
- package/src/components/svelte/content/Section.svelte +24 -0
- package/src/components/svelte/content/Table.svelte +44 -0
- package/src/components/svelte/disclosure/Accordion.svelte +100 -0
- package/src/components/svelte/disclosure/Collapsible.svelte +45 -0
- package/src/components/svelte/display/Stat.svelte +102 -0
- package/src/components/svelte/display/Text.svelte +11 -0
- package/src/components/svelte/feedback/Progress.svelte +34 -0
- package/src/components/svelte/feedback/Toast.svelte +105 -0
- package/src/components/svelte/helpers.ts +148 -0
- package/src/components/svelte/input/Button.svelte +78 -0
- package/src/components/svelte/input/Checkbox.svelte +52 -0
- package/src/components/svelte/input/Input.svelte +202 -0
- package/src/components/svelte/input/RadioGroup.svelte +71 -0
- package/src/components/svelte/input/Select.svelte +220 -0
- package/src/components/svelte/input/Slider.svelte +96 -0
- package/src/components/svelte/input/Submit.svelte +32 -0
- package/src/components/svelte/input/Switch.svelte +53 -0
- package/src/components/svelte/input/Tabs.svelte +188 -0
- package/src/components/svelte/layout/Card.svelte +17 -0
- package/src/components/svelte/layout/Column.svelte +15 -0
- package/src/components/svelte/layout/Grid.svelte +26 -0
- package/src/components/svelte/layout/Row.svelte +105 -0
- package/src/components/svelte/layout/balancedTiles.ts +85 -0
- package/src/components/svelte/tooling/CodeMirror.svelte +91 -0
- package/src/components/svelte/tooling/Playground.svelte +765 -0
- package/src/components/svelte/tooling/PlaygroundMarkdown.svelte +26 -0
- package/src/components/svelte/tooling/PlaygroundSlexCode.svelte +76 -0
- package/src/components/svelte/types.ts +17 -0
- package/src/styles/animation.css +98 -0
- package/src/styles/components/button.css +114 -0
- package/src/styles/components/choice.css +165 -0
- package/src/styles/components/select.css +260 -0
- package/src/styles/components/slider.css +125 -0
- package/src/styles/components/submit.css +9 -0
- package/src/styles/components/switch.css +114 -0
- package/src/styles/components/tabs.css +192 -0
- package/src/styles/components/text-input.css +245 -0
- package/src/styles/content.css +474 -0
- package/src/styles/disclosure.css +162 -0
- package/src/styles/display.css +259 -0
- package/src/styles/entry.css +34 -0
- package/src/styles/feedback.css +219 -0
- package/src/styles/input.css +8 -0
- package/src/styles/layout.css +365 -0
- package/src/styles/theme.css +31 -0
- package/src/styles/tooling.css +1009 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# SlexKit ToolHost for LLMs
|
|
2
|
+
|
|
3
|
+
ToolHost is the structured-input path for confirmations, choices, and forms. Do not use it for ordinary display-only UI.
|
|
4
|
+
|
|
5
|
+
## ToolHost
|
|
6
|
+
|
|
7
|
+
Raw Markdown: /docs/reference/toolhost.md
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
title: ToolHost
|
|
11
|
+
category: Reference
|
|
12
|
+
status: ready
|
|
13
|
+
order: 70
|
|
14
|
+
summary: "Structured user-input UI for confirmations, choices, forms, templates, and submit boundaries."
|
|
15
|
+
slexkitRenderMode: component
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# ToolHost
|
|
19
|
+
|
|
20
|
+
ToolHost bridges AI tool calls to interactive UI. Instead of the AI executing tools server-side, ToolHost renders a structured input form in the browser and returns the user's response as a `ToolResult`.
|
|
21
|
+
|
|
22
|
+
## Concepts
|
|
23
|
+
|
|
24
|
+
When an AI model emits a tool call (e.g., `confirm-action`, `fill-form`), ToolHost compiles it into a standard `SlexExpression` and mounts it using the core runtime. The mounted UI has a **submit boundary** (`submit:actions` component) that settles a Promise with the user's input.
|
|
25
|
+
|
|
26
|
+
ToolHost is **separate from display-oriented `slex` fences**. Display components render information; ToolHost components collect structured user input and return it programmatically.
|
|
27
|
+
|
|
28
|
+
## Public API
|
|
29
|
+
|
|
30
|
+
### `renderToolCall(call, container) → ToolRenderHandle`
|
|
31
|
+
|
|
32
|
+
Compiles a tool call into a SlexExpression, mounts it, and returns a handle.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
function renderToolCall(call: ToolCall, container: HTMLElement): ToolRenderHandle;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
type ToolRenderHandle = {
|
|
40
|
+
promise: Promise<ToolResult>; // Resolves when user submits or ignores
|
|
41
|
+
dispose: () => void; // Clean up the rendered UI
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type ToolResult =
|
|
45
|
+
| { toolCallId?: string; toolName: string; status: "submitted"; value: Record<string, unknown> }
|
|
46
|
+
| { toolCallId?: string; toolName: string; status: "ignored"; value: null };
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Usage:**
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { renderToolCall } from "slexkit";
|
|
53
|
+
|
|
54
|
+
const handle = renderToolCall(
|
|
55
|
+
{
|
|
56
|
+
id: "call_001",
|
|
57
|
+
name: "confirm-action",
|
|
58
|
+
arguments: {
|
|
59
|
+
title: "Delete file?",
|
|
60
|
+
description: "This action cannot be undone.",
|
|
61
|
+
confirmLabel: "Delete",
|
|
62
|
+
requireReason: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
document.getElementById("tool-container"),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
handle.promise.then((result) => {
|
|
69
|
+
console.log(result.status); // "submitted" or "ignored"
|
|
70
|
+
console.log(result.value); // { confirmed: true, reason: "Obsolete file" }
|
|
71
|
+
handle.dispose();
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `registerToolTemplate(name, compiler)`
|
|
76
|
+
|
|
77
|
+
Register a custom tool template. The compiler function receives the tool arguments and returns a `SlexExpression`.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
function registerToolTemplate(name: string, compiler: ToolTemplateCompiler): void;
|
|
81
|
+
|
|
82
|
+
type ToolTemplateCompiler<TArgs = Record<string, unknown>> = (
|
|
83
|
+
args: TArgs,
|
|
84
|
+
runtime: ToolRuntime,
|
|
85
|
+
call: ToolCall,
|
|
86
|
+
) => SlexExpression;
|
|
87
|
+
|
|
88
|
+
type ToolRuntime = {
|
|
89
|
+
submit: (value: Record<string, unknown>) => void;
|
|
90
|
+
ignore: () => void;
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Built-in templates
|
|
95
|
+
|
|
96
|
+
### `confirm-action`
|
|
97
|
+
|
|
98
|
+
Yes/no confirmation dialog. Supports an optional reason field.
|
|
99
|
+
|
|
100
|
+
**Arguments (`ConfirmActionArguments`):**
|
|
101
|
+
|
|
102
|
+
| Field | Type | Default | Description |
|
|
103
|
+
|-------|------|---------|-------------|
|
|
104
|
+
| `title` | `string` | `"Confirm action"` | Dialog title |
|
|
105
|
+
| `description` | `string` | — | Optional explanation text |
|
|
106
|
+
| `confirmLabel` | `string` | `"Confirm"` | Submit button label |
|
|
107
|
+
| `ignoreLabel` | `string` | `"Ignore"` | Cancel button label |
|
|
108
|
+
| `requireReason` | `boolean` | `false` | Show a reason text input |
|
|
109
|
+
| `reasonLabel` | `string` | `"Reason"` | Label for the reason input |
|
|
110
|
+
| `reasonPlaceholder` | `string` | `"Add a reason"` | Placeholder for the reason input |
|
|
111
|
+
|
|
112
|
+
**Result value:**
|
|
113
|
+
|
|
114
|
+
| Key | Type | Description |
|
|
115
|
+
|-----|------|-------------|
|
|
116
|
+
| `confirmed` | `boolean` | Always `true` when submitted |
|
|
117
|
+
| `reason` | `string` | User's reason text (only if `requireReason: true`) |
|
|
118
|
+
|
|
119
|
+
**Example:**
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
renderToolCall({
|
|
123
|
+
name: "confirm-action",
|
|
124
|
+
arguments: {
|
|
125
|
+
title: "Delete project?",
|
|
126
|
+
description: "This will permanently delete all files.",
|
|
127
|
+
confirmLabel: "Delete",
|
|
128
|
+
requireReason: true,
|
|
129
|
+
},
|
|
130
|
+
}, container);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `choose-options` / `option-list`
|
|
134
|
+
|
|
135
|
+
Single or multi-select option list. `option-list` is an alias for `choose-options` — behavior is identical.
|
|
136
|
+
|
|
137
|
+
**Arguments (`ChooseOptionsArguments` / `OptionListArguments`):**
|
|
138
|
+
|
|
139
|
+
| Field | Type | Default | Description |
|
|
140
|
+
|-------|------|---------|-------------|
|
|
141
|
+
| `title` | `string` | `"Choose options"` | Dialog title |
|
|
142
|
+
| `description` | `string` | — | Optional explanation text |
|
|
143
|
+
| `options` / `items` | `OptionListItem[]` | `[]` | List of selectable items |
|
|
144
|
+
| `multiple` | `boolean` | `true` | Allow multiple selection |
|
|
145
|
+
| `selected` | `string[]` | auto | Pre-selected item IDs |
|
|
146
|
+
| `minSelected` | `number` | `0` | Minimum required selections |
|
|
147
|
+
| `maxSelected` | `number` | `Infinity` | Maximum allowed selections |
|
|
148
|
+
| `submitLabel` | `string` | `"Submit"` | Submit button label |
|
|
149
|
+
| `ignoreLabel` | `string` | `"Ignore"` | Cancel button label |
|
|
150
|
+
|
|
151
|
+
**OptionListItem:**
|
|
152
|
+
|
|
153
|
+
| Field | Type | Description |
|
|
154
|
+
|-------|------|-------------|
|
|
155
|
+
| `label` | `string` | Display text (required) |
|
|
156
|
+
| `id` | `string` | Unique identifier (defaults to `value` or index) |
|
|
157
|
+
| `value` | `string` | Submitted value (defaults to `id`) |
|
|
158
|
+
| `description` | `string` | Secondary text shown after label |
|
|
159
|
+
| `selected` | `boolean` | Pre-selected state |
|
|
160
|
+
| `disabled` | `boolean` | Disabled state |
|
|
161
|
+
|
|
162
|
+
**Rendering:**
|
|
163
|
+
- When `multiple: true` (default): renders **checkboxes**
|
|
164
|
+
- When `multiple: false`: renders a **radio group**
|
|
165
|
+
|
|
166
|
+
**Result value:**
|
|
167
|
+
|
|
168
|
+
| Key | Type | Description |
|
|
169
|
+
|-----|------|-------------|
|
|
170
|
+
| `selected` | `string[]` | IDs of selected items |
|
|
171
|
+
|
|
172
|
+
**Example:**
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
renderToolCall({
|
|
176
|
+
name: "choose-options",
|
|
177
|
+
arguments: {
|
|
178
|
+
title: "Select dependencies",
|
|
179
|
+
options: [
|
|
180
|
+
{ id: "react", label: "React", description: "UI library" },
|
|
181
|
+
{ id: "vue", label: "Vue", description: "Progressive framework" },
|
|
182
|
+
{ id: "svelte", label: "Svelte", description: "Compiled framework", selected: true },
|
|
183
|
+
],
|
|
184
|
+
multiple: true,
|
|
185
|
+
minSelected: 1,
|
|
186
|
+
maxSelected: 2,
|
|
187
|
+
},
|
|
188
|
+
}, container);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `fill-form`
|
|
192
|
+
|
|
193
|
+
Multi-field form with various field types.
|
|
194
|
+
|
|
195
|
+
**Arguments (`FillFormArguments`):**
|
|
196
|
+
|
|
197
|
+
| Field | Type | Default | Description |
|
|
198
|
+
|-------|------|---------|-------------|
|
|
199
|
+
| `title` | `string` | `"Fill form"` | Form title |
|
|
200
|
+
| `description` | `string` | — | Optional explanation text |
|
|
201
|
+
| `fields` | `FormField[]` | `[]` | Form field definitions |
|
|
202
|
+
| `values` | `Record<string, unknown>` | — | Initial field values |
|
|
203
|
+
| `submitLabel` | `string` | `"Submit"` | Submit button label |
|
|
204
|
+
| `ignoreLabel` | `string` | `"Ignore"` | Cancel button label |
|
|
205
|
+
|
|
206
|
+
**FormField:**
|
|
207
|
+
|
|
208
|
+
| Field | Type | Default | Description |
|
|
209
|
+
|-------|------|---------|-------------|
|
|
210
|
+
| `name` | `string` | (required) | Field name (used as key in result value) |
|
|
211
|
+
| `type` | `FormFieldType` | `"text"` | Field type |
|
|
212
|
+
| `label` | `string` | `name` | Display label |
|
|
213
|
+
| `description` | `string` | — | Help text below the field |
|
|
214
|
+
| `placeholder` | `string` | — | Input placeholder |
|
|
215
|
+
| `required` | `boolean` | `false` | Require non-empty value to submit |
|
|
216
|
+
| `disabled` | `boolean` | `false` | Disable the field |
|
|
217
|
+
| `value` | `unknown` | — | Initial value |
|
|
218
|
+
| `options` | `Array<{label, value}>` | — | Options for `select` type |
|
|
219
|
+
|
|
220
|
+
**FormFieldType:**
|
|
221
|
+
|
|
222
|
+
| Type | Renders | Description |
|
|
223
|
+
|------|---------|-------------|
|
|
224
|
+
| `text` | `<input>` | Free-form text |
|
|
225
|
+
| `number` | `<input type="number">` | Numeric input, value is `number \| null` |
|
|
226
|
+
| `engineering` | `<input>` with SI prefix parsing | Accepts values like `"10kΩ"`, `"100nF"`, `"1.5MegHz"`. Parsed with `parseEngineeringNumber()`. State includes `raw`, `number`, `valid`, `prefix`, `unit`, `normalized` |
|
|
227
|
+
| `select` | `<select>` | Dropdown from `options` array |
|
|
228
|
+
| `checkbox` | Checkbox | Boolean toggle |
|
|
229
|
+
| `switch` | Switch toggle | Boolean toggle (switch style) |
|
|
230
|
+
|
|
231
|
+
**Result value:**
|
|
232
|
+
|
|
233
|
+
An object with a key for each field name, containing the submitted value. For `engineering` fields, the raw input string is submitted. For `checkbox`/`switch` fields, a boolean is submitted. For `number` fields, a number or `null` is submitted.
|
|
234
|
+
|
|
235
|
+
**Example:**
|
|
236
|
+
|
|
237
|
+
```js
|
|
238
|
+
renderToolCall({
|
|
239
|
+
name: "fill-form",
|
|
240
|
+
arguments: {
|
|
241
|
+
title: "New project",
|
|
242
|
+
fields: [
|
|
243
|
+
{ name: "name", type: "text", label: "Project name", required: true },
|
|
244
|
+
{ name: "framework", type: "select", label: "Framework", options: [
|
|
245
|
+
{ label: "React", value: "react" },
|
|
246
|
+
{ label: "Svelte", value: "svelte" },
|
|
247
|
+
]},
|
|
248
|
+
{ name: "resistance", type: "engineering", label: "Target resistance", placeholder: "e.g. 10kΩ" },
|
|
249
|
+
{ name: "typescript", type: "checkbox", label: "Use TypeScript", value: true },
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
}, container);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Writing a custom template
|
|
256
|
+
|
|
257
|
+
Implement the `ToolTemplateCompiler` function and register it:
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
import { registerToolTemplate, renderToolCall } from "slexkit";
|
|
261
|
+
|
|
262
|
+
registerToolTemplate("greet-user", (args, runtime, call) => ({
|
|
263
|
+
namespace: `tool_greet_${Date.now()}`,
|
|
264
|
+
g: {
|
|
265
|
+
__slexkitTool: runtime,
|
|
266
|
+
name: args.name || "World",
|
|
267
|
+
},
|
|
268
|
+
layout: {
|
|
269
|
+
"card:tool": {
|
|
270
|
+
title: "Greeting",
|
|
271
|
+
"text:message": { "$content": "'Hello, ' + g.name + '!'" },
|
|
272
|
+
"submit:actions": {
|
|
273
|
+
returnKeys: ["name"],
|
|
274
|
+
submitLabel: args.submitLabel || "OK",
|
|
275
|
+
ignoreLabel: args.ignoreLabel || "Cancel",
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
}));
|
|
280
|
+
|
|
281
|
+
renderToolCall(
|
|
282
|
+
{ name: "greet-user", arguments: { name: "Alice" } },
|
|
283
|
+
container,
|
|
284
|
+
);
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Key patterns
|
|
288
|
+
|
|
289
|
+
1. **`__slexkitTool`** — Set `g.__slexkitTool = runtime` to give expressions access to `submit()` and `ignore()`
|
|
290
|
+
2. **`submit:actions`** — Always include a `submit:actions` component as the completion boundary. Set `returnKeys` to the property names that should be included in the result value
|
|
291
|
+
3. **`canSubmit`** — Add a `g.canSubmit()` method to control the submit button's disabled state
|
|
292
|
+
4. **Unique namespace** — Use a timestamp-based namespace to avoid collisions with other tool calls
|
|
293
|
+
5. **Validation** — Implement validation logic in `g` methods and wire `$disabled` on the submit button
|
|
294
|
+
|
|
295
|
+
---
|
package/dist/ai/llms.txt
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# SlexKit > Markdown-friendly reactive UI runtime for AI output
|
|
2
|
+
|
|
3
|
+
## LLM Documentation Files
|
|
4
|
+
|
|
5
|
+
- [Full documentation](/llms-full.txt): all canonical English docs pages in one text file.
|
|
6
|
+
- [Component reference](/llms-components.txt): component docs index plus generated props/state reference.
|
|
7
|
+
- [Runtime docs](/llms-runtime.txt): runtime, host integration, and secure rendering docs.
|
|
8
|
+
- [ToolHost docs](/llms-toolhost.txt): structured user-input UI docs.
|
|
9
|
+
- [Authoring rules](/llms-authoring.txt): concise rules for Markdown `slex` fences.
|
|
10
|
+
- [AI manifest](/slexkit-ai-manifest.json): structured page, component, and hash metadata.
|
|
11
|
+
|
|
12
|
+
SlexKit raw docs are Markdown (`.md`) with explicit `slex` fences. The interactive layer is the fenced `slex` source inside each Markdown page.
|
|
13
|
+
|
|
14
|
+
Version: 0.2.0
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
### Guides
|
|
19
|
+
- [README](/README.md): Root package overview and installation matrix.
|
|
20
|
+
- [SlexKit Introduction](/docs/guides/intro.md): What SlexKit is and where it fits.
|
|
21
|
+
- [Quick Start](/docs/guides/quick-start.md): Install SlexKit and render a first Markdown-friendly Slex source.
|
|
22
|
+
- [Integration](/docs/guides/integration.md): React/Streamdown and Obsidian host plugins for explicit Slex fences.
|
|
23
|
+
- [Design Guidelines](/docs/guides/design.md): Design and authoring guidelines for SlexKit components and docs.
|
|
24
|
+
- [Secure Runtime Setup](/docs/guides/security-runtime.md): Decision and setup guide for rendering untrusted or agent-generated Slex source.
|
|
25
|
+
- [AI / Agents](/docs/guides/ai-agents.md): LLM docs, MCP server, skills, and authoring rules for SlexKit agents.
|
|
26
|
+
|
|
27
|
+
### Components
|
|
28
|
+
- [Accordion](/docs/components/accordion.md): Expandable grouped panels.
|
|
29
|
+
- [Badge](/docs/components/badge.md): Compact label for status or classification.
|
|
30
|
+
- [Button](/docs/components/button.md): Action trigger.
|
|
31
|
+
- [Callout](/docs/components/callout.md): Highlighted contextual message.
|
|
32
|
+
- [Card](/docs/components/card.md): Bordered grouping container.
|
|
33
|
+
- [Checkbox](/docs/components/checkbox.md): Boolean checkbox input.
|
|
34
|
+
- [Code Block](/docs/components/code-block.md): Formatted code or log block.
|
|
35
|
+
- [Collapsible](/docs/components/collapsible.md): Single expandable region.
|
|
36
|
+
- [Column](/docs/components/column.md): Vertical layout container.
|
|
37
|
+
- [Divider](/docs/components/divider.md): Visual separator.
|
|
38
|
+
- [Grid](/docs/components/grid.md): Responsive grid container.
|
|
39
|
+
- [Icon](/docs/components/icon.md): Shared icon field capability.
|
|
40
|
+
- [Input](/docs/components/input.md): Text or engineering-value input.
|
|
41
|
+
- [Link](/docs/components/link.md): Inline navigation link.
|
|
42
|
+
- [Playground](/docs/components/playground.md): Interactive source preview.
|
|
43
|
+
- [Progress](/docs/components/progress.md): Progress bar.
|
|
44
|
+
- [Radio Group](/docs/components/radio-group.md): Single-choice option group.
|
|
45
|
+
- [Row](/docs/components/row.md): Horizontal layout container.
|
|
46
|
+
- [Section](/docs/components/section.md): Page section with optional heading chrome.
|
|
47
|
+
- [Select](/docs/components/select.md): Dropdown selection input.
|
|
48
|
+
- [Slider](/docs/components/slider.md): Numeric range input.
|
|
49
|
+
- [Stat](/docs/components/stat.md): Metric display.
|
|
50
|
+
- [Submit](/docs/components/submit.md): ToolHost submit and ignore controls.
|
|
51
|
+
- [Switch](/docs/components/switch.md): Boolean switch input.
|
|
52
|
+
- [Table](/docs/components/table.md): Simple data table.
|
|
53
|
+
- [Tabs](/docs/components/tabs.md): Tabbed view switcher.
|
|
54
|
+
- [Text](/docs/components/text.md): Plain text display.
|
|
55
|
+
- [Toast](/docs/components/toast.md): Transient notification.
|
|
56
|
+
|
|
57
|
+
### Reference
|
|
58
|
+
- [Slex Specification](/docs/reference/spec.md): Public Slex expression envelope, component keys, props, directives, and lifecycle.
|
|
59
|
+
- [Slex Usage Reference](/docs/reference/usage.md): Slex source structure, props, directives, events, theming, custom components, and ToolHost boundaries.
|
|
60
|
+
- [Runtime Model](/docs/reference/runtime.md): Mounting, ingestion, boot, namespace store, lifecycle, and runtime APIs.
|
|
61
|
+
- [Host Integration](/docs/reference/integration.md): Markdown renderers, Streamdown, Obsidian, custom hosts, and artifact lifecycle.
|
|
62
|
+
- [Security Runtime](/docs/reference/security.md): Threat model, sandbox iframe, postMessage bridge, policy, and fail-closed behavior.
|
|
63
|
+
- [Package Boundaries](/docs/reference/packages.md): Package relationships, installation matrix, and packaging strategy.
|
|
64
|
+
- [ToolHost](/docs/reference/toolhost.md): Tool call rendering, built-in templates, custom templates, and submit boundaries.
|
|
65
|
+
- [Icon System](/docs/reference/icons.md): Phosphor icons, custom icon registration, Iconify fallback, and API reference.
|
|
66
|
+
- [Design Rationale](/docs/reference/rationale.md): Why SlexKit uses object literals, expressions, explicit fences, and secure/trusted modes.
|
|
67
|
+
|
|
68
|
+
### Releases
|
|
69
|
+
- [Changelog](/docs/releases/changelog.md): Release notes and notable changes for SlexKit.
|