@aidy-dev/react 0.0.0-stage → 0.1.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/LICENSE +18 -0
- package/README.md +34 -2
- package/dist/index.d.ts +119 -0
- package/dist/index.js +1692 -0
- package/dist/styles.css +997 -0
- package/package.json +61 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Aidy Contributors
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aidy-dev/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React 19 components for aidy:
|
|
4
|
+
- `AidyDock`: a side panel with history and the thread.
|
|
5
|
+
- `AidyThread`
|
|
6
|
+
- `ApprovalCard`
|
|
7
|
+
- `AidyForm`
|
|
8
|
+
- `SearchPalette`: a ⌘K palette with an Ask Aidy fallback.
|
|
9
|
+
- `HelpViewer`
|
|
10
|
+
- `ModelSettings`: the admin page for models.
|
|
11
|
+
- `Markdown`
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { createClient } from '@aidy-dev/client';
|
|
15
|
+
import { AidyDock, AidyProvider, SearchPalette } from '@aidy-dev/react';
|
|
16
|
+
import '@aidy-dev/react/styles.css';
|
|
17
|
+
|
|
18
|
+
const client = createClient({ baseUrl: '/aidy/v0' });
|
|
19
|
+
|
|
20
|
+
export function App() {
|
|
21
|
+
return (
|
|
22
|
+
<AidyProvider client={client} locale="zh-CN" onOpen={(path) => router.push(path)}>
|
|
23
|
+
<YourApp />
|
|
24
|
+
<SearchPalette />
|
|
25
|
+
<AidyDock />
|
|
26
|
+
</AidyProvider>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- **Shortcuts:** ⌘/Ctrl+J toggles the dock and ⌘/Ctrl+K opens search. `useDock()` lets your
|
|
32
|
+
own button open the dock with a question.
|
|
33
|
+
- **Navigation:** `onOpen` only receives same-origin paths.
|
|
34
|
+
- **Theming:** use the `--aidy-*` CSS variables; there are light and dark defaults.
|
|
35
|
+
- **Locales:** `en` and `zh-CN`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { AidyClient, ApprovalInterrupt, CatalogOperation, ResumeEntry, ThreadState, ThreadSummary } from "@aidy-dev/client";
|
|
3
|
+
import { Form, FormAnswers } from "@aidy-dev/spec/protocol";
|
|
4
|
+
import { FederatedSearchResponse, SearchHit } from "@aidy-dev/spec/search";
|
|
5
|
+
interface ApprovalCardProps {
|
|
6
|
+
readonly interrupt: ApprovalInterrupt;
|
|
7
|
+
readonly onAnswer: (approved: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
/** Asks the user to approve one write, showing exactly what will run. */
|
|
10
|
+
export declare function ApprovalCard({ interrupt, onAnswer }: ApprovalCardProps): import("react").JSX.Element;
|
|
11
|
+
type Locale = 'en' | 'zh-CN';
|
|
12
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
13
|
+
interface AidyProviderProps {
|
|
14
|
+
readonly client: AidyClient;
|
|
15
|
+
readonly locale?: Locale;
|
|
16
|
+
/** Shows a product page. Receives only same-origin paths (`/path?query#hash`). */
|
|
17
|
+
readonly onOpen?: (path: string) => void;
|
|
18
|
+
/** The color scheme; `system` follows `prefers-color-scheme`. Colors are CSS variables. */
|
|
19
|
+
readonly theme?: Theme;
|
|
20
|
+
readonly children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export declare function AidyProvider({ client, locale, onOpen, theme, children }: AidyProviderProps): import("react").JSX.Element;
|
|
23
|
+
interface DockHandle {
|
|
24
|
+
readonly open: boolean;
|
|
25
|
+
readonly setOpen: (open: boolean) => void;
|
|
26
|
+
/** Opens the dock on a new conversation that starts with `query`. */
|
|
27
|
+
readonly ask: (query: string) => void;
|
|
28
|
+
}
|
|
29
|
+
/** Controls the dock from the host page, e.g. an "Ask Aidy" button. */
|
|
30
|
+
export declare function useDock(): DockHandle;
|
|
31
|
+
/**
|
|
32
|
+
* The side panel: a launcher, the conversation and its history. ⌘J / Ctrl+J toggles it, Escape
|
|
33
|
+
* closes it; it fills the screen on narrow viewports.
|
|
34
|
+
*/
|
|
35
|
+
export declare function AidyDock(): import("react").JSX.Element;
|
|
36
|
+
interface AidyFormProps {
|
|
37
|
+
readonly form: Form;
|
|
38
|
+
readonly onSubmit: (answers: FormAnswers['answers']) => void;
|
|
39
|
+
}
|
|
40
|
+
/** A form the agent or an operation asks the user to fill in. */
|
|
41
|
+
export declare function AidyForm({ form, onSubmit }: AidyFormProps): import("react").JSX.Element;
|
|
42
|
+
interface HelpViewerProps {
|
|
43
|
+
/** The Markdown page to show; relative links and images resolve against it. */
|
|
44
|
+
readonly url: string;
|
|
45
|
+
}
|
|
46
|
+
/** Fetches and renders one Markdown help page. */
|
|
47
|
+
export declare function HelpViewer({ url }: HelpViewerProps): import("react").JSX.Element;
|
|
48
|
+
interface ThreadHandle {
|
|
49
|
+
/** The thread shown; set once `send` created one. */
|
|
50
|
+
readonly threadId: string | null;
|
|
51
|
+
readonly state: ThreadState;
|
|
52
|
+
/** A request that failed before its run started. */
|
|
53
|
+
readonly error: unknown;
|
|
54
|
+
/** Sends a message, creating the thread when there is none and cancelling open interrupts. */
|
|
55
|
+
readonly send: (text: string) => Promise<void>;
|
|
56
|
+
/** Answers open interrupts. */
|
|
57
|
+
readonly resume: (entries: ResumeEntry[]) => Promise<void>;
|
|
58
|
+
/** Cancels the running run. */
|
|
59
|
+
readonly cancel: () => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A thread's live state: it replays the thread's events and follows them, and opens the pages
|
|
63
|
+
* (`aidy.ui.open`) that runs started here ask for.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useThread(threadId: string | null): ThreadHandle;
|
|
66
|
+
interface ThreadsHandle {
|
|
67
|
+
readonly threads: readonly ThreadSummary[];
|
|
68
|
+
readonly loading: boolean;
|
|
69
|
+
readonly error: unknown;
|
|
70
|
+
/** Whether `loadMore` has another page. */
|
|
71
|
+
readonly hasMore: boolean;
|
|
72
|
+
readonly reload: () => void;
|
|
73
|
+
readonly loadMore: () => void;
|
|
74
|
+
readonly remove: (id: string) => Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/** The user's threads, newest first. */
|
|
77
|
+
export declare function useThreads(): ThreadsHandle;
|
|
78
|
+
interface SearchHandle {
|
|
79
|
+
/** The answer for the current query; null while it is empty or not yet answered. */
|
|
80
|
+
readonly result: FederatedSearchResponse | null;
|
|
81
|
+
readonly loading: boolean;
|
|
82
|
+
readonly error: unknown;
|
|
83
|
+
}
|
|
84
|
+
/** Federated search, debounced; a newer query aborts the older request. */
|
|
85
|
+
export declare function useSearch(query: string): SearchHandle;
|
|
86
|
+
interface CatalogHandle {
|
|
87
|
+
readonly operations: readonly CatalogOperation[];
|
|
88
|
+
readonly loading: boolean;
|
|
89
|
+
readonly error: unknown;
|
|
90
|
+
}
|
|
91
|
+
/** The operations visible to this user. */
|
|
92
|
+
export declare function useCatalog(): CatalogHandle;
|
|
93
|
+
interface MarkdownProps {
|
|
94
|
+
readonly text: string;
|
|
95
|
+
/** Hits that `[n]` markers cite, in order. */
|
|
96
|
+
readonly citations?: readonly SearchHit[];
|
|
97
|
+
/** Resolves relative links, e.g. against a help page's URL. */
|
|
98
|
+
readonly baseUrl?: string;
|
|
99
|
+
}
|
|
100
|
+
/** Safe Markdown: raw HTML is not rendered, and same-origin links route through `onOpen`. */
|
|
101
|
+
export declare function Markdown({ text, citations, baseUrl }: MarkdownProps): import("react").JSX.Element;
|
|
102
|
+
/**
|
|
103
|
+
* ⌘K / Ctrl+K search over every source, grouped by type. Arrow keys move, Enter opens, and the
|
|
104
|
+
* last row hands the query to Aidy in the dock.
|
|
105
|
+
*/
|
|
106
|
+
export declare function SearchPalette(): import("react").JSX.Element | null;
|
|
107
|
+
/** The admin form for the model chain. Keys are write-only: it shows whether one is stored. */
|
|
108
|
+
export declare function ModelSettings(): import("react").JSX.Element;
|
|
109
|
+
interface AidyThreadProps {
|
|
110
|
+
/** The thread to show; null starts a new one with the first message. */
|
|
111
|
+
readonly threadId: string | null;
|
|
112
|
+
/** Called when the first message created a thread. */
|
|
113
|
+
readonly onThreadCreated?: (threadId: string) => void;
|
|
114
|
+
/** A message to send once, as soon as the thread mounts. */
|
|
115
|
+
readonly initialMessage?: string;
|
|
116
|
+
}
|
|
117
|
+
/** One conversation: messages, tool activity, open requests and the composer. */
|
|
118
|
+
export declare function AidyThread({ threadId, onThreadCreated, initialMessage }: AidyThreadProps): import("react").JSX.Element;
|
|
119
|
+
export type { AidyFormProps, AidyProviderProps, AidyThreadProps, ApprovalCardProps, CatalogHandle, DockHandle, HelpViewerProps, Locale, MarkdownProps, SearchHandle, Theme, ThreadHandle, ThreadsHandle };
|