dsh-pf-stream 0.0.0-stage → 0.1.2

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.
Files changed (92) hide show
  1. package/LICENSE +201 -0
  2. package/README.en.md +110 -0
  3. package/README.md +109 -2
  4. package/cordis.patch.yml +2 -0
  5. package/lib/entry/adapter.d.ts +21 -0
  6. package/lib/entry/adapter.js +112 -0
  7. package/lib/entry/adapter.js.map +1 -0
  8. package/lib/entry/legacyNormalizer.d.ts +16 -0
  9. package/lib/entry/legacyNormalizer.js +86 -0
  10. package/lib/entry/legacyNormalizer.js.map +1 -0
  11. package/lib/errors.d.ts +7 -0
  12. package/lib/errors.js +12 -0
  13. package/lib/errors.js.map +1 -0
  14. package/lib/index.d.ts +108 -0
  15. package/lib/index.js +109 -0
  16. package/lib/index.js.map +1 -0
  17. package/lib/session/state.d.ts +25 -0
  18. package/lib/session/state.js +255 -0
  19. package/lib/session/state.js.map +1 -0
  20. package/lib/stage0/decoder.d.ts +57 -0
  21. package/lib/stage0/decoder.js +229 -0
  22. package/lib/stage0/decoder.js.map +1 -0
  23. package/lib/stage0/ffmpeg.d.ts +34 -0
  24. package/lib/stage0/ffmpeg.js +90 -0
  25. package/lib/stage0/ffmpeg.js.map +1 -0
  26. package/lib/stage0/probe.d.ts +47 -0
  27. package/lib/stage0/probe.js +150 -0
  28. package/lib/stage0/probe.js.map +1 -0
  29. package/lib/stage1/gradient.d.ts +27 -0
  30. package/lib/stage1/gradient.js +85 -0
  31. package/lib/stage1/gradient.js.map +1 -0
  32. package/lib/stage1/perceive.d.ts +66 -0
  33. package/lib/stage1/perceive.js +233 -0
  34. package/lib/stage1/perceive.js.map +1 -0
  35. package/lib/stage2/stateMachine.d.ts +70 -0
  36. package/lib/stage2/stateMachine.js +180 -0
  37. package/lib/stage2/stateMachine.js.map +1 -0
  38. package/lib/stage2/switchDetector.d.ts +18 -0
  39. package/lib/stage2/switchDetector.js +34 -0
  40. package/lib/stage2/switchDetector.js.map +1 -0
  41. package/lib/stage3/deterministicRouter.d.ts +44 -0
  42. package/lib/stage3/deterministicRouter.js +203 -0
  43. package/lib/stage3/deterministicRouter.js.map +1 -0
  44. package/lib/stage3/streamSampler.d.ts +74 -0
  45. package/lib/stage3/streamSampler.js +497 -0
  46. package/lib/stage3/streamSampler.js.map +1 -0
  47. package/lib/stage4/canvasPacker.d.ts +60 -0
  48. package/lib/stage4/canvasPacker.js +161 -0
  49. package/lib/stage4/canvasPacker.js.map +1 -0
  50. package/lib/stage4/markers.d.ts +19 -0
  51. package/lib/stage4/markers.js +98 -0
  52. package/lib/stage4/markers.js.map +1 -0
  53. package/lib/stage4/viewport.d.ts +61 -0
  54. package/lib/stage4/viewport.js +151 -0
  55. package/lib/stage4/viewport.js.map +1 -0
  56. package/lib/stage5/controller.d.ts +61 -0
  57. package/lib/stage5/controller.js +260 -0
  58. package/lib/stage5/controller.js.map +1 -0
  59. package/lib/stage5/intent.d.ts +27 -0
  60. package/lib/stage5/intent.js +87 -0
  61. package/lib/stage5/intent.js.map +1 -0
  62. package/lib/stage6/history.d.ts +52 -0
  63. package/lib/stage6/history.js +155 -0
  64. package/lib/stage6/history.js.map +1 -0
  65. package/lib/stage6/precheck.d.ts +56 -0
  66. package/lib/stage6/precheck.js +86 -0
  67. package/lib/stage6/precheck.js.map +1 -0
  68. package/lib/tool/handler.d.ts +35 -0
  69. package/lib/tool/handler.js +56 -0
  70. package/lib/tool/handler.js.map +1 -0
  71. package/lib/tool/schema.d.ts +29 -0
  72. package/lib/tool/schema.js +59 -0
  73. package/lib/tool/schema.js.map +1 -0
  74. package/lib/tool/streamCall.d.ts +41 -0
  75. package/lib/tool/streamCall.js +105 -0
  76. package/lib/tool/streamCall.js.map +1 -0
  77. package/lib/types.d.ts +355 -0
  78. package/lib/types.js +11 -0
  79. package/lib/types.js.map +1 -0
  80. package/lib/utils/ffmpegBin.d.ts +20 -0
  81. package/lib/utils/ffmpegBin.js +62 -0
  82. package/lib/utils/ffmpegBin.js.map +1 -0
  83. package/lib/utils/hash.d.ts +13 -0
  84. package/lib/utils/hash.js +24 -0
  85. package/lib/utils/hash.js.map +1 -0
  86. package/lib/utils/image.d.ts +32 -0
  87. package/lib/utils/image.js +135 -0
  88. package/lib/utils/image.js.map +1 -0
  89. package/lib/utils/pts.d.ts +15 -0
  90. package/lib/utils/pts.js +50 -0
  91. package/lib/utils/pts.js.map +1 -0
  92. package/package.json +55 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Weilv-D
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.en.md ADDED
@@ -0,0 +1,110 @@
1
+ # dsh-pf-stream
2
+
3
+ [中文](README.md) | **English**
4
+
5
+ Video perception plugin for DeepSeek Harness (DSH). One tool lets the model "see" local video files:
6
+
7
+ - **Continuous events** → adaptive streaming sampling. During motion, the sampler emits low-token process units by displacement integration. On settle or sharpness peaks, it freezes a high-resolution focus unit.
8
+ - **Suspicious time points** → deterministic inspection: metadata probe, frame extraction at given timestamps, uniform slicing, and local RoI zoom-in.
9
+
10
+ Every canvas aligns with the DeepSeek-V4.1-Flash vision pipeline: 42-px superpixel grid, billing `r×(c+1)+2`. All four forms bill ≤530 tokens, within the 1024-token per-image limit. The server encodes each canvas at its original resolution.
11
+
12
+ ## Capability routing
13
+
14
+ One tool, `dsh-pf-stream`, routes through `intent.action`:
15
+
16
+ | action | engine | use |
17
+ | --- | --- | --- |
18
+ | `pf_stream` (default) | adaptive streaming | 336² process units (P) during motion; 672² focus units (F) on settle/peak. Schmitt four-state machine + two-layer adaptation (intent baseline + content feedback R1-R4) |
19
+ | `timestamps` | deterministic inspection | high-resolution frames at given timestamps; `roi_hint` zoom-in |
20
+ | `uniform` | deterministic inspection | uniform slicing by step or target frame count |
21
+ | `probe` | deterministic inspection | metadata only (display size, rotation, last-frame PTS, stream summary); zero vision tokens |
22
+
23
+ ## Install
24
+
25
+ Requirements:
26
+
27
+ - DSH host (Node ≥ 20).
28
+ - `ffmpeg` and `ffprobe` executables. Search order: plugin config path → `DSH_FFMPEG_PATH` / `FFMPEG_PATH` → `DSH_FFMPEG_DIR` → `~/.dsh/tools/ffmpeg/bin` → `~/.dsh/bin` → `PATH`.
29
+
30
+ Install the package `dsh-pf-stream` in the DSH plugin manager. The host mounts the plugin through `dsh.bundle.patch` (`cordis.patch.yml`). Peer dependencies `@deepseek-ai/cordis` and `@deepseek-ai/schemastery` resolve in the host runtime. The only runtime dependency is `pngjs`; canvas PNG encoding uses fixed parameters, so output bytes are deterministic.
31
+
32
+ ## Usage
33
+
34
+ Streaming perception ("what text is on screen"):
35
+
36
+ ```json
37
+ {
38
+ "video_path": "D:/videos/demo.mp4",
39
+ "intent": { "action": "pf_stream", "focus": "detail", "mode": "dense" }
40
+ }
41
+ ```
42
+
43
+ Point inspection (text found at 12.9 s in a streaming result):
44
+
45
+ ```json
46
+ {
47
+ "video_path": "D:/videos/demo.mp4",
48
+ "intent": {
49
+ "action": "timestamps",
50
+ "timestamps_ms": [12900],
51
+ "roi_hint": { "x": 0.2, "y": 0.3, "w": 0.4, "h": 0.4 }
52
+ }
53
+ }
54
+ ```
55
+
56
+ The top level also accepts common convenience fields from the video-inspection domain: `start_time`, `end_time`, `timestamps`, `fps`, `interval`, `num_frames`, `crop`, `probe_only`. The entry adapter normalizes them into the standard `intent` structure.
57
+
58
+ ## Returned content
59
+
60
+ Each call returns one or more canvas packets:
61
+
62
+ - **PNG canvas**: one of four forms (table below). Two-tone separator lines block edge-feature crosstalk between units; an optional superpixel badge renders unit IDs.
63
+ - **Structured metadata**: `packet_id`, per-unit PTS, token-grid bbox, source-sampling bbox, dual-carrier SHA-256.
64
+ - **Timeline hint line**: a model-readable P/F timeline, for example `[Packet #42 | Anchor: #105 | #101(P, 12.1s, Left-Top) → …]`.
65
+
66
+ Session capabilities:
67
+
68
+ - Intent persists across calls.
69
+ - Streaming cursor resume: the next call on the same video continues from the last position.
70
+ - Two-tier history reference: the hot tier reuses the latest 2 full strips; the cold tier reuses up to 4 independent F-anchor carriers.
71
+ - Epoch compaction: hot-to-cold conversion in batches of 6 packets, keeping the multi-turn Prefix KV-Cache prefix stable.
72
+
73
+ ## Canvas and billing
74
+
75
+ | form | layout | tokens |
76
+ | --- | --- | --- |
77
+ | `FORM_1_STANDARD_STRIP` | 4P + 1F, 1344×672 | 530 |
78
+ | `FORM_2_COMPACT_4P` | 4P, 672×672 | 274 |
79
+ | `FORM_3_COMPACT_1F` | 1F, 672×672 | 274 |
80
+ | `FORM_4_PARTIAL_STRIP` | 1-3P + 1F, 1344×672 | 530 |
81
+
82
+ ## Configuration
83
+
84
+ | option | default | description |
85
+ | --- | --- | --- |
86
+ | `renderVisualId` | `true` | superpixel inverse badge at each unit corner |
87
+ | `maxPacketsPerCall` | `64` | packet count limit per call |
88
+ | `maxTokensBudgetPerCall` | `65536` | vision-token budget per call |
89
+ | `maxRequestBytes` | `56 MiB` | request byte watermark, Base64-inclusive |
90
+ | `maxColdRefs` | `4` | cold-tier reference limit |
91
+ | `defaultStreamWindowMs` | `10000` | window length in ms when `pts_window` is absent |
92
+ | `streamWorkMaxEdge` | `2048` | working-resolution long edge for streaming decode; deterministic inspection always uses full resolution |
93
+ | `epochCompactionWindow` | `6` | hot-to-cold batch window, in packets |
94
+ | `meteringProfile.imageCountTiersEnabled` | `false` | gate for the ≥15-image 4096-px rule |
95
+
96
+ ## Testing
97
+
98
+ ```bash
99
+ pnpm test # boundary (pure logic) + e2e (fixture-driven), 20 boundary cases
100
+ pnpm run build # TypeScript compile
101
+ pnpm verify:host # host-contract self-check (schema shape, keyword subset, dependency boundary)
102
+ ```
103
+
104
+ ## Release
105
+
106
+ npm releases run automatically through GitHub Actions. Process and version policy: [docs/发布规范.md](docs/发布规范.md) (Chinese).
107
+
108
+ ## License
109
+
110
+ Apache-2.0.
package/README.md CHANGED
@@ -1,3 +1,110 @@
1
- # Temporary Holding Version
1
+ # dsh-pf-stream
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **中文** | [English](README.en.md)
4
+
5
+ DeepSeek Harness(DSH)视频感知插件。模型用一个工具即可「看」本地视频:
6
+
7
+ - **连续事件** → 自适应流式采样。运动时按位移积分抽低 token 过程单元;停稳与顿挫波峰时定格高清焦点单元。
8
+ - **可疑时间点** → 确定性检视。能力:元数据探测、指定时间戳抽帧、均匀切片、局部 RoI 放大复核。
9
+
10
+ 全部画布对齐 DeepSeek-V4.1-Flash 视觉编码管线:42px 超像素网格,计费 `r×(c+1)+2`。四种形态计费均 ≤530 token,满足单图 1024 token 上限。服务端按画布原始分辨率计量。
11
+
12
+ ## 能力路由
13
+
14
+ 一个主工具 `dsh-pf-stream`,统一 `intent.action` 路由:
15
+
16
+ | action | 引擎 | 用途 |
17
+ | --- | --- | --- |
18
+ | `pf_stream`(默认) | 动态流式采样 | 运动中抽 336² 过程单元(P);停稳/波峰定格 672² 焦点单元(F)。施密特四状态机 + 双层自适应调节(意图基准 + 内容自闭环 R1-R4) |
19
+ | `timestamps` | 确定性检视 | 指定时间戳单帧/组合高清检视,支持 `roi_hint` 局部放大 |
20
+ | `uniform` | 确定性检视 | 固定步长或目标帧数均匀切片 |
21
+ | `probe` | 确定性检视 | 仅元数据(显示宽高/旋转/末帧 PTS/流摘要),零视觉 token |
22
+
23
+ ## 安装
24
+
25
+ 前置条件:
26
+
27
+ - DSH 宿主(Node ≥ 20)。
28
+ - `ffmpeg` 与 `ffprobe` 可执行文件。定位顺序:插件配置路径 → `DSH_FFMPEG_PATH` / `FFMPEG_PATH` → `DSH_FFMPEG_DIR` → `~/.dsh/tools/ffmpeg/bin` → `~/.dsh/bin` → `PATH`。
29
+
30
+ 在 DSH 插件管理器中安装包 `dsh-pf-stream`。宿主经 `dsh.bundle.patch`(`cordis.patch.yml`)挂载插件。peer 依赖 `@deepseek-ai/cordis` 与 `@deepseek-ai/schemastery` 由宿主运行时解析。运行时直接依赖仅 `pngjs`;画布 PNG 编码参数固定,输出字节幂等。
31
+
32
+ ## 使用
33
+
34
+ 流式感知(问「画面里写了什么」):
35
+
36
+ ```json
37
+ {
38
+ "video_path": "D:/videos/demo.mp4",
39
+ "intent": { "action": "pf_stream", "focus": "detail", "mode": "dense" }
40
+ }
41
+ ```
42
+
43
+ 定点复核(流式结果中 12.9s 处发现文字):
44
+
45
+ ```json
46
+ {
47
+ "video_path": "D:/videos/demo.mp4",
48
+ "intent": {
49
+ "action": "timestamps",
50
+ "timestamps_ms": [12900],
51
+ "roi_hint": { "x": 0.2, "y": 0.3, "w": 0.4, "h": 0.4 }
52
+ }
53
+ }
54
+ ```
55
+
56
+ 顶层同时接受视频检视领域常见便捷字段:`start_time` / `end_time` / `timestamps` / `fps` / `interval` / `num_frames` / `crop` / `probe_only`。入口适配器将其归一化为标准 `intent` 结构。
57
+
58
+ ## 返回内容
59
+
60
+ 每次调用返回一个或多个画布包:
61
+
62
+ - **PNG 画布**:四形态之一(见下表)。单元间双色隔离线阻断相邻边缘特征串扰;可选超像素角标渲染单元编号。
63
+ - **结构化元数据**:`packet_id`、每单元 PTS、token 网格 bbox、源采样 bbox、双载体 SHA-256。
64
+ - **时序提示行**:模型可读的 P/F 单元时间轴(如 `[Packet #42 | Anchor: #105 | #101(P, 12.1s, Left-Top) → …]`)。
65
+
66
+ 会话级能力:
67
+
68
+ - 意图跨调用持久化。
69
+ - 流式游标续窗:同视频下次调用从上次位置继续。
70
+ - 两级历史引用:热区最近 2 包整条带复用;冷区至多 4 个 F 锚点独立载体复用。
71
+ - Epoch Compaction:默认 6 包窗口批量热转冷,保持多轮对话 Prefix KV-Cache 前缀稳定。
72
+
73
+ ## 画布与计费
74
+
75
+ | 形态 | 布局 | Token |
76
+ | --- | --- | --- |
77
+ | `FORM_1_STANDARD_STRIP` | 4P + 1F,1344×672 | 530 |
78
+ | `FORM_2_COMPACT_4P` | 4P,672×672 | 274 |
79
+ | `FORM_3_COMPACT_1F` | 1F,672×672 | 274 |
80
+ | `FORM_4_PARTIAL_STRIP` | 1-3P + 1F,1344×672 | 530 |
81
+
82
+ ## 配置
83
+
84
+ | 配置项 | 默认 | 说明 |
85
+ | --- | --- | --- |
86
+ | `renderVisualId` | `true` | 单元左上角超像素反色角标 |
87
+ | `maxPacketsPerCall` | `64` | 单次调用返回包数上限 |
88
+ | `maxTokensBudgetPerCall` | `65536` | 单次调用视觉 token 预算 |
89
+ | `maxRequestBytes` | `56 MiB` | 请求字节软水位(Base64 后口径) |
90
+ | `maxColdRefs` | `4` | 冷区引用上限 |
91
+ | `defaultStreamWindowMs` | `10000` | `pts_window` 缺省时窗口长度(毫秒) |
92
+ | `streamWorkMaxEdge` | `2048` | 流式解码工作分辨率长边上限(定点检视恒全分辨率) |
93
+ | `epochCompactionWindow` | `6` | 热转冷批量收敛窗口(包数) |
94
+ | `meteringProfile.imageCountTiersEnabled` | `false` | ≥15 图单边 4096px 规则门控 |
95
+
96
+ ## 测试
97
+
98
+ ```bash
99
+ pnpm test # boundary(纯逻辑)+ e2e(fixture 驱动),20 项边界用例
100
+ pnpm run build # TypeScript 编译
101
+ pnpm verify:host # 宿主契约自检(Schema 形状/关键字子集/依赖边界)
102
+ ```
103
+
104
+ ## 发布
105
+
106
+ npm 发布由 GitHub Actions 自动执行。流程与版本策略见 [docs/发布规范.md](docs/发布规范.md)。
107
+
108
+ ## 许可证
109
+
110
+ Apache-2.0。
@@ -0,0 +1,2 @@
1
+ insert:
2
+ - name: dsh-pf-stream
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 入口适配器:顶层调用参数 → 标准 IntentDirective(含校验与钳制)。
3
+ *
4
+ * 校验规则(《五…》§1.3):枚举外值拒绝;pts_window/timestamps_ms 钳制 [0, last_pts_ms];
5
+ * roi_hint 钳制 [0,1];max_packets/max_tokens_budget 钳制到配置上限。
6
+ */
7
+ import type { IntentDirective } from '../types.js';
8
+ export interface AdapterLimits {
9
+ lastPtsMs: number;
10
+ maxPackets: number;
11
+ maxTokensBudget: number;
12
+ }
13
+ export interface AdaptedCall {
14
+ intent: IntentDirective;
15
+ normalizedFrom: string[];
16
+ videoPath: string;
17
+ }
18
+ /**
19
+ * 归一化入口参数。args 为宿主传入的工具参数(含顶层历史便捷字段与 intent)。
20
+ */
21
+ export declare function adaptCallArgs(args: Record<string, unknown>, limits: AdapterLimits): AdaptedCall;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * 入口适配器:顶层调用参数 → 标准 IntentDirective(含校验与钳制)。
3
+ *
4
+ * 校验规则(《五…》§1.3):枚举外值拒绝;pts_window/timestamps_ms 钳制 [0, last_pts_ms];
5
+ * roi_hint 钳制 [0,1];max_packets/max_tokens_budget 钳制到配置上限。
6
+ */
7
+ import { PfStreamError } from '../errors.js';
8
+ import { normalizeLegacyArgs } from './legacyNormalizer.js';
9
+ const ACTIONS = new Set(['pf_stream', 'timestamps', 'uniform', 'probe']);
10
+ const MODES = new Set(['dense', 'standard', 'sparse']);
11
+ const FOCUS = new Set(['motion', 'detail', 'balanced']);
12
+ function isRecord(v) {
13
+ return typeof v === 'object' && v !== null;
14
+ }
15
+ function clampRoi(roi) {
16
+ const x = Math.min(Math.max(roi.x, 0), 1);
17
+ const y = Math.min(Math.max(roi.y, 0), 1);
18
+ const w = Math.min(Math.max(roi.w, 1e-9), 1 - x);
19
+ const h = Math.min(Math.max(roi.h, 1e-9), 1 - y);
20
+ return { x, y, w, h };
21
+ }
22
+ /**
23
+ * 归一化入口参数。args 为宿主传入的工具参数(含顶层历史便捷字段与 intent)。
24
+ */
25
+ export function adaptCallArgs(args, limits) {
26
+ const videoPath = args['video_path'];
27
+ if (typeof videoPath !== 'string' || videoPath.length === 0) {
28
+ throw new PfStreamError('PFSTREAM_ARGS_VIDEO_PATH', 'video_path 必须为非空字符串');
29
+ }
30
+ const legacy = normalizeLegacyArgs(args, limits.lastPtsMs);
31
+ const rawIntent = isRecord(args['intent']) ? args['intent'] : {};
32
+ const intent = {};
33
+ const action = (rawIntent['action'] ?? legacy.intent.action);
34
+ if (action != null) {
35
+ if (!ACTIONS.has(action)) {
36
+ throw new PfStreamError('PFSTREAM_ARGS_ACTION', `action 枚举外值:${String(action)}`);
37
+ }
38
+ intent.action = action;
39
+ }
40
+ const mode = rawIntent['mode'];
41
+ if (mode != null) {
42
+ if (!MODES.has(mode))
43
+ throw new PfStreamError('PFSTREAM_ARGS_MODE', `mode 枚举外值:${String(mode)}`);
44
+ intent.mode = mode;
45
+ }
46
+ const focus = rawIntent['focus'];
47
+ if (focus != null) {
48
+ if (!FOCUS.has(focus))
49
+ throw new PfStreamError('PFSTREAM_ARGS_FOCUS', `focus 枚举外值:${String(focus)}`);
50
+ intent.focus = focus;
51
+ }
52
+ const roiRaw = (rawIntent['roi_hint'] ?? legacy.intent.roi_hint);
53
+ if (roiRaw != null) {
54
+ intent.roi_hint = clampRoi(roiRaw);
55
+ }
56
+ if (rawIntent['full_frame'] === true)
57
+ intent.full_frame = true;
58
+ const windowRaw = (rawIntent['pts_window'] ?? legacy.intent.pts_window);
59
+ if (windowRaw != null) {
60
+ if (!Array.isArray(windowRaw) || windowRaw.length !== 2) {
61
+ throw new PfStreamError('PFSTREAM_ARGS_WINDOW', 'pts_window 必须为 [start_ms, end_ms]');
62
+ }
63
+ const w0 = clampMs(windowRaw[0], limits.lastPtsMs);
64
+ const w1 = clampMs(windowRaw[1], limits.lastPtsMs);
65
+ intent.pts_window = [Math.min(w0, w1), Math.max(w0, w1)];
66
+ }
67
+ const tsRaw = (rawIntent['timestamps_ms'] ?? legacy.intent.timestamps_ms);
68
+ if (tsRaw != null) {
69
+ if (!Array.isArray(tsRaw) || tsRaw.length < 1) {
70
+ throw new PfStreamError('PFSTREAM_ARGS_TIMESTAMPS', 'timestamps_ms 必须为非空数组');
71
+ }
72
+ if (intent.action == null)
73
+ intent.action = 'timestamps';
74
+ intent.timestamps_ms = tsRaw.map((t) => clampMs(t, limits.lastPtsMs));
75
+ }
76
+ const intervalRaw = (rawIntent['interval_ms'] ?? legacy.intent.interval_ms);
77
+ if (intervalRaw != null) {
78
+ if (typeof intervalRaw !== 'number' || !(intervalRaw > 0)) {
79
+ throw new PfStreamError('PFSTREAM_ARGS_INTERVAL', 'interval_ms 必须为正数');
80
+ }
81
+ if (intent.action == null)
82
+ intent.action = 'uniform';
83
+ intent.interval_ms = intervalRaw;
84
+ }
85
+ const fcRaw = (rawIntent['frame_count'] ?? legacy.intent.frame_count);
86
+ if (fcRaw != null) {
87
+ if (typeof fcRaw !== 'number' || !(fcRaw >= 1)) {
88
+ throw new PfStreamError('PFSTREAM_ARGS_FRAME_COUNT', 'frame_count 必须为 ≥1 整数');
89
+ }
90
+ if (intent.action == null)
91
+ intent.action = 'uniform';
92
+ intent.frame_count = Math.min(Math.round(fcRaw), 128);
93
+ }
94
+ const mpRaw = rawIntent['max_packets'];
95
+ if (mpRaw != null && typeof mpRaw === 'number' && mpRaw >= 1) {
96
+ intent.max_packets = Math.min(Math.round(mpRaw), limits.maxPackets);
97
+ }
98
+ const mtbRaw = rawIntent['max_tokens_budget'];
99
+ if (mtbRaw != null && typeof mtbRaw === 'number' && mtbRaw >= 274) {
100
+ intent.max_tokens_budget = Math.min(Math.round(mtbRaw), limits.maxTokensBudget);
101
+ }
102
+ if (rawIntent['reset'] === true)
103
+ intent.reset = true;
104
+ return { intent, normalizedFrom: legacy.normalizedFrom, videoPath };
105
+ }
106
+ function clampMs(v, lastPtsMs) {
107
+ const n = typeof v === 'number' ? v : Number(v);
108
+ if (!Number.isFinite(n))
109
+ throw new PfStreamError('PFSTREAM_ARGS_PTS', `PTS 值非法:${String(v)}`);
110
+ return Math.min(Math.max(Math.round(n), 0), lastPtsMs);
111
+ }
112
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/entry/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAyB,MAAM,uBAAu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I,aAAa,CAAC,mBAAmB,EAAE,WAAW,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 历史便捷字段归一化(《五、双层自适应调节与统一参数映射》§1.1)。
3
+ *
4
+ * 输入便利层:start_time/end_time/time_range/timestamps/fps/interval/num_frames/
5
+ * frame_count/crop/bbox/roi/probe_only → 标准 IntentDirective 字段。
6
+ * 判秒规则:数值 ≤ 时长(秒)×1.5 判秒,超过判毫秒;归一化来源记入 normalizedFrom。
7
+ */
8
+ import type { IntentDirective } from '../types.js';
9
+ export interface NormalizedIntent {
10
+ intent: IntentDirective;
11
+ /** 触发了归一化的来源字段名列表(审计与 normalized_from 元数据用)。 */
12
+ normalizedFrom: string[];
13
+ }
14
+ /** 数值或字符串时间 → 毫秒(判秒规则见模块注释)。 */
15
+ export declare function toMs(value: number | string, durationMs: number): number;
16
+ export declare function normalizeLegacyArgs(args: Record<string, unknown>, durationMs: number): NormalizedIntent;