@gram-ai/elements 1.28.0 → 1.30.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.
- package/dist/components/MessageContent.d.ts +20 -0
- package/dist/components/MessageContent.parser.d.ts +12 -0
- package/dist/components/MessageContent.test.d.ts +1 -0
- package/dist/elements.cjs +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +14 -13
- package/dist/{index-C4bFBGfl.cjs → index-COzPF-WM.cjs} +45 -45
- package/dist/index-COzPF-WM.cjs.map +1 -0
- package/dist/{index-D93pV0_o.js → index-CRhpKl-G.js} +5218 -5201
- package/dist/index-CRhpKl-G.js.map +1 -0
- package/dist/{index-CtZz13Cf.js → index-QUz5guSg.js} +11835 -11604
- package/dist/index-QUz5guSg.js.map +1 -0
- package/dist/index-fVcTljYT.cjs +194 -0
- package/dist/index-fVcTljYT.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/lib/contextCompaction.d.ts +58 -0
- package/dist/lib/contextCompaction.test.d.ts +1 -0
- package/dist/lib/errorTracking.config.d.ts +2 -0
- package/dist/lib/tools.byte-cap.test.d.ts +1 -0
- package/dist/lib/tools.d.ts +19 -0
- package/dist/lib/tools.test.d.ts +1 -0
- package/dist/plugins/index.d.ts +4 -1
- package/dist/plugins/index.test.d.ts +1 -0
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/{profiler-Ccma0l1p.js → profiler-DifNjGGB.js} +2 -2
- package/dist/{profiler-Ccma0l1p.js.map → profiler-DifNjGGB.js.map} +1 -1
- package/dist/{profiler-CjNa3A1d.cjs → profiler-KLtVMM14.cjs} +2 -2
- package/dist/{profiler-CjNa3A1d.cjs.map → profiler-KLtVMM14.cjs.map} +1 -1
- package/dist/{startRecording-DAURU74n.js → startRecording-C6xu9UA9.js} +2 -2
- package/dist/{startRecording-DAURU74n.js.map → startRecording-C6xu9UA9.js.map} +1 -1
- package/dist/{startRecording-jSovclaq.cjs → startRecording-YENzw_0G.cjs} +2 -2
- package/dist/{startRecording-jSovclaq.cjs.map → startRecording-YENzw_0G.cjs.map} +1 -1
- package/dist/types/index.d.ts +49 -0
- package/dist/types/plugins.d.ts +5 -0
- package/package.json +2 -2
- package/src/components/MessageContent.parser.ts +39 -0
- package/src/components/MessageContent.test.ts +110 -0
- package/src/components/MessageContent.tsx +82 -0
- package/src/contexts/ElementsProvider.tsx +57 -7
- package/src/index.ts +2 -0
- package/src/lib/contextCompaction.test.ts +201 -0
- package/src/lib/contextCompaction.ts +211 -0
- package/src/lib/errorTracking.config.ts +2 -0
- package/src/lib/errorTracking.ts +1 -1
- package/src/lib/tools.byte-cap.test.ts +132 -0
- package/src/lib/tools.test.ts +259 -0
- package/src/lib/tools.ts +122 -0
- package/src/plugins/chart/index.ts +1 -0
- package/src/plugins/chart/ui/bar-chart.tsx +9 -1
- package/src/plugins/generative-ui/index.ts +1 -0
- package/src/plugins/index.test.ts +62 -0
- package/src/plugins/index.ts +14 -1
- package/src/types/index.ts +55 -0
- package/src/types/plugins.ts +6 -0
- package/dist/index-BmTGnEaV.cjs +0 -190
- package/dist/index-BmTGnEaV.cjs.map +0 -1
- package/dist/index-C4bFBGfl.cjs.map +0 -1
- package/dist/index-CtZz13Cf.js.map +0 -1
- package/dist/index-D93pV0_o.js.map +0 -1
package/src/types/index.ts
CHANGED
|
@@ -268,6 +268,13 @@ export interface ElementsConfig {
|
|
|
268
268
|
*/
|
|
269
269
|
tools?: ToolsConfig;
|
|
270
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Configuration for automatic conversation compaction when the estimated
|
|
273
|
+
* input size approaches the model's context window. Defaults are safe for
|
|
274
|
+
* all models; override per-page to tighten or disable.
|
|
275
|
+
*/
|
|
276
|
+
contextCompaction?: ContextCompactionConfig;
|
|
277
|
+
|
|
271
278
|
/**
|
|
272
279
|
* Configuration for chat history and thread persistence.
|
|
273
280
|
* When enabled, conversations are saved and the thread list is shown.
|
|
@@ -690,6 +697,54 @@ export interface ToolsConfig {
|
|
|
690
697
|
* }
|
|
691
698
|
*/
|
|
692
699
|
toolsToInclude?: ToolsFilter;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Maximum UTF-8 byte size for any single tool call's result. Results larger
|
|
703
|
+
* than this are truncated with a head+tail preserving strategy and a notice
|
|
704
|
+
* suffix before being added to the conversation. Prevents one greedy tool
|
|
705
|
+
* call (e.g. a wide log search) from filling the model's context window.
|
|
706
|
+
*
|
|
707
|
+
* Omit or set to 0 to disable.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* tools: {
|
|
711
|
+
* maxOutputBytes: 50_000, // ~12.5K tokens per tool call
|
|
712
|
+
* }
|
|
713
|
+
*/
|
|
714
|
+
maxOutputBytes?: number;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Configuration for automatic compaction of older conversation turns when the
|
|
719
|
+
* estimated input size approaches the model's context window. Prevents
|
|
720
|
+
* upstream 400 "prompt too long" errors without losing the system prompt or
|
|
721
|
+
* the most recent turns.
|
|
722
|
+
*/
|
|
723
|
+
export interface ContextCompactionConfig {
|
|
724
|
+
/**
|
|
725
|
+
* Hard ceiling (in tokens) for the outbound request. Overrides the built-in
|
|
726
|
+
* per-model map. Use this when you know your upstream provider enforces a
|
|
727
|
+
* smaller limit than the model's nominal maximum.
|
|
728
|
+
*/
|
|
729
|
+
maxTokens?: number;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Fraction of the model ceiling at which compaction kicks in. Defaults to
|
|
733
|
+
* 0.7 — leaves room for the assistant's response and some slack for the
|
|
734
|
+
* chars/4 token heuristic's error.
|
|
735
|
+
*/
|
|
736
|
+
compactAtFraction?: number;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Number of most-recent messages preserved verbatim during compaction.
|
|
740
|
+
* Defaults to 4 (covers the current turn + its immediate predecessor).
|
|
741
|
+
*/
|
|
742
|
+
keepRecent?: number;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Disable compaction entirely. Useful in tests and for opting out per-page.
|
|
746
|
+
*/
|
|
747
|
+
disabled?: boolean;
|
|
693
748
|
}
|
|
694
749
|
|
|
695
750
|
export interface WelcomeConfig {
|
package/src/types/plugins.ts
CHANGED
|
@@ -15,6 +15,12 @@ import { ComponentType } from "react";
|
|
|
15
15
|
* 3. The code fence is rendered using the custom renderer
|
|
16
16
|
*/
|
|
17
17
|
export interface Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* Unique identifier for the plugin. Used by `recommended.except()` to
|
|
20
|
+
* selectively exclude plugins. Defaults to `language` if not set.
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* Any prompt that the plugin may need to add to the system prompt.
|
|
20
26
|
* Will be appended to the built-in system prompt.
|