@canonmsg/agent-sdk 8.3.0 → 8.4.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.
@@ -1,5 +1,5 @@
1
1
  import { type AddMemberResult, type CanonContact, type CanonConversation, type CanonConversationsPage, type CanonConversationsPageOptions, type CreateConversationResult, type CanonRuntimeActivityItem, type CanonRuntimeCommandDescriptor, type CanonRuntimeFact, type CanonRuntimePrimitiveId, type ContactCardPayload, type ClearRuntimeActivityOptions, type CreateContactRequestResult, type CanonVoiceSession, type CanonVoiceSessionToken, type CreateVoiceSessionOptions, type VoiceSessionEventPayload } from '@canonmsg/core';
2
- import type { CanonAgentConnectionOptions, CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, CreateConversationOptions, MessageHandler, MessageUpdatedHandler, ReachOutOptions, ReachOutResult, ContactRequestHandler, RuntimeSignalHandler, RuntimePrimitiveHandler } from './types.js';
2
+ import type { CanonAgentConnectionOptions, CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, CreateConversationOptions, MessageHandler, MessageUpdatedHandler, ParticipationSuppressedHandler, ReachOutOptions, ReachOutResult, ContactRequestHandler, RuntimeSignalHandler, RuntimePrimitiveHandler } from './types.js';
3
3
  /**
4
4
  * Contact-graph operations exposed under `agent.contacts`. Wraps the REST
5
5
  * endpoints in CanonClient — the same surface a human user would hit through
@@ -46,6 +46,7 @@ export declare class CanonAgent {
46
46
  private contactAddedHandler;
47
47
  private contactRemovedHandler;
48
48
  private messageUpdatedHandler;
49
+ private participationSuppressedHandler;
49
50
  private interruptHandler;
50
51
  private stopAndDropHandler;
51
52
  private newSessionHandler;
@@ -106,6 +107,15 @@ export declare class CanonAgent {
106
107
  on(event: 'contactApproved', handler: ContactRequestHandler): void;
107
108
  on(event: 'contactAdded', handler: ContactAddedHandler): void;
108
109
  on(event: 'contactRemoved', handler: ContactRemovedHandler): void;
110
+ /**
111
+ * OBSERVE-ONLY. Fires when the participation gate suppressed a turn this
112
+ * agent would otherwise have been dispatched (cap reached, mention required,
113
+ * agent-to-agent disabled). Never run a turn off this event — the withheld
114
+ * message is deliberately not delivered, and replying to it would defeat the
115
+ * loop protection. It exists so a benched agent can tell deliberate
116
+ * participation policy from a dead stream.
117
+ */
118
+ on(event: 'participationSuppressed', handler: ParticipationSuppressedHandler): void;
109
119
  on(event: 'interrupt', handler: RuntimeSignalHandler): void;
110
120
  on(event: 'stopAndDrop', handler: RuntimeSignalHandler): void;
111
121
  on(event: 'newSession', handler: RuntimeSignalHandler): void;
@@ -162,6 +172,7 @@ export declare class CanonAgent {
162
172
  }>;
163
173
  private handleContactRequestEvent;
164
174
  private handleContactGraphEvent;
175
+ private handleParticipationSuppressedEvent;
165
176
  private handleMessageUpdatedEvent;
166
177
  stop(): Promise<void>;
167
178
  private hasInterruptSupport;
