@kohaku-ui/renderer-wc 0.3.0 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,123 @@
1
1
  # @kohaku-ui/renderer-wc
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#60](https://github.com/yosuque/kohaku/pull/60) [`5f1bbbd`](https://github.com/yosuque/kohaku/commit/5f1bbbd09fe1edb984a7b0f5a0c5212c3da628ea) Thanks [@yosuque](https://github.com/yosuque)! - Adds a Compliance Evidence Pack export (`@kohaku-ui/lineage`'s new `evidence` module; `kohaku evidence
8
+ keygen`/`export`/`verify`) and opt-in AI-generation disclosure for both renderers (design.md [#66](https://github.com/yosuque/kohaku/issues/66)/[#67](https://github.com/yosuque/kohaku/issues/67)).
9
+
10
+ **Evidence Pack** (`@kohaku-ui/lineage`): `buildEvidencePack` assembles a normalized, Ed25519-signed
11
+ export of the lineage log (`events.jsonl`), a governance-decision index (`approvals.jsonl`:
12
+ `component.reviewed`/`published`/`withdrawn`, `intent.fixated`/`unfixated`), promotion/fixation
13
+ snapshots, and the referenced component HTML artifacts, plus `manifest.json` and a detached signature
14
+ (`manifest.sig`). `EvidenceManifestSchema` is new but deliberately not part of `spec/schemas` — it
15
+ describes an export format for auditors, not a wire type. Ed25519 signing uses `globalThis.crypto.subtle`
16
+ (no new runtime dependency for TS); an artifact whose recorded hash does not match its own content is
17
+ still exported, recorded as a non-fatal warning rather than aborting the export.
18
+
19
+ **CLI** (`@kohaku-ui/cli`): `kohaku evidence keygen --out-dir <dir>` generates an Ed25519 keypair (private
20
+ key file mode 0600). `kohaku evidence export (--data-dir <dir> | --rest <baseUrl> [--header k:v])
21
+ [--tenant <id>] --since --until --private-key <pem> --out <dir> [--allow-incomplete]` builds and signs a
22
+ pack from a local `StoragePort` data directory or, over REST, from the existing `KohakuClient` surface
23
+ (`lineagePages`/`promotions.list`/`fixations.list`) — the REST source leaves `fixations.jsonl` empty with
24
+ a recorded warning, since `GET /fixations` does not expose enough fields to reconstruct a full
25
+ `FixationRecord`. `kohaku evidence verify <dir> --public-key <pem>` checks the manifest schema, the
26
+ signature, and every file's hash/size, and reports an independent artifact-hash cross-check as non-fatal
27
+ `mismatches`; exit code 0 valid / 1 invalid / 2 usage error. `@kohaku-ui/lineage` and
28
+ `@kohaku-ui/storage-memory` move from `cli`'s devDependencies to dependencies.
29
+
30
+ **AI-generation disclosure** (`@kohaku-ui/renderer-core`, `@kohaku-ui/renderer-react`,
31
+ `@kohaku-ui/renderer-wc`): `deriveDisclosure(provenance)` (renderer-core) derives a disclosure level
32
+ (`"ai-generated"` for tier L1/L2, `"ai-assisted-reviewed"` for a fixated tier-L0 Spec, `"none"` otherwise
33
+ — never encoded on the wire) and the corresponding `data-kohaku-disclosure`/`data-kohaku-tier`/
34
+ `data-digital-source-type` (IPTC Digital Source Type) attributes. `SpecView` gains a `disclosure?: "off" |
35
+ "attributes" | "label"` prop (renderer-react; also exports `useDisclosure`/`KohakuDisclosureLabel`), and
36
+ `<kohaku-surface>` gains a matching `disclosure` attribute (renderer-wc, applied to the host element,
37
+ with the visible label — `"label"` mode only — inside the shadow root). Both default to `"off"`: existing
38
+ DOM output is unchanged unless a host opts in.
39
+
40
+ See [docs/user-guide.md](../docs/user-guide.md)'s "Compliance Evidence Pack and AI-generation disclosure"
41
+ section for usage, EU AI Act Article 50 context (not legal advice), and a PII caution for exported Intent
42
+ `params`/request text.
43
+
44
+ - [#62](https://github.com/yosuque/kohaku/pull/62) [`cc17b7b`](https://github.com/yosuque/kohaku/commit/cc17b7bc3c96e49b1b74197ac20cd7a3d8ee0b47) Thanks [@yosuque](https://github.com/yosuque)! - Add Governed Actions: Human-In-The-Loop tiers for `DomainPort` write operations (design.md [#62](https://github.com/yosuque/kohaku/issues/62)/[#63](https://github.com/yosuque/kohaku/issues/63)/[#64](https://github.com/yosuque/kohaku/issues/64);
45
+ SPEC §5's ACT-PRM-001/ACT-APR-001/ACT-CNF-001, LIN-ACT-001, §6.2's MCPAPP-ACT-001).
46
+
47
+ An operation may declare `tier` (`"auto"` (default) / `"confirm"` / `"approve"`) and `paramsSchema`
48
+ (kohaku's own closed JSON Schema subset — `type`, `properties`, `required`,
49
+ `additionalProperties: false`, `enum`, `minimum`/`maximum`, `minLength`/`maxLength`, `items`, `maxItems`,
50
+ `x-message`; deliberately no `pattern`, to avoid both ReDoS and a JS/Python regex-dialect mismatch).
51
+ `spec-core`'s `validateActionParams`/`assertValidActionParamsSchema` (env-neutral, dependency-free, pinned
52
+ byte-for-byte against the Python port via the cross-language golden) enforces the schema before
53
+ `DomainPort.invoke` ever runs, on every write surface alike: REST's `POST /binding/action`, MCP's
54
+ `${prefix}_action`, and the client-side `preflightAction` check `renderer-core` runs before either.
55
+
56
+ `"approve"`-tier actions are gated by a new stateless, short-lived HMAC-signed `ApprovalPort`
57
+ (`@kohaku-ui/authz-hmac`'s `createHmacApprovalPort`, `"kohaku-approval.v1."`-prefixed tokens, 300s default
58
+ TTL) bound to `(action, payloadHash, requesterId, tenant)`; self-approval is refused at issuance, and a
59
+ verification failure the host cannot classify is treated as a denial (fail-closed). An optional
60
+ `ApprovalStore` adds single-use enforcement. REST gains `POST /approvals` (mints a token as an authorized
61
+ approver, governance kind `action.approve`) and both the REST body and the MCP action tool's input gain
62
+ optional `confirmed`/`approval` fields; a gate failure is `422 ACTION_PARAMS_INVALID` / `403
63
+ APPROVAL_REQUIRED` on REST (with `error.issues`/`error.approval`) and the MCP structured-tool-error
64
+ equivalent.
65
+
66
+ A compose response optionally carries an **Action manifest** (REST's `actions?` on
67
+ `/compose`/`/events`/`event: spec`; MCP's `_meta["kohaku/actions"]`) mapping each governed action name to
68
+ `{tier, paramsSchema?, confirmMessage?}` — placed outside the `UISpec` itself, next to the capability, so
69
+ it never affects `specHash` or the cache key. `renderer-core`'s `preflightAction` consults it client-side
70
+ before a write round-trip; `renderer-react`/`renderer-wc`/`mcp-renderer` thread `confirm`/`requestApproval`
71
+ hooks through (`renderer-react` ships a `globalThis.confirm`-backed default for the `"confirm"` tier; there
72
+ is no framework-neutral default for `"approve"`, so that tier stays gated until a product wires its own
73
+ hook). `@kohaku-ui/client`/`@kohaku-ui/data-binding` gain typed `ACTION_PARAMS_INVALID`/`APPROVAL_REQUIRED`
74
+ error codes and `confirmed`/`approval` request options. A host that records action outcomes to lineage does
75
+ so under a distinct `action.*` event family (`action.invoked`/`action.denied`/`action.approvalRequested`/
76
+ `action.approved`), carrying `payloadHash` but never the payload's own field values.
77
+
78
+ The Python port (`python/kohaku`) mirrors the full surface (`kohaku.spec.action_params`,
79
+ `kohaku.host_core.action_gate`/`action_audit`, `POST /approvals`, the MCP action-tool gate), and
80
+ `apps/sample-api` / `python/examples/sales-api` demonstrate both tiers end to end (`annotate`: confirm,
81
+ `publish`: approve) — see the [user guide](../docs/user-guide.md)'s "Governed actions: tiers" section.
82
+
83
+ **Behavior changes to check when upgrading.** (1) `POST /binding/action` and the MCP action tool now
84
+ reject, before `DomainPort.invoke` runs, any action that is not in the DomainPort's own
85
+ `listOperations()` — previously such an action was invoked ungated. It is rejected with the same response
86
+ as a missing write scope and recorded as `action.denied`. A product whose `listOperations()` omits an
87
+ operation it still expects to be invoked must declare it. (2) `validateActionParams` rejects a payload
88
+ property named `__proto__`, `constructor` or `prototype` at any depth (issue code `unsafeKey`), whatever
89
+ the schema's `additionalProperties` says.
90
+
91
+ - [#54](https://github.com/yosuque/kohaku/pull/54) [`bd2d484`](https://github.com/yosuque/kohaku/commit/bd2d484826bec86c78dcb720502740494a672ea8) Thanks [@yosuque](https://github.com/yosuque)! - Adds a typed way to register a product-specific part, so its `{type, version, propsSchema}` can live in one
92
+ `ComponentDefinition` instead of being re-typed as string literals at the registration call site (design.md
93
+ [#68](https://github.com/yosuque/kohaku/issues/68)).
94
+
95
+ `@kohaku-ui/renderer-react`: `implement(def, Component)` wraps a component whose props are inferred from
96
+ `def.propsSchema` (`z.infer`) — no `node.props["x"] as T` cast needed — and returns an entry consumed by the
97
+ new `ImplRegistry.use(entry)`. The existing `register(type, version, component)` / `ImplProps` keep working
98
+ unchanged for parts that have no static `ComponentDefinition` (e.g. a promoted part's per-artifact schema).
99
+
100
+ `@kohaku-ui/renderer-wc`: `<kohaku-surface>` gains a public `registerPart(type, version, builder)` (it was
101
+ previously private with no way for a host to register anything beyond the core catalog), plus `getPartVersion`
102
+ for introspection, and `implementWc(def, builder)` is the typed counterpart of `implement` for a `PartBuilder`.
103
+
104
+ Both `implement` and `implementWc` parse a node's props against the schema **unconditionally, in every
105
+ environment** (`propsSchema.safeParse` is also what materializes a `.default()`-ed prop the Spec omits, not
106
+ just a validation nicety, so it never skips in production) — on success the component receives the parsed
107
+ value, on failure it receives the raw (unvalidated) props instead (fail-open: a malformed prop degrades the
108
+ part's own display rather than the whole surface). Only the diagnostic — a `console.warn` on a mismatch — is
109
+ gated by environment: by default it fires outside a `NODE_ENV=production` build; pass `{ validate }` to force
110
+ the warning on or off regardless of environment.
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [[`fcd4eb7`](https://github.com/yosuque/kohaku/commit/fcd4eb7c8c6608030d4f9045648a305fa2e5992f), [`5f1bbbd`](https://github.com/yosuque/kohaku/commit/5f1bbbd09fe1edb984a7b0f5a0c5212c3da628ea), [`cc17b7b`](https://github.com/yosuque/kohaku/commit/cc17b7bc3c96e49b1b74197ac20cd7a3d8ee0b47), [`730e625`](https://github.com/yosuque/kohaku/commit/730e62584b249056078792f6f646019cb225b049), [`730e625`](https://github.com/yosuque/kohaku/commit/730e62584b249056078792f6f646019cb225b049), [`730e625`](https://github.com/yosuque/kohaku/commit/730e62584b249056078792f6f646019cb225b049), [`5d167cb`](https://github.com/yosuque/kohaku/commit/5d167cb386cc1f91102644f8a99bd5b5c2949ce0)]:
115
+ - @kohaku-ui/registry@0.4.0
116
+ - @kohaku-ui/renderer-core@0.4.0
117
+ - @kohaku-ui/spec-core@0.4.0
118
+ - @kohaku-ui/data-binding@0.4.0
119
+ - @kohaku-ui/sandbox@0.4.0
120
+
3
121
  ## 0.3.0
4
122
 
5
123
  ### Patch Changes
@@ -0,0 +1,37 @@
1
+ import type { ComponentDefinition } from "@kohaku-ui/registry";
2
+ import type { ComponentNode, JsonObject } from "@kohaku-ui/spec-core";
3
+ import type { z } from "zod";
4
+ import type { PartBuilder, RenderRuntime, Teardown } from "./types.js";
5
+ /**
6
+ * A part builder with typed props, taken from a `ComponentDefinition`'s `propsSchema` (design.md #68).
7
+ * Same shape as `PartBuilder`, with `props` added between `node` and `row`, so a product's builder never
8
+ * has to read `node.props["x"] as T` itself — the WC counterpart of renderer-react's typed `Component`.
9
+ */
10
+ export type TypedPartBuilder<P> = (rt: RenderRuntime, parent: ParentNode, node: ComponentNode, props: P, row: JsonObject | null) => Teardown;
11
+ /** Registration triple returned by `implementWc`, passed to `<kohaku-surface>.registerPart`. */
12
+ export interface PartEntry {
13
+ type: string;
14
+ version: string;
15
+ builder: PartBuilder;
16
+ }
17
+ /**
18
+ * Wraps a typed `TypedPartBuilder` into a plain `PartBuilder` bound to `def`'s own type and version — the
19
+ * WC counterpart of renderer-react's `implement` (design.md #68). Usage:
20
+ * ```ts
21
+ * const entry = implementWc(myPartDef, (rt, parent, node, props, row) => { ... });
22
+ * surface.registerPart(entry.type, entry.version, entry.builder);
23
+ * ```
24
+ *
25
+ * `def.propsSchema.safeParse` always runs, in every environment — not just outside a `NODE_ENV=production`
26
+ * build — because it is also what materializes a `.default()`-ed prop (or any other Zod transform) the Spec
27
+ * omits; skipping it in production would silently make `builder` see `undefined` for a prop its type says
28
+ * is always present. On success, `builder` receives `parsed.data`; on failure it receives the raw
29
+ * (unvalidated) `node.props` instead, matching the renderer's general fail-open policy. Only the
30
+ * **diagnostic** — a `console.warn` on a mismatch — is gated by environment: by default it fires outside a
31
+ * `NODE_ENV=production` build (see `isDevEnvironment`); pass `{ validate }` to force it on or off
32
+ * regardless of environment.
33
+ */
34
+ export declare function implementWc<P extends z.ZodObject>(def: ComponentDefinition<P>, builder: TypedPartBuilder<z.infer<P>>, options?: {
35
+ validate?: boolean;
36
+ }): PartEntry;
37
+ //# sourceMappingURL=implement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../src/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,CAAC,EACR,GAAG,EAAE,UAAU,GAAG,IAAI,KACnB,QAAQ,CAAC;AAEd,gGAAgG;AAChG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAC/C,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACrC,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/B,SAAS,CAkBX"}
@@ -0,0 +1,37 @@
1
+ import { isDevEnvironment } from "@kohaku-ui/renderer-core";
2
+ /**
3
+ * Wraps a typed `TypedPartBuilder` into a plain `PartBuilder` bound to `def`'s own type and version — the
4
+ * WC counterpart of renderer-react's `implement` (design.md #68). Usage:
5
+ * ```ts
6
+ * const entry = implementWc(myPartDef, (rt, parent, node, props, row) => { ... });
7
+ * surface.registerPart(entry.type, entry.version, entry.builder);
8
+ * ```
9
+ *
10
+ * `def.propsSchema.safeParse` always runs, in every environment — not just outside a `NODE_ENV=production`
11
+ * build — because it is also what materializes a `.default()`-ed prop (or any other Zod transform) the Spec
12
+ * omits; skipping it in production would silently make `builder` see `undefined` for a prop its type says
13
+ * is always present. On success, `builder` receives `parsed.data`; on failure it receives the raw
14
+ * (unvalidated) `node.props` instead, matching the renderer's general fail-open policy. Only the
15
+ * **diagnostic** — a `console.warn` on a mismatch — is gated by environment: by default it fires outside a
16
+ * `NODE_ENV=production` build (see `isDevEnvironment`); pass `{ validate }` to force it on or off
17
+ * regardless of environment.
18
+ */
19
+ export function implementWc(def, builder, options) {
20
+ const shouldWarn = options?.validate ?? isDevEnvironment();
21
+ const wrapped = (rt, parent, node, row) => {
22
+ const parsed = def.propsSchema.safeParse(node.props);
23
+ let props;
24
+ if (parsed.success) {
25
+ props = parsed.data;
26
+ }
27
+ else {
28
+ props = node.props;
29
+ if (shouldWarn) {
30
+ console.warn(`[kohaku] component "${def.type}" (node ${node.id}) received props that don't match its schema: ${parsed.error.message}`);
31
+ }
32
+ }
33
+ return builder(rt, parent, node, props, row);
34
+ };
35
+ return { type: def.type, version: def.version, builder: wrapped };
36
+ }
37
+ //# sourceMappingURL=implement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implement.js","sourceRoot":"","sources":["../src/implement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAyB5D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CACzB,GAA2B,EAC3B,OAAqC,EACrC,OAAgC;IAEhC,MAAM,UAAU,GAAG,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACrD,MAAM,MAAM,GAAG,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,KAAiB,CAAC;QACtB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,KAAK,GAAG,MAAM,CAAC,IAAkB,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,CAAC,KAAmB,CAAC;YACjC,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CACV,uBAAuB,GAAG,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,iDAAiD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CACzH,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACpE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { DEFAULT_MESSAGES, type RendererMessages } from "@kohaku-ui/renderer-core";
1
+ export { type ActionManifest, type ActionManifestEntry, DEFAULT_MESSAGES, type PreflightActionResult, preflightAction, type RendererMessages, summarizeActionForModel, } from "@kohaku-ui/renderer-core";
2
+ export { implementWc, type PartEntry, type TypedPartBuilder } from "./implement.js";
2
3
  export { defineKohakuSurface, KOHAKU_EVENT, KohakuSurface } from "./kohaku-surface.js";
