@pear-protocol/agent-sdk 0.4.1 → 0.5.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 CHANGED
@@ -4,7 +4,7 @@ TypeScript client for the Pear **agent chat** API — the conversational assista
4
4
  (pair-trade ideas, market data, and confirm-before-write trade execution).
5
5
 
6
6
  - **`@pear-protocol/agent-sdk`** — framework-agnostic core (`AgentChatClient`).
7
- - **`@pear-protocol/agent-sdk/react`** — optional React hooks (`useAgentChat`, `useAgentSessions`).
7
+ - **`@pear-protocol/agent-sdk/react`** — optional React hooks (`useAgentChat`, `useAgentSessions`, `useWalletLink`, `useOnboarding`).
8
8
 
9
9
  Published to **public npm** (same registry as the org's other `@pear-protocol`
10
10
  packages — no `.npmrc` or token needed). The wire types are a single source of
@@ -116,6 +116,66 @@ React apps can use `useWalletLink(client)` from `./react` —
116
116
  `{ linked, isWorking, error, link, unlink, refresh }` (`linked` is `null`
117
117
  while the initial status fetch is in flight).
118
118
 
119
+ ## Onboarding (deterministic, FE-controlled)
120
+
121
+ A first-time user can be onboarded with a short, deterministic wizard you render
122
+ yourself — the agent exposes the flow over REST (no in-band chat short-circuit).
123
+ Every endpoint returns the **same** state shape so you drive the loop off one type:
124
+
125
+ ```ts
126
+ let state = await client.getOnboardingState("pear_v3"); // { needsOnboarding, nextQuestion, isLast, answered, total, onboardingState, profile }
127
+ while (state.needsOnboarding && state.nextQuestion) {
128
+ const q = state.nextQuestion;
129
+ // closed questions carry q.options: { value, label, description? } — render
130
+ // label + description, submit value. Free-text note uses the typed string.
131
+ const value = q.freeform ? userTypedText : userPickedOption.value;
132
+ state = await client.submitOnboardingAnswer("pear_v3", { questionId: q.id, value });
133
+ }
134
+ // or bail: await client.skipOnboarding("pear_v3"); // smart-skip (parity with TG)
135
+ // start over: await client.resetOnboarding(); // clears picks — NOT for edits
136
+ // surface-static question set: await client.getOnboardingQuestions("pear_v3");
137
+ ```
138
+
139
+ ### Editing preferences (pre-fill + non-destructive)
140
+
141
+ `getOnboardingState` returns `profile` — the caller's CURRENT picks
142
+ (`experience`/`tradingStyle`/`riskAppetite`/`favoriteSectors`/`avoidAssets`/`note`,
143
+ all optional; `{}` for a new user). Render an edit form from the full question set
144
+ + `profile`, then submit only the changed field — the server MERGES, so editing
145
+ one field never wipes the others. **Use `submitOnboardingAnswer` to edit; `resetOnboarding`
146
+ is "start over" only.**
147
+
148
+ ```ts
149
+ const [state, questions] = await Promise.all([
150
+ client.getOnboardingState("pear_v3"),
151
+ client.getOnboardingQuestions("pear_v3"),
152
+ ]);
153
+ // Render each question PRE-FILLED: e.g. select state.profile.tradingStyle.
154
+ // On a change, submit just that field (non-destructive merge):
155
+ await client.submitOnboardingAnswer("pear_v3", { questionId: "risk_appetite", value: "aggressive" });
156
+ ```
157
+
158
+ React apps can use `useOnboarding({ client, surface })` from `./react` —
159
+ `{ needsOnboarding, onboardingState, currentQuestion, questions, profile, isLast, progress, submitAnswer, skip, reset, loading, error, refresh }`.
160
+ Gate your wizard on `needsOnboarding` once `loading` is false; for editing, render
161
+ `questions` pre-filled from `profile` and call `submitAnswer(questionId, value)`:
162
+
163
+ ```tsx
164
+ function App({ client }) {
165
+ const ob = useOnboarding({ client, surface: "pear_v3" });
166
+ if (ob.loading) return <Spinner />;
167
+ // First run — sequential wizard off currentQuestion + progress.
168
+ if (ob.needsOnboarding) return <OnboardingWizard {...ob} />;
169
+ // Edit — pre-fill from ob.profile, submit changed fields (no reset):
170
+ // ob.questions.map(q => …current value = ob.profile[…]…
171
+ // onChange={(value) => ob.submitAnswer(q.id, value)} )
172
+ return <Chat client={client} />;
173
+ }
174
+ ```
175
+
176
+ `submitAnswer` is overloaded: `submitAnswer(value)` answers the next first-run
177
+ question; `submitAnswer(questionId, value)` edits a specific field.
178
+
119
179
  ## Trade tickets (confirm-before-write)
