@claw-link/clom-renderer 1.0.0 → 1.0.1
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/LICENSE +21 -0
- package/README.md +112 -0
- package/package.json +5 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ClawLink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# clom-renderer
|
|
2
|
+
|
|
3
|
+
React component library for rendering [CLOM protocol](https://openclaw.ai) interactions. Pass any JSON output from a CLOM agent directly to `<ClomRenderer>` and it renders the appropriate interactive UI.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/clom-renderer)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
CLOM (ClawLink Local Orchestration Module) is an AI agent protocol that returns structured JSON describing interactive UI — forms, date pickers, OTP inputs, product grids, appointment slots, and more. `clom-renderer` sits on the client side: it receives that JSON and renders the right React component. No API calls, no configuration — just JSON in, UI out.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
CLOM agent (server) → JSON output → [request/response layer] → <ClomRenderer data={...} />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install clom-renderer
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { ClomRenderer } from 'clom-renderer';
|
|
26
|
+
import 'clom-renderer/style.css';
|
|
27
|
+
|
|
28
|
+
<ClomRenderer
|
|
29
|
+
data={clomOutput} // raw JSON from CLOM
|
|
30
|
+
onSubmit={(text) => send(text)} // called with user's response as plain text
|
|
31
|
+
locked={false} // true = already submitted, renders nothing
|
|
32
|
+
/>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Props
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Description |
|
|
38
|
+
|------|------|-------------|
|
|
39
|
+
| `data` | `ClomOutput` | Raw CLOM JSON output, discriminated by `interaction` field |
|
|
40
|
+
| `onSubmit` | `(text: string) => void` | Called when user submits — receives a formatted plain-text summary |
|
|
41
|
+
| `locked` | `boolean` | When `true`, component renders nothing (prevents re-submission) |
|
|
42
|
+
|
|
43
|
+
## Supported interaction types
|
|
44
|
+
|
|
45
|
+
| `interaction` | UI rendered | Submits |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `form` | Multi-field form | Line-separated `label: value` |
|
|
48
|
+
| `address` | Address form with prefill support | Line-separated `label: value` |
|
|
49
|
+
| `select` | Single-choice button group | Selected option text |
|
|
50
|
+
| `multiselect` | Checkbox list | Comma-separated selections |
|
|
51
|
+
| `date_picker` | Date input with min/max | `label: YYYY-MM-DD` |
|
|
52
|
+
| `otp` | Auto-advancing digit inputs with paste | `label: 123456` |
|
|
53
|
+
| `rating` | Star rating with hover labels | `label: 4/5 (Great)` |
|
|
54
|
+
| `file_upload` | Drag-and-drop file zone with size validation | `label: filename.pdf` |
|
|
55
|
+
| `card_grid` | Responsive product/service card grid | `Selected: card title` |
|
|
56
|
+
| `confirmation_card` | Key-value summary + action buttons | Action label |
|
|
57
|
+
| `timeline` | Read-only status timeline | _(display only)_ |
|
|
58
|
+
| `slot_picker` | Appointment slot grid | `Selected slot: label (datetime)` |
|
|
59
|
+
| `data_table` | Read-only scrollable table | _(display only)_ |
|
|
60
|
+
| `stepper` | Multi-step form wizard with progress dots | All step fields combined |
|
|
61
|
+
|
|
62
|
+
## Theming
|
|
63
|
+
|
|
64
|
+
The component uses CSS custom properties. When used inside a ClawLink app the host app's existing variables are picked up automatically. For standalone use, a dark theme is applied by default. Override any `--clom-*` variable on `:root` or a parent element:
|
|
65
|
+
|
|
66
|
+
```css
|
|
67
|
+
:root {
|
|
68
|
+
--clom-bg: #ffffff;
|
|
69
|
+
--clom-surface: #f5f5f5;
|
|
70
|
+
--clom-border: #e0e0e0;
|
|
71
|
+
--clom-text: #111111;
|
|
72
|
+
--clom-text-muted: #666666;
|
|
73
|
+
--clom-accent: #6366f1;
|
|
74
|
+
--clom-accent2: #8b5cf6;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## TypeScript
|
|
79
|
+
|
|
80
|
+
Full types are exported:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import type {
|
|
84
|
+
ClomOutput,
|
|
85
|
+
InteractionSpec,
|
|
86
|
+
FormField,
|
|
87
|
+
InteractionCard,
|
|
88
|
+
TimelineStep,
|
|
89
|
+
StepperStep,
|
|
90
|
+
} from 'clom-renderer';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`ClomOutput` is `InteractionSpec & Record<string, unknown>` — CLOM can attach any custom metadata fields alongside the standard ones; they are ignored by the renderer.
|
|
94
|
+
|
|
95
|
+
## Custom metadata
|
|
96
|
+
|
|
97
|
+
Since CLOM (generator) and `clom-renderer` (consumer) are designed together, you can freely add custom fields to the JSON for tracking or context purposes:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"interaction": "form",
|
|
102
|
+
"fields": [...],
|
|
103
|
+
"_session_ref": "abc123",
|
|
104
|
+
"_tenant_id": "xyz"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The renderer ignores unknown fields and only uses what it knows.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT — see [LICENSE](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claw-link/clom-renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React component library for rendering CLOM protocol interactions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -14,8 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"./style.css": "./dist/style.css"
|
|
16
16
|
},
|
|
17
|
+
"license": "MIT",
|
|
17
18
|
"files": [
|
|
18
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md"
|
|
19
22
|
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "vite build",
|