@apifuse/provider-sdk 2.1.0-beta.2 → 2.1.0-beta.4
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 +172 -8
- package/CHANGELOG.md +15 -1
- package/README.md +29 -15
- package/SUBMISSION.md +86 -0
- package/bin/apifuse-dev.ts +12 -5
- package/bin/apifuse-pack-check.ts +17 -2
- package/bin/apifuse-pack-smoke.ts +133 -6
- package/bin/apifuse-perf.ts +19 -15
- package/bin/apifuse-record.ts +41 -53
- package/bin/apifuse-submit-check.ts +1052 -0
- package/bin/apifuse.ts +1 -1
- package/package.json +19 -9
- package/src/choice-token.ts +164 -0
- package/src/cli/commands.ts +24 -3
- package/src/cli/create.ts +166 -51
- package/src/cli/templates/provider/README.md.tpl +66 -7
- package/src/cli/templates/provider/dev.ts.tpl +1 -1
- package/src/cli/templates/provider/domain/README.md.tpl +3 -0
- package/src/cli/templates/provider/index.ts.tpl +5 -47
- package/src/cli/templates/provider/mappers/README.md.tpl +3 -0
- package/src/cli/templates/provider/meta.ts.tpl +7 -0
- package/src/cli/templates/provider/operations/index.ts.tpl +5 -0
- package/src/cli/templates/provider/operations/ping.ts.tpl +23 -0
- package/src/cli/templates/provider/schemas/ping.ts.tpl +16 -0
- package/src/cli/templates/provider/start.ts.tpl +1 -1
- package/src/cli/templates/provider/upstream/README.md.tpl +3 -0
- package/src/config/loader.ts +1206 -9
- package/src/define.ts +1648 -43
- package/src/errors.ts +12 -0
- package/src/i18n/catalog.ts +121 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/keys.ts +64 -0
- package/src/index.ts +152 -8
- package/src/lint.ts +297 -42
- package/src/observability.ts +41 -0
- package/src/provider.ts +60 -3
- package/src/public-schema-field-lint.ts +237 -0
- package/src/runtime/auth-flow.ts +7 -0
- package/src/runtime/browser.ts +77 -21
- package/src/runtime/cache.ts +582 -0
- package/src/runtime/executor.ts +13 -1
- package/src/runtime/http.ts +939 -195
- package/src/runtime/insights.ts +11 -11
- package/src/runtime/instrumentation.ts +12 -4
- package/src/runtime/key-derivation.ts +1 -1
- package/src/runtime/keyring.ts +4 -3
- package/src/runtime/proxy-errors.ts +132 -0
- package/src/runtime/proxy-telemetry.ts +253 -0
- package/src/runtime/request-options.ts +66 -0
- package/src/runtime/state.ts +76 -0
- package/src/runtime/stealth.ts +1145 -0
- package/src/runtime/stt.ts +629 -0
- package/src/schema.ts +363 -1
- package/src/server/serve.ts +827 -60
- package/src/server/types.ts +35 -0
- package/src/stream.ts +210 -0
- package/src/testing/run.ts +17 -4
- package/src/types.ts +889 -50
- package/src/runtime/tls.ts +0 -434
- package/src/types/playwright-stealth.d.ts +0 -9
package/AUTHORING.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
## Generator and runtime alignment
|
|
2
2
|
|
|
3
3
|
- Canonical scaffolding command: `apifuse create`
|
|
4
|
-
-
|
|
4
|
+
- External bounty workspaces are one-provider repositories initialized with the standalone create flow. `--preset monorepo` is an internal APIFuse maintainer path only and must reject outside the private monorepo detected by `packages/provider-sdk/package.json`.
|
|
5
5
|
- Standalone bounty contributors should use `bunx @apifuse/provider-sdk@beta create <name> --yes` until this release is promoted to `latest`
|
|
6
6
|
- Provider server contract is:
|
|
7
7
|
- dev default `3900`
|
|
@@ -47,7 +47,7 @@ description:
|
|
|
47
47
|
- `description` — 150+ chars English (error-level rule)
|
|
48
48
|
- Every Zod field in input AND output has `.describe()` including nested objects + array items (error-level rule)
|
|
49
49
|
- `fixtures.request` + `fixtures.response` both present (error-level rule)
|
|
50
|
-
- Exactly one of `healthCheck` or `
|
|
50
|
+
- Exactly one of `healthCheck`, `healthCheckUnsupported`, or `healthJourneys[].coversOperations` coverage per operation. Prefer `healthCheck` for safe read-only upstream probes; use `healthCheckUnsupported` only with a specific reason for destructive, paid, credential-sensitive, flaky, or otherwise unsafe probes. Use a provider-level health journey when a destructive or credential-sensitive flow can be proven safely only as a multi-step boundary test, such as stopping at a payment WebView URL.
|
|
51
51
|
|
|
52
52
|
### Factored operations
|
|
53
53
|
|
|
@@ -65,6 +65,158 @@ Use `defineOperation()` when an operation is large enough to live beside helper
|
|
|
65
65
|
- `tags`: operation-level semantic tags for retrieval (e.g., `["weather", "korea", "realtime"]`)
|
|
66
66
|
- `relatedOperations`: `{ alternatives?: string[] }` — links to fallback/sibling operations
|
|
67
67
|
|
|
68
|
+
### STT runtime capability for audio OTP and short transcription
|
|
69
|
+
|
|
70
|
+
Providers that need speech-to-text should use the SDK runtime capability instead
|
|
71
|
+
of constructing a vendor client inside provider code. Declare STT at the provider
|
|
72
|
+
level, then call `ctx.stt` from operation handlers or auth-flow handlers.
|
|
73
|
+
|
|
74
|
+
<!-- @magic-start:sample -->
|
|
75
|
+
```ts
|
|
76
|
+
export default defineProvider({
|
|
77
|
+
id: "example-provider",
|
|
78
|
+
// ...metadata, auth, operations, allowedHosts
|
|
79
|
+
stt: { mode: "required" },
|
|
80
|
+
operations: {
|
|
81
|
+
verifyAudioOtp: {
|
|
82
|
+
input: z.object({
|
|
83
|
+
audioBase64: z.string().describe("Base64-encoded short OTP audio"),
|
|
84
|
+
mediaType: z.string().optional().describe("Audio MIME type"),
|
|
85
|
+
}),
|
|
86
|
+
output: z.object({ code: z.string().describe("Verification code") }),
|
|
87
|
+
async handler(ctx, input) {
|
|
88
|
+
const transcript = await ctx.stt.transcribe({
|
|
89
|
+
audio: {
|
|
90
|
+
kind: "base64",
|
|
91
|
+
data: input.audioBase64,
|
|
92
|
+
mediaType: input.mediaType,
|
|
93
|
+
},
|
|
94
|
+
language: "ko-KR",
|
|
95
|
+
mode: "otp",
|
|
96
|
+
verificationCode: { codeLengths: [4, 6] },
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const code =
|
|
100
|
+
transcript.verificationCode?.code ??
|
|
101
|
+
ctx.stt.extractVerificationCode(transcript.text, {
|
|
102
|
+
locale: "ko-KR",
|
|
103
|
+
codeLengths: [4, 6],
|
|
104
|
+
}).code;
|
|
105
|
+
|
|
106
|
+
return { code };
|
|
107
|
+
},
|
|
108
|
+
healthCheckUnsupported: {
|
|
109
|
+
reason: "Audio OTP transcription is cost-bearing and requires explicit smoke evidence.",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
<!-- @magic-end:sample -->
|
|
116
|
+
|
|
117
|
+
Best-practice rules:
|
|
118
|
+
|
|
119
|
+
- `stt: { mode: "required" }` is the production path for providers that depend
|
|
120
|
+
on STT; APIFuse provider manifests project STT credentials, model config, and
|
|
121
|
+
Cloudflare egress only for required STT. Use `mode: "optional"` only when STT
|
|
122
|
+
is a host/test override or truly best-effort capability that can remain
|
|
123
|
+
unavailable in production.
|
|
124
|
+
- Do not assume OTPs are always four digits. Configure accepted lengths, for
|
|
125
|
+
example `[4, 6]`, and keep the returned code as a string to preserve leading
|
|
126
|
+
zeros.
|
|
127
|
+
- Prompts are hints, not correctness guarantees. General transcription sends no
|
|
128
|
+
prompt by default. OTP mode may send a default digit-preserving hint. Use a
|
|
129
|
+
custom `initialPrompt` only with `promptPolicy: "custom-hint"`, and do not log
|
|
130
|
+
prompts, transcripts, raw audio, or OTP values.
|
|
131
|
+
- STT v1 accepts JSON-safe base64 audio only. Do not fetch arbitrary audio URLs
|
|
132
|
+
from provider code; URL input needs separate SSRF/private-network policy.
|
|
133
|
+
- Local and production wiring use the same env-backed runtime path. For the
|
|
134
|
+
Cloudflare Workers AI backend, set `APIFUSE__STT__BACKEND=cloudflare-workers-ai`,
|
|
135
|
+
`APIFUSE__STT__MODEL=@cf/openai/whisper-large-v3-turbo`,
|
|
136
|
+
`APIFUSE__CLOUDFLARE__ACCOUNT_ID`, and `APIFUSE__STT__CLOUDFLARE_API_TOKEN` in `.env.local` or the
|
|
137
|
+
provider workload environment. Do not deploy a Cloudflare Worker proxy for the
|
|
138
|
+
MVP; the SDK runtime calls Workers AI REST directly.
|
|
139
|
+
- Submission checks and health checks must not invoke live STT by default.
|
|
140
|
+
Provide explicit smoke evidence when a provider depends on audio OTP behavior.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Health journey DX for SMS/payment flows
|
|
144
|
+
|
|
145
|
+
Use `defineSmsOtpMatcher()` plus `defineHealthJourney()` when a real health signal requires an OTP ceremony and a safe handoff boundary. Keep matcher fields standards-backed: ISO 3166-1 alpha-2 `country`, BCP 47 `locale`, E.164 `phoneNumber` when present, ISO 8601 durations, and `nationalServiceCode` origins for local service senders. Do not add custom allowlist fields such as `senderAllowlist`; model the sender as an origin instead.
|
|
146
|
+
|
|
147
|
+
<!-- @magic-start:sample -->
|
|
148
|
+
```ts
|
|
149
|
+
import {
|
|
150
|
+
defineHealthJourney,
|
|
151
|
+
defineProvider,
|
|
152
|
+
defineSmsOtpMatcher,
|
|
153
|
+
every,
|
|
154
|
+
} from "@apifuse/provider-sdk";
|
|
155
|
+
|
|
156
|
+
const phoneOtp = defineSmsOtpMatcher({
|
|
157
|
+
id: "phone-otp",
|
|
158
|
+
country: "KR",
|
|
159
|
+
locale: "ko-KR",
|
|
160
|
+
origins: [
|
|
161
|
+
{
|
|
162
|
+
kind: "nationalServiceCode",
|
|
163
|
+
country: "KR",
|
|
164
|
+
value: "16615270",
|
|
165
|
+
display: "1661-5270",
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
code: { pattern: /인증번호는\s*\[([0-9]{4})\]/, capture: 1 },
|
|
169
|
+
maxAge: "PT5M",
|
|
170
|
+
waitTimeout: "PT2M30S",
|
|
171
|
+
clockSkew: "PT10S",
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const paymentWebviewJourney = defineHealthJourney({
|
|
175
|
+
id: "sms-payment-webview",
|
|
176
|
+
schedule: every("8h", { jitter: "PT20M" }),
|
|
177
|
+
timeout: "PT5M",
|
|
178
|
+
cooldown: "PT8H",
|
|
179
|
+
requiredSecrets: [
|
|
180
|
+
"APIFUSE__HEALTH_MONITOR__PROVIDER_PHONE",
|
|
181
|
+
"APIFUSE__HEALTH_MONITOR__PROVIDER_PASSWORD",
|
|
182
|
+
"APIFUSE__HEALTH_MONITOR__PROVIDER_CANARY_ORDER_JSON",
|
|
183
|
+
],
|
|
184
|
+
coversOperations: ["verify-phone", "confirm-phone", "place-order"],
|
|
185
|
+
smsMatchers: [phoneOtp],
|
|
186
|
+
steps: [
|
|
187
|
+
{ id: "send-phone-otp", kind: "operation", operationId: "verify-phone" },
|
|
188
|
+
{ id: "wait-phone-otp", kind: "smsOtp", usesSmsMatcher: "phone-otp" },
|
|
189
|
+
{ id: "confirm-phone-otp", kind: "operation", operationId: "confirm-phone" },
|
|
190
|
+
{
|
|
191
|
+
id: "create-payment-webview",
|
|
192
|
+
kind: "operation",
|
|
193
|
+
operationId: "place-order",
|
|
194
|
+
safeBoundary: "paymentWebviewUrl",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
export default defineProvider({
|
|
200
|
+
id: "example-provider",
|
|
201
|
+
// ...metadata, auth, operations, allowedHosts
|
|
202
|
+
healthJourneys: [paymentWebviewJourney],
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
<!-- @magic-end:sample -->
|
|
206
|
+
|
|
207
|
+
The journey runner supplies `ctx.gateway`, `ctx.sms.waitForOtp()`, `ctx.journal.sideEffect()`, `ctx.state`, and `ctx.event.operation()` to the optional journey `run` function. Provider authors should keep `run` small: call the covered operations in step order, stop at the declared safe boundary, and let the generated health metadata carry schedule, timeout, required secret, and SMS matcher information to the health monitor.
|
|
208
|
+
|
|
209
|
+
For authenticated journeys, open a fresh connection inside `run` with `ctx.gateway.connect({ input: { ... } })`, execute covered operations with the returned `connectionId`, and disconnect in a `finally` block. Do not require or store long-lived `HEALTH_MONITOR_*_CONNECTION_ID` secrets; those stale connection IDs can hide broken login ceremonies.
|
|
210
|
+
|
|
211
|
+
Use the runtime capabilities narrowly:
|
|
212
|
+
|
|
213
|
+
- `ctx.gateway.execute()` is the default path for operation health evidence; the runner records operation success/failure automatically.
|
|
214
|
+
- `ctx.journal.sideEffect()` wraps non-replayable provider mutations such as create/cancel/send operations.
|
|
215
|
+
- `ctx.state.namespace(name, policy)` stores bounded lifecycle memory and recovery cursors with TTL/quota/value-size policy. It is not a replacement for the side-effect journal.
|
|
216
|
+
- `ctx.event.operation()` records only synthetic operation outcomes proven by the journey, such as recovery/manual-review checks that are not direct gateway calls. The runtime rejects events for operations outside `coversOperations`.
|
|
217
|
+
|
|
218
|
+
Do not import `apps/health-monitor`, generated health artifacts, database repositories, schedulers, or recorders from provider code. If a journey needs provider-specific helper code, place it under the provider package (for example `providers/<id>/health-journeys/*`) and keep the SDK boundary generic.
|
|
219
|
+
|
|
68
220
|
### External bounty submission evidence
|
|
69
221
|
|
|
70
222
|
External contributors are expected to submit standalone Provider source plus:
|
|
@@ -74,6 +226,7 @@ External contributors are expected to submit standalone Provider source plus:
|
|
|
74
226
|
- Health coverage table for every Operation.
|
|
75
227
|
- `bun run check` output.
|
|
76
228
|
- `bun run test` output.
|
|
229
|
+
- `bun run submit-check` score/verdict and generated `submission-report.md`.
|
|
77
230
|
- Fixture evidence and known upstream constraints.
|
|
78
231
|
|
|
79
232
|
Maintainers own monorepo import under `providers/<id>/`, registry generation,
|
|
@@ -90,12 +243,23 @@ deployment projection checks, and release workflows.
|
|
|
90
243
|
- Auth-flow debugging starts with `/auth/start`, continues with
|
|
91
244
|
`/auth/continue`, and carries returned `contextPatch` values into the next
|
|
92
245
|
request's `context`.
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`
|
|
246
|
+
- Stealth/browser providers may require local runtime setup outside Provider code:
|
|
247
|
+
keep access-sensitive operations on `ctx.stealth.fetch()` with an SDK stealth
|
|
248
|
+
`profile`; the TypeScript runtime uses `impit` behind that interface, so do
|
|
249
|
+
not add per-operation JA3, HTTP/2 SETTINGS, or pseudo-header tuning. `ctx.stealth`
|
|
250
|
+
supports Chrome/Firefox-style profiles; use `browser.engine:
|
|
251
|
+
"playwright-stealth"` for Safari-specific or real browser Providers
|
|
252
|
+
(`nodriver` is Python-runtime only); install local browser assets with
|
|
253
|
+
`bunx playwright install chromium`, or set
|
|
254
|
+
`APIFUSE__CDP_POOL__URL` for remote browser debugging.
|
|
255
|
+
|
|
256
|
+
### Running the pre-submission report
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
bun run submit-check
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The report scores review readiness across definition metadata, operation/schema quality, fixtures/tests, health coverage, local smoke evidence, auth safety, secret hygiene, and submission docs. It is not a payout guarantee; any blocker must be fixed before review. For the complete public-only submission checklist, see `SUBMISSION.md` in the SDK package.
|
|
99
263
|
|
|
100
264
|
### Running the lint locally
|
|
101
265
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# @apifuse/provider-sdk Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
- Align `apifuse create` with the bounty program topology: external contributors use the standalone one-provider-repository scaffold even when their assigned repo contains workspace-like files.
|
|
6
|
+
- Stop auto-detecting `providers/` directories as public monorepo scaffolds. `--preset monorepo` is now reserved for the private APIFuse monorepo where `packages/provider-sdk` is actually present.
|
|
7
|
+
- Remove public CLI/docs examples that present monorepo placement as a contributor workflow.
|
|
8
|
+
|
|
9
|
+
## 2.1.0-beta.3
|
|
10
|
+
|
|
11
|
+
- Replace the legacy TypeScript request transport with `ctx.stealth`, backed by `impit` browser-grade TLS/HTTP2 impersonation without Python runtime dependencies.
|
|
12
|
+
- Add the public `apifuse submit-check` / `apifuse bounty-check` CLI for score-based pre-submission provider quality checks.
|
|
13
|
+
- Ship `SUBMISSION.md` in the npm package so bounty contributors can follow the checklist without access to the private monorepo.
|
|
14
|
+
- Include submit-check in generated provider validation scripts and packed-artifact smoke coverage.
|
|
15
|
+
- Warn, instead of hard-block, generated OAuth starters that have not yet declared persisted credential keys.
|
|
16
|
+
|
|
3
17
|
## 2.1.0-beta.2
|
|
4
18
|
|
|
5
19
|
- Harden public bounty contributor DX with server-contract accurate README and generated Provider smoke examples.
|
|
6
20
|
- Add packed-artifact regression checks so stale `connection: null` or missing `requestId` examples cannot ship again.
|
|
7
21
|
- Extend clean-room packed SDK smoke coverage to boot the generated dev server and call `/health` plus `POST /v1/ping`.
|
|
8
|
-
- Document credential, auth-flow,
|
|
22
|
+
- Document credential, auth-flow, stealth, browser, and Bun trusted-dependency troubleshooting for SDK-only local development.
|
|
9
23
|
|
|
10
24
|
## 2.1.0-beta.1
|
|
11
25
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @apifuse/provider-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
APIFuse Provider SDK — build provider declarations and runtimes with one public SDK surface and one canonical CLI.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -29,13 +29,11 @@ The canonical `create` flow:
|
|
|
29
29
|
3. runs baseline validation,
|
|
30
30
|
4. prints the exact next local-dev command.
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### Repository shape
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
The Provider SDK is a public bounty-contributor tool first. External bounty workspaces are one-provider repositories initialized from the standalone create flow. The generated provider must be installable without private APIFuse monorepo access.
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
apifuse create my-provider --preset monorepo
|
|
38
|
-
```
|
|
36
|
+
Do not use internal monorepo placement for bounty workspaces. Accepted provider work is imported into the private APIFuse monorepo later by maintainers or trusted automation.
|
|
39
37
|
|
|
40
38
|
## Provider server contract
|
|
41
39
|
|
|
@@ -58,6 +56,7 @@ Removed legacy runtime paths are not supported:
|
|
|
58
56
|
cd my-provider
|
|
59
57
|
bun run check
|
|
60
58
|
bun run test
|
|
59
|
+
bun run submit-check
|
|
61
60
|
bun run dev
|
|
62
61
|
```
|
|
63
62
|
|
|
@@ -70,7 +69,7 @@ curl -s -X POST http://localhost:3900/v1/ping \
|
|
|
70
69
|
-d '{"requestId":"req_local_ping","input":{"value":"hello"},"headers":{}}'
|
|
71
70
|
```
|
|
72
71
|
|
|
73
|
-
The operation request body is the same envelope used by the
|
|
72
|
+
The operation request body is the same envelope used by the APIFuse gateway:
|
|
74
73
|
|
|
75
74
|
| Field | Required | Notes |
|
|
76
75
|
|---|---:|---|
|
|
@@ -88,7 +87,7 @@ curl -s -X POST http://localhost:3900/v1/me \
|
|
|
88
87
|
"requestId":"req_local_me",
|
|
89
88
|
"input":{},
|
|
90
89
|
"connection":{
|
|
91
|
-
"id":"
|
|
90
|
+
"id":"af_con_local_debug",
|
|
92
91
|
"mode":"credentials",
|
|
93
92
|
"secrets":{"apiKey":"dev-only-secret"},
|
|
94
93
|
"scopes":[],
|
|
@@ -124,14 +123,17 @@ the bad request path; provider/runtime failures include `code`, `message`, and
|
|
|
124
123
|
- **Auth flows**: call `/auth/start`, then `/auth/continue` with the same
|
|
125
124
|
`flowId`; preserve any returned `contextPatch` in the next local request's
|
|
126
125
|
`context` object.
|
|
127
|
-
- **
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
`
|
|
126
|
+
- **Stealth-sensitive providers**: use `ctx.http` for normal JSON/REST calls and
|
|
127
|
+
`ctx.stealth.fetch()` when you need browser-like session or cookie control. `ctx.stealth.fetch()` uses the impit-backed browser stealth transport and accepts request
|
|
128
|
+
controls for `params`, `proxy`, `timeout`, `profile`, `throwOnHttpError`, and
|
|
129
|
+
`stealth.insecureSkipVerify`. Select an SDK stealth `profile` such as
|
|
130
|
+
`chrome-146`; do not tune JA3, HTTP/2 SETTINGS, or pseudo-header order in
|
|
131
|
+
provider code. Chrome/Firefox-style profiles are supported; use `ctx.browser`
|
|
132
|
+
when Safari-specific behavior is required.
|
|
131
133
|
- **Browser providers**: for TypeScript Providers use `runtime: "browser"` plus
|
|
132
134
|
`browser.engine: "playwright-stealth"`; `nodriver` is a Python-runtime path.
|
|
133
135
|
Install local browser assets with `bunx playwright install chromium` when
|
|
134
|
-
using the Playwright runtime, or set `
|
|
136
|
+
using the Playwright runtime, or set `APIFUSE__CDP_POOL__URL`
|
|
135
137
|
when debugging against a remote browser pool.
|
|
136
138
|
|
|
137
139
|
## Authoring ergonomics
|
|
@@ -195,14 +197,26 @@ apifuse dev [path]
|
|
|
195
197
|
apifuse check [path]
|
|
196
198
|
apifuse record [path] --operation <operation> --params '{"value":"hello"}'
|
|
197
199
|
apifuse test [path]
|
|
200
|
+
apifuse submit-check [path] --tier bronze --markdown submission-report.md
|
|
201
|
+
apifuse bounty-check [path]
|
|
198
202
|
apifuse perf <path> --operation <operation>
|
|
199
203
|
```
|
|
200
204
|
|
|
201
205
|
`apifuse record` is for real upstream-backed operations that declare
|
|
202
|
-
`upstream.baseUrl` and call the upstream through `ctx.http` or `ctx.
|
|
206
|
+
`upstream.baseUrl` and call the upstream through `ctx.http` or `ctx.stealth`. The
|
|
203
207
|
generated local-only `ping` operation intentionally has no upstream and should
|
|
204
208
|
be replaced before recording fixtures.
|
|
205
209
|
|
|
210
|
+
## Bounty submission readiness
|
|
211
|
+
|
|
212
|
+
Standalone providers include a pre-submission script:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
bun run submit-check
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This runs the public review-readiness evaluator and writes `submission-report.md`. The report contains provider metadata, a 100-point readiness score, hard blockers, warnings, checklist evidence, and remediation. Blockers override the score; fix them before posting bounty evidence. The command is offline-safe by default and does not execute arbitrary upstream calls. Add local smoke notes to your assigned workspace PR after testing `/health` and `POST /v1/{operation}`. See [`SUBMISSION.md`](./SUBMISSION.md) for the full public-only bounty submission checklist shipped in the npm package.
|
|
219
|
+
|
|
206
220
|
## Scope boundary
|
|
207
221
|
|
|
208
222
|
Generator v1 scaffolds **TypeScript providers only** for this redesign. Python generation remains future work.
|
|
@@ -213,6 +227,6 @@ Generator v1 scaffolds **TypeScript providers only** for this redesign. Python g
|
|
|
213
227
|
Provider cataloging, deployment enrollment, docs indexing, and runtime discovery are internal platform-registry responsibilities and are not part of the public `@apifuse/provider-sdk` contract.
|
|
214
228
|
|
|
215
229
|
External bounty contributors should submit standalone Provider source plus
|
|
216
|
-
`bun run check` / `bun run test` evidence.
|
|
230
|
+
`bun run check` / `bun run test` evidence. APIFuse maintainers own monorepo
|
|
217
231
|
import, registry generation, deployment projection checks, and release
|
|
218
232
|
publishing.
|
package/SUBMISSION.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Provider bounty submission guide
|
|
2
|
+
|
|
3
|
+
This guide is for public bounty contributors who only have access to the published `@apifuse/provider-sdk` package. You do **not** need the private APIFuse monorepo to build or pre-check a Provider.
|
|
4
|
+
|
|
5
|
+
## SDK-only workspace workflow
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx @apifuse/provider-sdk@beta create my-provider --yes
|
|
9
|
+
cd my-provider
|
|
10
|
+
bun run check
|
|
11
|
+
bun run test
|
|
12
|
+
bun run submit-check
|
|
13
|
+
bun run dev
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`bun run submit-check` runs `apifuse submit-check . --markdown submission-report.md` in generated Providers.
|
|
17
|
+
|
|
18
|
+
## What submit-check scores
|
|
19
|
+
|
|
20
|
+
`apifuse submit-check` produces a 100-point review-readiness score and a verdict:
|
|
21
|
+
|
|
22
|
+
- `ready` — no blockers or warnings and score is at least 90.
|
|
23
|
+
- `reviewable_with_warnings` — no blockers, but reviewers should inspect the warnings.
|
|
24
|
+
- `blocked` — at least one hard blocker must be fixed before review.
|
|
25
|
+
|
|
26
|
+
The score is a triage aid, not a payout guarantee. Maintainers still review correctness, upstream behavior, policy fit, and bounty scope.
|
|
27
|
+
|
|
28
|
+
| Category | Points | Examples |
|
|
29
|
+
|---|---:|---|
|
|
30
|
+
| Definition & metadata | 15 | `defineProvider`, package, Dockerfile, SDK structural checks |
|
|
31
|
+
| Operations & schemas | 15 | strong descriptions, annotations, input/output schemas |
|
|
32
|
+
| Fixtures & tests | 15 | bidirectional fixtures that parse against schemas |
|
|
33
|
+
| Health coverage | 15 | real `healthCheck` or specific `healthCheckUnsupported.reason` |
|
|
34
|
+
| Runtime/local smoke | 10 | `/health` and at least one `POST /v1/{operation}` note |
|
|
35
|
+
| Auth/credential safety | 10 | auth mode and credential declarations are consistent |
|
|
36
|
+
| Security hygiene | 10 | no high-confidence secrets in shareable files |
|
|
37
|
+
| Docs/submission evidence | 10 | README Parameters, Response, Example, submit-check guidance |
|
|
38
|
+
|
|
39
|
+
## Hard blockers
|
|
40
|
+
|
|
41
|
+
Fix all blockers before submitting:
|
|
42
|
+
|
|
43
|
+
- `bun run check` failures.
|
|
44
|
+
- Provider cannot be imported from `index.ts`.
|
|
45
|
+
- Missing handler/input/output for any Operation.
|
|
46
|
+
- Missing fixture request or response.
|
|
47
|
+
- Fixture data does not parse against schemas.
|
|
48
|
+
- Missing `healthCheck` or `healthCheckUnsupported` on any Operation.
|
|
49
|
+
- Credential-backed auth mode without declared credential keys.
|
|
50
|
+
- High-confidence secret or token material in source, README, package metadata, or fixtures.
|
|
51
|
+
|
|
52
|
+
Warnings do not fail the command, but they should be addressed when practical. For example, the generated starter `ping` operation warns because it is not a real upstream-backed bounty Operation.
|
|
53
|
+
|
|
54
|
+
## Safe local smoke evidence
|
|
55
|
+
|
|
56
|
+
`submit-check` does not call arbitrary live upstream APIs by default. After replacing starter logic, run the Provider locally and record a short evidence note:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bun run dev
|
|
60
|
+
curl -s http://localhost:3900/health
|
|
61
|
+
curl -s -X POST http://localhost:3900/v1/<operation> \
|
|
62
|
+
-H 'Content-Type: application/json' \
|
|
63
|
+
-d '{"requestId":"req_local_smoke","input":{...},"headers":{}}'
|
|
64
|
+
|
|
65
|
+
bun run submit-check -- --smoke-note "GET /health and POST /v1/<operation> passed locally with redacted input."
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Never paste real credentials, personal data, account numbers, access tokens, cookies, or unredacted upstream responses into workspace PR comments, chat, or reports.
|
|
69
|
+
|
|
70
|
+
## Submission evidence checklist
|
|
71
|
+
|
|
72
|
+
Include the following when you submit a Provider for review:
|
|
73
|
+
|
|
74
|
+
- Provider SDK version, for example `bun pm ls @apifuse/provider-sdk` or package.json dependency.
|
|
75
|
+
- Provider id, version, runtime, and auth mode.
|
|
76
|
+
- Operation list with input/output summaries.
|
|
77
|
+
- Health coverage table: one row per Operation with `healthCheck` or `healthCheckUnsupported` and rationale.
|
|
78
|
+
- `bun run check` output.
|
|
79
|
+
- `bun run test` output.
|
|
80
|
+
- `submission-report.md` generated by `bun run submit-check`.
|
|
81
|
+
- Local smoke evidence for `/health` and at least one `POST /v1/{operation}` call.
|
|
82
|
+
- Known upstream constraints: rate limits, paid/destructive calls, auth limits, flaky endpoints, or unsupported probes.
|
|
83
|
+
|
|
84
|
+
## Maintainer-owned follow-up
|
|
85
|
+
|
|
86
|
+
After workspace evidence is submitted, APIFuse maintainers import accepted standalone Provider work into the private monorepo and run internal registry, generated artifact, deployment projection, and CI checks. External contributors are not expected to run those private checks.
|
package/bin/apifuse-dev.ts
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { dirname, relative, resolve } from "node:path";
|
|
5
|
-
|
|
6
5
|
import type { ProviderDefinition } from "../src";
|
|
7
6
|
import {
|
|
8
7
|
createBrowserClient,
|
|
9
8
|
createCredentialContext,
|
|
10
9
|
createEnvContext,
|
|
11
10
|
createHttpClient,
|
|
12
|
-
|
|
11
|
+
createProviderCache,
|
|
12
|
+
createStealthClient,
|
|
13
|
+
createSttClientFromEnv,
|
|
13
14
|
ProviderError,
|
|
14
15
|
} from "../src";
|
|
16
|
+
import { createUnsupportedProviderRuntimeState } from "../src/runtime/state";
|
|
15
17
|
import { createTraceContext } from "../src/runtime/trace";
|
|
16
18
|
import type { BrowserClient, ProviderContext } from "../src/types";
|
|
17
19
|
|
|
@@ -35,7 +37,7 @@ export async function main() {
|
|
|
35
37
|
);
|
|
36
38
|
|
|
37
39
|
const { startDevServer } = await import("../src/dev");
|
|
38
|
-
const port = Number(process.env.
|
|
40
|
+
const port = Number(process.env.APIFUSE__RUNTIME__PORT) || 3900;
|
|
39
41
|
|
|
40
42
|
startDevServer(provider, { port });
|
|
41
43
|
|
|
@@ -85,8 +87,11 @@ export function createProviderContext(provider: ProviderDefinition): {
|
|
|
85
87
|
})
|
|
86
88
|
: createUnsupportedBrowserStub(),
|
|
87
89
|
http: createHttpClient(),
|
|
90
|
+
cache: createProviderCache({ providerId: provider.id }),
|
|
91
|
+
state: createUnsupportedProviderRuntimeState(),
|
|
88
92
|
trace: createTraceContext(),
|
|
89
|
-
|
|
93
|
+
stealth: createStealthClient("http://localhost"),
|
|
94
|
+
stt: createSttClientFromEnv(provider.stt),
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
return { ctx };
|
|
@@ -129,7 +134,9 @@ function renderHotReloadCommand(providerPath: string, port: number): string {
|
|
|
129
134
|
const devEntry = resolve(providerPath, "dev.ts");
|
|
130
135
|
if (existsSync(devEntry)) {
|
|
131
136
|
const relativeDevEntry = relative(process.cwd(), devEntry) || "dev.ts";
|
|
132
|
-
const portPrefix = process.env.
|
|
137
|
+
const portPrefix = process.env.APIFUSE__RUNTIME__PORT
|
|
138
|
+
? `APIFUSE__RUNTIME__PORT=${port} `
|
|
139
|
+
: "";
|
|
133
140
|
return `${portPrefix}bun --hot ${relativeDevEntry}`;
|
|
134
141
|
}
|
|
135
142
|
return "rerun `apifuse dev` after edits (no dev.ts entrypoint found)";
|
|
@@ -33,9 +33,18 @@ const requiredPaths = [
|
|
|
33
33
|
"bin/apifuse.ts",
|
|
34
34
|
"bin/apifuse-create.ts",
|
|
35
35
|
"bin/apifuse-pack-smoke.ts",
|
|
36
|
+
"bin/apifuse-submit-check.ts",
|
|
37
|
+
"SUBMISSION.md",
|
|
36
38
|
"src/cli/create.ts",
|
|
37
39
|
"src/cli/templates/provider/index.ts.tpl",
|
|
38
40
|
"src/cli/templates/provider/README.md.tpl",
|
|
41
|
+
"src/cli/templates/provider/meta.ts.tpl",
|
|
42
|
+
"src/cli/templates/provider/domain/README.md.tpl",
|
|
43
|
+
"src/cli/templates/provider/mappers/README.md.tpl",
|
|
44
|
+
"src/cli/templates/provider/operations/index.ts.tpl",
|
|
45
|
+
"src/cli/templates/provider/operations/ping.ts.tpl",
|
|
46
|
+
"src/cli/templates/provider/schemas/ping.ts.tpl",
|
|
47
|
+
"src/cli/templates/provider/upstream/README.md.tpl",
|
|
39
48
|
];
|
|
40
49
|
const forbiddenMatches = filePaths.filter(
|
|
41
50
|
(path) =>
|
|
@@ -111,9 +120,15 @@ function assertPublicSmokeDocs(label: string, content: string): void {
|
|
|
111
120
|
);
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
if (!content.includes("
|
|
123
|
+
if (!content.includes("impit")) {
|
|
115
124
|
throw new Error(
|
|
116
|
-
`${label} must include
|
|
125
|
+
`${label} must include impit stealth runtime guidance for TLS/browser bounties.`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!content.includes("submit-check")) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
`${label} must document the submit-check pre-submission workflow.`,
|
|
117
132
|
);
|
|
118
133
|
}
|
|
119
134
|
|