@dsh-cc/tool-web-fetch 0.5.0
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/LICENSE +201 -0
- package/README.md +45 -0
- package/README.zh.md +39 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +171 -0
- package/lib/index.js.map +1 -0
- package/lib/invariant.d.ts +16 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +23 -0
- package/lib/invariant.js.map +1 -0
- package/package.json +52 -0
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 the 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 [yyyy] [name of copyright owner]
|
|
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.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @dsh-cc/tool-web-fetch
|
|
2
|
+
|
|
3
|
+
CC-style `web_fetch` replacement with an optional `prompt`. This package replaces the
|
|
4
|
+
stock `@deepseek-ai/dsh-tool-web` `web_fetch` when the CC preset sets `tool-web` to
|
|
5
|
+
`fetch: false` and mounts this row in `cc-services` instead.
|
|
6
|
+
|
|
7
|
+
## Behavior
|
|
8
|
+
|
|
9
|
+
- **Without `prompt`** (or with a blank/whitespace one): identical to the stock tool —
|
|
10
|
+
the raw converted page text is returned.
|
|
11
|
+
- **With `prompt`** and a configured `haiku` model alias (`ccModelRoutes.resolve('haiku')`):
|
|
12
|
+
the fetched document is converted and passed, together with the prompt, to a one-shot
|
|
13
|
+
summarize call on that cheap lane. The tool returns only the extraction. A string-form
|
|
14
|
+
alias (`haiku: deepseek-v4-flash`, model only) inherits the missing provider from the
|
|
15
|
+
calling agent's request-header; with no calling agent (hence no parent provider) the
|
|
16
|
+
tool fails hard.
|
|
17
|
+
- **With `prompt`** but the `haiku` alias unconfigured (no `ccModelRoutes` service or the
|
|
18
|
+
resolver returns nothing): the tool throws
|
|
19
|
+
`web_fetch: prompt requires a configured haiku model alias` **before any fetch is
|
|
20
|
+
performed** — the page is not fetched, streamed, or returned.
|
|
21
|
+
|
|
22
|
+
The summarize call never carries a `purpose` field: the harness `GenerateOptions.purpose`
|
|
23
|
+
union is closed (`'compaction' | 'session-title'`). A summary model that requests a tool
|
|
24
|
+
or produces no text fails the call as an `isError` tool result.
|
|
25
|
+
|
|
26
|
+
## Provider requirement
|
|
27
|
+
|
|
28
|
+
CC deployments get a fetch executor from the cc-shell bundle, which mounts
|
|
29
|
+
`@dsh-cc/web-fetch-http` (wrapping `HttpFetchProvider`, with a literal
|
|
30
|
+
SSRF gate). This package itself does not register a provider; tests fake
|
|
31
|
+
`ctx.web.fetch`.
|
|
32
|
+
|
|
33
|
+
## Prompt guidance interplay
|
|
34
|
+
|
|
35
|
+
Setting `tool-web` `fetch: false` also drops the stock "Follow up with web_fetch" clause
|
|
36
|
+
from the `web_search` system-prompt section. This package re-registers the
|
|
37
|
+
`tool:web_fetch` prompt section (order 111) covering fetch guidance.
|
|
38
|
+
|
|
39
|
+
## Known limits
|
|
40
|
+
|
|
41
|
+
- No host allowlist in this package: the literal SSRF gate (private/loopback/
|
|
42
|
+
link-local literals blocked) lives in the `@dsh-cc/web-fetch-http`
|
|
43
|
+
wrapper mounted from cc-shell. Residual risk: DNS rebinding — upstream
|
|
44
|
+
webfetch-ssrf-allowlist (DNS-pin / per-hop re-validation) remains a follow-up.
|
|
45
|
+
- Tavily / Firecrawl are plugins/skills, not fetch backends for this tool.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @dsh-cc/tool-web-fetch
|
|
2
|
+
|
|
3
|
+
CC 风格的 `web_fetch` 替代工具,带可选 `prompt` 参数。当 CC preset 将 `tool-web` 配置为
|
|
4
|
+
`fetch: false` 并在 `cc-services` 内挂载本包时,本包取代 stock `@deepseek-ai/dsh-tool-web`
|
|
5
|
+
的 `web_fetch`。
|
|
6
|
+
|
|
7
|
+
## 行为
|
|
8
|
+
|
|
9
|
+
- **不传 `prompt`**(或为空白):与 stock 工具完全一致——返回原始转换后的页面文本。
|
|
10
|
+
- **传 `prompt`** 且已配置 `haiku` 模型别名(`ccModelRoutes.resolve('haiku')`):
|
|
11
|
+
抓取的文档经转换后与 prompt 一起送入该廉价 lane 上的一次性摘要调用,工具只返回提取结果。
|
|
12
|
+
字符串形式别名(`haiku: deepseek-v4-flash`,仅 model)会从调用方 agent 的 request-header 继承缺失的 provider;
|
|
13
|
+
没有调用方 agent(即无父 provider)时工具直接失败。
|
|
14
|
+
- **传 `prompt`** 但 `haiku` 别名未配置(无 `ccModelRoutes` 服务或 resolver 返回空):
|
|
15
|
+
工具抛出 `web_fetch: prompt requires a configured haiku model alias`,且**在任何抓取之前**——
|
|
16
|
+
页面不会被抓取、流式调用或返回。
|
|
17
|
+
|
|
18
|
+
摘要调用不携带 `purpose` 字段:harness `GenerateOptions.purpose` 是封闭联合
|
|
19
|
+
(`'compaction' | 'session-title'`)。摘要模型请求工具或未产出文本时,调用以
|
|
20
|
+
`isError` 工具结果失败。
|
|
21
|
+
|
|
22
|
+
## Provider 要求
|
|
23
|
+
|
|
24
|
+
CC 部署通过 cc-shell bundle 获得 fetch 执行器:其挂载
|
|
25
|
+
`@dsh-cc/web-fetch-http`(包装 `HttpFetchProvider`,带字面量 SSRF 门禁)。
|
|
26
|
+
本包自身不注册 provider。测试通过 fake `ctx.web.fetch` 进行。
|
|
27
|
+
|
|
28
|
+
## Prompt 指引的相互影响
|
|
29
|
+
|
|
30
|
+
将 `tool-web` 设为 `fetch: false` 同时会从 `web_search` 的 system-prompt 段落中
|
|
31
|
+
移除 stock 的 "Follow up with web_fetch" 子句。本包重新注册 `tool:web_fetch`
|
|
32
|
+
段落(order 111)补齐 fetch 指引。
|
|
33
|
+
|
|
34
|
+
## 已知限制
|
|
35
|
+
|
|
36
|
+
- 本包无 host allowlist:字面量 SSRF 门禁(阻止私有/回环/链路本地字面量)位于
|
|
37
|
+
cc-shell 挂载的 `@dsh-cc/web-fetch-http` 包装器中。残余风险:DNS rebinding——
|
|
38
|
+
上游 webfetch-ssrf-allowlist(DNS-pin / 逐跳重校验)仍是后续事项。
|
|
39
|
+
- Tavily / Firecrawl 是插件/skill,不是本工具的 fetch 后端。
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CC-style `web_fetch` replacement with an optional `prompt`. The stock
|
|
3
|
+
* harness tool returns the raw converted page; this one adds a model-facing
|
|
4
|
+
* `prompt` parameter and, when the cheap lane (`haiku` alias) is configured,
|
|
5
|
+
* one-shot summarizes the fetched document against that instruction. Passing
|
|
6
|
+
* a `prompt` without a configured cheap lane is a hard failure: the tool
|
|
7
|
+
* throws `WebFetchError` before any network request is made.
|
|
8
|
+
* @module @dsh-cc/tool-web-fetch
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import z from '@deepseek-ai/schemastery';
|
|
12
|
+
export declare const name = "tool-web-fetch";
|
|
13
|
+
export declare const inject: string[];
|
|
14
|
+
/** Runtime configuration for the WebFetch tool. */
|
|
15
|
+
export interface Config {
|
|
16
|
+
/** Cooperative tool-call timeout budget (ms), attached as the tool's `timeoutMs`. */
|
|
17
|
+
fetchTimeoutMs?: number;
|
|
18
|
+
/** Cap on the complete rendered `web_fetch` output characters. */
|
|
19
|
+
fetchMaxOutputChars?: number;
|
|
20
|
+
/** Token budget for the one-shot summarize call. */
|
|
21
|
+
maxSummaryTokens?: number;
|
|
22
|
+
/** Character cap on the document converted and fed to the summarize call. */
|
|
23
|
+
maxSummaryInputChars?: number;
|
|
24
|
+
}
|
|
25
|
+
/** Runtime configuration schema. */
|
|
26
|
+
export declare const Config: z<Config>;
|
|
27
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAQxC,eAAO,MAAM,IAAI,mBAAmB,CAAA;AACpC,eAAO,MAAM,MAAM,UAA0C,CAAA;AAE7D,mDAAmD;AACnD,MAAM,WAAW,MAAM;IACrB,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,oCAAoC;AACpC,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAK3B,CAAA;AAgBF,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAwJ7D"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CC-style `web_fetch` replacement with an optional `prompt`. The stock
|
|
3
|
+
* harness tool returns the raw converted page; this one adds a model-facing
|
|
4
|
+
* `prompt` parameter and, when the cheap lane (`haiku` alias) is configured,
|
|
5
|
+
* one-shot summarizes the fetched document against that instruction. Passing
|
|
6
|
+
* a `prompt` without a configured cheap lane is a hard failure: the tool
|
|
7
|
+
* throws `WebFetchError` before any network request is made.
|
|
8
|
+
* @module @dsh-cc/tool-web-fetch
|
|
9
|
+
*/
|
|
10
|
+
import z from '@deepseek-ai/schemastery';
|
|
11
|
+
import { BlockAssembler, createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
12
|
+
import { fetchMetaFromValue, formatFetchOutput, parseFetchArgs, presentFetchCall, presentFetchResult } from '@deepseek-ai/dsh-tool-web';
|
|
13
|
+
import { toOneShotRoute } from '@dsh-cc/model-aliases';
|
|
14
|
+
import { defineTool } from '@dsh-cc/tools';
|
|
15
|
+
export const name = 'tool-web-fetch';
|
|
16
|
+
export const inject = ['tools', 'web', 'systemPrompt', 'llm'];
|
|
17
|
+
/** Runtime configuration schema. */
|
|
18
|
+
export const Config = z.object({
|
|
19
|
+
fetchTimeoutMs: z.number(),
|
|
20
|
+
fetchMaxOutputChars: z.number(),
|
|
21
|
+
maxSummaryTokens: z.number(),
|
|
22
|
+
maxSummaryInputChars: z.number(),
|
|
23
|
+
});
|
|
24
|
+
/** Defaults applied by the config schema. */
|
|
25
|
+
const DEFAULTS = {
|
|
26
|
+
fetchTimeoutMs: 30_000,
|
|
27
|
+
fetchMaxOutputChars: 200_000,
|
|
28
|
+
maxSummaryTokens: 2048,
|
|
29
|
+
maxSummaryInputChars: 32_000,
|
|
30
|
+
};
|
|
31
|
+
/** Model-visible failure (maps to an isError tool result). */
|
|
32
|
+
class WebFetchError extends Error {
|
|
33
|
+
}
|
|
34
|
+
export function apply(ctx, config = {}) {
|
|
35
|
+
const resolved = {
|
|
36
|
+
...DEFAULTS,
|
|
37
|
+
...Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined)),
|
|
38
|
+
};
|
|
39
|
+
ctx.systemPrompt.section({
|
|
40
|
+
name: 'tool:web_fetch',
|
|
41
|
+
order: 111,
|
|
42
|
+
text: 'Use the web_fetch tool to retrieve the content of a specific HTTP(S) URL (for example a result from web_search). '
|
|
43
|
+
+ 'Omit prompt to receive the page decoded to text (HTML is converted to markdown). If you pass prompt, a configured haiku '
|
|
44
|
+
+ 'alias summarizes the page against that instruction on the cheap lane and you receive only the extraction — the call '
|
|
45
|
+
+ 'fails if haiku is not configured. Cite the URL as a markdown link when you use its content. Cross-origin redirects are '
|
|
46
|
+
+ 'not followed; fetch the Location URL in a new call.',
|
|
47
|
+
});
|
|
48
|
+
// The harness presenters/format helpers carry harness `dsh-tools` lib types,
|
|
49
|
+
// which are structurally compatible at runtime but nominal-incompatible with
|
|
50
|
+
// the cc-tools `ToolDefinition` under `exactOptionalPropertyTypes` — the
|
|
51
|
+
// established seam cast (see memory/hooks tests).
|
|
52
|
+
const tool = defineTool({
|
|
53
|
+
name: 'web_fetch',
|
|
54
|
+
description: 'Fetch the content of a specific HTTP(S) URL and return it decoded to text. '
|
|
55
|
+
+ 'If prompt is set, a configured haiku alias summarizes the page against that instruction on the cheap lane '
|
|
56
|
+
+ 'and you receive only the extraction; the call fails if haiku is not configured.',
|
|
57
|
+
parameters: {
|
|
58
|
+
url: { type: 'string', required: true, description: 'The HTTP(S) URL to fetch.' },
|
|
59
|
+
prompt: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'If set, extract/summarize the page against this instruction. Omit to receive the raw page text.',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
output: {
|
|
65
|
+
schema: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
properties: {
|
|
69
|
+
url: { type: 'string', required: true },
|
|
70
|
+
statusCode: { type: 'integer', required: true },
|
|
71
|
+
body: {
|
|
72
|
+
required: true,
|
|
73
|
+
oneOf: [
|
|
74
|
+
{
|
|
75
|
+
type: 'object',
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
properties: {
|
|
78
|
+
kind: { type: 'string', required: true, const: 'html' },
|
|
79
|
+
content: { type: 'string', required: true },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'object',
|
|
84
|
+
additionalProperties: false,
|
|
85
|
+
properties: {
|
|
86
|
+
kind: { type: 'string', required: true, const: 'text' },
|
|
87
|
+
content: { type: 'string', required: true },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
truncated: { type: 'boolean', required: true },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
render: (_args, value) => [{ type: 'text', text: formatFetchOutput(value, resolved.fetchMaxOutputChars) }],
|
|
96
|
+
presentationMeta: (_args, value) => fetchMetaFromValue(value, resolved.fetchMaxOutputChars),
|
|
97
|
+
},
|
|
98
|
+
timeoutMs: resolved.fetchTimeoutMs,
|
|
99
|
+
// Provider reads do not mutate parent-agent state.
|
|
100
|
+
isConcurrencySafe: () => true,
|
|
101
|
+
presentCall: presentFetchCall,
|
|
102
|
+
presentResult: presentFetchResult,
|
|
103
|
+
async execute(args, exec) {
|
|
104
|
+
const input = parseFetchArgs({ url: args.url });
|
|
105
|
+
const prompt = typeof args.prompt === 'string' ? args.prompt.trim() : '';
|
|
106
|
+
if (prompt.length === 0) {
|
|
107
|
+
const result = await ctx.web.fetch({ url: input.url }, exec.signal);
|
|
108
|
+
return {
|
|
109
|
+
url: result.url,
|
|
110
|
+
statusCode: result.statusCode,
|
|
111
|
+
body: { kind: result.body.kind, content: result.body.content },
|
|
112
|
+
truncated: result.truncated,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// Lazy by contract: the row lives in cc-services, but unit tests that
|
|
116
|
+
// only provide a fake seam must be able to load this plugin.
|
|
117
|
+
const routes = ctx.get('ccModelRoutes');
|
|
118
|
+
// The calling agent's logged request header fills the provider for a
|
|
119
|
+
// string-form (model-only) haiku alias; absent a calling agent the
|
|
120
|
+
// pair cannot be completed and the tool fails hard before fetching.
|
|
121
|
+
const parent = exec.agent?.session.requestHeader()?.config;
|
|
122
|
+
const filled = toOneShotRoute(routes?.resolve('haiku'), parent);
|
|
123
|
+
if (filled === undefined) {
|
|
124
|
+
throw new WebFetchError('web_fetch: prompt requires a configured haiku model alias');
|
|
125
|
+
}
|
|
126
|
+
const result = await ctx.web.fetch({ url: input.url }, exec.signal);
|
|
127
|
+
const converted = formatFetchOutput(result, resolved.maxSummaryInputChars);
|
|
128
|
+
// One-shot summarize on the cheap lane. `purpose` is omitted on
|
|
129
|
+
// purpose: the harness GenerateOptions purpose union is closed
|
|
130
|
+
// ('compaction' | 'session-title') and does not admit a fetch reason.
|
|
131
|
+
const options = {
|
|
132
|
+
provider: filled.provider,
|
|
133
|
+
model: filled.model,
|
|
134
|
+
maxTokens: resolved.maxSummaryTokens,
|
|
135
|
+
system: 'Extract/summarize the fetched document to answer the user prompt. Return only the extraction. Cite the URL as a markdown link.',
|
|
136
|
+
messages: [createUserMessage({
|
|
137
|
+
content: [{ type: 'text', text: `Prompt:\n${prompt}\n\nDocument:\n${converted}` }],
|
|
138
|
+
source: { kind: 'plugin', plugin: name },
|
|
139
|
+
})],
|
|
140
|
+
signal: exec.signal,
|
|
141
|
+
};
|
|
142
|
+
const assembler = new BlockAssembler();
|
|
143
|
+
for await (const chunk of ctx.llm.stream(options)) {
|
|
144
|
+
assembler.push(chunk);
|
|
145
|
+
}
|
|
146
|
+
// Terminal finish kinds agree with block inspection: either signals a
|
|
147
|
+
// misbehaving summary model.
|
|
148
|
+
if (assembler.finish?.kind === 'tool-calls') {
|
|
149
|
+
throw new WebFetchError('web_fetch: summary model unexpectedly requested a tool');
|
|
150
|
+
}
|
|
151
|
+
if (assembler.blocks().some(block => block.type === 'tool-call')) {
|
|
152
|
+
throw new WebFetchError('web_fetch: summary model unexpectedly requested a tool');
|
|
153
|
+
}
|
|
154
|
+
const text = assembler.blocks()
|
|
155
|
+
.filter(block => block.type === 'text')
|
|
156
|
+
.map(block => block.text)
|
|
157
|
+
.join(' ')
|
|
158
|
+
.trim();
|
|
159
|
+
if (text.length === 0)
|
|
160
|
+
throw new WebFetchError('web_fetch: summary model produced no text');
|
|
161
|
+
return {
|
|
162
|
+
url: result.url,
|
|
163
|
+
statusCode: result.statusCode,
|
|
164
|
+
body: { kind: 'text', content: text },
|
|
165
|
+
truncated: result.truncated,
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
ctx.tools.register(tool);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACvI,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,MAAM,CAAC,MAAM,IAAI,GAAG,gBAAgB,CAAA;AACpC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,CAAA;AAc7D,oCAAoC;AACpC,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC/B,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;CACjC,CAAC,CAAA;AAKF,6CAA6C;AAC7C,MAAM,QAAQ,GAAmB;IAC/B,cAAc,EAAE,MAAM;IACtB,mBAAmB,EAAE,OAAO;IAC5B,gBAAgB,EAAE,IAAI;IACtB,oBAAoB,EAAE,MAAM;CAC7B,CAAA;AAED,8DAA8D;AAC9D,MAAM,aAAc,SAAQ,KAAK;CAAG;AAEpC,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,SAAiB,EAAE;IACrD,MAAM,QAAQ,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AAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,IAAI,aAAa,CAAC,2CAA2C,CAAC,CAAA;YAC3F,OAAO;gBACL,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;gBACrC,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IACF,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAA2D,CAAC,CAAA;AACjF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@dsh-cc/tool-web-fetch`.
|
|
3
|
+
* @module @dsh-cc/tool-web-fetch/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "tool-web-fetch-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,6BAA6B,CAAA;AAC9C,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAiB,CAAA;AASpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@dsh-cc/tool-web-fetch`.
|
|
3
|
+
* @module @dsh-cc/tool-web-fetch/invariant
|
|
4
|
+
*/
|
|
5
|
+
const PACKAGE_NAME = '@dsh-cc/tool-web-fetch';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export const name = 'tool-web-fetch-invariant';
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export const inject = ['invariants'];
|
|
10
|
+
/**
|
|
11
|
+
* No runtime invariant: the tool composes an upstream seam (`ctx.web.fetch`)
|
|
12
|
+
* with a one-shot summarize call, neither of which publishes a durable
|
|
13
|
+
* projection a companion could cross-check.
|
|
14
|
+
*/
|
|
15
|
+
const install = () => { };
|
|
16
|
+
/**
|
|
17
|
+
* Register this package's invariant companion.
|
|
18
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
+
*/
|
|
21
|
+
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
+
/* jscpd:ignore-end */
|
|
23
|
+
//# sourceMappingURL=invariant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.js","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,YAAY,GAAG,wBAAwB,CAAA;AAE7C,oCAAoC;AACpC,MAAM,CAAC,MAAM,IAAI,GAAG,0BAA0B,CAAA;AAC9C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,YAAY,CAAC,CAAA;AAEpC;;;;GAIG;AACH,MAAM,OAAO,GAAuB,GAAG,EAAE,GAAE,CAAC,CAAA;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAY,EAAuB,EAAE,CACzD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;AACjE,sBAAsB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-cc/tool-web-fetch",
|
|
3
|
+
"description": "CC-style web_fetch replacement with an optional prompt: summarizes the fetched page on the cheap lane (haiku alias) when configured; passing a prompt without haiku fails before fetching",
|
|
4
|
+
"version": "0.5.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dsh-cc/dsh-cc.git",
|
|
8
|
+
"directory": "packages/core/tool-web-fetch"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./invariant": {
|
|
17
|
+
"types": "./lib/invariant.d.ts",
|
|
18
|
+
"default": "./lib/invariant.js"
|
|
19
|
+
},
|
|
20
|
+
"./src/*": "./src/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"license": "Apache-2.0",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@deepseek-ai/cordis": ">=0.1.1-rc.2",
|
|
29
|
+
"@deepseek-ai/dsh-invariants": ">=0.1.1-rc.2",
|
|
30
|
+
"@deepseek-ai/dsh-llm": ">=0.1.1-rc.2",
|
|
31
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.1.1-rc.2",
|
|
32
|
+
"@deepseek-ai/dsh-tool-web": ">=0.1.1-rc.2",
|
|
33
|
+
"@deepseek-ai/dsh-web": ">=0.1.1-rc.2",
|
|
34
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
35
|
+
"@dsh-cc/model-aliases": "^0.5.0",
|
|
36
|
+
"@dsh-cc/tools": "^0.5.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "link:../../../../deepseek-harness/packages/runtime-diagnostics/invariants",
|
|
41
|
+
"@deepseek-ai/dsh-llm": "link:../../../../deepseek-harness/packages/llm/llm",
|
|
42
|
+
"@deepseek-ai/dsh-system-prompt": "link:../../../../deepseek-harness/packages/core/system-prompt",
|
|
43
|
+
"@deepseek-ai/dsh-tool-web": "link:../../../../deepseek-harness/packages/web/tool-web",
|
|
44
|
+
"@deepseek-ai/dsh-web": "link:../../../../deepseek-harness/packages/web/web",
|
|
45
|
+
"@deepseek-ai/schemastery": "link:../../../../deepseek-harness/vendor/schemastery",
|
|
46
|
+
"@dsh-cc/model-aliases": "^0.5.0",
|
|
47
|
+
"@dsh-cc/tools": "^0.5.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|