@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.50
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/AUTHORING.md +537 -33
- package/CHANGELOG.md +201 -1
- package/README.md +83 -22
- package/SUBMISSION.md +2 -2
- package/bin/apifuse-check.ts +165 -11
- package/bin/apifuse-dev.ts +57 -13
- package/bin/apifuse-migrate-operation-declaration.ts +55 -0
- package/bin/apifuse-migrate-shape.ts +202 -0
- package/bin/apifuse-pack-check.ts +22 -2
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +357 -38
- package/bin/apifuse-perf.ts +14 -13
- package/bin/apifuse-record.ts +709 -72
- package/bin/apifuse-submit-check.ts +2344 -324
- package/bin/apifuse-sync-assets.ts +117 -0
- package/bin/submit-check-delimited-text.ts +50 -0
- package/dist/auth-turn/index.d.ts +3 -3
- package/dist/auth-turn/index.js +1 -1
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +67 -0
- package/dist/ceremonies/index.d.ts +16 -0
- package/dist/ceremonies/index.js +141 -36
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +27 -0
- package/dist/cli/create.d.ts +4 -1
- package/dist/cli/create.js +42 -37
- package/dist/cli/migrate-operation-declaration.d.ts +59 -0
- package/dist/cli/migrate-operation-declaration.js +1178 -0
- package/dist/cli/migrate-operation-shape.d.ts +44 -0
- package/dist/cli/migrate-operation-shape.js +113 -0
- package/dist/cli/migrate-provider-shape.d.ts +52 -0
- package/dist/cli/migrate-provider-shape.js +578 -0
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
- package/dist/cli/templates/provider/README.md.tpl +5 -5
- package/dist/cli/templates/provider/index.ts.tpl +6 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/dist/cli/templates/provider/provider.json.tpl +6 -0
- package/dist/config/loader.d.ts +179 -16
- package/dist/config/loader.js +435 -127
- package/dist/contract-serialization.js +4 -8
- package/dist/contract-types.d.ts +12 -5
- package/dist/contract.js +24 -10
- package/dist/declaration-validation.d.ts +33 -0
- package/dist/declaration-validation.js +266 -0
- package/dist/define.d.ts +66 -29
- package/dist/define.js +778 -69
- package/dist/dev.d.ts +3 -0
- package/dist/dev.js +1 -1
- package/dist/engine.d.ts +78 -0
- package/dist/engine.js +133 -0
- package/dist/error-observability.d.ts +7 -0
- package/dist/error-observability.js +61 -0
- package/dist/error-resolution.d.ts +4 -0
- package/dist/error-resolution.js +122 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +40 -0
- package/dist/fixture-sanitization.d.ts +28 -0
- package/dist/fixture-sanitization.js +227 -0
- package/dist/health-scenario.d.ts +1842 -0
- package/dist/health-scenario.js +624 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.js +12 -7
- package/dist/lint.d.ts +23 -11
- package/dist/lint.js +572 -69
- package/dist/native-address.d.ts +43 -0
- package/dist/native-address.js +281 -0
- package/dist/native-egress-policy.d.ts +31 -0
- package/dist/native-egress-policy.js +288 -0
- package/dist/observability.d.ts +5 -2
- package/dist/observability.js +48 -1
- package/dist/provider.d.ts +10 -2
- package/dist/provider.js +4 -1
- package/dist/runtime/auth-flow.d.ts +5 -1
- package/dist/runtime/auth-flow.js +6 -0
- package/dist/runtime/browser.d.ts +1 -0
- package/dist/runtime/browser.js +492 -49
- package/dist/runtime/cache.d.ts +1 -0
- package/dist/runtime/cache.js +169 -15
- package/dist/runtime/choice-wordlist.d.ts +9 -0
- package/dist/runtime/choice-wordlist.js +138 -0
- package/dist/runtime/choice.d.ts +13 -1
- package/dist/runtime/choice.js +490 -102
- package/dist/runtime/chrome149-header-order.d.ts +58 -0
- package/dist/runtime/chrome149-header-order.js +289 -0
- package/dist/runtime/env.js +12 -0
- package/dist/runtime/executor.d.ts +3 -2
- package/dist/runtime/executor.js +26 -25
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +515 -53
- package/dist/runtime/insights.js +2 -2
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +366 -8
- package/dist/runtime/native-network-errors.d.ts +33 -0
- package/dist/runtime/native-network-errors.js +69 -0
- package/dist/runtime/native-network.d.ts +96 -0
- package/dist/runtime/native-network.js +1232 -0
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +440 -0
- package/dist/runtime/otlp.d.ts +71 -2
- package/dist/runtime/otlp.js +397 -16
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +146 -0
- package/dist/runtime/proxy-telemetry.d.ts +80 -1
- package/dist/runtime/proxy-telemetry.js +154 -47
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/request-options.d.ts +68 -1
- package/dist/runtime/request-options.js +548 -0
- package/dist/runtime/resolver-config.d.ts +6 -0
- package/dist/runtime/resolver-config.js +6 -0
- package/dist/runtime/resolver-public.d.ts +1 -0
- package/dist/runtime/resolver-public.js +1 -0
- package/dist/runtime/resolver-shared.d.ts +14 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
- package/dist/runtime/resolver-vendors/bindings.js +40 -0
- package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
- package/dist/runtime/resolver-vendors/browser.js +377 -0
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +531 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
- package/dist/runtime/resolver-vendors/hosts.js +33 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +408 -0
- package/dist/runtime/resolver-vendors/types.d.ts +94 -0
- package/dist/runtime/resolver-vendors/types.js +96 -0
- package/dist/runtime/resolver.d.ts +72 -0
- package/dist/runtime/resolver.js +771 -0
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +277 -71
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.d.ts +41 -5
- package/dist/runtime/stealth.js +997 -291
- package/dist/runtime/stt.js +1 -12
- package/dist/runtime/timeout.d.ts +5 -0
- package/dist/runtime/timeout.js +12 -0
- package/dist/runtime/trace-config.d.ts +12 -0
- package/dist/runtime/trace-config.js +62 -0
- package/dist/runtime/trace.d.ts +5 -0
- package/dist/runtime/trace.js +43 -10
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/error-observability.d.ts +1 -0
- package/dist/server/error-observability.js +1 -0
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.js +2 -2
- package/dist/server/self-test-input-tokens.d.ts +2 -1
- package/dist/server/self-test-input-tokens.js +18 -14
- package/dist/server/self-test.d.ts +14 -3
- package/dist/server/self-test.js +129 -58
- package/dist/server/serve-implementation.d.ts +230 -0
- package/dist/server/serve-implementation.js +2265 -0
- package/dist/server/serve.d.ts +1 -70
- package/dist/server/serve.js +1 -1131
- package/dist/server/trace-output.d.ts +6 -0
- package/dist/server/trace-output.js +79 -0
- package/dist/server/types.d.ts +30 -5
- package/dist/server/types.js +13 -1
- package/dist/stateful/errors.d.ts +19 -0
- package/dist/stateful/errors.js +24 -0
- package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
- package/dist/stateful/http-provider-event-emitter.js +237 -0
- package/dist/stateful/http-session-owner-registry.d.ts +44 -0
- package/dist/stateful/http-session-owner-registry.js +210 -0
- package/dist/stateful/index.d.ts +18 -0
- package/dist/stateful/index.js +18 -0
- package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
- package/dist/stateful/provider-event-delivery-failures.js +43 -0
- package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
- package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
- package/dist/stateful/provider-event-pipeline.d.ts +50 -0
- package/dist/stateful/provider-event-pipeline.js +1 -0
- package/dist/stateful/provider-events.d.ts +101 -0
- package/dist/stateful/provider-events.js +289 -0
- package/dist/stateful/session-key.d.ts +15 -0
- package/dist/stateful/session-key.js +86 -0
- package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
- package/dist/stateful/stateful-provider-adapter-context.js +42 -0
- package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
- package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
- package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
- package/dist/stateful/stateful-provider-adapter.js +287 -0
- package/dist/stateful/stateful-provider-observability.d.ts +62 -0
- package/dist/stateful/stateful-provider-observability.js +161 -0
- package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
- package/dist/stateful/stateful-provider-runtime-context.js +60 -0
- package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
- package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
- package/dist/stateful/stateful-provider-session-routing.js +345 -0
- package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
- package/dist/stateful/stateful-provider-session-runtime.js +245 -0
- package/dist/stateful-signing.d.ts +18 -0
- package/dist/stateful-signing.js +27 -0
- package/dist/stealth/profiles.d.ts +9 -4
- package/dist/stealth/profiles.js +160 -211
- package/dist/stream-evidence.d.ts +74 -0
- package/dist/stream-evidence.js +785 -0
- package/dist/stream.js +7 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/run.d.ts +32 -2
- package/dist/testing/run.js +489 -21
- package/dist/trace-sanitization.d.ts +5 -0
- package/dist/trace-sanitization.js +45 -0
- package/dist/types.d.ts +673 -131
- package/dist/types.js +1 -0
- package/package.json +45 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +118 -0
- package/src/ceremonies/index.ts +189 -46
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +10 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +8 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +16 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +31 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +21 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +14 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +15 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +4 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +12 -0
- package/src/cli/commands.ts +33 -0
- package/src/cli/create.ts +50 -37
- package/src/cli/migrate-operation-declaration.ts +1654 -0
- package/src/cli/migrate-operation-shape.ts +184 -0
- package/src/cli/migrate-provider-shape.ts +772 -0
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/cli/templates/provider/Dockerfile.tpl +1 -1
- package/src/cli/templates/provider/README.md.tpl +5 -5
- package/src/cli/templates/provider/index.ts.tpl +6 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/src/cli/templates/provider/provider.json.tpl +6 -0
- package/src/config/loader.ts +690 -163
- package/src/contract-serialization.ts +5 -7
- package/src/contract-types.ts +12 -5
- package/src/contract.ts +24 -10
- package/src/declaration-validation.ts +330 -0
- package/src/define.ts +1048 -131
- package/src/dev.ts +4 -1
- package/src/engine.ts +279 -0
- package/src/error-observability.ts +64 -0
- package/src/error-resolution.ts +127 -0
- package/src/errors.ts +68 -0
- package/src/fixture-sanitization.ts +264 -0
- package/src/health-scenario.ts +875 -0
- package/src/index.ts +220 -13
- package/src/lint.ts +698 -90
- package/src/native-address.ts +340 -0
- package/src/native-egress-policy.ts +358 -0
- package/src/observability.ts +51 -1
- package/src/provider.ts +161 -3
- package/src/runtime/auth-flow.ts +12 -0
- package/src/runtime/browser.ts +661 -63
- package/src/runtime/cache.ts +189 -14
- package/src/runtime/choice-wordlist.ts +145 -0
- package/src/runtime/choice.ts +631 -120
- package/src/runtime/chrome149-header-order.ts +330 -0
- package/src/runtime/env.ts +13 -0
- package/src/runtime/executor.ts +43 -31
- package/src/runtime/http.ts +641 -61
- package/src/runtime/insights.ts +2 -2
- package/src/runtime/instrumentation.ts +520 -15
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +1605 -0
- package/src/runtime/ocr.ts +523 -0
- package/src/runtime/otlp.ts +467 -21
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +221 -0
- package/src/runtime/proxy-telemetry.ts +244 -75
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/request-options.ts +680 -1
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-public.ts +23 -0
- package/src/runtime/resolver-shared.ts +33 -0
- package/src/runtime/resolver-vendors/bindings.ts +56 -0
- package/src/runtime/resolver-vendors/browser.ts +533 -0
- package/src/runtime/resolver-vendors/capsolver.ts +707 -0
- package/src/runtime/resolver-vendors/hosts.ts +38 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +540 -0
- package/src/runtime/resolver-vendors/types.ts +212 -0
- package/src/runtime/resolver.ts +1157 -0
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +394 -77
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +1280 -336
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +78 -0
- package/src/runtime/trace.ts +57 -17
- package/src/serve.ts +6 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/index.ts +34 -2
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test.ts +191 -68
- package/src/server/serve-implementation.ts +3378 -0
- package/src/server/serve.ts +1 -1632
- package/src/server/trace-output.ts +129 -0
- package/src/server/types.ts +13 -1
- package/src/stateful/README.md +146 -0
- package/src/stateful/errors.ts +35 -0
- package/src/stateful/http-provider-event-emitter.ts +314 -0
- package/src/stateful/http-session-owner-registry.ts +306 -0
- package/src/stateful/index.ts +18 -0
- package/src/stateful/provider-event-delivery-failures.ts +80 -0
- package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
- package/src/stateful/provider-event-pipeline.ts +61 -0
- package/src/stateful/provider-events.ts +462 -0
- package/src/stateful/session-key.ts +111 -0
- package/src/stateful/stateful-provider-adapter-context.ts +59 -0
- package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
- package/src/stateful/stateful-provider-adapter.ts +562 -0
- package/src/stateful/stateful-provider-observability.ts +261 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
- package/src/stateful/stateful-provider-runtime-context.ts +92 -0
- package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
- package/src/stateful/stateful-provider-session-routing.ts +546 -0
- package/src/stateful/stateful-provider-session-runtime.ts +403 -0
- package/src/stateful-signing.ts +46 -0
- package/src/stealth/profiles.ts +202 -231
- package/src/stream-evidence.ts +988 -0
- package/src/stream.ts +8 -1
- package/src/testing/index.ts +10 -1
- package/src/testing/run.ts +658 -15
- package/src/trace-sanitization.ts +63 -0
- package/src/types.ts +788 -174
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type ms from "ms";
|
|
2
|
+
import type { HealthScenario } from "./health-scenario.js";
|
|
3
|
+
import type { SerializedCookieJar } from "tough-cookie";
|
|
2
4
|
import type { infer as ZodInfer, ZodType } from "zod";
|
|
3
5
|
/** Minimal Standard Schema v1 shape accepted by provider operations. */
|
|
4
6
|
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
@@ -32,25 +34,13 @@ export declare namespace StandardSchemaV1 {
|
|
|
32
34
|
export type SchemaLike = ZodType | StandardSchemaV1;
|
|
33
35
|
/** Infer the validated output type produced by a Zod or Standard Schema. */
|
|
34
36
|
export type InferSchemaOutput<TSchema extends SchemaLike> = TSchema extends ZodType ? ZodInfer<TSchema> : TSchema extends StandardSchemaV1<unknown, infer Output> ? Output : unknown;
|
|
35
|
-
export interface
|
|
36
|
-
|
|
37
|
+
export interface OperationExample {
|
|
38
|
+
scenarioKey: ProviderLocaleKeyInput;
|
|
37
39
|
input: unknown;
|
|
38
|
-
|
|
40
|
+
rationaleKey?: ProviderLocaleKeyInput;
|
|
39
41
|
}
|
|
40
42
|
export type OperationRiskClass = "read" | "write" | "destructive" | "external-send";
|
|
41
43
|
export type OperationApprovalPolicy = "never" | "risk-based" | "always";
|
|
42
|
-
export interface OperationToolRouterMetadata {
|
|
43
|
-
/** Optional MCP-safe override. Defaults to providerId__operationId. */
|
|
44
|
-
name?: string;
|
|
45
|
-
/** Safety class exposed to Tool Router clients and approval policy. */
|
|
46
|
-
riskClass?: OperationRiskClass;
|
|
47
|
-
/** OpenAI remote-MCP approval hint. Defaults from riskClass. */
|
|
48
|
-
approval?: OperationApprovalPolicy;
|
|
49
|
-
/** Override connection requirement when provider auth + openWorld inference is insufficient. */
|
|
50
|
-
requiresConnection?: boolean;
|
|
51
|
-
/** Public argument used to resolve the tenant-owned connection. Defaults to externalRef. */
|
|
52
|
-
connectionExternalRefParam?: string;
|
|
53
|
-
}
|
|
54
44
|
export type OperationSensitivePath = string;
|
|
55
45
|
export interface OperationObservabilitySensitiveConfig {
|
|
56
46
|
/**
|
|
@@ -72,37 +62,6 @@ export interface OperationObservabilityConfig {
|
|
|
72
62
|
*/
|
|
73
63
|
sensitive?: OperationObservabilitySensitiveConfig;
|
|
74
64
|
}
|
|
75
|
-
export interface OperationAnnotations {
|
|
76
|
-
readOnly?: boolean;
|
|
77
|
-
destructive?: boolean;
|
|
78
|
-
idempotent?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Marks the operation as callable without provider-level authentication.
|
|
81
|
-
*
|
|
82
|
-
* Provider-level `auth.mode` describes the **majority** auth model of a
|
|
83
|
-
* provider; individual operations can still opt out via `openWorld: true`
|
|
84
|
-
* when their handler does not consume `ctx.credential`. This is the
|
|
85
|
-
* canonical way to declare "this operation is public, even though the
|
|
86
|
-
* provider is `credentials`-mode" without splitting the provider into two.
|
|
87
|
-
*
|
|
88
|
-
* Health-check projections treat `openWorld: true` operations as
|
|
89
|
-
* connection-free probes (no `requiresConnection` required, no SA token
|
|
90
|
-
* lookup). Future gateway work MAY extend this annotation to bypass
|
|
91
|
-
* `X-ApiFuse-Connection-Id` enforcement at proxy time.
|
|
92
|
-
*
|
|
93
|
-
* Example: Naver Map's `search`, `geocode`, and directions operations
|
|
94
|
-
* call public Naver endpoints with no cookies, while `collections` and
|
|
95
|
-
* `export` consume the user's session cookie — the provider declares
|
|
96
|
-
* `auth.mode: "credentials"` (for the latter) and the former mark
|
|
97
|
-
* `openWorld: true`.
|
|
98
|
-
*/
|
|
99
|
-
openWorld?: boolean;
|
|
100
|
-
rateLimit?: {
|
|
101
|
-
calls: number;
|
|
102
|
-
window: "minute" | "hour" | "day";
|
|
103
|
-
};
|
|
104
|
-
timeoutMs?: number;
|
|
105
|
-
}
|
|
106
65
|
export declare const OPERATION_TIMEOUT_MS_MIN = 1;
|
|
107
66
|
export declare const OPERATION_TIMEOUT_MS_MAX = 60000;
|
|
108
67
|
export declare const STREAM_HEARTBEAT_MS_MIN = 1000;
|
|
@@ -193,6 +152,54 @@ export interface SmsOtpMatcherDefinition {
|
|
|
193
152
|
/** Runtime/fixture helper. Not serialized into generated registry artifacts. */
|
|
194
153
|
extractOtp(body: string): string | null;
|
|
195
154
|
}
|
|
155
|
+
export interface ProviderOcrConfig {
|
|
156
|
+
readonly mode: "required" | "optional";
|
|
157
|
+
}
|
|
158
|
+
export type OcrImageInput = {
|
|
159
|
+
readonly kind: "base64";
|
|
160
|
+
readonly data: string;
|
|
161
|
+
readonly mediaType?: string;
|
|
162
|
+
} | {
|
|
163
|
+
readonly kind: "url";
|
|
164
|
+
readonly url: string;
|
|
165
|
+
};
|
|
166
|
+
export interface OcrRecognizeRequest {
|
|
167
|
+
readonly image: OcrImageInput;
|
|
168
|
+
readonly hint?: "captcha" | "document" | "generic";
|
|
169
|
+
readonly prompt?: string;
|
|
170
|
+
readonly maxTokens?: number;
|
|
171
|
+
readonly timeoutMs?: number;
|
|
172
|
+
}
|
|
173
|
+
export interface OcrWarning {
|
|
174
|
+
readonly code: string;
|
|
175
|
+
readonly message: string;
|
|
176
|
+
}
|
|
177
|
+
export interface OcrResult {
|
|
178
|
+
readonly text: string;
|
|
179
|
+
readonly model: string;
|
|
180
|
+
readonly warnings?: readonly OcrWarning[];
|
|
181
|
+
}
|
|
182
|
+
export interface OcrCaptchaOptions {
|
|
183
|
+
readonly length?: number;
|
|
184
|
+
/** Allowed characters. A RegExp is applied to each character, not to the whole text. */
|
|
185
|
+
readonly charset?: string | RegExp;
|
|
186
|
+
readonly caseSensitive?: boolean;
|
|
187
|
+
readonly maxCandidates?: number;
|
|
188
|
+
}
|
|
189
|
+
export interface OcrCaptchaCandidate {
|
|
190
|
+
readonly text: string;
|
|
191
|
+
readonly satisfiesConstraints: boolean;
|
|
192
|
+
}
|
|
193
|
+
export interface OcrCaptchaResult {
|
|
194
|
+
readonly text: string;
|
|
195
|
+
readonly candidates: readonly OcrCaptchaCandidate[];
|
|
196
|
+
readonly satisfiesConstraints: boolean;
|
|
197
|
+
readonly model: string;
|
|
198
|
+
}
|
|
199
|
+
export interface OcrContext {
|
|
200
|
+
recognize(request: OcrRecognizeRequest): Promise<OcrResult>;
|
|
201
|
+
extractCaptchaText(image: OcrImageInput, options?: OcrCaptchaOptions): Promise<OcrCaptchaResult>;
|
|
202
|
+
}
|
|
196
203
|
export type SttTranscribeMode = "general" | "otp";
|
|
197
204
|
export type SttPromptPolicy = "none" | "default-hint" | "custom-hint";
|
|
198
205
|
export type SttUnsupportedOptionPolicy = "warn" | "error";
|
|
@@ -200,6 +207,111 @@ export type ProviderSttMode = "optional" | "required";
|
|
|
200
207
|
export interface ProviderSttConfig {
|
|
201
208
|
mode: ProviderSttMode;
|
|
202
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Union order is documentation only.
|
|
212
|
+
*
|
|
213
|
+
* The SDK owns the default hosted-vendor fallback policy and derives the chain
|
|
214
|
+
* from each provider's declared challenge kinds. Hosted solvers are preferred
|
|
215
|
+
* with `capsolver` ahead of `2captcha` in that policy.
|
|
216
|
+
*
|
|
217
|
+
* `browser` is the in-house CDP pool and remains opt-in; it is excluded from the
|
|
218
|
+
* default chain. `custom` is likewise reserved for provider-specific configuration.
|
|
219
|
+
*
|
|
220
|
+
* `ProviderResolverConfig.vendors` overrides the SDK policy when declared.
|
|
221
|
+
*/
|
|
222
|
+
export type ProviderResolverVendor = "browser" | "capsolver" | "capmonster" | "2captcha" | "custom";
|
|
223
|
+
/**
|
|
224
|
+
* Token-family kinds resolve to `{ form: "token" }`. Cookie-family kinds resolve
|
|
225
|
+
* to `{ form: "cookies" }`; network-identity binding is defined per kind. `aws_waf`
|
|
226
|
+
* was measured portable across residential leases on buyee, while `cf_clearance`
|
|
227
|
+
* remains unmeasured here and is treated as identity-scoped because it is widely
|
|
228
|
+
* described as IP-bound.
|
|
229
|
+
*/
|
|
230
|
+
export type ProviderChallenge = {
|
|
231
|
+
readonly kind: "turnstile";
|
|
232
|
+
readonly siteKey: string;
|
|
233
|
+
readonly pageUrl: string;
|
|
234
|
+
readonly action?: string;
|
|
235
|
+
readonly cdata?: string;
|
|
236
|
+
} | {
|
|
237
|
+
readonly kind: "recaptcha_v2";
|
|
238
|
+
readonly siteKey: string;
|
|
239
|
+
readonly pageUrl: string;
|
|
240
|
+
} | {
|
|
241
|
+
readonly kind: "recaptcha_v3";
|
|
242
|
+
readonly siteKey: string;
|
|
243
|
+
readonly pageUrl: string;
|
|
244
|
+
readonly action: string;
|
|
245
|
+
readonly minScore?: number;
|
|
246
|
+
} | {
|
|
247
|
+
readonly kind: "hcaptcha";
|
|
248
|
+
readonly siteKey: string;
|
|
249
|
+
readonly pageUrl: string;
|
|
250
|
+
} | {
|
|
251
|
+
readonly kind: "cloudflare_interstitial";
|
|
252
|
+
readonly pageUrl: string;
|
|
253
|
+
readonly blockedHtml?: string;
|
|
254
|
+
} | {
|
|
255
|
+
readonly kind: "aws_waf";
|
|
256
|
+
readonly pageUrl: string;
|
|
257
|
+
/** `window.gokuProps.key`; solver vendors require it, while `"browser"` does not. */
|
|
258
|
+
readonly siteKey?: string;
|
|
259
|
+
readonly captchaScript?: string;
|
|
260
|
+
readonly context?: string;
|
|
261
|
+
readonly iv?: string;
|
|
262
|
+
} | {
|
|
263
|
+
readonly kind: "akamai_sec_cpt";
|
|
264
|
+
readonly pageUrl: string;
|
|
265
|
+
/** The admitted challenge document, needed for tile/context extraction. */
|
|
266
|
+
readonly challengeHtml?: string;
|
|
267
|
+
} | {
|
|
268
|
+
readonly kind: "akamai_sensor";
|
|
269
|
+
readonly pageUrl: string;
|
|
270
|
+
/** Upstream sensor script URL the payload must be POSTed to. */
|
|
271
|
+
readonly scriptUrl: string;
|
|
272
|
+
/** Current `_abck` cookie value, rotates each round. */
|
|
273
|
+
readonly abck?: string;
|
|
274
|
+
/** Current `bm_sz` / `ak_bmsc` value when the upstream set one. */
|
|
275
|
+
readonly bmsz?: string;
|
|
276
|
+
/** Bot Manager major version when known ("3" measured on zozo.jp). */
|
|
277
|
+
readonly version?: string;
|
|
278
|
+
};
|
|
279
|
+
export type ProviderChallengeKind = ProviderChallenge["kind"];
|
|
280
|
+
/**
|
|
281
|
+
* Token solutions carry no network-identity binding. Cookie-solution binding is
|
|
282
|
+
* per challenge kind: `aws_waf` was measured portable across residential leases
|
|
283
|
+
* on buyee, while `cf_clearance` is unmeasured here and treated as scoped to the
|
|
284
|
+
* identity that produced it. The provider attaches the returned cookies to its
|
|
285
|
+
* own requests.
|
|
286
|
+
*/
|
|
287
|
+
export type ChallengeSolution = {
|
|
288
|
+
readonly form: "token";
|
|
289
|
+
readonly token: string;
|
|
290
|
+
} | {
|
|
291
|
+
readonly form: "cookies";
|
|
292
|
+
readonly cookies: Readonly<Record<string, string>>;
|
|
293
|
+
readonly userAgent: string;
|
|
294
|
+
/** Epoch seconds copied from the upstream cookie's own expiry attribute; never a constant. */
|
|
295
|
+
readonly expires?: number;
|
|
296
|
+
/**
|
|
297
|
+
* Epoch seconds conservatively estimated by the SDK when a resolver vendor omits
|
|
298
|
+
* the upstream cookie's expiry. `expires` takes precedence when both are present.
|
|
299
|
+
*/
|
|
300
|
+
readonly sdkEstimatedExpires?: number;
|
|
301
|
+
};
|
|
302
|
+
export interface ProviderResolverConfig {
|
|
303
|
+
/** Optional ordered override for the SDK-owned vendor fallback chain. */
|
|
304
|
+
readonly vendors?: readonly ProviderResolverVendor[];
|
|
305
|
+
/** Challenge kinds this provider is permitted to request. */
|
|
306
|
+
readonly kinds: readonly ProviderChallengeKind[];
|
|
307
|
+
/**
|
|
308
|
+
* Client fingerprint profile the SDK must use when reaching this upstream.
|
|
309
|
+
* Measured on zozo.jp: Chrome/Firefox profiles are refused 403 before any
|
|
310
|
+
* challenge is served, while a Safari profile is admitted. Provider-declared
|
|
311
|
+
* because only the provider knows its upstream's admission rule.
|
|
312
|
+
*/
|
|
313
|
+
readonly clientProfile?: string;
|
|
314
|
+
}
|
|
203
315
|
export type SttAudioInput = {
|
|
204
316
|
kind: "base64";
|
|
205
317
|
data: string;
|
|
@@ -264,6 +376,9 @@ export interface SttContext {
|
|
|
264
376
|
transcribe(request: SttTranscribeRequest): Promise<SttTranscript>;
|
|
265
377
|
extractVerificationCode(text: string, options?: SttVerificationCodeOptions): VerificationCodeExtractionResult;
|
|
266
378
|
}
|
|
379
|
+
export interface ResolverContext {
|
|
380
|
+
solve(challenge: ProviderChallenge, signal?: AbortSignal): Promise<ChallengeSolution>;
|
|
381
|
+
}
|
|
267
382
|
export interface HealthJourneySchedule {
|
|
268
383
|
kind: "interval";
|
|
269
384
|
/** ISO 8601 duration, for example PT8H. */
|
|
@@ -395,7 +510,7 @@ export interface HealthJourneyRunResult {
|
|
|
395
510
|
label?: string;
|
|
396
511
|
metadata?: Record<string, unknown>;
|
|
397
512
|
}
|
|
398
|
-
|
|
513
|
+
interface HealthJourneyDefinitionBase {
|
|
399
514
|
id: string;
|
|
400
515
|
title?: string;
|
|
401
516
|
description?: string;
|
|
@@ -407,8 +522,14 @@ export interface HealthJourneyDefinition {
|
|
|
407
522
|
requiredSecrets?: readonly string[];
|
|
408
523
|
manualTrigger?: HealthJourneyManualTriggerPolicy;
|
|
409
524
|
steps: readonly [HealthJourneyStep, ...HealthJourneyStep[]];
|
|
410
|
-
run?: (ctx: HealthJourneyRunContext) => Promise<HealthJourneyRunResult | undefined>;
|
|
411
525
|
}
|
|
526
|
+
export type HealthJourneyDefinition = HealthJourneyDefinitionBase & ({
|
|
527
|
+
run: (ctx: HealthJourneyRunContext) => Promise<HealthJourneyRunResult | undefined>;
|
|
528
|
+
scenario?: never;
|
|
529
|
+
} | {
|
|
530
|
+
scenario: HealthScenario;
|
|
531
|
+
run?: never;
|
|
532
|
+
});
|
|
412
533
|
/**
|
|
413
534
|
* Health-check authoring surface owned by `@apifuse/provider-sdk`.
|
|
414
535
|
*
|
|
@@ -479,13 +600,22 @@ export interface HealthCheckCaseResult {
|
|
|
479
600
|
* so authors get IntelliSense and compile-time errors when accessing fields
|
|
480
601
|
* that do not exist on the operation's declared output schema.
|
|
481
602
|
*/
|
|
482
|
-
export
|
|
603
|
+
export type HealthCheckCase<TInput = unknown, TOutput = unknown> = {
|
|
483
604
|
/** Human-readable case name; unique within the suite. */
|
|
484
605
|
name: string;
|
|
485
606
|
/** Optional longer description shown on ops dashboards. */
|
|
486
607
|
description?: string;
|
|
487
608
|
/** Input passed to the operation handler for this case. */
|
|
488
609
|
input: TInput;
|
|
610
|
+
/** Override per-case degradation threshold (ms); falls back to the suite default. */
|
|
611
|
+
degradedThresholdMs?: number;
|
|
612
|
+
/** Override per-case timeout in milliseconds; falls back to the suite/provider/runtime default. */
|
|
613
|
+
timeoutMs?: number;
|
|
614
|
+
/** Expected outcome for "negative" cases (e.g., expecting a degraded baseline). Default: `"ok"`. */
|
|
615
|
+
expectedStatus?: "ok" | "degraded";
|
|
616
|
+
/** Runtime gate (env-driven); if returns false the case is skipped & logged. */
|
|
617
|
+
enabled?: () => boolean;
|
|
618
|
+
} & ({
|
|
489
619
|
/**
|
|
490
620
|
* Optional runtime input preparation hook for volatile probes. Use this when
|
|
491
621
|
* the durable probe input must be derived from a live read-only operation
|
|
@@ -503,15 +633,14 @@ export interface HealthCheckCase<TInput = unknown, TOutput = unknown> {
|
|
|
503
633
|
* + lambda only.
|
|
504
634
|
*/
|
|
505
635
|
assertions: (ctx: HealthCheckAssertionContext<TOutput>) => void | Promise<void> | HealthCheckCaseResult | Promise<HealthCheckCaseResult>;
|
|
506
|
-
/**
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
636
|
+
/** Declarative scenarios replace the imperative preparation and assertion hooks. */
|
|
637
|
+
scenario?: never;
|
|
638
|
+
} | {
|
|
639
|
+
/** Declarative scenario executed by the health-monitor runtime. */
|
|
640
|
+
scenario: HealthScenario;
|
|
641
|
+
prepareInput?: never;
|
|
642
|
+
assertions?: never;
|
|
643
|
+
});
|
|
515
644
|
/**
|
|
516
645
|
* Operation-level health-check suite. At least one case is required when
|
|
517
646
|
* present. All cases share the suite's interval and default timeout.
|
|
@@ -609,23 +738,42 @@ export interface HealthMonitorProbeOverride {
|
|
|
609
738
|
/** Optional degraded threshold override for generated registry probes. */
|
|
610
739
|
degradedThresholdMs?: number;
|
|
611
740
|
}
|
|
741
|
+
export declare const VALID_OPERATION_ERROR_STATUSES: readonly [400, 401, 404, 409, 410, 422, 429, 500, 502, 503, 504];
|
|
742
|
+
export type ProviderErrorStatus = (typeof VALID_OPERATION_ERROR_STATUSES)[number];
|
|
612
743
|
export interface OperationErrorCode {
|
|
613
744
|
code: string;
|
|
614
|
-
status?:
|
|
745
|
+
status?: ProviderErrorStatus;
|
|
615
746
|
description: string;
|
|
616
747
|
retryable?: boolean;
|
|
617
748
|
}
|
|
618
|
-
export interface OperationDocMeta {
|
|
619
|
-
titleKey?: ProviderLocaleKeyInput;
|
|
620
|
-
descriptionKey?: ProviderLocaleKeyInput;
|
|
621
|
-
summaryKey?: ProviderLocaleKeyInput;
|
|
622
|
-
markdownKey?: ProviderLocaleKeyInput;
|
|
623
|
-
normalizationNotesKeys?: ProviderLocaleKeyInput[];
|
|
624
|
-
requestExample?: Record<string, unknown>;
|
|
625
|
-
responseExample?: unknown;
|
|
626
|
-
errorCodes?: OperationErrorCode[];
|
|
627
|
-
}
|
|
628
749
|
export type StealthPlatform = "macos" | "windows" | "linux" | "android" | "ios";
|
|
750
|
+
export type StealthBrowser = "chrome" | "firefox" | "safari";
|
|
751
|
+
export type StealthOS = "windows" | "macos" | "linux" | "ios";
|
|
752
|
+
/** A supported, fully resolved browser/OS fingerprint pair. */
|
|
753
|
+
export type StealthProfileDescriptor = {
|
|
754
|
+
browser: "chrome";
|
|
755
|
+
os: "windows" | "macos" | "linux";
|
|
756
|
+
} | {
|
|
757
|
+
browser: "firefox";
|
|
758
|
+
os: "windows" | "macos" | "linux";
|
|
759
|
+
} | {
|
|
760
|
+
browser: "safari";
|
|
761
|
+
os: "macos" | "ios";
|
|
762
|
+
};
|
|
763
|
+
/**
|
|
764
|
+
* Browser/OS fingerprint selection. Chrome and macOS are the named defaults
|
|
765
|
+
* when their respective axes are omitted.
|
|
766
|
+
*/
|
|
767
|
+
export type StealthProfileSelection = {
|
|
768
|
+
browser?: "chrome";
|
|
769
|
+
os?: "windows" | "macos" | "linux";
|
|
770
|
+
} | {
|
|
771
|
+
browser: "firefox";
|
|
772
|
+
os?: "windows" | "macos" | "linux";
|
|
773
|
+
} | {
|
|
774
|
+
browser: "safari";
|
|
775
|
+
os?: "macos" | "ios";
|
|
776
|
+
};
|
|
629
777
|
export type BrowserEngine = "playwright-stealth" | "nodriver" | "selenium-uc";
|
|
630
778
|
export interface BrowserOptions {
|
|
631
779
|
headless?: boolean;
|
|
@@ -634,9 +782,7 @@ export interface BrowserOptions {
|
|
|
634
782
|
engine?: BrowserEngine;
|
|
635
783
|
requireCdpPool?: boolean;
|
|
636
784
|
}
|
|
637
|
-
export
|
|
638
|
-
name: string;
|
|
639
|
-
platform: StealthPlatform;
|
|
785
|
+
export type StealthProfile = StealthProfileDescriptor & {
|
|
640
786
|
version: string;
|
|
641
787
|
userAgent: string;
|
|
642
788
|
tlsClientIdentifier?: string;
|
|
@@ -644,13 +790,33 @@ export interface StealthProfile {
|
|
|
644
790
|
ja4?: string;
|
|
645
791
|
h2Settings?: Record<string, unknown>;
|
|
646
792
|
headerOrder?: string[];
|
|
647
|
-
}
|
|
648
|
-
export type AuthMode = "none" | "platform-managed" | "credentials" | "oauth2";
|
|
793
|
+
};
|
|
794
|
+
export type AuthMode = "none" | "platform-managed" | "credentials" | "oauth2" | "oauth2_proxied";
|
|
649
795
|
export type ConnectionMode = AuthMode;
|
|
650
796
|
export type ProviderReviewed = "first-party" | "community" | "staging";
|
|
651
797
|
export type ProviderAccessVisibility = "public" | "early_access";
|
|
652
798
|
export type ProviderProxyMode = "disabled" | "optional" | "required";
|
|
653
|
-
|
|
799
|
+
/**
|
|
800
|
+
* Proxy egress vendors. These are FOUR DISTINCT services — do not conflate them
|
|
801
|
+
* (a common mistake because the names collide with a well-known rebrand):
|
|
802
|
+
*
|
|
803
|
+
* - `smartproxy` — **api.smartproxy.org**, a residential proxy with an IP
|
|
804
|
+
* *extraction/allocation* API (app_key → a pool of raw `ip:port` CONNECT
|
|
805
|
+
* endpoints). This is our own vendor. It is NOT the company formerly named
|
|
806
|
+
* "Smartproxy". Credentials: `APIFUSE__PROXY__SMARTPROXY_APP_KEY`.
|
|
807
|
+
* - `nodemaven` — **gate.nodemaven.com**, a *gateway* proxy with static
|
|
808
|
+
* credentials; geo/session encoded in the username, no allocation API.
|
|
809
|
+
* - `decodo` — **decodo.com**, the *gateway* proxy that was named "Smartproxy"
|
|
810
|
+
* (smartproxy.com) before its 2025 rebrand to Decodo. Sticky sessions via
|
|
811
|
+
* username params. A different company from `smartproxy` above.
|
|
812
|
+
* **@deprecated** — unused; no managed adapter. Declare a
|
|
813
|
+
* `ProviderProxyPolicy` using `smartproxy` or `nodemaven` instead; the
|
|
814
|
+
* `smartproxy` allocator requires `APIFUSE__PROXY__SMARTPROXY_APP_KEY`.
|
|
815
|
+
* - `custom` — **@deprecated** static proxy marker with no managed adapter.
|
|
816
|
+
* Use `ProviderProxyPolicy` with `smartproxy`/`nodemaven`; the `smartproxy`
|
|
817
|
+
* allocator requires `APIFUSE__PROXY__SMARTPROXY_APP_KEY`.
|
|
818
|
+
*/
|
|
819
|
+
export type ProviderProxyProvider = "smartproxy" | "nodemaven" | "decodo" | "custom";
|
|
654
820
|
export type ProviderProxySessionAffinity = "request" | "operation" | "auth-flow" | "connection";
|
|
655
821
|
export interface ProviderProxyPolicy {
|
|
656
822
|
/**
|
|
@@ -658,7 +824,18 @@ export interface ProviderProxyPolicy {
|
|
|
658
824
|
* certificate verification, and vendor allocator endpoints are SDK-owned.
|
|
659
825
|
*/
|
|
660
826
|
mode: ProviderProxyMode;
|
|
827
|
+
/**
|
|
828
|
+
* @deprecated Use `providers: [...]` to declare an ordered vendor fallback
|
|
829
|
+
* chain. A single-element `providers` list is equivalent to this field.
|
|
830
|
+
*/
|
|
661
831
|
provider?: ProviderProxyProvider;
|
|
832
|
+
/**
|
|
833
|
+
* Ordered proxy-vendor fallback chain. The SDK tries each vendor in order and
|
|
834
|
+
* fails over to the next when a vendor lacks credentials or its allocation /
|
|
835
|
+
* transport is exhausted. When omitted, `provider` (or the platform default)
|
|
836
|
+
* is used as a single-vendor chain.
|
|
837
|
+
*/
|
|
838
|
+
providers?: ProviderProxyProvider[];
|
|
662
839
|
geo?: {
|
|
663
840
|
/** ISO 3166-1 alpha-2 country code, for example KR or US. */
|
|
664
841
|
country?: Iso3166Alpha2CountryCode;
|
|
@@ -669,6 +846,12 @@ export interface ProviderProxyPolicy {
|
|
|
669
846
|
affinity?: ProviderProxySessionAffinity;
|
|
670
847
|
lifetimeMinutes?: number;
|
|
671
848
|
poolSize?: number;
|
|
849
|
+
/**
|
|
850
|
+
* Seconds before hard sticky expiry at which native connections receive
|
|
851
|
+
* the `expiring` event so the provider can drain and reconnect cleanly.
|
|
852
|
+
* Declared by the provider; the SDK does not assume a default cut point.
|
|
853
|
+
*/
|
|
854
|
+
drainLeadSeconds?: number;
|
|
672
855
|
};
|
|
673
856
|
}
|
|
674
857
|
export type ProviderProxyConfig = boolean | ProviderProxyPolicy;
|
|
@@ -677,13 +860,12 @@ export interface ProviderAccessConfig {
|
|
|
677
860
|
* Provider-level rollout visibility.
|
|
678
861
|
*
|
|
679
862
|
* - `public`: visible in public docs/catalog/OpenAPI and callable through
|
|
680
|
-
*
|
|
863
|
+
* the existing provider policy stack.
|
|
681
864
|
* - `early_access`: hidden from public discovery and callable only when the
|
|
682
|
-
*
|
|
865
|
+
* active customer organization has a provider-level access grant.
|
|
683
866
|
*
|
|
684
867
|
* This is intentionally provider-level only. It does not alter auth mode,
|
|
685
|
-
* operation schemas, health-check authoring,
|
|
686
|
-
* requirements.
|
|
868
|
+
* operation schemas, health-check authoring, or Connection requirements.
|
|
687
869
|
*/
|
|
688
870
|
visibility?: ProviderAccessVisibility;
|
|
689
871
|
}
|
|
@@ -748,6 +930,10 @@ export interface ProviderMeta {
|
|
|
748
930
|
publicProfile?: ProviderPublicProfile;
|
|
749
931
|
contract?: {
|
|
750
932
|
publicSchemaFieldNames?: "normalized";
|
|
933
|
+
readonly pinnedWireFieldPaths?: readonly {
|
|
934
|
+
readonly path: string;
|
|
935
|
+
readonly reason: string;
|
|
936
|
+
}[];
|
|
751
937
|
};
|
|
752
938
|
}
|
|
753
939
|
export type RequestParamPrimitive = string | number | boolean | null | undefined;
|
|
@@ -810,6 +996,11 @@ export interface HttpRetrySummary {
|
|
|
810
996
|
export interface RequestOptions {
|
|
811
997
|
headers?: Record<string, string>;
|
|
812
998
|
params?: RequestParams;
|
|
999
|
+
/**
|
|
1000
|
+
* Query parameters whose values contain credentials or other secret material.
|
|
1001
|
+
* They are sent like `params`, but redacted from SDK errors, traces, and recorded fixtures.
|
|
1002
|
+
*/
|
|
1003
|
+
sensitiveParams?: Record<string, string>;
|
|
813
1004
|
proxy?: string;
|
|
814
1005
|
timeout?: number;
|
|
815
1006
|
/**
|
|
@@ -818,12 +1009,38 @@ export interface RequestOptions {
|
|
|
818
1009
|
*/
|
|
819
1010
|
throwOnHttpError?: boolean;
|
|
820
1011
|
retry?: boolean | HttpRetryPreset | HttpRetryOptions;
|
|
1012
|
+
/**
|
|
1013
|
+
* Opt-in redirect-hop enforcement for ctx.http. When present, redirects are
|
|
1014
|
+
* evaluated before the next request is issued. Existing callers that omit
|
|
1015
|
+
* this policy retain the native fetch redirect behavior.
|
|
1016
|
+
*/
|
|
1017
|
+
redirectPolicy?: HttpRedirectPolicy;
|
|
821
1018
|
}
|
|
1019
|
+
export type RedirectRunReason = "completed" | "stopped" | "max_hops" | "missing_location" | "loop";
|
|
1020
|
+
export type HttpRedirectPolicyMode = "same-origin";
|
|
1021
|
+
export interface HttpRedirectPolicy {
|
|
1022
|
+
/** Only follow redirects whose canonical scheme, host, and port match the initial URL. */
|
|
1023
|
+
mode: HttpRedirectPolicyMode;
|
|
1024
|
+
/** Maximum number of redirect hops that may be followed. Must be an integer from 0 to 20. */
|
|
1025
|
+
maxHops: number;
|
|
1026
|
+
}
|
|
1027
|
+
export type HttpRedirectFailureReason = Exclude<RedirectRunReason, "completed">;
|
|
822
1028
|
export type HttpMethod = "HEAD" | "head" | "GET" | "get" | "POST" | "post" | "PUT" | "put" | "DELETE" | "delete" | "OPTIONS" | "options" | "TRACE" | "trace" | "PATCH" | "patch";
|
|
823
|
-
export interface StealthFetchOptions extends RequestOptions {
|
|
1029
|
+
export interface StealthFetchOptions extends Omit<RequestOptions, "redirectPolicy" | "headers"> {
|
|
1030
|
+
/**
|
|
1031
|
+
* Request headers. Array values and case-insensitive duplicate names are
|
|
1032
|
+
* combined in caller order using `", "`, matching Chrome's Fetch behavior.
|
|
1033
|
+
*/
|
|
1034
|
+
headers?: Record<string, string | string[]>;
|
|
824
1035
|
method?: HttpMethod;
|
|
825
1036
|
body?: string | Buffer;
|
|
826
1037
|
redirect?: "follow" | "manual" | "error";
|
|
1038
|
+
/**
|
|
1039
|
+
* Maximum decoded response-body bytes to buffer. When set, the stealth
|
|
1040
|
+
* transport aborts the response and throws `response_too_large` if the
|
|
1041
|
+
* declared or streamed body exceeds this limit.
|
|
1042
|
+
*/
|
|
1043
|
+
maxBodyBytes?: number;
|
|
827
1044
|
/**
|
|
828
1045
|
* Offsets policy-managed proxy pool selection for caller-managed retries.
|
|
829
1046
|
* Use when a request receives an upstream challenge page rather than a
|
|
@@ -831,29 +1048,58 @@ export interface StealthFetchOptions extends RequestOptions {
|
|
|
831
1048
|
* operation-affinity proxy.
|
|
832
1049
|
*/
|
|
833
1050
|
proxyAttemptOffset?: number;
|
|
834
|
-
/** Override the configured browser-like stealth profile for this request. */
|
|
835
|
-
profile?: string;
|
|
836
1051
|
/**
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
* certificate chain.
|
|
1052
|
+
* SDK-specific stealth controls. Standard HTTP metadata such as language,
|
|
1053
|
+
* referrer, and content type belongs in `headers`.
|
|
840
1054
|
*/
|
|
841
|
-
stealth?: {
|
|
1055
|
+
stealth?: StealthProfileSelection & {
|
|
1056
|
+
/** Override the configured browser and/or OS for this request. */
|
|
1057
|
+
/** Declare the Chrome request class when it cannot be inferred from the method. */
|
|
1058
|
+
requestClass?: "navigation" | "xhr" | "post";
|
|
1059
|
+
/**
|
|
1060
|
+
* Use only for proxy products that terminate CONNECT with a private CA
|
|
1061
|
+
* instead of tunneling the origin certificate chain.
|
|
1062
|
+
*/
|
|
842
1063
|
insecureSkipVerify?: boolean;
|
|
843
1064
|
};
|
|
844
1065
|
}
|
|
845
1066
|
export interface CookieJar {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1067
|
+
/** URL-less reads use the jar's response URL or session base URL. */
|
|
1068
|
+
get(name: string, url?: string): string | undefined;
|
|
1069
|
+
getAll(url?: string): Record<string, string>;
|
|
1070
|
+
toString(url?: string): string;
|
|
1071
|
+
find?(predicate: (cookie: string) => boolean, url?: string): string | undefined;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Version 1 of the JSON-safe, attribute-preserving stealth cookie store.
|
|
1075
|
+
* The nested jar is tough-cookie's serialized form and retains cookie origin,
|
|
1076
|
+
* Path, Secure, expiry, host-only, and other RFC attributes.
|
|
1077
|
+
*/
|
|
1078
|
+
export interface StealthCookieStoreV1 {
|
|
1079
|
+
readonly version: 1;
|
|
1080
|
+
readonly jar: SerializedCookieJar;
|
|
850
1081
|
}
|
|
1082
|
+
/** Cookie persistence formats understood by this SDK version. */
|
|
1083
|
+
export type StealthCookieStore = StealthCookieStoreV1;
|
|
851
1084
|
export interface StealthSessionCookies extends CookieJar {
|
|
852
|
-
has(name: string): boolean;
|
|
853
|
-
|
|
854
|
-
|
|
1085
|
+
has(name: string, url?: string): boolean;
|
|
1086
|
+
/** URL-less writes are scoped to the session base URL. */
|
|
1087
|
+
setFromCookieStrings(cookieStrings: readonly string[], url?: string): void;
|
|
1088
|
+
toHeader(url?: string): string;
|
|
1089
|
+
/**
|
|
1090
|
+
* Returns every cookie as a flat name/value map, collapsing duplicate names.
|
|
1091
|
+
* @deprecated Use serialize() for lossless, attribute-preserving persistence.
|
|
1092
|
+
*/
|
|
855
1093
|
snapshot(): Record<string, string>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Restores flat values as host-only, Path=/ cookies on the session base URL.
|
|
1096
|
+
* @deprecated Use deserialize() with state produced by serialize().
|
|
1097
|
+
*/
|
|
856
1098
|
restore(cookies: Record<string, string>): void;
|
|
1099
|
+
/** Returns a versioned, JSON-safe, attribute-preserving representation of every cookie. */
|
|
1100
|
+
serialize(): StealthCookieStoreV1;
|
|
1101
|
+
/** Replaces the jar with a previously serialized, attribute-preserving cookie store. */
|
|
1102
|
+
deserialize(state: StealthCookieStore): void;
|
|
857
1103
|
clear(): void;
|
|
858
1104
|
}
|
|
859
1105
|
export interface DeclarativeStealthResponse {
|
|
@@ -895,8 +1141,14 @@ export interface StealthRedirectRunOptions extends Omit<StealthFetchOptions, "re
|
|
|
895
1141
|
export interface StealthRedirectRunResult {
|
|
896
1142
|
final: StealthResponse;
|
|
897
1143
|
hops: StealthRedirectHop[];
|
|
898
|
-
reason:
|
|
1144
|
+
reason: RedirectRunReason;
|
|
1145
|
+
/**
|
|
1146
|
+
* Complete flat view across all redirect hosts. Attributes and duplicate names are lost.
|
|
1147
|
+
* @deprecated Use cookieStore for lossless persistence.
|
|
1148
|
+
*/
|
|
899
1149
|
cookies: Record<string, string>;
|
|
1150
|
+
/** Versioned, attribute-preserving cookie state accumulated across the redirect chain. */
|
|
1151
|
+
cookieStore: StealthCookieStoreV1;
|
|
900
1152
|
}
|
|
901
1153
|
export interface StealthSession {
|
|
902
1154
|
fetch(url: string, options?: StealthFetchOptions): Promise<StealthResponse>;
|
|
@@ -959,11 +1211,159 @@ export interface HttpClient {
|
|
|
959
1211
|
stream(url: string, options?: RequestWithMethodOptions): Promise<HttpStreamResponse>;
|
|
960
1212
|
sse(url: string, options?: RequestWithMethodOptions): Promise<AsyncIterable<SseMessage>>;
|
|
961
1213
|
}
|
|
1214
|
+
/** Request-scoped file reference accepted by provider operation inputs. */
|
|
1215
|
+
export interface ProviderFileRef {
|
|
1216
|
+
readonly type: "request_file";
|
|
1217
|
+
readonly id: string;
|
|
1218
|
+
readonly filename: string;
|
|
1219
|
+
readonly mime_type?: string;
|
|
1220
|
+
readonly size: number;
|
|
1221
|
+
readonly sha256?: string;
|
|
1222
|
+
}
|
|
1223
|
+
/** File body resolved from a request-scoped {@link ProviderFileRef}. */
|
|
1224
|
+
export type ProviderResolvedFile = Omit<ProviderFileRef, "mime_type"> & {
|
|
1225
|
+
readonly mimeType?: string;
|
|
1226
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
1227
|
+
bytes(): Promise<Uint8Array>;
|
|
1228
|
+
stream(): ReadableStream<Uint8Array>;
|
|
1229
|
+
};
|
|
1230
|
+
/** Resolver supplied by runtimes that accept request-scoped file inputs. */
|
|
1231
|
+
export interface ProviderFilesContext {
|
|
1232
|
+
has(input: string | ProviderFileRef): boolean;
|
|
1233
|
+
resolve(input: string | ProviderFileRef): Promise<ProviderResolvedFile>;
|
|
1234
|
+
}
|
|
1235
|
+
/** Where provider business logic executes relative to the capability engine. */
|
|
1236
|
+
export type ProviderRuntimeTarget = "vanilla" | "engine";
|
|
1237
|
+
export type NativeTcpTlsMode = "required" | "allowed" | "disabled";
|
|
1238
|
+
export interface NativeTcpPortRange {
|
|
1239
|
+
readonly start: number;
|
|
1240
|
+
readonly end: number;
|
|
1241
|
+
}
|
|
1242
|
+
/** Static native TCP egress declared by a provider. */
|
|
1243
|
+
export interface NativeTcpEgressRule {
|
|
1244
|
+
readonly host: string;
|
|
1245
|
+
readonly ports: readonly number[];
|
|
1246
|
+
readonly tls: NativeTcpTlsMode;
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Bounded native TCP egress discovered through a declared bootstrap endpoint.
|
|
1250
|
+
* Host suffixes are exact DNS suffixes, not wildcard patterns.
|
|
1251
|
+
* Dynamic rules must declare at least one target host selector through
|
|
1252
|
+
* targetHostSuffixes, targetIpv4Cidrs, and/or targetIpv6Cidrs. Literal grant
|
|
1253
|
+
* sources and targets match only same-family selectors (except exact
|
|
1254
|
+
* sourceHost); DNS names match only host/suffix selectors. IPv4-mapped and
|
|
1255
|
+
* IPv4-compatible IPv6 literals are authorized only by IPv4 CIDRs.
|
|
1256
|
+
*
|
|
1257
|
+
* Dynamic rules are ordered. The first rule whose source, target, port, and TLS
|
|
1258
|
+
* selectors match exclusively owns the grant; its ttlMs and maxGrants bounds
|
|
1259
|
+
* apply, and an exhausted/shorter rule never falls through to a later overlap.
|
|
1260
|
+
* Every rule must declare a source host selector, source port list/range, and
|
|
1261
|
+
* target port list/range; omitted ttlMs/maxGrants remain unbounded.
|
|
1262
|
+
*/
|
|
1263
|
+
export interface NativeTcpDynamicEgressRule {
|
|
1264
|
+
readonly sourceHost?: string;
|
|
1265
|
+
readonly sourceHostSuffixes?: readonly string[];
|
|
1266
|
+
readonly sourceIpv4Cidrs?: readonly string[];
|
|
1267
|
+
readonly sourceIpv6Cidrs?: readonly string[];
|
|
1268
|
+
readonly sourcePorts?: readonly number[];
|
|
1269
|
+
readonly sourcePortRanges?: readonly NativeTcpPortRange[];
|
|
1270
|
+
readonly targetHostSuffixes?: readonly string[];
|
|
1271
|
+
readonly targetIpv4Cidrs?: readonly string[];
|
|
1272
|
+
readonly targetIpv6Cidrs?: readonly string[];
|
|
1273
|
+
readonly targetPorts?: readonly number[];
|
|
1274
|
+
readonly targetPortRanges?: readonly NativeTcpPortRange[];
|
|
1275
|
+
readonly tls: NativeTcpTlsMode;
|
|
1276
|
+
readonly ttlMs?: number;
|
|
1277
|
+
readonly maxGrants?: number;
|
|
1278
|
+
}
|
|
1279
|
+
/** Common TCP/TLS connection input supported by the native runtime. */
|
|
1280
|
+
export interface NativeNetworkConnectInput {
|
|
1281
|
+
readonly host: string;
|
|
1282
|
+
readonly port: number;
|
|
1283
|
+
readonly serverName?: string;
|
|
1284
|
+
readonly rejectUnauthorized?: boolean;
|
|
1285
|
+
/**
|
|
1286
|
+
* Maximum time without a successful socket read before the connection is
|
|
1287
|
+
* closed. Opt-in; when absent, reads can remain pending indefinitely.
|
|
1288
|
+
*/
|
|
1289
|
+
readonly idleTimeoutMs?: number;
|
|
1290
|
+
/** Maximum time allowed to establish the TCP/SOCKS/TLS connection. */
|
|
1291
|
+
readonly timeoutMs?: number;
|
|
1292
|
+
readonly signal?: AbortSignal;
|
|
1293
|
+
/** Overrides the credential-derived sticky affinity key. */
|
|
1294
|
+
readonly affinityKey?: string;
|
|
1295
|
+
}
|
|
1296
|
+
export type NativeNetworkConnectOptions = Omit<NativeNetworkConnectInput, "serverName" | "rejectUnauthorized">;
|
|
1297
|
+
export type NativeTlsConnectOptions = NativeNetworkConnectInput;
|
|
1298
|
+
export interface NativeNetworkDynamicGrantOptions {
|
|
1299
|
+
readonly sourceHost: string;
|
|
1300
|
+
readonly sourcePort: number;
|
|
1301
|
+
readonly host: string;
|
|
1302
|
+
readonly port: number;
|
|
1303
|
+
readonly tls: NativeTcpTlsMode;
|
|
1304
|
+
readonly ttlMs?: number;
|
|
1305
|
+
}
|
|
1306
|
+
export interface NativeNetworkEgressGrant {
|
|
1307
|
+
revoke(): void;
|
|
1308
|
+
}
|
|
1309
|
+
/** Consumer-facing alias used by native TCP providers. */
|
|
1310
|
+
export type NativeTcpEgressGrant = NativeNetworkEgressGrant;
|
|
1311
|
+
/** Resolved egress identity for a native connection routed through a proxy. */
|
|
1312
|
+
export interface NativeProxyEgressInfo {
|
|
1313
|
+
readonly vendor: ProviderProxyProvider;
|
|
1314
|
+
readonly sticky: boolean;
|
|
1315
|
+
/** Vendor sticky session id (sid). Absent for rotating sessions. */
|
|
1316
|
+
readonly sessionId?: string;
|
|
1317
|
+
/** Hard expiry of the sticky binding, ISO 8601. */
|
|
1318
|
+
readonly expiresAt?: string;
|
|
1319
|
+
}
|
|
1320
|
+
export type NativeProxyExpiringReason = "sticky_expiry";
|
|
1321
|
+
export interface NativeProxyExpiringEvent {
|
|
1322
|
+
readonly expiresAt: string;
|
|
1323
|
+
readonly leadSeconds: number;
|
|
1324
|
+
readonly reason: NativeProxyExpiringReason;
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Cooperative drain handler. The SDK awaits this before closing a socket whose
|
|
1328
|
+
* sticky proxy binding is about to expire, then force-closes at hard expiry.
|
|
1329
|
+
*/
|
|
1330
|
+
export type NativeProxyDrainHandler = (event: NativeProxyExpiringEvent) => void | Promise<void>;
|
|
1331
|
+
/** Typed reason recorded when the SDK closes a native connection intentionally. */
|
|
1332
|
+
export interface NativeNetworkCloseReason {
|
|
1333
|
+
readonly code: string;
|
|
1334
|
+
readonly message: string;
|
|
1335
|
+
}
|
|
1336
|
+
/** Byte-oriented connection returned by the native TCP/TLS runtime. */
|
|
1337
|
+
export interface NativeNetworkConnection {
|
|
1338
|
+
/** Present when the connection was routed through a proxy. */
|
|
1339
|
+
readonly proxy?: NativeProxyEgressInfo;
|
|
1340
|
+
/** Present after an SDK-planned close, such as sticky proxy expiry. */
|
|
1341
|
+
readonly closeReason?: NativeNetworkCloseReason;
|
|
1342
|
+
/** Register a cooperative drain handler for sticky-expiry reconnects. */
|
|
1343
|
+
onExpiring?(handler: NativeProxyDrainHandler): void;
|
|
1344
|
+
read(): Promise<Uint8Array | null>;
|
|
1345
|
+
write(data: Uint8Array): Promise<void>;
|
|
1346
|
+
close(): Promise<void>;
|
|
1347
|
+
}
|
|
1348
|
+
export interface NativeNetworkClient {
|
|
1349
|
+
connectTcp(input: NativeNetworkConnectOptions): Promise<NativeNetworkConnection>;
|
|
1350
|
+
connectTls(input: NativeTlsConnectOptions): Promise<NativeNetworkConnection>;
|
|
1351
|
+
grantTcpEgress(input: NativeNetworkDynamicGrantOptions): NativeNetworkEgressGrant;
|
|
1352
|
+
}
|
|
1353
|
+
export interface NativeContext {
|
|
1354
|
+
readonly network: NativeNetworkClient;
|
|
1355
|
+
}
|
|
1356
|
+
export interface NativeProviderConfig {
|
|
1357
|
+
readonly network?: {
|
|
1358
|
+
readonly tcp?: readonly NativeTcpEgressRule[];
|
|
1359
|
+
readonly dynamicTcp?: readonly NativeTcpDynamicEgressRule[];
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
962
1362
|
export interface ProviderCacheKeyOptions {
|
|
963
1363
|
/**
|
|
964
|
-
* Additional field names
|
|
965
|
-
*
|
|
966
|
-
* cookie, token, password, and secret.
|
|
1364
|
+
* Additional field names whose values are hashed in stable key material. The
|
|
1365
|
+
* SDK always hashes values under known secret-bearing names such as serviceKey,
|
|
1366
|
+
* authorization, cookie, token, password, and secret.
|
|
967
1367
|
*/
|
|
968
1368
|
redactFields?: string[];
|
|
969
1369
|
}
|
|
@@ -1006,7 +1406,7 @@ export interface ProviderCache {
|
|
|
1006
1406
|
export interface StealthClient {
|
|
1007
1407
|
fetch(url: string, options?: StealthFetchOptions): Promise<StealthResponse>;
|
|
1008
1408
|
createSession(opts?: {
|
|
1009
|
-
|
|
1409
|
+
stealth?: StealthProfileSelection;
|
|
1010
1410
|
}): StealthSession;
|
|
1011
1411
|
close?(): void;
|
|
1012
1412
|
}
|
|
@@ -1036,7 +1436,18 @@ export interface BrowserFrame {
|
|
|
1036
1436
|
evaluate<T>(fn: string | (() => T)): Promise<T>;
|
|
1037
1437
|
locator(selector: string): BrowserLocator;
|
|
1038
1438
|
}
|
|
1039
|
-
export
|
|
1439
|
+
export interface BrowserCookie {
|
|
1440
|
+
readonly name: string;
|
|
1441
|
+
readonly value: string;
|
|
1442
|
+
readonly domain: string;
|
|
1443
|
+
readonly path: string;
|
|
1444
|
+
/** Unix seconds. Absent for a session cookie. */
|
|
1445
|
+
readonly expires?: number;
|
|
1446
|
+
readonly httpOnly: boolean;
|
|
1447
|
+
readonly secure: boolean;
|
|
1448
|
+
readonly sameSite?: "Strict" | "Lax" | "None";
|
|
1449
|
+
}
|
|
1450
|
+
export type BrowserResourceMethod = "GET" | "HEAD" | "POST";
|
|
1040
1451
|
export type BrowserResourceRequest = {
|
|
1041
1452
|
readonly url: string;
|
|
1042
1453
|
readonly method: BrowserResourceMethod;
|
|
@@ -1045,6 +1456,8 @@ export type BrowserResourceRequest = {
|
|
|
1045
1456
|
};
|
|
1046
1457
|
export type BrowserResourceBody = Buffer | Uint8Array | ArrayBuffer | string;
|
|
1047
1458
|
export type BrowserResourceDecision = {
|
|
1459
|
+
readonly action: "continue";
|
|
1460
|
+
} | {
|
|
1048
1461
|
readonly action: "fulfill";
|
|
1049
1462
|
readonly status?: number;
|
|
1050
1463
|
readonly headers?: Readonly<Record<string, string>>;
|
|
@@ -1060,12 +1473,29 @@ export type BrowserResourceRoute = {
|
|
|
1060
1473
|
export type BrowserResourcePolicy = {
|
|
1061
1474
|
readonly defaultAction?: "block";
|
|
1062
1475
|
readonly allowedMethods?: readonly BrowserResourceMethod[];
|
|
1476
|
+
/**
|
|
1477
|
+
* Appends an enforcing CSP header to every renderable document response
|
|
1478
|
+
* while the policy is active. Existing CSP headers are retained, so this
|
|
1479
|
+
* can only further restrict the document.
|
|
1480
|
+
*/
|
|
1481
|
+
readonly documentContentSecurityPolicy?: string;
|
|
1063
1482
|
readonly routes: readonly BrowserResourceRoute[];
|
|
1064
1483
|
};
|
|
1065
1484
|
export interface BrowserPage extends BrowserFrame {
|
|
1066
1485
|
close(): Promise<void>;
|
|
1486
|
+
/** Returns the user agent used by this page's browser context. */
|
|
1487
|
+
userAgent(): Promise<string>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Reads the browser context's cookie jar, including httpOnly cookies.
|
|
1490
|
+
* Cookie expiry values are Unix seconds and are absent for session cookies.
|
|
1491
|
+
*/
|
|
1492
|
+
cookies(): Promise<readonly BrowserCookie[]>;
|
|
1067
1493
|
fill(selector: string, text: string): Promise<void>;
|
|
1068
1494
|
goto(url: string): Promise<void>;
|
|
1495
|
+
goto(url: string, options?: {
|
|
1496
|
+
readonly timeout?: number;
|
|
1497
|
+
readonly waitUntil?: "load" | "domcontentloaded";
|
|
1498
|
+
}): Promise<void>;
|
|
1069
1499
|
pageId?: string;
|
|
1070
1500
|
screenshot(options?: {
|
|
1071
1501
|
fullPage?: boolean;
|
|
@@ -1107,7 +1537,7 @@ export interface TraceConfig {
|
|
|
1107
1537
|
exporter?: "console" | "json" | "otlp" | "none";
|
|
1108
1538
|
endpoint?: string;
|
|
1109
1539
|
otlp?: {
|
|
1110
|
-
endpoint
|
|
1540
|
+
endpoint?: string;
|
|
1111
1541
|
headers?: Record<string, string>;
|
|
1112
1542
|
timeout?: number;
|
|
1113
1543
|
};
|
|
@@ -1138,6 +1568,26 @@ export interface ProviderChoiceBindingOptions {
|
|
|
1138
1568
|
connection?: boolean;
|
|
1139
1569
|
credentialKeys?: readonly string[];
|
|
1140
1570
|
}
|
|
1571
|
+
export type ProviderChoiceConsumeMode = "never" | "on-parse" | "explicit";
|
|
1572
|
+
export type ProviderChoiceConsumeResult = {
|
|
1573
|
+
readonly status: "consumed";
|
|
1574
|
+
} | {
|
|
1575
|
+
readonly status: "already-consumed";
|
|
1576
|
+
} | {
|
|
1577
|
+
readonly status: "unsupported";
|
|
1578
|
+
};
|
|
1579
|
+
export type ProviderChoiceExplicitParseResult = {
|
|
1580
|
+
readonly status: "active";
|
|
1581
|
+
readonly payload: Record<string, unknown>;
|
|
1582
|
+
/** Stable, opaque key for provider-owned idempotency records. */
|
|
1583
|
+
readonly replayKey: string;
|
|
1584
|
+
/** Atomically claims a word token. Inline tokens report unsupported. */
|
|
1585
|
+
consume(): Promise<ProviderChoiceConsumeResult>;
|
|
1586
|
+
} | {
|
|
1587
|
+
readonly status: "consumed";
|
|
1588
|
+
/** Use this key to read the provider-owned result before returning an error. */
|
|
1589
|
+
readonly replayKey: string;
|
|
1590
|
+
};
|
|
1141
1591
|
export type ProviderChoiceStorageOptions = {
|
|
1142
1592
|
readonly mode: "inline";
|
|
1143
1593
|
} | {
|
|
@@ -1165,6 +1615,8 @@ export interface ProviderChoiceIssueOptions<TPayload extends Record<string, unkn
|
|
|
1165
1615
|
ttlMs: number;
|
|
1166
1616
|
nowMs?: number;
|
|
1167
1617
|
bind?: ProviderChoiceBindingOptions;
|
|
1618
|
+
/** Server storage only: standard emits four words; high emits five. */
|
|
1619
|
+
strength?: "standard" | "high";
|
|
1168
1620
|
storage?: ProviderChoiceStorageOptions;
|
|
1169
1621
|
}
|
|
1170
1622
|
export interface ProviderChoiceParseOptions {
|
|
@@ -1176,6 +1628,8 @@ export interface ProviderChoiceParseOptions {
|
|
|
1176
1628
|
futureToleranceMs?: number;
|
|
1177
1629
|
bind?: ProviderChoiceBindingOptions;
|
|
1178
1630
|
storage?: ProviderChoiceStorageOptions;
|
|
1631
|
+
/** Defaults to never, preserving reusable choice-token parse semantics. */
|
|
1632
|
+
consume?: ProviderChoiceConsumeMode;
|
|
1179
1633
|
}
|
|
1180
1634
|
export interface ProviderChoiceContext {
|
|
1181
1635
|
issue<TPayload extends Record<string, unknown>>(options: ProviderChoiceIssueOptions<TPayload> & {
|
|
@@ -1194,6 +1648,9 @@ export interface ProviderChoiceContext {
|
|
|
1194
1648
|
}>;
|
|
1195
1649
|
}): string | Promise<string>;
|
|
1196
1650
|
issue<TPayload extends Record<string, unknown>>(options: ProviderChoiceIssueOptions<TPayload>): string | Promise<string>;
|
|
1651
|
+
parse(options: ProviderChoiceParseOptions & {
|
|
1652
|
+
readonly consume: "explicit";
|
|
1653
|
+
}): Promise<ProviderChoiceExplicitParseResult>;
|
|
1197
1654
|
parse(options: ProviderChoiceParseOptions & {
|
|
1198
1655
|
readonly storage?: {
|
|
1199
1656
|
readonly mode: "inline";
|
|
@@ -1209,7 +1666,7 @@ export interface ProviderChoiceContext {
|
|
|
1209
1666
|
readonly mode: "auto";
|
|
1210
1667
|
}>;
|
|
1211
1668
|
}): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
1212
|
-
parse(options: ProviderChoiceParseOptions): Record<string, unknown>;
|
|
1669
|
+
parse(options: ProviderChoiceParseOptions): Record<string, unknown> | Promise<Record<string, unknown> | ProviderChoiceExplicitParseResult>;
|
|
1213
1670
|
}
|
|
1214
1671
|
export interface ContextScratchpad {
|
|
1215
1672
|
get(key: string): unknown;
|
|
@@ -1285,16 +1742,34 @@ export interface AuthFlowTerminalContext {
|
|
|
1285
1742
|
}): AuthTurn;
|
|
1286
1743
|
}
|
|
1287
1744
|
export interface FlowContext {
|
|
1745
|
+
/** Gateway auth-flow id. Required by flow-scoped auth ceremonies. */
|
|
1746
|
+
flowId?: string;
|
|
1288
1747
|
connectionId?: string;
|
|
1289
1748
|
externalRef?: string;
|
|
1290
1749
|
tenantId: string;
|
|
1291
1750
|
providerId: string;
|
|
1292
1751
|
http: HttpClient;
|
|
1752
|
+
/** Durable connection-scoped runtime state. Present when the host runtime
|
|
1753
|
+
* supplies one; auth ceremonies must fail closed when absent rather than
|
|
1754
|
+
* fall back to bypassable in-process storage.
|
|
1755
|
+
*
|
|
1756
|
+
* Scoped via `ProviderRuntimeState.forConnection`: requests that resolve no
|
|
1757
|
+
* connection id (pre-connection ceremonies such as first-time logins) share
|
|
1758
|
+
* the documented isolated missing-connection scope. That sharing is the
|
|
1759
|
+
* intended semantic — it lets counters keyed by caller identity (e.g. a
|
|
1760
|
+
* login email) persist across separate ceremonies for the same caller.
|
|
1761
|
+
* Flows storing entries in that scope MUST key them by caller identity;
|
|
1762
|
+
* un-keyed entries would be shared across all connectionless ceremonies. */
|
|
1763
|
+
readonly state?: ProviderRuntimeState;
|
|
1764
|
+
/** Present when the selected runtime supplies native network capabilities. */
|
|
1765
|
+
readonly native?: NativeContext;
|
|
1293
1766
|
stealth: StealthClient;
|
|
1294
1767
|
env: EnvContext;
|
|
1295
1768
|
credential?: CredentialContext;
|
|
1296
1769
|
context: ContextScratchpad;
|
|
1770
|
+
ocr: OcrContext;
|
|
1297
1771
|
stt: SttContext;
|
|
1772
|
+
resolver: ResolverContext;
|
|
1298
1773
|
auth: AuthFlowTerminalContext;
|
|
1299
1774
|
}
|
|
1300
1775
|
export interface AuthTurn {
|
|
@@ -1326,7 +1801,13 @@ export interface AuthFlowDefinition {
|
|
|
1326
1801
|
refresh?: AuthFlowInputHandler;
|
|
1327
1802
|
}
|
|
1328
1803
|
export type ProviderStateDurationString = `${number}${"ms" | "s" | "m" | "h" | "d"}` | `PT${string}`;
|
|
1804
|
+
export type StateNamespaceScope = "connection" | "provider";
|
|
1329
1805
|
export interface StateNamespaceOptions {
|
|
1806
|
+
/**
|
|
1807
|
+
* State isolation boundary. Connection scope is the default; provider scope
|
|
1808
|
+
* must be selected explicitly for provider-wide coordination state.
|
|
1809
|
+
*/
|
|
1810
|
+
scope?: StateNamespaceScope;
|
|
1330
1811
|
/** Default TTL used when a write omits ttl. Required to avoid unbounded state. */
|
|
1331
1812
|
defaultTtl: ProviderStateDurationString;
|
|
1332
1813
|
/** Maximum allowed TTL; writes are rejected when they exceed this policy. */
|
|
@@ -1368,24 +1849,69 @@ export interface ProviderStateNamespace {
|
|
|
1368
1849
|
increment(key: string, field: string, delta?: number, options?: StateWriteOptions): Promise<StateValue<Record<string, unknown>>>;
|
|
1369
1850
|
}
|
|
1370
1851
|
export interface ProviderRuntimeState {
|
|
1852
|
+
/**
|
|
1853
|
+
* Returns an immutable view bound to one request connection. An unresolved
|
|
1854
|
+
* connection uses an isolated reserved sentinel, never the provider-global scope.
|
|
1855
|
+
*/
|
|
1856
|
+
forConnection(connectionId: string | undefined): ProviderRuntimeState;
|
|
1371
1857
|
namespace(name: string, options: StateNamespaceOptions): ProviderStateNamespace;
|
|
1372
1858
|
}
|
|
1373
|
-
|
|
1859
|
+
/**
|
|
1860
|
+
* The operation context exposed for one provider declaration. Capability
|
|
1861
|
+
* bindings are present only when their corresponding declaration is present;
|
|
1862
|
+
* trace and request remain ambient runtime bindings. Omitting the type
|
|
1863
|
+
* parameter preserves the legacy full context shape for existing annotations.
|
|
1864
|
+
*/
|
|
1865
|
+
export type ProviderContext<TConfig = Record<string, unknown>> = {
|
|
1866
|
+
request?: ProviderRequestContext;
|
|
1867
|
+
trace: TraceContext;
|
|
1868
|
+
} & ("env" extends keyof TConfig ? {
|
|
1374
1869
|
env: EnvContext;
|
|
1870
|
+
} : Record<never, never>) & ("credential" extends keyof TConfig ? {
|
|
1375
1871
|
credential: CredentialContext;
|
|
1376
|
-
|
|
1872
|
+
} : Record<never, never>) & ("http" extends keyof TConfig ? {
|
|
1377
1873
|
http: HttpClient;
|
|
1874
|
+
} : Record<never, never>) & ("files" extends keyof TConfig ? string extends keyof TConfig ? {
|
|
1875
|
+
readonly files?: ProviderFilesContext;
|
|
1876
|
+
} : {
|
|
1877
|
+
readonly files: ProviderFilesContext;
|
|
1878
|
+
} : Record<never, never>) & ("native" extends keyof TConfig ? {
|
|
1879
|
+
readonly native: NativeContext;
|
|
1880
|
+
} : Record<never, never>) & ("cache" extends keyof TConfig ? {
|
|
1378
1881
|
cache: ProviderCache;
|
|
1882
|
+
} : Record<never, never>) & ("state" extends keyof TConfig ? {
|
|
1379
1883
|
state: ProviderRuntimeState;
|
|
1884
|
+
} : Record<never, never>) & ("stealth" extends keyof TConfig ? {
|
|
1380
1885
|
stealth: StealthClient;
|
|
1886
|
+
} : Record<never, never>) & ("browser" extends keyof TConfig ? {
|
|
1381
1887
|
browser: BrowserClient;
|
|
1382
|
-
|
|
1888
|
+
} : Record<never, never>) & ("auth" extends keyof TConfig ? {
|
|
1383
1889
|
auth: AuthContext;
|
|
1890
|
+
} : Record<never, never>) & ("ocr" extends keyof TConfig ? {
|
|
1891
|
+
ocr: OcrContext;
|
|
1892
|
+
} : Record<never, never>) & ("stt" extends keyof TConfig ? {
|
|
1384
1893
|
stt: SttContext;
|
|
1894
|
+
} : Record<never, never>) & ("resolver" extends keyof TConfig ? {
|
|
1895
|
+
resolver: ResolverContext;
|
|
1896
|
+
} : Record<never, never>) & ("choice" extends keyof TConfig ? {
|
|
1385
1897
|
choice: ProviderChoiceContext;
|
|
1898
|
+
} : Record<never, never>);
|
|
1899
|
+
/** Backwards-compatible name for a declaration-derived provider context. */
|
|
1900
|
+
export type ProviderContextFor<TConfig> = ProviderContext<TConfig>;
|
|
1901
|
+
export interface ProxiedOAuthConfig {
|
|
1902
|
+
authorizeUrl: string;
|
|
1903
|
+
tokenUrl: string;
|
|
1904
|
+
customScheme: string;
|
|
1905
|
+
rewriteProfile: string;
|
|
1906
|
+
clientIdEnvKey: string;
|
|
1907
|
+
pkce?: "S256" | "none";
|
|
1908
|
+
authorizeParams?: Record<string, string>;
|
|
1909
|
+
tokenParams?: Record<string, string>;
|
|
1386
1910
|
}
|
|
1387
1911
|
export interface AuthConfig {
|
|
1388
1912
|
mode: AuthMode;
|
|
1913
|
+
/** Browser reverse-proxy contract for providers with custom-scheme OAuth callbacks. */
|
|
1914
|
+
proxied?: ProxiedOAuthConfig;
|
|
1389
1915
|
flow?: AuthFlowDefinition;
|
|
1390
1916
|
}
|
|
1391
1917
|
export interface ProviderSecretDeclaration {
|
|
@@ -1417,40 +1943,41 @@ export interface OperationContractMetadata {
|
|
|
1417
1943
|
lifecycle?: OperationLifecycle;
|
|
1418
1944
|
deprecation?: OperationDeprecationMetadata;
|
|
1419
1945
|
}
|
|
1420
|
-
export interface OperationDefinition<TInput extends SchemaLike = SchemaLike, TOutput extends SchemaLike = SchemaLike> {
|
|
1421
|
-
/**
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
* provider lint rules for raw prose descriptions still apply.
|
|
1432
|
-
*/
|
|
1433
|
-
description?: string;
|
|
1946
|
+
export interface OperationDefinition<TInput extends SchemaLike = SchemaLike, TOutput extends SchemaLike = SchemaLike, TContext = ProviderContext> {
|
|
1947
|
+
/** Canonical operation-level connection requirement. */
|
|
1948
|
+
connectionMode?: "none" | "optional" | "required";
|
|
1949
|
+
/** Public argument used to resolve the tenant-owned connection. Defaults to externalRef. */
|
|
1950
|
+
connectionExternalRefParam?: string;
|
|
1951
|
+
/** Safety source of truth exposed to clients and approval policy. */
|
|
1952
|
+
riskClass: OperationRiskClass;
|
|
1953
|
+
/** Approval override. Omit when the risk-class default is correct. */
|
|
1954
|
+
approval?: OperationApprovalPolicy;
|
|
1955
|
+
timeoutMs?: number;
|
|
1956
|
+
titleKey?: ProviderLocaleKeyInput;
|
|
1434
1957
|
descriptionKey?: ProviderLocaleKeyInput;
|
|
1435
|
-
|
|
1958
|
+
summaryKey?: ProviderLocaleKeyInput;
|
|
1959
|
+
markdownKey?: ProviderLocaleKeyInput;
|
|
1436
1960
|
whenToUseKeys?: readonly ProviderLocaleKeyInput[];
|
|
1437
1961
|
whenNotToUseKeys?: readonly ProviderLocaleKeyInput[];
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1962
|
+
normalizationNotesKeys?: readonly ProviderLocaleKeyInput[];
|
|
1963
|
+
errorCodes?: readonly OperationErrorCode[];
|
|
1964
|
+
examples?: readonly OperationExample[];
|
|
1441
1965
|
contract?: OperationContractMetadata;
|
|
1442
1966
|
tags?: readonly string[];
|
|
1443
1967
|
relatedOperations?: OperationRelationships;
|
|
1444
|
-
toolRouter?: OperationToolRouterMetadata;
|
|
1445
1968
|
observability?: OperationObservabilityConfig;
|
|
1446
1969
|
transport?: OperationTransport;
|
|
1447
|
-
retryOnAuthRefresh?: boolean;
|
|
1448
1970
|
input: TInput;
|
|
1449
1971
|
output: TOutput;
|
|
1450
|
-
handler(ctx:
|
|
1972
|
+
handler(ctx: TContext, input: InferSchemaOutput<TInput>): OperationHandlerResult<InferSchemaOutput<TOutput>> | Promise<OperationHandlerResult<InferSchemaOutput<TOutput>>>;
|
|
1451
1973
|
fixtures?: {
|
|
1452
1974
|
request: InferSchemaOutput<TInput>;
|
|
1453
1975
|
response: InferSchemaOutput<TOutput>;
|
|
1976
|
+
/**
|
|
1977
|
+
* KST calendar date when `response` evidence was captured. Date fields in
|
|
1978
|
+
* the response align with this date, not a resolved relative request date.
|
|
1979
|
+
*/
|
|
1980
|
+
recordedAt?: string;
|
|
1454
1981
|
};
|
|
1455
1982
|
upstream?: {
|
|
1456
1983
|
baseUrl?: string;
|
|
@@ -1498,36 +2025,51 @@ export interface ProviderDeploymentOverrides {
|
|
|
1498
2025
|
};
|
|
1499
2026
|
buildContext?: string;
|
|
1500
2027
|
}
|
|
1501
|
-
export interface ProviderDefinition {
|
|
2028
|
+
export interface ProviderDefinition<TContext = ProviderContext> {
|
|
1502
2029
|
id: string;
|
|
1503
2030
|
version: string;
|
|
1504
2031
|
runtime: "standard" | "shared" | "browser";
|
|
2032
|
+
/**
|
|
2033
|
+
* `vanilla` executes provider business logic outside the engine; `engine`
|
|
2034
|
+
* keeps session-bearing provider logic in the engine process.
|
|
2035
|
+
*
|
|
2036
|
+
* Omitted only for definitions authored before the engine migration. New
|
|
2037
|
+
* providers should declare the target explicitly.
|
|
2038
|
+
*/
|
|
2039
|
+
runtimeTarget?: ProviderRuntimeTarget;
|
|
1505
2040
|
/**
|
|
1506
2041
|
* Optional deployment overrides, passed through verbatim from
|
|
1507
2042
|
* `defineProvider({ deployment })`. Validation and profile resolution are
|
|
1508
2043
|
* owned by the APIFuse registry builder, not the SDK.
|
|
1509
2044
|
*/
|
|
1510
2045
|
deployment?: ProviderDeploymentOverrides;
|
|
2046
|
+
http?: Record<string, never> | true;
|
|
1511
2047
|
allowedHosts?: string[];
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
platform: StealthPlatform;
|
|
1515
|
-
};
|
|
2048
|
+
native?: NativeProviderConfig;
|
|
2049
|
+
stealth?: StealthProfileSelection;
|
|
1516
2050
|
proxy?: ProviderProxyConfig;
|
|
2051
|
+
ocr?: ProviderOcrConfig;
|
|
1517
2052
|
stt?: ProviderSttConfig;
|
|
2053
|
+
resolver?: ProviderResolverConfig;
|
|
1518
2054
|
browser?: {
|
|
1519
2055
|
engine: BrowserEngine;
|
|
1520
2056
|
};
|
|
1521
2057
|
auth?: AuthConfig;
|
|
2058
|
+
choice?: Record<string, never> | true;
|
|
1522
2059
|
reviewed?: ProviderReviewed;
|
|
1523
2060
|
access?: ProviderAccessConfig;
|
|
1524
2061
|
secrets?: ProviderSecretDeclaration[];
|
|
2062
|
+
env?: Record<string, never> | true;
|
|
1525
2063
|
credential?: CredentialDeclaration;
|
|
1526
2064
|
context?: ContextDeclaration;
|
|
2065
|
+
state?: Record<string, never> | true;
|
|
2066
|
+
cache?: Record<string, never> | true;
|
|
2067
|
+
files?: Record<string, never> | true;
|
|
1527
2068
|
meta: ProviderMeta;
|
|
1528
|
-
operations: Record<string, OperationDefinition<SchemaLike, SchemaLike>>;
|
|
2069
|
+
operations: Record<string, OperationDefinition<SchemaLike, SchemaLike, TContext>>;
|
|
1529
2070
|
healthMonitor?: ProviderHealthMonitorConfig;
|
|
1530
2071
|
/** Transitional alias for `healthMonitor`; `defineProvider` mirrors both. */
|
|
1531
2072
|
healthProbe?: ProviderHealthProbeConfig;
|
|
1532
2073
|
healthJourneys?: readonly HealthJourneyDefinition[];
|
|
1533
2074
|
}
|
|
2075
|
+
export {};
|