@agimon-ai/po-config 0.0.0-alpha.145 → 0.0.0-alpha.147

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 (69) hide show
  1. package/dist/apiContracts.cjs +5 -10
  2. package/dist/apiContracts.cjs.map +1 -1
  3. package/dist/apiContracts.d.mts.map +1 -1
  4. package/dist/apiContracts.mjs +5 -10
  5. package/dist/apiContracts.mjs.map +1 -1
  6. package/dist/{config-Bd8XQgUt.mjs → config-Djaao8IK.mjs} +13 -8
  7. package/dist/config-Djaao8IK.mjs.map +1 -0
  8. package/dist/{config-CpQA0FCa.cjs → config-Xoep-Ipa.cjs} +13 -8
  9. package/dist/config-Xoep-Ipa.cjs.map +1 -0
  10. package/dist/config.cjs +2 -2
  11. package/dist/config.mjs +2 -2
  12. package/dist/{core-CcPiMlUw.mjs → core-B1oari2a.mjs} +28 -10
  13. package/dist/core-B1oari2a.mjs.map +1 -0
  14. package/dist/{core-DuzB4uF3.cjs → core-CyAtb-Gt.cjs} +39 -9
  15. package/dist/core-CyAtb-Gt.cjs.map +1 -0
  16. package/dist/{domains-BG2VXTb3.cjs → domains-9ffI7IYd.cjs} +4 -4
  17. package/dist/{domains-BG2VXTb3.cjs.map → domains-9ffI7IYd.cjs.map} +1 -1
  18. package/dist/{domains-DsHpOcX8.mjs → domains-BmdX_BMx.mjs} +4 -4
  19. package/dist/{domains-DsHpOcX8.mjs.map → domains-BmdX_BMx.mjs.map} +1 -1
  20. package/dist/domains.cjs +2 -2
  21. package/dist/domains.mjs +2 -2
  22. package/dist/extensions/server.cjs +2 -2
  23. package/dist/extensions/server.mjs +2 -2
  24. package/dist/index-Bstndgcw.d.mts.map +1 -1
  25. package/dist/index.cjs +9 -9
  26. package/dist/index.mjs +9 -9
  27. package/dist/{init-BWAZ5HZ_.mjs → init-DLNiuso4.mjs} +3 -3
  28. package/dist/{init-BWAZ5HZ_.mjs.map → init-DLNiuso4.mjs.map} +1 -1
  29. package/dist/{init-3Ovblp16.cjs → init-MwgLrvYK.cjs} +3 -3
  30. package/dist/{init-3Ovblp16.cjs.map → init-MwgLrvYK.cjs.map} +1 -1
  31. package/dist/init.cjs +1 -1
  32. package/dist/init.mjs +1 -1
  33. package/dist/{layeredConfig-E43vpoi5.mjs → layeredConfig-BWcYmZI7.mjs} +2 -2
  34. package/dist/{layeredConfig-E43vpoi5.mjs.map → layeredConfig-BWcYmZI7.mjs.map} +1 -1
  35. package/dist/{layeredConfig-Beodm-hT.cjs → layeredConfig-Dz9REO5H.cjs} +2 -2
  36. package/dist/{layeredConfig-Beodm-hT.cjs.map → layeredConfig-Dz9REO5H.cjs.map} +1 -1
  37. package/dist/layeredConfig.cjs +1 -1
  38. package/dist/layeredConfig.mjs +1 -1
  39. package/dist/{majorModes-DUBj06fk.mjs → majorModes-BQVTbC7k.mjs} +2 -2
  40. package/dist/{majorModes-DUBj06fk.mjs.map → majorModes-BQVTbC7k.mjs.map} +1 -1
  41. package/dist/{majorModes-DeJuAeS4.cjs → majorModes-C6xu8OTJ.cjs} +2 -2
  42. package/dist/{majorModes-DeJuAeS4.cjs.map → majorModes-C6xu8OTJ.cjs.map} +1 -1
  43. package/dist/majorModes.cjs +1 -1
  44. package/dist/majorModes.mjs +1 -1
  45. package/dist/piContext.cjs +1 -1
  46. package/dist/piContext.mjs +1 -1
  47. package/dist/{profiles-F2nS9qxb.cjs → profiles-DZP_-bFs.cjs} +2 -2
  48. package/dist/{profiles-F2nS9qxb.cjs.map → profiles-DZP_-bFs.cjs.map} +1 -1
  49. package/dist/{profiles-BuE2tvbt.mjs → profiles-Lf9s1Fb6.mjs} +2 -2
  50. package/dist/{profiles-BuE2tvbt.mjs.map → profiles-Lf9s1Fb6.mjs.map} +1 -1
  51. package/dist/profiles.cjs +1 -1
  52. package/dist/profiles.mjs +1 -1
  53. package/dist/selectionSwitch.cjs +2 -2
  54. package/dist/selectionSwitch.mjs +2 -2
  55. package/dist/{sessionConfig-D6YxctCD.mjs → sessionConfig-0eGoap9R.mjs} +2 -2
  56. package/dist/{sessionConfig-D6YxctCD.mjs.map → sessionConfig-0eGoap9R.mjs.map} +1 -1
  57. package/dist/{sessionConfig-mnpEL7QG.cjs → sessionConfig-Kj6vmVtE.cjs} +2 -2
  58. package/dist/{sessionConfig-mnpEL7QG.cjs.map → sessionConfig-Kj6vmVtE.cjs.map} +1 -1
  59. package/dist/{settingsApi-kXIXIfl0.mjs → settingsApi-CSog84S1.mjs} +15 -27
  60. package/dist/settingsApi-CSog84S1.mjs.map +1 -0
  61. package/dist/{settingsApi-BCAv_9pi.cjs → settingsApi-DZ0hKFXA.cjs} +15 -27
  62. package/dist/settingsApi-DZ0hKFXA.cjs.map +1 -0
  63. package/package.json +4 -4
  64. package/dist/config-Bd8XQgUt.mjs.map +0 -1
  65. package/dist/config-CpQA0FCa.cjs.map +0 -1
  66. package/dist/core-CcPiMlUw.mjs.map +0 -1
  67. package/dist/core-DuzB4uF3.cjs.map +0 -1
  68. package/dist/settingsApi-BCAv_9pi.cjs.map +0 -1
  69. package/dist/settingsApi-kXIXIfl0.mjs.map +0 -1
@@ -9,14 +9,10 @@ const Text = typebox.Type.String();
9
9
  const Optional = typebox.Type.Optional;
10
10
  const Strings = typebox.Type.Array(Text);
11
11
  const NullableText = typebox.Type.Union([Text, typebox.Type.Null()]);
12
- const Scope = typebox.Type.Union([typebox.Type.Literal("global"), typebox.Type.Literal("repository")]);
13
- const RequestScope = typebox.Type.Union([
14
- typebox.Type.Literal("host"),
15
- typebox.Type.Literal("global"),
16
- typebox.Type.Literal("repository")
17
- ]);
12
+ const Scope = typebox.Type.Union([typebox.Type.Literal("host"), typebox.Type.Literal("repository")]);
13
+ const RequestScope = typebox.Type.Union([typebox.Type.Literal("host"), typebox.Type.Literal("repository")]);
18
14
  const Origin = typebox.Type.Union([
19
- typebox.Type.Literal("global"),
15
+ typebox.Type.Literal("host"),
20
16
  typebox.Type.Literal("repository"),
21
17
  typebox.Type.Literal("default")
22
18
  ]);