@@ -259,6 +259,7 @@ export class CanonAgent {
259
259
  contactAddedHandler = null;
260
260
  contactRemovedHandler = null;
261
261
  messageUpdatedHandler = null;
262
+ participationSuppressedHandler = null;
262
263
  interruptHandler = null;
263
264
  stopAndDropHandler = null;
264
265
  newSessionHandler = null;
@@ -470,6 +471,10 @@ export class CanonAgent {
470
471
  this.contactAddedHandler = handler;
471
472
  return;
472
473
  }
474
+ if (event === 'participationSuppressed') {
475
+ this.participationSuppressedHandler = handler;
476
+ return;
477
+ }
473
478
  if (event === 'interrupt') {
474
479
  this.interruptHandler = handler;
475
480
  if (this.running) {
@@ -719,6 +724,11 @@ export class CanonAgent {
719
724
  rtm.setConversationUpdatedHandler((payload) => {
720
725
  this.handleConversationUpdated(payload);
721
726
  });
727
+ rtm.setParticipationSuppressedHandler((payload) => {
728
+ // Observe-only by construction: this path never touches the debouncer,
729
+ // the message handler, or the turn pipeline.
730
+ void this.handleParticipationSuppressedEvent(payload);
731
+ });
722
732
  rtm.setMessageUpdatedHandler((payload) => {
723
733
  void this.handleMessageUpdatedEvent(payload);
724
734
  });
@@ -818,6 +828,16 @@ export class CanonAgent {
818
828
  console.error('[canon-sdk] Contact-graph handler failed:', error instanceof Error ? error.message : error);
819
829
  }
820
830
  }
831
+ async handleParticipationSuppressedEvent(payload) {
832
+ if (!this.participationSuppressedHandler)
833
+ return;
834
+ try {
835
+ await this.participationSuppressedHandler(payload);
836
+ }
837
+ catch (error) {
838
+ console.error('[canon-sdk] participationSuppressed handler failed:', error instanceof Error ? error.message : error);
839
+ }
840
+ }
821
841
  async handleMessageUpdatedEvent(payload) {
822
842
  if (!this.messageUpdatedHandler)
823
843
  return;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { CanonAgent } from './canon-agent.js';
2
2
  export type { AgentContactsAPI, AgentConversationsAPI, AgentUsersAPI } from './canon-agent.js';
3
3
  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';
4
- export type { ApprovalConfig, ApprovalNativeRequestMetadata, ApprovalOutcomeMetadata, ApprovalReplyMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRequestMetadata, ApprovalResult, ApprovalRisk, CanonContact, CanonRuntimeActivityItem, CanonRuntimeActivityKind, CanonRuntimeActivityStatus, CanonRuntimeTurnModeActivation, CanonRuntimeTurnModeDescriptor, CanonRuntimeTurnModeScope, CanonRuntimeFact, CanonRuntimeFactGroup, CanonResolveAdmissionResult, ContactAddedPayload, ContactCardPayload, ContactRemovedPayload, ContactSource, HostAdmissionActionCapabilities, ResolveAdmissionTargetInput, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, RuntimeInputAnswers, RuntimeInputChoice, RuntimeInputKind, RuntimeInputNativeMetadata, RuntimeInputQuestion, SessionRule, } from '@canonmsg/core';
4
+ export type { ApprovalConfig, ApprovalNativeRequestMetadata, ApprovalOutcomeMetadata, ApprovalReplyMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRequestMetadata, ApprovalResult, ApprovalRisk, CanonContact, CanonRuntimeActivityItem, CanonRuntimeActivityKind, CanonRuntimeActivityStatus, CanonRuntimeTurnModeActivation, CanonRuntimeTurnModeDescriptor, CanonRuntimeTurnModeScope, CanonRuntimeFact, CanonRuntimeFactGroup, CanonResolveAdmissionResult, ContactAddedPayload, ContactCardPayload, ContactRemovedPayload, ContactSource, HostAdmissionActionCapabilities, ParticipationSuppressedPayload, ResolveAdmissionTargetInput, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, RuntimeInputAnswers, RuntimeInputChoice, RuntimeInputKind, RuntimeInputNativeMetadata, RuntimeInputQuestion, SessionRule, } from '@canonmsg/core';
5
5
  export { SessionManager } from './session-manager.js';
6
6
  export { DEFAULT_MEDIA_CACHE_DIR, getCodexImagePath, getMessageAttachments, inferUploadMimeType, isAnthropicImageAttachment, materializeAttachment, materializeMessageMedia, materializeReplyContextMedia, resolveAttachmentMimeType, sendMediaFileMessage, toAnthropicImageBlock, uploadMediaFile, } from './media.js';
7
7
  export type { AnthropicImageBlock, AnthropicImageMimeType, MaterializeMediaOptions, MaterializedCanonAttachment, MaterializedCanonReplyContext, ReplyWithFileOptions, UploadMediaFileOptions, } from './media.js';
8
8
  export type { SessionConfig, Session } from './session-manager.js';
9
9
  export type { CanonAgentTurnVerbosityOption } from './turn-verbosity-option.js';
10
10
  export type { AgentContext, CanonGroupContext, CanonKnownRecentParticipant, CanonMembershipChange, CanonContactRequest, CanonMessage, CanonConversation, CanonConversationsPage, CanonConversationsPageOptions, CanonReplyContext, CanonSelfContext, CanonTurnContextV2, CanonRuntimeDescriptor, MessageUpdatedPayload, SendContextualMessageOptions, SendContextualMessageResult, SendContextualSelfContextInput, SendMessageOptions, CreateConversationOptions, CreateConversationResult, DirectSessionSelection, TurnVerbosity, TurnVerbosityConfig, } from '@canonmsg/core';
11
- export type { CanonAgentConnectionOptions, CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, ContactRequestHandler, FinalMessageResult, MessageHandler, MessageHandlerContext, MessageUpdatedHandler, ProgressMessageOptions, ProgressMessageResult, ReachOutOptions, ReachOutResult, RuntimeApprovalRequest, RuntimeInputRequest, RuntimeInputResult, RuntimeControlSurface, RuntimePrimitiveContext, RuntimePrimitiveHandler, RuntimePrimitiveHandlers, SessionInfo, SessionOptions, DeliveryMode, } from './types.js';
11
+ export type { CanonAgentConnectionOptions, CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, ContactRequestHandler, FinalMessageResult, MessageHandler, MessageHandlerContext, MessageUpdatedHandler, ParticipationSuppressedHandler, ProgressMessageOptions, ProgressMessageResult, ReachOutOptions, ReachOutResult, RuntimeApprovalRequest, RuntimeInputRequest, RuntimeInputResult, RuntimeControlSurface, RuntimePrimitiveContext, RuntimePrimitiveHandler, RuntimePrimitiveHandlers, SessionInfo, SessionOptions, DeliveryMode, } from './types.js';
package/dist/types.d.ts CHANGED
@@ -339,6 +339,13 @@ export interface CanonAgentOptions extends CanonAgentConnectionOptions {
339
339
  export type ContactRequestHandler = (request: import('@canonmsg/core').CanonContactRequest) => void | Promise<void>;
340
340
  export type ContactAddedHandler = (contact: import('@canonmsg/core').ContactAddedPayload) => void | Promise<void>;
341
341
  export type ContactRemovedHandler = (payload: import('@canonmsg/core').ContactRemovedPayload) => void | Promise<void>;
342
+ /**
343
+ * Observe-only notice that the participation gate suppressed a turn this
344
+ * agent would otherwise have been dispatched (cap reached, mention required,
345
+ * agent-to-agent disabled). Never run a turn off this event — it exists so a
346
+ * benched agent can tell deliberate participation policy from a dead stream.
347
+ */
348
+ export type ParticipationSuppressedHandler = (payload: import('@canonmsg/core').ParticipationSuppressedPayload) => void | Promise<void>;
342
349
  /**
343
350
  * Result of `agent.reachOut(card)` — describes which side-effect ran so the
344
351
  * caller can decide what to tell the LLM. `messaged` means the agent opened
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/agent-sdk",
3
- "version": "8.3.0",
3
+ "version": "8.4.0",
4
4
  "description": "Canon Agent SDK — build AI agents that participate in Canon conversations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",