@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,46 @@
1
+ import { type DriverTurn, type RuntimeDriver } from '../runner/types.js';
2
+ export interface CodexDriverOptions {
3
+ /** The directory Codex works in. The agent may also send files from it. */
4
+ cwd: string;
5
+ /** A model id; Codex's configured default otherwise. */
6
+ model?: string;
7
+ /** Codex's sandbox for the owner's turns: `workspace-write` (the default), `read-only` or `danger-full-access`. */
8
+ sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access';
9
+ /**
10
+ * When Codex asks before acting in the owner's turns: `on-request` (the default), `untrusted` or `never`. Each request
11
+ * becomes a Canon approval. A turn holding a message from anyone but the owner or a confirmed trusted agent of the owner
12
+ * (`TurnInputMessage.trustedAgent`) is always read-only and approves nothing.
13
+ */
14
+ approvalPolicy?: 'untrusted' | 'on-request' | 'never';
15
+ /**
16
+ * The owner's standing instructions for this agent (its role, say), appended to the thread's developer instructions
17
+ * after Canon's own framing. At most 32 KiB; the CLI reads them from `--instructions <file>`. Never sent to Canon.
18
+ */
19
+ instructions?: string;
20
+ /** The Codex CLI (default: `codex` on the PATH). */
21
+ codexPath?: string;
22
+ /** How long an interrupted Codex may take to stop before its process is closed (default 5 s). */
23
+ interruptGraceMs?: number;
24
+ }
25
+ type Json = Record<string, unknown>;
26
+ /** Checks the Codex CLI runs at all; the CLI calls it at startup so a missing install fails at once. */
27
+ export declare function checkCodex(codexPath?: string): string;
28
+ /**
29
+ * Codex's requests to its client, from the turn's thread or a subagent's. Approvals are scoped to exactly what they
30
+ * allow: a session approval covers the same command with the same directory, network destination and permissions, the
31
+ * same set of files or the same MCP tool, never "commands". A request whose scope is not fully known is approved once.
32
+ * A command's, file change's or permission request's key is `exec`, `apply_patch` or `permissions` and a digest of what
33
+ * it covers (`callScope`), which the runner keeps as it is and the cards offer as one exact call; an MCP approval's key
34
+ * names its server and tool, all of whose calls it covers. `rpcId` is the request's own JSON-RPC id, the identity of a
35
+ * request that names no item.
36
+ */
37
+ export declare function answerCodexRequest(turn: DriverTurn, method: string, params: Json, items: Map<string, Json>, rpcId: unknown): Promise<unknown>;
38
+ /**
39
+ * Runs each turn as one `codex app-server` process that resumes the room's Codex thread, whose id the runner keeps in
40
+ * the driver state, and exits after the turn. Settings that differ per turn (Canon's tool URL and token, the guard for
41
+ * turns holding anyone else's message) are thread settings, so a fresh process per turn applies them exactly. Canon's
42
+ * tools reach Codex only as the turn's `canon` MCP server; Stop interrupts the native turn and closes a process that
43
+ * does not stop. A room's next turn starts only after the previous process has exited.
44
+ */
45
+ export declare function codexDriver(options: CodexDriverOptions): RuntimeDriver;
46
+ export {};
@@ -0,0 +1,34 @@
1
+ import { type ConnectorRelayAck, type ConnectorRelayClaim, type ConnectorRelayInputRef, type ConnectorRelaySettleOutcome } from '../internal/backend-contracts/index.js';
2
+ import { type RuntimeDriver } from '../runner/types.js';
3
+ /**
4
+ * The driver boundary (spec §11.3): what the relay channel calls on behalf of the remote assistant, through the
5
+ * connector's pickup tools. Each running turn is one pending input until the assistant claims it.
6
+ */
7
+ export interface ConnectorInbox {
8
+ /** Unclaimed inputs in the room, oldest first. */
9
+ pending(conversationId: string, limit?: number): ConnectorRelayInputRef[];
10
+ /**
11
+ * The first claim gets `runAllowed` and the turn's input, once Canon confirms the agent may still act on it (its
12
+ * membership and the room's audience, read now, never from a hint); a repeat gets its state, never the input again.
13
+ * A claim that cannot be confirmed by `deadline` (epoch ms) is refused as busy and the input stays pending.
14
+ */
15
+ claim(inputId: string, requestId: string, options?: {
16
+ deadline?: number;
17
+ }): Promise<ConnectorRelayClaim>;
18
+ /** The turn's one final. */
19
+ reply(inputId: string, requestId: string, text: string): ConnectorRelayAck;
20
+ /** `completed` or `no_reply`: a silent turn; `failed`: the runner's failure notice. */
21
+ settle(inputId: string, requestId: string, outcome: ConnectorRelaySettleOutcome): ConnectorRelayAck;
22
+ }
23
+ export interface ConnectorDriver extends RuntimeDriver {
24
+ readonly name: 'connector';
25
+ readonly inbox: ConnectorInbox;
26
+ }
27
+ /**
28
+ * The `connector` driver: the runtime is an assistant its provider runs (ChatGPT, Claude.ai and the like), reached
29
+ * through Canon's remote MCP connector, so a turn waits, as one pending input, for the assistant to claim it and answer
30
+ * through the connector's pickup tools (spec §11.3). It keeps no timer: an assistant that never answers is the runner's
31
+ * no-progress deadline, which a claim restarts. It never calls Canon itself; the relay channel calls its inbox, and the
32
+ * runner confirms each claim with Canon.
33
+ */
34
+ export declare function connectorDriver(): ConnectorDriver;
package/dist/index.d.ts CHANGED
@@ -1,27 +1,22 @@
1
- export { CanonAgent } from './canon-agent.js';
2
- export { createCanonManagedSessionHost } from './managed-session-host.js';
3
- export type { CanonManagedSessionHostOptions } from './managed-session-host.js';
4
- export { MANAGED_EXECUTION_MODE_LABELS, buildManagedSessionCatalog, configureManagedSession, findManagedSessionState, hasSavedNativeSession, inspectGitEnvironment, managedSessionFields, observedSessionFields, savedSessionFields, savedSessionMatchesOwner, } from './managed-session-setup.js';
5
- export type { ManagedSessionConfiguredFacts, ManagedSessionProject, ManagedSessionRuntime, } from './managed-session-setup.js';
6
- export { clearPendingRegistration, ensureAgentProfile, resumeRegistration } from '@canonmsg/core';
7
- export type { EnsureAgentProfileOptions, RegistrationCredentials, RegistrationProgress, RegistrationSession, RegistrationStatus, RegistrationStore, ResumeRegistrationOptions } from '@canonmsg/core';
8
- export type { AgentContactsAPI, AgentConversationsAPI, AgentDirectoryAPI, AgentUsersAPI, } from './canon-agent.js';
9
- export { ApprovalManager, buildApprovalOutcome, buildApprovalReply, buildApprovalRequest, CanonApiError, DEFAULT_APPROVAL_CONFIG, generateApprovalId, HOST_ADMISSION_ACTION_CAPABILITIES, HOST_ADMISSION_ACTIONS_DISABLED, parseApprovalReplyMetadata, parseApprovalRequestMetadata, parseSessionRule, redactSecrets, } from '@canonmsg/core';
10
- export type { ApprovalConfig, ApprovalNativeRequestMetadata, ApprovalOutcomeMetadata, ApprovalReplyMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRequestMetadata, ApprovalResult, ApprovalRisk, CanonContact, CanonRuntimeActivityItem, CanonRuntimeActivityKind, CanonRuntimeActivityStatus, CanonRuntimeTurnModeActivation, CanonRuntimeTurnModeDescriptor, CanonRuntimeTurnModeScope, CanonRuntimeFact, CanonRuntimeFactGroup, CanonResolveAdmissionResult, CanonAgentDirectoryEntry, ContactAddedPayload, ContactCardPayload, ContactRemovedPayload, ContactSource, DiscoverAgentsInput, DiscoverAgentsResult, HostAdmissionActionCapabilities, ParticipationSuppressedPayload, ResolveAdmissionTargetInput, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, ResumableMediaUploadResult, MediaAttachment, VideoProcessingStatus, VideoProcessingErrorCode, RuntimeInputAnswers, RuntimeInputChoice, RuntimeInputKind, RuntimeInputNativeMetadata, RuntimeInputQuestion, RuntimePlanRequestPayload, RuntimePlanRequestResult, SessionRule, } from '@canonmsg/core';
11
- export { SessionManager } from './session-manager.js';
1
+ export { createRunner, runtimeDescriptor } from './runner/runner.js';
2
+ export type { Runner, RunnerOptions } from './runner/runner.js';
3
+ export { ConnectorRelayError, DriverSessionError } from './runner/types.js';
4
+ export { loadMlsDevConfiguration, MLS_SETUP_ACTIONS, mlsDevRoomPackageId, runMlsDevSetup } from './runner/mls.js';
5
+ export type { MlsSetupAction, RunnerMlsOptions } from './runner/mls.js';
6
+ export type { ActivityEvent, AskAnswer, AskRequest, DriverCapabilities, DriverResult, DriverState, DriverTurn, ErrandFacts, RuntimeDriver, ToolDefinition, ToolResult, TurnInput, TurnInputMessage, TurnTools, } from './runner/types.js';
7
+ export { errandJournal, errandsDirectory, queueErrand } from './runner/errands.js';
8
+ export type { ErrandCommand, ErrandInput, ErrandKind, ErrandRecord, ErrandStatus } from './runner/errands.js';
9
+ export { codeDriver } from './drivers/code.js';
10
+ export type { CodeHandler, CodeTurn } from './drivers/code.js';
11
+ export { claudeDriver, loadClaudeQuery } from './drivers/claude.js';
12
+ export type { ClaudeDriverOptions, ClaudeQuery } from './drivers/claude.js';
13
+ export { checkCodex, codexDriver } from './drivers/codex.js';
14
+ export type { CodexDriverOptions } from './drivers/codex.js';
15
+ export { connectorDriver } from './drivers/connector.js';
16
+ export type { ConnectorDriver, ConnectorInbox } from './drivers/connector.js';
17
+ export { loadRelayConfiguration, startRelayChannel } from './runner/relay.js';
18
+ export type { RelayChannel, RelayChannelOptions, RelayConfiguration, RelayCredentialDelivery, RelayTarget } from './runner/relay.js';
19
+ export { CanonApiError, clearPendingRegistration, ensureAgentProfile, resumeRegistration } from './internal/core/index.js';
20
+ export type { CommunicateInput, CommunicateResult, EnsureAgentProfileOptions, MediaAttachment, RegistrationCredentials, RegistrationProgress, RegistrationSession, RegistrationStatus, RegistrationStore, ResumableMediaUploadResult, ResumeRegistrationOptions, VideoProcessingErrorCode, VideoProcessingStatus, } from './internal/core/index.js';
12
21
  export { DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES, DEFAULT_MEDIA_CACHE_DIR, DEFAULT_MEDIA_MATERIALIZATION_BYTES, MAX_ANTHROPIC_IMAGE_RAW_BYTES, MAX_ANTHROPIC_REQUEST_BYTES, MAX_CANON_MEDIA_BYTES, getCodexImagePath, getMessageAttachments, inferUploadMimeType, isAnthropicImageAttachment, conversationMediaCacheDir, materializeAttachment, materializeMessageMedia, materializeReplyContextMedia, resolveAttachmentMimeType, sendMediaFileMessage, toAnthropicImageBlock, toAnthropicImageBlocksWithinBudget, uploadMediaFile, } from './media.js';
