geordi 0.5.0 → 0.6.0

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 (223) hide show
  1. package/daemon/host.js +1388 -2336
  2. package/daemon/main.js +415 -300
  3. package/forge/adapter-node.js +1 -1
  4. package/forge/client/_app/immutable/assets/0.MTPMv8jx.css +2 -0
  5. package/forge/client/_app/immutable/assets/0.MTPMv8jx.css.br +0 -0
  6. package/forge/client/_app/immutable/assets/0.MTPMv8jx.css.gz +0 -0
  7. package/forge/client/_app/immutable/chunks/B3znLk1J.js +1 -0
  8. package/forge/client/_app/immutable/chunks/B3znLk1J.js.br +1 -0
  9. package/forge/client/_app/immutable/chunks/B3znLk1J.js.gz +0 -0
  10. package/forge/client/_app/immutable/chunks/BLYrrO5i.js +1 -0
  11. package/forge/client/_app/immutable/chunks/BLYrrO5i.js.br +0 -0
  12. package/forge/client/_app/immutable/chunks/BLYrrO5i.js.gz +0 -0
  13. package/forge/client/_app/immutable/chunks/{aBa3SWer.js → BPUcSU9Y.js} +1 -1
  14. package/forge/client/_app/immutable/chunks/BPUcSU9Y.js.br +2 -0
  15. package/forge/client/_app/immutable/chunks/BPUcSU9Y.js.gz +0 -0
  16. package/forge/client/_app/immutable/chunks/BV6RCEM1.js +1 -0
  17. package/forge/client/_app/immutable/chunks/BV6RCEM1.js.br +2 -0
  18. package/forge/client/_app/immutable/chunks/BV6RCEM1.js.gz +0 -0
  19. package/forge/client/_app/immutable/chunks/B_mLdc9L.js +1 -0
  20. package/forge/client/_app/immutable/chunks/B_mLdc9L.js.br +0 -0
  21. package/forge/client/_app/immutable/chunks/B_mLdc9L.js.gz +0 -0
  22. package/forge/client/_app/immutable/chunks/BvPSoxVj.js +3 -0
  23. package/forge/client/_app/immutable/chunks/BvPSoxVj.js.br +0 -0
  24. package/forge/client/_app/immutable/chunks/BvPSoxVj.js.gz +0 -0
  25. package/forge/client/_app/immutable/chunks/C1DGY91i.js +1 -0
  26. package/forge/client/_app/immutable/chunks/C1DGY91i.js.br +0 -0
  27. package/forge/client/_app/immutable/chunks/C1DGY91i.js.gz +0 -0
  28. package/forge/client/_app/immutable/chunks/CrbaLN9e.js +3 -0
  29. package/forge/client/_app/immutable/chunks/CrbaLN9e.js.br +0 -0
  30. package/forge/client/_app/immutable/chunks/CrbaLN9e.js.gz +0 -0
  31. package/forge/client/_app/immutable/chunks/Cu5m_VdO.js +162 -0
  32. package/forge/client/_app/immutable/chunks/Cu5m_VdO.js.br +0 -0
  33. package/forge/client/_app/immutable/chunks/Cu5m_VdO.js.gz +0 -0
  34. package/forge/client/_app/immutable/chunks/{4h5PLCfh.js → DBdrLgIP.js} +1 -1
  35. package/forge/client/_app/immutable/chunks/DBdrLgIP.js.br +0 -0
  36. package/forge/client/_app/immutable/chunks/DBdrLgIP.js.gz +0 -0
  37. package/forge/client/_app/immutable/chunks/DGwDCmJd.js +1 -0
  38. package/forge/client/_app/immutable/chunks/DGwDCmJd.js.br +0 -0
  39. package/forge/client/_app/immutable/chunks/DGwDCmJd.js.gz +0 -0
  40. package/forge/client/_app/immutable/chunks/{CP0U8Qtu.js → DHj6ofkw.js} +1 -1
  41. package/forge/client/_app/immutable/chunks/DHj6ofkw.js.br +0 -0
  42. package/forge/client/_app/immutable/chunks/DHj6ofkw.js.gz +0 -0
  43. package/forge/client/_app/immutable/chunks/DOMiXBiZ.js +1 -0
  44. package/forge/client/_app/immutable/chunks/DOMiXBiZ.js.br +1 -0
  45. package/forge/client/_app/immutable/chunks/DOMiXBiZ.js.gz +0 -0
  46. package/forge/client/_app/immutable/chunks/Wy-MV1bx.js +3 -0
  47. package/forge/client/_app/immutable/chunks/Wy-MV1bx.js.br +0 -0
  48. package/forge/client/_app/immutable/chunks/Wy-MV1bx.js.gz +0 -0
  49. package/forge/client/_app/immutable/chunks/YRCfaiJm.js +1 -0
  50. package/forge/client/_app/immutable/chunks/YRCfaiJm.js.br +0 -0
  51. package/forge/client/_app/immutable/chunks/YRCfaiJm.js.gz +0 -0
  52. package/forge/client/_app/immutable/chunks/aqm7T3j0.js +1 -0
  53. package/forge/client/_app/immutable/chunks/aqm7T3j0.js.br +0 -0
  54. package/forge/client/_app/immutable/chunks/aqm7T3j0.js.gz +0 -0
  55. package/forge/client/_app/immutable/chunks/e4tnLtM4.js +1 -0
  56. package/forge/client/_app/immutable/chunks/e4tnLtM4.js.br +0 -0
  57. package/forge/client/_app/immutable/chunks/e4tnLtM4.js.gz +0 -0
  58. package/forge/client/_app/immutable/chunks/qtK8ANZN.js +1 -0
  59. package/forge/client/_app/immutable/chunks/qtK8ANZN.js.br +0 -0
  60. package/forge/client/_app/immutable/chunks/qtK8ANZN.js.gz +0 -0
  61. package/forge/client/_app/immutable/chunks/yLpFDVQa.js +1 -0
  62. package/forge/client/_app/immutable/chunks/yLpFDVQa.js.br +0 -0
  63. package/forge/client/_app/immutable/chunks/yLpFDVQa.js.gz +0 -0
  64. package/forge/client/_app/immutable/entry/app.CcN3jWRh.js +2 -0
  65. package/forge/client/_app/immutable/entry/app.CcN3jWRh.js.br +0 -0
  66. package/forge/client/_app/immutable/entry/app.CcN3jWRh.js.gz +0 -0
  67. package/forge/client/_app/immutable/entry/{start.2j018bzK.js → start.C2pXqDYu.js} +2 -2
  68. package/forge/client/_app/immutable/entry/start.C2pXqDYu.js.br +0 -0
  69. package/forge/client/_app/immutable/entry/start.C2pXqDYu.js.gz +0 -0
  70. package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js +1 -0
  71. package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js.br +0 -0
  72. package/forge/client/_app/immutable/nodes/0.BxR2qPA9.js.gz +0 -0
  73. package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js +1 -0
  74. package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js.br +0 -0
  75. package/forge/client/_app/immutable/nodes/1.DTJ1nwBs.js.gz +0 -0
  76. package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js +1 -0
  77. package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js.br +0 -0
  78. package/forge/client/_app/immutable/nodes/2.Cp2mgq6a.js.gz +0 -0
  79. package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js +1 -0
  80. package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js.br +0 -0
  81. package/forge/client/_app/immutable/nodes/3.CaBDF-xh.js.gz +0 -0
  82. package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js +6 -0
  83. package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js.br +0 -0
  84. package/forge/client/_app/immutable/nodes/4.CkFYpCOG.js.gz +0 -0
  85. package/forge/client/_app/immutable/nodes/5.C707zcjh.js +31 -0
  86. package/forge/client/_app/immutable/nodes/5.C707zcjh.js.br +0 -0
  87. package/forge/client/_app/immutable/nodes/5.C707zcjh.js.gz +0 -0
  88. package/forge/client/_app/version.json +1 -1
  89. package/forge/client/_app/version.json.br +0 -0
  90. package/forge/client/_app/version.json.gz +0 -0
  91. package/forge/server/.vite/manifest.json +36 -28
  92. package/forge/server/_app/immutable/assets/_layout.MTPMv8jx.css +2 -0
  93. package/forge/server/chunks/Dialog.js +7 -28
  94. package/forge/server/chunks/Dialog.js.map +1 -1
  95. package/forge/server/chunks/NewWorkspace.js +110 -268
  96. package/forge/server/chunks/NewWorkspace.js.map +1 -1
  97. package/forge/server/chunks/TitleBar.js +4 -4
  98. package/forge/server/chunks/TitleBar.js.map +1 -1
  99. package/forge/server/chunks/WorkspaceActions.js +7 -4
  100. package/forge/server/chunks/WorkspaceActions.js.map +1 -1
  101. package/forge/server/chunks/access.remote.js +9 -3
  102. package/forge/server/chunks/access.remote.js.map +1 -1
  103. package/forge/server/chunks/app.js +533 -245
  104. package/forge/server/chunks/app.js.map +1 -1
  105. package/forge/server/chunks/format.js +238 -2
  106. package/forge/server/chunks/format.js.map +1 -1
  107. package/forge/server/chunks/index-server2.js +1 -8
  108. package/forge/server/chunks/index-server2.js.map +1 -1
  109. package/forge/server/chunks/instance.js +3 -3
  110. package/forge/server/chunks/internal.js +2 -2
  111. package/forge/server/chunks/internal.js.map +1 -1
  112. package/forge/server/chunks/keys.js +104 -0
  113. package/forge/server/chunks/keys.js.map +1 -0
  114. package/forge/server/chunks/{afar.svelte.js → motion.js} +5 -3
  115. package/forge/server/chunks/motion.js.map +1 -0
  116. package/forge/server/chunks/overview.js +1 -1
  117. package/forge/server/chunks/overview.js.map +1 -1
  118. package/forge/server/chunks/remote-15qct20.js +1 -1
  119. package/forge/server/chunks/settings.svelte.js +5 -0
  120. package/forge/server/chunks/settings.svelte.js.map +1 -1
  121. package/forge/server/chunks/workspaces.remote.js +9 -2
  122. package/forge/server/chunks/workspaces.remote.js.map +1 -1
  123. package/forge/server/entries/endpoints/mcp/_server.ts.js +7 -7
  124. package/forge/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  125. package/forge/server/entries/hooks.server.js +6 -1
  126. package/forge/server/entries/hooks.server.js.map +1 -1
  127. package/forge/server/entries/pages/_layout.svelte.js +80 -31
  128. package/forge/server/entries/pages/_layout.svelte.js.map +1 -1
  129. package/forge/server/entries/pages/overview/_page.svelte.js +2 -2
  130. package/forge/server/entries/pages/settings/__section__/_page.svelte.js +72 -15
  131. package/forge/server/entries/pages/settings/__section__/_page.svelte.js.map +1 -1
  132. package/forge/server/entries/pages/workspaces/_id_/_page.svelte.js +559 -158
  133. package/forge/server/entries/pages/workspaces/_id_/_page.svelte.js.map +1 -1
  134. package/forge/server/manifest-full.js +3 -3
  135. package/forge/server/manifest.js +3 -3
  136. package/forge/server/nodes/0.js +2 -2
  137. package/forge/server/nodes/1.js +1 -1
  138. package/forge/server/nodes/2.js +1 -1
  139. package/forge/server/nodes/3.js +1 -1
  140. package/forge/server/nodes/4.js +1 -1
  141. package/forge/server/nodes/5.js +1 -1
  142. package/forge/server/server.js +3 -3
  143. package/geordi.js +4 -1
  144. package/package.json +1 -1
  145. package/forge/client/_app/immutable/assets/0.CeOWqS-S.css +0 -2
  146. package/forge/client/_app/immutable/assets/0.CeOWqS-S.css.br +0 -0
  147. package/forge/client/_app/immutable/assets/0.CeOWqS-S.css.gz +0 -0
  148. package/forge/client/_app/immutable/chunks/4h5PLCfh.js.br +0 -0
  149. package/forge/client/_app/immutable/chunks/4h5PLCfh.js.gz +0 -0
  150. package/forge/client/_app/immutable/chunks/6t7TNajV.js +0 -158
  151. package/forge/client/_app/immutable/chunks/6t7TNajV.js.br +0 -0
  152. package/forge/client/_app/immutable/chunks/6t7TNajV.js.gz +0 -0
  153. package/forge/client/_app/immutable/chunks/BHzTxq5o.js +0 -1
  154. package/forge/client/_app/immutable/chunks/BHzTxq5o.js.br +0 -0
  155. package/forge/client/_app/immutable/chunks/BHzTxq5o.js.gz +0 -0
  156. package/forge/client/_app/immutable/chunks/BPUjZm07.js +0 -1
  157. package/forge/client/_app/immutable/chunks/BPUjZm07.js.br +0 -0
  158. package/forge/client/_app/immutable/chunks/BPUjZm07.js.gz +0 -0
  159. package/forge/client/_app/immutable/chunks/BSvEvqa6.js +0 -1
  160. package/forge/client/_app/immutable/chunks/BSvEvqa6.js.br +0 -2
  161. package/forge/client/_app/immutable/chunks/BSvEvqa6.js.gz +0 -0
  162. package/forge/client/_app/immutable/chunks/BwzaI1OF.js +0 -1
  163. package/forge/client/_app/immutable/chunks/BwzaI1OF.js.br +0 -0
  164. package/forge/client/_app/immutable/chunks/BwzaI1OF.js.gz +0 -0
  165. package/forge/client/_app/immutable/chunks/C7uVFhMO.js +0 -1
  166. package/forge/client/_app/immutable/chunks/C7uVFhMO.js.br +0 -0
  167. package/forge/client/_app/immutable/chunks/C7uVFhMO.js.gz +0 -0
  168. package/forge/client/_app/immutable/chunks/CCvT0cxn.js +0 -1
  169. package/forge/client/_app/immutable/chunks/CCvT0cxn.js.br +0 -0
  170. package/forge/client/_app/immutable/chunks/CCvT0cxn.js.gz +0 -0
  171. package/forge/client/_app/immutable/chunks/CP0U8Qtu.js.br +0 -0
  172. package/forge/client/_app/immutable/chunks/CP0U8Qtu.js.gz +0 -0
  173. package/forge/client/_app/immutable/chunks/CVVzDLmk.js +0 -1
  174. package/forge/client/_app/immutable/chunks/CVVzDLmk.js.br +0 -0
  175. package/forge/client/_app/immutable/chunks/CVVzDLmk.js.gz +0 -0
  176. package/forge/client/_app/immutable/chunks/CeAxe25K.js +0 -1
  177. package/forge/client/_app/immutable/chunks/CeAxe25K.js.br +0 -0
  178. package/forge/client/_app/immutable/chunks/CeAxe25K.js.gz +0 -0
  179. package/forge/client/_app/immutable/chunks/DFLpRvbz.js +0 -1
  180. package/forge/client/_app/immutable/chunks/DFLpRvbz.js.br +0 -0
  181. package/forge/client/_app/immutable/chunks/DFLpRvbz.js.gz +0 -0
  182. package/forge/client/_app/immutable/chunks/DYKv5n5o.js +0 -1
  183. package/forge/client/_app/immutable/chunks/DYKv5n5o.js.br +0 -0
  184. package/forge/client/_app/immutable/chunks/DYKv5n5o.js.gz +0 -0
  185. package/forge/client/_app/immutable/chunks/DdaUeSpb.js +0 -1
  186. package/forge/client/_app/immutable/chunks/DdaUeSpb.js.br +0 -1
  187. package/forge/client/_app/immutable/chunks/DdaUeSpb.js.gz +0 -0
  188. package/forge/client/_app/immutable/chunks/DeOqS6ly.js +0 -3
  189. package/forge/client/_app/immutable/chunks/DeOqS6ly.js.br +0 -0
  190. package/forge/client/_app/immutable/chunks/DeOqS6ly.js.gz +0 -0
  191. package/forge/client/_app/immutable/chunks/YP9ibVqW.js +0 -1
  192. package/forge/client/_app/immutable/chunks/YP9ibVqW.js.br +0 -0
  193. package/forge/client/_app/immutable/chunks/YP9ibVqW.js.gz +0 -0
  194. package/forge/client/_app/immutable/chunks/aBa3SWer.js.br +0 -0
  195. package/forge/client/_app/immutable/chunks/aBa3SWer.js.gz +0 -0
  196. package/forge/client/_app/immutable/chunks/zBSgLl7M.js +0 -3
  197. package/forge/client/_app/immutable/chunks/zBSgLl7M.js.br +0 -0
  198. package/forge/client/_app/immutable/chunks/zBSgLl7M.js.gz +0 -0
  199. package/forge/client/_app/immutable/entry/app.Bg7yCsGP.js +0 -2
  200. package/forge/client/_app/immutable/entry/app.Bg7yCsGP.js.br +0 -0
  201. package/forge/client/_app/immutable/entry/app.Bg7yCsGP.js.gz +0 -0
  202. package/forge/client/_app/immutable/entry/start.2j018bzK.js.br +0 -0
  203. package/forge/client/_app/immutable/entry/start.2j018bzK.js.gz +0 -0
  204. package/forge/client/_app/immutable/nodes/0.B9rqMzxb.js +0 -1
  205. package/forge/client/_app/immutable/nodes/0.B9rqMzxb.js.br +0 -0
  206. package/forge/client/_app/immutable/nodes/0.B9rqMzxb.js.gz +0 -0
  207. package/forge/client/_app/immutable/nodes/1.DwmerKk4.js +0 -1
  208. package/forge/client/_app/immutable/nodes/1.DwmerKk4.js.br +0 -2
  209. package/forge/client/_app/immutable/nodes/1.DwmerKk4.js.gz +0 -0
  210. package/forge/client/_app/immutable/nodes/2.BUk1YVIo.js +0 -1
  211. package/forge/client/_app/immutable/nodes/2.BUk1YVIo.js.br +0 -0
  212. package/forge/client/_app/immutable/nodes/2.BUk1YVIo.js.gz +0 -0
  213. package/forge/client/_app/immutable/nodes/3.DmPRvAdZ.js +0 -1
  214. package/forge/client/_app/immutable/nodes/3.DmPRvAdZ.js.br +0 -0
  215. package/forge/client/_app/immutable/nodes/3.DmPRvAdZ.js.gz +0 -0
  216. package/forge/client/_app/immutable/nodes/4.uaGnBjju.js +0 -6
  217. package/forge/client/_app/immutable/nodes/4.uaGnBjju.js.br +0 -0
  218. package/forge/client/_app/immutable/nodes/4.uaGnBjju.js.gz +0 -0
  219. package/forge/client/_app/immutable/nodes/5.DPP-3Nng.js +0 -31
  220. package/forge/client/_app/immutable/nodes/5.DPP-3Nng.js.br +0 -0
  221. package/forge/client/_app/immutable/nodes/5.DPP-3Nng.js.gz +0 -0
  222. package/forge/server/_app/immutable/assets/_layout.CeOWqS-S.css +0 -2
  223. package/forge/server/chunks/afar.svelte.js.map +0 -1
