@canonmsg/core 0.20.0 → 0.21.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/approval-format.d.ts +1 -0
- package/dist/approval-format.js +1 -0
- package/dist/approval-manager.js +6 -1
- package/dist/approval-types.d.ts +2 -0
- package/dist/approval-types.js +2 -0
- package/dist/client.d.ts +33 -0
- package/dist/client.js +20 -0
- package/dist/runtime-cards.d.ts +9 -1
- package/dist/runtime-cards.js +5 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ export declare function buildApprovalRequest(approvalId: string, toolName: strin
|
|
|
5
5
|
riskLevel?: 'normal' | 'destructive';
|
|
6
6
|
risk?: ApprovalRisk;
|
|
7
7
|
category?: ApprovalRequestCategory;
|
|
8
|
+
responseUserId?: string;
|
|
8
9
|
runtimeId?: string;
|
|
9
10
|
turnId?: string;
|
|
10
11
|
native?: ApprovalNativeRequestMetadata;
|
package/dist/approval-format.js
CHANGED
|
@@ -64,6 +64,7 @@ export function buildApprovalRequest(approvalId, toolName, toolInput, opts) {
|
|
|
64
64
|
const metadata = {
|
|
65
65
|
type: 'approval_request',
|
|
66
66
|
approvalId,
|
|
67
|
+
...(opts.responseUserId ? { responseUserId: opts.responseUserId.slice(0, 128) } : {}),
|
|
67
68
|
toolName,
|
|
68
69
|
toolSummary: summary,
|
|
69
70
|
...(opts.category ? { category: opts.category } : {}),
|
package/dist/approval-manager.js
CHANGED
|
@@ -54,6 +54,7 @@ export class ApprovalManager {
|
|
|
54
54
|
riskLevel: opts?.riskLevel,
|
|
55
55
|
risk: opts?.risk,
|
|
56
56
|
category: opts?.category,
|
|
57
|
+
responseUserId: this.ownerId,
|
|
57
58
|
runtimeId: opts?.runtimeId,
|
|
58
59
|
turnId: opts?.turnId,
|
|
59
60
|
native: opts?.native,
|
|
@@ -65,7 +66,11 @@ export class ApprovalManager {
|
|
|
65
66
|
// Send the approval request message with metadata
|
|
66
67
|
// Spread to satisfy Record<string, unknown> without double cast
|
|
67
68
|
await this.client.sendMessage(conversationId, text, {
|
|
68
|
-
metadata: {
|
|
69
|
+
metadata: {
|
|
70
|
+
...metadata,
|
|
71
|
+
turnSemantics: 'control',
|
|
72
|
+
replyBehavior: 'suppress_auto_reply',
|
|
73
|
+
},
|
|
69
74
|
});
|
|
70
75
|
// Wait for reply or timeout
|
|
71
76
|
return new Promise((resolve) => {
|
package/dist/approval-types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface ApprovalRequestMetadata {
|
|
2
2
|
type: 'approval_request';
|
|
3
3
|
approvalId: string;
|
|
4
|
+
/** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
|
|
5
|
+
responseUserId?: string;
|
|
4
6
|
toolName: string;
|
|
5
7
|
/** Pre-computed, redacted summary — raw toolInput is never stored */
|
|
6
8
|
toolSummary: string;
|
package/dist/approval-types.js
CHANGED
|
@@ -172,6 +172,7 @@ export function parseApprovalRequestMetadata(value) {
|
|
|
172
172
|
const expiresMs = Date.parse(expiresAt);
|
|
173
173
|
if (!Number.isFinite(expiresMs))
|
|
174
174
|
return null;
|
|
175
|
+
const responseUserId = normalizeString(value.responseUserId, 128) ?? undefined;
|
|
175
176
|
const riskLevel = value.riskLevel === 'destructive' || value.riskLevel === 'normal'
|
|
176
177
|
? value.riskLevel
|
|
177
178
|
: undefined;
|
|
@@ -184,6 +185,7 @@ export function parseApprovalRequestMetadata(value) {
|
|
|
184
185
|
return {
|
|
185
186
|
type: 'approval_request',
|
|
186
187
|
approvalId,
|
|
188
|
+
...(responseUserId ? { responseUserId } : {}),
|
|
187
189
|
toolName,
|
|
188
190
|
toolSummary,
|
|
189
191
|
...(category ? { category } : {}),
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CanonMessage, type CanonConversation, type CanonContact, type CanonContactRequest, type CanonMessagesPage, type CanonResolveAdmissionResult, type AgentContext, type AddMemberResult, type CreateContactRequestResult, type MediaAttachment, type SendMessageOptions, type CreateConversationOptions, type RegistrationStatus, type SetStreamingOptions } from './types.js';
|
|
2
|
+
import type { RuntimeInputKind } from './runtime-cards.js';
|
|
2
3
|
import type { SendContextualMessageOptions, SendContextualMessageResult } from './self-context.js';
|
|
3
4
|
import type { InboundDisposition } from './turn-protocol.js';
|
|
4
5
|
/**
|
|
@@ -53,6 +54,38 @@ export declare class CanonClient {
|
|
|
53
54
|
setStreaming(options: SetStreamingOptions): Promise<void>;
|
|
54
55
|
clearStreaming(conversationId: string): Promise<void>;
|
|
55
56
|
setTyping(conversationId: string, typing: boolean, status?: 'thinking' | 'typing'): Promise<void>;
|
|
57
|
+
createRuntimeInputRequest(options: {
|
|
58
|
+
conversationId: string;
|
|
59
|
+
inputId: string;
|
|
60
|
+
kind: RuntimeInputKind;
|
|
61
|
+
expiresAt: number;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
success: true;
|
|
64
|
+
inputId: string;
|
|
65
|
+
expiresAt: number;
|
|
66
|
+
}>;
|
|
67
|
+
consumeRuntimeInputResponse(options: {
|
|
68
|
+
conversationId: string;
|
|
69
|
+
inputId: string;
|
|
70
|
+
cancel?: boolean;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
status: 'pending';
|
|
73
|
+
inputId: string;
|
|
74
|
+
expiresAt?: number;
|
|
75
|
+
} | {
|
|
76
|
+
status: 'submitted';
|
|
77
|
+
inputId: string;
|
|
78
|
+
kind: RuntimeInputKind;
|
|
79
|
+
value: string;
|
|
80
|
+
} | {
|
|
81
|
+
status: 'cancelled';
|
|
82
|
+
inputId: string;
|
|
83
|
+
kind: RuntimeInputKind;
|
|
84
|
+
} | {
|
|
85
|
+
status: 'timeout';
|
|
86
|
+
inputId: string;
|
|
87
|
+
kind: RuntimeInputKind;
|
|
88
|
+
}>;
|
|
56
89
|
static register(baseUrl: string | undefined, body: {
|
|
57
90
|
name: string;
|
|
58
91
|
description: string;
|
package/dist/client.js
CHANGED
|
@@ -319,6 +319,26 @@ export class CanonClient {
|
|
|
319
319
|
if (!res.ok)
|
|
320
320
|
throw new CanonApiError(res.status, await res.text());
|
|
321
321
|
}
|
|
322
|
+
async createRuntimeInputRequest(options) {
|
|
323
|
+
const res = await fetch(`${this.baseUrl}/runtime-input/request`, {
|
|
324
|
+
method: 'POST',
|
|
325
|
+
headers: this.authHeaders(),
|
|
326
|
+
body: JSON.stringify(options),
|
|
327
|
+
});
|
|
328
|
+
if (!res.ok)
|
|
329
|
+
throw new CanonApiError(res.status, await res.text());
|
|
330
|
+
return res.json();
|
|
331
|
+
}
|
|
332
|
+
async consumeRuntimeInputResponse(options) {
|
|
333
|
+
const res = await fetch(`${this.baseUrl}/runtime-input/consume`, {
|
|
334
|
+
method: 'POST',
|
|
335
|
+
headers: this.authHeaders(),
|
|
336
|
+
body: JSON.stringify(options),
|
|
337
|
+
});
|
|
338
|
+
if (!res.ok)
|
|
339
|
+
throw new CanonApiError(res.status, await res.text());
|
|
340
|
+
return res.json();
|
|
341
|
+
}
|
|
322
342
|
// ── Static unauthenticated registration endpoints ────────────────────
|
|
323
343
|
static async register(baseUrl, body) {
|
|
324
344
|
const url = baseUrl || DEFAULT_BASE_URL;
|
package/dist/runtime-cards.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface RuntimeQuestionDefinition {
|
|
|
11
11
|
export interface ClaudeQuestionMetadata {
|
|
12
12
|
type: 'claude_question';
|
|
13
13
|
questionId: string;
|
|
14
|
+
/** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
|
|
15
|
+
responseUserId?: string;
|
|
14
16
|
questions: RuntimeQuestionDefinition[];
|
|
15
17
|
}
|
|
16
18
|
export interface ClaudeQuestionReplyMetadata {
|
|
@@ -21,6 +23,8 @@ export interface ClaudeQuestionReplyMetadata {
|
|
|
21
23
|
export interface PlanApprovalMetadata {
|
|
22
24
|
type: 'plan_approval';
|
|
23
25
|
planId: string;
|
|
26
|
+
/** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
|
|
27
|
+
responseUserId?: string;
|
|
24
28
|
title?: string;
|
|
25
29
|
summary?: string;
|
|
26
30
|
body?: string;
|
|
@@ -54,6 +58,8 @@ export interface RuntimeInputNativeMetadata {
|
|
|
54
58
|
export interface RuntimeInputRequestMetadata {
|
|
55
59
|
type: 'runtime_input_request';
|
|
56
60
|
inputId: string;
|
|
61
|
+
/** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
|
|
62
|
+
responseUserId?: string;
|
|
57
63
|
kind: RuntimeInputKind;
|
|
58
64
|
prompt: string;
|
|
59
65
|
title?: string;
|
|
@@ -78,7 +84,9 @@ export interface RuntimeInputOutcomeMetadata {
|
|
|
78
84
|
status: RuntimeInputResolutionStatus;
|
|
79
85
|
reason?: 'submitted' | 'cancelled' | 'timeout' | 'expired' | 'interrupted';
|
|
80
86
|
}
|
|
81
|
-
export declare function buildQuestionRequest(questionId: string, questions: RuntimeQuestionDefinition[]
|
|
87
|
+
export declare function buildQuestionRequest(questionId: string, questions: RuntimeQuestionDefinition[], options?: {
|
|
88
|
+
responseUserId?: string;
|
|
89
|
+
}): {
|
|
82
90
|
text: string;
|
|
83
91
|
metadata: ClaudeQuestionMetadata;
|
|
84
92
|
};
|
package/dist/runtime-cards.js
CHANGED
|
@@ -68,7 +68,7 @@ function assertNoSensitiveRuntimeInputPayload(value) {
|
|
|
68
68
|
&& !('secret' in value)
|
|
69
69
|
&& !('rawValue' in value);
|
|
70
70
|
}
|
|
71
|
-
export function buildQuestionRequest(questionId, questions) {
|
|
71
|
+
export function buildQuestionRequest(questionId, questions, options) {
|
|
72
72
|
const text = questions.length === 1
|
|
73
73
|
? questions[0]?.question || 'Question'
|
|
74
74
|
: `Please answer ${questions.length} questions.`;
|
|
@@ -77,6 +77,7 @@ export function buildQuestionRequest(questionId, questions) {
|
|
|
77
77
|
metadata: {
|
|
78
78
|
type: 'claude_question',
|
|
79
79
|
questionId,
|
|
80
|
+
...(options?.responseUserId ? { responseUserId: options.responseUserId.slice(0, 128) } : {}),
|
|
80
81
|
questions,
|
|
81
82
|
},
|
|
82
83
|
};
|
|
@@ -124,6 +125,7 @@ export function buildRuntimeInputRequest(inputId, input) {
|
|
|
124
125
|
metadata: {
|
|
125
126
|
type: 'runtime_input_request',
|
|
126
127
|
inputId,
|
|
128
|
+
...(input.responseUserId ? { responseUserId: input.responseUserId.slice(0, 128) } : {}),
|
|
127
129
|
kind: input.kind,
|
|
128
130
|
prompt: input.prompt.slice(0, 1000),
|
|
129
131
|
title: title.slice(0, 120),
|
|
@@ -171,6 +173,7 @@ export function parseRuntimeInputRequestMetadata(value) {
|
|
|
171
173
|
if (!assertNoSensitiveRuntimeInputPayload(value))
|
|
172
174
|
return null;
|
|
173
175
|
const inputId = normalizeString(value.inputId, 128);
|
|
176
|
+
const responseUserId = normalizeString(value.responseUserId, 128) ?? undefined;
|
|
174
177
|
const kind = normalizeRuntimeInputKind(value.kind);
|
|
175
178
|
const prompt = normalizeString(value.prompt, 1000);
|
|
176
179
|
const expiresAt = normalizeString(value.expiresAt, 128);
|
|
@@ -186,6 +189,7 @@ export function parseRuntimeInputRequestMetadata(value) {
|
|
|
186
189
|
return {
|
|
187
190
|
type: 'runtime_input_request',
|
|
188
191
|
inputId,
|
|
192
|
+
...(responseUserId ? { responseUserId } : {}),
|
|
189
193
|
kind,
|
|
190
194
|
prompt,
|
|
191
195
|
...(title ? { title } : {}),
|