{"version":3,"file":"poHomeMigration-grUSMsbc.mjs","names":["fs","parse","fs"],"sources":["../../../../../node_modules/.pnpm/@earendil-works+pi-durable@1.4.0_patch_hash=ca0435559cc5cf00cf977a30ff4d003dec6a5e5a1b1_41dffca5fd191e117609bd998f4ea469/node_modules/@earendil-works/pi-durable/dist/env/index.js","../../../../core/po-core/dist/src/services/platformFiles/index.mjs","../../../../foundations/po-config/dist/config-C-dgx_54.mjs","../../../../foundations/po-config/dist/harnessState-ufE-npBa.mjs","../../../../foundations/po-config/dist/atomicJson-Dj3rlZbD.mjs","../../../../foundations/po-config/dist/sync-BJ8gCP9s.mjs","../../../../core/po-core/dist/runtimeCordisHost.mjs","../../../../foundations/po-config/dist/harnessStore-yqKUx-kP.mjs","../../../../cli/po/src/composition/poHomeMigration/index.ts"],"sourcesContent":["export function ok(value) {\n    return { ok: true, value };\n}\nexport function err(error) {\n    return { ok: false, error };\n}\nexport function getOrThrow(result) {\n    if (!result.ok)\n        throw result.error;\n    return result.value;\n}\nexport function getOrUndefined(result) {\n    return result.ok ? result.value : undefined;\n}\nexport function toError(error) {\n    if (error instanceof Error)\n        return error;\n    if (typeof error === \"string\")\n        return new Error(error);\n    try {\n        return new Error(JSON.stringify(error));\n    }\n    catch {\n        return new Error(String(error));\n    }\n}\nexport class FileError extends Error {\n    code;\n    path;\n    constructor(code, message, path, cause) {\n        super(message, cause === undefined ? undefined : { cause });\n        this.name = \"FileError\";\n        this.code = code;\n        this.path = path;\n    }\n}\nexport class ExecutionError extends Error {\n    code;\n    /** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */\n    spillPath;\n    constructor(code, message, cause) {\n        super(message, cause === undefined ? undefined : { cause });\n        this.name = \"ExecutionError\";\n        this.code = code;\n    }\n}\nexport { rangeDecoder, StreamDecoder, startsWithBom } from \"./decode.js\";\nexport { LineScanner } from \"./line-scan.js\";\n//# sourceMappingURL=index.js.map","import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { BACKGROUND_CONTEXT } from \"@earendil-works/chord/context\";\nimport { getOrThrow } from \"@earendil-works/pi-durable/env\";\n//#region src/services/platformFiles/index.ts\nconst nativeReads = {\n\tread: {\n\t\tcount: 0,\n\t\tbytes: 0,\n\t\trefusals: 0\n\t},\n\tedit: {\n\t\tcount: 0,\n\t\tbytes: 0,\n\t\trefusals: 0\n\t},\n\tgrep: {\n\t\tcount: 0,\n\t\tbytes: 0,\n\t\trefusals: 0\n\t}\n};\nlet ripgrepBytes = 0;\nlet ripgrepTruncations = 0;\nlet largestTranscriptEntryBytes = 0;\nfunction recordBoundedRead(bytes, family = \"read\", refused = false) {\n\tif (family !== \"read\" && family !== \"edit\" && family !== \"grep\") return;\n\tconst counters = nativeReads[family];\n\tcounters.count++;\n\tif (Number.isSafeInteger(bytes) && bytes > 0) counters.bytes += bytes;\n\tif (refused) counters.refusals++;\n}\n/** Bytes retained from stdout and stderr, including failed or aborted searches. */\nfunction recordRipgrepOutput(bytes, truncated = false) {\n\tif (Number.isSafeInteger(bytes) && bytes > 0) ripgrepBytes += bytes;\n\tif (truncated) ripgrepTruncations++;\n}\n/** Exact JSON bytes of a browser projection, not the durable source entry size. */\nfunction recordTranscriptProjection(bytes) {\n\tif (Number.isSafeInteger(bytes) && bytes > 0) largestTranscriptEntryBytes = Math.max(largestTranscriptEntryBytes, bytes);\n}\nfunction memoryDiagnosticAttributes() {\n\treturn {\n\t\tnative_read_count: nativeReads.read.count,\n\t\tnative_read_bytes: nativeReads.read.bytes,\n\t\tnative_read_refusals: nativeReads.read.refusals,\n\t\tnative_edit_count: nativeReads.edit.count,\n\t\tnative_edit_bytes: nativeReads.edit.bytes,\n\t\tnative_edit_refusals: nativeReads.edit.refusals,\n\t\tnative_grep_count: nativeReads.grep.count,\n\t\tnative_grep_bytes: nativeReads.grep.bytes,\n\t\tnative_grep_refusals: nativeReads.grep.refusals,\n\t\tripgrep_collected_bytes: ripgrepBytes,\n\t\tripgrep_truncations: ripgrepTruncations,\n\t\tlargest_transcript_entry_projected_bytes: largestTranscriptEntryBytes\n\t};\n}\nvar FileTooLargeError = class extends Error {\n\tconstructor(filePath, maxBytes) {\n\t\tsuper(`File exceeds ${maxBytes} byte read limit: ${filePath}`);\n\t\tthis.name = \"FileTooLargeError\";\n\t}\n};\n/** Bounds allocation even when a file grows between stat and read. */\nasync function readBoundedFile(fs, filePath, maxBytes, context) {\n\tif (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError(\"Invalid read limit.\");\n\tconst reader = getOrThrow(await fs.openBinaryReader(filePath, {}, context));\n\ttry {\n\t\tconst info = getOrThrow(await reader.info(context));\n\t\tif (info.size > maxBytes) throw new FileTooLargeError(filePath, maxBytes);\n\t\tconst data = getOrThrow(await reader.read(0, info.size, context));\n\t\tconst after = getOrThrow(await reader.info(context));\n\t\tif (after.size > maxBytes) throw new FileTooLargeError(filePath, maxBytes);\n\t\tif (data.length !== info.size || after.size !== info.size || after.mtimeMs !== info.mtimeMs) throw new Error(`File changed during access: ${filePath}`);\n\t\treturn data;\n\t} finally {\n\t\tawait reader.close(BACKGROUND_CONTEXT);\n\t}\n}\n/** File text, or undefined when the file does not exist. Every other failure throws. */\nasync function readTextIfExists(fs, filePath, context) {\n\tconst result = await fs.readTextFile(filePath, context);\n\tif (!result.ok && result.error.code === \"not_found\") return void 0;\n\treturn getOrThrow(result);\n}\nasync function pathExists(fs, filePath, context) {\n\treturn getOrThrow(await fs.exists(filePath, context));\n}\n/** Removes a file or directory tree; a missing path is not an error. */\nasync function removePath(fs, filePath, context) {\n\tgetOrThrow(await fs.remove(filePath, {\n\t\trecursive: true,\n\t\tforce: true\n\t}, context));\n}\n/**\n* Writes through a uniquely named temporary file beside the target, then renames it into\n* place, so a reader never sees a torn file. A failed write removes its temporary file.\n* Callers that read-modify-write the same target serialise through `serialRunner.forKey`.\n*/\nasync function writeFileAtomic(fs, filePath, content, context) {\n\tgetOrThrow(await fs.createDir(path.dirname(filePath), { recursive: true }, context));\n\tconst temporaryPath = `${filePath}.${randomUUID()}.tmp`;\n\tconst written = await fs.writeFile(temporaryPath, content, context);\n\tconst renamed = written.ok ? await fs.renameFile(temporaryPath, filePath, context) : written;\n\tif (!renamed.ok) {\n\t\tawait fs.remove(temporaryPath, { force: true }, context);\n\t\tgetOrThrow(renamed);\n\t}\n}\n//#endregion\nexport { FileTooLargeError, memoryDiagnosticAttributes, pathExists, readBoundedFile, readTextIfExists, recordBoundedRead, recordRipgrepOutput, recordTranscriptProjection, removePath, writeFileAtomic };\n\n//# sourceMappingURL=index.mjs.map","import { f as parsePoConfig } from \"./configPolicy-BADJDi8o.mjs\";\nimport { c as layerFromText, d as mergeLenientLayers, f as repositoryConfigFor, i as defaultPoConfig, l as lenientConfigFromText, n as composeConfigLayers, o as globalPoConfigPath, r as configFromText, t as absentRepositoryLayer, u as mergeConfigLayers } from \"./core-BOyti7Xw.mjs\";\nimport path from \"node:path\";\nimport { nodeHost, readTextIfExists } from \"@agimon-ai/po-core/platform\";\nimport fs from \"node:fs\";\nimport { parse } from \"yaml\";\n//#region src/services/config/sync.ts\nfunction readTextSync(filePath) {\n\tif (filePath === void 0) return void 0;\n\ttry {\n\t\treturn fs.readFileSync(filePath, \"utf8\");\n\t} catch (error) {\n\t\tif (error.code === \"ENOENT\") return void 0;\n\t\tthrow error;\n\t}\n}\nasync function readText$1(filePath) {\n\ttry {\n\t\treturn await fs.promises.readFile(filePath, \"utf8\");\n\t} catch (error) {\n\t\tif (error.code === \"ENOENT\") return void 0;\n\t\tthrow error;\n\t}\n}\n/** @deprecated Node-only sync shim; use readPoConfig. Removed in M2. */\nfunction loadPoConfig(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n\treturn mergeConfigLayers(configFromText(readTextSync(globalPath), globalPath), repositoryPath === void 0 ? defaultPoConfig() : configFromText(readTextSync(repositoryPath), repositoryPath), environment);\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*/\nfunction loadPoConfigLenient(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n\treturn mergeLenientLayers(lenientConfigFromText(readTextSync(globalPath), globalPath), lenientConfigFromText(readTextSync(repositoryPath), repositoryPath ?? \"\"), environment);\n}\n/** @deprecated Node-only shim over node:fs; use readPoConfig. Removed in M2. */\nasync function loadPoConfigAsync(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n\tconst globalConfig = configFromText(await readText$1(globalPath), globalPath);\n\tconst repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(await readText$1(repositoryPath), repositoryPath);\n\treturn mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n/** @deprecated Node-only sync shim; use readPoConfigLayers. Removed in M2. */\nfunction loadPoConfigLayers(repoRoot, homeDirectory = nodeHost.homeDirectory(), environment = process.env) {\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repoRoot === void 0 ? void 0 : repositoryConfigFor(repoRoot, homeDirectory, environment);\n\tconst globalText = readTextSync(globalPath);\n\tconst repositoryText = readTextSync(repositoryPath);\n\tconst repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n\treturn composeConfigLayers(layerFromText(globalPath, globalText), repositoryPath === void 0 ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText), mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment));\n}\n//#endregion\n//#region src/services/config/index.ts\nconst object = (value) => typeof value === \"object\" && value !== null && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\nfunction jsonValue(value, seen = /* @__PURE__ */ new Set()) {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (typeof value !== \"object\" || !Array.isArray(value) && !object(value) || seen.has(value)) return false;\n\tseen.add(value);\n\tconst valid = (Array.isArray(value) ? value : Object.values(value)).every((entry) => jsonValue(entry, seen));\n\tseen.delete(value);\n\treturn valid;\n}\n/** Repository-only declarations. An existing new document is authoritative, even when empty. */\nasync function readWorkspaceDeclarations({ fs, repositoryRoot, context }) {\n\tconst filePath = path.join(repositoryRoot, \".po\", \"workspaces.yaml\");\n\tconst text = await readTextIfExists(fs, filePath, context);\n\tif (text === void 0) {\n\t\tconst legacyPath = path.join(repositoryRoot, \".po\", \"config.yaml\");\n\t\tconst legacy = await readTextIfExists(fs, legacyPath, context);\n\t\tconst declarations = legacy === void 0 ? void 0 : configFromText(legacy, legacyPath).workspaces;\n\t\treturn {\n\t\t\tdeclarations: declarations ?? [],\n\t\t\tsource: declarations === void 0 ? void 0 : \"config.yaml\",\n\t\t\tnotices: declarations === void 0 ? [] : [`Move workspaces from ${legacyPath} to ${filePath}; config.yaml workspaces is deprecated.`]\n\t\t};\n\t}\n\tlet document;\n\ttry {\n\t\tdocument = parse(text);\n\t} catch (error) {\n\t\tthrow new Error(`Could not parse workspace declarations at ${filePath}`, { cause: error });\n\t}\n\tif (!object(document) || Object.keys(document).some((key) => key !== \"workspaces\") || !Array.isArray(document.workspaces)) throw new Error(`Workspace declarations at ${filePath} must be an object containing a workspaces list`);\n\tconst aliases = /* @__PURE__ */ new Set();\n\tconst declarations = document.workspaces.map((entry, index) => {\n\t\tconst location = `workspaces[${String(index)}]`;\n\t\tif (!object(entry) || Object.keys(entry).some((key) => ![\n\t\t\t\"name\",\n\t\t\t\"path\",\n\t\t\t\"alias\",\n\t\t\t\"instructions\",\n\t\t\t\"metadata\"\n\t\t].includes(key))) throw new Error(`Workspace declarations at ${filePath} require ${location} to contain only name, path, alias, instructions, metadata`);\n\t\tconst base = parsePoConfig(JSON.stringify({ workspaces: [{\n\t\t\tname: entry.name,\n\t\t\tinstructions: entry.instructions\n\t\t}] }), filePath).workspaces[0];\n\t\tif (base.name.length > 80 || !/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/u.test(base.name) || base.name.includes(\"..\")) throw new Error(`Workspace declarations at ${filePath} require ${location}.name to use letters, numbers, spaces, dots, dashes, or underscores (up to 80 characters)`);\n\t\tif (entry.path !== void 0 && (typeof entry.path !== \"string\" || entry.path.trim() === \"\" || entry.path.includes(\"\\0\"))) throw new Error(`Workspace declarations at ${filePath} require ${location}.path to be a non-empty path`);\n\t\tif (entry.alias !== void 0 && (typeof entry.alias !== \"string\" || entry.alias.trim() === \"\")) throw new Error(`Workspace declarations at ${filePath} require ${location}.alias to be a non-empty string`);\n\t\tconst alias = typeof entry.alias === \"string\" ? entry.alias.trim() : void 0;\n\t\tif (alias !== void 0) {\n\t\t\tif (aliases.has(alias)) throw new Error(`Workspace declarations at ${filePath} have duplicate alias: ${alias}`);\n\t\t\taliases.add(alias);\n\t\t}\n\t\tif (entry.metadata !== void 0 && (!object(entry.metadata) || !jsonValue(entry.metadata))) throw new Error(`Workspace declarations at ${filePath} require ${location}.metadata to be a JSON object`);\n\t\treturn {\n\t\t\t...base,\n\t\t\t...entry.path === void 0 ? {} : { path: entry.path },\n\t\t\t...alias === void 0 ? {} : { alias },\n\t\t\t...entry.metadata === void 0 ? {} : { metadata: entry.metadata }\n\t\t};\n\t});\n\tparsePoConfig(JSON.stringify({ workspaces: declarations.map(({ name, instructions }) => ({\n\t\tname,\n\t\tinstructions\n\t})) }), filePath);\n\treturn {\n\t\tdeclarations,\n\t\tsource: \"workspaces.yaml\",\n\t\tnotices: []\n\t};\n}\nfunction resolved(options) {\n\treturn {\n\t\thomeDirectory: options.homeDirectory ?? nodeHost.homeDirectory(),\n\t\tenvironment: options.environment ?? process.env\n\t};\n}\nconst readText = (fs, filePath, context) => filePath === void 0 ? Promise.resolve(void 0) : readTextIfExists(fs, filePath, context);\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*/\nasync function readPoConfig(fs, repoRoot, context, options = {}) {\n\tconst { homeDirectory, environment } = resolved(options);\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n\tconst globalConfig = configFromText(await readText(fs, globalPath, context), globalPath);\n\tconst repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(await readText(fs, repositoryPath, context), repositoryPath);\n\treturn mergeConfigLayers(globalConfig, repositoryConfig, environment);\n}\n/** As `readPoConfig`, tolerating unknown keys in either file and reporting them. */\nasync function readPoConfigLenient(fs, repoRoot, context, options = {}) {\n\tconst { homeDirectory, environment } = resolved(options);\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repositoryConfigFor(repoRoot, homeDirectory, environment);\n\tconst globalConfig = lenientConfigFromText(await readText(fs, globalPath, context), globalPath);\n\tconst repositoryConfig = repositoryPath === void 0 ? lenientConfigFromText(void 0, \"\") : lenientConfigFromText(await readText(fs, repositoryPath, context), repositoryPath);\n\treturn mergeLenientLayers(globalConfig, repositoryConfig, environment);\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*/\nasync function readPoConfigLayers(fs, repoRoot, context, options = {}) {\n\tconst { homeDirectory, environment } = resolved(options);\n\tconst globalPath = globalPoConfigPath(homeDirectory, environment);\n\tconst repositoryPath = repoRoot === void 0 ? void 0 : repositoryConfigFor(repoRoot, homeDirectory, environment);\n\tconst globalText = await readText(fs, globalPath, context);\n\tconst repositoryText = await readText(fs, repositoryPath, context);\n\tconst globalLayer = layerFromText(globalPath, globalText);\n\tconst repositoryLayer = repositoryPath === void 0 ? absentRepositoryLayer() : layerFromText(repositoryPath, repositoryText);\n\tconst repositoryConfig = repositoryPath === void 0 ? defaultPoConfig() : configFromText(repositoryText, repositoryPath);\n\tconst effective = mergeConfigLayers(configFromText(globalText, globalPath), repositoryConfig, environment);\n\treturn composeConfigLayers(globalLayer, repositoryLayer, effective);\n}\n//#endregion\nexport { loadPoConfig as a, loadPoConfigLenient as c, readWorkspaceDeclarations as i, readPoConfigLayers as n, loadPoConfigAsync as o, readPoConfigLenient as r, loadPoConfigLayers as s, readPoConfig as t };\n\n//# sourceMappingURL=config-C-dgx_54.mjs.map","import path from \"node:path\";\n//#region src/services/harnessState/index.ts\n/**\n* The codec between harness state and the environment.\n*\n* Decoding exists for processes that were started without a state file: a\n* nested run, a third-party spawn, or anything older than the store. Encoding\n* exists because shell launchers and packages that do not\n* depend on this one can only read an environment. Ownership, persistence and\n* mutation belong to harnessStore.ts; nothing here touches disk or holds state.\n*/\nconst DEFAULT_MAJOR_MODE = \"copilot\";\nconst DISABLED_FLAG = \"0\";\n/**\n* State that lives in the file only.\n*\n* These are JSON documents that every spawned process would otherwise copy in\n* its environment. Profile defaults are read from the store, while Config\n* publishes the MCP projection through\n* the session-scoped Cordis registry.\n*/\nconst FILE_ONLY_STATE_FIELDS = /* @__PURE__ */ new Set([\n\t\"profileEnvironment\",\n\t\"mcpProjection\",\n\t\"packageAttribution\",\n\t\"profileIdentity\",\n\t\"profileVoice\"\n]);\nconst HARNESS_STATE_KEYS = {\n\troot: \"PO_ROOT\",\n\tmajorMode: \"PO_MAJOR_MODE\",\n\ttemporaryDirectory: \"PO_TEMP_DIR\",\n\tdomains: \"PO_DOMAINS\",\n\tlayers: \"PO_LAYERS\",\n\tcompositionFingerprint: \"PO_COMPOSITION_FINGERPRINT\",\n\tprofile: \"PO_PROFILE\",\n\tprofileEnvironment: \"PO_PROFILE_ENV\",\n\tskillDirectories: \"PO_SKILL_DIRS\",\n\tagentDirectories: \"PO_AGENT_DIRS\",\n\tadditionalDirectories: \"PO_ADDITIONAL_DIRS\",\n\tchildExtensions: \"PO_CHILD_EXTENSIONS\",\n\tpluginDirectories: \"PO_PLUGIN_DIRS\",\n\tmcpConfigPath: \"PO_MCP_CONFIG\",\n\tpersonaFile: \"PO_PERSONA_FILE\",\n\tagents: \"PO_AGENTS_ENABLED\",\n\tmcp: \"PO_MCP_ENABLED\",\n\tallowProtectedWrites: \"PO_ALLOW_PROTECTED_WRITES\"\n};\nfunction splitCsv(value) {\n\treturn value?.split(\",\").map((item) => item.trim()).filter(Boolean) ?? [];\n}\nfunction splitPaths(value) {\n\treturn value?.split(path.delimiter).map((item) => item.trim()).filter(Boolean) ?? [];\n}\nfunction parseFlag(value) {\n\treturn value !== DISABLED_FLAG;\n}\nfunction parseStringRecord(value, key, report) {\n\tif (!value) return {};\n\ttry {\n\t\tconst parsed = JSON.parse(value);\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return {};\n\t\treturn Object.fromEntries(Object.entries(parsed).filter((entry) => typeof entry[1] === \"string\"));\n\t} catch (error) {\n\t\treport?.(key, error);\n\t\treturn {};\n\t}\n}\nfunction parseStringList(value, key, report) {\n\tif (!value) return [];\n\ttry {\n\t\tconst parsed = JSON.parse(value);\n\t\treturn Array.isArray(parsed) ? parsed.filter((item) => typeof item === \"string\") : [];\n\t} catch (error) {\n\t\treport?.(key, error);\n\t\treturn [];\n\t}\n}\nfunction readHarnessState(environment = process.env, report) {\n\tconst keys = HARNESS_STATE_KEYS;\n\treturn {\n\t\troot: environment[keys.root] || void 0,\n\t\tmajorMode: environment[keys.majorMode] || DEFAULT_MAJOR_MODE,\n\t\ttemporaryDirectory: environment[keys.temporaryDirectory] || void 0,\n\t\tdomains: splitCsv(environment[keys.domains]),\n\t\tlayers: splitCsv(environment[keys.layers]),\n\t\tcompositionFingerprint: environment[keys.compositionFingerprint] || void 0,\n\t\tprofile: environment[keys.profile] || void 0,\n\t\tprofileEnvironment: parseStringRecord(environment[keys.profileEnvironment], keys.profileEnvironment, report),\n\t\tskillDirectories: splitPaths(environment[keys.skillDirectories]),\n\t\tagentDirectories: splitPaths(environment[keys.agentDirectories]),\n\t\tadditionalDirectories: splitPaths(environment[keys.additionalDirectories]),\n\t\tchildExtensions: parseStringList(environment[keys.childExtensions], keys.childExtensions, report),\n\t\tpluginDirectories: splitPaths(environment[keys.pluginDirectories]),\n\t\tmcpConfigPath: environment[keys.mcpConfigPath] || void 0,\n\t\tpersonaFile: environment[keys.personaFile] || void 0,\n\t\tagents: parseFlag(environment[keys.agents]),\n\t\tmcp: parseFlag(environment[keys.mcp]),\n\t\tallowProtectedWrites: parseFlag(environment[keys.allowProtectedWrites])\n\t};\n}\n/**\n* Publishes a state patch into an environment.\n*\n* Takes the environment rather than assuming `process.env`, because the\n* launcher builds a child environment and Po Team builds a spawn snapshot;\n* neither should mutate its own process to describe another one.\n*\n* Fields in FILE_ONLY_FIELDS are skipped: the file carries them, and a reader\n* that needs them reads the store.\n*/\nfunction projectHarnessEnvironment(patch, environment = process.env) {\n\tconst assign = (key, value) => {\n\t\tif (value === void 0) delete environment[key];\n\t\telse environment[key] = value;\n\t};\n\tconst assignFlag = (key, value) => assign(key, value ? \"1\" : DISABLED_FLAG);\n\tconst keys = HARNESS_STATE_KEYS;\n\tif (\"root\" in patch) assign(keys.root, patch.root);\n\tif (\"majorMode\" in patch) assign(keys.majorMode, patch.majorMode);\n\tif (\"temporaryDirectory\" in patch) assign(keys.temporaryDirectory, patch.temporaryDirectory);\n\tif (\"domains\" in patch) assign(keys.domains, patch.domains?.join(\",\"));\n\tif (\"layers\" in patch) assign(keys.layers, patch.layers?.join(\",\"));\n\tif (\"compositionFingerprint\" in patch) assign(keys.compositionFingerprint, patch.compositionFingerprint);\n\tif (\"profile\" in patch) assign(keys.profile, patch.profile);\n\tif (\"skillDirectories\" in patch) assign(keys.skillDirectories, patch.skillDirectories?.join(path.delimiter));\n\tif (\"agentDirectories\" in patch) assign(keys.agentDirectories, patch.agentDirectories?.join(path.delimiter));\n\tif (\"additionalDirectories\" in patch) assign(keys.additionalDirectories, patch.additionalDirectories?.join(path.delimiter));\n\tif (\"childExtensions\" in patch) assign(keys.childExtensions, JSON.stringify(patch.childExtensions ?? []));\n\tif (\"pluginDirectories\" in patch) assign(keys.pluginDirectories, patch.pluginDirectories?.join(path.delimiter));\n\tif (\"mcpConfigPath\" in patch) assign(keys.mcpConfigPath, patch.mcpConfigPath);\n\tif (\"personaFile\" in patch) assign(keys.personaFile, patch.personaFile);\n\tif (patch.agents !== void 0) assignFlag(keys.agents, patch.agents);\n\tif (patch.mcp !== void 0) assignFlag(keys.mcp, patch.mcp);\n\tif (patch.allowProtectedWrites !== void 0) assignFlag(keys.allowProtectedWrites, patch.allowProtectedWrites);\n\treturn environment;\n}\n//#endregion\nexport { readHarnessState as i, HARNESS_STATE_KEYS as n, projectHarnessEnvironment as r, FILE_ONLY_STATE_FIELDS as t };\n\n//# sourceMappingURL=harnessState-ufE-npBa.mjs.map","import path from \"node:path\";\nimport { createSerialRunner, getOrThrow, nodeHost, writeFileAtomic } from \"@agimon-ai/po-core/platform\";\n//#region src/services/atomicJson/format.ts\n/** The on-disk form: two-space indent and a trailing newline. */\nfunction serializePrivateJson(value) {\n\treturn `${JSON.stringify(value, null, 2)}\\n`;\n}\n//#endregion\n//#region src/services/atomicJson/index.ts\nconst writes = createSerialRunner();\n/**\n* Creates a directory and any missing ancestors, giving each directory it\n* creates `mode`, as `mkdir -p -m` does. Existing directories keep their mode.\n*/\nasync function createDirectoryWithMode(fs, directory, mode, context) {\n\tconst missing = [];\n\tlet current = path.resolve(directory);\n\twhile (!getOrThrow(await fs.exists(current, context))) {\n\t\tmissing.push(current);\n\t\tconst parent = path.dirname(current);\n\t\tif (parent === current) break;\n\t\tcurrent = parent;\n\t}\n\tif (missing.length === 0) return;\n\tgetOrThrow(await fs.createDir(directory, { recursive: true }, context));\n\tfor (const created of missing.reverse()) await nodeHost.setMode(created, mode);\n}\n/** Writes JSON readable by its owner only, replacing the target atomically. */\nasync function writePrivateAtomicJsonAsync(fs, filePath, value, context) {\n\tconst content = serializePrivateJson(value);\n\tawait writes.forKey(path.resolve(filePath))(async () => {\n\t\tawait createDirectoryWithMode(fs, path.dirname(filePath), 448, context);\n\t\tawait writeFileAtomic(fs, filePath, content, context);\n\t\tawait nodeHost.setMode(filePath, 384);\n\t});\n}\n//#endregion\nexport { writePrivateAtomicJsonAsync as n, serializePrivateJson as r, createDirectoryWithMode as t };\n\n//# sourceMappingURL=atomicJson-Dj3rlZbD.mjs.map","import { r as serializePrivateJson } from \"./atomicJson-Dj3rlZbD.mjs\";\nimport path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\n//#region src/services/atomicJson/sync.ts\nconst TEMPORARY_SUFFIX = \".tmp\";\n/**\n* Writes JSON readable by its owner only, replacing the target atomically.\n*\n* @deprecated Node-only sync shim; use writePrivateAtomicJsonAsync. Removed in M2.\n*/\nfunction writePrivateAtomicJson(filePath, value) {\n\tfs.mkdirSync(path.dirname(filePath), {\n\t\tmode: 448,\n\t\trecursive: true\n\t});\n\tconst temporaryPath = `${filePath}.${process.pid}.${randomUUID()}${TEMPORARY_SUFFIX}`;\n\ttry {\n\t\tfs.writeFileSync(temporaryPath, serializePrivateJson(value), { mode: 384 });\n\t\tfs.renameSync(temporaryPath, filePath);\n\t} catch (error) {\n\t\tfs.rmSync(temporaryPath, { force: true });\n\t\tthrow error;\n\t}\n}\n//#endregion\nexport { writePrivateAtomicJson as t };\n\n//# sourceMappingURL=sync-BJ8gCP9s.mjs.map","import { PO_CONTEXT_CONTRIBUTIONS_SERVICE } from \"./src/schemas/contextContributions.mjs\";\nimport { createPoContextContributionsService } from \"./src/services/contextContributions/index.mjs\";\nimport { PO_TOOL_OVERRIDES_SERVICE } from \"./src/schemas/toolOverrides.mjs\";\nimport { PO_TOOL_SURFACE_SERVICE } from \"./src/schemas/toolSurface.mjs\";\nimport { createPoToolOverridesService } from \"./src/services/toolOverrides/index.mjs\";\nimport { createPoToolSurface } from \"./src/services/toolSurface/index.mjs\";\nimport { Context } from \"@deepseek-ai/cordis\";\n//#region src/pi/cordisHost.ts\nconst PO_CORDIS_HOST_ABI_VERSION = 1;\nconst PO_CORDIS_HOST_QUERY_CHANNEL = \"po:cordis:host:v1:query\";\nconst PO_CORDIS_RUNTIME_SERVICE = \"po/runtime\";\nconst PO_CORDIS_SESSION_SERVICE = \"po/session\";\nconst PO_CORDIS_SERVER_SERVICES = \"po/server-session-services\";\nconst HOST_PROTOCOL = \"po.cordis.host\";\nconst DEFAULT_HOST_SOURCE = \"@agimon-ai/po/cordis-host\";\n/**\n* Admitted environments of sessions sharing this process, by session id.\n*\n* A server runs many sessions' Pi extensions in one process, so `process.env` is\n* the server's, not any session's. Held on a global symbol because extension\n* packages can load their own copy of this module.\n*/\nconst SESSION_ENVIRONMENTS = globalThis[Symbol.for(\"po.cordis.session-environments.v1\")] ??= /* @__PURE__ */ new Map();\n/**\n* Binds a session id to its admitted environment until the returned release runs.\n*\n* The newest registration wins: a reopened session can start before its previous host has\n* finished closing, and that late release must not unbind the new one.\n*/\nfunction registerPoSessionEnvironment(sessionId, environment) {\n\tconst registration = { environment };\n\tSESSION_ENVIRONMENTS.set(sessionId, registration);\n\treturn () => {\n\t\tif (SESSION_ENVIRONMENTS.get(sessionId) === registration) SESSION_ENVIRONMENTS.delete(sessionId);\n\t};\n}\n/** The session's admitted environment, or `process.env` for a session that owns its process. */\nfunction readPoSessionEnvironment(sessionId) {\n\treturn (sessionId === void 0 ? void 0 : SESSION_ENVIRONMENTS.get(sessionId)?.environment) ?? process.env;\n}\nfunction requirePoCordisSession(context) {\n\tconst session = context.get(PO_CORDIS_SESSION_SERVICE);\n\tif (!session) throw new Error(\"Po Cordis session service is unavailable.\");\n\treturn session;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction asHostQuery(value) {\n\tif (!isRecord(value)) return void 0;\n\tif (value.protocol !== HOST_PROTOCOL || value.abiVersion !== 1 || value.kind !== \"query\" || typeof value.requestId !== \"string\" || value.requestId.length === 0 || typeof value.source !== \"string\" || value.source.length === 0 || typeof value.accept !== \"function\") return;\n\treturn value;\n}\nfunction asHostResponder(value) {\n\tif (!isRecord(value)) throw new Error(\"The Po Cordis host returned an invalid discovery response.\");\n\tif (value.protocol !== HOST_PROTOCOL) throw new Error(\"The Po Cordis host returned an invalid protocol identifier.\");\n\tif (value.abiVersion !== 1) throw new Error(`The Po Cordis host ABI is incompatible: expected ${String(1)}, received ${String(value.abiVersion)}.`);\n\tif (typeof value.hostId !== \"string\" || value.hostId.length === 0) throw new Error(\"The Po Cordis host returned an invalid host identifier.\");\n\tif (!Context.is(value.root)) throw new Error(\"The Po Cordis host returned a value that is not a Cordis Context.\");\n\tif (!isRecord(value.runtime) || value.runtime.abiVersion !== 1 || value.runtime.hostId !== value.hostId || typeof value.acquire !== \"function\" || typeof value.shutdown !== \"function\" || !isRecord(value.ready) || typeof value.ready.then !== \"function\") throw new Error(\"The Po Cordis host returned incomplete runtime metadata.\");\n\treturn value;\n}\nfunction discoverHosts(pi, source) {\n\tconst responses = [];\n\tconst request = {\n\t\tprotocol: HOST_PROTOCOL,\n\t\tabiVersion: 1,\n\t\tkind: \"query\",\n\t\trequestId: `${source}:${crypto.randomUUID()}`,\n\t\tsource,\n\t\taccept(response) {\n\t\t\tresponses.push(asHostResponder(response));\n\t\t}\n\t};\n\tpi.events.emit(PO_CORDIS_HOST_QUERY_CHANNEL, request);\n\treturn responses;\n}\nfunction exactlyOneHost(responses, source) {\n\tif (responses.length <= 1) return responses[0];\n\tconst hostIds = responses.map(({ hostId }) => hostId).join(\", \");\n\tthrow new Error(`Multiple Po Cordis hosts answered ${source}: ${hostIds}.`);\n}\nfunction runtimeProvider(ctx, service) {\n\tctx.provide(PO_CORDIS_RUNTIME_SERVICE, service);\n\tctx.provide(PO_TOOL_OVERRIDES_SERVICE, createPoToolOverridesService(service.generation));\n}\nfunction sessionProvider(ctx, service, pi) {\n\tctx.provide(PO_CORDIS_SESSION_SERVICE, service);\n\tctx.provide(PO_CONTEXT_CONTRIBUTIONS_SERVICE, createPoContextContributionsService(service.generation));\n\tctx.provide(PO_TOOL_SURFACE_SERVICE, createPoToolSurface({\n\t\tgeneration: service.generation,\n\t\tallTools: () => pi.getAllTools().map((tool) => tool.name),\n\t\tactiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: (names) => pi.setActiveTools(names)\n\t}));\n}\n/**\n* Installs the sole Cordis application root for one Pi extension runner.\n*\n* The versioned EventBus query is intentional: Pi may hand independently\n* loaded factories different ExtensionAPI wrapper objects, while their event\n* buses still address the same runner.\n*/\nasync function installPoCordisHost(pi, options) {\n\tconst source = options.source ?? DEFAULT_HOST_SOURCE;\n\tconst existing = exactlyOneHost(discoverHosts(pi, source), source);\n\tif (existing) throw new Error(`A Po Cordis host is already installed: ${existing.hostId}.`);\n\tconst root = new Context();\n\tconst runtime = Object.freeze({\n\t\tabiVersion: 1,\n\t\thostId: `po-cordis:${crypto.randomUUID()}`,\n\t\tgeneration: `po-runtime:${crypto.randomUUID()}`,\n\t\tmode: options.mode\n\t});\n\tconst ready = root.plugin(runtimeProvider, runtime).await().then(() => void 0);\n\tlet sessionFiber;\n\tlet sessionGeneration = 0;\n\tlet sessionQueue = Promise.resolve();\n\tlet leaseCount = 0;\n\tlet shutdownPromise;\n\tlet responder;\n\tlet disposeQuerySubscription = () => void 0;\n\tconst controller = {\n\t\troot,\n\t\truntime,\n\t\tshutdown() {\n\t\t\tshutdownPromise ??= (async () => {\n\t\t\t\tdisposeQuerySubscription();\n\t\t\t\tawait ready.catch(() => void 0);\n\t\t\t\tawait sessionQueue.catch(() => void 0);\n\t\t\t\tawait sessionFiber?.dispose();\n\t\t\t\tsessionFiber = void 0;\n\t\t\t\tawait root.fiber.dispose();\n\t\t\t})();\n\t\t\treturn shutdownPromise;\n\t\t}\n\t};\n\tresponder = {\n\t\tprotocol: HOST_PROTOCOL,\n\t\tabiVersion: 1,\n\t\thostId: runtime.hostId,\n\t\troot,\n\t\truntime,\n\t\tready,\n\t\tacquire() {\n\t\t\tif (shutdownPromise) throw new Error(`The Po Cordis host is shutting down: ${runtime.hostId}.`);\n\t\t\tleaseCount += 1;\n\t\t\tlet released = false;\n\t\t\treturn {\n\t\t\t\troot,\n\t\t\t\truntime,\n\t\t\t\tasync dispose() {\n\t\t\t\t\tif (released) return;\n\t\t\t\t\treleased = true;\n\t\t\t\t\tleaseCount -= 1;\n\t\t\t\t\tif (options.mode === \"standalone\" && leaseCount === 0) await controller.shutdown();\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tshutdown: () => controller.shutdown()\n\t};\n\ttry {\n\t\tdisposeQuerySubscription = pi.events.on(PO_CORDIS_HOST_QUERY_CHANNEL, (value) => {\n\t\t\tconst query = asHostQuery(value);\n\t\t\tif (query) query.accept(responder);\n\t\t});\n\t\tpi.on(\"session_start\", (event, context) => {\n\t\t\tsessionQueue = sessionQueue.catch(() => void 0).then(async () => {\n\t\t\t\tif (shutdownPromise) return;\n\t\t\t\tawait sessionFiber?.dispose();\n\t\t\t\tsessionGeneration += 1;\n\t\t\t\tconst service = Object.freeze({\n\t\t\t\t\tsessionId: context.sessionManager.getSessionId(),\n\t\t\t\t\tgeneration: `${runtime.generation}:${String(sessionGeneration)}`,\n\t\t\t\t\treason: event.reason,\n\t\t\t\t\tcontext,\n\t\t\t\t\tenvironment: readPoSessionEnvironment(context.sessionManager.getSessionId())\n\t\t\t\t});\n\t\t\t\tsessionFiber = root.plugin((ctx, value) => {\n\t\t\t\t\tsessionProvider(ctx, value, pi);\n\t\t\t\t}, service);\n\t\t\t\tawait sessionFiber.await();\n\t\t\t});\n\t\t\treturn sessionQueue;\n\t\t});\n\t\tif (options.mode === \"standalone\") pi.on(\"session_shutdown\", () => {\n\t\t\tdisposeQuerySubscription();\n\t\t});\n\t\tawait ready;\n\t} catch (error) {\n\t\tawait controller.shutdown();\n\t\tthrow error;\n\t}\n\treturn controller;\n}\nasync function connectPoCordisHost(pi, source, options) {\n\tconst responder = exactlyOneHost(discoverHosts(pi, source), source);\n\tif (!responder) {\n\t\tif (options?.optional) return void 0;\n\t\tthrow new Error(\"The composed Po Cordis host is unavailable. Ensure cordisHost is the first extension.\");\n\t}\n\tawait responder.ready;\n\treturn responder.acquire();\n}\n/** Ends the host discovered on this runner. Repeated finalization is a no-op. */\nasync function finalizePoCordisHost(pi, source) {\n\tawait exactlyOneHost(discoverHosts(pi, source), source)?.shutdown();\n}\n//#endregion\nexport { PO_CORDIS_HOST_ABI_VERSION, PO_CORDIS_HOST_QUERY_CHANNEL, PO_CORDIS_RUNTIME_SERVICE, PO_CORDIS_SERVER_SERVICES, PO_CORDIS_SESSION_SERVICE, connectPoCordisHost, finalizePoCordisHost, installPoCordisHost, readPoSessionEnvironment, registerPoSessionEnvironment, requirePoCordisSession };\n\n//# sourceMappingURL=runtimeCordisHost.mjs.map","import { n as writePrivateAtomicJsonAsync } from \"./atomicJson-Dj3rlZbD.mjs\";\nimport { t as writePrivateAtomicJson } from \"./sync-BJ8gCP9s.mjs\";\nimport { i as readHarnessState, n as HARNESS_STATE_KEYS, r as projectHarnessEnvironment } from \"./harnessState-ufE-npBa.mjs\";\nimport path from \"node:path\";\nimport { createSerialRunner, nodeHost, readTextIfExists, removePath } from \"@agimon-ai/po-core/platform\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport { readPoSessionEnvironment } from \"@agimon-ai/po-core/cordisHost\";\n//#region src/models/harnessCache.ts\nconst harnessCache = { loaded: void 0 };\n//#endregion\n//#region src/services/harnessStore/core.ts\n/** Points at the state file. The one variable that is not derived. */\nconst HARNESS_STATE_POINTER = \"PO_STATE\";\nconst STATE_FILE_VERSION = 1;\nconst STATE_FILE_NAME = \"harness-state.json\";\nconst ADOPTED_DIRECTORY = \"po-harness\";\n/** Drops the cached state. For tests, and for a process changing identity. */\nfunction resetHarnessStore() {\n\tharnessCache.loaded = void 0;\n}\nfunction parseStateFile(source, filePath) {\n\tconst parsed = JSON.parse(source);\n\tif (parsed.version !== STATE_FILE_VERSION) throw new Error(`Harness state at ${filePath} has version ${String(parsed.version)}, expected ${STATE_FILE_VERSION}`);\n\tif (typeof parsed.state !== \"object\" || parsed.state === null) throw new Error(`Harness state at ${filePath} has no state object`);\n\treturn {\n\t\tversion: STATE_FILE_VERSION,\n\t\towner: {\n\t\t\tpid: parsed.owner?.pid ?? -1,\n\t\t\tstartedAt: parsed.owner?.startedAt ?? \"\"\n\t\t},\n\t\tstate: parsed.state\n\t};\n}\n/** Whether a process may write the file in place rather than copying it first. */\nfunction ownsStateFile(file, processId) {\n\treturn file.owner.pid === processId || file.owner.pid === 0;\n}\nfunction stateFileDocument(state, ownerPid) {\n\treturn {\n\t\tversion: STATE_FILE_VERSION,\n\t\towner: {\n\t\t\tpid: ownerPid,\n\t\t\tstartedAt: (/* @__PURE__ */ new Date()).toISOString()\n\t\t},\n\t\tstate\n\t};\n}\nfunction stateFilePath(directory) {\n\treturn path.join(directory, STATE_FILE_NAME);\n}\n/** Where a process writes state when it was not given a file of its own. */\nfunction adoptedStateFilePath(temporaryDirectory, processId) {\n\treturn path.join(temporaryDirectory, ADOPTED_DIRECTORY, `${String(processId)}.json`);\n}\n/** Captures a loaded state together with the pointer and every projected harness variable. */\nfunction snapshotFrom(loaded, environment) {\n\tconst environmentSnapshot = { [HARNESS_STATE_POINTER]: environment[HARNESS_STATE_POINTER] };\n\tfor (const key of Object.values(HARNESS_STATE_KEYS)) environmentSnapshot[key] = environment[key];\n\treturn {\n\t\tfilePath: loaded.filePath,\n\t\towned: loaded.owned,\n\t\tstate: structuredClone(loaded.state),\n\t\tenvironment: environmentSnapshot\n\t};\n}\n//#endregion\n//#region src/services/harnessStore/sync.ts\nfunction fileMtime(filePath) {\n\ttry {\n\t\treturn fs.statSync(filePath).mtimeMs;\n\t} catch {\n\t\treturn;\n\t}\n}\n/**\n* Whether the cache still describes what the process points at.\n*\n* A session can load more than one copy of this package (a layer package\n* installed under .pi/npm brings its own), and each copy caches on its own.\n* The pointer and the file are shared, so a switch persisted through one copy\n* moves the pointer or rewrites the file, and every other copy must notice\n* rather than answer from memory.\n*/\nfunction cacheCurrent(cache, environment) {\n\tconst pointer = environment[HARNESS_STATE_POINTER];\n\tif (cache.filePath !== pointer) return false;\n\tif (!cache.filePath) return true;\n\ttry {\n\t\treturn fs.statSync(cache.filePath).mtimeMs === cache.mtimeMs;\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Reads the state for this process, once.\n*\n* A missing pointer means nobody wrote a file for this process, so the\n* environment is all there is: a nested run, a third-party spawn, or a caller\n* older than the store. A pointer that cannot be read is reported and then\n* treated the same way, because a session that starts degraded beats a session\n* that does not start at all.\n*\n* @deprecated Node-only sync shim; use loadHarnessStateAsync. Removed in M2.\n*/\nfunction loadHarnessState(environment = process.env, report) {\n\tconst cacheable = environment === process.env;\n\tif (cacheable && harnessCache.loaded && cacheCurrent(harnessCache.loaded, environment)) return harnessCache.loaded;\n\tconst filePath = environment[HARNESS_STATE_POINTER];\n\tlet result;\n\tif (filePath && fs.existsSync(filePath)) try {\n\t\tconst file = parseStateFile(fs.readFileSync(filePath, \"utf8\"), filePath);\n\t\tresult = {\n\t\t\tfilePath,\n\t\t\towned: ownsStateFile(file, process.pid),\n\t\t\tstate: file.state,\n\t\t\tmtimeMs: fileMtime(filePath)\n\t\t};\n\t} catch (error) {\n\t\treport?.(HARNESS_STATE_POINTER, error);\n\t}\n\tresult ??= {\n\t\towned: false,\n\t\tstate: readHarnessState(environment, report)\n\t};\n\tif (cacheable) harnessCache.loaded = result;\n\treturn result;\n}\n/**\n* Captures the owned state pointer and every projected harness variable.\n*\n* @deprecated Node-only sync shim; use snapshotHarnessStateAsync. Removed in M2.\n*/\nfunction snapshotHarnessState(environment = process.env) {\n\treturn snapshotFrom(loadHarnessState(environment), environment);\n}\n/**\n* Restores a snapshot only while the current process still owns its state pointer.\n*\n* @deprecated Node-only sync shim. Removed in M2.\n*/\nfunction restoreHarnessStateSnapshot(snapshot, environment = process.env) {\n\tconst current = loadHarnessState(environment);\n\tif (snapshot.filePath && snapshot.owned) {\n\t\tif (!current.owned || current.filePath !== snapshot.filePath) throw new Error(\"Harness state ownership changed; refusing to restore an older snapshot.\");\n\t\tpersist(snapshot.filePath, snapshot.state);\n\t} else if (!snapshot.filePath) {\n\t\tif (current.filePath && !current.owned) throw new Error(\"Harness state is no longer owned by this process; refusing to restore an older snapshot.\");\n\t\tif (current.filePath && current.owned) fs.rmSync(current.filePath, { force: true });\n\t\tresetHarnessStore();\n\t} else if (current.filePath !== snapshot.filePath) throw new Error(\"Harness state pointer changed; refusing to restore an older snapshot.\");\n\tfor (const [key, value] of Object.entries(snapshot.environment)) if (value === void 0) delete environment[key];\n\telse environment[key] = value;\n\tif (environment === process.env) harnessCache.loaded = snapshot.filePath ? {\n\t\tfilePath: snapshot.filePath,\n\t\towned: snapshot.owned,\n\t\tstate: snapshot.state,\n\t\tmtimeMs: fileMtime(snapshot.filePath)\n\t} : void 0;\n}\n/** @deprecated Node-only sync shim; use loadHarnessStateAsync. Removed in M2. */\nfunction getHarnessState(report) {\n\treturn loadHarnessState(process.env, report).state;\n}\n/**\n* The harness state of one session, by id.\n*\n* A server runs many sessions' extensions in one process, each with its own state file, so\n* a session-scoped reader asks by session id. A terminal session owns its process, and the\n* answer is the same as `getHarnessState`.\n*\n* @deprecated Node-only sync shim; use loadHarnessStateAsync with readPoSessionEnvironment. Removed in M2.\n*/\nfunction getSessionHarnessState(sessionId, report) {\n\treturn loadHarnessState(readPoSessionEnvironment(sessionId), report).state;\n}\nfunction persist(filePath, state, ownerPid = process.pid) {\n\twritePrivateAtomicJson(filePath, stateFileDocument(state, ownerPid));\n}\n/**\n* Starts a session: writes the file and publishes the derived environment.\n*\n* The environment is a parameter because the caller is usually describing a\n* process other than itself. The launcher builds the environment for the Pi it\n* is about to spawn, and Po Team builds the snapshot for a detached child, so\n* neither should touch its own `process.env` to do it.\n*\n* @deprecated Node-only sync shim; use createHarnessSessionAsync. Removed in M2.\n*/\nfunction createHarnessSession(state, options) {\n\tconst filePath = stateFilePath(options.directory);\n\tpersist(filePath, state, options.unclaimed ? 0 : process.pid);\n\toptions.environment[HARNESS_STATE_POINTER] = filePath;\n\tprojectHarnessEnvironment(state, options.environment);\n\tif (!options.unclaimed && options.environment === process.env) harnessCache.loaded = {\n\t\tfilePath,\n\t\towned: true,\n\t\tstate,\n\t\tmtimeMs: fileMtime(filePath)\n\t};\n\treturn filePath;\n}\n/**\n* Applies a patch to this process's state.\n*\n* Copy on write: a process holding a file it does not own writes its own copy\n* and repoints itself at it, so a child can never rewrite its parent's session.\n*\n* @deprecated Node-only sync shim; use updateHarnessStateAsync. Removed in M2.\n*/\nfunction updateHarnessState(patch, environment = process.env) {\n\tconst current = loadHarnessState(environment);\n\tconst state = {\n\t\t...current.state,\n\t\t...patch\n\t};\n\tconst filePath = current.owned && current.filePath ? current.filePath : adoptedStateFilePath(os.tmpdir(), process.pid);\n\tpersist(filePath, state);\n\tenvironment[HARNESS_STATE_POINTER] = filePath;\n\tif (environment === process.env) harnessCache.loaded = {\n\t\tfilePath,\n\t\towned: true,\n\t\tstate,\n\t\tmtimeMs: fileMtime(filePath)\n\t};\n\tprojectHarnessEnvironment(patch, environment);\n\treturn state;\n}\n/**\n* Removes this process's own state file. Safe when there is none.\n*\n* @deprecated Node-only sync shim; use disposeHarnessStateAsync. Removed in M2.\n*/\nfunction disposeHarnessState(environment = process.env) {\n\tconst current = harnessCache.loaded;\n\tresetHarnessStore();\n\tif (!current?.owned || !current.filePath) return;\n\tfs.rmSync(current.filePath, { force: true });\n\tdelete environment[HARNESS_STATE_POINTER];\n}\n//#endregion\n//#region src/services/harnessStore/index.ts\n/** Read-modify-write of one state file, queued per path within this process. */\nconst stateWrites = createSerialRunner();\n/** Reads the state an environment points at, uncached. Same fallbacks as `loadHarnessState`. */\nasync function loadHarnessStateAsync(fs, environment, context, report) {\n\tconst filePath = environment[HARNESS_STATE_POINTER];\n\tif (filePath) try {\n\t\tconst source = await readTextIfExists(fs, filePath, context);\n\t\tif (source !== void 0) {\n\t\t\tconst file = parseStateFile(source, filePath);\n\t\t\treturn {\n\t\t\t\tfilePath,\n\t\t\t\towned: ownsStateFile(file, nodeHost.processId()),\n\t\t\t\tstate: file.state\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\treport?.(HARNESS_STATE_POINTER, error);\n\t}\n\treturn {\n\t\towned: false,\n\t\tstate: readHarnessState(environment, report)\n\t};\n}\n/** Captures the state pointer, the state, and every projected harness variable. */\nasync function snapshotHarnessStateAsync(fs, environment, context) {\n\treturn snapshotFrom(await loadHarnessStateAsync(fs, environment, context), environment);\n}\nasync function persistAsync(fs, filePath, state, ownerPid, context) {\n\tawait writePrivateAtomicJsonAsync(fs, filePath, stateFileDocument(state, ownerPid), context);\n}\n/** Starts a session over a FileSystem: writes the file and publishes the derived environment. */\nasync function createHarnessSessionAsync(fs, state, options, context) {\n\tconst filePath = stateFilePath(options.directory);\n\tawait stateWrites.forKey(path.resolve(filePath))(() => persistAsync(fs, filePath, state, options.unclaimed ? 0 : nodeHost.processId(), context));\n\toptions.environment[HARNESS_STATE_POINTER] = filePath;\n\tprojectHarnessEnvironment(state, options.environment);\n\treturn filePath;\n}\nconst REPOINTED = Symbol(\"repointed\");\n/**\n* Applies a patch to the state an environment points at, copy on write as\n* `updateHarnessState`. Concurrent patches to one file are queued, so each\n* reads what the previous one wrote and none is lost.\n*/\nasync function updateHarnessStateAsync(fs, patch, environment, context) {\n\tconst adoptedPath = adoptedStateFilePath(nodeHost.temporaryDirectory(), nodeHost.processId());\n\tconst key = environment[\"PO_STATE\"] ?? adoptedPath;\n\tconst result = await stateWrites.forKey(path.resolve(key))(async () => {\n\t\tif ((environment[\"PO_STATE\"] ?? adoptedPath) !== key) return REPOINTED;\n\t\tconst current = await loadHarnessStateAsync(fs, environment, context);\n\t\tconst state = {\n\t\t\t...current.state,\n\t\t\t...patch\n\t\t};\n\t\tconst filePath = current.owned && current.filePath ? current.filePath : adoptedPath;\n\t\tawait persistAsync(fs, filePath, state, nodeHost.processId(), context);\n\t\tenvironment[HARNESS_STATE_POINTER] = filePath;\n\t\tprojectHarnessEnvironment(patch, environment);\n\t\treturn state;\n\t});\n\treturn result === REPOINTED ? updateHarnessStateAsync(fs, patch, environment, context) : result;\n}\n/** Removes the state file this process owns, if the environment points at one. Safe when there is none. */\nasync function disposeHarnessStateAsync(fs, environment, context) {\n\tconst current = await loadHarnessStateAsync(fs, environment, context);\n\tif (!current.owned || !current.filePath) return;\n\tconst filePath = current.filePath;\n\tawait stateWrites.forKey(path.resolve(filePath))(() => removePath(fs, filePath, context));\n\tdelete environment[HARNESS_STATE_POINTER];\n}\nfunction harnessRoot(state = getHarnessState()) {\n\treturn state.root ?? process.cwd();\n}\n/**\n* The repository root, or a hard error.\n*\n* Separate from `requireHarnessPaths` because most callers only need the root,\n* and separate from `harnessRoot` because falling back to `process.cwd()` would\n* quietly operate on whatever directory the session happens to sit in. A caller\n* that asks for the root wants the session's repository or nothing.\n*/\nfunction requireHarnessRoot(state = getHarnessState()) {\n\tif (!state.root) throw new Error(`${HARNESS_STATE_KEYS.root} is not set`);\n\treturn state.root;\n}\n/** The root and the run's scratch directory, for callers that write to disk. */\nfunction requireHarnessPaths(state = getHarnessState()) {\n\tconst root = requireHarnessRoot(state);\n\tif (!state.temporaryDirectory) throw new Error(`${HARNESS_STATE_KEYS.temporaryDirectory} is not set`);\n\treturn {\n\t\troot,\n\t\ttemporaryDirectory: state.temporaryDirectory\n\t};\n}\n//#endregion\nexport { HARNESS_STATE_POINTER as _, requireHarnessPaths as a, updateHarnessStateAsync as c, getHarnessState as d, getSessionHarnessState as f, updateHarnessState as g, snapshotHarnessState as h, loadHarnessStateAsync as i, createHarnessSession as l, restoreHarnessStateSnapshot as m, disposeHarnessStateAsync as n, requireHarnessRoot as o, loadHarnessState as p, harnessRoot as r, snapshotHarnessStateAsync as s, createHarnessSessionAsync as t, disposeHarnessState as u, resetHarnessStore as v };\n\n//# sourceMappingURL=harnessStore-yqKUx-kP.mjs.map","import { execFileSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\n/**\n * Moving Po's home from `~/.pi/.po` to `~/.po`.\n *\n * The user's data is copied, never renamed: an older Po still running reads the old\n * directory, so it must stay whole until no older host is left. The old directory is\n * deleted only when both the host registry and a process scan find no older host.\n */\n\nconst LEGACY_SEGMENTS = ['.pi', '.po'] as const;\nconst MARKER_FILE = 'migration.json';\nconst MARKER_VERSION = 1;\n/** What moves: configuration, user workspaces, git and session state, and the signer. */\nconst COPIED_ENTRIES = [\n  'config.yaml',\n  'modes.yaml',\n  'domains.yaml',\n  'profiles.yaml',\n  'workspace',\n  'git',\n  'session',\n  path.join('server', 'signing.json'),\n] as const;\nconst LEGACY_PLANS_DIRECTORY = 'plans';\nconst HOSTS_DIRECTORY = path.join('run', 'hosts');\nconst HOST_RECORD_PREFIX = 'po-server-';\n/** Command lines of an older Po host, which reads the legacy directory. */\nconst PO_HOST_COMMAND = /po\\/dist\\/bin\\/(serve|cli)\\.mjs/u;\n/** The web and server ports older Po hosts listen on. */\nconst LEGACY_HOST_PORTS = [7433, 7434, 7533, 7534] as const;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\n\nexport function legacyPoHomeDirectory(homeDirectory: string): string {\n  return path.join(homeDirectory, ...LEGACY_SEGMENTS);\n}\n\nexport interface PoHomeMigrationResult {\n  readonly status: 'migrated' | 'already-migrated' | 'nothing-to-migrate';\n  readonly copied: readonly string[];\n  /** Entries left alone because `~/.po` already had them. */\n  readonly skipped: readonly string[];\n}\n\n/**\n * Copies the user's data from `~/.pi/.po`, and plans from `~/.pi/plans`, into the Po home, once.\n *\n * An entry the Po home already has is skipped, never merged or overwritten. The marker\n * records that this ran; the Po home existing does not, because `run` lives there too.\n */\nexport async function migratePoHome(homeDirectory: string, poHome: string): Promise<PoHomeMigrationResult> {\n  const marker = path.join(poHome, MARKER_FILE);\n  if (\n    await fs.access(marker).then(\n      () => true,\n      (error: NodeJS.ErrnoException) => {\n        if (error.code === 'ENOENT') return false;\n        throw error;\n      },\n    )\n  )\n    return { status: 'already-migrated', copied: [], skipped: [] };\n  const legacy = legacyPoHomeDirectory(homeDirectory);\n  if (\n    path.resolve(legacy) === path.resolve(poHome) ||\n    !(await fs.access(legacy).then(\n      () => true,\n      (error: NodeJS.ErrnoException) => {\n        if (error.code === 'ENOENT') return false;\n        throw error;\n      },\n    ))\n  ) {\n    return { status: 'nothing-to-migrate', copied: [], skipped: [] };\n  }\n  await fs.mkdir(poHome, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n  const copied: string[] = [];\n  const skipped: string[] = [];\n  // Plans lived beside ~/.pi/.po, at ~/.pi/plans, and now default to <po home>/plans.\n  const sources = [\n    ...COPIED_ENTRIES.map((entry) => ({ entry, source: path.join(legacy, entry) })),\n    { entry: LEGACY_PLANS_DIRECTORY, source: path.join(homeDirectory, '.pi', LEGACY_PLANS_DIRECTORY) },\n  ];\n  for (const { entry, source } of sources) {\n    if (\n      !(await fs.access(source).then(\n        () => true,\n        (error: NodeJS.ErrnoException) => {\n          if (error.code === 'ENOENT') return false;\n          throw error;\n        },\n      ))\n    )\n      continue;\n    const target = path.join(poHome, entry);\n    if (\n      await fs.access(target).then(\n        () => true,\n        (error: NodeJS.ErrnoException) => {\n          if (error.code === 'ENOENT') return false;\n          throw error;\n        },\n      )\n    ) {\n      skipped.push(entry);\n      continue;\n    }\n    await fs.mkdir(path.dirname(target), { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n    await fs.cp(source, target, { recursive: true, errorOnExist: true, force: false, preserveTimestamps: true });\n    copied.push(entry);\n  }\n  await fs.writeFile(\n    marker,\n    `${JSON.stringify({ version: MARKER_VERSION, from: legacy, migratedAt: new Date().toISOString(), copied, skipped }, null, 2)}\\n`,\n    { mode: 0o600 },\n  );\n  return { status: 'migrated', copied, skipped };\n}\n\n/** Records this host in the Po home's registry until the returned release runs. */\nexport async function registerPoHost(poHome: string, pid: number = process.pid): Promise<() => Promise<void>> {\n  const directory = path.join(poHome, HOSTS_DIRECTORY);\n  await fs.mkdir(directory, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });\n  const file = path.join(directory, `${HOST_RECORD_PREFIX}${String(pid)}.json`);\n  await fs.writeFile(file, `${JSON.stringify({ pid, startedAt: new Date().toISOString() })}\\n`, { mode: 0o600 });\n  return () => fs.rm(file, { force: true });\n}\n\n/** Pids of registered hosts; records of processes that are gone are ignored. */\nasync function registeredHostPids(poHome: string): Promise<Set<number>> {\n  const directory = path.join(poHome, HOSTS_DIRECTORY);\n  const pids = new Set<number>();\n  const entries = await fs.readdir(directory).catch((error: NodeJS.ErrnoException) => {\n    if (error.code === 'ENOENT') return [];\n    throw error;\n  });\n  for (const name of entries) {\n    const match = new RegExp(`^${HOST_RECORD_PREFIX}(\\\\d+)\\\\.json$`, 'u').exec(name);\n    if (match?.[1]) pids.add(Number(match[1]));\n  }\n  return pids;\n}\n\nexport interface HostScan {\n  /** Every process's pid and command line. */\n  processes(): readonly { pid: number; command: string }[];\n  /** Pids listening on any of the ports. */\n  listeners(ports: readonly number[]): readonly number[];\n}\n\n/** `ps` and `lsof`, as macOS and Linux provide them. A missing tool throws, which defers deletion. */\nexport const systemHostScan: HostScan = {\n  processes() {\n    return execFileSync('ps', ['-axo', 'pid=,command='], { encoding: 'utf8' })\n      .split('\\n')\n      .map((line) => /^\\s*(\\d+)\\s+(.*)$/u.exec(line))\n      .filter((match): match is RegExpExecArray => match !== null)\n      .map((match) => ({ pid: Number(match[1]), command: match[2]! }));\n  },\n  listeners(ports) {\n    const args = ['-nP', '-sTCP:LISTEN', '-t', ...ports.map((port) => `-iTCP:${String(port)}`)];\n    let output: string;\n    try {\n      output = execFileSync('lsof', args, { encoding: 'utf8' });\n    } catch (error) {\n      // lsof exits 1 when any one port has no listener, even when another port has one;\n      // its output still lists the pids it found. Any other status is a real failure.\n      const status = (error as { status?: number }).status;\n      if (status !== 1) throw error;\n      output = (error as { stdout?: string }).stdout ?? '';\n    }\n    return output\n      .split('\\n')\n      .map((line) => Number(line.trim()))\n      .filter((pid) => Number.isInteger(pid) && pid > 0);\n  },\n};\n\n/**\n * One scan for Po hosts: `hosts` holds every process running a Po host entry and every\n * listener on a Po host port, registered or not; `live` holds every pid that exists.\n * A scan that cannot run throws.\n */\nfunction scanPoHosts(scan: HostScan): { hosts: number[]; live: Set<number> } {\n  const processes = scan.processes();\n  return {\n    hosts: [\n      ...processes.filter((entry) => PO_HOST_COMMAND.test(entry.command)).map((entry) => entry.pid),\n      ...scan.listeners(LEGACY_HOST_PORTS),\n    ],\n    live: new Set(processes.map((entry) => entry.pid)),\n  };\n}\n\nexport type OtherPoHosts = { status: 'none' } | { status: 'running'; reason: string };\n\n/**\n * Whether any Po host other than this process runs: the scan of 4c's retirement, plus\n * registered hosts whose process still exists (a host run from source has no `dist` entry\n * to match). A scan that fails counts as running, so a caller acting on \"none\" never\n * acts on a guess.\n */\nexport async function otherPoHosts(\n  poHome: string,\n  scan: HostScan = systemHostScan,\n  selfPid: number = process.pid,\n): Promise<OtherPoHosts> {\n  let others: number[];\n  try {\n    const { hosts, live } = scanPoHosts(scan);\n    others = [...hosts, ...[...(await registeredHostPids(poHome))].filter((pid) => live.has(pid))].filter(\n      (pid) => pid !== selfPid,\n    );\n  } catch (error) {\n    return { status: 'running', reason: `host scan failed: ${error instanceof Error ? error.message : String(error)}` };\n  }\n  return others.length === 0\n    ? { status: 'none' }\n    : { status: 'running', reason: `other Po processes run: ${[...new Set(others)].join(', ')}` };\n}\n\nexport type LegacyRetirement =\n  | { status: 'removed' | 'absent' | 'not-migrated' }\n  | { status: 'deferred'; reason: string };\n\n/**\n * Deletes `~/.pi/.po` once nothing can still be using it.\n *\n * An older host is any Po process, or any listener on the old ports, that is not in the\n * registry: registered hosts are new and use the Po home. Only after the migration ran,\n * and only when the scan itself succeeded and found no older host; otherwise the next\n * start tries again. The directory is never renamed.\n */\nexport async function retireLegacyPoHome(\n  homeDirectory: string,\n  poHome: string,\n  scan: HostScan = systemHostScan,\n): Promise<LegacyRetirement> {\n  const legacy = legacyPoHomeDirectory(homeDirectory);\n  if (\n    path.resolve(legacy) === path.resolve(poHome) ||\n    !(await fs.access(legacy).then(\n      () => true,\n      (error: NodeJS.ErrnoException) => {\n        if (error.code === 'ENOENT') return false;\n        throw error;\n      },\n    ))\n  )\n    return { status: 'absent' };\n  if (\n    !(await fs.access(path.join(poHome, MARKER_FILE)).then(\n      () => true,\n      (error: NodeJS.ErrnoException) => {\n        if (error.code === 'ENOENT') return false;\n        throw error;\n      },\n    ))\n  )\n    return { status: 'not-migrated' };\n  const registered = await registeredHostPids(poHome);\n  let older: number[];\n  try {\n    older = scanPoHosts(scan).hosts.filter((pid) => !registered.has(pid));\n  } catch (error) {\n    return {\n      status: 'deferred',\n      reason: `host scan failed: ${error instanceof Error ? error.message : String(error)}`,\n    };\n  }\n  if (older.length > 0) {\n    return { status: 'deferred', reason: `unregistered Po processes still run: ${[...new Set(older)].join(', ')}` };\n  }\n  await fs.rm(legacy, { recursive: true, force: true });\n  return { status: 'removed' };\n}\n"],"ignoreList":[0],"mappings":";;;;;;;;AAAA,SAAgB,GAAG,OAAO;CACtB,OAAO;EAAE,IAAI;EAAM;CAAM;AAC7B;AACA,SAAgB,IAAI,OAAO;CACvB,OAAO;EAAE,IAAI;EAAO;CAAM;AAC9B;AACA,SAAgB,WAAW,QAAQ;CAC/B,IAAI,CAAC,OAAO,IACR,MAAM,OAAO;CACjB,OAAO,OAAO;AAClB;AAIA,SAAgB,QAAQ,OAAO;CAC3B,IAAI,iBAAiB,OACjB,OAAO;CACX,IAAI,OAAO,UAAU,UACjB,OAAO,IAAI,MAAM,KAAK;CAC1B,IAAI;EACA,OA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