{"version":3,"file":"aiws_ext.mjs","sources":["../src/aiws_ext.ts"],"sourcesContent":["/**\n * AI Workspace extension controls (buckyos src/frame/aiworkspace/README.md “Extension controls”), shared by the\n * Desktop and the CLI: a control's source lives in a home folder of the Zone file service (files may sit in\n * sub-folders: their names are relative paths, Q23); `build` lists it over NFSP and hands each file's object to\n * `ext.build`, `pull` writes a Workspace snapshot back, `watch` rebuilds on change; bundles (the AIWS manifest plus\n * `controls/<dir>/<path>` and Workspace templates under `templates/<id>/`) are what exports, packages and the library\n * carry.\n * Runs in browsers and Deno (fetch, crypto.subtle); no dependencies.\n */\nimport type { AiWorkspaceClient, AiwsMigration, AiwsTemplateItem } from './aiworkspace_client'\nimport type { NfspClient, WireRef } from './nfsp'\nimport { checkBindSteps, type BindingDecl } from './aiws_bind'\n\n/** The two service calls these drivers make (an `AiWorkspaceClient`, or a host's own session with the same shape). */\nexport type AiwsExtRpc = Pick<AiWorkspaceClient, 'extBuild' | 'extExport'>\n\n/** Puts bytes into the Zone's named store as a FileObject the caller may read and answers its `cyfile:` id (the\n * Desktop's asset upload, the CLI's NDM upload): what a build sends by reference when inline bytes would exceed the\n * service's limit (Q22). */\nexport type AiwsUploader = (name: string, bytes: Uint8Array) => Promise<string>\n\nexport const AIWS_COMPONENT_FILE = 'component.json'\n/** The entry of a composite control (P1). */\nexport const AIWS_COMPOSITION_FILE = 'composition.json'\nexport const AIWS_MANIFEST_FILE = 'aiws-manifest.json'\n/** A client's own record of the base it last built or pulled (never part of the source snapshot: dot files are not). */\nexport const AIWS_BUILD_STATE_FILE = '.aiws-build.json'\n/** The newest component.json / AIWS manifest version this module reads (older ones stay readable, Q19). Version 2\n * adds `kind: composite` and non-empty `deps`; version 3 `events`, the declarative `button`, composite `events` and\n * Workspace templates; version 4 `actions` and the composite projections; version 5 a composite's declared\n * `on_bind` / `on_init_control` (控件 on_bind TODO), and an HTML control's `\"script\"` for them. */\nexport const AIWS_MANIFEST_VERSION = 5\n/** The newest HTML Block host API (`window.aiws` v3: `emit`, `createBlock { parent, slot }`, `context.interactive`; v4:\n * `onConfig`, `serverNow`, `userState`, `mediaUrl`; v5: `aiws.on('bind')` / `aiws.on('init_control')` run without a page\n * before placing; v6: `aiws.query(sql, params?)` runs one SQL SELECT over the logical tables, answered as `doc.query\n * { sql }` (`{ columns, rows, truncated, read, head_seq }`) — 5 and older have no `aiws.query`; hosts run every version\n * from 2 on) and the declarative interpreter version. */\nexport const AIWS_HTML_API_VERSION = 6\nexport const AIWS_DECLARATIVE_API_VERSION = 1\n/** The `format` of a Workspace template's `snapshot.json` (Q32). */\nexport const AIWS_TEMPLATE_FORMAT = 'aiws-template/1'\nexport const AIWS_MAX_SOURCE_FILES = 64\n\n/**\n * One file of a source folder. `obj_id` is set when the file service holds it as a named-store FileObject (`cyfile:`):\n * the service then reads it by reference. Files of a native home folder have none (their `obj_id`, when the file\n * service reports one, is a `sha256:` content hash the service cannot fetch): their bytes travel with the build.\n */\nexport interface AiwsSourceFile { name: string; obj_id?: string; node_id?: string; etag?: string; size?: number }\nexport interface AiwsDiagnostic {\n  file: string\n  line?: number\n  col?: number\n  severity: 'error' | 'warning'\n  message: string\n  /** `DEP_MISSING`: a `deps` entry or a slot's `cell:<ident>` names no definition of the Workspace; `EVENT_UNDECLARED`:\n   * a composite re-raises an event no `cell:<ident>` of that slot declares, or a button emits an undeclared event. */\n  code?: string\n  /** Blocks whose contract a rebuild would break. */\n  instances?: { entity_id: string; title?: string | null }[]\n  /** Definitions that build on the one a rebuild would narrow. */\n  dependents?: { ident: string; def_entity_id: string }[]\n}\nexport interface AiwsBuildState { workspace_id: string; def_entity_id: string; def_rev: number; dir_rev: number; ident?: string; at?: string }\nexport interface AiwsManifestControl { ident: string; name: string; kind: string; version: number; digest: string; dir: string; title?: string; description?: string; catalog?: Record<string, unknown>; deps?: string[] }\nexport interface AiwsManifest { manifest_version: number; purpose: 'aiws'; host_api?: Record<string, number>; controls: AiwsManifestControl[]; workspace_templates: AiwsTemplateItem[] }\nexport interface AiwsBundle { manifest: AiwsManifest; files: Map<string, Uint8Array> }\n\n/** A source directory that cannot be built as it is (not a service refusal: `diagnostics` say why). */\nexport class AiwsSourceError extends Error {\n  readonly diagnostics: AiwsDiagnostic[]\n  constructor(diagnostics: AiwsDiagnostic[]) {\n    super(diagnostics.filter((d) => d.severity === 'error').map((d) => `${d.file ? `${d.file}: ` : ''}${d.message}`).join('; ') || 'invalid control source')\n    this.name = 'AiwsSourceError'\n    this.diagnostics = diagnostics\n  }\n}\n\nconst encoder = new TextEncoder()\nconst decoder = new TextDecoder()\n\nexport function joinPath(dir: string, name: string): string {\n  return `${dir.replace(/\\/+$/, '')}/${name}`\n}\n\n/** A Workspace title as one folder name (no `/`, no leading dot). */\nexport function folderName(title: string): string {\n  const cleaned = title.replace(/[/\\\\\\u0000-\\u001f]/g, ' ').replace(/^\\.+/, '').trim()\n  return cleaned.slice(0, 80) || 'Workspace'\n}\n\n/** The suggested home folder of a control (README: a suggestion; the definition never stores it). */\nexport function homeControlDir(owner: string, workspaceTitle: string, name: string): string {\n  return `/home/${owner}/AI Workspace/${folderName(workspaceTitle)}/controls/${name}`\n}\n\n/** Where a client writes an export bundle before packing it. */\nexport function homeExportDir(owner: string, pkg: string): string {\n  return `/home/${owner}/AI Workspace/exports/${pkg}`\n}\n\n/** `user_state` key under which each person remembers the home folder of a definition. */\nexport function sourceStateKey(defEntityId: string): string {\n  return `aiws:src:${defEntityId}`\n}\n\n// ---- digests (same canonical forms as the service: store/src/ext.rs)\n\nasync function sha256Hex(bytes: Uint8Array): Promise<string> {\n  const digest = await crypto.subtle.digest('SHA-256', bytes as unknown as ArrayBuffer)\n  return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** `sha256:` over `[[name, sha256 hex of its bytes], …]` sorted by name: a control's content digest. */\nexport async function aiwsContentDigest(files: Iterable<[string, Uint8Array]>): Promise<string> {\n  const pairs: [string, string][] = []\n  for (const [name, bytes] of files) pairs.push([name, await sha256Hex(bytes)])\n  pairs.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))\n  return `sha256:${await sha256Hex(encoder.encode(JSON.stringify(pairs)))}`\n}\n\n/** What a set of sources is, for \"nothing changed since the last build\" (names, objects or versions). */\nexport function sourcesKey(files: AiwsSourceFile[]): string {\n  return JSON.stringify([...files].sort((a, b) => a.name.localeCompare(b.name)).map((f) => [f.name, f.obj_id ?? f.etag ?? '']))\n}\n\n/** Bytes a single build may carry inline (the service's limit). */\nexport const AIWS_MAX_INLINE_BYTES = 4 * 1024 * 1024\n\nfunction base64(bytes: Uint8Array): string {\n  let binary = ''\n  for (let i = 0; i < bytes.length; i += 0x8000) binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000))\n  return btoa(binary)\n}\n\nexport type AiwsBuildFile = { name: string; obj_id: string } | { name: string; base64: string }\n\n/**\n * The `files` of `ext.build` from bytes the client holds: inline while the total stays within the service's limit;\n * beyond it, the largest files go to the named store through `upload` and are sent by reference (Q22) — without an\n * uploader the build is refused. `byRef` are files already held as FileObjects.\n */\nexport async function packBuildFiles(files: { name: string; bytes: Uint8Array }[], upload?: AiwsUploader, byRef: { name: string; obj_id: string }[] = []): Promise<AiwsBuildFile[]> {\n  let total = files.reduce((n, f) => n + f.bytes.length, 0)\n  const uploaded = new Map<string, string>()\n  if (total > AIWS_MAX_INLINE_BYTES) {\n    if (!upload) throw new AiwsSourceError([{ file: '', severity: 'error', message: `a control's inline files are limited to ${AIWS_MAX_INLINE_BYTES} bytes per build` }])\n    for (const f of [...files].sort((a, b) => b.bytes.length - a.bytes.length)) {\n      if (total <= AIWS_MAX_INLINE_BYTES) break\n      uploaded.set(f.name, await upload(f.name, f.bytes))\n      total -= f.bytes.length\n    }\n  }\n  const out: AiwsBuildFile[] = [...byRef]\n  for (const f of files) {\n    const obj = uploaded.get(f.name)\n    out.push(obj ? { name: f.name, obj_id: obj } : { name: f.name, base64: base64(f.bytes) })\n  }\n  return out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n}\n\n/** The `files` of `ext.build`: FileObjects by reference, everything else read over the file service and sent inline\n * (or, past the inline limit, uploaded through `upload`). */\nexport async function buildFiles(nfsp: NfspClient, files: AiwsSourceFile[], upload?: AiwsUploader): Promise<AiwsBuildFile[]> {\n  const byRef: { name: string; obj_id: string }[] = []\n  const inline: { name: string; bytes: Uint8Array }[] = []\n  for (const f of files) {\n    if (f.obj_id?.startsWith('cyfile:')) { byRef.push({ name: f.name, obj_id: f.obj_id }); continue }\n    if (!f.node_id) throw new AiwsSourceError([{ file: f.name, severity: 'error', message: 'the file service did not name this file' }])\n    inline.push({ name: f.name, bytes: new Uint8Array(await (await nfsp.readFile(f.node_id)).arrayBuffer()) })\n  }\n  return packBuildFiles(inline, upload, byRef)\n}\n\n// ---- component.json pre-check (the service's composer is authoritative; this catches the usual mistakes early)\n\nconst COMPONENT_KEYS = ['manifest_version', 'ident', 'kind', 'title', 'description', 'host_api', 'accepts', 'allow_no_source', 'default_size', 'config_schema', 'bindings', 'entry', 'assets', 'catalog', 'agent', 'deps', 'events', 'actions', 'on_bind', 'on_init_control']\nconst SCHEMA_KEYWORDS = ['type', 'enum', 'default', 'required', 'title', 'description', 'minimum', 'maximum', 'minLength', 'maxLength', 'properties', 'items']\nconst NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/\nconst DID = /^did:[a-z0-9]+:[^/#\\s]+$/\nconst BINDING = /^[a-z][a-z0-9_]{0,31}$/\nconst IDENT = /^did:[a-z0-9]+:[^/#\\s]+#[a-z0-9][a-z0-9._-]{0,63}$/\nconst V2_HINT = 'needs manifest_version 2 (raise it in component.json)'\nconst V3_HINT = 'needs manifest_version 3 (raise it in component.json)'\nconst V4_HINT = 'needs manifest_version 4 (raise it in component.json)'\nconst V5_HINT = 'needs manifest_version 5 (raise it in component.json)'\nconst EVENT_PARAM_TYPES = ['string', 'number', 'boolean', 'object', 'entity']\nconst ITEM_KINDS = ['text', 'value', 'metric', 'bar', 'list', 'badge']\nconst ITEM_KEYS = ['kind', 'text', 'label', 'bind', 'by', 'format', 'limit']\nconst ACTION_COMMANDS = ['open_source', 'activate_editor', 'open_definition']\nconst INSPECTOR_KINDS = ['text', 'number', 'select', 'boolean', 'color']\n\n/** What another control declares (the `events` names of its component.json), `undefined` when it is not at hand:\n * whether a composite's slot children raise an event can be judged only then (otherwise the build judges it). */\nexport type AiwsCellEvents = (ident: string) => string[] | undefined\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n  return !!v && typeof v === 'object' && !Array.isArray(v)\n}\n\n/** A file name of a source folder: a relative path whose parts are non-empty and do not start with `.` (Q23). */\nexport function isSourcePath(name: string): boolean {\n  return name.length > 0 && encoder.encode(name).length <= 255 && !name.includes('\\0') && name.split('/').every((seg) => seg.length > 0 && !seg.startsWith('.'))\n}\n\nfunction configProps(configSchema: unknown): Record<string, unknown> {\n  const props = isRecord(configSchema) ? configSchema.properties : undefined\n  return isRecord(props) ? props : {}\n}\n\n/** `{{config.<key>}}` placeholders of a string: each names a property of `config_schema`. */\nfunction configPlaceholders(text: string, at: string, props: Record<string, unknown>, error: (message: string) => void): void {\n  for (const m of text.matchAll(/\\{\\{([^}]*)\\}\\}/g)) {\n    const inner = m[1].trim()\n    if (!inner.startsWith('config.')) error(`${at}: only {{config.<key>}} may be used here`)\n    else if (!(inner.slice(7) in props)) error(`${at}: {{${inner}}} names no property of config_schema`)\n  }\n}\n\n/** A render control's `events` (Q26): ≤ 16 names `[a-z][a-z0-9_]{0,31}`, each `{ title?, description?, params? }` with\n * ≤ 16 params `{ type: string | number | boolean | object | entity, required?, description? }`. */\nfunction eventProblems(v: unknown, out: string[]): void {\n  if (!isRecord(v)) { out.push('events must be an object { <name>: { title?, description?, params? } }'); return }\n  if (Object.keys(v).length > 16) out.push('events: at most 16')\n  for (const [name, raw] of Object.entries(v)) {\n    const at = `events.${name}`\n    if (!BINDING.test(name)) out.push(`${at}: an event name is [a-z][a-z0-9_]{0,31}`)\n    if (!isRecord(raw)) { out.push(`${at} must be an object { title?, description?, params? }`); continue }\n    for (const [k, x] of Object.entries(raw)) {\n      if (k === 'title') { if (typeof x !== 'string' || x.length > 256) out.push(`${at}.title: at most 256 characters`) }\n      else if (k === 'description') { if (typeof x !== 'string' || x.length > 4000) out.push(`${at}.description: at most 4000 characters`) }\n      else if (k !== 'params') out.push(`${at}: unknown key ${k} (title, description, params)`)\n    }\n    if (raw.params === undefined) continue\n    if (!isRecord(raw.params)) { out.push(`${at}.params must be an object { <param>: { type, required?, description? } }`); continue }\n    if (Object.keys(raw.params).length > 16) out.push(`${at}.params: at most 16`)\n    for (const [p, spec] of Object.entries(raw.params)) {\n      const pat = `${at}.params.${p}`\n      if (!BINDING.test(p)) out.push(`${pat}: a param name is [a-z][a-z0-9_]{0,31}`)\n      if (!isRecord(spec)) { out.push(`${pat} must be an object { type, required?, description? }`); continue }\n      for (const [k, x] of Object.entries(spec)) {\n        if (k === 'type') { if (typeof x !== 'string' || !EVENT_PARAM_TYPES.includes(x)) out.push(`${pat}.type: ${EVENT_PARAM_TYPES.join(', ')}`) }\n        else if (k === 'required') { if (typeof x !== 'boolean') out.push(`${pat}.required must be a boolean`) }\n        else if (k === 'description') { if (typeof x !== 'string' || x.length > 1000) out.push(`${pat}.description: at most 1000 characters`) }\n        else out.push(`${pat}: unknown key ${k} (type, required, description)`)\n      }\n      if (spec.type === undefined) out.push(`${pat}.type required`)\n    }\n  }\n}\n\nfunction schemaProblems(v: unknown, path: string, out: string[]): void {\n  if (!v || typeof v !== 'object' || Array.isArray(v)) { out.push(`${path}: a schema is an object`); return }\n  for (const [k, x] of Object.entries(v as Record<string, unknown>)) {\n    if (!SCHEMA_KEYWORDS.includes(k)) { out.push(`${path}/${k}: keyword ${k} is outside the supported subset`); continue }\n    if (k === 'properties' && x && typeof x === 'object') for (const [n, s] of Object.entries(x as Record<string, unknown>)) schemaProblems(s, `${path}/properties/${n}`, out)\n    if (k === 'items') schemaProblems(x, `${path}/items`, out)\n  }\n}\n\n/**\n * Check a declarative control's entry file the way `ext.build` does (store/src/ext.rs `check_declarative`): what the\n * interpreter draws (`layout`, `items` / `view.items`, `accent`, `actions`, `inspector`) and, with manifest_version 3,\n * the item `{ kind: \"button\", label, emit, params? }` raising an event of `events` (`EVENT_UNDECLARED` otherwise;\n * strings in `params` may hold `{{config.<key>}}`). Without `events` the emitted names are not judged.\n */\nexport function checkDeclarative(text: string, context: { bindings?: unknown; events?: string[]; configSchema?: unknown; manifestVersion?: number } = {}, file = 'declarative.json'): AiwsDiagnostic[] {\n  const out: AiwsDiagnostic[] = []\n  const error = (message: string, code?: string) => out.push({ file, severity: 'error', message, ...(code ? { code } : {}) })\n  const warn = (message: string) => out.push({ file, severity: 'warning', message })\n  let o: Record<string, unknown>\n  try {\n    const parsed = JSON.parse(text) as unknown\n    if (!isRecord(parsed)) { error('a declarative definition is a JSON object'); return out }\n    o = parsed\n  } catch (e) {\n    error(e instanceof Error ? e.message : String(e))\n    return out\n  }\n  const bindings = isRecord(context.bindings) ? context.bindings : {}\n  const props = configProps(context.configSchema)\n  const strings = (v: unknown, at: string): void => {\n    if (typeof v === 'string') configPlaceholders(v, at, props, error)\n    else if (Array.isArray(v)) v.forEach((x, i) => strings(x, `${at}[${i}]`))\n    else if (isRecord(v)) for (const [k, x] of Object.entries(v)) strings(x, `${at}.${k}`)\n  }\n  const button = (it: Record<string, unknown>, at: string) => {\n    if (context.manifestVersion !== undefined && context.manifestVersion < 3) error(`${at}: a button ${V3_HINT}`)\n    for (const k of Object.keys(it)) if (!['kind', 'label', 'emit', 'params'].includes(k)) warn(`${at}: key ${k} is ignored by the interpreter`)\n    if (typeof it.label !== 'string' || !it.label) error(`${at}.label: the button's text (required)`)\n    if (typeof it.emit !== 'string' || !it.emit) error(`${at}.emit: the event the button raises (required)`)\n    else if (context.events && !context.events.includes(it.emit)) error(`${at}.emit ${it.emit}: not an event of component.json`, 'EVENT_UNDECLARED')\n    if (it.params !== undefined) { if (isRecord(it.params)) strings(it.params, `${at}.params`); else error(`${at}.params must be an object`) }\n  }\n  const items = (list: unknown, at: string) => {\n    if (list === undefined) return\n    if (!Array.isArray(list)) { error(`${at} must be an array`); return }\n    list.forEach((it, i) => {\n      const iat = `${at}[${i}]`\n      if (!isRecord(it)) { error(`${iat} must be an object`); return }\n      if (it.kind === 'button') { button(it, iat); return }\n      if (typeof it.kind !== 'string' || !ITEM_KINDS.includes(it.kind)) error(`${iat}.kind ${JSON.stringify(it.kind)}: one of ${[...ITEM_KINDS, 'button'].join(', ')}`)\n      for (const k of Object.keys(it)) if (!ITEM_KEYS.includes(k)) warn(`${iat}: key ${k} is ignored by the interpreter`)\n      if (it.format !== undefined && !['text', 'number', 'percent', 'currency'].includes(it.format as string)) error(`${iat}.format ${JSON.stringify(it.format)}: text, number, percent or currency`)\n      if (typeof it.bind === 'string' && it.bind.includes('.')) {\n        const prefix = it.bind.slice(0, it.bind.indexOf('.'))\n        if (prefix !== 'props' && !(prefix in bindings)) warn(`${iat}.bind ${JSON.stringify(it.bind)}: ${prefix} is not a declared binding, so it reads the field ${JSON.stringify(it.bind)} of the main source`)\n      }\n    })\n  }\n  for (const [k, v] of Object.entries(o)) {\n    if (k === 'layout') { if (v !== 'stack' && v !== 'row') error('layout: stack or row') }\n    else if (k === 'items') items(v, 'items')\n    else if (k === 'view') items(isRecord(v) ? v.items : undefined, 'view.items')\n    else if (k === 'accent') { if (typeof v !== 'string') error('accent must be a colour string') }\n    else if (k === 'actions') {\n      (Array.isArray(v) ? v : []).forEach((a: unknown, i) => {\n        const r = isRecord(a) ? a : {}\n        if (typeof r.command !== 'string' || !ACTION_COMMANDS.includes(r.command)) error(`actions[${i}].command: one of ${ACTION_COMMANDS.join(', ')}`)\n        if (typeof r.id !== 'string' || typeof r.label !== 'string') error(`actions[${i}] needs id and label`)\n      })\n    } else if (k === 'inspector') {\n      (Array.isArray(v) ? v : []).forEach((f: unknown, i) => {\n        const r = isRecord(f) ? f : {}\n        if (typeof r.kind !== 'string' || !INSPECTOR_KINDS.includes(r.kind)) error(`inspector[${i}].kind: one of ${INSPECTOR_KINDS.join(', ')}`)\n        if (typeof r.key !== 'string' || typeof r.label !== 'string') error(`inspector[${i}] needs key and label`)\n      })\n    } else warn(`key ${k} is not part of the declarative vocabulary`)\n  }\n  if (o.items === undefined && o.view === undefined) warn('no items: the control draws nothing')\n  return out\n}\n\n/** A composite's `composition.json` (K3): what the slots accept and their counts, the layout, the Chrome and the\n * events it re-raises from its children (P2). */\nexport interface AiwsComposition {\n  layout: { algorithm: 'stack' | 'fixed' | 'grid'; direction?: 'column' | 'row'; spacing?: number | string; padding?: number | string | { t?: number; r?: number; b?: number; l?: number }; columns?: number; gap?: number | string }\n  slots: Record<string, { accepts?: string[]; min?: number; max?: number; placement?: 'stack' | 'top' | 'bottom' | 'free'; title?: string }>\n  chrome?: { background?: string; radius?: number | string; border?: string; title?: { text: string; slot?: string }; empty?: string }\n  events?: Record<string, { from: { slot: string; event: string }; title?: string; description?: string }>\n}\n\n/**\n * Check a `composition.json` the way `ext.build` does (store/src/ext.rs `check_composition`): `layout` is `stack`,\n * `fixed` or `grid` (`columns` 1…12, `gap`; a grid fills its cells with the slots' children in slot order, so its slots\n * take placement `stack` only), at most 16 slots named `[a-z][a-z0-9_]{0,31}` accepting `cell:<ident>`, a view type or\n * `container`, the Chrome's strings, `{{config.<key>}}` naming properties of `config_schema`, and `events`\n * (manifest_version 3) re-raising an event of a slot's children: `EVENT_UNDECLARED` when no `cell:<ident>` of that slot\n * declares it, judged as far as `cellEvents` knows those controls.\n */\nexport function checkComposition(text: string, configSchema?: unknown, file = AIWS_COMPOSITION_FILE, context: { manifestVersion?: number; cellEvents?: AiwsCellEvents } = {}): AiwsDiagnostic[] {\n  const out: AiwsDiagnostic[] = []\n  const error = (message: string, code?: string) => out.push({ file, severity: 'error', message, ...(code ? { code } : {}) })\n  let o: Record<string, unknown>\n  try {\n    const parsed = JSON.parse(text) as unknown\n    if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) { error('a composition is a JSON object { layout, slots, chrome?, events? }'); return out }\n    o = parsed as Record<string, unknown>\n  } catch (e) {\n    error(e instanceof Error ? e.message : String(e))\n    return out\n  }\n  const props = configProps(configSchema)\n  const placeholders = (t: string, at: string) => configPlaceholders(t, at, props, error)\n  const dimension = (v: unknown, at: string, max: number) => {\n    if (typeof v === 'number' && v >= 0 && v <= max) return\n    if (typeof v === 'string' && /^\\s*\\{\\{.*\\}\\}\\s*$/.test(v)) { placeholders(v, at); return }\n    error(`${at}: a number in [0, ${max}] or {{config.<key>}}`)\n  }\n  const before4 = context.manifestVersion !== undefined && context.manifestVersion < 4\n  for (const k of Object.keys(o)) {\n    if (!['layout', 'slots', 'chrome', 'events', 'projections', 'media'].includes(k)) error(`unknown key ${k} (a composition says layout, slots, chrome, events, projections and media)`)\n    else if ((k === 'projections' || k === 'media') && before4) error(`${k} ${V4_HINT}`)\n  }\n  const layout = o.layout as Record<string, unknown> | undefined\n  let algorithm = 'stack'\n  if (!layout || typeof layout !== 'object') error('layout { algorithm: stack | fixed | grid } required')\n  else {\n    if (layout.algorithm === 'stack' || layout.algorithm === 'fixed' || layout.algorithm === 'grid') algorithm = layout.algorithm\n    else error(`layout.algorithm ${JSON.stringify(layout.algorithm)}: stack, fixed or grid (the algorithms the host ships)`)\n    for (const [k, v] of Object.entries(layout)) {\n      if (k === 'algorithm') continue\n      if ((k === 'direction' || k === 'spacing') && algorithm !== 'stack') { error(`layout.${k} belongs to the stack layout`); continue }\n      if ((k === 'columns' || k === 'gap') && algorithm !== 'grid') { error(`layout.${k} belongs to the grid layout`); continue }\n      if (k === 'direction') { if (v !== 'column' && v !== 'row') error('layout.direction: column or row') }\n      else if (k === 'spacing') dimension(v, 'layout.spacing', 2000)\n      else if (k === 'columns') { if (!Number.isInteger(v) || (v as number) < 1 || (v as number) > 12) error('layout.columns: an integer in [1, 12]') }\n      else if (k === 'gap') dimension(v, 'layout.gap', 2000)\n      else if (k === 'padding') {\n        if (v && typeof v === 'object' && !Array.isArray(v)) for (const [side, n] of Object.entries(v)) { if (!['t', 'r', 'b', 'l'].includes(side)) error(`layout.padding.${side}: t, r, b or l`); dimension(n, `layout.padding.${side}`, 2000) }\n        else dimension(v, 'layout.padding', 2000)\n      } else error(`layout: unknown key ${k}`)\n    }\n    if (algorithm === 'grid' && layout.columns === undefined) error('layout.columns (1…12) required: the cells of a grid row')\n  }\n  const slots = (o.slots && typeof o.slots === 'object' && !Array.isArray(o.slots) ? o.slots : null) as Record<string, unknown> | null\n  if (!slots) error('slots { <name>: { accepts?, min?, max?, placement? } } required')\n  else {\n    if (Object.keys(slots).length > 16) error('at most 16 slots')\n    for (const [name, raw] of Object.entries(slots)) {\n      const at = `slots.${name}`\n      if (!BINDING.test(name)) error(`${at}: a slot name is [a-z][a-z0-9_]{0,31}`)\n      if (!raw || typeof raw !== 'object' || Array.isArray(raw)) { error(`${at} must be an object`); continue }\n      const slot = raw as Record<string, unknown>\n      for (const [k, v] of Object.entries(slot)) {\n        if (k === 'accepts') {\n          if (!Array.isArray(v) || v.length === 0 || v.length > 32) { error(`${at}.accepts: 1…32 entries (cell:<ident>, a view type, container)`); continue }\n          for (const a of v) {\n            if (typeof a === 'string' && a.startsWith('cell:')) { if (!IDENT.test(a.slice(5)) || encoder.encode(a.slice(5)).length > 128) error(`${at}.accepts ${JSON.stringify(a)}: cell:<author_did>#<name>`) }\n            else if (a !== 'container' && !(typeof a === 'string' && NAME.test(a))) error(`${at}.accepts ${JSON.stringify(a)}: cell:<ident>, a view type or container`)\n          }\n        } else if (k === 'min') { if (!Number.isInteger(v) || (v as number) < 0 || (v as number) > 64) error(`${at}.min: an integer in [0, 64]`) }\n        else if (k === 'max') { if (!Number.isInteger(v) || (v as number) < 1 || (v as number) > 1000) error(`${at}.max: an integer in [1, 1000]`) }\n        else if (k === 'placement') {\n          if (v !== 'stack' && v !== 'top' && v !== 'bottom' && v !== 'free') error(`${at}.placement: stack, top, bottom or free`)\n          else if (algorithm === 'fixed' && v !== 'free') error(`${at}.placement: a fixed layout keeps every child where it is (free)`)\n          else if (algorithm === 'grid' && v !== 'stack') error(`${at}.placement: a grid fills its cells with the slots' children in slot order (stack)`)\n        } else if (k === 'title') { if (typeof v !== 'string' || v.length > 256) error(`${at}.title: at most 256 characters`) }\n        else if (k === 'visible') {\n          if (before4) { error(`${at}.visible ${V4_HINT}`); continue }\n          const vis = v as Record<string, unknown> | null\n          if (!isRecord(vis) || vis.from !== 'first_open' || Object.keys(vis).some((x) => x !== 'from' && x !== 'for_ms')) error(`${at}.visible: { from: \"first_open\", for_ms }`)\n          else if (typeof vis.for_ms === 'string') placeholders(vis.for_ms, `${at}.visible.for_ms`)\n          else if (!Number.isInteger(vis.for_ms) || (vis.for_ms as number) < 1 || (vis.for_ms as number) > 366 * 86_400_000) error(`${at}.visible.for_ms: milliseconds (≤ a year) or {{config.<key>}}`)\n        } else error(`${at}: unknown key ${k}`)\n      }\n      if (Number.isInteger(slot.min) && Number.isInteger(slot.max) && (slot.min as number) > (slot.max as number)) error(`${at}: min exceeds max`)\n    }\n  }\n  const chrome = o.chrome\n  if (chrome !== undefined) {\n    if (!chrome || typeof chrome !== 'object' || Array.isArray(chrome)) error('chrome must be an object')\n    else for (const [k, v] of Object.entries(chrome as Record<string, unknown>)) {\n      const at = `chrome.${k}`\n      if (k === 'background' || k === 'border') { if (typeof v === 'string' && v.length <= 64) placeholders(v, at); else error(`${at}: a colour (≤ 64 characters) or {{config.<key>}}`) }\n      else if (k === 'radius') dimension(v, at, 200)\n      else if (k === 'empty') { if (typeof v === 'string' && v.length <= 1000) placeholders(v, at); else error(`${at}: a text of at most 1000 characters`) }\n      else if (k === 'title') {\n        const t = v as Record<string, unknown> | null\n        if (!t || typeof t !== 'object' || Array.isArray(t)) { error(`${at}: { text, slot? }`); continue }\n        for (const [tk, tv] of Object.entries(t)) {\n          if (tk === 'text') { if (typeof tv === 'string' && tv.length <= 256) placeholders(tv, 'chrome.title.text'); else error('chrome.title.text: at most 256 characters') }\n          else if (tk === 'slot') { if (typeof tv !== 'string' || !slots || !(tv in slots)) error(`chrome.title.slot ${JSON.stringify(tv)}: a slot of this composition`) }\n          else error(`chrome.title: unknown key ${tk}`)\n        }\n        if (typeof t.text !== 'string') error('chrome.title.text required')\n      } else error(`chrome: unknown key ${k} (background, radius, border, title, empty)`)\n    }\n  }\n  if (o.events !== undefined) {\n    if (context.manifestVersion !== undefined && context.manifestVersion < 3) error(`events ${V3_HINT}`)\n    if (!isRecord(o.events)) error('events must be an object { <name>: { from: { slot, event }, title?, description? } }')\n    else {\n      if (Object.keys(o.events).length > 16) error('events: at most 16')\n      for (const [name, raw] of Object.entries(o.events)) {\n        const at = `events.${name}`\n        if (!BINDING.test(name)) error(`${at}: an event name is [a-z][a-z0-9_]{0,31}`)\n        if (!isRecord(raw)) { error(`${at} must be an object { from: { slot, event }, title?, description? }`); continue }\n        for (const [k, v] of Object.entries(raw)) {\n          if (k === 'title') { if (typeof v !== 'string' || v.length > 256) error(`${at}.title: at most 256 characters`) }\n          else if (k === 'description') { if (typeof v !== 'string' || v.length > 4000) error(`${at}.description: at most 4000 characters`) }\n          else if (k === 'on') {\n            // (manifest 4) what the event does when the instance binds no handler of its own\n            const list = Array.isArray(v) ? v : [v]\n            if (before4) error(`${at}.on ${V4_HINT}`)\n            else if (list.length === 0 || list.length > 4 || list.some((h) => !isRecord(h) || !['write', 'wish', 'open', 'notify'].includes(String(h.kind)))) error(`${at}.on: a handler (write, wish, open, notify) or 1…4 of them`)\n          }\n          else if (k !== 'from') error(`${at}: unknown key ${k} (from, title, description, on)`)\n        }\n        const from = raw.from\n        if (!isRecord(from)) { error(`${at}.from { slot, event } required: the child event it re-raises`); continue }\n        // (manifest 4) a press on a role of a projection's template raises it\n        if (from.projection !== undefined) {\n          if (before4) { error(`${at}.from.projection ${V4_HINT}`); continue }\n          const projections = isRecord(o.projections) ? o.projections : {}\n          if (typeof from.projection !== 'string' || !(from.projection in projections)) error(`${at}.from.projection ${JSON.stringify(from.projection)}: a projection of this composition`)\n          if (from.role !== undefined && !(typeof from.role === 'string' && BINDING.test(from.role))) error(`${at}.from.role: a role name of its template`)\n          for (const k of Object.keys(from)) if (k !== 'projection' && k !== 'role') error(`${at}.from: unknown key ${k} (projection, role)`)\n          continue\n        }\n        for (const k of Object.keys(from)) if (k !== 'slot' && k !== 'event') error(`${at}.from: unknown key ${k} (slot, event)`)\n        const event = typeof from.event === 'string' && BINDING.test(from.event) ? from.event : undefined\n        if (!event) error(`${at}.from.event: an event name [a-z][a-z0-9_]{0,31}`)\n        const slot = typeof from.slot === 'string' && slots ? slots[from.slot] : undefined\n        if (!isRecord(slot)) { error(`${at}.from.slot ${JSON.stringify(from.slot)}: a slot of this composition`); continue }\n        if (!event) continue\n        const cells = (Array.isArray(slot.accepts) ? slot.accepts : []).filter((a): a is string => typeof a === 'string' && a.startsWith('cell:')).map((a) => a.slice(5))\n        if (cells.length === 0) { error(`${at}: slot ${from.slot} accepts no cell:<ident>, so no control there declares ${event}`, 'EVENT_UNDECLARED'); continue }\n        const declared = cells.map((ident) => context.cellEvents?.(ident))\n        if (declared.every((names) => names !== undefined && !names.includes(event))) error(`${at}: no control slot ${from.slot} accepts (${cells.join(', ')}) declares the event ${event}`, 'EVENT_UNDECLARED')\n      }\n    }\n  }\n  if (o.projections !== undefined && !before4) {\n    if (!isRecord(o.projections) || Object.keys(o.projections).length > 8) error('projections: at most 8 of name → { source, template, layout }')\n    else for (const [name, raw] of Object.entries(o.projections)) {\n      const at = `projections.${name}`\n      if (!BINDING.test(name)) error(`${at}: a projection name is [a-z][a-z0-9_]{0,31}`)\n      if (!isRecord(raw)) { error(`${at} must be an object`); continue }\n      for (const k of Object.keys(raw)) if (!['source', 'mark', 'template', 'layout', 'placement', 'max_items'].includes(k)) error(`${at}: unknown key ${k} (source, mark, template, layout, placement, max_items)`)\n      const src = raw.source\n      const kind = isRecord(src) ? src.kind : undefined\n      if (!isRecord(src) || !['records', 'members', 'counts', 'viewer'].includes(String(kind)) || (kind !== 'viewer' && typeof src.binding !== 'string') || (kind === 'counts' && typeof src.field !== 'string')) {\n        error(`${at}.source: { kind: records | members | counts | viewer, binding (a binding name), field? (counts) }`)\n      }\n      const nodes = isRecord(raw.template) && Array.isArray(raw.template.nodes) ? raw.template.nodes : null\n      if (!nodes || nodes.length === 0 || nodes.length > 32) error(`${at}.template: { nodes: [1…32 of { id, view: label | shape | asset, box?, config?, when?, role? }] }`)\n      else nodes.forEach((n, i) => {\n        if (!isRecord(n) || typeof n.id !== 'string' || !BINDING.test(n.id)) error(`${at}.template.nodes[${i}].id: a name [a-z][a-z0-9_]{0,31}`)\n        else if (!['label', 'shape', 'asset'].includes(String(n.view))) error(`${at}.template.nodes[${i}].view: label, shape or asset`)\n      })\n      const lay = raw.layout\n      if (!isRecord(lay) || (lay.algorithm !== 'list' && lay.algorithm !== 'grid') || !isRecord(lay.item) || lay.item.h === undefined) error(`${at}.layout: { algorithm: list | grid, columns? (grid), gap?, item: { w?, h } }`)\n      else if (lay.algorithm === 'grid' && lay.columns === undefined) error(`${at}.layout.columns required (grid)`)\n      if (raw.placement !== undefined && !['top', 'stack', 'bottom'].includes(String(raw.placement))) error(`${at}.placement: top, stack or bottom`)\n    }\n  }\n  if (o.media !== undefined && !before4) {\n    const m = o.media\n    if (!isRecord(m) || typeof m.slot !== 'string' || !slots || !(m.slot in slots) || typeof m.anchor !== 'string' || (Object.keys(props).length > 0 && !(m.anchor in props))) {\n      error('media: { slot (a slot of this composition), anchor (a config property), loop? (a config property) }')\n    }\n  }\n  return out\n}\n\n/**\n * Check a `component.json` text against the files of its directory (and its declarative file or composition when\n * `readText` gives the entry's text; `cellEvents` says what other controls declare, for a composite's re-raised\n * events). Errors make a build fail; warnings do not.\n */\nexport function checkComponent(text: string, fileNames: string[], readText?: (name: string) => string | undefined, cellEvents?: AiwsCellEvents): AiwsDiagnostic[] {\n  const out: AiwsDiagnostic[] = []\n  const f = AIWS_COMPONENT_FILE\n  const error = (message: string) => out.push({ file: f, severity: 'error', message })\n  let c: Record<string, unknown>\n  try {\n    const parsed = JSON.parse(text) as unknown\n    if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) { error('must be a JSON object'); return out }\n    c = parsed as Record<string, unknown>\n  } catch (e) {\n    error(e instanceof Error ? e.message : String(e))\n    return out\n  }\n  for (const k of Object.keys(c)) if (!COMPONENT_KEYS.includes(k)) error(`unknown key ${k}`)\n  const mv = c.manifest_version\n  const version = typeof mv === 'number' && Number.isInteger(mv) && mv >= 1 ? mv : 0\n  // (manifest 4, H2) actions the host offers before the control runs\n  if (c.actions !== undefined) {\n    if (version > 0 && version < 4) error(`actions ${V4_HINT}`)\n    else if (!Array.isArray(c.actions) || c.actions.length > 16) error('actions: at most 16 of { id, title, icon?, modes?, needs?, run }')\n    else c.actions.forEach((a, i) => {\n      if (!isRecord(a) || typeof a.id !== 'string' || !BINDING.test(a.id) || typeof a.title !== 'string' || !a.title) error(`actions[${i}]: { id, title, run } (id a name [a-z][a-z0-9_]{0,31})`)\n      else {\n        const run = Array.isArray(a.run) ? a.run : [a.run]\n        if (run.length === 0 || run.length > 4 || run.some((h) => !isRecord(h) || !['write', 'wish', 'open', 'notify', 'config', 'forward'].includes(String(h.kind)))) error(`actions[${i}].run: a handler (write, wish, open, notify, config, forward) or 1…4 of them`)\n      }\n    })\n  }\n  if (!version) error(`manifest_version (1…${AIWS_MANIFEST_VERSION}) required`)\n  else if (version > AIWS_MANIFEST_VERSION) error(`manifest_version ${mv} is newer than this client reads (${AIWS_MANIFEST_VERSION})`)\n  const before3 = version > 0 && version < 3\n  const ident = c.ident as Record<string, unknown> | undefined\n  let self = ''\n  if (!ident || typeof ident !== 'object') error('ident { author_did, name } required')\n  else {\n    if (typeof ident.author_did !== 'string' || !DID.test(ident.author_did)) error('ident.author_did must be a DID (did:<method>:<id>)')\n    if (typeof ident.name !== 'string' || !NAME.test(ident.name)) error('ident.name must be [a-z0-9][a-z0-9._-]{0,63}')\n    if (typeof ident.author_did === 'string' && typeof ident.name === 'string') {\n      self = `${ident.author_did}#${ident.name}`\n      if (encoder.encode(self).length > 128) error('an identity is at most 128 bytes')\n    }\n  }\n  const composite = c.kind === 'composite'\n  if (c.kind !== 'declarative' && c.kind !== 'html' && !composite) error('kind must be declarative, html or composite')\n  if (composite && version === 1) error(`kind composite ${V2_HINT}`)\n  if (composite) for (const k of ['accepts', 'allow_no_source']) if (c[k] !== undefined) error(`${k}: a composite is a container of Blocks, not a Cell showing data`)\n  if (typeof c.title !== 'string' || !c.title || c.title.length > 256) error('title: 1…256 characters')\n  if (c.config_schema !== undefined) { const p: string[] = []; schemaProblems(c.config_schema, 'config_schema', p); p.forEach(error) }\n  if (c.bindings !== undefined) {\n    if (!c.bindings || typeof c.bindings !== 'object') error('bindings must be an object')\n    else for (const [n, d] of Object.entries(c.bindings as Record<string, unknown>)) {\n      if (!BINDING.test(n) || n === 'props') error(`binding name ${n}: [a-z][a-z0-9_]{0,31}, not props`)\n      if (!isRecord(d)) { error(`binding ${n} must be an object`); continue }\n      for (const k of Object.keys(d)) if (!['accepts', 'required', 'many', 'schema_id', 'title', 'description'].includes(k)) error(`binding ${n}: unknown key ${k}`)\n      if (d.many !== undefined && typeof d.many !== 'boolean') error(`binding ${n}.many: true or false`)\n      if (d.schema_id !== undefined && (typeof d.schema_id !== 'string' || !d.schema_id || d.schema_id.length > 128)) error(`binding ${n}.schema_id: a schema id such as buckyos.todo@1`)\n    }\n  }\n  // (manifest 5) what the composite binds when placed: its steps, against its bindings and actions\n  if (c.on_bind !== undefined || c.on_init_control !== undefined) {\n    if (version > 0 && version < 5) error(`on_bind / on_init_control ${V5_HINT}`)\n    else if (c.kind === 'html') {\n      // (host API 5) the control's behavior.js decides: aiws.on('bind') / aiws.on('init_control')\n      for (const [k, ev] of [['on_bind', 'bind'], ['on_init_control', 'init_control']] as const) {\n        if (c[k] !== undefined && c[k] !== 'script') error(`${k}: an HTML control writes \"script\" (its behavior.js handles aiws.on('${ev}'))`)\n      }\n      if (!(typeof c.host_api === 'number' && c.host_api >= 5)) error('on_bind / on_init_control \"script\": aiws.on(\\'bind\\') / aiws.on(\\'init_control\\') need host_api 5')\n    } else if (c.kind !== 'composite') error('on_bind / on_init_control: declared steps are for a composite, \"script\" for an HTML control')\n    else {\n      const actionIds = Array.isArray(c.actions) ? c.actions.filter(isRecord).map((a) => String(a.id)) : []\n      checkBindSteps(c.on_bind, c.on_init_control, isRecord(c.bindings) ? c.bindings as Record<string, BindingDecl> : {}, actionIds).forEach(error)\n    }\n  }\n  if (c.deps !== undefined) {\n    if (!Array.isArray(c.deps) || c.deps.length > 32) error('deps: at most 32 identities <author_did>#<name>')\n    else if (c.deps.length > 0 && version === 1) error(`deps ${V2_HINT}`)\n    else {\n      const seen = new Set<string>()\n      for (const d of c.deps) {\n        if (typeof d !== 'string' || !IDENT.test(d)) error(`deps: ${JSON.stringify(d)} is not an identity <author_did>#<name>`)\n        else if (d === self) error('deps: a control cannot depend on itself')\n        else if (seen.has(d)) error(`deps lists ${d} twice`)\n        seen.add(String(d))\n      }\n    }\n  }\n  let events: string[] = []\n  if (c.events !== undefined) {\n    if (composite) error('events: a composite declares its events in composition.json (events.<name>.from re-raises an event of a child)')\n    else if (before3) error(`events ${V3_HINT}`)\n    else { const p: string[] = []; eventProblems(c.events, p); p.forEach(error) }\n    if (!composite && isRecord(c.events)) events = Object.keys(c.events)\n  }\n  const has = (n: unknown) => typeof n === 'string' && fileNames.includes(n)\n  const named = new Set([f])\n  if (c.kind === 'html') {\n    const e = c.entry as Record<string, unknown> | undefined\n    if (!e || typeof e !== 'object' || typeof e.html !== 'string') error('entry must be { html, css?, js? }')\n    else for (const [k, n] of Object.entries(e)) { if (!has(n)) error(`entry.${k} ${JSON.stringify(n)} is not in the directory`); else named.add(String(n)) }\n    if (c.host_api !== undefined && ![2, 3, 4, 5, 6].includes(c.host_api as number)) error('host_api: the HTML Block host speaks API 2, 3, 4, 5 and 6')\n    else if ((c.host_api === 5 || c.host_api === 6) && version < 5) error(`host_api ${c.host_api} ${V5_HINT}`)\n    else if (c.host_api === 4 && version < 4) error(`host_api 4 ${V4_HINT}`)\n    else if (c.host_api === 3 && before3) error(`host_api 3 ${V3_HINT}`)\n    if (events.length > 0 && !(typeof c.host_api === 'number' && c.host_api >= 3)) out.push({ file: f, severity: 'warning', message: 'events: an HTML control raises them with aiws.emit, which is host API 3 (set host_api to 3 or later)' })\n  } else if (c.kind === 'declarative' || composite) {\n    if (!has(c.entry)) error(`entry ${JSON.stringify(c.entry)} is not in the directory`)\n    else {\n      named.add(String(c.entry))\n      const entryText = readText?.(String(c.entry))\n      const manifestVersion = version || undefined\n      if (entryText !== undefined && composite) out.push(...checkComposition(entryText, c.config_schema, String(c.entry), { manifestVersion, cellEvents }))\n      else if (entryText !== undefined) out.push(...checkDeclarative(entryText, { bindings: c.bindings, events, configSchema: c.config_schema, manifestVersion }, String(c.entry)))\n    }\n    if (composite && c.host_api !== undefined) error('host_api: a composite runs no code of its own (its layout and chrome are the host\\'s)')\n    if (!composite && c.host_api !== undefined && c.host_api !== AIWS_DECLARATIVE_API_VERSION) error(`host_api: the declarative interpreter is version ${AIWS_DECLARATIVE_API_VERSION}`)\n  }\n  for (const a of Array.isArray(c.assets) ? c.assets : []) { if (!has(a)) error(`asset ${JSON.stringify(a)} is not in the directory`); else named.add(String(a)) }\n  if (c.agent !== undefined) { if (!has(c.agent)) error(`agent ${JSON.stringify(c.agent)} is not in the directory`); else named.add(String(c.agent)) }\n  for (const n of fileNames) {\n    if (!isSourcePath(n)) out.push({ file: n, severity: 'error', message: 'a file of a source directory: a relative path whose parts do not start with \\'.\\'' })\n    else if (!named.has(n)) out.push({ file: n, severity: 'warning', message: 'not named by component.json: kept in the source snapshot only' })\n  }\n  return out\n}\n\n/** The identities a composition's slots accept as `cell:<ident>`. */\nexport function slotCells(composition: AiwsComposition): string[] {\n  const out = new Set<string>()\n  for (const slot of Object.values(composition.slots ?? {})) for (const a of slot.accepts ?? []) if (a.startsWith('cell:')) out.add(a.slice(5))\n  return [...out].sort()\n}\n\n// ---- bundles (exports, the `aiws` sub-package of a PIKG)\n\n/** Read an AIWS manifest of any supported version as the current one (Q19); a newer one is refused. */\nexport function compatManifest(value: unknown): AiwsManifest {\n  if (!value || typeof value !== 'object') throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'must be a JSON object' }])\n  const m = value as Record<string, unknown>\n  const version = m.manifest_version\n  if (typeof version !== 'number' || version < 1) throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'manifest_version required' }])\n  if (version > AIWS_MANIFEST_VERSION) throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: `manifest_version ${version} needs a newer client (this one reads ${AIWS_MANIFEST_VERSION})` }])\n  if (m.purpose !== 'aiws') throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'purpose must be aiws' }])\n  if (!Array.isArray(m.controls)) throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'controls must be an array' }])\n  return { manifest_version: version, purpose: 'aiws', host_api: (m.host_api as Record<string, number>) ?? {}, controls: m.controls as AiwsManifestControl[], workspace_templates: Array.isArray(m.workspace_templates) ? m.workspace_templates : [] }\n}\n\nconst TEMPLATE_ID = /^[a-z0-9][a-z0-9-]{0,63}$/\n\n/** Where a Workspace template's files sit in a bundle: `templates/<id>/` (`snapshot.json`, `objects/`, `chunks/`). */\nexport function templateDir(id: string): string {\n  return `templates/${id}/`\n}\n\n/** The content digest of a Workspace template (its manifest `digest`): the files under `templates/<id>/`, named\n * relative to that folder, digested as a control's. */\nexport async function aiwsTemplateDigest(files: Iterable<[string, Uint8Array]>, id: string): Promise<string> {\n  const dir = templateDir(id)\n  const own: [string, Uint8Array][] = []\n  for (const [path, bytes] of files) if (path.startsWith(dir)) own.push([path.slice(dir.length), bytes])\n  return aiwsContentDigest(own)\n}\n\n/** The shape of a `workspace_templates` item (schemas/template.schema.json); `controls` are the manifest's identities. */\nfunction templateProblems(t: unknown, controls: Set<string>): string[] {\n  if (!isRecord(t)) return ['a template is an object { id, title, snapshot, digest, requires, description?, params?, reset? }']\n  const out: string[] = []\n  for (const k of Object.keys(t)) if (!['id', 'title', 'description', 'snapshot', 'digest', 'requires', 'params', 'reset'].includes(k)) out.push(`unknown key ${k}`)\n  if (typeof t.id !== 'string' || !TEMPLATE_ID.test(t.id)) out.push('id: [a-z0-9][a-z0-9-]{0,63}')\n  else if (t.snapshot !== `${templateDir(t.id)}snapshot.json`) out.push(`snapshot must be ${templateDir(t.id)}snapshot.json`)\n  if (typeof t.title !== 'string' || !t.title || t.title.length > 256) out.push('title: 1…256 characters')\n  if (t.description !== undefined && (typeof t.description !== 'string' || t.description.length > 4000)) out.push('description: at most 4000 characters')\n  if (typeof t.digest !== 'string' || !/^sha256:[0-9a-f]{64}$/.test(t.digest)) out.push('digest: sha256:<64 hex digits>')\n  const requires = t.requires\n  if (!isRecord(requires)) out.push('requires { host_api?, controls } required')\n  else {\n    for (const k of Object.keys(requires)) if (k !== 'host_api' && k !== 'controls') out.push(`requires: unknown key ${k}`)\n    if (requires.host_api !== undefined) {\n      if (!isRecord(requires.host_api)) out.push('requires.host_api must be an object { html?, declarative? }')\n      else for (const [k, v] of Object.entries(requires.host_api)) if ((k !== 'html' && k !== 'declarative') || !Number.isInteger(v) || (v as number) < 1) out.push(`requires.host_api.${k}: html or declarative, a positive integer`)\n    }\n    if (!Array.isArray(requires.controls) || requires.controls.length > 256) out.push('requires.controls: at most 256 identities')\n    else {\n      const seen = new Set<unknown>()\n      for (const ident of requires.controls) {\n        if (typeof ident !== 'string' || !controls.has(ident)) out.push(`requires.controls: ${JSON.stringify(ident)} is not a control of this manifest`)\n        else if (seen.has(ident)) out.push(`requires.controls lists ${ident} twice`)\n        seen.add(ident)\n      }\n    }\n  }\n  if (t.params !== undefined) {\n    if (!isRecord(t.params) || Object.keys(t.params).length > 32) out.push('params: an object of at most 32 { type, title?, default? }')\n    else for (const [name, p] of Object.entries(t.params)) {\n      const at = `params.${name}`\n      if (!BINDING.test(name)) out.push(`${at}: a param name is [a-z][a-z0-9_]{0,31}`)\n      if (!isRecord(p)) { out.push(`${at} must be an object { type, title?, default? }`); continue }\n      for (const [k, v] of Object.entries(p)) {\n        if (k === 'type') { if (v !== 'string' && v !== 'number' && v !== 'boolean') out.push(`${at}.type: string, number or boolean`) }\n        else if (k === 'title') { if (typeof v !== 'string' || v.length > 256) out.push(`${at}.title: at most 256 characters`) }\n        else if (k === 'default') { if (!['string', 'number', 'boolean'].includes(typeof v)) out.push(`${at}.default: a string, number or boolean`) }\n        else out.push(`${at}: unknown key ${k} (type, title, default)`)\n      }\n      if (p.type === undefined) out.push(`${at}.type required`)\n    }\n  }\n  if (t.reset !== undefined) {\n    const tables = isRecord(t.reset) ? t.reset.tables : undefined\n    if (!isRecord(t.reset) || Object.keys(t.reset).some((k) => k !== 'tables')) out.push('reset: { tables }')\n    else if (tables !== undefined && (!Array.isArray(tables) || tables.length > 64 || new Set(tables).size !== tables.length || tables.some((x) => typeof x !== 'string' || !/^[a-z0-9][a-z0-9_-]{0,63}$/.test(x)))) out.push('reset.tables: at most 64 distinct table ids')\n  }\n  return out\n}\n\n/** Verify a bundle the way an installer does: manifest, each control's digest and component.json, each Workspace\n * template's shape, snapshot and digest, no stray files. */\nexport async function verifyBundle(files: Map<string, Uint8Array>): Promise<{ manifest: AiwsManifest; diagnostics: AiwsDiagnostic[] }> {\n  const raw = files.get(AIWS_MANIFEST_FILE)\n  if (!raw) throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'missing' }])\n  let parsed: unknown\n  try { parsed = JSON.parse(decoder.decode(raw)) } catch (e) { throw new AiwsSourceError([{ file: AIWS_MANIFEST_FILE, severity: 'error', message: String(e) }]) }\n  const manifest = compatManifest(parsed)\n  const diagnostics: AiwsDiagnostic[] = []\n  const templates = manifest.workspace_templates\n  if (templates.length > 0 && manifest.manifest_version < 3) diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: `Workspace templates need manifest_version 3 (raise it in ${AIWS_MANIFEST_FILE})` })\n  if (templates.length > 32) diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'at most 32 Workspace templates' })\n  if (manifest.controls.length === 0 && templates.length === 0) diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: 'lists no control' })\n  // what the bundle's controls declare: a composite's re-raised events are judged against them\n  const declared = new Map<string, string[]>()\n  for (const c of manifest.controls) {\n    const component = typeof c.dir === 'string' ? files.get(`${c.dir}${AIWS_COMPONENT_FILE}`) : undefined\n    try {\n      const comp = component ? JSON.parse(decoder.decode(component)) as unknown : undefined\n      if (isRecord(comp)) declared.set(c.ident, isRecord(comp.events) ? Object.keys(comp.events) : [])\n    } catch { /* reported below */ }\n  }\n  const dirs = new Set<string>()\n  for (const c of manifest.controls) {\n    if (typeof c.dir !== 'string' || !/^controls\\/[a-z0-9][a-z0-9._-]{0,70}\\/$/.test(c.dir) || dirs.has(c.dir)) { diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: `control ${c.ident}: bad or repeated dir` }); continue }\n    dirs.add(c.dir)\n    const own: [string, Uint8Array][] = [...files].filter(([p]) => p.startsWith(c.dir)).map(([p, b]) => [p.slice(c.dir.length), b])\n    if (await aiwsContentDigest(own) !== c.digest) diagnostics.push({ file: c.dir, severity: 'error', message: 'the files do not match the manifest digest' })\n    const component = own.find(([n]) => n === AIWS_COMPONENT_FILE)\n    if (!component) { diagnostics.push({ file: `${c.dir}${AIWS_COMPONENT_FILE}`, severity: 'error', message: 'missing' }); continue }\n    const text = (name: string) => { const hit = own.find(([n]) => n === name); return hit ? decoder.decode(hit[1]) : undefined }\n    for (const d of checkComponent(decoder.decode(component[1]), own.map(([n]) => n), text, (ident) => declared.get(ident))) diagnostics.push({ ...d, file: `${c.dir}${d.file}` })\n    try {\n      const comp = JSON.parse(decoder.decode(component[1])) as { ident?: { author_did?: string; name?: string }; kind?: string; deps?: string[] }\n      if (`${comp.ident?.author_did}#${comp.ident?.name}` !== c.ident || comp.kind !== c.kind) diagnostics.push({ file: c.dir, severity: 'error', message: 'ident and kind must match its component.json' })\n      if (JSON.stringify([...(comp.deps ?? [])].sort()) !== JSON.stringify([...(c.deps ?? [])].sort())) diagnostics.push({ file: c.dir, severity: 'error', message: 'deps must match its component.json' })\n    } catch { /* reported above */ }\n  }\n  // what a control builds on travels with it (P1): every dependency is another control of the bundle\n  const idents = new Set(manifest.controls.map((c) => c.ident))\n  for (const c of manifest.controls) for (const d of c.deps ?? []) if (!idents.has(d)) diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: `${c.ident} depends on ${d}, which the bundle does not carry` })\n  // a template is a snapshot under templates/<id>/ needing controls of the same manifest (Q32)\n  for (const [i, t] of templates.entries()) {\n    const label = isRecord(t) && typeof t.id === 'string' ? `template ${t.id}` : `workspace_templates[${i}]`\n    for (const p of templateProblems(t, idents)) diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: `${label}: ${p}` })\n    if (!isRecord(t) || typeof t.id !== 'string' || !TEMPLATE_ID.test(t.id)) continue\n    const dir = templateDir(t.id)\n    if (dirs.has(dir)) { diagnostics.push({ file: AIWS_MANIFEST_FILE, severity: 'error', message: `${label} is listed twice` }); continue }\n    dirs.add(dir)\n    const snapshot = files.get(`${dir}snapshot.json`)\n    let format: unknown\n    try { format = snapshot ? (JSON.parse(decoder.decode(snapshot)) as { format?: unknown }).format : undefined } catch { format = undefined }\n    if (!snapshot) diagnostics.push({ file: `${dir}snapshot.json`, severity: 'error', message: 'missing' })\n    else if (format !== AIWS_TEMPLATE_FORMAT) diagnostics.push({ file: `${dir}snapshot.json`, severity: 'error', message: `not a template snapshot (format ${AIWS_TEMPLATE_FORMAT})` })\n    if (await aiwsTemplateDigest(files, t.id) !== t.digest) diagnostics.push({ file: dir, severity: 'error', message: 'the files do not match the template digest' })\n  }\n  for (const p of files.keys()) if (p !== AIWS_MANIFEST_FILE && ![...dirs].some((d) => p.startsWith(d))) diagnostics.push({ file: p, severity: 'error', message: 'belongs to no control or template of the manifest' })\n  return { manifest, diagnostics }\n}\n\n/** The bundle of Workspace definitions (`ext.export`): the manifest plus every file's bytes. */\nexport async function exportBundle(client: AiwsExtRpc, workspaceId: string, entityIds: string[], fetchAsset: (workspaceId: string, objId: string) => Promise<Uint8Array>): Promise<AiwsBundle & { controls: Record<string, unknown>[] }> {\n  const r = await client.extExport(workspaceId, entityIds, 'package')\n  const files = new Map<string, Uint8Array>()\n  files.set(AIWS_MANIFEST_FILE, encoder.encode(`${JSON.stringify(r.manifest, null, 2)}\\n`))\n  for (const f of r.files) files.set(f.path, f.text !== undefined ? encoder.encode(f.text) : await fetchAsset(workspaceId, String(f.obj_id)))\n  return { manifest: compatManifest(r.manifest), files, controls: r.controls }\n}\n\n// ---- the home folder over NFSP\n\n/** The entry `name` of a folder, found with a filtered listing (no request fails for a missing name). */\nasync function child(nfsp: NfspClient, folder: WireRef | string, name: string) {\n  const glob = /[*?[\\]\\\\]/.test(name) ? undefined : name\n  const page = await nfsp.list(typeof folder === 'string' ? folder : { ref: folder }, { limit: glob ? 10 : 1000, ...(glob ? { filter: { name_glob: glob } } : {}) }, ['base', 'ident'])\n  return page.entries.find((e) => e.name === name)\n}\n\n/** Make sure a folder exists, creating each missing level below the realm root (`/home`); answers its ref. Levels\n * are looked up by listing their parent, so a missing one is not a failed request. */\nexport async function ensureFolder(nfsp: NfspClient, path: string): Promise<WireRef> {\n  const parts = path.split('/').filter(Boolean)\n  if (parts.length === 0) throw new Error(`not a folder path: ${path}`)\n  let ref = (await nfsp.stat(`/${parts[0]}`)).ref\n  for (const name of parts.slice(1)) {\n    const hit = await child(nfsp, ref, name)\n    if (hit && hit.target.kind !== 'dir') throw new AiwsSourceError([{ file: name, severity: 'error', message: `${name} in ${path} is not a folder` }])\n    ref = hit ? hit.target.ref : (await nfsp.mkdir({ ref }, name)).ref\n  }\n  return ref\n}\n\n/** A folder's ref, or null when it (or a level above it) does not exist — found without failed requests. */\nexport async function findFolder(nfsp: NfspClient, path: string): Promise<WireRef | null> {\n  const parts = path.split('/').filter(Boolean)\n  if (parts.length === 0) return null\n  let ref = (await nfsp.stat(`/${parts[0]}`)).ref\n  for (const name of parts.slice(1)) {\n    const hit = await child(nfsp, ref, name)\n    if (!hit || hit.target.kind !== 'dir') return null\n    ref = hit.target.ref\n  }\n  return ref\n}\n\n/** Whether a folder holds a control source (its component.json). */\nexport async function hasControlSource(nfsp: NfspClient, dir: string): Promise<boolean> {\n  const ref = await findFolder(nfsp, dir)\n  return ref !== null && (await child(nfsp, ref, AIWS_COMPONENT_FILE)) !== undefined\n}\n\n/** Write one file into a folder (replacing it). */\nexport async function writeHomeFile(nfsp: NfspClient, dir: string | WireRef, name: string, bytes: Uint8Array): Promise<void> {\n  const ref = typeof dir === 'string' ? await ensureFolder(nfsp, dir) : dir\n  await nfsp.uploadFile(ref, name, bytes, { overwrite: true })\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\n\n/** The files of a control's source folder, sub-folders included (names are relative paths, Q23); dot files and dot\n * folders are the client's own and skipped. */\nexport async function collectSources(nfsp: NfspClient, dir: string): Promise<AiwsSourceFile[]> {\n  const out: AiwsSourceFile[] = []\n  const problems: AiwsDiagnostic[] = []\n  const walk = async (folder: string | WireRef, prefix: string, depth: number): Promise<void> => {\n    let cursor: string | undefined\n    do {\n      const page = await nfsp.list(typeof folder === 'string' ? folder : { ref: folder }, { limit: 500, ...(cursor ? { cursor } : {}) }, ['base', 'ident'])\n      for (const e of page.entries) {\n        if (e.name.startsWith('.')) continue\n        const name = `${prefix}${e.name}`\n        if (e.target.kind === 'dir') {\n          if (depth >= 8) problems.push({ file: name, severity: 'error', message: 'sub-folders nest at most 8 levels' })\n          else await walk(e.target.ref, `${name}/`, depth + 1)\n          continue\n        }\n        if (e.target.kind !== 'file') { problems.push({ file: name, severity: 'error', message: 'only files and folders belong to a control source' }); continue }\n        const ref = e.target.ref\n        const objId = ref.type === 'object' ? ref.obj_id : typeof e.target.attrs?.obj_id === 'string' ? e.target.attrs.obj_id : undefined\n        out.push({\n          name,\n          ...(objId ? { obj_id: objId } : {}),\n          ...(ref.type === 'live' ? { node_id: ref.node_id } : {}),\n          ...(typeof e.target.attrs?.etag === 'string' ? { etag: e.target.attrs.etag } : {}),\n          ...(typeof e.target.attrs?.size === 'number' ? { size: e.target.attrs.size } : {}),\n        })\n      }\n      cursor = page.truncated ? page.next_cursor : undefined\n    } while (cursor)\n  }\n  await walk(dir, '', 0)\n  if (out.length === 0) problems.push({ file: '', severity: 'error', message: `${dir} holds no files` })\n  if (out.length > AIWS_MAX_SOURCE_FILES) problems.push({ file: '', severity: 'error', message: `a control holds at most ${AIWS_MAX_SOURCE_FILES} files` })\n  if (problems.some((p) => p.severity === 'error')) throw new AiwsSourceError(problems)\n  return out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))\n}\n\n/** Write a source file whose name may be a relative path (its sub-folders are created). */\nexport async function writeSourceFile(nfsp: NfspClient, dir: string, name: string, bytes: Uint8Array): Promise<void> {\n  const cut = name.lastIndexOf('/')\n  await writeHomeFile(nfsp, cut < 0 ? dir : joinPath(dir, name.slice(0, cut)), cut < 0 ? name : name.slice(cut + 1), bytes)\n}\n\n/** The content digest of a home folder's sources (what `ext.export` answers as a control's `digest`). */\nexport async function sourcesDigest(nfsp: NfspClient, files: AiwsSourceFile[]): Promise<string> {\n  const pairs: [string, Uint8Array][] = []\n  for (const f of files) {\n    if (!f.node_id) throw new AiwsSourceError([{ file: f.name, severity: 'error', message: 'the file service did not name this file' }])\n    pairs.push([f.name, new Uint8Array(await (await nfsp.readFile(f.node_id)).arrayBuffer())])\n  }\n  return aiwsContentDigest(pairs)\n}\n\n/**\n * Does the home folder of a definition hold changes that were not built (P0 遗留 L3)? Compares its sources with the\n * Workspace snapshot (`ext.export { purpose: pull }`). `null` when the folder holds no control.\n */\nexport async function unbuiltChanges(client: AiwsExtRpc, nfsp: NfspClient, workspaceId: string, defEntityId: string, dir: string): Promise<{ changed: boolean; home: string; built: string } | null> {\n  if (!(await hasControlSource(nfsp, dir))) return null\n  const home = await sourcesDigest(nfsp, await collectSources(nfsp, dir))\n  const r = await client.extExport(workspaceId, [defEntityId], 'pull')\n  const built = String((r.controls[0] as { digest?: string } | undefined)?.digest ?? '')\n  return { changed: home !== built, home, built }\n}\n\nexport async function readBuildState(nfsp: NfspClient, dir: string): Promise<AiwsBuildState | null> {\n  try {\n    const entry = await child(nfsp, dir, AIWS_BUILD_STATE_FILE)\n    const nodeId = entry?.target.ref.type === 'live' ? entry.target.ref.node_id : undefined\n    if (!nodeId) return null\n    const response = await nfsp.readFile(nodeId)\n    return (await response.json()) as AiwsBuildState\n  } catch {\n    return null\n  }\n}\n\nexport async function writeBuildState(nfsp: NfspClient, dir: string, state: AiwsBuildState): Promise<void> {\n  await writeHomeFile(nfsp, dir, AIWS_BUILD_STATE_FILE, encoder.encode(`${JSON.stringify(state, null, 2)}\\n`))\n}\n\nexport interface AiwsBuildOptions { folderId?: string; force?: boolean; dryRun?: boolean; upload?: AiwsUploader; migration?: Record<string, AiwsMigration> }\n\n/**\n * Build the control in `dir` into a Workspace: collect the files, call `ext.build` with the base recorded in\n * `.aiws-build.json` (when it is this Workspace's), and record the new base. Service refusals throw `AiwsFailure`\n * (`BUILD_FAILED` carries `data.diagnostics`); source problems throw `AiwsSourceError`.\n */\nexport async function buildControl(client: AiwsExtRpc, nfsp: NfspClient, workspaceId: string, dir: string, opts: AiwsBuildOptions = {}): Promise<Record<string, unknown> & { files: AiwsSourceFile[] }> {\n  const files = await collectSources(nfsp, dir)\n  const state = await readBuildState(nfsp, dir)\n  const base = state && state.workspace_id === workspaceId ? { def_rev: state.def_rev, dir_rev: state.dir_rev } : undefined\n  const result = await client.extBuild(workspaceId, {\n    files: await buildFiles(nfsp, files, opts.upload),\n    ...(opts.folderId ? { folder_id: opts.folderId } : {}),\n    ...(base ? { expect: base } : {}),\n    ...(opts.force ? { force: true } : {}),\n    ...(opts.dryRun ? { dry_run: true } : {}),\n    ...(opts.migration ? { migration: opts.migration } : {}),\n  })\n  if (!opts.dryRun && typeof result.def_entity_id === 'string' && typeof result.def_rev === 'number') {\n    await writeBuildState(nfsp, dir, { workspace_id: workspaceId, def_entity_id: result.def_entity_id, def_rev: result.def_rev, dir_rev: Number(result.dir_rev ?? 0), ident: String(result.ident ?? ''), at: new Date().toISOString() })\n  }\n  return { ...result, files }\n}\n\n/**\n * Write a definition's Workspace snapshot into `outDir` (a definition never built from source gets synthesized\n * files) and record it as the base of the next build.\n */\nexport async function pullControl(client: AiwsExtRpc, nfsp: NfspClient, workspaceId: string, defEntityId: string, outDir: string, fetchAsset: (workspaceId: string, objId: string) => Promise<Uint8Array>): Promise<{ files: string[]; state: AiwsBuildState }> {\n  const r = await client.extExport(workspaceId, [defEntityId], 'pull')\n  const control = r.controls[0] as { entity_id: string; ident: string; def_rev: number; dir_rev: number; files: { name: string; obj_id?: string; text?: string }[] }\n  await ensureFolder(nfsp, outDir)\n  for (const f of control.files) await writeSourceFile(nfsp, outDir, f.name, f.text !== undefined ? encoder.encode(f.text) : await fetchAsset(workspaceId, String(f.obj_id)))\n  const state: AiwsBuildState = { workspace_id: workspaceId, def_entity_id: control.entity_id, def_rev: control.def_rev, dir_rev: control.dir_rev, ident: control.ident, at: new Date().toISOString() }\n  await writeBuildState(nfsp, outDir, state)\n  return { files: control.files.map((f) => f.name), state }\n}\n\n/**\n * Rebuild whenever the folder changes: NFSP watch events (lossy: a `resync` lists again), debounced, and only when\n * the files' objects differ from the last build. Returns when `signal` aborts.\n */\nexport async function watchControl(nfsp: NfspClient, dir: string, onChange: (files: AiwsSourceFile[]) => Promise<void>, opts: { debounceMs?: number; signal?: AbortSignal } = {}): Promise<void> {\n  let last = ''\n  let timer: ReturnType<typeof setTimeout> | undefined\n  let running = Promise.resolve()\n  const check = () => {\n    running = running.then(async () => {\n      let files: AiwsSourceFile[]\n      try { files = await collectSources(nfsp, dir) } catch { return }\n      const key = sourcesKey(files)\n      if (key === last) return\n      last = key\n      await onChange(files)\n    }).catch(() => undefined)\n  }\n  check()\n  while (!opts.signal?.aborted) {\n    const listing = await nfsp.list(dir, { limit: 1 }, ['base'])\n    const stream = nfsp.watch({ tokens: listing.watch_token ? [listing.watch_token] : [], signal: opts.signal })\n    try {\n      for await (const _ of stream) {\n        if (timer) clearTimeout(timer)\n        timer = setTimeout(check, opts.debounceMs ?? 500)\n      }\n    } catch {\n      if (opts.signal?.aborted) break\n      await sleep(2_000)\n    } finally {\n      stream.close()\n    }\n  }\n  if (timer) clearTimeout(timer)\n  await running\n}\n\n// ---- skeletons\n\nexport interface AiwsSkeletonOptions {\n  authorDid: string\n  name: string\n  title?: string\n  kind?: 'declarative' | 'html' | 'composite'\n  /** A composite's slots (default: one `items` slot taking any Block) and what it builds on. */\n  slots?: AiwsComposition['slots']\n  deps?: string[]\n  algorithm?: 'stack' | 'fixed'\n}\n\n/** The files of a new control: a minimal working declarative or HTML control (with one public event, raised by a\n * button) with one optional binding, or a composite that stacks (or keeps in place) the Blocks of its slots under a\n * titled frame. */\nexport function controlSkeleton(opts: AiwsSkeletonOptions): Record<string, string> {\n  const title = opts.title ?? opts.name\n  if (opts.kind === 'composite') {\n    const fixed = opts.algorithm === 'fixed'\n    const slots = opts.slots ?? { items: { placement: fixed ? 'free' : 'stack', title: 'Items' } }\n    const composition: AiwsComposition = {\n      layout: fixed ? { algorithm: 'fixed', padding: 12 } : { algorithm: 'stack', direction: 'column', spacing: '{{config.gap}}', padding: 12 },\n      slots,\n      chrome: { background: '{{config.background}}', radius: 12, title: { text: '{{config.title}}' }, empty: 'Drop Blocks here' },\n    }\n    const component = {\n      manifest_version: AIWS_MANIFEST_VERSION,\n      ident: { author_did: opts.authorDid, name: opts.name },\n      kind: 'composite',\n      title,\n      description: `${title}: a panel of Blocks`,\n      default_size: { w: 320, h: 360 },\n      config_schema: { type: 'object', properties: {\n        title: { type: 'string', title: 'Title', default: title },\n        background: { type: 'string', title: 'Background', default: '#f6f7fb' },\n        gap: { type: 'integer', title: 'Gap (px)', default: 8, minimum: 0, maximum: 64 },\n      } },\n      entry: AIWS_COMPOSITION_FILE,\n      deps: opts.deps ?? [],\n      catalog: { group: 'custom', description: `${title}` },\n      agent: 'AGENT.md',\n    }\n    const names = Object.keys(slots).map((n) => `\\`${n}\\``).join(', ')\n    return {\n      [AIWS_COMPONENT_FILE]: `${JSON.stringify(component, null, 2)}\\n`,\n      [AIWS_COMPOSITION_FILE]: `${JSON.stringify(composition, null, 2)}\\n`,\n      'AGENT.md': `# ${title}\\n\\nA composite: an instance is a \\`buckyos.container { kind: \"composite\", def_ref }\\`; put Blocks under it with \\`slot\\` set to one of ${names}. Config: \\`title\\`, \\`background\\`, \\`gap\\`.\\n`,\n    }\n  }\n  const base = {\n    manifest_version: AIWS_MANIFEST_VERSION,\n    ident: { author_did: opts.authorDid, name: opts.name },\n    kind: opts.kind ?? 'declarative',\n    title,\n    description: `${title}: a control of this Workspace`,\n    accepts: ['buckyos.table-source', 'buckyos.record'],\n    allow_no_source: true,\n    default_size: { w: 260, h: 140 },\n    config_schema: { type: 'object', properties: { label: { type: 'string', title: 'Label', default: title } } },\n    bindings: { data: { accepts: ['buckyos.table-source'], title: 'Data', description: 'The table this control summarizes' } },\n    catalog: { group: 'custom', description: `${title}` },\n    agent: 'AGENT.md',\n  }\n  const agent = `# ${title}\\n\\nBind \\`data\\` to a table. Config: \\`label\\` (text).\\n`\n  if (opts.kind === 'html') {\n    const events = { clicked: { title: 'Clicked', description: 'Raised when someone clicks the button (in run mode)', params: { count: { type: 'number', description: 'Rows of the bound table' } } } }\n    return {\n      [AIWS_COMPONENT_FILE]: `${JSON.stringify({ ...base, host_api: AIWS_HTML_API_VERSION, events, entry: { html: 'view.html', css: 'style.css', js: 'behavior.js' } }, null, 2)}\\n`,\n      'view.html': '<div class=\"card\"><div class=\"label\" id=\"label\"></div><div class=\"value\" id=\"value\">—</div><button id=\"go\" type=\"button\">Go</button></div>\\n',\n      'style.css': '.card{font:14px system-ui;padding:12px}.label{opacity:.7}.value{font-size:28px;font-weight:600}\\n',\n      'behavior.js': [\n        \"document.getElementById('label').textContent = (aiws.context.config || {}).label || ''\",\n        'var count = 0',\n        \"if (aiws.bindings.data) aiws.input('data').rows().then(function (rows) { count = rows.length; document.getElementById('value').textContent = String(count) })\",\n        '// the public event of component.json: an instance binds handlers to it in its `on` (host API 3)',\n        \"document.getElementById('go').addEventListener('click', function () { aiws.emit('clicked', { count: count }) })\",\n        '',\n      ].join('\\n'),\n      'AGENT.md': `${agent}Event: \\`clicked\\` (\\`count\\`), raised by its button; bind handlers to it in the instance's \\`on\\`.\\n`,\n    }\n  }\n  return {\n    [AIWS_COMPONENT_FILE]: `${JSON.stringify({ ...base, entry: 'declarative.json' }, null, 2)}\\n`,\n    'declarative.json': `${JSON.stringify({ layout: 'stack', items: [{ kind: 'metric', label: title, bind: 'data.count', format: 'number' }, { kind: 'text', text: 'Rows of the bound table' }] }, null, 2)}\\n`,\n    'AGENT.md': agent,\n  }\n}\n\n/** Create a control's source folder from a skeleton (refuses to overwrite a folder that has a component.json). */\nexport async function createControlSource(nfsp: NfspClient, dir: string, files: Record<string, string>): Promise<WireRef> {\n  const ref = await ensureFolder(nfsp, dir)\n  const existing = await nfsp.list({ ref }, { limit: 500 }, ['base']).catch(() => null)\n  if (existing?.entries.some((e) => e.name === AIWS_COMPONENT_FILE)) throw new AiwsSourceError([{ file: AIWS_COMPONENT_FILE, severity: 'error', message: `${dir} already holds a control` }])\n  for (const [name, text] of Object.entries(files)) await writeHomeFile(nfsp, ref, name, encoder.encode(text))\n  return ref\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,sBAAsB;AAE5B,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB;AAE3B,MAAM,wBAAwB;AAK9B,MAAM,wBAAwB;AAM9B,MAAM,wBAAwB;AAC9B,MA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