@canonmsg/agent-sdk 1.5.4 → 1.6.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.d.ts +1 -0
- package/dist/canon-agent.js +18 -19
- package/package.json +2 -2
package/dist/canon-agent.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ export declare class CanonAgent {
|
|
|
140
140
|
private publishAcceptedRuntimeSignal;
|
|
141
141
|
private abortActiveTurns;
|
|
142
142
|
private resolveBatchDeliveryIntent;
|
|
143
|
+
private markQueuedMessagesAccepted;
|
|
143
144
|
private notifyMessageInterrupt;
|
|
144
145
|
private createRuntimeStatePublisher;
|
|
145
146
|
private requireRuntimeStatePublisher;
|
package/dist/canon-agent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApprovalManager, CanonClient, buildCanonGroupContext, createRuntimeStatePublisher, diffCanonMemberIds, FINAL_MESSAGE_HANDOFF_MS, RUNTIME_NEW_SESSION_ACTION, RUNTIME_STOP_ACTION, RUNTIME_STOP_AND_DROP_ACTION, buildRuntimeInputOutcome,
|
|
1
|
+
import { ApprovalManager, CanonClient, buildCanonGroupContext, createRuntimeStatePublisher, diffCanonMemberIds, FINAL_MESSAGE_HANDOFF_MS, RUNTIME_NEW_SESSION_ACTION, RUNTIME_STOP_ACTION, RUNTIME_STOP_AND_DROP_ACTION, buildRuntimeInputOutcome, initRTDBAuth, rtdbRead, rtdbWrite, normalizeTurnMetadata, reachOutToCanonContact, resolveCanonReplyContext, resolveMessageActiveSelfContextId, resolveRuntimeProvenance, selectActiveSelfContexts, } from '@canonmsg/core';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { AuthManager } from './auth.js';
|
|
4
4
|
import { Debouncer } from './debouncer.js';
|
|
@@ -1005,6 +1005,14 @@ export class CanonAgent {
|
|
|
1005
1005
|
? 'interrupt'
|
|
1006
1006
|
: 'queue';
|
|
1007
1007
|
}
|
|
1008
|
+
async markQueuedMessagesAccepted(conversationId, messages) {
|
|
1009
|
+
await Promise.all(messages.map((message) => {
|
|
1010
|
+
if (!message.id || normalizeTurnMetadata(message.metadata)?.inboundDisposition !== 'queued') {
|
|
1011
|
+
return Promise.resolve();
|
|
1012
|
+
}
|
|
1013
|
+
return this.apiClient.updateMessageDisposition(conversationId, message.id, 'accepted_now').catch(() => { });
|
|
1014
|
+
}));
|
|
1015
|
+
}
|
|
1008
1016
|
async notifyMessageInterrupt(conversationId, abortSignal) {
|
|
1009
1017
|
if (!abortSignal || !this.interruptHandler)
|
|
1010
1018
|
return;
|
|
@@ -1059,6 +1067,7 @@ export class CanonAgent {
|
|
|
1059
1067
|
async executeHandler(conversationId, messages, session, provenanceByMessageId) {
|
|
1060
1068
|
if (!this.handler)
|
|
1061
1069
|
return;
|
|
1070
|
+
await this.markQueuedMessagesAccepted(conversationId, messages);
|
|
1062
1071
|
const turnId = randomUUID();
|
|
1063
1072
|
const turnOpenedAt = Date.now();
|
|
1064
1073
|
let turnState = 'thinking';
|
|
@@ -1388,6 +1397,14 @@ export class CanonAgent {
|
|
|
1388
1397
|
inputId,
|
|
1389
1398
|
kind: request.kind,
|
|
1390
1399
|
expiresAt: expiresAtMs,
|
|
1400
|
+
responseUserId: agent.ownerId,
|
|
1401
|
+
title: request.title,
|
|
1402
|
+
prompt: request.prompt,
|
|
1403
|
+
...(request.choices ? { choices: request.choices } : {}),
|
|
1404
|
+
...(request.secretName ? { secretName: request.secretName } : {}),
|
|
1405
|
+
...(request.native ? { native: request.native } : {}),
|
|
1406
|
+
...(request.sensitive !== undefined ? { sensitive: request.sensitive } : {}),
|
|
1407
|
+
turnId: request.turnId ?? turnId,
|
|
1391
1408
|
});
|
|
1392
1409
|
requestCreated = true;
|
|
1393
1410
|
try {
|
|
@@ -1399,24 +1416,6 @@ export class CanonAgent {
|
|
|
1399
1416
|
await this.apiClient.setTyping(conversationId, false);
|
|
1400
1417
|
}
|
|
1401
1418
|
catch { }
|
|
1402
|
-
const card = buildRuntimeInputRequest(inputId, {
|
|
1403
|
-
kind: request.kind,
|
|
1404
|
-
title: request.title,
|
|
1405
|
-
prompt: request.prompt,
|
|
1406
|
-
...(request.choices ? { choices: request.choices } : {}),
|
|
1407
|
-
...(request.secretName ? { secretName: request.secretName } : {}),
|
|
1408
|
-
...(request.native ? { native: request.native } : {}),
|
|
1409
|
-
expiresAt,
|
|
1410
|
-
...(request.sensitive !== undefined ? { sensitive: request.sensitive } : {}),
|
|
1411
|
-
});
|
|
1412
|
-
await this.apiClient.sendMessage(conversationId, card.text, {
|
|
1413
|
-
metadata: {
|
|
1414
|
-
...card.metadata,
|
|
1415
|
-
turnId: request.turnId ?? turnId,
|
|
1416
|
-
turnSemantics: 'control',
|
|
1417
|
-
replyBehavior: 'suppress_auto_reply',
|
|
1418
|
-
},
|
|
1419
|
-
});
|
|
1420
1419
|
while (Date.now() < expiresAtMs) {
|
|
1421
1420
|
throwIfAborted();
|
|
1422
1421
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/agent-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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": "^0.
|
|
31
|
+
"@canonmsg/core": "^0.22.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|