3
4
  export { createCoreRenderRegistry } from "./registry.js";
4
5
  export type { ActionPhase, PartBuilder, RenderRuntime, SurfaceContext, SurfaceEvent, Teardown, } from "./types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,eAAe,EACf,KAAK,gBAAgB,EACrB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -2,7 +2,10 @@
2
2
  // A single <kohaku-surface> builds the entire UI Spec tree into one shadow root. The shared core is renderer-core.
3
3
  // Dependency direction: spec-core → {registry, data-binding} → renderer-core → renderer-wc (sandbox is imported directly).
4
4
  // UI message type and defaults (the single source of truth is renderer-core). Used to override context.messages.
5
- export { DEFAULT_MESSAGES } from "@kohaku-ui/renderer-core";
5
+ // Governed actions (design.md #62/#63/#64): re-exported from renderer-core (the framework-free source of
6
+ // truth) so a consumer does not need to reach into @kohaku-ui/renderer-core directly for these.
7
+ export { DEFAULT_MESSAGES, preflightAction, summarizeActionForModel, } from "@kohaku-ui/renderer-core";
8
+ export { implementWc } from "./implement.js";
6
9
  export { defineKohakuSurface, KOHAKU_EVENT, KohakuSurface } from "./kohaku-surface.js";
7
10
  export { createCoreRenderRegistry } from "./registry.js";
