diff --git a/plugin-kit/package.json b/plugin-kit/package.json index 06367b4b..4dd039f0 100644 --- a/plugin-kit/package.json +++ b/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@punktfunk/plugin-kit", - "version": "0.1.0", + "version": "0.1.1", "description": "Effect-based framework for punktfunk plugins: lifecycle runtime, config/state, sync engine, UI serving, CLI scaffold, and browser helpers.", "type": "module", "license": "MIT OR Apache-2.0", @@ -25,6 +25,10 @@ "types": "./dist/react/index.d.ts", "default": "./dist/react/index.js" }, + "./wire": { + "types": "./dist/wire.d.ts", + "default": "./dist/wire.js" + }, "./theme.css": "./dist/theme.css" }, "files": ["dist", "README.md"], diff --git a/plugin-kit/src/reconcile.ts b/plugin-kit/src/reconcile.ts index 22bc8ebd..4679f4e3 100644 --- a/plugin-kit/src/reconcile.ts +++ b/plugin-kit/src/reconcile.ts @@ -1,40 +1,13 @@ -// The library-provider wire, owned by the kit so plugins stop hand-copying `wire.ts`. -// Schemas mirror the host's `ProviderEntryInput` (crates/punktfunk-host mgmt/library.rs); -// the transport stays the SDK's untyped `pf.request` seam (version-skew-safe under the -// runner-bundled SDK — design D7). These schemas are identity codecs (plain JSON shapes), -// so entries pass through unencoded; the value is the shared type + authoring validation. -import { Context, Effect, Layer, Schema } from "effect"; +// The library-provider client, owned by the kit so plugins stop hand-copying host calls. +// The wire SCHEMAS live in ./wire.ts (browser-safe — plugin contracts re-use them); the +// transport here stays the SDK's untyped `pf.request` seam (version-skew-safe under the +// runner-bundled SDK — design D7). +import { Context, Effect, Layer } from "effect"; import type { HostRequestError } from "./errors.js"; import { HostClient } from "./host-client.js"; +import type { ProviderEntry } from "./wire.js"; -export const Artwork = Schema.Struct({ - portrait: Schema.optionalKey(Schema.NullOr(Schema.String)), - hero: Schema.optionalKey(Schema.NullOr(Schema.String)), - logo: Schema.optionalKey(Schema.NullOr(Schema.String)), - header: Schema.optionalKey(Schema.NullOr(Schema.String)), -}); -export type Artwork = typeof Artwork.Type; - -export const LaunchSpec = Schema.Struct({ - kind: Schema.Literal("command"), - value: Schema.String, -}); -export type LaunchSpec = typeof LaunchSpec.Type; - -export const PrepStep = Schema.Struct({ - do: Schema.String, - undo: Schema.optionalKey(Schema.NullOr(Schema.String)), -}); -export type PrepStep = typeof PrepStep.Type; - -export const ProviderEntry = Schema.Struct({ - external_id: Schema.String, - title: Schema.String, - art: Schema.optionalKey(Artwork), - launch: Schema.optionalKey(Schema.NullOr(LaunchSpec)), - prep: Schema.optionalKey(Schema.Array(PrepStep)), -}); -export type ProviderEntry = typeof ProviderEntry.Type; +export * from "./wire.js"; export interface ProviderClientService { /** Full-replace reconcile: PUT the desired set; the host diffs by `external_id`. */ diff --git a/plugin-kit/src/wire.ts b/plugin-kit/src/wire.ts new file mode 100644 index 00000000..6724aed7 --- /dev/null +++ b/plugin-kit/src/wire.ts @@ -0,0 +1,34 @@ +// The library-provider wire schemas — a browser-safe module (no node imports) so plugin +// CONTRACTS can share these types with their UIs. Mirrors the host's `ProviderEntryInput` +// (crates/punktfunk-host mgmt/library.rs). Identity codecs: plain JSON shapes, so values +// pass through unencoded; the value is the shared type + authoring validation. +import { Schema } from "effect"; + +export const Artwork = Schema.Struct({ + portrait: Schema.optionalKey(Schema.NullOr(Schema.String)), + hero: Schema.optionalKey(Schema.NullOr(Schema.String)), + logo: Schema.optionalKey(Schema.NullOr(Schema.String)), + header: Schema.optionalKey(Schema.NullOr(Schema.String)), +}); +export type Artwork = typeof Artwork.Type; + +export const LaunchSpec = Schema.Struct({ + kind: Schema.Literal("command"), + value: Schema.String, +}); +export type LaunchSpec = typeof LaunchSpec.Type; + +export const PrepStep = Schema.Struct({ + do: Schema.String, + undo: Schema.optionalKey(Schema.NullOr(Schema.String)), +}); +export type PrepStep = typeof PrepStep.Type; + +export const ProviderEntry = Schema.Struct({ + external_id: Schema.String, + title: Schema.String, + art: Schema.optionalKey(Artwork), + launch: Schema.optionalKey(Schema.NullOr(LaunchSpec)), + prep: Schema.optionalKey(Schema.Array(PrepStep)), +}); +export type ProviderEntry = typeof ProviderEntry.Type;