@agent-surface/react 0.13.0 → 0.16.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/README.md CHANGED
@@ -1,48 +1,12 @@
1
- # @agent-surface/react
1
+ # `@agent-surface/react`
2
2
 
3
- React bindings for [agent-surface](https://github.com/Wiseair-srl/agent-surface): lifecycle-correct hooks that tie capability registrations to component mounts. Registration happens once per mount in an effect; handlers are read through a ref at invocation time — no dependency arrays, no `useCallback`, no stale closures. Strict Mode, Suspense, SSR and concurrent rendering all work without special cases.
4
-
5
- Docs: https://agent-surface-docs.vercel.app
6
-
7
- ## Install
8
-
9
- ```bash
10
- pnpm add @agent-surface/core @agent-surface/react
11
- ```
12
-
13
- ## Use
3
+ Lifecycle-correct runtime bindings for compiler-generated contracts.
14
4
 
15
5
  ```tsx
16
- import { AgentSurfaceProvider, useAgentComponent, usePendingConfirmations } from "@agent-surface/react";
17
- import { action, observation } from "@agent-surface/core";
18
-
19
- function DevicesTable() {
20
- const [selectedIds, setSelectedIds] = useState<string[]>([]);
21
- useAgentComponent({
22
- type: "devices.table",
23
- description: "Table of the devices visible on the current page",
24
- observations: {
25
- readState: observation({
26
- description: "Visible rows and selection",
27
- output: TableStateSchema,
28
- read: () => ({ visibleRows, selectedIds }),
29
- }),
30
- },
31
- actions: {
32
- selectRows: action({
33
- description: "Replace the current row selection",
34
- input: SelectRowsSchema,
35
- effect: "local-state",
36
- execute: ({ ids }) => setSelectedIds(ids),
37
- }),
38
- },
39
- });
40
- return <Table />;
41
- }
6
+ useAgentComponent(devicesTableContract, {
7
+ observations: { readState: { read: () => state } },
8
+ actions: { selectRows: { execute: ({ ids }) => setSelected(ids) } },
9
+ });
42
10
  ```
43
11
 
44
- While mounted, an agent sees two typed capabilities; on unmount they are gone and late invocations fail with typed `COMPONENT_UNMOUNTED`. Availability (`when`, `enabled`) is re-evaluated per commit and pushed to the registry.
45
-
46
- Full specification: [docs](https://github.com/Wiseair-srl/agent-surface/tree/main/docs).
47
-
48
- MIT © Wiseair S.r.l.
12
+ Static identity/governance stays in the contract; handlers, state and availability stay in React. See [React API](../../docs/04-react-api.md).
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { AgentSurfaceRegistry, AgentComponentDefinition, PendingConfirmation, JsonValue, AgentActionDefinition, AgentObservationDefinition } from '@agent-surface/core';
2
+ import { AgentSurfaceRegistry, AgentComponentDefinition, AgentComponentContract, AgentComponentRuntimeBindings, PendingConfirmation, JsonValue, AgentActionDefinition, AgentObservationDefinition } from '@agent-surface/core';
3
3
 
4
4
  interface AgentSurfaceProviderProps {
5
5
  registry: AgentSurfaceRegistry;
@@ -35,6 +35,8 @@ interface AgentComponentHandle {
35
35
  * stale closures. Structure is frozen per registration (D2): changing it on a
36
36
  * live registration logs an error and re-registers.
37
37
  */
38
+ declare function useAgentComponent<TObservations extends Record<string, any>, TActions extends Record<string, any>>(contract: AgentComponentContract<TObservations, TActions>, bindings: AgentComponentRuntimeBindings<TObservations, TActions>): AgentComponentHandle;
39
+ /** @deprecated Use a compiler-generated contract plus runtime bindings. */
38
40
  declare function useAgentComponent(config: UseAgentComponentConfig): AgentComponentHandle;
39
41
 
40
42
  interface PendingConfirmationView extends PendingConfirmation {
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ function useAgentSurface() {
18
18
 
19
19
  // src/use-agent-component.ts
20
20
  import { useEffect, useRef, useState } from "react";
21
+ import { COMPILED_CAPABILITY_PROVENANCE } from "@agent-surface/core";
21
22
 
22
23
  // src/render-scope.ts
23
24
  var current = null;
@@ -33,7 +34,10 @@ function readRenderScopeContext() {
33
34
  }
34
35
 
35
36
  // src/use-agent-component.ts
36
- function useAgentComponent(config) {
37
+ function useAgentComponent(contractOrConfig, runtimeBindings) {
38
+ const config = "kind" in contractOrConfig && contractOrConfig.kind === "agent-component-contract" ? contractOrConfig.bind(
39
+ runtimeBindings ?? {}
40
+ ) : contractOrConfig;
37
41
  const registry = useAgentSurface();
38
42
  const type = config.type;
39
43
  const instanceId = config.instanceId ?? "default";
@@ -134,7 +138,7 @@ function buildDelegatingDefinition(latest) {
134
138
  ...act.timeoutMs !== void 0 ? { timeoutMs: act.timeoutMs } : {}
135
139
  };
136
140
  }
137
- return {
141
+ const definition = {
138
142
  type: cfg.type,
139
143
  ...cfg.instanceId !== void 0 ? { instanceId: cfg.instanceId } : {},
140
144
  description: cfg.description,
@@ -148,6 +152,14 @@ function buildDelegatingDefinition(latest) {
148
152
  ...Object.keys(observations).length > 0 ? { observations } : {},
149
153
  ...Object.keys(actions).length > 0 ? { actions } : {}
150
154
  };
155
+ const provenance = cfg[COMPILED_CAPABILITY_PROVENANCE];
156
+ if (provenance) {
157
+ Object.defineProperty(definition, COMPILED_CAPABILITY_PROVENANCE, {
158
+ value: provenance,
159
+ enumerable: false
160
+ });
161
+ }
162
+ return definition;
151
163
  }
152
164
  function evaluateReason(reason) {
153
165
  try {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context.ts","../src/use-agent-component.ts","../src/render-scope.ts","../src/confirmations.ts","../src/granular.ts"],"sourcesContent":["import { createContext, createElement, useContext, type ReactNode } from \"react\";\nimport type { AgentSurfaceRegistry } from \"@agent-surface/core\";\n\nconst AgentSurfaceContext = createContext<AgentSurfaceRegistry | null>(null);\n\nexport interface AgentSurfaceProviderProps {\n registry: AgentSurfaceRegistry;\n children: ReactNode;\n}\n\n/**\n * The application creates the registry ONCE (module scope or top-level\n * useState initializer) and passes it down — registry creation is where\n * environment, policies, audit and route wiring live (docs/04).\n */\nexport function AgentSurfaceProvider(props: AgentSurfaceProviderProps): ReactNode {\n return createElement(AgentSurfaceContext.Provider, { value: props.registry }, props.children);\n}\n\n/** Access the registry from context. Throws if no provider is mounted. */\nexport function useAgentSurface(): AgentSurfaceRegistry {\n const registry = useContext(AgentSurfaceContext);\n if (!registry) {\n throw new Error(\n \"useAgentSurface: no <AgentSurfaceProvider> found above this component. Wrap your app in a provider with an explicitly created registry.\",\n );\n }\n return registry;\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport type {\n AgentActionContext,\n AgentActionDefinition,\n AgentComponentDefinition,\n AgentObservationDefinition,\n AgentReadContext,\n AgentRegistrationHandle,\n JsonValue,\n} from \"@agent-surface/core\";\nimport { useAgentSurface } from \"./context.js\";\nimport { setRenderScopeContext } from \"./render-scope.js\";\n\nexport interface UseAgentComponentConfig\n extends Omit<AgentComponentDefinition, \"procedures\"> {\n /**\n * Gate for \"mounted but not presented\" (inactive tab, keep-alive, exit\n * animation). false ⇒ all capabilities visible-disabled. Default true.\n */\n enabled?: boolean;\n}\n\nexport interface AgentComponentHandle {\n /** Current registrationId; changes on remount/re-register. */\n registrationId: string | undefined;\n status: \"active\" | \"rejected\" | \"unregistered\" | \"pending\";\n}\n\n/**\n * One aggregated hook per agent component (docs/04, the recommended default):\n * one registration, one atomic descriptor, one lifecycle.\n *\n * Registration happens once per mount, in an effect; handlers are read through\n * a ref at invocation time (D3) — no dependency arrays, no useCallback, no\n * stale closures. Structure is frozen per registration (D2): changing it on a\n * live registration logs an error and re-registers.\n */\nexport function useAgentComponent(config: UseAgentComponentConfig): AgentComponentHandle {\n const registry = useAgentSurface();\n const type = config.type;\n const instanceId = config.instanceId ?? \"default\";\n\n // D3 latest-ref: every render writes the fresh config; the registered\n // definition's handlers delegate through it at invocation time.\n const latest = useRef(config);\n latest.current = config;\n\n // Record the render-scope link for a following useAgentProcedure call.\n setRenderScopeContext({ type, instanceId });\n\n const [nonce, setNonce] = useState(0);\n const handleRef = useRef<AgentRegistrationHandle | null>(null);\n const fingerprintRef = useRef<string | null>(null);\n const lastPushedAvailability = useRef<Record<string, { available: boolean; reason?: string }>>({});\n const lastPushedEnabled = useRef<boolean | null>(null);\n const [state, setState] = useState<AgentComponentHandle>({\n registrationId: undefined,\n status: \"pending\",\n });\n\n useEffect(() => {\n const definition = buildDelegatingDefinition(latest);\n const handle = registry.register(definition);\n handleRef.current = handle;\n fingerprintRef.current = structuralFingerprint(latest.current);\n lastPushedAvailability.current = {};\n lastPushedEnabled.current = latest.current.enabled !== false;\n const registrationId = handle.status === \"active\" ? handle.registrationId : undefined;\n const status = handle.status === \"active\" ? \"active\" : \"rejected\";\n setState((prev) =>\n prev.registrationId === registrationId && prev.status === status\n ? prev\n : { registrationId, status },\n );\n if (handle.status === \"active\") {\n pushAvailability(handle, latest.current, lastPushedAvailability, lastPushedEnabled);\n }\n return () => {\n handle.unregister();\n handleRef.current = null;\n fingerprintRef.current = null;\n };\n // Identity keys: (registry, type, instanceId) + explicit re-register nonce.\n }, [registry, type, instanceId, nonce]);\n\n // Availability is reactive (docs/04): re-evaluated on every commit and\n // PUSHED on change, so the surface version bumps and adapters refresh.\n useEffect(() => {\n const handle = handleRef.current;\n if (!handle || handle.status !== \"active\") return;\n const fingerprint = structuralFingerprint(latest.current);\n if (fingerprintRef.current !== null && fingerprint !== fingerprintRef.current) {\n // Structural change on a live registration violates D2. Re-register so\n // the surface never lies about what this registrationId can do.\n // eslint-disable-next-line no-console\n console.error(\n `[agent-surface] structural config change detected on live registration \"${type}\" (${instanceId}). ` +\n \"Structure (names, schemas, descriptions, effects, policies) is frozen per registration (D2); \" +\n \"keep it static per mount and put dynamism in when/enabled/handlers. Re-registering with a new registrationId.\",\n );\n setNonce((n) => n + 1);\n return;\n }\n pushAvailability(handle, latest.current, lastPushedAvailability, lastPushedEnabled);\n });\n\n return state;\n}\n\n/* ────────────────────────────── internals ────────────────────────────── */\n\ntype LatestRef = { current: UseAgentComponentConfig };\n\nfunction buildDelegatingDefinition(latest: LatestRef): AgentComponentDefinition {\n const cfg = latest.current;\n const observations: Record<string, AgentObservationDefinition<any>> = {};\n for (const [name, obs] of Object.entries(cfg.observations ?? {})) {\n observations[name] = {\n description: obs.description,\n output: obs.output,\n read: (ctx: AgentReadContext) => {\n const live = latest.current.observations?.[name];\n if (!live) throw new Error(`observation \"${name}\" disappeared from the config`);\n return live.read(ctx);\n },\n ...(obs.when !== undefined\n ? { when: () => latest.current.observations?.[name]?.when?.() !== false }\n : {}),\n ...(obs.unavailableReason !== undefined\n ? {\n unavailableReason: () =>\n evaluateReason(latest.current.observations?.[name]?.unavailableReason),\n }\n : {}),\n ...(obs.policies ? { policies: obs.policies } : {}),\n ...(obs.meta ? { meta: obs.meta } : {}),\n ...(obs.timeoutMs !== undefined ? { timeoutMs: obs.timeoutMs } : {}),\n };\n }\n const actions: Record<string, AgentActionDefinition<any, any>> = {};\n for (const [name, act] of Object.entries(cfg.actions ?? {})) {\n actions[name] = {\n description: act.description,\n input: act.input,\n ...(act.output ? { output: act.output } : {}),\n effect: act.effect,\n ...(act.idempotent !== undefined ? { idempotent: act.idempotent } : {}),\n ...(act.reversible !== undefined ? { reversible: act.reversible } : {}),\n ...(act.confirmation !== undefined ? { confirmation: act.confirmation } : {}),\n ...(act.audit !== undefined ? { audit: act.audit } : {}),\n ...(act.when !== undefined\n ? { when: () => latest.current.actions?.[name]?.when?.() !== false }\n : {}),\n ...(act.unavailableReason !== undefined\n ? {\n unavailableReason: () =>\n evaluateReason(latest.current.actions?.[name]?.unavailableReason),\n }\n : {}),\n ...(act.precondition !== undefined\n ? {\n precondition: (input: JsonValue, ctx: AgentReadContext) =>\n latest.current.actions?.[name]?.precondition?.(input, ctx),\n }\n : {}),\n execute: (input: JsonValue, ctx: AgentActionContext) => {\n const live = latest.current.actions?.[name];\n if (!live) throw new Error(`action \"${name}\" disappeared from the config`);\n return live.execute(input, ctx);\n },\n ...(act.policies ? { policies: act.policies } : {}),\n ...(act.meta ? { meta: act.meta } : {}),\n ...(act.timeoutMs !== undefined ? { timeoutMs: act.timeoutMs } : {}),\n };\n }\n return {\n type: cfg.type,\n ...(cfg.instanceId !== undefined ? { instanceId: cfg.instanceId } : {}),\n description: cfg.description,\n ...(cfg.parent ? { parent: cfg.parent } : {}),\n ...(cfg.meta ? { meta: cfg.meta } : {}),\n ...(cfg.internal ? { internal: cfg.internal } : {}),\n ...(cfg.policies ? { policies: cfg.policies } : {}),\n ...(cfg.origin !== undefined ? { origin: cfg.origin } : {}),\n ...(cfg.priority !== undefined ? { priority: cfg.priority } : {}),\n ...(cfg.enabled !== undefined ? { enabled: cfg.enabled } : {}),\n ...(Object.keys(observations).length > 0 ? { observations } : {}),\n ...(Object.keys(actions).length > 0 ? { actions } : {}),\n };\n}\n\nfunction evaluateReason(\n reason: string | (() => string) | undefined,\n): string {\n try {\n if (typeof reason === \"function\") return reason();\n if (typeof reason === \"string\") return reason;\n } catch {\n /* fall through */\n }\n return \"Currently unavailable\";\n}\n\n/** Structural fingerprint per D2 (handlers and when() results excluded). */\nfunction structuralFingerprint(cfg: UseAgentComponentConfig): string {\n const capability = (\n def:\n | AgentObservationDefinition<any>\n | AgentActionDefinition<any, any>,\n ): unknown => ({\n description: def.description,\n output: \"output\" in def && def.output ? def.output.jsonSchema : undefined,\n input: \"input\" in def ? def.input.jsonSchema : undefined,\n effect: \"effect\" in def ? def.effect : undefined,\n idempotent: \"idempotent\" in def ? def.idempotent : undefined,\n reversible: \"reversible\" in def ? def.reversible : undefined,\n confirmation: \"confirmation\" in def ? def.confirmation : undefined,\n audit: \"audit\" in def ? def.audit : undefined,\n timeoutMs: def.timeoutMs,\n hasWhen: def.when !== undefined,\n hasPrecondition: \"precondition\" in def && def.precondition !== undefined,\n policies: (def.policies ?? []).map((p) => p.name),\n });\n return JSON.stringify({\n type: cfg.type,\n instanceId: cfg.instanceId ?? \"default\",\n description: cfg.description,\n parent: cfg.parent,\n meta: cfg.meta,\n origin: cfg.origin,\n priority: cfg.priority,\n policies: (cfg.policies ?? []).map((p) => p.name),\n observations: Object.fromEntries(\n Object.entries(cfg.observations ?? {}).map(([name, def]) => [name, capability(def)]),\n ),\n actions: Object.fromEntries(\n Object.entries(cfg.actions ?? {}).map(([name, def]) => [name, capability(def)]),\n ),\n });\n}\n\nfunction pushAvailability(\n handle: AgentRegistrationHandle,\n cfg: UseAgentComponentConfig,\n lastPushed: { current: Record<string, { available: boolean; reason?: string }> },\n lastEnabled: { current: boolean | null },\n): void {\n const patch: {\n enabled?: boolean;\n availability?: Record<string, { available: boolean; reason?: string }>;\n } = {};\n\n const enabled = cfg.enabled !== false;\n if (lastEnabled.current !== enabled) {\n patch.enabled = enabled;\n lastEnabled.current = enabled;\n }\n\n const availability: Record<string, { available: boolean; reason?: string }> = {};\n const evaluate = (\n name: string,\n def: { when?: () => boolean; unavailableReason?: string | (() => string) },\n ): void => {\n if (!def.when) return; // no predicate ⇒ availability governed by enabled only\n let available = true;\n try {\n available = def.when() !== false;\n } catch {\n available = false;\n }\n const entry = available\n ? { available: true as const }\n : { available: false as const, reason: evaluateReason(def.unavailableReason) };\n const prev = lastPushed.current[name];\n if (!prev || prev.available !== entry.available || prev.reason !== entry.reason) {\n availability[name] = entry;\n lastPushed.current[name] = entry;\n }\n };\n for (const [name, def] of Object.entries(cfg.observations ?? {})) evaluate(name, def);\n for (const [name, def] of Object.entries(cfg.actions ?? {})) evaluate(name, def);\n\n if (Object.keys(availability).length > 0) patch.availability = availability;\n if (patch.enabled !== undefined || patch.availability) handle.update(patch);\n}\n","/**\n * Best-effort render-scope link between useAgentComponent and a following\n * useAgentProcedure in the SAME component function (docs/05): the component\n * hook records its identity during render; the procedure hook reads it.\n *\n * React exposes no public per-instance identity shared across independent\n * hook calls, so this is a heuristic: it is precise for the canonical\n * pattern (both hooks in one component) and clears itself at the end of the\n * synchronous render pass. A sibling component rendering later in the same\n * pass with only useAgentProcedure may pick up a stale link — cosmetic only\n * (the link is descriptor metadata, never authority).\n */\n\nexport interface RenderScopeContext {\n type: string;\n instanceId: string;\n}\n\ninterface Slot {\n context: RenderScopeContext;\n token: object;\n}\n\nlet current: Slot | null = null;\n\nexport function setRenderScopeContext(context: RenderScopeContext): void {\n const token = {};\n current = { context, token };\n queueMicrotask(() => {\n if (current?.token === token) current = null;\n });\n}\n\nexport function readRenderScopeContext(): RenderScopeContext | undefined {\n return current?.context;\n}\n","import { useEffect, useState } from \"react\";\nimport type { PendingConfirmation } from \"@agent-surface/core\";\nimport { useAgentSurface } from \"./context.js\";\n\nexport interface PendingConfirmationView extends PendingConfirmation {\n approve(): void;\n deny(reason?: string): void;\n}\n\n/**\n * Reactive list of pending confirmations for host-rendered dialogs. The\n * dialog is representation, not policy: approving calls\n * registry.confirmations.resolve, which mints the single-use evidence\n * (docs/04, docs/06).\n */\nexport function usePendingConfirmations(): PendingConfirmationView[] {\n const registry = useAgentSurface();\n const [pending, setPending] = useState<PendingConfirmation[]>(() =>\n registry.confirmations.pending(),\n );\n\n useEffect(() => {\n setPending(registry.confirmations.pending());\n return registry.confirmations.subscribe((next) => {\n setPending(next);\n });\n }, [registry]);\n\n return pending.map((record) => ({\n ...record,\n approve: () => registry.confirmations.resolve(record.confirmationId, { approved: true }),\n deny: (reason?: string) =>\n registry.confirmations.resolve(record.confirmationId, {\n approved: false,\n ...(reason !== undefined ? { reason } : {}),\n }),\n }));\n}\n","import {\n createContext,\n createElement,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport type {\n AgentActionDefinition,\n AgentObservationDefinition,\n JsonValue,\n} from \"@agent-surface/core\";\nimport { useAgentComponent, type UseAgentComponentConfig } from \"./use-agent-component.js\";\n\n/**\n * Granular composition — Experimental (docs/04): capabilities contributed\n * from separate files/subcomponents. Late-added capabilities are structural\n * changes, so each attach/detach re-registers the scope (new registrationId).\n * The aggregated useAgentComponent hook remains the recommended default.\n */\n\ninterface ScopeStore {\n observations: Map<string, AgentObservationDefinition<any>>;\n actions: Map<string, AgentActionDefinition<any, any>>;\n bump(): void;\n add(kind: \"observation\" | \"action\", name: string, def: unknown): () => void;\n}\n\nconst ScopeContext = createContext<ScopeStore | null>(null);\n\nexport interface AgentComponentScopeProps {\n config: Omit<UseAgentComponentConfig, \"observations\" | \"actions\">;\n children: ReactNode;\n}\n\n/** Establishes a component scope; children attach capabilities to it. */\nexport function AgentComponentScope(props: AgentComponentScopeProps): ReactNode {\n const [, setVersion] = useState(0);\n const store = useMemo<ScopeStore>(() => {\n const observations = new Map<string, AgentObservationDefinition<any>>();\n const actions = new Map<string, AgentActionDefinition<any, any>>();\n const bump = (): void => setVersion((v) => v + 1);\n return {\n observations,\n actions,\n bump,\n add(kind, name, def) {\n const map = kind === \"observation\" ? observations : actions;\n map.set(name, def as never);\n bump();\n return () => {\n map.delete(name);\n bump();\n };\n },\n };\n }, []);\n\n return createElement(\n ScopeContext.Provider,\n { value: store },\n createElement(ScopeRegistrar, { store, config: props.config }),\n props.children,\n );\n}\n\nfunction ScopeRegistrar(props: {\n store: ScopeStore;\n config: Omit<UseAgentComponentConfig, \"observations\" | \"actions\">;\n}): null {\n // Child effects run before this parent effect, so attachments within one\n // commit are coalesced into a single (re-)registration.\n useAgentComponent({\n ...props.config,\n observations: Object.fromEntries(props.store.observations),\n actions: Object.fromEntries(props.store.actions),\n });\n return null;\n}\n\nfunction useScope(hook: string): ScopeStore {\n const store = useContext(ScopeContext);\n if (!store) {\n throw new Error(`${hook} must be used inside an <AgentComponentScope>`);\n }\n return store;\n}\n\nexport function useAgentAction<TIn extends JsonValue, TOut extends JsonValue | void = void>(\n name: string,\n def: AgentActionDefinition<TIn, TOut>,\n): void {\n const store = useScope(\"useAgentAction\");\n // Keep the stored definition fresh without re-registering (D3 handlers are\n // read through the aggregated hook's latest-ref at invocation time).\n if (store.actions.has(name)) store.actions.set(name, def as AgentActionDefinition<any, any>);\n useEffect(() => store.add(\"action\", name, def), [store, name]);\n}\n\nexport function useAgentObservation<TOut extends JsonValue>(\n name: string,\n def: AgentObservationDefinition<TOut>,\n): void {\n const store = useScope(\"useAgentObservation\");\n if (store.observations.has(name)) {\n store.observations.set(name, def as AgentObservationDefinition<any>);\n }\n useEffect(() => store.add(\"observation\", name, def), [store, name]);\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,eAAe,kBAAkC;AAGzE,IAAM,sBAAsB,cAA2C,IAAI;AAYpE,SAAS,qBAAqB,OAA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AAI,MAAM,GAAY;AAC1B,aAAK;AACL,eAAO,MAAM;AACX,cAAI,OAAO,IAAI;AACf,eAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAOC;AAAA,IACL,aAAa;AAAA,IACb,EAAE,OAAO,MAAM;AAAA,IACfA,eAAc,gBAAgB,EAAE,OAAO,QAAQ,MAAM,OAAO,CAAC;AAAA,IAC7D,MAAM;AAAA,EACR;AACF;AAEA,SAAS,eAAe,OAGf;AAGP,oBAAkB;AAAA,IAChB,GAAG,MAAM;AAAA,IACT,cAAc,OAAO,YAAY,MAAM,MAAM,YAAY;AAAA,IACzD,SAAS,OAAO,YAAY,MAAM,MAAM,OAAO;AAAA,EACjD,CAAC;AACD,SAAO;AACT;AAEA,SAAS,SAAS,MAA0B;AAC1C,QAAM,QAAQC,YAAW,YAAY;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,GAAG,IAAI,+CAA+C;AAAA,EACxE;AACA,SAAO;AACT;AAEO,SAAS,eACd,MACA,KACM;AACN,QAAM,QAAQ,SAAS,gBAAgB;AAGvC,MAAI,MAAM,QAAQ,IAAI,IAAI,EAAG,OAAM,QAAQ,IAAI,MAAM,GAAsC;AAC3F,EAAAC,WAAU,MAAM,MAAM,IAAI,UAAU,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC;AAC/D;AAEO,SAAS,oBACd,MACA,KACM;AACN,QAAM,QAAQ,SAAS,qBAAqB;AAC5C,MAAI,MAAM,aAAa,IAAI,IAAI,GAAG;AAChC,UAAM,aAAa,IAAI,MAAM,GAAsC;AAAA,EACrE;AACA,EAAAA,WAAU,MAAM,MAAM,IAAI,eAAe,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC;AACpE;","names":["useEffect","useState","useState","useEffect","createContext","createElement","useContext","useEffect","useState","createContext","useState","createElement","useContext","useEffect"]}
1
+ {"version":3,"sources":["../src/context.ts","../src/use-agent-component.ts","../src/render-scope.ts","../src/confirmations.ts","../src/granular.ts"],"sourcesContent":["import { createContext, createElement, useContext, type ReactNode } from \"react\";\nimport type { AgentSurfaceRegistry } from \"@agent-surface/core\";\n\nconst AgentSurfaceContext = createContext<AgentSurfaceRegistry | null>(null);\n\nexport interface AgentSurfaceProviderProps {\n registry: AgentSurfaceRegistry;\n children: ReactNode;\n}\n\n/**\n * The application creates the registry ONCE (module scope or top-level\n * useState initializer) and passes it down — registry creation is where\n * environment, policies, audit and route wiring live (docs/04).\n */\nexport function AgentSurfaceProvider(props: AgentSurfaceProviderProps): ReactNode {\n return createElement(AgentSurfaceContext.Provider, { value: props.registry }, props.children);\n}\n\n/** Access the registry from context. Throws if no provider is mounted. */\nexport function useAgentSurface(): AgentSurfaceRegistry {\n const registry = useContext(AgentSurfaceContext);\n if (!registry) {\n throw new Error(\n \"useAgentSurface: no <AgentSurfaceProvider> found above this component. Wrap your app in a provider with an explicitly created registry.\",\n );\n }\n return registry;\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport { COMPILED_CAPABILITY_PROVENANCE } from \"@agent-surface/core\";\nimport type {\n AgentActionContext,\n AgentActionDefinition,\n AgentComponentDefinition,\n AgentObservationDefinition,\n AgentReadContext,\n AgentRegistrationHandle,\n AgentComponentContract,\n AgentComponentRuntimeBindings,\n JsonValue,\n} from \"@agent-surface/core\";\nimport { useAgentSurface } from \"./context.js\";\nimport { setRenderScopeContext } from \"./render-scope.js\";\n\nexport interface UseAgentComponentConfig\n extends Omit<AgentComponentDefinition, \"procedures\"> {\n /**\n * Gate for \"mounted but not presented\" (inactive tab, keep-alive, exit\n * animation). false ⇒ all capabilities visible-disabled. Default true.\n */\n enabled?: boolean;\n}\n\nexport interface AgentComponentHandle {\n /** Current registrationId; changes on remount/re-register. */\n registrationId: string | undefined;\n status: \"active\" | \"rejected\" | \"unregistered\" | \"pending\";\n}\n\n/**\n * One aggregated hook per agent component (docs/04, the recommended default):\n * one registration, one atomic descriptor, one lifecycle.\n *\n * Registration happens once per mount, in an effect; handlers are read through\n * a ref at invocation time (D3) — no dependency arrays, no useCallback, no\n * stale closures. Structure is frozen per registration (D2): changing it on a\n * live registration logs an error and re-registers.\n */\nexport function useAgentComponent<\n TObservations extends Record<string, any>,\n TActions extends Record<string, any>,\n>(\n contract: AgentComponentContract<TObservations, TActions>,\n bindings: AgentComponentRuntimeBindings<TObservations, TActions>,\n): AgentComponentHandle;\n/** @deprecated Use a compiler-generated contract plus runtime bindings. */\nexport function useAgentComponent(config: UseAgentComponentConfig): AgentComponentHandle;\nexport function useAgentComponent<\n TObservations extends Record<string, any>,\n TActions extends Record<string, any>,\n>(\n contractOrConfig: AgentComponentContract<TObservations, TActions> | UseAgentComponentConfig,\n runtimeBindings?: AgentComponentRuntimeBindings<TObservations, TActions>,\n): AgentComponentHandle {\n const config: UseAgentComponentConfig =\n \"kind\" in contractOrConfig && contractOrConfig.kind === \"agent-component-contract\"\n ? contractOrConfig.bind(\n (runtimeBindings ?? {}) as AgentComponentRuntimeBindings<TObservations, TActions>,\n ) as UseAgentComponentConfig\n : contractOrConfig;\n const registry = useAgentSurface();\n const type = config.type;\n const instanceId = config.instanceId ?? \"default\";\n\n // D3 latest-ref: every render writes the fresh config; the registered\n // definition's handlers delegate through it at invocation time.\n const latest = useRef(config);\n latest.current = config;\n\n // Record the render-scope link for a following useAgentProcedure call.\n setRenderScopeContext({ type, instanceId });\n\n const [nonce, setNonce] = useState(0);\n const handleRef = useRef<AgentRegistrationHandle | null>(null);\n const fingerprintRef = useRef<string | null>(null);\n const lastPushedAvailability = useRef<Record<string, { available: boolean; reason?: string }>>({});\n const lastPushedEnabled = useRef<boolean | null>(null);\n const [state, setState] = useState<AgentComponentHandle>({\n registrationId: undefined,\n status: \"pending\",\n });\n\n useEffect(() => {\n const definition = buildDelegatingDefinition(latest);\n const handle = registry.register(definition);\n handleRef.current = handle;\n fingerprintRef.current = structuralFingerprint(latest.current);\n lastPushedAvailability.current = {};\n lastPushedEnabled.current = latest.current.enabled !== false;\n const registrationId = handle.status === \"active\" ? handle.registrationId : undefined;\n const status = handle.status === \"active\" ? \"active\" : \"rejected\";\n setState((prev) =>\n prev.registrationId === registrationId && prev.status === status\n ? prev\n : { registrationId, status },\n );\n if (handle.status === \"active\") {\n pushAvailability(handle, latest.current, lastPushedAvailability, lastPushedEnabled);\n }\n return () => {\n handle.unregister();\n handleRef.current = null;\n fingerprintRef.current = null;\n };\n // Identity keys: (registry, type, instanceId) + explicit re-register nonce.\n }, [registry, type, instanceId, nonce]);\n\n // Availability is reactive (docs/04): re-evaluated on every commit and\n // PUSHED on change, so the surface version bumps and adapters refresh.\n useEffect(() => {\n const handle = handleRef.current;\n if (!handle || handle.status !== \"active\") return;\n const fingerprint = structuralFingerprint(latest.current);\n if (fingerprintRef.current !== null && fingerprint !== fingerprintRef.current) {\n // Structural change on a live registration violates D2. Re-register so\n // the surface never lies about what this registrationId can do.\n // eslint-disable-next-line no-console\n console.error(\n `[agent-surface] structural config change detected on live registration \"${type}\" (${instanceId}). ` +\n \"Structure (names, schemas, descriptions, effects, policies) is frozen per registration (D2); \" +\n \"keep it static per mount and put dynamism in when/enabled/handlers. Re-registering with a new registrationId.\",\n );\n setNonce((n) => n + 1);\n return;\n }\n pushAvailability(handle, latest.current, lastPushedAvailability, lastPushedEnabled);\n });\n\n return state;\n}\n\n/* ────────────────────────────── internals ────────────────────────────── */\n\ntype LatestRef = { current: UseAgentComponentConfig };\n\nfunction buildDelegatingDefinition(latest: LatestRef): AgentComponentDefinition {\n const cfg = latest.current;\n const observations: Record<string, AgentObservationDefinition<any>> = {};\n for (const [name, obs] of Object.entries(cfg.observations ?? {})) {\n observations[name] = {\n description: obs.description,\n output: obs.output,\n read: (ctx: AgentReadContext) => {\n const live = latest.current.observations?.[name];\n if (!live) throw new Error(`observation \"${name}\" disappeared from the config`);\n return live.read(ctx);\n },\n ...(obs.when !== undefined\n ? { when: () => latest.current.observations?.[name]?.when?.() !== false }\n : {}),\n ...(obs.unavailableReason !== undefined\n ? {\n unavailableReason: () =>\n evaluateReason(latest.current.observations?.[name]?.unavailableReason),\n }\n : {}),\n ...(obs.policies ? { policies: obs.policies } : {}),\n ...(obs.meta ? { meta: obs.meta } : {}),\n ...(obs.timeoutMs !== undefined ? { timeoutMs: obs.timeoutMs } : {}),\n };\n }\n const actions: Record<string, AgentActionDefinition<any, any>> = {};\n for (const [name, act] of Object.entries(cfg.actions ?? {})) {\n actions[name] = {\n description: act.description,\n input: act.input,\n ...(act.output ? { output: act.output } : {}),\n effect: act.effect,\n ...(act.idempotent !== undefined ? { idempotent: act.idempotent } : {}),\n ...(act.reversible !== undefined ? { reversible: act.reversible } : {}),\n ...(act.confirmation !== undefined ? { confirmation: act.confirmation } : {}),\n ...(act.audit !== undefined ? { audit: act.audit } : {}),\n ...(act.when !== undefined\n ? { when: () => latest.current.actions?.[name]?.when?.() !== false }\n : {}),\n ...(act.unavailableReason !== undefined\n ? {\n unavailableReason: () =>\n evaluateReason(latest.current.actions?.[name]?.unavailableReason),\n }\n : {}),\n ...(act.precondition !== undefined\n ? {\n precondition: (input: JsonValue, ctx: AgentReadContext) =>\n latest.current.actions?.[name]?.precondition?.(input, ctx),\n }\n : {}),\n execute: (input: JsonValue, ctx: AgentActionContext) => {\n const live = latest.current.actions?.[name];\n if (!live) throw new Error(`action \"${name}\" disappeared from the config`);\n return live.execute(input, ctx);\n },\n ...(act.policies ? { policies: act.policies } : {}),\n ...(act.meta ? { meta: act.meta } : {}),\n ...(act.timeoutMs !== undefined ? { timeoutMs: act.timeoutMs } : {}),\n };\n }\n const definition: AgentComponentDefinition = {\n type: cfg.type,\n ...(cfg.instanceId !== undefined ? { instanceId: cfg.instanceId } : {}),\n description: cfg.description,\n ...(cfg.parent ? { parent: cfg.parent } : {}),\n ...(cfg.meta ? { meta: cfg.meta } : {}),\n ...(cfg.internal ? { internal: cfg.internal } : {}),\n ...(cfg.policies ? { policies: cfg.policies } : {}),\n ...(cfg.origin !== undefined ? { origin: cfg.origin } : {}),\n ...(cfg.priority !== undefined ? { priority: cfg.priority } : {}),\n ...(cfg.enabled !== undefined ? { enabled: cfg.enabled } : {}),\n ...(Object.keys(observations).length > 0 ? { observations } : {}),\n ...(Object.keys(actions).length > 0 ? { actions } : {}),\n };\n const provenance = (cfg as UseAgentComponentConfig & {\n [COMPILED_CAPABILITY_PROVENANCE]?: unknown;\n })[COMPILED_CAPABILITY_PROVENANCE];\n if (provenance) {\n Object.defineProperty(definition, COMPILED_CAPABILITY_PROVENANCE, {\n value: provenance,\n enumerable: false,\n });\n }\n return definition;\n}\n\nfunction evaluateReason(\n reason: string | (() => string) | undefined,\n): string {\n try {\n if (typeof reason === \"function\") return reason();\n if (typeof reason === \"string\") return reason;\n } catch {\n /* fall through */\n }\n return \"Currently unavailable\";\n}\n\n/** Structural fingerprint per D2 (handlers and when() results excluded). */\nfunction structuralFingerprint(cfg: UseAgentComponentConfig): string {\n const capability = (\n def:\n | AgentObservationDefinition<any>\n | AgentActionDefinition<any, any>,\n ): unknown => ({\n description: def.description,\n output: \"output\" in def && def.output ? def.output.jsonSchema : undefined,\n input: \"input\" in def ? def.input.jsonSchema : undefined,\n effect: \"effect\" in def ? def.effect : undefined,\n idempotent: \"idempotent\" in def ? def.idempotent : undefined,\n reversible: \"reversible\" in def ? def.reversible : undefined,\n confirmation: \"confirmation\" in def ? def.confirmation : undefined,\n audit: \"audit\" in def ? def.audit : undefined,\n timeoutMs: def.timeoutMs,\n hasWhen: def.when !== undefined,\n hasPrecondition: \"precondition\" in def && def.precondition !== undefined,\n policies: (def.policies ?? []).map((p) => p.name),\n });\n return JSON.stringify({\n type: cfg.type,\n instanceId: cfg.instanceId ?? \"default\",\n description: cfg.description,\n parent: cfg.parent,\n meta: cfg.meta,\n origin: cfg.origin,\n priority: cfg.priority,\n policies: (cfg.policies ?? []).map((p) => p.name),\n observations: Object.fromEntries(\n Object.entries(cfg.observations ?? {}).map(([name, def]) => [name, capability(def)]),\n ),\n actions: Object.fromEntries(\n Object.entries(cfg.actions ?? {}).map(([name, def]) => [name, capability(def)]),\n ),\n });\n}\n\nfunction pushAvailability(\n handle: AgentRegistrationHandle,\n cfg: UseAgentComponentConfig,\n lastPushed: { current: Record<string, { available: boolean; reason?: string }> },\n lastEnabled: { current: boolean | null },\n): void {\n const patch: {\n enabled?: boolean;\n availability?: Record<string, { available: boolean; reason?: string }>;\n } = {};\n\n const enabled = cfg.enabled !== false;\n if (lastEnabled.current !== enabled) {\n patch.enabled = enabled;\n lastEnabled.current = enabled;\n }\n\n const availability: Record<string, { available: boolean; reason?: string }> = {};\n const evaluate = (\n name: string,\n def: { when?: () => boolean; unavailableReason?: string | (() => string) },\n ): void => {\n if (!def.when) return; // no predicate ⇒ availability governed by enabled only\n let available = true;\n try {\n available = def.when() !== false;\n } catch {\n available = false;\n }\n const entry = available\n ? { available: true as const }\n : { available: false as const, reason: evaluateReason(def.unavailableReason) };\n const prev = lastPushed.current[name];\n if (!prev || prev.available !== entry.available || prev.reason !== entry.reason) {\n availability[name] = entry;\n lastPushed.current[name] = entry;\n }\n };\n for (const [name, def] of Object.entries(cfg.observations ?? {})) evaluate(name, def);\n for (const [name, def] of Object.entries(cfg.actions ?? {})) evaluate(name, def);\n\n if (Object.keys(availability).length > 0) patch.availability = availability;\n if (patch.enabled !== undefined || patch.availability) handle.update(patch);\n}\n","/**\n * Best-effort render-scope link between useAgentComponent and a following\n * useAgentProcedure in the SAME component function (docs/05): the component\n * hook records its identity during render; the procedure hook reads it.\n *\n * React exposes no public per-instance identity shared across independent\n * hook calls, so this is a heuristic: it is precise for the canonical\n * pattern (both hooks in one component) and clears itself at the end of the\n * synchronous render pass. A sibling component rendering later in the same\n * pass with only useAgentProcedure may pick up a stale link — cosmetic only\n * (the link is descriptor metadata, never authority).\n */\n\nexport interface RenderScopeContext {\n type: string;\n instanceId: string;\n}\n\ninterface Slot {\n context: RenderScopeContext;\n token: object;\n}\n\nlet current: Slot | null = null;\n\nexport function setRenderScopeContext(context: RenderScopeContext): void {\n const token = {};\n current = { context, token };\n queueMicrotask(() => {\n if (current?.token === token) current = null;\n });\n}\n\nexport function readRenderScopeContext(): RenderScopeContext | undefined {\n return current?.context;\n}\n","import { useEffect, useState } from \"react\";\nimport type { PendingConfirmation } from \"@agent-surface/core\";\nimport { useAgentSurface } from \"./context.js\";\n\nexport interface PendingConfirmationView extends PendingConfirmation {\n approve(): void;\n deny(reason?: string): void;\n}\n\n/**\n * Reactive list of pending confirmations for host-rendered dialogs. The\n * dialog is representation, not policy: approving calls\n * registry.confirmations.resolve, which mints the single-use evidence\n * (docs/04, docs/06).\n */\nexport function usePendingConfirmations(): PendingConfirmationView[] {\n const registry = useAgentSurface();\n const [pending, setPending] = useState<PendingConfirmation[]>(() =>\n registry.confirmations.pending(),\n );\n\n useEffect(() => {\n setPending(registry.confirmations.pending());\n return registry.confirmations.subscribe((next) => {\n setPending(next);\n });\n }, [registry]);\n\n return pending.map((record) => ({\n ...record,\n approve: () => registry.confirmations.resolve(record.confirmationId, { approved: true }),\n deny: (reason?: string) =>\n registry.confirmations.resolve(record.confirmationId, {\n approved: false,\n ...(reason !== undefined ? { reason } : {}),\n }),\n }));\n}\n","import {\n createContext,\n createElement,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport type {\n AgentActionDefinition,\n AgentObservationDefinition,\n JsonValue,\n} from \"@agent-surface/core\";\nimport { useAgentComponent, type UseAgentComponentConfig } from \"./use-agent-component.js\";\n\n/**\n * Granular composition — Experimental (docs/04): capabilities contributed\n * from separate files/subcomponents. Late-added capabilities are structural\n * changes, so each attach/detach re-registers the scope (new registrationId).\n * The aggregated useAgentComponent hook remains the recommended default.\n */\n\ninterface ScopeStore {\n observations: Map<string, AgentObservationDefinition<any>>;\n actions: Map<string, AgentActionDefinition<any, any>>;\n bump(): void;\n add(kind: \"observation\" | \"action\", name: string, def: unknown): () => void;\n}\n\nconst ScopeContext = createContext<ScopeStore | null>(null);\n\nexport interface AgentComponentScopeProps {\n config: Omit<UseAgentComponentConfig, \"observations\" | \"actions\">;\n children: ReactNode;\n}\n\n/** Establishes a component scope; children attach capabilities to it. */\nexport function AgentComponentScope(props: AgentComponentScopeProps): ReactNode {\n const [, setVersion] = useState(0);\n const store = useMemo<ScopeStore>(() => {\n const observations = new Map<string, AgentObservationDefinition<any>>();\n const actions = new Map<string, AgentActionDefinition<any, any>>();\n const bump = (): void => setVersion((v) => v + 1);\n return {\n observations,\n actions,\n bump,\n add(kind, name, def) {\n const map = kind === \"observation\" ? observations : actions;\n map.set(name, def as never);\n bump();\n return () => {\n map.delete(name);\n bump();\n };\n },\n };\n }, []);\n\n return createElement(\n ScopeContext.Provider,\n { value: store },\n createElement(ScopeRegistrar, { store, config: props.config }),\n props.children,\n );\n}\n\nfunction ScopeRegistrar(props: {\n store: ScopeStore;\n config: Omit<UseAgentComponentConfig, \"observations\" | \"actions\">;\n}): null {\n // Child effects run before this parent effect, so attachments within one\n // commit are coalesced into a single (re-)registration.\n useAgentComponent({\n ...props.config,\n observations: Object.fromEntries(props.store.observations),\n actions: Object.fromEntries(props.store.actions),\n });\n return null;\n}\n\nfunction useScope(hook: string): ScopeStore {\n const store = useContext(ScopeContext);\n if (!store) {\n throw new Error(`${hook} must be used inside an <AgentComponentScope>`);\n }\n return store;\n}\n\nexport function useAgentAction<TIn extends JsonValue, TOut extends JsonValue | void = void>(\n name: string,\n def: AgentActionDefinition<TIn, TOut>,\n): void {\n const store = useScope(\"useAgentAction\");\n // Keep the stored definition fresh without re-registering (D3 handlers are\n // read through the aggregated hook's latest-ref at invocation time).\n if (store.actions.has(name)) store.actions.set(name, def as AgentActionDefinition<any, any>);\n useEffect(() => store.add(\"action\", name, def), [store, name]);\n}\n\nexport function useAgentObservation<TOut extends JsonValue>(\n name: string,\n def: AgentObservationDefinition<TOut>,\n): void {\n const store = useScope(\"useAgentObservation\");\n if (store.observations.has(name)) {\n store.observations.set(name, def as AgentObservationDefinition<any>);\n }\n useEffect(() => store.add(\"observation\",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I,UAAU,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC;AAC/D;AAEO,SAAS,oBACd,MACA,KACM;AACN,QAAM,QAAQ,SAAS,qBAAqB;AAC5C,MAAI,MAAM,aAAa,IAAI,IAAI,GAAG;AAChC,UAAM,aAAa,IAAI,MAAM,GAAsC;AAAA,EACrE;AACA,EAAAA,WAAU,MAAM,MAAM,IAAI,eAAe,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC;AACpE;","names":["useEffect","useState","useState","useEffect","createContext","createElement","useContext","useEffect","useState","createContext","useState","createElement","useContext","useEffect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-surface/react",
3
- "version": "0.13.0",
3
+ "version": "0.16.0",
4
4
  "description": "React bindings for agent-surface: lifecycle-correct registration hooks",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "dependencies": {
21
- "@agent-surface/core": "^0.13.0"
21
+ "@agent-surface/core": "^0.16.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=18.2"