@agimon-ai/po-config 0.0.0-alpha.201 → 0.0.0-alpha.203

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 (126) hide show
  1. package/dist/{completion-BeLpnmA4.d.mts → completion-BrN-LdQ6.d.mts} +3 -3
  2. package/dist/{completion-BeLpnmA4.d.mts.map → completion-BrN-LdQ6.d.mts.map} +1 -1
  3. package/dist/{config-DB7YUo6N.cjs → config-BDoem3_a.cjs} +4 -5
  4. package/dist/{config-DB7YUo6N.cjs.map → config-BDoem3_a.cjs.map} +1 -1
  5. package/dist/{config-tk56d8mk.d.mts → config-CG_KJdcd.d.mts} +32 -2
  6. package/dist/config-CG_KJdcd.d.mts.map +1 -0
  7. package/dist/{config-BeErFE6a.mjs → config-Cj6LBZgc.mjs} +2 -3
  8. package/dist/{config-BeErFE6a.mjs.map → config-Cj6LBZgc.mjs.map} +1 -1
  9. package/dist/config.cjs +19 -19
  10. package/dist/config.d.mts +5 -5
  11. package/dist/config.mjs +3 -4
  12. package/dist/{configWriter-BzTOeJCT.cjs → configWriter-3AB5THeY.cjs} +33 -6
  13. package/dist/configWriter-3AB5THeY.cjs.map +1 -0
  14. package/dist/{configWriter-DwaYuqi8.mjs → configWriter-DM7G3kNd.mjs} +27 -6
  15. package/dist/configWriter-DM7G3kNd.mjs.map +1 -0
  16. package/dist/configWriter.cjs +2 -1
  17. package/dist/configWriter.d.mts +2 -2
  18. package/dist/configWriter.mjs +1 -1
  19. package/dist/{core-DMD33YiW.d.mts → core-BfpG7H9Y.d.mts} +2 -2
  20. package/dist/{core-DMD33YiW.d.mts.map → core-BfpG7H9Y.d.mts.map} +1 -1
  21. package/dist/{configPolicy-BFBzdISO.mjs → core-DgNJe0sH.mjs} +314 -5
  22. package/dist/core-DgNJe0sH.mjs.map +1 -0
  23. package/dist/{configPolicy-BL4UUBLR.cjs → core-DyoibqKS.cjs} +465 -4
  24. package/dist/core-DyoibqKS.cjs.map +1 -0
  25. package/dist/{domains-dSPktRdk.cjs → domains-BHaiC7-3.cjs} +4 -4
  26. package/dist/{domains-dSPktRdk.cjs.map → domains-BHaiC7-3.cjs.map} +1 -1
  27. package/dist/{domains-B2jnohjL.mjs → domains-Cr7HYWY8.mjs} +4 -4
  28. package/dist/{domains-B2jnohjL.mjs.map → domains-Cr7HYWY8.mjs.map} +1 -1
  29. package/dist/domains.cjs +3 -3
  30. package/dist/domains.d.mts +3 -3
  31. package/dist/domains.mjs +3 -3
  32. package/dist/extensions/server.cjs +2 -2
  33. package/dist/extensions/server.mjs +2 -2
  34. package/dist/harnessState.d.mts +1 -1
  35. package/dist/harnessStore.d.mts +1 -1
  36. package/dist/{index-CJ9sIwip.d.mts → index-B86o1Y6t.d.mts} +2 -2
  37. package/dist/{index-CJ9sIwip.d.mts.map → index-B86o1Y6t.d.mts.map} +1 -1
  38. package/dist/{index-wyQiF3PI.d.mts → index-BkvMN2vr.d.mts} +6 -4
  39. package/dist/index-BkvMN2vr.d.mts.map +1 -0
  40. package/dist/{index-BXUn46YE.d.mts → index-C7Gw9FE_.d.mts} +3 -3
  41. package/dist/{index-BXUn46YE.d.mts.map → index-C7Gw9FE_.d.mts.map} +1 -1
  42. package/dist/{index-BSqfRiCE.d.mts → index-C_TOY6Nv.d.mts} +2 -2
  43. package/dist/{index-BSqfRiCE.d.mts.map → index-C_TOY6Nv.d.mts.map} +1 -1
  44. package/dist/{index-Cehagk1u.d.mts → index-Cwo02oDp.d.mts} +3 -3
  45. package/dist/{index-Cehagk1u.d.mts.map → index-Cwo02oDp.d.mts.map} +1 -1
  46. package/dist/{index-ClDBEynT.d.mts → index-DCRZD74X.d.mts} +3 -3
  47. package/dist/{index-ClDBEynT.d.mts.map → index-DCRZD74X.d.mts.map} +1 -1
  48. package/dist/{index-_ANcZzRj.d.mts → index-HwdX1mGP.d.mts} +2 -2
  49. package/dist/{index-_ANcZzRj.d.mts.map → index-HwdX1mGP.d.mts.map} +1 -1
  50. package/dist/{index-OSfUuVIi.d.mts → index-K6JD2MmM.d.mts} +12 -3
  51. package/dist/index-K6JD2MmM.d.mts.map +1 -0
  52. package/dist/{index-N_GmmWJz.d.mts → index-mYHYXDnp.d.mts} +14 -2
  53. package/dist/index-mYHYXDnp.d.mts.map +1 -0
  54. package/dist/index.cjs +28 -27
  55. package/dist/index.d.mts +14 -14
  56. package/dist/index.mjs +11 -12
  57. package/dist/{init-sDZ0vh78.mjs → init-B-qX7BzZ.mjs} +3 -3
  58. package/dist/{init-sDZ0vh78.mjs.map → init-B-qX7BzZ.mjs.map} +1 -1
  59. package/dist/{init-DvEao9kS.cjs → init-MCYKs223.cjs} +3 -3
  60. package/dist/{init-DvEao9kS.cjs.map → init-MCYKs223.cjs.map} +1 -1
  61. package/dist/init.cjs +1 -1
  62. package/dist/init.mjs +1 -1
  63. package/dist/{layeredConfig-5gINd_qJ.cjs → layeredConfig-3PXHqdya.cjs} +2 -2
  64. package/dist/{layeredConfig-5gINd_qJ.cjs.map → layeredConfig-3PXHqdya.cjs.map} +1 -1
  65. package/dist/{layeredConfig-DpLY-Azh.mjs → layeredConfig-Jw8jUaYK.mjs} +2 -2
  66. package/dist/{layeredConfig-DpLY-Azh.mjs.map → layeredConfig-Jw8jUaYK.mjs.map} +1 -1
  67. package/dist/layeredConfig.cjs +1 -1
  68. package/dist/layeredConfig.d.mts +1 -1
  69. package/dist/layeredConfig.mjs +1 -1
  70. package/dist/piContext.cjs +1 -1
  71. package/dist/piContext.d.mts +2 -2
  72. package/dist/piContext.mjs +1 -1
  73. package/dist/po-runtime-identity.json +1 -1
  74. package/dist/{presetConfig-BmoZvYW-.mjs → presetConfig-BBVDa-69.mjs} +2 -2
  75. package/dist/{presetConfig-BmoZvYW-.mjs.map → presetConfig-BBVDa-69.mjs.map} +1 -1
  76. package/dist/{presetConfig-BcmdY04H.cjs → presetConfig-HUsSf3d_.cjs} +2 -2
  77. package/dist/{presetConfig-BcmdY04H.cjs.map → presetConfig-HUsSf3d_.cjs.map} +1 -1
  78. package/dist/{presets-6swHXI2u.cjs → presets-D_9noOVD.cjs} +5 -5
  79. package/dist/{presets-6swHXI2u.cjs.map → presets-D_9noOVD.cjs.map} +1 -1
  80. package/dist/{presets-lP01-CKK.mjs → presets-EKWZXNTW.mjs} +5 -5
  81. package/dist/{presets-lP01-CKK.mjs.map → presets-EKWZXNTW.mjs.map} +1 -1
  82. package/dist/presets.cjs +3 -3
  83. package/dist/presets.d.mts +2 -2
  84. package/dist/presets.mjs +3 -3
  85. package/dist/{profiles-CUHo67zR.cjs → profiles-D19ZUlko.cjs} +19 -10
  86. package/dist/profiles-D19ZUlko.cjs.map +1 -0
  87. package/dist/{profiles-CY2ga4PH.mjs → profiles-HT11R35t.mjs} +19 -10
  88. package/dist/profiles-HT11R35t.mjs.map +1 -0
  89. package/dist/profiles.cjs +6 -3
  90. package/dist/profiles.cjs.map +1 -1
  91. package/dist/profiles.d.mts +6 -4
  92. package/dist/profiles.d.mts.map +1 -1
  93. package/dist/profiles.mjs +6 -3
  94. package/dist/profiles.mjs.map +1 -1
  95. package/dist/selectionSwitch.cjs +2 -2
  96. package/dist/selectionSwitch.d.mts +3 -3
  97. package/dist/selectionSwitch.mjs +2 -2
  98. package/dist/{sessionConfig-CLuSKK3A.cjs → sessionConfig-BYQpwixM.cjs} +2 -2
  99. package/dist/{sessionConfig-CLuSKK3A.cjs.map → sessionConfig-BYQpwixM.cjs.map} +1 -1
  100. package/dist/{sessionConfig-BESVV7Qg.mjs → sessionConfig-COZiEDqb.mjs} +2 -2
  101. package/dist/{sessionConfig-BESVV7Qg.mjs.map → sessionConfig-COZiEDqb.mjs.map} +1 -1
  102. package/dist/{settingsApi-BE3Jj3W9.mjs → settingsApi-BOCBA7R4.mjs} +8 -9
  103. package/dist/{settingsApi-BE3Jj3W9.mjs.map → settingsApi-BOCBA7R4.mjs.map} +1 -1
  104. package/dist/{settingsApi-bS3MV2dz.cjs → settingsApi-DAJyFMUT.cjs} +10 -11
  105. package/dist/{settingsApi-bS3MV2dz.cjs.map → settingsApi-DAJyFMUT.cjs.map} +1 -1
  106. package/dist/{sync-DW2exveL.d.mts → sync-Cy4OEDKw.d.mts} +2 -2
  107. package/dist/{sync-DW2exveL.d.mts.map → sync-Cy4OEDKw.d.mts.map} +1 -1
  108. package/dist/sync.cjs +2 -2
  109. package/dist/sync.d.mts +3 -3
  110. package/dist/sync.mjs +2 -2
  111. package/dist/types.d.mts +2 -2
  112. package/package.json +4 -4
  113. package/dist/config-tk56d8mk.d.mts.map +0 -1
  114. package/dist/configPolicy-BFBzdISO.mjs.map +0 -1
  115. package/dist/configPolicy-BL4UUBLR.cjs.map +0 -1
  116. package/dist/configWriter-BzTOeJCT.cjs.map +0 -1
  117. package/dist/configWriter-DwaYuqi8.mjs.map +0 -1
  118. package/dist/core-B8x1gjyx.cjs +0 -369
  119. package/dist/core-B8x1gjyx.cjs.map +0 -1
  120. package/dist/core-BjM59sEK.mjs +0 -230
  121. package/dist/core-BjM59sEK.mjs.map +0 -1
  122. package/dist/index-N_GmmWJz.d.mts.map +0 -1
  123. package/dist/index-OSfUuVIi.d.mts.map +0 -1
  124. package/dist/index-wyQiF3PI.d.mts.map +0 -1
  125. package/dist/profiles-CUHo67zR.cjs.map +0 -1
  126. package/dist/profiles-CY2ga4PH.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { a as GitPluginSource, d as PluginEntry, m as PluginSource, n as DomainManifest, u as PluginCatalogEntry } from "./domains-DBNTBmuc.mjs";
