@mastra/mcp-apps-components 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
@@ -0,0 +1,183 @@
1
+ import { DASHBOARD_SCHEMA_VERSION } from '@mastra/core/storage/dashboards';
2
+ import type { DashboardDefaults, DashboardDefinition, DashboardQuery, DashboardWidget } from '@mastra/core/storage/dashboards';
3
+ import { z } from 'zod/v4';
4
+ import type { ObservabilityDatePreset } from './apps/observability-widget/tool.js';
5
+ /** What the project records, so the input schema can list it rather than leave it to a guess. */
6
+ export type ObservabilityCatalog = {
7
+ /** The metric names with data, as `MastraClient#getMetricNames` lists them. */
8
+ metricNames?: readonly string[];
9
+ };
10
+ /** Past this many, metric names stay free strings: a longer list costs more than it guides. */
11
+ export declare const OBSERVABILITY_CATALOG_MAX_METRIC_NAMES = 200;
12
+ type Draft = Record<string, unknown>;
13
+ /** One object per case, holding only that case's key. */
14
+ type OneKeyOf<T> = {
15
+ [K in keyof T]: {
16
+ [P in K]: T[P];
17
+ };
18
+ }[keyof T];
19
+ type Args<Q, Omitted extends PropertyKey = never> = Omit<Q, 'source' | 'request' | 'id' | 'interval' | Omitted>;
20
+ type MetricQuery<R> = Extract<DashboardQuery, {
21
+ source: 'metrics';
22
+ request: R;
23
+ }>;
24
+ type ScoreQuery<R> = Extract<DashboardQuery, {
25
+ source: 'scores';
26
+ request: R;
27
+ }>;
28
+ type TraceQuery = Extract<DashboardQuery, {
29
+ source: 'traceAggregate';
30
+ }>;
31
+ type SpanQuery = Extract<DashboardQuery, {
32
+ source: 'spanAggregate';
33
+ }>;
34
+ type Field = {
35
+ field?: 'value' | 'estimatedCost';
36
+ };
37
+ type Groups = {
38
+ groups?: string[];
39
+ notGroups?: string[];
40
+ };
41
+ type TraceArgs<Q extends {
42
+ measures: unknown[];
43
+ }> = Args<Q, 'measures' | 'having' | 'orderBy'> & {
44
+ measure?: Q['measures'][number];
45
+ } & Groups;
46
+ /** Each read's arguments, with what picks the number out of its answer. */
47
+ export type ObservabilityReads = {
48
+ traceAggregate: TraceArgs<TraceQuery>;
49
+ spanAggregate: TraceArgs<SpanQuery>;
50
+ metricAggregate: Args<MetricQuery<'aggregate'>> & Field;
51
+ metricBreakdown: Args<MetricQuery<'breakdown'>, 'groupBy'> & {
52
+ groupBy?: string[];
53
+ } & Field;
54
+ metricTimeSeries: Args<MetricQuery<'timeSeries'>> & Field & Groups;
55
+ metricPercentiles: Args<MetricQuery<'percentiles'>, 'percentiles'> & {
56
+ percentile: number;
57
+ };
58
+ };
59
+ /** One read, named by its key, e.g. `{ metricAggregate: { name: [...], aggregation: 'count' } }`. */
60
+ export type ObservabilityRead = OneKeyOf<ObservabilityReads>;
61
+ /** A number a view shows: a read, or an operator over values. */
62
+ export type ObservabilityValue = ObservabilityRead | {
63
+ const: number;
64
+ } | {
65
+ sum: ObservabilityValue[];
66
+ } | {
67
+ minus: [ObservabilityValue, ObservabilityValue];
68
+ } | {
69
+ ratio: {
70
+ of: ObservabilityValue;
71
+ over: ObservabilityValue;
72
+ };
73
+ } | {
74
+ max: ObservabilityValue[];
75
+ } | {
76
+ coalesce: ObservabilityValue[];
77
+ };
78
+ type ViewDraft = {
79
+ label?: string;
80
+ description?: string;
81
+ } & Draft;
82
+ export type ObservabilityKpisDraft = ViewDraft & {
83
+ items: (Draft & {
84
+ value: ObservabilityValue;
85
+ })[];
86
+ };
87
+ export type ObservabilityTimeseriesDraft = ViewDraft & {
88
+ series: (Draft & {
89
+ value: ObservabilityValue;
90
+ rangeTotal?: ObservabilityValue;
91
+ emphasis?: boolean;
92
+ })[];
93
+ total?: {
94
+ value: 'total' | 'peak' | ObservabilityValue;
95
+ format?: string;
96
+ };
97
+ emptyWhenZero?: ObservabilityValue;
98
+ };
99
+ /**
100
+ * A table column, its type named by the key holding its options. A value column's options sit
101
+ * beside its number, e.g. `{ value: { format: 'count', traceAggregate: { measure: 'count' } } }`.
102
+ */
103
+ export type ObservabilityColumnDraft = {
104
+ id?: string;
105
+ label?: string;
106
+ sort?: 'asc' | 'desc';
107
+ } & OneKeyOf<{
108
+ name: Draft;
109
+ dimension: Draft & {
110
+ dimension: string;
111
+ };
112
+ value: Draft & ObservabilityValue & {
113
+ unpricedWhen?: string;
114
+ };
115
+ change: Draft;
116
+ }>;
117
+ export type ObservabilityTableDraft = ViewDraft & {
118
+ groupBy: string[];
119
+ columns: ObservabilityColumnDraft[];
120
+ };
121
+ export type ObservabilityScoresDraft = ViewDraft & Pick<ScoreQuery<'aggregate'>, 'scorerId' | 'scoreSource'> & {
122
+ average: Args<ScoreQuery<'aggregate'>, 'scorerId' | 'scoreSource'>;
123
+ series: Args<ScoreQuery<'timeSeries'>, 'scorerId' | 'scoreSource'>;
124
+ };
125
+ type WithTabs<V> = V & {
126
+ tabs?: V[];
127
+ };
128
+ /**
129
+ * A dashboard widget as the model writes it: its kind is the key holding its view, e.g.
130
+ * `{ span: 6, timeseries: { chart, format, series } }`. Left out, the server assigns the `id` and the
131
+ * widget spans the full row.
132
+ */
133
+ export type ObservabilityWidgetDraft = Omit<DashboardWidget, 'id' | 'span' | 'kind' | 'views' | 'scope' | 'drilldown'> & {
134
+ id?: string;
135
+ span?: DashboardWidget['span'];
136
+ } & OneKeyOf<{
137
+ kpis: WithTabs<ObservabilityKpisDraft>;
138
+ timeseries: WithTabs<ObservabilityTimeseriesDraft>;
139
+ table: WithTabs<ObservabilityTableDraft>;
140
+ scores: WithTabs<ObservabilityScoresDraft>;
141
+ }>;
142
+ /** A dashboard definition as the model writes it. */
143
+ export type ObservabilityDashboardDraft = {
144
+ schemaVersion?: typeof DASHBOARD_SCHEMA_VERSION;
145
+ defaults?: DashboardDefaults;
146
+ rows: {
147
+ widgets: ObservabilityWidgetDraft[];
148
+ }[];
149
+ };
150
+ /** The opening tool's input: the dashboard to draw and the window to draw it over. */
151
+ export type ObservabilityDashboardInput = {
152
+ dashboard: ObservabilityDashboardDraft;
153
+ /** Left out, the dashboard's `defaults.datePreset` when it is one of these, else `24h`. */
154
+ datePreset?: ObservabilityDatePreset;
155
+ };
156
+ /**
157
+ * The opening tool's input schema, with metric names limited to `catalog.metricNames`, so the
158
+ * model can only name metrics that have data. With no names, or more than
159
+ * `OBSERVABILITY_CATALOG_MAX_METRIC_NAMES`, metric names stay free strings. Build it again when the
160
+ * catalog changes: the schema is a snapshot.
161
+ */
162
+ export declare function createObservabilityDashboardInputSchema(catalog?: ObservabilityCatalog): z.ZodType<ObservabilityDashboardInput>;
163
+ /**
164
+ * The opening tool's input schema. It spells out each built-in kind's options and checks them as
165
+ * the widget's renderer does, so a model writing the dashboard sees them and gets actionable errors.
166
+ * Metric names are free strings; `createObservabilityDashboardInputSchema` lists the project's.
167
+ */
168
+ export declare const observabilityDashboardInputSchema: z.ZodType<ObservabilityDashboardInput, unknown, z.core.$ZodTypeInternals<ObservabilityDashboardInput, unknown>>;
169
+ /** The opening tool's output schema, which the app reads as `structuredContent`. */
170
+ export declare const observabilityDashboardOutputSchema: z.ZodType<ObservabilityDashboardOpened>;
171
+ export type ObservabilityDashboardOpened = {
172
+ dashboard: DashboardDefinition;
173
+ datePreset?: ObservabilityDatePreset;
174
+ };
175
+ /**
176
+ * The stored definition for `input`: each value's reads gathered into the view's queries, and every
177
+ * widget without an id given a fresh UUID, so the host can pin each widget by an id that stays the
178
+ * same whenever the result is shown. Throws when `input` doesn't pass
179
+ * `observabilityDashboardInputSchema`, or the definition doesn't validate (e.g. over the size limit).
180
+ */
181
+ export declare function toObservabilityDashboard(input: ObservabilityDashboardInput): ObservabilityDashboardOpened;
182
+ export {};
183
+ //# sourceMappingURL=observability-dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability-dashboard.d.ts","sourceRoot":"","sources":["../src/observability-dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EAMzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAEV,iBAAiB,EACjB,mBAAmB,EAC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C,CAAC,CAAC;AAEL,qDAAqD;AACrD,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,CAAC,EAAE,OAAO,wBAAwB,CAAC;IAChD,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,IAAI,EAAE;QAAE,OAAO,EAAE,wBAAwB,EAAE,CAAA;KAAE,EAAE,CAAC;CACjD,CAAC;AAEF,sFAAsF;AACtF,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,2BAA2B,CAAC;IACvC,2FAA2F;IAC3F,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,GAAE,oBAAyB,GACjC,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAUxC;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,iHAA4C,CAAC;AAE3F,oFAAoF;AACpF,eAAO,MAAM,kCAAkC,EAAE,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAGrF,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG;IAAE,SAAS,EAAE,mBAAmB,CAAC;IAAC,UAAU,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAEpH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,2BAA2B,GAAG,4BAA4B,CAazG"}
@@ -2,12 +2,49 @@
2
2
  /** The app-only tool the observability widget calls, on the server that opened it, for every read. */
