@mirasoth/soothe-client 0.5.3 → 0.5.5

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
@@ -170,7 +170,7 @@ declare const DEFAULT_CLIENT_CAPABILITIES: string[];
170
170
  declare const CLIENT_VERSION = "0.5.3";
171
171
  type MessageType = "connection_init" | "connection_ack" | "request" | "response" | "notification" | "subscribe" | "next" | "error" | "complete" | "unsubscribe" | "ping" | "pong" | "receipt_response" | "disconnect" | "status";
172
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";
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_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;
@@ -389,10 +389,6 @@ declare function newLoopSubscribeMessage(loopID: string, verbosity: string, stre
389
389
  */
390
390
 
391
391
  declare const EventPlanCreated = "soothe.cognition.plan.created";
392
- declare const EventExplorerStarted = "soothe.subagent.explorer.started";
393
- declare const EventExplorerMilestone = "soothe.subagent.explorer.milestone";
394
- declare const EventExplorerStepCompleted = "soothe.subagent.explorer.step.completed";
395
- declare const EventExplorerCompleted = "soothe.subagent.explorer.completed";
396
392
  declare const EventDeepResearchStarted = "soothe.subagent.deep_research.started";
397
393
  declare const EventDeepResearchProgress = "soothe.subagent.deep_research.progress";
398
394
  declare const EventDeepResearchStepCompleted = "soothe.subagent.deep_research.step.completed";
@@ -401,9 +397,11 @@ declare const EventDeepResearchCrawlSummary = "soothe.subagent.deep_research.cra
401
397
  declare const EventDeepResearchCompleted = "soothe.subagent.deep_research.completed";
402
398
  declare const EventReplayComplete = "replay_complete";
403
399
  declare const EventLoopReattachedWire = "loop_reattached";
404
- declare const EventCardReplayBegin = "card.replay_begin";
405
- declare const EventCardCreated = "card.created";
406
- declare const EventCardReplayEnd = "card.replay_end";
400
+ declare const EventCardCreated = "soothe.card.created";
401
+ declare const EventCardUpdated = "soothe.card.updated";
402
+ declare const EventCardFinalized = "soothe.card.finalized";
403
+ declare const EventCardReplayBegin = "soothe.card.replay.begin";
404
+ declare const EventCardReplayEnd = "soothe.card.replay.end";
407
405
  declare const EventToolStarted = "soothe.tool.execution.started";
408
406
  declare const EventToolCompleted = "soothe.tool.execution.completed";
409
407
  declare const EventToolError = "soothe.tool.execution.error";
@@ -670,8 +668,6 @@ declare class Client extends EventEmitter {
670
668
  sendLoopStateGet(loopID: string): Promise<void>;
671
669
  /** Applies partial checkpoint values. */
672
670
  sendLoopStateUpdate(loopID: string, values: Record<string, unknown>, asNode?: string): Promise<void>;
673
- /** Requests display card ledger snapshot. */
674
- sendLoopCardsFetch(loopID: string): Promise<void>;
675
671
  /** Requests the full loop history. */
676
672
  sendLoopHistoryFetch(loopID: string): Promise<void>;
677
673
  /** Requests MCP server status. */
@@ -688,8 +684,6 @@ declare class Client extends EventEmitter {
688
684
  getLoopState(loopID: string, timeout?: number): Promise<Record<string, unknown>>;
689
685
  /** Updates loop state and waits for response. */
690
686
  updateLoopState(loopID: string, values: Record<string, unknown>, asNode?: string, timeout?: number): Promise<Record<string, unknown>>;
691
- /** Requests display cards and waits for response. */
692
- fetchLoopCards(loopID: string, timeout?: number): Promise<Record<string, unknown>>;
693
687
  /** Requests MCP status and waits for response. */
694
688
  getMCPStatus(timeout?: number): Promise<Record<string, unknown>>;
695
689
  /** Requests loop history and waits for response. */
@@ -830,8 +824,6 @@ declare function fetchLoopHistory(client: Client, loopID: string, timeout?: numb
830
824
  declare function authenticate(client: Client, accessKey: string, secretKey: string, timeout?: number): Promise<Record<string, unknown>>;
831
825
  /** Refreshes the daemon-side auth token and waits for the response. */
832
826
  declare function refreshAuthToken(client: Client, refreshToken: string, timeout?: number): Promise<Record<string, unknown>>;
833
- /** Fetch bound display-card snapshot for a loop. */
834
- declare function fetchLoopCards(client: Client, loopID: string, timeout?: number): Promise<Record<string, unknown>>;
835
827
  /** Fetch persisted conversation/activity rows for a loop. */
836
828
  declare function fetchLoopMessages(client: Client, loopID: string, opts?: {
837
829
  limit?: number;
@@ -891,7 +883,7 @@ declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolea
891
883
  /**
892
884
  * Persistence seam for appkit.
893
885
  *
894
- * SessionStore abstracts per-application storage: the session↔loop-id mapping
886
+ * LoopSessionStore abstracts per-application storage: the session↔loop-id mapping
895
887
  * that ConnectionPool consults to decide bootstrap vs reattach, and the
896
888
  * message rows TurnRunner writes back when a turn completes. Applications
897
889
  * implement this against their own store (Postgres, Redis, in-memory, …).
@@ -899,7 +891,7 @@ declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolea
899
891
  * Implementations must be safe for concurrent use.
900
892
  */
901
893
  /** Persisted mapping between an application session id and the daemon loop id. */
902
- interface SessionEntry {
894
+ interface LoopSessionEntry {
903
895
  workspaceID: string;
904
896
  sessionID: string;
905
897
  loopID: string;
@@ -928,9 +920,9 @@ interface SessionMessage {
928
920
  * loop id once bootstrapped. TurnRunner persists the final assistant reply
929
921
  * and error rows via appendMessage.
930
922
  */
931
- interface SessionStore {
923
+ interface LoopSessionStore {
932
924
  /** Returns the persisted entry for sessionID, or null if no record exists. */
933
- getSession(sessionID: string): Promise<SessionEntry | null>;
925
+ getSession(sessionID: string): Promise<LoopSessionEntry | null>;
934
926
  /** Persists a new session↔loop mapping. */
935
927
  createSession(workspaceID: string, sessionID: string, loopID: string, sessionType: string): Promise<void>;
936
928
  /** Stamps the session's last-used timestamp. */
@@ -1221,7 +1213,7 @@ type BootstrapFunc = (client: ManagedClient, workspaceID: string, userID: string
1221
1213
  * active connection when still live, otherwise bootstraps a fresh loop
1222
1214
  * (loop_new + subscribe) or reattaches an existing one (loop_reattach +
1223
1215
  * subscribe + reattachAndProbe). Persistence of session↔loop mappings is
1224
- * abstracted behind SessionStore.
1216
+ * abstracted behind LoopSessionStore.
1225
1217
  *
1226
1218
  * The app-agnostic successor to triarch's SoothePoolManager connection
1227
1219
  * mechanics.
@@ -1276,7 +1268,7 @@ declare class ConnectionPool {
1276
1268
  * defaultPoolConfig is used; if scfg is null, defaultConfig is used; nil
1277
1269
  * factory/bootstrap fall back to the defaults.
1278
1270
  */
1279
- constructor(url: string, store: SessionStore, cfg?: PoolConfig | null, scfg?: Config | null, factory?: ClientFactory | null);
1271
+ constructor(url: string, store: LoopSessionStore, cfg?: PoolConfig | null, scfg?: Config | null, factory?: ClientFactory | null);
1280
1272
  /** Overrides the loop bootstrap function (useful for test fakes). */
1281
1273
  withBootstrap(f: BootstrapFunc): ConnectionPool;
1282
1274
  /**
@@ -1413,7 +1405,7 @@ declare class TurnRunner {
1413
1405
  private buildInput;
1414
1406
  private onComplete;
1415
1407
  private onError;
1416
- constructor(pool: ConnectionPool, gate: QueryGate, classifier: EventClassifier, store: SessionStore, broadcaster: SSEBroadcaster | null, cfg: TurnConfig);
1408
+ constructor(pool: ConnectionPool, gate: QueryGate, classifier: EventClassifier, store: LoopSessionStore, broadcaster: SSEBroadcaster | null, cfg: TurnConfig);
1417
1409
  withInputBuilder(f: typeof inputMessageForLoop): TurnRunner;
1418
1410
  withOnComplete(f: OnComplete): TurnRunner;
1419
1411
  withOnError(f: OnError): TurnRunner;
@@ -1547,12 +1539,6 @@ declare class DaemonSession {
1547
1539
  private withRpcLock;
1548
1540
  private ensureRpcConnected;
1549
1541
  listLoops(_limit?: number): Promise<Record<string, unknown>>;
1550
- fetchLoopCards(loopId: string): Promise<{
1551
- cards: unknown[];
1552
- seq: number;
1553
- contextTokens: number;
1554
- success: boolean;
1555
- }>;
1556
1542
  fetchLoopHistory(loopId: string): Promise<{
1557
1543
  goals: unknown[];
1558
1544
  liveCards: unknown[];
@@ -1570,4 +1556,42 @@ declare class DaemonSession {
1570
1556
  }): AsyncGenerator<TurnChunk>;
1571
1557
  }
1572
1558
 
1573
- export { type Attachment, type BaseEnvelope, CLIENT_VERSION, type ChatEventResult, ChatEventTerminal, type ClassifierConfig, Client, CommandClient, type CompactImageOptions, type CompleteEnvelope, type Config, type ConnectionAckEnvelope, ConnectionError, type ConnectionInitEnvelope, ConnectionPool, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_DELIVERABLE_PHASES, DEFAULT_POST_IDLE_DRAIN_MS, DEFAULT_THINKING_STEP_EVENTS, DaemonError, DaemonSession, type DaemonSessionOptions, type DecodedMessage, DisconnectCause, type DisconnectEnvelope, ErrIdleTimeout, ErrPoolExhausted, ErrQueryBusy, ErrQueryTimeout, type ErrorEnvelope, EventAutopilotGoalCompleted, EventAutopilotGoalCreated, EventAutopilotGoalProgress, EventAutopilotGoalStatus, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventCardCreated, EventCardReplayBegin, EventCardReplayEnd, EventClassifier, EventDeepResearchCompleted, EventDeepResearchCrawlSummary, EventDeepResearchGatherSummary, EventDeepResearchProgress, EventDeepResearchStarted, EventDeepResearchStepCompleted, EventExplorerCompleted, EventExplorerMilestone, EventExplorerStarted, EventExplorerStepCompleted, EventFinalReport, EventGeneralFailed, EventLoopReattachedWire, EventMessageReceived, EventMessageSent, EventPlanCreated, EventReplayComplete, EventStrangeLoopCompleted, EventStrangeLoopContextCompacted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStarted, EventStrangeLoopStepCompleted, EventStrangeLoopStepQueued, EventStrangeLoopStepStarted, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventToolCompleted, EventToolError, EventToolStarted, INTENT_HINT_EMBED, INTENT_HINT_IMAGE_TO_TEXT, INTENT_HINT_OCR, INTENT_HINT_TEXT_COMPLETION, type InputOptions, type InputOpts, type IntentHint, LOOP_ASSISTANT_OUTPUT_PHASES, type LoopAssistantOutputPhase, type LoopInputIntentHint, type LoopInputParams, type LoopNewOptions, type MessageType, type MethodName, type NegotiatedCapabilities, type NextEnvelope, type NotificationEnvelope, type OnComplete, type OnError, PROTO_VERSION, type PingEnvelope, type PongEnvelope, type PoolConfig, PooledConn, QueryGate, REMOVED_INTENT_HINTS, type ReceiptResponseEnvelope, ReconnectError, type RemovedIntentHint, type RequestEnvelope, type ResponseEnvelope, SSEBroadcaster, type SSEEvent, STREAM_END, type SessionEntry, type SessionMessage, type SessionStore, StaleLoopError, type StatusFrame, StreamCloseFail, type StreamClosePolicy, StreamCloseSoftComplete, type StreamEventPayload, type SubscribeEnvelope, TURN_END_IDLE, TURN_END_STOPPED, TURN_END_STREAM_END, TimeoutError, TimeoutPolicy, TurnBoundary, type TurnChunk, type TurnConfig, TurnEventStats, TurnLifecycleGate, TurnRunner, type UnsubscribeEnvelope, type VerbosityLevel, VerbosityTier, authenticate, bootstrapLoopSession, checkDaemonStatus, classifyEventVerbosity, compactAttachments, compactImageAttachment, connectWithRetries, connectedWebsocket, connectionInitEnvelope, decodeMessage, defaultConfig, defaultPoolConfig, disconnectCauseName, disconnectEnvelope, encodeMessage, extractSootheLoopID, extractThinkingStep, fetchConfigSection, fetchLoopCards, fetchLoopHistory, fetchLoopMessages, fetchSkillsCatalog, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseNamespace, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, unsubscribeEnvelope, validateLoopInputIntentHint, waitDaemonReady, waitLoopStatusWithID, waitSubscriptionConfirmed };
1559
+ /**
1560
+ * In-memory apply helpers for daemon `soothe.card.*` frames.
1561
+ *
1562
+ * Language clients stay transport/appkit — this projects card_id → wire dict
1563
+ * without mounting UI widgets.
1564
+ */
1565
+
1566
+ type CardWireDict = Record<string, unknown> & {
1567
+ id?: string;
1568
+ type?: string;
1569
+ content?: string;
1570
+ };
1571
+ type ParsedCardFrame = {
1572
+ wireType: typeof EventCardReplayBegin | typeof EventCardReplayEnd;
1573
+ card: null;
1574
+ patch: Record<string, unknown>;
1575
+ } | {
1576
+ wireType: typeof EventCardCreated;
1577
+ card: CardWireDict;
1578
+ patch: Record<string, unknown>;
1579
+ } | {
1580
+ wireType: typeof EventCardUpdated | typeof EventCardFinalized;
1581
+ card: null;
1582
+ patch: Record<string, unknown>;
1583
+ };
1584
+ /** Parse a custom-mode card frame, or null if not a card frame. */
1585
+ declare function parseCardCustomPayload(data: unknown): ParsedCardFrame | null;
1586
+ /** card_id → wire dict projection driven by `soothe.card.*` frames. */
1587
+ declare class CardProjection {
1588
+ private cards;
1589
+ private _replaying;
1590
+ get replaying(): boolean;
1591
+ snapshot(): CardWireDict[];
1592
+ get(cardId: string): CardWireDict | undefined;
1593
+ /** Apply one custom-mode card payload. Returns true when handled. */
1594
+ apply(data: unknown): boolean;
1595
+ }
1596
+
1597
+ export { type Attachment, type BaseEnvelope, CLIENT_VERSION, CardProjection, type CardWireDict, type ChatEventResult, ChatEventTerminal, type ClassifierConfig, Client, CommandClient, type CompactImageOptions, type CompleteEnvelope, type Config, type ConnectionAckEnvelope, ConnectionError, type ConnectionInitEnvelope, ConnectionPool, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_DELIVERABLE_PHASES, DEFAULT_POST_IDLE_DRAIN_MS, DEFAULT_THINKING_STEP_EVENTS, DaemonError, DaemonSession, type DaemonSessionOptions, type DecodedMessage, DisconnectCause, type DisconnectEnvelope, ErrIdleTimeout, ErrPoolExhausted, ErrQueryBusy, ErrQueryTimeout, type ErrorEnvelope, EventAutopilotGoalCompleted, EventAutopilotGoalCreated, EventAutopilotGoalProgress, EventAutopilotGoalStatus, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventCardCreated, EventCardFinalized, EventCardReplayBegin, EventCardReplayEnd, EventCardUpdated, EventClassifier, EventDeepResearchCompleted, EventDeepResearchCrawlSummary, EventDeepResearchGatherSummary, EventDeepResearchProgress, EventDeepResearchStarted, EventDeepResearchStepCompleted, EventFinalReport, EventGeneralFailed, EventLoopReattachedWire, EventMessageReceived, EventMessageSent, EventPlanCreated, EventReplayComplete, EventStrangeLoopCompleted, EventStrangeLoopContextCompacted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStarted, EventStrangeLoopStepCompleted, EventStrangeLoopStepQueued, EventStrangeLoopStepStarted, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventToolCompleted, EventToolError, EventToolStarted, INTENT_HINT_EMBED, INTENT_HINT_IMAGE_TO_TEXT, INTENT_HINT_OCR, INTENT_HINT_TEXT_COMPLETION, type InputOptions, type InputOpts, type IntentHint, LOOP_ASSISTANT_OUTPUT_PHASES, type LoopAssistantOutputPhase, type LoopInputIntentHint, type LoopInputParams, type LoopNewOptions, type LoopSessionEntry, type LoopSessionStore, type MessageType, type MethodName, type NegotiatedCapabilities, type NextEnvelope, type NotificationEnvelope, type OnComplete, type OnError, PROTO_VERSION, type ParsedCardFrame, type PingEnvelope, type PongEnvelope, type PoolConfig, PooledConn, QueryGate, REMOVED_INTENT_HINTS, type ReceiptResponseEnvelope, ReconnectError, type RemovedIntentHint, type RequestEnvelope, type ResponseEnvelope, SSEBroadcaster, type SSEEvent, STREAM_END, type SessionMessage, StaleLoopError, type StatusFrame, StreamCloseFail, type StreamClosePolicy, StreamCloseSoftComplete, type StreamEventPayload, type SubscribeEnvelope, TURN_END_IDLE, TURN_END_STOPPED, TURN_END_STREAM_END, TimeoutError, TimeoutPolicy, TurnBoundary, type TurnChunk, type TurnConfig, TurnEventStats, TurnLifecycleGate, TurnRunner, type UnsubscribeEnvelope, type VerbosityLevel, VerbosityTier, authenticate, bootstrapLoopSession, checkDaemonStatus, classifyEventVerbosity, compactAttachments, compactImageAttachment, connectWithRetries, connectedWebsocket, connectionInitEnvelope, decodeMessage, defaultConfig, defaultPoolConfig, disconnectCauseName, disconnectEnvelope, encodeMessage, extractSootheLoopID, extractThinkingStep, fetchConfigSection, fetchLoopHistory, fetchLoopMessages, fetchSkillsCatalog, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseCardCustomPayload, parseNamespace, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, unsubscribeEnvelope, validateLoopInputIntentHint, waitDaemonReady, waitLoopStatusWithID, waitSubscriptionConfirmed };
package/dist/index.d.ts CHANGED
@@ -170,7 +170,7 @@ declare const DEFAULT_CLIENT_CAPABILITIES: string[];
170
170
  declare const CLIENT_VERSION = "0.5.3";
171
171
  type MessageType = "connection_init" | "connection_ack" | "request" | "response" | "notification" | "subscribe" | "next" | "error" | "complete" | "unsubscribe" | "ping" | "pong" | "receipt_response" | "disconnect" | "status";
172
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";
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_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;
@@ -389,10 +389,6 @@ declare function newLoopSubscribeMessage(loopID: string, verbosity: string, stre
389
389
  */
390
390
 
391
391
  declare const EventPlanCreated = "soothe.cognition.plan.created";
392
- declare const EventExplorerStarted = "soothe.subagent.explorer.started";
393
- declare const EventExplorerMilestone = "soothe.subagent.explorer.milestone";
394
- declare const EventExplorerStepCompleted = "soothe.subagent.explorer.step.completed";
395
- declare const EventExplorerCompleted = "soothe.subagent.explorer.completed";
396
392
  declare const EventDeepResearchStarted = "soothe.subagent.deep_research.started";
397
393
  declare const EventDeepResearchProgress = "soothe.subagent.deep_research.progress";
398
394
  declare const EventDeepResearchStepCompleted = "soothe.subagent.deep_research.step.completed";
@@ -401,9 +397,11 @@ declare const EventDeepResearchCrawlSummary = "soothe.subagent.deep_research.cra
401
397
  declare const EventDeepResearchCompleted = "soothe.subagent.deep_research.completed";
402
398
  declare const EventReplayComplete = "replay_complete";
403
399
  declare const EventLoopReattachedWire = "loop_reattached";
404
- declare const EventCardReplayBegin = "card.replay_begin";
405
- declare const EventCardCreated = "card.created";
406
- declare const EventCardReplayEnd = "card.replay_end";
400
+ declare const EventCardCreated = "soothe.card.created";
401
+ declare const EventCardUpdated = "soothe.card.updated";
402
+ declare const EventCardFinalized = "soothe.card.finalized";
403
+ declare const EventCardReplayBegin = "soothe.card.replay.begin";
404
+ declare const EventCardReplayEnd = "soothe.card.replay.end";
407
405
  declare const EventToolStarted = "soothe.tool.execution.started";
408
406
  declare const EventToolCompleted = "soothe.tool.execution.completed";
409
407
  declare const EventToolError = "soothe.tool.execution.error";
@@ -670,8 +668,6 @@ declare class Client extends EventEmitter {
670
668
  sendLoopStateGet(loopID: string): Promise<void>;
671
669
  /** Applies partial checkpoint values. */
672
670
  sendLoopStateUpdate(loopID: string, values: Record<string, unknown>, asNode?: string): Promise<void>;
673
- /** Requests display card ledger snapshot. */
674
- sendLoopCardsFetch(loopID: string): Promise<void>;
675
671
  /** Requests the full loop history. */
676
672
  sendLoopHistoryFetch(loopID: string): Promise<void>;
677
673
  /** Requests MCP server status. */
@@ -688,8 +684,6 @@ declare class Client extends EventEmitter {
688
684
  getLoopState(loopID: string, timeout?: number): Promise<Record<string, unknown>>;
689
685
  /** Updates loop state and waits for response. */
690
686
  updateLoopState(loopID: string, values: Record<string, unknown>, asNode?: string, timeout?: number): Promise<Record<string, unknown>>;
691
- /** Requests display cards and waits for response. */
692
- fetchLoopCards(loopID: string, timeout?: number): Promise<Record<string, unknown>>;
693
687
  /** Requests MCP status and waits for response. */
694
688
  getMCPStatus(timeout?: number): Promise<Record<string, unknown>>;
695
689
  /** Requests loop history and waits for response. */
@@ -830,8 +824,6 @@ declare function fetchLoopHistory(client: Client, loopID: string, timeout?: numb
830
824
  declare function authenticate(client: Client, accessKey: string, secretKey: string, timeout?: number): Promise<Record<string, unknown>>;
831
825
  /** Refreshes the daemon-side auth token and waits for the response. */
832
826
  declare function refreshAuthToken(client: Client, refreshToken: string, timeout?: number): Promise<Record<string, unknown>>;
833
- /** Fetch bound display-card snapshot for a loop. */
834
- declare function fetchLoopCards(client: Client, loopID: string, timeout?: number): Promise<Record<string, unknown>>;
835
827
  /** Fetch persisted conversation/activity rows for a loop. */
836
828
  declare function fetchLoopMessages(client: Client, loopID: string, opts?: {
837
829
  limit?: number;
@@ -891,7 +883,7 @@ declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolea
891
883
  /**
892
884
  * Persistence seam for appkit.
893
885
  *
894
- * SessionStore abstracts per-application storage: the session↔loop-id mapping
886
+ * LoopSessionStore abstracts per-application storage: the session↔loop-id mapping
895
887
  * that ConnectionPool consults to decide bootstrap vs reattach, and the
896
888
  * message rows TurnRunner writes back when a turn completes. Applications
897
889
  * implement this against their own store (Postgres, Redis, in-memory, …).
@@ -899,7 +891,7 @@ declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolea
899
891
  * Implementations must be safe for concurrent use.
900
892
  */
901
893
  /** Persisted mapping between an application session id and the daemon loop id. */
902
- interface SessionEntry {
894
+ interface LoopSessionEntry {
903
895
  workspaceID: string;
904
896
  sessionID: string;
905
897
  loopID: string;
@@ -928,9 +920,9 @@ interface SessionMessage {
928
920
  * loop id once bootstrapped. TurnRunner persists the final assistant reply
929
921
  * and error rows via appendMessage.
930
922
  */
931
- interface SessionStore {
923
+ interface LoopSessionStore {
932
924
  /** Returns the persisted entry for sessionID, or null if no record exists. */
933
- getSession(sessionID: string): Promise<SessionEntry | null>;
925
+ getSession(sessionID: string): Promise<LoopSessionEntry | null>;
934
926
  /** Persists a new session↔loop mapping. */
935
927
  createSession(workspaceID: string, sessionID: string, loopID: string, sessionType: string): Promise<void>;
936
928
  /** Stamps the session's last-used timestamp. */
@@ -1221,7 +1213,7 @@ type BootstrapFunc = (client: ManagedClient, workspaceID: string, userID: string
1221
1213
  * active connection when still live, otherwise bootstraps a fresh loop
1222
1214
  * (loop_new + subscribe) or reattaches an existing one (loop_reattach +
1223
1215
  * subscribe + reattachAndProbe). Persistence of session↔loop mappings is
1224
- * abstracted behind SessionStore.
1216
+ * abstracted behind LoopSessionStore.
1225
1217
  *
1226
1218
  * The app-agnostic successor to triarch's SoothePoolManager connection
1227
1219
  * mechanics.
@@ -1276,7 +1268,7 @@ declare class ConnectionPool {
1276
1268
  * defaultPoolConfig is used; if scfg is null, defaultConfig is used; nil
1277
1269
  * factory/bootstrap fall back to the defaults.
1278
1270
  */
1279
- constructor(url: string, store: SessionStore, cfg?: PoolConfig | null, scfg?: Config | null, factory?: ClientFactory | null);
1271
+ constructor(url: string, store: LoopSessionStore, cfg?: PoolConfig | null, scfg?: Config | null, factory?: ClientFactory | null);
1280
1272
  /** Overrides the loop bootstrap function (useful for test fakes). */
1281
1273
  withBootstrap(f: BootstrapFunc): ConnectionPool;
1282
1274
  /**
@@ -1413,7 +1405,7 @@ declare class TurnRunner {
1413
1405
  private buildInput;
1414
1406
  private onComplete;
1415
1407
  private onError;
1416
- constructor(pool: ConnectionPool, gate: QueryGate, classifier: EventClassifier, store: SessionStore, broadcaster: SSEBroadcaster | null, cfg: TurnConfig);
1408
+ constructor(pool: ConnectionPool, gate: QueryGate, classifier: EventClassifier, store: LoopSessionStore, broadcaster: SSEBroadcaster | null, cfg: TurnConfig);
1417
1409
  withInputBuilder(f: typeof inputMessageForLoop): TurnRunner;
1418
1410
  withOnComplete(f: OnComplete): TurnRunner;
1419
1411
  withOnError(f: OnError): TurnRunner;
@@ -1547,12 +1539,6 @@ declare class DaemonSession {
1547
1539
  private withRpcLock;
1548
1540
  private ensureRpcConnected;
1549
1541
  listLoops(_limit?: number): Promise<Record<string, unknown>>;
1550
- fetchLoopCards(loopId: string): Promise<{
1551
- cards: unknown[];
1552
- seq: number;
1553
- contextTokens: number;
1554
- success: boolean;
1555
- }>;
1556
1542
  fetchLoopHistory(loopId: string): Promise<{
1557
1543
  goals: unknown[];
1558
1544
  liveCards: unknown[];
@@ -1570,4 +1556,42 @@ declare class DaemonSession {
1570
1556
  }): AsyncGenerator<TurnChunk>;
1571
1557
  }
1572
1558
 
1573
- export { type Attachment, type BaseEnvelope, CLIENT_VERSION, type ChatEventResult, ChatEventTerminal, type ClassifierConfig, Client, CommandClient, type CompactImageOptions, type CompleteEnvelope, type Config, type ConnectionAckEnvelope, ConnectionError, type ConnectionInitEnvelope, ConnectionPool, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_DELIVERABLE_PHASES, DEFAULT_POST_IDLE_DRAIN_MS, DEFAULT_THINKING_STEP_EVENTS, DaemonError, DaemonSession, type DaemonSessionOptions, type DecodedMessage, DisconnectCause, type DisconnectEnvelope, ErrIdleTimeout, ErrPoolExhausted, ErrQueryBusy, ErrQueryTimeout, type ErrorEnvelope, EventAutopilotGoalCompleted, EventAutopilotGoalCreated, EventAutopilotGoalProgress, EventAutopilotGoalStatus, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventCardCreated, EventCardReplayBegin, EventCardReplayEnd, EventClassifier, EventDeepResearchCompleted, EventDeepResearchCrawlSummary, EventDeepResearchGatherSummary, EventDeepResearchProgress, EventDeepResearchStarted, EventDeepResearchStepCompleted, EventExplorerCompleted, EventExplorerMilestone, EventExplorerStarted, EventExplorerStepCompleted, EventFinalReport, EventGeneralFailed, EventLoopReattachedWire, EventMessageReceived, EventMessageSent, EventPlanCreated, EventReplayComplete, EventStrangeLoopCompleted, EventStrangeLoopContextCompacted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStarted, EventStrangeLoopStepCompleted, EventStrangeLoopStepQueued, EventStrangeLoopStepStarted, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventToolCompleted, EventToolError, EventToolStarted, INTENT_HINT_EMBED, INTENT_HINT_IMAGE_TO_TEXT, INTENT_HINT_OCR, INTENT_HINT_TEXT_COMPLETION, type InputOptions, type InputOpts, type IntentHint, LOOP_ASSISTANT_OUTPUT_PHASES, type LoopAssistantOutputPhase, type LoopInputIntentHint, type LoopInputParams, type LoopNewOptions, type MessageType, type MethodName, type NegotiatedCapabilities, type NextEnvelope, type NotificationEnvelope, type OnComplete, type OnError, PROTO_VERSION, type PingEnvelope, type PongEnvelope, type PoolConfig, PooledConn, QueryGate, REMOVED_INTENT_HINTS, type ReceiptResponseEnvelope, ReconnectError, type RemovedIntentHint, type RequestEnvelope, type ResponseEnvelope, SSEBroadcaster, type SSEEvent, STREAM_END, type SessionEntry, type SessionMessage, type SessionStore, StaleLoopError, type StatusFrame, StreamCloseFail, type StreamClosePolicy, StreamCloseSoftComplete, type StreamEventPayload, type SubscribeEnvelope, TURN_END_IDLE, TURN_END_STOPPED, TURN_END_STREAM_END, TimeoutError, TimeoutPolicy, TurnBoundary, type TurnChunk, type TurnConfig, TurnEventStats, TurnLifecycleGate, TurnRunner, type UnsubscribeEnvelope, type VerbosityLevel, VerbosityTier, authenticate, bootstrapLoopSession, checkDaemonStatus, classifyEventVerbosity, compactAttachments, compactImageAttachment, connectWithRetries, connectedWebsocket, connectionInitEnvelope, decodeMessage, defaultConfig, defaultPoolConfig, disconnectCauseName, disconnectEnvelope, encodeMessage, extractSootheLoopID, extractThinkingStep, fetchConfigSection, fetchLoopCards, fetchLoopHistory, fetchLoopMessages, fetchSkillsCatalog, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseNamespace, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, unsubscribeEnvelope, validateLoopInputIntentHint, waitDaemonReady, waitLoopStatusWithID, waitSubscriptionConfirmed };
1559
+ /**
1560
+ * In-memory apply helpers for daemon `soothe.card.*` frames.
1561
+ *
1562
+ * Language clients stay transport/appkit — this projects card_id → wire dict
1563
+ * without mounting UI widgets.
1564
+ */
1565
+
1566
+ type CardWireDict = Record<string, unknown> & {
1567
+ id?: string;
1568
+ type?: string;
1569
+ content?: string;
1570
+ };
1571
+ type ParsedCardFrame = {
1572
+ wireType: typeof EventCardReplayBegin | typeof EventCardReplayEnd;
1573
+ card: null;
1574
+ patch: Record<string, unknown>;
1575
+ } | {
1576
+ wireType: typeof EventCardCreated;
1577
+ card: CardWireDict;
1578
+ patch: Record<string, unknown>;
1579
+ } | {
1580
+ wireType: typeof EventCardUpdated | typeof EventCardFinalized;
1581
+ card: null;
1582
+ patch: Record<string, unknown>;
1583
+ };
1584
+ /** Parse a custom-mode card frame, or null if not a card frame. */
1585
+ declare function parseCardCustomPayload(data: unknown): ParsedCardFrame | null;
1586
+ /** card_id → wire dict projection driven by `soothe.card.*` frames. */
1587
+ declare class CardProjection {
1588
+ private cards;
1589
+ private _replaying;
1590
+ get replaying(): boolean;
1591
+ snapshot(): CardWireDict[];
1592
+ get(cardId: string): CardWireDict | undefined;
1593
+ /** Apply one custom-mode card payload. Returns true when handled. */
1594
+ apply(data: unknown): boolean;
1595
+ }
1596
+
1597
+ export { type Attachment, type BaseEnvelope, CLIENT_VERSION, CardProjection, type CardWireDict, type ChatEventResult, ChatEventTerminal, type ClassifierConfig, Client, CommandClient, type CompactImageOptions, type CompleteEnvelope, type Config, type ConnectionAckEnvelope, ConnectionError, type ConnectionInitEnvelope, ConnectionPool, DEFAULT_CLIENT_CAPABILITIES, DEFAULT_DELIVERABLE_PHASES, DEFAULT_POST_IDLE_DRAIN_MS, DEFAULT_THINKING_STEP_EVENTS, DaemonError, DaemonSession, type DaemonSessionOptions, type DecodedMessage, DisconnectCause, type DisconnectEnvelope, ErrIdleTimeout, ErrPoolExhausted, ErrQueryBusy, ErrQueryTimeout, type ErrorEnvelope, EventAutopilotGoalCompleted, EventAutopilotGoalCreated, EventAutopilotGoalProgress, EventAutopilotGoalStatus, EventAutopilotWorkerAssigned, EventAutopilotWorkerUnassigned, EventCardCreated, EventCardFinalized, EventCardReplayBegin, EventCardReplayEnd, EventCardUpdated, EventClassifier, EventDeepResearchCompleted, EventDeepResearchCrawlSummary, EventDeepResearchGatherSummary, EventDeepResearchProgress, EventDeepResearchStarted, EventDeepResearchStepCompleted, EventFinalReport, EventGeneralFailed, EventLoopReattachedWire, EventMessageReceived, EventMessageSent, EventPlanCreated, EventReplayComplete, EventStrangeLoopCompleted, EventStrangeLoopContextCompacted, EventStrangeLoopPlanDecision, EventStrangeLoopReasoned, EventStrangeLoopStarted, EventStrangeLoopStepCompleted, EventStrangeLoopStepQueued, EventStrangeLoopStepStarted, EventStreamToolCallUpdate, EventToolCallUpdatesBatch, EventToolCompleted, EventToolError, EventToolStarted, INTENT_HINT_EMBED, INTENT_HINT_IMAGE_TO_TEXT, INTENT_HINT_OCR, INTENT_HINT_TEXT_COMPLETION, type InputOptions, type InputOpts, type IntentHint, LOOP_ASSISTANT_OUTPUT_PHASES, type LoopAssistantOutputPhase, type LoopInputIntentHint, type LoopInputParams, type LoopNewOptions, type LoopSessionEntry, type LoopSessionStore, type MessageType, type MethodName, type NegotiatedCapabilities, type NextEnvelope, type NotificationEnvelope, type OnComplete, type OnError, PROTO_VERSION, type ParsedCardFrame, type PingEnvelope, type PongEnvelope, type PoolConfig, PooledConn, QueryGate, REMOVED_INTENT_HINTS, type ReceiptResponseEnvelope, ReconnectError, type RemovedIntentHint, type RequestEnvelope, type ResponseEnvelope, SSEBroadcaster, type SSEEvent, STREAM_END, type SessionMessage, StaleLoopError, type StatusFrame, StreamCloseFail, type StreamClosePolicy, StreamCloseSoftComplete, type StreamEventPayload, type SubscribeEnvelope, TURN_END_IDLE, TURN_END_STOPPED, TURN_END_STREAM_END, TimeoutError, TimeoutPolicy, TurnBoundary, type TurnChunk, type TurnConfig, TurnEventStats, TurnLifecycleGate, TurnRunner, type UnsubscribeEnvelope, type VerbosityLevel, VerbosityTier, authenticate, bootstrapLoopSession, checkDaemonStatus, classifyEventVerbosity, compactAttachments, compactImageAttachment, connectWithRetries, connectedWebsocket, connectionInitEnvelope, decodeMessage, defaultConfig, defaultPoolConfig, disconnectCauseName, disconnectEnvelope, encodeMessage, extractSootheLoopID, extractThinkingStep, fetchConfigSection, fetchLoopHistory, fetchLoopMessages, fetchSkillsCatalog, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseCardCustomPayload, parseNamespace, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, unsubscribeEnvelope, validateLoopInputIntentHint, waitDaemonReady, waitLoopStatusWithID, waitSubscriptionConfirmed };
package/dist/index.js CHANGED
@@ -13,18 +13,16 @@ import {
13
13
  EventAutopilotWorkerAssigned,
14
14
  EventAutopilotWorkerUnassigned,
15
15
  EventCardCreated,
16
+ EventCardFinalized,
16
17
  EventCardReplayBegin,
17
18
  EventCardReplayEnd,
19
+ EventCardUpdated,
18
20
  EventDeepResearchCompleted,
19
21
  EventDeepResearchCrawlSummary,
20
22
  EventDeepResearchGatherSummary,
21
23
  EventDeepResearchProgress,
22
24
  EventDeepResearchStarted,
23
25
  EventDeepResearchStepCompleted,
24
- EventExplorerCompleted,
25
- EventExplorerMilestone,
26
- EventExplorerStarted,
27
- EventExplorerStepCompleted,
28
26
  EventFinalReport,
29
27
  EventGeneralFailed,
30
28
  EventLoopReattachedWire,
@@ -86,7 +84,7 @@ import {
86
84
  subscribeEnvelope,
87
85
  unsubscribeEnvelope,
88
86
  validateLoopInputIntentHint
89
- } from "./chunk-ZMZVHADX.js";
87
+ } from "./chunk-XEZBHENR.js";
90
88
 
91
89
  // src/session.ts
92
90
  async function bootstrapLoopSession(client, resumeLoopId, config, loopNew) {
@@ -289,7 +287,7 @@ async function checkDaemonStatus(client, timeout) {
289
287
  return client.requestResponse("daemon_status", {}, "daemon_status", timeout ?? 5e3);
290
288
  }
291
289
  async function isDaemonLive(wsURL, timeout) {
292
- const { Client: Client2 } = await import("./client-SBKRN2OQ.js");
290
+ const { Client: Client2 } = await import("./client-TQNJNIH2.js");
293
291
  const t = timeout ?? 5e3;
294
292
  const client = new Client2(wsURL, defaultConfig());
295
293
  try {
@@ -363,9 +361,6 @@ async function refreshAuthToken(client, refreshToken, timeout) {
363
361
  timeout ?? 15e3
364
362
  );
365
363
  }
366
- async function fetchLoopCards(client, loopID, timeout) {
367
- return client.fetchLoopCards(loopID, timeout);
368
- }
369
364
  async function fetchLoopMessages(client, loopID, opts) {
370
365
  return client.getLoopMessages(
371
366
  loopID,
@@ -376,7 +371,7 @@ async function fetchLoopMessages(client, loopID, opts) {
376
371
  );
377
372
  }
378
373
  async function connectedWebsocket(wsUrl, fn, timeoutMs = 3e4) {
379
- const { Client: Client2 } = await import("./client-SBKRN2OQ.js");
374
+ const { Client: Client2 } = await import("./client-TQNJNIH2.js");
380
375
  const client = new Client2(wsUrl, defaultConfig());
381
376
  const deadline = Date.now() + timeoutMs;
382
377
  try {
@@ -2115,25 +2110,6 @@ var DaemonSession = class {
2115
2110
  return this.rpcClient.listLoops(15e3);
2116
2111
  });
2117
2112
  }
2118
- async fetchLoopCards(loopId) {
2119
- const lid = String(loopId || "").trim();
2120
- if (!lid) return { cards: [], seq: 0, contextTokens: 0, success: false };
2121
- return this.withRpcLock(async () => {
2122
- await this.ensureRpcConnected();
2123
- try {
2124
- const resp = await this.rpcClient.fetchLoopCards(lid, 3e4);
2125
- const rawCards = resp.cards;
2126
- return {
2127
- cards: Array.isArray(rawCards) ? rawCards : [],
2128
- seq: Number(resp.seq ?? 0),
2129
- contextTokens: typeof resp.context_tokens === "number" && resp.context_tokens >= 0 ? resp.context_tokens : 0,
2130
- success: true
2131
- };
2132
- } catch {
2133
- return { cards: [], seq: 0, contextTokens: 0, success: false };
2134
- }
2135
- });
2136
- }
2137
2113
  async fetchLoopHistory(loopId) {
2138
2114
  const lid = String(loopId || "").trim();
2139
2115
  if (!lid) {
@@ -2281,8 +2257,86 @@ var DaemonSession = class {
2281
2257
  }
2282
2258
  }
2283
2259
  };
2260
+
2261
+ // src/display/cardProjection.ts
2262
+ var CARD_MUTATION_TYPES = /* @__PURE__ */ new Set([
2263
+ EventCardCreated,
2264
+ EventCardUpdated,
2265
+ EventCardFinalized,
2266
+ EventCardReplayBegin,
2267
+ EventCardReplayEnd
2268
+ ]);
2269
+ function parseCardCustomPayload(data) {
2270
+ if (!data || typeof data !== "object") return null;
2271
+ const d = data;
2272
+ const wireType = String(d.type ?? "").trim();
2273
+ if (!CARD_MUTATION_TYPES.has(wireType)) return null;
2274
+ if (wireType === EventCardReplayBegin || wireType === EventCardReplayEnd) {
2275
+ return { wireType, card: null, patch: {} };
2276
+ }
2277
+ const payload = d.data && typeof d.data === "object" ? { ...d.data } : {};
2278
+ const cardId = String(d.card_id ?? payload.id ?? "").trim();
2279
+ if (wireType === EventCardCreated) {
2280
+ if (!payload.type || payload.content === void 0) return null;
2281
+ if (!payload.id && cardId) payload.id = cardId;
2282
+ return { wireType, card: payload, patch: {} };
2283
+ }
2284
+ if (!payload.id && cardId) payload.id = cardId;
2285
+ return {
2286
+ wireType,
2287
+ card: null,
2288
+ patch: payload
2289
+ };
2290
+ }
2291
+ var CardProjection = class {
2292
+ cards = /* @__PURE__ */ new Map();
2293
+ _replaying = false;
2294
+ get replaying() {
2295
+ return this._replaying;
2296
+ }
2297
+ snapshot() {
2298
+ return [...this.cards.values()];
2299
+ }
2300
+ get(cardId) {
2301
+ return this.cards.get(cardId);
2302
+ }
2303
+ /** Apply one custom-mode card payload. Returns true when handled. */
2304
+ apply(data) {
2305
+ const parsed = parseCardCustomPayload(data);
2306
+ if (!parsed) return false;
2307
+ if (parsed.wireType === EventCardReplayBegin) {
2308
+ this._replaying = true;
2309
+ this.cards.clear();
2310
+ return true;
2311
+ }
2312
+ if (parsed.wireType === EventCardReplayEnd) {
2313
+ this._replaying = false;
2314
+ return true;
2315
+ }
2316
+ if (parsed.wireType === EventCardCreated && parsed.card) {
2317
+ const id = String(parsed.card.id ?? "").trim();
2318
+ if (id) this.cards.set(id, { ...parsed.card });
2319
+ return true;
2320
+ }
2321
+ if (parsed.wireType === EventCardUpdated || parsed.wireType === EventCardFinalized) {
2322
+ const id = String(parsed.patch.id ?? "").trim();
2323
+ if (!id) return true;
2324
+ const existing = this.cards.get(id);
2325
+ if (!existing) return true;
2326
+ const next = { ...existing };
2327
+ for (const [key, value] of Object.entries(parsed.patch)) {
2328
+ if (key === "id" || key === "type") continue;
2329
+ next[key] = value;
2330
+ }
2331
+ this.cards.set(id, next);
2332
+ return true;
2333
+ }
2334
+ return true;
2335
+ }
2336
+ };
2284
2337
  export {
2285
2338
  CLIENT_VERSION,
2339
+ CardProjection,
2286
2340
  ChatEventTerminal,
2287
2341
  Client,
2288
2342
  CommandClient,
@@ -2306,8 +2360,10 @@ export {
2306
2360
  EventAutopilotWorkerAssigned,
2307
2361
  EventAutopilotWorkerUnassigned,
2308
2362
  EventCardCreated,
2363
+ EventCardFinalized,
2309
2364
  EventCardReplayBegin,
2310
2365
  EventCardReplayEnd,
2366
+ EventCardUpdated,
2311
2367
  EventClassifier,
2312
2368
  EventDeepResearchCompleted,
2313
2369
  EventDeepResearchCrawlSummary,
@@ -2315,10 +2371,6 @@ export {
2315
2371
  EventDeepResearchProgress,
2316
2372
  EventDeepResearchStarted,
2317
2373
  EventDeepResearchStepCompleted,
2318
- EventExplorerCompleted,
2319
- EventExplorerMilestone,
2320
- EventExplorerStarted,
2321
- EventExplorerStepCompleted,
2322
2374
  EventFinalReport,
2323
2375
  EventGeneralFailed,
2324
2376
  EventLoopReattachedWire,
@@ -2382,7 +2434,6 @@ export {
2382
2434
  extractSootheLoopID,
2383
2435
  extractThinkingStep,
2384
2436
  fetchConfigSection,
2385
- fetchLoopCards,
2386
2437
  fetchLoopHistory,
2387
2438
  fetchLoopMessages,
2388
2439
  fetchSkillsCatalog,
@@ -2402,6 +2453,7 @@ export {
2402
2453
  newLoopSubscribeMessage,
2403
2454
  newRequestID,
2404
2455
  notificationEnvelope,
2456
+ parseCardCustomPayload,
2405
2457
  parseNamespace,
2406
2458
  pingEnvelope,
2407
2459
  pongEnvelope,