@pear-protocol/agent-sdk 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 +21 -0
- package/README.md +101 -0
- package/dist/client-EVhAAxSx.d.cts +348 -0
- package/dist/client-EVhAAxSx.d.ts +348 -0
- package/dist/index.cjs +456 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +264 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +76 -0
- package/dist/react/index.d.ts +76 -0
- package/dist/react/index.js +261 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pear Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @pear-protocol/agent-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript client for the Pear **agent chat** API — the conversational assistant
|
|
4
|
+
(pair-trade ideas, market data, and confirm-before-write trade execution).
|
|
5
|
+
|
|
6
|
+
- **`@pear-protocol/agent-sdk`** — framework-agnostic core (`AgentChatClient`).
|
|
7
|
+
- **`@pear-protocol/agent-sdk/react`** — optional React hooks (`useAgentChat`, `useAgentSessions`).
|
|
8
|
+
|
|
9
|
+
Published to **public npm** (same registry as the org's other `@pear-protocol`
|
|
10
|
+
packages — no `.npmrc` or token needed). The wire types are a single source of
|
|
11
|
+
truth shared with the backend, so they can't silently drift.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @pear-protocol/agent-sdk zod
|
|
17
|
+
# only if you use the React hooks:
|
|
18
|
+
pnpm add react
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`zod@^4.1.0` is a **required peer dependency** (the SDK ships zod schemas at
|
|
22
|
+
runtime). `react@>=18` is required **only** for the `/react` hooks.
|
|
23
|
+
|
|
24
|
+
## Quickstart (core)
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { AgentChatClient } from "@pear-protocol/agent-sdk";
|
|
28
|
+
|
|
29
|
+
const client = new AgentChatClient({
|
|
30
|
+
// Inject your env — the SDK NEVER reads it.
|
|
31
|
+
baseUrl: import.meta.env.VITE_AGENT_PEAR_API_URL, // Vite
|
|
32
|
+
// baseUrl: process.env.NEXT_PUBLIC_AGENT_PEAR_API_URL, // Next.js
|
|
33
|
+
getToken: () => auth.accessToken, // returns the freshest JWT; called per request
|
|
34
|
+
tokenVersion: "v2", // "v2" wallet JWT (default) | "v3"
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const { id } = await client.createSession();
|
|
38
|
+
|
|
39
|
+
for await (const ev of client.streamChat({ sessionId: id, message: "Long ETH short BTC?" })) {
|
|
40
|
+
if (ev.type === "token") process.stdout.write(ev.delta);
|
|
41
|
+
if (ev.type === "done" && ev.result.pendingAction) {
|
|
42
|
+
// A money-moving trade was STAGED, not executed — render Confirm/Cancel.
|
|
43
|
+
await client.confirmTicket(ev.result.pendingAction.ticketId);
|
|
44
|
+
// ...or: await client.cancelTicket(ev.result.pendingAction.ticketId);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`streamChat` yields `token` | `thinking` | `status` | `sources` events, then a
|
|
50
|
+
synthetic `{ type: "done", result }`. **Token text is delta-only** — accumulate
|
|
51
|
+
`ev.delta`. The SSE wire has no terminal `done` frame; the SDK assembles one. If
|
|
52
|
+
the backend emits a mid-stream error, `streamChat` **throws** an `AgentChatError`.
|
|
53
|
+
Aborting the stream (the hook's `stop()`, or your own `AbortSignal`) also stops
|
|
54
|
+
generation **server-side** — the backend detects the disconnect and winds the
|
|
55
|
+
worker job down at the next safe boundary (never mid-trade-write).
|
|
56
|
+
|
|
57
|
+
There's also a sync `client.sendMessage({ sessionId, message })` returning a
|
|
58
|
+
`ChatResult`, and sessions/history methods (`listSessions`,
|
|
59
|
+
`listSessionSummaries`, `createSession`, `getSession`, `deleteSession`,
|
|
60
|
+
`getMessages`).
|
|
61
|
+
|
|
62
|
+
## React
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { useAgentChat } from "@pear-protocol/agent-sdk/react";
|
|
66
|
+
|
|
67
|
+
function Chat({ client }) {
|
|
68
|
+
const {
|
|
69
|
+
messages, sendMessage, isStreaming, status, stop,
|
|
70
|
+
pendingAction, confirmTicket, cancelTicket, mode, setMode,
|
|
71
|
+
} = useAgentChat({ client });
|
|
72
|
+
|
|
73
|
+
// render `messages`; if `pendingAction`, show Confirm/Cancel buttons wired to
|
|
74
|
+
// confirmTicket(pendingAction.ticketId) / cancelTicket(pendingAction.ticketId)
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`useAgentChat` uses plain React state (no forced data lib). `useAgentSessions(client)`
|
|
79
|
+
is a minimal session-list hook; apps using TanStack Query can skip it and call the
|
|
80
|
+
client directly.
|
|
81
|
+
|
|
82
|
+
## Auth
|
|
83
|
+
|
|
84
|
+
`getToken()` returns whatever bearer token the agent API accepts (today a v2
|
|
85
|
+
HL-issued JWT). The SDK sends `Authorization: Bearer <token>` +
|
|
86
|
+
`X-Auth-Token-Version`. **It does NOT own sign-in** — wire it to your wallet/auth
|
|
87
|
+
flow. v3 callers are identity-only (no wallet → trade tickets disabled).
|
|
88
|
+
|
|
89
|
+
## Errors
|
|
90
|
+
|
|
91
|
+
`confirmTicket` / `cancelTicket` throw typed errors: `TicketExpiredError` (410),
|
|
92
|
+
`ForbiddenError` (403, not your ticket), `ConflictError` (409, already handled),
|
|
93
|
+
`AuthError` (401). All extend `AgentChatError` (carries `.status`).
|
|
94
|
+
|
|
95
|
+
## Trade tickets (confirm-before-write)
|
|
96
|
+
|
|
97
|
+
A turn that would move money returns a `pendingAction`
|
|
98
|
+
(`{ ticketId, action, consequence, options: ["confirm","cancel"] }`) instead of
|
|
99
|
+
executing. Render it, then call `confirmTicket(ticketId)` (executes) or
|
|
100
|
+
`cancelTicket(ticketId)` (discards). `setTradeConfirmations(false)` opts a user out
|
|
101
|
+
of the confirm step entirely.
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface AgentChatClientConfig {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
getToken: () => string | Promise<string>;
|
|
6
|
+
tokenVersion?: "v2" | "v3";
|
|
7
|
+
fetch?: typeof fetch;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const TokenEventSchema: z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"token">;
|
|
12
|
+
text: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
declare const ThinkingEventSchema: z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"thinking">;
|
|
16
|
+
text: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const StatusEventSchema: z.ZodObject<{
|
|
19
|
+
type: z.ZodLiteral<"status">;
|
|
20
|
+
text: z.ZodString;
|
|
21
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
start: "start";
|
|
23
|
+
end: "end";
|
|
24
|
+
}>>;
|
|
25
|
+
node: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
declare const SourcesEventSchema: z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"sources">;
|
|
29
|
+
researchAnnotations: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
|
|
30
|
+
url: string;
|
|
31
|
+
}, string>>, z.ZodObject<{
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
start_index: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
end_index: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
title: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>]>>>>;
|
|
37
|
+
twitterSources: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
38
|
+
author: z.ZodString;
|
|
39
|
+
tweetUrl: z.ZodString;
|
|
40
|
+
publishedAt: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>>>;
|
|
42
|
+
tradeLinks: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
43
|
+
link: z.ZodString;
|
|
44
|
+
platform: z.ZodString;
|
|
45
|
+
label: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>>>;
|
|
47
|
+
images: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodString>>>;
|
|
48
|
+
suggestedAction: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
49
|
+
question: z.ZodString;
|
|
50
|
+
options: z.ZodArray<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>>>;
|
|
52
|
+
pendingAction: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
53
|
+
ticketId: z.ZodString;
|
|
54
|
+
action: z.ZodString;
|
|
55
|
+
consequence: z.ZodString;
|
|
56
|
+
options: z.ZodArray<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
declare const ErrorEventSchema: z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"error">;
|
|
61
|
+
message: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
declare const AgentWireEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<"token">;
|
|
65
|
+
text: z.ZodString;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"thinking">;
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
type: z.ZodLiteral<"status">;
|
|
71
|
+
text: z.ZodString;
|
|
72
|
+
phase: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
start: "start";
|
|
74
|
+
end: "end";
|
|
75
|
+
}>>;
|
|
76
|
+
node: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
78
|
+
type: z.ZodLiteral<"sources">;
|
|
79
|
+
researchAnnotations: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
|
|
80
|
+
url: string;
|
|
81
|
+
}, string>>, z.ZodObject<{
|
|
82
|
+
url: z.ZodString;
|
|
83
|
+
start_index: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
end_index: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
title: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>]>>>>;
|
|
87
|
+
twitterSources: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
88
|
+
author: z.ZodString;
|
|
89
|
+
tweetUrl: z.ZodString;
|
|
90
|
+
publishedAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>>>;
|
|
92
|
+
tradeLinks: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
93
|
+
link: z.ZodString;
|
|
94
|
+
platform: z.ZodString;
|
|
95
|
+
label: z.ZodString;
|
|
96
|
+
}, z.core.$strip>>>>;
|
|
97
|
+
images: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodString>>>;
|
|
98
|
+
suggestedAction: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
99
|
+
question: z.ZodString;
|
|
100
|
+
options: z.ZodArray<z.ZodString>;
|
|
101
|
+
}, z.core.$strip>>>>;
|
|
102
|
+
pendingAction: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
103
|
+
ticketId: z.ZodString;
|
|
104
|
+
action: z.ZodString;
|
|
105
|
+
consequence: z.ZodString;
|
|
106
|
+
options: z.ZodArray<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>>;
|
|
108
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<"error">;
|
|
110
|
+
message: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>], "type">;
|
|
112
|
+
type AgentWireEvent = z.infer<typeof AgentWireEventSchema>;
|
|
113
|
+
declare const ChatResultSchema: z.ZodObject<{
|
|
114
|
+
finalText: z.ZodString;
|
|
115
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
researchAnnotations: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
|
|
117
|
+
url: string;
|
|
118
|
+
}, string>>, z.ZodObject<{
|
|
119
|
+
url: z.ZodString;
|
|
120
|
+
start_index: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
end_index: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
title: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strip>]>>>>;
|
|
124
|
+
twitterSources: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
125
|
+
author: z.ZodString;
|
|
126
|
+
tweetUrl: z.ZodString;
|
|
127
|
+
publishedAt: z.ZodString;
|
|
128
|
+
}, z.core.$strip>>>>;
|
|
129
|
+
tradeLinks: z.ZodOptional<z.ZodCatch<z.ZodArray<z.ZodObject<{
|
|
130
|
+
link: z.ZodString;
|
|
131
|
+
platform: z.ZodString;
|
|
132
|
+
label: z.ZodString;
|
|
133
|
+
}, z.core.$strip>>>>;
|
|
134
|
+
images: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
135
|
+
suggestedAction: z.ZodCatch<z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
136
|
+
question: z.ZodString;
|
|
137
|
+
options: z.ZodArray<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>>>>;
|
|
139
|
+
pendingAction: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
140
|
+
ticketId: z.ZodString;
|
|
141
|
+
action: z.ZodString;
|
|
142
|
+
consequence: z.ZodString;
|
|
143
|
+
options: z.ZodArray<z.ZodString>;
|
|
144
|
+
}, z.core.$strip>>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
type ChatResult = z.infer<typeof ChatResultSchema>;
|
|
147
|
+
type AgentEvent = AgentWireEvent | {
|
|
148
|
+
type: "done";
|
|
149
|
+
result: ChatResult;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
declare const SessionListItemSchema: z.ZodObject<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
appType: z.ZodString;
|
|
155
|
+
createdAt: z.ZodString;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
type SessionListItem = z.infer<typeof SessionListItemSchema>;
|
|
158
|
+
declare const SessionSummarySchema: z.ZodObject<{
|
|
159
|
+
id: z.ZodString;
|
|
160
|
+
appType: z.ZodString;
|
|
161
|
+
createdAt: z.ZodString;
|
|
162
|
+
firstUserMessage: z.ZodOptional<z.ZodString>;
|
|
163
|
+
lastUserMessage: z.ZodOptional<z.ZodString>;
|
|
164
|
+
lastUserMessageAt: z.ZodOptional<z.ZodString>;
|
|
165
|
+
lastAssistantMessageAt: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
type SessionSummary = z.infer<typeof SessionSummarySchema>;
|
|
168
|
+
declare const SessionSchema: z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
userId: z.ZodString;
|
|
171
|
+
appType: z.ZodString;
|
|
172
|
+
createdAt: z.ZodString;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
type Session = z.infer<typeof SessionSchema>;
|
|
175
|
+
declare const AgentChatMessageSchema: z.ZodObject<{
|
|
176
|
+
id: z.ZodString;
|
|
177
|
+
role: z.ZodString;
|
|
178
|
+
content: z.ZodString;
|
|
179
|
+
createdAt: z.ZodString;
|
|
180
|
+
researchAnnotations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
|
|
181
|
+
url: string;
|
|
182
|
+
}, string>>, z.ZodObject<{
|
|
183
|
+
url: z.ZodString;
|
|
184
|
+
start_index: z.ZodOptional<z.ZodNumber>;
|
|
185
|
+
end_index: z.ZodOptional<z.ZodNumber>;
|
|
186
|
+
title: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>]>>>>;
|
|
188
|
+
twitterSources: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
189
|
+
author: z.ZodString;
|
|
190
|
+
tweetUrl: z.ZodString;
|
|
191
|
+
publishedAt: z.ZodString;
|
|
192
|
+
}, z.core.$strip>>>>;
|
|
193
|
+
tradeLinks: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
194
|
+
link: z.ZodString;
|
|
195
|
+
platform: z.ZodString;
|
|
196
|
+
label: z.ZodString;
|
|
197
|
+
}, z.core.$strip>>>>;
|
|
198
|
+
images: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
199
|
+
suggestedAction: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
200
|
+
question: z.ZodString;
|
|
201
|
+
options: z.ZodArray<z.ZodString>;
|
|
202
|
+
}, z.core.$strip>>>;
|
|
203
|
+
}, z.core.$loose>;
|
|
204
|
+
type AgentChatMessage = z.infer<typeof AgentChatMessageSchema>;
|
|
205
|
+
|
|
206
|
+
declare const TradeLinkSchema: z.ZodObject<{
|
|
207
|
+
link: z.ZodString;
|
|
208
|
+
platform: z.ZodString;
|
|
209
|
+
label: z.ZodString;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
type TradeLink = z.infer<typeof TradeLinkSchema>;
|
|
212
|
+
declare const TwitterSourceSchema: z.ZodObject<{
|
|
213
|
+
author: z.ZodString;
|
|
214
|
+
tweetUrl: z.ZodString;
|
|
215
|
+
publishedAt: z.ZodString;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
type TwitterSource = z.infer<typeof TwitterSourceSchema>;
|
|
218
|
+
declare const CitationSourceSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<{
|
|
219
|
+
url: string;
|
|
220
|
+
}, string>>, z.ZodObject<{
|
|
221
|
+
url: z.ZodString;
|
|
222
|
+
start_index: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
end_index: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
title: z.ZodOptional<z.ZodString>;
|
|
225
|
+
}, z.core.$strip>]>;
|
|
226
|
+
type CitationSource = z.infer<typeof CitationSourceSchema>;
|
|
227
|
+
declare const SuggestedActionSchema: z.ZodObject<{
|
|
228
|
+
question: z.ZodString;
|
|
229
|
+
options: z.ZodArray<z.ZodString>;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
type SuggestedAction = z.infer<typeof SuggestedActionSchema>;
|
|
232
|
+
declare const ChatModeSchema: z.ZodEnum<{
|
|
233
|
+
standard: "standard";
|
|
234
|
+
advanced: "advanced";
|
|
235
|
+
}>;
|
|
236
|
+
type ChatMode = z.infer<typeof ChatModeSchema>;
|
|
237
|
+
|
|
238
|
+
declare const TicketActionSchema: z.ZodEnum<{
|
|
239
|
+
open_position: "open_position";
|
|
240
|
+
close_position: "close_position";
|
|
241
|
+
close_all_positions: "close_all_positions";
|
|
242
|
+
adjust_position: "adjust_position";
|
|
243
|
+
adjust_advance_position: "adjust_advance_position";
|
|
244
|
+
reverse_position: "reverse_position";
|
|
245
|
+
rebalance_position: "rebalance_position";
|
|
246
|
+
set_risk_parameters: "set_risk_parameters";
|
|
247
|
+
}>;
|
|
248
|
+
type TicketAction = z.infer<typeof TicketActionSchema>;
|
|
249
|
+
declare const TicketStatusSchema: z.ZodEnum<{
|
|
250
|
+
PENDING: "PENDING";
|
|
251
|
+
EXECUTING: "EXECUTING";
|
|
252
|
+
EXECUTED: "EXECUTED";
|
|
253
|
+
CANCELLED: "CANCELLED";
|
|
254
|
+
FAILED: "FAILED";
|
|
255
|
+
}>;
|
|
256
|
+
type TicketStatus = z.infer<typeof TicketStatusSchema>;
|
|
257
|
+
declare const PendingActionSchema: z.ZodObject<{
|
|
258
|
+
ticketId: z.ZodString;
|
|
259
|
+
action: z.ZodString;
|
|
260
|
+
consequence: z.ZodString;
|
|
261
|
+
options: z.ZodArray<z.ZodString>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
type PendingAction = z.infer<typeof PendingActionSchema>;
|
|
264
|
+
declare const ConfirmResultSchema: z.ZodObject<{
|
|
265
|
+
ok: z.ZodBoolean;
|
|
266
|
+
status: z.ZodEnum<{
|
|
267
|
+
EXECUTED: "EXECUTED";
|
|
268
|
+
FAILED: "FAILED";
|
|
269
|
+
}>;
|
|
270
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
271
|
+
positionsSnapshot: z.ZodOptional<z.ZodUnknown>;
|
|
272
|
+
images: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
273
|
+
}, z.core.$loose>;
|
|
274
|
+
type ConfirmResult = z.infer<typeof ConfirmResultSchema>;
|
|
275
|
+
declare const CancelResultSchema: z.ZodObject<{
|
|
276
|
+
ok: z.ZodLiteral<true>;
|
|
277
|
+
status: z.ZodLiteral<"CANCELLED">;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
type CancelResult = z.infer<typeof CancelResultSchema>;
|
|
280
|
+
declare const SetConfirmationsResultSchema: z.ZodObject<{
|
|
281
|
+
ok: z.ZodBoolean;
|
|
282
|
+
enabled: z.ZodBoolean;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
type SetConfirmationsResult = z.infer<typeof SetConfirmationsResultSchema>;
|
|
285
|
+
declare const TradeSettingsSchema: z.ZodObject<{
|
|
286
|
+
executionEnabled: z.ZodBoolean;
|
|
287
|
+
confirmationsEnabled: z.ZodBoolean;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
type TradeSettings = z.infer<typeof TradeSettingsSchema>;
|
|
290
|
+
declare const SetExecutionResultSchema: z.ZodObject<{
|
|
291
|
+
ok: z.ZodBoolean;
|
|
292
|
+
enabled: z.ZodBoolean;
|
|
293
|
+
}, z.core.$strip>;
|
|
294
|
+
type SetExecutionResult = z.infer<typeof SetExecutionResultSchema>;
|
|
295
|
+
|
|
296
|
+
type StreamEvent = (Extract<AgentWireEvent, {
|
|
297
|
+
type: "token";
|
|
298
|
+
}> & {
|
|
299
|
+
delta: string;
|
|
300
|
+
}) | (Extract<AgentWireEvent, {
|
|
301
|
+
type: "thinking";
|
|
302
|
+
}> & {
|
|
303
|
+
delta: string;
|
|
304
|
+
}) | Exclude<AgentWireEvent, {
|
|
305
|
+
type: "token" | "thinking";
|
|
306
|
+
}>;
|
|
307
|
+
|
|
308
|
+
declare class AgentChatClient {
|
|
309
|
+
private readonly http;
|
|
310
|
+
constructor(config: AgentChatClientConfig);
|
|
311
|
+
listSessions(): Promise<SessionListItem[]>;
|
|
312
|
+
listSessionSummaries(): Promise<SessionSummary[]>;
|
|
313
|
+
createSession(): Promise<{
|
|
314
|
+
id: string;
|
|
315
|
+
}>;
|
|
316
|
+
getSession(sessionId: string): Promise<Session>;
|
|
317
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
318
|
+
getMessages(sessionId: string, opts?: {
|
|
319
|
+
limit?: number;
|
|
320
|
+
before?: string;
|
|
321
|
+
}): Promise<AgentChatMessage[]>;
|
|
322
|
+
streamChat(args: {
|
|
323
|
+
sessionId: string;
|
|
324
|
+
message: string;
|
|
325
|
+
mode?: ChatMode;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
cta?: {
|
|
328
|
+
previousText: string;
|
|
329
|
+
question: string;
|
|
330
|
+
selectedOption: string;
|
|
331
|
+
};
|
|
332
|
+
}): AsyncGenerator<StreamEvent | {
|
|
333
|
+
type: "done";
|
|
334
|
+
result: ChatResult;
|
|
335
|
+
}>;
|
|
336
|
+
sendMessage(args: {
|
|
337
|
+
sessionId: string;
|
|
338
|
+
message: string;
|
|
339
|
+
mode?: ChatMode;
|
|
340
|
+
}): Promise<ChatResult>;
|
|
341
|
+
confirmTicket(ticketId: string): Promise<ConfirmResult>;
|
|
342
|
+
cancelTicket(ticketId: string): Promise<CancelResult>;
|
|
343
|
+
setTradeConfirmations(enabled: boolean): Promise<SetConfirmationsResult>;
|
|
344
|
+
getTradeSettings(): Promise<TradeSettings>;
|
|
345
|
+
setTradeExecution(enabled: boolean): Promise<SetExecutionResult>;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export { AgentChatClient as A, StatusEventSchema as B, type CancelResult as C, type StreamEvent as D, ErrorEventSchema as E, type SuggestedAction as F, SuggestedActionSchema as G, type TicketAction as H, TicketActionSchema as I, type TicketStatus as J, TicketStatusSchema as K, TokenEventSchema as L, type TradeLink as M, TradeLinkSchema as N, type TradeSettings as O, type PendingAction as P, TradeSettingsSchema as Q, type TwitterSource as R, type Session as S, ThinkingEventSchema as T, TwitterSourceSchema as U, type AgentChatClientConfig as a, type AgentChatMessage as b, AgentChatMessageSchema as c, type AgentEvent as d, type AgentWireEvent as e, AgentWireEventSchema as f, CancelResultSchema as g, type ChatMode as h, ChatModeSchema as i, type ChatResult as j, ChatResultSchema as k, type CitationSource as l, CitationSourceSchema as m, type ConfirmResult as n, ConfirmResultSchema as o, PendingActionSchema as p, type SessionListItem as q, SessionListItemSchema as r, SessionSchema as s, type SessionSummary as t, SessionSummarySchema as u, type SetConfirmationsResult as v, SetConfirmationsResultSchema as w, type SetExecutionResult as x, SetExecutionResultSchema as y, SourcesEventSchema as z };
|