@staff0rd/assist 0.1092.3 → 0.1093.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.
- package/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +413 -413
- package/dist/index.js +102 -58
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1093.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -880,7 +880,8 @@ var assistConfigShape = {
|
|
|
880
880
|
}).optional(),
|
|
881
881
|
autoUpdate: z6.strictObject({
|
|
882
882
|
enabled: z6.boolean().default(true),
|
|
883
|
-
restart: z6.boolean().default(false)
|
|
883
|
+
restart: z6.boolean().default(false),
|
|
884
|
+
idleMinutes: z6.number().positive().default(2)
|
|
884
885
|
}).optional(),
|
|
885
886
|
worktree: z6.strictObject({
|
|
886
887
|
enabled: z6.boolean().default(false),
|
|
@@ -1450,26 +1451,35 @@ function stripLegacyReviewKeys(review2) {
|
|
|
1450
1451
|
return { ...rest, highLevel: kept };
|
|
1451
1452
|
}
|
|
1452
1453
|
|
|
1453
|
-
// src/shared/
|
|
1454
|
-
var
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1454
|
+
// src/shared/stripLegacySectionKeys.ts
|
|
1455
|
+
var LEGACY_SECTION_KEYS = {
|
|
1456
|
+
sessions: [
|
|
1457
|
+
"windowsProjectsRoot",
|
|
1458
|
+
"windowsDaemonHost",
|
|
1459
|
+
"windowsDaemonPort",
|
|
1460
|
+
"windowsVersionCheck",
|
|
1461
|
+
"topBar",
|
|
1462
|
+
"floatWaiting",
|
|
1463
|
+
"floatWaitingAfterMs",
|
|
1464
|
+
"parkWaitingAfterMs",
|
|
1465
|
+
"askQuestionAutoApprove"
|
|
1466
|
+
],
|
|
1467
|
+
worktree: ["watcher", "includeDrafts"],
|
|
1468
|
+
devlog: ["skip"],
|
|
1469
|
+
testflight: ["account"]
|
|
1470
|
+
};
|
|
1467
1471
|
function withoutKeys(value, keys) {
|
|
1468
1472
|
if (!value || typeof value !== "object") return value;
|
|
1469
1473
|
const rest = { ...value };
|
|
1470
1474
|
for (const key of keys) delete rest[key];
|
|
1471
1475
|
return rest;
|
|
1472
1476
|
}
|
|
1477
|
+
function stripLegacySectionKeys(config) {
|
|
1478
|
+
for (const [section2, keys] of Object.entries(LEGACY_SECTION_KEYS))
|
|
1479
|
+
if (config[section2]) config[section2] = withoutKeys(config[section2], keys);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
// src/shared/stripLegacyConfigKeys.ts
|
|
1473
1483
|
function stripRepos(repos2) {
|
|
1474
1484
|
if (!repos2 || typeof repos2 !== "object") return repos2;
|
|
1475
1485
|
return Object.fromEntries(
|
|
@@ -1490,12 +1500,7 @@ function stripLegacyConfigKeys(config) {
|
|
|
1490
1500
|
const { feeds: _feeds, ...rest } = news;
|
|
1491
1501
|
stripped.news = rest;
|
|
1492
1502
|
}
|
|
1493
|
-
|
|
1494
|
-
stripped.sessions = withoutKeys(stripped.sessions, LEGACY_SESSIONS_KEYS);
|
|
1495
|
-
if (stripped.worktree)
|
|
1496
|
-
stripped.worktree = withoutKeys(stripped.worktree, LEGACY_WORKTREE_KEYS);
|
|
1497
|
-
if (stripped.devlog)
|
|
1498
|
-
stripped.devlog = withoutKeys(stripped.devlog, LEGACY_DEVLOG_KEYS);
|
|
1503
|
+
stripLegacySectionKeys(stripped);
|
|
1499
1504
|
if (stripped.review) stripped.review = stripLegacyReviewKeys(stripped.review);
|
|
1500
1505
|
return stripped;
|
|
1501
1506
|
}
|
|
@@ -6469,6 +6474,11 @@ var autoUpdateConfigHelp = [
|
|
|
6469
6474
|
key: "autoUpdate.restart",
|
|
6470
6475
|
setter: "assist config set autoUpdate.restart true --node",
|
|
6471
6476
|
note: "the node's web server applies a ready update itself, restarting the daemon and/or web server once every live agent session has been awaiting the user for a minute (or there are none); skipped while the build is pending, the loop is diverged or paused, and attempted once per built version. Toggle it per node from the Updates page (default off)"
|
|
6477
|
+
},
|
|
6478
|
+
{
|
|
6479
|
+
key: "autoUpdate.idleMinutes",
|
|
6480
|
+
setter: "assist config set autoUpdate.idleMinutes 5 --node",
|
|
6481
|
+
note: "with autoUpdate.restart on, hold the auto-restart until the web UI has seen no pointer, keyboard, wheel or touch input for this many minutes (default 2)"
|
|
6472
6482
|
}
|
|
6473
6483
|
];
|
|
6474
6484
|
|
|
@@ -14846,24 +14856,6 @@ function autoRestartAttempts(port, path110 = defaultPath) {
|
|
|
14846
14856
|
};
|
|
14847
14857
|
}
|
|
14848
14858
|
|
|
14849
|
-
// src/commands/sessions/web/updates/autoRestart/attemptAutoRestart.ts
|
|
14850
|
-
async function attemptAutoRestart(deps2, target, built) {
|
|
14851
|
-
deps2.attempted.set(built);
|
|
14852
|
-
deps2.log(`auto-restart: restarting ${target} to apply v${built}`);
|
|
14853
|
-
try {
|
|
14854
|
-
await deps2.restart(target);
|
|
14855
|
-
} catch (error) {
|
|
14856
|
-
deps2.log(
|
|
14857
|
-
`auto-restart: ${target} restart for v${built} failed: ${error instanceof Error ? error.message : String(error)}`
|
|
14858
|
-
);
|
|
14859
|
-
}
|
|
14860
|
-
}
|
|
14861
|
-
|
|
14862
|
-
// src/commands/sessions/web/updates/autoRestart/autoRestartTarget.ts
|
|
14863
|
-
function autoRestartTarget(restart) {
|
|
14864
|
-
return restart.length > 1 ? "both" : restart[0];
|
|
14865
|
-
}
|
|
14866
|
-
|
|
14867
14859
|
// src/commands/sessions/shared/isBusy.ts
|
|
14868
14860
|
function isBusy(session) {
|
|
14869
14861
|
if (session.node !== void 0 || session.commandType === "run") return false;
|
|
@@ -14873,7 +14865,12 @@ function isBusy(session) {
|
|
|
14873
14865
|
}
|
|
14874
14866
|
|
|
14875
14867
|
// src/commands/sessions/web/updates/autoRestart/autoRestartBlocker.ts
|
|
14876
|
-
|
|
14868
|
+
var DEFAULT_IDLE_MINUTES = 2;
|
|
14869
|
+
function userActive(input, now) {
|
|
14870
|
+
const idleMinutes = input.idleMinutes ?? DEFAULT_IDLE_MINUTES;
|
|
14871
|
+
return input.lastUserActivityAt !== void 0 && now - input.lastUserActivityAt < idleMinutes * 6e4;
|
|
14872
|
+
}
|
|
14873
|
+
function autoRestartBlocker(input, now) {
|
|
14877
14874
|
if (input.buildPending) return "build pending";
|
|
14878
14875
|
if (!input.loop) return "daemon not reachable";
|
|
14879
14876
|
if (input.loop.paused) return "auto-update paused";
|
|
@@ -14881,13 +14878,42 @@ function autoRestartBlocker(input) {
|
|
|
14881
14878
|
const busy = input.sessions.filter(isBusy);
|
|
14882
14879
|
if (busy.length > 0)
|
|
14883
14880
|
return `waiting on ${busy.length} running session${busy.length === 1 ? "" : "s"} (${busy.map((s) => s.name).join(", ")})`;
|
|
14881
|
+
if (userActive(input, now))
|
|
14882
|
+
return `you're active \xB7 restarting ${input.idleMinutes ?? DEFAULT_IDLE_MINUTES}m after you stop`;
|
|
14884
14883
|
return void 0;
|
|
14885
14884
|
}
|
|
14886
14885
|
|
|
14886
|
+
// src/commands/sessions/web/updates/autoRestart/autoRestartIdleMinutes.ts
|
|
14887
|
+
function autoRestartIdleMinutes(installDir) {
|
|
14888
|
+
try {
|
|
14889
|
+
return loadConfigFrom(installDir).autoUpdate?.idleMinutes ?? DEFAULT_IDLE_MINUTES;
|
|
14890
|
+
} catch {
|
|
14891
|
+
return DEFAULT_IDLE_MINUTES;
|
|
14892
|
+
}
|
|
14893
|
+
}
|
|
14894
|
+
|
|
14895
|
+
// src/commands/sessions/web/updates/autoRestart/attemptAutoRestart.ts
|
|
14896
|
+
async function attemptAutoRestart(deps2, target, built) {
|
|
14897
|
+
deps2.attempted.set(built);
|
|
14898
|
+
deps2.log(`auto-restart: restarting ${target} to apply v${built}`);
|
|
14899
|
+
try {
|
|
14900
|
+
await deps2.restart(target);
|
|
14901
|
+
} catch (error) {
|
|
14902
|
+
deps2.log(
|
|
14903
|
+
`auto-restart: ${target} restart for v${built} failed: ${error instanceof Error ? error.message : String(error)}`
|
|
14904
|
+
);
|
|
14905
|
+
}
|
|
14906
|
+
}
|
|
14907
|
+
|
|
14908
|
+
// src/commands/sessions/web/updates/autoRestart/autoRestartTarget.ts
|
|
14909
|
+
function autoRestartTarget(restart) {
|
|
14910
|
+
return restart.length > 1 ? "both" : restart[0];
|
|
14911
|
+
}
|
|
14912
|
+
|
|
14887
14913
|
// src/commands/sessions/web/updates/autoRestart/blockedBy.ts
|
|
14888
|
-
function blockedBy(snap, attempted2) {
|
|
14914
|
+
function blockedBy(snap, attempted2, now) {
|
|
14889
14915
|
if (attempted2 === snap.built) return "already attempted";
|
|
14890
|
-
return autoRestartBlocker(snap);
|
|
14916
|
+
return autoRestartBlocker(snap, now);
|
|
14891
14917
|
}
|
|
14892
14918
|
|
|
14893
14919
|
// src/commands/sessions/web/updates/autoRestart/createAutoRestartNotes.ts
|
|
@@ -14920,10 +14946,17 @@ function createAutoRestartNotes(deps2) {
|
|
|
14920
14946
|
}
|
|
14921
14947
|
|
|
14922
14948
|
// src/commands/sessions/web/updates/autoRestart/autoRestartPreflight.ts
|
|
14923
|
-
async function autoRestartPreflight(deps2, snap, activity2) {
|
|
14949
|
+
async function autoRestartPreflight(deps2, snap, activity2, now) {
|
|
14924
14950
|
const fresh = await deps2.freshSessions();
|
|
14925
14951
|
if (!fresh) return "daemon not reachable";
|
|
14926
|
-
return blockedBy({ ...snap, ...fresh }, deps2.attempted.get()) ?? (fresh.restartActivity !== activity2 ? "session activity changed" : void 0);
|
|
14952
|
+
return blockedBy({ ...snap, ...fresh }, deps2.attempted.get(), now()) ?? (fresh.restartActivity !== activity2 ? "session activity changed" : void 0);
|
|
14953
|
+
}
|
|
14954
|
+
|
|
14955
|
+
// src/commands/sessions/web/updates/autoRestart/noteSkipped.ts
|
|
14956
|
+
function noteSkipped(note, target, built, blocker) {
|
|
14957
|
+
if (!blocker) return false;
|
|
14958
|
+
note(`skipped ${target} restart for v${built}: ${blocker}`, blocker);
|
|
14959
|
+
return true;
|
|
14927
14960
|
}
|
|
14928
14961
|
|
|
14929
14962
|
// src/commands/sessions/web/updates/autoRestart/createAutoRestartCheck.ts
|
|
@@ -14941,19 +14974,11 @@ function createAutoRestartCheck(deps2) {
|
|
|
14941
14974
|
}
|
|
14942
14975
|
if (snap.restart.length === 0) return note(void 0);
|
|
14943
14976
|
const target = autoRestartTarget(snap.restart);
|
|
14944
|
-
const blocker = blockedBy(snap, deps2.attempted.get());
|
|
14945
|
-
if (blocker)
|
|
14946
|
-
return note(
|
|
14947
|
-
`skipped ${target} restart for v${snap.built}: ${blocker}`,
|
|
14948
|
-
blocker
|
|
14949
|
-
);
|
|
14977
|
+
const blocker = blockedBy(snap, deps2.attempted.get(), now());
|
|
14978
|
+
if (noteSkipped(note, target, snap.built, blocker)) return;
|
|
14950
14979
|
if (!notes.settled(now(), target, snap.built)) return;
|
|
14951
|
-
const finalBlocker = await autoRestartPreflight(deps2, snap, activity2);
|
|
14952
|
-
if (finalBlocker)
|
|
14953
|
-
return note(
|
|
14954
|
-
`skipped ${target} restart for v${snap.built}: ${finalBlocker}`,
|
|
14955
|
-
finalBlocker
|
|
14956
|
-
);
|
|
14980
|
+
const finalBlocker = await autoRestartPreflight(deps2, snap, activity2, now);
|
|
14981
|
+
if (noteSkipped(note, target, snap.built, finalBlocker)) return;
|
|
14957
14982
|
note(void 0, "restarting");
|
|
14958
14983
|
await attemptAutoRestart(deps2, target, snap.built);
|
|
14959
14984
|
};
|
|
@@ -14986,7 +15011,9 @@ async function snapshot(installDir) {
|
|
|
14986
15011
|
restart: state.restart,
|
|
14987
15012
|
loop: greeting ? state.reply?.loop : void 0,
|
|
14988
15013
|
sessions: greeting?.sessions ?? [],
|
|
14989
|
-
restartActivity: greeting?.restartActivity
|
|
15014
|
+
restartActivity: greeting?.restartActivity,
|
|
15015
|
+
lastUserActivityAt: greeting?.lastUserActivityAt,
|
|
15016
|
+
idleMinutes: autoRestartIdleMinutes(installDir)
|
|
14990
15017
|
};
|
|
14991
15018
|
}
|
|
14992
15019
|
function startAutoRestart(port) {
|
|
@@ -51529,6 +51556,20 @@ function toSessionInfo(session) {
|
|
|
51529
51556
|
};
|
|
51530
51557
|
}
|
|
51531
51558
|
|
|
51559
|
+
// src/commands/sessions/daemon/userActivity.ts
|
|
51560
|
+
var LOG_AFTER_IDLE_MS = 6e4;
|
|
51561
|
+
var lastAt;
|
|
51562
|
+
var userActivity = {
|
|
51563
|
+
get: () => lastAt,
|
|
51564
|
+
record: (at2 = Date.now()) => {
|
|
51565
|
+
if (lastAt === void 0 || at2 - lastAt > LOG_AFTER_IDLE_MS)
|
|
51566
|
+
daemonLog(
|
|
51567
|
+
`user-activity: web UI in use${lastAt === void 0 ? "" : ` after ${Math.round((at2 - lastAt) / 1e3)}s idle`}`
|
|
51568
|
+
);
|
|
51569
|
+
lastAt = at2;
|
|
51570
|
+
}
|
|
51571
|
+
};
|
|
51572
|
+
|
|
51532
51573
|
// src/commands/sessions/daemon/broadcastSessions.ts
|
|
51533
51574
|
var activityCounts = /* @__PURE__ */ new WeakMap();
|
|
51534
51575
|
function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
@@ -51537,10 +51578,12 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
51537
51578
|
const count10 = (activityCounts.get(sessions) ?? 0) + (local.some(isBusy) ? 1 : 0);
|
|
51538
51579
|
activityCounts.set(sessions, count10);
|
|
51539
51580
|
const restartActivity = `${process.pid}:${count10}`;
|
|
51581
|
+
const lastUserActivityAt = userActivity.get();
|
|
51540
51582
|
const viewers = clients.viewers();
|
|
51541
51583
|
broadcast(viewers, {
|
|
51542
51584
|
type: "sessions",
|
|
51543
51585
|
restartActivity,
|
|
51586
|
+
lastUserActivityAt,
|
|
51544
51587
|
sessions: local.concat(linkedSessions),
|
|
51545
51588
|
active: active?.toJSON() ?? {}
|
|
51546
51589
|
});
|
|
@@ -59865,6 +59908,7 @@ var messageHandlers = {
|
|
|
59865
59908
|
},
|
|
59866
59909
|
"pr-preview": (client, m, d) => m.prPreview.set(client, d),
|
|
59867
59910
|
"pr-decision": routed((_client, m, d) => m.prPreview.decide(d)),
|
|
59911
|
+
"user-activity": () => userActivity.record(),
|
|
59868
59912
|
"ui-status": (_client, _m, d) => daemonLog(`ui rendered: id=${d.sessionId} status=${d.status}`)
|
|
59869
59913
|
};
|
|
59870
59914
|
|