@ziggs-ai/contracts 0.49.1 → 0.50.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/message-command.js +10 -6
- package/dist/messaging.d.ts +18 -0
- package/dist/socket.d.ts +1 -1
- package/package.json +1 -1
package/dist/message-command.js
CHANGED
|
@@ -6,11 +6,15 @@ const fail = (field) => {
|
|
|
6
6
|
throw new Error(`Invalid ${field}`);
|
|
7
7
|
};
|
|
8
8
|
function object(value, keys, field) {
|
|
9
|
+
// A refusal names what was wrong and what is expected, so a caller can fix
|
|
10
|
+
// it on the next try instead of guessing at the shape.
|
|
11
|
+
const expected = `expected an object with ${keys.join(', ')}`;
|
|
9
12
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
10
|
-
return fail(field);
|
|
13
|
+
return fail(`${field}: ${expected}`);
|
|
11
14
|
const row = value;
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const unknown = Object.keys(row).filter((key) => !keys.includes(key));
|
|
16
|
+
if (unknown.length)
|
|
17
|
+
return fail(`${field}: unknown field ${unknown.map((key) => `"${key}"`).join(', ')}; ${expected}`);
|
|
14
18
|
return row;
|
|
15
19
|
}
|
|
16
20
|
function id(value, field, max = 200) {
|
|
@@ -108,19 +112,19 @@ function parseMessageCommand(value) {
|
|
|
108
112
|
const audience = object(row.audience, ['kind', 'principalIds'], 'audience');
|
|
109
113
|
const deliveries = object(row.deliveries, ['kind', 'principalIds'], 'deliveries');
|
|
110
114
|
if (audience.kind !== 'explicit')
|
|
111
|
-
return fail('audience kind');
|
|
115
|
+
return fail('audience kind: it is always "explicit"');
|
|
112
116
|
const audienceValue = {
|
|
113
117
|
kind: 'explicit',
|
|
114
118
|
principalIds: ids(audience.principalIds, 'readers'),
|
|
115
119
|
};
|
|
116
120
|
if (deliveries.kind !== 'explicit')
|
|
117
|
-
return fail('delivery kind');
|
|
121
|
+
return fail('delivery kind: it is always "explicit"');
|
|
118
122
|
const deliveryValue = {
|
|
119
123
|
kind: 'explicit',
|
|
120
124
|
principalIds: ids(deliveries.principalIds, 'recipients'),
|
|
121
125
|
};
|
|
122
126
|
if (row.intent !== 'fyi' && row.intent !== 'request')
|
|
123
|
-
return fail('intent');
|
|
127
|
+
return fail('intent: "fyi" or "request"');
|
|
124
128
|
const command = {
|
|
125
129
|
operationId: id(row.operationId, 'operation id', 128),
|
|
126
130
|
content: { text: id(content.text, 'message text', 32000) },
|
package/dist/messaging.d.ts
CHANGED
|
@@ -152,3 +152,21 @@ export interface ContactAlias {
|
|
|
152
152
|
/** Authenticated owner, not a field accepted from message content or a page. */
|
|
153
153
|
export declare function messageOperationKey(authenticatedOwnerId: string, operationId: string): string;
|
|
154
154
|
export declare function exactArtifactKey(ref: ExactArtifactRef): string;
|
|
155
|
+
/** Exact persisted observations. No observation means only Sent is known. */
|
|
156
|
+
export interface MessageReadState {
|
|
157
|
+
firstUnreadMessageId: string | null;
|
|
158
|
+
messages: Array<{
|
|
159
|
+
messageId: string;
|
|
160
|
+
unread: boolean;
|
|
161
|
+
recipients: Array<{
|
|
162
|
+
/** Scoped to this message, never a raw principal identity. */
|
|
163
|
+
recipientRef: string;
|
|
164
|
+
kind: 'human' | 'agent' | 'workspace';
|
|
165
|
+
seen: boolean;
|
|
166
|
+
seenAt: string | null;
|
|
167
|
+
pickedUpAt: string | null;
|
|
168
|
+
/** Inbox responsibility acknowledged, not task completed or answered. */
|
|
169
|
+
acknowledgedAt: string | null;
|
|
170
|
+
}>;
|
|
171
|
+
}>;
|
|
172
|
+
}
|
package/dist/socket.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export interface ChatParticipantsChangedFrame {
|
|
|
93
93
|
export interface MessageReadFrame {
|
|
94
94
|
addressId?: string;
|
|
95
95
|
messageIds: string[];
|
|
96
|
-
kind?: 'agent_handover';
|
|
96
|
+
kind?: 'agent_handover' | 'agent_acknowledged';
|
|
97
97
|
}
|
|
98
98
|
/** @deprecated Use MessageReadFrame. */
|
|
99
99
|
export type ChatMessageReadFrame = MessageReadFrame;
|
package/package.json
CHANGED