@apifuse/provider-sdk 2.1.0-beta.3 → 2.1.0-beta.5

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.
Files changed (63) hide show
  1. package/AUTHORING.md +187 -8
  2. package/CHANGELOG.md +13 -1
  3. package/README.md +40 -18
  4. package/SUBMISSION.md +4 -4
  5. package/bin/apifuse-dev.ts +12 -5
  6. package/bin/apifuse-pack-check.ts +9 -2
  7. package/bin/apifuse-pack-smoke.ts +127 -6
  8. package/bin/apifuse-perf.ts +76 -31
  9. package/bin/apifuse-record.ts +148 -94
  10. package/bin/apifuse-submit-check.ts +243 -7
  11. package/bin/apifuse.ts +1 -1
  12. package/package.json +17 -8
  13. package/src/choice-token.ts +164 -0
  14. package/src/cli/commands.ts +4 -7
  15. package/src/cli/create.ts +180 -51
  16. package/src/cli/templates/provider/.dockerignore.tpl +22 -0
  17. package/src/cli/templates/provider/.gitignore.tpl +22 -0
  18. package/src/cli/templates/provider/README.md.tpl +42 -7
  19. package/src/cli/templates/provider/dev.ts.tpl +1 -1
  20. package/src/cli/templates/provider/domain/README.md.tpl +3 -0
  21. package/src/cli/templates/provider/index.ts.tpl +5 -47
  22. package/src/cli/templates/provider/mappers/README.md.tpl +3 -0
  23. package/src/cli/templates/provider/meta.ts.tpl +7 -0
  24. package/src/cli/templates/provider/operations/index.ts.tpl +5 -0
  25. package/src/cli/templates/provider/operations/ping.ts.tpl +23 -0
  26. package/src/cli/templates/provider/schemas/ping.ts.tpl +16 -0
  27. package/src/cli/templates/provider/start.ts.tpl +1 -1
  28. package/src/cli/templates/provider/upstream/README.md.tpl +3 -0
  29. package/src/config/loader.ts +1206 -9
  30. package/src/define.ts +1620 -106
  31. package/src/errors.ts +12 -0
  32. package/src/i18n/catalog.ts +121 -0
  33. package/src/i18n/index.ts +2 -0
  34. package/src/i18n/keys.ts +64 -0
  35. package/src/index.ts +149 -8
  36. package/src/lint.ts +306 -51
  37. package/src/observability.ts +41 -0
  38. package/src/provider.ts +60 -3
  39. package/src/public-schema-field-lint.ts +237 -0
  40. package/src/runtime/auth-flow.ts +7 -0
  41. package/src/runtime/browser.ts +77 -21
  42. package/src/runtime/cache.ts +582 -0
  43. package/src/runtime/executor.ts +13 -1
  44. package/src/runtime/http.ts +939 -195
  45. package/src/runtime/insights.ts +11 -11
  46. package/src/runtime/instrumentation.ts +12 -4
  47. package/src/runtime/key-derivation.ts +1 -1
  48. package/src/runtime/keyring.ts +4 -3
  49. package/src/runtime/proxy-errors.ts +132 -0
  50. package/src/runtime/proxy-telemetry.ts +253 -0
  51. package/src/runtime/request-options.ts +66 -0
  52. package/src/runtime/state.ts +76 -0
  53. package/src/runtime/stealth.ts +1145 -0
  54. package/src/runtime/stt.ts +629 -0
  55. package/src/runtime/trace.ts +1 -1
  56. package/src/schema.ts +363 -1
  57. package/src/server/serve.ts +816 -58
  58. package/src/server/types.ts +35 -0
  59. package/src/stream.ts +210 -0
  60. package/src/testing/run.ts +17 -4
  61. package/src/types.ts +876 -53
  62. package/src/runtime/tls.ts +0 -434
  63. 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
- - Monorepo contributors should use `apifuse create <name> --preset monorepo`
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,12 +47,36 @@ 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 `healthCheckUnsupported` 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.
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
 
