dsh-fast 0.1.3 → 0.2.1
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 +12 -0
- package/README.es.md +37 -31
- package/README.hi.md +37 -31
- package/README.md +39 -31
- package/README.pt.md +37 -31
- package/README.zh.md +39 -31
- package/lib/index.js +224 -15
- package/lib/types/analyze.d.ts.map +1 -1
- package/lib/types/analyze.js +6 -0
- package/lib/types/analyze.js.map +1 -1
- package/lib/types/collector.d.ts +5 -1
- package/lib/types/collector.d.ts.map +1 -1
- package/lib/types/collector.js +14 -2
- package/lib/types/collector.js.map +1 -1
- package/lib/types/estimate.d.ts +19 -2
- package/lib/types/estimate.d.ts.map +1 -1
- package/lib/types/estimate.js +49 -2
- package/lib/types/estimate.js.map +1 -1
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +34 -8
- package/lib/types/index.js.map +1 -1
- package/lib/types/model.d.ts +23 -1
- package/lib/types/model.d.ts.map +1 -1
- package/lib/types/store.d.ts +22 -0
- package/lib/types/store.d.ts.map +1 -1
- package/lib/types/store.js +14 -0
- package/lib/types/store.js.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.js +1 -1
- package/package.json +6 -2
- package/src/analyze.ts +6 -0
- package/src/collector.ts +16 -2
- package/src/estimate.ts +54 -2
- package/src/index.ts +41 -8
- package/src/model.ts +25 -1
- package/src/store.ts +16 -0
- package/src/version.ts +1 -1
package/README.zh.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
3
|
# ⚡ dsh-fast
|
|
4
|
+
- **1024 商店渠道**:先 `npm i -g dsh1024`,再 `dsh1024 plugin --profile web add dsh-fast`(计入 [deepseek1024.com](https://deepseek1024.com) 安装排行)。
|
|
4
5
|
|
|
5
6
|
**DeepSeek Harness 的只读性能诊断插件。**
|
|
6
7
|
|
|
7
8
|
*观察会话事件流——绝不触碰模型热路径——并报告延迟与上下文预算究竟花在哪里。*
|
|
8
9
|
|
|
10
|
+
> **官方仓库。** 本仓库是 dsh-fast 的唯一官方仓库,由 PerryLink 维护。其他账号下的同名仓库与本项目无关。
|
|
11
|
+
|
|
9
12
|
[](LICENSE)
|
|
10
13
|
[](https://github.com/topics/dsh-plugin)
|
|
11
14
|
[](#)
|
|
@@ -123,43 +126,48 @@ pnpm pack
|
|
|
123
126
|
|
|
124
127
|
## Contributors
|
|
125
128
|
|
|
126
|
-
`dsh-fast`
|
|
129
|
+
感谢所有为 `dsh-fast` 做出贡献的人:
|
|
130
|
+
|
|
131
|
+
- **[PerryLink](https://github.com/PerryLink)** —— 作者与维护者:设计并实现了只读诊断(会话加载耗时、spill 命中统计、compaction 指标、上下文注入体量、LLM 缓存命中率)、`/fast` 命令与 `fast_report` 工具、`dsh_fast` 存储域以及五语文档。
|
|
127
132
|
|
|
128
133
|
## PerryLink DSH Plugin Family
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
这是 [PerryLink](https://github.com/PerryLink) 维护的 [33 个 DeepSeek Harness 插件](https://github.com/PerryLink) 之一。如果它能帮到你,其他的也会:
|
|
131
136
|
|
|
132
137
|
| Plugin | One-liner |
|
|
133
138
|
|---|---|
|
|
134
|
-
| [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | 审批链上的第二模型自动审查,默认失败关闭 |
|
|
135
|
-
| [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) |
|
|
136
|
-
| [dsh-budget](https://github.com/PerryLink/dsh-budget) | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 |
|
|
137
|
-
| [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Claude Code /rewind
|
|
138
|
-
| [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) |
|
|
139
|
-
| [dsh-click](https://github.com/PerryLink/dsh-click) | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 |
|
|
140
|
-
| [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Web
|
|
141
|
-
| [dsh-
|
|
142
|
-
| [dsh-
|
|
143
|
-
| [dsh-
|
|
144
|
-
| **[dsh-
|
|
145
|
-
| [dsh-
|
|
146
|
-
| [dsh-
|
|
147
|
-
| [dsh-
|
|
148
|
-
| [dsh-
|
|
149
|
-
| [dsh-
|
|
150
|
-
| [dsh-
|
|
151
|
-
| [dsh-
|
|
152
|
-
| [dsh-
|
|
153
|
-
| [dsh-
|
|
154
|
-
| [dsh-
|
|
155
|
-
| [dsh-
|
|
156
|
-
| [dsh-
|
|
157
|
-
| [dsh-
|
|
158
|
-
| [dsh-
|
|
159
|
-
| [dsh-
|
|
160
|
-
| [dsh-
|
|
161
|
-
| [dsh-
|
|
162
|
-
| [dsh-
|
|
139
|
+
| **[dsh-dsh-auto-review](https://github.com/PerryLink/dsh-dsh-auto-review)** | 审批链上的第二模型自动审查,默认失败关闭 | |
|
|
140
|
+
| **[dsh-dsh-background-agents](https://github.com/PerryLink/dsh-dsh-background-agents)** | 带 Web UI 侧栏、消息与中断的持久后台子代理 | |
|
|
141
|
+
| **[dsh-dsh-budget](https://github.com/PerryLink/dsh-dsh-budget)** | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 | |
|
|
142
|
+
| **[dsh-dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-dsh-checkpoint-rewind)** | Claude Code /rewind 等价:快照、会话 fork、一次性恢复 | |
|
|
143
|
+
| **[dsh-dsh-claude-move](https://github.com/PerryLink/dsh-dsh-claude-move)** | 把 Claude Code 会话、记忆、技能与 CLAUDE.md 迁入 DSH | |
|
|
144
|
+
| **[dsh-dsh-click](https://github.com/PerryLink/dsh-dsh-click)** | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 | |
|
|
145
|
+
| **[dsh-dsh-composer-history](https://github.com/PerryLink/dsh-dsh-composer-history)** | Web 输入框的终端式历史:方向键、Ctrl+R 搜索 | |
|
|
146
|
+
| **[dsh-dsh-data-quality](https://github.com/PerryLink/dsh-dsh-data-quality)** | 数据集质量检查与引文核查(本插件可选消费的数字核查桥) | |
|
|
147
|
+
| **[dsh-dsh-defend](https://github.com/PerryLink/dsh-dsh-defend)** | DeepSeek Harness 的提示注入、越狱与密钥泄露防护。 | |
|
|
148
|
+
| **[dsh-dsh-doublecheck](https://github.com/PerryLink/dsh-dsh-doublecheck)** | 工程纪律守卫:需求质询、测试门禁、对手评审 | |
|
|
149
|
+
| **[dsh-dsh-draw](https://github.com/PerryLink/dsh-dsh-draw)** | DeepSeek Harness 的统一静态图像生成路由。 | |
|
|
150
|
+
| **[dsh-dsh-fund-research](https://github.com/PerryLink/dsh-dsh-fund-research)** | 面向中国公募基金的确定性研究报告 | |
|
|
151
|
+
| **[dsh-dsh-github](https://github.com/PerryLink/dsh-dsh-github)** | 面向 DSH 的 GitHub PR/issues 集成,每次写入经审批门控 | |
|
|
152
|
+
| **[dsh-dsh-industry-research](https://github.com/PerryLink/dsh-dsh-industry-research)** | 行业研究编排,经本插件的 `ctx.researchReport.assemble` 封存交付物 | |
|
|
153
|
+
| **[dsh-dsh-library](https://github.com/PerryLink/dsh-dsh-library)** | DeepSeek Harness 的本地文档知识库。 | |
|
|
154
|
+
| **[dsh-dsh-local-ai](https://github.com/PerryLink/dsh-dsh-local-ai)** | DeepSeek Harness 的本地模型(Ollama)接入。 | |
|
|
155
|
+
| **[dsh-dsh-lsp-actions](https://github.com/PerryLink/dsh-dsh-lsp-actions)** | 通过语言服务器的 LSP 诊断、格式化、补全、代码操作与重命名 | |
|
|
156
|
+
| **[dsh-dsh-mask](https://github.com/PerryLink/dsh-dsh-mask)** | PII 脱敏中间件:模型边界匿名化、展示层还原 | |
|
|
157
|
+
| **[dsh-dsh-mcp-panel](https://github.com/PerryLink/dsh-dsh-mcp-panel)** | 只读 MCP 运行时面板:/mcp 命令 + 带状态、工具与错误的 Settings 标签页 | |
|
|
158
|
+
| **[dsh-dsh-memento](https://github.com/PerryLink/dsh-dsh-memento)** | 审批门控的跨会话记忆:ctx.memory 接缝 + SQLite + 记忆工具 | |
|
|
159
|
+
| **[dsh-dsh-observe](https://github.com/PerryLink/dsh-dsh-observe)** | DeepSeek Harness 的 OpenTelemetry 与 Langfuse 可观测导出器。 | |
|
|
160
|
+
| **[dsh-dsh-output-styles](https://github.com/PerryLink/dsh-dsh-output-styles)** | Claude Code outputStyles 等价的运行时风格切换 | |
|
|
161
|
+
| **[dsh-dsh-permission-rules](https://github.com/PerryLink/dsh-dsh-permission-rules)** | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 | |
|
|
162
|
+
| **[dsh-dsh-plugin-guide](https://github.com/PerryLink/dsh-dsh-plugin-guide)** | 作为按需代理技能的插件开发知识库 | |
|
|
163
|
+
| **[dsh-dsh-research-report](https://github.com/PerryLink/dsh-dsh-research-report)** | 可验证研究报告引擎:内容寻址证据账本与封存版本 | |
|
|
164
|
+
| **[dsh-dsh-score](https://github.com/PerryLink/dsh-dsh-score)** | DeepSeek Harness 插件的多维质量评分。 | |
|
|
165
|
+
| **[dsh-dsh-session-pin](https://github.com/PerryLink/dsh-dsh-session-pin)** | 在 Web 侧栏置顶会话,带持久排序 | |
|
|
166
|
+
| **[dsh-dsh-session-sync](https://github.com/PerryLink/dsh-dsh-session-sync)** | DeepSeek Harness 的跨设备会话同步——会话存储的专用 git 镜像。 | |
|
|
167
|
+
| **[dsh-dsh-skill-pack-security](https://github.com/PerryLink/dsh-dsh-skill-pack-security)** | 安全审计技能包:密钥扫描、依赖与供应链审查 | |
|
|
168
|
+
| **[dsh-dsh-talk](https://github.com/PerryLink/dsh-dsh-talk)** | DeepSeek Harness 的语音优先会话闭环:对它说,听它答。 | |
|
|
169
|
+
| **[dsh-dsh-test-drive](https://github.com/PerryLink/dsh-dsh-test-drive)** | DeepSeek Harness 插件的隔离试装冒烟。 | |
|
|
170
|
+
| **[dsh-dsh-translate](https://github.com/PerryLink/dsh-dsh-translate)** | DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 | |
|
|
163
171
|
|
|
164
172
|
## License
|
|
165
173
|
|
package/lib/index.js
CHANGED
|
@@ -97,9 +97,70 @@ const CHARS_PER_TOKEN = 4;
|
|
|
97
97
|
const ROLE_OVERHEAD = 4;
|
|
98
98
|
/** Per-block structural overhead for JSON framing and type tags. */
|
|
99
99
|
const BLOCK_OVERHEAD = 4;
|
|
100
|
+
/** Which tracked bucket a section name belongs to. */
|
|
101
|
+
function bucketOf(name) {
|
|
102
|
+
if (name === "deployment:persona") return "persona";
|
|
103
|
+
if (name.toLowerCase().includes("skill")) return "skills";
|
|
104
|
+
if (/agent|instructions?/iu.test(name)) return "agentsMd";
|
|
105
|
+
return "other";
|
|
106
|
+
}
|
|
107
|
+
/** An empty breakdown (all buckets zeroed). */
|
|
108
|
+
function emptyBreakdown() {
|
|
109
|
+
return {
|
|
110
|
+
agentsMd: {
|
|
111
|
+
tokens: 0,
|
|
112
|
+
chars: 0,
|
|
113
|
+
share: 0
|
|
114
|
+
},
|
|
115
|
+
skills: {
|
|
116
|
+
tokens: 0,
|
|
117
|
+
chars: 0,
|
|
118
|
+
share: 0
|
|
119
|
+
},
|
|
120
|
+
persona: {
|
|
121
|
+
tokens: 0,
|
|
122
|
+
chars: 0,
|
|
123
|
+
share: 0
|
|
124
|
+
},
|
|
125
|
+
other: {
|
|
126
|
+
tokens: 0,
|
|
127
|
+
chars: 0,
|
|
128
|
+
share: 0
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
100
132
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
133
|
+
* Classify the named system-prompt sections into the AGENTS.md / skills /
|
|
134
|
+
* persona / other buckets, with heuristic tokens and per-bucket shares. The
|
|
135
|
+
* caller supplies either the real assembled sections (via the optional
|
|
136
|
+
* `systemPrompt` service) or a single synthetic `{ name: 'other' }` section
|
|
137
|
+
* carrying the rendered prompt, so the breakdown always sums to the system
|
|
138
|
+
* prompt.
|
|
139
|
+
* @param sections - named sections (never empty in practice).
|
|
140
|
+
* @returns the per-bucket breakdown.
|
|
141
|
+
*/
|
|
142
|
+
function classifySystemSections(sections) {
|
|
143
|
+
const breakdown = emptyBreakdown();
|
|
144
|
+
for (const section of sections) {
|
|
145
|
+
const chars = section.text.length;
|
|
146
|
+
if (chars === 0) continue;
|
|
147
|
+
const bucket = breakdown[bucketOf(section.name)];
|
|
148
|
+
bucket.chars += chars;
|
|
149
|
+
bucket.tokens += Math.ceil(chars / CHARS_PER_TOKEN);
|
|
150
|
+
}
|
|
151
|
+
const total = breakdown.agentsMd.tokens + breakdown.skills.tokens + breakdown.persona.tokens + breakdown.other.tokens;
|
|
152
|
+
if (total <= 0) return breakdown;
|
|
153
|
+
for (const bucket of [
|
|
154
|
+
breakdown.agentsMd,
|
|
155
|
+
breakdown.skills,
|
|
156
|
+
breakdown.persona,
|
|
157
|
+
breakdown.other
|
|
158
|
+
]) bucket.share = bucket.tokens / total;
|
|
159
|
+
return breakdown;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Price the assembled system prompt (harness identity + persona + tool
|
|
163
|
+
* guidance + plugin sections).
|
|
103
164
|
* @param header - canonical request envelope, or undefined before any request.
|
|
104
165
|
* @returns heuristic system-prompt tokens; 0 when absent.
|
|
105
166
|
*/
|
|
@@ -234,9 +295,12 @@ var FastCollector = class {
|
|
|
234
295
|
* the optional token meter is consulted, so it never runs in the append path.
|
|
235
296
|
* @param session - the session to snapshot.
|
|
236
297
|
* @param measure - optional token-meter measure function.
|
|
298
|
+
* @param sections - optional named system-prompt sections (from the optional
|
|
299
|
+
* `systemPrompt` service); absent = the whole rendered system prompt is
|
|
300
|
+
* attributed to the `other` bucket.
|
|
237
301
|
* @returns the snapshot.
|
|
238
302
|
*/
|
|
239
|
-
snapshot(session, measure) {
|
|
303
|
+
snapshot(session, measure, sections) {
|
|
240
304
|
const state = this.live.get(session);
|
|
241
305
|
if (state === void 0) return emptySnapshot();
|
|
242
306
|
const measurement = measure === void 0 ? void 0 : measure(session);
|
|
@@ -244,6 +308,11 @@ var FastCollector = class {
|
|
|
244
308
|
const toolSchemaTokens = estimateToolsTokens(state.lastHeader);
|
|
245
309
|
const surfaceTokens = measurement?.surfaceTokens ?? 0;
|
|
246
310
|
const totalTokens = measurement?.totalTokens ?? systemTokens + toolSchemaTokens + surfaceTokens;
|
|
311
|
+
const systemChars = state.lastHeader?.system?.length ?? 0;
|
|
312
|
+
const systemBreakdown = classifySystemSections(sections ?? (systemChars > 0 ? [{
|
|
313
|
+
name: "other",
|
|
314
|
+
text: state.lastHeader.system
|
|
315
|
+
}] : []));
|
|
247
316
|
return {
|
|
248
317
|
load: {
|
|
249
318
|
kind: state.kind,
|
|
@@ -265,7 +334,8 @@ var FastCollector = class {
|
|
|
265
334
|
systemTokens,
|
|
266
335
|
toolSchemaTokens,
|
|
267
336
|
surfaceTokens,
|
|
268
|
-
...sharesOf(totalTokens, systemTokens, toolSchemaTokens, surfaceTokens)
|
|
337
|
+
...sharesOf(totalTokens, systemTokens, toolSchemaTokens, surfaceTokens),
|
|
338
|
+
systemBreakdown
|
|
269
339
|
},
|
|
270
340
|
cache: this.cacheStats(state)
|
|
271
341
|
};
|
|
@@ -340,7 +410,29 @@ function emptySnapshot() {
|
|
|
340
410
|
surfaceTokens: 0,
|
|
341
411
|
systemShare: 0,
|
|
342
412
|
toolsShare: 0,
|
|
343
|
-
surfaceShare: 0
|
|
413
|
+
surfaceShare: 0,
|
|
414
|
+
systemBreakdown: {
|
|
415
|
+
agentsMd: {
|
|
416
|
+
tokens: 0,
|
|
417
|
+
chars: 0,
|
|
418
|
+
share: 0
|
|
419
|
+
},
|
|
420
|
+
skills: {
|
|
421
|
+
tokens: 0,
|
|
422
|
+
chars: 0,
|
|
423
|
+
share: 0
|
|
424
|
+
},
|
|
425
|
+
persona: {
|
|
426
|
+
tokens: 0,
|
|
427
|
+
chars: 0,
|
|
428
|
+
share: 0
|
|
429
|
+
},
|
|
430
|
+
other: {
|
|
431
|
+
tokens: 0,
|
|
432
|
+
chars: 0,
|
|
433
|
+
share: 0
|
|
434
|
+
}
|
|
435
|
+
}
|
|
344
436
|
},
|
|
345
437
|
cache: {
|
|
346
438
|
inputTokens: 0,
|
|
@@ -467,6 +559,12 @@ function renderFastText(report) {
|
|
|
467
559
|
`tool schema: ${context.toolSchemaTokens} (${formatPercent(context.toolsShare)})`,
|
|
468
560
|
`surface: ${context.surfaceTokens} (${formatPercent(context.surfaceShare)})`,
|
|
469
561
|
"",
|
|
562
|
+
"## System prompt breakdown",
|
|
563
|
+
`persona: ${context.systemBreakdown.persona.tokens} tokens / ${context.systemBreakdown.persona.chars} chars (${formatPercent(context.systemBreakdown.persona.share)})`,
|
|
564
|
+
`skills: ${context.systemBreakdown.skills.tokens} tokens / ${context.systemBreakdown.skills.chars} chars (${formatPercent(context.systemBreakdown.skills.share)})`,
|
|
565
|
+
`AGENTS.md: ${context.systemBreakdown.agentsMd.tokens} tokens / ${context.systemBreakdown.agentsMd.chars} chars (${formatPercent(context.systemBreakdown.agentsMd.share)})`,
|
|
566
|
+
`other (harness identity + tool guidance): ${context.systemBreakdown.other.tokens} tokens / ${context.systemBreakdown.other.chars} chars (${formatPercent(context.systemBreakdown.other.share)})`,
|
|
567
|
+
"",
|
|
470
568
|
"## LLM cache",
|
|
471
569
|
`input: ${cache.inputTokens}, cache read: ${cache.cacheReadTokens}, cache write: ${cache.cacheWriteTokens}, output: ${cache.outputTokens}`,
|
|
472
570
|
`hit rate: ${formatPercent(cache.hitRate)}`
|
|
@@ -527,6 +625,19 @@ const compactionSchema = z$1.object({
|
|
|
527
625
|
automatic: z$1.number().int().nonnegative(),
|
|
528
626
|
shadowedTokens: z$1.number().int().nonnegative()
|
|
529
627
|
});
|
|
628
|
+
/** Zod schema for one prompt bucket. */
|
|
629
|
+
const bucketSchema = z$1.object({
|
|
630
|
+
tokens: z$1.number().nonnegative(),
|
|
631
|
+
chars: z$1.number().nonnegative(),
|
|
632
|
+
share: z$1.number()
|
|
633
|
+
});
|
|
634
|
+
/** Zod schema for the system-prompt breakdown. */
|
|
635
|
+
const breakdownSchema = z$1.object({
|
|
636
|
+
agentsMd: bucketSchema,
|
|
637
|
+
skills: bucketSchema,
|
|
638
|
+
persona: bucketSchema,
|
|
639
|
+
other: bucketSchema
|
|
640
|
+
});
|
|
530
641
|
/** Zod schema for the context section. */
|
|
531
642
|
const contextSchema = z$1.object({
|
|
532
643
|
totalTokens: z$1.number().nonnegative(),
|
|
@@ -535,7 +646,8 @@ const contextSchema = z$1.object({
|
|
|
535
646
|
surfaceTokens: z$1.number().nonnegative(),
|
|
536
647
|
systemShare: z$1.number(),
|
|
537
648
|
toolsShare: z$1.number(),
|
|
538
|
-
surfaceShare: z$1.number()
|
|
649
|
+
surfaceShare: z$1.number(),
|
|
650
|
+
systemBreakdown: breakdownSchema
|
|
539
651
|
});
|
|
540
652
|
/** Zod schema for the cache section. */
|
|
541
653
|
const cacheSchema = z$1.object({
|
|
@@ -579,7 +691,7 @@ function appendSample(history, sample, maxSamples) {
|
|
|
579
691
|
//#endregion
|
|
580
692
|
//#region src/version.ts
|
|
581
693
|
/** Single-source plugin version, bumped by `scripts/release.mjs`. @module dsh-fast/version */
|
|
582
|
-
const VERSION = "0.1
|
|
694
|
+
const VERSION = "0.2.1";
|
|
583
695
|
//#endregion
|
|
584
696
|
//#region src/index.ts
|
|
585
697
|
const name = "fast";
|
|
@@ -620,17 +732,31 @@ async function apply(ctx, config = {}) {
|
|
|
620
732
|
return;
|
|
621
733
|
}
|
|
622
734
|
};
|
|
735
|
+
/** Assemble the named system-prompt sections for the per-section breakdown. */
|
|
736
|
+
const assembleSections = async () => {
|
|
737
|
+
const systemPrompt = ctx.get("systemPrompt");
|
|
738
|
+
if (systemPrompt === void 0) return void 0;
|
|
739
|
+
try {
|
|
740
|
+
return (await systemPrompt.assemble()).sections.map((section) => ({
|
|
741
|
+
name: section.name,
|
|
742
|
+
text: section.text
|
|
743
|
+
}));
|
|
744
|
+
} catch (error) {
|
|
745
|
+
logger.warn(`system-prompt section assembly failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
};
|
|
623
749
|
/** Build the complete report for one session. */
|
|
624
|
-
const reportFor = (session) => {
|
|
625
|
-
return buildReport(collector.snapshot(session, measure), {
|
|
750
|
+
const reportFor = async (session) => {
|
|
751
|
+
return buildReport(collector.snapshot(session, measure, await assembleSections()), {
|
|
626
752
|
sessionId: session.id,
|
|
627
753
|
...resolved.includeCwd && session.header.cwd !== void 0 ? { cwd: session.header.cwd } : {},
|
|
628
754
|
generatedAt: Date.now()
|
|
629
755
|
}, resolved, VERSION);
|
|
630
756
|
};
|
|
631
757
|
/** Append one snapshot to the session's durable history (fire-and-forget). */
|
|
632
|
-
const persist = (session) => {
|
|
633
|
-
const snapshot = collector.snapshot(session, measure);
|
|
758
|
+
const persist = async (session) => {
|
|
759
|
+
const snapshot = collector.snapshot(session, measure, await assembleSections());
|
|
634
760
|
const next = appendSample(sessions.get(session.id), {
|
|
635
761
|
at: Date.now(),
|
|
636
762
|
snapshot
|
|
@@ -642,10 +768,10 @@ async function apply(ctx, config = {}) {
|
|
|
642
768
|
ctx.commands.register({
|
|
643
769
|
name: "fast",
|
|
644
770
|
description: "Print the dsh-fast performance report for the active session.",
|
|
645
|
-
handler
|
|
771
|
+
async handler(invocation) {
|
|
646
772
|
return {
|
|
647
773
|
kind: "success",
|
|
648
|
-
text: renderFastText(reportFor(invocation.agent.session))
|
|
774
|
+
text: renderFastText(await reportFor(invocation.agent.session))
|
|
649
775
|
};
|
|
650
776
|
}
|
|
651
777
|
});
|
|
@@ -761,6 +887,89 @@ async function apply(ctx, config = {}) {
|
|
|
761
887
|
surfaceShare: {
|
|
762
888
|
type: "number",
|
|
763
889
|
required: true
|
|
890
|
+
},
|
|
891
|
+
systemBreakdown: {
|
|
892
|
+
type: "object",
|
|
893
|
+
properties: {
|
|
894
|
+
agentsMd: {
|
|
895
|
+
type: "object",
|
|
896
|
+
properties: {
|
|
897
|
+
tokens: {
|
|
898
|
+
type: "number",
|
|
899
|
+
required: true
|
|
900
|
+
},
|
|
901
|
+
chars: {
|
|
902
|
+
type: "number",
|
|
903
|
+
required: true
|
|
904
|
+
},
|
|
905
|
+
share: {
|
|
906
|
+
type: "number",
|
|
907
|
+
required: true
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
additionalProperties: false,
|
|
911
|
+
required: true
|
|
912
|
+
},
|
|
913
|
+
skills: {
|
|
914
|
+
type: "object",
|
|
915
|
+
properties: {
|
|
916
|
+
tokens: {
|
|
917
|
+
type: "number",
|
|
918
|
+
required: true
|
|
919
|
+
},
|
|
920
|
+
chars: {
|
|
921
|
+
type: "number",
|
|
922
|
+
required: true
|
|
923
|
+
},
|
|
924
|
+
share: {
|
|
925
|
+
type: "number",
|
|
926
|
+
required: true
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
additionalProperties: false,
|
|
930
|
+
required: true
|
|
931
|
+
},
|
|
932
|
+
persona: {
|
|
933
|
+
type: "object",
|
|
934
|
+
properties: {
|
|
935
|
+
tokens: {
|
|
936
|
+
type: "number",
|
|
937
|
+
required: true
|
|
938
|
+
},
|
|
939
|
+
chars: {
|
|
940
|
+
type: "number",
|
|
941
|
+
required: true
|
|
942
|
+
},
|
|
943
|
+
share: {
|
|
944
|
+
type: "number",
|
|
945
|
+
required: true
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
additionalProperties: false,
|
|
949
|
+
required: true
|
|
950
|
+
},
|
|
951
|
+
other: {
|
|
952
|
+
type: "object",
|
|
953
|
+
properties: {
|
|
954
|
+
tokens: {
|
|
955
|
+
type: "number",
|
|
956
|
+
required: true
|
|
957
|
+
},
|
|
958
|
+
chars: {
|
|
959
|
+
type: "number",
|
|
960
|
+
required: true
|
|
961
|
+
},
|
|
962
|
+
share: {
|
|
963
|
+
type: "number",
|
|
964
|
+
required: true
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
additionalProperties: false,
|
|
968
|
+
required: true
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
additionalProperties: false,
|
|
972
|
+
required: true
|
|
764
973
|
}
|
|
765
974
|
},
|
|
766
975
|
additionalProperties: false,
|
|
@@ -810,7 +1019,7 @@ async function apply(ctx, config = {}) {
|
|
|
810
1019
|
async execute(_args, exec) {
|
|
811
1020
|
const session = exec.agent?.session;
|
|
812
1021
|
if (session === void 0) throw new Error("fast_report requires an agent-owned session");
|
|
813
|
-
return reportFor(session);
|
|
1022
|
+
return await reportFor(session);
|
|
814
1023
|
}
|
|
815
1024
|
}));
|
|
816
1025
|
ctx.on("session/created", (session) => {
|
|
@@ -841,4 +1050,4 @@ async function apply(ctx, config = {}) {
|
|
|
841
1050
|
});
|
|
842
1051
|
}
|
|
843
1052
|
//#endregion
|
|
844
|
-
export { Config, FastCollector, VERSION, appendSample, apply, buildReport, buildSuggestions, detectSpilledResult, fastDomainSpec, flattenToolResultText, historySchema, hitRateOf, inject, name, renderFastText, resolveConfig, sanitizePath, sanitizeText, sharesOf, stripControl, truncate };
|
|
1053
|
+
export { Config, FastCollector, VERSION, appendSample, apply, buildReport, buildSuggestions, classifySystemSections, detectSpilledResult, fastDomainSpec, flattenToolResultText, historySchema, hitRateOf, inject, name, renderFastText, resolveConfig, sanitizePath, sanitizeText, sharesOf, stripControl, truncate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CA4CzF;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CA4CzF;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA4CzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAUzH"}
|
package/lib/types/analyze.js
CHANGED
|
@@ -80,6 +80,12 @@ export function renderFastText(report) {
|
|
|
80
80
|
`tool schema: ${context.toolSchemaTokens} (${formatPercent(context.toolsShare)})`,
|
|
81
81
|
`surface: ${context.surfaceTokens} (${formatPercent(context.surfaceShare)})`,
|
|
82
82
|
'',
|
|
83
|
+
'## System prompt breakdown',
|
|
84
|
+
`persona: ${context.systemBreakdown.persona.tokens} tokens / ${context.systemBreakdown.persona.chars} chars (${formatPercent(context.systemBreakdown.persona.share)})`,
|
|
85
|
+
`skills: ${context.systemBreakdown.skills.tokens} tokens / ${context.systemBreakdown.skills.chars} chars (${formatPercent(context.systemBreakdown.skills.share)})`,
|
|
86
|
+
`AGENTS.md: ${context.systemBreakdown.agentsMd.tokens} tokens / ${context.systemBreakdown.agentsMd.chars} chars (${formatPercent(context.systemBreakdown.agentsMd.share)})`,
|
|
87
|
+
`other (harness identity + tool guidance): ${context.systemBreakdown.other.tokens} tokens / ${context.systemBreakdown.other.chars} chars (${formatPercent(context.systemBreakdown.other.share)})`,
|
|
88
|
+
'',
|
|
83
89
|
'## LLM cache',
|
|
84
90
|
`input: ${cache.inputTokens}, cache read: ${cache.cacheReadTokens}, cache write: ${cache.cacheWriteTokens}, output: ${cache.outputTokens}`,
|
|
85
91
|
`hit rate: ${formatPercent(cache.hitRate)}`,
|
package/lib/types/analyze.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAS1D;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAsB,EAAE,MAAsB;IAC7E,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,UAAU,CAAA;IAC3B,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAA;IAEtD,IAAI,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAChD,WAAW,CAAC,IAAI,CACd,2BAA2B,OAAO,CAAC,YAAY,sBAAsB,CAAC,CAAC,kBAAkB,kEAAkE,CAC5J,CAAA;IACH,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAClD,WAAW,CA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,EAAE,IAAgB,EAAE,MAAsB,EAAE,OAAe;IAC3G,OAAO;QACL,GAAG,QAAQ;QACX,SAAS,EAAE,UAAU;QACrB,OAAO;QACP,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC;QAC5C,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;KACxE,CAAA;AACH,CAAC"}
|
package/lib/types/collector.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import type { Session, SessionEvent, ToolResultMessage } from '@deepseek-ai/dsh-session';
|
|
11
11
|
import type { FastSnapshot, ContextStats } from './model.js';
|
|
12
12
|
import type { ResolvedConfig } from './config.js';
|
|
13
|
+
import { type SystemSection } from './estimate.js';
|
|
13
14
|
/**
|
|
14
15
|
* The structural surface of the optional `ctx.tokenMeter` service. Only the
|
|
15
16
|
* fields dsh-fast reads are declared; the service is optional, so a host
|
|
@@ -69,9 +70,12 @@ export declare class FastCollector {
|
|
|
69
70
|
* the optional token meter is consulted, so it never runs in the append path.
|
|
70
71
|
* @param session - the session to snapshot.
|
|
71
72
|
* @param measure - optional token-meter measure function.
|
|
73
|
+
* @param sections - optional named system-prompt sections (from the optional
|
|
74
|
+
* `systemPrompt` service); absent = the whole rendered system prompt is
|
|
75
|
+
* attributed to the `other` bucket.
|
|
72
76
|
* @returns the snapshot.
|
|
73
77
|
*/
|
|
74
|
-
snapshot(session: Session, measure?: MeasureFn): FastSnapshot;
|
|
78
|
+
snapshot(session: Session, measure?: MeasureFn, sections?: readonly SystemSection[]): FastSnapshot;
|
|
75
79
|
/** Aggregate cache counters into the report shape. */
|
|
76
80
|
private cacheStats;
|
|
77
81
|
/** Fold one provider usage record. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAc,YAAY,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAc,YAAY,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAqE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAErH;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,gBAAgB,GAAG,SAAS,CAAA;AAK1E,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQxE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAGvE;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAA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ast/collector
|
|
9
9
|
*/
|
|
10
|
-
import { estimateSystemTokens, estimateToolsTokens } from "./estimate.js";
|
|
10
|
+
import { classifySystemSections, estimateSystemTokens, estimateToolsTokens } from "./estimate.js";
|
|
11
11
|
/** The durable marker every spill notice carries (`... Full ... stored at: <locator> ...`). */
|
|
12
12
|
const SPILL_NOTICE_MARKERS = ['Full', 'stored at:'];
|
|
13
13
|
/** Flatten a tool result's model-facing text blocks to one string. */
|
|
@@ -134,9 +134,12 @@ export class FastCollector {
|
|
|
134
134
|
* the optional token meter is consulted, so it never runs in the append path.
|
|
135
135
|
* @param session - the session to snapshot.
|
|
136
136
|
* @param measure - optional token-meter measure function.
|
|
137
|
+
* @param sections - optional named system-prompt sections (from the optional
|
|
138
|
+
* `systemPrompt` service); absent = the whole rendered system prompt is
|
|
139
|
+
* attributed to the `other` bucket.
|
|
137
140
|
* @returns the snapshot.
|
|
138
141
|
*/
|
|
139
|
-
snapshot(session, measure) {
|
|
142
|
+
snapshot(session, measure, sections) {
|
|
140
143
|
const state = this.live.get(session);
|
|
141
144
|
if (state === undefined)
|
|
142
145
|
return emptySnapshot();
|
|
@@ -145,6 +148,8 @@ export class FastCollector {
|
|
|
145
148
|
const toolSchemaTokens = estimateToolsTokens(state.lastHeader);
|
|
146
149
|
const surfaceTokens = measurement?.surfaceTokens ?? 0;
|
|
147
150
|
const totalTokens = measurement?.totalTokens ?? (systemTokens + toolSchemaTokens + surfaceTokens);
|
|
151
|
+
const systemChars = state.lastHeader?.system?.length ?? 0;
|
|
152
|
+
const systemBreakdown = classifySystemSections(sections ?? (systemChars > 0 ? [{ name: 'other', text: state.lastHeader.system }] : []));
|
|
148
153
|
return {
|
|
149
154
|
load: {
|
|
150
155
|
kind: state.kind,
|
|
@@ -164,6 +169,7 @@ export class FastCollector {
|
|
|
164
169
|
toolSchemaTokens,
|
|
165
170
|
surfaceTokens,
|
|
166
171
|
...sharesOf(totalTokens, systemTokens, toolSchemaTokens, surfaceTokens),
|
|
172
|
+
systemBreakdown,
|
|
167
173
|
},
|
|
168
174
|
cache: this.cacheStats(state),
|
|
169
175
|
};
|
|
@@ -229,6 +235,12 @@ function emptySnapshot() {
|
|
|
229
235
|
systemShare: 0,
|
|
230
236
|
toolsShare: 0,
|
|
231
237
|
surfaceShare: 0,
|
|
238
|
+
systemBreakdown: {
|
|
239
|
+
agentsMd: { tokens: 0, chars: 0, share: 0 },
|
|
240
|
+
skills: { tokens: 0, chars: 0, share: 0 },
|
|
241
|
+
persona: { tokens: 0, chars: 0, share: 0 },
|
|
242
|
+
other: { tokens: 0, chars: 0, share: 0 },
|
|
243
|
+
},
|
|
232
244
|
},
|
|
233
245
|
cache: { inputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, outputTokens: 0, hitRate: null },
|
|
234
246
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,mBAAmB,EAAsB,MAAM,eAAe,CAAA;AAgBrH,+FAA+F;AAC/F,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAU,CAAA;AAE5D,sEAAsE;AACtE,MAAM,UAAU,qBAAqB,CAAC,OAA0B;IAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAChC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAClC,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,IAAI,I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d.ts
CHANGED
|
@@ -8,9 +8,26 @@
|
|
|
8
8
|
* @module dsh-fast/estimate
|
|
9
9
|
*/
|
|
10
10
|
import type { EpochHeader } from '@deepseek-ai/dsh-session';
|
|
11
|
+
import type { SystemPromptBreakdown } from './model.js';
|
|
12
|
+
/** One named system-prompt section (name + resolved text). */
|
|
13
|
+
export interface SystemSection {
|
|
14
|
+
name: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
11
17
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
18
|
+
* Classify the named system-prompt sections into the AGENTS.md / skills /
|
|
19
|
+
* persona / other buckets, with heuristic tokens and per-bucket shares. The
|
|
20
|
+
* caller supplies either the real assembled sections (via the optional
|
|
21
|
+
* `systemPrompt` service) or a single synthetic `{ name: 'other' }` section
|
|
22
|
+
* carrying the rendered prompt, so the breakdown always sums to the system
|
|
23
|
+
* prompt.
|
|
24
|
+
* @param sections - named sections (never empty in practice).
|
|
25
|
+
* @returns the per-bucket breakdown.
|
|
26
|
+
*/
|
|
27
|
+
export declare function classifySystemSections(sections: readonly SystemSection[]): SystemPromptBreakdown;
|
|
28
|
+
/**
|
|
29
|
+
* Price the assembled system prompt (harness identity + persona + tool
|
|
30
|
+
* guidance + plugin sections).
|
|
14
31
|
* @param header - canonical request envelope, or undefined before any request.
|
|
15
32
|
* @returns heuristic system-prompt tokens; 0 when absent.
|
|
16
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/estimate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/estimate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAWvD,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAoBD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,qBAAqB,CAehG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAG3E"}
|