@canonmsg/core 0.2.2 → 0.4.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/agent-resolver.d.ts +4 -0
- package/dist/agent-resolver.js +38 -15
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +3 -0
- package/dist/client.d.ts +6 -2
- package/dist/client.js +21 -2
- package/dist/execution-environment.d.ts +59 -0
- package/dist/execution-environment.js +284 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +7 -2
- package/dist/policy.d.ts +156 -0
- package/dist/policy.js +189 -0
- package/dist/rtdb-rest.d.ts +24 -0
- package/dist/rtdb-rest.js +40 -0
- package/dist/turn-protocol.d.ts +56 -0
- package/dist/turn-protocol.js +152 -0
- package/dist/types.d.ts +31 -8
- package/dist/types.js +7 -6
- package/package.json +7 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
import type { ResolvedAgentBehaviorPolicy } from './policy.js';
|
|
2
|
+
export type MediaAttachmentKind = 'image' | 'audio' | 'file';
|
|
3
|
+
export interface MediaAttachment {
|
|
4
|
+
kind: MediaAttachmentKind;
|
|
5
|
+
url: string;
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
fileName?: string;
|
|
8
|
+
sizeBytes?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
durationMs?: number;
|
|
12
|
+
}
|
|
1
13
|
export interface CanonMessage {
|
|
2
14
|
id: string;
|
|
3
15
|
senderId: string;
|
|
4
16
|
senderType: 'human' | 'ai_agent';
|
|
5
17
|
/** Whether the sender is this agent's owner (server-computed, trusted) */
|
|
6
18
|
isOwner: boolean;
|
|
7
|
-
contentType: 'text' | 'image' | 'audio' | 'contact_card';
|
|
19
|
+
contentType: 'text' | 'image' | 'audio' | 'file' | 'contact_card';
|
|
8
20
|
text: string | null;
|
|
9
21
|
imageUrl: string | null;
|
|
10
22
|
audioUrl: string | null;
|
|
11
23
|
audioDurationMs: number | null;
|
|
24
|
+
attachments?: MediaAttachment[];
|
|
12
25
|
mentions: string[];
|
|
13
26
|
replyTo: string | null;
|
|
14
27
|
replyToPosition: number | null;
|
|
@@ -24,6 +37,7 @@ export interface CanonConversation {
|
|
|
24
37
|
topic: string | null;
|
|
25
38
|
memberIds: string[];
|
|
26
39
|
isAgentChat: boolean;
|
|
40
|
+
behavior?: ResolvedAgentBehaviorPolicy;
|
|
27
41
|
hasUnread?: boolean;
|
|
28
42
|
lastMessage: {
|
|
29
43
|
text: string;
|
|
@@ -33,6 +47,10 @@ export interface CanonConversation {
|
|
|
33
47
|
} | null;
|
|
34
48
|
createdAt: string;
|
|
35
49
|
}
|
|
50
|
+
export interface CanonMessagesPage {
|
|
51
|
+
messages: CanonMessage[];
|
|
52
|
+
behavior?: ResolvedAgentBehaviorPolicy;
|
|
53
|
+
}
|
|
36
54
|
export type AgentClientType = 'claude-code' | 'openclaw' | 'codex' | 'generic';
|
|
37
55
|
/** Declares what session controls an agent type supports. */
|
|
38
56
|
export interface AgentCapabilities {
|
|
@@ -41,6 +59,8 @@ export interface AgentCapabilities {
|
|
|
41
59
|
supportsEffort: boolean;
|
|
42
60
|
supportsSessionState: boolean;
|
|
43
61
|
supportsInterrupt: boolean;
|
|
62
|
+
supportsQueue?: boolean;
|
|
63
|
+
supportsInterleave?: boolean;
|
|
44
64
|
}
|
|
45
65
|
export interface ModelOption {
|
|
46
66
|
value: string;
|
|
@@ -50,11 +70,7 @@ export interface WorkspaceOption {
|
|
|
50
70
|
id: string;
|
|
51
71
|
label: string;
|
|
52
72
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Capability map keyed by clientType. Add new agent types here.
|
|
55
|
-
* ALSO update the duplicate in app/src/types/index.ts (RN app can't
|
|
56
|
-
* import from core directly due to different bundler/runtime).
|
|
57
|
-
*/
|
|
73
|
+
/** Capability map keyed by clientType. Add new agent types here. */
|
|
58
74
|
export declare const AGENT_CAPABILITIES: Record<AgentClientType, AgentCapabilities>;
|
|
59
75
|
/** Trusted agent identity & access context, provided by the server */
|
|
60
76
|
export interface AgentContext {
|
|
@@ -67,9 +83,11 @@ export interface AgentContext {
|
|
|
67
83
|
accessLevel: 'open' | 'owner-only';
|
|
68
84
|
/** Identifies the agent's client platform for UI feature detection */
|
|
69
85
|
clientType?: AgentClientType;
|
|
86
|
+
defaultBehavior?: ResolvedAgentBehaviorPolicy;
|
|
70
87
|
}
|
|
71
88
|
export interface MessageCreatedPayload {
|
|
72
89
|
conversationId: string;
|
|
90
|
+
behavior?: ResolvedAgentBehaviorPolicy;
|
|
73
91
|
message: {
|
|
74
92
|
id: string;
|
|
75
93
|
senderId: string;
|
|
@@ -78,10 +96,11 @@ export interface MessageCreatedPayload {
|
|
|
78
96
|
/** Whether the sender is this agent's owner (server-computed, trusted) */
|
|
79
97
|
isOwner?: boolean;
|
|
80
98
|
text?: string;
|
|
81
|
-
contentType?: 'text' | 'image' | 'audio' | 'contact_card';
|
|
99
|
+
contentType?: 'text' | 'image' | 'audio' | 'file' | 'contact_card';
|
|
82
100
|
imageUrl?: string;
|
|
83
101
|
audioUrl?: string;
|
|
84
102
|
audioDurationMs?: number;
|
|
103
|
+
attachments?: MediaAttachment[];
|
|
85
104
|
replyTo?: string;
|
|
86
105
|
replyToPosition?: number;
|
|
87
106
|
mentions?: string[];
|
|
@@ -101,12 +120,13 @@ export interface PresencePayload {
|
|
|
101
120
|
online: boolean;
|
|
102
121
|
}
|
|
103
122
|
export interface SendMessageOptions {
|
|
104
|
-
contentType?: 'text' | 'audio' | 'image' | 'contact_card';
|
|
123
|
+
contentType?: 'text' | 'audio' | 'image' | 'file' | 'contact_card';
|
|
105
124
|
replyTo?: string;
|
|
106
125
|
replyToPosition?: number;
|
|
107
126
|
audioUrl?: string;
|
|
108
127
|
audioDurationMs?: number;
|
|
109
128
|
imageUrl?: string;
|
|
129
|
+
attachments?: MediaAttachment[];
|
|
110
130
|
contactCardUserId?: string;
|
|
111
131
|
mentions?: string[];
|
|
112
132
|
/** Structured metadata for rich UI (approval cards, etc.) */
|
|
@@ -135,10 +155,13 @@ export interface SessionControl {
|
|
|
135
155
|
}
|
|
136
156
|
/** Written by agent to /session-state/{convoId}/{agentId} in RTDB */
|
|
137
157
|
export interface SessionState {
|
|
158
|
+
lastError?: string;
|
|
138
159
|
model?: string;
|
|
139
160
|
permissionMode?: string;
|
|
140
161
|
effort?: string;
|
|
141
162
|
cwd?: string;
|
|
163
|
+
executionMode?: 'worktree' | 'locked';
|
|
164
|
+
executionBranch?: string;
|
|
142
165
|
/** True when the agent is running under the host wrapper (host.ts) which can apply control signals */
|
|
143
166
|
hostMode?: boolean;
|
|
144
167
|
isActive: boolean;
|
package/dist/types.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
// ── Message ────────────────────────────────────────────────────────────
|
|
2
1
|
const DEFAULT_CAPABILITIES = {
|
|
3
2
|
supportsModelSwitch: false,
|
|
4
3
|
supportsPermissionMode: false,
|
|
5
4
|
supportsEffort: false,
|
|
6
5
|
supportsSessionState: false,
|
|
7
6
|
supportsInterrupt: false,
|
|
7
|
+
supportsQueue: true,
|
|
8
|
+
supportsInterleave: false,
|
|
8
9
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Capability map keyed by clientType. Add new agent types here.
|
|
11
|
-
* ALSO update the duplicate in app/src/types/index.ts (RN app can't
|
|
12
|
-
* import from core directly due to different bundler/runtime).
|
|
13
|
-
*/
|
|
10
|
+
/** Capability map keyed by clientType. Add new agent types here. */
|
|
14
11
|
export const AGENT_CAPABILITIES = {
|
|
15
12
|
'claude-code': {
|
|
16
13
|
supportsModelSwitch: true,
|
|
@@ -18,6 +15,8 @@ export const AGENT_CAPABILITIES = {
|
|
|
18
15
|
supportsEffort: true,
|
|
19
16
|
supportsSessionState: true,
|
|
20
17
|
supportsInterrupt: true,
|
|
18
|
+
supportsQueue: true,
|
|
19
|
+
supportsInterleave: true,
|
|
21
20
|
},
|
|
22
21
|
'codex': {
|
|
23
22
|
supportsModelSwitch: false,
|
|
@@ -25,6 +24,8 @@ export const AGENT_CAPABILITIES = {
|
|
|
25
24
|
supportsEffort: false,
|
|
26
25
|
supportsSessionState: true,
|
|
27
26
|
supportsInterrupt: true,
|
|
27
|
+
supportsQueue: true,
|
|
28
|
+
supportsInterleave: false,
|
|
28
29
|
},
|
|
29
30
|
'openclaw': { ...DEFAULT_CAPABILITIES },
|
|
30
31
|
'generic': { ...DEFAULT_CAPABILITIES },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Canon core — shared types, REST client, SSE stream, and registration for Canon messaging",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,15 +9,19 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./browser": {
|
|
14
|
+
"import": "./dist/browser.js",
|
|
15
|
+
"types": "./dist/browser.d.ts"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
15
19
|
"dist"
|
|
16
20
|
],
|
|
17
21
|
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
22
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc",
|
|
19
23
|
"dev": "tsc --watch",
|
|
20
|
-
"
|
|
24
|
+
"prepack": "npm run build"
|
|
21
25
|
},
|
|
22
26
|
"engines": {
|
|
23
27
|
"node": ">=18.0.0"
|