120
180
 
121
181
  A turn that would move money returns a `pendingAction`
@@ -220,6 +220,122 @@ declare const AgentChatMessageSchema: z.ZodObject<{
220
220
  }, z.core.$loose>;
221
221
  type AgentChatMessage = z.infer<typeof AgentChatMessageSchema>;
222
222
 
223
+ declare const OnboardingQuestionIdSchema: z.ZodEnum<{
224
+ experience: "experience";
225
+ trading_style: "trading_style";
226
+ risk_appetite: "risk_appetite";
227
+ note: "note";
228
+ }>;
229
+ type OnboardingQuestionId = z.infer<typeof OnboardingQuestionIdSchema>;
230
+ declare const OnboardingStateSchema: z.ZodEnum<{
231
+ not_started: "not_started";
232
+ skipped: "skipped";
233
+ completed: "completed";
234
+ }>;
235
+ type OnboardingState = z.infer<typeof OnboardingStateSchema>;
236
+ declare const OnboardingOptionSchema: z.ZodObject<{
237
+ value: z.ZodString;
238
+ label: z.ZodString;
239
+ description: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strip>;
241
+ type OnboardingOption = z.infer<typeof OnboardingOptionSchema>;
242
+ declare const OnboardingQuestionSchema: z.ZodObject<{
243
+ id: z.ZodEnum<{
244
+ experience: "experience";
245
+ trading_style: "trading_style";
246
+ risk_appetite: "risk_appetite";
247
+ note: "note";
248
+ }>;
249
+ prompt: z.ZodString;
250
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
251
+ value: z.ZodString;
252
+ label: z.ZodString;
253
+ description: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strip>>>;
255
+ freeform: z.ZodBoolean;
256
+ }, z.core.$strip>;
257
+ type OnboardingQuestion = z.infer<typeof OnboardingQuestionSchema>;
258
+ declare const OnboardingProfileSchema: z.ZodObject<{
259
+ experience: z.ZodOptional<z.ZodEnum<{
260
+ new: "new";
261
+ intermediate: "intermediate";
262
+ seasoned: "seasoned";
263
+ }>>;
264
+ tradingStyle: z.ZodOptional<z.ZodEnum<{
265
+ scalper: "scalper";
266
+ swing: "swing";
267
+ position: "position";
268
+ passive: "passive";
269
+ }>>;
270
+ riskAppetite: z.ZodOptional<z.ZodEnum<{
271
+ conservative: "conservative";
272
+ balanced: "balanced";
273
+ aggressive: "aggressive";
274
+ }>>;
275
+ favoriteSectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
276
+ avoidAssets: z.ZodOptional<z.ZodArray<z.ZodString>>;
277
+ note: z.ZodOptional<z.ZodString>;
278
+ }, z.core.$strip>;
279
+ type OnboardingProfile = z.infer<typeof OnboardingProfileSchema>;
280
+ declare const OnboardingStateResponseSchema: z.ZodObject<{
281
+ needsOnboarding: z.ZodBoolean;
282
+ onboardingState: z.ZodEnum<{
283
+ not_started: "not_started";
284
+ skipped: "skipped";
285
+ completed: "completed";
286
+ }>;
287
+ nextQuestion: z.ZodNullable<z.ZodObject<{
288
+ id: z.ZodEnum<{
289
+ experience: "experience";
290
+ trading_style: "trading_style";
291
+ risk_appetite: "risk_appetite";
292
+ note: "note";
293
+ }>;
294
+ prompt: z.ZodString;
295
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
296
+ value: z.ZodString;
297
+ label: z.ZodString;
298
+ description: z.ZodOptional<z.ZodString>;
299
+ }, z.core.$strip>>>;
300
+ freeform: z.ZodBoolean;
301
+ }, z.core.$strip>>;
302
+ isLast: z.ZodBoolean;
303
+ answered: z.ZodNumber;
304
+ total: z.ZodNumber;
305
+ profile: z.ZodObject<{
306
+ experience: z.ZodOptional<z.ZodEnum<{
307
+ new: "new";
308
+ intermediate: "intermediate";
309
+ seasoned: "seasoned";
310
+ }>>;
311
+ tradingStyle: z.ZodOptional<z.ZodEnum<{
312
+ scalper: "scalper";
313
+ swing: "swing";
314
+ position: "position";
315
+ passive: "passive";
316
+ }>>;
317
+ riskAppetite: z.ZodOptional<z.ZodEnum<{
318
+ conservative: "conservative";
319
+ balanced: "balanced";
320
+ aggressive: "aggressive";
321
+ }>>;
322
+ favoriteSectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
323
+ avoidAssets: z.ZodOptional<z.ZodArray<z.ZodString>>;
324
+ note: z.ZodOptional<z.ZodString>;
325
+ }, z.core.$strip>;
326
+ }, z.core.$strip>;
327
+ type OnboardingStateResponse = z.infer<typeof OnboardingStateResponseSchema>;
328
+ declare const OnboardingAnswerRequestSchema: z.ZodObject<{
329
+ questionId: z.ZodEnum<{
330
+ experience: "experience";
331
+ trading_style: "trading_style";
332
+ risk_appetite: "risk_appetite";
333
+ note: "note";
334
+ }>;
335
+ value: z.ZodString;
336
+ }, z.core.$strip>;
337
+ type OnboardingAnswerRequest = z.infer<typeof OnboardingAnswerRequestSchema>;
338
+
223
339
  declare const TradeLinkSchema: z.ZodObject<{
224
340
  link: z.ZodString;
225
341
  platform: z.ZodString;
@@ -375,6 +491,11 @@ declare class AgentChatClient {
375
491
  code?: string;
376
492
  }): Promise<SelfLinkResult>;
