@docyrus/ui-pro-ai-assistant 0.5.8 → 0.6.1
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/dist/docy-assistant.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +115 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/client-tools.d.ts +39 -0
- package/dist/styles.css +17 -0
- package/dist/types/index.d.ts +42 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ClientTool, type ClientToolExecuteContext } from '../types';
|
|
3
|
+
export type ClientToolMap = Map<string, ClientTool>;
|
|
4
|
+
export declare function ClientToolsProvider({ tools, children }: {
|
|
5
|
+
tools: ClientToolMap;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
/** Returns the full registered client-tool map. */
|
|
9
|
+
export declare function useClientToolMap(): ClientToolMap;
|
|
10
|
+
/** Builds a name → tool lookup, ignoring duplicates (first wins). */
|
|
11
|
+
export declare function buildClientToolMap(tools?: ClientTool[]): ClientToolMap;
|
|
12
|
+
/** Serializable tool definitions sent to the chat endpoint as `clientTools`. */
|
|
13
|
+
export declare function serializeClientTools(tools?: ClientTool[]): {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: Record<string, unknown>;
|
|
17
|
+
}[];
|
|
18
|
+
export type ClientToolResult = {
|
|
19
|
+
success: true;
|
|
20
|
+
result: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
success: false;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
/** Executes a client tool, normalizing the outcome into a result envelope. */
|
|
26
|
+
export declare function runClientTool(tool: ClientTool, input: unknown, context: ClientToolExecuteContext): Promise<ClientToolResult>;
|
|
27
|
+
interface ClientToolCallProps {
|
|
28
|
+
tool: ClientTool;
|
|
29
|
+
part: {
|
|
30
|
+
state?: string;
|
|
31
|
+
input?: any;
|
|
32
|
+
output?: any;
|
|
33
|
+
errorText?: string;
|
|
34
|
+
toolCallId: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Compact card rendered for a client-tool call, driven by host-provided copy. */
|
|
38
|
+
export declare function ClientToolCall({ tool, part }: ClientToolCallProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
package/dist/styles.css
CHANGED
|
@@ -2471,6 +2471,12 @@
|
|
|
2471
2471
|
border-color: color-mix(in oklab, var(--destructive) 20%, transparent);
|
|
2472
2472
|
}
|
|
2473
2473
|
}
|
|
2474
|
+
.border-destructive\/40 {
|
|
2475
|
+
border-color: var(--destructive);
|
|
2476
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2477
|
+
border-color: color-mix(in oklab, var(--destructive) 40%, transparent);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2474
2480
|
.border-destructive\/50 {
|
|
2475
2481
|
border-color: var(--destructive);
|
|
2476
2482
|
@supports (color: color-mix(in lab, red, red)) {
|
|
@@ -2690,6 +2696,12 @@
|
|
|
2690
2696
|
.bg-destructive {
|
|
2691
2697
|
background-color: var(--destructive);
|
|
2692
2698
|
}
|
|
2699
|
+
.bg-destructive\/5 {
|
|
2700
|
+
background-color: var(--destructive);
|
|
2701
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2702
|
+
background-color: color-mix(in oklab, var(--destructive) 5%, transparent);
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2693
2705
|
.bg-destructive\/10 {
|
|
2694
2706
|
background-color: var(--destructive);
|
|
2695
2707
|
@supports (color: color-mix(in lab, red, red)) {
|
|
@@ -10122,6 +10134,11 @@
|
|
|
10122
10134
|
color: var(--color-blue-400);
|
|
10123
10135
|
}
|
|
10124
10136
|
}
|
|
10137
|
+
.dark\:text-emerald-500 {
|
|
10138
|
+
@media (prefers-color-scheme: dark) {
|
|
10139
|
+
color: var(--color-emerald-500);
|
|
10140
|
+
}
|
|
10141
|
+
}
|
|
10125
10142
|
.dark\:text-gray-400 {
|
|
10126
10143
|
@media (prefers-color-scheme: dark) {
|
|
10127
10144
|
color: var(--color-gray-400);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
export interface ToolActionEvent {
|
|
2
3
|
tool: string;
|
|
3
4
|
toolCallId: string;
|
|
4
5
|
decision: string;
|
|
5
6
|
input: any;
|
|
6
7
|
}
|
|
8
|
+
export interface ClientToolExecuteContext {
|
|
9
|
+
/** The id of the tool call being fulfilled. */
|
|
10
|
+
toolCallId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A host-provided tool the agent can call and have executed client-side.
|
|
14
|
+
*
|
|
15
|
+
* The serializable parts (`name`, `description`, `parameters`) are forwarded
|
|
16
|
+
* to the chat endpoint as `clientTools` so the backend can expose them to the
|
|
17
|
+
* agent. When the agent calls one, `execute` runs in the browser and its
|
|
18
|
+
* resolved value is sent back to the agent as the tool result.
|
|
19
|
+
*/
|
|
20
|
+
export interface ClientTool<TInput = any, TOutput = any> {
|
|
21
|
+
/** Unique tool name. Must match the name the agent uses to call it. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Natural-language description the agent uses to decide when to call it. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema (draft-07) describing the tool input. Forwarded to the backend. */
|
|
26
|
+
parameters?: Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Runs client-side when the agent calls this tool. The resolved value is
|
|
29
|
+
* serialized and sent back to the agent as the tool result. Throwing (or
|
|
30
|
+
* rejecting) reports the error back to the agent.
|
|
31
|
+
*/
|
|
32
|
+
execute: (input: TInput, context: ClientToolExecuteContext) => TOutput | Promise<TOutput>;
|
|
33
|
+
/** Icon rendered in the tool-call card. */
|
|
34
|
+
icon?: ReactNode;
|
|
35
|
+
/** Message shown while the tool is executing. */
|
|
36
|
+
progressMessage?: string;
|
|
37
|
+
/** Message shown when the tool resolves successfully. */
|
|
38
|
+
successMessage?: string;
|
|
39
|
+
/** Message shown when the tool throws or rejects. */
|
|
40
|
+
failMessage?: string;
|
|
41
|
+
}
|
|
7
42
|
export interface ApiResponse<T = unknown> {
|
|
8
43
|
success: boolean;
|
|
9
44
|
data?: T;
|
|
@@ -315,4 +350,11 @@ export interface DocyAssistantProps {
|
|
|
315
350
|
* Common values: 'web' | 'desktop' | 'chrome' | 'word' | 'excel' | 'powerpoint' | 'outlook'.
|
|
316
351
|
*/
|
|
317
352
|
hostEnvironment?: string;
|
|
353
|
+
/**
|
|
354
|
+
* Host-provided tools the agent can call and have executed client-side.
|
|
355
|
+
* Their definitions are forwarded to the chat endpoint as `clientTools`;
|
|
356
|
+
* when the agent calls one, its `execute` runs in the browser and the
|
|
357
|
+
* result is sent back to the agent automatically.
|
|
358
|
+
*/
|
|
359
|
+
clientTools?: ClientTool[];
|
|
318
360
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docyrus/ui-pro-ai-assistant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Docyrus AI Assistant component — full-featured chat UI with canvas, projects, and i18n support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/react": "^3.0.161",
|
|
33
|
-
"@tanstack/react-form": "^1.28.4",
|
|
34
33
|
"@ariakit/react": "0.4.21",
|
|
35
34
|
"@codesandbox/sandpack-react": "2.20.0",
|
|
36
35
|
"@emoji-mart/data": "1.2.1",
|
|
@@ -67,6 +66,7 @@
|
|
|
67
66
|
"@platejs/table": "52.0.11",
|
|
68
67
|
"@platejs/toc": "52.0.11",
|
|
69
68
|
"@platejs/toggle": "52.0.11",
|
|
69
|
+
"@tanstack/react-form": "^1.28.4",
|
|
70
70
|
"@univerjs/core": "0.16.1",
|
|
71
71
|
"@univerjs/design": "0.16.1",
|
|
72
72
|
"@univerjs/docs": "0.16.1",
|