@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/src/observability.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Mirrors packages/provider-observability in the platform monorepo (SoT).
|
|
2
|
+
export const PROVIDER_OBSERVABILITY_TAXONOMY_VERSION = "2026-08-07";
|
|
2
3
|
|
|
3
4
|
export const PROVIDER_ERROR_CATEGORIES = [
|
|
4
5
|
"ok",
|
|
@@ -7,6 +8,7 @@ export const PROVIDER_ERROR_CATEGORIES = [
|
|
|
7
8
|
"upstream_http",
|
|
8
9
|
"upstream_rate_limited",
|
|
9
10
|
"upstream_auth",
|
|
11
|
+
"upstream_rejected",
|
|
10
12
|
"upstream_schema_drift",
|
|
11
13
|
"proxy_pool",
|
|
12
14
|
"anti_bot_blocked",
|
|
@@ -16,6 +18,9 @@ export const PROVIDER_ERROR_CATEGORIES = [
|
|
|
16
18
|
"output_validation",
|
|
17
19
|
"provider_error",
|
|
18
20
|
"internal_error",
|
|
21
|
+
"dependency_unavailable",
|
|
22
|
+
"unsupported_transport",
|
|
23
|
+
"client_cancelled",
|
|
19
24
|
"unclassified",
|
|
20
25
|
] as const;
|
|
21
26
|
|
|
@@ -26,6 +31,9 @@ export function categoryForStatus(status: number): ProviderErrorCategory {
|
|
|
26
31
|
if (status === 408 || status === 504) return "timeout";
|
|
27
32
|
if (status === 429) return "upstream_rate_limited";
|
|
28
33
|
if (status === 401 || status === 403) return "upstream_auth";
|
|
34
|
+
// provider-error-contract: 409/410/422 are the deterministic
|
|
35
|
+
// upstream-rejection status class — not a retryable upstream failure.
|
|
36
|
+
if (status === 409 || status === 410 || status === 422) return "upstream_rejected";
|
|
29
37
|
if (status >= 400) return "upstream_http";
|
|
30
38
|
return "unclassified";
|
|
31
39
|
}
|
|
@@ -39,3 +47,45 @@ export function isRetryableCategory(category: ProviderErrorCategory): boolean {
|
|
|
39
47
|
category === "proxy_pool"
|
|
40
48
|
);
|
|
41
49
|
}
|
|
50
|
+
|
|
51
|
+
// Who stopped the request (honest-provider-error-contract). A deliberately
|
|
52
|
+
// small public projection of the internal taxonomy:
|
|
53
|
+
// - client: the request itself is fixable by the caller
|
|
54
|
+
// - upstream_rule: the upstream service refused it under its own business
|
|
55
|
+
// rules (deterministic) or rate limits
|
|
56
|
+
// - upstream_failure: the upstream service malfunctioned — retryable
|
|
57
|
+
// - apifuse: an APIFuse-side fault (provider bug, platform dependency)
|
|
58
|
+
export const PROVIDER_ERROR_SOURCES = [
|
|
59
|
+
"client",
|
|
60
|
+
"upstream_rule",
|
|
61
|
+
"upstream_failure",
|
|
62
|
+
"apifuse",
|
|
63
|
+
] as const;
|
|
64
|
+
|
|
65
|
+
export type ProviderErrorSource = (typeof PROVIDER_ERROR_SOURCES)[number];
|
|
66
|
+
|
|
67
|
+
export function sourceForCategory(category: ProviderErrorCategory): ProviderErrorSource {
|
|
68
|
+
switch (category) {
|
|
69
|
+
case "input_validation":
|
|
70
|
+
case "credential_expired":
|
|
71
|
+
case "credential_unavailable":
|
|
72
|
+
case "client_cancelled":
|
|
73
|
+
return "client";
|
|
74
|
+
case "upstream_rejected":
|
|
75
|
+
case "upstream_rate_limited":
|
|
76
|
+
return "upstream_rule";
|
|
77
|
+
case "timeout":
|
|
78
|
+
case "network":
|
|
79
|
+
case "upstream_http":
|
|
80
|
+
case "upstream_auth":
|
|
81
|
+
case "upstream_schema_drift":
|
|
82
|
+
case "anti_bot_blocked":
|
|
83
|
+
return "upstream_failure";
|
|
84
|
+
default:
|
|
85
|
+
// ok never reaches error serialization; provider_error,
|
|
86
|
+
// internal_error, output_validation, proxy_pool,
|
|
87
|
+
// dependency_unavailable, unsupported_transport, unclassified are
|
|
88
|
+
// APIFuse-side faults.
|
|
89
|
+
return "apifuse";
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/provider.ts
CHANGED
|
@@ -35,16 +35,123 @@ export {
|
|
|
35
35
|
defineSmsOtpMatcher,
|
|
36
36
|
every,
|
|
37
37
|
} from "./define.js";
|
|
38
|
+
export type {
|
|
39
|
+
OperationDefinitionFor,
|
|
40
|
+
ProviderBuilder,
|
|
41
|
+
ProviderContextOf,
|
|
42
|
+
ProviderDeclaration,
|
|
43
|
+
ProviderDefinitionFor,
|
|
44
|
+
} from "./define.js";
|
|
45
|
+
export type { JsonPrimitive, JsonValue } from "./contract-json.js";
|
|
46
|
+
export {
|
|
47
|
+
AssertionExpressionSchema,
|
|
48
|
+
AssertionPredicateSchema,
|
|
49
|
+
AssertStepSchema,
|
|
50
|
+
BoundedJsonPathSchema,
|
|
51
|
+
CandidateBlockSchema,
|
|
52
|
+
CandidatePolicySchema,
|
|
53
|
+
CredentialRefDeclarationSchema,
|
|
54
|
+
defineHealthScenario,
|
|
55
|
+
HealthScenarioSchema,
|
|
56
|
+
HealthStepSchema,
|
|
57
|
+
ExtractStepSchema,
|
|
58
|
+
FindFirstSchema,
|
|
59
|
+
GuardStepSchema,
|
|
60
|
+
JournalPolicySchema,
|
|
61
|
+
JsonTemplateSchema,
|
|
62
|
+
ManualTriggerPolicySchema,
|
|
63
|
+
OperandSchema,
|
|
64
|
+
OperationStepSchema,
|
|
65
|
+
QuantifierSchema,
|
|
66
|
+
ReferenceSchema,
|
|
67
|
+
RetryPolicySchema,
|
|
68
|
+
SafeRegexSchema,
|
|
69
|
+
ScopedAssertionExpressionSchema,
|
|
70
|
+
ScopedAssertionPredicateSchema,
|
|
71
|
+
ScopedItemReferenceSchema,
|
|
72
|
+
ScopedOperandSchema,
|
|
73
|
+
StepReferenceSchema,
|
|
74
|
+
RelativeDateNodeSchema,
|
|
75
|
+
ValueTypeSchema,
|
|
76
|
+
} from "./health-scenario.js";
|
|
77
|
+
export type {
|
|
78
|
+
AssertionExpression,
|
|
79
|
+
AssertionPredicate,
|
|
80
|
+
AttemptReference,
|
|
81
|
+
AssertResult,
|
|
82
|
+
AssertStep,
|
|
83
|
+
BoundedJsonPath,
|
|
84
|
+
CandidateBlock,
|
|
85
|
+
CandidatePolicy,
|
|
86
|
+
CandidateReference,
|
|
87
|
+
CredentialReference,
|
|
88
|
+
CredentialRefDeclaration,
|
|
89
|
+
EstablishedConnectionReference,
|
|
90
|
+
ExtractStep,
|
|
91
|
+
FindFirst,
|
|
92
|
+
GuardAttribution,
|
|
93
|
+
GuardReasonCode,
|
|
94
|
+
GuardResult,
|
|
95
|
+
GuardStep,
|
|
96
|
+
HealthScenario,
|
|
97
|
+
HealthStep,
|
|
98
|
+
JsonTemplate,
|
|
99
|
+
JournalPolicy,
|
|
100
|
+
ManualTriggerPolicy,
|
|
101
|
+
NonEmpty,
|
|
102
|
+
OperationResult,
|
|
103
|
+
OperationStep,
|
|
104
|
+
Operand,
|
|
105
|
+
Quantifier,
|
|
106
|
+
ReferenceNode,
|
|
107
|
+
Reference,
|
|
108
|
+
RelativeDateNode,
|
|
109
|
+
RetryPolicy,
|
|
110
|
+
SafeRegex,
|
|
111
|
+
ScopedAssertionExpression,
|
|
112
|
+
ScopedAssertionPredicate,
|
|
113
|
+
ScopedItemReference,
|
|
114
|
+
ScopedOperand,
|
|
115
|
+
StepBase,
|
|
116
|
+
StepReference,
|
|
117
|
+
ExtractResult,
|
|
118
|
+
ValueType,
|
|
119
|
+
} from "./health-scenario.js";
|
|
38
120
|
export {
|
|
39
121
|
AuthError,
|
|
122
|
+
HttpRedirectError,
|
|
40
123
|
isProviderError,
|
|
41
124
|
isSessionExpiredError,
|
|
42
125
|
isTransportError,
|
|
43
126
|
ProviderError,
|
|
127
|
+
type ProviderErrorObservability,
|
|
44
128
|
SessionExpiredError,
|
|
45
129
|
TransportError,
|
|
46
130
|
ValidationError,
|
|
47
131
|
} from "./errors.js";
|
|
132
|
+
export {
|
|
133
|
+
createProviderEnvironment,
|
|
134
|
+
createInProcessProviderEngine,
|
|
135
|
+
ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES,
|
|
136
|
+
ENGINE_OWNED_TELEMETRY_ENV_NAMES,
|
|
137
|
+
isEngineOwnedEnvName,
|
|
138
|
+
isEngineOwnedProxyCredentialName,
|
|
139
|
+
isEngineOwnedTelemetryEnvName,
|
|
140
|
+
PROVIDER_CAPABILITY_KEYS,
|
|
141
|
+
PROVIDER_ENGINE_PROTOCOL_VERSION,
|
|
142
|
+
readEngineProxyCredentials,
|
|
143
|
+
} from "./engine.js";
|
|
144
|
+
export type {
|
|
145
|
+
ProviderCapabilityKey,
|
|
146
|
+
ProviderEngine,
|
|
147
|
+
ProviderEngineAttachmentInput,
|
|
148
|
+
ProviderEngineBindingCandidates,
|
|
149
|
+
ProviderEngineCapabilitySurface,
|
|
150
|
+
ProviderEngineRequest,
|
|
151
|
+
ProviderEngineResidentSurface,
|
|
152
|
+
ProviderEngineSession,
|
|
153
|
+
ProviderEngineTransport,
|
|
154
|
+
} from "./engine.js";
|
|
48
155
|
export {
|
|
49
156
|
getProviderLocalePath,
|
|
50
157
|
providerLocaleKey,
|
|
@@ -91,50 +198,101 @@ export type {
|
|
|
91
198
|
HealthJourneyRunContext,
|
|
92
199
|
HealthJourneyRunResult,
|
|
93
200
|
HealthScheduleRandomization,
|
|
201
|
+
HttpRedirectFailureReason,
|
|
202
|
+
HttpRedirectPolicy,
|
|
203
|
+
HttpRedirectPolicyMode,
|
|
94
204
|
HttpRetryOptions,
|
|
95
205
|
HttpRetrySummary,
|
|
96
206
|
InferSchemaOutput,
|
|
207
|
+
NativeContext,
|
|
208
|
+
NativeNetworkClient,
|
|
209
|
+
NativeNetworkCloseReason,
|
|
210
|
+
NativeNetworkConnection,
|
|
211
|
+
NativeNetworkConnectInput,
|
|
212
|
+
NativeNetworkConnectOptions,
|
|
213
|
+
NativeNetworkDynamicGrantOptions,
|
|
214
|
+
NativeNetworkEgressGrant,
|
|
215
|
+
NativeProviderConfig,
|
|
216
|
+
NativeProxyDrainHandler,
|
|
217
|
+
NativeProxyEgressInfo,
|
|
218
|
+
NativeProxyExpiringEvent,
|
|
219
|
+
NativeProxyExpiringReason,
|
|
220
|
+
NativeTcpDynamicEgressRule,
|
|
221
|
+
NativeTcpEgressGrant,
|
|
222
|
+
NativeTcpEgressRule,
|
|
223
|
+
NativeTcpPortRange,
|
|
224
|
+
NativeTcpTlsMode,
|
|
225
|
+
NativeTlsConnectOptions,
|
|
97
226
|
OperationApprovalPolicy,
|
|
98
227
|
OperationContractMetadata,
|
|
99
228
|
OperationDefinition,
|
|
100
|
-
|
|
229
|
+
OperationExample,
|
|
101
230
|
OperationErrorCode,
|
|
102
|
-
|
|
231
|
+
ProviderErrorStatus,
|
|
103
232
|
OperationLifecycle,
|
|
104
233
|
OperationObservabilityConfig,
|
|
105
234
|
OperationObservabilitySensitiveConfig,
|
|
106
235
|
OperationRelationships,
|
|
107
236
|
OperationRiskClass,
|
|
108
237
|
OperationSensitivePath,
|
|
109
|
-
OperationToolRouterMetadata,
|
|
110
238
|
OperationTransport,
|
|
111
239
|
ProviderAccessVisibility,
|
|
112
240
|
ProviderChoiceBindingOptions,
|
|
241
|
+
ProviderChoiceConsumeMode,
|
|
242
|
+
ProviderChoiceConsumeResult,
|
|
113
243
|
ProviderChoiceContext,
|
|
244
|
+
ProviderChoiceExplicitParseResult,
|
|
114
245
|
ProviderChoiceIssueOptions,
|
|
115
246
|
ProviderChoiceParseOptions,
|
|
116
247
|
ProviderContext,
|
|
248
|
+
ProviderContextFor,
|
|
117
249
|
ProviderDefinition,
|
|
118
250
|
ProviderDeploymentOverrides,
|
|
251
|
+
ProviderFileRef,
|
|
252
|
+
ProviderFilesContext,
|
|
119
253
|
ProviderLocale,
|
|
120
254
|
ProviderLocaleKey,
|
|
121
255
|
ProviderLocaleKeyInput,
|
|
122
256
|
ProviderLogoProfile,
|
|
123
257
|
ProviderProxyPolicy,
|
|
258
|
+
ProxiedOAuthConfig,
|
|
124
259
|
ProviderPublicConnectionMode,
|
|
125
260
|
ProviderPublicProfile,
|
|
261
|
+
ProviderResolvedFile,
|
|
262
|
+
ProviderRuntimeTarget,
|
|
126
263
|
ProviderRuntimeState,
|
|
127
264
|
ProviderStateDurationString,
|
|
128
265
|
ProviderStateNamespace,
|
|
129
266
|
ProviderSupportLevel,
|
|
267
|
+
RedirectRunReason,
|
|
130
268
|
SchemaLike,
|
|
131
269
|
SmsOtpMatcherDefinition,
|
|
132
270
|
StandardSchemaV1,
|
|
133
271
|
StateCasResult,
|
|
134
272
|
StateNamespaceOptions,
|
|
273
|
+
StateNamespaceScope,
|
|
135
274
|
StateValue,
|
|
136
275
|
StateWriteOptions,
|
|
137
276
|
} from "./types.js";
|
|
277
|
+
export {
|
|
278
|
+
NativeEgressGrantExpiredError,
|
|
279
|
+
NativeEgressNotDeclaredError,
|
|
280
|
+
NativeIdleTimeoutError,
|
|
281
|
+
NativeNetworkError,
|
|
282
|
+
NativeProxyExpiredError,
|
|
283
|
+
} from "./runtime/native-network-errors.js";
|
|
284
|
+
export type {
|
|
285
|
+
NativeGatewayProxy,
|
|
286
|
+
NativeGatewayProxyResolutionInput,
|
|
287
|
+
NativeGatewayProxySkipReason,
|
|
288
|
+
NativeGatewayProxySynthesizer,
|
|
289
|
+
NativeGatewayProxySynthesisResult,
|
|
290
|
+
NativeGatewayProxySynthesisInput,
|
|
291
|
+
NativeNetworkClientOptions,
|
|
292
|
+
NativeNetworkErrorCode,
|
|
293
|
+
VendorCredentialLookup,
|
|
294
|
+
VendorCredentialResolver,
|
|
295
|
+
} from "./runtime/native-network.js";
|
|
138
296
|
export {
|
|
139
297
|
HttpRetryAfterPolicy,
|
|
140
298
|
HttpRetryDelayStrategy,
|
package/src/runtime/auth-flow.ts
CHANGED
|
@@ -5,9 +5,13 @@ import type {
|
|
|
5
5
|
EnvContext,
|
|
6
6
|
FlowContext,
|
|
7
7
|
HttpClient,
|
|
8
|
+
OcrContext,
|
|
9
|
+
ProviderRuntimeState,
|
|
8
10
|
StealthClient,
|
|
9
11
|
SttContext,
|
|
10
12
|
} from "../types.js";
|
|
13
|
+
import { createUnsupportedOcrClient } from "./ocr.js";
|
|
14
|
+
import { createUnsupportedResolverClient } from "./resolver-shared.js";
|
|
11
15
|
import { createUnsupportedSttClient } from "./stt.js";
|
|
12
16
|
|
|
13
17
|
function normalizeAllowedKeys(allowedKeys: string[]): Set<string> {
|
|
@@ -48,6 +52,7 @@ export function createScratchpad(
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export function createFlowContext(options: {
|
|
55
|
+
flowId?: string;
|
|
51
56
|
http: HttpClient;
|
|
52
57
|
stealth: StealthClient;
|
|
53
58
|
env: EnvContext;
|
|
@@ -55,20 +60,27 @@ export function createFlowContext(options: {
|
|
|
55
60
|
providerId: string;
|
|
56
61
|
connectionId?: string;
|
|
57
62
|
externalRef?: string;
|
|
63
|
+
/** Host-agnostic: callers pass an already-scoped runtime state, which this helper forwards verbatim. */
|
|
64
|
+
state?: ProviderRuntimeState;
|
|
58
65
|
allowedKeys: string[];
|
|
59
66
|
initialContext?: Record<string, unknown>;
|
|
67
|
+
ocr?: OcrContext;
|
|
60
68
|
stt?: SttContext;
|
|
61
69
|
}): FlowContext {
|
|
62
70
|
return {
|
|
71
|
+
flowId: options.flowId,
|
|
63
72
|
connectionId: options.connectionId,
|
|
64
73
|
externalRef: options.externalRef,
|
|
65
74
|
tenantId: options.tenantId,
|
|
66
75
|
providerId: options.providerId,
|
|
67
76
|
http: options.http,
|
|
77
|
+
state: options.state,
|
|
68
78
|
stealth: options.stealth,
|
|
69
79
|
env: options.env,
|
|
70
80
|
context: createScratchpad(options.allowedKeys, options.initialContext),
|
|
81
|
+
ocr: options.ocr ?? createUnsupportedOcrClient(),
|
|
71
82
|
stt: options.stt ?? createUnsupportedSttClient(),
|
|
83
|
+
resolver: createUnsupportedResolverClient("Resolver is not available in auth flow context"),
|
|
72
84
|
auth: createAuthFlowHelpers(),
|
|
73
85
|
};
|
|
74
86
|
}
|