@qoniai/qoni 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +13 -0
- package/README.zh-CN.md +11 -0
- package/dist/index.cjs +35 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +35 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -739,6 +739,15 @@ interface SnapshotAction {
|
|
|
739
739
|
interface RunLimits {
|
|
740
740
|
maxDurationMinutes?: number;
|
|
741
741
|
}
|
|
742
|
+
type BrowserbaseRegion = "us-west-2" | "us-east-1" | "eu-central-1" | "ap-southeast-1";
|
|
743
|
+
interface BrowserProxyOptions {
|
|
744
|
+
/** Server-side proxy registry id. Credentials never enter the SDK call. */
|
|
745
|
+
proxyId?: string;
|
|
746
|
+
/** `off` uses datacenter egress; `all` proxies all requests; `scoped` uses admin patterns. */
|
|
747
|
+
mode?: "off" | "all" | "scoped";
|
|
748
|
+
/** Browserbase compute region. This is separate from the proxy's IP geography. */
|
|
749
|
+
region?: BrowserbaseRegion;
|
|
750
|
+
}
|
|
742
751
|
interface DoAnythingRunOptions {
|
|
743
752
|
/** Delegation token — passed once here; the returned handle holds it. */
|
|
744
753
|
token: string;
|
|
@@ -752,6 +761,8 @@ interface DoAnythingRunOptions {
|
|
|
752
761
|
*/
|
|
753
762
|
session?: SessionRef;
|
|
754
763
|
profileId?: string;
|
|
764
|
+
/** Applies when this run creates a new Browserbase session. */
|
|
765
|
+
browserProxy?: BrowserProxyOptions;
|
|
755
766
|
keepAlive?: boolean;
|
|
756
767
|
allowedActions?: string[];
|
|
757
768
|
skills?: string[];
|
|
@@ -1242,7 +1253,6 @@ declare class Qoni {
|
|
|
1242
1253
|
private readonly secretKey;
|
|
1243
1254
|
private readonly host;
|
|
1244
1255
|
private runtimeConfigPromise?;
|
|
1245
|
-
private readonly productTokenCache;
|
|
1246
1256
|
private genAuthAdminTokenCache?;
|
|
1247
1257
|
readonly gumem: ReturnType<typeof createGumemNamespace>;
|
|
1248
1258
|
readonly genauth: ReturnType<typeof createGenAuthNamespace>;
|
|
@@ -1384,4 +1394,4 @@ declare const QoniScopeBundles: {
|
|
|
1384
1394
|
readonly TRACK: readonly ["webagent.track:read", "webagent.track:manage"];
|
|
1385
1395
|
};
|
|
1386
1396
|
|
|
1387
|
-
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, 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 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 };
|
|
1397
|
+
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 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
|
@@ -739,6 +739,15 @@ interface SnapshotAction {
|
|
|
739
739
|
interface RunLimits {
|
|
740
740
|
maxDurationMinutes?: number;
|
|
741
741
|
}
|
|
742
|
+
type BrowserbaseRegion = "us-west-2" | "us-east-1" | "eu-central-1" | "ap-southeast-1";
|
|
743
|
+
interface BrowserProxyOptions {
|
|
744
|
+
/** Server-side proxy registry id. Credentials never enter the SDK call. */
|
|
745
|
+
proxyId?: string;
|
|
746
|
+
/** `off` uses datacenter egress; `all` proxies all requests; `scoped` uses admin patterns. */
|
|
747
|
+
mode?: "off" | "all" | "scoped";
|
|
748
|
+
/** Browserbase compute region. This is separate from the proxy's IP geography. */
|
|
749
|
+
region?: BrowserbaseRegion;
|
|
750
|
+
}
|
|
742
751
|
interface DoAnythingRunOptions {
|
|
743
752
|
/** Delegation token — passed once here; the returned handle holds it. */
|
|
744
753
|
token: string;
|
|
@@ -752,6 +761,8 @@ interface DoAnythingRunOptions {
|
|
|
752
761
|
*/
|
|
753
762
|
session?: SessionRef;
|
|
754
763
|
profileId?: string;
|
|
764
|
+
/** Applies when this run creates a new Browserbase session. */
|
|
765
|
+
browserProxy?: BrowserProxyOptions;
|
|
755
766
|
keepAlive?: boolean;
|
|
756
767
|
allowedActions?: string[];
|
|
757
768
|
skills?: string[];
|
|
@@ -1242,7 +1253,6 @@ declare class Qoni {
|
|
|
1242
1253
|
private readonly secretKey;
|
|
1243
1254
|
private readonly host;
|
|
1244
1255
|
private runtimeConfigPromise?;
|
|
1245
|
-
private readonly productTokenCache;
|
|
1246
1256
|
private genAuthAdminTokenCache?;
|
|
1247
1257
|
readonly gumem: ReturnType<typeof createGumemNamespace>;
|
|
1248
1258
|
readonly genauth: ReturnType<typeof createGenAuthNamespace>;
|
|
@@ -1384,4 +1394,4 @@ declare const QoniScopeBundles: {
|
|
|
1384
1394
|
readonly TRACK: readonly ["webagent.track:read", "webagent.track:manage"];
|
|
1385
1395
|
};
|
|
1386
1396
|
|
|
1387
|
-
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, 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 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 };
|
|
1397
|
+
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 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.js
CHANGED
|
@@ -1146,6 +1146,34 @@ var PLATFORM_DECIDED_RUN_OPTIONS = [
|
|
|
1146
1146
|
"outputSchema",
|
|
1147
1147
|
"cacheScript"
|
|
1148
1148
|
];
|
|
1149
|
+
var BROWSERBASE_REGIONS = /* @__PURE__ */ new Set([
|
|
1150
|
+
"us-west-2",
|
|
1151
|
+
"us-east-1",
|
|
1152
|
+
"eu-central-1",
|
|
1153
|
+
"ap-southeast-1"
|
|
1154
|
+
]);
|
|
1155
|
+
function validateBrowserProxyOptions(value) {
|
|
1156
|
+
if (value === void 0) return;
|
|
1157
|
+
if (!isJsonObject(value)) {
|
|
1158
|
+
throw new QoniValidationError("browserProxy must be an object");
|
|
1159
|
+
}
|
|
1160
|
+
const allowed = /* @__PURE__ */ new Set(["proxyId", "mode", "region"]);
|
|
1161
|
+
const extras = Object.keys(value).filter((key) => !allowed.has(key));
|
|
1162
|
+
if (extras.length > 0) {
|
|
1163
|
+
throw new QoniValidationError(
|
|
1164
|
+
`browserProxy does not accept ${extras.join(", ")} \u2014 credentials stay server-side`
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
if (value.proxyId !== void 0 && (typeof value.proxyId !== "string" || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(value.proxyId))) {
|
|
1168
|
+
throw new QoniValidationError("browserProxy.proxyId is invalid");
|
|
1169
|
+
}
|
|
1170
|
+
if (value.mode !== void 0 && !["off", "all", "scoped"].includes(String(value.mode))) {
|
|
1171
|
+
throw new QoniValidationError("browserProxy.mode must be off, all, or scoped");
|
|
1172
|
+
}
|
|
1173
|
+
if (value.region !== void 0 && (typeof value.region !== "string" || !BROWSERBASE_REGIONS.has(value.region))) {
|
|
1174
|
+
throw new QoniValidationError("browserProxy.region is not supported");
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1149
1177
|
function createDoAnythingNamespace(transport) {
|
|
1150
1178
|
const api = {
|
|
1151
1179
|
createSession: (input) => transport.webAgentJson("POST", "/do_anything/sessions", input.token, {
|
|
@@ -1308,6 +1336,7 @@ function createDoAnythingNamespace(transport) {
|
|
|
1308
1336
|
if (!prompt || typeof prompt !== "string") {
|
|
1309
1337
|
throw new QoniValidationError("doAnything.run requires a prompt string");
|
|
1310
1338
|
}
|
|
1339
|
+
validateBrowserProxyOptions(rest.browserProxy);
|
|
1311
1340
|
const unsupported = PLATFORM_DECIDED_RUN_OPTIONS.filter(
|
|
1312
1341
|
(key) => rest[key] !== void 0
|
|
1313
1342
|
);
|
|
@@ -1359,8 +1388,13 @@ function normalizeDoAnythingRunInput(input) {
|
|
|
1359
1388
|
profileId: "profile_id",
|
|
1360
1389
|
keepAlive: "keep_alive",
|
|
1361
1390
|
allowedActions: "allowed_actions",
|
|
1362
|
-
maxDurationMinutes: "max_duration_minutes"
|
|
1391
|
+
maxDurationMinutes: "max_duration_minutes",
|
|
1392
|
+
browserProxy: "browser_proxy"
|
|
1363
1393
|
});
|
|
1394
|
+
const browserProxy = body.browser_proxy;
|
|
1395
|
+
if (isJsonObject(browserProxy)) {
|
|
1396
|
+
body.browser_proxy = renameKeys2(browserProxy, { proxyId: "proxy_id" });
|
|
1397
|
+
}
|
|
1364
1398
|
return body;
|
|
1365
1399
|
}
|
|
1366
1400
|
function normalizeDoAnythingInterveneInput(input) {
|
|
@@ -2032,7 +2066,6 @@ var Qoni = class {
|
|
|
2032
2066
|
secretKey;
|
|
2033
2067
|
host;
|
|
2034
2068
|
runtimeConfigPromise;
|
|
2035
|
-
productTokenCache = /* @__PURE__ */ new Map();
|
|
2036
2069
|
genAuthAdminTokenCache;
|
|
2037
2070
|
gumem;
|
|
2038
2071
|
genauth;
|
|
@@ -2503,9 +2536,6 @@ var Qoni = class {
|
|
|
2503
2536
|
const runtimeToken = requiredRuntimeToken(token);
|
|
2504
2537
|
if (!isQoniDelegationToken(runtimeToken)) return runtimeToken;
|
|
2505
2538
|
const scopes = [...requiredScopes || []].sort();
|
|
2506
|
-
const cacheKey = [service, runtimeToken, scopes.join(" ")].join(":");
|
|
2507
|
-
const cached = this.productTokenCache.get(cacheKey);
|
|
2508
|
-
if (cached && cached.expiresAt > Date.now() + 3e4) return cached.token;
|
|
2509
2539
|
const response = await this.signedPost("/api/v3/eak/token-exchange", {
|
|
2510
2540
|
subjectToken: runtimeToken,
|
|
2511
2541
|
resource: service === "gumem" ? "gumem" : "webagent",
|
|
@@ -2520,10 +2550,6 @@ var Qoni = class {
|
|
|
2520
2550
|
"Qoni product token exchange response did not include an access token"
|
|
2521
2551
|
);
|
|
2522
2552
|
}
|
|
2523
|
-
this.productTokenCache.set(cacheKey, {
|
|
2524
|
-
token: accessToken,
|
|
2525
|
-
expiresAt: Date.now() + Math.max(0, readExpiresIn(payload) ?? 3600) * 1e3
|
|
2526
|
-
});
|
|
2527
2553
|
return accessToken;
|
|
2528
2554
|
}
|
|
2529
2555
|
async genauthAdminTokenFor() {
|