@ai-matrx/applets 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +130 -0
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/context-Dz3PWsJd.d.cts +193 -0
- package/dist/context-Dz3PWsJd.d.ts +193 -0
- package/dist/frame.cjs +977 -0
- package/dist/frame.cjs.map +1 -0
- package/dist/frame.d.cts +42 -0
- package/dist/frame.d.ts +42 -0
- package/dist/frame.js +958 -0
- package/dist/frame.js.map +1 -0
- package/dist/host.cjs +664 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +128 -0
- package/dist/host.d.ts +128 -0
- package/dist/host.js +641 -0
- package/dist/host.js.map +1 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +200 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.cjs +699 -0
- package/dist/platform.cjs.map +1 -0
- package/dist/platform.d.cts +135 -0
- package/dist/platform.d.ts +135 -0
- package/dist/platform.js +680 -0
- package/dist/platform.js.map +1 -0
- package/dist/react.cjs +880 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +178 -0
- package/dist/react.d.ts +178 -0
- package/dist/react.js +854 -0
- package/dist/react.js.map +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/platform/host.ts","../src/types.ts","../src/platform/supabase.ts","../src/platform/record.ts"],"sourcesContent":["/**\n * `createPlatformHost(opts)` — the real `AppletHost` (CONTRACTS §1) over the\n * live platform. Host-neutral: every client is INJECTED (the viewer's supabase\n * client, the agents IntelligencePort, the host's surface ports, navigation,\n * error reporting). No framework, no store, no environment reads.\n *\n * record() `app.definition` through the viewer's client → `AppletRecord`\n * data `@ai-matrx/records/data` `createTableDataPort` for table sources;\n * entity sources refuse `not_supported` by name until AP-3 phase B\n * intelligence `@ai-matrx/agents/intelligence`; alias → key from the record,\n * `appletId` stamped on every run\n * surface the Applet's `applets/<id>` surface chain read from `ui.ui_surface*`;\n * Actions resolved and run through `@ai-matrx/alchemy/actions`;\n * page Actions routed to the frame on the `actions` stream\n * kinds `content_ir.kind_definition` / `kind_component` through the viewer's client\n * pages `not_supported` — there is no table-built page store yet\n * events one hub: records `subscribe`, agents run events, surface values,\n * page Actions and navigation as the named streams of CONTRACTS §1\n *\n * It ANNOUNCES ITSELF: `kind: \"platform\"`. It never picks an organization:\n * table writes go to the table's own organization (records), and jobs run in\n * `opts.activeOrganizationId` — a signed-in viewer with none is refused by name\n * (`organization_required`), so the host can ask them to choose.\n */\nimport { createRecordsClient, type RecordsClient } from \"@ai-matrx/records/core\";\nimport type { RecordsError, RecordsRealtimePort, RecordsResult } from \"@ai-matrx/records\";\nimport { createRecordsRealtimePort } from \"@ai-matrx/records/realtime\";\nimport { createTableDataPort, type AliasBinding } from \"@ai-matrx/records/data\";\nimport type { IntelligencePort as AgentsIntelligencePort } from \"@ai-matrx/agents/intelligence\";\nimport {\n resolveActionChain,\n runSurfaceAction,\n surfaceActionRowToAction,\n type ActionChainLink,\n type SurfaceActionPorts,\n type SurfaceActionRow,\n} from \"@ai-matrx/alchemy/actions\";\nimport type { ApprovalPort, DiagnosticsPort, ServerActionPort, WriteDoor } from \"@ai-matrx/alchemy/ports\";\nimport type {\n ActionContext,\n ActionInfo,\n AppletChannel,\n AppletError,\n AppletRecord,\n DataSource,\n EventMessage,\n HostDataPort,\n IntelligencePort,\n NavLocation,\n PageActionEvent,\n Result,\n RowsEvent,\n RunRef,\n SurfacePort,\n Uuid,\n Viewer,\n} from \"../types\";\nimport { fail, fromRecordsError, NAV_STREAM, ok, PAGE_ACTION_STREAM, toAppletError, valueStream } from \"../types\";\nimport { APPLET_BASE_SURFACE, DEFINITION_COLUMNS, definitionToRecord } from \"./record\";\nimport { asPlatformSupabase, isRecord, read, type PlatformSupabase } from \"./supabase\";\n\n// ─── options ──────────────────────────────────────────────────────────────\n\n/** The host's own surface capabilities, bound into alchemy's one runner. Each absent port = that capability is absent, said by name. */\nexport interface PlatformSurfaceOptions {\n /** `POST /actions/run` (aidream) for `runs: \"server\"` Actions. */\n serverActions?: ServerActionPort;\n /** Asks the person before an agent / applet / automation runs an `ask` Action. */\n approvals?: ApprovalPort;\n /** The one write door (ALC-17) for write-target Actions. */\n door?: WriteDoor;\n /** Maximum surface inheritance depth (alchemy's default when absent). */\n maxDepth?: number;\n}\n\nexport interface PlatformRecordsOptions {\n /**\n * The host's realtime port. Absent → records' own `createRecordsRealtimePort()` over the ambient\n * `@ai-matrx/realtime` manager the host app mounted, so `rows:<alias>` fires without per-host wiring.\n */\n realtime?: RecordsRealtimePort;\n /** Doors the store has that records' generated catalogue does not list yet (records `knownDoors`). */\n knownDoors?: readonly string[];\n}\n\nexport interface PlatformHostOptions {\n appletId: Uuid;\n /** A supabase-js v2 client carrying the VIEWER's session. Typed `object` on purpose (see ./supabase.ts). */\n supabase: object;\n /** `createIntelligencePort({ transport })` from `@ai-matrx/agents/intelligence`, bound to the viewer. */\n agents: AgentsIntelligencePort;\n /** The organization the viewer SET (where jobs run and new things are saved). Reported, never used to narrow a read. */\n activeOrganizationId: Uuid | null;\n /** Routing is the host's. `subscribe` (optional) reports route changes the host makes itself. */\n nav: {\n go(to: string): Promise<void>;\n current(): Promise<NavLocation>;\n subscribe?(listener: (location: NavLocation) => void): () => void;\n };\n reportError(err: AppletError & { where: string }): void | Promise<void>;\n surfaces?: PlatformSurfaceOptions;\n records?: PlatformRecordsOptions;\n}\n\nexport interface PlatformHost extends AppletChannel {\n readonly kind: \"platform\";\n readonly appletId: Uuid;\n /** Stop every producer this host (and its children) subscribed to. */\n dispose(): void;\n}\n\n// ─── world: what every host in one tree shares ────────────────────────────\n\ninterface World {\n opts: PlatformHostOptions;\n supabase: PlatformSupabase;\n hosts: Map<string, InternalHost>;\n pending: Map<string, (result: Result<unknown>) => void>;\n viewer: Promise<Viewer> | null;\n records: Promise<RecordsClient> | null;\n seq: number;\n stopNav: (() => void) | null;\n}\n\ninterface InternalHost extends PlatformHost {\n emit(stream: string, payload: unknown): void;\n hasSubscriber(stream: string): boolean;\n surfaceName(): Promise<string>;\n}\n\n/** Built-in page Actions of the base surface, answered by the host itself (not the frame). */\nconst BASE_PAGE_ACTIONS = new Set([\"write_row\"]);\n\nconst MAX_CHAIN = 16;\n\nfunction mint(world: World, prefix: string): string {\n world.seq += 1;\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n return `${prefix}_${c?.randomUUID ? c.randomUUID() : `${Date.now().toString(36)}${world.seq}`}`;\n}\n\nfunction clone<T>(value: T): T {\n return value === undefined ? value : (JSON.parse(JSON.stringify(value)) as T);\n}\n\nfunction refuseRecords<T>(code: RecordsError[\"code\"], message: string): RecordsResult<T> {\n return { ok: false, error: { code, message } };\n}\n\n// ─── public ───────────────────────────────────────────────────────────────\n\nexport function createPlatformHost(opts: PlatformHostOptions): PlatformHost {\n const world: World = {\n opts,\n supabase: asPlatformSupabase(opts.supabase),\n hosts: new Map(),\n pending: new Map(),\n viewer: null,\n records: null,\n seq: 0,\n stopNav: null,\n };\n const root = buildHost(world, opts.appletId, `platform:${opts.appletId}`, null);\n if (opts.nav.subscribe) {\n world.stopNav = opts.nav.subscribe((location) => {\n for (const h of world.hosts.values()) h.emit(NAV_STREAM, location);\n });\n }\n return root;\n}\n\n// ─── viewer + records client (one per tree) ───────────────────────────────\n\nfunction loadViewer(world: World): Promise<Viewer> {\n world.viewer ??= (async (): Promise<Viewer> => {\n const report = (error: AppletError, where: string) => void world.opts.reportError({ ...error, where });\n let userId: Uuid | null = null;\n try {\n const session = await world.supabase.auth.getSession();\n if (session.error) report({ code: \"session_unreadable\", message: session.error.message, retryable: true }, \"viewer.session\");\n userId = session.data.session?.user.id ?? null;\n } catch (err) {\n report(toAppletError(err, \"session_unreadable\"), \"viewer.session\");\n }\n if (!userId) return { userId: null, organizationIds: [], activeOrganizationId: null, guest: true };\n const memberships = await read(\n world.supabase.schema(\"iam\").from(\"organization_member\").select(\"organization_id\").eq(\"user_id\", userId),\n (data) => [...new Set((Array.isArray(data) ? data : []).flatMap((r) => (isRecord(r) && typeof r.organization_id === \"string\" ? [r.organization_id] : [])))],\n );\n if (!memberships.ok) report(memberships.error, \"viewer.memberships\");\n return {\n userId,\n organizationIds: memberships.ok ? memberships.data : [],\n activeOrganizationId: world.opts.activeOrganizationId,\n guest: false,\n };\n })().catch((err: unknown) => {\n world.viewer = null;\n throw err;\n });\n return world.viewer;\n}\n\nfunction loadRecordsClient(world: World): Promise<RecordsClient> {\n world.records ??= loadViewer(world).then((viewer) => {\n const actor = viewer.userId ? { actor: \"user\" as const, user_id: viewer.userId } : { actor: \"user\" as const };\n return createRecordsClient({\n dataSource: world.opts.supabase as Parameters<typeof createRecordsClient>[0][\"dataSource\"],\n actor,\n // Writes to a custom table go to the TABLE's organization (createTableDataPort's `clientIn`);\n // reads span every membership. Nothing here narrows a read to the active organization.\n organizationId: world.opts.activeOrganizationId,\n organizationIds: viewer.organizationIds,\n onError: (e) => void world.opts.reportError({ code: e.code, message: e.message, retryable: false, where: `records:${e.where}` }),\n realtime: world.opts.records?.realtime ?? createRecordsRealtimePort(),\n ...(world.opts.records?.knownDoors ? { knownDoors: world.opts.records.knownDoors } : {}),\n });\n });\n return world.records;\n}\n\n// ─── one host per mounted Applet ──────────────────────────────────────────\n\nfunction buildHost(world: World, appletId: Uuid, hostId: string, parent: InternalHost | null): InternalHost {\n const { opts, supabase } = world;\n const listeners = new Set<(message: EventMessage) => void>();\n const subscriptions = new Map<string, { stream: string; stop: (() => void) | null }>();\n const values = new Map<string, unknown>();\n let recordPromise: Promise<AppletRecord> | null = null;\n let mounted: { mountId: string; name: string; chain: ActionInfo[] } | null = null;\n let childCount = 0;\n\n const report = (error: AppletError, where: string): void => {\n void Promise.resolve(opts.reportError({ ...error, where })).catch(() => undefined);\n };\n const deliver = (subscriptionId: string, payload: unknown): void => {\n const message: EventMessage = { subscriptionId, payload: clone(payload) };\n for (const l of [...listeners]) l(message);\n };\n const emit = (stream: string, payload: unknown): void => {\n for (const [id, s] of subscriptions) if (s.stream === stream) deliver(id, payload);\n };\n\n // ── record ──\n const record = (): Promise<AppletRecord> => {\n recordPromise ??= (async () => {\n const answer = await read(\n supabase.schema(\"app\").from(\"definition\").select(DEFINITION_COLUMNS).eq(\"id\", appletId).is(\"deleted_at\", null).maybeSingle(),\n (data) => data,\n );\n if (!answer.ok) throw answer.error;\n if (answer.data === null) {\n throw { code: \"applet_not_found\", message: `There is no Applet ${appletId} you can open.`, retryable: false } satisfies AppletError;\n }\n const mapped = definitionToRecord(answer.data);\n if (!mapped.ok) throw { code: \"applet_unreadable\", message: mapped.message, retryable: false } satisfies AppletError;\n return mapped.record;\n })().catch((err: unknown) => {\n recordPromise = null; // a refusal is never kept for the next asker\n throw err;\n });\n return recordPromise.then(clone);\n };\n\n // ── data ──\n let dataPort: Promise<{ port: HostDataPort | null; entities: Map<string, string> }> | null = null;\n const loadData = () => {\n dataPort ??= (async () => {\n const rec = await record();\n const aliases: Record<string, AliasBinding> = {};\n const entities = new Map<string, string>();\n for (const s of rec.sources) {\n if (\"table_id\" in s) aliases[s.alias] = { kind: \"table\", tableId: s.table_id, organizationId: s.organization_id };\n else entities.set(s.alias, s.entity);\n }\n const port = Object.keys(aliases).length ? createTableDataPort({ client: await loadRecordsClient(world), aliases }) : null;\n return { port, entities };\n })().catch((err: unknown) => {\n dataPort = null;\n throw err;\n });\n return dataPort;\n };\n const entityRefusal = <T,>(alias: string, entity: string): RecordsResult<T> =>\n refuseRecords(\"not_supported\", `\"${alias}\" is a ${entity} source; platform record sources are not readable from an Applet yet (AP-3 phase B).`);\n /** Route one alias: a table port call, the entity stand-in, or \"no such source\". */\n const routed = async <T,>(alias: string, call: (port: HostDataPort) => Promise<RecordsResult<T>>): Promise<RecordsResult<T>> => {\n let d: Awaited<ReturnType<typeof loadData>>;\n try {\n d = await loadData();\n } catch (err) {\n const e = toAppletError(err);\n return refuseRecords(\"unreachable\", e.message);\n }\n const entity = d.entities.get(alias);\n if (entity !== undefined) return entityRefusal(alias, entity);\n if (!d.port) return refuseRecords(\"not_found\", `This Applet has no data source called \"${alias}\".`);\n return call(d.port);\n };\n const data: HostDataPort = {\n subscribe(event, listener) {\n let stop: (() => void) | null = null;\n let stopped = false;\n void loadData().then(\n (d) => {\n const alias = event.slice(\"rows:\".length);\n if (stopped || !d.port || d.entities.has(alias)) return;\n stop = d.port.subscribe(event, listener);\n },\n (err: unknown) => report(toAppletError(err), `events.on(${event})`),\n );\n return () => {\n stopped = true;\n stop?.();\n };\n },\n async sources() {\n try {\n const d = await loadData();\n const tables = d.port ? await d.port.sources() : ({ ok: true, data: [] } as RecordsResult<DataSource[]>);\n if (!tables.ok) return tables;\n const ents: DataSource[] = [...d.entities].map(([alias]) => ({ alias, label: alias, kind: \"entity\", canCreate: false, canUpdate: false }));\n return { ok: true, data: [...tables.data, ...ents] };\n } catch (err) {\n return refuseRecords(\"unreachable\", toAppletError(err).message);\n }\n },\n columns: (alias) => routed(alias, (p) => p.columns(alias)),\n list: (alias, q, cursor) => routed(alias, (p) => (cursor === undefined ? p.list(alias, q) : p.list(alias, q, cursor))),\n get: (alias, id) => routed(alias, (p) => p.get(alias, id)),\n create: (alias, v) => routed(alias, (p) => p.create(alias, v)),\n update: (alias, id, patch, baseVersion) => routed(alias, (p) => p.update(alias, id, patch, baseVersion)),\n archive: (alias, id) => routed(alias, (p) => p.archive(alias, id)),\n restore: (alias, id) => routed(alias, (p) => p.restore(alias, id)),\n };\n\n // ── intelligence ──\n const keyFor = async (aliasOrKey: string): Promise<string> => {\n try {\n const rec = await record();\n return rec.mandates.find((m) => m.alias === aliasOrKey)?.key ?? aliasOrKey;\n } catch {\n return aliasOrKey;\n }\n };\n const agents = opts.agents;\n const intelligence: IntelligencePort = {\n async describe(key) {\n return agents.describe(await keyFor(key));\n },\n async run(req) {\n let rec: AppletRecord;\n try {\n rec = await record();\n } catch (err) {\n return { ok: false, error: toAppletError(err) };\n }\n const viewer = await loadViewer(world);\n const organizationId = req.organizationId ?? opts.activeOrganizationId;\n if (organizationId === null && !viewer.guest) {\n return fail(\"organization_required\", \"Choose an organization to run this job in.\");\n }\n return agents.run({\n ...req,\n key: rec.mandates.find((m) => m.alias === req.key)?.key ?? req.key,\n organizationId,\n appletId: rec.id, // the scope's own Applet, always\n surfaceName: req.surfaceName ?? rec.surfaceName,\n });\n },\n result: (ref) => agents.result(ref),\n answer: (ref, v) => agents.answer(ref, v),\n rejoin: (ref) => agents.rejoin(ref),\n async listRuns(key, scopedApplet) {\n return agents.listRuns(await keyFor(key), scopedApplet ?? appletId);\n },\n createSoft: (spec) => agents.createSoft(spec),\n };\n\n // ── nav ──\n const nav = {\n async go(to: string) {\n await opts.nav.go(to);\n if (opts.nav.subscribe) return; // the host announces its own route changes\n const location = await opts.nav.current();\n for (const h of world.hosts.values()) h.emit(NAV_STREAM, location);\n },\n current: () => opts.nav.current(),\n };\n\n // ── surface ──\n const readChain = async (name: string, maxDepth: number | undefined): Promise<Result<ActionInfo[]>> => {\n const names: string[] = [];\n let at: string | null = name;\n while (at) {\n if (names.includes(at)) return fail(\"surface_cycle\", `The surface chain loops at \"${at}\": ${[...names, at].join(\" → \")}.`);\n if (names.length >= MAX_CHAIN) return fail(\"surface_too_deep\", `The surface chain for \"${name}\" is deeper than ${MAX_CHAIN}.`);\n const row: Result<unknown> = await read(\n supabase.schema(\"ui\").from(\"ui_surface\").select(\"name, parent_surface_name\").eq(\"name\", at).is(\"deleted_at\", null).maybeSingle(),\n (d) => d,\n );\n if (!row.ok) return row;\n if (!isRecord(row.data)) {\n return fail(\n \"surface_not_found\",\n names.length === 0\n ? `The surface \"${at}\" does not exist yet; saving the Applet writes it (ui.save_applet_surface).`\n : `The surface \"${names[names.length - 1]}\" names a parent \"${at}\" that does not exist.`,\n );\n }\n names.push(at);\n at = typeof row.data.parent_surface_name === \"string\" && row.data.parent_surface_name ? row.data.parent_surface_name : null;\n }\n const rows = await read(\n supabase.schema(\"ui\").from(\"ui_surface_action\").select(\"*\").in(\"surface_name\", names).is(\"deleted_at\", null).order(\"sort_order\", { ascending: true }),\n (d) => (Array.isArray(d) ? (d as SurfaceActionRow[]) : []),\n );\n if (!rows.ok) return rows;\n const chain: ActionChainLink[] = [...names].reverse().map((surfaceName) => ({\n surfaceName,\n actions: rows.data.filter((r) => r.surface_name === surfaceName).map(surfaceActionRowToAction),\n }));\n try {\n return ok(resolveActionChain(chain, maxDepth === undefined ? {} : { maxDepth }));\n } catch (err) {\n return { ok: false, error: toAppletError(err, \"surface_chain\") };\n }\n };\n\n const seedValues = async (rec: AppletRecord): Promise<void> => {\n const viewer = await loadViewer(world);\n let location: NavLocation | null = null;\n try {\n location = await opts.nav.current();\n } catch (err) {\n report(toAppletError(err), \"nav.current\");\n }\n const seeds: Record<string, unknown> = {\n viewer: { userId: viewer.userId, guest: viewer.guest },\n organization: viewer.activeOrganizationId,\n record: { id: rec.id, slug: rec.slug, version: rec.version },\n sources: rec.sources.map((s) => s.alias),\n route: location ? `/${location.path.join(\"/\")}` : null,\n page: location ? { path: location.path, params: location.params } : null,\n };\n for (const [name, v] of Object.entries(seeds)) if (!values.has(name)) values.set(name, v);\n };\n\n /** A page Action runs in the frame of the Applet whose surface declared it; base-surface built-ins run here. */\n const dispatchPage = async (name: string, input: unknown, context: ActionContext): Promise<Result<unknown>> => {\n const declaredOn = context.surfaceName ?? \"\";\n if (declaredOn === APPLET_BASE_SURFACE && BASE_PAGE_ACTIONS.has(name)) return builtIn(name, input);\n let owner: InternalHost = self;\n for (const h of world.hosts.values()) {\n if (!h.hasSubscriber(PAGE_ACTION_STREAM)) continue;\n const surfaceName = await h.surfaceName().catch(() => null);\n if (surfaceName === declaredOn) owner = h;\n }\n if (!owner.hasSubscriber(PAGE_ACTION_STREAM)) {\n return fail(\"action_unhandled\", `No page is open to run \"${name}\".`);\n }\n return new Promise<Result<unknown>>((resolve) => {\n world.pending.set(context.runId, resolve);\n const event: PageActionEvent = { action: name, input, runId: context.runId, by: context.by };\n owner.emit(PAGE_ACTION_STREAM, event);\n });\n };\n\n const builtIn = async (name: string, input: unknown): Promise<Result<unknown>> => {\n if (name !== \"write_row\") return fail(\"action_unhandled\", `No handler for \"${name}\".`);\n if (!isRecord(input) || typeof input.source !== \"string\" || !isRecord(input.values)) {\n return fail(\"invalid_argument\", \"write_row needs a source and values.\");\n }\n let answer: RecordsResult<unknown>;\n if (typeof input.id === \"string\") {\n if (typeof input.baseVersion !== \"number\") {\n return fail(\"invalid_argument\", \"write_row needs the row's baseVersion to change it, so a stale write is refused.\");\n }\n answer = await data.update(input.source, input.id, input.values, input.baseVersion);\n } else {\n answer = await data.create(input.source, input.values);\n }\n return answer.ok ? ok(answer.data) : { ok: false, error: fromRecordsError(answer.error) };\n };\n\n const actionPorts = (): SurfaceActionPorts => {\n const diagnostics: DiagnosticsPort = {\n capture(error, context) {\n report({ ...toAppletError(error, \"action_failed\"), diagnostic: JSON.stringify(context.detail) }, `surface.${context.area}`);\n },\n };\n const s = opts.surfaces ?? {};\n return {\n diagnostics,\n ...(s.serverActions ? { serverActions: s.serverActions } : {}),\n ...(s.approvals ? { approvals: s.approvals } : {}),\n ...(s.door ? { door: s.door } : {}),\n mandates: {\n async run(request) {\n const viewer = await loadViewer(world);\n const started = await intelligence.run({\n key: request.key ?? request.alias ?? \"\",\n variables: request.variables,\n ...(request.userInput !== undefined ? { userInput: request.userInput } : {}),\n organizationId: viewer.activeOrganizationId,\n });\n if (!started.ok) throw new Error(started.error.message);\n // The run streams on `run:<requestId>`; the Action answers with its serializable identity.\n return started.data satisfies RunRef;\n },\n },\n pageActions: { dispatch: dispatchPage },\n overlay: {\n navigate(href) {\n void nav.go(href).catch((err: unknown) => report(toAppletError(err), \"nav.go\"));\n },\n open(overlayId) {\n report({ code: \"not_supported\", message: `Overlays cannot be opened from an Applet yet (\"${overlayId}\").`, retryable: false }, \"surface.overlay\");\n },\n close() {\n // nothing an Applet opened can be open\n },\n },\n };\n };\n\n const chainFor = async (): Promise<Result<ActionInfo[]>> => {\n if (mounted) return ok(mounted.chain);\n const rec = await record();\n return readChain(rec.surfaceName, opts.surfaces?.maxDepth);\n };\n\n const surface: SurfacePort = {\n async mount(name) {\n // The chain is the database's (ui.ui_surface.parent_surface_name); the frame's `parent` argument\n // names the same thing and is not trusted over it.\n try {\n const chain = await readChain(name, opts.surfaces?.maxDepth);\n if (!chain.ok) return chain;\n await seedValues(await record());\n mounted = { mountId: mint(world, \"mount\"), name, chain: chain.data };\n return ok({ mountId: mounted.mountId });\n } catch (err) {\n return { ok: false, error: toAppletError(err) };\n }\n },\n async unmount(mountId) {\n if (mounted?.mountId === mountId) mounted = null;\n },\n async getValue(name) {\n return clone(values.get(name));\n },\n async setValue(name, v) {\n values.set(name, clone(v));\n emit(valueStream(name), v);\n },\n async listActions() {\n try {\n const chain = await chainFor();\n if (!chain.ok) {\n report(chain.error, \"surface.listActions\");\n return [];\n }\n return clone(chain.data);\n } catch (err) {\n report(toAppletError(err), \"surface.listActions\");\n return [];\n }\n },\n async runAction(name, input, by) {\n let chain: Result<ActionInfo[]>;\n try {\n chain = await chainFor();\n } catch (err) {\n return { ok: false, error: toAppletError(err) };\n }\n if (!chain.ok) return chain;\n const info = chain.data.find((a) => a.name === name);\n if (!info) return fail(\"action_not_found\", `This page has no action named \"${name}\".`);\n const viewer = await loadViewer(world);\n const result = await runSurfaceAction(info, input, by, actionPorts(), { runId: mint(world, \"act\"), viewerId: viewer.userId });\n if (result.ok && info.updatesValue) await surface.setValue(info.updatesValue, result.data);\n return result;\n },\n async completeAction(runId, result) {\n const resolve = world.pending.get(runId);\n world.pending.delete(runId);\n resolve?.(result);\n },\n };\n\n // ── kinds / pages ──\n const kindRow = async (slug: string): Promise<Result<Record<string, unknown> | null>> =>\n read(\n supabase.schema(\"content_ir\").from(\"kind_definition\").select(\"id, kind, label, data, sample_data, emitted_json_schema, variants, version\").eq(\"kind\", slug).is(\"deleted_at\", null).maybeSingle(),\n (d) => (isRecord(d) ? d : null),\n );\n const kinds: AppletChannel[\"kinds\"] = {\n async definition(slug) {\n const row = await kindRow(slug);\n if (!row.ok) return row;\n if (!row.data) return fail(\"kind_not_found\", `No kind named \"${slug}\".`);\n return ok(row.data);\n },\n async component(slug, platform) {\n const row = await kindRow(slug);\n if (!row.ok) return row;\n if (!row.data) return fail(\"kind_not_found\", `No kind named \"${slug}\".`);\n const comp = await read(\n supabase\n .schema(\"content_ir\")\n .from(\"kind_component\")\n .select(\"component_key, component_source, is_default, sort_order\")\n .eq(\"kind_definition_id\", row.data.id)\n .eq(\"platform\", platform)\n .eq(\"role\", \"output\")\n .eq(\"is_active\", true)\n .is(\"deleted_at\", null)\n .order(\"is_default\", { ascending: false })\n .order(\"sort_order\", { ascending: true })\n .limit(1),\n (d) => (Array.isArray(d) && isRecord(d[0]) ? d[0] : null),\n );\n if (!comp.ok) return comp;\n if (!comp.data || typeof comp.data.component_source !== \"string\") return ok(null);\n const file = `${typeof comp.data.component_key === \"string\" && comp.data.component_key ? comp.data.component_key : slug}.tsx`;\n return ok({ files: { [file]: comp.data.component_source }, entry: file });\n },\n };\n const pages: AppletChannel[\"pages\"] = {\n async definition(pageId) {\n return fail(\"not_supported\", `Table-built pages cannot be opened from an Applet yet (page ${pageId}); there is no page store to read.`);\n },\n };\n\n // ── the host ──\n const self: InternalHost = {\n kind: \"platform\",\n appletId,\n hostId,\n viewer: () => loadViewer(world),\n record,\n async child(childId) {\n childCount += 1;\n const id = `${hostId}/${childId}#${childCount}`;\n buildHost(world, childId, id, self);\n return { hostId: id };\n },\n kinds,\n pages,\n data,\n intelligence,\n surface,\n nav,\n events: {\n async on(stream) {\n const subscriptionId = mint(world, \"sub\");\n let stop: (() => void) | null = null;\n if (stream.startsWith(\"rows:\")) {\n stop = data.subscribe(stream as `rows:${string}`, (event: RowsEvent) => deliver(subscriptionId, event));\n } else if (stream.startsWith(\"run:\")) {\n stop = agents.events.on(stream, (event) => deliver(subscriptionId, event));\n }\n subscriptions.set(subscriptionId, { stream, stop });\n return { subscriptionId };\n },\n async off(subscriptionId) {\n subscriptions.get(subscriptionId)?.stop?.();\n subscriptions.delete(subscriptionId);\n },\n },\n async reportError(err) {\n await opts.reportError(err);\n },\n receive(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n forHost(id) {\n return world.hosts.get(id) ?? null;\n },\n dispose() {\n for (const s of subscriptions.values()) s.stop?.();\n subscriptions.clear();\n listeners.clear();\n world.hosts.delete(hostId);\n if (parent === null) {\n for (const h of [...world.hosts.values()]) h.dispose();\n world.stopNav?.();\n world.stopNav = null;\n for (const resolve of world.pending.values()) resolve(fail(\"host_disposed\", \"The page closed before the action finished.\"));\n world.pending.clear();\n }\n },\n emit,\n hasSubscriber(stream) {\n for (const s of subscriptions.values()) if (s.stream === stream) return true;\n return false;\n },\n async surfaceName() {\n return (await record()).surfaceName;\n },\n };\n world.hosts.set(hostId, self);\n return self;\n}\n","/**\n * The Applets contract types (CONTRACTS v2 §0, §1, §3, §4, §6, §8).\n *\n * One owner per type. Types another package owns are RE-EXPORTED from it,\n * never redefined; types whose owner has not exported them yet are written\n * here structurally, each naming its owner and contract section, and are\n * replaced by a re-export the release the owner ships them.\n *\n * Framework-free: no React, no runtime imports. Every import below is a type.\n */\nimport type { EntityRefWithWords, Uuid as RecordsUuid } from \"@ai-matrx/records\";\nimport type { IntelligencePort as AgentsIntelligencePort } from \"@ai-matrx/agents/intelligence\";\nimport type { ActionResult, SurfacePort as AlchemySurfacePort } from \"@ai-matrx/alchemy/actions\";\nimport type { ScopeSpec } from \"@ai-matrx/code-runtime\";\nimport type { DataPort, DataSource, WhereClause } from \"@ai-matrx/records/data\";\nimport type { RecordsError } from \"@ai-matrx/records\";\n\n// ─── §0 — owned elsewhere, re-exported ─────────────────────────────────────\n\n/** `@ai-matrx/records` — a UUID string. */\nexport type Uuid = RecordsUuid;\n\n/** `@ai-matrx/records` (AP-3) — every link everywhere reads as `EntityRef[]` (`EntityRefWithWords`). */\nexport type EntityRef = EntityRefWithWords;\n\n/** `@ai-matrx/agents/intelligence` (AP-1). */\nexport type {\n RunRef,\n ServedInput,\n RunEvent,\n KindEnvelope,\n MandateDescription,\n RunRequest,\n RunResult,\n RunListing,\n SoftMandateSpec,\n} from \"@ai-matrx/agents/intelligence\";\n\n/** `@ai-matrx/alchemy/actions` (AP-2). */\nexport type {\n ActionDeclaration,\n ActionInfo,\n ActionContext,\n ActionCaller,\n ActionPolicy,\n ActionRuns,\n} from \"@ai-matrx/alchemy/actions\";\n\n/** `@ai-matrx/code-runtime` (AP-5). */\nexport type { ScopeSpec, CompileResult, Finding } from \"@ai-matrx/code-runtime\";\n\n/**\n * `@ai-matrx/content-ir` — a registered kind slug. content-ir types it as a\n * plain string and exports no named alias; this is that string.\n */\nexport type KindRef = string;\n\n// ─── §0 — owned here ───────────────────────────────────────────────────────\n\n/**\n * The system's own sentence. Superset of `RecordsError` in the sense of the\n * contract: `code` + the store's `message`, plus `retryable`.\n */\nexport interface AppletError {\n code: string;\n message: string;\n retryable: boolean;\n diagnostic?: string;\n}\n\n/** Never throws: every port call and every hook write answers one of these. */\nexport type Result<T> = { ok: true; data: T } | { ok: false; error: AppletError };\n\nexport type Status = \"idle\" | \"loading\" | \"ready\" | \"saving\" | \"error\";\n\n// ─── §0/§4 — owned by @ai-matrx/records (AP-3), re-exported ──────────────\n//\n// AP-3 owns Column, Row, Values, Filter, Query, Page and DataPort (CONTRACTS\n// §0 and §4); `@ai-matrx/records/data` exports them. The frame sees only the\n// port (`DataPort`, no `subscribe`); `HostDataPort` is the host's producer\n// (amendment 2.2) and never crosses the channel.\n\nexport type {\n Column,\n Row,\n Values,\n Query,\n Page,\n DataPort,\n HostDataPort,\n RowsEvent,\n DataSource,\n DataEvents,\n WhereClause,\n WhereOp,\n Lane,\n} from \"@ai-matrx/records/data\";\n\n/** CONTRACTS §4 one `where` clause — records' `WhereClause`. */\nexport type Filter = WhereClause;\n\n/** One source an Applet declared (CONTRACTS §2 `useSources`, §4 `sources()`) — records' `DataSource`. */\nexport type SourceInfo = DataSource;\n\n/** A refusal in the store's words (`RecordsError`) — what a DataPort answers. */\nexport type { RecordsError, RecordsResult } from \"@ai-matrx/records\";\n\n// ─── §3 / §6 — the ports as the host exposes them ──────────────────────────\n\n/**\n * CONTRACTS §3 `IntelligencePort` (owner `@ai-matrx/agents`, AP-1) as a host\n * port: the agents package's port minus its in-process `events` listener —\n * across the doorway, run events arrive on the host's `run:<requestId>`\n * stream instead (no port takes a function).\n */\nexport type IntelligencePort = Omit<AgentsIntelligencePort, \"events\">;\n\n/** CONTRACTS §6 `SurfacePort` (owner `@ai-matrx/alchemy`, AP-2). Events: `value:<name>`. */\nexport type SurfacePort = AlchemySurfacePort;\n\n/**\n * The payload of the `actions` event stream: a `runs: \"page\"` Action routed to\n * the frame (CONTRACTS §6). The frame answers with `surface.completeAction`.\n * `by` is a superset field so the handler's `ActionContext` is truthful.\n */\nexport interface PageActionEvent {\n action: string;\n input: unknown;\n runId: string;\n by?: \"person\" | \"agent\" | \"applet\" | \"automation\";\n}\n\n/** The stream page-Action runs arrive on. */\nexport const PAGE_ACTION_STREAM = \"actions\";\n/** The stream a host announces route changes on (payload: `NavLocation`). */\nexport const NAV_STREAM = \"nav\";\n\nexport const rowsStream = (alias: string): string => `rows:${alias}`;\nexport const runStream = (requestId: string): string => `run:${requestId}`;\nexport const valueStream = (name: string): string => `value:${name}`;\n\n/** Re-exported so hosts can type completeAction answers without importing alchemy. */\nexport type ActionAnswer<T = unknown> = ActionResult<T>;\n\n// ─── §8 — the Applet record ────────────────────────────────────────────────\n\nexport interface AppletPage {\n path: string;\n title: string;\n file: string;\n parent?: string;\n}\n\nexport interface AppletMandate {\n alias: string;\n key: string;\n}\n\nexport type AppletSource =\n | { alias: string; table_id: Uuid; organization_id: Uuid }\n | { alias: string; entity: string };\n\n/** CONTRACTS §8 `AppletRecord` (owner `@ai-matrx/applets`, AP-0). */\nexport interface AppletRecord {\n id: Uuid;\n version: number;\n organizationId: Uuid;\n slug: string;\n published: boolean;\n files: Record<string, string>;\n entry: string;\n scope: ScopeSpec;\n pages: AppletPage[];\n mandates: AppletMandate[];\n sources: AppletSource[];\n parentId: Uuid | null;\n /** `applets/<id>` */\n surfaceName: string;\n}\n\n// ─── §1 — the doorway ──────────────────────────────────────────────────────\n\nexport interface Viewer {\n userId: Uuid | null;\n organizationIds: Uuid[];\n activeOrganizationId: Uuid | null;\n guest: boolean;\n}\n\nexport interface NavLocation {\n path: string[];\n params: Record<string, string>;\n}\n\nexport interface KindComponentSource {\n files: Record<string, string>;\n entry: string;\n}\n\n/**\n * CONTRACTS §1 `AppletHost`. Every call is an async request with JSON in and\n * JSON out (kind envelopes allowed), scoped to ONE mounted Applet.\n */\nexport interface AppletHost {\n viewer(): Promise<Viewer>;\n record(): Promise<AppletRecord>;\n child(appletId: Uuid): Promise<{ hostId: string }>;\n kinds: {\n definition(slug: string): Promise<Result<unknown>>;\n component(slug: string, platform: string): Promise<Result<KindComponentSource | null>>;\n };\n pages: { definition(pageId: Uuid): Promise<Result<unknown>> };\n data: DataPort;\n intelligence: IntelligencePort;\n surface: SurfacePort;\n nav: { go(to: string): Promise<void>; current(): Promise<NavLocation> };\n events: {\n on(stream: string, filter: unknown): Promise<{ subscriptionId: string }>;\n off(subscriptionId: string): Promise<void>;\n };\n reportError(err: AppletError & { where: string }): Promise<void>;\n}\n\n/** What the frame receives for each event (CONTRACTS §1). */\nexport interface EventMessage {\n subscriptionId: string;\n payload: unknown;\n}\n\n/**\n * The frame's side of the doorway: the contract's `AppletHost` plus the two\n * things §1 says the CHANNEL supplies — receiving `{ subscriptionId, payload }`\n * messages, and addressing a child host by the `hostId` that `child()` answered.\n * An in-page host implements these in memory; a sandbox host maps them onto a\n * message channel. Neither is a port: nothing here crosses the doorway as data.\n */\nexport interface AppletChannel extends AppletHost {\n readonly hostId: string;\n /** Subscribe to every event message for this host. Returns an unsubscribe. */\n receive(listener: (message: EventMessage) => void): () => void;\n /** The scoped host for a `hostId` that `child()` answered. */\n forHost(hostId: string): AppletChannel | null;\n}\n\n// ─── helpers every half uses ───────────────────────────────────────────────\n\nexport function ok<T>(data: T): Result<T> {\n return { ok: true, data };\n}\n\nexport function fail<T = never>(code: string, message: string, retryable = false, diagnostic?: string): Result<T> {\n const error: AppletError = { code, message, retryable };\n if (diagnostic !== undefined) error.diagnostic = diagnostic;\n return { ok: false, error };\n}\n\n/**\n * A DataPort refusal (`RecordsError`) as the §0 `AppletError`: the store's code\n * and sentence verbatim, `retryable` true only where a second try could change\n * the answer (the call never reached the store, or ran out of time).\n */\nexport function fromRecordsError(error: RecordsError): AppletError {\n const out: AppletError = { code: error.code, message: error.message, retryable: error.code === \"unreachable\" || error.code === \"timed_out\" };\n if (error.diagnostic !== undefined) out.diagnostic = error.diagnostic;\n return out;\n}\n\n/** Any thrown value → an `AppletError`, keeping a system sentence when there is one. */\nexport function toAppletError(err: unknown, code = \"internal\"): AppletError {\n if (err && typeof err === \"object\") {\n const o = err as Record<string, unknown>;\n if (typeof o.code === \"string\" && typeof o.message === \"string\") {\n const out: AppletError = { code: o.code, message: o.message, retryable: o.retryable === true };\n if (typeof o.diagnostic === \"string\") out.diagnostic = o.diagnostic;\n return out;\n }\n if (err instanceof Error) return { code, message: err.message, retryable: false };\n }\n return { code, message: String(err), retryable: false };\n}\n","/**\n * The few reads the platform host makes through the VIEWER's supabase client,\n * typed structurally.\n *\n * Deliberately NOT `SupabaseClient<Database>`: a generated `Database` type\n * makes `schema().from().select()` enormous, and a host passing its typed\n * client in hits TS2589 in its own build (the same reason `@ai-matrx/records`\n * takes `object` in `supabaseDataSource`). The host hands in its client as an\n * `object`; the one cast lives here, where it is explained, and every read\n * names its schema out loud (supabase-js has no per-call schema option).\n *\n * This file holds no key and opens no connection: the client already carries\n * the person's session, so row security decides every answer.\n */\nimport type { AppletError, Result } from \"../types\";\n\n/** What a supabase-js read resolves with. */\nexport interface ReadAnswer {\n data: unknown;\n error: { message: string; code?: string; details?: string; hint?: string } | null;\n}\n\n/** The filter chain the host uses — a subset of supabase-js's `PostgrestFilterBuilder`. */\nexport interface ReadChain extends PromiseLike<ReadAnswer> {\n eq(column: string, value: unknown): ReadChain;\n in(column: string, values: readonly unknown[]): ReadChain;\n is(column: string, value: null): ReadChain;\n order(column: string, options?: { ascending?: boolean }): ReadChain;\n limit(count: number): ReadChain;\n maybeSingle(): PromiseLike<ReadAnswer>;\n}\n\n/** The part of a supabase-js v2 client the platform host reads through. */\nexport interface PlatformSupabase {\n auth: {\n getSession(): PromiseLike<{ data: { session: { user: { id: string } } | null }; error: { message: string } | null }>;\n };\n schema(name: string): { from(table: string): { select(columns: string): ReadChain } };\n}\n\n/** Bind the host's client. A value without `auth.getSession` and `schema()` is refused by name. */\nexport function asPlatformSupabase(client: object): PlatformSupabase {\n const c = client as Partial<PlatformSupabase>;\n if (typeof c.schema !== \"function\" || typeof c.auth?.getSession !== \"function\") {\n throw new Error(\n \"[applets/platform] createPlatformHost needs a supabase-js v2 client carrying the viewer's session \" +\n \"(it has no schema() or auth.getSession()).\",\n );\n }\n return c as PlatformSupabase;\n}\n\n/** A read's error as an `AppletError`: the database's own sentence, never paraphrased. */\nexport function readError(error: NonNullable<ReadAnswer[\"error\"]>, code = \"read_failed\"): AppletError {\n const out: AppletError = { code: error.code ? `${code}:${error.code}` : code, message: error.message, retryable: false };\n if (error.details) out.diagnostic = error.details;\n return out;\n}\n\n/** Run a read; a thrown transport error answers `unreachable` (retryable), never throws. */\nexport async function read<T>(chain: PromiseLike<ReadAnswer>, shape: (data: unknown) => T): Promise<Result<T>> {\n try {\n const answer = await chain;\n if (answer.error) return { ok: false, error: readError(answer.error) };\n return { ok: true, data: shape(answer.data) };\n } catch (err) {\n return {\n ok: false,\n error: { code: \"unreachable\", message: err instanceof Error ? err.message : String(err), retryable: true },\n };\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","/**\n * `app.definition` row → `AppletRecord` (CONTRACTS §8). Pure: no client, no I/O.\n */\nimport type { AppletMandate, AppletPage, AppletRecord, AppletSource, Uuid } from \"../types\";\nimport { isRecord } from \"./supabase\";\n\n/** The columns the host reads from `app.definition`. */\nexport const DEFINITION_COLUMNS =\n \"id, version, organization_id, slug, name, status, files, entry, pages, mandates, sources, parent_applet_id, allowed_imports, component_code\";\n\n/** The surface every Applet's own surface sits under when it has no parent Applet (AP-2). */\nexport const APPLET_BASE_SURFACE = \"applets/applet\";\n\nexport const appletSurfaceName = (appletId: Uuid): string => `applets/${appletId}`;\n\nfunction strings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((v): v is string => typeof v === \"string\") : [];\n}\n\nfunction files(value: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (!isRecord(value)) return out;\n for (const [name, source] of Object.entries(value)) if (typeof source === \"string\") out[name] = source;\n return out;\n}\n\nfunction pages(value: unknown): AppletPage[] {\n if (!Array.isArray(value)) return [];\n const out: AppletPage[] = [];\n for (const p of value) {\n if (!isRecord(p) || typeof p.path !== \"string\" || typeof p.file !== \"string\") continue;\n const page: AppletPage = { path: p.path, title: typeof p.title === \"string\" ? p.title : p.path, file: p.file };\n if (typeof p.parent === \"string\") page.parent = p.parent;\n out.push(page);\n }\n return out;\n}\n\nfunction mandates(value: unknown): AppletMandate[] {\n if (!Array.isArray(value)) return [];\n return value.flatMap((m) => (isRecord(m) && typeof m.alias === \"string\" && typeof m.key === \"string\" ? [{ alias: m.alias, key: m.key }] : []));\n}\n\nfunction sources(value: unknown): AppletSource[] {\n if (!Array.isArray(value)) return [];\n const out: AppletSource[] = [];\n for (const s of value) {\n if (!isRecord(s) || typeof s.alias !== \"string\") continue;\n if (typeof s.table_id === \"string\" && typeof s.organization_id === \"string\") {\n out.push({ alias: s.alias, table_id: s.table_id, organization_id: s.organization_id });\n } else if (typeof s.entity === \"string\") {\n out.push({ alias: s.alias, entity: s.entity });\n }\n }\n return out;\n}\n\n/** The record, or the sentence naming what the row lacks. */\nexport function definitionToRecord(row: unknown): { ok: true; record: AppletRecord } | { ok: false; message: string } {\n if (!isRecord(row) || typeof row.id !== \"string\") return { ok: false, message: \"The Applet row has no id.\" };\n if (typeof row.organization_id !== \"string\") return { ok: false, message: `Applet ${row.id} has no organization.` };\n const id = row.id;\n let recordFiles = files(row.files);\n let entry = typeof row.entry === \"string\" && row.entry ? row.entry : \"\";\n let recordPages = pages(row.pages);\n\n // MIGRATION BRIDGE — delete with AP-0's record migration (no-legacy: it dies with the migration).\n // A row that still holds its code only in `component_code` (no `files` / `entry` yet) is read as\n // one file, `App.tsx`, and one page. The migration moves `component_code` into `files` and drops it;\n // the day it runs, this block and the `component_code` column in DEFINITION_COLUMNS go too.\n if ((Object.keys(recordFiles).length === 0 || !entry) && typeof row.component_code === \"string\" && row.component_code) {\n recordFiles = { \"App.tsx\": row.component_code };\n entry = \"App.tsx\";\n if (recordPages.length === 0) {\n recordPages = [{ path: \"/\", title: typeof row.name === \"string\" && row.name ? row.name : \"Home\", file: \"App.tsx\" }];\n }\n }\n // END MIGRATION BRIDGE\n\n if (!entry || recordFiles[entry] === undefined) {\n return { ok: false, message: `Applet ${id} has no entry file to run.` };\n }\n return {\n ok: true,\n record: {\n id,\n version: typeof row.version === \"number\" ? row.version : 1,\n organizationId: row.organization_id,\n slug: typeof row.slug === \"string\" ? row.slug : id,\n published: row.status === \"published\",\n files: recordFiles,\n entry,\n scope: { entries: strings(row.allowed_imports), shadowDangerousGlobals: true },\n pages: recordPages,\n mandates: mandates(row.mandates),\n sources: sources(row.sources),\n parentId: typeof row.parent_applet_id === \"string\" ? row.parent_applet_id : null,\n surfaceName: appletSurfaceName(id),\n },\n };\n}\n"],"mappings":";AAwBA,SAAS,2BAA+C;AAExD,SAAS,iCAAiC;AAC1C,SAAS,2BAA8C;AAEvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA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