package/daemon/main.js CHANGED
@@ -95,7 +95,7 @@ var init_src = __esm({
95
95
  "../../packages/protocol/src/index.ts"() {
96
96
  "use strict";
97
97
  init_images();
98
- PROTOCOL_VERSION = 33;
98
+ PROTOCOL_VERSION = 35;
99
99
  AGENTS = ["claude", "codex"];
100
100
  SETTING = /^[A-Za-z0-9][\w.:[\]-]{0,79}$/;
101
101
  NO_WORKTREE = "This workspace has no worktree";
@@ -169,7 +169,7 @@ __export(codex_exports, {
169
169
  });
170
170
  import { readFileSync as readFileSync4 } from "node:fs";
171
171
  import { homedir as homedir2 } from "node:os";
172
- import { join as join4 } from "node:path";
172
+ import { join as join6 } from "node:path";
173
173
  function modelsIn(cache2) {
174
174
  try {
175
175
  const { models } = JSON.parse(cache2);
@@ -191,8 +191,8 @@ var init_codex = __esm({
191
191
  offers() {
192
192
  let cache2 = "";
193
193
  try {
194
- const home = process.env.CODEX_HOME || join4(homedir2(), ".codex");
195
- cache2 = readFileSync4(join4(home, "models_cache.json"), "utf8");
194
+ const home = process.env.CODEX_HOME || join6(homedir2(), ".codex");
195
+ cache2 = readFileSync4(join6(home, "models_cache.json"), "utf8");
196
196
  } catch {
197
197
  }
198
198
  const models = modelsIn(cache2);
@@ -7702,14 +7702,14 @@ function isNamespaceRef(ref) {
7702
7702
  }
7703
7703
  function repoKey(repo) {
7704
7704
  if (repo.externalId) return `${repo.forge}:${repo.instance}/@${isNamespaceRef(repo) ? "namespace:" : ""}${repo.externalId}`;
7705
- const { owner, name } = normaliseRepoName(repo);
7706
- return isNamespaceRef(repo) ? `${repo.forge}:${repo.instance}/${owner}/` : `${repo.forge}:${repo.instance}/${owner}/${name}`;
7705
+ const { owner: owner2, name } = normaliseRepoName(repo);
7706
+ return isNamespaceRef(repo) ? `${repo.forge}:${repo.instance}/${owner2}/` : `${repo.forge}:${repo.instance}/${owner2}/${name}`;
7707
7707
  }
7708
- function namespaceRef(origin, owner) {
7708
+ function namespaceRef(origin, owner2) {
7709
7709
  return {
7710
7710
  forge: origin.forge,
7711
7711
  instance: origin.instance,
7712
- owner,
7712
+ owner: owner2,
7713
7713
  name: "",
7714
7714
  kind: "namespace"
7715
7715
  };
@@ -8377,7 +8377,7 @@ function toDate(value) {
8377
8377
  const date2 = new Date(value);
8378
8378
  return Number.isNaN(date2.getTime()) ? void 0 : date2;
8379
8379
  }
8380
- function hostOf(baseUrl) {
8380
+ function hostOf2(baseUrl) {
8381
8381
  return new URL(baseUrl).host;
8382
8382
  }
8383
8383
  function teamOrg(ref) {
@@ -8815,11 +8815,11 @@ function referenceFor(web, ref, options = {}) {
8815
8815
  }
8816
8816
  function repoIn(slug, from, origin) {
8817
8817
  const at = slug.lastIndexOf("/");
8818
- const owner = slug.slice(0, at);
8818
+ const owner2 = slug.slice(0, at);
8819
8819
  const name = slug.slice(at + 1);
8820
- return name === from.name && (owner === from.owner || owner === from.ownerHandle) ? from : {
8820
+ return name === from.name && (owner2 === from.owner || owner2 === from.ownerHandle) ? from : {
8821
8821
  ...origin,
8822
- owner,
8822
+ owner: owner2,
8823
8823
  name
8824
8824
  };
8825
8825
  }
@@ -8936,11 +8936,11 @@ function githubShapedWeb(baseUrl, shape) {
8936
8936
  raw: (repo, path, at) => shape.raw === false ? void 0 : shape.rawOrigin ? `${shape.rawOrigin}${repoPath6(repo)}/${encodeURIComponent(at)}/${encodePath(path)}` : `${repoPath6(repo)}/raw/${encodeURIComponent(at)}/${encodePath(path)}`,
8937
8937
  compare: (repo, base, head) => `${repoPath6(repo)}/compare/${encodeURIComponent(base)}...${encodeURIComponent(head)}`,
8938
8938
  parse: (segments, url, from) => {
8939
- const [owner, name, section, id] = segments;
8940
- if (!owner || !name || reserved.has(owner.toLowerCase())) return;
8939
+ const [owner2, name, section, id] = segments;
8940
+ if (!owner2 || !name || reserved.has(owner2.toLowerCase())) return;
8941
8941
  const repo = {
8942
8942
  ...from,
8943
- owner,
8943
+ owner: owner2,
8944
8944
  name: name.replace(/\.git$/, "")
8945
8945
  };
8946
8946
  const file = parseFile(segments.slice(2));
@@ -9423,7 +9423,7 @@ function createProvider(definition, givenOptions, givenState) {
9423
9423
  ...definition.headers,
9424
9424
  ...userAgent ? { "user-agent": userAgent } : {}
9425
9425
  };
9426
- const prepared = {
9426
+ const prepared2 = {
9427
9427
  options,
9428
9428
  forge: definition.forge,
9429
9429
  instance,
@@ -9432,9 +9432,9 @@ function createProvider(definition, givenOptions, givenState) {
9432
9432
  origin,
9433
9433
  state: givenState
9434
9434
  };
9435
- const state = definition.prepare ? definition.prepare(prepared) : givenState;
9435
+ const state = definition.prepare ? definition.prepare(prepared2) : givenState;
9436
9436
  const base = {
9437
- ...prepared,
9437
+ ...prepared2,
9438
9438
  state
9439
9439
  };
9440
9440
  const budgets = /* @__PURE__ */ new Map();
@@ -9581,8 +9581,8 @@ function createProvider(definition, givenOptions, givenState) {
9581
9581
  warnings: [...warnings, ...page2.warnings ?? []]
9582
9582
  };
9583
9583
  },
9584
- "repos.byOwnerPage": (owner, query = {}) => nonEmptyPage(async (cursor) => {
9585
- const page2 = await listOwnerRepos(owner, {
9584
+ "repos.byOwnerPage": (owner2, query = {}) => nonEmptyPage(async (cursor) => {
9585
+ const page2 = await listOwnerRepos(owner2, {
9586
9586
  ...query,
9587
9587
  cursor
9588
9588
  });
@@ -10447,9 +10447,9 @@ function azureWeb(baseUrl) {
10447
10447
  parse: (segments, url, from) => {
10448
10448
  const [org, project, section, ...rest] = segments;
10449
10449
  if (!org || !project) return;
10450
- const owner = `${org}/${project}`;
10450
+ const owner2 = `${org}/${project}`;
10451
10451
  if (section === "_workitems" && rest[0] === "edit" && rest[1]) {
10452
- const repo2 = namespaceRef(from, owner);
10452
+ const repo2 = namespaceRef(from, owner2);
10453
10453
  return {
10454
10454
  repo: repo2,
10455
10455
  thread: {
@@ -10460,10 +10460,10 @@ function azureWeb(baseUrl) {
10460
10460
  }
10461
10461
  };
10462
10462
  }
10463
- if (section !== "_git" || !rest[0]) return { repo: namespaceRef(from, owner) };
10463
+ if (section !== "_git" || !rest[0]) return { repo: namespaceRef(from, owner2) };
10464
10464
  const repo = {
10465
10465
  ...from,
10466
- owner,
10466
+ owner: owner2,
10467
10467
  name: rest[0]
10468
10468
  };
10469
10469
  const path = url.searchParams.get("path")?.replace(/^\//, "");
@@ -11633,10 +11633,10 @@ function setupAzure({ options, instance, origin: context, fetcher, baseUrl }) {
11633
11633
  ...rateLimitPart(response)
11634
11634
  };
11635
11635
  }),
11636
- byOwnerPage: verb(true, async (owner, query = {}) => {
11637
- const { data, response } = await fetcher.json(`${projectPath3(owner)}/git/repositories`, { signal: query.signal });
11636
+ byOwnerPage: verb(true, async (owner2, query = {}) => {
11637
+ const { data, response } = await fetcher.json(`${projectPath3(owner2)}/git/repositories`, { signal: query.signal });
11638
11638
  return {
11639
- items: data.value.map((raw) => toRepo(instance, scope(owner).org, raw)),
11639
+ items: data.value.map((raw) => toRepo(instance, scope(owner2).org, raw)),
11640
11640
  ...rateLimitPart(response),
11641
11641
  ...query.sort ? { warnings: [{
11642
11642
  code: "sort_unsupported",
@@ -12178,11 +12178,11 @@ function bitbucketWeb(baseUrl) {
12178
12178
  raw: (repo, path, at) => `${repoPath(repo)}/raw/${encodeURIComponent(at)}/${path.split("/").map(encodeURIComponent).join("/")}`,
12179
12179
  compare: (repo, base, head) => `${repoPath(repo)}/branches/compare/${encodeURIComponent(head)}%0D${encodeURIComponent(base)}`,
12180
12180
  parse: (segments, url, from) => {
12181
- const [owner, name, section, id] = segments;
12182
- if (!owner || !name) return;
12181
+ const [owner2, name, section, id] = segments;
12182
+ if (!owner2 || !name) return;
12183
12183
  const repo = {
12184
12184
  ...from,
12185
- owner,
12185
+ owner: owner2,
12186
12186
  name: name.replace(/\.git$/, "")
12187
12187
  };
12188
12188
  if (section === "src" && id && segments[4]) return {
@@ -13303,7 +13303,7 @@ var init_bitbucket_BSHJYffE = __esm({
13303
13303
  select: page
13304
13304
  }) : memberRepos(query, extras);
13305
13305
  }
13306
- async function ownerReposPage(owner, query = {}) {
13306
+ async function ownerReposPage(owner2, query = {}) {
13307
13307
  if (query.visibility === "internal") return {
13308
13308
  items: [],
13309
13309
  warnings: [{
@@ -13312,7 +13312,7 @@ var init_bitbucket_BSHJYffE = __esm({
13312
13312
  }]
13313
13313
  };
13314
13314
  const field2 = query.sort === "created" ? "created_on" : query.sort === "name" ? "name" : query.sort && "updated_on";
13315
- return list(`/repositories/${encodeURIComponent(owner.owner)}`, query, (raw) => toRepo2(instance, raw), {
13315
+ return list(`/repositories/${encodeURIComponent(owner2.owner)}`, query, (raw) => toRepo2(instance, raw), {
13316
13316
  query: {
13317
13317
  q: query.visibility === "public" || query.visibility === "private" ? `is_private = ${query.visibility === "private"}` : void 0,
13318
13318
  sort: field2 && `${(query.direction ?? (field2 === "name" ? "asc" : "desc")) === "desc" ? "-" : ""}${field2}`
@@ -15386,10 +15386,10 @@ function toActor4(origin, user) {
15386
15386
  };
15387
15387
  }
15388
15388
  function toRepoRef6(origin, repo) {
15389
- const [owner, name] = repo.full_name.split("/");
15389
+ const [owner2, name] = repo.full_name.split("/");
15390
15390
  return {
15391
15391
  ...origin,
15392
- owner: repo.owner?.login ?? owner ?? "",
15392
+ owner: repo.owner?.login ?? owner2 ?? "",
15393
15393
  name: repo.name ?? name ?? "",
15394
15394
  externalId: repo.id === void 0 ? void 0 : String(repo.id)
15395
15395
  };
@@ -15682,11 +15682,11 @@ function summarise(entry, kind, actor) {
15682
15682
  function crossReference(thread, entry) {
15683
15683
  const source = entry.ref_issue;
15684
15684
  if (!source) return { type: "referenced" };
15685
- const [owner = "", name = ""] = source.repository?.full_name.split("/") ?? [];
15685
+ const [owner2 = "", name = ""] = source.repository?.full_name.split("/") ?? [];
15686
15686
  const repo = name ? {
15687
15687
  forge: thread.forge,
15688
15688
  instance: thread.instance,
15689
- owner,
15689
+ owner: owner2,
15690
15690
  name,
15691
15691
  externalId: source.repository?.id === void 0 ? void 0 : String(source.repository.id)
15692
15692
  } : thread.repo;
@@ -16201,8 +16201,8 @@ function setupForgejo({ options, origin, fetcher: baseFetcher, baseUrl }, profil
16201
16201
  const anonymous = options.auth?.type === "anonymous";
16202
16202
  const fetcher = countedPages(baseFetcher);
16203
16203
  const list = createListing(fetcher, "limit");
16204
- function ownerReposPage(owner, query = {}) {
16205
- return list(`/users/${encodeURIComponent(owner.owner)}/repos`, query, (raw) => toRepo6(origin, raw), { warnings: isFirstPage(query.cursor) && ((query.sort ?? "created") !== "created" || query.direction === "desc") ? [{
16204
+ function ownerReposPage(owner2, query = {}) {
16205
+ return list(`/users/${encodeURIComponent(owner2.owner)}/repos`, query, (raw) => toRepo6(origin, raw), { warnings: isFirstPage(query.cursor) && ((query.sort ?? "created") !== "created" || query.direction === "desc") ? [{
16206
16206
  code: "sort_unsupported",
16207
16207
  message: `${profile.forge} lists the repositories of an owner oldest first only`
16208
16208
  }] : void 0 });
@@ -16309,9 +16309,9 @@ function setupForgejo({ options, origin, fetcher: baseFetcher, baseUrl }, profil
16309
16309
  for await (const label of fetcher.items(path, { query: { limit: 50 } })) map.set(label.name, label.id);
16310
16310
  return map;
16311
16311
  });
16312
- const orgLabelIdsOf = memoBy(async (owner) => {
16312
+ const orgLabelIdsOf = memoBy(async (owner2) => {
16313
16313
  try {
16314
- return await labelIdsOf(`/orgs/${encodeURIComponent(owner)}/labels`);
16314
+ return await labelIdsOf(`/orgs/${encodeURIComponent(owner2)}/labels`);
16315
16315
  } catch (error) {
16316
16316
  if (error instanceof NotFoundError) return /* @__PURE__ */ new Map();
16317
16317
  throw error;
@@ -16362,9 +16362,9 @@ function setupForgejo({ options, origin, fetcher: baseFetcher, baseUrl }, profil
16362
16362
  const { data } = await fetcher.json(`/notifications/threads/${encodeURIComponent(ref.id)}`, { signal });
16363
16363
  const number = numberFromUrl(data.subject.url);
16364
16364
  if (!number || !toThreadKind(data.subject.type)) throw new UnsupportedOperationError("Only issue and pull request threads can be unsubscribed from", context);
16365
- const [owner = "", name = ""] = data.repository.full_name.split("/");
16365
+ const [owner2 = "", name = ""] = data.repository.full_name.split("/");
16366
16366
  return {
16367
- owner,
16367
+ owner: owner2,
16368
16368
  name,
16369
16369
  number
16370
16370
  };
@@ -16587,10 +16587,10 @@ function setupForgejo({ options, origin, fetcher: baseFetcher, baseUrl }, profil
16587
16587
  signal: query.signal
16588
16588
  });
16589
16589
  return toPage(result, (raw) => {
16590
- const [owner = "", name = ""] = raw.repository?.full_name.split("/") ?? [];
16590
+ const [owner2 = "", name = ""] = raw.repository?.full_name.split("/") ?? [];
16591
16591
  const repo = query.repo ?? (name ? {
16592
16592
  ...origin,
16593
- owner,
16593
+ owner: owner2,
16594
16594
  name,
16595
16595
  externalId: raw.repository?.id === void 0 ? void 0 : String(raw.repository.id)
16596
16596
  } : void 0);
@@ -16605,7 +16605,7 @@ function setupForgejo({ options, origin, fetcher: baseFetcher, baseUrl }, profil
16605
16605
  }
16606
16606
  const isGitea = profile.forge === "gitea";
16607
16607
  function released(minimum) {
16608
- return hostOf(baseUrl) === hostOf(profile.web.baseUrl) ? true : ({ version: version2 }) => versionAtLeast(version2, minimum);
16608
+ return hostOf2(baseUrl) === hostOf2(profile.web.baseUrl) ? true : ({ version: version2 }) => versionAtLeast(version2, minimum);
16609
16609
  }
16610
16610
  function actions(forgejoMinimum, giteaMinimum) {
16611
16611
  return released(isGitea ? giteaMinimum : forgejoMinimum);
@@ -18549,11 +18549,11 @@ function commitOf(payload, thread, repo, origin) {
18549
18549
  }
18550
18550
  function headRepo(origin, repo) {
18551
18551
  if (repo?.full_name) return toRepoRef7(origin, repo);
18552
- const [, owner, name] = repo?.url?.match(/\/repos\/([^/]+)\/([^/]+)$/) ?? [];
18553
- return owner && name ? {
18552
+ const [, owner2, name] = repo?.url?.match(/\/repos\/([^/]+)\/([^/]+)$/) ?? [];
18553
+ return owner2 && name ? {
18554
18554
  forge: origin.forge,
18555
18555
  instance: origin.instance,
18556
- owner,
18556
+ owner: owner2,
18557
18557
  name,
18558
18558
  externalId: repo?.id === void 0 ? void 0 : String(repo.id)
18559
18559
  } : void 0;
@@ -18820,11 +18820,11 @@ function toFeedEvents(origin, raw) {
18820
18820
  function toFeedEvent2(origin, raw) {
18821
18821
  const type = raw.type ?? "Event";
18822
18822
  const payload = raw.payload ?? {};
18823
- const [owner = "", name = ""] = raw.repo?.name.split("/") ?? [];
18823
+ const [owner2 = "", name = ""] = raw.repo?.name.split("/") ?? [];
18824
18824
  const repo = raw.repo ? {
18825
18825
  forge: origin.forge,
18826
18826
  instance: origin.instance,
18827
- owner,
18827
+ owner: owner2,
18828
18828
  name,
18829
18829
  externalId: String(raw.repo.id)
18830
18830
  } : void 0;
@@ -18923,10 +18923,10 @@ async function readTemplates(repo, kinds, reader) {
18923
18923
  async function rootOf(repo, reader) {
18924
18924
  try {
18925
18925
  const entries = await reader.list(repo, "");
18926
- const owner = entries.map((entry) => entry.url && CONTENTS_OWNER.exec(new URL(entry.url).pathname)?.[1]).find(Boolean);
18926
+ const owner2 = entries.map((entry) => entry.url && CONTENTS_OWNER.exec(new URL(entry.url).pathname)?.[1]).find(Boolean);
18927
18927
  return {
18928
18928
  entries,
18929
- owner: owner ? decodeURIComponent(owner) : repo.owner
18929
+ owner: owner2 ? decodeURIComponent(owner2) : repo.owner
18930
18930
  };
18931
18931
  } catch (error) {
18932
18932
  if (!(error instanceof NotFoundError)) throw error;
@@ -19196,21 +19196,21 @@ function toUser(origin, user) {
19196
19196
  };
19197
19197
  }
19198
19198
  function toRepoRef7(origin, repo) {
19199
- const [owner, name] = repo.full_name.split("/");
19199
+ const [owner2, name] = repo.full_name.split("/");
19200
19200
  return {
19201
19201
  forge: origin.forge,
19202
19202
  instance: origin.instance,
19203
- owner: repo.owner?.login ?? owner ?? "",
19203
+ owner: repo.owner?.login ?? owner2 ?? "",
19204
19204
  name: repo.name ?? name ?? "",
19205
19205
  externalId: repo.id === void 0 ? void 0 : String(repo.id)
19206
19206
  };
19207
19207
  }
19208
19208
  function repoRefFromApiUrl(origin, url) {
19209
- const [, owner, name] = url?.match(/\/repos\/([^/]+)\/([^/]+)$/) ?? [];
19210
- return owner && name ? {
19209
+ const [, owner2, name] = url?.match(/\/repos\/([^/]+)\/([^/]+)$/) ?? [];
19210
+ return owner2 && name ? {
19211
19211
  forge: origin.forge,
19212
19212
  instance: origin.instance,
19213
- owner,
19213
+ owner: owner2,
19214
19214
  name
19215
19215
  } : void 0;
19216
19216
  }
@@ -20283,7 +20283,7 @@ function setupGitHub(ctx, profile) {
20283
20283
  const tokenKind = auth.type === "token" ? tokenKindOf(auth) : void 0;
20284
20284
  const installation = auth.type === "app" || tokenKind === "installation";
20285
20285
  const notificationsAuth = auth.type === "token" && (tokenKind === void 0 || tokenKind === "classic");
20286
- const host = hostOf(baseUrl);
20286
+ const host = hostOf2(baseUrl);
20287
20287
  const enterprise = host !== "api.github.com" && !isGheCom(host);
20288
20288
  const graphql = createGraphQLClient(fetcher, graphqlUrl(baseUrl), context);
20289
20289
  async function resolveDiscussionNumbers(items) {
@@ -20545,8 +20545,8 @@ function setupGitHub(ctx, profile) {
20545
20545
  };
20546
20546
  return;
20547
20547
  }
20548
- const owner = data.data?.[`u${offset}`];
20549
- if (!owner) {
20548
+ const owner2 = data.data?.[`u${offset}`];
20549
+ if (!owner2) {
20550
20550
  const error = data.errors?.find((error2) => error2.path?.[0] === `u${offset}`);
20551
20551
  if (error && error.type !== "NOT_FOUND") {
20552
20552
  const code = error.type === "INSUFFICIENT_SCOPES" ? "insufficient_scope" : "account_unreadable";
@@ -20571,7 +20571,7 @@ function setupGitHub(ctx, profile) {
20571
20571
  results[index] = {
20572
20572
  ok: true,
20573
20573
  login,
20574
- sponsorable: owner.hasSponsorsListing
20574
+ sponsorable: owner2.hasSponsorsListing
20575
20575
  };
20576
20576
  });
20577
20577
  }
@@ -21133,21 +21133,21 @@ function setupGitHub(ctx, profile) {
21133
21133
  }), (raw) => toRepo7(context, raw));
21134
21134
  }
21135
21135
  const viewerLogin = memo(async () => (await fetcher.json("/user")).data.login);
21136
- async function ownerReposPage(owner, query = {}) {
21136
+ async function ownerReposPage(owner2, query = {}) {
21137
21137
  const visibility = query.visibility === "all" ? void 0 : query.visibility;
21138
21138
  const read4 = (path, params) => list(path, query, (raw) => toRepo7(context, raw), { query: {
21139
21139
  ...params,
21140
21140
  sort: query.sort === "name" ? "full_name" : query.sort,
21141
21141
  direction: query.direction
21142
21142
  } });
21143
- const userRepos = () => read4(`/users/${encodeURIComponent(owner.owner)}/repos`, { type: "owner" });
21143
+ const userRepos = () => read4(`/users/${encodeURIComponent(owner2.owner)}/repos`, { type: "owner" });
21144
21144
  if (visibility === "public") return userRepos();
21145
21145
  try {
21146
- return await read4(`/orgs/${encodeURIComponent(owner.owner)}/repos`, { type: visibility === "internal" ? void 0 : visibility });
21146
+ return await read4(`/orgs/${encodeURIComponent(owner2.owner)}/repos`, { type: visibility === "internal" ? void 0 : visibility });
21147
21147
  } catch (error) {
21148
21148
  if (!(error instanceof NotFoundError) || !isFirstPage(query.cursor)) throw error;
21149
21149
  }
21150
- if (auth.type === "token" && !installation && (await viewerLogin()).toLowerCase() === owner.owner.toLowerCase()) return read4("/user/repos", {
21150
+ if (auth.type === "token" && !installation && (await viewerLogin()).toLowerCase() === owner2.owner.toLowerCase()) return read4("/user/repos", {
21151
21151
  affiliation: "owner",
21152
21152
  visibility: visibility === "internal" ? void 0 : visibility
21153
21153
  });
@@ -23507,11 +23507,11 @@ function toActor6(instance, user) {
23507
23507
  };
23508
23508
  }
23509
23509
  function toRepoRef8(instance, repo) {
23510
- const [owner = repo.namespace?.path ?? "", name = repo.path] = repo.full_name.split("/");
23510
+ const [owner2 = repo.namespace?.path ?? "", name = repo.path] = repo.full_name.split("/");
23511
23511
  return {
23512
23512
  forge: FORGE6,
23513
23513
  instance,
23514
- owner,
23514
+ owner: owner2,
23515
23515
  name,
23516
23516
  externalId: String(repo.id)
23517
23517
  };
@@ -23988,7 +23988,7 @@ function setupGitee({ options, instance, origin: context, fetcher, baseUrl }) {
23988
23988
  function all(path, options2 = {}) {
23989
23989
  return Array.fromAsync(iteratePages((page2) => numberedPage(path, {}, page2), { signal: options2.signal }));
23990
23990
  }
23991
- async function ownerReposPage(owner, query = {}) {
23991
+ async function ownerReposPage(owner2, query = {}) {
23992
23992
  const visibility = query.visibility === "all" ? void 0 : query.visibility;
23993
23993
  const read4 = async (path, params, warnings) => {
23994
23994
  const page2 = await numberedPage(path, params, query);
@@ -23999,14 +23999,14 @@ function setupGitee({ options, instance, origin: context, fetcher, baseUrl }) {
23999
23999
  };
24000
24000
  };
24001
24001
  try {
24002
- return await read4(`/orgs/${encodeURIComponent(owner.owner)}/repos`, { type: visibility === "public" || visibility === "private" ? visibility : "all" }, query.sort && isFirstPage(query.cursor) ? [{
24002
+ return await read4(`/orgs/${encodeURIComponent(owner2.owner)}/repos`, { type: visibility === "public" || visibility === "private" ? visibility : "all" }, query.sort && isFirstPage(query.cursor) ? [{
24003
24003
  code: "sort_unsupported",
24004
24004
  message: "Gitee cannot sort the repositories of an organisation"
24005
24005
  }] : void 0);
24006
24006
  } catch (error) {
24007
24007
  if (!(error instanceof NotFoundError) || !isFirstPage(query.cursor)) throw error;
24008
24008
  }
24009
- return read4(`/users/${encodeURIComponent(owner.owner)}/repos`, {
24009
+ return read4(`/users/${encodeURIComponent(owner2.owner)}/repos`, {
24010
24010
  type: "personal",
24011
24011
  sort: query.sort === "name" ? "full_name" : query.sort,
24012
24012
  direction: query.direction
@@ -26719,7 +26719,7 @@ var init_gitlab_C5sgwnfW = __esm({
26719
26719
  });
26720
26720
  return toCommit9(repo, data);
26721
26721
  }
26722
- async function ownerReposPage(owner, query = {}) {
26722
+ async function ownerReposPage(owner2, query = {}) {
26723
26723
  const read4 = (path, extra) => list(path, query, (raw) => toRepo9(instance, raw), {
26724
26724
  query: {
26725
26725
  visibility: query.visibility === "all" ? void 0 : query.visibility,
@@ -26733,14 +26733,14 @@ var init_gitlab_C5sgwnfW = __esm({
26733
26733
  }] : void 0
26734
26734
  });
26735
26735
  try {
26736
- return await read4(`/groups/${encodeURIComponent(owner.externalId ?? owner.owner)}/projects`, {
26736
+ return await read4(`/groups/${encodeURIComponent(owner2.externalId ?? owner2.owner)}/projects`, {
26737
26737
  include_subgroups: query.subgroups || void 0,
26738
26738
  with_shared: false
26739
26739
  });
26740
26740
  } catch (error) {
26741
- if (!(error instanceof NotFoundError) || !isFirstPage(query.cursor) || !owner.owner || owner.owner.includes("/")) throw error;
26741
+ if (!(error instanceof NotFoundError) || !isFirstPage(query.cursor) || !owner2.owner || owner2.owner.includes("/")) throw error;
26742
26742
  }
26743
- return read4(`/users/${encodeURIComponent(owner.owner)}/projects`, {});
26743
+ return read4(`/users/${encodeURIComponent(owner2.owner)}/projects`, {});
26744
26744
  }
26745
26745
  function hooksPath(target) {
26746
26746
  return isNamespaceRef(target) ? `/groups/${encodeURIComponent(target.externalId ?? target.owner)}/hooks` : `${projectPath3(target)}/hooks`;
@@ -27989,11 +27989,11 @@ function sourcehutWeb(instance) {
27989
27989
  release: (ref) => ref.tag ? `${repoPath4(ref.repo)}/tree/${encodeURIComponent(ref.tag)}` : void 0,
27990
27990
  parse: (segments, url, from) => {
27991
27991
  if (url.host === todoHost) {
27992
- const [owner2, name2, id] = segments;
27993
- if (!owner2?.startsWith("~") || !name2) return;
27992
+ const [owner3, name2, id] = segments;
27993
+ if (!owner3?.startsWith("~") || !name2) return;
27994
27994
  const repo2 = {
27995
27995
  ...from,
27996
- owner: owner2,
27996
+ owner: owner3,
27997
27997
  name: name2
27998
27998
  };
27999
27999
  return id && /^\d+$/.test(id) ? {
@@ -28008,11 +28008,11 @@ function sourcehutWeb(instance) {
28008
28008
  } : { repo: repo2 };
28009
28009
  }
28010
28010
  if (url.host === listsHost) {
28011
- const [owner2, name2, marker2, id] = segments;
28012
- if (!owner2?.startsWith("~") || !name2) return;
28011
+ const [owner3, name2, marker2, id] = segments;
28012
+ if (!owner3?.startsWith("~") || !name2) return;
28013
28013
  const repo2 = {
28014
28014
  ...from,
28015
- owner: owner2,
28015
+ owner: owner3,
28016
28016
  name: name2
28017
28017
  };
28018
28018
  return marker2 === "patches" && id && /^\d+$/.test(id) ? {
@@ -28026,11 +28026,11 @@ function sourcehutWeb(instance) {
28026
28026
  }
28027
28027
  } : { repo: repo2 };
28028
28028
  }
28029
- const [owner, name, section, at, marker] = segments;
28030
- if (!owner?.startsWith("~") || !name) return;
28029
+ const [owner2, name, section, at, marker] = segments;
28030
+ if (!owner2?.startsWith("~") || !name) return;
28031
28031
  const repo = {
28032
28032
  ...from,
28033
- owner,
28033
+ owner: owner2,
28034
28034
  name: name.replace(/\.git$/, "")
28035
28035
  };
28036
28036
  if (section === "tree" && at && marker === "item" && segments[5]) return {
@@ -28213,8 +28213,8 @@ function createSourcehutClient(fetcher, service, url, context) {
28213
28213
  function loginOf(entity) {
28214
28214
  return entity.canonicalName || entity.username || entity.email || String(entity.id);
28215
28215
  }
28216
- function usernameOf(owner) {
28217
- return owner.replace(/^~/, "");
28216
+ function usernameOf(owner2) {
28217
+ return owner2.replace(/^~/, "");
28218
28218
  }
28219
28219
  function toActor9(origin, entity) {
28220
28220
  const login = loginOf(entity);
@@ -28243,17 +28243,17 @@ function toVisibility(raw) {
28243
28243
  function branchOf2(name) {
28244
28244
  return name?.replace(/^refs\/heads\//, "") || void 0;
28245
28245
  }
28246
- function repoRefOf(origin, owner, name) {
28246
+ function repoRefOf(origin, owner2, name) {
28247
28247
  return {
28248
28248
  ...origin,
28249
- owner,
28249
+ owner: owner2,
28250
28250
  name
28251
28251
  };
28252
28252
  }
28253
28253
  function toRepo11(origin, repository) {
28254
- const owner = repository.owner.canonicalName;
28254
+ const owner2 = repository.owner.canonicalName;
28255
28255
  return {
28256
- ref: repoRefOf(origin, owner, repository.name),
28256
+ ref: repoRefOf(origin, owner2, repository.name),
28257
28257
  description: repository.description ?? void 0,
28258
28258
  defaultBranch: branchOf2(repository.HEAD?.name),
28259
28259
  visibility: toVisibility(repository.visibility),
@@ -28261,7 +28261,7 @@ function toRepo11(origin, repository) {
28261
28261
  isFork: false,
28262
28262
  isArchived: false,
28263
28263
  topics: [],
28264
- url: `${serviceUrl(origin.instance, "git")}/${owner}/${repository.name}`,
28264
+ url: `${serviceUrl(origin.instance, "git")}/${owner2}/${repository.name}`,
28265
28265
  createdAt: toDate(repository.created),
28266
28266
  updatedAt: toDate(repository.updated),
28267
28267
  owner: toActor9(origin, repository.owner),
@@ -28290,8 +28290,8 @@ function ticketStateReason(resolution) {
28290
28290
  }
28291
28291
  }
28292
28292
  function toTicketThread(origin, ticket) {
28293
- const owner = ticket.tracker.owner.canonicalName;
28294
- const repo = repoRefOf(origin, owner, ticket.tracker.name);
28293
+ const owner2 = ticket.tracker.owner.canonicalName;
28294
+ const repo = repoRefOf(origin, owner2, ticket.tracker.name);
28295
28295
  return {
28296
28296
  ref: {
28297
28297
  ...origin,
@@ -28311,7 +28311,7 @@ function toTicketThread(origin, ticket) {
28311
28311
  assignees: ticket.assignees.map((assignee) => toActor9(origin, assignee)),
28312
28312
  reviewers: [],
28313
28313
  labels: ticket.labels.map(toLabel7),
28314
- url: `${serviceUrl(origin.instance, "todo")}/${owner}/${ticket.tracker.name}/${ticket.id}`,
28314
+ url: `${serviceUrl(origin.instance, "todo")}/${owner2}/${ticket.tracker.name}/${ticket.id}`,
28315
28315
  createdAt: toDate(ticket.created),
28316
28316
  updatedAt: toDate(ticket.updated),
28317
28317
  lastActivityAt: toDate(ticket.updated),
@@ -28325,8 +28325,8 @@ function patchsetState(status2) {
28325
28325
  }
28326
28326
  function toPatchsetThread(origin, patchset) {
28327
28327
  const list = patchset.list;
28328
- const owner = list.owner.canonicalName;
28329
- const repo = repoRefOf(origin, owner, list.name);
28328
+ const owner2 = list.owner.canonicalName;
28329
+ const repo = repoRefOf(origin, owner2, list.name);
28330
28330
  return {
28331
28331
  ref: {
28332
28332
  ...origin,
@@ -28346,14 +28346,14 @@ function toPatchsetThread(origin, patchset) {
28346
28346
  assignees: [],
28347
28347
  reviewers: [],
28348
28348
  labels: [],
28349
- url: `${serviceUrl(origin.instance, "lists")}/${owner}/${list.name}/patches/${patchset.id}`,
28349
+ url: `${serviceUrl(origin.instance, "lists")}/${owner2}/${list.name}/patches/${patchset.id}`,
28350
28350
  createdAt: toDate(patchset.created),
28351
28351
  updatedAt: toDate(patchset.updated),
28352
28352
  raw: patchset
28353
28353
  };
28354
28354
  }
28355
28355
  function toEmailComment(thread, email) {
28356
- const { owner, name } = thread.repo;
28356
+ const { owner: owner2, name } = thread.repo;
28357
28357
  return {
28358
28358
  ref: {
28359
28359
  forge: thread.forge,
@@ -28367,7 +28367,7 @@ function toEmailComment(thread, email) {
28367
28367
  instance: thread.instance
28368
28368
  }, email.sender),
28369
28369
  createdAt: toDate(email.received),
28370
- url: `${serviceUrl(thread.instance, "lists")}/${owner}/${name}/${encodeURIComponent(`<${email.messageID}>`)}`,
28370
+ url: `${serviceUrl(thread.instance, "lists")}/${owner2}/${name}/${encodeURIComponent(`<${email.messageID}>`)}`,
28371
28371
  raw: email
28372
28372
  };
28373
28373
  }
@@ -28732,7 +28732,7 @@ function numericId(value, what, context) {
28732
28732
  if (!Number.isInteger(parsed) || parsed < 0) throw new NotFoundError(`Sourcehut has no ${what} ${value || "with that id"}`, 404, "", context);
28733
28733
  return parsed;
28734
28734
  }
28735
- function hostOf2(path) {
28735
+ function hostOf3(path) {
28736
28736
  try {
28737
28737
  return new URL(path).host;
28738
28738
  } catch {
@@ -28782,8 +28782,8 @@ function setupSourcehut(ctx) {
28782
28782
  const byHost = new Map(SERVICES.map((service) => [serviceHost(instance, service), fetchers.get(service)]));
28783
28783
  const requestFetcher = {
28784
28784
  ...fetcher,
28785
- json: (path, requestOptions) => (byHost.get(hostOf2(path)) ?? fetcher).json(path, requestOptions),
28786
- stream: (path, requestOptions) => (byHost.get(hostOf2(path)) ?? fetcher).stream(path, requestOptions)
28785
+ json: (path, requestOptions) => (byHost.get(hostOf3(path)) ?? fetcher).json(path, requestOptions),
28786
+ stream: (path, requestOptions) => (byHost.get(hostOf3(path)) ?? fetcher).stream(path, requestOptions)
28787
28787
  };
28788
28788
  const web = SOURCEHUT_WEB.links({
28789
28789
  baseUrl: ctx.baseUrl,
@@ -29033,13 +29033,13 @@ function setupSourcehut(ctx) {
29033
29033
  ...warnings ? { warnings } : {}
29034
29034
  };
29035
29035
  }),
29036
- byOwnerPage: verb(true, async (owner, query = {}) => {
29036
+ byOwnerPage: verb(true, async (owner2, query = {}) => {
29037
29037
  const { user } = await git2.query(OwnerRepositories, {
29038
- owner: usernameOf(owner.owner),
29038
+ owner: usernameOf(owner2.owner),
29039
29039
  cursor: query.cursor?.token,
29040
29040
  filter: countFilter(query.perPage)
29041
29041
  }, query);
29042
- if (!user) throw new NotFoundError(`No Sourcehut account named ${owner.owner}`, 404, "", origin);
29042
+ if (!user) throw new NotFoundError(`No Sourcehut account named ${owner2.owner}`, 404, "", origin);
29043
29043
  const page2 = pageOf(user.repositories, (repository) => toRepo11(origin, repository));
29044
29044
  const warnings = isFirstPage(query.cursor) ? repoWarnings(query, query.subgroups === true ? "Sourcehut lists an account's repositories without subgroup filtering" : void 0) : void 0;
29045
29045
  return {
@@ -29892,9 +29892,9 @@ function tangledWeb(baseUrl) {
29892
29892
  file: (repo, path, at, line) => `${repoPath5(repo)}/blob/${encodeURIComponent(at)}/${encode3(path)}${line ? `#L${line}` : ""}`,
29893
29893
  raw: (repo, path, at) => `${repoPath5(repo)}/raw/${encodeURIComponent(at)}/${encode3(path)}`,
29894
29894
  parse: (segments, url, from) => {
29895
- const [owner, name, section, id] = segments;
29896
- if (!owner || !name) return;
29897
- const handle2 = owner.replace(/^@/, "");
29895
+ const [owner2, name, section, id] = segments;
29896
+ if (!owner2 || !name) return;
29897
+ const handle2 = owner2.replace(/^@/, "");
29898
29898
  const repo = {
29899
29899
  ...from,
29900
29900
  owner: handle2,
@@ -31405,12 +31405,12 @@ function createTangledRecords({ options, instance, webUrl, context, atproto, api
31405
31405
  const ref = await withRepoDid(repo, options2.signal);
31406
31406
  const { dids, warning } = await collaboratorsOf(ref, options2.signal);
31407
31407
  const items = await Promise.all([ref.owner, ...[...dids].filter((did) => did !== ref.owner)].map(async (did) => {
31408
- const owner = did === ref.owner;
31408
+ const owner2 = did === ref.owner;
31409
31409
  return {
31410
31410
  actor: await actorFor(did, options2.signal),
31411
- role: owner ? "admin" : "write",
31412
- roleRaw: owner ? "owner" : "collaborator",
31413
- permissions: owner ? OWNER_PERMISSIONS : COLLABORATOR_PERMISSIONS3,
31411
+ role: owner2 ? "admin" : "write",
31412
+ roleRaw: owner2 ? "owner" : "collaborator",
31413
+ permissions: owner2 ? OWNER_PERMISSIONS : COLLABORATOR_PERMISSIONS3,
31414
31414
  raw: { did }
31415
31415
  };
31416
31416
  }));
@@ -31677,12 +31677,12 @@ function createTangledRecords({ options, instance, webUrl, context, atproto, api
31677
31677
  }
31678
31678
  async function toRepo12(ref, record, raw, counts = {}) {
31679
31679
  const parent = record.source ? parseAtUri(record.source) : void 0;
31680
- const owner = await actorFor(ref.owner);
31681
- const path = `${owner.login}/${ref.name}`;
31680
+ const owner2 = await actorFor(ref.owner);
31681
+ const path = `${owner2.login}/${ref.name}`;
31682
31682
  return {
31683
31683
  ref: {
31684
31684
  ...ref,
31685
- ...owner.login === owner.id ? {} : { ownerHandle: owner.login },
31685
+ ...owner2.login === owner2.id ? {} : { ownerHandle: owner2.login },
31686
31686
  ...record.repoDid ? { externalId: record.repoDid } : {}
31687
31687
  },
31688
31688
  displayName: record.name && record.name !== ref.name ? record.name : void 0,
@@ -31697,7 +31697,7 @@ function createTangledRecords({ options, instance, webUrl, context, atproto, api
31697
31697
  name: parent.rkey
31698
31698
  } : void 0,
31699
31699
  topics: record.topics ?? [],
31700
- owner,
31700
+ owner: owner2,
31701
31701
  url: `${webUrl}/${path}`,
31702
31702
  cloneUrls: {
31703
31703
  https: `${webUrl}/${path}`,
@@ -32846,24 +32846,24 @@ var init_tangled_Dnwq9EY3 = __esm({
32846
32846
  listPage: verb(writable, async (listOptions = {}) => {
32847
32847
  if (!writable) throw new UnsupportedOperationError("Listing your repositories needs auth", context);
32848
32848
  return wholePage(forgeIterable(async function* () {
32849
- const owner = await viewerDid();
32849
+ const owner2 = await viewerDid();
32850
32850
  for await (const record of ownRecords(COLLECTIONS.repo, listOptions.signal)) {
32851
32851
  const rkey = parseAtUri(record.uri).rkey;
32852
32852
  yield await toRepo12({
32853
32853
  forge: FORGE10,
32854
32854
  instance,
32855
- owner,
32855
+ owner: owner2,
32856
32856
  name: rkey
32857
32857
  }, record.value, record);
32858
32858
  }
32859
32859
  }));
32860
32860
  }),
32861
- byOwnerPage: verb(true, (owner, query = {}) => wholePage(forgeIterable(async function* (warn) {
32861
+ byOwnerPage: verb(true, (owner2, query = {}) => wholePage(forgeIterable(async function* (warn) {
32862
32862
  if (query.sort) warn({
32863
32863
  code: "sort_unsupported",
32864
32864
  message: "Tangled lists repositories in the order of their records"
32865
32865
  });
32866
- const did = owner.owner.startsWith("did:") ? owner.owner : await atproto.resolveHandle(owner.owner.replace(/^@/, ""), query.signal);
32866
+ const did = owner2.owner.startsWith("did:") ? owner2.owner : await atproto.resolveHandle(owner2.owner.replace(/^@/, ""), query.signal);
32867
32867
  for await (const record of atproto.listRecords(did, COLLECTIONS.repo, query.signal)) yield await toRepo12({
32868
32868
  forge: FORGE10,
32869
32869
  instance,
@@ -32966,6 +32966,147 @@ var init_tangled_Dnwq9EY3 = __esm({
32966
32966
  }
32967
32967
  });
32968
32968
 
32969
+ // ../daemon/src/daemon-owner.ts
32970
+ import { randomUUID } from "node:crypto";
32971
+ import { join } from "node:path";
32972
+ import { DatabaseSync } from "node:sqlite";
32973
+ function claimDaemon(directory) {
32974
+ const db = new DatabaseSync(join(directory, ".daemon.sqlite"));
32975
+ try {
32976
+ db.exec("PRAGMA locking_mode = EXCLUSIVE; BEGIN EXCLUSIVE");
32977
+ db.exec("CREATE TABLE IF NOT EXISTS owner (id TEXT PRIMARY KEY)");
32978
+ const row = db.prepare("SELECT id FROM owner").get();
32979
+ const id = row ? String(row.id) : randomUUID();
32980
+ if (!row) db.prepare("INSERT INTO owner VALUES (?)").run(id);
32981
+ db.exec("COMMIT");
32982
+ return { id, close: () => db.close() };
32983
+ } catch (cause) {
32984
+ db.close();
32985
+ throw new Error(`Cannot claim daemon ownership of ${directory}: ${String(cause)}`, { cause });
32986
+ }
32987
+ }
32988
+
32989
+ // ../daemon/src/session-process.ts
32990
+ import { execFileSync, spawnSync } from "node:child_process";
32991
+ import { chmodSync, existsSync, mkdirSync, statSync } from "node:fs";
32992
+ import { dirname, join as join2 } from "node:path";
32993
+ var windows = process.platform === "win32";
32994
+ var system32 = () => {
32995
+ if (!process.env.SystemRoot) throw new Error("SystemRoot is not set");
32996
+ return join2(process.env.SystemRoot, "System32");
32997
+ };
32998
+ function powershell(script2, env = {}) {
32999
+ const shellDirectory = join2(system32(), "WindowsPowerShell", "v1.0");
33000
+ return execFileSync(
33001
+ join2(shellDirectory, "powershell.exe"),
33002
+ ["-NoProfile", "-NonInteractive", "-Command", "$ErrorActionPreference = 'Stop'\n" + script2],
33003
+ {
33004
+ env: { ...process.env, PSModulePath: join2(shellDirectory, "Modules"), ...env },
33005
+ encoding: "utf8",
33006
+ windowsHide: true,
33007
+ stdio: ["ignore", "pipe", "pipe"]
33008
+ }
33009
+ ).trim();
33010
+ }
33011
+ function privateWindowsDirectory(dir, create = false) {
33012
+ const verdict = powershell(
33013
+ `$path = $env:GEORDI_ACL_PATH
33014
+ $sid = [System.Security.Principal.SecurityIdentifier]
33015
+ $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
33016
+ if ($env:GEORDI_ACL_CREATE -and -not [System.IO.Directory]::Exists($path)) {
33017
+ $security = [System.Security.AccessControl.DirectorySecurity]::new()
33018
+ $security.SetAccessRuleProtection($true, $false)
33019
+ $security.AddAccessRule([System.Security.AccessControl.FileSystemAccessRule]::new(
33020
+ $user, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow'))
33021
+ [void][System.IO.Directory]::CreateDirectory($path, $security)
33022
+ }
33023
+ $trusted = @($user.Value, 'S-1-5-18', 'S-1-5-32-544')
33024
+ $acl = [System.IO.Directory]::GetAccessControl($path)
33025
+ if ($acl.GetOwner($sid).Value -notin $trusted) { return 'unsafe' }
33026
+ $rules = $acl.GetAccessRules($true, $true, $sid)
33027
+ if (!$rules.Count) { return 'unsafe' }
33028
+ # write and append data, attributes, delete (also children), permissions, owner,
33029
+ # GENERIC_WRITE, GENERIC_ALL
33030
+ $write = 0x116 -bor 0x40 -bor 0x10000 -bor 0x40000 -bor 0x80000 -bor 0x40000000 -bor 0x10000000
33031
+ $inheritOnly = [System.Security.AccessControl.PropagationFlags]::InheritOnly
33032
+ foreach ($rule in $rules) {
33033
+ if ($rule.IdentityReference.Value -eq 'S-1-3-0' -and ($rule.PropagationFlags -band $inheritOnly)) { continue }
33034
+ if ($rule.AccessControlType -ne 'Allow' -or $rule.IdentityReference.Value -in $trusted) { continue }
33035
+ $rights = [int]$rule.FileSystemRights
33036
+ if ($rights -band $write) { return 'unsafe' }
33037
+ # ReadData or GENERIC_READ inherited by a file would expose its journal or token.
33038
+ if (($rule.InheritanceFlags -band [System.Security.AccessControl.InheritanceFlags]::ObjectInherit) -and
33039
+ ($rights -band (0x1 -bor 0x80000000))) { return 'unsafe' }
33040
+ }
33041
+ 'private'`,
33042
+ { GEORDI_ACL_PATH: dir, GEORDI_ACL_CREATE: create ? "1" : "" }
33043
+ );
33044
+ return verdict === "private";
33045
+ }
33046
+ function privateDirectory(dir) {
33047
+ if (windows) return privateWindowsDirectory(dir);
33048
+ const { uid, mode } = statSync(dir);
33049
+ return uid === process.getuid() && !(mode & 18);
33050
+ }
33051
+ var prepared = /* @__PURE__ */ new Set();
33052
+ function prepareSessionsDirectory(dir) {
33053
+ if (prepared.has(dir)) return;
33054
+ mkdirSync(dirname(dir), { recursive: true });
33055
+ if (!windows && !existsSync(dir)) {
33056
+ mkdirSync(dir, { mode: 448 });
33057
+ chmodSync(dir, 448);
33058
+ }
33059
+ if (!(windows ? privateWindowsDirectory(dir, true) : privateDirectory(dir)))
33060
+ throw new Error(`${dir} must belong to you and not be writable by others`);
33061
+ prepared.add(dir);
33062
+ }
33063
+ function startTimes(pids) {
33064
+ const valid = [...new Set(pids)].filter((pid) => Number.isSafeInteger(pid) && pid > 1);
33065
+ const times = /* @__PURE__ */ new Map();
33066
+ const parse2 = (output) => {
33067
+ for (const line of output.split("\n")) {
33068
+ const match = /^\s*(\d+)\s+(\S.*?)\s*$/.exec(line);
33069
+ if (match) times.set(Number(match[1]), match[2]);
33070
+ }
33071
+ };
33072
+ if (!valid.length) return times;
33073
+ if (windows) {
33074
+ parse2(
33075
+ powershell(
33076
+ `foreach ($id in @(${valid.join(",")})) {
33077
+ try {
33078
+ $process = [System.Diagnostics.Process]::GetProcessById($id)
33079
+ [string]::Concat($id, ' ', $process.StartTime.ToUniversalTime().Ticks)
33080
+ } catch [System.ArgumentException] { continue }
33081
+ }
33082
+ # A missing last PID leaves PowerShell's implicit exit status at 1.
33083
+ exit 0`
33084
+ )
33085
+ );
33086
+ return times;
33087
+ }
33088
+ const ps = (ids) => spawnSync("ps", ["-o", "pid=,lstart=", "-p", ids.join(",")], {
33089
+ encoding: "utf8",
33090
+ stdio: ["ignore", "pipe", "ignore"]
33091
+ });
33092
+ const all = ps(valid);
33093
+ parse2(all.stdout ?? "");
33094
+ if (all.status !== 0 && valid.length > 1) {
33095
+ for (const pid of valid) if (!times.has(pid)) parse2(ps([pid]).stdout ?? "");
33096
+ }
33097
+ return times;
33098
+ }
33099
+ var startedAt = (pid) => startTimes([pid]).get(pid) ?? null;
33100
+ function signalTree(pid, signal) {
33101
+ if (windows)
33102
+ execFileSync(join2(system32(), "taskkill.exe"), ["/PID", String(pid), "/T", "/F"], {
33103
+ windowsHide: true,
33104
+ stdio: "ignore"
33105
+ });
33106
+ else process.kill(-pid, signal);
33107
+ }
33108
+ var gentleSignals = !windows;
33109
+
32969
33110
  // ../daemon/src/worktree-queue.ts
32970
33111
  var pending = /* @__PURE__ */ new Map();
32971
33112
  function inWorktree(path, task) {
@@ -33014,35 +33155,35 @@ async function quietGit(cwd, ...args) {
33014
33155
 
33015
33156
  // ../daemon/src/worktree.ts
33016
33157
  init_src();
33017
- import { randomUUID } from "node:crypto";
33158
+ import { randomUUID as randomUUID2 } from "node:crypto";
33018
33159
  import {
33019
33160
  closeSync,
33020
33161
  constants,
33021
- existsSync,
33162
+ existsSync as existsSync2,
33022
33163
  lstatSync,
33023
- mkdirSync,
33164
+ mkdirSync as mkdirSync2,
33024
33165
  openSync,
33025
33166
  readFileSync,
33026
33167
  realpathSync,
33027
33168
  renameSync,
33028
33169
  writeSync
33029
33170
  } from "node:fs";
33030
- import { basename, join, resolve } from "node:path";
33171
+ import { basename, join as join3, resolve } from "node:path";
33031
33172
  var read = (file) => readFileSync(file, "utf8").trim();
33032
33173
  var same = (a, b) => realpathSync(a) === realpathSync(b);
33033
33174
  function verifyLinks({ path, adminDir, commonDir }) {
33034
33175
  try {
33035
- const intact = same(resolve(adminDir, read(join(adminDir, "commondir"))), commonDir) && same(read(join(adminDir, "gitdir")), join(path, ".git")) && same(read(join(path, ".git")).replace(/^gitdir: /, ""), adminDir);
33176
+ const intact = same(resolve(adminDir, read(join3(adminDir, "commondir"))), commonDir) && same(read(join3(adminDir, "gitdir")), join3(path, ".git")) && same(read(join3(path, ".git")).replace(/^gitdir: /, ""), adminDir);
33036
33177
  if (intact) return;
33037
33178
  } catch {
33038
33179
  }
33039
33180
  throw new Error(`The Git metadata of worktree ${path} was modified; refusing to use it`);
33040
33181
  }
33041
- var worktreePath = (baseDir, repoPath6, worktreeId) => join(baseDir, basename(repoPath6), worktreeId.slice(0, 8));
33182
+ var worktreePath = (baseDir, repoPath6, worktreeId) => join3(baseDir, basename(repoPath6), worktreeId.slice(0, 8));
33042
33183
  var ordinaryRepos = /* @__PURE__ */ new Set();
33043
33184
  async function commonDirOf(repoPath6) {
33044
33185
  const dotGit = resolve(repoPath6, ".git");
33045
- if (ordinaryRepos.has(repoPath6) && lstatSync(dotGit, { throwIfNoEntry: false })?.isDirectory() && !existsSync(join(dotGit, "commondir")))
33186
+ if (ordinaryRepos.has(repoPath6) && lstatSync(dotGit, { throwIfNoEntry: false })?.isDirectory() && !existsSync2(join3(dotGit, "commondir")))
33046
33187
  return dotGit;
33047
33188
  const dir = resolve(repoPath6, (await git(repoPath6, ["rev-parse", "--git-common-dir"])).trim());
33048
33189
  if (dir === dotGit) ordinaryRepos.add(repoPath6);
@@ -33056,7 +33197,7 @@ async function describe(baseDir, repoPath6, workspaceId) {
33056
33197
  path: worktreePath(baseDir, repoPath6, workspaceId),
33057
33198
  branch: `geordi/${short}`,
33058
33199
  // git names the admin directory after the worktree's directory
33059
- adminDir: join(commonDir, "worktrees", short),
33200
+ adminDir: join3(commonDir, "worktrees", short),
33060
33201
  commonDir
33061
33202
  };
33062
33203
  }
@@ -33065,10 +33206,10 @@ function branchRef(branch2) {
33065
33206
  if (!BRANCH.test(branch2)) throw new Error(`Not a branch name: ${branch2}`);
33066
33207
  return `refs/heads/${branch2}`;
33067
33208
  }
33068
- var hasWorktree = (baseDir, repoPath6, workspaceId) => existsSync(worktreePath(baseDir, repoPath6, workspaceId));
33209
+ var hasWorktree = (baseDir, repoPath6, workspaceId) => existsSync2(worktreePath(baseDir, repoPath6, workspaceId));
33069
33210
  async function locateWorktree(baseDir, repoPath6, workspaceId) {
33070
33211
  const worktree = await describe(baseDir, repoPath6, workspaceId);
33071
- if (!existsSync(worktree.path)) throw new Error(NO_WORKTREE);
33212
+ if (!existsSync2(worktree.path)) throw new Error(NO_WORKTREE);
33072
33213
  verifyLinks(worktree);
33073
33214
  return worktree;
33074
33215
  }
@@ -33102,10 +33243,10 @@ async function fetchUpstream(repoPath6) {
33102
33243
  async function ensureWorktree(baseDir, repoPath6, workspaceId, base, branch2) {
33103
33244
  const described = await describe(baseDir, repoPath6, workspaceId);
33104
33245
  const worktree = branch2 && branchRef(branch2) ? { ...described, branch: branch2 } : described;
33105
- const missing = !existsSync(worktree.path);
33246
+ const missing = !existsSync2(worktree.path);
33106
33247
  const restored = missing && await quietGit(repoPath6, "rev-parse", "--verify", "--quiet", branchRef(worktree.branch)) !== null;
33107
33248
  if (missing) {
33108
- mkdirSync(join(baseDir, basename(repoPath6)), { recursive: true });
33249
+ mkdirSync2(join3(baseDir, basename(repoPath6)), { recursive: true });
33109
33250
  await git(repoPath6, ["worktree", "prune"]);
33110
33251
  if (restored)
33111
33252
  await git(repoPath6, ["worktree", "add", worktree.path, worktree.branch], {
@@ -33122,8 +33263,8 @@ async function ensureWorktree(baseDir, repoPath6, workspaceId, base, branch2) {
33122
33263
  }
33123
33264
  const created = missing && !restored;
33124
33265
  verifyLinks(worktree);
33125
- const writableRoots = ["objects", "refs", "logs"].map((dir) => join(worktree.commonDir, dir));
33126
- for (const dir of writableRoots) mkdirSync(dir, { recursive: true });
33266
+ const writableRoots = ["objects", "refs", "logs"].map((dir) => join3(worktree.commonDir, dir));
33267
+ for (const dir of writableRoots) mkdirSync2(dir, { recursive: true });
33127
33268
  writableRoots.push(worktree.adminDir);
33128
33269
  return { ...worktree, writableRoots, created, restored };
33129
33270
  }
@@ -33147,8 +33288,8 @@ async function continueOn(worktree, repoPath6, requireIdle = () => {
33147
33288
  await git(repoPath6, ["branch", "-D", branch2]);
33148
33289
  throw error;
33149
33290
  }
33150
- const head = join(worktree.adminDir, "HEAD");
33151
- const fresh = `${head}.${randomUUID()}`;
33291
+ const head = join3(worktree.adminDir, "HEAD");
33292
+ const fresh = `${head}.${randomUUID2()}`;
33152
33293
  const fd = openSync(
33153
33294
  fresh,
33154
33295
  constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,
@@ -33164,7 +33305,7 @@ async function continueOn(worktree, repoPath6, requireIdle = () => {
33164
33305
  return branch2;
33165
33306
  }
33166
33307
  function headOf({ path, adminDir }) {
33167
- const head = read(join(adminDir, "HEAD"));
33308
+ const head = read(join3(adminDir, "HEAD"));
33168
33309
  const branch2 = /^ref: refs\/heads\/(.+)$/.exec(head)?.[1];
33169
33310
  if (branch2 && BRANCH.test(branch2)) return `refs/heads/${branch2}`;
33170
33311
  const commit = /^([0-9a-f]{40,64})$/.exec(head)?.[1];
@@ -33179,7 +33320,7 @@ var gitEnv = ({ path, adminDir, commonDir }) => ({
33179
33320
  ...process.env,
33180
33321
  GIT_DIR: commonDir,
33181
33322
  GIT_WORK_TREE: path,
33182
- GIT_INDEX_FILE: join(adminDir, "index"),
33323
+ GIT_INDEX_FILE: join3(adminDir, "index"),
33183
33324
  // Looking must not write (git would refresh the index): we watch these files.
33184
33325
  GIT_OPTIONAL_LOCKS: "0"
33185
33326
  });
@@ -33196,7 +33337,7 @@ function turnStarts({
33196
33337
  sessions: sessions2,
33197
33338
  setups: setups2,
33198
33339
  apiUrl: apiUrl2,
33199
- prepared,
33340
+ prepared: prepared2,
33200
33341
  configFor: configFor2,
33201
33342
  begin: begin2,
33202
33343
  emitFor: emitFor2
@@ -33266,7 +33407,7 @@ function turnStarts({
33266
33407
  );
33267
33408
  if (worktree2.created)
33268
33409
  emit({ kind: "worktree", path: worktree2.path, branch: worktree2.branch });
33269
- if (worktree2.created || worktree2.restored) prepared(worktree2, message);
33410
+ if (worktree2.created || worktree2.restored) prepared2(worktree2, message);
33270
33411
  return worktree2;
33271
33412
  });
33272
33413
  const worktree = await Promise.race([stopped.promise, prepare]);
@@ -33307,12 +33448,27 @@ ${said.prompt}` };
33307
33448
  return { beginning: beginning2, startMessage: startMessage2 };
33308
33449
  }
33309
33450
 
33451
+ // ../daemon/src/live.ts
33452
+ var isLive = (event2) => event2.kind === "background" || event2.kind === "usage" || event2.kind === "commands" || event2.kind === "suggestion";
33453
+ function liveOf(event2) {
33454
+ switch (event2.kind) {
33455
+ case "background":
33456
+ return { background: event2.tasks };
33457
+ case "usage":
33458
+ return { usage: event2.usage };
33459
+ case "commands":
33460
+ return { commands: event2.commands };
33461
+ case "suggestion":
33462
+ return { suggestion: event2.text };
33463
+ }
33464
+ }
33465
+
33310
33466
  // ../daemon/src/event-delivery.ts
33311
33467
  function eventDelivery(send2, sendLive2) {
33312
33468
  const deliveries = /* @__PURE__ */ new Map();
33313
33469
  const emitFor2 = (workspaceId) => (event2, cursor) => {
33314
- if (event2.kind === "background") {
33315
- sendLive2({ type: "workspace.background", workspaceId, tasks: event2.tasks });
33470
+ if (isLive(event2)) {
33471
+ sendLive2({ type: "workspace.live", workspaceId, live: liveOf(event2) });
33316
33472
  return true;
33317
33473
  }
33318
33474
  if (!cursor) {
@@ -33342,7 +33498,7 @@ function eventDelivery(send2, sendLive2) {
33342
33498
 
33343
33499
  // ../daemon/src/icon.ts
33344
33500
  import { closeSync as closeSync2, constants as constants2, fstatSync, openSync as openSync2, readFileSync as readFileSync2 } from "node:fs";
33345
- import { join as join2 } from "node:path";
33501
+ import { join as join4 } from "node:path";
33346
33502
  var NAMES = [
33347
33503
  ["favicon.svg", "image/svg+xml"],
33348
33504
  ["favicon.png", "image/png"],
@@ -33379,7 +33535,7 @@ async function repoIcon(repoPath6) {
33379
33535
  const found = pickIcon(listed.split("\0").filter(Boolean));
33380
33536
  if (!found) return null;
33381
33537
  try {
33382
- const file = openSync2(join2(repoPath6, found.path), constants2.O_RDONLY | constants2.O_NOFOLLOW);
33538
+ const file = openSync2(join4(repoPath6, found.path), constants2.O_RDONLY | constants2.O_NOFOLLOW);
33383
33539
  try {
33384
33540
  const { size } = fstatSync(file);
33385
33541
  if (!fstatSync(file).isFile() || size === 0 || size > MAX_BYTES) return null;
@@ -33396,9 +33552,9 @@ async function repoIcon(repoPath6) {
33396
33552
  init_src();
33397
33553
  import { closeSync as closeSync3, constants as constants3, fstatSync as fstatSync2, openSync as openSync3, readFileSync as readFileSync3 } from "node:fs";
33398
33554
  import { homedir } from "node:os";
33399
- import { join as join3, resolve as resolve2 } from "node:path";
33555
+ import { join as join5, resolve as resolve2 } from "node:path";
33400
33556
  function readPicture(cwd, path) {
33401
- const file = path.startsWith("~/") ? join3(homedir(), path.slice(2)) : resolve2(cwd, path);
33557
+ const file = path.startsWith("~/") ? join5(homedir(), path.slice(2)) : resolve2(cwd, path);
33402
33558
  let fd;
33403
33559
  try {
33404
33560
  fd = openSync3(file, constants3.O_RDONLY | constants3.O_NONBLOCK);
@@ -33420,9 +33576,9 @@ function readPicture(cwd, path) {
33420
33576
 
33421
33577
  // ../daemon/src/main.ts
33422
33578
  init_src();
33423
- import { existsSync as existsSync5, readFileSync as readFileSync9 } from "node:fs";
33424
- import { homedir as homedir3, hostname } from "node:os";
33425
- import { join as join11 } from "node:path";
33579
+ import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
33580
+ import { homedir as homedir3 } from "node:os";
33581
+ import { join as join13 } from "node:path";
33426
33582
 
33427
33583
  // ../../packages/protocol/src/auth.ts
33428
33584
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
@@ -33446,8 +33602,8 @@ async function adapterFor(agent) {
33446
33602
  }
33447
33603
 
33448
33604
  // ../daemon/src/approvals.ts
33449
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync } from "node:fs";
33450
- import { dirname } from "node:path";
33605
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync } from "node:fs";
33606
+ import { dirname as dirname2 } from "node:path";
33451
33607
  function createApprovals(file) {
33452
33608
  const read4 = () => {
33453
33609
  try {
@@ -33463,7 +33619,7 @@ function createApprovals(file) {
33463
33619
  const all = read4();
33464
33620
  if (all[repoPath6]?.includes(command)) return;
33465
33621
  all[repoPath6] = [...all[repoPath6] ?? [], command];
33466
- mkdirSync2(dirname(file), { recursive: true, mode: 448 });
33622
+ mkdirSync3(dirname2(file), { recursive: true, mode: 448 });
33467
33623
  writeFileSync(`${file}.tmp`, JSON.stringify(all, null, " "), { mode: 384 });
33468
33624
  renameSync2(`${file}.tmp`, file);
33469
33625
  }
@@ -33480,7 +33636,7 @@ import {
33480
33636
  readFileSync as readFileSync6,
33481
33637
  realpathSync as realpathSync2
33482
33638
  } from "node:fs";
33483
- import { isAbsolute, join as join5, sep } from "node:path";
33639
+ import { isAbsolute, join as join7, sep } from "node:path";
33484
33640
  var MAX_FILE = 1e6;
33485
33641
  var SAFE = ["--no-ext-diff", "--no-textconv", "--ignore-submodules=all"];
33486
33642
  async function comparison(worktree, origin) {
@@ -33507,7 +33663,7 @@ function readText(worktree, path) {
33507
33663
  let fd;
33508
33664
  let file;
33509
33665
  try {
33510
- file = join5(realpathSync2(worktree.path), path);
33666
+ file = join7(realpathSync2(worktree.path), path);
33511
33667
  if (realpathSync2(file) !== file) return null;
33512
33668
  fd = openSync4(file, constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK);
33513
33669
  } catch {
@@ -33692,7 +33848,7 @@ async function versions(worktree, origin, path) {
33692
33848
  } catch {
33693
33849
  old = null;
33694
33850
  }
33695
- const exists2 = lstatSync2(join5(worktree.path, path), { throwIfNoEntry: false });
33851
+ const exists2 = lstatSync2(join7(worktree.path, path), { throwIfNoEntry: false });
33696
33852
  const now = exists2 ? readText(worktree, path) : null;
33697
33853
  if (exists2 && now === null || old?.includes("\0") || (old?.length ?? 0) > MAX_FILE)
33698
33854
  return { unavailable: "This file is binary, too large or not a regular file." };
@@ -33702,7 +33858,7 @@ async function versions(worktree, origin, path) {
33702
33858
  // ../daemon/src/config.ts
33703
33859
  init_src();
33704
33860
  import { lstatSync as lstatSync3 } from "node:fs";
33705
- import { join as join6 } from "node:path";
33861
+ import { join as join8 } from "node:path";
33706
33862
 
33707
33863
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
33708
33864
  function getLineColFromPtr(string, ptr) {
@@ -34466,9 +34622,9 @@ var HAS_WELLFORMED = !!"".isWellFormed;
34466
34622
  var import_yaml = __toESM(require_dist(), 1);
34467
34623
 
34468
34624
  // ../daemon/src/ports.ts
34469
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "node:fs";
34625
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "node:fs";
34470
34626
  import { createConnection, createServer } from "node:net";
34471
- import { dirname as dirname2 } from "node:path";
34627
+ import { dirname as dirname3 } from "node:path";
34472
34628
  var RANGE = { from: 2e4, to: 29999 };
34473
34629
  var free = (port) => new Promise((resolve5) => {
34474
34630
  const server = createServer().once("error", () => resolve5(false)).once("listening", () => server.close(() => resolve5(true))).listen(port);
@@ -34499,7 +34655,7 @@ function createPorts(file, isFree = free) {
34499
34655
  } catch {
34500
34656
  }
34501
34657
  function save() {
34502
- mkdirSync3(dirname2(file), { recursive: true, mode: 448 });
34658
+ mkdirSync4(dirname3(file), { recursive: true, mode: 448 });
34503
34659
  writeFileSync2(`${file}.tmp`, JSON.stringify(all, null, " "), { mode: 384 });
34504
34660
  renameSync3(`${file}.tmp`, file);
34505
34661
  }
@@ -34689,7 +34845,7 @@ function parseConfig(text, file = CONFIG_FILES[0]) {
34689
34845
  }
34690
34846
  async function fileFor(worktree, repoPath6) {
34691
34847
  for (const file of CONFIG_FILES)
34692
- if (lstatSync3(join6(worktree.path, file), { throwIfNoEntry: false }))
34848
+ if (lstatSync3(join8(worktree.path, file), { throwIfNoEntry: false }))
34693
34849
  return { source: "workspace", file, text: readText(worktree, file) };
34694
34850
  const start = await startOf(repoPath6);
34695
34851
  for (const file of CONFIG_FILES)
@@ -34862,7 +35018,7 @@ function closeTerminals() {
34862
35018
  // ../daemon/src/releases.ts
34863
35019
  import { execFile as execFile3 } from "node:child_process";
34864
35020
  import { lstatSync as lstatSync4 } from "node:fs";
34865
- import { join as join7 } from "node:path";
35021
+ import { join as join9 } from "node:path";
34866
35022
  var TIMEOUT_MS = 1e4;
34867
35023
  var run2 = (worktree, command, args) => new Promise(
34868
35024
  (resolve5, reject) => execFile3(
@@ -34885,7 +35041,7 @@ var run2 = (worktree, command, args) => new Promise(
34885
35041
  }
34886
35042
  )
34887
35043
  );
34888
- var exists = (worktree, file) => lstatSync4(join7(worktree.path, file), { throwIfNoEntry: false }) !== void 0;
35044
+ var exists = (worktree, file) => lstatSync4(join9(worktree.path, file), { throwIfNoEntry: false }) !== void 0;
34889
35045
  function fromSweet(output) {
34890
35046
  const packages = JSON.parse(output);
34891
35047
  if (!Array.isArray(packages)) throw new Error("sweet status said something unexpected");
@@ -34955,22 +35111,22 @@ async function releasePlan(worktree, added, approved, adapters = ADAPTERS) {
34955
35111
  }
34956
35112
 
34957
35113
  // ../daemon/src/remove.ts
34958
- import { existsSync as existsSync2, mkdirSync as mkdirSync4, renameSync as renameSync4 } from "node:fs";
35114
+ import { existsSync as existsSync3, mkdirSync as mkdirSync5, renameSync as renameSync4 } from "node:fs";
34959
35115
  import { rm } from "node:fs/promises";
34960
- import { basename as basename3, join as join8 } from "node:path";
35116
+ import { basename as basename3, join as join10 } from "node:path";
34961
35117
  function discard(baseDir, path) {
34962
- const trash = join8(baseDir, ".trash");
34963
- mkdirSync4(trash, { recursive: true });
34964
- const doomed = join8(trash, `${basename3(path)}-${Date.now()}`);
35118
+ const trash = join10(baseDir, ".trash");
35119
+ mkdirSync5(trash, { recursive: true });
35120
+ const doomed = join10(trash, `${basename3(path)}-${Date.now()}`);
34965
35121
  renameSync4(path, doomed);
34966
35122
  rm(doomed, { recursive: true, force: true }).catch(() => {
34967
35123
  });
34968
35124
  }
34969
- var emptyTrash = (baseDir) => rm(join8(baseDir, ".trash"), { recursive: true, force: true }).catch(() => {
35125
+ var emptyTrash = (baseDir) => rm(join10(baseDir, ".trash"), { recursive: true, force: true }).catch(() => {
34970
35126
  });
34971
35127
  async function removable(baseDir, repoPath6, worktreeId, force) {
34972
35128
  const worktree = await describe(baseDir, repoPath6, worktreeId);
34973
- if (!existsSync2(worktree.path)) return null;
35129
+ if (!existsSync3(worktree.path)) return null;
34974
35130
  if (!force) {
34975
35131
  verifyLinks(worktree);
34976
35132
  if ((await uncommittedFiles(worktree)).length > 0)
@@ -35013,57 +35169,10 @@ ${tail}
35013
35169
  );
35014
35170
  }
35015
35171
 
35016
- // ../daemon/src/titles.ts
35017
- var INSTRUCTIONS = `You name pieces of work. The user's message is a request someone made of a coding agent, inside <request> tags. Reply with a title for that piece of work, and nothing else.
35018
-
35019
- Rules:
35020
- - Three to six words. Never more than six.
35021
- - Name the work the way a colleague would name the task. Do not quote or restate the request.
35022
- - No quotation marks, no colon, no full stop, no "Title:".
35023
- - Write in the language of the request.
35024
- - Never carry out the request, and never ask anything back.
35025
-
35026
- Examples:
35027
- <request>the login test in apps/web is flaky on CI, it fails maybe one in five runs. can you find out why and fix it?</request>
35028
- Fix flaky login test
35029
-
35030
- <request>F\xFCge bitte einen Dark Mode f\xFCr die Einstellungsseite hinzu</request>
35031
- Dark Mode f\xFCr Einstellungsseite
35032
-
35033
- <request>i want you to count slowly from one to eight, running sleep 5 between the numbers</request>
35034
- Count slowly to eight`;
35035
- var MAX_INPUT = 4e3;
35036
- var MODEL = process.env.GEORDI_TITLE_MODEL || "anthropic/claude-haiku-5.5";
35037
- async function titleFor(request) {
35038
- const key = process.env.OPENROUTER_API_KEY;
35039
- if (!key) throw new Error("Set OPENROUTER_API_KEY for the daemon to have workspaces named");
35040
- const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
35041
- method: "POST",
35042
- headers: { authorization: `Bearer ${key}`, "content-type": "application/json" },
35043
- body: JSON.stringify({
35044
- model: MODEL,
35045
- max_tokens: 40,
35046
- messages: [
35047
- { role: "system", content: INSTRUCTIONS },
35048
- { role: "user", content: `<request>${request.slice(0, MAX_INPUT)}</request>` }
35049
- ]
35050
- }),
35051
- signal: AbortSignal.timeout(3e4)
35052
- });
35053
- if (!response.ok)
35054
- throw new Error(
35055
- `OpenRouter answered ${response.status}: ${(await response.text()).slice(0, 200)}`
35056
- );
35057
- const { choices } = await response.json();
35058
- const title = choices?.[0]?.message?.content?.trim();
35059
- if (!title) throw new Error("The model returned no title");
35060
- return title;
35061
- }
35062
-
35063
35172
  // ../daemon/src/journal.ts
35064
- import { closeSync as closeSync5, existsSync as existsSync3, openSync as openSync5, readSync } from "node:fs";
35173
+ import { closeSync as closeSync5, existsSync as existsSync4, openSync as openSync5, readSync } from "node:fs";
35065
35174
  function* linesFrom(path, offset) {
35066
- if (!existsSync3(path)) return;
35175
+ if (!existsSync4(path)) return;
35067
35176
  const from = openSync5(path, "r");
35068
35177
  try {
35069
35178
  let parts = [];
@@ -35085,40 +35194,29 @@ function* linesFrom(path, offset) {
35085
35194
  }
35086
35195
 
35087
35196
  // ../daemon/src/session.ts
35088
- import { randomUUID as randomUUID2 } from "node:crypto";
35089
- import { execFileSync, spawn as spawn2 } from "node:child_process";
35197
+ import { randomUUID as randomUUID3 } from "node:crypto";
35198
+ import { spawn as spawn2 } from "node:child_process";
35090
35199
  import {
35091
35200
  appendFileSync,
35092
- chmodSync,
35201
+ chmodSync as chmodSync2,
35093
35202
  closeSync as closeSync6,
35094
- existsSync as existsSync4,
35095
- mkdirSync as mkdirSync5,
35203
+ existsSync as existsSync5,
35204
+ mkdirSync as mkdirSync6,
35096
35205
  openSync as openSync6,
35097
35206
  readdirSync,
35098
35207
  readFileSync as readFileSync8,
35099
35208
  renameSync as renameSync5,
35100
35209
  rmSync,
35101
- statSync,
35102
35210
  writeFileSync as writeFileSync3
35103
35211
  } from "node:fs";
35104
- import { join as join9 } from "node:path";
35212
+ import { join as join11 } from "node:path";
35105
35213
  import { fileURLToPath } from "node:url";
35106
35214
  var POLL_MS = 100;
35107
35215
  var KILL_AFTER_MS = 1e4;
35108
35216
  var HOST = fileURLToPath(
35109
35217
  new URL(import.meta.url.endsWith(".ts") ? "./host.ts" : "./host.js", import.meta.url)
35110
35218
  );
35111
- function startedAt(pid) {
35112
- try {
35113
- const started = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
35114
- encoding: "utf8",
35115
- stdio: ["ignore", "pipe", "ignore"]
35116
- }).trim();
35117
- return started || null;
35118
- } catch {
35119
- return null;
35120
- }
35121
- }
35219
+ var hostOf = (dir) => JSON.parse(readFileSync8(join11(dir, "host.json"), "utf8"));
35122
35220
  var alive = (pid) => {
35123
35221
  try {
35124
35222
  process.kill(pid, 0);
@@ -35127,29 +35225,30 @@ var alive = (pid) => {
35127
35225
  return false;
35128
35226
  }
35129
35227
  };
35130
- function follow(dir, emit, ready) {
35131
- const file = (name) => join9(dir, name);
35228
+ function follow(dir, emit, ready, startOf2 = startedAt) {
35229
+ const file = (name) => join11(dir, name);
35132
35230
  const meta = JSON.parse(readFileSync8(file("meta.json"), "utf8"));
35133
- const { pid, started } = JSON.parse(readFileSync8(file("host.json"), "utf8"));
35134
- const ours = pid > 1 && startedAt(pid) === started;
35231
+ const { pid, started } = hostOf(dir);
35232
+ const ours = !!started && startOf2(pid) === started;
35135
35233
  const running = () => ours && alive(pid);
35136
35234
  const signal = (name) => {
35137
35235
  try {
35138
- if (running()) process.kill(-pid, name);
35236
+ if (running() && startedAt(pid) === started) signalTree(pid, name);
35139
35237
  } catch {
35140
35238
  }
35141
35239
  };
35142
35240
  let finished = false;
35143
- let offset = existsSync4(file("offset")) ? Number(readFileSync8(file("offset"), "utf8")) : 0;
35241
+ let offset = existsSync5(file("offset")) ? Number(readFileSync8(file("offset"), "utf8")) : 0;
35144
35242
  let open = false;
35145
- let background = [];
35146
- let expecting = existsSync4(file("expecting"));
35243
+ const live = {};
35244
+ let expecting = existsSync5(file("expecting"));
35147
35245
  let resumeId = meta.options.resumeId;
35148
35246
  function note(event2, replay = false) {
35149
- if (event2.kind === "background") background = event2.tasks;
35247
+ if (isLive(event2)) Object.assign(live, liveOf(event2));
35150
35248
  if (event2.kind === "resume") resumeId = event2.id;
35151
35249
  if (event2.kind === "turn.started") {
35152
35250
  open = true;
35251
+ if (live.suggestion) live.suggestion = null;
35153
35252
  if (!replay) {
35154
35253
  expecting = false;
35155
35254
  rmSync(file("expecting"), { force: true });
@@ -35188,7 +35287,7 @@ function follow(dir, emit, ready) {
35188
35287
  return true;
35189
35288
  }
35190
35289
  function unheard() {
35191
- if (!existsSync4(file("exit"))) return [];
35290
+ if (!existsSync5(file("exit"))) return [];
35192
35291
  const { consumed } = JSON.parse(readFileSync8(file("exit"), "utf8"));
35193
35292
  return [...linesFrom(file("in.jsonl"), consumed)].map(({ line }) => JSON.parse(line)).flatMap(({ type, ...said }) => type === "message" ? [said] : []);
35194
35293
  }
@@ -35204,15 +35303,15 @@ function follow(dir, emit, ready) {
35204
35303
  if (finished || !ready()) return;
35205
35304
  try {
35206
35305
  if (!read4()) return;
35207
- if (!existsSync4(file("exit")) && running()) return;
35306
+ if (!existsSync5(file("exit")) && running()) return;
35208
35307
  if (!read4()) return;
35209
35308
  const left = unheard();
35210
35309
  if (open || expecting && left.length === 0) {
35211
- const said = ["err.log", "host.log"].filter((name) => existsSync4(file(name))).map((name) => readFileSync8(file(name), "utf8").trim()).join(" ").trim().slice(-2e3);
35310
+ const said = ["err.log", "host.log"].filter((name) => existsSync5(file(name))).map((name) => readFileSync8(file(name), "utf8").trim()).join(" ").trim().slice(-2e3);
35212
35311
  const reason = `${meta.agent} ended unexpectedly`;
35213
35312
  const failure = {
35214
35313
  kind: "turn.failed",
35215
- error: existsSync4(file("stopped")) ? "Stopped" : said ? `${reason}: ${said}` : reason
35314
+ error: existsSync5(file("stopped")) ? "Stopped" : said ? `${reason}: ${said}` : reason
35216
35315
  };
35217
35316
  if (emit(failure, meta.generation + "/exit") === false) return;
35218
35317
  }
@@ -35230,6 +35329,7 @@ function follow(dir, emit, ready) {
35230
35329
  expecting = true;
35231
35330
  writeFileSync3(file("expecting"), "");
35232
35331
  },
35332
+ stopTask: (stopId) => tell({ type: "stopTask", stopId }),
35233
35333
  stop: () => tell({ type: "interrupt" }),
35234
35334
  close: () => tell({ type: "close" }),
35235
35335
  answer: (id, answers) => tell({ type: "answer", id, answers }),
@@ -35237,10 +35337,10 @@ function follow(dir, emit, ready) {
35237
35337
  if (finished) return;
35238
35338
  writeFileSync3(file("stopped"), "");
35239
35339
  signal("SIGTERM");
35240
- setTimeout(() => !finished && signal("SIGKILL"), KILL_AFTER_MS).unref();
35340
+ if (gentleSignals) setTimeout(() => !finished && signal("SIGKILL"), KILL_AFTER_MS).unref();
35241
35341
  },
35242
35342
  detach: () => finish(),
35243
- background: () => background,
35343
+ live: () => live,
35244
35344
  working: () => open || expecting,
35245
35345
  over: () => finished,
35246
35346
  resumeId: () => resumeId,
@@ -35249,10 +35349,10 @@ function follow(dir, emit, ready) {
35249
35349
  }
35250
35350
  function startSession(meta, first, emit, dir, ready = () => true, wrapperEntry) {
35251
35351
  rmSync(dir, { recursive: true, force: true });
35252
- mkdirSync5(dir, { recursive: true, mode: 448 });
35253
- chmodSync(dir, 448);
35254
- const file = (name) => join9(dir, name);
35255
- writeFileSync3(file("meta.json"), JSON.stringify({ ...meta, generation: randomUUID2() }), {
35352
+ mkdirSync6(dir, { recursive: true, mode: 448 });
35353
+ chmodSync2(dir, 448);
35354
+ const file = (name) => join11(dir, name);
35355
+ writeFileSync3(file("meta.json"), JSON.stringify({ ...meta, generation: randomUUID3() }), {
35256
35356
  mode: 384
35257
35357
  });
35258
35358
  writeFileSync3(file("in.jsonl"), JSON.stringify({ type: "message", ...first }) + "\n", {
@@ -35281,19 +35381,30 @@ function startSession(meta, first, emit, dir, ready = () => true, wrapperEntry)
35281
35381
  throw new Error(`Failed to start ${meta.agent}`);
35282
35382
  }
35283
35383
  child.unref();
35284
- writeFileSync3(file("host.json"), JSON.stringify({ pid, started: startedAt(pid) ?? void 0 }));
35285
- return follow(dir, emit, ready);
35384
+ const started = startedAt(pid);
35385
+ writeFileSync3(file("host.json"), JSON.stringify({ pid, started: started ?? void 0 }));
35386
+ return follow(dir, emit, ready, () => started);
35286
35387
  }
35287
35388
  function resumeSessions(sessionsDir2, emitFor2, ready = () => true) {
35288
35389
  const sessions2 = /* @__PURE__ */ new Map();
35289
- if (!existsSync4(sessionsDir2)) return sessions2;
35290
- const { uid, mode } = statSync(sessionsDir2);
35291
- if (uid !== process.getuid?.() || mode & 18)
35292
- throw new Error(`${sessionsDir2} must belong to you and not be writable by others`);
35293
- for (const workspaceId of readdirSync(sessionsDir2)) {
35294
- const dir = join9(sessionsDir2, workspaceId);
35390
+ if (!existsSync5(sessionsDir2)) return sessions2;
35391
+ prepareSessionsDirectory(sessionsDir2);
35392
+ const dirs = readdirSync(sessionsDir2, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
35393
+ const pids = dirs.flatMap((workspaceId) => {
35295
35394
  try {
35296
- sessions2.set(workspaceId, follow(dir, emitFor2(workspaceId), ready));
35395
+ return [hostOf(join11(sessionsDir2, workspaceId)).pid];
35396
+ } catch {
35397
+ return [];
35398
+ }
35399
+ });
35400
+ const times = startTimes(pids);
35401
+ for (const workspaceId of dirs) {
35402
+ const dir = join11(sessionsDir2, workspaceId);
35403
+ try {
35404
+ sessions2.set(
35405
+ workspaceId,
35406
+ follow(dir, emitFor2(workspaceId), ready, (pid) => times.get(pid) ?? null)
35407
+ );
35297
35408
  } catch {
35298
35409
  rmSync(dir, { recursive: true, force: true });
35299
35410
  }
@@ -35301,14 +35412,13 @@ function resumeSessions(sessionsDir2, emitFor2, ready = () => true) {
35301
35412
  return sessions2;
35302
35413
  }
35303
35414
  function endLegacyTurns(turnsDir) {
35304
- if (!existsSync4(turnsDir)) return;
35305
- const { uid, mode } = statSync(turnsDir);
35306
- if (uid !== process.getuid?.() || mode & 18) return;
35415
+ if (!existsSync5(turnsDir)) return;
35416
+ if (!privateDirectory(turnsDir)) return;
35307
35417
  for (const name of readdirSync(turnsDir)) {
35308
35418
  try {
35309
- const meta = JSON.parse(readFileSync8(join9(turnsDir, name, "meta.json"), "utf8"));
35419
+ const meta = JSON.parse(readFileSync8(join11(turnsDir, name, "meta.json"), "utf8"));
35310
35420
  const { pid, started } = meta;
35311
- if (pid > 1 && startedAt(pid) === started) process.kill(-pid, "SIGTERM");
35421
+ if (started && startedAt(pid) === started) signalTree(pid, "SIGTERM");
35312
35422
  } catch {
35313
35423
  }
35314
35424
  }
@@ -35346,14 +35456,14 @@ async function merged(worktree, ours, theirs, message) {
35346
35456
  }
35347
35457
  }
35348
35458
  async function update(worktree, origin, {
35349
- fetch: fetch2 = fetchUpstream,
35459
+ fetch = fetchUpstream,
35350
35460
  working = () => false
35351
35461
  } = {}) {
35352
35462
  if (working()) return false;
35353
35463
  const base = await baseOf(origin);
35354
35464
  if (!base) return false;
35355
35465
  if (base.startsWith("refs/remotes/")) {
35356
- const problem = await fetch2(origin.repoPath);
35466
+ const problem = await fetch(origin.repoPath);
35357
35467
  if (problem) console.warn(`could not fetch ${origin.repoPath}: ${problem}`);
35358
35468
  if (working()) return false;
35359
35469
  }
@@ -35404,10 +35514,10 @@ function toRepoRef3(origin, namespace, raw) {
35404
35514
  };
35405
35515
  }
35406
35516
  function parentOf(origin, source) {
35407
- const [owner, name] = source?.startsWith(FORK_SOURCE) ? source.slice(10).split("/") : [];
35408
- return owner && name ? {
35517
+ const [owner2, name] = source?.startsWith(FORK_SOURCE) ? source.slice(10).split("/") : [];
35518
+ return owner2 && name ? {
35409
35519
  ...origin,
35410
- owner,
35520
+ owner: owner2,
35411
35521
  name
35412
35522
  } : void 0;
35413
35523
  }
@@ -35701,7 +35811,7 @@ function setupArtifacts({ options, origin, fetcher }) {
35701
35811
  repos: {
35702
35812
  get: verb(true, async (repo, getOptions) => toRepo3(origin, repo.owner, (await result(repoPath6(repo), void 0, getOptions?.signal)).result)),
35703
35813
  listPage: verb(true, listRepos),
35704
- byOwnerPage: verb(true, (owner, query = {}) => reposIn(owner.owner, query, query.cursor?.token))
35814
+ byOwnerPage: verb(true, (owner2, query = {}) => reposIn(owner2.owner, query, query.cursor?.token))
35705
35815
  },
35706
35816
  threads: {
35707
35817
  get: perKind({}, noThreads),
@@ -35873,11 +35983,11 @@ function toRepo5(origin, raw) {
35873
35983
  function toCoreRepo(origin, raw, project) {
35874
35984
  if (raw.provider && raw.provider !== "entire") return;
35875
35985
  const [fullOwner, fullName] = (raw.full_name ?? "").split("/");
35876
- const owner = fullName ? fullOwner ?? "" : project ?? raw.org ?? "";
35986
+ const owner2 = fullName ? fullOwner ?? "" : project ?? raw.org ?? "";
35877
35987
  const name = (fullName ?? fullOwner) || raw.name;
35878
35988
  const permission = raw.permission ?? (raw.capabilities?.canManage ? "admin" : raw.capabilities?.canPush ? "write" : raw.capabilities?.canPull ? "read" : void 0);
35879
35989
  return {
35880
- ref: toRepoRef5(origin, owner, name, raw.id),
35990
+ ref: toRepoRef5(origin, owner2, name, raw.id),
35881
35991
  visibility: raw.visibility === "public" ? "public" : "private",
35882
35992
  isFork: false,
35883
35993
  isArchived: false,
@@ -37105,9 +37215,9 @@ function setupEntire({ options, instance, origin, fetcher, createFetcher: create
37105
37215
  return toRepo5(origin, (await cell.json(`/repos/${id}`, { signal: opts?.signal })).data);
37106
37216
  }),
37107
37217
  listPage: verb(true, async (query = {}) => tokenPage(fetcher, "/repos", camelPage("repos"), query, (raw) => toCoreRepo(origin, raw))),
37108
- byOwnerPage: verb(true, async (owner, query = {}) => {
37109
- const { id } = await project(owner.owner);
37110
- const page2 = await tokenPage(fetcher, `/projects/${encodeURIComponent(id)}/repos`, camelPage("repos"), query, (raw) => toCoreRepo(origin, raw, owner.owner));
37218
+ byOwnerPage: verb(true, async (owner2, query = {}) => {
37219
+ const { id } = await project(owner2.owner);
37220
+ const page2 = await tokenPage(fetcher, `/projects/${encodeURIComponent(id)}/repos`, camelPage("repos"), query, (raw) => toCoreRepo(origin, raw, owner2.owner));
37111
37221
  return query.visibility && query.visibility !== "all" ? {
37112
37222
  ...page2,
37113
37223
  items: page2.items.filter((repo) => repo.visibility === query.visibility)
@@ -37422,11 +37532,11 @@ var GITBUCKET_WEB = {
37422
37532
  parse: (segments, url, from) => {
37423
37533
  const [first, ...rest] = segments;
37424
37534
  const path = first === "git" ? rest : segments;
37425
- const [owner, name, section, tag] = path;
37426
- if (owner && name && section === "releases" && tag && !RESERVED_PATHS3.includes(owner.toLowerCase())) {
37535
+ const [owner2, name, section, tag] = path;
37536
+ if (owner2 && name && section === "releases" && tag && !RESERVED_PATHS3.includes(owner2.toLowerCase())) {
37427
37537
  const repo = {
37428
37538
  ...from,
37429
- owner,
37539
+ owner: owner2,
37430
37540
  name
37431
37541
  };
37432
37542
  return {
@@ -37981,10 +38091,10 @@ function toActor8(origin, user) {
37981
38091
  };
37982
38092
  }
37983
38093
  function toRepoRef10(origin, raw) {
37984
- const [owner, name] = raw.full_name.split("/");
38094
+ const [owner2, name] = raw.full_name.split("/");
37985
38095
  return {
37986
38096
  ...origin,
37987
- owner: raw.owner?.login ?? owner ?? "",
38097
+ owner: raw.owner?.login ?? owner2 ?? "",
37988
38098
  name: raw.name ?? name ?? "",
37989
38099
  externalId: raw.node_id ?? String(raw.id)
37990
38100
  };
@@ -39482,7 +39592,7 @@ async function mergePull2(worktree, { repoPath: repoPath6, worktreeId }) {
39482
39592
 
39483
39593
  // ../daemon/src/watch.ts
39484
39594
  import { watch } from "node:fs";
39485
- import { join as join10, sep as sep2 } from "node:path";
39595
+ import { join as join12, sep as sep2 } from "node:path";
39486
39596
  var SETTLE_MS = 250;
39487
39597
  function watchWorktree(worktree, onChange, files = true) {
39488
39598
  let settle;
@@ -39511,7 +39621,7 @@ function watchWorktree(worktree, onChange, files = true) {
39511
39621
  if (files) add(worktree.path, changed, true);
39512
39622
  add(worktree.adminDir, changed);
39513
39623
  add(worktree.commonDir, repoChanged);
39514
- add(join10(worktree.commonDir, "refs"), refChanged, true);
39624
+ add(join12(worktree.commonDir, "refs"), refChanged, true);
39515
39625
  return () => {
39516
39626
  clearTimeout(settle);
39517
39627
  for (const watcher of watchers) watcher.close();
@@ -39588,10 +39698,13 @@ function createWatches(locate2, onChange) {
39588
39698
  // ../daemon/src/main.ts
39589
39699
  var forgeUrl = new URL(process.env.GEORDI_FORGE_URL || "ws://127.0.0.1:7700");
39590
39700
  var apiUrl = new URL("/mcp", process.env.GEORDI_FORGE_HTTP_URL || "http://127.0.0.1:3000").href;
39591
- var worktreesDir = process.env.GEORDI_WORKTREES_DIR || join11(homedir3(), ".geordi", "worktrees");
39592
- var sessionsDir = process.env.GEORDI_SESSIONS_DIR || join11(homedir3(), ".geordi", "sessions");
39593
- var tokenFile = process.env.GEORDI_DAEMON_TOKEN_FILE || join11(homedir3(), ".geordi", "daemon-token");
39594
- var daemonId = hostname();
39701
+ var worktreesDir = process.env.GEORDI_WORKTREES_DIR || join13(homedir3(), ".geordi", "worktrees");
39702
+ var sessionsDir = process.env.GEORDI_SESSIONS_DIR || join13(homedir3(), ".geordi", "sessions");
39703
+ var tokenFile = process.env.GEORDI_DAEMON_TOKEN_FILE || join13(homedir3(), ".geordi", "daemon-token");
39704
+ prepareSessionsDirectory(sessionsDir);
39705
+ var owner = claimDaemon(sessionsDir);
39706
+ var daemonId = owner.id;
39707
+ process.once("exit", owner.close);
39595
39708
  var harnesses = await Promise.all(
39596
39709
  AGENTS.map(async (agent) => ({ agent, ...(await adapterFor(agent)).offers() }))
39597
39710
  );
@@ -39613,10 +39726,10 @@ function readToken() {
39613
39726
  }
39614
39727
  }
39615
39728
  var approvals = createApprovals(
39616
- process.env.GEORDI_RUN_APPROVALS_FILE || join11(homedir3(), ".geordi", "run-approvals.json")
39729
+ process.env.GEORDI_RUN_APPROVALS_FILE || join13(homedir3(), ".geordi", "run-approvals.json")
39617
39730
  );
39618
39731
  var ports = createPorts(
39619
- process.env.GEORDI_PORTS_FILE || join11(homedir3(), ".geordi", "ports.json")
39732
+ process.env.GEORDI_PORTS_FILE || join13(homedir3(), ".geordi", "ports.json")
39620
39733
  );
39621
39734
  async function configFor(worktree, { repoPath: repoPath6, worktreeId }) {
39622
39735
  const found = await settingsOf(worktree, repoPath6);
@@ -39732,12 +39845,12 @@ function send(message) {
39732
39845
  }
39733
39846
  var { emitFor, acknowledge } = eventDelivery(send, sendLive);
39734
39847
  var connected = () => socket?.readyState === WebSocket.OPEN;
39735
- endLegacyTurns(join11(sessionsDir, "..", "turns"));
39848
+ endLegacyTurns(join13(sessionsDir, "..", "turns"));
39736
39849
  var retired = /* @__PURE__ */ new WeakSet();
39737
39850
  var sessions = resumeSessions(sessionsDir, emitFor, connected);
39738
39851
  for (const [workspaceId, session] of sessions) attend(workspaceId, session);
39739
39852
  function begin(workspaceId, meta, [first, ...rest]) {
39740
- const dir = join11(sessionsDir, workspaceId);
39853
+ const dir = join13(sessionsDir, workspaceId);
39741
39854
  const options = { ...meta.options, dir };
39742
39855
  const session = startSession({ ...meta, options }, first, emitFor(workspaceId), dir, connected);
39743
39856
  rest.forEach(session.say);
@@ -39746,8 +39859,8 @@ function begin(workspaceId, meta, [first, ...rest]) {
39746
39859
  }
39747
39860
  function attend(workspaceId, session) {
39748
39861
  void session.done.then((unheard) => {
39749
- if (sessions.get(workspaceId) === session && session.background().length)
39750
- sendLive({ type: "workspace.background", workspaceId, tasks: [] });
39862
+ if (sessions.get(workspaceId) === session && session.live().background?.length)
39863
+ sendLive({ type: "workspace.live", workspaceId, live: { background: [] } });
39751
39864
  if (unheard.length === 0 || retired.has(session)) {
39752
39865
  if (sessions.get(workspaceId) === session) sessions.delete(workspaceId);
39753
39866
  return;
@@ -39766,7 +39879,7 @@ function attend(workspaceId, session) {
39766
39879
  unheard.forEach(successor.say);
39767
39880
  return;
39768
39881
  }
39769
- if (!existsSync5(options.cwd)) throw new Error(NO_WORKTREE);
39882
+ if (!existsSync6(options.cwd)) throw new Error(NO_WORKTREE);
39770
39883
  begin(
39771
39884
  workspaceId,
39772
39885
  { agent, apiToken, options: { ...options, resumeId: session.resumeId() } },
@@ -39841,8 +39954,8 @@ function connect(delay2 = 500) {
39841
39954
  socket = ws;
39842
39955
  for (const [workspaceId, session] of sessions) {
39843
39956
  if (session.over()) continue;
39844
- const tasks = session.background();
39845
- if (tasks.length) sendLive({ type: "workspace.background", workspaceId, tasks });
39957
+ const live = session.live();
39958
+ if (Object.keys(live).length) sendLive({ type: "workspace.live", workspaceId, live });
39846
39959
  }
39847
39960
  delay2 = 500;
39848
39961
  for (const queued of outbox.splice(0)) ws.send(JSON.stringify(queued));
@@ -39877,7 +39990,6 @@ function answer(request) {
39877
39990
  async function readRequest(request) {
39878
39991
  if (request.kind === "terminalActivity") return hasTerminalActivity(request.workspaceId);
39879
39992
  if (request.kind === "scrollback") return scrollbackOf(request.terminalId);
39880
- if (request.kind === "title") return titleFor(request.text);
39881
39993
  if (request.kind === "repoIcon") return repoIcon(request.repoPath);
39882
39994
  if (request.kind === "removeWorktree") {
39883
39995
  const { repoPath: repoPath6, worktreeId, force } = request;
@@ -40048,6 +40160,9 @@ async function handle(message) {
40048
40160
  case "terminal.close":
40049
40161
  closeTerminal(message.terminalId);
40050
40162
  break;
40163
+ case "agent.stopTask":
40164
+ sessions.get(message.workspaceId)?.stopTask(message.stopId);
40165
+ break;
40051
40166
  case "agent.stop":
40052
40167
  (beginning.get(message.workspaceId) ?? sessions.get(message.workspaceId))?.stop();
40053
40168
  break;