import type { Static, TSchema } from "typebox"; import type { AdapterImplementation, AuthorizedManifestTool, LegacyManifestTool, PackageManifest } from "./types"; type ExcessKeys = Exclude, keyof TConfig>; /** Every property optional, recursively; functions and arrays pass through. * Settings are checked against DeepPartial rather than * Partial because config subtrees often mix serializable knobs * with wiring-time material (an OAuth provider entry requires * `credentials`, but credentials come from env at wiring time and must * never appear in a settings schema). Key-name and value-type drift is * still caught; only nested requiredness is relaxed — the conformance * suite's runtime deep-key check covers that. */ type DeepPartial = T extends (...args: never[]) => unknown ? T : T extends ReadonlyArray ? ReadonlyArray> : T extends object ? { [K in keyof T]?: DeepPartial; } : T; /** Resolves to `unknown` (intersection no-op) when the schema is a valid * serializable deep-subset of TConfig; otherwise resolves to a descriptive * error object that the schema literal cannot satisfy, so the package's own * typecheck fails at its manifest module. This is the drift-breaker: rename * or retype a config key without updating the manifest and `tsc` stops the * package's build. Nested excess keys are the one soft spot (structural * assignability permits them); the conformance suite's runtime deep-key * check covers those. */ type ValidSettings = Static extends DeepPartial ? ExcessKeys extends never ? unknown : { "settings schema declares keys that do not exist on the config type": ExcessKeys; } : { "settings schema values are not assignable to the config type — check nested shapes": true; }; /** Curried so TConfig/TRuntime are explicit while the settings schema is * inferred — TypeScript has no partial inference in a single call. * * ```ts * export const manifest = defineManifest()({ * contract: 2, * identity: { ... }, * settings: Type.Object({ ... }), // checked against DispatcherOptions * wiring: [ ... ] * }); * ``` */ export declare const defineImplementation: () => (implementation: Omit & { settings?: S & ValidSettings; }) => AdapterImplementation; export declare const defineManifest: () => (manifest: Omit, "contract" | "settings" | "tools"> & ({ contract: 1; tools?: Record>; } | { contract: 2; tools?: Record>; }) & { settings: S & ValidSettings; }) => Omit, "contract" | "settings" | "tools"> & (({ contract: 1; tools?: Record>; } | { contract: 2; tools?: Record>; }) & { settings: S & ValidSettings; }); export {};