377
493
  unlinkWallet(): Promise<SelfUnlinkResult>;
494
+ getOnboardingState(surface: ChatSurface): Promise<OnboardingStateResponse>;
495
+ getOnboardingQuestions(surface: ChatSurface): Promise<OnboardingQuestion[]>;
496
+ submitOnboardingAnswer(surface: ChatSurface, body: OnboardingAnswerRequest): Promise<OnboardingStateResponse>;
497
+ skipOnboarding(surface: ChatSurface): Promise<OnboardingStateResponse>;
498
+ resetOnboarding(): Promise<OnboardingStateResponse>;
378
499
  }
379
500
 
380
- export { type TwitterSource as $, AgentChatClient as A, type SessionSummary as B, type CancelResult as C, SessionSummarySchema as D, ErrorEventSchema as E, type SetConfirmationsResult as F, SetConfirmationsResultSchema as G, type SetExecutionResult as H, SetExecutionResultSchema as I, SourcesEventSchema as J, StatusEventSchema as K, type LinkStatus as L, type StreamEvent as M, type SuggestedAction as N, SuggestedActionSchema as O, type PendingAction as P, type TicketAction as Q, TicketActionSchema as R, type SelfLinkResult as S, ThinkingEventSchema as T, type TicketStatus as U, TicketStatusSchema as V, TokenEventSchema as W, type TradeLink as X, TradeLinkSchema as Y, type TradeSettings as Z, TradeSettingsSchema as _, type AgentChatClientConfig as a, TwitterSourceSchema as a0, 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 ChatSurface as l, ChatSurfaceSchema as m, type CitationSource as n, CitationSourceSchema as o, type ConfirmResult as p, ConfirmResultSchema as q, LinkStatusSchema as r, PendingActionSchema as s, SelfLinkResultSchema as t, type SelfUnlinkResult as u, SelfUnlinkResultSchema as v, type Session as w, type SessionListItem as x, SessionListItemSchema as y, SessionSchema as z };
501
+ export { StatusEventSchema as $, AgentChatClient as A, OnboardingQuestionSchema as B, type CancelResult as C, type OnboardingState as D, ErrorEventSchema as E, type OnboardingStateResponse as F, OnboardingStateResponseSchema as G, OnboardingStateSchema as H, PendingActionSchema as I, SelfLinkResultSchema as J, type SelfUnlinkResult as K, type LinkStatus as L, SelfUnlinkResultSchema as M, type Session as N, type OnboardingAnswerRequest as O, type PendingAction as P, type SessionListItem as Q, SessionListItemSchema as R, type SelfLinkResult as S, SessionSchema as T, type SessionSummary as U, SessionSummarySchema as V, type SetConfirmationsResult as W, SetConfirmationsResultSchema as X, type SetExecutionResult as Y, SetExecutionResultSchema as Z, SourcesEventSchema as _, type AgentChatClientConfig as a, type StreamEvent as a0, type SuggestedAction as a1, SuggestedActionSchema as a2, ThinkingEventSchema as a3, type TicketAction as a4, TicketActionSchema as a5, type TicketStatus as a6, TicketStatusSchema as a7, TokenEventSchema as a8, type TradeLink as a9, TradeLinkSchema as aa, type TradeSettings as ab, TradeSettingsSchema as ac, type TwitterSource as ad, TwitterSourceSchema as ae, 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 ChatSurface as l, ChatSurfaceSchema as m, type CitationSource as n, CitationSourceSchema as o, type ConfirmResult as p, ConfirmResultSchema as q, LinkStatusSchema as r, OnboardingAnswerRequestSchema as s, type OnboardingOption as t, OnboardingOptionSchema as u, type OnboardingProfile as v, OnboardingProfileSchema as w, type OnboardingQuestion as x, type OnboardingQuestionId as y, OnboardingQuestionIdSchema as z };
@@ -220,6 +220,122 @@ declare const AgentChatMessageSchema: z.ZodObject<{
220
220
  }, z.core.$loose>;
