morph-embed 0.1.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/LICENSE +21 -0
- package/README.md +152 -0
- package/dist/morph-embed.esm.mjs +2424 -0
- package/dist/morph-embed.js +2420 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mandar Wagh
|
|
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,152 @@
|
|
|
1
|
+
# morph-embed
|
|
2
|
+
|
|
3
|
+
**Let your users build the features you haven't shipped yet.**
|
|
4
|
+
|
|
5
|
+
Morph Embed adds a prompt bar to your web product. Your users type what they're
|
|
6
|
+
missing — *"add a box showing how much we lost in the last 15 days"* — and get a
|
|
7
|
+
real, working widget computed from **your** data, rendered safely, saved for
|
|
8
|
+
them, and reapplied on every visit. No ticket, no sprint, no code deployed.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
User types a sentence → a real feature appears → it persists
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Three capabilities, in increasing order of integration effort:
|
|
15
|
+
|
|
16
|
+
| Capability | What users can do | What you provide |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| **Reshape** | Restyle, rearrange, declutter your UI by prompt | Nothing — works out of the box |
|
|
19
|
+
| **Data widgets** | Generate stat boxes and charts over live data ("lost deals this month", "signups per week") | Registered *data sources* (a fetch function + a field schema) |
|
|
20
|
+
| **Actions** | Generated buttons that do things ("add a follow-up task") — always user-clicked, always confirmable | Registered *actions* (a callback + an argument schema) |
|
|
21
|
+
|
|
22
|
+
## Why it's safe to put in your product
|
|
23
|
+
|
|
24
|
+
Most teams can't let an LLM touch their UI because model output might execute.
|
|
25
|
+
Morph is built so it **can't**:
|
|
26
|
+
|
|
27
|
+
1. **The model never returns code.** It answers only in a fixed, declarative
|
|
28
|
+
JSON DSL (`hide`, `injectCSS`, `move`, `addElement`, `renderData`, …).
|
|
29
|
+
Every op is validated and sanitized in the browser: HTML is
|
|
30
|
+
whitelist-sanitized, CSS is neutralized, and there is no execution op to
|
|
31
|
+
reach for. This is the architecture, not a filter.
|
|
32
|
+
2. **Your data never leaves the page.** The model only ever sees your source
|
|
33
|
+
*names and field schemas*. When it wants numbers, it emits a *query
|
|
34
|
+
description*; trusted SDK code validates that query against your schema,
|
|
35
|
+
runs **your** fetch function in the browser (under your existing auth),
|
|
36
|
+
aggregates client-side, and renders the numbers itself via `createElementNS`.
|
|
37
|
+
Morph's servers never see a record — and the model never emits a number.
|
|
38
|
+
3. **Actions are allowlisted by construction.** Unknown action names and
|
|
39
|
+
off-schema arguments are dropped before anything renders. A registered
|
|
40
|
+
action runs only on a real user click, behind a confirm dialog if you say
|
|
41
|
+
so. Nothing is scheduled; nothing fires on its own.
|
|
42
|
+
4. **Keys are publishable.** Like a Stripe `pk_` key, your key appears in page
|
|
43
|
+
source by design. It's bound to your origins server-side and rate-limited
|
|
44
|
+
per vendor. It gates cost, not data — there is no data behind it.
|
|
45
|
+
5. **Generated features live client-side** — in `localStorage`, or in your own
|
|
46
|
+
backend via a three-method storage adapter. Morph stores nothing per-user.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
**npm:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install morph-embed
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { init } from 'morph-embed';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Or one script tag** (IIFE build, exposes `window.Morph`):
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<script src="https://unpkg.com/morph-embed/dist/morph-embed.js"></script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Integrate
|
|
67
|
+
|
|
68
|
+
This is the complete integration surface — a CRM registering one data source
|
|
69
|
+
and one action:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
Morph.init({
|
|
73
|
+
key: 'pk_...', // your publishable key
|
|
74
|
+
|
|
75
|
+
sources: {
|
|
76
|
+
deals: {
|
|
77
|
+
fetch: async (query) => api.deals(), // your API, your auth, your data
|
|
78
|
+
schema: { // field name -> string|number|date|boolean
|
|
79
|
+
name: 'string',
|
|
80
|
+
stage: 'string',
|
|
81
|
+
amount: 'number',
|
|
82
|
+
closedAt: 'date',
|
|
83
|
+
},
|
|
84
|
+
description: 'All CRM deals (stage: won|lost|open)',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
actions: {
|
|
89
|
+
createTask: {
|
|
90
|
+
run: async (args) => api.tasks.create(args), // your callback
|
|
91
|
+
argsSchema: { note: 'string' }, // string|number args only
|
|
92
|
+
description: 'Create a follow-up task',
|
|
93
|
+
confirm: true, // user must approve every run
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Optional:
|
|
98
|
+
storage: { get, set, remove }, // persist users' features in YOUR backend
|
|
99
|
+
// (omit for localStorage)
|
|
100
|
+
trigger: 'alt+m', // hotkey, or 'none' + call Morph.open()
|
|
101
|
+
// from your own button
|
|
102
|
+
backend: 'https://...', // override the Morph API endpoint
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Your users press **Alt+M** and describe what they want. That's the whole thing.
|
|
107
|
+
|
|
108
|
+
### What the model can ask of your sources
|
|
109
|
+
|
|
110
|
+
The query language is deliberately tiny — enough for "show me X", small enough
|
|
111
|
+
to audit:
|
|
112
|
+
|
|
113
|
+
- `filter` — equality or IN over your fields
|
|
114
|
+
- `dateField` + `since` / `until` — durations like `'15d'`, `'24h'`, or ISO dates
|
|
115
|
+
- `groupBy` — one row per group
|
|
116
|
+
- `aggregate` — `sum` | `count` | `avg` | `min` | `max`
|
|
117
|
+
- `limit`
|
|
118
|
+
|
|
119
|
+
Every referenced field must exist in your declared schema — a hallucinated
|
|
120
|
+
field is a hard error, never a silent zero. If a question needs more than this
|
|
121
|
+
language expresses, expose it as a purpose-built source instead.
|
|
122
|
+
|
|
123
|
+
### Widgets your users can generate
|
|
124
|
+
|
|
125
|
+
`stat` (big number + caption), `bar`, and `line` charts — all rendered by
|
|
126
|
+
trusted code as SVG from the query result. Layout reshapes and added elements
|
|
127
|
+
use the same sanitized DSL as the rest of Morph.
|
|
128
|
+
|
|
129
|
+
## Try it
|
|
130
|
+
|
|
131
|
+
The repository ships a fake CRM with Morph embedded —
|
|
132
|
+
[`sdk/demo-crm/`](https://github.com/mandarwagh9/morph/tree/master/sdk/demo-crm)
|
|
133
|
+
— seeded with deals data. Its `app.js` is the reference integration; the golden
|
|
134
|
+
path ("add a box showing how much we lost in the last 15 days" → real widget →
|
|
135
|
+
survives reload) is documented in its README.
|
|
136
|
+
|
|
137
|
+
## Status & keys
|
|
138
|
+
|
|
139
|
+
Morph Embed is in **early access**. Publishable keys are provisioned manually
|
|
140
|
+
while we onboard the first integrations — open an issue on
|
|
141
|
+
[GitHub](https://github.com/mandarwagh9/morph/issues) or reach out via
|
|
142
|
+
[usemorph.xyz](https://usemorph.xyz) and we'll set you up (origins allowlist +
|
|
143
|
+
rate limits included).
|
|
144
|
+
|
|
145
|
+
Morph is also a [browser extension](https://usemorph.xyz) that reshapes any
|
|
146
|
+
website the same way — same engine, same security model.
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT © Mandar Wagh — see [LICENSE](./LICENSE). (The `morph-embed` package is
|
|
151
|
+
MIT-licensed; the Morph backend service and the wider repository are licensed
|
|
152
|
+
separately.)
|