@grafana/assistant 0.1.35 → 0.1.36
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/README.md +110 -0
- package/dist/analyticsEvents.d.ts +33 -0
- package/dist/analyticsEvents.d.ts.map +1 -0
- package/dist/components/button/OpenAssistantButton.d.ts +6 -1
- package/dist/components/button/OpenAssistantButton.d.ts.map +1 -1
- package/dist/components/grots/GrotAvatar.d.ts +31 -0
- package/dist/components/grots/GrotAvatar.d.ts.map +1 -0
- package/dist/components/grots/GrotTopicView.d.ts +19 -0
- package/dist/components/grots/GrotTopicView.d.ts.map +1 -0
- package/dist/components/grots/OpenGrotButton.d.ts +23 -0
- package/dist/components/grots/OpenGrotButton.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/esm/analyticsEvents.js +31 -0
- package/dist/esm/analyticsEvents.js.map +1 -0
- package/dist/esm/components/button/OpenAssistantButton.js +11 -10
- package/dist/esm/components/button/OpenAssistantButton.js.map +1 -1
- package/dist/esm/components/button/OpenAssistantSplitButton.js +2 -2
- package/dist/esm/components/button/OpenAssistantSplitButton.js.map +1 -1
- package/dist/esm/components/grots/GrotAvatar.js +37 -0
- package/dist/esm/components/grots/GrotAvatar.js.map +1 -0
- package/dist/esm/components/grots/GrotTopicView.js +25 -0
- package/dist/esm/components/grots/GrotTopicView.js.map +1 -0
- package/dist/esm/components/grots/OpenGrotButton.js +36 -0
- package/dist/esm/components/grots/OpenGrotButton.js.map +1 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/prompt-card/AssistantPromptCard.js +2 -2
- package/dist/esm/components/prompt-card/AssistantPromptCard.js.map +1 -1
- package/dist/esm/grots/avatar/appearance.js +303 -0
- package/dist/esm/grots/avatar/appearance.js.map +1 -0
- package/dist/esm/grots/avatar/sprite.js +481 -0
- package/dist/esm/grots/avatar/sprite.js.map +1 -0
- package/dist/esm/grots/client.js +377 -0
- package/dist/esm/grots/client.js.map +1 -0
- package/dist/esm/grots/index.js +2 -0
- package/dist/esm/grots/index.js.map +1 -0
- package/dist/esm/grots/retry.js +67 -0
- package/dist/esm/grots/retry.js.map +1 -0
- package/dist/esm/grots/types.js +2 -0
- package/dist/esm/grots/types.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sidebar.js +4 -3
- package/dist/esm/sidebar.js.map +1 -1
- package/dist/grots/avatar/appearance.d.ts +82 -0
- package/dist/grots/avatar/appearance.d.ts.map +1 -0
- package/dist/grots/avatar/sprite.d.ts +84 -0
- package/dist/grots/avatar/sprite.d.ts.map +1 -0
- package/dist/grots/client.d.ts +130 -0
- package/dist/grots/client.d.ts.map +1 -0
- package/dist/grots/index.d.ts +3 -0
- package/dist/grots/index.d.ts.map +1 -0
- package/dist/grots/retry.d.ts +7 -0
- package/dist/grots/retry.d.ts.map +1 -0
- package/dist/grots/types.d.ts +331 -0
- package/dist/grots/types.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/investigations/api.gen.d.ts +3 -3
- package/dist/sidebar.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -563,6 +563,15 @@ function MyDashboard() {
|
|
|
563
563
|
origin="grafana-datasources/loki/query-editor"
|
|
564
564
|
/>
|
|
565
565
|
|
|
566
|
+
{/* Bordered icon-only button, for a row of secondary icon buttons */}
|
|
567
|
+
<OpenAssistantButton
|
|
568
|
+
prompt="Explain this issue"
|
|
569
|
+
iconOnlyButton={true}
|
|
570
|
+
iconOnlyVariant="bordered"
|
|
571
|
+
title="Ask Assistant"
|
|
572
|
+
origin="grafana-advisor-app/issue-actions"
|
|
573
|
+
/>
|
|
574
|
+
|
|
566
575
|
{/* Button without auto-send */}
|
|
567
576
|
<OpenAssistantButton
|
|
568
577
|
prompt="What patterns do you see in the data?"
|
|
@@ -718,6 +727,7 @@ A pre-built React component that renders a button to open the Grafana Assistant
|
|
|
718
727
|
- `title?: string` - Text to display on the button (defaults to `'Analyze with Assistant'`)
|
|
719
728
|
- `size?: 'xs' | 'sm' | 'md' | 'lg'` - Button size (defaults to `'sm'`)
|
|
720
729
|
- `iconOnlyButton?: boolean` - If `true`, renders as an icon-only button with tooltip (defaults to `false`)
|
|
730
|
+
- `iconOnlyVariant?: 'ghost' | 'bordered'` - Style of the icon-only button. `'ghost'` is borderless. `'bordered'` renders a standard secondary `Button` that lines up with other secondary icon buttons, with `title` as its tooltip and accessible name. Only applies when `iconOnlyButton` is `true` (defaults to `'ghost'`)
|
|
721
731
|
|
|
722
732
|
#### `<QueryWithAssistantButton />`
|
|
723
733
|
|
|
@@ -1159,6 +1169,106 @@ HTTP failures, invalid response/event data, a connection that doesn't open withi
|
|
|
1159
1169
|
|
|
1160
1170
|
Unsubscribing closes the event connection, aborts pending reads, and clears timers. It never pauses or cancels server-side work. Multiple subscriptions are independent; share one subscription in your UI when multiple consumers need the same updates. The API observes investigations only and doesn't send prompts or observe regular Assistant conversations.
|
|
1161
1171
|
|
|
1172
|
+
### Working with Grots (experimental)
|
|
1173
|
+
|
|
1174
|
+
The Grots client is experimental and may change between releases.
|
|
1175
|
+
|
|
1176
|
+
Use the Grots client from a Grafana plugin to list Grots, create one, chat with one in direct topics, or wake one with a workflow event. The calls go through Grafana's plugin proxy as the signed-in user, so there is no extra authentication; do not embed service account tokens in browser code. The Go SDK (`packages/assistant-go`, `GROTS.md`) has the same calls for servers.
|
|
1177
|
+
|
|
1178
|
+
```typescript
|
|
1179
|
+
import {
|
|
1180
|
+
createGrot,
|
|
1181
|
+
createGrotTopic,
|
|
1182
|
+
listGrotTopicMessages,
|
|
1183
|
+
listGrots,
|
|
1184
|
+
postGrotTopicMessage,
|
|
1185
|
+
wakeGrot,
|
|
1186
|
+
readGrotLane,
|
|
1187
|
+
closeGrotLane,
|
|
1188
|
+
} from '@grafana/assistant';
|
|
1189
|
+
|
|
1190
|
+
const grots = await listGrots({ labelSelector: 'team=payments' });
|
|
1191
|
+
|
|
1192
|
+
// Chat: one topic per item. Reuse a dedupeKey only when retrying the same message.
|
|
1193
|
+
const { topic } = await createGrotTopic(grots[0].id, {
|
|
1194
|
+
title: 'Incident 42',
|
|
1195
|
+
content: 'Please investigate the 5xx rate on checkout-api.',
|
|
1196
|
+
dedupeKey: 'incident-42-open',
|
|
1197
|
+
});
|
|
1198
|
+
await postGrotTopicMessage(grots[0].id, topic.id, { content: 'The deploy was rolled back.', dedupeKey: 'incident-42-rollback' });
|
|
1199
|
+
const page = await listGrotTopicMessages(grots[0].id, topic.chatId); // takes chatId, not topic id
|
|
1200
|
+
|
|
1201
|
+
// Wake: events with the same laneKey run in order in one lane.
|
|
1202
|
+
await wakeGrot(grots[0].id, { workflow: 'disk-pressure', dedupeKey: `${runId}/${stepId}`, content: 'Disk above 90%', laneKey: 'incident-42' });
|
|
1203
|
+
const lane = await readGrotLane(grots[0].id, 'incident-42'); // lane.busy is false when the Grot is done
|
|
1204
|
+
await closeGrotLane(grots[0].id, 'incident-42'); // frees one of the 50 open lanes
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
#### Grot components
|
|
1208
|
+
|
|
1209
|
+
Three small components show Grots in your own plugin. They call the same client as above, as the signed-in user.
|
|
1210
|
+
|
|
1211
|
+
```tsx
|
|
1212
|
+
import { GrotAvatar, GrotTopicView, OpenGrotButton } from '@grafana/assistant';
|
|
1213
|
+
|
|
1214
|
+
// Draws a Grot from its look: pass the Grot, or a `look` (the avatar string, or some of its parts).
|
|
1215
|
+
<GrotAvatar grot={grot} size={32} title="Ada, the on-call Grot" />
|
|
1216
|
+
|
|
1217
|
+
// Opens the Grot (and optionally one topic, by number) on the Assistant's Grots page.
|
|
1218
|
+
<OpenGrotButton grotId={grot.id} topic={topic.number} label="Open topic" variant="secondary" />
|
|
1219
|
+
|
|
1220
|
+
// One of your topics with the Grot, read only, as the Grots page shows it. Give its container a height.
|
|
1221
|
+
<div style={{ height: 480 }}>
|
|
1222
|
+
<GrotTopicView grotId={grot.id} topic={topic} />
|
|
1223
|
+
</div>
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
`GrotAvatar` and `OpenGrotButton` call nothing, so they need only `plugins.app:access` (the link opens the Grots page, which checks the person's own access). `GrotTopicView` renders the Assistant app's `grafana-assistant-app/grot-topic/v1` exposed component, so list that ID under `dependencies.extensions.exposedComponents` in your `plugin.json`. On an Assistant app that doesn't expose it yet, the view says to update the Assistant. It reads the Grot and its topic as the signed-in user, so it needs `grafana-assistant-app.durable-agents.<scope>:read` for the Grot's scope and `grafana-assistant-app.durable-agents.conversations.user:read` (see `packages/assistant-go/GROTS.md`). Without them it shows its error state.
|
|
1227
|
+
|
|
1228
|
+
Every function takes `{ signal }` to abort, validates the response and throws on a malformed one. Non-2xx responses reject with the Grafana fetch error. Messages come back as raw AI SDK `UIMessage` objects; `parseGrotTopicMessage(message)` turns one into a typed `ParsedGrotMessage` (`kind` is `user`, `assistant`, `system` or `unknown`, with `text` and typed `parts`). Unknown roles and part types stay readable and do not throw; a value that is not an object, or whose `id` or `role` is not a string, throws, as in Go.
|
|
1229
|
+
|
|
1230
|
+
Change things with `updateGrot(id, { expectedRevision, name, purpose, role, labels })`, `updateGrotTopic(id, topicId, { expectedRevision, title, archived, pinned })` and `archiveGrotTopic(id, topicId, expectedRevision)`. Pass the `revision` you last read; a stale one rejects with 409. Only those fields are sent: `updateGrot` cannot change tool grants, permissions or the execution binding (use `bindGrot`, below), and extra properties are dropped. If you send `labels` to a backend that predates labels, `updateGrot` throws `GrotLabelsNotSupportedError` (its `grot` property is the updated Grot): the other fields changed but the labels did not.
|
|
1231
|
+
|
|
1232
|
+
Calls make one request unless you pass `retry`. `retry: true` uses the Go SDK's `Chat` policy: 3 attempts in total, waits of 500 ms then 1 s (doubling, at most 10 s, 10% jitter), only on 429, 502, 503 and 504. Pass `{ maxAttempts, initialBackoffMs, maxBackoffMs }` to tune it. Invalid values (NaN, Infinity, a `maxAttempts` below 1 or not whole, a negative wait) fall back to the defaults. It applies to reads and the calls that carry a `dedupeKey` (`wakeGrot`, `createGrotTopic`, `postGrotTopicMessage`); `createGrot`, `bindGrot`, `closeGrotLane`, `updateGrot`, `updateGrotTopic` and `archiveGrotTopic` never retry. The Go SDK retries none of the Grots calls, so this is off by default.
|
|
1233
|
+
|
|
1234
|
+
`createGrot(input)` sends only the fields you pass: `name`, `purpose`, `role`, `scope`, `teamId`, `ownerDelegation`, `executionBinding`, `grant` and `labels`. Nothing is added for you. `scope` defaults to `user`, a private Grot, which the backend only accepts with `ownerDelegation: true`: your explicit consent that the Grot may use your Grafana permissions for unattended background work. Set it only when the person using your code agreed. `ownerDelegation` is refused on `team` Grots, and shared (`tenant`) Grots can't be created any more.
|
|
1235
|
+
|
|
1236
|
+
A Grot created without `executionBinding` and `grant` stays a `draft` and cannot run: `createGrotTopic` fails with 400 "configure an execution identity before running the agent". To create a Grot that can run, pass both, or call `bindGrot` on the Grot afterwards. Either turns on the Grot's background work and gives it tool access, so set them only when the person using your code has explicitly agreed, and never by default. The only `executionBinding` today is `'assistant-tenant-service'`. It is the same value for both scopes, but whose access the Grot runs with depends on its scope: a private (`user`) Grot runs with its owner's current Grafana permissions, so it can do what the owner can do when it runs and loses access when the owner does; a team Grot runs as a service account scoped to its team, not as the person who bound it. Tell your users which one they are granting before you bind a Grot for them. `grant` is `{ allowAllTools: true }`, which lets the Grot call every tool, or `{ allowAllTools: false, allowedTools: ['<TOOL_NAME>'] }` with at least one tool name. The backend refuses any other shape.
|
|
1237
|
+
|
|
1238
|
+
```typescript
|
|
1239
|
+
const grot = await createGrot({
|
|
1240
|
+
name: 'Checkout watcher',
|
|
1241
|
+
ownerDelegation: true,
|
|
1242
|
+
executionBinding: 'assistant-tenant-service',
|
|
1243
|
+
grant: { allowAllTools: false, allowedTools: ['<TOOL_NAME>'] },
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
// Or bind a Grot you already created. A stale expectedRevision, or a run in progress, rejects with 409.
|
|
1247
|
+
const bound = await bindGrot(draft.id, {
|
|
1248
|
+
expectedRevision: draft.revision,
|
|
1249
|
+
executionBinding: 'assistant-tenant-service',
|
|
1250
|
+
grant: { allowAllTools: true },
|
|
1251
|
+
});
|
|
1252
|
+
```
|
|
1253
|
+
|
|
1254
|
+
Required RBAC (all actions carry the `grafana-assistant-app.` prefix, plus `plugins.app:access`):
|
|
1255
|
+
|
|
1256
|
+
| Function | Permissions |
|
|
1257
|
+
| --- | --- |
|
|
1258
|
+
| `listGrots`, `getGrot` | `durable-agents.<scope>:read` |
|
|
1259
|
+
| `createGrot` | `durable-agents.<scope>:create` for the new Grot's scope; with `executionBinding` and `grant`, also `durable-agents:configure` and `durable-agents.<scope>:execute` |
|
|
1260
|
+
| `bindGrot` | `durable-agents:configure` and `durable-agents.<scope>:write`, plus `:execute` on a draft Grot |
|
|
1261
|
+
| `wakeGrot`, `closeGrotLane` | `durable-agents.<scope>:execute` |
|
|
1262
|
+
| `readGrotLane` | `:execute` and `:read`, plus `durable-agents.conversations.tenant:read` |
|
|
1263
|
+
| `createGrotTopic` | `:execute`, plus `conversations.user:create` (first topic) and `conversations.user:write` |
|
|
1264
|
+
| `postGrotTopicMessage` | `:execute` and `conversations.user:write` |
|
|
1265
|
+
| `updateGrot` | `durable-agents.<scope>:write` |
|
|
1266
|
+
| `updateGrotTopic`, `archiveGrotTopic` | `:execute` and `conversations.user:write` |
|
|
1267
|
+
| `parseGrotTopicMessage` | none (local) |
|
|
1268
|
+
| `listGrotTopics`, `listGrotTopicMessages` | `:read` and `conversations.user:read` |
|
|
1269
|
+
|
|
1270
|
+
Private Grots answer 404 to anyone but their owner, and team Grots to non-members. See `packages/assistant-go/GROTS.md` for dedupe keys, lane limits and status codes.
|
|
1271
|
+
|
|
1162
1272
|
### Deriving Structured Views of Investigations (Lens)
|
|
1163
1273
|
|
|
1164
1274
|
The `useInvestigationThroughLens` hook derives a structured, LLM-generated view of an investigation's report, shaped by a JSON Schema you provide. Use it when a host plugin (for example, IRM) holds an `investigationId` and wants a compact, typed digest of the investigation — an executive headline, contributing factors, follow-up actions — without rendering the full report.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Where an integration opened or showed Assistant, which every SDK event sends. */
|
|
2
|
+
type SdkEventOrigin = {
|
|
3
|
+
/**
|
|
4
|
+
* The caller's `origin`: a namespaced, slash-separated name for the integration and the place in it, such as
|
|
5
|
+
* `grafana-slo-app/slo-editor-overview`.
|
|
6
|
+
*/
|
|
7
|
+
from: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A caller opens the Assistant sidebar. The from field identifies the entry point.
|
|
11
|
+
*/
|
|
12
|
+
export declare const trackSidebarOpened: (properties: SdkEventOrigin) => void;
|
|
13
|
+
/**
|
|
14
|
+
* A caller toggles the Assistant sidebar and optionally supplies a prompt.
|
|
15
|
+
*/
|
|
16
|
+
export declare const trackSidebarToggled: (properties: SdkEventOrigin & {
|
|
17
|
+
/** The prompt the caller asked Assistant to open with, as the caller wrote it; empty when it gave none. */
|
|
18
|
+
prompt: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
/**
|
|
21
|
+
* The SDK renders the Open Assistant button for an integration.
|
|
22
|
+
*/
|
|
23
|
+
export declare const trackOpenButtonDisplayed: (properties: SdkEventOrigin) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The SDK renders the Open Assistant split button for an integration.
|
|
26
|
+
*/
|
|
27
|
+
export declare const trackSplitButtonDisplayed: (properties: SdkEventOrigin) => void;
|
|
28
|
+
/**
|
|
29
|
+
* The SDK renders an Assistant prompt card for an integration.
|
|
30
|
+
*/
|
|
31
|
+
export declare const trackPromptCardDisplayed: (properties: SdkEventOrigin) => void;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=analyticsEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyticsEvents.d.ts","sourceRoot":"","sources":["../src/analyticsEvents.ts"],"names":[],"mappings":"AAKA,oFAAoF;AACpF,KAAK,cAAc,GAAG;IACpB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,kBAAkB,sCAA4E,CAAC;AAE5G;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAE5B,2GAA2G;YACnG,MAAM;UAE2C,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,wBAAwB,sCAEnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,sCAEpC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,sCAEnC,CAAC"}
|
|
@@ -15,6 +15,11 @@ export interface OpenAssistantButtonProps {
|
|
|
15
15
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
16
16
|
/** If true, the button will be Assistant icon only with name as title. Defaults to false. */
|
|
17
17
|
iconOnlyButton?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Style of the icon-only button. `'ghost'` is borderless; `'bordered'` is a standard secondary `Button`
|
|
20
|
+
* that lines up with other secondary icon buttons. Only applies when `iconOnlyButton` is true. Defaults to `'ghost'`.
|
|
21
|
+
*/
|
|
22
|
+
iconOnlyVariant?: 'ghost' | 'bordered';
|
|
18
23
|
/** Function to call when the button is clicked. Optional, defaults to undefined. */
|
|
19
24
|
onClick?: () => void;
|
|
20
25
|
}
|
|
@@ -26,7 +31,7 @@ export declare function OpenAssistantButton(props: OpenAssistantButtonProps): im
|
|
|
26
31
|
* Presentational component separated from OpenAssistantButton to avoid hook dependencies in previews.
|
|
27
32
|
* It is not exported for users of the package.
|
|
28
33
|
*/
|
|
29
|
-
export declare function OpenAssistantButtonView({ prompt, origin, context, autoSend, title, size, iconOnlyButton, openAssistant, onClick, }: OpenAssistantButtonProps & {
|
|
34
|
+
export declare function OpenAssistantButtonView({ prompt, origin, context, autoSend, title, size, iconOnlyButton, iconOnlyVariant, openAssistant, onClick, }: OpenAssistantButtonProps & {
|
|
30
35
|
openAssistant: (props: OpenAssistantProps) => void;
|
|
31
36
|
}): import("react").JSX.Element;
|
|
32
37
|
//# sourceMappingURL=OpenAssistantButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAssistantButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/OpenAssistantButton.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,iUAAiU;IACjU,MAAM,EAAE,MAAM,CAAC;IACf,iIAAiI;IACjI,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,6FAA6F;IAC7F,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,sCAOlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAe,EACf,KAAgC,EAChC,IAAW,EACX,cAAsB,EACtB,aAAa,EACb,OAAO,GACR,EAAE,wBAAwB,GAAG;IAC5B,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACpD,+
|
|
1
|
+
{"version":3,"file":"OpenAssistantButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/OpenAssistantButton.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,wBAAwB;IACvC,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,iUAAiU;IACjU,MAAM,EAAE,MAAM,CAAC;IACf,iIAAiI;IACjI,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,6FAA6F;IAC7F,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACvC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,sCAOlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAe,EACf,KAAgC,EAChC,IAAW,EACX,cAAsB,EACtB,eAAyB,EACzB,aAAa,EACb,OAAO,GACR,EAAE,wBAAwB,GAAG;IAC5B,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACpD,+BA2DA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Appearance } from '../../grots/avatar/appearance';
|
|
2
|
+
/** @experimental This API is under active development and may change in future releases. */
|
|
3
|
+
export type GrotLook = Partial<Appearance>;
|
|
4
|
+
/** @experimental This API is under active development and may change in future releases. */
|
|
5
|
+
export interface GrotAvatarProps {
|
|
6
|
+
/**
|
|
7
|
+
* The Grot to draw. Its `avatar` string is its look, such as `mint.fin.band.bars.smile.cap.empty.curl`.
|
|
8
|
+
* A Grot without one gets a stable look derived from its `id`.
|
|
9
|
+
*/
|
|
10
|
+
grot?: {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
avatar?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A look to draw instead of `grot`: the dotted avatar string, or some of the parts. A part left out, or one with
|
|
17
|
+
* an unknown option, is the classic Grot's.
|
|
18
|
+
*/
|
|
19
|
+
look?: string | GrotLook;
|
|
20
|
+
/** Width and height in pixels. Defaults to 32. */
|
|
21
|
+
size?: number;
|
|
22
|
+
/** Accessible label. Defaults to the Grot's name, else "Grot". */
|
|
23
|
+
title?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A Grot at rest, drawn from its look. It is an image with an accessible name.
|
|
27
|
+
*
|
|
28
|
+
* @experimental This API is under active development and may change in future releases.
|
|
29
|
+
*/
|
|
30
|
+
export declare function GrotAvatar(props: GrotAvatarProps): import("react").JSX.Element;
|
|
31
|
+
//# sourceMappingURL=GrotAvatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrotAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/grots/GrotAvatar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqD,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGnH,4FAA4F;AAC5F,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,4FAA4F;AAC5F,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,+BAMhD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The Assistant app's exposed component this view renders. Add it to your plugin.json's `dependencies.extensions.exposedComponents`. */
|
|
2
|
+
export declare const GROT_TOPIC_COMPONENT_ID = "grafana-assistant-app/grot-topic/v1";
|
|
3
|
+
/** @experimental This API is under active development and may change in future releases. */
|
|
4
|
+
export interface GrotTopicViewProps {
|
|
5
|
+
grotId: string;
|
|
6
|
+
/** The topic to show, such as a `GrotTopic`. Its `number` picks it among the signed-in person's topics with the Grot. */
|
|
7
|
+
topic: {
|
|
8
|
+
number: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One of the signed-in person's topics with a Grot, read only, drawn by the Grafana Assistant app: the Grots page's own
|
|
13
|
+
* conversation, so it changes when that page does. It fills its container's height and scrolls inside it, so give the
|
|
14
|
+
* container a height. Needs read access to the Grot and its direct chats, and an Assistant app that exposes
|
|
15
|
+
* `grafana-assistant-app/grot-topic/v1`.
|
|
16
|
+
* @experimental This API is under active development and may change in future releases.
|
|
17
|
+
*/
|
|
18
|
+
export declare function GrotTopicView({ grotId, topic }: GrotTopicViewProps): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=GrotTopicView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrotTopicView.d.ts","sourceRoot":"","sources":["../../../src/components/grots/GrotTopicView.tsx"],"names":[],"mappings":"AAIA,yIAAyI;AACzI,eAAO,MAAM,uBAAuB,wCAAyC,CAAC;AAE9E,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,yHAAyH;IACzH,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3B;AAOD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,kBAAkB,+BAgBlE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @experimental This API is under active development and may change in future releases. */
|
|
2
|
+
export interface OpenGrotButtonProps {
|
|
3
|
+
/** ID of the Grot to open. */
|
|
4
|
+
grotId: string;
|
|
5
|
+
/** Number of one of the Grot's topics to open on (`GrotTopic.number`). Without it the Grot opens on its topics. */
|
|
6
|
+
topic?: number;
|
|
7
|
+
/** Button text. Defaults to "Open Grot". */
|
|
8
|
+
label?: string;
|
|
9
|
+
variant?: 'primary' | 'secondary';
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The link the Grots page opens a Grot or topic from: `?assistantGrot=<id>&assistantTopic=<number>` on the Grots page
|
|
14
|
+
* (`WORKSPACE_GROT_PARAM`, `WORKSPACE_TOPIC_PARAM` and `GROTS_BASE_URL` in the plugin's `constants.ts`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function grotHref(grotId: string, topic?: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Opens a Grot, and optionally one of its topics, on the Grafana Assistant's Grots page.
|
|
19
|
+
*
|
|
20
|
+
* @experimental This API is under active development and may change in future releases.
|
|
21
|
+
*/
|
|
22
|
+
export declare function OpenGrotButton({ grotId, topic, label, variant, size, }: OpenGrotButtonProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=OpenGrotButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenGrotButton.d.ts","sourceRoot":"","sources":["../../../src/components/grots/OpenGrotButton.tsx"],"names":[],"mappings":"AAKA,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,mHAAmH;IACnH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAmB,EACnB,OAAqB,EACrB,IAAW,GACZ,EAAE,mBAAmB,+BAgBrB"}
|
|
@@ -5,4 +5,7 @@ export { AITextArea, type AITextAreaProps } from './input/AITextArea';
|
|
|
5
5
|
export { useAIGeneration, type UseAIGenerationOptions } from './input/useAIGeneration';
|
|
6
6
|
export { QueryWithAssistantButton, type QueryWithAssistantButtonProps } from './button/QueryWithAssistantButton';
|
|
7
7
|
export { AssistantPromptCard, AssistantPromptCardView, type AssistantPromptCardProps, type AssistantPromptCardViewProps, } from './prompt-card/AssistantPromptCard';
|
|
8
|
+
export { GrotAvatar, type GrotAvatarProps, type GrotLook } from './grots/GrotAvatar';
|
|
9
|
+
export { OpenGrotButton, type OpenGrotButtonProps } from './grots/OpenGrotButton';
|
|
10
|
+
export { GrotTopicView, type GrotTopicViewProps } from './grots/GrotTopicView';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,KAAK,6BAA6B,EAAE,MAAM,mCAAm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M,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { reportInteraction } from '@grafana/runtime';
|
|
2
|
+
function defineSdkEvent(name, { actor }) {
|
|
3
|
+
return (properties) => reportInteraction(name, { ...properties, actor });
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A caller opens the Assistant sidebar. The from field identifies the entry point.
|
|
7
|
+
*/
|
|
8
|
+
export const trackSidebarOpened = defineSdkEvent('grafana_assistant_app_opened_sidebar', { actor: 'user' });
|
|
9
|
+
/**
|
|
10
|
+
* A caller toggles the Assistant sidebar and optionally supplies a prompt.
|
|
11
|
+
*/
|
|
12
|
+
export const trackSidebarToggled = defineSdkEvent('grafana_assistant_app_toggled_sidebar', { actor: 'user' });
|
|
13
|
+
/**
|
|
14
|
+
* The SDK renders the Open Assistant button for an integration.
|
|
15
|
+
*/
|
|
16
|
+
export const trackOpenButtonDisplayed = defineSdkEvent('grafana_assistant_app_open_sidebar_button_displayed', {
|
|
17
|
+
actor: 'system',
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The SDK renders the Open Assistant split button for an integration.
|
|
21
|
+
*/
|
|
22
|
+
export const trackSplitButtonDisplayed = defineSdkEvent('grafana_assistant_app_open_sidebar_split_button_displayed', {
|
|
23
|
+
actor: 'system',
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* The SDK renders an Assistant prompt card for an integration.
|
|
27
|
+
*/
|
|
28
|
+
export const trackPromptCardDisplayed = defineSdkEvent('grafana_assistant_app_prompt_card_displayed', {
|
|
29
|
+
actor: 'system',
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=analyticsEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyticsEvents.js","sourceRoot":"","sources":["../../src/analyticsEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAcrD,SAAS,cAAc,CACrB,IAAY,EACZ,EAAE,KAAK,EAAqB;IAE5B,OAAO,CAAC,UAAsB,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACvF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5G;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAK/C,uCAAuC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC,qDAAqD,EAAE;IAC5G,KAAK,EAAE,QAAQ;CAChB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,cAAc,CAAC,2DAA2D,EAAE;IACnH,KAAK,EAAE,QAAQ;CAChB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC,6CAA6C,EAAE;IACpG,KAAK,EAAE,QAAQ;CAChB,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { Button, IconButton, useStyles2 } from '@grafana/ui';
|
|
4
4
|
import { css } from '@emotion/css';
|
|
5
5
|
import { useAssistant } from '../../hook';
|
|
6
|
-
import {
|
|
6
|
+
import { trackOpenButtonDisplayed } from '../../analyticsEvents';
|
|
7
7
|
/**
|
|
8
8
|
* A button component that opens the Grafana Assistant with configurable prompt and context.
|
|
9
9
|
*/
|
|
@@ -19,20 +19,21 @@ export function OpenAssistantButton(props) {
|
|
|
19
19
|
* Presentational component separated from OpenAssistantButton to avoid hook dependencies in previews.
|
|
20
20
|
* It is not exported for users of the package.
|
|
21
21
|
*/
|
|
22
|
-
export function OpenAssistantButtonView({ prompt, origin, context, autoSend = true, title = 'Analyze with Assistant', size = 'sm', iconOnlyButton = false, openAssistant, onClick, }) {
|
|
22
|
+
export function OpenAssistantButtonView({ prompt, origin, context, autoSend = true, title = 'Analyze with Assistant', size = 'sm', iconOnlyButton = false, iconOnlyVariant = 'ghost', openAssistant, onClick, }) {
|
|
23
23
|
const styles = useStyles2(getStyles);
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
|
|
25
|
+
trackOpenButtonDisplayed({
|
|
26
26
|
from: origin,
|
|
27
27
|
});
|
|
28
28
|
}, [origin]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const handleClick = () => {
|
|
30
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
31
|
+
openAssistant({ prompt, context, autoSend, origin });
|
|
32
|
+
};
|
|
33
|
+
if (iconOnlyButton && iconOnlyVariant === 'bordered') {
|
|
34
|
+
return (_jsx(Button, { icon: "ai-sparkle", onClick: handleClick, variant: "secondary", fill: "solid", size: size, tooltip: title, "aria-label": title, "data-testid": "assistant-bordered-icon-button" }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsx(_Fragment, { children: iconOnlyButton ? (_jsx(IconButton, { name: "ai-sparkle", onClick: handleClick, variant: "secondary", size: size, "aria-label": title, className: styles.icon, tooltip: title, "data-testid": "assistant-icon-button" })) : (_jsx(Button, { icon: "ai-sparkle", onClick: handleClick, variant: "secondary", fill: "solid", size: size, title: title, "aria-label": title, className: styles.button, "data-testid": "assistant-button", children: title })) }));
|
|
36
37
|
}
|
|
37
38
|
const getStyles = (theme) => {
|
|
38
39
|
const baseBackground = theme.colors.secondary.main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAssistantButton.js","sourceRoot":"","sources":["../../../../src/components/button/OpenAssistantButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OpenAssistantButton.js","sourceRoot":"","sources":["../../../../src/components/button/OpenAssistantButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AA0BjE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,kDAAkD;IAClD,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE,CAAC;IACtD,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAC,uBAAuB,OAAK,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,GAAG,IAAI,EACf,KAAK,GAAG,wBAAwB,EAChC,IAAI,GAAG,IAAI,EACX,cAAc,GAAG,KAAK,EACtB,eAAe,GAAG,OAAO,EACzB,aAAa,EACb,OAAO,GAGR;IACC,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,wBAAwB,CAAC;YACvB,IAAI,EAAE,MAAM;SACb,CAAC,C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ACV,GAAG,oBAAoB,CAAC,cAAc,CAAC;gBACvC,UAAU,EAAE,MAAM;aACnB;YACD,SAAS,EAAE;gBACT,UAAU,EAAE,iBAAiB;aAC9B;YACD,gBAAgB,EAAE;gBAChB,UAAU,EAAE,mBAAmB,kBAAkB,KAAK,kBAAkB,MAAM,eAAe,EAAE;aAChG;SACF,CAAC;QACF,IAAI,EAAE,GAAG,CAAC;YACR,KAAK,EAAE,gBAAgB;YACvB,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,SAAS;YACpB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAC3B,WAAW,EAAE,EAAE,GAAG,mBAAmB,EAAE,UAAU,EAAE,sBAAsB,EAAE;YAC3E,gBAAgB,EAAE;gBAChB,GAAG,oBAAoB,CAAC,cAAc,CAAC;gBACvC,UAAU,EAAE,mBAAmB,kBAAkB,KAAK,kBAAkB,MAAM,eAAe,EAAE;aAChG;SACF,CAAC;KACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { Button, ButtonGroup, Dropdown, Tooltip, useStyles2 } from '@grafana/ui';
|
|
4
4
|
import { css, cx } from '@emotion/css';
|
|
5
5
|
import { useAssistant } from '../../hook';
|
|
6
|
-
import {
|
|
6
|
+
import { trackSplitButtonDisplayed } from '../../analyticsEvents';
|
|
7
7
|
const defaultDropdownButtonWidths = {
|
|
8
8
|
sm: 32,
|
|
9
9
|
md: 36,
|
|
@@ -25,7 +25,7 @@ export function OpenAssistantSplitButtonView({ prompt, origin, context, autoSend
|
|
|
25
25
|
const hasMenuItems = Boolean(menuItems);
|
|
26
26
|
const resolvedDropdownButtonWidth = toCssWidth(dropdownButtonWidth !== null && dropdownButtonWidth !== void 0 ? dropdownButtonWidth : defaultDropdownButtonWidths[size]);
|
|
27
27
|
useEffect(() => {
|
|
28
|
-
|
|
28
|
+
trackSplitButtonDisplayed({
|
|
29
29
|
from: origin,
|
|
30
30
|
});
|
|
31
31
|
}, [origin]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAssistantSplitButton.js","sourceRoot":"","sources":["../../../../src/components/button/OpenAssistantSplitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OpenAssistantSplitButton.js","sourceRoot":"","sources":["../../../../src/components/button/OpenAssistantSplitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AA2BlE,MAAM,2BAA2B,GAAwC;IACvE,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACP,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE,CAAC;IACtD,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO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,WAAW;SAC1B,CAAC;QACF,eAAe,EAAE,GAAG,CAAC;YACnB,KAAK,EAAE,mCAAmC;YAC1C,mBAAmB,EAAE,WAAW;YAChC,sBAAsB,EAAE,WAAW;YACnC,oBAAoB,EAAE,CAAC;YACvB,uBAAuB,EAAE,CAAC;SAC3B,CAAC;QACF,cAAc,EAAE,GAAG,CAAC;YAClB,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,GAAG,EAAE,CAAC;YACN,mBAAmB,EAAE,CAAC;YACtB,sBAAsB,EAAE,CAAC;YACzB,oBAAoB,EAAE,WAAW;YACjC,uBAAuB,EAAE,WAAW;YACpC,OAAO,EAAE,cAAc;YACvB,SAAS,EAAE,iBAAiB,YAAY,EAAE;YAC1C,OAAO,EAAE;gBACP,MAAM,EAAE,CAAC;aACV;SACF,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,UAAU,CAAC,KAAsB;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
import { useStyles2 } from '@grafana/ui';
|
|
4
|
+
import { appearanceOf, classicLook, grotOptions, partOrder } from '../../grots/avatar/appearance';
|
|
5
|
+
import { spriteSvgDataUrl } from '../../grots/avatar/sprite';
|
|
6
|
+
function lookOf({ grot, look }) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (typeof look === 'object') {
|
|
9
|
+
const result = { ...classicLook };
|
|
10
|
+
for (const part of partOrder) {
|
|
11
|
+
const option = grotOptions[part].find((o) => o === look[part]);
|
|
12
|
+
if (option) {
|
|
13
|
+
result[part] = option;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
return appearanceOf({ id: (_a = grot === null || grot === void 0 ? void 0 : grot.id) !== null && _a !== void 0 ? _a : '', avatar: look !== null && look !== void 0 ? look : grot === null || grot === void 0 ? void 0 : grot.avatar });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A Grot at rest, drawn from its look. It is an image with an accessible name.
|
|
22
|
+
*
|
|
23
|
+
* @experimental This API is under active development and may change in future releases.
|
|
24
|
+
*/
|
|
25
|
+
export function GrotAvatar(props) {
|
|
26
|
+
var _a;
|
|
27
|
+
var _b;
|
|
28
|
+
const { size = 32, title } = props;
|
|
29
|
+
const styles = useStyles2(getStyles);
|
|
30
|
+
const label = (_b = title !== null && title !== void 0 ? title : (_a = props.grot) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'Grot';
|
|
31
|
+
const src = spriteSvgDataUrl(lookOf(props));
|
|
32
|
+
return _jsx("img", { className: styles.image, src: src, width: size, height: size, alt: label });
|
|
33
|
+
}
|
|
34
|
+
const getStyles = () => ({
|
|
35
|
+
image: css({ display: 'block', flexShrink: 0, imageRendering: 'pixelated' }),
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=GrotAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrotAvatar.js","sourceRoot":"","sources":["../../../../src/components/grots/GrotAvatar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAmB,MAAM,+BAA+B,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAuB7D,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAA0C;;IACpE,IAAI,OAAO,IAAI,KAAK,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;IACvB,KAAK,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;CAC7E,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { config, usePluginComponent } from '@grafana/runtime';
|
|
3
|
+
import { Alert, LinkButton, LoadingPlaceholder } from '@grafana/ui';
|
|
4
|
+
import { ASSISTANT_PLUGIN_ID } from '../../plugin';
|
|
5
|
+
/** The Assistant app's exposed component this view renders. Add it to your plugin.json's `dependencies.extensions.exposedComponents`. */
|
|
6
|
+
export const GROT_TOPIC_COMPONENT_ID = `${ASSISTANT_PLUGIN_ID}/grot-topic/v1`;
|
|
7
|
+
/**
|
|
8
|
+
* One of the signed-in person's topics with a Grot, read only, drawn by the Grafana Assistant app: the Grots page's own
|
|
9
|
+
* conversation, so it changes when that page does. It fills its container's height and scrolls inside it, so give the
|
|
10
|
+
* container a height. Needs read access to the Grot and its direct chats, and an Assistant app that exposes
|
|
11
|
+
* `grafana-assistant-app/grot-topic/v1`.
|
|
12
|
+
* @experimental This API is under active development and may change in future releases.
|
|
13
|
+
*/
|
|
14
|
+
export function GrotTopicView({ grotId, topic }) {
|
|
15
|
+
var _a;
|
|
16
|
+
const { component: Topic, isLoading } = usePluginComponent(GROT_TOPIC_COMPONENT_ID);
|
|
17
|
+
if (isLoading) {
|
|
18
|
+
return _jsx(LoadingPlaceholder, { text: "Loading messages" });
|
|
19
|
+
}
|
|
20
|
+
if (!Topic) {
|
|
21
|
+
return (_jsxs(Alert, { severity: "info", title: "Grot topics aren't available", children: ["Update Grafana Assistant to show this topic here.", ' ', _jsx(LinkButton, { href: `${(_a = config.appSubUrl) !== null && _a !== void 0 ? _a : ''}/plugins/${ASSISTANT_PLUGIN_ID}`, variant: "secondary", size: "sm", children: "Open the Assistant plugin page" })] }));
|
|
22
|
+
}
|
|
23
|
+
return _jsx(Topic, { grotId: grotId, topic: topic.number });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=GrotTopicView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrotTopicView.js","sourceRoot":"","sources":["../../../../src/components/grots/GrotTopicView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,yIAAyI;AACzI,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,mBAAmB,gBAAgB,CAAC;AAc9E;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,MAAM,EAAE,KAAK,EAAsB;;IACjE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAe,uBAAuB,CAAC,CAAC;IAClG,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,KAAC,kBAAkB,IAAC,IAAI,EAAC,kBAAkB,GAAG,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CACL,MAAC,KAAK,IAAC,QAAQ,EAAC,MAAM,EAAC,KAAK,EAAC,8BAA8B,kEACP,GAAG,EACrD,KAAC,UAAU,IAAC,IAAI,EAAE,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,YAAY,mBAAmB,EAAE,EAAE,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,+CAE9F,IACP,CACT,CAAC;IACJ,CAAC;IACD,OAAO,KAAC,KAAK,IAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,GAAI,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { config, locationService } from '@grafana/runtime';
|
|
3
|
+
import { LinkButton } from '@grafana/ui';
|
|
4
|
+
import { ASSISTANT_PLUGIN_ID } from '../../plugin';
|
|
5
|
+
/**
|
|
6
|
+
* The link the Grots page opens a Grot or topic from: `?assistantGrot=<id>&assistantTopic=<number>` on the Grots page
|
|
7
|
+
* (`WORKSPACE_GROT_PARAM`, `WORKSPACE_TOPIC_PARAM` and `GROTS_BASE_URL` in the plugin's `constants.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export function grotHref(grotId, topic) {
|
|
10
|
+
var _a;
|
|
11
|
+
const params = new URLSearchParams({ assistantGrot: grotId });
|
|
12
|
+
if (topic !== undefined) {
|
|
13
|
+
params.set('assistantTopic', String(topic));
|
|
14
|
+
}
|
|
15
|
+
return `${(_a = config.appSubUrl) !== null && _a !== void 0 ? _a : ''}/a/${ASSISTANT_PLUGIN_ID}/lab/grots?${params}`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Opens a Grot, and optionally one of its topics, on the Grafana Assistant's Grots page.
|
|
19
|
+
*
|
|
20
|
+
* @experimental This API is under active development and may change in future releases.
|
|
21
|
+
*/
|
|
22
|
+
export function OpenGrotButton({ grotId, topic, label = 'Open Grot', variant = 'secondary', size = 'md', }) {
|
|
23
|
+
const href = grotHref(grotId, topic);
|
|
24
|
+
// LinkButton types onClick for both its anchor and button forms, so take the shared HTMLElement event.
|
|
25
|
+
const onClick = (event) => {
|
|
26
|
+
var _a;
|
|
27
|
+
// Keep new-tab and modified clicks native; navigate in-app otherwise so Grafana does not reload.
|
|
28
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
locationService.push(href.slice(((_a = config.appSubUrl) !== null && _a !== void 0 ? _a : '').length));
|
|
33
|
+
};
|
|
34
|
+
return (_jsx(LinkButton, { href: href, onClick: onClick, variant: variant, size: size, icon: "arrow-right", children: label }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=OpenGrotButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenGrotButton.js","sourceRoot":"","sources":["../../../../src/components/grots/OpenGrotButton.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcnD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,KAAc;;IACrD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,MAAM,mBAAmB,cAAc,MAAM,EAAE,CAAC;AAClF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,GAAG,WAAW,EACnB,OAAO,GAAG,WAAW,EACrB,IAAI,GAAG,IAAI,GACS;IACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,uGAAuG;IACvG,MAAM,OAAO,GAAG,CAAC,KAA8B,EAAE,EAAE;;QACjD,iGAAiG;QACjG,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3F,OAAO;QACT,CAAC;QACD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAC,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC;IACF,OAAO,CACL,KAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,aAAa,YACvF,KAAK,GACK,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -5,4 +5,7 @@ export { AITextArea } from './input/AITextArea';
|
|
|
5
5
|
export { useAIGeneration } from './input/useAIGeneration';
|
|
6
6
|
export { QueryWithAssistantButton } from './button/QueryWithAssistantButton';
|
|
7
7
|
export { AssistantPromptCard, AssistantPromptCardView, } from './prompt-card/AssistantPromptCard';
|
|
8
|
+
export { GrotAvatar } from './grots/GrotAvatar';
|
|
9
|
+
export { OpenGrotButton } from './grots/OpenGrotButton';
|
|
10
|
+
export { GrotTopicView } from './grots/GrotTopicView';
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiC,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAsC,MAAM,mCAAmC,CAAC;AACjH,OAAO,EAAE,WAAW,EAAyB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,eAAe,EAA+B,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAsC,MAAM,mCAAmC,CAAC;AACjH,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GAGxB,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiC,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAsC,MAAM,mCAAmC,CAAC;AACjH,OAAO,EAAE,WAAW,EAAyB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,eAAe,EAA+B,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAsC,MAAM,mCAAmC,CAAC;AACjH,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GAGxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAuC,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,cAAc,EAA4B,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,aAAa,EAA2B,MAAM,uBAAuB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import { IconButton, Input, useStyles2 } from '@grafana/ui';
|
|
4
4
|
import { css, cx, keyframes } from '@emotion/css';
|
|
5
|
-
import {
|
|
5
|
+
import { trackPromptCardDisplayed } from '../../analyticsEvents';
|
|
6
6
|
import { useAssistant } from '../../hook';
|
|
7
7
|
import { createBorderAnimation, getBackgroundGradientColors } from '../../utils/theme';
|
|
8
8
|
import { useAnimatedPlaceholder, DEFAULT_EXAMPLE_PROMPTS } from './useAnimatedPlaceholder';
|
|
@@ -25,7 +25,7 @@ export function AssistantPromptCardView({ origin, context, mode, placeholder, ex
|
|
|
25
25
|
const staticPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : 'Ask Assistant...';
|
|
26
26
|
const animatedPlaceholder = useAnimatedPlaceholder(staticPlaceholder, resolvedPrompts, prompt.length > 0);
|
|
27
27
|
useEffect(() => {
|
|
28
|
-
|
|
28
|
+
trackPromptCardDisplayed({ from: origin });
|
|
29
29
|
}, [origin]);
|
|
30
30
|
// biome-ignore lint/correctness/useExhaustiveDependencies: context is an intentional re-trigger to re-focus the input when the context changes
|
|
31
31
|
useEffect(() => {
|