221
221
  type AgentChatMessage = z.infer<typeof AgentChatMessageSchema>;
222
222
 
223
+ declare const OnboardingQuestionIdSchema: z.ZodEnum<{
224
+ experience: "experience";
225
+ trading_style: "trading_style";
226
+ risk_appetite: "risk_appetite";
227
+ note: "note";
228
+ }>;
229
+ type OnboardingQuestionId = z.infer<typeof OnboardingQuestionIdSchema>;
230
+ declare const OnboardingStateSchema: z.ZodEnum<{
231
+ not_started: "not_started";
232
+ skipped: "skipped";
233
+ completed: "completed";
234
+ }>;
235
+ type OnboardingState = z.infer<typeof OnboardingStateSchema>;
236
+ declare const OnboardingOptionSchema: z.ZodObject<{
237
+ value: z.ZodString;
238
+ label: z.ZodString;
239
+ description: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strip>;
241
+ type OnboardingOption = z.infer<typeof OnboardingOptionSchema>;
242
+ declare const OnboardingQuestionSchema: z.ZodObject<{
243
+ id: z.ZodEnum<{
244
+ experience: "experience";
245
+ trading_style: "trading_style";
246
+ risk_appetite: "risk_appetite";
247
+ note: "note";
248
+ }>;
249
+ prompt: z.ZodString;
250
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
251
+ value: z.ZodString;
252
+ label: z.ZodString;
253
+ description: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strip>>>;
255
+ freeform: z.ZodBoolean;
256
+ }, z.core.$strip>;
257
+ type OnboardingQuestion = z.infer<typeof OnboardingQuestionSchema>;
258
+ declare const OnboardingProfileSchema: z.ZodObject<{
259
+ experience: z.ZodOptional<z.ZodEnum<{
260
+ new: "new";
261
+ intermediate: "intermediate";
262
+ seasoned: "seasoned";
263
+ }>>;
264
+ tradingStyle: z.ZodOptional<z.ZodEnum<{
265
+ scalper: "scalper";
266
+ swing: "swing";
267
+ position: "position";
268
+ passive: "passive";
269
+ }>>;
270
+ riskAppetite: z.ZodOptional<z.ZodEnum<{
271
+ conservative: "conservative";
272
+ balanced: "balanced";
273
+ aggressive: "aggressive";
274
+ }>>;
275
+ favoriteSectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
276
+ avoidAssets: z.ZodOptional<z.ZodArray<z.ZodString>>;
277
+ note: z.ZodOptional<z.ZodString>;
278
+ }, z.core.$strip>;
279
+ type OnboardingProfile = z.infer<typeof OnboardingProfileSchema>;
280
+ declare const OnboardingStateResponseSchema: z.ZodObject<{
281
+ needsOnboarding: z.ZodBoolean;
282
+ onboardingState: z.ZodEnum<{
283
+ not_started: "not_started";
284
+ skipped: "skipped";
285
+ completed: "completed";
286
+ }>;
287
+ nextQuestion: z.ZodNullable<z.ZodObject<{
288
+ id: z.ZodEnum<{
289
+ experience: "experience";
290
+ trading_style: "trading_style";
291
+ risk_appetite: "risk_appetite";
292
+ note: "note";
293
+ }>;
294
+ prompt: z.ZodString;
295
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
296
+ value: z.ZodString;
297
+ label: z.ZodString;
298
+ description: z.ZodOptional<z.ZodString>;
299
+ }, z.core.$strip>>>;
300
+ freeform: z.ZodBoolean;
301
+ }, z.core.$strip>>;
302
+ isLast: z.ZodBoolean;
303
+ answered: z.ZodNumber;
304
+ total: z.ZodNumber;
305
+ profile: z.ZodObject<{
306
+ experience: z.ZodOptional<z.ZodEnum<{
307
+ new: "new";
308
+ intermediate: "intermediate";
309
+ seasoned: "seasoned";
310
+ }>>;
311
+ tradingStyle: z.ZodOptional<z.ZodEnum<{
312
+ scalper: "scalper";
313
+ swing: "swing";
314
+ position: "position";
315
+ passive: "passive";
316
+ }>>;
317
+ riskAppetite: z.ZodOptional<z.ZodEnum<{
318
+ conservative: "conservative";
319
+ balanced: "balanced";
320
+ aggressive: "aggressive";
321
+ }>>;
322
+ favoriteSectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
323
+ avoidAssets: z.ZodOptional<z.ZodArray<z.ZodString>>;
324
+ note: z.ZodOptional<z.ZodString>;
325
+ }, z.core.$strip>;
326
+ }, z.core.$strip>;
327
+ type OnboardingStateResponse = z.infer<typeof OnboardingStateResponseSchema>;
328
+ declare const OnboardingAnswerRequestSchema: z.ZodObject<{
329
+ questionId: z.ZodEnum<{
330
+ experience: "experience";
331
+ trading_style: "trading_style";
332
+ risk_appetite: "risk_appetite";
333
+ note: "note";
334
+ }>;
335
+ value: z.ZodString;
336
+ }, z.core.$strip>;
337
+ type OnboardingAnswerRequest = z.infer<typeof OnboardingAnswerRequestSchema>;
338
+
223
339
  declare const TradeLinkSchema: z.ZodObject<{
224
340
  link: z.ZodString;
225
341
  platform: z.ZodString;
@@ -375,6 +491,11 @@ declare class AgentChatClient {
375
491
  code?: string;
376
492
  }): Promise<SelfLinkResult>;
