@lincyaw/aegis-ui 0.3.0
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 +17 -0
- package/dist/agent/AegisAgentProvider.d.ts +35 -0
- package/dist/agent/AgentProvider.d.ts +13 -0
- package/dist/agent/AgentmChannelProvider.d.ts +43 -0
- package/dist/agent/AskOverlay.d.ts +3 -0
- package/dist/agent/AskPanel.d.ts +19 -0
- package/dist/agent/aegisAgentContext.d.ts +6 -0
- package/dist/agent/agentContext.d.ts +52 -0
- package/dist/agent/agentmChannelClient.d.ts +76 -0
- package/dist/agent/buildAskContext.d.ts +9 -0
- package/dist/agent/hooks.d.ts +24 -0
- package/dist/agent/index.d.ts +17 -0
- package/dist/agent/mcpToolCatalogue.d.ts +2 -0
- package/dist/agent/runtime.d.ts +65 -0
- package/dist/agent/types.d.ts +261 -0
- package/dist/agent/useAgent.d.ts +7 -0
- package/dist/auth/AuthProvider.d.ts +13 -0
- package/dist/auth/RequireAuth.d.ts +13 -0
- package/dist/auth/authContext.d.ts +33 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/useAuth.d.ts +7 -0
- package/dist/commands/CommandProvider.d.ts +12 -0
- package/dist/commands/commandContext.d.ts +57 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/shortcut.d.ts +9 -0
- package/dist/commands/useCommands.d.ts +6 -0
- package/dist/commands/useRegisterCommands.d.ts +7 -0
- package/dist/components/ui/AgentPanel.d.ts +23 -0
- package/dist/components/ui/AuthLayout.d.ts +11 -0
- package/dist/components/ui/Avatar.d.ts +26 -0
- package/dist/components/ui/BlastRadiusBar.d.ts +24 -0
- package/dist/components/ui/Breadcrumb.d.ts +29 -0
- package/dist/components/ui/BucketCard.d.ts +24 -0
- package/dist/components/ui/Button.d.ts +14 -0
- package/dist/components/ui/ChatComposer.d.ts +10 -0
- package/dist/components/ui/ChatMessage.d.ts +31 -0
- package/dist/components/ui/ChatMessageList.d.ts +23 -0
- package/dist/components/ui/ChatSessionList.d.ts +22 -0
- package/dist/components/ui/Chip.d.ts +22 -0
- package/dist/components/ui/CodeBlock.d.ts +21 -0
- package/dist/components/ui/CodeEditor.d.ts +42 -0
- package/dist/components/ui/CommandInvocationCard.d.ts +24 -0
- package/dist/components/ui/CommandPalette.d.ts +3 -0
- package/dist/components/ui/ControlListItem.d.ts +18 -0
- package/dist/components/ui/DangerZone.d.ts +9 -0
- package/dist/components/ui/DataList.d.ts +30 -0
- package/dist/components/ui/DataTable.d.ts +48 -0
- package/dist/components/ui/DiffViewer.d.ts +33 -0
- package/dist/components/ui/DropdownMenu.d.ts +20 -0
- package/dist/components/ui/EmptyState.d.ts +10 -0
- package/dist/components/ui/EnvironmentSwitcher.d.ts +29 -0
- package/dist/components/ui/ErrorState.d.ts +11 -0
- package/dist/components/ui/EventTable.d.ts +39 -0
- package/dist/components/ui/FileDropzone.d.ts +47 -0
- package/dist/components/ui/FilePreview.d.ts +34 -0
- package/dist/components/ui/FolderDropzone.d.ts +24 -0
- package/dist/components/ui/ForgotPasswordForm.d.ts +12 -0
- package/dist/components/ui/FormRow.d.ts +9 -0
- package/dist/components/ui/InboxPage.d.ts +18 -0
- package/dist/components/ui/KeyValueList.d.ts +27 -0
- package/dist/components/ui/LoginForm.d.ts +18 -0
- package/dist/components/ui/Markdown.d.ts +6 -0
- package/dist/components/ui/MetadataList.d.ts +15 -0
- package/dist/components/ui/MetricCard.d.ts +30 -0
- package/dist/components/ui/MetricLabel.d.ts +11 -0
- package/dist/components/ui/MonoValue.d.ts +22 -0
- package/dist/components/ui/NotificationBell.d.ts +12 -0
- package/dist/components/ui/ObjectBrowser.d.ts +40 -0
- package/dist/components/ui/ObjectInspector.d.ts +27 -0
- package/dist/components/ui/PageHeader.d.ts +9 -0
- package/dist/components/ui/PageSizeSelect.d.ts +11 -0
- package/dist/components/ui/Panel.d.ts +22 -0
- package/dist/components/ui/PanelTitle.d.ts +10 -0
- package/dist/components/ui/ParquetViewer.d.ts +30 -0
- package/dist/components/ui/PasswordField.d.ts +9 -0
- package/dist/components/ui/ProjectSelector.d.ts +17 -0
- package/dist/components/ui/QueryAutocomplete.d.ts +26 -0
- package/dist/components/ui/RegisterForm.d.ts +14 -0
- package/dist/components/ui/ResizableSidePanel.d.ts +21 -0
- package/dist/components/ui/SavedQueryBar.d.ts +16 -0
- package/dist/components/ui/SearchInput.d.ts +12 -0
- package/dist/components/ui/SectionDivider.d.ts +12 -0
- package/dist/components/ui/ServiceMap.d.ts +28 -0
- package/dist/components/ui/SettingsSection.d.ts +9 -0
- package/dist/components/ui/ShareLinkDialog.d.ts +25 -0
- package/dist/components/ui/Skeleton.d.ts +16 -0
- package/dist/components/ui/SparkLine.d.ts +27 -0
- package/dist/components/ui/StatBlock.d.ts +29 -0
- package/dist/components/ui/StatusDot.d.ts +8 -0
- package/dist/components/ui/Tabs.d.ts +18 -0
- package/dist/components/ui/Terminal.d.ts +25 -0
- package/dist/components/ui/TextField.d.ts +10 -0
- package/dist/components/ui/ThemeToggle.d.ts +13 -0
- package/dist/components/ui/TimeDisplay.d.ts +11 -0
- package/dist/components/ui/TimeRangePicker.d.ts +18 -0
- package/dist/components/ui/Timeline.d.ts +32 -0
- package/dist/components/ui/TimelineChart.d.ts +23 -0
- package/dist/components/ui/ToolCallCard.d.ts +24 -0
- package/dist/components/ui/Toolbar.d.ts +24 -0
- package/dist/components/ui/TraceTree.d.ts +35 -0
- package/dist/components/ui/TrajectoryStep.d.ts +28 -0
- package/dist/components/ui/TrajectoryTimeline.d.ts +22 -0
- package/dist/components/ui/UploadQueue.d.ts +13 -0
- package/dist/components/ui/index.d.ts +130 -0
- package/dist/components/ui/relativeTime.d.ts +5 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useResizable.d.ts +15 -0
- package/dist/hooks/useSavedQueries.d.ts +23 -0
- package/dist/index-6WZzHI2Z.cjs +1151 -0
- package/dist/index-6WZzHI2Z.cjs.map +1 -0
- package/dist/index-CZ_qegBG.js +6736 -0
- package/dist/index-CZ_qegBG.js.map +1 -0
- package/dist/index-DLXAAlfH.cjs +15 -0
- package/dist/index-DLXAAlfH.cjs.map +1 -0
- package/dist/index-DtgBxtmy.js +56284 -0
- package/dist/index-DtgBxtmy.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/PageWrapper.d.ts +10 -0
- package/dist/layouts/shell/AegisShell.d.ts +11 -0
- package/dist/layouts/shell/AppSwitcher.d.ts +14 -0
- package/dist/layouts/shell/AuthRequiredCard.d.ts +16 -0
- package/dist/layouts/shell/BreadcrumbBar.d.ts +13 -0
- package/dist/layouts/shell/Sidebar.d.ts +11 -0
- package/dist/layouts/shell/TopHeader.d.ts +33 -0
- package/dist/layouts/shell/activeAppContext.d.ts +15 -0
- package/dist/layouts/shell/environments/EnvironmentContext.d.ts +12 -0
- package/dist/layouts/shell/environments/context.d.ts +6 -0
- package/dist/layouts/shell/environments/hooks.d.ts +8 -0
- package/dist/layouts/shell/environments/index.d.ts +4 -0
- package/dist/layouts/shell/environments/manifest.d.ts +26 -0
- package/dist/layouts/shell/environments/types.d.ts +55 -0
- package/dist/layouts/shell/index.d.ts +7 -0
- package/dist/layouts/shell/types.d.ts +173 -0
- package/dist/layouts/shell/useAppNavigate.d.ts +21 -0
- package/dist/lib/luceneQuery/compile.d.ts +29 -0
- package/dist/lib/luceneQuery/index.d.ts +4 -0
- package/dist/lib/luceneQuery/tokenizeAtCursor.d.ts +21 -0
- package/dist/lib/timeRange.d.ts +25 -0
- package/dist/notifications/NotificationProvider.d.ts +13 -0
- package/dist/notifications/index.d.ts +3 -0
- package/dist/notifications/notificationContext.d.ts +38 -0
- package/dist/notifications/useNotifications.d.ts +7 -0
- package/dist/style.css +1 -0
- package/dist/styles/fonts.d.ts +0 -0
- package/dist/theme/ThemeProvider.d.ts +14 -0
- package/dist/theme/antdTheme.d.ts +9 -0
- package/dist/theme/themeContext.d.ts +12 -0
- package/dist/theme/useTheme.d.ts +2 -0
- package/dist/workerBundle-D52AeOj1.js +76 -0
- package/dist/workerBundle-D52AeOj1.js.map +1 -0
- package/dist/workerBundle-FGNDqtbW.cjs +73 -0
- package/dist/workerBundle-FGNDqtbW.cjs.map +1 -0
- package/package.json +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @lincyaw/aegis-ui
|
|
2
|
+
|
|
3
|
+
AegisLab shared design system: tokens, primitives, layout, AntD theme.
|
|
4
|
+
|
|
5
|
+
See the [repository root README](../../README.md) for project documentation,
|
|
6
|
+
conventions, and the AegisApp contract.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @lincyaw/aegis-ui
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { PageWrapper, Panel } from '@lincyaw/aegis-ui';
|
|
16
|
+
import '@lincyaw/aegis-ui/style.css';
|
|
17
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AegisRuntime } from './runtime';
|
|
3
|
+
import { ShellSnapshot } from './types';
|
|
4
|
+
interface BridgeConfig {
|
|
5
|
+
url: string;
|
|
6
|
+
authToken?: string;
|
|
7
|
+
autoConnect?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface AegisAgentProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** Externally-provided runtime — pass when the host wants control. */
|
|
12
|
+
runtime?: AegisRuntime;
|
|
13
|
+
/** Current app id from the shell. Threaded into ActionSource for hooks. */
|
|
14
|
+
appId?: string | null;
|
|
15
|
+
/** Live shell snapshot getter — called on every snapshot() invocation. */
|
|
16
|
+
shellSnapshot?: () => ShellSnapshot;
|
|
17
|
+
/** Router navigate fn — wired into ActionContext.navigate + aegis.navigate. */
|
|
18
|
+
navigate?: (to: string) => void;
|
|
19
|
+
/** When true (default), mount the runtime on `window.__aegis`. */
|
|
20
|
+
exposeOnWindow?: boolean;
|
|
21
|
+
/** MCP bridge WebSocket URL (e.g. ws://127.0.0.1:3323/aegis-bridge/ws). */
|
|
22
|
+
bridgeUrl?: string;
|
|
23
|
+
/** Bearer token for bridge auth. Omit when bridge runs --bridge-no-auth. */
|
|
24
|
+
bridgeAuthToken?: string;
|
|
25
|
+
/** Default false. Set true to open the WS on mount and reconnect. */
|
|
26
|
+
bridgeAutoConnect?: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface Window {
|
|
30
|
+
__aegis?: AegisRuntime;
|
|
31
|
+
__AEGIS_BRIDGE__?: BridgeConfig;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export declare function AegisAgentProvider({ children, runtime: externalRuntime, appId, shellSnapshot, navigate, exposeOnWindow, bridgeUrl, bridgeAuthToken, bridgeAutoConnect, }: AegisAgentProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { AgentContextValue } from './agentContext';
|
|
3
|
+
interface AgentProviderProps {
|
|
4
|
+
value: AgentContextValue;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Thin context wrapper. The library deliberately holds no agent state —
|
|
9
|
+
* the host owns the LLM round-trip, tool-call dispatch, and message
|
|
10
|
+
* history, and feeds the resulting value in.
|
|
11
|
+
*/
|
|
12
|
+
export declare function AgentProvider({ value, children, }: AgentProviderProps): ReactElement;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { AgentMessage, AgentMessageRole, AgentToolCallRecord } from './agentContext';
|
|
3
|
+
import { AgentmChannelClientOptions, ConnectionStatus, Envelope } from './agentmChannelClient';
|
|
4
|
+
type ChannelOptions = Omit<AgentmChannelClientOptions, 'peerId'> & {
|
|
5
|
+
/** Stable peer id. Defaults to a sessionStorage-persisted random id. */
|
|
6
|
+
peerId?: string;
|
|
7
|
+
};
|
|
8
|
+
interface AgentmChannelProviderProps {
|
|
9
|
+
channel: ChannelOptions;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Initial messages — for resuming a prior thread server-side. The
|
|
13
|
+
* library still does not persist anything itself.
|
|
14
|
+
*/
|
|
15
|
+
initialMessages?: AgentMessage[];
|
|
16
|
+
/** Notified on every connection-state change. */
|
|
17
|
+
onStatusChange?: (status: ConnectionStatus) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Custom mapper from an `outbound` envelope to a renderable assistant
|
|
20
|
+
* message. Default reads `body.content` as the text body.
|
|
21
|
+
*/
|
|
22
|
+
mapOutbound?: (env: Envelope) => MappedOutbound | null;
|
|
23
|
+
}
|
|
24
|
+
interface MappedOutbound {
|
|
25
|
+
content: string;
|
|
26
|
+
role?: AgentMessageRole;
|
|
27
|
+
final?: boolean;
|
|
28
|
+
streamId?: string | null;
|
|
29
|
+
toolCall?: AgentToolCallRecord;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Connects to an AgentM channels gateway (contrib/channels) as a
|
|
33
|
+
* `chat_client` peer over WebSocket and exposes the conversation as
|
|
34
|
+
* an `AgentContextValue` consumable by `<AgentPanel>` / `useAgent`.
|
|
35
|
+
*
|
|
36
|
+
* The client owns the round-trip: `send(content)` emits an `inbound`
|
|
37
|
+
* envelope; `outbound` envelopes from the gateway become assistant
|
|
38
|
+
* messages. Streamed responses (same `stream_id`) replace the same
|
|
39
|
+
* message in place — contrib/channels sends cumulative content per
|
|
40
|
+
* chunk, not deltas. Non-streamed outbounds become discrete messages.
|
|
41
|
+
*/
|
|
42
|
+
export declare function AgentmChannelProvider({ channel, children, initialMessages, onStatusChange, mapOutbound, }: AgentmChannelProviderProps): ReactElement;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { AegisActionDescriptor, AskContext } from './types';
|
|
3
|
+
export interface AskPanelProps {
|
|
4
|
+
context: AskContext;
|
|
5
|
+
/** Tools the agent could invoke. Defaults to deriving from snapshot. */
|
|
6
|
+
tools?: AegisActionDescriptor[];
|
|
7
|
+
/** Optional anchor — the panel positions itself near this rect. */
|
|
8
|
+
anchorRect?: DOMRect | null;
|
|
9
|
+
/** Preferred anchor point (e.g. mouse position). Wins over anchorRect. */
|
|
10
|
+
anchorPoint?: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
} | null;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
/** When true, render fixed-positioned popover; when false, inline. */
|
|
16
|
+
popover?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function AskPanel({ context, tools, anchorRect, anchorPoint, onClose, popover, }: AskPanelProps): ReactElement;
|
|
19
|
+
export default AskPanel;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type AgentMessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
2
|
+
export interface AgentCommandInvocation {
|
|
3
|
+
/** The command id the agent called, e.g. 'projects.create'. */
|
|
4
|
+
commandId: string;
|
|
5
|
+
/** Arguments passed. Library does not validate. */
|
|
6
|
+
args?: unknown;
|
|
7
|
+
status: 'pending' | 'success' | 'error';
|
|
8
|
+
/** Set when status is 'error'. */
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentToolCallRecord {
|
|
12
|
+
toolCallId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
/** Raw args dict from the gateway; renderers stringify on demand. */
|
|
15
|
+
args: unknown;
|
|
16
|
+
status: 'running' | 'ok' | 'error';
|
|
17
|
+
resultText?: string;
|
|
18
|
+
isError?: boolean;
|
|
19
|
+
startedAt?: number;
|
|
20
|
+
endedAt?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentMessage {
|
|
23
|
+
id: string;
|
|
24
|
+
role: AgentMessageRole;
|
|
25
|
+
content: string;
|
|
26
|
+
/** Command calls the assistant attempted in this message. */
|
|
27
|
+
invocations?: AgentCommandInvocation[];
|
|
28
|
+
/** Set on messages with role === 'tool'. */
|
|
29
|
+
toolCall?: AgentToolCallRecord;
|
|
30
|
+
/** ISO timestamp. */
|
|
31
|
+
timestamp: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Contract every agent-chat integration implements. The library does
|
|
35
|
+
* not own state — callers wire their own LLM / tool-calling adapter and
|
|
36
|
+
* pass the resulting value through `<AgentProvider value={...}>`.
|
|
37
|
+
*/
|
|
38
|
+
export interface AgentContextValue {
|
|
39
|
+
messages: AgentMessage[];
|
|
40
|
+
/** True while the assistant is generating a response. */
|
|
41
|
+
sending: boolean;
|
|
42
|
+
/** Send a user message. Host handles the LLM round-trip and state updates. */
|
|
43
|
+
send: (content: string) => Promise<void> | void;
|
|
44
|
+
/** Optional: clear the current thread. */
|
|
45
|
+
clear?: () => void;
|
|
46
|
+
/** Optional: panel open/closed (panel controls). Persisted by host. */
|
|
47
|
+
panelOpen?: boolean;
|
|
48
|
+
/** Optional: toggle panel. */
|
|
49
|
+
setPanelOpen?: (open: boolean) => void;
|
|
50
|
+
}
|
|
51
|
+
export declare const defaultAgentContextValue: AgentContextValue;
|
|
52
|
+
export declare const AgentContext: import('react').Context<AgentContextValue>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare const WIRE_VERSION = 1;
|
|
2
|
+
export type EnvelopeKind = 'hello' | 'welcome' | 'inbound' | 'outbound' | 'ack' | 'ack_batch' | 'ping' | 'pong' | 'error' | 'bye' | 'delivery_batch';
|
|
3
|
+
export interface Envelope {
|
|
4
|
+
v: number;
|
|
5
|
+
id: string;
|
|
6
|
+
kind: EnvelopeKind;
|
|
7
|
+
ts: number;
|
|
8
|
+
body: Record<string, unknown>;
|
|
9
|
+
to?: string;
|
|
10
|
+
correlation_id?: string;
|
|
11
|
+
hops?: number;
|
|
12
|
+
root_session_key?: string;
|
|
13
|
+
peer_kind?: string;
|
|
14
|
+
}
|
|
15
|
+
export type ConnectionStatus = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'closed';
|
|
16
|
+
export interface AgentmChannelClientOptions {
|
|
17
|
+
url: string;
|
|
18
|
+
peerId: string;
|
|
19
|
+
/** Default: 'chat_client'. */
|
|
20
|
+
peerKind?: string;
|
|
21
|
+
/** Bearer/shared token sent in the hello body. */
|
|
22
|
+
token?: string;
|
|
23
|
+
/** Default: 'web'. Goes into every inbound body. */
|
|
24
|
+
channel?: string;
|
|
25
|
+
/** Default: same as peerId. Goes into every inbound body. */
|
|
26
|
+
chatId?: string;
|
|
27
|
+
capabilities?: Record<string, unknown>;
|
|
28
|
+
/** Reconnect backoff schedule in ms. Defaults to [1000, 2000, 5000, 10000]. */
|
|
29
|
+
reconnectBackoffMs?: number[];
|
|
30
|
+
/** If false, do not auto-reconnect after close. Default true. */
|
|
31
|
+
autoReconnect?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type Listener<T> = (value: T) => void;
|
|
34
|
+
interface ConnectResult {
|
|
35
|
+
welcome: Envelope;
|
|
36
|
+
}
|
|
37
|
+
export declare class AgentmChannelClient {
|
|
38
|
+
private readonly opts;
|
|
39
|
+
private ws;
|
|
40
|
+
private status;
|
|
41
|
+
private attempt;
|
|
42
|
+
private reconnectTimer;
|
|
43
|
+
private welcomePending;
|
|
44
|
+
private explicitlyClosed;
|
|
45
|
+
private readonly outboundListeners;
|
|
46
|
+
private readonly errorListeners;
|
|
47
|
+
private readonly statusListeners;
|
|
48
|
+
private readonly anyListeners;
|
|
49
|
+
constructor(options: AgentmChannelClientOptions);
|
|
50
|
+
get connectionStatus(): ConnectionStatus;
|
|
51
|
+
get peerId(): string;
|
|
52
|
+
get sessionKey(): string;
|
|
53
|
+
/** Open the WebSocket and complete the hello/welcome handshake. */
|
|
54
|
+
connect(): Promise<ConnectResult>;
|
|
55
|
+
/** Close the connection. Disables auto-reconnect for this client. */
|
|
56
|
+
close(): void;
|
|
57
|
+
/** Send an arbitrary envelope. Throws if not OPEN. */
|
|
58
|
+
send(env: Envelope): void;
|
|
59
|
+
/** Convenience: send an `inbound` envelope with `{channel, chat_id, content}`. */
|
|
60
|
+
sendInbound(content: string, extraBody?: Record<string, unknown>): string;
|
|
61
|
+
/** Convenience: send a `ping`. */
|
|
62
|
+
ping(): void;
|
|
63
|
+
onOutbound(cb: Listener<Envelope>): () => void;
|
|
64
|
+
onError(cb: Listener<Envelope>): () => void;
|
|
65
|
+
onStatusChange(cb: Listener<ConnectionStatus>): () => void;
|
|
66
|
+
/** Fires for every envelope received (including welcome/pong/error). */
|
|
67
|
+
onAny(cb: Listener<Envelope>): () => void;
|
|
68
|
+
private makeEnvelope;
|
|
69
|
+
private setStatus;
|
|
70
|
+
private openOnce;
|
|
71
|
+
private handleEnvelope;
|
|
72
|
+
private handleFatal;
|
|
73
|
+
private failPending;
|
|
74
|
+
private scheduleReconnect;
|
|
75
|
+
}
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AegisRuntime } from './runtime';
|
|
2
|
+
import { AskContext, AskOrigin } from './types';
|
|
3
|
+
export interface AskTrigger {
|
|
4
|
+
origin: AskOrigin;
|
|
5
|
+
surfaceId?: string;
|
|
6
|
+
entityId?: string;
|
|
7
|
+
actionId?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildAskContext(runtime: AegisRuntime, trigger: AskTrigger): AskContext;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { AegisAction, SearchProvider, SurfaceKind, SurfaceSnapshot } from './types';
|
|
3
|
+
export interface UseAegisActionResult<P, R> {
|
|
4
|
+
invoke: (params: P) => Promise<R>;
|
|
5
|
+
available: boolean;
|
|
6
|
+
unavailableReason?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function useAegisAction<P = void, R = unknown>(action: AegisAction<P, R> | null | undefined): UseAegisActionResult<P, R>;
|
|
9
|
+
export interface UseAegisSurfaceOptions<T> {
|
|
10
|
+
id: string;
|
|
11
|
+
kind: SurfaceKind;
|
|
12
|
+
label?: string;
|
|
13
|
+
data: T;
|
|
14
|
+
project: (data: T) => Pick<SurfaceSnapshot, 'entities' | 'fields'>;
|
|
15
|
+
ref?: RefObject<HTMLElement | null>;
|
|
16
|
+
askSuggestions?: string[];
|
|
17
|
+
/** When false the hook is a no-op — lets callers skip registration. */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface UseAegisSurfaceResult {
|
|
21
|
+
surfaceId: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function useAegisSurface<T>(opts: UseAegisSurfaceOptions<T>): UseAegisSurfaceResult;
|
|
24
|
+
export declare function useAegisSearchProvider(provider: SearchProvider): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { AgentProvider } from './AgentProvider';
|
|
2
|
+
export { useAgent } from './useAgent';
|
|
3
|
+
export { AgentmChannelProvider } from './AgentmChannelProvider';
|
|
4
|
+
export { AgentmChannelClient, WIRE_VERSION as AGENTM_WIRE_VERSION, } from './agentmChannelClient';
|
|
5
|
+
export type { AgentmChannelClientOptions, ConnectionStatus as AgentmConnectionStatus, Envelope as AgentmEnvelope, EnvelopeKind as AgentmEnvelopeKind, } from './agentmChannelClient';
|
|
6
|
+
export type { AgentContextValue, AgentMessage, AgentMessageRole, AgentCommandInvocation, AgentToolCallRecord, } from './agentContext';
|
|
7
|
+
export { AegisAgentProvider } from './AegisAgentProvider';
|
|
8
|
+
export { useAegisAction, useAegisSearchProvider, useAegisSurface, } from './hooks';
|
|
9
|
+
export type { UseAegisActionResult, UseAegisSurfaceOptions, UseAegisSurfaceResult, } from './hooks';
|
|
10
|
+
export { AskOverlay } from './AskOverlay';
|
|
11
|
+
export { AskPanel } from './AskPanel';
|
|
12
|
+
export type { AskPanelProps } from './AskPanel';
|
|
13
|
+
export { buildAskContext } from './buildAskContext';
|
|
14
|
+
export type { AskTrigger } from './buildAskContext';
|
|
15
|
+
export { createAegisRuntime } from './runtime';
|
|
16
|
+
export type { AegisRuntime, ListActionsFilter, RegisteredAction, RegisteredSurface, RuntimeDeps, SearchOptions, } from './runtime';
|
|
17
|
+
export type { ActionContext, ActionPreview, ActionSource, AegisAction, AegisActionDescriptor, AegisError, AegisErrorCode, AegisEvent, AegisInspectResult, AegisRef, AegisSearchResult, AegisSnapshot, AskContext, AskMessage, AskOrigin, AskRequest, DispatchResult, EntityProjection, EntityRef, FieldProjection, InvocationSource, McpToolDefinition, SearchProvider, ShellSnapshot, SnapshotDiff, SurfaceKind, SurfaceSnapshot, } from './types';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ActionSource, AegisAction, AegisActionDescriptor, AegisEvent, AegisInspectResult, AegisRef, AegisSearchResult, AegisSnapshot, AskContext, AskRequest, DispatchResult, EntityRef, InvocationSource, McpToolDefinition, SearchProvider, ShellSnapshot, SurfaceKind, SurfaceSnapshot } from './types';
|
|
2
|
+
export interface RegisteredAction {
|
|
3
|
+
action: AegisAction<unknown, unknown>;
|
|
4
|
+
source: ActionSource;
|
|
5
|
+
}
|
|
6
|
+
export interface RegisteredSurface {
|
|
7
|
+
id: string;
|
|
8
|
+
kind: SurfaceKind;
|
|
9
|
+
appId: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
getProjection: () => Pick<SurfaceSnapshot, 'entities' | 'fields'>;
|
|
12
|
+
getBBox?: () => SurfaceSnapshot['bbox'];
|
|
13
|
+
getInViewport?: () => boolean;
|
|
14
|
+
askSuggestions?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface ListActionsFilter {
|
|
17
|
+
available?: boolean;
|
|
18
|
+
appId?: string;
|
|
19
|
+
invocableBy?: InvocationSource;
|
|
20
|
+
}
|
|
21
|
+
export interface SearchOptions {
|
|
22
|
+
kinds?: Array<AegisRef['kind']>;
|
|
23
|
+
appId?: string;
|
|
24
|
+
limit?: number;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
export interface AegisRuntime {
|
|
28
|
+
snapshot(): AegisSnapshot;
|
|
29
|
+
listActions(filter?: ListActionsFilter): AegisActionDescriptor[];
|
|
30
|
+
getAction(id: string): AegisActionDescriptor | null;
|
|
31
|
+
inspect(ref: AegisRef): AegisInspectResult | null;
|
|
32
|
+
search(query: string, opts?: SearchOptions): Promise<AegisSearchResult[]>;
|
|
33
|
+
highlight(ref: AegisRef): Promise<{
|
|
34
|
+
found: boolean;
|
|
35
|
+
bbox?: DOMRect;
|
|
36
|
+
}>;
|
|
37
|
+
waitFor(predicate: string, opts?: {
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<AegisSnapshot>;
|
|
41
|
+
toMcpTools(): McpToolDefinition[];
|
|
42
|
+
dispatch<R = unknown>(id: string, params?: unknown, opts?: {
|
|
43
|
+
force?: boolean;
|
|
44
|
+
correlationId?: string;
|
|
45
|
+
by?: InvocationSource;
|
|
46
|
+
}): Promise<DispatchResult<R>>;
|
|
47
|
+
subscribe(listener: (e: AegisEvent) => void): () => void;
|
|
48
|
+
/** Subscribe specifically to ask-triggered events (sugar over subscribe). */
|
|
49
|
+
onAskTriggered(handler: (ctx: AskContext) => void): () => void;
|
|
50
|
+
/** Emit an ask-triggered event. Used by AskOverlay + programmatic openers. */
|
|
51
|
+
emitAskTriggered(ctx: AskContext): void;
|
|
52
|
+
/** Emit an ask-submit event. Env-only — there is no transport yet. */
|
|
53
|
+
emitAskSubmit(req: AskRequest): void;
|
|
54
|
+
_register(entry: RegisteredAction): () => void;
|
|
55
|
+
_registerSurface(entry: RegisteredSurface): () => void;
|
|
56
|
+
_registerSearchProvider(provider: SearchProvider): () => void;
|
|
57
|
+
_setSelection(refs: EntityRef[]): void;
|
|
58
|
+
_setShellSnapshot(getter: () => ShellSnapshot): void;
|
|
59
|
+
_setNavigate(nav: (to: string) => void): void;
|
|
60
|
+
}
|
|
61
|
+
export interface RuntimeDeps {
|
|
62
|
+
navigate?: (to: string) => void;
|
|
63
|
+
toast?: (msg: string, level?: 'info' | 'warn' | 'error') => void;
|
|
64
|
+
}
|
|
65
|
+
export declare function createAegisRuntime(deps?: RuntimeDeps): AegisRuntime;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
export type InvocationSource = 'user' | 'agent' | 'system';
|
|
2
|
+
export interface EntityRef {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
}
|
|
6
|
+
export interface EntityProjection extends EntityRef {
|
|
7
|
+
label?: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface FieldProjection {
|
|
11
|
+
name: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
type: string;
|
|
14
|
+
value: unknown;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
invalid?: string;
|
|
17
|
+
}
|
|
18
|
+
export type SurfaceKind = 'list' | 'table' | 'form' | 'detail' | 'dialog' | 'panel' | 'chart' | 'editor' | 'metric' | 'code' | 'diff' | 'preview' | 'terminal' | 'timeline' | 'tree' | 'chat' | 'message' | 'entity' | 'value' | 'tag';
|
|
19
|
+
export interface SurfaceSnapshot {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: SurfaceKind;
|
|
22
|
+
appId: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
entities?: EntityProjection[];
|
|
25
|
+
fields?: FieldProjection[];
|
|
26
|
+
actionIds: string[];
|
|
27
|
+
bbox?: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
inViewport: boolean;
|
|
34
|
+
askSuggestions?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface ShellSnapshot {
|
|
37
|
+
currentAppId: string | null;
|
|
38
|
+
route: {
|
|
39
|
+
pathname: string;
|
|
40
|
+
search: string;
|
|
41
|
+
params: Record<string, string>;
|
|
42
|
+
};
|
|
43
|
+
breadcrumbs: Array<{
|
|
44
|
+
label: string;
|
|
45
|
+
href?: string;
|
|
46
|
+
}>;
|
|
47
|
+
theme: 'light' | 'dark';
|
|
48
|
+
viewport: {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface AegisSnapshot {
|
|
54
|
+
timestamp: number;
|
|
55
|
+
shell: ShellSnapshot;
|
|
56
|
+
surfaces: SurfaceSnapshot[];
|
|
57
|
+
selection: EntityRef[];
|
|
58
|
+
focus: {
|
|
59
|
+
surfaceId: string | null;
|
|
60
|
+
entityId: string | null;
|
|
61
|
+
};
|
|
62
|
+
appData: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
export interface ActionContext {
|
|
65
|
+
appId: string;
|
|
66
|
+
navigate: (to: string) => void;
|
|
67
|
+
snapshot: () => AegisSnapshot;
|
|
68
|
+
toast: (msg: string, level?: 'info' | 'warn' | 'error') => void;
|
|
69
|
+
correlationId: string;
|
|
70
|
+
invokedBy: InvocationSource;
|
|
71
|
+
signal: AbortSignal;
|
|
72
|
+
}
|
|
73
|
+
export interface ActionPreview {
|
|
74
|
+
summary: string;
|
|
75
|
+
affectedEntities?: EntityRef[];
|
|
76
|
+
diff?: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface AegisAction<P = unknown, R = unknown> {
|
|
79
|
+
id: string;
|
|
80
|
+
label: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
category?: string;
|
|
83
|
+
keywords?: string[];
|
|
84
|
+
shortcut?: string;
|
|
85
|
+
paramsSchema?: unknown;
|
|
86
|
+
resultSchema?: unknown;
|
|
87
|
+
run: (params: P, ctx: ActionContext) => Promise<R> | R;
|
|
88
|
+
dryRun?: (params: P, ctx: ActionContext) => Promise<ActionPreview> | ActionPreview;
|
|
89
|
+
availability?: (snap: AegisSnapshot) => true | string;
|
|
90
|
+
confirm?: {
|
|
91
|
+
title: string;
|
|
92
|
+
body?: string;
|
|
93
|
+
danger?: boolean;
|
|
94
|
+
};
|
|
95
|
+
invocableBy?: 'user' | 'agent' | 'both';
|
|
96
|
+
/** Noun-first discovery binding. See docs/agent-native-ui.md §3.5. */
|
|
97
|
+
appliesTo?: {
|
|
98
|
+
entityType?: string;
|
|
99
|
+
surfaceKind?: SurfaceKind;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export type AegisRef = {
|
|
103
|
+
kind: 'surface';
|
|
104
|
+
surfaceId: string;
|
|
105
|
+
} | {
|
|
106
|
+
kind: 'entity';
|
|
107
|
+
entityId: string;
|
|
108
|
+
surfaceId?: string;
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'action';
|
|
111
|
+
actionId: string;
|
|
112
|
+
} | {
|
|
113
|
+
kind: 'route';
|
|
114
|
+
appId: string;
|
|
115
|
+
pathname: string;
|
|
116
|
+
};
|
|
117
|
+
export interface AegisInspectResult {
|
|
118
|
+
ref: AegisRef;
|
|
119
|
+
surface?: SurfaceSnapshot;
|
|
120
|
+
entity?: EntityProjection;
|
|
121
|
+
action?: AegisActionDescriptor;
|
|
122
|
+
actions: AegisActionDescriptor[];
|
|
123
|
+
entities?: EntityProjection[];
|
|
124
|
+
}
|
|
125
|
+
export interface AegisSearchResult {
|
|
126
|
+
ref: AegisRef;
|
|
127
|
+
kind: AegisRef['kind'];
|
|
128
|
+
label: string;
|
|
129
|
+
snippet?: string;
|
|
130
|
+
appId?: string;
|
|
131
|
+
source: 'snapshot' | 'provider';
|
|
132
|
+
score: number;
|
|
133
|
+
}
|
|
134
|
+
export interface SearchProvider {
|
|
135
|
+
id: string;
|
|
136
|
+
appId: string;
|
|
137
|
+
kinds: Array<'entity' | 'route'>;
|
|
138
|
+
matches?: (query: string) => boolean;
|
|
139
|
+
search: (query: string, opts: {
|
|
140
|
+
limit: number;
|
|
141
|
+
signal: AbortSignal;
|
|
142
|
+
}) => Promise<AegisSearchResult[]>;
|
|
143
|
+
}
|
|
144
|
+
export interface McpToolDefinition {
|
|
145
|
+
name: string;
|
|
146
|
+
description: string;
|
|
147
|
+
inputSchema: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
export type ActionSource = {
|
|
150
|
+
kind: 'app';
|
|
151
|
+
appId: string;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'route';
|
|
154
|
+
appId: string;
|
|
155
|
+
pathname: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: 'component';
|
|
158
|
+
appId: string;
|
|
159
|
+
surfaceId?: string;
|
|
160
|
+
nodeId: string;
|
|
161
|
+
};
|
|
162
|
+
export interface AegisActionDescriptor {
|
|
163
|
+
id: string;
|
|
164
|
+
label: string;
|
|
165
|
+
description?: string;
|
|
166
|
+
category?: string;
|
|
167
|
+
paramsSchema?: unknown;
|
|
168
|
+
resultSchema?: unknown;
|
|
169
|
+
available: boolean;
|
|
170
|
+
unavailableReason?: string;
|
|
171
|
+
invocableBy: 'user' | 'agent' | 'both';
|
|
172
|
+
source: ActionSource;
|
|
173
|
+
}
|
|
174
|
+
export type AegisErrorCode = 'unknown_action' | 'unavailable' | 'invalid_params' | 'needs_confirm' | 'aborted' | 'thrown';
|
|
175
|
+
export interface AegisError {
|
|
176
|
+
code: AegisErrorCode;
|
|
177
|
+
message: string;
|
|
178
|
+
reason?: unknown;
|
|
179
|
+
}
|
|
180
|
+
export type DispatchResult<R> = {
|
|
181
|
+
ok: true;
|
|
182
|
+
result: R;
|
|
183
|
+
correlationId: string;
|
|
184
|
+
} | {
|
|
185
|
+
ok: false;
|
|
186
|
+
error: AegisError;
|
|
187
|
+
correlationId: string;
|
|
188
|
+
};
|
|
189
|
+
export interface SnapshotDiff {
|
|
190
|
+
added?: string[];
|
|
191
|
+
removed?: string[];
|
|
192
|
+
changed?: string[];
|
|
193
|
+
}
|
|
194
|
+
export type AegisEvent = {
|
|
195
|
+
type: 'action.invoked';
|
|
196
|
+
id: string;
|
|
197
|
+
params: unknown;
|
|
198
|
+
by: InvocationSource;
|
|
199
|
+
correlationId: string;
|
|
200
|
+
} | {
|
|
201
|
+
type: 'action.completed';
|
|
202
|
+
correlationId: string;
|
|
203
|
+
result: unknown;
|
|
204
|
+
durationMs: number;
|
|
205
|
+
} | {
|
|
206
|
+
type: 'action.failed';
|
|
207
|
+
correlationId: string;
|
|
208
|
+
error: AegisError;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'snapshot.changed';
|
|
211
|
+
diff: SnapshotDiff;
|
|
212
|
+
} | {
|
|
213
|
+
type: 'navigation';
|
|
214
|
+
from: string;
|
|
215
|
+
to: string;
|
|
216
|
+
} | {
|
|
217
|
+
type: 'registry.changed';
|
|
218
|
+
added: string[];
|
|
219
|
+
removed: string[];
|
|
220
|
+
} | {
|
|
221
|
+
type: 'ask.triggered';
|
|
222
|
+
context: AskContext;
|
|
223
|
+
} | {
|
|
224
|
+
type: 'ask.submit';
|
|
225
|
+
request: AskRequest;
|
|
226
|
+
};
|
|
227
|
+
export type AskOrigin = 'entity' | 'surface' | 'action' | 'global';
|
|
228
|
+
export interface AskContext {
|
|
229
|
+
/** What the user clicked from. */
|
|
230
|
+
origin: AskOrigin;
|
|
231
|
+
appId: string;
|
|
232
|
+
surface?: {
|
|
233
|
+
id: string;
|
|
234
|
+
kind: SurfaceKind;
|
|
235
|
+
label?: string;
|
|
236
|
+
};
|
|
237
|
+
entity?: EntityProjection;
|
|
238
|
+
selection?: EntityProjection[];
|
|
239
|
+
action?: {
|
|
240
|
+
id: string;
|
|
241
|
+
label: string;
|
|
242
|
+
};
|
|
243
|
+
/** Pre-filled prompt chips, sourced from surface.askSuggestions. */
|
|
244
|
+
suggestions: string[];
|
|
245
|
+
/** Snapshot at trigger time. Frozen — the panel works on this. */
|
|
246
|
+
snapshot: AegisSnapshot;
|
|
247
|
+
}
|
|
248
|
+
export interface AskRequest {
|
|
249
|
+
prompt: string;
|
|
250
|
+
context: AskContext;
|
|
251
|
+
tools: AegisActionDescriptor[];
|
|
252
|
+
/** Conversation so far; first call is empty. */
|
|
253
|
+
history: AskMessage[];
|
|
254
|
+
}
|
|
255
|
+
export type AskMessage = {
|
|
256
|
+
role: 'user';
|
|
257
|
+
content: string;
|
|
258
|
+
} | {
|
|
259
|
+
role: 'assistant';
|
|
260
|
+
content: string;
|
|
261
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AgentContextValue } from './agentContext';
|
|
2
|
+
/**
|
|
3
|
+
* Read the current agent context. Returns the default empty state when
|
|
4
|
+
* no `<AgentProvider>` is mounted, so render code does not have to
|
|
5
|
+
* special-case "agent not wired yet".
|
|
6
|
+
*/
|
|
7
|
+
export declare function useAgent(): AgentContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { AegisAuthUser, AuthContextValue } from './authContext';
|
|
3
|
+
interface AuthProviderProps<TUser = AegisAuthUser> {
|
|
4
|
+
value: AuthContextValue<TUser>;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Thin context wrapper. The library deliberately holds no auth state —
|
|
9
|
+
* the host owns sign-in, token storage, SSO callbacks, etc., and feeds
|
|
10
|
+
* the resulting `{ status, user, signIn?, signOut? }` value in.
|
|
11
|
+
*/
|
|
12
|
+
export declare function AuthProvider<TUser = AegisAuthUser>({ value, children, }: AuthProviderProps<TUser>): ReactElement;
|
|
13
|
+
export {};
|