@mirasoth/soothe-client 0.2.1 → 0.4.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/README.md +81 -47
- package/dist/{chunk-AQZACDIC.js → chunk-YYUVHZ3W.js} +607 -31
- package/dist/chunk-YYUVHZ3W.js.map +1 -0
- package/dist/client-SOJZSF7C.js +7 -0
- package/dist/index.cjs +1568 -298
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +355 -136
- package/dist/index.d.ts +355 -136
- package/dist/index.js +988 -258
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
- package/dist/chunk-AQZACDIC.js.map +0 -1
- package/dist/client-CB6WKQYW.js +0 -7
- /package/dist/{client-CB6WKQYW.js.map → client-SOJZSF7C.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,82 +1,116 @@
|
|
|
1
1
|
# @mirasoth/soothe-client
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Provides a typed message protocol, session bootstrap, event helpers, and convenience RPCs for
|
|
6
|
-
interacting with a running `soothe-daemon` from Node.js.
|
|
7
|
-
|
|
8
|
-
## Install
|
|
3
|
+
Talk to a running **soothe-daemon** over WebSocket — send prompts, stream agent
|
|
4
|
+
turns, run jobs.
|
|
9
5
|
|
|
10
6
|
```bash
|
|
11
7
|
npm install @mirasoth/soothe-client
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
# or
|
|
15
|
-
yarn add @mirasoth/soothe-client
|
|
8
|
+
# optional: real image downscale for CompactAttachmentsBeforeSend
|
|
9
|
+
npm install sharp
|
|
16
10
|
```
|
|
17
11
|
|
|
18
|
-
Requires Node.js `>=19
|
|
12
|
+
Requires Node.js `>=19` and a local daemon (default `ws://127.0.0.1:8765`).
|
|
19
13
|
|
|
20
14
|
## Quick start
|
|
21
15
|
|
|
22
16
|
```ts
|
|
23
|
-
import {
|
|
17
|
+
import { DaemonSession } from '@mirasoth/soothe-client';
|
|
18
|
+
|
|
19
|
+
const session = new DaemonSession('ws://127.0.0.1:8765');
|
|
20
|
+
await session.connect();
|
|
21
|
+
await session.sendTurn('Summarize this in one sentence: agents need tools.');
|
|
22
|
+
|
|
23
|
+
for await (const [_namespace, mode, data] of session.iterTurnChunks()) {
|
|
24
|
+
console.log(mode, data);
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
await session.close();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
More patterns: [`examples/`](examples/) (hello → streaming → multi-turn → pool → jobs).
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
const loopId = await bootstrapLoopSession(client, null, config);
|
|
32
|
+
## What you get
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
| Need | Use |
|
|
35
|
+
|------|-----|
|
|
36
|
+
| One conversation, stream replies | `DaemonSession` |
|
|
37
|
+
| Jobs / cron one-shots | `CommandClient` |
|
|
38
|
+
| Raw WebSocket / custom RPCs | `Client` |
|
|
39
|
+
| Many users / HTTP backend | `ConnectionPool` + `TurnRunner` |
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
`iterTurnChunks` peels leftover prior-goal terminals at turn start, ignores
|
|
42
|
+
premature `soothe.stream.end` until the turn has real progress, drains a short
|
|
43
|
+
post-idle window, and sends `delivery_ack` on terminal frames for daemon drain
|
|
44
|
+
gating.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { CommandClient } from '@mirasoth/soothe-client';
|
|
48
|
+
|
|
49
|
+
const cc = new CommandClient('ws://127.0.0.1:8765', { timeoutMs: 30_000 });
|
|
50
|
+
const created = await cc.jobCreate('Echo: smoke job', '/tmp/workspace');
|
|
51
|
+
await cc.jobStatus(String(created.job_id));
|
|
52
|
+
await cc.jobCancel(String(created.job_id));
|
|
40
53
|
```
|
|
41
54
|
|
|
55
|
+
## Appkit TurnRunner
|
|
56
|
+
|
|
57
|
+
Product backends that pool connections per chat session use `ConnectionPool` +
|
|
58
|
+
`QueryGate` + `TurnRunner` + `EventClassifier`.
|
|
59
|
+
|
|
60
|
+
| Knob | Default | Notes |
|
|
61
|
+
|------|---------|--------|
|
|
62
|
+
| `idleTimeout` | off (`0`) | Silence watchdog between events (ms) |
|
|
63
|
+
| `minIdleTimeoutWithAttachments` | off | Floor when attachments are present |
|
|
64
|
+
| `onIdleTimeout` / `onQueryTimeout` / `onStreamClose` | `Fail` | Or `SoftComplete` |
|
|
65
|
+
| `compactAttachmentsBeforeSend` | `false` | Needs optional `sharp` for real downscale |
|
|
66
|
+
| `treatStatusIdleAsComplete` (classifier) | `false` | Opt-in idle deliverable |
|
|
67
|
+
|
|
42
68
|
## Configuration
|
|
43
69
|
|
|
44
|
-
`defaultConfig()`
|
|
45
|
-
overrides from these environment variables:
|
|
70
|
+
`defaultConfig()` / `loadConfigFromEnv()`:
|
|
46
71
|
|
|
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`
|
|
72
|
+
| Variable | Default | Description |
|
|
73
|
+
|----------|---------|-------------|
|
|
74
|
+
| `SOOTHE_DAEMON_URL` | `ws://localhost:8765` | Daemon WebSocket URL |
|
|
75
|
+
| `SOOTHE_VERBOSITY` | `normal` | quiet / minimal / normal / detailed / debug |
|
|
76
|
+
| `SOOTHE_MAX_RETRIES` | `5` | Reconnect attempts |
|
|
77
|
+
| `SOOTHE_DAEMON_READY_TIMEOUT_SEC` | `20` | Handshake timeout |
|
|
78
|
+
| `SOOTHE_LOOP_STATUS_TIMEOUT_SEC` | `60` | Loop status wait |
|
|
79
|
+
| `SOOTHE_SUBSCRIPTION_TIMEOUT_SEC` | `10` | Subscription confirmation |
|
|
55
80
|
|
|
56
81
|
## API surface
|
|
57
82
|
|
|
58
|
-
- **`
|
|
59
|
-
- **`
|
|
60
|
-
- **`
|
|
61
|
-
- **`
|
|
62
|
-
- **`
|
|
63
|
-
- **`
|
|
64
|
-
- **Errors** — `ConnectionError`, `DaemonError`, `TimeoutError`
|
|
83
|
+
- **`DaemonSession`** — dual-socket loop session + `iterTurnChunks` (preferred for chat)
|
|
84
|
+
- **`CommandClient`** — ephemeral connect → one RPC → close (jobs / cron)
|
|
85
|
+
- **`Client`** — long-lived WebSocket, RPC, reconnect/reattach, peel-stale helpers
|
|
86
|
+
- **`ConnectionPool` / `TurnRunner` / `QueryGate` / `EventClassifier` / `SSEBroadcaster`** — multi-user appkit
|
|
87
|
+
- **`connectedWebsocket` / `protocol1Rpc`** — oneshot CLI-style helpers
|
|
88
|
+
- **`bootstrapLoopSession` / `connectWithRetries`** — session helpers
|
|
65
89
|
|
|
66
|
-
See `dist/index.d.ts`
|
|
90
|
+
See `dist/index.d.ts` or `src/index.ts` for the full export list.
|
|
67
91
|
|
|
68
|
-
##
|
|
92
|
+
## Limitations
|
|
93
|
+
|
|
94
|
+
Autopilot control is WebSocket-only (protocol-1 `autopilot_*` / `job_*`
|
|
95
|
+
request RPCs). Prefer `CommandClient` for job/cron/autopilot one-shots so they
|
|
96
|
+
do not share a streaming socket. Worker event streams use
|
|
97
|
+
`client.autopilotSubscribe()` on a long-lived `Client`.
|
|
98
|
+
|
|
99
|
+
## Develop
|
|
69
100
|
|
|
70
101
|
```bash
|
|
71
|
-
make help # list
|
|
102
|
+
make help # list targets
|
|
72
103
|
make install # install dependencies
|
|
73
104
|
make build # compile to dist/
|
|
74
|
-
make test #
|
|
105
|
+
make test # unit tests
|
|
75
106
|
make verify # full pre-publish verification
|
|
76
|
-
|
|
107
|
+
npm test -- examples/progressive # 01–06 ladder (offline)
|
|
77
108
|
```
|
|
78
109
|
|
|
79
|
-
|
|
110
|
+
## Compatibility
|
|
111
|
+
|
|
112
|
+
Same protocol-1 WebSocket contract as `soothe-client-python` and
|
|
113
|
+
`soothe-client-go`.
|
|
80
114
|
|
|
81
115
|
## License
|
|
82
116
|
|