neuvikon 0.2.20 → 0.2.21
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.mjs +29 -9
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -560,16 +560,26 @@ async function postUsage(credentials, session, delta) {
|
|
|
560
560
|
* Switching tickets used to stop the outgoing session bare, which dropped every
|
|
561
561
|
* token it had earned since its last turn ended — and a ticket that was started
|
|
562
562
|
* and left inside a single turn recorded exactly nothing.
|
|
563
|
+
*
|
|
564
|
+
* Returns whether the server actually confirmed the stop, so a caller can tell
|
|
565
|
+
* the difference between "closed" and "we gave up trying to tell the server" —
|
|
566
|
+
* a repeat `stop` for an already-stopped session is a safe no-op on the server
|
|
567
|
+
* side, so it's fine for a caller to retry this on failure.
|
|
563
568
|
*/
|
|
564
569
|
async function stopSession(credentials, session, transcript) {
|
|
565
570
|
const usage = pendingUsage(session, transcript);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
try {
|
|
572
|
+
await post(credentials.url, "/api/agent/events", {
|
|
573
|
+
token: credentials.token,
|
|
574
|
+
event: "stop",
|
|
575
|
+
sessionKey: session.sessionKey,
|
|
576
|
+
tokensIn: usage.tokensIn,
|
|
577
|
+
tokensOut: usage.tokensOut
|
|
578
|
+
});
|
|
579
|
+
return true;
|
|
580
|
+
} catch {
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
573
583
|
}
|
|
574
584
|
/**
|
|
575
585
|
* Called from an agent hook on every turn, so it is deliberately silent and
|
|
@@ -1627,7 +1637,9 @@ async function start(flags, positional) {
|
|
|
1627
1637
|
}
|
|
1628
1638
|
throw error;
|
|
1629
1639
|
}
|
|
1630
|
-
if (existing)
|
|
1640
|
+
if (existing) {
|
|
1641
|
+
if (!await stopSession(credentials, existing, transcript)) warn(`Switched off ${existing.ticket} locally, but Neuvikon didn't confirm the stop — it may still show in progress.`);
|
|
1642
|
+
}
|
|
1631
1643
|
writeSession({
|
|
1632
1644
|
sessionKey: result.sessionKey,
|
|
1633
1645
|
ticket: ref,
|
|
@@ -1663,7 +1675,15 @@ async function stop(flags) {
|
|
|
1663
1675
|
return;
|
|
1664
1676
|
}
|
|
1665
1677
|
const credentials = readCredentials();
|
|
1666
|
-
if (credentials)
|
|
1678
|
+
if (!credentials) {
|
|
1679
|
+
clearSession();
|
|
1680
|
+
success(`Stopped tracking ${session.ticket}`);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
if (!await stopSession(credentials, session, flags.get("transcript") || claudeTranscriptPath())) {
|
|
1684
|
+
warn(`Stopped tracking ${session.ticket} locally, but Neuvikon didn't confirm it — the ticket may still show in progress.`);
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1667
1687
|
clearSession();
|
|
1668
1688
|
success(`Stopped tracking ${session.ticket}`);
|
|
1669
1689
|
}
|