@pmate/chat-sdk 0.1.20 → 0.2.0

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 (51) hide show
  1. package/lib/components/ChatInputDesktop.js +11 -6
  2. package/lib/components/ChatInputMobile.js +4 -1
  3. package/lib/index.d.ts +1 -1
  4. package/lib/index.js +1 -1
  5. package/lib/services/{agentSdkASRClient.d.ts → functionASRClient.d.ts} +7 -7
  6. package/lib/services/{agentSdkASRClient.js → functionASRClient.js} +2 -2
  7. package/lib/types/chatInput.d.ts +1 -0
  8. package/package.json +18 -16
  9. package/dist/assets/ChatInput.stories-pjQKncGw.js +0 -1644
  10. package/dist/assets/Color-AVL7NMMY-CKkkQz33.js +0 -1
  11. package/dist/assets/DocsRenderer-PQXLIZUC-CVx0v9rK.js +0 -1243
  12. package/dist/assets/client-CMlGEQEC.js +0 -9
  13. package/dist/assets/iframe-4FbYaDjf.css +0 -1
  14. package/dist/assets/iframe-Bo_J3UyC.js +0 -1071
  15. package/dist/assets/index-D9myAQ7a.js +0 -1
  16. package/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
  17. package/dist/assets/react-18-CVKdgGic.js +0 -1
  18. package/dist/favicon-wrapper.svg +0 -46
  19. package/dist/favicon.svg +0 -1
  20. package/dist/iframe.html +0 -687
  21. package/dist/index.html +0 -148
  22. package/dist/index.json +0 -1
  23. package/dist/nunito-sans-bold-italic.woff2 +0 -0
  24. package/dist/nunito-sans-bold.woff2 +0 -0
  25. package/dist/nunito-sans-italic.woff2 +0 -0
  26. package/dist/nunito-sans-regular.woff2 +0 -0
  27. package/dist/project.json +0 -1
  28. package/dist/sb-addons/docs-1/manager-bundle.js +0 -151
  29. package/dist/sb-addons/docs-1/manager-bundle.js.LEGAL.txt +0 -0
  30. package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +0 -971
  31. package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
  32. package/dist/sb-common-assets/favicon-wrapper.svg +0 -46
  33. package/dist/sb-common-assets/favicon.svg +0 -1
  34. package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  35. package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  36. package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  37. package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  38. package/dist/sb-manager/globals-module-info.js +0 -799
  39. package/dist/sb-manager/globals-runtime.js +0 -69791
  40. package/dist/sb-manager/globals.js +0 -34
  41. package/dist/sb-manager/runtime.js +0 -13198
  42. package/dist/vite-inject-mocker-entry.js +0 -2
  43. package/lib/recorder-processor.js +0 -20
  44. package/lib/stories/ChatInput.stories.d.ts +0 -15
  45. package/lib/stories/ChatInput.stories.js +0 -38
  46. package/lib/tests/agentSdkASRClient.test.d.ts +0 -1
  47. package/lib/tests/agentSdkASRClient.test.js +0 -39
  48. package/lib/tests/defaultTokens.test.d.ts +0 -1
  49. package/lib/tests/defaultTokens.test.js +0 -16
  50. package/lib/tests/transcriptComposer.test.d.ts +0 -1
  51. package/lib/tests/transcriptComposer.test.js +0 -10