2
- import "./index-BXUn46YE.mjs";
3
- import { t as readPoConfigSourcesAsync } from "./index-_ANcZzRj.mjs";
2
+ import "./index-C7Gw9FE_.mjs";
3
+ import { t as readPoConfigSourcesAsync } from "./index-HwdX1mGP.mjs";
4
4
  import { FileSystem } from "@agimon-ai/po-core/platform";
5
5
  //#region src/services/pluginCatalog/parse.d.ts
6
6
  declare const MARKETPLACE_MANIFEST_RELATIVE_PATHS: readonly ['.agents/plugins/marketplace.json', '.agents/plugins/api_marketplace.json', '.claude-plugin/marketplace.json', '.cursor-plugin/marketplace.json'];
@@ -99,4 +99,4 @@ declare function domainCompletionItems(domainNames: string[], query: string): Ar
99
99
  }>;
100
100
  //#endregion
101
101
  export { isRemotePluginSource as C, marketplaceSnapshotPath as D, marketplaceSnapshotEntries as E, pluginDirectoryForSource as O, MARKETPLACE_MANIFEST_RELATIVE_PATHS as S, marketplaceInstalledPath as T, defaultDomainsForPreset as _, loadDomainsAsync as a, findPluginManifestPathAsync as b, resolvePluginEntriesAsync as c, loadDomains as d, resolvePluginDirectories as f, PO_DOMAINS_ENV as g, DEFAULT_DOMAIN as h, listDomainNamesAsync as i, resolveSharedSkillsAsync as l, resolveSharedSkills as m, domainCompletionPrefix as n, resolveManifestPluginEntriesAsync as o, resolvePluginEntries as p, expandDomainNames as r, resolvePluginDirectoriesAsync as s, domainCompletionItems as t, listDomainNames as u, domainNamesOf as v, marketplaceInstalledEntries as w, findPluginManifestPath as x, sharedSkillsFor as y };
