@agentconnect.md/daemon 1.0.0-rc.205 → 1.0.0-rc.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14072,12 +14072,18 @@ const UNSAFE_OPTS = { unsafe: {
14072
14072
  allowUnsafeCredentialHelper: true,
14073
14073
  allowUnsafeConfigEnvCount: true
14074
14074
  } };
14075
- /** simple-git bound to a cwd with the credential-helper opt-in. */
14076
- function gitFor(cwd) {
14077
- return cwd ? simpleGit({
14078
- baseDir: cwd,
14075
+ /**
14076
+ * simple-git bound to a cwd with the credential-helper opt-in. An `abort`
14077
+ * signal KILLS the spawned git child (abort-plugin) — pair budget timeouts
14078
+ * with it, or the abandoned child keeps running and holds .git locks
14079
+ * (index.lock) into the next session's pull.
14080
+ */
14081
+ function gitFor(cwd, abort) {
14082
+ return simpleGit({
14083
+ ...cwd ? { baseDir: cwd } : {},
14084
+ ...abort ? { abort } : {},
14079
14085
  ...UNSAFE_OPTS
14080
- }) : simpleGit(UNSAFE_OPTS);
14086
+ });
14081
14087
  }
14082
14088
  const HOST_ENV_STRIP = /* @__PURE__ */ new Set([
14083
14089
  "EDITOR",
@@ -14215,6 +14221,31 @@ async function preWarmGitCred(agentId, reason) {
14215
14221
  if (!preWarm) return;
14216
14222
  await preWarm(agentId, reason);
14217
14223
  }
14224
+ const MIN_GIT = [2, 32];
14225
+ /** `git version 2.39.5 (Apple Git-154)` → [2, 39]; null when unparseable. */
14226
+ function parseGitVersion(raw) {
14227
+ const m = /git version (\d+)\.(\d+)/.exec(raw);
14228
+ return m ? [Number(m[1]), Number(m[2])] : null;
14229
+ }
14230
+ /**
14231
+ * Boot-time probe (fire-and-forget): a host below the floor would otherwise
14232
+ * only show up as a mysterious credential prompt / auth failure deep inside an
14233
+ * agent session — say it once, at startup, in plain words.
14234
+ */
14235
+ function probeGitVersion(warn) {
14236
+ execFile("git", ["--version"], { timeout: 5e3 }, (err, stdout) => {
14237
+ if (err) {
14238
+ warn("git probe: `git --version` failed — git workspaces will not work on this host");
14239
+ return;
14240
+ }
14241
+ const v = parseGitVersion(String(stdout));
14242
+ if (!v) return;
14243
+ const [major, minor] = v;
14244
+ if (major > MIN_GIT[0] || major === MIN_GIT[0] && minor >= MIN_GIT[1]) return;
14245
+ const cloneToo = major < 2 || major === 2 && minor < 31;
14246
+ warn(`git ${major}.${minor} found but github-app workspaces need git >= ${MIN_GIT[0]}.${MIN_GIT[1]}: this git silently ignores the session credential channel (GIT_CONFIG_GLOBAL)` + (cloneToo ? " and clone-time injection (GIT_CONFIG_COUNT, needs >= 2.31) will fail" : ""));
14247
+ });
14248
+ }
14218
14249
  //#endregion
14219
14250
  //#region src/workspace/workspace-manager.ts
14220
14251
  const PULL_TIMEOUT_MS$1 = 4500;
@@ -14236,12 +14267,16 @@ async function prepareWorkspace(agent) {
14236
14267
  }
14237
14268
  if (agent.workspace.pullOnNewSession) {
14238
14269
  if (usesGithubApp(agent)) await preWarmGitCred(agent.id, "pull").catch(() => void 0);
14270
+ const abort = new AbortController();
14271
+ const timer = setTimeout(() => abort.abort(), PULL_TIMEOUT_MS$1);
14239
14272
  try {
14240
- await Promise.race([gitFor(cwd).env({
14273
+ await gitFor(cwd, abort.signal).env({
14241
14274
  ...gitEnvBase(),
14242
14275
  GIT_TERMINAL_PROMPT: "0"
14243
- }).pull(["--ff-only"]), new Promise((_, rej) => setTimeout(() => rej(/* @__PURE__ */ new Error("pull timeout")), PULL_TIMEOUT_MS$1))]);
14244
- } catch {}
14276
+ }).pull(["--ff-only"]);
14277
+ } catch {} finally {
14278
+ clearTimeout(timer);
14279
+ }
14245
14280
  }
14246
14281
  return cwd;
14247
14282
  }
@@ -101300,6 +101335,7 @@ var Daemon = class Daemon {
101300
101335
  warn: (m) => this.log.warn(m)
101301
101336
  });
101302
101337
  this.gitCredServer.start();
101338
+ probeGitVersion((m) => this.log.warn(m));
101303
101339
  if (!cfg.daemonId && !cpKeyOnboarding) {
101304
101340
  cfg.daemonId = randomUUID();
101305
101341
  persistDaemonId(root, cfg.daemonId);