@agimon-ai/po-config 0.0.0-alpha.205 → 0.0.0-alpha.207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{completion-DJ3d7yvD.d.mts → completion-DIpRWq4w.d.mts} +3 -3
- package/dist/{completion-DJ3d7yvD.d.mts.map → completion-DIpRWq4w.d.mts.map} +1 -1
- package/dist/{config-DflTCMgj.mjs → config--V6YzqD0.mjs} +2 -2
- package/dist/{config-DflTCMgj.mjs.map → config--V6YzqD0.mjs.map} +1 -1
- package/dist/{config-Dz3o2hS-.cjs → config-C2drFdF-.cjs} +2 -2
- package/dist/{config-Dz3o2hS-.cjs.map → config-C2drFdF-.cjs.map} +1 -1
- package/dist/{config-BQdKIq-S.d.mts → config-CiNJtGX1.d.mts} +2 -1
- package/dist/config-CiNJtGX1.d.mts.map +1 -0
- package/dist/config.cjs +2 -2
- package/dist/config.d.mts +4 -4
- package/dist/config.mjs +2 -2
- package/dist/{configWriter-V4SOCh7_.cjs → configWriter-BHyszJvW.cjs} +2 -2
- package/dist/{configWriter-V4SOCh7_.cjs.map → configWriter-BHyszJvW.cjs.map} +1 -1
- package/dist/{configWriter-BY2s7hz-.mjs → configWriter-X7ySHBMS.mjs} +2 -2
- package/dist/{configWriter-BY2s7hz-.mjs.map → configWriter-X7ySHBMS.mjs.map} +1 -1
- package/dist/configWriter.cjs +1 -1
- package/dist/configWriter.mjs +1 -1
- package/dist/{core-C1RuztaG.mjs → core-2Tw_zo7m.mjs} +8 -4
- package/dist/core-2Tw_zo7m.mjs.map +1 -0
- package/dist/{core-C88ExOh9.cjs → core-C1Vhkd5h.cjs} +7 -9
- package/dist/core-C1Vhkd5h.cjs.map +1 -0
- package/dist/{core-CUoIGGGZ.d.mts → core-ShA5KyXD.d.mts} +2 -2
- package/dist/{core-CUoIGGGZ.d.mts.map → core-ShA5KyXD.d.mts.map} +1 -1
- package/dist/{domains-DHUWuQX6.cjs → domains-RqyiIpgN.cjs} +4 -4
- package/dist/{domains-DHUWuQX6.cjs.map → domains-RqyiIpgN.cjs.map} +1 -1
- package/dist/{domains-D1bnUkIp.mjs → domains-nfz6sVO7.mjs} +4 -4
- package/dist/{domains-D1bnUkIp.mjs.map → domains-nfz6sVO7.mjs.map} +1 -1
- package/dist/domains.cjs +3 -3
- package/dist/domains.d.mts +3 -3
- package/dist/domains.mjs +3 -3
- package/dist/extensions/mcp.cjs +11 -3
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts.map +1 -1
- package/dist/extensions/mcp.mjs +11 -3
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/server.cjs +2 -2
- package/dist/extensions/server.mjs +2 -2
- package/dist/harnessState.d.mts +1 -1
- package/dist/harnessStore.d.mts +1 -1
- package/dist/{index-DMMUa1lO.d.mts → index-5AveMup-.d.mts} +2 -2
- package/dist/{index-DMMUa1lO.d.mts.map → index-5AveMup-.d.mts.map} +1 -1
- package/dist/{index-C4zNW4_4.d.mts → index-B36ADk6m.d.mts} +4 -6
- package/dist/index-B36ADk6m.d.mts.map +1 -0
- package/dist/{index-dXlVqofs.d.mts → index-BEyiPft9.d.mts} +3 -3
- package/dist/{index-dXlVqofs.d.mts.map → index-BEyiPft9.d.mts.map} +1 -1
- package/dist/{index-D-P42J9r.d.mts → index-C6e7ZmJa.d.mts} +2 -2
- package/dist/{index-D-P42J9r.d.mts.map → index-C6e7ZmJa.d.mts.map} +1 -1
- package/dist/{index-DuaD-eov.d.mts → index-CQKdOAmg.d.mts} +2 -2
- package/dist/{index-DuaD-eov.d.mts.map → index-CQKdOAmg.d.mts.map} +1 -1
- package/dist/{index-DGY3kPWs.d.mts → index-Hqld7FKO.d.mts} +3 -3
- package/dist/{index-DGY3kPWs.d.mts.map → index-Hqld7FKO.d.mts.map} +1 -1
- package/dist/{index-C4cbZohC.d.mts → index-MV6Yd0PZ.d.mts} +2 -2
- package/dist/{index-C4cbZohC.d.mts.map → index-MV6Yd0PZ.d.mts.map} +1 -1
- package/dist/{index-DlBDrzA1.d.mts → index-_4Wn61ei.d.mts} +3 -3
- package/dist/{index-DlBDrzA1.d.mts.map → index-_4Wn61ei.d.mts.map} +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +10 -10
- package/dist/{init-ch5xHkr2.cjs → init-DcWaVS9o.cjs} +3 -3
- package/dist/{init-ch5xHkr2.cjs.map → init-DcWaVS9o.cjs.map} +1 -1
- package/dist/{init-BtqVDJRO.mjs → init-n-d7Sv7c.mjs} +3 -3
- package/dist/{init-BtqVDJRO.mjs.map → init-n-d7Sv7c.mjs.map} +1 -1
- package/dist/init.cjs +1 -1
- package/dist/init.mjs +1 -1
- package/dist/{layeredConfig-smnKDcns.mjs → layeredConfig-CDayq4zb.mjs} +2 -2
- package/dist/{layeredConfig-smnKDcns.mjs.map → layeredConfig-CDayq4zb.mjs.map} +1 -1
- package/dist/{layeredConfig-oG-Q1La8.cjs → layeredConfig-CuoEC4gS.cjs} +2 -2
- package/dist/{layeredConfig-oG-Q1La8.cjs.map → layeredConfig-CuoEC4gS.cjs.map} +1 -1
- package/dist/layeredConfig.cjs +1 -1
- package/dist/layeredConfig.d.mts +1 -1
- package/dist/layeredConfig.mjs +1 -1
- package/dist/piContext.cjs +1 -1
- package/dist/piContext.d.mts +2 -2
- package/dist/piContext.mjs +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/dist/{presetConfig-C1RXs-gY.cjs → presetConfig-CCelpshN.cjs} +2 -2
- package/dist/{presetConfig-C1RXs-gY.cjs.map → presetConfig-CCelpshN.cjs.map} +1 -1
- package/dist/{presetConfig-WP-DhPXU.mjs → presetConfig-yIK2k35g.mjs} +2 -2
- package/dist/{presetConfig-WP-DhPXU.mjs.map → presetConfig-yIK2k35g.mjs.map} +1 -1
- package/dist/{presets-6qJsr1qz.cjs → presets-49tqXJwu.cjs} +5 -5
- package/dist/{presets-6qJsr1qz.cjs.map → presets-49tqXJwu.cjs.map} +1 -1
- package/dist/{presets-nQct9jak.mjs → presets-BPoAxpDT.mjs} +5 -5
- package/dist/{presets-nQct9jak.mjs.map → presets-BPoAxpDT.mjs.map} +1 -1
- package/dist/presets.cjs +3 -3
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +3 -3
- package/dist/{profiles-CZnp3SPd.mjs → profiles-C9of0cyO.mjs} +3 -8
- package/dist/profiles-C9of0cyO.mjs.map +1 -0
- package/dist/{profiles-D8P9c0Ix.cjs → profiles-DQx7KQV6.cjs} +3 -8
- package/dist/profiles-DQx7KQV6.cjs.map +1 -0
- package/dist/profiles.cjs +3 -5
- package/dist/profiles.cjs.map +1 -1
- package/dist/profiles.d.mts +4 -6
- package/dist/profiles.d.mts.map +1 -1
- package/dist/profiles.mjs +3 -5
- package/dist/profiles.mjs.map +1 -1
- package/dist/selectionSwitch.cjs +2 -2
- package/dist/selectionSwitch.d.mts +3 -3
- package/dist/selectionSwitch.mjs +2 -2
- package/dist/{sessionConfig-CLA1vfx4.mjs → sessionConfig-B1B-poVk.mjs} +2 -2
- package/dist/{sessionConfig-CLA1vfx4.mjs.map → sessionConfig-B1B-poVk.mjs.map} +1 -1
- package/dist/{sessionConfig-VFUiNRmJ.cjs → sessionConfig-DW4w9cu5.cjs} +2 -2
- package/dist/{sessionConfig-VFUiNRmJ.cjs.map → sessionConfig-DW4w9cu5.cjs.map} +1 -1
- package/dist/{settingsApi-CXcC3euQ.cjs → settingsApi-Bc8EnAr_.cjs} +8 -8
- package/dist/{settingsApi-CXcC3euQ.cjs.map → settingsApi-Bc8EnAr_.cjs.map} +1 -1
- package/dist/{settingsApi-DfZFrioP.mjs → settingsApi-CiVhh2fG.mjs} +8 -8
- package/dist/{settingsApi-DfZFrioP.mjs.map → settingsApi-CiVhh2fG.mjs.map} +1 -1
- package/dist/{sync-BTkomlpU.d.mts → sync-Ce3pXZ3Z.d.mts} +2 -2
- package/dist/{sync-BTkomlpU.d.mts.map → sync-Ce3pXZ3Z.d.mts.map} +1 -1
- package/dist/sync.cjs +2 -2
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/types.d.mts +1 -1
- package/package.json +4 -4
- package/dist/config-BQdKIq-S.d.mts.map +0 -1
- package/dist/core-C1RuztaG.mjs.map +0 -1
- package/dist/core-C88ExOh9.cjs.map +0 -1
- package/dist/index-C4zNW4_4.d.mts.map +0 -1
- package/dist/profiles-CZnp3SPd.mjs.map +0 -1
- package/dist/profiles-D8P9c0Ix.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as GitPluginSource, d as PluginEntry, m as PluginSource, n as DomainManifest, u as PluginCatalogEntry } from "./domains-DBNTBmuc.mjs";
|
|
2
|
-
import "./index-
|
|
3
|
-
import { t as readPoConfigSourcesAsync } from "./index-
|
|
2
|
+
import "./index-_4Wn61ei.mjs";
|
|
3
|
+
import { t as readPoConfigSourcesAsync } from "./index-5AveMup-.mjs";
|
|
4
4
|
import { FileSystem } from "@agimon-ai/po-core/platform";
|
|
5
5
|
//#region src/services/pluginCatalog/parse.d.ts
|
|
6
6
|
declare const MARKETPLACE_MANIFEST_RELATIVE_PATHS: readonly ['.agents/plugins/marketplace.json', '.agents/plugins/api_marketplace.json', '.claude-plugin/marketplace.json', '.cursor-plugin/marketplace.json'];
|
|
@@ -101,4 +101,4 @@ declare function domainCompletionItems(domainNames: string[], query: string): Ar
|
|
|
101
101
|
}>;
|
|
102
102
|
//#endregion
|
|
103
103
|
export { isAgentPluginRootManifest as C, marketplaceSnapshotEntries as D, marketplaceInstalledPath as E, marketplaceSnapshotPath as O, MARKETPLACE_MANIFEST_RELATIVE_PATHS as S, marketplaceInstalledEntries as T, defaultDomainsForPreset as _, loadDomainsAsync as a, findPluginManifestPathAsync as b, resolvePluginEntriesAsync as c, loadDomains as d, resolvePluginDirectories as f, PO_DOMAINS_ENV as g, DEFAULT_DOMAIN as h, listDomainNamesAsync as i, pluginDirectoryForSource as k, resolveSharedSkillsAsync as l, resolveSharedSkills as m, domainCompletionPrefix as n, resolveManifestPluginEntriesAsync as o, resolvePluginEntries as p, expandDomainNames as r, resolvePluginDirectoriesAsync as s, domainCompletionItems as t, listDomainNames as u, domainNamesOf as v, isRemotePluginSource as w, findPluginManifestPath as x, sharedSkillsFor as y };
|
|
104
|
-
//# sourceMappingURL=completion-
|
|
104
|
+
//# sourceMappingURL=completion-DIpRWq4w.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion-
|
|
1
|
+
{"version":3,"file":"completion-DIpRWq4w.d.mts","names":[],"sources":["../src/services/pluginCatalog/parse.ts","../src/services/pluginCatalog/sync.ts","../src/services/pluginCatalog/index.ts","../src/services/domains/core.ts","../src/services/domains/sync.ts","../src/services/domains/index.ts","../src/services/domains/completion.ts"],"mappings":";;;;;cAmBa;;iBAuOG,0BAA0B;iBA2I1B,yBAAyB,QAAQ,cAAc;;iBAiB/C,wBACd,uBACA,aAAa,SAAS,qCACtB;;iBAQc,2BAA2B,cAAc,iBAAiB,eAAe;iBAwCzE,qBACd,QAAQ,eACP,UAAU,kBAAkB,QAAQ;EAAgB;;;iBAKvC,yBACd,uBACA,aAAa,SAAS,qCACtB,gBACA;;iBAac,4BAA4B,cAAc,iBAAiB,eAAe;;;;;;;iBChb1E,uBAAuB;;;KCtBlC,UAAU,WAAW;;iBA8DJ,4BACpB,IAAI,YACJ,oBACA,SAAS,UACR;;;iBCoGa,cAAc,UAAU;;;;;;;iBAUxB,gBAAgB,UAAU,gBAAgB;cA8F7C;cACA;;;;;;;;iBAiBG,wBACd,gBACA,aAAa,OAAO,YACpB;;;;;;;;iBCvSc,YAAY,kBAAkB,yBAAmD;;iBAMjF,gBAAgB,kBAAkB;;iBAKlC,oBAAoB,kBAAkB,uBAAuB;;iBAK7D,qBACd,kBACA,uBACA,+BACA,yBACC;;iBAkBa,yBACd,kBACA,uBACA,+BACA;;;KCnDG,YAAY,WAAW;;;;;;;;iBAkCN,iBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;iBAqBW,qBACpB,IAAI,YACJ,kBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;;;;;;iBAUmB,yBACpB,IAAI,YACJ,kBACA,uBACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B;;iBAKmB,0BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,wBACA,cAAc,kBAAkB,+BAC/B,QAAQ;;iBAMW,kCACpB,IAAI,YACJ,UAAU,gBACV,uBACA,+BACA,SAAS,WACT,wBACC,QAAQ;iBAgBW,8BACpB,IAAI,YACJ,kBACA,uBACA,+BACA,SAAS,WACT,yBACC;;;;iBC/Ia,kBAAkB,UAAU,gBAAgB;iBAW5C,uBAAuB;iBAKvB,sBAAsB,uBAAuB,gBAAgB;EAAQ;EAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as parsePoConfig, C as withGlobalLayer, S as sameGlobalSettingsBinding, _ as mergeConfigLayers, a as defaultPoConfig, c as globalSettingsCachePath, f as globalSettingsRecords, g as lenientConfigFromText, h as layerFromText, i as configFromText, l as globalSettingsMember, m as isGlobalSettingsBinding, n as absentRepositoryLayer, r as composeConfigLayers, s as globalPoConfigPath, u as globalSettingsOwnerPath, v as mergeLenientLayers, y as repositoryConfigFor } from "./core-2Tw_zo7m.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { nodeHost, readTextIfExists, writeFileAtomic } from "@agimon-ai/po-core/platform";
|
|
4
4
|
import fs from "node:fs";
|
|
@@ -226,4 +226,4 @@ async function readPoConfigLayers(fs, repoRoot, context, options = {}) {
|
|
|
226
226
|
//#endregion
|
|
227
227
|
export { readWorkspaceDeclarations as a, loadPoConfigAsync as c, readPoConfigLenient as i, loadPoConfigLayers as l, readPoConfig as n, refreshGlobalSettingsCache as o, readPoConfigLayers as r, loadPoConfig as s, readHostMarketplaceOrigin as t, loadPoConfigLenient as u };
|
|
228
228
|
|
|
229
|
-
//# sourceMappingURL=config
|
|
229
|
+
//# sourceMappingURL=config--V6YzqD0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-DflTCMgj.mjs","names":["readText","parseYaml"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAO,GAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;AAEA,eAAeA,WAAS,UAA+C;CACrE,IAAI;EACF,OAAO,MAAM,GAAG,SAAS,SAAS,UAAU,MAAM;CACpD,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;;AAGA,SAAgB,aACd,UACA,gBAAgB,SAAS,cAAc,GACvC,cAAiC,QAAQ,KAC/B;CACV,MAAM,aAAa,mBAAmB,eAAe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,IAAY,KAAA,IAAY,oBAAoB,UAAU,eAAe,WAAW;CACpH,MAAM,aAAa,MAAM,SAAS,IAAI,YAAY,OAAO;CACzD,MAAM,iBAAiB,MAAM,SAAS,IAAI,gBAAgB,OAAO;CACjE,MAAM,cAAc,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAY,sBAAsB,IAAI,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAY,gBAAgB,IAAI,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAY,kBAAkB,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAO,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
|
|
1
|
+
{"version":3,"file":"config--V6YzqD0.mjs","names":["readText","parseYaml"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAO,GAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU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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,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
2
|
-
const require_core = require("./core-
|
|
2
|
+
const require_core = require("./core-C1Vhkd5h.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
5
|
let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
|
|
@@ -288,4 +288,4 @@ Object.defineProperty(exports, "refreshGlobalSettingsCache", {
|
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
-
//# sourceMappingURL=config-
|
|
291
|
+
//# sourceMappingURL=config-C2drFdF-.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-Dz3o2hS-.cjs","names":["fs","readText","nodeHost","globalPoConfigPath","repositoryConfigFor","mergeConfigLayers","configFromText","withGlobalLayer","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","defaultPoConfig","mergeLenientLayers","lenientConfigFromText","composeConfigLayers","layerFromText","absentRepositoryLayer","path","readTextIfExists","configFromText","parseYaml","parsePoConfig","nodeHost","globalPoConfigPath","marketplaceOrigin","repositoryConfigFor","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","withGlobalLayer","defaultPoConfig","mergeConfigLayers","GLOBAL_SETTINGS_READ_OPERATION","globalSettingsRecords","isGlobalSettingsBinding","sameGlobalSettingsBinding","writeFileAtomic","lenientConfigFromText","mergeLenientLayers","layerFromText","absentRepositoryLayer","composeConfigLayers"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAOA,QAAAA,QAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MA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AAM,cAAcc,aAAAA,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAYC,aAAAA,sBAAsB,IAAID,aAAAA,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAYT,aAAAA,gBAAgB,IAAIX,aAAAA,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAYY,aAAAA,kBAAkBZ,aAAAA,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAOsB,aAAAA,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
|
|
1
|
+
{"version":3,"file":"config-C2drFdF-.cjs","names":["fs","readText","nodeHost","globalPoConfigPath","repositoryConfigFor","mergeConfigLayers","configFromText","withGlobalLayer","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","defaultPoConfig","mergeLenientLayers","lenientConfigFromText","composeConfigLayers","layerFromText","absentRepositoryLayer","path","readTextIfExists","configFromText","parseYaml","parsePoConfig","nodeHost","globalPoConfigPath","marketplaceOrigin","repositoryConfigFor","globalSettingsCachePath","globalSettingsMember","globalSettingsOwnerPath","withGlobalLayer","defaultPoConfig","mergeConfigLayers","GLOBAL_SETTINGS_READ_OPERATION","globalSettingsRecords","isGlobalSettingsBinding","sameGlobalSettingsBinding","writeFileAtomic","lenientConfigFromText","mergeLenientLayers","layerFromText","absentRepositoryLayer","composeConfigLayers"],"sources":["../src/services/config/sync.ts","../src/services/config/index.ts"],"sourcesContent":["// sync: readTextSync supports exported Node-only synchronous config readers retained for phase 2.\nimport fs from 'node:fs';\n\nimport { nodeHost } from '@agimon-ai/po-core/platform';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult } from '../../types/config';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n withGlobalLayer,\n} from './core';\n\nfunction readTextSync(filePath: string | undefined): string | undefined {\n if (filePath === undefined) return undefined;\n try {\n return fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\nasync function readText(filePath: string): Promise<string | undefined> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. Applies the global layer as readPoConfig does. */\nexport function loadPoConfig(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfig {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeConfigLayers(\n configFromText(\n withGlobalLayer(\n readTextSync(globalSettingsCachePath(homeDirectory, environment)),\n readTextSync(globalPath),\n globalSettingsMember(environment, readTextSync(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n ),\n repositoryPath === undefined ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath),\n environment,\n );\n}\n\n/**\n * Loads the merged config, tolerating unknown keys in either file.\n *\n * Only `po sync` uses this. Everything that runs during a session keeps\n * `loadPoConfig`, because a key a running extension cannot understand is\n * better reported than silently ignored; a build that refuses to start over\n * the same key is not.\n *\n * @deprecated Node-only sync shim; use readPoConfigLenient. Removed in M2.\n */\nexport function loadPoConfigLenient(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): LenientParseResult {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n return mergeLenientLayers(\n lenientConfigFromText(readTextSync(globalPath), globalPath),\n lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? ''),\n environment,\n );\n}\n\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nexport async function loadPoConfigAsync(\n repoRoot: string,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<PoConfig> {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = configFromText(\n withGlobalLayer(\n await readText(globalSettingsCachePath(homeDirectory, environment)),\n await readText(globalPath),\n globalSettingsMember(environment, await readText(globalSettingsOwnerPath(homeDirectory, environment))),\n ),\n globalPath,\n );\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(await readText(repositoryPath), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nexport function loadPoConfigLayers(\n repoRoot: string | undefined,\n homeDirectory = nodeHost.homeDirectory(),\n environment: NodeJS.ProcessEnv = process.env,\n): PoConfigLayers {\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = readTextSync(globalPath);\n const repositoryText = readTextSync(repositoryPath);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n return composeConfigLayers(\n layerFromText(globalPath, globalText),\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText),\n mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment),\n );\n}\n","import path from 'node:path';\n\nimport { GLOBAL_SETTINGS_READ_OPERATION } from '@agimon-ai/po-core';\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\nimport { marketplaceOrigin } from '@agimon-ai/po-core/verifiedArchive';\nimport { parse as parseYaml } from 'yaml';\n\nimport type { PoConfig, PoConfigLayers, LenientParseResult, WorkspaceDeclaration } from '../../types/config';\nimport { parsePoConfig } from '../configPolicy';\nimport {\n absentRepositoryLayer,\n composeConfigLayers,\n configFromText,\n defaultPoConfig,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsMember,\n isGlobalSettingsBinding,\n globalSettingsOwnerPath,\n layerFromText,\n lenientConfigFromText,\n mergeConfigLayers,\n mergeLenientLayers,\n repositoryConfigFor,\n sameGlobalSettingsBinding,\n globalSettingsRecords,\n withGlobalLayer,\n type ConfigEnvironment,\n type GlobalSettingsRecord,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\nexport interface ReadWorkspaceDeclarationsOptions {\n fs: FileSystem;\n repositoryRoot: string;\n context: IoContext;\n}\n\nexport interface WorkspaceDeclarationsResult {\n declarations: WorkspaceDeclaration[];\n source: 'workspaces.yaml' | 'config.yaml' | undefined;\n notices: string[];\n}\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' &&\n value !== null &&\n (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n\nfunction jsonValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object' || (!Array.isArray(value) && !object(value)) || seen.has(value)) return false;\n seen.add(value);\n const valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nexport async function readWorkspaceDeclarations({\n fs,\n repositoryRoot,\n context,\n}: ReadWorkspaceDeclarationsOptions): Promise<WorkspaceDeclarationsResult> {\n const filePath = path.join(repositoryRoot, '.po', 'workspaces.yaml');\n const text = await readTextIfExists(fs, filePath, context);\n if (text === undefined) {\n const legacyPath = path.join(repositoryRoot, '.po', 'config.yaml');\n const legacy = await readTextIfExists(fs, legacyPath, context);\n const declarations = legacy === undefined ? undefined : configFromText(legacy, legacyPath).workspaces;\n return {\n declarations: declarations ?? [],\n source: declarations === undefined ? undefined : 'config.yaml',\n notices:\n declarations === undefined\n ? []\n : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`],\n };\n }\n let document: unknown;\n try {\n document = parseYaml(text);\n } catch (error) {\n throw new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n }\n if (\n !object(document) ||\n Object.keys(document).some((key) => key !== 'workspaces') ||\n !Array.isArray(document.workspaces)\n )\n throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n const aliases = new Set<string>();\n const declarations = document.workspaces.map((entry: unknown, index): WorkspaceDeclaration => {\n const location = `workspaces[${String(index)}]`;\n if (\n !object(entry) ||\n Object.keys(entry).some((key) => !['name', 'path', 'alias', 'instructions', 'metadata'].includes(key))\n )\n throw new Error(\n `Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`,\n );\n // Reuse the established declaration name/instructions parser, without changing the legacy config contract.\n const base = parsePoConfig(\n JSON.stringify({ workspaces: [{ name: entry.name, instructions: entry.instructions }] }),\n filePath,\n ).workspaces![0]!;\n if (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes('..'))\n throw new Error(\n `Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`,\n );\n if (\n entry.path !== undefined &&\n (typeof entry.path !== 'string' || entry.path.trim() === '' || entry.path.includes('\\0'))\n )\n throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n if (entry.alias !== undefined && (typeof entry.alias !== 'string' || entry.alias.trim() === ''))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n const alias = typeof entry.alias === 'string' ? entry.alias.trim() : undefined;\n if (alias !== undefined) {\n if (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n aliases.add(alias);\n }\n if (entry.metadata !== undefined && (!object(entry.metadata) || !jsonValue(entry.metadata)))\n throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n return {\n ...base,\n ...(entry.path === undefined ? {} : { path: entry.path as string }),\n ...(alias === undefined ? {} : { alias }),\n ...(entry.metadata === undefined ? {} : { metadata: entry.metadata as Record<string, unknown> }),\n };\n });\n // Retain the legacy parser's case-insensitive duplicate-name rule across the entire document.\n parsePoConfig(\n JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({ name, instructions })) }),\n filePath,\n );\n return { declarations, source: 'workspaces.yaml', notices: [] };\n}\n\nexport interface ReadPoConfigOptions {\n /** Defaults to the host's home directory. */\n readonly homeDirectory?: string;\n /** Admitted environment for locating Po home and member overrides. Defaults to empty. */\n readonly environment?: ConfigEnvironment;\n}\n\nfunction resolved(options: ReadPoConfigOptions): { homeDirectory: string; environment: ConfigEnvironment } {\n return {\n homeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n environment: options.environment ?? {},\n };\n}\n\n/** Reads only the machine owner's config, never repository or org-member preferences. */\nexport async function readHostMarketplaceOrigin(\n fs: FileSystem,\n homeDirectory: string,\n environment: ConfigEnvironment,\n context: IoContext,\n): Promise<string> {\n const file = globalPoConfigPath(homeDirectory, environment);\n const config = configFromText(await readTextIfExists(fs, file, context), file);\n return marketplaceOrigin(config.marketplace?.url);\n}\n\nconst readText = (fs: FileSystem, filePath: string | undefined, context: IoContext) =>\n filePath === undefined ? Promise.resolve(undefined) : readTextIfExists(fs, filePath, context);\n\n/**\n * Loads the merged global and repository config over a FileSystem. A missing\n * file contributes the defaults, so a host with neither file, such as a fresh\n * Durable Object filesystem, reads the same config as an empty Node home.\n * One person's cached global settings sit beneath the host file, portable keys only: the session starter's\n * when the environment names one, else the host owner's.\n */\nexport async function readPoConfig(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfig> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const hostText = await readText(fs, globalPath, context);\n const cacheText = await readText(fs, globalSettingsCachePath(homeDirectory, environment), context);\n const member = globalSettingsMember(\n environment,\n await readText(fs, globalSettingsOwnerPath(homeDirectory, environment), context),\n );\n const globalConfig = configFromText(withGlobalLayer(cacheText, hostText, member), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? defaultPoConfig()\n : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * Refreshes the global settings cache from what the host's federation answers: one entry for each person\n * whose grant it holds. `ok` replaces that person's copy and `removed` (they left the team, or took the\n * grant back) drops it, as does having no entry at all. Any other refusal keeps their last copy, and no\n * answer, such as no network, keeps the whole cache.\n */\nexport async function refreshGlobalSettingsCache(\n fs: FileSystem,\n accountCall: (operation: string, input: unknown) => Promise<unknown>,\n context: IoContext,\n options: Required<ReadPoConfigOptions>,\n): Promise<'written' | 'removed' | 'kept'> {\n const answers = await accountCall(GLOBAL_SETTINGS_READ_OPERATION, {}).catch(() => undefined);\n if (!Array.isArray(answers)) return 'kept';\n const cachePath = globalSettingsCachePath(options.homeDirectory, options.environment);\n const before = globalSettingsRecords(await readText(fs, cachePath, context));\n const after: GlobalSettingsRecord[] = [];\n for (const answer of answers as ({ ok?: unknown; yaml?: unknown; code?: unknown; binding?: unknown } | null)[]) {\n const binding = answer?.binding;\n // An answer that names nobody is about nobody, so it is never written.\n if (!answer || !isGlobalSettingsBinding(binding)) continue;\n const last = before.find((record) => sameGlobalSettingsBinding(record.binding, binding));\n if (answer.ok === true && typeof answer.yaml === 'string') after.push({ binding, yaml: answer.yaml });\n else if (answer.code !== 'removed' && last) after.push(last);\n }\n if (JSON.stringify(after) === JSON.stringify(before)) return 'kept';\n if (after.length) {\n await writeFileAtomic(fs, cachePath, JSON.stringify({ members: after }), context);\n return 'written';\n }\n const removed = await fs.remove(cachePath, { force: true }, context);\n if (!removed.ok) throw new Error(`Could not remove ${cachePath}`, { cause: removed.error });\n return 'removed';\n}\n\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nexport async function readPoConfigLenient(\n fs: FileSystem,\n repoRoot: string,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<LenientParseResult> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n const repositoryConfig =\n repositoryPath === undefined\n ? lenientConfigFromText(undefined, '')\n : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n return mergeLenientLayers(globalConfig, repositoryConfig, environment);\n}\n\n/**\n * The two config files kept apart, with the merge alongside them.\n *\n * `repoRoot` is optional because the global file is complete on its own: a\n * settings surface with no repository in view still has settings to show.\n */\nexport async function readPoConfigLayers(\n fs: FileSystem,\n repoRoot: string | undefined,\n context: IoContext,\n options: ReadPoConfigOptions = {},\n): Promise<PoConfigLayers> {\n const { homeDirectory, environment } = resolved(options);\n const globalPath = globalPoConfigPath(homeDirectory, environment);\n const repositoryPath = repoRoot === undefined ? undefined : repositoryConfigFor(repoRoot, homeDirectory, environment);\n const globalText = await readText(fs, globalPath, context);\n const repositoryText = await readText(fs, repositoryPath, context);\n const globalLayer = layerFromText(globalPath, globalText);\n const repositoryLayer =\n repositoryPath === undefined ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n const repositoryConfig =\n repositoryPath === undefined ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n const effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n return composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n\nexport {\n globalPoConfigDirectory,\n globalPoConfigPath,\n globalSettingsCachePath,\n globalSettingsPeople,\n isGlobalPoConfigRoot,\n SESSION_MEMBER_ENVIRONMENT,\n repositoryPoConfigPath,\n resolvePlanningPlansDirectory,\n} from './core';\nexport type { ConfigEnvironment, GlobalSettingsPerson } from './core';\nexport { loadPoConfig, loadPoConfigAsync, loadPoConfigLayers, loadPoConfigLenient } from './sync';\n"],"mappings":";;;;;;;;;;;AAuBA,SAAS,aAAa,UAAkD;CACtE,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,IAAI;EACF,OAAOA,QAAAA,QAAG,aAAa,UAAU,MAAM;CACzC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;AAEA,eAAeC,WAAS,UAA+C;CACrE,IAAI;EACF,OAAO,MAAMD,QAAAA,QAAG,SAAS,SAAS,UAAU,MAAM;CACpD,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,OAAO,KAAA;EAC/D,MAAM;CACR;AACF;;AAGA,SAAgB,aACd,UACA,gBAAgBE,4BAAAA,SAAS,cAAc,GACvC,cAAiC,QAAQ,KAC/B;CACV,MAAM,aAAaC,aAAAA,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiBC,aAAAA,oBAAoB,UAAU,eAAe,WAAW;CAC/E,OAAOC,aAAAA,kBACLC,aAAAA,eACEC,aAAAA,gBACE,aAAaC,aAAAA,wBAAwB,eAAe,WAAW,CAAC,GAChE,aAAa,UAAU,GACvBC,aAAAA,qBAAqB,aAAa,aAAaC,aAAAA,wBAAwB,eAAe,WAAW,CAAC,CAAC,CACrG,GACA,UACF,GACA,mBAAmB,KAAA,IAAYC,aAAAA,gBAAgB,IAAIL,aAAAA,eAAe,aAAa,cAAc,GAAG,cAAc,GAC9G,WACF;AACF;;;;;;;;;;;AAYA,SAAgB,oBACd,UACA,gBAAgBJ,4BAAAA,SAAS,cAAc,GACvC,cAAiC,QAAQ,KACrB;CACpB,MAAM,aAAaC,aAAAA,mBAAmB,eAAe,WAAW;CAChE,M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AAkB,WAAW;AACvE;;;;;;;AAQA,eAAsB,mBACpB,IACA,UACA,SACA,UAA+B,CAAC,GACP;CACzB,MAAM,EAAE,eAAe,gBAAgB,SAAS,OAAO;CACvD,MAAM,aAAaf,aAAAA,mBAAmB,eAAe,WAAW;CAChE,MAAM,iBAAiB,aAAa,KAAA,IAAY,KAAA,IAAYE,aAAAA,oBAAoB,UAAU,eAAe,WAAW;CACpH,MAAM,aAAa,MAAM,SAAS,IAAI,YAAY,OAAO;CACzD,MAAM,iBAAiB,MAAM,SAAS,IAAI,gBAAgB,OAAO;CACjE,MAAM,cAAcc,aAAAA,cAAc,YAAY,UAAU;CACxD,MAAM,kBACJ,mBAAmB,KAAA,IAAYC,aAAAA,sBAAsB,IAAID,aAAAA,cAAc,gBAAgB,cAAc;CACvG,MAAM,mBACJ,mBAAmB,KAAA,IAAYT,aAAAA,gBAAgB,IAAIX,aAAAA,eAAe,gBAAgB,cAAc;CAClG,MAAM,YAAYY,aAAAA,kBAAkBZ,aAAAA,eAAe,YAAY,UAAU,GAAG,kBAAkB,WAAW;CACzG,OAAOsB,aAAAA,oBAAoB,aAAa,iBAAiB,SAAS;AACpE"}
|
|
@@ -91,6 +91,7 @@ interface AutocompactOverrideConfig {
|
|
|
91
91
|
tokens: AutocompactTokenConfig;
|
|
92
92
|
}
|
|
93
93
|
interface AutocompactModeConfig {
|
|
94
|
+
botIdleMinutes?: number;
|
|
94
95
|
enabled?: boolean;
|
|
95
96
|
model?: string;
|
|
96
97
|
thinking?: PlanningThinkingLevel;
|
|
@@ -483,4 +484,4 @@ interface LenientParseResult {
|
|
|
483
484
|
}
|
|
484
485
|
//#endregion
|
|
485
486
|
export { PoHarnessContext as A, VoiceModelConfig as B, PoConfigLayer as C, PoConfigTransitionPhase as D, PoConfigSelection as E, VoiceAdapterConfig as F, PersonaFrontMatter as G, VoiceTtsEngine as H, VoiceAutoCaptureConfig as I, PersonaIdentity as K, VoiceConfig as L, ProjectTrust as M, ResolvedVoiceAutoCaptureConfig as N, PoConfigTransitionRecord as O, ResolvedVoiceConfig as P, VoiceEngine as R, PoConfigContext as S, PoConfigPendingSelection as T, WorkspaceDeclaration as U, VoiceTtsConfig as V, PersonaDocument as W, PlanningAgentConfig as _, ConfigDiagnostic as a, PlanningThinkingLevel as b, DesktopEnvironmentConfig as c, IPoConfigLoader as d, IPoConfigService$1 as f, PackageAttribution$1 as g, PO_CONFIG_SERVICE as h, AutocompactTokenConfig as i, PoSelectionConfig as j, PoConfigTransitionStrategy as k, EditorConfig as l, LenientParseResult as m, AutocompactOverrideConfig as n, ConfigValueOrigin as o, LenientParseOptions as p, PersonaVoiceOverride as q, AutocompactThresholdConfig as r, DeepReadonly as s, AutocompactModeConfig as t, HarnessState as u, PlanningModeConfig as v, PoConfigLayers as w, PoConfig as x, PlanningModeDefinition as y, VoiceMode as z };
|
|
486
|
-
//# sourceMappingURL=config-
|
|
487
|
+
//# sourceMappingURL=config-CiNJtGX1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CiNJtGX1.d.mts","names":["IPoConfigService","PoConfigServiceContract"],"sources":["../src/types/profiles.ts","../src/types/config.ts"],"mappings":";;;;UAAiB;EACf;EACA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf;;EAEA;;EAEA;;EAEA,QAAQ;;UAGO;EACf,cAAc;;EAEd;;;;KCvBU;KACA;KACA;KACA;KACA;UAEK;EACf;EACA,WAAW;;;UAGI;EACf;EACA;EACA;;UAEe;EACf,OAAO;EACP,YAAY;EACZ;;EAEA,QAAQ,eAAe;;;;;;;;;UASR;EACf;EACA;EACA;;;;;;;;;UASe;EACf;EACA;EACA;;;;;;;;;UASe;EACf;EACA,QAAQ;;UAEO;EACf;EACA;EACA;EACA,WAAW;EACX,aAAa;EACb,YAAY;;;UAGG;EACf;;;;;;UAMe;;EAEf;;UAEe;;EAEf;;UAEe;EACf;;;;;IAKE;;;UAGa;;;;;EAKf;;EAEA;;E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;EACA;EACA;;EAEA;;;;;;;;;;;EAWA,qBAAqB,eAAe;;EAEpC;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA;EACA;;EAEA,gBAAgB;EAChB;EACA;;;;;;EAMA,kBAAkB;;EAElB,eAAe;EACf;EACA;EACA;;KAGU,aAAa,UAAU,oBAAmB,6BAClD,SACA,+BAA+B,oBACpB,aAAa,WACtB,oCACc,cAAc,SAAS,aAAa,OAAO,YACvD;KAEI,mBAAmB,aAAa;UAE3B;WACN,UAAU,aAAa;WACvB,SAAS;;WAET,mBAAmB,aAAa;;WAEhC;;;UAIM;EACf,KAAK,kBAAkB,yBAAyB;;;UAIjCA,2BAAyBC,iBAAwB,iBAAiB;;YAGvE;IACR,aAAaD;;;;KAQL;;UAGK;EACf;EACA;;;;;;EAMA;;EAEA;;;;;;;;;;UAWe;;EAEf,YAAY;EACZ,gBAAgB;EAChB,WAAW;;EAEX,SAAS,6BAA6B;;EAEtC,QAAQ;;;;;;;;;UAUO;EACf;;EAEA;EACA;;;UAIe;EACf;;;UAIe;EACf,QAAQ;EACR,aAAa"}
|
package/dist/config.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_core = require("./core-
|
|
3
|
-
const require_config = require("./config-
|
|
2
|
+
const require_core = require("./core-C1Vhkd5h.cjs");
|
|
3
|
+
const require_config = require("./config-C2drFdF-.cjs");
|
|
4
4
|
let _agimon_ai_po_core = require("@agimon-ai/po-core");
|
|
5
5
|
exports.PO_PLANNING_MODE_LIMITS = require_core.PO_PLANNING_MODE_LIMITS;
|
|
6
6
|
exports.PO_PLANNING_THINKING_LEVELS = require_core.PO_PLANNING_THINKING_LEVELS;
|
package/dist/config.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as PoConfigLayer, a as ConfigDiagnostic, m as LenientParseResult, o as ConfigValueOrigin, p as LenientParseOptions, w as PoConfigLayers } from "./config-
|
|
2
|
-
import { a as globalPoConfigPath, c as repositoryPoConfigPath, i as globalPoConfigDirectory, l as resolvePlanningPlansDirectory, n as GlobalSettingsPerson, o as globalSettingsCachePath, r as SESSION_MEMBER_ENVIRONMENT, s as globalSettingsPeople } from "./core-
|
|
3
|
-
import { a as readPoConfig, c as readWorkspaceDeclarations, i as readHostMarketplaceOrigin, l as refreshGlobalSettingsCache, n as ReadWorkspaceDeclarationsOptions, o as readPoConfigLayers, r as WorkspaceDeclarationsResult, s as readPoConfigLenient, t as ReadPoConfigOptions } from "./index-
|
|
4
|
-
import { _ as parsePlanningModeConfig, a as PO_VOICE_LIVE_VOICES, b as valueAtKeyPath, c as configLeafKeys, d as isPortableConfigKey, f as mergeGlobalConfigLayer, g as parseAutocompactModeConfig, h as nonPortableConfigText, i as PO_VOICE_ENGINES, l as configRootKeys, m as nonPortableConfigKeys, n as PO_PLANNING_MODE_LIMITS, o as PO_VOICE_MODES, p as mergePoConfigs, r as PO_PLANNING_THINKING_LEVELS, s as PO_VOICE_TTS_ENGINES, t as ConfigKeyScope, u as configScopeOf, v as parsePoConfig, y as resolveVoiceConfig } from "./index-
|
|
1
|
+
import { C as PoConfigLayer, a as ConfigDiagnostic, m as LenientParseResult, o as ConfigValueOrigin, p as LenientParseOptions, w as PoConfigLayers } from "./config-CiNJtGX1.mjs";
|
|
2
|
+
import { a as globalPoConfigPath, c as repositoryPoConfigPath, i as globalPoConfigDirectory, l as resolvePlanningPlansDirectory, n as GlobalSettingsPerson, o as globalSettingsCachePath, r as SESSION_MEMBER_ENVIRONMENT, s as globalSettingsPeople } from "./core-ShA5KyXD.mjs";
|
|
3
|
+
import { a as readPoConfig, c as readWorkspaceDeclarations, i as readHostMarketplaceOrigin, l as refreshGlobalSettingsCache, n as ReadWorkspaceDeclarationsOptions, o as readPoConfigLayers, r as WorkspaceDeclarationsResult, s as readPoConfigLenient, t as ReadPoConfigOptions } from "./index-_4Wn61ei.mjs";
|
|
4
|
+
import { _ as parsePlanningModeConfig, a as PO_VOICE_LIVE_VOICES, b as valueAtKeyPath, c as configLeafKeys, d as isPortableConfigKey, f as mergeGlobalConfigLayer, g as parseAutocompactModeConfig, h as nonPortableConfigText, i as PO_VOICE_ENGINES, l as configRootKeys, m as nonPortableConfigKeys, n as PO_PLANNING_MODE_LIMITS, o as PO_VOICE_MODES, p as mergePoConfigs, r as PO_PLANNING_THINKING_LEVELS, s as PO_VOICE_TTS_ENGINES, t as ConfigKeyScope, u as configScopeOf, v as parsePoConfig, y as resolveVoiceConfig } from "./index-C6e7ZmJa.mjs";
|
|
5
5
|
export { type ConfigDiagnostic, type ConfigKeyScope, type ConfigValueOrigin, type GlobalSettingsPerson, type LenientParseOptions, type LenientParseResult, PO_PLANNING_MODE_LIMITS, PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, type PoConfigLayer, type PoConfigLayers, type ReadPoConfigOptions, type ReadWorkspaceDeclarationsOptions, SESSION_MEMBER_ENVIRONMENT, type WorkspaceDeclarationsResult, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
|
package/dist/config.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as readWorkspaceDeclarations, i as readPoConfigLenient, n as readPoConfig, o as refreshGlobalSettingsCache, r as readPoConfigLayers, t as readHostMarketplaceOrigin } from "./config
|
|
1
|
+
import { A as configLeafKeys, B as parsePoConfig, D as PO_VOICE_LIVE_VOICES, E as PO_VOICE_ENGINES, F as mergePoConfigs, H as valueAtKeyPath, I as nonPortableConfigKeys, L as nonPortableConfigText, M as configScopeOf, N as isPortableConfigKey, O as PO_VOICE_MODES, P as mergeGlobalConfigLayer, R as parseAutocompactModeConfig, T as PO_PLANNING_THINKING_LEVELS, V as resolveVoiceConfig, b as repositoryPoConfigPath, c as globalSettingsCachePath, d as globalSettingsPeople, j as configRootKeys, k as PO_VOICE_TTS_ENGINES, o as globalPoConfigDirectory, s as globalPoConfigPath, t as SESSION_MEMBER_ENVIRONMENT, w as PO_PLANNING_MODE_LIMITS, x as resolvePlanningPlansDirectory, z as parsePlanningModeConfig } from "./core-2Tw_zo7m.mjs";
|
|
2
|
+
import { a as readWorkspaceDeclarations, i as readPoConfigLenient, n as readPoConfig, o as refreshGlobalSettingsCache, r as readPoConfigLayers, t as readHostMarketplaceOrigin } from "./config--V6YzqD0.mjs";
|
|
3
3
|
export { PO_PLANNING_MODE_LIMITS, PO_PLANNING_THINKING_LEVELS, PO_VOICE_ENGINES, PO_VOICE_LIVE_VOICES, PO_VOICE_MODES, PO_VOICE_TTS_ENGINES, SESSION_MEMBER_ENVIRONMENT, configLeafKeys, configRootKeys, configScopeOf, globalPoConfigDirectory, globalPoConfigPath, globalSettingsCachePath, globalSettingsPeople, isPortableConfigKey, mergeGlobalConfigLayer, mergePoConfigs, nonPortableConfigKeys, nonPortableConfigText, parseAutocompactModeConfig, parsePlanningModeConfig, parsePoConfig, readHostMarketplaceOrigin, readPoConfig, readPoConfigLayers, readPoConfigLenient, readWorkspaceDeclarations, refreshGlobalSettingsCache, repositoryPoConfigPath, resolvePlanningPlansDirectory, resolveVoiceConfig, valueAtKeyPath };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
2
2
|
const require_atomicJson = require("./atomicJson-D3MHqnLW.cjs");
|
|
3
|
-
const require_core = require("./core-
|
|
3
|
+
const require_core = require("./core-C1Vhkd5h.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");
|
|
@@ -242,4 +242,4 @@ Object.defineProperty(exports, "writePoConfigValuesAsync", {
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
-
//# sourceMappingURL=configWriter-
|
|
245
|
+
//# sourceMappingURL=configWriter-BHyszJvW.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configWriter-V4SOCh7_.cjs","names":["createSerialRunner","parseDocument","fs","path","layerFromText","randomUUID","path","readTextIfExists","layerFromText","createDirectoryWithMode","writeFileAtomic","nodeHost"],"sources":["../src/services/configWriter/core.ts","../src/services/configWriter/sync.ts","../src/services/configWriter/index.ts"],"sourcesContent":["/**\n * Pure half of the Po config writer.\n *\n * Writes into the global Po config file, one key path at a time.\n *\n * Extracted from po-file-edit, which owned the only writer in the repo and had\n * it hard-coded to `editor.command`. Several extensions now edit their own\n * settings from the config panel, and every one of them needs the same four\n * properties: keep the user's comments, never publish a file the parser would\n * reject, never leave a half-written file behind, and apply a set of related\n * edits together.\n *\n * That last one is not a convenience. `voice.adapters.<engine>.model` accepts a\n * path or an id but not both, so switching between them is a set and an unset\n * that must land in the same write, or the file is briefly invalid.\n *\n * Atomicity is the same rename trick as `atomicJson` next door, and carries\n * the same caveat across processes: it prevents torn reads, not lost updates.\n * Two sessions with the panel open still clobber each other, because the rename\n * only publishes what the caller already computed. Within one process every\n * read-modify-write of a file is queued per path, so concurrent edits compose.\n *\n * AVOID:\n * - Treating this as a lock\n * - Writing an empty string; the parser rejects blank values, so clearing a key\n * means removing it\n */\n\nimport { createSerialRunner } from '@agimon-ai/po-core/platform';\nimport { parseDocument } from 'yaml';\n\nimport { parsePoConfig } from '../configPolicy';\n\n/**\n * The global file holds machine-wide credentials-adjacent settings and lives in\n * the user's home, so it stays private.\n */\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\n/**\n * The repository file is committed to git and read by everyone who checks the\n * project out, so it takes the modes `init.ts` already seeds it with. Writing it\n * private would produce a 0600 file in a working tree, which is both wrong and\n * invisible until someone else clones.\n */\nconst REPOSITORY_FILE_MODE = 0o644;\nconst REPOSITORY_DIRECTORY_MODE = 0o755;\n\n/** Which file a write is aimed at; the modes follow from it. */\nexport type PoConfigScope = 'host' | 'repository';\n\n/** The permissions a scope's file and its parent directory are created with. */\nexport function modesForScope(scope: PoConfigScope): { file: number; directory: number } {\n return scope === 'repository'\n ? { file: REPOSITORY_FILE_MODE, directory: REPOSITORY_DIRECTORY_MODE }\n : { file: PRIVATE_FILE_MODE, directory: PRIVATE_DIRECTORY_MODE };\n}\n\nexport interface PoConfigEdit {\n /** Key path into the document, e.g. `['voice', 'adapters', 'mlx-whisper', 'model', 'id']`. */\n readonly keyPath: readonly string[];\n /**\n * The value to write. `undefined` removes the key.\n *\n * Not only strings: the config holds numbers (`utteranceIdleMs`) and lists\n * (`startPhrases`), and a panel that edits them as text has to hand back the\n * parsed value or the next load rejects what it wrote.\n */\n readonly value?: string | number | boolean | readonly string[];\n}\n\nexport interface WritePoConfigOptions {\n /**\n * Remove ancestors left holding nothing. Defaults to true, and is not\n * cosmetic: an adapter left as `{}` fails validation, because the parser\n * requires a model once the adapter exists at all.\n */\n readonly prune?: boolean;\n /**\n * Which file this is, so the write lands with the right permissions.\n * Defaults to `host`, which is what every caller wrote before the\n * repository file was writable at all.\n */\n readonly scope?: PoConfigScope;\n /**\n * The file hash the caller read (`''` for an absent file). Checked inside the\n * per-file queue, so a write computed from a stale read is refused rather than\n * overwriting a newer one.\n */\n readonly expectedHash?: string;\n}\n\n/** The file changed since the caller read it. `hash` is what it holds now. */\nexport class PoConfigConflictError extends Error {\n constructor(\n readonly filePath: string,\n readonly hash: string,\n ) {\n super(`Po config at ${filePath} changed since it was read.`);\n this.name = 'PoConfigConflictError';\n }\n}\n\nfunction isEmptyCollection(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const items = (value as { items?: unknown }).items;\n return Array.isArray(items) && items.length === 0;\n}\n\n/** Drops ancestors of a removed key that are now empty, deepest first. */\nfunction pruneEmptyAncestors(document: ReturnType<typeof parseDocument>, keyPath: readonly string[]): void {\n for (let depth = keyPath.length - 1; depth > 0; depth -= 1) {\n const ancestor = keyPath.slice(0, depth);\n if (!document.hasIn(ancestor)) continue;\n if (!isEmptyCollection(document.getIn(ancestor, true))) return;\n document.deleteIn(ancestor);\n }\n}\n\n/** One queue per config file, shared by the async writer and the Node shim. */\nexport const configWrites = createSerialRunner();\n\n/**\n * Applies every edit to the file's current text as one document mutation and\n * returns the text to publish.\n * Throws, having changed nothing, when the source does not parse or the result\n * would not validate.\n *\n * Validation runs against the serialized result rather than each edit, so a pair\n * of edits only valid together is accepted, and a single edit that breaks an\n * invariant elsewhere is still caught.\n */\nexport function applyPoConfigEdits(\n content: string,\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): string {\n // Not `content || '{}\\n'`: seeding an absent file with a flow map makes yaml\n // keep that style, so the first write produces `{ editor: { command: ... } }`\n // and every later one grows that one line. An empty source starts a block map.\n const document = parseDocument(content, { keepSourceTokens: true });\n if (document.errors.length > 0) throw new Error(`Could not parse Po config at ${filePath}`);\n\n for (const edit of edits) {\n const keyPath = [...edit.keyPath];\n if (edit.value !== undefined) {\n document.setIn(keyPath, edit.value);\n continue;\n }\n // deleteIn throws when an ancestor is missing rather than treating the key as\n // already absent, and clearing an unset key is worth supporting.\n if (!document.hasIn(keyPath)) continue;\n document.deleteIn(keyPath);\n if (options.prune !== false) pruneEmptyAncestors(document, keyPath);\n }\n\n const output = document.toString();\n parsePoConfig(output, filePath);\n return output;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\nasync function readIfPresent(filePath: string): Promise<string | undefined> {\n try {\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Applies every edit as one document mutation, or throws having written nothing.\n *\n * @deprecated Node-only shim over node:fs; use writePoConfigValuesAsync. Removed in M2.\n */\nexport async function writePoConfigValues(\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readIfPresent(filePath);\n // Same precondition as writePoConfigValuesAsync, checked inside the queue.\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await fs.mkdir(path.dirname(filePath), { mode: modes.directory, recursive: true });\n const temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporaryPath, output, { encoding: 'utf8', mode: modes.file });\n await fs.rename(temporaryPath, filePath);\n } catch (error) {\n await fs.rm(temporaryPath, { force: true });\n throw error;\n }\n });\n}\n\n/** @deprecated Node-only shim over node:fs; use setPoConfigValueAsync. Removed in M2. */\nexport async function setPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n value: string,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath, value }], options);\n}\n\n/** @deprecated Node-only shim over node:fs; use unsetPoConfigValueAsync. Removed in M2. */\nexport async function unsetPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath }], options);\n}\n","import path from 'node:path';\n\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { createDirectoryWithMode } from '../atomicJson';\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/**\n * Applies every edit as one document mutation over a FileSystem, or throws\n * having written nothing. Concurrent calls for one file in this process are\n * queued, so each reads what the previous one wrote.\n */\nexport async function writePoConfigValuesAsync(\n fs: FileSystem,\n filePath: string,\n edits: readonly PoConfigEdit[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readTextIfExists(fs, filePath, context);\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await createDirectoryWithMode(fs, path.dirname(filePath), modes.directory, context);\n await writeFileAtomic(fs, filePath, output, context);\n await nodeHost.setMode(filePath, modes.file);\n });\n}\n\nexport async function setPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n value: string,\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath, value }], context, options);\n}\n\nexport async function unsetPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath }], context, options);\n}\n\nexport { PoConfigConflictError } from './core';\nexport type { PoConfigEdit, PoConfigScope, WritePoConfigOptions } from './core';\nexport { setPoConfigVal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EA,eAAsB,sBACpB,IACA,UACA,SACA,OACA,SACA,UAAgC,CAAC,GAClB;CACf,MAAM,yBAAyB,IAAI,UAAU,CAAC;EAAE;EAAS;CAAM,CAAC,GAAG,SAAS,OAAO;AACrF;AAEA,eAAsB,wBACpB,IACA,UACA,SACA,SACA,UAAgC,CAAC,GAClB;CACf,MAAM,yBAAyB,IAAI,UAAU,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,OAAO;AAC9E"}
|
|
1
|
+
{"version":3,"file":"configWriter-BHyszJvW.cjs","names":["createSerialRunner","parseDocument","fs","path","layerFromText","randomUUID","path","readTextIfExists","layerFromText","createDirectoryWithMode","writeFileAtomic","nodeHost"],"sources":["../src/services/configWriter/core.ts","../src/services/configWriter/sync.ts","../src/services/configWriter/index.ts"],"sourcesContent":["/**\n * Pure half of the Po config writer.\n *\n * Writes into the global Po config file, one key path at a time.\n *\n * Extracted from po-file-edit, which owned the only writer in the repo and had\n * it hard-coded to `editor.command`. Several extensions now edit their own\n * settings from the config panel, and every one of them needs the same four\n * properties: keep the user's comments, never publish a file the parser would\n * reject, never leave a half-written file behind, and apply a set of related\n * edits together.\n *\n * That last one is not a convenience. `voice.adapters.<engine>.model` accepts a\n * path or an id but not both, so switching between them is a set and an unset\n * that must land in the same write, or the file is briefly invalid.\n *\n * Atomicity is the same rename trick as `atomicJson` next door, and carries\n * the same caveat across processes: it prevents torn reads, not lost updates.\n * Two sessions with the panel open still clobber each other, because the rename\n * only publishes what the caller already computed. Within one process every\n * read-modify-write of a file is queued per path, so concurrent edits compose.\n *\n * AVOID:\n * - Treating this as a lock\n * - Writing an empty string; the parser rejects blank values, so clearing a key\n * means removing it\n */\n\nimport { createSerialRunner } from '@agimon-ai/po-core/platform';\nimport { parseDocument } from 'yaml';\n\nimport { parsePoConfig } from '../configPolicy';\n\n/**\n * The global file holds machine-wide credentials-adjacent settings and lives in\n * the user's home, so it stays private.\n */\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\n/**\n * The repository file is committed to git and read by everyone who checks the\n * project out, so it takes the modes `init.ts` already seeds it with. Writing it\n * private would produce a 0600 file in a working tree, which is both wrong and\n * invisible until someone else clones.\n */\nconst REPOSITORY_FILE_MODE = 0o644;\nconst REPOSITORY_DIRECTORY_MODE = 0o755;\n\n/** Which file a write is aimed at; the modes follow from it. */\nexport type PoConfigScope = 'host' | 'repository';\n\n/** The permissions a scope's file and its parent directory are created with. */\nexport function modesForScope(scope: PoConfigScope): { file: number; directory: number } {\n return scope === 'repository'\n ? { file: REPOSITORY_FILE_MODE, directory: REPOSITORY_DIRECTORY_MODE }\n : { file: PRIVATE_FILE_MODE, directory: PRIVATE_DIRECTORY_MODE };\n}\n\nexport interface PoConfigEdit {\n /** Key path into the document, e.g. `['voice', 'adapters', 'mlx-whisper', 'model', 'id']`. */\n readonly keyPath: readonly string[];\n /**\n * The value to write. `undefined` removes the key.\n *\n * Not only strings: the config holds numbers (`utteranceIdleMs`) and lists\n * (`startPhrases`), and a panel that edits them as text has to hand back the\n * parsed value or the next load rejects what it wrote.\n */\n readonly value?: string | number | boolean | readonly string[];\n}\n\nexport interface WritePoConfigOptions {\n /**\n * Remove ancestors left holding nothing. Defaults to true, and is not\n * cosmetic: an adapter left as `{}` fails validation, because the parser\n * requires a model once the adapter exists at all.\n */\n readonly prune?: boolean;\n /**\n * Which file this is, so the write lands with the right permissions.\n * Defaults to `host`, which is what every caller wrote before the\n * repository file was writable at all.\n */\n readonly scope?: PoConfigScope;\n /**\n * The file hash the caller read (`''` for an absent file). Checked inside the\n * per-file queue, so a write computed from a stale read is refused rather than\n * overwriting a newer one.\n */\n readonly expectedHash?: string;\n}\n\n/** The file changed since the caller read it. `hash` is what it holds now. */\nexport class PoConfigConflictError extends Error {\n constructor(\n readonly filePath: string,\n readonly hash: string,\n ) {\n super(`Po config at ${filePath} changed since it was read.`);\n this.name = 'PoConfigConflictError';\n }\n}\n\nfunction isEmptyCollection(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const items = (value as { items?: unknown }).items;\n return Array.isArray(items) && items.length === 0;\n}\n\n/** Drops ancestors of a removed key that are now empty, deepest first. */\nfunction pruneEmptyAncestors(document: ReturnType<typeof parseDocument>, keyPath: readonly string[]): void {\n for (let depth = keyPath.length - 1; depth > 0; depth -= 1) {\n const ancestor = keyPath.slice(0, depth);\n if (!document.hasIn(ancestor)) continue;\n if (!isEmptyCollection(document.getIn(ancestor, true))) return;\n document.deleteIn(ancestor);\n }\n}\n\n/** One queue per config file, shared by the async writer and the Node shim. */\nexport const configWrites = createSerialRunner();\n\n/**\n * Applies every edit to the file's current text as one document mutation and\n * returns the text to publish.\n * Throws, having changed nothing, when the source does not parse or the result\n * would not validate.\n *\n * Validation runs against the serialized result rather than each edit, so a pair\n * of edits only valid together is accepted, and a single edit that breaks an\n * invariant elsewhere is still caught.\n */\nexport function applyPoConfigEdits(\n content: string,\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): string {\n // Not `content || '{}\\n'`: seeding an absent file with a flow map makes yaml\n // keep that style, so the first write produces `{ editor: { command: ... } }`\n // and every later one grows that one line. An empty source starts a block map.\n const document = parseDocument(content, { keepSourceTokens: true });\n if (document.errors.length > 0) throw new Error(`Could not parse Po config at ${filePath}`);\n\n for (const edit of edits) {\n const keyPath = [...edit.keyPath];\n if (edit.value !== undefined) {\n document.setIn(keyPath, edit.value);\n continue;\n }\n // deleteIn throws when an ancestor is missing rather than treating the key as\n // already absent, and clearing an unset key is worth supporting.\n if (!document.hasIn(keyPath)) continue;\n document.deleteIn(keyPath);\n if (options.prune !== false) pruneEmptyAncestors(document, keyPath);\n }\n\n const output = document.toString();\n parsePoConfig(output, filePath);\n return output;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\nasync function readIfPresent(filePath: string): Promise<string | undefined> {\n try {\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Applies every edit as one document mutation, or throws having written nothing.\n *\n * @deprecated Node-only shim over node:fs; use writePoConfigValuesAsync. Removed in M2.\n */\nexport async function writePoConfigValues(\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readIfPresent(filePath);\n // Same precondition as writePoConfigValuesAsync, checked inside the queue.\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await fs.mkdir(path.dirname(filePath), { mode: modes.directory, recursive: true });\n const temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporaryPath, output, { encoding: 'utf8', mode: modes.file });\n await fs.rename(temporaryPath, filePath);\n } catch (error) {\n await fs.rm(temporaryPath, { force: true });\n throw error;\n }\n });\n}\n\n/** @deprecated Node-only shim over node:fs; use setPoConfigValueAsync. Removed in M2. */\nexport async function setPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n value: string,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath, value }], options);\n}\n\n/** @deprecated Node-only shim over node:fs; use unsetPoConfigValueAsync. Removed in M2. */\nexport async function unsetPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath }], options);\n}\n","import path from 'node:path';\n\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { createDirectoryWithMode } from '../atomicJson';\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/**\n * Applies every edit as one document mutation over a FileSystem, or throws\n * having written nothing. Concurrent calls for one file in this process are\n * queued, so each reads what the previous one wrote.\n */\nexport async function writePoConfigValuesAsync(\n fs: FileSystem,\n filePath: string,\n edits: readonly PoConfigEdit[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readTextIfExists(fs, filePath, context);\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await createDirectoryWithMode(fs, path.dirname(filePath), modes.directory, context);\n await writeFileAtomic(fs, filePath, output, context);\n await nodeHost.setMode(filePath, modes.file);\n });\n}\n\nexport async function setPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n value: string,\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath, value }], context, options);\n}\n\nexport async function unsetPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath }], context, options);\n}\n\nexport { PoConfigConflictError } from './core';\nexport type { PoConfigEdit, PoConfigScope, WritePoConfigOptions } from './core';\nexport { setPoConfigValue, unsetPoConfigValue, writePoConfigValues } from './sync';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,UAAU,CAAC;EAAE;EAAS;CAAM,CAAC,GAAG,SAAS,OAAO;AACrF;AAEA,eAAsB,wBACpB,IACA,UACA,SACA,SACA,UAAgC,CAAC,GAClB;CACf,MAAM,yBAAyB,IAAI,UAAU,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,OAAO;AAC9E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as createDirectoryWithMode } from "./atomicJson-Dj3rlZbD.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { B as parsePoConfig, h as layerFromText } from "./core-2Tw_zo7m.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createSerialRunner, nodeHost, readTextIfExists, writeFileAtomic } from "@agimon-ai/po-core/platform";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
@@ -198,4 +198,4 @@ async function unsetPoConfigValueAsync(fs, filePath, keyPath, context, options =
|
|
|
198
198
|
//#endregion
|
|
199
199
|
export { unsetPoConfigValue as a, setPoConfigValue as i, unsetPoConfigValueAsync as n, writePoConfigValues as o, writePoConfigValuesAsync as r, PoConfigConflictError as s, setPoConfigValueAsync as t };
|
|
200
200
|
|
|
201
|
-
//# sourceMappingURL=configWriter-
|
|
201
|
+
//# sourceMappingURL=configWriter-X7ySHBMS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configWriter-BY2s7hz-.mjs","names":[],"sources":["../src/services/configWriter/core.ts","../src/services/configWriter/sync.ts","../src/services/configWriter/index.ts"],"sourcesContent":["/**\n * Pure half of the Po config writer.\n *\n * Writes into the global Po config file, one key path at a time.\n *\n * Extracted from po-file-edit, which owned the only writer in the repo and had\n * it hard-coded to `editor.command`. Several extensions now edit their own\n * settings from the config panel, and every one of them needs the same four\n * properties: keep the user's comments, never publish a file the parser would\n * reject, never leave a half-written file behind, and apply a set of related\n * edits together.\n *\n * That last one is not a convenience. `voice.adapters.<engine>.model` accepts a\n * path or an id but not both, so switching between them is a set and an unset\n * that must land in the same write, or the file is briefly invalid.\n *\n * Atomicity is the same rename trick as `atomicJson` next door, and carries\n * the same caveat across processes: it prevents torn reads, not lost updates.\n * Two sessions with the panel open still clobber each other, because the rename\n * only publishes what the caller already computed. Within one process every\n * read-modify-write of a file is queued per path, so concurrent edits compose.\n *\n * AVOID:\n * - Treating this as a lock\n * - Writing an empty string; the parser rejects blank values, so clearing a key\n * means removing it\n */\n\nimport { createSerialRunner } from '@agimon-ai/po-core/platform';\nimport { parseDocument } from 'yaml';\n\nimport { parsePoConfig } from '../configPolicy';\n\n/**\n * The global file holds machine-wide credentials-adjacent settings and lives in\n * the user's home, so it stays private.\n */\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\n/**\n * The repository file is committed to git and read by everyone who checks the\n * project out, so it takes the modes `init.ts` already seeds it with. Writing it\n * private would produce a 0600 file in a working tree, which is both wrong and\n * invisible until someone else clones.\n */\nconst REPOSITORY_FILE_MODE = 0o644;\nconst REPOSITORY_DIRECTORY_MODE = 0o755;\n\n/** Which file a write is aimed at; the modes follow from it. */\nexport type PoConfigScope = 'host' | 'repository';\n\n/** The permissions a scope's file and its parent directory are created with. */\nexport function modesForScope(scope: PoConfigScope): { file: number; directory: number } {\n return scope === 'repository'\n ? { file: REPOSITORY_FILE_MODE, directory: REPOSITORY_DIRECTORY_MODE }\n : { file: PRIVATE_FILE_MODE, directory: PRIVATE_DIRECTORY_MODE };\n}\n\nexport interface PoConfigEdit {\n /** Key path into the document, e.g. `['voice', 'adapters', 'mlx-whisper', 'model', 'id']`. */\n readonly keyPath: readonly string[];\n /**\n * The value to write. `undefined` removes the key.\n *\n * Not only strings: the config holds numbers (`utteranceIdleMs`) and lists\n * (`startPhrases`), and a panel that edits them as text has to hand back the\n * parsed value or the next load rejects what it wrote.\n */\n readonly value?: string | number | boolean | readonly string[];\n}\n\nexport interface WritePoConfigOptions {\n /**\n * Remove ancestors left holding nothing. Defaults to true, and is not\n * cosmetic: an adapter left as `{}` fails validation, because the parser\n * requires a model once the adapter exists at all.\n */\n readonly prune?: boolean;\n /**\n * Which file this is, so the write lands with the right permissions.\n * Defaults to `host`, which is what every caller wrote before the\n * repository file was writable at all.\n */\n readonly scope?: PoConfigScope;\n /**\n * The file hash the caller read (`''` for an absent file). Checked inside the\n * per-file queue, so a write computed from a stale read is refused rather than\n * overwriting a newer one.\n */\n readonly expectedHash?: string;\n}\n\n/** The file changed since the caller read it. `hash` is what it holds now. */\nexport class PoConfigConflictError extends Error {\n constructor(\n readonly filePath: string,\n readonly hash: string,\n ) {\n super(`Po config at ${filePath} changed since it was read.`);\n this.name = 'PoConfigConflictError';\n }\n}\n\nfunction isEmptyCollection(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const items = (value as { items?: unknown }).items;\n return Array.isArray(items) && items.length === 0;\n}\n\n/** Drops ancestors of a removed key that are now empty, deepest first. */\nfunction pruneEmptyAncestors(document: ReturnType<typeof parseDocument>, keyPath: readonly string[]): void {\n for (let depth = keyPath.length - 1; depth > 0; depth -= 1) {\n const ancestor = keyPath.slice(0, depth);\n if (!document.hasIn(ancestor)) continue;\n if (!isEmptyCollection(document.getIn(ancestor, true))) return;\n document.deleteIn(ancestor);\n }\n}\n\n/** One queue per config file, shared by the async writer and the Node shim. */\nexport const configWrites = createSerialRunner();\n\n/**\n * Applies every edit to the file's current text as one document mutation and\n * returns the text to publish.\n * Throws, having changed nothing, when the source does not parse or the result\n * would not validate.\n *\n * Validation runs against the serialized result rather than each edit, so a pair\n * of edits only valid together is accepted, and a single edit that breaks an\n * invariant elsewhere is still caught.\n */\nexport function applyPoConfigEdits(\n content: string,\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): string {\n // Not `content || '{}\\n'`: seeding an absent file with a flow map makes yaml\n // keep that style, so the first write produces `{ editor: { command: ... } }`\n // and every later one grows that one line. An empty source starts a block map.\n const document = parseDocument(content, { keepSourceTokens: true });\n if (document.errors.length > 0) throw new Error(`Could not parse Po config at ${filePath}`);\n\n for (const edit of edits) {\n const keyPath = [...edit.keyPath];\n if (edit.value !== undefined) {\n document.setIn(keyPath, edit.value);\n continue;\n }\n // deleteIn throws when an ancestor is missing rather than treating the key as\n // already absent, and clearing an unset key is worth supporting.\n if (!document.hasIn(keyPath)) continue;\n document.deleteIn(keyPath);\n if (options.prune !== false) pruneEmptyAncestors(document, keyPath);\n }\n\n const output = document.toString();\n parsePoConfig(output, filePath);\n return output;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\nasync function readIfPresent(filePath: string): Promise<string | undefined> {\n try {\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Applies every edit as one document mutation, or throws having written nothing.\n *\n * @deprecated Node-only shim over node:fs; use writePoConfigValuesAsync. Removed in M2.\n */\nexport async function writePoConfigValues(\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readIfPresent(filePath);\n // Same precondition as writePoConfigValuesAsync, checked inside the queue.\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await fs.mkdir(path.dirname(filePath), { mode: modes.directory, recursive: true });\n const temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporaryPath, output, { encoding: 'utf8', mode: modes.file });\n await fs.rename(temporaryPath, filePath);\n } catch (error) {\n await fs.rm(temporaryPath, { force: true });\n throw error;\n }\n });\n}\n\n/** @deprecated Node-only shim over node:fs; use setPoConfigValueAsync. Removed in M2. */\nexport async function setPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n value: string,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath, value }], options);\n}\n\n/** @deprecated Node-only shim over node:fs; use unsetPoConfigValueAsync. Removed in M2. */\nexport async function unsetPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath }], options);\n}\n","import path from 'node:path';\n\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { createDirectoryWithMode } from '../atomicJson';\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/**\n * Applies every edit as one document mutation over a FileSystem, or throws\n * having written nothing. Concurrent calls for one file in this process are\n * queued, so each reads what the previous one wrote.\n */\nexport async function writePoConfigValuesAsync(\n fs: FileSystem,\n filePath: string,\n edits: readonly PoConfigEdit[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readTextIfExists(fs, filePath, context);\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await createDirectoryWithMode(fs, path.dirname(filePath), modes.directory, context);\n await writeFileAtomic(fs, filePath, output, context);\n await nodeHost.setMode(filePath, modes.file);\n });\n}\n\nexport async function setPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n value: string,\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath, value }], context, options);\n}\n\nexport async function unsetPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath }], context, options);\n}\n\nexport { PoConfigConflictError } from './core';\nexport type { PoConfigEdit, PoConfigScope, WritePoConfigOptions } from './core';\nexport { setPoConfigValue, unsetPoConfigValue, writePoConfigValues } from './sync';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,oBAAoB;AAC1B,MAAM,yBAAyB;;;;;;;AAQ/B,MAAM,uBAAuB;AAC7B,MAAM,4BAA4B;;AAMlC,SAAgB,cAAc,OAA2D;CACvF,OAAO,UAAU,eACb;EAAE,MAAM;EAAsB,WAAW;CAA0B,IACnE;EAAE,MAAM;EAAmB,WAAW;CAAuB;AACnE;;AAqCA,IAAa,wBAAb,cAA2C,MAAM;CAEpC;CACA;CAFX,YACE,UACA,MACA;EACA,MAAM,gBAAgB,SAAS,4BAA4B;EAHlD,KAAA,WAAA;EACA,KAAA,OAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,SAAS,kBAAkB,OAAyB;CAClD,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,MAAM,QAAS,MAA8B;CAC7C,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAClD;;AAGA,SAAS,oBAAoB,UAA4C,SAAkC;CACzG,KAAK,IAAI,QAAQ,QAAQ,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG;EAC1D,MAAM,WAAW,QAAQ,MAAM,GAAG,KAAK;EACvC,IAAI,CAAC,SAAS,MAAM,QAAQ,GAAG;EAC/B,IAAI,CAAC,kBAAkB,SAA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,MAAM,WAAW,OAAO;EAClF,MAAM,gBAAgB,IAAI,UAAU,QAAQ,OAAO;EACnD,MAAM,SAAS,QAAQ,UAAU,MAAM,IAAI;CAC7C,CAAC;AACH;AAEA,eAAsB,sBACpB,IACA,UACA,SACA,OACA,SACA,UAAgC,CAAC,GAClB;CACf,MAAM,yBAAyB,IAAI,UAAU,CAAC;EAAE;EAAS;CAAM,CAAC,GAAG,SAAS,OAAO;AACrF;AAEA,eAAsB,wBACpB,IACA,UACA,SACA,SACA,UAAgC,CAAC,GAClB;CACf,MAAM,yBAAyB,IAAI,UAAU,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,OAAO;AAC9E"}
|
|
1
|
+
{"version":3,"file":"configWriter-X7ySHBMS.mjs","names":[],"sources":["../src/services/configWriter/core.ts","../src/services/configWriter/sync.ts","../src/services/configWriter/index.ts"],"sourcesContent":["/**\n * Pure half of the Po config writer.\n *\n * Writes into the global Po config file, one key path at a time.\n *\n * Extracted from po-file-edit, which owned the only writer in the repo and had\n * it hard-coded to `editor.command`. Several extensions now edit their own\n * settings from the config panel, and every one of them needs the same four\n * properties: keep the user's comments, never publish a file the parser would\n * reject, never leave a half-written file behind, and apply a set of related\n * edits together.\n *\n * That last one is not a convenience. `voice.adapters.<engine>.model` accepts a\n * path or an id but not both, so switching between them is a set and an unset\n * that must land in the same write, or the file is briefly invalid.\n *\n * Atomicity is the same rename trick as `atomicJson` next door, and carries\n * the same caveat across processes: it prevents torn reads, not lost updates.\n * Two sessions with the panel open still clobber each other, because the rename\n * only publishes what the caller already computed. Within one process every\n * read-modify-write of a file is queued per path, so concurrent edits compose.\n *\n * AVOID:\n * - Treating this as a lock\n * - Writing an empty string; the parser rejects blank values, so clearing a key\n * means removing it\n */\n\nimport { createSerialRunner } from '@agimon-ai/po-core/platform';\nimport { parseDocument } from 'yaml';\n\nimport { parsePoConfig } from '../configPolicy';\n\n/**\n * The global file holds machine-wide credentials-adjacent settings and lives in\n * the user's home, so it stays private.\n */\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\n/**\n * The repository file is committed to git and read by everyone who checks the\n * project out, so it takes the modes `init.ts` already seeds it with. Writing it\n * private would produce a 0600 file in a working tree, which is both wrong and\n * invisible until someone else clones.\n */\nconst REPOSITORY_FILE_MODE = 0o644;\nconst REPOSITORY_DIRECTORY_MODE = 0o755;\n\n/** Which file a write is aimed at; the modes follow from it. */\nexport type PoConfigScope = 'host' | 'repository';\n\n/** The permissions a scope's file and its parent directory are created with. */\nexport function modesForScope(scope: PoConfigScope): { file: number; directory: number } {\n return scope === 'repository'\n ? { file: REPOSITORY_FILE_MODE, directory: REPOSITORY_DIRECTORY_MODE }\n : { file: PRIVATE_FILE_MODE, directory: PRIVATE_DIRECTORY_MODE };\n}\n\nexport interface PoConfigEdit {\n /** Key path into the document, e.g. `['voice', 'adapters', 'mlx-whisper', 'model', 'id']`. */\n readonly keyPath: readonly string[];\n /**\n * The value to write. `undefined` removes the key.\n *\n * Not only strings: the config holds numbers (`utteranceIdleMs`) and lists\n * (`startPhrases`), and a panel that edits them as text has to hand back the\n * parsed value or the next load rejects what it wrote.\n */\n readonly value?: string | number | boolean | readonly string[];\n}\n\nexport interface WritePoConfigOptions {\n /**\n * Remove ancestors left holding nothing. Defaults to true, and is not\n * cosmetic: an adapter left as `{}` fails validation, because the parser\n * requires a model once the adapter exists at all.\n */\n readonly prune?: boolean;\n /**\n * Which file this is, so the write lands with the right permissions.\n * Defaults to `host`, which is what every caller wrote before the\n * repository file was writable at all.\n */\n readonly scope?: PoConfigScope;\n /**\n * The file hash the caller read (`''` for an absent file). Checked inside the\n * per-file queue, so a write computed from a stale read is refused rather than\n * overwriting a newer one.\n */\n readonly expectedHash?: string;\n}\n\n/** The file changed since the caller read it. `hash` is what it holds now. */\nexport class PoConfigConflictError extends Error {\n constructor(\n readonly filePath: string,\n readonly hash: string,\n ) {\n super(`Po config at ${filePath} changed since it was read.`);\n this.name = 'PoConfigConflictError';\n }\n}\n\nfunction isEmptyCollection(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const items = (value as { items?: unknown }).items;\n return Array.isArray(items) && items.length === 0;\n}\n\n/** Drops ancestors of a removed key that are now empty, deepest first. */\nfunction pruneEmptyAncestors(document: ReturnType<typeof parseDocument>, keyPath: readonly string[]): void {\n for (let depth = keyPath.length - 1; depth > 0; depth -= 1) {\n const ancestor = keyPath.slice(0, depth);\n if (!document.hasIn(ancestor)) continue;\n if (!isEmptyCollection(document.getIn(ancestor, true))) return;\n document.deleteIn(ancestor);\n }\n}\n\n/** One queue per config file, shared by the async writer and the Node shim. */\nexport const configWrites = createSerialRunner();\n\n/**\n * Applies every edit to the file's current text as one document mutation and\n * returns the text to publish.\n * Throws, having changed nothing, when the source does not parse or the result\n * would not validate.\n *\n * Validation runs against the serialized result rather than each edit, so a pair\n * of edits only valid together is accepted, and a single edit that breaks an\n * invariant elsewhere is still caught.\n */\nexport function applyPoConfigEdits(\n content: string,\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): string {\n // Not `content || '{}\\n'`: seeding an absent file with a flow map makes yaml\n // keep that style, so the first write produces `{ editor: { command: ... } }`\n // and every later one grows that one line. An empty source starts a block map.\n const document = parseDocument(content, { keepSourceTokens: true });\n if (document.errors.length > 0) throw new Error(`Could not parse Po config at ${filePath}`);\n\n for (const edit of edits) {\n const keyPath = [...edit.keyPath];\n if (edit.value !== undefined) {\n document.setIn(keyPath, edit.value);\n continue;\n }\n // deleteIn throws when an ancestor is missing rather than treating the key as\n // already absent, and clearing an unset key is worth supporting.\n if (!document.hasIn(keyPath)) continue;\n document.deleteIn(keyPath);\n if (options.prune !== false) pruneEmptyAncestors(document, keyPath);\n }\n\n const output = document.toString();\n parsePoConfig(output, filePath);\n return output;\n}\n","import { randomUUID } from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\nasync function readIfPresent(filePath: string): Promise<string | undefined> {\n try {\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return undefined;\n throw error;\n }\n}\n\n/**\n * Applies every edit as one document mutation, or throws having written nothing.\n *\n * @deprecated Node-only shim over node:fs; use writePoConfigValuesAsync. Removed in M2.\n */\nexport async function writePoConfigValues(\n filePath: string,\n edits: readonly PoConfigEdit[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readIfPresent(filePath);\n // Same precondition as writePoConfigValuesAsync, checked inside the queue.\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await fs.mkdir(path.dirname(filePath), { mode: modes.directory, recursive: true });\n const temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n try {\n await fs.writeFile(temporaryPath, output, { encoding: 'utf8', mode: modes.file });\n await fs.rename(temporaryPath, filePath);\n } catch (error) {\n await fs.rm(temporaryPath, { force: true });\n throw error;\n }\n });\n}\n\n/** @deprecated Node-only shim over node:fs; use setPoConfigValueAsync. Removed in M2. */\nexport async function setPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n value: string,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath, value }], options);\n}\n\n/** @deprecated Node-only shim over node:fs; use unsetPoConfigValueAsync. Removed in M2. */\nexport async function unsetPoConfigValue(\n filePath: string,\n keyPath: readonly string[],\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValues(filePath, [{ keyPath }], options);\n}\n","import path from 'node:path';\n\nimport { nodeHost, readTextIfExists, writeFileAtomic, type FileSystem } from '@agimon-ai/po-core/platform';\n\nimport { createDirectoryWithMode } from '../atomicJson';\nimport { layerFromText } from '../config/core';\nimport {\n applyPoConfigEdits,\n configWrites,\n modesForScope,\n PoConfigConflictError,\n type PoConfigEdit,\n type WritePoConfigOptions,\n} from './core';\n\ntype IoContext = Parameters<FileSystem['readTextFile']>[1];\n\n/**\n * Applies every edit as one document mutation over a FileSystem, or throws\n * having written nothing. Concurrent calls for one file in this process are\n * queued, so each reads what the previous one wrote.\n */\nexport async function writePoConfigValuesAsync(\n fs: FileSystem,\n filePath: string,\n edits: readonly PoConfigEdit[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n if (edits.length === 0) return;\n await configWrites.forKey(path.resolve(filePath))(async () => {\n const text = await readTextIfExists(fs, filePath, context);\n if (options.expectedHash !== undefined) {\n const hash = layerFromText(filePath, text).hash;\n if (hash !== options.expectedHash) throw new PoConfigConflictError(filePath, hash);\n }\n const output = applyPoConfigEdits(text ?? '', filePath, edits, options);\n const modes = modesForScope(options.scope ?? 'host');\n await createDirectoryWithMode(fs, path.dirname(filePath), modes.directory, context);\n await writeFileAtomic(fs, filePath, output, context);\n await nodeHost.setMode(filePath, modes.file);\n });\n}\n\nexport async function setPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n value: string,\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath, value }], context, options);\n}\n\nexport async function unsetPoConfigValueAsync(\n fs: FileSystem,\n filePath: string,\n keyPath: readonly string[],\n context: IoContext,\n options: WritePoConfigOptions = {},\n): Promise<void> {\n await writePoConfigValuesAsync(fs, filePath, [{ keyPath }], context, options);\n}\n\nexport { PoConfigConflictError } from './core';\nexport type { PoConfigEdit, PoConfigScope, WritePoConfigOptions } from './core';\nexport { setPoConfigValue, unsetPoConfigValue, writePoConfigValues } from './sync';\n"],"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;AAC9E"}
|
package/dist/configWriter.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_configWriter = require("./configWriter-
|
|
2
|
+
const require_configWriter = require("./configWriter-BHyszJvW.cjs");
|
|
3
3
|
exports.PoConfigConflictError = require_configWriter.PoConfigConflictError;
|
|
4
4
|
exports.setPoConfigValue = require_configWriter.setPoConfigValue;
|
|
5
5
|
exports.setPoConfigValueAsync = require_configWriter.setPoConfigValueAsync;
|
package/dist/configWriter.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { s as PoConfigConflictError, i as setPoConfigValue, t as setPoConfigValueAsync, a as unsetPoConfigValue, n as unsetPoConfigValueAsync, o as writePoConfigValues, r as writePoConfigValuesAsync } from "./configWriter-
|
|
1
|
+
export { s as PoConfigConflictError, i as setPoConfigValue, t as setPoConfigValueAsync, a as unsetPoConfigValue, n as unsetPoConfigValueAsync, o as writePoConfigValues, r as writePoConfigValuesAsync } from "./configWriter-X7ySHBMS.mjs";
|