8
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,mHAAmH;AACnH,2HAA2H;AAE3H,iHAAiH;AACjH,OAAO,EAAE,gBAAgB,EAAyB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,mHAAmH;AACnH,2HAA2H;AAE3H,iHAAiH;AACjH,yGAAyG;AACzG,gGAAgG;AAChG,OAAO,EAGL,gBAAgB,EAEhB,eAAe,EAEf,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAyC,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { type RendererMessages } from "@kohaku-ui/renderer-core";
2
2
  import { type ThemeTokens, type UISpec } from "@kohaku-ui/spec-core";
3
- import type { SurfaceContext } from "./types.js";
3
+ import type { PartBuilder, SurfaceContext } from "./types.js";
4
4
  /** Name of the forward event dispatched by <kohaku-surface> (detail is a SurfaceEvent). */
5
5
  export declare const KOHAKU_EVENT = "kohaku-event";
6
+ /** `disclosure` attribute values (design.md #66); anything else (including absence) behaves as `"off"`. */
7
+ type DisclosureMode = "off" | "attributes" | "label";
6
8
  /**
7
9
  * The single host element <kohaku-surface> (Shadow DOM). It builds the entire UI Spec tree into one shadow root
8
10
  * (rather than a Custom Element per part type — a single-element surface). Spec / context are received as properties.
@@ -15,8 +17,13 @@ export declare const KOHAKU_EVENT = "kohaku-event";
15
17
  */