54
54
  Use `defineOperation()` when an operation is large enough to live beside helper functions or in a separate module. It preserves the same type inference as inline `defineProvider()` operations and can be placed directly in the provider `operations` map. `defineProvider()` accepts Zod and Standard Schema v1-compatible schemas. If config validation fails, the SDK names the field to fix, for example `runtime`, `auth.mode`, `operations.<id>.handler`, or `operations.<id>.fixtures.response`.
55
55
 
56
+ ### Health assertion context
57
+
58
+ `healthCheck.cases[].assertions` receives a `HealthCheckAssertionContext` with
59
+ `data`, `status`, `durationMs`, and optional `meta`. `data` is typed from the
60
+ operation output schema, so assertions should inspect normalized output instead
61
+ of reaching into transport internals.
62
+
63
+ <!-- @magic-start:sample -->
64
+ ```ts
65
+ healthCheck: {
66
+ interval: "5m",
67
+ cases: [{
68
+ name: "lookup baseline",
69
+ input: { q: "btc" },
70
+ assertions: ({ data, status, durationMs }) => {
71
+ if (status !== 200 || data.results.length === 0 || durationMs > 3000) {
72
+ return { status: "degraded", label: "lookup baseline changed" };
73
+ }
74
+ },
75
+ }],
76
+ }
77
+ ```
78
+ <!-- @magic-end:sample -->
79
+
56
80
  ### Strongly recommended (warn-level rules)
57
81
 
58
82
  - `description` includes "use" AND "when" phrasing
@@ -65,6 +89,158 @@ Use `defineOperation()` when an operation is large enough to live beside helper
65
89
  - `tags`: operation-level semantic tags for retrieval (e.g., `["weather", "korea", "realtime"]`)
66
90
  - `relatedOperations`: `{ alternatives?: string[] }` — links to fallback/sibling operations
67
91
 
