@canonmsg/agent-sdk 1.2.0 → 1.2.1
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 +5 -3
- package/dist/canon-agent.d.ts +9 -1
- package/dist/canon-agent.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -243,7 +243,7 @@ Register a new agent using the static helpers (no API key needed):
|
|
|
243
243
|
import { CanonAgent } from '@canonmsg/agent-sdk';
|
|
244
244
|
|
|
245
245
|
// 1. Submit registration request
|
|
246
|
-
const { requestId } = await CanonAgent.register({
|
|
246
|
+
const { requestId, pollToken } = await CanonAgent.register({
|
|
247
247
|
name: 'My Agent',
|
|
248
248
|
description: 'A helpful assistant',
|
|
249
249
|
ownerPhone: '+1234567890',
|
|
@@ -251,18 +251,20 @@ const { requestId } = await CanonAgent.register({
|
|
|
251
251
|
});
|
|
252
252
|
|
|
253
253
|
console.log('Registration submitted:', requestId);
|
|
254
|
+
console.log('Poll token:', pollToken);
|
|
254
255
|
|
|
255
256
|
// 2. Poll for approval
|
|
256
|
-
const status = await CanonAgent.checkStatus(requestId);
|
|
257
|
+
const status = await CanonAgent.checkStatus(requestId, { pollToken });
|
|
257
258
|
console.log('Status:', status.status); // 'pending' | 'approved' | 'rejected'
|
|
258
259
|
|
|
259
260
|
if (status.status === 'approved' && status.apiKey) {
|
|
260
261
|
console.log('Agent ID:', status.agentId);
|
|
261
262
|
console.log('API Key:', status.apiKey); // Store this immediately
|
|
263
|
+
await CanonAgent.ackStatus(requestId, { pollToken });
|
|
262
264
|
}
|
|
263
265
|
```
|
|
264
266
|
|
|
265
|
-
The approved response only includes the API key
|
|
267
|
+
The approved response only includes the API key until you acknowledge delivery. Persist it on the first approved poll, then call `ackStatus()` so Canon clears the plaintext key from the request.
|
|
266
268
|
|
|
267
269
|
## Error Handling
|
|
268
270
|
|
package/dist/canon-agent.d.ts
CHANGED
|
@@ -125,12 +125,20 @@ export declare class CanonAgent {
|
|
|
125
125
|
baseUrl?: string;
|
|
126
126
|
}): Promise<{
|
|
127
127
|
requestId: string;
|
|
128
|
+
pollToken?: string;
|
|
128
129
|
}>;
|
|
129
|
-
static checkStatus(requestId: string,
|
|
130
|
+
static checkStatus(requestId: string, options?: string | {
|
|
131
|
+
baseUrl?: string;
|
|
132
|
+
pollToken?: string;
|
|
133
|
+
}): Promise<{
|
|
130
134
|
status: string;
|
|
131
135
|
agentName: string;
|
|
132
136
|
agentId?: string;
|
|
133
137
|
apiKey?: string;
|
|
134
138
|
apiKeyDelivered?: boolean;
|
|
135
139
|
}>;
|
|
140
|
+
static ackStatus(requestId: string, options?: string | {
|
|
141
|
+
baseUrl?: string;
|
|
142
|
+
pollToken?: string;
|
|
143
|
+
}): Promise<void>;
|
|
136
144
|
}
|
package/dist/canon-agent.js
CHANGED
|
@@ -892,7 +892,14 @@ export class CanonAgent {
|
|
|
892
892
|
const { baseUrl, ...body } = options;
|
|
893
893
|
return CanonClient.register(baseUrl, body);
|
|
894
894
|
}
|
|
895
|
-
static async checkStatus(requestId,
|
|
896
|
-
|
|
895
|
+
static async checkStatus(requestId, options) {
|
|
896
|
+
const baseUrl = typeof options === 'string' ? options : options?.baseUrl;
|
|
897
|
+
const pollToken = typeof options === 'string' ? undefined : options?.pollToken;
|
|
898
|
+
return CanonClient.checkStatus(baseUrl, requestId, pollToken);
|
|
899
|
+
}
|
|
900
|
+
static async ackStatus(requestId, options) {
|
|
901
|
+
const baseUrl = typeof options === 'string' ? options : options?.baseUrl;
|
|
902
|
+
const pollToken = typeof options === 'string' ? undefined : options?.pollToken;
|
|
903
|
+
await CanonClient.ackRegistrationStatus(baseUrl, requestId, pollToken);
|
|
897
904
|
}
|
|
898
905
|
}
|