teamshare-bridge 0.21.72 → 0.21.74
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/bridge/auto-upgrade.d.ts +49 -0
- package/dist/bridge/auto-upgrade.js +262 -0
- package/dist/bridge/auto-upgrade.js.map +1 -0
- package/dist/bridge/daemon-support.d.ts +9 -0
- package/dist/bridge/daemon-support.js +10 -1
- package/dist/bridge/daemon-support.js.map +1 -1
- package/dist/bridge/daemon.js +100 -4
- package/dist/bridge/daemon.js.map +1 -1
- package/dist/bridge/index.js +120 -10
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/service.js +6 -0
- package/dist/bridge/service.js.map +1 -1
- package/dist/bridge/spawn.d.ts +3 -1
- package/dist/bridge/spawn.js +9 -2
- package/dist/bridge/spawn.js.map +1 -1
- package/dist/bridge/upgrade-marker.d.ts +44 -0
- package/dist/bridge/upgrade-marker.js +147 -0
- package/dist/bridge/upgrade-marker.js.map +1 -0
- package/dist/bridge/wake-handler.js +99 -58
- package/dist/bridge/wake-handler.js.map +1 -1
- package/dist/bridge/wake-routing.d.ts +13 -0
- package/dist/bridge/wake-routing.js +18 -0
- package/dist/bridge/wake-routing.js.map +1 -1
- package/dist/cli/commands/build.js +25 -15
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/chat.js +19 -2
- package/dist/cli/commands/chat.js.map +1 -1
- package/dist/cli/commands/link.js +29 -0
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/plan.js +27 -0
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/research.js +3 -3
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/run.js +41 -20
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/worker.js +29 -18
- package/dist/cli/commands/worker.js.map +1 -1
- package/dist/lib/api-content.d.ts +0 -13
- package/dist/lib/api-content.js +0 -10
- package/dist/lib/api-content.js.map +1 -1
- package/dist/lib/brief.js +1 -1
- package/dist/lib/brief.js.map +1 -1
- package/dist/lib/config.d.ts +12 -0
- package/dist/lib/config.js +16 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/diagnostics.d.ts +3 -1
- package/dist/lib/diagnostics.js.map +1 -1
- package/dist/lib/git/git-auto.js +3 -1
- package/dist/lib/git/git-auto.js.map +1 -1
- package/dist/lib/git/git-core.d.ts +1 -0
- package/dist/lib/git/git-core.js +3 -3
- package/dist/lib/git/git-core.js.map +1 -1
- package/dist/lib/git/git-finalize.js +22 -5
- package/dist/lib/git/git-finalize.js.map +1 -1
- package/dist/lib/git/git-pipeline.d.ts +1 -0
- package/dist/lib/git/git-pipeline.js +3 -1
- package/dist/lib/git/git-pipeline.js.map +1 -1
- package/dist/lib/git/git-prepare.d.ts +13 -0
- package/dist/lib/git/git-prepare.js +115 -17
- package/dist/lib/git/git-prepare.js.map +1 -1
- package/dist/lib/git/git-runner.d.ts +3 -0
- package/dist/lib/git/git-runner.js +151 -8
- package/dist/lib/git/git-runner.js.map +1 -1
- package/dist/lib/git/index-recovery.d.ts +106 -0
- package/dist/lib/git/index-recovery.js +433 -0
- package/dist/lib/git/index-recovery.js.map +1 -0
- package/dist/lib/git/index.d.ts +2 -0
- package/dist/lib/git/index.js +11 -1
- package/dist/lib/git/index.js.map +1 -1
- package/dist/lib/git/stash-context.d.ts +6 -1
- package/dist/lib/git/stash-context.js +32 -3
- package/dist/lib/git/stash-context.js.map +1 -1
- package/dist/lib/llm/llm.js +2 -1
- package/dist/lib/llm/llm.js.map +1 -1
- package/dist/lib/orchestrator/handlers/git.js +12 -1
- package/dist/lib/orchestrator/handlers/git.js.map +1 -1
- package/dist/lib/orchestrator/worktree.d.ts +17 -5
- package/dist/lib/orchestrator/worktree.js +110 -30
- package/dist/lib/orchestrator/worktree.js.map +1 -1
- package/dist/lib/version-check.d.ts +32 -0
- package/dist/lib/version-check.js +151 -0
- package/dist/lib/version-check.js.map +1 -0
- package/dist/lib/workspace/mirror.d.ts +72 -0
- package/dist/lib/workspace/mirror.js +415 -0
- package/dist/lib/workspace/mirror.js.map +1 -0
- package/package.json +1 -1
- package/skills/teamshare-cdd/SKILL.md +30 -11
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** First probe: warm-up + jitter so N machines never check together. */
|
|
2
|
+
export declare const FIRST_CHECK_DELAY_MS: number;
|
|
3
|
+
export declare const FIRST_CHECK_JITTER_MS: number;
|
|
4
|
+
/** Subsequent probes. */
|
|
5
|
+
export declare const CHECK_INTERVAL_MS: number;
|
|
6
|
+
export declare const CHECK_INTERVAL_JITTER_MS: number;
|
|
7
|
+
/** How often the busy/idle sampler runs while an upgrade is pending. */
|
|
8
|
+
export declare const SAMPLE_MS = 30000;
|
|
9
|
+
/** The machine must have been continuously idle this long before dispatch. */
|
|
10
|
+
export declare const MIN_IDLE_MS: number;
|
|
11
|
+
/** Never upgrade seconds after boot (a daemon restart is not "idle time"). */
|
|
12
|
+
export declare const MIN_UPTIME_MS: number;
|
|
13
|
+
/** Give up on this window and retry at the next scheduled check. */
|
|
14
|
+
export declare const IDLE_WAIT_TIMEOUT_MS: number;
|
|
15
|
+
/** After a failed install, wait before trying again... */
|
|
16
|
+
export declare const FAILURE_BACKOFF_MS: number;
|
|
17
|
+
/** ...and stop trying entirely after this many failures in one boot. */
|
|
18
|
+
export declare const MAX_FAILURES = 3;
|
|
19
|
+
export interface AutoUpgradeOptions {
|
|
20
|
+
/** Daemon logger (writes to ~/.teamshare/daemon.log). */
|
|
21
|
+
log: (line: string) => void;
|
|
22
|
+
/** Fresh opt-out check (`config.autoUpgrade === false` disables the loop). */
|
|
23
|
+
enabled: () => boolean;
|
|
24
|
+
/** Reason the machine is busy, or null when completely idle. */
|
|
25
|
+
busyReason: () => string | null;
|
|
26
|
+
/** Installed version (package.json of THIS install). */
|
|
27
|
+
version: string;
|
|
28
|
+
/** Probe port the daemon bound; the restarted daemon reuses it. */
|
|
29
|
+
port: number;
|
|
30
|
+
/** Graceful daemon exit, called once the helper has been dispatched. */
|
|
31
|
+
shutdown: () => void;
|
|
32
|
+
/** Best-effort hub report (diagnostics). Resolves when delivered/queued. */
|
|
33
|
+
report: (severity: 'warning' | 'error', message: string, context?: Record<string, unknown>) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** Verdict for one idle sample - exported so the gates are unit-testable. */
|
|
36
|
+
export declare function idleVerdict(input: {
|
|
37
|
+
busyReason: string | null;
|
|
38
|
+
lastBusyAt: number;
|
|
39
|
+
now: number;
|
|
40
|
+
bootAt: number;
|
|
41
|
+
}): {
|
|
42
|
+
ready: boolean;
|
|
43
|
+
why: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Starts the periodic check. Returns a stop function (the daemon clears it
|
|
47
|
+
* on shutdown). Idempotent per call - one scheduler per daemon process.
|
|
48
|
+
*/
|
|
49
|
+
export declare function startAutoUpgrade(opts: AutoUpgradeOptions): () => void;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_FAILURES = exports.FAILURE_BACKOFF_MS = exports.IDLE_WAIT_TIMEOUT_MS = exports.MIN_UPTIME_MS = exports.MIN_IDLE_MS = exports.SAMPLE_MS = exports.CHECK_INTERVAL_JITTER_MS = exports.CHECK_INTERVAL_MS = exports.FIRST_CHECK_JITTER_MS = exports.FIRST_CHECK_DELAY_MS = void 0;
|
|
4
|
+
exports.idleVerdict = idleVerdict;
|
|
5
|
+
exports.startAutoUpgrade = startAutoUpgrade;
|
|
6
|
+
/**
|
|
7
|
+
* Silent auto-upgrade scheduler (2026-09).
|
|
8
|
+
*
|
|
9
|
+
* Every few hours the daemon asks the npm registry whether a newer
|
|
10
|
+
* `teamshare-bridge` is published. When one is, it WAITS for a genuinely
|
|
11
|
+
* idle machine (no session lock, no live session, no queued wakes, warm
|
|
12
|
+
* boot) and only then dispatches a detached helper that runs the existing
|
|
13
|
+
* `teamshare-bridge upgrade` flow (stop -> `npm i -g ...@latest` -> start).
|
|
14
|
+
*
|
|
15
|
+
* Rules that make this safe:
|
|
16
|
+
* - never runs while anything is executing (see the daemon's busyReason),
|
|
17
|
+
* - never runs against a dev / npm-link / git checkout (version-check),
|
|
18
|
+
* - never overlaps itself: the upgrade marker is stamped first and the
|
|
19
|
+
* supervisor refuses to start a daemon while a helper owns the machine,
|
|
20
|
+
* - failures back off instead of retrying in a loop, and the helper
|
|
21
|
+
* restarts the previous version when the install fails.
|
|
22
|
+
*
|
|
23
|
+
* Everything is injected (see AutoUpgradeOptions) so the gates are unit
|
|
24
|
+
* testable without a live daemon.
|
|
25
|
+
*/
|
|
26
|
+
const node_child_process_1 = require("node:child_process");
|
|
27
|
+
const node_fs_1 = require("node:fs");
|
|
28
|
+
const node_os_1 = require("node:os");
|
|
29
|
+
const node_path_1 = require("node:path");
|
|
30
|
+
const version_check_1 = require("../lib/version-check");
|
|
31
|
+
const spawn_1 = require("./spawn");
|
|
32
|
+
const upgrade_marker_1 = require("./upgrade-marker");
|
|
33
|
+
/** First probe: warm-up + jitter so N machines never check together. */
|
|
34
|
+
exports.FIRST_CHECK_DELAY_MS = 20 * 60_000;
|
|
35
|
+
exports.FIRST_CHECK_JITTER_MS = 10 * 60_000;
|
|
36
|
+
/** Subsequent probes. */
|
|
37
|
+
exports.CHECK_INTERVAL_MS = 6 * 3_600_000;
|
|
38
|
+
exports.CHECK_INTERVAL_JITTER_MS = 30 * 60_000;
|
|
39
|
+
/** How often the busy/idle sampler runs while an upgrade is pending. */
|
|
40
|
+
exports.SAMPLE_MS = 30_000;
|
|
41
|
+
/** The machine must have been continuously idle this long before dispatch. */
|
|
42
|
+
exports.MIN_IDLE_MS = 10 * 60_000;
|
|
43
|
+
/** Never upgrade seconds after boot (a daemon restart is not "idle time"). */
|
|
44
|
+
exports.MIN_UPTIME_MS = 5 * 60_000;
|
|
45
|
+
/** Give up on this window and retry at the next scheduled check. */
|
|
46
|
+
exports.IDLE_WAIT_TIMEOUT_MS = 60 * 60_000;
|
|
47
|
+
/** After a failed install, wait before trying again... */
|
|
48
|
+
exports.FAILURE_BACKOFF_MS = 6 * 3_600_000;
|
|
49
|
+
/** ...and stop trying entirely after this many failures in one boot. */
|
|
50
|
+
exports.MAX_FAILURES = 3;
|
|
51
|
+
/** Verdict for one idle sample - exported so the gates are unit-testable. */
|
|
52
|
+
function idleVerdict(input) {
|
|
53
|
+
if (input.busyReason)
|
|
54
|
+
return { ready: false, why: input.busyReason };
|
|
55
|
+
if (input.now - input.bootAt < exports.MIN_UPTIME_MS) {
|
|
56
|
+
return { ready: false, why: 'daemon just started' };
|
|
57
|
+
}
|
|
58
|
+
const idleFor = input.now - input.lastBusyAt;
|
|
59
|
+
if (idleFor < exports.MIN_IDLE_MS) {
|
|
60
|
+
return {
|
|
61
|
+
ready: false,
|
|
62
|
+
why: `idle only ${Math.round(idleFor / 1000)}s (need ${Math.round(exports.MIN_IDLE_MS / 1000)}s)`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { ready: true, why: `idle for ${Math.round(idleFor / 1000)}s` };
|
|
66
|
+
}
|
|
67
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
68
|
+
const t = setTimeout(resolve, ms);
|
|
69
|
+
t.unref?.();
|
|
70
|
+
});
|
|
71
|
+
const jitter = (spread) => Math.floor(Math.random() * spread);
|
|
72
|
+
/**
|
|
73
|
+
* Starts the periodic check. Returns a stop function (the daemon clears it
|
|
74
|
+
* on shutdown). Idempotent per call - one scheduler per daemon process.
|
|
75
|
+
*/
|
|
76
|
+
function startAutoUpgrade(opts) {
|
|
77
|
+
const bootAt = Date.now();
|
|
78
|
+
/** Last moment the machine was observed doing something. */
|
|
79
|
+
let lastBusyAt = Date.now();
|
|
80
|
+
let failures = 0;
|
|
81
|
+
let backoffUntil = 0;
|
|
82
|
+
let inFlight = null;
|
|
83
|
+
let stopped = false;
|
|
84
|
+
let notifiedUpToDate = false;
|
|
85
|
+
let notifiedDisabled = false;
|
|
86
|
+
let gaveUpNotified = false;
|
|
87
|
+
const timers = [];
|
|
88
|
+
const log = (line) => opts.log(line);
|
|
89
|
+
const sample = () => {
|
|
90
|
+
if (opts.busyReason())
|
|
91
|
+
lastBusyAt = Date.now();
|
|
92
|
+
};
|
|
93
|
+
const waitUntilIdle = async () => {
|
|
94
|
+
const deadline = Date.now() + exports.IDLE_WAIT_TIMEOUT_MS;
|
|
95
|
+
for (;;) {
|
|
96
|
+
if (stopped)
|
|
97
|
+
return false;
|
|
98
|
+
const verdict = idleVerdict({
|
|
99
|
+
busyReason: opts.busyReason(),
|
|
100
|
+
lastBusyAt,
|
|
101
|
+
now: Date.now(),
|
|
102
|
+
bootAt,
|
|
103
|
+
});
|
|
104
|
+
if (verdict.ready)
|
|
105
|
+
return true;
|
|
106
|
+
if (Date.now() >= deadline) {
|
|
107
|
+
log(`[auto-upgrade] no idle window in the last ${Math.round(exports.IDLE_WAIT_TIMEOUT_MS / 60_000)} min (${verdict.why}) - retrying at the next check`);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
await sleep(exports.SAMPLE_MS);
|
|
111
|
+
sample();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const runCheck = async () => {
|
|
115
|
+
if (stopped)
|
|
116
|
+
return;
|
|
117
|
+
if (!opts.enabled()) {
|
|
118
|
+
if (!notifiedDisabled) {
|
|
119
|
+
notifiedDisabled = true;
|
|
120
|
+
log('[auto-upgrade] disabled in config (autoUpgrade: false)');
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
notifiedDisabled = false;
|
|
125
|
+
const install = (0, version_check_1.updatableInstall)();
|
|
126
|
+
if (!install.ok) {
|
|
127
|
+
if (!notifiedDisabled) {
|
|
128
|
+
notifiedDisabled = true;
|
|
129
|
+
log(`[auto-upgrade] not applicable: ${install.reason}`);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if ((0, upgrade_marker_1.upgradeInProgress)()) {
|
|
134
|
+
log('[auto-upgrade] an upgrade is already running - skipping this check');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (Date.now() < backoffUntil)
|
|
138
|
+
return;
|
|
139
|
+
const state = (0, upgrade_marker_1.readUpgradeState)();
|
|
140
|
+
const totalFailures = failures + (state?.failures ?? 0);
|
|
141
|
+
if (totalFailures >= exports.MAX_FAILURES) {
|
|
142
|
+
if (!gaveUpNotified) {
|
|
143
|
+
gaveUpNotified = true;
|
|
144
|
+
log(`[auto-upgrade] giving up after ${totalFailures} failed install(s) (last: ${state?.lastError ?? 'unknown'}) - run \`teamshare-bridge auto-upgrade on\` to reset`);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (state?.lastFailureAt && Date.now() - state.lastFailureAt < exports.FAILURE_BACKOFF_MS) {
|
|
149
|
+
return; // recently failed - stay quiet until the backoff expires
|
|
150
|
+
}
|
|
151
|
+
const latest = await (0, version_check_1.fetchLatestVersion)();
|
|
152
|
+
if (!latest)
|
|
153
|
+
return; // offline / registry hiccup - next check retries
|
|
154
|
+
if (!(0, version_check_1.isNewer)(latest, opts.version)) {
|
|
155
|
+
if (!notifiedUpToDate) {
|
|
156
|
+
notifiedUpToDate = true;
|
|
157
|
+
log(`[auto-upgrade] up to date (installed ${opts.version}, published ${latest})`);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
notifiedUpToDate = false;
|
|
162
|
+
log(`[auto-upgrade] update available: ${opts.version} -> ${latest} - waiting for an idle machine`);
|
|
163
|
+
if (!(await waitUntilIdle()))
|
|
164
|
+
return;
|
|
165
|
+
// Last-second re-check: a wake can land while the loop slept.
|
|
166
|
+
const busy = opts.busyReason();
|
|
167
|
+
if (busy) {
|
|
168
|
+
log(`[auto-upgrade] work arrived at the last moment (${busy}) - deferring`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if ((0, upgrade_marker_1.upgradeInProgress)())
|
|
172
|
+
return;
|
|
173
|
+
(0, upgrade_marker_1.writeUpgradeMarker)({
|
|
174
|
+
from: opts.version,
|
|
175
|
+
to: latest,
|
|
176
|
+
startedAt: new Date().toISOString(),
|
|
177
|
+
state: 'running',
|
|
178
|
+
});
|
|
179
|
+
log(`[auto-upgrade] dispatching ${opts.version} -> ${latest} (idle for ${Math.round((Date.now() - lastBusyAt) / 1000)}s)`);
|
|
180
|
+
try {
|
|
181
|
+
await Promise.race([
|
|
182
|
+
opts.report('warning', `TeamShare bridge ${opts.version} is upgrading to ${latest}`, { from: opts.version, to: latest, auto: true }),
|
|
183
|
+
sleep(3_000),
|
|
184
|
+
]);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
/* reporting must never block the upgrade */
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
dispatchHelper(opts.port);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
failures += 1;
|
|
194
|
+
backoffUntil = Date.now() + exports.FAILURE_BACKOFF_MS;
|
|
195
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
196
|
+
log(`[auto-upgrade] failed to start the upgrade helper: ${detail}`);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
opts.shutdown();
|
|
200
|
+
};
|
|
201
|
+
const scheduleCheck = (delay) => {
|
|
202
|
+
if (stopped)
|
|
203
|
+
return;
|
|
204
|
+
const timer = setTimeout(() => {
|
|
205
|
+
if (stopped)
|
|
206
|
+
return;
|
|
207
|
+
if (!inFlight) {
|
|
208
|
+
inFlight = runCheck()
|
|
209
|
+
.catch((err) => {
|
|
210
|
+
failures += 1;
|
|
211
|
+
backoffUntil = Date.now() + exports.FAILURE_BACKOFF_MS;
|
|
212
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
213
|
+
log(`[auto-upgrade] check failed: ${detail}`);
|
|
214
|
+
})
|
|
215
|
+
.finally(() => {
|
|
216
|
+
inFlight = null;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const next = exports.CHECK_INTERVAL_MS + jitter(exports.CHECK_INTERVAL_JITTER_MS);
|
|
220
|
+
scheduleCheck(next);
|
|
221
|
+
}, delay);
|
|
222
|
+
timer.unref?.();
|
|
223
|
+
timers.push(timer);
|
|
224
|
+
};
|
|
225
|
+
// Warm-up first probe, then a jittered 6-hourly cadence.
|
|
226
|
+
scheduleCheck(exports.FIRST_CHECK_DELAY_MS + jitter(exports.FIRST_CHECK_JITTER_MS));
|
|
227
|
+
const sampler = setInterval(sample, exports.SAMPLE_MS);
|
|
228
|
+
sampler.unref?.();
|
|
229
|
+
timers.push(sampler);
|
|
230
|
+
log(`[auto-upgrade] enabled - first check in ${Math.round(exports.FIRST_CHECK_DELAY_MS / 60_000)}-${Math.round((exports.FIRST_CHECK_DELAY_MS + exports.FIRST_CHECK_JITTER_MS) / 60_000)} min, installed ${opts.version}`);
|
|
231
|
+
return () => {
|
|
232
|
+
stopped = true;
|
|
233
|
+
for (const t of timers) {
|
|
234
|
+
clearTimeout(t);
|
|
235
|
+
clearInterval(t);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Spawns the detached `upgrade --auto` helper. Hidden on Windows (the VBS
|
|
241
|
+
* chain is the only primitive that is both window-less and survives this
|
|
242
|
+
* process exiting); setsid-detached elsewhere. Output lands in upgrade.log.
|
|
243
|
+
*/
|
|
244
|
+
function dispatchHelper(port) {
|
|
245
|
+
const argv = [(0, node_path_1.join)(__dirname, 'index.js'), 'upgrade', '--auto', '--port', String(port)];
|
|
246
|
+
if (process.platform === 'win32') {
|
|
247
|
+
(0, spawn_1.launchHiddenVbs)({
|
|
248
|
+
argv,
|
|
249
|
+
capture: upgrade_marker_1.UPGRADE_LOG_PATH,
|
|
250
|
+
vbsPath: (0, node_path_1.join)((0, node_os_1.homedir)(), '.teamshare', 'upgrade-launch.vbs'),
|
|
251
|
+
});
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const out = (0, node_fs_1.openSync)(upgrade_marker_1.UPGRADE_LOG_PATH, 'a');
|
|
255
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, argv, {
|
|
256
|
+
detached: true,
|
|
257
|
+
stdio: ['ignore', out, out],
|
|
258
|
+
windowsHide: true,
|
|
259
|
+
});
|
|
260
|
+
child.unref();
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=auto-upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-upgrade.js","sourceRoot":"","sources":["../../src/bridge/auto-upgrade.ts"],"names":[],"mappings":";;;AA8EA,kCAkBC;AAcD,4CA+KC;AA7RD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2DAA2C;AAC3C,qCAAmC;AACnC,qCAAkC;AAClC,yCAAiC;AACjC,wDAI8B;AAC9B,mCAA0C;AAC1C,qDAK0B;AAE1B,wEAAwE;AAC3D,QAAA,oBAAoB,GAAG,EAAE,GAAG,MAAM,CAAC;AACnC,QAAA,qBAAqB,GAAG,EAAE,GAAG,MAAM,CAAC;AACjD,yBAAyB;AACZ,QAAA,iBAAiB,GAAG,CAAC,GAAG,SAAS,CAAC;AAClC,QAAA,wBAAwB,GAAG,EAAE,GAAG,MAAM,CAAC;AACpD,wEAAwE;AAC3D,QAAA,SAAS,GAAG,MAAM,CAAC;AAChC,8EAA8E;AACjE,QAAA,WAAW,GAAG,EAAE,GAAG,MAAM,CAAC;AACvC,8EAA8E;AACjE,QAAA,aAAa,GAAG,CAAC,GAAG,MAAM,CAAC;AACxC,oEAAoE;AACvD,QAAA,oBAAoB,GAAG,EAAE,GAAG,MAAM,CAAC;AAChD,0DAA0D;AAC7C,QAAA,kBAAkB,GAAG,CAAC,GAAG,SAAS,CAAC;AAChD,wEAAwE;AAC3D,QAAA,YAAY,GAAG,CAAC,CAAC;AAuB9B,6EAA6E;AAC7E,SAAgB,WAAW,C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,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,IAAA,uBAAe,EAAC;YACd,IAAI;YACJ,OAAO,EAAE,iCAAgB;YACzB,OAAO,EAAE,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,YAAY,EAAE,oBAAoB,CAAC;SAC7D,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,MAAM,GAAG,GAAG,IAAA,kBAAQ,EAAC,iCAAgB,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAA,0BAAK,EAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE;QAC1C,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC;QAC3B,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -34,6 +34,15 @@ export declare const HEARTBEAT_MS = 120000;
|
|
|
34
34
|
export declare const PUSH_STATE_MS: number;
|
|
35
35
|
/** Per-agent last-sent bridge-state snapshot (push-on-change diff). */
|
|
36
36
|
export declare const lastBridgeState: Map<string, string>;
|
|
37
|
+
/** Per-agent wall-clock time of the last SENT bridge-state (not just diffed). */
|
|
38
|
+
export declare const lastBridgePushAt: Map<string, number>;
|
|
39
|
+
/**
|
|
40
|
+
* While an agent is BUSY, re-push at least this often even when the payload
|
|
41
|
+
* is byte-identical. The backend gates `busy` on a 5-minute TTL (so a crashed
|
|
42
|
+
* daemon can't pin a permanent Busy), and push-on-change alone would starve a
|
|
43
|
+
* long run of refreshes - 60 s keeps a live run well inside the TTL.
|
|
44
|
+
*/
|
|
45
|
+
export declare const BUSY_REFRESH_MS = 60000;
|
|
37
46
|
/**
|
|
38
47
|
* Stagger counter so N agents never fire their first heartbeat in the
|
|
39
48
|
* same second (multi-agent flood flattening).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lastBridgeState = exports.PUSH_STATE_MS = exports.HEARTBEAT_MS = exports.SIGNAL_DIR = exports.STOP_DIR = exports.BUILD_STATE_DIR = void 0;
|
|
3
|
+
exports.BUSY_REFRESH_MS = exports.lastBridgePushAt = exports.lastBridgeState = exports.PUSH_STATE_MS = exports.HEARTBEAT_MS = exports.SIGNAL_DIR = exports.STOP_DIR = exports.BUILD_STATE_DIR = void 0;
|
|
4
4
|
exports.setSpawnWatchScheduler = setSpawnWatchScheduler;
|
|
5
5
|
exports.callSpawnWatchScheduler = callSpawnWatchScheduler;
|
|
6
6
|
exports.setSessionRunningProbe = setSessionRunningProbe;
|
|
@@ -135,6 +135,15 @@ exports.HEARTBEAT_MS = 120_000;
|
|
|
135
135
|
exports.PUSH_STATE_MS = 5 * 60_000;
|
|
136
136
|
/** Per-agent last-sent bridge-state snapshot (push-on-change diff). */
|
|
137
137
|
exports.lastBridgeState = new Map();
|
|
138
|
+
/** Per-agent wall-clock time of the last SENT bridge-state (not just diffed). */
|
|
139
|
+
exports.lastBridgePushAt = new Map();
|
|
140
|
+
/**
|
|
141
|
+
* While an agent is BUSY, re-push at least this often even when the payload
|
|
142
|
+
* is byte-identical. The backend gates `busy` on a 5-minute TTL (so a crashed
|
|
143
|
+
* daemon can't pin a permanent Busy), and push-on-change alone would starve a
|
|
144
|
+
* long run of refreshes - 60 s keeps a live run well inside the TTL.
|
|
145
|
+
*/
|
|
146
|
+
exports.BUSY_REFRESH_MS = 60_000;
|
|
138
147
|
/** Stagger counter so N agents never fire their first beat in the same second. */
|
|
139
148
|
let agentLoopSeq = 0;
|
|
140
149
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-support.js","sourceRoot":"","sources":["../../src/bridge/daemon-support.ts"],"names":[],"mappings":";;;AAmCA,wDAIC;AAGD,0DAKC;AAED,wDAIC;AAGD,wDAEC;AAgBD,gDAWC;AAQD,oDAyCC;
|
|
1
|
+
{"version":3,"file":"daemon-support.js","sourceRoot":"","sources":["../../src/bridge/daemon-support.ts"],"names":[],"mappings":";;;AAmCA,wDAIC;AAGD,0DAKC;AAED,wDAIC;AAGD,wDAEC;AAgBD,gDAWC;AAQD,oDAyCC;AA8BD,4CAEC;AAOD,kDAcC;AAED,gDAMC;AAED,gDAQC;AAED,4CAMC;AAGD,kBAcC;AAED,oCAaC;AArPD;;;;;;GAMG;AACH,qCAQiB;AACjB,qCAAkC;AAClC,yCAAiC;AAEjC,0CAAuD;AACvD,oDAAoE;AAEpE;;;;GAIG;AACH,IAAI,mBAAmB,GAAyD,IAAI,CAAC;AACrF;;;;GAIG;AACH,IAAI,mBAAmB,GAA0C,IAAI,CAAC;AAEtE,SAAgB,sBAAsB,CACpC,EAA+C;IAE/C,mBAAmB,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,2EAA2E;AAC3E,SAAgB,uBAAuB,CACrC,OAAe,EACf,QAAgB;IAEhB,mBAAmB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,sBAAsB,CACpC,EAAgC;IAEhC,mBAAmB,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,6EAA6E;AAC7E,SAAgB,sBAAsB,CAAC,OAAe;IACpD,OAAO,mBAAmB,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC;AACjD,CAAC;AAED,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAC7D;2EAC2E;AAC3E,MAAM,eAAe,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AACpE,+EAA+E;AAClE,QAAA,eAAe,GAAG,IAAA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KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG,GAAG,CAAC;AAClF,CAAC"}
|
package/dist/bridge/daemon.js
CHANGED
|
@@ -34,6 +34,8 @@ const local_server_1 = require("./local-server");
|
|
|
34
34
|
const orchestrator_1 = require("../lib/orchestrator");
|
|
35
35
|
const manager_1 = require("../lib/browser/manager");
|
|
36
36
|
const session_relay_1 = require("./session-relay");
|
|
37
|
+
const version_check_1 = require("../lib/version-check");
|
|
38
|
+
const auto_upgrade_1 = require("./auto-upgrade");
|
|
37
39
|
const daemon_support_1 = require("./daemon-support");
|
|
38
40
|
const wake_handler_1 = require("./wake-handler");
|
|
39
41
|
const daemon_inbox_1 = require("./daemon-inbox");
|
|
@@ -219,7 +221,27 @@ async function runDaemon(portOverride) {
|
|
|
219
221
|
// WAKE_QUEUE_STUCK must ignore healthy long runs (see module-level probe).
|
|
220
222
|
(0, daemon_support_1.setSessionRunningProbe)((id) => Boolean(sessionRelay.current(id)));
|
|
221
223
|
const { server, port: boundPort } = await (0, local_server_1.startProbeServer)(port, getStatus, () => syncAgents(), pushAllStates, {
|
|
222
|
-
sessionStart: (body) =>
|
|
224
|
+
sessionStart: (body) => {
|
|
225
|
+
const start = body;
|
|
226
|
+
const ok = sessionRelay.sessionStart(start);
|
|
227
|
+
// BUSY APPEARS FAST (status indicator): push state immediately when a
|
|
228
|
+
// session starts instead of waiting for the first beat (30-90 s), the
|
|
229
|
+
// 5-min timer or the next transition. The CLI acquires its lock before
|
|
230
|
+
// posting session:start, so this snapshot already reads busy=true with
|
|
231
|
+
// the right kind/since - runs shorter than the next tick used to never
|
|
232
|
+
// show Busy at all. Covers task/run/chat/build AND tool sessions
|
|
233
|
+
// (research, doc-job), which post through the same probe endpoint.
|
|
234
|
+
const handle = handles.get(start.agentId);
|
|
235
|
+
if (handle) {
|
|
236
|
+
try {
|
|
237
|
+
handle.pushState();
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
/* best-effort */
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return ok;
|
|
244
|
+
},
|
|
223
245
|
sessionOutput: (body) => sessionRelay.sessionOutput(body),
|
|
224
246
|
sessionEnd: (body) => {
|
|
225
247
|
// Find the agentId by checking which agent owns this session.
|
|
@@ -554,9 +576,24 @@ async function runDaemon(portOverride) {
|
|
|
554
576
|
projects: Object.fromEntries(Object.entries(status.projects).map(([id, link]) => [id, { path: link.path, guard: link.guard ?? true }])),
|
|
555
577
|
};
|
|
556
578
|
const snapshot = JSON.stringify(payload);
|
|
557
|
-
|
|
579
|
+
const now = Date.now();
|
|
580
|
+
const lastPushAt = daemon_support_1.lastBridgePushAt.get(agent.agentId) ?? 0;
|
|
581
|
+
// Push-on-change stays the default (idle agents remain near-silent),
|
|
582
|
+
// but two timers break the suppression:
|
|
583
|
+
// - busy states re-push every BUSY_REFRESH_MS so the backend's 5-min
|
|
584
|
+
// TTL never expires a live run mid-session;
|
|
585
|
+
// - any state re-pushes every PUSH_STATE_MS so a backend restart
|
|
586
|
+
// (in-memory store wiped) is re-populated without waiting for a
|
|
587
|
+
// transition.
|
|
588
|
+
const stalePush = now - lastPushAt >= daemon_support_1.PUSH_STATE_MS;
|
|
589
|
+
const busyRefresh = payload.busy && now - lastPushAt >= daemon_support_1.BUSY_REFRESH_MS;
|
|
590
|
+
if (daemon_support_1.lastBridgeState.get(agent.agentId) === snapshot &&
|
|
591
|
+
!stalePush &&
|
|
592
|
+
!busyRefresh) {
|
|
558
593
|
return;
|
|
594
|
+
}
|
|
559
595
|
daemon_support_1.lastBridgeState.set(agent.agentId, snapshot);
|
|
596
|
+
daemon_support_1.lastBridgePushAt.set(agent.agentId, now);
|
|
560
597
|
api
|
|
561
598
|
.pushBridgeState(agent.agentId, payload)
|
|
562
599
|
.catch((err) => (0, daemon_support_1.log)(`agent ${agent.agentId}: bridge-state push failed: ${(0, config_1.msg)(err)}`));
|
|
@@ -628,7 +665,11 @@ async function runDaemon(portOverride) {
|
|
|
628
665
|
if (!timersCreated) {
|
|
629
666
|
timersCreated = true;
|
|
630
667
|
agentTimers.push(setInterval(heartbeat, daemon_support_1.HEARTBEAT_MS));
|
|
631
|
-
|
|
668
|
+
// Tick every BUSY_REFRESH_MS (60 s): pushState itself diff-suppresses
|
|
669
|
+
// unchanged idle payloads (they still force-push every PUSH_STATE_MS
|
|
670
|
+
// so a backend restart repopulates), while a BUSY payload re-pushes on
|
|
671
|
+
// every tick to stay inside the backend's 5-minute TTL.
|
|
672
|
+
agentTimers.push(setInterval(pushState, daemon_support_1.BUSY_REFRESH_MS));
|
|
632
673
|
// Periodic mention poll + stranded-assignment recovery
|
|
633
674
|
// (daemon-inbox.ts): catches wakes lost while connected.
|
|
634
675
|
agentTimers.push(setInterval(() => void (0, daemon_inbox_1.pollInboxMentions)(inboxDeps()), daemon_inbox_1.MENTION_POLL_MS));
|
|
@@ -722,7 +763,7 @@ async function runDaemon(portOverride) {
|
|
|
722
763
|
}
|
|
723
764
|
}
|
|
724
765
|
if (stopCwd) {
|
|
725
|
-
const gitRoots = (0, git_pipeline_1.
|
|
766
|
+
const gitRoots = (0, git_pipeline_1.resolveRunRepos)(stopCwd);
|
|
726
767
|
for (const root of gitRoots) {
|
|
727
768
|
const stashes = (0, git_runner_1.listStashes)(root, stopCwd, taskIdForStop);
|
|
728
769
|
const target = stashes.find((s) => s.taskId === taskIdForStop);
|
|
@@ -999,8 +1040,63 @@ async function runDaemon(portOverride) {
|
|
|
999
1040
|
}
|
|
1000
1041
|
}, lock_1.LOCK_POLL_MS);
|
|
1001
1042
|
timers.push(flushInterval);
|
|
1043
|
+
// ── Silent auto-upgrade (2026-09) ──────────────────────────────────────
|
|
1044
|
+
// The daemon installs the newest published `teamshare-bridge` on its own
|
|
1045
|
+
// once THIS machine has been fully idle: no session lock, no live session,
|
|
1046
|
+
// no queued/folder-waiting wakes and nothing started in the last few
|
|
1047
|
+
// minutes. Opt out with `teamshare-bridge auto-upgrade off` (config
|
|
1048
|
+
// autoUpgrade).
|
|
1049
|
+
//
|
|
1050
|
+
// WAKE_QUIET only has to cover the gap between a wake arriving and its
|
|
1051
|
+
// session taking the agent lock (hidden launch + node boot + settings
|
|
1052
|
+
// fetch - seconds). After that the lock/queue/session checks take over,
|
|
1053
|
+
// so the 10-min continuous-idle window in idleVerdict stays the real gate.
|
|
1054
|
+
const WAKE_QUIET_MS = 2 * 60_000;
|
|
1055
|
+
const machineBusy = () => {
|
|
1056
|
+
for (const agent of (0, config_1.loadConfig)().agents) {
|
|
1057
|
+
if ((0, lock_1.isLockBusy)(agent.agentId)) {
|
|
1058
|
+
return `agent ${agent.agentId} holds a session lock`;
|
|
1059
|
+
}
|
|
1060
|
+
if (sessionRelay.current(agent.agentId)) {
|
|
1061
|
+
return `agent ${agent.agentId} has a live session`;
|
|
1062
|
+
}
|
|
1063
|
+
if ((wakeQueue.get(agent.agentId)?.length ?? 0) > 0) {
|
|
1064
|
+
return `agent ${agent.agentId} has queued wakes`;
|
|
1065
|
+
}
|
|
1066
|
+
const lastWake = lastWakeByAgent.get(agent.agentId);
|
|
1067
|
+
if (lastWake) {
|
|
1068
|
+
const ago = Date.now() - Date.parse(lastWake);
|
|
1069
|
+
if (Number.isFinite(ago) && ago < WAKE_QUIET_MS) {
|
|
1070
|
+
return `a wake landed ${Math.round(ago / 1000)}s ago`;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
for (const entries of wake_handler_1.folderWaitQueue.values()) {
|
|
1075
|
+
if (entries.length > 0)
|
|
1076
|
+
return 'a wake is waiting for a busy folder';
|
|
1077
|
+
}
|
|
1078
|
+
return null;
|
|
1079
|
+
};
|
|
1080
|
+
let stopAutoUpgrade = () => { };
|
|
1081
|
+
stopAutoUpgrade = (0, auto_upgrade_1.startAutoUpgrade)({
|
|
1082
|
+
log: daemon_support_1.log,
|
|
1083
|
+
enabled: () => (0, config_1.loadConfig)().autoUpgrade !== false,
|
|
1084
|
+
busyReason: machineBusy,
|
|
1085
|
+
version: (0, version_check_1.currentVersion)(),
|
|
1086
|
+
port: boundPort,
|
|
1087
|
+
shutdown: () => shutdown(),
|
|
1088
|
+
report: async (severity, message, context) => {
|
|
1089
|
+
await (0, diagnostics_1.reportDiagnostic)({
|
|
1090
|
+
kind: 'auto_upgrade',
|
|
1091
|
+
severity,
|
|
1092
|
+
message,
|
|
1093
|
+
...(context ? { context } : {}),
|
|
1094
|
+
});
|
|
1095
|
+
},
|
|
1096
|
+
});
|
|
1002
1097
|
const shutdown = () => {
|
|
1003
1098
|
(0, daemon_support_1.log)('shutting down');
|
|
1099
|
+
stopAutoUpgrade();
|
|
1004
1100
|
if (watchDebounce)
|
|
1005
1101
|
clearTimeout(watchDebounce);
|
|
1006
1102
|
try {
|