longtable 0.1.26 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "longtable",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Brings your own Claude Code or Codex to your team's table on longtable.chat, quietly, on your own plan.",
5
5
  "homepage": "https://longtable.chat",
6
6
  "repository": {
package/src/claude.mjs CHANGED
@@ -162,11 +162,14 @@ export function ask({ claude, cwd, prompt, system, schema, model, tools = "Read,
162
162
  for (const part of e.message?.content || []) {
163
163
  if (part.type !== "tool_use") continue;
164
164
  const where = String(part.input?.file_path || part.input?.path || "");
165
- const file = where.split(/[/\\]/).pop();
165
+ // The path inside the project when it is in it (src/booking/StaffPicker.tsx), else the file's name alone.
166
+ const inside = where && where.toLowerCase().startsWith(String(cwd).toLowerCase()) ? where.slice(String(cwd).length).replace(/^[/\\]+/, "").replace(/\\/g, "/") : "";
167
+ const file = inside && inside.length <= 80 ? inside : where.split(/[/\\]/).pop();
166
168
  if (/[/\\]\.longtable-yours([/\\]|$)/.test(where) || /^\.longtable-yours([/\\]|$)/.test(where)) onNote("reading what it knows");
167
169
  // A command is named by its program only: the rest of a command line can hold a secret.
168
170
  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}` : "searching the code");
171
+ else onNote(part.name === "Edit" || part.name === "Write" ? `editing ${file}` : part.name === "Read" ? `reading ${file}`
172
+ : (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
173
  }
171
174
  }
172
175
  });
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 || null, timeoutMs: 5 * 60 * 1000 });
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; if (Date.now() - told > 4000) tell(); } },
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 || {};
@@ -733,6 +736,7 @@ async function workListen(rpc, seat, engines, job) {
733
736
  let s;
734
737
  let model;
735
738
  let usage;
739
+ let limits = null;
736
740
  if (seat.kind === "codex") {
737
741
  const result = await askCodex({ codex: engines.codex, prompt: `${listenSystem(job)}${NL}${NL}${listenPrompt(job)}`, schema });
738
742
  s = result.tools.length ? { act: "silent", reply: "" } : result.structured_output;
@@ -747,12 +751,16 @@ async function workListen(rpc, seat, engines, job) {
747
751
  s = result.structured_output;
748
752
  model = Object.keys(result.modelUsage || {})[0] || "haiku";
749
753
  usage = { input: result.usage?.input_tokens, output: result.usage?.output_tokens, wall_ms: result.wall_ms, cost_usd_equivalent: result.total_cost_usd };
754
+ limits = result.limits;
750
755
  }
751
756
  const act = ["silent", "reply", "look", "work"].includes(s?.act) ? s.act : "silent";
752
757
  const label = /^T(\d+)$/.exec(String(s?.task || "").trim());
753
758
  const task = label ? (job.tasks || [])[Number(label[1]) - 1]?.id || "" : "";
754
759
  await rpc("runner_finish", { token: seat.token, job: job.job_id, answer: act === "reply" ? String(s.reply || "") : "", info: { act, model, usage, task, title: String(s?.title || "").slice(0, 80) } });
755
760
  log(`listen job ${job.job_id}: ${act}`);
761
+ // The plan's use moves with every message heard, not only with bigger jobs, so Usage stays current. The person's
762
+ // own model is kept: the listener runs on its own small one.
763
+ if (limits) await report(rpc, seat, { ai: "claude", ...limits, models: ["opus", "sonnet", "haiku"] }, null);
756
764
  }
757
765
 
758
766
  // People's and tables' names come from the table like any other words, and go into the AI's own instructions: a
@@ -837,6 +845,9 @@ async function work(rpc, seat, engines, raw) {
837
845
  told = Date.now();
838
846
  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?.(); }
839
847
  };
848
+ // The newest note reaches the room within a second, and the room is told at most once a second.
849
+ let pending = null;
850
+ const soon = () => { if (!pending) pending = setTimeout(() => { pending = null; tell(); }, Math.max(0, 1000 - (Date.now() - told))); };
840
851
  beat = setInterval(tell, 20000);
841
852
  const dir = opened ? opened.dir : copy.dir;
842
853
  // And the whole of it beside the code, to read when the question needs it. Never in a folder that is committed
@@ -874,8 +885,7 @@ async function work(rpc, seat, engines, raw) {
874
885
  cwd: dir,
875
886
  edit: doing,
876
887
  long: doing,
877
- // What it is doing reaches the room within a few seconds of changing, and no more often than that.
878
- onNote: (n) => { if (n !== note) { note = n; if (Date.now() - told > 4000) tell(); } },
888
+ onNote: (n) => { if (n !== note) { note = n; soon(); } },
879
889
  control,
880
890
  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)
881
891
  + materialsPrompt(job.materials) + attachedPrompt(attached, dir) + (PAGE_KINDS.has(job.kind) ? pagesPrompt(job) : "")
@@ -884,7 +894,7 @@ async function work(rpc, seat, engines, raw) {
884
894
  addDirs: laid ? laid.dirs : [],
885
895
  schema: KINDS[job.kind].schema,
886
896
  model: seat.model || process.env.LONGTABLE_MODEL,
887
- effort: job.effort || null,
897
+ effort: job.effort || "medium",
888
898
  fast: job.fast === true,
889
899
  }).catch((e) => {
890
900
  // Only short jobs have a time limit now; if one that was changing files hits it, what it changed still lands.