lobstah 0.8.6 → 0.8.7

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/runner.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // packages/runner/src/index.ts
2
- import * as fs39 from "node:fs";
2
+ import * as fs40 from "node:fs";
3
3
  import * as path35 from "node:path";
4
4
 
5
5
  // packages/core/dist/types.js
@@ -1280,6 +1280,7 @@ function dropHeavyTickets(match, reason) {
1280
1280
  function liveHeavyTickets(match, now2 = Date.now()) {
1281
1281
  return readLine().filter((t) => (match.dispatch !== void 0 && t.dispatch === match.dispatch || match.trap !== void 0 && t.trap === match.trap) && (t.state === "waiting" ? t.deadAt === void 0 && ownerAlive(t, now2) : t.state !== "cancelled" && (ownerAlive(t, now2) || groupAlive(t))));
1282
1282
  }
1283
+ var HISTORY_TAIL_BYTES = 64 * 1024;
1283
1284
 
1284
1285
  // packages/core/dist/remote-link.js
1285
1286
  var CHUNK = 1 << 20;
@@ -2546,7 +2547,7 @@ function waitingFields(verb, w, now2 = Date.now()) {
2546
2547
  }
2547
2548
  return out;
2548
2549
  }
2549
- function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2550
+ function appendStatus(id, lane, verb, note, at, waiting, reported = false, permissionRequest = false) {
2550
2551
  if (!isVerb(verb)) {
2551
2552
  throw new Error(`invalid status verb "${verb}" \u2014 must be one of: ${VERBS.join(", ")}`);
2552
2553
  }
@@ -2556,7 +2557,8 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
2556
2557
  verb,
2557
2558
  ...note ? { note } : {},
2558
2559
  ...extra,
2559
- ...reported ? { reported: true } : {}
2560
+ ...reported ? { reported: true } : {},
2561
+ ...permissionRequest ? { permissionRequest: true } : {}
2560
2562
  };
2561
2563
  if (verb === "done") {
2562
2564
  try {
@@ -2784,7 +2786,7 @@ function sendMessageOnce(id, lane, deliveryId, text, from, attachments = []) {
2784
2786
  return appendMessage(id, lane, text, from, attachments, deliveryId);
2785
2787
  });
2786
2788
  }
