@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.51
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 +205 -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 +1249 -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-hoisted-array-spread.ts.txt +15 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-imported-array-spread.ts.txt +9 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-mixed-array-spread.ts.txt +24 -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 +1751 -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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LIST_INPUT_EXAMPLES } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
const importedExamplesOperation = defineOperation<ProviderContext>()({
|
|
4
|
+
annotations: { readOnly: true },
|
|
5
|
+
inputExamples: [...LIST_INPUT_EXAMPLES],
|
|
6
|
+
input: InputSchema,
|
|
7
|
+
output: OutputSchema,
|
|
8
|
+
handler,
|
|
9
|
+
});
|
package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-mixed-array-spread.ts.txt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const SHARED_INPUT_EXAMPLES = [
|
|
2
|
+
{
|
|
3
|
+
scenario: "Shared middle example",
|
|
4
|
+
input: { page: 2 },
|
|
5
|
+
},
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
const mixedOperation = defineOperation<ProviderContext>()({
|
|
9
|
+
annotations: { readOnly: true },
|
|
10
|
+
inputExamples: [
|
|
11
|
+
{
|
|
12
|
+
scenario: "Literal first example",
|
|
13
|
+
input: { page: 1 },
|
|
14
|
+
},
|
|
15
|
+
...SHARED_INPUT_EXAMPLES,
|
|
16
|
+
{
|
|
17
|
+
scenario: "Literal last example",
|
|
18
|
+
input: { page: 3 },
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
input: InputSchema,
|
|
22
|
+
output: OutputSchema,
|
|
23
|
+
handler,
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const searchOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
annotations: { readOnly: true },
|
|
3
|
+
inputExamples: [
|
|
4
|
+
{
|
|
5
|
+
scenario: "Search by a precise phrase",
|
|
6
|
+
input: {
|
|
7
|
+
query: `京都
|
|
8
|
+
ホテル`,
|
|
9
|
+
},
|
|
10
|
+
rationale: "Shows whitespace preservation",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
input: InputSchema,
|
|
14
|
+
output: OutputSchema,
|
|
15
|
+
handler,
|
|
16
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const searchOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
annotations: {
|
|
3
|
+
readOnly: true,
|
|
4
|
+
openWorld: true,
|
|
5
|
+
idempotent: true,
|
|
6
|
+
rateLimit: { requests: 10 },
|
|
7
|
+
timeoutMs: 30_000,
|
|
8
|
+
},
|
|
9
|
+
toolRouter: {
|
|
10
|
+
name: "ignored",
|
|
11
|
+
requiresConnection: false,
|
|
12
|
+
connectionExternalRefParam: "accountId",
|
|
13
|
+
},
|
|
14
|
+
docs: {
|
|
15
|
+
titleKey: "operations.search.title",
|
|
16
|
+
descriptionKey: "operations.search.description",
|
|
17
|
+
summaryKey: "operations.search.summary",
|
|
18
|
+
markdownKey: "operations.search.markdown",
|
|
19
|
+
normalizationNotesKeys: ["operations.search.normalization.one"],
|
|
20
|
+
errorCodes: [{ code: "UPSTREAM" }],
|
|
21
|
+
requestExample: { query: "old" },
|
|
22
|
+
responseExample: { items: [] },
|
|
23
|
+
},
|
|
24
|
+
derivations: { value: "unused" } as unknown as Derivations,
|
|
25
|
+
retryOnAuthRefresh: true as unknown as boolean,
|
|
26
|
+
title: "Raw title" as unknown as string,
|
|
27
|
+
description: "Raw description" as unknown as string,
|
|
28
|
+
input: InputSchema,
|
|
29
|
+
output: OutputSchema,
|
|
30
|
+
handler,
|
|
31
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { toolRouterDefaults } from "./tool-router-defaults.js";
|
|
2
|
+
|
|
3
|
+
const importedSpreadOperation = defineOperation<ProviderContext>()({
|
|
4
|
+
annotations: { readOnly: true },
|
|
5
|
+
toolRouter: {
|
|
6
|
+
...toolRouterDefaults,
|
|
7
|
+
},
|
|
8
|
+
input: InputSchema,
|
|
9
|
+
output: OutputSchema,
|
|
10
|
+
handler,
|
|
11
|
+
});
|
package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const castTailOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
annotations: {
|
|
3
|
+
...({ timeoutMs: 15_000 as Milliseconds } as unknown as LegacyAnnotations),
|
|
4
|
+
},
|
|
5
|
+
toolRouter: {
|
|
6
|
+
...({
|
|
7
|
+
riskClass: "write" as const,
|
|
8
|
+
approval: "always" as ApprovalMode,
|
|
9
|
+
connectionMode: "none" as ConnectionMode,
|
|
10
|
+
} as unknown as LegacyToolRouter),
|
|
11
|
+
},
|
|
12
|
+
docs: {
|
|
13
|
+
...({
|
|
14
|
+
titleKey: "operations.castTail.title" as const,
|
|
15
|
+
descriptionKey: "operations.castTail.description" as LocaleKey,
|
|
16
|
+
} as unknown as LegacyDocs),
|
|
17
|
+
},
|
|
18
|
+
input: InputSchema,
|
|
19
|
+
output: OutputSchema,
|
|
20
|
+
handler,
|
|
21
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const getStationInfoOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
toolRouter: {
|
|
3
|
+
riskClass: "read",
|
|
4
|
+
approval: "never",
|
|
5
|
+
requiresConnection: false,
|
|
6
|
+
...{ connectionMode: "none" as const },
|
|
7
|
+
},
|
|
8
|
+
input: InputSchema,
|
|
9
|
+
output: OutputSchema,
|
|
10
|
+
handler,
|
|
11
|
+
});
|
package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const overrideOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
toolRouter: {
|
|
3
|
+
riskClass: "read",
|
|
4
|
+
connectionMode: "required" as const,
|
|
5
|
+
...{
|
|
6
|
+
connectionMode: "none" as const,
|
|
7
|
+
approval: "never" as const,
|
|
8
|
+
},
|
|
9
|
+
approval: "always" as const,
|
|
10
|
+
},
|
|
11
|
+
input: InputSchema,
|
|
12
|
+
output: OutputSchema,
|
|
13
|
+
handler,
|
|
14
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const requiredConnection = {
|
|
2
|
+
requiresConnection: true,
|
|
3
|
+
connectionExternalRefParam: "profileId",
|
|
4
|
+
} as const;
|
|
5
|
+
|
|
6
|
+
const updateOperation = defineOperation<ProviderContext>()({
|
|
7
|
+
annotations: { destructive: true },
|
|
8
|
+
toolRouter: {
|
|
9
|
+
...requiredConnection,
|
|
10
|
+
approval: "always",
|
|
11
|
+
},
|
|
12
|
+
input: InputSchema,
|
|
13
|
+
output: OutputSchema,
|
|
14
|
+
handler,
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const explainOperation = defineOperation<ProviderContext>()({
|
|
2
|
+
annotations: { readOnly: true },
|
|
3
|
+
docs: { descriptionKey: "operations.explain.description" },
|
|
4
|
+
input: InputSchema,
|
|
5
|
+
output: OutputSchema,
|
|
6
|
+
handler: async () => {
|
|
7
|
+
const message = `最初の行
|
|
8
|
+
${value}
|
|
9
|
+
最後の行`;
|
|
10
|
+
return { message };
|
|
11
|
+
},
|
|
12
|
+
});
|
package/src/cli/commands.ts
CHANGED
|
@@ -2,6 +2,9 @@ export type ApifuseCommandName =
|
|
|
2
2
|
| "create"
|
|
3
3
|
| "dev"
|
|
4
4
|
| "check"
|
|
5
|
+
| "sync-assets"
|
|
6
|
+
| "migrate-shape"
|
|
7
|
+
| "migrate-operation-declaration"
|
|
5
8
|
| "submit-check"
|
|
6
9
|
| "bounty-check"
|
|
7
10
|
| "record"
|
|
@@ -46,6 +49,33 @@ export const COMMAND_MANIFEST: Record<
|
|
|
46
49
|
examples: ["apifuse check .", "apifuse check providers/korea-air-quality"],
|
|
47
50
|
modulePath: "./apifuse-check",
|
|
48
51
|
},
|
|
52
|
+
"sync-assets": {
|
|
53
|
+
name: "sync-assets",
|
|
54
|
+
summary:
|
|
55
|
+
"Regenerate SDK-managed agent prompt assets (AGENTS.md, .agents/skills, symlinks, manifest) for the installed SDK version.",
|
|
56
|
+
usage: "apifuse sync-assets [path] [--check]",
|
|
57
|
+
examples: ["apifuse sync-assets .", "apifuse sync-assets . --check"],
|
|
58
|
+
modulePath: "./apifuse-sync-assets",
|
|
59
|
+
},
|
|
60
|
+
"migrate-shape": {
|
|
61
|
+
name: "migrate-shape",
|
|
62
|
+
summary:
|
|
63
|
+
"Migrate a provider to the phase-separated SDK: two-phase defineProvider in index.ts and curried defineOperation across sources.",
|
|
64
|
+
usage: "apifuse migrate-shape [path] [--check] [--json]",
|
|
65
|
+
examples: ["apifuse migrate-shape .", "apifuse migrate-shape . --check"],
|
|
66
|
+
modulePath: "./apifuse-migrate-shape",
|
|
67
|
+
},
|
|
68
|
+
"migrate-operation-declaration": {
|
|
69
|
+
name: "migrate-operation-declaration",
|
|
70
|
+
summary:
|
|
71
|
+
"Migrate legacy nested operation declarations to the ADR-0009 flat shape, refusing ambiguous safety or metadata.",
|
|
72
|
+
usage: "apifuse migrate-operation-declaration [path] [--check] [--json]",
|
|
73
|
+
examples: [
|
|
74
|
+
"apifuse migrate-operation-declaration .",
|
|
75
|
+
"apifuse migrate-operation-declaration . --check --json",
|
|
76
|
+
],
|
|
77
|
+
modulePath: "./apifuse-migrate-operation-declaration",
|
|
78
|
+
},
|
|
49
79
|
"submit-check": {
|
|
50
80
|
name: "submit-check",
|
|
51
81
|
summary:
|
|
@@ -103,6 +133,9 @@ export const COMMAND_ORDER: ApifuseCommandName[] = [
|
|
|
103
133
|
"create",
|
|
104
134
|
"dev",
|
|
105
135
|
"check",
|
|
136
|
+
"sync-assets",
|
|
137
|
+
"migrate-shape",
|
|
138
|
+
"migrate-operation-declaration",
|
|
106
139
|
"submit-check",
|
|
107
140
|
"record",
|
|
108
141
|
"test",
|
package/src/cli/create.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, readFile, rm, symlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
@@ -8,6 +8,11 @@ import { cancel, intro, isCancel, note, outro, select, text } from "@clack/promp
|
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
|
|
10
10
|
import packageJson from "../../package.json";
|
|
11
|
+
import {
|
|
12
|
+
buildPromptAssetManifest,
|
|
13
|
+
buildPromptAssetPlanEntries,
|
|
14
|
+
PROMPT_ASSET_MANIFEST_PATH,
|
|
15
|
+
} from "./prompt-assets.js";
|
|
11
16
|
|
|
12
17
|
export const PROVIDER_NAME_REGEX = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
13
18
|
export const CATEGORY_OPTIONS = [
|
|
@@ -21,7 +26,7 @@ export const CATEGORY_OPTIONS = [
|
|
|
21
26
|
"other",
|
|
22
27
|
] as const;
|
|
23
28
|
export const AUTH_MODE_OPTIONS = ["none", "platform-managed", "credentials", "oauth2"] as const;
|
|
24
|
-
export const RUNTIME_OPTIONS = ["standard", "browser"] as const;
|
|
29
|
+
export const RUNTIME_OPTIONS = ["standard", "shared", "browser"] as const;
|
|
25
30
|
export const PRESET_OPTIONS = ["standalone", "monorepo"] as const;
|
|
26
31
|
|
|
27
32
|
export type CreateCategory = (typeof CATEGORY_OPTIONS)[number];
|
|
@@ -64,7 +69,10 @@ export type CreateResolvedOptions = {
|
|
|
64
69
|
|
|
65
70
|
export type ProviderPlanFile = {
|
|
66
71
|
path: string;
|
|
72
|
+
/** File content, or the symlink target (relative path) for kind "symlink". */
|
|
67
73
|
content: string;
|
|
74
|
+
/** Absent kind means "file" (backward compatible with older consumers). */
|
|
75
|
+
kind?: "file" | "symlink";
|
|
68
76
|
};
|
|
69
77
|
|
|
70
78
|
export type ProviderCreatePlan = {
|
|
@@ -94,7 +102,7 @@ Options:
|
|
|
94
102
|
--display-name <name>
|
|
95
103
|
--category <category>
|
|
96
104
|
--auth-mode <mode>
|
|
97
|
-
--runtime <standard|browser>
|
|
105
|
+
--runtime <standard|shared|browser>
|
|
98
106
|
--yes
|
|
99
107
|
--dry-run
|
|
100
108
|
--json
|
|
@@ -410,11 +418,16 @@ export async function buildProviderCreatePlan(
|
|
|
410
418
|
);
|
|
411
419
|
}
|
|
412
420
|
|
|
421
|
+
// Exact pin, not a caret range: the prompt-asset freshness gate requires
|
|
422
|
+
// manifest.sdkVersion === installed SDK version, and the manifest records
|
|
423
|
+
// this CLI's own version. A caret range would let `bun install` resolve a
|
|
424
|
+
// newer SDK than the create binary, making a fresh scaffold fail its own
|
|
425
|
+
// gate. `sync-assets` after an explicit SDK upgrade re-records the version.
|
|
413
426
|
const sdkSpecifier =
|
|
414
427
|
options.sdkSpecifier ??
|
|
415
428
|
(options.preset === "monorepo" && resolvedWorkspaceRoot
|
|
416
429
|
? "workspace:*"
|
|
417
|
-
:
|
|
430
|
+
: packageJson.version);
|
|
418
431
|
const relativeProviderRoot = relative(cwd, providerRoot) || options.name;
|
|
419
432
|
const nextDevCommand = `cd ${relativeProviderRoot} && bun run dev`;
|
|
420
433
|
const packageName =
|
|
@@ -506,6 +519,12 @@ export async function buildProviderCreatePlan(
|
|
|
506
519
|
sdkSpecifier,
|
|
507
520
|
}),
|
|
508
521
|
},
|
|
522
|
+
{
|
|
523
|
+
path: resolve(providerRoot, "provider.json"),
|
|
524
|
+
content: await renderTemplate("provider.json.tpl", {
|
|
525
|
+
PROVIDER_ID: options.name,
|
|
526
|
+
}),
|
|
527
|
+
},
|
|
509
528
|
{
|
|
510
529
|
path: resolve(providerRoot, "Dockerfile"),
|
|
511
530
|
content: await renderTemplate("Dockerfile.tpl", {}),
|
|
@@ -538,40 +557,23 @@ export async function buildProviderCreatePlan(
|
|
|
538
557
|
PROVIDER_ID: options.name,
|
|
539
558
|
}),
|
|
540
559
|
},
|
|
541
|
-
{
|
|
542
|
-
path: resolve(providerRoot, "AGENTS.md"),
|
|
543
|
-
content: await renderTemplate("AGENTS.md.tpl", {}),
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
path: resolve(providerRoot, "CLAUDE.md"),
|
|
547
|
-
content: await renderTemplate("CLAUDE.md.tpl", {}),
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
path: resolve(providerRoot, "skills", "normalization-standards", "SKILL.md"),
|
|
551
|
-
content: await renderTemplate("skills/normalization-standards/SKILL.md.tpl", {}),
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
path: resolve(providerRoot, "skills", "upstream-contract-verification", "SKILL.md"),
|
|
555
|
-
content: await renderTemplate("skills/upstream-contract-verification/SKILL.md.tpl", {}),
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
path: resolve(providerRoot, "skills", "fixtures-and-recording", "SKILL.md"),
|
|
559
|
-
content: await renderTemplate("skills/fixtures-and-recording/SKILL.md.tpl", {}),
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
path: resolve(providerRoot, "skills", "pagination-and-counts", "SKILL.md"),
|
|
563
|
-
content: await renderTemplate("skills/pagination-and-counts/SKILL.md.tpl", {}),
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
path: resolve(providerRoot, "skills", "health-checks-and-fail-closed", "SKILL.md"),
|
|
567
|
-
content: await renderTemplate("skills/health-checks-and-fail-closed/SKILL.md.tpl", {}),
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
path: resolve(providerRoot, "skills", "upstream-notes", "README.md"),
|
|
571
|
-
content: await renderTemplate("skills/upstream-notes/README.md.tpl", {}),
|
|
572
|
-
},
|
|
573
560
|
];
|
|
574
561
|
|
|
562
|
+
const promptAssetEntries = await buildPromptAssetPlanEntries(renderTemplate);
|
|
563
|
+
for (const entry of promptAssetEntries) {
|
|
564
|
+
files.push({
|
|
565
|
+
path: resolve(providerRoot, entry.path),
|
|
566
|
+
content: entry.content,
|
|
567
|
+
...(entry.kind === "symlink" ? { kind: "symlink" as const } : {}),
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
// Manifest last: writePlan writes in order, so a crash mid-scaffold never
|
|
571
|
+
// leaves a manifest that claims assets which were not written.
|
|
572
|
+
files.push({
|
|
573
|
+
path: resolve(providerRoot, PROMPT_ASSET_MANIFEST_PATH),
|
|
574
|
+
content: buildPromptAssetManifest(promptAssetEntries, packageJson.version),
|
|
575
|
+
});
|
|
576
|
+
|
|
575
577
|
return {
|
|
576
578
|
displayName: options.displayName,
|
|
577
579
|
files,
|
|
@@ -614,6 +616,7 @@ function renderPackageJson(input: { packageName: string; sdkSpecifier: string })
|
|
|
614
616
|
check: "apifuse check . && bun run type-check",
|
|
615
617
|
"type-check": "tsc --noEmit",
|
|
616
618
|
"submit-check": "apifuse submit-check . --markdown submission-report.md",
|
|
619
|
+
"sync-assets": "apifuse sync-assets .",
|
|
617
620
|
test: "apifuse test .",
|
|
618
621
|
record: "apifuse record .",
|
|
619
622
|
start: "bun start.ts",
|
|
@@ -869,6 +872,13 @@ function isApifuseInternalWorkspaceRoot(workspaceRoot: string): boolean {
|
|
|
869
872
|
async function writePlan(plan: ProviderCreatePlan): Promise<void> {
|
|
870
873
|
for (const file of plan.files) {
|
|
871
874
|
await mkdir(dirname(file.path), { recursive: true });
|
|
875
|
+
if (file.kind === "symlink") {
|
|
876
|
+
// rm operates on the link itself (lstat semantics) and tolerates
|
|
877
|
+
// directories, so whatever occupies the path is replaced by the link.
|
|
878
|
+
await rm(file.path, { recursive: true, force: true });
|
|
879
|
+
await symlink(file.content, file.path);
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
872
882
|
await writeFile(file.path, file.content);
|
|
873
883
|
}
|
|
874
884
|
}
|
|
@@ -940,7 +950,10 @@ function printResult(plan: ProviderCreatePlan, jsonMode: boolean, dryRun: boolea
|
|
|
940
950
|
},
|
|
941
951
|
validationCommands: plan.validationCommands,
|
|
942
952
|
nextDevCommand: plan.nextDevCommand,
|
|
943
|
-
files: plan.files.map((file) =>
|
|
953
|
+
files: plan.files.map((file) => {
|
|
954
|
+
const relativePath = relative(plan.providerRoot, file.path) || file.path;
|
|
955
|
+
return file.kind === "symlink" ? `${relativePath} -> ${file.content} (symlink)` : relativePath;
|
|
956
|
+
}),
|
|
944
957
|
};
|
|
945
958
|
|
|
946
959
|
if (jsonMode) {
|