eve-hub 0.6.30 → 0.6.31

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # eve-hub
2
2
 
3
+ ## 0.6.31
4
+
5
+ ### Patch Changes
6
+
7
+ - A bot's sandbox reads its session's git worktree from the file in HUB_SESSION_WORKTREE_DIR when it is set (a bot run by the Mac runner).
8
+
3
9
  ## 0.6.30
4
10
 
5
11
  ### Patch Changes
package/host-sandbox.js CHANGED
@@ -28,16 +28,16 @@ export function hostEnvironment(options) {
28
28
  return { root };
29
29
  },
30
30
  async start(ctx, _open, artifact) {
31
- const worktree = await sessionWorktree(ctx.session.id);
32
31
  const rootSessionId = ctx.session.parent?.rootSessionId;
32
+ const worktree = await sessionWorktree(ctx.session.id, rootSessionId);
33
33
  const state = { ...(worktree ? { root: worktree.path, worktree } : { root: artifact.root }), version: 1, ...(rootSessionId ? { rootSessionId } : {}) };
34
34
  return { handle: hostHandle(state, ctx.session.id), state };
35
35
  },
36
36
  async resume(ctx, _artifact, state) {
37
37
  // Asked again: the registry restores a worktree whose directory went
38
38
  // missing. A session that started on the shared checkout stays there.
39
- const worktree = state.worktree ? ((await sessionWorktree(ctx.session.id)) ?? state.worktree) : undefined;
40
39
  const rootSessionId = state.rootSessionId ?? ctx.session.parent?.rootSessionId;
40
+ const worktree = state.worktree ? ((await sessionWorktree(ctx.session.id, rootSessionId)) ?? state.worktree) : undefined;
41
41
  const next = { ...(worktree ? { ...state, root: worktree.path, worktree } : state), ...(rootSessionId ? { rootSessionId } : {}) };
42
42
  if (!worktree)
43
43
  await mkdir(next.root, { recursive: true }); // never fake a missing worktree with an empty dir
@@ -59,7 +59,25 @@ export const HostSandbox = defineSandboxProvider({
59
59
  // checkout stays there. Any other failure: the shared checkout.
60
60
  class WorkspaceUnavailable extends Error {
61
61
  }
62
- async function sessionWorktree(sessionId) {
62
+ // HUB_SESSION_WORKTREE_DIR (the Mac runner sets it): the runner writes
63
+ // <dir>/<sessionId>.json before it delivers to the session, so there is nothing
64
+ // to ask or wait for. An `agent` copy has no file of its own and uses its root session's.
65
+ async function sessionWorktree(sessionId, rootSessionId) {
66
+ const dir = process.env.HUB_SESSION_WORKTREE_DIR;
67
+ if (dir) {
68
+ for (const id of [sessionId, rootSessionId]) {
69
+ if (!id)
70
+ continue;
71
+ try {
72
+ return JSON.parse(await readFile(join(dir, `${id}.json`), "utf8"));
73
+ }
74
+ catch (error) {
75
+ if (error.code !== "ENOENT")
76
+ throw error;
77
+ }
78
+ }
79
+ return undefined;
80
+ }
63
81
  if (process.env.HUB_SESSION_WORKTREES !== "1")
64
82
  return undefined;
65
83
  const deadline = Date.now() + 15_000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-hub",
3
- "version": "0.6.30",
3
+ "version": "0.6.31",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Bot-side code shared by every hub agent: registry tools, the roster hook, the eve channel, the host sandbox and browser, and model helpers.",
6
6
  "type": "module",