@@ -24,7 +20,6 @@ const SettingsConfigSchema = typebox.Type.Object({
24
20
  repoRoot: Text,
25
21
  hashes: typebox.Type.Object({
26
22
  host: Text,
27
- global: Text,
28
23
  repository: Text
29
24
  }),
30
25
  values: typebox.Type.Record(Text, typebox.Type.Object({
@@ -154,7 +149,7 @@ const http = ["host", "workspace"].flatMap((scope) => {
154
149
  path: "/repository",
155
150
  method: "GET",
156
151
  description: "Read the mounted workspace catalog and selection.",
157
- availability: "Requires a workspace mount; global returns 404.",
152
+ availability: "Requires a workspace mount; host returns 404.",
158
153
  responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(RepositorySettingsSchema)
159
154
  },
160
155
  {
@@ -163,7 +158,7 @@ const http = ["host", "workspace"].flatMap((scope) => {
163
158
  path: "/repository/selection",
164
159
  method: "PUT",
165
160
  description: "Update the mounted workspace selection.",
166
- availability: "Requires a workspace mount; global returns 404.",
161
+ availability: "Requires a workspace mount; host returns 404.",
167
162
  body: {
168
163
  contentType: "application/json",
169
164
  required: true,
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Optional = Type.Optional;\nconst Strings = Type.Array(Text);\nconst NullableText = Type.Union([Text, Type.Null()]);\n// ponytail: the wire spells the host tier 'global' until Phase 10; requests may also say 'host'.\nconst Scope = Type.Union([Type.Literal('global'), Type.Literal('repository')]);\nconst RequestScope = Type.Union([Type.Literal('host'), Type.Literal('global'), Type.Literal('repository')]);\nconst Origin = Type.Union([Type.Literal('global'), Type.Literal('repository'), Type.Literal('default')]);\nexport const SettingsConfigSchema = Type.Object({\n repoRoot: Text,\n // ponytail: `global` duplicates `host` for older clients until Phase 10.\n hashes: Type.Object({ host: Text, global: Text, repository: Text }),\n values: Type.Record(\n Text,\n Type.Object({\n value: Optional(Text),\n origin: Origin,\n scope: Type.Union([Scope, Type.Literal('both')]),\n }),\n ),\n});\nconst SettingsEditSchema = Type.Object({ keyPath: Strings, value: Type.Union([Text, Type.Number(), Type.Null()]) });\nexport const SettingsWriteSchema = Type.Union([\n Type.Object({ repoRoot: Text, scope: RequestScope, ...SettingsEditSchema.properties, expectedHash: Text }),\n Type.Object({\n repoRoot: Text,\n scope: RequestScope,\n edits: Type.Array(SettingsEditSchema, { minItems: 1, maxItems: 100 }),\n expectedHash: Text,\n }),\n]);\n\nconst Repository = Type.Object({ id: Text, name: Text, path: Text, active: Type.Boolean() });\nconst Catalog = Type.Array(\n Type.Object({ name: Text, description: Optional(Text), expandsTo: Optional(Strings), layers: Optional(Strings) }),\n);\nconst SelectionText = Type.Object({ effective: Optional(Text), repository: Optional(Text), origin: Origin });\nconst SelectionStrings = Type.Object({ effective: Optional(Strings), repository: Optional(Strings), origin: Origin });\nexport const RepositorySettingsSchema = Type.Object({\n repository: Repository,\n hash: Text,\n catalogs: Type.Object({ majorModes: Catalog, domains: Catalog, profiles: Catalog }),\n selection: Type.Object({ majorMode: SelectionText, domains: SelectionStrings, profile: SelectionText }),\n});\nexport const RepositorySelectionWriteSchema = Type.Object({\n repositoryId: Text,\n expectedHash: Text,\n changes: Type.Object({\n majorMode: Optional(NullableText),\n domains: Optional(Type.Union([Strings, Type.Null()])),\n profile: Optional(NullableText),\n }),\n});\nconst Images = Type.Object({\n autoResize: Type.Boolean(),\n maxDimension: Type.Number(),\n minDimension: Type.Number(),\n maxAllowedDimension: Type.Number(),\n});\nconst http: PoHttpContract[] = (['host', 'workspace'] as const).flatMap((scope) => {\n const common = { scope, basePath: 'settings', authentication: 'owner' as const };\n return [\n {\n ...common,\n id: 'config',\n path: '/',\n method: 'GET',\n description: 'Read selected settings keys and file hashes.',\n parameters: [{ name: 'key', in: 'query', required: false, schema: Strings }],\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'value',\n path: '/value',\n method: 'PUT',\n description: 'Write a setting with an optimistic file hash.',\n body: { contentType: 'application/json', required: true, schema: SettingsWriteSchema },\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'repositories',\n path: '/repositories',\n method: 'GET',\n description: 'List admitted repositories.',\n responses: jsonApiResponses(Type.Object({ repositories: Type.Array(Repository) })),\n },\n {\n ...common,\n id: 'repository',\n path: '/repository',\n method: 'GET',\n description: 'Read the mounted workspace catalog and selection.',\n availability: 'Requires a workspace mount; global returns 404.',\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n {\n ...common,\n id: 'selection',\n path: '/repository/selection',\n method: 'PUT',\n description: 'Update the mounted workspace selection.',\n availability: 'Requires a workspace mount; global returns 404.',\n body: { contentType: 'application/json', required: true, schema: RepositorySelectionWriteSchema },\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n ...(scope === 'host'\n ? [\n {\n ...common,\n id: 'images.get',\n path: '/images',\n method: 'GET' as const,\n description: 'Read image resizing limits.',\n responses: jsonApiResponses(Images),\n },\n {\n ...common,\n id: 'images.put',\n path: '/images',\n method: 'PUT' as const,\n description: 'Update image resizing settings; dimensions are clamped.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object({ autoResize: Optional(Type.Boolean()), maxDimension: Optional(Type.Number()) }),\n },\n responses: jsonApiResponses(Images),\n },\n ]\n : []),\n ] satisfies PoHttpContract[];\n});\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,OAAOA,QAAAA,KAAK,OAAO;AACzB,MAAM,WAAWA,QAAAA,KAAK;AACtB,MAAM,UAAUA,QAAAA,KAAK,MAAM,IAAI;AAC/B,MAAM,eAAeA,QAAAA,KAAK,MAAM,CAAC,MAAMA,QAAAA,KAAK,KAAK,CAAC,CAAC;AAEnD,MAAM,QAAQA,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAA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,KAAK,OAAO,CAAC;IAAE,CAAC;GACrG;GACA,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,MAAM;EACpC,CACF,IACA,CAAC;CACP;AACF,CAAC;AACD,MAAa,gBAAA,GAAeC,gCAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","jsonApiResponses","defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Optional = Type.Optional;\nconst Strings = Type.Array(Text);\nconst NullableText = Type.Union([Text, Type.Null()]);\nconst Scope = Type.Union([Type.Literal('host'), Type.Literal('repository')]);\nconst RequestScope = Type.Union([Type.Literal('host'), Type.Literal('repository')]);\nconst Origin = Type.Union([Type.Literal('host'), Type.Literal('repository'), Type.Literal('default')]);\nexport const SettingsConfigSchema = Type.Object({\n repoRoot: Text,\n hashes: Type.Object({ host: Text, repository: Text }),\n values: Type.Record(\n Text,\n Type.Object({\n value: Optional(Text),\n origin: Origin,\n scope: Type.Union([Scope, Type.Literal('both')]),\n }),\n ),\n});\nconst SettingsEditSchema = Type.Object({ keyPath: Strings, value: Type.Union([Text, Type.Number(), Type.Null()]) });\nexport const SettingsWriteSchema = Type.Union([\n Type.Object({ repoRoot: Text, scope: RequestScope, ...SettingsEditSchema.properties, expectedHash: Text }),\n Type.Object({\n repoRoot: Text,\n scope: RequestScope,\n edits: Type.Array(SettingsEditSchema, { minItems: 1, maxItems: 100 }),\n expectedHash: Text,\n }),\n]);\n\nconst Repository = Type.Object({ id: Text, name: Text, path: Text, active: Type.Boolean() });\nconst Catalog = Type.Array(\n Type.Object({ name: Text, description: Optional(Text), expandsTo: Optional(Strings), layers: Optional(Strings) }),\n);\nconst SelectionText = Type.Object({ effective: Optional(Text), repository: Optional(Text), origin: Origin });\nconst SelectionStrings = Type.Object({ effective: Optional(Strings), repository: Optional(Strings), origin: Origin });\nexport const RepositorySettingsSchema = Type.Object({\n repository: Repository,\n hash: Text,\n catalogs: Type.Object({ majorModes: Catalog, domains: Catalog, profiles: Catalog }),\n selection: Type.Object({ majorMode: SelectionText, domains: SelectionStrings, profile: SelectionText }),\n});\nexport const RepositorySelectionWriteSchema = Type.Object({\n repositoryId: Text,\n expectedHash: Text,\n changes: Type.Object({\n majorMode: Optional(NullableText),\n domains: Optional(Type.Union([Strings, Type.Null()])),\n profile: Optional(NullableText),\n }),\n});\nconst Images = Type.Object({\n autoResize: Type.Boolean(),\n maxDimension: Type.Number(),\n minDimension: Type.Number(),\n maxAllowedDimension: Type.Number(),\n});\nconst http: PoHttpContract[] = (['host', 'workspace'] as const).flatMap((scope) => {\n const common = { scope, basePath: 'settings', authentication: 'owner' as const };\n return [\n {\n ...common,\n id: 'config',\n path: '/',\n method: 'GET',\n description: 'Read selected settings keys and file hashes.',\n parameters: [{ name: 'key', in: 'query', required: false, schema: Strings }],\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'value',\n path: '/value',\n method: 'PUT',\n description: 'Write a setting with an optimistic file hash.',\n body: { contentType: 'application/json', required: true, schema: SettingsWriteSchema },\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'repositories',\n path: '/repositories',\n method: 'GET',\n description: 'List admitted repositories.',\n responses: jsonApiResponses(Type.Object({ repositories: Type.Array(Repository) })),\n },\n {\n ...common,\n id: 'repository',\n path: '/repository',\n method: 'GET',\n description: 'Read the mounted workspace catalog and selection.',\n availability: 'Requires a workspace mount; host returns 404.',\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n {\n ...common,\n id: 'selection',\n path: '/repository/selection',\n method: 'PUT',\n description: 'Update the mounted workspace selection.',\n availability: 'Requires a workspace mount; host returns 404.',\n body: { contentType: 'application/json', required: true, schema: RepositorySelectionWriteSchema },\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n ...(scope === 'host'\n ? [\n {\n ...common,\n id: 'images.get',\n path: '/images',\n method: 'GET' as const,\n description: 'Read image resizing limits.',\n responses: jsonApiResponses(Images),\n },\n {\n ...common,\n id: 'images.put',\n path: '/images',\n method: 'PUT' as const,\n description: 'Update image resizing settings; dimensions are clamped.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object({ autoResize: Optional(Type.Boolean()), maxDimension: Optional(Type.Number()) }),\n },\n responses: jsonApiResponses(Images),\n },\n ]\n : []),\n ] satisfies PoHttpContract[];\n});\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,OAAOA,QAAAA,KAAK,OAAO;AACzB,MAAM,WAAWA,QAAAA,KAAK;AACtB,MAAM,UAAUA,QAAAA,KAAK,MAAM,IAAI;AAC/B,MAAM,eAAeA,QAAAA,KAAK,MAAM,CAAC,MAAMA,QAAAA,KAAK,KAAK,CAAC,CAAC;AACnD,MAAM,QAAQA,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAAK,QAAQ,MAAM,GAAGA,QAAAA,KAAK,QAAQ,YAAY,CAAC,CAAC;AAC3E,MAAM,eAAeA,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAAK,QAAQ,MAAM,GAAGA,QAAAA,KAAK,QAAQ,YAAY,CAAC,CAAC;AAClF,MAAM,SAASA,QAAAA,KAAK,MAAM;CAACA,QAAAA,KAAK,QAAQ,MAAM;CAAGA,QAAAA,KAAK,QAAQ,YAAY;CAAGA,QAAAA,KAAK,QAAQ,SAAS;AAAC,CAAC;AACrG,MAAa,uBAAuBA,QAAAA,KAAK,OAAO;CAC9C,UAAU;CACV,QAAQA,QAAAA,KAAK,OAAO;EAAE,MAAM;EAAM,YAAY;CAAK,CAAC;CACpD,QAAQA,QAAAA,KAAK,OACX,MACAA,QAAAA,KAAK,OAAO;EACV,OA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CAAC,CAAC;EACnF;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,wBAAwB;EACtD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,MAAM;IAAE,aAAa;IAAoB,UAAU;IAAM,QAAQ;GAA+B;GAChG,YAAA,GAAWA,gCAAAA,iBAAAA,CAAiB,wBAAwB;EACtD;EACA,GAAI,UAAU,SACV,CACE;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,YAAA,GAAWA,gCAAAA,iBAAAA,CAAiB,MAAM;EACpC,GACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM;IACJ,aAAa;IACb,UAAU;IACV,QAAQD,QAAAA,KAAK,OAAO;KAAE,YAAY,SAASA,QAAAA,KAAK,QAAQ,CAAC;KAAG,cAAc,SAASA,QAAAA,KAAK,OAAO,CAAC;IAAE,CAAC;GACrG;GACA,YAAA,GAAWC,gCAAAA,iBAAAA,CAAiB,MAAM;EACpC,CACF,IACA,CAAC;CACP;AACF,CAAC;AACD,MAAa,gBAAA,GAAeC,gCAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAyIa"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAuIa"}
@@ -5,14 +5,10 @@ const Text = Type.String();
5
5
  const Optional = Type.Optional;
6
6
  const Strings = Type.Array(Text);
7
7
  const NullableText = Type.Union([Text, Type.Null()]);
8
- const Scope = Type.Union([Type.Literal("global"), Type.Literal("repository")]);
9
- const RequestScope = Type.Union([
10
- Type.Literal("host"),
11
- Type.Literal("global"),
12
- Type.Literal("repository")
13
- ]);
8
+ const Scope = Type.Union([Type.Literal("host"), Type.Literal("repository")]);
9
+ const RequestScope = Type.Union([Type.Literal("host"), Type.Literal("repository")]);
14
10
  const Origin = Type.Union([
15
- Type.Literal("global"),
11
+ Type.Literal("host"),
16
12
  Type.Literal("repository"),
17
13
  Type.Literal("default")
18
14
  ]);
@@ -20,7 +16,6 @@ const SettingsConfigSchema = Type.Object({
20
16
  repoRoot: Text,
21
17
  hashes: Type.Object({
22
18
  host: Text,
23
- global: Text,
24
19
  repository: Text
25
20
  }),
26
21
  values: Type.Record(Text, Type.Object({
@@ -150,7 +145,7 @@ const http = ["host", "workspace"].flatMap((scope) => {
150
145
  path: "/repository",
151
146
  method: "GET",
152
147
  description: "Read the mounted workspace catalog and selection.",
153
- availability: "Requires a workspace mount; global returns 404.",
148
+ availability: "Requires a workspace mount; host returns 404.",
154
149
  responses: jsonApiResponses(RepositorySettingsSchema)
155
150
  },
156
151
  {
@@ -159,7 +154,7 @@ const http = ["host", "workspace"].flatMap((scope) => {
159
154
  path: "/repository/selection",
160
155
  method: "PUT",
161
156
  description: "Update the mounted workspace selection.",
162
- availability: "Requires a workspace mount; global returns 404.",
157
+ availability: "Requires a workspace mount; host returns 404.",
163
158
  body: {
164
159
  contentType: "application/json",
165
160
  required: true,
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Optional = Type.Optional;\nconst Strings = Type.Array(Text);\nconst NullableText = Type.Union([Text, Type.Null()]);\n// ponytail: the wire spells the host tier 'global' until Phase 10; requests may also say 'host'.\nconst Scope = Type.Union([Type.Literal('global'), Type.Literal('repository')]);\nconst RequestScope = Type.Union([Type.Literal('host'), Type.Literal('global'), Type.Literal('repository')]);\nconst Origin = Type.Union([Type.Literal('global'), Type.Literal('repository'), Type.Literal('default')]);\nexport const SettingsConfigSchema = Type.Object({\n repoRoot: Text,\n // ponytail: `global` duplicates `host` for older clients until Phase 10.\n hashes: Type.Object({ host: Text, global: Text, repository: Text }),\n values: Type.Record(\n Text,\n Type.Object({\n value: Optional(Text),\n origin: Origin,\n scope: Type.Union([Scope, Type.Literal('both')]),\n }),\n ),\n});\nconst SettingsEditSchema = Type.Object({ keyPath: Strings, value: Type.Union([Text, Type.Number(), Type.Null()]) });\nexport const SettingsWriteSchema = Type.Union([\n Type.Object({ repoRoot: Text, scope: RequestScope, ...SettingsEditSchema.properties, expectedHash: Text }),\n Type.Object({\n repoRoot: Text,\n scope: RequestScope,\n edits: Type.Array(SettingsEditSchema, { minItems: 1, maxItems: 100 }),\n expectedHash: Text,\n }),\n]);\n\nconst Repository = Type.Object({ id: Text, name: Text, path: Text, active: Type.Boolean() });\nconst Catalog = Type.Array(\n Type.Object({ name: Text, description: Optional(Text), expandsTo: Optional(Strings), layers: Optional(Strings) }),\n);\nconst SelectionText = Type.Object({ effective: Optional(Text), repository: Optional(Text), origin: Origin });\nconst SelectionStrings = Type.Object({ effective: Optional(Strings), repository: Optional(Strings), origin: Origin });\nexport const RepositorySettingsSchema = Type.Object({\n repository: Repository,\n hash: Text,\n catalogs: Type.Object({ majorModes: Catalog, domains: Catalog, profiles: Catalog }),\n selection: Type.Object({ majorMode: SelectionText, domains: SelectionStrings, profile: SelectionText }),\n});\nexport const RepositorySelectionWriteSchema = Type.Object({\n repositoryId: Text,\n expectedHash: Text,\n changes: Type.Object({\n majorMode: Optional(NullableText),\n domains: Optional(Type.Union([Strings, Type.Null()])),\n profile: Optional(NullableText),\n }),\n});\nconst Images = Type.Object({\n autoResize: Type.Boolean(),\n maxDimension: Type.Number(),\n minDimension: Type.Number(),\n maxAllowedDimension: Type.Number(),\n});\nconst http: PoHttpContract[] = (['host', 'workspace'] as const).flatMap((scope) => {\n const common = { scope, basePath: 'settings', authentication: 'owner' as const };\n return [\n {\n ...common,\n id: 'config',\n path: '/',\n method: 'GET',\n description: 'Read selected settings keys and file hashes.',\n parameters: [{ name: 'key', in: 'query', required: false, schema: Strings }],\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'value',\n path: '/value',\n method: 'PUT',\n description: 'Write a setting with an optimistic file hash.',\n body: { contentType: 'application/json', required: true, schema: SettingsWriteSchema },\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'repositories',\n path: '/repositories',\n method: 'GET',\n description: 'List admitted repositories.',\n responses: jsonApiResponses(Type.Object({ repositories: Type.Array(Repository) })),\n },\n {\n ...common,\n id: 'repository',\n path: '/repository',\n method: 'GET',\n description: 'Read the mounted workspace catalog and selection.',\n availability: 'Requires a workspace mount; global returns 404.',\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n {\n ...common,\n id: 'selection',\n path: '/repository/selection',\n method: 'PUT',\n description: 'Update the mounted workspace selection.',\n availability: 'Requires a workspace mount; global returns 404.',\n body: { contentType: 'application/json', required: true, schema: RepositorySelectionWriteSchema },\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n ...(scope === 'host'\n ? [\n {\n ...common,\n id: 'images.get',\n path: '/images',\n method: 'GET' as const,\n description: 'Read image resizing limits.',\n responses: jsonApiResponses(Images),\n },\n {\n ...common,\n id: 'images.put',\n path: '/images',\n method: 'PUT' as const,\n description: 'Update image resizing settings; dimensions are clamped.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object({ autoResize: Optional(Type.Boolean()), maxDimension: Optional(Type.Number()) }),\n },\n responses: jsonApiResponses(Images),\n },\n ]\n : []),\n ] satisfies PoHttpContract[];\n});\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,OAAO,KAAK,OAAO;AACzB,MAAM,WAAW,KAAK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BAAoB;EAClD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM;IAAE,aAAa;IAAoB,UAAU;IAAM,QAAQ;GAAoB;GACrF,WAAW,iBAAiB,oBAAoB;EAClD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,WAAW,iBAAiB,KAAK,OAAO,EAAE,cAAc,KAAK,MAAM,UAAU,EAAE,CAAC,CAAC;EACnF;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,WAAW,iBAAiB,wBAAwB;EACtD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,MAAM;IAAE,aAAa;IAAoB,UAAU;IAAM,QAAQ;GAA+B;GAChG,WAAW,iBAAiB,wBAAwB;EACtD;EACA,GAAI,UAAU,SACV,CACE;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,WAAW,iBAAiB,MAAM;EACpC,GACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM;IACJ,aAAa;IACb,UAAU;IACV,QAAQ,KAAK,OAAO;KAAE,YAAY,SAAS,KAAK,QAAQ,CAAC;KAAG,cAAc,SAAS,KAAK,OAAO,CAAC;IAAE,CAAC;GACrG;GACA,WAAW,iBAAiB,MAAM;EACpC,CACF,IACA,CAAC;CACP;AACF,CAAC;AACD,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst Text = Type.String();\nconst Optional = Type.Optional;\nconst Strings = Type.Array(Text);\nconst NullableText = Type.Union([Text, Type.Null()]);\nconst Scope = Type.Union([Type.Literal('host'), Type.Literal('repository')]);\nconst RequestScope = Type.Union([Type.Literal('host'), Type.Literal('repository')]);\nconst Origin = Type.Union([Type.Literal('host'), Type.Literal('repository'), Type.Literal('default')]);\nexport const SettingsConfigSchema = Type.Object({\n repoRoot: Text,\n hashes: Type.Object({ host: Text, repository: Text }),\n values: Type.Record(\n Text,\n Type.Object({\n value: Optional(Text),\n origin: Origin,\n scope: Type.Union([Scope, Type.Literal('both')]),\n }),\n ),\n});\nconst SettingsEditSchema = Type.Object({ keyPath: Strings, value: Type.Union([Text, Type.Number(), Type.Null()]) });\nexport const SettingsWriteSchema = Type.Union([\n Type.Object({ repoRoot: Text, scope: RequestScope, ...SettingsEditSchema.properties, expectedHash: Text }),\n Type.Object({\n repoRoot: Text,\n scope: RequestScope,\n edits: Type.Array(SettingsEditSchema, { minItems: 1, maxItems: 100 }),\n expectedHash: Text,\n }),\n]);\n\nconst Repository = Type.Object({ id: Text, name: Text, path: Text, active: Type.Boolean() });\nconst Catalog = Type.Array(\n Type.Object({ name: Text, description: Optional(Text), expandsTo: Optional(Strings), layers: Optional(Strings) }),\n);\nconst SelectionText = Type.Object({ effective: Optional(Text), repository: Optional(Text), origin: Origin });\nconst SelectionStrings = Type.Object({ effective: Optional(Strings), repository: Optional(Strings), origin: Origin });\nexport const RepositorySettingsSchema = Type.Object({\n repository: Repository,\n hash: Text,\n catalogs: Type.Object({ majorModes: Catalog, domains: Catalog, profiles: Catalog }),\n selection: Type.Object({ majorMode: SelectionText, domains: SelectionStrings, profile: SelectionText }),\n});\nexport const RepositorySelectionWriteSchema = Type.Object({\n repositoryId: Text,\n expectedHash: Text,\n changes: Type.Object({\n majorMode: Optional(NullableText),\n domains: Optional(Type.Union([Strings, Type.Null()])),\n profile: Optional(NullableText),\n }),\n});\nconst Images = Type.Object({\n autoResize: Type.Boolean(),\n maxDimension: Type.Number(),\n minDimension: Type.Number(),\n maxAllowedDimension: Type.Number(),\n});\nconst http: PoHttpContract[] = (['host', 'workspace'] as const).flatMap((scope) => {\n const common = { scope, basePath: 'settings', authentication: 'owner' as const };\n return [\n {\n ...common,\n id: 'config',\n path: '/',\n method: 'GET',\n description: 'Read selected settings keys and file hashes.',\n parameters: [{ name: 'key', in: 'query', required: false, schema: Strings }],\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'value',\n path: '/value',\n method: 'PUT',\n description: 'Write a setting with an optimistic file hash.',\n body: { contentType: 'application/json', required: true, schema: SettingsWriteSchema },\n responses: jsonApiResponses(SettingsConfigSchema),\n },\n {\n ...common,\n id: 'repositories',\n path: '/repositories',\n method: 'GET',\n description: 'List admitted repositories.',\n responses: jsonApiResponses(Type.Object({ repositories: Type.Array(Repository) })),\n },\n {\n ...common,\n id: 'repository',\n path: '/repository',\n method: 'GET',\n description: 'Read the mounted workspace catalog and selection.',\n availability: 'Requires a workspace mount; host returns 404.',\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n {\n ...common,\n id: 'selection',\n path: '/repository/selection',\n method: 'PUT',\n description: 'Update the mounted workspace selection.',\n availability: 'Requires a workspace mount; host returns 404.',\n body: { contentType: 'application/json', required: true, schema: RepositorySelectionWriteSchema },\n responses: jsonApiResponses(RepositorySettingsSchema),\n },\n ...(scope === 'host'\n ? [\n {\n ...common,\n id: 'images.get',\n path: '/images',\n method: 'GET' as const,\n description: 'Read image resizing limits.',\n responses: jsonApiResponses(Images),\n },\n {\n ...common,\n id: 'images.put',\n path: '/images',\n method: 'PUT' as const,\n description: 'Update image resizing settings; dimensions are clamped.',\n body: {\n contentType: 'application/json',\n required: true,\n schema: Type.Object({ autoResize: Optional(Type.Boolean()), maxDimension: Optional(Type.Number()) }),\n },\n responses: jsonApiResponses(Images),\n },\n ]\n : []),\n ] satisfies PoHttpContract[];\n});\nexport const apiContracts = defineApiContract({ version: 1, http, sockets: [], dynamic: [] });\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AQ,CAAC;GAC3E,WAAW,iBAAiB,oBAAoB;EAClD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM;IAAE,aAAa;IAAoB,UAAU;IAAM,QAAQ;GAAoB;GACrF,WAAW,iBAAiB,oBAAoB;EAClD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,WAAW,iBAAiB,KAAK,OAAO,EAAE,cAAc,KAAK,MAAM,UAAU,EAAE,CAAC,CAAC;EACnF;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,WAAW,iBAAiB,wBAAwB;EACtD;EACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,cAAc;GACd,MAAM;IAAE,aAAa;IAAoB,UAAU;IAAM,QAAQ;GAA+B;GAChG,WAAW,iBAAiB,wBAAwB;EACtD;EACA,GAAI,UAAU,SACV,CACE;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,WAAW,iBAAiB,MAAM;EACpC,GACA;GACE,GAAG;GACH,IAAI;GACJ,MAAM;GACN,QAAQ;GACR,aAAa;GACb,MAAM;IACJ,aAAa;IACb,UAAU;IACV,QAAQ,KAAK,OAAO;KAAE,YAAY,SAAS,KAAK,QAAQ,CAAC;KAAG,cAAc,SAAS,KAAK,OAAO,CAAC;IAAE,CAAC;GACrG;GACA,WAAW,iBAAiB,MAAM;EACpC,CACF,IACA,CAAC;CACP;AACF,CAAC;AACD,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG;CAAM,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { g as parsePoConfig } from "./configPolicy-C5n1_TYu.mjs";
2
- import { d as mergeConfigLayers, f as mergeLenientLayers, g as withGlobalLayer, i as defaultPoConfig, l as layerFromText, n as composeConfigLayers, o as globalPoConfigPath, p as repositoryConfigFor, r as configFromText, s as globalSettingsCachePath, t as absentRepositoryLayer, u as lenientConfigFromText } from "./core-CcPiMlUw.mjs";
2
+ import { c as globalSettingsOwner, d as layerFromText, f as lenientConfigFromText, h as repositoryConfigFor, i as defaultPoConfig, l as globalSettingsOwnerPath, m as mergeLenientLayers, n as composeConfigLayers, o as globalPoConfigPath, p as mergeConfigLayers, r as configFromText, s as globalSettingsCachePath, t as absentRepositoryLayer, v as withGlobalLayer } from "./core-B1oari2a.mjs";
3
3
  import path from "node:path";
4
4
  import { nodeHost, readTextIfExists, writeFileAtomic } from "@agimon-ai/po-core/platform";
5
5
  import fs from "node:fs";
@@ -27,7 +27,7 @@ async function readText$1(filePath) {
27
27
  function loadPoConfig(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {
28
28
  const globalPath = globalPoConfigPath(homeDirectory, environment);
29
29
  const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);
30
- return mergeConfigLayers(configFromText(withGlobalLayer(readTextSync(globalSettingsCachePath(homeDirectory, environment)), readTextSync(globalPath)), globalPath), repositoryPath === void 0 ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath), environment);
30
+ return mergeConfigLayers(configFromText(withGlobalLayer(readTextSync(globalSettingsCachePath(homeDirectory, environment)), readTextSync(globalPath), globalSettingsOwner(readTextSync(globalSettingsOwnerPath(homeDirectory, environment)))), globalPath), repositoryPath === void 0 ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath), environment);
31
31
  }
32
32
  /**
33
33
  * Loads the merged config, tolerating unknown keys in either file.
@@ -48,7 +48,7 @@ function loadPoConfigLenient(repoRoot, homeDirectory = nodeHost.homeDirectory(),
48
48
  async function loadPoConfigAsync(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {
49
49
  const globalPath = globalPoConfigPath(homeDirectory, environment);
50
50
  const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);
51
- const globalConfig = configFromText(withGlobalLayer(await readText$1(globalSettingsCachePath(homeDirectory, environment)), await readText$1(globalPath)), globalPath);
51
+ const globalConfig = configFromText(withGlobalLayer(await readText$1(globalSettingsCachePath(homeDirectory, environment)), await readText$1(globalPath), globalSettingsOwner(await readText$1(globalSettingsOwnerPath(homeDirectory, environment)))), globalPath);
52
52
  const repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(await readText$1(repositoryPath), repositoryPath);
53
53
  return mergeConfigLayers(globalConfig, repositoryConfig, environment);
54
54
  }
@@ -153,7 +153,8 @@ async function readPoConfig(fs, repoRoot, context, options = {}) {
153
153
  const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);
154
154
  const hostText = await readText(fs, globalPath, context);
155
155
  const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);
156
- const globalConfig = configFromText(withGlobalLayer(cacheText, hostText), globalPath);
156
+ const member = globalSettingsOwner(await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context));
157
+ const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);
157
158
  const repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(await readText(fs, repositoryPath, context), repositoryPath);
158
159
  return mergeConfigLayers(globalConfig, repositoryConfig, environment);
159
160
  }
@@ -166,9 +167,13 @@ async function refreshGlobalSettingsCache(fs, accountCall, context, options) {
166
167
  const answer = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => void 0);
167
168
  const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);
168
169
  if (typeof answer !== "object" || answer === null) return "kept";
169
- const { ok, yaml, code } = answer;
170
- if (ok === true && typeof yaml === "string") {
171
- await writeFileAtomic(fs, cachePath, yaml, context);
170
+ const { ok, yaml, code, binding } = answer;
171
+ const member = globalSettingsOwner(await readText(fs, globalSettingsOwnerPath(options.homeDirectory, options.environment), context));
172
+ if (ok === true && typeof yaml === "string" && member && binding && member.issuer === binding.issuer && member.org === binding.org && member.subject === binding.subject) {
173
+ await writeFileAtomic(fs, cachePath, JSON.stringify({
174
+ binding,
175
+ yaml
176
+ }), context);
172
177
  return "written";
173
178
  }
174
179
  if (code === "shared") {
@@ -208,4 +213,4 @@ async function readPoConfigLayers(fs, repoRoot, context, options = {}) {
208
213
  //#endregion
209
214
  export { refreshGlobalSettingsCache as a, loadPoConfigLayers as c, readWorkspaceDeclarations as i, loadPoConfigLenient as l, readPoConfigLayers as n, loadPoConfig as o, readPoConfigLenient as r, loadPoConfigAsync as s, readPoConfig as t };
210
215
 
211
- //# sourceMappingURL=config-Bd8XQgUt.mjs.map
216
+ //# sourceMappingURL=config-Djaao8IK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-Djaao8IK.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 globalSettingsOwner,\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 globalSettingsOwner(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 globalSettingsOwner(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 { 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 globalSettingsOwner,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n type ConfigEnvironment,\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 /** Defaults to `process.env`. */\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 ?? process.env,\n };\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 * The host owner's cached global settings sit beneath the host file, portable keys only.\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 = globalSettingsOwner(await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context));\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 the issuer. `ok` replaces it; `shared` (the org has other\n * members, so sessions here may not be the owner's) removes it. Anything else, such as no network\n * or an unreachable issuer, keeps the last copy.\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 answer = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n if (typeof answer !== 'object' || answer === null) return 'kept';\n const { ok, yaml, code, binding } = answer as {\n ok?: unknown;\n yaml?: unknown;\n code?: unknown;\n binding?: import('./core').GlobalSettingsBinding;\n };\n const member = globalSettingsOwner(\n await readText(fs, globalSettingsOwnerPath(options.homeDirectory, options.environment), context),\n );\n if (\n ok === true &&\n typeof yaml === 'string' &&\n member &&\n binding &&\n member.issuer === binding.issuer &&\n member.org === binding.org &&\n member.subject === binding.subject\n ) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ binding, yaml }), context);\n return 'written';\n }\n if (code === 'shared') {\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 return 'kept';\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 isGlobalPoConfigRoot,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment } 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,oBAAoB,aAAa,wBAAwB,eAAe,WAAW,CAAC,CAAC,CACvF,GACA,UACF,GACA,mBAAmB,KAAA,IAAY,gBAAgB,IAAI,eAAe,aAAa,cAAc,GA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B,MAAM,EAAE,eAAe,gBAAgB,SAAS,OAAO;CACvD,MAAM,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,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
2
  const require_configPolicy = require("./configPolicy-DT_C-QJF.cjs");
3
- const require_core = require("./core-DuzB4uF3.cjs");
3
+ const require_core = require("./core-CyAtb-Gt.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");
@@ -30,7 +30,7 @@ async function readText$1(filePath) {
30
30
  function loadPoConfig(repoRoot, homeDirectory = _agimon_ai_po_core_platform.nodeHost.homeDirectory(), environment = process.env) {
31
31
  const globalPath = require_core.globalPoConfigPath(homeDirectory, environment);
32
32
  const repositoryPath = require_core.repositoryConfigFor(repoRoot, homeDirectory, environment);
33
- return require_core.mergeConfigLayers(require_core.configFromText(require_core.withGlobalLayer(readTextSync(require_core.globalSettingsCachePath(homeDirectory, environment)), readTextSync(globalPath)), globalPath), repositoryPath === void 0 ? require_core.defaultPoConfig() : require_core.configFromText(readTextSync(repositoryPath), repositoryPath), environment);
33
+ return require_core.mergeConfigLayers(require_core.configFromText(require_core.withGlobalLayer(readTextSync(require_core.globalSettingsCachePath(homeDirectory, environment)), readTextSync(globalPath), require_core.globalSettingsOwner(readTextSync(require_core.globalSettingsOwnerPath(homeDirectory, environment)))), globalPath), repositoryPath === void 0 ? require_core.defaultPoConfig() : require_core.configFromText(readTextSync(repositoryPath), repositoryPath), environment);
34
34
  }
35
35
  /**
36
36
  * Loads the merged config, tolerating unknown keys in either file.
@@ -51,7 +51,7 @@ function loadPoConfigLenient(repoRoot, homeDirectory = _agimon_ai_po_core_platfo
51
51
  async function loadPoConfigAsync(repoRoot, homeDirectory = _agimon_ai_po_core_platform.nodeHost.homeDirectory(), environment = process.env) {
52
52
  const globalPath = require_core.globalPoConfigPath(homeDirectory, environment);
53
53
  const repositoryPath = require_core.repositoryConfigFor(repoRoot, homeDirectory, environment);
54
- const globalConfig = require_core.configFromText(require_core.withGlobalLayer(await readText$1(require_core.globalSettingsCachePath(homeDirectory, environment)), await readText$1(globalPath)), globalPath);
54
+ const globalConfig = require_core.configFromText(require_core.withGlobalLayer(await readText$1(require_core.globalSettingsCachePath(homeDirectory, environment)), await readText$1(globalPath), require_core.globalSettingsOwner(await readText$1(require_core.globalSettingsOwnerPath(homeDirectory, environment)))), globalPath);
55
55
  const repositoryConfig = repositoryPath === void 0 ? require_core.defaultPoConfig() : require_core.configFromText(await readText$1(repositoryPath), repositoryPath);
56
56
  return require_core.mergeConfigLayers(globalConfig, repositoryConfig, environment);
57
57
  }
@@ -156,7 +156,8 @@ async function readPoConfig(fs, repoRoot, context, options = {}) {
156
156
  const repositoryPath = require_core.repositoryConfigFor(repoRoot, homeDirectory, environment);
157
157
  const hostText = await readText(fs, globalPath, context);
158
158
  const cacheText = await readText(fs, require_core.globalSettingsCachePath(homeDirectory, environment), context);
159
- const globalConfig = require_core.configFromText(require_core.withGlobalLayer(cacheText, hostText), globalPath);
159
+ const member = require_core.globalSettingsOwner(await readText(fs, require_core.globalSettingsOwnerPath(homeDirectory, environment), context));
160
+ const globalConfig = require_core.configFromText(require_core.withGlobalLayer(cacheText, hostText, member), globalPath);
160
161
  const repositoryConfig = repositoryPath === void 0 ? require_core.defaultPoConfig() : require_core.configFromText(await readText(fs, repositoryPath, context), repositoryPath);
161
162
  return require_core.mergeConfigLayers(globalConfig, repositoryConfig, environment);
162
163
  }
@@ -169,9 +170,13 @@ async function refreshGlobalSettingsCache(fs, accountCall, context, options) {
169
170
  const answer = await accountCall(_agimon_ai_po_core.GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => void 0);
170
171
  const cachePath = require_core.globalSettingsCachePath(options.homeDirectory, options.environment);
171
172
  if (typeof answer !== "object" || answer === null) return "kept";
172
- const { ok, yaml, code } = answer;
173
- if (ok === true && typeof yaml === "string") {
174
- await (0, _agimon_ai_po_core_platform.writeFileAtomic)(fs, cachePath, yaml, context);
173
+ const { ok, yaml, code, binding } = answer;
174
+ const member = require_core.globalSettingsOwner(await readText(fs, require_core.globalSettingsOwnerPath(options.homeDirectory, options.environment), context));
175
+ if (ok === true && typeof yaml === "string" && member && binding && member.issuer === binding.issuer && member.org === binding.org && member.subject === binding.subject) {
176
+ await (0, _agimon_ai_po_core_platform.writeFileAtomic)(fs, cachePath, JSON.stringify({
177
+ binding,
178
+ yaml
179
+ }), context);
175
180
  return "written";
176
181
  }
177
182
  if (code === "shared") {
@@ -264,4 +269,4 @@ Object.defineProperty(exports, "refreshGlobalSettingsCache", {
264
269
  }
265
270
  });
266
271
 
267
- //# sourceMappingURL=config-CpQA0FCa.cjs.map
272
+ //# sourceMappingURL=config-Xoep-Ipa.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-Xoep-Ipa.cjs","names":["fs","readText","nodeHost","globalPoConfigPath","repositoryConfigFor","mergeConfigLayers","configFromText","withGlobalLayer","globalSettingsCachePath","globalSettingsOwner","globalSettingsOwnerPath","defaultPoConfig","mergeLenientLayers","lenientConfigFromText","composeConfigLayers","layerFromText","absentRepositoryLayer","path","readTextIfExists","configFromText","parseYaml","parsePoConfig","nodeHost","globalPoConfigPath","repositoryConfigFor","globalSettingsCachePath","globalSettingsOwner","globalSettingsOwnerPath","withGlobalLayer","defaultPoConfig","mergeConfigLayers","GLOBAL_SETTINGS_READ_OPERATION","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 globalSettingsOwner,\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 globalSettingsOwner(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 globalSettingsOwner(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 { 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 globalSettingsOwner,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n type ConfigEnvironment,\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 /** Defaults to `process.env`. */\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 ?? process.env,\n };\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 * The host owner's cached global settings sit beneath the host file, portable keys only.\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 = globalSettingsOwner(await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context));\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 the issuer. `ok` replaces it; `shared` (the org has other\n * members, so sessions here may not be the owner's) removes it. Anything else, such as no network\n * or an unreachable issuer, keeps the last copy.\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 answer = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n if (typeof answer !== 'object' || answer === null) return 'kept';\n const { ok, yaml, code, binding } = answer as {\n ok?: unknown;\n yaml?: unknown;\n code?: unknown;\n binding?: import('./core').GlobalSettingsBinding;\n };\n const member = globalSettingsOwner(\n await readText(fs, globalSettingsOwnerPath(options.homeDirectory, options.environment), context),\n );\n if (\n ok === true &&\n typeof yaml === 'string' &&\n member &&\n binding &&\n member.issuer === binding.issuer &&\n member.org === binding.org &&\n member.subject === binding.subject\n ) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ binding, yaml }), context);\n return 'written';\n }\n if (code === 'shared') {\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 return 'kept';\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 isGlobalPoConfigRoot,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment } 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,KAC/B;CACV,MAAM,aAAaC,aAAAA,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiBC,aAAAA,oBAAoB,UAAU,eA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;AAQA,eAAsB,mBACpB,IACA,UACA,SACA,UAA+B,CAAC,GACP;CACzB,MAAM,EAAE,eAAe,gBAAgB,SAAS,OAAO;CACvD,MAAM,aAAaX,aAAAA,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,aAAa,KAAA,IAAY,KAAA,IAAYC,aAAAA,oBAAoB,UAAU,eAAe,WAAW;CACpH,MAAM,aAAa,MAAM,SAAS,IAAI,YAAY,OAAO;CACzD,MAAM,iBAAiB,MAAM,SAAS,IAAI,gBAAgB,OAAO;CACjE,MAAM,cAAcW,aAAAA,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAYC,aAAAA,sBAAsB,IAAID,aAAAA,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAYN,aAAAA,gBAAgB,IAAIV,aAAAA,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAYW,aAAAA,kBAAkBX,aAAAA,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAOkB,aAAAA,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
package/dist/config.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_configPolicy = require("./configPolicy-DT_C-QJF.cjs");
3
- const require_core = require("./core-DuzB4uF3.cjs");
4
- const require_config = require("./config-CpQA0FCa.cjs");
3
+ const require_core = require("./core-CyAtb-Gt.cjs");
4
+ const require_config = require("./config-Xoep-Ipa.cjs");
5
5
  let _agimon_ai_po_core = require("@agimon-ai/po-core");
6
6
  exports.PO_PLANNING_THINKING_LEVELS = require_configPolicy.PO_PLANNING_THINKING_LEVELS;
7
7
  exports.PO_VOICE_ENGINES = require_configPolicy.PO_VOICE_ENGINES;
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
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-C5n1_TYu.mjs";
2
- import { a as globalPoConfigDirectory, h as resolvePlanningPlansDirectory, m as repositoryPoConfigPath, o as globalPoConfigPath, s as globalSettingsCachePath } from "./core-CcPiMlUw.mjs";
3
- import { a as refreshGlobalSettingsCache, c as loadPoConfigLayers, i as readWorkspaceDeclarations, l as loadPoConfigLenient, n as readPoConfigLayers, o as loadPoConfig, r as readPoConfigLenient, s as loadPoConfigAsync, t as readPoConfig } from "./config-Bd8XQgUt.mjs";
2
+ import { _ as resolvePlanningPlansDirectory, a as globalPoConfigDirectory, g as repositoryPoConfigPath, o as globalPoConfigPath, s as globalSettingsCachePath } from "./core-B1oari2a.mjs";
3
+ import { a as refreshGlobalSettingsCache, c as loadPoConfigLayers, i as readWorkspaceDeclarations, l as loadPoConfigLenient, n as readPoConfigLayers, o as loadPoConfig, r as readPoConfigLenient, s as loadPoConfigAsync, t as readPoConfig } from "./config-Djaao8IK.mjs";
4
4
  export { PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, isPortableConfigKey, loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
@@ -24,6 +24,24 @@ function globalPoConfigPath(homeDirectory = nodeHost.homeDirectory(), environmen
24
24
  function globalSettingsCachePath(homeDirectory, environment) {
25
25
  return path.join(globalPoConfigDirectory(homeDirectory, environment), "global-settings.yaml");
26
26
  }
27
+ function globalSettingsOwnerPath(homeDirectory, environment) {
28
+ return path.join(globalPoConfigDirectory(homeDirectory, environment), "web", "hub-trust.json");
29
+ }
30
+ /** ponytail: shared-host per-member settings still need session attribution, deferred in the hierarchy plan. */
31
+ function globalSettingsOwner(text) {
32
+ try {
33
+ const state = JSON.parse(text ?? "null");
34
+ const owner = state?.owner;
35
+ if (!owner || typeof owner.issuer !== "string" || !owner.issuer || typeof owner.subject !== "string" || !owner.subject || typeof state?.ownerNetworkId !== "string" || !state.ownerNetworkId || !state.issuers?.some((pin) => pin.issuer === owner.issuer)) return void 0;
36
+ return {
37
+ issuer: owner.issuer,
38
+ subject: owner.subject,
39
+ org: state.ownerNetworkId
40
+ };
41
+ } catch {
42
+ return;
43
+ }
44
+ }
27
45
  function parsedYaml(text) {
28
46
  try {
29
47
  return {
@@ -34,16 +52,16 @@ function parsedYaml(text) {
34
52
  return { ok: false };
35
53
  }
36
54
  }
37
- /**
38
- * The host file's text with the cached global layer beneath it. A missing or unreadable cache, or a
39
- * host file that does not parse, leaves the host text untouched so its own errors still surface.
40
- */
41
- function withGlobalLayer(cacheText, hostText) {
42
- if (cacheText === void 0) return hostText;
55
+ function withGlobalLayer(cacheText, hostText, binding) {
56
+ if (cacheText === void 0 || !binding) return hostText;
43
57
  const cached = parsedYaml(cacheText);
44
58
  const host = parsedYaml(hostText ?? "");
45
- if (!cached.ok || !host.ok) return hostText;
46
- return JSON.stringify(mergeGlobalConfigLayer(cached.value, host.value));
59
+ if (!cached.ok || !host.ok || !cached.value || typeof cached.value !== "object") return hostText;
60
+ const record = cached.value;
61
+ if (!record.binding || typeof record.yaml !== "string" || !binding.issuer || !binding.org || !binding.subject || record.binding.issuer !== binding.issuer || record.binding.org !== binding.org || record.binding.subject !== binding.subject) return hostText;
62
+ const settings = parsedYaml(record.yaml);
63
+ if (!settings.ok) return hostText;
64
+ return JSON.stringify(mergeGlobalConfigLayer(settings.value, host.value));
47
65
  }
48
66
  function resolvePlanningPlansDirectory(configured, repoRoot, homeDirectory = nodeHost.homeDirectory()) {
49
67
  if (!configured) return path.join(globalPoConfigDirectory(homeDirectory), PLANS_DIR);
@@ -160,6 +178,6 @@ function composeConfigLayers(globalLayer, repositoryLayer, effective) {
160
178
  };
161
179
  }
162
180
  //#endregion
163
- export { globalPoConfigDirectory as a, isGlobalPoConfigRoot as c, mergeConfigLayers as d, mergeLenientLayers as f, withGlobalLayer as g, resolvePlanningPlansDirectory as h, defaultPoConfig as i, layerFromText as l, repositoryPoConfigPath as m, composeConfigLayers as n, globalPoConfigPath as o, repositoryConfigFor as p, configFromText as r, globalSettingsCachePath as s, absentRepositoryLayer as t, lenientConfigFromText as u };
181
+ export { resolvePlanningPlansDirectory as _, globalPoConfigDirectory as a, globalSettingsOwner as c, layerFromText as d, lenientConfigFromText as f, repositoryPoConfigPath as g, repositoryConfigFor as h, defaultPoConfig as i, globalSettingsOwnerPath as l, mergeLenientLayers as m, composeConfigLayers as n, globalPoConfigPath as o, mergeConfigLayers as p, configFromText as r, globalSettingsCachePath as s, absentRepositoryLayer as t, isGlobalPoConfigRoot as u, withGlobalLayer as v };
164
182
 
165
- //# sourceMappingURL=core-CcPiMlUw.mjs.map
183
+ //# sourceMappingURL=core-B1oari2a.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-B1oari2a.mjs","names":["parseYaml"],"sources":["../src/services/config/core.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport path from 'node:path';\n\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\nimport { nodeHost } from '@agimon-ai/po-core/platform';\nimport { parse as parseYaml } from 'yaml';\n\nimport type {\n ConfigDiagnostic,\n ConfigValueOrigin,\n PoConfig,\n PoConfigLayer,\n PoConfigLayers,\n LenientParseResult,\n} from '../../types/config';\nimport {\n configLeafKeys,\n configScopeOf,\n mergeGlobalConfigLayer,\n mergePoConfigs,\n parsePoConfig,\n valueAtKeyPath,\n} from '../configPolicy';\n\n/**\n * Paths and pure parse/merge steps for the two Po config files. The readers\n * in `read.ts` (async, over a FileSystem) and `sync.ts` (Node-only shims) only\n * fetch file text and hand it here, so both produce identical results.\n */\n\nconst PO_DIR = '.po';\nconst CONFIG_FILE = 'config.yaml';\nconst PLANS_DIR = 'plans';\n\nexport type ConfigEnvironment = Readonly<Record<string, string | undefined>>;\n\n/** Runtime callers pass admitted environment; omission retains the legacy host lookup. */\nexport function globalPoConfigDirectory(\n homeDirectory = nodeHost.homeDirectory(),\n environment?: ConfigEnvironment,\n): string {\n return poHomeDirectory(homeDirectory, environment);\n}\n\nexport function globalPoConfigPath(homeDirectory = nodeHost.homeDirectory(), environment?: ConfigEnvironment): string {\n return path.join(globalPoConfigDirectory(homeDirectory, environment), CONFIG_FILE);\n}\n\n/** The host owner's global settings, as the issuer last answered them. Written by the host only. */\nexport function globalSettingsCachePath(homeDirectory: string, environment?: ConfigEnvironment): string {\n return path.join(globalPoConfigDirectory(homeDirectory, environment), 'global-settings.yaml');\n}\n\nexport function globalSettingsOwnerPath(homeDirectory: string, environment?: ConfigEnvironment): string {\n return path.join(globalPoConfigDirectory(homeDirectory, environment), 'web', 'hub-trust.json');\n}\n\n/** ponytail: shared-host per-member settings still need session attribution, deferred in the hierarchy plan. */\nexport function globalSettingsOwner(text: string | undefined): GlobalSettingsBinding | undefined {\n try {\n const state = JSON.parse(text ?? 'null') as {\n owner?: { issuer?: unknown; subject?: unknown };\n ownerNetworkId?: unknown;\n issuers?: { issuer: string }[];\n } | null;\n const owner = state?.owner;\n if (\n !owner ||\n typeof owner.issuer !== 'string' ||\n !owner.issuer ||\n typeof owner.subject !== 'string' ||\n !owner.subject ||\n typeof state?.ownerNetworkId !== 'string' ||\n !state.ownerNetworkId ||\n !state.issuers?.some((pin) => pin.issuer === owner.issuer)\n )\n return undefined;\n return { issuer: owner.issuer, subject: owner.subject, org: state.ownerNetworkId };\n } catch {\n return undefined;\n }\n}\n\nfunction parsedYaml(text: string): { ok: true; value: unknown } | { ok: false } {\n try {\n return { ok: true, value: parseYaml(text) };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * The host file's text with the cached global layer beneath it. A missing or unreadable cache, or a\n * host file that does not parse, leaves the host text untouched so its own errors still surface.\n */\nexport interface GlobalSettingsBinding {\n issuer: string;\n org: string;\n subject: string;\n}\n\nexport function withGlobalLayer(\n cacheText: string | undefined,\n hostText: string | undefined,\n binding?: GlobalSettingsBinding,\n): string | undefined {\n if (cacheText === undefined || !binding) return hostText;\n const cached = parsedYaml(cacheText);\n const host = parsedYaml(hostText ?? '');\n if (!cached.ok || !host.ok || !cached.value || typeof cached.value !== 'object') return hostText;\n const record = cached.value as { binding?: GlobalSettingsBinding; yaml?: unknown };\n if (\n !record.binding ||\n typeof record.yaml !== 'string' ||\n !binding.issuer ||\n !binding.org ||\n !binding.subject ||\n record.binding.issuer !== binding.issuer ||\n record.binding.org !== binding.org ||\n record.binding.subject !== binding.subject\n )\n return hostText;\n const settings = parsedYaml(record.yaml);\n if (!settings.ok) return hostText;\n // JSON is YAML, so the merged document parses like any host file.\n return JSON.stringify(mergeGlobalConfigLayer(settings.value, host.value));\n}\n\nexport function resolvePlanningPlansDirectory(\n configured: string | undefined,\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n): string {\n // Under Po's home, so Po writes nothing into ~/.pi.\n if (!configured) return path.join(globalPoConfigDirectory(homeDirectory), PLANS_DIR);\n if (configured === '~') return homeDirectory;\n if (configured.startsWith('~/')) return path.resolve(homeDirectory, configured.slice(2));\n if (configured.startsWith('~')) {\n throw new Error(\"Po planning plansDirectory supports only '~' or '~/' home aliases\");\n }\n return path.isAbsolute(configured) ? path.normalize(configured) : path.resolve(repoRoot, configured);\n}\n\nexport function repositoryPoConfigPath(repoRoot: string): string {\n return path.join(repoRoot, PO_DIR, CONFIG_FILE);\n}\n\n/**\n * True when a repository's `.po` folder is Po's home itself, as it is for a\n * session rooted at home. That folder is already the global layer; reading it\n * again as the repository layer would apply global-only keys at repository scope.\n */\nexport function isGlobalPoConfigRoot(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment?: ConfigEnvironment,\n): boolean {\n return path.resolve(repoRoot, PO_DIR) === path.resolve(globalPoConfigDirectory(homeDirectory, environment));\n}\n\nexport function repositoryConfigFor(\n repoRoot: string,\n homeDirectory: string,\n environment?: ConfigEnvironment,\n): string | undefined {\n return isGlobalPoConfigRoot(repoRoot, homeDirectory, environment) ? undefined : repositoryPoConfigPath(repoRoot);\n}\n\n/** The config a missing file stands for. */\nexport function defaultPoConfig(): PoConfig {\n return { projectTrust: 'ask' };\n}\n\n/** Parses one file's text strictly; `undefined` text means the file is absent. */\nexport function configFromText(text: string | undefined, filePath: string): PoConfig {\n return text === undefined ? defaultPoConfig() : parsePoConfig(text, filePath);\n}\n\n/** Parses one file's text leniently; `undefined` text means the file is absent. */\nexport function lenientConfigFromText(text: string | undefined, filePath: string): LenientParseResult {\n return text === undefined\n ? { config: defaultPoConfig(), diagnostics: [] }\n : parsePoConfig(text, filePath, { lenient: true });\n}\n\n/** Process-local distribution defaults never grant native authority or modify user files. */\nexport function distributionDefaults(config: PoConfig, environment: ConfigEnvironment): PoConfig {\n if (environment.PO_DISTRIBUTION !== 'desktop') return config;\n return { ...config, computerUse: { ...config.computerUse, enabled: config.computerUse?.enabled ?? true } };\n}\n\n/** Merges the global and repository files, then applies distribution defaults. */\nexport function mergeConfigLayers(\n globalConfig: PoConfig,\n repositoryConfig: PoConfig,\n environment: ConfigEnvironment,\n): PoConfig {\n return distributionDefaults(mergePoConfigs(globalConfig, repositoryConfig), environment);\n}\n\n/** Merges lenient parses; the merge itself stays strict about cross-file scope. */\nexport function mergeLenientLayers(\n globalConfig: LenientParseResult,\n repositoryConfig: LenientParseResult,\n environment: ConfigEnvironment,\n): LenientParseResult {\n const diagnostics: ConfigDiagnostic[] = [...globalConfig.diagnostics, ...repositoryConfig.diagnostics];\n // mergePoConfigs stays strict on purpose: its errors are cross-file scope\n // violations on known keys, which is a different fault from an unknown key.\n return { config: mergeConfigLayers(globalConfig.config, repositoryConfig.config, environment), diagnostics };\n}\n\n/**\n * One config file as a layer: what it is, what it sets, and the bytes it held.\n * A file that does not exist is a layer that sets nothing, which is a normal\n * state rather than an error.\n */\nexport function layerFromText(filePath: string, text: string | undefined): PoConfigLayer {\n if (text === undefined) return { filePath, exists: false, hash: '', keys: [] };\n // The raw document, not the parsed config: this is the one read that has to\n // distinguish a key the file set from a key the parser defaulted.\n const document = (parseYaml(text) ?? {}) as unknown;\n return {\n filePath,\n exists: true,\n hash: createHash('sha256').update(text, 'utf8').digest('hex'),\n keys: configLeafKeys(document),\n };\n}\n\nexport function absentRepositoryLayer(): PoConfigLayer {\n return { filePath: '', exists: false, hash: '', keys: [] };\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * The origin answer respects the merge's own per-field rules rather than simply\n * preferring the repository: `editor` is read from the global side whatever the\n * repository says, and `projectTrust` from the repository side whatever the\n * global one says. Reporting a file as the source of a value the merge discards\n * is the exact confusion this exists to remove.\n */\nexport function composeConfigLayers(\n globalLayer: PoConfigLayer,\n repositoryLayer: PoConfigLayer,\n effective: PoConfig,\n): PoConfigLayers {\n const sets = (layer: PoConfigLayer, keyPath: readonly string[]): boolean => {\n const dotted = keyPath.join('.');\n return layer.keys.some((key) => key === dotted || key.startsWith(`${dotted}.`));\n };\n return {\n globalFile: globalLayer,\n repositoryFile: repositoryLayer,\n effective,\n originOf(keyPath: readonly string[]): ConfigValueOrigin {\n const scope = configScopeOf(keyPath);\n if (scope !== 'host' && sets(repositoryLayer, keyPath)) return 'repository';\n if (scope !== 'repository' && sets(globalLayer, keyPath)) return 'host';\n return 'default';\n },\n valueA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