buckyos 0.7.160 → 0.7.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,6 +221,11 @@ export function createPikgModule(dependencies: PikgModuleDependencies = {}): Com
221
221
  },
222
222
  { name: 'version', description: 'Initial App version', type: 'string' },
223
223
  { name: 'app-did', property: 'app_did', description: 'Explicit App DID', type: 'string' },
224
+ {
225
+ name: 'composite',
226
+ description: 'aiws-controls: start the package with a composite control (a panel of Blocks) instead of a declarative one',
227
+ type: 'boolean',
228
+ },
224
229
  ],
225
230
  inputSchema: {
226
231
  type: 'object',
@@ -232,6 +237,7 @@ export function createPikgModule(dependencies: PikgModuleDependencies = {}): Com
232
237
  source: { type: 'string', minLength: 1 },
233
238
  version: { type: 'string', minLength: 1 },
234
239
  app_did: { type: 'string', minLength: 1 },
240
+ composite: { type: 'boolean' },
235
241
  },
236
242
  additionalProperties: false,
237
243
  },
@@ -247,6 +253,7 @@ export function createPikgModule(dependencies: PikgModuleDependencies = {}): Com
247
253
  'buckyos --non-interactive pikg init . --owner did:bns:root --kind static-web --source ./web/dist',
248
254
  'buckyos --non-interactive pikg init . --owner did:bns:root --kind agent-skills --source ./skills',
249
255
  'buckyos --non-interactive pikg init . --owner did:bns:alice --kind aiws-controls --source ./aiws',
256
+ 'buckyos --non-interactive pikg init . --owner did:bns:alice --kind aiws-controls --source ./aiws --composite',
250
257
  ],
251
258
  handler: async (ctx, input) => await initCommand(ctx, input, docker),
252
259
  },
