sideby 0.32.2 → 0.34.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/assets/brand/sai-painted-1024.png +0 -0
- package/assets/brand/sai-painted-128.png +0 -0
- package/assets/brand/sai-painted-256.png +0 -0
- package/assets/brand/sai-painted-64.png +0 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.js +76 -18
- package/dist/src/cli/format.js +3 -1
- package/dist/src/cli/json-schemas.js +34 -6
- package/dist/src/cli/main.js +12 -5
- package/dist/src/core/brand-mark.d.ts +18 -115
- package/dist/src/core/brand-mark.js +43 -174
- package/dist/src/core/live-sessions.d.ts +4 -0
- package/dist/src/core/live-sessions.js +17 -3
- package/dist/src/core/messages.d.ts +26 -5
- package/dist/src/core/messages.js +73 -16
- package/dist/src/core/quota-fetch.js +9 -2
- package/dist/src/core/session-status.d.ts +55 -0
- package/dist/src/core/session-status.js +59 -0
- package/dist/src/core/unattended-retry.d.ts +39 -0
- package/dist/src/core/unattended-retry.js +107 -0
- package/dist/src/core/unattended.d.ts +2 -2
- package/dist/src/core/unattended.js +10 -2
- package/dist/src/desktop/icon.d.ts +13 -1
- package/dist/src/desktop/icon.js +153 -285
- package/dist/src/families/claude/deliver.js +14 -2
- package/dist/src/families/claude/messaging.d.ts +14 -1
- package/dist/src/families/claude/messaging.js +24 -4
- package/dist/src/families/codex/deliver.d.ts +10 -1
- package/dist/src/families/codex/deliver.js +24 -2
- package/dist/src/families/messaging.d.ts +12 -1
- package/dist/src/handoff/messages.js +1 -1
- package/dist/src/menubar/script.d.ts +5 -0
- package/dist/src/menubar/script.js +111 -25
- package/dist/src/menubar/snapshot.d.ts +25 -5
- package/dist/src/menubar/snapshot.js +114 -26
- package/dist/src/menubar/strings.d.ts +22 -6
- package/dist/src/menubar/strings.js +22 -6
- package/dist/src/panel/handler.d.ts +2 -2
- package/dist/src/panel/handler.js +8 -2
- package/dist/src/panel/i18n.d.ts +11 -0
- package/dist/src/panel/i18n.js +35 -13
- package/dist/src/panel/page-logic.d.ts +41 -4
- package/dist/src/panel/page-logic.js +145 -10
- package/dist/src/panel/page-script.js +50 -11
- package/dist/src/panel/page-styles.js +5 -5
- package/dist/src/panel/page.js +2 -2
- package/dist/src/panel/theme.d.ts +4 -1
- package/dist/src/runtime.d.ts +3 -1
- package/dist/src/runtime.js +1 -1
- package/dist/src/unattended/hook.d.ts +4 -0
- package/dist/src/unattended/hook.js +86 -2
- package/package.json +2 -1
- package/schemas/menubar-snapshot.json +102 -2
- package/schemas/messages.json +6 -2
- package/schemas/send.json +6 -2
- package/schemas/sessions.json +22 -1
- package/skills/sideby/SKILL.md +1 -1
- package/skills/sideby/references/panel.md +1 -1
- package/skills/sideby/references/sessions.md +7 -4
- package/skills/sideby/references/unattended.md +4 -2
|
@@ -18,6 +18,101 @@ export function formatDuration(ms, lang) {
|
|
|
18
18
|
return zh ? `${h}小时${mm}分` : `${h}h ${mm}m`;
|
|
19
19
|
return zh ? `${m}分钟` : `${m}m`;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* When a quota window resets, in words (spec §3.31): under 24 hours a countdown (`in 4h 20m`, `4小时20分后`); else
|
|
23
|
+
* the next local calendar day (`tomorrow 4:59 PM`, `明天 16:59`), up to 6 days the weekday (`Wed 4:59 PM`, `周三
|
|
24
|
+
* 16:59`), later the date (`Nov 11, 4:59 PM`, `11月11日 16:59`) with the year when it is not this year. One rule for
|
|
25
|
+
* the menu bar, the Panel and the CLI. `timeZone` is for tests; the local zone otherwise. Times are composed by hand
|
|
26
|
+
* from numbers, so ICU's spacing (a narrow no-break space before PM) never shows.
|
|
27
|
+
*/
|
|
28
|
+
export function resetWhen(resetsAt, now, lang, timeZone) {
|
|
29
|
+
const zh = lang === 'zh';
|
|
30
|
+
const at = Date.parse(resetsAt);
|
|
31
|
+
if (!Number.isFinite(at))
|
|
32
|
+
return '?';
|
|
33
|
+
// Decided on the exact difference, so 23 h 59 m 30 s is still a countdown, not tomorrow's date.
|
|
34
|
+
if (at - now < 86_400_000) {
|
|
35
|
+
const minutes = Math.min(1439, Math.max(1, Math.ceil((at - now) / 60000)));
|
|
36
|
+
const h = Math.floor(minutes / 60);
|
|
37
|
+
const m = minutes % 60;
|
|
38
|
+
if (zh)
|
|
39
|
+
return h > 0 ? `${h}小时${m}分后` : `${m}分后`;
|
|
40
|
+
return h > 0 ? `in ${h}h ${m}m` : `in ${m}m`;
|
|
41
|
+
}
|
|
42
|
+
const fmt = new Intl.DateTimeFormat('en-US', {
|
|
43
|
+
timeZone,
|
|
44
|
+
year: 'numeric',
|
|
45
|
+
month: 'numeric',
|
|
46
|
+
day: 'numeric',
|
|
47
|
+
hour: 'numeric',
|
|
48
|
+
minute: 'numeric',
|
|
49
|
+
hourCycle: 'h23',
|
|
50
|
+
});
|
|
51
|
+
const parts = (t) => {
|
|
52
|
+
const p = {};
|
|
53
|
+
for (const x of fmt.formatToParts(new Date(t)))
|
|
54
|
+
if (x.type !== 'literal')
|
|
55
|
+
p[x.type] = Number(x.value);
|
|
56
|
+
return { y: p.year, mo: p.month, d: p.day, h: p.hour % 24, mi: p.minute };
|
|
57
|
+
};
|
|
58
|
+
const r = parts(at);
|
|
59
|
+
const n = parts(now);
|
|
60
|
+
const dayOf = (x) => Math.round(Date.UTC(x.y, x.mo - 1, x.d) / 86400000);
|
|
61
|
+
const days = dayOf(r) - dayOf(n);
|
|
62
|
+
const mm = String(r.mi).padStart(2, '0');
|
|
63
|
+
const time = zh
|
|
64
|
+
? `${String(r.h).padStart(2, '0')}:${mm}`
|
|
65
|
+
: `${r.h % 12 || 12}:${mm} ${r.h < 12 ? 'AM' : 'PM'}`;
|
|
66
|
+
if (days === 1)
|
|
67
|
+
return zh ? `明天 ${time}` : `tomorrow ${time}`;
|
|
68
|
+
const weekday = new Date(Date.UTC(r.y, r.mo - 1, r.d)).getUTCDay();
|
|
69
|
+
if (days > 1 && days <= 6)
|
|
70
|
+
return zh
|
|
71
|
+
? `周${'日一二三四五六'.charAt(weekday)} ${time}`
|
|
72
|
+
: `${['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][weekday]} ${time}`;
|
|
73
|
+
const month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][r.mo - 1];
|
|
74
|
+
if (zh)
|
|
75
|
+
return `${r.y !== n.y ? `${r.y}年` : ''}${r.mo}月${r.d}日 ${time}`;
|
|
76
|
+
return `${month} ${r.d}${r.y !== n.y ? `, ${r.y}` : ''}, ${time}`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A reset time in full for hover text, such as `Wed, Nov 4, 4:59 PM` or `11月4日周三 16:59`, with the year when it is
|
|
80
|
+
* not this year. `timeZone` is for tests.
|
|
81
|
+
*/
|
|
82
|
+
export function resetDate(resetsAt, now, lang, timeZone) {
|
|
83
|
+
const zh = lang === 'zh';
|
|
84
|
+
const at = Date.parse(resetsAt);
|
|
85
|
+
if (!Number.isFinite(at))
|
|
86
|
+
return '?';
|
|
87
|
+
const p = {};
|
|
88
|
+
const fmt = new Intl.DateTimeFormat('en-US', {
|
|
89
|
+
timeZone,
|
|
90
|
+
year: 'numeric',
|
|
91
|
+
month: 'numeric',
|
|
92
|
+
day: 'numeric',
|
|
93
|
+
hour: 'numeric',
|
|
94
|
+
minute: 'numeric',
|
|
95
|
+
hourCycle: 'h23',
|
|
96
|
+
});
|
|
97
|
+
for (const x of fmt.formatToParts(new Date(at)))
|
|
98
|
+
if (x.type !== 'literal')
|
|
99
|
+
p[x.type] = Number(x.value);
|
|
100
|
+
const y = p.year;
|
|
101
|
+
const mo = p.month;
|
|
102
|
+
const d = p.day;
|
|
103
|
+
const h = p.hour % 24;
|
|
104
|
+
const mm = String(p.minute).padStart(2, '0');
|
|
105
|
+
let thisYear = y;
|
|
106
|
+
for (const x of fmt.formatToParts(new Date(now)))
|
|
107
|
+
if (x.type === 'year')
|
|
108
|
+
thisYear = Number(x.value);
|
|
109
|
+
const weekday = new Date(Date.UTC(y, mo - 1, d)).getUTCDay();
|
|
110
|
+
if (zh)
|
|
111
|
+
return `${y !== thisYear ? `${y}年` : ''}${mo}月${d}日周${'日一二三四五六'.charAt(weekday)} ${String(h).padStart(2, '0')}:${mm}`;
|
|
112
|
+
const month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][mo - 1];
|
|
113
|
+
const wd = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][weekday];
|
|
114
|
+
return `${wd}, ${month} ${d}${y !== thisYear ? `, ${y}` : ''}, ${h % 12 || 12}:${mm} ${h < 12 ? 'AM' : 'PM'}`;
|
|
115
|
+
}
|
|
21
116
|
/**
|
|
22
117
|
* A Long Window: longer than one day (weekly, a billing period), from `windowMinutes` or else a label such as `7d`.
|
|
23
118
|
* The page's copy of `isLongWindow` in core/quota-levels.ts; a test keeps the two equal.
|
|
@@ -706,6 +801,29 @@ export function steadyOrder(shown, list) {
|
|
|
706
801
|
rank.sort((a, b) => needs(a.s) - needs(b.s) || a.seen - b.seen || a.at - b.at);
|
|
707
802
|
return rank.map((x) => x.s);
|
|
708
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Everything a Sessions row shows except its age, as plain values: the page redraws a row only when this changes.
|
|
806
|
+
* `reason` is in it, so a Session that keeps `needs-you` for another reason (a decision instead of its Host asking)
|
|
807
|
+
* gets its button and its hint redrawn.
|
|
808
|
+
*/
|
|
809
|
+
export function sessionRowShape(s, msg) {
|
|
810
|
+
return [
|
|
811
|
+
s.sessionId,
|
|
812
|
+
s.account,
|
|
813
|
+
s.accountLabel,
|
|
814
|
+
s.family,
|
|
815
|
+
s.title,
|
|
816
|
+
s.label,
|
|
817
|
+
s.status,
|
|
818
|
+
s.reason || '',
|
|
819
|
+
s.cwd,
|
|
820
|
+
s.guessed,
|
|
821
|
+
s.copy,
|
|
822
|
+
Boolean(s.orca),
|
|
823
|
+
s.run || null,
|
|
824
|
+
msg ? msg.status + (msg.needsApproval ? '+approve' : '') : '',
|
|
825
|
+
];
|
|
826
|
+
}
|
|
709
827
|
/** How long ago a Session was last active, as a message key and count; null when it has no time at all. */
|
|
710
828
|
export function sessionAge(s, now) {
|
|
711
829
|
const ts = Date.parse(s.updatedAt || s.startedAt || '');
|
|
@@ -727,7 +845,9 @@ export function sessionLabelParts(s) {
|
|
|
727
845
|
* What the "Send to it" dialog shows after a send: `done` (the Host took it; `hint` is any note, shown as a yellow
|
|
728
846
|
* hint), `approve` (it took it, but the target shows it only once the user approves it there; `reason` says how, ADR-0045),
|
|
729
847
|
* `paste` (the user pastes `pasteText`; `reason` says why, `jump` offers the
|
|
730
|
-
* target's Orca tab)
|
|
848
|
+
* target's Orca tab), `stored` (kept as a file only; `pasteText` for reference) or `unknown` (sideby could not tell if
|
|
849
|
+
* it arrived, ADR-0065: `reason` says why, and `pasteText` is offered only with a caution, never as the next step).
|
|
850
|
+
* A status this page does not know is shown as `unknown`, never as a request to paste. `key` is the headline's key.
|
|
731
851
|
*/
|
|
732
852
|
export function sendResultView(m, orca) {
|
|
733
853
|
const pasteText = m.pasteText || '';
|
|
@@ -752,7 +872,9 @@ export function sendResultView(m, orca) {
|
|
|
752
872
|
hint: '',
|
|
753
873
|
jump: Boolean(orca && pasteText),
|
|
754
874
|
};
|
|
755
|
-
|
|
875
|
+
if (m.status === 'stored')
|
|
876
|
+
return { kind: 'stored', key: 'send.stored', pasteText, reason: note, hint: '', jump: false };
|
|
877
|
+
return { kind: 'unknown', key: 'send.unknown', pasteText, reason: note, hint: '', jump: false };
|
|
756
878
|
}
|
|
757
879
|
/** The chip a Sessions row shows for the latest Message to it, or null when there is none worth showing. */
|
|
758
880
|
export function messageChip(status, needsApproval) {
|
|
@@ -765,8 +887,18 @@ export function messageChip(status, needsApproval) {
|
|
|
765
887
|
return { key: 'send.chip.read', tone: 'ok' };
|
|
766
888
|
if (status === 'paste-needed')
|
|
767
889
|
return { key: 'send.chip.paste', tone: 'warn' };
|
|
890
|
+
// Given to the channel, but never confirmed (ADR-0065).
|
|
891
|
+
if (status === 'unknown')
|
|
892
|
+
return { key: 'send.chip.unknown', tone: 'warn' };
|
|
768
893
|
return null;
|
|
769
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* Whether a Session's latest Message asks the user to look: it waits for a paste, or it could not be confirmed. The
|
|
897
|
+
* Sessions tab counts running Sessions for which this holds.
|
|
898
|
+
*/
|
|
899
|
+
export function messageToCheck(status) {
|
|
900
|
+
return status === 'paste-needed' || status === 'unknown';
|
|
901
|
+
}
|
|
770
902
|
/** A Session Label without its short id: `cc002 · knip cleanup · 61230c3d` → `cc002 · knip cleanup`. */
|
|
771
903
|
export function shortSessionLabel(label) {
|
|
772
904
|
const parts = (label || '').split(' · ').filter(Boolean);
|
|
@@ -777,7 +909,8 @@ export function shortSessionLabel(label) {
|
|
|
777
909
|
/**
|
|
778
910
|
* What changed between two readings of the latest Messages, for the Panel's notices (spec §3.32): `new` (a Message
|
|
779
911
|
* reached a Session), `approve` (it reached one that shows it only once the user approves it, ADR-0045), `read` (its
|
|
780
|
-
* Session read it)
|
|
912
|
+
* Session read it), `paste` (it waits for the user to paste it) or `unknown` (sideby could not confirm it arrived,
|
|
913
|
+
* ADR-0065; announced once, as the status never changes by itself). The first reading (`before` null) only sets the
|
|
781
914
|
* baseline, so opening the Panel announces nothing that was already there.
|
|
782
915
|
*/
|
|
783
916
|
export function messageNews(before, after) {
|
|
@@ -795,13 +928,15 @@ export function messageNews(before, after) {
|
|
|
795
928
|
const fresh = !same || was.status === 'stored';
|
|
796
929
|
const kind = m.status === 'paste-needed'
|
|
797
930
|
? 'paste'
|
|
798
|
-
:
|
|
799
|
-
?
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
:
|
|
931
|
+
: m.status === 'unknown'
|
|
932
|
+
? 'unknown'
|
|
933
|
+
: fresh
|
|
934
|
+
? m.status === 'delivered' && m.needsApproval
|
|
935
|
+
? 'approve'
|
|
936
|
+
: 'new'
|
|
937
|
+
: m.status === 'read'
|
|
938
|
+
? 'read'
|
|
939
|
+
: null;
|
|
805
940
|
if (kind)
|
|
806
941
|
out.push({ kind, sessionId, id: m.id, to: shortSessionLabel(m.to), from: shortSessionLabel(m.from) });
|
|
807
942
|
}
|
|
@@ -5,7 +5,7 @@ import { groupsToAccept } from '../core/inbound.js';
|
|
|
5
5
|
import { quotaIsStale } from '../core/quota-levels.js';
|
|
6
6
|
import { remoteControlTodo } from '../core/remote-control.js';
|
|
7
7
|
import { catalogMatchLevel, catalogNorm, searchCatalog } from '../core/search-catalog.js';
|
|
8
|
-
import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, networkTaskFacts, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
|
|
8
|
+
import { aiTaskAccounts, aliasArgsOf, aliasIssue, askBridge, askBridged, askCopy, attentionReasons, attentionWhy, autostartNote, bindingWindow, cacheHitRate, canLeaveLocal, categoryOrder, codeSwapOutcome, dotsKeepKeyboard, enableOutcome, fileSize, fixPrompt, foldSkips, foldToolCalls, formatDuration, handoffChangeOf, handoffHintAccount, handoffTaskFacts, hiddenIn, highlightParts, histFilters, historyEmpty, historyWhen, hotkeyFromKey, hotkeyPressKind, inDisplayOrder, loginClusters, loginKey, longWindow, maskEmail, matchesQuery, mdBlocks, mdInline, menuPlacement, mergeDaily, mergeUsage, messageChip, messageNews, messageToCheck, networkTaskFacts, newAccountDir, nextReset, panelFixes, panelHint, panelLang, panelMigration, panelPrefs, passedWindow, pinnedIn, quotaAskable, quotaHighLevel, quotaPressure, radioStep, reloadForBuild, remoteControlSummary, reorder, resetWhen, rowBadge, runCodeSwap, saveHandoffChange, sendBlock, sendFileProblem, sendResultView, sessionAge, sessionLabelParts, sessionRowShape, shortCwd, shortSessionLabel, sortAccounts, sortSessions, steadyOrder, stripSecrets, suggestAlias, suggestName, switchFailure, tailInView, taskFindings, uaDayRuns, uaGroupPending, uaOnChoices, uaParseClock, uaPickTime, uaSameSlot, uaShouldRead, uaSlotNight, uaStatusParts, uaStepClock, uaToggleDay, uaWaitingCount, uaWhen, updatedAge, widthFollower, widthTier, windowState, withPinned, } from './page-logic.js';
|
|
9
9
|
const LOGIC = [
|
|
10
10
|
quotaIsStale,
|
|
11
11
|
catalogNorm,
|
|
@@ -33,6 +33,7 @@ const LOGIC = [
|
|
|
33
33
|
fixPrompt,
|
|
34
34
|
foldSkips,
|
|
35
35
|
formatDuration,
|
|
36
|
+
resetWhen,
|
|
36
37
|
foldToolCalls,
|
|
37
38
|
highlightParts,
|
|
38
39
|
historyEmpty,
|
|
@@ -54,6 +55,7 @@ const LOGIC = [
|
|
|
54
55
|
mergeUsage,
|
|
55
56
|
messageChip,
|
|
56
57
|
messageNews,
|
|
58
|
+
messageToCheck,
|
|
57
59
|
longWindow,
|
|
58
60
|
newAccountDir,
|
|
59
61
|
nextReset,
|
|
@@ -80,6 +82,7 @@ const LOGIC = [
|
|
|
80
82
|
sendResultView,
|
|
81
83
|
sessionAge,
|
|
82
84
|
sessionLabelParts,
|
|
85
|
+
sessionRowShape,
|
|
83
86
|
shortCwd,
|
|
84
87
|
shortSessionLabel,
|
|
85
88
|
sortAccounts,
|
|
@@ -1353,7 +1356,8 @@ const MAIN = String.raw `
|
|
|
1353
1356
|
const left = prefs.quota === 'left'
|
|
1354
1357
|
const shown = left ? 100 - st.pct : st.pct
|
|
1355
1358
|
const asOf = stale ? t('quota.asOf', { ago: ago(observedAt) }) : ''
|
|
1356
|
-
|
|
1359
|
+
// The same words as the menu bar and the CLI (spec §3.31): a countdown under a day, then tomorrow, a weekday, a date.
|
|
1360
|
+
const reset = passed ? t('quota.resetShort') : t('quota.resetsIn', { d: resetWhen(w.resetsAt, now, lang) })
|
|
1357
1361
|
// The wide list's column says only the model group, so the hover names which of its limits this is.
|
|
1358
1362
|
const title = [withLength ? winTitle(w.label) : '', passed ? t('quota.resetNoData', { date: day(passed.since) }) : t('quota.resetsAt', { at: clock(w.resetsAt) }), asOf].filter(Boolean).join(' · ')
|
|
1359
1363
|
return h('div', { class: 'meter lvl-' + st.level + (stale || passed ? ' lvl-stale' : ''), title },
|
|
@@ -2235,8 +2239,8 @@ const MAIN = String.raw `
|
|
|
2235
2239
|
function emptyState() {
|
|
2236
2240
|
const fams = S.state.families.slice().sort((x, y) => Number(y.installed) - Number(x.installed))
|
|
2237
2241
|
return h('div', { class: 'empty' },
|
|
2238
|
-
// The header's mark, cloned (page.ts
|
|
2239
|
-
h('span', { class: 'logo', 'aria-hidden': 'true' }, document.querySelector('.brand .logo
|
|
2242
|
+
// The header's mark, cloned (page.ts takes it from core/brand-mark.ts).
|
|
2243
|
+
h('span', { class: 'logo', 'aria-hidden': 'true' }, document.querySelector('.brand .logo img')?.cloneNode(true) ?? null),
|
|
2240
2244
|
h('h3', null, t('empty.title')),
|
|
2241
2245
|
h('p', { class: 'muted' }, t('empty.body')),
|
|
2242
2246
|
fams.length ? h('ul', { class: 'host-list' }, fams.map((f) => h('li', null, badge(f.id, 'sm'), h('span', null, f.title),
|
|
@@ -3396,10 +3400,10 @@ const MAIN = String.raw `
|
|
|
3396
3400
|
// "asked" numbers each reading and "applied" is the newest one used, so an answer that comes back late never
|
|
3397
3401
|
// replaces a newer one; "own" holds the ids this Panel sent, never announced.
|
|
3398
3402
|
const mn = { base: null, at: 0, loading: false, asked: 0, applied: 0, own: new Set() }
|
|
3399
|
-
// Running Sessions whose latest Message waits for a paste, for the count on the Sessions tab.
|
|
3403
|
+
// Running Sessions whose latest Message waits for a paste or could not be confirmed, for the count on the Sessions tab.
|
|
3400
3404
|
function pasteCount() {
|
|
3401
3405
|
if (!sp.data) return 0
|
|
3402
|
-
return sp.data.sessions.filter((s) => sp.msgs[s.sessionId] && sp.msgs[s.sessionId].status
|
|
3406
|
+
return sp.data.sessions.filter((s) => sp.msgs[s.sessionId] && messageToCheck(sp.msgs[s.sessionId].status)).length
|
|
3403
3407
|
}
|
|
3404
3408
|
function noteMessages(latest, seq) {
|
|
3405
3409
|
if (seq < mn.applied) return
|
|
@@ -3420,6 +3424,11 @@ const MAIN = String.raw `
|
|
|
3420
3424
|
toast(t('msgn.approve', { to: n.to || t('msgn.aSession') }), { kind: 'info', key: 'msg-' + n.sessionId, keep: true, duration: 12000, action: BOOT.readOnly ? null : { label: t('inb.go'), run: openInbound } })
|
|
3421
3425
|
continue
|
|
3422
3426
|
}
|
|
3427
|
+
if (n.kind === 'unknown') {
|
|
3428
|
+
// It may still arrive, so nothing is copied and nothing waits: "View" opens the row's chip with the reason (ADR-0065).
|
|
3429
|
+
toast(t('msgn.unknown', { to: n.to || t('msgn.aSession') }), { kind: 'info', key: 'msg-' + n.sessionId, action: { label: t('msgn.show'), run: () => showSession(n.sessionId, true) } })
|
|
3430
|
+
continue
|
|
3431
|
+
}
|
|
3423
3432
|
const key = n.kind === 'read' ? 'msgn.read' : n.kind === 'paste' ? 'msgn.paste' : n.from ? 'msgn.newFrom' : 'msgn.new'
|
|
3424
3433
|
const there = curPage === 'sessions' && hs.mode !== 'history'
|
|
3425
3434
|
const line = n.kind === 'paste' ? latest[n.sessionId].pasteText : null
|
|
@@ -3582,7 +3591,8 @@ const MAIN = String.raw `
|
|
|
3582
3591
|
p.title ? h('span', { class: 'sess-title' }, p.title) : null,
|
|
3583
3592
|
h('span', { class: 'mono sess-id' }, p.id)),
|
|
3584
3593
|
h('div', { class: 'sess-sub muted small' },
|
|
3585
|
-
|
|
3594
|
+
sessStatus(s, status),
|
|
3595
|
+
s.reason === 'pending-decision' && status === 'needs-you' ? h('button', { class: 'chip chip-sm chip-warn chip-btn sess-decision', type: 'button', 'data-key': 'sess-decision-' + s.sessionId, 'data-tip': t('spage.decisionTip'), onclick: () => setPage('unattended') }, t('spage.decision'), icon('chevron')) : null,
|
|
3586
3596
|
chip ? msgChip(chip, msg, s) : null,
|
|
3587
3597
|
s.guessed ? h('span', { class: 'chip sess-guessed', tabindex: '0', 'data-tip': t('spage.guessedTip') }, t('spage.guessed')) : null,
|
|
3588
3598
|
runChip(s),
|
|
@@ -3590,6 +3600,11 @@ const MAIN = String.raw `
|
|
|
3590
3600
|
h('span', { class: 'sess-age', 'data-age': s.sessionId }, sessAgeText(s)))),
|
|
3591
3601
|
h('div', { class: 'sess-actions' }, copyBtn, sendBtn, more)), liveMenu)
|
|
3592
3602
|
}
|
|
3603
|
+
// The status, and why a Session needs the user when sideby knows (spec §3.32 step 1's table).
|
|
3604
|
+
function sessStatus(s, status) {
|
|
3605
|
+
const why = status === 'needs-you' && ['host-waits', 'pending-decision', 'message-to-approve', 'message-to-paste'].includes(s.reason) ? t('spage.why.' + s.reason) : null
|
|
3606
|
+
return h('span', { class: 'sess-status', tabindex: why ? '0' : null, 'data-tip': why }, h('span', { class: 'dot sess-dot', 'aria-hidden': 'true' }), t('spage.status.' + status))
|
|
3607
|
+
}
|
|
3593
3608
|
// The latest Message's state on a row. One that waits for a paste opens what to paste and why, so the line is never
|
|
3594
3609
|
// only in the dialog that sent it.
|
|
3595
3610
|
function msgChip(chip, msg, s) {
|
|
@@ -3604,6 +3619,22 @@ const MAIN = String.raw `
|
|
|
3604
3619
|
}))
|
|
3605
3620
|
return btn
|
|
3606
3621
|
}
|
|
3622
|
+
// Not confirmed (ADR-0065): why, and the line only with the warning that a paste may deliver it twice.
|
|
3623
|
+
if (chip.key === 'send.chip.unknown') {
|
|
3624
|
+
const btn = h('button', { class: cls + ' sess-msg-paste', type: 'button', 'aria-haspopup': 'dialog', 'data-key': 'sess-msg-' + s.sessionId }, t(chip.key), icon('chevron'))
|
|
3625
|
+
btn.addEventListener('click', () => openPopover(btn, 'sess-paste', t(chip.key), () => {
|
|
3626
|
+
const out = [msg.note ? h('p', { class: 'small muted' }, msg.note) : null]
|
|
3627
|
+
if (msg.pasteText) {
|
|
3628
|
+
const area = h('textarea', { class: 'sess-copy-text mono', readonly: true, rows: '3', 'aria-label': t('send.copyLine') })
|
|
3629
|
+
area.value = msg.pasteText
|
|
3630
|
+
const copy = h('button', { class: 'btn btn-sm', type: 'button' }, icon('copy'), h('span', null, t('send.copyLine')))
|
|
3631
|
+
copy.addEventListener('click', () => sessCopy(copy, msg.pasteText, () => { closeMenu(true); toast(t('toast.copied', { text: msg.pasteText })) }))
|
|
3632
|
+
out.push(h('p', { class: 'small' }, t('send.unknownCaution')), area, h('div', { class: 'pop-actions' }, copy))
|
|
3633
|
+
}
|
|
3634
|
+
return out
|
|
3635
|
+
}))
|
|
3636
|
+
return btn
|
|
3637
|
+
}
|
|
3607
3638
|
if (chip.tone !== 'warn' || !msg.pasteText) return h('span', { class: cls, tabindex: '0', 'data-tip': t('send.chipTip') }, t(chip.key))
|
|
3608
3639
|
const btn = h('button', { class: cls + ' sess-msg-paste', type: 'button', 'aria-haspopup': 'dialog', 'data-key': 'sess-msg-' + s.sessionId }, t(chip.key), icon('chevron'))
|
|
3609
3640
|
btn.addEventListener('click', () => openPopover(btn, 'sess-paste', t('send.chip.paste'), () => {
|
|
@@ -3627,7 +3658,7 @@ const MAIN = String.raw `
|
|
|
3627
3658
|
sp.order = list.map((s) => s.sessionId)
|
|
3628
3659
|
// Everything a row shows except its age, which renderSessionAges keeps current in place.
|
|
3629
3660
|
const shape = JSON.stringify([lang, hs.opening, !d && !sp.error, sp.error ? sp.error.message : '', d ? d.problems : [],
|
|
3630
|
-
list.map((s) =>
|
|
3661
|
+
list.map((s) => sessionRowShape(s, sp.msgs[s.sessionId])), inboundShape()])
|
|
3631
3662
|
if (shape === sp.drawn) { sp.pending = false; renderSessionAges(); revealSession(); return }
|
|
3632
3663
|
if (sessionsMenuOpen()) { sp.pending = true; return }
|
|
3633
3664
|
sp.pending = false
|
|
@@ -4747,7 +4778,7 @@ const MAIN = String.raw `
|
|
|
4747
4778
|
const r = await api('/api/sessions/send', { sessionId: mine.s.sessionId, text, attachments: ready.map((f) => f.id), lang })
|
|
4748
4779
|
ready.forEach((f) => { f.sent = true })
|
|
4749
4780
|
mine.result = r
|
|
4750
|
-
ownMessage(mine.s.sessionId, { id: r.message.id, status: r.message.status, sentAt: r.message.sentAt, to: r.message.to, ...(r.message.status
|
|
4781
|
+
ownMessage(mine.s.sessionId, { id: r.message.id, status: r.message.status, sentAt: r.message.sentAt, to: r.message.to, ...(messageToCheck(r.message.status) ? { pasteText: r.message.pasteText } : {}), ...(r.message.note ? { note: r.message.note } : {}) })
|
|
4751
4782
|
renderSessionsPage()
|
|
4752
4783
|
} catch (e) { mine.error = e }
|
|
4753
4784
|
dlg.busy = false
|
|
@@ -4766,7 +4797,7 @@ const MAIN = String.raw `
|
|
|
4766
4797
|
const v = sendResultView(r.message, Boolean(r.orca))
|
|
4767
4798
|
const out = []
|
|
4768
4799
|
if (v.kind === 'done') out.push(h('div', { class: 'note note-ok', role: 'status' }, icon('tick'), h('span', null, t(v.key, { name }))))
|
|
4769
|
-
else out.push(h('div', { class: 'note' + (v.kind === 'paste' || v.kind === 'approve' ? ' note-warn' : ''), role: 'status' }, h('b', null, t(v.key, { name })), v.reason ? h('span', { class: 'note-line' }, v.reason) : null))
|
|
4800
|
+
else out.push(h('div', { class: 'note' + (v.kind === 'paste' || v.kind === 'approve' || v.kind === 'unknown' ? ' note-warn' : ''), role: 'status' }, h('b', null, t(v.key, { name })), v.reason ? h('span', { class: 'note-line' }, v.reason) : null))
|
|
4770
4801
|
if (v.hint) out.push(h('p', { class: 'note note-warn small' }, v.hint))
|
|
4771
4802
|
if (v.kind === 'approve' && !BOOT.readOnly)
|
|
4772
4803
|
out.push(h('div', { class: 'pop-actions' }, h('button', { class: 'btn btn-sm btn-primary', type: 'button', onclick: openInbound }, t('inb.go'))))
|
|
@@ -4777,6 +4808,13 @@ const MAIN = String.raw `
|
|
|
4777
4808
|
h('div', { class: 'send-line-actions' }, copy,
|
|
4778
4809
|
v.jump ? h('button', { class: 'btn btn-sm', type: 'button', onclick: () => jumpToOrca(sd.s) }, icon('link'), t('send.jump')) : null)))
|
|
4779
4810
|
}
|
|
4811
|
+
// Not confirmed: the line is there for when it never shows up, never the next step, and never copied by itself.
|
|
4812
|
+
if (v.kind === 'unknown' && v.pasteText) {
|
|
4813
|
+
const copy = h('button', { class: 'btn btn-sm', type: 'button' }, icon('copy'), t('send.copyLine'))
|
|
4814
|
+
copy.addEventListener('click', () => sessCopy(copy, v.pasteText, () => toast(t('send.copiedUnknown', { name }))))
|
|
4815
|
+
out.push(h('p', { class: 'small muted' }, t('send.unknownCaution')),
|
|
4816
|
+
h('div', { class: 'send-line' }, h('code', { class: 'send-line-text' }, v.pasteText), h('div', { class: 'send-line-actions' }, copy)))
|
|
4817
|
+
}
|
|
4780
4818
|
return out
|
|
4781
4819
|
}
|
|
4782
4820
|
function sendAgain() {
|
|
@@ -5765,7 +5803,8 @@ const MAIN = String.raw `
|
|
|
5765
5803
|
const p = uaStatusParts(st)
|
|
5766
5804
|
const schedule = st.schedule || []
|
|
5767
5805
|
const slotWord = p.slot !== null && schedule[p.slot] ? uaSlotWord(schedule[p.slot], p.slot) : null
|
|
5768
|
-
|
|
5806
|
+
// State first, then the one time that matters (until when, or when it comes on), then why.
|
|
5807
|
+
if (p.state === 'on') return [t('ua.on'), p.noEnd ? t('ua.noEnd') : uaAt('until', p.until), p.byHand ? t('ua.byHand') : slotWord]
|
|
5769
5808
|
if (p.state === 'paused') return [t('ua.paused'), p.noEnd ? t('ua.pausedOpen') : uaAt('back', p.until)]
|
|
5770
5809
|
return [t('ua.off'), p.next ? uaAt('next', p.next.at) : null]
|
|
5771
5810
|
}
|
|
@@ -8,11 +8,11 @@ const colorDecls = (tokens) => Object.entries(tokens)
|
|
|
8
8
|
.map(([k, v]) => `${THEME_TOKENS[k]}: ${v}`)
|
|
9
9
|
.join('; ');
|
|
10
10
|
// Colors defined from other tokens, before each scheme's Theme colors so a Theme can set them; repeated in both schemes so they follow that scheme's base colors. Dark mode keeps
|
|
11
|
-
// the logo tile light: the mark
|
|
12
|
-
//
|
|
11
|
+
// the logo tile light: the painted mark (core/brand-mark.ts, ADR-0064) is drawn for a light ground. `--logo-fg` no longer
|
|
12
|
+
// colours the mark (it is a painting); it stays the brand blue so Themes that set it keep working (ADR-0050).
|
|
13
13
|
const DERIVED_COLORS = `
|
|
14
14
|
--btn-text: var(--text); --btn-hover-text: var(--accent); --check: var(--focus);
|
|
15
|
-
--logo-bg: var(--surface-2); --logo-fg: #3f8fc4; /* design-system-ignore: the
|
|
15
|
+
--logo-bg: var(--surface-2); --logo-fg: #3f8fc4; /* design-system-ignore: the brand blue (ADR-0050); the painted mark keeps its own colours (ADR-0064) */ --logo-line: var(--border);
|
|
16
16
|
--focus-outline: 2px solid var(--focus); --focus-ring: none;
|
|
17
17
|
--scrim: color-mix(in srgb, var(--text) 40%, transparent);`;
|
|
18
18
|
// The usage chart (--spark) takes the main button's hue at a readable lightness, keeping its chroma: a black-and-white
|
|
@@ -100,8 +100,8 @@ code, .mono { font-family: var(--mono); font-size: 0.92em; }
|
|
|
100
100
|
.ver-pill.has-update { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
|
|
101
101
|
.ver-pill.has-update::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
|
|
102
102
|
.logo { display: inline-flex; flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--logo-bg); box-shadow: inset 0 0 0 1px var(--logo-line); }
|
|
103
|
-
/*
|
|
104
|
-
.logo
|
|
103
|
+
/* The painted mark (core/brand-mark.ts), 3 px in from the tile's edge; desktop/icon.ts lays the app icon out the same way. */
|
|
104
|
+
.logo img { display: block; width: 100%; height: 100%; padding: 7.5%; box-sizing: border-box; object-fit: contain; }
|
|
105
105
|
.top-actions { display: flex; align-items: center; gap: 8px; }
|
|
106
106
|
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
|
|
107
107
|
.section-head > div:first-child { min-width: 0; }
|
package/dist/src/panel/page.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// sibling modules: page-styles.ts (tokens and CSS), page-script.ts (behaviour, with page-logic.ts helpers) and
|
|
3
3
|
// i18n.ts (English and Chinese text); this module assembles them under the CSP nonce.
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
|
-
import { FAVICON_SVG,
|
|
5
|
+
import { FAVICON_SVG, MARK_IMG } from '../core/brand-mark.js';
|
|
6
6
|
import { commandListForPage } from '../core/cli-commands.js';
|
|
7
7
|
import { ALIAS_NAME, RESERVED_ALIASES } from '../core/config.js';
|
|
8
8
|
import { QUOTA_FAIL_PERCENT, QUOTA_LONG_FAIL_PERCENT, QUOTA_LONG_WARN_PERCENT, QUOTA_WARN_PERCENT, USAGE_DAYS, } from '../core/quota-levels.js';
|
|
@@ -86,7 +86,7 @@ export function renderPage(opts) {
|
|
|
86
86
|
<header class="top">
|
|
87
87
|
<div class="top-in">
|
|
88
88
|
<div class="brand">
|
|
89
|
-
<span class="logo" aria-hidden="true">${
|
|
89
|
+
<span class="logo" aria-hidden="true">${MARK_IMG}</span>
|
|
90
90
|
<div>
|
|
91
91
|
<div class="title-row"><h1>sideby</h1><button id="ver-top" class="ver-pill" type="button" aria-haspopup="dialog" aria-expanded="false" hidden></button></div>
|
|
92
92
|
<p class="tagline" data-i18n="top.tagline">Every AI coding account, side by side.</p>
|
|
@@ -67,7 +67,10 @@ export interface PanelThemeTokens {
|
|
|
67
67
|
warnBar?: string;
|
|
68
68
|
failBar?: string;
|
|
69
69
|
track?: string;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The tile behind the sideby mark in the page header. `logoColor` no longer colours the mark, which is a painting
|
|
72
|
+
* (ADR-0064); it is kept so existing Themes and Portals still load.
|
|
73
|
+
*/
|
|
71
74
|
logoBg?: string;
|
|
72
75
|
logoColor?: string;
|
|
73
76
|
logoBorder?: string;
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -359,10 +359,12 @@ export interface Runtime {
|
|
|
359
359
|
/**
|
|
360
360
|
* Which Account of a Family to move on to (spec §3.13), for a start the user asks for: past the Takeover Limit it
|
|
361
361
|
* falls back to the least used Account under 100% (`tight`). Throws a UserError with code `no-quota-source`
|
|
362
|
-
* when the Family cannot tell, `no-accounts` when it has none.
|
|
362
|
+
* when the Family cannot tell, `no-accounts` when it has none. `fetch` is as for `quota`; `never` reads only the kept
|
|
363
|
+
* answers (the menu bar's cache-only snapshot, spec §3.31).
|
|
363
364
|
*/
|
|
364
365
|
handoff(familyId: string, opts?: {
|
|
365
366
|
includeApi?: boolean;
|
|
367
|
+
fetch?: QuotaFetchMode;
|
|
366
368
|
}): Promise<HandoffPlan>;
|
|
367
369
|
/** The config `handoff` settings with every default filled in (spec §3.17). */
|
|
368
370
|
handoffSettings(): HandoffSettings;
|
package/dist/src/runtime.js
CHANGED
|
@@ -969,7 +969,7 @@ export async function createRuntime(opts = {}) {
|
|
|
969
969
|
code: 'no-accounts',
|
|
970
970
|
});
|
|
971
971
|
// Login state, Quota and Same Login (spec §3.21): no model or Host lookups are needed to rank.
|
|
972
|
-
const [quotas, groups] = await Promise.all([quotasOf(list), groupsOf(list)]);
|
|
972
|
+
const [quotas, groups] = await Promise.all([quotasOf(list, o.fetch), groupsOf(list)]);
|
|
973
973
|
const candidates = await Promise.all(list.map(async (a) => {
|
|
974
974
|
const peers = groups.get(a.ref);
|
|
975
975
|
return {
|
|
@@ -5,6 +5,10 @@ export declare const ASK_TOOLS: Readonly<Record<string, string>>;
|
|
|
5
5
|
type Env = Record<string, string | undefined>;
|
|
6
6
|
export interface UnattendedHookDeps {
|
|
7
7
|
now?: () => Date;
|
|
8
|
+
/** Turn Retry's wait; a real timer by default. */
|
|
9
|
+
sleep?: (ms: number) => Promise<void>;
|
|
10
|
+
/** Whether the Host that started the hook is gone (`ppid` 1 by default): nothing is left to wake. */
|
|
11
|
+
parentGone?: () => boolean;
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
10
14
|
* The question as the user should read it later: each question (with its short header) and its options' labels.
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
// Claude Code's permission requests with a denial (JSON on stdout: Claude Code does not honor exit 2 for that event),
|
|
11
11
|
// keeping the request as a Pending Decision too; it keeps a turn going once when the model ended it on a question
|
|
12
12
|
// written as plain text (`{"decision":"block","reason":…}` on stdout), keeping the question; and it declines an MCP
|
|
13
|
-
// server's form, keeping what the server asked.
|
|
13
|
+
// server's form, keeping what the server asked. In Claude it also runs in the background after a turn that failed for
|
|
14
|
+
// a passing reason (`StopFailure`, `asyncRewake`): it waits, then wakes the session with exit 2 so the turn goes on, at
|
|
15
|
+
// most three times in a row, and keeps a Pending Decision when that did not help (Turn Retry, ADR-0067). A failure
|
|
16
|
+
// before the decision is made does nothing: that is
|
|
14
17
|
// how a session behaves without the feature (unlike `network-hook`, which blocks when it cannot tell). Once the
|
|
15
18
|
// decision is to refuse, it refuses: keeping the Pending Decision and writing the reason are best effort, and their
|
|
16
19
|
// failure neither allows the call nor adds any output of its own.
|
|
17
20
|
import { resolvePaths } from '../core/paths.js';
|
|
18
21
|
import { addPendingDecision } from '../core/unattended-pending.js';
|
|
22
|
+
import { clearRetryStreak, countFailure, passingFailure, RETRY_LIMIT, readRetryStreak, retryDelay, retryGaveUpText, retryMessage, } from '../core/unattended-retry.js';
|
|
19
23
|
import { clockText, readUnattendedConfig, readUnattendedOverride, UNATTENDED_ENV, unattendedState, } from '../core/unattended-state.js';
|
|
20
24
|
export const UNATTENDED_HOOK_COMMAND = 'sideby unattended-hook';
|
|
21
25
|
/** The tool each Host's model asks the user with. */
|
|
@@ -332,12 +336,21 @@ async function decide(argv, env, input, now) {
|
|
|
332
336
|
if (!permission && !elicitation && !stop && (event !== 'PreToolUse' || !askTool))
|
|
333
337
|
return undefined;
|
|
334
338
|
const paths = resolvePaths(env);
|
|
339
|
+
// A turn that finished ends the session's run of retried failures (Turn Retry), whether Unattended Mode is on or
|
|
340
|
+
// not: a wait left from earlier must never wake a session whose turn is already done.
|
|
341
|
+
let early;
|
|
342
|
+
if (stop && family === 'claude') {
|
|
343
|
+
early = await readInput(input);
|
|
344
|
+
const sessionId = text(parseObject(early)?.session_id, 256);
|
|
345
|
+
if (sessionId)
|
|
346
|
+
await clearRetryStreak(paths.stateDir, sessionId).catch(() => { });
|
|
347
|
+
}
|
|
335
348
|
const { schedule } = await readUnattendedConfig(paths.configFile);
|
|
336
349
|
const override = await readUnattendedOverride(paths.stateDir);
|
|
337
350
|
const state = unattendedState({ schedule, override, now, session: env[UNATTENDED_ENV] === '1' });
|
|
338
351
|
if (!state.on)
|
|
339
352
|
return undefined;
|
|
340
|
-
const raw = await readInput(input);
|
|
353
|
+
const raw = early ?? (await readInput(input));
|
|
341
354
|
const zh = prefersChinese(env);
|
|
342
355
|
const account = text(env.SIDEBY_ACCOUNT, 256);
|
|
343
356
|
if (stop || elicitation) {
|
|
@@ -418,6 +431,18 @@ async function decide(argv, env, input, now) {
|
|
|
418
431
|
* record.
|
|
419
432
|
*/
|
|
420
433
|
export async function runUnattendedHook(argv, env, input, io, deps = {}) {
|
|
434
|
+
if (argv[0] === 'claude' && argv[1] === 'StopFailure') {
|
|
435
|
+
try {
|
|
436
|
+
const wake = await retryAfterFailure(env, input, deps);
|
|
437
|
+
if (!wake)
|
|
438
|
+
return 0;
|
|
439
|
+
io.err.write(`${wake}\n`);
|
|
440
|
+
return 2;
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
return 0;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
421
446
|
let refusal;
|
|
422
447
|
const now = deps.now ? deps.now() : new Date();
|
|
423
448
|
try {
|
|
@@ -454,3 +479,62 @@ export async function runUnattendedHook(argv, env, input, io, deps = {}) {
|
|
|
454
479
|
}
|
|
455
480
|
return 2;
|
|
456
481
|
}
|
|
482
|
+
/** Whether Unattended Mode is on right now, read fresh from the Schedule and the manual state. */
|
|
483
|
+
async function isOn(env, now) {
|
|
484
|
+
const paths = resolvePaths(env);
|
|
485
|
+
const { schedule } = await readUnattendedConfig(paths.configFile);
|
|
486
|
+
const override = await readUnattendedOverride(paths.stateDir);
|
|
487
|
+
return unattendedState({ schedule, override, now, session: env[UNATTENDED_ENV] === '1' }).on;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Turn Retry (spec §3.37 item 6, ADR-0067), Claude's background `StopFailure` hook (`asyncRewake`): Claude Code runs it
|
|
491
|
+
* when a turn ends on an API error and ignores its output, but wakes the idle session when it exits 2, with its stderr
|
|
492
|
+
* as the model's next note (checked with Claude Code 2.1.316). While Unattended Mode is on and the failure is a
|
|
493
|
+
* passing one, it counts the failure for the session; up to `RETRY_LIMIT` in a row it waits 1, 2, then 4 minutes and
|
|
494
|
+
* returns the note that wakes the session. Past the limit it keeps a Pending Decision and wakes nothing. It returns
|
|
495
|
+
* nothing (exit 0) when the mode is off, the failure is not passing, there is no session id, or by the end of the wait
|
|
496
|
+
* the mode went off, the Host is gone, or another failure or a finished turn has taken over the session's streak.
|
|
497
|
+
*/
|
|
498
|
+
async function retryAfterFailure(env, input, deps) {
|
|
499
|
+
const clock = deps.now ?? (() => new Date());
|
|
500
|
+
const now = clock();
|
|
501
|
+
const v = parseObject(await readInput(input));
|
|
502
|
+
if (!v)
|
|
503
|
+
return undefined;
|
|
504
|
+
const sessionId = text(v.session_id, 256);
|
|
505
|
+
if (!sessionId)
|
|
506
|
+
return undefined;
|
|
507
|
+
const paths = resolvePaths(env);
|
|
508
|
+
const error = typeof v.error === 'string' ? v.error : undefined;
|
|
509
|
+
const said = [text(v.last_assistant_message, 1000), text(v.error_details, 1000)].filter(Boolean).join(' ');
|
|
510
|
+
// A later failure that is not retried (a used-up Quota, a lasting error) or comes while the mode is off still
|
|
511
|
+
// takes over the session: the wait an earlier failure left must not wake it.
|
|
512
|
+
if (!error || !passingFailure(error, said) || !(await isOn(env, now))) {
|
|
513
|
+
await clearRetryStreak(paths.stateDir, sessionId).catch(() => { });
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
const streak = await countFailure(paths.stateDir, sessionId, now);
|
|
517
|
+
if (streak.count > RETRY_LIMIT) {
|
|
518
|
+
const account = text(env.SIDEBY_ACCOUNT, 256);
|
|
519
|
+
const cwd = text(v.cwd);
|
|
520
|
+
await clearRetryStreak(paths.stateDir, sessionId).catch(() => { });
|
|
521
|
+
await addPendingDecision(paths.stateDir, {
|
|
522
|
+
kind: 'deferred',
|
|
523
|
+
family: 'claude',
|
|
524
|
+
...(account ? { account } : {}),
|
|
525
|
+
sessionId,
|
|
526
|
+
...(cwd ? { cwd } : {}),
|
|
527
|
+
text: retryGaveUpText(error, text(v.last_assistant_message, 1000) ?? ''),
|
|
528
|
+
}, now, { dedupe: true }).catch(() => { });
|
|
529
|
+
return undefined;
|
|
530
|
+
}
|
|
531
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
532
|
+
await sleep(retryDelay(streak.count));
|
|
533
|
+
if ((deps.parentGone ?? (() => process.ppid === 1))())
|
|
534
|
+
return undefined;
|
|
535
|
+
if ((await readRetryStreak(paths.stateDir, sessionId))?.token !== streak.token)
|
|
536
|
+
return undefined;
|
|
537
|
+
if (!(await isOn(env, clock())))
|
|
538
|
+
return undefined;
|
|
539
|
+
return retryMessage(error, text(v.last_assistant_message, 1000) ?? '', streak.count, prefersChinese(env));
|
|
540
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sideby",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Run work, personal and API-key accounts at the same time, without their configs drifting apart.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adonis0123 (https://github.com/Adonis0123)",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
|
+
"assets/brand",
|
|
50
51
|
"schemas",
|
|
51
52
|
"skills",
|
|
52
53
|
"mods/claude/.claude-plugin",
|