wildcrane-runner 0.6.126 → 0.6.128

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/dist/launcher.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.126 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.128 — built by runner/scripts/build.mjs. Do not edit.
2
2
  import { createRequire as __ai4kanbanRequire } from 'node:module'
3
3
  const require = __ai4kanbanRequire(import.meta.url)
4
4
  var __create = Object.create;
@@ -41121,8 +41121,8 @@ function saveAlphaUpdates(value) {
41121
41121
  }
41122
41122
 
41123
41123
  // src/protocol.ts
41124
- var VERSION = true ? "0.6.126" : "0.0.0";
41125
- var AKB_VERSION = true ? "0.11.108" : "0.0.0";
41124
+ var VERSION = true ? "0.6.128" : "0.0.0";
41125
+ var AKB_VERSION = true ? "0.11.110" : "0.0.0";
41126
41126
  var EXIT_REFUSED = 10;
41127
41127
  var EXIT_OUTDATED = 11;
41128
41128
  var EXIT_UPDATE = 12;
@@ -41754,24 +41754,49 @@ var STUDIO_SCHEMA = {
41754
41754
  var validate = new import_ajv.Ajv({ allErrors: true, meta: false, validateSchema: false }).compile(STUDIO_SCHEMA);
41755
41755
  var comments = /<!--[^]*?(?:-->|$)/g;
41756
41756
  var blank = (text2) => text2.replace(/[^\r\n]/g, " ");
41757
- var headingsOf = (body) => [...withoutCode(body).replace(comments, blank).matchAll(/^ {0,3}#{1,2}(?=[ \t\r\n]|$)[^\r\n]*/gm)];
41758
- function landSections(body, previews) {
41759
- let visible = "", at = 0;
41760
- for (const { start, end } of previews) {
41761
- visible += body.slice(at, start) + blank(body.slice(start, end));
41762
- at = end;
41763
- }
41764
- visible += body.slice(at);
41765
- const headings = headingsOf(visible);
41766
- return headings.flatMap((heading, index) => {
41767
- const start = heading.index;
41768
- const end = start + heading[0].length;
41769
- if (!/^ {0,3}##[ \t]+Land(?:[ \t]+#+)?[ \t]*$/.test(visible.slice(start, end))) return [];
41770
- const text2 = visible.slice(end, headings[index + 1]?.index).replace(comments, "").trim();
41771
- return [{ offset: start + heading[0].indexOf("#"), empty: !text2, text: text2 }];
41757
+ function studioSections(body) {
41758
+ const headings = [...withoutCode(body).replace(comments, blank).matchAll(/^ {0,3}#{1,2}(?=[ \t\r\n]|$)[^\r\n]*/gm)];
41759
+ return headings.map((heading, index) => {
41760
+ const start = heading.index + heading[0].indexOf("#");
41761
+ const content = heading.index + heading[0].length;
41762
+ const name = /^##[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/.exec(body.slice(start, content))?.[1];
41763
+ return { name, start, content, end: headings[index + 1]?.index ?? body.length };
41772
41764
  });
41773
41765
  }
41774
- function parseStudioFile(id, source, from, { requirePreviewCopy = false, requireLand = false } = {}) {
41766
+ function checkStudioSections(body, previews, fail) {
41767
+ let visible = "", end = 0;
41768
+ for (const block of previews) {
41769
+ visible += body.slice(end, block.start) + blank(body.slice(block.start, block.end));
41770
+ end = block.end;
41771
+ }
41772
+ visible += body.slice(end);
41773
+ const sections = studioSections(visible);
41774
+ const instructions = {
41775
+ Land: "Describe delivery, checks and what to record.",
41776
+ Work: "Describe the workflow and tools.",
41777
+ Previews: "Put Preview blocks under this heading, or leave it empty if none are needed."
41778
+ };
41779
+ for (const name of ["Land", "Work", "Previews"]) {
41780
+ const matching = sections.filter((section) => section.name === name);
41781
+ const code = `studio-${name.toLowerCase()}`;
41782
+ if (!matching.length) fail(0, name, `${code}-missing`, `Missing ## ${name} section`, `Add ## ${name} to the Studio body. ${instructions[name]}`);
41783
+ for (const [index2, section] of matching.entries()) {
41784
+ if (index2) fail(section.start, name, `${code}-duplicate`, `Repeated ## ${name} section`, `Combine its contents under one ## ${name} heading.`);
41785
+ if (name !== "Previews" && !visible.slice(section.content, section.end).replace(comments, "").trim()) {
41786
+ fail(section.start, name, `${code}-empty`, `The ## ${name} section is empty`, instructions[name]);
41787
+ }
41788
+ }
41789
+ }
41790
+ let index = 0;
41791
+ for (const block of previews) {
41792
+ while (sections[index] && sections[index].end <= block.start) index++;
41793
+ const section = sections[index];
41794
+ if (section?.name !== "Previews" || block.start < section.content) {
41795
+ fail(block.start, `previews.${block.id}`, "preview-section", `Preview ${block.id} is outside ## Previews`, "Move the block under ## Previews.");
41796
+ }
41797
+ }
41798
+ }
41799
+ function parseStudioFile(id, source, from, { requirePreviewCopy = false, requireSections = false } = {}) {
41775
41800
  const problems = [];
41776
41801
  const fail = (offset, path39, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source, offset), path: path39, code, message, hint: hint2 });
41777
41802
  const result = () => ({ problem: problems.map((p) => `${p.file}:${p.line}:${p.column} ${p.path}: ${p.code} \u2014 ${p.message}. ${p.hint}`).join("\n"), problems });
@@ -41823,14 +41848,7 @@ function parseStudioFile(id, source, from, { requirePreviewCopy = false, require
41823
41848
  );
41824
41849
  }
41825
41850
  }
41826
- if (requireLand) {
41827
- const sections = landSections(body, parsed.blocks);
41828
- if (!sections.length) fail(bodyOffset, "Land", "studio-land-missing", "Missing ## Land section", "Add ## Land to the Studio body and describe delivery, checks and what to record.");
41829
- for (const [index, { offset, empty }] of sections.entries()) {
41830
- if (index) fail(bodyOffset + offset, "Land", "studio-land-duplicate", "Repeated ## Land section", "Combine delivery instructions under one ## Land heading.");
41831
- if (empty) fail(bodyOffset + offset, "Land", "studio-land-empty", "The ## Land section is empty", "Describe delivery, checks and what to record under ## Land.");
41832
- }
41833
- }
41851
+ if (requireSections) checkStudioSections(body, parsed.blocks, (offset, ...problem) => fail(bodyOffset + offset, ...problem));
41834
41852
  if (problems.length) return result();
41835
41853
  let rules = "", at = 0;
41836
41854
  for (const block of parsed.blocks) {
@@ -41943,7 +41961,7 @@ function checkStudioFiles(value, official = false, checks = {}) {
41943
41961
  const first = read3.problems[0];
41944
41962
  return first ? { ok: false, ...first, problems: read3.problems } : { ok: true, def: read3.def, files: read3.files };
41945
41963
  }
41946
- function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } = {}) {
41964
+ function inspect(value, official, { allowLegacyPreviewCopy, allowLegacySections } = {}) {
41947
41965
  const problems = [];
41948
41966
  const fail = (file2, reason, tooLarge = false) => {
41949
41967
  problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
@@ -42016,7 +42034,7 @@ function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } =
42016
42034
  });
42017
42035
  }
42018
42036
  const source = files[STUDIO_FILE];
42019
- const read3 = typeof source === "string" ? parseStudioFile("studio", source, STUDIO_FILE, { requirePreviewCopy: !official && !allowLegacyPreviewCopy, requireLand: !allowLegacyLand }) : null;
42037
+ const read3 = typeof source === "string" ? parseStudioFile("studio", source, STUDIO_FILE, { requirePreviewCopy: !official && !allowLegacyPreviewCopy, requireSections: !allowLegacySections }) : null;
42020
42038
  if (!read3) fail(STUDIO_FILE, "is missing");
42021
42039
  else if ("problem" in read3) for (const problem of read3.problems) problems.push({ ...problem, reason: problem.message });
42022
42040
  if (!read3 || "problem" in read3) return { problems };
@@ -42368,7 +42386,7 @@ var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray
42368
42386
  var hasText = (value) => typeof value === "string" && !!value.trim();
42369
42387
  function temporaryCloudFailure({ code, status: status2 }) {
42370
42388
  if (code && ["unauthenticated", "machine_offline", "quota_exceeded", "daily_write_budget_reached", "storage_limit_reached"].includes(code)) return false;
42371
- return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable"].includes(code ?? "") || status2 === 408 || (status2 !== void 0 ? status2 >= 500 : !code);
42389
+ return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable", "board-busy"].includes(code ?? "") || status2 === 408 || (status2 !== void 0 ? status2 >= 500 : !code);
42372
42390
  }
42373
42391
  var invalidResponse = (expected) => ({ code: "invalid_response", message: `Cloud did not return ${expected}.`, retryable: true });
42374
42392
  async function readCloudJson(response) {
@@ -43593,8 +43611,8 @@ function createTail(log) {
43593
43611
  // ../cli/package.json
43594
43612
  var package_default = {
43595
43613
  name: "wildcrane",
43596
- version: "0.11.108",
43597
- akbContract: 41,
43614
+ version: "0.11.110",
43615
+ akbContract: 42,
43598
43616
  canonicalCommands: true,
43599
43617
  description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
43600
43618
  keywords: [
@@ -44981,37 +44999,63 @@ function dayDir(root2, at) {
44981
44999
  const pad = (n) => String(n).padStart(2, "0");
44982
45000
  return join2(root2, String(day.getFullYear()), pad(day.getMonth() + 1), pad(day.getDate()));
44983
45001
  }
44984
- function findRollout(threadId) {
44985
- const home3 = process.env.CODEX_HOME?.trim() || join2(homedir2(), ".codex");
45002
+ function matchesRollout(name, threadId) {
45003
+ return name.startsWith("rollout-") && name.endsWith(".jsonl") && (name.endsWith(`-${threadId}.jsonl`) || name.includes(`-${threadId}_`));
45004
+ }
45005
+ function findCodexRollout(threadId, codexHome) {
45006
+ if (!threadId) return void 0;
45007
+ const customHome = codexHome?.trim() || process.env.CODEX_HOME?.trim();
45008
+ const home3 = customHome || join2(homedir2(), ".codex");
44986
45009
  const root2 = join2(home3, "sessions");
44987
- const tail = `-${threadId}.jsonl`;
44988
- const minted = parseInt(threadId.replace(/-/g, "").slice(0, 12), 16);
45010
+ const uuidLike = /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(threadId);
45011
+ const minted = uuidLike ? parseInt(threadId.replace(/-/g, "").slice(0, 12), 16) : Number.NaN;
44989
45012
  const days = /* @__PURE__ */ new Set();
44990
45013
  for (const at of [Date.now(), ...Number.isFinite(minted) && minted > 0 ? [minted] : []]) {
44991
45014
  for (const shift of [0, -1, 1]) days.add(dayDir(root2, at + shift * 864e5));
44992
45015
  }
44993
- let newest2;
44994
- for (const dir of days) {
45016
+ let newestPath;
45017
+ let newestAt = -1;
45018
+ const considerDir = (dir) => {
44995
45019
  let names;
44996
45020
  try {
44997
45021
  names = readdirSync(dir);
44998
45022
  } catch {
44999
- continue;
45023
+ return;
45000
45024
  }
45001
45025
  for (const name of names) {
45002
- if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
45026
+ if (!matchesRollout(name, threadId)) continue;
45003
45027
  const path39 = join2(dir, name);
45004
45028
  try {
45005
45029
  const at = statSync2(path39).mtimeMs;
45006
- if (!newest2 || at > newest2.at) newest2 = { path: path39, at };
45030
+ if (at > newestAt) {
45031
+ newestPath = path39;
45032
+ newestAt = at;
45033
+ }
45007
45034
  } catch {
45008
45035
  }
45009
45036
  }
45037
+ };
45038
+ for (const dir of days) considerDir(dir);
45039
+ if (newestPath || !customHome && !uuidLike) return newestPath;
45040
+ const subdirs = (dir) => {
45041
+ try {
45042
+ return readdirSync(dir).map((n) => join2(dir, n));
45043
+ } catch {
45044
+ return [];
45045
+ }
45046
+ };
45047
+ for (const year of subdirs(root2)) {
45048
+ for (const month of subdirs(year)) {
45049
+ for (const day of subdirs(month)) {
45050
+ if (!days.has(day)) considerDir(day);
45051
+ }
45052
+ }
45010
45053
  }
45011
- return newest2?.path;
45054
+ considerDir(join2(home3, "archived_sessions"));
45055
+ return newestPath;
45012
45056
  }
45013
45057
  function readCodexRunFacts(threadId) {
45014
- const path39 = findRollout(threadId);
45058
+ const path39 = findCodexRollout(threadId);
45015
45059
  if (!path39) return void 0;
45016
45060
  let raw;
45017
45061
  try {
@@ -46012,6 +46056,13 @@ async function* terminals(rpc, threadId, alive2, verify2 = false) {
46012
46056
  cursor = typeof page.nextCursor === "string" ? page.nextCursor : void 0;
46013
46057
  } while (cursor !== void 0);
46014
46058
  }
46059
+ async function activeTerminalHandles(rpc, threadId, alive2) {
46060
+ const handles = /* @__PURE__ */ new Map();
46061
+ for await (const { itemId, processId } of terminals(rpc, threadId, alive2, true)) {
46062
+ handles.set(terminalKey(threadId, itemId), processId);
46063
+ }
46064
+ return handles;
46065
+ }
46015
46066
  function codexWork() {
46016
46067
  const children = /* @__PURE__ */ new Set();
46017
46068
  const entries = /* @__PURE__ */ new Map();
@@ -46225,17 +46276,21 @@ function createCodexConnection(argv) {
46225
46276
  }
46226
46277
  function createCodexClient(options = { images: [] }) {
46227
46278
  let background = 0;
46279
+ let commandCheck = () => false;
46228
46280
  return {
46229
46281
  structured: true,
46230
46282
  managedProcess: true,
46231
46283
  idleRecovery: true,
46232
46284
  background: () => background,
46285
+ activeCommand: () => commandCheck(),
46233
46286
  turn: (io) => run(io, options, (count2) => {
46234
46287
  background = count2;
46288
+ }, (check) => {
46289
+ commandCheck = check;
46235
46290
  })
46236
46291
  };
46237
46292
  }
46238
- async function run(io, options, count2) {
46293
+ async function run(io, options, count2, commandCheck) {
46239
46294
  const since = Date.now();
46240
46295
  const renderer = createCodexStreamRenderer();
46241
46296
  let idling = false;
@@ -46284,12 +46339,17 @@ async function run(io, options, count2) {
46284
46339
  const seenItems = /* @__PURE__ */ new Set();
46285
46340
  const completedTurns = /* @__PURE__ */ new Set();
46286
46341
  const historicalTurns = /* @__PURE__ */ new Set();
46342
+ const ownCommands = /* @__PURE__ */ new Set();
46287
46343
  let currentTurn2 = "";
46288
46344
  let threadId = "";
46289
46345
  let active = true;
46290
46346
  let timer;
46291
46347
  let ended = false;
46292
46348
  let checking = false;
46349
+ let checkingCommands = false;
46350
+ let commandProbeFailed = false;
46351
+ let commandCheckedAt = -Infinity;
46352
+ let commandHandles = /* @__PURE__ */ new Map();
46293
46353
  let context;
46294
46354
  let total;
46295
46355
  let baseline;
@@ -46350,9 +46410,9 @@ async function run(io, options, count2) {
46350
46410
  };
46351
46411
  const cancelled = () => {
46352
46412
  work.freeze();
46353
- if (submitted && !started || [...work.entries.values()].some((w) => !itemTerminal(w))) {
46354
- note(STOPPED_CLEANUP_DETAIL);
46355
- }
46413
+ for (const [id, entry2] of work.entries) if (!itemTerminal(entry2)) work.background.add(id);
46414
+ if (submitted && !started) note("Execution stopped before turn startup was confirmed.");
46415
+ else if (work.work().some((w) => !itemTerminal(w))) note(STOPPED_CLEANUP_DETAIL);
46356
46416
  end("Codex execution stopped.");
46357
46417
  };
46358
46418
  io.signal?.addEventListener("abort", cancelled, { once: true });
@@ -46613,6 +46673,11 @@ async function run(io, options, count2) {
46613
46673
  if (msg.method === "item/started" || msg.method === "item/completed") {
46614
46674
  const raw = obj2(p.item);
46615
46675
  work.observe(source, raw);
46676
+ const itemTurn = str2(p.turnId);
46677
+ if (source === threadId && submitted && active && itemTurn === currentTurn2 && itemTurn && raw.type === "commandExecution" && str2(raw.id)) {
46678
+ const id = terminalKey(source, str2(raw.id));
46679
+ if (!retained.has(id)) ownCommands.add(id);
46680
+ }
46616
46681
  if (source === threadId && active) {
46617
46682
  if (raw.type === "commandExecution") visible.add(terminalKey(source, str2(raw.id)));
46618
46683
  if (raw.type === "collabAgentToolCall") for (const id of Object.keys(obj2(raw.agentsStates))) visible.add(`agent:${id}`);
@@ -46715,6 +46780,33 @@ async function run(io, options, count2) {
46715
46780
  void check();
46716
46781
  }
46717
46782
  });
46783
+ commandCheck(() => {
46784
+ if (ended || idling || !threadId || commandProbeFailed) return false;
46785
+ const running = (id) => ownCommands.has(id) && work.entries.get(id)?.status === "running";
46786
+ const now = Date.now();
46787
+ if (!checkingCommands && now - commandCheckedAt >= 1e3 && [...ownCommands].some(running)) {
46788
+ checkingCommands = true;
46789
+ let settled = false;
46790
+ void bounded(
46791
+ activeTerminalHandles(rpc, threadId, () => !ended && !idling && !settled),
46792
+ 2e3,
46793
+ "Codex background verification timed out."
46794
+ ).then((handles) => {
46795
+ commandHandles = handles;
46796
+ commandCheckedAt = Date.now();
46797
+ }, () => {
46798
+ commandProbeFailed = true;
46799
+ }).finally(() => {
46800
+ settled = true;
46801
+ checkingCommands = false;
46802
+ });
46803
+ }
46804
+ return now - commandCheckedAt <= 3e3 && [...commandHandles].some(([id, handle]) => {
46805
+ if (!running(id)) return false;
46806
+ const observed = work.entries.get(id)?.processId;
46807
+ return !observed || observed === handle;
46808
+ });
46809
+ });
46718
46810
  try {
46719
46811
  if (io.signal?.aborted) {
46720
46812
  cancelled();
@@ -49659,8 +49751,10 @@ var PAGE = (outcome, lang, links) => {
49659
49751
  return `<!doctype html><html lang="${lang === "zh" ? "zh-CN" : "en"}"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title} \xB7 WildCrane</title><style>*{margin:0;box-sizing:border-box}body{display:flex;flex-direction:column;min-height:100dvh;background:#fff;color:#24231f;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}header{padding:16px 36px 0}main{flex:1;display:flex;align-items:center;justify-content:center;padding:0 36px 64px;text-align:center}.icon{display:flex;margin:0 auto;width:44px;height:44px;border-radius:50%;align-items:center;justify-content:center;background:${ok ? "#e4f3ea" : "#f7ddce"};color:${ok ? "#2f6b46" : "#b83a12"}}h1{font-size:24px;font-weight:850;line-height:1.25;letter-spacing:-0.02em}h1.below{margin-top:16px}p{margin:8px auto 0;max-width:38ch;font-size:13px;line-height:19px;color:#565550}main>div.choose{width:100%;max-width:320px}nav{margin-top:28px;display:flex;flex-direction:column;gap:12px}nav a{display:flex;height:44px;align-items:center;justify-content:center;gap:8px;border-radius:10px;font-size:14.5px;font-weight:600;color:#24231f;text-decoration:none;background:#fff;border:1px solid rgba(36,35,31,0.14)}nav a.dark{background:#24231f;color:#fff;border-color:#24231f}form{margin-top:28px;display:flex;flex-direction:column;gap:12px}input{height:44px;padding:0 14px;border-radius:10px;border:1px solid rgba(36,35,31,0.14);font:inherit;font-size:14.5px}button{height:44px;border-radius:10px;border:0;font:inherit;font-size:14.5px;font-weight:600;cursor:pointer}button.dark{background:#24231f;color:#fff}button:disabled{opacity:.6}button.link{height:auto;background:none;color:#565550;font-size:13px;font-weight:500}small{font-size:13px;line-height:19px;color:#565550}small.bad{color:#b83a12}small:empty{display:none}.or{margin-top:20px;display:flex;align-items:center;gap:12px;font-size:13px;color:#8a8984}.or::before,.or::after{content:"";flex:1;height:1px;background:rgba(36,35,31,0.12)}.or+nav{margin-top:20px}</style><header><svg viewBox="2 4 56 52" width="23.7" height="22" aria-hidden="true"><path d="${CRANE}" fill="#24231f"/><path d="${CREST}" fill="#dd4f1e"/></svg></header><main><div${links ? ' class="choose"' : ""}>${top}</div></main></html>`;
49660
49752
  };
49661
49753
  function sameToken(a, b) {
49662
- if (!a || a.length !== b.length) return false;
49663
- return crypto9.timingSafeEqual(Buffer.from(a), Buffer.from(b));
49754
+ if (!a) return false;
49755
+ const received = Buffer.from(a);
49756
+ const expected = Buffer.from(b);
49757
+ return received.length === expected.length && crypto9.timingSafeEqual(received, expected);
49664
49758
  }
49665
49759
  async function signIn(options = {}) {
49666
49760
  const generation = accountGeneration();
@@ -49718,11 +49812,18 @@ async function signIn(options = {}) {
49718
49812
  const params = asked.searchParams;
49719
49813
  const code = params.get("code");
49720
49814
  const error = params.get("error");
49721
- const stateOk = sameToken(params.get("state"), oauthState);
49722
- const failure3 = !stateOk ? { why: "other", detail: "invalid oauth state" } : code ? await exchange(code, verifier, generation, options.signal) : {
49723
- why: error === "access_denied" ? "denied" : "other",
49724
- detail: params.get("error_description") || error || "no code came back"
49725
- };
49815
+ const errorCode = params.get("error_code");
49816
+ let failure3;
49817
+ if (!sameToken(params.get("state"), oauthState)) {
49818
+ failure3 = { why: "other", detail: "invalid oauth state" };
49819
+ } else if (code && !error && errorCode === null) {
49820
+ failure3 = await exchange(code, verifier, generation, options.signal);
49821
+ } else {
49822
+ failure3 = {
49823
+ why: error === "access_denied" && errorCode === null ? "denied" : "other",
49824
+ detail: params.get("error_description") || errorCode || error || "no code came back"
49825
+ };
49826
+ }
49726
49827
  const outcome = !failure3 ? "ok" : failure3.why === "denied" ? "denied" : "failed";
49727
49828
  res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
49728
49829
  res.end(PAGE(outcome, lang));
@@ -49732,14 +49833,15 @@ async function signIn(options = {}) {
49732
49833
  const { port } = server.address();
49733
49834
  expectedOrigin = `http://127.0.0.1:${port}`;
49734
49835
  const { supabaseUrl } = cloudEndpoints();
49836
+ const callback2 = new URL("/signed-in", expectedOrigin);
49837
+ callback2.searchParams.set("state", oauthState);
49735
49838
  const authorize = (provider) => {
49736
49839
  const url = new URL(`${supabaseUrl}/auth/v1/authorize`);
49737
49840
  url.searchParams.set("provider", provider);
49738
- url.searchParams.set("redirect_to", `http://127.0.0.1:${port}/signed-in`);
49841
+ url.searchParams.set("redirect_to", callback2.toString());
49739
49842
  if (provider === "github") url.searchParams.set("scopes", "user:email");
49740
49843
  url.searchParams.set("code_challenge", challenge);
49741
49844
  url.searchParams.set("code_challenge_method", "s256");
49742
- url.searchParams.set("state", oauthState);
49743
49845
  return url.toString().replace(/&/g, "&amp;");
49744
49846
  };
49745
49847
  const choose = `http://127.0.0.1:${port}/`;