@canonmsg/agent-sdk 11.2.1 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +248 -523
  2. package/dist/chunks/chunk-7N6OPPW4.js +5430 -0
  3. package/dist/chunks/chunk-N722GWCP.js +4897 -0
  4. package/dist/chunks/chunk-QZ4PPRQW.js +14247 -0
  5. package/dist/chunks/mls-crypto-LMNQZOS6.js +10 -0
  6. package/dist/cli.js +572 -0
  7. package/dist/drivers/claude.d.ts +42 -0
  8. package/dist/drivers/code.d.ts +18 -0
  9. package/dist/drivers/codex.d.ts +46 -0
  10. package/dist/drivers/connector.d.ts +34 -0
  11. package/dist/index.d.ts +20 -25
  12. package/dist/index.js +91 -13
  13. package/dist/internal/backend-contracts/agentBehaviorPolicy.d.ts +122 -0
  14. package/dist/internal/backend-contracts/agentDirectory.d.ts +32 -0
  15. package/dist/internal/backend-contracts/agentOrigin.d.ts +23 -0
  16. package/dist/internal/backend-contracts/agentSearch.d.ts +17 -0
  17. package/dist/internal/backend-contracts/api-origins.generated.d.ts +4 -0
  18. package/dist/internal/backend-contracts/apiErrors.d.ts +1 -0
  19. package/dist/internal/backend-contracts/artifactActions.d.ts +8 -0
  20. package/dist/internal/backend-contracts/artifacts.d.ts +386 -0
  21. package/dist/internal/backend-contracts/clientFloor.d.ts +41 -0
  22. package/dist/internal/backend-contracts/communication.d.ts +146 -0
  23. package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
  24. package/dist/internal/backend-contracts/conversationMembership.d.ts +28 -0
  25. package/dist/internal/backend-contracts/deliveryObservation.d.ts +23 -0
  26. package/dist/internal/backend-contracts/diffRedaction.d.ts +6 -0
  27. package/dist/internal/backend-contracts/endpoint-unread.d.ts +4 -0
  28. package/dist/internal/backend-contracts/endpoint.d.ts +120 -0
  29. package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +48 -0
  30. package/dist/internal/backend-contracts/environment.d.ts +20 -0
  31. package/dist/internal/backend-contracts/externalInbound.d.ts +24 -0
  32. package/dist/internal/backend-contracts/firestoreValues.d.ts +9 -0
  33. package/dist/internal/backend-contracts/index.d.ts +54 -0
  34. package/dist/internal/backend-contracts/media-url.d.ts +20 -0
  35. package/dist/internal/backend-contracts/media.d.ts +51 -0
  36. package/dist/internal/backend-contracts/mediaDelivery.d.ts +46 -0
  37. package/dist/internal/backend-contracts/mediaTransferProtocol.d.ts +17 -0
  38. package/dist/internal/backend-contracts/membershipChange.d.ts +21 -0
  39. package/dist/internal/backend-contracts/message.d.ts +86 -0
  40. package/dist/internal/backend-contracts/messageText.d.ts +6 -0
  41. package/dist/internal/backend-contracts/mlsDevApplication.d.ts +161 -0
  42. package/dist/internal/backend-contracts/mlsDevCredential.d.ts +78 -0
  43. package/dist/internal/backend-contracts/mlsDevCredentialReconciliation.d.ts +45 -0
  44. package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +52 -0
  45. package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +75 -0
  46. package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
  47. package/dist/internal/backend-contracts/mlsDevGroup.d.ts +321 -0
  48. package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +51 -0
  49. package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
  50. package/dist/internal/backend-contracts/mlsDevKeyPackage.d.ts +42 -0
  51. package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +55 -0
  52. package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
  53. package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +23 -0
  54. package/dist/internal/backend-contracts/moderation.d.ts +7 -0
  55. package/dist/internal/backend-contracts/plaintextProcessors.d.ts +63 -0
  56. package/dist/internal/backend-contracts/preparedContent.d.ts +54 -0
  57. package/dist/internal/backend-contracts/replyAuthority.d.ts +14 -0
  58. package/dist/internal/backend-contracts/runtimeCardFields.d.ts +66 -0
  59. package/dist/internal/backend-contracts/runtimeCardStorage.d.ts +3 -0
  60. package/dist/internal/backend-contracts/runtimeDescriptor.d.ts +88 -0
  61. package/dist/internal/backend-contracts/selfContext.d.ts +9 -0
  62. package/dist/internal/backend-contracts/turnProtocol.d.ts +43 -0
  63. package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
  64. package/dist/internal/backend-contracts/verbContract.d.ts +856 -0
  65. package/dist/internal/backend-contracts/verbSchemas.d.ts +1717 -0
  66. package/dist/internal/backend-contracts/verbWire.d.ts +493 -0
  67. package/dist/internal/backend-contracts/webAuth.d.ts +8 -0
  68. package/dist/internal/core/agent-profiles.d.ts +65 -0
  69. package/dist/internal/core/approval-format.d.ts +22 -0
  70. package/dist/internal/core/approval-manager.d.ts +43 -0
  71. package/dist/internal/core/approval-types.d.ts +73 -0
  72. package/dist/internal/core/base-url.d.ts +1 -0
  73. package/dist/internal/core/cli-metadata.d.ts +13 -0
  74. package/dist/internal/core/client.d.ts +432 -0
  75. package/dist/internal/core/completed-output-journal.d.ts +39 -0
  76. package/dist/internal/core/constants.d.ts +1 -0
  77. package/dist/internal/core/endpoint-client.d.ts +56 -0
  78. package/dist/internal/core/execution-environment-mode.d.ts +6 -0
  79. package/dist/internal/core/gifs.d.ts +29 -0
  80. package/dist/internal/core/host-runtime.d.ts +53 -0
  81. package/dist/internal/core/index.d.ts +68 -0
  82. package/dist/internal/core/node-media.d.ts +6 -0
  83. package/dist/internal/core/policy.d.ts +2 -0
  84. package/dist/internal/core/registration-profile.d.ts +10 -0
  85. package/dist/internal/core/registration-session.d.ts +55 -0
  86. package/dist/internal/core/registration.d.ts +5 -0
  87. package/dist/internal/core/retry.d.ts +113 -0
  88. package/dist/internal/core/rtdb-rest.d.ts +141 -0
  89. package/dist/internal/core/runtime-cards.d.ts +286 -0
  90. package/dist/internal/core/runtime-descriptor.d.ts +16 -0
  91. package/dist/internal/core/runtime-endpoints.d.ts +26 -0
  92. package/dist/internal/core/runtime-heartbeat.d.ts +29 -0
  93. package/dist/internal/core/runtime-presentation.d.ts +9 -0
  94. package/dist/internal/core/runtime-request-manager.d.ts +283 -0
  95. package/dist/internal/core/runtime-state-publisher.d.ts +42 -0
  96. package/dist/internal/core/self-context.d.ts +22 -0
  97. package/dist/internal/core/silent-turn.d.ts +49 -0
  98. package/dist/internal/core/stream.d.ts +78 -0
  99. package/dist/internal/core/turn-protocol.d.ts +28 -0
  100. package/dist/internal/core/turn-verbosity.d.ts +85 -0
  101. package/dist/internal/core/types.d.ts +964 -0
  102. package/dist/internal/core/unified-diff.d.ts +35 -0
  103. package/dist/internal/endpoint/artifact-images.d.ts +60 -0
  104. package/dist/internal/endpoint/artifact-reducer.d.ts +35 -0
  105. package/dist/internal/endpoint/artifact-views.d.ts +113 -0
  106. package/dist/internal/endpoint/artifacts.d.ts +75 -0
  107. package/dist/internal/endpoint/delivery.d.ts +47 -0
  108. package/dist/internal/endpoint/engine.d.ts +249 -0
  109. package/dist/internal/endpoint/ephemeral.d.ts +8 -0
  110. package/dist/internal/endpoint/events.d.ts +32 -0
  111. package/dist/internal/endpoint/external-inbound.d.ts +36 -0
  112. package/dist/internal/endpoint/handoff.d.ts +50 -0
  113. package/dist/internal/endpoint/history.d.ts +22 -0
  114. package/dist/internal/endpoint/image-generation-errors.d.ts +2 -0
  115. package/dist/internal/endpoint/inbound.d.ts +29 -0
  116. package/dist/internal/endpoint/index.d.ts +32 -0
  117. package/dist/internal/endpoint/media.d.ts +177 -0
  118. package/dist/internal/endpoint/migration.d.ts +50 -0
  119. package/dist/internal/endpoint/mls-crypto.d.ts +32 -0
  120. package/dist/internal/endpoint/mls-dev-client.d.ts +52 -0
  121. package/dist/internal/endpoint/mls-dev-device.d.ts +69 -0
  122. package/dist/internal/endpoint/mls-dev-groups.d.ts +174 -0
  123. package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
  124. package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +46 -0
  125. package/dist/internal/endpoint/mls-dev-key-packages.d.ts +62 -0
  126. package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
  127. package/dist/internal/endpoint/mls-dev-transport.d.ts +38 -0
  128. package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +29 -0
  129. package/dist/internal/endpoint/node-mls-custody.d.ts +15 -0
  130. package/dist/internal/endpoint/node.d.ts +7 -0
  131. package/dist/internal/endpoint/observe-query.d.ts +17 -0
  132. package/dist/internal/endpoint/portable-node-mls-custody.d.ts +23 -0
  133. package/dist/internal/endpoint/queue.d.ts +22 -0
  134. package/dist/internal/endpoint/recovery.d.ts +27 -0
  135. package/dist/internal/endpoint/retention.d.ts +7 -0
  136. package/dist/internal/endpoint/store.d.ts +22 -0
  137. package/dist/internal/endpoint/sync.d.ts +33 -0
  138. package/dist/internal/endpoint/transient-publisher.d.ts +8 -0
  139. package/dist/internal/endpoint/transport.d.ts +63 -0
  140. package/dist/media.d.ts +1 -1
  141. package/dist/media.js +42 -541
  142. package/dist/runner/errands.d.ts +118 -0
  143. package/dist/runner/mls.d.ts +97 -0
  144. package/dist/runner/relay.d.ts +87 -0
  145. package/dist/runner/runner.d.ts +98 -0
  146. package/dist/runner/types.d.ts +215 -0
  147. package/package.json +18 -5
  148. package/dist/attached-session.d.ts +0 -58
  149. package/dist/attached-session.js +0 -638
  150. package/dist/bounded-file-read.d.ts +0 -14
  151. package/dist/bounded-file-read.js +0 -34
  152. package/dist/canon-agent.d.ts +0 -236
  153. package/dist/canon-agent.js +0 -2531
  154. package/dist/debouncer.d.ts +0 -18
  155. package/dist/debouncer.js +0 -133
  156. package/dist/inbound-handoff.d.ts +0 -6
  157. package/dist/inbound-handoff.js +0 -17
  158. package/dist/managed-session-host.d.ts +0 -27
  159. package/dist/managed-session-host.js +0 -195
  160. package/dist/managed-session-setup.d.ts +0 -99
  161. package/dist/managed-session-setup.js +0 -234
  162. package/dist/realtime.d.ts +0 -62
  163. package/dist/realtime.js +0 -193
  164. package/dist/runtime-card.d.ts +0 -48
  165. package/dist/runtime-card.js +0 -64
  166. package/dist/session-manager.d.ts +0 -77
  167. package/dist/session-manager.js +0 -285
  168. package/dist/turn-streaming-request.d.ts +0 -17
  169. package/dist/turn-streaming-request.js +0 -22
  170. package/dist/turn-verbosity-option.d.ts +0 -33
  171. package/dist/turn-verbosity-option.js +0 -23
  172. package/dist/types.d.ts +0 -387
  173. package/dist/types.js +0 -1
  174. package/dist/work-session-coordination.d.ts +0 -21
  175. package/dist/work-session-coordination.js +0 -53
  176. package/dist/work-session-host.d.ts +0 -31
  177. package/dist/work-session-host.js +0 -617
  178. package/dist/work-session-interactions.d.ts +0 -12
  179. package/dist/work-session-interactions.js +0 -173
  180. package/dist/work-session-state.d.ts +0 -36
  181. package/dist/work-session-state.js +0 -62