92
+ ### STT runtime capability for audio OTP and short transcription
93
+
94
+ Providers that need speech-to-text should use the SDK runtime capability instead
95
+ of constructing a vendor client inside provider code. Declare STT at the provider
96
+ level, then call `ctx.stt` from operation handlers or auth-flow handlers.
97
+
98
+ <!-- @magic-start:sample -->
99
+ ```ts
100
+ export default defineProvider({
101
+ id: "example-provider",
102
+ // ...metadata, auth, operations, allowedHosts
103
+ stt: { mode: "required" },
104
+ operations: {
105
+ verifyAudioOtp: {
106
+ input: z.object({
107
+ audioBase64: z.string().describe("Base64-encoded short OTP audio"),
108
+ mediaType: z.string().optional().describe("Audio MIME type"),
109
+ }),
110
+ output: z.object({ code: z.string().describe("Verification code") }),
111
+ async handler(ctx, input) {
112
+ const transcript = await ctx.stt.transcribe({
113
+ audio: {
114
+ kind: "base64",
115
+ data: input.audioBase64,
116
+ mediaType: input.mediaType,
117
+ },
118
+ language: "ko-KR",
119
+ mode: "otp",
120
+ verificationCode: { codeLengths: [4, 6] },
121
+ });
122
+
123
+ const code =
124
+ transcript.verificationCode?.code ??
125
+ ctx.stt.extractVerificationCode(transcript.text, {
126
+ locale: "ko-KR",
127
+ codeLengths: [4, 6],
128
+ }).code;
129
+
130
+ return { code };
131
+ },
132
+ healthCheckUnsupported: {
133
+ reason: "Audio OTP transcription is cost-bearing and requires explicit smoke evidence.",
134
+ },
135
+ },
136
+ },
137
+ });
138
+ ```
139
+ <!-- @magic-end:sample -->
140
+
141
+ Best-practice rules:
142
+
143
+ - `stt: { mode: "required" }` is the production path for providers that depend
144
+ on STT; APIFuse provider manifests project STT credentials, model config, and
145
+ Cloudflare egress only for required STT. Use `mode: "optional"` only when STT
146
+ is a host/test override or truly best-effort capability that can remain
147
+ unavailable in production.
148
+ - Do not assume OTPs are always four digits. Configure accepted lengths, for
149
+ example `[4, 6]`, and keep the returned code as a string to preserve leading
150
+ zeros.
151
+ - Prompts are hints, not correctness guarantees. General transcription sends no
152
+ prompt by default. OTP mode may send a default digit-preserving hint. Use a
153
+ custom `initialPrompt` only with `promptPolicy: "custom-hint"`, and do not log
154
+ prompts, transcripts, raw audio, or OTP values.
155
+ - STT v1 accepts JSON-safe base64 audio only. Do not fetch arbitrary audio URLs
156
+ from provider code; URL input needs separate SSRF/private-network policy.
157
+ - Local and production wiring use the same env-backed runtime path. For the
158
+ Cloudflare Workers AI backend, set `APIFUSE__STT__BACKEND=cloudflare-workers-ai`,
159
+ `APIFUSE__STT__MODEL=@cf/openai/whisper-large-v3-turbo`,
160
+ `APIFUSE__CLOUDFLARE__ACCOUNT_ID`, and `APIFUSE__STT__CLOUDFLARE_API_TOKEN` in `.env.local` or the
161
+ provider workload environment. Do not deploy a Cloudflare Worker proxy for the
162
+ MVP; the SDK runtime calls Workers AI REST directly.
163
+ - Submission checks and health checks must not invoke live STT by default.
164
+ Provide explicit smoke evidence when a provider depends on audio OTP behavior.
165
+
166
+
167
+ ### Health journey DX for SMS/payment flows
168
+
169
+ 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.
170
+
171
+ <!-- @magic-start:sample -->
172
+ ```ts
173
+ import {
174
+ defineHealthJourney,
175
+ defineProvider,
176
+ defineSmsOtpMatcher,
177
+ every,
178
+ } from "@apifuse/provider-sdk";
179
+
180
+ const phoneOtp = defineSmsOtpMatcher({
181
+ id: "phone-otp",
182
+ country: "KR",
183
+ locale: "ko-KR",
184
+ origins: [
185
+ {
186
+ kind: "nationalServiceCode",
187
+ country: "KR",
188
+ value: "16615270",
189
+ display: "1661-5270",
190
+ },
191
+ ],
192
+ code: { pattern: /인증번호는\s*\[([0-9]{4})\]/, capture: 1 },
193
+ maxAge: "PT5M",
194
+ waitTimeout: "PT2M30S",
195
+ clockSkew: "PT10S",
196
+ });
197
+
198
+ const paymentWebviewJourney = defineHealthJourney({
199
+ id: "sms-payment-webview",
200
+ schedule: every("8h", { jitter: "PT20M" }),
201
+ timeout: "PT5M",
202
+ cooldown: "PT8H",
203
+ requiredSecrets: [
204
+ "APIFUSE__HEALTH_MONITOR__PROVIDER_PHONE",
205
+ "APIFUSE__HEALTH_MONITOR__PROVIDER_PASSWORD",
206
+ "APIFUSE__HEALTH_MONITOR__PROVIDER_CANARY_ORDER_JSON",
207
+ ],
208
+ coversOperations: ["verify-phone", "confirm-phone", "place-order"],
209
+ smsMatchers: [phoneOtp],
210
+ steps: [
211
+ { id: "send-phone-otp", kind: "operation", operationId: "verify-phone" },
212
+ { id: "wait-phone-otp", kind: "smsOtp", usesSmsMatcher: "phone-otp" },
213
+ { id: "confirm-phone-otp", kind: "operation", operationId: "confirm-phone" },
214
+ {
215
+ id: "create-payment-webview",
216
+ kind: "operation",
217
+ operationId: "place-order",
218
+ safeBoundary: "paymentWebviewUrl",
219
+ },
220
+ ],
221
+ });
222
+
223
+ export default defineProvider({
224
+ id: "example-provider",
225
+ // ...metadata, auth, operations, allowedHosts
226
+ healthJourneys: [paymentWebviewJourney],
227
+ });
228
+ ```
229
+ <!-- @magic-end:sample -->
230
+
231
+ 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.
232
+
233
+ 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.
234
+
235
+ Use the runtime capabilities narrowly:
236
+
237
+ - `ctx.gateway.execute()` is the default path for operation health evidence; the runner records operation success/failure automatically.
238
+ - `ctx.journal.sideEffect()` wraps non-replayable provider mutations such as create/cancel/send operations.
239
+ - `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.
240
+ - `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`.
241
+
242
+ 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.
243
+
68
244
  ### External bounty submission evidence
69
245
 
70
246
  External contributors are expected to submit standalone Provider source plus:
@@ -91,12 +267,15 @@ deployment projection checks, and release workflows.
91
267
  - Auth-flow debugging starts with `/auth/start`, continues with
92
268
  `/auth/continue`, and carries returned `contextPatch` values into the next
93
269
  request's `context`.
94
- - TLS/browser providers may require local runtime setup outside Provider code:
95
- use `bun pm untrusted`/`bun pm trust koffi` for blocked native TLS dependency
96
- scripts, `browser.engine: "playwright-stealth"` for TypeScript browser
97
- Providers (`nodriver` is Python-runtime only), `bunx playwright install
98
- chromium` for local Playwright browser assets, or
99
- `CDP_POOL_URL`/`APIFUSE_CDP_POOL_URL` for remote browser debugging.
270
+ - Stealth/browser providers may require local runtime setup outside Provider code:
271
+ keep access-sensitive operations on `ctx.stealth.fetch()` with an SDK stealth
272
+ `profile`; the TypeScript runtime uses `impit` behind that interface, so do
273
+ not add per-operation JA3, HTTP/2 SETTINGS, or pseudo-header tuning. `ctx.stealth`
274
+ supports Chrome/Firefox-style profiles; use `browser.engine:
275
+ "playwright-stealth"` for Safari-specific or real browser Providers
276
+ (`nodriver` is Python-runtime only); install local browser assets with
277
+ `bunx playwright install chromium`, or set
278
+ `APIFUSE__CDP_POOL__URL` for remote browser debugging.
100
279
 
101
280
  ### Running the pre-submission report
102
281
 
package/CHANGELOG.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # @apifuse/provider-sdk Changelog
2
2
 
3
+ ## 2.1.0-beta.5
4
+
5
+ - Republish the bounty workspace DX hardening that accepts generated readonly metadata and factored `defineOperation()` maps during standalone TypeScript checks.
6
+ - Ensure new bounty workspaces can install the public SDK version that matches their generated scaffold and pass `bun run check` immediately after bootstrap.
7
+
8
+ ## 2.1.0-beta.4
9
+
10
+ - 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.
11
+ - 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.
12
+ - Remove public CLI/docs examples that present monorepo placement as a contributor workflow.
13
+
3
14
  ## 2.1.0-beta.3
4
15
 
16
+ - Replace the legacy TypeScript request transport with `ctx.stealth`, backed by `impit` browser-grade TLS/HTTP2 impersonation without Python runtime dependencies.
5
17
  - Add the public `apifuse submit-check` / `apifuse bounty-check` CLI for score-based pre-submission provider quality checks.
6
18
  - Ship `SUBMISSION.md` in the npm package so bounty contributors can follow the checklist without access to the private monorepo.
7
19
  - Include submit-check in generated provider validation scripts and packed-artifact smoke coverage.
@@ -12,7 +24,7 @@
12
24
  - Harden public bounty contributor DX with server-contract accurate README and generated Provider smoke examples.
13
25
  - Add packed-artifact regression checks so stale `connection: null` or missing `requestId` examples cannot ship again.
14
26
  - Extend clean-room packed SDK smoke coverage to boot the generated dev server and call `/health` plus `POST /v1/ping`.
15
- - Document credential, auth-flow, TLS, browser, and Bun trusted-dependency troubleshooting for SDK-only local development.
27
+ - Document credential, auth-flow, stealth, browser, and Bun trusted-dependency troubleshooting for SDK-only local development.
16
28
 
17
29
  ## 2.1.0-beta.1
18
30
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @apifuse/provider-sdk
2
2
 
3
- ApiFuse Provider SDK — build provider declarations and runtimes with one public SDK surface and one canonical CLI.
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
- ### Monorepo preset
32
+ ### Repository shape
33
33
 
34
- Inside the ApiFuse repository:
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
- ```bash
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
 