3
3
  const QUERY_OBSERVABILITY_TOOL = "queryObservability";
4
4
  /**
5
+ * Every `MastraClient` method the app sends as a `queryObservability` action. All are reads; allow
6
+ * these and nothing else (`z.enum(OBSERVABILITY_READ_ACTIONS)`).
7
+ */
8
+ const OBSERVABILITY_READ_ACTIONS = [
9
+ "aggregateTraces",
10
+ "aggregateSpans",
11
+ "getMetricAggregate",
12
+ "getMetricBreakdown",
13
+ "getMetricTimeSeries",
14
+ "getMetricPercentiles",
15
+ "getScoreAggregate",
16
+ "getScoreBreakdown",
17
+ "getScoreTimeSeries",
18
+ "getScorePercentiles",
19
+ "listScores"
20
+ ];
21
+ /** The windows the widget can show, ending when it opens; the same presets as Studio's metrics. */
22
+ const OBSERVABILITY_DATE_PRESETS = [
23
+ "24h",
24
+ "3d",
25
+ "7d",
26
+ "14d",
27
+ "30d"
28
+ ];
29
+ /**
5
30
  * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button
6
31
  * only shows when the host sends it and supports `updateModelContext.structuredContent`.
7
32
  */
8
33
  const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = "mastra.ai/observability-widget-pinned";