@@ -0,0 +1,42 @@
1
+ import type { AgentClientType, AgentRuntime, CanonRuntimeActivityItem, RuntimeInfoPayload, TurnOutputBlock } from './types.js';
2
+ import { type AgentSessionSnapshotPatch, type RTDBClientHandle, type SessionStatePayload, type TurnStatePayload } from './rtdb-rest.js';
3
+ export interface RuntimeStatePublisherOptions {
4
+ agentId: string;
5
+ clientType: AgentClientType;
6
+ hostMode: boolean;
7
+ /** Scoped endpoint-backed runtime-state handle from `initRTDBAuth`. */
8
+ rtdb: RTDBClientHandle;
9
+ }
10
+ export interface RuntimeStreamingPayload {
11
+ text: string;
12
+ status: 'thinking' | 'streaming' | 'tool' | 'waiting_input';
13
+ messageId?: string;
14
+ turnId?: string | null;
15
+ blocks?: TurnOutputBlock[];
16
+ updatedAt?: number | {
17
+ '.sv': 'timestamp';
18
+ };
19
+ }
20
+ export interface ClearRuntimeActivityOptions {
21
+ itemIds?: ReadonlyArray<string>;
22
+ terminalOnly?: boolean;
23
+ olderThanMs?: number;
24
+ all?: boolean;
25
+ }
26
+ export interface RuntimeStatePublisher {
27
+ publishAgentRuntime(runtime: AgentRuntime): Promise<void>;
28
+ clearAgentRuntime(): Promise<void>;
29
+ writeSessionState(conversationId: string, state: Omit<SessionStatePayload, 'updatedAt'>): Promise<void>;
30
+ clearSessionState(conversationId: string): Promise<void>;
31
+ writeTurnState(conversationId: string, state: Omit<TurnStatePayload, 'updatedAt'>): Promise<void>;
32
+ clearTurnState(conversationId: string): Promise<void>;
33
+ patchAgentSessionSnapshot(conversationId: string, snapshot: Omit<AgentSessionSnapshotPatch, 'updatedAt'>): Promise<void>;
34
+ writeRuntimeInfo(conversationId: string, payload: Omit<RuntimeInfoPayload, 'updatedAt'>): Promise<void>;
35
+ patchRuntimeInfo(conversationId: string, payload: Partial<Omit<RuntimeInfoPayload, 'updatedAt'>>): Promise<void>;
36
+ clearRuntimeInfo(conversationId: string): Promise<void>;
37
+ writeRuntimeActivity(conversationId: string, item: CanonRuntimeActivityItem): Promise<void>;
38
+ clearRuntimeActivity(conversationId: string, options?: ClearRuntimeActivityOptions): Promise<void>;
39
+ writeStreaming(conversationId: string, payload: RuntimeStreamingPayload): Promise<void>;
40
+ clearStreaming(conversationId: string): Promise<void>;
41
+ }
42
+ export declare function createRuntimeStatePublisher(options: RuntimeStatePublisherOptions): RuntimeStatePublisher;
@@ -0,0 +1,22 @@
1
+ export type CanonSelfContextType = 'cross_session';
2
+ export interface CanonSelfContext {
3
+ id: string;
4
+ type: CanonSelfContextType;
5
+ context: string;
6
+ /** Public message sent with this private explanation. */
7
+ targetMessageId?: string | null;
8
+ /** The Canon room that originated an older cross-session action. */
9
+ sourceConversationId?: string | null;
10
+ /** A local task may originate an action without having its own Canon room. */
11
+ externalSource?: {
12
+ kind: 'external';
13
+ integration: 'codex';
14
+ label?: string;
15
+ } | null;
16
+ /** Public target text hydrated from this room; never stored in the private note. */
17
+ targetMessageText?: string | null;
18
+ /** Public message time hydrated at delivery, used to order recent actions. */
19
+ targetMessageCreatedAt?: string | null;
20
+ createdAt?: string | null;
21
+ updatedAt?: string | null;
22
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Deliberate silence — the shared half of the `no_reply` verb.
3
+ *
4
+ * A turn that calls `no_reply` must end without posting anything: the trigger
5
+ * gate is message-driven, so no message means no other agent is woken.
6
+ */
7
+ /**
8
+ * The model-facing closure sentence, re-exported so a runtime that answers
9
+ * `no_reply` locally reads it from the same definition the server sends. It is
10
+ * DEFINED in @canonmsg/backend-contracts because that is the only package both
11
+ * the server and the hosts depend on.
12
+ */
13
+ export { NO_REPLY_ACK_NOTE } from '../backend-contracts/index.js';
14
+ import { type CanonVerbWireRequest } from '../backend-contracts/index.js';
15
+ /** The one client capability the outcome report needs. */
16
+ export interface NoReplyReportClient {
17
+ executeVerbWire(wire: CanonVerbWireRequest): Promise<unknown>;
18
+ }
19
+ /**
20
+ * What `reportNoReplyOutcome` puts on the wire in place of any caller-supplied
21
+ * reason text. The server stores only `hasReason` and discards the text, so
22
+ * transmitting the model- or handler-authored sentence would be pure exposure:
23
+ * the sentinel preserves the server's `hasReason` signal without moving the
24
+ * text. The reason a binding was handed never leaves its process.
25
+ */
26
+ export declare const NO_REPLY_REASON_SENTINEL = "given";
27
+ /**
28
+ * Report a locally-answered `no_reply` to the server, fire-and-forget.
29
+ *
30
+ * Four of the five runtimes answer the silence tool inside their own process
31
+ * and never reach `POST /agent/verbs/no_reply`, so Canon's durable record of
32
+ * deliberate silence (`/runtime-silence/{convoId}/{agentId}`) would otherwise
33
+ * cover Claude turns only. This is telemetry, not behavior: the silence flag
34
+ * is already set locally before this is called, so a failed or unreachable
35
+ * report degrades to exactly the pre-report behavior — never to a posted
36
+ * message and never to a failed turn.
37
+ *
38
+ * `params.reason` is read only for its presence: the wire carries
39
+ * `NO_REPLY_REASON_SENTINEL` in its place, never the caller's text.
40
+ *
41
+ * The Claude host must NOT call this helper: its binding already POSTs the
42
+ * verb via agent-tools, so calling both would double-record the silence.
43
+ */
44
+ export declare function reportNoReplyOutcome(client: NoReplyReportClient, params: {
45
+ conversationId: string;
46
+ messageId?: string;
47
+ reason?: string;
48
+ now?: number;
49
+ }): void;
@@ -0,0 +1,78 @@
1
+ import type { CanonEndpoint } from './endpoint-client.js';
2
+ import type { AgentContext, ContactAddedPayload, ContactRemovedPayload, ConversationUpdatedPayload, MessageCreatedPayload, MessageUpdatedPayload, TypingPayload, PresencePayload, RuntimeUpdatedPayload, RuntimeControlEventPayload, TurnUpdatedPayload, ParticipationSuppressedPayload, VoiceSessionEventPayload } from './types.js';
3
+ export interface CanonStreamErrorPayload {
4
+ code?: string;
5
+ message?: string;
6
+ retryAfterMs?: number;
7
+ activeConnections?: number;
8
+ maxConnections?: number;
9
+ [key: string]: unknown;
10
+ }
11
+ export interface ReplayExpiredPayload {
12
+ /** Oldest event id still available in the server's replay buffer, if any. */
13
+ lastAvailableId?: string | null;
14
+ message?: string;
15
+ [key: string]: unknown;
16
+ }
17
+ export declare class CanonStreamError extends Error {
18
+ readonly code?: string;
19
+ readonly retryAfterMs?: number;
20
+ readonly payload: CanonStreamErrorPayload;
21
+ constructor(payload: CanonStreamErrorPayload, fallbackMessage: string);
22
+ }
23
+ export type StreamHandler = {
24
+ onMessage: (payload: MessageCreatedPayload) => void;
25
+ onMessageUpdated?: (payload: MessageUpdatedPayload) => void;
26
+ onAgentContext?: (ctx: AgentContext) => void;
27
+ onContactAdded?: (payload: ContactAddedPayload) => void;
28
+ onContactRemoved?: (payload: ContactRemovedPayload) => void;
29
+ onTyping?: (data: TypingPayload) => void;
30
+ onPresence?: (data: PresencePayload) => void;
31
+ onRuntimeUpdated?: (payload: RuntimeUpdatedPayload) => void;
32
+ onTurnUpdated?: (payload: TurnUpdatedPayload) => void;
33
+ /** Observe-only: the participation gate suppressed a turn for this agent. */
34
+ onParticipationSuppressed?: (payload: ParticipationSuppressedPayload) => void;
35
+ onRuntimeControl?: (payload: RuntimeControlEventPayload) => void;
36
+ onVoiceSessionStarted?: (payload: VoiceSessionEventPayload) => void;
37
+ onVoiceSessionEnded?: (payload: VoiceSessionEventPayload) => void;
38
+ onMessageDeleted?: (payload: {
39
+ conversationId: string;
40
+ messageId: string;
41
+ }) => void;
42
+ onConversationUpdated?: (payload: ConversationUpdatedPayload) => void;
43
+ onConnected?: () => void;
44
+ onDisconnected?: () => void;
45
+ /**
46
+ * Fired when the server reports the replay window expired (`replay.expired`):
47
+ * the reconnect cursor was evicted, so events in the gap were NOT replayed
48
+ * and must be recovered out-of-band (e.g. via the REST API). The transport
49
+ * stays policy-free — it only clears its cursor and surfaces the expiry.
50
+ *
51
+ * When this handler is provided it REPLACES the synthetic
52
+ * `Replay expired — some messages may have been missed` error on `onError`;
53
+ * raw consumers that only register `onError` keep the existing behavior.
54
+ */
55
+ onReplayExpired?: (payload: ReplayExpiredPayload) => void;
56
+ /** `conversationId` names the room when endpoint recovery failed for one. */
57
+ onError?: (error: Error, conversationId?: string) => void;
58
+ };
59
+ /** Typed agent event projection; the endpoint owns authentication, SSE and reconnect. */
60
+ export declare class CanonStream {
61
+ private readonly endpoint;
62
+ private readonly agentId;
63
+ private readonly handler;
64
+ private unsubscribe?;
65
+ private releaseRecovery?;
66
+ private running;
67
+ private generation;
68
+ private resolveStopped?;
69
+ constructor(options: {
70
+ endpoint: CanonEndpoint;
71
+ agentId: string;
72
+ handler: StreamHandler;
73
+ });
74
+ start(): Promise<void>;
75
+ private forwardPlaintextMessage;
76
+ stop(): void;
77
+ isRunning(): boolean;
78
+ }
@@ -0,0 +1,28 @@
1
+ import type { DeliveryIntent, TurnLifecycleState } from '../backend-contracts/index.js';
2
+ export { ACTIVE_TURN_STALE_THRESHOLD_MS, WAITING_INPUT_STALE_THRESHOLD_MS, getTurnStateStaleThresholdMs, isTurnOpen, isTurnStateStale, normalizeTurnMetadata, resolveTurnMessageSemantics, shouldPromoteConversationMessage, shouldTriggerAgentTurn, } from '../backend-contracts/index.js';
3
+ export type { DeliveryIntent, InboundDisposition, TriggerDecision, TurnLifecycleState, TurnMessageSemantics, TurnMetadata, } from '../backend-contracts/index.js';
4
+ export interface RuntimeCapabilities {
5
+ supportsInterrupt: boolean;
6
+ supportsInputInterrupt: boolean;
7
+ supportsQueue: boolean;
8
+ supportsInterleave: boolean;
9
+ supportsRequiresAction: boolean;
10
+ supportsNonFinalPermanentMessages: boolean;
11
+ }
12
+ export interface TurnState {
13
+ turnId?: string | null;
14
+ state: TurnLifecycleState;
15
+ queueDepth: number;
16
+ currentSpeakerId?: string | null;
17
+ lastAcceptedIntent?: DeliveryIntent | null;
18
+ activeMessageIds?: string[];
19
+ capabilities?: RuntimeCapabilities;
20
+ openedAt?: number;
21
+ turnUpdatedAt?: number | null;
22
+ updatedAt?: number;
23
+ completedAt?: number | null;
24
+ }
25
+ /** The one optional proactive communication capability a runtime may expose. */
26
+ export interface HostAdmissionActionCapabilities {
27
+ communicate: boolean;
28
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Turn verbosity — how much of a turn's middle the reader sees.
3
+ *
4
+ * `quiet` = the thinking indicator and the final message only: no `/streaming`
5
+ * narration and no runtime-generated per-tool-call step output. Emission the
6
+ * DEVELOPER asks for explicitly is not narration and survives — owner ruling
7
+ * D1: `replyProgress(text, { durable: true })` keeps its durable send, and only
8
+ * the implicit `/streaming` half is gated. Interaction requests and their
9
+ * `control` outcome receipts are real interactions, not steps, and are
10
+ * untouched in both modes; the duplicate trail rows that summarize them go with
11
+ * the trail (D4).
12
+ *
13
+ * Owner ruling 5, 2026-07-31 (docs/history/group-behavior-2026-08-01.md): configured
14
+ * by the AGENT DEVELOPER per host/SDK, never by Canon and never per
15
+ * conversation by users. ONE resolver so five integrations cannot disagree.
16
+ *
17
+ * This lives in @canonmsg/core rather than @canonmsg/backend-contracts because
18
+ * quiet mode has no server participant: it is emission control at the agent
19
+ * side. Nothing on the server reads it, no verb carries it, and clients need
20
+ * no change — they simply have nothing to render.
21
+ *
22
+ * Notes for the runtimes that consume this (the guards are per-integration):
23
+ * - Suppress by CALL SITE, never by `turnSemantics === 'progress'` (D5): the
24
+ * leading parts of a chunked final carry that semantic and are answer body.
25
+ * - A quiet turn still clears `/streaming` at turn open (a surviving node from
26
+ * an earlier turn would otherwise strand a stale bubble), still writes
27
+ * `/turn-state`, and still writes `/typing`. Quiet removes the narration,
28
+ * not the fact that the agent is working.
29
+ */
30
+ /** The resolved mode a turn runs in. Named `turnVerbosity`, never `verbosity` —
31
+ * `runtime.verbosity.set` is a different, user-facing primitive. */
32
+ export type TurnVerbosity = 'verbose' | 'quiet';
33
+ /** What a developer may write in config. `'auto'` === unset. */
34
+ export type TurnVerbosityConfig = TurnVerbosity | 'auto';
35
+ /**
36
+ * Hermes spells a direct chat `'dm'` (adapter.py `_chat_type_from_conversation`);
37
+ * the TS stack spells it `'direct'` and can also be `'unknown'` when the
38
+ * conversation fetch failed (host-runtime.ts HostInboundParticipantContext).
39
+ */
40
+ export type TurnVerbosityConversationType = 'direct' | 'dm' | 'group' | 'unknown';
41
+ /**
42
+ * The per-conversation-type defaults. `canon-hermes-plugin` will hand-port this
43
+ * map into Python — that package has no dependency on this one — and pin the
44
+ * two sides with a cross-language parity test, the way it already does for the
45
+ * turn-trail budgets and the group guidance wording.
46
+ */
47
+ export declare const DEFAULT_TURN_VERBOSITY_BY_CONVERSATION_TYPE: {
48
+ readonly direct: "verbose";
49
+ readonly group: "quiet";
50
+ readonly unknown: "verbose";
51
+ };
52
+ /**
53
+ * Folds every spelling a runtime might hand us onto the three keys the
54
+ * defaults map has. Accepts a raw string because the value arrives from
55
+ * provenance, a conversation fetch, or a Python-side payload.
56
+ */
57
+ export declare function normalizeTurnVerbosityConversationType(value: string | null | undefined): 'direct' | 'group' | 'unknown';
58
+ /**
59
+ * An explicit `'verbose'`/`'quiet'` wins outright; `'auto'`, unset and any
60
+ * unrecognized value fall through to the per-conversation-type default.
61
+ *
62
+ * `configured` goes through `parseTurnVerbosityConfig` on the way in, so a
63
+ * caller handing over a raw config value gets the same answer as one that
64
+ * pre-parsed. That matters because the escape hatch is the whole point of the
65
+ * field: an operator who writes `Verbose` in a group is opting OUT of quiet,
66
+ * and a byte-exact comparison would drop that back onto the group default —
67
+ * i.e. into silence — with nothing anywhere to warn about it.
68
+ */
69
+ export declare function resolveTurnVerbosity(input: {
70
+ configured?: TurnVerbosityConfig | null;
71
+ conversationType?: TurnVerbosityConversationType | null;
72
+ }): TurnVerbosity;
73
+ /**
74
+ * Shared parser for CLI flags, env vars and config files, so four TS runtimes
75
+ * agree on what a developer typed. Case-insensitive and trimmed.
76
+ *
77
+ * `null` means absent OR unrecognized — `''`, whitespace, `null` and `undefined`
78
+ * land there alongside a genuine typo. A host that warns on `null` must first
79
+ * check the raw input was a non-empty string, or a declared-but-empty
80
+ * `CANON_TURN_VERBOSITY=` (routine in launchd plists, Docker `ENV` and `.env`
81
+ * files) gets reported as a mistake the operator never made. Absent stays `null`
82
+ * rather than collapsing to `'auto'` so that the usual flag-then-env fallback,
83
+ * `parse(flag) ?? parse(env)`, keeps working.
84
+ */
85
+ export declare function parseTurnVerbosityConfig(raw: string | null | undefined): TurnVerbosityConfig | null;