@@ -71,7 +69,7 @@ curl -s -X POST http://localhost:3900/v1/ping \
71
69
  -d '{"requestId":"req_local_ping","input":{"value":"hello"},"headers":{}}'
72
70
  ```
73
71
 
74
- The operation request body is the same envelope used by the ApiFuse gateway:
72
+ The operation request body is the same envelope used by the APIFuse gateway:
75
73
 
76
74
  | Field | Required | Notes |
77
75
  |---|---:|---|
@@ -89,7 +87,7 @@ curl -s -X POST http://localhost:3900/v1/me \
89
87
  "requestId":"req_local_me",
90
88
  "input":{},
91
89
  "connection":{
92
- "id":"conn_local_debug",
90
+ "id":"af_con_local_debug",
93
91
  "mode":"credentials",
94
92
  "secrets":{"apiKey":"dev-only-secret"},
95
93
  "scopes":[],
@@ -125,14 +123,17 @@ the bad request path; provider/runtime failures include `code`, `message`, and
125
123
  - **Auth flows**: call `/auth/start`, then `/auth/continue` with the same
126
124
  `flowId`; preserve any returned `contextPatch` in the next local request's
127
125
  `context` object.
128
- - **TLS-sensitive providers**: if Bun reports blocked lifecycle scripts after
129
- install, run `bun pm untrusted`; when it lists trusted SDK native dependencies
130
- such as `koffi`, run `bun pm trust koffi` (or `bun pm trust`) before debugging
131
- `ctx.tls` failures.
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.
132
133
  - **Browser providers**: for TypeScript Providers use `runtime: "browser"` plus
133
134
  `browser.engine: "playwright-stealth"`; `nodriver` is a Python-runtime path.
134
135
  Install local browser assets with `bunx playwright install chromium` when
135
- using the Playwright runtime, or set `CDP_POOL_URL`/`APIFUSE_CDP_POOL_URL`
136
+ using the Playwright runtime, or set `APIFUSE__CDP_POOL__URL`
136
137
  when debugging against a remote browser pool.
137
138
 
138
139
  ## Authoring ergonomics
@@ -148,6 +149,9 @@ const search = defineOperation({
148
149
  async handler(ctx, input) {
149
150
  return { count: input.q.length }
150
151
  },
152
+ healthCheckUnsupported: {
153
+ reason: "Example operation only; replace with a real upstream probe.",
154
+ },
151
155
  })
152
156
 
153
157
  export default defineProvider({
@@ -173,6 +177,24 @@ Every operation must declare exactly one of:
173
177
  The generated `ping` operation uses `healthCheckUnsupported` only because it is
174
178
  a local scaffold check, not a real upstream API probe.
175
179
 
180
+ `healthCheck.cases[].assertions` receives `{ data, status, durationMs, meta }`.
181
+ `data` is the operation output parsed by the declared output schema:
182
+
183
+ ```ts
184
+ healthCheck: {
185
+ interval: "5m",
186
+ cases: [{
187
+ name: "search responds",
188
+ input: { q: "weather" },
189
+ assertions: ({ data, status, durationMs }) => {
190
+ if (status !== 200 || data.count < 1 || durationMs > 3000) {
191
+ return { status: "degraded", label: "unexpected search baseline" }
192
+ }
193
+ },
194
+ }],
195
+ }
196
+ ```
197
+
176
198
  ### Operation annotations
177
199
 
178
200
  Operations declare non-functional metadata via `annotations`:
@@ -194,15 +216,15 @@ Operations declare non-functional metadata via `annotations`:
194
216
  apifuse create <name>
195
217
  apifuse dev [path]
196
218
  apifuse check [path]
197
- apifuse record [path] --operation <operation> --params '{"value":"hello"}'
219
+ apifuse record providers/airkorea --operation realtime --params '{"stationName":"종로구"}'
198
220
  apifuse test [path]
199
221
  apifuse submit-check [path] --tier bronze --markdown submission-report.md
200
222
  apifuse bounty-check [path]
201
- apifuse perf <path> --operation <operation>
223
+ apifuse perf providers/airkorea --operation realtime --params '{"stationName":"종로구"}'
202
224
  ```
