Skip to content

feat: structured telemetry metrics, strict MCP config mode, and PermissionDecision types#263

Open
raymondginger2018-sudo wants to merge 5 commits into
lessweb:mainfrom
raymondginger2018-sudo:feat/jul26-metrics-strict-mcp
Open

feat: structured telemetry metrics, strict MCP config mode, and PermissionDecision types#263
raymondginger2018-sudo wants to merge 5 commits into
lessweb:mainfrom
raymondginger2018-sudo:feat/jul26-metrics-strict-mcp

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown

Summary

Adds structured observability and security hardening features ported from Claude Code upstream.

Key Changes

Structured Telemetry Metrics

  • Added PermissionDecisionMetrics type (toolType + accept/reject decision tracking)
  • Added ToolUsageMetrics type (totalCostUSD, totalAPIDuration, lines added/removed, tool calls)
  • In-memory per-session metrics store with get/reset APIs
  • Re-exported all new types from core/index.ts

Strict MCP Config Mode

  • Added strictMcpConfig option to settings schema
  • Implemented command allowlist validation in McpManager (npx, node, python3, uvx, bun, deno, go, java)
  • Wired strictMcpConfig from SessionManager to McpManager.setStrictMode()
  • Blocked MCP servers using non-allowlisted commands with descriptive error message

Upstream References

  • Claude Code --strict-mcp-config flag
  • OpenTelemetry-style structured metrics for observability

Raymo added 5 commits July 14, 2026 22:11
1. 自动错误修复循环 (Auto Error Fix Loop)
   - bash-handler.ts: 命令失败时自动提取关键错误行
   - session.ts: 检测工具执行失败,自动注入修复提醒

2. Plan → Execute → Verify 内置循环
   - prompt.ts: 新增 AGENTIC_BEHAVIOR_PROMPT 系统提示
   - 告诉 LLM 先规划、再执行、每步验证、失败必修

3. 错误输出结构化增强
   - 失败命令的输出自动包裹 <error_analysis> 标签
   - LLM 放弃修复时自动注入 [Auto Error Fix] 提醒
   - 最多重试 3 轮,仍失败则向用户解释
.agentic-snapshot/ 包含:
- README.md: 恢复指南(Git / 脚本 / npm link 三种方式)
- restore-agentic.bat: 一键恢复脚本
- .gitignore: 不跟踪构建产物

备份的 dist 文件存储在本地 .agentic-snapshot/*.js,
不会被 git 跟踪,需要手动保留或从 git 提交还原源码。
借鉴 OpenAI Codex CLI 架构精华,四大模块升级:

1. Permission Profile:结构化权限系统
   - Managed / Unrestricted / Legacy 三模式
   - 路径级 ACL(read/write/deny + glob 匹配)
   - 内置 STRICT_SANDBOX / DEFAULT_DEV 预置 Profile

2. SQLite 统一状态管理
   - 4 张表:session_logs / token_budget / permission_audit / checkpoints
   - json_extract 结构化查询
   - 自动持久化 + 7 天清理

3. Job 队列引擎
   - SpawnRequest->SpawnReady->ExitPayload 三阶段协议
   - 指数退避重试 + 并发控制
   - 全局单例 getGlobalJobQueue()

4. Skill 标准化
   - Codex 兼容 SKILL.md frontmatter 解析
   - agent.dependencies / interface / policy 声明
   - skillPolicyToProfile() 自动权限转换

测试:38/38 全部通过
从 Claude Code v2.1.216 移植:
  - deepcode-agent-sdk: Agent SDK (agentSdk.ts)
  - deepcode-sandbox: 安全沙箱 (sandbox-runtime)
  - deepcode-auth: OAuth2/OIDC/API Key 认证
  - deepcode-streaming: SSE 流式 API
  - deepcode-hooks: Hook 系统 + Codex 决策模型
  - deepcode-chrome: Chrome 浏览器集成

从 codex.exe 移植:
  - deepcode-agent: Agent 消息类型系统 (21 种消息类型)
  - deepcode-rust-re: Rust 二进制逆向分析引擎

附: SQLite 自动保存修复
…ermissionDecision types

- feat(telemetry): Add PermissionDecisionMetrics and ToolUsageMetrics types
- feat(telemetry): Implement in-memory metrics store (per-session, non-persistent)
- feat(telemetry): Export recordPermissionDecision, recordToolUsage, getSessionMetrics
- feat(mcp-manager): Add strict MCP config mode with command allowlist validation
- feat(mcp-manager): Support setStrictMode() for upstream --strict-mcp-config
- feat(session): Wire strictMcpConfig from settings to McpManager
- feat(settings): Add strictMcpConfig option to DeepcodingSettings schema
- refactor: Re-export new telemetry types from core/index.ts

Upstream reference: Claude Code --strict-mcp-config flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant