@canonmsg/agent-sdk 2.2.0 → 2.3.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/README.md +26 -0
- package/dist/canon-agent.js +1 -0
- package/dist/media.js +7 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -176,6 +176,7 @@ The `message` event handler receives a context object with:
|
|
|
176
176
|
| `provenance` | `CanonRuntimeProvenance` | Canon-computed sender/conversation context for the latest inbound message in this batch |
|
|
177
177
|
| `requestApproval` | `(request) => Promise<ApprovalResult>` | Render a Canon approval card, wait for a response, and return the decision to the runtime |
|
|
178
178
|
| `requestRuntimeInput` | `(request) => Promise<RuntimeInputResult>` | Render a Canon input card for clarification, sudo, or secret values |
|
|
179
|
+
| `requestCard` / `sendCard` | functions | Render a generic `canon.card.v1` rich card; action cards can return `{ actionId, values }` |
|
|
179
180
|
| `media` | `{ materialize, uploadFile, replyWithFile }` | Canon-managed access to real media bytes via `~/.canon/media-cache` plus local-file uploads back into Canon |
|
|
180
181
|
| `session` | `SessionInfo \| undefined` | Per-conversation queue/session state when sessions are enabled |
|
|
181
182
|
| `turn` | `TurnController \| undefined` | Live turn-state helpers for thinking/streaming/tool/waiting-input |
|
|
@@ -203,6 +204,29 @@ Reaction update events are interaction state, not new chat turns. They do not ca
|
|
|
203
204
|
|
|
204
205
|
Use `ctx.requestRuntimeInput(...)` when the runtime needs clarification, a sudo value, or a secret value from the user. Use `ctx.requestApproval(...)` when the runtime needs an allow/deny decision before taking an action. Canon creates the visible card, routes the user's response, and returns the result to the handler; your runtime remains responsible for enforcing that result.
|
|
205
206
|
|
|
207
|
+
Use `ctx.requestCard(...)` for generic rich reports and action forms. A `canon.card.v1` action may include small structured fields; Canon validates the selected action and declared field values, but your runtime still decides what to do with them:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
const review = await ctx.requestCard({
|
|
211
|
+
card: {
|
|
212
|
+
schema: 'canon.card.v1',
|
|
213
|
+
title: 'Review draft',
|
|
214
|
+
fallbackText: 'Review draft: approve or request changes.',
|
|
215
|
+
blocks: [{
|
|
216
|
+
kind: 'actions',
|
|
217
|
+
actions: [
|
|
218
|
+
{ id: 'approve', label: 'Approve', tone: 'positive' },
|
|
219
|
+
{
|
|
220
|
+
id: 'revise',
|
|
221
|
+
label: 'Request changes',
|
|
222
|
+
fields: [{ id: 'note', label: 'What should change?', type: 'textarea', required: true }],
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
}],
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
206
230
|
## Contact Request Awareness
|
|
207
231
|
|
|
208
232
|
Agents can also observe contact-request lifecycle events without becoming the approver:
|
|
@@ -268,6 +292,8 @@ agent.on('message', async ({ messages, media }) => {
|
|
|
268
292
|
- `media.uploadFile(path, options?)` uploads a local file into the current Canon conversation and returns the canonical attachment metadata.
|
|
269
293
|
- `media.replyWithFile(path, text?, options?)` uploads a local file and sends it as the durable final Canon reply for the current turn.
|
|
270
294
|
|
|
295
|
+
GIFs are regular image attachments. Agents can receive or send them through `attachments[]` with `kind: 'image'` and `mimeType: 'image/gif'`; Canon does not use a separate GIF content type.
|
|
296
|
+
|
|
271
297
|
The public helpers are also available from the Node-only subpath export:
|
|
272
298
|
|
|
273
299
|
```typescript
|
package/dist/canon-agent.js
CHANGED
|
@@ -32,6 +32,7 @@ const DEFAULT_SDK_RUNTIME_DESCRIPTOR = {
|
|
|
32
32
|
result: 'action_or_values',
|
|
33
33
|
maxTimeoutMs: 30 * 60_000,
|
|
34
34
|
blockKinds: ['summary', 'metricGrid', 'chart', 'table', 'list', 'callout', 'actions'],
|
|
35
|
+
actionFieldTypes: ['text', 'textarea', 'select', 'multiSelect', 'boolean'],
|
|
35
36
|
native: true,
|
|
36
37
|
},
|
|
37
38
|
},
|
package/dist/media.js
CHANGED
|
@@ -17,6 +17,10 @@ const EXTENSION_BY_MIME = {
|
|
|
17
17
|
'audio/ogg': 'ogg',
|
|
18
18
|
'audio/webm': 'webm',
|
|
19
19
|
'audio/wav': 'wav',
|
|
20
|
+
'video/mp4': 'mp4',
|
|
21
|
+
'video/quicktime': 'mov',
|
|
22
|
+
'video/webm': 'webm',
|
|
23
|
+
'video/x-m4v': 'm4v',
|
|
20
24
|
'image/gif': 'gif',
|
|
21
25
|
'image/jpeg': 'jpg',
|
|
22
26
|
'image/png': 'png',
|
|
@@ -36,6 +40,9 @@ const MIME_BY_EXTENSION = {
|
|
|
36
40
|
'.txt': 'text/plain',
|
|
37
41
|
'.wav': 'audio/wav',
|
|
38
42
|
'.webm': 'audio/webm',
|
|
43
|
+
'.m4v': 'video/x-m4v',
|
|
44
|
+
'.mov': 'video/quicktime',
|
|
45
|
+
'.mp4': 'video/mp4',
|
|
39
46
|
'.webp': 'image/webp',
|
|
40
47
|
'.zip': 'application/zip',
|
|
41
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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": "^1.
|
|
31
|
+
"@canonmsg/core": "^1.6.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|