{"version":3,"file":"aiws_ext.cjs","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":["AIWS_COMPONENT_FILE","AIWS_COMPOSITION_FILE","AIWS_MANIFEST_FILE","AIWS_BUILD_STATE_FILE","AIWS_TEMPLATE_FORMAT","AiwsSourceError","Error","constructor","diagnostics","super","filter","d","severity","map","file","message","join","this","name","encoder","TextEncoder","decoder","TextDecoder","joinPath","dir","replace","folderName","title","trim","slice","async","sha256Hex","bytes","digest","crypto","subtle","Array","from","Uint8Array","b","toString","padStart","aiwsContentDigest","files","pairs","push","sort","a","encode","JSON","stringify","sourcesKey","localeCompare","f","obj_id","etag","AIWS_MAX_INLINE_BYTES","base64","binary","i","length","String","fromCharCode","subarray","btoa","packBuildFiles","upload","byRef","total","reduce","n","uploaded","Map","set","out","obj","get","buildFiles","nfsp","inline","_a","startsWith","node_id","readFile","arrayBuffer","COMPONENT_KEYS","SCHEMA_KEYWORDS","NAME","DID","BINDING","IDENT","V2_HINT","V3_HINT","V4_HINT","V5_HINT","EVENT_PARAM_TYPES","ITEM_KINDS","ITEM_KEYS","ACTION_COMMANDS","INSPECTOR_KINDS","isRecord","v","isArray","isSourcePath","includes","split","every","seg","configProps","configSchema","props","properties","configPlaceholders","text","at","error","m","matchAll","inner","schemaProblems","path","k","x","Object","entries","s","checkDeclarative","context","code","warn","o","parsed","parse","e","bindings","strings","forEach","items","list","it","iat","kind","keys","format","bind","prefix","indexOf","manifestVersion","label","emit","events","params","button","r","command","id","key","view","checkComposition","placeholders","t","dimension","max","test","before4","layout","algorithm","Number","isInteger","side","columns","slots","raw","slot","vis","some","for_ms","min","chrome","tk","tv","h","projection","projections","role","event","cells","accepts","ident","cellEvents","call","names","src","source","binding","field","nodes","template","lay","item","placement","media","anchor","checkComponent","fileNames","readText","c","mv","manifest_version","version","actions","run","before3","self","author_did","composite","config_schema","p","many","schema_id","on_bind","on_init_control","ev","host_api","actionIds","checkBindSteps","deps","seen","Set","has","add","spec","pat","type","eventProblems","named","entry","html","entryText","assets","agent","compatManifest","value","purpose","controls","workspace_templates","TEMPLATE_ID","templateDir","aiwsTemplateDigest","own","templateProblems","snapshot","description","requires","reset","tables","size","child","folder","glob","ref","limit","name_glob","find","ensureFolder","parts","Boolean","stat","hit","target","mkdir","findFolder","hasControlSource","writeHomeFile","uploadFile","overwrite","sleep","ms","Promise","setTimeout","collectSources","problems","walk","depth","cursor","page","objId","attrs","_b","_c","truncated","next_cursor","writeSourceFile","cut","lastIndexOf","sourcesDigest","readBuildState","nodeId","response","json","writeBuildState","state","client","workspaceId","opts","base","workspace_id","def_rev","dir_rev","result","extBuild","folderId","folder_id","expect","force","dryRun","dry_run","migration","def_entity_id","Date","toISOString","fixed","composition","padding","direction","spacing","background","radius","empty","component","authorDid","default_size","w","default","gap","minimum","maximum","catalog","group","allow_no_source","data","clicked","count","css","js","existing","catch","entityIds","fetchAsset","extExport","manifest","owner","workspaceTitle","pkg","defEntityId","outDir","control","entity_id","values","home","built","changed","decode","templates","declared","comp","dirs","idents","onChange","timer","last","running","resolve","check","then","signal","aborted","listing","stream","watch","tokens","watch_token","_","clearTimeout","debounceMs","close"],"mappings":"kMAqBO,MAAMA,EAAsB,iBAEtBC,EAAwB,mBACxBC,EAAqB,qBAErBC,EAAwB,mBAcxBC,EAAuB,kBA6B7B,MAAMC,UAAwBC,MAEnC,WAAAC,CAAYC,GACJC,MAAAD,EAAYE,QAAQC,GAAqB,UAAfA,EAAEC,WAAsBC,KAAKF,GAAM,GAAGA,EAAEG,KAAO,GAAGH,EAAEG,SAAW,KAAKH,EAAEI,YAAWC,KAAK,OAAS,0BAC/HC,KAAKC,KAAO,kBACZD,KAAKT,YAAcA,CACrB,EAGF,MAAMW,EAAU,IAAIC,YACdC,EAAU,IAAIC,YAEJ,SAAAC,EAASC,EAAaN,GACpC,MAAO,GAAGM,EAAIC,QAAQ,OAAQ,OAAOP,GACvC,CAGO,SAASQ,EAAWC,GAEzB,OADgBA,EAAMF,QAAQ,sBAAuB,KAAKA,QAAQ,OAAQ,IAAIG,OAC/DC,MAAM,EAAG,KAAO,WACjC,CAmBAC,eAAeC,EAAUC,GACvB,MAAMC,QAAeC,OAAOC,OAAOF,OAAO,UAAWD,GACrD,OAAOI,MAAMC,KAAK,IAAIC,WAAWL,IAAUM,GAAMA,EAAEC,SAAS,IAAIC,SAAS,EAAG,O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