102
- //# sourceMappingURL=completion-BeLpnmA4.d.mts.map
102
+ //# sourceMappingURL=completion-BrN-LdQ6.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"completion-BeLpnmA4.d.mts","names":[],"sources":["../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts","../src/services/domains/completion.ts"],"mappings":";;;;;cAmBa;iBAkXG,yBAAyB,QAAQ,cAAc;;iBAiB/C,wBACd,uBACA,aAAa,SAAS,qCACtB;;iBAQc,2BAA2B,cAAc,iBAAiB,eAAe;iBAwCzE,qBACd,QAAQ,eACP,UAAU,kBAAkB,QAAQ;EAAgB;;;iBAKvC,yBACd,uBACA,aAAa,SAAS,qCACtB,gBACA;;iBAac,4BAA4B,cAAc,iBAAiB,eAAe;;;;;;;iBChb1E,uBAAuB;;;KCtBlC,UAAU,WAAW;;iBA8DJ,4BACpB,IAAI,YACJ,oBACA,SAAS,UACR;;;iBCoGa,cAAc,UAAU;;;;;;;iBAUxB,gBAAgB,UAAU,gBAAgB;cA8F7C;cACA;;;;;;;;iBAiBG,wBACd,gBACA,aAAa,OAAO,YACpB;;;;;;;;iBCvSc,YAAY,kBAAkB,yBAAmD;;iBAMjF,gBAAgB,kBAAkB;;iBAKlC,oBAAoB,kBAAkB,uBAAuB;;iBAK7D,qBACd,kBACA,uBACA,+BACA,yBACC;;iBAkBa,yBACd,kBACA,uBACA,+BACA;;;KCnDG,YAAY,WAAW;;;;;;;;iBAkCN,iBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;iBAqBW,qBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;;;;;;iBAUmB,yBACpB,IAAI,YACJ,kBACA,uBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;iBAKmB,0BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;;iBAMW,kCACpB,IAAI,YACJ,UAAU,gBACV,uBACA,+BACA,SAAS,WACT,wBACC,QAAQ;iBAgBW,8BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,yBACC;;;;iBC/Ia,kBAAkB,UAAU,gBAAgB;iBAW5C,uBAAuB;iBAKvB,sBAAsB,uBAAuB,gBAAgB;EAAQ;EAAe"}
1
+ {"version":3,"file":"completion-BrN-LdQ6.d.mts","names":[],"sources":["../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts","../src/services/domains/completion.ts"],"mappings":";;;;;cAmBa;iBAkXG,yBAAyB,QAAQ,cAAc;;iBAiB/C,wBACd,uBACA,aAAa,SAAS,qCACtB;;iBAQc,2BAA2B,cAAc,iBAAiB,eAAe;iBAwCzE,qBACd,QAAQ,eACP,UAAU,kBAAkB,QAAQ;EAAgB;;;iBAKvC,yBACd,uBACA,aAAa,SAAS,qCACtB,gBACA;;iBAac,4BAA4B,cAAc,iBAAiB,eAAe;;;;;;;iBChb1E,uBAAuB;;;KCtBlC,UAAU,WAAW;;iBA8DJ,4BACpB,IAAI,YACJ,oBACA,SAAS,UACR;;;iBCoGa,cAAc,UAAU;;;;;;;iBAUxB,gBAAgB,UAAU,gBAAgB;cA8F7C;cACA;;;;;;;;iBAiBG,wBACd,gBACA,aAAa,OAAO,YACpB;;;;;;;;iBCvSc,YAAY,kBAAkB,yBAAmD;;iBAMjF,gBAAgB,kBAAkB;;iBAKlC,oBAAoB,kBAAkB,uBAAuB;;iBAK7D,qBACd,kBACA,uBACA,+BACA,yBACC;;iBAkBa,yBACd,kBACA,uBACA,+BACA;;;KCnDG,YAAY,WAAW;;;;;;;;iBAkCN,iBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;iBAqBW,qBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;;;;;;iBAUmB,yBACpB,IAAI,YACJ,kBACA,uBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;iBAKmB,0BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;;iBAMW,kCACpB,IAAI,YACJ,UAAU,gBACV,uBACA,+BACA,SAAS,WACT,wBACC,QAAQ;iBAgBW,8BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,yBACC;;;;iBC/Ia,kBAAkB,UAAU,gBAAgB;iBAW5C,uBAAuB;iBAKvB,sBAAsB,uBAAuB,gBAAgB;EAAQ;EAAe"}
@@ -1,6 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
- const require_configPolicy = require("./configPolicy-BL4UUBLR.cjs");
3
- const require_core = require("./core-B8x1gjyx.cjs");
2
+ const require_core = require("./core-DyoibqKS.cjs");
4
3
  let node_path = require("node:path");
5
4
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
6
5
  let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
@@ -108,7 +107,7 @@ async function readWorkspaceDeclarations({ fs, repositoryRoot, context }) {
108
107
  "instructions",
109
108
  "metadata"
110
109
  ].includes(key))) throw new Error(`Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`);