16
18
  export declare class KohakuSurface extends HTMLElement {
17
19
  #private;
20
+ static get observedAttributes(): string[];
18
21
  constructor();
19
22
  connectedCallback(): void;
23
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
24
+ /** `"off"` (default) | `"attributes"` | `"label"` (design.md #66). Reflects the `disclosure` attribute. */
25
+ get disclosure(): DisclosureMode;
26
+ set disclosure(v: DisclosureMode);
20
27
  disconnectedCallback(): void;
21
28
  /** UI Spec. Setting it triggers resetForIntent → rebuild the tree + reattach the controller. */
22
29
  get spec(): UISpec | null;
@@ -35,8 +42,38 @@ export declare class KohakuSurface extends HTMLElement {
35
42
  set onEvent(v: SurfaceContext["onEvent"]);
36
43
  set onNodeError(v: SurfaceContext["onNodeError"]);
37
44
  set onActionResult(v: SurfaceContext["onActionResult"]);
45
+ set actionManifest(v: SurfaceContext["actionManifest"]);
46
+ set confirm(v: SurfaceContext["confirm"]);
47
+ set requestApproval(v: SurfaceContext["requestApproval"]);
38
48
  set sandbox(v: SurfaceContext["sandbox"]);
49
+ /**
50
+ * Public registration API for product-specific parts (design.md #68). Previously `#registry` was private
51
+ * with no way for a host to add its own component types — a product could not register anything beyond
52
+ * the core catalog on the WC surface at all. Pair with `implementWc` for typed props:
53
+ * ```ts
54
+ * const entry = implementWc(myPartDef, builder);
55
+ * surface.registerPart(entry.type, entry.version, entry.builder);
56
+ * ```
57
+ * `version` is recorded for parity with renderer-react's `ImplRegistry.register`; unlike that registry,
58
+ * this surface does not (yet) feed a `SurfaceCapabilities` table into `@kohaku-ui/registry`'s
59
+ * `negotiate()` — no host wires WC capability negotiation today (AGENTS.md's renderer-wc section) — so
60
+ * `version` is not itself consulted by any negotiation path yet. Call before assigning `spec` when
61
+ * possible; if a Spec is already mounted, this rebuilds it so the newly registered part renders
62
+ * immediately instead of only taking effect on the next Spec swap.
63
+ *
64
+ * `#registry` starts seeded with the 16 core-catalog parts (`createCoreRenderRegistry`), so registering
65
+ * an already-taken `type` — most easily a core one, by typo or intentional override — silently replaces
66
+ * it. That is sometimes exactly what a product wants (replacing a core part with its own), but silent
67
+ * shadowing of a core part is also an easy way to lose one by accident, so replacing any existing entry
68
+ * warns via `console.warn` unless the caller opts in explicitly with `{ override: true }`.
69
+ */
70
+ registerPart(type: string, version: string, builder: PartBuilder, options?: {
71
+ override?: boolean;
72
+ }): void;
73
+ /** The version last passed to `registerPart` for `type`, if any (introspection only — see its doc comment). */
74
+ getPartVersion(type: string): string | undefined;
39
75
  }
40
76
  /** Registers <kohaku-surface> as a custom element (idempotent). */
41
77
  export declare function defineKohakuSurface(tagName?: string): void;
78
+ export {};
42
79
  //# sourceMappingURL=kohaku-surface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kohaku-surface.d.ts","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,gBAAgB,EAItB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAIxF,OAAO,KAAK,EAAe,cAAc,EAAY,MAAM,YAAY,CAAC;AAExE,2FAA2F;AAC3F,eAAO,MAAM,YAAY,iBAAiB,CAAC;AA0B3C;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAW5C,cAYC;IAED,iBAAiB,IAAI,IAAI,CAUxB;IAED,oBAAoB,IAAI,IAAI,CAG3B;IAUD,gGAAgG;IAChG,IAAI,IAAI,IAAI,MAAM,GAAG,IAAI,CAExB;IACD,IAAI,IAAI,CAAC,I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,cAAc,CAAC,iBAAiB,CAAC,EAEvD;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,EAEvC;IAoBD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAUxG;IAED,+GAA+G;IAC/G,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/C;CA8GF;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,OAAO,SAAmB,GAAG,IAAI,CAIpE"}
@@ -1,4 +1,4 @@
1
- import { createDataInvalidationBus, createSpecStateStore, DEFAULT_LOCALE, DEFAULT_MESSAGES, PARTS_STATE_CSS, themeTokensToCssVars, } from "@kohaku-ui/renderer-core";
1
+ import { createDataInvalidationBus, createSpecStateStore, DEFAULT_LOCALE, DEFAULT_MESSAGES, deriveDisclosure, disclosureDomAttributes, PARTS_STATE_CSS, themeTokensToCssVars, } from "@kohaku-ui/renderer-core";
2
2
  import { ROOT_COMPONENT_ID } from "@kohaku-ui/spec-core";
3
3
  import { noop } from "./dom.js";
4
4
  import { createCoreRenderRegistry } from "./registry.js";
@@ -13,7 +13,16 @@ export const KOHAKU_EVENT = "kohaku-event";
13
13
  * this set: they are read live from `#context` at call time (see `#dispatchForward` and the wrapper
14
14
  * closures built in `#render`), so reassigning one of them mid-lifecycle must not force a full rebuild.
15
15
  */
16
- const REBUILD_KEYS = new Set(["binding", "theme", "locale", "messages", "sandbox"]);
16
+ const REBUILD_KEYS = new Set([
17
+ "binding",
18
+ "theme",
19
+ "locale",
20
+ "messages",
21
+ "sandbox",
22
+ "actionManifest",
23
+ "confirm",
24
+ "requestApproval",
25
+ ]);
17
26
  /** Every property <kohaku-surface> exposes as a plain instance accessor (used by #upgradeProperty). */
18
27
  const UPGRADE_PROPS = [
19
28
  "spec",
@@ -25,7 +34,11 @@ const UPGRADE_PROPS = [
25
34
  "onEvent",
26
35
  "onNodeError",
27
36
  "onActionResult",
37
+ "actionManifest",
38
+ "confirm",
39
+ "requestApproval",
28
40
  "sandbox",
41
+ "disclosure",
29
42
  ];
30
43
  /**
31
44
  * The single host element <kohaku-surface> (Shadow DOM). It builds the entire UI Spec tree into one shadow root
@@ -42,10 +55,22 @@ export class KohakuSurface extends HTMLElement {
42
55
  #spec = null;
43
56
  #context = {};
44
57
  #registry = createCoreRenderRegistry();
58
+ // version is not read by #render (RenderRuntime.registry only needs the builder); it is recorded purely
59
+ // for parity with renderer-react's ImplRegistry.register (see registerPart's doc comment).
60
+ #partVersions = new Map();
45
61
  // The store is retained by intent.hash; the bus stays the same for the surface's lifetime (equivalent to renderer-react's Provider useRef bus).
46
62
  #store = null;
47
63
  #bus = createDataInvalidationBus();
48
64
  #teardown = noop;
65
+ // AI-generation disclosure (design.md #66). Unlike the properties above, `disclosure` is attribute-backed
66
+ // (`static observedAttributes` + `attributeChangedCallback`) rather than a plain instance accessor: it is
67
+ // a simple serializable enum, well suited to `<kohaku-surface disclosure="label">` markup, unlike
68
+ // spec/context/binding/theme which need real object identity. #disclosureLabelEl is the shadow-root
69
+ // element `#applyDisclosure` creates on demand for `disclosure="label"`; null in every other mode.
70
+ #disclosureLabelEl = null;
71
+ static get observedAttributes() {
72
+ return ["disclosure"];
73
+ }
49
74
  constructor() {
50
75
  super();
51
76
  const shadow = this.attachShadow({ mode: "open" });
@@ -66,12 +91,28 @@ export class KohakuSurface extends HTMLElement {
66
91
  // forever, so its setter logic (patchContext / re-render) would never fire again once the element is
67
92
  // upgraded. Re-apply each such value through its accessor exactly once, here, at upgrade time
68
93
  // (connectedCallback always fires after the class is defined). A no-op for an element created after
69
- // define() (no own-property was ever set).
94
+ // define() (no own-property was ever set). "disclosure" is listed last so, if it was pre-assigned
95
+ // alongside "spec", #render() (triggered by spec's own upgrade) already sees the right value.
70
96
  for (const prop of UPGRADE_PROPS)
71
97
  this.#upgradeProperty(prop);
72
98
  if (this.#spec != null)
73
99
  this.#render();
74
100
  }
101
+ attributeChangedCallback(name, oldValue, newValue) {
102
+ if (name === "disclosure" && oldValue !== newValue)
103
+ this.#applyDisclosure();
104
+ }
105
+ /** `"off"` (default) | `"attributes"` | `"label"` (design.md #66). Reflects the `disclosure` attribute. */
106
+ get disclosure() {
107
+ const v = this.getAttribute("disclosure");
108
+ return v === "attributes" || v === "label" ? v : "off";
109
+ }
110
+ set disclosure(v) {
111
+ if (v === "off")
112
+ this.removeAttribute("disclosure");
113
+ else
114
+ this.setAttribute("disclosure", v);
115
+ }
75
116
  disconnectedCallback() {
76
117
  this.#teardown();
77
118
  this.#teardown = noop;
@@ -129,6 +170,15 @@ export class KohakuSurface extends HTMLElement {
129
170
  set onActionResult(v) {
130
171
  this.#patchContext({ onActionResult: v });
131
172
  }
173
+ set actionManifest(v) {
174
+ this.#patchContext({ actionManifest: v });
175
+ }
176
+ set confirm(v) {
177
+ this.#patchContext({ confirm: v });
178
+ }
179
+ set requestApproval(v) {
180
+ this.#patchContext({ requestApproval: v });
181
+ }
132
182
  set sandbox(v) {
133
183
  this.#patchContext({ sandbox: v });
134
184
  }
@@ -152,14 +202,51 @@ export class KohakuSurface extends HTMLElement {
152
202
  if (needsRebuild && this.#spec != null)
153
203
  this.#render();
154
204
  }
205
+ /**
206
+ * Public registration API for product-specific parts (design.md #68). Previously `#registry` was private
207
+ * with no way for a host to add its own component types — a product could not register anything beyond
208
+ * the core catalog on the WC surface at all. Pair with `implementWc` for typed props:
209
+ * ```ts
210
+ * const entry = implementWc(myPartDef, builder);
211
+ * surface.registerPart(entry.type, entry.version, entry.builder);
212
+ * ```
213
+ * `version` is recorded for parity with renderer-react's `ImplRegistry.register`; unlike that registry,
214
+ * this surface does not (yet) feed a `SurfaceCapabilities` table into `@kohaku-ui/registry`'s
215
+ * `negotiate()` — no host wires WC capability negotiation today (AGENTS.md's renderer-wc section) — so
216
+ * `version` is not itself consulted by any negotiation path yet. Call before assigning `spec` when
217
+ * possible; if a Spec is already mounted, this rebuilds it so the newly registered part renders
218
+ * immediately instead of only taking effect on the next Spec swap.
219
+ *
220
+ * `#registry` starts seeded with the 16 core-catalog parts (`createCoreRenderRegistry`), so registering
221
+ * an already-taken `type` — most easily a core one, by typo or intentional override — silently replaces
222
+ * it. That is sometimes exactly what a product wants (replacing a core part with its own), but silent
223
+ * shadowing of a core part is also an easy way to lose one by accident, so replacing any existing entry
224
+ * warns via `console.warn` unless the caller opts in explicitly with `{ override: true }`.
225
+ */
226
+ registerPart(type, version, builder, options) {
227
+ if (this.#registry.has(type) && options?.override !== true) {
228
+ console.warn(`[kohaku] registerPart("${type}", ...) replaces an existing part. ` +
229
+ "Pass { override: true } if that is intentional.");
230
+ }
231
+ this.#registry.set(type, builder);
232
+ this.#partVersions.set(type, version);
233
+ if (this.#spec != null)
234
+ this.#render();
235
+ }
236
+ /** The version last passed to `registerPart` for `type`, if any (introspection only — see its doc comment). */
237
+ getPartVersion(type) {
238
+ return this.#partVersions.get(type);
239
+ }
155
240
  #render() {
156
241
  // Tear down the previous tree (controller detach / unsubscribe / sandbox destroy / anchor removal).
157
242
  this.#teardown();
158
243
  this.#teardown = noop;
159
244
  this.#root.replaceChildren();
160
245
  const spec = this.#spec;
161
- if (spec == null)
246
+ if (spec == null) {
247
+ this.#applyDisclosure();
162
248
  return;
249
+ }
163
250
  const theme = this.#context.theme ?? {};
164
251
  const messages = { ...DEFAULT_MESSAGES, ...(this.#context.messages ?? {}) };
165
252
  const locale = this.#context.locale ?? DEFAULT_LOCALE;
@@ -187,6 +274,9 @@ export class KohakuSurface extends HTMLElement {
187
274
  // just one of these callbacks does not go through #render again, so RenderRuntime's own onNodeError/
188
275
  // onActionResult fields (baked in once here) must forward through a stable indirection instead of
189
276
  // holding a stale reference to whatever callback existed when the tree was last built.
277
+ // actionManifest / confirm / requestApproval are *not* wrapped: all three are in REBUILD_KEYS, so any
278
+ // change already goes through a fresh #render, matching binding/theme/sandbox's own treatment as
279
+ // tree-scoped data rather than a live-read callback.
190
280
  ctx: {
191
281
  ...this.#context,
192
282
  onNodeError: (args) => this.#context.onNodeError?.(args),
@@ -196,12 +286,57 @@ export class KohakuSurface extends HTMLElement {
196
286
  dispatchForward: (event) => this.#dispatchForward(event),
197
287
  });
198
288
  this.#teardown = mountTree(rt, this.#root, ROOT_COMPONENT_ID);
289
+ this.#applyDisclosure();
199
290
  }
200
291
  #dispatchForward(event) {
201
292
  // composed so it crosses the shadow boundary and reaches the host page. Flows to both paths regardless of whether a sink exists.
202
293
  this.dispatchEvent(new CustomEvent(KOHAKU_EVENT, { detail: event, bubbles: true, composed: true }));
203
294
  this.#context.onEvent?.(event);
204
295
  }
296
+ /**
297
+ * Applies (or clears) AI-generation disclosure (design.md #66): the `data-kohaku-disclosure` /
298
+ * `data-kohaku-tier` / `data-digital-source-type` attributes go on the *host* element itself (`this`),
299
+ * not inside the shadow root -- unlike renderer-react's SpecView, which has no host element of its own
300
+ * to mark and so wraps the tree in an internal `<div>` instead. The visible label (`disclosure="label"`
301
+ * only) is a shadow-root element, since that is what is actually displayed. Called from `#render()`
302
+ * (spec/context changes) and from `attributeChangedCallback` (the `disclosure` attribute changing on
303
+ * its own, with no other change to re-render for).
304
+ */
305
+ #applyDisclosure() {
306
+ const mode = this.disclosure;
307
+ if (mode === "off" || this.#spec == null) {
308
+ this.removeAttribute("data-kohaku-disclosure");
309
+ this.removeAttribute("data-kohaku-tier");
310
+ this.removeAttribute("data-digital-source-type");
311
+ this.#disclosureLabelEl?.remove();
312
+ this.#disclosureLabelEl = null;
313
+ return;
314
+ }
315
+ const disclosure = deriveDisclosure(this.#spec.provenance);
316
+ const attrs = disclosureDomAttributes(disclosure);
317
+ this.setAttribute("data-kohaku-disclosure", attrs["data-kohaku-disclosure"]);
318
+ this.setAttribute("data-kohaku-tier", attrs["data-kohaku-tier"]);
319
+ if (attrs["data-digital-source-type"] != null) {
320
+ this.setAttribute("data-digital-source-type", attrs["data-digital-source-type"]);
321
+ }
322
+ else {
323
+ this.removeAttribute("data-digital-source-type");
324
+ }
325
+ if (mode === "label" && disclosure.level !== "none") {
326
+ const messages = { ...DEFAULT_MESSAGES, ...(this.#context.messages ?? {}) };
327
+ const text = disclosure.level === "ai-generated" ? messages.disclosureAiGenerated : messages.disclosureAiReviewed;
328
+ if (this.#disclosureLabelEl == null) {
329
+ this.#disclosureLabelEl = document.createElement("div");
330
+ this.#disclosureLabelEl.setAttribute("data-kohaku-disclosure-label", "");
331
+ this.shadowRoot.insertBefore(this.#disclosureLabelEl, this.#root);
332
+ }
333
+ this.#disclosureLabelEl.textContent = text;
334
+ }
335
+ else {
336
+ this.#disclosureLabelEl?.remove();
337
+ this.#disclosureLabelEl = null;
338
+ }
339
+ }
205
340
  }
206
341
  /** Registers <kohaku-surface> as a custom element (idempotent). */
207
342
  export function defineKohakuSurface(tagName = "kohaku-surface") {
@@ -1 +1 @@
1
- {"version":3,"file":"kohaku-surface.js","sourceRoot":"","sources":["../src/kohaku-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EAEpB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAIf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAiC,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGrD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAuB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC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,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,yHAAyH;IACzH,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAsC9D;AAED,+GAA+G;AAC/G,wBAAgB,SAAS,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAEzF"}
package/dist/tree.js CHANGED
@@ -28,6 +28,9 @@ export function createRuntime(deps) {
28
28
  messages: deps.messages,
29
29
  onNodeError: deps.ctx.onNodeError,
30
30
  onActionResult: deps.ctx.onActionResult,
31
+ actionManifest: deps.ctx.actionManifest,
32
+ confirm: deps.ctx.confirm,
33
+ requestApproval: deps.ctx.requestApproval,
31
34
  sandbox: deps.ctx.sandbox,
32
35
  registry: deps.registry,
33
36
  dispatchForward: deps.dispatchForward,
@@ -135,10 +138,22 @@ function emitEvent(rt, node, eventName, runtime, row) {
135
138
  }
136
139
  // drop: undeclared events are discarded (SPEC-EVT-002).
137
140
  }
141
+ /**
142
+ * The default "confirm"-tier hook (design.md #62/#63) used when the host does not supply its own via
143
+ * `SurfaceContext.confirm`: `globalThis.confirm` (the native browser dialog). Declines (returns `false`)
144
+ * when `confirm` is unavailable in this environment (e.g. SSR) rather than throwing — the same fail-safe
145
+ * posture as an explicitly declining host hook.
146
+ */
147
+ function defaultConfirmHook(messages, args) {
148
+ if (typeof globalThis.confirm !== "function")
149
+ return false;
150
+ return globalThis.confirm(args.message ?? messages.actionConfirmDefault(args.action));
151
+ }
138
152
  /**
139
153
  * Applies the write path (the glue for resolveInvokeTarget). Whether binding exists is passed as a boolean.
140
- * For invoke, delegates the pending/invokeAction/phase/publish/onActionResult sequence to renderer-core's
141
- * runInvokeTarget (shared with renderer-react); otherwise delegates to emit.
154
+ * For invoke, delegates the preflightAction/confirm/requestApproval/pending/invokeAction/phase/publish/
155
+ * onActionResult sequence to renderer-core's runInvokeTarget (shared with renderer-react); otherwise
156
+ * delegates to emit.
142
157
  */
143
158
  async function invokeAction(rt, node, eventName, runtime, row, onPhase) {
144
159
  const target = resolveInvokeTarget(rt.spec, node, eventName, runtime, {
@@ -150,8 +165,17 @@ async function invokeAction(rt, node, eventName, runtime, row, onPhase) {
150
165
  return;
151
166
  }
152
167
  const binding = rt.binding;
153
- // The pending → invokeAction → succeeded/failed phase → bus.publish → onActionResult sequence has
154
- // renderer-core's runInvokeTarget as the single source of truth (shared with renderer-react).
155
- await runInvokeTarget(target, { binding, bus: rt.bus, onActionResult: rt.onActionResult }, node.id, onPhase);
168
+ // The pending → invokeAction → succeeded/failed/invalid/awaitingApproval phase → bus.publish →
169
+ // onActionResult sequence has renderer-core's runInvokeTarget as the single source of truth (shared
170
+ // with renderer-react). `confirm` defaults to `globalThis.confirm` (defaultConfirmHook) when the host
171
+ // does not supply its own; `requestApproval` has no default (design.md #63).
172
+ await runInvokeTarget(target, {
173
+ binding,
174
+ bus: rt.bus,
175
+ onActionResult: rt.onActionResult,
176
+ actionManifest: rt.actionManifest,
177
+ confirm: rt.confirm ?? ((args) => defaultConfirmHook(rt.messages, args)),
178
+ requestApproval: rt.requestApproval,
179
+ }, node.id, onPhase);
156
180
  }
157
181
  //# sourceMappingURL=tree.js.map
package/dist/tree.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EAGzB,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,GAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAA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CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACxF,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,YAAY,CACzB,EAAiB,EACjB,IAAmB,EACnB,SAAiB,EACjB,OAAmB,EACnB,GAAsB,EACtB,OAAqC;IAErC,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;QACpE,UAAU,EAAE,EAAE,CAAC,OAAO,IAAI,IAAI;QAC9B,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,CAAC,OAAwB,CAAC;IAC5C,+FAA+F;IAC/F,oGAAoG;IACpG,sGAAsG;IACtG,6EAA6E;IAC7E,MAAM,eAAe,CACnB,MAAM,EACN;QACE,OAAO;QACP,GAAG,EAAE,EAAE,CAAC,GAAG;QACX,cAAc,EAAE,EAAE,CAAC,cAAc;QACjC,cAAc,EAAE,EAAE,CAAC,cAAc;QACjC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACxE,eAAe,EAAE,EAAE,CAAC,eAAe;KACpC,EACD,IAAI,CAAC,EAAE,EACP,OAAO,CACR,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { BindingClient } from "@kohaku-ui/data-binding";
2
- import type { ActionPhase, BoundDataController, DataInvalidationBus, RendererMessages, SizingTokens, SpecStateStore, SurfaceEvent } from "@kohaku-ui/renderer-core";
2
+ import type { ActionManifest, ActionPhase, BoundDataController, DataInvalidationBus, RendererMessages, SizingTokens, SpecStateStore, SurfaceEvent } from "@kohaku-ui/renderer-core";
3
3
  import type { DesignKitStylesheet, SandboxBridge, SandboxPolicy } from "@kohaku-ui/sandbox";
4
4
  import type { ComponentNode, JsonObject, ThemeTokens, UISpec } from "@kohaku-ui/spec-core";
5
5
  export type { ActionPhase, SurfaceEvent } from "@kohaku-ui/renderer-core";
@@ -74,6 +74,29 @@ export interface SurfaceContext {
74
74
  result?: unknown;
75
75
  message?: string;
76
76
  }) => void;
77
+ /**
78
+ * The compose-issued Action manifest (design.md #62/#64), threaded through to `runInvokeTarget` for a
79
+ * client-side `preflightAction` check before the round trip. Absent -> no local check; the server
80
+ * remains authoritative.
81
+ */
82
+ actionManifest?: ActionManifest;
83
+ /**
84
+ * Confirmation hook for a "confirm"-tier action (design.md #62/#63). When unset, defaults to
85
+ * `globalThis.confirm` (declining when unavailable in this environment, e.g. SSR).
86
+ */
87
+ confirm?: (args: {
88
+ action: string;
89
+ message?: string;
90
+ }) => boolean | Promise<boolean>;
91
+ /**
92
+ * Approval-token hook for an "approve"-tier action (design.md #63). No default is provided (an approval
93
+ * token is obtained out of band — there is no generic browser-native equivalent of `globalThis.confirm`
94
+ * for it).
95
+ */
96
+ requestApproval?: (args: {
97
+ action: string;
98
+ payload: JsonObject;
99
+ }) => string | undefined | Promise<string | undefined>;
77
100
  /** Bridge / policy / kit / badge visibility for running L2 (sandbox.html) parts. See {@link SandboxSurfaceContext}. */
78
101
  sandbox?: SandboxSurfaceContext;
79
102
  }
@@ -95,6 +118,9 @@ export interface RenderRuntime {
95
118
  messages: RendererMessages;
96
119
  onNodeError: SurfaceContext["onNodeError"];
97
120
  onActionResult: SurfaceContext["onActionResult"];
121
+ actionManifest: SurfaceContext["actionManifest"];
122
+ confirm: SurfaceContext["confirm"];
123
+ requestApproval: SurfaceContext["requestApproval"];
98
124
  sandbox: SurfaceContext["sandbox"];
99
125
  /** Table of type → part builder (createCoreRenderRegistry). */
100
126
  registry: Map<string, PartBuilder>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE3F,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE1E,mFAAmF;AACnF,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,sDAAsD;IACtD,MAAM,EAAE,aAAa,CAAC;IACtB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,EACA,mBAAmB,GACnB,MAAM,GACN,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,KAAK,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACtF;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iIAAiI;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C,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,UAAU,GAAG,IAAI,KACnB,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kohaku-ui/renderer-wc",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Web Components renderer for kohaku UI Specs: a single <kohaku-surface> custom element with Shadow DOM.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,14 +11,17 @@
11
11
  "./package.json": "./package.json"
12
12
  },
13
13
  "dependencies": {
14
- "@kohaku-ui/spec-core": "^0.3.0",
15
- "@kohaku-ui/data-binding": "^0.3.0",
16
- "@kohaku-ui/renderer-core": "^0.3.0",
17
- "@kohaku-ui/registry": "^0.3.0",
18
- "@kohaku-ui/sandbox": "^0.3.0"
14
+ "@kohaku-ui/spec-core": "^0.4.0",
15
+ "@kohaku-ui/data-binding": "^0.4.0",
16
+ "@kohaku-ui/renderer-core": "^0.4.0",
17
+ "@kohaku-ui/registry": "^0.4.0",
18
+ "@kohaku-ui/sandbox": "^0.4.0"
19
+ },
20
+ "peerDependencies": {
21
+ "zod": "^4.6.5"
19
22
  },
20
23
  "devDependencies": {
21
- "@kohaku-ui/renderer-react": "^0.3.0",
24
+ "@kohaku-ui/renderer-react": "^0.4.0",
22
25
  "@testing-library/react": "^16.3.3",
23
26
  "axe-core": "^4.13.0",
24
27
  "@types/react": "^19.3.0",
@@ -28,7 +31,8 @@
28
31
  "react-dom": "19.3.0",
29
32
  "recharts": "^3.10.1",
30
33
  "typescript": "7.0.2",
31
- "vitest": "^5.0.1"
34
+ "vitest": "^5.0.1",
35
+ "zod": "^4.6.5"
32
36
  },
33
37
  "license": "Apache-2.0",
34
38
  "homepage": "https://github.com/yosuque/kohaku/tree/main/packages/renderer-wc#readme",