@blogic-cz/agent-tools 0.15.8 → 0.15.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.15.8",
3
+ "version": "0.15.10",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, sessions, and audit",
5
5
  "keywords": [
6
6
  "agent",
@@ -557,10 +557,23 @@ const acquireVpn = <E>(
557
557
  while (true) {
558
558
  const snapshot = store.snapshot();
559
559
  if (snapshot.lifecycle === "UNKNOWN") {
560
+ const contended = snapshot.activeLeases > 0;
561
+ if (!contended) {
562
+ const observed = yield* runStatusBefore(driver, connectDeadline, runCommand);
563
+ if (
564
+ observed !== undefined &&
565
+ (store.reconcileUnknown(snapshot, observed, Date.now()) ||
566
+ store.snapshot().lifecycle !== "UNKNOWN")
567
+ ) {
568
+ continue;
569
+ }
570
+ }
560
571
  return yield* fail(
561
572
  new PrerequisiteRunError({
562
573
  message: `VPN prerequisite "${key}" has unknown ownership: ${snapshot.evidence ?? "no evidence"}`,
563
- hint: "Quiesce all agent-tools processes and remove its VPN runtime state before retrying.",
574
+ hint: contended
575
+ ? "Another agent-tools process holds an active lease on this VPN. Retry once it has finished."
576
+ : missingVpnToolHint(driver),
564
577
  }),
565
578
  );
566
579
  }
@@ -534,6 +534,28 @@ export class VpnStore {
534
534
  return false;
535
535
  }
536
536
 
537
+ /** Recovers terminal UNKNOWN from an observed status; fenced so it can never take ownership from a holder. */
538
+ reconcileUnknown(snapshot: VpnStateSnapshot, connected: boolean, now: number): boolean {
539
+ return this.immediate(
540
+ () =>
541
+ this.db
542
+ .query(
543
+ `UPDATE vpn_state SET lifecycle=?, managed_epoch_id=NULL, idle_deadline=NULL,
544
+ revision=revision+1, evidence=?, updated_at=?
545
+ WHERE singleton=1 AND lifecycle='UNKNOWN' AND operation_id IS NULL AND revision=?
546
+ AND NOT EXISTS (SELECT 1 FROM leases WHERE status='ACTIVE')`,
547
+ )
548
+ .run(
549
+ connected ? "EXTERNAL" : "DOWN",
550
+ connected
551
+ ? "Recovered from unknown ownership: VPN observed connected outside agent-tools."
552
+ : "Recovered from unknown ownership: VPN observed disconnected.",
553
+ now,
554
+ snapshot.revision,
555
+ ).changes === 1,
556
+ );
557
+ }
558
+
537
559
  private commitOperation(
538
560
  guard: OperationGuard,
539
561
  from: VpnLifecycle,