203
225
 
204
226
  `apifuse record` is for real upstream-backed operations that declare
205
- `upstream.baseUrl` and call the upstream through `ctx.http` or `ctx.tls`. The
227
+ `upstream.baseUrl` and call the upstream through `ctx.http` or `ctx.stealth`. The
206
228
  generated local-only `ping` operation intentionally has no upstream and should
207
229
  be replaced before recording fixtures.
208
230
 
@@ -214,7 +236,7 @@ Standalone providers include a pre-submission script:
214
236
  bun run submit-check
215
237
  ```
216
238
 
217
- 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 bounty issue 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.
239
+ 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.
218
240
 
219
241
  ## Scope boundary
220
242
 
@@ -226,6 +248,6 @@ Generator v1 scaffolds **TypeScript providers only** for this redesign. Python g
226
248
  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.
227
249
 
228
250
  External bounty contributors should submit standalone Provider source plus
229
- `bun run check` / `bun run test` evidence. ApiFuse maintainers own monorepo
251
+ `bun run check` / `bun run test` evidence. APIFuse maintainers own monorepo
230
252
  import, registry generation, deployment projection checks, and release
231
253
  publishing.
package/SUBMISSION.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Provider bounty submission guide
2
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.
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
4
 
5
- ## Public-only workflow
5
+ ## SDK-only workspace workflow
6
6
 
7
7
  ```bash
