rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
JularDepick/dsh-time-introspect
A dsh plugin: after a timeout, the time distribution from the previous iteration is fed to the model, enabling the model to autonomously identify and adjust its behavior; if the introspection cost becomes too high, the plugin enters a dormant state, allowing the model to be restarted at any time.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:JularDepick/dsh-time-introspect
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
面向 dsh 的耗时反思插件: 上一轮实际耗时超出模型预估时, 把完整的耗时分布以 JSON 注入下一轮, 由模型自己决定是否反思. 反思的开始与结束都由模型显式调用工具, 插件只负责计时与记账; 插件不自动冷却, 不自动休眠, 是否让插件安静由模型决定.
支持 dsh 0.2.1-rc.1 至 0.2.2-rc.1
minOverrunRatio, 默认 20%)与绝对下限(minOverrunMs, 默认 5000 毫秒)时, 在下一轮 step 1 注入一次run_code 程序内嵌套调用的工具同样被识别, 预估, 反思, 休眠与工具明细都按真实工具名入账time_introspect_start 开始, time_introspect_stop 结束; 插件按两次调用的位置计时, 模型不需要整理或上报任何耗时数据introspect 明细里, 帮助模型判断反思本身是否值得time_introspect_shut 让插件休眠, time_introspect_waken 恢复; 没有自动冷却与自动休眠estimate_ms, overrun_ms, overrun_ratio 为 nulldetails 数组默认收起, 点击展开time_introspect_status 只读返回状态, 最近一轮总账与三类耗时合计locale 可选中文(zh-CN, 默认)或英文(en-US){
"type": "time_introspect",
"desc": "本 JSON 由 dsh-time-introspect 插件自动统计生成, 内容是上一轮任务的耗时分布报告. 是否据此反思由你决定; 如需反思, 调用 time_introspect_start 开始, 完成后调用 time_introspect_stop.",
"turn": 3,
"estimate_ms": 100000,
"overrun_ms": 30000,
"overrun_ratio": 0.3,
"time_consume_total_ms": 130000,
"time_consume_details": {
"tool": {
"desc": "本层是反思窗口外的工具耗时, 不含反思窗口内调用的工具; 含反思窗口外的本插件工具(包括开始与结束边界工具)的调用耗时.",
"ratio": 0.0769,
"total_ms": 10000,
"details": [
{ "name": "bash", "calls": 3, "ms": 4000, "ratio": 0.4 },
{ "name": "read", "calls": 2, "ms": 2000, "ratio": 0.2 },
{ "name": "write", "calls": 4, "ms": 3000, "ratio": 0.3 },
{ "name": "time_introspect_start", "calls": 1, "ms": 300, "ratio": 0.03 },
{ "name": "time_introspect_stop", "calls": 1, "ms": 700, "ratio": 0.07 }
]
},
"model": { "desc": "本层是反思窗口外的模型自身处理与等待耗时, 不含反思窗口内的模型耗时, 也不含任何工具耗时.", "ratio": 0.7693, "total_ms": 100000 },
"introspect": {
"desc": "本层是反思窗口内的全部耗时, 含窗口内调用的工具(包括本插件工具)与模型处理; 开始与结束工具本身在窗口外, 不计入本层.",
"ratio": 0.1538,
"total_ms": 20000,
"details": {
"tool": {
"desc": "本层是反思窗口内调用的工具耗时, 含窗口内调用的本插件工具; 开始与结束工具本身在窗口外, 不计入本层.",
"ratio": 0.3,
"total_ms": 6000,
"details": [
{ "name": "bash", "calls": 10, "ms": 5000, "ratio": 0.8333 },
{ "name": "read", "calls": 2, "ms": 1000, "ratio": 0.1667 }
]
},
"model": { "desc": "本层是反思窗口内的模型处理与等待耗时, 不含窗口内工具耗时.", "ratio": 0.7, "total_ms": 14000 }
}
}
}
}
注入 JSON 不携带唤醒原因: time_introspect_waken 的 reason 只展示给用户并写入归档, 不会回流到模型上下文. 每个耗时层都带 desc, 说明该层是否包含反思工具与本插件工具. 每层 ratio 保留 4 位小数, 缺失差值补给该层最大项.
dsh plugin --profile <name> add dsh-time-introspect
<name> 是目标 profile, 例如 web, desktop 或专用 profile.
| 工具 | 参数 | 行为 |
|---|---|---|
time_introspect_estimate |
estimateMs |
登记本轮预估, 同轮以最后一次为准 |
time_introspect_start |
无 | 开始反思; 本轮必须先收到注入, 已有打开窗口时报错 |
time_introspect_stop |
无 | 结束反思; 没有打开窗口时报错 |
time_introspect_shut |
reason |
休眠; 已休眠时幂等返回, 丢弃未闭合窗口 |
time_introspect_waken |
reason |
重启; 原因只展示给用户并写入归档, 不回灌后续报告; 已活动时幂等返回 |
time_introspect_status |
无 | 只读查询状态与最近一轮总账 |
工具名统一带 time_introspect_ 前缀. estimateMs 取值 1 到 86400000 毫秒; reason 上限 500 字符, 超出被截断. 插件不阻断任何工具调用, 也不检查模型是否真的完成了反思.
- name: dsh-time-introspect
config:
minOverrunRatio: 0.15
minOverrunMs: 3000
locale: zh-CN
| 字段 | 默认值 | 含义 |
|---|---|---|
enabled |
true |
总开关; 关闭后不注册投影, 工具与监听器 |
minOverrunRatio |
0.20 |
触发注入所需的最小超出比例, 取值 0 到 1 |
minOverrunMs |
5000 |
触发注入所需的最小绝对超出毫秒数, 取值 0 到 86400000 |
maxTurnHistory |
12 |
投影保留的已完成轮数上限, 取值 1 到 200 |
locale |
zh-CN |
模型可见文案语言, 可选 zh-CN 或 en-US |
气泡自动展开时长固定为 3 秒, 历史调用自动展开窗口固定为 15 秒; 归档与注入记录保留最近 200 轮; 均不提供配置.
turn/end 事件时间减去 turn/start 事件时间callId 配对 tool/call 与 tool/result; PTC 模式下的子调用按 subCallId 配对 tool/ptc-dispatch-start 与 tool/ptc-dispatchrun_code 只记扣除子调用后的净耗时, 总账不重复计数time_introspect_start 的工具结果到 time_introspect_stop 的工具调用开始introspect.details.tool, 不再进入顶层 tool.detailstool.details, 不单列插件开销time_consume_total_ms = tool.total_ms + model.total_ms + introspect.total_msratio 相对该层父级总量, 4 位小数, 缺失差值补给最大项| 状态 | 行为 | 迁入 | 迁出 |
|---|---|---|---|
| active | 正常判定并注入 | 初始状态, 或模型重启 | 模型调用 time_introspect_shut |
| dormant | 不注入; 仍归档每轮耗时 | 模型调用 time_introspect_shut |
模型调用 time_introspect_waken |
没有自动冷却, 没有自动休眠. 是否让插件安静由模型决定.
turn/end 生成, 每一轮一条; 结构与注入 JSON 相同, 但未登记预估的轮次缺失的总账字段为 null$DSH_HOME/profiles/<profile>/time-introspect/<sessionId>.json; 内容为 type, version, sessionId, updatedAt, archive 数组与 injections 数组, 最近 200 轮start 与 stop 都完成start 但轮次结束前没有 stopstartshut 丢弃details 数组; Tab 数据随会话投影实时更新, 文件是持久化镜像本插件不替代 dsh-time-context 或 dsh-time-reminder. 那两者负责"让模型知道时间", 本插件负责"在超时后告诉模型时间去了哪, 并让反思本身有成本". 三者可以同时挂载.
| 项目 | 说明 |
|---|---|
| dsh | >=0.2.1-rc.1 <=0.2.2-rc.1(含 0.2.1-rc.1, 0.2.1-rc.2, 0.2.1-rc.3, 0.2.2-rc.1) |
| Node.js | ^22.19.0 或 >=24.0.0 |
| 判定方式 | engines.dsh 与所有 @deepseek-ai/dsh* peer 声明同一组受支持版本; 0.2.1-rc.1 起存在 engines.dsh 时以它为准 |
| 注册差异 | 0.2.1 的投影注册只返回注销函数, 状态从注册表读取; 0.2.2 起注册返回可 await 的句柄, 插件在句柄就绪后改用句柄读取 |
npm install
npm run typecheck
npm test
npm run build
npm run pack
构建产物在 lib/, 入口为 lib/index.js, 客户端入口为 lib/client.js. npm run build 同时生成 host 与 client; npm run build:client 只重建客户端. npm run pack 或直接 npm pack 的 tgz 产物都会落入 release/, 根目录不保留.
目录结构:
dsh-time-introspect/
├── .gitignore # git 忽略规则
├── COPYRIGHT # 版权声明
├── LICENSE # Apache-2.0 许可证
├── README.md # 中文 README
├── README_en-US.md # 英文 README
├── client/ # 浏览器半端: 红点气泡与耗时自省 Tab
├── cordis.patch.yml # 组合包 patch 层
├── docs/ # 项目文档与官方开发文档快照
├── package-lock.json # 依赖锁文件
├── package.json # 包清单
├── scripts/ # 辅助脚本
├── src/ # 插件源码
├── test/ # 单元测试
├── tsconfig.build.json # 构建配置
├── tsconfig.json # 类型检查配置
├── types/ # 环境补充类型声明 (浏览器全局与 React)
├── version.index.md # 版本号出现位置索引
└── vitest.config.ts # 测试配置
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness、deepseek-harness-plugin。