@mirasoth/soothe-client 0.1.0 → 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.
- package/README.md +59 -43
- package/dist/chunk-U6RMINYV.js +1883 -0
- package/dist/chunk-U6RMINYV.js.map +1 -0
- package/dist/client-UNPC32NQ.js +7 -0
- package/dist/index.cjs +3677 -584
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1279 -280
- package/dist/index.d.ts +1279 -280
- package/dist/index.js +2098 -243
- package/dist/index.js.map +1 -1
- package/package.json +37 -8
- package/dist/chunk-OMAC7LA7.js +0 -647
- package/dist/chunk-OMAC7LA7.js.map +0 -1
- package/dist/client-QS23U6WX.js +0 -7
- /package/dist/{client-QS23U6WX.js.map → client-UNPC32NQ.js.map} +0 -0
package/README.md
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript WebSocket client for the [Soothe](https://github.com/mirasoth/soothe) daemon.
|
|
4
4
|
|
|
5
|
-
Provides a typed message
|
|
6
|
-
|
|
5
|
+
Provides a typed protocol-1 message stack, session bootstrap, reconnect/reattach,
|
|
6
|
+
appkit (connection pool, turn runner, event classifier), and a dual-socket
|
|
7
|
+
`DaemonSession` for streamed turns — matching the production Go and Python clients.
|
|
7
8
|
|
|
8
9
|
## Install
|
|
9
10
|
|
|
10
11
|
```bash
|
|
11
12
|
npm install @mirasoth/soothe-client
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
# or
|
|
15
|
-
yarn add @mirasoth/soothe-client
|
|
13
|
+
# optional: real image downscale for CompactAttachmentsBeforeSend
|
|
14
|
+
npm install sharp
|
|
16
15
|
```
|
|
17
16
|
|
|
18
17
|
Requires Node.js `>=19`.
|
|
@@ -20,64 +19,81 @@ Requires Node.js `>=19`.
|
|
|
20
19
|
## Quick start
|
|
21
20
|
|
|
22
21
|
```ts
|
|
23
|
-
import {
|
|
22
|
+
import { DaemonSession } from '@mirasoth/soothe-client';
|
|
24
23
|
|
|
25
|
-
const
|
|
26
|
-
|
|
24
|
+
const session = new DaemonSession('ws://127.0.0.1:8765');
|
|
25
|
+
await session.connect();
|
|
26
|
+
await session.sendTurn('summarize this repo');
|
|
27
27
|
|
|
28
|
-
await
|
|
29
|
-
|
|
28
|
+
for await (const [namespace, mode, data] of session.iterTurnChunks()) {
|
|
29
|
+
console.log(mode, data);
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
console.log('event:', msg);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
await client.sendMessage({
|
|
36
|
-
type: 'loop_input',
|
|
37
|
-
loop_id: loopId,
|
|
38
|
-
input: 'hello soothe',
|
|
39
|
-
});
|
|
32
|
+
await session.close();
|
|
40
33
|
```
|
|
41
34
|
|
|
35
|
+
## What you get
|
|
36
|
+
|
|
37
|
+
| Need | Use |
|
|
38
|
+
|------|-----|
|
|
39
|
+
| One conversation, stream replies | `DaemonSession` |
|
|
40
|
+
| Jobs / cron one-shots | `CommandClient` |
|
|
41
|
+
| Raw WebSocket / custom RPCs | `Client` |
|
|
42
|
+
| Many users / HTTP backend | `ConnectionPool` + `TurnRunner` |
|
|
43
|
+
|
|
44
|
+
`iterTurnChunks` peels leftover prior-goal terminals at turn start, ignores
|
|
45
|
+
premature `soothe.stream.end` until the turn has real progress, and drains a
|
|
46
|
+
short post-idle window before returning. Terminal stream frames send
|
|
47
|
+
`delivery_ack` (daemon drain gating).
|
|
48
|
+
|
|
49
|
+
## Appkit TurnRunner
|
|
50
|
+
|
|
51
|
+
Product backends that pool connections per chat session use `ConnectionPool` +
|
|
52
|
+
`QueryGate` + `TurnRunner` + `EventClassifier` (RFC-629 Layer 1).
|
|
53
|
+
|
|
54
|
+
Lifecycle knobs (all opt-in; defaults match historical fail-on-timeout behaviour):
|
|
55
|
+
|
|
56
|
+
| Knob | Default | Notes |
|
|
57
|
+
|------|---------|--------|
|
|
58
|
+
| `idleTimeout` | off (`0`) | Silence watchdog between events (ms) |
|
|
59
|
+
| `minIdleTimeoutWithAttachments` | off | Floor when attachments are present |
|
|
60
|
+
| `onIdleTimeout` / `onQueryTimeout` / `onStreamClose` | `Fail` | Or `SoftComplete` |
|
|
61
|
+
| `compactAttachmentsBeforeSend` | `false` | Needs optional `sharp` for real downscale |
|
|
62
|
+
| `treatStatusIdleAsComplete` (classifier) | `false` | Opt-in idle deliverable |
|
|
63
|
+
|
|
42
64
|
## Configuration
|
|
43
65
|
|
|
44
|
-
`defaultConfig()`
|
|
45
|
-
overrides from these environment variables:
|
|
66
|
+
`defaultConfig()` / `loadConfigFromEnv()`:
|
|
46
67
|
|
|
47
|
-
| Variable
|
|
48
|
-
|
|
49
|
-
| `SOOTHE_DAEMON_URL`
|
|
50
|
-
| `SOOTHE_VERBOSITY`
|
|
51
|
-
| `SOOTHE_MAX_RETRIES`
|
|
52
|
-
| `SOOTHE_DAEMON_READY_TIMEOUT_SEC`
|
|
53
|
-
| `SOOTHE_LOOP_STATUS_TIMEOUT_SEC`
|
|
54
|
-
| `SOOTHE_SUBSCRIPTION_TIMEOUT_SEC`
|
|
68
|
+
| Variable | Default | Description |
|
|
69
|
+
|----------|---------|-------------|
|
|
70
|
+
| `SOOTHE_DAEMON_URL` | `ws://localhost:8765` | Daemon WebSocket URL |
|
|
71
|
+
| `SOOTHE_VERBOSITY` | `normal` | quiet / minimal / normal / detailed / debug |
|
|
72
|
+
| `SOOTHE_MAX_RETRIES` | `5` | Reconnect attempts |
|
|
73
|
+
| `SOOTHE_DAEMON_READY_TIMEOUT_SEC` | `20` | Handshake timeout |
|
|
74
|
+
| `SOOTHE_LOOP_STATUS_TIMEOUT_SEC` | `60` | Loop status wait |
|
|
75
|
+
| `SOOTHE_SUBSCRIPTION_TIMEOUT_SEC` | `10` | Subscription confirmation |
|
|
55
76
|
|
|
56
77
|
## API surface
|
|
57
78
|
|
|
58
|
-
- **`Client`** — WebSocket session,
|
|
59
|
-
- **`
|
|
60
|
-
- **`
|
|
61
|
-
- **`
|
|
62
|
-
- **`
|
|
63
|
-
- **`VerbosityTier`**, **`classifyEventVerbosity`** — verbosity filtering
|
|
64
|
-
- **Errors** — `ConnectionError`, `DaemonError`, `TimeoutError`
|
|
79
|
+
- **`Client`** — WebSocket session, RPC, reconnect/reattach, peel stale pending frames
|
|
80
|
+
- **`DaemonSession`** — dual-socket loop session + `iterTurnChunks`
|
|
81
|
+
- **`TurnRunner` / `ConnectionPool` / `QueryGate` / `EventClassifier` / `SSEBroadcaster`** — appkit
|
|
82
|
+
- **`connectedWebsocket` / `protocol1Rpc`** — oneshot CLI-style helpers
|
|
83
|
+
- **`bootstrapLoopSession`**, **`connectWithRetries`** — session helpers
|
|
65
84
|
|
|
66
|
-
See `dist/index.d.ts`
|
|
85
|
+
See `dist/index.d.ts` or `src/index.ts` for the full export list.
|
|
67
86
|
|
|
68
87
|
## Development
|
|
69
88
|
|
|
70
89
|
```bash
|
|
71
|
-
make help # list
|
|
90
|
+
make help # list targets
|
|
72
91
|
make install # install dependencies
|
|
73
92
|
make build # compile to dist/
|
|
74
|
-
make test #
|
|
93
|
+
make test # unit tests
|
|
75
94
|
make verify # full pre-publish verification
|
|
76
|
-
make publish # publish to npm (after verify)
|
|
77
95
|
```
|
|
78
96
|
|
|
79
|
-
See [`Makefile`](./Makefile) for the complete list of targets.
|
|
80
|
-
|
|
81
97
|
## License
|
|
82
98
|
|
|
83
99
|
MIT — see [LICENSE](./LICENSE).
|