@staff0rd/assist 0.318.8 → 0.318.9
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 +34 -7
- 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.318.
|
|
9
|
+
version: "0.318.9",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -20481,7 +20481,10 @@ function restoreOne(persisted, spawn12, sessions) {
|
|
|
20481
20481
|
logUnresumable(persisted.name, id2, sessions.get(id2));
|
|
20482
20482
|
} catch (error) {
|
|
20483
20483
|
const reason = logRestoreError(persisted.name, error);
|
|
20484
|
-
|
|
20484
|
+
try {
|
|
20485
|
+
spawn12((id2) => errorSession(id2, persisted, reason));
|
|
20486
|
+
} catch {
|
|
20487
|
+
}
|
|
20485
20488
|
}
|
|
20486
20489
|
}
|
|
20487
20490
|
function logUnresumable(name, id2, session) {
|
|
@@ -20496,11 +20499,35 @@ function logRestoreError(name, error) {
|
|
|
20496
20499
|
return reason;
|
|
20497
20500
|
}
|
|
20498
20501
|
|
|
20502
|
+
// src/commands/sessions/daemon/sessionLimits.ts
|
|
20503
|
+
var MAX_LIVE = 12;
|
|
20504
|
+
var MAX_RESTORE = 10;
|
|
20505
|
+
var sessionLimits = {
|
|
20506
|
+
maxRestore: MAX_RESTORE,
|
|
20507
|
+
/** Allocate the next session id from counter, refusing past the absolute
|
|
20508
|
+
* ceiling regardless of caller (restore, web create, retry) so no trigger
|
|
20509
|
+
* can fan out without bound. The counter advances only when allowed. */
|
|
20510
|
+
nextId(liveCount, counter) {
|
|
20511
|
+
if (liveCount >= MAX_LIVE) {
|
|
20512
|
+
daemonLog(`refusing to spawn: at ceiling of ${MAX_LIVE} live sessions`);
|
|
20513
|
+
throw new Error(`session ceiling of ${MAX_LIVE} reached`);
|
|
20514
|
+
}
|
|
20515
|
+
return String(counter.next++);
|
|
20516
|
+
}
|
|
20517
|
+
};
|
|
20518
|
+
|
|
20499
20519
|
// src/commands/sessions/daemon/restoreAll.ts
|
|
20500
20520
|
function restoreAll(spawn12, sessions) {
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20521
|
+
const persisted = loadPersistedSessions();
|
|
20522
|
+
const toRestore = persisted.slice(0, sessionLimits.maxRestore);
|
|
20523
|
+
const skipped = persisted.length - toRestore.length;
|
|
20524
|
+
if (skipped > 0)
|
|
20525
|
+
daemonLog(
|
|
20526
|
+
`restore capped at ${sessionLimits.maxRestore}; skipping ${skipped} persisted session(s)`
|
|
20527
|
+
);
|
|
20528
|
+
return toRestore.map((persisted2) => {
|
|
20529
|
+
restoreOne(persisted2, spawn12, sessions);
|
|
20530
|
+
return persisted2.name;
|
|
20504
20531
|
});
|
|
20505
20532
|
}
|
|
20506
20533
|
|
|
@@ -21233,7 +21260,7 @@ var SessionManager = class {
|
|
|
21233
21260
|
// why: dispatch calls active.set() on card click; broadcasts include active.toJSON()
|
|
21234
21261
|
active = new ActiveSelection(() => this.notify());
|
|
21235
21262
|
clients = new ClientHub(persistUsagePeak);
|
|
21236
|
-
|
|
21263
|
+
idCounter = { next: 1 };
|
|
21237
21264
|
shuttingDown = false;
|
|
21238
21265
|
// why: dispatch calls windowsProxy.route() to forward windows-origin sessions
|
|
21239
21266
|
windowsProxy = new WindowsProxy(this.clients, () => this.notify());
|
|
@@ -21259,7 +21286,7 @@ var SessionManager = class {
|
|
|
21259
21286
|
watchActivity(session, this.notify);
|
|
21260
21287
|
return session.id;
|
|
21261
21288
|
}
|
|
21262
|
-
spawnWith = (create) => this.add(create(
|
|
21289
|
+
spawnWith = (create) => this.add(create(sessionLimits.nextId(this.sessions.size, this.idCounter)));
|
|
21263
21290
|
spawn(prompt, cwd) {
|
|
21264
21291
|
return this.spawnWith((id2) => createSession(id2, prompt, cwd));
|
|
21265
21292
|
}
|