ClawsJoy/dsh-plugins--packages-tool-attribution ↗★ 0
@clawsjoy/dsh-tool-attribution
Publishes DSH_TOOL_CALL_ID/DSH_TOOL_NAME for shell tool executions via the public ctx.shellEnv registry. 适合需要精确追踪 Shell 子进程归属,为可观测性或审计层提供调用链关联的开发者。
Install
This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full README ↗
README
Read the full README ↗@clawsjoy/dsh-tool-attribution
Publishes DSH_TOOL_CALL_ID and DSH_TOOL_NAME for every shell tool
execution, through the public ctx.shellEnv registry.
Why
Upstream DSH (0.1.5-rc.2) does not set those variables for tool
subprocesses (verified: no reference in the tree; env inside a tool call shows
nothing). Without them a subprocess cannot say which tool call it belongs to, so
any egress or observability layer can only guess — and a guessed attribution is
worse than none, because it looks authoritative.
What it does
ctx.shellEnv.register({
name: 'clawsjoy-tool-attribution',
variables: { DSH_TOOL_CALL_ID: {...}, DSH_TOOL_NAME: {...} },
resolve: execution => attribute(execution), // {} when unattributable
})
- Reads the host's
ToolExecutionstructurally (callId,name,rootCallId) so a host type change cannot break the build; - Sanitizes values (trimmed, no NUL/newline, bounded) and publishes nothing when the identity is unusable — the negative control;
- Touches no
subprocess-local/shell-envinternals: the registry validates keys and rejects undeclared ones.
Install
dsh plugin --profile web add @clawsjoy/dsh-tool-attribution
- insert:
- id: tool-attribution
name: '@clawsjoy/dsh-tool-attribution'
Verification
pnpm test
License
MIT