@starcite/sdk 0.0.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/LICENSE +201 -0
- package/README.md +219 -0
- package/dist/index.cjs +608 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +555 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.js +574 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Request payload for creating a session.
|
|
5
|
+
*/
|
|
6
|
+
declare const CreateSessionInputSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
title: z.ZodOptional<z.ZodString>;
|
|
9
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
metadata?: Record<string, unknown> | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
id?: string | undefined;
|
|
16
|
+
title?: string | undefined;
|
|
17
|
+
metadata?: Record<string, unknown> | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Inferred TypeScript type for {@link CreateSessionInputSchema}.
|
|
21
|
+
*/
|
|
22
|
+
type CreateSessionInput = z.infer<typeof CreateSessionInputSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Session record returned by the Starcite API.
|
|
25
|
+
*/
|
|
26
|
+
declare const SessionRecordSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
30
|
+
last_seq: z.ZodNumber;
|
|
31
|
+
created_at: z.ZodString;
|
|
32
|
+
updated_at: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
id: string;
|
|
35
|
+
metadata: Record<string, unknown>;
|
|
36
|
+
last_seq: number;
|
|
37
|
+
created_at: string;
|
|
38
|
+
updated_at: string;
|
|
39
|
+
title?: string | null | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
id: string;
|
|
42
|
+
metadata: Record<string, unknown>;
|
|
43
|
+
last_seq: number;
|
|
44
|
+
created_at: string;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
title?: string | null | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Inferred TypeScript type for {@link SessionRecordSchema}.
|
|
50
|
+
*/
|
|
51
|
+
type SessionRecord = z.infer<typeof SessionRecordSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* Session item returned by the list endpoint.
|
|
54
|
+
*/
|
|
55
|
+
declare const SessionListItemSchema: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
59
|
+
created_at: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
id: string;
|
|
62
|
+
metadata: Record<string, unknown>;
|
|
63
|
+
created_at: string;
|
|
64
|
+
title?: string | null | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
id: string;
|
|
67
|
+
metadata: Record<string, unknown>;
|
|
68
|
+
created_at: string;
|
|
69
|
+
title?: string | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Inferred TypeScript type for {@link SessionListItemSchema}.
|
|
73
|
+
*/
|
|
74
|
+
type SessionListItem = z.infer<typeof SessionListItemSchema>;
|
|
75
|
+
/**
|
|
76
|
+
* Paginated session list response.
|
|
77
|
+
*/
|
|
78
|
+
declare const SessionListPageSchema: z.ZodObject<{
|
|
79
|
+
sessions: z.ZodArray<z.ZodObject<{
|
|
80
|
+
id: z.ZodString;
|
|
81
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
83
|
+
created_at: z.ZodString;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
id: string;
|
|
86
|
+
metadata: Record<string, unknown>;
|
|
87
|
+
created_at: string;
|
|
88
|
+
title?: string | null | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
id: string;
|
|
91
|
+
metadata: Record<string, unknown>;
|
|
92
|
+
created_at: string;
|
|
93
|
+
title?: string | null | undefined;
|
|
94
|
+
}>, "many">;
|
|
95
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
sessions: {
|
|
98
|
+
id: string;
|
|
99
|
+
metadata: Record<string, unknown>;
|
|
100
|
+
created_at: string;
|
|
101
|
+
title?: string | null | undefined;
|
|
102
|
+
}[];
|
|
103
|
+
next_cursor: string | null;
|
|
104
|
+
}, {
|
|
105
|
+
sessions: {
|
|
106
|
+
id: string;
|
|
107
|
+
metadata: Record<string, unknown>;
|
|
108
|
+
created_at: string;
|
|
109
|
+
title?: string | null | undefined;
|
|
110
|
+
}[];
|
|
111
|
+
next_cursor: string | null;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Inferred TypeScript type for {@link SessionListPageSchema}.
|
|
115
|
+
*/
|
|
116
|
+
type SessionListPage = z.infer<typeof SessionListPageSchema>;
|
|
117
|
+
/**
|
|
118
|
+
* Low-level request payload for appending an event to a session.
|
|
119
|
+
*/
|
|
120
|
+
declare const AppendEventRequestSchema: z.ZodObject<{
|
|
121
|
+
type: z.ZodString;
|
|
122
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
123
|
+
actor: z.ZodString;
|
|
124
|
+
producer_id: z.ZodString;
|
|
125
|
+
producer_seq: z.ZodNumber;
|
|
126
|
+
source: z.ZodOptional<z.ZodString>;
|
|
127
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
128
|
+
refs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
129
|
+
idempotency_key: z.ZodOptional<z.ZodString>;
|
|
130
|
+
expected_seq: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
type: string;
|
|
133
|
+
payload: Record<string, unknown>;
|
|
134
|
+
actor: string;
|
|
135
|
+
producer_id: string;
|
|
136
|
+
producer_seq: number;
|
|
137
|
+
metadata?: Record<string, unknown> | undefined;
|
|
138
|
+
source?: string | undefined;
|
|
139
|
+
refs?: Record<string, unknown> | undefined;
|
|
140
|
+
idempotency_key?: string | undefined;
|
|
141
|
+
expected_seq?: number | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
type: string;
|
|
144
|
+
payload: Record<string, unknown>;
|
|
145
|
+
actor: string;
|
|
146
|
+
producer_id: string;
|
|
147
|
+
producer_seq: number;
|
|
148
|
+
metadata?: Record<string, unknown> | undefined;
|
|
149
|
+
source?: string | undefined;
|
|
150
|
+
refs?: Record<string, unknown> | undefined;
|
|
151
|
+
idempotency_key?: string | undefined;
|
|
152
|
+
expected_seq?: number | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* Inferred TypeScript type for {@link AppendEventRequestSchema}.
|
|
156
|
+
*/
|
|
157
|
+
type AppendEventRequest = z.infer<typeof AppendEventRequestSchema>;
|
|
158
|
+
/**
|
|
159
|
+
* API response returned after appending an event.
|
|
160
|
+
*/
|
|
161
|
+
declare const AppendEventResponseSchema: z.ZodObject<{
|
|
162
|
+
seq: z.ZodNumber;
|
|
163
|
+
last_seq: z.ZodNumber;
|
|
164
|
+
deduped: z.ZodBoolean;
|
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
|
166
|
+
last_seq: number;
|
|
167
|
+
seq: number;
|
|
168
|
+
deduped: boolean;
|
|
169
|
+
}, {
|
|
170
|
+
last_seq: number;
|
|
171
|
+
seq: number;
|
|
172
|
+
deduped: boolean;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Inferred TypeScript type for {@link AppendEventResponseSchema}.
|
|
176
|
+
*/
|
|
177
|
+
type AppendEventResponse = z.infer<typeof AppendEventResponseSchema>;
|
|
178
|
+
/**
|
|
179
|
+
* Raw event frame shape emitted by the Starcite tail stream.
|
|
180
|
+
*/
|
|
181
|
+
declare const TailEventSchema: z.ZodObject<{
|
|
182
|
+
seq: z.ZodNumber;
|
|
183
|
+
type: z.ZodString;
|
|
184
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
185
|
+
actor: z.ZodString;
|
|
186
|
+
producer_id: z.ZodString;
|
|
187
|
+
producer_seq: z.ZodNumber;
|
|
188
|
+
source: z.ZodOptional<z.ZodString>;
|
|
189
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
190
|
+
refs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
191
|
+
idempotency_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
192
|
+
inserted_at: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
type: string;
|
|
195
|
+
payload: Record<string, unknown>;
|
|
196
|
+
actor: string;
|
|
197
|
+
producer_id: string;
|
|
198
|
+
producer_seq: number;
|
|
199
|
+
seq: number;
|
|
200
|
+
metadata?: Record<string, unknown> | undefined;
|
|
201
|
+
source?: string | undefined;
|
|
202
|
+
refs?: Record<string, unknown> | undefined;
|
|
203
|
+
idempotency_key?: string | null | undefined;
|
|
204
|
+
inserted_at?: string | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
type: string;
|
|
207
|
+
payload: Record<string, unknown>;
|
|
208
|
+
actor: string;
|
|
209
|
+
producer_id: string;
|
|
210
|
+
producer_seq: number;
|
|
211
|
+
seq: number;
|
|
212
|
+
metadata?: Record<string, unknown> | undefined;
|
|
213
|
+
source?: string | undefined;
|
|
214
|
+
refs?: Record<string, unknown> | undefined;
|
|
215
|
+
idempotency_key?: string | null | undefined;
|
|
216
|
+
inserted_at?: string | undefined;
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* Inferred TypeScript type for {@link TailEventSchema}.
|
|
220
|
+
*/
|
|
221
|
+
type TailEvent = z.infer<typeof TailEventSchema>;
|
|
222
|
+
/**
|
|
223
|
+
* Convenience tail event shape with SDK-derived fields (`agent`, `text`).
|
|
224
|
+
*/
|
|
225
|
+
declare const SessionEventInternalSchema: z.ZodObject<{
|
|
226
|
+
seq: z.ZodNumber;
|
|
227
|
+
type: z.ZodString;
|
|
228
|
+
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
229
|
+
actor: z.ZodString;
|
|
230
|
+
producer_id: z.ZodString;
|
|
231
|
+
producer_seq: z.ZodNumber;
|
|
232
|
+
source: z.ZodOptional<z.ZodString>;
|
|
233
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
234
|
+
refs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
235
|
+
idempotency_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
236
|
+
inserted_at: z.ZodOptional<z.ZodString>;
|
|
237
|
+
} & {
|
|
238
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
239
|
+
text: z.ZodOptional<z.ZodString>;
|
|
240
|
+
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
type: string;
|
|
242
|
+
payload: Record<string, unknown>;
|
|
243
|
+
actor: string;
|
|
244
|
+
producer_id: string;
|
|
245
|
+
producer_seq: number;
|
|
246
|
+
seq: number;
|
|
247
|
+
metadata?: Record<string, unknown> | undefined;
|
|
248
|
+
source?: string | undefined;
|
|
249
|
+
refs?: Record<string, unknown> | undefined;
|
|
250
|
+
idempotency_key?: string | null | undefined;
|
|
251
|
+
inserted_at?: string | undefined;
|
|
252
|
+
agent?: string | undefined;
|
|
253
|
+
text?: string | undefined;
|
|
254
|
+
}, {
|
|
255
|
+
type: string;
|
|
256
|
+
payload: Record<string, unknown>;
|
|
257
|
+
actor: string;
|
|
258
|
+
producer_id: string;
|
|
259
|
+
producer_seq: number;
|
|
260
|
+
seq: number;
|
|
261
|
+
metadata?: Record<string, unknown> | undefined;
|
|
262
|
+
source?: string | undefined;
|
|
263
|
+
refs?: Record<string, unknown> | undefined;
|
|
264
|
+
idempotency_key?: string | null | undefined;
|
|
265
|
+
inserted_at?: string | undefined;
|
|
266
|
+
agent?: string | undefined;
|
|
267
|
+
text?: string | undefined;
|
|
268
|
+
}>;
|
|
269
|
+
/**
|
|
270
|
+
* Inferred TypeScript type for the SDK-level enriched tail event.
|
|
271
|
+
*/
|
|
272
|
+
type SessionEvent = z.infer<typeof SessionEventInternalSchema>;
|
|
273
|
+
/**
|
|
274
|
+
* High-level `session.append()` input.
|
|
275
|
+
*
|
|
276
|
+
* You must provide producer identity (`producerId`, `producerSeq`) and either
|
|
277
|
+
* `text` or `payload`.
|
|
278
|
+
*/
|
|
279
|
+
declare const SessionAppendInputSchema: z.ZodEffects<z.ZodObject<{
|
|
280
|
+
agent: z.ZodString;
|
|
281
|
+
producerId: z.ZodString;
|
|
282
|
+
producerSeq: z.ZodNumber;
|
|
283
|
+
text: z.ZodOptional<z.ZodString>;
|
|
284
|
+
payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
285
|
+
type: z.ZodOptional<z.ZodString>;
|
|
286
|
+
source: z.ZodOptional<z.ZodString>;
|
|
287
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
288
|
+
refs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
289
|
+
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
290
|
+
expectedSeq: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
agent: string;
|
|
293
|
+
producerId: string;
|
|
294
|
+
producerSeq: number;
|
|
295
|
+
type?: string | undefined;
|
|
296
|
+
metadata?: Record<string, unknown> | undefined;
|
|
297
|
+
payload?: Record<string, unknown> | undefined;
|
|
298
|
+
source?: string | undefined;
|
|
299
|
+
refs?: Record<string, unknown> | undefined;
|
|
300
|
+
text?: string | undefined;
|
|
301
|
+
idempotencyKey?: string | undefined;
|
|
302
|
+
expectedSeq?: number | undefined;
|
|
303
|
+
}, {
|
|
304
|
+
agent: string;
|
|
305
|
+
producerId: string;
|
|
306
|
+
producerSeq: number;
|
|
307
|
+
type?: string | undefined;
|
|
308
|
+
metadata?: Record<string, unknown> | undefined;
|
|
309
|
+
payload?: Record<string, unknown> | undefined;
|
|
310
|
+
source?: string | undefined;
|
|
311
|
+
refs?: Record<string, unknown> | undefined;
|
|
312
|
+
text?: string | undefined;
|
|
313
|
+
idempotencyKey?: string | undefined;
|
|
314
|
+
expectedSeq?: number | undefined;
|
|
315
|
+
}>, {
|
|
316
|
+
agent: string;
|
|
317
|
+
producerId: string;
|
|
318
|
+
producerSeq: number;
|
|
319
|
+
type?: string | undefined;
|
|
320
|
+
metadata?: Record<string, unknown> | undefined;
|
|
321
|
+
payload?: Record<string, unknown> | undefined;
|
|
322
|
+
source?: string | undefined;
|
|
323
|
+
refs?: Record<string, unknown> | undefined;
|
|
324
|
+
text?: string | undefined;
|
|
325
|
+
idempotencyKey?: string | undefined;
|
|
326
|
+
expectedSeq?: number | undefined;
|
|
327
|
+
}, {
|
|
328
|
+
agent: string;
|
|
329
|
+
producerId: string;
|
|
330
|
+
producerSeq: number;
|
|
331
|
+
type?: string | undefined;
|
|
332
|
+
metadata?: Record<string, unknown> | undefined;
|
|
333
|
+
payload?: Record<string, unknown> | undefined;
|
|
334
|
+
source?: string | undefined;
|
|
335
|
+
refs?: Record<string, unknown> | undefined;
|
|
336
|
+
text?: string | undefined;
|
|
337
|
+
idempotencyKey?: string | undefined;
|
|
338
|
+
expectedSeq?: number | undefined;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* Inferred TypeScript type for {@link SessionAppendInputSchema}.
|
|
342
|
+
*/
|
|
343
|
+
type SessionAppendInput = z.infer<typeof SessionAppendInputSchema>;
|
|
344
|
+
/**
|
|
345
|
+
* Options for streaming events from a session.
|
|
346
|
+
*/
|
|
347
|
+
interface SessionTailOptions {
|
|
348
|
+
/**
|
|
349
|
+
* Starting cursor (inclusive) in the event stream.
|
|
350
|
+
*/
|
|
351
|
+
cursor?: number;
|
|
352
|
+
/**
|
|
353
|
+
* Optional filter for `agent:<name>` events.
|
|
354
|
+
*/
|
|
355
|
+
agent?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Optional abort signal to close the stream.
|
|
358
|
+
*/
|
|
359
|
+
signal?: AbortSignal;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Options for listing sessions.
|
|
363
|
+
*/
|
|
364
|
+
interface SessionListOptions {
|
|
365
|
+
/**
|
|
366
|
+
* Maximum rows to return. Must be a positive integer.
|
|
367
|
+
*/
|
|
368
|
+
limit?: number;
|
|
369
|
+
/**
|
|
370
|
+
* Optional cursor from the previous response.
|
|
371
|
+
*/
|
|
372
|
+
cursor?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Optional flat metadata exact-match filters.
|
|
375
|
+
*/
|
|
376
|
+
metadata?: Record<string, string>;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Minimal WebSocket contract required by the SDK.
|
|
380
|
+
*/
|
|
381
|
+
interface StarciteWebSocket {
|
|
382
|
+
addEventListener(type: string, listener: (event: unknown) => void): void;
|
|
383
|
+
removeEventListener(type: string, listener: (event: unknown) => void): void;
|
|
384
|
+
close(code?: number, reason?: string): void;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Factory used to create the WebSocket connection for `tail`.
|
|
388
|
+
*/
|
|
389
|
+
interface StarciteWebSocketConnectOptions {
|
|
390
|
+
/**
|
|
391
|
+
* Headers to include with the WebSocket handshake request.
|
|
392
|
+
*/
|
|
393
|
+
headers?: HeadersInit;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Factory used to create the WebSocket connection for `tail`.
|
|
397
|
+
*/
|
|
398
|
+
type StarciteWebSocketFactory = (url: string, options?: StarciteWebSocketConnectOptions) => StarciteWebSocket;
|
|
399
|
+
/**
|
|
400
|
+
* Client construction options.
|
|
401
|
+
*/
|
|
402
|
+
interface StarciteClientOptions {
|
|
403
|
+
/**
|
|
404
|
+
* Base API URL. Defaults to `process.env.STARCITE_BASE_URL` or `http://localhost:4000`.
|
|
405
|
+
*/
|
|
406
|
+
baseUrl?: string;
|
|
407
|
+
/**
|
|
408
|
+
* Custom fetch implementation for non-standard runtimes.
|
|
409
|
+
*/
|
|
410
|
+
fetch?: typeof fetch;
|
|
411
|
+
/**
|
|
412
|
+
* Headers applied to every HTTP request.
|
|
413
|
+
*/
|
|
414
|
+
headers?: HeadersInit;
|
|
415
|
+
/**
|
|
416
|
+
* Service key / JWT token. When set, the SDK automatically sends
|
|
417
|
+
* `Authorization: Bearer <token>` for HTTP requests and WebSocket upgrades.
|
|
418
|
+
*/
|
|
419
|
+
apiKey?: string;
|
|
420
|
+
/**
|
|
421
|
+
* Custom WebSocket factory for non-browser runtimes.
|
|
422
|
+
*/
|
|
423
|
+
websocketFactory?: StarciteWebSocketFactory;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Error payload shape returned by non-2xx API responses.
|
|
427
|
+
*/
|
|
428
|
+
declare const StarciteErrorPayloadSchema: z.ZodObject<{
|
|
429
|
+
error: z.ZodOptional<z.ZodString>;
|
|
430
|
+
message: z.ZodOptional<z.ZodString>;
|
|
431
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
432
|
+
error: z.ZodOptional<z.ZodString>;
|
|
433
|
+
message: z.ZodOptional<z.ZodString>;
|
|
434
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
435
|
+
error: z.ZodOptional<z.ZodString>;
|
|
436
|
+
message: z.ZodOptional<z.ZodString>;
|
|
437
|
+
}, z.ZodUnknown, "strip">>;
|
|
438
|
+
/**
|
|
439
|
+
* Inferred TypeScript type for {@link StarciteErrorPayloadSchema}.
|
|
440
|
+
*/
|
|
441
|
+
type StarciteErrorPayload = z.infer<typeof StarciteErrorPayloadSchema>;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Normalizes a Starcite base URL to the `/v1` API root used by this SDK.
|
|
445
|
+
*/
|
|
446
|
+
declare function normalizeBaseUrl(baseUrl: string): string;
|
|
447
|
+
/**
|
|
448
|
+
* Session-scoped helper for append and tail operations.
|
|
449
|
+
*/
|
|
450
|
+
declare class StarciteSession {
|
|
451
|
+
/** Session identifier. */
|
|
452
|
+
readonly id: string;
|
|
453
|
+
/** Optional session record captured at creation time. */
|
|
454
|
+
readonly record?: SessionRecord;
|
|
455
|
+
private readonly client;
|
|
456
|
+
constructor(client: StarciteClient, id: string, record?: SessionRecord);
|
|
457
|
+
/**
|
|
458
|
+
* Appends a high-level agent event to this session.
|
|
459
|
+
*
|
|
460
|
+
* Automatically prefixes `agent` as `agent:<name>` when needed.
|
|
461
|
+
*/
|
|
462
|
+
append(input: SessionAppendInput): Promise<AppendEventResponse>;
|
|
463
|
+
/**
|
|
464
|
+
* Appends a raw event payload as-is.
|
|
465
|
+
*/
|
|
466
|
+
appendRaw(input: AppendEventRequest): Promise<AppendEventResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Streams transformed session events with SDK convenience fields (`agent`, `text`).
|
|
469
|
+
*/
|
|
470
|
+
tail(options?: SessionTailOptions): AsyncIterable<SessionEvent>;
|
|
471
|
+
/**
|
|
472
|
+
* Streams raw tail events returned by the API.
|
|
473
|
+
*/
|
|
474
|
+
tailRaw(options?: SessionTailOptions): AsyncIterable<TailEvent>;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Starcite API client for HTTP and WebSocket session operations.
|
|
478
|
+
*/
|
|
479
|
+
declare class StarciteClient {
|
|
480
|
+
/** Normalized API base URL ending with `/v1`. */
|
|
481
|
+
readonly baseUrl: string;
|
|
482
|
+
private readonly websocketBaseUrl;
|
|
483
|
+
private readonly fetchFn;
|
|
484
|
+
private readonly headers;
|
|
485
|
+
private readonly websocketFactory;
|
|
486
|
+
/**
|
|
487
|
+
* Creates a new client instance.
|
|
488
|
+
*/
|
|
489
|
+
constructor(options?: StarciteClientOptions);
|
|
490
|
+
/**
|
|
491
|
+
* Returns a session helper bound to an existing session id.
|
|
492
|
+
*/
|
|
493
|
+
session(sessionId: string, record?: SessionRecord): StarciteSession;
|
|
494
|
+
/**
|
|
495
|
+
* Creates a new session and returns a bound `StarciteSession` helper.
|
|
496
|
+
*/
|
|
497
|
+
create(input?: CreateSessionInput): Promise<StarciteSession>;
|
|
498
|
+
/**
|
|
499
|
+
* Creates a new session and returns the raw session record.
|
|
500
|
+
*/
|
|
501
|
+
createSession(input?: CreateSessionInput): Promise<SessionRecord>;
|
|
502
|
+
/**
|
|
503
|
+
* Lists sessions from the archive-backed catalog.
|
|
504
|
+
*/
|
|
505
|
+
listSessions(options?: SessionListOptions): Promise<SessionListPage>;
|
|
506
|
+
/**
|
|
507
|
+
* Appends a raw event payload to a specific session.
|
|
508
|
+
*/
|
|
509
|
+
appendEvent(sessionId: string, input: AppendEventRequest): Promise<AppendEventResponse>;
|
|
510
|
+
/**
|
|
511
|
+
* Opens a WebSocket tail stream and yields raw events.
|
|
512
|
+
*/
|
|
513
|
+
tailRawEvents(sessionId: string, options?: SessionTailOptions): AsyncGenerator<TailEvent>;
|
|
514
|
+
/**
|
|
515
|
+
* Opens a WebSocket tail stream and yields transformed session events.
|
|
516
|
+
*/
|
|
517
|
+
tailEvents(sessionId: string, options?: SessionTailOptions): AsyncGenerator<SessionEvent>;
|
|
518
|
+
private request;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Base error type for SDK-level failures.
|
|
523
|
+
*/
|
|
524
|
+
declare class StarciteError extends Error {
|
|
525
|
+
constructor(message: string);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Thrown when the Starcite API responds with a non-2xx status code.
|
|
529
|
+
*/
|
|
530
|
+
declare class StarciteApiError extends StarciteError {
|
|
531
|
+
/** HTTP status code returned by the API. */
|
|
532
|
+
readonly status: number;
|
|
533
|
+
/** Stable API error code (or synthesized `http_<status>` fallback). */
|
|
534
|
+
readonly code: string;
|
|
535
|
+
/** Parsed API error payload when available. */
|
|
536
|
+
readonly payload: StarciteErrorPayload | null;
|
|
537
|
+
constructor(message: string, status: number, code: string, payload: StarciteErrorPayload | null);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Thrown when the SDK cannot reach Starcite or receives invalid transport payloads.
|
|
541
|
+
*/
|
|
542
|
+
declare class StarciteConnectionError extends StarciteError {
|
|
543
|
+
constructor(message: string);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Creates a new {@link StarciteClient} instance.
|
|
548
|
+
*/
|
|
549
|
+
declare function createStarciteClient(options?: StarciteClientOptions): StarciteClient;
|
|
550
|
+
/**
|
|
551
|
+
* Default singleton client using environment/default configuration.
|
|
552
|
+
*/
|
|
553
|
+
declare const starcite: StarciteClient;
|
|
554
|
+
|
|
555
|
+
export { type AppendEventRequest, type AppendEventResponse, type CreateSessionInput, type SessionAppendInput, type SessionEvent, type SessionListItem, type SessionListOptions, type SessionListPage, type SessionRecord, type SessionTailOptions, StarciteApiError, StarciteClient, type StarciteClientOptions, StarciteConnectionError, StarciteError, type StarciteErrorPayload, StarciteSession, type StarciteWebSocket, type StarciteWebSocketConnectOptions, type StarciteWebSocketFactory, type TailEvent, createStarciteClient, normalizeBaseUrl, starcite };
|