@mulmoclaude/core 7.7.2 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/helps/error-recovery.md +21 -0
- package/assets/helps/spreadsheet.md +8 -7
- package/dist/{atomic-C3NMg6-j.js → atomic-Dw7dV4TL.js} +1 -1
- package/dist/{atomic-C3NMg6-j.js.map → atomic-Dw7dV4TL.js.map} +1 -1
- package/dist/{atomic-cqafMWEI.cjs → atomic-bzFw4-ix.cjs} +3 -3
- package/dist/atomic-bzFw4-ix.cjs.map +1 -0
- package/dist/collection/index.cjs +6 -6
- package/dist/collection/index.js +6 -6
- package/dist/collection/paths.cjs +1 -1
- package/dist/collection/paths.js +1 -1
- package/dist/collection/registry/index.cjs +1 -1
- package/dist/collection/registry/index.js +1 -1
- package/dist/collection/registry/server/index.cjs +11 -11
- package/dist/collection/registry/server/index.cjs.map +1 -1
- package/dist/collection/registry/server/index.js +10 -10
- package/dist/collection/server/index.cjs +5 -5
- package/dist/collection/server/index.js +5 -5
- package/dist/collection-watchers/index.cjs +6 -6
- package/dist/collection-watchers/index.cjs.map +1 -1
- package/dist/collection-watchers/index.js +6 -6
- package/dist/collection-watchers/index.js.map +1 -1
- package/dist/{containment-Dc3gO4wD.cjs → containment-NZYJbiaa.cjs} +2 -2
- package/dist/{containment-Dc3gO4wD.cjs.map → containment-NZYJbiaa.cjs.map} +1 -1
- package/dist/{containment-D_vAa6eT.js → containment-Ne0w06jN.js} +1 -1
- package/dist/{containment-D_vAa6eT.js.map → containment-Ne0w06jN.js.map} +1 -1
- package/dist/{discovery-CY4pvgo9.cjs → discovery-Cu35oXeW.cjs} +13 -13
- package/dist/{discovery-CY4pvgo9.cjs.map → discovery-Cu35oXeW.cjs.map} +1 -1
- package/dist/{discovery-CImpaG95.js → discovery-DTOodl_M.js} +10 -10
- package/dist/{discovery-CImpaG95.js.map → discovery-DTOodl_M.js.map} +1 -1
- package/dist/{dist-734JaRYi.cjs → dist-DK0zTPR1.cjs} +1 -1
- package/dist/{dist-734JaRYi.cjs.map → dist-DK0zTPR1.cjs.map} +1 -1
- package/dist/{dist-BmO4oSQy.js → dist-wmt60Ec-.js} +1 -1
- package/dist/{dist-BmO4oSQy.js.map → dist-wmt60Ec-.js.map} +1 -1
- package/dist/errorMessage-CEWGPYzN.js +1 -0
- package/dist/errorMessage-DCZuXjO4.cjs +1 -0
- package/dist/{errors-0QwjDxsv.js → errors-DfW0e2uv.js} +2 -2
- package/dist/{errors-0QwjDxsv.js.map → errors-DfW0e2uv.js.map} +1 -1
- package/dist/{errors-B9mCEVG9.cjs → errors-WLfupg-H.cjs} +2 -2
- package/dist/{errors-B9mCEVG9.cjs.map → errors-WLfupg-H.cjs.map} +1 -1
- package/dist/feeds/index.cjs +2 -2
- package/dist/feeds/index.js +2 -2
- package/dist/feeds/paths.cjs +1 -1
- package/dist/feeds/server/index.cjs +13 -13
- package/dist/feeds/server/index.js +11 -11
- package/dist/file-change/index.cjs +2 -2
- package/dist/file-change/index.js +1 -1
- package/dist/files/index.cjs +9 -9
- package/dist/files/index.js +7 -7
- package/dist/global-config/index.cjs +1 -1
- package/dist/global-config/index.js +1 -1
- package/dist/google/index.cjs +16 -16
- package/dist/google/index.cjs.map +1 -1
- package/dist/google/index.js +14 -14
- package/dist/google/index.js.map +1 -1
- package/dist/{graph-DBbzemby.js → graph-CVoiWp8B.js} +2 -2
- package/dist/{graph-DBbzemby.js.map → graph-CVoiWp8B.js.map} +1 -1
- package/dist/{graph-BvVMZfDV.cjs → graph-RyHEgm-F.cjs} +2 -2
- package/dist/{graph-BvVMZfDV.cjs.map → graph-RyHEgm-F.cjs.map} +1 -1
- package/dist/{iconGlyph-CFOiFsmq.cjs → iconGlyph-BhtU1a9P.cjs} +1 -1
- package/dist/{iconGlyph-CFOiFsmq.cjs.map → iconGlyph-BhtU1a9P.cjs.map} +1 -1
- package/dist/{iconGlyph-D9h__VaM.js → iconGlyph-DjE_HLf4.js} +1 -1
- package/dist/{iconGlyph-D9h__VaM.js.map → iconGlyph-DjE_HLf4.js.map} +1 -1
- package/dist/{ingestTypes-CLDvn7kw.cjs → ingestTypes-CmO3SNaO.cjs} +2 -2
- package/dist/{ingestTypes-CLDvn7kw.cjs.map → ingestTypes-CmO3SNaO.cjs.map} +1 -1
- package/dist/{ingestTypes-DuXuSBSn.js → ingestTypes-V3bHEQ2i.js} +2 -2
- package/dist/{ingestTypes-DuXuSBSn.js.map → ingestTypes-V3bHEQ2i.js.map} +1 -1
- package/dist/{itemId-D2XAQ8RU.cjs → itemId-D3mJhGu0.cjs} +1 -1
- package/dist/{itemId-D2XAQ8RU.cjs.map → itemId-D3mJhGu0.cjs.map} +1 -1
- package/dist/{itemId-D_pSpa3U.js → itemId-D7pPwaX6.js} +1 -1
- package/dist/{itemId-D_pSpa3U.js.map → itemId-D7pPwaX6.js.map} +1 -1
- package/dist/{json-BizOSThv.js → json-C23c3t1W.js} +2 -2
- package/dist/{json-BizOSThv.js.map → json-C23c3t1W.js.map} +1 -1
- package/dist/{json-BGdV2cz6.cjs → json-CWiVjlka.cjs} +2 -2
- package/dist/{json-BGdV2cz6.cjs.map → json-CWiVjlka.cjs.map} +1 -1
- package/dist/{listen-uiEnXcW9.js → listen-DFP9Lrbd.js} +2 -2
- package/dist/{listen-uiEnXcW9.js.map → listen-DFP9Lrbd.js.map} +1 -1
- package/dist/{listen-OmfLDX1l.cjs → listen-jSwqWZfE.cjs} +2 -2
- package/dist/{listen-OmfLDX1l.cjs.map → listen-jSwqWZfE.cjs.map} +1 -1
- package/dist/notifier/index.cjs +1 -1
- package/dist/notifier/index.js +1 -1
- package/dist/{notifier-htdf4ekH.js → notifier-BkIAgskG.js} +3 -3
- package/dist/{notifier-htdf4ekH.js.map → notifier-BkIAgskG.js.map} +1 -1
- package/dist/{notifier-CRTk34EC.cjs → notifier-nv9c1r6T.cjs} +3 -3
- package/dist/{notifier-CRTk34EC.cjs.map → notifier-nv9c1r6T.cjs.map} +1 -1
- package/dist/{paths-DUHAueEv.cjs → paths-D0WRbJTV.cjs} +2 -2
- package/dist/{paths-DUHAueEv.cjs.map → paths-D0WRbJTV.cjs.map} +1 -1
- package/dist/{paths-BMQNHdaJ.js → paths-qvo3SsnP.js} +2 -2
- package/dist/{paths-BMQNHdaJ.js.map → paths-qvo3SsnP.js.map} +1 -1
- package/dist/plugin-vue/i18n.cjs +1 -1
- package/dist/plugin-vue/i18n.cjs.map +1 -1
- package/dist/plugin-vue/i18n.js +1 -1
- package/dist/plugin-vue/index.cjs +2 -2
- package/dist/plugin-vue/index.cjs.map +1 -1
- package/dist/plugin-vue/index.js +2 -2
- package/dist/plugin-vue/index.js.map +1 -1
- package/dist/{project-mU6-xLfy.js → project-CSx7gqgs.js} +1 -1
- package/dist/{project-mU6-xLfy.js.map → project-CSx7gqgs.js.map} +1 -1
- package/dist/{project-DDTIVEMU.cjs → project-sS_ltoWz.cjs} +1 -1
- package/dist/{project-DDTIVEMU.cjs.map → project-sS_ltoWz.cjs.map} +1 -1
- package/dist/prompt-files/index.cjs +3 -3
- package/dist/prompt-files/index.cjs.map +1 -1
- package/dist/prompt-files/index.js +1 -1
- package/dist/{promptSafety-CjxafW2b.cjs → promptSafety-BkFiS7El.cjs} +3 -3
- package/dist/{promptSafety-CjxafW2b.cjs.map → promptSafety-BkFiS7El.cjs.map} +1 -1
- package/dist/{promptSafety-B8LECAkY.js → promptSafety-Dp9Zga_t.js} +3 -3
- package/dist/{promptSafety-B8LECAkY.js.map → promptSafety-Dp9Zga_t.js.map} +1 -1
- package/dist/{relPath-CZiP2S_a.cjs → relPath-B-c9FUkm.cjs} +2 -2
- package/dist/{relPath-CZiP2S_a.cjs.map → relPath-B-c9FUkm.cjs.map} +1 -1
- package/dist/{relPath-BkKmqiiF.js → relPath-DV2ZrxF_.js} +1 -1
- package/dist/{relPath-BkKmqiiF.js.map → relPath-DV2ZrxF_.js.map} +1 -1
- package/dist/remote-host/index.cjs +1 -1
- package/dist/remote-host/index.js +1 -1
- package/dist/remote-host/server/index.cjs +4 -4
- package/dist/remote-host/server/index.cjs.map +1 -1
- package/dist/remote-host/server/index.js +4 -4
- package/dist/remote-host/server/index.js.map +1 -1
- package/dist/{remote-host-11euEZKP.cjs → remote-host-B6r8BkA1.cjs} +2 -2
- package/dist/{remote-host-11euEZKP.cjs.map → remote-host-B6r8BkA1.cjs.map} +1 -1
- package/dist/{remote-host-TiMhcW1o.js → remote-host-BI_3SnK1.js} +2 -2
- package/dist/{remote-host-TiMhcW1o.js.map → remote-host-BI_3SnK1.js.map} +1 -1
- package/dist/remote-view/index.cjs +2 -2
- package/dist/remote-view/index.js +2 -2
- package/dist/{rolldown-runtime-CmQyd0Gu.cjs → rolldown-runtime-C5rMTSut.cjs} +8 -6
- package/dist/{root-s0MUUMQU.js → root-DDMQu5hb.js} +1 -1
- package/dist/{root-s0MUUMQU.js.map → root-DDMQu5hb.js.map} +1 -1
- package/dist/{root-Ccgd3H5S.cjs → root-kKYFqEMf.cjs} +2 -2
- package/dist/{root-Ccgd3H5S.cjs.map → root-kKYFqEMf.cjs.map} +1 -1
- package/dist/runtime-plugins/index.cjs +104 -15
- package/dist/runtime-plugins/index.cjs.map +1 -1
- package/dist/runtime-plugins/index.d.ts +1 -0
- package/dist/runtime-plugins/index.js +99 -15
- package/dist/runtime-plugins/index.js.map +1 -1
- package/dist/runtime-plugins/ledgerLock.d.ts +16 -0
- package/dist/scheduler/index.cjs +5 -5
- package/dist/scheduler/index.js +4 -4
- package/dist/{server-BXtSbL-b.cjs → server-BNmwQGcq.cjs} +15 -15
- package/dist/server-BNmwQGcq.cjs.map +1 -0
- package/dist/{server-B5TZjZN9.js → server-BpCUehxP.js} +14 -14
- package/dist/{server-B5TZjZN9.js.map → server-BpCUehxP.js.map} +1 -1
- package/dist/skill-bridge/index.cjs +3 -3
- package/dist/skill-bridge/index.cjs.map +1 -1
- package/dist/skill-bridge/index.js +2 -2
- package/dist/{slug-DVkuPjIv.cjs → slug-BRj6KEiN.cjs} +1 -1
- package/dist/{slug-DVkuPjIv.cjs.map → slug-BRj6KEiN.cjs.map} +1 -1
- package/dist/{slug-D24AYqCZ.js → slug-X5tnZoc-.js} +1 -1
- package/dist/{slug-D24AYqCZ.js.map → slug-X5tnZoc-.js.map} +1 -1
- package/dist/{templatePath-CB3wtVpe.js → templatePath-B5mHTFDX.js} +1 -1
- package/dist/{templatePath-CB3wtVpe.js.map → templatePath-B5mHTFDX.js.map} +1 -1
- package/dist/{templatePath-BIh7wqgS.cjs → templatePath-DSawCKNy.cjs} +1 -1
- package/dist/{templatePath-BIh7wqgS.cjs.map → templatePath-DSawCKNy.cjs.map} +1 -1
- package/dist/{text-BQAuwKVj.js → text-BpGv7qxC.js} +1 -1
- package/dist/{text-BQAuwKVj.js.map → text-BpGv7qxC.js.map} +1 -1
- package/dist/{text-BQiyo5R9.cjs → text-CPK6ABnv.cjs} +1 -1
- package/dist/{text-BQiyo5R9.cjs.map → text-CPK6ABnv.cjs.map} +1 -1
- package/dist/{types-DPycxnDf.cjs → types-Bmk0fWDr.cjs} +1 -1
- package/dist/{types-DPycxnDf.cjs.map → types-Bmk0fWDr.cjs.map} +1 -1
- package/dist/{types-BLCZTGW2.js → types-CuiYCIof.js} +1 -1
- package/dist/{types-BLCZTGW2.js.map → types-CuiYCIof.js.map} +1 -1
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.js +3 -3
- package/dist/whisper/client.cjs.map +1 -1
- package/dist/whisper/client.js.map +1 -1
- package/dist/whisper/index.cjs +7 -7
- package/dist/whisper/index.cjs.map +1 -1
- package/dist/whisper/index.js +5 -5
- package/dist/wiki/index.cjs +3 -3
- package/dist/wiki/index.js +3 -3
- package/dist/wiki/paths.cjs +2 -2
- package/dist/wiki/paths.js +1 -1
- package/dist/wiki/server/index.cjs +7 -7
- package/dist/wiki/server/index.js +5 -5
- package/dist/{withinRoot-CheaBWt0.js → withinRoot-Dc756J5K.js} +2 -2
- package/dist/{withinRoot-CheaBWt0.js.map → withinRoot-Dc756J5K.js.map} +1 -1
- package/dist/{withinRoot-CHPN9eHD.cjs → withinRoot-OaOVCBHa.cjs} +2 -2
- package/dist/withinRoot-OaOVCBHa.cjs.map +1 -0
- package/dist/workspace-setup/index.js +1 -1
- package/package.json +5 -5
- package/dist/atomic-cqafMWEI.cjs.map +0 -1
- package/dist/errorMessage-D0kR547_.cjs +0 -1
- package/dist/errorMessage-TpKxrmeo.js +0 -1
- package/dist/server-BXtSbL-b.cjs.map +0 -1
- package/dist/withinRoot-CHPN9eHD.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../rolldown-runtime-
|
|
3
|
-
const require_templatePath = require("../templatePath-BIh7wqgS.cjs");
|
|
4
|
-
let node_fs = require("node:fs");
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-C5rMTSut.cjs");
|
|
5
3
|
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
const require_templatePath = require("../templatePath-DSawCKNy.cjs");
|
|
6
6
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
7
7
|
// src/skill-bridge/index.ts
|
|
8
8
|
var DATA_SKILLS_DIR = node_path.default.join("data", "skills");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["path","isSafeActionTemplatePath","readFileSync"],"sources":["../../src/skill-bridge/index.ts"],"sourcesContent":["// @mulmoclaude/core/skill-bridge — the skill staging→active mirror RULE, shared by\n// MulmoClaude and MulmoTerminal so the two hosts can't drift on what crosses the\n// `.claude/` permission gate.\n//\n// The agent writes skill drafts under `data/skills/<slug>/` (a plain data dir, no\n// `.claude/` permission special-case). This package decides which writes are\n// allowlisted and mirrors them 1:1 into `.claude/skills/<slug>/` so Claude CLI's\n// skill discovery + the collection engine pick them up. It also mirrors a\n// `rm -rf data/skills/<slug>` delete.\n//\n// What crosses — a FIXED ALLOWLIST, not the whole dir:\n// SKILL.md the skill body Claude CLI reads\n// schema.json the collection definition (a \"collection skill\" ships one)\n// templates/<path> action templates a schema's `actions` reference — exactly the\n// set the schema validator accepts (`isSafeActionTemplatePath`)\n// Everything else (README.md, assets/, arbitrary nesting) stays staging-side.\n//\n// Pure rule + fs ops, parameterized by `workspaceRoot` (passed in, not read from a\n// host module) so either host can call it. Each host wires this into its own hook /\n// PostToolUse path and triggers its own config refresh afterward.\nimport path from \"node:path\";\nimport { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { isSafeActionTemplatePath } from \"../collection/server/templatePath\";\n\nconst DATA_SKILLS_DIR = path.join(\"data\", \"skills\");\nconst CLAUDE_SKILLS_DIR = path.join(\".claude\", \"skills\");\nconst SKILL_FILENAME = \"SKILL.md\";\nconst SCHEMA_FILENAME = \"schema.json\";\n\n// Slugs follow Claude Code's skill-name convention: lowercase ASCII letters/digits\n// with single-hyphen separators. Strict so a typo / traversal never reaches the dest.\n// eslint-disable-next-line security/detect-unsafe-regex -- input is a basename slice ≤64 chars; bounded backtracking.\nconst SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\n// `rm -rf data/skills/<slug>` matcher. `match[1]` is the flag run (must contain a\n// recursive flag); `match[2]` is the slug. Wildcards / the parent dir / non-recursive\n// `rm` are intentionally NOT matched (a non-recursive rm can't delete the dir anyway,\n// so mirroring would desync the trees).\n// eslint-disable-next-line security/detect-unsafe-regex -- single-line captured Bash command; bounded.\nconst RM_RE = /^\\s*rm\\s+((?:-[a-zA-Z]+\\s+)+)['\"]?data\\/skills\\/([a-z0-9-]+)\\/?['\"]?\\s*$/;\nconst RECURSIVE_FLAG_RE = /[rR]/;\n\n/** A staging file cleared to cross the `.claude/` gate. */\nexport interface BridgeTarget {\n /** The skill slug (the dir directly under data/skills/). */\n slug: string;\n /** Path segments BELOW the slug dir, e.g. `[\"SKILL.md\"]`, `[\"templates\",\"x.md\"]`.\n * Used verbatim for both source and destination so the mirror is 1:1. */\n relSegments: string[];\n}\n\n/** `<workspaceRoot>/data/skills/<slug>` — the staging dir for a skill. */\nexport function dataSkillDir(workspaceRoot: string, slug: string): string {\n return path.join(workspaceRoot, DATA_SKILLS_DIR, slug);\n}\n\n/** `<workspaceRoot>/.claude/skills/<slug>` — the active dir Claude CLI discovers. */\nexport function claudeSkillDir(workspaceRoot: string, slug: string): string {\n return path.join(workspaceRoot, CLAUDE_SKILLS_DIR, slug);\n}\n\n// Allowlist a path below the slug dir: SKILL.md / schema.json at the top, or a safe\n// `templates/<path>` (the same predicate the schema validator uses, so what a schema\n// can declare is exactly what crosses). Everything else → false.\nfunction isAllowlisted(relSegments: string[]): boolean {\n if (relSegments.length === 1) {\n return relSegments[0] === SKILL_FILENAME || relSegments[0] === SCHEMA_FILENAME;\n }\n return isSafeActionTemplatePath(relSegments.join(\"/\"));\n}\n\n/** Resolve a Write/Edit path to the staging file it mirrors, or null when it isn't a\n * bridged file (not under `data/skills/<slug>/`, bad slug, or off the allowlist). */\nexport function bridgeTargetFromDataPath(workspaceRoot: string, filePath: string): BridgeTarget | null {\n const staging = path.join(workspaceRoot, DATA_SKILLS_DIR);\n const rel = path.relative(staging, filePath);\n if (!rel || rel.startsWith(\"..\") || path.isAbsolute(rel)) return null;\n const [slug, ...relSegments] = rel.split(path.sep);\n if (!slug || relSegments.length === 0) return null; // need at least `<slug>/<file>`\n if (!SLUG_RE.test(slug)) return null;\n if (!isAllowlisted(relSegments)) return null;\n return { slug, relSegments };\n}\n\n/** Extract the slug from a Bash `rm -rf data/skills/<slug>` command, or null on any\n * mismatch (wildcards, paths outside staging, non-recursive `rm`). */\nexport function slugFromRmCommand(command: string): string | null {\n const match = RM_RE.exec(command);\n if (!match) return null;\n // Both groups are mandatory in RM_RE; the \"\" defaults fail both tests below,\n // i.e. they land on the same `null` a non-matching command already gets.\n const [, flags = \"\", slug = \"\"] = match;\n if (!RECURSIVE_FLAG_RE.test(flags)) return null;\n return SLUG_RE.test(slug) ? slug : null;\n}\n\n/** Atomic mirror of one allowlisted staging file → its active path: write a tmp file\n * in the dest dir, then rename onto the canonical path (atomic on POSIX; both paths\n * share a filesystem). A killed mid-write leaves a harmless tmp and the previous\n * SKILL.md intact. Returns the resolved src/dest for logging. */\nexport function mirrorSkillWrite(workspaceRoot: string, target: BridgeTarget): { src: string; dest: string } {\n const { slug, relSegments } = target;\n const src = path.join(dataSkillDir(workspaceRoot, slug), ...relSegments);\n const content = readFileSync(src, \"utf-8\");\n const dest = path.join(claudeSkillDir(workspaceRoot, slug), ...relSegments);\n const destDir = path.dirname(dest);\n mkdirSync(destDir, { recursive: true }); // covers templates/ + the slug dir on first install\n const tmp = path.join(destDir, `.${path.basename(dest)}.${process.pid}.tmp`);\n writeFileSync(tmp, content, \"utf-8\");\n renameSync(tmp, dest);\n return { src, dest };\n}\n\n/** Remove the active skill dir (mirrors a staging `rm -rf`). Returns the dest. */\nexport function mirrorSkillDelete(workspaceRoot: string, slug: string): { dest: string } {\n const dest = claudeSkillDir(workspaceRoot, slug);\n rmSync(dest, { recursive: true, force: true });\n return { dest };\n}\n"],"mappings":";;;;;;;AAwBA,IAAM,kBAAkBA,UAAAA,QAAK,KAAK,QAAQ,QAAQ;AAClD,IAAM,oBAAoBA,UAAAA,QAAK,KAAK,WAAW,QAAQ;AACvD,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAKxB,IAAM,UAAU;AAOhB,IAAM,QAAQ;AACd,IAAM,oBAAoB;;AAY1B,SAAgB,aAAa,eAAuB,MAAsB;CACxE,OAAOA,UAAAA,QAAK,KAAK,eAAe,iBAAiB,IAAI;AACvD;;AAGA,SAAgB,eAAe,eAAuB,MAAsB;CAC1E,OAAOA,UAAAA,QAAK,KAAK,eAAe,mBAAmB,IAAI;AACzD;AAKA,SAAS,cAAc,aAAgC;CACrD,IAAI,YAAY,WAAW,GACzB,OAAO,YAAY,OAAO,kBAAkB,YAAY,OAAO;CAEjE,OAAOC,qBAAAA,yBAAyB,YAAY,KAAK,GAAG,CAAC;AACvD;;;AAIA,SAAgB,yBAAyB,eAAuB,UAAuC;CACrG,MAAM,UAAUD,UAAAA,QAAK,KAAK,eAAe,eAAe;CACxD,MAAM,MAAMA,UAAAA,QAAK,SAAS,SAAS,QAAQ;CAC3C,IAAI,CAAC,OAAO,IAAI,WAAW,IAAI,KAAKA,UAAAA,QAAK,WAAW,GAAG,GAAG,OAAO;CACjE,MAAM,CAAC,MAAM,GAAG,eAAe,IAAI,MAAMA,UAAAA,QAAK,GAAG;CACjD,IAAI,CAAC,QAAQ,YAAY,WAAW,GAAG,OAAO;CAC9C,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,OAAO;CAChC,IAAI,CAAC,cAAc,WAAW,GAAG,OAAO;CACxC,OAAO;EAAE;EAAM;CAAY;AAC7B;;;AAIA,SAAgB,kBAAkB,SAAgC;CAChE,MAAM,QAAQ,MAAM,KAAK,OAAO;CAChC,IAAI,CAAC,OAAO,OAAO;CAGnB,MAAM,GAAG,QAAQ,IAAI,OAAO,MAAM;CAClC,IAAI,CAAC,kBAAkB,KAAK,KAAK,GAAG,OAAO;CAC3C,OAAO,QAAQ,KAAK,IAAI,IAAI,OAAO;AACrC;;;;;AAMA,SAAgB,iBAAiB,eAAuB,QAAqD;CAC3G,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,MAAMA,UAAAA,QAAK,KAAK,aAAa,eAAe,IAAI,GAAG,GAAG,WAAW;CACvE,MAAM,WAAA,GAAUE,QAAAA,aAAAA,CAAa,KAAK,OAAO;CACzC,MAAM,OAAOF,UAAAA,QAAK,KAAK,eAAe,eAAe,IAAI,GAAG,GAAG,WAAW;CAC1E,MAAM,UAAUA,UAAAA,QAAK,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["path","isSafeActionTemplatePath","readFileSync","mkdirSync","writeFileSync","renameSync","rmSync"],"sources":["../../src/skill-bridge/index.ts"],"sourcesContent":["// @mulmoclaude/core/skill-bridge — the skill staging→active mirror RULE, shared by\n// MulmoClaude and MulmoTerminal so the two hosts can't drift on what crosses the\n// `.claude/` permission gate.\n//\n// The agent writes skill drafts under `data/skills/<slug>/` (a plain data dir, no\n// `.claude/` permission special-case). This package decides which writes are\n// allowlisted and mirrors them 1:1 into `.claude/skills/<slug>/` so Claude CLI's\n// skill discovery + the collection engine pick them up. It also mirrors a\n// `rm -rf data/skills/<slug>` delete.\n//\n// What crosses — a FIXED ALLOWLIST, not the whole dir:\n// SKILL.md the skill body Claude CLI reads\n// schema.json the collection definition (a \"collection skill\" ships one)\n// templates/<path> action templates a schema's `actions` reference — exactly the\n// set the schema validator accepts (`isSafeActionTemplatePath`)\n// Everything else (README.md, assets/, arbitrary nesting) stays staging-side.\n//\n// Pure rule + fs ops, parameterized by `workspaceRoot` (passed in, not read from a\n// host module) so either host can call it. Each host wires this into its own hook /\n// PostToolUse path and triggers its own config refresh afterward.\nimport path from \"node:path\";\nimport { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { isSafeActionTemplatePath } from \"../collection/server/templatePath\";\n\nconst DATA_SKILLS_DIR = path.join(\"data\", \"skills\");\nconst CLAUDE_SKILLS_DIR = path.join(\".claude\", \"skills\");\nconst SKILL_FILENAME = \"SKILL.md\";\nconst SCHEMA_FILENAME = \"schema.json\";\n\n// Slugs follow Claude Code's skill-name convention: lowercase ASCII letters/digits\n// with single-hyphen separators. Strict so a typo / traversal never reaches the dest.\n// eslint-disable-next-line security/detect-unsafe-regex -- input is a basename slice ≤64 chars; bounded backtracking.\nconst SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\n// `rm -rf data/skills/<slug>` matcher. `match[1]` is the flag run (must contain a\n// recursive flag); `match[2]` is the slug. Wildcards / the parent dir / non-recursive\n// `rm` are intentionally NOT matched (a non-recursive rm can't delete the dir anyway,\n// so mirroring would desync the trees).\n// eslint-disable-next-line security/detect-unsafe-regex -- single-line captured Bash command; bounded.\nconst RM_RE = /^\\s*rm\\s+((?:-[a-zA-Z]+\\s+)+)['\"]?data\\/skills\\/([a-z0-9-]+)\\/?['\"]?\\s*$/;\nconst RECURSIVE_FLAG_RE = /[rR]/;\n\n/** A staging file cleared to cross the `.claude/` gate. */\nexport interface BridgeTarget {\n /** The skill slug (the dir directly under data/skills/). */\n slug: string;\n /** Path segments BELOW the slug dir, e.g. `[\"SKILL.md\"]`, `[\"templates\",\"x.md\"]`.\n * Used verbatim for both source and destination so the mirror is 1:1. */\n relSegments: string[];\n}\n\n/** `<workspaceRoot>/data/skills/<slug>` — the staging dir for a skill. */\nexport function dataSkillDir(workspaceRoot: string, slug: string): string {\n return path.join(workspaceRoot, DATA_SKILLS_DIR, slug);\n}\n\n/** `<workspaceRoot>/.claude/skills/<slug>` — the active dir Claude CLI discovers. */\nexport function claudeSkillDir(workspaceRoot: string, slug: string): string {\n return path.join(workspaceRoot, CLAUDE_SKILLS_DIR, slug);\n}\n\n// Allowlist a path below the slug dir: SKILL.md / schema.json at the top, or a safe\n// `templates/<path>` (the same predicate the schema validator uses, so what a schema\n// can declare is exactly what crosses). Everything else → false.\nfunction isAllowlisted(relSegments: string[]): boolean {\n if (relSegments.length === 1) {\n return relSegments[0] === SKILL_FILENAME || relSegments[0] === SCHEMA_FILENAME;\n }\n return isSafeActionTemplatePath(relSegments.join(\"/\"));\n}\n\n/** Resolve a Write/Edit path to the staging file it mirrors, or null when it isn't a\n * bridged file (not under `data/skills/<slug>/`, bad slug, or off the allowlist). */\nexport function bridgeTargetFromDataPath(workspaceRoot: string, filePath: string): BridgeTarget | null {\n const staging = path.join(workspaceRoot, DATA_SKILLS_DIR);\n const rel = path.relative(staging, filePath);\n if (!rel || rel.startsWith(\"..\") || path.isAbsolute(rel)) return null;\n const [slug, ...relSegments] = rel.split(path.sep);\n if (!slug || relSegments.length === 0) return null; // need at least `<slug>/<file>`\n if (!SLUG_RE.test(slug)) return null;\n if (!isAllowlisted(relSegments)) return null;\n return { slug, relSegments };\n}\n\n/** Extract the slug from a Bash `rm -rf data/skills/<slug>` command, or null on any\n * mismatch (wildcards, paths outside staging, non-recursive `rm`). */\nexport function slugFromRmCommand(command: string): string | null {\n const match = RM_RE.exec(command);\n if (!match) return null;\n // Both groups are mandatory in RM_RE; the \"\" defaults fail both tests below,\n // i.e. they land on the same `null` a non-matching command already gets.\n const [, flags = \"\", slug = \"\"] = match;\n if (!RECURSIVE_FLAG_RE.test(flags)) return null;\n return SLUG_RE.test(slug) ? slug : null;\n}\n\n/** Atomic mirror of one allowlisted staging file → its active path: write a tmp file\n * in the dest dir, then rename onto the canonical path (atomic on POSIX; both paths\n * share a filesystem). A killed mid-write leaves a harmless tmp and the previous\n * SKILL.md intact. Returns the resolved src/dest for logging. */\nexport function mirrorSkillWrite(workspaceRoot: string, target: BridgeTarget): { src: string; dest: string } {\n const { slug, relSegments } = target;\n const src = path.join(dataSkillDir(workspaceRoot, slug), ...relSegments);\n const content = readFileSync(src, \"utf-8\");\n const dest = path.join(claudeSkillDir(workspaceRoot, slug), ...relSegments);\n const destDir = path.dirname(dest);\n mkdirSync(destDir, { recursive: true }); // covers templates/ + the slug dir on first install\n const tmp = path.join(destDir, `.${path.basename(dest)}.${process.pid}.tmp`);\n writeFileSync(tmp, content, \"utf-8\");\n renameSync(tmp, dest);\n return { src, dest };\n}\n\n/** Remove the active skill dir (mirrors a staging `rm -rf`). Returns the dest. */\nexport function mirrorSkillDelete(workspaceRoot: string, slug: string): { dest: string } {\n const dest = claudeSkillDir(workspaceRoot, slug);\n rmSync(dest, { recursive: true, force: true });\n return { dest };\n}\n"],"mappings":";;;;;;;AAwBA,IAAM,kBAAkBA,UAAAA,QAAK,KAAK,QAAQ,QAAQ;AAClD,IAAM,oBAAoBA,UAAAA,QAAK,KAAK,WAAW,QAAQ;AACvD,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAKxB,IAAM,UAAU;AAOhB,IAAM,QAAQ;AACd,IAAM,oBAAoB;;AAY1B,SAAgB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A,aAAAA,CAAa,KAAK,OAAO;CACzC,MAAM,OAAOF,UAAAA,QAAK,KAAK,eAAe,eAAe,IAAI,GAAG,GAAG,WAAW;CAC1E,MAAM,UAAUA,UAAAA,QAAK,QAAQ,IAAI;CACjCG,CAAAA,GAAAA,QAAAA,UAAAA,CAAU,SAAS,EAAE,WAAW,KAAK,CAAC;CACtC,MAAM,MAAMH,UAAAA,QAAK,KAAK,SAAS,IAAIA,UAAAA,QAAK,SAAS,IAAI,EAAE,GAAG,QAAQ,IAAI,KAAK;CAC3EI,CAAAA,GAAAA,QAAAA,cAAAA,CAAc,KAAK,SAAS,OAAO;CACnCC,CAAAA,GAAAA,QAAAA,WAAAA,CAAW,KAAK,IAAI;CACpB,OAAO;EAAE;EAAK;CAAK;AACrB;;AAGA,SAAgB,kBAAkB,eAAuB,MAAgC;CACvF,MAAM,OAAO,eAAe,eAAe,IAAI;CAC/CC,CAAAA,GAAAA,QAAAA,OAAAA,CAAO,MAAM;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAC7C,OAAO,EAAE,KAAK;AAChB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as isSafeActionTemplatePath } from "../templatePath-CB3wtVpe.js";
|
|
2
|
-
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
1
|
import path from "node:path";
|
|
2
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { t as isSafeActionTemplatePath } from "../templatePath-B5mHTFDX.js";
|
|
4
4
|
// src/skill-bridge/index.ts
|
|
5
5
|
var DATA_SKILLS_DIR = path.join("data", "skills");
|
|
6
6
|
var CLAUDE_SKILLS_DIR = path.join(".claude", "skills");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slug-
|
|
1
|
+
{"version":3,"file":"slug-BRj6KEiN.cjs","names":[],"sources":["../src/wiki/slug.ts"],"sourcesContent":["// Pure wiki-page slug helpers — string-only, no Node / browser\n// dependencies, importable from any bundle.\n//\n// Used by:\n// - server/workspace/wiki-pages/io.ts (the write chokepoint)\n// - server/workspace/hooks/handlers/wikiSnapshot.ts (the\n// PostToolUse handler that fires on Write/Edit of a wiki page)\n// - server/api/routes/wiki.ts (page resolver + lint)\n// - server/api/routes/wiki/history.ts (history slug guard)\n// - src/plugins/wiki/route.ts (router slug guard — replaces the\n// local `isSafeWikiSlug` duplicate that existed before the\n// pure-lib refactor)\n// - src/plugins/wiki/helpers.ts (renderer slugify for [[…]] links)\n//\n// Any helper that needs `node:path` lives in `./paths.ts` so that\n// importing this file from frontend code never pulls in Node\n// builtins.\n\n/** Reject slugs that would escape `data/wiki/pages/` once\n * joined back into a path, or that are otherwise invalid as\n * page filenames. The chokepoint must defend itself even when\n * callers derive the slug from a trusted source — a typo or\n * future caller mistake should fail loud, not silently write\n * outside the wiki tree.\n *\n * The rule is intentionally narrow — separators / `..` / NUL /\n * empty — so it only rejects unambiguous violations. Aesthetic\n * concerns (e.g. dot-prefixed filenames) are out of scope: a\n * pre-existing `data/wiki/pages/.foo.md` should remain writable\n * through the chokepoint (codex review iter-2 #883). */\nexport function isSafeSlug(slug: string): boolean {\n if (slug.length === 0) return false;\n if (slug === \".\" || slug === \"..\") return false;\n if (slug.includes(\"/\") || slug.includes(\"\\\\\")) return false;\n if (slug.includes(\"\\0\")) return false;\n return true;\n}\n\n/** Slug rules for `[[wiki link]]` text → slug derivation:\n * lowercase, spaces collapsed to hyphens, every non-ASCII /\n * non-alphanumeric / non-hyphen character stripped.\n *\n * Pure: no normalisation, no transliteration — this is the\n * same shape the index parser, page resolver, and frontend\n * renderer all need to agree on. Non-ASCII titles (e.g.\n * Japanese) collapse to an ASCII remnant here, so a caller\n * matching against real page files must go through\n * `matchWikiSlug`, which tries the untouched name first. */\nexport function wikiSlugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/\\s+/g, \"-\")\n .replace(/[^a-z0-9-]/g, \"\");\n}\n\n// Code point above which `wikiSlugify` strips a character outright.\nconst MAX_ASCII_CODE_POINT = 127;\n\nfunction hasNonAscii(text: string): boolean {\n return [...text].some((char) => (char.codePointAt(0) ?? 0) > MAX_ASCII_CODE_POINT);\n}\n\n/** Filename stem to suggest when a page has to be created for `name`,\n * or null when `name` cannot yield one.\n *\n * ASCII names keep the hyphenated slug convention. A non-ASCII name is\n * suggested verbatim — the write chokepoint accepts any `isSafeSlug`\n * filename, and slugifying it would propose a stripped remnant like\n * `-4.md` (#2940). Null rather than a salvaged stem for a name the\n * write guard would reject anyway: suggesting `wiki/pages/.md`, or\n * `secrets.md` for `../secrets`, sends the caller to a file it did\n * not ask for. */\nexport function wikiPageStem(name: string): string | null {\n const trimmed = name.trim();\n if (!isSafeSlug(trimmed)) return null;\n if (hasNonAscii(trimmed)) return trimmed;\n const slug = wikiSlugify(trimmed);\n return slug.length > 0 ? slug : null;\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,WAAW,MAAuB;CAChD,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,IAAI,SAAS,OAAO,SAAS,MAAM,OAAO;CAC1C,IAAI,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,GAAG,OAAO;CACtD,IAAI,KAAK,SAAS,IAAI,GAAG,OAAO;CAChC,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,YAAY,MAAsB;CAChD,OAAO,KACJ,YAAY,CAAC,CACb,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,eAAe,EAAE;AAC9B;AAGA,IAAM,uBAAuB;AAE7B,SAAS,YAAY,MAAuB;CAC1C,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,UAAU,KAAK,YAAY,CAAC,KAAK,KAAK,oBAAoB;AACnF;;;;;;;;;;;AAYA,SAAgB,aAAa,MAA6B;CACxD,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,WAAW,OAAO,GAAG,OAAO;CACjC,IAAI,YAAY,OAAO,GAAG,OAAO;CACjC,MAAM,OAAO,YAAY,OAAO;CAChC,OAAO,KAAK,SAAS,IAAI,OAAO;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slug-
|
|
1
|
+
{"version":3,"file":"slug-X5tnZoc-.js","names":[],"sources":["../src/wiki/slug.ts"],"sourcesContent":["// Pure wiki-page slug helpers — string-only, no Node / browser\n// dependencies, importable from any bundle.\n//\n// Used by:\n// - server/workspace/wiki-pages/io.ts (the write chokepoint)\n// - server/workspace/hooks/handlers/wikiSnapshot.ts (the\n// PostToolUse handler that fires on Write/Edit of a wiki page)\n// - server/api/routes/wiki.ts (page resolver + lint)\n// - server/api/routes/wiki/history.ts (history slug guard)\n// - src/plugins/wiki/route.ts (router slug guard — replaces the\n// local `isSafeWikiSlug` duplicate that existed before the\n// pure-lib refactor)\n// - src/plugins/wiki/helpers.ts (renderer slugify for [[…]] links)\n//\n// Any helper that needs `node:path` lives in `./paths.ts` so that\n// importing this file from frontend code never pulls in Node\n// builtins.\n\n/** Reject slugs that would escape `data/wiki/pages/` once\n * joined back into a path, or that are otherwise invalid as\n * page filenames. The chokepoint must defend itself even when\n * callers derive the slug from a trusted source — a typo or\n * future caller mistake should fail loud, not silently write\n * outside the wiki tree.\n *\n * The rule is intentionally narrow — separators / `..` / NUL /\n * empty — so it only rejects unambiguous violations. Aesthetic\n * concerns (e.g. dot-prefixed filenames) are out of scope: a\n * pre-existing `data/wiki/pages/.foo.md` should remain writable\n * through the chokepoint (codex review iter-2 #883). */\nexport function isSafeSlug(slug: string): boolean {\n if (slug.length === 0) return false;\n if (slug === \".\" || slug === \"..\") return false;\n if (slug.includes(\"/\") || slug.includes(\"\\\\\")) return false;\n if (slug.includes(\"\\0\")) return false;\n return true;\n}\n\n/** Slug rules for `[[wiki link]]` text → slug derivation:\n * lowercase, spaces collapsed to hyphens, every non-ASCII /\n * non-alphanumeric / non-hyphen character stripped.\n *\n * Pure: no normalisation, no transliteration — this is the\n * same shape the index parser, page resolver, and frontend\n * renderer all need to agree on. Non-ASCII titles (e.g.\n * Japanese) collapse to an ASCII remnant here, so a caller\n * matching against real page files must go through\n * `matchWikiSlug`, which tries the untouched name first. */\nexport function wikiSlugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/\\s+/g, \"-\")\n .replace(/[^a-z0-9-]/g, \"\");\n}\n\n// Code point above which `wikiSlugify` strips a character outright.\nconst MAX_ASCII_CODE_POINT = 127;\n\nfunction hasNonAscii(text: string): boolean {\n return [...text].some((char) => (char.codePointAt(0) ?? 0) > MAX_ASCII_CODE_POINT);\n}\n\n/** Filename stem to suggest when a page has to be created for `name`,\n * or null when `name` cannot yield one.\n *\n * ASCII names keep the hyphenated slug convention. A non-ASCII name is\n * suggested verbatim — the write chokepoint accepts any `isSafeSlug`\n * filename, and slugifying it would propose a stripped remnant like\n * `-4.md` (#2940). Null rather than a salvaged stem for a name the\n * write guard would reject anyway: suggesting `wiki/pages/.md`, or\n * `secrets.md` for `../secrets`, sends the caller to a file it did\n * not ask for. */\nexport function wikiPageStem(name: string): string | null {\n const trimmed = name.trim();\n if (!isSafeSlug(trimmed)) return null;\n if (hasNonAscii(trimmed)) return trimmed;\n const slug = wikiSlugify(trimmed);\n return slug.length > 0 ? slug : null;\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,WAAW,MAAuB;CAChD,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,IAAI,SAAS,OAAO,SAAS,MAAM,OAAO;CAC1C,IAAI,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,GAAG,OAAO;CACtD,IAAI,KAAK,SAAS,IAAI,GAAG,OAAO;CAChC,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,YAAY,MAAsB;CAChD,OAAO,KACJ,YAAY,CAAC,CACb,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,eAAe,EAAE;AAC9B;AAGA,IAAM,uBAAuB;AAE7B,SAAS,YAAY,MAAuB;CAC1C,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,UAAU,KAAK,YAAY,CAAC,KAAK,KAAK,oBAAoB;AACnF;;;;;;;;;;;AAYA,SAAgB,aAAa,MAA6B;CACxD,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,WAAW,OAAO,GAAG,OAAO;CACjC,IAAI,YAAY,OAAO,GAAG,OAAO;CACjC,MAAM,OAAO,YAAY,OAAO;CAChC,OAAO,KAAK,SAAS,IAAI,OAAO;AAClC"}
|
|
@@ -48,4 +48,4 @@ function isSafeCustomViewI18nPath(value) {
|
|
|
48
48
|
}
|
|
49
49
|
export { isSafeTemplatePath as i, isSafeCustomViewI18nPath as n, isSafeCustomViewPath as r, isSafeActionTemplatePath as t };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=templatePath-
|
|
51
|
+
//# sourceMappingURL=templatePath-B5mHTFDX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templatePath-
|
|
1
|
+
{"version":3,"file":"templatePath-B5mHTFDX.js","names":[],"sources":["../src/collection/core/templatePath.ts"],"sourcesContent":["// Shared template-path safety, used by BOTH the collection schema\n// validator (`./schemaZ` `ActionSpecZ`) and the skill-bridge\n// hook (`hooks/handlers/skillBridge.ts`). Centralised so the set of\n// action `template` paths a schema may declare is *exactly* the set\n// the bridge mirrors into `.claude/skills/<slug>/` — if the two\n// diverge, a schema can validate yet reference a template the bridge\n// silently drops (runtime \"template could not be read\").\n//\n// Keep this module dependency-free: the bridge is bundled into a lean\n// esbuild dispatcher, so it must not drag in workspace/path machinery.\n\n/** `templates/` — the subdir an action template must live under. */\nconst TEMPLATES_PREFIX = \"templates/\";\n\n/**\n * A safe skill-relative path: non-empty, no backslash, not absolute,\n * and every `/`-separated segment is a plain `[A-Za-z0-9._-]+` token\n * that isn't `.` / `..` (no traversal). Multi-segment (nested) paths\n * are allowed. The reader's realpath containment is the hard\n * guarantee; this fails a bad path fast.\n */\nexport function isSafeTemplatePath(value: string): boolean {\n if (value.length === 0 || value.includes(\"\\\\\") || value.startsWith(\"/\")) return false;\n return value.split(\"/\").every((seg) => seg.length > 0 && seg !== \".\" && seg !== \"..\" && /^[A-Za-z0-9._-]+$/.test(seg));\n}\n\n/**\n * An action `template` value: a safe path that lives under the skill's\n * `templates/` subdir. This is the canonical contract — the schema\n * validator rejects anything else up front, and the bridge mirrors\n * exactly these. Nested paths (`templates/mail/welcome.md`) and any\n * extension are allowed as long as the path is otherwise safe.\n */\nexport function isSafeActionTemplatePath(value: string): boolean {\n return value.startsWith(TEMPLATES_PREFIX) && isSafeTemplatePath(value);\n}\n\n/** `views/` — the subdir a custom-view HTML file must live under. */\nconst VIEWS_PREFIX = \"views/\";\n\n/**\n * A custom-view `file` value: a safe path under the skill's `views/`\n * subdir that ends in `.html`. Custom views are LLM-authored HTML the\n * host renders in a sandboxed iframe; constraining them to `views/*.html`\n * keeps the data folder and the schema/template files off-limits to the\n * view-file reader. Same per-segment safety as templates; the reader's\n * realpath containment is the hard guarantee.\n */\nexport function isSafeCustomViewPath(value: string): boolean {\n return value.startsWith(VIEWS_PREFIX) && /\\.html$/.test(value) && isSafeTemplatePath(value);\n}\n\n/**\n * A custom-view `i18n` value: the JSON dictionary file authors ship next to\n * their `views/<id>.html`. Constrained to `views/<name>.i18n.json` so the\n * field can only point at a translation file co-located with the view it\n * translates — the same `views/` containment the HTML reader uses. The\n * `.i18n.json` suffix (vs plain `.json`) makes the file's purpose grep-able\n * for both authors and tooling.\n */\nexport function isSafeCustomViewI18nPath(value: string): boolean {\n return value.startsWith(VIEWS_PREFIX) && /\\.i18n\\.json$/.test(value) && isSafeTemplatePath(value);\n}\n"],"mappings":";;AAYA,IAAM,mBAAmB;;;;;;;;AASzB,SAAgB,mBAAmB,OAAwB;CACzD,IAAI,MAAM,WAAW,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,WAAW,GAAG,GAAG,OAAO;CAChF,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK,QAAQ,OAAO,QAAQ,QAAQ,oBAAoB,KAAK,GAAG,CAAC;AACvH;;;;;;;;AASA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,MAAM,WAAW,gBAAgB,KAAK,mBAAmB,KAAK;AACvE;;AAGA,IAAM,eAAe;;;;;;;;;AAUrB,SAAgB,qBAAqB,OAAwB;CAC3D,OAAO,MAAM,WAAW,YAAY,KAAK,UAAU,KAAK,KAAK,KAAK,mBAAmB,KAAK;AAC5F;;;;;;;;;AAUA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,MAAM,WAAW,YAAY,KAAK,gBAAgB,KAAK,KAAK,KAAK,mBAAmB,KAAK;AAClG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templatePath-
|
|
1
|
+
{"version":3,"file":"templatePath-DSawCKNy.cjs","names":[],"sources":["../src/collection/core/templatePath.ts"],"sourcesContent":["// Shared template-path safety, used by BOTH the collection schema\n// validator (`./schemaZ` `ActionSpecZ`) and the skill-bridge\n// hook (`hooks/handlers/skillBridge.ts`). Centralised so the set of\n// action `template` paths a schema may declare is *exactly* the set\n// the bridge mirrors into `.claude/skills/<slug>/` — if the two\n// diverge, a schema can validate yet reference a template the bridge\n// silently drops (runtime \"template could not be read\").\n//\n// Keep this module dependency-free: the bridge is bundled into a lean\n// esbuild dispatcher, so it must not drag in workspace/path machinery.\n\n/** `templates/` — the subdir an action template must live under. */\nconst TEMPLATES_PREFIX = \"templates/\";\n\n/**\n * A safe skill-relative path: non-empty, no backslash, not absolute,\n * and every `/`-separated segment is a plain `[A-Za-z0-9._-]+` token\n * that isn't `.` / `..` (no traversal). Multi-segment (nested) paths\n * are allowed. The reader's realpath containment is the hard\n * guarantee; this fails a bad path fast.\n */\nexport function isSafeTemplatePath(value: string): boolean {\n if (value.length === 0 || value.includes(\"\\\\\") || value.startsWith(\"/\")) return false;\n return value.split(\"/\").every((seg) => seg.length > 0 && seg !== \".\" && seg !== \"..\" && /^[A-Za-z0-9._-]+$/.test(seg));\n}\n\n/**\n * An action `template` value: a safe path that lives under the skill's\n * `templates/` subdir. This is the canonical contract — the schema\n * validator rejects anything else up front, and the bridge mirrors\n * exactly these. Nested paths (`templates/mail/welcome.md`) and any\n * extension are allowed as long as the path is otherwise safe.\n */\nexport function isSafeActionTemplatePath(value: string): boolean {\n return value.startsWith(TEMPLATES_PREFIX) && isSafeTemplatePath(value);\n}\n\n/** `views/` — the subdir a custom-view HTML file must live under. */\nconst VIEWS_PREFIX = \"views/\";\n\n/**\n * A custom-view `file` value: a safe path under the skill's `views/`\n * subdir that ends in `.html`. Custom views are LLM-authored HTML the\n * host renders in a sandboxed iframe; constraining them to `views/*.html`\n * keeps the data folder and the schema/template files off-limits to the\n * view-file reader. Same per-segment safety as templates; the reader's\n * realpath containment is the hard guarantee.\n */\nexport function isSafeCustomViewPath(value: string): boolean {\n return value.startsWith(VIEWS_PREFIX) && /\\.html$/.test(value) && isSafeTemplatePath(value);\n}\n\n/**\n * A custom-view `i18n` value: the JSON dictionary file authors ship next to\n * their `views/<id>.html`. Constrained to `views/<name>.i18n.json` so the\n * field can only point at a translation file co-located with the view it\n * translates — the same `views/` containment the HTML reader uses. The\n * `.i18n.json` suffix (vs plain `.json`) makes the file's purpose grep-able\n * for both authors and tooling.\n */\nexport function isSafeCustomViewI18nPath(value: string): boolean {\n return value.startsWith(VIEWS_PREFIX) && /\\.i18n\\.json$/.test(value) && isSafeTemplatePath(value);\n}\n"],"mappings":";;AAYA,IAAM,mBAAmB;;;;;;;;AASzB,SAAgB,mBAAmB,OAAwB;CACzD,IAAI,MAAM,WAAW,KAAK,MAAM,SAAS,IAAI,KAAK,MAAM,WAAW,GAAG,GAAG,OAAO;CAChF,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK,QAAQ,OAAO,QAAQ,QAAQ,oBAAoB,KAAK,GAAG,CAAC;AACvH;;;;;;;;AASA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,MAAM,WAAW,gBAAgB,KAAK,mBAAmB,KAAK;AACvE;;AAGA,IAAM,eAAe;;;;;;;;;AAUrB,SAAgB,qBAAqB,OAAwB;CAC3D,OAAO,MAAM,WAAW,YAAY,KAAK,UAAU,KAAK,KAAK,KAAK,mBAAmB,KAAK;AAC5F;;;;;;;;;AAUA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,MAAM,WAAW,YAAY,KAAK,gBAAgB,KAAK,KAAK,KAAK,mBAAmB,KAAK;AAClG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-
|
|
1
|
+
{"version":3,"file":"text-BpGv7qxC.js","names":[],"sources":["../src/utils/text.ts"],"sourcesContent":["// Canonical text helpers. Browser-safe: pure string work, no node imports.\n\n/** Clip a string to at most `max` chars. The ellipsis is part of the budget,\n * so the result never exceeds `max`.\n *\n * Edge cases:\n * - `text.length <= max` → `text` unchanged.\n * - `max <= 0` → empty string (callers asking for \"no output\" should get no\n * output, not a stray ellipsis).\n * - `ellipsis.length >= max` → the ellipsis itself is clipped to `max` rather\n * than throwing. Dropping this guard is what let the pre-#2217 core copy\n * return 3 chars for `truncate(\"hello\", 2, \"...\")` while promising in its\n * own docblock that output never exceeds `max`. */\nexport function truncate(text: string, max: number, ellipsis = \"…\"): string {\n if (max <= 0) return \"\";\n if (text.length <= max) return text;\n if (ellipsis.length >= max) return ellipsis.slice(0, max);\n return text.slice(0, max - ellipsis.length) + ellipsis;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,SAAS,MAAc,KAAa,WAAW,KAAa;CAC1E,IAAI,OAAO,GAAG,OAAO;CACrB,IAAI,KAAK,UAAU,KAAK,OAAO;CAC/B,IAAI,SAAS,UAAU,KAAK,OAAO,SAAS,MAAM,GAAG,GAAG;CACxD,OAAO,KAAK,MAAM,GAAG,MAAM,SAAS,MAAM,IAAI;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-
|
|
1
|
+
{"version":3,"file":"text-CPK6ABnv.cjs","names":[],"sources":["../src/utils/text.ts"],"sourcesContent":["// Canonical text helpers. Browser-safe: pure string work, no node imports.\n\n/** Clip a string to at most `max` chars. The ellipsis is part of the budget,\n * so the result never exceeds `max`.\n *\n * Edge cases:\n * - `text.length <= max` → `text` unchanged.\n * - `max <= 0` → empty string (callers asking for \"no output\" should get no\n * output, not a stray ellipsis).\n * - `ellipsis.length >= max` → the ellipsis itself is clipped to `max` rather\n * than throwing. Dropping this guard is what let the pre-#2217 core copy\n * return 3 chars for `truncate(\"hello\", 2, \"...\")` while promising in its\n * own docblock that output never exceeds `max`. */\nexport function truncate(text: string, max: number, ellipsis = \"…\"): string {\n if (max <= 0) return \"\";\n if (text.length <= max) return text;\n if (ellipsis.length >= max) return ellipsis.slice(0, max);\n return text.slice(0, max - ellipsis.length) + ellipsis;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,SAAS,MAAc,KAAa,WAAW,KAAa;CAC1E,IAAI,OAAO,GAAG,OAAO;CACrB,IAAI,KAAK,UAAU,KAAK,OAAO;CAC/B,IAAI,SAAS,UAAU,KAAK,OAAO,SAAS,MAAM,GAAG,GAAG;CACxD,OAAO,KAAK,MAAM,GAAG,MAAM,SAAS,MAAM,IAAI;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-DPycxnDf.cjs","names":[],"sources":["../src/collection/registry/guards.ts","../src/collection/registry/registryIndex.ts","../src/collection/registry/types.ts"],"sourcesContent":["/** Narrow `unknown` to a plain object (not null, not array). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// Parse + validate the curated collection registry's published index.json.\n// Pure — no I/O. The caller fetches the JSON and hands the parsed value here.\n// Mirrors the registry repo's schema/index.schema.json contract (schemaVersion 1):\n// receptron/mulmoclaude-collections.\n//\n// The index is host-fetched convenience data for the Discover catalog, not a\n// trust boundary: a collection's actual files are re-validated on import.\n\nimport { isRecord } from \"./guards.js\";\n\nexport interface RegistryEntry {\n /** `<author>/<slug>` — identity inside its source registry. NOT globally\n * unique when multiple registries are configured — pair with `registryName`\n * for a global key. */\n id: string;\n author: string;\n slug: string;\n title: string;\n icon: string;\n description: string;\n version: string;\n tags: string[];\n license: string;\n fieldCount: number;\n /** Custom view labels. */\n views: string[];\n hasSeed: boolean;\n seedCount: number;\n /** repo-relative path, omitted when absent. */\n screenshot?: string | undefined;\n /** repo-relative collection dir. */\n path: string;\n /** Stable bundle hash for update detection. */\n contentSha: string;\n /** Label of the source registry. Set by the client (not by the parser) when\n * the index is fetched, so the import / preview path can resolve the right\n * rawBase. `\"official\"` for receptron/mulmoclaude-collections; otherwise\n * the user's config entry name. */\n registryName: string;\n}\n\nexport interface RegistryIndex {\n schemaVersion: number;\n generatedAt: string;\n registry: string;\n collections: RegistryEntry[];\n}\n\nexport type ParseResult = { ok: true; index: RegistryIndex } | { ok: false; error: string };\n\nconst SUPPORTED_SCHEMA_VERSION = 1;\n\nconst pickString = (rec: Record<string, unknown>, key: string): string | undefined => {\n const value = rec[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n};\n\n// Count fields (fieldCount/seedCount) must be non-negative integers. A present\n// but negative/fractional value is rejected rather than served to the UI; an\n// absent value defaults to 0.\nfunction validatedCount(rec: Record<string, unknown>, key: string): number | \"invalid\" {\n const value = rec[key];\n if (value === undefined) return 0;\n return typeof value === \"number\" && Number.isInteger(value) && value >= 0 ? value : \"invalid\";\n}\n\nconst pickBoolean = (rec: Record<string, unknown>, key: string): boolean | undefined => {\n const value = rec[key];\n return typeof value === \"boolean\" ? value : undefined;\n};\n\nconst asStringArray = (value: unknown): string[] => (Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : []);\n\n// Identifier allowlists (mirror the registry's meta.schema.json). Crucially these\n// exclude `.`, `/`, `\\`, and `..`, so a poisoned author/slug can never make\n// collectionFileUrl() escape the collections/<author>/<slug> subtree — even if the\n// entry is internally consistent. Bounded quantifiers (no ReDoS).\nconst AUTHOR_RE = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/;\nconst SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;\n\n// author/slug must be allowlisted identifiers, and id/path must agree with them, so a\n// lookup by author+slug can never fetch files from a different (or out-of-tree)\n// directory than requested (defense against a poisoned index).\nfunction identityError(entryId: string, author: string, slug: string, dirPath: string, index: number): string | null {\n if (!AUTHOR_RE.test(author)) return `collections[${index}].author has an invalid format`;\n if (!SLUG_RE.test(slug)) return `collections[${index}].slug has an invalid format`;\n if (entryId !== `${author}/${slug}`) return `collections[${index}].id must equal \"${author}/${slug}\"`;\n if (dirPath !== `collections/${author}/${slug}`) return `collections[${index}].path must equal \"collections/${author}/${slug}\"`;\n return null;\n}\n\nfunction validatedCounts(value: Record<string, unknown>, index: number): { fieldCount: number; seedCount: number } | string {\n const fieldCount = validatedCount(value, \"fieldCount\");\n const seedCount = validatedCount(value, \"seedCount\");\n if (fieldCount === \"invalid\") return `collections[${index}].fieldCount must be a non-negative integer`;\n if (seedCount === \"invalid\") return `collections[${index}].seedCount must be a non-negative integer`;\n return { fieldCount, seedCount };\n}\n\nfunction parseEntry(value: unknown, index: number, registryName: string): RegistryEntry | string {\n if (!isRecord(value)) return `collections[${index}] is not an object`;\n const entryId = pickString(value, \"id\");\n const author = pickString(value, \"author\");\n const slug = pickString(value, \"slug\");\n const title = pickString(value, \"title\");\n const version = pickString(value, \"version\");\n const path = pickString(value, \"path\");\n const contentSha = pickString(value, \"contentSha\");\n if (!entryId || !author || !slug || !title || !version || !path || !contentSha) {\n return `collections[${index}] is missing a required string field (id/author/slug/title/version/path/contentSha)`;\n }\n const mismatch = identityError(entryId, author, slug, path, index);\n if (mismatch) return mismatch;\n const counts = validatedCounts(value, index);\n if (typeof counts === \"string\") return counts;\n return {\n id: entryId,\n author,\n slug,\n title,\n version,\n path,\n contentSha,\n icon: pickString(value, \"icon\") ?? \"\",\n description: pickString(value, \"description\") ?? \"\",\n license: pickString(value, \"license\") ?? \"\",\n tags: asStringArray(value.tags),\n views: asStringArray(value.views),\n fieldCount: counts.fieldCount,\n seedCount: counts.seedCount,\n hasSeed: pickBoolean(value, \"hasSeed\") ?? false,\n screenshot: pickString(value, \"screenshot\"),\n registryName,\n };\n}\n\n/** Parse an index payload. `registryName` labels every entry produced — the\n * caller passes \"official\" for the canonical registry or the user's config\n * entry name. The label is needed downstream so import / preview can pick the\n * right rawBase for per-collection files. */\nexport function parseRegistryIndex(value: unknown, registryName: string): ParseResult {\n if (!isRecord(value)) return { ok: false, error: \"index is not an object\" };\n if (value.schemaVersion !== SUPPORTED_SCHEMA_VERSION) {\n return { ok: false, error: `unsupported schemaVersion (expected ${SUPPORTED_SCHEMA_VERSION})` };\n }\n const registry = pickString(value, \"registry\");\n const generatedAt = pickString(value, \"generatedAt\");\n if (!registry || !generatedAt) return { ok: false, error: \"index missing registry/generatedAt\" };\n if (!Array.isArray(value.collections)) return { ok: false, error: \"index.collections must be an array\" };\n\n const parsed = value.collections.map((entry, idx) => parseEntry(entry, idx, registryName));\n const firstError = parsed.find((entry): entry is string => typeof entry === \"string\");\n if (firstError !== undefined) return { ok: false, error: firstError };\n const collections = parsed.filter((entry): entry is RegistryEntry => typeof entry !== \"string\");\n return { ok: true, index: { schemaVersion: SUPPORTED_SCHEMA_VERSION, registry, generatedAt, collections } };\n}\n","// Isomorphic contract shared by the registry engine, the host routes, and the\n// collection plugin's Discover UI. No I/O — types + a reserved-name constant.\n\nimport type { RegistryEntry } from \"./registryIndex.js\";\n\nexport interface RegistryConfigEntry {\n /** Short label shown on Discover cards + used as the routing key. */\n name: string;\n /** Absolute HTTPS URL of the registry's index.json. */\n indexUrl: string;\n /** Absolute HTTPS base for per-collection files (no trailing slash). */\n rawBaseUrl: string;\n}\n\n/** Reserved name for the official registry. The client always synthesizes one\n * entry under this name; user config that re-uses it is rejected. */\nexport const OFFICIAL_REGISTRY_NAME = \"official\";\n\n/** Per-registry summary in the merged Discover response. */\nexport interface RegistrySummary {\n name: string;\n /** `ok` = fresh, `stale` = served from cache because the upstream failed,\n * `failed` = no cache to fall back to (the entries contribution is 0). */\n status: \"ok\" | \"stale\" | \"failed\";\n generatedAt: string | null;\n error: string | null;\n entryCount: number;\n}\n\n/** `GET …collectionsRegistry.list` — the Discover catalog merged across every\n * configured registry. */\nexport interface RegistryListResponse {\n registries: RegistrySummary[];\n /** Convenience flag: true iff any single registry's contribution was stale. */\n stale: boolean;\n collections: RegistryEntry[];\n}\n\n/** `POST …collectionsRegistry.import` — install result. */\nexport interface RegistryImportResponse {\n localSlug: string;\n updated: boolean;\n seedWritten: number;\n seedSkipped: boolean;\n}\n"],"mappings":";;AACA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AC+CA,IAAM,2BAA2B;AAEjC,IAAM,cAAc,KAA8B,QAAoC;CACpF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;AAKA,SAAS,eAAe,KAA8B,KAAiC;CACrF,MAAM,QAAQ,IAAI;CAClB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS,IAAI,QAAQ;AACtF;AAEA,IAAM,eAAe,KAA8B,QAAqC;CACtF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,QAAQ,KAAA;AAC9C;AAEA,IAAM,iBAAiB,UAA8B,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;AAMhJ,IAAM,YAAY;AAClB,IAAM,UAAU;AAKhB,SAAS,cAAc,SAAiB,QAAgB,MAAc,SAAiB,OAA8B;CACnH,IAAI,CAAC,UAAU,KAAK,MAAM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,WAAW,OAAO,aAAa,KAAK;EACjD,SAAS,WAAW,OAAO,SAAS,KAAK;EACzC,MAAM,cAAc,MAAM,IAAI;EAC9B,OAAO,cAAc,MAAM,KAAK;EAChC,YAAY,OAAO;EACnB,WAAW,OAAO;EAClB,SAAS,YAAY,OAAO,SAAS,KAAK;EAC1C,YAAY,WAAW,OAAO,YAAY;EAC1C;CACF;AACF;;;;;AAMA,SAAgB,mBAAmB,OAAgB,cAAmC;CACpF,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO;EAAE,IAAI;EAAO,OAAO;CAAyB;CAC1E,IAAI,MAAM,kBAAkB,0BAC1B,OAAO;EAAE,IAAI;EAAO,OAAO,uCAAuC,yBAAyB;CAAG;CAEhG,MAAM,WAAW,WAAW,OAAO,UAAU;CAC7C,MAAM,cAAc,WAAW,OAAO,aAAa;CACnD,IAAI,CAAC,YAAY,CAAC,aAAa,OAAO;EAAE,IAAI;EAAO,OAAO;CAAqC;CAC/F,IAAI,CAAC,MAAM,QAAQ,MAAM,WAAW,GAAG,OAAO;EAAE,IAAI;EAAO,OAAO;CAAqC;CAEvG,MAAM,SAAS,MAAM,YAAY,KAAK,OAAO,QAAQ,WAAW,OAAO,KAAK,YAAY,CAAC;CACzF,MAAM,aAAa,OAAO,MAAM,UAA2B,OAAO,UAAU,QAAQ;CACpF,IAAI,eAAe,KAAA,GAAW,OAAO;EAAE,IAAI;EAAO,OAAO;CAAW;CAEpE,OAAO;EAAE,IAAI;EAAM,OAAO;GAAE,eAAe;GAA0B;GAAU;GAAa,aADxE,OAAO,QAAQ,UAAkC,OAAO,UAAU,QACM;EAAY;CAAE;AAC5G;;;;AC3IA,IAAa,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"types-Bmk0fWDr.cjs","names":[],"sources":["../src/collection/registry/guards.ts","../src/collection/registry/registryIndex.ts","../src/collection/registry/types.ts"],"sourcesContent":["/** Narrow `unknown` to a plain object (not null, not array). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// Parse + validate the curated collection registry's published index.json.\n// Pure — no I/O. The caller fetches the JSON and hands the parsed value here.\n// Mirrors the registry repo's schema/index.schema.json contract (schemaVersion 1):\n// receptron/mulmoclaude-collections.\n//\n// The index is host-fetched convenience data for the Discover catalog, not a\n// trust boundary: a collection's actual files are re-validated on import.\n\nimport { isRecord } from \"./guards.js\";\n\nexport interface RegistryEntry {\n /** `<author>/<slug>` — identity inside its source registry. NOT globally\n * unique when multiple registries are configured — pair with `registryName`\n * for a global key. */\n id: string;\n author: string;\n slug: string;\n title: string;\n icon: string;\n description: string;\n version: string;\n tags: string[];\n license: string;\n fieldCount: number;\n /** Custom view labels. */\n views: string[];\n hasSeed: boolean;\n seedCount: number;\n /** repo-relative path, omitted when absent. */\n screenshot?: string | undefined;\n /** repo-relative collection dir. */\n path: string;\n /** Stable bundle hash for update detection. */\n contentSha: string;\n /** Label of the source registry. Set by the client (not by the parser) when\n * the index is fetched, so the import / preview path can resolve the right\n * rawBase. `\"official\"` for receptron/mulmoclaude-collections; otherwise\n * the user's config entry name. */\n registryName: string;\n}\n\nexport interface RegistryIndex {\n schemaVersion: number;\n generatedAt: string;\n registry: string;\n collections: RegistryEntry[];\n}\n\nexport type ParseResult = { ok: true; index: RegistryIndex } | { ok: false; error: string };\n\nconst SUPPORTED_SCHEMA_VERSION = 1;\n\nconst pickString = (rec: Record<string, unknown>, key: string): string | undefined => {\n const value = rec[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n};\n\n// Count fields (fieldCount/seedCount) must be non-negative integers. A present\n// but negative/fractional value is rejected rather than served to the UI; an\n// absent value defaults to 0.\nfunction validatedCount(rec: Record<string, unknown>, key: string): number | \"invalid\" {\n const value = rec[key];\n if (value === undefined) return 0;\n return typeof value === \"number\" && Number.isInteger(value) && value >= 0 ? value : \"invalid\";\n}\n\nconst pickBoolean = (rec: Record<string, unknown>, key: string): boolean | undefined => {\n const value = rec[key];\n return typeof value === \"boolean\" ? value : undefined;\n};\n\nconst asStringArray = (value: unknown): string[] => (Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : []);\n\n// Identifier allowlists (mirror the registry's meta.schema.json). Crucially these\n// exclude `.`, `/`, `\\`, and `..`, so a poisoned author/slug can never make\n// collectionFileUrl() escape the collections/<author>/<slug> subtree — even if the\n// entry is internally consistent. Bounded quantifiers (no ReDoS).\nconst AUTHOR_RE = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/;\nconst SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;\n\n// author/slug must be allowlisted identifiers, and id/path must agree with them, so a\n// lookup by author+slug can never fetch files from a different (or out-of-tree)\n// directory than requested (defense against a poisoned index).\nfunction identityError(entryId: string, author: string, slug: string, dirPath: string, index: number): string | null {\n if (!AUTHOR_RE.test(author)) return `collections[${index}].author has an invalid format`;\n if (!SLUG_RE.test(slug)) return `collections[${index}].slug has an invalid format`;\n if (entryId !== `${author}/${slug}`) return `collections[${index}].id must equal \"${author}/${slug}\"`;\n if (dirPath !== `collections/${author}/${slug}`) return `collections[${index}].path must equal \"collections/${author}/${slug}\"`;\n return null;\n}\n\nfunction validatedCounts(value: Record<string, unknown>, index: number): { fieldCount: number; seedCount: number } | string {\n const fieldCount = validatedCount(value, \"fieldCount\");\n const seedCount = validatedCount(value, \"seedCount\");\n if (fieldCount === \"invalid\") return `collections[${index}].fieldCount must be a non-negative integer`;\n if (seedCount === \"invalid\") return `collections[${index}].seedCount must be a non-negative integer`;\n return { fieldCount, seedCount };\n}\n\nfunction parseEntry(value: unknown, index: number, registryName: string): RegistryEntry | string {\n if (!isRecord(value)) return `collections[${index}] is not an object`;\n const entryId = pickString(value, \"id\");\n const author = pickString(value, \"author\");\n const slug = pickString(value, \"slug\");\n const title = pickString(value, \"title\");\n const version = pickString(value, \"version\");\n const path = pickString(value, \"path\");\n const contentSha = pickString(value, \"contentSha\");\n if (!entryId || !author || !slug || !title || !version || !path || !contentSha) {\n return `collections[${index}] is missing a required string field (id/author/slug/title/version/path/contentSha)`;\n }\n const mismatch = identityError(entryId, author, slug, path, index);\n if (mismatch) return mismatch;\n const counts = validatedCounts(value, index);\n if (typeof counts === \"string\") return counts;\n return {\n id: entryId,\n author,\n slug,\n title,\n version,\n path,\n contentSha,\n icon: pickString(value, \"icon\") ?? \"\",\n description: pickString(value, \"description\") ?? \"\",\n license: pickString(value, \"license\") ?? \"\",\n tags: asStringArray(value.tags),\n views: asStringArray(value.views),\n fieldCount: counts.fieldCount,\n seedCount: counts.seedCount,\n hasSeed: pickBoolean(value, \"hasSeed\") ?? false,\n screenshot: pickString(value, \"screenshot\"),\n registryName,\n };\n}\n\n/** Parse an index payload. `registryName` labels every entry produced — the\n * caller passes \"official\" for the canonical registry or the user's config\n * entry name. The label is needed downstream so import / preview can pick the\n * right rawBase for per-collection files. */\nexport function parseRegistryIndex(value: unknown, registryName: string): ParseResult {\n if (!isRecord(value)) return { ok: false, error: \"index is not an object\" };\n if (value.schemaVersion !== SUPPORTED_SCHEMA_VERSION) {\n return { ok: false, error: `unsupported schemaVersion (expected ${SUPPORTED_SCHEMA_VERSION})` };\n }\n const registry = pickString(value, \"registry\");\n const generatedAt = pickString(value, \"generatedAt\");\n if (!registry || !generatedAt) return { ok: false, error: \"index missing registry/generatedAt\" };\n if (!Array.isArray(value.collections)) return { ok: false, error: \"index.collections must be an array\" };\n\n const parsed = value.collections.map((entry, idx) => parseEntry(entry, idx, registryName));\n const firstError = parsed.find((entry): entry is string => typeof entry === \"string\");\n if (firstError !== undefined) return { ok: false, error: firstError };\n const collections = parsed.filter((entry): entry is RegistryEntry => typeof entry !== \"string\");\n return { ok: true, index: { schemaVersion: SUPPORTED_SCHEMA_VERSION, registry, generatedAt, collections } };\n}\n","// Isomorphic contract shared by the registry engine, the host routes, and the\n// collection plugin's Discover UI. No I/O — types + a reserved-name constant.\n\nimport type { RegistryEntry } from \"./registryIndex.js\";\n\nexport interface RegistryConfigEntry {\n /** Short label shown on Discover cards + used as the routing key. */\n name: string;\n /** Absolute HTTPS URL of the registry's index.json. */\n indexUrl: string;\n /** Absolute HTTPS base for per-collection files (no trailing slash). */\n rawBaseUrl: string;\n}\n\n/** Reserved name for the official registry. The client always synthesizes one\n * entry under this name; user config that re-uses it is rejected. */\nexport const OFFICIAL_REGISTRY_NAME = \"official\";\n\n/** Per-registry summary in the merged Discover response. */\nexport interface RegistrySummary {\n name: string;\n /** `ok` = fresh, `stale` = served from cache because the upstream failed,\n * `failed` = no cache to fall back to (the entries contribution is 0). */\n status: \"ok\" | \"stale\" | \"failed\";\n generatedAt: string | null;\n error: string | null;\n entryCount: number;\n}\n\n/** `GET …collectionsRegistry.list` — the Discover catalog merged across every\n * configured registry. */\nexport interface RegistryListResponse {\n registries: RegistrySummary[];\n /** Convenience flag: true iff any single registry's contribution was stale. */\n stale: boolean;\n collections: RegistryEntry[];\n}\n\n/** `POST …collectionsRegistry.import` — install result. */\nexport interface RegistryImportResponse {\n localSlug: string;\n updated: boolean;\n seedWritten: number;\n seedSkipped: boolean;\n}\n"],"mappings":";;AACA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AC+CA,IAAM,2BAA2B;AAEjC,IAAM,cAAc,KAA8B,QAAoC;CACpF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;AAKA,SAAS,eAAe,KAA8B,KAAiC;CACrF,MAAM,QAAQ,IAAI;CAClB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS,IAAI,QAAQ;AACtF;AAEA,IAAM,eAAe,KAA8B,QAAqC;CACtF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,QAAQ,KAAA;AAC9C;AAEA,IAAM,iBAAiB,UAA8B,MA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Aa,yBAAyB"}
|
|
@@ -117,4 +117,4 @@ function parseRegistryIndex(value, registryName) {
|
|
|
117
117
|
var OFFICIAL_REGISTRY_NAME = "official";
|
|
118
118
|
export { parseRegistryIndex as n, isRecord as r, OFFICIAL_REGISTRY_NAME as t };
|
|
119
119
|
|
|
120
|
-
//# sourceMappingURL=types-
|
|
120
|
+
//# sourceMappingURL=types-CuiYCIof.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-BLCZTGW2.js","names":[],"sources":["../src/collection/registry/guards.ts","../src/collection/registry/registryIndex.ts","../src/collection/registry/types.ts"],"sourcesContent":["/** Narrow `unknown` to a plain object (not null, not array). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// Parse + validate the curated collection registry's published index.json.\n// Pure — no I/O. The caller fetches the JSON and hands the parsed value here.\n// Mirrors the registry repo's schema/index.schema.json contract (schemaVersion 1):\n// receptron/mulmoclaude-collections.\n//\n// The index is host-fetched convenience data for the Discover catalog, not a\n// trust boundary: a collection's actual files are re-validated on import.\n\nimport { isRecord } from \"./guards.js\";\n\nexport interface RegistryEntry {\n /** `<author>/<slug>` — identity inside its source registry. NOT globally\n * unique when multiple registries are configured — pair with `registryName`\n * for a global key. */\n id: string;\n author: string;\n slug: string;\n title: string;\n icon: string;\n description: string;\n version: string;\n tags: string[];\n license: string;\n fieldCount: number;\n /** Custom view labels. */\n views: string[];\n hasSeed: boolean;\n seedCount: number;\n /** repo-relative path, omitted when absent. */\n screenshot?: string | undefined;\n /** repo-relative collection dir. */\n path: string;\n /** Stable bundle hash for update detection. */\n contentSha: string;\n /** Label of the source registry. Set by the client (not by the parser) when\n * the index is fetched, so the import / preview path can resolve the right\n * rawBase. `\"official\"` for receptron/mulmoclaude-collections; otherwise\n * the user's config entry name. */\n registryName: string;\n}\n\nexport interface RegistryIndex {\n schemaVersion: number;\n generatedAt: string;\n registry: string;\n collections: RegistryEntry[];\n}\n\nexport type ParseResult = { ok: true; index: RegistryIndex } | { ok: false; error: string };\n\nconst SUPPORTED_SCHEMA_VERSION = 1;\n\nconst pickString = (rec: Record<string, unknown>, key: string): string | undefined => {\n const value = rec[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n};\n\n// Count fields (fieldCount/seedCount) must be non-negative integers. A present\n// but negative/fractional value is rejected rather than served to the UI; an\n// absent value defaults to 0.\nfunction validatedCount(rec: Record<string, unknown>, key: string): number | \"invalid\" {\n const value = rec[key];\n if (value === undefined) return 0;\n return typeof value === \"number\" && Number.isInteger(value) && value >= 0 ? value : \"invalid\";\n}\n\nconst pickBoolean = (rec: Record<string, unknown>, key: string): boolean | undefined => {\n const value = rec[key];\n return typeof value === \"boolean\" ? value : undefined;\n};\n\nconst asStringArray = (value: unknown): string[] => (Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : []);\n\n// Identifier allowlists (mirror the registry's meta.schema.json). Crucially these\n// exclude `.`, `/`, `\\`, and `..`, so a poisoned author/slug can never make\n// collectionFileUrl() escape the collections/<author>/<slug> subtree — even if the\n// entry is internally consistent. Bounded quantifiers (no ReDoS).\nconst AUTHOR_RE = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/;\nconst SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;\n\n// author/slug must be allowlisted identifiers, and id/path must agree with them, so a\n// lookup by author+slug can never fetch files from a different (or out-of-tree)\n// directory than requested (defense against a poisoned index).\nfunction identityError(entryId: string, author: string, slug: string, dirPath: string, index: number): string | null {\n if (!AUTHOR_RE.test(author)) return `collections[${index}].author has an invalid format`;\n if (!SLUG_RE.test(slug)) return `collections[${index}].slug has an invalid format`;\n if (entryId !== `${author}/${slug}`) return `collections[${index}].id must equal \"${author}/${slug}\"`;\n if (dirPath !== `collections/${author}/${slug}`) return `collections[${index}].path must equal \"collections/${author}/${slug}\"`;\n return null;\n}\n\nfunction validatedCounts(value: Record<string, unknown>, index: number): { fieldCount: number; seedCount: number } | string {\n const fieldCount = validatedCount(value, \"fieldCount\");\n const seedCount = validatedCount(value, \"seedCount\");\n if (fieldCount === \"invalid\") return `collections[${index}].fieldCount must be a non-negative integer`;\n if (seedCount === \"invalid\") return `collections[${index}].seedCount must be a non-negative integer`;\n return { fieldCount, seedCount };\n}\n\nfunction parseEntry(value: unknown, index: number, registryName: string): RegistryEntry | string {\n if (!isRecord(value)) return `collections[${index}] is not an object`;\n const entryId = pickString(value, \"id\");\n const author = pickString(value, \"author\");\n const slug = pickString(value, \"slug\");\n const title = pickString(value, \"title\");\n const version = pickString(value, \"version\");\n const path = pickString(value, \"path\");\n const contentSha = pickString(value, \"contentSha\");\n if (!entryId || !author || !slug || !title || !version || !path || !contentSha) {\n return `collections[${index}] is missing a required string field (id/author/slug/title/version/path/contentSha)`;\n }\n const mismatch = identityError(entryId, author, slug, path, index);\n if (mismatch) return mismatch;\n const counts = validatedCounts(value, index);\n if (typeof counts === \"string\") return counts;\n return {\n id: entryId,\n author,\n slug,\n title,\n version,\n path,\n contentSha,\n icon: pickString(value, \"icon\") ?? \"\",\n description: pickString(value, \"description\") ?? \"\",\n license: pickString(value, \"license\") ?? \"\",\n tags: asStringArray(value.tags),\n views: asStringArray(value.views),\n fieldCount: counts.fieldCount,\n seedCount: counts.seedCount,\n hasSeed: pickBoolean(value, \"hasSeed\") ?? false,\n screenshot: pickString(value, \"screenshot\"),\n registryName,\n };\n}\n\n/** Parse an index payload. `registryName` labels every entry produced — the\n * caller passes \"official\" for the canonical registry or the user's config\n * entry name. The label is needed downstream so import / preview can pick the\n * right rawBase for per-collection files. */\nexport function parseRegistryIndex(value: unknown, registryName: string): ParseResult {\n if (!isRecord(value)) return { ok: false, error: \"index is not an object\" };\n if (value.schemaVersion !== SUPPORTED_SCHEMA_VERSION) {\n return { ok: false, error: `unsupported schemaVersion (expected ${SUPPORTED_SCHEMA_VERSION})` };\n }\n const registry = pickString(value, \"registry\");\n const generatedAt = pickString(value, \"generatedAt\");\n if (!registry || !generatedAt) return { ok: false, error: \"index missing registry/generatedAt\" };\n if (!Array.isArray(value.collections)) return { ok: false, error: \"index.collections must be an array\" };\n\n const parsed = value.collections.map((entry, idx) => parseEntry(entry, idx, registryName));\n const firstError = parsed.find((entry): entry is string => typeof entry === \"string\");\n if (firstError !== undefined) return { ok: false, error: firstError };\n const collections = parsed.filter((entry): entry is RegistryEntry => typeof entry !== \"string\");\n return { ok: true, index: { schemaVersion: SUPPORTED_SCHEMA_VERSION, registry, generatedAt, collections } };\n}\n","// Isomorphic contract shared by the registry engine, the host routes, and the\n// collection plugin's Discover UI. No I/O — types + a reserved-name constant.\n\nimport type { RegistryEntry } from \"./registryIndex.js\";\n\nexport interface RegistryConfigEntry {\n /** Short label shown on Discover cards + used as the routing key. */\n name: string;\n /** Absolute HTTPS URL of the registry's index.json. */\n indexUrl: string;\n /** Absolute HTTPS base for per-collection files (no trailing slash). */\n rawBaseUrl: string;\n}\n\n/** Reserved name for the official registry. The client always synthesizes one\n * entry under this name; user config that re-uses it is rejected. */\nexport const OFFICIAL_REGISTRY_NAME = \"official\";\n\n/** Per-registry summary in the merged Discover response. */\nexport interface RegistrySummary {\n name: string;\n /** `ok` = fresh, `stale` = served from cache because the upstream failed,\n * `failed` = no cache to fall back to (the entries contribution is 0). */\n status: \"ok\" | \"stale\" | \"failed\";\n generatedAt: string | null;\n error: string | null;\n entryCount: number;\n}\n\n/** `GET …collectionsRegistry.list` — the Discover catalog merged across every\n * configured registry. */\nexport interface RegistryListResponse {\n registries: RegistrySummary[];\n /** Convenience flag: true iff any single registry's contribution was stale. */\n stale: boolean;\n collections: RegistryEntry[];\n}\n\n/** `POST …collectionsRegistry.import` — install result. */\nexport interface RegistryImportResponse {\n localSlug: string;\n updated: boolean;\n seedWritten: number;\n seedSkipped: boolean;\n}\n"],"mappings":";;AACA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AC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I;EAAO,OAAO;CAAqC;CAC/F,IAAI,CAAC,MAAM,QAAQ,MAAM,WAAW,GAAG,OAAO;EAAE,IAAI;EAAO,OAAO;CAAqC;CAEvG,MAAM,SAAS,MAAM,YAAY,KAAK,OAAO,QAAQ,WAAW,OAAO,KAAK,YAAY,CAAC;CACzF,MAAM,aAAa,OAAO,MAAM,UAA2B,OAAO,UAAU,QAAQ;CACpF,IAAI,eAAe,KAAA,GAAW,OAAO;EAAE,IAAI;EAAO,OAAO;CAAW;CAEpE,OAAO;EAAE,IAAI;EAAM,OAAO;GAAE,eAAe;GAA0B;GAAU;GAAa,aADxE,OAAO,QAAQ,UAAkC,OAAO,UAAU,QACM;EAAY;CAAE;AAC5G;;;;AC3IA,IAAa,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"types-CuiYCIof.js","names":[],"sources":["../src/collection/registry/guards.ts","../src/collection/registry/registryIndex.ts","../src/collection/registry/types.ts"],"sourcesContent":["/** Narrow `unknown` to a plain object (not null, not array). */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","// Parse + validate the curated collection registry's published index.json.\n// Pure — no I/O. The caller fetches the JSON and hands the parsed value here.\n// Mirrors the registry repo's schema/index.schema.json contract (schemaVersion 1):\n// receptron/mulmoclaude-collections.\n//\n// The index is host-fetched convenience data for the Discover catalog, not a\n// trust boundary: a collection's actual files are re-validated on import.\n\nimport { isRecord } from \"./guards.js\";\n\nexport interface RegistryEntry {\n /** `<author>/<slug>` — identity inside its source registry. NOT globally\n * unique when multiple registries are configured — pair with `registryName`\n * for a global key. */\n id: string;\n author: string;\n slug: string;\n title: string;\n icon: string;\n description: string;\n version: string;\n tags: string[];\n license: string;\n fieldCount: number;\n /** Custom view labels. */\n views: string[];\n hasSeed: boolean;\n seedCount: number;\n /** repo-relative path, omitted when absent. */\n screenshot?: string | undefined;\n /** repo-relative collection dir. */\n path: string;\n /** Stable bundle hash for update detection. */\n contentSha: string;\n /** Label of the source registry. Set by the client (not by the parser) when\n * the index is fetched, so the import / preview path can resolve the right\n * rawBase. `\"official\"` for receptron/mulmoclaude-collections; otherwise\n * the user's config entry name. */\n registryName: string;\n}\n\nexport interface RegistryIndex {\n schemaVersion: number;\n generatedAt: string;\n registry: string;\n collections: RegistryEntry[];\n}\n\nexport type ParseResult = { ok: true; index: RegistryIndex } | { ok: false; error: string };\n\nconst SUPPORTED_SCHEMA_VERSION = 1;\n\nconst pickString = (rec: Record<string, unknown>, key: string): string | undefined => {\n const value = rec[key];\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n};\n\n// Count fields (fieldCount/seedCount) must be non-negative integers. A present\n// but negative/fractional value is rejected rather than served to the UI; an\n// absent value defaults to 0.\nfunction validatedCount(rec: Record<string, unknown>, key: string): number | \"invalid\" {\n const value = rec[key];\n if (value === undefined) return 0;\n return typeof value === \"number\" && Number.isInteger(value) && value >= 0 ? value : \"invalid\";\n}\n\nconst pickBoolean = (rec: Record<string, unknown>, key: string): boolean | undefined => {\n const value = rec[key];\n return typeof value === \"boolean\" ? value : undefined;\n};\n\nconst asStringArray = (value: unknown): string[] => (Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : []);\n\n// Identifier allowlists (mirror the registry's meta.schema.json). Crucially these\n// exclude `.`, `/`, `\\`, and `..`, so a poisoned author/slug can never make\n// collectionFileUrl() escape the collections/<author>/<slug> subtree — even if the\n// entry is internally consistent. Bounded quantifiers (no ReDoS).\nconst AUTHOR_RE = /^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/;\nconst SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;\n\n// author/slug must be allowlisted identifiers, and id/path must agree with them, so a\n// lookup by author+slug can never fetch files from a different (or out-of-tree)\n// directory than requested (defense against a poisoned index).\nfunction identityError(entryId: string, author: string, slug: string, dirPath: string, index: number): string | null {\n if (!AUTHOR_RE.test(author)) return `collections[${index}].author has an invalid format`;\n if (!SLUG_RE.test(slug)) return `collections[${index}].slug has an invalid format`;\n if (entryId !== `${author}/${slug}`) return `collections[${index}].id must equal \"${author}/${slug}\"`;\n if (dirPath !== `collections/${author}/${slug}`) return `collections[${index}].path must equal \"collections/${author}/${slug}\"`;\n return null;\n}\n\nfunction validatedCounts(value: Record<string, unknown>, index: number): { fieldCount: number; seedCount: number } | string {\n const fieldCount = validatedCount(value, \"fieldCount\");\n const seedCount = validatedCount(value, \"seedCount\");\n if (fieldCount === \"invalid\") return `collections[${index}].fieldCount must be a non-negative integer`;\n if (seedCount === \"invalid\") return `collections[${index}].seedCount must be a non-negative integer`;\n return { fieldCount, seedCount };\n}\n\nfunction parseEntry(value: unknown, index: number, registryName: string): RegistryEntry | string {\n if (!isRecord(value)) return `collections[${index}] is not an object`;\n const entryId = pickString(value, \"id\");\n const author = pickString(value, \"author\");\n const slug = pickString(value, \"slug\");\n const title = pickString(value, \"title\");\n const version = pickString(value, \"version\");\n const path = pickString(value, \"path\");\n const contentSha = pickString(value, \"contentSha\");\n if (!entryId || !author || !slug || !title || !version || !path || !contentSha) {\n return `collections[${index}] is missing a required string field (id/author/slug/title/version/path/contentSha)`;\n }\n const mismatch = identityError(entryId, author, slug, path, index);\n if (mismatch) return mismatch;\n const counts = validatedCounts(value, index);\n if (typeof counts === \"string\") return counts;\n return {\n id: entryId,\n author,\n slug,\n title,\n version,\n path,\n contentSha,\n icon: pickString(value, \"icon\") ?? \"\",\n description: pickString(value, \"description\") ?? \"\",\n license: pickString(value, \"license\") ?? \"\",\n tags: asStringArray(value.tags),\n views: asStringArray(value.views),\n fieldCount: counts.fieldCount,\n seedCount: counts.seedCount,\n hasSeed: pickBoolean(value, \"hasSeed\") ?? false,\n screenshot: pickString(value, \"screenshot\"),\n registryName,\n };\n}\n\n/** Parse an index payload. `registryName` labels every entry produced — the\n * caller passes \"official\" for the canonical registry or the user's config\n * entry name. The label is needed downstream so import / preview can pick the\n * right rawBase for per-collection files. */\nexport function parseRegistryIndex(value: unknown, registryName: string): ParseResult {\n if (!isRecord(value)) return { ok: false, error: \"index is not an object\" };\n if (value.schemaVersion !== SUPPORTED_SCHEMA_VERSION) {\n return { ok: false, error: `unsupported schemaVersion (expected ${SUPPORTED_SCHEMA_VERSION})` };\n }\n const registry = pickString(value, \"registry\");\n const generatedAt = pickString(value, \"generatedAt\");\n if (!registry || !generatedAt) return { ok: false, error: \"index missing registry/generatedAt\" };\n if (!Array.isArray(value.collections)) return { ok: false, error: \"index.collections must be an array\" };\n\n const parsed = value.collections.map((entry, idx) => parseEntry(entry, idx, registryName));\n const firstError = parsed.find((entry): entry is string => typeof entry === \"string\");\n if (firstError !== undefined) return { ok: false, error: firstError };\n const collections = parsed.filter((entry): entry is RegistryEntry => typeof entry !== \"string\");\n return { ok: true, index: { schemaVersion: SUPPORTED_SCHEMA_VERSION, registry, generatedAt, collections } };\n}\n","// Isomorphic contract shared by the registry engine, the host routes, and the\n// collection plugin's Discover UI. No I/O — types + a reserved-name constant.\n\nimport type { RegistryEntry } from \"./registryIndex.js\";\n\nexport interface RegistryConfigEntry {\n /** Short label shown on Discover cards + used as the routing key. */\n name: string;\n /** Absolute HTTPS URL of the registry's index.json. */\n indexUrl: string;\n /** Absolute HTTPS base for per-collection files (no trailing slash). */\n rawBaseUrl: string;\n}\n\n/** Reserved name for the official registry. The client always synthesizes one\n * entry under this name; user config that re-uses it is rejected. */\nexport const OFFICIAL_REGISTRY_NAME = \"official\";\n\n/** Per-registry summary in the merged Discover response. */\nexport interface RegistrySummary {\n name: string;\n /** `ok` = fresh, `stale` = served from cache because the upstream failed,\n * `failed` = no cache to fall back to (the entries contribution is 0). */\n status: \"ok\" | \"stale\" | \"failed\";\n generatedAt: string | null;\n error: string | null;\n entryCount: number;\n}\n\n/** `GET …collectionsRegistry.list` — the Discover catalog merged across every\n * configured registry. */\nexport interface RegistryListResponse {\n registries: RegistrySummary[];\n /** Convenience flag: true iff any single registry's contribution was stale. */\n stale: boolean;\n collections: RegistryEntry[];\n}\n\n/** `POST …collectionsRegistry.import` — install result. */\nexport interface RegistryImportResponse {\n localSlug: string;\n updated: boolean;\n seedWritten: number;\n seedSkipped: boolean;\n}\n"],"mappings":";;AACA,SAAgB,SAAS,OAAkD;CACzE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AC+CA,IAAM,2BAA2B;AAEjC,IAAM,cAAc,KAA8B,QAAoC;CACpF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;AAKA,SAAS,eAAe,KAA8B,KAAiC;CACrF,MAAM,QAAQ,IAAI;CAClB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS,IAAI,QAAQ;AACtF;AAEA,IAAM,eAAe,KAA8B,QAAqC;CACtF,MAAM,QAAQ,IAAI;CAClB,OAAO,OAAO,UAAU,YAAY,QAAQ,KAAA;AAC9C;AAEA,IAAM,iBAAiB,UAA8B,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;AAMhJ,IAAM,YAAY;AAClB,IAAM,UAAU;AAKhB,SAAS,cAAc,SAAiB,QAAgB,MAAc,SAAiB,OAA8B;CACnH,IAAI,CAAC,UAAU,KAAK,MAAM,GAAG,OAAO,eAAe,MAAM;CACzD,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,OAAO,eAAe,MAAM;CACrD,IAAI,YAAY,GAAG,OAAO,GAAG,QAAQ,OAAO,eAAe,MAAM,mBAAmB,OAAO,GAAG,KAAK;CACnG,IAAI,YAAY,eAAe,OAAO,GAAG,QAAQ,OAAO,eAAe,MAAM,iCAAiC,OAAO,GAAG,KAAK;CAC7H,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAgC,OAAmE;CAC1H,MAAM,aAAa,eAAe,OAAO,YAAY;CACrD,MAAM,YAAY,eAAe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,kBAAkB,0BAC1B,OAAO;EAAE,IAAI;EAAO,OAAO,uCAAuC,yBAAyB;CAAG;CAEhG,MAAM,WAAW,WAAW,OAAO,UAAU;CAC7C,MAAM,cAAc,WAAW,OAAO,aAAa;CACnD,IAAI,CAAC,YAAY,CAAC,aAAa,OAAO;EAAE,IAAI;EAAO,OAAO;CAAqC;CAC/F,IAAI,CAAC,MAAM,QAAQ,MAAM,WAAW,GAAG,OAAO;EAAE,IAAI;EAAO,OAAO;CAAqC;CAEvG,MAAM,SAAS,MAAM,YAAY,KAAK,OAAO,QAAQ,WAAW,OAAO,KAAK,YAAY,CAAC;CACzF,MAAM,aAAa,OAAO,MAAM,UAA2B,OAAO,UAAU,QAAQ;CACpF,IAAI,eAAe,KAAA,GAAW,OAAO;EAAE,IAAI;EAAO,OAAO;CAAW;CAEpE,OAAO;EAAE,IAAI;EAAM,OAAO;GAAE,eAAe;GAA0B;GAAU;GAAa,aADxE,OAAO,QAAQ,UAAkC,OAAO,UAAU,QACM;EAAY;CAAE;AAC5G;;;;AC3IA,IAAa,yBAAyB"}
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dist = require("../dist-
|
|
3
|
-
const require_errors = require("../errors-
|
|
4
|
-
const require_text = require("../text-
|
|
2
|
+
const require_dist = require("../dist-DK0zTPR1.cjs");
|
|
3
|
+
const require_errors = require("../errors-WLfupg-H.cjs");
|
|
4
|
+
const require_text = require("../text-CPK6ABnv.cjs");
|
|
5
5
|
exports.errorMessage = require_dist.errorMessage;
|
|
6
6
|
exports.toError = require_errors.toError;
|
|
7
7
|
exports.truncate = require_text.truncate;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as errorMessage } from "../dist-
|
|
2
|
-
import { t as toError } from "../errors-
|
|
3
|
-
import { t as truncate } from "../text-
|
|
1
|
+
import { t as errorMessage } from "../dist-wmt60Ec-.js";
|
|
2
|
+
import { t as toError } from "../errors-DfW0e2uv.js";
|
|
3
|
+
import { t as truncate } from "../text-BpGv7qxC.js";
|
|
4
4
|
export { errorMessage, toError, truncate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":[],"sources":["../../src/whisper/client-helpers.ts","../../src/whisper/client.ts"],"sourcesContent":["// Pure, framework-neutral helpers for the browser voice-capture controller.\n// Kept separate from `client.ts` so the audio math and VAD state machine can be\n// unit-tested without a DOM / MediaRecorder / Web Audio environment.\n\nexport function computeRms(buffer: Float32Array): number {\n let sum = 0;\n for (const sample of buffer) sum += sample * sample;\n return Math.sqrt(sum / buffer.length);\n}\n\n/** The recorder mime can carry a codec suffix (`audio/webm;codecs=opus`); the\n * Blob container type is just the part before the `;`. */\nexport function containerTypeFromMime(mimeType: string): string {\n return mimeType.split(\";\")[0] || \"audio/webm\";\n}\n\nexport interface VadState {\n readonly hasSpeech: boolean;\n readonly silenceStart: number | null;\n}\n\nexport interface VadConfig {\n readonly speechRms: number;\n readonly silenceMs: number;\n readonly maxSegmentMs: number;\n}\n\nexport interface VadDecision {\n readonly hasSpeech: boolean;\n readonly silenceStart: number | null;\n readonly cut: boolean;\n}\n\nfunction isSpeech(rms: number, config: VadConfig): boolean {\n return rms > config.speechRms;\n}\n\nfunction nextSilenceStart(state: VadState, rms: number, nowMs: number, config: VadConfig): number | null {\n if (isSpeech(rms, config)) return null;\n if (state.hasSpeech && state.silenceStart === null) return nowMs;\n return state.silenceStart;\n}\n\nfunction silenceExceeded(state: VadState, rms: number, nowMs: number, config: VadConfig): boolean {\n if (isSpeech(rms, config) || !state.hasSpeech || state.silenceStart === null) return false;\n return nowMs - state.silenceStart > config.silenceMs;\n}\n\n/** Advance the pause-detector one tick: fold the current RMS/time into the\n * segment state and decide whether the segment should be force-cut (either a\n * long-enough silence after speech, or the max-segment length reached). */\nexport function evaluateVad(state: VadState, segmentStartMs: number, rms: number, nowMs: number, config: VadConfig): VadDecision {\n const hasSpeech = isSpeech(rms, config) || state.hasSpeech;\n const silenceStart = nextSilenceStart(state, rms, nowMs, config);\n const maxCut = hasSpeech && nowMs - segmentStartMs > config.maxSegmentMs;\n return { hasSpeech, silenceStart, cut: silenceExceeded(state, rms, nowMs, config) || maxCut };\n}\n","// @mulmoclaude/core/whisper/client — framework-neutral browser capture controller.\n// Records one utterance at a time with MediaRecorder, segments on pauses via a\n// Web Audio VAD, and sends each segment through an injected transport. State is\n// pushed via `onState`; the host wraps this into its own reactivity (Vue refs,\n// React state, …). No framework dependency. See plans/done/feat-extract-whisper-package.md.\n\nimport { computeRms, containerTypeFromMime, evaluateVad, type VadConfig } from \"./client-helpers.ts\";\n\n// Map a UI locale to a Whisper language code. UI language is a strong prior for\n// the spoken language; \"auto\" lets Whisper detect it from the audio.\nconst LOCALE_TO_WHISPER: Record<string, string> = {\n en: \"en\",\n ja: \"ja\",\n zh: \"zh\",\n ko: \"ko\",\n es: \"es\",\n \"pt-BR\": \"pt\",\n fr: \"fr\",\n de: \"de\",\n};\n\nexport function localeToWhisperLanguage(locale: string): string {\n return LOCALE_TO_WHISPER[locale] ?? \"auto\";\n}\n\n// VAD tuning. RMS over [-1,1] float samples; a pause is SILENCE_MS of\n// sub-threshold level after speech. MAX_SEGMENT_MS force-cuts a long unbroken\n// utterance so no clip exceeds Whisper's 30s window or the server's size cap.\nconst SPEECH_RMS = 0.015;\nconst SILENCE_MS = 800;\nconst MAX_SEGMENT_MS = 20_000;\nconst MONITOR_INTERVAL_MS = 100;\nconst AVAILABILITY_POLL_MS = 2_000;\nconst VAD_CONFIG: VadConfig = { speechRms: SPEECH_RMS, silenceMs: SILENCE_MS, maxSegmentMs: MAX_SEGMENT_MS };\n\nfunction pickRecorderMime(): string | undefined {\n const candidates = [\"audio/webm;codecs=opus\", \"audio/webm\", \"audio/mp4\"];\n if (typeof MediaRecorder === \"undefined\") return undefined;\n return candidates.find((type) => MediaRecorder.isTypeSupported(type));\n}\n\nfunction blobToDataUrl(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- FileReader.result is `string | ArrayBuffer | null`; readAsDataURL always yields the string branch, and the rule cannot narrow it.\n reader.onload = () => resolve(String(reader.result));\n reader.onerror = () => reject(reader.error ?? new Error(\"FileReader failed\"));\n reader.readAsDataURL(blob);\n });\n}\n\nfunction toMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nexport interface VoiceCaptureTransport {\n /** Transcribe one segment. Throws on failure. */\n transcribe: (dataUrl: string, language: string) => Promise<{ text: string }>;\n /** Current readiness. `downloading` true keeps the controller polling so it\n * flips to ready as soon as a model download finishes. */\n getStatus: () => Promise<{ ready: boolean; downloading: boolean }>;\n}\n\nexport interface VoiceCaptureState {\n available: boolean;\n listening: boolean;\n transcribing: boolean;\n}\n\nexport interface VoiceCaptureCallbacks {\n /** A recognized (non-empty) segment transcript. */\n onTranscript: (text: string) => void;\n /** A segment produced no speech. */\n onEmpty?: (() => void) | undefined;\n /** A recoverable error message (transport failure, permission denied, etc.). */\n onError?: ((message: string) => void) | undefined;\n /** Pushed whenever available/listening/transcribing changes. */\n onState?: ((state: VoiceCaptureState) => void) | undefined;\n}\n\nexport interface VoiceCapture {\n refreshAvailability: () => Promise<void>;\n start: () => Promise<boolean>;\n stop: () => void;\n dispose: () => void;\n}\n\nexport interface CaptureStateController {\n setAvailable: (value: boolean) => void;\n setListening: (value: boolean) => void;\n setPending: (delta: number) => void;\n isListening: () => boolean;\n}\n\n// Owns the three observable flags. Each setter emits only on an actual change so\n// the host's reactivity never churns on a no-op write. `pending` is a private\n// counter; `transcribing` is true exactly while at least one send is in flight.\nexport function createCaptureState(onState?: (state: VoiceCaptureState) => void): CaptureStateController {\n let available = false;\n let listening = false;\n let transcribing = false;\n let pending = 0;\n\n function emit(): void {\n onState?.({ available, listening, transcribing });\n }\n function setAvailable(value: boolean): void {\n if (available !== value) {\n available = value;\n emit();\n }\n }\n function setListening(value: boolean): void {\n if (listening !== value) {\n listening = value;\n emit();\n }\n }\n function setPending(delta: number): void {\n pending += delta;\n const next = pending > 0;\n if (transcribing !== next) {\n transcribing = next;\n emit();\n }\n }\n\n return { setAvailable, setListening, setPending, isListening: () => listening };\n}\n\nexport interface AvailabilityPoller {\n refresh: () => Promise<void>;\n stop: () => void;\n}\n\n// Owns the polling timer. `refresh` mirrors transport readiness into\n// `setAvailable`; while a model is downloading it self-schedules so `available`\n// flips as soon as the download finishes. A `getStatus` throw fails closed\n// (unavailable) and tears the timer down.\nexport function createAvailabilityPoller(transport: VoiceCaptureTransport, setAvailable: (value: boolean) => void): AvailabilityPoller {\n let availabilityPollHandle: number | null = null;\n\n function stop(): void {\n if (availabilityPollHandle !== null) {\n window.clearInterval(availabilityPollHandle);\n availabilityPollHandle = null;\n }\n }\n\n async function refresh(): Promise<void> {\n let status: { ready: boolean; downloading: boolean };\n try {\n status = await transport.getStatus();\n } catch {\n setAvailable(false);\n stop();\n return;\n }\n setAvailable(status.ready);\n if (status.downloading) {\n if (availabilityPollHandle === null) {\n availabilityPollHandle = window.setInterval(() => {\n void refresh();\n }, AVAILABILITY_POLL_MS);\n }\n } else {\n stop();\n }\n }\n\n return { refresh, stop };\n}\n\nexport interface SegmentQueueOptions {\n transport: VoiceCaptureTransport;\n language: () => string;\n callbacks: VoiceCaptureCallbacks;\n setPending: (delta: number) => void;\n // Read-only epoch seam: the queue never mutates the generation, it only reads\n // the parent's current value to drop segments captured under an older session.\n getGeneration: () => number;\n}\n\nexport interface SegmentQueue {\n enqueue: (blob: Blob, gen: number) => void;\n}\n\n// Owns the serialized send chain. Each blob is transcribed in capture order; the\n// generation is checked at entry and again after transcription so a segment\n// belonging to a session the user already left is dropped silently.\nexport function createSegmentQueue(options: SegmentQueueOptions): SegmentQueue {\n const { transport, language, callbacks, setPending, getGeneration } = options;\n let queue: Promise<void> = Promise.resolve();\n\n async function sendSegment(blob: Blob, gen: number): Promise<void> {\n if (gen !== getGeneration()) return;\n try {\n const dataUrl = await blobToDataUrl(blob);\n const result = await transport.transcribe(dataUrl, language());\n if (gen !== getGeneration()) return;\n const text = result.text.trim();\n if (text.length === 0) callbacks.onEmpty?.();\n else callbacks.onTranscript(text);\n } catch (err) {\n // Generation-guard the failure path too: a send rejected after stop()/\n // session change belongs to a session the user already left.\n if (gen === getGeneration()) callbacks.onError?.(toMessage(err));\n }\n }\n\n // Serialize sends so transcripts append in capture order; `pending` keeps\n // `transcribing` true from enqueue until the send resolves.\n function enqueue(blob: Blob, gen: number): void {\n setPending(1);\n queue = queue\n .then(() => sendSegment(blob, gen))\n .catch(() => undefined)\n .finally(() => setPending(-1));\n }\n\n return { enqueue };\n}\n\nexport interface AudioGraph {\n /** True between `attach()` and the next `teardown()`. */\n isAttached: () => boolean;\n /** Read the current PCM window into an internal buffer and return it.\n * Callers must not mutate the returned array. */\n sample: () => Float32Array;\n /** Live mic stream — the outer needs it to hand to MediaRecorder. */\n getStream: () => MediaStream | null;\n /** Attach a fresh mic stream: create AudioContext + AnalyserNode + VAD buffer,\n * connect the source. Called only by `bootstrapCapture` after the caller has\n * passed the stale-generation / permission checks. */\n attach: (stream: MediaStream) => void;\n /** Close the AudioContext, stop the mic tracks, null everything. Safe to\n * call before `attach()` or twice in a row. */\n teardown: () => void;\n}\n\n// Owns the browser-side audio pipeline: mic stream + AudioContext + AnalyserNode\n// + the reusable Float32 buffer VAD reads samples into. Separated from\n// `createVoiceCapture` so its four browser-API fields don't inflate the parent\n// factory's line count and so the setup/teardown ordering is in one place.\nfunction createAudioGraph(): AudioGraph {\n let stream: MediaStream | null = null;\n let audioCtx: AudioContext | null = null;\n let analyser: AnalyserNode | null = null;\n let vadBuffer = new Float32Array(0);\n\n function attach(nextStream: MediaStream): void {\n stream = nextStream;\n audioCtx = new AudioContext();\n analyser = audioCtx.createAnalyser();\n analyser.fftSize = 2048;\n vadBuffer = new Float32Array(analyser.fftSize);\n audioCtx.createMediaStreamSource(nextStream).connect(analyser);\n }\n\n function sample(): Float32Array {\n analyser?.getFloatTimeDomainData(vadBuffer);\n return vadBuffer;\n }\n\n function teardown(): void {\n if (audioCtx) {\n audioCtx.close().catch(() => undefined);\n audioCtx = null;\n }\n analyser = null;\n stream?.getTracks().forEach((track) => track.stop());\n stream = null;\n }\n\n return { isAttached: () => analyser !== null, sample, getStream: () => stream, attach, teardown };\n}\n\ninterface BootstrappedCapture {\n audioGraph: AudioGraph;\n mimeType: string;\n}\n\n// Acquire the mic + probe MediaRecorder support + wire an AudioGraph, returning\n// null (with `callbacks.onError` fired) on any recoverable failure. Deliberately\n// does NOT touch `state` or start the recorder — the caller commits the session\n// only after this resolves successfully, so a stale `generation` detected mid-\n// flight can drop the tracks and bail without partially publishing state.\nasync function bootstrapCapture(callbacks: VoiceCaptureCallbacks, generationAtStart: number, generationNow: () => number): Promise<BootstrappedCapture | null> {\n const mimeType = pickRecorderMime() ?? \"\";\n if (!mimeType || !navigator.mediaDevices?.getUserMedia) {\n callbacks.onError?.(\"unsupported\");\n return null;\n }\n let acquired: MediaStream;\n try {\n acquired = await navigator.mediaDevices.getUserMedia({ audio: true });\n } catch {\n callbacks.onError?.(\"permission-denied\");\n return null;\n }\n if (generationAtStart !== generationNow()) {\n acquired.getTracks().forEach((track) => track.stop());\n return null;\n }\n const audioGraph = createAudioGraph();\n try {\n audioGraph.attach(acquired);\n } catch (err) {\n // teardown() is null-safe and closes any half-created AudioContext AND\n // stops the mic tracks — the pre-refactor code only stopped tracks and\n // leaked the context (codex/CodeRabbit findings on this PR).\n audioGraph.teardown();\n throw err;\n }\n return { audioGraph, mimeType };\n}\n\nexport interface RecorderSession {\n isRecording: () => boolean;\n hadSpeech: () => boolean;\n markSpeech: () => void;\n /** Start a new segment on `stream`, tagged with `gen`. Resets per-segment\n * state (chunks + hadSpeech) synchronously so a subsequent VAD tick sees\n * a fresh window. */\n startNext: (stream: MediaStream, mimeType: string, gen: number) => void;\n /** Force-close the current segment (silence exceeded or MAX_SEGMENT_MS). */\n cut: () => void;\n}\n\ninterface RecorderSessionDeps {\n /** Fires each time a segment finishes. The parent decides whether to\n * restart (via `session.startNext`) and whether to enqueue the blob. */\n onSegmentEnd: (blob: Blob, hadSpeech: boolean, gen: number) => void;\n}\n\n// Owns MediaRecorder + its per-segment scratchpad (chunks, hadSpeech, gen,\n// mimeType). The parent keeps VAD state and the global generation, and calls\n// `startNext` on both initial-start and post-onstop restart paths.\nfunction createRecorderSession(deps: RecorderSessionDeps): RecorderSession {\n let recorder: MediaRecorder | null = null;\n let chunks: Blob[] = [];\n let segmentHasSpeech = false;\n let sessionGen = 0;\n let sessionMimeType = \"\";\n\n function onStop(): void {\n // Snapshot BEFORE the parent's onSegmentEnd callback runs; `startNext`\n // (if the parent chooses to restart) will clear chunks synchronously.\n const hadSpeech = segmentHasSpeech;\n const gen = sessionGen;\n const blob = new Blob(chunks, { type: containerTypeFromMime(sessionMimeType) });\n deps.onSegmentEnd(blob, hadSpeech, gen);\n }\n\n function startNext(stream: MediaStream, mimeType: string, gen: number): void {\n chunks = [];\n segmentHasSpeech = false;\n sessionGen = gen;\n sessionMimeType = mimeType;\n recorder = new MediaRecorder(stream, { mimeType });\n recorder.ondataavailable = (event) => {\n if (event.data.size > 0) chunks.push(event.data);\n };\n recorder.onstop = onStop;\n recorder.start();\n }\n\n return {\n isRecording: () => recorder?.state === \"recording\",\n hadSpeech: () => segmentHasSpeech,\n markSpeech: () => {\n segmentHasSpeech = true;\n },\n startNext,\n cut: () => {\n if (recorder?.state === \"recording\") recorder.stop();\n },\n };\n}\n\n// Zero-values used to seed a fresh `CaptureRuntime` at the top of every\n// `createVoiceCapture` call. Kept module-scope so the seed doesn't inflate the\n// factory's line count.\nconst INITIAL_RUNTIME: Readonly<CaptureRuntime> = {\n audioGraph: null,\n monitorHandle: null,\n mimeType: \"\",\n silenceStart: null,\n segmentStart: 0,\n generation: 0,\n startInFlight: false,\n};\n\n// Mutable capture-time state, kept as one object so module-scope helpers\n// (`stopCapture`, `monitorTick`) can be typed against one shape rather than\n// threading each field through their signatures.\ninterface CaptureRuntime {\n audioGraph: AudioGraph | null;\n monitorHandle: number | null;\n mimeType: string;\n silenceStart: number | null;\n segmentStart: number;\n /** Bumped on stop(); segments captured under an older value are dropped so a\n * late transcript never leaks across sessions. */\n generation: number;\n /** Single-flight guard on start() — true between entry and completion so a\n * second start can't race the first before `listening` flips. */\n startInFlight: boolean;\n}\n\n// Tear down the browser-side resources. `state.setListening(false)` MUST happen\n// BEFORE `session.cut()` so the parent's onSegmentEnd callback sees\n// isListening()===false and does NOT restart. The monitor interval MUST clear\n// BEFORE `audioGraph.teardown()` so a scheduled tick can't run against a\n// half-closed AudioContext.\nfunction stopCapture(runtime: CaptureRuntime, state: CaptureStateController, session: RecorderSession): void {\n runtime.generation += 1;\n state.setListening(false);\n if (runtime.monitorHandle !== null) {\n window.clearInterval(runtime.monitorHandle);\n runtime.monitorHandle = null;\n }\n session.cut();\n runtime.audioGraph?.teardown();\n runtime.audioGraph = null;\n}\n\n// One VAD tick against the audio graph's current window. No-op when the graph\n// is not attached (defensive: `stopCapture` clears `monitorHandle` before\n// `audioGraph.teardown()`, so this is the belt-and-braces for any late fire).\nfunction monitorTick(runtime: CaptureRuntime, session: RecorderSession): void {\n if (!runtime.audioGraph?.isAttached()) return;\n const rms = computeRms(runtime.audioGraph.sample());\n const {\n hasSpeech,\n silenceStart: nextSilence,\n cut,\n } = evaluateVad({ hasSpeech: session.hadSpeech(), silenceStart: runtime.silenceStart }, runtime.segmentStart, rms, Date.now(), VAD_CONFIG);\n if (hasSpeech) session.markSpeech();\n runtime.silenceStart = nextSilence;\n if (cut) session.cut();\n}\n\nexport function createVoiceCapture(transport: VoiceCaptureTransport, language: () => string, callbacks: VoiceCaptureCallbacks): VoiceCapture {\n const state = createCaptureState(callbacks.onState);\n const poller = createAvailabilityPoller(transport, state.setAvailable);\n const runtime: CaptureRuntime = { ...INITIAL_RUNTIME };\n const segments = createSegmentQueue({ transport, language, callbacks, setPending: state.setPending, getGeneration: () => runtime.generation });\n\n const session = createRecorderSession({ onSegmentEnd: handleSegmentEnd });\n\n function handleSegmentEnd(blob: Blob, hadSpeech: boolean, gen: number): void {\n // Restart FIRST so audio-loss between segments is minimal; the snapshot\n // in blob/hadSpeech/gen is already independent of session state.\n if (state.isListening()) startRecorder();\n if (hadSpeech && blob.size > 0 && gen === runtime.generation) segments.enqueue(blob, gen);\n }\n\n function startRecorder(): void {\n const stream = runtime.audioGraph?.getStream();\n if (!stream) return;\n runtime.silenceStart = null;\n runtime.segmentStart = Date.now();\n session.startNext(stream, runtime.mimeType, runtime.generation);\n }\n\n async function start(): Promise<boolean> {\n if (runtime.startInFlight || state.isListening()) return true;\n runtime.startInFlight = true;\n const startGen = runtime.generation;\n try {\n const capture = await bootstrapCapture(callbacks, startGen, () => runtime.generation);\n if (!capture) return false;\n runtime.audioGraph = capture.audioGraph;\n runtime.mimeType = capture.mimeType;\n state.setListening(true);\n startRecorder();\n runtime.monitorHandle = window.setInterval(() => monitorTick(runtime, session), MONITOR_INTERVAL_MS);\n return true;\n } finally {\n runtime.startInFlight = false;\n }\n }\n\n function stop(): void {\n stopCapture(runtime, state, session);\n }\n\n function dispose(): void {\n poller.stop();\n stop();\n }\n\n return { refreshAvailability: poller.refresh, start, stop, dispose };\n}\n"],"mappings":";;AAIA,SAAgB,WAAW,QAA8B;CACvD,IAAI,MAAM;CACV,KAAK,MAAM,UAAU,QAAQ,OAAO,SAAS;CAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,MAAM;AACtC;;;AAIA,SAAgB,sBAAsB,UAA0B;CAC9D,OAAO,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM;AACnC;AAmBA,SAAS,SAAS,KAAa,QAA4B;CACzD,OAAO,MAAM,OAAO;AACtB;AAEA,SAAS,iBAAiB,OAAiB,KAAa,OAAe,QAAkC;CACvG,IAAI,SAAS,KAAK,MAAM,GAAG,OAAO;CAClC,IAAI,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AAK,OAAO,KAAK,QAAQ,QAAQ,YAAY,SAAS,QAAQ,MAAM,GAAG;CAC1F;CAEA,SAAS,gBAAsB;EAC7B,MAAM,SAAS,QAAQ,YAAY,UAAU;EAC7C,IAAI,CAAC,QAAQ;EACb,QAAQ,eAAe;EACvB,QAAQ,eAAe,KAAK,IAAI;EAChC,QAAQ,UAAU,QAAQ,QAAQ,UAAU,QAAQ,UAAU;CAChE;CAEA,eAAe,QAA0B;EACvC,IAAI,QAAQ,iBAAiB,MAAM,YAAY,GAAG,OAAO;EACzD,QAAQ,gBAAgB;EACxB,MAAM,WAAW,QAAQ;EACzB,IAAI;GACF,MAAM,UAAU,MAAM,iBAAiB,WAAW,gBAAgB,QAAQ,UAAU;GACpF,IAAI,CAAC,SAAS,OAAO;GACrB,QAAQ,aAAa,QAAQ;GAC7B,QAAQ,WAAW,QAAQ;GAC3B,MAAM,aAAa,IAAI;GACvB,cAAc;GACd,QAAQ,gBAAgB,OAAO,kBAAkB,YAAY,SAAS,OAAO,GAAG,mBAAmB;GACnG,OAAO;EACT,UAAU;GACR,QAAQ,gBAAgB;EAC1B;CACF;CAEA,SAAS,OAAa;EACpB,YAAY,SAAS,OAAO,OAAO;CACrC;CAEA,SAAS,UAAgB;EACvB,OAAO,KAAK;EACZ,KAAK;CACP;CAEA,OAAO;EAAE,qBAAqB,OAAO;EAAS;EAAO;EAAM;CAAQ;AACrE"}
|
|
1
|
+
{"version":3,"file":"client.cjs","names":[],"sources":["../../src/whisper/client-helpers.ts","../../src/whisper/client.ts"],"sourcesContent":["// Pure, framework-neutral helpers for the browser voice-capture controller.\n// Kept separate from `client.ts` so the audio math and VAD state machine can be\n// unit-tested without a DOM / MediaRecorder / Web Audio environment.\n\nexport function computeRms(buffer: Float32Array): number {\n let sum = 0;\n for (const sample of buffer) sum += sample * sample;\n return Math.sqrt(sum / buffer.length);\n}\n\n/** The recorder mime can carry a codec suffix (`audio/webm;codecs=opus`); the\n * Blob container type is just the part before the `;`. */\nexport function containerTypeFromMime(mimeType: string): string {\n return mimeType.split(\";\")[0] || \"audio/webm\";\n}\n\nexport interface VadState {\n readonly hasSpeech: boolean;\n readonly silenceStart: number | null;\n}\n\nexport interface VadConfig {\n readonly speechRms: number;\n readonly silenceMs: number;\n readonly maxSegmentMs: number;\n}\n\nexport interface VadDecision {\n readonly hasSpeech: boolean;\n readonly silenceStart: number | null;\n readonly cut: boolean;\n}\n\nfunction isSpeech(rms: number, config: VadConfig): boolean {\n return rms > config.speechRms;\n}\n\nfunction nextSilenceStart(state: VadState, rms: number, nowMs: number, config: VadConfig): number | null {\n if (isSpeech(rms, config)) return null;\n if (state.hasSpeech && state.silenceStart === null) return nowMs;\n return state.silenceStart;\n}\n\nfunction silenceExceeded(state: VadState, rms: number, nowMs: number, config: VadConfig): boolean {\n if (isSpeech(rms, config) || !state.hasSpeech || state.silenceStart === null) return false;\n return nowMs - state.silenceStart > config.silenceMs;\n}\n\n/** Advance the pause-detector one tick: fold the current RMS/time into the\n * segment state and decide whether the segment should be force-cut (either a\n * long-enough silence after speech, or the max-segment length reached). */\nexport function evaluateVad(state: VadState, segmentStartMs: number, rms: number, nowMs: number, config: VadConfig): VadDecision {\n const hasSpeech = isSpeech(rms, config) || state.hasSpeech;\n const silenceStart = nextSilenceStart(state, rms, nowMs, config);\n const maxCut = hasSpeech && nowMs - segmentStartMs > config.maxSegmentMs;\n return { hasSpeech, silenceStart, cut: silenceExceeded(state, rms, nowMs, config) || maxCut };\n}\n","// @mulmoclaude/core/whisper/client — framework-neutral browser capture controller.\n// Records one utterance at a time with MediaRecorder, segments on pauses via a\n// Web Audio VAD, and sends each segment through an injected transport. State is\n// pushed via `onState`; the host wraps this into its own reactivity (Vue refs,\n// React state, …). No framework dependency. See plans/done/feat-extract-whisper-package.md.\n\nimport { computeRms, containerTypeFromMime, evaluateVad, type VadConfig } from \"./client-helpers.ts\";\n\n// Map a UI locale to a Whisper language code. UI language is a strong prior for\n// the spoken language; \"auto\" lets Whisper detect it from the audio.\nconst LOCALE_TO_WHISPER: Record<string, string> = {\n en: \"en\",\n ja: \"ja\",\n zh: \"zh\",\n ko: \"ko\",\n es: \"es\",\n \"pt-BR\": \"pt\",\n fr: \"fr\",\n de: \"de\",\n};\n\nexport function localeToWhisperLanguage(locale: string): string {\n return LOCALE_TO_WHISPER[locale] ?? \"auto\";\n}\n\n// VAD tuning. RMS over [-1,1] float samples; a pause is SILENCE_MS of\n// sub-threshold level after speech. MAX_SEGMENT_MS force-cuts a long unbroken\n// utterance so no clip exceeds Whisper's 30s window or the server's size cap.\nconst SPEECH_RMS = 0.015;\nconst SILENCE_MS = 800;\nconst MAX_SEGMENT_MS = 20_000;\nconst MONITOR_INTERVAL_MS = 100;\nconst AVAILABILITY_POLL_MS = 2_000;\nconst VAD_CONFIG: VadConfig = { speechRms: SPEECH_RMS, silenceMs: SILENCE_MS, maxSegmentMs: MAX_SEGMENT_MS };\n\nfunction pickRecorderMime(): string | undefined {\n const candidates = [\"audio/webm;codecs=opus\", \"audio/webm\", \"audio/mp4\"];\n if (typeof MediaRecorder === \"undefined\") return undefined;\n return candidates.find((type) => MediaRecorder.isTypeSupported(type));\n}\n\nfunction blobToDataUrl(blob: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- FileReader.result is `string | ArrayBuffer | null`; readAsDataURL always yields the string branch, and the rule cannot narrow it.\n reader.onload = () => resolve(String(reader.result));\n reader.onerror = () => reject(reader.error ?? new Error(\"FileReader failed\"));\n reader.readAsDataURL(blob);\n });\n}\n\nfunction toMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nexport interface VoiceCaptureTransport {\n /** Transcribe one segment. Throws on failure. */\n transcribe: (dataUrl: string, language: string) => Promise<{ text: string }>;\n /** Current readiness. `downloading` true keeps the controller polling so it\n * flips to ready as soon as a model download finishes. */\n getStatus: () => Promise<{ ready: boolean; downloading: boolean }>;\n}\n\nexport interface VoiceCaptureState {\n available: boolean;\n listening: boolean;\n transcribing: boolean;\n}\n\nexport interface VoiceCaptureCallbacks {\n /** A recognized (non-empty) segment transcript. */\n onTranscript: (text: string) => void;\n /** A segment produced no speech. */\n onEmpty?: (() => void) | undefined;\n /** A recoverable error message (transport failure, permission denied, etc.). */\n onError?: ((message: string) => void) | undefined;\n /** Pushed whenever available/listening/transcribing changes. */\n onState?: ((state: VoiceCaptureState) => void) | undefined;\n}\n\nexport interface VoiceCapture {\n refreshAvailability: () => Promise<void>;\n start: () => Promise<boolean>;\n stop: () => void;\n dispose: () => void;\n}\n\nexport interface CaptureStateController {\n setAvailable: (value: boolean) => void;\n setListening: (value: boolean) => void;\n setPending: (delta: number) => void;\n isListening: () => boolean;\n}\n\n// Owns the three observable flags. Each setter emits only on an actual change so\n// the host's reactivity never churns on a no-op write. `pending` is a private\n// counter; `transcribing` is true exactly while at least one send is in flight.\nexport function createCaptureState(onState?: (state: VoiceCaptureState) => void): CaptureStateController {\n let available = false;\n let listening = false;\n let transcribing = false;\n let pending = 0;\n\n function emit(): void {\n onState?.({ available, listening, transcribing });\n }\n function setAvailable(value: boolean): void {\n if (available !== value) {\n available = value;\n emit();\n }\n }\n function setListening(value: boolean): void {\n if (listening !== value) {\n listening = value;\n emit();\n }\n }\n function setPending(delta: number): void {\n pending += delta;\n const next = pending > 0;\n if (transcribing !== next) {\n transcribing = next;\n emit();\n }\n }\n\n return { setAvailable, setListening, setPending, isListening: () => listening };\n}\n\nexport interface AvailabilityPoller {\n refresh: () => Promise<void>;\n stop: () => void;\n}\n\n// Owns the polling timer. `refresh` mirrors transport readiness into\n// `setAvailable`; while a model is downloading it self-schedules so `available`\n// flips as soon as the download finishes. A `getStatus` throw fails closed\n// (unavailable) and tears the timer down.\nexport function createAvailabilityPoller(transport: VoiceCaptureTransport, setAvailable: (value: boolean) => void): AvailabilityPoller {\n let availabilityPollHandle: number | null = null;\n\n function stop(): void {\n if (availabilityPollHandle !== null) {\n window.clearInterval(availabilityPollHandle);\n availabilityPollHandle = null;\n }\n }\n\n async function refresh(): Promise<void> {\n let status: { ready: boolean; downloading: boolean };\n try {\n status = await transport.getStatus();\n } catch {\n setAvailable(false);\n stop();\n return;\n }\n setAvailable(status.ready);\n if (status.downloading) {\n if (availabilityPollHandle === null) {\n availabilityPollHandle = window.setInterval(() => {\n void refresh();\n }, AVAILABILITY_POLL_MS);\n }\n } else {\n stop();\n }\n }\n\n return { refresh, stop };\n}\n\nexport interface SegmentQueueOptions {\n transport: VoiceCaptureTransport;\n language: () => string;\n callbacks: VoiceCaptureCallbacks;\n setPending: (delta: number) => void;\n // Read-only epoch seam: the queue never mutates the generation, it only reads\n // the parent's current value to drop segments captured under an older session.\n getGeneration: () => number;\n}\n\nexport interface SegmentQueue {\n enqueue: (blob: Blob, gen: number) => void;\n}\n\n// Owns the serialized send chain. Each blob is transcribed in capture order; the\n// generation is checked at entry and again after transcription so a segment\n// belonging to a session the user already left is dropped silently.\nexport function createSegmentQueue(options: SegmentQueueOptions): SegmentQueue {\n const { transport, language, callbacks, setPending, getGeneration } = options;\n let queue: Promise<void> = Promise.resolve();\n\n async function sendSegment(blob: Blob, gen: number): Promise<void> {\n if (gen !== getGeneration()) return;\n try {\n const dataUrl = await blobToDataUrl(blob);\n const result = await transport.transcribe(dataUrl, language());\n if (gen !== getGeneration()) return;\n const text = result.text.trim();\n if (text.length === 0) callbacks.onEmpty?.();\n else callbacks.onTranscript(text);\n } catch (err) {\n // Generation-guard the failure path too: a send rejected after stop()/\n // session change belongs to a session the user already left.\n if (gen === getGeneration()) callbacks.onError?.(toMessage(err));\n }\n }\n\n // Serialize sends so transcripts append in capture order; `pending` keeps\n // `transcribing` true from enqueue until the send resolves.\n function enqueue(blob: Blob, gen: number): void {\n setPending(1);\n queue = queue\n .then(() => sendSegment(blob, gen))\n .catch(() => undefined)\n .finally(() => setPending(-1));\n }\n\n return { enqueue };\n}\n\nexport interface AudioGraph {\n /** True between `attach()` and the next `teardown()`. */\n isAttached: () => boolean;\n /** Read the current PCM window into an internal buffer and return it.\n * Callers must not mutate the returned array. */\n sample: () => Float32Array;\n /** Live mic stream — the outer needs it to hand to MediaRecorder. */\n getStream: () => MediaStream | null;\n /** Attach a fresh mic stream: create AudioContext + AnalyserNode + VAD buffer,\n * connect the source. Called only by `bootstrapCapture` after the caller has\n * passed the stale-generation / permission checks. */\n attach: (stream: MediaStream) => void;\n /** Close the AudioContext, stop the mic tracks, null everything. Safe to\n * call before `attach()` or twice in a row. */\n teardown: () => void;\n}\n\n// Owns the browser-side audio pipeline: mic stream + AudioContext + AnalyserNode\n// + the reusable Float32 buffer VAD reads samples into. Separated from\n// `createVoiceCapture` so its four browser-API fields don't inflate the parent\n// factory's line count and so the setup/teardown ordering is in one place.\nfunction createAudioGraph(): AudioGraph {\n let stream: MediaStream | null = null;\n let audioCtx: AudioContext | null = null;\n let analyser: AnalyserNode | null = null;\n let vadBuffer = new Float32Array(0);\n\n function attach(nextStream: MediaStream): void {\n stream = nextStream;\n audioCtx = new AudioContext();\n analyser = audioCtx.createAnalyser();\n analyser.fftSize = 2048;\n vadBuffer = new Float32Array(analyser.fftSize);\n audioCtx.createMediaStreamSource(nextStream).connect(analyser);\n }\n\n function sample(): Float32Array {\n analyser?.getFloatTimeDomainData(vadBuffer);\n return vadBuffer;\n }\n\n function teardown(): void {\n if (audioCtx) {\n audioCtx.close().catch(() => undefined);\n audioCtx = null;\n }\n analyser = null;\n stream?.getTracks().forEach((track) => track.stop());\n stream = null;\n }\n\n return { isAttached: () => analyser !== null, sample, getStream: () => stream, attach, teardown };\n}\n\ninterface BootstrappedCapture {\n audioGraph: AudioGraph;\n mimeType: string;\n}\n\n// Acquire the mic + probe MediaRecorder support + wire an AudioGraph, returning\n// null (with `callbacks.onError` fired) on any recoverable failure. Deliberately\n// does NOT touch `state` or start the recorder — the caller commits the session\n// only after this resolves successfully, so a stale `generation` detected mid-\n// flight can drop the tracks and bail without partially publishing state.\nasync function bootstrapCapture(callbacks: VoiceCaptureCallbacks, generationAtStart: number, generationNow: () => number): Promise<BootstrappedCapture | null> {\n const mimeType = pickRecorderMime() ?? \"\";\n if (!mimeType || !navigator.mediaDevices?.getUserMedia) {\n callbacks.onError?.(\"unsupported\");\n return null;\n }\n let acquired: MediaStream;\n try {\n acquired = await navigator.mediaDevices.getUserMedia({ audio: true });\n } catch {\n callbacks.onError?.(\"permission-denied\");\n return null;\n }\n if (generationAtStart !== generationNow()) {\n acquired.getTracks().forEach((track) => track.stop());\n return null;\n }\n const audioGraph = createAudioGraph();\n try {\n audioGraph.attach(acquired);\n } catch (err) {\n // teardown() is null-safe and closes any half-created AudioContext AND\n // stops the mic tracks — the pre-refactor code only stopped tracks and\n // leaked the context (codex/CodeRabbit findings on this PR).\n audioGraph.teardown();\n throw err;\n }\n return { audioGraph, mimeType };\n}\n\nexport interface RecorderSession {\n isRecording: () => boolean;\n hadSpeech: () => boolean;\n markSpeech: () => void;\n /** Start a new segment on `stream`, tagged with `gen`. Resets per-segment\n * state (chunks + hadSpeech) synchronously so a subsequent VAD tick sees\n * a fresh window. */\n startNext: (stream: MediaStream, mimeType: string, gen: number) => void;\n /** Force-close the current segment (silence exceeded or MAX_SEGMENT_MS). */\n cut: () => void;\n}\n\ninterface RecorderSessionDeps {\n /** Fires each time a segment finishes. The parent decides whether to\n * restart (via `session.startNext`) and whether to enqueue the blob. */\n onSegmentEnd: (blob: Blob, hadSpeech: boolean, gen: number) => void;\n}\n\n// Owns MediaRecorder + its per-segment scratchpad (chunks, hadSpeech, gen,\n// mimeType). The parent keeps VAD state and the global generation, and calls\n// `startNext` on both initial-start and post-onstop restart paths.\nfunction createRecorderSession(deps: RecorderSessionDeps): RecorderSession {\n let recorder: MediaRecorder | null = null;\n let chunks: Blob[] = [];\n let segmentHasSpeech = false;\n let sessionGen = 0;\n let sessionMimeType = \"\";\n\n function onStop(): void {\n // Snapshot BEFORE the parent's onSegmentEnd callback runs; `startNext`\n // (if the parent chooses to restart) will clear chunks synchronously.\n const hadSpeech = segmentHasSpeech;\n const gen = sessionGen;\n const blob = new Blob(chunks, { type: containerTypeFromMime(sessionMimeType) });\n deps.onSegmentEnd(blob, hadSpeech, gen);\n }\n\n function startNext(stream: MediaStream, mimeType: string, gen: number): void {\n chunks = [];\n segmentHasSpeech = false;\n sessionGen = gen;\n sessionMimeType = mimeType;\n recorder = new MediaRecorder(stream, { mimeType });\n recorder.ondataavailable = (event) => {\n if (event.data.size > 0) chunks.push(event.data);\n };\n recorder.onstop = onStop;\n recorder.start();\n }\n\n return {\n isRecording: () => recorder?.state === \"recording\",\n hadSpeech: () => segmentHasSpeech,\n markSpeech: () => {\n segmentHasSpeech = true;\n },\n startNext,\n cut: () => {\n if (recorder?.state === \"recording\") recorder.stop();\n },\n };\n}\n\n// Zero-values used to seed a fresh `CaptureRuntime` at the top of every\n// `createVoiceCapture` call. Kept module-scope so the seed doesn't inflate the\n// factory's line count.\nconst INITIAL_RUNTIME: Readonly<CaptureRuntime> = {\n audioGraph: null,\n monitorHandle: null,\n mimeType: \"\",\n silenceStart: null,\n segmentStart: 0,\n generation: 0,\n startInFlight: false,\n};\n\n// Mutable capture-time state, kept as one object so module-scope helpers\n// (`stopCapture`, `monitorTick`) can be typed against one shape rather than\n// threading each field through their signatures.\ninterface CaptureRuntime {\n audioGraph: AudioGraph | null;\n monitorHandle: number | null;\n mimeType: string;\n silenceStart: number | null;\n segmentStart: number;\n /** Bumped on stop(); segments captured under an older value are dropped so a\n * late transcript never leaks across sessions. */\n generation: number;\n /** Single-flight guard on start() — true between entry and completion so a\n * second start can't race the first before `listening` flips. */\n startInFlight: boolean;\n}\n\n// Tear down the browser-side resources. `state.setListening(false)` MUST happen\n// BEFORE `session.cut()` so the parent's onSegmentEnd callback sees\n// isListening()===false and does NOT restart. The monitor interval MUST clear\n// BEFORE `audioGraph.teardown()` so a scheduled tick can't run against a\n// half-closed AudioContext.\nfunction stopCapture(runtime: CaptureRuntime, state: CaptureStateController, session: RecorderSession): void {\n runtime.generation += 1;\n state.setListening(false);\n if (runtime.monitorHandle !== null) {\n window.clearInterval(runtime.monitorHandle);\n runtime.monitorHandle = null;\n }\n session.cut();\n runtime.audioGraph?.teardown();\n runtime.audioGraph = null;\n}\n\n// One VAD tick against the audio graph's current window. No-op when the graph\n// is not attached (defensive: `stopCapture` clears `monitorHandle` before\n// `audioGraph.teardown()`, so this is the belt-and-braces for any late fire).\nfunction monitorTick(runtime: CaptureRuntime, session: RecorderSession): void {\n if (!runtime.audioGraph?.isAttached()) return;\n const rms = computeRms(runtime.audioGraph.sample());\n const {\n hasSpeech,\n silenceStart: nextSilence,\n cut,\n } = evaluateVad({ hasSpeech: session.hadSpeech(), silenceStart: runtime.silenceStart }, runtime.segmentStart, rms, Date.now(), VAD_CONFIG);\n if (hasSpeech) session.markSpeech();\n runtime.silenceStart = nextSilence;\n if (cut) session.cut();\n}\n\nexport function createVoiceCapture(transport: VoiceCaptureTransport, language: () => string, callbacks: VoiceCaptureCallbacks): VoiceCapture {\n const state = createCaptureState(callbacks.onState);\n const poller = createAvailabilityPoller(transport, state.setAvailable);\n const runtime: CaptureRuntime = { ...INITIAL_RUNTIME };\n const segments = createSegmentQueue({ transport, language, callbacks, setPending: state.setPending, getGeneration: () => runtime.generation });\n\n const session = createRecorderSession({ onSegmentEnd: handleSegmentEnd });\n\n function handleSegmentEnd(blob: Blob, hadSpeech: boolean, gen: number): void {\n // Restart FIRST so audio-loss between segments is minimal; the snapshot\n // in blob/hadSpeech/gen is already independent of session state.\n if (state.isListening()) startRecorder();\n if (hadSpeech && blob.size > 0 && gen === runtime.generation) segments.enqueue(blob, gen);\n }\n\n function startRecorder(): void {\n const stream = runtime.audioGraph?.getStream();\n if (!stream) return;\n runtime.silenceStart = null;\n runtime.segmentStart = Date.now();\n session.startNext(stream, runtime.mimeType, runtime.generation);\n }\n\n async function start(): Promise<boolean> {\n if (runtime.startInFlight || state.isListening()) return true;\n runtime.startInFlight = true;\n const startGen = runtime.generation;\n try {\n const capture = await bootstrapCapture(callbacks, startGen, () => runtime.generation);\n if (!capture) return false;\n runtime.audioGraph = capture.audioGraph;\n runtime.mimeType = capture.mimeType;\n state.setListening(true);\n startRecorder();\n runtime.monitorHandle = window.setInterval(() => monitorTick(runtime, session), MONITOR_INTERVAL_MS);\n return true;\n } finally {\n runtime.startInFlight = false;\n }\n }\n\n function stop(): void {\n stopCapture(runtime, state, session);\n }\n\n function dispose(): void {\n poller.stop();\n stop();\n }\n\n return { refreshAvailability: poller.refresh, start, stop, dispose };\n}\n"],"mappings":";;AAIA,SAAgB,WAAW,QAA8B;CACvD,IAAI,MAAM;CACV,KAAK,MAAM,UAAU,QAAQ,OAAO,SAAS;CAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,MAAM;AACtC;;;AAIA,SAAgB,sBAAsB,UAA0B;CAC9D,OAAO,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM;AACnC;AAmBA,SAAS,SAAS,KAAa,QAA4B;CACzD,OAAO,MAAM,OAAO;AACtB;AAEA,SAAS,iBAAiB,OAAiB,KAAa,OAAe,QAAkC;CACvG,IAAI,SAAS,KAAK,MAAM,GAAG,OAAO;CAClC,IAAI,MAAM,aAAa,MAAM,iBAAiB,MAAM,OAAO;CAC3D,OAAO,MAAM;AACf;AAEA,SAAS,gBAAgB,OAAiB,KAAa,OAAe,QAA4B;CAChG,IAAI,SAAS,KAAK,MAAM,KAAK,CAAC,MAAM,aAAa,MAAM,iBAAiB,MAAM,OAAO;CACrF,OAAO,QAAQ,MAAM,eAAe,OAAO;AAC7C;;;;AAKA,SAAgB,YAAY,OAAiB,gBAAwB,KAAa,OAAe,QAAgC;CAC/H,MAAM,YAAY,SAAS,KAAK,MAAM,KAAK,MAAM;CACjD,MAAM,eAAe,iBAAiB,OAAO,KAAK,OAAO,MAAM;CAC/D,MAAM,SAAS,aAAa,QAAQ,iBAAiB,OAAO;CAC5D,OAAO;EAAE;EAAW;EAAc,KAAK,gBAAgB,OAAO,KAAK,OAAO,MAAM,KAAK;CAAO;AAC9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