@pmate/chat-sdk 0.1.6 → 0.1.8

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.
Files changed (63) hide show
  1. package/lib/components/AttachmentPreview.js +20 -4
  2. package/lib/components/ChatInputDesktop.js +149 -43
  3. package/lib/components/ChatInputMobile.js +119 -44
  4. package/lib/components/HoldToTalkButton.js +10 -9
  5. package/lib/components/ImageTrigger.d.ts +1 -1
  6. package/lib/components/ImageTrigger.js +1 -1
  7. package/lib/components/icons.d.ts +3 -0
  8. package/lib/components/icons.js +13 -4
  9. package/lib/hooks/useAttachmentState.d.ts +3 -1
  10. package/lib/hooks/useVoiceInputController.js +21 -2
  11. package/lib/index.d.ts +4 -0
  12. package/lib/index.js +4 -0
  13. package/lib/runtime/botAuth.d.ts +32 -0
  14. package/lib/runtime/botAuth.js +71 -0
  15. package/lib/runtime/botKey.d.ts +14 -0
  16. package/lib/runtime/botKey.js +25 -0
  17. package/lib/runtime/chatClient.d.ts +62 -0
  18. package/lib/runtime/chatClient.js +209 -0
  19. package/lib/runtime/index.d.ts +5 -0
  20. package/lib/runtime/index.js +5 -0
  21. package/lib/runtime/protocol.d.ts +83 -0
  22. package/lib/runtime/protocol.js +113 -0
  23. package/lib/runtime/thread.d.ts +3 -0
  24. package/lib/runtime/thread.js +18 -0
  25. package/lib/tokens/chatInputThemes.js +20 -20
  26. package/lib/tokens/defaultTokens.js +17 -17
  27. package/lib/types/attachment.d.ts +1 -1
  28. package/lib/types/voice.d.ts +1 -0
  29. package/package.json +7 -1
  30. package/dist/assets/ChatInput.stories-CSt4WoEv.js +0 -1702
  31. package/dist/assets/Color-AVL7NMMY-BspvszXC.js +0 -1
  32. package/dist/assets/DocsRenderer-PQXLIZUC-BM8CapQZ.js +0 -1243
  33. package/dist/assets/client-Bw6ZM57k.js +0 -9
  34. package/dist/assets/iframe-Dci6y3pc.js +0 -1071
  35. package/dist/assets/iframe-DnNTepBm.css +0 -1
  36. package/dist/assets/index-DQ_t8Ou6.js +0 -1
  37. package/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
  38. package/dist/assets/react-18-3UzO1Bv7.js +0 -1
  39. package/dist/favicon-wrapper.svg +0 -46
  40. package/dist/favicon.svg +0 -1
  41. package/dist/iframe.html +0 -687
  42. package/dist/index.html +0 -148
  43. package/dist/index.json +0 -1
  44. package/dist/nunito-sans-bold-italic.woff2 +0 -0
  45. package/dist/nunito-sans-bold.woff2 +0 -0
  46. package/dist/nunito-sans-italic.woff2 +0 -0
  47. package/dist/nunito-sans-regular.woff2 +0 -0
  48. package/dist/project.json +0 -1
  49. package/dist/sb-addons/docs-1/manager-bundle.js +0 -151
  50. package/dist/sb-addons/docs-1/manager-bundle.js.LEGAL.txt +0 -0
  51. package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +0 -971
  52. package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
  53. package/dist/sb-common-assets/favicon-wrapper.svg +0 -46
  54. package/dist/sb-common-assets/favicon.svg +0 -1
  55. package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  56. package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  57. package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  58. package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  59. package/dist/sb-manager/globals-module-info.js +0 -799
  60. package/dist/sb-manager/globals-runtime.js +0 -69791
  61. package/dist/sb-manager/globals.js +0 -34
  62. package/dist/sb-manager/runtime.js +0 -13198
  63. package/dist/vite-inject-mocker-entry.js +0 -2