13
22
  export type { AnthropicImageBlock, AnthropicImageBudgetOptions, AnthropicImageMimeType, MaterializeMediaOptions, MaterializedCanonAttachment, MaterializedCanonReplyContext, ReplyWithFileOptions, UploadMediaFileOptions, } from './media.js';
14
- export type { SessionConfig, Session } from './session-manager.js';
15
- export type { CanonAgentTurnVerbosityOption } from './turn-verbosity-option.js';
16
- export type { AgentContext, CanonGroupContext, CanonKnownRecentParticipant, CanonMembershipChange, CanonMessage, CanonConversation, CommunicateInput, CommunicateResult, DirectConversationSelection, CanonConversationsPage, CanonConversationsPageOptions, CanonReplyContext, CanonSelfContext, CanonTurnContextV2, CanonRuntimeDescriptor, MessageUpdatedPayload, SendMessageOptions, CreateGroupOptions, CreateGroupResult, TurnVerbosity, TurnVerbosityConfig, } from '@canonmsg/core';
17
- export type { CanonAgentConnectionOptions, CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, FinalMessageResult, MessageHandler, MessageHandlerContext, MessageUpdatedHandler, ParticipationSuppressedHandler, ProgressMessageOptions, ProgressMessageResult, RuntimeApprovalRequest, RuntimeInputRequest, RuntimeInputResult, RuntimePlanReviewRequest, RuntimePlanReviewResult, RuntimeControlSurface, RuntimePrimitiveContext, RuntimePrimitiveHandler, RuntimePrimitiveHandlers, SessionInfo, SessionOptions, DeliveryMode, } from './types.js';
18
- export { createCanonAttachedSession, createCanonAttachedSessionPublisher } from './attached-session.js';
19
- export { createCanonWorkSessionHost } from './work-session-host.js';
20
- export type { CanonWorkSessionHost, CanonWorkSessionHostOptions } from './work-session-host.js';
21
- export { createFileWorkSessionHostStore } from './work-session-state.js';
22
- export type { WorkSessionHostStore, WorkSessionHostJournal } from './work-session-state.js';
23
- export { createFileAttachedSessionStore } from '@canonmsg/core';
24
- export type { CanonAttachedSession, CanonAttachedSessionConnection, CanonAttachedSessionOptions, CanonAttachedSessionStatus, } from './attached-session.js';
25
- export type { AttachedNativeSessionAdapter, AttachedSessionBinding, AttachedSessionJournal, AttachedSessionState, AttachedSessionStore, NativeSessionEvent, NativeSessionItem, NativeSessionSnapshot, NativeSubmissionResult, } from '@canonmsg/core';
26
- export { ARTIFACT_CONTEXT_PROTOCOL, ARTIFACT_LIMITS, CanonArtifactError, isCanonArtifactEnvironmentEnabled, parseArtifactContext, readArtifactContext, } from '@canonmsg/core';
27
- export type { CanonConversationArtifacts, CanonArtifactErrorCode, ArtifactConflictView, ArtifactDomainOutcome, ArtifactCreateInput, ArtifactUpdateAction, ArtifactUpdateResult, ArtifactWriteView, ArtifactInputValue, ArtifactList, ArtifactListItem, ArtifactGenerateImageInput, ArtifactGenerateImageResult, ArtifactAddImageInput, ArtifactAddImageResult, ArtifactImageRegion, ArtifactAsset, ArtifactView, ArtifactPrincipalView, ArtifactChessView, ArtifactChessMoveView, ArtifactFormView, ArtifactFormFieldView, ArtifactFormChangeView, ArtifactImageView, ArtifactImageVariantView, ArtifactKind, ArtifactFormField, ArtifactFormFieldType, ArtifactFormValue, ArtifactFormTable, ArtifactFormColumn, ArtifactContext, ArtifactReference, ArtifactReferenceOrigin, ArtifactSelection, } from '@canonmsg/core';
package/dist/index.js CHANGED
@@ -1,13 +1,91 @@
1
- export { CanonAgent } from './canon-agent.js';
2
- export { createCanonManagedSessionHost } from './managed-session-host.js';
3
- export { MANAGED_EXECUTION_MODE_LABELS, buildManagedSessionCatalog, configureManagedSession, findManagedSessionState, hasSavedNativeSession, inspectGitEnvironment, managedSessionFields, observedSessionFields, savedSessionFields, savedSessionMatchesOwner, } from './managed-session-setup.js';
4
- export { clearPendingRegistration, ensureAgentProfile, resumeRegistration } from '@canonmsg/core';
5
- export { ApprovalManager, buildApprovalOutcome, buildApprovalReply, buildApprovalRequest, CanonApiError, DEFAULT_APPROVAL_CONFIG, generateApprovalId, HOST_ADMISSION_ACTION_CAPABILITIES, HOST_ADMISSION_ACTIONS_DISABLED, parseApprovalReplyMetadata, parseApprovalRequestMetadata, parseSessionRule, redactSecrets, } from '@canonmsg/core';
6
- export { SessionManager } from './session-manager.js';
7
- export { DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES, DEFAULT_MEDIA_CACHE_DIR, DEFAULT_MEDIA_MATERIALIZATION_BYTES, MAX_ANTHROPIC_IMAGE_RAW_BYTES, MAX_ANTHROPIC_REQUEST_BYTES, MAX_CANON_MEDIA_BYTES, getCodexImagePath, getMessageAttachments, inferUploadMimeType, isAnthropicImageAttachment, conversationMediaCacheDir, materializeAttachment, materializeMessageMedia, materializeReplyContextMedia, resolveAttachmentMimeType, sendMediaFileMessage, toAnthropicImageBlock, toAnthropicImageBlocksWithinBudget, uploadMediaFile, } from './media.js';
8
- export { createCanonAttachedSession, createCanonAttachedSessionPublisher } from './attached-session.js';
9
- export { createCanonWorkSessionHost } from './work-session-host.js';
10
- export { createFileWorkSessionHostStore } from './work-session-state.js';
11
- export { createFileAttachedSessionStore } from '@canonmsg/core';
12
- // Shared work (Dev-only preview): `ctx.artifacts` is `CanonClient.artifacts(conversationId)`.
13
- export { ARTIFACT_CONTEXT_PROTOCOL, ARTIFACT_LIMITS, CanonArtifactError, isCanonArtifactEnvironmentEnabled, parseArtifactContext, readArtifactContext, } from '@canonmsg/core';
1
+ import {
2
+ ConnectorRelayError,
3
+ DriverSessionError,
4
+ MLS_SETUP_ACTIONS,
5
+ checkCodex,
6
+ claudeDriver,
7
+ codeDriver,
8
+ codexDriver,
9
+ connectorDriver,
10
+ createRunner,
11
+ errandJournal,
12
+ errandsDirectory,
13
+ loadClaudeQuery,
14
+ loadMlsDevConfiguration,
15
+ loadRelayConfiguration,
16
+ mlsDevRoomPackageId,
17
+ queueErrand,
18
+ runMlsDevSetup,
19
+ runtimeDescriptor,
20
+ startRelayChannel
21
+ } from "./chunks/chunk-N722GWCP.js";
22
+ import {
23
+ CanonApiError,
24
+ DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
25
+ DEFAULT_MEDIA_CACHE_DIR,
26
+ DEFAULT_MEDIA_MATERIALIZATION_BYTES,
27
+ MAX_ANTHROPIC_IMAGE_RAW_BYTES,
28
+ MAX_ANTHROPIC_REQUEST_BYTES,
29
+ MAX_CANON_MEDIA_BYTES,
30
+ clearPendingRegistration,
31
+ conversationMediaCacheDir,
32
+ ensureAgentProfile,
33
+ getCodexImagePath,
34
+ getMessageAttachments,
35
+ inferUploadMimeType,
36
+ isAnthropicImageAttachment,
37
+ materializeAttachment,
38
+ materializeMessageMedia,
39
+ materializeReplyContextMedia,
40
+ resolveAttachmentMimeType,
41
+ resumeRegistration,
42
+ sendMediaFileMessage,
43
+ toAnthropicImageBlock,
44
+ toAnthropicImageBlocksWithinBudget,
45
+ uploadMediaFile
46
+ } from "./chunks/chunk-QZ4PPRQW.js";
47
+ import "./chunks/chunk-7N6OPPW4.js";
48
+ export {
49
+ CanonApiError,
50
+ ConnectorRelayError,
51
+ DEFAULT_ANTHROPIC_REQUEST_HEADROOM_BYTES,
52
+ DEFAULT_MEDIA_CACHE_DIR,
53
+ DEFAULT_MEDIA_MATERIALIZATION_BYTES,
54
+ DriverSessionError,
55
+ MAX_ANTHROPIC_IMAGE_RAW_BYTES,
56
+ MAX_ANTHROPIC_REQUEST_BYTES,
57
+ MAX_CANON_MEDIA_BYTES,
58
+ MLS_SETUP_ACTIONS,
59
+ checkCodex,
60
+ claudeDriver,
61
+ clearPendingRegistration,
62
+ codeDriver,
63
+ codexDriver,
64
+ connectorDriver,
65
+ conversationMediaCacheDir,
66
+ createRunner,
67
+ ensureAgentProfile,
68
+ errandJournal,
69
+ errandsDirectory,
70
+ getCodexImagePath,
71
+ getMessageAttachments,
72
+ inferUploadMimeType,
73
+ isAnthropicImageAttachment,
74
+ loadClaudeQuery,
75
+ loadMlsDevConfiguration,
76
+ loadRelayConfiguration,
77
+ materializeAttachment,
78
+ materializeMessageMedia,
79
+ materializeReplyContextMedia,
80
+ mlsDevRoomPackageId,
81
+ queueErrand,
82
+ resolveAttachmentMimeType,
83
+ resumeRegistration,
84
+ runMlsDevSetup,
85
+ runtimeDescriptor,
86
+ sendMediaFileMessage,
87
+ startRelayChannel,
88
+ toAnthropicImageBlock,
89
+ toAnthropicImageBlocksWithinBudget,
90
+ uploadMediaFile
91
+ };
@@ -0,0 +1,122 @@
1
+ /** Conversation scope a policy is resolved for. Absent means "agent scope". */
2
+ export type PolicyConversationType = 'direct' | 'group' | 'unknown';
3
+ export type ParticipationStyle = 'natural' | 'collaborative' | 'mention-first' | 'approval-gated' | 'handoff-only' | 'observer';
4
+ /**
5
+ * The stored/parsed shape. This is the RETURN type of
6
+ * {@link parseAgentBehaviorSettings} and {@link normalizeStoredAgentBehaviorPolicy},
7
+ * so its optional fields deliberately stay `T | undefined` — widening them to
8
+ * `T | null` would be a breaking change for every reader of those results.
9
+ * Parameter positions take {@link AgentBehaviorSettingsInput} instead.
10
+ */
11
+ export interface AgentBehaviorSettingsRecord {
12
+ participationStyle?: ParticipationStyle;
13
+ allowAgentToAgent?: boolean;
14
+ allowLongRunningCollaboration?: boolean;
15
+ requireMentionForGroupReplies?: boolean;
16
+ maxConsecutiveAgentTurns?: number | null;
17
+ instructions?: string | null;
18
+ }
19
+ /**
20
+ * The input shape accepted by {@link resolveAgentBehaviorPolicy}. Every field
21
+ * additionally accepts an explicit `null` (an editor clearing a value), which
22
+ * coalesces exactly like `undefined` — the field falls through to the next
23
+ * layer. {@link AgentBehaviorSettingsRecord} is assignable to this type.
24
+ */
25
+ export interface AgentBehaviorSettingsInput {
26
+ participationStyle?: ParticipationStyle | null;
27
+ allowAgentToAgent?: boolean | null;
28
+ allowLongRunningCollaboration?: boolean | null;
29
+ requireMentionForGroupReplies?: boolean | null;
30
+ maxConsecutiveAgentTurns?: number | null;
31
+ instructions?: string | null;
32
+ }
33
+ export interface ParticipationPolicy {
34
+ style: ParticipationStyle;
35
+ allowAgentToAgent: boolean;
36
+ allowHumanToAgent: boolean;
37
+ allowLongRunningCollaboration: boolean;
38
+ requireMentionForGroupReplies: boolean;
39
+ maxConsecutiveAgentTurns?: number | null;
40
+ }
41
+ export interface ResolvedAgentBehaviorPolicyRecord {
42
+ participation: ParticipationPolicy;
43
+ instructions: string[];
44
+ source: {
45
+ hasAgentDefault: boolean;
46
+ hasConversationOverride: boolean;
47
+ };
48
+ }
49
+ export interface ParticipationDecisionInput {
50
+ conversationType: PolicyConversationType;
51
+ senderType: 'human' | 'ai_agent';
52
+ isOwner: boolean;
53
+ mentionedAgent: boolean;
54
+ recentHumanCount?: number;
55
+ /**
56
+ * Consecutive agent turns already in the streak, NOT counting the message
57
+ * being evaluated. The message itself adds one more when its sender is an
58
+ * agent, and a delivery would add a further one — see the turn-cap check in
59
+ * {@link evaluateParticipationPolicy}.
60
+ */
61
+ consecutiveAgentTurns?: number;
62
+ currentAgentStreakStartedByHuman?: boolean;
63
+ }
64
+ export interface ParticipationDecision {
65
+ allow: boolean;
66
+ reasonCode: string;
67
+ reason: string;
68
+ }
69
+ export interface ParticipationHistoryMessage {
70
+ id?: string;
71
+ senderId: string;
72
+ senderType: 'human' | 'ai_agent';
73
+ metadata?: unknown;
74
+ }
75
+ export interface ParticipationHistorySnapshot {
76
+ recentSenderTypes: Array<'human' | 'ai_agent'>;
77
+ recentHumanCount: number;
78
+ recentAgentCount: number;
79
+ consecutiveAgentTurns: number;
80
+ currentAgentStreakStartedByHuman: boolean;
81
+ }
82
+ export declare const PARTICIPATION_HISTORY_FETCH_LIMIT = 50;
83
+ /**
84
+ * Safety backstop for conversations with no explicit turn cap: at most this
85
+ * many consecutive agent turns before a human speaks or a new conversation
86
+ * starts.
87
+ *
88
+ * This is a backstop, not the steering wheel — agents are expected to stop on
89
+ * their own. Every triggerable agent message counts in both direct and group
90
+ * conversations. An explicit `null` remains the deployer opt-out for trusted,
91
+ * intentionally long-running collaboration.
92
+ */
93
+ export declare const DEFAULT_GROUP_MAX_CONSECUTIVE_AGENT_TURNS = 4;
94
+ export declare const DEFAULT_DIRECT_MAX_CONSECUTIVE_AGENT_TURNS = 4;
95
+ export declare function parseAgentBehaviorSettings(raw: unknown): AgentBehaviorSettingsRecord;
96
+ export declare function normalizeStoredAgentBehaviorPolicy(raw: Record<string, unknown> | undefined): AgentBehaviorSettingsRecord | null;
97
+ export declare function normalizeAgentBehaviorInstructions(value: string | null | undefined): string | null;
98
+ /**
99
+ * The scope-independent participation defaults. `maxConsecutiveAgentTurns` is
100
+ * `null` here because the turn cap is scope-dependent — a conversation with no
101
+ * stored setting resolves to its direct or group safety default. Use
102
+ * {@link resolveAgentBehaviorPolicy} with a `conversationType` to learn what a
103
+ * given conversation actually enforces.
104
+ */
105
+ export declare function getDefaultParticipationPolicy(): ParticipationPolicy;
106
+ /**
107
+ * Coalesce agent defaults and a conversation override into the resolved record
108
+ * every runtime reads. `conversationType` selects the Canon-wide fallbacks that
109
+ * differ per scope — today only the turn cap, which defaults to 4 in direct and
110
+ * group conversations and to unlimited elsewhere. Omit it when resolving for
111
+ * the agent scope (no conversation);
112
+ * an absent or unknown type always resolves to the unlimited default, so a call
113
+ * site that forgets to thread it can never invent a cap.
114
+ */
115
+ export declare function resolveAgentBehaviorPolicy(params?: {
116
+ agentDefault?: AgentBehaviorSettingsInput | null;
117
+ conversationOverride?: AgentBehaviorSettingsInput | null;
118
+ conversationType?: PolicyConversationType;
119
+ }): ResolvedAgentBehaviorPolicyRecord;
120
+ export declare function buildParticipationHistorySnapshot(messages: ParticipationHistoryMessage[], agentId?: string): ParticipationHistorySnapshot;
121
+ export declare function appendParticipationHistoryMessage(snapshot: ParticipationHistorySnapshot, message: ParticipationHistoryMessage, limit?: number): ParticipationHistorySnapshot;
122
+ export declare function evaluateParticipationPolicy(policy: ResolvedAgentBehaviorPolicyRecord | null | undefined, input: ParticipationDecisionInput): ParticipationDecision;
@@ -0,0 +1,32 @@
1
+ import type { CommunicationRule } from './communication.js';
2
+ import type { AgentOrigin } from './agentOrigin.js';
3
+ /** Shared paging bounds for Canon's discoverable-agent directory. */
4
+ export declare const DEFAULT_DISCOVER_AGENTS_LIMIT = 20;
5
+ export declare const MAX_DISCOVER_AGENTS_LIMIT = 25;
6
+ export declare const MAX_DISCOVER_AGENTS_QUERY_LENGTH = 64;
7
+ export interface DiscoverAgentsInput {
8
+ query?: string;
9
+ limit?: number;
10
+ cursor?: string | null;
11
+ }
12
+ /** Public, addressable identity returned to an authenticated agent caller. */
13
+ export interface CanonAgentDirectoryEntry {
14
+ principalId: string;
15
+ canonContactId?: string;
16
+ displayName?: string;
17
+ description?: string;
18
+ /** Self-reported source attribution; never an identity or verification claim. */
19
+ origin?: AgentOrigin;
20
+ /** Human principal accountable for this agent. */
21
+ owner: {
22
+ principalId: string;
23
+ displayName?: string;
24
+ };
25
+ inboundPolicy?: CommunicationRule;
26
+ groupJoinPolicy?: CommunicationRule;
27
+ shareable: boolean;
28
+ }
29
+ export interface DiscoverAgentsResult {
30
+ agents: CanonAgentDirectoryEntry[];
31
+ nextCursor: string | null;
32
+ }
@@ -0,0 +1,23 @@
1
+ /** Public attribution supplied by an agent's developer or connecting client.
2
+ * It describes where an agent came from, never its Canon identity, permissions,
3
+ * uniqueness, or a verified relationship with the named service. */
4
+ export interface AgentOriginDeclaration {
5
+ name: string;
6
+ /** Optional public reference link. Canon does not use it to connect or authenticate. */
7
+ url?: string;
8
+ }
9
+ /** Canon records how it received the declaration. The name and URL remain
10
+ * self-reported, including when an OAuth client supplied them. */
11
+ export interface AgentOrigin extends AgentOriginDeclaration {
12
+ reportedBy: 'registration' | 'connector';
13
+ }
14
+ export declare const MAX_AGENT_ORIGIN_NAME_LENGTH = 120;
15
+ export declare const MAX_AGENT_ORIGIN_URL_LENGTH = 2048;
16
+ /** Strict write-boundary parser. A supplied invalid declaration must be rejected
17
+ * by its caller; absent origin remains optional for existing and custom agents.
18
+ * Unknown fields are rejected, so callers cannot supply Canon's provenance or
19
+ * assert verification. The result is a fresh, normalized value. */
20
+ export declare function parseAgentOriginDeclaration(value: unknown): AgentOriginDeclaration | null;
21
+ /** Closed projection for a stored/public origin. Missing or malformed legacy
22
+ * data returns null; it must not be guessed from an agent's name or client type. */
23
+ export declare function parseAgentOrigin(value: unknown): AgentOrigin | null;
@@ -0,0 +1,17 @@
1
+ /** The indexable fields a stored agent contributes to `searchPrefixes`. */
2
+ export interface AgentSearchIndexFields {
3
+ displayName?: string | null;
4
+ description?: string | null;
5
+ }
6
+ /** The agent shape a directory filter reads. */
7
+ export interface AgentSearchProfile {
8
+ displayName?: string | null;
9
+ agentConfig?: {
10
+ description?: string | null;
11
+ } | null;
12
+ }
13
+ /** Tolerant: non-string input normalises to ''. */
14
+ export declare function normalizeAgentDirectoryQuery(value: unknown): string;
15
+ export declare function getAgentDirectoryQueryTokens(query: string): string[];
16
+ export declare function buildAgentSearchPrefixes(input: AgentSearchIndexFields): string[];
17
+ export declare function matchesAgentSearchQuery(profile: AgentSearchProfile, query: string): boolean;
@@ -0,0 +1,4 @@
1
+ export declare const CANON_API_ORIGINS: {
2
+ readonly "canon-dev-v1": "https://dev.api.canonmail.com";
3
+ readonly "canon-prod-v1": "https://api.canonmail.com";
4
+ };
@@ -0,0 +1 @@
1
+ export declare const MESSAGE_ADMISSION_REQUIRED_CODE: "MESSAGE_ADMISSION_REQUIRED";
@@ -0,0 +1,8 @@
1
+ /** Fractions of the image, origin top-left. */
2
+ export interface ArtifactImageRegion {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function parseArtifactImageRegion(input: unknown): ArtifactImageRegion;