@cossistant/react 0.0.32 → 0.0.33
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/hooks/index.d.ts +2 -2
- package/hooks/index.js +2 -2
- package/hooks/private/use-grouped-messages.d.ts +27 -2
- package/hooks/private/use-grouped-messages.d.ts.map +1 -1
- package/hooks/private/use-grouped-messages.js +154 -106
- package/hooks/private/use-grouped-messages.js.map +1 -1
- package/hooks/use-new-message-sound.d.ts.map +1 -1
- package/hooks/use-new-message-sound.js +2 -2
- package/hooks/use-new-message-sound.js.map +1 -1
- package/hooks/use-typing-sound.d.ts.map +1 -1
- package/hooks/use-typing-sound.js +2 -2
- package/hooks/use-typing-sound.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +3 -5
- package/packages/tiny-markdown/src/context/index.d.ts +1 -0
- package/packages/tiny-markdown/src/context/tiny-markdown-context.d.ts +3 -0
- package/packages/tiny-markdown/src/hooks/index.d.ts +4 -0
- package/packages/tiny-markdown/src/hooks/use-caret-position.d.ts +1 -0
- package/packages/tiny-markdown/src/hooks/use-tiny-markdown.d.ts +1 -0
- package/packages/tiny-markdown/src/hooks/use-tiny-mention.d.ts +1 -0
- package/packages/tiny-markdown/src/hooks/use-tiny-shortcuts.d.ts +1 -0
- package/packages/tiny-markdown/src/index.d.ts +4 -0
- package/packages/tiny-markdown/src/types.d.ts +75 -0
- package/packages/tiny-markdown/src/types.d.ts.map +1 -0
- package/packages/tiny-markdown/src/utils/index.d.ts +3 -0
- package/packages/tiny-markdown/src/utils/markdown-parser.d.ts +1 -0
- package/packages/tiny-markdown/src/utils/mention-parser.d.ts +1 -0
- package/packages/tiny-markdown/src/utils/merge-refs.d.ts +1 -0
- package/packages/types/src/api/conversation.d.ts +304 -4
- package/packages/types/src/api/conversation.d.ts.map +1 -1
- package/packages/types/src/api/timeline-item.d.ts +228 -3
- package/packages/types/src/api/timeline-item.d.ts.map +1 -1
- package/packages/types/src/realtime-events.d.ts +229 -4
- package/packages/types/src/realtime-events.d.ts.map +1 -1
- package/packages/types/src/schemas.d.ts +76 -1
- package/packages/types/src/schemas.d.ts.map +1 -1
- package/primitives/command-block-utils.d.ts +26 -0
- package/primitives/command-block-utils.d.ts.map +1 -0
- package/primitives/command-block-utils.js +310 -0
- package/primitives/command-block-utils.js.map +1 -0
- package/primitives/index.d.ts +7 -3
- package/primitives/index.js +11 -2
- package/primitives/index.parts.d.ts +6 -2
- package/primitives/index.parts.js +5 -1
- package/primitives/multimodal-input.d.ts +2 -2
- package/primitives/multimodal-input.d.ts.map +1 -1
- package/primitives/timeline-code-block.d.ts +32 -0
- package/primitives/timeline-code-block.d.ts.map +1 -0
- package/primitives/timeline-code-block.js +66 -0
- package/primitives/timeline-code-block.js.map +1 -0
- package/primitives/timeline-command-block.d.ts +29 -0
- package/primitives/timeline-command-block.d.ts.map +1 -0
- package/primitives/timeline-command-block.js +97 -0
- package/primitives/timeline-command-block.js.map +1 -0
- package/primitives/timeline-item-group.d.ts.map +1 -1
- package/primitives/timeline-item-group.js +5 -15
- package/primitives/timeline-item-group.js.map +1 -1
- package/primitives/timeline-item.d.ts +21 -1
- package/primitives/timeline-item.d.ts.map +1 -1
- package/primitives/timeline-item.js +148 -83
- package/primitives/timeline-item.js.map +1 -1
- package/primitives/timeline-message-layout.d.ts +9 -0
- package/primitives/timeline-message-layout.d.ts.map +1 -0
- package/primitives/timeline-message-layout.js +20 -0
- package/primitives/timeline-message-layout.js.map +1 -0
- package/realtime/event-filter.js +4 -3
- package/realtime/event-filter.js.map +1 -1
- package/sounds/sound-data.d.ts +6 -0
- package/sounds/sound-data.d.ts.map +1 -0
- package/sounds/sound-data.js +7 -0
- package/sounds/sound-data.js.map +1 -0
- package/support/components/button.d.ts +2 -2
- package/support/components/button.d.ts.map +1 -1
- package/support/components/button.js +1 -0
- package/support/components/button.js.map +1 -1
- package/support/components/conversation-event.d.ts +3 -0
- package/support/components/conversation-event.d.ts.map +1 -1
- package/support/components/conversation-event.js +46 -15
- package/support/components/conversation-event.js.map +1 -1
- package/support/components/conversation-timeline.d.ts.map +1 -1
- package/support/components/conversation-timeline.js +12 -0
- package/support/components/conversation-timeline.js.map +1 -1
- package/support/components/index.d.ts +2 -1
- package/support/components/index.js +2 -1
- package/support/components/timeline-activity-group.d.ts +25 -0
- package/support/components/timeline-activity-group.d.ts.map +1 -0
- package/support/components/timeline-activity-group.js +104 -0
- package/support/components/timeline-activity-group.js.map +1 -0
- package/support/components/timeline-code-block.d.ts +14 -0
- package/support/components/timeline-code-block.d.ts.map +1 -0
- package/support/components/timeline-code-block.js +44 -0
- package/support/components/timeline-code-block.js.map +1 -0
- package/support/components/timeline-command-block.d.ts +12 -0
- package/support/components/timeline-command-block.d.ts.map +1 -0
- package/support/components/timeline-command-block.js +42 -0
- package/support/components/timeline-command-block.js.map +1 -0
- package/support/components/timeline-message-item.d.ts +2 -1
- package/support/components/timeline-message-item.d.ts.map +1 -1
- package/support/components/timeline-message-item.js +23 -3
- package/support/components/timeline-message-item.js.map +1 -1
- package/support/index.d.ts +4 -4
- package/support/store/support-store.d.ts +5 -5
- package/utils/metadata-hash.d.ts +1 -1
- package/utils/metadata-hash.js +9 -4
- package/utils/metadata-hash.js.map +1 -1
- package/utils/timeline-item-sender.d.ts +17 -0
- package/utils/timeline-item-sender.d.ts.map +1 -0
- package/utils/timeline-item-sender.js +43 -0
- package/utils/timeline-item-sender.js.map +1 -0
- package/utils/use-render-element.d.ts.map +1 -1
package/utils/metadata-hash.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This is used to check if metadata has changed without comparing the entire object.
|
|
5
5
|
* Returns a short hash string (first 8 characters of SHA256).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Uses Web Crypto when available and falls back to a deterministic non-crypto hash.
|
|
8
8
|
*/
|
|
9
9
|
async function computeMetadataHash(metadata) {
|
|
10
10
|
if (!metadata || Object.keys(metadata).length === 0) return "";
|
|
@@ -13,12 +13,17 @@ async function computeMetadataHash(metadata) {
|
|
|
13
13
|
return acc;
|
|
14
14
|
}, {});
|
|
15
15
|
const metadataString = JSON.stringify(sortedMetadata);
|
|
16
|
-
if (
|
|
16
|
+
if (globalThis.crypto?.subtle) {
|
|
17
17
|
const data = new TextEncoder().encode(metadataString);
|
|
18
|
-
const hashBuffer = await
|
|
18
|
+
const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
19
19
|
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, 8);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
let hash = 2166136261;
|
|
22
|
+
for (let i = 0; i < metadataString.length; i += 1) {
|
|
23
|
+
hash ^= metadataString.charCodeAt(i);
|
|
24
|
+
hash = Math.imul(hash, 16777619);
|
|
25
|
+
}
|
|
26
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-hash.js","names":[],"sources":["../../src/utils/metadata-hash.ts"],"sourcesContent":["/**\n * Computes a deterministic hash from metadata object.\n * This is used to check if metadata has changed without comparing the entire object.\n * Returns a short hash string (first 8 characters of SHA256).\n *\n *
|
|
1
|
+
{"version":3,"file":"metadata-hash.js","names":[],"sources":["../../src/utils/metadata-hash.ts"],"sourcesContent":["/**\n * Computes a deterministic hash from metadata object.\n * This is used to check if metadata has changed without comparing the entire object.\n * Returns a short hash string (first 8 characters of SHA256).\n *\n * Uses Web Crypto when available and falls back to a deterministic non-crypto hash.\n */\nexport async function computeMetadataHash(\n\tmetadata: Record<string, unknown> | null | undefined\n): Promise<string> {\n\tif (!metadata || Object.keys(metadata).length === 0) {\n\t\treturn \"\";\n\t}\n\n\t// Sort keys to ensure deterministic output\n\tconst sortedKeys = Object.keys(metadata).sort();\n\tconst sortedMetadata = sortedKeys.reduce(\n\t\t(acc, key) => {\n\t\t\tacc[key] = metadata[key];\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, unknown>\n\t);\n\n\t// Create a stable string representation\n\tconst metadataString = JSON.stringify(sortedMetadata);\n\n\t// Use Web Crypto when available (browser and modern Node runtimes)\n\tif (globalThis.crypto?.subtle) {\n\t\tconst encoder = new TextEncoder();\n\t\tconst data = encoder.encode(metadataString);\n\t\tconst hashBuffer = await globalThis.crypto.subtle.digest(\"SHA-256\", data);\n\t\tconst hashArray = Array.from(new Uint8Array(hashBuffer));\n\t\tconst hashHex = hashArray\n\t\t\t.map((b) => b.toString(16).padStart(2, \"0\"))\n\t\t\t.join(\"\");\n\t\treturn hashHex.slice(0, 8);\n\t}\n\n\t// FNV-1a fallback for runtimes without Web Crypto.\n\tlet hash = 0x81_1c_9d_c5;\n\tfor (let i = 0; i < metadataString.length; i += 1) {\n\t\thash ^= metadataString.charCodeAt(i);\n\t\thash = Math.imul(hash, 0x01_00_01_93);\n\t}\n\n\treturn (hash >>> 0).toString(16).padStart(8, \"0\");\n}\n"],"mappings":";;;;;;;;AAOA,eAAsB,oBACrB,UACkB;AAClB,KAAI,CAAC,YAAY,OAAO,KAAK,SAAS,CAAC,WAAW,EACjD,QAAO;CAKR,MAAM,iBADa,OAAO,KAAK,SAAS,CAAC,MAAM,CACb,QAChC,KAAK,QAAQ;AACb,MAAI,OAAO,SAAS;AACpB,SAAO;IAER,EAAE,CACF;CAGD,MAAM,iBAAiB,KAAK,UAAU,eAAe;AAGrD,KAAI,WAAW,QAAQ,QAAQ;EAE9B,MAAM,OADU,IAAI,aAAa,CACZ,OAAO,eAAe;EAC3C,MAAM,aAAa,MAAM,WAAW,OAAO,OAAO,OAAO,WAAW,KAAK;AAKzE,SAJkB,MAAM,KAAK,IAAI,WAAW,WAAW,CAAC,CAEtD,KAAK,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC3C,KAAK,GAAG,CACK,MAAM,GAAG,EAAE;;CAI3B,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK,GAAG;AAClD,UAAQ,eAAe,WAAW,EAAE;AACpC,SAAO,KAAK,KAAK,MAAM,SAAc;;AAGtC,SAAQ,SAAS,GAAG,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TimelineItem } from "../packages/types/src/api/timeline-item.js";
|
|
2
|
+
import { SenderType } from "@cossistant/types";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/timeline-item-sender.d.ts
|
|
5
|
+
type TimelineItemSender = {
|
|
6
|
+
senderId: string;
|
|
7
|
+
senderType: SenderType;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Resolve timeline item sender consistently across hooks and primitives.
|
|
11
|
+
* Precedence is user -> AI agent -> visitor so tool and event rows that
|
|
12
|
+
* include multiple IDs are grouped/rendered according to the acting sender.
|
|
13
|
+
*/
|
|
14
|
+
declare function getTimelineItemSender(item: TimelineItem): TimelineItemSender;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TimelineItemSender, getTimelineItemSender };
|
|
17
|
+
//# sourceMappingURL=timeline-item-sender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item-sender.d.ts","names":[],"sources":["../../src/utils/timeline-item-sender.ts"],"sourcesContent":[],"mappings":";;;;KASY,kBAAA;;EAAA,UAAA,EAEC,UAFiB;AAsB9B,CAAA;;;;;;iBAAgB,qBAAA,OAA4B,eAAe"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SenderType } from "@cossistant/types";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/timeline-item-sender.ts
|
|
4
|
+
function extractEventPart(item) {
|
|
5
|
+
if (item.type !== "event") return null;
|
|
6
|
+
return item.parts.find((part) => part.type === "event") ?? null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve timeline item sender consistently across hooks and primitives.
|
|
10
|
+
* Precedence is user -> AI agent -> visitor so tool and event rows that
|
|
11
|
+
* include multiple IDs are grouped/rendered according to the acting sender.
|
|
12
|
+
*/
|
|
13
|
+
function getTimelineItemSender(item) {
|
|
14
|
+
if (item.userId) return {
|
|
15
|
+
senderId: item.userId,
|
|
16
|
+
senderType: SenderType.TEAM_MEMBER
|
|
17
|
+
};
|
|
18
|
+
if (item.aiAgentId) return {
|
|
19
|
+
senderId: item.aiAgentId,
|
|
20
|
+
senderType: SenderType.AI
|
|
21
|
+
};
|
|
22
|
+
if (item.visitorId) return {
|
|
23
|
+
senderId: item.visitorId,
|
|
24
|
+
senderType: SenderType.VISITOR
|
|
25
|
+
};
|
|
26
|
+
const eventPart = extractEventPart(item);
|
|
27
|
+
if (eventPart?.actorUserId) return {
|
|
28
|
+
senderId: eventPart.actorUserId,
|
|
29
|
+
senderType: SenderType.TEAM_MEMBER
|
|
30
|
+
};
|
|
31
|
+
if (eventPart?.actorAiAgentId) return {
|
|
32
|
+
senderId: eventPart.actorAiAgentId,
|
|
33
|
+
senderType: SenderType.AI
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
senderId: item.id || "default-sender",
|
|
37
|
+
senderType: SenderType.TEAM_MEMBER
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { getTimelineItemSender };
|
|
43
|
+
//# sourceMappingURL=timeline-item-sender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item-sender.js","names":[],"sources":["../../src/utils/timeline-item-sender.ts"],"sourcesContent":["import {\n\tSenderType,\n\ttype SenderType as SenderTypeValue,\n} from \"@cossistant/types\";\nimport type {\n\tTimelineItem,\n\tTimelinePartEvent,\n} from \"@cossistant/types/api/timeline-item\";\n\nexport type TimelineItemSender = {\n\tsenderId: string;\n\tsenderType: SenderTypeValue;\n};\n\nfunction extractEventPart(item: TimelineItem): TimelinePartEvent | null {\n\tif (item.type !== \"event\") {\n\t\treturn null;\n\t}\n\n\tconst eventPart = item.parts.find(\n\t\t(part): part is TimelinePartEvent => part.type === \"event\"\n\t);\n\n\treturn eventPart ?? null;\n}\n\n/**\n * Resolve timeline item sender consistently across hooks and primitives.\n * Precedence is user -> AI agent -> visitor so tool and event rows that\n * include multiple IDs are grouped/rendered according to the acting sender.\n */\nexport function getTimelineItemSender(item: TimelineItem): TimelineItemSender {\n\tif (item.userId) {\n\t\treturn { senderId: item.userId, senderType: SenderType.TEAM_MEMBER };\n\t}\n\n\tif (item.aiAgentId) {\n\t\treturn { senderId: item.aiAgentId, senderType: SenderType.AI };\n\t}\n\n\tif (item.visitorId) {\n\t\treturn { senderId: item.visitorId, senderType: SenderType.VISITOR };\n\t}\n\n\tconst eventPart = extractEventPart(item);\n\tif (eventPart?.actorUserId) {\n\t\treturn {\n\t\t\tsenderId: eventPart.actorUserId,\n\t\t\tsenderType: SenderType.TEAM_MEMBER,\n\t\t};\n\t}\n\n\tif (eventPart?.actorAiAgentId) {\n\t\treturn {\n\t\t\tsenderId: eventPart.actorAiAgentId,\n\t\t\tsenderType: SenderType.AI,\n\t\t};\n\t}\n\n\treturn {\n\t\tsenderId: item.id || \"default-sender\",\n\t\tsenderType: SenderType.TEAM_MEMBER,\n\t};\n}\n"],"mappings":";;;AAcA,SAAS,iBAAiB,MAA8C;AACvE,KAAI,KAAK,SAAS,QACjB,QAAO;AAOR,QAJkB,KAAK,MAAM,MAC3B,SAAoC,KAAK,SAAS,QACnD,IAEmB;;;;;;;AAQrB,SAAgB,sBAAsB,MAAwC;AAC7E,KAAI,KAAK,OACR,QAAO;EAAE,UAAU,KAAK;EAAQ,YAAY,WAAW;EAAa;AAGrE,KAAI,KAAK,UACR,QAAO;EAAE,UAAU,KAAK;EAAW,YAAY,WAAW;EAAI;AAG/D,KAAI,KAAK,UACR,QAAO;EAAE,UAAU,KAAK;EAAW,YAAY,WAAW;EAAS;CAGpE,MAAM,YAAY,iBAAiB,KAAK;AACxC,KAAI,WAAW,YACd,QAAO;EACN,UAAU,UAAU;EACpB,YAAY,WAAW;EACvB;AAGF,KAAI,WAAW,eACd,QAAO;EACN,UAAU,UAAU;EACpB,YAAY,WAAW;EACvB;AAGF,QAAO;EACN,UAAU,KAAK,MAAM;EACrB,YAAY,WAAW;EACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-render-element.d.ts","names":[],"sources":["../../src/utils/use-render-element.tsx"],"sourcesContent":[],"mappings":";;;;AAI+B,KA8B1B,YAAA,GAAY,MAAS,GAAA,CAAI,iBAAA;AAAiB,KAE1C,SAAA,CAAA,KAAS,CAAA,GAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"use-render-element.d.ts","names":[],"sources":["../../src/utils/use-render-element.tsx"],"sourcesContent":[],"mappings":";;;;AAI+B,KA8B1B,YAAA,GAAY,MAAS,GAAA,CAAI,iBAAA;AAAiB,KAE1C,SAAA,CAAA,KAAS,CAAA,GAAA,MAAA,GAAA,CAA4B,CAAA,KAAK,EAAL,KAAK,EAAA,GAAA,MAAA,CAAA;AAAA,KAE1C,QAAA,CAAA,KAAQ,EAAA,KAAA,CAAA,GAAA,CAAA,KAAA,EACL,KADK,EAAA,KAAA,EAEL,KAFK,EAAA,GAGR,OAAA,CAAM,YAHE;KAKR,WAJG,CAAA,KAAA,EAAA,YAI4B,YAJ5B,CAAA,GAAA;EACA,MAAA,CAAA,EAIE,OAAA,CAAM,YAJR,GAIuB,QAJvB,CAIgC,GAAA,CAAI,iBAJpC,CAIsD,GAJtD,CAAA,EAI4D,KAJ5D,CAAA;EACH,SAAM,CAAA,EAIE,SAJF,CAIY,KAJZ,CAAA;EAAY,OAAA,CAAA,EAAA,OAAA;AAAA,CAAA;KAQlB,YAN+B,CAAA,KAAA,EAAA,YAMC,YAND,CAAA,GAAA;EAC1B,KAAM,CAAA,EAMP,KANO;EAAwB,GAAI,CAAA,EAOrC,OAAA,CAAM,GAP+B,CAAA,GAAA,CAAA;EAAkB,KAAA,CAAA,EAQrD,OARqD,CAQ7C,GAAA,CAAI,iBARyC,CAQvB,GARuB,CAAA,CAAA;EAAM,OAAA,CAAA,EAAA,OAAA;CAArC;;;;AAK1B,iBAqCW,gBArCC,CAAA,cAsCF,MAtCE,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,YAuCJ,YAvCI,CAAA,CAAA,GAAA,EAyCX,GAzCW,EAAA,cAAA,EA0CA,WA1CA,CA0CY,KA1CZ,EA0CmB,GA1CnB,CAAA,EAAA,MAAA,CAAA,EA2CP,YA3CO,CA2CM,KA3CN,EA2Ca,GA3Cb,CAAA,CAAA,EA4Cd,OAAA,CAAM,YA5CQ,GAAA,IAAA"}
|