@dench.com/cli 3.11.43-staging.878 → 3.11.44-staging.887
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/dench.ts +59 -3
- package/lib/command-registry.ts +2 -1
- package/lib/references.generated.json +5 -5
- package/package.json +1 -1
package/dench.ts
CHANGED
|
@@ -166,6 +166,9 @@ const api = {
|
|
|
166
166
|
pollSignInRequest: makeFunctionReference<"mutation">(
|
|
167
167
|
"functions/agentWorkspace:pollSignInRequest",
|
|
168
168
|
),
|
|
169
|
+
revokeOwnAgentSession: makeFunctionReference<"mutation">(
|
|
170
|
+
"functions/agentWorkspace:revokeOwnAgentSession",
|
|
171
|
+
),
|
|
169
172
|
whatCanIDoHere: makeFunctionReference<"query">(
|
|
170
173
|
"functions/agentWorkspace:whatCanIDoHere",
|
|
171
174
|
),
|
|
@@ -832,6 +835,7 @@ Usage:
|
|
|
832
835
|
|
|
833
836
|
Notes:
|
|
834
837
|
dench logout removes only the current selected session for this local agent context.
|
|
838
|
+
It also ends that sign-in on the Dench server, so its token stops working everywhere.
|
|
835
839
|
Other saved sessions can still be reused by future chats until removed.
|
|
836
840
|
Use dench logout --all to clear every saved Dench session on this machine.
|
|
837
841
|
`);
|
|
@@ -1478,6 +1482,50 @@ async function selectSession() {
|
|
|
1478
1482
|
);
|
|
1479
1483
|
}
|
|
1480
1484
|
|
|
1485
|
+
const LOGOUT_REVOKE_TIMEOUT_MS = 10_000;
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* End saved sign-ins on the server before they are removed locally, so the
|
|
1489
|
+
* token stops working everywhere, not just on this machine (DEN-247). Best
|
|
1490
|
+
* effort: a server that cannot be reached (offline, or one that predates
|
|
1491
|
+
* `revokeOwnAgentSession`) never blocks the local logout; it is reported as
|
|
1492
|
+
* `serverRevokeFailed` and the session still expires on its own.
|
|
1493
|
+
*/
|
|
1494
|
+
async function revokeSessionsOnServer(sessions: StoredSession[]) {
|
|
1495
|
+
let revoked = 0;
|
|
1496
|
+
let failed = 0;
|
|
1497
|
+
for (const session of sessions) {
|
|
1498
|
+
if (!session.convexUrl || !session.sessionToken) continue;
|
|
1499
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
1500
|
+
try {
|
|
1501
|
+
const result = (await Promise.race([
|
|
1502
|
+
createCliConvexClient(session.convexUrl).mutation(
|
|
1503
|
+
api.functions.agentWorkspace.revokeOwnAgentSession,
|
|
1504
|
+
{ sessionToken: session.sessionToken },
|
|
1505
|
+
),
|
|
1506
|
+
new Promise((_, reject) => {
|
|
1507
|
+
timer = setTimeout(
|
|
1508
|
+
() => reject(new Error("timed out")),
|
|
1509
|
+
LOGOUT_REVOKE_TIMEOUT_MS,
|
|
1510
|
+
);
|
|
1511
|
+
}),
|
|
1512
|
+
])) as { revoked?: boolean } | null;
|
|
1513
|
+
if (result?.revoked) revoked += 1;
|
|
1514
|
+
} catch {
|
|
1515
|
+
failed += 1;
|
|
1516
|
+
} finally {
|
|
1517
|
+
if (timer) clearTimeout(timer);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return { serverRevoked: revoked, serverRevokeFailed: failed };
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
function serverRevokeNote(result: { serverRevokeFailed: number }) {
|
|
1524
|
+
const failed = result.serverRevokeFailed;
|
|
1525
|
+
if (failed === 0) return "";
|
|
1526
|
+
return `\nCould not reach Dench to end ${plural(failed, "session")} on the server; ${failed === 1 ? "it stays" : "they stay"} valid until expiry.`;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1481
1529
|
async function logout() {
|
|
1482
1530
|
const config = await loadConfig();
|
|
1483
1531
|
const scope = resolveSessionScope({ args: filteredArgs });
|
|
@@ -1490,6 +1538,9 @@ async function logout() {
|
|
|
1490
1538
|
}
|
|
1491
1539
|
const entries = listStoredSessionEntries(config, host);
|
|
1492
1540
|
const removed = entries.length;
|
|
1541
|
+
const server = await revokeSessionsOnServer(
|
|
1542
|
+
entries.map((entry) => entry.session),
|
|
1543
|
+
);
|
|
1493
1544
|
const nextConfig = host
|
|
1494
1545
|
? removeSessionEntries(config, entries)
|
|
1495
1546
|
: removeAllStoredSessions(config);
|
|
@@ -1510,13 +1561,14 @@ async function logout() {
|
|
|
1510
1561
|
removed,
|
|
1511
1562
|
all: true,
|
|
1512
1563
|
host: host ?? null,
|
|
1564
|
+
...server,
|
|
1513
1565
|
remainingSessions: remaining.total,
|
|
1514
1566
|
remainingHostSessions: remaining.forHost ?? null,
|
|
1515
1567
|
nextActions: logoutNextActions(remaining, host),
|
|
1516
1568
|
}
|
|
1517
1569
|
: removed > 0
|
|
1518
1570
|
? formatLogoutMessage(
|
|
1519
|
-
`Logged out of ${plural(removed, "Dench session")}
|
|
1571
|
+
`Logged out of ${plural(removed, "Dench session")}.${serverRevokeNote(server)}`,
|
|
1520
1572
|
remaining,
|
|
1521
1573
|
host,
|
|
1522
1574
|
)
|
|
@@ -1540,6 +1592,7 @@ async function logout() {
|
|
|
1540
1592
|
);
|
|
1541
1593
|
}
|
|
1542
1594
|
|
|
1595
|
+
const server = await revokeSessionsOnServer([matches[0].session]);
|
|
1543
1596
|
const nextConfig = removeSessionEntries(config, matches);
|
|
1544
1597
|
const remaining = logoutRemainingSummary(nextConfig, matches[0].host);
|
|
1545
1598
|
await saveConfig(nextConfig);
|
|
@@ -1550,12 +1603,13 @@ async function logout() {
|
|
|
1550
1603
|
removed: 1,
|
|
1551
1604
|
all: false,
|
|
1552
1605
|
sessionKey: matches[0].key,
|
|
1606
|
+
...server,
|
|
1553
1607
|
remainingSessions: remaining.total,
|
|
1554
1608
|
remainingHostSessions: remaining.forHost ?? null,
|
|
1555
1609
|
nextActions: logoutNextActions(remaining, matches[0].host),
|
|
1556
1610
|
}
|
|
1557
1611
|
: formatLogoutMessage(
|
|
1558
|
-
`Logged out of Dench session ${matches[0].key}
|
|
1612
|
+
`Logged out of Dench session ${matches[0].key}.${serverRevokeNote(server)}`,
|
|
1559
1613
|
remaining,
|
|
1560
1614
|
matches[0].host,
|
|
1561
1615
|
),
|
|
@@ -1585,6 +1639,7 @@ async function logout() {
|
|
|
1585
1639
|
return;
|
|
1586
1640
|
}
|
|
1587
1641
|
|
|
1642
|
+
const server = await revokeSessionsOnServer([result.session]);
|
|
1588
1643
|
await saveConfig(result.config);
|
|
1589
1644
|
const remaining = logoutRemainingSummary(result.config, resolvedHost);
|
|
1590
1645
|
print(
|
|
@@ -1596,12 +1651,13 @@ async function logout() {
|
|
|
1596
1651
|
host: resolvedHost,
|
|
1597
1652
|
sessionScope: scope.label,
|
|
1598
1653
|
sessionKey: result.removedKey,
|
|
1654
|
+
...server,
|
|
1599
1655
|
remainingSessions: remaining.total,
|
|
1600
1656
|
remainingHostSessions: remaining.forHost ?? null,
|
|
1601
1657
|
nextActions: logoutNextActions(remaining, resolvedHost),
|
|
1602
1658
|
}
|
|
1603
1659
|
: formatLogoutMessage(
|
|
1604
|
-
`Logged out of Dench session ${result.removedKey}
|
|
1660
|
+
`Logged out of Dench session ${result.removedKey}.${serverRevokeNote(server)}`,
|
|
1605
1661
|
remaining,
|
|
1606
1662
|
resolvedHost,
|
|
1607
1663
|
),
|
package/lib/command-registry.ts
CHANGED
|
@@ -810,7 +810,8 @@ const rawApiOperations = [
|
|
|
810
810
|
op({
|
|
811
811
|
id: "sessions.local.logout",
|
|
812
812
|
group: "local",
|
|
813
|
-
summary:
|
|
813
|
+
summary:
|
|
814
|
+
"Sign out: end CLI sessions on the server and remove them locally.",
|
|
814
815
|
cli: "dench logout",
|
|
815
816
|
method: "POST",
|
|
816
817
|
path: "/local/logout",
|