@@ -213,11 +213,14 @@ function DesktopInner(props) {
213
213
  flexDirection: "column",
214
214
  gap: 12,
215
215
  }, children: [_jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 3, placeholder: "Message PMate", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
216
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
217
- event.preventDefault();
218
- if (state.text.trim() || state.attachments.length > 0)
219
- void onSend();
220
- }
216
+ if (event.key !== "Enter" ||
217
+ event.shiftKey ||
218
+ event.nativeEvent.isComposing ||
219
+ event.keyCode === 229)
220
+ return;
221
+ event.preventDefault();
222
+ if (state.text.trim() || state.attachments.length > 0)
223
+ void onSend();
221
224
  }, onChange: (event) => {
222
225
  state.setText(event.target.value);
223
226
  state.setStatus(event.target.value.trim() ? "typing" : "idle");
@@ -280,7 +283,9 @@ function DesktopInner(props) {
280
283
  display: "flex",
281
284
  alignItems: "center",
282
285
  }, children: _jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 1, placeholder: "Message PMate", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
283
- if (event.key !== "Enter") {
286
+ if (event.key !== "Enter" ||
287
+ event.nativeEvent.isComposing ||
288
+ event.keyCode === 229) {
284
289
  return;
285
290
  }
286
291
  const shouldSend = props.submitShortcut === "meta-enter" ? event.metaKey || event.ctrlKey : !event.shiftKey;
@@ -553,7 +553,10 @@ function MobileInner(props) {
553
553
  setRecordingChoice("send");
554
554
  voice.cancelRecording();
555
555
  } }) })) : (_jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 1, wrap: "off", placeholder: "Message", enterKeyHint: "send", onPaste: handlePaste, onDrop: props.onDrop, onKeyDown: (event) => {
556
- if (event.key === "Enter" && !event.shiftKey) {
556
+ if (event.key === "Enter" &&
557
+ !event.shiftKey &&
558
+ !event.nativeEvent.isComposing &&
559
+ event.keyCode !== 229) {
557
560
  event.preventDefault();
558
561
  if (state.text.trim()) {
559
562
  void onSend();
package/lib/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * from "./hooks/useAttachmentState";
14
14
  export * from "./hooks/useChatInputState";
15
15
  export * from "./hooks/useTranscriptComposer";
16
16
  export * from "./hooks/useVoiceInputController";
17
- export * from "./services/agentSdkASRClient";
17
+ export * from "./services/functionASRClient";
18
18
  export * from "./services/authTokenResolver";
19
19
  export * from "./runtime/botAuth";
20
20
  export * from "./runtime/botKey";
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ export * from "./hooks/useAttachmentState";
14
14
  export * from "./hooks/useChatInputState";
15
15
  export * from "./hooks/useTranscriptComposer";
16
16
  export * from "./hooks/useVoiceInputController";
17
- export * from "./services/agentSdkASRClient";
17
+ export * from "./services/functionASRClient";
18
18
  export * from "./services/authTokenResolver";
19
19
  export * from "./runtime/botAuth";
20
20
  export * from "./runtime/botKey";
@@ -1,7 +1,7 @@
1
1
  import { AsyncStream } from "./AsyncStream";
2
- export type AgentSdkStreamLike = {
2
+ export type FunctionStreamLike = {
3
3
  stream<TFinal = unknown, TChunk = Blob>(request: {
4
- agentId: string;
4
+ functionId: string;
5
5
  stream: AsyncStream<TChunk>;
6
6
  params?: Record<string, unknown>;
7
7
  minChunkSizeBytes?: number;
@@ -9,17 +9,17 @@ export type AgentSdkStreamLike = {
9
9
  finish(): Promise<TFinal | null>;
10
10
  };
11
11
  };
12
- export type AgentSdkASRClientOptions = {
13
- client: AgentSdkStreamLike;
14
- agentId: string;
12
+ export type FunctionASRClientOptions = {
13
+ client: FunctionStreamLike;
14
+ functionId: string;
15
15
  tokenResolver?: {
16
16
  getToken(): string;
17
17
  };
18
18
  minChunkSizeBytes?: number;
19
19
  };
20
- export declare class AgentSdkASRClient {
20
+ export declare class FunctionASRClient {
21
21
  private readonly options;
22
- constructor(options: AgentSdkASRClientOptions);
22
+ constructor(options: FunctionASRClientOptions);
23
23
  transcribe(blob: Blob, input?: {
24
24
  lang?: string;
25
25
  }): Promise<{
@@ -1,5 +1,5 @@
1
1
  import { AsyncStream } from "./AsyncStream";
2
- export class AgentSdkASRClient {
2
+ export class FunctionASRClient {
3
3
  options;
4
4
  constructor(options) {
5
5
  this.options = options;
@@ -8,7 +8,7 @@ export class AgentSdkASRClient {
8
8
  const token = this.options.tokenResolver?.getToken() ?? "";
9
9
  const stream = new AsyncStream();
10
10
  const task = this.options.client.stream({
11
- agentId: this.options.agentId,
11
+ functionId: this.options.functionId,
12
12
  stream,
13
13
  params: {
14
14
  lang: input?.lang ?? "auto",
@@ -141,5 +141,6 @@ export type ChatInputMobileProps = ChatInputBaseProps & {
141
141
  voiceModeDefault?: ChatInputMode;
142
142
  };
143
143
  export type ChatInputDesktopProps = ChatInputBaseProps & {
144
+ /** Defaults to Enter to send and Shift+Enter to insert a newline. */
144
145
  submitShortcut?: "enter" | "meta-enter";
145
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/chat-sdk",
3
- "version": "0.1.20",
3
+ "version": "0.2.0",
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",
@@ -29,10 +29,18 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
+ "scripts": {
33
+ "clean": "rimraf lib",
34
+ "build": "pnpm run clean && tsc -p tsconfig.build.json && cp src/voice/recorder-processor.js lib/voice/recorder-processor.js",
35
+ "prepack": "pnpm run build",
36
+ "npm:publish": "pnpm run build && npm publish --access public --registry https://registry.npmjs.org/",
37
+ "test": "vitest run",
38
+ "storybook": "storybook dev -p 6009",
39
+ "build-storybook": "storybook build --output-dir dist"
40
+ },
32
41
  "dependencies": {
33
42
  "@emoji-mart/data": "^1.2.1",
34
43
  "@emoji-mart/react": "^1.1.1",
35
- "@pmate/agent-sdk": "^1.1.2",
36
44
  "@msgpack/msgpack": "^3.1.2",
37
45
  "jotai": "^2.16.1"
38
46
  },
@@ -43,21 +51,15 @@
43
51
  "devDependencies": {
44
52
  "@storybook/addon-docs": "^9.0.17",
45
53
  "@storybook/react-vite": "9.0.17",
46
- "@tailwindcss/vite": "^4.1.3",
47
- "@types/react": "^19.2.7",
48
- "@types/react-dom": "^19.2.3",
49
- "react": "^19.1.1",
50
- "react-dom": "^19.1.1",
54
+ "@tailwindcss/vite": "catalog:",
55
+ "@types/react": "catalog:",
56
+ "@types/react-dom": "catalog:",
57
+ "react": "catalog:",
58
+ "react-dom": "catalog:",
59
+ "rimraf": "^6.1.2",
51
60
  "storybook": "^9.0.17",
52
- "tailwindcss": "^4.0.14",
61
+ "tailwindcss": "catalog:",
53
62
  "typescript": "5.9.2",
54
63
  "vitest": "^4.0.17"
55
- },
56
- "scripts": {
57
- "build": "tsc -p tsconfig.build.json && cp src/voice/recorder-processor.js lib/voice/recorder-processor.js",
58
- "npm:publish": "pnpm run build && npm publish --access public --registry https://registry.npmjs.org/",
59
- "test": "vitest run",
60
- "storybook": "storybook dev -p 6009",
61
- "build-storybook": "storybook build --output-dir dist"
62
64
  }
63
- }
65
+ }