sumo-agents 0.1.0 → 0.3.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/AGENTS.md +3 -2
- package/README.md +97 -611
- package/bin/sumo.mjs +3 -1
- package/guides/delegation.md +8 -7
- package/package.json +3 -2
- package/prompts/agent.md +3 -3
- package/prompts/dream.md +1 -0
- package/prompts/scribe.md +1 -0
- package/src/apply.mjs +79 -19
- package/src/card.mjs +11 -6
- package/src/chat.mjs +215 -40
- package/src/cli.mjs +120 -31
- package/src/cost.mjs +128 -0
- package/src/db.mjs +40 -1
- package/src/export.mjs +1 -1
- package/src/hooks.mjs +8 -1
- package/src/jobs.mjs +606 -59
- package/src/jobtools.mjs +10 -7
- package/src/loop.mjs +358 -53
- package/src/mcp.mjs +44 -14
- package/src/memory.mjs +39 -4
- package/src/model.mjs +6 -5
- package/src/page.mjs +3 -1
- package/src/paths.mjs +9 -2
- package/src/prime.mjs +14 -5
- package/src/render.mjs +1 -0
- package/src/route.mjs +87 -9
- package/src/sandbox.mjs +173 -0
- package/src/scribe.mjs +7 -5
- package/src/sessions.mjs +9 -6
- package/src/setup.mjs +72 -7
- package/src/sqlite.mjs +66 -0
- package/src/text.mjs +8 -3
- package/src/tools.mjs +562 -31
- package/src/tty.mjs +5 -4
- package/src/ui.mjs +74 -18
- package/src/verify.mjs +51 -8
- package/src/worktree.mjs +128 -0
package/src/jobtools.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rmSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import { capRedacted, runCommand } from './tools.mjs';
|
|
3
|
+
import { paths, SELF } from './paths.mjs';
|
|
4
|
+
import { capRedacted, checksWrap, runCommand } from './tools.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* What a sub-agent notes, asks, reads memory and closes its job with: tools of
|
|
@@ -21,7 +21,7 @@ const BASELINE = tool('baseline', "Before your first edit: run the project's che
|
|
|
21
21
|
const VERIFY = tool('verify', "Run the project's checks now and see the verdict DONE will be given. Takes minutes.");
|
|
22
22
|
const FINISH = tool(
|
|
23
23
|
'finish',
|
|
24
|
-
"Close the job — the last thing you do, or nobody knows it ended. A worker's DONE runs the project's checks
|
|
24
|
+
"Close the job — the last thing you do, or nobody knows it ended. A worker's first DONE is answered with the task beside its change, to look over once; the next runs the project's checks and is refused while something new fails.",
|
|
25
25
|
// No way to take the work unverified: that is for the user or the main agent to grant, never the author.
|
|
26
26
|
{ status: { type: 'string', enum: ['DONE', 'FAILED'] }, report: text('the report, in the shape the brief gives') },
|
|
27
27
|
);
|
|
@@ -33,7 +33,7 @@ export const isJobTool = (call) => NAMES.has(call.name);
|
|
|
33
33
|
|
|
34
34
|
/** One word for the shell: left as it is when plain, single-quoted otherwise. */
|
|
35
35
|
const word = (w) => (/^[\w/.:=@%+-]+$/.test(w) ? w : `'${String(w).replaceAll("'", `'\\''`)}'`);
|
|
36
|
-
const sumo = (args) => [
|
|
36
|
+
const sumo = (args) => [...SELF, ...args].map(word).join(' ');
|
|
37
37
|
|
|
38
38
|
/** The command a call stands for, and what it reads on stdin. Null for a call missing what it needs. */
|
|
39
39
|
function commandFor(call, job) {
|
|
@@ -46,7 +46,8 @@ function commandFor(call, job) {
|
|
|
46
46
|
case 'ask':
|
|
47
47
|
return given(input.question) ? { args: ['job', 'ask', id], stdin: input.question } : null;
|
|
48
48
|
case 'search_memory':
|
|
49
|
-
|
|
49
|
+
// The query comes after `--`: one that looks like a flag is still words to search for.
|
|
50
|
+
return given(input.query) ? { args: ['search', '--project', job.project, '--', input.query] } : null;
|
|
50
51
|
case 'baseline':
|
|
51
52
|
return { args: ['job', 'baseline', id], checks: true };
|
|
52
53
|
case 'verify':
|
|
@@ -68,8 +69,10 @@ export async function runJobTool(call, { job, ctx, signal = null }) {
|
|
|
68
69
|
if (file) writeFileSync(file, command.stdin, { mode: 0o600 });
|
|
69
70
|
try {
|
|
70
71
|
const args = file ? [...command.args, '--from-file', file] : command.args;
|
|
71
|
-
// The checks give each command its own limit; anything else is quick.
|
|
72
|
-
|
|
72
|
+
// The checks give each command its own limit; anything else is quick. They run the project's code — tests the model may have
|
|
73
|
+
// written among it — so they run in the sandbox its shell is in, writing only where it may: Sumo's home is one of those places,
|
|
74
|
+
// so the records are still written. A check that fails only for the sandbox fails so at the baseline and at the end alike.
|
|
75
|
+
const run = await runCommand(sumo(args), { cwd: ctx.cwd, env: ctx.env, signal, timeoutMs: command.checks ? null : 60_000, wrap: command.checks ? checksWrap(ctx) : null });
|
|
73
76
|
if (run.error) return { content: run.error, isError: true };
|
|
74
77
|
const output = capRedacted(run.output.trim(), undefined, run.omitted);
|
|
75
78
|
return { content: output || '(done)', isError: run.stopped !== null || run.status !== 0 };
|