@mirasoth/soothe-client 0.5.2 → 0.5.4

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.
@@ -0,0 +1,7 @@
1
+ import {
2
+ Client
3
+ } from "./chunk-B5FIL7O4.js";
4
+ export {
5
+ Client
6
+ };
7
+ //# sourceMappingURL=client-BOND6P6S.js.map
package/dist/index.cjs CHANGED
@@ -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.5.2";
360
+ CLIENT_VERSION = "0.5.3";
361
361
  }
362
362
  });
363
363
 
@@ -485,16 +485,12 @@ function isSubagentProgressEvent(eventType) {
485
485
  }
486
486
  return parsed.action === "started" || parsed.action === "completed";
487
487
  }
488
- 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
+ var EventPlanCreated, EventDeepResearchStarted, EventDeepResearchProgress, EventDeepResearchStepCompleted, EventDeepResearchGatherSummary, EventDeepResearchCrawlSummary, EventDeepResearchCompleted, EventReplayComplete, EventLoopReattachedWire, EventCardCreated, EventCardUpdated, EventCardFinalized, EventCardReplayBegin, EventCardReplayEnd, EventToolStarted, EventToolCompleted, EventToolError, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventStrangeLoopStarted, EventStrangeLoopCompleted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStepStarted, EventStrangeLoopStepQueued, EventStrangeLoopStepCompleted, EventStrangeLoopContextCompacted, EventMessageReceived, EventMessageSent, EventFinalReport, EventAutopilotGoalStatus, EventAutopilotGoalProgress, EventAutopilotGoalCreated, EventAutopilotGoalCompleted, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventGeneralFailed;
489
489
  var init_events = __esm({
490
490
  "src/events.ts"() {
491
491
  "use strict";
492
492
  init_verbosity();
493
493
  EventPlanCreated = "soothe.cognition.plan.created";
494
- EventExplorerStarted = "soothe.subagent.explorer.started";
495
- EventExplorerMilestone = "soothe.subagent.explorer.milestone";
496
- EventExplorerStepCompleted = "soothe.subagent.explorer.step.completed";
497
- EventExplorerCompleted = "soothe.subagent.explorer.completed";
498
494
  EventDeepResearchStarted = "soothe.subagent.deep_research.started";
499
495
  EventDeepResearchProgress = "soothe.subagent.deep_research.progress";
500
496
  EventDeepResearchStepCompleted = "soothe.subagent.deep_research.step.completed";
@@ -503,9 +499,11 @@ var init_events = __esm({
503
499
  EventDeepResearchCompleted = "soothe.subagent.deep_research.completed";
504
500
  EventReplayComplete = "replay_complete";
505
501
  EventLoopReattachedWire = "loop_reattached";
506
- EventCardReplayBegin = "card.replay_begin";
507
- EventCardCreated = "card.created";
508
- EventCardReplayEnd = "card.replay_end";
502
+ EventCardCreated = "soothe.card.created";
503
+ EventCardUpdated = "soothe.card.updated";
504
+ EventCardFinalized = "soothe.card.finalized";
505
+ EventCardReplayBegin = "soothe.card.replay.begin";
506
+ EventCardReplayEnd = "soothe.card.replay.end";
509
507
  EventToolStarted = "soothe.tool.execution.started";
510
508
  EventToolCompleted = "soothe.tool.execution.completed";
511
509
  EventToolError = "soothe.tool.execution.error";
@@ -777,7 +775,10 @@ var init_stream_terminal = __esm({
777
775
  EventPlanCreated,
778
776
  EventStrangeLoopStepStarted,
779
777
  EventStrangeLoopStepQueued,
780
- EventStrangeLoopStepCompleted
778
+ EventStrangeLoopStepCompleted,
779
+ EventCardCreated,
780
+ EventCardUpdated,
781
+ EventCardFinalized
781
782
  ]);
782
783
  STALE_TURN_PENDING_TYPES = /* @__PURE__ */ new Set([
783
784
  "connection_ack",
@@ -1998,6 +1999,7 @@ var init_client = __esm({
1998
1999
  var index_exports = {};
1999
2000
  __export(index_exports, {
2000
2001
  CLIENT_VERSION: () => CLIENT_VERSION,
2002
+ CardProjection: () => CardProjection,
2001
2003
  ChatEventTerminal: () => ChatEventTerminal,
2002
2004
  Client: () => Client,
2003
2005
  CommandClient: () => CommandClient,
@@ -2021,8 +2023,10 @@ __export(index_exports, {
2021
2023
  EventAutopilotWorkerAssigned: () => EventAutopilotWorkerAssigned,
2022
2024
  EventAutopilotWorkerUnassigned: () => EventAutopilotWorkerUnassigned,
2023
2025
  EventCardCreated: () => EventCardCreated,
2026
+ EventCardFinalized: () => EventCardFinalized,
2024
2027
  EventCardReplayBegin: () => EventCardReplayBegin,
2025
2028
  EventCardReplayEnd: () => EventCardReplayEnd,
2029
+ EventCardUpdated: () => EventCardUpdated,
2026
2030
  EventClassifier: () => EventClassifier,
2027
2031
  EventDeepResearchCompleted: () => EventDeepResearchCompleted,
2028
2032
  EventDeepResearchCrawlSummary: () => EventDeepResearchCrawlSummary,
@@ -2030,10 +2034,6 @@ __export(index_exports, {
2030
2034
  EventDeepResearchProgress: () => EventDeepResearchProgress,
2031
2035
  EventDeepResearchStarted: () => EventDeepResearchStarted,
2032
2036
  EventDeepResearchStepCompleted: () => EventDeepResearchStepCompleted,
2033
- EventExplorerCompleted: () => EventExplorerCompleted,
2034
- EventExplorerMilestone: () => EventExplorerMilestone,
2035
- EventExplorerStarted: () => EventExplorerStarted,
2036
- EventExplorerStepCompleted: () => EventExplorerStepCompleted,
2037
2037
  EventFinalReport: () => EventFinalReport,
2038
2038
  EventGeneralFailed: () => EventGeneralFailed,
2039
2039
  EventLoopReattachedWire: () => EventLoopReattachedWire,
@@ -2117,6 +2117,7 @@ __export(index_exports, {
2117
2117
  newLoopSubscribeMessage: () => newLoopSubscribeMessage,
2118
2118
  newRequestID: () => newRequestID,
2119
2119
  notificationEnvelope: () => notificationEnvelope,
2120
+ parseCardCustomPayload: () => parseCardCustomPayload,
2120
2121
  parseNamespace: () => parseNamespace,
2121
2122
  pingEnvelope: () => pingEnvelope,
2122
2123
  pongEnvelope: () => pongEnvelope,
@@ -4367,9 +4368,88 @@ var DaemonSession = class {
4367
4368
  }
4368
4369
  }
4369
4370
  };
4371
+
4372
+ // src/display/cardProjection.ts
4373
+ init_events();
4374
+ var CARD_MUTATION_TYPES = /* @__PURE__ */ new Set([
4375
+ EventCardCreated,
4376
+ EventCardUpdated,
4377
+ EventCardFinalized,
4378
+ EventCardReplayBegin,
4379
+ EventCardReplayEnd
4380
+ ]);
4381
+ function parseCardCustomPayload(data) {
4382
+ if (!data || typeof data !== "object") return null;
4383
+ const d = data;
4384
+ const wireType = String(d.type ?? "").trim();
4385
+ if (!CARD_MUTATION_TYPES.has(wireType)) return null;
4386
+ if (wireType === EventCardReplayBegin || wireType === EventCardReplayEnd) {
4387
+ return { wireType, card: null, patch: {} };
4388
+ }
4389
+ const payload = d.data && typeof d.data === "object" ? { ...d.data } : {};
4390
+ const cardId = String(d.card_id ?? payload.id ?? "").trim();
4391
+ if (wireType === EventCardCreated) {
4392
+ if (!payload.type || payload.content === void 0) return null;
4393
+ if (!payload.id && cardId) payload.id = cardId;
4394
+ return { wireType, card: payload, patch: {} };
4395
+ }
4396
+ if (!payload.id && cardId) payload.id = cardId;
4397
+ return {
4398
+ wireType,
4399
+ card: null,
4400
+ patch: payload
4401
+ };
4402
+ }
4403
+ var CardProjection = class {
4404
+ cards = /* @__PURE__ */ new Map();
4405
+ _replaying = false;
4406
+ get replaying() {
4407
+ return this._replaying;
4408
+ }
4409
+ snapshot() {
4410
+ return [...this.cards.values()];
4411
+ }
4412
+ get(cardId) {
4413
+ return this.cards.get(cardId);
4414
+ }
4415
+ /** Apply one custom-mode card payload. Returns true when handled. */
4416
+ apply(data) {
4417
+ const parsed = parseCardCustomPayload(data);
4418
+ if (!parsed) return false;
4419
+ if (parsed.wireType === EventCardReplayBegin) {
4420
+ this._replaying = true;
4421
+ this.cards.clear();
4422
+ return true;
4423
+ }
4424
+ if (parsed.wireType === EventCardReplayEnd) {
4425
+ this._replaying = false;
4426
+ return true;
4427
+ }
4428
+ if (parsed.wireType === EventCardCreated && parsed.card) {
4429
+ const id = String(parsed.card.id ?? "").trim();
4430
+ if (id) this.cards.set(id, { ...parsed.card });
4431
+ return true;
4432
+ }
4433
+ if (parsed.wireType === EventCardUpdated || parsed.wireType === EventCardFinalized) {
4434
+ const id = String(parsed.patch.id ?? "").trim();
4435
+ if (!id) return true;
4436
+ const existing = this.cards.get(id);
4437
+ if (!existing) return true;
4438
+ const next = { ...existing };
4439
+ for (const [key, value] of Object.entries(parsed.patch)) {
4440
+ if (key === "id" || key === "type") continue;
4441
+ next[key] = value;
4442
+ }
4443
+ this.cards.set(id, next);
4444
+ return true;
4445
+ }
4446
+ return true;
4447
+ }
4448
+ };
4370
4449
  // Annotate the CommonJS export names for ESM import in node:
4371
4450
  0 && (module.exports = {
4372
4451
  CLIENT_VERSION,
4452
+ CardProjection,
4373
4453
  ChatEventTerminal,
4374
4454
  Client,
4375
4455
  CommandClient,
@@ -4393,8 +4473,10 @@ var DaemonSession = class {
4393
4473
  EventAutopilotWorkerAssigned,
4394
4474
  EventAutopilotWorkerUnassigned,
4395
4475
  EventCardCreated,
4476
+ EventCardFinalized,
4396
4477
  EventCardReplayBegin,
4397
4478
  EventCardReplayEnd,
4479
+ EventCardUpdated,
4398
4480
  EventClassifier,
4399
4481
  EventDeepResearchCompleted,
4400
4482
  EventDeepResearchCrawlSummary,
@@ -4402,10 +4484,6 @@ var DaemonSession = class {
4402
4484
  EventDeepResearchProgress,
4403
4485
  EventDeepResearchStarted,
4404
4486
  EventDeepResearchStepCompleted,
4405
- EventExplorerCompleted,
4406
- EventExplorerMilestone,
4407
- EventExplorerStarted,
4408
- EventExplorerStepCompleted,
4409
4487
  EventFinalReport,
4410
4488
  EventGeneralFailed,
4411
4489
  EventLoopReattachedWire,
@@ -4489,6 +4567,7 @@ var DaemonSession = class {
4489
4567
  newLoopSubscribeMessage,
4490
4568
  newRequestID,
4491
4569
  notificationEnvelope,
4570
+ parseCardCustomPayload,
4492
4571
  parseNamespace,
4493
4572
  pingEnvelope,
4494
4573
  pongEnvelope,