377
493
  unlinkWallet(): Promise<SelfUnlinkResult>;
494
+ getOnboardingState(surface: ChatSurface): Promise<OnboardingStateResponse>;
495
+ getOnboardingQuestions(surface: ChatSurface): Promise<OnboardingQuestion[]>;
496
+ submitOnboardingAnswer(surface: ChatSurface, body: OnboardingAnswerRequest): Promise<OnboardingStateResponse>;
497
+ skipOnboarding(surface: ChatSurface): Promise<OnboardingStateResponse>;
498
+ resetOnboarding(): Promise<OnboardingStateResponse>;
378
499
  }
379
500
 
380
- export { type TwitterSource as $, AgentChatClient as A, type SessionSummary as B, type CancelResult as C, SessionSummarySchema as D, ErrorEventSchema as E, type SetConfirmationsResult as F, SetConfirmationsResultSchema as G, type SetExecutionResult as H, SetExecutionResultSchema as I, SourcesEventSchema as J, StatusEventSchema as K, type LinkStatus as L, type StreamEvent as M, type SuggestedAction as N, SuggestedActionSchema as O, type PendingAction as P, type TicketAction as Q, TicketActionSchema as R, type SelfLinkResult as S, ThinkingEventSchema as T, type TicketStatus as U, TicketStatusSchema as V, TokenEventSchema as W, type TradeLink as X, TradeLinkSchema as Y, type TradeSettings as Z, TradeSettingsSchema as _, type AgentChatClientConfig as a, TwitterSourceSchema as a0, 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 ChatSurface as l, ChatSurfaceSchema as m, type CitationSource as n, CitationSourceSchema as o, type ConfirmResult as p, ConfirmResultSchema as q, LinkStatusSchema as r, PendingActionSchema as s, SelfLinkResultSchema as t, type SelfUnlinkResult as u, SelfUnlinkResultSchema as v, type Session as w, type SessionListItem as x, SessionListItemSchema as y, SessionSchema as z };
501
+ export { StatusEventSchema as $, AgentChatClient as A, OnboardingQuestionSchema as B, type CancelResult as C, type OnboardingState as D, ErrorEventSchema as E, type OnboardingStateResponse as F, OnboardingStateResponseSchema as G, OnboardingStateSchema as H, PendingActionSchema as I, SelfLinkResultSchema as J, type SelfUnlinkResult as K, type LinkStatus as L, SelfUnlinkResultSchema as M, type Session as N, type OnboardingAnswerRequest as O, type PendingAction as P, type SessionListItem as Q, SessionListItemSchema as R, type SelfLinkResult as S, SessionSchema as T, type SessionSummary as U, SessionSummarySchema as V, type SetConfirmationsResult as W, SetConfirmationsResultSchema as X, type SetExecutionResult as Y, SetExecutionResultSchema as Z, SourcesEventSchema as _, type AgentChatClientConfig as a, type StreamEvent as a0, type SuggestedAction as a1, SuggestedActionSchema as a2, ThinkingEventSchema as a3, type TicketAction as a4, TicketActionSchema as a5, type TicketStatus as a6, TicketStatusSchema as a7, TokenEventSchema as a8, type TradeLink as a9, TradeLinkSchema as aa, type TradeSettings as ab, TradeSettingsSchema as ac, type TwitterSource as ad, TwitterSourceSchema as ae, 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 ChatSurface as l, ChatSurfaceSchema as m, type CitationSource as n, CitationSourceSchema as o, type ConfirmResult as p, ConfirmResultSchema as q, LinkStatusSchema as r, OnboardingAnswerRequestSchema as s, type OnboardingOption as t, OnboardingOptionSchema as u, type OnboardingProfile as v, OnboardingProfileSchema as w, type OnboardingQuestion as x, type OnboardingQuestionId as y, OnboardingQuestionIdSchema as z };
package/dist/index.cjs CHANGED
@@ -248,6 +248,49 @@ var AgentChatMessageSchema = zod.z.looseObject({
248
248
  images: zod.z.array(zod.z.string()).nullish(),
249
249
  suggestedAction: SuggestedActionSchema.nullish()
250
250
  });
