@serviceme/devtools-core 2.0.5 → 2.0.6

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolbox-BV7vLGXZ.js","names":["path","fsp","delay","getToolboxJsonPath"],"sources":["../src/toolbox/sort.ts","../src/toolbox/types.ts","../src/toolbox/ToolboxStore.ts","../src/toolbox/ToolboxCore.ts"],"sourcesContent":["/**\n * toolbox sort + dedup — pure helpers, no I/O.\n *\n * The Extension's `ToolBoxService` keeps a stable `order` index and\n * surfaces \"recently used\" via the `lastUsedAt` ISO timestamp. These\n * helpers codify that algorithm so the CLI and Extension agree on the\n * \"最近使用置顶\" UX.\n *\n * Refs:\n * - 4.功能规划.md §2.3 — `sort.ts 排序与去重纯函数`\n */\n\nimport type { ExternalTool } from \"@serviceme/devtools-protocol\";\n\n/**\n * Parsed timestamp from `lastUsedAt`. Returns 0 when the field is\n * missing or unparseable (so the entry falls below entries with a\n * real timestamp).\n */\nfunction lastUsedTimestamp(tool: ExternalTool): number {\n\tif (!tool.lastUsedAt) return 0;\n\tconst ms = Date.parse(tool.lastUsedAt);\n\treturn Number.isFinite(ms) ? ms : 0;\n}\n\n/**\n * Sort by \"recently used\" — entries with newer `lastUsedAt` float to\n * the top, entries with no `lastUsedAt` sort to the bottom (preserving\n * their relative `order` index when both are absent).\n *\n * Ties (same `lastUsedAt` or both missing) are broken by `order`, then\n * by `id` for determinism.\n */\nexport function sortByRecentFirst(tools: readonly ExternalTool[]): ExternalTool[] {\n\treturn [...tools].sort((a, b) => {\n\t\tconst tsA = lastUsedTimestamp(a);\n\t\tconst tsB = lastUsedTimestamp(b);\n\t\tif (tsA !== tsB) return tsB - tsA;\n\t\tconst orderA = a.order ?? Number.MAX_SAFE_INTEGER;\n\t\tconst orderB = b.order ?? Number.MAX_SAFE_INTEGER;\n\t\tif (orderA !== orderB) return orderA - orderB;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n}\n\n/**\n * Sort by user-defined `order` field. Entries without `order` are\n * appended in their input order (stable sort via `id` tiebreaker).\n */\nexport function sortByUserOrder(tools: readonly ExternalTool[]): ExternalTool[] {\n\treturn [...tools].sort((a, b) => {\n\t\tconst orderA = a.order ?? Number.MAX_SAFE_INTEGER;\n\t\tconst orderB = b.order ?? Number.MAX_SAFE_INTEGER;\n\t\tif (orderA !== orderB) return orderA - orderB;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n}\n\n/**\n * Deduplicate by `id`. The first occurrence wins; later ones are\n * discarded. Used when merging built-in + user seeds so duplicates\n * from the on-disk file don't shadow the built-in defaults.\n */\nexport function dedupeById(tools: readonly ExternalTool[]): ExternalTool[] {\n\tconst seen = new Set<string>();\n\tconst out: ExternalTool[] = [];\n\tfor (const tool of tools) {\n\t\tif (seen.has(tool.id)) continue;\n\t\tseen.add(tool.id);\n\t\tout.push(tool);\n\t}\n\treturn out;\n}\n\n/**\n * Merge built-in defaults with user-stored tools. Defaults keep\n * `isDefault: true` and their `order`; user tools are appended with\n * their stored metadata. Output is sorted by user order.\n */\nexport function mergeWithDefaults(\n\tdefaults: readonly ExternalTool[],\n\tuserTools: readonly ExternalTool[]\n): ExternalTool[] {\n\tconst defaultIds = new Set(defaults.map((d) => d.id));\n\tconst uniqueUserTools = userTools.filter((t) => !defaultIds.has(t.id));\n\treturn sortByUserOrder([...defaults, ...uniqueUserTools]);\n}\n\n/**\n * Re-number `order` for a list of tool ids. Used by\n * `toolbox.update` when the user drags-and-drops entries in the UI.\n */\nexport function reindexOrder(\n\ttools: ExternalTool[],\n\tnewOrderIds: readonly string[]\n): ExternalTool[] {\n\tconst orderMap = new Map<string, number>();\n\tfor (const [index, id] of newOrderIds.entries()) {\n\t\torderMap.set(id, index);\n\t}\n\tfor (const tool of tools) {\n\t\tconst next = orderMap.get(tool.id);\n\t\tif (next !== undefined) tool.order = next;\n\t}\n\treturn tools;\n}\n\n/**\n * Stamp `lastUsedAt` on the targeted tool (clones the array). Returns\n * a new array; the input is left untouched.\n */\nexport function touchLastUsedAt(\n\ttools: readonly ExternalTool[],\n\tid: string,\n\twhen: Date = new Date()\n): ExternalTool[] {\n\treturn tools.map((tool) => (tool.id === id ? { ...tool, lastUsedAt: when.toISOString() } : tool));\n}\n","/**\n * toolbox types — internal-only data shapes.\n *\n * The public data model lives in `@serviceme/devtools-protocol/toolbox`\n * (`ExternalTool`, `ToolboxScope`, `ToolboxList`). The types below are\n * the persisted on-disk shape and the patch helpers, scoped to the\n * toolbox domain only.\n *\n * Refs:\n * - 4.功能规划.md §2.3 — `toolbox/types.ts`\n */\n\nimport type { ExternalTool, ToolboxScope } from \"@serviceme/devtools-protocol\";\n\n/** Schema version of the on-disk toolbox JSON files. Bumped on breaking changes. */\nexport const TOOLBOX_JSON_SCHEMA_VERSION = 1;\n\nexport interface PersistedToolbox {\n\tversion: number;\n\ttools: ExternalTool[];\n}\n\n/** Patch payload accepted by `ToolboxCore.update` (mirrors `ExternalToolPatch`). */\nexport type ToolboxPatch = Partial<Omit<ExternalTool, \"id\" | \"isDefault\">>;\n\n/**\n * Built-in (default) tool seeds. Mirrors the Extension's\n * `apps/extension/src/config/external-tools.ts`. The Core stores these\n * verbatim and never mutates them — the Extension's `ToolBoxService`\n * runs the same merge on top of the Core's view.\n */\nexport interface DefaultToolSeed {\n\tid: string;\n\tname: string;\n\tdescription: string;\n\ticon: string;\n\turl: string;\n}\n\n/** Built-in tools rendered when the JSON file is missing or empty. */\nexport const BUILTIN_DEFAULT_TOOLS: readonly DefaultToolSeed[] = [\n\t{\n\t\tid: \"builtin-docs\",\n\t\tname: \"SERVICEME Docs\",\n\t\tdescription: \"Official documentation portal\",\n\t\ticon: \"book\",\n\t\turl: \"https://docs.medalsoft.com/serviceme\",\n\t},\n\t{\n\t\tid: \"builtin-issues\",\n\t\tname: \"Issue Tracker\",\n\t\tdescription: \"Report bugs and feature requests\",\n\t\ticon: \"bug\",\n\t\turl: \"https://github.com/medalsoftchina/ms-devtools-vscode/issues\",\n\t},\n\t{\n\t\tid: \"builtin-changelog\",\n\t\tname: \"Changelog\",\n\t\tdescription: \"Release notes for every published version\",\n\t\ticon: \"history\",\n\t\turl: \"https://github.com/medalsoftchina/ms-devtools-vscode/releases\",\n\t},\n];\n\n/** Resolved toolbox shape returned by `ToolboxStore.read()`. */\nexport interface ResolvedToolbox {\n\tscope: ToolboxScope;\n\ttools: ExternalTool[];\n}\n","/**\n * ToolboxStore — JSON persistence for the toolbox entries.\n *\n * Two scopes:\n * - `user` → `~/.serviceme/toolbox.json`\n * - `workspace` → `<cwd>/.github/.serviceme-toolbox.json`\n *\n * Both files share the `PersistedToolbox` shape and the same atomic\n * write pattern (tmp + rename + fsync) as `IdentityStore`. Concurrent\n * writers are serialized via a mkdir-based file lock (Phase 6+ may\n * upgrade to `proper-lockfile`).\n *\n * Refs:\n * - 4.功能规划.md §2.3 — `ToolboxStore.ts JSON 持久化(user + workspace scope)`\n * - `3.功能拆分.md` §3 — toolbox wire shape\n */\n\nimport * as fsp from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { setTimeout as delay } from \"node:timers/promises\";\n\nimport type { ExternalTool, ToolboxScope } from \"@serviceme/devtools-protocol\";\n\nimport { getToolboxJsonPath } from \"../paths/userHome\";\n\nimport { mergeWithDefaults, sortByUserOrder } from \"./sort\";\nimport {\n\tBUILTIN_DEFAULT_TOOLS,\n\ttype DefaultToolSeed,\n\ttype PersistedToolbox,\n\ttype ResolvedToolbox,\n\tTOOLBOX_JSON_SCHEMA_VERSION,\n} from \"./types\";\n\nconst FILE_MODE = 0o600;\nconst LOCK_DIR_MODE = 0o700;\nconst DEFAULT_LOCK_TIMEOUT_MS = 5000;\nconst DEFAULT_LOCK_RETRY_MS = 25;\n// `mkdir` (lock acquisition) and writing the pid file are two separate\n// syscalls, so there's a brief window where the lock dir exists but the\n// pid file doesn't yet. A grace period keeps a concurrent acquirer from\n// mistaking that window for an abandoned lock (see `isStaleLock`).\nconst LOCK_STALE_GRACE_MS = 200;\nconst TMP_SUFFIX = \".tmp\";\nexport const WORKSPACE_TOOLBOX_RELATIVE_PATH = path.join(\".github\", \".serviceme-toolbox.json\");\nconst LEGACY_WORKSPACE_TOOLBOX_FILENAME = \".ms-devtools-toolbox.json\";\n\n/**\n * One-time migration: the workspace-scope toolbox file used to be named\n * `.ms-devtools-toolbox.json`. If the new `.serviceme-toolbox.json` doesn't\n * exist yet but the legacy file does (in the same directory), rename it\n * forward so existing toolbox entries aren't silently lost.\n */\nasync function migrateLegacyWorkspaceToolboxFile(filePath: string | null): Promise<void> {\n\tif (!filePath) return;\n\tconst legacyPath = path.join(path.dirname(filePath), LEGACY_WORKSPACE_TOOLBOX_FILENAME);\n\tif (legacyPath === filePath) return;\n\ttry {\n\t\tawait fsp.access(filePath);\n\t\treturn;\n\t} catch {\n\t\t// new file missing — check the legacy path below\n\t}\n\ttry {\n\t\tawait fsp.rename(legacyPath, filePath);\n\t} catch {\n\t\t// legacy file doesn't exist either — nothing to migrate\n\t}\n}\n\nexport interface ToolboxFileBackend {\n\tread(filePath: string): Promise<PersistedToolbox | null>;\n\twrite(filePath: string, payload: PersistedToolbox): Promise<void>;\n\texists(filePath: string): Promise<boolean>;\n\t/** Maximum number of `.corrupted.*.bak` snapshots to keep per toolbox file (default: 5). */\n\tmaxBackupCount?: number;\n}\n\nexport interface ToolboxStoreOptions {\n\t/** Override the user-scope file path (default: `getToolboxJsonPath()`). */\n\tuserFilePath?: string;\n\t/** Override the workspace-scope file path resolver (default: cwd-relative). */\n\tresolveWorkspacePath?: () => string | null;\n\t/** Injectable built-in tool seeds (default: `BUILTIN_DEFAULT_TOOLS`). */\n\tdefaultTools?: readonly DefaultToolSeed[];\n\thooks?: ToolboxStoreHooks;\n\tbackend?: ToolboxFileBackend;\n\tlockTimeoutMs?: number;\n\tlockRetryMs?: number;\n}\n\nexport interface ToolboxStoreHooks {\n\tbeforeWrite?: (scope: ToolboxScope, payload: PersistedToolbox) => void | Promise<void>;\n\tafterWrite?: (scope: ToolboxScope, payload: PersistedToolbox) => void | Promise<void>;\n}\n\nexport class FsToolboxFileBackend implements ToolboxFileBackend {\n\tmaxBackupCount: number = 5;\n\n\tasync exists(filePath: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fsp.access(filePath);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tasync read(filePath: string): Promise<PersistedToolbox | null> {\n\t\tlet buf: string;\n\t\ttry {\n\t\t\tbuf = await fsp.readFile(filePath, \"utf8\");\n\t\t} catch (err) {\n\t\t\tif (isNodeError(err) && err.code === \"ENOENT\") return null;\n\t\t\tthrow err;\n\t\t}\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(buf) as unknown;\n\t\t\treturn coercePersistedToolbox(parsed);\n\t\t} catch {\n\t\t\t// File exists but is unparseable JSON or fails schema validation\n\t\t\t// (e.g. hand-edited, written by an older/incompatible schema, or\n\t\t\t// truncated by a crash). Quarantine it as a timestamped `.bak`\n\t\t\t// sibling and fall back to an empty toolbox (defaults still\n\t\t\t// merge in via `ToolboxStore.read()`) rather than crashing the\n\t\t\t// whole \"get external tools\" request.\n\t\t\tawait this.backupCorruptedFile(filePath);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate async backupCorruptedFile(filePath: string): Promise<void> {\n\t\ttry {\n\t\t\tconst backupPath = `${filePath}.corrupted.${Date.now()}.bak`;\n\t\t\tawait fsp.copyFile(filePath, backupPath);\n\t\t\tawait this.purgeExcessBackups(filePath);\n\t\t} catch {\n\t\t\t// Best-effort backup — never let backup failure mask the real recovery.\n\t\t}\n\t}\n\n\tprivate async purgeExcessBackups(filePath: string): Promise<void> {\n\t\tconst dir = path.dirname(filePath);\n\t\tconst base = path.basename(filePath);\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = await fsp.readdir(dir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tconst backups = entries\n\t\t\t.filter((n) => n.startsWith(base) && n.endsWith(\".bak\"))\n\t\t\t.map((n) => ({ name: n, filePath: path.join(dir, n) }))\n\t\t\t.sort((a, b) => {\n\t\t\t\t// Sort oldest-first so we drop the earliest ones first.\n\t\t\t\treturn a.name.localeCompare(b.name);\n\t\t\t});\n\t\tconst excess = backups.length - this.maxBackupCount;\n\t\tif (excess <= 0) return;\n\t\tawait Promise.all(\n\t\t\tbackups.slice(0, excess).map((b) => fsp.rm(b.filePath).catch(() => undefined))\n\t\t);\n\t}\n\n\tasync write(filePath: string, payload: PersistedToolbox): Promise<void> {\n\t\tawait fsp.mkdir(path.dirname(filePath), { recursive: true });\n\t\tconst tmpPath = `${filePath}${TMP_SUFFIX}`;\n\t\tconst bytes = Buffer.from(JSON.stringify(payload, null, \"\\t\"), \"utf8\");\n\t\tawait fsp.rm(tmpPath, { force: true });\n\t\tconst handle = await fsp.open(tmpPath, \"w\", FILE_MODE);\n\t\ttry {\n\t\t\tawait handle.writeFile(bytes);\n\t\t\tawait handle.sync();\n\t\t} finally {\n\t\t\tawait handle.close();\n\t\t}\n\t\tawait fsp.rename(tmpPath, filePath);\n\t\tawait fsp.chmod(filePath, FILE_MODE).catch(() => undefined);\n\t}\n}\n\nfunction coercePersistedToolbox(parsed: unknown): PersistedToolbox {\n\tif (typeof parsed !== \"object\" || parsed === null) {\n\t\tthrow new Error(\"toolbox.json: top-level must be an object\");\n\t}\n\tconst obj = parsed as Record<string, unknown>;\n\tconst version = obj.version;\n\tif (version !== TOOLBOX_JSON_SCHEMA_VERSION) {\n\t\tthrow new Error(`toolbox.json: unsupported schema version ${String(version)}`);\n\t}\n\tif (!Array.isArray(obj.tools)) {\n\t\tthrow new Error(\"toolbox.json: 'tools' must be an array\");\n\t}\n\treturn { version, tools: obj.tools as ExternalTool[] };\n}\n\nfunction isNodeError(value: unknown): value is NodeJS.ErrnoException {\n\treturn value instanceof Error && typeof (value as { code?: unknown }).code === \"string\";\n}\n\nfunction isProcessAlive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nclass ToolboxFileLock {\n\tprivate readonly dirPath: string;\n\tprivate readonly pidFilePath: string;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly retryMs: number;\n\tprivate acquired = false;\n\n\tconstructor(filePath: string, timeoutMs: number, retryMs: number) {\n\t\tthis.dirPath = `${filePath}.lock`;\n\t\tthis.pidFilePath = path.join(this.dirPath, \"pid\");\n\t\tthis.timeoutMs = timeoutMs;\n\t\tthis.retryMs = retryMs;\n\t}\n\n\tasync acquire(): Promise<void> {\n\t\tconst start = Date.now();\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tawait fsp.mkdir(this.dirPath, { mode: LOCK_DIR_MODE });\n\t\t\t\tawait fsp.writeFile(this.pidFilePath, String(process.pid), \"utf8\").catch(() => undefined);\n\t\t\t\tthis.acquired = true;\n\t\t\t\treturn;\n\t\t\t} catch (err) {\n\t\t\t\tif (!isNodeError(err) || err.code !== \"EEXIST\") throw err;\n\t\t\t\tconst stale = await this.isStaleLock();\n\t\t\t\tif (stale) {\n\t\t\t\t\tawait fsp.rm(this.dirPath, { recursive: true, force: true });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (Date.now() - start >= this.timeoutMs) {\n\t\t\t\t\tthrow new Error(`ToolboxStore lock acquisition timed out for ${this.dirPath}`);\n\t\t\t\t}\n\t\t\t\tawait delay(this.retryMs);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async isStaleLock(): Promise<boolean> {\n\t\tlet pidStr: string;\n\t\ttry {\n\t\t\tpidStr = await fsp.readFile(this.pidFilePath, \"utf8\");\n\t\t} catch {\n\t\t\t// The pid file may not exist yet because another acquirer just\n\t\t\t// created the lock dir and hasn't finished writing its pid file\n\t\t\t// (mkdir + writeFile is not atomic). Give it a short grace window\n\t\t\t// before concluding the owner crashed between mkdir and writeFile.\n\t\t\ttry {\n\t\t\t\tconst stat = await fsp.stat(this.dirPath);\n\t\t\t\treturn Date.now() - stat.mtimeMs > LOCK_STALE_GRACE_MS;\n\t\t\t} catch {\n\t\t\t\t// Lock dir disappeared concurrently (e.g. released mid-check) —\n\t\t\t\t// not stale, just gone; the caller's next mkdir will succeed.\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tconst pid = Number.parseInt(pidStr.trim(), 10);\n\t\tif (!Number.isFinite(pid) || pid <= 0) return true;\n\t\treturn !isProcessAlive(pid);\n\t}\n\n\tasync release(): Promise<void> {\n\t\tif (!this.acquired) return;\n\t\tthis.acquired = false;\n\t\tawait fsp.rm(this.dirPath, { recursive: true, force: true });\n\t}\n}\n\nfunction defaultWorkspacePath(): string | null {\n\t// The store caller (ToolboxCore) supplies a cwd, but tests want a\n\t// stable default. Return null when the env var says \"no workspace\".\n\tif (process.env.SERVICEME_NO_WORKSPACE_TOOLBOX === \"1\") return null;\n\treturn path.join(process.cwd(), WORKSPACE_TOOLBOX_RELATIVE_PATH);\n}\n\nexport class ToolboxStore {\n\tprivate readonly userFilePath: string;\n\tprivate readonly resolveWorkspacePath: () => string | null;\n\tprivate readonly defaults: readonly DefaultToolSeed[];\n\tprivate readonly hooks: ToolboxStoreHooks;\n\tprivate readonly backend: ToolboxFileBackend;\n\tprivate readonly lockTimeoutMs: number;\n\tprivate readonly lockRetryMs: number;\n\n\tconstructor(opts: ToolboxStoreOptions = {}) {\n\t\tthis.userFilePath = opts.userFilePath ?? getToolboxJsonPath();\n\t\tthis.resolveWorkspacePath = opts.resolveWorkspacePath ?? defaultWorkspacePath;\n\t\tthis.defaults = opts.defaultTools ?? BUILTIN_DEFAULT_TOOLS;\n\t\tthis.hooks = opts.hooks ?? {};\n\t\tthis.backend = opts.backend ?? new FsToolboxFileBackend();\n\t\tthis.lockTimeoutMs = opts.lockTimeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS;\n\t\tthis.lockRetryMs = opts.lockRetryMs ?? DEFAULT_LOCK_RETRY_MS;\n\t}\n\n\t/** Read a scope; returns the resolved toolbox (with defaults merged when empty). */\n\tasync read(scope: ToolboxScope): Promise<ResolvedToolbox> {\n\t\tconst filePath = this.filePathFor(scope);\n\t\tif (scope === \"workspace\") {\n\t\t\tawait migrateLegacyWorkspaceToolboxFile(filePath);\n\t\t}\n\t\tconst stored = filePath ? await this.backend.read(filePath) : null;\n\t\tconst storedTools = stored?.tools ?? [];\n\t\tconst defaults = this.defaults.map((seed, index) => toDefaultTool(seed, index));\n\t\tconst merged = mergeWithDefaults(defaults, storedTools);\n\t\tconst userOnly = storedTools.filter((t) => !this.defaults.some((d) => d.id === t.id));\n\t\tvoid userOnly;\n\t\treturn { scope, tools: merged };\n\t}\n\n\t/**\n\t * Atomic write under a file lock. Replaces the entire `tools` array\n\t * with the provided snapshot.\n\t */\n\tasync write(scope: ToolboxScope, tools: readonly ExternalTool[]): Promise<void> {\n\t\tconst filePath = this.filePathFor(scope);\n\t\tif (!filePath) {\n\t\t\tthrow new Error(`Cannot write toolbox scope '${scope}': file path is unavailable`);\n\t\t}\n\t\tif (scope === \"workspace\") {\n\t\t\tawait migrateLegacyWorkspaceToolboxFile(filePath);\n\t\t}\n\t\tconst payload: PersistedToolbox = {\n\t\t\tversion: TOOLBOX_JSON_SCHEMA_VERSION,\n\t\t\ttools: sortByUserOrder([...tools]),\n\t\t};\n\t\tawait this.hooks.beforeWrite?.(scope, payload);\n\t\tconst lock = new ToolboxFileLock(filePath, this.lockTimeoutMs, this.lockRetryMs);\n\t\tawait lock.acquire();\n\t\ttry {\n\t\t\tawait this.backend.write(filePath, payload);\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t\tawait this.hooks.afterWrite?.(scope, payload);\n\t}\n\n\t/**\n\t * Read-modify-write under the file lock. The mutator receives the\n\t * current user-only list (defaults not included) and returns the\n\t * replacement list. Throwing inside the mutator aborts the write.\n\t */\n\tasync mutate(\n\t\tscope: ToolboxScope,\n\t\tmutator: (current: ExternalTool[]) => Promise<ExternalTool[]>\n\t): Promise<ExternalTool[]> {\n\t\tconst filePath = this.filePathFor(scope);\n\t\tif (!filePath) {\n\t\t\tthrow new Error(`Cannot mutate toolbox scope '${scope}': file path is unavailable`);\n\t\t}\n\t\tif (scope === \"workspace\") {\n\t\t\tawait migrateLegacyWorkspaceToolboxFile(filePath);\n\t\t}\n\t\tconst lock = new ToolboxFileLock(filePath, this.lockTimeoutMs, this.lockRetryMs);\n\t\tawait lock.acquire();\n\t\ttry {\n\t\t\tconst stored = await this.backend.read(filePath);\n\t\t\tconst storedTools = stored?.tools ?? [];\n\t\t\tconst defaultIds = new Set(this.defaults.map((d) => d.id));\n\t\t\tconst userTools = storedTools.filter((t) => !defaultIds.has(t.id));\n\t\t\tconst next = await mutator(userTools);\n\t\t\tconst payload: PersistedToolbox = {\n\t\t\t\tversion: TOOLBOX_JSON_SCHEMA_VERSION,\n\t\t\t\ttools: sortByUserOrder([...next]),\n\t\t\t};\n\t\t\tawait this.hooks.beforeWrite?.(scope, payload);\n\t\t\tawait this.backend.write(filePath, payload);\n\t\t\tawait this.hooks.afterWrite?.(scope, payload);\n\t\t\treturn next;\n\t\t} finally {\n\t\t\tawait lock.release();\n\t\t}\n\t}\n\n\t/** Wipe a scope entirely (used by `toolbox.remove --all` extensions). */\n\tasync clear(scope: ToolboxScope): Promise<void> {\n\t\tconst filePath = this.filePathFor(scope);\n\t\tif (!filePath) return;\n\t\tawait fsp.rm(filePath, { force: true });\n\t}\n\n\t/** Test seam — resolve the user-scope file path. */\n\tgetUserFilePath(): string {\n\t\treturn this.userFilePath;\n\t}\n\n\t/** Test seam — resolve the workspace-scope file path (or null when disabled). */\n\tgetWorkspaceFilePath(): string | null {\n\t\treturn this.resolveWorkspacePath();\n\t}\n\n\tprivate filePathFor(scope: ToolboxScope): string | null {\n\t\treturn scope === \"user\" ? this.userFilePath : this.resolveWorkspacePath();\n\t}\n}\n\nfunction toDefaultTool(seed: DefaultToolSeed, order: number): ExternalTool {\n\treturn {\n\t\tid: seed.id,\n\t\tname: seed.name,\n\t\tdescription: seed.description,\n\t\ticon: seed.icon,\n\t\turl: seed.url,\n\t\tisDefault: true,\n\t\torder,\n\t\tscope: \"user\",\n\t};\n}\n","/**\n * ToolboxCore — Main entry for the toolbox domain.\n *\n * Orchestrates the user + workspace scopes via `ToolboxStore`, applies\n * the \"最近使用置顶\" sort, and exposes a small surface that mirrors\n * the Phase 5.1 bridge methods:\n *\n * - `list(scope?)` → `toolbox.list`\n * - `add(tool, scope)` → `toolbox.add`\n * - `remove(id, scope?)` → `toolbox.remove`\n * - `update(id, patch, scope?)` → `toolbox.update`\n *\n * Default tools (built-in seeds) are never user-deletable. `remove()`\n * is a no-op for default tools and surfaces a structured error so\n * callers can map it to `TOOLBOX_DEFAULT_IMMUTABLE` (Phase 5.3 error\n * code).\n *\n * Refs:\n * - 4.功能规划.md §2.3 — `ToolboxCore.ts 主入口`\n * - `3.功能拆分.md` §3 — wire shape\n */\n\nimport type { ExternalTool, ToolboxList, ToolboxScope } from \"@serviceme/devtools-protocol\";\n\nimport { sortByRecentFirst, sortByUserOrder, touchLastUsedAt } from \"./sort\";\nimport { ToolboxStore } from \"./ToolboxStore\";\nimport { BUILTIN_DEFAULT_TOOLS, type DefaultToolSeed, type ToolboxPatch } from \"./types\";\n\n/** Sentinel — caller tried to remove a built-in (immutable) tool. */\nexport class DefaultToolImmutableError extends Error {\n\tconstructor(public readonly toolId: string) {\n\t\tsuper(`Cannot remove default toolbox entry: ${toolId}`);\n\t\tthis.name = \"DefaultToolImmutableError\";\n\t}\n}\n\nexport interface ToolboxCoreOptions {\n\tstore?: ToolboxStore;\n\tdefaultTools?: readonly DefaultToolSeed[];\n\t/** Sort applied to the merged list returned by `list()`. Default: `sortByUserOrder`. */\n\tlistSort?: (tools: readonly ExternalTool[]) => ExternalTool[];\n}\n\nexport class ToolboxCore {\n\tprivate readonly store: ToolboxStore;\n\tprivate readonly defaults: readonly DefaultToolSeed[];\n\tprivate readonly listSort: (tools: readonly ExternalTool[]) => ExternalTool[];\n\n\tconstructor(opts: ToolboxCoreOptions = {}) {\n\t\tthis.store = opts.store ?? new ToolboxStore();\n\t\tthis.defaults = opts.defaultTools ?? BUILTIN_DEFAULT_TOOLS;\n\t\tthis.listSort = opts.listSort ?? sortByUserOrder;\n\t}\n\n\t/** List all tools in a scope. Built-in defaults are merged in. */\n\tasync list(scope: ToolboxScope = \"user\"): Promise<ToolboxList> {\n\t\tconst resolved = await this.store.read(scope);\n\t\treturn {\n\t\t\tscope,\n\t\t\ttools: this.listSort(resolved.tools),\n\t\t};\n\t}\n\n\t/**\n\t * Append a new tool to the requested scope. Default tools are\n\t * rejected (they are seeds, not user entries).\n\t */\n\tasync add(tool: ExternalTool, scope: ToolboxScope = \"user\"): Promise<ToolboxList> {\n\t\tif (this.isDefaultId(tool.id)) {\n\t\t\tthrow new DefaultToolImmutableError(tool.id);\n\t\t}\n\t\tconst next = await this.store.mutate(scope, async (current) => {\n\t\t\tconst filtered = current.filter((t) => t.id !== tool.id);\n\t\t\treturn [\n\t\t\t\t...filtered,\n\t\t\t\t{\n\t\t\t\t\t...tool,\n\t\t\t\t\tscope,\n\t\t\t\t\tisDefault: false,\n\t\t\t\t\torder: tool.order ?? filtered.length,\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t\treturn { scope, tools: next };\n\t}\n\n\t/**\n\t * Remove a tool by id. Returns `success: false` when the id is a\n\t * built-in default (idempotent, never throws on missing entries).\n\t */\n\tasync remove(\n\t\tid: string,\n\t\tscope: ToolboxScope = \"user\"\n\t): Promise<{ scope: ToolboxScope; toolId: string; success: boolean }> {\n\t\tif (this.isDefaultId(id)) {\n\t\t\tthrow new DefaultToolImmutableError(id);\n\t\t}\n\t\tconst removed = await this.store.mutate(scope, async (current) =>\n\t\t\tcurrent.filter((t) => t.id !== id)\n\t\t);\n\t\treturn { scope, toolId: id, success: !removed.some((t) => t.id === id) };\n\t}\n\n\t/**\n\t * Patch a tool by id. Default tools can only have their `order`\n\t * updated; other patches are silently ignored for default entries\n\t * (callers can compare before/after to detect the ignore).\n\t */\n\tasync update(\n\t\tid: string,\n\t\tpatch: ToolboxPatch,\n\t\tscope: ToolboxScope = \"user\"\n\t): Promise<ToolboxList> {\n\t\tconst isDefault = this.isDefaultId(id);\n\t\tconst next = await this.store.mutate(scope, async (current) => {\n\t\t\tif (isDefault) {\n\t\t\t\t// Default tools are not stored on disk — silently ignore\n\t\t\t\t// non-order patches. The order field is also not persisted\n\t\t\t\t// (default order is set in memory at merge time), so the\n\t\t\t\t// caller can compare before/after to detect the ignore.\n\t\t\t\treturn current;\n\t\t\t}\n\t\t\treturn current.map((tool) =>\n\t\t\t\ttool.id === id ? { ...tool, ...patch, scope, isDefault: false } : tool\n\t\t\t);\n\t\t});\n\t\treturn { scope, tools: next };\n\t}\n\n\t/**\n\t * Stamp `lastUsedAt` on the targeted tool. This is the \"recently\n\t * used\" hook the Extension's webview uses when a user clicks a\n\t * toolbox entry.\n\t */\n\tasync recordUsage(\n\t\tid: string,\n\t\tscope: ToolboxScope = \"user\",\n\t\twhen: Date = new Date()\n\t): Promise<ExternalTool | null> {\n\t\tif (this.isDefaultId(id)) {\n\t\t\t// Defaults live in memory only — return a synthetic record so\n\t\t\t// callers can render the click without persisting anything.\n\t\t\tconst seed = this.defaults.find((d) => d.id === id);\n\t\t\tif (!seed) return null;\n\t\t\treturn { ...seed, scope, isDefault: true, order: 0, lastUsedAt: when.toISOString() };\n\t\t}\n\t\tlet updated: ExternalTool | null = null;\n\t\tawait this.store.mutate(scope, async (current) => {\n\t\t\tconst next = touchLastUsedAt(current, id, when);\n\t\t\tupdated = next.find((t) => t.id === id) ?? null;\n\t\t\treturn next;\n\t\t});\n\t\treturn updated;\n\t}\n\n\t/**\n\t * Combined view: user + workspace scopes merged, sorted by recent\n\t * usage. Workspace tools overlay user tools (workspace entries win\n\t * on `id` collision).\n\t */\n\tasync listMerged(): Promise<ToolboxList> {\n\t\tconst [user, workspace] = await Promise.all([\n\t\t\tthis.store.read(\"user\"),\n\t\t\tthis.store.read(\"workspace\"),\n\t\t]);\n\t\tconst seen = new Set<string>();\n\t\tconst merged: ExternalTool[] = [];\n\t\tfor (const tool of workspace.tools) {\n\t\t\tseen.add(tool.id);\n\t\t\tmerged.push({ ...tool, scope: \"workspace\" });\n\t\t}\n\t\tfor (const tool of user.tools) {\n\t\t\tif (seen.has(tool.id)) continue;\n\t\t\tmerged.push({ ...tool, scope: \"user\" });\n\t\t}\n\t\treturn { scope: \"user\", tools: sortByRecentFirst(merged) };\n\t}\n\n\t/** Expose the underlying store (CLI / Bridge use it for path-level access). */\n\tgetStore(): ToolboxStore {\n\t\treturn this.store;\n\t}\n\n\tprivate isDefaultId(id: string): boolean {\n\t\treturn this.defaults.some((d) => d.id === id);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAS,kBAAkB,MAA4B;CACtD,IAAI,CAAC,KAAK,YAAY,OAAO;CAC7B,MAAM,KAAK,KAAK,MAAM,KAAK,UAAU;CACrC,OAAO,OAAO,SAAS,EAAE,IAAI,KAAK;AACnC;;;;;;;;;AAUA,SAAgB,kBAAkB,OAAgD;CACjF,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM;EAChC,MAAM,MAAM,kBAAkB,CAAC;EAC/B,MAAM,MAAM,kBAAkB,CAAC;EAC/B,IAAI,QAAQ,KAAK,OAAO,MAAM;EAC9B,MAAM,SAAS,EAAE,SAAS,OAAO;EACjC,MAAM,SAAS,EAAE,SAAS,OAAO;EACjC,IAAI,WAAW,QAAQ,OAAO,SAAS;EACvC,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE;CAC/B,CAAC;AACF;;;;;AAMA,SAAgB,gBAAgB,OAAgD;CAC/E,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM;EAChC,MAAM,SAAS,EAAE,SAAS,OAAO;EACjC,MAAM,SAAS,EAAE,SAAS,OAAO;EACjC,IAAI,WAAW,QAAQ,OAAO,SAAS;EACvC,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C3C,OAAO;EACR,CAAC;EACD,OAAO;CACR;;;;;;CAOA,MAAM,aAAmC;EACxC,MAAM,CAAC,MAAM,aAAa,MAAM,QAAQ,IAAI,CAC3C,KAAK,MAAM,KAAK,MAAM,GACtB,KAAK,MAAM,KAAK,WAAW,CAC5B,CAAC;EACD,MAAM,uBAAO,IAAI,IAAY;EAC7B,MAAM,SAAyB,CAAC;EAChC,KAAK,MAAM,QAAQ,UAAU,OAAO;GACnC,KAAK,IAAI,KAAK,EAAE;GAChB,OAAO,KAAK;IAAE,GAAG;IAAM,OAAO;GAAY,CAAC;EAC5C;EACA,KAAK,MAAM,QAAQ,KAAK,OAAO;GAC9B,IAAI,KAAK,IAAI,KAAK,EAAE,GAAG;GACvB,OAAO,KAAK;IAAE,GAAG;IAAM,OAAO;GAAO,CAAC;EACvC;EACA,OAAO;GAAE,OAAO;GAAQ,OAAO,kBAAkB,MAAM;EAAE;CAC1D;;CAGA,WAAyB;EACxB,OAAO,KAAK;CACb;CAEA,YAAoB,IAAqB;EACxC,OAAO,KAAK,SAAS,MAAM,MAAM,EAAE,OAAO,EAAE;CAC7C;AACD"}
@@ -1,518 +0,0 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
2
- let node_path = require("node:path");
3
- node_path = require_rolldown_runtime.__toESM(node_path);
4
- let node_os = require("node:os");
5
- node_os = require_rolldown_runtime.__toESM(node_os);
6
- //#region src/paths/userHome.ts
7
- /**
8
- * SERVICEME user home directory helpers.
9
- *
10
- * All paths resolve under {@link getServicemeHome}, which is either the
11
- * `SERVICEME_HOME` environment variable (when set and non-empty) or
12
- * `$HOME/.serviceme` on POSIX / `%USERPROFILE%\.serviceme` on Windows.
13
- *
14
- * Tests inject `homeDir` and `servicemeHomeEnv` overrides via
15
- * {@link setUserHomeOverrides} / {@link resetUserHomeOverrides} so they can
16
- * exercise the path logic without touching the real user environment.
17
- */
18
- /** Layout constants — kept in one place so other modules can reuse them. */
19
- const SERVICEME_DIR_NAME = ".serviceme";
20
- const REPOS_SUBDIR = "repos";
21
- const CACHE_SUBDIR = "cache";
22
- const DRAFTS_SUBDIR = "drafts";
23
- const SKILL_DRAFTS_SUBDIR = "skills";
24
- const AGENT_DRAFTS_SUBDIR = "agents";
25
- const REPOS_CONFIG_FILENAME = "repos.json";
26
- const WORKSPACES_SUBDIR = "workspaces";
27
- const WORKSPACE_CONTENT_STATE_FILENAME = "copilot-content-state.json";
28
- /**
29
- * Repo id regex — used to validate any `repoId` argument before it is joined
30
- * into a filesystem path. Keeps path traversal attempts out and gives us a
31
- * predictable on-disk shape.
32
- */
33
- const SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
34
- /** Environment variable that overrides the user-home root directory. */
35
- const SERVICEME_HOME_ENV = "SERVICEME_HOME";
36
- let activeOverrides = {};
37
- function setUserHomeOverrides(overrides) {
38
- activeOverrides = { ...overrides };
39
- }
40
- function resetUserHomeOverrides() {
41
- activeOverrides = {};
42
- }
43
- function resolveHomeDir() {
44
- const injected = activeOverrides.homeDir;
45
- if (injected !== void 0) return injected;
46
- return node_os.homedir();
47
- }
48
- function resolveServicemeHomeEnv() {
49
- const injected = activeOverrides.servicemeHomeEnv;
50
- if (injected !== void 0) return injected.length > 0 ? injected : void 0;
51
- const envValue = process.env[SERVICEME_HOME_ENV];
52
- return envValue && envValue.length > 0 ? envValue : void 0;
53
- }
54
- function resolvePlatform() {
55
- return activeOverrides.platform ?? process.platform;
56
- }
57
- function assertSafeRepoId(repoId) {
58
- if (typeof repoId !== "string" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) throw new Error(`Invalid repo id: ${JSON.stringify(repoId)}. Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then alphanumerics / underscores / hyphens, ≤ 64 chars).`);
59
- return repoId;
60
- }
61
- /**
62
- * The raw OS home directory (`os.homedir()`), honoring test overrides
63
- * ({@link setUserHomeOverrides}). Exported for callers that need a
64
- * home-relative path *outside* of `~/.serviceme` — e.g. the
65
- * `~/.agents/{skills,agents}` convention used by `SkillLinker` for
66
- * user-scope links.
67
- */
68
- function getHomeDir() {
69
- return resolveHomeDir();
70
- }
71
- /**
72
- * Root directory for all SERVICEME user-level state. Resolves to
73
- * `${SERVICEME_HOME}` when that env var is set, otherwise `${HOME}/.serviceme`
74
- * (POSIX) or `%USERPROFILE%\.serviceme` (Windows via `os.homedir`).
75
- */
76
- function getServicemeHome() {
77
- const override = resolveServicemeHomeEnv();
78
- if (override !== void 0) return node_path.resolve(override);
79
- return node_path.join(resolveHomeDir(), SERVICEME_DIR_NAME);
80
- }
81
- /** `$HOME/.serviceme/repos` (or `${SERVICEME_HOME}/repos`). */
82
- function getReposDir() {
83
- return node_path.join(getServicemeHome(), REPOS_SUBDIR);
84
- }
85
- /** `$HOME/.serviceme/repos/<repoId>` — validates `repoId` first. */
86
- function getRepoDir(repoId) {
87
- return node_path.join(getReposDir(), assertSafeRepoId(repoId));
88
- }
89
- /** `$HOME/.serviceme/cache` — generic per-user cache. */
90
- function getCacheDir() {
91
- return node_path.join(getServicemeHome(), CACHE_SUBDIR);
92
- }
93
- /** `$HOME/.serviceme/cache/<repoId>` — per-repo sync state lives here. */
94
- function getRepoCacheDir(repoId) {
95
- return node_path.join(getCacheDir(), assertSafeRepoId(repoId));
96
- }
97
- /** `$HOME/.serviceme/drafts` — local edits not yet pushed upstream. */
98
- function getDraftsDir() {
99
- return node_path.join(getServicemeHome(), DRAFTS_SUBDIR);
100
- }
101
- /** `$HOME/.serviceme/drafts/skills` — local skill drafts. */
102
- function getSkillDraftsDir() {
103
- return node_path.join(getDraftsDir(), SKILL_DRAFTS_SUBDIR);
104
- }
105
- /** `$HOME/.serviceme/drafts/agents` — local agent drafts. */
106
- function getAgentDraftsDir() {
107
- return node_path.join(getDraftsDir(), AGENT_DRAFTS_SUBDIR);
108
- }
109
- /**
110
- * `$HOME/.serviceme/repos.json` — the single config entry point for repo
111
- * metadata. Always under the resolved home root (i.e. follows
112
- * `SERVICEME_HOME` overrides too).
113
- */
114
- function getReposConfigPath() {
115
- return node_path.join(getServicemeHome(), REPOS_CONFIG_FILENAME);
116
- }
117
- /** `~/.serviceme/workspaces` — machine-local per-workspace state root. */
118
- function getWorkspacesDir() {
119
- return node_path.join(getServicemeHome(), WORKSPACES_SUBDIR);
120
- }
121
- /**
122
- * Convenience helper for callers that need to switch behaviour on platform
123
- * (e.g. `SkillLinker` chooses symlink vs junction). Exported mostly so tests
124
- * can pin the value without touching `process.platform` directly.
125
- */
126
- function getHomePlatform() {
127
- return resolvePlatform();
128
- }
129
- /** Layout constants for scheduled-tasks files. Kept here so other modules
130
- * can reuse them and the names stay in sync with the design doc. */
131
- const SCHEDULED_TASKS_CONFIG_FILENAME = "scheduled-tasks.json";
132
- const SCHEDULED_TASKS_LOG_FILENAME = "scheduled-tasks-log.json";
133
- const SCHEDULER_PID_FILENAME = "scheduler.pid";
134
- const SCHEDULER_LOCK_FILENAME = "scheduler.lock";
135
- const SCHEDULER_LOG_FILENAME = "scheduler.log";
136
- const MIGRATION_FAILURES_FILENAME = "migration-failures.json";
137
- const KNOWN_WORKSPACES_FILENAME = "known-workspaces.json";
138
- /** `~/.serviceme/scheduled-tasks.json` — the global v2 task list. */
139
- function getScheduledTasksConfigPath() {
140
- return node_path.join(getServicemeHome(), SCHEDULED_TASKS_CONFIG_FILENAME);
141
- }
142
- /** `~/.serviceme/scheduled-tasks-log.json` — the global execution log (200 LRU). */
143
- function getScheduledTasksLogPath() {
144
- return node_path.join(getServicemeHome(), SCHEDULED_TASKS_LOG_FILENAME);
145
- }
146
- /** `~/.serviceme/scheduler.pid` — global daemon PID file. */
147
- function getSchedulerPidPath() {
148
- return node_path.join(getServicemeHome(), SCHEDULER_PID_FILENAME);
149
- }
150
- /** `~/.serviceme/scheduler.lock` — global daemon startup flock. */
151
- function getSchedulerLockPath() {
152
- return node_path.join(getServicemeHome(), SCHEDULER_LOCK_FILENAME);
153
- }
154
- /** `~/.serviceme/scheduler.log` — global daemon log (daemon lifecycle, not task execution). */
155
- function getSchedulerLogPath() {
156
- return node_path.join(getServicemeHome(), SCHEDULER_LOG_FILENAME);
157
- }
158
- /** `~/.serviceme/migration-failures.json` — diagnostics for failed v1→v2 imports. */
159
- function getMigrationFailuresPath() {
160
- return node_path.join(getServicemeHome(), MIGRATION_FAILURES_FILENAME);
161
- }
162
- /** `~/.serviceme/known-workspaces.json` — workspace list the extension has seen. */
163
- function getKnownWorkspacesPath() {
164
- return node_path.join(getServicemeHome(), KNOWN_WORKSPACES_FILENAME);
165
- }
166
- /**
167
- * `~/.serviceme/server-proxy.json` — r7 BYOM Server Proxy toggle
168
- * self-state. Written by the extension's `ProxyConfigService`, readable
169
- * by the CLI / Server so they can decide whether to route traffic
170
- * through the corporate proxy without booting VS Code.
171
- *
172
- * Lives under user-level `~/.serviceme/` (not under a workspace) because
173
- * the toggle is a *user preference* — the same human enabling it on
174
- * machine A should be able to rely on it on machine B after sync, not
175
- * have it disappear when they switch repos.
176
- */
177
- function getServerProxyGlobalPath() {
178
- return node_path.join(getServicemeHome(), SERVER_PROXY_GLOBAL_FILENAME);
179
- }
180
- /** Layout constants for the Phase 5 client-side state files. The server
181
- * already has the corresponding routes (`/api/v1/auth/...`,
182
- * `/api/v1/device/...`, etc.) — the client just needs the on-disk
183
- * file paths + a first-run bootstrap so the auth/device/toolbox
184
- * services can open + read them without a per-call existence check. */
185
- const CREDENTIALS_CONFIG_FILENAME = "credentials.json";
186
- const DEVICE_JSON_FILENAME = "device.json";
187
- const TOOLBOX_JSON_FILENAME = "toolbox.json";
188
- const MACHINE_ID_FILENAME = "machine-id";
189
- const PROFILES_JSON_FILENAME = "profiles.json";
190
- /** `~/.serviceme/credentials.json` — better-auth session tokens + refresh state (client-side cache). */
191
- function getCredentialsConfigPath() {
192
- return node_path.join(getServicemeHome(), CREDENTIALS_CONFIG_FILENAME);
193
- }
194
- /** `~/.serviceme/device.json` — device enrollment payload (id, public key fingerprint, claimed-by). */
195
- function getDeviceJsonPath() {
196
- return node_path.join(getServicemeHome(), DEVICE_JSON_FILENAME);
197
- }
198
- /** `~/.serviceme/toolbox.json` — local toolbox state (installed tool refs, per-user prefs). */
199
- function getToolboxJsonPath() {
200
- return node_path.join(getServicemeHome(), TOOLBOX_JSON_FILENAME);
201
- }
202
- /** `~/.serviceme/machine-id` — opaque stable per-install id (uuid v4 string, no JSON wrapper). */
203
- function getMachineIdPath() {
204
- return node_path.join(getServicemeHome(), MACHINE_ID_FILENAME);
205
- }
206
- /** `~/.serviceme/profiles.json` — cached projection of server-side profile rows; refresh on demand. */
207
- function getProfilesJsonPath() {
208
- return node_path.join(getServicemeHome(), PROFILES_JSON_FILENAME);
209
- }
210
- //#endregion
211
- Object.defineProperty(exports, "AGENT_DRAFTS_SUBDIR", {
212
- enumerable: true,
213
- get: function() {
214
- return AGENT_DRAFTS_SUBDIR;
215
- }
216
- });
217
- Object.defineProperty(exports, "CACHE_SUBDIR", {
218
- enumerable: true,
219
- get: function() {
220
- return CACHE_SUBDIR;
221
- }
222
- });
223
- Object.defineProperty(exports, "CREDENTIALS_CONFIG_FILENAME", {
224
- enumerable: true,
225
- get: function() {
226
- return CREDENTIALS_CONFIG_FILENAME;
227
- }
228
- });
229
- Object.defineProperty(exports, "DEVICE_JSON_FILENAME", {
230
- enumerable: true,
231
- get: function() {
232
- return DEVICE_JSON_FILENAME;
233
- }
234
- });
235
- Object.defineProperty(exports, "DRAFTS_SUBDIR", {
236
- enumerable: true,
237
- get: function() {
238
- return DRAFTS_SUBDIR;
239
- }
240
- });
241
- Object.defineProperty(exports, "KNOWN_WORKSPACES_FILENAME", {
242
- enumerable: true,
243
- get: function() {
244
- return KNOWN_WORKSPACES_FILENAME;
245
- }
246
- });
247
- Object.defineProperty(exports, "MACHINE_ID_FILENAME", {
248
- enumerable: true,
249
- get: function() {
250
- return MACHINE_ID_FILENAME;
251
- }
252
- });
253
- Object.defineProperty(exports, "MIGRATION_FAILURES_FILENAME", {
254
- enumerable: true,
255
- get: function() {
256
- return MIGRATION_FAILURES_FILENAME;
257
- }
258
- });
259
- Object.defineProperty(exports, "PROFILES_JSON_FILENAME", {
260
- enumerable: true,
261
- get: function() {
262
- return PROFILES_JSON_FILENAME;
263
- }
264
- });
265
- Object.defineProperty(exports, "REPOS_CONFIG_FILENAME", {
266
- enumerable: true,
267
- get: function() {
268
- return REPOS_CONFIG_FILENAME;
269
- }
270
- });
271
- Object.defineProperty(exports, "REPOS_SUBDIR", {
272
- enumerable: true,
273
- get: function() {
274
- return REPOS_SUBDIR;
275
- }
276
- });
277
- Object.defineProperty(exports, "SAFE_REPO_ID_PATTERN", {
278
- enumerable: true,
279
- get: function() {
280
- return SAFE_REPO_ID_PATTERN;
281
- }
282
- });
283
- Object.defineProperty(exports, "SCHEDULED_TASKS_CONFIG_FILENAME", {
284
- enumerable: true,
285
- get: function() {
286
- return SCHEDULED_TASKS_CONFIG_FILENAME;
287
- }
288
- });
289
- Object.defineProperty(exports, "SCHEDULED_TASKS_LOG_FILENAME", {
290
- enumerable: true,
291
- get: function() {
292
- return SCHEDULED_TASKS_LOG_FILENAME;
293
- }
294
- });
295
- Object.defineProperty(exports, "SCHEDULER_LOCK_FILENAME", {
296
- enumerable: true,
297
- get: function() {
298
- return SCHEDULER_LOCK_FILENAME;
299
- }
300
- });
301
- Object.defineProperty(exports, "SCHEDULER_LOG_FILENAME", {
302
- enumerable: true,
303
- get: function() {
304
- return SCHEDULER_LOG_FILENAME;
305
- }
306
- });
307
- Object.defineProperty(exports, "SCHEDULER_PID_FILENAME", {
308
- enumerable: true,
309
- get: function() {
310
- return SCHEDULER_PID_FILENAME;
311
- }
312
- });
313
- Object.defineProperty(exports, "SERVICEME_DIR_NAME", {
314
- enumerable: true,
315
- get: function() {
316
- return SERVICEME_DIR_NAME;
317
- }
318
- });
319
- Object.defineProperty(exports, "SERVICEME_HOME_ENV", {
320
- enumerable: true,
321
- get: function() {
322
- return SERVICEME_HOME_ENV;
323
- }
324
- });
325
- Object.defineProperty(exports, "SKILL_DRAFTS_SUBDIR", {
326
- enumerable: true,
327
- get: function() {
328
- return SKILL_DRAFTS_SUBDIR;
329
- }
330
- });
331
- Object.defineProperty(exports, "TOOLBOX_JSON_FILENAME", {
332
- enumerable: true,
333
- get: function() {
334
- return TOOLBOX_JSON_FILENAME;
335
- }
336
- });
337
- Object.defineProperty(exports, "WORKSPACES_SUBDIR", {
338
- enumerable: true,
339
- get: function() {
340
- return WORKSPACES_SUBDIR;
341
- }
342
- });
343
- Object.defineProperty(exports, "WORKSPACE_CONTENT_STATE_FILENAME", {
344
- enumerable: true,
345
- get: function() {
346
- return WORKSPACE_CONTENT_STATE_FILENAME;
347
- }
348
- });
349
- Object.defineProperty(exports, "assertSafeRepoId", {
350
- enumerable: true,
351
- get: function() {
352
- return assertSafeRepoId;
353
- }
354
- });
355
- Object.defineProperty(exports, "getAgentDraftsDir", {
356
- enumerable: true,
357
- get: function() {
358
- return getAgentDraftsDir;
359
- }
360
- });
361
- Object.defineProperty(exports, "getCacheDir", {
362
- enumerable: true,
363
- get: function() {
364
- return getCacheDir;
365
- }
366
- });
367
- Object.defineProperty(exports, "getCredentialsConfigPath", {
368
- enumerable: true,
369
- get: function() {
370
- return getCredentialsConfigPath;
371
- }
372
- });
373
- Object.defineProperty(exports, "getDeviceJsonPath", {
374
- enumerable: true,
375
- get: function() {
376
- return getDeviceJsonPath;
377
- }
378
- });
379
- Object.defineProperty(exports, "getDraftsDir", {
380
- enumerable: true,
381
- get: function() {
382
- return getDraftsDir;
383
- }
384
- });
385
- Object.defineProperty(exports, "getHomeDir", {
386
- enumerable: true,
387
- get: function() {
388
- return getHomeDir;
389
- }
390
- });
391
- Object.defineProperty(exports, "getHomePlatform", {
392
- enumerable: true,
393
- get: function() {
394
- return getHomePlatform;
395
- }
396
- });
397
- Object.defineProperty(exports, "getKnownWorkspacesPath", {
398
- enumerable: true,
399
- get: function() {
400
- return getKnownWorkspacesPath;
401
- }
402
- });
403
- Object.defineProperty(exports, "getMachineIdPath", {
404
- enumerable: true,
405
- get: function() {
406
- return getMachineIdPath;
407
- }
408
- });
409
- Object.defineProperty(exports, "getMigrationFailuresPath", {
410
- enumerable: true,
411
- get: function() {
412
- return getMigrationFailuresPath;
413
- }
414
- });
415
- Object.defineProperty(exports, "getProfilesJsonPath", {
416
- enumerable: true,
417
- get: function() {
418
- return getProfilesJsonPath;
419
- }
420
- });
421
- Object.defineProperty(exports, "getRepoCacheDir", {
422
- enumerable: true,
423
- get: function() {
424
- return getRepoCacheDir;
425
- }
426
- });
427
- Object.defineProperty(exports, "getRepoDir", {
428
- enumerable: true,
429
- get: function() {
430
- return getRepoDir;
431
- }
432
- });
433
- Object.defineProperty(exports, "getReposConfigPath", {
434
- enumerable: true,
435
- get: function() {
436
- return getReposConfigPath;
437
- }
438
- });
439
- Object.defineProperty(exports, "getReposDir", {
440
- enumerable: true,
441
- get: function() {
442
- return getReposDir;
443
- }
444
- });
445
- Object.defineProperty(exports, "getScheduledTasksConfigPath", {
446
- enumerable: true,
447
- get: function() {
448
- return getScheduledTasksConfigPath;
449
- }
450
- });
451
- Object.defineProperty(exports, "getScheduledTasksLogPath", {
452
- enumerable: true,
453
- get: function() {
454
- return getScheduledTasksLogPath;
455
- }
456
- });
457
- Object.defineProperty(exports, "getSchedulerLockPath", {
458
- enumerable: true,
459
- get: function() {
460
- return getSchedulerLockPath;
461
- }
462
- });
463
- Object.defineProperty(exports, "getSchedulerLogPath", {
464
- enumerable: true,
465
- get: function() {
466
- return getSchedulerLogPath;
467
- }
468
- });
469
- Object.defineProperty(exports, "getSchedulerPidPath", {
470
- enumerable: true,
471
- get: function() {
472
- return getSchedulerPidPath;
473
- }
474
- });
475
- Object.defineProperty(exports, "getServerProxyGlobalPath", {
476
- enumerable: true,
477
- get: function() {
478
- return getServerProxyGlobalPath;
479
- }
480
- });
481
- Object.defineProperty(exports, "getServicemeHome", {
482
- enumerable: true,
483
- get: function() {
484
- return getServicemeHome;
485
- }
486
- });
487
- Object.defineProperty(exports, "getSkillDraftsDir", {
488
- enumerable: true,
489
- get: function() {
490
- return getSkillDraftsDir;
491
- }
492
- });
493
- Object.defineProperty(exports, "getToolboxJsonPath", {
494
- enumerable: true,
495
- get: function() {
496
- return getToolboxJsonPath;
497
- }
498
- });
499
- Object.defineProperty(exports, "getWorkspacesDir", {
500
- enumerable: true,
501
- get: function() {
502
- return getWorkspacesDir;
503
- }
504
- });
505
- Object.defineProperty(exports, "resetUserHomeOverrides", {
506
- enumerable: true,
507
- get: function() {
508
- return resetUserHomeOverrides;
509
- }
510
- });
511
- Object.defineProperty(exports, "setUserHomeOverrides", {
512
- enumerable: true,
513
- get: function() {
514
- return setUserHomeOverrides;
515
- }
516
- });
517
-
518
- //# sourceMappingURL=userHome-CLlsXCvW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"userHome-CLlsXCvW.js","names":["os","path"],"sources":["../src/paths/userHome.ts"],"sourcesContent":["import * as os from \"node:os\";\nimport * as path from \"node:path\";\n\n/**\n * SERVICEME user home directory helpers.\n *\n * All paths resolve under {@link getServicemeHome}, which is either the\n * `SERVICEME_HOME` environment variable (when set and non-empty) or\n * `$HOME/.serviceme` on POSIX / `%USERPROFILE%\\.serviceme` on Windows.\n *\n * Tests inject `homeDir` and `servicemeHomeEnv` overrides via\n * {@link setUserHomeOverrides} / {@link resetUserHomeOverrides} so they can\n * exercise the path logic without touching the real user environment.\n */\n\n/** Layout constants — kept in one place so other modules can reuse them. */\nexport const SERVICEME_DIR_NAME = \".serviceme\";\nexport const REPOS_SUBDIR = \"repos\";\nexport const CACHE_SUBDIR = \"cache\";\nexport const DRAFTS_SUBDIR = \"drafts\";\nexport const SKILL_DRAFTS_SUBDIR = \"skills\";\nexport const AGENT_DRAFTS_SUBDIR = \"agents\";\nexport const REPOS_CONFIG_FILENAME = \"repos.json\";\nexport const WORKSPACES_SUBDIR = \"workspaces\";\nexport const WORKSPACE_CONTENT_STATE_FILENAME = \"copilot-content-state.json\";\n\n/**\n * Repo id regex — used to validate any `repoId` argument before it is joined\n * into a filesystem path. Keeps path traversal attempts out and gives us a\n * predictable on-disk shape.\n */\nexport const SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;\n\n/** Environment variable that overrides the user-home root directory. */\nexport const SERVICEME_HOME_ENV = \"SERVICEME_HOME\";\n\n/**\n * Test seam: lets unit tests inject deterministic values for `os.homedir()`\n * and the `SERVICEME_HOME` env override without actually mutating\n * `process.env` (which would leak into other tests).\n */\ninterface UserHomeOverrides {\n\thomeDir?: string | undefined;\n\tservicemeHomeEnv?: string | undefined;\n\tplatform?: NodeJS.Platform | undefined;\n}\n\nlet activeOverrides: UserHomeOverrides = {};\n\nexport function setUserHomeOverrides(overrides: UserHomeOverrides): void {\n\tactiveOverrides = { ...overrides };\n}\n\nexport function resetUserHomeOverrides(): void {\n\tactiveOverrides = {};\n}\n\nfunction resolveHomeDir(): string {\n\tconst injected = activeOverrides.homeDir;\n\tif (injected !== undefined) {\n\t\treturn injected;\n\t}\n\treturn os.homedir();\n}\n\nfunction resolveServicemeHomeEnv(): string | undefined {\n\tconst injected = activeOverrides.servicemeHomeEnv;\n\tif (injected !== undefined) {\n\t\t// Treat empty string as \"not set\" — `process.env` always returns a string\n\t\t// but tests may deliberately pass \"\" to opt out.\n\t\treturn injected.length > 0 ? injected : undefined;\n\t}\n\tconst envValue = process.env[SERVICEME_HOME_ENV];\n\treturn envValue && envValue.length > 0 ? envValue : undefined;\n}\n\nfunction resolvePlatform(): NodeJS.Platform {\n\treturn activeOverrides.platform ?? process.platform;\n}\n\nexport function assertSafeRepoId(repoId: string): string {\n\tif (typeof repoId !== \"string\" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) {\n\t\tthrow new Error(\n\t\t\t`Invalid repo id: ${JSON.stringify(repoId)}. ` +\n\t\t\t\t`Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then ` +\n\t\t\t\t`alphanumerics / underscores / hyphens, ≤ 64 chars).`\n\t\t);\n\t}\n\treturn repoId;\n}\n\n/**\n * The raw OS home directory (`os.homedir()`), honoring test overrides\n * ({@link setUserHomeOverrides}). Exported for callers that need a\n * home-relative path *outside* of `~/.serviceme` — e.g. the\n * `~/.agents/{skills,agents}` convention used by `SkillLinker` for\n * user-scope links.\n */\nexport function getHomeDir(): string {\n\treturn resolveHomeDir();\n}\n\n/**\n * Root directory for all SERVICEME user-level state. Resolves to\n * `${SERVICEME_HOME}` when that env var is set, otherwise `${HOME}/.serviceme`\n * (POSIX) or `%USERPROFILE%\\.serviceme` (Windows via `os.homedir`).\n */\nexport function getServicemeHome(): string {\n\tconst override = resolveServicemeHomeEnv();\n\tif (override !== undefined) {\n\t\treturn path.resolve(override);\n\t}\n\treturn path.join(resolveHomeDir(), SERVICEME_DIR_NAME);\n}\n\n/** `$HOME/.serviceme/repos` (or `${SERVICEME_HOME}/repos`). */\nexport function getReposDir(): string {\n\treturn path.join(getServicemeHome(), REPOS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/repos/<repoId>` — validates `repoId` first. */\nexport function getRepoDir(repoId: string): string {\n\treturn path.join(getReposDir(), assertSafeRepoId(repoId));\n}\n\n/** `$HOME/.serviceme/cache` — generic per-user cache. */\nexport function getCacheDir(): string {\n\treturn path.join(getServicemeHome(), CACHE_SUBDIR);\n}\n\n/** `$HOME/.serviceme/cache/<repoId>` — per-repo sync state lives here. */\nexport function getRepoCacheDir(repoId: string): string {\n\treturn path.join(getCacheDir(), assertSafeRepoId(repoId));\n}\n\n/** `$HOME/.serviceme/drafts` — local edits not yet pushed upstream. */\nexport function getDraftsDir(): string {\n\treturn path.join(getServicemeHome(), DRAFTS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/drafts/skills` — local skill drafts. */\nexport function getSkillDraftsDir(): string {\n\treturn path.join(getDraftsDir(), SKILL_DRAFTS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/drafts/agents` — local agent drafts. */\nexport function getAgentDraftsDir(): string {\n\treturn path.join(getDraftsDir(), AGENT_DRAFTS_SUBDIR);\n}\n\n/**\n * `$HOME/.serviceme/repos.json` — the single config entry point for repo\n * metadata. Always under the resolved home root (i.e. follows\n * `SERVICEME_HOME` overrides too).\n */\nexport function getReposConfigPath(): string {\n\treturn path.join(getServicemeHome(), REPOS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/workspaces` — machine-local per-workspace state root. */\nexport function getWorkspacesDir(): string {\n\treturn path.join(getServicemeHome(), WORKSPACES_SUBDIR);\n}\n\n/**\n * Convenience helper for callers that need to switch behaviour on platform\n * (e.g. `SkillLinker` chooses symlink vs junction). Exported mostly so tests\n * can pin the value without touching `process.platform` directly.\n */\nexport function getHomePlatform(): NodeJS.Platform {\n\treturn resolvePlatform();\n}\n\n// ─── Scheduled Tasks paths (added by M1.5.3) ───────────────────────────────\n\n/** Layout constants for scheduled-tasks files. Kept here so other modules\n * can reuse them and the names stay in sync with the design doc. */\nexport const SCHEDULED_TASKS_CONFIG_FILENAME = \"scheduled-tasks.json\";\nexport const SCHEDULED_TASKS_LOG_FILENAME = \"scheduled-tasks-log.json\";\nexport const SCHEDULER_PID_FILENAME = \"scheduler.pid\";\nexport const SCHEDULER_LOCK_FILENAME = \"scheduler.lock\";\nexport const SCHEDULER_LOG_FILENAME = \"scheduler.log\";\nexport const MIGRATION_FAILURES_FILENAME = \"migration-failures.json\";\nexport const KNOWN_WORKSPACES_FILENAME = \"known-workspaces.json\";\n\n/** `~/.serviceme/scheduled-tasks.json` — the global v2 task list. */\nexport function getScheduledTasksConfigPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULED_TASKS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/scheduled-tasks-log.json` — the global execution log (200 LRU). */\nexport function getScheduledTasksLogPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULED_TASKS_LOG_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.pid` — global daemon PID file. */\nexport function getSchedulerPidPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_PID_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.lock` — global daemon startup flock. */\nexport function getSchedulerLockPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_LOCK_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.log` — global daemon log (daemon lifecycle, not task execution). */\nexport function getSchedulerLogPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_LOG_FILENAME);\n}\n\n/** `~/.serviceme/migration-failures.json` — diagnostics for failed v1→v2 imports. */\nexport function getMigrationFailuresPath(): string {\n\treturn path.join(getServicemeHome(), MIGRATION_FAILURES_FILENAME);\n}\n\n/** `~/.serviceme/known-workspaces.json` — workspace list the extension has seen. */\nexport function getKnownWorkspacesPath(): string {\n\treturn path.join(getServicemeHome(), KNOWN_WORKSPACES_FILENAME);\n}\n\n// ─── r7 BYOM Server Proxy (rev.20) ─────────────────────────────────────────\n\n/**\n * `~/.serviceme/server-proxy.json` — r7 BYOM Server Proxy toggle\n * self-state. Written by the extension's `ProxyConfigService`, readable\n * by the CLI / Server so they can decide whether to route traffic\n * through the corporate proxy without booting VS Code.\n *\n * Lives under user-level `~/.serviceme/` (not under a workspace) because\n * the toggle is a *user preference* — the same human enabling it on\n * machine A should be able to rely on it on machine B after sync, not\n * have it disappear when they switch repos.\n */\nexport function getServerProxyGlobalPath(): string {\n\treturn path.join(getServicemeHome(), SERVER_PROXY_GLOBAL_FILENAME);\n}\n\n// ─── Phase 5 (auth + device + toolbox) placeholders (Spec §11.12) ────────\n\n/** Layout constants for the Phase 5 client-side state files. The server\n * already has the corresponding routes (`/api/v1/auth/...`,\n * `/api/v1/device/...`, etc.) — the client just needs the on-disk\n * file paths + a first-run bootstrap so the auth/device/toolbox\n * services can open + read them without a per-call existence check. */\nexport const CREDENTIALS_CONFIG_FILENAME = \"credentials.json\";\nexport const DEVICE_JSON_FILENAME = \"device.json\";\nexport const TOOLBOX_JSON_FILENAME = \"toolbox.json\";\nexport const MACHINE_ID_FILENAME = \"machine-id\";\nexport const PROFILES_JSON_FILENAME = \"profiles.json\";\n\n/** `~/.serviceme/credentials.json` — better-auth session tokens + refresh state (client-side cache). */\nexport function getCredentialsConfigPath(): string {\n\treturn path.join(getServicemeHome(), CREDENTIALS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/device.json` — device enrollment payload (id, public key fingerprint, claimed-by). */\nexport function getDeviceJsonPath(): string {\n\treturn path.join(getServicemeHome(), DEVICE_JSON_FILENAME);\n}\n\n/** `~/.serviceme/toolbox.json` — local toolbox state (installed tool refs, per-user prefs). */\nexport function getToolboxJsonPath(): string {\n\treturn path.join(getServicemeHome(), TOOLBOX_JSON_FILENAME);\n}\n\n/** `~/.serviceme/machine-id` — opaque stable per-install id (uuid v4 string, no JSON wrapper). */\nexport function getMachineIdPath(): string {\n\treturn path.join(getServicemeHome(), MACHINE_ID_FILENAME);\n}\n\n/** `~/.serviceme/profiles.json` — cached projection of server-side profile rows; refresh on demand. */\nexport function getProfilesJsonPath(): string {\n\treturn path.join(getServicemeHome(), PROFILES_JSON_FILENAME);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAa,qBAAqB;AAClC,MAAa,eAAe;AAC5B,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AACnC,MAAa,sBAAsB;AACnC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;AACjC,MAAa,mCAAmC;;;;;;AAOhD,MAAa,uBAAuB;;AAGpC,MAAa,qBAAqB;AAalC,IAAI,kBAAqC,CAAC;AAE1C,SAAgB,qBAAqB,WAAoC;CACxE,kBAAkB,EAAE,GAAG,UAAU;AAClC;AAEA,SAAgB,yBAA+B;CAC9C,kBAAkB,CAAC;AACpB;AAEA,SAAS,iBAAyB;CACjC,MAAM,WAAW,gBAAgB;CACjC,IAAI,aAAa,KAAA,GAChB,OAAO;CAER,OAAOA,QAAG,QAAQ;AACnB;AAEA,SAAS,0BAA8C;CACtD,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