longtable 0.1.42 → 0.1.43

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/run.mjs +41 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "longtable",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
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/run.mjs CHANGED
@@ -792,8 +792,12 @@ export function sandboxSystem(job) {
792
792
  return [
793
793
  `You build in ${job.client}'s sandbox at "${job.table_name}": their own copy of the product, apart from the real one. ${job.client} is the team's client, not an engineer. Nothing you do here reaches the real product; the team looks at it later and decides what to take.`,
794
794
  `What ${job.client} wants is between <<<CLIENT and CLIENT>>>. Make that change in this folder: how the product looks and behaves. Keep to what they asked, keep it small, and make it really work to click through, with made-up data where real data would be needed.`,
795
- "Change only what people see and click: pages, components, styles, wording, made-up data. Never touch how the product is built, set up or deployed, anything that runs on the server, anything about sign-in, permissions, secrets or environment values, the database, or tests. Never read a file to show what is in it, and never send anything anywhere. A change that needs any of that is the team's to make.",
795
+ job.scope === "code"
796
+ ? "You may change what people see and click and the code behind it: pages, components, styles, wording, made-up data, and the server code those pages use (their data loading, actions and routes), because this copy runs on made-up data with no real keys. Never touch how the product is built, set up or deployed, its packages, scripts, middleware or proxy, the database schema or migrations, anything about sign-in, sign-up, permissions, secrets or environment values, or tests. Never read environment values or files on the server, never run programs, never call outside sites, and never read a file to show what is in it. A change that needs any of that is the team's to make."
797
+ : "Change only what people see and click: pages, components, styles, wording, made-up data. Never touch how the product is built, set up or deployed, anything that runs on the server, anything about sign-in, permissions, secrets or environment values, the database, or tests. Never read a file to show what is in it, and never send anything anywhere. A change that needs any of that is the team's to make.",
796
798
  ...(job.paths ? [`The only folders you may change are: ${job.paths}.`] : []),
799
+ ...(blockedList(job.blocked).length ? [`Never change these, whatever is asked: ${blockedList(job.blocked).join(", ")}.`] : []),
800
+ "Before you finish, make sure your change still type-checks: it is checked before it goes into their copy, and a change that breaks it is not put in.",
797
801
  "If they ask for any of that, or for something that is not a change to try (a question, a date, a price, a decision, their real data), change nothing, set pass_on to true, and tell them kindly in one or two sentences that you have passed it to the team, saying plainly why it is the team's: when it changes how the product works (a rule, a limit, who approves what, what is kept or sent), say that it changes how the product works, so the team builds it, and that they will see it here when it is done; when it is a question or a decision, say the team will answer. Never leave them wondering whether anything happened.",
798
802
  `Your reply is read by ${job.client}: plain words, what is different now and where to look. Never name a file, show code, or say anything about the team or how the product is made. The detail is read by the team only.`,
799
803
  "You cannot run anything. This folder has no .git on purpose: the connection commits and pushes what you change, so never mention committing.",
@@ -830,15 +834,46 @@ const NOT_A_SANDBOX_WORD = new RegExp([
830
834
  "\\beval\\s*\\(", "new\\s+Function\\b", "\\bFunction\\s*\\(", "\\bglobalThis\\b", "[\"']use server[\"']", "\\bserver-only\\b", "dangerouslySetInnerHTML",
831
835
  "\\b(fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon)\\b[^;]{0,80}(https?:|[\"'`]//)", "<script\\b", "\\bsecrets[.][A-Za-z_]",
832
836
  ].join("|"), "m");
833
- export function sandboxRefusal({ files, text, unread }, paths = "") {
834
- const file = files.find((f) => NOT_IN_A_SANDBOX.test(f));
837
+ // With the table's copy rules set to "code" (a preview that is fully separate: made-up data, no real keys, no email),
838
+ // a copy may also change the code behind the screens: server components, actions, API routes. Still never how the
839
+ // product is built, set up or deployed, migrations and the database, scripts, middleware, sign-in and permissions,
840
+ // or tests; and the code still may not reach for env values, programs, files or outside sites.
841
+ const NOT_IN_A_CODE_COPY = new RegExp([
842
+ "(^|/)[.]git(hub|lab|attributes|modules|ignore)", "(^|/)[.](circleci|husky|vscode|devcontainer)/", "(^|/)[.]env", "(^|/)[.](npmrc|yarnrc|babelrc|vercelignore|dockerignore)",
843
+ "(^|/)(package|composer|turbo|tsconfig[^/]*|jsconfig|vercel|netlify|firebase|app|now)[.]json$", "[.](toml|ya?ml|lock|lockb|sql|sh|bat|ps1|cjs|mjs|pem|key|crt)$",
844
+ "(^|/)(package-lock[.]json|Dockerfile[^/]*|docker-compose[^/]*|Makefile|Procfile|Gemfile|requirements[^/]*[.]txt|go[.](mod|sum))$", "[.]config[.][cm]?[jt]sx?$",
845
+ "(^|/)(scripts?|migrations?|supabase|prisma|drizzle|infra|deploy|ops|bin|tools|docker)/",
846
+ "(^|/)(middleware|instrumentation|proxy)[.][cm]?[jt]sx?$",
847
+ "(^|[/._-])(auth|login|signin|sign-in|session|permissions?|polic(y|ies)|rls|guard|admin|secrets?|credentials?)([/._-]|$)",
848
+ "(^|/)(roles?|tokens?|keys?)([/.]|$)",
849
+ "(^|/)(tests?|__tests__|e2e|spec|cypress|playwright)/", "[.](test|spec)[.]",
850
+ ].join("|"), "i");
851
+ const NOT_A_CODE_COPY_WORD = new RegExp([
852
+ "\\bprocess\\s*\\??\\.[A-Za-z_$]", "\\bprocess\\s*\\[", "[=(,:]\\s*process\\s*[;),}\\]]", "[=(,:]\\s*process\\s*$", "import\\s*[.]\\s*meta", "\\b(Deno|Bun)\\s*[.]",
853
+ "\\benv\\s*\\[", "\\benv\\s*\\??\\.[A-Za-z_$]", "[{,]\\s*env\\s*[,})]", "\\bgetenv\\b", "os[.]environ", "\\bENV\\s*[\\[.]",
854
+ "\\b(readFile|readFileSync|readdir|readdirSync|createReadStream|child_process|execSync|spawn)\\b", "[\"'`](node:)?(fs|fs/promises|vm|net|dns|child_process|worker_threads)[\"'`]",
855
+ "\\b(require|import)\\s*\\(\\s*[\"'`](node:)?(https?|http2|os|tls|dgram|module)[\"'`]", "\\bfrom\\s*[\"'`](node:)?(https?|http2|os|tls|dgram|module)[\"'`]",
856
+ "\\beval\\s*\\(", "new\\s+Function\\b", "\\bFunction\\s*\\(", "dangerouslySetInnerHTML",
857
+ "\\b(fetch|XMLHttpRequest|WebSocket|EventSource|sendBeacon)\\b[^;]{0,80}(https?:|[\"'`]//)", "<script\\b", "\\bsecrets[.][A-Za-z_]",
858
+ ].join("|"), "m");
859
+ // The owner's own list of paths a copy may never change, whatever the mode: a folder ends in "/", anything else is a
860
+ // file or a folder by that name.
861
+ export const blockedList = (blocked) => String(blocked || "").split(/[,\n]/).map((x) => x.trim().replace(/^[/]+/, "")).filter(Boolean);
862
+ const isBlocked = (f, list) => list.some((b) => (b.endsWith("/") ? f.startsWith(b) : f === b || f.startsWith(b + "/")));
863
+
864
+ export function sandboxRefusal({ files, text, unread }, paths = "", { scope = "screens", blocked = "" } = {}) {
865
+ const code = scope === "code";
866
+ const theirs = blockedList(blocked);
867
+ const kept = theirs.length ? files.find((f) => isBlocked(f, theirs)) : null;
868
+ if (kept) return `it changes ${kept}, which this table keeps out of every copy`;
869
+ const file = files.find((f) => (code ? NOT_IN_A_CODE_COPY : NOT_IN_A_SANDBOX).test(f));
835
870
  if (file) return `it changes ${file}, which is part of how the product is built, run or kept safe`;
836
871
  // Folders the owner said a copy may change: with any set, everything outside them is the team's.
837
872
  const allowed = String(paths || "").split(",").map((x) => x.trim().replace(/^[/]+|[/]+$/g, "")).filter(Boolean);
838
873
  const outside = allowed.length ? files.find((f) => !allowed.some((a) => f === a || f.startsWith(a + "/"))) : null;
839
874
  if (outside) return `it changes ${outside}, which is outside the folders a copy may change`;
840
875
  if (unread) return "it changes a file that could not be read through";
841
- const word = NOT_A_SANDBOX_WORD.exec(text || "");
876
+ const word = (code ? NOT_A_CODE_COPY_WORD : NOT_A_SANDBOX_WORD).exec(text || "");
842
877
  if (word) return `a file it changed reaches for something a copy must not (${word[0].trim().slice(0, 40)})`;
843
878
  return null;
844
879
  }
@@ -909,7 +944,7 @@ async function workSandbox(rpc, seat, engines, job) {
909
944
  let s = result.structured_output || {};
910
945
  const usage = { input: result.usage?.input_tokens, output: result.usage?.output_tokens, turns: result.num_turns, wall_ms: result.wall_ms, cost_usd_equivalent: result.total_cost_usd };
911
946
  let seen = changedSoFar(seat.table_id, opened);
912
- let refused = seen.files.length ? sandboxRefusal(seen, job.paths) : null;
947
+ let refused = seen.files.length ? sandboxRefusal(seen, job.paths, { scope: job.scope, blocked: job.blocked }) : null;
913
948
  // The project's own type check, before anything is pushed: a change that breaks it never reaches the copy (its
914
949
  // build would fail and the client would wait minutes for a "that did not work"). Its AI gets one go at fixing what
915
950
  // it broke; if the check still fails, nothing is pushed and it goes to the team.
@@ -924,7 +959,7 @@ async function workSandbox(rpc, seat, engines, job) {
924
959
  system: sandboxSystem(job), schema: KINDS.sandbox.schema, model: seat.model || process.env.LONGTABLE_MODEL });
925
960
  if (!again.is_error && again.structured_output) s = again.structured_output;
926
961
  seen = changedSoFar(seat.table_id, opened);
927
- refused = seen.files.length ? sandboxRefusal(seen, job.paths) : null;
962
+ refused = seen.files.length ? sandboxRefusal(seen, job.paths, { scope: job.scope, blocked: job.blocked }) : null;
928
963
  checked = !refused && !s.pass_on && seen.files.length ? await checkCopy(seat, opened) : null;
929
964
  }
930
965
  if (checked && checked.added.length) {