@dot-agent/compiler 0.10.2 → 0.12.0-alpha.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dot-agent/compiler",
3
- "version": "0.10.2",
3
+ "version": "0.12.0-alpha.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Compiler for the dot-agent DSL: AST parsing, linting, graph extraction and .agent packaging",
6
6
  "author": {
@@ -79,10 +79,10 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@clack/prompts": "^1.7.0",
82
- "@dot-agent/parser-dsl": "0.10.2",
83
- "@dot-agent/tree-sitter": "0.10.1",
84
- "jszip": "^3.10.1",
85
- "web-tree-sitter": "^0.26.9"
82
+ "@dot-agent/parser-dsl": "0.12.0-alpha.0",
83
+ "@dot-agent/tree-sitter": "0.12.0-alpha.0",
84
+ "jszip": "^3.10.2",
85
+ "web-tree-sitter": "^0.27.0"
86
86
  },
87
87
  "publishConfig": {
88
88
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace-0cuKn3-s.cjs","names":["JSZip"],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.10.2'\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is bundled but unreachable (see pack.ts's W016).\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath.startsWith(`${ns}/`)) ?? null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,mBAAmB;;;ACShC,SAAgB,aAAa,MAAoB;CAC/C,IAAI,CAAC,KAAK,YAAY,MAAM,IAAI,MAAM,oCAAoC;CAC1E,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,4BAA4B;CAC1D,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,MAAM,8BAA8B;CAC9D,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,MAAM,qCAAqC;CAC5E,IAAI,CAAC,KAAK,QAAQ,MAAM,IAAI,MAAM,gCAAgC;CAClE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,kCAAkC;CACtE,IAAI,CAAC,MAAM,QAAQ,KAAK,YAAY,GAAG,MAAM,IAAI,MAAM,4CAA4C;CACnG,IAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,GAAG,MAAM,IAAI,MAAM,wCAAwC;CAC3F,IAAI,CAAC,KAAK,WAAW,MAAM,IAAI,MAAM,mCAAmC;CAExE,OAAO;EACL,YAAY,KAAK;EACjB,IAAI,KAAK;EACT,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,SAAS,KAAK,WAAW;EACzB,QAAQ,KAAK;EACb,SAAS,KAAK,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,IAAI,IAAoB;CACtC,MAAM,WAA4B,CAAC;CAEnC,IAAI,SAAS,cAAc,SAAS;EAClC,IAAI,KAAK,KAAK;EACd,IAAI,UAAU,CAAC,OAAO,MAAK,MAAK,aAAa,WAAW,CAAC,CAAC,GAAG;EAC7D,SAAS,KACP,KAAK,MAAM,MAAM,CAAC,CAAC,MAAK,YAAW;GACjC,MAAM,IAAI,cAAc,OAAO;EACjC,CAAC,CACH;CACF,CAAC;CAED,MAAM,QAAQ,IAAI,QAAQ;CAC1B,OAAO;AACT;;;AC5CA,MAAa,qBAAqB,CAAC,UAAU,WAAW;AAGxD,SAAgB,qBAAqB,YAA6B;CAChE,OAAO,oBAAoB,UAAU,MAAM;AAC7C;AAEA,SAAgB,oBAAoB,YAA6C;CAC/E,OAAO,mBAAmB,MAAK,OAAM,WAAW,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK;AAC3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"namespace-CjeG5-7u.mjs","names":[],"sources":["../src/generated-version.ts","../src/manifest.ts","../src/id.ts","../src/zip-core.ts","../src/namespace.ts"],"sourcesContent":["// Generated by scripts/embed-version.mjs from dsl/VERSION and package.json — do not edit by hand.\nexport const DSL_VERSION = '0.1'\nexport const COMPILER_VERSION = '0.10.2'\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\nimport type { AboutMe, BuildAboutmeOptions } from './types.js'\nimport { DSL_VERSION } from './generated-version.js'\n\nexport function parseAboutme(json: any): AboutMe {\n if (!json.dslVersion) throw new Error('Missing dslVersion in aboutme.json')\n if (!json.id) throw new Error('Missing id in aboutme.json')\n if (!json.name) throw new Error('Missing name in aboutme.json')\n if (!json.description) throw new Error('Missing description in aboutme.json')\n if (!json.domain) throw new Error('Missing domain in aboutme.json')\n if (!json.compiler) throw new Error('Missing compiler in aboutme.json')\n if (!Array.isArray(json.capabilities)) throw new Error('Missing capabilities array in aboutme.json')\n if (!Array.isArray(json.requires)) throw new Error('Missing requires array in aboutme.json')\n if (!json.integrity) throw new Error('Missing integrity in aboutme.json')\n\n return {\n dslVersion: json.dslVersion,\n id: json.id,\n name: json.name,\n description: json.description,\n version: json.version ?? '',\n domain: json.domain,\n license: json.license ?? '',\n persona: json.persona,\n purpose: json.purpose ?? 'unknown',\n compiler: json.compiler,\n commit: json.commit,\n capabilities: json.capabilities,\n requires: json.requires,\n integrity: json.integrity,\n }\n}\n\nexport function buildAboutme(opts: BuildAboutmeOptions): AboutMe {\n return {\n dslVersion: `dot-agent/${DSL_VERSION}`,\n id: opts.id,\n name: opts.name,\n description: opts.description,\n version: opts.version,\n domain: opts.domain,\n license: opts.license ?? '',\n persona: opts.persona,\n purpose: opts.purpose ?? 'unknown',\n compiler: opts.compiler,\n commit: opts.commit,\n capabilities: opts.capabilities ?? [],\n requires: opts.requires ?? [],\n integrity: opts.integrity,\n }\n}\n\nexport function aboutmeToJson(aboutme: AboutMe): string {\n return JSON.stringify(aboutme, null, 2)\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { IdParts } from './types.js'\n\n// Code hosting platforms whose namespace format is platform/user rather than plain domain.\n// The list is maintained by the compiler and updated via CLI releases.\nexport const KNOWN_PLATFORMS = ['github.com', 'gitlab.com', 'codeberg.org', 'sr.ht'] as const\n\nfunction parseNamespaceName(identifier: string): { namespace: string; name: string } {\n // Email namespace: @ appears before any /\n const atIdx = identifier.indexOf('@')\n if (atIdx !== -1 && (identifier.indexOf('/') === -1 || atIdx < identifier.indexOf('/'))) {\n const slashIdx = identifier.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`)\n }\n return {\n namespace: identifier.slice(0, slashIdx),\n name: identifier.slice(slashIdx + 1),\n }\n }\n\n // Known code-hosting platforms: namespace is platform/user, name is the next segment.\n for (const platform of KNOWN_PLATFORMS) {\n if (identifier.startsWith(platform + '/')) {\n const afterPlatform = identifier.slice(platform.length + 1)\n const slashIdx = afterPlatform.indexOf('/')\n if (slashIdx === -1) {\n throw new Error(\n `Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`,\n )\n }\n return {\n namespace: platform + '/' + afterPlatform.slice(0, slashIdx),\n name: afterPlatform.slice(slashIdx + 1),\n }\n }\n }\n\n // Domain or reserved keyword (e.g. 'unknown'): last '/' separates namespace from name.\n const lastSlash = identifier.lastIndexOf('/')\n if (lastSlash === -1) {\n throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`)\n }\n return {\n namespace: identifier.slice(0, lastSlash),\n name: identifier.slice(lastSlash + 1),\n }\n}\n\nexport function parseId(id: string): IdParts {\n if (!id) throw new Error('Invalid agent ID: empty string')\n\n // Phase 1: split on the first ':' to isolate the identifier from version~digest.\n const colonIdx = id.indexOf(':')\n\n let identifier: string\n let version: string | undefined\n let digest: string | undefined\n\n if (colonIdx === -1) {\n // Form A: namespace/name\n identifier = id\n } else {\n identifier = id.slice(0, colonIdx)\n const rest = id.slice(colonIdx + 1)\n if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`)\n\n // Phase 2: split version~digest\n const tildeIdx = rest.indexOf('~')\n if (tildeIdx === -1) {\n // Form B: namespace/name:version\n version = rest\n } else {\n // Form D: namespace/name:version~digest\n version = rest.slice(0, tildeIdx)\n digest = rest.slice(tildeIdx + 1)\n if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`)\n if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`)\n }\n }\n\n // Phase 3: extract namespace and name from the identifier\n const { namespace, name } = parseNamespaceName(identifier)\n\n if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`)\n if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`)\n\n return { namespace, name, version, digest }\n}\n\nexport function buildId(parts: IdParts): string {\n const { namespace, name, version, digest } = parts\n if (!namespace || !name) {\n throw new Error('Missing required ID parts: namespace and name')\n }\n if (digest && !version) {\n throw new Error('Invalid ID parts: digest requires version')\n }\n let result = `${namespace}/${name}`\n if (version) {\n result += `:${version}`\n if (digest) result += `~${digest}`\n }\n // Ids are always lowercase — domains, platform usernames (GitHub/GitLab/\n // Codeberg/Sourcehut) and email local-parts are all case-insensitive in\n // practice, so normalizing here is safe and gives every id a single shape.\n return result.toLowerCase()\n}\n\n// Turns a human display name (e.g. \"Fridge Assistant\", from `agent Fridge\n// Assistant` in the DSL — spaces/capitalization are deliberate there) into\n// the kebab-case slug used for an id's name segment.\nexport function slugify(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n}\n\n// Accepts optional leading 'v' (id spec examples use it; monorepo tags after\n// their '@' split don't), 1-3 dot-separated numeric groups, and optional\n// -prerelease / +build suffixes — e.g. v1.0, 2.3.1, v1.0.0-alpha.1, 1.0+build.\nconst VERSION_RE = /^v?\\d+(\\.\\d+){0,2}(-[0-9A-Za-z.]+)?(\\+[0-9A-Za-z.]+)?$/i\n\nexport function isValidVersion(version: string): boolean {\n return VERSION_RE.test(version)\n}\n\nexport function extractDigest(id: string): string {\n try {\n return parseId(id).digest ?? ''\n } catch {\n return ''\n }\n}\n\nexport function extractName(id: string): string {\n try {\n return parseId(id).name\n } catch {\n return ''\n }\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport JSZip from 'jszip'\n\nexport const MAX_ZIP_SIZE = 500 * 1024 * 1024\nexport const MAX_COMPRESSION_RATIO = 100\n\nexport function validateMagicBytes(bytes: Uint8Array): void {\n if (!(bytes[0] === 0x50 && bytes[1] === 0x4b && bytes[2] === 0x03 && bytes[3] === 0x04)) {\n throw new Error('Not a valid .agent file (invalid magic bytes)')\n }\n}\n\nexport function validateZipBomb(zip: JSZip, compressedSize: number): void {\n let totalUncompressed = 0\n zip.forEach((_path, file) => {\n if (!file.dir) totalUncompressed += (file as any)._data?.uncompressedSize || 0\n })\n if (totalUncompressed > MAX_ZIP_SIZE) {\n throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`)\n }\n if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {\n throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`)\n }\n}\n\nexport function createZip(): JSZip {\n return new JSZip()\n}\n\nexport async function extractFiles(zip: JSZip, filter?: string[]): Promise<Map<string, string>> {\n const files = new Map<string, string>()\n const promises: Promise<void>[] = []\n\n zip.forEach((relativePath, file) => {\n if (file.dir) return\n if (filter && !filter.some(f => relativePath.startsWith(f))) return\n promises.push(\n file.async('text').then(content => {\n files.set(relativePath, content)\n })\n )\n })\n\n await Promise.all(promises)\n return files\n}\n","// Copyright 2026 Danilo Borges\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n\n// The two directories the runtime can actually serve content from: pack.ts's\n// collectFiles() bundles a guide/teach reference at its literal path, but\n// bundle.ts, sdk/load.ts, and the CLI's MCP resource handlers each classify a\n// bundled file into guides/knowledge purely by this prefix — a reference\n// resolving outside them is bundled but unreachable (see pack.ts's W016).\n// Single source of truth so the three sites can't drift on the prefix list.\nexport const CONTENT_NAMESPACES = ['guides', 'knowledge'] as const\nexport type ContentNamespace = (typeof CONTENT_NAMESPACES)[number]\n\nexport function isInContentNamespace(bundlePath: string): boolean {\n return classifyContentPath(bundlePath) !== null\n}\n\nexport function classifyContentPath(bundlePath: string): ContentNamespace | null {\n return CONTENT_NAMESPACES.find(ns => bundlePath.startsWith(`${ns}/`)) ?? null\n}\n"],"mappings":";;AAEA,MAAa,mBAAmB;;;ACShC,SAAgB,aAAa,MAAoB;CAC/C,IAAI,CAAC,KAAK,YAAY,MAAM,IAAI,MAAM,oCAAoC;CAC1E,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,4BAA4B;CAC1D,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,MAAM,8BAA8B;CAC9D,IAAI,CAAC,KAAK,aAAa,MAAM,IAAI,MAAM,qCAAqC;CAC5E,IAAI,CAAC,KAAK,QAAQ,MAAM,IAAI,MAAM,gCAAgC;CAClE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,kCAAkC;CACtE,IAAI,CAAC,MAAM,QAAQ,KAAK,YAAY,GAAG,MAAM,IAAI,MAAM,4CAA4C;CACnG,IAAI,CAAC,MAAM,QAAQ,KAAK,QAAQ,GAAG,MAAM,IAAI,MAAM,wCAAwC;CAC3F,IAAI,CAAC,KAAK,WAAW,MAAM,IAAI,MAAM,mCAAmC;CAExE,OAAO;EACL,YAAY,KAAK;EACjB,IAAI,KAAK;EACT,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,SAAS,KAAK,WAAW;EACzB,QAAQ,KAAK;EACb,SAAS,KAAK,WAAW;EACzB,SAAS,KAAK;EACd,SAAS,KAAK,WAAW;EACzB,UAAU,KAAK;EACf,QAAQ,KAAK;EACb,cAAc,KAAK;EACnB,UAAU,KAAK;EACf,WAAW,KAAK;CAClB;A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