@happyvertical/smrt-dev-mcp 0.57.46 → 0.57.48

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"observation-CmDrAP9J.js","names":[],"sources":["../src/tools/runtime/boot.ts","../src/tools/runtime/observation.ts"],"sourcesContent":["/**\n * Confined runtime bootstrap for the Level 2 observation plane (#1831).\n *\n * \"Booting\" here means registering *manifests* into the in-process\n * `ObjectRegistry` — the project's own `.smrt/manifest.json` (or built\n * `dist/manifest.json`) plus every installed SMRT package manifest that the\n * project's dependency tree resolves to. No project source is imported, no\n * module is executed, no database is touched. That confinement is the safety\n * boundary: an observing agent sees what the runtime *would* register, never\n * what arbitrary project code does on import.\n *\n * The registry is a process-global singleton, so a process boots once. There\n * is deliberately no re-boot tool; restart the process to observe a rebuilt\n * manifest.\n */\n\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport {\n importProjectRuntimeModule,\n loadProjectCore,\n ProjectRuntimeResolutionError,\n projectRuntimeRoot,\n resetProjectRuntimeForTests,\n} from './project-runtime.js';\n\n/** Provenance label for facts read from authored/installed manifests. */\nexport const DECLARED_PROVENANCE = 'declared (manifest)';\n\n/** Project manifest candidates, most authoritative first. */\nconst PROJECT_MANIFEST_CANDIDATES = [\n '.smrt/manifest.json',\n 'dist/manifest.json',\n] as const;\n\nexport interface BootDiagnostic {\n severity: 'info' | 'warning' | 'error';\n code: string;\n message: string;\n}\n\nexport interface BootedManifest {\n /** `project` for the project's own manifest, `dependency` for installed packages. */\n kind: 'project' | 'dependency';\n packageName: string | null;\n /** Path relative to the project root (never absolute). */\n path: string;\n objectCount: number;\n}\n\nexport interface RuntimeBoot {\n provenance: typeof DECLARED_PROVENANCE;\n bootedAt: string;\n /** Basename only; the absolute project root never leaves the process. */\n projectName: string;\n manifests: BootedManifest[];\n objectCount: number;\n diagnostics: BootDiagnostic[];\n}\n\ninterface ManifestLike {\n packageName?: unknown;\n moduleType?: unknown;\n objects?: Record<string, unknown>;\n}\n\nfunction relativePath(projectRoot: string, path: string): string {\n const rel = relative(projectRoot, path);\n // Anything outside the root — the parent itself, a `..` walk, or a path on\n // another drive (Windows keeps those absolute) — is reduced to a basename.\n if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {\n return basename(path);\n }\n return rel.split(sep).join('/');\n}\n\nfunction readManifest(path: string): ManifestLike | null {\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as unknown;\n return parsed && typeof parsed === 'object'\n ? (parsed as ManifestLike)\n : null;\n } catch {\n return null;\n }\n}\n\nfunction registerManifest(\n ObjectRegistry: typeof import('@happyvertical/smrt-core').ObjectRegistry,\n manifest: ManifestLike,\n fallbackPackageName: string | null,\n): number {\n const manifestPackageName =\n typeof manifest.packageName === 'string' && manifest.packageName\n ? manifest.packageName\n : (fallbackPackageName ?? undefined);\n let count = 0;\n for (const [name, definition] of Object.entries(manifest.objects ?? {})) {\n if (!definition || typeof definition !== 'object') continue;\n // An aggregate project manifest (consumer plugin output) carries\n // dependency objects that keep their own `packageName`; registering them\n // under the app's name would mint false `@app:Object` identities that\n // collide with the dependency's own manifest. Per-object ownership wins.\n const ownPackage = (definition as { packageName?: unknown }).packageName;\n ObjectRegistry.registerFromManifest(\n name,\n definition as Parameters<typeof ObjectRegistry.registerFromManifest>[1],\n typeof ownPackage === 'string' && ownPackage\n ? ownPackage\n : manifestPackageName,\n );\n count += 1;\n }\n return count;\n}\n\nlet booting: Promise<RuntimeBoot> | null = null;\nlet booted: RuntimeBoot | null = null;\nlet bootedProjectRoot: string | null = null;\nlet bootedProjectManifestPath: string | null = null;\nlet bootedProjectManifestMtimeMs: number | null = null;\n\n/**\n * Whether the project manifest on disk is newer than the one this process\n * booted. The registry is process-global and boots once, so this is the only\n * signal an agent has that a rebuild happened underneath it.\n */\nexport function getBootStaleness(): {\n stale: boolean;\n bootedAt: string | null;\n manifestModifiedAt: string | null;\n} {\n if (!booted || !bootedProjectManifestPath) {\n return {\n stale: false,\n bootedAt: booted?.bootedAt ?? null,\n manifestModifiedAt: null,\n };\n }\n try {\n const mtimeMs = statSync(bootedProjectManifestPath).mtimeMs;\n return {\n stale:\n bootedProjectManifestMtimeMs !== null &&\n mtimeMs > bootedProjectManifestMtimeMs,\n bootedAt: booted.bootedAt,\n manifestModifiedAt: new Date(mtimeMs).toISOString(),\n };\n } catch {\n return {\n stale: false,\n bootedAt: booted.bootedAt,\n manifestModifiedAt: null,\n };\n }\n}\n\n/** The boot record for this process, or `null` before {@link bootRuntime}. */\nexport function getRuntimeBoot(): RuntimeBoot | null {\n return booted;\n}\n\n/**\n * The resolved root the process booted from. Consumers must relativize\n * paths against *this* root, never a per-request argument, or a caller could\n * widen the root (e.g. `/`) and read the layout back through \"relative\" paths.\n */\nexport function getBootedProjectRoot(): string | null {\n return bootedProjectRoot;\n}\n\n/** Test seam: forget the boot record (the registry itself is cleared by the caller). */\nexport function resetRuntimeBootForTests(): void {\n resetProjectRuntimeForTests();\n booting = null;\n booted = null;\n bootedProjectRoot = null;\n bootedProjectManifestPath = null;\n bootedProjectManifestMtimeMs = null;\n}\n\nexport interface BootRuntimeOptions {\n projectRoot?: string;\n /** Clock for `bootedAt` (defaults to `new Date()`). */\n now?: Date;\n}\n\n/**\n * Boot the confined runtime once per process. A second call returns the\n * existing record without touching the registry.\n */\nexport async function bootRuntime(\n options: BootRuntimeOptions = {},\n): Promise<RuntimeBoot> {\n const projectRoot = resolve(options.projectRoot ?? process.cwd());\n if (\n bootedProjectRoot &&\n projectRuntimeRoot(bootedProjectRoot) !== projectRuntimeRoot(projectRoot)\n ) {\n throw new ProjectRuntimeResolutionError(\n '@happyvertical/smrt-core',\n 'runtime_project_mismatch',\n );\n }\n if (booted) return booted;\n if (booting) return booting;\n bootedProjectRoot = projectRoot;\n booting = performBoot(projectRoot, options).catch((error) => {\n booting = null;\n bootedProjectRoot = null;\n throw error;\n });\n return booting;\n}\n\nasync function performBoot(\n projectRoot: string,\n options: BootRuntimeOptions,\n): Promise<RuntimeBoot> {\n const { ObjectRegistry } = await loadProjectCore(projectRoot);\n const { discoverSmrtPackages, resolveManifestPath } =\n await importProjectRuntimeModule<\n typeof import('@happyvertical/smrt-core/manifest/discover-smrt-packages')\n >(projectRoot, '@happyvertical/smrt-core/manifest/discover-smrt-packages');\n if (\n typeof ObjectRegistry?.registerFromManifest !== 'function' ||\n typeof discoverSmrtPackages !== 'function' ||\n typeof resolveManifestPath !== 'function'\n ) {\n throw new ProjectRuntimeResolutionError('@happyvertical/smrt-core');\n }\n const diagnostics: BootDiagnostic[] = [];\n const manifests: BootedManifest[] = [];\n\n const projectManifestPath = PROJECT_MANIFEST_CANDIDATES.map((candidate) =>\n join(projectRoot, candidate),\n ).find((path) => existsSync(path));\n const projectPackageName = readProjectPackageName(projectRoot);\n\n if (!projectManifestPath) {\n diagnostics.push({\n severity: 'warning',\n code: 'project_manifest_missing',\n message:\n 'No project manifest found (.smrt/manifest.json or dist/manifest.json); run the project build so the runtime manifest exists.',\n });\n } else {\n const manifest = readManifest(projectManifestPath);\n if (!manifest) {\n diagnostics.push({\n severity: 'error',\n code: 'project_manifest_invalid',\n message: `Project manifest at ${relativePath(projectRoot, projectManifestPath)} is not valid JSON.`,\n });\n } else {\n manifests.push({\n kind: 'project',\n packageName:\n typeof manifest.packageName === 'string'\n ? manifest.packageName\n : projectPackageName,\n path: relativePath(projectRoot, projectManifestPath),\n objectCount: registerManifest(\n ObjectRegistry,\n manifest,\n projectPackageName,\n ),\n });\n }\n }\n\n let dependencyNames: string[] = [];\n try {\n // `noCache` keeps discovery from writing `.smrt/discovery-cache.json`:\n // observing a project must never dirty it.\n dependencyNames = discoverSmrtPackages({\n baseDir: projectRoot,\n noCache: true,\n });\n } catch (error) {\n diagnostics.push({\n severity: 'warning',\n code: 'dependency_discovery_failed',\n message: `Installed SMRT package discovery failed: ${error instanceof Error ? error.message : 'unknown error'}`,\n });\n }\n for (const dependency of dependencyNames.sort()) {\n const manifestPath = resolveManifestPath(dependency, projectRoot);\n if (!manifestPath) {\n diagnostics.push({\n severity: 'info',\n code: 'dependency_manifest_missing',\n message: `Installed SMRT package ${dependency} exposes no runtime manifest.`,\n });\n continue;\n }\n const manifest = readManifest(manifestPath);\n if (!manifest) {\n diagnostics.push({\n severity: 'warning',\n code: 'dependency_manifest_invalid',\n message: `Manifest for ${dependency} is not valid JSON.`,\n });\n continue;\n }\n manifests.push({\n kind: 'dependency',\n packageName: dependency,\n path: relativePath(projectRoot, manifestPath),\n objectCount: registerManifest(ObjectRegistry, manifest, dependency),\n });\n }\n\n bootedProjectRoot = projectRoot;\n if (projectManifestPath) {\n bootedProjectManifestPath = projectManifestPath;\n try {\n bootedProjectManifestMtimeMs = statSync(projectManifestPath).mtimeMs;\n } catch {\n bootedProjectManifestMtimeMs = null;\n }\n }\n booted = {\n provenance: DECLARED_PROVENANCE,\n bootedAt: (options.now ?? new Date()).toISOString(),\n projectName: projectPackageName ?? basename(projectRoot),\n manifests,\n objectCount: manifests.reduce((sum, m) => sum + m.objectCount, 0),\n diagnostics,\n };\n return booted;\n}\n\nfunction readProjectPackageName(projectRoot: string): string | null {\n try {\n const parsed = JSON.parse(\n readFileSync(join(projectRoot, 'package.json'), 'utf8'),\n ) as { name?: unknown };\n return typeof parsed.name === 'string' && parsed.name ? parsed.name : null;\n } catch {\n return null;\n }\n}\n","/**\n * Level 2 read-only observation tools over the booted runtime (#1831).\n *\n * Three facts planes, labelled separately in every envelope:\n * - `declared (manifest)`: what the confined boot registered ({@link bootRuntime});\n * - `booted (registry)`: the in-process `ObjectRegistry` projected through the\n * sanitized {@link snapshotRegistry} DTO;\n * - `runtime (live DB)`: the optional read-only connection, reused from Level 1.\n *\n * Nothing here mutates: no writes, no `do()`, no generated CRUD, no project\n * code execution. `runtime-schema-diff` only *introspects* the live schema.\n */\n\nimport type { RegistrySnapshotObject } from '@happyvertical/smrt-core';\nimport {\n bootRuntime,\n getBootedProjectRoot,\n getBootStaleness,\n type RuntimeBoot,\n} from './boot.js';\nimport type { RuntimeDatabaseArgs } from './connection.js';\nimport {\n importProjectRuntimeModule,\n loadProjectCore,\n ProjectRuntimeResolutionError,\n} from './project-runtime.js';\nimport {\n type RuntimeDiagnostic,\n type RuntimeToolEnvelope,\n withRuntimeConnection,\n withRuntimeSetup,\n} from './tools.js';\n\n/** Row budget for `runtime-schema-diff` change lists. */\nconst SCHEMA_DIFF_CHANGE_LIMIT = 200;\n\nexport interface RuntimeProjectArgs {\n /** Project root to boot from (defaults to the server's cwd). */\n projectPath?: string;\n}\n\nfunction bootDiagnostics(boot: RuntimeBoot): RuntimeDiagnostic[] {\n return boot.diagnostics\n .filter((d) => d.severity !== 'info')\n .map((d) => ({\n severity: d.severity === 'error' ? 'warning' : d.severity,\n code: `boot_${d.code}`,\n message: d.message,\n }));\n}\n\nlet bootPreambleSent = false;\n\n/**\n * The full manifest list is emitted once per process; later envelopes carry\n * only the identifying fields. Every runtime response re-embedding the same\n * multi-manifest block was pure repetition for an agent.\n */\nfunction bootSummary(boot: RuntimeBoot) {\n const compact = {\n provenance: boot.provenance,\n bootedAt: boot.bootedAt,\n projectName: boot.projectName,\n objectCount: boot.objectCount,\n manifestCount: boot.manifests.length,\n };\n if (bootPreambleSent) return compact;\n bootPreambleSent = true;\n return { ...compact, manifests: boot.manifests };\n}\n\n/** Test seam paired with `resetRuntimeBootForTests()`. */\nexport function resetBootPreambleForTests(): void {\n bootPreambleSent = false;\n}\n\nfunction stalenessDiagnostics(): RuntimeDiagnostic[] {\n const staleness = getBootStaleness();\n if (!staleness.stale) return [];\n return [\n {\n severity: 'warning',\n code: 'manifest_newer_than_boot',\n message: `The project manifest changed at ${staleness.manifestModifiedAt} after this process booted at ${staleness.bootedAt}; restart the server to observe the rebuilt registry.`,\n },\n ];\n}\n\nexport interface RuntimeRegistryArgs extends RuntimeProjectArgs {\n /** Restrict object detail to these simple or qualified names. */\n objects?: string[];\n /** Include field/method detail (default: only when `objects` is given). */\n detail?: boolean;\n /**\n * Resume after this object key: the qualified name when the object has\n * one, otherwise its simple name — exactly the value a previous response\n * returned as `page.nextCursor` (#2779). Objects are sorted by that key.\n */\n cursor?: string;\n /** Objects per page (default {@link REGISTRY_PAGE_LIMIT}, max 500). */\n limit?: number;\n}\n\n/** Default objects per `runtime-registry` page. */\nexport const REGISTRY_PAGE_LIMIT = 50;\n\nfunction objectKey(object: {\n qualifiedName: string | null;\n name: string;\n}): string {\n return object.qualifiedName ?? object.name;\n}\n\n/** `runtime-registry`: sanitized snapshot of the booted registry. */\nasync function runtimeRegistryFromProject(\n args: RuntimeRegistryArgs = {},\n): Promise<RuntimeToolEnvelope> {\n const boot = await bootRuntime({ projectRoot: args.projectPath });\n const { snapshotRegistry } = await loadProjectCore(args.projectPath);\n // Paths are relativized against the root the process actually booted from,\n // never the per-request argument (which is ignored after the first boot).\n if (typeof snapshotRegistry !== 'function')\n throw new ProjectRuntimeResolutionError('@happyvertical/smrt-core');\n const snapshot = snapshotRegistry({\n projectRoot: getBootedProjectRoot() ?? undefined,\n objects: args.objects,\n detail: args.detail ?? Boolean(args.objects?.length),\n });\n // Page the object list (summary stays global). A 76-object app answered in\n // 56 KB before paging; an agent hunting one class needs a cursor, not a cut.\n const limit = Math.min(\n Math.max(Math.floor(args.limit ?? REGISTRY_PAGE_LIMIT), 1),\n 500,\n );\n // The cursor is compared against the same key `page.nextCursor` carries.\n const cursor =\n typeof args.cursor === 'string' && args.cursor.length > 0\n ? args.cursor\n : null;\n const all = snapshot.objects;\n const afterCursor = cursor\n ? all.filter((object) => objectKey(object).localeCompare(cursor) > 0)\n : all;\n const objects = afterCursor.slice(0, limit);\n const nextCursor =\n afterCursor.length > objects.length && objects.length > 0\n ? objectKey(objects[objects.length - 1])\n : null;\n return {\n ok: true,\n coverage: null,\n diagnostics: [...bootDiagnostics(boot), ...stalenessDiagnostics()],\n data: {\n provenance: snapshot.provenance,\n boot: bootSummary(boot),\n page: {\n returned: objects.length,\n matched: all.length,\n limit,\n cursor,\n nextCursor,\n },\n snapshot: { ...snapshot, objects },\n },\n };\n}\n\nexport interface RuntimeObjectArgs extends RuntimeProjectArgs {\n /** Simple or qualified object name. */\n name: string;\n /** Engine for the generated DDL preview (default: the registry's default). */\n engine?: 'sqlite' | 'postgres' | 'duckdb';\n}\n\n/** `runtime-object`: one object's sanitized definition plus its generated DDL. */\nasync function runtimeObjectFromProject(\n args: RuntimeObjectArgs,\n): Promise<RuntimeToolEnvelope> {\n const boot = await bootRuntime({ projectRoot: args.projectPath });\n const { ObjectRegistry, snapshotRegistry } = await loadProjectCore(\n args.projectPath,\n );\n const name = typeof args.name === 'string' ? args.name.trim() : '';\n if (typeof snapshotRegistry !== 'function')\n throw new ProjectRuntimeResolutionError('@happyvertical/smrt-core');\n const snapshot = snapshotRegistry({\n projectRoot: getBootedProjectRoot() ?? undefined,\n objects: name ? [name] : [],\n detail: true,\n });\n const diagnostics = [...bootDiagnostics(boot), ...stalenessDiagnostics()];\n let object: RegistrySnapshotObject | null = snapshot.objects[0] ?? null;\n if (snapshot.objects.length > 1) {\n // Two packages registering the same simple name is legal; picking one\n // silently would misreport identity. Ask for the qualified name instead.\n object = null;\n diagnostics.push({\n severity: 'warning',\n code: 'object_ambiguous',\n message: `${name} is registered by several packages; pass a qualified name: ${snapshot.objects\n .map((candidate) => candidate.qualifiedName ?? candidate.name)\n .join(', ')}`,\n });\n } else if (!object) {\n diagnostics.push({\n severity: 'warning',\n code: 'object_not_found',\n message: name\n ? `No booted object named ${name}; use runtime-registry to list names.`\n : 'name is required.',\n });\n }\n let ddl: string | null = null;\n if (object) {\n try {\n // Resolve by qualified identity so a same-name class in another package\n // can never answer for this one.\n ddl =\n ObjectRegistry.getSchemaDDL(\n object.qualifiedName ?? object.name,\n args.engine,\n ) ?? null;\n } catch (error) {\n diagnostics.push({\n severity: 'warning',\n code: 'ddl_unavailable',\n message: `Generated DDL unavailable: ${error instanceof Error ? error.message : 'unknown error'}`,\n });\n }\n }\n return {\n ok: true,\n coverage: null,\n diagnostics,\n data: {\n provenance: snapshot.provenance,\n boot: bootSummary(boot),\n object,\n ddl,\n },\n };\n}\n\nexport interface RuntimeSchemaDiffArgs\n extends RuntimeDatabaseArgs,\n RuntimeProjectArgs {}\n\n/**\n * `runtime-schema-diff`: booted registry schemas versus the live database,\n * using the same comparer `db:diff`/`db:migrate` use. Introspection only —\n * drop/relax options are pinned off and nothing is executed.\n */\nasync function runtimeSchemaDiffFromProject(\n args: RuntimeSchemaDiffArgs = {},\n): Promise<RuntimeToolEnvelope> {\n const boot = await bootRuntime({ projectRoot: args.projectPath });\n const { ObjectRegistry } = await loadProjectCore(args.projectPath);\n const envelope = await withRuntimeConnection(\n args,\n async (db) => {\n const { SchemaComparer } = await importProjectRuntimeModule<\n typeof import('@happyvertical/smrt-core/migrations')\n >(args.projectPath, '@happyvertical/smrt-core/migrations');\n if (typeof SchemaComparer !== 'function')\n throw new ProjectRuntimeResolutionError(\n '@happyvertical/smrt-core/migrations',\n );\n const comparer = new SchemaComparer(\n db as ConstructorParameters<typeof SchemaComparer>[0],\n {\n includeDroppedTables: false,\n includeDroppedColumns: false,\n includeDroppedIndexes: false,\n relaxColumns: false,\n },\n );\n const diff = await comparer.compare(\n ObjectRegistry.getAllSchemasAsDefinitions(),\n );\n const byType: Record<string, number> = {};\n for (const change of diff.changes) {\n const type = String((change as { type?: unknown }).type ?? 'unknown');\n byType[type] = (byType[type] ?? 0) + 1;\n }\n // `hasChanges` covers table adds/drops too; count them so the two agree.\n const addedTables = diff.added_tables.map((t) => t.tableName);\n if (addedTables.length > 0) byType.add_table = addedTables.length;\n if (diff.dropped_tables.length > 0)\n byType.drop_table = diff.dropped_tables.length;\n const changeCount =\n diff.changes.length + addedTables.length + diff.dropped_tables.length;\n return {\n data: {\n boot: bootSummary(boot),\n hasChanges: diff.has_changes,\n addedTables,\n droppedTables: diff.dropped_tables,\n orphanTables: diff.orphan_tables ?? [],\n changeCount,\n columnChangeCount: diff.changes.length,\n changesByType: byType,\n changes: diff.changes.slice(0, SCHEMA_DIFF_CHANGE_LIMIT),\n truncated: diff.changes.length > SCHEMA_DIFF_CHANGE_LIMIT,\n },\n diagnostics: [],\n };\n },\n 'booted registry schemas only; connect a dev database to diff against live tables',\n );\n envelope.diagnostics = [\n ...bootDiagnostics(boot),\n ...stalenessDiagnostics(),\n ...envelope.diagnostics,\n ];\n return envelope;\n}\n\nexport const runtimeRegistry = (args: RuntimeRegistryArgs = {}) =>\n withRuntimeSetup(() => runtimeRegistryFromProject(args));\nexport const runtimeObject = (args: RuntimeObjectArgs) =>\n withRuntimeSetup(() => runtimeObjectFromProject(args));\nexport const runtimeSchemaDiff = (args: RuntimeSchemaDiffArgs = {}) =>\n withRuntimeSetup(() => runtimeSchemaDiffFromProject(args));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,IAAa,sBAAsB;;AAGnC,IAAM,8BAA8B,CAClC,uBACA,oBACF;AAiCA,SAAS,aAAa,aAAqB,MAAsB;CAC/D,MAAM,MAAM,SAAS,aAAa,IAAI;CAGtC,IAAI,QAAQ,QAAQ,IAAI,WAAW,KAAK,KAAK,KAAK,WAAW,GAAG,GAC9D,OAAO,SAAS,IAAI;CAEtB,OAAO,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;AAChC;AAEA,SAAS,aAAa,MAAmC;CACvD,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EACpD,OAAO,UAAU,OAAO,WAAW,WAC9B,SACD;CACN,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,iBACP,gBACA,UACA,qBACQ;CACR,MAAM,sBACJ,OAAO,SAAS,gBAAgB,YAAY,SAAS,cACjD,SAAS,cACR,uBAAuB,KAAA;CAC9B,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,SAAS,WAAW,CAAC,CAAC,GAAG;EACv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