@agimon-ai/po-config 0.0.0-alpha.2 → 0.0.0-alpha.21

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.
Files changed (221) hide show
  1. package/LICENSE +149 -21
  2. package/README.md +11 -11
  3. package/dist/agentPluginMcp.cjs +313 -134
  4. package/dist/agentPluginMcp.cjs.map +1 -1
  5. package/dist/agentPluginMcp.d.mts +22 -4
  6. package/dist/agentPluginMcp.d.mts.map +1 -1
  7. package/dist/agentPluginMcp.mjs +312 -134
  8. package/dist/agentPluginMcp.mjs.map +1 -1
  9. package/dist/apiContracts.cjs.map +1 -1
  10. package/dist/apiContracts.mjs.map +1 -1
  11. package/dist/atomicJson-D3MHqnLW.cjs +59 -0
  12. package/dist/atomicJson-D3MHqnLW.cjs.map +1 -0
  13. package/dist/atomicJson-Dj3rlZbD.mjs +40 -0
  14. package/dist/atomicJson-Dj3rlZbD.mjs.map +1 -0
  15. package/dist/atomicJson.cjs +4 -2
  16. package/dist/atomicJson.d.mts +2 -2
  17. package/dist/atomicJson.mjs +3 -2
  18. package/dist/{index-BT29GZx5.d.mts → completion-Ba0TiBHa.d.mts} +58 -27
  19. package/dist/completion-Ba0TiBHa.d.mts.map +1 -0
  20. package/dist/config-BBvn_ZLP.mjs +1 -0
  21. package/dist/config-Cdybp9rT.cjs +155 -0
  22. package/dist/config-Cdybp9rT.cjs.map +1 -0
  23. package/dist/config-Cxc2xw54.mjs +112 -0
  24. package/dist/config-Cxc2xw54.mjs.map +1 -0
  25. package/dist/{config-D2HbBLzo.d.mts → config-pxC7FyUJ.d.mts} +33 -33
  26. package/dist/config-pxC7FyUJ.d.mts.map +1 -0
  27. package/dist/config.cjs +21 -17
  28. package/dist/config.d.mts +3 -3
  29. package/dist/config.mjs +4 -3
  30. package/dist/{configPolicy-Ce1QKDxa.cjs → configPolicy-CowlLhK1.cjs} +99 -99
  31. package/dist/configPolicy-CowlLhK1.cjs.map +1 -0
  32. package/dist/{configPolicy-DCQgF5-f.mjs → configPolicy-DueX0k6i.mjs} +84 -84
  33. package/dist/configPolicy-DueX0k6i.mjs.map +1 -0
  34. package/dist/configSchema.d.mts +2 -2
  35. package/dist/configWriter-DCASRzr-.mjs +180 -0
  36. package/dist/configWriter-DCASRzr-.mjs.map +1 -0
  37. package/dist/configWriter-DGO0gmXo.cjs +218 -0
  38. package/dist/configWriter-DGO0gmXo.cjs.map +1 -0
  39. package/dist/configWriter.cjs +7 -4
  40. package/dist/configWriter.d.mts +2 -2
  41. package/dist/configWriter.mjs +1 -2
  42. package/dist/core-B0Qg0Qq2.cjs +224 -0
  43. package/dist/core-B0Qg0Qq2.cjs.map +1 -0
  44. package/dist/core-DKWW9gkh.mjs +139 -0
  45. package/dist/core-DKWW9gkh.mjs.map +1 -0
  46. package/dist/{domains-DGCb7uMC.cjs → domains-CiDUsRiX.cjs} +473 -171
  47. package/dist/domains-CiDUsRiX.cjs.map +1 -0
  48. package/dist/{domains-BroCVHrS.mjs → domains-IlieGHaY.mjs} +437 -170
  49. package/dist/domains-IlieGHaY.mjs.map +1 -0
  50. package/dist/domains.cjs +9 -3
  51. package/dist/domains.d.mts +3 -3
  52. package/dist/domains.mjs +3 -3
  53. package/dist/extensions/mcp-ui.mjs +1 -1
  54. package/dist/extensions/mcp-ui.mjs.map +1 -1
  55. package/dist/extensions/mcp.cjs +3 -3
  56. package/dist/extensions/mcp.cjs.map +1 -1
  57. package/dist/extensions/mcp.d.mts +1 -1
  58. package/dist/extensions/mcp.mjs +2 -2
  59. package/dist/extensions/mcp.mjs.map +1 -1
  60. package/dist/extensions/server.cjs +55 -47
  61. package/dist/extensions/server.cjs.map +1 -1
  62. package/dist/extensions/server.d.mts +2 -2
  63. package/dist/extensions/server.d.mts.map +1 -1
  64. package/dist/extensions/server.mjs +56 -48
  65. package/dist/extensions/server.mjs.map +1 -1
  66. package/dist/{harnessState-Dn_S7fB9.mjs → harnessState-8lZda_8r.mjs} +2 -2
  67. package/dist/{harnessState-Dn_S7fB9.mjs.map → harnessState-8lZda_8r.mjs.map} +1 -1
  68. package/dist/{harnessState-CCyBeutB.cjs → harnessState-BrmH0lG5.cjs} +2 -2
  69. package/dist/{harnessState-CCyBeutB.cjs.map → harnessState-BrmH0lG5.cjs.map} +1 -1
  70. package/dist/harnessState.cjs +1 -1
  71. package/dist/harnessState.d.mts +1 -1
  72. package/dist/harnessState.mjs +1 -2
  73. package/dist/{harnessStore-CJSxdSkV.cjs → harnessStore-BinxGITh.cjs} +189 -81
  74. package/dist/harnessStore-BinxGITh.cjs.map +1 -0
  75. package/dist/{harnessStore-CltwLB7M.mjs → harnessStore-w8zHmJ_H.mjs} +160 -82
  76. package/dist/harnessStore-w8zHmJ_H.mjs.map +1 -0
  77. package/dist/harnessStore.cjs +6 -1
  78. package/dist/harnessStore.d.mts +2 -2
  79. package/dist/harnessStore.mjs +1 -2
  80. package/dist/index-7RuIAWX1.d.mts +63 -0
  81. package/dist/index-7RuIAWX1.d.mts.map +1 -0
  82. package/dist/{index-CkDDvVQt.d.mts → index-BNcG0voG.d.mts} +61 -16
  83. package/dist/index-BNcG0voG.d.mts.map +1 -0
  84. package/dist/{index-Dy_-m7gx.d.mts → index-BTOU4XiI.d.mts} +3 -3
  85. package/dist/{index-Dy_-m7gx.d.mts.map → index-BTOU4XiI.d.mts.map} +1 -1
  86. package/dist/index-COokUToB.d.mts +83 -0
  87. package/dist/index-COokUToB.d.mts.map +1 -0
  88. package/dist/index-D3vGEYup.d.mts +135 -0
  89. package/dist/index-D3vGEYup.d.mts.map +1 -0
  90. package/dist/{index-Ch7ptOkW.d.mts → index-DNEK9W6n.d.mts} +26 -16
  91. package/dist/index-DNEK9W6n.d.mts.map +1 -0
  92. package/dist/index-D_OtYtsl.d.mts +37 -0
  93. package/dist/index-D_OtYtsl.d.mts.map +1 -0
  94. package/dist/{index-DNk4q0Qm.d.mts → index-Nbj2iQWw.d.mts} +19 -25
  95. package/dist/index-Nbj2iQWw.d.mts.map +1 -0
  96. package/dist/{index-CEUc7m16.d.mts → index-dYgF03lE.d.mts} +82 -32
  97. package/dist/index-dYgF03lE.d.mts.map +1 -0
  98. package/dist/index-fTuf8tVH.d.mts +34 -0
  99. package/dist/index-fTuf8tVH.d.mts.map +1 -0
  100. package/dist/index-nVcEC1jO.d.mts +62 -0
  101. package/dist/index-nVcEC1jO.d.mts.map +1 -0
  102. package/dist/index.cjs +81 -59
  103. package/dist/index.d.mts +16 -15
  104. package/dist/index.mjs +17 -15
  105. package/dist/{init-Cd3Ki6Ub.cjs → init-BdZ-gqqk.cjs} +209 -59
  106. package/dist/init-BdZ-gqqk.cjs.map +1 -0
  107. package/dist/{init-DVzhiCUE.mjs → init-DG7MxGxC.mjs} +187 -48
  108. package/dist/init-DG7MxGxC.mjs.map +1 -0
  109. package/dist/init.cjs +8 -6
  110. package/dist/init.d.mts +2 -2
  111. package/dist/init.mjs +1 -2
  112. package/dist/layeredConfig-BbkoIEfM.mjs +95 -0
  113. package/dist/layeredConfig-BbkoIEfM.mjs.map +1 -0
  114. package/dist/layeredConfig-Bs18dXQG.cjs +127 -0
  115. package/dist/layeredConfig-Bs18dXQG.cjs.map +1 -0
  116. package/dist/layeredConfig.cjs +5 -4
  117. package/dist/layeredConfig.d.mts +7 -2
  118. package/dist/layeredConfig.d.mts.map +1 -0
  119. package/dist/layeredConfig.mjs +1 -2
  120. package/dist/{majorModes-D1Itd8SN.mjs → majorModes-B8Km83e1.mjs} +130 -23
  121. package/dist/majorModes-B8Km83e1.mjs.map +1 -0
  122. package/dist/{majorModes-DnNSH9ZK.cjs → majorModes-CLccNMZt.cjs} +147 -22
  123. package/dist/majorModes-CLccNMZt.cjs.map +1 -0
  124. package/dist/majorModes.cjs +4 -1
  125. package/dist/majorModes.d.mts +2 -2
  126. package/dist/majorModes.mjs +1 -2
  127. package/dist/{piConfig-qGyCbcVj.mjs → piConfig-Bq36PQFF.mjs} +104 -69
  128. package/dist/piConfig-Bq36PQFF.mjs.map +1 -0
  129. package/dist/{piConfig-Bx26HMb_.d.mts → piConfig-C9rGUqPe.d.mts} +3 -3
  130. package/dist/{piConfig-Bx26HMb_.d.mts.map → piConfig-C9rGUqPe.d.mts.map} +1 -1
  131. package/dist/{piConfig-CCBdZXQr.cjs → piConfig-cluCie5i.cjs} +122 -70
  132. package/dist/piConfig-cluCie5i.cjs.map +1 -0
  133. package/dist/piConfig.cjs +4 -1
  134. package/dist/piConfig.d.mts +2 -2
  135. package/dist/piConfig.mjs +1 -2
  136. package/dist/piContext.cjs +27 -16
  137. package/dist/piContext.d.mts +3 -3
  138. package/dist/piContext.mjs +1 -2
  139. package/dist/{profiles-DBcYg5nA.mjs → profiles-CHict0x-.mjs} +322 -101
  140. package/dist/profiles-CHict0x-.mjs.map +1 -0
  141. package/dist/{profiles-tpplXY4r.cjs → profiles-t2EUj0aB.cjs} +359 -102
  142. package/dist/profiles-t2EUj0aB.cjs.map +1 -0
  143. package/dist/profiles.cjs +7 -1
  144. package/dist/profiles.d.mts +27 -3
  145. package/dist/profiles.d.mts.map +1 -1
  146. package/dist/profiles.mjs +1 -2
  147. package/dist/selectionSwitch.cjs +88 -22
  148. package/dist/selectionSwitch.cjs.map +1 -1
  149. package/dist/selectionSwitch.d.mts +40 -18
  150. package/dist/selectionSwitch.d.mts.map +1 -1
  151. package/dist/selectionSwitch.mjs +85 -22
  152. package/dist/selectionSwitch.mjs.map +1 -1
  153. package/dist/{sessionConfig-DV5xTRRw.mjs → sessionConfig-DFQF618G.mjs} +48 -47
  154. package/dist/sessionConfig-DFQF618G.mjs.map +1 -0
  155. package/dist/{sessionConfig-Bf6xHWLd.cjs → sessionConfig-DeP6pplT.cjs} +74 -85
  156. package/dist/sessionConfig-DeP6pplT.cjs.map +1 -0
  157. package/dist/sync-BJ8gCP9s.mjs +29 -0
  158. package/dist/sync-BJ8gCP9s.mjs.map +1 -0
  159. package/dist/sync-CC_15kkB.d.mts +46 -0
  160. package/dist/sync-CC_15kkB.d.mts.map +1 -0
  161. package/dist/sync-Dlxz2msM.cjs +37 -0
  162. package/dist/sync-Dlxz2msM.cjs.map +1 -0
  163. package/dist/types.cjs +2 -2
  164. package/dist/types.d.mts +2 -2
  165. package/dist/types.mjs +1 -2
  166. package/llms.txt +1 -1
  167. package/package.json +16 -16
  168. package/src/prompts/po-author-config/SKILL.md +4 -4
  169. package/src/prompts/po-author-config/agents/openai.yaml +1 -1
  170. package/src/prompts/po-author-config/references/config-contract.md +5 -5
  171. package/dist/atomicJson-1W0WhuFF.mjs +0 -44
  172. package/dist/atomicJson-1W0WhuFF.mjs.map +0 -1
  173. package/dist/atomicJson-Dt2z_DXl.cjs +0 -52
  174. package/dist/atomicJson-Dt2z_DXl.cjs.map +0 -1
  175. package/dist/config-CfTb0_9G.cjs +0 -219
  176. package/dist/config-CfTb0_9G.cjs.map +0 -1
  177. package/dist/config-D2HbBLzo.d.mts.map +0 -1
  178. package/dist/config-DoQWSt1V.mjs +0 -162
  179. package/dist/config-DoQWSt1V.mjs.map +0 -1
  180. package/dist/config-NSHRd6na.mjs +0 -2
  181. package/dist/configPolicy-Ce1QKDxa.cjs.map +0 -1
  182. package/dist/configPolicy-DCQgF5-f.mjs.map +0 -1
  183. package/dist/configWriter-B7uO8MuN.cjs +0 -150
  184. package/dist/configWriter-B7uO8MuN.cjs.map +0 -1
  185. package/dist/configWriter-DUtLgOlD.mjs +0 -130
  186. package/dist/configWriter-DUtLgOlD.mjs.map +0 -1
  187. package/dist/domains-BroCVHrS.mjs.map +0 -1
  188. package/dist/domains-DGCb7uMC.cjs.map +0 -1
  189. package/dist/harnessStore-CJSxdSkV.cjs.map +0 -1
  190. package/dist/harnessStore-CltwLB7M.mjs.map +0 -1
  191. package/dist/index-78zvoS9s.d.mts +0 -35
  192. package/dist/index-78zvoS9s.d.mts.map +0 -1
  193. package/dist/index-BT29GZx5.d.mts.map +0 -1
  194. package/dist/index-C6GaYjq-.d.mts +0 -6
  195. package/dist/index-C6GaYjq-.d.mts.map +0 -1
  196. package/dist/index-CEUc7m16.d.mts.map +0 -1
  197. package/dist/index-CRcoVYXz.d.mts +0 -39
  198. package/dist/index-CRcoVYXz.d.mts.map +0 -1
  199. package/dist/index-CVlciCJF.d.mts +0 -40
  200. package/dist/index-CVlciCJF.d.mts.map +0 -1
  201. package/dist/index-Ch7ptOkW.d.mts.map +0 -1
  202. package/dist/index-CkDDvVQt.d.mts.map +0 -1
  203. package/dist/index-Cvdt-Y-i.d.mts +0 -66
  204. package/dist/index-Cvdt-Y-i.d.mts.map +0 -1
  205. package/dist/index-DNk4q0Qm.d.mts.map +0 -1
  206. package/dist/index-DdH0w56b.d.mts +0 -116
  207. package/dist/index-DdH0w56b.d.mts.map +0 -1
  208. package/dist/init-Cd3Ki6Ub.cjs.map +0 -1
  209. package/dist/init-DVzhiCUE.mjs.map +0 -1
  210. package/dist/layeredConfig-fukqN2EA.mjs +0 -67
  211. package/dist/layeredConfig-fukqN2EA.mjs.map +0 -1
  212. package/dist/layeredConfig-ol0274TN.cjs +0 -94
  213. package/dist/layeredConfig-ol0274TN.cjs.map +0 -1
  214. package/dist/majorModes-D1Itd8SN.mjs.map +0 -1
  215. package/dist/majorModes-DnNSH9ZK.cjs.map +0 -1
  216. package/dist/piConfig-CCBdZXQr.cjs.map +0 -1
  217. package/dist/piConfig-qGyCbcVj.mjs.map +0 -1
  218. package/dist/profiles-DBcYg5nA.mjs.map +0 -1
  219. package/dist/profiles-tpplXY4r.cjs.map +0 -1
  220. package/dist/sessionConfig-Bf6xHWLd.cjs.map +0 -1
  221. package/dist/sessionConfig-DV5xTRRw.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles-t2EUj0aB.cjs","names":["isRecord","parseYaml","PARENT_DIRECTORY","Buffer","path","PROFILE_ICON_MAX_DATA_URL_LENGTH","path","fs","path","getOrThrow","path","parseProfile","fs","readPersonaFrontMatter","readPersonaPresentation","containsPersonaFile","path","discoverProfile","discoverProfileRoot","readProfileLayers","readPoConfigSources","profilesFromLayers","os","getOrThrow","path","readTextIfExists","readPoConfigSourcesAsync","nodeHost"],"sources":["../src/services/personaFrontMatter/index.ts","../src/services/personaIcon/core.ts","../src/services/personaIcon/sync.ts","../src/services/personaIcon/index.ts","../src/services/profileBinding/index.ts","../src/services/profiles/core.ts","../src/services/profiles/sync.ts","../src/services/profiles/index.ts"],"sourcesContent":["import { parse as parseYaml } from 'yaml';\n\nimport type { PersonaDocument, PersonaFrontMatter, PersonaVoiceOverride } from '../../types/profiles';\n\n/**\n * Optional identity a persona declares at the top of its `profile.md`.\n *\n * A profile used to be prompt text only, so there was nowhere to say who the\n * persona is or how it should sound. Front-matter puts that beside the persona\n * text it describes, which is the only place that works for both explicit\n * `profiles.yaml` entries and folders found by root discovery.\n *\n * Recognition is deliberately narrow. Personas that exist today were written\n * without any of this, and one of them may legitimately open with a horizontal\n * rule, so a leading fence alone is not enough to claim the block. A block is\n * only treated as identity when it is fenced at the very first line, closed,\n * parses as a mapping, and declares at least one field this contract owns.\n * Anything else is passed through byte for byte.\n */\n\nconst FENCE = '---';\nconst OWNED_KEYS = ['name', 'icon', 'voice'] as const;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction readVoice(value: unknown): PersonaVoiceOverride | undefined {\n if (!isRecord(value)) return undefined;\n const voice = typeof value.voice === 'string' && value.voice.trim().length > 0 ? value.voice.trim() : undefined;\n const rate = typeof value.rate === 'number' && Number.isFinite(value.rate) ? value.rate : undefined;\n if (voice === undefined && rate === undefined) return undefined;\n return { ...(voice === undefined ? {} : { voice }), ...(rate === undefined ? {} : { rate }) };\n}\n\nfunction readFrontMatter(parsed: Record<string, unknown>): PersonaFrontMatter | undefined {\n const name = typeof parsed.name === 'string' && parsed.name.trim().length > 0 ? parsed.name.trim() : undefined;\n const icon = typeof parsed.icon === 'string' && parsed.icon.trim().length > 0 ? parsed.icon.trim() : undefined;\n const voice = readVoice(parsed.voice);\n if (name === undefined && icon === undefined && voice === undefined) return undefined;\n return {\n ...(name === undefined ? {} : { name }),\n ...(icon === undefined ? {} : { icon }),\n ...(voice === undefined ? {} : { voice }),\n };\n}\n\n/**\n * Splits a recognised identity block off a persona document.\n *\n * Never throws: a malformed avatar must not make a persona unloadable, so an\n * unparseable or unrecognised block leaves the document exactly as it arrived.\n */\nexport function parsePersonaFrontMatter(content: string): PersonaDocument {\n const lines = content.split('\\n');\n if (lines[0]?.trimEnd() !== FENCE) return { body: content };\n\n const closingIndex = lines.findIndex((line, index) => index > 0 && line.trimEnd() === FENCE);\n if (closingIndex === -1) return { body: content };\n\n let parsed: unknown;\n try {\n parsed = parseYaml(lines.slice(1, closingIndex).join('\\n'));\n } catch {\n return { body: content };\n }\n if (!isRecord(parsed)) return { body: content };\n if (!OWNED_KEYS.some((key) => Object.hasOwn(parsed, key))) return { body: content };\n\n const frontMatter = readFrontMatter(parsed);\n if (!frontMatter) return { body: content };\n return { frontMatter, body: lines.slice(closingIndex + 1).join('\\n') };\n}\n","import { Buffer } from 'node:buffer';\nimport path from 'node:path';\n\nimport { PROFILE_ICON_MAX_DATA_URL_LENGTH, type ProfileIconMimeType } from '@agimon-ai/po-core/profileIdentity';\n\n/**\n * Pure half of persona icon loading: confinement and image sniffing. The\n * readers in `index.ts` (async, over a FileSystem) and `sync.ts` (Node shim)\n * only resolve paths and fetch bytes.\n */\nconst PARENT_DIRECTORY = '..';\n\n/**\n * Magic-byte signatures, checked instead of trusting the filename.\n *\n * `image/svg+xml` is absent on purpose: an SVG rendered same-origin executes\n * script, and the author of this path is whoever wrote the persona. Do not add\n * it to match the cockpit's broader media catalog.\n */\nconst SIGNATURES: readonly { readonly mime: ProfileIconMimeType; readonly test: (bytes: Buffer) => boolean }[] = [\n {\n mime: 'image/png',\n test: (b) => b.length > 8 && b.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])),\n },\n { mime: 'image/jpeg', test: (b) => b.length > 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff },\n { mime: 'image/gif', test: (b) => b.length > 6 && b.subarray(0, 6).toString('latin1').startsWith('GIF8') },\n {\n mime: 'image/webp',\n test: (b) =>\n b.length > 12 &&\n b.subarray(0, 4).toString('latin1') === 'RIFF' &&\n b.subarray(8, 12).toString('latin1') === 'WEBP',\n },\n];\n\n/** True when `realIconPath` lies inside `realPersonaPath` (both already canonical). */\nexport function isInsidePersona(realPersonaPath: string, realIconPath: string): boolean {\n const relative = path.relative(realPersonaPath, realIconPath);\n return !(\n relative === PARENT_DIRECTORY ||\n relative.startsWith(`${PARENT_DIRECTORY}${path.sep}`) ||\n path.isAbsolute(relative)\n );\n}\n\n/** A bounded `data:` URL for an allowed image, or undefined. */\nexport function iconDataUrl(content: Uint8Array): string | undefined {\n const bytes = Buffer.from(content.buffer, content.byteOffset, content.byteLength);\n const mime = SIGNATURES.find((signature) => signature.test(bytes))?.mime;\n if (!mime) return undefined;\n const dataUrl = `data:${mime};base64,${bytes.toString('base64')}`;\n return dataUrl.length > PROFILE_ICON_MAX_DATA_URL_LENGTH ? undefined : dataUrl;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { iconDataUrl, isInsidePersona } from './core';\n\n/**\n * Resolves an icon declared in persona front-matter, or undefined when it is\n * missing, unreadable, not an allowed image, escapes the persona directory, or\n * exceeds the data-URL ceiling.\n *\n * @deprecated Node-only sync shim; use readPersonaIconAsync. Removed in M2.\n */\nexport function readPersonaIcon(personaPath: string, iconRelative: string): string | undefined {\n if (path.isAbsolute(iconRelative)) return undefined;\n\n try {\n const realPersonaPath = fs.realpathSync(personaPath);\n const iconPath = path.resolve(realPersonaPath, iconRelative);\n if (!fs.existsSync(iconPath)) return undefined;\n\n const realIconPath = fs.realpathSync(iconPath);\n if (!isInsidePersona(realPersonaPath, realIconPath)) return undefined;\n if (!fs.statSync(realIconPath).isFile()) return undefined;\n\n return iconDataUrl(fs.readFileSync(realIconPath));\n } catch {\n return undefined;\n }\n}\n","import path from 'node:path';\n\nimport { getOrThrow, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { iconDataUrl, isInsidePersona } from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/**\n * Reads a persona icon into a bounded `data:` URL.\n *\n * The icon travels inside the journalled identity entry rather than through an\n * HTTP route. A route would leave a request-time filesystem resolution reachable\n * from the browser for the life of a session, defended on every request forever;\n * this resolves the path once, server side, at the moment the profile loads.\n *\n * The path comes from user-authored front-matter, so it is confined the same way\n * `buildPersonaPrompt` confines persona files: a symlink must not read outside\n * the persona directory.\n *\n * Every failure is silent and returns undefined. An avatar is decoration, and a\n * broken one must never stop a persona from loading. That includes a host whose\n * filesystem lacks the persona entirely, such as the edge.\n */\nexport async function readPersonaIconAsync(\n fs: FileSystem,\n personaPath: string,\n iconRelative: string,\n context: IoContext,\n): Promise<string | undefined> {\n if (path.isAbsolute(iconRelative)) return undefined;\n\n try {\n const realPersonaPath = getOrThrow(await fs.canonicalPath(personaPath, context));\n const iconPath = path.resolve(realPersonaPath, iconRelative);\n if (!getOrThrow(await fs.exists(iconPath, context))) return undefined;\n\n const realIconPath = getOrThrow(await fs.canonicalPath(iconPath, context));\n if (!isInsidePersona(realPersonaPath, realIconPath)) return undefined;\n if (getOrThrow(await fs.fileInfo(realIconPath, context)).kind !== 'file') return undefined;\n\n return iconDataUrl(getOrThrow(await fs.readBinaryFile(realIconPath, context)));\n } catch {\n return undefined;\n }\n}\n\nexport { readPersonaIcon } from './sync';\n","import type { ProfileBrowserBinding, ProfileIntegrationBinding, ProfileSecretReference } from './type';\n\nconst BINDING_KEYS = new Set(['provider', 'organizationId', 'mailboxId', 'credentialRef', 'secrets', 'browser']);\nconst SECRET_KEYS = new Set(['credentialId', 'field', 'allowedOrigins']);\nconst BROWSER_KEYS = new Set(['profileName', 'allowedOrigins']);\nconst ALIAS_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;\nconst FIELD_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;\nconst BROWSER_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;\n\nfunction record(value: unknown, location: string, keys?: ReadonlySet<string>): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${location} must be a mapping`);\n }\n if (keys && Object.keys(value).some((key) => !keys.has(key))) {\n // Never echo an unknown key or value, either of which might contain a misplaced secret.\n throw new Error(`${location} contains unsupported metadata`);\n }\n return value as Record<string, unknown>;\n}\n\nfunction reference(value: unknown, location: string): string {\n if (typeof value !== 'string' || value.length === 0 || value.length > 256 || /\\s/.test(value)) {\n throw new Error(`${location} must be a non-empty reference without whitespace`);\n }\n return value;\n}\n\nfunction origins(value: unknown, location: string): readonly string[] {\n if (!Array.isArray(value) || value.length === 0) throw new Error(`${location} must contain exact HTTP(S) origins`);\n const result = value.map((entry: unknown) => {\n if (typeof entry !== 'string') throw new Error(`${location} must contain exact HTTP(S) origins`);\n let url: URL;\n try {\n url = new URL(entry);\n } catch {\n throw new Error(`${location} must contain exact HTTP(S) origins`);\n }\n if (\n (url.protocol !== 'https:' && url.protocol !== 'http:') ||\n url.origin !== entry ||\n url.username ||\n url.password\n ) {\n throw new Error(`${location} must contain exact HTTP(S) origins`);\n }\n return entry;\n });\n return Object.freeze([...new Set(result)]);\n}\n\nfunction browser(value: unknown, location: string): ProfileBrowserBinding {\n const entry = record(value, location, BROWSER_KEYS);\n if (typeof entry.profileName !== 'string' || !BROWSER_PROFILE_PATTERN.test(entry.profileName)) {\n throw new Error(`${location}.profileName must be a safe browser profile name`);\n }\n return Object.freeze({\n profileName: entry.profileName,\n allowedOrigins: origins(entry.allowedOrigins, `${location}.allowedOrigins`),\n });\n}\n\n/** Validates and deeply freezes a detached metadata snapshot. No provider SDK or secret is loaded. */\nexport function parseProfileBinding(value: unknown, location = 'Profile integration'): ProfileIntegrationBinding {\n const entry = record(value, location, BINDING_KEYS);\n const sourceSecrets = record(entry.secrets, `${location}.secrets`);\n const secrets: Record<string, ProfileSecretReference> = {};\n for (const [alias, value] of Object.entries(sourceSecrets)) {\n if (!ALIAS_PATTERN.test(alias)) throw new Error(`${location}.secrets requires uppercase alias names`);\n const secret = record(value, `${location}.secrets.${alias}`, SECRET_KEYS);\n if (typeof secret.field !== 'string' || !FIELD_PATTERN.test(secret.field)) {\n throw new Error(`${location}.secrets.${alias}.field must be a credential field name`);\n }\n secrets[alias] = Object.freeze({\n credentialId: reference(secret.credentialId, `${location}.secrets.${alias}.credentialId`),\n field: secret.field,\n allowedOrigins: origins(secret.allowedOrigins, `${location}.secrets.${alias}.allowedOrigins`),\n });\n }\n const browserBinding = entry.browser === undefined ? undefined : browser(entry.browser, `${location}.browser`);\n if (\n browserBinding &&\n Object.values(secrets).some((secret) =>\n secret.allowedOrigins.some((origin) => !browserBinding.allowedOrigins.includes(origin)),\n )\n ) {\n throw new Error(`${location} secret origins must be included in browser.allowedOrigins`);\n }\n return Object.freeze({\n provider: reference(entry.provider, `${location}.provider`),\n organizationId: reference(entry.organizationId, `${location}.organizationId`),\n mailboxId: reference(entry.mailboxId, `${location}.mailboxId`),\n credentialRef: reference(entry.credentialRef, `${location}.credentialRef`),\n secrets: Object.freeze(secrets),\n ...(browserBinding === undefined ? {} : { browser: browserBinding }),\n });\n}\n","import path from 'node:path';\n\nimport type { PersonaFrontMatter, PersonaIdentity, PersonaVoiceOverride } from '../../types/profiles';\nimport { parsePersonaFrontMatter } from '../personaFrontMatter';\nimport { parseProfileBinding } from '../profileBinding';\nimport type { ProfileIntegrationBinding } from '../profileBinding/type';\n\n/** Files that make up one repository persona, concatenated in this order. */\nexport const PERSONA_FILES = ['profile.md', 'SOUL.md', 'AGENTS.md'];\n\n/** The persona file that may carry an identity block; the others are prose only. */\nexport const PERSONA_IDENTITY_FILE = 'profile.md';\n\nexport interface AgentProfile {\n name: string;\n /** Directory relative to personaRoot, which remains the persona source. */\n persona: string;\n /**\n * Root the persona path resolves against: the repository root for a\n * repository profile, the global `.po` directory for a global one.\n */\n personaRoot: string;\n /** Environment defaults. Values already exported by the caller win. */\n env: Record<string, string>;\n /** Nonsecret integration metadata. Resolved secrets never enter profile environment. */\n integration?: ProfileIntegrationBinding;\n /** Display name and avatar declared in the persona's own front-matter. */\n identity?: PersonaIdentity;\n /** Narrowly scoped TTS override declared alongside the identity. */\n voice?: PersonaVoiceOverride;\n}\n\nexport interface ProfileConfigLayer {\n filePath: string;\n baseDirectory: string;\n roots: string[];\n entries: Record<string, unknown>;\n defaultProfile?: string;\n}\n\n/** An explicit entry that passed shape checks, before its persona is read from disk. */\nexport interface ProfileEntryDraft {\n name: string;\n persona: string;\n personaPath: string;\n /** Allowed roots that lexically contain the persona; the caller confirms one after resolving links. */\n lexicalRoots: string[];\n value: Record<string, unknown>;\n}\n\nexport type PersonaPresentation = { identity?: PersonaIdentity; voice?: PersonaVoiceOverride };\n\nconst PROFILE_KEYS = new Set(['persona', 'env', 'integration']);\nconst PROFILE_CATALOG_KEYS = new Set(['roots', 'entries', 'defaultProfile']);\nexport const PROFILES_FILE = 'profiles.yaml';\nconst PROFILES_ROOT_KEY = 'profiles';\nconst AGENTS_DIRECTORY = 'agents';\nexport const PARENT_DIRECTORY = '..';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function isPathInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return (\n relative === '' ||\n (!path.isAbsolute(relative) &&\n relative !== PARENT_DIRECTORY &&\n !relative.startsWith(`${PARENT_DIRECTORY}${path.sep}`))\n );\n}\n\nfunction parseEnvironment(name: string, value: unknown): Record<string, string> {\n if (value === undefined) return {};\n if (!isRecord(value)) throw new Error(`Profile \"${name}\" env must be a string mapping`);\n\n const environment: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value)) {\n if (typeof entry !== 'string') throw new Error(`Profile \"${name}\" env.${key} must be a string`);\n if (entry.includes('${secrets.')) throw new Error(`Profile \"${name}\" env cannot contain secret aliases`);\n environment[key] = entry;\n }\n return environment;\n}\n\nfunction parseProfileRoots(value: unknown, filePath: string, baseDirectory: string): string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) throw new Error(`profiles.roots in ${filePath} must be an array`);\n return value.map((entry, index) => {\n if (typeof entry !== 'string' || entry.trim().length === 0) {\n throw new Error(`profiles.roots[${index}] in ${filePath} must be a non-empty string`);\n }\n return path.resolve(baseDirectory, entry.trim());\n });\n}\n\nexport function parseProfileLayer(source: {\n filePath: string;\n baseDirectory: string;\n document: unknown;\n}): ProfileConfigLayer {\n if (!isRecord(source.document) || !isRecord(source.document[PROFILES_ROOT_KEY])) {\n throw new Error(`${source.filePath} must contain a profiles mapping`);\n }\n const unsupportedDocumentKeys = Object.keys(source.document).filter((key) => key !== PROFILES_ROOT_KEY);\n if (unsupportedDocumentKeys.length > 0) {\n throw new Error(`${source.filePath} may only contain profiles; unsupported: ${unsupportedDocumentKeys.join(', ')}`);\n }\n\n const profiles = source.document[PROFILES_ROOT_KEY];\n const usesCatalogShape = Object.hasOwn(profiles, 'roots') || Object.hasOwn(profiles, 'entries');\n if (!usesCatalogShape) {\n return { filePath: source.filePath, baseDirectory: source.baseDirectory, roots: [], entries: profiles };\n }\n\n const unsupportedCatalogKeys = Object.keys(profiles).filter((key) => !PROFILE_CATALOG_KEYS.has(key));\n if (unsupportedCatalogKeys.length > 0) {\n throw new Error(\n `profiles in ${source.filePath} may only contain roots, entries and defaultProfile; unsupported: ${unsupportedCatalogKeys.join(', ')}`,\n );\n }\n if (\n profiles.defaultProfile !== undefined &&\n (typeof profiles.defaultProfile !== 'string' || profiles.defaultProfile.trim().length === 0)\n ) {\n throw new Error(`profiles.defaultProfile in ${source.filePath} must be a non-empty string`);\n }\n if (profiles.entries !== undefined && !isRecord(profiles.entries)) {\n throw new Error(`profiles.entries in ${source.filePath} must be a mapping`);\n }\n return {\n filePath: source.filePath,\n baseDirectory: source.baseDirectory,\n roots: parseProfileRoots(profiles.roots, source.filePath, source.baseDirectory),\n entries: profiles.entries ?? {},\n ...(profiles.defaultProfile === undefined ? {} : { defaultProfile: String(profiles.defaultProfile).trim() }),\n };\n}\n\n/**\n * Shape checks for one explicit entry. The caller checks the persona on disk,\n * then `profileFromDraft` parses env and integration, keeping the error order.\n */\nexport function draftProfileEntry(\n personaRoot: string,\n configuredRoots: readonly string[],\n name: string,\n value: unknown,\n): ProfileEntryDraft {\n if (!isRecord(value)) throw new Error(`Profile \"${name}\" must be a mapping`);\n\n const unsupported = Object.keys(value).filter((key) => !PROFILE_KEYS.has(key));\n if (unsupported.length > 0) {\n throw new Error(\n `Profile \"${name}\" may only set persona, env and integration; unsupported: ${unsupported.join(', ')}`,\n );\n }\n if (typeof value.persona !== 'string' || value.persona.trim().length === 0) {\n throw new Error(`Profile \"${name}\" must set a persona`);\n }\n if (path.isAbsolute(value.persona)) {\n throw new Error(`Profile \"${name}\" persona must be relative to the config that declares it`);\n }\n\n const persona = value.persona;\n const personaPath = path.resolve(personaRoot, persona);\n const lexicalRoots = [path.resolve(personaRoot, AGENTS_DIRECTORY), ...configuredRoots].filter((root) =>\n isPathInside(root, personaPath),\n );\n if (lexicalRoots.length === 0) throw outsideAllowedRoot(name);\n return {\n name,\n persona,\n personaPath,\n lexicalRoots,\n value,\n };\n}\n\nexport function outsideAllowedRoot(name: string): Error {\n return new Error(`Profile \"${name}\" persona must stay inside agents/ or a configured profile root`);\n}\n\nexport function missingPersona(name: string, persona: string): Error {\n return new Error(`Profile \"${name}\" references a missing persona: ${persona}`);\n}\n\n/**\n * An identity block is not persona text, so a profile.md holding nothing else\n * leaves the persona empty. Say that, rather than claiming the file is unreadable.\n */\nexport function emptyPersona(name: string, persona: string, declaresIdentity: boolean): Error {\n return new Error(\n declaresIdentity\n ? `Profile \"${name}\" persona declares identity front-matter but no persona text: ${persona}`\n : `Profile \"${name}\" persona has no readable persona files: ${persona}`,\n );\n}\n\nexport function profileFromDraft(\n draft: ProfileEntryDraft,\n personaRoot: string,\n presentation: PersonaPresentation,\n): AgentProfile {\n const { name, value } = draft;\n return {\n name,\n persona: draft.persona,\n personaRoot,\n env: parseEnvironment(name, value.env),\n ...(value.integration === undefined\n ? {}\n : { integration: parseProfileBinding(value.integration, `Profile \"${name}\" integration`) }),\n ...presentation,\n };\n}\n\nexport function presentationFrom(frontMatter: PersonaFrontMatter, icon: string | undefined): PersonaPresentation {\n const identity: PersonaIdentity = {\n ...(frontMatter.name === undefined ? {} : { name: frontMatter.name }),\n ...(icon === undefined ? {} : { icon }),\n };\n return {\n ...(identity.name === undefined && identity.icon === undefined ? {} : { identity }),\n ...(frontMatter.voice === undefined ? {} : { voice: frontMatter.voice }),\n };\n}\n\n/** Rejects a persona file whose real path left the persona directory. */\nexport function assertPersonaFileInside(\n personaPath: string,\n realFilePath: string,\n personaDirectory: string,\n file: string,\n): void {\n const relativeFilePath = path.relative(personaPath, realFilePath);\n if (relativeFilePath === PARENT_DIRECTORY || relativeFilePath.startsWith(`${PARENT_DIRECTORY}${path.sep}`)) {\n throw new Error(`Persona file must stay inside ${personaDirectory}: ${file}`);\n }\n}\n\n/** The text one persona file contributes. Only profile.md may declare identity, so only profile.md is stripped. */\nexport function personaFileSection(file: string, raw: string): string {\n return (file === PERSONA_IDENTITY_FILE ? parsePersonaFrontMatter(raw).body : raw).trim();\n}\n\nexport function personaPromptFromSections(personaDirectory: string, sections: readonly string[]): string | undefined {\n if (sections.length === 0) return undefined;\n return [`[PERSONA] You are operating as the person described below (source: ${personaDirectory}).`, ...sections].join(\n '\\n\\n',\n );\n}\n\nexport function sortProfiles(byName: Map<string, AgentProfile>): AgentProfile[] {\n return [...byName.values()].sort((left, right) => left.name.localeCompare(right.name));\n}\n\n/** A repository declaration replaces a personal one; an unknown name is an error, not a fallback. */\nexport function catalogDefaultProfile(\n layers: readonly ProfileConfigLayer[],\n profiles: readonly AgentProfile[],\n): string | undefined {\n let defaultProfile: string | undefined;\n for (const layer of layers) {\n if (layer.defaultProfile !== undefined) defaultProfile = layer.defaultProfile;\n }\n if (defaultProfile !== undefined && !profiles.some((profile) => profile.name === defaultProfile)) {\n throw new Error(`profiles.defaultProfile names an unknown profile: ${defaultProfile}`);\n }\n return defaultProfile;\n}\n\n/** Applies profile environment defaults and returns only the values it contributed. */\nexport function applyProfileEnvironment(\n environment: NodeJS.ProcessEnv,\n defaults: Record<string, string>,\n): Record<string, string> {\n const applied: Record<string, string> = {};\n for (const [key, value] of Object.entries(defaults)) {\n if (environment[key] !== undefined) continue;\n environment[key] = value;\n applied[key] = value;\n }\n return applied;\n}\n\n/** Replaces environment defaults previously contributed by another profile. */\nexport function replaceProfileEnvironment(\n environment: NodeJS.ProcessEnv,\n previous: Record<string, string>,\n next: Record<string, string>,\n): Record<string, string> {\n for (const [key, value] of Object.entries(previous)) {\n if (environment[key] === value) delete environment[key];\n }\n return applyProfileEnvironment(environment, next);\n}\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport type { PersonaFrontMatter } from '../../types/profiles';\nimport { readPoConfigSources } from '../layeredConfig';\nimport { parsePersonaFrontMatter } from '../personaFrontMatter';\nimport { readPersonaIcon } from '../personaIcon';\nimport {\n PERSONA_FILES,\n PERSONA_IDENTITY_FILE,\n PROFILES_FILE,\n assertPersonaFileInside,\n catalogDefaultProfile,\n draftProfileEntry,\n emptyPersona,\n isPathInside,\n missingPersona,\n outsideAllowedRoot,\n parseProfileLayer,\n personaFileSection,\n personaPromptFromSections,\n presentationFrom,\n profileFromDraft,\n sortProfiles,\n type AgentProfile,\n type PersonaPresentation,\n type ProfileConfigLayer,\n} from './core';\n\nconst TEXT_ENCODING = 'utf8';\n\nfunction parseProfile(\n personaRoot: string,\n configuredRoots: readonly string[],\n name: string,\n value: unknown,\n): AgentProfile {\n const draft = draftProfileEntry(personaRoot, configuredRoots, name, value);\n if (!fs.existsSync(draft.personaPath) || !fs.statSync(draft.personaPath).isDirectory()) {\n throw missingPersona(name, draft.persona);\n }\n const realPersonaPath = fs.realpathSync(draft.personaPath);\n if (!draft.lexicalRoots.some((root) => isPathInside(fs.realpathSync(root), realPersonaPath))) {\n throw outsideAllowedRoot(name);\n }\n if (!buildPersonaPrompt(personaRoot, draft.persona)) {\n throw emptyPersona(name, draft.persona, readPersonaFrontMatter(personaRoot, draft.persona) !== undefined);\n }\n return profileFromDraft(draft, personaRoot, readPersonaPresentation(personaRoot, draft.persona));\n}\n\nfunction containsPersonaFile(directory: string): boolean {\n return PERSONA_FILES.some((file) => {\n try {\n return fs.lstatSync(path.join(directory, file)).isFile();\n } catch {\n return false;\n }\n });\n}\n\nfunction discoverProfile(directory: string, configuredRoot: string, personaRoot: string): AgentProfile | undefined {\n if (!containsPersonaFile(directory)) return undefined;\n try {\n const realConfiguredRoot = fs.realpathSync(configuredRoot);\n const realDirectory = fs.realpathSync(directory);\n if (!isPathInside(realConfiguredRoot, realDirectory)) return undefined;\n const persona = path.relative(personaRoot, directory) || '.';\n if (!buildPersonaPrompt(personaRoot, persona)) return undefined;\n return {\n name: path.basename(directory),\n persona,\n personaRoot,\n env: {},\n ...readPersonaPresentation(personaRoot, persona),\n };\n } catch {\n // Automatic discovery ignores unreadable or unsafe candidates; explicit entries remain fatal.\n return undefined;\n }\n}\n\nfunction discoverProfileRoot(root: string, personaRoot: string): AgentProfile[] {\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n throw new Error(`Configured profile root is not a directory: ${root}`);\n }\n\n const rootProfile = discoverProfile(root, root, personaRoot);\n if (rootProfile) return [rootProfile];\n\n return fs\n .readdirSync(root, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .sort((left, right) => left.name.localeCompare(right.name))\n .flatMap((entry) => {\n const profile = discoverProfile(path.join(root, entry.name), root, personaRoot);\n return profile ? [profile] : [];\n });\n}\n\nfunction readProfileLayers(repoRoot: string, homeDirectory: string): ProfileConfigLayer[] {\n return readPoConfigSources<unknown>(PROFILES_FILE, repoRoot, homeDirectory).map(parseProfileLayer);\n}\n\nfunction profilesFromLayers(layers: readonly ProfileConfigLayer[]): AgentProfile[] {\n const byName = new Map<string, AgentProfile>();\n for (const layer of layers) {\n for (const root of layer.roots) {\n for (const profile of discoverProfileRoot(root, layer.baseDirectory)) byName.set(profile.name, profile);\n }\n }\n for (const layer of layers) {\n for (const [name, value] of Object.entries(layer.entries)) {\n byName.set(name, parseProfile(layer.baseDirectory, layer.roots, name, value));\n }\n }\n return sortProfiles(byName);\n}\n\n/**\n * Loads profiles from the global and repository configs, repository last.\n *\n * Configured roots accumulate and inspect themselves or their direct-child\n * directories for persona files. Later discoveries replace earlier names, and\n * explicit entries replace discoveries. Legacy flat profile mappings remain\n * accepted as explicit entries.\n *\n * @deprecated Node-only sync shim; use loadProfilesAsync. Removed in M2.\n */\nexport function loadProfiles(repoRoot: string, homeDirectory: string = os.homedir()): AgentProfile[] {\n return profilesFromLayers(readProfileLayers(repoRoot, homeDirectory));\n}\n\n/**\n * The profile catalog: every resolved profile, plus the name a launch starts on\n * when the caller names none.\n *\n * `defaultProfile` mirrors `defaultMajorMode` in modes.yaml and `defaultDomains`\n * in domains.yaml, so each selection axis declares its default in its own\n * catalog. A repository declaration replaces a personal one. An unknown name is\n * an error rather than a silent fallback: a typo that quietly starts the session\n * with no persona is worse than a refused launch.\n *\n * @deprecated Node-only sync shim; use loadProfileCatalogAsync. Removed in M2.\n */\nexport function loadProfileCatalog(\n repoRoot: string,\n homeDirectory: string = os.homedir(),\n): { profiles: AgentProfile[]; defaultProfile?: string } {\n const layers = readProfileLayers(repoRoot, homeDirectory);\n const profiles = profilesFromLayers(layers);\n const defaultProfile = catalogDefaultProfile(layers, profiles);\n return { profiles, ...(defaultProfile === undefined ? {} : { defaultProfile }) };\n}\n\n/**\n * Resolves one selected profile and fails clearly when its name is unknown.\n *\n * @deprecated Node-only sync shim; use resolveProfileAsync. Removed in M2.\n */\nexport function resolveProfile(repoRoot: string, name: string, homeDirectory?: string): AgentProfile {\n const profile = loadProfiles(repoRoot, homeDirectory).find((candidate) => candidate.name === name);\n if (!profile) throw new Error(`Unknown profile: ${name}`);\n return profile;\n}\n\n/** @deprecated Node-only sync shim; use listProfileNamesAsync. Removed in M2. */\nexport function listProfileNames(repoRoot: string, homeDirectory?: string): string[] {\n return loadProfiles(repoRoot, homeDirectory).map((profile) => profile.name);\n}\n\nfunction readPersonaPresentation(personaRoot: string, personaDirectory: string): PersonaPresentation {\n const frontMatter = readPersonaFrontMatter(personaRoot, personaDirectory);\n if (!frontMatter) return {};\n const icon =\n frontMatter.icon === undefined\n ? undefined\n : readPersonaIcon(path.join(personaRoot, personaDirectory), frontMatter.icon);\n return presentationFrom(frontMatter, icon);\n}\n\nfunction readPersonaFrontMatter(personaRoot: string, personaDirectory: string): PersonaFrontMatter | undefined {\n try {\n const personaPath = fs.realpathSync(path.join(personaRoot, personaDirectory));\n const filePath = path.join(personaPath, PERSONA_IDENTITY_FILE);\n if (!fs.existsSync(filePath)) return undefined;\n return parsePersonaFrontMatter(fs.readFileSync(fs.realpathSync(filePath), TEXT_ENCODING)).frontMatter;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Builds the persona system-prompt block, or undefined when nothing is readable.\n *\n * @deprecated Node-only sync shim; use buildPersonaPromptAsync. Removed in M2.\n */\nexport function buildPersonaPrompt(personaRoot: string, personaDirectory: string): string | undefined {\n const sections: string[] = [];\n const personaPath = fs.realpathSync(path.join(personaRoot, personaDirectory));\n for (const file of PERSONA_FILES) {\n const filePath = path.join(personaPath, file);\n if (!fs.existsSync(filePath)) continue;\n const realFilePath = fs.realpathSync(filePath);\n assertPersonaFileInside(personaPath, realFilePath, personaDirectory, file);\n const content = personaFileSection(file, fs.readFileSync(realFilePath, TEXT_ENCODING));\n if (content) sections.push(content);\n }\n return personaPromptFromSections(personaDirectory, sections);\n}\n","import path from 'node:path';\n\nimport { getOrThrow, nodeHost, readTextIfExists, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport type { PersonaFrontMatter } from '../../types/profiles';\nimport { readPoConfigSourcesAsync } from '../layeredConfig';\nimport { parsePersonaFrontMatter } from '../personaFrontMatter';\nimport { readPersonaIconAsync } from '../personaIcon';\nimport {\n PERSONA_FILES,\n PERSONA_IDENTITY_FILE,\n PROFILES_FILE,\n assertPersonaFileInside,\n catalogDefaultProfile,\n draftProfileEntry,\n emptyPersona,\n isPathInside,\n missingPersona,\n outsideAllowedRoot,\n parseProfileLayer,\n personaFileSection,\n personaPromptFromSections,\n presentationFrom,\n profileFromDraft,\n sortProfiles,\n type AgentProfile,\n type PersonaPresentation,\n type ProfileConfigLayer,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/** Profile reads over a FileSystem; the Node shims in `./sync` give the same answers from node:fs. */\n\nconst realPath = async (fs: FileSystem, target: string, context: IoContext): Promise<string> =>\n getOrThrow(await fs.canonicalPath(target, context));\n\nconst exists = async (fs: FileSystem, target: string, context: IoContext): Promise<boolean> =>\n getOrThrow(await fs.exists(target, context));\n\n/** Whether a path is a directory once links are followed, as `statSync().isDirectory()`. */\nasync function isDirectory(fs: FileSystem, target: string, context: IoContext): Promise<boolean> {\n if (!(await exists(fs, target, context))) return false;\n const info = getOrThrow(await fs.fileInfo(await realPath(fs, target, context), context));\n return info.kind === 'directory';\n}\n\nasync function readPersonaFrontMatter(\n fs: FileSystem,\n personaRoot: string,\n personaDirectory: string,\n context: IoContext,\n): Promise<PersonaFrontMatter | undefined> {\n try {\n const personaPath = await realPath(fs, path.join(personaRoot, personaDirectory), context);\n const filePath = path.join(personaPath, PERSONA_IDENTITY_FILE);\n if (!(await exists(fs, filePath, context))) return undefined;\n const text = await readTextIfExists(fs, await realPath(fs, filePath, context), context);\n return text === undefined ? undefined : parsePersonaFrontMatter(text).frontMatter;\n } catch {\n return undefined;\n }\n}\n\nasync function readPersonaPresentation(\n fs: FileSystem,\n personaRoot: string,\n personaDirectory: string,\n context: IoContext,\n): Promise<PersonaPresentation> {\n const frontMatter = await readPersonaFrontMatter(fs, personaRoot, personaDirectory, context);\n if (!frontMatter) return {};\n const icon =\n frontMatter.icon === undefined\n ? undefined\n : await readPersonaIconAsync(fs, path.join(personaRoot, personaDirectory), frontMatter.icon, context);\n return presentationFrom(frontMatter, icon);\n}\n\n/** Builds the persona system-prompt block, or undefined when nothing is readable. */\nexport async function buildPersonaPromptAsync(\n fs: FileSystem,\n personaRoot: string,\n personaDirectory: string,\n context: IoContext,\n): Promise<string | undefined> {\n const sections: string[] = [];\n const personaPath = await realPath(fs, path.join(personaRoot, personaDirectory), context);\n for (const file of PERSONA_FILES) {\n const filePath = path.join(personaPath, file);\n if (!(await exists(fs, filePath, context))) continue;\n const realFilePath = await realPath(fs, filePath, context);\n assertPersonaFileInside(personaPath, realFilePath, personaDirectory, file);\n const content = personaFileSection(file, getOrThrow(await fs.readTextFile(realFilePath, context)));\n if (content) sections.push(content);\n }\n return personaPromptFromSections(personaDirectory, sections);\n}\n\nasync function parseProfile(\n fs: FileSystem,\n personaRoot: string,\n configuredRoots: readonly string[],\n name: string,\n value: unknown,\n context: IoContext,\n): Promise<AgentProfile> {\n const draft = draftProfileEntry(personaRoot, configuredRoots, name, value);\n if (!(await isDirectory(fs, draft.personaPath, context))) throw missingPersona(name, draft.persona);\n const realPersonaPath = await realPath(fs, draft.personaPath, context);\n let allowed = false;\n for (const root of draft.lexicalRoots) {\n if (isPathInside(await realPath(fs, root, context), realPersonaPath)) {\n allowed = true;\n break;\n }\n }\n if (!allowed) throw outsideAllowedRoot(name);\n if (!(await buildPersonaPromptAsync(fs, personaRoot, draft.persona, context))) {\n const declaresIdentity = (await readPersonaFrontMatter(fs, personaRoot, draft.persona, context)) !== undefined;\n throw emptyPersona(name, draft.persona, declaresIdentity);\n }\n return profileFromDraft(draft, personaRoot, await readPersonaPresentation(fs, personaRoot, draft.persona, context));\n}\n\nasync function containsPersonaFile(fs: FileSystem, directory: string, context: IoContext): Promise<boolean> {\n for (const file of PERSONA_FILES) {\n const info = await fs.fileInfo(path.join(directory, file), context);\n if (info.ok && info.value.kind === 'file') return true;\n }\n return false;\n}\n\nasync function discoverProfile(\n fs: FileSystem,\n directory: string,\n configuredRoot: string,\n personaRoot: string,\n context: IoContext,\n): Promise<AgentProfile | undefined> {\n if (!(await containsPersonaFile(fs, directory, context))) return undefined;\n try {\n const realConfiguredRoot = await realPath(fs, configuredRoot, context);\n const realDirectory = await realPath(fs, directory, context);\n if (!isPathInside(realConfiguredRoot, realDirectory)) return undefined;\n const persona = path.relative(personaRoot, directory) || '.';\n if (!(await buildPersonaPromptAsync(fs, personaRoot, persona, context))) return undefined;\n return {\n name: path.basename(directory),\n persona,\n personaRoot,\n env: {},\n ...(await readPersonaPresentation(fs, personaRoot, persona, context)),\n };\n } catch {\n // Automatic discovery ignores unreadable or unsafe candidates; explicit entries remain fatal.\n return undefined;\n }\n}\n\nasync function discoverProfileRoot(\n fs: FileSystem,\n root: string,\n personaRoot: string,\n context: IoContext,\n): Promise<AgentProfile[]> {\n if (!(await isDirectory(fs, root, context))) throw new Error(`Configured profile root is not a directory: ${root}`);\n\n const rootProfile = await discoverProfile(fs, root, root, personaRoot, context);\n if (rootProfile) return [rootProfile];\n\n const directories = getOrThrow(await fs.listDir(root, context))\n .filter((entry) => entry.kind === 'directory')\n .sort((left, right) => left.name.localeCompare(right.name));\n const profiles: AgentProfile[] = [];\n for (const entry of directories) {\n const profile = await discoverProfile(fs, path.join(root, entry.name), root, personaRoot, context);\n if (profile) profiles.push(profile);\n }\n return profiles;\n}\n\nasync function readProfileLayers(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n homeDirectory: string,\n): Promise<ProfileConfigLayer[]> {\n const sources = await readPoConfigSourcesAsync<unknown>(fs, PROFILES_FILE, repoRoot, context, homeDirectory);\n return sources.map(parseProfileLayer);\n}\n\nasync function profilesFromLayers(\n fs: FileSystem,\n layers: readonly ProfileConfigLayer[],\n context: IoContext,\n): Promise<AgentProfile[]> {\n const byName = new Map<string, AgentProfile>();\n for (const layer of layers) {\n for (const root of layer.roots) {\n for (const profile of await discoverProfileRoot(fs, root, layer.baseDirectory, context)) {\n byName.set(profile.name, profile);\n }\n }\n }\n for (const layer of layers) {\n for (const [name, value] of Object.entries(layer.entries)) {\n byName.set(name, await parseProfile(fs, layer.baseDirectory, layer.roots, name, value, context));\n }\n }\n return sortProfiles(byName);\n}\n\n/**\n * Loads profiles from the global and repository configs, repository last.\n *\n * Configured roots accumulate and inspect themselves or their direct-child\n * directories for persona files. Later discoveries replace earlier names, and\n * explicit entries replace discoveries. Legacy flat profile mappings remain\n * accepted as explicit entries.\n */\nexport async function loadProfilesAsync(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n homeDirectory: string = nodeHost.homeDirectory(),\n): Promise<AgentProfile[]> {\n return profilesFromLayers(fs, await readProfileLayers(fs, repoRoot, context, homeDirectory), context);\n}\n\n/** The profile catalog plus the name a launch starts on when the caller names none. */\nexport async function loadProfileCatalogAsync(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n homeDirectory: string = nodeHost.homeDirectory(),\n): Promise<{ profiles: AgentProfile[]; defaultProfile?: string }> {\n const layers = await readProfileLayers(fs, repoRoot, context, homeDirectory);\n const profiles = await profilesFromLayers(fs, layers, context);\n const defaultProfile = catalogDefaultProfile(layers, profiles);\n return { profiles, ...(defaultProfile === undefined ? {} : { defaultProfile }) };\n}\n\n/** Resolves one selected profile and fails clearly when its name is unknown. */\nexport async function resolveProfileAsync(\n fs: FileSystem,\n repoRoot: string,\n name: string,\n context: IoContext,\n homeDirectory?: string,\n): Promise<AgentProfile> {\n const profiles = await loadProfilesAsync(fs, repoRoot, context, homeDirectory);\n const profile = profiles.find((candidate) => candidate.name === name);\n if (!profile) throw new Error(`Unknown profile: ${name}`);\n return profile;\n}\n\nexport async function listProfileNamesAsync(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n homeDirectory?: string,\n): Promise<string[]> {\n return (await loadProfilesAsync(fs, repoRoot, context, homeDirectory)).map((profile) => profile.name);\n}\n\nexport { PERSONA_FILES, applyProfileEnvironment, replaceProfileEnvironment } from './core';\nexport type { AgentProfile } from './core';\nexport { buildPersonaPrompt, listProfileNames, loadProfileCatalog, loadProfiles, resolveProfile } from './sync';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,QAAQ;AACd,MAAM,aAAa;CAAC;CAAQ;CAAQ;AAAO;AAE3C,SAASA,WAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,OAAkD;CACnE,IAAI,CAACA,WAAS,KAAK,GAAG,OAAO,KAAA;CAC7B,MAAM,QAAQ,OAAO,MAAM,UAAU,YAAY,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,IAAI,MAAM,MAAM,KAAK,IAAI,KAAA;CACtG,MAAM,OAAO,OAAO,MAAM,SAAS,YAAY,OAAO,SAAS,MAAM,IAAI,IAAI,MAAM,OAAO,KAAA;CAC1F,IAAI,UAAU,KAAA,KAAa,SAAS,KAAA,GAAW,OAAO,KAAA;CACtD,OAAO;EAAE,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM;EAAI,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;CAAG;AAC9F;AAEA,SAAS,gBAAgB,QAAiE;CACxF,MAAM,OAAO,OAAO,OAAO,SAAS,YAAY,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,IAAI,KAAA;CACrG,MAAM,OAAO,OAAO,OAAO,SAAS,YAAY,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,IAAI,KAAA;CACrG,MAAM,QAAQ,UAAU,OAAO,KAAK;CACpC,IAAI,SAAS,KAAA,KAAa,SAAS,KAAA,KAAa,UAAU,KAAA,GAAW,OAAO,KAAA;CAC5E,OAAO;EACL,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;EACrC,GAAI,S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CACzB,OAAO,mBAAmB,IAAI,MAAM,kBAAkB,IAAI,UAAU,SAAS,aAAa,GAAG,OAAO;AACtG;;AAGA,eAAsB,wBACpB,IACA,UACA,SACA,gBAAwBA,4BAAAA,SAAS,cAAc,GACiB;CAChE,MAAM,SAAS,MAAM,kBAAkB,IAAI,UAAU,SAAS,aAAa;CAC3E,MAAM,WAAW,MAAM,mBAAmB,IAAI,QAAQ,OAAO;CAC7D,MAAM,iBAAiB,sBAAsB,QAAQ,QAAQ;CAC7D,OAAO;EAAE;EAAU,GAAI,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,eAAe;CAAG;AACjF;;AAGA,eAAsB,oBACpB,IACA,UACA,MACA,SACA,eACuB;CAEvB,MAAM,WAAU,MADO,kBAAkB,IAAI,UAAU,SAAS,aAAa,EAAA,CACpD,MAAM,cAAc,UAAU,SAAS,IAAI;CACpE,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,oBAAoB,MAAM;CACxD,OAAO;AACT;AAEA,eAAsB,sBACpB,IACA,UACA,SACA,eACmB;CACnB,QAAQ,MAAM,kBAAkB,IAAI,UAAU,SAAS,aAAa,EAAA,CAAG,KAAK,YAAY,QAAQ,IAAI;AACtG"}
package/dist/profiles.cjs CHANGED
@@ -1,13 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_profiles = require("./profiles-tpplXY4r.cjs");
2
+ const require_profiles = require("./profiles-t2EUj0aB.cjs");
3
3
  exports.PERSONA_FILES = require_profiles.PERSONA_FILES;
4
4
  exports.applyProfileEnvironment = require_profiles.applyProfileEnvironment;
5
5
  exports.buildPersonaPrompt = require_profiles.buildPersonaPrompt;
6
+ exports.buildPersonaPromptAsync = require_profiles.buildPersonaPromptAsync;
6
7
  exports.listProfileNames = require_profiles.listProfileNames;
8
+ exports.listProfileNamesAsync = require_profiles.listProfileNamesAsync;
7
9
  exports.loadProfileCatalog = require_profiles.loadProfileCatalog;
10
+ exports.loadProfileCatalogAsync = require_profiles.loadProfileCatalogAsync;
8
11
  exports.loadProfiles = require_profiles.loadProfiles;
12
+ exports.loadProfilesAsync = require_profiles.loadProfilesAsync;
9
13
  exports.parsePersonaFrontMatter = require_profiles.parsePersonaFrontMatter;
10
14
  exports.parseProfileBinding = require_profiles.parseProfileBinding;
11
15
  exports.readPersonaIcon = require_profiles.readPersonaIcon;
16
+ exports.readPersonaIconAsync = require_profiles.readPersonaIconAsync;
12
17
  exports.replaceProfileEnvironment = require_profiles.replaceProfileEnvironment;
13
18
  exports.resolveProfile = require_profiles.resolveProfile;
19
+ exports.resolveProfileAsync = require_profiles.resolveProfileAsync;
@@ -1,5 +1,7 @@
1
1
  import { i as PersonaVoiceOverride, n as PersonaFrontMatter, r as PersonaIdentity, t as PersonaDocument } from "./profiles-CTrUCmIh.mjs";
2
- import { a as listProfileNames, c as replaceProfileEnvironment, d as ProfileIntegrationBinding, f as ProfileSecretReference, i as buildPersonaPrompt, l as resolveProfile, n as PERSONA_FILES, o as loadProfileCatalog, r as applyProfileEnvironment, s as loadProfiles, t as AgentProfile, u as ProfileBrowserBinding } from "./index-DNk4q0Qm.mjs";
2
+ import { a as resolveProfileAsync, c as applyProfileEnvironment, d as ProfileIntegrationBinding, f as ProfileSecretReference, i as loadProfilesAsync, l as replaceProfileEnvironment, n as listProfileNamesAsync, o as AgentProfile, r as loadProfileCatalogAsync, s as PERSONA_FILES, t as buildPersonaPromptAsync, u as ProfileBrowserBinding } from "./index-Nbj2iQWw.mjs";
3
+ import { a as resolveProfile, i as loadProfiles, n as listProfileNames, r as loadProfileCatalog, t as buildPersonaPrompt } from "./sync-CC_15kkB.mjs";
4
+ import { FileSystem } from "@agimon-ai/po-core/platform";
3
5
  //#region src/services/personaFrontMatter/index.d.ts
4
6
  /**
5
7
  * Splits a recognised identity block off a persona document.
@@ -9,17 +11,39 @@ import { a as listProfileNames, c as replaceProfileEnvironment, d as ProfileInte
9
11
  */
10
12
  export declare function parsePersonaFrontMatter(content: string): PersonaDocument;
11
13
  //#endregion
12
- //#region src/services/personaIcon/index.d.ts
14
+ //#region src/services/personaIcon/sync.d.ts
13
15
  /**
14
16
  * Resolves an icon declared in persona front-matter, or undefined when it is
15
17
  * missing, unreadable, not an allowed image, escapes the persona directory, or
16
18
  * exceeds the data-URL ceiling.
19
+ *
20
+ * @deprecated Node-only sync shim; use readPersonaIconAsync. Removed in M2.
17
21
  */
18
22
  export declare function readPersonaIcon(personaPath: string, iconRelative: string): string | undefined;
19
23
  //#endregion
24
+ //#region src/services/personaIcon/index.d.ts
25
+ type IoContext = Parameters<FileSystem['readTextFile']>[1];
26
+ /**
27
+ * Reads a persona icon into a bounded `data:` URL.
28
+ *
29
+ * The icon travels inside the journalled identity entry rather than through an
30
+ * HTTP route. A route would leave a request-time filesystem resolution reachable
31
+ * from the browser for the life of a session, defended on every request forever;
32
+ * this resolves the path once, server side, at the moment the profile loads.
33
+ *
34
+ * The path comes from user-authored front-matter, so it is confined the same way
35
+ * `buildPersonaPrompt` confines persona files: a symlink must not read outside
36
+ * the persona directory.
37
+ *
38
+ * Every failure is silent and returns undefined. An avatar is decoration, and a
39
+ * broken one must never stop a persona from loading. That includes a host whose
40
+ * filesystem lacks the persona entirely, such as the edge.
41
+ */
42
+ export declare function readPersonaIconAsync(fs: FileSystem, personaPath: string, iconRelative: string, context: IoContext): Promise<string | undefined>;
43
+ //#endregion
20
44
  //#region src/services/profileBinding/index.d.ts
21
45
  /** Validates and deeply freezes a detached metadata snapshot. No provider SDK or secret is loaded. */
22
46
  export declare function parseProfileBinding(value: unknown, location?: string): ProfileIntegrationBinding;
23
47
  //#endregion
24
- export { type AgentProfile, PERSONA_FILES, type PersonaFrontMatter, type PersonaIdentity, type PersonaVoiceOverride, type ProfileBrowserBinding, type ProfileIntegrationBinding, type ProfileSecretReference, applyProfileEnvironment, buildPersonaPrompt, listProfileNames, loadProfileCatalog, loadProfiles, replaceProfileEnvironment, resolveProfile };
48
+ export { type AgentProfile, PERSONA_FILES, type PersonaFrontMatter, type PersonaIdentity, type PersonaVoiceOverride, type ProfileBrowserBinding, type ProfileIntegrationBinding, type ProfileSecretReference, applyProfileEnvironment, buildPersonaPrompt, buildPersonaPromptAsync, listProfileNames, listProfileNamesAsync, loadProfileCatalog, loadProfileCatalogAsync, loadProfiles, loadProfilesAsync, replaceProfileEnvironment, resolveProfile, resolveProfileAsync };
25
49
  //# sourceMappingURL=profiles.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.d.mts","names":[],"sources":["../src/services/personaFrontMatter/index.ts","../src/services/personaIcon/index.ts","../src/services/profileBinding/index.ts"],"mappings":";;;;;;;;;wBAqDgB,wBAAwB,kBAAkB;;;;;;;;wBCC1C,gBAAgB,qBAAqB;;;;wBCQrC,oBAAoB,gBAAgB,oBAAmC"}
1
+ {"version":3,"file":"profiles.d.mts","names":[],"sources":["../src/services/personaFrontMatter/index.ts","../src/services/personaIcon/sync.ts","../src/services/personaIcon/index.ts","../src/services/profileBinding/index.ts"],"mappings":";;;;;;;;;;;wBAqDgB,wBAAwB,kBAAkB;;;;;;;;;;wBCzC1C,gBAAgB,qBAAqB;;;KCNhD,YAAY,WAAW;;;;;;;;;;;;;;;;;wBAkBN,qBACpB,IAAI,YACJ,qBACA,sBACA,SAAS,YACR;;;;wBCiCa,oBAAoB,gBAAgB,oBAAmC"}
package/dist/profiles.mjs CHANGED
@@ -1,2 +1 @@
1
- import { a as loadProfileCatalog, c as resolveProfile, d as parsePersonaFrontMatter, i as listProfileNames, l as parseProfileBinding, n as applyProfileEnvironment, o as loadProfiles, r as buildPersonaPrompt, s as replaceProfileEnvironment, t as PERSONA_FILES, u as readPersonaIcon } from "./profiles-DBcYg5nA.mjs";
2
- export { PERSONA_FILES, applyProfileEnvironment, buildPersonaPrompt, listProfileNames, loadProfileCatalog, loadProfiles, parsePersonaFrontMatter, parseProfileBinding, readPersonaIcon, replaceProfileEnvironment, resolveProfile };
1
+ export { d as PERSONA_FILES, f as applyProfileEnvironment, o as buildPersonaPrompt, t as buildPersonaPromptAsync, s as listProfileNames, n as listProfileNamesAsync, c as loadProfileCatalog, r as loadProfileCatalogAsync, l as loadProfiles, i as loadProfilesAsync, _ as parsePersonaFrontMatter, m as parseProfileBinding, g as readPersonaIcon, h as readPersonaIconAsync, p as replaceProfileEnvironment, u as resolveProfile, a as resolveProfileAsync } from "./profiles-CHict0x-.mjs";
@@ -1,14 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
- const require_harnessStore = require("./harnessStore-CJSxdSkV.cjs");
4
- const require_majorModes = require("./majorModes-DnNSH9ZK.cjs");
5
- const require_profiles = require("./profiles-tpplXY4r.cjs");
6
- let node_fs = require("node:fs");
7
- node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
3
+ const require_harnessStore = require("./harnessStore-BinxGITh.cjs");
4
+ const require_majorModes = require("./majorModes-CLccNMZt.cjs");
5
+ const require_profiles = require("./profiles-t2EUj0aB.cjs");
8
6
  let node_path = require("node:path");
9
7
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
10
- //#region src/services/selectionSwitch/index.ts
11
- const PERSONA_FILE = "persona.md";
8
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
9
+ let node_fs = require("node:fs");
10
+ node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
11
+ //#region src/services/selectionSwitch/core.ts
12
12
  /**
13
13
  * Applying a selection axis to harness state.
14
14
  *
@@ -21,16 +21,47 @@ const PERSONA_FILE = "persona.md";
21
21
  * --major-mode and --profile flags before any command exists to run them.
22
22
  * Domains is the exception and stays with its resource staging.
23
23
  */
24
- /** Applies one major mode and the hook groups its effective layers contribute. */
25
- function applyMajorMode(config, majorMode, state, compositionFingerprint, childExtensions) {
24
+ const PERSONA_FILE = "persona.md";
25
+ /** The state patch for one major mode and the hook groups its effective layers contribute. */
26
+ function majorModePatch(config, majorMode, state, compositionFingerprint, childExtensions) {
26
27
  const selected = require_majorModes.filterHookDisabledLayers(config, require_majorModes.resolveLayers(config, majorMode), state.hooks);
27
- return require_harnessStore.updateHarnessState({
28
+ return {
28
29
  majorMode,
29
30
  layers: selected,
30
31
  compositionFingerprint,
31
32
  ...childExtensions ? { childExtensions: [...childExtensions] } : {},
32
33
  hookGroups: require_majorModes.layerHookGroups(config, selected)
33
- });
34
+ };
35
+ }
36
+ /**
37
+ * Written unconditionally, including as undefined, so switching to a profile
38
+ * that declares nothing clears the previous persona's name, icon, and voice.
39
+ */
40
+ function profilePatch(profile, profileEnvironment) {
41
+ return {
42
+ profile: profile.name,
43
+ profileEnvironment,
44
+ profileIdentity: profile.identity,
45
+ profileVoice: profile.voice
46
+ };
47
+ }
48
+ function noPersonaFiles(profile) {
49
+ return /* @__PURE__ */ new Error(`Profile ${profile.name} has no readable persona files`);
50
+ }
51
+ function profileSummary(profile) {
52
+ const environmentKeys = Object.keys(profile.env).sort();
53
+ const environmentSummary = environmentKeys.length > 0 ? `; env defaults ${environmentKeys.join(", ")}` : "";
54
+ return `Loaded ${profile.name}: persona ${profile.persona}${environmentSummary}.`;
55
+ }
56
+ //#endregion
57
+ //#region src/services/selectionSwitch/sync.ts
58
+ /**
59
+ * Applies one major mode and the hook groups its effective layers contribute.
60
+ *
61
+ * @deprecated Node-only sync shim; use applyMajorModeAsync. Removed in M2.
62
+ */
63
+ function applyMajorMode(config, majorMode, state, compositionFingerprint, childExtensions) {
64
+ return require_harnessStore.updateHarnessState(majorModePatch(config, majorMode, state, compositionFingerprint, childExtensions));
34
65
  }
35
66
  /**
36
67
  * Persona: rewrites the assembled prompt file that the persona extension reads.
@@ -38,6 +69,8 @@ function applyMajorMode(config, majorMode, state, compositionFingerprint, childE
38
69
  * The extension re-reads the file on reload and appends its block to whatever
39
70
  * system prompt it is given, so the repository's own AGENTS.md keeps applying
40
71
  * underneath. Returns false when the directories hold no readable persona.
72
+ *
73
+ * @deprecated Node-only shim over node:fs; use applyPersonaAsync. Removed in M2.
41
74
  */
42
75
  async function applyPersona(personaDirectory, state, personaRoot) {
43
76
  const { root, temporaryDirectory } = require_harnessStore.requireHarnessPaths(state);
@@ -48,23 +81,56 @@ async function applyPersona(personaDirectory, state, personaRoot) {
48
81
  require_harnessStore.updateHarnessState({ personaFile: personaPath });
49
82
  return true;
50
83
  }
51
- /** Profile: one persona plus the environment defaults it declares. */
84
+ /**
85
+ * Profile: one persona plus the environment defaults it declares.
86
+ *
87
+ * @deprecated Node-only shim over node:fs; use applyProfileAsync. Removed in M2.
88
+ */
52
89
  async function applyProfile(profile, state) {
53
- if (!await applyPersona(profile.persona, state, profile.personaRoot)) throw new Error(`Profile ${profile.name} has no readable persona files`);
90
+ if (!await applyPersona(profile.persona, state, profile.personaRoot)) throw noPersonaFiles(profile);
54
91
  const profileEnvironment = require_profiles.replaceProfileEnvironment(process.env, state.profileEnvironment, profile.env);
55
- require_harnessStore.updateHarnessState({
56
- profile: profile.name,
57
- profileEnvironment,
58
- profileIdentity: profile.identity,
59
- profileVoice: profile.voice
60
- });
61
- const environmentKeys = Object.keys(profile.env).sort();
62
- const environmentSummary = environmentKeys.length > 0 ? `; env defaults ${environmentKeys.join(", ")}` : "";
63
- return `Loaded ${profile.name}: persona ${profile.persona}${environmentSummary}.`;
92
+ require_harnessStore.updateHarnessState(profilePatch(profile, profileEnvironment));
93
+ return profileSummary(profile);
94
+ }
95
+ //#endregion
96
+ //#region src/services/selectionSwitch/index.ts
97
+ /** Applies one major mode over a FileSystem; the same patch `applyMajorMode` writes. */
98
+ async function applyMajorModeAsync(fs, config, majorMode, state, context, options = {}) {
99
+ const patch = majorModePatch(config, majorMode, state, options.compositionFingerprint, options.childExtensions);
100
+ return require_harnessStore.updateHarnessStateAsync(fs, patch, options.environment ?? process.env, context);
101
+ }
102
+ /**
103
+ * Persona over a FileSystem: rewrites the assembled prompt file that the persona
104
+ * extension reads, readable by its owner only. Returns false when the
105
+ * directories hold no readable persona.
106
+ */
107
+ async function applyPersonaAsync(fs, personaDirectory, state, context, options = {}) {
108
+ const { root, temporaryDirectory } = require_harnessStore.requireHarnessPaths(state);
109
+ const prompt = await require_profiles.buildPersonaPromptAsync(fs, options.personaRoot ?? root, personaDirectory, context);
110
+ if (!prompt) return false;
111
+ const personaPath = node_path.default.join(temporaryDirectory, PERSONA_FILE);
112
+ await (0, _agimon_ai_po_core_platform.writeFileAtomic)(fs, personaPath, `${prompt}\n`, context);
113
+ await _agimon_ai_po_core_platform.nodeHost.setMode(personaPath, 384);
114
+ await require_harnessStore.updateHarnessStateAsync(fs, { personaFile: personaPath }, options.environment ?? process.env, context);
115
+ return true;
116
+ }
117
+ /** Profile over a FileSystem: one persona plus the environment defaults it declares. */
118
+ async function applyProfileAsync(fs, profile, state, context, options = {}) {
119
+ const environment = options.environment ?? process.env;
120
+ if (!await applyPersonaAsync(fs, profile.persona, state, context, {
121
+ environment,
122
+ personaRoot: profile.personaRoot
123
+ })) throw noPersonaFiles(profile);
124
+ const profileEnvironment = require_profiles.replaceProfileEnvironment(environment, state.profileEnvironment, profile.env);
125
+ await require_harnessStore.updateHarnessStateAsync(fs, profilePatch(profile, profileEnvironment), environment, context);
126
+ return profileSummary(profile);
64
127
  }
65
128
  //#endregion
66
129
  exports.applyMajorMode = applyMajorMode;
130
+ exports.applyMajorModeAsync = applyMajorModeAsync;
67
131
  exports.applyPersona = applyPersona;
132
+ exports.applyPersonaAsync = applyPersonaAsync;
68
133
  exports.applyProfile = applyProfile;
134
+ exports.applyProfileAsync = applyProfileAsync;
69
135
 
70
136
  //# sourceMappingURL=selectionSwitch.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectionSwitch.cjs","names":["filterHookDisabledLayers","resolveLayers","updateHarnessState","layerHookGroups","requireHarnessPaths","buildPersonaPrompt","path","fs","replaceProfileEnvironment"],"sources":["../src/services/selectionSwitch/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { DoomHarnessContext, HarnessState } from '../../types/config';\nimport { requireHarnessPaths, updateHarnessState } from '../harnessStore';\nimport { filterHookDisabledLayers, layerHookGroups, type MajorModesConfig, resolveLayers } from '../majorModes';\nimport { type AgentProfile, buildPersonaPrompt, replaceProfileEnvironment } from '../profiles';\n\nconst PERSONA_FILE = 'persona.md';\n\n/**\n * Applying a selection axis to harness state.\n *\n * Every axis writes through the harness store and relies on Pi's reload\n * re-executing extension modules, which drops their module-level caches and\n * makes them re-read the environment.\n *\n * These live here rather than in the packages that own the /mode and /profile\n * commands because the synced startup path applies the same switches from its\n * --major-mode and --profile flags before any command exists to run them.\n * Domains is the exception and stays with its resource staging.\n */\n\n/** Applies one major mode and the hook groups its effective layers contribute. */\nexport function applyMajorMode(\n config: MajorModesConfig,\n majorMode: string,\n state: DoomHarnessContext,\n compositionFingerprint?: string,\n childExtensions?: readonly string[],\n): HarnessState {\n const selected = filterHookDisabledLayers(config, resolveLayers(config, majorMode), state.hooks);\n return updateHarnessState({\n majorMode,\n layers: selected,\n compositionFingerprint,\n ...(childExtensions ? { childExtensions: [...childExtensions] } : {}),\n hookGroups: layerHookGroups(config, selected),\n });\n}\n\n/**\n * Persona: rewrites the assembled prompt file that the persona extension reads.\n *\n * The extension re-reads the file on reload and appends its block to whatever\n * system prompt it is given, so the repository's own AGENTS.md keeps applying\n * underneath. Returns false when the directories hold no readable persona.\n */\nexport async function applyPersona(\n personaDirectory: string,\n state: DoomHarnessContext,\n personaRoot?: string,\n): Promise<boolean> {\n const { root, temporaryDirectory } = requireHarnessPaths(state);\n\n const prompt = buildPersonaPrompt(personaRoot ?? root, personaDirectory);\n if (!prompt) return false;\n\n const personaPath = path.join(temporaryDirectory, PERSONA_FILE);\n await fs.promises.writeFile(personaPath, `${prompt}\\n`, { mode: 0o600 });\n updateHarnessState({ personaFile: personaPath });\n return true;\n}\n\n/** Profile: one persona plus the environment defaults it declares. */\nexport async function applyProfile(profile: AgentProfile, state: DoomHarnessContext): Promise<string> {\n const appliedPersona = await applyPersona(profile.persona, state, profile.personaRoot);\n if (!appliedPersona) throw new Error(`Profile ${profile.name} has no readable persona files`);\n\n const profileEnvironment = replaceProfileEnvironment(process.env, state.profileEnvironment, profile.env);\n // Written unconditionally, including as undefined, so switching to a profile\n // that declares nothing clears the previous persona's name, icon, and voice.\n updateHarnessState({\n profile: profile.name,\n profileEnvironment,\n profileIdentity: profile.identity,\n profileVoice: profile.voice,\n });\n\n const environmentKeys = Object.keys(profile.env).sort();\n const environmentSummary = environmentKeys.length > 0 ? `; env defaults ${environmentKeys.join(', ')}` : '';\n return `Loaded ${profile.name}: persona ${profile.persona}${environmentSummary}.`;\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAM,eAAe;;;;;;;;;;;;;;AAgBrB,SAAgB,eACd,QACA,WACA,OACA,wBACA,iBACc;CACd,MAAM,WAAWA,mBAAAA,yBAAyB,QAAQC,mBAAAA,cAAc,QAAQ,SAAS,GAAG,MAAM,KAAK;CAC/F,OAAOC,qBAAAA,mBAAmB;EACxB;EACA,QAAQ;EACR;EACA,GAAI,kBAAkB,EAAE,iBAAiB,CAAC,GAAG,eAAe,EAAE,IAAI,CAAC;EACnE,YAAYC,mBAAAA,gBAAgB,QAAQ,QAAQ;CAC9C,CAAC;AACH;;;;;;;;AASA,eAAsB,aACpB,kBACA,OACA,aACkB;CAClB,MAAM,EAAE,MAAM,uBAAuBC,qBAAAA,oBAAoB,KAAK;CAE9D,MAAM,SAASC,iBAAAA,mBAAmB,eAAe,MAAM,gBAAgB;CACvE,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,cAAcC,UAAAA,QAAK,KAAK,oBAAoB,YAAY;CAC9D,MAAMC,QAAAA,QAAG,SAAS,UAAU,aAAa,GAAG,OAAO,KAAK,EAAE,MAAM,IAAM,CAAC;CACvE,qBAAA,mBAAmB,EAAE,aAAa,YAAY,CAAC;CAC/C,OAAO;AACT;;AAGA,eAAsB,aAAa,SAAuB,OAA4C;CAEpG,IAAI,CAAC,MADwB,aAAa,QAAQ,SAAS,OAAO,QAAQ,WAAW,GAChE,MAAM,IAAI,MAAM,WAAW,QAAQ,KAAK,+BAA+B;CAE5F,MAAM,qBAAqBC,iBAAAA,0BAA0B,QAAQ,KAAK,MAAM,oBAAoB,QAAQ,GAAG;CAGvG,qBAAA,mBAAmB;EACjB,SAAS,QAAQ;EACjB;EACA,iBAAiB,QAAQ;EACzB,cAAc,QAAQ;CACxB,CAAC;CAED,MAAM,kBAAkB,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK;CACtD,MAAM,qBAAqB,gBAAgB,SAAS,IAAI,kBAAkB,gBAAgB,KAAK,IAAI,MAAM;CACzG,OAAO,UAAU,QAAQ,KAAK,YAAY,QAAQ,UAAU,mBAAmB;AACjF"}
1
+ {"version":3,"file":"selectionSwitch.cjs","names":["filterHookDisabledLayers","resolveLayers","layerHookGroups","updateHarnessState","requireHarnessPaths","buildPersonaPrompt","path","fs","replaceProfileEnvironment","updateHarnessStateAsync","requireHarnessPaths","buildPersonaPromptAsync","path","writeFileAtomic","nodeHost","replaceProfileEnvironment"],"sources":["../src/services/selectionSwitch/core.ts","../src/services/selectionSwitch/sync.ts","../src/services/selectionSwitch/index.ts"],"sourcesContent":["import type { PoHarnessContext, HarnessState } from '../../types/config';\nimport { filterHookDisabledLayers, layerHookGroups, type MajorModesConfig, resolveLayers } from '../majorModes';\nimport type { AgentProfile } from '../profiles';\n\n/**\n * Applying a selection axis to harness state.\n *\n * Every axis writes through the harness store and relies on Pi's reload\n * re-executing extension modules, which drops their module-level caches and\n * makes them re-read the environment.\n *\n * These live here rather than in the packages that own the /mode and /profile\n * commands because the synced startup path applies the same switches from its\n * --major-mode and --profile flags before any command exists to run them.\n * Domains is the exception and stays with its resource staging.\n */\n\nexport const PERSONA_FILE = 'persona.md';\nexport const PERSONA_FILE_MODE = 0o600;\n\n/** The state patch for one major mode and the hook groups its effective layers contribute. */\nexport function majorModePatch(\n config: MajorModesConfig,\n majorMode: string,\n state: PoHarnessContext,\n compositionFingerprint?: string,\n childExtensions?: readonly string[],\n): Partial<HarnessState> {\n const selected = filterHookDisabledLayers(config, resolveLayers(config, majorMode), state.hooks);\n return {\n majorMode,\n layers: selected,\n compositionFingerprint,\n ...(childExtensions ? { childExtensions: [...childExtensions] } : {}),\n hookGroups: layerHookGroups(config, selected),\n };\n}\n\n/**\n * Written unconditionally, including as undefined, so switching to a profile\n * that declares nothing clears the previous persona's name, icon, and voice.\n */\nexport function profilePatch(profile: AgentProfile, profileEnvironment: Record<string, string>): Partial<HarnessState> {\n return {\n profile: profile.name,\n profileEnvironment,\n profileIdentity: profile.identity,\n profileVoice: profile.voice,\n };\n}\n\nexport function noPersonaFiles(profile: AgentProfile): Error {\n return new Error(`Profile ${profile.name} has no readable persona files`);\n}\n\nexport function profileSummary(profile: AgentProfile): string {\n const environmentKeys = Object.keys(profile.env).sort();\n const environmentSummary = environmentKeys.length > 0 ? `; env defaults ${environmentKeys.join(', ')}` : '';\n return `Loaded ${profile.name}: persona ${profile.persona}${environmentSummary}.`;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { PoHarnessContext, HarnessState } from '../../types/config';\nimport { requireHarnessPaths, updateHarnessState } from '../harnessStore';\nimport type { MajorModesConfig } from '../majorModes';\nimport { type AgentProfile, buildPersonaPrompt, replaceProfileEnvironment } from '../profiles';\nimport { PERSONA_FILE, PERSONA_FILE_MODE, majorModePatch, noPersonaFiles, profilePatch, profileSummary } from './core';\n\n/**\n * Applies one major mode and the hook groups its effective layers contribute.\n *\n * @deprecated Node-only sync shim; use applyMajorModeAsync. Removed in M2.\n */\nexport function applyMajorMode(\n config: MajorModesConfig,\n majorMode: string,\n state: PoHarnessContext,\n compositionFingerprint?: string,\n childExtensions?: readonly string[],\n): HarnessState {\n return updateHarnessState(majorModePatch(config, majorMode, state, compositionFingerprint, childExtensions));\n}\n\n/**\n * Persona: rewrites the assembled prompt file that the persona extension reads.\n *\n * The extension re-reads the file on reload and appends its block to whatever\n * system prompt it is given, so the repository's own AGENTS.md keeps applying\n * underneath. Returns false when the directories hold no readable persona.\n *\n * @deprecated Node-only shim over node:fs; use applyPersonaAsync. Removed in M2.\n */\nexport async function applyPersona(\n personaDirectory: string,\n state: PoHarnessContext,\n personaRoot?: string,\n): Promise<boolean> {\n const { root, temporaryDirectory } = requireHarnessPaths(state);\n\n const prompt = buildPersonaPrompt(personaRoot ?? root, personaDirectory);\n if (!prompt) return false;\n\n const personaPath = path.join(temporaryDirectory, PERSONA_FILE);\n await fs.promises.writeFile(personaPath, `${prompt}\\n`, { mode: PERSONA_FILE_MODE });\n updateHarnessState({ personaFile: personaPath });\n return true;\n}\n\n/**\n * Profile: one persona plus the environment defaults it declares.\n *\n * @deprecated Node-only shim over node:fs; use applyProfileAsync. Removed in M2.\n */\nexport async function applyProfile(profile: AgentProfile, state: PoHarnessContext): Promise<string> {\n const appliedPersona = await applyPersona(profile.persona, state, profile.personaRoot);\n if (!appliedPersona) throw noPersonaFiles(profile);\n\n const profileEnvironment = replaceProfileEnvironment(process.env, state.profileEnvironment, profile.env);\n updateHarnessState(profilePatch(profile, profileEnvironment));\n return profileSummary(profile);\n}\n","import path from 'node:path';\n\nimport { nodeHost, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport type { PoHarnessContext, HarnessState } from '../../types/config';\nimport { requireHarnessPaths, updateHarnessStateAsync } from '../harnessStore';\nimport type { MajorModesConfig } from '../majorModes';\nimport { type AgentProfile, buildPersonaPromptAsync, replaceProfileEnvironment } from '../profiles';\nimport { PERSONA_FILE, PERSONA_FILE_MODE, majorModePatch, noPersonaFiles, profilePatch, profileSummary } from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface SelectionSwitchOptions {\n /** The environment the harness state pointer lives in. Defaults to `process.env`. */\n readonly environment?: NodeJS.ProcessEnv;\n}\n\n/** Applies one major mode over a FileSystem; the same patch `applyMajorMode` writes. */\nexport async function applyMajorModeAsync(\n fs: FileSystem,\n config: MajorModesConfig,\n majorMode: string,\n state: PoHarnessContext,\n context: IoContext,\n options: SelectionSwitchOptions & {\n readonly compositionFingerprint?: string;\n readonly childExtensions?: readonly string[];\n } = {},\n): Promise<HarnessState> {\n const patch = majorModePatch(config, majorMode, state, options.compositionFingerprint, options.childExtensions);\n return updateHarnessStateAsync(fs, patch, options.environment ?? process.env, context);\n}\n\n/**\n * Persona over a FileSystem: rewrites the assembled prompt file that the persona\n * extension reads, readable by its owner only. Returns false when the\n * directories hold no readable persona.\n */\nexport async function applyPersonaAsync(\n fs: FileSystem,\n personaDirectory: string,\n state: PoHarnessContext,\n context: IoContext,\n options: SelectionSwitchOptions & { readonly personaRoot?: string } = {},\n): Promise<boolean> {\n const { root, temporaryDirectory } = requireHarnessPaths(state);\n\n const prompt = await buildPersonaPromptAsync(fs, options.personaRoot ?? root, personaDirectory, context);\n if (!prompt) return false;\n\n const personaPath = path.join(temporaryDirectory, PERSONA_FILE);\n await writeFileAtomic(fs, personaPath, `${prompt}\\n`, context);\n await nodeHost.setMode(personaPath, PERSONA_FILE_MODE);\n await updateHarnessStateAsync(fs, { personaFile: personaPath }, options.environment ?? process.env, context);\n return true;\n}\n\n/** Profile over a FileSystem: one persona plus the environment defaults it declares. */\nexport async function applyProfileAsync(\n fs: FileSystem,\n profile: AgentProfile,\n state: PoHarnessContext,\n context: IoContext,\n options: SelectionSwitchOptions = {},\n): Promise<string> {\n const environment = options.environment ?? process.env;\n const appliedPersona = await applyPersonaAsync(fs, profile.persona, state, context, {\n environment,\n personaRoot: profile.personaRoot,\n });\n if (!appliedPersona) throw noPersonaFiles(profile);\n\n const profileEnvironment = replaceProfileEnvironment(environment, state.profileEnvironment, profile.env);\n await updateHarnessStateAsync(fs, profilePatch(profile, profileEnvironment), environment, context);\n return profileSummary(profile);\n}\n\nexport { applyMajorMode, applyPersona, applyProfile } from './sync';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,eAAe;;AAI5B,SAAgB,eACd,QACA,WAC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ACA,aAAa,QAAQ;CACvB,CAAC,GACoB,MAAM,eAAe,OAAO;CAEjD,MAAM,qBAAqBM,iBAAAA,0BAA0B,aAAa,MAAM,oBAAoB,QAAQ,GAAG;CACvG,MAAMN,qBAAAA,wBAAwB,IAAI,aAAa,SAAS,kBAAkB,GAAG,aAAa,OAAO;CACjG,OAAO,eAAe,OAAO;AAC/B"}
@@ -1,30 +1,52 @@
1
- import { v as DoomHarnessContext, x as HarnessState } from "./config-D2HbBLzo.mjs";
2
- import { o as MajorModesConfig } from "./index-CkDDvVQt.mjs";
3
- import { t as AgentProfile } from "./index-DNk4q0Qm.mjs";
4
- //#region src/services/selectionSwitch/index.d.ts
1
+ import { k as PoHarnessContext, l as HarnessState } from "./config-pxC7FyUJ.mjs";
2
+ import { f as MajorModesConfig } from "./index-BNcG0voG.mjs";
3
+ import { o as AgentProfile } from "./index-Nbj2iQWw.mjs";
4
+ import { FileSystem } from "@agimon-ai/po-core/platform";
5
+ //#region src/services/selectionSwitch/sync.d.ts
5
6
  /**
6
- * Applying a selection axis to harness state.
7
- *
8
- * Every axis writes through the harness store and relies on Pi's reload
9
- * re-executing extension modules, which drops their module-level caches and
10
- * makes them re-read the environment.
7
+ * Applies one major mode and the hook groups its effective layers contribute.
11
8
  *
12
- * These live here rather than in the packages that own the /mode and /profile
13
- * commands because the synced startup path applies the same switches from its
14
- * --major-mode and --profile flags before any command exists to run them.
15
- * Domains is the exception and stays with its resource staging.
9
+ * @deprecated Node-only sync shim; use applyMajorModeAsync. Removed in M2.
16
10
  */
17
- /** Applies one major mode and the hook groups its effective layers contribute. */
18
- export declare function applyMajorMode(config: MajorModesConfig, majorMode: string, state: DoomHarnessContext, compositionFingerprint?: string, childExtensions?: readonly string[]): HarnessState;
11
+ export declare function applyMajorMode(config: MajorModesConfig, majorMode: string, state: PoHarnessContext, compositionFingerprint?: string, childExtensions?: readonly string[]): HarnessState;
19
12
  /**
20
13
  * Persona: rewrites the assembled prompt file that the persona extension reads.
21
14
  *
22
15
  * The extension re-reads the file on reload and appends its block to whatever
23
16
  * system prompt it is given, so the repository's own AGENTS.md keeps applying
24
17
  * underneath. Returns false when the directories hold no readable persona.
18
+ *
19
+ * @deprecated Node-only shim over node:fs; use applyPersonaAsync. Removed in M2.
20
+ */
21
+ export declare function applyPersona(personaDirectory: string, state: PoHarnessContext, personaRoot?: string): Promise<boolean>;
22
+ /**
23
+ * Profile: one persona plus the environment defaults it declares.
24
+ *
25
+ * @deprecated Node-only shim over node:fs; use applyProfileAsync. Removed in M2.
26
+ */
27
+ export declare function applyProfile(profile: AgentProfile, state: PoHarnessContext): Promise<string>;
28
+ //#endregion
29
+ //#region src/services/selectionSwitch/index.d.ts
30
+ type IoContext = Parameters<FileSystem['readTextFile']>[1];
31
+ interface SelectionSwitchOptions {
32
+ /** The environment the harness state pointer lives in. Defaults to `process.env`. */
33
+ readonly environment?: NodeJS.ProcessEnv;
34
+ }
35
+ /** Applies one major mode over a FileSystem; the same patch `applyMajorMode` writes. */
36
+ export declare function applyMajorModeAsync(fs: FileSystem, config: MajorModesConfig, majorMode: string, state: PoHarnessContext, context: IoContext, options?: SelectionSwitchOptions & {
37
+ readonly compositionFingerprint?: string;
38
+ readonly childExtensions?: readonly string[];
39
+ }): Promise<HarnessState>;
40
+ /**
41
+ * Persona over a FileSystem: rewrites the assembled prompt file that the persona
42
+ * extension reads, readable by its owner only. Returns false when the
43
+ * directories hold no readable persona.
25
44
  */
26
- export declare function applyPersona(personaDirectory: string, state: DoomHarnessContext, personaRoot?: string): Promise<boolean>;
27
- /** Profile: one persona plus the environment defaults it declares. */
28
- export declare function applyProfile(profile: AgentProfile, state: DoomHarnessContext): Promise<string>;
45
+ export declare function applyPersonaAsync(fs: FileSystem, personaDirectory: string, state: PoHarnessContext, context: IoContext, options?: SelectionSwitchOptions & {
46
+ readonly personaRoot?: string;
47
+ }): Promise<boolean>;
48
+ /** Profile over a FileSystem: one persona plus the environment defaults it declares. */
49
+ export declare function applyProfileAsync(fs: FileSystem, profile: AgentProfile, state: PoHarnessContext, context: IoContext, options?: SelectionSwitchOptions): Promise<string>;
29
50
  //#endregion
51
+ export type { SelectionSwitchOptions };
30
52
  //# sourceMappingURL=selectionSwitch.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectionSwitch.d.mts","names":[],"sources":["../src/services/selectionSwitch/index.ts"],"mappings":";;;;;;;;;;;;;;;;;wBAwBgB,eACd,QAAQ,kBACR,mBACA,OAAO,oBACP,iCACA,sCACC;;;;;;;;wBAkBmB,aACpB,0BACA,OAAO,oBACP,uBACC;;wBAamB,aAAa,SAAS,cAAc,OAAO,qBAAqB"}
1
+ {"version":3,"file":"selectionSwitch.d.mts","names":[],"sources":["../src/services/selectionSwitch/sync.ts","../src/services/selectionSwitch/index.ts"],"mappings":";;;;;;;;;;wBAcgB,eACd,QAAQ,kBACR,mBACA,OAAO,kBACP,iCACA,sCACC;;;;;;;;;;wBAamB,aACpB,0BACA,OAAO,kBACP,uBACC;;;;;;wBAiBmB,aAAa,SAAS,cAAc,OAAO,mBAAmB;;;KC5C/E,YAAY,WAAW;UAEX;;WAEN,cAAc,OAAO;;;wBAIV,oBACpB,IAAI,YACJ,QAAQ,kBACR,mBACA,OAAO,kBACP,SAAS,WACT,UAAS;WACE;WACA;IAEV,QAAQ;;;;;;wBAUW,kBACpB,IAAI,YACJ,0BACA,OAAO,kBACP,SAAS,WACT,UAAS;WAAoC;IAC5C;;wBAcmB,kBACpB,IAAI,YACJ,SAAS,cACT,OAAO,kBACP,SAAS,WACT,UAAS,yBACR"}