@qoniai/qoni 0.6.0 → 0.8.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 +70 -2
- package/README.md +74 -7
- package/README.zh-CN.md +59 -7
- package/dist/index.cjs +331 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -10
- package/dist/index.d.ts +101 -10
- package/dist/index.js +331 -149
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -138,11 +138,16 @@ interface UserRef {
|
|
|
138
138
|
interface DelegateTokenBaseInput {
|
|
139
139
|
/** Audit label for this delegation. Defaults to "sdk". */
|
|
140
140
|
agent?: string;
|
|
141
|
+
/** Compatibility alias for agent. Supplying conflicting labels is an error. */
|
|
142
|
+
agentKey?: string;
|
|
141
143
|
/** Fine-grained scopes. May be combined with `products`. */
|
|
142
144
|
scopes?: readonly string[];
|
|
143
145
|
/** Per-product authorization sugar — expands to the product's scope set. */
|
|
144
146
|
products?: readonly QoniProductName[];
|
|
147
|
+
/** Integer seconds (60–86400), or a whole-number duration such as "15m". */
|
|
145
148
|
expiresIn?: string | number;
|
|
149
|
+
/** Not supported: the delegation service does not enforce a deny policy. */
|
|
150
|
+
deniedScopes?: never;
|
|
146
151
|
idempotencyKey?: string;
|
|
147
152
|
}
|
|
148
153
|
/**
|
|
@@ -156,11 +161,11 @@ type DelegateTokenSilentInput = DelegateTokenBaseInput & {
|
|
|
156
161
|
state?: string;
|
|
157
162
|
} & ({
|
|
158
163
|
user: UserRef;
|
|
159
|
-
/**
|
|
164
|
+
/** Alternative to user.id. A nonempty userId takes precedence. */
|
|
160
165
|
userId?: string;
|
|
161
166
|
} | {
|
|
162
167
|
user?: UserRef;
|
|
163
|
-
/**
|
|
168
|
+
/** Alternative to user.id. A nonempty userId takes precedence. */
|
|
164
169
|
userId: string;
|
|
165
170
|
});
|
|
166
171
|
interface DelegateTokenInteractiveInput extends DelegateTokenBaseInput {
|
|
@@ -168,7 +173,7 @@ interface DelegateTokenInteractiveInput extends DelegateTokenBaseInput {
|
|
|
168
173
|
redirectUri: string;
|
|
169
174
|
state: string;
|
|
170
175
|
user?: UserRef;
|
|
171
|
-
/**
|
|
176
|
+
/** Alternative to user.id; optional for interactive authorization. */
|
|
172
177
|
userId?: string;
|
|
173
178
|
}
|
|
174
179
|
type DelegateTokenInput = DelegateTokenSilentInput | DelegateTokenInteractiveInput;
|
|
@@ -363,7 +368,70 @@ interface Interaction<T extends InteractionType = InteractionType> {
|
|
|
363
368
|
* supplies this (token + run addressing already bound); the handle below uses
|
|
364
369
|
* it to invoke `action.endpoint` without the consumer touching HTTP.
|
|
365
370
|
*/
|
|
366
|
-
type InteractionActionPoster = (action: Action, body: JsonObject | undefined
|
|
371
|
+
type InteractionActionPoster = (action: Action, body: JsonObject | undefined, options?: {
|
|
372
|
+
requiredScopes?: readonly string[];
|
|
373
|
+
}) => Promise<unknown>;
|
|
374
|
+
/** Options for {@link InteractionHandle.openLogin}. */
|
|
375
|
+
interface OpenLoginOptions {
|
|
376
|
+
/**
|
|
377
|
+
* Site to sign in to — one of `interaction.payload.sites[].siteId`. May be
|
|
378
|
+
* omitted when the interaction lists exactly one site.
|
|
379
|
+
*/
|
|
380
|
+
siteId?: string;
|
|
381
|
+
/** Re-login an existing browser profile in place instead of creating one. */
|
|
382
|
+
profileId?: string;
|
|
383
|
+
}
|
|
384
|
+
/** Interactive login session started by {@link InteractionHandle.openLogin}. */
|
|
385
|
+
interface OpenLoginResult {
|
|
386
|
+
profileId: string;
|
|
387
|
+
siteId: string;
|
|
388
|
+
/** Login browser session the user signs in through. */
|
|
389
|
+
sessionId: string;
|
|
390
|
+
/** Live view URL of the login browser to show to the user. */
|
|
391
|
+
liveUrl: string;
|
|
392
|
+
/** Unmodified response body (escape hatch — shape may evolve with the API). */
|
|
393
|
+
raw: JsonObject;
|
|
394
|
+
/**
|
|
395
|
+
* Persist the login into the profile after the user signs in
|
|
396
|
+
* (`POST /profiles/{profileId}/confirm`). Confirming ends this login
|
|
397
|
+
* session and closes its browser, whatever the outcome:
|
|
398
|
+
*
|
|
399
|
+
* - `active: true` — the login is saved; call
|
|
400
|
+
* {@link InteractionHandle.confirmSignedIn}.
|
|
401
|
+
* - `active: false` with `probeResult: "no_session"` — the backend no longer
|
|
402
|
+
* holds the session (it may already have saved the login automatically, or
|
|
403
|
+
* restarted). Call `confirmSignedIn()`: the agent rechecks the site and
|
|
404
|
+
* raises a new `site_login` interaction if it is still signed out.
|
|
405
|
+
* - Rejects with a `QoniError` whose `code` is `no_pending_login` (HTTP 409)
|
|
406
|
+
* when the backend has no pending login for this profile: the session
|
|
407
|
+
* already ended on providers that report it this way, or the profile no
|
|
408
|
+
* longer exists for this user. Handle it like `no_session`: call
|
|
409
|
+
* `confirmSignedIn()`, and the agent asks again if it is still signed out.
|
|
410
|
+
* - `active: false` with any other `probeResult` — the user was not signed
|
|
411
|
+
* in. Start a new session with `openLogin({ siteId, profileId })` and show
|
|
412
|
+
* its new `liveUrl`; the old one no longer works.
|
|
413
|
+
*
|
|
414
|
+
* Requires `QoniScopes.SITE_LOGIN_CONFIRM`.
|
|
415
|
+
*/
|
|
416
|
+
confirm(options?: ConfirmLoginOptions): Promise<ConfirmLoginResult>;
|
|
417
|
+
}
|
|
418
|
+
/** Options for {@link OpenLoginResult.confirm}. */
|
|
419
|
+
interface ConfirmLoginOptions {
|
|
420
|
+
/** Optional human-readable label stored on the profile. */
|
|
421
|
+
displayLabel?: string;
|
|
422
|
+
}
|
|
423
|
+
/** Result of {@link OpenLoginResult.confirm}. */
|
|
424
|
+
interface ConfirmLoginResult {
|
|
425
|
+
profileId: string;
|
|
426
|
+
/** True only when the profile is now `active` (the login was captured). */
|
|
427
|
+
active: boolean;
|
|
428
|
+
/** Profile state after confirmation: `active`, or `pending_login` when no signed-in session was detected. */
|
|
429
|
+
state: string;
|
|
430
|
+
/** Outcome of the backend's signed-in probe, for example `no_session`. */
|
|
431
|
+
probeResult: string;
|
|
432
|
+
/** Unmodified response body (escape hatch — shape may evolve with the API). */
|
|
433
|
+
raw: JsonObject;
|
|
434
|
+
}
|
|
367
435
|
/**
|
|
368
436
|
* Typed wrapper over an {@link Interaction} that exposes one method per
|
|
369
437
|
* action kind. Each method finds the matching declared action and posts to its
|
|
@@ -372,6 +440,7 @@ type InteractionActionPoster = (action: Action, body: JsonObject | undefined) =>
|
|
|
372
440
|
* backend offered it).
|
|
373
441
|
*/
|
|
374
442
|
declare class InteractionHandle<T extends InteractionType = InteractionType> {
|
|
443
|
+
#private;
|
|
375
444
|
private readonly post;
|
|
376
445
|
readonly interaction: Interaction<T>;
|
|
377
446
|
constructor(interaction: Interaction<T>, post: InteractionActionPoster);
|
|
@@ -389,8 +458,16 @@ declare class InteractionHandle<T extends InteractionType = InteractionType> {
|
|
|
389
458
|
confirm(): Promise<void>;
|
|
390
459
|
/** Reject a pending confirmation. */
|
|
391
460
|
reject(): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Start an interactive login session for a `site_login` interaction. The
|
|
463
|
+
* backend needs the site to sign in to: pass `siteId`, or omit it when the
|
|
464
|
+
* interaction lists exactly one site. Show `liveUrl` to the user; when they
|
|
465
|
+
* finish, call `confirm()` on the result to save the login, and act on its
|
|
466
|
+
* outcome (see {@link OpenLoginResult.confirm}) before {@link confirmSignedIn}.
|
|
467
|
+
* The delegation must include `QoniScopes.SITE_LOGIN_REQUEST` and
|
|
468
|
+
* `QoniScopes.SITE_LOGIN_CONFIRM`; the AccessKey policy must allow both.
|
|
469
|
+
*/
|
|
470
|
+
openLogin(options?: OpenLoginOptions): Promise<OpenLoginResult>;
|
|
394
471
|
/** Tell the agent the user has finished signing in. */
|
|
395
472
|
confirmSignedIn(): Promise<void>;
|
|
396
473
|
/** Connect to the live browser for a take_control interaction. */
|
|
@@ -663,7 +740,9 @@ interface RunWireOps {
|
|
|
663
740
|
* Interaction model's `actions[]` carry the endpoint + method, so the SDK
|
|
664
741
|
* never hard-codes a HITL route — it forwards what the backend declared.
|
|
665
742
|
*/
|
|
666
|
-
postAction(action: Action, body: JsonObject | undefined
|
|
743
|
+
postAction(action: Action, body: JsonObject | undefined, options?: {
|
|
744
|
+
requiredScopes?: readonly string[];
|
|
745
|
+
}): Promise<unknown>;
|
|
667
746
|
cancel(reason?: string): Promise<JsonObject>;
|
|
668
747
|
/** Products without artifacts leave this undefined → `result.artifacts` is []. */
|
|
669
748
|
listArtifacts?(signal?: AbortSignal): Promise<Artifact[]>;
|
|
@@ -1000,7 +1079,13 @@ type GenAuthUserDeleteBatchInput = GenAuthAdminTokenOverrideInput & {
|
|
|
1000
1079
|
};
|
|
1001
1080
|
declare function createGenAuthNamespace(transport: QoniTransport, options?: {
|
|
1002
1081
|
adminTokenFor?: GenAuthAdminTokenProvider;
|
|
1082
|
+
delegateTokenFor?: (input: DelegateTokenInput) => Promise<QoniResponse<DelegateAgentResponse>>;
|
|
1003
1083
|
}): {
|
|
1084
|
+
delegateAgent: {
|
|
1085
|
+
(input: DelegateTokenSilentInput): Promise<DelegateTokenSilentResponse>;
|
|
1086
|
+
(input: DelegateTokenInteractiveInput): Promise<InteractiveDelegationResponse>;
|
|
1087
|
+
(input: DelegateTokenInput): Promise<DelegateAgentResponse>;
|
|
1088
|
+
};
|
|
1004
1089
|
userInfo: <T = unknown>(input: GenAuthAccessTokenInput) => Promise<QoniResponse<T>>;
|
|
1005
1090
|
jwks: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
1006
1091
|
discovery: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
@@ -1090,10 +1175,12 @@ interface MonitorRunsOptions {
|
|
|
1090
1175
|
/** A monitor's check cadence. */
|
|
1091
1176
|
type MonitorSchedule = {
|
|
1092
1177
|
kind: "cron";
|
|
1093
|
-
expr: string;
|
|
1178
|
+
expr: string; /** IANA time zone for the cron expression. */
|
|
1179
|
+
tz?: string;
|
|
1094
1180
|
} | {
|
|
1095
1181
|
kind: "interval";
|
|
1096
1182
|
intervalSeconds: number;
|
|
1183
|
+
tz?: string;
|
|
1097
1184
|
};
|
|
1098
1185
|
/**
|
|
1099
1186
|
* Fields to change on a monitor via {@link MonitorHandle.refine}. Pass any
|
|
@@ -1115,7 +1202,9 @@ interface MonitorWireOps {
|
|
|
1115
1202
|
update(input: JsonObject): Promise<JsonObject>;
|
|
1116
1203
|
runNow(): Promise<JsonObject>;
|
|
1117
1204
|
streamEvents(opts: MonitorEventsOptions): AsyncIterable<QoniEvent<unknown>>;
|
|
1118
|
-
postAction(action: Action, body: JsonObject | undefined
|
|
1205
|
+
postAction(action: Action, body: JsonObject | undefined, options?: {
|
|
1206
|
+
requiredScopes?: readonly string[];
|
|
1207
|
+
}): Promise<unknown>;
|
|
1119
1208
|
listRuns(opts: MonitorRunsOptions): Promise<JsonObject>;
|
|
1120
1209
|
getRun(runId: string): Promise<JsonObject>;
|
|
1121
1210
|
delete(): Promise<void>;
|
|
@@ -1388,6 +1477,8 @@ declare const QoniScopes: {
|
|
|
1388
1477
|
readonly DEEP_RESEARCH_MANAGE: "webagent.deep_research:manage";
|
|
1389
1478
|
readonly TRACK_READ: "webagent.track:read";
|
|
1390
1479
|
readonly TRACK_MANAGE: "webagent.track:manage";
|
|
1480
|
+
readonly SITE_LOGIN_REQUEST: "webagent.site_login:request";
|
|
1481
|
+
readonly SITE_LOGIN_CONFIRM: "webagent.site_login:confirm";
|
|
1391
1482
|
};
|
|
1392
1483
|
type QoniScope = (typeof QoniScopes)[keyof typeof QoniScopes];
|
|
1393
1484
|
/** Product names accepted by `delegateToken({ products })`. */
|
|
@@ -1407,4 +1498,4 @@ declare const QoniScopeBundles: {
|
|
|
1407
1498
|
readonly TRACK: readonly ["webagent.track:read", "webagent.track:manage"];
|
|
1408
1499
|
};
|
|
1409
1500
|
|
|
1410
|
-
export { type Action, type ActionKind, ActionKinds, type Artifact, type BrowserProxyOptions, type BrowserbaseRegion, 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, Qoni, 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 RunBrowserLiveUrlChangedData, 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 };
|
|
1501
|
+
export { type Action, type ActionKind, ActionKinds, type Artifact, type BrowserProxyOptions, type BrowserbaseRegion, type CaptureOptions, type ClarificationPayload, type CompleteDelegateAgentInput, type CompleteDelegateTokenInput, type ConfirmLoginOptions, type ConfirmLoginResult, 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, type OpenLoginOptions, type OpenLoginResult, Qoni, 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 RunBrowserLiveUrlChangedData, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -138,11 +138,16 @@ interface UserRef {
|
|
|
138
138
|
interface DelegateTokenBaseInput {
|
|
139
139
|
/** Audit label for this delegation. Defaults to "sdk". */
|
|
140
140
|
agent?: string;
|
|
141
|
+
/** Compatibility alias for agent. Supplying conflicting labels is an error. */
|
|
142
|
+
agentKey?: string;
|
|
141
143
|
/** Fine-grained scopes. May be combined with `products`. */
|
|
142
144
|
scopes?: readonly string[];
|
|
143
145
|
/** Per-product authorization sugar — expands to the product's scope set. */
|
|
144
146
|
products?: readonly QoniProductName[];
|
|
147
|
+
/** Integer seconds (60–86400), or a whole-number duration such as "15m". */
|
|
145
148
|
expiresIn?: string | number;
|
|
149
|
+
/** Not supported: the delegation service does not enforce a deny policy. */
|
|
150
|
+
deniedScopes?: never;
|
|
146
151
|
idempotencyKey?: string;
|
|
147
152
|
}
|
|
148
153
|
/**
|
|
@@ -156,11 +161,11 @@ type DelegateTokenSilentInput = DelegateTokenBaseInput & {
|
|
|
156
161
|
state?: string;
|
|
157
162
|
} & ({
|
|
158
163
|
user: UserRef;
|
|
159
|
-
/**
|
|
164
|
+
/** Alternative to user.id. A nonempty userId takes precedence. */
|
|
160
165
|
userId?: string;
|
|
161
166
|
} | {
|
|
162
167
|
user?: UserRef;
|
|
163
|
-
/**
|
|
168
|
+
/** Alternative to user.id. A nonempty userId takes precedence. */
|
|
164
169
|
userId: string;
|
|
165
170
|
});
|
|
166
171
|
interface DelegateTokenInteractiveInput extends DelegateTokenBaseInput {
|
|
@@ -168,7 +173,7 @@ interface DelegateTokenInteractiveInput extends DelegateTokenBaseInput {
|
|
|
168
173
|
redirectUri: string;
|
|
169
174
|
state: string;
|
|
170
175
|
user?: UserRef;
|
|
171
|
-
/**
|
|
176
|
+
/** Alternative to user.id; optional for interactive authorization. */
|
|
172
177
|
userId?: string;
|
|
173
178
|
}
|
|
174
179
|
type DelegateTokenInput = DelegateTokenSilentInput | DelegateTokenInteractiveInput;
|
|
@@ -363,7 +368,70 @@ interface Interaction<T extends InteractionType = InteractionType> {
|
|
|
363
368
|
* supplies this (token + run addressing already bound); the handle below uses
|
|
364
369
|
* it to invoke `action.endpoint` without the consumer touching HTTP.
|
|
365
370
|
*/
|
|
366
|
-
type InteractionActionPoster = (action: Action, body: JsonObject | undefined
|
|
371
|
+
type InteractionActionPoster = (action: Action, body: JsonObject | undefined, options?: {
|
|
372
|
+
requiredScopes?: readonly string[];
|
|
373
|
+
}) => Promise<unknown>;
|
|
374
|
+
/** Options for {@link InteractionHandle.openLogin}. */
|
|
375
|
+
interface OpenLoginOptions {
|
|
376
|
+
/**
|
|
377
|
+
* Site to sign in to — one of `interaction.payload.sites[].siteId`. May be
|
|
378
|
+
* omitted when the interaction lists exactly one site.
|
|
379
|
+
*/
|
|
380
|
+
siteId?: string;
|
|
381
|
+
/** Re-login an existing browser profile in place instead of creating one. */
|
|
382
|
+
profileId?: string;
|
|
383
|
+
}
|
|
384
|
+
/** Interactive login session started by {@link InteractionHandle.openLogin}. */
|
|
385
|
+
interface OpenLoginResult {
|
|
386
|
+
profileId: string;
|
|
387
|
+
siteId: string;
|
|
388
|
+
/** Login browser session the user signs in through. */
|
|
389
|
+
sessionId: string;
|
|
390
|
+
/** Live view URL of the login browser to show to the user. */
|
|
391
|
+
liveUrl: string;
|
|
392
|
+
/** Unmodified response body (escape hatch — shape may evolve with the API). */
|
|
393
|
+
raw: JsonObject;
|
|
394
|
+
/**
|
|
395
|
+
* Persist the login into the profile after the user signs in
|
|
396
|
+
* (`POST /profiles/{profileId}/confirm`). Confirming ends this login
|
|
397
|
+
* session and closes its browser, whatever the outcome:
|
|
398
|
+
*
|
|
399
|
+
* - `active: true` — the login is saved; call
|
|
400
|
+
* {@link InteractionHandle.confirmSignedIn}.
|
|
401
|
+
* - `active: false` with `probeResult: "no_session"` — the backend no longer
|
|
402
|
+
* holds the session (it may already have saved the login automatically, or
|
|
403
|
+
* restarted). Call `confirmSignedIn()`: the agent rechecks the site and
|
|
404
|
+
* raises a new `site_login` interaction if it is still signed out.
|
|
405
|
+
* - Rejects with a `QoniError` whose `code` is `no_pending_login` (HTTP 409)
|
|
406
|
+
* when the backend has no pending login for this profile: the session
|
|
407
|
+
* already ended on providers that report it this way, or the profile no
|
|
408
|
+
* longer exists for this user. Handle it like `no_session`: call
|
|
409
|
+
* `confirmSignedIn()`, and the agent asks again if it is still signed out.
|
|
410
|
+
* - `active: false` with any other `probeResult` — the user was not signed
|
|
411
|
+
* in. Start a new session with `openLogin({ siteId, profileId })` and show
|
|
412
|
+
* its new `liveUrl`; the old one no longer works.
|
|
413
|
+
*
|
|
414
|
+
* Requires `QoniScopes.SITE_LOGIN_CONFIRM`.
|
|
415
|
+
*/
|
|
416
|
+
confirm(options?: ConfirmLoginOptions): Promise<ConfirmLoginResult>;
|
|
417
|
+
}
|
|
418
|
+
/** Options for {@link OpenLoginResult.confirm}. */
|
|
419
|
+
interface ConfirmLoginOptions {
|
|
420
|
+
/** Optional human-readable label stored on the profile. */
|
|
421
|
+
displayLabel?: string;
|
|
422
|
+
}
|
|
423
|
+
/** Result of {@link OpenLoginResult.confirm}. */
|
|
424
|
+
interface ConfirmLoginResult {
|
|
425
|
+
profileId: string;
|
|
426
|
+
/** True only when the profile is now `active` (the login was captured). */
|
|
427
|
+
active: boolean;
|
|
428
|
+
/** Profile state after confirmation: `active`, or `pending_login` when no signed-in session was detected. */
|
|
429
|
+
state: string;
|
|
430
|
+
/** Outcome of the backend's signed-in probe, for example `no_session`. */
|
|
431
|
+
probeResult: string;
|
|
432
|
+
/** Unmodified response body (escape hatch — shape may evolve with the API). */
|
|
433
|
+
raw: JsonObject;
|
|
434
|
+
}
|
|
367
435
|
/**
|
|
368
436
|
* Typed wrapper over an {@link Interaction} that exposes one method per
|
|
369
437
|
* action kind. Each method finds the matching declared action and posts to its
|
|
@@ -372,6 +440,7 @@ type InteractionActionPoster = (action: Action, body: JsonObject | undefined) =>
|
|
|
372
440
|
* backend offered it).
|
|
373
441
|
*/
|
|
374
442
|
declare class InteractionHandle<T extends InteractionType = InteractionType> {
|
|
443
|
+
#private;
|
|
375
444
|
private readonly post;
|
|
376
445
|
readonly interaction: Interaction<T>;
|
|
377
446
|
constructor(interaction: Interaction<T>, post: InteractionActionPoster);
|
|
@@ -389,8 +458,16 @@ declare class InteractionHandle<T extends InteractionType = InteractionType> {
|
|
|
389
458
|
confirm(): Promise<void>;
|
|
390
459
|
/** Reject a pending confirmation. */
|
|
391
460
|
reject(): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
|
|
461
|
+
/**
|
|
462
|
+
* Start an interactive login session for a `site_login` interaction. The
|
|
463
|
+
* backend needs the site to sign in to: pass `siteId`, or omit it when the
|
|
464
|
+
* interaction lists exactly one site. Show `liveUrl` to the user; when they
|
|
465
|
+
* finish, call `confirm()` on the result to save the login, and act on its
|
|
466
|
+
* outcome (see {@link OpenLoginResult.confirm}) before {@link confirmSignedIn}.
|
|
467
|
+
* The delegation must include `QoniScopes.SITE_LOGIN_REQUEST` and
|
|
468
|
+
* `QoniScopes.SITE_LOGIN_CONFIRM`; the AccessKey policy must allow both.
|
|
469
|
+
*/
|
|
470
|
+
openLogin(options?: OpenLoginOptions): Promise<OpenLoginResult>;
|
|
394
471
|
/** Tell the agent the user has finished signing in. */
|
|
395
472
|
confirmSignedIn(): Promise<void>;
|
|
396
473
|
/** Connect to the live browser for a take_control interaction. */
|
|
@@ -663,7 +740,9 @@ interface RunWireOps {
|
|
|
663
740
|
* Interaction model's `actions[]` carry the endpoint + method, so the SDK
|
|
664
741
|
* never hard-codes a HITL route — it forwards what the backend declared.
|
|
665
742
|
*/
|
|
666
|
-
postAction(action: Action, body: JsonObject | undefined
|
|
743
|
+
postAction(action: Action, body: JsonObject | undefined, options?: {
|
|
744
|
+
requiredScopes?: readonly string[];
|
|
745
|
+
}): Promise<unknown>;
|
|
667
746
|
cancel(reason?: string): Promise<JsonObject>;
|
|
668
747
|
/** Products without artifacts leave this undefined → `result.artifacts` is []. */
|
|
669
748
|
listArtifacts?(signal?: AbortSignal): Promise<Artifact[]>;
|
|
@@ -1000,7 +1079,13 @@ type GenAuthUserDeleteBatchInput = GenAuthAdminTokenOverrideInput & {
|
|
|
1000
1079
|
};
|
|
1001
1080
|
declare function createGenAuthNamespace(transport: QoniTransport, options?: {
|
|
1002
1081
|
adminTokenFor?: GenAuthAdminTokenProvider;
|
|
1082
|
+
delegateTokenFor?: (input: DelegateTokenInput) => Promise<QoniResponse<DelegateAgentResponse>>;
|
|
1003
1083
|
}): {
|
|
1084
|
+
delegateAgent: {
|
|
1085
|
+
(input: DelegateTokenSilentInput): Promise<DelegateTokenSilentResponse>;
|
|
1086
|
+
(input: DelegateTokenInteractiveInput): Promise<InteractiveDelegationResponse>;
|
|
1087
|
+
(input: DelegateTokenInput): Promise<DelegateAgentResponse>;
|
|
1088
|
+
};
|
|
1004
1089
|
userInfo: <T = unknown>(input: GenAuthAccessTokenInput) => Promise<QoniResponse<T>>;
|
|
1005
1090
|
jwks: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
1006
1091
|
discovery: <T = unknown>() => Promise<QoniResponse<T>>;
|
|
@@ -1090,10 +1175,12 @@ interface MonitorRunsOptions {
|
|
|
1090
1175
|
/** A monitor's check cadence. */
|
|
1091
1176
|
type MonitorSchedule = {
|
|
1092
1177
|
kind: "cron";
|
|
1093
|
-
expr: string;
|
|
1178
|
+
expr: string; /** IANA time zone for the cron expression. */
|
|
1179
|
+
tz?: string;
|
|
1094
1180
|
} | {
|
|
1095
1181
|
kind: "interval";
|
|
1096
1182
|
intervalSeconds: number;
|
|
1183
|
+
tz?: string;
|
|
1097
1184
|
};
|
|
1098
1185
|
/**
|
|
1099
1186
|
* Fields to change on a monitor via {@link MonitorHandle.refine}. Pass any
|
|
@@ -1115,7 +1202,9 @@ interface MonitorWireOps {
|
|
|
1115
1202
|
update(input: JsonObject): Promise<JsonObject>;
|
|
1116
1203
|
runNow(): Promise<JsonObject>;
|
|
1117
1204
|
streamEvents(opts: MonitorEventsOptions): AsyncIterable<QoniEvent<unknown>>;
|
|
1118
|
-
postAction(action: Action, body: JsonObject | undefined
|
|
1205
|
+
postAction(action: Action, body: JsonObject | undefined, options?: {
|
|
1206
|
+
requiredScopes?: readonly string[];
|
|
1207
|
+
}): Promise<unknown>;
|
|
1119
1208
|
listRuns(opts: MonitorRunsOptions): Promise<JsonObject>;
|
|
1120
1209
|
getRun(runId: string): Promise<JsonObject>;
|
|
1121
1210
|
delete(): Promise<void>;
|
|
@@ -1388,6 +1477,8 @@ declare const QoniScopes: {
|
|
|
1388
1477
|
readonly DEEP_RESEARCH_MANAGE: "webagent.deep_research:manage";
|
|
1389
1478
|
readonly TRACK_READ: "webagent.track:read";
|
|
1390
1479
|
readonly TRACK_MANAGE: "webagent.track:manage";
|
|
1480
|
+
readonly SITE_LOGIN_REQUEST: "webagent.site_login:request";
|
|
1481
|
+
readonly SITE_LOGIN_CONFIRM: "webagent.site_login:confirm";
|
|
1391
1482
|
};
|
|
1392
1483
|
type QoniScope = (typeof QoniScopes)[keyof typeof QoniScopes];
|
|
1393
1484
|
/** Product names accepted by `delegateToken({ products })`. */
|
|
@@ -1407,4 +1498,4 @@ declare const QoniScopeBundles: {
|
|
|
1407
1498
|
readonly TRACK: readonly ["webagent.track:read", "webagent.track:manage"];
|
|
1408
1499
|
};
|
|
1409
1500
|
|
|
1410
|
-
export { type Action, type ActionKind, ActionKinds, type Artifact, type BrowserProxyOptions, type BrowserbaseRegion, 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, Qoni, 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 RunBrowserLiveUrlChangedData, 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 };
|
|
1501
|
+
export { type Action, type ActionKind, ActionKinds, type Artifact, type BrowserProxyOptions, type BrowserbaseRegion, type CaptureOptions, type ClarificationPayload, type CompleteDelegateAgentInput, type CompleteDelegateTokenInput, type ConfirmLoginOptions, type ConfirmLoginResult, 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, type OpenLoginOptions, type OpenLoginResult, Qoni, 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 RunBrowserLiveUrlChangedData, 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 };
|