@escapeaihq/client-core 0.4.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -0
  3. package/dist/api.d.ts +836 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +781 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/audio.d.ts +278 -0
  8. package/dist/audio.d.ts.map +1 -0
  9. package/dist/audio.js +758 -0
  10. package/dist/audio.js.map +1 -0
  11. package/dist/audioProtocol.d.ts +101 -0
  12. package/dist/audioProtocol.d.ts.map +1 -0
  13. package/dist/audioProtocol.js +62 -0
  14. package/dist/audioProtocol.js.map +1 -0
  15. package/dist/index.d.ts +28 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +28 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/visemeGeometry.d.ts +198 -0
  20. package/dist/visemeGeometry.d.ts.map +1 -0
  21. package/dist/visemeGeometry.js +297 -0
  22. package/dist/visemeGeometry.js.map +1 -0
  23. package/dist/visemeScheduler.d.ts +28 -0
  24. package/dist/visemeScheduler.d.ts.map +1 -0
  25. package/dist/visemeScheduler.js +94 -0
  26. package/dist/visemeScheduler.js.map +1 -0
  27. package/dist/websocket.d.ts +196 -0
  28. package/dist/websocket.d.ts.map +1 -0
  29. package/dist/websocket.js +250 -0
  30. package/dist/websocket.js.map +1 -0
  31. package/package.json +40 -0
  32. package/src/__tests__/api-pollers.test.ts +524 -0
  33. package/src/__tests__/audio.test.ts +714 -0
  34. package/src/__tests__/visemeGeometry.test.ts +465 -0
  35. package/src/__tests__/visemeScheduler.test.ts +256 -0
  36. package/src/api.ts +1577 -0
  37. package/src/audio.ts +934 -0
  38. package/src/audioProtocol.ts +163 -0
  39. package/src/index.ts +28 -0
  40. package/src/visemeGeometry.ts +353 -0
  41. package/src/visemeScheduler.ts +133 -0
  42. package/src/websocket.ts +385 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Filip Iliescu
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,122 @@
1
+ # @escapeaihq/client-core
2
+
3
+ Framework-agnostic Seer client building blocks. Vanilla TypeScript, no React or Vue dependencies. Imported by both seer-agent's React `web/` app (this monorepo) and the Vue Escape `web-app` (sibling repo).
4
+
5
+ ## Module format
6
+
7
+ ESM-only. The published `package.json` points `exports[".".import]` at `./dist/index.js` and `exports[".".types]` at `./dist/index.d.ts` — there's no CJS `require` path. Both current consumers are ESM-default (Next.js 15 + React, Nuxt 3 + Vue + Vite), so this is fine. If a future CJS consumer (older Jest config, Node CLI script) appears, add a CJS bundle to the build (`tsup` or similar dual-output) before it bites.
8
+
9
+ ## What's in here
10
+
11
+ | Module | What it does |
12
+ |---|---|
13
+ | `audioProtocol` | Binary audio frame codec (1-byte tag + 320 samples PCM16); type defs for phoneme/word/barge-in messages |
14
+ | `audio` | `MicrophoneRecorder`, `AudioFramePlayer`, `PlaybackTracker`, `AudioSessionClient`, `AudioPipeline`. Web Audio API based. Clean barge-in via `GainNode` + tracked `activeSources`. Sentence-boundary viseme scheduling. |
15
+ | `visemeScheduler` | Maps Inworld TTS 1.5 phoneme timing to mouth shape changes via `requestAnimationFrame`, locked to `AudioContext.currentTime`. Stops the loop when idle. |
16
+ | `visemeGeometry` | Pure path math: derive inner-lip donut, mouth clip ellipse, teeth/tongue geometry from existing `mouth_paths` data |
17
+ | `websocket` | `ChatWebSocket` — auto-reconnecting wrapper around native WebSocket with text/binary multiplexing |
18
+ | `api` | `ApiClient` REST client + all backend response/request type definitions. Constructor takes `baseURL` and `chatBaseUrl` from the caller (no env-var coupling). Image-tool wrappers since 0.3.0: `extractImage`, `regenerateImage`, `pollVisemeBundleUntilDone`. See [CHANGELOG.md](./CHANGELOG.md). |
19
+
20
+ ## Layout
21
+
22
+ ```
23
+ src/
24
+ audioProtocol.ts
25
+ audio.ts
26
+ visemeScheduler.ts
27
+ visemeGeometry.ts
28
+ websocket.ts
29
+ api.ts
30
+ index.ts ← re-exports
31
+ __tests__/
32
+ audio.test.ts
33
+ visemeScheduler.test.ts
34
+ visemeGeometry.test.ts
35
+ ```
36
+
37
+ ## Consumption — locally in this repo
38
+
39
+ The repo root is an npm workspace covering `packages/*` (client-core's own dev tooling). `web/` is **not** a workspace member — it depends on this package via `"@escapeaihq/client-core": "file:../packages/client-core"`, which makes npm create a symlink in `web/node_modules/@escapeaihq/client-core`. Edits here show up in `web/` immediately. Next.js compiles the TS source through `transpilePackages: ['@escapeaihq/client-core']`, so no build step is required during dev.
40
+
41
+ Web was deliberately moved out of the root workspace: npm's workspace lockfiles strict-filter platform-specific optional deps, and a lockfile generated on macOS would break `next build` on Vercel/Linux when it couldn't resolve `lightningcss-linux-x64-gnu`. The `file:` symlink gives the same dev experience without polluting web's lockfile.
42
+
43
+ ## Consumption — sibling repo (web-app)
44
+
45
+ For the sibling Vue `web-app`, two flows:
46
+
47
+ **Production / CI:** install the published artifact from the registry. `package.json` declares `"@escapeaihq/client-core": "^x.y.z"`.
48
+
49
+ **Local dev with live edits:** symlink via `npm link` so edits in this repo are picked up immediately:
50
+
51
+ ```bash
52
+ # one-time setup, after both repos are cloned side-by-side
53
+ cd ~/projects/seer-agent/packages/client-core && npm link
54
+ cd ~/projects/web-app && npm link @escapeaihq/client-core
55
+ ```
56
+
57
+ Unlink with `npm unlink @escapeaihq/client-core` to fall back to the registry version.
58
+
59
+ ## Where to run `npm install` when adding/upgrading deps
60
+
61
+ The repo deliberately runs three install lifecycles, one per consumer:
62
+
63
+ | Goal | Command | Lockfile that gets updated |
64
+ |---|---|---|
65
+ | Add/upgrade a dep used by `@escapeaihq/client-core` (jest, ts-jest, typescript, etc.) | `npm install <pkg> --workspace=@escapeaihq/client-core` (from repo root) | repo-root `package-lock.json` |
66
+ | Add/upgrade a dep used by `web/` (Next.js, React, Tailwind, etc.) | `cd web && npm install <pkg>` | `web/package-lock.json` |
67
+ | Pull in remote changes after a branch update | `npm ci` from repo root, then `cd web && npm ci` | both — neither lockfile is rewritten |
68
+
69
+ `web/` is not a workspace member (the cross-platform optional-deps issue described above), so `npm install` at the repo root will *not* refresh `web/node_modules`. Always run installs in `web/` separately.
70
+
71
+ ## Build & publish
72
+
73
+ `package.json` uses the `publishConfig` override pattern: in dev (workspace consumption) `main` and `types` resolve to `./src/index.ts`; on `npm publish` they're rewritten to `./dist/index.js` and `./dist/index.d.ts`.
74
+
75
+ ```bash
76
+ # from the package directory
77
+ npm run typecheck # tsc -p tsconfig.json --noEmit
78
+ npm test # jest (jsdom)
79
+ npm run build # tsc -p tsconfig.build.json → dist/
80
+ npm publish # uses publishConfig overrides
81
+ ```
82
+
83
+ ### Cutting a release
84
+
85
+ CI publishes to GitHub Packages on every push of a `client-core-v*` tag (`.github/workflows/publish-client-core.yml`). The flow:
86
+
87
+ ```bash
88
+ # 1. bump version in packages/client-core/package.json (semver)
89
+ # 2. commit the bump on main
90
+ git commit -am "client-core: release v0.1.1"
91
+ # 3. tag and push — the tag triggers the publish workflow
92
+ git tag client-core-v0.1.1
93
+ git push origin main client-core-v0.1.1
94
+ ```
95
+
96
+ The workflow runs `npm ci` at the repo root, runs `npm --workspace=@escapeaihq/client-core run typecheck`, `test`, and `build`, then `npm publish --workspace=@escapeaihq/client-core`. Auth uses the auto-issued `GITHUB_TOKEN`. Versions are manual; revisit changesets when ≥2 external consumers exist.
97
+
98
+ **Semver policy (manual bumps):**
99
+
100
+ | Bump | When |
101
+ |---|---|
102
+ | **Patch** (0.x.Z) | Bug fix in an existing function; new internal helper; documentation; tests; non-API-visible refactor. |
103
+ | **Minor** (0.Y.0) | New exported function/class/type; new optional parameter; new module under `src/`. |
104
+ | **Major** (X.0.0 — pre-1.0 still bumps the leading 0.) | Renamed/removed exported symbol; required argument added or order changed (e.g. `ApiClient` constructor in 1a.1); changed return type or thrown errors that consumers branch on. |
105
+
106
+ While this is `0.x`, the package is pre-stable: any release may include breaking changes in the constructor signatures of `ApiClient`, `AudioPipeline`, etc. — consumers should pin to an exact version (`"@escapeaihq/client-core": "0.1.0"`, no caret) until `1.0`.
107
+
108
+ ## What does NOT belong here
109
+
110
+ - React or Vue components, hooks, or composables — those live with their consumer
111
+ - App-specific config (env vars, base URLs) — pass them in via constructor args
112
+ - Any DOM rendering beyond what's needed for Web Audio / Web Animations / WebSocket APIs
113
+
114
+ ## Testing
115
+
116
+ Jest with `ts-jest/presets/default-esm` and `jsdom` environment. Tests live next to source under `src/__tests__/`. Run from this directory:
117
+
118
+ ```bash
119
+ npm test
120
+ # or from monorepo root
121
+ npm run test:client-core
122
+ ```