open-multi-agent-kit 0.90.9 → 0.92.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/CHANGELOG.md +39 -4
- package/README.md +14 -1
- package/dist/core/agent-session.d.ts +27 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +196 -32
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/command-safety.d.ts.map +1 -1
- package/dist/core/command-safety.js +0 -58
- package/dist/core/command-safety.js.map +1 -1
- package/dist/core/compaction/transaction.d.ts.map +1 -1
- package/dist/core/compaction/transaction.js +7 -3
- package/dist/core/compaction/transaction.js.map +1 -1
- package/dist/core/context-budget-headroom-candidates.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-candidates.js +21 -11
- package/dist/core/context-budget-headroom-candidates.js.map +1 -1
- package/dist/core/context-budget-system-prompt-items.d.ts +1 -0
- package/dist/core/context-budget-system-prompt-items.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt-items.js +7 -8
- package/dist/core/context-budget-system-prompt-items.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +7 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +12 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/loadouts.d.ts.map +1 -1
- package/dist/core/loadouts.js +27 -48
- package/dist/core/loadouts.js.map +1 -1
- package/dist/core/metrics-sampler.d.ts +20 -0
- package/dist/core/metrics-sampler.d.ts.map +1 -1
- package/dist/core/metrics-sampler.js +52 -0
- package/dist/core/metrics-sampler.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +15 -6
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-resilience.d.ts +51 -0
- package/dist/core/provider-resilience.d.ts.map +1 -0
- package/dist/core/provider-resilience.js +86 -0
- package/dist/core/provider-resilience.js.map +1 -0
- package/dist/core/run-journal.d.ts.map +1 -1
- package/dist/core/run-journal.js +14 -22
- package/dist/core/run-journal.js.map +1 -1
- package/dist/core/session-termination.d.ts +8 -2
- package/dist/core/session-termination.d.ts.map +1 -1
- package/dist/core/session-termination.js +45 -3
- package/dist/core/session-termination.js.map +1 -1
- package/dist/core/settings-manager.d.ts +30 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +35 -30
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +47 -0
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/omp-pure-seams.d.ts +41 -0
- package/dist/core/tools/omp-pure-seams.d.ts.map +1 -0
- package/dist/core/tools/omp-pure-seams.js +142 -0
- package/dist/core/tools/omp-pure-seams.js.map +1 -0
- package/dist/core/tools/omp-seam-runtime.d.ts +100 -0
- package/dist/core/tools/omp-seam-runtime.d.ts.map +1 -0
- package/dist/core/tools/omp-seam-runtime.js +40 -0
- package/dist/core/tools/omp-seam-runtime.js.map +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +34 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +112 -11
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +11 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/theme/omk-aurora-dark.json +80 -0
- package/dist/modes/interactive/theme/omk-aurora-light.json +80 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +5 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +9 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +174 -0
- package/docs/adaptorch-preview.md +2 -2
- package/docs/compaction.md +13 -13
- package/docs/correctness-wall.md +13 -5
- package/docs/custom-provider.md +8 -8
- package/docs/development.md +2 -2
- package/docs/extensions.md +8 -8
- package/docs/json.md +4 -4
- package/docs/provider-resilience.md +87 -0
- package/docs/providers.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/settings.md +30 -0
- package/docs/skills.md +2 -0
- package/docs/themes.md +4 -2
- package/docs/tui.md +4 -4
- package/docs/usage.md +4 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/README.md +35 -10
- package/examples/extensions/subagent/adaptive-agent-runtime.test.ts +234 -0
- package/examples/extensions/subagent/adaptive-agent-runtime.ts +240 -0
- package/examples/extensions/subagent/adaptive-result.ts +112 -0
- package/examples/extensions/subagent/checkpoint-runtime.test.ts +125 -0
- package/examples/extensions/subagent/checkpoint-runtime.ts +198 -0
- package/examples/extensions/subagent/deadline-budget.test.ts +135 -0
- package/examples/extensions/subagent/deadline-budget.ts +242 -0
- package/examples/extensions/subagent/deadline-profile-store.test.ts +72 -0
- package/examples/extensions/subagent/deadline-profile-store.ts +172 -0
- package/examples/extensions/subagent/fixtures/fake-omk-json.mjs +13 -0
- package/examples/extensions/subagent/fixtures/hanging-process-tree.mjs +40 -0
- package/examples/extensions/subagent/index.ts +253 -137
- package/examples/extensions/subagent/managed-process.test.ts +178 -0
- package/examples/extensions/subagent/managed-process.ts +236 -0
- package/examples/extensions/subagent/subagent-extension-smoke.test.ts +112 -0
- package/examples/extensions/subagent/subagent-runtime-types.ts +76 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +28 -19
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-system-prompt-items.js","sourceRoot":"","sources":["../../src/core/context-budget-system-prompt-items.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAiB/F,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAEtC,MAAM,UAAU,6BAA6B,CAC5C,KAAkC,EAClC,cAAsB,EACE;IACxB,MAAM,KAAK,GAA0B,EAAE,CAAC;IACxC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,uBAAuB,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACzG,MAAM,YAAY,GAAG,mBAAmB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAE3E,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,UAAU,GAAG,yBAAyB,CAC3C,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAA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AC;IACD,OAAO,GAAG,IAAI,0CAA0C,OAAO,CAAC,MAAM,GAAG,YAAY,iBAAiB,IAAI,EAAE,CAAC;AAAA,CAC7G;AAED,SAAS,iBAAiB,GAAW;IACpC,OAAO;QACN,+EAA+E;QAC/E,iFAAiF;QACjF,8KAA8K;QAC9K,EAAE;QACF,oBAAoB;KACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACb;AAED,SAAS,gBAAgB,CAAC,KAAY,EAAU;IAC/C,OAAO;QACN,WAAW;QACX,aAAa,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS;QAC3C,oBAAoB,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB;QAChE,iBAAiB,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa;QACvD,YAAY;KACZ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACb;AAED,MAAM,UAAU,SAAS,CAAC,GAAW,EAAU;IAC9C,OAAO,GAAG;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAAA,CAC1B","sourcesContent":["import { type ContextBudgetItemV2, fnv1aHex } from \"./context-budget-governor-v2.ts\";\nimport { scoreContextFileRelevance, scoreSkillRelevance } from \"./context-budget-relevance.ts\";\nimport type { ContextFile } from \"./resource-loader.ts\";\nimport type { Skill } from \"./skills.ts\";\n\ninterface SystemPromptBudgetItemInput {\n\treadonly contextFiles: readonly ContextFile[];\n\treadonly skills: readonly Skill[];\n\treadonly includeSkills: boolean;\n\treadonly options: {\n\t\treadonly activeSkillNames?: readonly string[];\n\t\treadonly includeSkillInventory?: boolean;\n\t\treadonly includeFullContextFiles?: boolean;\n\t\treadonly maxInactiveSkills?: number;\n\t\treadonly queryContext?: string;\n\t};\n}\n\nconst CONTEXT_EXCERPT_CHARS = 1200;\nconst MIN_EXCERPT_CHARS = 400;\nconst MAX_EXCERPT_CHARS = 3000;\nconst MAX_INACTIVE_SKILLS = 15;\nconst CONTEXT_FULL_BUDGET_RATIO = 0.5;\n\nexport function createSystemPromptBudgetItems(\n\tinput: SystemPromptBudgetItemInput,\n\tresourceBudget: number,\n): ContextBudgetItemV2[] {\n\tconst items: ContextBudgetItemV2[] = [];\n\tconst contextFullCount = input.options.includeFullContextFiles !== false ? input.contextFiles.length : 0;\n\tconst excerptChars = computeExcerptChars(resourceBudget, contextFullCount);\n\n\tfor (const contextFile of input.contextFiles) {\n\t\tconst queryScore = scoreContextFileRelevance(\n\t\t\t{ path: contextFile.path, content: contextFile.content, isGlobal: contextFile.isGlobal ?? false },\n\t\t\tinput.options.queryContext,\n\t\t);\n\t\tpushContextItems(items, contextFile, queryScore, excerptChars, input.options.includeFullContextFiles !== false);\n\t}\n\n\tconst visibleSkills = input.skills.filter((skill) => !skill.disableModelInvocation);\n\tif (input.includeSkills && input.options.includeSkillInventory !== false && visibleSkills.length > 0) {\n\t\tpushSkillItems(items, visibleSkills, input.options);\n\t}\n\treturn items;\n}\n\nfunction pushContextItems(\n\titems: ContextBudgetItemV2[],\n\tcontextFile: ContextFile,\n\tqueryScore: number,\n\texcerptChars: number,\n\tincludeFullContextFiles: boolean,\n): void {\n\tconst scope = contextFile.isGlobal ? \"parent\" : \"project\";\n\tconst tagName = contextFile.isGlobal ? \"parent_instructions\" : \"project_instructions\";\n\titems.push({\n\t\tid: `context-pointer:${contextFile.path}`,\n\t\ttier: contextFile.isGlobal ? \"system\" : \"current-files\",\n\t\tpriority: contextFile.isGlobal ? \"hard\" : \"high\",\n\t\trelevance: (contextFile.isGlobal ? 1 : 0.8) * 0.4 + queryScore * 0.6,\n\t\ttext: renderContextPointer(contextFile, scope),\n\t});\n\tif (!includeFullContextFiles) return;\n\titems.push({\n\t\tid: `context-full:${contextFile.path}`,\n\t\ttier: contextFile.isGlobal ? \"system\" : \"current-files\",\n\t\tpriority: contextFile.isGlobal ? \"high\" : \"medium\",\n\t\trelevance: (contextFile.isGlobal ? 0.9 : 0.6) * 0.4 + queryScore * 0.6,\n\t\tredundancyKey: contextFile.path,\n\t\tsourceRef: {\n\t\t\turi: `file://${contextFile.path}`,\n\t\t\tcontentHash: fnv1aHex(contextFile.content),\n\t\t\tretrievable: true,\n\t\t},\n\t\ttext: renderContextFull(contextFile, tagName, excerptChars),\n\t});\n}\n\nfunction pushSkillItems(\n\titems: ContextBudgetItemV2[],\n\tvisibleSkills: readonly Skill[],\n\toptions: SystemPromptBudgetItemInput[\"options\"],\n): void {\n\titems.push({ id: \"skill-header\", tier: \"skills\", priority: \"hard\", text: renderSkillHeader() });\n\tconst activeSkillNames = new Set(options.activeSkillNames ?? []);\n\tconst maxInactive = options.maxInactiveSkills ?? MAX_INACTIVE_SKILLS;\n\tfor (const skill of visibleSkills.filter((skill) => activeSkillNames.has(skill.name))) {\n\t\titems.push(renderSkillBudgetItem(skill, \"hard\", 1));\n\t}\n\n\tconst sortedInactive = visibleSkills\n\t\t.filter((skill) => !activeSkillNames.has(skill.name))\n\t\t.sort((a, b) => scoreSkillRelevance(b, options.queryContext) - scoreSkillRelevance(a, options.queryContext));\n\tfor (const skill of sortedInactive.slice(0, maxInactive)) {\n\t\titems.push(renderSkillBudgetItem(skill, \"low\", Math.max(0.25, scoreSkillRelevance(skill, options.queryContext))));\n\t}\n\titems.push({ id: \"skill-footer\", tier: \"skills\", priority: \"hard\", text: \"</available_skills>\" });\n\n\tconst omittedInactiveCount = sortedInactive.length - Math.min(sortedInactive.length, maxInactive);\n\tif (omittedInactiveCount > 0) {\n\t\titems.push({\n\t\t\tid: \"skill-omitted-summary\",\n\t\t\ttier: \"skills\",\n\t\t\tpriority: \"low\",\n\t\t\trelevance: 0.1,\n\t\t\ttext: `<!-- ${omittedInactiveCount} additional skills available. Use 'read' to load a specific skill file when a task matches. -->`,\n\t\t});\n\t}\n}\n\nfunction renderSkillBudgetItem(skill: Skill, priority: \"hard\" | \"low\", relevance: number): ContextBudgetItemV2 {\n\treturn {\n\t\tid: `skill:${skill.name}`,\n\t\ttier: \"skills\",\n\t\tpriority,\n\t\trelevance,\n\t\tredundancyKey: skill.name,\n\t\ttext: renderSkillEntry(skill),\n\t};\n}\n\nfunction computeExcerptChars(resourceBudget: number, contextFullCount: number): number {\n\tif (contextFullCount <= 0) {\n\t\treturn CONTEXT_EXCERPT_CHARS;\n\t}\n\tconst allocatedTokens = Math.floor(resourceBudget * CONTEXT_FULL_BUDGET_RATIO) / contextFullCount;\n\tconst estimatedChars = Math.floor(allocatedTokens * 4);\n\treturn Math.max(MIN_EXCERPT_CHARS, Math.min(MAX_EXCERPT_CHARS, estimatedChars));\n}\n\nfunction renderContextPointer(contextFile: ContextFile, scope: string): string {\n\tconst marker = contextFile.containsJailbreak ? \" sanitized=true\" : \"\";\n\treturn `<context_file_pointer scope=\"${escapeXml(scope)}\" path=\"${escapeXml(contextFile.path)}\"${marker} chars=\"${contextFile.content.length}\" />`;\n}\n\nfunction renderContextFull(contextFile: ContextFile, tagName: string, excerptChars = CONTEXT_EXCERPT_CHARS): string {\n\tconst content =\n\t\tcontextFile.content.length > excerptChars\n\t\t\t? boundedExcerpt(contextFile.content, excerptChars)\n\t\t\t: contextFile.content;\n\tconst truncated = content.length < contextFile.content.length ? \" truncated=true\" : \"\";\n\treturn `<${tagName} path=\"${escapeXml(contextFile.path)}\"${truncated}>\\n${content}\\n</${tagName}>`;\n}\n\nfunction boundedExcerpt(content: string, excerptChars = CONTEXT_EXCERPT_CHARS): string {\n\tconst headChars = Math.floor(excerptChars * 0.7);\n\tconst tailChars = excerptChars - headChars;\n\tlet head = content.slice(0, headChars);\n\tconst lastSpace = head.search(/\\s+\\S*$/);\n\tif (lastSpace > headChars * 0.5) {\n\t\thead = head.slice(0, lastSpace);\n\t}\n\tlet tail = content.slice(-tailChars);\n\tconst firstSpace = tail.search(/\\S+\\s+/);\n\tif (firstSpace > 0 && firstSpace < tailChars * 0.5) {\n\t\ttail = tail.slice(firstSpace).trimStart();\n\t}\n\treturn `${head}\\n\\n[...context-budget excerpt omitted ${content.length - excerptChars} chars...]\\n\\n${tail}`;\n}\n\nfunction renderSkillHeader(): string {\n\treturn [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t].join(\"\\n\");\n}\n\nfunction renderSkillEntry(skill: Skill): string {\n\treturn [\n\t\t\" <skill>\",\n\t\t` <name>${escapeXml(skill.name)}</name>`,\n\t\t` <description>${escapeXml(skill.description)}</description>`,\n\t\t` <location>${escapeXml(skill.filePath)}</location>`,\n\t\t\" </skill>\",\n\t].join(\"\\n\");\n}\n\nexport function escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context-budget-system-prompt-items.js","sourceRoot":"","sources":["../../src/core/context-budget-system-prompt-items.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAA4B,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAiB/F,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,yBAAyB,G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AM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAAA,CAC9E;AAED,MAAM,UAAU,SAAS,CAAC,GAAW,EAAU;IAC9C,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAAA,CAC1E","sourcesContent":["import { pathToFileURL } from \"node:url\";\nimport { type ContextBudgetItemV2, fnv1aHex } from \"./context-budget-governor-v2.ts\";\nimport { scoreContextFileRelevance, scoreSkillRelevance } from \"./context-budget-relevance.ts\";\nimport type { ContextFile } from \"./resource-loader.ts\";\nimport type { Skill } from \"./skills.ts\";\n\ninterface SystemPromptBudgetItemInput {\n\treadonly contextFiles: readonly ContextFile[];\n\treadonly skills: readonly Skill[];\n\treadonly includeSkills: boolean;\n\treadonly options: {\n\t\treadonly activeSkillNames?: readonly string[];\n\t\treadonly includeSkillInventory?: boolean;\n\t\treadonly includeFullContextFiles?: boolean;\n\t\treadonly maxInactiveSkills?: number;\n\t\treadonly queryContext?: string;\n\t};\n}\n\nconst CONTEXT_EXCERPT_CHARS = 1200;\nconst MIN_EXCERPT_CHARS = 400;\nconst MAX_EXCERPT_CHARS = 3000;\nconst MAX_INACTIVE_SKILLS = 15;\nconst CONTEXT_FULL_BUDGET_RATIO = 0.5;\n\nexport function createSystemPromptBudgetItems(\n\tinput: SystemPromptBudgetItemInput,\n\tresourceBudget: number,\n): ContextBudgetItemV2[] {\n\tconst items: ContextBudgetItemV2[] = [];\n\tconst contextFullCount = input.options.includeFullContextFiles !== false ? input.contextFiles.length : 0;\n\tconst excerptChars = computeExcerptChars(resourceBudget, contextFullCount);\n\n\tfor (const contextFile of input.contextFiles) {\n\t\tconst queryScore = scoreContextFileRelevance(\n\t\t\t{ path: contextFile.path, content: contextFile.content, isGlobal: contextFile.isGlobal ?? false },\n\t\t\tinput.options.queryContext,\n\t\t);\n\t\tpushContextItems(items, contextFile, queryScore, excerptChars, input.options.includeFullContextFiles !== false);\n\t}\n\n\tconst visibleSkills = input.skills.filter((skill) => !skill.disableModelInvocation);\n\tif (input.includeSkills && input.options.includeSkillInventory !== false && visibleSkills.length > 0) {\n\t\tpushSkillItems(items, visibleSkills, input.options);\n\t}\n\treturn items;\n}\n\nfunction pushContextItems(\n\titems: ContextBudgetItemV2[],\n\tcontextFile: ContextFile,\n\tqueryScore: number,\n\texcerptChars: number,\n\tincludeFullContextFiles: boolean,\n): void {\n\tconst scope = contextFile.isGlobal ? \"parent\" : \"project\";\n\tconst tagName = contextFile.isGlobal ? \"parent_instructions\" : \"project_instructions\";\n\titems.push({\n\t\tid: `context-pointer:${contextFile.path}`,\n\t\ttier: contextFile.isGlobal ? \"system\" : \"current-files\",\n\t\tpriority: contextFile.isGlobal ? \"hard\" : \"high\",\n\t\trelevance: (contextFile.isGlobal ? 1 : 0.8) * 0.4 + queryScore * 0.6,\n\t\ttext: renderContextPointer(contextFile, scope),\n\t});\n\tif (!includeFullContextFiles) return;\n\titems.push({\n\t\tid: `context-full:${contextFile.path}`,\n\t\ttier: contextFile.isGlobal ? \"system\" : \"current-files\",\n\t\tpriority: contextFile.isGlobal ? \"high\" : \"medium\",\n\t\trelevance: (contextFile.isGlobal ? 0.9 : 0.6) * 0.4 + queryScore * 0.6,\n\t\tredundancyKey: contextFile.path,\n\t\tsourceRef: {\n\t\t\turi: pathToFileURL(contextFile.path).href,\n\t\t\tcontentHash: fnv1aHex(contextFile.content),\n\t\t\tretrievable: true,\n\t\t},\n\t\ttext: renderContextFull(contextFile, tagName, excerptChars),\n\t});\n}\n\nfunction pushSkillItems(\n\titems: ContextBudgetItemV2[],\n\tvisibleSkills: readonly Skill[],\n\toptions: SystemPromptBudgetItemInput[\"options\"],\n): void {\n\titems.push({ id: \"skill-header\", tier: \"skills\", priority: \"hard\", text: renderSkillHeader() });\n\tconst activeSkillNames = new Set(options.activeSkillNames ?? []);\n\tconst maxInactive = options.maxInactiveSkills ?? MAX_INACTIVE_SKILLS;\n\tfor (const skill of visibleSkills.filter((skill) => activeSkillNames.has(skill.name))) {\n\t\titems.push(renderSkillBudgetItem(skill, \"hard\", 1));\n\t}\n\n\tconst sortedInactive = visibleSkills\n\t\t.filter((skill) => !activeSkillNames.has(skill.name))\n\t\t.sort((a, b) => scoreSkillRelevance(b, options.queryContext) - scoreSkillRelevance(a, options.queryContext));\n\tfor (const skill of sortedInactive.slice(0, maxInactive)) {\n\t\titems.push(renderSkillBudgetItem(skill, \"low\", Math.max(0.25, scoreSkillRelevance(skill, options.queryContext))));\n\t}\n\titems.push({ id: \"skill-footer\", tier: \"skills\", priority: \"hard\", text: \"</available_skills>\" });\n\n\tconst omittedInactiveCount = sortedInactive.length - Math.min(sortedInactive.length, maxInactive);\n\tif (omittedInactiveCount > 0) {\n\t\titems.push({\n\t\t\tid: \"skill-omitted-summary\",\n\t\t\ttier: \"skills\",\n\t\t\tpriority: \"low\",\n\t\t\trelevance: 0.1,\n\t\t\ttext: `<!-- ${omittedInactiveCount} additional skills available. Use 'read' to load a specific skill file when a task matches. -->`,\n\t\t});\n\t}\n}\n\nfunction renderSkillBudgetItem(skill: Skill, priority: \"hard\" | \"low\", relevance: number): ContextBudgetItemV2 {\n\treturn {\n\t\tid: `skill:${skill.name}`,\n\t\ttier: \"skills\",\n\t\tpriority,\n\t\trelevance,\n\t\tredundancyKey: skill.name,\n\t\ttext: renderSkillEntry(skill),\n\t};\n}\n\nfunction computeExcerptChars(resourceBudget: number, contextFullCount: number): number {\n\tif (contextFullCount <= 0) {\n\t\treturn CONTEXT_EXCERPT_CHARS;\n\t}\n\tconst allocatedTokens = Math.floor(resourceBudget * CONTEXT_FULL_BUDGET_RATIO) / contextFullCount;\n\tconst estimatedChars = Math.floor(allocatedTokens * 4);\n\treturn Math.max(MIN_EXCERPT_CHARS, Math.min(MAX_EXCERPT_CHARS, estimatedChars));\n}\n\nfunction renderContextPointer(contextFile: ContextFile, scope: string): string {\n\tconst marker = contextFile.containsJailbreak ? \" sanitized=true\" : \"\";\n\treturn `<context_file_pointer scope=\"${escapeXml(scope)}\" path=\"${escapeXml(contextFile.path)}\"${marker} chars=\"${contextFile.content.length}\" />`;\n}\n\nfunction renderContextFull(contextFile: ContextFile, tagName: string, excerptChars = CONTEXT_EXCERPT_CHARS): string {\n\tconst content =\n\t\tcontextFile.content.length > excerptChars\n\t\t\t? boundedExcerpt(contextFile.content, excerptChars)\n\t\t\t: contextFile.content;\n\tconst truncated = content.length < contextFile.content.length ? \" truncated=true\" : \"\";\n\treturn `<${tagName} path=\"${escapeXml(contextFile.path)}\"${truncated}>\\n${escapeXmlText(content)}\\n</${tagName}>`;\n}\n\nfunction boundedExcerpt(content: string, excerptChars = CONTEXT_EXCERPT_CHARS): string {\n\tconst headChars = Math.floor(excerptChars * 0.7);\n\tconst tailChars = excerptChars - headChars;\n\tlet head = content.slice(0, headChars);\n\tconst lastSpace = head.search(/\\s+\\S*$/);\n\tif (lastSpace > headChars * 0.5) {\n\t\thead = head.slice(0, lastSpace);\n\t}\n\tlet tail = content.slice(-tailChars);\n\tconst firstSpace = tail.search(/\\S+\\s+/);\n\tif (firstSpace > 0 && firstSpace < tailChars * 0.5) {\n\t\ttail = tail.slice(firstSpace).trimStart();\n\t}\n\treturn `${head}\\n\\n[...context-budget excerpt omitted ${content.length - excerptChars} chars...]\\n\\n${tail}`;\n}\n\nfunction renderSkillHeader(): string {\n\treturn [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t].join(\"\\n\");\n}\n\nfunction renderSkillEntry(skill: Skill): string {\n\treturn [\n\t\t\" <skill>\",\n\t\t` <name>${escapeXml(skill.name)}</name>`,\n\t\t` <description>${escapeXml(skill.description)}</description>`,\n\t\t` <location>${escapeXml(skill.filePath)}</location>`,\n\t\t\" </skill>\",\n\t].join(\"\\n\");\n}\n\nexport function escapeXmlText(str: string): string {\n\treturn str.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\n}\n\nexport function escapeXml(str: string): string {\n\treturn escapeXmlText(str).replace(/\"/g, \""\").replace(/'/g, \"'\");\n}\n"]}
|
|
@@ -40,6 +40,12 @@ export declare class FooterDataProvider {
|
|
|
40
40
|
getCpuPercent(): number | null;
|
|
41
41
|
/** Most recent process RSS memory size in bytes, or `null` if not yet sampled. */
|
|
42
42
|
getMemoryRssBytes(): number | null;
|
|
43
|
+
/** System-wide CPU busy percent (0-100), or `null` if not yet sampled. */
|
|
44
|
+
getSystemCpuPercent(): number | null;
|
|
45
|
+
/** System-wide used memory in bytes, or `null` if not yet sampled. */
|
|
46
|
+
getSystemMemoryUsedBytes(): number | null;
|
|
47
|
+
/** System total physical memory in bytes, or `null` if not yet sampled. */
|
|
48
|
+
getSystemMemoryTotalBytes(): number | null;
|
|
43
49
|
getPackageIntakeSummary(): PiPackageIntakeSummary;
|
|
44
50
|
/** Internal: update available provider count */
|
|
45
51
|
setAvailableProviderCount(count: number): void;
|
|
@@ -57,5 +63,5 @@ export declare class FooterDataProvider {
|
|
|
57
63
|
private setupGitWatcher;
|
|
58
64
|
}
|
|
59
65
|
/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */
|
|
60
|
-
export type ReadonlyFooterDataProvider = Pick<FooterDataProvider, "getGitBranch" | "getExtensionStatuses" | "getAvailableProviderCount" | "onBranchChange" | "getCpuPercent" | "getMemoryRssBytes" | "getPackageIntakeSummary">;
|
|
66
|
+
export type ReadonlyFooterDataProvider = Pick<FooterDataProvider, "getGitBranch" | "getExtensionStatuses" | "getAvailableProviderCount" | "onBranchChange" | "getCpuPercent" | "getMemoryRssBytes" | "getSystemCpuPercent" | "getSystemMemoryUsedBytes" | "getSystemMemoryTotalBytes" | "getPackageIntakeSummary">;
|
|
61
67
|
//# sourceMappingURL=footer-data-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-data-provider.d.ts","sourceRoot":"","sources":["../../src/core/footer-data-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AA2F9F;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAEhD,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,QAAQ,CAA0C;IAC1D,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,qBAAqB,CAA4D;IACzF,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,yBAAyB,CAA0B;IAC3D,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,sBAAsB,CAAK;IACnC,OAAO,CAAC,YAAY,CAA8C;IAClE,OAAO,CAAC,oBAAoB,CAA8C;IAC1E,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,cAAc,CAAiB;IAEvC,YAAY,GAAG,EAAE,MAAM,EAMtB;IAED,2EAA2E;IAC3E,YAAY,IAAI,MAAM,GAAG,IAAI,CAK5B;IAED,wDAAwD;IACxD,oBAAoB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAElD;IAED,qEAAqE;IACrE,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG/C;IAED,qCAAqC;IACrC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM9D;IAED,yCAAyC;IACzC,sBAAsB,IAAI,IAAI,CAE7B;IAED,4EAA4E;IAC5E,yBAAyB,IAAI,MAAM,CAElC;IAED,6EAA6E;IAC7E,aAAa,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED,kFAAkF;IAClF,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED,uBAAuB,IAAI,sBAAsB,CAEhD;IAED,gDAAgD;IAChD,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7C;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAexB;IAED,wBAAwB;IACxB,OAAO,IAAI,IAAI,CASd;IAED,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,eAAe;YAYT,qBAAqB;IA0BnC,OAAO,CAAC,oBAAoB;YAcd,qBAAqB;IAgBnC,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,eAAe;CA2EvB;AAED,yGAAyG;AACzG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC5C,kBAAkB,EAChB,cAAc,GACd,sBAAsB,GACtB,2BAA2B,GAC3B,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,yBAAyB,CAC3B,CAAC","sourcesContent":["import { type ExecFileException, execFile, spawnSync } from \"child_process\";\nimport { existsSync, type FSWatcher, readFileSync, type Stats, statSync, unwatchFile, watchFile } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { closeWatcher, FS_WATCH_RETRY_DELAY_MS, watchWithErrorHandler } from \"../utils/fs-watch.ts\";\nimport { MetricsSampler } from \"./metrics-sampler.ts\";\nimport { evaluatePiPackageIntake, type PiPackageIntakeSummary } from \"./pi-package-intake.ts\";\n\ntype GitPaths = {\n\trepoDir: string;\n\tcommonGitDir: string;\n\theadPath: string;\n};\n\n/**\n * Find git metadata paths by walking up from cwd.\n * Handles both regular git repos (.git is a directory) and worktrees (.git is a file).\n */\nfunction findGitPaths(cwd: string): GitPaths | null {\n\tlet dir = cwd;\n\twhile (true) {\n\t\tconst gitPath = join(dir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\ttry {\n\t\t\t\tconst stat = statSync(gitPath);\n\t\t\t\tif (stat.isFile()) {\n\t\t\t\t\tconst content = readFileSync(gitPath, \"utf8\").trim();\n\t\t\t\t\tif (content.startsWith(\"gitdir: \")) {\n\t\t\t\t\t\tconst gitDir = resolve(dir, content.slice(8).trim());\n\t\t\t\t\t\tconst headPath = join(gitDir, \"HEAD\");\n\t\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\t\tconst commonDirPath = join(gitDir, \"commondir\");\n\t\t\t\t\t\tconst commonGitDir = existsSync(commonDirPath)\n\t\t\t\t\t\t\t? resolve(gitDir, readFileSync(commonDirPath, \"utf8\").trim())\n\t\t\t\t\t\t\t: gitDir;\n\t\t\t\t\t\treturn { repoDir: dir, commonGitDir, headPath };\n\t\t\t\t\t}\n\t\t\t\t} else if (stat.isDirectory()) {\n\t\t\t\t\tconst headPath = join(gitPath, \"HEAD\");\n\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\treturn { repoDir: dir, commonGitDir: gitPath, headPath };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\n/** Ask git for the current branch. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitSync(repoDir: string): string | null {\n\tconst result = spawnSync(\"git\", [\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n\t\tcwd: repoDir,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t});\n\tconst branch = result.status === 0 ? result.stdout.trim() : \"\";\n\treturn branch || null;\n}\n\n/** Ask git for the current branch asynchronously. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitAsync(repoDir: string): Promise<string | null> {\n\treturn new Promise((resolvePromise) => {\n\t\texecFile(\n\t\t\t\"git\",\n\t\t\t[\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"],\n\t\t\t{\n\t\t\t\tcwd: repoDir,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t},\n\t\t\t(error: ExecFileException | null, stdout: string) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tresolvePromise(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst branch = stdout.trim();\n\t\t\t\tresolvePromise(branch || null);\n\t\t\t},\n\t\t);\n\t});\n}\n\nfunction isWslEnvironment(): boolean {\n\treturn process.platform === \"linux\" && !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);\n}\n\nfunction isWindowsMountedRepoPath(repoDir: string): boolean {\n\treturn /^\\/mnt\\/[a-z](?:\\/|$)/i.test(repoDir);\n}\n\nfunction shouldPollGitHead(repoDir: string): boolean {\n\treturn isWslEnvironment() && isWindowsMountedRepoPath(repoDir);\n}\n\n/**\n * Provides git branch and extension statuses - data not otherwise accessible to extensions.\n * Token stats, model info available via ctx.sessionManager and ctx.model.\n */\nexport class FooterDataProvider {\n\tprivate cwd: string;\n\tprivate static readonly WATCH_DEBOUNCE_MS = 500;\n\n\tprivate extensionStatuses = new Map<string, string>();\n\tprivate cachedBranch: string | null | undefined = undefined;\n\tprivate gitPaths: GitPaths | null | undefined = undefined;\n\tprivate headWatcher: FSWatcher | null = null;\n\tprivate headWatchFilePath: string | null = null;\n\tprivate headWatchFileListener: ((current: Stats, previous: Stats) => void) | null = null;\n\tprivate reftableWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListPath: string | null = null;\n\tprivate branchChangeCallbacks = new Set<() => void>();\n\tprivate availableProviderCount = 0;\n\tprivate refreshTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate gitWatcherRetryTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate refreshInFlight = false;\n\tprivate refreshPending = false;\n\tprivate disposed = false;\n\tprivate metricsSampler: MetricsSampler;\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.metricsSampler = new MetricsSampler();\n\t\tthis.metricsSampler.start();\n\t}\n\n\t/** Current git branch, null if not in repo, \"detached\" if detached HEAD */\n\tgetGitBranch(): string | null {\n\t\tif (this.cachedBranch === undefined) {\n\t\t\tthis.cachedBranch = this.resolveGitBranchSync();\n\t\t}\n\t\treturn this.cachedBranch;\n\t}\n\n\t/** Extension status texts set via ctx.ui.setStatus() */\n\tgetExtensionStatuses(): ReadonlyMap<string, string> {\n\t\treturn this.extensionStatuses;\n\t}\n\n\t/** Subscribe to git branch changes. Returns unsubscribe function. */\n\tonBranchChange(callback: () => void): () => void {\n\t\tthis.branchChangeCallbacks.add(callback);\n\t\treturn () => this.branchChangeCallbacks.delete(callback);\n\t}\n\n\t/** Internal: set extension status */\n\tsetExtensionStatus(key: string, text: string | undefined): void {\n\t\tif (text === undefined) {\n\t\t\tthis.extensionStatuses.delete(key);\n\t\t} else {\n\t\t\tthis.extensionStatuses.set(key, text);\n\t\t}\n\t}\n\n\t/** Internal: clear extension statuses */\n\tclearExtensionStatuses(): void {\n\t\tthis.extensionStatuses.clear();\n\t}\n\n\t/** Number of unique providers with available models (for footer display) */\n\tgetAvailableProviderCount(): number {\n\t\treturn this.availableProviderCount;\n\t}\n\n\t/** Most recent process CPU percent (0-100), or `null` if not yet sampled. */\n\tgetCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getCpuPercent();\n\t}\n\n\t/** Most recent process RSS memory size in bytes, or `null` if not yet sampled. */\n\tgetMemoryRssBytes(): number | null {\n\t\treturn this.metricsSampler.getMemoryRssBytes();\n\t}\n\n\tgetPackageIntakeSummary(): PiPackageIntakeSummary {\n\t\treturn evaluatePiPackageIntake().summary;\n\t}\n\n\t/** Internal: update available provider count */\n\tsetAvailableProviderCount(count: number): void {\n\t\tthis.availableProviderCount = count;\n\t}\n\n\tsetCwd(cwd: string): void {\n\t\tif (this.cwd === cwd) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.cwd = cwd;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.cachedBranch = undefined;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.notifyBranchChange();\n\t}\n\n\t/** Internal: cleanup */\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.branchChangeCallbacks.clear();\n\t\tthis.metricsSampler.stop();\n\t}\n\n\tprivate notifyBranchChange(): void {\n\t\tfor (const cb of this.branchChangeCallbacks) cb();\n\t}\n\n\tprivate scheduleRefresh(): void {\n\t\tif (this.disposed || this.refreshTimer) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.refreshTimer = setTimeout(() => {\n\t\t\tthis.refreshTimer = null;\n\t\t\tvoid this.refreshGitBranchAsync();\n\t\t}, FooterDataProvider.WATCH_DEBOUNCE_MS);\n\t}\n\n\tprivate async refreshGitBranchAsync(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshInFlight = true;\n\t\ttry {\n\t\t\tconst nextBranch = await this.resolveGitBranchAsync();\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.cachedBranch !== undefined && this.cachedBranch !== nextBranch) {\n\t\t\t\tthis.cachedBranch = nextBranch;\n\t\t\t\tthis.notifyBranchChange();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.cachedBranch = nextBranch;\n\t\t} finally {\n\t\t\tthis.refreshInFlight = false;\n\t\t\tif (this.refreshPending && !this.disposed) {\n\t\t\t\tthis.refreshPending = false;\n\t\t\t\tthis.scheduleRefresh();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate resolveGitBranchSync(): string | null {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\" ? (resolveBranchWithGitSync(this.gitPaths.repoDir) ?? \"detached\") : branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate async resolveGitBranchAsync(): Promise<string | null> {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\"\n\t\t\t\t\t? ((await resolveBranchWithGitAsync(this.gitPaths.repoDir)) ?? \"detached\")\n\t\t\t\t\t: branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate clearGitWatchers(): void {\n\t\tcloseWatcher(this.headWatcher);\n\t\tthis.headWatcher = null;\n\t\tif (this.headWatchFilePath && this.headWatchFileListener) {\n\t\t\tunwatchFile(this.headWatchFilePath, this.headWatchFileListener);\n\t\t\tthis.headWatchFilePath = null;\n\t\t\tthis.headWatchFileListener = null;\n\t\t}\n\t\tcloseWatcher(this.reftableWatcher);\n\t\tthis.reftableWatcher = null;\n\t\tcloseWatcher(this.reftableTablesListWatcher);\n\t\tthis.reftableTablesListWatcher = null;\n\t\tif (this.reftableTablesListPath) {\n\t\t\tunwatchFile(this.reftableTablesListPath);\n\t\t\tthis.reftableTablesListPath = null;\n\t\t}\n\t\tif (this.gitWatcherRetryTimer) {\n\t\t\tclearTimeout(this.gitWatcherRetryTimer);\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t}\n\t}\n\n\tprivate scheduleGitWatcherRetry(): void {\n\t\tif (this.disposed || this.gitWatcherRetryTimer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.gitWatcherRetryTimer = setTimeout(() => {\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t\tthis.setupGitWatcher();\n\t\t}, FS_WATCH_RETRY_DELAY_MS);\n\t}\n\n\tprivate handleGitWatcherError(): void {\n\t\tthis.clearGitWatchers();\n\t\tthis.scheduleGitWatcherRetry();\n\t}\n\n\tprivate setupGitWatcher(): void {\n\t\tthis.clearGitWatchers();\n\t\tif (!this.gitPaths) return;\n\n\t\tconst pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);\n\n\t\t// Watch the directory containing HEAD, not HEAD itself.\n\t\t// Git uses atomic writes (write temp, rename over HEAD), which changes the inode.\n\t\t// fs.watch on a file stops working after the inode changes.\n\t\tthis.headWatcher = watchWithErrorHandler(\n\t\t\tdirname(this.gitPaths.headPath),\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (!filename || filename === \"HEAD\") {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.handleGitWatcherError(),\n\t\t);\n\t\tif (pollGitHead) {\n\t\t\tthis.headWatchFilePath = this.gitPaths.headPath;\n\t\t\tthis.headWatchFileListener = (current, previous) => {\n\t\t\t\tif (\n\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t) {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t};\n\t\t\twatchFile(this.headWatchFilePath, { interval: 1000 }, this.headWatchFileListener);\n\t\t}\n\t\tif (!this.headWatcher && !pollGitHead) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In reftable repos, branch switches update files in the reftable directory\n\t\t// instead of HEAD. Watch it separately so the footer picks up those changes.\n\t\tconst reftableDir = join(this.gitPaths.commonGitDir, \"reftable\");\n\t\tif (existsSync(reftableDir)) {\n\t\t\tthis.reftableWatcher = watchWithErrorHandler(\n\t\t\t\treftableDir,\n\t\t\t\t() => {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t},\n\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t);\n\t\t\tif (!this.reftableWatcher) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst tablesListPath = join(reftableDir, \"tables.list\");\n\t\t\tif (existsSync(tablesListPath)) {\n\t\t\t\tthis.reftableTablesListPath = tablesListPath;\n\t\t\t\tthis.reftableTablesListWatcher = watchWithErrorHandler(\n\t\t\t\t\ttablesListPath,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t},\n\t\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t\t);\n\t\t\t\tif (!this.reftableTablesListWatcher) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\twatchFile(tablesListPath, { interval: 250 }, (current, previous) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */\nexport type ReadonlyFooterDataProvider = Pick<\n\tFooterDataProvider,\n\t| \"getGitBranch\"\n\t| \"getExtensionStatuses\"\n\t| \"getAvailableProviderCount\"\n\t| \"onBranchChange\"\n\t| \"getCpuPercent\"\n\t| \"getMemoryRssBytes\"\n\t| \"getPackageIntakeSummary\"\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"footer-data-provider.d.ts","sourceRoot":"","sources":["../../src/core/footer-data-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AA2F9F;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAEhD,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,QAAQ,CAA0C;IAC1D,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,qBAAqB,CAA4D;IACzF,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,yBAAyB,CAA0B;IAC3D,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,sBAAsB,CAAK;IACnC,OAAO,CAAC,YAAY,CAA8C;IAClE,OAAO,CAAC,oBAAoB,CAA8C;IAC1E,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,cAAc,CAAiB;IAEvC,YAAY,GAAG,EAAE,MAAM,EAMtB;IAED,2EAA2E;IAC3E,YAAY,IAAI,MAAM,GAAG,IAAI,CAK5B;IAED,wDAAwD;IACxD,oBAAoB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAElD;IAED,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import { type ExecFileException, execFile, spawnSync } from \"child_process\";\nimport { existsSync, type FSWatcher, readFileSync, type Stats, statSync, unwatchFile, watchFile } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { closeWatcher, FS_WATCH_RETRY_DELAY_MS, watchWithErrorHandler } from \"../utils/fs-watch.ts\";\nimport { MetricsSampler } from \"./metrics-sampler.ts\";\nimport { evaluatePiPackageIntake, type PiPackageIntakeSummary } from \"./pi-package-intake.ts\";\n\ntype GitPaths = {\n\trepoDir: string;\n\tcommonGitDir: string;\n\theadPath: string;\n};\n\n/**\n * Find git metadata paths by walking up from cwd.\n * Handles both regular git repos (.git is a directory) and worktrees (.git is a file).\n */\nfunction findGitPaths(cwd: string): GitPaths | null {\n\tlet dir = cwd;\n\twhile (true) {\n\t\tconst gitPath = join(dir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\ttry {\n\t\t\t\tconst stat = statSync(gitPath);\n\t\t\t\tif (stat.isFile()) {\n\t\t\t\t\tconst content = readFileSync(gitPath, \"utf8\").trim();\n\t\t\t\t\tif (content.startsWith(\"gitdir: \")) {\n\t\t\t\t\t\tconst gitDir = resolve(dir, content.slice(8).trim());\n\t\t\t\t\t\tconst headPath = join(gitDir, \"HEAD\");\n\t\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\t\tconst commonDirPath = join(gitDir, \"commondir\");\n\t\t\t\t\t\tconst commonGitDir = existsSync(commonDirPath)\n\t\t\t\t\t\t\t? resolve(gitDir, readFileSync(commonDirPath, \"utf8\").trim())\n\t\t\t\t\t\t\t: gitDir;\n\t\t\t\t\t\treturn { repoDir: dir, commonGitDir, headPath };\n\t\t\t\t\t}\n\t\t\t\t} else if (stat.isDirectory()) {\n\t\t\t\t\tconst headPath = join(gitPath, \"HEAD\");\n\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\treturn { repoDir: dir, commonGitDir: gitPath, headPath };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\n/** Ask git for the current branch. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitSync(repoDir: string): string | null {\n\tconst result = spawnSync(\"git\", [\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n\t\tcwd: repoDir,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t});\n\tconst branch = result.status === 0 ? result.stdout.trim() : \"\";\n\treturn branch || null;\n}\n\n/** Ask git for the current branch asynchronously. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitAsync(repoDir: string): Promise<string | null> {\n\treturn new Promise((resolvePromise) => {\n\t\texecFile(\n\t\t\t\"git\",\n\t\t\t[\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"],\n\t\t\t{\n\t\t\t\tcwd: repoDir,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t},\n\t\t\t(error: ExecFileException | null, stdout: string) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tresolvePromise(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst branch = stdout.trim();\n\t\t\t\tresolvePromise(branch || null);\n\t\t\t},\n\t\t);\n\t});\n}\n\nfunction isWslEnvironment(): boolean {\n\treturn process.platform === \"linux\" && !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);\n}\n\nfunction isWindowsMountedRepoPath(repoDir: string): boolean {\n\treturn /^\\/mnt\\/[a-z](?:\\/|$)/i.test(repoDir);\n}\n\nfunction shouldPollGitHead(repoDir: string): boolean {\n\treturn isWslEnvironment() && isWindowsMountedRepoPath(repoDir);\n}\n\n/**\n * Provides git branch and extension statuses - data not otherwise accessible to extensions.\n * Token stats, model info available via ctx.sessionManager and ctx.model.\n */\nexport class FooterDataProvider {\n\tprivate cwd: string;\n\tprivate static readonly WATCH_DEBOUNCE_MS = 500;\n\n\tprivate extensionStatuses = new Map<string, string>();\n\tprivate cachedBranch: string | null | undefined = undefined;\n\tprivate gitPaths: GitPaths | null | undefined = undefined;\n\tprivate headWatcher: FSWatcher | null = null;\n\tprivate headWatchFilePath: string | null = null;\n\tprivate headWatchFileListener: ((current: Stats, previous: Stats) => void) | null = null;\n\tprivate reftableWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListPath: string | null = null;\n\tprivate branchChangeCallbacks = new Set<() => void>();\n\tprivate availableProviderCount = 0;\n\tprivate refreshTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate gitWatcherRetryTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate refreshInFlight = false;\n\tprivate refreshPending = false;\n\tprivate disposed = false;\n\tprivate metricsSampler: MetricsSampler;\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.metricsSampler = new MetricsSampler();\n\t\tthis.metricsSampler.start();\n\t}\n\n\t/** Current git branch, null if not in repo, \"detached\" if detached HEAD */\n\tgetGitBranch(): string | null {\n\t\tif (this.cachedBranch === undefined) {\n\t\t\tthis.cachedBranch = this.resolveGitBranchSync();\n\t\t}\n\t\treturn this.cachedBranch;\n\t}\n\n\t/** Extension status texts set via ctx.ui.setStatus() */\n\tgetExtensionStatuses(): ReadonlyMap<string, string> {\n\t\treturn this.extensionStatuses;\n\t}\n\n\t/** Subscribe to git branch changes. Returns unsubscribe function. */\n\tonBranchChange(callback: () => void): () => void {\n\t\tthis.branchChangeCallbacks.add(callback);\n\t\treturn () => this.branchChangeCallbacks.delete(callback);\n\t}\n\n\t/** Internal: set extension status */\n\tsetExtensionStatus(key: string, text: string | undefined): void {\n\t\tif (text === undefined) {\n\t\t\tthis.extensionStatuses.delete(key);\n\t\t} else {\n\t\t\tthis.extensionStatuses.set(key, text);\n\t\t}\n\t}\n\n\t/** Internal: clear extension statuses */\n\tclearExtensionStatuses(): void {\n\t\tthis.extensionStatuses.clear();\n\t}\n\n\t/** Number of unique providers with available models (for footer display) */\n\tgetAvailableProviderCount(): number {\n\t\treturn this.availableProviderCount;\n\t}\n\n\t/** Most recent process CPU percent (0-100), or `null` if not yet sampled. */\n\tgetCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getCpuPercent();\n\t}\n\n\t/** Most recent process RSS memory size in bytes, or `null` if not yet sampled. */\n\tgetMemoryRssBytes(): number | null {\n\t\treturn this.metricsSampler.getMemoryRssBytes();\n\t}\n\n\t/** System-wide CPU busy percent (0-100), or `null` if not yet sampled. */\n\tgetSystemCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getSystemCpuPercent();\n\t}\n\n\t/** System-wide used memory in bytes, or `null` if not yet sampled. */\n\tgetSystemMemoryUsedBytes(): number | null {\n\t\treturn this.metricsSampler.getSystemMemoryUsedBytes();\n\t}\n\n\t/** System total physical memory in bytes, or `null` if not yet sampled. */\n\tgetSystemMemoryTotalBytes(): number | null {\n\t\treturn this.metricsSampler.getSystemMemoryTotalBytes();\n\t}\n\n\tgetPackageIntakeSummary(): PiPackageIntakeSummary {\n\t\treturn evaluatePiPackageIntake().summary;\n\t}\n\n\t/** Internal: update available provider count */\n\tsetAvailableProviderCount(count: number): void {\n\t\tthis.availableProviderCount = count;\n\t}\n\n\tsetCwd(cwd: string): void {\n\t\tif (this.cwd === cwd) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.cwd = cwd;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.cachedBranch = undefined;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.notifyBranchChange();\n\t}\n\n\t/** Internal: cleanup */\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.branchChangeCallbacks.clear();\n\t\tthis.metricsSampler.stop();\n\t}\n\n\tprivate notifyBranchChange(): void {\n\t\tfor (const cb of this.branchChangeCallbacks) cb();\n\t}\n\n\tprivate scheduleRefresh(): void {\n\t\tif (this.disposed || this.refreshTimer) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.refreshTimer = setTimeout(() => {\n\t\t\tthis.refreshTimer = null;\n\t\t\tvoid this.refreshGitBranchAsync();\n\t\t}, FooterDataProvider.WATCH_DEBOUNCE_MS);\n\t}\n\n\tprivate async refreshGitBranchAsync(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshInFlight = true;\n\t\ttry {\n\t\t\tconst nextBranch = await this.resolveGitBranchAsync();\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.cachedBranch !== undefined && this.cachedBranch !== nextBranch) {\n\t\t\t\tthis.cachedBranch = nextBranch;\n\t\t\t\tthis.notifyBranchChange();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.cachedBranch = nextBranch;\n\t\t} finally {\n\t\t\tthis.refreshInFlight = false;\n\t\t\tif (this.refreshPending && !this.disposed) {\n\t\t\t\tthis.refreshPending = false;\n\t\t\t\tthis.scheduleRefresh();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate resolveGitBranchSync(): string | null {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\" ? (resolveBranchWithGitSync(this.gitPaths.repoDir) ?? \"detached\") : branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate async resolveGitBranchAsync(): Promise<string | null> {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\"\n\t\t\t\t\t? ((await resolveBranchWithGitAsync(this.gitPaths.repoDir)) ?? \"detached\")\n\t\t\t\t\t: branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate clearGitWatchers(): void {\n\t\tcloseWatcher(this.headWatcher);\n\t\tthis.headWatcher = null;\n\t\tif (this.headWatchFilePath && this.headWatchFileListener) {\n\t\t\tunwatchFile(this.headWatchFilePath, this.headWatchFileListener);\n\t\t\tthis.headWatchFilePath = null;\n\t\t\tthis.headWatchFileListener = null;\n\t\t}\n\t\tcloseWatcher(this.reftableWatcher);\n\t\tthis.reftableWatcher = null;\n\t\tcloseWatcher(this.reftableTablesListWatcher);\n\t\tthis.reftableTablesListWatcher = null;\n\t\tif (this.reftableTablesListPath) {\n\t\t\tunwatchFile(this.reftableTablesListPath);\n\t\t\tthis.reftableTablesListPath = null;\n\t\t}\n\t\tif (this.gitWatcherRetryTimer) {\n\t\t\tclearTimeout(this.gitWatcherRetryTimer);\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t}\n\t}\n\n\tprivate scheduleGitWatcherRetry(): void {\n\t\tif (this.disposed || this.gitWatcherRetryTimer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.gitWatcherRetryTimer = setTimeout(() => {\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t\tthis.setupGitWatcher();\n\t\t}, FS_WATCH_RETRY_DELAY_MS);\n\t}\n\n\tprivate handleGitWatcherError(): void {\n\t\tthis.clearGitWatchers();\n\t\tthis.scheduleGitWatcherRetry();\n\t}\n\n\tprivate setupGitWatcher(): void {\n\t\tthis.clearGitWatchers();\n\t\tif (!this.gitPaths) return;\n\n\t\tconst pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);\n\n\t\t// Watch the directory containing HEAD, not HEAD itself.\n\t\t// Git uses atomic writes (write temp, rename over HEAD), which changes the inode.\n\t\t// fs.watch on a file stops working after the inode changes.\n\t\tthis.headWatcher = watchWithErrorHandler(\n\t\t\tdirname(this.gitPaths.headPath),\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (!filename || filename === \"HEAD\") {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.handleGitWatcherError(),\n\t\t);\n\t\tif (pollGitHead) {\n\t\t\tthis.headWatchFilePath = this.gitPaths.headPath;\n\t\t\tthis.headWatchFileListener = (current, previous) => {\n\t\t\t\tif (\n\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t) {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t};\n\t\t\twatchFile(this.headWatchFilePath, { interval: 1000 }, this.headWatchFileListener);\n\t\t}\n\t\tif (!this.headWatcher && !pollGitHead) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In reftable repos, branch switches update files in the reftable directory\n\t\t// instead of HEAD. Watch it separately so the footer picks up those changes.\n\t\tconst reftableDir = join(this.gitPaths.commonGitDir, \"reftable\");\n\t\tif (existsSync(reftableDir)) {\n\t\t\tthis.reftableWatcher = watchWithErrorHandler(\n\t\t\t\treftableDir,\n\t\t\t\t() => {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t},\n\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t);\n\t\t\tif (!this.reftableWatcher) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst tablesListPath = join(reftableDir, \"tables.list\");\n\t\t\tif (existsSync(tablesListPath)) {\n\t\t\t\tthis.reftableTablesListPath = tablesListPath;\n\t\t\t\tthis.reftableTablesListWatcher = watchWithErrorHandler(\n\t\t\t\t\ttablesListPath,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t},\n\t\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t\t);\n\t\t\t\tif (!this.reftableTablesListWatcher) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\twatchFile(tablesListPath, { interval: 250 }, (current, previous) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */\nexport type ReadonlyFooterDataProvider = Pick<\n\tFooterDataProvider,\n\t| \"getGitBranch\"\n\t| \"getExtensionStatuses\"\n\t| \"getAvailableProviderCount\"\n\t| \"onBranchChange\"\n\t| \"getCpuPercent\"\n\t| \"getMemoryRssBytes\"\n\t| \"getSystemCpuPercent\"\n\t| \"getSystemMemoryUsedBytes\"\n\t| \"getSystemMemoryTotalBytes\"\n\t| \"getPackageIntakeSummary\"\n>;\n"]}
|
|
@@ -153,6 +153,18 @@ export class FooterDataProvider {
|
|
|
153
153
|
getMemoryRssBytes() {
|
|
154
154
|
return this.metricsSampler.getMemoryRssBytes();
|
|
155
155
|
}
|
|
156
|
+
/** System-wide CPU busy percent (0-100), or `null` if not yet sampled. */
|
|
157
|
+
getSystemCpuPercent() {
|
|
158
|
+
return this.metricsSampler.getSystemCpuPercent();
|
|
159
|
+
}
|
|
160
|
+
/** System-wide used memory in bytes, or `null` if not yet sampled. */
|
|
161
|
+
getSystemMemoryUsedBytes() {
|
|
162
|
+
return this.metricsSampler.getSystemMemoryUsedBytes();
|
|
163
|
+
}
|
|
164
|
+
/** System total physical memory in bytes, or `null` if not yet sampled. */
|
|
165
|
+
getSystemMemoryTotalBytes() {
|
|
166
|
+
return this.metricsSampler.getSystemMemoryTotalBytes();
|
|
167
|
+
}
|
|
156
168
|
getPackageIntakeSummary() {
|
|
157
169
|
return evaluatePiPackageIntake().summary;
|
|
158
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-data-provider.js","sourceRoot":"","sources":["../../src/core/footer-data-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAkB,YAAY,EAAc,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC5G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,wBAAwB,CAAC;AAQ9F;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAW,EAAmB;IACnD,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,OAAO,IAAI,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC;gBACJ,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC/B,IAAI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;CACD","sourcesContent":["import { type ExecFileException, execFile, spawnSync } from \"child_process\";\nimport { existsSync, type FSWatcher, readFileSync, type Stats, statSync, unwatchFile, watchFile } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { closeWatcher, FS_WATCH_RETRY_DELAY_MS, watchWithErrorHandler } from \"../utils/fs-watch.ts\";\nimport { MetricsSampler } from \"./metrics-sampler.ts\";\nimport { evaluatePiPackageIntake, type PiPackageIntakeSummary } from \"./pi-package-intake.ts\";\n\ntype GitPaths = {\n\trepoDir: string;\n\tcommonGitDir: string;\n\theadPath: string;\n};\n\n/**\n * Find git metadata paths by walking up from cwd.\n * Handles both regular git repos (.git is a directory) and worktrees (.git is a file).\n */\nfunction findGitPaths(cwd: string): GitPaths | null {\n\tlet dir = cwd;\n\twhile (true) {\n\t\tconst gitPath = join(dir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\ttry {\n\t\t\t\tconst stat = statSync(gitPath);\n\t\t\t\tif (stat.isFile()) {\n\t\t\t\t\tconst content = readFileSync(gitPath, \"utf8\").trim();\n\t\t\t\t\tif (content.startsWith(\"gitdir: \")) {\n\t\t\t\t\t\tconst gitDir = resolve(dir, content.slice(8).trim());\n\t\t\t\t\t\tconst headPath = join(gitDir, \"HEAD\");\n\t\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\t\tconst commonDirPath = join(gitDir, \"commondir\");\n\t\t\t\t\t\tconst commonGitDir = existsSync(commonDirPath)\n\t\t\t\t\t\t\t? resolve(gitDir, readFileSync(commonDirPath, \"utf8\").trim())\n\t\t\t\t\t\t\t: gitDir;\n\t\t\t\t\t\treturn { repoDir: dir, commonGitDir, headPath };\n\t\t\t\t\t}\n\t\t\t\t} else if (stat.isDirectory()) {\n\t\t\t\t\tconst headPath = join(gitPath, \"HEAD\");\n\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\treturn { repoDir: dir, commonGitDir: gitPath, headPath };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\n/** Ask git for the current branch. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitSync(repoDir: string): string | null {\n\tconst result = spawnSync(\"git\", [\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n\t\tcwd: repoDir,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t});\n\tconst branch = result.status === 0 ? result.stdout.trim() : \"\";\n\treturn branch || null;\n}\n\n/** Ask git for the current branch asynchronously. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitAsync(repoDir: string): Promise<string | null> {\n\treturn new Promise((resolvePromise) => {\n\t\texecFile(\n\t\t\t\"git\",\n\t\t\t[\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"],\n\t\t\t{\n\t\t\t\tcwd: repoDir,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t},\n\t\t\t(error: ExecFileException | null, stdout: string) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tresolvePromise(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst branch = stdout.trim();\n\t\t\t\tresolvePromise(branch || null);\n\t\t\t},\n\t\t);\n\t});\n}\n\nfunction isWslEnvironment(): boolean {\n\treturn process.platform === \"linux\" && !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);\n}\n\nfunction isWindowsMountedRepoPath(repoDir: string): boolean {\n\treturn /^\\/mnt\\/[a-z](?:\\/|$)/i.test(repoDir);\n}\n\nfunction shouldPollGitHead(repoDir: string): boolean {\n\treturn isWslEnvironment() && isWindowsMountedRepoPath(repoDir);\n}\n\n/**\n * Provides git branch and extension statuses - data not otherwise accessible to extensions.\n * Token stats, model info available via ctx.sessionManager and ctx.model.\n */\nexport class FooterDataProvider {\n\tprivate cwd: string;\n\tprivate static readonly WATCH_DEBOUNCE_MS = 500;\n\n\tprivate extensionStatuses = new Map<string, string>();\n\tprivate cachedBranch: string | null | undefined = undefined;\n\tprivate gitPaths: GitPaths | null | undefined = undefined;\n\tprivate headWatcher: FSWatcher | null = null;\n\tprivate headWatchFilePath: string | null = null;\n\tprivate headWatchFileListener: ((current: Stats, previous: Stats) => void) | null = null;\n\tprivate reftableWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListPath: string | null = null;\n\tprivate branchChangeCallbacks = new Set<() => void>();\n\tprivate availableProviderCount = 0;\n\tprivate refreshTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate gitWatcherRetryTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate refreshInFlight = false;\n\tprivate refreshPending = false;\n\tprivate disposed = false;\n\tprivate metricsSampler: MetricsSampler;\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.metricsSampler = new MetricsSampler();\n\t\tthis.metricsSampler.start();\n\t}\n\n\t/** Current git branch, null if not in repo, \"detached\" if detached HEAD */\n\tgetGitBranch(): string | null {\n\t\tif (this.cachedBranch === undefined) {\n\t\t\tthis.cachedBranch = this.resolveGitBranchSync();\n\t\t}\n\t\treturn this.cachedBranch;\n\t}\n\n\t/** Extension status texts set via ctx.ui.setStatus() */\n\tgetExtensionStatuses(): ReadonlyMap<string, string> {\n\t\treturn this.extensionStatuses;\n\t}\n\n\t/** Subscribe to git branch changes. Returns unsubscribe function. */\n\tonBranchChange(callback: () => void): () => void {\n\t\tthis.branchChangeCallbacks.add(callback);\n\t\treturn () => this.branchChangeCallbacks.delete(callback);\n\t}\n\n\t/** Internal: set extension status */\n\tsetExtensionStatus(key: string, text: string | undefined): void {\n\t\tif (text === undefined) {\n\t\t\tthis.extensionStatuses.delete(key);\n\t\t} else {\n\t\t\tthis.extensionStatuses.set(key, text);\n\t\t}\n\t}\n\n\t/** Internal: clear extension statuses */\n\tclearExtensionStatuses(): void {\n\t\tthis.extensionStatuses.clear();\n\t}\n\n\t/** Number of unique providers with available models (for footer display) */\n\tgetAvailableProviderCount(): number {\n\t\treturn this.availableProviderCount;\n\t}\n\n\t/** Most recent process CPU percent (0-100), or `null` if not yet sampled. */\n\tgetCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getCpuPercent();\n\t}\n\n\t/** Most recent process RSS memory size in bytes, or `null` if not yet sampled. */\n\tgetMemoryRssBytes(): number | null {\n\t\treturn this.metricsSampler.getMemoryRssBytes();\n\t}\n\n\tgetPackageIntakeSummary(): PiPackageIntakeSummary {\n\t\treturn evaluatePiPackageIntake().summary;\n\t}\n\n\t/** Internal: update available provider count */\n\tsetAvailableProviderCount(count: number): void {\n\t\tthis.availableProviderCount = count;\n\t}\n\n\tsetCwd(cwd: string): void {\n\t\tif (this.cwd === cwd) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.cwd = cwd;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.cachedBranch = undefined;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.notifyBranchChange();\n\t}\n\n\t/** Internal: cleanup */\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.branchChangeCallbacks.clear();\n\t\tthis.metricsSampler.stop();\n\t}\n\n\tprivate notifyBranchChange(): void {\n\t\tfor (const cb of this.branchChangeCallbacks) cb();\n\t}\n\n\tprivate scheduleRefresh(): void {\n\t\tif (this.disposed || this.refreshTimer) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.refreshTimer = setTimeout(() => {\n\t\t\tthis.refreshTimer = null;\n\t\t\tvoid this.refreshGitBranchAsync();\n\t\t}, FooterDataProvider.WATCH_DEBOUNCE_MS);\n\t}\n\n\tprivate async refreshGitBranchAsync(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshInFlight = true;\n\t\ttry {\n\t\t\tconst nextBranch = await this.resolveGitBranchAsync();\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.cachedBranch !== undefined && this.cachedBranch !== nextBranch) {\n\t\t\t\tthis.cachedBranch = nextBranch;\n\t\t\t\tthis.notifyBranchChange();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.cachedBranch = nextBranch;\n\t\t} finally {\n\t\t\tthis.refreshInFlight = false;\n\t\t\tif (this.refreshPending && !this.disposed) {\n\t\t\t\tthis.refreshPending = false;\n\t\t\t\tthis.scheduleRefresh();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate resolveGitBranchSync(): string | null {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\" ? (resolveBranchWithGitSync(this.gitPaths.repoDir) ?? \"detached\") : branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate async resolveGitBranchAsync(): Promise<string | null> {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\"\n\t\t\t\t\t? ((await resolveBranchWithGitAsync(this.gitPaths.repoDir)) ?? \"detached\")\n\t\t\t\t\t: branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate clearGitWatchers(): void {\n\t\tcloseWatcher(this.headWatcher);\n\t\tthis.headWatcher = null;\n\t\tif (this.headWatchFilePath && this.headWatchFileListener) {\n\t\t\tunwatchFile(this.headWatchFilePath, this.headWatchFileListener);\n\t\t\tthis.headWatchFilePath = null;\n\t\t\tthis.headWatchFileListener = null;\n\t\t}\n\t\tcloseWatcher(this.reftableWatcher);\n\t\tthis.reftableWatcher = null;\n\t\tcloseWatcher(this.reftableTablesListWatcher);\n\t\tthis.reftableTablesListWatcher = null;\n\t\tif (this.reftableTablesListPath) {\n\t\t\tunwatchFile(this.reftableTablesListPath);\n\t\t\tthis.reftableTablesListPath = null;\n\t\t}\n\t\tif (this.gitWatcherRetryTimer) {\n\t\t\tclearTimeout(this.gitWatcherRetryTimer);\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t}\n\t}\n\n\tprivate scheduleGitWatcherRetry(): void {\n\t\tif (this.disposed || this.gitWatcherRetryTimer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.gitWatcherRetryTimer = setTimeout(() => {\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t\tthis.setupGitWatcher();\n\t\t}, FS_WATCH_RETRY_DELAY_MS);\n\t}\n\n\tprivate handleGitWatcherError(): void {\n\t\tthis.clearGitWatchers();\n\t\tthis.scheduleGitWatcherRetry();\n\t}\n\n\tprivate setupGitWatcher(): void {\n\t\tthis.clearGitWatchers();\n\t\tif (!this.gitPaths) return;\n\n\t\tconst pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);\n\n\t\t// Watch the directory containing HEAD, not HEAD itself.\n\t\t// Git uses atomic writes (write temp, rename over HEAD), which changes the inode.\n\t\t// fs.watch on a file stops working after the inode changes.\n\t\tthis.headWatcher = watchWithErrorHandler(\n\t\t\tdirname(this.gitPaths.headPath),\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (!filename || filename === \"HEAD\") {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.handleGitWatcherError(),\n\t\t);\n\t\tif (pollGitHead) {\n\t\t\tthis.headWatchFilePath = this.gitPaths.headPath;\n\t\t\tthis.headWatchFileListener = (current, previous) => {\n\t\t\t\tif (\n\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t) {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t};\n\t\t\twatchFile(this.headWatchFilePath, { interval: 1000 }, this.headWatchFileListener);\n\t\t}\n\t\tif (!this.headWatcher && !pollGitHead) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In reftable repos, branch switches update files in the reftable directory\n\t\t// instead of HEAD. Watch it separately so the footer picks up those changes.\n\t\tconst reftableDir = join(this.gitPaths.commonGitDir, \"reftable\");\n\t\tif (existsSync(reftableDir)) {\n\t\t\tthis.reftableWatcher = watchWithErrorHandler(\n\t\t\t\treftableDir,\n\t\t\t\t() => {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t},\n\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t);\n\t\t\tif (!this.reftableWatcher) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst tablesListPath = join(reftableDir, \"tables.list\");\n\t\t\tif (existsSync(tablesListPath)) {\n\t\t\t\tthis.reftableTablesListPath = tablesListPath;\n\t\t\t\tthis.reftableTablesListWatcher = watchWithErrorHandler(\n\t\t\t\t\ttablesListPath,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t},\n\t\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t\t);\n\t\t\t\tif (!this.reftableTablesListWatcher) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\twatchFile(tablesListPath, { interval: 250 }, (current, previous) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */\nexport type ReadonlyFooterDataProvider = Pick<\n\tFooterDataProvider,\n\t| \"getGitBranch\"\n\t| \"getExtensionStatuses\"\n\t| \"getAvailableProviderCount\"\n\t| \"onBranchChange\"\n\t| \"getCpuPercent\"\n\t| \"getMemoryRssBytes\"\n\t| \"getPackageIntakeSummary\"\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"footer-data-provider.js","sourceRoot":"","sources":["../../src/core/footer-data-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAkB,YAAY,EAAc,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC5G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,wBAAwB,CAAC;AAQ9F;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAW,EAAmB;IACnD,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,OAAO,IAAI,EA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,EACD,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAClC,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC;oBACrC,OAAO;gBACR,CAAC;gBACD,SAAS,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC;oBACnE,IACC,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO;wBACpC,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO;wBACpC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAC7B,CAAC;wBACF,IAAI,CAAC,eAAe,EAAE,CAAC;oBACxB,CAAC;gBAAA,CACD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;IAAA,CACD;CACD","sourcesContent":["import { type ExecFileException, execFile, spawnSync } from \"child_process\";\nimport { existsSync, type FSWatcher, readFileSync, type Stats, statSync, unwatchFile, watchFile } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { closeWatcher, FS_WATCH_RETRY_DELAY_MS, watchWithErrorHandler } from \"../utils/fs-watch.ts\";\nimport { MetricsSampler } from \"./metrics-sampler.ts\";\nimport { evaluatePiPackageIntake, type PiPackageIntakeSummary } from \"./pi-package-intake.ts\";\n\ntype GitPaths = {\n\trepoDir: string;\n\tcommonGitDir: string;\n\theadPath: string;\n};\n\n/**\n * Find git metadata paths by walking up from cwd.\n * Handles both regular git repos (.git is a directory) and worktrees (.git is a file).\n */\nfunction findGitPaths(cwd: string): GitPaths | null {\n\tlet dir = cwd;\n\twhile (true) {\n\t\tconst gitPath = join(dir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\ttry {\n\t\t\t\tconst stat = statSync(gitPath);\n\t\t\t\tif (stat.isFile()) {\n\t\t\t\t\tconst content = readFileSync(gitPath, \"utf8\").trim();\n\t\t\t\t\tif (content.startsWith(\"gitdir: \")) {\n\t\t\t\t\t\tconst gitDir = resolve(dir, content.slice(8).trim());\n\t\t\t\t\t\tconst headPath = join(gitDir, \"HEAD\");\n\t\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\t\tconst commonDirPath = join(gitDir, \"commondir\");\n\t\t\t\t\t\tconst commonGitDir = existsSync(commonDirPath)\n\t\t\t\t\t\t\t? resolve(gitDir, readFileSync(commonDirPath, \"utf8\").trim())\n\t\t\t\t\t\t\t: gitDir;\n\t\t\t\t\t\treturn { repoDir: dir, commonGitDir, headPath };\n\t\t\t\t\t}\n\t\t\t\t} else if (stat.isDirectory()) {\n\t\t\t\t\tconst headPath = join(gitPath, \"HEAD\");\n\t\t\t\t\tif (!existsSync(headPath)) return null;\n\t\t\t\t\treturn { repoDir: dir, commonGitDir: gitPath, headPath };\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\n/** Ask git for the current branch. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitSync(repoDir: string): string | null {\n\tconst result = spawnSync(\"git\", [\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n\t\tcwd: repoDir,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t});\n\tconst branch = result.status === 0 ? result.stdout.trim() : \"\";\n\treturn branch || null;\n}\n\n/** Ask git for the current branch asynchronously. Returns null on detached HEAD or if git is unavailable. */\nfunction resolveBranchWithGitAsync(repoDir: string): Promise<string | null> {\n\treturn new Promise((resolvePromise) => {\n\t\texecFile(\n\t\t\t\"git\",\n\t\t\t[\"--no-optional-locks\", \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"],\n\t\t\t{\n\t\t\t\tcwd: repoDir,\n\t\t\t\tencoding: \"utf8\",\n\t\t\t},\n\t\t\t(error: ExecFileException | null, stdout: string) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tresolvePromise(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst branch = stdout.trim();\n\t\t\t\tresolvePromise(branch || null);\n\t\t\t},\n\t\t);\n\t});\n}\n\nfunction isWslEnvironment(): boolean {\n\treturn process.platform === \"linux\" && !!(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);\n}\n\nfunction isWindowsMountedRepoPath(repoDir: string): boolean {\n\treturn /^\\/mnt\\/[a-z](?:\\/|$)/i.test(repoDir);\n}\n\nfunction shouldPollGitHead(repoDir: string): boolean {\n\treturn isWslEnvironment() && isWindowsMountedRepoPath(repoDir);\n}\n\n/**\n * Provides git branch and extension statuses - data not otherwise accessible to extensions.\n * Token stats, model info available via ctx.sessionManager and ctx.model.\n */\nexport class FooterDataProvider {\n\tprivate cwd: string;\n\tprivate static readonly WATCH_DEBOUNCE_MS = 500;\n\n\tprivate extensionStatuses = new Map<string, string>();\n\tprivate cachedBranch: string | null | undefined = undefined;\n\tprivate gitPaths: GitPaths | null | undefined = undefined;\n\tprivate headWatcher: FSWatcher | null = null;\n\tprivate headWatchFilePath: string | null = null;\n\tprivate headWatchFileListener: ((current: Stats, previous: Stats) => void) | null = null;\n\tprivate reftableWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListWatcher: FSWatcher | null = null;\n\tprivate reftableTablesListPath: string | null = null;\n\tprivate branchChangeCallbacks = new Set<() => void>();\n\tprivate availableProviderCount = 0;\n\tprivate refreshTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate gitWatcherRetryTimer: ReturnType<typeof setTimeout> | null = null;\n\tprivate refreshInFlight = false;\n\tprivate refreshPending = false;\n\tprivate disposed = false;\n\tprivate metricsSampler: MetricsSampler;\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.metricsSampler = new MetricsSampler();\n\t\tthis.metricsSampler.start();\n\t}\n\n\t/** Current git branch, null if not in repo, \"detached\" if detached HEAD */\n\tgetGitBranch(): string | null {\n\t\tif (this.cachedBranch === undefined) {\n\t\t\tthis.cachedBranch = this.resolveGitBranchSync();\n\t\t}\n\t\treturn this.cachedBranch;\n\t}\n\n\t/** Extension status texts set via ctx.ui.setStatus() */\n\tgetExtensionStatuses(): ReadonlyMap<string, string> {\n\t\treturn this.extensionStatuses;\n\t}\n\n\t/** Subscribe to git branch changes. Returns unsubscribe function. */\n\tonBranchChange(callback: () => void): () => void {\n\t\tthis.branchChangeCallbacks.add(callback);\n\t\treturn () => this.branchChangeCallbacks.delete(callback);\n\t}\n\n\t/** Internal: set extension status */\n\tsetExtensionStatus(key: string, text: string | undefined): void {\n\t\tif (text === undefined) {\n\t\t\tthis.extensionStatuses.delete(key);\n\t\t} else {\n\t\t\tthis.extensionStatuses.set(key, text);\n\t\t}\n\t}\n\n\t/** Internal: clear extension statuses */\n\tclearExtensionStatuses(): void {\n\t\tthis.extensionStatuses.clear();\n\t}\n\n\t/** Number of unique providers with available models (for footer display) */\n\tgetAvailableProviderCount(): number {\n\t\treturn this.availableProviderCount;\n\t}\n\n\t/** Most recent process CPU percent (0-100), or `null` if not yet sampled. */\n\tgetCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getCpuPercent();\n\t}\n\n\t/** Most recent process RSS memory size in bytes, or `null` if not yet sampled. */\n\tgetMemoryRssBytes(): number | null {\n\t\treturn this.metricsSampler.getMemoryRssBytes();\n\t}\n\n\t/** System-wide CPU busy percent (0-100), or `null` if not yet sampled. */\n\tgetSystemCpuPercent(): number | null {\n\t\treturn this.metricsSampler.getSystemCpuPercent();\n\t}\n\n\t/** System-wide used memory in bytes, or `null` if not yet sampled. */\n\tgetSystemMemoryUsedBytes(): number | null {\n\t\treturn this.metricsSampler.getSystemMemoryUsedBytes();\n\t}\n\n\t/** System total physical memory in bytes, or `null` if not yet sampled. */\n\tgetSystemMemoryTotalBytes(): number | null {\n\t\treturn this.metricsSampler.getSystemMemoryTotalBytes();\n\t}\n\n\tgetPackageIntakeSummary(): PiPackageIntakeSummary {\n\t\treturn evaluatePiPackageIntake().summary;\n\t}\n\n\t/** Internal: update available provider count */\n\tsetAvailableProviderCount(count: number): void {\n\t\tthis.availableProviderCount = count;\n\t}\n\n\tsetCwd(cwd: string): void {\n\t\tif (this.cwd === cwd) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.cwd = cwd;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.cachedBranch = undefined;\n\t\tthis.gitPaths = findGitPaths(cwd);\n\t\tthis.setupGitWatcher();\n\t\tthis.notifyBranchChange();\n\t}\n\n\t/** Internal: cleanup */\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tif (this.refreshTimer) {\n\t\t\tclearTimeout(this.refreshTimer);\n\t\t\tthis.refreshTimer = null;\n\t\t}\n\t\tthis.clearGitWatchers();\n\t\tthis.branchChangeCallbacks.clear();\n\t\tthis.metricsSampler.stop();\n\t}\n\n\tprivate notifyBranchChange(): void {\n\t\tfor (const cb of this.branchChangeCallbacks) cb();\n\t}\n\n\tprivate scheduleRefresh(): void {\n\t\tif (this.disposed || this.refreshTimer) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\t\tthis.refreshTimer = setTimeout(() => {\n\t\t\tthis.refreshTimer = null;\n\t\t\tvoid this.refreshGitBranchAsync();\n\t\t}, FooterDataProvider.WATCH_DEBOUNCE_MS);\n\t}\n\n\tprivate async refreshGitBranchAsync(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tif (this.refreshInFlight) {\n\t\t\tthis.refreshPending = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.refreshInFlight = true;\n\t\ttry {\n\t\t\tconst nextBranch = await this.resolveGitBranchAsync();\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.cachedBranch !== undefined && this.cachedBranch !== nextBranch) {\n\t\t\t\tthis.cachedBranch = nextBranch;\n\t\t\t\tthis.notifyBranchChange();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.cachedBranch = nextBranch;\n\t\t} finally {\n\t\t\tthis.refreshInFlight = false;\n\t\t\tif (this.refreshPending && !this.disposed) {\n\t\t\t\tthis.refreshPending = false;\n\t\t\t\tthis.scheduleRefresh();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate resolveGitBranchSync(): string | null {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\" ? (resolveBranchWithGitSync(this.gitPaths.repoDir) ?? \"detached\") : branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate async resolveGitBranchAsync(): Promise<string | null> {\n\t\ttry {\n\t\t\tif (!this.gitPaths) return null;\n\t\t\tconst content = readFileSync(this.gitPaths.headPath, \"utf8\").trim();\n\t\t\tif (content.startsWith(\"ref: refs/heads/\")) {\n\t\t\t\tconst branch = content.slice(16);\n\t\t\t\treturn branch === \".invalid\"\n\t\t\t\t\t? ((await resolveBranchWithGitAsync(this.gitPaths.repoDir)) ?? \"detached\")\n\t\t\t\t\t: branch;\n\t\t\t}\n\t\t\treturn \"detached\";\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate clearGitWatchers(): void {\n\t\tcloseWatcher(this.headWatcher);\n\t\tthis.headWatcher = null;\n\t\tif (this.headWatchFilePath && this.headWatchFileListener) {\n\t\t\tunwatchFile(this.headWatchFilePath, this.headWatchFileListener);\n\t\t\tthis.headWatchFilePath = null;\n\t\t\tthis.headWatchFileListener = null;\n\t\t}\n\t\tcloseWatcher(this.reftableWatcher);\n\t\tthis.reftableWatcher = null;\n\t\tcloseWatcher(this.reftableTablesListWatcher);\n\t\tthis.reftableTablesListWatcher = null;\n\t\tif (this.reftableTablesListPath) {\n\t\t\tunwatchFile(this.reftableTablesListPath);\n\t\t\tthis.reftableTablesListPath = null;\n\t\t}\n\t\tif (this.gitWatcherRetryTimer) {\n\t\t\tclearTimeout(this.gitWatcherRetryTimer);\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t}\n\t}\n\n\tprivate scheduleGitWatcherRetry(): void {\n\t\tif (this.disposed || this.gitWatcherRetryTimer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.gitWatcherRetryTimer = setTimeout(() => {\n\t\t\tthis.gitWatcherRetryTimer = null;\n\t\t\tthis.setupGitWatcher();\n\t\t}, FS_WATCH_RETRY_DELAY_MS);\n\t}\n\n\tprivate handleGitWatcherError(): void {\n\t\tthis.clearGitWatchers();\n\t\tthis.scheduleGitWatcherRetry();\n\t}\n\n\tprivate setupGitWatcher(): void {\n\t\tthis.clearGitWatchers();\n\t\tif (!this.gitPaths) return;\n\n\t\tconst pollGitHead = shouldPollGitHead(this.gitPaths.repoDir);\n\n\t\t// Watch the directory containing HEAD, not HEAD itself.\n\t\t// Git uses atomic writes (write temp, rename over HEAD), which changes the inode.\n\t\t// fs.watch on a file stops working after the inode changes.\n\t\tthis.headWatcher = watchWithErrorHandler(\n\t\t\tdirname(this.gitPaths.headPath),\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (!filename || filename === \"HEAD\") {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => this.handleGitWatcherError(),\n\t\t);\n\t\tif (pollGitHead) {\n\t\t\tthis.headWatchFilePath = this.gitPaths.headPath;\n\t\t\tthis.headWatchFileListener = (current, previous) => {\n\t\t\t\tif (\n\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t) {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t}\n\t\t\t};\n\t\t\twatchFile(this.headWatchFilePath, { interval: 1000 }, this.headWatchFileListener);\n\t\t}\n\t\tif (!this.headWatcher && !pollGitHead) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In reftable repos, branch switches update files in the reftable directory\n\t\t// instead of HEAD. Watch it separately so the footer picks up those changes.\n\t\tconst reftableDir = join(this.gitPaths.commonGitDir, \"reftable\");\n\t\tif (existsSync(reftableDir)) {\n\t\t\tthis.reftableWatcher = watchWithErrorHandler(\n\t\t\t\treftableDir,\n\t\t\t\t() => {\n\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t},\n\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t);\n\t\t\tif (!this.reftableWatcher) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst tablesListPath = join(reftableDir, \"tables.list\");\n\t\t\tif (existsSync(tablesListPath)) {\n\t\t\t\tthis.reftableTablesListPath = tablesListPath;\n\t\t\t\tthis.reftableTablesListWatcher = watchWithErrorHandler(\n\t\t\t\t\ttablesListPath,\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t},\n\t\t\t\t\t() => this.handleGitWatcherError(),\n\t\t\t\t);\n\t\t\t\tif (!this.reftableTablesListWatcher) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\twatchFile(tablesListPath, { interval: 250 }, (current, previous) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrent.mtimeMs !== previous.mtimeMs ||\n\t\t\t\t\t\tcurrent.ctimeMs !== previous.ctimeMs ||\n\t\t\t\t\t\tcurrent.size !== previous.size\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.scheduleRefresh();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Read-only view for extensions - excludes setExtensionStatus, setAvailableProviderCount and dispose */\nexport type ReadonlyFooterDataProvider = Pick<\n\tFooterDataProvider,\n\t| \"getGitBranch\"\n\t| \"getExtensionStatuses\"\n\t| \"getAvailableProviderCount\"\n\t| \"onBranchChange\"\n\t| \"getCpuPercent\"\n\t| \"getMemoryRssBytes\"\n\t| \"getSystemCpuPercent\"\n\t| \"getSystemMemoryUsedBytes\"\n\t| \"getSystemMemoryTotalBytes\"\n\t| \"getPackageIntakeSummary\"\n>;\n"]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { applyContextCacheInvalidation, type ContextCacheInvalidationEvent, type
|
|
|
10
10
|
export { computeReservedTokenBudget, estimateToolResultReserve, ReservedTokenBudgetError, } from "./context-budget-reserved-tokens.ts";
|
|
11
11
|
export { createEventBus, type EventBus, type EventBusController } from "./event-bus.ts";
|
|
12
12
|
export { type AgentEndEvent, type AgentStartEvent, type AgentToolResult, type AgentToolUpdateCallback, type BeforeAgentStartEvent, type BeforeAgentStartEventResult, type BuildSystemPromptOptions, type ContextEvent, defineTool, discoverAndLoadExtensions, type ExecOptions, type ExecResult, type Extension, type ExtensionAPI, type ExtensionCommandContext, type ExtensionContext, type ExtensionError, type ExtensionEvent, type ExtensionFactory, type ExtensionFlag, type ExtensionHandler, ExtensionRunner, type ExtensionShortcut, type ExtensionUIContext, type LoadExtensionsResult, type MessageRenderer, type RegisteredCommand, type SessionBeforeCompactEvent, type SessionBeforeForkEvent, type SessionBeforeSwitchEvent, type SessionBeforeTreeEvent, type SessionCompactEvent, type SessionShutdownEvent, type SessionStartEvent, type SessionTreeEvent, type ToolCallEvent, type ToolCallEventResult, type ToolDefinition, type ToolRenderResultOptions, type ToolResultEvent, type TurnEndEvent, type TurnStartEvent, type WorkingIndicatorOptions, } from "./extensions/index.ts";
|
|
13
|
+
export { DEFAULT_PROVIDER_RESILIENCE, DEFAULT_SAFETY_FAILOVER_CANDIDATES, type FailoverCandidate, isContentSafetyStopMessage, isOrphanToolCallIdError, isStickySafetyModel, isTransientProviderErrorMessage, type ProviderResilienceSettings, pickFailoverCandidate, resolveFailoverCandidates, resolveProviderResilience, STICKY_SAFETY_MODEL_RE, stickySafetyBlockMessage, } from "./provider-resilience.ts";
|
|
13
14
|
export { appendRunJournalRecordDurably, type OpenRunJournalStoreOptions, type RunJournalQuarantineReport, RunJournalStore, RunJournalStoreCorruptionError, writeQuarantineBytesDurably, } from "./run-journal-store.ts";
|
|
14
15
|
export { classifySessionTermination, formatSessionTermination, type SessionTermination, type SessionTerminationCause, SessionTerminationError, type SessionTerminationKind, } from "./session-termination.ts";
|
|
15
16
|
export { createSyntheticSourceInfo } from "./source-info.ts";
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,uBAAuB,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,mBAAmB,EACnB,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,yBAAyB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,qCAAqC,EAC1C,KAAK,iCAAiC,EACtC,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB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AmB,EACxB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,uBAAuB,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,6BAA6B,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,eAAe,EACf,8BAA8B,EAC9B,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,KAAK,sBAAsB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Core modules shared between all run modes.\n */\n\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype PromptOptions,\n\ttype SessionStats,\n\ttype SessionTranscriptRepair,\n} from \"./agent-session.ts\";\nexport {\n\tAgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\tcreateAgentSessionRuntime,\n} from \"./agent-session-runtime.ts\";\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\nexport { type BashExecutorOptions, type BashResult, executeBashWithOperations } from \"./bash-executor.ts\";\nexport {\n\ttype CompactionBarrierResult,\n\ttype CompactionCommitDecision,\n\ttype CompactionEnvelope,\n\ttype CompactionHysteresisConfig,\n\ttype CompactionHysteresisState,\n\ttype CompactionResult,\n\ttype CompactionTransaction,\n\tcreateCompactionEnvelope,\n\tcreateCompactionHysteresisConfig,\n\tcreateCompactionHysteresisState,\n\tcreateCompactionSourceIdentity,\n\tcreateCompactionTransaction,\n\tcreateSessionRevisionToken,\n\tdecideCompactionCommit,\n\tevaluateCompactionBarrier,\n\tstepCompactionHysteresis,\n\tvalidateCompactionEnvelope,\n} from \"./compaction/index.ts\";\nexport {\n\tapplyContextCacheInvalidation,\n\ttype ContextCacheInvalidationEvent,\n\ttype ContextCacheInvalidationSnapshot,\n\tcreateContextCacheInvalidationSnapshot,\n\tplanPromptContextBudgetV2,\n} from \"./context-budget-governor-v2.ts\";\nexport {\n\tcomputeReservedTokenBudget,\n\testimateToolResultReserve,\n\tReservedTokenBudgetError,\n} from \"./context-budget-reserved-tokens.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./event-bus.ts\";\n// Extensions system\nexport {\n\ttype AgentEndEvent,\n\ttype AgentStartEvent,\n\ttype AgentToolResult,\n\ttype AgentToolUpdateCallback,\n\ttype BeforeAgentStartEvent,\n\ttype BeforeAgentStartEventResult,\n\ttype BuildSystemPromptOptions,\n\ttype ContextEvent,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\ttype ExecOptions,\n\ttype ExecResult,\n\ttype Extension,\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n\ttype ExtensionError,\n\ttype ExtensionEvent,\n\ttype ExtensionFactory,\n\ttype ExtensionFlag,\n\ttype ExtensionHandler,\n\tExtensionRunner,\n\ttype ExtensionShortcut,\n\ttype ExtensionUIContext,\n\ttype LoadExtensionsResult,\n\ttype MessageRenderer,\n\ttype RegisteredCommand,\n\ttype SessionBeforeCompactEvent,\n\ttype SessionBeforeForkEvent,\n\ttype SessionBeforeSwitchEvent,\n\ttype SessionBeforeTreeEvent,\n\ttype SessionCompactEvent,\n\ttype SessionShutdownEvent,\n\ttype SessionStartEvent,\n\ttype SessionTreeEvent,\n\ttype ToolCallEvent,\n\ttype ToolCallEventResult,\n\ttype ToolDefinition,\n\ttype ToolRenderResultOptions,\n\ttype ToolResultEvent,\n\ttype TurnEndEvent,\n\ttype TurnStartEvent,\n\ttype WorkingIndicatorOptions,\n} from \"./extensions/index.ts\";\nexport {\n\tappendRunJournalRecordDurably,\n\ttype OpenRunJournalStoreOptions,\n\ttype RunJournalQuarantineReport,\n\tRunJournalStore,\n\tRunJournalStoreCorruptionError,\n\twriteQuarantineBytesDurably,\n} from \"./run-journal-store.ts\";\nexport {\n\tclassifySessionTermination,\n\tformatSessionTermination,\n\ttype SessionTermination,\n\ttype SessionTerminationCause,\n\tSessionTerminationError,\n\ttype SessionTerminationKind,\n} from \"./session-termination.ts\";\nexport { createSyntheticSourceInfo } from \"./source-info.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,uBAAuB,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,mBAAmB,EACnB,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,yBAAyB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,qCAAqC,EAC1C,KAAK,iCAAiC,EACtC,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,wBAAwB,EACxB,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pB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,uBAAuB,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,EAClC,KAAK,iBAAiB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,EACnB,+BAA+B,EAC/B,KAAK,0BAA0B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,6BAA6B,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,eAAe,EACf,8BAA8B,EAC9B,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,KAAK,sBAAsB,GAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Core modules shared between all run modes.\n */\n\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype PromptOptions,\n\ttype SessionStats,\n\ttype SessionTranscriptRepair,\n} from \"./agent-session.ts\";\nexport {\n\tAgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\tcreateAgentSessionRuntime,\n} from \"./agent-session-runtime.ts\";\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\nexport { type BashExecutorOptions, type BashResult, executeBashWithOperations } from \"./bash-executor.ts\";\nexport {\n\ttype CompactionBarrierResult,\n\ttype CompactionCommitDecision,\n\ttype CompactionEnvelope,\n\ttype CompactionHysteresisConfig,\n\ttype CompactionHysteresisState,\n\ttype CompactionResult,\n\ttype CompactionTransaction,\n\tcreateCompactionEnvelope,\n\tcreateCompactionHysteresisConfig,\n\tcreateCompactionHysteresisState,\n\tcreateCompactionSourceIdentity,\n\tcreateCompactionTransaction,\n\tcreateSessionRevisionToken,\n\tdecideCompactionCommit,\n\tevaluateCompactionBarrier,\n\tstepCompactionHysteresis,\n\tvalidateCompactionEnvelope,\n} from \"./compaction/index.ts\";\nexport {\n\tapplyContextCacheInvalidation,\n\ttype ContextCacheInvalidationEvent,\n\ttype ContextCacheInvalidationSnapshot,\n\tcreateContextCacheInvalidationSnapshot,\n\tplanPromptContextBudgetV2,\n} from \"./context-budget-governor-v2.ts\";\nexport {\n\tcomputeReservedTokenBudget,\n\testimateToolResultReserve,\n\tReservedTokenBudgetError,\n} from \"./context-budget-reserved-tokens.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./event-bus.ts\";\n// Extensions system\nexport {\n\ttype AgentEndEvent,\n\ttype AgentStartEvent,\n\ttype AgentToolResult,\n\ttype AgentToolUpdateCallback,\n\ttype BeforeAgentStartEvent,\n\ttype BeforeAgentStartEventResult,\n\ttype BuildSystemPromptOptions,\n\ttype ContextEvent,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\ttype ExecOptions,\n\ttype ExecResult,\n\ttype Extension,\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n\ttype ExtensionError,\n\ttype ExtensionEvent,\n\ttype ExtensionFactory,\n\ttype ExtensionFlag,\n\ttype ExtensionHandler,\n\tExtensionRunner,\n\ttype ExtensionShortcut,\n\ttype ExtensionUIContext,\n\ttype LoadExtensionsResult,\n\ttype MessageRenderer,\n\ttype RegisteredCommand,\n\ttype SessionBeforeCompactEvent,\n\ttype SessionBeforeForkEvent,\n\ttype SessionBeforeSwitchEvent,\n\ttype SessionBeforeTreeEvent,\n\ttype SessionCompactEvent,\n\ttype SessionShutdownEvent,\n\ttype SessionStartEvent,\n\ttype SessionTreeEvent,\n\ttype ToolCallEvent,\n\ttype ToolCallEventResult,\n\ttype ToolDefinition,\n\ttype ToolRenderResultOptions,\n\ttype ToolResultEvent,\n\ttype TurnEndEvent,\n\ttype TurnStartEvent,\n\ttype WorkingIndicatorOptions,\n} from \"./extensions/index.ts\";\nexport {\n\tDEFAULT_PROVIDER_RESILIENCE,\n\tDEFAULT_SAFETY_FAILOVER_CANDIDATES,\n\ttype FailoverCandidate,\n\tisContentSafetyStopMessage,\n\tisOrphanToolCallIdError,\n\tisStickySafetyModel,\n\tisTransientProviderErrorMessage,\n\ttype ProviderResilienceSettings,\n\tpickFailoverCandidate,\n\tresolveFailoverCandidates,\n\tresolveProviderResilience,\n\tSTICKY_SAFETY_MODEL_RE,\n\tstickySafetyBlockMessage,\n} from \"./provider-resilience.ts\";\nexport {\n\tappendRunJournalRecordDurably,\n\ttype OpenRunJournalStoreOptions,\n\ttype RunJournalQuarantineReport,\n\tRunJournalStore,\n\tRunJournalStoreCorruptionError,\n\twriteQuarantineBytesDurably,\n} from \"./run-journal-store.ts\";\nexport {\n\tclassifySessionTermination,\n\tformatSessionTermination,\n\ttype SessionTermination,\n\ttype SessionTerminationCause,\n\tSessionTerminationError,\n\ttype SessionTerminationKind,\n} from \"./session-termination.ts\";\nexport { createSyntheticSourceInfo } from \"./source-info.ts\";\n"]}
|
package/dist/core/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { computeReservedTokenBudget, estimateToolResultReserve, ReservedTokenBud
|
|
|
11
11
|
export { createEventBus } from "./event-bus.js";
|
|
12
12
|
// Extensions system
|
|
13
13
|
export { defineTool, discoverAndLoadExtensions, ExtensionRunner, } from "./extensions/index.js";
|
|
14
|
+
export { DEFAULT_PROVIDER_RESILIENCE, DEFAULT_SAFETY_FAILOVER_CANDIDATES, isContentSafetyStopMessage, isOrphanToolCallIdError, isStickySafetyModel, isTransientProviderErrorMessage, pickFailoverCandidate, resolveFailoverCandidates, resolveProviderResilience, STICKY_SAFETY_MODEL_RE, stickySafetyBlockMessage, } from "./provider-resilience.js";
|
|
14
15
|
export { appendRunJournalRecordDurably, RunJournalStore, RunJournalStoreCorruptionError, writeQuarantineBytesDurably, } from "./run-journal-store.js";
|
|
15
16
|
export { classifySessionTermination, formatSessionTermination, SessionTerminationError, } from "./session-termination.js";
|
|
16
17
|
export { createSyntheticSourceInfo } from "./source-info.js";
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,GAQZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,mBAAmB,EAGnB,yBAAyB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAKN,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAA6C,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAQN,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,6BAA6B,EAG7B,sCAAsC,EACtC,yBAAyB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAA0C,MAAM,gBAAgB,CAAC;AACxF,oBAAoB;AACpB,OAAO,EASN,UAAU,EACV,yBAAyB,EAYzB,eAAe,GAsBf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,6BAA6B,EAG7B,eAAe,EACf,8BAA8B,EAC9B,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,0BAA0B,EAC1B,wBAAwB,EAGxB,uBAAuB,GAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Core modules shared between all run modes.\n */\n\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype PromptOptions,\n\ttype SessionStats,\n\ttype SessionTranscriptRepair,\n} from \"./agent-session.ts\";\nexport {\n\tAgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\tcreateAgentSessionRuntime,\n} from \"./agent-session-runtime.ts\";\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\nexport { type BashExecutorOptions, type BashResult, executeBashWithOperations } from \"./bash-executor.ts\";\nexport {\n\ttype CompactionBarrierResult,\n\ttype CompactionCommitDecision,\n\ttype CompactionEnvelope,\n\ttype CompactionHysteresisConfig,\n\ttype CompactionHysteresisState,\n\ttype CompactionResult,\n\ttype CompactionTransaction,\n\tcreateCompactionEnvelope,\n\tcreateCompactionHysteresisConfig,\n\tcreateCompactionHysteresisState,\n\tcreateCompactionSourceIdentity,\n\tcreateCompactionTransaction,\n\tcreateSessionRevisionToken,\n\tdecideCompactionCommit,\n\tevaluateCompactionBarrier,\n\tstepCompactionHysteresis,\n\tvalidateCompactionEnvelope,\n} from \"./compaction/index.ts\";\nexport {\n\tapplyContextCacheInvalidation,\n\ttype ContextCacheInvalidationEvent,\n\ttype ContextCacheInvalidationSnapshot,\n\tcreateContextCacheInvalidationSnapshot,\n\tplanPromptContextBudgetV2,\n} from \"./context-budget-governor-v2.ts\";\nexport {\n\tcomputeReservedTokenBudget,\n\testimateToolResultReserve,\n\tReservedTokenBudgetError,\n} from \"./context-budget-reserved-tokens.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./event-bus.ts\";\n// Extensions system\nexport {\n\ttype AgentEndEvent,\n\ttype AgentStartEvent,\n\ttype AgentToolResult,\n\ttype AgentToolUpdateCallback,\n\ttype BeforeAgentStartEvent,\n\ttype BeforeAgentStartEventResult,\n\ttype BuildSystemPromptOptions,\n\ttype ContextEvent,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\ttype ExecOptions,\n\ttype ExecResult,\n\ttype Extension,\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n\ttype ExtensionError,\n\ttype ExtensionEvent,\n\ttype ExtensionFactory,\n\ttype ExtensionFlag,\n\ttype ExtensionHandler,\n\tExtensionRunner,\n\ttype ExtensionShortcut,\n\ttype ExtensionUIContext,\n\ttype LoadExtensionsResult,\n\ttype MessageRenderer,\n\ttype RegisteredCommand,\n\ttype SessionBeforeCompactEvent,\n\ttype SessionBeforeForkEvent,\n\ttype SessionBeforeSwitchEvent,\n\ttype SessionBeforeTreeEvent,\n\ttype SessionCompactEvent,\n\ttype SessionShutdownEvent,\n\ttype SessionStartEvent,\n\ttype SessionTreeEvent,\n\ttype ToolCallEvent,\n\ttype ToolCallEventResult,\n\ttype ToolDefinition,\n\ttype ToolRenderResultOptions,\n\ttype ToolResultEvent,\n\ttype TurnEndEvent,\n\ttype TurnStartEvent,\n\ttype WorkingIndicatorOptions,\n} from \"./extensions/index.ts\";\nexport {\n\tappendRunJournalRecordDurably,\n\ttype OpenRunJournalStoreOptions,\n\ttype RunJournalQuarantineReport,\n\tRunJournalStore,\n\tRunJournalStoreCorruptionError,\n\twriteQuarantineBytesDurably,\n} from \"./run-journal-store.ts\";\nexport {\n\tclassifySessionTermination,\n\tformatSessionTermination,\n\ttype SessionTermination,\n\ttype SessionTerminationCause,\n\tSessionTerminationError,\n\ttype SessionTerminationKind,\n} from \"./session-termination.ts\";\nexport { createSyntheticSourceInfo } from \"./source-info.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,YAAY,GAQZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,mBAAmB,EAGnB,yBAAyB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAKN,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAA6C,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAQN,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,6BAA6B,EAG7B,sCAAsC,EACtC,yBAAyB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAA0C,MAAM,gBAAgB,CAAC;AACxF,oBAAoB;AACpB,OAAO,EASN,UAAU,EACV,yBAAyB,EAYzB,eAAe,GAsBf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,EAElC,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,EACnB,+BAA+B,EAE/B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,6BAA6B,EAG7B,eAAe,EACf,8BAA8B,EAC9B,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,0BAA0B,EAC1B,wBAAwB,EAGxB,uBAAuB,GAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Core modules shared between all run modes.\n */\n\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype PromptOptions,\n\ttype SessionStats,\n\ttype SessionTranscriptRepair,\n} from \"./agent-session.ts\";\nexport {\n\tAgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\tcreateAgentSessionRuntime,\n} from \"./agent-session-runtime.ts\";\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\nexport { type BashExecutorOptions, type BashResult, executeBashWithOperations } from \"./bash-executor.ts\";\nexport {\n\ttype CompactionBarrierResult,\n\ttype CompactionCommitDecision,\n\ttype CompactionEnvelope,\n\ttype CompactionHysteresisConfig,\n\ttype CompactionHysteresisState,\n\ttype CompactionResult,\n\ttype CompactionTransaction,\n\tcreateCompactionEnvelope,\n\tcreateCompactionHysteresisConfig,\n\tcreateCompactionHysteresisState,\n\tcreateCompactionSourceIdentity,\n\tcreateCompactionTransaction,\n\tcreateSessionRevisionToken,\n\tdecideCompactionCommit,\n\tevaluateCompactionBarrier,\n\tstepCompactionHysteresis,\n\tvalidateCompactionEnvelope,\n} from \"./compaction/index.ts\";\nexport {\n\tapplyContextCacheInvalidation,\n\ttype ContextCacheInvalidationEvent,\n\ttype ContextCacheInvalidationSnapshot,\n\tcreateContextCacheInvalidationSnapshot,\n\tplanPromptContextBudgetV2,\n} from \"./context-budget-governor-v2.ts\";\nexport {\n\tcomputeReservedTokenBudget,\n\testimateToolResultReserve,\n\tReservedTokenBudgetError,\n} from \"./context-budget-reserved-tokens.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./event-bus.ts\";\n// Extensions system\nexport {\n\ttype AgentEndEvent,\n\ttype AgentStartEvent,\n\ttype AgentToolResult,\n\ttype AgentToolUpdateCallback,\n\ttype BeforeAgentStartEvent,\n\ttype BeforeAgentStartEventResult,\n\ttype BuildSystemPromptOptions,\n\ttype ContextEvent,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\ttype ExecOptions,\n\ttype ExecResult,\n\ttype Extension,\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n\ttype ExtensionError,\n\ttype ExtensionEvent,\n\ttype ExtensionFactory,\n\ttype ExtensionFlag,\n\ttype ExtensionHandler,\n\tExtensionRunner,\n\ttype ExtensionShortcut,\n\ttype ExtensionUIContext,\n\ttype LoadExtensionsResult,\n\ttype MessageRenderer,\n\ttype RegisteredCommand,\n\ttype SessionBeforeCompactEvent,\n\ttype SessionBeforeForkEvent,\n\ttype SessionBeforeSwitchEvent,\n\ttype SessionBeforeTreeEvent,\n\ttype SessionCompactEvent,\n\ttype SessionShutdownEvent,\n\ttype SessionStartEvent,\n\ttype SessionTreeEvent,\n\ttype ToolCallEvent,\n\ttype ToolCallEventResult,\n\ttype ToolDefinition,\n\ttype ToolRenderResultOptions,\n\ttype ToolResultEvent,\n\ttype TurnEndEvent,\n\ttype TurnStartEvent,\n\ttype WorkingIndicatorOptions,\n} from \"./extensions/index.ts\";\nexport {\n\tDEFAULT_PROVIDER_RESILIENCE,\n\tDEFAULT_SAFETY_FAILOVER_CANDIDATES,\n\ttype FailoverCandidate,\n\tisContentSafetyStopMessage,\n\tisOrphanToolCallIdError,\n\tisStickySafetyModel,\n\tisTransientProviderErrorMessage,\n\ttype ProviderResilienceSettings,\n\tpickFailoverCandidate,\n\tresolveFailoverCandidates,\n\tresolveProviderResilience,\n\tSTICKY_SAFETY_MODEL_RE,\n\tstickySafetyBlockMessage,\n} from \"./provider-resilience.ts\";\nexport {\n\tappendRunJournalRecordDurably,\n\ttype OpenRunJournalStoreOptions,\n\ttype RunJournalQuarantineReport,\n\tRunJournalStore,\n\tRunJournalStoreCorruptionError,\n\twriteQuarantineBytesDurably,\n} from \"./run-journal-store.ts\";\nexport {\n\tclassifySessionTermination,\n\tformatSessionTermination,\n\ttype SessionTermination,\n\ttype SessionTerminationCause,\n\tSessionTerminationError,\n\ttype SessionTerminationKind,\n} from \"./session-termination.ts\";\nexport { createSyntheticSourceInfo } from \"./source-info.ts\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadouts.d.ts","sourceRoot":"","sources":["../../src/core/loadouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,WAAW,GACX,eAAe,GACf,cAAc,GACd,aAAa,GACb,iBAAiB,CAAC;AAErB,MAAM,MAAM,WAAW,GACpB,SAAS,GACT,UAAU,GACV,WAAW,GACX,OAAO,GACP,UAAU,GACV,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,oBAAoB,CAAC;AAExB,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAChG,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AACvE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,iBAAiB,GAAG,YAAY,GAAG,cAAc,CAAC;AACrF,MAA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wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ5D","sourcesContent":["/**\n * Pure loadout / lane-profile algorithms for the OMK control plane.\n *\n * This module is I/O-free. It owns the loadout schema, built-in presets,\n * capability gating (allow/exclude/require selectors), profile validation, and\n * the derivation of scheduler read/write/parallelizable fields from a lane's\n * optional assigned paths. Runtime wiring (AgentSession tool registry, skill\n * prompt construction, MCP runtime, scheduler admission) lives in sibling\n * modules and consumes the decisions made here.\n *\n * Schema and presets follow the OMK package hardening loadout plan.\n *\n * Erasable TypeScript only (no enum/namespace/parameter properties).\n */\n\nimport type { HookPolicyMetadata } from \"./hooks/index.ts\";\n\nexport type LoadoutAuthority =\n\t| \"advisory\"\n\t| \"read-only\"\n\t| \"execute-tests\"\n\t| \"write-scoped\"\n\t| \"review-only\"\n\t| \"security-review\";\n\nexport type LoadoutRole =\n\t| \"planner\"\n\t| \"explorer\"\n\t| \"architect\"\n\t| \"coder\"\n\t| \"executor\"\n\t| \"tester\"\n\t| \"reviewer\"\n\t| \"critic\"\n\t| \"security\"\n\t| \"visual-qa\"\n\t| \"rhwp-doc\"\n\t| \"synthesizer\"\n\t| \"package-maintainer\";\n\n/** Resource kinds the loadout layer can describe. Only the last four are gated here. */\nexport type ResourceKind = \"extension\" | \"skill\" | \"prompt\" | \"theme\" | \"tool\" | \"mcp\" | \"hook\";\nexport type ResourceOrigin = \"package\" | \"top-level\";\nexport type SourceScope = \"user\" | \"project\" | \"temporary\" | \"builtin\";\nexport type CommandMode = \"none\" | \"read-only-shell\" | \"tests-only\" | \"scoped-shell\";\nexport type ToolDefaultMode = \"default-builtins\" | \"no-tools\" | \"no-builtin-tools\";\n\nexport interface NamedResource {\n\tkind: ResourceKind;\n\tname: string;\n\tsource?: string;\n\tscope?: SourceScope;\n\t/** Package-relative or absolute resource path, when meaningful (skills/prompts). */\n\tpath?: string;\n\torigin?: ResourceOrigin;\n\tpolicy?: HookPolicyMetadata;\n}\n\n/**\n * A selector matches inventory resources by name and/or provenance criteria.\n * A resource matches when its kind equals `kind` and every defined criterion\n * matches (names is an OR over the listed names; paths/sources are OR over globs).\n */\nexport interface ResourceSelector {\n\tkind: ResourceKind;\n\tnames?: readonly string[];\n\t/** Glob patterns matched against `NamedResource.path`. */\n\tpaths?: readonly string[];\n\t/** Glob patterns matched against `NamedResource.source`. */\n\tsources?: readonly string[];\n\tscopes?: readonly SourceScope[];\n\torigins?: readonly ResourceOrigin[];\n\t/** Marker only; requirement is expressed by placement in `CapabilityGate.require`. */\n\trequired?: boolean;\n}\n\n/** Tool gating uses flat name arrays (mapped to SDK tools / setActiveTools). */\nexport interface ToolGate {\n\tallow?: readonly string[];\n\texclude?: readonly string[];\n\trequire?: readonly string[];\n\tdefaultMode?: ToolDefaultMode;\n}\n\n/** Skills / MCP / hooks gating uses selector arrays. */\nexport interface CapabilityGate {\n\tallow?: readonly ResourceSelector[];\n\texclude?: readonly ResourceSelector[];\n\trequire?: readonly ResourceSelector[];\n}\n\nexport interface LoadoutCommands {\n\tmode: CommandMode;\n\tallowPatterns?: readonly string[];\n\tblockPatterns?: readonly string[];\n}\n\nexport interface LoadoutEvidence {\n\trequired: boolean;\n\toutputPattern: string;\n}\n\nexport interface LoadoutProfile {\n\tschemaVersion: \"omk.loadout.v1\";\n\tname: string;\n\tdescription?: string;\n\tauthority: LoadoutAuthority;\n\ttools: ToolGate;\n\tskills?: CapabilityGate;\n\tmcp?: CapabilityGate;\n\thooks?: CapabilityGate;\n\tcommands?: LoadoutCommands;\n\tevidence?: LoadoutEvidence;\n}\n\nexport interface CapabilityInventory {\n\ttools: readonly NamedResource[];\n\tskills: readonly NamedResource[];\n\tmcp: readonly NamedResource[];\n\thooks: readonly NamedResource[];\n}\n\nexport interface LaneDefaults {\n\tloadout: string;\n\tauthority: LoadoutAuthority;\n\tparallelizable: boolean;\n\treadOnly: boolean;\n\twritesProductFiles: boolean;\n}\n\nexport interface AppliedLoadout {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tblockers: string[];\n\twarnings: string[];\n}\n\nexport interface LoadoutValidation {\n\tvalid: boolean;\n\terrors: string[];\n}\n\n/** A scheduler access entry; shape matches `AccessSetEntry` in the orchestration layer. */\nexport interface LoadoutAccessEntry {\n\tpath: string;\n\tsymbols?: readonly string[];\n}\n\nexport interface SchedulerFields {\n\treadSet: LoadoutAccessEntry[];\n\twriteSet: LoadoutAccessEntry[];\n\tparallelizable: boolean;\n}\n\nexport interface SchedulerDerivationInput {\n\trole: LoadoutRole;\n\tassignedReadPaths?: readonly string[];\n\tassignedWritePaths?: readonly string[];\n}\n\nconst AUTHORITY_RANK: Record<LoadoutAuthority, number> = {\n\tadvisory: 0,\n\t\"read-only\": 1,\n\t\"review-only\": 1,\n\t\"security-review\": 2,\n\t\"execute-tests\": 3,\n\t\"write-scoped\": 4,\n};\n\nconst KNOWN_RESOURCE_KINDS: ReadonlySet<ResourceKind> = new Set([\n\t\"extension\",\n\t\"skill\",\n\t\"prompt\",\n\t\"theme\",\n\t\"tool\",\n\t\"mcp\",\n\t\"hook\",\n]);\n\nconst KNOWN_COMMAND_MODES: ReadonlySet<CommandMode> = new Set([\n\t\"none\",\n\t\"read-only-shell\",\n\t\"tests-only\",\n\t\"scoped-shell\",\n]);\n\nconst KNOWN_TOOL_DEFAULT_MODES: ReadonlySet<ToolDefaultMode> = new Set([\n\t\"default-builtins\",\n\t\"no-tools\",\n\t\"no-builtin-tools\",\n]);\n\n/** Roles permitted to declare a non-empty writeSet during scheduler derivation. */\nconst WRITING_ROLES: ReadonlySet<LoadoutRole> = new Set([\n\t\"coder\",\n\t\"executor\",\n\t\"tester\",\n\t\"rhwp-doc\",\n\t\"synthesizer\",\n\t\"package-maintainer\",\n]);\n\nconst LOCKFILE_BASENAMES: ReadonlySet<string> = new Set([\n\t\"package-lock.json\",\n\t\"npm-shrinkwrap.json\",\n\t\"yarn.lock\",\n\t\"pnpm-lock.yaml\",\n]);\n\nfunction allowNames(kind: ResourceKind, names: readonly string[]): CapabilityGate {\n\treturn { allow: [{ kind, names }] };\n}\n\nexport const BUILTIN_LOADOUTS: Readonly<Record<string, LoadoutProfile>> = {\n\tinspect: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"inspect\",\n\t\tauthority: \"read-only\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\"] },\n\t\tskills: allowNames(\"skill\", [\"understand-chat\", \"analyze\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem-readonly\", \"memory\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\"]),\n\t},\n\tplan: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"plan\",\n\t\tauthority: \"advisory\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\"] },\n\t\tskills: allowNames(\"skill\", [\"adaptorch-route\", \"writing-plans\", \"ddd-software-architecture\"]),\n\t\tmcp: allowNames(\"mcp\", [\"memory\", \"adaptorch\"]),\n\t\thooks: allowNames(\"hook\", [\"session-context\", \"precompact-checkpoint\"]),\n\t},\n\tarchitect: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"architect\",\n\t\tauthority: \"review-only\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"bash\", \"report_finding\"] },\n\t\tskills: allowNames(\"skill\", [\"ddd-software-architecture\", \"code-review\", \"security-review\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem-readonly\", \"memory\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\", \"subagent-stop-audit\"]),\n\t\tcommands: { mode: \"read-only-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/architect.md\" },\n\t},\n\tcode: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"code\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"test-driven-development\", \"coding-standards\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"typecheck-after-edit\"]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\texecutor: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"executor\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"test-driven-development\", \"coding-standards\", \"verification-before-completion\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"typecheck-after-edit\", \"stop-verify\"]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/implementation.md\" },\n\t},\n\ttest: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"test\",\n\t\tauthority: \"execute-tests\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"verification-before-completion\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"stop-verify\"]),\n\t\tcommands: { mode: \"tests-only\" },\n\t},\n\treview: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"review\",\n\t\tauthority: \"review-only\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\"] },\n\t\tskills: allowNames(\"skill\", [\"code-review\", \"differential-review\"]),\n\t\tmcp: allowNames(\"mcp\", [\"memory\"]),\n\t\thooks: allowNames(\"hook\", [\"stop-verify\", \"subagent-stop-audit\"]),\n\t},\n\tcritic: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"critic\",\n\t\tauthority: \"review-only\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"code-review\", \"verification-before-completion\", \"scientific-critical-thinking\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem-readonly\", \"memory\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\", \"subagent-stop-audit\"]),\n\t\tcommands: { mode: \"read-only-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/critic.md\" },\n\t},\n\tsecurity: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"security\",\n\t\tauthority: \"security-review\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"security-review\", \"differential-review\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem-readonly\", \"memory\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"stop-verify\"]),\n\t\tcommands: { mode: \"read-only-shell\" },\n\t},\n\t\"visual-qa\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"visual-qa\",\n\t\tauthority: \"execute-tests\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"clone-website\",\n\t\t\t\"visual-qa\",\n\t\t\t\"visual-diff\",\n\t\t\t\"visual-regression\",\n\t\t\t\"browser-qa\",\n\t\t\t\"web-quality-audit\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"chrome-devtools\", \"playwright\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\n\t\t\t\"component-spec-before-build\",\n\t\t\t\"visual-diff-after-edit\",\n\t\t\t\"typecheck-after-edit\",\n\t\t\t\"bounded-evidence\",\n\t\t\t\"protect-secrets\",\n\t\t\t\"stop-verify\",\n\t\t]),\n\t\tcommands: { mode: \"tests-only\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/visual-qa.md\" },\n\t},\n\t\"rhwp-doc\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"rhwp-doc\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"rhwp\",\n\t\t\t\"rhwp-doc\",\n\t\t\t\"document-extraction\",\n\t\t\t\"document-conversion\",\n\t\t\t\"technical-writing\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\", \"playwright\"]),\n\t\thooks: allowNames(\"hook\", [\n\t\t\t\"document-artifact-guard\",\n\t\t\t\"bounded-evidence\",\n\t\t\t\"pre-shell-guard\",\n\t\t\t\"protect-secrets\",\n\t\t\t\"stop-verify\",\n\t\t]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/rhwp-doc.md\" },\n\t},\n\t\"package-maintainer\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"package-maintainer\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"exact-pin\",\n\t\t\t\"no-lifecycle-scripts\",\n\t\t\t\"security-review\",\n\t\t\t\"verification-before-completion\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"npm-audit-summary\", \"stop-verify\"]),\n\t\tcommands: {\n\t\t\tmode: \"scoped-shell\",\n\t\t\tallowPatterns: [\n\t\t\t\t\"npm install --ignore-scripts*\",\n\t\t\t\t\"npm ci --ignore-scripts*\",\n\t\t\t\t\"npm install --package-lock-only --ignore-scripts*\",\n\t\t\t\t\"node scripts/generate-coding-agent-shrinkwrap.mjs*\",\n\t\t\t],\n\t\t\tblockPatterns: [\n\t\t\t\t\"*@latest*\",\n\t\t\t\t\"npm install *--ignore-scripts=false*\",\n\t\t\t\t\"npm ci *--ignore-scripts=false*\",\n\t\t\t\t\"npm rebuild*\",\n\t\t\t],\n\t\t},\n\t},\n\tnone: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"none\",\n\t\tauthority: \"advisory\",\n\t\ttools: { allow: [], defaultMode: \"no-tools\" },\n\t\tcommands: { mode: \"none\" },\n\t},\n};\n\nexport function inferLoadoutForRole(role: LoadoutRole): string {\n\tswitch (role) {\n\t\tcase \"planner\":\n\t\t\treturn \"plan\";\n\t\tcase \"explorer\":\n\t\t\treturn \"inspect\";\n\t\tcase \"architect\":\n\t\t\treturn \"architect\";\n\t\tcase \"coder\":\n\t\t\treturn \"code\";\n\t\tcase \"executor\":\n\t\t\treturn \"executor\";\n\t\tcase \"tester\":\n\t\t\treturn \"test\";\n\t\tcase \"reviewer\":\n\t\t\treturn \"review\";\n\t\tcase \"critic\":\n\t\t\treturn \"critic\";\n\t\tcase \"security\":\n\t\t\treturn \"security\";\n\t\tcase \"visual-qa\":\n\t\t\treturn \"visual-qa\";\n\t\tcase \"rhwp-doc\":\n\t\t\treturn \"rhwp-doc\";\n\t\tcase \"package-maintainer\":\n\t\t\treturn \"package-maintainer\";\n\t\tcase \"synthesizer\":\n\t\t\treturn \"plan\";\n\t}\n}\n\nexport function authorityWithinGrant(requested: LoadoutAuthority, grant: LoadoutAuthority): boolean {\n\treturn AUTHORITY_RANK[requested] <= AUTHORITY_RANK[grant];\n}\n\nexport function laneDefaultsForRole(role: LoadoutRole): LaneDefaults {\n\tconst loadout = inferLoadoutForRole(role);\n\tconst profile = BUILTIN_LOADOUTS[loadout];\n\treturn {\n\t\tloadout,\n\t\tauthority: profile.authority,\n\t\tparallelizable: profile.authority !== \"write-scoped\",\n\t\treadOnly:\n\t\t\tprofile.authority === \"read-only\" || profile.authority === \"review-only\" || profile.authority === \"advisory\",\n\t\twritesProductFiles: profile.authority === \"write-scoped\",\n\t};\n}\n\nexport function applyLoadoutProfile(\n\tprofile: LoadoutProfile,\n\tinventory: CapabilityInventory,\n\toptions: { grantAuthority?: LoadoutAuthority } = {},\n): AppliedLoadout {\n\tconst blockers: string[] = [];\n\tconst warnings: string[] = [];\n\t// Deterministic blocker order: authority, then tool/skill/mcp/hook requires.\n\tif (options.grantAuthority && !authorityWithinGrant(profile.authority, options.grantAuthority)) {\n\t\tblockers.push(`loadout authority ${profile.authority} exceeds grant ${options.grantAuthority}`);\n\t}\n\n\tconst activeTools = applyToolGate(profile.tools, inventory.tools, blockers, warnings);\n\tconst activeSkills = applyCapabilityGate(\"skill\", profile.skills, inventory.skills, blockers, warnings);\n\tconst activeMcp = applyCapabilityGate(\"mcp\", profile.mcp, inventory.mcp, blockers, warnings);\n\tconst activeHooks = applyCapabilityGate(\"hook\", profile.hooks, inventory.hooks, blockers, warnings);\n\n\treturn {\n\t\tprofileName: profile.name,\n\t\tauthority: profile.authority,\n\t\tactiveTools,\n\t\tactiveSkills,\n\t\tactiveMcp,\n\t\tactiveHooks,\n\t\tblockers,\n\t\twarnings,\n\t};\n}\n\n/**\n * Fail-closed structural validation of a loadout profile. Errors are returned\n * in a deterministic order: schemaVersion, name, authority, tools, skills, mcp,\n * hooks, commands.\n */\nexport function validateLoadoutProfile(profile: LoadoutProfile): LoadoutValidation {\n\tconst errors: string[] = [];\n\tif (profile.schemaVersion !== \"omk.loadout.v1\") {\n\t\terrors.push(`unknown schemaVersion: ${String(profile.schemaVersion)}`);\n\t}\n\tif (typeof profile.name !== \"string\" || profile.name.trim() === \"\") {\n\t\terrors.push(\"missing loadout name\");\n\t}\n\tif (!(profile.authority in AUTHORITY_RANK)) {\n\t\terrors.push(`unknown authority: ${String(profile.authority)}`);\n\t}\n\tvalidateToolGate(profile.tools, errors);\n\tvalidateCapabilityGate(\"skills\", \"skill\", profile.skills, errors);\n\tvalidateCapabilityGate(\"mcp\", \"mcp\", profile.mcp, errors);\n\tvalidateCapabilityGate(\"hooks\", \"hook\", profile.hooks, errors);\n\tif (profile.commands) {\n\t\tif (!KNOWN_COMMAND_MODES.has(profile.commands.mode)) {\n\t\t\terrors.push(`unknown command mode: ${String(profile.commands.mode)}`);\n\t\t} else if (profile.authority in AUTHORITY_RANK) {\n\t\t\tconst conflict = commandModeAuthorityConflict(profile.commands.mode, profile.authority);\n\t\t\tif (conflict) errors.push(conflict);\n\t\t}\n\t}\n\treturn { valid: errors.length === 0, errors };\n}\n\n/**\n * Derive scheduler readSet/writeSet/parallelizable from a lane role plus the\n * optional paths granted to that lane. Non-writing roles never produce a\n * writeSet. parallelizable is false when a write-scoped lane writes anything,\n * or when any write touches a lockfile, package config, snapshot, or git index.\n */\nexport function deriveSchedulerFields(input: SchedulerDerivationInput): SchedulerFields {\n\tconst defaults = laneDefaultsForRole(input.role);\n\tconst readSet = toAccessSet(input.assignedReadPaths);\n\tconst writeSet = WRITING_ROLES.has(input.role) ? toAccessSet(input.assignedWritePaths) : [];\n\tconst parallelizable = deriveParallelizable(defaults.authority, writeSet);\n\treturn { readSet, writeSet, parallelizable };\n}\n\nfunction deriveParallelizable(authority: LoadoutAuthority, writeSet: readonly LoadoutAccessEntry[]): boolean {\n\tif (writeSet.length === 0) return true;\n\tif (authority === \"write-scoped\") return false;\n\tif (writeSet.some((entry) => isSerializeTriggerPath(entry.path))) return false;\n\treturn true;\n}\n\n/** Lockfile, package config, snapshot, or git-index writes force serialization. */\nexport function isSerializeTriggerPath(path: string): boolean {\n\tconst normalized = path.replaceAll(\"\\\\\", \"/\");\n\tconst base = normalized.slice(normalized.lastIndexOf(\"/\") + 1);\n\tif (LOCKFILE_BASENAMES.has(base)) return true;\n\tif (base === \"package.json\") return true;\n\tif (base.endsWith(\".snap\")) return true;\n\tif (normalized === \".git/index\" || normalized.startsWith(\".git/\") || normalized.includes(\"/.git/\")) return true;\n\treturn false;\n}\n\nfunction toAccessSet(paths: readonly string[] | undefined): LoadoutAccessEntry[] {\n\tif (!paths) return [];\n\tconst seen = new Set<string>();\n\tconst entries: LoadoutAccessEntry[] = [];\n\tfor (const raw of paths) {\n\t\tconst path = raw.trim();\n\t\tif (path === \"\" || seen.has(path)) continue;\n\t\tseen.add(path);\n\t\tentries.push({ path });\n\t}\n\tentries.sort((a, b) => compareString(a.path, b.path));\n\treturn entries;\n}\n\nfunction resourceNames(resources: readonly NamedResource[]): Set<string> {\n\treturn new Set(resources.map((resource) => resource.name));\n}\n\nfunction applyToolGate(\n\tgate: ToolGate,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\twarnings: string[],\n): string[] {\n\tconst available = resourceNames(resources);\n\tfor (const required of gate.require ?? []) {\n\t\tif (!available.has(required)) blockers.push(`missing required tool: ${required}`);\n\t}\n\tconst base = gate.defaultMode === \"no-tools\" ? [] : (gate.allow ?? resources.map((resource) => resource.name));\n\tconst excluded = new Set(gate.exclude ?? []);\n\tconst active: string[] = [];\n\tfor (const tool of base) {\n\t\tif (!available.has(tool)) {\n\t\t\twarnings.push(`optional tool not available: ${tool}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!excluded.has(tool)) active.push(tool);\n\t}\n\treturn [...new Set(active)].sort(compareString);\n}\n\nfunction applyCapabilityGate(\n\tkind: ResourceKind,\n\tgate: CapabilityGate | undefined,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\twarnings: string[],\n): string[] {\n\tif (!gate) return [];\n\tconst active = new Set<string>();\n\n\t// require: every required selector must resolve, else a deterministic blocker.\n\tfor (const selector of gate.require ?? []) {\n\t\tresolveRequireSelector(kind, selector, resources, blockers, active);\n\t}\n\n\t// allow: union of matches; warn on named-but-missing optional capabilities.\n\tfor (const selector of gate.allow ?? []) {\n\t\tfor (const match of matchSelector(selector, resources)) active.add(match.name);\n\t\tfor (const name of selector.names ?? []) {\n\t\t\tif (!resources.some((resource) => resource.name === name && matchesCriteria(selector, resource))) {\n\t\t\t\twarnings.push(`optional ${kind} not available: ${name}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// exclude: applied last.\n\tconst excluded = new Set<string>();\n\tfor (const selector of gate.exclude ?? []) {\n\t\tfor (const match of matchSelector(selector, resources)) excluded.add(match.name);\n\t}\n\n\tconst result = [...active].filter((name) => !excluded.has(name));\n\treturn [...new Set(result)].sort(compareString);\n}\n\nfunction resolveRequireSelector(\n\tkind: ResourceKind,\n\tselector: ResourceSelector,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\tactive: Set<string>,\n): void {\n\tif (selector.names && selector.names.length > 0) {\n\t\tfor (const name of selector.names) {\n\t\t\tconst matched = resources.some((resource) => resource.name === name && matchesCriteria(selector, resource));\n\t\t\tif (matched) active.add(name);\n\t\t\telse blockers.push(`missing required ${kind}: ${name}`);\n\t\t}\n\t\treturn;\n\t}\n\tconst matches = matchSelector(selector, resources);\n\tif (matches.length === 0) {\n\t\tblockers.push(`missing required ${kind}: ${describeSelector(selector)}`);\n\t\treturn;\n\t}\n\tfor (const match of matches) active.add(match.name);\n}\n\nfunction matchSelector(selector: ResourceSelector, resources: readonly NamedResource[]): NamedResource[] {\n\treturn resources.filter((resource) => {\n\t\tif (selector.names && !selector.names.includes(resource.name)) return false;\n\t\treturn matchesCriteria(selector, resource);\n\t});\n}\n\nfunction matchesCriteria(selector: ResourceSelector, resource: NamedResource): boolean {\n\tif (resource.kind !== selector.kind) return false;\n\tif (selector.scopes && (resource.scope === undefined || !selector.scopes.includes(resource.scope))) return false;\n\tif (selector.origins && (resource.origin === undefined || !selector.origins.includes(resource.origin))) return false;\n\tif (selector.sources && !selector.sources.some((glob) => globMatch(glob, resource.source ?? \"\"))) return false;\n\tif (selector.paths && !selector.paths.some((glob) => globMatch(glob, resource.path ?? \"\"))) return false;\n\treturn true;\n}\n\nfunction describeSelector(selector: ResourceSelector): string {\n\tconst parts: string[] = [`kind=${selector.kind}`];\n\tif (selector.paths) parts.push(`paths=${selector.paths.join(\",\")}`);\n\tif (selector.sources) parts.push(`sources=${selector.sources.join(\",\")}`);\n\tif (selector.scopes) parts.push(`scopes=${selector.scopes.join(\",\")}`);\n\tif (selector.origins) parts.push(`origins=${selector.origins.join(\",\")}`);\n\treturn parts.join(\" \");\n}\n\nfunction validateToolGate(gate: ToolGate | undefined, errors: string[]): void {\n\tif (!gate) {\n\t\terrors.push(\"missing tools gate\");\n\t\treturn;\n\t}\n\tif (gate.defaultMode !== undefined && !KNOWN_TOOL_DEFAULT_MODES.has(gate.defaultMode)) {\n\t\terrors.push(`unknown tool defaultMode: ${String(gate.defaultMode)}`);\n\t}\n}\n\nfunction validateCapabilityGate(\n\tgateName: string,\n\texpectedKind: ResourceKind,\n\tgate: CapabilityGate | undefined,\n\terrors: string[],\n): void {\n\tif (!gate) return;\n\tfor (const group of [\"allow\", \"exclude\", \"require\"] as const) {\n\t\tconst selectors = gate[group];\n\t\tif (!selectors) continue;\n\t\tfor (const selector of selectors) {\n\t\t\tif (!KNOWN_RESOURCE_KINDS.has(selector.kind)) {\n\t\t\t\terrors.push(`unknown resource kind in ${gateName}.${group}: ${String(selector.kind)}`);\n\t\t\t} else if (selector.kind !== expectedKind) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`mismatched selector kind in ${gateName}.${group}: expected ${expectedKind}, got ${selector.kind}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction commandModeAuthorityConflict(mode: CommandMode, authority: LoadoutAuthority): string | undefined {\n\tif (mode === \"scoped-shell\" && authority !== \"write-scoped\") {\n\t\treturn `command mode scoped-shell requires write-scoped authority, got ${authority}`;\n\t}\n\tif (mode === \"tests-only\" && authority !== \"execute-tests\" && authority !== \"write-scoped\") {\n\t\treturn `command mode tests-only requires execute-tests or write-scoped authority, got ${authority}`;\n\t}\n\treturn undefined;\n}\n\nfunction globMatch(glob: string, value: string): boolean {\n\treturn globToRegExp(glob).test(value);\n}\n\nfunction globToRegExp(glob: string): RegExp {\n\tlet pattern = \"\";\n\tfor (let index = 0; index < glob.length; index++) {\n\t\tconst char = glob[index];\n\t\tif (char === \"*\") {\n\t\t\tif (glob[index + 1] === \"*\") {\n\t\t\t\tpattern += \".*\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\tpattern += \"[^/]*\";\n\t\t\t}\n\t\t} else if (char === \"?\") {\n\t\t\tpattern += \".\";\n\t\t} else {\n\t\t\tpattern += char.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t}\n\t}\n\treturn new RegExp(`^${pattern}$`);\n}\n\nfunction compareString(a: string, b: string): number {\n\tif (a < b) return -1;\n\tif (a > b) return 1;\n\treturn 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loadouts.d.ts","sourceRoot":"","sources":["../../src/core/loadouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,WAAW,GACX,eAAe,GACf,cAAc,GACd,aAAa,GACb,iBAAiB,CAAC;AAErB,MAAM,MAAM,WAAW,GACpB,SAAS,GACT,UAAU,GACV,WAAW,GACX,OAAO,GACP,UAAU,GACV,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,UAAU,GACV,WAAW,GACX,UAAU,GACV,aAAa,GACb,oBAAoB,CAAC;AAExB,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAChG,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,MAA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AE,cAAc,GAAG,iBAAiB,CAwBjF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,wBAAwB,GAAG,eAAe,CAMtF;AASD,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ5D","sourcesContent":["/**\n * Pure loadout / lane-profile algorithms for the OMK control plane.\n *\n * This module is I/O-free. It owns the loadout schema, built-in presets,\n * capability gating (allow/exclude/require selectors), profile validation, and\n * the derivation of scheduler read/write/parallelizable fields from a lane's\n * optional assigned paths. Runtime wiring (AgentSession tool registry, skill\n * prompt construction, MCP runtime, scheduler admission) lives in sibling\n * modules and consumes the decisions made here.\n *\n * Schema and presets follow the OMK package hardening loadout plan.\n *\n * Erasable TypeScript only (no enum/namespace/parameter properties).\n */\n\nimport type { HookPolicyMetadata } from \"./hooks/index.ts\";\n\nexport type LoadoutAuthority =\n\t| \"advisory\"\n\t| \"read-only\"\n\t| \"execute-tests\"\n\t| \"write-scoped\"\n\t| \"review-only\"\n\t| \"security-review\";\n\nexport type LoadoutRole =\n\t| \"planner\"\n\t| \"explorer\"\n\t| \"architect\"\n\t| \"coder\"\n\t| \"executor\"\n\t| \"tester\"\n\t| \"reviewer\"\n\t| \"critic\"\n\t| \"security\"\n\t| \"visual-qa\"\n\t| \"rhwp-doc\"\n\t| \"synthesizer\"\n\t| \"package-maintainer\";\n\n/** Resource kinds the loadout layer can describe. Only the last four are gated here. */\nexport type ResourceKind = \"extension\" | \"skill\" | \"prompt\" | \"theme\" | \"tool\" | \"mcp\" | \"hook\";\nexport type ResourceOrigin = \"package\" | \"top-level\";\nexport type SourceScope = \"user\" | \"project\" | \"temporary\" | \"builtin\";\nexport type CommandMode = \"none\" | \"read-only-shell\" | \"tests-only\" | \"scoped-shell\";\nexport type ToolDefaultMode = \"default-builtins\" | \"no-tools\" | \"no-builtin-tools\";\n\nexport interface NamedResource {\n\tkind: ResourceKind;\n\tname: string;\n\tsource?: string;\n\tscope?: SourceScope;\n\t/** Package-relative or absolute resource path, when meaningful (skills/prompts). */\n\tpath?: string;\n\torigin?: ResourceOrigin;\n\tpolicy?: HookPolicyMetadata;\n}\n\n/**\n * A selector matches inventory resources by name and/or provenance criteria.\n * A resource matches when its kind equals `kind` and every defined criterion\n * matches (names is an OR over the listed names; paths/sources are OR over globs).\n */\nexport interface ResourceSelector {\n\tkind: ResourceKind;\n\tnames?: readonly string[];\n\t/** Glob patterns matched against `NamedResource.path`. */\n\tpaths?: readonly string[];\n\t/** Glob patterns matched against `NamedResource.source`. */\n\tsources?: readonly string[];\n\tscopes?: readonly SourceScope[];\n\torigins?: readonly ResourceOrigin[];\n\t/** Marker only; requirement is expressed by placement in `CapabilityGate.require`. */\n\trequired?: boolean;\n}\n\n/** Tool gating uses flat name arrays (mapped to SDK tools / setActiveTools). */\nexport interface ToolGate {\n\tallow?: readonly string[];\n\texclude?: readonly string[];\n\trequire?: readonly string[];\n\tdefaultMode?: ToolDefaultMode;\n}\n\n/** Skills / MCP / hooks gating uses selector arrays. */\nexport interface CapabilityGate {\n\tallow?: readonly ResourceSelector[];\n\texclude?: readonly ResourceSelector[];\n\trequire?: readonly ResourceSelector[];\n}\n\nexport interface LoadoutCommands {\n\tmode: CommandMode;\n\tallowPatterns?: readonly string[];\n\tblockPatterns?: readonly string[];\n}\n\nexport interface LoadoutEvidence {\n\trequired: boolean;\n\toutputPattern: string;\n}\n\nexport interface LoadoutProfile {\n\tschemaVersion: \"omk.loadout.v1\";\n\tname: string;\n\tdescription?: string;\n\tauthority: LoadoutAuthority;\n\ttools: ToolGate;\n\tskills?: CapabilityGate;\n\tmcp?: CapabilityGate;\n\thooks?: CapabilityGate;\n\tcommands?: LoadoutCommands;\n\tevidence?: LoadoutEvidence;\n}\n\nexport interface CapabilityInventory {\n\ttools: readonly NamedResource[];\n\tskills: readonly NamedResource[];\n\tmcp: readonly NamedResource[];\n\thooks: readonly NamedResource[];\n}\n\nexport interface LaneDefaults {\n\tloadout: string;\n\tauthority: LoadoutAuthority;\n\tparallelizable: boolean;\n\treadOnly: boolean;\n\twritesProductFiles: boolean;\n}\n\nexport interface AppliedLoadout {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tblockers: string[];\n\twarnings: string[];\n}\n\nexport interface LoadoutValidation {\n\tvalid: boolean;\n\terrors: string[];\n}\n\n/** A scheduler access entry; shape matches `AccessSetEntry` in the orchestration layer. */\nexport interface LoadoutAccessEntry {\n\tpath: string;\n\tsymbols?: readonly string[];\n}\n\nexport interface SchedulerFields {\n\treadSet: LoadoutAccessEntry[];\n\twriteSet: LoadoutAccessEntry[];\n\tparallelizable: boolean;\n}\n\nexport interface SchedulerDerivationInput {\n\trole: LoadoutRole;\n\tassignedReadPaths?: readonly string[];\n\tassignedWritePaths?: readonly string[];\n}\n\nconst AUTHORITY_RANK: Record<LoadoutAuthority, number> = {\n\tadvisory: 0,\n\t\"read-only\": 1,\n\t\"review-only\": 1,\n\t\"security-review\": 2,\n\t\"execute-tests\": 3,\n\t\"write-scoped\": 4,\n};\n\nconst KNOWN_RESOURCE_KINDS: ReadonlySet<ResourceKind> = new Set([\n\t\"extension\",\n\t\"skill\",\n\t\"prompt\",\n\t\"theme\",\n\t\"tool\",\n\t\"mcp\",\n\t\"hook\",\n]);\n\nconst KNOWN_COMMAND_MODES: ReadonlySet<CommandMode> = new Set([\n\t\"none\",\n\t\"read-only-shell\",\n\t\"tests-only\",\n\t\"scoped-shell\",\n]);\n\nconst KNOWN_TOOL_DEFAULT_MODES: ReadonlySet<ToolDefaultMode> = new Set([\n\t\"default-builtins\",\n\t\"no-tools\",\n\t\"no-builtin-tools\",\n]);\n\n/** Roles permitted to declare a non-empty writeSet during scheduler derivation. */\nconst WRITING_ROLES: ReadonlySet<LoadoutRole> = new Set([\n\t\"coder\",\n\t\"executor\",\n\t\"tester\",\n\t\"rhwp-doc\",\n\t\"synthesizer\",\n\t\"package-maintainer\",\n]);\n\nconst LOCKFILE_BASENAMES: ReadonlySet<string> = new Set([\n\t\"package-lock.json\",\n\t\"npm-shrinkwrap.json\",\n\t\"yarn.lock\",\n\t\"pnpm-lock.yaml\",\n]);\n\nfunction allowNames(kind: ResourceKind, names: readonly string[]): CapabilityGate {\n\treturn { allow: [{ kind, names }] };\n}\n\nexport const BUILTIN_LOADOUTS: Readonly<Record<string, LoadoutProfile>> = {\n\tinspect: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"inspect\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\tplan: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"plan\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\tarchitect: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"architect\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\", \"report_finding\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\tcode: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"code\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"test-driven-development\", \"coding-standards\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"typecheck-after-edit\"]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\texecutor: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"executor\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\"test-driven-development\", \"coding-standards\", \"verification-before-completion\"]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"typecheck-after-edit\", \"stop-verify\"]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/implementation.md\" },\n\t},\n\ttest: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"test\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\treview: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"review\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\tcritic: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"critic\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\tsecurity: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"security\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\t\"visual-qa\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"visual-qa\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"clone-website\",\n\t\t\t\"visual-qa\",\n\t\t\t\"visual-diff\",\n\t\t\t\"visual-regression\",\n\t\t\t\"browser-qa\",\n\t\t\t\"web-quality-audit\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"chrome-devtools\", \"playwright\", \"context7\"]),\n\t\thooks: allowNames(\"hook\", [\n\t\t\t\"component-spec-before-build\",\n\t\t\t\"visual-diff-after-edit\",\n\t\t\t\"typecheck-after-edit\",\n\t\t\t\"bounded-evidence\",\n\t\t\t\"protect-secrets\",\n\t\t\t\"stop-verify\",\n\t\t]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n\t\"rhwp-doc\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"rhwp-doc\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"rhwp\",\n\t\t\t\"rhwp-doc\",\n\t\t\t\"document-extraction\",\n\t\t\t\"document-conversion\",\n\t\t\t\"technical-writing\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\", \"context7\", \"playwright\"]),\n\t\thooks: allowNames(\"hook\", [\n\t\t\t\"document-artifact-guard\",\n\t\t\t\"bounded-evidence\",\n\t\t\t\"pre-shell-guard\",\n\t\t\t\"protect-secrets\",\n\t\t\t\"stop-verify\",\n\t\t]),\n\t\tcommands: { mode: \"scoped-shell\" },\n\t\tevidence: { required: true, outputPattern: \".omk/runs/<goal>/rhwp-doc.md\" },\n\t},\n\t\"package-maintainer\": {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"package-maintainer\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tskills: allowNames(\"skill\", [\n\t\t\t\"exact-pin\",\n\t\t\t\"no-lifecycle-scripts\",\n\t\t\t\"security-review\",\n\t\t\t\"verification-before-completion\",\n\t\t]),\n\t\tmcp: allowNames(\"mcp\", [\"filesystem\"]),\n\t\thooks: allowNames(\"hook\", [\"pre-shell-guard\", \"protect-secrets\", \"npm-audit-summary\", \"stop-verify\"]),\n\t\tcommands: {\n\t\t\tmode: \"scoped-shell\",\n\t\t\tallowPatterns: [\n\t\t\t\t\"npm install --ignore-scripts*\",\n\t\t\t\t\"npm ci --ignore-scripts*\",\n\t\t\t\t\"npm install --package-lock-only --ignore-scripts*\",\n\t\t\t\t\"node scripts/generate-coding-agent-shrinkwrap.mjs*\",\n\t\t\t],\n\t\t\tblockPatterns: [\n\t\t\t\t\"*@latest*\",\n\t\t\t\t\"npm install *--ignore-scripts=false*\",\n\t\t\t\t\"npm ci *--ignore-scripts=false*\",\n\t\t\t\t\"npm rebuild*\",\n\t\t\t],\n\t\t},\n\t},\n\tnone: {\n\t\tschemaVersion: \"omk.loadout.v1\",\n\t\tname: \"none\",\n\t\tauthority: \"write-scoped\",\n\t\ttools: { allow: [\"read\", \"grep\", \"find\", \"ls\", \"edit\", \"write\", \"bash\"] },\n\t\tcommands: { mode: \"scoped-shell\" },\n\t},\n};\n\nexport function inferLoadoutForRole(role: LoadoutRole): string {\n\tswitch (role) {\n\t\tcase \"planner\":\n\t\t\treturn \"plan\";\n\t\tcase \"explorer\":\n\t\t\treturn \"inspect\";\n\t\tcase \"architect\":\n\t\t\treturn \"architect\";\n\t\tcase \"coder\":\n\t\t\treturn \"code\";\n\t\tcase \"executor\":\n\t\t\treturn \"executor\";\n\t\tcase \"tester\":\n\t\t\treturn \"test\";\n\t\tcase \"reviewer\":\n\t\t\treturn \"review\";\n\t\tcase \"critic\":\n\t\t\treturn \"critic\";\n\t\tcase \"security\":\n\t\t\treturn \"security\";\n\t\tcase \"visual-qa\":\n\t\t\treturn \"visual-qa\";\n\t\tcase \"rhwp-doc\":\n\t\t\treturn \"rhwp-doc\";\n\t\tcase \"package-maintainer\":\n\t\t\treturn \"package-maintainer\";\n\t\tcase \"synthesizer\":\n\t\t\treturn \"plan\";\n\t}\n}\n\nexport function authorityWithinGrant(requested: LoadoutAuthority, grant: LoadoutAuthority): boolean {\n\treturn AUTHORITY_RANK[requested] <= AUTHORITY_RANK[grant];\n}\n\nexport function laneDefaultsForRole(role: LoadoutRole): LaneDefaults {\n\tconst loadout = inferLoadoutForRole(role);\n\tconst profile = BUILTIN_LOADOUTS[loadout];\n\treturn {\n\t\tloadout,\n\t\tauthority: profile.authority,\n\t\tparallelizable: profile.authority !== \"write-scoped\",\n\t\treadOnly:\n\t\t\tprofile.authority === \"read-only\" || profile.authority === \"review-only\" || profile.authority === \"advisory\",\n\t\twritesProductFiles: profile.authority === \"write-scoped\",\n\t};\n}\n\nexport function applyLoadoutProfile(\n\tprofile: LoadoutProfile,\n\tinventory: CapabilityInventory,\n\toptions: { grantAuthority?: LoadoutAuthority } = {},\n): AppliedLoadout {\n\tconst blockers: string[] = [];\n\tconst warnings: string[] = [];\n\t// Deterministic blocker order: authority, then tool/skill/mcp/hook requires.\n\tif (options.grantAuthority && !authorityWithinGrant(profile.authority, options.grantAuthority)) {\n\t\tblockers.push(`loadout authority ${profile.authority} exceeds grant ${options.grantAuthority}`);\n\t}\n\n\tconst activeTools = applyToolGate(profile.tools, inventory.tools, blockers, warnings);\n\tconst activeSkills = applyCapabilityGate(\"skill\", profile.skills, inventory.skills, blockers, warnings);\n\tconst activeMcp = applyCapabilityGate(\"mcp\", profile.mcp, inventory.mcp, blockers, warnings);\n\tconst activeHooks = applyCapabilityGate(\"hook\", profile.hooks, inventory.hooks, blockers, warnings);\n\n\treturn {\n\t\tprofileName: profile.name,\n\t\tauthority: profile.authority,\n\t\tactiveTools,\n\t\tactiveSkills,\n\t\tactiveMcp,\n\t\tactiveHooks,\n\t\tblockers,\n\t\twarnings,\n\t};\n}\n\n/**\n * Fail-closed structural validation of a loadout profile. Errors are returned\n * in a deterministic order: schemaVersion, name, authority, tools, skills, mcp,\n * hooks, commands.\n */\nexport function validateLoadoutProfile(profile: LoadoutProfile): LoadoutValidation {\n\tconst errors: string[] = [];\n\tif (profile.schemaVersion !== \"omk.loadout.v1\") {\n\t\terrors.push(`unknown schemaVersion: ${String(profile.schemaVersion)}`);\n\t}\n\tif (typeof profile.name !== \"string\" || profile.name.trim() === \"\") {\n\t\terrors.push(\"missing loadout name\");\n\t}\n\tif (!(profile.authority in AUTHORITY_RANK)) {\n\t\terrors.push(`unknown authority: ${String(profile.authority)}`);\n\t}\n\tvalidateToolGate(profile.tools, errors);\n\tvalidateCapabilityGate(\"skills\", \"skill\", profile.skills, errors);\n\tvalidateCapabilityGate(\"mcp\", \"mcp\", profile.mcp, errors);\n\tvalidateCapabilityGate(\"hooks\", \"hook\", profile.hooks, errors);\n\tif (profile.commands) {\n\t\tif (!KNOWN_COMMAND_MODES.has(profile.commands.mode)) {\n\t\t\terrors.push(`unknown command mode: ${String(profile.commands.mode)}`);\n\t\t} else if (profile.authority in AUTHORITY_RANK) {\n\t\t\tconst conflict = commandModeAuthorityConflict(profile.commands.mode, profile.authority);\n\t\t\tif (conflict) errors.push(conflict);\n\t\t}\n\t}\n\treturn { valid: errors.length === 0, errors };\n}\n\n/**\n * Derive scheduler readSet/writeSet/parallelizable from a lane role plus the\n * optional paths granted to that lane. Non-writing roles never produce a\n * writeSet. parallelizable is false when a write-scoped lane writes anything,\n * or when any write touches a lockfile, package config, snapshot, or git index.\n */\nexport function deriveSchedulerFields(input: SchedulerDerivationInput): SchedulerFields {\n\tconst defaults = laneDefaultsForRole(input.role);\n\tconst readSet = toAccessSet(input.assignedReadPaths);\n\tconst writeSet = WRITING_ROLES.has(input.role) ? toAccessSet(input.assignedWritePaths) : [];\n\tconst parallelizable = deriveParallelizable(defaults.authority, writeSet);\n\treturn { readSet, writeSet, parallelizable };\n}\n\nfunction deriveParallelizable(authority: LoadoutAuthority, writeSet: readonly LoadoutAccessEntry[]): boolean {\n\tif (writeSet.length === 0) return true;\n\tif (authority === \"write-scoped\") return false;\n\tif (writeSet.some((entry) => isSerializeTriggerPath(entry.path))) return false;\n\treturn true;\n}\n\n/** Lockfile, package config, snapshot, or git-index writes force serialization. */\nexport function isSerializeTriggerPath(path: string): boolean {\n\tconst normalized = path.replaceAll(\"\\\\\", \"/\");\n\tconst base = normalized.slice(normalized.lastIndexOf(\"/\") + 1);\n\tif (LOCKFILE_BASENAMES.has(base)) return true;\n\tif (base === \"package.json\") return true;\n\tif (base.endsWith(\".snap\")) return true;\n\tif (normalized === \".git/index\" || normalized.startsWith(\".git/\") || normalized.includes(\"/.git/\")) return true;\n\treturn false;\n}\n\nfunction toAccessSet(paths: readonly string[] | undefined): LoadoutAccessEntry[] {\n\tif (!paths) return [];\n\tconst seen = new Set<string>();\n\tconst entries: LoadoutAccessEntry[] = [];\n\tfor (const raw of paths) {\n\t\tconst path = raw.trim();\n\t\tif (path === \"\" || seen.has(path)) continue;\n\t\tseen.add(path);\n\t\tentries.push({ path });\n\t}\n\tentries.sort((a, b) => compareString(a.path, b.path));\n\treturn entries;\n}\n\nfunction resourceNames(resources: readonly NamedResource[]): Set<string> {\n\treturn new Set(resources.map((resource) => resource.name));\n}\n\nfunction applyToolGate(\n\tgate: ToolGate,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\twarnings: string[],\n): string[] {\n\tconst available = resourceNames(resources);\n\tfor (const required of gate.require ?? []) {\n\t\tif (!available.has(required)) blockers.push(`missing required tool: ${required}`);\n\t}\n\tconst base = gate.defaultMode === \"no-tools\" ? [] : (gate.allow ?? resources.map((resource) => resource.name));\n\tconst excluded = new Set(gate.exclude ?? []);\n\tconst active: string[] = [];\n\tfor (const tool of base) {\n\t\tif (!available.has(tool)) {\n\t\t\twarnings.push(`optional tool not available: ${tool}`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!excluded.has(tool)) active.push(tool);\n\t}\n\treturn [...new Set(active)].sort(compareString);\n}\n\nfunction applyCapabilityGate(\n\tkind: ResourceKind,\n\tgate: CapabilityGate | undefined,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\twarnings: string[],\n): string[] {\n\tif (!gate) return [];\n\tconst active = new Set<string>();\n\n\t// require: every required selector must resolve, else a deterministic blocker.\n\tfor (const selector of gate.require ?? []) {\n\t\tresolveRequireSelector(kind, selector, resources, blockers, active);\n\t}\n\n\t// allow: union of matches; warn on named-but-missing optional capabilities.\n\tfor (const selector of gate.allow ?? []) {\n\t\tfor (const match of matchSelector(selector, resources)) active.add(match.name);\n\t\tfor (const name of selector.names ?? []) {\n\t\t\tif (!resources.some((resource) => resource.name === name && matchesCriteria(selector, resource))) {\n\t\t\t\twarnings.push(`optional ${kind} not available: ${name}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// exclude: applied last.\n\tconst excluded = new Set<string>();\n\tfor (const selector of gate.exclude ?? []) {\n\t\tfor (const match of matchSelector(selector, resources)) excluded.add(match.name);\n\t}\n\n\tconst result = [...active].filter((name) => !excluded.has(name));\n\treturn [...new Set(result)].sort(compareString);\n}\n\nfunction resolveRequireSelector(\n\tkind: ResourceKind,\n\tselector: ResourceSelector,\n\tresources: readonly NamedResource[],\n\tblockers: string[],\n\tactive: Set<string>,\n): void {\n\tif (selector.names && selector.names.length > 0) {\n\t\tfor (const name of selector.names) {\n\t\t\tconst matched = resources.some((resource) => resource.name === name && matchesCriteria(selector, resource));\n\t\t\tif (matched) active.add(name);\n\t\t\telse blockers.push(`missing required ${kind}: ${name}`);\n\t\t}\n\t\treturn;\n\t}\n\tconst matches = matchSelector(selector, resources);\n\tif (matches.length === 0) {\n\t\tblockers.push(`missing required ${kind}: ${describeSelector(selector)}`);\n\t\treturn;\n\t}\n\tfor (const match of matches) active.add(match.name);\n}\n\nfunction matchSelector(selector: ResourceSelector, resources: readonly NamedResource[]): NamedResource[] {\n\treturn resources.filter((resource) => {\n\t\tif (selector.names && !selector.names.includes(resource.name)) return false;\n\t\treturn matchesCriteria(selector, resource);\n\t});\n}\n\nfunction matchesCriteria(selector: ResourceSelector, resource: NamedResource): boolean {\n\tif (resource.kind !== selector.kind) return false;\n\tif (selector.scopes && (resource.scope === undefined || !selector.scopes.includes(resource.scope))) return false;\n\tif (selector.origins && (resource.origin === undefined || !selector.origins.includes(resource.origin))) return false;\n\tif (selector.sources && !selector.sources.some((glob) => globMatch(glob, resource.source ?? \"\"))) return false;\n\tif (selector.paths && !selector.paths.some((glob) => globMatch(glob, resource.path ?? \"\"))) return false;\n\treturn true;\n}\n\nfunction describeSelector(selector: ResourceSelector): string {\n\tconst parts: string[] = [`kind=${selector.kind}`];\n\tif (selector.paths) parts.push(`paths=${selector.paths.join(\",\")}`);\n\tif (selector.sources) parts.push(`sources=${selector.sources.join(\",\")}`);\n\tif (selector.scopes) parts.push(`scopes=${selector.scopes.join(\",\")}`);\n\tif (selector.origins) parts.push(`origins=${selector.origins.join(\",\")}`);\n\treturn parts.join(\" \");\n}\n\nfunction validateToolGate(gate: ToolGate | undefined, errors: string[]): void {\n\tif (!gate) {\n\t\terrors.push(\"missing tools gate\");\n\t\treturn;\n\t}\n\tif (gate.defaultMode !== undefined && !KNOWN_TOOL_DEFAULT_MODES.has(gate.defaultMode)) {\n\t\terrors.push(`unknown tool defaultMode: ${String(gate.defaultMode)}`);\n\t}\n}\n\nfunction validateCapabilityGate(\n\tgateName: string,\n\texpectedKind: ResourceKind,\n\tgate: CapabilityGate | undefined,\n\terrors: string[],\n): void {\n\tif (!gate) return;\n\tfor (const group of [\"allow\", \"exclude\", \"require\"] as const) {\n\t\tconst selectors = gate[group];\n\t\tif (!selectors) continue;\n\t\tfor (const selector of selectors) {\n\t\t\tif (!KNOWN_RESOURCE_KINDS.has(selector.kind)) {\n\t\t\t\terrors.push(`unknown resource kind in ${gateName}.${group}: ${String(selector.kind)}`);\n\t\t\t} else if (selector.kind !== expectedKind) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`mismatched selector kind in ${gateName}.${group}: expected ${expectedKind}, got ${selector.kind}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction commandModeAuthorityConflict(mode: CommandMode, authority: LoadoutAuthority): string | undefined {\n\tif (mode === \"scoped-shell\" && authority !== \"write-scoped\") {\n\t\treturn `command mode scoped-shell requires write-scoped authority, got ${authority}`;\n\t}\n\tif (mode === \"tests-only\" && authority !== \"execute-tests\" && authority !== \"write-scoped\") {\n\t\treturn `command mode tests-only requires execute-tests or write-scoped authority, got ${authority}`;\n\t}\n\treturn undefined;\n}\n\nfunction globMatch(glob: string, value: string): boolean {\n\treturn globToRegExp(glob).test(value);\n}\n\nfunction globToRegExp(glob: string): RegExp {\n\tlet pattern = \"\";\n\tfor (let index = 0; index < glob.length; index++) {\n\t\tconst char = glob[index];\n\t\tif (char === \"*\") {\n\t\t\tif (glob[index + 1] === \"*\") {\n\t\t\t\tpattern += \".*\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\tpattern += \"[^/]*\";\n\t\t\t}\n\t\t} else if (char === \"?\") {\n\t\t\tpattern += \".\";\n\t\t} else {\n\t\t\tpattern += char.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t}\n\t}\n\treturn new RegExp(`^${pattern}$`);\n}\n\nfunction compareString(a: string, b: string): number {\n\tif (a < b) return -1;\n\tif (a > b) return 1;\n\treturn 0;\n}\n"]}
|