gbs-add-block 2.1.0 → 2.3.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/.gbs/skills/gbs-components/SKILL.md +190 -134
- package/.gbs/skills/gbs-components/references/install.md +25 -3
- package/.gbs/skills/gbs-components/references/styling.md +246 -207
- package/CHANGELOG.md +74 -0
- package/README.md +154 -23
- package/index.cjs +212 -3
- package/package.json +41 -10
- package/schema/passport-v1.schema.json +204 -0
- package/source/beta-components/accordion/passport.json +259 -0
- package/source/beta-components/accordion/styles.css +207 -208
- package/source/beta-components/alert/passport.json +250 -0
- package/source/beta-components/alert/styles.css +154 -155
- package/source/beta-components/avatar/passport.json +294 -0
- package/source/beta-components/avatar/styles.css +225 -226
- package/source/beta-components/badge/passport.json +332 -0
- package/source/beta-components/badge/styles.css +203 -204
- package/source/beta-components/breadcrumb/passport.json +243 -0
- package/source/beta-components/breadcrumb/styles.css +138 -140
- package/source/beta-components/button/passport.json +402 -0
- package/source/beta-components/button/passport.manual.json +31 -0
- package/source/beta-components/button/styles.css +232 -234
- package/source/beta-components/card/passport.json +337 -0
- package/source/beta-components/card/styles.css +230 -232
- package/source/beta-components/checkbox/passport.json +456 -0
- package/source/beta-components/checkbox/styles.css +211 -213
- package/source/beta-components/combobox/passport.json +456 -0
- package/source/beta-components/combobox/styles.css +419 -417
- package/source/beta-components/data-grid/agent/coerce.ts +368 -0
- package/source/beta-components/data-grid/agent/contract.ts +410 -0
- package/source/beta-components/data-grid/agent/dataset.ts +92 -0
- package/source/beta-components/data-grid/agent/engine.ts +470 -0
- package/source/beta-components/data-grid/agent/executors.ts +155 -0
- package/source/beta-components/data-grid/agent/index.ts +79 -0
- package/source/beta-components/data-grid/agent/intent.ts +324 -0
- package/source/beta-components/data-grid/agent/operations.ts +335 -0
- package/source/beta-components/data-grid/agent/validate.ts +630 -0
- package/source/beta-components/data-grid/agent/webmcp.ts +107 -0
- package/source/beta-components/data-grid/index.ts +14 -7
- package/source/beta-components/data-grid/passport.json +1051 -0
- package/source/beta-components/data-grid/passport.manual.json +255 -0
- package/source/beta-components/data-grid/react/AskGrid.tsx +164 -0
- package/source/beta-components/data-grid/react/DataGrid.tsx +39 -0
- package/source/beta-components/data-grid/styles.css +874 -716
- package/source/beta-components/date-picker/passport.json +407 -0
- package/source/beta-components/date-picker/styles.css +445 -446
- package/source/beta-components/dialog/passport.json +344 -0
- package/source/beta-components/dialog/styles.css +280 -279
- package/source/beta-components/file-uploader/passport.json +518 -0
- package/source/beta-components/file-uploader/styles.css +394 -396
- package/source/beta-components/input/passport.json +536 -0
- package/source/beta-components/input/styles.css +295 -297
- package/source/beta-components/menu/passport.json +322 -0
- package/source/beta-components/menu/styles.css +224 -223
- package/source/beta-components/modal/passport.json +289 -0
- package/source/beta-components/modal/styles.css +241 -240
- package/source/beta-components/number-input/passport.json +541 -0
- package/source/beta-components/number-input/styles.css +230 -231
- package/source/beta-components/popover/passport.json +238 -0
- package/source/beta-components/popover/styles.css +148 -147
- package/source/beta-components/progress/passport.json +270 -0
- package/source/beta-components/progress/styles.css +200 -201
- package/source/beta-components/radio-group/passport.json +477 -0
- package/source/beta-components/radio-group/styles.css +269 -270
- package/source/beta-components/shared/core/agent/adapter.ts +65 -0
- package/source/beta-components/shared/core/agent/history.ts +120 -0
- package/source/beta-components/shared/core/agent/index.ts +46 -0
- package/source/beta-components/shared/core/agent/numbers.ts +217 -0
- package/source/beta-components/shared/core/agent/schema.ts +180 -0
- package/source/beta-components/shared/core/agent/types.ts +169 -0
- package/source/beta-components/shared/core/agent/webmcp.ts +328 -0
- package/source/beta-components/shared/index.ts +9 -0
- package/source/beta-components/shared/react/GramproAIProvider.tsx +50 -0
- package/source/beta-components/shared/react/useAskAgent.ts +217 -0
- package/source/beta-components/shared/styles.css +79 -0
- package/source/beta-components/shared/version.json +4 -4
- package/source/beta-components/shared/version.ts +6 -6
- package/source/beta-components/skeleton/passport.json +251 -0
- package/source/beta-components/skeleton/styles.css +185 -187
- package/source/beta-components/spinner/passport.json +245 -0
- package/source/beta-components/spinner/styles.css +173 -174
- package/source/beta-components/switch/passport.json +421 -0
- package/source/beta-components/switch/styles.css +227 -229
- package/source/beta-components/tabs/passport.json +315 -0
- package/source/beta-components/tabs/styles.css +263 -264
- package/source/beta-components/textarea/passport.json +382 -0
- package/source/beta-components/textarea/styles.css +158 -160
- package/source/beta-components/toaster/passport.json +221 -0
- package/source/beta-components/toaster/styles.css +282 -282
- package/source/beta-components/tooltip/passport.json +170 -0
- package/source/beta-components/tooltip/styles.css +71 -73
- package/tools/env.cjs +61 -0
- package/tools/passport/cli.cjs +79 -0
- package/tools/passport/extract.cjs +493 -0
- package/tools/passport/index.cjs +185 -0
- package/tools/passport/merge.cjs +131 -0
- package/tools/passport/policy.cjs +65 -0
- package/tools/passport/validate.cjs +277 -0
- package/tools/ts-require.cjs +79 -0
- package/source/beta-components/accordion/__tests__/core.test.ts +0 -58
- package/source/beta-components/alert/__tests__/core.test.ts +0 -17
- package/source/beta-components/avatar/__tests__/core.test.ts +0 -88
- package/source/beta-components/badge/__tests__/core.test.ts +0 -46
- package/source/beta-components/breadcrumb/__tests__/core.test.ts +0 -58
- package/source/beta-components/button/__tests__/core.test.ts +0 -31
- package/source/beta-components/card/__tests__/core.test.ts +0 -57
- package/source/beta-components/checkbox/__tests__/core.test.ts +0 -40
- package/source/beta-components/combobox/__tests__/core.test.ts +0 -134
- package/source/beta-components/data-grid/__tests__/core.test.ts +0 -356
- package/source/beta-components/data-grid/__tests__/export.test.ts +0 -70
- package/source/beta-components/data-grid/__tests__/pdf.test.ts +0 -209
- package/source/beta-components/date-picker/__tests__/core.test.ts +0 -273
- package/source/beta-components/dialog/__tests__/core.test.ts +0 -86
- package/source/beta-components/file-uploader/__tests__/core.test.ts +0 -395
- package/source/beta-components/input/__tests__/core.test.ts +0 -75
- package/source/beta-components/menu/__tests__/core.test.ts +0 -120
- package/source/beta-components/modal/__tests__/core.test.ts +0 -55
- package/source/beta-components/number-input/__tests__/core.test.ts +0 -151
- package/source/beta-components/progress/__tests__/core.test.ts +0 -56
- package/source/beta-components/radio-group/__tests__/core.test.ts +0 -64
- package/source/beta-components/shared/__tests__/boundaries.test.ts +0 -95
- package/source/beta-components/shared/__tests__/core.test.ts +0 -55
- package/source/beta-components/shared/__tests__/position.test.ts +0 -143
- package/source/beta-components/skeleton/__tests__/core.test.ts +0 -41
- package/source/beta-components/spinner/__tests__/core.test.ts +0 -48
- package/source/beta-components/switch/__tests__/core.test.ts +0 -64
- package/source/beta-components/tabs/__tests__/core.test.ts +0 -51
- package/source/beta-components/textarea/__tests__/core.test.ts +0 -38
- package/source/beta-components/toaster/__tests__/core.test.ts +0 -256
- package/source/beta-components/tooltip/__tests__/core.test.ts +0 -42
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The DataGrid's WebMCP tool.
|
|
3
|
+
*
|
|
4
|
+
* All of the mechanism lives in `shared/core/agent/webmcp`. What belongs here
|
|
5
|
+
* is only what is true of a grid: the tool's name, how to describe this grid
|
|
6
|
+
* to an agent in words, and which numbers a successful call should report.
|
|
7
|
+
*
|
|
8
|
+
* Framework-free, like the rest of `agent/` — no React import, so a host can
|
|
9
|
+
* register the tool from an effect, a router, or not at all.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
registerAgentTool,
|
|
14
|
+
type ModelContext,
|
|
15
|
+
type RegistrationResult,
|
|
16
|
+
type ToolCallLog,
|
|
17
|
+
} from "../../shared/core/agent/webmcp";
|
|
18
|
+
import type { GridAgent } from "./engine";
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Re-exported so a host that only imports from `data-grid` has every type that
|
|
22
|
+
* appears in this module's options and results.
|
|
23
|
+
*/
|
|
24
|
+
export type {
|
|
25
|
+
ModelContext,
|
|
26
|
+
RegistrationResult,
|
|
27
|
+
ToolCallLog,
|
|
28
|
+
ToolResultPayload,
|
|
29
|
+
} from "../../shared/core/agent/webmcp";
|
|
30
|
+
|
|
31
|
+
export const GRID_TOOL_NAME = "operate_grid";
|
|
32
|
+
|
|
33
|
+
export interface RegisterGridToolOptions {
|
|
34
|
+
/** Override the tool name when a page carries more than one grid. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Observe every call, for a UI log or a test. */
|
|
37
|
+
onCall?: (entry: ToolCallLog) => void;
|
|
38
|
+
/** Where to register. Defaults to `document.modelContext`. */
|
|
39
|
+
modelContext?: ModelContext;
|
|
40
|
+
/** How many operations an agent may send in one call. Default 8. */
|
|
41
|
+
maxIntents?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* How the grid introduces itself to an agent.
|
|
46
|
+
*
|
|
47
|
+
* Built from the live contract rather than written once, so a grid with
|
|
48
|
+
* different columns advertises different columns. Policy-restricted fields are
|
|
49
|
+
* absent from the generated schema entirely, so they are not listed here
|
|
50
|
+
* either — an agent should not be told about a column it cannot address.
|
|
51
|
+
*/
|
|
52
|
+
function describeGrid(agent: GridAgent<unknown>): string {
|
|
53
|
+
const contract = agent.contract();
|
|
54
|
+
const columns = contract.columns
|
|
55
|
+
.filter((column) => column.filterable || column.sortable)
|
|
56
|
+
.map((column) => column.id)
|
|
57
|
+
.join(", ");
|
|
58
|
+
|
|
59
|
+
return [
|
|
60
|
+
"Filter, sort, search, paginate, select rows in, or export the data grid on this page.",
|
|
61
|
+
`Columns: ${columns}.`,
|
|
62
|
+
`Operations: ${contract.operations.join(", ")}.`,
|
|
63
|
+
'Values may be written as a person would — "1 lakh", "20%", "last month" — and are',
|
|
64
|
+
"converted exactly. Every call is validated before anything happens; an invalid request",
|
|
65
|
+
"is refused with a reason rather than approximated.",
|
|
66
|
+
].join(" ");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Registers `operate_grid` against the browser's WebMCP surface.
|
|
71
|
+
*
|
|
72
|
+
* Returns rather than throws when WebMCP is absent, because that is the normal
|
|
73
|
+
* case in most browsers today: the caller shows the grid regardless and the
|
|
74
|
+
* agent affordance is simply not there.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const agent = createGridAgent({ api: apiRef.current, options });
|
|
78
|
+
* const result = registerGridTool(agent);
|
|
79
|
+
* if (!result.registered) console.info(result.reason);
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* One tool per page: WebMCP throws on a duplicate name, and React's
|
|
83
|
+
* StrictMode runs effects twice in development, so guard the call with a ref
|
|
84
|
+
* or register outside the render path.
|
|
85
|
+
*/
|
|
86
|
+
export function registerGridTool(
|
|
87
|
+
agent: GridAgent<unknown>,
|
|
88
|
+
options: RegisterGridToolOptions = {},
|
|
89
|
+
): RegistrationResult {
|
|
90
|
+
return registerAgentTool(agent, {
|
|
91
|
+
name: options.name ?? GRID_TOOL_NAME,
|
|
92
|
+
describe: describeGrid,
|
|
93
|
+
maxIntents: options.maxIntents,
|
|
94
|
+
intentsDescription:
|
|
95
|
+
"Operations to apply in order. Several filters on different columns combine with AND.",
|
|
96
|
+
summarise: (current) => {
|
|
97
|
+
const contract = current.contract();
|
|
98
|
+
return {
|
|
99
|
+
rowsShowing: contract.stats.filteredRows,
|
|
100
|
+
rowsTotal: contract.stats.totalRows,
|
|
101
|
+
canUndo: contract.state.canUndo,
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
onCall: options.onCall,
|
|
105
|
+
modelContext: options.modelContext,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export { DataGrid } from "./react/DataGrid";
|
|
2
|
-
export type { DataGridProps } from "./react/DataGrid";
|
|
3
|
-
export type { GridSlot } from "./react/context";
|
|
4
|
-
export type { ToolbarOptions } from "./react/Toolbar";
|
|
5
|
-
export { defaultLocaleText } from "./react/locale";
|
|
6
|
-
export type { LocaleText } from "./react/locale";
|
|
7
|
-
export * from "./core";
|
|
1
|
+
export { DataGrid } from "./react/DataGrid";
|
|
2
|
+
export type { DataGridProps } from "./react/DataGrid";
|
|
3
|
+
export type { GridSlot } from "./react/context";
|
|
4
|
+
export type { ToolbarOptions } from "./react/Toolbar";
|
|
5
|
+
export { defaultLocaleText } from "./react/locale";
|
|
6
|
+
export type { LocaleText } from "./react/locale";
|
|
7
|
+
export * from "./core";
|
|
8
|
+
|
|
9
|
+
// Agent runtime: runtime contract, intent schema, validator, executors,
|
|
10
|
+
// snapshot history. Framework-free and opt-in — importing the grid does not
|
|
11
|
+
// pull it in.
|
|
12
|
+
export * from "./agent";
|
|
13
|
+
|
|
14
|
+
export { AskGrid, type AskGridProps } from "./react/AskGrid";
|