@absolutejs/ai 0.0.32 → 0.0.34
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/ai/index.js +54 -2
- package/dist/ai/index.js.map +3 -3
- package/dist/ai/ui/index.js +604 -0
- package/dist/ai/ui/index.js.map +12 -0
- package/dist/src/ai/ui/catalog.d.ts +25 -0
- package/dist/src/ai/ui/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -3685,10 +3685,13 @@ var CHART_MAX_POINTS = 24;
|
|
|
3685
3685
|
var TABLE_MAX_COLUMNS = 8;
|
|
3686
3686
|
var TABLE_MAX_ROWS = 30;
|
|
3687
3687
|
var STAT_TILES_MAX = 6;
|
|
3688
|
+
var UI_ACTIONS_MAX = 3;
|
|
3688
3689
|
var LABEL_MAX_CHARS = 80;
|
|
3689
3690
|
var TITLE_MAX_CHARS = 120;
|
|
3690
3691
|
var CELL_MAX_CHARS = 160;
|
|
3691
3692
|
var UNIT_MAX_CHARS = 8;
|
|
3693
|
+
var ACTION_LABEL_MAX_CHARS = 40;
|
|
3694
|
+
var ACTION_TOOL_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;
|
|
3692
3695
|
var isRecord6 = (value) => typeof value === "object" && value !== null;
|
|
3693
3696
|
var cleanString = (value, maxChars) => typeof value === "string" && value.trim().length > 0 ? value.trim().slice(0, maxChars) : null;
|
|
3694
3697
|
var cleanStringArray = (value, maxItems, maxChars) => {
|
|
@@ -3712,6 +3715,40 @@ var cleanNumberArray = (value, maxItems) => {
|
|
|
3712
3715
|
}
|
|
3713
3716
|
return cleaned;
|
|
3714
3717
|
};
|
|
3718
|
+
var parseUiActions = (value) => {
|
|
3719
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
3720
|
+
return;
|
|
3721
|
+
const actions = [];
|
|
3722
|
+
for (const raw of value.slice(0, UI_ACTIONS_MAX)) {
|
|
3723
|
+
if (!isRecord6(raw))
|
|
3724
|
+
continue;
|
|
3725
|
+
const label = cleanString(raw.label, ACTION_LABEL_MAX_CHARS);
|
|
3726
|
+
const tool = typeof raw.tool === "string" && ACTION_TOOL_PATTERN.test(raw.tool) ? raw.tool : null;
|
|
3727
|
+
if (!label || !tool || !isRecord6(raw.input))
|
|
3728
|
+
continue;
|
|
3729
|
+
actions.push({ input: raw.input, label, tool });
|
|
3730
|
+
}
|
|
3731
|
+
return actions.length > 0 ? actions : undefined;
|
|
3732
|
+
};
|
|
3733
|
+
var ACTIONS_SCHEMA = {
|
|
3734
|
+
description: "Optional action buttons under the card (max 3): each invokes one of YOUR tools with a fully-resolved input when the member clicks it. Use real ids you looked up \u2014 never placeholders. Approval-gated tools queue their normal approval card.",
|
|
3735
|
+
items: {
|
|
3736
|
+
properties: {
|
|
3737
|
+
input: {
|
|
3738
|
+
description: "The exact tool input to send on click",
|
|
3739
|
+
type: "object"
|
|
3740
|
+
},
|
|
3741
|
+
label: {
|
|
3742
|
+
description: 'Short button label, e.g. "Create follow-up task"',
|
|
3743
|
+
type: "string"
|
|
3744
|
+
},
|
|
3745
|
+
tool: { description: "The tool name to invoke", type: "string" }
|
|
3746
|
+
},
|
|
3747
|
+
required: ["label", "tool", "input"],
|
|
3748
|
+
type: "object"
|
|
3749
|
+
},
|
|
3750
|
+
type: "array"
|
|
3751
|
+
};
|
|
3715
3752
|
var parseChartSpec = (input) => {
|
|
3716
3753
|
if (!isRecord6(input))
|
|
3717
3754
|
return null;
|
|
@@ -3748,6 +3785,9 @@ var parseChartSpec = (input) => {
|
|
|
3748
3785
|
spec.unitPrefix = unitPrefix;
|
|
3749
3786
|
if (unitSuffix)
|
|
3750
3787
|
spec.unitSuffix = unitSuffix;
|
|
3788
|
+
const actions = parseUiActions(input.actions);
|
|
3789
|
+
if (actions)
|
|
3790
|
+
spec.actions = actions;
|
|
3751
3791
|
return spec;
|
|
3752
3792
|
};
|
|
3753
3793
|
var parseTableSpec = (input) => {
|
|
@@ -3771,6 +3811,9 @@ var parseTableSpec = (input) => {
|
|
|
3771
3811
|
const title = cleanString(input.title, TITLE_MAX_CHARS);
|
|
3772
3812
|
if (title)
|
|
3773
3813
|
spec.title = title;
|
|
3814
|
+
const actions = parseUiActions(input.actions);
|
|
3815
|
+
if (actions)
|
|
3816
|
+
spec.actions = actions;
|
|
3774
3817
|
return spec;
|
|
3775
3818
|
};
|
|
3776
3819
|
var parseStatTilesSpec = (input) => {
|
|
@@ -3795,7 +3838,11 @@ var parseStatTilesSpec = (input) => {
|
|
|
3795
3838
|
}
|
|
3796
3839
|
tiles.push(tile);
|
|
3797
3840
|
}
|
|
3798
|
-
|
|
3841
|
+
const spec = { tiles };
|
|
3842
|
+
const actions = parseUiActions(input.actions);
|
|
3843
|
+
if (actions)
|
|
3844
|
+
spec.actions = actions;
|
|
3845
|
+
return spec;
|
|
3799
3846
|
};
|
|
3800
3847
|
var SERIES_SCHEMA = {
|
|
3801
3848
|
properties: {
|
|
@@ -3814,6 +3861,7 @@ var chartCard = {
|
|
|
3814
3861
|
description: "Render a real chart inline in the chat from data you have (tool results, the conversation). Use whenever numbers COMPARE or TREND: revenue by partner (bar), pipeline over time (line), share of a whole (donut). Rules: bar/line take up to 8 series aligned to the same labels; donut takes exactly ONE series of non-negative values (one slice per label). Prefer a chart over a wall of numbers, but never invent data for it.",
|
|
3815
3862
|
inputSchema: {
|
|
3816
3863
|
properties: {
|
|
3864
|
+
actions: ACTIONS_SCHEMA,
|
|
3817
3865
|
labels: {
|
|
3818
3866
|
description: "Category labels \u2014 x-axis for bar/line, slice names for donut (max 24)",
|
|
3819
3867
|
items: { type: "string" },
|
|
@@ -3846,6 +3894,7 @@ var tableCard = {
|
|
|
3846
3894
|
description: "Render a compact data table inline in the chat (max 8 columns \xD7 30 rows). Use for structured comparisons the member will scan \u2014 matches side by side, deal terms, task lists with dates. All cells are strings; format numbers yourself.",
|
|
3847
3895
|
inputSchema: {
|
|
3848
3896
|
properties: {
|
|
3897
|
+
actions: ACTIONS_SCHEMA,
|
|
3849
3898
|
columns: {
|
|
3850
3899
|
description: "Column headers (max 8)",
|
|
3851
3900
|
items: { type: "string" },
|
|
@@ -3869,6 +3918,7 @@ var statTilesCard = {
|
|
|
3869
3918
|
description: "Render a row of headline stat tiles inline in the chat (max 6): a label, a big value, and an optional delta with direction. Use for the 2-4 numbers that ARE the answer \u2014 total attributed revenue, pipeline value, credits remaining \u2014 instead of burying them in prose.",
|
|
3870
3919
|
inputSchema: {
|
|
3871
3920
|
properties: {
|
|
3921
|
+
actions: ACTIONS_SCHEMA,
|
|
3872
3922
|
tiles: {
|
|
3873
3923
|
description: "The tiles (max 6)",
|
|
3874
3924
|
items: {
|
|
@@ -5046,6 +5096,7 @@ export {
|
|
|
5046
5096
|
resolveRenderers,
|
|
5047
5097
|
renderChartSvg,
|
|
5048
5098
|
providerStatusPage,
|
|
5099
|
+
parseUiActions,
|
|
5049
5100
|
parseTableSpec,
|
|
5050
5101
|
parseStatTilesSpec,
|
|
5051
5102
|
parseChartSpec,
|
|
@@ -5078,6 +5129,7 @@ export {
|
|
|
5078
5129
|
anthropic,
|
|
5079
5130
|
alibaba,
|
|
5080
5131
|
aiChat,
|
|
5132
|
+
UI_ACTIONS_MAX,
|
|
5081
5133
|
TABLE_MAX_ROWS,
|
|
5082
5134
|
TABLE_MAX_COLUMNS,
|
|
5083
5135
|
STAT_TILES_MAX,
|
|
@@ -5091,5 +5143,5 @@ export {
|
|
|
5091
5143
|
BUILTIN_UI_CARDS
|
|
5092
5144
|
};
|
|
5093
5145
|
|
|
5094
|
-
//# debugId=
|
|
5146
|
+
//# debugId=0E766AE845A0759F64756E2164756E21
|
|
5095
5147
|
//# sourceMappingURL=index.js.map
|