@@ -499,7 +506,7 @@ async function initCommand(
499
506
  } catch (error) {
500
507
  if (!isHostError(error, 'NotFound')) throw error
501
508
  if (kind === 'aiws-controls') {
502
- await writeAiwsSkeleton(absoluteSource, owner, name)
509
+ await writeAiwsSkeleton(absoluteSource, owner, name, input.composite === true)
503
510
  sourceSummary.skeleton = true
504
511
  } else {
505
512
  await ctx.io.stderr(`warning: source does not exist yet: ${sourceSummary.path}\n`)
@@ -565,9 +572,11 @@ async function initCommand(
565
572
  }
566
573
  }
567
574
 
568
- /** A control package skeleton: one declarative control under controls/<name>/ and its manifest (digest included). */
569
- async function writeAiwsSkeleton(dir: string, ownerDid: string, name: string): Promise<void> {
570
- const files = controlSkeleton({ authorDid: ownerDid, name, title: name })
575
+ /** A control package skeleton: one declarative control (or a composite one) under controls/<name>/ and its manifest
576
+ * (digest included). */
577
+ async function writeAiwsSkeleton(dir: string, ownerDid: string, name: string, composite: boolean): Promise<void> {
578
+ const kind = composite ? 'composite' : 'declarative'
579
+ const files = controlSkeleton({ authorDid: ownerDid, name, title: name, kind })
571
580
  const encoder = new TextEncoder()
572
581
  const host = getHost()
573
582
  await host.mkdir(join(dir, 'controls', name), { recursive: true })
@@ -576,8 +585,8 @@ async function writeAiwsSkeleton(dir: string, ownerDid: string, name: string): P
576
585
  const manifest = {
577
586
  manifest_version: AIWS_MANIFEST_VERSION,
578
587
  purpose: 'aiws',
579
- host_api: { declarative: 1 },
580
- controls: [{ ident: `${ownerDid}#${name}`, name, kind: 'declarative', version: 1, digest, dir: `controls/${name}/`, title: name }],
588
+ host_api: composite ? {} : { declarative: 1 },
589
+ controls: [{ ident: `${ownerDid}#${name}`, name, kind, version: 1, digest, dir: `controls/${name}/`, title: name }],
581
590
  workspace_templates: [],
582
591
  }
583
592
  await host.writeTextFile(join(dir, AIWS_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}\n`)
@@ -509,11 +509,13 @@ export function appDocObjectId(value: Record<string, unknown>): string {
509
509
  return ndn.buildNamedObjectByJson('appdoc', value)[0].toString()
510
510
  }
511
511
 
512
- /** The sub-package of an `aiws` package: the AIWS bundle (aiws-manifest.json plus controls/<dir>/<file>). */
512
+ /** The sub-package of an `aiws` package: the AIWS bundle (aiws-manifest.json plus controls/<dir>/<file> and, from
513
+ * manifest_version 3, Workspace templates under templates/<id>/). */
513
514
  export const AIWS_SUB_PACKAGE = 'aiws'
514
515
  const MAX_AIWS_PAYLOAD_BYTES = 256 * 1024 * 1024
515
516
 
516
- /** Check the bundle inside an `aiws` payload the way the AI Workspace library does (digests, component.json). */
517
+ /** Check the bundle inside an `aiws` payload the way the AI Workspace library does (digests, component.json, the
518
+ * templates' shape, snapshot, digest and required controls, no file outside a control, a template or the manifest). */
517
519
  export async function verifyAiwsPayload(tarGz: Uint8Array): Promise<Record<string, unknown>> {
518
520
  const files = new Map<string, Uint8Array>()
519
521
  for (const entry of await readTarGz(tarGz, MAX_AIWS_PAYLOAD_BYTES)) files.set(entry.path, entry.bytes)
@@ -527,7 +529,11 @@ export async function verifyAiwsPayload(tarGz: Uint8Array): Promise<Record<strin
527
529
  if (errors.length > 0) {
528
530
  throw invalid('aiws', `aiws bundle: ${errors.map((d: { file: string; message: string }) => `${d.file}: ${d.message}`).join('; ')}`)
529
531
  }
530
- return { manifest_version: checked.manifest.manifest_version, controls: checked.manifest.controls.map((c: Record<string, unknown>) => ({ ident: c.ident, kind: c.kind, version: c.version, digest: c.digest })) }
532
+ return {
533
+ manifest_version: checked.manifest.manifest_version,
534
+ controls: checked.manifest.controls.map((c: Record<string, unknown>) => ({ ident: c.ident, kind: c.kind, version: c.version, digest: c.digest })),
535
+ templates: checked.manifest.workspace_templates.map((t: Record<string, unknown>) => ({ id: t.id, title: t.title, digest: t.digest, requires: t.requires })),
536
+ }
531
537
  }
532
538
 
533
539
  export async function validateSnapshot(
package/cli/version.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Generated by scripts/generate-cli-version.mjs. Do not edit.
2
- export const PACKAGE_VERSION = '0.7.160'
2
+ export const PACKAGE_VERSION = '0.7.162'
3
3
  export const TOOL_VERSION = PACKAGE_VERSION
4
4
  export const SDK_VERSION = PACKAGE_VERSION
5
5
  export const PROTOCOL_VERSION = '1'
@@ -44,6 +44,30 @@ export interface AiwsReference {
44
44
  export declare function aiwsReferenceUrl(reference: AiwsReference, workspaceId?: string): string;
45
45
  /** The Reference an `obj://aiworkspace/<ws>/entities/<entity_id>[?...]` URL projects. */
46
46
  export declare function parseAiwsReferenceUrl(url: string): AiwsReference;
47
+ /** What `ext.upgrade` / `ext.build` rewrite on the instances of a definition whose new version narrows what they rely
48
+ * on (schemas/migration.schema.json, Q30). */
49
+ export interface AiwsMigration {
50
+ config?: {
51
+ rename?: Record<string, string>;
52
+ drop?: string[];
53
+ fill?: Record<string, unknown>;
54
+ };
55
+ bindings?: {
56
+ rename?: Record<string, string>;
57
+ drop?: string[];
58
+ fill?: Record<string, {
59
+ entity_id: string;
60
+ }>;
61
+ };
62
+ slots?: {
63
+ rename?: Record<string, string>;
64
+ move?: Record<string, string>;
65
+ };
66
+ events?: {
67
+ rename?: Record<string, string>;
68
+ drop?: string[];
69
+ };
70
+ }
47
71
  export interface AiwsExtBuildParams {
48
72
  files: ({
49
73
  name: string;
@@ -64,8 +88,82 @@ export interface AiwsExtBuildParams {
64
88
  version?: string;
65
89
  digest?: string;
66
90
  };
91
+ /** With `provenance`: rebuild an identity the folder holds from another source (an upgrade across Zones, Q30). */
92
+ upgrade?: boolean;
93
+ /** `{ <ident>: Migration }` for a build that narrows what instances rely on. */
94
+ migration?: Record<string, AiwsMigration>;
67
95
  idempotency_key?: string;
68
96
  }
97
+ export interface AiwsExtUpgradeParams {
98
+ workspace_id: string;
99
+ /** `pkg_id` default: the package the definition was imported from (`provenance.pkg_id`). */
100
+ items: {
101
+ def_entity_id: string;
102
+ pkg_id?: string;
103
+ }[];
104
+ migration?: Record<string, AiwsMigration>;
105
+ force?: boolean;
106
+ dry_run?: boolean;
107
+ idempotency_key?: string;
108
+ }
109
+ export interface AiwsExtUpgradeResult {
110
+ status: 'accepted' | 'unchanged' | 'checked';
111
+ commit_id?: string;
112
+ seq?: number;
113
+ controls: {
114
+ ident: string;
115
+ def_entity_id: string;
116
+ action: 'upgraded' | 'unchanged';
117
+ from?: string;
118
+ to?: string;
119
+ migrated?: string[];
120
+ }[];
121
+ /** `dry_run`: what the migration writes on each instance. */
122
+ plan?: {
123
+ instance: string;
124
+ ops: Record<string, unknown>[];
125
+ }[];
126
+ }
127
+ export interface AiwsTemplateParam {
128
+ type: 'string' | 'number' | 'boolean';
129
+ title?: string;
130
+ default?: string | number | boolean;
131
+ }
132
+ /** A Workspace template of a control package (aiws-manifest.json `workspace_templates`, schemas/template.schema.json,
133
+ * Q32): a snapshot under `templates/<id>/` and the controls of the same package it needs. */
134
+ export interface AiwsTemplateItem {
135
+ id: string;
136
+ title: string;
137
+ description?: string;
138
+ snapshot: string;
139
+ digest: string;
140
+ requires: {
141
+ host_api?: {
142
+ html?: number;
143
+ declarative?: number;
144
+ };
145
+ controls: string[];
146
+ };
147
+ params?: Record<string, AiwsTemplateParam>;
148
+ reset?: {
149
+ tables?: string[];
150
+ };
151
+ }
152
+ /** One template to export (`ext.export_template`, `ext.pack` / `ext.install` `templates`): chosen Surfaces (and data
153
+ * entities) of the Workspace. */
154
+ export interface AiwsTemplateExport {
155
+ surfaces: string[];
156
+ data?: string[];
157
+ template: {
158
+ id: string;
159
+ title: string;
160
+ description?: string;
161
+ params?: Record<string, AiwsTemplateParam>;
162
+ reset?: {
163
+ tables: string[];
164
+ };
165
+ };
166
+ }
69
167
  /** `ext.build` / `ext.import`: one entry per control (`created | rebuilt | unchanged | satisfied`), the first also at the top. */
70
168
  export interface AiwsExtBuildResult {
71
169
  status: 'accepted' | 'unchanged' | 'checked';
@@ -94,6 +192,8 @@ export interface AiwsLibraryPackage {
94
192
  author: string;
95
193
  mode: string;
96
194
  installed_at: string;
195
+ /** The package's manifest_version is above what the service reads: listed, not importable. */
196
+ needs_newer?: boolean;
97
197
  controls: {
98
198
  ident: string;
99
199
  name: string;
@@ -104,7 +204,35 @@ export interface AiwsLibraryPackage {
104
204
  title?: string;
105
205
  description?: string;
106
206
  catalog?: Record<string, unknown>;
207
+ deps?: string[];
107
208
  }[];
209
+ templates?: {
210
+ id: string;
211
+ title: string;
212
+ description?: string;
213
+ params?: Record<string, AiwsTemplateParam>;
214
+ requires: AiwsTemplateItem['requires'];
215
+ }[];
216
+ }
217
+ /** `ext.pack`: the `.pikg` the service wrote into the caller's `exports` bucket. */
218
+ export interface AiwsExtPackResult {
219
+ bucket_id: string;
220
+ key: string;
221
+ obj_id: string;
222
+ size: number;
223
+ digest: string;
224
+ app_doc_object_id: string;
225
+ app_did: string;
226
+ pkg_id: string;
227
+ version: string;
228
+ /** The bucket binding with a read token (as `doc.export`'s `download`). */
229
+ download: {
230
+ bucket_id: string;
231
+ key: string;
232
+ version: number;
233
+ obj_id: string;
234
+ token: string;
235
+ };
108
236
  }
109
237
  /** What an executor outside the service reports for a run (M3): results in the Mock executor's shape, or an analysis. */
110
238
  export interface AiwsRunReport {
@@ -188,14 +316,19 @@ export declare class AiWorkspaceClient {
188
316
  text?: string;
189
317
  }[];
190
318
  }>;
191
- /** Into the caller's library: a `.pikg` object, or definitions of a Workspace (`from` + `package`). */
319
+ /** Into the caller's library: a `.pikg` object or one bound into the caller's `exports` bucket (consumed), or
320
+ * definitions of a Workspace (`from` + `package`). */
192
321
  extInstall(params: {
193
322
  pikg?: {
194
323
  obj_id: string;
324
+ } | {
325
+ bucket_id: string;
326
+ key: string;
195
327
  };
196
328
  from?: {
197
329
  workspace_id: string;
198
330
  entity_ids: string[];
331
+ templates?: AiwsTemplateExport[];
199
332
  };
200
333
  package?: {
201
334
  name: string;
@@ -209,6 +342,37 @@ export declare class AiWorkspaceClient {
209
342
  action: string;
210
343
  controls: Record<string, unknown>[];
211
344
  }>;
345
+ /** Pack definitions (and what they build on, and templates of the Workspace) as an `aiws` `.pikg` into the caller's
346
+ * `exports` bucket (unsigned). */
347
+ extPack(workspace_id: string, entity_ids: string[], pkg: {
348
+ name: string;
349
+ version?: string;
350
+ title?: string;
351
+ }, templates?: AiwsTemplateExport[]): Promise<AiwsExtPackResult>;
352
+ /** Rebuild imported definitions from the caller's library (same Zone; across Zones `ext.build { provenance, upgrade }`):
353
+ * `EXT_LOCAL_CHANGES` when the snapshot was built locally since, unless `force`. */
354
+ extUpgrade(params: AiwsExtUpgradeParams): Promise<AiwsExtUpgradeResult>;
355
+ /** Chosen Surfaces as a template snapshot: the manifest item, the definitions it needs and the files (base64) of
356
+ * `templates/<id>/`. */
357
+ extExportTemplate(params: {
358
+ workspace_id: string;
359
+ } & AiwsTemplateExport): Promise<{
360
+ template: AiwsTemplateItem;
361
+ controls: Record<string, unknown>[];
362
+ files: {
363
+ path: string;
364
+ base64: string;
365
+ }[];
366
+ }>;
367
+ /** A new Workspace from a template of the caller's library (installing a template never creates one). */
368
+ extCreateFromTemplate(params: {
369
+ pkg_id: string;
370
+ template_id: string;
371
+ title?: string;
372
+ params?: Record<string, string | number | boolean>;
373
+ }): Promise<{
374
+ workspace_id: string;
375
+ }>;
212
376
  extListLibrary(): Promise<{
213
377
  packages: AiwsLibraryPackage[];
214
378
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"aiworkspace_client.d.ts","sourceRoot":"","sources":["../src/aiworkspace_client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,eAAO,MAAM,wBAAwB,gBAAgB,CAAA;AAErD,2HAA2H;AAC3H,MAAM,WAAW,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AAClH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAEhF,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA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AM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,EAAE,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO;IAK7G,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM;IAGxG,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAG9E,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAG9D,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBACzE,MAAM;iBAAW,MAAM;mBAAa,MAAM;qBAAe,MAAM;kBAAY,MAAM;;IAE9G,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAGtG,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IACrD,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAGvF,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAC/C"}
package/dist/aiws_ext.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="component.json",t="aiws-manifest.json",r=".aiws-build.json";class i extends Error{constructor(e){super(e.filter((e=>"error"===e.severity)).map((e=>`${e.file?`${e.file}: `:""}${e.message}`)).join("; ")||"invalid control source"),this.name="AiwsSourceError",this.diagnostics=e}}const n=new TextEncoder,s=new TextDecoder;function o(e){return e.replace(/[/\\\u0000-\u001f]/g," ").replace(/^\.+/,"").trim().slice(0,80)||"Workspace"}async function a(e){const t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t),(e=>e.toString(16).padStart(2,"0"))).join("")}async function c(e){const t=[];for(const[r,i]of e)t.push([r,await a(i)]);return t.sort(((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0)),`sha256:${await a(n.encode(JSON.stringify(t)))}`}function l(e){return JSON.stringify([...e].sort(((e,t)=>e.name.localeCompare(t.name))).map((e=>[e.name,e.obj_id??e.etag??""])))}const d=4194304;function f(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}async function u(e,t){var r;const n=[];let s=0;for(const o of t){if(null==(r=o.obj_id)?void 0:r.startsWith("cyfile:")){n.push({name:o.name,obj_id:o.obj_id});continue}if(!o.node_id)throw new i([{file:o.name,severity:"error",message:"the file service did not name this file"}]);const t=new Uint8Array(await(await e.readFile(o.node_id)).arrayBuffer());if(s+=t.length,s>d)throw new i([{file:o.name,severity:"error",message:"a control's files are limited to 4194304 bytes per build"}]);n.push({name:o.name,base64:f(t)})}return n}const p=["manifest_version","ident","kind","title","description","host_api","accepts","allow_no_source","default_size","config_schema","bindings","entry","assets","catalog","agent","deps"],m=["type","enum","default","required","title","description","minimum","maximum","minLength","maxLength","properties","items"],y=/^[a-z0-9][a-z0-9._-]{0,63}$/,g=/^did:[a-z0-9]+:[^/#\s]+$/,h=/^[a-z][a-z0-9_]{0,31}$/;function w(e,t,r){if(e&&"object"==typeof e&&!Array.isArray(e))for(const[i,n]of Object.entries(e))if(m.includes(i)){if("properties"===i&&n&&"object"==typeof n)for(const[e,i]of Object.entries(n))w(i,`${t}/properties/${e}`,r);"items"===i&&w(n,`${t}/items`,r)}else r.push(`${t}/${i}: keyword ${i} is outside the supported subset`);else r.push(`${t}: a schema is an object`)}function _(t,r){const i=[],s=e,o=e=>i.push({file:s,severity:"error",message:e});let a;try{const e=JSON.parse(t);if(!e||"object"!=typeof e||Array.isArray(e))return o("must be a JSON object"),i;a=e}catch(u){return o(u instanceof Error?u.message:String(u)),i}for(const e of Object.keys(a))p.includes(e)||o(`unknown key ${e}`);const c=a.manifest_version;"number"!=typeof c||!Number.isInteger(c)||c<1?o("manifest_version (1) required"):c>1&&o(`manifest_version ${c} is newer than this client reads (1)`);const l=a.ident;if(l&&"object"==typeof l?("string"==typeof l.author_did&&g.test(l.author_did)||o("ident.author_did must be a DID (did:<method>:<id>)"),"string"==typeof l.name&&y.test(l.name)||o("ident.name must be [a-z0-9][a-z0-9._-]{0,63}"),"string"==typeof l.author_did&&"string"==typeof l.name&&n.encode(`${l.author_did}#${l.name}`).length>128&&o("an identity is at most 128 bytes")):o("ident { author_did, name } required"),"declarative"!==a.kind&&"html"!==a.kind&&o("kind must be declarative or html"),("string"!=typeof a.title||!a.title||a.title.length>256)&&o("title: 1…256 characters"),void 0!==a.config_schema){const e=[];w(a.config_schema,"config_schema",e),e.forEach(o)}if(void 0!==a.bindings)if(a.bindings&&"object"==typeof a.bindings)for(const e of Object.keys(a.bindings))h.test(e)&&"props"!==e||o(`binding name ${e}: [a-z][a-z0-9_]{0,31}, not props`);else o("bindings must be an object");Array.isArray(a.deps)&&a.deps.length>0&&o("deps must be empty: dependencies between controls come in a later version");const d=e=>"string"==typeof e&&r.includes(e),f=new Set([s]);if("html"===a.kind){const e=a.entry;if(e&&"object"==typeof e&&"string"==typeof e.html)for(const[t,r]of Object.entries(e))d(r)?f.add(String(r)):o(`entry.${t} ${JSON.stringify(r)} is not in the directory`);else o("entry must be { html, css?, js? }");void 0!==a.host_api&&2!==a.host_api&&o("host_api: the HTML Block host speaks API 2")}else"declarative"===a.kind&&(d(a.entry)?f.add(String(a.entry)):o(`entry ${JSON.stringify(a.entry)} is not in the directory`));for(const e of Array.isArray(a.assets)?a.assets:[])d(e)?f.add(String(e)):o(`asset ${JSON.stringify(e)} is not in the directory`);void 0!==a.agent&&(d(a.agent)?f.add(String(a.agent)):o(`agent ${JSON.stringify(a.agent)} is not in the directory`));for(const e of r)f.has(e)||i.push({file:e,severity:"warning",message:"not named by component.json: kept in the source snapshot only"});return i}function v(e){if(!e||"object"!=typeof e)throw new i([{file:t,severity:"error",message:"must be a JSON object"}]);const r=e,n=r.manifest_version;if("number"!=typeof n||n<1)throw new i([{file:t,severity:"error",message:"manifest_version required"}]);if(n>1)throw new i([{file:t,severity:"error",message:`manifest_version ${n} needs a newer client (this one reads 1)`}]);if("aiws"!==r.purpose)throw new i([{file:t,severity:"error",message:"purpose must be aiws"}]);if(!Array.isArray(r.controls))throw new i([{file:t,severity:"error",message:"controls must be an array"}]);return{manifest_version:n,purpose:"aiws",host_api:r.host_api??{},controls:r.controls,workspace_templates:Array.isArray(r.workspace_templates)?r.workspace_templates:[]}}async function b(e,t,r){const i=/[*?[\]\\]/.test(r)?void 0:r;return(await e.list("string"==typeof t?t:{ref:t},{limit:i?10:1e3,...i?{filter:{name_glob:i}}:{}},["base","ident"])).entries.find((e=>e.name===r))}async function S(e,t){const r=t.split("/").filter(Boolean);if(0===r.length)throw new Error(`not a folder path: ${t}`);let n=(await e.stat(`/${r[0]}`)).ref;for(const s of r.slice(1)){const r=await b(e,n,s);if(r&&"dir"!==r.target.kind)throw new i([{file:s,severity:"error",message:`${s} in ${t} is not a folder`}]);n=r?r.target.ref:(await e.mkdir({ref:n},s)).ref}return n}async function x(e,t){const r=t.split("/").filter(Boolean);if(0===r.length)return null;let i=(await e.stat(`/${r[0]}`)).ref;for(const n of r.slice(1)){const t=await b(e,i,n);if(!t||"dir"!==t.target.kind)return null;i=t.target.ref}return i}async function $(e,t,r,i){const n="string"==typeof t?await S(e,t):t;await e.uploadFile(n,r,i,{overwrite:!0})}const k=e=>new Promise((t=>setTimeout(t,e)));async function j(e,t){var r,n,s;const o=[],a=[];let c;do{const i=await e.list(t,{limit:500,...c?{cursor:c}:{}},["base","ident"]);for(const e of i.entries){if(e.name.startsWith("."))continue;if("file"!==e.target.kind){a.push({file:e.name,severity:"error",message:"a control source folder is flat: move files out of sub-folders"});continue}const t=e.target.ref,i="object"===t.type?t.obj_id:"string"==typeof(null==(r=e.target.attrs)?void 0:r.obj_id)?e.target.attrs.obj_id:void 0;o.push({name:e.name,...i?{obj_id:i}:{},..."live"===t.type?{node_id:t.node_id}:{},..."string"==typeof(null==(n=e.target.attrs)?void 0:n.etag)?{etag:e.target.attrs.etag}:{},..."number"==typeof(null==(s=e.target.attrs)?void 0:s.size)?{size:e.target.attrs.size}:{}})}c=i.truncated?i.next_cursor:void 0}while(c);if(0===o.length&&a.push({file:"",severity:"error",message:`${t} holds no files`}),o.length>64&&a.push({file:"",severity:"error",message:"a control holds at most 64 files"}),a.some((e=>"error"===e.severity)))throw new i(a);return o.sort(((e,t)=>e.name.localeCompare(t.name)))}async function A(e,t){try{const i=await b(e,t,r),n="live"===(null==i?void 0:i.target.ref.type)?i.target.ref.node_id:void 0;if(!n)return null;const s=await e.readFile(n);return await s.json()}catch{return null}}async function I(e,t,i){await $(e,t,r,n.encode(`${JSON.stringify(i,null,2)}\n`))}exports.AIWS_BUILD_STATE_FILE=r,exports.AIWS_COMPONENT_FILE=e,exports.AIWS_DECLARATIVE_API_VERSION=1,exports.AIWS_HTML_API_VERSION=2,exports.AIWS_MANIFEST_FILE=t,exports.AIWS_MANIFEST_VERSION=1,exports.AIWS_MAX_INLINE_BYTES=d,exports.AIWS_MAX_SOURCE_FILES=64,exports.AiwsSourceError=i,exports.aiwsContentDigest=c,exports.buildControl=async function(e,t,r,i,n={}){const s=await j(t,i),o=await A(t,i),a=o&&o.workspace_id===r?{def_rev:o.def_rev,dir_rev:o.dir_rev}:void 0,c=await e.extBuild(r,{files:await u(t,s),...n.folderId?{folder_id:n.folderId}:{},...a?{expect:a}:{},...n.force?{force:!0}:{},...n.dryRun?{dry_run:!0}:{}});return n.dryRun||"string"!=typeof c.def_entity_id||"number"!=typeof c.def_rev||await I(t,i,{workspace_id:r,def_entity_id:c.def_entity_id,def_rev:c.def_rev,dir_rev:Number(c.dir_rev??0),ident:String(c.ident??""),at:(new Date).toISOString()}),{...c,files:s}},exports.buildFiles=u,exports.checkComponent=_,exports.collectSources=j,exports.compatManifest=v,exports.controlSkeleton=function(t){const r=t.title??t.name,i={manifest_version:1,ident:{author_did:t.authorDid,name:t.name},kind:t.kind??"declarative",title:r,description:`${r}: a control of this Workspace`,accepts:["buckyos.table-source","buckyos.record"],allow_no_source:!0,default_size:{w:260,h:140},config_schema:{type:"object",properties:{label:{type:"string",title:"Label",default:r}}},bindings:{data:{accepts:["buckyos.table-source"],title:"Data",description:"The table this control summarizes"}},catalog:{group:"custom",description:`${r}`},agent:"AGENT.md"},n=`# ${r}\n\nBind \`data\` to a table. Config: \`label\` (text).\n`;return"html"===t.kind?{[e]:`${JSON.stringify({...i,host_api:2,entry:{html:"view.html",css:"style.css",js:"behavior.js"}},null,2)}\n`,"view.html":'<div class="card"><div class="label" id="label"></div><div class="value" id="value">—</div></div>\n',"style.css":".card{font:14px system-ui;padding:12px}.label{opacity:.7}.value{font-size:28px;font-weight:600}\n","behavior.js":"document.getElementById('label').textContent = (aiws.context.config || {}).label || ''\nif (aiws.bindings.data) aiws.input('data').rows().then(function (rows) { document.getElementById('value').textContent = String(rows.length) })\n","AGENT.md":n}:{[e]:`${JSON.stringify({...i,entry:"declarative.json"},null,2)}\n`,"declarative.json":`${JSON.stringify({layout:"stack",items:[{kind:"metric",label:r,bind:"data.count",format:"number"},{kind:"text",text:"Rows of the bound table"}]},null,2)}\n`,"AGENT.md":n}},exports.createControlSource=async function(t,r,s){const o=await S(t,r),a=await t.list({ref:o},{limit:500},["base"]).catch((()=>null));if(null==a?void 0:a.entries.some((t=>t.name===e)))throw new i([{file:e,severity:"error",message:`${r} already holds a control`}]);for(const[e,i]of Object.entries(s))await $(t,o,e,n.encode(i));return o},exports.ensureFolder=S,exports.exportBundle=async function(e,r,i,s){const o=await e.extExport(r,i,"package"),a=new Map;a.set(t,n.encode(`${JSON.stringify(o.manifest,null,2)}\n`));for(const t of o.files)a.set(t.path,void 0!==t.text?n.encode(t.text):await s(r,String(t.obj_id)));return{manifest:v(o.manifest),files:a,controls:o.controls}},exports.findFolder=x,exports.folderName=o,exports.hasControlSource=async function(t,r){const i=await x(t,r);return null!==i&&void 0!==await b(t,i,e)},exports.homeControlDir=function(e,t,r){return`/home/${e}/AI Workspace/${o(t)}/controls/${r}`},exports.homeExportDir=function(e,t){return`/home/${e}/AI Workspace/exports/${t}`},exports.joinPath=function(e,t){return`${e.replace(/\/+$/,"")}/${t}`},exports.pullControl=async function(e,t,r,i,s,o){const a=(await e.extExport(r,[i],"pull")).controls[0],c=await S(t,s);for(const d of a.files)await $(t,c,d.name,void 0!==d.text?n.encode(d.text):await o(r,String(d.obj_id)));const l={workspace_id:r,def_entity_id:a.entity_id,def_rev:a.def_rev,dir_rev:a.dir_rev,ident:a.ident,at:(new Date).toISOString()};return await I(t,s,l),{files:a.files.map((e=>e.name)),state:l}},exports.readBuildState=A,exports.sourceStateKey=function(e){return`aiws:src:${e}`},exports.sourcesKey=l,exports.verifyBundle=async function(r){var n,o;const a=r.get(t);if(!a)throw new i([{file:t,severity:"error",message:"missing"}]);let l;try{l=JSON.parse(s.decode(a))}catch(p){throw new i([{file:t,severity:"error",message:String(p)}])}const d=v(l),f=[];d.workspace_templates.length>0&&f.push({file:t,severity:"error",message:"Workspace templates are not supported yet"}),0===d.controls.length&&f.push({file:t,severity:"error",message:"lists no control"});const u=new Set;for(const i of d.controls){if("string"!=typeof i.dir||!/^controls\/[a-z0-9][a-z0-9._-]{0,70}\/$/.test(i.dir)||u.has(i.dir)){f.push({file:t,severity:"error",message:`control ${i.ident}: bad or repeated dir`});continue}u.add(i.dir);const a=[...r].filter((([e])=>e.startsWith(i.dir))).map((([e,t])=>[e.slice(i.dir.length),t]));a.some((([e])=>e.includes("/")))&&f.push({file:i.dir,severity:"error",message:"a control directory is flat"}),await c(a)!==i.digest&&f.push({file:i.dir,severity:"error",message:"the files do not match the manifest digest"});const l=a.find((([t])=>t===e));if(l){for(const e of _(s.decode(l[1]),a.map((([e])=>e))))f.push({...e,file:`${i.dir}${e.file}`});try{const e=JSON.parse(s.decode(l[1]));`${null==(n=e.ident)?void 0:n.author_did}#${null==(o=e.ident)?void 0:o.name}`===i.ident&&e.kind===i.kind||f.push({file:i.dir,severity:"error",message:"ident and kind must match its component.json"})}catch{}}else f.push({file:`${i.dir}${e}`,severity:"error",message:"missing"})}for(const e of r.keys())e===t||[...u].some((t=>e.startsWith(t)))||f.push({file:e,severity:"error",message:"belongs to no control of the manifest"});return{manifest:d,diagnostics:f}},exports.watchControl=async function(e,t,r,i={}){var n,s;let o,a="",c=Promise.resolve();const d=()=>{c=c.then((async()=>{let i;try{i=await j(e,t)}catch{return}const n=l(i);n!==a&&(a=n,await r(i))})).catch((()=>{}))};for(d();!(null==(n=i.signal)?void 0:n.aborted);){const r=await e.list(t,{limit:1},["base"]),n=e.watch({tokens:r.watch_token?[r.watch_token]:[],signal:i.signal});try{for await(const e of n)o&&clearTimeout(o),o=setTimeout(d,i.debounceMs??500)}catch{if(null==(s=i.signal)?void 0:s.aborted)break;await k(2e3)}finally{n.close()}}o&&clearTimeout(o),await c},exports.writeBuildState=I,exports.writeHomeFile=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="component.json",t="composition.json",s="aiws-manifest.json",i=".aiws-build.json",n="aiws-template/1";class o extends Error{constructor(e){super(e.filter((e=>"error"===e.severity)).map((e=>`${e.file?`${e.file}: `:""}${e.message}`)).join("; ")||"invalid control source"),this.name="AiwsSourceError",this.diagnostics=e}}const r=new TextEncoder,a=new TextDecoder;function c(e,t){return`${e.replace(/\/+$/,"")}/${t}`}function l(e){return e.replace(/[/\\\u0000-\u001f]/g," ").replace(/^\.+/,"").trim().slice(0,80)||"Workspace"}async function d(e){const t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t),(e=>e.toString(16).padStart(2,"0"))).join("")}async function f(e){const t=[];for(const[s,i]of e)t.push([s,await d(i)]);return t.sort(((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0)),`sha256:${await d(r.encode(JSON.stringify(t)))}`}function p(e){return JSON.stringify([...e].sort(((e,t)=>e.name.localeCompare(t.name))).map((e=>[e.name,e.obj_id??e.etag??""])))}const u=4194304;function m(e){let t="";for(let s=0;s<e.length;s+=32768)t+=String.fromCharCode(...e.subarray(s,s+32768));return btoa(t)}async function h(e,t,s=[]){let i=e.reduce(((e,t)=>e+t.bytes.length),0);const n=new Map;if(i>u){if(!t)throw new o([{file:"",severity:"error",message:"a control's inline files are limited to 4194304 bytes per build"}]);for(const s of[...e].sort(((e,t)=>t.bytes.length-e.bytes.length))){if(i<=u)break;n.set(s.name,await t(s.name,s.bytes)),i-=s.bytes.length}}const r=[...s];for(const o of e){const e=n.get(o.name);r.push(e?{name:o.name,obj_id:e}:{name:o.name,base64:m(o.bytes)})}return r.sort(((e,t)=>e.name<t.name?-1:e.name>t.name?1:0))}async function y(e,t,s){var i;const n=[],r=[];for(const a of t)if(null==(i=a.obj_id)?void 0:i.startsWith("cyfile:"))n.push({name:a.name,obj_id:a.obj_id});else{if(!a.node_id)throw new o([{file:a.name,severity:"error",message:"the file service did not name this file"}]);r.push({name:a.name,bytes:new Uint8Array(await(await e.readFile(a.node_id)).arrayBuffer())})}return h(r,s,n)}const g=["manifest_version","ident","kind","title","description","host_api","accepts","allow_no_source","default_size","config_schema","bindings","entry","assets","catalog","agent","deps","events"],b=["type","enum","default","required","title","description","minimum","maximum","minLength","maxLength","properties","items"],v=/^[a-z0-9][a-z0-9._-]{0,63}$/,$=/^did:[a-z0-9]+:[^/#\s]+$/,w=/^[a-z][a-z0-9_]{0,31}$/,_=/^did:[a-z0-9]+:[^/#\s]+#[a-z0-9][a-z0-9._-]{0,63}$/,k="needs manifest_version 2 (raise it in component.json)",j="needs manifest_version 3 (raise it in component.json)",x=["string","number","boolean","object","entity"],S=["text","value","metric","bar","list","badge"],O=["kind","text","label","bind","by","format","limit"],A=["open_source","activate_editor","open_definition"],N=["text","number","select","boolean","color"];function E(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function I(e){return e.length>0&&r.encode(e).length<=255&&!e.includes("\0")&&e.split("/").every((e=>e.length>0&&!e.startsWith(".")))}function z(e){const t=E(e)?e.properties:void 0;return E(t)?t:{}}function J(e,t,s,i){for(const n of e.matchAll(/\{\{([^}]*)\}\}/g)){const e=n[1].trim();e.startsWith("config.")?e.slice(7)in s||i(`${t}: {{${e}}} names no property of config_schema`):i(`${t}: only {{config.<key>}} may be used here`)}}function T(e,t,s){if(e&&"object"==typeof e&&!Array.isArray(e))for(const[i,n]of Object.entries(e))if(b.includes(i)){if("properties"===i&&n&&"object"==typeof n)for(const[e,i]of Object.entries(n))T(i,`${t}/properties/${e}`,s);"items"===i&&T(n,`${t}/items`,s)}else s.push(`${t}/${i}: keyword ${i} is outside the supported subset`);else s.push(`${t}: a schema is an object`)}function q(e,t={},s="declarative.json"){const i=[],n=(e,t)=>i.push({file:s,severity:"error",message:e,...t?{code:t}:{}}),o=e=>i.push({file:s,severity:"warning",message:e});let r;try{const t=JSON.parse(e);if(!E(t))return n("a declarative definition is a JSON object"),i;r=t}catch(f){return n(f instanceof Error?f.message:String(f)),i}const a=E(t.bindings)?t.bindings:{},c=z(t.configSchema),l=(e,t)=>{if("string"==typeof e)J(e,t,c,n);else if(Array.isArray(e))e.forEach(((e,s)=>l(e,`${t}[${s}]`)));else if(E(e))for(const[s,i]of Object.entries(e))l(i,`${t}.${s}`)},d=(e,s)=>{void 0!==e&&(Array.isArray(e)?e.forEach(((e,i)=>{const r=`${s}[${i}]`;if(E(e))if("button"!==e.kind){"string"==typeof e.kind&&S.includes(e.kind)||n(`${r}.kind ${JSON.stringify(e.kind)}: one of ${[...S,"button"].join(", ")}`);for(const t of Object.keys(e))O.includes(t)||o(`${r}: key ${t} is ignored by the interpreter`);if(void 0===e.format||["text","number","percent","currency"].includes(e.format)||n(`${r}.format ${JSON.stringify(e.format)}: text, number, percent or currency`),"string"==typeof e.bind&&e.bind.includes(".")){const t=e.bind.slice(0,e.bind.indexOf("."));"props"===t||t in a||o(`${r}.bind ${JSON.stringify(e.bind)}: ${t} is not a declared binding, so it reads the field ${JSON.stringify(e.bind)} of the main source`)}}else((e,s)=>{void 0!==t.manifestVersion&&t.manifestVersion<3&&n(`${s}: a button ${j}`);for(const t of Object.keys(e))["kind","label","emit","params"].includes(t)||o(`${s}: key ${t} is ignored by the interpreter`);"string"==typeof e.label&&e.label||n(`${s}.label: the button's text (required)`),"string"==typeof e.emit&&e.emit?t.events&&!t.events.includes(e.emit)&&n(`${s}.emit ${e.emit}: not an event of component.json`,"EVENT_UNDECLARED"):n(`${s}.emit: the event the button raises (required)`),void 0!==e.params&&(E(e.params)?l(e.params,`${s}.params`):n(`${s}.params must be an object`))})(e,r);else n(`${r} must be an object`)})):n(`${s} must be an array`))};for(const[p,u]of Object.entries(r))"layout"===p?"stack"!==u&&"row"!==u&&n("layout: stack or row"):"items"===p?d(u,"items"):"view"===p?d(E(u)?u.items:void 0,"view.items"):"accent"===p?"string"!=typeof u&&n("accent must be a colour string"):"actions"===p?(Array.isArray(u)?u:[]).forEach(((e,t)=>{const s=E(e)?e:{};"string"==typeof s.command&&A.includes(s.command)||n(`actions[${t}].command: one of ${A.join(", ")}`),"string"==typeof s.id&&"string"==typeof s.label||n(`actions[${t}] needs id and label`)})):"inspector"===p?(Array.isArray(u)?u:[]).forEach(((e,t)=>{const s=E(e)?e:{};"string"==typeof s.kind&&N.includes(s.kind)||n(`inspector[${t}].kind: one of ${N.join(", ")}`),"string"==typeof s.key&&"string"==typeof s.label||n(`inspector[${t}] needs key and label`)})):o(`key ${p} is not part of the declarative vocabulary`);return void 0===r.items&&void 0===r.view&&o("no items: the control draws nothing"),i}function C(e,s,i=t,n={}){const o=[],a=(e,t)=>o.push({file:i,severity:"error",message:e,...t?{code:t}:{}});let c;try{const t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))return a("a composition is a JSON object { layout, slots, chrome?, events? }"),o;c=t}catch(y){return a(y instanceof Error?y.message:String(y)),o}const l=z(s),d=(e,t)=>J(e,t,l,a),f=(e,t,s)=>{"number"==typeof e&&e>=0&&e<=s||("string"==typeof e&&/^\s*\{\{.*\}\}\s*$/.test(e)?d(e,t):a(`${t}: a number in [0, ${s}] or {{config.<key>}}`))};for(const t of Object.keys(c))["layout","slots","chrome","events"].includes(t)||a(`unknown key ${t} (a composition says layout, slots, chrome and events)`);const p=c.layout;let u="stack";if(p&&"object"==typeof p){"stack"===p.algorithm||"fixed"===p.algorithm||"grid"===p.algorithm?u=p.algorithm:a(`layout.algorithm ${JSON.stringify(p.algorithm)}: stack, fixed or grid (the algorithms the host ships)`);for(const[e,t]of Object.entries(p))if("algorithm"!==e)if("direction"!==e&&"spacing"!==e||"stack"===u)if("columns"!==e&&"gap"!==e||"grid"===u)if("direction"===e)"column"!==t&&"row"!==t&&a("layout.direction: column or row");else if("spacing"===e)f(t,"layout.spacing",2e3);else if("columns"===e)(!Number.isInteger(t)||t<1||t>12)&&a("layout.columns: an integer in [1, 12]");else if("gap"===e)f(t,"layout.gap",2e3);else if("padding"===e)if(t&&"object"==typeof t&&!Array.isArray(t))for(const[s,i]of Object.entries(t))["t","r","b","l"].includes(s)||a(`layout.padding.${s}: t, r, b or l`),f(i,`layout.padding.${s}`,2e3);else f(t,"layout.padding",2e3);else a(`layout: unknown key ${e}`);else a(`layout.${e} belongs to the grid layout`);else a(`layout.${e} belongs to the stack layout`);"grid"===u&&void 0===p.columns&&a("layout.columns (1…12) required: the cells of a grid row")}else a("layout { algorithm: stack | fixed | grid } required");const m=c.slots&&"object"==typeof c.slots&&!Array.isArray(c.slots)?c.slots:null;if(m){Object.keys(m).length>16&&a("at most 16 slots");for(const[e,t]of Object.entries(m)){const s=`slots.${e}`;if(w.test(e)||a(`${s}: a slot name is [a-z][a-z0-9_]{0,31}`),!t||"object"!=typeof t||Array.isArray(t)){a(`${s} must be an object`);continue}const i=t;for(const[e,t]of Object.entries(i))if("accepts"===e){if(!Array.isArray(t)||0===t.length||t.length>32){a(`${s}.accepts: 1…32 entries (cell:<ident>, a view type, container)`);continue}for(const e of t)"string"==typeof e&&e.startsWith("cell:")?(!_.test(e.slice(5))||r.encode(e.slice(5)).length>128)&&a(`${s}.accepts ${JSON.stringify(e)}: cell:<author_did>#<name>`):"container"===e||"string"==typeof e&&v.test(e)||a(`${s}.accepts ${JSON.stringify(e)}: cell:<ident>, a view type or container`)}else"min"===e?(!Number.isInteger(t)||t<0||t>64)&&a(`${s}.min: an integer in [0, 64]`):"max"===e?(!Number.isInteger(t)||t<1||t>1e3)&&a(`${s}.max: an integer in [1, 1000]`):"placement"===e?"stack"!==t&&"top"!==t&&"bottom"!==t&&"free"!==t?a(`${s}.placement: stack, top, bottom or free`):"fixed"===u&&"free"!==t?a(`${s}.placement: a fixed layout keeps every child where it is (free)`):"grid"===u&&"stack"!==t&&a(`${s}.placement: a grid fills its cells with the slots' children in slot order (stack)`):"title"===e?("string"!=typeof t||t.length>256)&&a(`${s}.title: at most 256 characters`):a(`${s}: unknown key ${e}`);Number.isInteger(i.min)&&Number.isInteger(i.max)&&i.min>i.max&&a(`${s}: min exceeds max`)}}else a("slots { <name>: { accepts?, min?, max?, placement? } } required");const h=c.chrome;if(void 0!==h)if(!h||"object"!=typeof h||Array.isArray(h))a("chrome must be an object");else for(const[t,r]of Object.entries(h)){const e=`chrome.${t}`;if("background"===t||"border"===t)"string"==typeof r&&r.length<=64?d(r,e):a(`${e}: a colour (≤ 64 characters) or {{config.<key>}}`);else if("radius"===t)f(r,e,200);else if("empty"===t)"string"==typeof r&&r.length<=1e3?d(r,e):a(`${e}: a text of at most 1000 characters`);else if("title"===t){const t=r;if(!t||"object"!=typeof t||Array.isArray(t)){a(`${e}: { text, slot? }`);continue}for(const[e,s]of Object.entries(t))"text"===e?"string"==typeof s&&s.length<=256?d(s,"chrome.title.text"):a("chrome.title.text: at most 256 characters"):"slot"===e?"string"==typeof s&&m&&s in m||a(`chrome.title.slot ${JSON.stringify(s)}: a slot of this composition`):a(`chrome.title: unknown key ${e}`);"string"!=typeof t.text&&a("chrome.title.text required")}else a(`chrome: unknown key ${t} (background, radius, border, title, empty)`)}if(void 0!==c.events)if(void 0!==n.manifestVersion&&n.manifestVersion<3&&a(`events ${j}`),E(c.events)){Object.keys(c.events).length>16&&a("events: at most 16");for(const[e,t]of Object.entries(c.events)){const s=`events.${e}`;if(w.test(e)||a(`${s}: an event name is [a-z][a-z0-9_]{0,31}`),!E(t)){a(`${s} must be an object { from: { slot, event }, title?, description? }`);continue}for(const[e,n]of Object.entries(t))"title"===e?("string"!=typeof n||n.length>256)&&a(`${s}.title: at most 256 characters`):"description"===e?("string"!=typeof n||n.length>4e3)&&a(`${s}.description: at most 4000 characters`):"from"!==e&&a(`${s}: unknown key ${e} (from, title, description)`);const i=t.from;if(!E(i)){a(`${s}.from { slot, event } required: the child event it re-raises`);continue}for(const e of Object.keys(i))"slot"!==e&&"event"!==e&&a(`${s}.from: unknown key ${e} (slot, event)`);const o="string"==typeof i.event&&w.test(i.event)?i.event:void 0;o||a(`${s}.from.event: an event name [a-z][a-z0-9_]{0,31}`);const r="string"==typeof i.slot&&m?m[i.slot]:void 0;if(!E(r)){a(`${s}.from.slot ${JSON.stringify(i.slot)}: a slot of this composition`);continue}if(!o)continue;const c=(Array.isArray(r.accepts)?r.accepts:[]).filter((e=>"string"==typeof e&&e.startsWith("cell:"))).map((e=>e.slice(5)));if(0===c.length){a(`${s}: slot ${i.slot} accepts no cell:<ident>, so no control there declares ${o}`,"EVENT_UNDECLARED");continue}c.map((e=>{var t;return null==(t=n.cellEvents)?void 0:t.call(n,e)})).every((e=>void 0!==e&&!e.includes(o)))&&a(`${s}: no control slot ${i.slot} accepts (${c.join(", ")}) declares the event ${o}`,"EVENT_UNDECLARED")}}else a("events must be an object { <name>: { from: { slot, event }, title?, description? } }");return o}function W(t,s,i,n){const o=[],a=e,c=e=>o.push({file:a,severity:"error",message:e});let l;try{const e=JSON.parse(t);if(!e||"object"!=typeof e||Array.isArray(e))return c("must be a JSON object"),o;l=e}catch(O){return c(O instanceof Error?O.message:String(O)),o}for(const e of Object.keys(l))g.includes(e)||c(`unknown key ${e}`);const d=l.manifest_version,f="number"==typeof d&&Number.isInteger(d)&&d>=1?d:0;f?f>3&&c(`manifest_version ${d} is newer than this client reads (3)`):c("manifest_version (1…3) required");const p=f>0&&f<3,u=l.ident;let m="";u&&"object"==typeof u?("string"==typeof u.author_did&&$.test(u.author_did)||c("ident.author_did must be a DID (did:<method>:<id>)"),"string"==typeof u.name&&v.test(u.name)||c("ident.name must be [a-z0-9][a-z0-9._-]{0,63}"),"string"==typeof u.author_did&&"string"==typeof u.name&&(m=`${u.author_did}#${u.name}`,r.encode(m).length>128&&c("an identity is at most 128 bytes"))):c("ident { author_did, name } required");const h="composite"===l.kind;if("declarative"===l.kind||"html"===l.kind||h||c("kind must be declarative, html or composite"),h&&1===f&&c(`kind composite ${k}`),h)for(const e of["accepts","allow_no_source"])void 0!==l[e]&&c(`${e}: a composite is a container of Blocks, not a Cell showing data`);if(("string"!=typeof l.title||!l.title||l.title.length>256)&&c("title: 1…256 characters"),void 0!==l.config_schema){const e=[];T(l.config_schema,"config_schema",e),e.forEach(c)}if(void 0!==l.bindings)if(l.bindings&&"object"==typeof l.bindings)for(const e of Object.keys(l.bindings))w.test(e)&&"props"!==e||c(`binding name ${e}: [a-z][a-z0-9_]{0,31}, not props`);else c("bindings must be an object");if(void 0!==l.deps)if(!Array.isArray(l.deps)||l.deps.length>32)c("deps: at most 32 identities <author_did>#<name>");else if(l.deps.length>0&&1===f)c(`deps ${k}`);else{const e=new Set;for(const t of l.deps)"string"==typeof t&&_.test(t)?t===m?c("deps: a control cannot depend on itself"):e.has(t)&&c(`deps lists ${t} twice`):c(`deps: ${JSON.stringify(t)} is not an identity <author_did>#<name>`),e.add(String(t))}let y=[];if(void 0!==l.events){if(h)c("events: a composite declares its events in composition.json (events.<name>.from re-raises an event of a child)");else if(p)c(`events ${j}`);else{const e=[];!function(e,t){if(E(e)){Object.keys(e).length>16&&t.push("events: at most 16");for(const[s,i]of Object.entries(e)){const e=`events.${s}`;if(w.test(s)||t.push(`${e}: an event name is [a-z][a-z0-9_]{0,31}`),E(i)){for(const[s,n]of Object.entries(i))"title"===s?("string"!=typeof n||n.length>256)&&t.push(`${e}.title: at most 256 characters`):"description"===s?("string"!=typeof n||n.length>4e3)&&t.push(`${e}.description: at most 4000 characters`):"params"!==s&&t.push(`${e}: unknown key ${s} (title, description, params)`);if(void 0!==i.params)if(E(i.params)){Object.keys(i.params).length>16&&t.push(`${e}.params: at most 16`);for(const[s,n]of Object.entries(i.params)){const i=`${e}.params.${s}`;if(w.test(s)||t.push(`${i}: a param name is [a-z][a-z0-9_]{0,31}`),E(n)){for(const[e,s]of Object.entries(n))"type"===e?"string"==typeof s&&x.includes(s)||t.push(`${i}.type: ${x.join(", ")}`):"required"===e?"boolean"!=typeof s&&t.push(`${i}.required must be a boolean`):"description"===e?("string"!=typeof s||s.length>1e3)&&t.push(`${i}.description: at most 1000 characters`):t.push(`${i}: unknown key ${e} (type, required, description)`);void 0===n.type&&t.push(`${i}.type required`)}else t.push(`${i} must be an object { type, required?, description? }`)}}else t.push(`${e}.params must be an object { <param>: { type, required?, description? } }`)}else t.push(`${e} must be an object { title?, description?, params? }`)}}else t.push("events must be an object { <name>: { title?, description?, params? } }")}(l.events,e),e.forEach(c)}!h&&E(l.events)&&(y=Object.keys(l.events))}const b=e=>"string"==typeof e&&s.includes(e),S=new Set([a]);if("html"===l.kind){const e=l.entry;if(e&&"object"==typeof e&&"string"==typeof e.html)for(const[t,s]of Object.entries(e))b(s)?S.add(String(s)):c(`entry.${t} ${JSON.stringify(s)} is not in the directory`);else c("entry must be { html, css?, js? }");void 0!==l.host_api&&2!==l.host_api&&3!==l.host_api?c("host_api: the HTML Block host speaks API 2 and 3"):3===l.host_api&&p&&c(`host_api 3 ${j}`),y.length>0&&3!==l.host_api&&o.push({file:a,severity:"warning",message:"events: an HTML control raises them with aiws.emit, which is host API 3 (set host_api to 3)"})}else if("declarative"===l.kind||h){if(b(l.entry)){S.add(String(l.entry));const e=null==i?void 0:i(String(l.entry)),t=f||void 0;void 0!==e&&h?o.push(...C(e,l.config_schema,String(l.entry),{manifestVersion:t,cellEvents:n})):void 0!==e&&o.push(...q(e,{bindings:l.bindings,events:y,configSchema:l.config_schema,manifestVersion:t},String(l.entry)))}else c(`entry ${JSON.stringify(l.entry)} is not in the directory`);h&&void 0!==l.host_api&&c("host_api: a composite runs no code of its own (its layout and chrome are the host's)"),h||void 0===l.host_api||1===l.host_api||c("host_api: the declarative interpreter is version 1")}for(const e of Array.isArray(l.assets)?l.assets:[])b(e)?S.add(String(e)):c(`asset ${JSON.stringify(e)} is not in the directory`);void 0!==l.agent&&(b(l.agent)?S.add(String(l.agent)):c(`agent ${JSON.stringify(l.agent)} is not in the directory`));for(const e of s)I(e)?S.has(e)||o.push({file:e,severity:"warning",message:"not named by component.json: kept in the source snapshot only"}):o.push({file:e,severity:"error",message:"a file of a source directory: a relative path whose parts do not start with '.'"});return o}function D(e){if(!e||"object"!=typeof e)throw new o([{file:s,severity:"error",message:"must be a JSON object"}]);const t=e,i=t.manifest_version;if("number"!=typeof i||i<1)throw new o([{file:s,severity:"error",message:"manifest_version required"}]);if(i>3)throw new o([{file:s,severity:"error",message:`manifest_version ${i} needs a newer client (this one reads 3)`}]);if("aiws"!==t.purpose)throw new o([{file:s,severity:"error",message:"purpose must be aiws"}]);if(!Array.isArray(t.controls))throw new o([{file:s,severity:"error",message:"controls must be an array"}]);return{manifest_version:i,purpose:"aiws",host_api:t.host_api??{},controls:t.controls,workspace_templates:Array.isArray(t.workspace_templates)?t.workspace_templates:[]}}const B=/^[a-z0-9][a-z0-9-]{0,63}$/;function L(e){return`templates/${e}/`}async function F(e,t){const s=L(t),i=[];for(const[n,o]of e)n.startsWith(s)&&i.push([n.slice(s.length),o]);return f(i)}function M(e,t){if(!E(e))return["a template is an object { id, title, snapshot, digest, requires, description?, params?, reset? }"];const s=[];for(const n of Object.keys(e))["id","title","description","snapshot","digest","requires","params","reset"].includes(n)||s.push(`unknown key ${n}`);"string"==typeof e.id&&B.test(e.id)?e.snapshot!==`${L(e.id)}snapshot.json`&&s.push(`snapshot must be ${L(e.id)}snapshot.json`):s.push("id: [a-z0-9][a-z0-9-]{0,63}"),("string"!=typeof e.title||!e.title||e.title.length>256)&&s.push("title: 1…256 characters"),void 0!==e.description&&("string"!=typeof e.description||e.description.length>4e3)&&s.push("description: at most 4000 characters"),"string"==typeof e.digest&&/^sha256:[0-9a-f]{64}$/.test(e.digest)||s.push("digest: sha256:<64 hex digits>");const i=e.requires;if(E(i)){for(const e of Object.keys(i))"host_api"!==e&&"controls"!==e&&s.push(`requires: unknown key ${e}`);if(void 0!==i.host_api)if(E(i.host_api))for(const[e,t]of Object.entries(i.host_api))("html"!==e&&"declarative"!==e||!Number.isInteger(t)||t<1)&&s.push(`requires.host_api.${e}: html or declarative, a positive integer`);else s.push("requires.host_api must be an object { html?, declarative? }");if(!Array.isArray(i.controls)||i.controls.length>256)s.push("requires.controls: at most 256 identities");else{const e=new Set;for(const n of i.controls)"string"==typeof n&&t.has(n)?e.has(n)&&s.push(`requires.controls lists ${n} twice`):s.push(`requires.controls: ${JSON.stringify(n)} is not a control of this manifest`),e.add(n)}}else s.push("requires { host_api?, controls } required");if(void 0!==e.params)if(!E(e.params)||Object.keys(e.params).length>32)s.push("params: an object of at most 32 { type, title?, default? }");else for(const[n,o]of Object.entries(e.params)){const e=`params.${n}`;if(w.test(n)||s.push(`${e}: a param name is [a-z][a-z0-9_]{0,31}`),E(o)){for(const[t,i]of Object.entries(o))"type"===t?"string"!==i&&"number"!==i&&"boolean"!==i&&s.push(`${e}.type: string, number or boolean`):"title"===t?("string"!=typeof i||i.length>256)&&s.push(`${e}.title: at most 256 characters`):"default"===t?["string","number","boolean"].includes(typeof i)||s.push(`${e}.default: a string, number or boolean`):s.push(`${e}: unknown key ${t} (type, title, default)`);void 0===o.type&&s.push(`${e}.type required`)}else s.push(`${e} must be an object { type, title?, default? }`)}if(void 0!==e.reset){const t=E(e.reset)?e.reset.tables:void 0;!E(e.reset)||Object.keys(e.reset).some((e=>"tables"!==e))?s.push("reset: { tables }"):void 0!==t&&(!Array.isArray(t)||t.length>64||new Set(t).size!==t.length||t.some((e=>"string"!=typeof e||!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(e))))&&s.push("reset.tables: at most 64 distinct table ids")}return s}async function R(e,t,s){const i=/[*?[\]\\]/.test(s)?void 0:s;return(await e.list("string"==typeof t?t:{ref:t},{limit:i?10:1e3,...i?{filter:{name_glob:i}}:{}},["base","ident"])).entries.find((e=>e.name===s))}async function P(e,t){const s=t.split("/").filter(Boolean);if(0===s.length)throw new Error(`not a folder path: ${t}`);let i=(await e.stat(`/${s[0]}`)).ref;for(const n of s.slice(1)){const s=await R(e,i,n);if(s&&"dir"!==s.target.kind)throw new o([{file:n,severity:"error",message:`${n} in ${t} is not a folder`}]);i=s?s.target.ref:(await e.mkdir({ref:i},n)).ref}return i}async function V(e,t){const s=t.split("/").filter(Boolean);if(0===s.length)return null;let i=(await e.stat(`/${s[0]}`)).ref;for(const n of s.slice(1)){const t=await R(e,i,n);if(!t||"dir"!==t.target.kind)return null;i=t.target.ref}return i}async function U(t,s){const i=await V(t,s);return null!==i&&void 0!==await R(t,i,e)}async function G(e,t,s,i){const n="string"==typeof t?await P(e,t):t;await e.uploadFile(n,s,i,{overwrite:!0})}const H=e=>new Promise((t=>setTimeout(t,e)));async function K(e,t){const s=[],i=[],n=async(t,o,r)=>{var a,c,l;let d;do{const f=await e.list("string"==typeof t?t:{ref:t},{limit:500,...d?{cursor:d}:{}},["base","ident"]);for(const e of f.entries){if(e.name.startsWith("."))continue;const t=`${o}${e.name}`;if("dir"===e.target.kind){r>=8?i.push({file:t,severity:"error",message:"sub-folders nest at most 8 levels"}):await n(e.target.ref,`${t}/`,r+1);continue}if("file"!==e.target.kind){i.push({file:t,severity:"error",message:"only files and folders belong to a control source"});continue}const d=e.target.ref,f="object"===d.type?d.obj_id:"string"==typeof(null==(a=e.target.attrs)?void 0:a.obj_id)?e.target.attrs.obj_id:void 0;s.push({name:t,...f?{obj_id:f}:{},..."live"===d.type?{node_id:d.node_id}:{},..."string"==typeof(null==(c=e.target.attrs)?void 0:c.etag)?{etag:e.target.attrs.etag}:{},..."number"==typeof(null==(l=e.target.attrs)?void 0:l.size)?{size:e.target.attrs.size}:{}})}d=f.truncated?f.next_cursor:void 0}while(d)};if(await n(t,"",0),0===s.length&&i.push({file:"",severity:"error",message:`${t} holds no files`}),s.length>64&&i.push({file:"",severity:"error",message:"a control holds at most 64 files"}),i.some((e=>"error"===e.severity)))throw new o(i);return s.sort(((e,t)=>e.name<t.name?-1:e.name>t.name?1:0))}async function X(e,t,s,i){const n=s.lastIndexOf("/");await G(e,n<0?t:c(t,s.slice(0,n)),n<0?s:s.slice(n+1),i)}async function Y(e,t){const s=[];for(const i of t){if(!i.node_id)throw new o([{file:i.name,severity:"error",message:"the file service did not name this file"}]);s.push([i.name,new Uint8Array(await(await e.readFile(i.node_id)).arrayBuffer())])}return f(s)}async function Q(e,t){try{const s=await R(e,t,i),n="live"===(null==s?void 0:s.target.ref.type)?s.target.ref.node_id:void 0;if(!n)return null;const o=await e.readFile(n);return await o.json()}catch{return null}}async function Z(e,t,s){await G(e,t,i,r.encode(`${JSON.stringify(s,null,2)}\n`))}exports.AIWS_BUILD_STATE_FILE=i,exports.AIWS_COMPONENT_FILE=e,exports.AIWS_COMPOSITION_FILE=t,exports.AIWS_DECLARATIVE_API_VERSION=1,exports.AIWS_HTML_API_VERSION=3,exports.AIWS_MANIFEST_FILE=s,exports.AIWS_MANIFEST_VERSION=3,exports.AIWS_MAX_INLINE_BYTES=u,exports.AIWS_MAX_SOURCE_FILES=64,exports.AIWS_TEMPLATE_FORMAT=n,exports.AiwsSourceError=o,exports.aiwsContentDigest=f,exports.aiwsTemplateDigest=F,exports.buildControl=async function(e,t,s,i,n={}){const o=await K(t,i),r=await Q(t,i),a=r&&r.workspace_id===s?{def_rev:r.def_rev,dir_rev:r.dir_rev}:void 0,c=await e.extBuild(s,{files:await y(t,o,n.upload),...n.folderId?{folder_id:n.folderId}:{},...a?{expect:a}:{},...n.force?{force:!0}:{},...n.dryRun?{dry_run:!0}:{},...n.migration?{migration:n.migration}:{}});return n.dryRun||"string"!=typeof c.def_entity_id||"number"!=typeof c.def_rev||await Z(t,i,{workspace_id:s,def_entity_id:c.def_entity_id,def_rev:c.def_rev,dir_rev:Number(c.dir_rev??0),ident:String(c.ident??""),at:(new Date).toISOString()}),{...c,files:o}},exports.buildFiles=y,exports.checkComponent=W,exports.checkComposition=C,exports.checkDeclarative=q,exports.collectSources=K,exports.compatManifest=D,exports.controlSkeleton=function(s){const i=s.title??s.name;if("composite"===s.kind){const n="fixed"===s.algorithm,o=s.slots??{items:{placement:n?"free":"stack",title:"Items"}},r={layout:n?{algorithm:"fixed",padding:12}:{algorithm:"stack",direction:"column",spacing:"{{config.gap}}",padding:12},slots:o,chrome:{background:"{{config.background}}",radius:12,title:{text:"{{config.title}}"},empty:"Drop Blocks here"}},a={manifest_version:3,ident:{author_did:s.authorDid,name:s.name},kind:"composite",title:i,description:`${i}: a panel of Blocks`,default_size:{w:320,h:360},config_schema:{type:"object",properties:{title:{type:"string",title:"Title",default:i},background:{type:"string",title:"Background",default:"#f6f7fb"},gap:{type:"integer",title:"Gap (px)",default:8,minimum:0,maximum:64}}},entry:t,deps:s.deps??[],catalog:{group:"custom",description:`${i}`},agent:"AGENT.md"},c=Object.keys(o).map((e=>`\`${e}\``)).join(", ");return{[e]:`${JSON.stringify(a,null,2)}\n`,[t]:`${JSON.stringify(r,null,2)}\n`,"AGENT.md":`# ${i}\n\nA composite: an instance is a \`buckyos.container { kind: "composite", def_ref }\`; put Blocks under it with \`slot\` set to one of ${c}. Config: \`title\`, \`background\`, \`gap\`.\n`}}const n={manifest_version:3,ident:{author_did:s.authorDid,name:s.name},kind:s.kind??"declarative",title:i,description:`${i}: a control of this Workspace`,accepts:["buckyos.table-source","buckyos.record"],allow_no_source:!0,default_size:{w:260,h:140},config_schema:{type:"object",properties:{label:{type:"string",title:"Label",default:i}}},bindings:{data:{accepts:["buckyos.table-source"],title:"Data",description:"The table this control summarizes"}},catalog:{group:"custom",description:`${i}`},agent:"AGENT.md"},o=`# ${i}\n\nBind \`data\` to a table. Config: \`label\` (text).\n`;if("html"===s.kind){const t={clicked:{title:"Clicked",description:"Raised when someone clicks the button (in run mode)",params:{count:{type:"number",description:"Rows of the bound table"}}}};return{[e]:`${JSON.stringify({...n,host_api:3,events:t,entry:{html:"view.html",css:"style.css",js:"behavior.js"}},null,2)}\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',"style.css":".card{font:14px system-ui;padding:12px}.label{opacity:.7}.value{font-size:28px;font-weight:600}\n","behavior.js":["document.getElementById('label').textContent = (aiws.context.config || {}).label || ''","var count = 0","if (aiws.bindings.data) aiws.input('data').rows().then(function (rows) { count = rows.length; document.getElementById('value').textContent = String(count) })","// the public event of component.json: an instance binds handlers to it in its `on` (host API 3)","document.getElementById('go').addEventListener('click', function () { aiws.emit('clicked', { count: count }) })",""].join("\n"),"AGENT.md":`${o}Event: \`clicked\` (\`count\`), raised by its button; bind handlers to it in the instance's \`on\`.\n`}}return{[e]:`${JSON.stringify({...n,entry:"declarative.json"},null,2)}\n`,"declarative.json":`${JSON.stringify({layout:"stack",items:[{kind:"metric",label:i,bind:"data.count",format:"number"},{kind:"text",text:"Rows of the bound table"}]},null,2)}\n`,"AGENT.md":o}},exports.createControlSource=async function(t,s,i){const n=await P(t,s),a=await t.list({ref:n},{limit:500},["base"]).catch((()=>null));if(null==a?void 0:a.entries.some((t=>t.name===e)))throw new o([{file:e,severity:"error",message:`${s} already holds a control`}]);for(const[e,o]of Object.entries(i))await G(t,n,e,r.encode(o));return n},exports.ensureFolder=P,exports.exportBundle=async function(e,t,i,n){const o=await e.extExport(t,i,"package"),a=new Map;a.set(s,r.encode(`${JSON.stringify(o.manifest,null,2)}\n`));for(const s of o.files)a.set(s.path,void 0!==s.text?r.encode(s.text):await n(t,String(s.obj_id)));return{manifest:D(o.manifest),files:a,controls:o.controls}},exports.findFolder=V,exports.folderName=l,exports.hasControlSource=U,exports.homeControlDir=function(e,t,s){return`/home/${e}/AI Workspace/${l(t)}/controls/${s}`},exports.homeExportDir=function(e,t){return`/home/${e}/AI Workspace/exports/${t}`},exports.isSourcePath=I,exports.joinPath=c,exports.packBuildFiles=h,exports.pullControl=async function(e,t,s,i,n,o){const a=(await e.extExport(s,[i],"pull")).controls[0];await P(t,n);for(const l of a.files)await X(t,n,l.name,void 0!==l.text?r.encode(l.text):await o(s,String(l.obj_id)));const c={workspace_id:s,def_entity_id:a.entity_id,def_rev:a.def_rev,dir_rev:a.dir_rev,ident:a.ident,at:(new Date).toISOString()};return await Z(t,n,c),{files:a.files.map((e=>e.name)),state:c}},exports.readBuildState=Q,exports.slotCells=function(e){const t=new Set;for(const s of Object.values(e.slots??{}))for(const e of s.accepts??[])e.startsWith("cell:")&&t.add(e.slice(5));return[...t].sort()},exports.sourceStateKey=function(e){return`aiws:src:${e}`},exports.sourcesDigest=Y,exports.sourcesKey=p,exports.templateDir=L,exports.unbuiltChanges=async function(e,t,s,i,n){var o;if(!(await U(t,n)))return null;const r=await Y(t,await K(t,n)),a=await e.extExport(s,[i],"pull"),c=String((null==(o=a.controls[0])?void 0:o.digest)??"");return{changed:r!==c,home:r,built:c}},exports.verifyBundle=async function(t){var i,r;const c=t.get(s);if(!c)throw new o([{file:s,severity:"error",message:"missing"}]);let l;try{l=JSON.parse(a.decode(c))}catch(g){throw new o([{file:s,severity:"error",message:String(g)}])}const d=D(l),p=[],u=d.workspace_templates;u.length>0&&d.manifest_version<3&&p.push({file:s,severity:"error",message:`Workspace templates need manifest_version 3 (raise it in ${s})`}),u.length>32&&p.push({file:s,severity:"error",message:"at most 32 Workspace templates"}),0===d.controls.length&&0===u.length&&p.push({file:s,severity:"error",message:"lists no control"});const m=new Map;for(const s of d.controls){const i="string"==typeof s.dir?t.get(`${s.dir}${e}`):void 0;try{const e=i?JSON.parse(a.decode(i)):void 0;E(e)&&m.set(s.ident,E(e.events)?Object.keys(e.events):[])}catch{}}const h=new Set;for(const n of d.controls){if("string"!=typeof n.dir||!/^controls\/[a-z0-9][a-z0-9._-]{0,70}\/$/.test(n.dir)||h.has(n.dir)){p.push({file:s,severity:"error",message:`control ${n.ident}: bad or repeated dir`});continue}h.add(n.dir);const o=[...t].filter((([e])=>e.startsWith(n.dir))).map((([e,t])=>[e.slice(n.dir.length),t]));await f(o)!==n.digest&&p.push({file:n.dir,severity:"error",message:"the files do not match the manifest digest"});const c=o.find((([t])=>t===e));if(!c){p.push({file:`${n.dir}${e}`,severity:"error",message:"missing"});continue}const l=e=>{const t=o.find((([t])=>t===e));return t?a.decode(t[1]):void 0};for(const e of W(a.decode(c[1]),o.map((([e])=>e)),l,(e=>m.get(e))))p.push({...e,file:`${n.dir}${e.file}`});try{const e=JSON.parse(a.decode(c[1]));`${null==(i=e.ident)?void 0:i.author_did}#${null==(r=e.ident)?void 0:r.name}`===n.ident&&e.kind===n.kind||p.push({file:n.dir,severity:"error",message:"ident and kind must match its component.json"}),JSON.stringify([...e.deps??[]].sort())!==JSON.stringify([...n.deps??[]].sort())&&p.push({file:n.dir,severity:"error",message:"deps must match its component.json"})}catch{}}const y=new Set(d.controls.map((e=>e.ident)));for(const e of d.controls)for(const t of e.deps??[])y.has(t)||p.push({file:s,severity:"error",message:`${e.ident} depends on ${t}, which the bundle does not carry`});for(const[e,o]of u.entries()){const i=E(o)&&"string"==typeof o.id?`template ${o.id}`:`workspace_templates[${e}]`;for(const e of M(o,y))p.push({file:s,severity:"error",message:`${i}: ${e}`});if(!E(o)||"string"!=typeof o.id||!B.test(o.id))continue;const r=L(o.id);if(h.has(r)){p.push({file:s,severity:"error",message:`${i} is listed twice`});continue}h.add(r);const c=t.get(`${r}snapshot.json`);let l;try{l=c?JSON.parse(a.decode(c)).format:void 0}catch{l=void 0}c?l!==n&&p.push({file:`${r}snapshot.json`,severity:"error",message:`not a template snapshot (format ${n})`}):p.push({file:`${r}snapshot.json`,severity:"error",message:"missing"}),await F(t,o.id)!==o.digest&&p.push({file:r,severity:"error",message:"the files do not match the template digest"})}for(const e of t.keys())e===s||[...h].some((t=>e.startsWith(t)))||p.push({file:e,severity:"error",message:"belongs to no control or template of the manifest"});return{manifest:d,diagnostics:p}},exports.watchControl=async function(e,t,s,i={}){var n,o;let r,a="",c=Promise.resolve();const l=()=>{c=c.then((async()=>{let i;try{i=await K(e,t)}catch{return}const n=p(i);n!==a&&(a=n,await s(i))})).catch((()=>{}))};for(l();!(null==(n=i.signal)?void 0:n.aborted);){const s=await e.list(t,{limit:1},["base"]),n=e.watch({tokens:s.watch_token?[s.watch_token]:[],signal:i.signal});try{for await(const e of n)r&&clearTimeout(r),r=setTimeout(l,i.debounceMs??500)}catch{if(null==(o=i.signal)?void 0:o.aborted)break;await H(2e3)}finally{n.close()}}r&&clearTimeout(r),await c},exports.writeBuildState=Z,exports.writeHomeFile=G,exports.writeSourceFile=X;
2
2
  //# sourceMappingURL=aiws_ext.cjs.map