@grafana/assistant 0.1.16 → 0.1.18
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 +10 -2
- package/dist/components/button/OpenAssistantButton.d.ts +33 -0
- package/dist/components/button/OpenAssistantButton.d.ts.map +1 -0
- package/dist/components/button/OpenAssistantButton.stories.d.ts +11 -0
- package/dist/components/button/OpenAssistantButton.stories.d.ts.map +1 -0
- package/dist/components/button/OpenAssistantSplitButton.d.ts +34 -0
- package/dist/components/button/OpenAssistantSplitButton.d.ts.map +1 -0
- package/dist/components/button/OpenAssistantSplitButton.stories.d.ts +11 -0
- package/dist/components/button/OpenAssistantSplitButton.stories.d.ts.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/input/AITextArea.d.ts +12 -0
- package/dist/components/input/AITextArea.d.ts.map +1 -0
- package/dist/components/input/AITextArea.stories.d.ts +26 -0
- package/dist/components/input/AITextArea.stories.d.ts.map +1 -0
- package/dist/components/input/AITextInput.d.ts +10 -0
- package/dist/components/input/AITextInput.d.ts.map +1 -0
- package/dist/components/input/AITextInput.stories.d.ts +22 -0
- package/dist/components/input/AITextInput.stories.d.ts.map +1 -0
- package/dist/components/input/types.d.ts +18 -0
- package/dist/components/input/types.d.ts.map +1 -0
- package/dist/components/input/useAIGeneration.d.ts +20 -0
- package/dist/components/input/useAIGeneration.d.ts.map +1 -0
- package/dist/components/input/useGeneratingPlaceholder.d.ts +6 -0
- package/dist/components/input/useGeneratingPlaceholder.d.ts.map +1 -0
- package/dist/context/base.d.ts +49 -0
- package/dist/context/base.d.ts.map +1 -0
- package/dist/context/chat.d.ts +37 -0
- package/dist/context/chat.d.ts.map +1 -0
- package/dist/context/component.d.ts +45 -0
- package/dist/context/component.d.ts.map +1 -0
- package/dist/context/dashboard.d.ts +28 -0
- package/dist/context/dashboard.d.ts.map +1 -0
- package/dist/context/datasource.d.ts +20 -0
- package/dist/context/datasource.d.ts.map +1 -0
- package/dist/context/entity.d.ts +28 -0
- package/dist/context/entity.d.ts.map +1 -0
- package/dist/context/factory.d.ts +57 -0
- package/dist/context/factory.d.ts.map +1 -0
- package/dist/context/index.d.ts +13 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/label.d.ts +33 -0
- package/dist/context/label.d.ts.map +1 -0
- package/dist/context/page.d.ts +47 -0
- package/dist/context/page.d.ts.map +1 -0
- package/dist/context/playbook.d.ts +13 -0
- package/dist/context/playbook.d.ts.map +1 -0
- package/dist/context/questions.d.ts +42 -0
- package/dist/context/questions.d.ts.map +1 -0
- package/dist/context/types.d.ts +80 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/functions.d.ts +12 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/hook.d.ts +13 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/inline/index.d.ts +4 -0
- package/dist/inline/index.d.ts.map +1 -0
- package/dist/inline/inlineAssistant.d.ts +40 -0
- package/dist/inline/inlineAssistant.d.ts.map +1 -0
- package/dist/inline/types.d.ts +84 -0
- package/dist/inline/types.d.ts.map +1 -0
- package/dist/inline/useInlineAssistant.d.ts +65 -0
- package/dist/inline/useInlineAssistant.d.ts.map +1 -0
- package/dist/investigations.d.ts +41 -0
- package/dist/investigations.d.ts.map +1 -0
- package/dist/limits/index.d.ts +73 -0
- package/dist/limits/index.d.ts.map +1 -0
- package/dist/plugin.d.ts +9 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/sidebar.d.ts +26 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/terms/index.d.ts +60 -0
- package/dist/terms/index.d.ts.map +1 -0
- package/dist/terms/settings.gen.d.ts +461 -0
- package/dist/terms/settings.gen.d.ts.map +1 -0
- package/dist/terms/versionCompare.d.ts +16 -0
- package/dist/terms/versionCompare.d.ts.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/toolFactory.d.ts +22 -0
- package/dist/tools/toolFactory.d.ts.map +1 -0
- package/dist/tools/types.d.ts +201 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/theme.d.ts +30 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useInlineAssistant } from './useInlineAssistant';
|
|
2
|
+
export type { InlineAssistantOptions, InlineAssistantResult, InlineAssistantState, StreamEvent, MessageStreamStartEvent, MessageContentDeltaEvent, MessageStreamCompleteEvent, } from './types';
|
|
3
|
+
export { setInlineAssistantFactory, setInlineAssistantInitializer, getInlineAssistantFactory, ensureInlineAssistantInitialized, type InlineAssistant, type InlineAssistantFactory, type InlineAssistantInitializer, type InlineAssistantPromptOptions, } from './inlineAssistant';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inline/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,GAClC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { InlineToolRunnable } from '../tools/types';
|
|
2
|
+
export interface InlineAssistantPromptOptions {
|
|
3
|
+
prompt: string;
|
|
4
|
+
systemPrompt?: string;
|
|
5
|
+
tools?: InlineToolRunnable[];
|
|
6
|
+
onStart?: () => void;
|
|
7
|
+
onDelta?: (delta: string) => void;
|
|
8
|
+
onComplete?: (text: string) => void;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface InlineAssistant {
|
|
12
|
+
sendPrompt(options: InlineAssistantPromptOptions): Promise<void>;
|
|
13
|
+
cancel(): void;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface Window {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export type InlineAssistantFactory = (origin: string) => Promise<InlineAssistant>;
|
|
22
|
+
export type InlineAssistantInitializer = () => Promise<void>;
|
|
23
|
+
export declare function setInlineAssistantFactory(fn: InlineAssistantFactory): void;
|
|
24
|
+
/**
|
|
25
|
+
* Register a lazy initializer that will be called on first use.
|
|
26
|
+
* The plugin code should register this to enable lazy loading of the inline assistant.
|
|
27
|
+
*
|
|
28
|
+
* This uses global storage (window) so that all plugins share the same initializer,
|
|
29
|
+
* regardless of which plugin instance or package version loads first.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setInlineAssistantInitializer(fn: InlineAssistantInitializer): void;
|
|
32
|
+
/**
|
|
33
|
+
* Ensure the inline assistant is initialized. If an initializer is registered,
|
|
34
|
+
* it will be called on first use. Otherwise, checks if factory is already registered.
|
|
35
|
+
*
|
|
36
|
+
* Uses global storage (window) so that initialization is shared across all plugins.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensureInlineAssistantInitialized(): Promise<void>;
|
|
39
|
+
export declare function getInlineAssistantFactory(): InlineAssistantFactory;
|
|
40
|
+
//# sourceMappingURL=inlineAssistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineAssistant.d.ts","sourceRoot":"","sources":["../../src/inline/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../tools/types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for inline assistant generation
|
|
4
|
+
*/
|
|
5
|
+
export interface InlineAssistantOptions {
|
|
6
|
+
/** The prompt to send to the assistant */
|
|
7
|
+
prompt: string;
|
|
8
|
+
/** Origin of the request for analytics tracking (e.g., 'grafana/panel-editor/title', 'grafana-slo-app/slo-form/description') */
|
|
9
|
+
origin: string;
|
|
10
|
+
/** Optional system prompt to guide the assistant's behavior */
|
|
11
|
+
systemPrompt?: string;
|
|
12
|
+
/** Optional array of tools to make available to the assistant for this generation */
|
|
13
|
+
tools?: InlineToolRunnable[];
|
|
14
|
+
/** Callback invoked when generation completes successfully */
|
|
15
|
+
onComplete?: (text: string) => void;
|
|
16
|
+
/** Callback invoked if an error occurs during generation */
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
/** Callback invoked when streaming tokens are received */
|
|
19
|
+
onDelta?: (delta: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* State for the inline assistant hook
|
|
23
|
+
*/
|
|
24
|
+
export interface InlineAssistantState {
|
|
25
|
+
/** Whether generation is currently in progress */
|
|
26
|
+
isGenerating: boolean;
|
|
27
|
+
/** Accumulated content from streaming */
|
|
28
|
+
content: string;
|
|
29
|
+
/** Error that occurred during generation, if any */
|
|
30
|
+
error: Error | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Return type of the useInlineAssistant hook
|
|
34
|
+
*/
|
|
35
|
+
export interface InlineAssistantResult {
|
|
36
|
+
/** Start generating content with the given options */
|
|
37
|
+
generate: (options: InlineAssistantOptions) => Promise<void>;
|
|
38
|
+
/** Whether generation is currently in progress */
|
|
39
|
+
isGenerating: boolean;
|
|
40
|
+
/** Accumulated streaming content (updates in real-time) */
|
|
41
|
+
content: string;
|
|
42
|
+
/** Error that occurred during generation, if any */
|
|
43
|
+
error: Error | null;
|
|
44
|
+
/** Cancel the current generation */
|
|
45
|
+
cancel: () => void;
|
|
46
|
+
/** Clear error and content state */
|
|
47
|
+
reset: () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Streaming event types from the backend
|
|
51
|
+
*/
|
|
52
|
+
export interface MessageStreamStartEvent {
|
|
53
|
+
type: 'message.stream.start';
|
|
54
|
+
payload: {
|
|
55
|
+
messageId: string;
|
|
56
|
+
chatId: string;
|
|
57
|
+
role: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface MessageContentDeltaEvent {
|
|
61
|
+
type: 'message.content.delta';
|
|
62
|
+
payload: {
|
|
63
|
+
messageId: string;
|
|
64
|
+
chatId: string;
|
|
65
|
+
contentIndex: number;
|
|
66
|
+
contentType: string;
|
|
67
|
+
delta?: string;
|
|
68
|
+
toolUse?: unknown;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface MessageStreamCompleteEvent {
|
|
72
|
+
type: 'message.stream.complete';
|
|
73
|
+
payload: {
|
|
74
|
+
messageId: string;
|
|
75
|
+
chatId: string;
|
|
76
|
+
stopReason: string;
|
|
77
|
+
usage: {
|
|
78
|
+
inputTokens: number;
|
|
79
|
+
outputTokens: number;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export type StreamEvent = MessageStreamStartEvent | MessageContentDeltaEvent | MessageStreamCompleteEvent;
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inline/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,gIAAgI;IAChI,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,KAAK,CAAC,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MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC;YACpB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;CACH;AAED,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAAG,wBAAwB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { InlineAssistantResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* React hook for inline assistant generation with streaming support.
|
|
4
|
+
*
|
|
5
|
+
* This hook enables generating content (like panel titles or descriptions) inline
|
|
6
|
+
* without opening the assistant sidebar. Each hook instance creates its own chat
|
|
7
|
+
* conversation, so all generations from the same instance are grouped together.
|
|
8
|
+
* Generated content is ephemeral - it won't appear in the user's chat history
|
|
9
|
+
* but will be tracked in the admin UI for analytics.
|
|
10
|
+
*
|
|
11
|
+
* Uses the full BaseMultiStepAgent infrastructure for tool execution and multi-step workflows.
|
|
12
|
+
*
|
|
13
|
+
* The implementation is lazy-loaded on first use to reduce initial bundle size.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* function PanelEditor() {
|
|
18
|
+
* const { generate, isGenerating, content, error, reset } = useInlineAssistant();
|
|
19
|
+
* const [title, setTitle] = useState('');
|
|
20
|
+
*
|
|
21
|
+
* const handleGenerate = () => {
|
|
22
|
+
* generate({
|
|
23
|
+
* prompt: 'Generate a panel title for CPU metrics',
|
|
24
|
+
* origin: 'grafana/panel-editor/title',
|
|
25
|
+
* systemPrompt: 'Generate only the title text, no explanation',
|
|
26
|
+
* onComplete: (text) => setTitle(text.trim()),
|
|
27
|
+
* onError: (err) => console.error(err)
|
|
28
|
+
* });
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <div>
|
|
33
|
+
* <input value={title} onChange={(e) => setTitle(e.target.value)} />
|
|
34
|
+
* <button onClick={handleGenerate} disabled={isGenerating}>
|
|
35
|
+
* {isGenerating ? 'Generating...' : 'Generate with Assistant'}
|
|
36
|
+
* </button>
|
|
37
|
+
* {isGenerating && <div>{content}</div>}
|
|
38
|
+
* </div>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Using tools with inline assistant
|
|
46
|
+
* import { lokiQueryHandlerTool } from 'agent/tools';
|
|
47
|
+
*
|
|
48
|
+
* function ComponentWithTools() {
|
|
49
|
+
* const { generate } = useInlineAssistant();
|
|
50
|
+
*
|
|
51
|
+
* const handleGenerate = async () => {
|
|
52
|
+
* await generate({
|
|
53
|
+
* prompt: 'Query Loki for error logs from the last hour',
|
|
54
|
+
* origin: 'my-app/component',
|
|
55
|
+
* tools: [lokiQueryHandlerTool],
|
|
56
|
+
* onComplete: (text) => console.log('Generated:', text),
|
|
57
|
+
* });
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* return <button onClick={handleGenerate}>Generate</button>;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function useInlineAssistant(): InlineAssistantResult;
|
|
65
|
+
//# sourceMappingURL=useInlineAssistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInlineAssistant.d.ts","sourceRoot":"","sources":["../../src/inline/useInlineAssistant.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,kBAAkB,IAAI,qBAAqB,CA6F1D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BusEventWithPayload } from '@grafana/data';
|
|
2
|
+
/**
|
|
3
|
+
* Payload for the InvestigationCreatedEvent
|
|
4
|
+
*/
|
|
5
|
+
export interface InvestigationCreatedPayload {
|
|
6
|
+
/** The ID of the newly created investigation */
|
|
7
|
+
investigationId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Event emitted when an investigation is created.
|
|
11
|
+
* External integrations can subscribe to this event to react to new investigations.
|
|
12
|
+
*/
|
|
13
|
+
export declare class InvestigationCreatedEvent extends BusEventWithPayload<InvestigationCreatedPayload> {
|
|
14
|
+
static type: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Emit an InvestigationCreatedEvent to notify subscribers that a new investigation was created.
|
|
18
|
+
*
|
|
19
|
+
* @param investigationId - The ID of the newly created investigation
|
|
20
|
+
*/
|
|
21
|
+
export declare function emitInvestigationCreated(investigationId: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to investigation created events.
|
|
24
|
+
*
|
|
25
|
+
* @param callback - Function to call when an investigation is created
|
|
26
|
+
* @returns Unsubscribe function to stop listening for events
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { onInvestigationCreated } from '@grafana/assistant';
|
|
31
|
+
*
|
|
32
|
+
* const unsubscribe = onInvestigationCreated((payload) => {
|
|
33
|
+
* console.log('Investigation created:', payload.investigationId);
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Later, when you want to stop listening
|
|
37
|
+
* unsubscribe();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function onInvestigationCreated(callback: (payload: InvestigationCreatedPayload) => void): () => void;
|
|
41
|
+
//# sourceMappingURL=investigations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"investigations.d.ts","sourceRoot":"","sources":["../src/investigations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gDAAgD;IAChD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,2BAA2B,CAAC;IAC7F,MAAM,CAAC,IAAI,SAA6C;CACzD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAGtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,IAAI,GAAG,MAAM,IAAI,CAM3G"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event name dispatched when limits are updated via SSE.
|
|
3
|
+
* Other components can listen to this event to get real-time updates.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LIMITS_UPDATED_EVENT = "grafana-assistant-limits-updated";
|
|
6
|
+
/**
|
|
7
|
+
* Detail payload for the LIMITS_UPDATED_EVENT custom event.
|
|
8
|
+
*/
|
|
9
|
+
export interface LimitsUpdatedEventDetail {
|
|
10
|
+
count: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Result type for limits data.
|
|
15
|
+
*/
|
|
16
|
+
export interface LimitsData {
|
|
17
|
+
/** Current prompt count for the month */
|
|
18
|
+
count: number;
|
|
19
|
+
/** Monthly prompt limit (0 = unlimited) */
|
|
20
|
+
limit: number;
|
|
21
|
+
/** Current month in YYYY-MM format */
|
|
22
|
+
month: string;
|
|
23
|
+
/** Whether the limit has been reached */
|
|
24
|
+
isLimitReached: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether the user has reached their monthly prompt limit.
|
|
28
|
+
*
|
|
29
|
+
* @returns A promise that resolves to `true` if limits are reached, `false` otherwise
|
|
30
|
+
* @throws Error if the API call fails
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { checkLimits } from '@grafana/assistant';
|
|
35
|
+
*
|
|
36
|
+
* const data = await checkLimits();
|
|
37
|
+
* if (data.isLimitReached) {
|
|
38
|
+
* console.log('Monthly limit reached');
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function checkLimits(): Promise<LimitsData>;
|
|
43
|
+
/**
|
|
44
|
+
* React hook to check user prompt limits.
|
|
45
|
+
* Automatically fetches limits data on mount and listens to real-time updates
|
|
46
|
+
* via the LIMITS_UPDATED_EVENT custom event.
|
|
47
|
+
*
|
|
48
|
+
* @returns An object containing limit data, loading state, error state, and refetch function
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { useLimits } from '@grafana/assistant';
|
|
53
|
+
*
|
|
54
|
+
* function MyComponent() {
|
|
55
|
+
* const { count, limit, isLimitReached, loading, error, refetch } = useLimits();
|
|
56
|
+
*
|
|
57
|
+
* if (loading) return <div>Loading...</div>;
|
|
58
|
+
* if (error) return <div>Error: {error}</div>;
|
|
59
|
+
* if (isLimitReached) return <div>Monthly limit reached ({count}/{limit})</div>;
|
|
60
|
+
* return <div>Prompts used: {count}/{limit || 'unlimited'}</div>;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function useLimits(): {
|
|
65
|
+
count: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
month: string;
|
|
68
|
+
isLimitReached: boolean;
|
|
69
|
+
loading: boolean;
|
|
70
|
+
error: string | null;
|
|
71
|
+
refetch: () => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limits/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;CACzB;AAkCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAMvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS;;;;;;;;EA8DxB"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
export declare const ASSISTANT_PLUGIN_ID = "grafana-assistant-app";
|
|
3
|
+
export declare const ASSISTANT_PLUGIN_TITLE = "Grafana Assistant";
|
|
4
|
+
/**
|
|
5
|
+
* Check if the assistant is available.
|
|
6
|
+
* @returns An observable that emits true if the assistant is available, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isAssistantAvailable(): Observable<boolean>;
|
|
9
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,UAAU,EAAgC,MAAM,MAAM,CAAC;AAExF,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAC3D,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAM1D;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,CAAC,CA+C1D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChatContextItem } from './context/types';
|
|
2
|
+
export type OpenAssistantProps = {
|
|
3
|
+
origin: string;
|
|
4
|
+
prompt?: string;
|
|
5
|
+
context?: ChatContextItem[];
|
|
6
|
+
autoSend?: boolean;
|
|
7
|
+
/** Mode to open the assistant in. Built-in modes: 'assistant', 'investigation', 'dashboarding'. Can also be a backend agent ID. */
|
|
8
|
+
mode?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Open the Grafana Assistant sidebar with a given initial prompt.
|
|
12
|
+
*
|
|
13
|
+
* @param props - The props to pass to the assistant.
|
|
14
|
+
* @param props.origin - The origin of the request that opened the assistant. This is used to track the source of the request. Should be a structured string using forward slashes, with the first part as a namespace. Examples: 'grafana-datasources/prometheus/query-builder', 'grafana-slo-app/slo-editor-overview', 'grafana/trace-view-analyzer`.
|
|
15
|
+
* @param props.prompt - The initial prompt to display in the assistant.
|
|
16
|
+
* @param props.context - The initial context to display in the assistant. Created with `createContext`.
|
|
17
|
+
* @param props.autoSend - Whether to automatically send the initial prompt. When true, opens a chat and sends the initial prompt right away. When false, opens chat and updates user message without sending it. Defaults to true.
|
|
18
|
+
* @param props.mode - The mode to open the assistant in. Built-in modes: 'assistant', 'investigation', 'dashboarding'. Can also be a backend agent ID. Defaults to 'assistant'.
|
|
19
|
+
*/
|
|
20
|
+
export declare function openAssistant(props: OpenAssistantProps): void;
|
|
21
|
+
/**
|
|
22
|
+
* Close the Grafana Assistant sidebar.
|
|
23
|
+
*/
|
|
24
|
+
export declare function closeAssistant(): void;
|
|
25
|
+
export declare function toggleAssistant(props: OpenAssistantProps): void;
|
|
26
|
+
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA4ClD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mIAAmI;IACnI,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,QAatD;AAED;;GAEG;AACH,wBAAgB,cAAc,SAE7B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,QAaxD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { components } from './settings.gen';
|
|
2
|
+
/**
|
|
3
|
+
* The type of terms that apply to a tenant.
|
|
4
|
+
* - 'msa': Master Service Agreement - only requires acceptance, no version checking
|
|
5
|
+
* - 'termsAndConditions': Full terms and conditions - requires acceptance AND version checking
|
|
6
|
+
*/
|
|
7
|
+
export type TermsType = components['schemas']['TermsAndConditionsResponse']['termsType'];
|
|
8
|
+
/**
|
|
9
|
+
* Event name that is dispatched when terms and conditions are accepted.
|
|
10
|
+
* Other components can listen to this event to refresh their UI.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TERMS_AND_CONDITIONS_REFRESH_EVENT = "grafana-assistant-terms-and-conditions-refresh";
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether terms and conditions are accepted and up-to-date.
|
|
15
|
+
* This function verifies that:
|
|
16
|
+
* 1. Terms have been accepted
|
|
17
|
+
* 2. The accepted version matches or exceeds the current version
|
|
18
|
+
*
|
|
19
|
+
* @returns A promise that resolves to `true` if terms are accepted and up-to-date, `false` otherwise
|
|
20
|
+
* @throws Error if the API call fails
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { checkTerms } from '@grafana/assistant';
|
|
25
|
+
*
|
|
26
|
+
* const accepted = await checkTerms();
|
|
27
|
+
* if (!accepted) {
|
|
28
|
+
* // Show terms acceptance UI
|
|
29
|
+
* console.log('Terms need to be accepted');
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkTerms(): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* React hook to check terms and conditions acceptance status.
|
|
36
|
+
* Automatically fetches terms data on mount and re-fetches when terms change
|
|
37
|
+
* (via TERMS_AND_CONDITIONS_REFRESH_EVENT).
|
|
38
|
+
*
|
|
39
|
+
* @returns An object containing whether terms are accepted, the terms type, loading state, and error state
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { useTerms } from '@grafana/assistant';
|
|
44
|
+
*
|
|
45
|
+
* function MyComponent() {
|
|
46
|
+
* const { accepted, termsType, loading, error } = useTerms();
|
|
47
|
+
*
|
|
48
|
+
* if (loading) return <div>Loading...</div>;
|
|
49
|
+
* if (error) return <div>Error: {error}</div>;
|
|
50
|
+
* return <div>Terms accepted</div>;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function useTerms(): {
|
|
55
|
+
accepted: boolean;
|
|
56
|
+
termsType: "msa" | "termsAndConditions" | null;
|
|
57
|
+
loading: boolean;
|
|
58
|
+
error: string | null;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/terms/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,4BAA4B,CAAC,CAAC,WAAW,CAAC,CAAC;AAUzF;;;GAGG;AACH,eAAO,MAAM,kCAAkC,mDAAmD,CAAC;AA2CnG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAQnD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ;;;;;EA0CvB"}
|