@canonmsg/agent-sdk 3.0.0 → 3.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.
- package/dist/canon-agent.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/realtime.js +4 -0
- package/dist/turn-filter.d.ts +2 -1
- package/dist/turn-filter.js +3 -0
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
package/dist/canon-agent.js
CHANGED
|
@@ -1363,6 +1363,9 @@ export class CanonAgent {
|
|
|
1363
1363
|
replyContext,
|
|
1364
1364
|
message: latestMessage ?? undefined,
|
|
1365
1365
|
});
|
|
1366
|
+
const requestedTurnMode = latestMessage
|
|
1367
|
+
? normalizeTurnMetadata(latestMessage.metadata)?.requestedTurnMode ?? null
|
|
1368
|
+
: null;
|
|
1366
1369
|
// Build context methods bound to this conversation
|
|
1367
1370
|
const deleteMessage = (messageId) => this.apiClient.deleteMessage(conversationId, messageId);
|
|
1368
1371
|
const markAsRead = () => this.apiClient.markAsRead(conversationId);
|
|
@@ -1844,6 +1847,7 @@ export class CanonAgent {
|
|
|
1844
1847
|
selfContexts,
|
|
1845
1848
|
provenance,
|
|
1846
1849
|
turnContext,
|
|
1850
|
+
requestedTurnMode,
|
|
1847
1851
|
requestApproval,
|
|
1848
1852
|
requestRuntimeInput,
|
|
1849
1853
|
requestCard,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { CanonAgent } from './canon-agent.js';
|
|
2
2
|
export type { AgentContactsAPI, 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, CanonRuntimeFact, CanonRuntimeFactGroup, CanonResolveAdmissionResult, ContactAddedPayload, ContactCardPayload, ContactRemovedPayload, ContactSource, HostAdmissionActionCapabilities, 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, 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
|
-
export type { AgentContext, CanonGroupContext, CanonKnownRecentParticipant, CanonMembershipChange, CanonContactRequest, CanonMessage, CanonConversation, CanonReplyContext, CanonSelfContext, CanonTurnContextV2, MessageUpdatedPayload, SendContextualMessageOptions, SendContextualMessageResult, SendContextualSelfContextInput, SendMessageOptions, CreateConversationOptions, } from '@canonmsg/core';
|
|
9
|
+
export type { AgentContext, CanonGroupContext, CanonKnownRecentParticipant, CanonMembershipChange, CanonContactRequest, CanonMessage, CanonConversation, CanonReplyContext, CanonSelfContext, CanonTurnContextV2, CanonRuntimeDescriptor, MessageUpdatedPayload, SendContextualMessageOptions, SendContextualMessageResult, SendContextualSelfContextInput, SendMessageOptions, CreateConversationOptions, } from '@canonmsg/core';
|
|
10
10
|
export type { CanonAgentOptions, ContactAddedHandler, ContactRemovedHandler, ContactRequestHandler, MessageHandler, MessageHandlerContext, MessageUpdatedHandler, ProgressMessageOptions, ProgressMessageResult, ReachOutOptions, ReachOutResult, RuntimeApprovalRequest, RuntimeInputRequest, RuntimeInputResult, RuntimeControlSurface, RuntimePrimitiveContext, RuntimePrimitiveHandler, RuntimePrimitiveHandlers, SessionInfo, SessionOptions, DeliveryMode, } from './types.js';
|
package/dist/realtime.js
CHANGED
|
@@ -32,6 +32,10 @@ export class RealtimeManager {
|
|
|
32
32
|
streamUrl,
|
|
33
33
|
handler: {
|
|
34
34
|
onMessage: (payload) => {
|
|
35
|
+
if (payload.turnDispatch && payload.turnDispatch.kind !== 'run_turn') {
|
|
36
|
+
console.error(`[canon-sdk] Ignoring server-dispatched observe-only message in ${payload.conversationId}: ${payload.turnDispatch.reason}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
const m = payload.message;
|
|
36
40
|
const message = {
|
|
37
41
|
id: m.id,
|
package/dist/turn-filter.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type ResolvedAgentBehaviorPolicy, type CanonMessage } from '@canonmsg/core';
|
|
1
|
+
import { type ResolvedAgentBehaviorPolicy, type CanonMessage, type MessageCreatedPayload } from '@canonmsg/core';
|
|
2
2
|
export declare function shouldDispatchInboundMessage(_conversationId: string, agentId: string, message: CanonMessage, options?: {
|
|
3
3
|
conversationType?: 'direct' | 'group' | 'unknown';
|
|
4
4
|
behavior?: ResolvedAgentBehaviorPolicy | null;
|
|
5
5
|
recentHumanCount?: number;
|
|
6
6
|
consecutiveAgentTurns?: number;
|
|
7
7
|
currentAgentStreakStartedByHuman?: boolean;
|
|
8
|
+
turnDispatch?: MessageCreatedPayload['turnDispatch'];
|
|
8
9
|
}): Promise<boolean>;
|
package/dist/turn-filter.js
CHANGED
|
@@ -2,6 +2,9 @@ import { evaluateParticipationPolicy, shouldTriggerAgentTurn, } from '@canonmsg/
|
|
|
2
2
|
export async function shouldDispatchInboundMessage(_conversationId, agentId, message, options) {
|
|
3
3
|
if (message.senderId === agentId)
|
|
4
4
|
return false;
|
|
5
|
+
if (options?.turnDispatch) {
|
|
6
|
+
return options.turnDispatch.kind === 'run_turn';
|
|
7
|
+
}
|
|
5
8
|
const triggerDecision = shouldTriggerAgentTurn({
|
|
6
9
|
senderType: message.senderType,
|
|
7
10
|
metadata: message.metadata,
|
package/dist/types.d.ts
CHANGED
|
@@ -150,6 +150,8 @@ export interface MessageHandlerContext {
|
|
|
150
150
|
provenance: CanonRuntimeProvenance;
|
|
151
151
|
/** Compact structured Canon turn context for the latest inbound message in this handler batch. */
|
|
152
152
|
turnContext: CanonTurnContextV2;
|
|
153
|
+
/** Runtime turn mode requested by the sender for this inbound turn, if any. */
|
|
154
|
+
requestedTurnMode: string | null;
|
|
153
155
|
/**
|
|
154
156
|
* Ask the conversation owner to approve a native runtime action. This only
|
|
155
157
|
* renders Canon's inline approval card; runtimes must explicitly wait for
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/agent-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"node": ">=18.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@canonmsg/core": "^2.
|
|
31
|
+
"@canonmsg/core": "^2.1.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|