@william_jin/autobrowse 0.8.26 → 0.8.28
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/assets/live-view/hub.html +71 -36
- package/assets/live-view/viewer.html +292 -21
- package/assets/overlay/bin/win32-arm64/overlay-host.exe +0 -0
- package/assets/overlay/bin/win32-x64/overlay-host.exe +0 -0
- package/dist/app/cli-record.js +17 -6
- package/dist/app/cli-record.js.map +1 -1
- package/dist/app/cli-task.d.ts +25 -0
- package/dist/app/cli-task.js +156 -0
- package/dist/app/cli-task.js.map +1 -0
- package/dist/app/config.d.ts +0 -1
- package/dist/app/config.js +1 -1
- package/dist/app/config.js.map +1 -1
- package/dist/app/help.js +1 -0
- package/dist/app/help.js.map +1 -1
- package/dist/app/task.d.ts +182 -0
- package/dist/app/task.js +382 -0
- package/dist/app/task.js.map +1 -0
- package/dist/auth/sign-in-kit.d.ts +2 -0
- package/dist/auth/sign-in-kit.js +52 -13
- package/dist/auth/sign-in-kit.js.map +1 -1
- package/dist/browser/flow-api.d.ts +2 -0
- package/dist/browser/flow-api.js.map +1 -1
- package/dist/browser/flow.js +3 -1
- package/dist/browser/flow.js.map +1 -1
- package/dist/browser/live-term.d.ts +78 -0
- package/dist/browser/live-term.js +341 -0
- package/dist/browser/live-term.js.map +1 -0
- package/dist/browser/live-view.d.ts +3 -0
- package/dist/browser/live-view.js +44 -2
- package/dist/browser/live-view.js.map +1 -1
- package/dist/explore/commands.d.ts +11 -8
- package/dist/explore/commands.js +3 -0
- package/dist/explore/commands.js.map +1 -1
- package/dist/explore/server.d.ts +8 -0
- package/dist/explore/server.js +23 -3
- package/dist/explore/server.js.map +1 -1
- package/dist/llms.txt +2 -1
- package/package.json +7 -2
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { DoneActs } from "../browser/attempt.js";
|
|
3
|
+
/** A dir name and a tmux target: tmux turns `.` and `:` into `_`. */
|
|
4
|
+
export declare const TASK_ID: RegExp;
|
|
5
|
+
export declare const EXIT_GLITCH = 75;
|
|
6
|
+
export declare const RETRY_AFTER_S = 120;
|
|
7
|
+
/** wren's host agent keeps the last 4,000 characters of output (host/agent.ts TAIL); the result line stays under it. */
|
|
8
|
+
export declare const OUTPUT_MAX = 3000;
|
|
9
|
+
/** From the stop note to the end of the session. */
|
|
10
|
+
export declare const STOP_GRACE_MS: number;
|
|
11
|
+
/** The run ends this long before the host's kill, so a result goes out. */
|
|
12
|
+
export declare const TIMEOUT_MARGIN_MIN = 3;
|
|
13
|
+
/** The host's slack under `timeoutMin` that zod keeps free. */
|
|
14
|
+
export declare const SLACK_MIN = 5;
|
|
15
|
+
export declare const MARK_ACT = "started";
|
|
16
|
+
export declare const taskSchema: (timeoutMin: number) => z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
goal: z.ZodString;
|
|
19
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
20
|
+
inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
budget: z.ZodPrefault<z.ZodObject<{
|
|
22
|
+
min: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
tools: z.ZodPrefault<z.ZodObject<{
|
|
25
|
+
signIn: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
codes: z.ZodDefault<z.ZodNullable<z.ZodEmail>>;
|
|
27
|
+
allowDomains: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
retry: z.ZodDefault<z.ZodEnum<{
|
|
30
|
+
once: "once";
|
|
31
|
+
safe: "safe";
|
|
32
|
+
}>>;
|
|
33
|
+
humanWaitMin: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
export type Task = z.output<ReturnType<typeof taskSchema>>;
|
|
36
|
+
export type TaskStatus = "done" | "failed" | "needs-human" | "budget";
|
|
37
|
+
export interface TaskResult {
|
|
38
|
+
status: TaskStatus;
|
|
39
|
+
output?: unknown;
|
|
40
|
+
why?: string;
|
|
41
|
+
/** `budget` only: which one ran out. */
|
|
42
|
+
budget?: "budget.min" | "timeoutMin";
|
|
43
|
+
/** The host run that wrote it (`JOB_RUN`): a later run never reads another's result. */
|
|
44
|
+
run?: string | null;
|
|
45
|
+
}
|
|
46
|
+
export type TaskEnd = {
|
|
47
|
+
kind: "result";
|
|
48
|
+
result: TaskResult;
|
|
49
|
+
}
|
|
50
|
+
/** Chrome did not start, the profile is busy, memory is critical: 75, no strike. */
|
|
51
|
+
| {
|
|
52
|
+
kind: "glitch";
|
|
53
|
+
why: string;
|
|
54
|
+
}
|
|
55
|
+
/** Anything else: 1 and a strike; `fingerprint` groups it in the DLQ, so no ids in it. */
|
|
56
|
+
| {
|
|
57
|
+
kind: "fail";
|
|
58
|
+
fingerprint: string;
|
|
59
|
+
why: string;
|
|
60
|
+
};
|
|
61
|
+
/** The exit code and the last lines; `wren:result` is the very last on a known end. */
|
|
62
|
+
export declare function exitOf(end: TaskEnd, id: string | null): {
|
|
63
|
+
code: number;
|
|
64
|
+
lines: string[];
|
|
65
|
+
};
|
|
66
|
+
/** The once rule: a later try of a `once` task that finds the start mark ends as needs-you, no Chrome. */
|
|
67
|
+
export declare function onceEnds(o: {
|
|
68
|
+
attempt: number;
|
|
69
|
+
retry: Task["retry"];
|
|
70
|
+
marked: boolean;
|
|
71
|
+
}): TaskResult | null;
|
|
72
|
+
export declare const resultFile: (taskDir: string) => string;
|
|
73
|
+
export declare function readResult(taskDir: string): TaskResult | null;
|
|
74
|
+
/** `autobrowse cmd finish '<json>'`: the result file, whole (a temp file, then a rename). */
|
|
75
|
+
export declare function finishTask(env: Record<string, string | undefined>, json: string): {
|
|
76
|
+
said: string;
|
|
77
|
+
};
|
|
78
|
+
/** What the clocks say at one poll. A person wait stops the budget clock, not the overall one. */
|
|
79
|
+
export declare function tick(s: {
|
|
80
|
+
now: number;
|
|
81
|
+
startedAt: number;
|
|
82
|
+
/** Person waits already over, in ms. */
|
|
83
|
+
waitedMs: number;
|
|
84
|
+
ask: {
|
|
85
|
+
why: string;
|
|
86
|
+
at: number;
|
|
87
|
+
} | null;
|
|
88
|
+
budgetMin: number;
|
|
89
|
+
humanWaitMin: number;
|
|
90
|
+
timeoutMin: number;
|
|
91
|
+
/** When the stop note went in; null before. */
|
|
92
|
+
noteAt: number | null;
|
|
93
|
+
}): "go" | "note" | TaskResult;
|
|
94
|
+
export declare const stopNote: (budgetMin: number) => string;
|
|
95
|
+
/** The prompt file: the goal, the inputs, the port, the two verbs, the budget. */
|
|
96
|
+
export declare function promptText(t: Task, o: {
|
|
97
|
+
site: string;
|
|
98
|
+
port: number;
|
|
99
|
+
skill: string;
|
|
100
|
+
}): string;
|
|
101
|
+
/** Shell single quotes. */
|
|
102
|
+
export declare const sq: (s: string) => string;
|
|
103
|
+
/** `autobrowse` first on the session's PATH: the same install as the task child, from its cwd. */
|
|
104
|
+
export declare function shimText(cli: {
|
|
105
|
+
node: string;
|
|
106
|
+
args: string[];
|
|
107
|
+
cwd: string;
|
|
108
|
+
}): string;
|
|
109
|
+
/**
|
|
110
|
+
* Env names a nested Claude Code must not see: its own session's ids, sockets and the nesting
|
|
111
|
+
* check; an API key from autobrowse's env file (Claude asks to use it; William's login runs tasks).
|
|
112
|
+
*/
|
|
113
|
+
export declare const claudeEnvNames: (env: Record<string, string | undefined>) => string[];
|
|
114
|
+
/** Claude Code's argv: the allow-list, `dontAsk` (the user default may be bypassPermissions), no MCP. */
|
|
115
|
+
export declare function claudeArgv(claude: string, promptFile: string, id: string): string[];
|
|
116
|
+
export declare function runScript(o: {
|
|
117
|
+
argv: string[];
|
|
118
|
+
bin: string;
|
|
119
|
+
env: Record<string, string>;
|
|
120
|
+
unset: string[];
|
|
121
|
+
}): string;
|
|
122
|
+
export interface Tmux {
|
|
123
|
+
has(name: string): boolean;
|
|
124
|
+
start(name: string, cwd: string, script: string): void;
|
|
125
|
+
kill(name: string): void;
|
|
126
|
+
capture(name: string): string;
|
|
127
|
+
/** tmux key names (`Enter`, `Down`, `Escape`), or text with `literal`. */
|
|
128
|
+
keys(name: string, keys: string[], literal?: boolean): void;
|
|
129
|
+
}
|
|
130
|
+
export interface TaskBrowser {
|
|
131
|
+
port: number;
|
|
132
|
+
humanAsk(): {
|
|
133
|
+
why: string;
|
|
134
|
+
at: number;
|
|
135
|
+
} | null;
|
|
136
|
+
/** The hub's Claude terminal on this tmux session; null takes it away. */
|
|
137
|
+
terminal?(session: string | null): void;
|
|
138
|
+
closed(): boolean;
|
|
139
|
+
close(): Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
export interface TaskDeps {
|
|
142
|
+
env: Record<string, string | undefined>;
|
|
143
|
+
/** `<artifactsDir>/tasks`: each task's dir below; Claude's cwd, trusted once. */
|
|
144
|
+
root: string;
|
|
145
|
+
marks: DoneActs;
|
|
146
|
+
tmux: Tmux | null;
|
|
147
|
+
claude: string | null;
|
|
148
|
+
timeoutMin: number;
|
|
149
|
+
/** The path key (`JOB_KEY`) or `--site`; null: `scratch-<id>`. */
|
|
150
|
+
site: string | null;
|
|
151
|
+
/** The CLI this child runs, for the shim. */
|
|
152
|
+
cli: {
|
|
153
|
+
node: string;
|
|
154
|
+
args: string[];
|
|
155
|
+
cwd: string;
|
|
156
|
+
};
|
|
157
|
+
/** Where the explore skill's commands are. */
|
|
158
|
+
skill: string;
|
|
159
|
+
now(): number;
|
|
160
|
+
sleep(ms: number): Promise<void>;
|
|
161
|
+
/** Text when memory is too low to open a browser; null when fine. */
|
|
162
|
+
memoryStop(): Promise<string | null>;
|
|
163
|
+
open(o: {
|
|
164
|
+
site: string;
|
|
165
|
+
task: Task;
|
|
166
|
+
taskDir: string;
|
|
167
|
+
}): Promise<TaskBrowser>;
|
|
168
|
+
/** True when `err` is a busy profile (`ProfileBusy`). */
|
|
169
|
+
busy(err: unknown): boolean;
|
|
170
|
+
/** Called with the cleanup once a session exists: a SIGTERM runs it. */
|
|
171
|
+
onStop?(fn: () => void): void;
|
|
172
|
+
log(line: string): void;
|
|
173
|
+
/** Poll step; 1 s. */
|
|
174
|
+
pollMs?: number;
|
|
175
|
+
}
|
|
176
|
+
/** Claude Code's folder trust prompt waits on a new cwd (default "No, exit"): pick yes. True once past. */
|
|
177
|
+
export declare function acceptTrust(tmux: Tmux, name: string): boolean;
|
|
178
|
+
/** One task, start to end. Never throws: every way out is a `TaskEnd`. */
|
|
179
|
+
export declare function runTask(raw: string, d: TaskDeps): Promise<{
|
|
180
|
+
id: string | null;
|
|
181
|
+
end: TaskEnd;
|
|
182
|
+
}>;
|
package/dist/app/task.js
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `autobrowse task`: one queued goal done by a Claude Code session in tmux, on an explore
|
|
3
|
+
* session with the live view (designs/2026-12-01-agent-task.md). The task, the exit table, the
|
|
4
|
+
* once rule, the clocks, `cmd finish`, and the run itself over injected parts (cli-task.ts wires
|
|
5
|
+
* the real ones).
|
|
6
|
+
*/
|
|
7
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
/** A dir name and a tmux target: tmux turns `.` and `:` into `_`. */
|
|
11
|
+
export const TASK_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
12
|
+
export const EXIT_GLITCH = 75;
|
|
13
|
+
export const RETRY_AFTER_S = 120;
|
|
14
|
+
/** wren's host agent keeps the last 4,000 characters of output (host/agent.ts TAIL); the result line stays under it. */
|
|
15
|
+
export const OUTPUT_MAX = 3_000;
|
|
16
|
+
/** From the stop note to the end of the session. */
|
|
17
|
+
export const STOP_GRACE_MS = 2 * 60_000;
|
|
18
|
+
/** The run ends this long before the host's kill, so a result goes out. */
|
|
19
|
+
export const TIMEOUT_MARGIN_MIN = 3;
|
|
20
|
+
/** The host's slack under `timeoutMin` that zod keeps free. */
|
|
21
|
+
export const SLACK_MIN = 5;
|
|
22
|
+
export const MARK_ACT = "started";
|
|
23
|
+
export const taskSchema = (timeoutMin) => z
|
|
24
|
+
.object({
|
|
25
|
+
id: z.string().regex(TASK_ID, "letters, digits, _ and - only, at most 64"),
|
|
26
|
+
goal: z.string().min(1).max(4_000),
|
|
27
|
+
url: z.url().optional(),
|
|
28
|
+
inputs: z
|
|
29
|
+
.record(z.string(), z.unknown())
|
|
30
|
+
.default({})
|
|
31
|
+
.refine((v) => JSON.stringify(v).length <= 20_000, "inputs: 20,000 characters of JSON at most"),
|
|
32
|
+
budget: z.object({ min: z.number().int().min(1).max(240) }).prefault({ min: 30 }),
|
|
33
|
+
tools: z
|
|
34
|
+
.object({
|
|
35
|
+
signIn: z.boolean().default(true),
|
|
36
|
+
codes: z.email().nullable().default(null),
|
|
37
|
+
allowDomains: z.array(z.string().min(1)).default([]),
|
|
38
|
+
})
|
|
39
|
+
.strict()
|
|
40
|
+
.prefault({}),
|
|
41
|
+
retry: z.enum(["once", "safe"]).default("once"),
|
|
42
|
+
humanWaitMin: z.number().int().min(1).max(120).default(15),
|
|
43
|
+
})
|
|
44
|
+
.strict()
|
|
45
|
+
.refine((t) => t.budget.min + t.humanWaitMin <= timeoutMin - SLACK_MIN, {
|
|
46
|
+
message: `budget.min + humanWaitMin must be at most timeoutMin - ${SLACK_MIN} (${timeoutMin - SLACK_MIN})`,
|
|
47
|
+
});
|
|
48
|
+
/** The exit code and the last lines; `wren:result` is the very last on a known end. */
|
|
49
|
+
export function exitOf(end, id) {
|
|
50
|
+
if (end.kind === "glitch")
|
|
51
|
+
return { code: EXIT_GLITCH, lines: [end.why, `wren:retry-after ${RETRY_AFTER_S}`] };
|
|
52
|
+
if (end.kind === "fail")
|
|
53
|
+
return { code: 1, lines: [end.why, `wren:fingerprint ${end.fingerprint}`] };
|
|
54
|
+
const { run: _run, ...r } = end.result;
|
|
55
|
+
let line = JSON.stringify({ id, ...r });
|
|
56
|
+
if (line.length > OUTPUT_MAX + 500)
|
|
57
|
+
line = JSON.stringify({
|
|
58
|
+
id,
|
|
59
|
+
...r,
|
|
60
|
+
output: { cut: true, text: JSON.stringify(r.output).slice(0, OUTPUT_MAX) },
|
|
61
|
+
});
|
|
62
|
+
return { code: 0, lines: [`wren:result ${line}`] };
|
|
63
|
+
}
|
|
64
|
+
/** The once rule: a later try of a `once` task that finds the start mark ends as needs-you, no Chrome. */
|
|
65
|
+
export function onceEnds(o) {
|
|
66
|
+
return o.attempt > 1 && o.retry === "once" && o.marked
|
|
67
|
+
? { status: "needs-human", why: "may have acted; check it (a retry found the start mark)" }
|
|
68
|
+
: null;
|
|
69
|
+
}
|
|
70
|
+
export const resultFile = (taskDir) => join(taskDir, "result.json");
|
|
71
|
+
export function readResult(taskDir) {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(readFileSync(resultFile(taskDir), "utf8"));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const finishSchema = z
|
|
80
|
+
.object({
|
|
81
|
+
status: z.enum(["done", "failed", "needs-human"]),
|
|
82
|
+
output: z.unknown().optional(),
|
|
83
|
+
why: z.string().min(1).max(500).optional(),
|
|
84
|
+
})
|
|
85
|
+
.strict();
|
|
86
|
+
/** `autobrowse cmd finish '<json>'`: the result file, whole (a temp file, then a rename). */
|
|
87
|
+
export function finishTask(env, json) {
|
|
88
|
+
const dir = env.AUTOBROWSE_TASK_DIR;
|
|
89
|
+
if (!dir)
|
|
90
|
+
throw new Error("finish: only inside an autobrowse task (no AUTOBROWSE_TASK_DIR)");
|
|
91
|
+
let raw;
|
|
92
|
+
try {
|
|
93
|
+
raw = JSON.parse(json);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
throw new Error('finish: give one JSON object: autobrowse cmd finish \'{"status":"done","output":…}\'');
|
|
97
|
+
}
|
|
98
|
+
const got = finishSchema.safeParse(raw);
|
|
99
|
+
if (!got.success)
|
|
100
|
+
throw new Error(`finish: ${z.prettifyError(got.error)}`);
|
|
101
|
+
const size = JSON.stringify(got.data.output ?? null).length;
|
|
102
|
+
if (size > OUTPUT_MAX)
|
|
103
|
+
throw new Error(`finish: output is ${size} characters of JSON; ${OUTPUT_MAX} at most. Keep what the goal asks for`);
|
|
104
|
+
const { status, output, why } = got.data;
|
|
105
|
+
const result = {
|
|
106
|
+
status,
|
|
107
|
+
...(output !== undefined ? { output } : {}),
|
|
108
|
+
...(why ? { why } : {}),
|
|
109
|
+
run: env.AUTOBROWSE_TASK_RUN || null,
|
|
110
|
+
};
|
|
111
|
+
const tmp = `${resultFile(dir)}.tmp`;
|
|
112
|
+
writeFileSync(tmp, JSON.stringify(result), { mode: 0o600 });
|
|
113
|
+
renameSync(tmp, resultFile(dir));
|
|
114
|
+
return { said: `finished: ${result.status}. This session ends in a few seconds.` };
|
|
115
|
+
}
|
|
116
|
+
/** What the clocks say at one poll. A person wait stops the budget clock, not the overall one. */
|
|
117
|
+
export function tick(s) {
|
|
118
|
+
if (s.now - s.startedAt >= (s.timeoutMin - TIMEOUT_MARGIN_MIN) * 60_000)
|
|
119
|
+
return {
|
|
120
|
+
status: "budget",
|
|
121
|
+
budget: "timeoutMin",
|
|
122
|
+
why: `the run reached timeoutMin ${s.timeoutMin} less ${TIMEOUT_MARGIN_MIN}`,
|
|
123
|
+
};
|
|
124
|
+
if (s.noteAt !== null)
|
|
125
|
+
return s.now - s.noteAt >= STOP_GRACE_MS
|
|
126
|
+
? {
|
|
127
|
+
status: "budget",
|
|
128
|
+
budget: "budget.min",
|
|
129
|
+
why: `${s.budgetMin} min of work, then the stop note`,
|
|
130
|
+
}
|
|
131
|
+
: "go";
|
|
132
|
+
if (s.ask && s.now - s.ask.at >= s.humanWaitMin * 60_000)
|
|
133
|
+
return { status: "needs-human", why: s.ask.why };
|
|
134
|
+
const worked = s.now - s.startedAt - s.waitedMs - (s.ask ? s.now - s.ask.at : 0);
|
|
135
|
+
return worked >= s.budgetMin * 60_000 ? "note" : "go";
|
|
136
|
+
}
|
|
137
|
+
export const stopNote = (budgetMin) => `STOP: the task's budget (${budgetMin} min) is spent. Within 2 minutes run autobrowse cmd finish with what you have (status done, failed or needs-human, and a why); then this session ends.`;
|
|
138
|
+
/** The prompt file: the goal, the inputs, the port, the two verbs, the budget. */
|
|
139
|
+
export function promptText(t, o) {
|
|
140
|
+
return `# Task ${t.id}
|
|
141
|
+
|
|
142
|
+
You do one task in a browser for William. He watches this terminal and the browser, and may type here at any time: follow him.
|
|
143
|
+
|
|
144
|
+
## The task
|
|
145
|
+
|
|
146
|
+
Goal: ${t.goal}
|
|
147
|
+
Start page: ${t.url ?? "none given (the browser is open on a blank page)"}
|
|
148
|
+
Inputs (JSON): ${JSON.stringify(t.inputs)}
|
|
149
|
+
Budget: ${t.budget.min} min of work. A person wait does not count. At the end a STOP note comes; 2 min later this session ends.
|
|
150
|
+
|
|
151
|
+
## The browser
|
|
152
|
+
|
|
153
|
+
Chrome is open on the site profile \`${o.site}\` (an explore session on port ${o.port}, the port is set for you). Drive it with \`autobrowse cmd '<json>'\` only, one command at a time.
|
|
154
|
+
Read ${o.skill} for the commands (aria, click, type, read, open, flow, place…). Skip its Session section: the session is open and you never start or stop one.
|
|
155
|
+
|
|
156
|
+
## Tools
|
|
157
|
+
|
|
158
|
+
Only \`autobrowse cmd …\` and Read work here. Other tools and shell commands are refused.
|
|
159
|
+
|
|
160
|
+
## A person step
|
|
161
|
+
|
|
162
|
+
When only William can go on (a code on his phone, a choice that is his, a page that blocks you):
|
|
163
|
+
autobrowse cmd human "<what you need from him, one line>"
|
|
164
|
+
Then wait. His answer comes in this terminal, or as a note from the viewer: autobrowse cmd '{"cmd":"waitNote","timeoutS":100}' (again until one comes). With no answer in ${t.humanWaitMin} min the task ends as needs-human.
|
|
165
|
+
|
|
166
|
+
## The end
|
|
167
|
+
|
|
168
|
+
End the task with exactly one of:
|
|
169
|
+
autobrowse cmd finish '{"status":"done","output":<JSON the goal asks for>}'
|
|
170
|
+
autobrowse cmd finish '{"status":"failed","why":"<why it cannot be done>"}'
|
|
171
|
+
autobrowse cmd finish '{"status":"needs-human","why":"<what William must do>"}'
|
|
172
|
+
Output is at most ${OUTPUT_MAX} characters of JSON. The session ends a few seconds after finish.
|
|
173
|
+
${t.retry === "once" ? '\nThis task acts once: never do a submit, a send or a payment twice. Give each act an id (`"id":"submit-1"`); a resend with the same id answers what happened.\n' : ""}`;
|
|
174
|
+
}
|
|
175
|
+
/** Shell single quotes. */
|
|
176
|
+
export const sq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
177
|
+
/** `autobrowse` first on the session's PATH: the same install as the task child, from its cwd. */
|
|
178
|
+
export function shimText(cli) {
|
|
179
|
+
return `#!/bin/sh\ncd ${sq(cli.cwd)} || exit 1\nexec ${[cli.node, ...cli.args].map(sq).join(" ")} "$@"\n`;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Env names a nested Claude Code must not see: its own session's ids, sockets and the nesting
|
|
183
|
+
* check; an API key from autobrowse's env file (Claude asks to use it; William's login runs tasks).
|
|
184
|
+
*/
|
|
185
|
+
export const claudeEnvNames = (env) => Object.keys(env).filter((k) => (/^CLAUDE/.test(k) && k !== "CLAUDE_CONFIG_DIR") || /^ANTHROPIC_/.test(k) || k === "AI_AGENT");
|
|
186
|
+
/** Claude Code's argv: the allow-list, `dontAsk` (the user default may be bypassPermissions), no MCP. */
|
|
187
|
+
export function claudeArgv(claude, promptFile, id) {
|
|
188
|
+
return [
|
|
189
|
+
claude,
|
|
190
|
+
// the prompt first: --tools and --allowedTools take a list
|
|
191
|
+
`Read ${promptFile} and do the task in it.`,
|
|
192
|
+
"--name",
|
|
193
|
+
`task-${id}`,
|
|
194
|
+
"--permission-mode",
|
|
195
|
+
"dontAsk",
|
|
196
|
+
"--tools",
|
|
197
|
+
"Bash,Read",
|
|
198
|
+
"--allowedTools",
|
|
199
|
+
"Bash(autobrowse cmd:*),Read",
|
|
200
|
+
"--strict-mcp-config",
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
export function runScript(o) {
|
|
204
|
+
return [
|
|
205
|
+
"#!/bin/sh",
|
|
206
|
+
...(o.unset.length ? [`unset ${o.unset.join(" ")}`] : []),
|
|
207
|
+
...Object.entries(o.env).map(([k, v]) => `export ${k}=${sq(v)}`),
|
|
208
|
+
`export PATH=${sq(o.bin)}:"$PATH"`,
|
|
209
|
+
`exec ${o.argv.map(sq).join(" ")}`,
|
|
210
|
+
"",
|
|
211
|
+
].join("\n");
|
|
212
|
+
}
|
|
213
|
+
const TRUST = "Yes, I trust this folder";
|
|
214
|
+
/** Claude Code's folder trust prompt waits on a new cwd (default "No, exit"): pick yes. True once past. */
|
|
215
|
+
export function acceptTrust(tmux, name) {
|
|
216
|
+
const pane = tmux.capture(name);
|
|
217
|
+
if (!pane.includes(TRUST))
|
|
218
|
+
return /❯|>/.test(pane) && !/trust/i.test(pane);
|
|
219
|
+
const picked = pane.split("\n").find((l) => l.includes("❯"));
|
|
220
|
+
if (!picked?.includes(TRUST))
|
|
221
|
+
tmux.keys(name, ["Down"]);
|
|
222
|
+
else
|
|
223
|
+
tmux.keys(name, ["Enter"]);
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
/** One task, start to end. Never throws: every way out is a `TaskEnd`. */
|
|
227
|
+
export async function runTask(raw, d) {
|
|
228
|
+
let input;
|
|
229
|
+
try {
|
|
230
|
+
input = JSON.parse(raw);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return {
|
|
234
|
+
id: null,
|
|
235
|
+
end: { kind: "fail", fingerprint: "task input invalid", why: "stdin is not JSON" },
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const parsed = taskSchema(d.timeoutMin).safeParse(input);
|
|
239
|
+
const id = parsed.success
|
|
240
|
+
? parsed.data.id
|
|
241
|
+
: typeof input?.id === "string"
|
|
242
|
+
? String(input.id)
|
|
243
|
+
: null;
|
|
244
|
+
if (!parsed.success)
|
|
245
|
+
return {
|
|
246
|
+
id,
|
|
247
|
+
end: { kind: "fail", fingerprint: "task input invalid", why: z.prettifyError(parsed.error) },
|
|
248
|
+
};
|
|
249
|
+
const t = parsed.data;
|
|
250
|
+
const fail = (fingerprint, why = fingerprint) => ({ id, end: { kind: "fail", fingerprint, why } });
|
|
251
|
+
if (!d.tmux)
|
|
252
|
+
return fail("tmux missing", "tmux is not installed: brew install tmux");
|
|
253
|
+
if (!d.claude)
|
|
254
|
+
return fail("claude missing", "the claude CLI is not on the PATH");
|
|
255
|
+
const tmux = d.tmux;
|
|
256
|
+
const name = `task-${t.id}`;
|
|
257
|
+
const taskDir = join(d.root, t.id);
|
|
258
|
+
mkdirSync(join(taskDir, "bin"), { recursive: true, mode: 0o700 });
|
|
259
|
+
// a killed earlier try's session: never two Claudes on one task
|
|
260
|
+
if (tmux.has(name))
|
|
261
|
+
tmux.kill(name);
|
|
262
|
+
const run = d.env.JOB_RUN || null;
|
|
263
|
+
const attempt = Number(d.env.JOB_ATTEMPT ?? 1) || 1;
|
|
264
|
+
// this run's own result, written before a crash: it stands
|
|
265
|
+
const prior = readResult(taskDir);
|
|
266
|
+
if (prior && run && prior.run === run)
|
|
267
|
+
return { id, end: { kind: "result", result: prior } };
|
|
268
|
+
rmSync(resultFile(taskDir), { force: true });
|
|
269
|
+
const once = onceEnds({
|
|
270
|
+
attempt,
|
|
271
|
+
retry: t.retry,
|
|
272
|
+
marked: run !== null && d.marks.has(run, MARK_ACT),
|
|
273
|
+
});
|
|
274
|
+
if (once)
|
|
275
|
+
return { id, end: { kind: "result", result: once } };
|
|
276
|
+
const mem = await d.memoryStop();
|
|
277
|
+
if (mem)
|
|
278
|
+
return { id, end: { kind: "glitch", why: `memory: ${mem}` } };
|
|
279
|
+
const site = d.site ?? `scratch-${t.id}`;
|
|
280
|
+
let browser;
|
|
281
|
+
try {
|
|
282
|
+
browser = await d.open({ site, task: t, taskDir });
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
const msg = (err instanceof Error ? err.message : String(err)).split("\n")[0] ?? "";
|
|
286
|
+
return {
|
|
287
|
+
id,
|
|
288
|
+
end: {
|
|
289
|
+
kind: "glitch",
|
|
290
|
+
why: d.busy(err) ? `profile busy: ${msg}` : `chrome did not start: ${msg}`,
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
// after Chrome, before Claude: a later try of a `once` task that finds it acts no more
|
|
295
|
+
if (run)
|
|
296
|
+
d.marks.add(run, MARK_ACT);
|
|
297
|
+
let ended = false;
|
|
298
|
+
const cleanup = () => {
|
|
299
|
+
if (ended)
|
|
300
|
+
return;
|
|
301
|
+
ended = true;
|
|
302
|
+
try {
|
|
303
|
+
tmux.kill(name);
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
// gone already
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
d.onStop?.(cleanup);
|
|
310
|
+
try {
|
|
311
|
+
const promptFile = join(taskDir, "prompt.md");
|
|
312
|
+
writeFileSync(promptFile, promptText(t, { site, port: browser.port, skill: d.skill }));
|
|
313
|
+
const bin = join(taskDir, "bin");
|
|
314
|
+
writeFileSync(join(bin, "autobrowse"), shimText(d.cli), { mode: 0o755 });
|
|
315
|
+
const script = join(taskDir, "run.sh");
|
|
316
|
+
writeFileSync(script, runScript({
|
|
317
|
+
argv: claudeArgv(d.claude, promptFile, t.id),
|
|
318
|
+
bin,
|
|
319
|
+
env: {
|
|
320
|
+
AUTOBROWSE_TASK_DIR: taskDir,
|
|
321
|
+
AUTOBROWSE_TASK_PORT: String(browser.port),
|
|
322
|
+
AUTOBROWSE_TASK_RUN: run ?? "",
|
|
323
|
+
},
|
|
324
|
+
unset: claudeEnvNames(d.env),
|
|
325
|
+
}), { mode: 0o700 });
|
|
326
|
+
tmux.start(name, d.root, script);
|
|
327
|
+
if (!tmux.has(name))
|
|
328
|
+
return fail("tmux session did not start");
|
|
329
|
+
browser.terminal?.(name);
|
|
330
|
+
d.log(`task ${t.id}: claude in tmux session ${name} (tmux attach -t ${name}); browser on port ${browser.port}`);
|
|
331
|
+
const startedAt = d.now();
|
|
332
|
+
let waitedMs = 0;
|
|
333
|
+
let lastAsk = null;
|
|
334
|
+
let noteAt = null;
|
|
335
|
+
let trusted = false;
|
|
336
|
+
for (;;) {
|
|
337
|
+
await d.sleep(d.pollMs ?? 1_000);
|
|
338
|
+
const now = d.now();
|
|
339
|
+
if (!trusted && now - startedAt < 60_000)
|
|
340
|
+
trusted = acceptTrust(tmux, name);
|
|
341
|
+
const result = readResult(taskDir);
|
|
342
|
+
if (result)
|
|
343
|
+
return { id, end: { kind: "result", result } };
|
|
344
|
+
if (browser.closed())
|
|
345
|
+
return fail("chrome closed mid-task");
|
|
346
|
+
if (!tmux.has(name))
|
|
347
|
+
return fail("claude ended without finish");
|
|
348
|
+
const ask = browser.humanAsk();
|
|
349
|
+
if (lastAsk && ask?.at !== lastAsk.at)
|
|
350
|
+
waitedMs += now - lastAsk.at;
|
|
351
|
+
lastAsk = ask;
|
|
352
|
+
const next = tick({
|
|
353
|
+
now,
|
|
354
|
+
startedAt,
|
|
355
|
+
waitedMs,
|
|
356
|
+
ask,
|
|
357
|
+
budgetMin: t.budget.min,
|
|
358
|
+
humanWaitMin: t.humanWaitMin,
|
|
359
|
+
timeoutMin: d.timeoutMin,
|
|
360
|
+
noteAt,
|
|
361
|
+
});
|
|
362
|
+
if (next === "go")
|
|
363
|
+
continue;
|
|
364
|
+
if (next === "note") {
|
|
365
|
+
noteAt = now;
|
|
366
|
+
// Escape stops a turn in flight and shuts a dialog; then the note is sent as a message
|
|
367
|
+
tmux.keys(name, ["Escape"]);
|
|
368
|
+
tmux.keys(name, [stopNote(t.budget.min)], true);
|
|
369
|
+
tmux.keys(name, ["Enter"]);
|
|
370
|
+
d.log(`task ${t.id}: budget spent, stop note sent`);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
return { id, end: { kind: "result", result: next } };
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
finally {
|
|
377
|
+
browser.terminal?.(null);
|
|
378
|
+
cleanup();
|
|
379
|
+
await browser.close().catch(() => undefined);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/app/task.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,qEAAqE;AACrE,MAAM,CAAC,MAAM,OAAO,GAAG,uBAAuB,CAAC;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,wHAAwH;AACxH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAChC,oDAAoD;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,CAAC;AACxC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,EAAE,CAC/C,CAAC;KACE,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,2CAA2C,CAAC;IAC1E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC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AAC;gBAC3B,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,gCAAgC,CAAC,CAAC;gBACpD,SAAS;YACX,CAAC;YACD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;QACvD,CAAC;IACH,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,EAAE,CAAC;QACV,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -22,6 +22,8 @@ export interface SignInState {
|
|
|
22
22
|
note: string | null;
|
|
23
23
|
/** Times on a list of second steps: a third is a loop, a person's. */
|
|
24
24
|
listed: number;
|
|
25
|
+
/** A list left unanswered (its view moved on under the click): not counted in `listed`, once a try. */
|
|
26
|
+
slipped: boolean;
|
|
25
27
|
/** The previous password went in, once, after a rejection. */
|
|
26
28
|
typedPrevious: boolean;
|
|
27
29
|
/** The username went in on a page of its own. */
|