@qoniai/qoni 0.4.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/CHANGELOG.md +232 -0
- package/LICENSE +21 -0
- package/README.md +771 -0
- package/README.zh-CN.md +708 -0
- package/dist/index.cjs +2916 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1362 -0
- package/dist/index.d.ts +1362 -0
- package/dist/index.js +2866 -0
- package/dist/index.js.map +1 -0
- package/docs/open-source-readiness.md +50 -0
- package/package.json +81 -0
- package/skills/qoni-sdk/SKILL.md +324 -0
- package/skills/qoni-sdk/agents/openai.yaml +4 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1362 @@
|
|
|
1
|
+
type Headers = Record<string, string>;
|
|
2
|
+
type Params = Record<string, unknown>;
|
|
3
|
+
declare function buildStringToSign(method: string, pathname: string, headers: Headers, params: Params): string;
|
|
4
|
+
declare function buildSignature(secretKey: string, stringToSign: string): string;
|
|
5
|
+
declare function buildAuthorization(accessKey: string, secretKey: string, stringToSign: string): string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The interaction `type` discriminator — the single field a consumer
|
|
9
|
+
* switches on to pick a card / typed handle.
|
|
10
|
+
*/
|
|
11
|
+
declare const InteractionTypes: {
|
|
12
|
+
readonly SiteLogin: "site_login";
|
|
13
|
+
readonly Clarification: "clarification";
|
|
14
|
+
readonly Confirmation: "confirmation";
|
|
15
|
+
readonly TakeControl: "take_control";
|
|
16
|
+
readonly Wait: "wait";
|
|
17
|
+
};
|
|
18
|
+
type InteractionType = (typeof InteractionTypes)[keyof typeof InteractionTypes];
|
|
19
|
+
/**
|
|
20
|
+
* Interaction lifecycle status (backend-authoritative):
|
|
21
|
+
* pending → active → resolved | expired | canceled.
|
|
22
|
+
*/
|
|
23
|
+
declare const InteractionStatuses: {
|
|
24
|
+
readonly Pending: "pending";
|
|
25
|
+
readonly Active: "active";
|
|
26
|
+
readonly Resolved: "resolved";
|
|
27
|
+
readonly Expired: "expired";
|
|
28
|
+
readonly Canceled: "canceled";
|
|
29
|
+
};
|
|
30
|
+
type InteractionStatus = (typeof InteractionStatuses)[keyof typeof InteractionStatuses];
|
|
31
|
+
/**
|
|
32
|
+
* Action-contract kinds — what a consumer can do to an interaction.
|
|
33
|
+
* Each maps to a typed method on InteractionHandle.
|
|
34
|
+
*/
|
|
35
|
+
declare const ActionKinds: {
|
|
36
|
+
readonly answer: "answer";
|
|
37
|
+
readonly skip: "skip";
|
|
38
|
+
readonly confirm: "confirm";
|
|
39
|
+
readonly reject: "reject";
|
|
40
|
+
readonly openLogin: "open_login";
|
|
41
|
+
readonly confirmSignedIn: "confirm_signed_in";
|
|
42
|
+
readonly connectControl: "connect_control";
|
|
43
|
+
readonly refreshControl: "refresh_control";
|
|
44
|
+
readonly releaseControl: "release_control";
|
|
45
|
+
readonly retry: "retry";
|
|
46
|
+
readonly switchProfile: "switch_profile";
|
|
47
|
+
};
|
|
48
|
+
type ActionKind = (typeof ActionKinds)[keyof typeof ActionKinds];
|
|
49
|
+
|
|
50
|
+
type JsonObject = Record<string, unknown>;
|
|
51
|
+
type DelegationMode = "silent" | "interactive";
|
|
52
|
+
type QoniService = "qoni" | "genauth" | "gumem" | "webagent";
|
|
53
|
+
type QoniHttpMethod = "GET" | "POST" | "PATCH" | "DELETE";
|
|
54
|
+
interface QoniOptions {
|
|
55
|
+
accessKey?: string;
|
|
56
|
+
secretKey?: string;
|
|
57
|
+
host?: string;
|
|
58
|
+
/** Overrides the GenAuth URL returned by runtime-config. Prefer host for normal discovery. */
|
|
59
|
+
genauthHost?: string;
|
|
60
|
+
/** Overrides the GUMem URL returned by runtime-config. Prefer host for normal discovery. */
|
|
61
|
+
gumemHost?: string;
|
|
62
|
+
/** Overrides the WebAgent URL returned by runtime-config. Prefer host for normal discovery. */
|
|
63
|
+
webAgentHost?: string;
|
|
64
|
+
/** @deprecated Use accessKey. */
|
|
65
|
+
accessKeyId?: string;
|
|
66
|
+
/** @deprecated Use secretKey. */
|
|
67
|
+
accessKeySecret?: string;
|
|
68
|
+
/** @deprecated Prefer host runtime discovery for normal Qoni Console gateway access. */
|
|
69
|
+
qoniBaseUrl?: string;
|
|
70
|
+
/** @deprecated Use host for normal Qoni Gateway access. */
|
|
71
|
+
genauthBaseUrl?: string;
|
|
72
|
+
/** @deprecated Use host for normal Qoni Gateway access. */
|
|
73
|
+
gumemBaseUrl?: string;
|
|
74
|
+
/** @deprecated Use host for normal Qoni Gateway access. */
|
|
75
|
+
webAgentBaseUrl?: string;
|
|
76
|
+
fetch?: typeof fetch;
|
|
77
|
+
timeoutMs?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Max automatic reconnect attempts for SSE streams (`events()`) after a
|
|
80
|
+
* dropped connection. Each reconnect resumes from the last seen event id
|
|
81
|
+
* via the `last-event-id` header. Defaults to 5; set 0 to disable.
|
|
82
|
+
*/
|
|
83
|
+
sseMaxRetries?: number;
|
|
84
|
+
}
|
|
85
|
+
interface QoniRuntimeConfig {
|
|
86
|
+
/** Current control-plane wire field. Keep until the server contract migrates. */
|
|
87
|
+
eakBaseUrl?: string;
|
|
88
|
+
genauthBaseUrl?: string;
|
|
89
|
+
gumemBaseUrl?: string;
|
|
90
|
+
webAgentBaseUrl?: string;
|
|
91
|
+
services?: {
|
|
92
|
+
eak?: string | {
|
|
93
|
+
baseUrl?: string;
|
|
94
|
+
url?: string;
|
|
95
|
+
host?: string;
|
|
96
|
+
};
|
|
97
|
+
genauth?: string | {
|
|
98
|
+
baseUrl?: string;
|
|
99
|
+
url?: string;
|
|
100
|
+
host?: string;
|
|
101
|
+
};
|
|
102
|
+
gumem?: string | {
|
|
103
|
+
baseUrl?: string;
|
|
104
|
+
url?: string;
|
|
105
|
+
host?: string;
|
|
106
|
+
};
|
|
107
|
+
webAgent?: string | {
|
|
108
|
+
baseUrl?: string;
|
|
109
|
+
url?: string;
|
|
110
|
+
host?: string;
|
|
111
|
+
};
|
|
112
|
+
webagent?: string | {
|
|
113
|
+
baseUrl?: string;
|
|
114
|
+
url?: string;
|
|
115
|
+
host?: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface QoniMeta {
|
|
120
|
+
requestId?: string;
|
|
121
|
+
traceId?: string;
|
|
122
|
+
auditId?: string;
|
|
123
|
+
service?: QoniService;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
interface QoniResponse<T = unknown> {
|
|
127
|
+
data: T;
|
|
128
|
+
meta: QoniMeta;
|
|
129
|
+
}
|
|
130
|
+
interface UserRef {
|
|
131
|
+
id: string;
|
|
132
|
+
subject?: string;
|
|
133
|
+
name?: string;
|
|
134
|
+
email?: string;
|
|
135
|
+
avatarUrl?: string;
|
|
136
|
+
[key: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
interface DelegateTokenBaseInput {
|
|
139
|
+
/** Audit label for this delegation. Defaults to "sdk". */
|
|
140
|
+
agent?: string;
|
|
141
|
+
/** Fine-grained scopes. May be combined with `products`. */
|
|
142
|
+
scopes?: readonly string[];
|
|
143
|
+
/** Per-product authorization sugar — expands to the product's scope set. */
|
|
144
|
+
products?: readonly QoniProductName[];
|
|
145
|
+
expiresIn?: string | number;
|
|
146
|
+
idempotencyKey?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Product names accepted by `delegateToken({ products })`. Mirrors
|
|
150
|
+
* `QoniProduct` in scopes.ts (duplicated to keep this module import-free).
|
|
151
|
+
*/
|
|
152
|
+
type QoniProductName = "doAnything" | "webSearch" | "deepResearch" | "track";
|
|
153
|
+
type DelegateTokenSilentInput = DelegateTokenBaseInput & {
|
|
154
|
+
mode?: "silent";
|
|
155
|
+
redirectUri?: string;
|
|
156
|
+
state?: string;
|
|
157
|
+
} & ({
|
|
158
|
+
user: UserRef;
|
|
159
|
+
/** @deprecated Use user. */
|
|
160
|
+
userId?: string;
|
|
161
|
+
} | {
|
|
162
|
+
user?: UserRef;
|
|
163
|
+
/** @deprecated Use user. */
|
|
164
|
+
userId: string;
|
|
165
|
+
});
|
|
166
|
+
interface DelegateTokenInteractiveInput extends DelegateTokenBaseInput {
|
|
167
|
+
mode: "interactive";
|
|
168
|
+
redirectUri: string;
|
|
169
|
+
state: string;
|
|
170
|
+
user?: UserRef;
|
|
171
|
+
/** @deprecated Use user. */
|
|
172
|
+
userId?: string;
|
|
173
|
+
}
|
|
174
|
+
type DelegateTokenInput = DelegateTokenSilentInput | DelegateTokenInteractiveInput;
|
|
175
|
+
/** @deprecated Use DelegateTokenInput. */
|
|
176
|
+
type DelegateAgentInput = DelegateTokenInput;
|
|
177
|
+
interface CompleteDelegateTokenInput {
|
|
178
|
+
grantId: string;
|
|
179
|
+
code: string;
|
|
180
|
+
state: string;
|
|
181
|
+
}
|
|
182
|
+
/** @deprecated Use CompleteDelegateTokenInput. */
|
|
183
|
+
type CompleteDelegateAgentInput = CompleteDelegateTokenInput;
|
|
184
|
+
interface DelegateTokenResponse {
|
|
185
|
+
mode: DelegationMode;
|
|
186
|
+
tokenType: "Bearer";
|
|
187
|
+
token: string;
|
|
188
|
+
/** @deprecated Use token. */
|
|
189
|
+
delegateAgentToken: string;
|
|
190
|
+
/** @deprecated Use token. */
|
|
191
|
+
delegationToken?: string;
|
|
192
|
+
expiresIn: number;
|
|
193
|
+
grantId: string;
|
|
194
|
+
auditId: string;
|
|
195
|
+
grantedScopes?: string[];
|
|
196
|
+
}
|
|
197
|
+
type DelegateTokenSilentResponse = DelegateTokenResponse & {
|
|
198
|
+
mode: "silent";
|
|
199
|
+
};
|
|
200
|
+
/** @deprecated Use DelegateTokenResponse. */
|
|
201
|
+
type DelegateAgentTokenResponse = DelegateTokenResponse;
|
|
202
|
+
/** @deprecated Use DelegateTokenResponse. */
|
|
203
|
+
type DelegationTokenResponse = DelegateTokenResponse;
|
|
204
|
+
interface InteractiveDelegationResponse {
|
|
205
|
+
mode: "interactive";
|
|
206
|
+
authorizationUrl: string;
|
|
207
|
+
grantId: string;
|
|
208
|
+
grantState: string;
|
|
209
|
+
state: string;
|
|
210
|
+
requestedScopes?: string[];
|
|
211
|
+
}
|
|
212
|
+
type DelegateAgentResponse = DelegateTokenResponse | InteractiveDelegationResponse;
|
|
213
|
+
type DelegateTokenResult = DelegateAgentResponse;
|
|
214
|
+
interface TokenInput {
|
|
215
|
+
/** Delegation/runtime token to authorize the call with. */
|
|
216
|
+
token?: string;
|
|
217
|
+
}
|
|
218
|
+
type RuntimeTokenInput = TokenInput;
|
|
219
|
+
interface RawRequestInput extends TokenInput {
|
|
220
|
+
method: QoniHttpMethod;
|
|
221
|
+
path: string;
|
|
222
|
+
query?: JsonObject;
|
|
223
|
+
body?: JsonObject;
|
|
224
|
+
headers?: Record<string, string>;
|
|
225
|
+
}
|
|
226
|
+
interface RequestPayload {
|
|
227
|
+
query?: JsonObject;
|
|
228
|
+
body?: JsonObject | BodyInit;
|
|
229
|
+
headers?: Record<string, string>;
|
|
230
|
+
requiredScopes?: readonly string[];
|
|
231
|
+
}
|
|
232
|
+
interface QoniEvent<T = unknown> {
|
|
233
|
+
id?: string;
|
|
234
|
+
event?: string;
|
|
235
|
+
data: T;
|
|
236
|
+
}
|
|
237
|
+
type QoniSSEEvent<T = unknown> = QoniEvent<T>;
|
|
238
|
+
interface QoniTransport {
|
|
239
|
+
qoniJson<T>(method: QoniHttpMethod, path: string, token?: string, payload?: RequestPayload): Promise<QoniResponse<T>>;
|
|
240
|
+
genauthJson<T>(method: QoniHttpMethod, path: string, token?: string, payload?: RequestPayload): Promise<QoniResponse<T>>;
|
|
241
|
+
gumemJson<T>(method: QoniHttpMethod, path: string, token?: string, payload?: RequestPayload): Promise<QoniResponse<T>>;
|
|
242
|
+
gumemSSE<T>(path: string, token?: string, payload?: RequestPayload & {
|
|
243
|
+
lastEventId?: string;
|
|
244
|
+
signal?: AbortSignal;
|
|
245
|
+
}): AsyncIterable<QoniEvent<T>>;
|
|
246
|
+
webAgentJson<T>(method: QoniHttpMethod, path: string, token?: string, payload?: RequestPayload): Promise<QoniResponse<T>>;
|
|
247
|
+
/** Binary GET — used for artifact content downloads. */
|
|
248
|
+
webAgentBytes(path: string, token?: string, payload?: RequestPayload): Promise<{
|
|
249
|
+
bytes: Uint8Array;
|
|
250
|
+
mime: string;
|
|
251
|
+
}>;
|
|
252
|
+
webAgentSSE<T>(path: string, token?: string, payload?: RequestPayload & {
|
|
253
|
+
lastEventId?: string;
|
|
254
|
+
signal?: AbortSignal;
|
|
255
|
+
onReconnect?: (info: {
|
|
256
|
+
attempt: number;
|
|
257
|
+
lastEventId?: string;
|
|
258
|
+
error: unknown;
|
|
259
|
+
}) => void;
|
|
260
|
+
}): AsyncIterable<QoniEvent<T>>;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Curated interaction surface (axis B of the interaction model, see
|
|
265
|
+
* webagentbackend/docs/qoni-interaction-model.md §2.3). A single wire event
|
|
266
|
+
* `run.interaction` carries the complete, typed object across its whole
|
|
267
|
+
* lifecycle (created / updated / resolved), discriminated by `type` and driven
|
|
268
|
+
* by a backend-authoritative `status`. This replaces the old `run.input_request`
|
|
269
|
+
* + `run.take_control_*` family — consumers no longer rebuild a state machine
|
|
270
|
+
* from an event sequence.
|
|
271
|
+
*
|
|
272
|
+
* Wire is snake_case; this layer is camelCase. The `actions[]` contract carries
|
|
273
|
+
* each action's endpoint, so the typed methods on {@link InteractionHandle}
|
|
274
|
+
* post to the right route without the consumer hard-coding any path — and a
|
|
275
|
+
* button/method only exists when the backend declared the action (structurally
|
|
276
|
+
* closing off "dead recovery affordances").
|
|
277
|
+
*/
|
|
278
|
+
/** A declared action a consumer can take on an interaction. */
|
|
279
|
+
interface Action {
|
|
280
|
+
/** What this action does — maps to a typed method on {@link InteractionHandle}. */
|
|
281
|
+
kind: ActionKind;
|
|
282
|
+
/** Human-readable button label. */
|
|
283
|
+
label: string;
|
|
284
|
+
/** HTTP method to invoke the endpoint with (defaults to POST on the wire). */
|
|
285
|
+
method: string;
|
|
286
|
+
/** Endpoint to invoke (run-relative path); the consumer never hard-codes it. */
|
|
287
|
+
endpoint: string;
|
|
288
|
+
/** JSON schema for the action's input body, when the action needs one. */
|
|
289
|
+
inputSchema?: JsonObject | null;
|
|
290
|
+
}
|
|
291
|
+
/** Optional evidence image attached to an interaction. */
|
|
292
|
+
interface InteractionEvidence {
|
|
293
|
+
artifactId: string;
|
|
294
|
+
}
|
|
295
|
+
/** A site the agent needs the user to sign in to (`site_login`). */
|
|
296
|
+
interface InteractionSite {
|
|
297
|
+
siteId: string;
|
|
298
|
+
displayName: string;
|
|
299
|
+
loginUrl: string;
|
|
300
|
+
}
|
|
301
|
+
interface SiteLoginPayload {
|
|
302
|
+
sites: InteractionSite[];
|
|
303
|
+
/** Set when the login is for a Track monitor (monitor.needs_login reuse). */
|
|
304
|
+
monitorId?: string;
|
|
305
|
+
}
|
|
306
|
+
interface ClarificationPayload {
|
|
307
|
+
question: string;
|
|
308
|
+
/** Hint for how the answer should be collected (e.g. "text", "choice"). */
|
|
309
|
+
inputType?: string;
|
|
310
|
+
}
|
|
311
|
+
interface ConfirmationPayload {
|
|
312
|
+
summary: string;
|
|
313
|
+
}
|
|
314
|
+
interface TakeControlPayload {
|
|
315
|
+
liveUrl: string;
|
|
316
|
+
surface?: string;
|
|
317
|
+
reason?: string;
|
|
318
|
+
}
|
|
319
|
+
type WaitKind = "rate_limit" | "external" | "sleep";
|
|
320
|
+
interface WaitPayload {
|
|
321
|
+
waitKind: WaitKind;
|
|
322
|
+
/** ISO 8601 — when the wait is expected to end. */
|
|
323
|
+
until?: string;
|
|
324
|
+
retryable?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/** Maps each interaction `type` to its narrowed payload shape. */
|
|
327
|
+
interface InteractionPayloadByType {
|
|
328
|
+
site_login: SiteLoginPayload;
|
|
329
|
+
clarification: ClarificationPayload;
|
|
330
|
+
confirmation: ConfirmationPayload;
|
|
331
|
+
take_control: TakeControlPayload;
|
|
332
|
+
wait: WaitPayload;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A typed interaction object. Generic over `type` so the `payload` narrows to
|
|
336
|
+
* the matching shape; the bare `Interaction` (T = InteractionType) is the union
|
|
337
|
+
* a consumer switches on.
|
|
338
|
+
*/
|
|
339
|
+
interface Interaction<T extends InteractionType = InteractionType> {
|
|
340
|
+
/** Stable identity across the interaction's lifecycle. */
|
|
341
|
+
id: string;
|
|
342
|
+
/** The discriminator — the single field a consumer switches on. */
|
|
343
|
+
type: T;
|
|
344
|
+
/** Backend-authoritative lifecycle status. */
|
|
345
|
+
status: InteractionStatus;
|
|
346
|
+
createdAt: string;
|
|
347
|
+
resolvedAt?: string | null;
|
|
348
|
+
expiresAt?: string | null;
|
|
349
|
+
/** Human-readable title (e.g. "Agent needs you to sign in"). */
|
|
350
|
+
title: string;
|
|
351
|
+
/** Detail / question text. */
|
|
352
|
+
prompt?: string | null;
|
|
353
|
+
/** Optional evidence image. */
|
|
354
|
+
evidence?: InteractionEvidence | null;
|
|
355
|
+
/** Declared actions — drives the typed methods + UI buttons. */
|
|
356
|
+
actions: Action[];
|
|
357
|
+
/** Type-specific fields. */
|
|
358
|
+
payload: InteractionPayloadByType[T];
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Posts an interaction action to its declared endpoint. The product namespace
|
|
362
|
+
* supplies this (token + run addressing already bound); the handle below uses
|
|
363
|
+
* it to invoke `action.endpoint` without the consumer touching HTTP.
|
|
364
|
+
*/
|
|
365
|
+
type InteractionActionPoster = (action: Action, body: JsonObject | undefined) => Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Typed wrapper over an {@link Interaction} that exposes one method per
|
|
368
|
+
* action kind. Each method finds the matching declared action and posts to its
|
|
369
|
+
* endpoint; calling a method whose action the backend did NOT declare throws
|
|
370
|
+
* (so "dead recovery affordances" are impossible — if you can call it, the
|
|
371
|
+
* backend offered it).
|
|
372
|
+
*/
|
|
373
|
+
declare class InteractionHandle<T extends InteractionType = InteractionType> {
|
|
374
|
+
private readonly post;
|
|
375
|
+
readonly interaction: Interaction<T>;
|
|
376
|
+
constructor(interaction: Interaction<T>, post: InteractionActionPoster);
|
|
377
|
+
get id(): string;
|
|
378
|
+
get type(): T;
|
|
379
|
+
get status(): InteractionStatus;
|
|
380
|
+
get actions(): Action[];
|
|
381
|
+
/** Whether the backend declared an action of this kind on the interaction. */
|
|
382
|
+
can(kind: ActionKind): boolean;
|
|
383
|
+
/** Answer a clarification ask. */
|
|
384
|
+
answer(text: string): Promise<void>;
|
|
385
|
+
/** Skip / dismiss the interaction (proceed without acting on it). */
|
|
386
|
+
skip(): Promise<void>;
|
|
387
|
+
/** Confirm a pending confirmation (approve the plan / destructive op). */
|
|
388
|
+
confirm(): Promise<void>;
|
|
389
|
+
/** Reject a pending confirmation. */
|
|
390
|
+
reject(): Promise<void>;
|
|
391
|
+
/** Open the login surface for a site_login interaction. */
|
|
392
|
+
openLogin(): Promise<void>;
|
|
393
|
+
/** Tell the agent the user has finished signing in. */
|
|
394
|
+
confirmSignedIn(): Promise<void>;
|
|
395
|
+
/** Connect to the live browser for a take_control interaction. */
|
|
396
|
+
connectControl(): Promise<void>;
|
|
397
|
+
/** Refresh the live control surface / live url. */
|
|
398
|
+
refreshControl(): Promise<void>;
|
|
399
|
+
/** Hand control back to the agent. */
|
|
400
|
+
releaseControl(): Promise<void>;
|
|
401
|
+
/** Retry a wait interaction now. */
|
|
402
|
+
retry(): Promise<void>;
|
|
403
|
+
/** Switch the profile a wait/login interaction is bound to. */
|
|
404
|
+
switchProfile(): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Invoke an action by kind with an optional body. `async` so a missing-action
|
|
407
|
+
* error surfaces as a rejected promise (not a synchronous throw), keeping the
|
|
408
|
+
* method contract uniformly promise-based.
|
|
409
|
+
*/
|
|
410
|
+
private invoke;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Semantic run events — the public event surface for doAnything / webSearch /
|
|
415
|
+
* deepResearch run handles and Track monitor handles. Wire envelopes
|
|
416
|
+
* (`{ type, task_id, session_id, occurred_at, data }`, snake_case payloads,
|
|
417
|
+
* data-URI screenshots) are normalized here; the original wire event stays
|
|
418
|
+
* reachable on `event.raw`.
|
|
419
|
+
*/
|
|
420
|
+
/**
|
|
421
|
+
* `QoniEventTypes` — the complete set of `event.type` values, as named
|
|
422
|
+
* constants. This is THE thing a developer matches on. Import it for
|
|
423
|
+
* autocomplete + typo-safety instead of hand-typing strings:
|
|
424
|
+
*
|
|
425
|
+
* import { QoniEventTypes } from "@qoniai/qoni";
|
|
426
|
+
* for await (const event of run.events()) {
|
|
427
|
+
* switch (event.type) {
|
|
428
|
+
* case QoniEventTypes.Results: …
|
|
429
|
+
* case QoniEventTypes.Done: …
|
|
430
|
+
* }
|
|
431
|
+
* }
|
|
432
|
+
*
|
|
433
|
+
* The raw wire types (supervisor orchestration, sub-agent execution, protocol
|
|
434
|
+
* markers) are internal: all that churn folds into `QoniEventTypes.Progress`,
|
|
435
|
+
* and only the handful a developer reacts to get a distinct value. The exact
|
|
436
|
+
* wire string is on `event.raw.event` if ever needed.
|
|
437
|
+
*/
|
|
438
|
+
declare const QoniEventTypes: {
|
|
439
|
+
/** The agent is working — folds ALL internal steps (actions, plan/subtask, sections, telemetry, take-control, …); `event.data` is a best-effort human-readable line (string). */
|
|
440
|
+
readonly Progress: "progress";
|
|
441
|
+
/** The agent produced a user-facing chat message. */
|
|
442
|
+
readonly Message: "message";
|
|
443
|
+
/** HITL — a typed interaction needs the user (login / clarification / confirmation / take-control / wait); `event.data` is the full {@link Interaction} object. Act on it via the action methods (`run.interactionHandle(event.data).answer(…)` etc). */
|
|
444
|
+
readonly Interaction: "interaction";
|
|
445
|
+
/** A live screenshot frame (opt in with `capture: { screenshots: true }`); image on `event.image`. */
|
|
446
|
+
readonly Screenshot: "screenshot";
|
|
447
|
+
/** Terminal — the run finished; outcome + output in `event.data` (cost is on the `RunResult`). */
|
|
448
|
+
readonly Done: "done";
|
|
449
|
+
/** Web Search results are ready; `event.data` is the count (the list is in `done.output`). */
|
|
450
|
+
readonly ResultsReady: "resultsReady";
|
|
451
|
+
/** Deep Research coarse phase changed (brief → gather → synthesize …). */
|
|
452
|
+
readonly Phase: "phase";
|
|
453
|
+
/** A Deep Research outline section was completed (stream sections as they finish). */
|
|
454
|
+
readonly SectionReady: "sectionReady";
|
|
455
|
+
/** A Track monitor was created (e.g. Do Anything handed a recurring request to Track). */
|
|
456
|
+
readonly MonitorCreated: "monitorCreated";
|
|
457
|
+
/** A monitor detected a change worth acting on (the Track signal you react to). */
|
|
458
|
+
readonly Triggered: "triggered";
|
|
459
|
+
/** A monitor's scheduled check finished (`event.data` is whether it found a change). */
|
|
460
|
+
readonly CheckCompleted: "checkCompleted";
|
|
461
|
+
};
|
|
462
|
+
/** Every `event.type` value. Derived from {@link QoniEventTypes} — the single source. */
|
|
463
|
+
type QoniEventType = (typeof QoniEventTypes)[keyof typeof QoniEventTypes];
|
|
464
|
+
/** A decoded screenshot frame. `bytes` are the raw image bytes. */
|
|
465
|
+
interface RunImage {
|
|
466
|
+
bytes: Uint8Array;
|
|
467
|
+
mime: string;
|
|
468
|
+
pageUrl?: string;
|
|
469
|
+
step?: number;
|
|
470
|
+
}
|
|
471
|
+
interface RunEventBase {
|
|
472
|
+
/** The run this event belongs to. */
|
|
473
|
+
runId: string;
|
|
474
|
+
/** ISO 8601 timestamp of when the event occurred. */
|
|
475
|
+
at: string;
|
|
476
|
+
/** The original wire event (escape hatch — shape may evolve with the API). */
|
|
477
|
+
raw: QoniEvent<unknown>;
|
|
478
|
+
}
|
|
479
|
+
/** `message` — an assistant/user chat message. */
|
|
480
|
+
interface RunMessageData {
|
|
481
|
+
text: string;
|
|
482
|
+
role: string;
|
|
483
|
+
}
|
|
484
|
+
/** `screenshot` — page metadata; the decoded image is on `event.image`. */
|
|
485
|
+
interface RunScreenshotData {
|
|
486
|
+
pageUrl?: string;
|
|
487
|
+
step?: number;
|
|
488
|
+
}
|
|
489
|
+
/** `done` — terminal outcome + final output. (Total cost is on the `RunResult`.) */
|
|
490
|
+
interface RunDoneData {
|
|
491
|
+
output?: unknown;
|
|
492
|
+
succeeded: boolean | null;
|
|
493
|
+
terminalReason: string;
|
|
494
|
+
}
|
|
495
|
+
type RunEvent = (RunEventBase & {
|
|
496
|
+
type: "progress";
|
|
497
|
+
data: string;
|
|
498
|
+
isTerminal: false;
|
|
499
|
+
}) | (RunEventBase & {
|
|
500
|
+
type: "message";
|
|
501
|
+
data: RunMessageData;
|
|
502
|
+
isTerminal: false;
|
|
503
|
+
}) | (RunEventBase & {
|
|
504
|
+
type: "interaction";
|
|
505
|
+
data: Interaction;
|
|
506
|
+
isTerminal: false;
|
|
507
|
+
}) | (RunEventBase & {
|
|
508
|
+
type: "screenshot";
|
|
509
|
+
data: RunScreenshotData;
|
|
510
|
+
image: RunImage;
|
|
511
|
+
isTerminal: false;
|
|
512
|
+
}) | (RunEventBase & {
|
|
513
|
+
type: "done";
|
|
514
|
+
data: RunDoneData;
|
|
515
|
+
isTerminal: true;
|
|
516
|
+
}) | (RunEventBase & {
|
|
517
|
+
type: "resultsReady";
|
|
518
|
+
data: number;
|
|
519
|
+
isTerminal: false;
|
|
520
|
+
}) | (RunEventBase & {
|
|
521
|
+
type: "phase";
|
|
522
|
+
data: string;
|
|
523
|
+
isTerminal: false;
|
|
524
|
+
}) | (RunEventBase & {
|
|
525
|
+
type: "sectionReady";
|
|
526
|
+
data: string;
|
|
527
|
+
isTerminal: false;
|
|
528
|
+
}) | (RunEventBase & {
|
|
529
|
+
type: "monitorCreated";
|
|
530
|
+
data: string;
|
|
531
|
+
isTerminal: false;
|
|
532
|
+
}) | (RunEventBase & {
|
|
533
|
+
type: "triggered";
|
|
534
|
+
data: string;
|
|
535
|
+
isTerminal: false;
|
|
536
|
+
}) | (RunEventBase & {
|
|
537
|
+
type: "checkCompleted";
|
|
538
|
+
data: boolean;
|
|
539
|
+
isTerminal: false;
|
|
540
|
+
});
|
|
541
|
+
/** Events any product run can emit. */
|
|
542
|
+
type CoreRunEvent = Extract<RunEvent, {
|
|
543
|
+
type: "progress" | "message" | "interaction" | "screenshot" | "done";
|
|
544
|
+
}>;
|
|
545
|
+
/** Do Anything — core events only. */
|
|
546
|
+
type DoAnythingEvent = CoreRunEvent;
|
|
547
|
+
/** Web Search — core + `resultsReady`. */
|
|
548
|
+
type WebSearchEvent = CoreRunEvent | Extract<RunEvent, {
|
|
549
|
+
type: "resultsReady";
|
|
550
|
+
}>;
|
|
551
|
+
/** Deep Research — core + `phase` / `sectionReady`. */
|
|
552
|
+
type DeepResearchEvent = CoreRunEvent | Extract<RunEvent, {
|
|
553
|
+
type: "phase" | "sectionReady";
|
|
554
|
+
}>;
|
|
555
|
+
/** Track monitor — core + `monitorCreated` / `triggered` / `checkCompleted`. */
|
|
556
|
+
type MonitorEvent = CoreRunEvent | Extract<RunEvent, {
|
|
557
|
+
type: "monitorCreated" | "triggered" | "checkCompleted";
|
|
558
|
+
}>;
|
|
559
|
+
|
|
560
|
+
/** Opaque reference to a backend browser/context session a run executed in. */
|
|
561
|
+
interface SessionRef {
|
|
562
|
+
sessionId: string;
|
|
563
|
+
}
|
|
564
|
+
/** Semantic capture switch — controls which media events the stream delivers. */
|
|
565
|
+
interface CaptureOptions {
|
|
566
|
+
screenshots?: boolean;
|
|
567
|
+
videoFrames?: boolean;
|
|
568
|
+
}
|
|
569
|
+
interface RunEventsOptions {
|
|
570
|
+
lastEventId?: string;
|
|
571
|
+
signal?: AbortSignal;
|
|
572
|
+
/**
|
|
573
|
+
* Receives every original SSE frame before semantic normalization/filtering.
|
|
574
|
+
* Use this for audit logs and observability evidence that must retain internal
|
|
575
|
+
* Agent/tool lifecycle payloads. Some frames do not become semantic events.
|
|
576
|
+
*/
|
|
577
|
+
onWireEvent?: (event: QoniEvent<unknown>) => void | Promise<void>;
|
|
578
|
+
/** Called whenever the SDK reconnects a dropped SSE stream. */
|
|
579
|
+
onReconnect?: (info: RunReconnectInfo) => void;
|
|
580
|
+
}
|
|
581
|
+
interface RunReconnectInfo {
|
|
582
|
+
attempt: number;
|
|
583
|
+
lastEventId?: string;
|
|
584
|
+
error: unknown;
|
|
585
|
+
}
|
|
586
|
+
/** A refreshed snapshot of a run's state, as returned by `run.status()`. */
|
|
587
|
+
interface RunStatus {
|
|
588
|
+
id: string;
|
|
589
|
+
/** pending | running | awaiting_input | succeeded | failed | canceled */
|
|
590
|
+
status: string;
|
|
591
|
+
sessionId?: string;
|
|
592
|
+
output?: unknown;
|
|
593
|
+
/** Full wire run envelope (escape hatch — shape may evolve with the API). */
|
|
594
|
+
raw: JsonObject;
|
|
595
|
+
}
|
|
596
|
+
/** A deliverable produced by a run. Content is fetched lazily via `content()`. */
|
|
597
|
+
interface Artifact {
|
|
598
|
+
id: string;
|
|
599
|
+
name?: string;
|
|
600
|
+
mime?: string;
|
|
601
|
+
sizeBytes?: number;
|
|
602
|
+
createdAt?: string;
|
|
603
|
+
content(): Promise<Uint8Array>;
|
|
604
|
+
}
|
|
605
|
+
/** Settled outcome of `run.wait()`. */
|
|
606
|
+
interface RunResult {
|
|
607
|
+
runId: string;
|
|
608
|
+
status: "succeeded" | "failed" | "canceled";
|
|
609
|
+
/** Final answer / output payload (shape is task-specific). */
|
|
610
|
+
output?: unknown;
|
|
611
|
+
/** Deliverables (deepResearch reports etc). Empty array for products without artifacts. */
|
|
612
|
+
artifacts: Artifact[];
|
|
613
|
+
terminalReason?: string;
|
|
614
|
+
isTaskSuccessful?: boolean;
|
|
615
|
+
/** Full wire run envelope (escape hatch — shape may evolve with the API). */
|
|
616
|
+
raw: JsonObject;
|
|
617
|
+
}
|
|
618
|
+
interface RunWaitOptions {
|
|
619
|
+
/** Client-side wall-clock cap. On elapse, `wait` throws `QoniTimeoutError`; the run keeps executing server-side. */
|
|
620
|
+
timeoutMs?: number;
|
|
621
|
+
signal?: AbortSignal;
|
|
622
|
+
onEvent?: (event: RunEvent) => void | Promise<void>;
|
|
623
|
+
/** Every original SSE frame, including frames filtered from the semantic stream. */
|
|
624
|
+
onWireEvent?: (event: QoniEvent<unknown>) => void | Promise<void>;
|
|
625
|
+
/** Reconnect telemetry for the underlying resumable SSE stream. */
|
|
626
|
+
onReconnect?: (info: RunReconnectInfo) => void;
|
|
627
|
+
/**
|
|
628
|
+
* Fires on `event.type === "interaction"` (HITL). The handle exposes typed
|
|
629
|
+
* action methods (`interaction.answer(…)` / `confirmSignedIn()` /
|
|
630
|
+
* `releaseControl()` / …) that post to the action's declared endpoint.
|
|
631
|
+
*/
|
|
632
|
+
onInteraction?: (interaction: InteractionHandle, event: RunEvent) => void | Promise<void>;
|
|
633
|
+
onScreenshot?: (image: RunImage, index: number) => void | Promise<void>;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Product-specific wire operations a `RunHandle` is built on. Each product
|
|
637
|
+
* namespace constructs one of these from its `api.*` escape-hatch methods
|
|
638
|
+
* with the token + run addressing already bound.
|
|
639
|
+
*/
|
|
640
|
+
interface RunWireOps {
|
|
641
|
+
getDetail(): Promise<JsonObject>;
|
|
642
|
+
streamEvents(opts: RunEventsOptions): AsyncIterable<QoniEvent<unknown>>;
|
|
643
|
+
/**
|
|
644
|
+
* Invoke an interaction action by posting to its declared endpoint. The
|
|
645
|
+
* Interaction model's `actions[]` carry the endpoint + method, so the SDK
|
|
646
|
+
* never hard-codes a HITL route — it forwards what the backend declared.
|
|
647
|
+
*/
|
|
648
|
+
postAction(action: Action, body: JsonObject | undefined): Promise<void>;
|
|
649
|
+
cancel(reason?: string): Promise<JsonObject>;
|
|
650
|
+
/** Products without artifacts leave this undefined → `result.artifacts` is []. */
|
|
651
|
+
listArtifacts?(): Promise<Artifact[]>;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Handle to a single run. Generic over the product's event set (分型): a
|
|
655
|
+
* `RunHandle<DeepResearchEvent>` only ever yields Deep Research events, so
|
|
656
|
+
* `switch (event.type)` autocompletes just that product's events and a
|
|
657
|
+
* wrong-product case is a compile error. The runtime is identical across
|
|
658
|
+
* products; the generic only narrows the public type surface.
|
|
659
|
+
*/
|
|
660
|
+
declare class RunHandle<E extends RunEvent = RunEvent> {
|
|
661
|
+
#private;
|
|
662
|
+
private readonly ops;
|
|
663
|
+
readonly id: string;
|
|
664
|
+
/** Pass back to `run({ session })` to reuse the same backend session. */
|
|
665
|
+
sessionRef?: SessionRef;
|
|
666
|
+
private readonly capture;
|
|
667
|
+
constructor(ops: RunWireOps, init: {
|
|
668
|
+
id: string;
|
|
669
|
+
sessionRef?: SessionRef;
|
|
670
|
+
capture?: CaptureOptions;
|
|
671
|
+
});
|
|
672
|
+
/** Refresh and return the run's current state. */
|
|
673
|
+
status(): Promise<RunStatus>;
|
|
674
|
+
/**
|
|
675
|
+
* Stream semantic events. Ends automatically at the run's terminal event.
|
|
676
|
+
* Reconnects with `Last-Event-ID` catch-up are handled internally.
|
|
677
|
+
*/
|
|
678
|
+
events(opts?: RunEventsOptions): AsyncIterable<E>;
|
|
679
|
+
/** Drive the run to a terminal state and return the settled result. */
|
|
680
|
+
wait(opts?: RunWaitOptions): Promise<RunResult>;
|
|
681
|
+
/**
|
|
682
|
+
* Wrap an {@link Interaction} (from `event.data` of an `interaction` event)
|
|
683
|
+
* in a typed {@link InteractionHandle} bound to this run. The handle's action
|
|
684
|
+
* methods (`answer` / `confirmSignedIn` / `releaseControl` / …) post to the
|
|
685
|
+
* endpoint the backend declared for that action.
|
|
686
|
+
*/
|
|
687
|
+
interactionHandle(interaction: Interaction): InteractionHandle;
|
|
688
|
+
/**
|
|
689
|
+
* Cancel the run. Idempotent: cancelling an already-terminal run returns
|
|
690
|
+
* its terminal state instead of throwing.
|
|
691
|
+
*/
|
|
692
|
+
cancel(reason?: string): Promise<RunStatus>;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* A structured snapshot of the agent's state at a single step — not just an
|
|
697
|
+
* image. The screenshot is one field (an inline reference/data), alongside the
|
|
698
|
+
* metadata and extracted page state captured at that moment.
|
|
699
|
+
*/
|
|
700
|
+
interface DoAnythingSnapshot {
|
|
701
|
+
/** When the snapshot was captured (ISO 8601). */
|
|
702
|
+
capturedAt?: string;
|
|
703
|
+
/** Which step of the run this snapshot belongs to. */
|
|
704
|
+
stepIndex?: number;
|
|
705
|
+
/** The page the agent was on. */
|
|
706
|
+
url?: string;
|
|
707
|
+
/** Title of the page, if known. */
|
|
708
|
+
title?: string;
|
|
709
|
+
/** The screenshot image — carried in JSON (base64) and/or by reference. */
|
|
710
|
+
image?: SnapshotImage;
|
|
711
|
+
/** What the agent was doing at this step. */
|
|
712
|
+
action?: SnapshotAction;
|
|
713
|
+
}
|
|
714
|
+
interface SnapshotImage {
|
|
715
|
+
/** Base64-encoded image bytes (no data: prefix). */
|
|
716
|
+
base64?: string;
|
|
717
|
+
/** MIME type, e.g. "image/jpeg". */
|
|
718
|
+
contentType?: string;
|
|
719
|
+
/** Direct URL to the image, when the backend exposes one. */
|
|
720
|
+
url?: string;
|
|
721
|
+
/** Artifact id, when the image is stored as an artifact. */
|
|
722
|
+
artifactId?: string;
|
|
723
|
+
width?: number;
|
|
724
|
+
height?: number;
|
|
725
|
+
}
|
|
726
|
+
interface SnapshotAction {
|
|
727
|
+
/** "navigate" | "click" | "type" | ... */
|
|
728
|
+
kind?: string;
|
|
729
|
+
/** The element/URL/value the action targeted. */
|
|
730
|
+
target?: string;
|
|
731
|
+
/** Human-readable summary of the action. */
|
|
732
|
+
summary?: string;
|
|
733
|
+
}
|
|
734
|
+
interface RunLimits {
|
|
735
|
+
maxDurationMinutes?: number;
|
|
736
|
+
}
|
|
737
|
+
interface DoAnythingRunOptions {
|
|
738
|
+
/** Delegation token — passed once here; the returned handle holds it. */
|
|
739
|
+
token: string;
|
|
740
|
+
/** Natural-language task for the agent to carry out. */
|
|
741
|
+
prompt: string;
|
|
742
|
+
capture?: CaptureOptions;
|
|
743
|
+
limits?: RunLimits;
|
|
744
|
+
/**
|
|
745
|
+
* Reuse an existing browser session (follow-up run); a new one is created
|
|
746
|
+
* around the run by default. Maps to `session_id` on the wire create body.
|
|
747
|
+
*/
|
|
748
|
+
session?: SessionRef;
|
|
749
|
+
profileId?: string;
|
|
750
|
+
keepAlive?: boolean;
|
|
751
|
+
allowedActions?: string[];
|
|
752
|
+
skills?: string[];
|
|
753
|
+
[key: string]: unknown;
|
|
754
|
+
}
|
|
755
|
+
interface DoAnythingAttachOptions {
|
|
756
|
+
token: string;
|
|
757
|
+
/**
|
|
758
|
+
* Optional — runs are addressed by `run_id` alone; resolution happens via
|
|
759
|
+
* `GET /do_anything/runs/{run_id}`. Accepted for callers that already hold
|
|
760
|
+
* a `sessionRef`; otherwise it is adopted from the run detail envelope.
|
|
761
|
+
*/
|
|
762
|
+
session?: SessionRef;
|
|
763
|
+
capture?: CaptureOptions;
|
|
764
|
+
}
|
|
765
|
+
declare function createDoAnythingNamespace(transport: QoniTransport): {
|
|
766
|
+
/** Start a run. Returns a handle — see `RunHandle` for the run lifecycle. */
|
|
767
|
+
run: (input: DoAnythingRunOptions) => Promise<RunHandle<DoAnythingEvent>>;
|
|
768
|
+
/**
|
|
769
|
+
* Reconnect to an existing run by id. Verifies the run exists before
|
|
770
|
+
* returning; `sessionRef` is adopted from the run detail envelope when
|
|
771
|
+
* not supplied.
|
|
772
|
+
*/
|
|
773
|
+
attach: (runId: string, opts: DoAnythingAttachOptions) => Promise<RunHandle<DoAnythingEvent>>;
|
|
774
|
+
api: {
|
|
775
|
+
createSession: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
776
|
+
/**
|
|
777
|
+
* `POST /do_anything/runs` — one call creates the run. Without
|
|
778
|
+
* `session_id` a fresh session is created around the run; with it the
|
|
779
|
+
* run is a follow-up in that session (409 while the prior run is
|
|
780
|
+
* non-terminal).
|
|
781
|
+
*/
|
|
782
|
+
createRun: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
783
|
+
getRun: <T = unknown>(input: RuntimeTokenInput & {
|
|
784
|
+
runId: string;
|
|
785
|
+
}) => Promise<QoniResponse<T>>;
|
|
786
|
+
events: <T = unknown>(input: RuntimeTokenInput & {
|
|
787
|
+
runId: string;
|
|
788
|
+
lastEventId?: string;
|
|
789
|
+
signal?: AbortSignal;
|
|
790
|
+
/**
|
|
791
|
+
* Forwarded as the `include_screenshots` query flag — set false to
|
|
792
|
+
* skip `run.screenshot` rows in the replay/backfill window.
|
|
793
|
+
*/
|
|
794
|
+
includeScreenshots?: boolean;
|
|
795
|
+
/**
|
|
796
|
+
* Drop events for internal sub-runs (planning / grading) and yield only
|
|
797
|
+
* the top-level run's events. Matches on `event.data.task_id`.
|
|
798
|
+
* Default false.
|
|
799
|
+
*/
|
|
800
|
+
onlyTopLevel?: boolean;
|
|
801
|
+
onReconnect?: (info: {
|
|
802
|
+
attempt: number;
|
|
803
|
+
lastEventId?: string;
|
|
804
|
+
error: unknown;
|
|
805
|
+
}) => void;
|
|
806
|
+
}) => AsyncIterable<QoniEvent<T>>;
|
|
807
|
+
intervene: <T = unknown>(input: RuntimeTokenInput & {
|
|
808
|
+
runId: string;
|
|
809
|
+
} & JsonObject) => Promise<QoniResponse<T>>;
|
|
810
|
+
cancel: <T = unknown>(input: RuntimeTokenInput & {
|
|
811
|
+
runId: string;
|
|
812
|
+
reason?: string;
|
|
813
|
+
}) => Promise<QoniResponse<T>>;
|
|
814
|
+
readArtifacts: <T = DoAnythingSnapshot>(input: RuntimeTokenInput & {
|
|
815
|
+
sessionId: string;
|
|
816
|
+
artifactId: string;
|
|
817
|
+
}) => Promise<QoniResponse<T>>;
|
|
818
|
+
readRecording: <T = unknown>(input: RuntimeTokenInput & {
|
|
819
|
+
sessionId: string;
|
|
820
|
+
}) => Promise<QoniResponse<T>>;
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
interface DeepResearchRunOptions {
|
|
825
|
+
/** Delegation token — passed once here; the returned handle holds it. */
|
|
826
|
+
token: string;
|
|
827
|
+
/** The research topic. */
|
|
828
|
+
prompt: string;
|
|
829
|
+
capture?: CaptureOptions;
|
|
830
|
+
limits?: RunLimits;
|
|
831
|
+
/**
|
|
832
|
+
* Reuse an existing research session — a follow-up run that inherits the
|
|
833
|
+
* prior run's context. Pass `prior.sessionRef`.
|
|
834
|
+
*/
|
|
835
|
+
session?: SessionRef;
|
|
836
|
+
depth?: "light" | "standard" | "deep";
|
|
837
|
+
outputFormat?: string;
|
|
838
|
+
targetAudience?: string;
|
|
839
|
+
domainWhitelist?: string[];
|
|
840
|
+
domainBlacklist?: string[];
|
|
841
|
+
[key: string]: unknown;
|
|
842
|
+
}
|
|
843
|
+
interface DeepResearchAttachOptions {
|
|
844
|
+
token: string;
|
|
845
|
+
capture?: CaptureOptions;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* DeepResearch capability namespace — runs are created with a research
|
|
849
|
+
* `topic`, gated by an optional HITL outline approval, then stream events
|
|
850
|
+
* until a cited report is produced. Mirrors the backend contract at
|
|
851
|
+
* `/api/v1/projects/{tenant}/deep_research/...`.
|
|
852
|
+
*/
|
|
853
|
+
declare function createDeepResearchNamespace(transport: QoniTransport): {
|
|
854
|
+
/**
|
|
855
|
+
* Start a research run. Pass `session: prior.sessionRef` to start a
|
|
856
|
+
* follow-up run that inherits the prior run's context.
|
|
857
|
+
*/
|
|
858
|
+
run: (input: DeepResearchRunOptions) => Promise<RunHandle<DeepResearchEvent>>;
|
|
859
|
+
/** Reconnect to an existing run. Verifies the run exists before returning. */
|
|
860
|
+
attach: (runId: string, opts: DeepResearchAttachOptions) => Promise<RunHandle<DeepResearchEvent>>;
|
|
861
|
+
api: {
|
|
862
|
+
run: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
863
|
+
get: <T = unknown>(input: RuntimeTokenInput & {
|
|
864
|
+
runId: string;
|
|
865
|
+
}) => Promise<QoniResponse<T>>;
|
|
866
|
+
events: <T = unknown>(input: RuntimeTokenInput & {
|
|
867
|
+
runId: string;
|
|
868
|
+
lastEventId?: string;
|
|
869
|
+
signal?: AbortSignal;
|
|
870
|
+
onReconnect?: (info: {
|
|
871
|
+
attempt: number;
|
|
872
|
+
lastEventId?: string;
|
|
873
|
+
error: unknown;
|
|
874
|
+
}) => void;
|
|
875
|
+
}) => AsyncIterable<QoniEvent<T>>;
|
|
876
|
+
followUp: <T = unknown>(input: RuntimeTokenInput & {
|
|
877
|
+
runId: string;
|
|
878
|
+
text: string;
|
|
879
|
+
}) => Promise<QoniResponse<T>>;
|
|
880
|
+
cancel: <T = unknown>(input: RuntimeTokenInput & {
|
|
881
|
+
runId: string;
|
|
882
|
+
}) => Promise<QoniResponse<T>>;
|
|
883
|
+
feedback: <T = unknown>(input: RuntimeTokenInput & {
|
|
884
|
+
runId: string;
|
|
885
|
+
} & JsonObject) => Promise<QoniResponse<T>>;
|
|
886
|
+
listArtifacts: <T = unknown>(input: RuntimeTokenInput & {
|
|
887
|
+
runId: string;
|
|
888
|
+
}) => Promise<QoniResponse<T>>;
|
|
889
|
+
getArtifact: <T = unknown>(input: RuntimeTokenInput & {
|
|
890
|
+
runId: string;
|
|
891
|
+
artifactId: string;
|
|
892
|
+
}) => Promise<QoniResponse<T>>;
|
|
893
|
+
};
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
type DelegateToken = {
|
|
897
|
+
(input: DelegateTokenInteractiveInput): Promise<QoniResponse<InteractiveDelegationResponse>>;
|
|
898
|
+
(input: DelegateTokenSilentInput): Promise<QoniResponse<DelegateTokenSilentResponse>>;
|
|
899
|
+
(input: DelegateTokenInput): Promise<QoniResponse<DelegateAgentResponse>>;
|
|
900
|
+
};
|
|
901
|
+
type CompleteDelegateToken = (input: CompleteDelegateTokenInput) => Promise<QoniResponse<DelegateTokenResponse>>;
|
|
902
|
+
declare function createQoniNamespace(_transport: QoniTransport, delegateToken: DelegateToken, completeDelegateToken: CompleteDelegateToken): {
|
|
903
|
+
delegateToken: DelegateToken;
|
|
904
|
+
/** @deprecated Use delegateToken. */
|
|
905
|
+
delegateAgent: (input: DelegateAgentInput) => Promise<QoniResponse<DelegateAgentResponse>>;
|
|
906
|
+
completeDelegateToken: CompleteDelegateToken;
|
|
907
|
+
/** @deprecated Use completeDelegateToken. */
|
|
908
|
+
completeDelegateAgent: (input: CompleteDelegateAgentInput) => Promise<QoniResponse<DelegateTokenResponse>>;
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
interface GenAuthAccessTokenInput {
|
|
912
|
+
accessToken: string;
|
|
913
|
+
}
|
|
914
|
+
interface GenAuthDelegationIntrospectionInput {
|
|
915
|
+
token?: string;
|
|
916
|
+
/** @deprecated Use token. */
|
|
917
|
+
delegateAgentToken?: string;
|
|
918
|
+
}
|
|
919
|
+
interface GenAuthAdminToken {
|
|
920
|
+
accessToken: string;
|
|
921
|
+
userPoolId: string;
|
|
922
|
+
}
|
|
923
|
+
type GenAuthAdminTokenProvider = () => Promise<GenAuthAdminToken>;
|
|
924
|
+
interface GenAuthAdminTokenOverrideInput {
|
|
925
|
+
adminToken?: string;
|
|
926
|
+
userPoolId?: string;
|
|
927
|
+
}
|
|
928
|
+
type GenAuthUserListInput = GenAuthAdminTokenOverrideInput & {
|
|
929
|
+
page?: number;
|
|
930
|
+
limit?: number;
|
|
931
|
+
options?: JsonObject & {
|
|
932
|
+
pagination?: JsonObject;
|
|
933
|
+
};
|
|
934
|
+
} & JsonObject;
|
|
935
|
+
type GenAuthUserGetInput = GenAuthAdminTokenOverrideInput & {
|
|
936
|
+
userId: string;
|
|
937
|
+
};
|
|
938
|
+
type GenAuthUserGetBatchInput = GenAuthAdminTokenOverrideInput & {
|
|
939
|
+
userIds: string[];
|
|
940
|
+
};
|
|
941
|
+
type GenAuthUserCreateInput = GenAuthAdminTokenOverrideInput & JsonObject;
|
|
942
|
+
type GenAuthUserCreateBatchInput = GenAuthAdminTokenOverrideInput & {
|
|
943
|
+
users?: JsonObject[];
|
|
944
|
+
list?: JsonObject[];
|
|
945
|
+
options?: JsonObject;
|
|
946
|
+
};
|
|
947
|
+
type GenAuthUserUpdateInput = GenAuthAdminTokenOverrideInput & {
|
|
948
|
+
userId: string;
|
|
949
|
+
} & JsonObject;
|
|
950
|
+
type GenAuthUserDeleteBatchInput = GenAuthAdminTokenOverrideInput & {
|
|
951
|
+
userIds: string[];
|
|
952
|
+
};
|
|
953
|
+
declare function createGenAuthNamespace(transport: QoniTransport, options?: {
|
|
954
|
+
adminTokenFor?: GenAuthAdminTokenProvider;
|
|
955
|
+
}): {
|
|
956
|
+
userInfo: <T = unknown>(input: GenAuthAccessTokenInput) => Promise<QoniResponse<T>>;
|
|
957
|
+
jwks: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
958
|
+
discovery: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
959
|
+
introspectDelegationToken: <T = unknown>(input: GenAuthDelegationIntrospectionInput) => Promise<QoniResponse<T>>;
|
|
960
|
+
users: {
|
|
961
|
+
list: <T = unknown>(input?: GenAuthUserListInput) => Promise<QoniResponse<T>>;
|
|
962
|
+
get: <T = unknown>(input: GenAuthUserGetInput) => Promise<QoniResponse<T>>;
|
|
963
|
+
getBatch: <T = unknown>(input: GenAuthUserGetBatchInput) => Promise<QoniResponse<T>>;
|
|
964
|
+
create: <T = unknown>(input: GenAuthUserCreateInput) => Promise<QoniResponse<T>>;
|
|
965
|
+
createBatch: <T = unknown>(input: GenAuthUserCreateBatchInput) => Promise<QoniResponse<T>>;
|
|
966
|
+
update: <T = unknown>(input: GenAuthUserUpdateInput) => Promise<QoniResponse<T>>;
|
|
967
|
+
deleteBatch: <T = unknown>(input: GenAuthUserDeleteBatchInput) => Promise<QoniResponse<T>>;
|
|
968
|
+
};
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
interface GumemCreateSessionInput extends RuntimeTokenInput {
|
|
972
|
+
userId?: string;
|
|
973
|
+
sessionId?: string;
|
|
974
|
+
/** @deprecated Use userId. */
|
|
975
|
+
user_id?: string;
|
|
976
|
+
/** @deprecated Use sessionId. */
|
|
977
|
+
session_id?: string;
|
|
978
|
+
title?: string;
|
|
979
|
+
metadata?: JsonObject;
|
|
980
|
+
}
|
|
981
|
+
interface GumemAddMessagesInput extends RuntimeTokenInput {
|
|
982
|
+
sessionId: string;
|
|
983
|
+
messages: JsonObject[];
|
|
984
|
+
sync?: boolean;
|
|
985
|
+
userId?: string;
|
|
986
|
+
/** @deprecated Use userId. */
|
|
987
|
+
user_id?: string;
|
|
988
|
+
}
|
|
989
|
+
interface GumemRecallInput extends RuntimeTokenInput {
|
|
990
|
+
sessionId?: string;
|
|
991
|
+
query?: string;
|
|
992
|
+
details?: boolean;
|
|
993
|
+
recallConfig?: JsonObject;
|
|
994
|
+
metadataFilters?: JsonObject;
|
|
995
|
+
/** @deprecated Use recallConfig. */
|
|
996
|
+
recall_config?: JsonObject;
|
|
997
|
+
/** @deprecated Use metadataFilters. */
|
|
998
|
+
metadata_filters?: JsonObject;
|
|
999
|
+
}
|
|
1000
|
+
interface GumemUploadResourceInput extends RuntimeTokenInput {
|
|
1001
|
+
userId?: string;
|
|
1002
|
+
sessionId?: string;
|
|
1003
|
+
/** @deprecated Use userId. */
|
|
1004
|
+
user_id?: string;
|
|
1005
|
+
/** @deprecated Use sessionId. */
|
|
1006
|
+
session_id?: string;
|
|
1007
|
+
file: Blob | File;
|
|
1008
|
+
filename?: string;
|
|
1009
|
+
contentType?: string;
|
|
1010
|
+
}
|
|
1011
|
+
declare function createGumemNamespace(transport: QoniTransport): {
|
|
1012
|
+
createSession: <T = unknown>(input: GumemCreateSessionInput) => Promise<QoniResponse<T>>;
|
|
1013
|
+
addMessages: <T = unknown>(input: GumemAddMessagesInput) => Promise<QoniResponse<T>>;
|
|
1014
|
+
recall: <T = unknown>(input: GumemRecallInput) => Promise<QoniResponse<T>>;
|
|
1015
|
+
uploadResource: <T = unknown>(input: GumemUploadResourceInput) => Promise<QoniResponse<T>>;
|
|
1016
|
+
actions: {
|
|
1017
|
+
record: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
1018
|
+
recall: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
1019
|
+
stream: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
interface TrackCreateOptions {
|
|
1024
|
+
/** Delegation token — passed once here; the returned handle holds it. */
|
|
1025
|
+
token: string;
|
|
1026
|
+
/** Natural-language description of what to monitor. */
|
|
1027
|
+
prompt: string;
|
|
1028
|
+
/** Rest of the monitor definition (url, schedule, …) — camelCase keys. */
|
|
1029
|
+
[key: string]: unknown;
|
|
1030
|
+
}
|
|
1031
|
+
interface TrackAttachOptions {
|
|
1032
|
+
token: string;
|
|
1033
|
+
}
|
|
1034
|
+
interface MonitorEventsOptions {
|
|
1035
|
+
lastEventId?: string;
|
|
1036
|
+
signal?: AbortSignal;
|
|
1037
|
+
}
|
|
1038
|
+
interface MonitorRunsOptions {
|
|
1039
|
+
limit?: number;
|
|
1040
|
+
offset?: number;
|
|
1041
|
+
}
|
|
1042
|
+
/** A monitor's check cadence. */
|
|
1043
|
+
type MonitorSchedule = {
|
|
1044
|
+
kind: "cron";
|
|
1045
|
+
expr: string;
|
|
1046
|
+
} | {
|
|
1047
|
+
kind: "interval";
|
|
1048
|
+
intervalSeconds: number;
|
|
1049
|
+
};
|
|
1050
|
+
/**
|
|
1051
|
+
* Fields to change on a monitor via {@link MonitorHandle.refine}. Pass any
|
|
1052
|
+
* subset; at least one is required. The monitor's natural-language `intent`
|
|
1053
|
+
* is NOT refinable — it drives URL/schema/DSL generation, so changing it means
|
|
1054
|
+
* creating a new monitor.
|
|
1055
|
+
*/
|
|
1056
|
+
interface MonitorRefinePatch {
|
|
1057
|
+
schedule?: MonitorSchedule;
|
|
1058
|
+
targetUrls?: string[];
|
|
1059
|
+
extractionSchema?: JsonObject;
|
|
1060
|
+
triggerDsl?: JsonObject;
|
|
1061
|
+
stopConditionDsl?: JsonObject;
|
|
1062
|
+
notifyChannel?: JsonObject | null;
|
|
1063
|
+
[key: string]: unknown;
|
|
1064
|
+
}
|
|
1065
|
+
interface MonitorWireOps {
|
|
1066
|
+
get(): Promise<JsonObject>;
|
|
1067
|
+
update(input: JsonObject): Promise<JsonObject>;
|
|
1068
|
+
runNow(): Promise<JsonObject>;
|
|
1069
|
+
streamEvents(opts: MonitorEventsOptions): AsyncIterable<QoniEvent<unknown>>;
|
|
1070
|
+
postAction(action: Action, body: JsonObject | undefined): Promise<void>;
|
|
1071
|
+
listRuns(opts: MonitorRunsOptions): Promise<JsonObject>;
|
|
1072
|
+
getRun(runId: string): Promise<JsonObject>;
|
|
1073
|
+
delete(): Promise<void>;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Handle to a Track monitor — a resident resource (unlike a one-shot run).
|
|
1077
|
+
* Holds the delegation token and monitor id internally; no method takes a
|
|
1078
|
+
* token or an id.
|
|
1079
|
+
*/
|
|
1080
|
+
declare class MonitorHandle {
|
|
1081
|
+
private readonly ops;
|
|
1082
|
+
readonly id: string;
|
|
1083
|
+
constructor(ops: MonitorWireOps, id: string);
|
|
1084
|
+
/** Refresh and return the monitor (normalized camelCase fields). */
|
|
1085
|
+
get(): Promise<JsonObject>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Pause the monitor — stops scheduled ticks until {@link resume}. The
|
|
1088
|
+
* monitor stays addressable; this is the way to "stop monitoring" without
|
|
1089
|
+
* deleting.
|
|
1090
|
+
*/
|
|
1091
|
+
pause(): Promise<JsonObject>;
|
|
1092
|
+
/** Resume a paused monitor. */
|
|
1093
|
+
resume(): Promise<JsonObject>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Change the monitor definition. Pass any subset of fields (at least one);
|
|
1096
|
+
* `schedule` is `{ kind: "cron", expr }` or `{ kind: "interval", intervalSeconds }`.
|
|
1097
|
+
* The backend re-validates the trigger DSL against the schema, so a bad
|
|
1098
|
+
* change is rejected, not applied. The natural-language intent is not
|
|
1099
|
+
* refinable — create a new monitor to change it.
|
|
1100
|
+
*/
|
|
1101
|
+
refine(patch: MonitorRefinePatch): Promise<JsonObject>;
|
|
1102
|
+
/** Trigger an immediate tick outside the schedule. */
|
|
1103
|
+
runNow(): Promise<JsonObject>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Stream semantic monitor events. Monitors are resident, so the stream has
|
|
1106
|
+
* no terminal event — it ends only when closed by the caller or the server.
|
|
1107
|
+
*/
|
|
1108
|
+
events(opts?: MonitorEventsOptions): AsyncIterable<MonitorEvent>;
|
|
1109
|
+
/**
|
|
1110
|
+
* Wrap an {@link Interaction} (from `event.data` of an `interaction` event on
|
|
1111
|
+
* the monitor stream — e.g. a `site_login` to unlock a `needs_reauth` park)
|
|
1112
|
+
* in a typed {@link InteractionHandle}. The handle's action methods post to
|
|
1113
|
+
* the endpoint the backend declared for that action.
|
|
1114
|
+
*/
|
|
1115
|
+
interactionHandle(interaction: Interaction): InteractionHandle;
|
|
1116
|
+
/**
|
|
1117
|
+
* Read-only list of the runs the monitor's ticks produced. Tick runs are
|
|
1118
|
+
* owned by the scheduler — to stop monitoring use `pause()` / `delete()`.
|
|
1119
|
+
*/
|
|
1120
|
+
runs(opts?: MonitorRunsOptions): Promise<JsonObject[]>;
|
|
1121
|
+
/** Read-only detail of a single tick run. */
|
|
1122
|
+
run(runId: string): Promise<JsonObject>;
|
|
1123
|
+
/** Delete the monitor. */
|
|
1124
|
+
delete(): Promise<void>;
|
|
1125
|
+
}
|
|
1126
|
+
declare function createTrackNamespace(transport: QoniTransport): {
|
|
1127
|
+
/** Create a monitor. Returns a handle — see `MonitorHandle`. */
|
|
1128
|
+
create: (input: TrackCreateOptions) => Promise<MonitorHandle>;
|
|
1129
|
+
/** Reconnect to an existing monitor. Verifies it exists before returning. */
|
|
1130
|
+
attach: (monitorId: string, opts: TrackAttachOptions) => Promise<MonitorHandle>;
|
|
1131
|
+
api: {
|
|
1132
|
+
createMonitor: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
1133
|
+
getMonitor: <T = unknown>(input: RuntimeTokenInput & {
|
|
1134
|
+
monitorId: string;
|
|
1135
|
+
}) => Promise<QoniResponse<T>>;
|
|
1136
|
+
runNow: <T = unknown>(input: RuntimeTokenInput & {
|
|
1137
|
+
monitorId: string;
|
|
1138
|
+
}) => Promise<QoniResponse<T>>;
|
|
1139
|
+
events: <T = unknown>(input: RuntimeTokenInput & {
|
|
1140
|
+
monitorId: string;
|
|
1141
|
+
lastEventId?: string;
|
|
1142
|
+
signal?: AbortSignal;
|
|
1143
|
+
}) => AsyncIterable<QoniEvent<T>>;
|
|
1144
|
+
intervene: <T = unknown>(input: RuntimeTokenInput & {
|
|
1145
|
+
monitorId: string;
|
|
1146
|
+
} & JsonObject) => Promise<QoniResponse<T>>;
|
|
1147
|
+
listRuns: <T = unknown>(input: RuntimeTokenInput & {
|
|
1148
|
+
monitorId: string;
|
|
1149
|
+
limit?: number;
|
|
1150
|
+
offset?: number;
|
|
1151
|
+
}) => Promise<QoniResponse<T>>;
|
|
1152
|
+
getRun: <T = unknown>(input: RuntimeTokenInput & {
|
|
1153
|
+
monitorId: string;
|
|
1154
|
+
runId: string;
|
|
1155
|
+
}) => Promise<QoniResponse<T>>;
|
|
1156
|
+
updateMonitor: <T = unknown>(input: RuntimeTokenInput & {
|
|
1157
|
+
monitorId: string;
|
|
1158
|
+
} & JsonObject) => Promise<QoniResponse<T>>;
|
|
1159
|
+
deleteMonitor: <T = unknown>(input: RuntimeTokenInput & {
|
|
1160
|
+
monitorId: string;
|
|
1161
|
+
}) => Promise<QoniResponse<T>>;
|
|
1162
|
+
};
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
interface WebSearchRunOptions {
|
|
1166
|
+
/** Delegation token — passed once here; the returned handle holds it. */
|
|
1167
|
+
token: string;
|
|
1168
|
+
/** What to search for — one query, or several for a multi-query search. */
|
|
1169
|
+
prompt: string | string[];
|
|
1170
|
+
capture?: CaptureOptions;
|
|
1171
|
+
/** Not supported by webSearch yet — passing it throws locally. */
|
|
1172
|
+
limits?: RunLimits;
|
|
1173
|
+
/** Not supported by webSearch — searches don't run in reusable sessions. */
|
|
1174
|
+
session?: SessionRef;
|
|
1175
|
+
maxResultsPerQuery?: number;
|
|
1176
|
+
siteWhitelist?: string[];
|
|
1177
|
+
siteBlacklist?: string[];
|
|
1178
|
+
[key: string]: unknown;
|
|
1179
|
+
}
|
|
1180
|
+
interface WebSearchAttachOptions {
|
|
1181
|
+
token: string;
|
|
1182
|
+
capture?: CaptureOptions;
|
|
1183
|
+
}
|
|
1184
|
+
declare function createWebSearchNamespace(transport: QoniTransport): {
|
|
1185
|
+
/** Start a search run. Returns a handle — see `RunHandle` for the run lifecycle. */
|
|
1186
|
+
run: (input: WebSearchRunOptions) => Promise<RunHandle<WebSearchEvent>>;
|
|
1187
|
+
/** Reconnect to an existing run. Verifies the run exists before returning. */
|
|
1188
|
+
attach: (runId: string, opts: WebSearchAttachOptions) => Promise<RunHandle<WebSearchEvent>>;
|
|
1189
|
+
api: {
|
|
1190
|
+
run: <T = unknown>(input: RuntimeTokenInput & JsonObject) => Promise<QoniResponse<T>>;
|
|
1191
|
+
get: <T = unknown>(input: RuntimeTokenInput & {
|
|
1192
|
+
runId: string;
|
|
1193
|
+
}) => Promise<QoniResponse<T>>;
|
|
1194
|
+
events: <T = unknown>(input: RuntimeTokenInput & {
|
|
1195
|
+
runId: string;
|
|
1196
|
+
lastEventId?: string;
|
|
1197
|
+
signal?: AbortSignal;
|
|
1198
|
+
onReconnect?: (info: {
|
|
1199
|
+
attempt: number;
|
|
1200
|
+
lastEventId?: string;
|
|
1201
|
+
error: unknown;
|
|
1202
|
+
}) => void;
|
|
1203
|
+
}) => AsyncIterable<QoniEvent<T>>;
|
|
1204
|
+
cancel: <T = unknown>(input: RuntimeTokenInput & {
|
|
1205
|
+
runId: string;
|
|
1206
|
+
reason?: string;
|
|
1207
|
+
}) => Promise<QoniResponse<T>>;
|
|
1208
|
+
};
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
declare class QoniAgentKit {
|
|
1212
|
+
private readonly options;
|
|
1213
|
+
private readonly fetchImpl;
|
|
1214
|
+
private readonly timeoutMs;
|
|
1215
|
+
private readonly sseMaxRetries;
|
|
1216
|
+
private readonly accessKey;
|
|
1217
|
+
private readonly secretKey;
|
|
1218
|
+
private readonly host;
|
|
1219
|
+
private runtimeConfigPromise?;
|
|
1220
|
+
private readonly productTokenCache;
|
|
1221
|
+
private genAuthAdminTokenCache?;
|
|
1222
|
+
readonly gumem: ReturnType<typeof createGumemNamespace>;
|
|
1223
|
+
readonly genauth: ReturnType<typeof createGenAuthNamespace>;
|
|
1224
|
+
readonly qoni: ReturnType<typeof createQoniNamespace>;
|
|
1225
|
+
readonly webSearch: ReturnType<typeof createWebSearchNamespace>;
|
|
1226
|
+
readonly doAnything: ReturnType<typeof createDoAnythingNamespace>;
|
|
1227
|
+
readonly track: ReturnType<typeof createTrackNamespace>;
|
|
1228
|
+
readonly deepResearch: ReturnType<typeof createDeepResearchNamespace>;
|
|
1229
|
+
constructor(options: QoniOptions);
|
|
1230
|
+
delegateToken(input: DelegateTokenInteractiveInput): Promise<QoniResponse<InteractiveDelegationResponse>>;
|
|
1231
|
+
delegateToken(input: DelegateTokenSilentInput): Promise<QoniResponse<DelegateTokenSilentResponse>>;
|
|
1232
|
+
delegateToken(input: DelegateTokenInput): Promise<QoniResponse<DelegateAgentResponse>>;
|
|
1233
|
+
/** @deprecated Use delegateToken. */
|
|
1234
|
+
delegateAgent(input: DelegateAgentInput): Promise<QoniResponse<DelegateAgentResponse>>;
|
|
1235
|
+
completeDelegateToken(input: CompleteDelegateTokenInput): Promise<QoniResponse<DelegateTokenResponse>>;
|
|
1236
|
+
/** @deprecated Use completeDelegateToken. */
|
|
1237
|
+
completeDelegateAgent(input: CompleteDelegateAgentInput): Promise<QoniResponse<DelegateTokenResponse>>;
|
|
1238
|
+
currentUser<T = unknown>(input: GenAuthAccessTokenInput): Promise<QoniResponse<T>>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Resolve a real GenAuth user id from the userpool bound to this AK/SK, by
|
|
1241
|
+
* listing users and returning the first one. Convenience for demos / smoke
|
|
1242
|
+
* tests so `delegateToken` has a valid `userId` without hardcoding one. In
|
|
1243
|
+
* application code, resolve the actual logged-in user via `currentUser`
|
|
1244
|
+
* instead of picking an arbitrary userpool member.
|
|
1245
|
+
*/
|
|
1246
|
+
resolveAnyBoundUser(): Promise<string>;
|
|
1247
|
+
request<T = unknown>(input: RawRequestInput): Promise<QoniResponse<T>>;
|
|
1248
|
+
unstableRequest<T = unknown>(input: RawRequestInput): Promise<QoniResponse<T>>;
|
|
1249
|
+
private qoniJson;
|
|
1250
|
+
private genauthJson;
|
|
1251
|
+
private gumemJson;
|
|
1252
|
+
private gumemSSE;
|
|
1253
|
+
private webAgentJson;
|
|
1254
|
+
private webAgentBytes;
|
|
1255
|
+
private webAgentSSE;
|
|
1256
|
+
private signedPost;
|
|
1257
|
+
private jsonRequest;
|
|
1258
|
+
private sseRequest;
|
|
1259
|
+
private sseConnectOnce;
|
|
1260
|
+
private fetchWithTimeout;
|
|
1261
|
+
private baseUrlFor;
|
|
1262
|
+
private explicitBaseUrlFor;
|
|
1263
|
+
private runtimeConfig;
|
|
1264
|
+
private fetchRuntimeConfig;
|
|
1265
|
+
private webAgentPath;
|
|
1266
|
+
private productTokenFor;
|
|
1267
|
+
private genauthAdminTokenFor;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Known `QoniError.code` values. The SDK assigns the `*.*` codes; the `eak.*`
|
|
1272
|
+
* codes are backend apiCodes surfaced verbatim. The trailing `(string & {})`
|
|
1273
|
+
* keeps `code` assignable from any string (the backend may add new codes)
|
|
1274
|
+
* while still giving literal autocomplete and letting you write an exhaustive
|
|
1275
|
+
* `switch (err.code)` over the known set.
|
|
1276
|
+
*/
|
|
1277
|
+
type QoniErrorCode = "qoni_error" | "auth.failed" | "delegation.required" | "permission_denied" | "token.expired" | "validation.failed" | "rate_limit.exceeded" | "upstream.failed" | "timeout" | "not_found" | "conflict" | "eak.delegation.user_not_bound" | "eak.genauth.userpool_binding_missing" | "eak.genauth.userpool_owner_missing" | "eak.genauth.no_bound_users" | "eak.token_exchange.upstream_failed" | (string & {});
|
|
1278
|
+
interface QoniErrorOptions {
|
|
1279
|
+
code?: QoniErrorCode;
|
|
1280
|
+
status?: number;
|
|
1281
|
+
requestId?: string;
|
|
1282
|
+
traceId?: string;
|
|
1283
|
+
auditId?: string;
|
|
1284
|
+
retryable?: boolean;
|
|
1285
|
+
body?: unknown;
|
|
1286
|
+
cause?: unknown;
|
|
1287
|
+
}
|
|
1288
|
+
declare class QoniError extends Error {
|
|
1289
|
+
readonly code: QoniErrorCode;
|
|
1290
|
+
readonly status?: number;
|
|
1291
|
+
readonly requestId?: string;
|
|
1292
|
+
readonly traceId?: string;
|
|
1293
|
+
readonly auditId?: string;
|
|
1294
|
+
readonly retryable: boolean;
|
|
1295
|
+
readonly body?: unknown;
|
|
1296
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1297
|
+
}
|
|
1298
|
+
declare class QoniAuthError extends QoniError {
|
|
1299
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1300
|
+
}
|
|
1301
|
+
declare class QoniDelegationRequiredError extends QoniError {
|
|
1302
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1303
|
+
}
|
|
1304
|
+
declare class QoniPermissionDeniedError extends QoniError {
|
|
1305
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1306
|
+
}
|
|
1307
|
+
declare class QoniTokenExpiredError extends QoniError {
|
|
1308
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1309
|
+
}
|
|
1310
|
+
declare class QoniValidationError extends QoniError {
|
|
1311
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1312
|
+
}
|
|
1313
|
+
declare class QoniRateLimitError extends QoniError {
|
|
1314
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1315
|
+
}
|
|
1316
|
+
declare class QoniUpstreamError extends QoniError {
|
|
1317
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1318
|
+
}
|
|
1319
|
+
declare class QoniTimeoutError extends QoniError {
|
|
1320
|
+
constructor(message: string, options?: QoniErrorOptions);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
declare const QoniScopes: {
|
|
1324
|
+
readonly GUMEM_SESSION_CREATE: "gumem.session:create";
|
|
1325
|
+
readonly GUMEM_MESSAGE_WRITE: "gumem.message:write";
|
|
1326
|
+
readonly GUMEM_MEMORY_READ: "gumem.memory:read";
|
|
1327
|
+
readonly GUMEM_MEMORY_WRITE: "gumem.memory:write";
|
|
1328
|
+
readonly GUMEM_MEMORY_DELETE: "gumem.memory:delete";
|
|
1329
|
+
readonly GUMEM_SEARCH_RUN: "gumem.search:run";
|
|
1330
|
+
readonly GUMEM_ADMIN_MANAGE: "gumem.admin:manage";
|
|
1331
|
+
readonly GUMEM_RESOURCE_WRITE: "gumem.resource:write";
|
|
1332
|
+
readonly GUMEM_ACTION_WRITE: "gumem.action:write";
|
|
1333
|
+
readonly GUMEM_ACTION_READ: "gumem.action:read";
|
|
1334
|
+
readonly GUMEM_PROFILE_READ: "gumem.profile:read";
|
|
1335
|
+
readonly DO_ANYTHING_READ: "webagent.do_anything:read";
|
|
1336
|
+
readonly DO_ANYTHING_MANAGE: "webagent.do_anything:manage";
|
|
1337
|
+
readonly WEB_SEARCH_READ: "webagent.web_search:read";
|
|
1338
|
+
readonly WEB_SEARCH_MANAGE: "webagent.web_search:manage";
|
|
1339
|
+
readonly DEEP_RESEARCH_READ: "webagent.deep_research:read";
|
|
1340
|
+
readonly DEEP_RESEARCH_MANAGE: "webagent.deep_research:manage";
|
|
1341
|
+
readonly TRACK_READ: "webagent.track:read";
|
|
1342
|
+
readonly TRACK_MANAGE: "webagent.track:manage";
|
|
1343
|
+
};
|
|
1344
|
+
type QoniScope = (typeof QoniScopes)[keyof typeof QoniScopes];
|
|
1345
|
+
/** Product names accepted by `delegateToken({ products })`. */
|
|
1346
|
+
type QoniProduct = "doAnything" | "webSearch" | "deepResearch" | "track";
|
|
1347
|
+
/**
|
|
1348
|
+
* Scope sets granted by the `delegateToken({ products })` sugar — each
|
|
1349
|
+
* product expands to its full verb pair: `read` + `manage`.
|
|
1350
|
+
*/
|
|
1351
|
+
declare const QoniProductScopes: Record<QoniProduct, readonly QoniScope[]>;
|
|
1352
|
+
declare const QoniScopeBundles: {
|
|
1353
|
+
readonly GUMEM_READONLY: readonly ["gumem.memory:read", "gumem.profile:read"];
|
|
1354
|
+
readonly GUMEM_SESSION_RECALL: readonly ["gumem.memory:read", "gumem.memory:write", "gumem.message:write"];
|
|
1355
|
+
readonly GUMEM_WRITE: readonly ["gumem.session:create", "gumem.message:write", "gumem.action:write"];
|
|
1356
|
+
readonly DO_ANYTHING: readonly ["webagent.do_anything:read", "webagent.do_anything:manage"];
|
|
1357
|
+
readonly WEB_SEARCH: readonly ["webagent.web_search:read", "webagent.web_search:manage"];
|
|
1358
|
+
readonly DEEP_RESEARCH: readonly ["webagent.deep_research:read", "webagent.deep_research:manage"];
|
|
1359
|
+
readonly TRACK: readonly ["webagent.track:read", "webagent.track:manage"];
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
export { type Action, type ActionKind, ActionKinds, type Artifact, type CaptureOptions, type ClarificationPayload, type CompleteDelegateAgentInput, type CompleteDelegateTokenInput, type ConfirmationPayload, type CoreRunEvent, type DeepResearchAttachOptions, type DeepResearchEvent, type DeepResearchRunOptions, type DelegateAgentInput, type DelegateAgentResponse, type DelegateAgentTokenResponse, type DelegateTokenInput, type DelegateTokenInteractiveInput, type DelegateTokenResponse, type DelegateTokenResult, type DelegateTokenSilentInput, type DelegateTokenSilentResponse, type DelegationMode, type DelegationTokenResponse, type DoAnythingAttachOptions, type DoAnythingEvent, type DoAnythingRunOptions, type DoAnythingSnapshot, type GenAuthAccessTokenInput, type GenAuthAdminToken, type GenAuthAdminTokenOverrideInput, type GenAuthDelegationIntrospectionInput, type GenAuthUserCreateBatchInput, type GenAuthUserCreateInput, type GenAuthUserDeleteBatchInput, type GenAuthUserGetBatchInput, type GenAuthUserGetInput, type GenAuthUserListInput, type GenAuthUserUpdateInput, type Interaction, type InteractionEvidence, InteractionHandle, type InteractionPayloadByType, type InteractionSite, type InteractionStatus, InteractionStatuses, type InteractionType, InteractionTypes, type InteractiveDelegationResponse, type JsonObject, type MonitorEvent, type MonitorEventsOptions, MonitorHandle, type MonitorRunsOptions, QoniAgentKit as Qoni, QoniAgentKit, QoniAuthError, QoniDelegationRequiredError, QoniError, type QoniErrorCode, type QoniErrorOptions, type QoniEvent, type QoniEventType, QoniEventTypes, type QoniMeta, type QoniOptions, QoniPermissionDeniedError, type QoniProduct, type QoniProductName, QoniProductScopes, QoniRateLimitError, type QoniResponse, type QoniRuntimeConfig, type QoniSSEEvent, QoniScopeBundles, QoniScopes, QoniTimeoutError, QoniTokenExpiredError, QoniUpstreamError, QoniValidationError, type RawRequestInput, type RunDoneData, type RunEvent, type RunEventsOptions, RunHandle, type RunImage, type RunLimits, type RunMessageData, type RunReconnectInfo, type RunResult, type RunScreenshotData, type RunStatus, type RunWaitOptions, type RuntimeTokenInput, type SessionRef, type SiteLoginPayload, type SnapshotAction, type SnapshotImage, type TakeControlPayload, type TokenInput, type TrackAttachOptions, type TrackCreateOptions, type WaitKind, type WaitPayload, type WebSearchAttachOptions, type WebSearchEvent, type WebSearchRunOptions, buildAuthorization, buildSignature, buildStringToSign };
|