@scotthuang/openclaw-bytedance 0.1.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 +21 -0
- package/README.md +222 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/src/bytedance-web-search-provider.d.ts +3 -0
- package/dist/src/bytedance-web-search-provider.d.ts.map +1 -0
- package/dist/src/bytedance-web-search-provider.js +92 -0
- package/dist/src/bytedance-web-search-provider.js.map +1 -0
- package/dist/src/bytedance-web-search-provider.runtime.d.ts +71 -0
- package/dist/src/bytedance-web-search-provider.runtime.d.ts.map +1 -0
- package/dist/src/bytedance-web-search-provider.runtime.js +314 -0
- package/dist/src/bytedance-web-search-provider.runtime.js.map +1 -0
- package/dist/src/credentials.d.ts +42 -0
- package/dist/src/credentials.d.ts.map +1 -0
- package/dist/src/credentials.js +93 -0
- package/dist/src/credentials.js.map +1 -0
- package/dist/src/logger.d.ts +41 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +69 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/media-understanding-provider.d.ts +3 -0
- package/dist/src/media-understanding-provider.d.ts.map +1 -0
- package/dist/src/media-understanding-provider.js +288 -0
- package/dist/src/media-understanding-provider.js.map +1 -0
- package/openclaw.plugin.json +82 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 openclaw-bytedance contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# @scotthuang/openclaw-bytedance
|
|
2
|
+
|
|
3
|
+
> OpenClaw plugin for **ByteDance Volcengine Ark** — adds two tools to your OpenClaw agent:
|
|
4
|
+
>
|
|
5
|
+
> 1. **Web Search** — via Volcengine Ark Harness ("AskEcho Search Infinity"), the same backend the official `volcengine/mcp-server` package wraps
|
|
6
|
+
> 2. **Image Understanding** — via Doubao multimodal models (default: `doubao-seed-2.0-pro`)
|
|
7
|
+
|
|
8
|
+
This plugin is open-source and **never bundles any API key**. You configure your own credentials via environment variables or the OpenClaw config file.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
| Capability | Backend | Default Model |
|
|
15
|
+
| ------------------ | -------------------------------------------------------------- | ----------------------- |
|
|
16
|
+
| Web Search | `POST open.feedcoopapi.com/search_api/web_search` | (no model — direct API) |
|
|
17
|
+
| Image Understanding| `POST {ARK_BASE_URL}/chat/completions` (Agent Plan) | `doubao-seed-2.0-pro` |
|
|
18
|
+
|
|
19
|
+
The web-search tool returns **titles, URLs, snippets, AI-generated summaries, publish dates, and site names** — wrapped in OpenClaw's untrusted-content envelope so prompts stay safe.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Two API keys, by design
|
|
24
|
+
|
|
25
|
+
Volcengine Ark splits chat/vision and search across two products with separate quotas. The plugin reflects that:
|
|
26
|
+
|
|
27
|
+
| Capability | Env var | Console location |
|
|
28
|
+
| ------------------- | ---------------------------------------- | ----------------------------------------------------- |
|
|
29
|
+
| Vision / chat | `ARK_API_KEY` | Agent Plan → API Key 管理 |
|
|
30
|
+
| Web search | `ARK_SEARCH_API_KEY` (or `ASK_ECHO_SEARCH_INFINITY_API_KEY`) | Agent Plan → 使用配置 → 配置 Harness → 联网 API Key |
|
|
31
|
+
|
|
32
|
+
You can configure either, both, or neither. Tools whose key is missing return a clear "missing key" error.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
End users (let OpenClaw install it from npm):
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# inside your OpenClaw config / extension manager
|
|
42
|
+
# add @scotthuang/openclaw-bytedance to the plugins list
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or globally:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @scotthuang/openclaw-bytedance
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Local development:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
git clone https://github.com/scotthuang/openclaw-bytedance.git ~/github/openclaw-bytedance
|
|
55
|
+
cd ~/github/openclaw-bytedance
|
|
56
|
+
npm install
|
|
57
|
+
# Link a local OpenClaw checkout for type resolution + tests
|
|
58
|
+
# (override OPENCLAW_REPO if it lives somewhere other than ../openclaw)
|
|
59
|
+
npm run setup:openclaw
|
|
60
|
+
npm run build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
### Env vars (most users)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Vision / chat (Agent Plan)
|
|
71
|
+
export ARK_API_KEY="ark-xxxxxxxxxxxx"
|
|
72
|
+
# Optional override (default: https://ark.cn-beijing.volces.com/api/plan/v3)
|
|
73
|
+
# export ARK_BASE_URL="..."
|
|
74
|
+
|
|
75
|
+
# Web search (Harness AskEcho Search Infinity)
|
|
76
|
+
export ARK_SEARCH_API_KEY="<your-harness-search-key>"
|
|
77
|
+
# Optional override (default: https://open.feedcoopapi.com)
|
|
78
|
+
# export ARK_SEARCH_BASE_URL="..."
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Aliases also accepted:
|
|
82
|
+
|
|
83
|
+
| Primary | Aliases (lower priority) |
|
|
84
|
+
| --------------------- | --------------------------------------------------------------------- |
|
|
85
|
+
| `ARK_API_KEY` | `VOLCENGINE_API_KEY` |
|
|
86
|
+
| `ARK_BASE_URL` | `VOLCENGINE_BASE_URL` |
|
|
87
|
+
| `ARK_SEARCH_API_KEY` | `ASK_ECHO_SEARCH_INFINITY_API_KEY`, `VOLCENGINE_SEARCH_API_KEY` |
|
|
88
|
+
|
|
89
|
+
### OpenClaw config file (alternative)
|
|
90
|
+
|
|
91
|
+
```toml
|
|
92
|
+
[plugins.entries.bytedance.config.webSearch]
|
|
93
|
+
# apiKey = "<harness-search-key>" # falls back to ARK_SEARCH_API_KEY
|
|
94
|
+
# baseUrl = "https://open.feedcoopapi.com"
|
|
95
|
+
searchType = "web" # or "image"
|
|
96
|
+
|
|
97
|
+
[plugins.entries.bytedance.config.vision]
|
|
98
|
+
# apiKey = "ark-..." # falls back to ARK_API_KEY
|
|
99
|
+
# baseUrl = "..." # falls back to ARK_BASE_URL
|
|
100
|
+
model = "doubao-seed-2.0-pro"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Tool surface
|
|
106
|
+
|
|
107
|
+
### `web_search` (ByteDance / Volcengine Ark Harness)
|
|
108
|
+
|
|
109
|
+
| Field | Type | Description |
|
|
110
|
+
| ------------ | -------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
111
|
+
| `query` | string (req'd) | 1–100 characters |
|
|
112
|
+
| `count` | number | Web: 1–50, Image: 1–5. Defaults to 5 |
|
|
113
|
+
| `searchType` | enum | `web` (default) or `image` |
|
|
114
|
+
| `timeRange` | string | `OneDay` / `OneWeek` / `OneMonth` / `OneYear`, or `YYYY-MM-DD..YYYY-MM-DD` (web only) |
|
|
115
|
+
| `authLevel` | 0 \| 1 | 0 = default, 1 = only highly authoritative sources (web only) |
|
|
116
|
+
|
|
117
|
+
**Response** (abridged):
|
|
118
|
+
|
|
119
|
+
```jsonc
|
|
120
|
+
{
|
|
121
|
+
"query": "OpenClaw",
|
|
122
|
+
"provider": "bytedance",
|
|
123
|
+
"searchType": "web",
|
|
124
|
+
"count": 3,
|
|
125
|
+
"tookMs": 315,
|
|
126
|
+
"requestId": "202605160209109A2F527379DE92B5997E",
|
|
127
|
+
"results": [
|
|
128
|
+
{
|
|
129
|
+
"title": "<wrapped: OpenClaw 入驻微博...>",
|
|
130
|
+
"url": "https://...",
|
|
131
|
+
"description": "<wrapped: snippet>",
|
|
132
|
+
"summary": "<wrapped: longer model-generated summary>",
|
|
133
|
+
"published": "2026-03-04T08:27:25+08:00",
|
|
134
|
+
"siteName": "中华网"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"externalContent": { "untrusted": true, "source": "web_search", "provider": "bytedance", "wrapped": true }
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Image Understanding (auto-invoked by OpenClaw media pipeline)
|
|
142
|
+
|
|
143
|
+
The plugin sends each image as a base64 data URL inside an OpenAI-compatible multimodal user message and returns the model's textual description.
|
|
144
|
+
|
|
145
|
+
Supported MIME types: `image/png`, `image/jpeg`, `image/webp`, `image/gif`. Unknown types fall back to `image/jpeg`.
|
|
146
|
+
|
|
147
|
+
The image must be at least **14×14 pixels** (Volcengine Ark service-side requirement).
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Security notes
|
|
152
|
+
|
|
153
|
+
- **No bundled credentials.** Keys are resolved at runtime from config or env vars only.
|
|
154
|
+
- **Untrusted-content envelope.** All web-fetched titles, snippets, and summaries are wrapped via OpenClaw's `wrapWebContent` helper.
|
|
155
|
+
- **Trusted endpoints.** HTTP requests go through OpenClaw's `withTrustedWebSearchEndpoint` (private-network egress blocked).
|
|
156
|
+
- **Search-key separation.** Vision and search keys are separate so users can revoke one without affecting the other.
|
|
157
|
+
- **Traffic tag.** Search requests carry `X-Traffic-Tag: ark_mcp_server_openclaw_bytedance`, matching the Volcengine MCP convention so traffic is attributable.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
### Run unit tests
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
pnpm install
|
|
167
|
+
pnpm test # vitest run, all suites
|
|
168
|
+
pnpm test:watch
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Pure unit tests (no network):
|
|
172
|
+
|
|
173
|
+
- `credentials.test.ts` — env-var fallback chains for both keys (vision + search)
|
|
174
|
+
- `bytedance-web-search-provider.runtime.test.ts` — payload builder, time-range validation, count clamping, response parsing
|
|
175
|
+
- `media-understanding-provider.test.ts` — request shape (data URL, image_url block, max_tokens), error handling, model selection from cfg
|
|
176
|
+
|
|
177
|
+
The `vitest.config.ts` aliases `openclaw/plugin-sdk/*` to a local OpenClaw checkout. Set `OPENCLAW_REPO=/path/to/openclaw` to override the default `~/github/openclaw`.
|
|
178
|
+
|
|
179
|
+
### Compare against MiniMax (live API)
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
ARK_API_KEY=ark-... \
|
|
183
|
+
ARK_SEARCH_API_KEY=<harness-search-key> \
|
|
184
|
+
MINIMAX_CODE_PLAN_KEY=sk-cp-... \
|
|
185
|
+
MINIMAX_API_HOST=https://api.minimaxi.com \
|
|
186
|
+
QUERY="OpenClaw 是什么开源项目" \
|
|
187
|
+
COUNT=3 \
|
|
188
|
+
pnpm run compare
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Modes:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
pnpm run compare # search + vision
|
|
195
|
+
pnpm run compare:search
|
|
196
|
+
pnpm run compare:vision # set IMAGE_PATH=./img.png or IMAGE_URL=https://...
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The runner hits both providers in parallel and prints latency, result count, summaries, and full descriptions.
|
|
200
|
+
|
|
201
|
+
#### Real-world result (May 2026)
|
|
202
|
+
|
|
203
|
+
| Test | ByteDance | MiniMax |
|
|
204
|
+
| ------------------------ | ------------------------------------------------------------------ | ------------------------------------------------ |
|
|
205
|
+
| Search "OpenClaw" | **315 ms**, 3 results + 3 AI summaries + SiteName + PublishTime | 642 ms, 3 results, snippet only |
|
|
206
|
+
| Vision (32×32 red shape) | 4759 ms, 199 chars, **correctly identifies circle** | 3631 ms, 84 chars, identifies as square |
|
|
207
|
+
|
|
208
|
+
ByteDance Search wins on latency, summary quality, and metadata richness. MiniMax VL wins on vision latency. Doubao 2.0 Pro produces longer, more accurate vision descriptions on small images.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT — see [LICENSE](./LICENSE).
|
|
215
|
+
|
|
216
|
+
## Links
|
|
217
|
+
|
|
218
|
+
- Volcengine Ark Agent Plan: <https://www.volcengine.com/activity/agentplan>
|
|
219
|
+
- Harness web search docs: <https://www.volcengine.com/docs/82379/2301412>
|
|
220
|
+
- Official MCP server (search backend reference): <https://github.com/volcengine/mcp-server>
|
|
221
|
+
- Image understanding docs: <https://www.volcengine.com/docs/82379/1362931>
|
|
222
|
+
- Doubao Seed 2.0 series: <https://www.volcengine.com/docs/82379/1330310>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
configSchema: import("openclaw/plugin-sdk/plugin-entry").OpenClawPluginConfigSchema;
|
|
6
|
+
register: NonNullable<import("openclaw/plugin-sdk/plugin-entry").OpenClawPluginDefinition["register"]>;
|
|
7
|
+
} & Pick<import("openclaw/plugin-sdk/plugin-entry").OpenClawPluginDefinition, "kind" | "reload" | "nodeHostCommands" | "securityAuditCollectors">;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;AAMA,wBAgBG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
|
+
import { createByteDanceWebSearchProvider } from "./src/bytedance-web-search-provider.js";
|
|
3
|
+
import { setPluginLogger } from "./src/logger.js";
|
|
4
|
+
import { bytedanceMediaUnderstandingProvider } from "./src/media-understanding-provider.js";
|
|
5
|
+
export default definePluginEntry({
|
|
6
|
+
id: "bytedance",
|
|
7
|
+
name: "ByteDance (Volcengine Ark)",
|
|
8
|
+
description: "OpenClaw plugin for ByteDance Volcengine Ark: web search via Responses API and image understanding via Doubao-Seed-2.0-pro.",
|
|
9
|
+
register(api) {
|
|
10
|
+
setPluginLogger(api.logger);
|
|
11
|
+
api.logger.info("[bytedance] register: installing web-search + media-understanding providers (id=bytedance)");
|
|
12
|
+
api.registerWebSearchProvider(createByteDanceWebSearchProvider());
|
|
13
|
+
api.registerMediaUnderstandingProvider(bytedanceMediaUnderstandingProvider);
|
|
14
|
+
api.logger.info("[bytedance] register: providers installed (vision-default=doubao-seed-2.0-pro, search-tag=ark_mcp_server_openclaw_bytedance)");
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAE5F,eAAe,iBAAiB,CAAC;IAC/B,EAAE,EAAE,WAAW;IACf,IAAI,EAAE,4BAA4B;IAClC,WAAW,EACT,6HAA6H;IAC/H,QAAQ,CAAC,GAAG;QACV,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,GAAG,CAAC,MAAM,CAAC,IAAI,CACb,4FAA4F,CAC7F,CAAC;QACF,GAAG,CAAC,yBAAyB,CAAC,gCAAgC,EAAE,CAAC,CAAC;QAClE,GAAG,CAAC,kCAAkC,CAAC,mCAAmC,CAAC,CAAC;QAC5E,GAAG,CAAC,MAAM,CAAC,IAAI,CACb,8HAA8H,CAC/H,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytedance-web-search-provider.d.ts","sourceRoot":"","sources":["../../src/bytedance-web-search-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yDAAyD,CAAC;AAyEjE,wBAAgB,gCAAgC,IAAI,uBAAuB,CA4B1E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createWebSearchProviderContractFields, } from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
|
2
|
+
/**
|
|
3
|
+
* ByteDance (Volcengine Ark) web-search provider.
|
|
4
|
+
*
|
|
5
|
+
* Backend: Volcengine "AskEcho Search Infinity" — the same search service
|
|
6
|
+
* the official `mcp_server_askecho_search_infinity` MCP server wraps and
|
|
7
|
+
* which Agent Plan / Harness bundles as a service plan add-on.
|
|
8
|
+
*
|
|
9
|
+
* Two distinct API keys are involved in this plugin overall:
|
|
10
|
+
* 1. ARK_API_KEY — for chat-completions / vision (doubao-seed-2.0-pro)
|
|
11
|
+
* 2. ARK_SEARCH_API_KEY — for the search service (this provider)
|
|
12
|
+
* The two are intentionally separate so users can revoke / scope them
|
|
13
|
+
* independently. Either or both may be set.
|
|
14
|
+
*
|
|
15
|
+
* Search credential resolution order:
|
|
16
|
+
* 1. plugins.entries.bytedance.config.webSearch.apiKey
|
|
17
|
+
* 2. ARK_SEARCH_API_KEY
|
|
18
|
+
* 3. ASK_ECHO_SEARCH_INFINITY_API_KEY (matches the official MCP server)
|
|
19
|
+
* 4. VOLCENGINE_SEARCH_API_KEY
|
|
20
|
+
*/
|
|
21
|
+
const BYTEDANCE_CREDENTIAL_PATH = "plugins.entries.bytedance.config.webSearch.apiKey";
|
|
22
|
+
const BYTEDANCE_SEARCH_ENV_VARS = [
|
|
23
|
+
"ARK_SEARCH_API_KEY",
|
|
24
|
+
"ASK_ECHO_SEARCH_INFINITY_API_KEY",
|
|
25
|
+
"VOLCENGINE_SEARCH_API_KEY",
|
|
26
|
+
];
|
|
27
|
+
let runtimePromise;
|
|
28
|
+
function loadRuntime() {
|
|
29
|
+
runtimePromise ??= import("./bytedance-web-search-provider.runtime.js");
|
|
30
|
+
return runtimePromise;
|
|
31
|
+
}
|
|
32
|
+
const ByteDanceSearchSchema = {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
query: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Search query string. 1-100 characters. Should be focused and natural-language.",
|
|
38
|
+
minLength: 1,
|
|
39
|
+
maxLength: 100,
|
|
40
|
+
},
|
|
41
|
+
count: {
|
|
42
|
+
type: "number",
|
|
43
|
+
description: "Number of results to return (web: 1-50, image: 1-5). Defaults to 5.",
|
|
44
|
+
minimum: 1,
|
|
45
|
+
maximum: 50,
|
|
46
|
+
},
|
|
47
|
+
searchType: {
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: ["web", "image"],
|
|
50
|
+
description: "Type of search: web pages or images. Defaults to 'web'.",
|
|
51
|
+
},
|
|
52
|
+
timeRange: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "Restrict to recent results. One of: OneDay | OneWeek | OneMonth | OneYear, or a date range 'YYYY-MM-DD..YYYY-MM-DD'. Web search only.",
|
|
55
|
+
},
|
|
56
|
+
authLevel: {
|
|
57
|
+
type: "number",
|
|
58
|
+
enum: [0, 1],
|
|
59
|
+
description: "Authority filter: 0 = default (no filter), 1 = only highly authoritative sources. Web search only.",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ["query"],
|
|
63
|
+
};
|
|
64
|
+
export function createByteDanceWebSearchProvider() {
|
|
65
|
+
return {
|
|
66
|
+
id: "bytedance",
|
|
67
|
+
label: "ByteDance Volcengine Search",
|
|
68
|
+
hint: "Web search via Volcengine Ark Harness (AskEcho Search Infinity)",
|
|
69
|
+
onboardingScopes: ["text-inference"],
|
|
70
|
+
credentialLabel: "Volcengine Ark Harness search API key",
|
|
71
|
+
envVars: [...BYTEDANCE_SEARCH_ENV_VARS],
|
|
72
|
+
placeholder: "<harness-search-key>",
|
|
73
|
+
signupUrl: "https://www.volcengine.com/activity/agentplan",
|
|
74
|
+
docsUrl: "https://www.volcengine.com/docs/82379/2301412",
|
|
75
|
+
autoDetectOrder: 30,
|
|
76
|
+
credentialPath: BYTEDANCE_CREDENTIAL_PATH,
|
|
77
|
+
...createWebSearchProviderContractFields({
|
|
78
|
+
credentialPath: BYTEDANCE_CREDENTIAL_PATH,
|
|
79
|
+
searchCredential: { type: "top-level" },
|
|
80
|
+
configuredCredential: { pluginId: "bytedance" },
|
|
81
|
+
}),
|
|
82
|
+
createTool: (ctx) => ({
|
|
83
|
+
description: "Search the web (or images) using Volcengine Ark Harness. Returns titles, URLs, snippets, summaries, and publish dates.",
|
|
84
|
+
parameters: ByteDanceSearchSchema,
|
|
85
|
+
execute: async (args) => {
|
|
86
|
+
const { executeByteDanceWebSearchProviderTool } = await loadRuntime();
|
|
87
|
+
return await executeByteDanceWebSearchProviderTool(ctx, args);
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=bytedance-web-search-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytedance-web-search-provider.js","sourceRoot":"","sources":["../../src/bytedance-web-search-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,GAEtC,MAAM,yDAAyD,CAAC;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,yBAAyB,GAAG,mDAAmD,CAAC;AACtF,MAAM,yBAAyB,GAAG;IAChC,oBAAoB;IACpB,kCAAkC;IAClC,2BAA2B;CACnB,CAAC;AAIX,IAAI,cAA8D,CAAC;AAEnE,SAAS,WAAW;IAClB,cAAc,KAAK,MAAM,CAAC,4CAA4C,CAAC,CAAC;IACxE,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gFAAgF;YAC7F,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,GAAG;SACf;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qEAAqE;YAClF,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,EAAE;SACZ;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;YACtB,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image";
|
|
3
|
+
type AskEchoWebSearchRequest = {
|
|
4
|
+
Query: string;
|
|
5
|
+
SearchType: SearchType;
|
|
6
|
+
Count: number;
|
|
7
|
+
NeedSummary?: boolean;
|
|
8
|
+
TimeRange?: string;
|
|
9
|
+
Filter?: {
|
|
10
|
+
AuthInfoLevel?: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type AskEchoSearchResult = {
|
|
14
|
+
Id?: string;
|
|
15
|
+
SortId?: number;
|
|
16
|
+
Title?: string;
|
|
17
|
+
Snippet?: string;
|
|
18
|
+
SiteName?: string;
|
|
19
|
+
Url?: string;
|
|
20
|
+
Summary?: string;
|
|
21
|
+
Content?: string;
|
|
22
|
+
PublishTime?: string;
|
|
23
|
+
LogoUrl?: string;
|
|
24
|
+
RankScore?: number;
|
|
25
|
+
};
|
|
26
|
+
type AskEchoSearchResponse = {
|
|
27
|
+
ResponseMetadata?: {
|
|
28
|
+
RequestId?: string;
|
|
29
|
+
};
|
|
30
|
+
Result?: {
|
|
31
|
+
ResultCount?: number;
|
|
32
|
+
WebResults?: AskEchoSearchResult[];
|
|
33
|
+
ImageResults?: AskEchoSearchResult[];
|
|
34
|
+
};
|
|
35
|
+
error?: {
|
|
36
|
+
message?: string;
|
|
37
|
+
code?: string | number;
|
|
38
|
+
type?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type ExtractedReference = {
|
|
42
|
+
title: string;
|
|
43
|
+
url: string;
|
|
44
|
+
description: string;
|
|
45
|
+
summary?: string;
|
|
46
|
+
published?: string;
|
|
47
|
+
siteName?: string;
|
|
48
|
+
};
|
|
49
|
+
declare function resolveSearchType(args: Record<string, unknown>, searchConfig: SearchConfigRecord | undefined): SearchType;
|
|
50
|
+
declare function resolveAuthLevel(args: Record<string, unknown>): 0 | 1;
|
|
51
|
+
declare function readTimeRange(value: unknown): string | undefined;
|
|
52
|
+
declare function clampCount(count: number | undefined, searchType: SearchType): number;
|
|
53
|
+
declare function buildPayload(req: AskEchoWebSearchRequest): Record<string, unknown>;
|
|
54
|
+
declare function normalizeReference(raw: AskEchoSearchResult): ExtractedReference | undefined;
|
|
55
|
+
declare function extractReferences(payload: AskEchoSearchResponse, searchType: SearchType, count: number): ExtractedReference[];
|
|
56
|
+
export declare function executeByteDanceWebSearchProviderTool(ctx: {
|
|
57
|
+
config?: Record<string, unknown>;
|
|
58
|
+
searchConfig?: SearchConfigRecord;
|
|
59
|
+
}, args: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
60
|
+
export declare const __testing: {
|
|
61
|
+
resolveSearchType: typeof resolveSearchType;
|
|
62
|
+
resolveAuthLevel: typeof resolveAuthLevel;
|
|
63
|
+
readTimeRange: typeof readTimeRange;
|
|
64
|
+
clampCount: typeof clampCount;
|
|
65
|
+
buildPayload: typeof buildPayload;
|
|
66
|
+
normalizeReference: typeof normalizeReference;
|
|
67
|
+
extractReferences: typeof extractReferences;
|
|
68
|
+
SEARCH_PATH: string;
|
|
69
|
+
};
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=bytedance-web-search-provider.runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytedance-web-search-provider.runtime.d.ts","sourceRoot":"","sources":["../../src/bytedance-web-search-provider.runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAeL,KAAK,kBAAkB,EACxB,MAAM,yCAAyC,CAAC;AA4CjD,KAAK,UAAU,GAAG,KAAK,GAAG,OAAO,CAAC;AAElC,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,E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