@grafana/assistant 0.1.34 → 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 +296 -42
- package/dist/analyticsEvents.d.ts +33 -0
- package/dist/analyticsEvents.d.ts.map +1 -0
- package/dist/components/button/OpenAssistantButton.d.ts +9 -4
- package/dist/components/button/OpenAssistantButton.d.ts.map +1 -1
- package/dist/components/button/OpenAssistantSplitButton.d.ts +2 -2
- package/dist/components/button/OpenAssistantSplitButton.d.ts.map +1 -1
- package/dist/components/button/QueryWithAssistantButton.d.ts +2 -2
- package/dist/components/button/QueryWithAssistantButton.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/components/input/AITextArea.d.ts +1 -1
- package/dist/components/input/AITextArea.d.ts.map +1 -1
- package/dist/components/input/AITextInput.d.ts +1 -1
- package/dist/components/input/AITextInput.d.ts.map +1 -1
- package/dist/components/input/useAIGeneration.d.ts.map +1 -1
- package/dist/components/prompt-card/AssistantPromptCard.d.ts +2 -2
- package/dist/components/prompt-card/AssistantPromptCard.d.ts.map +1 -1
- package/dist/context/agentSkill.d.ts +69 -0
- package/dist/context/agentSkill.d.ts.map +1 -0
- package/dist/context/base.d.ts.map +1 -1
- package/dist/context/chat.d.ts.map +1 -1
- package/dist/context/component.d.ts.map +1 -1
- package/dist/context/dashboard.d.ts.map +1 -1
- package/dist/context/datasource.d.ts.map +1 -1
- package/dist/context/entity.d.ts.map +1 -1
- package/dist/context/factory.d.ts.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/label.d.ts.map +1 -1
- package/dist/context/page.d.ts.map +1 -1
- package/dist/context/skill.d.ts.map +1 -1
- package/dist/context/types.d.ts +15 -1
- package/dist/context/types.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 +13 -12
- package/dist/esm/components/button/OpenAssistantButton.js.map +1 -1
- package/dist/esm/components/button/OpenAssistantSplitButton.js +3 -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/input/useAIGeneration.js +14 -1
- package/dist/esm/components/input/useAIGeneration.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/context/agentSkill.js +70 -0
- package/dist/esm/context/agentSkill.js.map +1 -0
- package/dist/esm/context/base.js.map +1 -1
- package/dist/esm/context/chat.js +1 -0
- package/dist/esm/context/chat.js.map +1 -1
- package/dist/esm/context/component.js.map +1 -1
- package/dist/esm/context/factory.js +6 -4
- package/dist/esm/context/factory.js.map +1 -1
- package/dist/esm/context/index.js +1 -0
- package/dist/esm/context/index.js.map +1 -1
- package/dist/esm/context/page.js.map +1 -1
- package/dist/esm/context/questions.js +20 -26
- package/dist/esm/context/questions.js.map +1 -1
- package/dist/esm/extension/extension.js +7 -8
- package/dist/esm/extension/extension.js.map +1 -1
- package/dist/esm/extension/index.js +2 -1
- package/dist/esm/extension/index.js.map +1 -1
- package/dist/esm/extension/suggestionContexts.js +35 -0
- package/dist/esm/extension/suggestionContexts.js.map +1 -0
- 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 +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/inline/index.js.map +1 -1
- package/dist/esm/inline/inlineAssistant.js +1 -1
- package/dist/esm/inline/inlineAssistant.js.map +1 -1
- package/dist/esm/inline/useInlineAssistant.js +8 -3
- package/dist/esm/inline/useInlineAssistant.js.map +1 -1
- package/dist/esm/investigations/api.gen.js +6 -0
- package/dist/esm/investigations/api.gen.js.map +1 -0
- package/dist/esm/investigations/client.js +76 -0
- package/dist/esm/investigations/client.js.map +1 -0
- package/dist/esm/investigations/index.js +3 -0
- package/dist/esm/investigations/index.js.map +1 -0
- package/dist/esm/investigations/observe.js +204 -0
- package/dist/esm/investigations/observe.js.map +1 -0
- package/dist/esm/investigations/types.js +2 -0
- package/dist/esm/investigations/types.js.map +1 -0
- package/dist/esm/k6.js.map +1 -1
- package/dist/esm/lens/investigationLens.js +1 -1
- package/dist/esm/lens/investigationLens.js.map +1 -1
- package/dist/esm/lens/useInvestigationThroughLens.js +3 -1
- package/dist/esm/lens/useInvestigationThroughLens.js.map +1 -1
- package/dist/esm/limits/index.js +1 -1
- package/dist/esm/limits/index.js.map +1 -1
- package/dist/esm/pathfinder.js +41 -0
- package/dist/esm/pathfinder.js.map +1 -0
- package/dist/esm/sidebar.js +44 -23
- package/dist/esm/sidebar.js.map +1 -1
- package/dist/esm/terms/index.js +43 -5
- package/dist/esm/terms/index.js.map +1 -1
- package/dist/esm/tools/toolFactory.js.map +1 -1
- package/dist/esm/utils/errorHandling.js.map +1 -1
- package/dist/esm/utils/theme.js +11 -1
- package/dist/esm/utils/theme.js.map +1 -1
- package/dist/extension/extension.d.ts +206 -114
- package/dist/extension/extension.d.ts.map +1 -1
- package/dist/extension/index.d.ts +2 -1
- package/dist/extension/index.d.ts.map +1 -1
- package/dist/extension/suggestionContexts.d.ts +36 -0
- package/dist/extension/suggestionContexts.d.ts.map +1 -0
- 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 +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inline/index.d.ts +1 -1
- package/dist/inline/index.d.ts.map +1 -1
- package/dist/inline/inlineAssistant.d.ts +19 -6
- package/dist/inline/inlineAssistant.d.ts.map +1 -1
- package/dist/inline/useInlineAssistant.d.ts +5 -1
- package/dist/inline/useInlineAssistant.d.ts.map +1 -1
- package/dist/investigations/api.gen.d.ts +1872 -0
- package/dist/investigations/api.gen.d.ts.map +1 -0
- package/dist/investigations/client.d.ts +8 -0
- package/dist/investigations/client.d.ts.map +1 -0
- package/dist/investigations/index.d.ts +5 -0
- package/dist/investigations/index.d.ts.map +1 -0
- package/dist/investigations/observe.d.ts +10 -0
- package/dist/investigations/observe.d.ts.map +1 -0
- package/dist/investigations/types.d.ts +26 -0
- package/dist/investigations/types.d.ts.map +1 -0
- package/dist/lens/investigationLens.d.ts +0 -5
- package/dist/lens/investigationLens.d.ts.map +1 -1
- package/dist/lens/useInvestigationThroughLens.d.ts.map +1 -1
- package/dist/pathfinder.d.ts +41 -0
- package/dist/pathfinder.d.ts.map +1 -0
- package/dist/sidebar.d.ts +15 -0
- package/dist/sidebar.d.ts.map +1 -1
- package/dist/terms/index.d.ts +8 -0
- package/dist/terms/index.d.ts.map +1 -1
- package/dist/terms/settings.gen.d.ts +470 -89
- package/dist/terms/settings.gen.d.ts.map +1 -1
- package/dist/tools/types.d.ts +3 -3
- package/dist/utils/theme.d.ts.map +1 -1
- package/package.json +21 -18
package/README.md
CHANGED
|
@@ -69,6 +69,20 @@ openAssistant({
|
|
|
69
69
|
origin: 'grafana-slo-app/some-page',
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
+
// Open a new conversation with one Agent Skill already attached, named by the token a user
|
|
73
|
+
// types after `/`. Never a handle or the server-issued selection id.
|
|
74
|
+
//
|
|
75
|
+
// This is a request, not a grant: the composer resolves the name against the catalog that user
|
|
76
|
+
// may already attach from, so an unknown, switched-off or unsupported name attaches nothing and
|
|
77
|
+
// says so, without revealing which. Naming a skill never auto-sends — whoever opens the link
|
|
78
|
+
// sees what it attached before anything reaches the model — and pins Assistant mode unless a
|
|
79
|
+
// `mode` is given. Ignored alongside `chatId`; a skill attaches to a new conversation only.
|
|
80
|
+
openAssistant({
|
|
81
|
+
origin: 'grafana-pathfinder-app/authoring-link',
|
|
82
|
+
prompt: 'Turn these steps into an interactive guide',
|
|
83
|
+
agentSkillInvocationName: 'pathfinder-authoring',
|
|
84
|
+
});
|
|
85
|
+
|
|
72
86
|
// Close the assistant
|
|
73
87
|
closeAssistant();
|
|
74
88
|
```
|
|
@@ -464,64 +478,57 @@ const namespace = newFunctionNamespace('myPlugin', myFunctions);
|
|
|
464
478
|
export const getExtensionConfigs = () => [getExposeAssistantFunctionsConfig([namespace])];
|
|
465
479
|
```
|
|
466
480
|
|
|
467
|
-
### Contributing Assistant
|
|
468
|
-
|
|
469
|
-
> **Experimental:** this API is under active development and may change in future releases. It requires a Grafana version with `AppPlugin.addFunction()` / `addedFunctions` support (February 2025+, covered by this package's `>=12.1.0` peer dependency floor).
|
|
481
|
+
### Contributing Assistant extensions (experimental)
|
|
470
482
|
|
|
471
|
-
An app plugin can
|
|
483
|
+
An app plugin can add conversation starters, expanded tool details, inline reply components, and custom artifact renderers to Grafana Assistant. Register one `AssistantExtensionManifest` with `getAssistantExtensionConfig`:
|
|
472
484
|
|
|
473
485
|
```typescript
|
|
474
486
|
import { AppPlugin } from '@grafana/data';
|
|
475
|
-
import { getAssistantExtensionConfig, AssistantExtensionManifest } from '@grafana/assistant';
|
|
487
|
+
import { SuggestionContext, getAssistantExtensionConfig, type AssistantExtensionManifest } from '@grafana/assistant';
|
|
476
488
|
|
|
477
489
|
const manifest: AssistantExtensionManifest = {
|
|
478
490
|
schemaVersion: 1,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
title: 'Author a check',
|
|
485
|
-
description: 'Step-by-step workflow for creating a check with the myplugin tools.',
|
|
486
|
-
content: '# Author a check\n\n1. List existing checks...\n2. Draft the check...\n3. Validate before saving.',
|
|
487
|
-
},
|
|
488
|
-
],
|
|
489
|
-
artifactKinds: [
|
|
490
|
-
{
|
|
491
|
-
ext: '.grafana-myplugin-app.check',
|
|
492
|
-
label: 'Check',
|
|
493
|
-
icon: 'check',
|
|
494
|
-
tabPriority: 0, // ascending: lower promotes earlier, among your own kinds (built-ins always come first)
|
|
495
|
-
validate: (data) => isCheck(data),
|
|
496
|
-
renderer: CheckRenderer,
|
|
497
|
-
},
|
|
498
|
-
],
|
|
499
|
-
promptContributions: [
|
|
500
|
-
{
|
|
501
|
-
modeId: 'authoring',
|
|
502
|
-
label: 'Check authoring',
|
|
503
|
-
description: 'Author checks with guided help',
|
|
504
|
-
whenToUse: 'When the user asks to create or edit checks',
|
|
505
|
-
compose: 'append',
|
|
506
|
-
prompt: 'You can author checks using the myplugin tools.',
|
|
507
|
-
},
|
|
508
|
-
],
|
|
491
|
+
starters: [{
|
|
492
|
+
label: 'Review service errors',
|
|
493
|
+
message: 'Help me review recent service errors in this stack.',
|
|
494
|
+
contexts: [SuggestionContext.Alerting, SuggestionContext.Logs, SuggestionContext.Workspace],
|
|
495
|
+
}],
|
|
509
496
|
};
|
|
510
497
|
|
|
511
498
|
export const plugin = new AppPlugin().addFunction(getAssistantExtensionConfig(manifest));
|
|
512
499
|
```
|
|
513
500
|
|
|
514
|
-
|
|
501
|
+
Starter `contexts` is an optional list of `SuggestionContext` values exported by `@grafana/assistant`. A starter is eligible when any listed context matches the current route (including nested routes). Eligible plugin starters share randomized selection with built-in route suggestions in the sidebar and Workspace; registration does not guarantee a visible slot. Omit `contexts` to limit the starter to the contributing plugin’s `/a/<pluginId>` routes. An empty list disables the starter. Invalid contexts cause the host to drop that starter rather than broaden its scope. Generic suggestions fill remaining slots.
|
|
502
|
+
|
|
503
|
+
Also add these fields to your existing `plugin.json`:
|
|
504
|
+
|
|
505
|
+
```json
|
|
506
|
+
{
|
|
507
|
+
"preload": true,
|
|
508
|
+
"extensions": {
|
|
509
|
+
"addedFunctions": [{
|
|
510
|
+
"title": "assistant-extension",
|
|
511
|
+
"targets": ["grafana-assistant-app/extension/v1"]
|
|
512
|
+
}]
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Use Grafana 12.1 or later and an Assistant environment with `assistant.frontend.plugin-extensions` enabled. `preload: true` supports Grafana 12.1, whose extension loader doesn't discover function-only declarations. Add the function to your existing `AppPlugin` if you already have one. Keep the manifest and its component/function references stable after registration.
|
|
518
|
+
|
|
519
|
+
Use `starters` for attributed first messages on empty chats; use `provideQuestions` for page-specific suggestions. The supported `chits` kinds are `tool-details` and `inline`. Artifact writes use `artifact_files`; renderers receive a read-only conversation filesystem.
|
|
515
520
|
|
|
516
|
-
|
|
521
|
+
The manifest also accepts `skills` and `promptContributions`. Skills currently appear in settings but aren't loaded by the model. Modes require `assistant.frontend.plugin-extensions-prompt` and your plugin ID in `assistant.frontend.plugin-extensions-prompt-allowlist`, in addition to the master flag. An operator can disable all contributions with `assistant.frontend.plugin-extensions-enabled.<pluginId>`.
|
|
517
522
|
|
|
518
|
-
|
|
523
|
+
Browser registration does not enable skill activation, even when the builtin Agent Skills runtime is enabled. The proposed plugin activation contract requires trusted server integration and a supported runtime surface. Automatic discovery additionally requires a short author hint, `whenToUse`, which is not yet part of this SDK. Existing manifests remain valid for inspection and would be manual-only without a hint once manual plugin activation ships.
|
|
519
524
|
|
|
520
|
-
|
|
525
|
+
Inline components can supply `prompt` (up to 4096 UTF-8 bytes) to explain when to emit their tag in normal chat, without selecting a mode. This is attributed chat context, not a system-prompt override. Set `selfClosing: true` for a childless marker such as `<grafana_myplugin_app_result name="checkout" />`; the host recovers saved bare/backticked tag names and suppresses identical duplicates outside code.
|
|
521
526
|
|
|
522
|
-
Use
|
|
527
|
+
Use `InlineChitProps` to receive `turn.isStreaming` and `turn.tools` (message-local tool names, IDs, and unknown inputs). Validate inputs in your plugin. A stopped turn is also non-streaming; this is not a success signal. Older hosts omit `turn` and ignore the new fields. The [inline integration example](../../../docs/sources/reference/plugin-extensions.md#use-tool-inputs-and-wait-for-the-turn) shows how to keep a scene stable after its first settled render.
|
|
523
528
|
|
|
524
|
-
|
|
529
|
+
For a larger view, add `display: 'block'` with `selfClosing: true`. It uses the same tag but renders below the message text, outside Markdown paragraphs, at the available message width with keyboard-accessible horizontal scrolling. Omitted `display` keeps inline placement. `InlineChitDisplay` exports the two display values.
|
|
530
|
+
|
|
531
|
+
This API is experimental and may change between releases. For contribution examples, ownership rules, limits, and troubleshooting, refer to the [plugin extensions guide](../../../docs/sources/reference/plugin-extensions.md).
|
|
525
532
|
|
|
526
533
|
### Using the OpenAssistantButton Component
|
|
527
534
|
|
|
@@ -556,6 +563,15 @@ function MyDashboard() {
|
|
|
556
563
|
origin="grafana-datasources/loki/query-editor"
|
|
557
564
|
/>
|
|
558
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
|
+
|
|
559
575
|
{/* Button without auto-send */}
|
|
560
576
|
<OpenAssistantButton
|
|
561
577
|
prompt="What patterns do you see in the data?"
|
|
@@ -711,6 +727,7 @@ A pre-built React component that renders a button to open the Grafana Assistant
|
|
|
711
727
|
- `title?: string` - Text to display on the button (defaults to `'Analyze with Assistant'`)
|
|
712
728
|
- `size?: 'xs' | 'sm' | 'md' | 'lg'` - Button size (defaults to `'sm'`)
|
|
713
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'`)
|
|
714
731
|
|
|
715
732
|
#### `<QueryWithAssistantButton />`
|
|
716
733
|
|
|
@@ -1029,6 +1046,229 @@ export function WeatherComponent() {
|
|
|
1029
1046
|
}
|
|
1030
1047
|
```
|
|
1031
1048
|
|
|
1049
|
+
#### Configuring the agent and calling it without React
|
|
1050
|
+
|
|
1051
|
+
By default the inline assistant suits short content generation: at most 5 model calls per prompt, the smaller model, no reasoning, and 4096 output tokens per call.
|
|
1052
|
+
For agentic work, such as discovery with your own tools before answering, pass an `InlineAssistantConfig` to `useInlineAssistant(config)` or, without React, to the inline assistant factory.
|
|
1053
|
+
The config is fixed for the life of the instance and applies to every prompt sent to it.
|
|
1054
|
+
|
|
1055
|
+
| Field | Allowed values | Default |
|
|
1056
|
+
| --- | --- | --- |
|
|
1057
|
+
| `maxSteps` | integer from 1 to 76; the agent stops after the last model call | `5` |
|
|
1058
|
+
| `weak` | `true` for the smaller, faster model, `false` for the standard one | `true` |
|
|
1059
|
+
| `reasoningLevel` | `'none'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`, `'max'` | `'none'` |
|
|
1060
|
+
| `maxTokens` | integer from 1 to 16000 output tokens per model call | `4096` |
|
|
1061
|
+
|
|
1062
|
+
`ensureInlineAssistantInitialized` loads the implementation on first use.
|
|
1063
|
+
The factory returns an `InlineAssistant` that owns one conversation: each `sendPrompt` continues it, so you can answer a question the model asked in the next prompt.
|
|
1064
|
+
Call `dispose()` when you are done.
|
|
1065
|
+
|
|
1066
|
+
```typescript
|
|
1067
|
+
import { ensureInlineAssistantInitialized, getInlineAssistantFactory } from '@grafana/assistant';
|
|
1068
|
+
|
|
1069
|
+
await ensureInlineAssistantInitialized();
|
|
1070
|
+
const assistant = await getInlineAssistantFactory()('my-plugin/planner', {
|
|
1071
|
+
maxSteps: 30,
|
|
1072
|
+
weak: false,
|
|
1073
|
+
reasoningLevel: 'medium',
|
|
1074
|
+
maxTokens: 8000,
|
|
1075
|
+
});
|
|
1076
|
+
try {
|
|
1077
|
+
await assistant.sendPrompt({
|
|
1078
|
+
prompt: 'Plan the checks for this requirement: ...',
|
|
1079
|
+
systemPrompt: 'Explore with the tools, then call submit_plan once.',
|
|
1080
|
+
tools: [listDatasourcesTool, queryTool, submitPlanTool],
|
|
1081
|
+
onComplete: (text) => console.log(text),
|
|
1082
|
+
onError: (err) => console.error(err),
|
|
1083
|
+
});
|
|
1084
|
+
} finally {
|
|
1085
|
+
assistant.dispose();
|
|
1086
|
+
}
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
The implementation comes from the installed Grafana Assistant, which can be older than your copy of the SDK.
|
|
1090
|
+
Releases that predate `InlineAssistantConfig` ignore it and run with the defaults.
|
|
1091
|
+
An invalid value makes the factory reject before any conversation is created; the hook reports it through `onError` and `error`.
|
|
1092
|
+
|
|
1093
|
+
### Creating and monitoring investigations
|
|
1094
|
+
|
|
1095
|
+
Use `createInvestigation`, `getInvestigationStatus`, and `getInvestigationReport` from a Grafana plugin. These methods call the public-preview v2 API through Grafana's plugin proxy as the signed-in user. They require a backend with the v2 investigation routes enabled. Do not embed service account tokens in browser code; use the [HTTP API](../../../docs/sources/reference/http-apis/_index.md#manage-investigations) for server-side integrations.
|
|
1096
|
+
|
|
1097
|
+
```typescript
|
|
1098
|
+
import { createInvestigation, getInvestigationStatus, getInvestigationReport } from '@grafana/assistant';
|
|
1099
|
+
|
|
1100
|
+
// Call from an explicit user action. The caller awaits and handles failures.
|
|
1101
|
+
async function startInvestigation(signal: AbortSignal) {
|
|
1102
|
+
return createInvestigation({ instruction: 'Investigate elevated API latency' }, { signal });
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// Call on refresh or from a polling loop with an interval and a deadline.
|
|
1106
|
+
async function readInvestigation(investigationId: string, signal: AbortSignal) {
|
|
1107
|
+
const status = await getInvestigationStatus(investigationId, { signal });
|
|
1108
|
+
const report = status.state === 'completed'
|
|
1109
|
+
? await getInvestigationReport(investigationId, { signal })
|
|
1110
|
+
: undefined;
|
|
1111
|
+
return { status, report };
|
|
1112
|
+
}
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
| Method | Result |
|
|
1116
|
+
| --- | --- |
|
|
1117
|
+
| `createInvestigation(input, options?)` | `CreatedInvestigation`: `investigationId` and `chatId`. Input includes required `instruction` and optional `title`, `labels`, and `teamNames`. |
|
|
1118
|
+
| `getInvestigationStatus(investigationId, options?)` | `InvestigationStatus`: identifiers, optional `state`, title, summary, and failure or completion details. |
|
|
1119
|
+
| `getInvestigationReport(investigationId, options?)` | `InvestigationReport`: `investigationId`, `reportPending`, and optional `reportSpec` and `reportContent`. |
|
|
1120
|
+
|
|
1121
|
+
Results are unwrapped from the HTTP success envelope and validated at runtime. The exported types derive from the backend OpenAPI schema. Each call makes one request; the SDK doesn't poll, retry, or display error notifications. Every method accepts `{ signal?: AbortSignal }`. Aborting stops waiting for the request; it doesn't cancel an investigation already created on the server. A failed or aborted create request can still have started an investigation, so don't retry it automatically.
|
|
1122
|
+
|
|
1123
|
+
Use the returned `investigationId` for reads. The separate `chatId` identifies the backing conversation. Poll `state`: `pending` and `in_progress` indicate ongoing work; `completed`, `failed`, and `cancelled` stop ordinary polling; `paused` needs intervention. State is an optional, open string: bound polling with a deadline and handle unfamiliar or absent states explicitly.
|
|
1124
|
+
|
|
1125
|
+
A report can be absent even when `reportPending` is false. A snapshot can return 404 before its session starts; status reads remain the lifecycle source. Report retrieval also works during an investigation when a snapshot exists. Render `reportContent` as text or sanitized Markdown, never as trusted HTML.
|
|
1126
|
+
|
|
1127
|
+
Handle rejected promises in your UI. HTTP failures preserve Grafana's `FetchError` contract (use `isFetchError` from `@grafana/runtime`); malformed responses reject with a validation error. Reads respect the signed-in user's permissions and team visibility. Refer to the HTTP reference for exact permissions and response fields. For live updates, use `observeInvestigation` below.
|
|
1128
|
+
|
|
1129
|
+
For a structured view derived from an existing report, use the lens hook below.
|
|
1130
|
+
|
|
1131
|
+
### Observing investigation progress
|
|
1132
|
+
|
|
1133
|
+
`observeInvestigation(investigationId): Observable<InvestigationEvent>` watches an existing investigation as the signed-in Grafana user. It requires the v2 investigation APIs and the authenticated chat event stream on the backend. Each subscription starts its own connection and snapshot reads; calling the function alone does no work.
|
|
1134
|
+
|
|
1135
|
+
```typescript
|
|
1136
|
+
import { observeInvestigation, type InvestigationEvent } from '@grafana/assistant';
|
|
1137
|
+
|
|
1138
|
+
// Pass your UI's update, error, and completion handlers.
|
|
1139
|
+
function watchInvestigation(
|
|
1140
|
+
investigationId: string,
|
|
1141
|
+
onEvent: (event: InvestigationEvent) => void,
|
|
1142
|
+
onError: (error: unknown) => void,
|
|
1143
|
+
onComplete: () => void,
|
|
1144
|
+
) {
|
|
1145
|
+
const subscription = observeInvestigation(investigationId).subscribe({
|
|
1146
|
+
next: onEvent,
|
|
1147
|
+
error: onError,
|
|
1148
|
+
complete: onComplete,
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
// Call when leaving the view. The investigation keeps running.
|
|
1152
|
+
return () => subscription.unsubscribe();
|
|
1153
|
+
}
|
|
1154
|
+
```
|
|
1155
|
+
|
|
1156
|
+
| Event | Payload | Meaning |
|
|
1157
|
+
| --- | --- | --- |
|
|
1158
|
+
| `status` | `event.status: InvestigationStatus` | Current persisted lifecycle state, emitted initially and when its fields change. |
|
|
1159
|
+
| `report` | `event.report: InvestigationReport` | Current persisted report snapshot, when available, emitted initially and when its fields change. |
|
|
1160
|
+
| `progress` | `investigationId`, `messageId`, `contentIndex`, `delta` | Live user-visible text. Append deltas separately for each `(messageId, contentIndex)` pair. |
|
|
1161
|
+
|
|
1162
|
+
The first event is a status snapshot. A report snapshot can be absent before the session starts. Live text can arrive while a snapshot is loading. Progress excludes tool inputs, reasoning, and private sub-agent audiences; it is best-effort text, not a complete conversation history or the report itself. Render text safely. Report events contain persisted snapshots rather than every in-flight report edit.
|
|
1163
|
+
|
|
1164
|
+
The observer refreshes persisted state after the stream connects and on relevant notifications, and reconciles about every 5 seconds while idle. Reads are serialized and identical snapshots are suppressed. Stream notifications don't override persisted lifecycle state.
|
|
1165
|
+
|
|
1166
|
+
`completed`, `failed`, and `cancelled` are terminal states. After observing a terminal state and checking the report, the Observable completes when no report is pending. A missing report does not prevent completion. `paused`, unknown, and absent states keep the subscription open. Use the status payload to distinguish success from investigation failure; `complete` means observation finished successfully, not that the investigation succeeded.
|
|
1167
|
+
|
|
1168
|
+
HTTP failures, invalid response/event data, a connection that doesn't open within 30 seconds, or a disconnected stream terminate the subscription through `error`. HTTP errors retain Grafana's `FetchError` shape. Browser event-stream errors don't expose an HTTP status. There is no automatic reconnect: subscribe again to recover current snapshots. Missed text deltas are not replayed, including text produced before the initial connection. Keep partial progress distinct from a complete transcript.
|
|
1169
|
+
|
|
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.
|
|
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
|
+
|
|
1032
1272
|
### Deriving Structured Views of Investigations (Lens)
|
|
1033
1273
|
|
|
1034
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.
|
|
@@ -1183,7 +1423,7 @@ try {
|
|
|
1183
1423
|
|
|
1184
1424
|
#### `openAssistant(props: OpenAssistantProps): void`
|
|
1185
1425
|
|
|
1186
|
-
Opens the Grafana Assistant sidebar.
|
|
1426
|
+
Opens the Grafana Assistant sidebar. Repeated calls with the same prompt and context are processed even while the sidebar remains open. Calls without `chatId` start a new conversation; calls with `chatId` target that conversation.
|
|
1187
1427
|
|
|
1188
1428
|
**Parameters:**
|
|
1189
1429
|
|
|
@@ -1656,6 +1896,20 @@ export type ComponentImplementation;
|
|
|
1656
1896
|
export type NamedComponents;
|
|
1657
1897
|
```
|
|
1658
1898
|
|
|
1899
|
+
|
|
1900
|
+
### Plugin filesystems (experimental)
|
|
1901
|
+
|
|
1902
|
+
Extension manifests can provide `filesystem: AssistantFilesystemContribution` to
|
|
1903
|
+
mount live text/JSON files at `/plugins/<registered-plugin-id>/`. Required callbacks
|
|
1904
|
+
are `read`, `list`, and `metadata`; optional `create` and conditional `write` enable
|
|
1905
|
+
mutations. Each receives the current Grafana namespace; the owning backend must
|
|
1906
|
+
authorize every operation. An optional `agentGuide` is demand-loaded as the mount's
|
|
1907
|
+
read-only `AGENT.md`.
|
|
1908
|
+
|
|
1909
|
+
Registered artifact kinds can render mounted files in the canvas. Ordinary files
|
|
1910
|
+
remain tool-accessible. Reads and listings never attach artifacts. Refer to the
|
|
1911
|
+
[filesystem contract and example](../../../docs/sources/reference/plugin-extensions.md#expose-a-filesystem).
|
|
1912
|
+
|
|
1659
1913
|
## License
|
|
1660
1914
|
|
|
1661
1915
|
Apache-2.0
|
|
@@ -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,18 +15,23 @@ 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
|
}
|
|
21
26
|
/**
|
|
22
27
|
* A button component that opens the Grafana Assistant with configurable prompt and context.
|
|
23
28
|
*/
|
|
24
|
-
export declare function OpenAssistantButton(props: OpenAssistantButtonProps): import("react
|
|
29
|
+
export declare function OpenAssistantButton(props: OpenAssistantButtonProps): import("react").JSX.Element | null;
|
|
25
30
|
/**
|
|
26
|
-
* Presentational component separated from OpenAssistantButton to avoid hook dependencies in
|
|
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
|
-
}): import("react
|
|
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,
|
|
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"}
|
|
@@ -27,8 +27,8 @@ export interface OpenAssistantSplitButtonProps {
|
|
|
27
27
|
* A split button component that opens the Grafana Assistant with a dropdown for additional actions.
|
|
28
28
|
* The gradient border wraps around both buttons as a unified control.
|
|
29
29
|
*/
|
|
30
|
-
export declare function OpenAssistantSplitButton(props: OpenAssistantSplitButtonProps): import("react
|
|
30
|
+
export declare function OpenAssistantSplitButton(props: OpenAssistantSplitButtonProps): import("react").JSX.Element | null;
|
|
31
31
|
export declare function OpenAssistantSplitButtonView({ prompt, origin, context, autoSend, title, size, onClick, menuItems, tooltip, dropdownButtonWidth, openAssistant, }: OpenAssistantSplitButtonProps & {
|
|
32
32
|
openAssistant: (props: OpenAssistantProps) => void;
|
|
33
|
-
}): import("react
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
34
|
//# sourceMappingURL=OpenAssistantSplitButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAssistantSplitButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/OpenAssistantSplitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,6BAA6B;IAC5C,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC;AAUD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"OpenAssistantSplitButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/OpenAssistantSplitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,6BAA6B;IAC5C,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC;AAUD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,sCAM5E;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAe,EACf,KAA6B,EAC7B,IAAW,EACX,OAAO,EACP,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,aAAa,GACd,EAAE,6BAA6B,GAAG;IACjC,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACpD,+BAiDA"}
|
|
@@ -7,8 +7,8 @@ export interface QueryWithAssistantButtonProps<TQuery extends DataQuery = DataQu
|
|
|
7
7
|
queries: TQuery[];
|
|
8
8
|
dataSourceInstanceSettings: DataSourceInstanceSettings;
|
|
9
9
|
app?: CoreApp;
|
|
10
|
-
datasourceApi: DataSourceApi<TQuery, DataSourceJsonData
|
|
10
|
+
datasourceApi: DataSourceApi<TQuery, DataSourceJsonData> | null;
|
|
11
11
|
title?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function QueryWithAssistantButton<TQuery extends DataQuery = DataQuery>({ size, currentQuery, queries, dataSourceInstanceSettings, app, datasourceApi, title, }: QueryWithAssistantButtonProps<TQuery>): import("react
|
|
13
|
+
export declare function QueryWithAssistantButton<TQuery extends DataQuery = DataQuery>({ size, currentQuery, queries, dataSourceInstanceSettings, app, datasourceApi, title, }: QueryWithAssistantButtonProps<TQuery>): import("react").JSX.Element | null;
|
|
14
14
|
//# sourceMappingURL=QueryWithAssistantButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryWithAssistantButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/QueryWithAssistantButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoBjD,MAAM,WAAW,6BAA6B,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACjF,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0BAA0B,EAAE,0BAA0B,CAAC;IACvD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,aAAa,CAAC,MAAM,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"QueryWithAssistantButton.d.ts","sourceRoot":"","sources":["../../../src/components/button/QueryWithAssistantButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoBjD,MAAM,WAAW,6BAA6B,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACjF,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,0BAA0B,EAAE,0BAA0B,CAAC;IACvD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,aAAa,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,IAAI,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,wBAAwB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,EAAE,EAC7E,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,0BAA0B,EAC1B,GAAG,EACH,aAAa,EACb,KAA8B,GAC/B,EAAE,6BAA6B,CAAC,MAAM,CAAC,sCAsEvC"}
|
|
@@ -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"}
|