@markusylisiurunen/tau 0.3.29 → 0.3.30
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/README.md +11 -11
- package/dist/core/config/content_loader.js +3 -1
- package/dist/core/config/content_loader.js.map +1 -1
- package/dist/core/config/index.js +1 -1
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/schema.js +3 -3
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/personas.js +2 -1
- package/dist/core/personas.js.map +1 -1
- package/dist/core/session/runner.js +1 -0
- package/dist/core/session/runner.js.map +1 -1
- package/dist/core/static/code_mode/web/documentation.md +236 -0
- package/dist/core/static/code_mode/web/sandbox_runner.mjs +112 -0
- package/dist/core/subagents/registry.js +2 -3
- package/dist/core/subagents/registry.js.map +1 -1
- package/dist/core/subagents/subagent_engine.js +1 -11
- package/dist/core/subagents/subagent_engine.js.map +1 -1
- package/dist/core/subagents/types.js +2 -3
- package/dist/core/subagents/types.js.map +1 -1
- package/dist/core/telegram/adapter.js +58 -17
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/runtime.js +20 -2
- package/dist/core/telegram/runtime.js.map +1 -1
- package/dist/core/tools/catalog.js +6 -9
- package/dist/core/tools/catalog.js.map +1 -1
- package/dist/core/tools/code_mode.js +105 -0
- package/dist/core/tools/code_mode.js.map +1 -0
- package/dist/core/tools/registry.js.map +1 -1
- package/dist/core/tools/tool_names.js +2 -4
- package/dist/core/tools/tool_names.js.map +1 -1
- package/dist/core/tools/web.js +537 -0
- package/dist/core/tools/web.js.map +1 -0
- package/dist/core/tools/web_discovery.js +201 -0
- package/dist/core/tools/web_discovery.js.map +1 -0
- package/dist/core/utils/subagent_utils.js +8 -8
- package/dist/core/utils/subagent_utils.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/host/hosted_ephemeral_agent_session.js +1 -1
- package/dist/host/hosted_ephemeral_agent_session.js.map +1 -1
- package/dist/protocol/session_protocol.d.ts +1 -1
- package/dist/protocol/session_protocol.js +1 -2
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/tui/ui/agent_activity_format.js +6 -15
- package/dist/tui/ui/agent_activity_format.js.map +1 -1
- package/dist/tui/ui/tool_ui_registry.js +83 -19
- package/dist/tui/ui/tool_ui_registry.js.map +1 -1
- package/package.json +3 -2
- package/dist/core/tools/web_fetch.js +0 -259
- package/dist/core/tools/web_fetch.js.map +0 -1
- package/dist/core/tools/web_search.js +0 -242
- package/dist/core/tools/web_search.js.map +0 -1
- package/dist/core/utils/parallel_api.js +0 -26
- package/dist/core/utils/parallel_api.js.map +0 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
The one-shot JavaScript runtime provides these globals:
|
|
2
|
+
|
|
3
|
+
- `web.discover(url)`: discover metadata for direct Markdown representations and `llms.txt` files for a direct URL.
|
|
4
|
+
- `web.search(query, options?)`: search the web and return relevant page highlights.
|
|
5
|
+
- `web.fetch(urls, options?)`: retrieve highlights or bounded text from known URLs through the web extraction service.
|
|
6
|
+
- `docs`: this document.
|
|
7
|
+
- `console`: program output. Only text written through console methods is returned; return values are ignored.
|
|
8
|
+
|
|
9
|
+
Top-level `await` is supported. Calls may run concurrently with `Promise.all`.
|
|
10
|
+
|
|
11
|
+
## Defaults
|
|
12
|
+
|
|
13
|
+
The API is designed for agent workflows and defaults to token-efficient retrieval:
|
|
14
|
+
|
|
15
|
+
- Search uses automatic search with 10 results unless `numResults` is set.
|
|
16
|
+
- Search always requests highlights rather than full page text.
|
|
17
|
+
- Fetch defaults to highlights. Use `mode: "text"` only when fuller page content is needed.
|
|
18
|
+
- Cached content is accepted with live retrieval as fallback. Set `maxAgeHours` only when the task has a specific freshness requirement.
|
|
19
|
+
|
|
20
|
+
## `web.discover(url)`
|
|
21
|
+
|
|
22
|
+
Use discovery as a separate first step when the user provides a specific URL and a direct agent-friendly representation may exist. Print a concise discovery report, then decide in the next turn whether to use `curl`, `web.fetch`, or another approach.
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
const discovery = await web.discover("https://example.com/docs/getting-started");
|
|
26
|
+
|
|
27
|
+
console.log(`Requested: ${discovery.requestedUrl}`);
|
|
28
|
+
for (const representation of discovery.markdown) {
|
|
29
|
+
console.log(
|
|
30
|
+
`Markdown: ${representation.url} (${representation.via}, ${representation.contentType})`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
for (const file of discovery.llmsTxt) {
|
|
34
|
+
console.log(`llms.txt: ${file.url} (${file.contentType})`);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Discovery accepts HTTP(S) URLs up to 2,048 characters and 20 path segments.
|
|
39
|
+
|
|
40
|
+
Discovery checks:
|
|
41
|
+
|
|
42
|
+
1. The original URL with Markdown content negotiation.
|
|
43
|
+
2. Deterministic same-origin `.md` and `/index.md` paths.
|
|
44
|
+
3. `/llms.txt` and `llms.txt` at every path prefix.
|
|
45
|
+
|
|
46
|
+
Discovery returns metadata only. It does not return page or `llms.txt` bodies, parse Markdown links, match entries to the requested page, or automatically follow anything listed there. Missing discovery files are omitted.
|
|
47
|
+
|
|
48
|
+
### Response
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
{
|
|
52
|
+
requestedUrl: string,
|
|
53
|
+
markdown: [
|
|
54
|
+
{
|
|
55
|
+
url: string,
|
|
56
|
+
via: "content-negotiation" | "markdown-path",
|
|
57
|
+
contentType: "text/markdown" | "text/x-markdown" | "text/plain",
|
|
58
|
+
varyAccept?: boolean,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
llmsTxt: [
|
|
62
|
+
{
|
|
63
|
+
url: string,
|
|
64
|
+
contentType: "text/markdown" | "text/x-markdown" | "text/plain",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Retrieve an explicit Markdown or `llms.txt` URL with `curl` in a later Bash call:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl -fsSL -H 'Accept: text/markdown' \
|
|
74
|
+
'https://example.com/docs/getting-started/index.md'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For content negotiation, request the original URL with the same header. Use `web.fetch` instead when extraction through the web search infrastructure is preferable.
|
|
78
|
+
|
|
79
|
+
## `web.search(query, options?)`
|
|
80
|
+
|
|
81
|
+
Search the web and retrieve highlights in one request.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
const response = await web.search("latest Tau releases", {
|
|
85
|
+
numResults: 5,
|
|
86
|
+
includeDomains: ["github.com"],
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Options
|
|
91
|
+
|
|
92
|
+
| Option | Type | Behavior |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| `numResults` | integer, 1-100 | Number of results. Defaults to 10. |
|
|
95
|
+
| `includeDomains` | string array, 1-1,200 items | Return only matching domains or path prefixes. |
|
|
96
|
+
| `excludeDomains` | string array, 1-1,200 items | Exclude matching domains or path prefixes. |
|
|
97
|
+
| `startPublishedDate` | string | Return pages published after this ISO 8601 date. |
|
|
98
|
+
| `endPublishedDate` | string | Return pages published before this ISO 8601 date. |
|
|
99
|
+
| `category` | string | One of `company`, `people`, `publication`, `news`, `personal site`, or `financial report`. |
|
|
100
|
+
| `userLocation` | two-letter country code | Bias results toward a country. |
|
|
101
|
+
| `maxAgeHours` | integer, -1 to 720 | Maximum cached-content age. `0` always retrieves live; `-1` uses cache only. Omit for the recommended default. |
|
|
102
|
+
|
|
103
|
+
Do not combine `excludeDomains` or publication-date filters with the `company` or `people` categories; those combinations are unsupported.
|
|
104
|
+
|
|
105
|
+
### Response
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
{
|
|
109
|
+
results: [
|
|
110
|
+
{
|
|
111
|
+
title: string,
|
|
112
|
+
url: string,
|
|
113
|
+
publishedDate?: string,
|
|
114
|
+
author?: string,
|
|
115
|
+
highlights?: string[],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
statuses: [
|
|
119
|
+
{
|
|
120
|
+
id: string,
|
|
121
|
+
status: "success" | "error",
|
|
122
|
+
error?: { tag?: string, httpStatusCode?: number },
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Results are relevance ordered. Check `statuses` when inline content is important because an individual page may fail retrieval while the overall search succeeds.
|
|
129
|
+
|
|
130
|
+
## `web.fetch(urls, options?)`
|
|
131
|
+
|
|
132
|
+
Retrieve content from one URL or an array of up to 100 URLs. Each URL may contain up to 2,048 characters.
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
const response = await web.fetch("https://example.com/article", {
|
|
136
|
+
query: "release date and breaking changes",
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Options
|
|
141
|
+
|
|
142
|
+
| Option | Type | Behavior |
|
|
143
|
+
| --- | --- | --- |
|
|
144
|
+
| `mode` | `"highlights"` or `"text"` | Content mode. Defaults to `"highlights"`. |
|
|
145
|
+
| `query` | string | Guides highlight selection. Available only in highlights mode. |
|
|
146
|
+
| `maxCharacters` | integer, 1-10,000 | Caps highlight or text characters per URL. Omit for the service default. |
|
|
147
|
+
| `maxAgeHours` | integer, -1 to 720 | Maximum cached-content age. `0` always retrieves live; `-1` uses cache only. |
|
|
148
|
+
| `subpages` | integer, 0-100 | Number of linked subpages to retrieve per URL. |
|
|
149
|
+
| `subpageTarget` | string or string array | Guides linked-subpage selection. Strings may contain up to 100 characters; arrays may contain 1-100 items. |
|
|
150
|
+
| `links` | integer, 0-1,000 | Number of links to return from each page. |
|
|
151
|
+
|
|
152
|
+
Use highlights for focused questions and multi-step research. Use bounded text when exact context or comprehensive reading is necessary:
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
const response = await web.fetch(urls, {
|
|
156
|
+
mode: "text",
|
|
157
|
+
maxCharacters: 12_000,
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Response
|
|
162
|
+
|
|
163
|
+
Fetch returns the same top-level `{ results, statuses }` shape as search. Result objects may contain:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
{
|
|
167
|
+
title: string,
|
|
168
|
+
url: string,
|
|
169
|
+
publishedDate?: string,
|
|
170
|
+
author?: string,
|
|
171
|
+
highlights?: string[],
|
|
172
|
+
text?: string,
|
|
173
|
+
subpages?: Array<{ /* same result fields */ }>,
|
|
174
|
+
links?: string[],
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Always inspect `statuses` for fetch calls. A fetch request can succeed overall while individual URLs report errors such as not found, forbidden, or live-retrieval timeout.
|
|
179
|
+
|
|
180
|
+
## Common patterns
|
|
181
|
+
|
|
182
|
+
### Format evidence compactly
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
const { results } = await web.search("current browser compatibility for CSS nesting", {
|
|
186
|
+
numResults: 5,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
for (const result of results) {
|
|
190
|
+
console.log(`${result.title}\n${result.url}`);
|
|
191
|
+
for (const highlight of result.highlights ?? []) console.log(`- ${highlight}`);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Search several query variants concurrently
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
const queries = [
|
|
199
|
+
"Tau latest release notes",
|
|
200
|
+
"Tau recent breaking changes",
|
|
201
|
+
"Tau GitHub releases",
|
|
202
|
+
];
|
|
203
|
+
const responses = await Promise.all(
|
|
204
|
+
queries.map((query) => web.search(query, { numResults: 5 })),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const unique = new Map();
|
|
208
|
+
for (const response of responses) {
|
|
209
|
+
for (const result of response.results) unique.set(result.url, result);
|
|
210
|
+
}
|
|
211
|
+
for (const result of unique.values()) {
|
|
212
|
+
console.log(`${result.title}\n${result.url}`);
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Search first, then fetch selected pages
|
|
217
|
+
|
|
218
|
+
```js
|
|
219
|
+
const { results } = await web.search("official Tau documentation", {
|
|
220
|
+
numResults: 8,
|
|
221
|
+
includeDomains: ["github.com"],
|
|
222
|
+
});
|
|
223
|
+
const urls = results.slice(0, 3).map((result) => result.url);
|
|
224
|
+
const pages = await web.fetch(urls, {
|
|
225
|
+
query: "installation and configuration instructions",
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
for (const page of pages.results) {
|
|
229
|
+
console.log(`${page.title}\n${page.url}`);
|
|
230
|
+
for (const highlight of page.highlights ?? []) console.log(`- ${highlight}`);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Output guidance
|
|
235
|
+
|
|
236
|
+
Print only information needed for the task. Prefer concise labeled text over serialized response objects. Select relevant fields when possible; when all fields matter, flatten and label them compactly. Emit JSON only when the user explicitly requests JSON or another machine-readable result.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
2
|
+
import "ses";
|
|
3
|
+
|
|
4
|
+
if (!parentPort) {
|
|
5
|
+
throw new Error("web sandbox requires a parent port");
|
|
6
|
+
}
|
|
7
|
+
if (
|
|
8
|
+
typeof workerData !== "object" ||
|
|
9
|
+
workerData === null ||
|
|
10
|
+
typeof workerData.code !== "string" ||
|
|
11
|
+
typeof workerData.docs !== "string"
|
|
12
|
+
) {
|
|
13
|
+
throw new Error("web sandbox received invalid worker data");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
lockdown();
|
|
17
|
+
|
|
18
|
+
const pending = new Map();
|
|
19
|
+
let nextRequestId = 1;
|
|
20
|
+
|
|
21
|
+
parentPort.on("message", (message) => {
|
|
22
|
+
if (message?.type !== "response" || typeof message.id !== "number") return;
|
|
23
|
+
const request = pending.get(message.id);
|
|
24
|
+
if (!request) return;
|
|
25
|
+
pending.delete(message.id);
|
|
26
|
+
if (message.ok) {
|
|
27
|
+
request.resolve(message.value);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const error = new Error(message.error?.message || "Web request failed");
|
|
32
|
+
if (message.error?.name) error.name = message.error.name;
|
|
33
|
+
request.reject(error);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
function requestWeb(method, argsJson) {
|
|
37
|
+
if (typeof method !== "string" || typeof argsJson !== "string") {
|
|
38
|
+
return Promise.reject(new Error("invalid web bridge request"));
|
|
39
|
+
}
|
|
40
|
+
const id = nextRequestId++;
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
pending.set(id, { resolve, reject });
|
|
43
|
+
parentPort.postMessage({ type: "request", id, method, argsJson });
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function writeOutput(stream, text) {
|
|
48
|
+
if ((stream !== "stdout" && stream !== "stderr") || typeof text !== "string") {
|
|
49
|
+
throw new Error("invalid console bridge output");
|
|
50
|
+
}
|
|
51
|
+
const output = stream === "stderr" ? process.stderr : process.stdout;
|
|
52
|
+
output.write(text + "\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const compartment = new Compartment({
|
|
56
|
+
globals: {
|
|
57
|
+
_requestWeb: harden(requestWeb),
|
|
58
|
+
_writeOutput: harden(writeOutput),
|
|
59
|
+
docs: workerData.docs,
|
|
60
|
+
},
|
|
61
|
+
__options__: true,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
compartment.evaluate(String.raw`
|
|
65
|
+
(() => {
|
|
66
|
+
const requestWebBridge = _requestWeb;
|
|
67
|
+
const writeOutputBridge = _writeOutput;
|
|
68
|
+
delete globalThis._requestWeb;
|
|
69
|
+
delete globalThis._writeOutput;
|
|
70
|
+
|
|
71
|
+
function formatOutputValue(value) {
|
|
72
|
+
if (typeof value === "string") return value;
|
|
73
|
+
if (value instanceof Error) return value.stack || value.message;
|
|
74
|
+
try {
|
|
75
|
+
const serialized = JSON.stringify(value);
|
|
76
|
+
if (serialized !== undefined) return serialized;
|
|
77
|
+
} catch {}
|
|
78
|
+
return String(value);
|
|
79
|
+
}
|
|
80
|
+
function writeConsole(stream, values) {
|
|
81
|
+
writeOutputBridge(stream, values.map(formatOutputValue).join(" "));
|
|
82
|
+
}
|
|
83
|
+
Object.defineProperty(globalThis, "console", {
|
|
84
|
+
value: Object.freeze({
|
|
85
|
+
debug: (...values) => writeConsole("stdout", values),
|
|
86
|
+
error: (...values) => writeConsole("stderr", values),
|
|
87
|
+
info: (...values) => writeConsole("stdout", values),
|
|
88
|
+
log: (...values) => writeConsole("stdout", values),
|
|
89
|
+
warn: (...values) => writeConsole("stderr", values),
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
function callWeb(method, args) {
|
|
93
|
+
return requestWebBridge(method, JSON.stringify(args));
|
|
94
|
+
}
|
|
95
|
+
Object.defineProperty(globalThis, "web", {
|
|
96
|
+
value: Object.freeze({
|
|
97
|
+
discover: (...args) => callWeb("discover", args),
|
|
98
|
+
search: (...args) => callWeb("search", args),
|
|
99
|
+
fetch: (...args) => callWeb("fetch", args),
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
})();
|
|
103
|
+
`);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
await compartment.evaluate("(async () => {\n" + workerData.code + "\n})()");
|
|
107
|
+
} catch (error) {
|
|
108
|
+
writeOutput("stderr", error instanceof Error ? error.stack || error.message : String(error));
|
|
109
|
+
process.exitCode = 1;
|
|
110
|
+
} finally {
|
|
111
|
+
parentPort.close();
|
|
112
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TOOL_NAME_BASH, TOOL_NAME_EDIT, TOOL_NAME_VIEW_IMAGE,
|
|
1
|
+
import { TOOL_NAME_BASH, TOOL_NAME_EDIT, TOOL_NAME_VIEW_IMAGE, TOOL_NAME_WEB, TOOL_NAME_WRITE, } from "../tools/tool_names.js";
|
|
2
2
|
import { buildDefaultSubagentSystemPrompt, DEFAULT_SUBAGENT_DESCRIPTION } from "./default.js";
|
|
3
3
|
import { DEFAULT_SUBAGENT_NAME, } from "./types.js";
|
|
4
4
|
const INHERITABLE_TOOL_NAMES = new Set([
|
|
@@ -6,8 +6,7 @@ const INHERITABLE_TOOL_NAMES = new Set([
|
|
|
6
6
|
TOOL_NAME_WRITE,
|
|
7
7
|
TOOL_NAME_EDIT,
|
|
8
8
|
TOOL_NAME_VIEW_IMAGE,
|
|
9
|
-
|
|
10
|
-
TOOL_NAME_WEB_FETCH,
|
|
9
|
+
TOOL_NAME_WEB,
|
|
11
10
|
]);
|
|
12
11
|
function normalizeTools(tools) {
|
|
13
12
|
const seen = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/core/subagents/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/core/subagents/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EACL,qBAAqB,GAKtB,MAAM,YAAY,CAAC;AAEpB,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAmB;IACvD,cAAc;IACd,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,aAAa;CACd,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,KAAyB;IAC/C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,MAAM,UAAU,GAAuB,EAAE,CAAC;IAE1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,I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Y,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;QAC/C,MAAM,gBAAgB,GACpB,YAAY,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,iCAAiC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yHAAyH;YAClN,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,OAAO,IAAI,OAAO,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,EAAE;QACF,EAAE;QACF,0BAA0B;QAC1B,EAAE;QACF,8CAA8C;QAC9C,EAAE;QACF,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;QACxB,EAAE;QACF,aAAa;QACb,qVAAqV;KACtV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -16,9 +16,6 @@ function getStreamingSettings(settings) {
|
|
|
16
16
|
const merged = { ...(settings ?? {}) };
|
|
17
17
|
return parseStreamingSettings(merged);
|
|
18
18
|
}
|
|
19
|
-
function buildToolRegistryForAllowedTools(allowedTools, config, backend) {
|
|
20
|
-
return ToolCatalog.createSubagentRegistry(allowedTools, config, backend);
|
|
21
|
-
}
|
|
22
19
|
function isToolCall(block) {
|
|
23
20
|
return block.type === "toolCall";
|
|
24
21
|
}
|
|
@@ -35,8 +32,7 @@ export async function runSubagent(options) {
|
|
|
35
32
|
}
|
|
36
33
|
const baseBackend = options.backend ?? createLocalToolExecutionBackend();
|
|
37
34
|
const backend = scopeToolExecutionBackend(baseBackend, runtimeConfig.workingDirectory);
|
|
38
|
-
const
|
|
39
|
-
const toolRegistry = buildToolRegistryForAllowedTools(allowedTools, config, backend);
|
|
35
|
+
const toolRegistry = ToolCatalog.createSubagentRegistry(runtimeConfig.tools, backend);
|
|
40
36
|
const messages = options.messages ?? [];
|
|
41
37
|
const promptWithModelNotice = prependModelNotice(prompt, resolveModelNotice(config, runtimeConfig.model));
|
|
42
38
|
messages.push({
|
|
@@ -183,12 +179,6 @@ export async function runSubagent(options) {
|
|
|
183
179
|
const handleUi = (uiEvent) => {
|
|
184
180
|
if (!uiEvent)
|
|
185
181
|
return;
|
|
186
|
-
if ((uiEvent.type === "web_search_finished" || uiEvent.type === "web_fetch_finished") &&
|
|
187
|
-
typeof uiEvent.costUsd === "number" &&
|
|
188
|
-
Number.isFinite(uiEvent.costUsd) &&
|
|
189
|
-
uiEvent.costUsd > 0) {
|
|
190
|
-
costTotal += uiEvent.costUsd;
|
|
191
|
-
}
|
|
192
182
|
const text = formatToolUiEventForProgress(uiEvent);
|
|
193
183
|
if (text && /\b(blocked|failed):/.test(text)) {
|
|
194
184
|
recordIssue(text);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent_engine.js","sourceRoot":"","sources":["../../../src/core/subagents/subagent_engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EACL,kBAAkB,EAElB,eAAe,EACf,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CA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,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { TOOL_NAME_BASH, TOOL_NAME_EDIT, TOOL_NAME_VIEW_IMAGE,
|
|
1
|
+
import { TOOL_NAME_BASH, TOOL_NAME_EDIT, TOOL_NAME_VIEW_IMAGE, TOOL_NAME_WEB, TOOL_NAME_WRITE, } from "../tools/tool_names.js";
|
|
2
2
|
export const DEFAULT_SUBAGENT_NAME = "default";
|
|
3
3
|
export const SUBAGENT_TOOL_NAMES = [
|
|
4
4
|
TOOL_NAME_BASH,
|
|
5
5
|
TOOL_NAME_WRITE,
|
|
6
6
|
TOOL_NAME_EDIT,
|
|
7
7
|
TOOL_NAME_VIEW_IMAGE,
|
|
8
|
-
|
|
9
|
-
TOOL_NAME_WEB_FETCH,
|
|
8
|
+
TOOL_NAME_WEB,
|
|
10
9
|
];
|
|
11
10
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/subagents/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/subagents/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAI/C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc;IACd,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,aAAa;CACL,CAAC"}
|
|
@@ -19,8 +19,8 @@ const DEFAULT_TELEGRAM_AUDIO_MIME_TYPE = "audio/mpeg";
|
|
|
19
19
|
const DEFAULT_TELEGRAM_AUDIO_FILE_NAME = "audio.mp3";
|
|
20
20
|
const DEFAULT_TELEGRAM_PHOTO_MIME_TYPE = "image/jpeg";
|
|
21
21
|
const DEFAULT_TELEGRAM_DOCUMENT_MIME_TYPE = "application/octet-stream";
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const MESSAGE_ACKNOWLEDGMENT_REACTION_EMOJI = "👀";
|
|
23
|
+
const MESSAGE_ACKNOWLEDGMENT_DELAY_MS = 1000;
|
|
24
24
|
const TELEGRAM_MAX_MESSAGE_BYTES = 4096;
|
|
25
25
|
const TELEGRAM_MAX_RICH_MESSAGE_BYTES = 32 * 1024;
|
|
26
26
|
const TELEGRAM_MESSAGE_BYTE_BUFFER_RATIO = 0.95;
|
|
@@ -510,19 +510,60 @@ const TelegramGetUpdatesResultSchema = z.array(TelegramUpdateSchema);
|
|
|
510
510
|
const TelegramGetFileResultSchema = z.object({ file_path: z.string() });
|
|
511
511
|
const TelegramGetMeResultSchema = telegramObject({ username: z.string() });
|
|
512
512
|
const TelegramAckResultSchema = z.literal(true);
|
|
513
|
+
const MAX_TELEGRAM_ERROR_DETAIL_LENGTH = 500;
|
|
514
|
+
function getErrorCode(error) {
|
|
515
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
516
|
+
return undefined;
|
|
517
|
+
}
|
|
518
|
+
return typeof error.code === "string" ? error.code : undefined;
|
|
519
|
+
}
|
|
520
|
+
function formatTelegramNetworkError(error) {
|
|
521
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
522
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
523
|
+
const causeMessage = cause instanceof Error ? cause.message : undefined;
|
|
524
|
+
const codes = Array.from(new Set([getErrorCode(error), getErrorCode(cause)].filter((code) => code !== undefined)));
|
|
525
|
+
const detail = causeMessage && causeMessage !== message ? `${message}: ${causeMessage}` : message;
|
|
526
|
+
return `${detail}${codes.length > 0 ? ` (${codes.join(", ")})` : ""}`;
|
|
527
|
+
}
|
|
528
|
+
function truncateTelegramErrorDetail(detail) {
|
|
529
|
+
if (detail.length <= MAX_TELEGRAM_ERROR_DETAIL_LENGTH) {
|
|
530
|
+
return detail;
|
|
531
|
+
}
|
|
532
|
+
return `${detail.slice(0, MAX_TELEGRAM_ERROR_DETAIL_LENGTH)}…`;
|
|
533
|
+
}
|
|
534
|
+
async function readTelegramHttpErrorDetail(response) {
|
|
535
|
+
const responseText = (await response.text()).trim();
|
|
536
|
+
if (!responseText) {
|
|
537
|
+
return "";
|
|
538
|
+
}
|
|
539
|
+
try {
|
|
540
|
+
const parsed = TelegramEnvelopeSchema.safeParse(JSON.parse(responseText));
|
|
541
|
+
if (parsed.success && parsed.data.description?.trim()) {
|
|
542
|
+
return truncateTelegramErrorDetail(parsed.data.description.trim());
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
catch { }
|
|
546
|
+
return truncateTelegramErrorDetail(responseText);
|
|
547
|
+
}
|
|
513
548
|
function createTelegramApi(botToken) {
|
|
514
549
|
const apiUrl = `https://api.telegram.org/bot${botToken}`;
|
|
515
550
|
async function callTelegramMethod(method, payload, resultSchema) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
551
|
+
let response;
|
|
552
|
+
try {
|
|
553
|
+
response = await fetch(`${apiUrl}/${method}`, {
|
|
554
|
+
method: "POST",
|
|
555
|
+
headers: {
|
|
556
|
+
"content-type": "application/json",
|
|
557
|
+
},
|
|
558
|
+
body: JSON.stringify(payload),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
throw new Error(`telegram ${method} network request failed: ${formatTelegramNetworkError(error)}`);
|
|
563
|
+
}
|
|
523
564
|
if (!response.ok) {
|
|
524
|
-
const detail =
|
|
525
|
-
throw new Error(
|
|
565
|
+
const detail = await readTelegramHttpErrorDetail(response);
|
|
566
|
+
throw new Error(`telegram ${method} failed: HTTP ${response.status}${detail ? `: ${detail}` : ""}`);
|
|
526
567
|
}
|
|
527
568
|
let raw;
|
|
528
569
|
try {
|
|
@@ -534,7 +575,7 @@ function createTelegramApi(botToken) {
|
|
|
534
575
|
const envelope = parseOrThrow(TelegramEnvelopeSchema, raw, `telegram ${method} returned an invalid response payload`);
|
|
535
576
|
if (!envelope.ok) {
|
|
536
577
|
const detail = envelope.description?.trim() ?? "";
|
|
537
|
-
throw new Error(
|
|
578
|
+
throw new Error(`telegram ${method} request failed${detail ? `: ${detail}` : ""}`);
|
|
538
579
|
}
|
|
539
580
|
return parseOrThrow(resultSchema, envelope.result, `telegram ${method} returned an invalid result`);
|
|
540
581
|
}
|
|
@@ -596,7 +637,7 @@ function createTelegramApi(botToken) {
|
|
|
596
637
|
await callTelegramMethod("setMessageReaction", {
|
|
597
638
|
chat_id: chatId,
|
|
598
639
|
message_id: messageId,
|
|
599
|
-
reaction: [{ type: "emoji", emoji:
|
|
640
|
+
reaction: [{ type: "emoji", emoji: MESSAGE_ACKNOWLEDGMENT_REACTION_EMOJI }],
|
|
600
641
|
}, TelegramAckResultSchema);
|
|
601
642
|
},
|
|
602
643
|
async answerCallbackQuery(callbackQueryId, text) {
|
|
@@ -1435,6 +1476,7 @@ class TelegramAdapterImpl {
|
|
|
1435
1476
|
await this.reply(chatId, parsed.error);
|
|
1436
1477
|
return;
|
|
1437
1478
|
}
|
|
1479
|
+
void this.acknowledgeMessageAfterDelay(chatId, sourceMessageId);
|
|
1438
1480
|
try {
|
|
1439
1481
|
const sessionManager = this.getSessionManagerForChat(chatId);
|
|
1440
1482
|
const previousSession = this.getActiveSession(chatId);
|
|
@@ -1446,7 +1488,6 @@ class TelegramAdapterImpl {
|
|
|
1446
1488
|
projectId: parsed.projectId,
|
|
1447
1489
|
});
|
|
1448
1490
|
this.setActiveSession(chatId, session.id);
|
|
1449
|
-
void this.reactToQueuedMessage(chatId, sourceMessageId);
|
|
1450
1491
|
}
|
|
1451
1492
|
catch (error) {
|
|
1452
1493
|
await this.reply(chatId, this.formatManagerError(error));
|
|
@@ -1742,7 +1783,7 @@ class TelegramAdapterImpl {
|
|
|
1742
1783
|
...(this.systemMessage ? { additionalSystemMessage: this.systemMessage } : {}),
|
|
1743
1784
|
});
|
|
1744
1785
|
this.resetPendingAttachmentQueue(sessionId);
|
|
1745
|
-
await this.
|
|
1786
|
+
await this.acknowledgeMessageAfterDelay(chatId, sourceMessageId);
|
|
1746
1787
|
if (this.isVerboseSession(sessionId)) {
|
|
1747
1788
|
await this.reply(chatId, this.formatMessageQueued(sessionId));
|
|
1748
1789
|
}
|
|
@@ -2006,11 +2047,11 @@ class TelegramAdapterImpl {
|
|
|
2006
2047
|
getSessionChatKey(sessionId, chatId) {
|
|
2007
2048
|
return `${sessionId}:${chatId}`;
|
|
2008
2049
|
}
|
|
2009
|
-
async
|
|
2050
|
+
async acknowledgeMessageAfterDelay(chatId, messageId) {
|
|
2010
2051
|
if (typeof messageId !== "number" || !Number.isInteger(messageId) || messageId <= 0) {
|
|
2011
2052
|
return;
|
|
2012
2053
|
}
|
|
2013
|
-
await this.wait(
|
|
2054
|
+
await this.wait(MESSAGE_ACKNOWLEDGMENT_DELAY_MS);
|
|
2014
2055
|
if (this.abortController.signal.aborted) {
|
|
2015
2056
|
return;
|
|
2016
2057
|
}
|