251
+ var OnboardingQuestionIdSchema = zod.z.enum([
252
+ "experience",
253
+ "trading_style",
254
+ "risk_appetite",
255
+ "note"
256
+ ]);
257
+ var OnboardingStateSchema = zod.z.enum([
258
+ "not_started",
259
+ "skipped",
260
+ "completed"
261
+ ]);
262
+ var OnboardingOptionSchema = zod.z.object({
263
+ value: zod.z.string(),
264
+ label: zod.z.string(),
265
+ description: zod.z.string().optional()
266
+ });
267
+ var OnboardingQuestionSchema = zod.z.object({
268
+ id: OnboardingQuestionIdSchema,
269
+ prompt: zod.z.string(),
270
+ options: zod.z.array(OnboardingOptionSchema).optional(),
271
+ freeform: zod.z.boolean()
272
+ });
273
+ var OnboardingProfileSchema = zod.z.object({
274
+ experience: zod.z.enum(["new", "intermediate", "seasoned"]).optional(),
275
+ tradingStyle: zod.z.enum(["scalper", "swing", "position", "passive"]).optional(),
276
+ riskAppetite: zod.z.enum(["conservative", "balanced", "aggressive"]).optional(),
277
+ favoriteSectors: zod.z.array(zod.z.string()).optional(),
278
+ avoidAssets: zod.z.array(zod.z.string()).optional(),
279
+ note: zod.z.string().optional()
280
+ });
281
+ var OnboardingStateResponseSchema = zod.z.object({
282
+ needsOnboarding: zod.z.boolean(),
283
+ onboardingState: OnboardingStateSchema,
284
+ nextQuestion: OnboardingQuestionSchema.nullable(),
285
+ isLast: zod.z.boolean(),
286
+ answered: zod.z.number(),
287
+ total: zod.z.number(),
288
+ profile: OnboardingProfileSchema
289
+ });
290
+ var OnboardingAnswerRequestSchema = zod.z.object({
291
+ questionId: OnboardingQuestionIdSchema,
292
+ value: zod.z.string()
293
+ });
251
294
 
