{"version":3,"file":"manifest-D8UTRohY.mjs","names":[],"sources":["../src/batteries/skills/exceptions.ts","../src/batteries/skills/manifest.ts"],"sourcesContent":["import { isError } from '@nhtio/adk/guards'\nimport { createException } from '@nhtio/adk/factories'\n\n/** Fatal construction error for invalid or unsafe-to-resolve manager configuration. */\nexport const E_INVALID_SKILLS_CONFIG = createException<[string]>(\n  'E_INVALID_SKILLS_CONFIG',\n  'Invalid skills config: %s',\n  'E_INVALID_SKILLS_CONFIG',\n  529,\n  true\n)\n/** Raised when load, refresh, or unload names no winning catalog entry. */\nexport const E_SKILL_NOT_FOUND = createException<[string]>(\n  'E_SKILL_NOT_FOUND',\n  'Skill not found: %s',\n  'E_SKILL_NOT_FOUND',\n  422,\n  false\n)\n/** Raised when load would initialize a skill that is already initialized. */\nexport const E_SKILL_ALREADY_LOADED = createException<[string]>(\n  'E_SKILL_ALREADY_LOADED',\n  'Skill already loaded: %s',\n  'E_SKILL_ALREADY_LOADED',\n  422,\n  false\n)\n/** Raised when unload or a loaded-only operation targets an uninitialized skill. */\nexport const E_SKILL_NOT_LOADED = createException<[string]>(\n  'E_SKILL_NOT_LOADED',\n  'Skill not loaded: %s',\n  'E_SKILL_NOT_LOADED',\n  422,\n  false\n)\n/** Raised when source metadata or a descriptor violates the identity/version contract. */\nexport const E_SKILL_MANIFEST_INVALID = createException<[string]>(\n  'E_SKILL_MANIFEST_INVALID',\n  'Invalid skill manifest: %s',\n  'E_SKILL_MANIFEST_INVALID',\n  422,\n  false\n)\n/** Raised when a skill tool name collides with another registered tool. */\nexport const E_SKILL_TOOL_COLLISION = createException<[string]>(\n  'E_SKILL_TOOL_COLLISION',\n  'Skill tool collision: %s',\n  'E_SKILL_TOOL_COLLISION',\n  422,\n  false\n)\n/** Raised when one skill declares the same tool name more than once. */\nexport const E_SKILL_TOOL_DUPLICATE = createException<[string]>(\n  'E_SKILL_TOOL_DUPLICATE',\n  'Duplicate skill tool: %s',\n  'E_SKILL_TOOL_DUPLICATE',\n  422,\n  false\n)\n/** Raised when a skill tool handler fails during execution. */\nexport const E_SKILL_TOOL_FAILED = createException<[string, string]>(\n  'E_SKILL_TOOL_FAILED',\n  'Skill tool \"%s\" failed: %s',\n  'E_SKILL_TOOL_FAILED',\n  500,\n  false\n)\n/** Raised when a skill tool returns a value that fails response validation. */\nexport const E_SKILL_TOOL_BAD_RESPONSE = createException<[string]>(\n  'E_SKILL_TOOL_BAD_RESPONSE',\n  'Invalid response from skill tool: %s',\n  'E_SKILL_TOOL_BAD_RESPONSE',\n  422,\n  false\n)\n/** Raised when the selected artifact kind was not registered. */\nexport const E_SKILL_ARTIFACT_UNAVAILABLE = createException<[string]>(\n  'E_SKILL_ARTIFACT_UNAVAILABLE',\n  'Skill artifact kind unavailable: %s',\n  'E_SKILL_ARTIFACT_UNAVAILABLE',\n  422,\n  false\n)\n/** Raised when a requested bundled path is unsafe or outside the source namespace. */\nexport const E_SKILL_SOURCE_PATH_REJECTED = createException<[string]>(\n  'E_SKILL_SOURCE_PATH_REJECTED',\n  'Skill source path rejected: %s',\n  'E_SKILL_SOURCE_PATH_REJECTED',\n  422,\n  false\n)\n/** Explicit 403 refusal by the script policy; this is distinct from a failed gate. */\nexport const E_SKILL_SCRIPT_DENIED = createException<[string]>(\n  'E_SKILL_SCRIPT_DENIED',\n  'Skill script denied: %s',\n  'E_SKILL_SCRIPT_DENIED',\n  403,\n  false\n)\n/** 503 when the script gate fails for any reason other than an explicit denial; never misroutes an engine failure as 403. */\nexport const E_SKILL_SCRIPT_GATE_UNAVAILABLE = createException<[string]>(\n  'E_SKILL_SCRIPT_GATE_UNAVAILABLE',\n  'Skill script gate unavailable: %s',\n  'E_SKILL_SCRIPT_GATE_UNAVAILABLE',\n  503,\n  false\n)\n/** Raised when script policy derivation would widen permissions beyond the declared boundary. */\nexport const E_SKILL_SCRIPT_POLICY_WIDENED = createException<[string]>(\n  'E_SKILL_SCRIPT_POLICY_WIDENED',\n  'Skill script policy widened: %s',\n  'E_SKILL_SCRIPT_POLICY_WIDENED',\n  500,\n  false\n)\n/** Raised when a script exceeds its configured execution deadline. */\nexport const E_SKILL_SCRIPT_TIMEOUT = createException<[string]>(\n  'E_SKILL_SCRIPT_TIMEOUT',\n  'Skill script timed out: %s',\n  'E_SKILL_SCRIPT_TIMEOUT',\n  422,\n  false\n)\n/**\n * Raised when a skill script completes with a nonzero exit code and the deployment leaves\n * `SkillScriptConfig.failOnNonzeroExit` at its default (`true`). The message carries the script\n * name, the exit code, and the retrievable id of the spooled output so the failure is still\n * inspectable. A deployment whose scripts use exit codes as ordinary signalling sets\n * `failOnNonzeroExit: false` and receives the acknowledgement string instead.\n */\nexport const E_SKILL_SCRIPT_FAILED = createException<[string, string]>(\n  'E_SKILL_SCRIPT_FAILED',\n  'Skill script \"%s\" failed: %s',\n  'E_SKILL_SCRIPT_FAILED',\n  422,\n  false\n)\n/** Raised when materialization or disposal of a skill workspace fails. */\nexport const E_SKILL_WORKSPACE_FAILED = createException<[string]>(\n  'E_SKILL_WORKSPACE_FAILED',\n  'Skill workspace failed: %s',\n  'E_SKILL_WORKSPACE_FAILED',\n  500,\n  false\n)\n\nconst failure = (code: string, message: string): string => `Error (${code}): ${message}`\n\n/** Render skill runtime errors for the model; configuration errors remain fatal. */\nexport const renderError = (err: unknown): string => {\n  if (isError(err) && err.name.startsWith('E_SKILL_')) {\n    return failure(err.name.replace(/^E_SKILL_/, ''), err.message)\n  }\n  throw err\n}\n","import { default as yaml } from 'js-yaml'\nimport { isError } from '@nhtio/adk/guards'\nimport { E_SKILL_MANIFEST_INVALID } from './exceptions'\n\n/**\n * Parse an agentskills.io-shaped SKILL.md for source authors. The manager's load path never calls\n * this helper: sources own descriptor and body authority. Malformed frontmatter degrades to an\n * empty object when it is not a delimited YAML block; malformed YAML is a manifest error.\n */\nexport const parseSkillMd = (\n  text: string\n): { frontmatter: Record<string, unknown>; body: string } => {\n  const match = /^(?:\\uFEFF)?---[ \\t]*\\r?\\n([\\s\\S]*?)\\r?\\n---[ \\t]*(?:\\r?\\n|$)/.exec(text)\n  if (!match) return { frontmatter: {}, body: text }\n  let parsed: unknown\n  try {\n    parsed = yaml.load(match[1])\n  } catch (error) {\n    throw new E_SKILL_MANIFEST_INVALID([isError(error) ? error.message : String(error)])\n  }\n  if (parsed === undefined || parsed === null) {\n    throw new E_SKILL_MANIFEST_INVALID(['frontmatter must include name and description'])\n  }\n  if (typeof parsed !== 'object' || Array.isArray(parsed)) {\n    throw new E_SKILL_MANIFEST_INVALID(['frontmatter must be a mapping'])\n  }\n  const source = parsed as Record<string, unknown>\n  if (!('name' in source) || typeof source.name !== 'string') {\n    throw new E_SKILL_MANIFEST_INVALID(['frontmatter name must be a string'])\n  }\n  if (!('description' in source) || typeof source.description !== 'string') {\n    throw new E_SKILL_MANIFEST_INVALID(['frontmatter description must be a string'])\n  }\n  const allowed = ['name', 'description', 'license', 'compatibility', 'metadata', 'allowed-tools']\n  const frontmatter: Record<string, unknown> = {}\n  for (const key of allowed) if (key in source) frontmatter[key] = source[key]\n  return { frontmatter, body: text.slice(match[0].length) }\n}\n"],"mappings":";;;;;;;AAIA,IAAa,0BAA0B,gBACrC,2BACA,6BACA,2BACA,KACA,IACF;;AAEA,IAAa,oBAAoB,gBAC/B,qBACA,uBACA,qBACA,KACA,KACF;;AAEA,IAAa,yBAAyB,gBACpC,0BACA,4BACA,0BACA,KACA,KACF;;AAEA,IAAa,qBAAqB,gBAChC,sBACA,wBACA,sBACA,KACA,KACF;;AAEA,IAAa,2BAA2B,gBACtC,4BACA,8BACA,4BACA,KACA,KACF;;AAEA,IAAa,yBAAyB,gBACpC,0BACA,4BACA,0BACA,KACA,KACF;;AAEA,IAAa,yBAAyB,gBACpC,0BACA,4BACA,0BACA,KACA,KACF;;AAEA,IAAa,sBAAsB,gBACjC,uBACA,gCACA,uBACA,KACA,KACF;;AAEA,IAAa,4BAA4B,gBACvC,6BACA,wCACA,6BACA,KACA,KACF;;AAEA,IAAa,+BAA+B,gBAC1C,gCACA,uCACA,gCAC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