跳转至

作者 B 的源码研究索引

身份:章节作者,现阶段不是独立审查员。主源码固定 da00f7f5358f2949383b35c14f548bc20187d80c,对照发布 639ed015397290b3745d163aafe02ffee4aa3f84 / 0.2.0-rc.2。

实际研究方法:读取 root AGENTS.md / architecture.md;连续读取下面的模块及其被调用实现、配置、关键类型;针对 main vs rc.2 做 git diff。表内行号是实际引用函数或字段锚点,不表示整仓每一行已经人工检查。

在章节中直接追踪的文件/函数

章节 文件 函数/字段锚点 主分支行号
04-boot-and-presets.md apps/cli/src/profile-boot.ts export function prepareProfile 167
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts export function initProfile 254
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts export const PROFILE_TEMPLATES 179
04-boot-and-presets.md apps/cli/src/profile-boot.ts async function composeProfile 197
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts export function bundlePatchFiles 58
04-boot-and-presets.md packages/bundle/web-app/cordis.patch.yml A patch replaces 5
04-boot-and-presets.md apps/cli/src/profile-boot.ts function createAppReady 44
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts export async function createRuntimeResolution 441
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts export interface LinkedRoot 142
04-boot-and-presets.md packages/boot/app-boot/src/profile.ts computeLatestResolution(): 515
04-boot-and-presets.md packages/preset/agent-preset-registry/src/mount.ts export async function mountPreset 204
04-boot-and-presets.md packages/preset/agent-preset-registry/src/mount.ts export function leakedServices 69
04-boot-and-presets.md packages/preset/agent-preset-registry/src/mount.ts export async function auditRows 134
04-boot-and-presets.md packages/preset/agent-preset-registry/src/display.ts const BUILT_IN_PRESET_KEYS 40
04-boot-and-presets.md packages/bundle/web-app/cordis.patch.yml id: tools 32
04-boot-and-presets.md packages/bundle/web-app/presets/standard.patch.yml id: preset-standard 5
04-boot-and-presets.md packages/bundle/web-app/presets/minimal.patch.yml id: preset-minimal 5
04-boot-and-presets.md packages/bundle/web-app/presets/cordis.patch.yml id: tool-cordis 157
04-boot-and-presets.md apps/cli/src/profile-boot.ts export function initializeProfileFromDefault 101
04-boot-and-presets.md apps/cli/src/plugin.ts export async function runPlugin 70
09-llm-and-context.md packages/llm/llm/src/index.ts registerAdapter(providers: 389
09-llm-and-context.md packages/llm/llm/src/index.ts async prepareCall(config: 929
09-llm-and-context.md packages/llm/llm-deepseek-api-key/src/index.ts const PROVIDER 15
09-llm-and-context.md packages/llm/llm-deepseek-api-key/src/index.ts const resolveApiKey 20
09-llm-and-context.md packages/llm/llm-deepseek/src/config.ts export const PUBLIC_BASE_URL 106
09-llm-and-context.md packages/llm/llm-deepseek/src/adapter.ts override prepareCall 43
09-llm-and-context.md packages/llm/llm-deepseek/src/adapter.ts private async * request 75
09-llm-and-context.md packages/llm/llm-deepseek/src/sse.ts export async function* parseSse 13
09-llm-and-context.md packages/llm/llm-deepseek/src/defaults.ts DEFAULT_STREAM_IDLE_TIMEOUT_MS 4
09-llm-and-context.md packages/llm/llm-deepseek/src/models.ts export const DEFAULT_MODELS 6
09-llm-and-context.md packages/llm/llm-pi-ai/src/index.ts const resolveApiKey 183
09-llm-and-context.md packages/llm/llm-retry/src/index.ts function validateConfig 30
09-llm-and-context.md packages/llm/llm-retry/src/index.ts async function backoff 149
09-llm-and-context.md packages/llm/llm-retry/src/index.ts if (failure.providerRetryAfterMs 227
09-llm-and-context.md packages/llm/token-meter/src/estimate.ts const CHARS_PER_TOKEN 13
09-llm-and-context.md packages/llm/token-meter/src/index.ts measure(session: 146
09-llm-and-context.md packages/compaction/compaction-basic/src/config.ts export function resolveConfig 68
09-llm-and-context.md packages/compaction/compaction-basic/src/config.ts export function resolveCompactSpec 153
09-llm-and-context.md packages/compaction/compaction-basic/src/region.ts export function selectCompactableRange 117
09-llm-and-context.md packages/compaction/compaction-basic/src/region.ts export async function compactSurfaceRegion 173
09-llm-and-context.md packages/compaction/compaction-basic/src/summarizer.ts export async function summarizeWithLlm 120
09-llm-and-context.md packages/compaction/compaction-tool-result-pruner/src/index.ts pruneContent(blocks: 83
09-llm-and-context.md packages/compaction/compaction-image-offload/src/index.ts export function apply 25
09-llm-and-context.md packages/context/agent-instructions/src/index.ts export function apply 84
09-llm-and-context.md packages/skill/skill-filesystem/src/index.ts const PROJECT_DSH_RANK 36
09-llm-and-context.md packages/skill/skill-filesystem/src/index.ts export interface Config 49
09-llm-and-context.md packages/context/time-context/src/index.ts export function apply 132
09-llm-and-context.md packages/context/session-reference/src/index.ts private async prepareDirectMessages 153
10-execution-and-sandbox.md packages/fs/fs-local/src/index.ts export class LocalFileSystem 68
10-execution-and-sandbox.md packages/fs/fs-local/src/index.ts private async withLock 118
10-execution-and-sandbox.md packages/fs/fs-local/src/index.ts override async writeText 202
10-execution-and-sandbox.md packages/fs/fs-observation-policy/src/index.ts writeIntent(target: 65
10-execution-and-sandbox.md packages/fs/fs-observation-policy/src/index.ts editIntent(target: 78
10-execution-and-sandbox.md packages/fs/fs-sandbox/src/index.ts private async checkedTarget 122
10-execution-and-sandbox.md packages/sandbox/sandbox-policy/src/index.ts resolve(request: 164
10-execution-and-sandbox.md packages/sandbox/sandbox/src/escalation.ts export const WIDER_MODES 28
10-execution-and-sandbox.md packages/sandbox/sandbox/src/escalation.ts export function validateEscalationArgs 51
10-execution-and-sandbox.md packages/sandbox/sandbox-local/src/index.ts export interface Config 45
10-execution-and-sandbox.md packages/sandbox/sandbox-local/src/profiles.ts export function bwrapProfileArgs 16
10-execution-and-sandbox.md packages/sandbox/sandbox-local/src/profiles.ts export function landlockProfileArgs 30
10-execution-and-sandbox.md packages/sandbox/sandbox-local/src/profiles.ts export function seatbeltProfileArgs 51
10-execution-and-sandbox.md packages/shell/bash-sandbox/src/index.ts override onProcessDone 158
10-execution-and-sandbox.md native/system/README.md Importing either entry 27
10-execution-and-sandbox.md packages/subprocess/subprocess-local/src/index.ts export class LocalSubprocessRuntime 59
10-execution-and-sandbox.md packages/terminal/terminal-bash/src/config.ts export function resolveConfig 78
10-execution-and-sandbox.md packages/ssh/ssh/src/index.ts export interface Config 17
10-execution-and-sandbox.md packages/ssh/subprocess-ssh/src/index.ts private async start 114
10-execution-and-sandbox.md packages/ssh/fs-ssh/src/index.ts override async writeText 82
10-execution-and-sandbox.md packages/ssh/sandbox-ssh/src/index.ts override async confine 13
10-execution-and-sandbox.md packages/lsp/lsp-stdio/src/index.ts export async function apply 126
10-execution-and-sandbox.md packages/lsp/lsp-stdio/src/connection.ts export class LspConnection 66
11-ptc-and-workflows.md packages/core/tools/src/ptc.ts const TYPESCRIPT_FLAVOR 53
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/index.ts const stripped = stripTypeScriptTypes 206
11-ptc-and-workflows.md packages/core/tools/src/ptc.ts for (const schema of registry.schemas(exec.agent)) 690
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/bootstrap.ts export function makeNamespaces 313
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/index.ts export class NodePtcRuntime 52
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/index.ts private async execute 143
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/launch.ts export function bootstrapArgs 21
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/index.ts static Config 54
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/bootstrap.ts export class LogBuffer 47
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime-node/src/bootstrap.ts export function prepareCompletion 164
11-ptc-and-workflows.md packages/ptc-runtime/ptc-runtime/src/types.ts export interface PtcRunFailure 132
11-ptc-and-workflows.md packages/core/tools/src/ptc.ts interface PendingDispatch 433
11-ptc-and-workflows.md packages/core/tools/src/ptc.ts const settle = (result: 564
11-ptc-and-workflows.md packages/core/tools/src/ptc.ts const standingPolicy 392
11-ptc-and-workflows.md packages/workflow/workflow-ptc/src/index.ts start(request: 133
11-ptc-and-workflows.md packages/workflow/workflow-ptc/src/host.ts export class PtcWorkflowRun 112
11-ptc-and-workflows.md packages/workflow/workflow-ptc/src/runtime.ts export class WorkflowExecution 56
11-ptc-and-workflows.md packages/workflow/workflow-ptc/src/runtime.ts private async agent 163
11-ptc-and-workflows.md packages/workflow/workflow-ptc/src/index.ts const limits: WorkerLimits 140
11-ptc-and-workflows.md packages/workflow/tool-workflow/src/index.ts function createWorkflowRecorder 93
11-ptc-and-workflows.md packages/workflow/tool-ralph/src/index.ts const RALPH_SCRIPT 88
11-ptc-and-workflows.md packages/workflow/tool-ralph/src/index.ts function requireFreshProvider 218
12-mcp-and-bridges.md packages/mcp/mcp-client/src/index.ts export interface StdioConfig 52
12-mcp-and-bridges.md packages/mcp/mcp-client/src/transport.ts export function createTransport 31
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts export function publicToolName 81
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts export async function syncTools 113
12-mcp-and-bridges.md packages/mcp/mcp-client/src/connection.ts function enqueueSync 169
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts export function createMcpToolDefinition 225
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts function createExecutor 272
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts async function resolveImageAdmission 352
12-mcp-and-bridges.md packages/mcp/mcp-client/src/tools.ts async function prepareImageProjection 386
12-mcp-and-bridges.md packages/mcp/mcp-client/src/connection.ts export function startConnection 127
12-mcp-and-bridges.md packages/mcp/mcp-client/src/connection.ts function settleFailedGeneration 188
12-mcp-and-bridges.md packages/mcp/mcp-resources/src/index.ts register(server: 80
12-mcp-and-bridges.md packages/hooks/hook-protocol/src/runner.ts export async function runHook 67
12-mcp-and-bridges.md packages/hooks/hooks-claude-code/src/index.ts export function apply 102
12-mcp-and-bridges.md packages/hooks/hooks-codex/src/index.ts export function apply 87
12-mcp-and-bridges.md packages/experimental/claude-code-mods/src/index.ts export const SERVED_EVENTS 68
12-mcp-and-bridges.md packages/experimental/claude-code-mods/src/index.ts function rewritePromptText 94
12-mcp-and-bridges.md packages/experimental/claude-code-mods/src/module.ts select(event: 61
12-mcp-and-bridges.md packages/browser-use/browser-use/src/index.ts register(name: 35
12-mcp-and-bridges.md packages/computer-use/computer-use/src/index.ts register(name: 35
12-mcp-and-bridges.md packages/experimental/browser-use-playwright-mcp/src/index.ts export function apply 26
12-mcp-and-bridges.md packages/experimental/browser-use-chrome-devtools-mcp/src/index.ts export function apply 25
12-mcp-and-bridges.md packages/experimental/browser-use-stagehand-native/src/index.ts export function apply 84
12-mcp-and-bridges.md packages/experimental/computer-use-cua-driver-mcp/src/index.ts export async function apply 52
12-mcp-and-bridges.md packages/experimental/computer-use-cua-driver-native/src/index.ts export async function apply 50
12-mcp-and-bridges.md packages/experimental/browser-use-runtime/src/index.ts export class SessionResources 60
12-mcp-and-bridges.md packages/experimental/browser-use-runtime/src/mcp.ts export function mountSessionMcp 100
12-mcp-and-bridges.md packages/experimental/browser-use-stagehand-native/src/index.ts const GUIDANCE 74

额外实际阅读路径

  • packages/boot/app-boot/src/profile.ts:1–530,bundle/profile初始化、resolver表、linkedRoots与最新代。
  • apps/cli/src/profile-boot.ts:1–235,appReady、initializeProfileFromDefault、prepareProfile、composeProfile。
  • packages/preset/agent-preset-registry/src/mount.ts:1–228,tree、leakedServices、serviceForMount、auditRows、mountPreset。
  • packages/bundle/sdk-minimal/cordis.patch.yml:发布版完整文件,默认权限/服务/工具。
  • packages/bundle/web-app/presets/{standard,minimal,ptc,cordis}.patch.yml:完整配置声明,stable ids、isolate、disabled、main新增time/schedule。
  • packages/llm/llm/src/index.ts:1–290、385–450、865–980,服务类型、adapter注册、preparedcall一致性。
  • packages/llm/llm-deepseek/src/{adapter,config,sse,transport,defaults,models}.ts:request串联、connection snapshot、framing/error。
  • packages/llm/llm-pi-ai/src/index.ts:1–210,profiles与认证;辅助 context/replay/stream/adapter 通过类型与调用链定向阅读。
  • packages/llm/llm-retry/src/index.ts:完整文件,backoff、projection、normal/always、dispose。
  • packages/compaction/compaction-basic/src/{index,config,region,summarizer}.ts:pressure/recovery、预算、span/transaction、summary组装连续阅读。
  • packages/compaction/{compaction-tool-result-pruner,compaction-image-offload}/src/index.ts:1–120,prune/offload差异;未宣称所有图像原生转换算法已验证。
  • packages/fs/fs-local/src/index.ts:1–260,canonicalidentity、withLock、write/CAS;fs-sandbox/src/index.ts、fs-observation-policy/src/index.ts 完整阅读。
  • packages/sandbox/{sandbox-local,sandbox-policy}/src/index.ts:policy与backend主要连续段;sandbox-local/src/profiles.ts 完整;sandbox/src/escalation.ts1–120及approve调用链。
  • packages/subprocess/subprocess-local/src/index.ts:1–200,environment/executable/disposal/managedrange路径;nativeprocess原语未跨平台实测。
  • packages/ssh/{ssh,subprocess-ssh,fs-ssh,sandbox-ssh}/src/index.ts:配置/ready、RPC/stream、prepare/start、termination、fs expected/policy;helper全RPC implementation未逐行覆盖。
  • packages/lsp/lsp-stdio/src/{index,connection}.ts:1–220/1–180,load atomicregistration、query/server、stdio与applyEdit拒绝边界。
  • packages/terminal/terminal-bash/src/{index,config,session}.ts:config/defaults、PTY与readiness主路径;未做真实交互全矩阵。
  • packages/ptc-runtime/ptc-runtime-node/src/{index,launch,bootstrap,process-entry,process}.ts:完整runtime主要路径与bootstrap/output/JSON通道;ptc-runtime/src/types.ts 类型边界。
  • packages/core/tools/src/ptc.ts:1–150、385–475、535–735,program审批、single-driver、nestedcall/pipeline、settle/drain。
  • packages/workflow/workflow-ptc/src/{index,runtime,host}.ts:start/resolve/caps、vm/helpers/childnull、holder/cancellation/quiescence;tool-workflowdescription/recorder,tool-ralph固定script/validation/provider。
  • packages/context/agent-instructions/src/index.ts:1–170和增量观察主链;time-context/src/index.ts1–180;session-reference/src/index.ts1–210;skill-filesystem/src/index.ts1–180/config/ranks。
  • packages/mcp/mcp-client/src/{index,connection,tools,transport}.ts:连接generation、reconnect、two-phaseswap、canonical/modelprojection、SDKspawn;mcp-resources/src/index.ts完整service。
  • packages/hooks/{hooks-claude-code,hooks-codex}/src/index.ts:完整eventmaps与payload/limitations;hook-protocol/src/runner.ts完整。
  • packages/experimental/claude-code-mods/src/{index,module}.ts:served events/prompt rewrite/HookRegistry;不存在Codex Mods包已按实际目录核对。
  • packages/experimental/{browser-use-playwright-mcp,browser-use-chrome-devtools-mcp,browser-use-stagehand-native,computer-use-cua-driver-mcp,computer-use-cua-driver-native}/src/index.ts与browser-use-runtime/src/{index,mcp}.ts:注册/配置/生命周期/失败语义。
  • native/system/README.md与对应入口说明:packaging/support/native职责;并未实际阅读验证所有C/C++平台代码。

当前未验范围

没有收费模型请求,没有实际远程SSHserver、WindowsACL、macOSSeatbelt/Cua、真实Chromium/Stagehandmodel/MCPvendor全矩阵。没有上游全仓测试。此作者的文档是真实源码核对;课程root的独立实验/审查/平台验收另有具体日志,不把static阅读替代runtime证据。现阶段章节示例仅示范配置与接口,真正 runnable 发布版实验指向root 18/19/20章。

作者完成后的自查记录

这仍属于作者自查,不计入用户要求的独立审查轮次。检查了五章 Markdown fence 配对、不可变源码 URL 对应的文件是否存在与行号是否在范围内、示例与 rc.2 CLI flags 的一致性。五章有 12 张 Mermaid、123 处源码链接;跨章链接等待 root 的 18/19/20 文件完成后统一验收。

纠正了 MCP unsupported outputSchema 的实际降级行为、skill 同名冲突的 scope layer 优先级、TimeContext 配置键 refreshIntervalMs。补读 packages/mcp/mcp-client/src/tools.ts 170–270(supportedOutputSchema/createOutput)、packages/skill/skill/src/index.ts 345–380、797–813(层级与 rank),以及 release/apps/cli/src/args.ts 的初始化参数。压缩预算两组示例直接按 config.ts 的函数公式重新计算。未将这些静态核对宣称为真实平台集成测试。

独立审查 A 返回问题后的修改

  • 10.3 删除错误的 main 新增 observer containment 归属;git diff 证明 write.ts/edit.ts 只有 file_path 描述顺序指导。两个快照 mutation 后都直接同步 emit fs/observed,异常仍可能使已提交修改呈现 tool error。
  • 12.2 Mermaid 加 reconnect.enabled 分支,禁用重连时保留失效工具的情况不再画成自动 reconnect。
  • 12.10 区分 SessionResources 的 close-reject 保留 ownership 契约与 MCP ConnectionHandle.dispose 的实际 close 未确认只日志后 resolve;不再承诺所有 MCP child close 都被强确认。补读 connection.ts 183–241、384–411、browser-use-runtime/mcp.ts 88–175 与资源 closeEntry。

以上修正由原独立审查员 A 复验;本作者修改不计作独立通过。

  • 12.6 Codex payload 字段由不存在的 realtool_name 改为 tool_name,值使用 exec.name;按 hooks-codex preToolPayload/postToolPayload 复核。

  • 12.2 断开流程图继续补充关闭未确认停止恢复、预算耗尽删除 server 工具两个控制条件;将旧 connection 与 previous tool registrations 分开表述,避免暗示断开立即删除旧注册。

版本表续审发现的作者自身追加修正

04.3 原将 linkedRoots 归为 main 新增,版本表续审时重读 release/profile.ts 发现错误:rc.2 已有 LinkedRoot(142)、linkedRoots(160)、linkedProfileRoots(306)、createRuntimeResolution构造(446–452)。main新增的是 ProfileRuntimeResolution 来源保存与 computeLatestResolution(475–523)、PluginPackages.refresh,以及解析代/HMR协调。已拆开表述,保留初始错误记录,并请独立审查 A 追加复签。