@ouro.bot/cli 0.1.0-alpha.1307 → 0.1.0-alpha.1309
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/nerves/coverage/file-completeness.js +2 -0
- package/dist/repertoire/coding/tools.js +42 -13
- package/dist/repertoire/tool-error-code.js +14 -0
- package/dist/repertoire/tools-base.js +3 -10
- package/dist/repertoire/tools-shell.js +23 -4
- package/dist/repertoire/tools-web.js +15 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1309",
|
|
6
|
+
"changes": [
|
|
7
|
+
"coding_spawn, coding_status, coding_tail, coding_send_input and coding_kill have Ouro AX cards; their failures end with a code (missing-argument, invalid-runner, session-not-found), and coding_status and coding_tail state a low-risk profile."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1308",
|
|
12
|
+
"changes": [
|
|
13
|
+
"shell, shell_status, shell_tail and fetch_url have Ouro AX cards, with shell's approval prompt declared; their failures end with a code (command-failed, command-timed-out, command-not-started, process-not-found, invalid-url, private-address, http-error, fetch-failed), and shell_status, shell_tail and fetch_url state a low-risk profile."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1307",
|
|
6
18
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1309</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -73,6 +73,8 @@ const DISPATCH_EXEMPT_PATTERNS = [
|
|
|
73
73
|
"heart/mail-import-discovery",
|
|
74
74
|
"repertoire/api-client",
|
|
75
75
|
"repertoire/github-client",
|
|
76
|
+
// The suffix that ends a tool's coded error; each tool module that uses it owns its own observability.
|
|
77
|
+
"repertoire/tool-error-code",
|
|
76
78
|
"mind/embedding-provider",
|
|
77
79
|
// Commerce utility module: error classes and pure helpers (no independent side effects).
|
|
78
80
|
"repertoire/commerce-errors",
|
|
@@ -4,6 +4,7 @@ exports.codingToolDefinitions = void 0;
|
|
|
4
4
|
exports.countFilesInSessionOutput = countFilesInSessionOutput;
|
|
5
5
|
const index_1 = require("./index");
|
|
6
6
|
const context_pack_1 = require("./context-pack");
|
|
7
|
+
const tool_error_code_1 = require("../tool-error-code");
|
|
7
8
|
const identity_1 = require("../../heart/identity");
|
|
8
9
|
const obligations_1 = require("../../arc/obligations");
|
|
9
10
|
const evolution_1 = require("../../arc/evolution");
|
|
@@ -51,6 +52,10 @@ async function sendCodingInput(manager, sessionId, input) {
|
|
|
51
52
|
async function killCodingSession(manager, sessionId) {
|
|
52
53
|
return manager.killSession(sessionId);
|
|
53
54
|
}
|
|
55
|
+
/** The manager's action result as JSON, with the card's code added when the session is unknown. */
|
|
56
|
+
function actionResultText(result) {
|
|
57
|
+
return JSON.stringify(!result.ok && result.message.startsWith("session not found:") ? { ...result, code: "session-not-found" } : result);
|
|
58
|
+
}
|
|
54
59
|
/**
|
|
55
60
|
* Count distinct file paths mentioned in a coding session's stdout output.
|
|
56
61
|
* Looks for path-like tokens (containing / and a file extension).
|
|
@@ -259,19 +264,19 @@ exports.codingToolDefinitions = [
|
|
|
259
264
|
emitCodingToolEvent("coding_spawn");
|
|
260
265
|
const rawRunner = requireArg(args, "runner");
|
|
261
266
|
if (!rawRunner)
|
|
262
|
-
return "runner is required";
|
|
267
|
+
return (0, tool_error_code_1.withCode)("runner is required", "missing-argument");
|
|
263
268
|
const runner = parseRunner(rawRunner);
|
|
264
269
|
if (!runner)
|
|
265
|
-
return `invalid runner: ${rawRunner}
|
|
270
|
+
return (0, tool_error_code_1.withCode)(`invalid runner: ${rawRunner}`, "invalid-runner");
|
|
266
271
|
const workdir = requireArg(args, "workdir");
|
|
267
272
|
if (!workdir)
|
|
268
|
-
return "workdir is required";
|
|
273
|
+
return (0, tool_error_code_1.withCode)("workdir is required", "missing-argument");
|
|
269
274
|
const prompt = requireArg(args, "prompt");
|
|
270
275
|
if (!prompt)
|
|
271
|
-
return "prompt is required";
|
|
276
|
+
return (0, tool_error_code_1.withCode)("prompt is required", "missing-argument");
|
|
272
277
|
const taskRef = requireArg(args, "taskRef");
|
|
273
278
|
if (!taskRef)
|
|
274
|
-
return "taskRef is required";
|
|
279
|
+
return (0, tool_error_code_1.withCode)("taskRef is required", "missing-argument");
|
|
275
280
|
const request = {
|
|
276
281
|
runner,
|
|
277
282
|
workdir,
|
|
@@ -373,6 +378,11 @@ exports.codingToolDefinitions = [
|
|
|
373
378
|
risk: "high",
|
|
374
379
|
reason: "spawns a separate coding process and may create obligations",
|
|
375
380
|
},
|
|
381
|
+
ax: { id: "tool:coding_spawn", group: "turn-coding", when: "Pick this to hand a whole coding job to a separate claude or codex worker; for one quick command, shell is enough.", effect: "write", errors: [
|
|
382
|
+
{ code: "missing-argument", means: "runner, workdir, prompt or taskRef is missing or blank; the message names which.", fix: "Call coding_spawn again with all four filled in, the prompt complete enough to work from alone." },
|
|
383
|
+
{ code: "invalid-runner", means: "runner is something other than claude or codex.", fix: "Set runner to claude or codex and spawn again." },
|
|
384
|
+
{ code: "orientation-hold", means: "This turn is on a correction hold, so new coding work waits.", fix: "Call orientation_get, settle what the person meant, then spawn if the job is still right." },
|
|
385
|
+
] },
|
|
376
386
|
},
|
|
377
387
|
{
|
|
378
388
|
tool: codingStatusTool,
|
|
@@ -385,10 +395,14 @@ exports.codingToolDefinitions = [
|
|
|
385
395
|
}
|
|
386
396
|
const session = await getCodingSession(manager, sessionId);
|
|
387
397
|
if (!session)
|
|
388
|
-
return `session not found: ${sessionId}
|
|
398
|
+
return (0, tool_error_code_1.withCode)(`session not found: ${sessionId}`, "session-not-found");
|
|
389
399
|
return appendCompletionScrutiny(JSON.stringify(session), session);
|
|
390
400
|
},
|
|
391
401
|
summaryKeys: ["sessionId"],
|
|
402
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
403
|
+
ax: { id: "tool:coding_status", group: "turn-coding", when: "Pick this to check how coding workers are progressing, or list them all, before telling anyone their state; coding_tail shows their output.", effect: "read", idempotent: true, errors: [
|
|
404
|
+
{ code: "session-not-found", means: "No coding session has that id.", fix: "Call coding_status with no sessionId to list the sessions and their ids." },
|
|
405
|
+
] },
|
|
392
406
|
},
|
|
393
407
|
{
|
|
394
408
|
tool: codingTailTool,
|
|
@@ -396,13 +410,18 @@ exports.codingToolDefinitions = [
|
|
|
396
410
|
emitCodingToolEvent("coding_tail");
|
|
397
411
|
const sessionId = requireArg(args, "sessionId");
|
|
398
412
|
if (!sessionId)
|
|
399
|
-
return "sessionId is required";
|
|
413
|
+
return (0, tool_error_code_1.withCode)("sessionId is required", "missing-argument");
|
|
400
414
|
const session = await getCodingSession((0, index_1.getCodingSessionManager)(), sessionId);
|
|
401
415
|
if (!session)
|
|
402
|
-
return `session not found: ${sessionId}
|
|
416
|
+
return (0, tool_error_code_1.withCode)(`session not found: ${sessionId}`, "session-not-found");
|
|
403
417
|
return appendCompletionScrutiny((0, index_1.formatCodingTail)(session), session);
|
|
404
418
|
},
|
|
405
419
|
summaryKeys: ["sessionId"],
|
|
420
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
421
|
+
ax: { id: "tool:coding_tail", group: "turn-coding", when: "Pick this to read what a coding worker printed lately, to see why it stalled or what it finished; coding_status gives only its state.", effect: "read", idempotent: true, errors: [
|
|
422
|
+
{ code: "missing-argument", means: "sessionId is missing or blank.", fix: "Get the id from coding_status, then call coding_tail with it." },
|
|
423
|
+
{ code: "session-not-found", means: "That sessionId matches no coding session.", fix: "List the sessions with coding_status and use one of their ids." },
|
|
424
|
+
] },
|
|
406
425
|
},
|
|
407
426
|
{
|
|
408
427
|
tool: codingSendInputTool,
|
|
@@ -410,14 +429,19 @@ exports.codingToolDefinitions = [
|
|
|
410
429
|
emitCodingToolEvent("coding_send_input");
|
|
411
430
|
const sessionId = requireArg(args, "sessionId");
|
|
412
431
|
if (!sessionId)
|
|
413
|
-
return "sessionId is required";
|
|
432
|
+
return (0, tool_error_code_1.withCode)("sessionId is required", "missing-argument");
|
|
414
433
|
const input = requireArg(args, "input");
|
|
415
434
|
if (!input)
|
|
416
|
-
return "input is required";
|
|
417
|
-
return
|
|
435
|
+
return (0, tool_error_code_1.withCode)("input is required", "missing-argument");
|
|
436
|
+
return actionResultText(await sendCodingInput((0, index_1.getCodingSessionManager)(), sessionId, input));
|
|
418
437
|
},
|
|
419
438
|
summaryKeys: ["sessionId", "input"],
|
|
420
439
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "sends input to a live coding process" },
|
|
440
|
+
ax: { id: "tool:coding_send_input", group: "turn-coding", when: "Pick this to answer a coding worker that is waiting on a question, or steer one mid-task; to begin new work, use coding_spawn.", effect: "write", errors: [
|
|
441
|
+
{ code: "missing-argument", means: "sessionId or input is missing or blank; the message names which.", fix: "Call coding_send_input again with both the session's id and the text to send." },
|
|
442
|
+
{ code: "session-not-found", means: "The JSON reply's code says no live session has that id, often because it already ended.", fix: "Check it with coding_status; if it ended, read coding_tail or spawn a new session." },
|
|
443
|
+
{ code: "orientation-hold", means: "This turn is on a correction hold, so input to a running worker waits.", fix: "Call orientation_get, settle the correction, then send the input if it still fits." },
|
|
444
|
+
] },
|
|
421
445
|
},
|
|
422
446
|
{
|
|
423
447
|
tool: codingKillTool,
|
|
@@ -425,10 +449,15 @@ exports.codingToolDefinitions = [
|
|
|
425
449
|
emitCodingToolEvent("coding_kill");
|
|
426
450
|
const sessionId = requireArg(args, "sessionId");
|
|
427
451
|
if (!sessionId)
|
|
428
|
-
return "sessionId is required";
|
|
429
|
-
return
|
|
452
|
+
return (0, tool_error_code_1.withCode)("sessionId is required", "missing-argument");
|
|
453
|
+
return actionResultText(await killCodingSession((0, index_1.getCodingSessionManager)(), sessionId));
|
|
430
454
|
},
|
|
431
455
|
summaryKeys: ["sessionId"],
|
|
432
456
|
riskProfile: { mutates: "external_side_effect", risk: "high", reason: "terminates a live coding process" },
|
|
457
|
+
ax: { id: "tool:coding_kill", group: "turn-coding", when: "Pick this to stop a coding worker that is stuck, wrong or no longer wanted; unsaved work in its process is lost.", effect: "write", destructive: true, errors: [
|
|
458
|
+
{ code: "missing-argument", means: "sessionId is missing or blank.", fix: "Find the session's id with coding_status and call coding_kill with it." },
|
|
459
|
+
{ code: "session-not-found", means: "The JSON reply's code says no live session has that id; it may have ended already.", fix: "Confirm with coding_status; a session that already ended needs no kill." },
|
|
460
|
+
{ code: "orientation-hold", means: "This turn is on a correction hold, so stopping a worker waits.", fix: "Call orientation_get, settle what the person meant, then kill the session if that is still wanted." },
|
|
461
|
+
] },
|
|
433
462
|
},
|
|
434
463
|
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withCode = withCode;
|
|
4
|
+
/**
|
|
5
|
+
* An error text a tool or the dispatcher returns, ending with the code its Ouro AX card names, so a model can look up
|
|
6
|
+
* the card's fix. The message stays first and unchanged; the code is a suffix. Pass the code as a literal: the AX
|
|
7
|
+
* census counts a card's code as raised only where it appears in the handler's file.
|
|
8
|
+
*
|
|
9
|
+
* It lives apart from tools-base so a tool module can use it without importing tools-base, which imports every tool
|
|
10
|
+
* module and so can't be loaded from one.
|
|
11
|
+
*/
|
|
12
|
+
function withCode(message, code) {
|
|
13
|
+
return `${message} (code: ${code})`;
|
|
14
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tools = exports.baseToolDefinitions = exports.editFileReadTracker = exports.SELF_FRIEND_ID = exports.routineActionRequester = exports.renderInnerProgressStatus = exports.speakTool = exports.restTool = exports.settleTool = exports.observeTool = exports.ponderTool = void 0;
|
|
4
|
-
exports.withCode = withCode;
|
|
3
|
+
exports.tools = exports.baseToolDefinitions = exports.editFileReadTracker = exports.withCode = exports.SELF_FRIEND_ID = exports.routineActionRequester = exports.renderInnerProgressStatus = exports.speakTool = exports.restTool = exports.settleTool = exports.observeTool = exports.ponderTool = void 0;
|
|
5
4
|
exports.routineActionDenied = routineActionDenied;
|
|
6
5
|
const runtime_1 = require("../nerves/runtime");
|
|
7
6
|
const tools_files_1 = require("./tools-files");
|
|
@@ -48,14 +47,8 @@ var relationship_authorization_1 = require("./relationship-authorization");
|
|
|
48
47
|
Object.defineProperty(exports, "routineActionRequester", { enumerable: true, get: function () { return relationship_authorization_1.routineActionRequester; } });
|
|
49
48
|
/** The friend id of the agent talking to itself: every private-runtime turn (awaits and its own reflection) runs with this friend. */
|
|
50
49
|
exports.SELF_FRIEND_ID = "self";
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* the card's fix. The message stays first and unchanged; the code is a suffix. Pass the code as a literal: the AX
|
|
54
|
-
* census counts a card's code as raised only where it appears in the handler's file.
|
|
55
|
-
*/
|
|
56
|
-
function withCode(message, code) {
|
|
57
|
-
return `${message} (code: ${code})`;
|
|
58
|
-
}
|
|
50
|
+
var tool_error_code_1 = require("./tool-error-code");
|
|
51
|
+
Object.defineProperty(exports, "withCode", { enumerable: true, get: function () { return tool_error_code_1.withCode; } });
|
|
59
52
|
function routineActionDenied(reason) {
|
|
60
53
|
const message = reason.slice(0, 500);
|
|
61
54
|
(0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.routine_action_denied", message: "routine action denied", meta: { reason: message } });
|
|
@@ -42,6 +42,7 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const shell_sessions_1 = require("./shell-sessions");
|
|
43
43
|
const identity_1 = require("../heart/identity");
|
|
44
44
|
const runtime_1 = require("../nerves/runtime");
|
|
45
|
+
const tool_error_code_1 = require("./tool-error-code");
|
|
45
46
|
const tool_arguments_1 = require("./tool-arguments");
|
|
46
47
|
const tool_limits_1 = require("./tool-limits");
|
|
47
48
|
const MAX_BUFFER = 16 * 1024 * 1024;
|
|
@@ -60,9 +61,10 @@ function shellHome(ctx) {
|
|
|
60
61
|
*/
|
|
61
62
|
/** A failed command as one result: how it ended, then stdout and stderr, each only when it printed something. */
|
|
62
63
|
function shellFailureText(error, timeout, stdout, stderr) {
|
|
64
|
+
// The code goes on the first line, so it survives when a long failure is cut to fit.
|
|
63
65
|
const ended = error.killed && error.signal
|
|
64
|
-
? `the command was stopped after ${timeout} ms (${String(error.signal)}); pass a larger timeout_ms or background: true for long work
|
|
65
|
-
: typeof error.code === "number" ? `the command exited with code ${error.code}
|
|
66
|
+
? (0, tool_error_code_1.withCode)(`the command was stopped after ${timeout} ms (${String(error.signal)}); pass a larger timeout_ms or background: true for long work`, "command-timed-out")
|
|
67
|
+
: typeof error.code === "number" ? (0, tool_error_code_1.withCode)(`the command exited with code ${error.code}`, "command-failed") : (0, tool_error_code_1.withCode)(`the command could not start: ${String(error.code ?? "unknown error")}`, "command-not-started");
|
|
66
68
|
const parts = [ended];
|
|
67
69
|
if (stdout.trim())
|
|
68
70
|
parts.push(`stdout:\n${stdout.trimEnd()}`);
|
|
@@ -193,6 +195,13 @@ exports.shellToolDefinitions = [
|
|
|
193
195
|
return output;
|
|
194
196
|
},
|
|
195
197
|
summaryKeys: ["command"],
|
|
198
|
+
ax: { id: "tool:shell", group: "turn-shell", when: "Pick this to run a program or script in your home; for plain file reads and searches, read_file, grep and glob are safer.", effect: "consequential", confirm: "Approve shell with exact arguments <the call's arguments as JSON>?", errors: [
|
|
199
|
+
{ code: "command-failed", means: "The command ran and exited non-zero; its stdout and stderr follow the first line.", fix: "Read stderr, fix the command or its input, and run it again." },
|
|
200
|
+
{ code: "command-timed-out", means: "The command ran past its timeout and was stopped; whatever it printed follows.", fix: "Run it again with a larger timeout_ms, at most 600000, or with background: true and watch it with shell_status." },
|
|
201
|
+
{ code: "command-not-started", means: "The shell couldn't start the command at all, so nothing ran.", fix: "Check the program's name and that it is installed, then run it again." },
|
|
202
|
+
{ code: "guardrail-blocked", means: "The line writes to a protected path, names the sync key's folder, or runs a command this person isn't trusted for.", fix: "Change the command so it stays off protected paths, or run it from a chat with your owner." },
|
|
203
|
+
{ code: "orientation-hold", means: "This turn is on a correction hold and the command changes things, so it waits.", fix: "Call orientation_get, settle what the person meant, then run the command if it is still right." },
|
|
204
|
+
] },
|
|
196
205
|
},
|
|
197
206
|
{
|
|
198
207
|
tool: {
|
|
@@ -214,10 +223,15 @@ exports.shellToolDefinitions = [
|
|
|
214
223
|
}
|
|
215
224
|
const session = (0, shell_sessions_1.getShellSession)(a.id, shellOwner(ctx));
|
|
216
225
|
if (!session)
|
|
217
|
-
return `process not found: ${a.id}
|
|
226
|
+
return (0, tool_error_code_1.withCode)(`process not found: ${a.id}`, "process-not-found");
|
|
218
227
|
return JSON.stringify(session);
|
|
219
228
|
},
|
|
220
229
|
summaryKeys: ["id"],
|
|
230
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
231
|
+
ax: { id: "tool:shell_status", group: "turn-shell", when: "Pick this to learn whether a background shell you started is still running or how it ended; shell_tail shows its output.", effect: "read", idempotent: true, errors: [
|
|
232
|
+
{ code: "process-not-found", means: "No background shell with that id belongs to you; a runtime restart forgets them all.", fix: "Call shell_status with no id to list yours, or start the command again." },
|
|
233
|
+
{ code: "invalid-arguments", means: "id isn't text.", fix: "Call shell_status again with the id shell returned, or with no id to list them." },
|
|
234
|
+
] },
|
|
221
235
|
},
|
|
222
236
|
{
|
|
223
237
|
tool: {
|
|
@@ -240,9 +254,14 @@ exports.shellToolDefinitions = [
|
|
|
240
254
|
return "id is required";
|
|
241
255
|
const output = (0, shell_sessions_1.tailShellSession)(a.id, shellOwner(ctx));
|
|
242
256
|
if (output === undefined)
|
|
243
|
-
return `process not found: ${a.id}
|
|
257
|
+
return (0, tool_error_code_1.withCode)(`process not found: ${a.id}`, "process-not-found");
|
|
244
258
|
return output || "(no output yet)";
|
|
245
259
|
},
|
|
246
260
|
summaryKeys: ["id"],
|
|
261
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
262
|
+
ax: { id: "tool:shell_tail", group: "turn-shell", when: "Pick this to read the latest lines a background shell you started has printed; shell_status says only whether it still runs.", effect: "read", idempotent: true, errors: [
|
|
263
|
+
{ code: "process-not-found", means: "That id names no background shell of yours, often because the runtime restarted since it began.", fix: "List yours with shell_status, or run the command in the background again." },
|
|
264
|
+
{ code: "invalid-arguments", means: "id is missing or isn't text.", fix: "Call shell_tail again with the id shell returned." },
|
|
265
|
+
] },
|
|
247
266
|
},
|
|
248
267
|
];
|
|
@@ -42,6 +42,7 @@ const https = __importStar(require("node:https"));
|
|
|
42
42
|
const node_net_1 = require("node:net");
|
|
43
43
|
const runtime_1 = require("../nerves/runtime");
|
|
44
44
|
const tool_limits_1 = require("./tool-limits");
|
|
45
|
+
const tool_error_code_1 = require("./tool-error-code");
|
|
45
46
|
const MAX_REDIRECTS = 5;
|
|
46
47
|
/** Test hook: the request deadline. */
|
|
47
48
|
exports.webTestHooks = { timeoutMs: 20_000 };
|
|
@@ -150,22 +151,22 @@ async function fetchPage(rawUrl, offset, exempt) {
|
|
|
150
151
|
url = new URL(rawUrl);
|
|
151
152
|
}
|
|
152
153
|
catch {
|
|
153
|
-
return `error: not a valid URL: ${rawUrl}
|
|
154
|
+
return (0, tool_error_code_1.withCode)(`error: not a valid URL: ${rawUrl}`, "invalid-url");
|
|
154
155
|
}
|
|
155
156
|
const signal = AbortSignal.timeout(exports.webTestHooks.timeoutMs);
|
|
156
157
|
for (let hop = 0;; hop++) {
|
|
157
158
|
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
158
|
-
return `error: only http and https URLs can be fetched, not ${url.protocol}
|
|
159
|
+
return (0, tool_error_code_1.withCode)(`error: only http and https URLs can be fetched, not ${url.protocol}`, "invalid-url");
|
|
159
160
|
const literal = url.hostname.replace(/^\[|\]$/g, "");
|
|
160
161
|
if (!exempt && (0, node_net_1.isIP)(literal) && isPrivateAddress(literal))
|
|
161
|
-
return `error: ${new RefusedError(url.hostname, literal).message}
|
|
162
|
+
return (0, tool_error_code_1.withCode)(`error: ${new RefusedError(url.hostname, literal).message}`, "private-address");
|
|
162
163
|
const response = await get(url, exempt, signal);
|
|
163
164
|
const status = response.statusCode;
|
|
164
165
|
const location = response.headers.location;
|
|
165
166
|
if (status >= 300 && status < 400 && location) {
|
|
166
167
|
response.destroy();
|
|
167
168
|
if (hop >= MAX_REDIRECTS)
|
|
168
|
-
return `error: more than ${MAX_REDIRECTS} redirects fetching ${rawUrl}
|
|
169
|
+
return (0, tool_error_code_1.withCode)(`error: more than ${MAX_REDIRECTS} redirects fetching ${rawUrl}`, "fetch-failed");
|
|
169
170
|
url = new URL(location, url);
|
|
170
171
|
continue;
|
|
171
172
|
}
|
|
@@ -175,7 +176,7 @@ async function fetchPage(rawUrl, offset, exempt) {
|
|
|
175
176
|
}
|
|
176
177
|
if (status < 200 || status >= 300) {
|
|
177
178
|
response.destroy();
|
|
178
|
-
return `error: HTTP ${status} fetching ${url.href}
|
|
179
|
+
return (0, tool_error_code_1.withCode)(`error: HTTP ${status} fetching ${url.href}`, "http-error");
|
|
179
180
|
}
|
|
180
181
|
const type = (response.headers["content-type"] ?? "text/plain").split(";")[0].trim().toLowerCase();
|
|
181
182
|
const isHtml = type === "text/html" || type === "application/xhtml+xml";
|
|
@@ -220,11 +221,18 @@ exports.webToolDefinitions = [
|
|
|
220
221
|
}
|
|
221
222
|
catch (error) {
|
|
222
223
|
if (error instanceof RefusedError)
|
|
223
|
-
return `error: ${error.message}
|
|
224
|
+
return (0, tool_error_code_1.withCode)(`error: ${error.message}`, "private-address");
|
|
224
225
|
const timedOut = error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
|
|
225
|
-
return timedOut ? `error: timed out after ${exports.webTestHooks.timeoutMs / 1000} seconds fetching ${a.url}` : `error: could not fetch ${a.url}: ${error instanceof Error ? error.message : String(error)}
|
|
226
|
+
return (0, tool_error_code_1.withCode)(timedOut ? `error: timed out after ${exports.webTestHooks.timeoutMs / 1000} seconds fetching ${a.url}` : `error: could not fetch ${a.url}: ${error instanceof Error ? error.message : String(error)}`, "fetch-failed");
|
|
226
227
|
}
|
|
227
228
|
},
|
|
228
229
|
summaryKeys: ["url"],
|
|
230
|
+
riskProfile: { mutates: "none", risk: "low" },
|
|
231
|
+
ax: { id: "tool:fetch_url", group: "turn-web", when: "Pick this to read one web page whose address you already have; to find pages about a subject first, use web_search.", effect: "read", idempotent: true, errors: [
|
|
232
|
+
{ code: "invalid-url", means: "url isn't a full http or https address.", fix: "Send the whole address, starting with https://; read a local file with read_file instead." },
|
|
233
|
+
{ code: "private-address", means: "The address leads to this machine or a private network, which only a family member may have fetched.", fix: "Fetch a public address, or ask a family member to have you fetch this one." },
|
|
234
|
+
{ code: "http-error", means: "The site answered with an error status such as 404 or 403, shown in the message.", fix: "Check the address; for a 404, search for where the page moved." },
|
|
235
|
+
{ code: "fetch-failed", means: "The page didn't arrive: the connection failed, it took over 20 seconds, or it redirected more than 5 times.", fix: "Try again once; if it fails again, use another source for the same facts." },
|
|
236
|
+
] },
|
|
229
237
|
},
|
|
230
238
|
];
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1309",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1309",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|