@code-yeongyu/senpi 2026.7.17-5 → 2026.7.17
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 +0 -59
- package/dist/core/dynamic-prompt/build.d.ts +0 -7
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +0 -5
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +0 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +2 -20
- package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts +1 -8
- package/dist/core/extensions/builtin/mcp/config-schema.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config-schema.js +0 -23
- package/dist/core/extensions/builtin/mcp/config-schema.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.d.ts +0 -13
- package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/config.js +0 -36
- package/dist/core/extensions/builtin/mcp/config.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js +10 -10
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js +14 -14
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +5 -5
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.js +0 -1
- package/dist/core/extensions/builtin/mcp/service-snapshot.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +0 -12
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +2 -2
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +3 -4
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/status.js +0 -1
- package/dist/core/extensions/builtin/mcp/status.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +7 -5
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.js +3 -20
- package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
- package/dist/core/extensions/index.d.ts +0 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +4 -20
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +0 -20
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +0 -13
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +1 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/docs/extensions.md +0 -46
- package/docs/mcp.md +5 -21
- package/examples/AGENTS.md +0 -3
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +0 -48
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +19 -59
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +2 -69
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +0 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +4 -19
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +1 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -25
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +21 -31
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +9 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +27 -9
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +0 -31
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +0 -19
- package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +0 -3
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +1 -2
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +0 -11
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +1 -40
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +7 -92
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +1 -8
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +27 -129
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +6 -140
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +6 -28
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +18 -51
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +9 -70
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +2 -5
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +2 -13
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +2 -19
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
- package/dist/core/dynamic-prompt/workstation.d.ts +0 -35
- package/dist/core/dynamic-prompt/workstation.d.ts.map +0 -1
- package/dist/core/dynamic-prompt/workstation.js +0 -81
- package/dist/core/dynamic-prompt/workstation.js.map +0 -1
- package/docs/AGENTS.md +0 -70
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +0 -19
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +0 -215
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,64 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [2026.7.17-5] - 2026-07-17
|
|
4
|
-
|
|
5
|
-
### Breaking Changes
|
|
6
|
-
|
|
7
|
-
### Added
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
|
|
11
|
-
### Fixed
|
|
12
|
-
|
|
13
|
-
### Removed
|
|
14
|
-
|
|
15
|
-
## [2026.7.17-4] - 2026-07-17
|
|
16
|
-
|
|
17
|
-
### Breaking Changes
|
|
18
|
-
|
|
19
|
-
### Added
|
|
20
|
-
|
|
21
|
-
### Changed
|
|
22
|
-
|
|
23
|
-
### Fixed
|
|
24
|
-
|
|
25
|
-
- Fixed Kimi/Moonshot function parameters with root object unions by flattening them into a compatible object schema.
|
|
26
|
-
|
|
27
|
-
### Removed
|
|
28
|
-
|
|
29
|
-
## [2026.7.17-3] - 2026-07-17
|
|
30
|
-
|
|
31
|
-
### Breaking Changes
|
|
32
|
-
|
|
33
|
-
### Added
|
|
34
|
-
|
|
35
|
-
### Changed
|
|
36
|
-
|
|
37
|
-
- Renamed the MCP discovery tool from `mcp_search` to `tool_search` so its public name matches its behavior ([#227](https://github.com/code-yeongyu/senpi/pull/227)).
|
|
38
|
-
|
|
39
|
-
### Fixed
|
|
40
|
-
|
|
41
|
-
- Fixed payload hooks reintroducing Moonshot-incompatible function schemas by normalizing the final tool list after `onPayload` and immediately before request submission.
|
|
42
|
-
|
|
43
|
-
### Removed
|
|
44
|
-
|
|
45
|
-
## [2026.7.17-2] - 2026-07-17
|
|
46
|
-
|
|
47
|
-
### Breaking Changes
|
|
48
|
-
|
|
49
|
-
### Added
|
|
50
|
-
|
|
51
|
-
- Added a `<workstation>` block (OS/kernel, arch, CPU, GPU, terminal) to the dynamic system prompt, followed by a dialect-tuned execution-context instruction telling the model that `bash`/`eval` run on this workstation while written code may target other machines. Presets pass their model-family dialect (Claude/GLM, GPT, Kimi); the fallback prompt uses a maximum-emphasis default.
|
|
52
|
-
|
|
53
|
-
### Changed
|
|
54
|
-
|
|
55
|
-
### Fixed
|
|
56
|
-
|
|
57
|
-
- Fixed Kimi K3 prompt preset tuning to discourage overthinking and keep concise tool use ([#225](https://github.com/code-yeongyu/senpi/pull/225)).
|
|
58
|
-
- Fixed Moonshot-flavored OpenAI backends by normalizing tool parameters through a dedicated compatibility layer so function schemas and result images are accepted by Moonshot's API ([#225](https://github.com/code-yeongyu/senpi/pull/225)).
|
|
59
|
-
|
|
60
|
-
### Removed
|
|
61
|
-
|
|
62
3
|
## [2026.7.17] - 2026-07-17
|
|
63
4
|
|
|
64
5
|
### Breaking Changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Skill } from "../skills.ts";
|
|
2
2
|
import type { AvailableTool } from "./types.ts";
|
|
3
|
-
import { type WorkstationDialect } from "./workstation.ts";
|
|
4
3
|
/** Context handed to a `corePrompt` override so it can reuse the dynamic pieces. */
|
|
5
4
|
export interface DynamicPromptCoreContext {
|
|
6
5
|
tools: AvailableTool[];
|
|
@@ -24,12 +23,6 @@ export interface BuildDynamicSystemPromptOptions {
|
|
|
24
23
|
* date, and cwd assembly stay in this builder.
|
|
25
24
|
*/
|
|
26
25
|
corePrompt?: (context: DynamicPromptCoreContext) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Wording dialect for the workstation execution-context instruction.
|
|
29
|
-
* Presets pass their model family; the fallback prompt uses `default`
|
|
30
|
-
* (maximum emphasis).
|
|
31
|
-
*/
|
|
32
|
-
workstationDialect?: WorkstationDialect;
|
|
33
26
|
}
|
|
34
27
|
export declare function buildDynamicSystemPrompt(options: BuildDynamicSystemPromptOptions): string;
|
|
35
28
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAU1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAU1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,oFAAoF;AACpF,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,CAAC;CAC3D;AAmBD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAiDzF"}
|
|
@@ -8,7 +8,6 @@ import { buildStyleSection } from "./style.js";
|
|
|
8
8
|
import { categorizeTools } from "./tool-categorization.js";
|
|
9
9
|
import { buildToolSection } from "./tool-section.js";
|
|
10
10
|
import { buildVerificationSection } from "./verification.js";
|
|
11
|
-
import { buildWorkstationSection } from "./workstation.js";
|
|
12
11
|
function buildContextFilesSection(contextFiles) {
|
|
13
12
|
if (contextFiles.length === 0) {
|
|
14
13
|
return "";
|
|
@@ -64,10 +63,6 @@ export function buildDynamicSystemPrompt(options) {
|
|
|
64
63
|
if (skillsSection) {
|
|
65
64
|
sections.push(skillsSection);
|
|
66
65
|
}
|
|
67
|
-
sections.push("", buildWorkstationSection({
|
|
68
|
-
selectedTools: options.selectedTools,
|
|
69
|
-
dialect: options.workstationDialect ?? "default",
|
|
70
|
-
}));
|
|
71
66
|
sections.push("", `Current date: ${date}`, `Current working directory: ${promptCwd}`);
|
|
72
67
|
return sections.join("\n");
|
|
73
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/build.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAA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QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,IAAI,EAAE,EAAE,8BAA8B,SAAS,EAAE,CAAC,CAAC;IAEtF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import type { Skill } from \"../skills.ts\";\nimport { formatSkillsForPrompt } from \"../skills.ts\";\nimport { buildExplorationSection } from \"./exploration.ts\";\nimport { buildIdentitySection } from \"./identity.ts\";\nimport { buildIntentGate } from \"./intent-gate.ts\";\nimport { buildParallelToolsSection } from \"./parallel-tools.ts\";\nimport { buildPoliciesSection } from \"./policies.ts\";\nimport { buildStyleSection } from \"./style.ts\";\nimport { categorizeTools } from \"./tool-categorization.ts\";\nimport { buildToolSection } from \"./tool-section.ts\";\nimport type { AvailableTool } from \"./types.ts\";\nimport { buildVerificationSection } from \"./verification.ts\";\n\n/** Context handed to a `corePrompt` override so it can reuse the dynamic pieces. */\nexport interface DynamicPromptCoreContext {\n\ttools: AvailableTool[];\n\t/** Rendered \"## Available Tools\" (+ \"## Tool Guidelines\") section. */\n\ttoolSection: string;\n}\n\nexport interface BuildDynamicSystemPromptOptions {\n\tcwd: string;\n\tselectedTools: string[];\n\ttoolSnippets: Record<string, string>;\n\tpromptGuidelines: string[];\n\tcontextFiles: Array<{ path: string; content: string }>;\n\tskills: Skill[];\n\ttuningSection?: string;\n\t/**\n\t * Replaces the default core sections (identity through style) with a\n\t * model-specific full rewrite. Tool section, tuning, context files, skills,\n\t * date, and cwd assembly stay in this builder.\n\t */\n\tcorePrompt?: (context: DynamicPromptCoreContext) => string;\n}\n\nfunction buildContextFilesSection(contextFiles: Array<{ path: string; content: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\n\t\t\"## Project Context\",\n\t\t\"\",\n\t\t\"Project instruction files (below, and in [Directory Context: ...] blocks injected during reads) bind files under their directory; deeper files win on conflict; explicit user instructions override.\",\n\t\t\"\",\n\t];\n\tfor (const contextFile of contextFiles) {\n\t\tlines.push(`### ${contextFile.path}`, \"\", contextFile.content.trimEnd(), \"\");\n\t}\n\treturn lines.join(\"\\n\").trimEnd();\n}\n\nexport function buildDynamicSystemPrompt(options: BuildDynamicSystemPromptOptions): string {\n\tconst promptCwd = options.cwd.replace(/\\\\/g, \"/\");\n\tconst tools = categorizeTools(options.selectedTools);\n\tconst date = new Date().toISOString().slice(0, 10);\n\n\tconst toolSection = buildToolSection({\n\t\ttools,\n\t\ttoolSnippets: options.toolSnippets,\n\t\tpromptGuidelines: options.promptGuidelines,\n\t});\n\n\tconst sections = options.corePrompt\n\t\t? [options.corePrompt({ tools, toolSection })]\n\t\t: [\n\t\t\t\tbuildIdentitySection(),\n\t\t\t\t\"\",\n\t\t\t\tbuildIntentGate({ tools }),\n\t\t\t\t\"\",\n\t\t\t\tbuildParallelToolsSection(),\n\t\t\t\t\"\",\n\t\t\t\tbuildExplorationSection(),\n\t\t\t\t\"\",\n\t\t\t\tbuildVerificationSection(),\n\t\t\t\t\"\",\n\t\t\t\ttoolSection,\n\t\t\t\t\"\",\n\t\t\t\tbuildPoliciesSection(),\n\t\t\t\t\"\",\n\t\t\t\tbuildStyleSection(),\n\t\t\t];\n\n\tconst tuning = options.tuningSection?.trim();\n\tif (tuning) {\n\t\tsections.push(\"\", tuning);\n\t}\n\n\tconst contextFilesSection = buildContextFilesSection(options.contextFiles);\n\tif (contextFilesSection) {\n\t\tsections.push(\"\", contextFilesSection);\n\t}\n\n\tconst skillsSection = formatSkillsForPrompt(options.skills);\n\tif (skillsSection) {\n\t\tsections.push(skillsSection);\n\t}\n\n\tsections.push(\"\", `Current date: ${date}`, `Current working directory: ${promptCwd}`);\n\n\treturn sections.join(\"\\n\");\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Message } from "@earendil-works/pi-ai";
|
|
2
2
|
export declare const TOOL_RESULT_PLACEHOLDER = "Tool output unavailable (context compacted)";
|
|
3
|
-
/** Repairs orphaned tool results and dangling tool calls. */
|
|
4
3
|
export declare function repairOrphanedToolResults(messages: Message[]): Message[];
|
|
5
4
|
//# sourceMappingURL=repair-tool-pairs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-tool-pairs.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,uBAAuB,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"repair-tool-pairs.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,uBAAuB,gDAAgD,CAAC;AAErF,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CA8CxE"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
export const TOOL_RESULT_PLACEHOLDER = "Tool output unavailable (context compacted)";
|
|
2
|
-
/**
|
|
3
|
-
* Retry diagnostic for a dangling tool call flagged `incomplete` by the text
|
|
4
|
-
* tool-call middleware (truncated and unrecoverable at stream end). Tells the
|
|
5
|
-
* model the call never ran and should be re-issued with complete arguments.
|
|
6
|
-
* Duplicated verbatim in the sibling pair-repair copy — the two packages
|
|
7
|
-
* intentionally do not share this constant (no new cross-package dependency).
|
|
8
|
-
*/
|
|
9
|
-
function incompleteToolCallRetryText(name, errorMessage) {
|
|
10
|
-
if (errorMessage !== undefined) {
|
|
11
|
-
return `${errorMessage}${errorMessage.endsWith(".") ? "" : "."} Re-issue the tool call with complete arguments.`;
|
|
12
|
-
}
|
|
13
|
-
return `Tool call "${name}" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`;
|
|
14
|
-
}
|
|
15
|
-
/** Repairs orphaned tool results and dangling tool calls. */
|
|
16
2
|
export function repairOrphanedToolResults(messages) {
|
|
17
3
|
const toolCallIds = new Set();
|
|
18
4
|
const toolResultIds = new Set();
|
|
@@ -45,16 +31,12 @@ export function repairOrphanedToolResults(messages) {
|
|
|
45
31
|
for (const block of message.content) {
|
|
46
32
|
if (block.type !== "toolCall" || !dangling.has(block.id))
|
|
47
33
|
continue;
|
|
48
|
-
const incomplete = block.incomplete === true;
|
|
49
|
-
const text = incomplete
|
|
50
|
-
? incompleteToolCallRetryText(block.name, block.errorMessage)
|
|
51
|
-
: TOOL_RESULT_PLACEHOLDER;
|
|
52
34
|
output.push({
|
|
53
35
|
role: "toolResult",
|
|
54
36
|
toolCallId: block.id,
|
|
55
37
|
toolName: block.name,
|
|
56
|
-
content: [{ type: "text", text }],
|
|
57
|
-
isError:
|
|
38
|
+
content: [{ type: "text", text: TOOL_RESULT_PLACEHOLDER }],
|
|
39
|
+
isError: false,
|
|
58
40
|
timestamp: message.timestamp ? message.timestamp + 1 : Date.now(),
|
|
59
41
|
});
|
|
60
42
|
dangling.delete(block.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repair-tool-pairs.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,6CAA6C,CAAC;AAErF
|
|
1
|
+
{"version":3,"file":"repair-tool-pairs.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/repair-tool-pairs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAAG,6CAA6C,CAAC;AAErF,MAAM,UAAU,yBAAyB,CAAC,QAAmB;IAC5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,C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AK,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;oBAAE,SAAS;gBACnE,MAAM,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,YAAY;oBAClB,UAAU,EAAE,KAAK,CAAC,EAAE;oBACpB,QAAQ,EAAE,KAAK,CAAC,IAAI;oBACpB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;oBAC1D,OAAO,EAAE,KAAK;oBACd,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;iBACjE,CAAC,CAAC;gBACH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { Message, TextContent } from \"@earendil-works/pi-ai\";\n\nexport const TOOL_RESULT_PLACEHOLDER = \"Tool output unavailable (context compacted)\";\n\nexport function repairOrphanedToolResults(messages: Message[]): Message[] {\n\tconst toolCallIds = new Set<string>();\n\tconst toolResultIds = new Set<string>();\n\tfor (const message of messages) {\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type === \"toolCall\") toolCallIds.add(block.id);\n\t\t\t}\n\t\t}\n\t\tif (message.role === \"toolResult\") toolResultIds.add(message.toolCallId);\n\t}\n\n\tconst output: Message[] = [];\n\tconst dangling = new Set([...toolCallIds].filter((id) => !toolResultIds.has(id)));\n\n\tfor (const message of messages) {\n\t\tif (message.role === \"toolResult\") {\n\t\t\tif (!toolCallIds.has(message.toolCallId)) {\n\t\t\t\toutput.push({\n\t\t\t\t\t...message,\n\t\t\t\t\tcontent: [{ type: \"text\", text: TOOL_RESULT_PLACEHOLDER }] satisfies TextContent[],\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\toutput.push(message);\n\t\t\tcontinue;\n\t\t}\n\n\t\toutput.push(message);\n\t\tif (message.role === \"assistant\") {\n\t\t\tfor (const block of message.content) {\n\t\t\t\tif (block.type !== \"toolCall\" || !dangling.has(block.id)) continue;\n\t\t\t\toutput.push({\n\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\ttoolCallId: block.id,\n\t\t\t\t\ttoolName: block.name,\n\t\t\t\t\tcontent: [{ type: \"text\", text: TOOL_RESULT_PLACEHOLDER }],\n\t\t\t\t\tisError: false,\n\t\t\t\t\ttimestamp: message.timestamp ? message.timestamp + 1 : Date.now(),\n\t\t\t\t});\n\t\t\t\tdangling.delete(block.id);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn output;\n}\n"]}
|
|
@@ -96,10 +96,8 @@ export type McpServerConfig = Static<typeof ServerSchema> & {
|
|
|
96
96
|
exposure: "auto" | "direct" | "search" | "proxy";
|
|
97
97
|
logLevel: Static<typeof LogLevelSchema>;
|
|
98
98
|
};
|
|
99
|
-
/** Public raw type for extension-declared MCP servers. */
|
|
100
|
-
export type McpServerDeclaration = Static<typeof ServerSchema>;
|
|
101
99
|
export type McpSettings = Required<Pick<Static<typeof SettingsSchema>, "toolPrefix">> & Omit<Static<typeof SettingsSchema>, "toolPrefix">;
|
|
102
|
-
export type McpServerSource = "global" | "claude" | "project" | "skill"
|
|
100
|
+
export type McpServerSource = "global" | "claude" | "project" | "skill";
|
|
103
101
|
export type McpServerState = "enabled" | "disabled" | "untrusted";
|
|
104
102
|
export interface ResolvedMcpServer {
|
|
105
103
|
name: string;
|
|
@@ -249,11 +247,6 @@ export declare const validateConfig: import("typebox/compile").Validator<{}, Typ
|
|
|
249
247
|
logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning" | undefined;
|
|
250
248
|
}> | undefined;
|
|
251
249
|
}>;
|
|
252
|
-
/**
|
|
253
|
-
* Validate a single extension-declared MCP server.
|
|
254
|
-
* Returns a descriptive error string, or null when valid.
|
|
255
|
-
*/
|
|
256
|
-
export declare function validateMcpServerDeclaration(name: string, raw: unknown): string | null;
|
|
257
250
|
export declare const defaultSettings: McpSettings;
|
|
258
251
|
export {};
|
|
259
252
|
//# sourceMappingURL=config-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,cAAc,wNASzB,CAAC;AAaH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BxB,CAAC;AAEF,QAAA,MAAM,cAAc;;;;;;;;;;;;EAoBnB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMxB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,GAAG;IAC3D,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACjD,QAAQ,EAAE,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;CACxC,CAAC;AACF,
|
|
1
|
+
{"version":3,"file":"config-schema.d.ts","sourceRoot":"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AM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC3C,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAYtF;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwB,CAAC;AACpD,eAAO,MAAM,eAAe,EAAE,WAI7B,CAAC"}
|
|
@@ -71,29 +71,6 @@ export function getServerEndpointValidationError(config) {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
export const validateConfig = Compile(ConfigSchema);
|
|
74
|
-
const validateServer = Compile(ServerSchema);
|
|
75
|
-
/**
|
|
76
|
-
* Validate a single extension-declared MCP server.
|
|
77
|
-
* Returns a descriptive error string, or null when valid.
|
|
78
|
-
*/
|
|
79
|
-
export function validateMcpServerDeclaration(name, raw) {
|
|
80
|
-
if (!validateServer.Check(raw)) {
|
|
81
|
-
const error = Array.from(validateServer.Errors(raw))[0];
|
|
82
|
-
const path = error.instancePath
|
|
83
|
-
.replace(/^\//, "")
|
|
84
|
-
.split("/")
|
|
85
|
-
.map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~"))
|
|
86
|
-
.join(".") || "$";
|
|
87
|
-
const message = error.message === "must be array" ? "Expected array" : error.message;
|
|
88
|
-
return `Invalid MCP server declaration "${name}": ${path}: ${message}`;
|
|
89
|
-
}
|
|
90
|
-
const server = raw;
|
|
91
|
-
const endpointError = getServerEndpointValidationError({ mcpServers: { [name]: server } });
|
|
92
|
-
if (endpointError) {
|
|
93
|
-
return `Invalid MCP server declaration "${name}": ${endpointError}`;
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
74
|
export const defaultSettings = {
|
|
98
75
|
outputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },
|
|
99
76
|
searchThreshold: 10,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACxB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,WAAW,CAA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aAAa,GAAG,gCAAgC,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3F,IAAI,aAAa,EAAE,CAAC;QACnB,OAAO,mCAAmC,IAAI,MAAM,aAAa,EAAE,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC3C,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpD,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const LogLevelSchema = Type.Union([\n\tType.Literal(\"debug\"),\n\tType.Literal(\"info\"),\n\tType.Literal(\"notice\"),\n\tType.Literal(\"warning\"),\n\tType.Literal(\"error\"),\n\tType.Literal(\"critical\"),\n\tType.Literal(\"alert\"),\n\tType.Literal(\"emergency\"),\n]);\n\nconst OAuthSchema = Type.Object(\n\t{\n\t\tclientId: Type.Optional(Type.String()),\n\t\tcallbackPort: Type.Optional(Type.Integer({ minimum: 0, maximum: 65_535 })),\n\t\tscopes: Type.Optional(Type.Array(Type.String())),\n\t\tclientMetadataUrl: Type.Optional(Type.String()),\n\t\tflow: Type.Optional(Type.Union([Type.Literal(\"code\"), Type.Literal(\"client_credentials\")])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ServerSchema = Type.Object(\n\t{\n\t\ttype: Type.Optional(Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\")])),\n\t\turl: Type.Optional(Type.String()),\n\t\tcommand: Type.Optional(Type.String()),\n\t\targs: Type.Optional(Type.Array(Type.String())),\n\t\tenv: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tcwd: Type.Optional(Type.String()),\n\t\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tauth: Type.Optional(Type.Union([Type.Literal(\"bearer\"), Type.Literal(\"oauth\"), Type.Literal(false)])),\n\t\tbearerTokenEnv: Type.Optional(Type.String()),\n\t\toauth: Type.Optional(OAuthSchema),\n\t\tenabled: Type.Optional(Type.Boolean()),\n\t\tlifecycle: Type.Optional(Type.Union([Type.Literal(\"lazy\"), Type.Literal(\"eager\"), Type.Literal(\"keep-alive\")])),\n\t\tidleTimeoutMin: Type.Optional(Type.Number()),\n\t\trequestTimeoutMs: Type.Optional(Type.Number()),\n\t\tconnectTimeoutMs: Type.Optional(Type.Number()),\n\t\tincludeTools: Type.Optional(Type.Array(Type.String())),\n\t\texcludeTools: Type.Optional(Type.Array(Type.String())),\n\t\tdirectTools: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String())])),\n\t\texposure: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"auto\"), Type.Literal(\"direct\"), Type.Literal(\"search\"), Type.Literal(\"proxy\")]),\n\t\t),\n\t\tlogLevel: Type.Optional(LogLevelSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst SettingsSchema = Type.Object(\n\t{\n\t\ttoolPrefix: Type.Optional(Type.String()),\n\t\tsearchThreshold: Type.Optional(Type.Number()),\n\t\toutputGuard: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmaxBytes: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxLines: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxTokens: Type.Optional(Type.Number()),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\timportConfigs: Type.Optional(Type.Array(Type.Literal(\"claude\"))),\n\t\toauthCallbackUrl: Type.Optional(Type.String()),\n\t\tstubSwap: Type.Optional(Type.Boolean()),\n\t\tnativeToolSearch: Type.Optional(Type.Union([Type.Literal(\"auto\"), Type.Boolean()])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ConfigSchema = Type.Object(\n\t{\n\t\tsettings: Type.Optional(SettingsSchema),\n\t\tmcpServers: Type.Optional(Type.Record(Type.String(), ServerSchema)),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type RawConfig = Static<typeof ConfigSchema>;\nexport type McpServerConfig = Static<typeof ServerSchema> & {\n\ttype: \"stdio\" | \"http\";\n\targs: string[];\n\tenabled: boolean;\n\tlifecycle: \"lazy\" | \"eager\" | \"keep-alive\";\n\tconnectTimeoutMs: number;\n\trequestTimeoutMs: number;\n\tidleTimeoutMin: number;\n\texposure: \"auto\" | \"direct\" | \"search\" | \"proxy\";\n\tlogLevel: Static<typeof LogLevelSchema>;\n};\n/** Public raw type for extension-declared MCP servers. */\nexport type McpServerDeclaration = Static<typeof ServerSchema>;\nexport type McpSettings = Required<Pick<Static<typeof SettingsSchema>, \"toolPrefix\">> &\n\tOmit<Static<typeof SettingsSchema>, \"toolPrefix\">;\nexport type McpServerSource = \"global\" | \"claude\" | \"project\" | \"skill\" | \"extension\";\nexport type McpServerState = \"enabled\" | \"disabled\" | \"untrusted\";\n\nexport interface ResolvedMcpServer {\n\tname: string;\n\tsource: McpServerSource;\n\tsourcePath: string;\n\tstate: McpServerState;\n\ttransport?: \"stdio\" | \"http\";\n\tconfigHash?: string;\n\tconfig?: McpServerConfig;\n}\n\nexport interface ResolvedMcpConfig {\n\tsettings: McpSettings;\n\tservers: Record<string, ResolvedMcpServer>;\n\tdiagnostics: string[];\n}\n\nexport interface LoadMcpConfigOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tenv?: Record<string, string | undefined>;\n\tprojectTrusted: boolean;\n}\n\nexport function getServerEndpointValidationError(config: RawConfig): string | undefined {\n\tfor (const [name, server] of Object.entries(config.mcpServers ?? {})) {\n\t\tif (server.enabled === false) continue;\n\t\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\t\tif (type === \"stdio\" && (server.command === undefined || server.command.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.command: Required for enabled stdio server`;\n\t\t}\n\t\tif (type === \"http\" && (server.url === undefined || server.url.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.url: Required for enabled http server`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport const validateConfig = Compile(ConfigSchema);\nconst validateServer = Compile(ServerSchema);\n\n/**\n * Validate a single extension-declared MCP server.\n * Returns a descriptive error string, or null when valid.\n */\nexport function validateMcpServerDeclaration(name: string, raw: unknown): string | null {\n\tif (!validateServer.Check(raw)) {\n\t\tconst error = Array.from(validateServer.Errors(raw))[0];\n\t\tconst path =\n\t\t\terror.instancePath\n\t\t\t\t.replace(/^\\//, \"\")\n\t\t\t\t.split(\"/\")\n\t\t\t\t.map((p) => p.replace(/~1/g, \"/\").replace(/~0/g, \"~\"))\n\t\t\t\t.join(\".\") || \"$\";\n\t\tconst message = error.message === \"must be array\" ? \"Expected array\" : error.message;\n\t\treturn `Invalid MCP server declaration \"${name}\": ${path}: ${message}`;\n\t}\n\tconst server = raw as McpServerDeclaration;\n\tconst endpointError = getServerEndpointValidationError({ mcpServers: { [name]: server } });\n\tif (endpointError) {\n\t\treturn `Invalid MCP server declaration \"${name}\": ${endpointError}`;\n\t}\n\treturn null;\n}\n\nexport const defaultSettings: McpSettings = {\n\toutputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },\n\tsearchThreshold: 10,\n\ttoolPrefix: \"mcp\",\n};\n"]}
|
|
1
|
+
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC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,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YAC9F,OAAO,cAAc,IAAI,6CAA6C,CAAC;QACxE,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YACrF,OAAO,cAAc,IAAI,wCAAwC,CAAC;QACnE,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC3C,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACpD,eAAe,EAAE,EAAE;IACnB,UAAU,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nexport const LogLevelSchema = Type.Union([\n\tType.Literal(\"debug\"),\n\tType.Literal(\"info\"),\n\tType.Literal(\"notice\"),\n\tType.Literal(\"warning\"),\n\tType.Literal(\"error\"),\n\tType.Literal(\"critical\"),\n\tType.Literal(\"alert\"),\n\tType.Literal(\"emergency\"),\n]);\n\nconst OAuthSchema = Type.Object(\n\t{\n\t\tclientId: Type.Optional(Type.String()),\n\t\tcallbackPort: Type.Optional(Type.Integer({ minimum: 0, maximum: 65_535 })),\n\t\tscopes: Type.Optional(Type.Array(Type.String())),\n\t\tclientMetadataUrl: Type.Optional(Type.String()),\n\t\tflow: Type.Optional(Type.Union([Type.Literal(\"code\"), Type.Literal(\"client_credentials\")])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ServerSchema = Type.Object(\n\t{\n\t\ttype: Type.Optional(Type.Union([Type.Literal(\"stdio\"), Type.Literal(\"http\")])),\n\t\turl: Type.Optional(Type.String()),\n\t\tcommand: Type.Optional(Type.String()),\n\t\targs: Type.Optional(Type.Array(Type.String())),\n\t\tenv: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tcwd: Type.Optional(Type.String()),\n\t\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\t\tauth: Type.Optional(Type.Union([Type.Literal(\"bearer\"), Type.Literal(\"oauth\"), Type.Literal(false)])),\n\t\tbearerTokenEnv: Type.Optional(Type.String()),\n\t\toauth: Type.Optional(OAuthSchema),\n\t\tenabled: Type.Optional(Type.Boolean()),\n\t\tlifecycle: Type.Optional(Type.Union([Type.Literal(\"lazy\"), Type.Literal(\"eager\"), Type.Literal(\"keep-alive\")])),\n\t\tidleTimeoutMin: Type.Optional(Type.Number()),\n\t\trequestTimeoutMs: Type.Optional(Type.Number()),\n\t\tconnectTimeoutMs: Type.Optional(Type.Number()),\n\t\tincludeTools: Type.Optional(Type.Array(Type.String())),\n\t\texcludeTools: Type.Optional(Type.Array(Type.String())),\n\t\tdirectTools: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String())])),\n\t\texposure: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"auto\"), Type.Literal(\"direct\"), Type.Literal(\"search\"), Type.Literal(\"proxy\")]),\n\t\t),\n\t\tlogLevel: Type.Optional(LogLevelSchema),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst SettingsSchema = Type.Object(\n\t{\n\t\ttoolPrefix: Type.Optional(Type.String()),\n\t\tsearchThreshold: Type.Optional(Type.Number()),\n\t\toutputGuard: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmaxBytes: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxLines: Type.Optional(Type.Number()),\n\t\t\t\t\tmaxTokens: Type.Optional(Type.Number()),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\timportConfigs: Type.Optional(Type.Array(Type.Literal(\"claude\"))),\n\t\toauthCallbackUrl: Type.Optional(Type.String()),\n\t\tstubSwap: Type.Optional(Type.Boolean()),\n\t\tnativeToolSearch: Type.Optional(Type.Union([Type.Literal(\"auto\"), Type.Boolean()])),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const ConfigSchema = Type.Object(\n\t{\n\t\tsettings: Type.Optional(SettingsSchema),\n\t\tmcpServers: Type.Optional(Type.Record(Type.String(), ServerSchema)),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type RawConfig = Static<typeof ConfigSchema>;\nexport type McpServerConfig = Static<typeof ServerSchema> & {\n\ttype: \"stdio\" | \"http\";\n\targs: string[];\n\tenabled: boolean;\n\tlifecycle: \"lazy\" | \"eager\" | \"keep-alive\";\n\tconnectTimeoutMs: number;\n\trequestTimeoutMs: number;\n\tidleTimeoutMin: number;\n\texposure: \"auto\" | \"direct\" | \"search\" | \"proxy\";\n\tlogLevel: Static<typeof LogLevelSchema>;\n};\nexport type McpSettings = Required<Pick<Static<typeof SettingsSchema>, \"toolPrefix\">> &\n\tOmit<Static<typeof SettingsSchema>, \"toolPrefix\">;\nexport type McpServerSource = \"global\" | \"claude\" | \"project\" | \"skill\";\nexport type McpServerState = \"enabled\" | \"disabled\" | \"untrusted\";\n\nexport interface ResolvedMcpServer {\n\tname: string;\n\tsource: McpServerSource;\n\tsourcePath: string;\n\tstate: McpServerState;\n\ttransport?: \"stdio\" | \"http\";\n\tconfigHash?: string;\n\tconfig?: McpServerConfig;\n}\n\nexport interface ResolvedMcpConfig {\n\tsettings: McpSettings;\n\tservers: Record<string, ResolvedMcpServer>;\n\tdiagnostics: string[];\n}\n\nexport interface LoadMcpConfigOptions {\n\tcwd: string;\n\tagentDir?: string;\n\tenv?: Record<string, string | undefined>;\n\tprojectTrusted: boolean;\n}\n\nexport function getServerEndpointValidationError(config: RawConfig): string | undefined {\n\tfor (const [name, server] of Object.entries(config.mcpServers ?? {})) {\n\t\tif (server.enabled === false) continue;\n\t\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\t\tif (type === \"stdio\" && (server.command === undefined || server.command.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.command: Required for enabled stdio server`;\n\t\t}\n\t\tif (type === \"http\" && (server.url === undefined || server.url.trim().length === 0)) {\n\t\t\treturn `mcpServers.${name}.url: Required for enabled http server`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport const validateConfig = Compile(ConfigSchema);\nexport const defaultSettings: McpSettings = {\n\toutputGuard: { maxBytes: 50 * 1024, maxLines: 2000 },\n\tsearchThreshold: 10,\n\ttoolPrefix: \"mcp\",\n};\n"]}
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import type { RegisteredMcpServerDeclaration } from "../../types.ts";
|
|
2
1
|
import { type LoadMcpConfigOptions, type RawConfig, type ResolvedMcpConfig, type ResolvedMcpServer } from "./config-schema.ts";
|
|
3
2
|
export declare class McpConfigValidationError extends Error {
|
|
4
3
|
constructor(message: string);
|
|
5
4
|
}
|
|
6
5
|
export declare function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig;
|
|
7
6
|
export declare function visitSpawnableMcpServers(config: ResolvedMcpConfig, visit: (name: string, server: ResolvedMcpServer) => void): void;
|
|
8
|
-
/**
|
|
9
|
-
* Resolve an extension-declared MCP server. Preserves the declared exposure,
|
|
10
|
-
* directTools, filters, lifecycle, and enabled state. A stdio declaration
|
|
11
|
-
* without an explicit `cwd` defaults to the extension's registration cwd.
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveExtensionMcpServer(name: string, raw: NonNullable<RawConfig["mcpServers"]>[string], sourcePath: string, registrationCwd: string): ResolvedMcpServer;
|
|
14
|
-
/**
|
|
15
|
-
* Merge extension-declared MCP servers into a resolved config. Trusted file
|
|
16
|
-
* sources (global/claude/project) win, including disabled entries. An
|
|
17
|
-
* extension entry replaces an untrusted placeholder and records a diagnostic.
|
|
18
|
-
*/
|
|
19
|
-
export declare function mergeExtensionMcpServers(result: ResolvedMcpConfig, declarations: readonly RegisteredMcpServerDeclaration[]): void;
|
|
20
7
|
/**
|
|
21
8
|
* Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md
|
|
22
9
|
* frontmatter). Exposure is forced to search with no directTools so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAGN,KAAK,oBAAoB,EAIzB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEtB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CAqD9E;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,IAAI,GACtD,IAAI,CAMN;AA6GD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,EACjD,UAAU,EAAE,MAAM,GAChB,iBAAiB,CAWnB"}
|
|
@@ -151,42 +151,6 @@ function readServerNames(raw) {
|
|
|
151
151
|
return [];
|
|
152
152
|
return Object.keys(servers);
|
|
153
153
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Resolve an extension-declared MCP server. Preserves the declared exposure,
|
|
156
|
-
* directTools, filters, lifecycle, and enabled state. A stdio declaration
|
|
157
|
-
* without an explicit `cwd` defaults to the extension's registration cwd.
|
|
158
|
-
*/
|
|
159
|
-
export function resolveExtensionMcpServer(name, raw, sourcePath, registrationCwd) {
|
|
160
|
-
const withCwd = { ...raw, cwd: raw.cwd ?? registrationCwd };
|
|
161
|
-
const config = normalizeServer(withCwd);
|
|
162
|
-
return {
|
|
163
|
-
config,
|
|
164
|
-
configHash: hashConfig(config),
|
|
165
|
-
name,
|
|
166
|
-
source: "extension",
|
|
167
|
-
sourcePath,
|
|
168
|
-
state: config.enabled ? "enabled" : "disabled",
|
|
169
|
-
transport: config.type,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Merge extension-declared MCP servers into a resolved config. Trusted file
|
|
174
|
-
* sources (global/claude/project) win, including disabled entries. An
|
|
175
|
-
* extension entry replaces an untrusted placeholder and records a diagnostic.
|
|
176
|
-
*/
|
|
177
|
-
export function mergeExtensionMcpServers(result, declarations) {
|
|
178
|
-
for (const decl of declarations) {
|
|
179
|
-
const existing = result.servers[decl.name];
|
|
180
|
-
if (existing !== undefined && existing.state !== "untrusted") {
|
|
181
|
-
result.diagnostics.push(`Extension MCP server '${decl.name}' from ${decl.extensionPath} skipped; ${existing.source} config at ${existing.sourcePath} wins.`);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (existing !== undefined) {
|
|
185
|
-
result.diagnostics.push(`Extension MCP server '${decl.name}' from ${decl.extensionPath} replaces untrusted ${existing.source} placeholder from ${existing.sourcePath}.`);
|
|
186
|
-
}
|
|
187
|
-
result.servers[decl.name] = resolveExtensionMcpServer(decl.name, decl.config, decl.extensionPath, decl.registrationCwd);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
154
|
/**
|
|
191
155
|
* Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md
|
|
192
156
|
* frontmatter). Exposure is forced to search with no directTools so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EACN,eAAe,EACf,gCAAgC,EAQhC,cAAc,GACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACxC,CAAC;CACD;AAOD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAyC,CAAC;AAErE,MAAM,UAAU,aAAa,CAAC,OAA6B;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,WAAW,EAAE,CAAC;IACnD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;IACnE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,WAA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C,GAAG,CAAC,GAAG,CAAC;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAC3B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,eAAe,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAClG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../../../config.ts\";\nimport type { RegisteredMcpServerDeclaration } from \"../../types.ts\";\nimport {\n\tdefaultSettings,\n\tgetServerEndpointValidationError,\n\ttype LoadMcpConfigOptions,\n\ttype McpServerConfig,\n\ttype McpServerSource,\n\ttype McpSettings,\n\ttype RawConfig,\n\ttype ResolvedMcpConfig,\n\ttype ResolvedMcpServer,\n\tvalidateConfig,\n} from \"./config-schema.ts\";\n\nexport class McpConfigValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"McpConfigValidationError\";\n\t}\n}\n\ninterface JsonReadResult {\n\traw: unknown;\n\tdiagnostic?: string;\n}\n\nconst trustedEnv = process.env as Record<string, string | undefined>;\n\nexport function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst env = options.env ?? trustedEnv;\n\tconst globalPath = join(agentDir, \"mcp.json\");\n\tconst projectPath = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tconst claudePath = join(options.cwd, \".mcp.json\");\n\tconst globalConfig = readTrustedConfig(globalPath, env);\n\tconst projectRead = readConfigJson(projectPath, options.projectTrusted);\n\tconst projectRaw = projectRead.raw;\n\tconst preliminary = mergeConfigs(\n\t\tglobalConfig,\n\t\toptions.projectTrusted ? validateRaw(projectRaw, projectPath) : undefined,\n\t);\n\tconst shouldImportClaude = preliminary.settings?.importConfigs?.includes(\"claude\") === true;\n\tconst claudeRead = shouldImportClaude ? readConfigJson(claudePath, options.projectTrusted) : { raw: undefined };\n\tconst claudeRaw = claudeRead.raw;\n\tconst sources = [\n\t\t{ config: globalConfig, path: globalPath, source: \"global\" as const, trusted: true },\n\t\t{\n\t\t\tconfig:\n\t\t\t\toptions.projectTrusted && shouldImportClaude ? readTrustedConfig(claudePath, env, claudeRaw) : undefined,\n\t\t\tpath: claudePath,\n\t\t\tsource: \"claude\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t\t{\n\t\t\tconfig: options.projectTrusted ? readTrustedConfig(projectPath, env, projectRaw) : undefined,\n\t\t\tpath: projectPath,\n\t\t\tsource: \"project\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t];\n\tconst merged = mergeConfigs(...sources.map((item) => item.config));\n\tconst result: ResolvedMcpConfig = { diagnostics: [], servers: {}, settings: normalizeSettings(merged.settings) };\n\tfor (const diagnostic of [projectRead.diagnostic, claudeRead.diagnostic]) {\n\t\tif (diagnostic) result.diagnostics.push(diagnostic);\n\t}\n\n\tfor (const item of sources) {\n\t\tif (item.trusted && item.config?.mcpServers) {\n\t\t\taddTrustedServers(result, item.config.mcpServers, item.source, item.path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item.trusted) {\n\t\t\taddUntrustedServers(\n\t\t\t\tresult,\n\t\t\t\treadServerNames(item.source === \"claude\" ? claudeRaw : projectRaw),\n\t\t\t\titem.source,\n\t\t\t\titem.path,\n\t\t\t);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport function visitSpawnableMcpServers(\n\tconfig: ResolvedMcpConfig,\n\tvisit: (name: string, server: ResolvedMcpServer) => void,\n): void {\n\tfor (const [name, server] of Object.entries(config.servers)) {\n\t\tif (server.state === \"enabled\") {\n\t\t\tvisit(name, server);\n\t\t}\n\t}\n}\n\nfunction readTrustedConfig(\n\tpath: string,\n\tenv: Record<string, string | undefined>,\n\traw = readConfigJson(path, true).raw,\n): RawConfig | undefined {\n\tconst config = interpolateConfig(validateRaw(raw, path), env);\n\tconst endpointError = config ? getServerEndpointValidationError(config) : undefined;\n\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\treturn config;\n}\n\nfunction readConfigJson(path: string, trusted: boolean): JsonReadResult {\n\tif (!existsSync(path)) return { raw: undefined };\n\ttry {\n\t\tconst raw: unknown = JSON.parse(readFileSync(path, \"utf-8\"));\n\t\treturn { raw };\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (trusted) throw new McpConfigValidationError(`Invalid MCP config at ${path}: ${reason}`);\n\t\treturn { raw: undefined, diagnostic: `Blocked untrusted MCP config at ${path}: invalid JSON (${reason})` };\n\t}\n}\n\nfunction validateRaw(raw: unknown, _path: string): RawConfig | undefined {\n\tif (raw === undefined) return undefined;\n\tif (validateConfig.Check(raw)) {\n\t\tconst config = raw as RawConfig;\n\t\tconst endpointError = getServerEndpointValidationError(config);\n\t\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\t\treturn config;\n\t}\n\tconst error = Array.from(validateConfig.Errors(raw))[0];\n\tthrow new McpConfigValidationError(`Invalid MCP config at ${formatErrorPath(error)}: ${formatErrorMessage(error)}`);\n}\n\nfunction formatErrorPath(error: TLocalizedValidationError): string {\n\tconst trimmed = error.instancePath.replace(/^\\//, \"\");\n\treturn trimmed.length === 0 ? \"$\" : trimmed.split(\"/\").map(decodePathPart).join(\".\");\n}\n\nfunction decodePathPart(part: string): string {\n\treturn part.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nfunction formatErrorMessage(error: TLocalizedValidationError): string {\n\treturn error.message === \"must be array\" ? \"Expected array\" : error.message;\n}\n\nfunction mergeConfigs(...configs: (RawConfig | undefined)[]): RawConfig {\n\tconst merged: RawConfig = {};\n\tfor (const config of configs) {\n\t\tif (!config) continue;\n\t\tmerged.settings = { ...(merged.settings ?? {}), ...(config.settings ?? {}) };\n\t\tmerged.mcpServers = { ...(merged.mcpServers ?? {}), ...(config.mcpServers ?? {}) };\n\t}\n\treturn merged;\n}\n\nfunction normalizeSettings(settings: RawConfig[\"settings\"]): McpSettings {\n\treturn { ...defaultSettings, ...settings };\n}\n\nfunction addTrustedServers(\n\tresult: ResolvedMcpConfig,\n\tservers: NonNullable<RawConfig[\"mcpServers\"]>,\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const [name, server] of Object.entries(servers)) {\n\t\tconst config = normalizeServer(server);\n\t\tresult.servers[name] = {\n\t\t\tconfig,\n\t\t\tconfigHash: hashConfig(config),\n\t\t\tname,\n\t\t\tsource,\n\t\t\tsourcePath,\n\t\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\t\ttransport: config.type,\n\t\t};\n\t}\n}\n\nfunction addUntrustedServers(\n\tresult: ResolvedMcpConfig,\n\tnames: readonly string[],\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const name of names) {\n\t\tconst existing = result.servers[name];\n\t\tif (existing && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Blocked untrusted ${source} MCP server '${name}' from shadowing trusted ${existing.source} server.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tresult.servers[name] = { name, source, sourcePath, state: \"untrusted\" };\n\t}\n}\n\nfunction readServerNames(raw: unknown): string[] {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return [];\n\tconst servers = (raw as { mcpServers?: unknown }).mcpServers;\n\tif (typeof servers !== \"object\" || servers === null || Array.isArray(servers)) return [];\n\treturn Object.keys(servers);\n}\n\n/**\n * Resolve an extension-declared MCP server. Preserves the declared exposure,\n * directTools, filters, lifecycle, and enabled state. A stdio declaration\n * without an explicit `cwd` defaults to the extension's registration cwd.\n */\nexport function resolveExtensionMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n\tregistrationCwd: string,\n): ResolvedMcpServer {\n\tconst withCwd = { ...raw, cwd: raw.cwd ?? registrationCwd };\n\tconst config = normalizeServer(withCwd);\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"extension\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\n/**\n * Merge extension-declared MCP servers into a resolved config. Trusted file\n * sources (global/claude/project) win, including disabled entries. An\n * extension entry replaces an untrusted placeholder and records a diagnostic.\n */\nexport function mergeExtensionMcpServers(\n\tresult: ResolvedMcpConfig,\n\tdeclarations: readonly RegisteredMcpServerDeclaration[],\n): void {\n\tfor (const decl of declarations) {\n\t\tconst existing = result.servers[decl.name];\n\t\tif (existing !== undefined && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Extension MCP server '${decl.name}' from ${decl.extensionPath} skipped; ${existing.source} config at ${existing.sourcePath} wins.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (existing !== undefined) {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Extension MCP server '${decl.name}' from ${decl.extensionPath} replaces untrusted ${existing.source} placeholder from ${existing.sourcePath}.`,\n\t\t\t);\n\t\t}\n\t\tresult.servers[decl.name] = resolveExtensionMcpServer(\n\t\t\tdecl.name,\n\t\t\tdecl.config,\n\t\t\tdecl.extensionPath,\n\t\t\tdecl.registrationCwd,\n\t\t);\n\t}\n}\n\n/**\n * Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md\n * frontmatter). Exposure is forced to search with no directTools so the\n * catalog registers with ZERO active tools until the owning skill loads\n * (0 pre-load payload tokens); lifecycle stays lazy.\n */\nexport function resolveSkillMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n): ResolvedMcpServer {\n\tconst config = { ...normalizeServer(raw), directTools: [], exposure: \"search\" as const };\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"skill\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\nfunction normalizeServer(server: NonNullable<RawConfig[\"mcpServers\"]>[string]): McpServerConfig {\n\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\treturn {\n\t\targs: server.args ?? [],\n\t\tconnectTimeoutMs: server.connectTimeoutMs ?? 15_000,\n\t\tenabled: server.enabled ?? true,\n\t\texposure: server.exposure ?? \"auto\",\n\t\tidleTimeoutMin: server.idleTimeoutMin ?? 10,\n\t\tlifecycle: server.lifecycle ?? \"lazy\",\n\t\tlogLevel: server.logLevel ?? \"info\",\n\t\trequestTimeoutMs: server.requestTimeoutMs ?? 30_000,\n\t\ttype,\n\t\t...server,\n\t};\n}\n\nfunction interpolateConfig(\n\tconfig: RawConfig | undefined,\n\tenv: Record<string, string | undefined>,\n): RawConfig | undefined {\n\treturn interpolateValue(config, \"mcp\", env) as RawConfig | undefined;\n}\n\nfunction interpolateValue(value: unknown, path: string, env: Record<string, string | undefined>): unknown {\n\tif (typeof value === \"string\") return interpolateString(value, path, env);\n\tif (Array.isArray(value)) return value.map((item, index) => interpolateValue(item, `${path}.${index}`, env));\n\tif (typeof value === \"object\" && value !== null) {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, item] of Object.entries(value)) out[key] = interpolateValue(item, `${path}.${key}`, env);\n\t\treturn out;\n\t}\n\treturn value;\n}\n\nfunction interpolateString(value: string, path: string, env: Record<string, string | undefined>): string {\n\tif (value.trimStart().startsWith(\"!\") || value.includes(\"$(\")) {\n\t\tconst displayPath = path.replace(/^mcp\\./, \"\");\n\t\tthrow new McpConfigValidationError(\n\t\t\t`MCP config interpolation rejected command substitution at ${displayPath}: config values may reference only environment variables for security; shell commands are never executed.`,\n\t\t);\n\t}\n\treturn value.replace(\n\t\t/\\$\\{([A-Za-z_][A-Za-z0-9_]*)(:-([^}]*))?\\}/g,\n\t\t(_match, name: string, _fallback: string, fallbackValue: string | undefined) => {\n\t\t\treturn env[name] ?? fallbackValue ?? \"\";\n\t\t},\n\t);\n}\n\nfunction hashConfig(config: McpServerConfig): string {\n\treturn createHash(\"sha256\").update(stableStringify(config)).digest(\"hex\");\n}\n\nfunction stableStringify(value: unknown): string {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (typeof value === \"object\" && value !== null) {\n\t\treturn `{${Object.keys(value)\n\t\t\t.sort()\n\t\t\t.map((key) => `${JSON.stringify(key)}:${stableStringify((value as Record<string, unknown>)[key])}`)\n\t\t\t.join(\",\")}}`;\n\t}\n\treturn JSON.stringify(value);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,gCAAgC,EAQhC,cAAc,GACd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAClD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,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CACnB,6CAA6C,EAC7C,CAAC,MAAM,EAAE,IAAY,EAAE,SAAiB,EAAE,aAAiC,EAAE,EAAE;QAC9E,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,aAAa,IAAI,EAAE,CAAC;IACzC,CAAC,CACD,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAuB;IAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aAC3B,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,eAAe,CAAE,KAAiC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAClG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../../../../config.ts\";\nimport {\n\tdefaultSettings,\n\tgetServerEndpointValidationError,\n\ttype LoadMcpConfigOptions,\n\ttype McpServerConfig,\n\ttype McpServerSource,\n\ttype McpSettings,\n\ttype RawConfig,\n\ttype ResolvedMcpConfig,\n\ttype ResolvedMcpServer,\n\tvalidateConfig,\n} from \"./config-schema.ts\";\n\nexport class McpConfigValidationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"McpConfigValidationError\";\n\t}\n}\n\ninterface JsonReadResult {\n\traw: unknown;\n\tdiagnostic?: string;\n}\n\nconst trustedEnv = process.env as Record<string, string | undefined>;\n\nexport function loadMcpConfig(options: LoadMcpConfigOptions): ResolvedMcpConfig {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst env = options.env ?? trustedEnv;\n\tconst globalPath = join(agentDir, \"mcp.json\");\n\tconst projectPath = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tconst claudePath = join(options.cwd, \".mcp.json\");\n\tconst globalConfig = readTrustedConfig(globalPath, env);\n\tconst projectRead = readConfigJson(projectPath, options.projectTrusted);\n\tconst projectRaw = projectRead.raw;\n\tconst preliminary = mergeConfigs(\n\t\tglobalConfig,\n\t\toptions.projectTrusted ? validateRaw(projectRaw, projectPath) : undefined,\n\t);\n\tconst shouldImportClaude = preliminary.settings?.importConfigs?.includes(\"claude\") === true;\n\tconst claudeRead = shouldImportClaude ? readConfigJson(claudePath, options.projectTrusted) : { raw: undefined };\n\tconst claudeRaw = claudeRead.raw;\n\tconst sources = [\n\t\t{ config: globalConfig, path: globalPath, source: \"global\" as const, trusted: true },\n\t\t{\n\t\t\tconfig:\n\t\t\t\toptions.projectTrusted && shouldImportClaude ? readTrustedConfig(claudePath, env, claudeRaw) : undefined,\n\t\t\tpath: claudePath,\n\t\t\tsource: \"claude\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t\t{\n\t\t\tconfig: options.projectTrusted ? readTrustedConfig(projectPath, env, projectRaw) : undefined,\n\t\t\tpath: projectPath,\n\t\t\tsource: \"project\" as const,\n\t\t\ttrusted: options.projectTrusted,\n\t\t},\n\t];\n\tconst merged = mergeConfigs(...sources.map((item) => item.config));\n\tconst result: ResolvedMcpConfig = { diagnostics: [], servers: {}, settings: normalizeSettings(merged.settings) };\n\tfor (const diagnostic of [projectRead.diagnostic, claudeRead.diagnostic]) {\n\t\tif (diagnostic) result.diagnostics.push(diagnostic);\n\t}\n\n\tfor (const item of sources) {\n\t\tif (item.trusted && item.config?.mcpServers) {\n\t\t\taddTrustedServers(result, item.config.mcpServers, item.source, item.path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!item.trusted) {\n\t\t\taddUntrustedServers(\n\t\t\t\tresult,\n\t\t\t\treadServerNames(item.source === \"claude\" ? claudeRaw : projectRaw),\n\t\t\t\titem.source,\n\t\t\t\titem.path,\n\t\t\t);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport function visitSpawnableMcpServers(\n\tconfig: ResolvedMcpConfig,\n\tvisit: (name: string, server: ResolvedMcpServer) => void,\n): void {\n\tfor (const [name, server] of Object.entries(config.servers)) {\n\t\tif (server.state === \"enabled\") {\n\t\t\tvisit(name, server);\n\t\t}\n\t}\n}\n\nfunction readTrustedConfig(\n\tpath: string,\n\tenv: Record<string, string | undefined>,\n\traw = readConfigJson(path, true).raw,\n): RawConfig | undefined {\n\tconst config = interpolateConfig(validateRaw(raw, path), env);\n\tconst endpointError = config ? getServerEndpointValidationError(config) : undefined;\n\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\treturn config;\n}\n\nfunction readConfigJson(path: string, trusted: boolean): JsonReadResult {\n\tif (!existsSync(path)) return { raw: undefined };\n\ttry {\n\t\tconst raw: unknown = JSON.parse(readFileSync(path, \"utf-8\"));\n\t\treturn { raw };\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tif (trusted) throw new McpConfigValidationError(`Invalid MCP config at ${path}: ${reason}`);\n\t\treturn { raw: undefined, diagnostic: `Blocked untrusted MCP config at ${path}: invalid JSON (${reason})` };\n\t}\n}\n\nfunction validateRaw(raw: unknown, _path: string): RawConfig | undefined {\n\tif (raw === undefined) return undefined;\n\tif (validateConfig.Check(raw)) {\n\t\tconst config = raw as RawConfig;\n\t\tconst endpointError = getServerEndpointValidationError(config);\n\t\tif (endpointError) throw new McpConfigValidationError(`Invalid MCP config at ${endpointError}`);\n\t\treturn config;\n\t}\n\tconst error = Array.from(validateConfig.Errors(raw))[0];\n\tthrow new McpConfigValidationError(`Invalid MCP config at ${formatErrorPath(error)}: ${formatErrorMessage(error)}`);\n}\n\nfunction formatErrorPath(error: TLocalizedValidationError): string {\n\tconst trimmed = error.instancePath.replace(/^\\//, \"\");\n\treturn trimmed.length === 0 ? \"$\" : trimmed.split(\"/\").map(decodePathPart).join(\".\");\n}\n\nfunction decodePathPart(part: string): string {\n\treturn part.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nfunction formatErrorMessage(error: TLocalizedValidationError): string {\n\treturn error.message === \"must be array\" ? \"Expected array\" : error.message;\n}\n\nfunction mergeConfigs(...configs: (RawConfig | undefined)[]): RawConfig {\n\tconst merged: RawConfig = {};\n\tfor (const config of configs) {\n\t\tif (!config) continue;\n\t\tmerged.settings = { ...(merged.settings ?? {}), ...(config.settings ?? {}) };\n\t\tmerged.mcpServers = { ...(merged.mcpServers ?? {}), ...(config.mcpServers ?? {}) };\n\t}\n\treturn merged;\n}\n\nfunction normalizeSettings(settings: RawConfig[\"settings\"]): McpSettings {\n\treturn { ...defaultSettings, ...settings };\n}\n\nfunction addTrustedServers(\n\tresult: ResolvedMcpConfig,\n\tservers: NonNullable<RawConfig[\"mcpServers\"]>,\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const [name, server] of Object.entries(servers)) {\n\t\tconst config = normalizeServer(server);\n\t\tresult.servers[name] = {\n\t\t\tconfig,\n\t\t\tconfigHash: hashConfig(config),\n\t\t\tname,\n\t\t\tsource,\n\t\t\tsourcePath,\n\t\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\t\ttransport: config.type,\n\t\t};\n\t}\n}\n\nfunction addUntrustedServers(\n\tresult: ResolvedMcpConfig,\n\tnames: readonly string[],\n\tsource: McpServerSource,\n\tsourcePath: string,\n): void {\n\tfor (const name of names) {\n\t\tconst existing = result.servers[name];\n\t\tif (existing && existing.state !== \"untrusted\") {\n\t\t\tresult.diagnostics.push(\n\t\t\t\t`Blocked untrusted ${source} MCP server '${name}' from shadowing trusted ${existing.source} server.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tresult.servers[name] = { name, source, sourcePath, state: \"untrusted\" };\n\t}\n}\n\nfunction readServerNames(raw: unknown): string[] {\n\tif (typeof raw !== \"object\" || raw === null || Array.isArray(raw)) return [];\n\tconst servers = (raw as { mcpServers?: unknown }).mcpServers;\n\tif (typeof servers !== \"object\" || servers === null || Array.isArray(servers)) return [];\n\treturn Object.keys(servers);\n}\n\n/**\n * Resolve a skill-declared MCP server (mcp.json sidecar or SKILL.md\n * frontmatter). Exposure is forced to search with no directTools so the\n * catalog registers with ZERO active tools until the owning skill loads\n * (0 pre-load payload tokens); lifecycle stays lazy.\n */\nexport function resolveSkillMcpServer(\n\tname: string,\n\traw: NonNullable<RawConfig[\"mcpServers\"]>[string],\n\tsourcePath: string,\n): ResolvedMcpServer {\n\tconst config = { ...normalizeServer(raw), directTools: [], exposure: \"search\" as const };\n\treturn {\n\t\tconfig,\n\t\tconfigHash: hashConfig(config),\n\t\tname,\n\t\tsource: \"skill\",\n\t\tsourcePath,\n\t\tstate: config.enabled ? \"enabled\" : \"disabled\",\n\t\ttransport: config.type,\n\t};\n}\n\nfunction normalizeServer(server: NonNullable<RawConfig[\"mcpServers\"]>[string]): McpServerConfig {\n\tconst type = server.type ?? (server.url ? \"http\" : \"stdio\");\n\treturn {\n\t\targs: server.args ?? [],\n\t\tconnectTimeoutMs: server.connectTimeoutMs ?? 15_000,\n\t\tenabled: server.enabled ?? true,\n\t\texposure: server.exposure ?? \"auto\",\n\t\tidleTimeoutMin: server.idleTimeoutMin ?? 10,\n\t\tlifecycle: server.lifecycle ?? \"lazy\",\n\t\tlogLevel: server.logLevel ?? \"info\",\n\t\trequestTimeoutMs: server.requestTimeoutMs ?? 30_000,\n\t\ttype,\n\t\t...server,\n\t};\n}\n\nfunction interpolateConfig(\n\tconfig: RawConfig | undefined,\n\tenv: Record<string, string | undefined>,\n): RawConfig | undefined {\n\treturn interpolateValue(config, \"mcp\", env) as RawConfig | undefined;\n}\n\nfunction interpolateValue(value: unknown, path: string, env: Record<string, string | undefined>): unknown {\n\tif (typeof value === \"string\") return interpolateString(value, path, env);\n\tif (Array.isArray(value)) return value.map((item, index) => interpolateValue(item, `${path}.${index}`, env));\n\tif (typeof value === \"object\" && value !== null) {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, item] of Object.entries(value)) out[key] = interpolateValue(item, `${path}.${key}`, env);\n\t\treturn out;\n\t}\n\treturn value;\n}\n\nfunction interpolateString(value: string, path: string, env: Record<string, string | undefined>): string {\n\tif (value.trimStart().startsWith(\"!\") || value.includes(\"$(\")) {\n\t\tconst displayPath = path.replace(/^mcp\\./, \"\");\n\t\tthrow new McpConfigValidationError(\n\t\t\t`MCP config interpolation rejected command substitution at ${displayPath}: config values may reference only environment variables for security; shell commands are never executed.`,\n\t\t);\n\t}\n\treturn value.replace(\n\t\t/\\$\\{([A-Za-z_][A-Za-z0-9_]*)(:-([^}]*))?\\}/g,\n\t\t(_match, name: string, _fallback: string, fallbackValue: string | undefined) => {\n\t\t\treturn env[name] ?? fallbackValue ?? \"\";\n\t\t},\n\t);\n}\n\nfunction hashConfig(config: McpServerConfig): string {\n\treturn createHash(\"sha256\").update(stableStringify(config)).digest(\"hex\");\n}\n\nfunction stableStringify(value: unknown): string {\n\tif (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\tif (typeof value === \"object\" && value !== null) {\n\t\treturn `{${Object.keys(value)\n\t\t\t.sort()\n\t\t\t.map((key) => `${JSON.stringify(key)}:${stableStringify((value as Record<string, unknown>)[key])}`)\n\t\t\t.join(\",\")}}`;\n\t}\n\treturn JSON.stringify(value);\n}\n"]}
|
|
@@ -3,7 +3,7 @@ export declare const ANTHROPIC_TOOL_SEARCH_NAME = "tool_search";
|
|
|
3
3
|
/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */
|
|
4
4
|
export declare const ANTHROPIC_MAX_TOOLS = 10000;
|
|
5
5
|
export interface AnthropicNativeInjectionConfig {
|
|
6
|
-
/** Never defer this tool (our custom
|
|
6
|
+
/** Never defer this tool (our custom mcp_search), and it is non-deferrable. */
|
|
7
7
|
readonly searchToolName?: string;
|
|
8
8
|
/** True for MCP catalog tools eligible for deferral. */
|
|
9
9
|
readonly isDeferrable: (toolName: string) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AACxD,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,MAAM,WAAW,8BAA8B;IAC9C
|
|
1
|
+
{"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AACxD,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,MAAM,WAAW,8BAA8B;IAC9C,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CACrD;AAMD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,8BAA8B,GACpC,OAAO,CAUT;AAaD;6EAC6E;AAC7E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAE7G;AAED,MAAM,WAAW,0BAA2B,SAAQ,8BAA8B;IACjF,+EAA+E;IAC/E,OAAO,IAAI,OAAO,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,gCAAgC;;IAM5C,YAAY,IAAI,EAAE,0BAA0B,EAE3C;IAED,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAMrE;IAED,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMvC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;CACD"}
|
|
@@ -85,7 +85,7 @@ export class AnthropicNativeToolSearchAdapter {
|
|
|
85
85
|
return;
|
|
86
86
|
this.#disabled = true;
|
|
87
87
|
this.#fallbackReason =
|
|
88
|
-
"Anthropic returned 400 for native tool-search; disabled it and fell back to local
|
|
88
|
+
"Anthropic returned 400 for native tool-search; disabled it and fell back to local mcp_search for this session.";
|
|
89
89
|
this.#deps.onFallback?.(this.#fallbackReason);
|
|
90
90
|
}
|
|
91
91
|
get disabled() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,iFAAiF;AACjF,gFAAgF;AAChF,2EAA2E;AAC3E,EAAE;A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B,GAAG,KAAK,CAAC;QAClC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAAE,OAAO,OAAO,CAAC;QAC5D,MAAM,IAAI,GAAG,4BAA4B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,CAAC,oBAAoB,GAAG,IAAI,KAAK,OAAO,CAAC;QAC7C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB,CAAC,MAAc;QAChC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,eAAe;YACnB,
|
|
1
|
+
{"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,iFAAiF;AACjF,gFAAgF;AAChF,2EAA2E;AAC3E,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,wEAAwE;AACxE,yDAAyD;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,aAAa,CAAC;AACxD,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AASzC,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC3C,GAAuB,EACvB,OAAgB,EAChB,MAAsC;IAEtC,IAAI,GAAG,KAAK,oBAAoB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,C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H,CAAC;QAClH,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["// Native provider tool-search adapters (todo 33 — Anthropic half).\n//\n// Gated on the todo-29 spike verdict: Anthropic Messages is GO-pure-extension —\n// server_tool_use / tool_search_tool_result blocks round-trip pi-ai's\n// parse->persist->re-serialise cycle untouched (native-search-spike.md), so this\n// adapter injects request-side fields via the extension before_provider_request\n// event ONLY (the sole ExtensionAPI payload surface) with no pi-ai change.\n//\n// It injects Anthropic's native `tool_search_tool_bm25_20251119` tool and marks\n// deferrable MCP tools `defer_loading:true`, honouring the API HARD RULES, and\n// auto-falls-back to local Tier-B on a 400. The OpenAI half is deferred\n// (spike = GO-with-ai-seam; see native-search-spike.md).\n\nexport const ANTHROPIC_TOOL_SEARCH_TYPE = \"tool_search_tool_bm25_20251119\";\nexport const ANTHROPIC_TOOL_SEARCH_NAME = \"tool_search\";\n/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */\nexport const ANTHROPIC_MAX_TOOLS = 10000;\n\nexport interface AnthropicNativeInjectionConfig {\n\t/** Never defer this tool (our custom mcp_search), and it is non-deferrable. */\n\treadonly searchToolName?: string;\n\t/** True for MCP catalog tools eligible for deferral. */\n\treadonly isDeferrable: (toolName: string) => boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Pure payload transform. Adds exactly one native tool-search tool (idempotent)\n * and sets `defer_loading:true` on eligible MCP tools, enforcing the HARD RULES:\n * never defer the search tool, never combine defer_loading with cache_control\n * (400), keep >=1 non-deferred tool (the native search tool guarantees this),\n * and skip entirely above the 10k tool cap.\n */\nexport function addAnthropicNativeToolSearch(\n\tapi: string | undefined,\n\tpayload: unknown,\n\tconfig: AnthropicNativeInjectionConfig,\n): unknown {\n\tif (api !== \"anthropic-messages\" || !isRecord(payload)) return payload;\n\tconst tools = Array.isArray(payload.tools) ? payload.tools : [];\n\tif (tools.length > ANTHROPIC_MAX_TOOLS) return payload;\n\tconst deferred = tools.map((tool) => maybeDefer(tool, config));\n\tconst hasSearchTool = deferred.some((tool) => isRecord(tool) && tool.type === ANTHROPIC_TOOL_SEARCH_TYPE);\n\tconst nextTools = hasSearchTool\n\t\t? deferred\n\t\t: [...deferred, { type: ANTHROPIC_TOOL_SEARCH_TYPE, name: ANTHROPIC_TOOL_SEARCH_NAME }];\n\treturn { ...payload, tools: nextTools };\n}\n\nfunction maybeDefer(tool: unknown, config: AnthropicNativeInjectionConfig): unknown {\n\tif (!isRecord(tool)) return tool;\n\tconst name = typeof tool.name === \"string\" ? tool.name : undefined;\n\tif (name === undefined) return tool; // server/native tools are type-based, never deferred\n\tif (name === config.searchToolName) return tool; // never defer the search tool\n\tif (!config.isDeferrable(name)) return tool; // non-MCP tools untouched\n\tif (\"cache_control\" in tool) return tool; // never defer_loading + cache_control (400)\n\tif (tool.defer_loading === true) return tool; // idempotent\n\treturn { ...tool, defer_loading: true };\n}\n\n/** `tool_reference` blocks emitted inside a tool_result so the API expands the\n * referenced (deferred) tools — the cache-prefix-safe custom-search path. */\nexport function buildToolReferenceBlocks(names: readonly string[]): { type: \"tool_reference\"; name: string }[] {\n\treturn names.map((name) => ({ type: \"tool_reference\", name }));\n}\n\nexport interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {\n\t/** Resolved config gate (nativeToolSearch auto|true AND provider supports). */\n\tenabled(): boolean;\n\t/** Invoked once when a 400 forces the local-search fallback. */\n\tonFallback?(reason: string): void;\n}\n\n/**\n * Stateful adapter driving the before_provider_request injection and the\n * after_provider_response 400 detector. Once a 400 lands on a request we\n * injected, native search is disabled for the rest of the session and the\n * extension falls back to local Tier-B (which is always registered).\n */\nexport class AnthropicNativeToolSearchAdapter {\n\t#disabled = false;\n\t#injectedLastRequest = false;\n\t#fallbackReason: string | null = null;\n\treadonly #deps: AnthropicNativeAdapterDeps;\n\n\tconstructor(deps: AnthropicNativeAdapterDeps) {\n\t\tthis.#deps = deps;\n\t}\n\n\tapplyBeforeRequest(api: string | undefined, payload: unknown): unknown {\n\t\tthis.#injectedLastRequest = false;\n\t\tif (this.#disabled || !this.#deps.enabled()) return payload;\n\t\tconst next = addAnthropicNativeToolSearch(api, payload, this.#deps);\n\t\tthis.#injectedLastRequest = next !== payload;\n\t\treturn next;\n\t}\n\n\tnoteResponseStatus(status: number): void {\n\t\tif (status !== 400 || !this.#injectedLastRequest || this.#disabled) return;\n\t\tthis.#disabled = true;\n\t\tthis.#fallbackReason =\n\t\t\t\"Anthropic returned 400 for native tool-search; disabled it and fell back to local mcp_search for this session.\";\n\t\tthis.#deps.onFallback?.(this.#fallbackReason);\n\t}\n\n\tget disabled(): boolean {\n\t\treturn this.#disabled;\n\t}\n\n\tget fallbackReason(): string | null {\n\t\treturn this.#fallbackReason;\n\t}\n}\n"]}
|