252
295
  // src/stream.ts
253
296
  async function* parseSseStream(body) {
@@ -455,6 +498,48 @@ var AgentChatClient = class {
455
498
  unlinkWallet() {
456
499
  return this.http.json("DELETE", "/auth/link-wallet/self").then((raw) => SelfUnlinkResultSchema.parse(raw));
457
500
  }
501
+ // ── Onboarding (deterministic, FE-controlled) ──────────────────────
502
+ // Drive a wizard: read state, render `nextQuestion`, POST an answer (get the
503
+ // same shape back), or skip/reset. `surface` is the client surface — drives
504
+ // per-surface question phrasing server-side. The userId is the JWT caller,
505
+ // never sent in the body.
506
+ /** Current onboarding state for the caller on this surface (gate + next
507
+ * question + progress + current `profile` picks). Returns the same shape
508
+ * submitOnboardingAnswer/skip do. */
509
+ getOnboardingState(surface) {
510
+ return this.http.json(
511
+ "GET",
512
+ `/onboarding/state?surface=${encodeURIComponent(surface)}`
513
+ ).then((raw) => OnboardingStateResponseSchema.parse(raw));
514
+ }
515
+ /** Ordered onboarding questions for the surface (surface-static; no per-user
516
+ * state). Closed questions carry `options`; the free-text note has none. */
517
+ getOnboardingQuestions(surface) {
518
+ return this.http.json(
519
+ "GET",
520
+ `/onboarding/questions?surface=${encodeURIComponent(surface)}`
521
+ ).then((raw) => raw.map((q) => OnboardingQuestionSchema.parse(q)));
522
+ }
523
+ /** Record one answer, then get the new state shape (next question or done). */
524
+ submitOnboardingAnswer(surface, body) {
525
+ return this.http.json(
526
+ "POST",
527
+ `/onboarding/answer?surface=${encodeURIComponent(surface)}`,
528
+ body
529
+ ).then((raw) => OnboardingStateResponseSchema.parse(raw));
530
+ }
531
+ /** Smart skip (parity with TG): skipping the optional last note step COMPLETES
532
+ * onboarding with style+risk captured; skipping earlier bails the whole flow. */
533
+ skipOnboarding(surface) {
534
+ return this.http.json(
535
+ "POST",
536
+ `/onboarding/skip?surface=${encodeURIComponent(surface)}`
537
+ ).then((raw) => OnboardingStateResponseSchema.parse(raw));
538
+ }
539
+ /** Retake — clears persona + resets to not_started so the flow re-runs. */
540
+ resetOnboarding() {
541
+ return this.http.json("POST", "/onboarding/reset").then((raw) => OnboardingStateResponseSchema.parse(raw));
542
+ }
458
543
  };
459
544
 
460
545
  exports.AgentChatClient = AgentChatClient;
@@ -472,6 +557,13 @@ exports.ConflictError = ConflictError;
472
557
  exports.ErrorEventSchema = ErrorEventSchema;
473
558
  exports.ForbiddenError = ForbiddenError;
474
559
  exports.LinkStatusSchema = LinkStatusSchema;
560
+ exports.OnboardingAnswerRequestSchema = OnboardingAnswerRequestSchema;
561
+ exports.OnboardingOptionSchema = OnboardingOptionSchema;
562
+ exports.OnboardingProfileSchema = OnboardingProfileSchema;
563
+ exports.OnboardingQuestionIdSchema = OnboardingQuestionIdSchema;
564
+ exports.OnboardingQuestionSchema = OnboardingQuestionSchema;
565
+ exports.OnboardingStateResponseSchema = OnboardingStateResponseSchema;
566
+ exports.OnboardingStateSchema = OnboardingStateSchema;
475
567
  exports.PendingActionSchema = PendingActionSchema;
476
568
  exports.RateLimitError = RateLimitError;
477
569
  exports.SelfLinkResultSchema = SelfLinkResultSchema;