@mirasoth/soothe-client 0.4.0 → 0.5.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/dist/index.cjs CHANGED
@@ -51,7 +51,7 @@ var init_errors = __esm({
51
51
  }
52
52
  };
53
53
  DaemonError = class extends Error {
54
- /** Numeric error code from the RFC-450 §7.3 registry. */
54
+ /** Numeric error code from the daemon error registry. */
55
55
  code;
56
56
  /** The daemon's error message text. */
57
57
  daemonMessage;
@@ -357,7 +357,7 @@ var init_protocol = __esm({
357
357
  import_node_crypto = require("crypto");
358
358
  PROTO_VERSION = "1";
359
359
  DEFAULT_CLIENT_CAPABILITIES = ["streaming", "batch", "heartbeat", "receipts"];
360
- CLIENT_VERSION = "0.4.0";
360
+ CLIENT_VERSION = "0.5.0";
361
361
  }
362
362
  });
363
363
 
@@ -484,19 +484,22 @@ function isSubagentProgressEvent(eventType) {
484
484
  }
485
485
  return parsed.action === "started" || parsed.action === "completed";
486
486
  }
487
- var EventPlanCreated, EventExploreStarted, EventExploreMilestone, EventExploreStepCompleted, EventExploreCompleted, EventTacitusStarted, EventTacitusGatherSummary, EventTacitusCompleted, EventReplayComplete, EventLoopReattachedWire, EventCardReplayBegin, EventCardCreated, EventCardReplayEnd, EventToolStarted, EventToolCompleted, EventToolError, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventStrangeLoopStarted, EventStrangeLoopCompleted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStepStarted, EventStrangeLoopStepQueued, EventStrangeLoopStepCompleted, EventStrangeLoopContextCompacted, EventMessageReceived, EventMessageSent, EventFinalReport, EventAutopilotGoalStatus, EventAutopilotGoalProgress, EventAutopilotGoalCreated, EventAutopilotGoalCompleted, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventGeneralFailed;
487
+ var EventPlanCreated, EventExplorerStarted, EventExplorerMilestone, EventExplorerStepCompleted, EventExplorerCompleted, EventDeepResearchStarted, EventDeepResearchProgress, EventDeepResearchStepCompleted, EventDeepResearchGatherSummary, EventDeepResearchCrawlSummary, EventDeepResearchCompleted, EventReplayComplete, EventLoopReattachedWire, EventCardReplayBegin, EventCardCreated, EventCardReplayEnd, EventToolStarted, EventToolCompleted, EventToolError, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventStrangeLoopStarted, EventStrangeLoopCompleted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStepStarted, EventStrangeLoopStepQueued, EventStrangeLoopStepCompleted, EventStrangeLoopContextCompacted, EventMessageReceived, EventMessageSent, EventFinalReport, EventAutopilotGoalStatus, EventAutopilotGoalProgress, EventAutopilotGoalCreated, EventAutopilotGoalCompleted, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventGeneralFailed;
488
488
  var init_events = __esm({
489
489
  "src/events.ts"() {
490
490
  "use strict";
491
491
  init_verbosity();
492
492
  EventPlanCreated = "soothe.cognition.plan.created";
493
- EventExploreStarted = "soothe.subagent.explore.started";
494
- EventExploreMilestone = "soothe.subagent.explore.milestone";
495
- EventExploreStepCompleted = "soothe.subagent.explore.step.completed";
496
- EventExploreCompleted = "soothe.subagent.explore.completed";
497
- EventTacitusStarted = "soothe.subagent.tacitus.started";
498
- EventTacitusGatherSummary = "soothe.subagent.tacitus.gather.summary";
499
- EventTacitusCompleted = "soothe.subagent.tacitus.completed";
493
+ EventExplorerStarted = "soothe.subagent.explorer.started";
494
+ EventExplorerMilestone = "soothe.subagent.explorer.milestone";
495
+ EventExplorerStepCompleted = "soothe.subagent.explorer.step.completed";
496
+ EventExplorerCompleted = "soothe.subagent.explorer.completed";
497
+ EventDeepResearchStarted = "soothe.subagent.deep_research.started";
498
+ EventDeepResearchProgress = "soothe.subagent.deep_research.progress";
499
+ EventDeepResearchStepCompleted = "soothe.subagent.deep_research.step.completed";
500
+ EventDeepResearchGatherSummary = "soothe.subagent.deep_research.gather.summary";
501
+ EventDeepResearchCrawlSummary = "soothe.subagent.deep_research.crawl.summary";
502
+ EventDeepResearchCompleted = "soothe.subagent.deep_research.completed";
500
503
  EventReplayComplete = "replay_complete";
501
504
  EventLoopReattachedWire = "loop_reattached";
502
505
  EventCardReplayBegin = "card.replay_begin";
@@ -895,7 +898,7 @@ var init_client = __esm({
895
898
  inboundDroppedCount = 0;
896
899
  onStreamDegraded = null;
897
900
  resolvers = [];
898
- // Protocol-1 handshake state (RFC-450 §8.2)
901
+ // Protocol-1 handshake state
899
902
  handshakeComplete = false;
900
903
  negotiatedCapabilities = /* @__PURE__ */ new Set();
901
904
  protocolVersion = null;
@@ -903,12 +906,12 @@ var init_client = __esm({
903
906
  heartbeatIntervalMs = 0;
904
907
  heartbeatTimer = null;
905
908
  lastPongMonotonic = 0;
906
- // Mid-session drop signal (RFC-450 §8.3). The 'disconnected' event is
909
+ // Mid-session drop signal. The 'disconnected' event is
907
910
  // emitted exactly once when the connection drops, carrying a DisconnectCause
908
911
  // that distinguishes clean (peer `disconnect`) from unclean (read/write
909
912
  // error or missed pong). `disconnFired` guards the once-only delivery.
910
913
  disconnFired = false;
911
- // Pending-request/subscription multiplexer (RFC-629 constraint #1). Routes
914
+ // Pending-request/subscription multiplexer. Routes
912
915
  // inbound frames by (type, id) instead of discarding non-matching events.
913
916
  mux = new Multiplexer();
914
917
  deliveryRecvSeq = /* @__PURE__ */ new Map();
@@ -1025,7 +1028,7 @@ var init_client = __esm({
1025
1028
  return this.ws !== null && this.ws.readyState === import_ws.default.OPEN && this.handshakeComplete;
1026
1029
  }
1027
1030
  // ---------------------------------------------------------------------------
1028
- // Mid-session drop signal + reconnect/reattach (RFC-450 §8.3, RFC-629 L0)
1031
+ // Mid-session drop signal + reconnect/reattach
1029
1032
  // ---------------------------------------------------------------------------
1030
1033
  /**
1031
1034
  * Returns whether the connection has dropped (the `'disconnected'` event has
@@ -1060,8 +1063,8 @@ var init_client = __esm({
1060
1063
  }
1061
1064
  }
1062
1065
  /**
1063
- * Re-dials the daemon and re-handshakes after a connection drop (RFC-450
1064
- * §8.3). Does not re-establish loop subscriptions; follow with
1066
+ * Re-dials the daemon and re-handshakes after a connection drop.
1067
+ * Does not re-establish loop subscriptions; follow with
1065
1068
  * `reattachAndProbe()` to resume a loop session. The caller should invoke
1066
1069
  * this after the `'disconnected'` event fires. Reuses the same Client,
1067
1070
  * resetting the drop signal and multiplexer.
@@ -1095,7 +1098,7 @@ var init_client = __esm({
1095
1098
  * Returns a `StaleLoopError` when the probe fails; callers should fall back
1096
1099
  * to a fresh `loop_new` bootstrap.
1097
1100
  *
1098
- * Per RFC-629: connection-level readiness is the handshake's readiness_state
1101
+ * Note: connection-level readiness is the handshake's readiness_state
1099
1102
  * (+ daemon_status); loop_get is a loop-scoped probe only, not a readiness
1100
1103
  * probe.
1101
1104
  */
@@ -1136,7 +1139,7 @@ var init_client = __esm({
1136
1139
  }
1137
1140
  }
1138
1141
  // ---------------------------------------------------------------------------
1139
- // Protocol-1 handshake (RFC-450 §8.2)
1142
+ // Protocol-1 handshake
1140
1143
  // ---------------------------------------------------------------------------
1141
1144
  /** Send connection_init and wait for connection_ack with readiness "ready". */
1142
1145
  async _performHandshake() {
@@ -1185,7 +1188,7 @@ var init_client = __esm({
1185
1188
  throw new Error(`timeout after ${this.config.daemonReadyTimeout}ms waiting for connection_ack`);
1186
1189
  }
1187
1190
  // ---------------------------------------------------------------------------
1188
- // Heartbeat (RFC-450 §8.3)
1191
+ // Heartbeat
1189
1192
  // ---------------------------------------------------------------------------
1190
1193
  _startHeartbeat() {
1191
1194
  if (!this.negotiatedCapabilities.has("heartbeat")) return;
@@ -1380,7 +1383,7 @@ var init_client = __esm({
1380
1383
  }
1381
1384
  }
1382
1385
  // ---------------------------------------------------------------------------
1383
- // Protocol-1 RPC primitives (RFC-450 §5/§9)
1386
+ // Protocol-1 RPC primitives
1384
1387
  // ---------------------------------------------------------------------------
1385
1388
  /**
1386
1389
  * Reads the next frame directly from the live socket (via a resolver),
@@ -1406,16 +1409,16 @@ var init_client = __esm({
1406
1409
  });
1407
1410
  }
1408
1411
  /**
1409
- * Sends a `request` envelope and waits for the matching `response` (or
1410
- * `error`) correlated by `id` (RFC-450 §5/§9). Returns the `result` object.
1411
- *
1412
- * Multiplexer-aware (RFC-629 constraint #1): registers a pending RPC wait
1413
- * keyed by the request id so that, even when a `receiveMessages()` reader
1414
- * is concurrently active, the matching `response`/`error` is routed to
1415
- * this caller instead of being discarded or buffered behind a stream.
1416
- * Non-matching frames are routed to their own waiters by the multiplexer
1417
- * or flow on to the resolver queue for stream readers.
1418
- */
1412
+ * Sends a `request` envelope and waits for the matching `response` (or
1413
+ * `error`) correlated by `id`. Returns the `result` object.
1414
+ *
1415
+ * Multiplexer-aware: registers a pending RPC wait
1416
+ * keyed by the request id so that, even when a `receiveMessages()` reader
1417
+ * is concurrently active, the matching `response`/`error` is routed to
1418
+ * this caller instead of being discarded or buffered behind a stream.
1419
+ * Non-matching frames are routed to their own waiters by the multiplexer
1420
+ * or flow on to the resolver queue for stream readers.
1421
+ */
1419
1422
  async requestResponse(method, params, responseType, timeout = 15e3) {
1420
1423
  const req = requestEnvelope(method, params);
1421
1424
  const rid = req.id;
@@ -1566,7 +1569,7 @@ var init_client = __esm({
1566
1569
  return ev;
1567
1570
  }
1568
1571
  // ---------------------------------------------------------------------------
1569
- // High-level API methods (Loop-first, RFC-503)
1572
+ // High-level API methods
1570
1573
  // ---------------------------------------------------------------------------
1571
1574
  /** Sends user input to the daemon (loop_input notification; requires loopID). */
1572
1575
  sendInput(text, options) {
@@ -1605,7 +1608,7 @@ var init_client = __esm({
1605
1608
  return this.notify("slash_command", { cmd });
1606
1609
  }
1607
1610
  // ---------------------------------------------------------------------------
1608
- // Loop lifecycle methods (RFC-503)
1611
+ // Loop lifecycle methods
1609
1612
  // ---------------------------------------------------------------------------
1610
1613
  /** Requests the daemon to create a new StrangeLoop and waits for the response. */
1611
1614
  sendLoopNew(opts) {
@@ -1700,7 +1703,7 @@ var init_client = __esm({
1700
1703
  sendLoopCardsFetch(loopID) {
1701
1704
  return this.sendMessage(requestEnvelope("loop_cards_fetch", { loop_id: loopID }));
1702
1705
  }
1703
- /** Requests the full loop history (RFC-631). */
1706
+ /** Requests the full loop history. */
1704
1707
  sendLoopHistoryFetch(loopID) {
1705
1708
  return this.sendMessage(requestEnvelope("loop_history_fetch", { loop_id: loopID }));
1706
1709
  }
@@ -1795,7 +1798,7 @@ var init_client = __esm({
1795
1798
  );
1796
1799
  }
1797
1800
  // ---------------------------------------------------------------------------
1798
- // RFC-228 Job IPC methods
1801
+ // Job IPC methods
1799
1802
  // ---------------------------------------------------------------------------
1800
1803
  /** Creates an autopilot job and waits for the response. */
1801
1804
  createJob(goal, verificationRules, workspace, timeout) {
@@ -1830,6 +1833,98 @@ var init_client = __esm({
1830
1833
  if (goalId) params.goal_id = goalId;
1831
1834
  return this.requestResponse("job_guidance", params, "job_guidance", timeout ?? 3e4);
1832
1835
  }
1836
+ // ---------------------------------------------------------------------------
1837
+ // Autopilot goal RPCs (protocol-1 request methods)
1838
+ // ---------------------------------------------------------------------------
1839
+ /** Return autopilot scheduler status (running / dreaming / pool). */
1840
+ autopilotStatus(timeout) {
1841
+ return this.requestResponse("autopilot_status", {}, "autopilot_status", timeout ?? 15e3);
1842
+ }
1843
+ /** Submit a new autopilot goal (returns goal_id). */
1844
+ autopilotSubmit(description, opts) {
1845
+ const params = {
1846
+ description,
1847
+ priority: opts?.priority ?? 50
1848
+ };
1849
+ if (opts?.workspace) params.workspace = opts.workspace;
1850
+ return this.requestResponse(
1851
+ "autopilot_submit",
1852
+ params,
1853
+ "autopilot_submit",
1854
+ opts?.timeout ?? 15e3
1855
+ );
1856
+ }
1857
+ /** List all goals (including non-root children). */
1858
+ autopilotListGoals(timeout) {
1859
+ return this.requestResponse(
1860
+ "autopilot_list_goals",
1861
+ {},
1862
+ "autopilot_list_goals",
1863
+ timeout ?? 15e3
1864
+ );
1865
+ }
1866
+ /** Fetch one goal by id. */
1867
+ autopilotGetGoal(goalId, timeout) {
1868
+ return this.requestResponse(
1869
+ "autopilot_get_goal",
1870
+ { goal_id: goalId },
1871
+ "autopilot_get_goal",
1872
+ timeout ?? 15e3
1873
+ );
1874
+ }
1875
+ /** Cancel a goal and its non-terminal descendants. */
1876
+ autopilotCancelGoal(goalId, timeout) {
1877
+ return this.requestResponse(
1878
+ "autopilot_cancel_goal",
1879
+ { goal_id: goalId },
1880
+ "autopilot_cancel_goal",
1881
+ timeout ?? 15e3
1882
+ );
1883
+ }
1884
+ /** Cancel every open (non-terminal) goal. */
1885
+ autopilotCancelAll(timeout) {
1886
+ return this.requestResponse(
1887
+ "autopilot_cancel_all",
1888
+ {},
1889
+ "autopilot_cancel_all",
1890
+ timeout ?? 15e3
1891
+ );
1892
+ }
1893
+ /** Exit dreaming mode and resume scheduling. */
1894
+ autopilotWake(timeout) {
1895
+ return this.requestResponse("autopilot_wake", {}, "autopilot_wake", timeout ?? 15e3);
1896
+ }
1897
+ /** Force dreaming mode. */
1898
+ autopilotDream(timeout) {
1899
+ return this.requestResponse("autopilot_dream", {}, "autopilot_dream", timeout ?? 15e3);
1900
+ }
1901
+ /** Resume a suspended or blocked goal. */
1902
+ autopilotResume(goalId, timeout) {
1903
+ return this.requestResponse(
1904
+ "autopilot_resume",
1905
+ { goal_id: goalId },
1906
+ "autopilot_resume",
1907
+ timeout ?? 15e3
1908
+ );
1909
+ }
1910
+ /** List root goals only (jobs). Prefer createJob / getJobStatus for job control. */
1911
+ autopilotListJobs(timeout) {
1912
+ return this.requestResponse(
1913
+ "autopilot_list_jobs",
1914
+ {},
1915
+ "autopilot_list_jobs",
1916
+ timeout ?? 15e3
1917
+ );
1918
+ }
1919
+ /** Get a root job with DAG snapshot. Prefer getJobStatus / getJobDag. */
1920
+ autopilotGetJob(jobId, timeout) {
1921
+ return this.requestResponse(
1922
+ "autopilot_get_job",
1923
+ { job_id: jobId },
1924
+ "autopilot_get_job",
1925
+ timeout ?? 15e3
1926
+ );
1927
+ }
1833
1928
  /** Subscribes to autopilot worker events. */
1834
1929
  autopilotSubscribe(timeout) {
1835
1930
  return this.subscribe("autopilot_events", {}, timeout ?? 15e3);
@@ -1840,7 +1935,7 @@ var init_client = __esm({
1840
1935
  return this._requestResponseForEnvelope(req, "autopilot_unsubscribe", timeout ?? 15e3);
1841
1936
  }
1842
1937
  // ---------------------------------------------------------------------------
1843
- // RFC-229 Cron IPC methods
1938
+ // Cron IPC methods
1844
1939
  // ---------------------------------------------------------------------------
1845
1940
  /** Creates a scheduled job from natural language. */
1846
1941
  cronAdd(text, priority, timeout) {
@@ -1928,10 +2023,16 @@ __export(index_exports, {
1928
2023
  EventCardReplayBegin: () => EventCardReplayBegin,
1929
2024
  EventCardReplayEnd: () => EventCardReplayEnd,
1930
2025
  EventClassifier: () => EventClassifier,
1931
- EventExploreCompleted: () => EventExploreCompleted,
1932
- EventExploreMilestone: () => EventExploreMilestone,
1933
- EventExploreStarted: () => EventExploreStarted,
1934
- EventExploreStepCompleted: () => EventExploreStepCompleted,
2026
+ EventDeepResearchCompleted: () => EventDeepResearchCompleted,
2027
+ EventDeepResearchCrawlSummary: () => EventDeepResearchCrawlSummary,
2028
+ EventDeepResearchGatherSummary: () => EventDeepResearchGatherSummary,
2029
+ EventDeepResearchProgress: () => EventDeepResearchProgress,
2030
+ EventDeepResearchStarted: () => EventDeepResearchStarted,
2031
+ EventDeepResearchStepCompleted: () => EventDeepResearchStepCompleted,
2032
+ EventExplorerCompleted: () => EventExplorerCompleted,
2033
+ EventExplorerMilestone: () => EventExplorerMilestone,
2034
+ EventExplorerStarted: () => EventExplorerStarted,
2035
+ EventExplorerStepCompleted: () => EventExplorerStepCompleted,
1935
2036
  EventFinalReport: () => EventFinalReport,
1936
2037
  EventGeneralFailed: () => EventGeneralFailed,
1937
2038
  EventLoopReattachedWire: () => EventLoopReattachedWire,
@@ -1948,9 +2049,6 @@ __export(index_exports, {
1948
2049
  EventStrangeLoopStepQueued: () => EventStrangeLoopStepQueued,
1949
2050
  EventStrangeLoopStepStarted: () => EventStrangeLoopStepStarted,
1950
2051
  EventStreamToolCallUpdate: () => EventStreamToolCallUpdate,
1951
- EventTacitusCompleted: () => EventTacitusCompleted,
1952
- EventTacitusGatherSummary: () => EventTacitusGatherSummary,
1953
- EventTacitusStarted: () => EventTacitusStarted,
1954
2052
  EventToolCallUpdatesBatch: () => EventToolCallUpdatesBatch,
1955
2053
  EventToolCompleted: () => EventToolCompleted,
1956
2054
  EventToolError: () => EventToolError,
@@ -2180,6 +2278,55 @@ var CommandClient = class {
2180
2278
  async jobCancel(jobId) {
2181
2279
  return this.request("job_cancel", { job_id: jobId });
2182
2280
  }
2281
+ /** Return autopilot scheduler status (running / dreaming / pool). */
2282
+ async autopilotStatus() {
2283
+ return this.request("autopilot_status");
2284
+ }
2285
+ /** Submit a new autopilot goal (returns goal_id). */
2286
+ async autopilotSubmit(description, opts) {
2287
+ const params = {
2288
+ description,
2289
+ priority: opts?.priority ?? 50
2290
+ };
2291
+ if (opts?.workspace) params.workspace = opts.workspace;
2292
+ return this.request("autopilot_submit", params);
2293
+ }
2294
+ /** List all goals (including non-root children). */
2295
+ async autopilotListGoals() {
2296
+ return this.request("autopilot_list_goals");
2297
+ }
2298
+ /** Fetch one goal by id. */
2299
+ async autopilotGetGoal(goalId) {
2300
+ return this.request("autopilot_get_goal", { goal_id: goalId });
2301
+ }
2302
+ /** Cancel a goal and its non-terminal descendants. */
2303
+ async autopilotCancelGoal(goalId) {
2304
+ return this.request("autopilot_cancel_goal", { goal_id: goalId });
2305
+ }
2306
+ /** Cancel every open (non-terminal) goal. */
2307
+ async autopilotCancelAll() {
2308
+ return this.request("autopilot_cancel_all");
2309
+ }
2310
+ /** Exit dreaming mode and resume scheduling. */
2311
+ async autopilotWake() {
2312
+ return this.request("autopilot_wake");
2313
+ }
2314
+ /** Force dreaming mode. */
2315
+ async autopilotDream() {
2316
+ return this.request("autopilot_dream");
2317
+ }
2318
+ /** Resume a suspended or blocked goal. */
2319
+ async autopilotResume(goalId) {
2320
+ return this.request("autopilot_resume", { goal_id: goalId });
2321
+ }
2322
+ /** List root goals only (jobs). Prefer job* for job control. */
2323
+ async autopilotListJobs() {
2324
+ return this.request("autopilot_list_jobs");
2325
+ }
2326
+ /** Get a root job with DAG snapshot. Prefer jobStatus / getJobDag. */
2327
+ async autopilotGetJob(jobId) {
2328
+ return this.request("autopilot_get_job", { job_id: jobId });
2329
+ }
2183
2330
  async cronAdd(text, priority = 0) {
2184
2331
  const params = { text };
2185
2332
  if (priority > 0) params.priority = priority;
@@ -4116,10 +4263,16 @@ var DaemonSession = class {
4116
4263
  EventCardReplayBegin,
4117
4264
  EventCardReplayEnd,
4118
4265
  EventClassifier,
4119
- EventExploreCompleted,
4120
- EventExploreMilestone,
4121
- EventExploreStarted,
4122
- EventExploreStepCompleted,
4266
+ EventDeepResearchCompleted,
4267
+ EventDeepResearchCrawlSummary,
4268
+ EventDeepResearchGatherSummary,
4269
+ EventDeepResearchProgress,
4270
+ EventDeepResearchStarted,
4271
+ EventDeepResearchStepCompleted,
4272
+ EventExplorerCompleted,
4273
+ EventExplorerMilestone,
4274
+ EventExplorerStarted,
4275
+ EventExplorerStepCompleted,
4123
4276
  EventFinalReport,
4124
4277
  EventGeneralFailed,
4125
4278
  EventLoopReattachedWire,
@@ -4136,9 +4289,6 @@ var DaemonSession = class {
4136
4289
  EventStrangeLoopStepQueued,
4137
4290
  EventStrangeLoopStepStarted,
4138
4291
  EventStreamToolCallUpdate,
4139
- EventTacitusCompleted,
4140
- EventTacitusGatherSummary,
4141
- EventTacitusStarted,
4142
4292
  EventToolCallUpdatesBatch,
4143
4293
  EventToolCompleted,
4144
4294
  EventToolError,