@canonmsg/backend-contracts 6.1.0 → 6.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/dist/cjs/index.js +1 -0
- package/dist/cjs/message.js +13 -8
- package/dist/cjs/messageText.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/message.d.ts +3 -1
- package/dist/message.js +12 -8
- package/dist/messageText.d.ts +6 -0
- package/dist/messageText.js +11 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./diffRedaction.js"), exports);
|
|
|
18
18
|
__exportStar(require("./environment.js"), exports);
|
|
19
19
|
__exportStar(require("./media.js"), exports);
|
|
20
20
|
__exportStar(require("./message.js"), exports);
|
|
21
|
+
__exportStar(require("./messageText.js"), exports);
|
|
21
22
|
__exportStar(require("./runtimeCardFields.js"), exports);
|
|
22
23
|
__exportStar(require("./runtimeCardStorage.js"), exports);
|
|
23
24
|
__exportStar(require("./turnProtocol.js"), exports);
|
package/dist/cjs/message.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AGENT_CLIENT_TYPES = void 0;
|
|
3
4
|
exports.serializeStoredMessage = serializeStoredMessage;
|
|
4
5
|
const media_js_1 = require("./media.js");
|
|
5
6
|
const runtimeCardStorage_js_1 = require("./runtimeCardStorage.js");
|
|
7
|
+
/** Canonical agent client identifiers shared by Canon services and clients. */
|
|
8
|
+
exports.AGENT_CLIENT_TYPES = [
|
|
9
|
+
'claude-code',
|
|
10
|
+
'openclaw',
|
|
11
|
+
'codex',
|
|
12
|
+
'hermes',
|
|
13
|
+
'deepseek-harness',
|
|
14
|
+
'generic',
|
|
15
|
+
];
|
|
6
16
|
function isRecord(value) {
|
|
7
17
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
18
|
}
|
|
@@ -46,14 +56,9 @@ function requireSenderType(value) {
|
|
|
46
56
|
throw new Error('Message is missing canonical senderType');
|
|
47
57
|
}
|
|
48
58
|
function normalizeAgentClientType(value) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|| value === 'hermes'
|
|
53
|
-
|| value === 'generic') {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
59
|
+
return exports.AGENT_CLIENT_TYPES.includes(value)
|
|
60
|
+
? value
|
|
61
|
+
: undefined;
|
|
57
62
|
}
|
|
58
63
|
function normalizeContentType(value) {
|
|
59
64
|
if (value === 'text'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HUMAN_MESSAGE_TEXT_MAX_BYTES = void 0;
|
|
4
|
+
exports.messageTextUtf8ByteLength = messageTextUtf8ByteLength;
|
|
5
|
+
exports.isHumanMessageTextWithinLimit = isHumanMessageTextWithinLimit;
|
|
6
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
7
|
+
exports.HUMAN_MESSAGE_TEXT_MAX_BYTES = 32 * 1024;
|
|
8
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
9
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
10
|
+
function messageTextUtf8ByteLength(value) {
|
|
11
|
+
return UTF8_ENCODER.encode(value).byteLength;
|
|
12
|
+
}
|
|
13
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
14
|
+
function isHumanMessageTextWithinLimit(value) {
|
|
15
|
+
return messageTextUtf8ByteLength(value) <= exports.HUMAN_MESSAGE_TEXT_MAX_BYTES;
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './diffRedaction.js';
|
|
|
2
2
|
export * from './environment.js';
|
|
3
3
|
export * from './media.js';
|
|
4
4
|
export * from './message.js';
|
|
5
|
+
export * from './messageText.js';
|
|
5
6
|
export * from './runtimeCardFields.js';
|
|
6
7
|
export * from './runtimeCardStorage.js';
|
|
7
8
|
export * from './turnProtocol.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './diffRedaction.js';
|
|
|
2
2
|
export * from './environment.js';
|
|
3
3
|
export * from './media.js';
|
|
4
4
|
export * from './message.js';
|
|
5
|
+
export * from './messageText.js';
|
|
5
6
|
export * from './runtimeCardFields.js';
|
|
6
7
|
export * from './runtimeCardStorage.js';
|
|
7
8
|
export * from './turnProtocol.js';
|
package/dist/message.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MediaAttachment } from './media.js';
|
|
2
2
|
export type SerializedSenderType = 'human' | 'ai_agent';
|
|
3
|
-
|
|
3
|
+
/** Canonical agent client identifiers shared by Canon services and clients. */
|
|
4
|
+
export declare const AGENT_CLIENT_TYPES: readonly ["claude-code", "openclaw", "codex", "hermes", "deepseek-harness", "generic"];
|
|
5
|
+
export type SerializedAgentClientType = typeof AGENT_CLIENT_TYPES[number];
|
|
4
6
|
export type SerializedContentType = 'text' | 'image' | 'audio' | 'video' | 'file' | 'contact_card' | 'interaction';
|
|
5
7
|
export interface ForwardedFrom {
|
|
6
8
|
sourceConversationId: string;
|
package/dist/message.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { normalizeStoredAttachments } from './media.js';
|
|
2
2
|
import { decodeStoredRuntimeCard } from './runtimeCardStorage.js';
|
|
3
|
+
/** Canonical agent client identifiers shared by Canon services and clients. */
|
|
4
|
+
export const AGENT_CLIENT_TYPES = [
|
|
5
|
+
'claude-code',
|
|
6
|
+
'openclaw',
|
|
7
|
+
'codex',
|
|
8
|
+
'hermes',
|
|
9
|
+
'deepseek-harness',
|
|
10
|
+
'generic',
|
|
11
|
+
];
|
|
3
12
|
function isRecord(value) {
|
|
4
13
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
14
|
}
|
|
@@ -43,14 +52,9 @@ function requireSenderType(value) {
|
|
|
43
52
|
throw new Error('Message is missing canonical senderType');
|
|
44
53
|
}
|
|
45
54
|
function normalizeAgentClientType(value) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|| value === 'hermes'
|
|
50
|
-
|| value === 'generic') {
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
55
|
+
return AGENT_CLIENT_TYPES.includes(value)
|
|
56
|
+
? value
|
|
57
|
+
: undefined;
|
|
54
58
|
}
|
|
55
59
|
function normalizeContentType(value) {
|
|
56
60
|
if (value === 'text'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
2
|
+
export declare const HUMAN_MESSAGE_TEXT_MAX_BYTES: number;
|
|
3
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
4
|
+
export declare function messageTextUtf8ByteLength(value: string): number;
|
|
5
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
6
|
+
export declare function isHumanMessageTextWithinLimit(value: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
2
|
+
export const HUMAN_MESSAGE_TEXT_MAX_BYTES = 32 * 1024;
|
|
3
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
4
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
5
|
+
export function messageTextUtf8ByteLength(value) {
|
|
6
|
+
return UTF8_ENCODER.encode(value).byteLength;
|
|
7
|
+
}
|
|
8
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
9
|
+
export function isHumanMessageTextWithinLimit(value) {
|
|
10
|
+
return messageTextUtf8ByteLength(value) <= HUMAN_MESSAGE_TEXT_MAX_BYTES;
|
|
11
|
+
}
|