@devicai/ui 0.7.1 → 0.9.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 (37) hide show
  1. package/dist/cjs/api/types.js.map +1 -1
  2. package/dist/cjs/components/AICommandBar/AICommandBar.js +46 -10
  3. package/dist/cjs/components/AICommandBar/AICommandBar.js.map +1 -1
  4. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js +41 -10
  5. package/dist/cjs/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  6. package/dist/cjs/components/ChatDrawer/ChatDrawer.js +2 -1
  7. package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
  8. package/dist/cjs/components/ChatDrawer/ChatMessages.js +58 -8
  9. package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
  10. package/dist/cjs/index.js +2 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/utils/index.js.map +1 -1
  13. package/dist/cjs/utils/toolGroups.js +47 -0
  14. package/dist/cjs/utils/toolGroups.js.map +1 -0
  15. package/dist/esm/api/types.d.ts +17 -0
  16. package/dist/esm/api/types.js.map +1 -1
  17. package/dist/esm/components/AICommandBar/AICommandBar.js +46 -10
  18. package/dist/esm/components/AICommandBar/AICommandBar.js.map +1 -1
  19. package/dist/esm/components/AICommandBar/AICommandBar.types.d.ts +5 -1
  20. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js +41 -10
  21. package/dist/esm/components/AIGenerationButton/AIGenerationButton.js.map +1 -1
  22. package/dist/esm/components/AIGenerationButton/AIGenerationButton.types.d.ts +5 -1
  23. package/dist/esm/components/ChatDrawer/ChatDrawer.js +2 -1
  24. package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
  25. package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +9 -1
  26. package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
  27. package/dist/esm/components/ChatDrawer/ChatMessages.js +58 -8
  28. package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
  29. package/dist/esm/index.d.ts +3 -2
  30. package/dist/esm/index.js +1 -0
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/utils/index.d.ts +2 -0
  33. package/dist/esm/utils/index.js.map +1 -1
  34. package/dist/esm/utils/toolGroups.d.ts +18 -0
  35. package/dist/esm/utils/toolGroups.js +45 -0
  36. package/dist/esm/utils/toolGroups.js.map +1 -0
  37. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Partition an array of tool calls into grouped and ungrouped sub-sequences
3
+ * based on the provided toolGroups configuration.
4
+ *
5
+ * Consecutive calls matching the same ToolGroupConfig are accumulated into a single group segment.
6
+ * When a call doesn't match any config, or matches a different config, the current group is flushed.
7
+ */
8
+ function segmentToolCalls(calls, toolGroups) {
9
+ const segments = [];
10
+ let currentConfig = null;
11
+ let currentGroup = [];
12
+ const flush = () => {
13
+ if (currentGroup.length > 0 && currentConfig) {
14
+ segments.push({ type: 'group', config: currentConfig, calls: currentGroup });
15
+ currentGroup = [];
16
+ currentConfig = null;
17
+ }
18
+ };
19
+ for (let i = 0; i < calls.length; i++) {
20
+ const call = calls[i];
21
+ const matchingConfig = toolGroups.find((g) => g.tools.includes(call.name));
22
+ if (matchingConfig) {
23
+ if (currentConfig === matchingConfig) {
24
+ // Same group, accumulate
25
+ currentGroup.push(call);
26
+ }
27
+ else {
28
+ // Different group or starting a new one
29
+ flush();
30
+ currentConfig = matchingConfig;
31
+ currentGroup = [call];
32
+ }
33
+ }
34
+ else {
35
+ // No matching config — flush any pending group, emit as single
36
+ flush();
37
+ segments.push({ type: 'single', call, index: i });
38
+ }
39
+ }
40
+ flush();
41
+ return segments;
42
+ }
43
+
44
+ export { segmentToolCalls };
45
+ //# sourceMappingURL=toolGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolGroups.js","sources":["../../../src/utils/toolGroups.ts"],"sourcesContent":["import type { ToolGroupCall, ToolGroupConfig } from '../api/types';\n\nexport type ToolGroupSegment =\n | { type: 'group'; config: ToolGroupConfig; calls: ToolGroupCall[] }\n | { type: 'single'; call: ToolGroupCall; index: number };\n\n/**\n * Partition an array of tool calls into grouped and ungrouped sub-sequences\n * based on the provided toolGroups configuration.\n *\n * Consecutive calls matching the same ToolGroupConfig are accumulated into a single group segment.\n * When a call doesn't match any config, or matches a different config, the current group is flushed.\n */\nexport function segmentToolCalls(\n calls: ToolGroupCall[],\n toolGroups: ToolGroupConfig[],\n): ToolGroupSegment[] {\n const segments: ToolGroupSegment[] = [];\n let currentConfig: ToolGroupConfig | null = null;\n let currentGroup: ToolGroupCall[] = [];\n\n const flush = () => {\n if (currentGroup.length > 0 && currentConfig) {\n segments.push({ type: 'group', config: currentConfig, calls: currentGroup });\n currentGroup = [];\n currentConfig = null;\n }\n };\n\n for (let i = 0; i < calls.length; i++) {\n const call = calls[i];\n const matchingConfig = toolGroups.find((g) => g.tools.includes(call.name));\n\n if (matchingConfig) {\n if (currentConfig === matchingConfig) {\n // Same group, accumulate\n currentGroup.push(call);\n } else {\n // Different group or starting a new one\n flush();\n currentConfig = matchingConfig;\n currentGroup = [call];\n }\n } else {\n // No matching config — flush any pending group, emit as single\n flush();\n segments.push({ type: 'single', call, index: i });\n }\n }\n\n flush();\n\n return segments;\n}\n"],"names":[],"mappings":"AAMA;;;;;;AAMG;AACG,SAAU,gBAAgB,CAC9B,KAAsB,EACtB,UAA6B,EAAA;IAE7B,MAAM,QAAQ,GAAuB,EAAE;IACvC,IAAI,aAAa,GAA2B,IAAI;IAChD,IAAI,YAAY,GAAoB,EAAE;IAEtC,MAAM,KAAK,GAAG,MAAK;QACjB,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa,EAAE;AAC5C,YAAA,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;YAC5E,YAAY,GAAG,EAAE;YACjB,aAAa,GAAG,IAAI;QACtB;AACF,IAAA,CAAC;AAED,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACrC,QAAA,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;QACrB,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1E,IAAI,cAAc,EAAE;AAClB,YAAA,IAAI,aAAa,KAAK,cAAc,EAAE;;AAEpC,gBAAA,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACzB;iBAAO;;AAEL,gBAAA,KAAK,EAAE;gBACP,aAAa,GAAG,cAAc;AAC9B,gBAAA,YAAY,GAAG,CAAC,IAAI,CAAC;YACvB;QACF;aAAO;;AAEL,YAAA,KAAK,EAAE;AACP,YAAA,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACnD;IACF;AAEA,IAAA,KAAK,EAAE;AAEP,IAAA,OAAO,QAAQ;AACjB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devicai/ui",
3
- "version": "0.7.1",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "React component library for Devic AI assistants",
6
6
  "engines": {