@sable-ai/sdk-core 0.1.2 → 0.1.4
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/README.md +71 -21
- package/dist/esm/index.js +1 -1
- package/dist/sable-core.mjs +1486 -0
- package/dist/sable.iife.js +1 -1486
- package/dist/types/loader.d.ts +23 -0
- package/dist/types/session/index.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -3
- package/src/index.test.ts +2 -2
- package/src/loader.ts +143 -0
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
# @sable-ai/sdk-core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
agent worker
|
|
3
|
+
Browser runtime for Sable: joins a LiveKit room and lets users talk to an
|
|
4
|
+
agent worker with optional vision + browser-bridge tools. Ships as a
|
|
5
|
+
Stripe.js-style split bundle:
|
|
6
|
+
|
|
7
|
+
| File | Size (gzipped) | When it loads |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `sable.js` (loader) | **~530 B** | Page load |
|
|
10
|
+
| `sable-core.mjs` (full SDK, livekit inlined) | ~150 KB | First `Sable.start()` call |
|
|
11
|
+
|
|
12
|
+
Pages that never open a session pay only the loader cost.
|
|
5
13
|
|
|
6
14
|
## Install
|
|
7
15
|
|
|
16
|
+
### Script tag (recommended for no-build sites + extensions)
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<script src="https://sdk.withsable.com/v0.1.4/sable.js"></script>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The loader installs `window.Sable` synchronously. On the first
|
|
23
|
+
`Sable.start()` call it lazy-imports `sable-core.mjs` from the same CDN
|
|
24
|
+
path and forwards the call.
|
|
25
|
+
|
|
26
|
+
Available CDN pins:
|
|
27
|
+
|
|
28
|
+
| Path | Cache | Use case |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `https://sdk.withsable.com/v0.1.4/sable.js` | 1 year, immutable | **Recommended for production** — exact version pin |
|
|
31
|
+
| `https://sdk.withsable.com/v1/sable.js` | 1 hour | Latest 0.x (accepts patch releases automatically) |
|
|
32
|
+
| `https://sdk.withsable.com/latest/sable.js` | 5 minutes | Demos and smoke tests only |
|
|
33
|
+
|
|
34
|
+
### npm (ESM)
|
|
35
|
+
|
|
8
36
|
```bash
|
|
9
37
|
bun add @sable-ai/sdk-core
|
|
10
38
|
```
|
|
11
39
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
```js
|
|
41
|
+
import Sable from "@sable-ai/sdk-core";
|
|
42
|
+
// Importing also installs window.Sable (first-write-wins), so mixed
|
|
43
|
+
// script-tag + npm usage on the same page stays coherent.
|
|
16
44
|
```
|
|
17
45
|
|
|
46
|
+
The npm build keeps `livekit-client` as an external peer so your bundler
|
|
47
|
+
can dedupe it.
|
|
48
|
+
|
|
18
49
|
## Usage
|
|
19
50
|
|
|
20
51
|
```js
|
|
21
52
|
await window.Sable.start({
|
|
22
53
|
agentPublicId: "agt_...",
|
|
23
|
-
apiUrl: "https://sable-api-gateway-9dfmhij9.wl.gateway.dev", // optional,
|
|
54
|
+
apiUrl: "https://sable-api-gateway-9dfmhij9.wl.gateway.dev", // optional, default
|
|
24
55
|
nickelRegion: "us-east1", // optional
|
|
25
56
|
});
|
|
26
57
|
|
|
@@ -29,7 +60,25 @@ await window.Sable.start({
|
|
|
29
60
|
await window.Sable.stop();
|
|
30
61
|
```
|
|
31
62
|
|
|
32
|
-
|
|
63
|
+
`Sable.on(event, handler)` subscriptions registered before `start()`
|
|
64
|
+
resolves are buffered by the loader and flushed onto the real session
|
|
65
|
+
once `sable-core.mjs` finishes loading.
|
|
66
|
+
|
|
67
|
+
## Architecture
|
|
68
|
+
|
|
69
|
+
The loader is a tiny IIFE proxy (`src/loader.ts`) that:
|
|
70
|
+
|
|
71
|
+
1. Captures `document.currentScript.src` synchronously at top-level
|
|
72
|
+
(the only time `currentScript` is defined).
|
|
73
|
+
2. Installs `window.Sable` with stub `start/stop/on` methods.
|
|
74
|
+
3. On first `start()`, resolves `new URL("./sable-core.mjs", scriptSrc)`
|
|
75
|
+
and dynamically imports it — so `/v0.1.4/sable.js` always pulls
|
|
76
|
+
`/v0.1.4/sable-core.mjs`. Version cohesion is automatic.
|
|
77
|
+
4. Memoises the import and flushes any queued `on()` subscriptions.
|
|
78
|
+
|
|
79
|
+
See `docs/superpowers/specs/` and `infra/cdn/README.md` for more.
|
|
80
|
+
|
|
81
|
+
## Local development
|
|
33
82
|
|
|
34
83
|
```bash
|
|
35
84
|
bun install
|
|
@@ -37,19 +86,20 @@ bun run --filter @sable-ai/sdk-core build
|
|
|
37
86
|
python3 -m http.server 5173 --directory packages/sdk-core
|
|
38
87
|
```
|
|
39
88
|
|
|
40
|
-
Open `http://localhost:5173/examples/test.html`, paste an agent public
|
|
41
|
-
Grant mic permission when prompted.
|
|
42
|
-
|
|
89
|
+
Open `http://localhost:5173/examples/test.html`, paste an agent public
|
|
90
|
+
ID, click Start. Grant mic permission when prompted.
|
|
91
|
+
|
|
92
|
+
**Only `http://localhost:*` origins work against the hosted API** —
|
|
93
|
+
`sable-api`'s CORS policy does not yet allow arbitrary origins.
|
|
43
94
|
|
|
44
|
-
|
|
45
|
-
does not yet allow arbitrary origins. See the v0 spec at
|
|
46
|
-
`docs/superpowers/specs/2026-04-07-sdk-voice-integration-design.md` for the
|
|
47
|
-
deferred per-org allowed-origins work.
|
|
95
|
+
## Releasing
|
|
48
96
|
|
|
49
|
-
|
|
97
|
+
Tagging `sdk-core-v<x.y.z>` triggers `.github/workflows/release-sdk-core.yml`
|
|
98
|
+
which:
|
|
50
99
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
100
|
+
1. Runs typecheck + tests + build.
|
|
101
|
+
2. Publishes to npm with OIDC trusted-publisher provenance.
|
|
102
|
+
3. Stages `dist/sable.iife.js` + `dist/sable-core.mjs` under
|
|
103
|
+
`/v<version>/`, `/v1/`, and `/latest/` via `infra/cdn/stage.sh`.
|
|
104
|
+
4. Deploys the staged directory to Cloudflare Pages
|
|
105
|
+
(`sable-sdk-cdn` project, custom domain `sdk.withsable.com`).
|
package/dist/esm/index.js
CHANGED