@athenaintel/react 0.10.33 → 0.10.35
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 +27 -0
- package/dist/assets/AssetPanel.d.ts +6 -0
- package/dist/assets/AthenaAssetEmbed.d.ts +17 -0
- package/dist/assets/AthenaLayout.d.ts +13 -0
- package/dist/assets/asset-embed-messages.d.ts +27 -0
- package/dist/assets/asset-panel-store.d.ts +65 -0
- package/dist/assets/asset-panel-url.d.ts +17 -0
- package/dist/assets/use-asset-embed.d.ts +45 -0
- package/dist/auth/AthenaAuthContext.d.ts +26 -0
- package/dist/auth/AthenaAuthProvider.d.ts +43 -0
- package/dist/auth/AthenaSSOProvider.d.ts +91 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/types.d.ts +66 -0
- package/dist/chat/AthenaChat.d.ts +64 -0
- package/dist/chat/ComposerEditorContext.d.ts +30 -0
- package/dist/chat/athena-citation-links.d.ts +18 -0
- package/dist/chat/super-grouping/CollapsibleGroup.d.ts +15 -0
- package/dist/chat/super-grouping/SuperGroupingCard.d.ts +35 -0
- package/dist/chat/super-grouping/grouping-function.d.ts +19 -0
- package/dist/chat/super-grouping/tool-status-labels.d.ts +1 -0
- package/dist/chat/super-grouping/toolkit-map.d.ts +9 -0
- package/dist/chat/tiptap-composer.d.ts +7 -0
- package/dist/chat/tiptap-text.d.ts +4 -0
- package/dist/chat/tooltip-icon-button.d.ts +7 -0
- package/dist/composer/AttachmentContext.d.ts +27 -0
- package/dist/composer/ComposerAttachmentPreview.d.ts +9 -0
- package/dist/composer/ComposerDropZone.d.ts +13 -0
- package/dist/composer/ComposerQuotePreview.d.ts +12 -0
- package/dist/composer/FileUploadButton.d.ts +15 -0
- package/dist/composer/QuoteContext.d.ts +33 -0
- package/dist/composer/build-composed-message.d.ts +15 -0
- package/dist/composer/clipboard.d.ts +6 -0
- package/dist/composer/index.d.ts +18 -0
- package/dist/composer/useAppendToComposer.d.ts +14 -0
- package/dist/composer/useComposerAttachment.d.ts +14 -0
- package/dist/composer/useFileUpload.d.ts +35 -0
- package/dist/composer/useSendMessage.d.ts +21 -0
- package/dist/index.cjs +1996 -1440
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +81 -1545
- package/dist/index.js +1997 -1441
- package/dist/index.js.map +1 -1
- package/dist/lib/athena-urls.d.ts +32 -0
- package/dist/lib/posthog/capture-gate.d.ts +72 -0
- package/dist/lib/posthog/wrap-posthog-client.d.ts +11 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/mentions/composer-keybinds.d.ts +5 -0
- package/dist/mentions/mention-extension.d.ts +6 -0
- package/dist/mentions/mention-icons.d.ts +4 -0
- package/dist/mentions/mention-node-view.d.ts +2 -0
- package/dist/mentions/mention-suggestion-list.d.ts +14 -0
- package/dist/mentions/mention-suggestion-popup.d.ts +15 -0
- package/dist/mentions/mention-suggestions-extension.d.ts +11 -0
- package/dist/mentions/mention-types.d.ts +21 -0
- package/dist/mentions/mention-utils.d.ts +23 -0
- package/dist/mentions/scope-registry.d.ts +21 -0
- package/dist/mentions/types.d.ts +39 -0
- package/dist/mentions/use-mention-suggestions.d.ts +28 -0
- package/dist/provider/AthenaContext.d.ts +11 -0
- package/dist/provider/AthenaProvider.d.ts +86 -0
- package/dist/provider/PostHogProvider.d.ts +14 -0
- package/dist/provider/citation-links.d.ts +61 -0
- package/dist/provider/config.d.ts +20 -0
- package/dist/provider/types.d.ts +4 -0
- package/dist/runtime/auth.d.ts +45 -0
- package/dist/runtime/converter.d.ts +5 -0
- package/dist/runtime/external-message-converter.d.ts +21 -0
- package/dist/runtime/schemas.d.ts +24 -0
- package/dist/runtime/useAthenaRuntime.d.ts +47 -0
- package/dist/theme/index.d.ts +215 -0
- package/dist/threads/ThreadList.d.ts +4 -0
- package/dist/threads/adapter.d.ts +42 -0
- package/dist/threads/api.d.ts +49 -0
- package/dist/threads/index.d.ts +5 -0
- package/dist/threads/title.d.ts +4 -0
- package/dist/threads/useActiveThreadStateHydration.d.ts +14 -0
- package/dist/threads/useAthenaThreadManager.d.ts +25 -0
- package/dist/threads/useThreadTitlePolling.d.ts +14 -0
- package/dist/toolkits/index.d.ts +89 -0
- package/dist/tools/NestedPtcMessages.d.ts +14 -0
- package/dist/tools/append-document-tool-ui.d.ts +2 -0
- package/dist/tools/asset-utils.d.ts +6 -0
- package/dist/tools/auto-open-tools.d.ts +8 -0
- package/dist/tools/read-asset-tool-ui.d.ts +2 -0
- package/dist/tools/tool-fallback.d.ts +34 -0
- package/dist/tools/tool-uis.d.ts +62 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/collapsible.d.ts +5 -0
- package/dist/ui/tooltip.d.ts +7 -0
- package/package.json +9 -10
- package/dist/auth.d.ts +0 -240
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type AthenaEnvironment = 'production' | 'staging';
|
|
2
|
+
export interface AthenaEnvironmentUrls {
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
backendUrl: string;
|
|
5
|
+
appUrl: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_ATHENA_ENVIRONMENT: AthenaEnvironment;
|
|
8
|
+
export declare const DEFAULT_API_URL: string;
|
|
9
|
+
export declare const DEFAULT_BACKEND_URL: string;
|
|
10
|
+
export declare const DEFAULT_APP_URL: string;
|
|
11
|
+
export declare function getAthenaEnvironmentUrls({ environment, }?: {
|
|
12
|
+
environment?: AthenaEnvironment;
|
|
13
|
+
}): AthenaEnvironmentUrls;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the Iris chat endpoint that fronts a known Agora backend.
|
|
16
|
+
*
|
|
17
|
+
* Unknown custom backends deliberately return `null`: callers can preserve a
|
|
18
|
+
* direct-Agora fallback instead of accidentally sending a custom environment's
|
|
19
|
+
* bearer token and traffic through production Iris.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deriveAthenaApiUrl({ backendUrl, }: {
|
|
22
|
+
backendUrl?: string | null;
|
|
23
|
+
}): string | null;
|
|
24
|
+
export declare function deriveAthenaAppUrl({ apiUrl, backendUrl, }: {
|
|
25
|
+
apiUrl?: string | null;
|
|
26
|
+
backendUrl?: string | null;
|
|
27
|
+
}): string | null;
|
|
28
|
+
export declare function createAthenaSpacesUrl({ appUrl, assetIds, sessionId, }: {
|
|
29
|
+
appUrl?: string;
|
|
30
|
+
assetIds?: string | string[];
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
}): string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CaptureOptions, Properties } from 'posthog-js';
|
|
2
|
+
export type CaptureGateSuppressReason = 'global_budget' | 'event_budget' | 'dedupe';
|
|
3
|
+
export type CaptureGateOutcome = {
|
|
4
|
+
action: 'emit';
|
|
5
|
+
} | {
|
|
6
|
+
action: 'coalesce';
|
|
7
|
+
reason: CaptureGateSuppressReason;
|
|
8
|
+
bucketKey: string;
|
|
9
|
+
};
|
|
10
|
+
export interface CaptureGateEventOverride {
|
|
11
|
+
maxPerWindow: number;
|
|
12
|
+
windowMs: number;
|
|
13
|
+
dedupeWindowMs?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CaptureGateConfig {
|
|
16
|
+
globalMaxPerWindow: number;
|
|
17
|
+
globalWindowMs: number;
|
|
18
|
+
criticalReservePerWindow: number;
|
|
19
|
+
defaultEventMaxPerWindow: number;
|
|
20
|
+
defaultEventWindowMs: number;
|
|
21
|
+
defaultDedupeWindowMs: number;
|
|
22
|
+
/** Flush coalesced buckets on this interval (ms). */
|
|
23
|
+
flushIntervalMs: number;
|
|
24
|
+
/** Flush a bucket early once it reaches this many suppressed occurrences. */
|
|
25
|
+
flushCoalesceThreshold: number;
|
|
26
|
+
eventOverrides: Record<string, CaptureGateEventOverride>;
|
|
27
|
+
}
|
|
28
|
+
export interface CoalescedCapturePayload {
|
|
29
|
+
bucketKey: string;
|
|
30
|
+
event: string;
|
|
31
|
+
properties: Properties;
|
|
32
|
+
coalescedCount: number;
|
|
33
|
+
firstAt: number;
|
|
34
|
+
lastAt: number;
|
|
35
|
+
suppressionReason: CaptureGateSuppressReason;
|
|
36
|
+
}
|
|
37
|
+
export interface CaptureGateSnapshot {
|
|
38
|
+
coalescedPending: number;
|
|
39
|
+
coalescedPendingByEvent: Record<string, number>;
|
|
40
|
+
emittedTotal: number;
|
|
41
|
+
coalescedTotal: number;
|
|
42
|
+
flushedCoalescedTotal: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const DEFAULT_CAPTURE_GATE_CONFIG: CaptureGateConfig;
|
|
45
|
+
export declare function isCriticalPosthogEvent(event: string): boolean;
|
|
46
|
+
export declare function shouldBypassCaptureGate(options?: CaptureOptions): boolean;
|
|
47
|
+
export declare function withCaptureGateBypass(options?: CaptureOptions): CaptureOptions;
|
|
48
|
+
export declare function buildCaptureFingerprint(event: string, properties?: Properties): string;
|
|
49
|
+
export declare function buildCoalescedCaptureProperties(payload: CoalescedCapturePayload): Properties;
|
|
50
|
+
export declare class PosthogCaptureGate {
|
|
51
|
+
private readonly config;
|
|
52
|
+
private readonly globalWindow;
|
|
53
|
+
private readonly eventWindows;
|
|
54
|
+
private readonly activeDedupe;
|
|
55
|
+
private readonly coalesceBuckets;
|
|
56
|
+
private emittedTotal;
|
|
57
|
+
private coalescedTotal;
|
|
58
|
+
private flushedCoalescedTotal;
|
|
59
|
+
constructor(config?: CaptureGateConfig);
|
|
60
|
+
resetForTests(): void;
|
|
61
|
+
getSnapshot(): CaptureGateSnapshot;
|
|
62
|
+
evaluateCapture(event: string, properties?: Properties, options?: CaptureOptions, now?: number): CaptureGateOutcome;
|
|
63
|
+
/** Returns payloads ready to flush (does not mutate buckets until caller confirms). */
|
|
64
|
+
collectFlushCandidates(now?: number): CoalescedCapturePayload[];
|
|
65
|
+
/** Remove flushed bucket keys after successful emit. */
|
|
66
|
+
acknowledgeFlushed(payloads: CoalescedCapturePayload[]): void;
|
|
67
|
+
/** After coalescing, flush immediately if the bucket crossed the early threshold. */
|
|
68
|
+
takeBucketIfReady(bucketKey: string, now?: number): CoalescedCapturePayload | null;
|
|
69
|
+
/** Force-flush every pending bucket (e.g. page hide). */
|
|
70
|
+
collectAllPending(): CoalescedCapturePayload[];
|
|
71
|
+
private recordCoalesce;
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CaptureResult, PostHog, Properties } from 'posthog-js';
|
|
2
|
+
import type { CaptureOptions } from 'posthog-js';
|
|
3
|
+
import { PosthogCaptureGate } from './capture-gate';
|
|
4
|
+
export type PosthogCaptureClient = Pick<PostHog, 'capture'> & {
|
|
5
|
+
captureException?: (error: unknown, additionalProperties?: Properties) => CaptureResult | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function getPosthogCaptureGate(): PosthogCaptureGate;
|
|
8
|
+
export declare function resetPosthogCaptureGateForTests(): void;
|
|
9
|
+
export declare function wrapPosthogClient<TClient extends PosthogCaptureClient>(client: TClient): TClient;
|
|
10
|
+
export declare function capturePosthogEvent(client: PosthogCaptureClient | null | undefined, event: string, properties?: Properties, options?: CaptureOptions): void;
|
|
11
|
+
export declare function capturePosthogException(client: PosthogCaptureClient | null | undefined, error: Error, properties?: Properties, options?: CaptureOptions): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MenuItem } from "./types";
|
|
2
|
+
import type { MentionSuggestionsStore } from "./use-mention-suggestions";
|
|
3
|
+
export interface MentionSuggestionListProps {
|
|
4
|
+
store: MentionSuggestionsStore;
|
|
5
|
+
query: string;
|
|
6
|
+
command: (item: MenuItem) => void;
|
|
7
|
+
closeMenu: (dismissedByUser?: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface MentionSuggestionListHandle {
|
|
10
|
+
onKeyDown: (props: {
|
|
11
|
+
event: KeyboardEvent;
|
|
12
|
+
}) => boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const MentionSuggestionList: import("react").ForwardRefExoticComponent<MentionSuggestionListProps & import("react").RefAttributes<MentionSuggestionListHandle>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MentionSuggestionsStore } from "./use-mention-suggestions";
|
|
2
|
+
export interface MentionSuggestionPopupProps {
|
|
3
|
+
store: MentionSuggestionsStore;
|
|
4
|
+
query: string;
|
|
5
|
+
command: (props: any) => void;
|
|
6
|
+
clientRect: (() => DOMRect) | null;
|
|
7
|
+
closeMenu: (dismissedByUser?: boolean) => void;
|
|
8
|
+
isHidden?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface MentionSuggestionPopupHandle {
|
|
11
|
+
onKeyDown: (props: {
|
|
12
|
+
event: KeyboardEvent;
|
|
13
|
+
}) => boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const MentionSuggestionPopup: import("react").ForwardRefExoticComponent<MentionSuggestionPopupProps & import("react").RefAttributes<MentionSuggestionPopupHandle>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import type { MentionSuggestionsStore } from "./use-mention-suggestions";
|
|
3
|
+
export interface MentionSuggestionsOptions {
|
|
4
|
+
store: MentionSuggestionsStore;
|
|
5
|
+
}
|
|
6
|
+
export interface MentionSuggestionsStorage {
|
|
7
|
+
mentionSuggestionsActive: boolean;
|
|
8
|
+
query: string;
|
|
9
|
+
dismissedWithEsc: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const MentionSuggestionsExtension: Extension<MentionSuggestionsOptions, MentionSuggestionsStorage>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export interface MentionConfig {
|
|
3
|
+
type: string;
|
|
4
|
+
schema: z.ZodSchema;
|
|
5
|
+
parser: (url: string) => Record<string, any> | null;
|
|
6
|
+
encoder: (data: any, mentionType?: string) => string;
|
|
7
|
+
style: {
|
|
8
|
+
icon: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface MentionNodeAttrs {
|
|
12
|
+
type: string;
|
|
13
|
+
name: string;
|
|
14
|
+
params: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
export declare const MENTION_TYPES: Record<string, MentionConfig>;
|
|
17
|
+
export declare function getMentionConfig(type: string | null | undefined): MentionConfig | null;
|
|
18
|
+
/**
|
|
19
|
+
* Detect mention type from a URL string
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectMentionTypeFromUrl(url: string): string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
import { type MentionNodeAttrs } from "./mention-types";
|
|
3
|
+
/** Pattern for [@Name](url) format */
|
|
4
|
+
export declare const MENTION_PATTERN: RegExp;
|
|
5
|
+
/**
|
|
6
|
+
* Insert a mention node into the editor with schema validation
|
|
7
|
+
*/
|
|
8
|
+
export declare function insertMention(editor: Editor, mentionType: string, name: string, rawParams: Record<string, any>, range: {
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
}): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Markdown link for mentions: [@Name](mention://type?params)
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeMarkdownMention(attrs: MentionNodeAttrs): string;
|
|
16
|
+
/**
|
|
17
|
+
* Creates mention URL from node attributes using the config encoder
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeMentionUrl(attrs: MentionNodeAttrs): string;
|
|
20
|
+
/**
|
|
21
|
+
* Parse mention attributes from a name and URL
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseMentionAttrsFromUrl(name: string, url: string): MentionNodeAttrs | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FetchState, MenuItem, MenuScope, SourceFn } from "./types";
|
|
2
|
+
export interface ScopeRegistryEntry {
|
|
3
|
+
sourceFn: SourceFn;
|
|
4
|
+
fetchStates: Map<string, FetchState>;
|
|
5
|
+
}
|
|
6
|
+
export interface ScopeRegistry {
|
|
7
|
+
entries: Map<MenuScope, ScopeRegistryEntry>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createScopeRegistry(): ScopeRegistry;
|
|
10
|
+
export declare function registerSource(registry: ScopeRegistry, scope: MenuScope, sourceFn: SourceFn): void;
|
|
11
|
+
export declare function getEntry(registry: ScopeRegistry, scope: MenuScope): ScopeRegistryEntry | undefined;
|
|
12
|
+
export declare function getFetchState(registry: ScopeRegistry, scope: MenuScope, query: string): FetchState | undefined;
|
|
13
|
+
export declare function updateFetchState(registry: ScopeRegistry, scope: MenuScope, query: string, state: FetchState): void;
|
|
14
|
+
/** Item cache: deduplicates items by ID, tracks scope membership */
|
|
15
|
+
export interface ItemCache {
|
|
16
|
+
items: Map<string, MenuItem>;
|
|
17
|
+
}
|
|
18
|
+
export declare function createItemCache(): ItemCache;
|
|
19
|
+
export declare function addItems(cache: ItemCache, items: MenuItem[], scope: MenuScope): void;
|
|
20
|
+
export declare function getFilteredItems(cache: ItemCache, scope: MenuScope, query: string): MenuItem[];
|
|
21
|
+
export declare function clearScope(cache: ItemCache, scope: MenuScope): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for mention suggestions data layer
|
|
3
|
+
* Simplified from Olympus — only Tool and Toolkit types
|
|
4
|
+
*/
|
|
5
|
+
export type MenuScope = string;
|
|
6
|
+
export interface MenuItem {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: "menu" | "tool" | "toolkit";
|
|
10
|
+
fallbackIcon: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
visibleInScopes: Set<MenuScope>;
|
|
13
|
+
navigatesToScope?: MenuScope;
|
|
14
|
+
isNavigationOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface MenuItemsSelector {
|
|
17
|
+
items: MenuItem[];
|
|
18
|
+
isFetching: boolean;
|
|
19
|
+
hasMore: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface FetchState {
|
|
22
|
+
isFetching: boolean;
|
|
23
|
+
hasNextPage: boolean;
|
|
24
|
+
error: Error | null;
|
|
25
|
+
meta: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface SourceResult {
|
|
28
|
+
items: MenuItem[];
|
|
29
|
+
pagination?: {
|
|
30
|
+
hasMore: boolean;
|
|
31
|
+
totalCount?: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface SourceContext {
|
|
35
|
+
scope: MenuScope;
|
|
36
|
+
query: string;
|
|
37
|
+
fetchState: FetchState;
|
|
38
|
+
}
|
|
39
|
+
export type SourceFn = (context: SourceContext) => Promise<SourceResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Store } from "@tanstack/react-store";
|
|
2
|
+
import type { MenuItem } from "./types";
|
|
3
|
+
import { type ItemCache, type ScopeRegistry } from "./scope-registry";
|
|
4
|
+
export interface MentionTool {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
type: "tool" | "toolkit";
|
|
10
|
+
}
|
|
11
|
+
export interface MentionSuggestionsState {
|
|
12
|
+
registry: ScopeRegistry;
|
|
13
|
+
cache: ItemCache;
|
|
14
|
+
}
|
|
15
|
+
export type MentionSuggestionsStore = Store<MentionSuggestionsState>;
|
|
16
|
+
export type MentionRootCategory = "toolkits" | "team";
|
|
17
|
+
export interface UseMentionSuggestionsOptions {
|
|
18
|
+
rootCategories?: readonly MentionRootCategory[];
|
|
19
|
+
}
|
|
20
|
+
export declare function useMentionSuggestions(tools: MentionTool[], options?: UseMentionSuggestionsOptions): MentionSuggestionsStore;
|
|
21
|
+
/**
|
|
22
|
+
* Select items from store for a given scope and query
|
|
23
|
+
*/
|
|
24
|
+
export declare function selectItems(store: MentionSuggestionsStore, scope: string, query: string): {
|
|
25
|
+
items: MenuItem[];
|
|
26
|
+
isFetching: boolean;
|
|
27
|
+
hasMore: boolean;
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AthenaProviderConfig } from './config';
|
|
2
|
+
import type { AthenaCitationLinkOptions, AthenaLinkClickOptions } from './citation-links';
|
|
3
|
+
export interface AthenaConfig extends Pick<AthenaProviderConfig, 'apiKey' | 'token'> {
|
|
4
|
+
backendUrl: string;
|
|
5
|
+
appUrl: string;
|
|
6
|
+
enabledToolkits: string[];
|
|
7
|
+
linkClicks?: AthenaLinkClickOptions;
|
|
8
|
+
citationLinks?: AthenaCitationLinkOptions;
|
|
9
|
+
}
|
|
10
|
+
export declare const AthenaContext: import("react").Context<AthenaConfig | null>;
|
|
11
|
+
export declare function useAthenaConfig(): AthenaConfig;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Toolkit } from '@assistant-ui/react';
|
|
3
|
+
import { type AthenaEnvironment } from '../lib/athena-urls';
|
|
4
|
+
import type { AthenaProviderConfig } from './config';
|
|
5
|
+
import type { AthenaCitationLinkOptions, AthenaLinkClickOptions } from './citation-links';
|
|
6
|
+
import { type AthenaTheme } from '../theme';
|
|
7
|
+
import { type PostHogConfig } from './PostHogProvider';
|
|
8
|
+
export interface AthenaProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Preferred structured config for auth and Athena endpoint settings. */
|
|
11
|
+
config?: AthenaProviderConfig;
|
|
12
|
+
/** @deprecated Prefer `config.apiKey`. API key for authentication in standalone mode. */
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/** @deprecated Prefer `config.token`. PropelAuth token. If provided, takes priority over apiKey. If omitted, the SDK
|
|
15
|
+
* will automatically listen for a token from the parent window via PostMessage. */
|
|
16
|
+
token?: string | null;
|
|
17
|
+
/** Agent name to use. Defaults to 'athena_assist_agent'. */
|
|
18
|
+
agent?: string;
|
|
19
|
+
/** LLM model identifier. Defaults to 'claude-opus-4-6-thinking-max-fast'. */
|
|
20
|
+
model?: string;
|
|
21
|
+
/** Backend toolkit IDs to enable (e.g. 'document_toolkit', 'web_search_browse_toolkit'). */
|
|
22
|
+
tools?: string[];
|
|
23
|
+
/** Frontend tools that execute in the browser. The agent can invoke these.
|
|
24
|
+
* Merged on top of the SDK's default auto-open tools; entries here take
|
|
25
|
+
* precedence over defaults with the same name. */
|
|
26
|
+
frontendTools?: Toolkit;
|
|
27
|
+
/** Disable the SDK's default auto-open behavior for created/touched assets. */
|
|
28
|
+
disableAutoOpen?: boolean;
|
|
29
|
+
/** @deprecated Prefer `config.apiUrl`. URL for the chat streaming endpoint. */
|
|
30
|
+
apiUrl?: string;
|
|
31
|
+
/** @deprecated Prefer `config.backendUrl`. URL for the Athena backend API. */
|
|
32
|
+
backendUrl?: string;
|
|
33
|
+
/** @deprecated Prefer `config.appUrl`. URL for the Athena frontend app origin. */
|
|
34
|
+
appUrl?: string;
|
|
35
|
+
/** @deprecated Prefer `config.environment`. Athena environment preset used when URLs are not explicitly provided. */
|
|
36
|
+
environment?: AthenaEnvironment;
|
|
37
|
+
/** Asset IDs to include in the workbench. */
|
|
38
|
+
workbench?: string[];
|
|
39
|
+
/** Knowledge base IDs for RAG context. */
|
|
40
|
+
knowledgeBase?: string[];
|
|
41
|
+
/** System prompt override. */
|
|
42
|
+
systemPrompt?: string;
|
|
43
|
+
/** Custom tool configurations (e.g. MCP servers).
|
|
44
|
+
* Passed through as `custom_tool_configs` in runConfig.custom.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <AthenaProvider customToolConfigs={{
|
|
48
|
+
* mcp: {
|
|
49
|
+
* "my-server": {
|
|
50
|
+
* config: { transport: "streamable_http", url: "https://..." },
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* }}>
|
|
54
|
+
*/
|
|
55
|
+
customToolConfigs?: Record<string, unknown>;
|
|
56
|
+
/** Client app identifier for session filtering.
|
|
57
|
+
* Sessions created with this ID can be filtered in the thread list.
|
|
58
|
+
* E.g. "olympus", "athena-app", or a computer asset ID like "asset_<uuid>". */
|
|
59
|
+
appId?: string;
|
|
60
|
+
/** Thread ID override. Auto-generated if not provided. */
|
|
61
|
+
threadId?: string;
|
|
62
|
+
/** Enable thread list management (sidebar thread switching). */
|
|
63
|
+
enableThreadList?: boolean;
|
|
64
|
+
/** Theme configuration. Pass a preset from `themes` or a custom `AthenaTheme` object.
|
|
65
|
+
* Injects CSS variables on a wrapper element — no CSS files needed.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* import { themes } from '@athenaintel/react';
|
|
69
|
+
* <AthenaProvider theme={themes.dark}>
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* <AthenaProvider theme={{ primary: '#8b5cf6', radius: '1rem' }}>
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* <AthenaProvider theme={{ ...themes.dark, primary: '#22c55e' }}>
|
|
76
|
+
*/
|
|
77
|
+
theme?: AthenaTheme;
|
|
78
|
+
/** Customize how rendered chat links behave. */
|
|
79
|
+
linkClicks?: AthenaLinkClickOptions;
|
|
80
|
+
/** @deprecated Prefer `linkClicks`. Customize how Athena citation links rendered in chat messages behave. */
|
|
81
|
+
citationLinks?: AthenaCitationLinkOptions;
|
|
82
|
+
/** PostHog analytics configuration. When omitted or keys are missing, PostHog is silently disabled.
|
|
83
|
+
* Prefer `config.posthog` for structured configuration. */
|
|
84
|
+
posthog?: PostHogConfig;
|
|
85
|
+
}
|
|
86
|
+
export declare function AthenaProvider({ children, config, apiKey, token: tokenProp, agent, model, tools, frontendTools, disableAutoOpen, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, customToolConfigs, appId, threadId: threadIdProp, enableThreadList, theme, linkClicks, citationLinks, posthog: posthogProp, }: AthenaProviderProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface PostHogConfig {
|
|
3
|
+
/** PostHog API key. When falsy, PostHog is disabled and the provider is a no-op. */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
/** PostHog ingestion host. Defaults to 'https://us.i.posthog.com'. */
|
|
6
|
+
host?: string;
|
|
7
|
+
/** Enable debug mode (logs PostHog internals to the console). */
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function getPostHogInstance<TClient = unknown>(): TClient | null;
|
|
11
|
+
export declare function PostHogProvider({ children, config, }: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
config?: PostHogConfig;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AssetType } from '../assets/asset-panel-store';
|
|
2
|
+
export type AthenaLinkKind = 'athena-citation' | 'athena-app' | 'external';
|
|
3
|
+
export interface AthenaLinkClickHandleInput {
|
|
4
|
+
href: string;
|
|
5
|
+
linkText?: string | null;
|
|
6
|
+
target?: string | null;
|
|
7
|
+
nativeEvent?: MouseEvent | null;
|
|
8
|
+
}
|
|
9
|
+
export interface AthenaCitationLinkMetadata {
|
|
10
|
+
assetId: string;
|
|
11
|
+
assetIds: string[];
|
|
12
|
+
assetType: AssetType | null;
|
|
13
|
+
}
|
|
14
|
+
export interface AthenaLinkClickContext {
|
|
15
|
+
href: string;
|
|
16
|
+
url: URL;
|
|
17
|
+
target: string | null;
|
|
18
|
+
linkText: string | null;
|
|
19
|
+
isAssetPanelAvailable: boolean;
|
|
20
|
+
kind: AthenaLinkKind;
|
|
21
|
+
citation: AthenaCitationLinkMetadata | null;
|
|
22
|
+
nativeEvent: MouseEvent | null;
|
|
23
|
+
openInAssetPanel?: () => void;
|
|
24
|
+
openInBrowser: (target?: string | null) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface AthenaLinkClickOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Whether Athena citation links should be intercepted by the SDK.
|
|
29
|
+
* Defaults to `true`.
|
|
30
|
+
*/
|
|
31
|
+
interceptAthenaCitations?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Optional override invoked when any rendered chat link is clicked.
|
|
34
|
+
* Return `true` to mark the click as handled and skip the default SDK behavior.
|
|
35
|
+
*/
|
|
36
|
+
onClick?: (context: AthenaLinkClickContext) => boolean | void;
|
|
37
|
+
}
|
|
38
|
+
export interface AthenaCitationLinkClickContext extends AthenaLinkClickContext {
|
|
39
|
+
kind: 'athena-citation';
|
|
40
|
+
citation: AthenaCitationLinkMetadata;
|
|
41
|
+
assetId: string;
|
|
42
|
+
assetIds: string[];
|
|
43
|
+
assetType: AssetType | null;
|
|
44
|
+
openInAssetPanel: () => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Prefer `AthenaLinkClickOptions`. This remains supported as a citation-only alias.
|
|
48
|
+
*/
|
|
49
|
+
export interface AthenaCitationLinkOptions {
|
|
50
|
+
interceptAthenaCitations?: boolean;
|
|
51
|
+
onClick?: (context: AthenaCitationLinkClickContext) => boolean | void;
|
|
52
|
+
}
|
|
53
|
+
export type AthenaLinkClickHandler = (input: AthenaLinkClickHandleInput) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Prefer `AthenaLinkClickHandleInput`.
|
|
56
|
+
*/
|
|
57
|
+
export type AthenaCitationLinkHandleInput = AthenaLinkClickHandleInput;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Prefer `AthenaLinkClickHandler`.
|
|
60
|
+
*/
|
|
61
|
+
export type AthenaCitationLinkHandler = AthenaLinkClickHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AthenaEnvironment } from '../lib/athena-urls';
|
|
2
|
+
import type { PostHogConfig } from './PostHogProvider';
|
|
3
|
+
export interface AthenaProviderConfig {
|
|
4
|
+
/** API key for standalone authentication when no token is provided. */
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
/** PropelAuth token. Takes priority over apiKey when provided. */
|
|
7
|
+
token?: string | null;
|
|
8
|
+
/** URL for the chat streaming endpoint. Defaults to the matching Athena environment. */
|
|
9
|
+
apiUrl?: string;
|
|
10
|
+
/** URL for the Athena backend API. Defaults to the matching Athena environment. */
|
|
11
|
+
backendUrl?: string;
|
|
12
|
+
/** URL for the Athena frontend app origin. Defaults to the matching Athena environment. */
|
|
13
|
+
appUrl?: string;
|
|
14
|
+
/** Exact parent origins allowed to send embedded auth/config via postMessage. */
|
|
15
|
+
trustedParentOrigins?: string[];
|
|
16
|
+
/** Athena environment preset used when URLs are not explicitly provided. */
|
|
17
|
+
environment?: AthenaEnvironment;
|
|
18
|
+
/** PostHog analytics configuration. When omitted or keys are missing, PostHog is disabled. */
|
|
19
|
+
posthog?: PostHogConfig;
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface ParentBridgeState {
|
|
2
|
+
/** PropelAuth access token from the parent window. */
|
|
3
|
+
token: string | null;
|
|
4
|
+
/** Sync server chat URL provided by the Marathon wrapper. */
|
|
5
|
+
apiUrl: string | null;
|
|
6
|
+
/** Athena backend URL provided by the Marathon wrapper. */
|
|
7
|
+
backendUrl: string | null;
|
|
8
|
+
/** Athena frontend origin provided by the parent wrapper. */
|
|
9
|
+
appUrl: string | null;
|
|
10
|
+
/** True once config has been received from the parent (or timeout fired). */
|
|
11
|
+
ready: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ParentBridgeOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Exact parent origins that are allowed to send auth/config via postMessage.
|
|
16
|
+
* Useful for private-cloud or custom-domain deployments.
|
|
17
|
+
*/
|
|
18
|
+
trustedOrigins?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare const getTokenRefreshDelay: (expiresAt: unknown, nowMs: number) => number;
|
|
21
|
+
export declare const getAuthRetryDelay: (retryAttempt: number) => number;
|
|
22
|
+
/**
|
|
23
|
+
* Listens for auth tokens AND environment config from the host environment.
|
|
24
|
+
*
|
|
25
|
+
* Two transport modes, picked automatically:
|
|
26
|
+
*
|
|
27
|
+
* 1. **Iframe (legacy / Olympus inline preview)**: a parent window posts
|
|
28
|
+
* `athena-config` and `athena-auth` via PostMessage. The hook also posts
|
|
29
|
+
* `athena-auth-ready` so the parent knows when to (re-)send.
|
|
30
|
+
*
|
|
31
|
+
* 2. **Standalone (Marathon-served deploy URL)**: top-level navigation, no
|
|
32
|
+
* parent. The hook fetches `/_athena/auth` on its own origin. Marathon
|
|
33
|
+
* validates its session cookie (sent by the browser automatically) and
|
|
34
|
+
* returns `{ token, apiUrl, backendUrl, appUrl }`. A 404 means we're not
|
|
35
|
+
* on a Marathon origin — the hook falls through with empty state.
|
|
36
|
+
*
|
|
37
|
+
* In both modes a timeout safety net flips `ready: true` so the app never
|
|
38
|
+
* blocks indefinitely.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useParentBridge({ trustedOrigins, }?: ParentBridgeOptions): ParentBridgeState;
|
|
41
|
+
/**
|
|
42
|
+
* Legacy hook — returns just the auth token from the parent bridge.
|
|
43
|
+
* Prefer useParentBridge() for new code.
|
|
44
|
+
*/
|
|
45
|
+
export declare function useParentAuth(): string | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ThreadMessage } from '@assistant-ui/react';
|
|
2
|
+
import { type AthenaLangChainMessage } from './schemas';
|
|
3
|
+
export declare const PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE = "Sub-call did not complete before the parent tool returned.";
|
|
4
|
+
export declare const autoCloseInFlightSubgraphMessages: (msgs: readonly unknown[]) => unknown[];
|
|
5
|
+
export declare const convertLangChainToThreadMessages: (messages: AthenaLangChainMessage[], isRunning?: boolean, metadata?: {}) => ThreadMessage[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ThreadMessage, type ThreadMessageLike, type ToolExecutionStatus } from '@assistant-ui/react';
|
|
2
|
+
export declare namespace useExternalMessageConverter {
|
|
3
|
+
type Message = (ThreadMessageLike & {
|
|
4
|
+
readonly convertConfig?: {
|
|
5
|
+
readonly joinStrategy?: 'concat-content' | 'none';
|
|
6
|
+
};
|
|
7
|
+
}) | {
|
|
8
|
+
role: 'tool';
|
|
9
|
+
toolCallId: string;
|
|
10
|
+
toolName?: string | undefined;
|
|
11
|
+
result: any;
|
|
12
|
+
artifact?: any;
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
messages?: readonly ThreadMessage[];
|
|
15
|
+
};
|
|
16
|
+
type Metadata = {
|
|
17
|
+
readonly toolStatuses?: Record<string, ToolExecutionStatus>;
|
|
18
|
+
};
|
|
19
|
+
type Callback<T> = (message: T, metadata: Metadata) => Message | Message[] | null | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare const convertExternalMessages: <T extends WeakKey>(messages: T[], callback: useExternalMessageConverter.Callback<T>, isRunning: boolean, metadata: useExternalMessageConverter.Metadata) => ThreadMessage[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LangChainMessage } from '@assistant-ui/react-langgraph';
|
|
2
|
+
export type AthenaAiLangChainMessage = Extract<LangChainMessage, {
|
|
3
|
+
type: 'ai';
|
|
4
|
+
}> & {
|
|
5
|
+
usage_metadata?: Record<string, unknown>;
|
|
6
|
+
response_metadata?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
export type AthenaLangChainMessage = Exclude<LangChainMessage, {
|
|
9
|
+
type: 'ai';
|
|
10
|
+
}> | AthenaAiLangChainMessage;
|
|
11
|
+
export declare const parseLangChainMessage: (msg: unknown) => AthenaLangChainMessage | null;
|
|
12
|
+
export declare const parseMessages: (messages: unknown) => AthenaLangChainMessage[];
|
|
13
|
+
export declare const parseInterrupt: (interrupt: unknown) => {
|
|
14
|
+
value: unknown;
|
|
15
|
+
resumable: boolean;
|
|
16
|
+
} | null;
|
|
17
|
+
export declare const parseLangGraphState: (state: unknown) => {
|
|
18
|
+
messages: AthenaLangChainMessage[];
|
|
19
|
+
__interrupt__: {
|
|
20
|
+
value?: unknown;
|
|
21
|
+
resumable: boolean;
|
|
22
|
+
} | null;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|