2787
- function appendMessage(id, lane, text, from, attachments = [], deliveryId) {
2789
+ function appendMessage(id, lane, text, from, attachments = [], deliveryId, permissionCard) {
2788
2790
  const dir = inboxDir(id, lane);
2789
2791
  fs23.mkdirSync(path19.join(dir, "handled"), { recursive: true });
2790
2792
  const existing = fs23.readdirSync(dir).filter((f) => f.endsWith(".msg")).length;
@@ -2792,7 +2794,13 @@ function appendMessage(id, lane, text, from, attachments = [], deliveryId) {
2792
2794
  const name = `${String(existing + handled + 1).padStart(3, "0")}.msg`;
2793
2795
  const tmp = uniqueTempPath(path19.join(dir, name));
2794
2796
  if (from !== void 0 || attachments.length > 0) {
2795
- const meta = { ...deliveryId ? { deliveryId } : {}, from: from ?? "unknown", at: (/* @__PURE__ */ new Date()).toISOString(), ...attachments.length ? { attachments } : {} };
2797
+ const meta = {
2798
+ ...deliveryId ? { deliveryId } : {},
2799
+ from: from ?? "unknown",
2800
+ at: (/* @__PURE__ */ new Date()).toISOString(),
2801
+ ...attachments.length ? { attachments } : {},
2802
+ ...permissionCard ? { permissionCard } : {}
2803
+ };
2796
2804
  const metaTmp = `${tmp}.meta`;
2797
2805
  fs23.writeFileSync(metaTmp, JSON.stringify(meta, null, 2));
2798
2806
  atomicRenameSync(metaTmp, path19.join(dir, metaName(name)));
@@ -3461,6 +3469,13 @@ var DEFAULT_HELM = {
3461
3469
  goalsNudgeSecs: 7200
3462
3470
  };
3463
3471
  var DEFAULT_GLASS = { port: 4949 };
3472
+ function glassConfig(raw, wharves) {
3473
+ const glass = { ...DEFAULT_GLASS, ...raw ?? {} };
3474
+ if (glass.mirror !== void 0 && (typeof glass.mirror !== "string" || !Object.hasOwn(wharves, glass.mirror))) {
3475
+ throw new Error(`[glass] mirror must name a wharf in [wharves]; ${JSON.stringify(glass.mirror)} is not one`);
3476
+ }
3477
+ return glass;
3478
+ }
3464
3479
  var DEFAULT_WAIT = { baseTimeoutSecs: 900, baseRepeats: 3, maxTimeoutSecs: 14400 };
3465
3480
  var DEFAULT_WATCH = { maxForksPerCycle: 3, autoRepair: true, conflicts: true, checks: true, maxRepairsPerPr: 2, maxRepairsWithoutProgress: 2, repairSettleSecs: 600, repairCooldownSecs: 0, repairTrapWaitSecs: 600 };
3466
3481
  var DEFAULT_LIMITS = {
@@ -3592,7 +3607,7 @@ function loadConfig() {
3592
3607
  heavy: parseHeavy(raw.heavy),
3593
3608
  helm,
3594
3609
  wait,
3595
- glass: { ...DEFAULT_GLASS, ...raw.glass ?? {} },
3610
+ glass: glassConfig(raw.glass, wharves),
3596
3611
  pet: { open: petOpen },
3597
3612
  watch,
3598
3613
  grounds,
@@ -3755,6 +3770,10 @@ function cancelRequested(id, lane) {
3755
3770
  return fs31.existsSync(path27.join(laneDirs(lane).active, id, "cancel"));
3756
3771
  }
3757
3772
 
3773
+ // packages/core/dist/backend-model.js
3774
+ var MIRROR_SNAPSHOT_MAX_BYTES = 2 * 1024 * 1024;
3775
+ var MIRROR_SNAPSHOT_MAX_JSON_BYTES = 16 * 1024 * 1024;
3776
+
3758
3777
  // packages/core/dist/backend.js
3759
3778
  function parseBackendLocation(raw) {
3760
3779
  if (raw === void 0)
@@ -3777,8 +3796,23 @@ var CLOSED_KEEP_MS = 30 * 24 * 3600 * 1e3;
3777
3796
  // packages/core/dist/grants.js
3778
3797
  var ONCE_TTL_MS = 60 * 60 * 1e3;
3779
3798
 
3780
- // packages/core/dist/harness.js
3799
+ // packages/core/dist/version.js
3781
3800
  import * as fs32 from "node:fs";
3801
+ function installedVersion() {
3802
+ if (process.env.LOBSTAH_BUILD_VERSION)
3803
+ return process.env.LOBSTAH_BUILD_VERSION;
3804
+ try {
3805
+ const pkg = JSON.parse(fs32.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
3806
+ if (pkg.name === "lobstah" && typeof pkg.version === "string")
3807
+ return pkg.version;
3808
+ } catch {
3809
+ }
3810
+ return "0.0.0-dev";
3811
+ }
3812
+ var VERSION = installedVersion();
3813
+
3814
+ // packages/core/dist/harness.js
3815
+ import * as fs33 from "node:fs";
3782
3816
  import * as path28 from "node:path";
3783
3817
  import { createRequire } from "node:module";
3784
3818
  function resolveOnPath(bin, pathVar = process.env.PATH) {
@@ -3791,8 +3825,8 @@ function resolveOnPath(bin, pathVar = process.env.PATH) {
3791
3825
  for (const name of names) {
3792
3826
  const candidate = path28.join(dir, name);
3793
3827
  try {
3794
- fs32.accessSync(candidate, fs32.constants.X_OK);
3795
- if (fs32.statSync(candidate).isFile())
3828
+ fs33.accessSync(candidate, fs33.constants.X_OK);
3829
+ if (fs33.statSync(candidate).isFile())
3796
3830
  return candidate;
3797
3831
  } catch {
3798
3832
  }
@@ -3814,7 +3848,7 @@ function codexInvocation(argv) {
3814
3848
  }
3815
3849
  for (const dir of require_.resolve.paths("@openai/codex") ?? []) {
3816
3850
  const cli = path28.join(dir, "@openai", "codex", "bin", "codex.js");
3817
- if (fs32.existsSync(cli))
3851
+ if (fs33.existsSync(cli))
3818
3852
  return { file: process.execPath, argv: [cli, ...argv] };
3819
3853
  }
3820
3854
  return void 0;
@@ -3822,7 +3856,7 @@ function codexInvocation(argv) {
3822
3856
 
3823
3857
  // packages/core/dist/heavy-hooks.js
3824
3858
  import { execFileSync as execFileSync4 } from "node:child_process";
3825
- import fs33 from "node:fs";
3859
+ import fs34 from "node:fs";
3826
3860
  import * as path29 from "node:path";
3827
3861
  var HOOK_NAMES = [
3828
3862
  "applypatch-msg",
@@ -3869,30 +3903,30 @@ exec "$real" "$@"
3869
3903
  var heavyHooksDir = () => path29.join(heavyDir(), "hooks");
3870
3904
  function ensureHeavyHooks() {
3871
3905
  const dir = heavyHooksDir();
3872
- fs33.mkdirSync(dir, { recursive: true });
3906
+ fs34.mkdirSync(dir, { recursive: true });
3873
3907
  const shim = path29.join(dir, SHIM_FILE);
3874
3908
  let current;
3875
3909
  try {
3876
- current = fs33.readFileSync(shim, "utf8");
3910
+ current = fs34.readFileSync(shim, "utf8");
3877
3911
  } catch {
3878
3912
  }
3879
3913
  if (current !== SHIM) {
3880
3914
  const tmp = uniqueTempPath(shim);
3881
- fs33.writeFileSync(tmp, SHIM, { mode: 493 });
3915
+ fs34.writeFileSync(tmp, SHIM, { mode: 493 });
3882
3916
  atomicRenameSync(tmp, shim);
3883
3917
  }
3884
3918
  for (const name of HOOK_NAMES) {
3885
3919
  const link = path29.join(dir, name);
3886
3920
  try {
3887
- if (fs33.readlinkSync(link) === SHIM_FILE)
3921
+ if (fs34.readlinkSync(link) === SHIM_FILE)
3888
3922
  continue;
3889
- fs33.rmSync(link, { force: true });
3923
+ fs34.rmSync(link, { force: true });
3890
3924
  } catch (err) {
3891
3925
  if (err.code !== "ENOENT")
3892
- fs33.rmSync(link, { force: true });
3926
+ fs34.rmSync(link, { force: true });
3893
3927
  }
3894
3928
  try {
3895
- fs33.symlinkSync(SHIM_FILE, link);
3929
+ fs34.symlinkSync(SHIM_FILE, link);
3896
3930
  } catch (err) {
3897
3931
  if (err.code !== "EEXIST")
3898
3932
  throw err;
@@ -4001,8 +4035,11 @@ function droppedModelNote(harness, dropped) {
4001
4035
  return `model ${dropped.model} is a ${dropped.owner} model \u2014 dropped, using ${harness}'s default`;
4002
4036
  }
4003
4037
 
4038
+ // packages/core/dist/mirror-status.js
4039
+ var MIRROR_FRESH_MS = 6 * 6e4;
4040
+
4004
4041
  // packages/runner/src/run.ts
4005
- import * as fs38 from "node:fs";
4042
+ import * as fs39 from "node:fs";
4006
4043
  import * as path34 from "node:path";
4007
4044
  import { execFileSync as execFileSync6 } from "node:child_process";
4008
4045
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -4299,31 +4336,31 @@ function createClaudeAdapter() {
4299
4336
  }
4300
4337
 
4301
4338
  // packages/adapters/dist/codex.js
4302
- import * as fs34 from "node:fs";
4339
+ import * as fs35 from "node:fs";
4303
4340
  import * as os5 from "node:os";
4304
4341
  import * as path30 from "node:path";
4305
4342
  import { spawn as spawn2 } from "node:child_process";
4306
4343
  function isolatedCodexHome() {
4307
4344
  const dir = path30.join(lobstahHome(), "codex-home");
4308
- fs34.mkdirSync(dir, { recursive: true });
4345
+ fs35.mkdirSync(dir, { recursive: true });
4309
4346
  const auth = path30.join(dir, "auth.json");
4310
4347
  const realAuth = path30.join(os5.homedir(), ".codex", "auth.json");
4311
- if (!fs34.existsSync(auth) && fs34.existsSync(realAuth)) {
4348
+ if (!fs35.existsSync(auth) && fs35.existsSync(realAuth)) {
4312
4349
  try {
4313
- fs34.symlinkSync(realAuth, auth);
4350
+ fs35.symlinkSync(realAuth, auth);
4314
4351
  } catch {
4315
- fs34.copyFileSync(realAuth, auth);
4352
+ fs35.copyFileSync(realAuth, auth);
4316
4353
  }
4317
4354
  }
4318
4355
  const cfg = path30.join(dir, "config.toml");
4319
- if (!fs34.existsSync(cfg)) {
4320
- fs34.writeFileSync(cfg, "# lobstah-managed: auth inherited from ~/.codex, interactive config not\n");
4356
+ if (!fs35.existsSync(cfg)) {
4357
+ fs35.writeFileSync(cfg, "# lobstah-managed: auth inherited from ~/.codex, interactive config not\n");
4321
4358
  }
4322
4359
  return dir;
4323
4360
  }
4324
4361
  function heavyLineDir() {
4325
4362
  const dir = heavyDir();
4326
- fs34.mkdirSync(dir, { recursive: true });
4363
+ fs35.mkdirSync(dir, { recursive: true });
4327
4364
  return dir;
4328
4365
  }
4329
4366
  function pumpCodexEvent(ev, push, onSession) {
@@ -4526,14 +4563,14 @@ function loadAdapter(name) {
4526
4563
  }
4527
4564
 
4528
4565
  // packages/worktree/dist/index.js
4529
- import * as fs36 from "node:fs";
4566
+ import * as fs37 from "node:fs";
4530
4567
  import * as path32 from "node:path";
4531
4568
  import { createHash } from "node:crypto";
4532
4569
  import { exec, execFile as execFile2, execFileSync as execFileSync5 } from "node:child_process";
4533
4570
  import { promisify as promisify2 } from "node:util";
4534
4571
 
4535
4572
  // packages/worktree/dist/pool.js
4536
- import * as fs35 from "node:fs";
4573
+ import * as fs36 from "node:fs";
4537
4574
  import * as path31 from "node:path";
4538
4575
  import { execFile } from "node:child_process";
4539
4576
  import { promisify } from "node:util";
@@ -4596,7 +4633,7 @@ function takeOut(name, pool, slot, reason, dispatch, notice = true) {
4596
4633
  function trapIn(dir) {
4597
4634
  const real = (p) => {
4598
4635
  try {
4599
- return fs35.realpathSync.native(p);
4636
+ return fs36.realpathSync.native(p);
4600
4637
  } catch {
4601
4638
  return path31.resolve(p);
4602
4639
  }
@@ -4614,7 +4651,7 @@ async function claimPoolSlot(input) {
4614
4651
  const refused = [];
4615
4652
  for (let slot = 1; slot <= pool.size; slot++) {
4616
4653
  const dir = poolSlotPath(name, slot);
4617
- if (fs35.existsSync(dir) && readWorktreeLock(dir)?.id === id && readWorktreeLock(dir)?.kind !== "warm") {
4654
+ if (fs36.existsSync(dir) && readWorktreeLock(dir)?.id === id && readWorktreeLock(dir)?.kind !== "warm") {
4618
4655
  writeSlotClaim(name, slot, { id, lane, at: (/* @__PURE__ */ new Date()).toISOString() });
4619
4656
  return { claimed: true, dir, slot, label: poolSlotLabel(name, slot) };
4620
4657
  }
@@ -4662,7 +4699,7 @@ async function resetPoolWorktree(repo, dir, id, fromRemoteBranch = repo.trunk) {
4662
4699
  }
4663
4700
  var WARM_ID = "pool-warm";
4664
4701
  async function createSlot(repo, dir) {
4665
- fs35.mkdirSync(path31.dirname(dir), { recursive: true });
4702
+ fs36.mkdirSync(path31.dirname(dir), { recursive: true });
4666
4703
  await oneAtATime(repo.path, async () => {
4667
4704
  await tryGit(repo.path, "worktree", "prune");
4668
4705
  await gitShared(repo.path, "worktree", "add", "--detach", dir, `origin/${repo.trunk}`);
@@ -4684,7 +4721,7 @@ async function warmPool(name, opts = {}) {
4684
4721
  if (!release)
4685
4722
  return false;
4686
4723
  try {
4687
- if (!fs35.existsSync(repo.path)) {
4724
+ if (!fs36.existsSync(repo.path)) {
4688
4725
  if (!repo.origin)
4689
4726
  throw new Error(`repo path ${repo.path} missing and no origin configured`);
4690
4727
  await run("git", ["clone", repo.origin, repo.path], { env: process.env });
@@ -4697,8 +4734,8 @@ async function warmPool(name, opts = {}) {
4697
4734
  const dir = poolSlotPath(name, slot);
4698
4735
  const label = poolSlotLabel(name, slot);
4699
4736
  const meta = readSlotMeta(name, slot);
4700
- if (!fs35.existsSync(dir)) {
4701
- fs35.mkdirSync(poolsRoot(), { recursive: true });
4737
+ if (!fs36.existsSync(dir)) {
4738
+ fs36.mkdirSync(poolsRoot(), { recursive: true });
4702
4739
  recoverTrapCaches(cfg, poolsRoot(), read2, log);
4703
4740
  let free = Infinity;
4704
4741
  try {
@@ -4842,7 +4879,7 @@ function pidAlive3(pid) {
4842
4879
  var BUSY = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
4843
4880
  function takeRepoLock(file2, mine) {
4844
4881
  try {
4845
- fs36.writeFileSync(file2, mine, { flag: "wx" });
4882
+ fs37.writeFileSync(file2, mine, { flag: "wx" });
4846
4883
  return { state: "held" };
4847
4884
  } catch (err) {
4848
4885
  const code2 = err.code ?? "";
@@ -4852,8 +4889,8 @@ function takeRepoLock(file2, mine) {
4852
4889
  let raw = "";
4853
4890
  let age = 0;
4854
4891
  try {
4855
- raw = fs36.readFileSync(file2, "utf8");
4856
- age = Date.now() - fs36.statSync(file2).mtimeMs;
4892
+ raw = fs37.readFileSync(file2, "utf8");
4893
+ age = Date.now() - fs37.statSync(file2).mtimeMs;
4857
4894
  } catch {
4858
4895
  return { state: "retry" };
4859
4896
  }
@@ -4866,8 +4903,8 @@ function takeRepoLock(file2, mine) {
4866
4903
  const stale = age > REPO_LOCK_WAIT_MS || (holder ? !pidAlive3(holder.pid) : age > 5e3);
4867
4904
  if (stale) {
4868
4905
  try {
4869
- if (fs36.readFileSync(file2, "utf8") === raw)
4870
- fs36.rmSync(file2, { force: true });
4906
+ if (fs37.readFileSync(file2, "utf8") === raw)
4907
+ fs37.rmSync(file2, { force: true });
4871
4908
  } catch {
4872
4909
  }
4873
4910
  return { state: "retry" };
@@ -4876,8 +4913,8 @@ function takeRepoLock(file2, mine) {
4876
4913
  }
4877
4914
  function releaseRepoLock(file2, mine) {
4878
4915
  try {
4879
- if (fs36.readFileSync(file2, "utf8") === mine)
4880
- fs36.rmSync(file2, { force: true, recursive: true, maxRetries: 5 });
4916
+ if (fs37.readFileSync(file2, "utf8") === mine)
4917
+ fs37.rmSync(file2, { force: true, recursive: true, maxRetries: 5 });
4881
4918
  } catch {
4882
4919
  }
4883
4920
  }
@@ -4918,7 +4955,7 @@ async function oneAtATime(cwd, fn) {
4918
4955
  }
4919
4956
  function fetchStamps(common) {
4920
4957
  try {
4921
- return JSON.parse(fs36.readFileSync(path32.join(common, "lobstah-fetch.json"), "utf8"));
4958
+ return JSON.parse(fs37.readFileSync(path32.join(common, "lobstah-fetch.json"), "utf8"));
4922
4959
  } catch {
4923
4960
  return {};
4924
4961
  }
@@ -4932,15 +4969,15 @@ async function fetchShared(cwd, remote, ref) {
4932
4969
  const started = Date.now();
4933
4970
  await gitShared(cwd, "fetch", remote, ref);
4934
4971
  const stamps = { ...fetchStamps(common), [key]: started };
4935
- fs36.writeFileSync(path32.join(common, "lobstah-fetch.json"), JSON.stringify(stamps, null, 2));
4972
+ fs37.writeFileSync(path32.join(common, "lobstah-fetch.json"), JSON.stringify(stamps, null, 2));
4936
4973
  });
4937
4974
  }
4938
4975
  async function allocate(repo, id, fromRemoteBranch = repo.trunk) {
4939
4976
  const dir = worktreePath(id);
4940
- if (fs36.existsSync(dir)) {
4977
+ if (fs37.existsSync(dir)) {
4941
4978
  throw new Error(`worktree for ${id} already exists at ${dir} \u2014 never allocate a second`);
4942
4979
  }
4943
- if (!fs36.existsSync(repo.path)) {
4980
+ if (!fs37.existsSync(repo.path)) {
4944
4981
  if (!repo.origin)
4945
4982
  throw new Error(`repo path ${repo.path} missing and no origin configured`);
4946
4983
  await run2("git", ["clone", repo.origin, repo.path], { env: process.env });
@@ -4955,7 +4992,7 @@ async function allocate(repo, id, fromRemoteBranch = repo.trunk) {
4955
4992
  async function recoverWorktree(repo, id) {
4956
4993
  const dir = worktreePath(id);
4957
4994
  try {
4958
- if (fs36.statSync(path32.join(dir, ".git")).isFile()) {
4995
+ if (fs37.statSync(path32.join(dir, ".git")).isFile()) {
4959
4996
  const branch = await git2(dir, "symbolic-ref", "--quiet", "HEAD");
4960
4997
  const root = await git2(dir, "rev-parse", "--show-toplevel");
4961
4998
  const common = await git2(dir, "rev-parse", "--path-format=absolute", "--git-common-dir");
@@ -5022,10 +5059,10 @@ function setupHash(repo, dir) {
5022
5059
  h.update(JSON.stringify(repo.setup ?? []));
5023
5060
  for (const name of LOCKFILES) {
5024
5061
  const file2 = path32.join(dir, name);
5025
- if (!fs36.existsSync(file2))
5062
+ if (!fs37.existsSync(file2))
5026
5063
  continue;
5027
5064
  h.update(`\0${name}\0`);
5028
- h.update(fs36.readFileSync(file2));
5065
+ h.update(fs37.readFileSync(file2));
5029
5066
  }
5030
5067
  return h.digest("hex");
5031
5068
  }
@@ -5036,12 +5073,12 @@ function setupRecordFile(dir) {
5036
5073
  function recordSetup(repo, dir) {
5037
5074
  const file2 = setupRecordFile(dir);
5038
5075
  if (file2)
5039
- fs36.writeFileSync(file2, JSON.stringify({ hash: setupHash(repo, dir), at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
5076
+ fs37.writeFileSync(file2, JSON.stringify({ hash: setupHash(repo, dir), at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
5040
5077
  }
5041
5078
  function recordedSetupHash(dir) {
5042
5079
  const file2 = setupRecordFile(dir);
5043
5080
  try {
5044
- return file2 ? JSON.parse(fs36.readFileSync(file2, "utf8")).hash : void 0;
5081
+ return file2 ? JSON.parse(fs37.readFileSync(file2, "utf8")).hash : void 0;
5045
5082
  } catch {
5046
5083
  return void 0;
5047
5084
  }
@@ -5054,7 +5091,7 @@ function poolReused(slot, by) {
5054
5091
  function realpath(p) {
5055
5092
  let r;
5056
5093
  try {
5057
- r = fs36.realpathSync.native(p);
5094
+ r = fs37.realpathSync.native(p);
5058
5095
  } catch {
5059
5096
  r = path32.resolve(p);
5060
5097
  }
@@ -5548,7 +5585,7 @@ function startWallClock(opts) {
5548
5585
  import { execFile as execFile3 } from "node:child_process";
5549
5586
  import { promisify as promisify3 } from "node:util";
5550
5587
  import { fileURLToPath } from "node:url";
5551
- import * as fs37 from "node:fs";
5588
+ import * as fs38 from "node:fs";
5552
5589
  import * as path33 from "node:path";
5553
5590
  var exec2 = promisify3(execFile3);
5554
5591
  function firstLine(err) {
@@ -5582,7 +5619,7 @@ function keepRemote(opts) {
5582
5619
  const root = path33.resolve(path33.dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
5583
5620
  const localCli = path33.join(root, "apps", "cli", "dist", "main.js");
5584
5621
  const args = ["watch", "add", url, "--for", id];
5585
- if (fs37.existsSync(localCli)) await command(process.execPath, [localCli, ...args], 15e3);
5622
+ if (fs38.existsSync(localCli)) await command(process.execPath, [localCli, ...args], 15e3);
5586
5623
  else await command("lobstah", args, 15e3);
5587
5624
  };
5588
5625
  let lastSeenHead;
@@ -5778,13 +5815,13 @@ async function main(activeDir, lane, seams = {}) {
5778
5815
  if (isTrapCatch(id, lane)) throw new Error(`refusing headless runner for trap catch ${id}`);
5779
5816
  const status = (verb, note) => appendStatus(id, lane, verb, note);
5780
5817
  const cfg = loadConfig();
5781
- const descriptor = JSON.parse(fs38.readFileSync(path34.join(activeDir, "descriptor.json"), "utf8"));
5818
+ const descriptor = JSON.parse(fs39.readFileSync(path34.join(activeDir, "descriptor.json"), "utf8"));
5782
5819
  if (descriptor.target || !descriptor.repo) throw new Error("configured trap work cannot launch headless");
5783
5820
  const resolved = resolveDispatch(descriptor, cfg);
5784
5821
  const repo = cfg.repos[descriptor.repo];
5785
5822
  const briefFile = path34.join(activeDir, "brief.md");
5786
- if (!fs38.existsSync(briefFile)) fs38.writeFileSync(briefFile, descriptor.brief);
5787
- const brief = fs38.readFileSync(briefFile, "utf8");
5823
+ if (!fs39.existsSync(briefFile)) fs39.writeFileSync(briefFile, descriptor.brief);
5824
+ const brief = fs39.readFileSync(briefFile, "utf8");
5788
5825
  const attempts = Number(process.env.LOBSTAH_ATTEMPTS ?? "1");
5789
5826
  const wake = process.env.LOBSTAH_WAKE;
5790
5827
  const runnerInfo = {
@@ -5792,7 +5829,7 @@ async function main(activeDir, lane, seams = {}) {
5792
5829
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
5793
5830
  attempts
5794
5831
  };
5795
- fs38.writeFileSync(path34.join(activeDir, "runner.json"), JSON.stringify(runnerInfo, null, 2));
5832
+ fs39.writeFileSync(path34.join(activeDir, "runner.json"), JSON.stringify(runnerInfo, null, 2));
5796
5833
  if (descriptor.systemRepair && descriptor.pr?.url) {
5797
5834
  const state = deps.prState(descriptor.pr.url) ?? readPr(parsePrRef(descriptor.pr.url)?.key ?? "")?.state;
5798
5835
  if (state === "MERGED" || state === "CLOSED") {
@@ -5813,10 +5850,10 @@ async function main(activeDir, lane, seams = {}) {
5813
5850
  let recorded;
5814
5851
  let recovered = false;
5815
5852
  let choice3;
5816
- if (fs38.existsSync(wtFile)) {
5817
- recorded = JSON.parse(fs38.readFileSync(wtFile, "utf8")).path;
5818
- if (!fs38.existsSync(recorded)) throw new Error(`recorded worktree ${recorded} is gone`);
5819
- } else if (fs38.existsSync(worktreePath(id))) {
5853
+ if (fs39.existsSync(wtFile)) {
5854
+ recorded = JSON.parse(fs39.readFileSync(wtFile, "utf8")).path;
5855
+ if (!fs39.existsSync(recorded)) throw new Error(`recorded worktree ${recorded} is gone`);
5856
+ } else if (fs39.existsSync(worktreePath(id))) {
5820
5857
  recorded = await recoverWorktree(repo, id);
5821
5858
  recovered = true;
5822
5859
  } else if (descriptor.followUp && cfg.limits.reuseWorktree !== false) {
@@ -5871,7 +5908,7 @@ async function main(activeDir, lane, seams = {}) {
5871
5908
  if (held) throw new Error(`worktree at ${cwd} is in use by ${held.id} \u2014 wait for that dispatch to release it before retrying`);
5872
5909
  if (recovered) {
5873
5910
  await deps.prepareReuse(repo, cwd);
5874
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5911
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5875
5912
  }
5876
5913
  } else if (choice3?.reuse) {
5877
5914
  cwd = choice3.path;
@@ -5882,17 +5919,17 @@ async function main(activeDir, lane, seams = {}) {
5882
5919
  type: "runner",
5883
5920
  data: { worktree: cwd, worktreeOf: choice3.owner, setupRan }
5884
5921
  });
5885
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd, of: choice3.owner }, null, 2));
5922
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd, of: choice3.owner }, null, 2));
5886
5923
  } else if (poolClaim) {
5887
5924
  cwd = poolClaim.dir;
5888
5925
  await deps.resetPool(repo, cwd, id, descriptor.systemRepair ? descriptor.pr?.headRefName : void 0);
5889
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd, pool: poolClaim.label }, null, 2));
5926
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd, pool: poolClaim.label }, null, 2));
5890
5927
  } else {
5891
5928
  cwd = await deps.allocate(repo, id, descriptor.systemRepair ? descriptor.pr?.headRefName : void 0);
5892
5929
  acquireWorktreeLock(cwd, id, lane);
5893
- fs38.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5930
+ fs39.writeFileSync(wtFile, JSON.stringify({ path: cwd }, null, 2));
5894
5931
  }
5895
- const worktreeOf = JSON.parse(fs38.readFileSync(wtFile, "utf8")).of;
5932
+ const worktreeOf = JSON.parse(fs39.readFileSync(wtFile, "utf8")).of;
5896
5933
  const inPool = poolSlotOf(cwd);
5897
5934
  mergeEvidence(id, lane, { worktree: cwd, worktreeOf, ...inPool ? { pool: poolSlotLabel(inPool.pool, inPool.slot) } : {} });
5898
5935
  const existingPr = boundPr(descriptor, lane);
@@ -5921,13 +5958,13 @@ async function main(activeDir, lane, seams = {}) {
5921
5958
  const planNudge = plan.cold && !envNudge ? coldNote(plan.cold, cwd, repo.trunk) : void 0;
5922
5959
  const promptWith = (nudge) => buildPrompt(brief, { id, nudge, attachments: descriptor.attachments, existingPr });
5923
5960
  const binDir = path34.resolve(path34.dirname(fileURLToPath2(import.meta.url)), "..", "..", "..", "bin");
5924
- const workerPath = fs38.existsSync(path34.join(binDir, "lobstah")) ? `${binDir}${path34.delimiter}${process.env.PATH ?? ""}` : void 0;
5961
+ const workerPath = fs39.existsSync(path34.join(binDir, "lobstah")) ? `${binDir}${path34.delimiter}${process.env.PATH ?? ""}` : void 0;
5925
5962
  let wallClockHit = false;
5926
5963
  let current;
5927
5964
  const wallFile = path34.join(activeDir, "wallclock.json");
5928
5965
  const wallState = (() => {
5929
5966
  try {
5930
- return JSON.parse(fs38.readFileSync(wallFile, "utf8"));
5967
+ return JSON.parse(fs39.readFileSync(wallFile, "utf8"));
5931
5968
  } catch {
5932
5969
  return { elapsedMs: 0, windowMs: resolved.limits.wallClockSecs * 1e3 };
5933
5970
  }
@@ -5946,8 +5983,8 @@ async function main(activeDir, lane, seams = {}) {
5946
5983
  ) * 1e3;
5947
5984
  const persistWall = (elapsedMs, windowMs) => {
5948
5985
  const tmp = uniqueTempPath(wallFile);
5949
- fs38.writeFileSync(tmp, JSON.stringify({ ...wallState, elapsedMs, windowMs }));
5950
- fs38.renameSync(tmp, wallFile);
5986
+ fs39.writeFileSync(tmp, JSON.stringify({ ...wallState, elapsedMs, windowMs }));
5987
+ fs39.renameSync(tmp, wallFile);
5951
5988
  };
5952
5989
  const madeProgress = () => {
5953
5990
  const activity = readActivity(id, lane);
@@ -6258,7 +6295,7 @@ function runRunner(activeDirArg2, laneArg2) {
6258
6295
  if (!isFinished(id, lane)) {
6259
6296
  appendStatus(id, lane, "failed", String(err instanceof Error ? err.message : err).slice(0, 500));
6260
6297
  }
6261
- fs39.renameSync(activeDirArg2, path35.join(laneDirs(lane).done, id));
6298
+ fs40.renameSync(activeDirArg2, path35.join(laneDirs(lane).done, id));
6262
6299
  } catch {
6263
6300
  }
6264
6301
  process.exitCode = 1;
@@ -323,6 +323,7 @@ harness's blocking Stop-hook timeout too.
323
323
  | Key | Default | Meaning |
324
324
  |---|---|---|
325
325
  | `port` | `4949` | Localhost port for the glass. `LOBSTAH_GLASS_PORT` takes precedence. |
326
+ | `mirror` | unset | A wharf in `[wharves]` that shows this machine's glass on its hosted glass. The fleet stays on its local grounds. The daemon puts the glass snapshot there (never the page token): within seconds of a change while a hosted glass is open, and every five minutes otherwise. It carries out on this glass, over loopback, the reads and writes a person makes there, except ↗ Open. Enroll with `lobstah wharf login --wharf <name> --mirror` (mirror and read access only), then `lobstah daemon restart`; `lobstah wharf whoami --wharf <name>` and `lobstah doctor` show how fresh the mirror is. Unset, nothing is sent. |
326
327
 
327
328
  ## `[pet]` — report and decision clicks
328
329
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lobstah",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Harness-agnostic, token-efficient supervision framework for coding agents",
5
5
  "license": "MIT",
6
6
  "author": "aequitas labs LLC",
@@ -11,6 +11,7 @@
11
11
  "files": [
12
12
  "dist",
13
13
  "docs",
14
+ "pet",
14
15
  "README.md",
15
16
  "LICENSE"
16
17
  ],
@@ -0,0 +1,26 @@
1
+ // swift-tools-version:5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "LobstahPet",
6
+ platforms: [.macOS(.v13)],
7
+ targets: [
8
+ // Everything that runs without a window: child processes, the
9
+ // attention read, the state file, the log. Tested on its own.
10
+ .target(
11
+ name: "LobstahPetCore",
12
+ path: "Sources/LobstahPetCore"
13
+ ),
14
+ .executableTarget(
15
+ name: "LobstahPet",
16
+ dependencies: ["LobstahPetCore"],
17
+ path: "Sources/LobstahPet",
18
+ resources: [.process("Resources")]
19
+ ),
20
+ .testTarget(
21
+ name: "LobstahPetCoreTests",
22
+ dependencies: ["LobstahPetCore"],
23
+ path: "Tests/LobstahPetCoreTests"
24
+ ),
25
+ ]
26
+ )