@@ -0,0 +1,3 @@
1
+ export declare function pairId(appId: string, userA: string, userB: string): string;
2
+ export declare function dmThreadId(appId: string, userA: string, userB: string): string;
3
+ export declare function groupThreadId(appId: string, groupId: string): string;
@@ -0,0 +1,18 @@
1
+ export function pairId(appId, userA, userB) {
2
+ const [left, right] = userA <= userB ? [userA, userB] : [userB, userA];
3
+ return stableHash(`social:v1:pair:${appId}:${left}:${right}`);
4
+ }
5
+ export function dmThreadId(appId, userA, userB) {
6
+ return stableHash(`social:v1:dm:${appId}:${pairId(appId, userA, userB)}`);
7
+ }
8
+ export function groupThreadId(appId, groupId) {
9
+ return stableHash(`social:v1:group:${appId}:${groupId}`);
10
+ }
11
+ function stableHash(value) {
12
+ let hash = 0x811c9dc5;
13
+ for (let index = 0; index < value.length; index += 1) {
14
+ hash ^= value.charCodeAt(index);
15
+ hash = Math.imul(hash, 0x01000193);
16
+ }
17
+ return `h${(hash >>> 0).toString(16).padStart(8, "0")}`;
18
+ }
@@ -2,20 +2,20 @@ export const chatInputThemes = {
2
2
  pmate: {},
3
3
  cli: {
4
4
  color: {
5
- brandPrimary: "#15D49A",
6
- surfaceInputDefault: "#07110E",
7
- surfaceInputFocus: "#0C1B16",
8
- surfaceInputRecording: "#0F251E",
5
+ brandPrimary: "#25D6A0",
6
+ surfaceInputDefault: "#0B1512",
7
+ surfaceInputFocus: "#10201A",
8
+ surfaceInputRecording: "#132A22",
9
9
  surfaceInputError: "#251111",
10
- textPrimary: "#E8FFF5",
11
- textSecondary: "#79A996",
12
- iconDefault: "#8DB7A7",
13
- iconActive: "#15D49A",
14
- actionSendDefault: "#15D49A",
10
+ textPrimary: "#ECFFF7",
11
+ textSecondary: "#8CB6A8",
12
+ iconDefault: "#A4C7BA",
13
+ iconActive: "#25D6A0",
14
+ actionSendDefault: "#25D6A0",
15
15
  actionSendDisabled: "#23483B",
16
16
  actionSendTextOnPrimary: "#06100D",
17
- borderDefault: "#1A3A30",
18
- borderFocus: "#15D49A",
17
+ borderDefault: "#263F37",
18
+ borderFocus: "#3A715F",
19
19
  borderError: "#D66B6B",
20
20
  statusError: "#FF8A8A",
21
21
  statusWarning: "#E0B256",
@@ -24,9 +24,9 @@ export const chatInputThemes = {
24
24
  voiceWaveformBackground: "#214A3C",
25
25
  },
26
26
  spacing: {
27
- inputOuter: 10,
27
+ inputOuter: 8,
28
28
  inputInner: 10,
29
- actionGap: 8,
29
+ actionGap: 10,
30
30
  attachmentGap: 8,
31
31
  voiceWaveformGap: 4,
32
32
  mobileTouchInset: 10,
@@ -34,16 +34,16 @@ export const chatInputThemes = {
34
34
  statusHintTop: 6,
35
35
  },
36
36
  radius: {
37
- inputSurface: 8,
38
- actionButton: 6,
39
- attachmentPreview: 6,
37
+ inputSurface: 14,
38
+ actionButton: 18,
39
+ attachmentPreview: 10,
40
40
  waveformBar: 2,
41
- mobileHoldToTalk: 6,
42
- desktopInputSurface: 8,
41
+ mobileHoldToTalk: 14,
42
+ desktopInputSurface: 14,
43
43
  },
44
44
  shadow: {
45
- inputElevated: "0 0 0 1px rgba(21, 212, 154, 0.10)",
46
- recordingActive: "0 0 0 2px rgba(21, 212, 154, 0.28)",
45
+ inputElevated: "0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.18)",
46
+ recordingActive: "0 0 0 4px rgba(37, 214, 160, 0.16)",
47
47
  },
48
48
  typography: {
49
49
  familyBase: '"SF Mono", "JetBrains Mono", monospace',
@@ -1,25 +1,25 @@
1
1
  export const defaultChatInputTokens = {
2
2
  color: {
3
- brandPrimary: "#6D4AFF",
3
+ brandPrimary: "#12B886",
4
4
  surfaceInputDefault: "#FFFFFF",
5
- surfaceInputFocus: "#F7F4FF",
6
- surfaceInputRecording: "#EEE7FF",
5
+ surfaceInputFocus: "#F4F7F6",
6
+ surfaceInputRecording: "#E9F8F1",
7
7
  surfaceInputError: "#FFF1F3",
8
- textPrimary: "#1F1637",
9
- textSecondary: "#6F6790",
10
- iconDefault: "#6F6790",
11
- iconActive: "#6D4AFF",
12
- actionSendDefault: "#6D4AFF",
13
- actionSendDisabled: "#CFC6F6",
8
+ textPrimary: "#18211E",
9
+ textSecondary: "#65736E",
10
+ iconDefault: "#3F4A46",
11
+ iconActive: "#12B886",
12
+ actionSendDefault: "#12B886",
13
+ actionSendDisabled: "#B9D9CF",
14
14
  actionSendTextOnPrimary: "#FFFFFF",
15
- borderDefault: "#E6E0F7",
16
- borderFocus: "#B9A8FF",
15
+ borderDefault: "#DCE6E2",
16
+ borderFocus: "#8EDBC3",
17
17
  borderError: "#F2A7B5",
18
18
  statusError: "#D14363",
19
19
  statusWarning: "#D98E04",
20
20
  statusSuccess: "#2E9B62",
21
- voiceWaveformActive: "#7C5CFF",
22
- voiceWaveformBackground: "#DCD2FF",
21
+ voiceWaveformActive: "#12B886",
22
+ voiceWaveformBackground: "#CFEFE3",
23
23
  },
24
24
  spacing: {
25
25
  inputOuter: 12,
@@ -32,8 +32,8 @@ export const defaultChatInputTokens = {
32
32
  statusHintTop: 6,
33
33
  },
34
34
  radius: {
35
- inputSurface: 20,
36
- actionButton: 16,
35
+ inputSurface: 16,
36
+ actionButton: 18,
37
37
  attachmentPreview: 14,
38
38
  waveformBar: 999,
39
39
  mobileHoldToTalk: 18,
@@ -46,8 +46,8 @@ export const defaultChatInputTokens = {
46
46
  transcribingLoading: "900ms linear infinite",
47
47
  },
48
48
  shadow: {
49
- inputElevated: "0 6px 24px rgba(95, 70, 180, 0.08)",
50
- recordingActive: "0 0 0 4px rgba(109, 74, 255, 0.14)",
49
+ inputElevated: "0 1px 2px rgba(15, 23, 42, 0.04)",
50
+ recordingActive: "0 0 0 4px rgba(18, 184, 134, 0.14)",
51
51
  },
52
52
  typography: {
53
53
  familyBase: '"SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif',
@@ -1,7 +1,7 @@
1
1
  export type ChatAttachment = {
2
2
  id: string;
3
3
  name: string;
4
- kind: "image";
4
+ kind: "image" | "file";
5
5
  file?: File;
6
6
  url?: string;
7
7
  previewUrl?: string;
@@ -11,6 +11,7 @@ export type ChatVoiceConfig = {
11
11
  asrClient?: ChatASRClient;
12
12
  lang?: string;
13
13
  minDurationMs?: number;
14
+ transcribeTimeoutMs?: number;
14
15
  simulatedTranscript?: string;
15
16
  shortRecordingMessage?: string;
16
17
  onVoiceSend?: (blob: Blob) => Promise<void> | void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/chat-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Cross-platform PMate chat input components, voice input primitives, and ASR helpers",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -19,6 +19,11 @@
19
19
  "types": "./lib/index.d.ts",
20
20
  "import": "./lib/index.js",
21
21
  "default": "./lib/index.js"
22
+ },
23
+ "./runtime": {
24
+ "types": "./lib/runtime/index.d.ts",
25
+ "import": "./lib/runtime/index.js",
26
+ "default": "./lib/runtime/index.js"
22
27
  }
23
28
  },
24
29
  "publishConfig": {
@@ -36,6 +41,7 @@
36
41
  "@emoji-mart/data": "^1.2.1",
37
42
  "@emoji-mart/react": "^1.1.1",
38
43
  "@pmate/agent-sdk": "^1.1.2",
44
+ "@msgpack/msgpack": "^3.1.2",
39
45
  "jotai": "^2.16.1"
40
46
  },
41
47
  "peerDependencies": {