@ziggs-ai/api-client 0.22.0 → 0.22.2
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default `ziggs_chat_list` projection.
|
|
3
|
+
*
|
|
4
|
+
* The wire row carries three web-app rosters (`members`, `rosterSummary`,
|
|
5
|
+
* `participantSummary`) and repeats the persona on each. The MCP default
|
|
6
|
+
* keeps the people who actually receive (`participantSummary`) and drops the
|
|
7
|
+
* other two unless `fields` asks for them.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CHAT_LIST_DEFAULT_FIELDS: readonly ["chatId", "name", "updatedAt", "lastMessage", "unreadCount", "participantSummary"];
|
|
10
|
+
/** Apply `fields`, or the MCP default when the caller omitted it. */
|
|
11
|
+
export declare function projectChatListRows(chats: unknown[], fieldsRaw?: unknown): unknown[];
|
|
12
|
+
export declare function utf8Bytes(value: unknown): number;
|
|
13
|
+
/** Rough token count: 4 UTF-8 bytes per token, rounded up. */
|
|
14
|
+
export declare function approxTokens(value: unknown): number;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { pickListedRow, parseListFields } from './listedFields.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default `ziggs_chat_list` projection.
|
|
4
|
+
*
|
|
5
|
+
* The wire row carries three web-app rosters (`members`, `rosterSummary`,
|
|
6
|
+
* `participantSummary`) and repeats the persona on each. The MCP default
|
|
7
|
+
* keeps the people who actually receive (`participantSummary`) and drops the
|
|
8
|
+
* other two unless `fields` asks for them.
|
|
9
|
+
*/
|
|
10
|
+
export const CHAT_LIST_DEFAULT_FIELDS = [
|
|
11
|
+
'chatId',
|
|
12
|
+
'name',
|
|
13
|
+
'updatedAt',
|
|
14
|
+
'lastMessage',
|
|
15
|
+
'unreadCount',
|
|
16
|
+
'participantSummary',
|
|
17
|
+
];
|
|
18
|
+
function slimParticipant(row) {
|
|
19
|
+
if (!row || typeof row !== 'object' || Array.isArray(row))
|
|
20
|
+
return row;
|
|
21
|
+
const rec = row;
|
|
22
|
+
const view = rec.presentationView;
|
|
23
|
+
const { presentationView: _drop, ...rest } = rec;
|
|
24
|
+
if (view && typeof view === 'object' && !Array.isArray(view)) {
|
|
25
|
+
const presented = view;
|
|
26
|
+
return {
|
|
27
|
+
...rest,
|
|
28
|
+
...(rest.persona == null && presented.persona != null
|
|
29
|
+
? { persona: presented.persona }
|
|
30
|
+
: {}),
|
|
31
|
+
...(rest.presentation == null && presented.mode != null
|
|
32
|
+
? { presentation: presented.mode }
|
|
33
|
+
: {}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return rest;
|
|
37
|
+
}
|
|
38
|
+
function projectOneChat(row, fields) {
|
|
39
|
+
const picked = pickListedRow(row, fields);
|
|
40
|
+
if (Array.isArray(picked.participantSummary)) {
|
|
41
|
+
picked.participantSummary = picked.participantSummary.map(slimParticipant);
|
|
42
|
+
}
|
|
43
|
+
return picked;
|
|
44
|
+
}
|
|
45
|
+
/** Apply `fields`, or the MCP default when the caller omitted it. */
|
|
46
|
+
export function projectChatListRows(chats, fieldsRaw) {
|
|
47
|
+
const fields = parseListFields(fieldsRaw) ?? [...CHAT_LIST_DEFAULT_FIELDS];
|
|
48
|
+
return chats.map((row) => row && typeof row === 'object' && !Array.isArray(row)
|
|
49
|
+
? projectOneChat(row, fields)
|
|
50
|
+
: row);
|
|
51
|
+
}
|
|
52
|
+
export function utf8Bytes(value) {
|
|
53
|
+
return Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
54
|
+
}
|
|
55
|
+
/** Rough token count: 4 UTF-8 bytes per token, rounded up. */
|
|
56
|
+
export function approxTokens(value) {
|
|
57
|
+
return Math.ceil(utf8Bytes(value) / 4);
|
|
58
|
+
}
|
|
@@ -6,6 +6,7 @@ export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsRe
|
|
|
6
6
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.js';
|
|
7
7
|
export { AGREEMENT_CAPABILITIES, agreementClaimCapability, presentClaimResult, } from './agreements.js';
|
|
8
8
|
export { LIST_FIELDS_PARAM, parseListFields, pickListedRow, pickListedRows, } from './listedFields.js';
|
|
9
|
+
export { CHAT_LIST_DEFAULT_FIELDS, projectChatListRows, utf8Bytes, approxTokens, } from './chatListFields.js';
|
|
9
10
|
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTaskOutcome, type TaskOutcomeEffects, type TaskOutcomePresentation, } from './tasks.js';
|
|
10
11
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
11
12
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
@@ -6,6 +6,7 @@ export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsRe
|
|
|
6
6
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.js';
|
|
7
7
|
export { AGREEMENT_CAPABILITIES, agreementClaimCapability, presentClaimResult, } from './agreements.js';
|
|
8
8
|
export { LIST_FIELDS_PARAM, parseListFields, pickListedRow, pickListedRows, } from './listedFields.js';
|
|
9
|
+
export { CHAT_LIST_DEFAULT_FIELDS, projectChatListRows, utf8Bytes, approxTokens, } from './chatListFields.js';
|
|
9
10
|
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, presentTaskOutcome, } from './tasks.js';
|
|
10
11
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
11
12
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|