9
34
  /** `structuredContent` key of the model context update the app sends when the user (un)pins. */
10
35
  const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = "mastra.ai/observability-widget-pin";
36
+ Object.defineProperty(exports, "OBSERVABILITY_DATE_PRESETS", {
37
+ enumerable: true,
38
+ get: function() {
39
+ return OBSERVABILITY_DATE_PRESETS;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "OBSERVABILITY_READ_ACTIONS", {
43
+ enumerable: true,
44
+ get: function() {
45
+ return OBSERVABILITY_READ_ACTIONS;
46
+ }
47
+ });
11
48
  Object.defineProperty(exports, "OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY", {
12
49
  enumerable: true,
13
50
  get: function() {
@@ -27,4 +64,4 @@ Object.defineProperty(exports, "QUERY_OBSERVABILITY_TOOL", {
27
64
  }
28
65
  });
29
66
 
30
- //# sourceMappingURL=tool-C6_-nIOM.cjs.map
67
+ //# sourceMappingURL=tool-B4yU6CY0.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-B4yU6CY0.cjs","names":[],"sources":["../src/apps/observability-widget/tool.ts"],"sourcesContent":["/** The app-only tool the observability widget calls, on the server that opened it, for every read. */\nexport const QUERY_OBSERVABILITY_TOOL = 'queryObservability';\n\n/**\n * Every `MastraClient` method the app sends as a `queryObservability` action. All are reads; allow\n * these and nothing else (`z.enum(OBSERVABILITY_READ_ACTIONS)`).\n */\nexport const OBSERVABILITY_READ_ACTIONS = [\n 'aggregateTraces',\n 'aggregateSpans',\n 'getMetricAggregate',\n 'getMetricBreakdown',\n 'getMetricTimeSeries',\n 'getMetricPercentiles',\n 'getScoreAggregate',\n 'getScoreBreakdown',\n 'getScoreTimeSeries',\n 'getScorePercentiles',\n 'listScores',\n] as const;\n\nexport type ObservabilityReadAction = (typeof OBSERVABILITY_READ_ACTIONS)[number];\n\n/** The windows the widget can show, ending when it opens; the same presets as Studio's metrics. */\nexport const OBSERVABILITY_DATE_PRESETS = ['24h', '3d', '7d', '14d', '30d'] as const;\n\nexport type ObservabilityDatePreset = (typeof OBSERVABILITY_DATE_PRESETS)[number];\n\n/**\n * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button\n * only shows when the host sends it and supports `updateModelContext.structuredContent`.\n */\nexport const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = 'mastra.ai/observability-widget-pinned';\n\n/** `structuredContent` key of the model context update the app sends when the user (un)pins. */\nexport const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = 'mastra.ai/observability-widget-pin';\n\n/** What the app sends under `OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY`: the state the user asked for. */\nexport type ObservabilityWidgetPin = {\n pinned: boolean;\n /** The stored dashboard widget, as the opening tool returned it. */\n widget: { id: string; [key: string]: unknown };\n datePreset: string;\n /** The dashboard's `defaults.filters` the widget was drawn under, when it has any. */\n filters?: unknown[];\n};\n"],"mappings":";;AACA,MAAa,2BAA2B;;;;;AAMxC,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAKA,MAAa,6BAA6B;CAAC;CAAO;CAAM;CAAM;CAAO;AAAK;;;;;AAQ1E,MAAa,0CAA0C;;AAGvD,MAAa,uCAAuC"}
@@ -0,0 +1,38 @@
1
+ // src/apps/observability-widget/tool.ts
2
+ /** The app-only tool the observability widget calls, on the server that opened it, for every read. */
3
+ const QUERY_OBSERVABILITY_TOOL = "queryObservability";
4
+ /**
5
+ * Every `MastraClient` method the app sends as a `queryObservability` action. All are reads; allow
6
+ * these and nothing else (`z.enum(OBSERVABILITY_READ_ACTIONS)`).
7
+ */
8
+ const OBSERVABILITY_READ_ACTIONS = [
9
+ "aggregateTraces",
10
+ "aggregateSpans",
11
+ "getMetricAggregate",
12
+ "getMetricBreakdown",
13
+ "getMetricTimeSeries",
14
+ "getMetricPercentiles",
15
+ "getScoreAggregate",
16
+ "getScoreBreakdown",
17
+ "getScoreTimeSeries",
18
+ "getScorePercentiles",
19
+ "listScores"
20
+ ];
21
+ /** The windows the widget can show, ending when it opens; the same presets as Studio's metrics. */
22
+ const OBSERVABILITY_DATE_PRESETS = [
23
+ "24h",
24
+ "3d",
25
+ "7d",
26
+ "14d",
27
+ "30d"
28
+ ];
29
+ /**
30
+ * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button
31
+ * only shows when the host sends it and supports `updateModelContext.structuredContent`.
32
+ */
33
+ const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = "mastra.ai/observability-widget-pinned";
34
+ /** `structuredContent` key of the model context update the app sends when the user (un)pins. */
35
+ const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = "mastra.ai/observability-widget-pin";
36
+ export { QUERY_OBSERVABILITY_TOOL as a, OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY as i, OBSERVABILITY_READ_ACTIONS as n, OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY as r, OBSERVABILITY_DATE_PRESETS as t };
37
+
38
+ //# sourceMappingURL=tool-C601G1w9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-C601G1w9.js","names":[],"sources":["../src/apps/observability-widget/tool.ts"],"sourcesContent":["/** The app-only tool the observability widget calls, on the server that opened it, for every read. */\nexport const QUERY_OBSERVABILITY_TOOL = 'queryObservability';\n\n/**\n * Every `MastraClient` method the app sends as a `queryObservability` action. All are reads; allow\n * these and nothing else (`z.enum(OBSERVABILITY_READ_ACTIONS)`).\n */\nexport const OBSERVABILITY_READ_ACTIONS = [\n 'aggregateTraces',\n 'aggregateSpans',\n 'getMetricAggregate',\n 'getMetricBreakdown',\n 'getMetricTimeSeries',\n 'getMetricPercentiles',\n 'getScoreAggregate',\n 'getScoreBreakdown',\n 'getScoreTimeSeries',\n 'getScorePercentiles',\n 'listScores',\n] as const;\n\nexport type ObservabilityReadAction = (typeof OBSERVABILITY_READ_ACTIONS)[number];\n\n/** The windows the widget can show, ending when it opens; the same presets as Studio's metrics. */\nexport const OBSERVABILITY_DATE_PRESETS = ['24h', '3d', '7d', '14d', '30d'] as const;\n\nexport type ObservabilityDatePreset = (typeof OBSERVABILITY_DATE_PRESETS)[number];\n\n/**\n * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button\n * only shows when the host sends it and supports `updateModelContext.structuredContent`.\n */\nexport const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = 'mastra.ai/observability-widget-pinned';\n\n/** `structuredContent` key of the model context update the app sends when the user (un)pins. */\nexport const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = 'mastra.ai/observability-widget-pin';\n\n/** What the app sends under `OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY`: the state the user asked for. */\nexport type ObservabilityWidgetPin = {\n pinned: boolean;\n /** The stored dashboard widget, as the opening tool returned it. */\n widget: { id: string; [key: string]: unknown };\n datePreset: string;\n /** The dashboard's `defaults.filters` the widget was drawn under, when it has any. */\n filters?: unknown[];\n};\n"],"mappings":";;AACA,MAAa,2BAA2B;;;;;AAMxC,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAKA,MAAa,6BAA6B;CAAC;CAAO;CAAM;CAAM;CAAO;AAAK;;;;;AAQ1E,MAAa,0CAA0C;;AAGvD,MAAa,uCAAuC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-apps-components",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Prebuilt MCP Apps, ready to register as MCP server app resources",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -39,6 +39,10 @@
39
39
  "bugs": {
40
40
  "url": "https://github.com/mastra-ai/mastra/issues"
41
41
  },
42
+ "peerDependencies": {
43
+ "@mastra/core": ">=1.82.0-0 <2.0.0-0",
44
+ "zod": "^4.2.0"
45
+ },
42
46
  "devDependencies": {
43
47
  "@modelcontextprotocol/client": "2.4.0",
44
48
  "@modelcontextprotocol/core": "2.4.0",
@@ -52,6 +56,7 @@
52
56
  "@types/react-dom": "^19.3.0",
53
57
  "@vitejs/plugin-react": "^6.1.2",
54
58
  "jsdom": "^30.1.3",
59
+ "lucide-react": "^1.61.0",
55
60
  "react": "^19.3.1",
56
61
  "react-dom": "^19.3.1",
57
62
  "tailwindcss": "4.3.3",
@@ -67,7 +72,7 @@
67
72
  "@mastra/client-js": "1.60.0-alpha.1",
68
73
  "@mastra/core": "1.83.0-alpha.1",
69
74
  "@mastra/mcp": "2.9.0-alpha.1",
70
- "@mastra/playground-ui": "69.0.0-alpha.1",
75
+ "@mastra/playground-ui": "69.0.0-alpha.2",
71
76
  "@mastra/react": "1.15.0-alpha.1"
72
77
  },
73
78
  "engines": {
@@ -1,13 +0,0 @@
1
- // src/apps/observability-widget/tool.ts
2
- /** The app-only tool the observability widget calls, on the server that opened it, for every read. */
3
- const QUERY_OBSERVABILITY_TOOL = "queryObservability";
4
- /**
5
- * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button
6
- * only shows when the host sends it and supports `updateModelContext.structuredContent`.
7
- */
8
- const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = "mastra.ai/observability-widget-pinned";
9
- /** `structuredContent` key of the model context update the app sends when the user (un)pins. */
10
- const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = "mastra.ai/observability-widget-pin";
11
- export { OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY as n, QUERY_OBSERVABILITY_TOOL as r, OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY as t };
12
-
13
- //# sourceMappingURL=tool-BD-7EJf2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-BD-7EJf2.js","names":[],"sources":["../src/apps/observability-widget/tool.ts"],"sourcesContent":["/** The app-only tool the observability widget calls, on the server that opened it, for every read. */\nexport const QUERY_OBSERVABILITY_TOOL = 'queryObservability';\n\n/**\n * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button\n * only shows when the host sends it and supports `updateModelContext.structuredContent`.\n */\nexport const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = 'mastra.ai/observability-widget-pinned';\n\n/** `structuredContent` key of the model context update the app sends when the user (un)pins. */\nexport const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = 'mastra.ai/observability-widget-pin';\n\n/** What the app sends under `OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY`: the state the user asked for. */\nexport type ObservabilityWidgetPin = {\n pinned: boolean;\n /** The stored dashboard widget, as the opening tool returned it. */\n widget: { id: string; [key: string]: unknown };\n datePreset: string;\n};\n"],"mappings":";;AACA,MAAa,2BAA2B;;;;;AAMxC,MAAa,0CAA0C;;AAGvD,MAAa,uCAAuC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-C6_-nIOM.cjs","names":[],"sources":["../src/apps/observability-widget/tool.ts"],"sourcesContent":["/** The app-only tool the observability widget calls, on the server that opened it, for every read. */\nexport const QUERY_OBSERVABILITY_TOOL = 'queryObservability';\n\n/**\n * Host context key holding the ids of the widgets the host has pinned (`string[]`). The pin button\n * only shows when the host sends it and supports `updateModelContext.structuredContent`.\n */\nexport const OBSERVABILITY_WIDGET_PINNED_CONTEXT_KEY = 'mastra.ai/observability-widget-pinned';\n\n/** `structuredContent` key of the model context update the app sends when the user (un)pins. */\nexport const OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY = 'mastra.ai/observability-widget-pin';\n\n/** What the app sends under `OBSERVABILITY_WIDGET_PIN_CONTEXT_KEY`: the state the user asked for. */\nexport type ObservabilityWidgetPin = {\n pinned: boolean;\n /** The stored dashboard widget, as the opening tool returned it. */\n widget: { id: string; [key: string]: unknown };\n datePreset: string;\n};\n"],"mappings":";;AACA,MAAa,2BAA2B;;;;;AAMxC,MAAa,0CAA0C;;AAGvD,MAAa,uCAAuC"}