111
- const base = require_configPolicy.parsePoConfig(JSON.stringify({ workspaces: [{
110
+ const base = require_core.parsePoConfig(JSON.stringify({ workspaces: [{
112
111
  name: entry.name,
113
112
  instructions: entry.instructions
114
113
  }] }), filePath).workspaces[0];
@@ -128,7 +127,7 @@ async function readWorkspaceDeclarations({ fs, repositoryRoot, context }) {
128
127
  ...entry.metadata === void 0 ? {} : { metadata: entry.metadata }
129
128
  };
130
129
  });
131
- require_configPolicy.parsePoConfig(JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({
130
+ require_core.parsePoConfig(JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({
132
131
  name,
133
132
  instructions
134
133
  })) }), filePath);
@@ -289,4 +288,4 @@ Object.defineProperty(exports, "refreshGlobalSettingsCache", {
289
288
  }
290
289
  });
291
290
 
292
- //# sourceMappingURL=config-DB7YUo6N.cjs.map
291
+ //# sourceMappingURL=config-BDoem3_a.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-DB7YUo6N.cjs","names":["fs","readText","nodeHost","globalPoConfigPath","repositoryConfigFor","mergeConfigLayers","configFromText","withGlobalLayer","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","defaultPoConfig","mergeLenientLayers","lenientConfigFromText","composeConfigLayers","layerFromText","absentRepositoryLayer","path","readTextIfExists","configFromText","parseYaml","parsePoConfig","nodeHost","globalPoConfigPath","marketplaceOrigin","repositoryConfigFor","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","withGlobalLayer","defaultPoConfig","mergeConfigLayers","GLOBAL_SETTINGS_READ_OPERATION","globalSettingsRecords","isGlobalSettingsBinding","sameGlobalSettingsBinding","writeFileAtomic","lenientConfigFromText","mergeLenientLayers","layerFromText","absentRepositoryLayer","composeConfigLayers"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAOA,QAAAA,QAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;AAEA,eAAeC,WAAS,UAA+C;CACrE,IAAI;EACF,OAAO,MAAMD,QAAAA,QAAG,SAAS,SAAS,UAAU,MAAM;CACpD,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;;AAGA,SAAgB,aACd,UACA,gBAAgBE,4BAAAA,SAAS,cAAc,GACvC,cAAiC,QAAQ,K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CACzG,OAAOsB,aAAAA,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
1
+ {"version":3,"file":"config-BDoem3_a.cjs","names":["fs","readText","nodeHost","globalPoConfigPath","repositoryConfigFor","mergeConfigLayers","configFromText","withGlobalLayer","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","defaultPoConfig","mergeLenientLayers","lenientConfigFromText","composeConfigLayers","layerFromText","absentRepositoryLayer","path","readTextIfExists","configFromText","parseYaml","parsePoConfig","nodeHost","globalPoConfigPath","marketplaceOrigin","repositoryConfigFor","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","withGlobalLayer","defaultPoConfig","mergeConfigLayers","GLOBAL_SETTINGS_READ_OPERATION","globalSettingsRecords","isGlobalSettingsBinding","sameGlobalSettingsBinding","writeFileAtomic","lenientConfigFromText","mergeLenientLayers","layerFromText","absentRepositoryLayer","composeConfigLayers"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAOA,QAAAA,Q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MAAM,iBAAiB,MAAM,SAAS,IAAI,gBAAgB,OAAO;CACjE,MAAM,cAAcc,aAAAA,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAYC,aAAAA,sBAAsB,IAAID,aAAAA,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAYT,aAAAA,gBAAgB,IAAIX,aAAAA,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAYY,aAAAA,kBAAkBZ,aAAAA,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAOsB,aAAAA,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
@@ -42,10 +42,18 @@ interface PlanningAgentConfig {
42
42
  model?: string;
43
43
  thinking?: PlanningThinkingLevel;
44
44
  }
45
+ /** A plan mode the person defined: its brief is added to the Plan prompt while it is selected. */
46
+ interface PlanningModeDefinition {
47
+ label: string;
48
+ description?: string;
49
+ brief: string;
50
+ }
45
51
  interface PlanningModeConfig {
46
52
  main?: PlanningAgentConfig;
47
53
  subagents?: PlanningAgentConfig;
48
54
  plansDirectory?: string;
55
+ /** Custom plan modes by id. A workspace entry replaces the host entry with the same id. */
56
+ modes?: Record<string, PlanningModeDefinition>;
49
57
  }
50
58
  /**
51
59
  * Ratios of the context window at which each autocompact pass fires.
@@ -105,6 +113,24 @@ interface CanvasConfig {
105
113
  /** Where New canvas saves boards: a workspace-relative folder or `artifact:<folder>`. Unset saves to `artifact:canvas`. */
106
114
  directory?: string;
107
115
  }
116
+ interface WorkflowsConfig {
117
+ recovery?: {
118
+ /**
119
+ * True makes a recovery refuse an edited workflow that adds jobs before its restart point. Unset or false lets
120
+ * it adopt such an edit, for workflows still being written. The restart job must still exist either way.
121
+ */
122
+ checkEdits?: boolean;
123
+ };
124
+ }
125
+ interface NotificationsConfig {
126
+ /**
127
+ * True runs one model check when a session settles with no background work, telling a finished
128
+ * session from one waiting on a question. Unset or false keeps the plain finished notice.
129
+ */
130
+ idleCheck?: boolean;
131
+ /** `provider/model-id` that runs the idle check. Unset, or unavailable, uses the session model. */
132
+ idleCheckModel?: string;
133
+ }
108
134
  interface SubagentsConfig {
109
135
  model?: string;
110
136
  thinking?: PlanningThinkingLevel;
@@ -304,6 +330,10 @@ interface PoConfig {
304
330
  artifacts?: ArtifactsConfig;
305
331
  /** Repository value wins over personal. */
306
332
  canvas?: CanvasConfig;
333
+ /** Host and repository; the repository value wins. */
334
+ workflows?: WorkflowsConfig;
335
+ /** Host and repository; the repository value wins. */
336
+ notifications?: NotificationsConfig;
307
337
  projectTrust: ProjectTrust;
308
338
  editor?: EditorConfig;
309
339
  browse?: BrowseConfig;
@@ -450,5 +480,5 @@ interface LenientParseResult {
450
480
  diagnostics: ConfigDiagnostic[];
451
481
  }
452
482
  //#endregion
453
- export { PoSelectionConfig as A, VoiceTtsConfig as B, PoConfigLayers as C, PoConfigTransitionRecord as D, PoConfigTransitionPhase as E, VoiceAutoCaptureConfig as F, PersonaIdentity as G, WorkspaceDeclaration as H, VoiceConfig as I, PersonaVoiceOverride as K, VoiceEngine as L, ResolvedVoiceAutoCaptureConfig as M, ResolvedVoiceConfig as N, PoConfigTransitionStrategy as O, VoiceAdapterConfig as P, VoiceMode as R, PoConfigLayer as S, PoConfigSelection as T, PersonaDocument as U, VoiceTtsEngine as V, PersonaFrontMatter as W, PlanningAgentConfig as _, ConfigDiagnostic as a, PoConfig as b, DesktopEnvironmentConfig as c, IPoConfigLoader as d, IPoConfigService$1 as f, PackageAttribution$1 as g, PO_CONFIG_SERVICE as h, AutocompactTokenConfig as i, ProjectTrust as j, PoHarnessContext as k, EditorConfig as l, LenientParseResult as m, AutocompactOverrideConfig as n, ConfigValueOrigin as o, LenientParseOptions as p, AutocompactThresholdConfig as r, DeepReadonly as s, AutocompactModeConfig as t, HarnessState as u, PlanningModeConfig as v, PoConfigPendingSelection as w, PoConfigContext as x, PlanningThinkingLevel as y, VoiceModelConfig as z };
454
- //# sourceMappingURL=config-tk56d8mk.d.mts.map
483
+ export { PoHarnessContext as A, VoiceModelConfig as B, PoConfigLayer as C, PoConfigTransitionPhase as D, PoConfigSelection as E, VoiceAdapterConfig as F, PersonaFrontMatter as G, VoiceTtsEngine as H, VoiceAutoCaptureConfig as I, PersonaIdentity as K, VoiceConfig as L, ProjectTrust as M, ResolvedVoiceAutoCaptureConfig as N, PoConfigTransitionRecord as O, ResolvedVoiceConfig as P, VoiceEngine as R, PoConfigContext as S, PoConfigPendingSelection as T, WorkspaceDeclaration as U, VoiceTtsConfig as V, PersonaDocument as W, PlanningAgentConfig as _, ConfigDiagnostic as a, PlanningThinkingLevel as b, DesktopEnvironmentConfig as c, IPoConfigLoader as d, IPoConfigService$1 as f, PackageAttribution$1 as g, PO_CONFIG_SERVICE as h, AutocompactTokenConfig as i, PoSelectionConfig as j, PoConfigTransitionStrategy as k, EditorConfig as l, LenientParseResult as m, AutocompactOverrideConfig as n, ConfigValueOrigin as o, LenientParseOptions as p, PersonaVoiceOverride as q, AutocompactThresholdConfig as r, DeepReadonly as s, AutocompactModeConfig as t, HarnessState as u, PlanningModeConfig as v, PoConfigLayers as w, PoConfig as x, PlanningModeDefinition as y, VoiceMode as z };
484
+ //# sourceMappingURL=config-CG_KJdcd.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-CG_KJdcd.d.mts","names":["IPoConfigService","PoConfigServiceContract"],"sources":["../src/types/profiles.ts","../src/types/config.ts"],"mappings":";;;;UAAiB;EACf;EACA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,QAAQ;;UAGO;EACf,cAAc;;EAEd;;;;KCvBU;KACA;KACA;KACA;KACA;UAEK;EACf;EACA,WAAW;;;UAGI;EACf;EACA;EACA;;UAEe;EACf,OAAO;EACP,YAAY;EACZ;;EAEA,QAAQ,eAAe;;;;;;;;;UASR;EACf;EACA;EACA;;;;;;;;;UASe;EACf;EACA;EACA;;;;;;;;;UASe;EACf;E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ACd,SAAS;EACT,SAAS;EACT,MAAM;EACN,QAAQ;EACR,YAAY;;;;;EAKZ;IAAQ;IAAmB;IAAmB;IAAe;;;EAE7D;IAAW;;;EAEX;IAAW;;;UAMI;EACf;;EAEA;EACA;EACA;;EAEA;;;;;;;;;;;EAWA,qBAAqB,eAAe;;EAEpC;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA;EACA;;EAEA,gBAAgB;EAChB;EACA;;;;;;EAMA,kBAAkB;;EAElB,eAAe;EACf;EACA;EACA;;KAGU,aAAa,UAAU,oBAAmB,6BAClD,SACA,+BAA+B,oBACpB,aAAa,WACtB,oCACc,cAAc,SAAS,aAAa,OAAO,YACvD;KAEI,mBAAmB,aAAa;UAE3B;WACN,UAAU,aAAa;WACvB,SAAS;;WAET,mBAAmB,aAAa;;WAEhC;;;UAIM;EACf,KAAK,kBAAkB,yBAAyB;;;UAIjCA,2BAAyBC,iBAAwB,iBAAiB;;YAGvE;IACR,aAAaD;;;;KAQL;;UAGK;EACf;EACA;;;;;;EAMA;;EAEA;;;;;;;;;;UAWe;;EAEf,YAAY;EACZ,gBAAgB;EAChB,WAAW;;EAEX,SAAS,6BAA6B;;EAEtC,QAAQ;;;;;;;;;UAUO;EACf;;EAEA;EACA;;;UAIe;EACf;;;UAIe;EACf,QAAQ;EACR,aAAa"}
@@ -1,5 +1,4 @@
1
- import { g as parsePoConfig } from "./configPolicy-BFBzdISO.mjs";
2
- import { C as withGlobalLayer, S as sameGlobalSettingsBinding, _ as mergeConfigLayers, a as defaultPoConfig, c as globalSettingsCachePath, f as globalSettingsRecords, g as lenientConfigFromText, h as layerFromText, i as configFromText, l as globalSettingsMember, m as isGlobalSettingsBinding, n as absentRepositoryLayer, r as composeConfigLayers, s as globalPoConfigPath, u as globalSettingsOwnerPath, v as mergeLenientLayers, y as repositoryConfigFor } from "./core-BjM59sEK.mjs";
1
+ import { C as withGlobalLayer, S as sameGlobalSettingsBinding, V as parsePoConfig, _ as mergeConfigLayers, a as defaultPoConfig, c as globalSettingsCachePath, f as globalSettingsRecords, g as lenientConfigFromText, h as layerFromText, i as configFromText, l as globalSettingsMember, m as isGlobalSettingsBinding, n as absentRepositoryLayer, r as composeConfigLayers, s as globalPoConfigPath, u as globalSettingsOwnerPath, v as mergeLenientLayers, y as repositoryConfigFor } from "./core-DgNJe0sH.mjs";
3
2
  import path from "node:path";
4
3
  import { nodeHost, readTextIfExists, writeFileAtomic } from "@agimon-ai/po-core/platform";
5
4
  import fs from "node:fs";
@@ -227,4 +226,4 @@ async function readPoConfigLayers(fs, repoRoot, context, options = {}) {
227
226
  //#endregion
228
227
  export { readWorkspaceDeclarations as a, loadPoConfigAsync as c, readPoConfigLenient as i, loadPoConfigLayers as l, readPoConfig as n, refreshGlobalSettingsCache as o, readPoConfigLayers as r, loadPoConfig as s, readHostMarketplaceOrigin as t, loadPoConfigLenient as u };
229
228
 
230
- //# sourceMappingURL=config-BeErFE6a.mjs.map
229
+ //# sourceMappingURL=config-Cj6LBZgc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-BeErFE6a.mjs","names":["readText","parseYaml"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync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M,aAAa,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,oBAAoB,UAAU,eAAe,WAAW;CAC/E,MAAM,eAAe,sBAAsB,MAAM,SAAS,IAAI,YAAY,OAAO,GAAG,UAAU;CAC9F,MAAM,mBACJ,mBAAmB,KAAA,IACf,sBAAsB,KAAA,GAAW,EAAE,IACnC,sBAAsB,MAAM,SAAS,IAAI,gBAAgB,OAAO,GAAG,cAAc;CACvF,OAAO,mBAAmB,cAAc,kBAAkB,WAAW;AACvE;;;;;;;AAQA,eAAsB,mBACpB,IACA,UACA,SACA,UAA+B,CAAC,GACP;CACzB,MAAM,EAAE,eAAe,gBAAgB,SAAS,OAAO;CACvD,MAAM,aAAa,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,aAAa,KAAA,IAAY,KAAA,IAAY,oBAAoB,UAAU,eAAe,WAAW;CACpH,MAAM,aAAa,MAAM,SAAS,IAAI,YAAY,OAAO;CACzD,MAAM,iBAAiB,MAAM,SAAS,IAAI,gBAAgB,OAAO;CACjE,MAAM,cAAc,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAY,sBAAsB,IAAI,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAY,gBAAgB,IAAI,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAY,kBAAkB,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAO,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
1
+ {"version":3,"file":"config-Cj6LBZgc.mjs","names":["readText","parseYaml"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAO,GAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;AAEA,eAAeA,WAAS,UAA+C;CACrE,IAAI;EACF,OAAO,MAAM,GAAG,SAAS,SAAS,UAAU,MAAM;CACpD,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;;AAGA,SAAgB,aACd,UACA,gBAAgB,SAAS,cAAc,GACvC,cAAiC,QAAQ,KAC/B;CACV,MAAM,aAAa,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,oBAAoB,UAAU,eAAe,WAAW;CAC/E,OAAO,kBACL,eACE,gBACE,aAAa,wBAAwB,eAAe,WAAW,CAAC,GAChE,aAAa,UAAU,GACvB,qBAAqB,aAAa,aAAa,wBAAwB,eAAe,WAAW,CAAC,CAAC,CACrG,GACA,UACF,GACA,mBAAmB,KAAA,IAAY,gBAAgB,IAAI,eAAe,aAAa,cAAc,GAAG,cAAc,GAC9G,WACF;AACF;;;;;;;;;;;AAYA,SAAgB,oBACd,UACA,gBAAgB,SAAS,cAAc,GACvC,cAAiC,QAAQ,KACrB;CACpB,MAAM,aAAa,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,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AACpE"}
package/dist/config.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_configPolicy = require("./configPolicy-BL4UUBLR.cjs");
3
- const require_core = require("./core-B8x1gjyx.cjs");
4
- const require_config = require("./config-DB7YUo6N.cjs");
2
+ const require_core = require("./core-DyoibqKS.cjs");
3
+ const require_config = require("./config-BDoem3_a.cjs");
5
4
  let _agimon_ai_po_core = require("@agimon-ai/po-core");
6
- exports.PO_PLANNING_THINKING_LEVELS = require_configPolicy.PO_PLANNING_THINKING_LEVELS;
7
- exports.PO_VOICE_ENGINES = require_configPolicy.PO_VOICE_ENGINES;
8
- exports.PO_VOICE_LIVE_VOICES = require_configPolicy.PO_VOICE_LIVE_VOICES;
9
- exports.PO_VOICE_MODES = require_configPolicy.PO_VOICE_MODES;
10
- exports.PO_VOICE_TTS_ENGINES = require_configPolicy.PO_VOICE_TTS_ENGINES;
5
+ exports.PO_PLANNING_MODE_LIMITS = require_core.PO_PLANNING_MODE_LIMITS;
6
+ exports.PO_PLANNING_THINKING_LEVELS = require_core.PO_PLANNING_THINKING_LEVELS;
7
+ exports.PO_VOICE_ENGINES = require_core.PO_VOICE_ENGINES;
8
+ exports.PO_VOICE_LIVE_VOICES = require_core.PO_VOICE_LIVE_VOICES;
9
+ exports.PO_VOICE_MODES = require_core.PO_VOICE_MODES;
10
+ exports.PO_VOICE_TTS_ENGINES = require_core.PO_VOICE_TTS_ENGINES;
11
11
  exports.SESSION_MEMBER_ENVIRONMENT = require_core.SESSION_MEMBER_ENVIRONMENT;
12
- exports.configLeafKeys = require_configPolicy.configLeafKeys;
13
- exports.configRootKeys = require_configPolicy.configRootKeys;
14
- exports.configScopeOf = require_configPolicy.configScopeOf;
12
+ exports.configLeafKeys = require_core.configLeafKeys;
13
+ exports.configRootKeys = require_core.configRootKeys;
14
+ exports.configScopeOf = require_core.configScopeOf;
15
15
  exports.globalPoConfigDirectory = require_core.globalPoConfigDirectory;
16
16
  exports.globalPoConfigPath = require_core.globalPoConfigPath;
17
17
  exports.globalSettingsCachePath = require_core.globalSettingsCachePath;
@@ -22,18 +22,18 @@ Object.defineProperty(exports, "isPortableConfigKey", {
22
22
  return _agimon_ai_po_core.isPortableConfigKey;
23
23
  }
24
24
  });
25
- exports.mergeGlobalConfigLayer = require_configPolicy.mergeGlobalConfigLayer;
26
- exports.mergePoConfigs = require_configPolicy.mergePoConfigs;
25
+ exports.mergeGlobalConfigLayer = require_core.mergeGlobalConfigLayer;
26
+ exports.mergePoConfigs = require_core.mergePoConfigs;
27
27
  Object.defineProperty(exports, "nonPortableConfigKeys", {
28
28
  enumerable: true,
29
29
  get: function() {
30
30
  return _agimon_ai_po_core.nonPortableConfigKeys;
31
31
  }
32
32
  });
33
- exports.nonPortableConfigText = require_configPolicy.nonPortableConfigText;
34
- exports.parseAutocompactModeConfig = require_configPolicy.parseAutocompactModeConfig;
35
- exports.parsePlanningModeConfig = require_configPolicy.parsePlanningModeConfig;
36
- exports.parsePoConfig = require_configPolicy.parsePoConfig;
33
+ exports.nonPortableConfigText = require_core.nonPortableConfigText;
34
+ exports.parseAutocompactModeConfig = require_core.parseAutocompactModeConfig;
35
+ exports.parsePlanningModeConfig = require_core.parsePlanningModeConfig;
36
+ exports.parsePoConfig = require_core.parsePoConfig;
37
37
  exports.readHostMarketplaceOrigin = require_config.readHostMarketplaceOrigin;
38
38
  exports.readPoConfig = require_config.readPoConfig;
39
39
  exports.readPoConfigLayers = require_config.readPoConfigLayers;
@@ -42,5 +42,5 @@ exports.readWorkspaceDeclarations = require_config.readWorkspaceDeclarations;
42
42
  exports.refreshGlobalSettingsCache = require_config.refreshGlobalSettingsCache;
43
43
  exports.repositoryPoConfigPath = require_core.repositoryPoConfigPath;
44
44
  exports.resolvePlanningPlansDirectory = require_core.resolvePlanningPlansDirectory;
45
- exports.resolveVoiceConfig = require_configPolicy.resolveVoiceConfig;
46
- exports.valueAtKeyPath = require_configPolicy.valueAtKeyPath;
45
+ exports.resolveVoiceConfig = require_core.resolveVoiceConfig;
46
+ exports.valueAtKeyPath = require_core.valueAtKeyPath;
package/dist/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as PoConfigLayers, S as PoConfigLayer, a as ConfigDiagnostic, m as LenientParseResult, o as ConfigValueOrigin, p as LenientParseOptions } from "./config-tk56d8mk.mjs";
2
- import { a as globalPoConfigPath, c as repositoryPoConfigPath, i as globalPoConfigDirectory, l as resolvePlanningPlansDirectory, n as GlobalSettingsPerson, o as globalSettingsCachePath, r as SESSION_MEMBER_ENVIRONMENT, s as globalSettingsPeople } from "./core-DMD33YiW.mjs";
3
- import { a as readPoConfig, c as readWorkspaceDeclarations, i as readHostMarketplaceOrigin, l as refreshGlobalSettingsCache, n as ReadWorkspaceDeclarationsOptions, o as readPoConfigLayers, r as WorkspaceDeclarationsResult, s as readPoConfigLenient, t as ReadPoConfigOptions } from "./index-BXUn46YE.mjs";
4
- import { _ as parsePoConfig, a as PO_VOICE_MODES, c as configRootKeys, d as mergeGlobalConfigLayer, f as mergePoConfigs, g as parsePlanningModeConfig, h as parseAutocompactModeConfig, i as PO_VOICE_LIVE_VOICES, l as configScopeOf, m as nonPortableConfigText, n as PO_PLANNING_THINKING_LEVELS, o as PO_VOICE_TTS_ENGINES, p as nonPortableConfigKeys, r as PO_VOICE_ENGINES, s as configLeafKeys, t as ConfigKeyScope, u as isPortableConfigKey, v as resolveVoiceConfig, y as valueAtKeyPath } from "./index-OSfUuVIi.mjs";
5
- export { type ConfigDiagnostic, type ConfigKeyScope, type ConfigValueOrigin, type GlobalSettingsPerson, type LenientParseOptions, type LenientParseResult, PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, type PoConfigLayer, type PoConfigLayers, type ReadPoConfigOptions, type ReadWorkspaceDeclarationsOptions, SESSION_MEMBER_ENVIRONMENT, type WorkspaceDeclarationsResult, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
1
+ import { C as PoConfigLayer, a as ConfigDiagnostic, m as LenientParseResult, o as ConfigValueOrigin, p as LenientParseOptions, w as PoConfigLayers } from "./config-CG_KJdcd.mjs";
2
+ import { a as globalPoConfigPath, c as repositoryPoConfigPath, i as globalPoConfigDirectory, l as resolvePlanningPlansDirectory, n as GlobalSettingsPerson, o as globalSettingsCachePath, r as SESSION_MEMBER_ENVIRONMENT, s as globalSettingsPeople } from "./core-BfpG7H9Y.mjs";
3
+ import { a as readPoConfig, c as readWorkspaceDeclarations, i as readHostMarketplaceOrigin, l as refreshGlobalSettingsCache, n as ReadWorkspaceDeclarationsOptions, o as readPoConfigLayers, r as WorkspaceDeclarationsResult, s as readPoConfigLenient, t as ReadPoConfigOptions } from "./index-C7Gw9FE_.mjs";
4
+ import { _ as parsePlanningModeConfig, a as PO_VOICE_LIVE_VOICES, b as valueAtKeyPath, c as configLeafKeys, d as isPortableConfigKey, f as mergeGlobalConfigLayer, g as parseAutocompactModeConfig, h as nonPortableConfigText, i as PO_VOICE_ENGINES, l as configRootKeys, m as nonPortableConfigKeys, n as PO_PLANNING_MODE_LIMITS, o as PO_VOICE_MODES, p as mergePoConfigs, r as PO_PLANNING_THINKING_LEVELS, s as PO_VOICE_TTS_ENGINES, t as ConfigKeyScope, u as configScopeOf, v as parsePoConfig, y as resolveVoiceConfig } from "./index-K6JD2MmM.mjs";
5
+ export { type ConfigDiagnostic, type ConfigKeyScope, type ConfigValueOrigin, type GlobalSettingsPerson, type LenientParseOptions, type LenientParseResult, PO_PLANNING_MODE_LIMITS, PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, type PoConfigLayer, type PoConfigLayers, type ReadPoConfigOptions, type ReadWorkspaceDeclarationsOptions, SESSION_MEMBER_ENVIRONMENT, type WorkspaceDeclarationsResult, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
package/dist/config.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { _ as resolveVoiceConfig, a as PO_VOICE_TTS_ENGINES, c as configScopeOf, d as mergePoConfigs, f as nonPortableConfigKeys, g as parsePoConfig, h as parsePlanningModeConfig, i as PO_VOICE_MODES, l as isPortableConfigKey, m as parseAutocompactModeConfig, n as PO_VOICE_ENGINES, o as configLeafKeys, p as nonPortableConfigText, r as PO_VOICE_LIVE_VOICES, s as configRootKeys, t as PO_PLANNING_THINKING_LEVELS, u as mergeGlobalConfigLayer, v as valueAtKeyPath } from "./configPolicy-BFBzdISO.mjs";
2
- import { b as repositoryPoConfigPath, c as globalSettingsCachePath, d as globalSettingsPeople, o as globalPoConfigDirectory, s as globalPoConfigPath, t as SESSION_MEMBER_ENVIRONMENT, x as resolvePlanningPlansDirectory } from "./core-BjM59sEK.mjs";
3
- import { a as readWorkspaceDeclarations, i as readPoConfigLenient, n as readPoConfig, o as refreshGlobalSettingsCache, r as readPoConfigLayers, t as readHostMarketplaceOrigin } from "./config-BeErFE6a.mjs";
4
- export { PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, SESSION_MEMBER_ENVIRONMENT, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
1
+ import { A as PO_VOICE_TTS_ENGINES, B as parsePlanningModeConfig, D as PO_VOICE_ENGINES, E as PO_PLANNING_THINKING_LEVELS, F as mergeGlobalConfigLayer, H as resolveVoiceConfig, I as mergePoConfigs, L as nonPortableConfigKeys, M as configRootKeys, N as configScopeOf, O as PO_VOICE_LIVE_VOICES, P as isPortableConfigKey, R as nonPortableConfigText, T as PO_PLANNING_MODE_LIMITS, U as valueAtKeyPath, V as parsePoConfig, b as repositoryPoConfigPath, c as globalSettingsCachePath, d as globalSettingsPeople, j as configLeafKeys, k as PO_VOICE_MODES, o as globalPoConfigDirectory, s as globalPoConfigPath, t as SESSION_MEMBER_ENVIRONMENT, x as resolvePlanningPlansDirectory, z as parseAutocompactModeConfig } from "./core-DgNJe0sH.mjs";
2
+ import { a as readWorkspaceDeclarations, i as readPoConfigLenient, n as readPoConfig, o as refreshGlobalSettingsCache, r as readPoConfigLayers, t as readHostMarketplaceOrigin } from "./config-Cj6LBZgc.mjs";
3
+ export { PO_PLANNING_MODE_LIMITS, PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, SESSION_MEMBER_ENVIRONMENT, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
2
  const require_atomicJson = require("./atomicJson-D3MHqnLW.cjs");
3
- const require_configPolicy = require("./configPolicy-BL4UUBLR.cjs");
3
+ const require_core = require("./core-DyoibqKS.cjs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
6
6
  let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
@@ -60,6 +60,17 @@ function modesForScope(scope) {
60
60
  directory: PRIVATE_DIRECTORY_MODE
61
61
  };
62
62
  }
63
+ /** The file changed since the caller read it. `hash` is what it holds now. */
64
+ var PoConfigConflictError = class extends Error {
65
+ filePath;
66
+ hash;
67
+ constructor(filePath, hash) {
68
+ super(`Po config at ${filePath} changed since it was read.`);
69
+ this.filePath = filePath;
70
+ this.hash = hash;
71
+ this.name = "PoConfigConflictError";
72
+ }
73
+ };
63
74
  function isEmptyCollection(value) {
64
75
  if (value === null || typeof value !== "object") return false;
65
76
  const items = value.items;
@@ -100,7 +111,7 @@ function applyPoConfigEdits(content, filePath, edits, options = {}) {
100
111
  if (options.prune !== false) pruneEmptyAncestors(document, keyPath);
101
112
  }
102
113
  const output = document.toString();
103
- require_configPolicy.parsePoConfig(output, filePath);
114
+ require_core.parsePoConfig(output, filePath);
104
115
  return output;
105
116
  }
106
117
  //#endregion
@@ -109,7 +120,7 @@ async function readIfPresent(filePath) {
109
120
  try {
110
121
  return await node_fs_promises.default.readFile(filePath, "utf8");
111
122
  } catch (error) {
112
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return "";
123
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
113
124
  throw error;
114
125
  }
115
126
  }
@@ -121,7 +132,12 @@ async function readIfPresent(filePath) {
121
132
  async function writePoConfigValues(filePath, edits, options = {}) {
122
133
  if (edits.length === 0) return;
123
134
  await configWrites.forKey(node_path.default.resolve(filePath))(async () => {
124
- const output = applyPoConfigEdits(await readIfPresent(filePath), filePath, edits, options);
135
+ const text = await readIfPresent(filePath);
136
+ if (options.expectedHash !== void 0) {
137
+ const hash = require_core.layerFromText(filePath, text).hash;
138
+ if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);
139
+ }
140
+ const output = applyPoConfigEdits(text ?? "", filePath, edits, options);
125
141
  const modes = modesForScope(options.scope ?? "host");
126
142
  await node_fs_promises.default.mkdir(node_path.default.dirname(filePath), {
127
143
  mode: modes.directory,
@@ -161,7 +177,12 @@ async function unsetPoConfigValue(filePath, keyPath, options = {}) {
161
177
  async function writePoConfigValuesAsync(fs, filePath, edits, context, options = {}) {
162
178
  if (edits.length === 0) return;
163
179
  await configWrites.forKey(node_path.default.resolve(filePath))(async () => {
164
- const output = applyPoConfigEdits(await (0, _agimon_ai_po_core_platform.readTextIfExists)(fs, filePath, context) ?? "", filePath, edits, options);
180
+ const text = await (0, _agimon_ai_po_core_platform.readTextIfExists)(fs, filePath, context);
181
+ if (options.expectedHash !== void 0) {
182
+ const hash = require_core.layerFromText(filePath, text).hash;
183
+ if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);
184
+ }
185
+ const output = applyPoConfigEdits(text ?? "", filePath, edits, options);
165
186
  const modes = modesForScope(options.scope ?? "host");
166
187
  await require_atomicJson.createDirectoryWithMode(fs, node_path.default.dirname(filePath), modes.directory, context);
167
188
  await (0, _agimon_ai_po_core_platform.writeFileAtomic)(fs, filePath, output, context);
@@ -178,6 +199,12 @@ async function unsetPoConfigValueAsync(fs, filePath, keyPath, context, options =
178
199
  await writePoConfigValuesAsync(fs, filePath, [{ keyPath }], context, options);
179
200
  }
180
201
  //#endregion
202
+ Object.defineProperty(exports, "PoConfigConflictError", {
203
+ enumerable: true,
204
+ get: function() {
205
+ return PoConfigConflictError;
206
+ }
207
+ });
181
208
  Object.defineProperty(exports, "setPoConfigValue", {
182
209
  enumerable: true,
183
210
  get: function() {
@@ -215,4 +242,4 @@ Object.defineProperty(exports, "writePoConfigValuesAsync", {
215
242
  }
216
243
  });
217
244
 
218
- //# sourceMappingURL=configWriter-BzTOeJCT.cjs.map
245
+ //# sourceMappingURL=configWriter-3AB5THeY.cjs.map