8
8
  bunx @apifuse/provider-sdk@beta create my-provider --yes
@@ -65,7 +65,7 @@ curl -s -X POST http://localhost:3900/v1/<operation> \
65
65
  bun run submit-check -- --smoke-note "GET /health and POST /v1/<operation> passed locally with redacted input."
66
66
  ```
67
67
 
68
- Never paste real credentials, personal data, account numbers, access tokens, cookies, or unredacted upstream responses into issue comments or reports.
68
+ Never paste real credentials, personal data, account numbers, access tokens, cookies, or unredacted upstream responses into workspace PR comments, chat, or reports.
69
69
 
70
70
  ## Submission evidence checklist
71
71
 
@@ -83,4 +83,4 @@ Include the following when you submit a Provider for review:
83
83
 
84
84
  ## Maintainer-owned follow-up
85
85
 
86
- After public 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. Public contributors are not expected to run those private checks.
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.
@@ -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
- createTlsClient,
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.PORT) || 3900;
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
- tls: createTlsClient("http://localhost"),
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.PORT ? `PORT=${port} ` : "";
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)";
@@ -38,6 +38,13 @@ const requiredPaths = [
38
38
  "src/cli/create.ts",
39
39
  "src/cli/templates/provider/index.ts.tpl",
40
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",
41
48
  ];
42
49
  const forbiddenMatches = filePaths.filter(
43
50
  (path) =>
@@ -113,9 +120,9 @@ function assertPublicSmokeDocs(label: string, content: string): void {
113
120
  );
114
121
  }
115
122
 
116
- if (!content.includes("bun pm untrusted")) {
123
+ if (!content.includes("impit")) {
117
124
  throw new Error(
118
- `${label} must include Bun trusted-dependency troubleshooting for TLS/browser bounties.`,
125
+ `${label} must include impit stealth runtime guidance for TLS/browser bounties.`,
119
126
  );
120
127
  }
121
128