@apifuse/provider-sdk 2.2.0-beta.4 → 2.2.0-beta.41
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 +501 -13
- package/CHANGELOG.md +169 -1
- package/README.md +72 -14
- package/SUBMISSION.md +1 -1
- package/bin/apifuse-check.ts +150 -5
- package/bin/apifuse-dev.ts +38 -5
- package/bin/apifuse-migrate-shape.ts +84 -0
- package/bin/apifuse-pack-check.ts +22 -2
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +356 -38
- package/bin/apifuse-perf.ts +14 -13
- package/bin/apifuse-record.ts +691 -68
- package/bin/apifuse-submit-check.ts +2301 -282
- 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 +16 -0
- package/dist/cli/create.d.ts +3 -0
- package/dist/cli/create.js +40 -35
- package/dist/cli/migrate-provider-shape.d.ts +52 -0
- package/dist/cli/migrate-provider-shape.js +515 -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 +4 -4
- package/dist/cli/templates/provider/index.ts.tpl +6 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +2 -1
- package/dist/cli/templates/provider/provider.json.tpl +6 -0
- package/dist/config/loader.d.ts +177 -16
- package/dist/config/loader.js +424 -127
- package/dist/contract-serialization.js +4 -8
- package/dist/contract-types.d.ts +1 -0
- package/dist/contract.js +3 -0
- package/dist/declaration-validation.d.ts +32 -0
- package/dist/declaration-validation.js +207 -0
- package/dist/define.d.ts +51 -25
- package/dist/define.js +774 -39
- 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 +19 -9
- package/dist/index.js +10 -6
- package/dist/lint.d.ts +6 -1
- package/dist/lint.js +362 -3
- 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 +8 -2
- package/dist/provider.js +3 -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/executor.d.ts +2 -2
- package/dist/runtime/executor.js +37 -3
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +515 -53
- 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/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 +3 -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 +526 -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 +407 -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 +60 -0
- package/dist/runtime/resolver.js +737 -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 +28 -3
- package/dist/runtime/stealth.js +519 -255
- 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 +61 -0
- 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 +6 -3
- package/dist/server/index.js +3 -3
- 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 +114 -0
- package/dist/server/self-test.js +787 -148
- package/dist/server/serve-implementation.d.ts +225 -0
- package/dist/server/serve-implementation.js +2242 -0
- package/dist/server/serve.d.ts +1 -70
- package/dist/server/serve.js +1 -1130
- package/dist/server/trace-output.d.ts +4 -0
- package/dist/server/trace-output.js +20 -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.js +16 -7
- 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 +563 -33
- package/dist/types.js +1 -0
- package/package.json +44 -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/commands.ts +20 -0
- package/src/cli/create.ts +48 -35
- package/src/cli/migrate-provider-shape.ts +701 -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 +4 -4
- package/src/cli/templates/provider/index.ts.tpl +6 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +2 -1
- package/src/cli/templates/provider/provider.json.tpl +6 -0
- package/src/config/loader.ts +665 -163
- package/src/contract-serialization.ts +5 -7
- package/src/contract-types.ts +1 -0
- package/src/contract.ts +3 -0
- package/src/declaration-validation.ts +266 -0
- package/src/define.ts +1003 -88
- 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 +205 -8
- package/src/lint.ts +408 -4
- 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 +134 -0
- 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/executor.ts +53 -8
- package/src/runtime/http.ts +641 -61
- 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/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 +20 -0
- package/src/runtime/resolver-shared.ts +17 -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 +700 -0
- package/src/runtime/resolver-vendors/hosts.ts +38 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +539 -0
- package/src/runtime/resolver-vendors/types.ts +212 -0
- package/src/runtime/resolver.ts +1103 -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 +675 -289
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +77 -0
- package/src/serve.ts +6 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/index.ts +39 -2
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test.ts +1030 -175
- package/src/server/serve-implementation.ts +3338 -0
- package/src/server/serve.ts +1 -1626
- package/src/server/trace-output.ts +32 -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 +17 -7
- 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 +698 -65
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/dist/cli/create.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
|
import { cancel, intro, isCancel, note, outro, select, text } from "@clack/prompts";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import packageJson from "../../package.json";
|
|
9
|
+
import { buildPromptAssetManifest, buildPromptAssetPlanEntries, PROMPT_ASSET_MANIFEST_PATH, } from "./prompt-assets.js";
|
|
9
10
|
export const PROVIDER_NAME_REGEX = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
10
11
|
export const CATEGORY_OPTIONS = [
|
|
11
12
|
"developer-tools",
|
|
@@ -283,10 +284,15 @@ export async function buildProviderCreatePlan(options, cwd) {
|
|
|
283
284
|
if (options.sdkSpecifier?.startsWith("workspace:") && !resolvedWorkspaceRoot) {
|
|
284
285
|
throw new Error("workspace:* is only valid inside the APIFuse monorepo because public Provider SDK scaffolds must install from npm or an explicit tarball/file specifier.");
|
|
285
286
|
}
|
|
287
|
+
// Exact pin, not a caret range: the prompt-asset freshness gate requires
|
|
288
|
+
// manifest.sdkVersion === installed SDK version, and the manifest records
|
|
289
|
+
// this CLI's own version. A caret range would let `bun install` resolve a
|
|
290
|
+
// newer SDK than the create binary, making a fresh scaffold fail its own
|
|
291
|
+
// gate. `sync-assets` after an explicit SDK upgrade re-records the version.
|
|
286
292
|
const sdkSpecifier = options.sdkSpecifier ??
|
|
287
293
|
(options.preset === "monorepo" && resolvedWorkspaceRoot
|
|
288
294
|
? "workspace:*"
|
|
289
|
-
:
|
|
295
|
+
: packageJson.version);
|
|
290
296
|
const relativeProviderRoot = relative(cwd, providerRoot) || options.name;
|
|
291
297
|
const nextDevCommand = `cd ${relativeProviderRoot} && bun run dev`;
|
|
292
298
|
const packageName = options.preset === "monorepo"
|
|
@@ -373,6 +379,12 @@ export async function buildProviderCreatePlan(options, cwd) {
|
|
|
373
379
|
sdkSpecifier,
|
|
374
380
|
}),
|
|
375
381
|
},
|
|
382
|
+
{
|
|
383
|
+
path: resolve(providerRoot, "provider.json"),
|
|
384
|
+
content: await renderTemplate("provider.json.tpl", {
|
|
385
|
+
PROVIDER_ID: options.name,
|
|
386
|
+
}),
|
|
387
|
+
},
|
|
376
388
|
{
|
|
377
389
|
path: resolve(providerRoot, "Dockerfile"),
|
|
378
390
|
content: await renderTemplate("Dockerfile.tpl", {}),
|
|
@@ -405,39 +417,21 @@ export async function buildProviderCreatePlan(options, cwd) {
|
|
|
405
417
|
PROVIDER_ID: options.name,
|
|
406
418
|
}),
|
|
407
419
|
},
|
|
408
|
-
{
|
|
409
|
-
path: resolve(providerRoot, "AGENTS.md"),
|
|
410
|
-
content: await renderTemplate("AGENTS.md.tpl", {}),
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
path: resolve(providerRoot, "CLAUDE.md"),
|
|
414
|
-
content: await renderTemplate("CLAUDE.md.tpl", {}),
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
path: resolve(providerRoot, "skills", "normalization-standards", "SKILL.md"),
|
|
418
|
-
content: await renderTemplate("skills/normalization-standards/SKILL.md.tpl", {}),
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
path: resolve(providerRoot, "skills", "upstream-contract-verification", "SKILL.md"),
|
|
422
|
-
content: await renderTemplate("skills/upstream-contract-verification/SKILL.md.tpl", {}),
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
path: resolve(providerRoot, "skills", "fixtures-and-recording", "SKILL.md"),
|
|
426
|
-
content: await renderTemplate("skills/fixtures-and-recording/SKILL.md.tpl", {}),
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
path: resolve(providerRoot, "skills", "pagination-and-counts", "SKILL.md"),
|
|
430
|
-
content: await renderTemplate("skills/pagination-and-counts/SKILL.md.tpl", {}),
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
path: resolve(providerRoot, "skills", "health-checks-and-fail-closed", "SKILL.md"),
|
|
434
|
-
content: await renderTemplate("skills/health-checks-and-fail-closed/SKILL.md.tpl", {}),
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
path: resolve(providerRoot, "skills", "upstream-notes", "README.md"),
|
|
438
|
-
content: await renderTemplate("skills/upstream-notes/README.md.tpl", {}),
|
|
439
|
-
},
|
|
440
420
|
];
|
|
421
|
+
const promptAssetEntries = await buildPromptAssetPlanEntries(renderTemplate);
|
|
422
|
+
for (const entry of promptAssetEntries) {
|
|
423
|
+
files.push({
|
|
424
|
+
path: resolve(providerRoot, entry.path),
|
|
425
|
+
content: entry.content,
|
|
426
|
+
...(entry.kind === "symlink" ? { kind: "symlink" } : {}),
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
// Manifest last: writePlan writes in order, so a crash mid-scaffold never
|
|
430
|
+
// leaves a manifest that claims assets which were not written.
|
|
431
|
+
files.push({
|
|
432
|
+
path: resolve(providerRoot, PROMPT_ASSET_MANIFEST_PATH),
|
|
433
|
+
content: buildPromptAssetManifest(promptAssetEntries, packageJson.version),
|
|
434
|
+
});
|
|
441
435
|
return {
|
|
442
436
|
displayName: options.displayName,
|
|
443
437
|
files,
|
|
@@ -477,6 +471,7 @@ function renderPackageJson(input) {
|
|
|
477
471
|
check: "apifuse check . && bun run type-check",
|
|
478
472
|
"type-check": "tsc --noEmit",
|
|
479
473
|
"submit-check": "apifuse submit-check . --markdown submission-report.md",
|
|
474
|
+
"sync-assets": "apifuse sync-assets .",
|
|
480
475
|
test: "apifuse test .",
|
|
481
476
|
record: "apifuse record .",
|
|
482
477
|
start: "bun start.ts",
|
|
@@ -696,6 +691,13 @@ function isApifuseInternalWorkspaceRoot(workspaceRoot) {
|
|
|
696
691
|
async function writePlan(plan) {
|
|
697
692
|
for (const file of plan.files) {
|
|
698
693
|
await mkdir(dirname(file.path), { recursive: true });
|
|
694
|
+
if (file.kind === "symlink") {
|
|
695
|
+
// rm operates on the link itself (lstat semantics) and tolerates
|
|
696
|
+
// directories, so whatever occupies the path is replaced by the link.
|
|
697
|
+
await rm(file.path, { recursive: true, force: true });
|
|
698
|
+
await symlink(file.content, file.path);
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
699
701
|
await writeFile(file.path, file.content);
|
|
700
702
|
}
|
|
701
703
|
}
|
|
@@ -754,7 +756,10 @@ function printResult(plan, jsonMode, dryRun) {
|
|
|
754
756
|
},
|
|
755
757
|
validationCommands: plan.validationCommands,
|
|
756
758
|
nextDevCommand: plan.nextDevCommand,
|
|
757
|
-
files: plan.files.map((file) =>
|
|
759
|
+
files: plan.files.map((file) => {
|
|
760
|
+
const relativePath = relative(plan.providerRoot, file.path) || file.path;
|
|
761
|
+
return file.kind === "symlink" ? `${relativePath} -> ${file.content} (symlink)` : relativePath;
|
|
762
|
+
}),
|
|
758
763
|
};
|
|
759
764
|
if (jsonMode) {
|
|
760
765
|
console.log(JSON.stringify(payload, null, 2));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider authoring shape migration.
|
|
3
|
+
*
|
|
4
|
+
* `defineProvider` changed in 2.2.0-beta.37 from returning a finished provider
|
|
5
|
+
* to returning a builder, splitting authoring into two phases:
|
|
6
|
+
*
|
|
7
|
+
* const buildProvider = defineProvider(<declaration>);
|
|
8
|
+
* export type ProviderContext = ProviderContextOf<typeof buildProvider>;
|
|
9
|
+
* export default buildProvider({ operations });
|
|
10
|
+
*
|
|
11
|
+
* Source written against the single-phase shape still type-checks against an
|
|
12
|
+
* older pin but default-exports a builder function once the pin moves, so
|
|
13
|
+
* `loadProviderDefinition` rejects it. Bumping the pin without migrating the
|
|
14
|
+
* source therefore breaks the module. This transform performs the source half
|
|
15
|
+
* so the SDK bump fan-out can ship both in one commit.
|
|
16
|
+
*
|
|
17
|
+
* The transform is deliberately conservative: it rewrites only the shapes it
|
|
18
|
+
* can fully account for and reports `skipped` with a reason for anything else,
|
|
19
|
+
* rather than emitting a partial migration a reviewer would have to audit.
|
|
20
|
+
*/
|
|
21
|
+
/** Every source shape this transform recognizes. */
|
|
22
|
+
export type ProviderShapeKind =
|
|
23
|
+
/** `export default defineProvider({ ..., operations })` */
|
|
24
|
+
"single-phase-default-export"
|
|
25
|
+
/** `const p = defineProvider({ ..., operations }); export default p;` */
|
|
26
|
+
| "single-phase-variable-export"
|
|
27
|
+
/** `const p = defineProvider({ ..., operations }); export default { ...p, deployment };` */
|
|
28
|
+
| "single-phase-variable-spread-export"
|
|
29
|
+
/** Already `const b = defineProvider(...); export default b({ operations })` */
|
|
30
|
+
| "two-phase";
|
|
31
|
+
export type ProviderShapeMigration = {
|
|
32
|
+
readonly status: "migrated";
|
|
33
|
+
readonly kind: ProviderShapeKind;
|
|
34
|
+
readonly code: string;
|
|
35
|
+
/** Source text the operations map was supplied as, for reporting. */
|
|
36
|
+
readonly operationsExpression: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly status: "unchanged";
|
|
39
|
+
readonly kind: "two-phase";
|
|
40
|
+
readonly code: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly status: "skipped";
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Migrate one provider `index.ts` to the two-phase authoring shape.
|
|
47
|
+
*
|
|
48
|
+
* Returns the rewritten source on success. Callers MUST treat `skipped` as a
|
|
49
|
+
* hard stop for that provider — a skipped provider needs a human, and pairing
|
|
50
|
+
* a pin bump with a skipped migration produces an unloadable module.
|
|
51
|
+
*/
|
|
52
|
+
export declare function migrateProviderShape(sourceText: string, fileName?: string): ProviderShapeMigration;
|