@mirasoth/soothe-client 0.4.0 → 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/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
 
3
3
  /**
4
- * Custom error types for the Soothe client (RFC-450 protocol-1).
4
+ * Custom error types for the Soothe client.
5
5
  */
6
6
  /** Represents a WebSocket connection failure. */
7
7
  declare class ConnectionError extends Error {
@@ -11,13 +11,13 @@ declare class ConnectionError extends Error {
11
11
  constructor(url: string, attempt: number, cause: Error);
12
12
  }
13
13
  /**
14
- * Represents an error reported by the Soothe daemon (RFC-450 §7).
14
+ * Represents an error reported by the Soothe daemon.
15
15
  *
16
16
  * The daemon's structured error object carries a numeric `code` from the
17
17
  * reserved ranges, a human-readable `message`, and optional `data`.
18
18
  */
19
19
  declare class DaemonError extends Error {
20
- /** Numeric error code from the RFC-450 §7.3 registry. */
20
+ /** Numeric error code from the daemon error registry. */
21
21
  readonly code: number;
22
22
  /** The daemon's error message text. */
23
23
  readonly daemonMessage: string;
@@ -32,7 +32,7 @@ declare class TimeoutError extends Error {
32
32
  constructor(operation: string, duration: string);
33
33
  }
34
34
  /**
35
- * Distinguishes clean vs unclean connection loss (RFC-450 §4, §8.3).
35
+ * Distinguishes clean vs unclean connection loss.
36
36
  *
37
37
  * A clean drop follows a `disconnect` notification (loops keep running
38
38
  * server-side); an unclean drop is a read/write error or a missed pong
@@ -40,9 +40,9 @@ declare class TimeoutError extends Error {
40
40
  * event: the cause is emitted exactly once when the connection drops.
41
41
  */
42
42
  declare enum DisconnectCause {
43
- /** Abrupt loss: read/write error or missed pong (RFC-450 §8.3). */
43
+ /** Abrupt loss: read/write error or missed pong. */
44
44
  Unclean = 0,
45
- /** Graceful peer-initiated `disconnect` notification (RFC-450 §9.2). */
45
+ /** Graceful peer-initiated `disconnect` notification. */
46
46
  Clean = 1
47
47
  }
48
48
  /** Human-readable cause name for logging. */
@@ -155,22 +155,22 @@ declare const DEFAULT_DELIVERABLE_PHASES: ReadonlySet<string>;
155
155
 
156
156
  /**
157
157
  * Protocol-1 wire envelope: message types, encode/decode, NDJSON splitting,
158
- * and factory functions for the Soothe daemon (RFC-450).
158
+ * and factory functions for the Soothe daemon.
159
159
  *
160
160
  * The unified `{proto, type, method, params, id}` envelope combines
161
161
  * JSON-RPC 2.0's `method`/`params`/`id` structure with graphql-ws's `type`
162
162
  * semantics for message class distinction.
163
163
  */
164
164
 
165
- /** Protocol version string (RFC-450 §8.1). */
165
+ /** Protocol version string. */
166
166
  declare const PROTO_VERSION = "1";
167
167
  /** Default client capabilities declared in the connection_init handshake. */
168
168
  declare const DEFAULT_CLIENT_CAPABILITIES: string[];
169
169
  /** Client version reported in the connection_init handshake. */
170
- declare const CLIENT_VERSION = "0.4.0";
170
+ declare const CLIENT_VERSION = "0.4.1";
171
171
  type MessageType = "connection_init" | "connection_ack" | "request" | "response" | "notification" | "subscribe" | "next" | "error" | "complete" | "unsubscribe" | "ping" | "pong" | "receipt_response" | "disconnect" | "status";
172
- /** Method names carried in the envelope `method` field (RFC-450 §9.2). */
173
- type MethodName = "loop_list" | "loop_get" | "loop_tree" | "loop_prune" | "loop_delete" | "loop_new" | "loop_reattach" | "loop_detach" | "loop_input" | "loop_messages" | "loop_state_get" | "loop_state_update" | "loop_cards_fetch" | "loop_history_fetch" | "loop_events" | "autopilot_events" | "job_create" | "job_status" | "job_pause" | "job_resume" | "job_cancel" | "job_dag" | "job_guidance" | "daemon_status" | "daemon_shutdown" | "config_get" | "config_reload" | "skills_list" | "invoke_skill" | "models_list" | "mcp_status" | "auth" | "auth_refresh" | "slash_command" | "rpc_command" | "delivery_ack" | "cron_add" | "cron_list" | "cron_show" | "cron_cancel" | "disconnect";
172
+ /** Method names carried in the envelope `method` field. */
173
+ type MethodName = "loop_list" | "loop_get" | "loop_tree" | "loop_prune" | "loop_delete" | "loop_new" | "loop_reattach" | "loop_detach" | "loop_input" | "loop_messages" | "loop_state_get" | "loop_state_update" | "loop_cards_fetch" | "loop_history_fetch" | "loop_events" | "autopilot_events" | "job_create" | "job_status" | "job_pause" | "job_resume" | "job_cancel" | "job_dag" | "job_guidance" | "autopilot_status" | "autopilot_submit" | "autopilot_list_goals" | "autopilot_get_goal" | "autopilot_cancel_goal" | "autopilot_cancel_all" | "autopilot_wake" | "autopilot_dream" | "autopilot_resume" | "autopilot_list_jobs" | "autopilot_get_job" | "daemon_status" | "daemon_shutdown" | "config_get" | "config_reload" | "skills_list" | "invoke_skill" | "models_list" | "mcp_status" | "auth" | "auth_refresh" | "slash_command" | "rpc_command" | "delivery_ack" | "cron_add" | "cron_list" | "cron_show" | "cron_cancel" | "disconnect";
174
174
  /** Base fields shared by every protocol-1 message. */
175
175
  interface BaseEnvelope {
176
176
  proto: string;
@@ -194,7 +194,7 @@ interface NotificationEnvelope extends BaseEnvelope {
194
194
  type: "notification";
195
195
  method: MethodName;
196
196
  params?: Record<string, unknown>;
197
- /** Optional receipt id for delivery confirmation (RFC-450 §5.7). */
197
+ /** Optional receipt id for delivery confirmation. */
198
198
  receipt?: string;
199
199
  }
200
200
  /** Start a subscription stream (events arrive as `next`). */
@@ -276,9 +276,9 @@ interface DisconnectEnvelope extends BaseEnvelope {
276
276
  type: "disconnect";
277
277
  }
278
278
  /**
279
- * A daemon status frame. `status` is a defined protocol-1 top-level type
280
- * (RFC-450 §9.1): it passes through the daemon's legacy→`next` translator
281
- * unchanged, so it is NOT wrapped in a `next` envelope.
279
+ * A daemon status frame. `status` is a defined protocol-1 top-level type:
280
+ * it passes through the daemon's legacy→`next` translator unchanged, so it
281
+ * is NOT wrapped in a `next` envelope.
282
282
  */
283
283
  interface StatusFrame extends BaseEnvelope {
284
284
  type: "status";
@@ -370,7 +370,7 @@ declare function splitWirePayload(data: string): string[];
370
370
  * both shapes.
371
371
  */
372
372
  declare function extractSootheLoopID(msg: unknown): [string, boolean];
373
- /** Generates a new UUID correlation ID (RFC-450 §5.2 `id`). */
373
+ /** Generates a new UUID correlation ID. */
374
374
  declare function newRequestID(): string;
375
375
  /** Creates a `loop_input` notification envelope. */
376
376
  declare function newLoopInputMessage(loopID: string, content: string): NotificationEnvelope;
@@ -438,7 +438,7 @@ declare function isCompletionEvent(eventType: string): boolean;
438
438
  declare function isSubagentProgressEvent(eventType: string): boolean;
439
439
 
440
440
  /**
441
- * Client manages a WebSocket session with the Soothe daemon (RFC-450 protocol-1).
441
+ * Client manages a WebSocket session with the Soothe daemon.
442
442
  *
443
443
  * After close(), a new Client must be created to reconnect. The connection
444
444
  * begins with a bidirectional connection_init/connection_ack handshake; no
@@ -524,8 +524,8 @@ declare class Client extends EventEmitter {
524
524
  */
525
525
  private _signalDisconnect;
526
526
  /**
527
- * Re-dials the daemon and re-handshakes after a connection drop (RFC-450
528
- * §8.3). Does not re-establish loop subscriptions; follow with
527
+ * Re-dials the daemon and re-handshakes after a connection drop.
528
+ * Does not re-establish loop subscriptions; follow with
529
529
  * `reattachAndProbe()` to resume a loop session. The caller should invoke
530
530
  * this after the `'disconnected'` event fires. Reuses the same Client,
531
531
  * resetting the drop signal and multiplexer.
@@ -540,7 +540,7 @@ declare class Client extends EventEmitter {
540
540
  * Returns a `StaleLoopError` when the probe fails; callers should fall back
541
541
  * to a fresh `loop_new` bootstrap.
542
542
  *
543
- * Per RFC-629: connection-level readiness is the handshake's readiness_state
543
+ * Note: connection-level readiness is the handshake's readiness_state
544
544
  * (+ daemon_status); loop_get is a loop-scoped probe only, not a readiness
545
545
  * probe.
546
546
  */
@@ -587,9 +587,9 @@ declare class Client extends EventEmitter {
587
587
  private readLiveEventWithTimeout;
588
588
  /**
589
589
  * Sends a `request` envelope and waits for the matching `response` (or
590
- * `error`) correlated by `id` (RFC-450 §5/§9). Returns the `result` object.
590
+ * `error`) correlated by `id`. Returns the `result` object.
591
591
  *
592
- * Multiplexer-aware (RFC-629 constraint #1): registers a pending RPC wait
592
+ * Multiplexer-aware: registers a pending RPC wait
593
593
  * keyed by the request id so that, even when a `receiveMessages()` reader
594
594
  * is concurrently active, the matching `response`/`error` is routed to
595
595
  * this caller instead of being discarded or buffered behind a stream.
@@ -669,7 +669,7 @@ declare class Client extends EventEmitter {
669
669
  sendLoopStateUpdate(loopID: string, values: Record<string, unknown>, asNode?: string): Promise<void>;
670
670
  /** Requests display card ledger snapshot. */
671
671
  sendLoopCardsFetch(loopID: string): Promise<void>;
672
- /** Requests the full loop history (RFC-631). */
672
+ /** Requests the full loop history. */
673
673
  sendLoopHistoryFetch(loopID: string): Promise<void>;
674
674
  /** Requests MCP server status. */
675
675
  sendMCPStatus(): Promise<void>;
@@ -711,6 +711,32 @@ declare class Client extends EventEmitter {
711
711
  getJobDag(jobId: string, timeout?: number): Promise<Record<string, unknown>>;
712
712
  /** Sends guidance to a job or specific goal. */
713
713
  sendJobGuidance(jobId: string, text: string, goalId?: string, timeout?: number): Promise<Record<string, unknown>>;
714
+ /** Return autopilot scheduler status (running / dreaming / pool). */
715
+ autopilotStatus(timeout?: number): Promise<Record<string, unknown>>;
716
+ /** Submit a new autopilot goal (returns goal_id). */
717
+ autopilotSubmit(description: string, opts?: {
718
+ priority?: number;
719
+ workspace?: string;
720
+ timeout?: number;
721
+ }): Promise<Record<string, unknown>>;
722
+ /** List all goals (including non-root children). */
723
+ autopilotListGoals(timeout?: number): Promise<Record<string, unknown>>;
724
+ /** Fetch one goal by id. */
725
+ autopilotGetGoal(goalId: string, timeout?: number): Promise<Record<string, unknown>>;
726
+ /** Cancel a goal and its non-terminal descendants. */
727
+ autopilotCancelGoal(goalId: string, timeout?: number): Promise<Record<string, unknown>>;
728
+ /** Cancel every open (non-terminal) goal. */
729
+ autopilotCancelAll(timeout?: number): Promise<Record<string, unknown>>;
730
+ /** Exit dreaming mode and resume scheduling. */
731
+ autopilotWake(timeout?: number): Promise<Record<string, unknown>>;
732
+ /** Force dreaming mode. */
733
+ autopilotDream(timeout?: number): Promise<Record<string, unknown>>;
734
+ /** Resume a suspended or blocked goal. */
735
+ autopilotResume(goalId: string, timeout?: number): Promise<Record<string, unknown>>;
736
+ /** List root goals only (jobs). Prefer createJob / getJobStatus for job control. */
737
+ autopilotListJobs(timeout?: number): Promise<Record<string, unknown>>;
738
+ /** Get a root job with DAG snapshot. Prefer getJobStatus / getJobDag. */
739
+ autopilotGetJob(jobId: string, timeout?: number): Promise<Record<string, unknown>>;
714
740
  /** Subscribes to autopilot worker events. */
715
741
  autopilotSubscribe(timeout?: number): Promise<string>;
716
742
  /** Unsubscribes from autopilot worker events. */
@@ -733,7 +759,7 @@ declare class Client extends EventEmitter {
733
759
 
734
760
  /**
735
761
  * Ephemeral one-shot RPC client for jobs / cron / autopilot.
736
- * Mirrors Python AsyncCommandClient / CommandClient (RFC-629 / IG-662).
762
+ * Mirrors Python AsyncCommandClient / CommandClient.
737
763
  */
738
764
 
739
765
  declare class CommandClient {
@@ -750,12 +776,37 @@ declare class CommandClient {
750
776
  jobCreate(goal: string, workspace?: string): Promise<Record<string, unknown>>;
751
777
  jobStatus(jobId: string): Promise<Record<string, unknown>>;
752
778
  jobCancel(jobId: string): Promise<Record<string, unknown>>;
779
+ /** Return autopilot scheduler status (running / dreaming / pool). */
780
+ autopilotStatus(): Promise<Record<string, unknown>>;
781
+ /** Submit a new autopilot goal (returns goal_id). */
782
+ autopilotSubmit(description: string, opts?: {
783
+ priority?: number;
784
+ workspace?: string;
785
+ }): Promise<Record<string, unknown>>;
786
+ /** List all goals (including non-root children). */
787
+ autopilotListGoals(): Promise<Record<string, unknown>>;
788
+ /** Fetch one goal by id. */
789
+ autopilotGetGoal(goalId: string): Promise<Record<string, unknown>>;
790
+ /** Cancel a goal and its non-terminal descendants. */
791
+ autopilotCancelGoal(goalId: string): Promise<Record<string, unknown>>;
792
+ /** Cancel every open (non-terminal) goal. */
793
+ autopilotCancelAll(): Promise<Record<string, unknown>>;
794
+ /** Exit dreaming mode and resume scheduling. */
795
+ autopilotWake(): Promise<Record<string, unknown>>;
796
+ /** Force dreaming mode. */
797
+ autopilotDream(): Promise<Record<string, unknown>>;
798
+ /** Resume a suspended or blocked goal. */
799
+ autopilotResume(goalId: string): Promise<Record<string, unknown>>;
800
+ /** List root goals only (jobs). Prefer job* for job control. */
801
+ autopilotListJobs(): Promise<Record<string, unknown>>;
802
+ /** Get a root job with DAG snapshot. Prefer jobStatus / getJobDag. */
803
+ autopilotGetJob(jobId: string): Promise<Record<string, unknown>>;
753
804
  cronAdd(text: string, priority?: number): Promise<Record<string, unknown>>;
754
805
  cronList(status?: string): Promise<Record<string, unknown>>;
755
806
  }
756
807
 
757
808
  /**
758
- * Convenience RPC helper functions for the Soothe client (RFC-450 protocol-1).
809
+ * Convenience RPC helper functions for the Soothe client.
759
810
  */
760
811
 
761
812
  /** Checks daemon status via RPC. */
@@ -770,7 +821,7 @@ declare function fetchSkillsCatalog(client: Client, timeout?: number): Promise<R
770
821
  declare function fetchConfigSection(client: Client, section: string, timeout?: number): Promise<Record<string, unknown>>;
771
822
  /** Requests daemon config reload via RPC. */
772
823
  declare function requestDaemonConfigReload(client: Client, timeout?: number): Promise<Record<string, unknown>>;
773
- /** Requests loop history (RFC-631) and waits for the response. */
824
+ /** Requests loop history and waits for the response. */
774
825
  declare function fetchLoopHistory(client: Client, loopID: string, timeout?: number): Promise<Record<string, unknown>>;
775
826
  /** Submits credentials for daemon-side authentication and waits for the response. */
776
827
  declare function authenticate(client: Client, accessKey: string, secretKey: string, timeout?: number): Promise<Record<string, unknown>>;
@@ -835,7 +886,7 @@ declare function isTurnProgressChunk(mode: string, data: unknown): boolean;
835
886
  declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolean;
836
887
 
837
888
  /**
838
- * Persistence seam for appkit (RFC-629 Layer 1).
889
+ * Persistence seam for appkit.
839
890
  *
840
891
  * SessionStore abstracts per-application storage: the session↔loop-id mapping
841
892
  * that ConnectionPool consults to decide bootstrap vs reattach, and the
@@ -896,7 +947,7 @@ interface SessionStore {
896
947
  }
897
948
 
898
949
  /**
899
- * SSE-style pub/sub fan-out for appkit (RFC-629 Layer 1).
950
+ * SSE-style pub/sub fan-out for appkit.
900
951
  *
901
952
  * Generic, string-keyed pub/sub for SSE-style event delivery. The
902
953
  * application-agnostic successor to a domain-keyed broadcaster: applications
@@ -944,7 +995,7 @@ declare class SSEBroadcaster {
944
995
  }
945
996
 
946
997
  /**
947
- * Thinking-step extraction for appkit (RFC-629 Layer 1).
998
+ * Thinking-step extraction for appkit.
948
999
  *
949
1000
  * Maps an allowlisted progress event to one structured UI line. Free-form
950
1001
  * streams (tokens, reports, reasoning) are excluded. Ported from the Go
@@ -960,18 +1011,17 @@ declare const DEFAULT_THINKING_STEP_EVENTS: ReadonlySet<string>;
960
1011
  declare function extractThinkingStep(eventType: string, data: Record<string, unknown> | null, allow?: ReadonlySet<string>): [string, boolean];
961
1012
 
962
1013
  /**
963
- * Event classifier for appkit (RFC-629 Layer 1).
1014
+ * Event classifier for appkit.
964
1015
  *
965
1016
  * Maps a stream of decoded daemon events into deliverable/streaming/terminal
966
- * outcomes, keyed on (namespace, mode, phase) per RFC-614/RFC-403
967
- * (RFC-629 constraint #4). The app-agnostic successor to triarch's
968
- * ProcessChatEvent, with the deliverable phase set promoted from hardcoded
969
- * constants to configuration.
1017
+ * outcomes, keyed on (namespace, mode, phase). The app-agnostic successor to
1018
+ * product-specific ProcessChatEvent helpers, with the deliverable phase set
1019
+ * promoted from hardcoded constants to configuration.
970
1020
  *
971
1021
  * Event shape: a protocol-1 `next` envelope carries
972
1022
  * `{type:"next", payload:{namespace, mode, data, loop_id}}`. The daemon
973
1023
  * wraps legacy free-form frames as `{payload:{namespace, mode:<orig type>,
974
- * data:<orig frame>}}` (RFC-450 §9.3). The classifier inspects the payload's
1024
+ * data:<orig frame>}}`. The classifier inspects the payload's
975
1025
  * `mode`/`data`/`namespace` and the inner message's `phase`/`type`/`content`.
976
1026
  */
977
1027
 
@@ -1069,7 +1119,7 @@ declare class EventClassifier {
1069
1119
  }
1070
1120
 
1071
1121
  /**
1072
- * Single-flight query gate for appkit (RFC-629 Layer 1).
1122
+ * Single-flight query gate for appkit.
1073
1123
  *
1074
1124
  * Enforces single-flight query execution per session id and the
1075
1125
  * cancel-before-context ordering: when a query is cancelled, the daemon is
@@ -1117,7 +1167,7 @@ declare class QueryGate {
1117
1167
 
1118
1168
  /**
1119
1169
  * ManagedClient — the subset of the core Client that appkit's ConnectionPool
1120
- * and TurnRunner depend on (RFC-629 Layer 1).
1170
+ * and TurnRunner depend on.
1121
1171
  *
1122
1172
  * The concrete `Client` satisfies it; tests supply a fake. Defining it as an
1123
1173
  * interface lets appkit be unit-tested without a live WebSocket daemon.
@@ -1163,7 +1213,7 @@ type ClientFactory = (url: string, config?: Config) => ManagedClient;
1163
1213
  type BootstrapFunc = (client: ManagedClient, workspaceID: string, userID: string, config?: Config) => Promise<string>;
1164
1214
 
1165
1215
  /**
1166
- * Per-session connection pool for appkit (RFC-629 Layer 1).
1216
+ * Per-session connection pool for appkit.
1167
1217
  *
1168
1218
  * Manages a pool of daemon connections, one active per session. Reuses an
1169
1219
  * active connection when still live, otherwise bootstraps a fresh loop
@@ -1257,7 +1307,7 @@ declare class ConnectionPool {
1257
1307
  }
1258
1308
 
1259
1309
  /**
1260
- * Attachment image compaction for appkit (Go IG-651 / SIL-04 parity).
1310
+ * Attachment image compaction for appkit.
1261
1311
  *
1262
1312
  * When `sharp` is installed (optionalDependency), oversized image/* payloads
1263
1313
  * are downscaled. Without sharp, attachments pass through unchanged.
@@ -1280,13 +1330,13 @@ declare function compactImageAttachment(mimeType: string, dataB64: string, opts?
1280
1330
  declare function compactAttachments(atts: Record<string, unknown>[], opts?: CompactImageOptions | null): Promise<Record<string, unknown>[]>;
1281
1331
 
1282
1332
  /**
1283
- * Turn runner for appkit (RFC-629 Layer 1).
1333
+ * Turn runner for appkit.
1284
1334
  *
1285
1335
  * Executes one query turn end-to-end: acquire a pooled connection, enforce
1286
1336
  * single-flight, send loop_input, consume the event stream, classify events,
1287
1337
  * resolve the deliverable, persist the reply, and broadcast completion.
1288
1338
  *
1289
- * Supports IG-651 / SIL-04 lifecycle knobs: idle timeout, soft-complete
1339
+ * Supports lifecycle knobs: idle timeout, soft-complete
1290
1340
  * policies, attachment compaction, and stream-close soft-complete.
1291
1341
  */
1292
1342