@canonmsg/backend-contracts 1.0.0 → 1.1.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/dist/cjs/index.js +1 -0
- package/dist/cjs/message.js +5 -0
- package/dist/cjs/runtimeCardStorage.js +21 -0
- package/dist/cjs/turnProtocol.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/message.d.ts +2 -0
- package/dist/message.js +5 -0
- package/dist/runtimeCardStorage.d.ts +4 -0
- package/dist/runtimeCardStorage.js +18 -0
- package/dist/turnProtocol.js +3 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./media.js"), exports);
|
|
18
18
|
__exportStar(require("./message.js"), exports);
|
|
19
|
+
__exportStar(require("./runtimeCardStorage.js"), exports);
|
|
19
20
|
__exportStar(require("./turnProtocol.js"), exports);
|
|
20
21
|
__exportStar(require("./agentBehaviorPolicy.js"), exports);
|
|
21
22
|
__exportStar(require("./contactRequest.js"), exports);
|
package/dist/cjs/message.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeStoredMessage = serializeStoredMessage;
|
|
4
4
|
const media_js_1 = require("./media.js");
|
|
5
|
+
const runtimeCardStorage_js_1 = require("./runtimeCardStorage.js");
|
|
5
6
|
function isRecord(value) {
|
|
6
7
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
8
|
}
|
|
@@ -132,5 +133,9 @@ function serializeStoredMessage(input) {
|
|
|
132
133
|
if (contactCard) {
|
|
133
134
|
result.contactCard = contactCard;
|
|
134
135
|
}
|
|
136
|
+
const runtimeCard = (0, runtimeCardStorage_js_1.decodeStoredRuntimeCard)(data);
|
|
137
|
+
if (runtimeCard) {
|
|
138
|
+
result.runtimeCard = runtimeCard;
|
|
139
|
+
}
|
|
135
140
|
return result;
|
|
136
141
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeStoredRuntimeCard = decodeStoredRuntimeCard;
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function decodeStoredRuntimeCard(input) {
|
|
8
|
+
if (isRecord(input.runtimeCard)) {
|
|
9
|
+
return input.runtimeCard;
|
|
10
|
+
}
|
|
11
|
+
if (typeof input.runtimeCardJson !== 'string' || !input.runtimeCardJson.trim()) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(input.runtimeCardJson);
|
|
16
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/cjs/turnProtocol.js
CHANGED
|
@@ -22,7 +22,9 @@ function isHiddenRuntimeCardMetadata(metadata) {
|
|
|
22
22
|
|| metadata.type === 'question_reply'
|
|
23
23
|
|| metadata.type === 'plan_approval_reply'
|
|
24
24
|
|| metadata.type === 'runtime_input_reply'
|
|
25
|
-
|| metadata.type === 'runtime_input_outcome'
|
|
25
|
+
|| metadata.type === 'runtime_input_outcome'
|
|
26
|
+
|| metadata.type === 'runtime_card_reply'
|
|
27
|
+
|| metadata.type === 'runtime_card_outcome';
|
|
26
28
|
}
|
|
27
29
|
function normalizeTurnMetadata(metadata) {
|
|
28
30
|
if (!isRecord(metadata))
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/message.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface SerializedMessage {
|
|
|
36
36
|
createdAt: string;
|
|
37
37
|
metadata?: Record<string, unknown>;
|
|
38
38
|
contactCard?: SerializedContactCard;
|
|
39
|
+
/** Durable canon.card.v1 runtime card content, passed through opaquely. */
|
|
40
|
+
runtimeCard?: Record<string, unknown>;
|
|
39
41
|
}
|
|
40
42
|
export interface SerializeMessageInput {
|
|
41
43
|
id: string;
|
package/dist/message.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeStoredAttachments } from './media.js';
|
|
2
|
+
import { decodeStoredRuntimeCard } from './runtimeCardStorage.js';
|
|
2
3
|
function isRecord(value) {
|
|
3
4
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
5
|
}
|
|
@@ -129,5 +130,9 @@ export function serializeStoredMessage(input) {
|
|
|
129
130
|
if (contactCard) {
|
|
130
131
|
result.contactCard = contactCard;
|
|
131
132
|
}
|
|
133
|
+
const runtimeCard = decodeStoredRuntimeCard(data);
|
|
134
|
+
if (runtimeCard) {
|
|
135
|
+
result.runtimeCard = runtimeCard;
|
|
136
|
+
}
|
|
132
137
|
return result;
|
|
133
138
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function isRecord(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function decodeStoredRuntimeCard(input) {
|
|
5
|
+
if (isRecord(input.runtimeCard)) {
|
|
6
|
+
return input.runtimeCard;
|
|
7
|
+
}
|
|
8
|
+
if (typeof input.runtimeCardJson !== 'string' || !input.runtimeCardJson.trim()) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(input.runtimeCardJson);
|
|
13
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/turnProtocol.js
CHANGED
|
@@ -11,7 +11,9 @@ function isHiddenRuntimeCardMetadata(metadata) {
|
|
|
11
11
|
|| metadata.type === 'question_reply'
|
|
12
12
|
|| metadata.type === 'plan_approval_reply'
|
|
13
13
|
|| metadata.type === 'runtime_input_reply'
|
|
14
|
-
|| metadata.type === 'runtime_input_outcome'
|
|
14
|
+
|| metadata.type === 'runtime_input_outcome'
|
|
15
|
+
|| metadata.type === 'runtime_card_reply'
|
|
16
|
+
|| metadata.type === 'runtime_card_outcome';
|
|
15
17
|
}
|
|
16
18
|
export function normalizeTurnMetadata(metadata) {
|
|
17
19
|
if (!isRecord(metadata))
|