longtable 0.1.27 → 0.1.29
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/package.json +1 -1
- package/src/claude.mjs +10 -4
- package/src/run.mjs +19 -8
package/package.json
CHANGED
package/src/claude.mjs
CHANGED
|
@@ -113,7 +113,9 @@ export function ask({ claude, cwd, prompt, system, schema, model, tools = "Read,
|
|
|
113
113
|
// Streamed output carries the plan's usage limits (a rate_limit_event) as well as the result.
|
|
114
114
|
const args = full
|
|
115
115
|
? ["-p", "--output-format", "stream-json", "--verbose", "--no-session-persistence",
|
|
116
|
-
|
|
116
|
+
// Their own choice of how it asks (manual, accept edits, auto, plan), else as before: edits go ahead in work.
|
|
117
|
+
"--permission-mode", full.mode === "plan" ? "plan" : full.mode === "auto" ? "auto" : full.mode === "manual" ? "default" : full.mode === "acceptEdits" || edit ? "acceptEdits" : "default",
|
|
118
|
+
"--permission-prompt-tool", "mcp__longtable__approve",
|
|
117
119
|
"--mcp-config", full.mcp, "--max-turns", edit ? (long ? "10000" : "200") : "60"]
|
|
118
120
|
: ["-p", "--output-format", "stream-json", "--verbose", "--no-session-persistence", "--restricted", "--permission-mode", edit ? "acceptEdits" : "dontAsk",
|
|
119
121
|
"--strict-mcp-config", "--max-turns", edit ? (long ? "10000" : "60") : tools ? "25" : "4", "--tools", tools];
|
|
@@ -122,7 +124,8 @@ export function ask({ claude, cwd, prompt, system, schema, model, tools = "Read,
|
|
|
122
124
|
// their own folder (full.project), never from the branch being worked on, which other people's AIs push to.
|
|
123
125
|
args.push("--setting-sources", "user");
|
|
124
126
|
// Only the connection pushes, and only the task's branch: their Claude never pushes itself, whatever their rules.
|
|
125
|
-
|
|
127
|
+
// In plan mode the plan is its answer here: there is no plan to approve, so it never asks to leave plan mode.
|
|
128
|
+
args.push("--disallowedTools", "Bash(git push:*)", "Bash(git push)", ...(edit ? [] : ["Edit", "Write", "NotebookEdit"]), ...(full.mode === "plan" ? ["ExitPlanMode"] : []));
|
|
126
129
|
if (full.allow?.length) args.push("--allowedTools", ...full.allow);
|
|
127
130
|
}
|
|
128
131
|
if (system) args.push("--append-system-prompt", system);
|
|
@@ -162,11 +165,14 @@ export function ask({ claude, cwd, prompt, system, schema, model, tools = "Read,
|
|
|
162
165
|
for (const part of e.message?.content || []) {
|
|
163
166
|
if (part.type !== "tool_use") continue;
|
|
164
167
|
const where = String(part.input?.file_path || part.input?.path || "");
|
|
165
|
-
|
|
168
|
+
// The path inside the project when it is in it (src/booking/StaffPicker.tsx), else the file's name alone.
|
|
169
|
+
const inside = where && where.toLowerCase().startsWith(String(cwd).toLowerCase()) ? where.slice(String(cwd).length).replace(/^[/\\]+/, "").replace(/\\/g, "/") : "";
|
|
170
|
+
const file = inside && inside.length <= 80 ? inside : where.split(/[/\\]/).pop();
|
|
166
171
|
if (/[/\\]\.longtable-yours([/\\]|$)/.test(where) || /^\.longtable-yours([/\\]|$)/.test(where)) onNote("reading what it knows");
|
|
167
172
|
// A command is named by its program only: the rest of a command line can hold a secret.
|
|
168
173
|
else if (part.name === "Bash") onNote(`running ${String(part.input?.command || "").trim().split(/\s+/)[0].replace(/[^A-Za-z0-9._-]/g, "").slice(0, 30) || "a command"}`);
|
|
169
|
-
else onNote(part.name === "Edit" || part.name === "Write" ? `editing ${file}` : part.name === "Read" ? `reading ${file}`
|
|
174
|
+
else onNote(part.name === "Edit" || part.name === "Write" ? `editing ${file}` : part.name === "Read" ? `reading ${file}`
|
|
175
|
+
: (part.name === "Grep" || part.name === "Glob") && part.input?.pattern ? `searching for ${String(part.input.pattern).replace(/\s+/g, " ").slice(0, 40)}` : "searching the code");
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
});
|
package/src/run.mjs
CHANGED
|
@@ -534,7 +534,7 @@ async function workPacked(rpc, seat, engines, job, copy) {
|
|
|
534
534
|
// One of their own prompts or skills, or one of the table's, when their message runs one: the same as on Claude.
|
|
535
535
|
const cmd = job.command?.mine ? loadCommand(seat, job.question) : null;
|
|
536
536
|
const prompt = `${cmd ? commandPrompt(job.me, cmd) : ""}${buildPrompt(job)}\n\n<<<CODE\n${inert(pack.text)}\nCODE>>>${PAGE_KINDS.has(job.kind) ? pagesPrompt(job) : ""}`;
|
|
537
|
-
const result = await askCodex({ codex: engines.codex, prompt: `${systemFor({ ...job, packed: true })}\n\n${prompt}`, schema, model: seat.model || undefined, effort: job.effort ||
|
|
537
|
+
const result = await askCodex({ codex: engines.codex, prompt: `${systemFor({ ...job, packed: true })}\n\n${prompt}`, schema, model: seat.model || undefined, effort: job.effort || "medium", timeoutMs: 5 * 60 * 1000 });
|
|
538
538
|
if (result.tools.length) throw new Error(`Codex tried to use tools (${result.tools.join(", ")}); its answer was dropped`);
|
|
539
539
|
const s = result.structured_output || {};
|
|
540
540
|
const text = job.kind === "view" || job.kind === "review" ? s.view : job.kind === "intro" ? `${s.knows}\n\nI can check: ${s.can_check}` : s.answer;
|
|
@@ -683,11 +683,14 @@ async function workSandbox(rpc, seat, engines, job) {
|
|
|
683
683
|
told = Date.now();
|
|
684
684
|
try { if ((await rpc("runner_beat", { token: seat.token, job: job.job_id, note })) === false) control.kill?.(); } catch (e) { if (/connection was removed/i.test(e.message)) control.kill?.(); }
|
|
685
685
|
};
|
|
686
|
+
// The newest note reaches the room within a second, and the room is told at most once a second.
|
|
687
|
+
let pending = null;
|
|
688
|
+
const soon = () => { if (!pending) pending = setTimeout(() => { pending = null; tell(); }, Math.max(0, 1000 - (Date.now() - told))); };
|
|
686
689
|
const beat = setInterval(tell, 20000);
|
|
687
690
|
try {
|
|
688
691
|
// A change in a copy is a short piece of work: ten minutes and sixty steps, on the team's plan.
|
|
689
692
|
const result = await ask({ claude: engines.claude, cwd: opened.dir, edit: true, long: false, control,
|
|
690
|
-
onNote: (n) => { if (n !== note) { note = n;
|
|
693
|
+
onNote: (n) => { if (n !== note) { note = n; soon(); } },
|
|
691
694
|
prompt: sandboxPrompt(job), system: sandboxSystem(job), schema: KINDS.sandbox.schema, model: seat.model || process.env.LONGTABLE_MODEL });
|
|
692
695
|
if (result.is_error) throw new Error(result.result || "Claude Code reported an error");
|
|
693
696
|
const s = result.structured_output || {};
|
|
@@ -821,7 +824,10 @@ async function work(rpc, seat, engines, raw) {
|
|
|
821
824
|
// A view for the back room only reads, and so does anything asked while no code is connected.
|
|
822
825
|
// With several AIs, one of them does the work, the others look it over on its branch, and the table's answer
|
|
823
826
|
// reports it; none of those last two change anything.
|
|
824
|
-
|
|
827
|
+
// In plan mode their person wants the plan first: it reads and proposes, and nothing is changed. Their mode is for
|
|
828
|
+
// their own requests to their full Claude Code, as it is for Claude Code at home.
|
|
829
|
+
const planning = job.full === true && job.mode === "plan";
|
|
830
|
+
const doing = !!seat.source && !planning && (job.kind === "work" || (job.kind === "answer" && !job.worker));
|
|
825
831
|
const onBranch = !!seat.source && !!job.work_read && (job.kind === "review" || job.kind === "combine");
|
|
826
832
|
const branch = doing || onBranch ? job.branch || workBranch(job.chat_name) : null;
|
|
827
833
|
// Their full Claude Code, when they turned it on: in a git worktree of their own repository, with their own
|
|
@@ -842,6 +848,9 @@ async function work(rpc, seat, engines, raw) {
|
|
|
842
848
|
told = Date.now();
|
|
843
849
|
try { if ((await rpc("runner_beat", { token: seat.token, job: job.job_id, note })) === false) control.kill?.(); } catch (e) { if (/connection was removed/i.test(e.message)) control.kill?.(); }
|
|
844
850
|
};
|
|
851
|
+
// The newest note reaches the room within a second, and the room is told at most once a second.
|
|
852
|
+
let pending = null;
|
|
853
|
+
const soon = () => { if (!pending) pending = setTimeout(() => { pending = null; tell(); }, Math.max(0, 1000 - (Date.now() - told))); };
|
|
845
854
|
beat = setInterval(tell, 20000);
|
|
846
855
|
const dir = opened ? opened.dir : copy.dir;
|
|
847
856
|
// And the whole of it beside the code, to read when the question needs it. Never in a folder that is committed
|
|
@@ -874,22 +883,21 @@ async function work(rpc, seat, engines, raw) {
|
|
|
874
883
|
if (cmd) log(`job ${job.job_id}: running their /${cmd.name}`);
|
|
875
884
|
if (full) { fullRun = await fullSetup(rpc, seat, job); log(`job ${job.job_id}: running as their full Claude Code in ${opened.dir}`); }
|
|
876
885
|
const result = await ask({
|
|
877
|
-
full: fullRun ? { mcp: fullRun.mcp, allow: fullRun.allow, project: fullRun.project } : null,
|
|
886
|
+
full: fullRun ? { mcp: fullRun.mcp, allow: fullRun.allow, project: fullRun.project, mode: job.mode || null } : null,
|
|
878
887
|
claude,
|
|
879
888
|
cwd: dir,
|
|
880
889
|
edit: doing,
|
|
881
890
|
long: doing,
|
|
882
|
-
|
|
883
|
-
onNote: (n) => { if (n !== note) { note = n; if (Date.now() - told > 4000) tell(); } },
|
|
891
|
+
onNote: (n) => { if (n !== note) { note = n; soon(); } },
|
|
884
892
|
control,
|
|
885
|
-
prompt: yours(job) + (cmd ? commandPrompt(job.me, cmd) : "") + (doing ? `${buildPrompt(job)}\n\n${full ? FULL_DOING(branch) : DOING(branch)}` : buildPrompt(job) + (full ? `\n\n${FULL_READING}` : "")) + fromSandbox(seat, job)
|
|
893
|
+
prompt: yours(job) + (cmd ? commandPrompt(job.me, cmd) : "") + (doing ? `${buildPrompt(job)}\n\n${full ? FULL_DOING(branch) : DOING(branch)}` : buildPrompt(job) + (full ? `\n\n${FULL_READING}` : "") + (planning && ["work", "answer"].includes(job.kind) ? `\n\n${PLANNING}` : "")) + fromSandbox(seat, job)
|
|
886
894
|
+ materialsPrompt(job.materials) + attachedPrompt(attached, dir) + (PAGE_KINDS.has(job.kind) ? pagesPrompt(job) : "")
|
|
887
895
|
+ (job.command && !job.command.mine ? `${NL}${NL}${job.asker}'s message runs their own AI's command /${job.command.name}${job.command.about ? ` (${job.command.about})` : ""}. Their own AI has its instructions; you do not. Help with what it is for.` : ""),
|
|
888
896
|
system: [systemFor({ ...job, doing, full }), ...(laid ? pointedSystem(job.me, laid, dir) : [])].join(NL),
|
|
889
897
|
addDirs: laid ? laid.dirs : [],
|
|
890
898
|
schema: KINDS[job.kind].schema,
|
|
891
899
|
model: seat.model || process.env.LONGTABLE_MODEL,
|
|
892
|
-
effort: job.effort ||
|
|
900
|
+
effort: job.effort || "medium",
|
|
893
901
|
fast: job.fast === true,
|
|
894
902
|
}).catch((e) => {
|
|
895
903
|
// Only short jobs have a time limit now; if one that was changing files hits it, what it changed still lands.
|
|
@@ -969,6 +977,9 @@ async function work(rpc, seat, engines, raw) {
|
|
|
969
977
|
// What a full Claude Code run needs: a key for this one job (the approval server asks with that, never with the
|
|
970
978
|
// device token), the MCP config that starts the approval server, kept in a file of the connection's own and removed
|
|
971
979
|
// when the job ends, and the person's "always allow" answers for this table.
|
|
980
|
+
// Plan mode, as in Claude Code: the plan first, nothing changed.
|
|
981
|
+
const PLANNING = "Your person has you in plan mode: read what you need, then answer with the plan, what you would change, where and why, step by step. Change nothing and run nothing that changes anything. They will say when to go ahead.";
|
|
982
|
+
|
|
972
983
|
async function fullSetup(rpc, seat, job) {
|
|
973
984
|
const key = await rpc("runner_job_key", { token: seat.token, job: job.job_id });
|
|
974
985
|
const always = join(home, "allow", `${safeTable(seat.table_id)}.json`);
|