@automattic/agenttic-client 0.1.0 → 0.1.2
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/auth/jetpack.d.ts +77 -0
- package/dist/auth/jetpack.d.ts.map +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types/index.d.ts +192 -0
- package/dist/client/types/index.d.ts.map +1 -0
- package/dist/client/utils/core.d.ts +82 -0
- package/dist/client/utils/core.d.ts.map +1 -0
- package/dist/client/utils/index.d.ts +8 -0
- package/dist/client/utils/index.d.ts.map +1 -0
- package/dist/client/utils/internal/errors.d.ts +43 -0
- package/dist/client/utils/internal/errors.d.ts.map +1 -0
- package/dist/client/utils/internal/messages.d.ts +27 -0
- package/dist/client/utils/internal/messages.d.ts.map +1 -0
- package/dist/client/utils/internal/requests.d.ts +54 -0
- package/dist/client/utils/internal/requests.d.ts.map +1 -0
- package/dist/client/utils/internal/streaming.d.ts +23 -0
- package/dist/client/utils/internal/streaming.d.ts.map +1 -0
- package/dist/client/utils/internal/tools.d.ts +16 -0
- package/dist/client/utils/internal/tools.d.ts.map +1 -0
- package/dist/client/utils/logger.d.ts +7 -0
- package/dist/client/utils/logger.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +146 -0
- package/dist/markdown-extensions/charts/BarChart.d.ts +16 -0
- package/dist/markdown-extensions/charts/BarChart.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/BaseChart.d.ts +36 -0
- package/dist/markdown-extensions/charts/BaseChart.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/ChartBlock.d.ts +34 -0
- package/dist/markdown-extensions/charts/ChartBlock.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/ChartError.d.ts +17 -0
- package/dist/markdown-extensions/charts/ChartError.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/ChartErrorBoundary.d.ts +30 -0
- package/dist/markdown-extensions/charts/ChartErrorBoundary.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/LineChart.d.ts +14 -0
- package/dist/markdown-extensions/charts/LineChart.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/index.d.ts +293 -0
- package/dist/markdown-extensions/charts/index.d.ts.map +1 -0
- package/dist/markdown-extensions/charts/utils/chartUtils.d.ts +56 -0
- package/dist/markdown-extensions/charts/utils/chartUtils.d.ts.map +1 -0
- package/dist/markdown-extensions/index.d.ts +34 -0
- package/dist/markdown-extensions/index.d.ts.map +1 -0
- package/dist/markdown-extensions/types.d.ts +52 -0
- package/dist/markdown-extensions/types.d.ts.map +1 -0
- package/dist/message-actions/factories.d.ts +16 -0
- package/dist/message-actions/index.d.ts +5 -0
- package/dist/message-actions/resolver.d.ts +9 -0
- package/dist/message-actions/useMessageActions.d.ts +9 -0
- package/dist/mocks/MockSalesGraph.d.ts +13 -0
- package/dist/mocks/MockSalesGraph.d.ts.map +1 -0
- package/dist/mocks/index.d.ts +12 -0
- package/dist/mocks/index.d.ts.map +1 -0
- package/dist/mocks/mockContext.d.ts +187 -0
- package/dist/mocks/mockContext.d.ts.map +1 -0
- package/dist/mocks/mockTools.d.ts +44 -0
- package/dist/mocks/mockTools.d.ts.map +1 -0
- package/dist/react/agentManager.d.ts +27 -0
- package/dist/react/conversationStorage.d.ts +29 -0
- package/dist/react/conversationStorage.d.ts.map +1 -0
- package/dist/react/conversationUtils.d.ts +32 -0
- package/dist/react/conversationUtils.d.ts.map +1 -0
- package/dist/react/useAgentChat.d.ts +97 -0
- package/dist/react/useClientContext.d.ts +17 -0
- package/dist/react/useClientContext.d.ts.map +1 -0
- package/dist/react/useClientTools.d.ts +23 -0
- package/dist/react/useClientTools.d.ts.map +1 -0
- package/dist/utils/createMessageRenderer.d.ts +25 -0
- package/dist/utils/createMessageRenderer.d.ts.map +1 -0
- package/dist/utils/markdownParser.d.ts +25 -0
- package/dist/utils/markdownParser.d.ts.map +1 -0
- package/dist/utils/theme.d.ts +8 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/package.json +81 -73
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jetpack Authentication Provider for Agenttic Client
|
|
3
|
+
*
|
|
4
|
+
* Provides authentication for WordPress sites using Jetpack connection.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { AuthProvider } from '../client/types/index';
|
|
10
|
+
export declare const JWT_TOKEN_ID = "jetpack-ai-jwt-token";
|
|
11
|
+
export declare const JWT_TOKEN_EXPIRATION_TIME: number;
|
|
12
|
+
declare global {
|
|
13
|
+
interface Window {
|
|
14
|
+
JP_CONNECTION_INITIAL_STATE?: {
|
|
15
|
+
apiNonce: string;
|
|
16
|
+
siteSuffix: string;
|
|
17
|
+
connectionStatus: {
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
Jetpack_Editor_Initial_State?: {
|
|
22
|
+
wpcomBlogId: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
interface TokenData {
|
|
27
|
+
token: string;
|
|
28
|
+
blogId: string;
|
|
29
|
+
expire: number;
|
|
30
|
+
}
|
|
31
|
+
export interface JetpackApiError {
|
|
32
|
+
code?: string;
|
|
33
|
+
status?: number;
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Error handler function type for Jetpack authentication errors
|
|
38
|
+
*/
|
|
39
|
+
export type JetpackErrorHandler = (error: JetpackApiError) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Request a JWT token from Jetpack for API authentication
|
|
42
|
+
* @param errorHandler - Function to handle and format error messages
|
|
43
|
+
* @param useCachedToken - Whether to use cached token if available and valid
|
|
44
|
+
* @return Token data with JWT token and blog ID, or null on failure
|
|
45
|
+
*/
|
|
46
|
+
export declare function requestJetpackToken(errorHandler: JetpackErrorHandler, useCachedToken?: boolean): Promise<TokenData | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Create a Jetpack authentication provider for use with Agenttic client.
|
|
49
|
+
*
|
|
50
|
+
* This factory function creates an authentication provider that handles
|
|
51
|
+
* authentication for WordPress sites with Jetpack, automatically managing
|
|
52
|
+
* token caching and refresh.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { createJetpackAuthProvider } from '@automattic/agenttic-client';
|
|
57
|
+
* import { useAgent } from '@automattic/agenttic-client';
|
|
58
|
+
*
|
|
59
|
+
* const errorHandler = (error) => {
|
|
60
|
+
* if (error.code === 'rest_forbidden') {
|
|
61
|
+
* return 'Permission denied';
|
|
62
|
+
* }
|
|
63
|
+
* return 'Authentication failed';
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* const { state, sendMessage } = useAgent({
|
|
67
|
+
* agentId: 'my-agent',
|
|
68
|
+
* authProvider: createJetpackAuthProvider(errorHandler),
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param errorHandler - Function to handle and format error messages
|
|
73
|
+
* @return Authentication provider function that returns headers with JWT token
|
|
74
|
+
*/
|
|
75
|
+
export declare const createJetpackAuthProvider: (errorHandler: JetpackErrorHandler) => AuthProvider;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=jetpack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jetpack.d.ts","sourceRoot":"","sources":["../../src/auth/jetpack.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,eAAO,MAAM,YAAY,yBAAyB,CAAC;AACnD,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAExD,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,2BAA2B,CAAC,EAAE;YAC7B,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,gBAAgB,EAAE;gBAAE,QAAQ,EAAE,OAAO,CAAA;aAAE,CAAC;SACxC,CAAC;QACF,4BAA4B,CAAC,EAAE;YAC9B,WAAW,EAAE,MAAM,CAAC;SACpB,CAAC;KACF;CACD;AAED,UAAU,SAAS;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAE,KAAK,EAAE,eAAe,KAAM,MAAM,CAAC;AAmBvE;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,YAAY,EAAE,mBAAmB,EACjC,cAAc,UAAO,GACnB,OAAO,CAAE,SAAS,GAAG,IAAI,CAAE,CA2E7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,yBAAyB,GACrC,cAAc,mBAAmB,KAC/B,YAkBF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAGZ,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAGZ,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;AAqsBvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,YAAY,CAAE,MAAM,EAAE,YAAY,GAAI,MAAM,CA+T3D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAE,UAAU,CAAE,CAavB"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export type JsonRpcId = string | number;
|
|
2
|
+
export interface JsonRpcRequest<TParams = unknown> {
|
|
3
|
+
jsonrpc: '2.0';
|
|
4
|
+
id: JsonRpcId;
|
|
5
|
+
method: string;
|
|
6
|
+
params?: TParams;
|
|
7
|
+
}
|
|
8
|
+
export interface JsonRpcResponse<TResult = unknown> {
|
|
9
|
+
jsonrpc: '2.0';
|
|
10
|
+
id: JsonRpcId | null;
|
|
11
|
+
result?: TResult;
|
|
12
|
+
error?: JsonRpcError;
|
|
13
|
+
}
|
|
14
|
+
export interface JsonRpcError {
|
|
15
|
+
code: number;
|
|
16
|
+
message: string;
|
|
17
|
+
data?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export type TaskState = 'submitted' | 'working' | 'running' | 'input-required' | 'completed' | 'canceled' | 'failed';
|
|
20
|
+
export interface TextPart {
|
|
21
|
+
type: 'text';
|
|
22
|
+
text: string;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface FilePart {
|
|
26
|
+
type: 'file';
|
|
27
|
+
file: {
|
|
28
|
+
name: string;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
bytes?: string;
|
|
31
|
+
uri?: string;
|
|
32
|
+
};
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
export interface DataPart {
|
|
36
|
+
type: 'data';
|
|
37
|
+
data: Record<string, unknown>;
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolDataPart extends DataPart {
|
|
41
|
+
data: {
|
|
42
|
+
toolId: string;
|
|
43
|
+
toolName: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object';
|
|
47
|
+
properties: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface ToolCallDataPart extends DataPart {
|
|
52
|
+
data: {
|
|
53
|
+
toolCallId: string;
|
|
54
|
+
toolId: string;
|
|
55
|
+
arguments: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface ToolResultDataPart extends DataPart {
|
|
59
|
+
data: {
|
|
60
|
+
toolCallId: string;
|
|
61
|
+
toolId: string;
|
|
62
|
+
result?: unknown;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface ContextDataPart extends DataPart {
|
|
66
|
+
data: {
|
|
67
|
+
clientContext: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface ConversationHistoryPart extends DataPart {
|
|
71
|
+
data: {
|
|
72
|
+
role: 'user' | 'model';
|
|
73
|
+
text: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export type Part = TextPart | FilePart | DataPart | ToolDataPart | ToolCallDataPart | ToolResultDataPart | ContextDataPart;
|
|
77
|
+
export interface Message {
|
|
78
|
+
role: 'user' | 'agent';
|
|
79
|
+
parts: Part[];
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
81
|
+
messageId: string;
|
|
82
|
+
kind: 'message';
|
|
83
|
+
}
|
|
84
|
+
export interface TaskStatus {
|
|
85
|
+
state: TaskState;
|
|
86
|
+
message?: Message;
|
|
87
|
+
timestamp?: string;
|
|
88
|
+
error?: JsonRpcError;
|
|
89
|
+
}
|
|
90
|
+
export interface Artifact {
|
|
91
|
+
name: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
index: number;
|
|
94
|
+
parts: Part[];
|
|
95
|
+
metadata?: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
export interface Task {
|
|
98
|
+
id: string;
|
|
99
|
+
sessionId?: string;
|
|
100
|
+
status: TaskStatus;
|
|
101
|
+
artifacts?: Artifact[];
|
|
102
|
+
}
|
|
103
|
+
export interface MessageSendParams {
|
|
104
|
+
id?: string;
|
|
105
|
+
sessionId?: string;
|
|
106
|
+
message: Message;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
export type SendMessageRequest = JsonRpcRequest<MessageSendParams>;
|
|
110
|
+
export type SendMessageResponse = JsonRpcResponse<Task>;
|
|
111
|
+
export interface TaskStatusUpdateEvent {
|
|
112
|
+
id: string;
|
|
113
|
+
status: TaskStatus;
|
|
114
|
+
final?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export interface TaskArtifactUpdateEvent {
|
|
117
|
+
id: string;
|
|
118
|
+
artifact: Artifact;
|
|
119
|
+
}
|
|
120
|
+
export declare enum A2AErrorCodes {
|
|
121
|
+
PARSE_ERROR = -32700,
|
|
122
|
+
INVALID_REQUEST = -32600,
|
|
123
|
+
METHOD_NOT_FOUND = -32601,
|
|
124
|
+
INVALID_PARAMS = -32602,
|
|
125
|
+
INTERNAL_ERROR = -32603,
|
|
126
|
+
SERVER_ERROR = -32000
|
|
127
|
+
}
|
|
128
|
+
export interface AuthProvider {
|
|
129
|
+
(): Promise<Record<string, string>>;
|
|
130
|
+
}
|
|
131
|
+
export interface ClientConfig {
|
|
132
|
+
agentId: string;
|
|
133
|
+
agentUrl: string;
|
|
134
|
+
authProvider?: AuthProvider;
|
|
135
|
+
defaultSessionId?: string;
|
|
136
|
+
timeout?: number;
|
|
137
|
+
toolProvider?: ToolProvider;
|
|
138
|
+
contextProvider?: ContextProvider;
|
|
139
|
+
conversationStorageKey?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface SendMessageParams {
|
|
142
|
+
message: Message;
|
|
143
|
+
taskId?: string;
|
|
144
|
+
sessionId?: string;
|
|
145
|
+
metadata?: Record<string, unknown>;
|
|
146
|
+
withHistory?: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface TaskUpdate {
|
|
149
|
+
id: string;
|
|
150
|
+
status: TaskStatus;
|
|
151
|
+
final?: boolean;
|
|
152
|
+
artifact?: Artifact;
|
|
153
|
+
text: string;
|
|
154
|
+
agentMessage?: Message;
|
|
155
|
+
}
|
|
156
|
+
export interface Client {
|
|
157
|
+
sendMessage(params: SendMessageParams): Promise<TaskUpdate>;
|
|
158
|
+
sendMessageStream(params: SendMessageParams): AsyncIterable<TaskUpdate>;
|
|
159
|
+
continueTask(taskId: string, userInput: string, sessionId?: string): Promise<TaskUpdate>;
|
|
160
|
+
getTask(taskId: string): Promise<Task>;
|
|
161
|
+
cancelTask(taskId: string): Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
export interface Tool {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
description: string;
|
|
167
|
+
input_schema: {
|
|
168
|
+
type: 'object';
|
|
169
|
+
properties: Record<string, unknown>;
|
|
170
|
+
required?: string[];
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface ToolExecutionResult {
|
|
174
|
+
result: any;
|
|
175
|
+
returnToAgent?: boolean;
|
|
176
|
+
agentMessage?: string;
|
|
177
|
+
}
|
|
178
|
+
export interface ToolProvider {
|
|
179
|
+
getAvailableTools(): Promise<Tool[]>;
|
|
180
|
+
executeTool(toolId: string, args: any, messageId?: string, toolCallId?: string): Promise<any | ToolExecutionResult>;
|
|
181
|
+
}
|
|
182
|
+
export interface ToolCallResult {
|
|
183
|
+
toolCallId: string;
|
|
184
|
+
toolId: string;
|
|
185
|
+
result: any;
|
|
186
|
+
error?: string;
|
|
187
|
+
}
|
|
188
|
+
export type ClientContext = Record<string, unknown>;
|
|
189
|
+
export interface ContextProvider {
|
|
190
|
+
getClientContext(): ClientContext;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/types/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM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message, MessageSendParams, SendMessageRequest, TextPart, Tool, ToolCallDataPart, ToolDataPart, ToolResultDataPart } from '../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a random 8-character alphanumeric string for IDs
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateRandomId(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique message ID
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateMessageId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a unique request ID for A2A requests
|
|
12
|
+
*/
|
|
13
|
+
export declare function createRequestId(): JsonRpcId;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a unique task ID for A2A tasks
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTaskId(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Create a simple text part for a message
|
|
20
|
+
* @param text
|
|
21
|
+
*/
|
|
22
|
+
export declare function createTextPart(text: string): TextPart;
|
|
23
|
+
/**
|
|
24
|
+
* Create a message/send request payload
|
|
25
|
+
* @param params
|
|
26
|
+
* @param method
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSendMessageRequest(params: MessageSendParams, method?: string): SendMessageRequest;
|
|
29
|
+
/**
|
|
30
|
+
* Extract text content from a message
|
|
31
|
+
* @param message
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractTextFromMessage(message: Message): string;
|
|
34
|
+
/**
|
|
35
|
+
* Create a ToolDataPart from a Tool
|
|
36
|
+
* @param tool
|
|
37
|
+
*/
|
|
38
|
+
export declare function createToolDataPart(tool: Tool): ToolDataPart;
|
|
39
|
+
/**
|
|
40
|
+
* Extract tool calls from a message
|
|
41
|
+
* @param message
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractToolCallsFromMessage(message: Message): ToolCallDataPart[];
|
|
44
|
+
/**
|
|
45
|
+
* Create a tool result data part
|
|
46
|
+
* @param toolCallId
|
|
47
|
+
* @param toolId
|
|
48
|
+
* @param result
|
|
49
|
+
* @param error
|
|
50
|
+
*/
|
|
51
|
+
export declare function createToolResultDataPart(toolCallId: string, toolId: string, result?: unknown, error?: string): ToolResultDataPart;
|
|
52
|
+
/**
|
|
53
|
+
* Create a context data part from client context
|
|
54
|
+
* @param clientContext
|
|
55
|
+
*/
|
|
56
|
+
export declare function createContextDataPart(clientContext: ClientContext): ContextDataPart;
|
|
57
|
+
/**
|
|
58
|
+
* Create a simple text message with user role
|
|
59
|
+
* @param text
|
|
60
|
+
*/
|
|
61
|
+
export declare function createTextMessage(text: string): Message;
|
|
62
|
+
/**
|
|
63
|
+
* Create a simple text message with agent role
|
|
64
|
+
* @param text
|
|
65
|
+
*/
|
|
66
|
+
export declare function createAgentTextMessage(text: string): Message;
|
|
67
|
+
/**
|
|
68
|
+
* Process tool execution result to extract result and returnToAgent flag
|
|
69
|
+
* @param executionResult
|
|
70
|
+
*/
|
|
71
|
+
export declare function processToolExecutionResult(executionResult: any): {
|
|
72
|
+
result: any;
|
|
73
|
+
returnToAgent: boolean;
|
|
74
|
+
agentMessage?: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Create a tool result message from tool result data parts
|
|
78
|
+
* @param toolResults
|
|
79
|
+
* @param historyDataParts
|
|
80
|
+
*/
|
|
81
|
+
export declare function createToolResultMessage(toolResults: ToolResultDataPart[], historyDataParts?: any[]): Message;
|
|
82
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/client/utils/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,C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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createRequestId, createTaskId, createTextPart, createSendMessageRequest, extractTextFromMessage, extractToolCallsFromMessage, createToolDataPart, createToolResultDataPart, createContextDataPart, createTextMessage, createAgentTextMessage, createToolResultMessage, processToolExecutionResult, generateMessageId, } from './core';
|
|
2
|
+
export { executeRequest, executeStreamingRequest, prepareRequest, type RequestConfig, type RequestOptions, } from './internal/requests';
|
|
3
|
+
export { parseStreamChunk, parseSSEStream, streamToTask, } from './internal/streaming';
|
|
4
|
+
export { enhanceMessage, enhanceMessageWithTools, enhanceMessageWithContext, } from './internal/messages';
|
|
5
|
+
export { getToolCallCount, hasToolCalls } from './internal/tools';
|
|
6
|
+
export { createTimeoutHandler, handleRequestError, validateHttpResponse, validateJsonRpcResponse, validateStreamingResponse, } from './internal/errors';
|
|
7
|
+
export { logger, isDebugEnabled, enableDebug, formatObject } from './logger';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,eAAe,EACf,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GACjB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,cAAc,EACd,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { JsonRpcResponse } from '../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Handle request errors with consistent logging and timeout cleanup
|
|
4
|
+
*
|
|
5
|
+
* @param error - The error that occurred
|
|
6
|
+
* @param timeoutId - Timeout ID to clear
|
|
7
|
+
* @param operation - Description of the operation
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleRequestError(error: unknown, timeoutId: number, operation?: string): never;
|
|
10
|
+
/**
|
|
11
|
+
* Validate HTTP response and throw if not ok
|
|
12
|
+
*
|
|
13
|
+
* @param response - The HTTP response
|
|
14
|
+
* @param operation - Description of the operation
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateHttpResponse(response: Response, operation?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Validate JSON-RPC response and return result
|
|
19
|
+
*
|
|
20
|
+
* @param data - The JSON-RPC response
|
|
21
|
+
* @param operation - Description of the operation
|
|
22
|
+
* @return The validated result
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateJsonRpcResponse<T>(data: JsonRpcResponse<T>, operation?: string): T;
|
|
25
|
+
/**
|
|
26
|
+
* Validate streaming response
|
|
27
|
+
*
|
|
28
|
+
* @param response - The HTTP response
|
|
29
|
+
* @param operation - Description of the operation
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateStreamingResponse(response: Response, operation?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create timeout handler with abort controller
|
|
34
|
+
*
|
|
35
|
+
* @param timeout - Timeout in milliseconds
|
|
36
|
+
* @param operation - Description of the operation
|
|
37
|
+
* @return Timeout handler object
|
|
38
|
+
*/
|
|
39
|
+
export declare function createTimeoutHandler(timeout: number, operation?: string): {
|
|
40
|
+
timeoutId: number;
|
|
41
|
+
controller: AbortController;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAkB,GAC3B,KAAK,CAUP;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,MAAkB,GAC3B,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAE,CAAC,EACzC,IAAI,EAAE,eAAe,CAAE,CAAC,CAAE,EAC1B,SAAS,GAAE,MAAkB,GAC3B,CAAC,CAUH;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,MAA4B,GACrC,IAAI,CAMN;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,GAC3B;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,eAAe,CAAA;CAAE,CAOpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ContextProvider, Message, ToolProvider } from '../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Enhance a message with available tools from the tool provider
|
|
4
|
+
*
|
|
5
|
+
* @param message - The message to enhance
|
|
6
|
+
* @param toolProvider - Optional tool provider to get tools from
|
|
7
|
+
* @return Promise resolving to the enhanced message
|
|
8
|
+
*/
|
|
9
|
+
export declare function enhanceMessageWithTools(message: Message, toolProvider?: ToolProvider): Promise<Message>;
|
|
10
|
+
/**
|
|
11
|
+
* Enhance a message with client context from the context provider
|
|
12
|
+
*
|
|
13
|
+
* @param message - The message to enhance
|
|
14
|
+
* @param contextProvider - Optional context provider to get context from
|
|
15
|
+
* @return The enhanced message
|
|
16
|
+
*/
|
|
17
|
+
export declare function enhanceMessageWithContext(message: Message, contextProvider?: ContextProvider): Message;
|
|
18
|
+
/**
|
|
19
|
+
* Enhance a message with both tools and context
|
|
20
|
+
*
|
|
21
|
+
* @param message - The message to enhance
|
|
22
|
+
* @param toolProvider - Optional tool provider to get tools from
|
|
23
|
+
* @param contextProvider - Optional context provider to get context from
|
|
24
|
+
* @return Promise resolving to the enhanced message
|
|
25
|
+
*/
|
|
26
|
+
export declare function enhanceMessage(message: Message, toolProvider?: ToolProvider, contextProvider?: ContextProvider): Promise<Message>;
|
|
27
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIhF;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,OAAO,EAChB,YAAY,CAAC,EAAE,YAAY,GACzB,OAAO,CAAE,OAAO,CAAE,CAoBpB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,OAAO,EAChB,eAAe,CAAC,EAAE,eAAe,GAC/B,OAAO,CAoBT;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,OAAO,EAChB,YAAY,CAAC,EAAE,YAAY,EAC3B,eAAe,CAAC,EAAE,eAAe,GAC/B,OAAO,CAAE,OAAO,CAAE,CAiBpB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AuthProvider, SendMessageParams, Task, TaskUpdate } from '../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for making requests
|
|
4
|
+
*/
|
|
5
|
+
export interface RequestConfig {
|
|
6
|
+
agentId: string;
|
|
7
|
+
agentUrl: string;
|
|
8
|
+
authProvider?: AuthProvider;
|
|
9
|
+
timeout: number;
|
|
10
|
+
proxy?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for request execution
|
|
14
|
+
*/
|
|
15
|
+
export interface RequestOptions {
|
|
16
|
+
isStreaming?: boolean;
|
|
17
|
+
streamingTimeout?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Prepare a request for execution
|
|
21
|
+
*
|
|
22
|
+
* @param params - Send message parameters
|
|
23
|
+
* @param config - Request configuration
|
|
24
|
+
* @param options - Request options
|
|
25
|
+
* @param toolProvider - Optional tool provider
|
|
26
|
+
* @param contextProvider - Optional context provider
|
|
27
|
+
* @param defaultSessionId - Default session ID
|
|
28
|
+
* @return Promise resolving to prepared request data
|
|
29
|
+
*/
|
|
30
|
+
export declare function prepareRequest(params: SendMessageParams, config: RequestConfig, options: RequestOptions, toolProvider?: any, contextProvider?: any, defaultSessionId?: string): Promise<{
|
|
31
|
+
request: import("../../..").SendMessageRequest;
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
enhancedMessage: import("../../..").Message;
|
|
34
|
+
effectiveSessionId: string | undefined;
|
|
35
|
+
fullAgentUrl: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Execute a non-streaming request
|
|
39
|
+
*
|
|
40
|
+
* @param preparedRequest - Prepared request data
|
|
41
|
+
* @param config - Request configuration
|
|
42
|
+
* @return Promise resolving to the response task
|
|
43
|
+
*/
|
|
44
|
+
export declare function executeRequest(preparedRequest: Awaited<ReturnType<typeof prepareRequest>>, config: RequestConfig): Promise<Task>;
|
|
45
|
+
/**
|
|
46
|
+
* Execute a streaming request
|
|
47
|
+
*
|
|
48
|
+
* @param preparedRequest - Prepared request data
|
|
49
|
+
* @param config - Request configuration
|
|
50
|
+
* @param options - Request options
|
|
51
|
+
* @return Async iterable of task updates
|
|
52
|
+
*/
|
|
53
|
+
export declare function executeStreamingRequest(preparedRequest: Awaited<ReturnType<typeof prepareRequest>>, config: RequestConfig, options: RequestOptions): AsyncIterable<TaskUpdate>;
|
|
54
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EAEZ,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACV,MAAM,mBAAmB,CAAC;AAa3B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAaD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAuED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CACnC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,GAAG,EAClB,eAAe,CAAC,EAAE,GAAG,EACrB,gBAAgB,CAAC,EAAE,MAAM;;;;;;GAwCzB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CACnC,eAAe,EAAE,OAAO,CAAE,UAAU,CAAE,OAAO,cAAc,CAAE,CAAE,EAC/D,MAAM,EAAE,aAAa,GACnB,OAAO,CAAE,IAAI,CAAE,CA2CjB;AAED;;;;;;;GAOG;AACH,wBAAuB,uBAAuB,CAC7C,eAAe,EAAE,OAAO,CAAE,UAAU,CAAE,OAAO,cAAc,CAAE,CAAE,EAC/D,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACrB,aAAa,CAAE,UAAU,CAAE,CA6B7B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Task, TaskUpdate } from '../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a stream chunk from a server-sent events stream.
|
|
4
|
+
* This function processes an incoming chunk of data, potentially combined with a buffer
|
|
5
|
+
* from previous chunks, and extracts complete SSE events.
|
|
6
|
+
* @param chunk
|
|
7
|
+
* @param buffer
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseStreamChunk(chunk: string, buffer?: string): {
|
|
10
|
+
events: Record<string, any>[];
|
|
11
|
+
nextBuffer: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Parse SSE stream and yield task updates
|
|
15
|
+
* @param stream
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseSSEStream(stream: ReadableStream<Uint8Array>): AsyncIterable<TaskUpdate>;
|
|
18
|
+
/**
|
|
19
|
+
* Convert a streaming response to a final task result
|
|
20
|
+
* @param stream
|
|
21
|
+
*/
|
|
22
|
+
export declare function streamToTask(stream: AsyncIterable<TaskUpdate>): Promise<Task>;
|
|
23
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAW,GACjB;IAAE,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAmEzD;AAED;;;GAGG;AACH,wBAAuB,cAAc,CACpC,MAAM,EAAE,cAAc,CAAE,UAAU,CAAE,GAClC,aAAa,CAAE,UAAU,CAAE,CAiD7B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CACjC,MAAM,EAAE,aAAa,CAAE,UAAU,CAAE,GACjC,OAAO,CAAE,IAAI,CAAE,CAiBjB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Message } from '../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a message contains tool calls
|
|
4
|
+
*
|
|
5
|
+
* @param message - The message to check
|
|
6
|
+
* @return True if the message contains tool calls, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasToolCalls(message: Message): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Get the number of tool calls in a message
|
|
11
|
+
*
|
|
12
|
+
* @param message - The message to analyze
|
|
13
|
+
* @return The number of tool calls found
|
|
14
|
+
*/
|
|
15
|
+
export declare function getToolCallCount(message: Message): number;
|
|
16
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAE,OAAO,EAAE,OAAO,GAAI,OAAO,CAOxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,OAAO,GAAI,MAAM,CAO3D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const logger: (message: string, ...args: any[]) => void;
|
|
2
|
+
export declare function isDebugEnabled(): boolean;
|
|
3
|
+
export declare function enableDebug(): void;
|
|
4
|
+
export declare function formatObject(obj: any): string;
|
|
5
|
+
export declare function log(message: string, ...args: any[]): void;
|
|
6
|
+
export { logger };
|
|
7
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/client/utils/logger.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,GAAK,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,EAAE,SAK/C,CAAC;AAGF,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAGD,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAGD,wBAAgB,YAAY,CAAE,GAAG,EAAE,GAAG,GAAI,MAAM,CAE/C;AAGD,wBAAgB,GAAG,CAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,IAAI,CAG3D;AAGD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agenttic-client
|
|
3
|
+
*
|
|
4
|
+
* A TypeScript client library for communication with WPcom Agent API
|
|
5
|
+
*/
|
|
6
|
+
export { useClientContext } from './react/useClientContext';
|
|
7
|
+
export { useClientTools } from './react/useClientTools';
|
|
8
|
+
export { useAgentChat } from './react/useAgentChat';
|
|
9
|
+
export { createRequestId, createTaskId, createTextMessage, extractToolCallsFromMessage, extractTextFromMessage, } from './client/utils/core';
|
|
10
|
+
export { createMessageRenderer } from './utils/createMessageRenderer';
|
|
11
|
+
export type { JsonRpcId, JsonRpcRequest, JsonRpcResponse, JsonRpcError, TaskState, TextPart, FilePart, DataPart, ToolDataPart, ToolCallDataPart, ContextDataPart, Part, Message, TaskStatus, Artifact, Task, MessageSendParams, SendMessageRequest, SendMessageResponse, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Client, AuthProvider, ClientConfig, SendMessageParams, TaskUpdate, Tool, ToolProvider, ToolCallResult, ClientContext, ContextProvider, } from './client/types/index';
|
|
12
|
+
export type { UseAgentChatConfig, UseAgentChatReturn, UIMessage, Suggestion, MarkdownComponents, } from './react/useAgentChat';
|
|
13
|
+
export { A2AErrorCodes } from './client/types/index';
|
|
14
|
+
export { createClient } from './client/index';
|
|
15
|
+
export { getAgentManager } from './react/agentManager';
|
|
16
|
+
export type { AgentManager, AgentManagerConfig } from './react/agentManager';
|
|
17
|
+
export { BarChart, LineChart, ChartBlock } from './markdown-extensions/charts';
|
|
18
|
+
export type { MarkdownExtensions, ChartExtensionConfig, ChartData, ChartSeries, } from './markdown-extensions/types';
|
|
19
|
+
export { createFeedbackActions, useMessageActions } from './message-actions';
|
|
20
|
+
export type { FeedbackActionsManager } from './message-actions';
|
|
21
|
+
export { createJetpackAuthProvider, type JetpackErrorHandler, type JetpackApiError, } from './auth/jetpack';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EACN,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,YAAY,EAEX,SAAS,EACT,cAAc,EACd,eAAe,EACf,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,u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