@mirasoth/soothe-client 0.5.5 → 0.5.7
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/{chunk-XEZBHENR.js → chunk-56Z7SUGW.js} +11 -1
- package/dist/chunk-56Z7SUGW.js.map +1 -0
- package/dist/client-CUYIRMFW.js +7 -0
- package/dist/index.cjs +174 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -5
- package/dist/index.d.ts +37 -5
- package/dist/index.js +160 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-XEZBHENR.js.map +0 -1
- package/dist/client-TQNJNIH2.js +0 -7
- /package/dist/{client-TQNJNIH2.js.map → client-CUYIRMFW.js.map} +0 -0
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_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" | "autopilot_top" | "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;
|
|
@@ -734,6 +734,11 @@ declare class Client extends EventEmitter {
|
|
|
734
734
|
autopilotListJobs(timeout?: number): Promise<Record<string, unknown>>;
|
|
735
735
|
/** Get a root job with DAG snapshot. Prefer getJobStatus / getJobDag. */
|
|
736
736
|
autopilotGetJob(jobId: string, timeout?: number): Promise<Record<string, unknown>>;
|
|
737
|
+
/** Jobs → goals → loops snapshot for CLI top. */
|
|
738
|
+
autopilotTop(timeoutOrOptions?: number | {
|
|
739
|
+
includeTerminal?: boolean;
|
|
740
|
+
timeout?: number;
|
|
741
|
+
}): Promise<Record<string, unknown>>;
|
|
737
742
|
/** Subscribes to autopilot worker events. */
|
|
738
743
|
autopilotSubscribe(timeout?: number): Promise<string>;
|
|
739
744
|
/** Unsubscribes from autopilot worker events. */
|
|
@@ -798,6 +803,8 @@ declare class CommandClient {
|
|
|
798
803
|
autopilotListJobs(): Promise<Record<string, unknown>>;
|
|
799
804
|
/** Get a root job with DAG snapshot. Prefer jobStatus / getJobDag. */
|
|
800
805
|
autopilotGetJob(jobId: string): Promise<Record<string, unknown>>;
|
|
806
|
+
/** Jobs → goals → loops snapshot for CLI top. */
|
|
807
|
+
autopilotTop(includeTerminal?: boolean): Promise<Record<string, unknown>>;
|
|
801
808
|
cronAdd(text: string, priority?: number): Promise<Record<string, unknown>>;
|
|
802
809
|
cronList(status?: string): Promise<Record<string, unknown>>;
|
|
803
810
|
}
|
|
@@ -880,6 +887,30 @@ declare function isTurnProgressChunk(mode: string, data: unknown): boolean;
|
|
|
880
887
|
/** True when the client should bump delivery_ack sequence for this frame. */
|
|
881
888
|
declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolean;
|
|
882
889
|
|
|
890
|
+
/**
|
|
891
|
+
* Turn / stream boundary helpers (`turn_id` / `seq`).
|
|
892
|
+
* Used by DaemonSession for demuxing concurrent goal turns.
|
|
893
|
+
*/
|
|
894
|
+
declare function formatTurnId(loopId: string, generation: number): string;
|
|
895
|
+
declare function parseTurnGeneration(turnId: string | null | undefined): number | null;
|
|
896
|
+
declare function frameTurnId(frame: Record<string, unknown> | null | undefined): string | null;
|
|
897
|
+
declare function frameSeq(frame: Record<string, unknown> | null | undefined): number | null;
|
|
898
|
+
/** Absent ids never match. */
|
|
899
|
+
declare function turnIdsMatch(expected: string | null | undefined, candidate: string | null | undefined): boolean;
|
|
900
|
+
declare function isTurnTerminalAllowed(opts: {
|
|
901
|
+
expectedTurnId: string | null | undefined;
|
|
902
|
+
frameTurnId: string | null | undefined;
|
|
903
|
+
queryStarted: boolean;
|
|
904
|
+
turnProgressSeen: boolean;
|
|
905
|
+
}): boolean;
|
|
906
|
+
declare function isIdleTerminalAllowed(opts: {
|
|
907
|
+
expectedTurnId: string | null | undefined;
|
|
908
|
+
frameTurnId: string | null | undefined;
|
|
909
|
+
queryStarted: boolean;
|
|
910
|
+
turnProgressSeen: boolean;
|
|
911
|
+
cancellationSeen?: boolean;
|
|
912
|
+
}): boolean;
|
|
913
|
+
|
|
883
914
|
/**
|
|
884
915
|
* Persistence seam for appkit.
|
|
885
916
|
*
|
|
@@ -1431,11 +1462,12 @@ declare const TURN_END_IDLE = "status.idle";
|
|
|
1431
1462
|
declare const TURN_END_STOPPED = "status.stopped";
|
|
1432
1463
|
declare class TurnLifecycleGate {
|
|
1433
1464
|
sawRunning: boolean;
|
|
1434
|
-
sawStreamPayload: boolean;
|
|
1435
1465
|
sawTurnProgress: boolean;
|
|
1466
|
+
expectedTurnId: string | null;
|
|
1467
|
+
cancellationSeen: boolean;
|
|
1436
1468
|
observe(msg: unknown): void;
|
|
1437
|
-
allowStreamEnd(): boolean;
|
|
1438
|
-
allowIdleComplete(): boolean;
|
|
1469
|
+
allowStreamEnd(frameTurn: string | null): boolean;
|
|
1470
|
+
allowIdleComplete(frameTurn: string | null): boolean;
|
|
1439
1471
|
}
|
|
1440
1472
|
declare class TurnBoundary {
|
|
1441
1473
|
readonly gate: TurnLifecycleGate;
|
|
@@ -1594,4 +1626,4 @@ declare class CardProjection {
|
|
|
1594
1626
|
apply(data: unknown): boolean;
|
|
1595
1627
|
}
|
|
1596
1628
|
|
|
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 };
|
|
1629
|
+
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, formatTurnId, frameSeq, frameTurnId, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isIdleTerminalAllowed, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isTurnTerminalAllowed, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseCardCustomPayload, parseNamespace, parseTurnGeneration, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, turnIdsMatch, 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_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" | "autopilot_top" | "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;
|
|
@@ -734,6 +734,11 @@ declare class Client extends EventEmitter {
|
|
|
734
734
|
autopilotListJobs(timeout?: number): Promise<Record<string, unknown>>;
|
|
735
735
|
/** Get a root job with DAG snapshot. Prefer getJobStatus / getJobDag. */
|
|
736
736
|
autopilotGetJob(jobId: string, timeout?: number): Promise<Record<string, unknown>>;
|
|
737
|
+
/** Jobs → goals → loops snapshot for CLI top. */
|
|
738
|
+
autopilotTop(timeoutOrOptions?: number | {
|
|
739
|
+
includeTerminal?: boolean;
|
|
740
|
+
timeout?: number;
|
|
741
|
+
}): Promise<Record<string, unknown>>;
|
|
737
742
|
/** Subscribes to autopilot worker events. */
|
|
738
743
|
autopilotSubscribe(timeout?: number): Promise<string>;
|
|
739
744
|
/** Unsubscribes from autopilot worker events. */
|
|
@@ -798,6 +803,8 @@ declare class CommandClient {
|
|
|
798
803
|
autopilotListJobs(): Promise<Record<string, unknown>>;
|
|
799
804
|
/** Get a root job with DAG snapshot. Prefer jobStatus / getJobDag. */
|
|
800
805
|
autopilotGetJob(jobId: string): Promise<Record<string, unknown>>;
|
|
806
|
+
/** Jobs → goals → loops snapshot for CLI top. */
|
|
807
|
+
autopilotTop(includeTerminal?: boolean): Promise<Record<string, unknown>>;
|
|
801
808
|
cronAdd(text: string, priority?: number): Promise<Record<string, unknown>>;
|
|
802
809
|
cronList(status?: string): Promise<Record<string, unknown>>;
|
|
803
810
|
}
|
|
@@ -880,6 +887,30 @@ declare function isTurnProgressChunk(mode: string, data: unknown): boolean;
|
|
|
880
887
|
/** True when the client should bump delivery_ack sequence for this frame. */
|
|
881
888
|
declare function inboundNeedsDeliveryAck(event: Record<string, unknown>): boolean;
|
|
882
889
|
|
|
890
|
+
/**
|
|
891
|
+
* Turn / stream boundary helpers (`turn_id` / `seq`).
|
|
892
|
+
* Used by DaemonSession for demuxing concurrent goal turns.
|
|
893
|
+
*/
|
|
894
|
+
declare function formatTurnId(loopId: string, generation: number): string;
|
|
895
|
+
declare function parseTurnGeneration(turnId: string | null | undefined): number | null;
|
|
896
|
+
declare function frameTurnId(frame: Record<string, unknown> | null | undefined): string | null;
|
|
897
|
+
declare function frameSeq(frame: Record<string, unknown> | null | undefined): number | null;
|
|
898
|
+
/** Absent ids never match. */
|
|
899
|
+
declare function turnIdsMatch(expected: string | null | undefined, candidate: string | null | undefined): boolean;
|
|
900
|
+
declare function isTurnTerminalAllowed(opts: {
|
|
901
|
+
expectedTurnId: string | null | undefined;
|
|
902
|
+
frameTurnId: string | null | undefined;
|
|
903
|
+
queryStarted: boolean;
|
|
904
|
+
turnProgressSeen: boolean;
|
|
905
|
+
}): boolean;
|
|
906
|
+
declare function isIdleTerminalAllowed(opts: {
|
|
907
|
+
expectedTurnId: string | null | undefined;
|
|
908
|
+
frameTurnId: string | null | undefined;
|
|
909
|
+
queryStarted: boolean;
|
|
910
|
+
turnProgressSeen: boolean;
|
|
911
|
+
cancellationSeen?: boolean;
|
|
912
|
+
}): boolean;
|
|
913
|
+
|
|
883
914
|
/**
|
|
884
915
|
* Persistence seam for appkit.
|
|
885
916
|
*
|
|
@@ -1431,11 +1462,12 @@ declare const TURN_END_IDLE = "status.idle";
|
|
|
1431
1462
|
declare const TURN_END_STOPPED = "status.stopped";
|
|
1432
1463
|
declare class TurnLifecycleGate {
|
|
1433
1464
|
sawRunning: boolean;
|
|
1434
|
-
sawStreamPayload: boolean;
|
|
1435
1465
|
sawTurnProgress: boolean;
|
|
1466
|
+
expectedTurnId: string | null;
|
|
1467
|
+
cancellationSeen: boolean;
|
|
1436
1468
|
observe(msg: unknown): void;
|
|
1437
|
-
allowStreamEnd(): boolean;
|
|
1438
|
-
allowIdleComplete(): boolean;
|
|
1469
|
+
allowStreamEnd(frameTurn: string | null): boolean;
|
|
1470
|
+
allowIdleComplete(frameTurn: string | null): boolean;
|
|
1439
1471
|
}
|
|
1440
1472
|
declare class TurnBoundary {
|
|
1441
1473
|
readonly gate: TurnLifecycleGate;
|
|
@@ -1594,4 +1626,4 @@ declare class CardProjection {
|
|
|
1594
1626
|
apply(data: unknown): boolean;
|
|
1595
1627
|
}
|
|
1596
1628
|
|
|
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 };
|
|
1629
|
+
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, formatTurnId, frameSeq, frameTurnId, idleTimeoutForTurn, inboundNeedsDeliveryAck, inputMessageForLoop, isCompletionEvent, isDaemonLive, isDaemonTurnEndEvent, isIdleTerminalAllowed, isSubagentProgressEvent, isTurnEndCustomData, isTurnProgressChunk, isTurnTerminalAllowed, isValidVerbosityLevel, loadConfigFromEnv, newLoopInputMessage, newLoopNewMessage, newLoopSubscribeMessage, newRequestID, notificationEnvelope, parseCardCustomPayload, parseNamespace, parseTurnGeneration, pingEnvelope, pongEnvelope, protocol1Rpc, refreshAuthToken, requestDaemonConfigReload, requestDaemonShutdown, requestEnvelope, shouldShow, splitWirePayload, subscribeEnvelope, turnIdsMatch, unsubscribeEnvelope, validateLoopInputIntentHint, waitDaemonReady, waitLoopStatusWithID, waitSubscriptionConfirmed };
|
package/dist/index.js
CHANGED
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
subscribeEnvelope,
|
|
85
85
|
unsubscribeEnvelope,
|
|
86
86
|
validateLoopInputIntentHint
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-56Z7SUGW.js";
|
|
88
88
|
|
|
89
89
|
// src/session.ts
|
|
90
90
|
async function bootstrapLoopSession(client, resumeLoopId, config, loopNew) {
|
|
@@ -270,6 +270,10 @@ var CommandClient = class {
|
|
|
270
270
|
async autopilotGetJob(jobId) {
|
|
271
271
|
return this.request("autopilot_get_job", { job_id: jobId });
|
|
272
272
|
}
|
|
273
|
+
/** Jobs → goals → loops snapshot for CLI top. */
|
|
274
|
+
async autopilotTop(includeTerminal = false) {
|
|
275
|
+
return this.request("autopilot_top", { include_terminal: includeTerminal });
|
|
276
|
+
}
|
|
273
277
|
async cronAdd(text, priority = 0) {
|
|
274
278
|
const params = { text };
|
|
275
279
|
if (priority > 0) params.priority = priority;
|
|
@@ -287,7 +291,7 @@ async function checkDaemonStatus(client, timeout) {
|
|
|
287
291
|
return client.requestResponse("daemon_status", {}, "daemon_status", timeout ?? 5e3);
|
|
288
292
|
}
|
|
289
293
|
async function isDaemonLive(wsURL, timeout) {
|
|
290
|
-
const { Client: Client2 } = await import("./client-
|
|
294
|
+
const { Client: Client2 } = await import("./client-CUYIRMFW.js");
|
|
291
295
|
const t = timeout ?? 5e3;
|
|
292
296
|
const client = new Client2(wsURL, defaultConfig());
|
|
293
297
|
try {
|
|
@@ -371,7 +375,7 @@ async function fetchLoopMessages(client, loopID, opts) {
|
|
|
371
375
|
);
|
|
372
376
|
}
|
|
373
377
|
async function connectedWebsocket(wsUrl, fn, timeoutMs = 3e4) {
|
|
374
|
-
const { Client: Client2 } = await import("./client-
|
|
378
|
+
const { Client: Client2 } = await import("./client-CUYIRMFW.js");
|
|
375
379
|
const client = new Client2(wsUrl, defaultConfig());
|
|
376
380
|
const deadline = Date.now() + timeoutMs;
|
|
377
381
|
try {
|
|
@@ -428,6 +432,59 @@ async function protocol1Rpc(wsUrl, method, params = null, opts = {}) {
|
|
|
428
432
|
}
|
|
429
433
|
}
|
|
430
434
|
|
|
435
|
+
// src/turn_boundary.ts
|
|
436
|
+
function formatTurnId(loopId, generation) {
|
|
437
|
+
const lid = String(loopId || "").trim();
|
|
438
|
+
const gen = Number(generation);
|
|
439
|
+
if (!lid || !Number.isFinite(gen) || gen <= 0) return "";
|
|
440
|
+
return `${lid}:${Math.trunc(gen)}`;
|
|
441
|
+
}
|
|
442
|
+
function parseTurnGeneration(turnId) {
|
|
443
|
+
const raw = String(turnId || "").trim();
|
|
444
|
+
if (!raw || !raw.includes(":")) return null;
|
|
445
|
+
const suffix = raw.split(":").pop() ?? "";
|
|
446
|
+
const gen = Number.parseInt(suffix, 10);
|
|
447
|
+
return Number.isFinite(gen) && gen > 0 ? gen : null;
|
|
448
|
+
}
|
|
449
|
+
function frameTurnId(frame) {
|
|
450
|
+
if (!frame || typeof frame !== "object") return null;
|
|
451
|
+
const tid = frame.turn_id;
|
|
452
|
+
if (typeof tid === "string" && tid.trim()) return tid.trim();
|
|
453
|
+
const data = frame.data;
|
|
454
|
+
if (data && typeof data === "object") {
|
|
455
|
+
const inner = data.turn_id;
|
|
456
|
+
if (typeof inner === "string" && inner.trim()) return inner.trim();
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
function frameSeq(frame) {
|
|
461
|
+
if (!frame || typeof frame !== "object") return null;
|
|
462
|
+
const raw = frame.seq;
|
|
463
|
+
if (typeof raw === "boolean") return null;
|
|
464
|
+
if (typeof raw === "number" && Number.isFinite(raw) && raw >= 0 && Number.isInteger(raw)) {
|
|
465
|
+
return raw;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
function turnIdsMatch(expected, candidate) {
|
|
470
|
+
const exp = String(expected || "").trim();
|
|
471
|
+
const cand = String(candidate || "").trim();
|
|
472
|
+
return Boolean(exp) && Boolean(cand) && exp === cand;
|
|
473
|
+
}
|
|
474
|
+
function isTurnTerminalAllowed(opts) {
|
|
475
|
+
if (!opts.queryStarted || !opts.turnProgressSeen) return false;
|
|
476
|
+
return turnIdsMatch(opts.expectedTurnId, opts.frameTurnId);
|
|
477
|
+
}
|
|
478
|
+
function isIdleTerminalAllowed(opts) {
|
|
479
|
+
if (!opts.queryStarted || !String(opts.expectedTurnId || "").trim()) return false;
|
|
480
|
+
const cand = String(opts.frameTurnId || "").trim();
|
|
481
|
+
if (cand) {
|
|
482
|
+
if (!turnIdsMatch(opts.expectedTurnId, cand)) return false;
|
|
483
|
+
return Boolean(opts.turnProgressSeen || opts.cancellationSeen);
|
|
484
|
+
}
|
|
485
|
+
return Boolean(opts.cancellationSeen);
|
|
486
|
+
}
|
|
487
|
+
|
|
431
488
|
// src/appkit/broadcaster.ts
|
|
432
489
|
var SUBSCRIBER_QUEUE_CAP = 100;
|
|
433
490
|
var SSEBroadcaster = class {
|
|
@@ -1384,8 +1441,9 @@ var TURN_END_IDLE = "status.idle";
|
|
|
1384
1441
|
var TURN_END_STOPPED = "status.stopped";
|
|
1385
1442
|
var TurnLifecycleGate = class {
|
|
1386
1443
|
sawRunning = false;
|
|
1387
|
-
sawStreamPayload = false;
|
|
1388
1444
|
sawTurnProgress = false;
|
|
1445
|
+
expectedTurnId = null;
|
|
1446
|
+
cancellationSeen = false;
|
|
1389
1447
|
observe(msg) {
|
|
1390
1448
|
const frame = normalizeFrame(msg);
|
|
1391
1449
|
if (!frame) return;
|
|
@@ -1393,22 +1451,43 @@ var TurnLifecycleGate = class {
|
|
|
1393
1451
|
if (typ === "status") {
|
|
1394
1452
|
if (String(frame.state ?? "").trim().toLowerCase() === "running") {
|
|
1395
1453
|
this.sawRunning = true;
|
|
1454
|
+
const statusTurn = frameTurnId(frame);
|
|
1455
|
+
if (statusTurn) {
|
|
1456
|
+
const newGen = parseTurnGeneration(statusTurn);
|
|
1457
|
+
const oldGen = parseTurnGeneration(this.expectedTurnId);
|
|
1458
|
+
if (this.expectedTurnId === null || newGen !== null && (oldGen === null || newGen >= oldGen)) {
|
|
1459
|
+
if (this.expectedTurnId && statusTurn !== this.expectedTurnId) {
|
|
1460
|
+
this.sawTurnProgress = false;
|
|
1461
|
+
}
|
|
1462
|
+
this.expectedTurnId = statusTurn;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1396
1465
|
}
|
|
1397
1466
|
return;
|
|
1398
1467
|
}
|
|
1399
1468
|
if (typ === "event") {
|
|
1400
|
-
this.sawStreamPayload = true;
|
|
1401
1469
|
const mode = String(frame.mode ?? "");
|
|
1402
1470
|
if (isTurnProgressChunk(mode, frame.data)) {
|
|
1403
1471
|
this.sawTurnProgress = true;
|
|
1404
1472
|
}
|
|
1405
1473
|
}
|
|
1406
1474
|
}
|
|
1407
|
-
allowStreamEnd() {
|
|
1408
|
-
return
|
|
1475
|
+
allowStreamEnd(frameTurn) {
|
|
1476
|
+
return isTurnTerminalAllowed({
|
|
1477
|
+
expectedTurnId: this.expectedTurnId,
|
|
1478
|
+
frameTurnId: frameTurn,
|
|
1479
|
+
queryStarted: this.sawRunning,
|
|
1480
|
+
turnProgressSeen: this.sawTurnProgress
|
|
1481
|
+
});
|
|
1409
1482
|
}
|
|
1410
|
-
allowIdleComplete() {
|
|
1411
|
-
return
|
|
1483
|
+
allowIdleComplete(frameTurn) {
|
|
1484
|
+
return isIdleTerminalAllowed({
|
|
1485
|
+
expectedTurnId: this.expectedTurnId,
|
|
1486
|
+
frameTurnId: frameTurn,
|
|
1487
|
+
queryStarted: this.sawRunning,
|
|
1488
|
+
turnProgressSeen: this.sawTurnProgress,
|
|
1489
|
+
cancellationSeen: this.cancellationSeen
|
|
1490
|
+
});
|
|
1412
1491
|
}
|
|
1413
1492
|
};
|
|
1414
1493
|
var TurnBoundary = class {
|
|
@@ -1423,17 +1502,23 @@ var TurnBoundary = class {
|
|
|
1423
1502
|
const typ = String(frame.type ?? "");
|
|
1424
1503
|
if (typ === "status") {
|
|
1425
1504
|
const state = String(frame.state ?? "").trim().toLowerCase();
|
|
1505
|
+
const frameTurn = frameTurnId(frame);
|
|
1426
1506
|
if (state === "stopped" && this.gate.sawRunning) {
|
|
1507
|
+
if (this.gate.expectedTurnId && !turnIdsMatch(this.gate.expectedTurnId, frameTurn)) {
|
|
1508
|
+
return [false, ""];
|
|
1509
|
+
}
|
|
1427
1510
|
return this.mark(TURN_END_STOPPED);
|
|
1428
1511
|
}
|
|
1429
|
-
if (state === "idle" && this.gate.allowIdleComplete()) {
|
|
1512
|
+
if (state === "idle" && this.gate.allowIdleComplete(frameTurn)) {
|
|
1430
1513
|
return this.mark(TURN_END_IDLE);
|
|
1431
1514
|
}
|
|
1432
1515
|
return [false, ""];
|
|
1433
1516
|
}
|
|
1434
1517
|
if (typ === "event") {
|
|
1435
1518
|
const mode = String(frame.mode ?? "");
|
|
1436
|
-
|
|
1519
|
+
const data = frame.data;
|
|
1520
|
+
const dataTurn = frameTurnId(data) || frameTurnId(frame);
|
|
1521
|
+
if (mode === "custom" && isTurnEndCustomData(data) && this.gate.allowStreamEnd(dataTurn)) {
|
|
1437
1522
|
return this.mark(TURN_END_STREAM_END);
|
|
1438
1523
|
}
|
|
1439
1524
|
}
|
|
@@ -1459,20 +1544,26 @@ function normalizeFrame(msg) {
|
|
|
1459
1544
|
return inner;
|
|
1460
1545
|
}
|
|
1461
1546
|
if (inner && typeof inner === "object" && inner.mode) {
|
|
1462
|
-
|
|
1547
|
+
const out = {
|
|
1463
1548
|
type: "event",
|
|
1464
1549
|
mode: inner.mode,
|
|
1465
1550
|
data: inner.data,
|
|
1466
1551
|
namespace: inner.namespace ?? payload.namespace
|
|
1467
1552
|
};
|
|
1553
|
+
const tid = inner.turn_id ?? payload.turn_id ?? m.turn_id;
|
|
1554
|
+
if (tid) out.turn_id = tid;
|
|
1555
|
+
return out;
|
|
1468
1556
|
}
|
|
1469
1557
|
if (payload.mode) {
|
|
1470
|
-
|
|
1558
|
+
const out = {
|
|
1471
1559
|
type: "event",
|
|
1472
1560
|
mode: payload.mode,
|
|
1473
1561
|
data: payload.data,
|
|
1474
1562
|
namespace: payload.namespace
|
|
1475
1563
|
};
|
|
1564
|
+
const tid = payload.turn_id ?? m.turn_id;
|
|
1565
|
+
if (tid) out.turn_id = tid;
|
|
1566
|
+
return out;
|
|
1476
1567
|
}
|
|
1477
1568
|
return null;
|
|
1478
1569
|
}
|
|
@@ -2161,7 +2252,7 @@ var DaemonSession = class {
|
|
|
2161
2252
|
this.lastTurnErrorMessage = null;
|
|
2162
2253
|
let queryStarted = false;
|
|
2163
2254
|
let expectedLoopId = this.loopId;
|
|
2164
|
-
let
|
|
2255
|
+
let expectedTurnId = null;
|
|
2165
2256
|
let turnProgressSeen = false;
|
|
2166
2257
|
this.streaming = true;
|
|
2167
2258
|
const absoluteDeadline = opts.maxWaitMs !== void 0 && opts.maxWaitMs > 0 ? Date.now() + opts.maxWaitMs : null;
|
|
@@ -2195,6 +2286,17 @@ var DaemonSession = class {
|
|
|
2195
2286
|
if (expectedLoopId && typeof eventLoopId === "string" && eventLoopId && eventLoopId !== expectedLoopId) {
|
|
2196
2287
|
continue;
|
|
2197
2288
|
}
|
|
2289
|
+
const evTurnId = frameTurnId(frame);
|
|
2290
|
+
const statusState = eventType === "status" ? String(frame.state ?? "") : "";
|
|
2291
|
+
const isRunningStatus = statusState === "running";
|
|
2292
|
+
const isTerminalStatus = statusState === "idle" || statusState === "stopped";
|
|
2293
|
+
if (expectedTurnId && (eventType === "event" || eventType === "status") && !isRunningStatus) {
|
|
2294
|
+
if (isTerminalStatus) {
|
|
2295
|
+
if (evTurnId && !turnIdsMatch(expectedTurnId, evTurnId)) continue;
|
|
2296
|
+
} else if (!turnIdsMatch(expectedTurnId, evTurnId)) {
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2198
2300
|
if (eventType === "error") {
|
|
2199
2301
|
const errObj = frame.error ?? {};
|
|
2200
2302
|
throw new Error(String(errObj.message || frame.message || "daemon error"));
|
|
@@ -2205,16 +2307,37 @@ var DaemonSession = class {
|
|
|
2205
2307
|
this.loopId = loopEv;
|
|
2206
2308
|
expectedLoopId = loopEv;
|
|
2207
2309
|
}
|
|
2208
|
-
|
|
2209
|
-
if (state === "running") {
|
|
2310
|
+
if (statusState === "running") {
|
|
2210
2311
|
queryStarted = true;
|
|
2211
|
-
|
|
2212
|
-
|
|
2312
|
+
const statusTurn = frameTurnId(frame);
|
|
2313
|
+
if (statusTurn) {
|
|
2314
|
+
const newGen = parseTurnGeneration(statusTurn);
|
|
2315
|
+
const oldGen = parseTurnGeneration(expectedTurnId);
|
|
2316
|
+
if (expectedTurnId === null || newGen !== null && (oldGen === null || newGen >= oldGen)) {
|
|
2317
|
+
if (expectedTurnId && statusTurn !== expectedTurnId) {
|
|
2318
|
+
turnProgressSeen = false;
|
|
2319
|
+
}
|
|
2320
|
+
expectedTurnId = statusTurn;
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
} else if (queryStarted && statusState === "stopped") {
|
|
2324
|
+
const stopTurn = frameTurnId(frame);
|
|
2325
|
+
if (expectedTurnId && !turnIdsMatch(expectedTurnId, stopTurn)) continue;
|
|
2326
|
+
this.lastTurnEndState = statusState;
|
|
2213
2327
|
yield* this.drainStreamEventsAfterIdle(expectedLoopId);
|
|
2214
2328
|
break;
|
|
2215
|
-
} else if (queryStarted &&
|
|
2216
|
-
|
|
2217
|
-
|
|
2329
|
+
} else if (queryStarted && statusState === "idle") {
|
|
2330
|
+
const idleTurn = frameTurnId(frame);
|
|
2331
|
+
if (!isIdleTerminalAllowed({
|
|
2332
|
+
expectedTurnId,
|
|
2333
|
+
frameTurnId: idleTurn,
|
|
2334
|
+
queryStarted,
|
|
2335
|
+
turnProgressSeen,
|
|
2336
|
+
cancellationSeen: this.lastTurnCancellationSeen
|
|
2337
|
+
})) {
|
|
2338
|
+
continue;
|
|
2339
|
+
}
|
|
2340
|
+
this.lastTurnEndState = statusState;
|
|
2218
2341
|
yield* this.drainStreamEventsAfterIdle(expectedLoopId);
|
|
2219
2342
|
break;
|
|
2220
2343
|
}
|
|
@@ -2236,9 +2359,16 @@ var DaemonSession = class {
|
|
|
2236
2359
|
continue;
|
|
2237
2360
|
}
|
|
2238
2361
|
if (mode === "custom" && isTurnEndCustomData(data)) {
|
|
2239
|
-
|
|
2362
|
+
const dataTurn = frameTurnId(data) || evTurnId;
|
|
2363
|
+
if (!isTurnTerminalAllowed({
|
|
2364
|
+
expectedTurnId,
|
|
2365
|
+
frameTurnId: dataTurn,
|
|
2366
|
+
queryStarted,
|
|
2367
|
+
turnProgressSeen
|
|
2368
|
+
})) {
|
|
2369
|
+
continue;
|
|
2370
|
+
}
|
|
2240
2371
|
}
|
|
2241
|
-
streamPayloadSeen = true;
|
|
2242
2372
|
if (isTurnProgressChunk(mode, data)) turnProgressSeen = true;
|
|
2243
2373
|
yield [namespace, mode, data];
|
|
2244
2374
|
if (mode === "custom" && isTurnEndCustomData(data)) {
|
|
@@ -2437,15 +2567,20 @@ export {
|
|
|
2437
2567
|
fetchLoopHistory,
|
|
2438
2568
|
fetchLoopMessages,
|
|
2439
2569
|
fetchSkillsCatalog,
|
|
2570
|
+
formatTurnId,
|
|
2571
|
+
frameSeq,
|
|
2572
|
+
frameTurnId,
|
|
2440
2573
|
idleTimeoutForTurn,
|
|
2441
2574
|
inboundNeedsDeliveryAck,
|
|
2442
2575
|
inputMessageForLoop,
|
|
2443
2576
|
isCompletionEvent,
|
|
2444
2577
|
isDaemonLive,
|
|
2445
2578
|
isDaemonTurnEndEvent,
|
|
2579
|
+
isIdleTerminalAllowed,
|
|
2446
2580
|
isSubagentProgressEvent,
|
|
2447
2581
|
isTurnEndCustomData,
|
|
2448
2582
|
isTurnProgressChunk,
|
|
2583
|
+
isTurnTerminalAllowed,
|
|
2449
2584
|
isValidVerbosityLevel,
|
|
2450
2585
|
loadConfigFromEnv,
|
|
2451
2586
|
newLoopInputMessage,
|
|
@@ -2455,6 +2590,7 @@ export {
|
|
|
2455
2590
|
notificationEnvelope,
|
|
2456
2591
|
parseCardCustomPayload,
|
|
2457
2592
|
parseNamespace,
|
|
2593
|
+
parseTurnGeneration,
|
|
2458
2594
|
pingEnvelope,
|
|
2459
2595
|
pongEnvelope,
|
|
2460
2596
|
protocol1Rpc,
|
|
@@ -2465,6 +2601,7 @@ export {
|
|
|
2465
2601
|
shouldShow,
|
|
2466
2602
|
splitWirePayload,
|
|
2467
2603
|
subscribeEnvelope,
|
|
2604
|
+
turnIdsMatch,
|
|
2468
2605
|
unsubscribeEnvelope,
|
|
2469
2606
|
validateLoopInputIntentHint,
|
|
2470
2607
|
waitDaemonReady,
|