clanka 0.24.4 → 0.25.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/dist/Agent.js +1 -1
- package/dist/Agent.js.map +1 -1
- package/dist/AgentCallerConfig.test.js +8 -2
- package/dist/AgentCallerConfig.test.js.map +1 -1
- package/dist/AgentExecutor.js +1 -1
- package/dist/AgentExecutor.js.map +1 -1
- package/dist/AgentExecutor.test.js +14 -0
- package/dist/AgentExecutor.test.js.map +1 -1
- package/dist/AgentTools.d.ts +112 -88
- package/dist/AgentTools.d.ts.map +1 -1
- package/dist/AgentTools.js +43 -35
- package/dist/AgentTools.js.map +1 -1
- package/dist/bin/{AiError-fiHIiGOy.mjs → AiError-CsvdOsKR.mjs} +67 -43
- package/dist/bin/Latch-B3e9629m.mjs +5 -0
- package/dist/bin/{McpClient-CXwyRd_3.mjs → McpClient-BCxZZgnA.mjs} +1 -1
- package/dist/bin/{OutputFormatter-B8yF7iiq.mjs → OutputFormatter-ByMjyBhe.mjs} +2 -2
- package/dist/bin/{Schema-D629S5yu.mjs → Schema-BfUmMefy.mjs} +224 -163
- package/dist/bin/{SemanticSearch-BlcfFvPr.mjs → SemanticSearch-DMzIsoZb.mjs} +68 -55
- package/dist/bin/cli.mjs +506 -381
- package/dist/bin/{helpers-CljL9OKa.mjs → helpers-Bb68A2Sv.mjs} +2 -2
- package/dist/bin/{index.min-ClUfQ5ji.mjs → index.min-CuA3AuA-.mjs} +1448 -1348
- package/dist/bin/{rolldown-runtime-5zChB7MF.mjs → rolldown-runtime-CXhmmSW5.mjs} +4 -4
- package/dist/bin/{server-HlLriZxF.mjs → server-D4nrvZHH.mjs} +2 -2
- package/dist/bin/{turndown.cjs-C2WBxeA-.mjs → turndown.cjs-CwE2EFNQ.mjs} +15 -10
- package/dist/bin/{types-LcwjLVkt.mjs → types-N9Z-HYP0.mjs} +1 -1
- package/dist/bin/{upgrade-E_f-q2h8.mjs → upgrade-t590zYhO.mjs} +4 -4
- package/package.json +15 -15
- package/src/Agent.ts +1 -1
- package/src/AgentCallerConfig.test.ts +39 -28
- package/src/AgentExecutor.test.ts +38 -0
- package/src/AgentExecutor.ts +1 -1
- package/src/AgentTools.ts +59 -44
- package/dist/bin/Latch-D1909CI6.mjs +0 -5
|
@@ -7,18 +7,18 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
|
-
var __exportAll = (all,
|
|
11
|
-
let target = {};
|
|
10
|
+
var __exportAll = (all, flags) => {
|
|
11
|
+
let target = Object.setPrototypeOf({}, null);
|
|
12
12
|
for (var name in all) {
|
|
13
13
|
__defProp(target, name, {
|
|
14
14
|
get: all[name],
|
|
15
15
|
enumerable: true
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
if (!
|
|
18
|
+
if (!(flags & 1)) {
|
|
19
19
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
20
20
|
}
|
|
21
|
-
return target;
|
|
21
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
22
22
|
};
|
|
23
23
|
var __copyProps = (to, from, except, desc) => {
|
|
24
24
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as mergeCapabilities, c as safeParse, i as Protocol, n as assertToolsCallTaskCapability, o as getLiteralValue, r as AjvJsonSchemaValidator, s as getObjectShape, t as assertClientRequestTaskCapability } from "./helpers-
|
|
2
|
-
import { B as SUPPORTED_PROTOCOL_VERSIONS, C as LATEST_PROTOCOL_VERSION, M as LoggingLevelSchema, N as McpError, O as ListRootsResultSchema, V as SetLevelRequestSchema, c as CreateMessageResultSchema, f as ElicitResultSchema, l as CreateMessageResultWithToolsSchema, m as ErrorCode, n as CallToolResultSchema, p as EmptyResultSchema, t as CallToolRequestSchema, u as CreateTaskResultSchema, x as InitializedNotificationSchema, y as InitializeRequestSchema } from "./types-
|
|
1
|
+
import { a as mergeCapabilities, c as safeParse, i as Protocol, n as assertToolsCallTaskCapability, o as getLiteralValue, r as AjvJsonSchemaValidator, s as getObjectShape, t as assertClientRequestTaskCapability } from "./helpers-Bb68A2Sv.mjs";
|
|
2
|
+
import { B as SUPPORTED_PROTOCOL_VERSIONS, C as LATEST_PROTOCOL_VERSION, M as LoggingLevelSchema, N as McpError, O as ListRootsResultSchema, V as SetLevelRequestSchema, c as CreateMessageResultSchema, f as ElicitResultSchema, l as CreateMessageResultWithToolsSchema, m as ErrorCode, n as CallToolResultSchema, p as EmptyResultSchema, t as CallToolRequestSchema, u as CreateTaskResultSchema, x as InitializedNotificationSchema, y as InitializeRequestSchema } from "./types-N9Z-HYP0.mjs";
|
|
3
3
|
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_zod@4.4.2/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
4
4
|
var ExperimentalServerTasks = class {
|
|
5
5
|
constructor(_server) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __commonJSMin } from "./rolldown-runtime-
|
|
1
|
+
import { t as __commonJSMin } from "./rolldown-runtime-CXhmmSW5.mjs";
|
|
2
2
|
// node_modules/.pnpm/@mixmark-io+domino@2.2.0/node_modules/@mixmark-io/domino/lib/Event.js
|
|
3
3
|
var require_Event = __commonJSMin(((exports, module) => {
|
|
4
4
|
module.exports = Event;
|
|
@@ -14506,7 +14506,7 @@ var require_lib = __commonJSMin(((exports) => {
|
|
|
14506
14506
|
};
|
|
14507
14507
|
exports.impl = impl;
|
|
14508
14508
|
}));
|
|
14509
|
-
// node_modules/.pnpm/turndown@7.2.
|
|
14509
|
+
// node_modules/.pnpm/turndown@7.2.5/node_modules/turndown/lib/turndown.cjs.js
|
|
14510
14510
|
var require_turndown_cjs = __commonJSMin(((exports, module) => {
|
|
14511
14511
|
function extend(destination) {
|
|
14512
14512
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -15107,28 +15107,33 @@ var require_turndown_cjs = __commonJSMin(((exports, module) => {
|
|
|
15107
15107
|
var replacement = "";
|
|
15108
15108
|
if (node.nodeType === 3) replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
|
|
15109
15109
|
else if (node.nodeType === 1) replacement = replacementForNode.call(self, node);
|
|
15110
|
-
|
|
15111
|
-
|
|
15110
|
+
join(output, replacement);
|
|
15111
|
+
return output;
|
|
15112
|
+
}, []);
|
|
15112
15113
|
}
|
|
15113
15114
|
function postProcess(output) {
|
|
15114
15115
|
var self = this;
|
|
15115
15116
|
this.rules.forEach(function(rule) {
|
|
15116
|
-
if (typeof rule.append === "function")
|
|
15117
|
+
if (typeof rule.append === "function") join(output, rule.append(self.options));
|
|
15117
15118
|
});
|
|
15118
|
-
return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
15119
|
+
return output.join("").replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
|
|
15119
15120
|
}
|
|
15120
15121
|
function replacementForNode(node) {
|
|
15121
15122
|
var rule = this.rules.forNode(node);
|
|
15122
|
-
var content = process.call(this, node);
|
|
15123
|
+
var content = process.call(this, node).join("");
|
|
15123
15124
|
var whitespace = node.flankingWhitespace;
|
|
15124
15125
|
if (whitespace.leading || whitespace.trailing) content = content.trim();
|
|
15125
15126
|
return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;
|
|
15126
15127
|
}
|
|
15127
15128
|
function join(output, replacement) {
|
|
15128
|
-
var
|
|
15129
|
+
var tail = output.pop() || "";
|
|
15130
|
+
var s1 = trimTrailingNewlines(tail);
|
|
15129
15131
|
var s2 = trimLeadingNewlines(replacement);
|
|
15130
|
-
var nls = Math.max(
|
|
15131
|
-
|
|
15132
|
+
var nls = Math.max(tail.length - s1.length, replacement.length - s2.length);
|
|
15133
|
+
var separator = "\n\n".substring(0, nls);
|
|
15134
|
+
if (s1) output.push(s1);
|
|
15135
|
+
if (separator) output.push(separator);
|
|
15136
|
+
if (s2) output.push(s2);
|
|
15132
15137
|
}
|
|
15133
15138
|
function canConvert(input) {
|
|
15134
15139
|
return input != null && (typeof input === "string" || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ba as scope, Bd as identity, Fi as fail, Ka as succeed, Qi as gen, Us as addFinalizer, Xa as sync, Xs as provide, Ya as suspend, _l as ensure, co as updateContext, di as as, do as void_, gi as callback, ii as acquireRelease, jl as map, mo as withFiber, ni as value, no as timeoutOrElse, xu as merge } from "./Schema-BfUmMefy.mjs";
|
|
2
2
|
import { C as make, S as isCloseEvent, _ as SocketError, b as SocketUpgradeError, g as SocketCloseError, v as SocketOpenError, x as SocketWriteError, y as SocketReadError } from "./cli.mjs";
|
|
3
|
-
import { n as makeUnsafe } from "./Latch-
|
|
3
|
+
import { n as makeUnsafe } from "./Latch-B3e9629m.mjs";
|
|
4
4
|
import { Readable, finished } from "node:stream";
|
|
5
5
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
6
6
|
import * as Tls from "node:tls";
|
|
7
|
-
// node_modules/.pnpm/@effect+platform-node-shared@4.1.
|
|
7
|
+
// node_modules/.pnpm/@effect+platform-node-shared@4.1.3_effect@4.1.3/node_modules/@effect/platform-node-shared/dist/NodeSocket.js
|
|
8
8
|
const isDeno = "Deno" in globalThis;
|
|
9
9
|
const readAvailable = (conn, chunkSize) => {
|
|
10
10
|
const first = conn.read();
|
|
@@ -252,7 +252,7 @@ const fromDuplex = (open, options) => withFiber((fiber) => {
|
|
|
252
252
|
writer
|
|
253
253
|
}));
|
|
254
254
|
});
|
|
255
|
-
// node_modules/.pnpm/@effect+platform-node@4.1.
|
|
255
|
+
// node_modules/.pnpm/@effect+platform-node@4.1.3_effect@4.1.3_redis@6.2.1_@opentelemetry+api@1.10.0_/node_modules/@effect/platform-node/dist/internal/upgrade.js
|
|
256
256
|
const toSocket = (conn, open = void_) => fromDuplex(acquireRelease(suspend(() => conn.destroyed ? fail(openError("The upgraded connection closed before it was read")) : as(open, conn)), (conn) => sync(() => {
|
|
257
257
|
if (conn.destroyed) return;
|
|
258
258
|
if ("destroySoon" in conn) conn.destroySoon();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clanka",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"url": "https://github.com/Effectful-Tech/clanka.git"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
28
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.322",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
30
30
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
31
31
|
"@vscode/ripgrep": "^1.18.0",
|
|
32
32
|
"chalk": "^6.0.1",
|
|
33
|
-
"glob": "^14.0.
|
|
33
|
+
"glob": "^14.0.4",
|
|
34
34
|
"sqlite-vec": "0.1.9",
|
|
35
35
|
"tree-sitter": "^0.21.1",
|
|
36
36
|
"tree-sitter-javascript": "^0.23.1",
|
|
37
37
|
"tree-sitter-typescript": "^0.23.2",
|
|
38
|
-
"turndown": "^7.2.
|
|
38
|
+
"turndown": "^7.2.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@effect/ai-openai": "^4.0.0",
|
|
@@ -45,25 +45,25 @@
|
|
|
45
45
|
"effect": "^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@anthropic-ai/sdk": "^1.
|
|
48
|
+
"@anthropic-ai/sdk": "^1.7.0",
|
|
49
49
|
"@changesets/changelog-github": "^1.0.1",
|
|
50
50
|
"@changesets/cli": "^3.0.3",
|
|
51
|
-
"@effect/ai-openai": "4.1.
|
|
52
|
-
"@effect/ai-openai-compat": "4.1.
|
|
53
|
-
"@effect/platform-node": "4.1.
|
|
54
|
-
"@effect/sql-sqlite-node": "4.1.
|
|
55
|
-
"@effect/tsgo": "0.
|
|
56
|
-
"@effect/vitest": "4.1.
|
|
51
|
+
"@effect/ai-openai": "4.1.3",
|
|
52
|
+
"@effect/ai-openai-compat": "4.1.3",
|
|
53
|
+
"@effect/platform-node": "4.1.3",
|
|
54
|
+
"@effect/sql-sqlite-node": "4.1.3",
|
|
55
|
+
"@effect/tsgo": "0.67.5",
|
|
56
|
+
"@effect/vitest": "4.1.3",
|
|
57
57
|
"@types/node": "^26.6.6",
|
|
58
58
|
"@types/turndown": "^5.0.6",
|
|
59
|
-
"effect": "4.1.
|
|
59
|
+
"effect": "4.1.3",
|
|
60
60
|
"husky": "^9.1.7",
|
|
61
61
|
"lint-staged": "^17.6.0",
|
|
62
|
-
"oxlint": "^1.
|
|
62
|
+
"oxlint": "^1.93.0",
|
|
63
63
|
"prettier": "^3.9.10",
|
|
64
|
-
"tsdown": "^0.23.
|
|
64
|
+
"tsdown": "^0.23.7",
|
|
65
65
|
"typescript": "^7.0.2",
|
|
66
|
-
"vitest": "^5.0
|
|
66
|
+
"vitest": "^5.1.0"
|
|
67
67
|
},
|
|
68
68
|
"lint-staged": {
|
|
69
69
|
"*.{ts,tsx}": [
|
package/src/Agent.ts
CHANGED
|
@@ -1691,7 +1691,7 @@ const incompleteResponseError = (description: string) =>
|
|
|
1691
1691
|
|
|
1692
1692
|
const retryPolicy = Schedule.min([
|
|
1693
1693
|
Schedule.exponential(100, 1.5),
|
|
1694
|
-
Schedule.spaced(
|
|
1694
|
+
Schedule.spaced({ minutes: 5 }),
|
|
1695
1695
|
]).pipe(Schedule.jittered)
|
|
1696
1696
|
|
|
1697
1697
|
const environmentUpdateOpen = "<environment-update>"
|
|
@@ -286,34 +286,45 @@ await taskComplete(missing + " " + call)`,
|
|
|
286
286
|
|
|
287
287
|
// The shared task functions address bash and agent tasks, so they stay
|
|
288
288
|
// while either kind can still be started.
|
|
289
|
-
it.live(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
289
|
+
it.live(
|
|
290
|
+
"the task functions go only when bash, run and subagent all go",
|
|
291
|
+
() =>
|
|
292
|
+
Effect.gen(function* () {
|
|
293
|
+
const tasks =
|
|
294
|
+
"[typeof taskOutput, typeof waitTasks, typeof stopTask, typeof listTasks].join()"
|
|
295
|
+
const withBash = yield* runAgent({
|
|
296
|
+
mode,
|
|
297
|
+
executor: { excludeTools: ["subagent"] },
|
|
298
|
+
script: `await taskComplete(${tasks})`,
|
|
299
|
+
})
|
|
300
|
+
assert.strictEqual(
|
|
301
|
+
withBash.summary,
|
|
302
|
+
"function,function,function,function",
|
|
303
|
+
)
|
|
304
|
+
const withRun = yield* runAgent({
|
|
305
|
+
mode,
|
|
306
|
+
executor: { excludeTools: ["bash", "subagent"] },
|
|
307
|
+
script: `await taskComplete(${tasks})`,
|
|
308
|
+
})
|
|
309
|
+
assert.strictEqual(
|
|
310
|
+
withRun.summary,
|
|
311
|
+
"function,function,function,function",
|
|
312
|
+
)
|
|
313
|
+
const withNeither = yield* runAgent({
|
|
314
|
+
mode,
|
|
315
|
+
executor: { excludeTools: ["bash", "run", "subagent"] },
|
|
316
|
+
script: `await taskComplete(${tasks})`,
|
|
317
|
+
})
|
|
318
|
+
assert.strictEqual(
|
|
319
|
+
withNeither.summary,
|
|
320
|
+
"undefined,undefined,undefined,undefined",
|
|
321
|
+
)
|
|
322
|
+
assert.notMatch(
|
|
323
|
+
withNeither.system,
|
|
324
|
+
/\b(taskOutput|waitTasks|stopTask|listTasks)\b/,
|
|
325
|
+
)
|
|
326
|
+
assert.notInclude(withNeither.system, "<task")
|
|
327
|
+
}),
|
|
317
328
|
)
|
|
318
329
|
|
|
319
330
|
it.live("a caller tool replaces a left-out built-in of the same name", () =>
|
|
@@ -558,6 +558,44 @@ await sleep(60000)`,
|
|
|
558
558
|
})
|
|
559
559
|
|
|
560
560
|
describe(`${mode} executor limits`, () => {
|
|
561
|
+
it.live("run accepts only a string and returns command output", () =>
|
|
562
|
+
Effect.gen(function* () {
|
|
563
|
+
const output = yield* runScript(
|
|
564
|
+
'console.log("OUTPUT:", JSON.stringify(await run("printf hello"))); try { await run({ command: "echo invalid" }) } catch { console.log("INVALID") }',
|
|
565
|
+
)
|
|
566
|
+
assert.include(output, 'OUTPUT: "hello"')
|
|
567
|
+
assert.include(output, "INVALID")
|
|
568
|
+
}).pipe(Effect.provide(executorLayer({}))),
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
it.live(
|
|
572
|
+
"run hands timed-out commands to the background with a string notice",
|
|
573
|
+
() =>
|
|
574
|
+
Effect.gen(function* () {
|
|
575
|
+
const executor = yield* AgentExecutor.AgentExecutor
|
|
576
|
+
const { environment } = yield* executor.capabilities
|
|
577
|
+
const output = yield* runScript(
|
|
578
|
+
`console.log("OUTPUT:", JSON.stringify(await run(${JSON.stringify(gatedCommand(environment.cwd))})))`,
|
|
579
|
+
)
|
|
580
|
+
assert.strictEqual(
|
|
581
|
+
JSON.parse(output.split("OUTPUT:")[1]!),
|
|
582
|
+
'Task "1" is still running in the background',
|
|
583
|
+
)
|
|
584
|
+
assert.strictEqual(
|
|
585
|
+
yield* waitForLog(environment.cwd, started),
|
|
586
|
+
"start\n",
|
|
587
|
+
)
|
|
588
|
+
openGate(environment.cwd)
|
|
589
|
+
assert.strictEqual(
|
|
590
|
+
yield* waitForLog(environment.cwd, finished),
|
|
591
|
+
"start\nfinish\n",
|
|
592
|
+
)
|
|
593
|
+
}).pipe(
|
|
594
|
+
Effect.timeout("5 seconds"),
|
|
595
|
+
Effect.provide(executorLayer({ commandTimeout: "300 millis" })),
|
|
596
|
+
),
|
|
597
|
+
)
|
|
598
|
+
|
|
561
599
|
it.live("runs a bash command in the background", () =>
|
|
562
600
|
Effect.gen(function* () {
|
|
563
601
|
const executor = yield* AgentExecutor.AgentExecutor
|
package/src/AgentExecutor.ts
CHANGED
|
@@ -1390,7 +1390,7 @@ const excludedToolNames = (
|
|
|
1390
1390
|
const names = new Set<string>(excludeTools)
|
|
1391
1391
|
if (names.has("subagent")) {
|
|
1392
1392
|
names.add("messageAgent")
|
|
1393
|
-
if (names.has("bash")) {
|
|
1393
|
+
if (names.has("bash") && names.has("run")) {
|
|
1394
1394
|
for (const name of ["taskOutput", "waitTasks", "stopTask", "listTasks"]) {
|
|
1395
1395
|
names.add(name)
|
|
1396
1396
|
}
|
package/src/AgentTools.ts
CHANGED
|
@@ -426,6 +426,13 @@ export const AgentTools = Toolkit.make(
|
|
|
426
426
|
dependencies: [CurrentDirectory],
|
|
427
427
|
}),
|
|
428
428
|
makeBashTool(defaultBashTimeout),
|
|
429
|
+
Tool.make("run", {
|
|
430
|
+
description:
|
|
431
|
+
"Run a bash command in the foreground and return its output. If it takes longer than 2 minutes it will become a background task.",
|
|
432
|
+
parameters: Schema.String.annotate({ identifier: "command" }),
|
|
433
|
+
success: Schema.String,
|
|
434
|
+
dependencies: [CurrentDirectory],
|
|
435
|
+
}),
|
|
429
436
|
Tool.make("taskOutput", {
|
|
430
437
|
description:
|
|
431
438
|
"Return the status and output so far of one of your tasks: a background bash command or a sub-agent.",
|
|
@@ -721,6 +728,53 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
721
728
|
return `Image attached: ${fileName}`
|
|
722
729
|
})
|
|
723
730
|
|
|
731
|
+
const bash = Effect.fn("AgentTools.bash")(function* (options: {
|
|
732
|
+
readonly command: string
|
|
733
|
+
readonly timeoutMs?: number | undefined
|
|
734
|
+
readonly background?: boolean | undefined
|
|
735
|
+
}) {
|
|
736
|
+
const maxMs = bashTimeoutMs(yield* CommandLimits)
|
|
737
|
+
const timeoutMs = Math.min(options.timeoutMs ?? maxMs, maxMs)
|
|
738
|
+
yield* Effect.logInfo(`Calling "bash"`).pipe(
|
|
739
|
+
Effect.annotateLogs({
|
|
740
|
+
...options,
|
|
741
|
+
timeoutMs,
|
|
742
|
+
}),
|
|
743
|
+
)
|
|
744
|
+
const cwd = yield* CurrentDirectory
|
|
745
|
+
const cmd = ChildProcess.make("bash", ["-c", options.command], {
|
|
746
|
+
cwd,
|
|
747
|
+
stdin: "ignore",
|
|
748
|
+
})
|
|
749
|
+
const entry = yield* addBashTask(
|
|
750
|
+
options.command,
|
|
751
|
+
yield* startCommand(cmd, true),
|
|
752
|
+
)
|
|
753
|
+
if (options.background !== true) {
|
|
754
|
+
const exit = yield* awaitCommand(
|
|
755
|
+
entry.command,
|
|
756
|
+
Duration.millis(timeoutMs),
|
|
757
|
+
)
|
|
758
|
+
if (Option.isSome(exit)) {
|
|
759
|
+
// A finished command is reported here, so it is never pushed.
|
|
760
|
+
const exitCode = yield* exit.value
|
|
761
|
+
const task = reportBash(entry)
|
|
762
|
+
if (exitCode === 0) return task
|
|
763
|
+
return yield* Effect.die(
|
|
764
|
+
new Error(
|
|
765
|
+
`Command failed with exit code ${exitCode}: ${task.output}`,
|
|
766
|
+
),
|
|
767
|
+
)
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
// Snapshot the task before yielding to the watcher: the command can
|
|
771
|
+
// finish while it is being handed over, and its final state must
|
|
772
|
+
// reach the model only once. A finished task is never handed over.
|
|
773
|
+
const task = reportBash(entry)
|
|
774
|
+
if (task.status === "running") yield* watchBashTask(entry)
|
|
775
|
+
return options.background === true ? task : backgroundRunningOutput(task)
|
|
776
|
+
}, Effect.orDie)
|
|
777
|
+
|
|
724
778
|
return AgentToolsWithSearch.of({
|
|
725
779
|
changeDirectory: Effect.fn("AgentTools.changeDirectory")(
|
|
726
780
|
function* (directory) {
|
|
@@ -891,50 +945,11 @@ export const AgentToolHandlersNoDeps = AgentToolsWithSearch.toLayer(
|
|
|
891
945
|
import("glob").then((Glob) => Glob.glob(pattern, { cwd })),
|
|
892
946
|
)
|
|
893
947
|
}),
|
|
894
|
-
bash
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
...options,
|
|
900
|
-
timeoutMs,
|
|
901
|
-
}),
|
|
902
|
-
)
|
|
903
|
-
const cwd = yield* CurrentDirectory
|
|
904
|
-
const cmd = ChildProcess.make("bash", ["-c", options.command], {
|
|
905
|
-
cwd,
|
|
906
|
-
stdin: "ignore",
|
|
907
|
-
})
|
|
908
|
-
const entry = yield* addBashTask(
|
|
909
|
-
options.command,
|
|
910
|
-
yield* startCommand(cmd, true),
|
|
911
|
-
)
|
|
912
|
-
if (options.background !== true) {
|
|
913
|
-
const exit = yield* awaitCommand(
|
|
914
|
-
entry.command,
|
|
915
|
-
Duration.millis(timeoutMs),
|
|
916
|
-
)
|
|
917
|
-
if (Option.isSome(exit)) {
|
|
918
|
-
// A finished command is reported here, so it is never pushed.
|
|
919
|
-
const exitCode = yield* exit.value
|
|
920
|
-
const task = reportBash(entry)
|
|
921
|
-
if (exitCode === 0) return task
|
|
922
|
-
return yield* Effect.die(
|
|
923
|
-
new Error(
|
|
924
|
-
`Command failed with exit code ${exitCode}: ${task.output}`,
|
|
925
|
-
),
|
|
926
|
-
)
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
// Snapshot the task before yielding to the watcher: the command can
|
|
930
|
-
// finish while it is being handed over, and its final state must
|
|
931
|
-
// reach the model only once. A finished task is never handed over.
|
|
932
|
-
const task = reportBash(entry)
|
|
933
|
-
if (task.status === "running") yield* watchBashTask(entry)
|
|
934
|
-
return options.background === true
|
|
935
|
-
? task
|
|
936
|
-
: backgroundRunningOutput(task)
|
|
937
|
-
}, Effect.orDie),
|
|
948
|
+
bash,
|
|
949
|
+
run: Effect.fn("AgentTools.run")(function* (command) {
|
|
950
|
+
const task = yield* bash({ command, timeoutMs: 120_000 })
|
|
951
|
+
return task.output
|
|
952
|
+
}),
|
|
938
953
|
taskOutput: Effect.fn("AgentTools.taskOutput")(function* (
|
|
939
954
|
input: unknown,
|
|
940
955
|
) {
|