github-issue-tower-defence-management 1.104.4 → 1.106.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/CHANGELOG.md +20 -0
- package/README.md +8 -7
- package/bin/adapter/entry-points/cli/index.js +21 -13
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/console/{consoleServer.js → webServer.js} +11 -11
- package/bin/adapter/entry-points/console/webServer.js.map +1 -0
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +54 -2
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -1
- package/bin/adapter/entry-points/handlers/dashboardRowWriter.js +34 -0
- package/bin/adapter/entry-points/handlers/dashboardRowWriter.js.map +1 -0
- package/bin/adapter/entry-points/handlers/machineStatusWriter.js +60 -0
- package/bin/adapter/entry-points/handlers/machineStatusWriter.js.map +1 -0
- package/bin/adapter/entry-points/handlers/staleTmuxSessionCleaner.js +18 -0
- package/bin/adapter/entry-points/handlers/staleTmuxSessionCleaner.js.map +1 -0
- package/bin/adapter/entry-points/handlers/tokenStatusWriter.js +98 -0
- package/bin/adapter/entry-points/handlers/tokenStatusWriter.js.map +1 -0
- package/bin/adapter/proxy/RateLimitCache.js +3 -0
- package/bin/adapter/proxy/RateLimitCache.js.map +1 -1
- package/bin/adapter/repositories/NodeTmuxSessionRepository.js +22 -0
- package/bin/adapter/repositories/NodeTmuxSessionRepository.js.map +1 -1
- package/bin/adapter/repositories/ProcHostMetricsRepository.js +136 -0
- package/bin/adapter/repositories/ProcHostMetricsRepository.js.map +1 -0
- package/bin/adapter/repositories/ProcTakeOwnershipSpawnRepository.js +131 -0
- package/bin/adapter/repositories/ProcTakeOwnershipSpawnRepository.js.map +1 -0
- package/bin/domain/entities/LiveTmuxSession.js +3 -0
- package/bin/domain/entities/LiveTmuxSession.js.map +1 -0
- package/bin/domain/usecases/StaleTmuxSessionKillUseCase.js +58 -0
- package/bin/domain/usecases/StaleTmuxSessionKillUseCase.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository.js.map +1 -0
- package/bin/domain/usecases/dashboard/GenerateDashboardRowUseCase.js +38 -0
- package/bin/domain/usecases/dashboard/GenerateDashboardRowUseCase.js.map +1 -0
- package/bin/domain/usecases/dashboard/GenerateTokenStatusUseCase.js +115 -0
- package/bin/domain/usecases/dashboard/GenerateTokenStatusUseCase.js.map +1 -0
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.test.ts +74 -21
- package/src/adapter/entry-points/cli/index.ts +146 -136
- package/src/adapter/entry-points/console/ui/e2e/consoleTestHarness.ts +2 -2
- package/src/adapter/entry-points/console/{consoleServer.test.ts → webServer.test.ts} +32 -32
- package/src/adapter/entry-points/console/{consoleServer.ts → webServer.ts} +15 -17
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts +69 -0
- package/src/adapter/entry-points/handlers/dashboardRowWriter.test.ts +111 -0
- package/src/adapter/entry-points/handlers/dashboardRowWriter.ts +51 -0
- package/src/adapter/entry-points/handlers/machineStatusWriter.test.ts +100 -0
- package/src/adapter/entry-points/handlers/machineStatusWriter.ts +79 -0
- package/src/adapter/entry-points/handlers/staleTmuxSessionCleaner.test.ts +170 -0
- package/src/adapter/entry-points/handlers/staleTmuxSessionCleaner.ts +40 -0
- package/src/adapter/entry-points/handlers/tokenStatusWriter.test.ts +176 -0
- package/src/adapter/entry-points/handlers/tokenStatusWriter.ts +139 -0
- package/src/adapter/proxy/RateLimitCache.test.ts +32 -0
- package/src/adapter/proxy/RateLimitCache.ts +6 -0
- package/src/adapter/repositories/NodeTmuxSessionRepository.test.ts +81 -0
- package/src/adapter/repositories/NodeTmuxSessionRepository.ts +35 -0
- package/src/adapter/repositories/ProcHostMetricsRepository.test.ts +135 -0
- package/src/adapter/repositories/ProcHostMetricsRepository.ts +136 -0
- package/src/adapter/repositories/ProcTakeOwnershipSpawnRepository.test.ts +130 -0
- package/src/adapter/repositories/ProcTakeOwnershipSpawnRepository.ts +118 -0
- package/src/domain/entities/LiveTmuxSession.ts +4 -0
- package/src/domain/usecases/StaleTmuxSessionKillUseCase.test.ts +286 -0
- package/src/domain/usecases/StaleTmuxSessionKillUseCase.ts +102 -0
- package/src/domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository.ts +8 -0
- package/src/domain/usecases/adapter-interfaces/TmuxSessionRepository.ts +4 -0
- package/src/domain/usecases/dashboard/GenerateDashboardRowUseCase.test.ts +159 -0
- package/src/domain/usecases/dashboard/GenerateDashboardRowUseCase.ts +72 -0
- package/src/domain/usecases/dashboard/GenerateTokenStatusUseCase.test.ts +209 -0
- package/src/domain/usecases/dashboard/GenerateTokenStatusUseCase.ts +195 -0
- package/src/domain/usecases/intmux/InTmuxByHumanSessionReconcileUseCase.test.ts +6 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/console/{consoleServer.d.ts → webServer.d.ts} +7 -7
- package/types/adapter/entry-points/console/webServer.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/dashboardRowWriter.d.ts +15 -0
- package/types/adapter/entry-points/handlers/dashboardRowWriter.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/machineStatusWriter.d.ts +16 -0
- package/types/adapter/entry-points/handlers/machineStatusWriter.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/staleTmuxSessionCleaner.d.ts +12 -0
- package/types/adapter/entry-points/handlers/staleTmuxSessionCleaner.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/tokenStatusWriter.d.ts +21 -0
- package/types/adapter/entry-points/handlers/tokenStatusWriter.d.ts.map +1 -0
- package/types/adapter/proxy/RateLimitCache.d.ts +2 -0
- package/types/adapter/proxy/RateLimitCache.d.ts.map +1 -1
- package/types/adapter/repositories/NodeTmuxSessionRepository.d.ts +3 -0
- package/types/adapter/repositories/NodeTmuxSessionRepository.d.ts.map +1 -1
- package/types/adapter/repositories/ProcHostMetricsRepository.d.ts +23 -0
- package/types/adapter/repositories/ProcHostMetricsRepository.d.ts.map +1 -0
- package/types/adapter/repositories/ProcTakeOwnershipSpawnRepository.d.ts +11 -0
- package/types/adapter/repositories/ProcTakeOwnershipSpawnRepository.d.ts.map +1 -0
- package/types/domain/entities/LiveTmuxSession.d.ts +5 -0
- package/types/domain/entities/LiveTmuxSession.d.ts.map +1 -0
- package/types/domain/usecases/StaleTmuxSessionKillUseCase.d.ts +19 -0
- package/types/domain/usecases/StaleTmuxSessionKillUseCase.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository.d.ts +8 -0
- package/types/domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/TmuxSessionRepository.d.ts +3 -0
- package/types/domain/usecases/adapter-interfaces/TmuxSessionRepository.d.ts.map +1 -1
- package/types/domain/usecases/dashboard/GenerateDashboardRowUseCase.d.ts +19 -0
- package/types/domain/usecases/dashboard/GenerateDashboardRowUseCase.d.ts.map +1 -0
- package/types/domain/usecases/dashboard/GenerateTokenStatusUseCase.d.ts +53 -0
- package/types/domain/usecases/dashboard/GenerateTokenStatusUseCase.d.ts.map +1 -0
- package/bin/adapter/entry-points/console/consoleServer.js.map +0 -1
- package/types/adapter/entry-points/console/consoleServer.d.ts.map +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GenerateTokenStatusUseCase,
|
|
3
|
+
TokenRateLimitDecision,
|
|
4
|
+
TokenRateLimitSnapshot,
|
|
5
|
+
judgeTokenColor,
|
|
6
|
+
} from './GenerateTokenStatusUseCase';
|
|
7
|
+
|
|
8
|
+
const usableDecision = (
|
|
9
|
+
overrides: Partial<TokenRateLimitDecision> = {},
|
|
10
|
+
): TokenRateLimitDecision => ({
|
|
11
|
+
fiveHourUtilization: 0.1,
|
|
12
|
+
sevenDayUtilization: 0.1,
|
|
13
|
+
fiveHourRejected: false,
|
|
14
|
+
sevenDayRejected: false,
|
|
15
|
+
blocked: false,
|
|
16
|
+
unifiedStatus: 'allowed',
|
|
17
|
+
sevenDaySonnetRejected: false,
|
|
18
|
+
sevenDayOpusRejected: false,
|
|
19
|
+
partial: false,
|
|
20
|
+
...overrides,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('judgeTokenColor', () => {
|
|
24
|
+
it('returns Y when there is no snapshot or the snapshot is partial', () => {
|
|
25
|
+
expect(judgeTokenColor(null)).toBe('Y');
|
|
26
|
+
expect(judgeTokenColor(usableDecision({ partial: true }))).toBe('Y');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns G for a normal allowed low-utilization token', () => {
|
|
30
|
+
expect(judgeTokenColor(usableDecision())).toBe('G');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns Y for high utilization while allowed', () => {
|
|
34
|
+
expect(judgeTokenColor(usableDecision({ fiveHourUtilization: 0.8 }))).toBe(
|
|
35
|
+
'Y',
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('keeps a token usable (G) when only Sonnet 7d is rejected but Opus is usable', () => {
|
|
40
|
+
expect(
|
|
41
|
+
judgeTokenColor(
|
|
42
|
+
usableDecision({
|
|
43
|
+
sevenDaySonnetRejected: true,
|
|
44
|
+
sevenDayOpusRejected: false,
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
).toBe('G');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('returns Y when Sonnet is rejected, Opus usable, and 7d utilization is high', () => {
|
|
51
|
+
expect(
|
|
52
|
+
judgeTokenColor(
|
|
53
|
+
usableDecision({
|
|
54
|
+
sevenDaySonnetRejected: true,
|
|
55
|
+
sevenDayOpusRejected: false,
|
|
56
|
+
sevenDayUtilization: 0.8,
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
59
|
+
).toBe('Y');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('returns K when both Sonnet and Opus 7d are rejected', () => {
|
|
63
|
+
expect(
|
|
64
|
+
judgeTokenColor(
|
|
65
|
+
usableDecision({
|
|
66
|
+
sevenDaySonnetRejected: true,
|
|
67
|
+
sevenDayOpusRejected: true,
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
).toBe('K');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('returns K when the general 7d window is rejected', () => {
|
|
74
|
+
expect(judgeTokenColor(usableDecision({ sevenDayRejected: true }))).toBe(
|
|
75
|
+
'K',
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('returns K when the 5h window is rejected', () => {
|
|
80
|
+
expect(judgeTokenColor(usableDecision({ fiveHourRejected: true }))).toBe(
|
|
81
|
+
'K',
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('returns K when 5h utilization is exhausted', () => {
|
|
86
|
+
expect(judgeTokenColor(usableDecision({ fiveHourUtilization: 1.0 }))).toBe(
|
|
87
|
+
'K',
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns Y for the allowed_warning unified status', () => {
|
|
92
|
+
expect(
|
|
93
|
+
judgeTokenColor(usableDecision({ unifiedStatus: 'allowed_warning' })),
|
|
94
|
+
).toBe('Y');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const snapshot = (
|
|
99
|
+
overrides: Partial<TokenRateLimitSnapshot> = {},
|
|
100
|
+
): TokenRateLimitSnapshot => ({
|
|
101
|
+
fiveHourUtilization: 0.1,
|
|
102
|
+
fiveHourReset: 0,
|
|
103
|
+
sevenDayUtilization: 0.1,
|
|
104
|
+
sevenDayReset: 0,
|
|
105
|
+
blocked: false,
|
|
106
|
+
fiveHourRejected: false,
|
|
107
|
+
sevenDayRejected: false,
|
|
108
|
+
unifiedStatus: 'allowed',
|
|
109
|
+
sevenDaySonnetRejected: false,
|
|
110
|
+
sevenDayOpusRejected: false,
|
|
111
|
+
hasWindowData: true,
|
|
112
|
+
...overrides,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('GenerateTokenStatusUseCase', () => {
|
|
116
|
+
const usecase = new GenerateTokenStatusUseCase();
|
|
117
|
+
const now = 1_000_000;
|
|
118
|
+
|
|
119
|
+
it('renders per-token utilization percents, color, prep and hum counts', () => {
|
|
120
|
+
const result = usecase.run({
|
|
121
|
+
tokens: [
|
|
122
|
+
{
|
|
123
|
+
name: 'alice',
|
|
124
|
+
token: 'token-a',
|
|
125
|
+
snapshot: snapshot({
|
|
126
|
+
fiveHourUtilization: 0.42,
|
|
127
|
+
fiveHourReset: now + 3600,
|
|
128
|
+
sevenDayUtilization: 0.8,
|
|
129
|
+
sevenDayReset: now + 86400,
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
{ name: 'bob', token: 'token-b', snapshot: null },
|
|
133
|
+
],
|
|
134
|
+
prepCountByToken: new Map([['token-a', 2]]),
|
|
135
|
+
humCountByToken: new Map([['token-a', 1]]),
|
|
136
|
+
nowEpochSeconds: now,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
expect(result).toEqual([
|
|
140
|
+
{
|
|
141
|
+
name: 'alice',
|
|
142
|
+
fiveHourUtilizationPercent: 42,
|
|
143
|
+
fiveHourResetSeconds: 3600,
|
|
144
|
+
sevenDayUtilizationPercent: 80,
|
|
145
|
+
sevenDayResetSeconds: 86400,
|
|
146
|
+
color: 'Y',
|
|
147
|
+
prep: 2,
|
|
148
|
+
hum: 1,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'bob',
|
|
152
|
+
fiveHourUtilizationPercent: null,
|
|
153
|
+
fiveHourResetSeconds: null,
|
|
154
|
+
sevenDayUtilizationPercent: null,
|
|
155
|
+
sevenDayResetSeconds: null,
|
|
156
|
+
color: 'Y',
|
|
157
|
+
prep: 0,
|
|
158
|
+
hum: 0,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('reports G for an allowed token with headroom on both windows', () => {
|
|
164
|
+
const result = usecase.run({
|
|
165
|
+
tokens: [
|
|
166
|
+
{
|
|
167
|
+
name: 'alice',
|
|
168
|
+
token: 'token-a',
|
|
169
|
+
snapshot: snapshot({
|
|
170
|
+
fiveHourUtilization: 0.1,
|
|
171
|
+
fiveHourReset: now + 3600,
|
|
172
|
+
sevenDayUtilization: 0.1,
|
|
173
|
+
sevenDayReset: now + 86400,
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
prepCountByToken: new Map(),
|
|
178
|
+
humCountByToken: new Map(),
|
|
179
|
+
nowEpochSeconds: now,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
expect(result[0].color).toBe('G');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('zeroes a window whose reset is already in the past and clears its rejection', () => {
|
|
186
|
+
const result = usecase.run({
|
|
187
|
+
tokens: [
|
|
188
|
+
{
|
|
189
|
+
name: 'alice',
|
|
190
|
+
token: 'token-a',
|
|
191
|
+
snapshot: snapshot({
|
|
192
|
+
fiveHourUtilization: 1.0,
|
|
193
|
+
fiveHourReset: now - 10,
|
|
194
|
+
fiveHourRejected: true,
|
|
195
|
+
sevenDayUtilization: 0.2,
|
|
196
|
+
sevenDayReset: now + 86400,
|
|
197
|
+
}),
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
prepCountByToken: new Map(),
|
|
201
|
+
humCountByToken: new Map(),
|
|
202
|
+
nowEpochSeconds: now,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
expect(result[0].fiveHourUtilizationPercent).toBe(0);
|
|
206
|
+
expect(result[0].fiveHourResetSeconds).toBe(0);
|
|
207
|
+
expect(result[0].color).toBe('G');
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export type TokenStatusColor = 'G' | 'Y' | 'K';
|
|
2
|
+
|
|
3
|
+
export type TokenRateLimitSnapshot = {
|
|
4
|
+
fiveHourUtilization: number;
|
|
5
|
+
fiveHourReset: number;
|
|
6
|
+
sevenDayUtilization: number;
|
|
7
|
+
sevenDayReset: number;
|
|
8
|
+
blocked: boolean;
|
|
9
|
+
fiveHourRejected: boolean;
|
|
10
|
+
sevenDayRejected: boolean;
|
|
11
|
+
unifiedStatus: string | null;
|
|
12
|
+
sevenDaySonnetRejected: boolean;
|
|
13
|
+
sevenDayOpusRejected: boolean;
|
|
14
|
+
hasWindowData: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type TokenRateLimitDecision = {
|
|
18
|
+
fiveHourUtilization: number | null;
|
|
19
|
+
sevenDayUtilization: number | null;
|
|
20
|
+
fiveHourRejected: boolean;
|
|
21
|
+
sevenDayRejected: boolean;
|
|
22
|
+
blocked: boolean;
|
|
23
|
+
unifiedStatus: string | null;
|
|
24
|
+
sevenDaySonnetRejected: boolean;
|
|
25
|
+
sevenDayOpusRejected: boolean;
|
|
26
|
+
partial: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type TokenStatus = {
|
|
30
|
+
name: string;
|
|
31
|
+
fiveHourUtilizationPercent: number | null;
|
|
32
|
+
fiveHourResetSeconds: number | null;
|
|
33
|
+
sevenDayUtilizationPercent: number | null;
|
|
34
|
+
sevenDayResetSeconds: number | null;
|
|
35
|
+
color: TokenStatusColor;
|
|
36
|
+
prep: number;
|
|
37
|
+
hum: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type TokenStatusInput = {
|
|
41
|
+
name: string;
|
|
42
|
+
token: string;
|
|
43
|
+
snapshot: TokenRateLimitSnapshot | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type GenerateTokenStatusInput = {
|
|
47
|
+
tokens: TokenStatusInput[];
|
|
48
|
+
prepCountByToken: Map<string, number>;
|
|
49
|
+
humCountByToken: Map<string, number>;
|
|
50
|
+
nowEpochSeconds: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const HIGH_UTILIZATION_THRESHOLD = 0.7;
|
|
54
|
+
const ALLOWED_WARNING_STATUS = 'allowed_warning';
|
|
55
|
+
|
|
56
|
+
export const judgeTokenColor = (
|
|
57
|
+
decision: TokenRateLimitDecision | null,
|
|
58
|
+
): TokenStatusColor => {
|
|
59
|
+
if (decision === null || decision.partial) {
|
|
60
|
+
return 'Y';
|
|
61
|
+
}
|
|
62
|
+
const fiveHourUtilization = decision.fiveHourUtilization ?? 0;
|
|
63
|
+
const sevenDayUtilization = decision.sevenDayUtilization ?? 0;
|
|
64
|
+
const fiveHourExhausted =
|
|
65
|
+
fiveHourUtilization >= 1.0 || decision.fiveHourRejected;
|
|
66
|
+
const generalSevenDayRejected = decision.sevenDayRejected;
|
|
67
|
+
const bothModelsSevenDayRejected =
|
|
68
|
+
decision.sevenDaySonnetRejected && decision.sevenDayOpusRejected;
|
|
69
|
+
const noModelUsable =
|
|
70
|
+
decision.blocked ||
|
|
71
|
+
fiveHourExhausted ||
|
|
72
|
+
generalSevenDayRejected ||
|
|
73
|
+
bothModelsSevenDayRejected;
|
|
74
|
+
if (noModelUsable) {
|
|
75
|
+
return 'K';
|
|
76
|
+
}
|
|
77
|
+
if (decision.unifiedStatus === ALLOWED_WARNING_STATUS) {
|
|
78
|
+
return 'Y';
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
fiveHourUtilization >= HIGH_UTILIZATION_THRESHOLD ||
|
|
82
|
+
sevenDayUtilization >= HIGH_UTILIZATION_THRESHOLD
|
|
83
|
+
) {
|
|
84
|
+
return 'Y';
|
|
85
|
+
}
|
|
86
|
+
return 'G';
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export class GenerateTokenStatusUseCase {
|
|
90
|
+
run = (input: GenerateTokenStatusInput): TokenStatus[] => {
|
|
91
|
+
const { tokens, prepCountByToken, humCountByToken, nowEpochSeconds } =
|
|
92
|
+
input;
|
|
93
|
+
return tokens.map((tokenInput) => {
|
|
94
|
+
const decision = this.toDecision(tokenInput.snapshot, nowEpochSeconds);
|
|
95
|
+
const normalized = this.normalizeWindows(
|
|
96
|
+
tokenInput.snapshot,
|
|
97
|
+
nowEpochSeconds,
|
|
98
|
+
);
|
|
99
|
+
return {
|
|
100
|
+
name: tokenInput.name,
|
|
101
|
+
fiveHourUtilizationPercent: normalized.fiveHourUtilizationPercent,
|
|
102
|
+
fiveHourResetSeconds: normalized.fiveHourResetSeconds,
|
|
103
|
+
sevenDayUtilizationPercent: normalized.sevenDayUtilizationPercent,
|
|
104
|
+
sevenDayResetSeconds: normalized.sevenDayResetSeconds,
|
|
105
|
+
color: judgeTokenColor(decision),
|
|
106
|
+
prep: prepCountByToken.get(tokenInput.token) ?? 0,
|
|
107
|
+
hum: humCountByToken.get(tokenInput.token) ?? 0,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
private normalizeWindows = (
|
|
113
|
+
snapshot: TokenRateLimitSnapshot | null,
|
|
114
|
+
nowEpochSeconds: number,
|
|
115
|
+
): {
|
|
116
|
+
fiveHourUtilizationPercent: number | null;
|
|
117
|
+
fiveHourResetSeconds: number | null;
|
|
118
|
+
sevenDayUtilizationPercent: number | null;
|
|
119
|
+
sevenDayResetSeconds: number | null;
|
|
120
|
+
} => {
|
|
121
|
+
if (snapshot === null || !snapshot.hasWindowData) {
|
|
122
|
+
return {
|
|
123
|
+
fiveHourUtilizationPercent: null,
|
|
124
|
+
fiveHourResetSeconds: null,
|
|
125
|
+
sevenDayUtilizationPercent: null,
|
|
126
|
+
sevenDayResetSeconds: null,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const fiveHourReset =
|
|
130
|
+
snapshot.fiveHourReset > 0 ? snapshot.fiveHourReset : null;
|
|
131
|
+
const sevenDayReset =
|
|
132
|
+
snapshot.sevenDayReset > 0 ? snapshot.sevenDayReset : null;
|
|
133
|
+
const fiveHourExpired =
|
|
134
|
+
fiveHourReset !== null && fiveHourReset < nowEpochSeconds;
|
|
135
|
+
const sevenDayExpired =
|
|
136
|
+
sevenDayReset !== null && sevenDayReset < nowEpochSeconds;
|
|
137
|
+
return {
|
|
138
|
+
fiveHourUtilizationPercent: fiveHourExpired
|
|
139
|
+
? 0
|
|
140
|
+
: Math.trunc(snapshot.fiveHourUtilization * 100),
|
|
141
|
+
fiveHourResetSeconds:
|
|
142
|
+
fiveHourReset === null
|
|
143
|
+
? null
|
|
144
|
+
: Math.max(0, fiveHourReset - nowEpochSeconds),
|
|
145
|
+
sevenDayUtilizationPercent: sevenDayExpired
|
|
146
|
+
? 0
|
|
147
|
+
: Math.trunc(snapshot.sevenDayUtilization * 100),
|
|
148
|
+
sevenDayResetSeconds:
|
|
149
|
+
sevenDayReset === null
|
|
150
|
+
? null
|
|
151
|
+
: Math.max(0, sevenDayReset - nowEpochSeconds),
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
private toDecision = (
|
|
156
|
+
snapshot: TokenRateLimitSnapshot | null,
|
|
157
|
+
nowEpochSeconds: number,
|
|
158
|
+
): TokenRateLimitDecision | null => {
|
|
159
|
+
if (snapshot === null) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (!snapshot.hasWindowData) {
|
|
163
|
+
return {
|
|
164
|
+
fiveHourUtilization: null,
|
|
165
|
+
sevenDayUtilization: null,
|
|
166
|
+
fiveHourRejected: snapshot.fiveHourRejected,
|
|
167
|
+
sevenDayRejected: snapshot.sevenDayRejected,
|
|
168
|
+
blocked: snapshot.blocked,
|
|
169
|
+
unifiedStatus: snapshot.unifiedStatus,
|
|
170
|
+
sevenDaySonnetRejected: snapshot.sevenDaySonnetRejected,
|
|
171
|
+
sevenDayOpusRejected: snapshot.sevenDayOpusRejected,
|
|
172
|
+
partial: true,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const fiveHourExpired =
|
|
176
|
+
snapshot.fiveHourReset > 0 && snapshot.fiveHourReset < nowEpochSeconds;
|
|
177
|
+
const sevenDayExpired =
|
|
178
|
+
snapshot.sevenDayReset > 0 && snapshot.sevenDayReset < nowEpochSeconds;
|
|
179
|
+
return {
|
|
180
|
+
fiveHourUtilization: fiveHourExpired ? 0 : snapshot.fiveHourUtilization,
|
|
181
|
+
sevenDayUtilization: sevenDayExpired ? 0 : snapshot.sevenDayUtilization,
|
|
182
|
+
fiveHourRejected: fiveHourExpired ? false : snapshot.fiveHourRejected,
|
|
183
|
+
sevenDayRejected: sevenDayExpired ? false : snapshot.sevenDayRejected,
|
|
184
|
+
blocked: snapshot.blocked,
|
|
185
|
+
unifiedStatus: snapshot.unifiedStatus,
|
|
186
|
+
sevenDaySonnetRejected:
|
|
187
|
+
snapshot.sevenDaySonnetRejected ||
|
|
188
|
+
(sevenDayExpired ? false : snapshot.sevenDayRejected),
|
|
189
|
+
sevenDayOpusRejected:
|
|
190
|
+
snapshot.sevenDayOpusRejected ||
|
|
191
|
+
(sevenDayExpired ? false : snapshot.sevenDayRejected),
|
|
192
|
+
partial: false,
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}
|
|
@@ -60,10 +60,16 @@ const createFakeTmuxSessionRepository = (state: {
|
|
|
60
60
|
return {
|
|
61
61
|
launches,
|
|
62
62
|
listLiveSessionNames: async () => state.liveSessionNames,
|
|
63
|
+
listLiveSessionsWithActivity: async () =>
|
|
64
|
+
state.liveSessionNames.map((sessionName) => ({
|
|
65
|
+
sessionName,
|
|
66
|
+
activityEpochSeconds: 0,
|
|
67
|
+
})),
|
|
63
68
|
listInteractiveProcessCommandLines: async () => state.processCommandLines,
|
|
64
69
|
launchDetachedSession: async (sessionName, launcherCommand, issueUrl) => {
|
|
65
70
|
launches.push({ sessionName, launcherCommand, issueUrl });
|
|
66
71
|
},
|
|
72
|
+
killSession: async () => undefined,
|
|
67
73
|
};
|
|
68
74
|
};
|
|
69
75
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AA4GzB,eAAO,MAAM,OAAO,SAAgB,CAAC"}
|
|
@@ -3,14 +3,14 @@ import { IssueRepository } from '../../../domain/usecases/adapter-interfaces/Iss
|
|
|
3
3
|
import { IssueTitleStateCache } from './consoleReadApi';
|
|
4
4
|
import { ConsoleProjectResolver } from './consoleOperationApi';
|
|
5
5
|
import { ImageFetcher } from './consoleImageProxy';
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const DEFAULT_WEB_PORT = 9981;
|
|
7
7
|
export declare const CONSOLE_TOKEN_HEADER = "x-pv-token";
|
|
8
8
|
export declare const hasDotSegment: (requestPath: string) => boolean;
|
|
9
9
|
export declare const requiresToken: (requestPath: string) => boolean;
|
|
10
10
|
export declare const isConsoleAppRoute: (requestPath: string) => boolean;
|
|
11
11
|
export declare const isTokenValid: (expectedToken: string, providedToken: string | null) => boolean;
|
|
12
12
|
export declare const extractProvidedToken: (queryToken: string | string[] | null, headerToken: string | string[] | undefined) => string | null;
|
|
13
|
-
export type
|
|
13
|
+
export type WebServerOptions = {
|
|
14
14
|
accessToken: string;
|
|
15
15
|
uiDistDir: string;
|
|
16
16
|
consoleDataOutputDir: string | null;
|
|
@@ -26,10 +26,10 @@ export declare const DASHBOARD_REQUEST_PATH = "/tdpm.txt";
|
|
|
26
26
|
export declare const IMAGE_PROXY_REQUEST_PATH = "/api/img";
|
|
27
27
|
export declare const resolveDashboardFilePath: (dashboardDir: string, requestPath: string) => string | null;
|
|
28
28
|
export declare const resolveFlatInTmuxFilePath: (inTmuxDataDir: string, requestPath: string) => string | null;
|
|
29
|
-
export declare const
|
|
30
|
-
export declare const
|
|
31
|
-
export type
|
|
29
|
+
export declare const handleWebRequest: (options: WebServerOptions, request: http.IncomingMessage, response: http.ServerResponse) => Promise<void>;
|
|
30
|
+
export declare const createWebServer: (options: WebServerOptions) => http.Server;
|
|
31
|
+
export type StartWebServerOptions = WebServerOptions & {
|
|
32
32
|
port: number;
|
|
33
33
|
};
|
|
34
|
-
export declare const
|
|
35
|
-
//# sourceMappingURL=
|
|
34
|
+
export declare const startWebServer: (options: StartWebServerOptions) => Promise<http.Server>;
|
|
35
|
+
//# sourceMappingURL=webServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webServer.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/webServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AAM9F,OAAO,EACL,oBAAoB,EAOrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,sBAAsB,EAMvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAqB,MAAM,qBAAqB,CAAC;AAEtE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAmCjD,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,KAAG,OAGiB,CAAC;AAEtE,eAAO,MAAM,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AAC,IAAI,CAiFd,CAAC;AAcF,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,IAAI,CAAC,MAM7D,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,SAAS,qBAAqB,KAC7B,OAAO,CAAC,IAAI,CAAC,MAAM,CAQlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandleScheduledEventUseCaseHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HandleScheduledEventUseCaseHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAgC3D,qBAAa,kCAAkC;IAC7C,MAAM,GACJ,gBAAgB,MAAM,EACtB,UAAU,OAAO,KAChB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,KAAK,EAAE,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,eAAe,EAAE,IAAI,EAAE,CAAC;KACzB,GAAG,IAAI,CAAC,CAwcP;CACH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Issue } from '../../../domain/entities/Issue';
|
|
2
|
+
import { DashboardRow } from '../../../domain/usecases/dashboard/GenerateDashboardRowUseCase';
|
|
3
|
+
export type DashboardRowWriterParams = {
|
|
4
|
+
dashboardDataDir: string | null | undefined;
|
|
5
|
+
pjcode: string | null | undefined;
|
|
6
|
+
assigneeLogin: string | null | undefined;
|
|
7
|
+
issues: Issue[];
|
|
8
|
+
generatedAt?: string;
|
|
9
|
+
};
|
|
10
|
+
export type DashboardRowFile = DashboardRow & {
|
|
11
|
+
pjcode: string;
|
|
12
|
+
capturedAt: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const writeDashboardRow: (params: DashboardRowWriterParams) => void;
|
|
15
|
+
//# sourceMappingURL=dashboardRowWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboardRowWriter.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/dashboardRowWriter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EACL,YAAY,EAEb,MAAM,gEAAgE,CAAC;AAExE,MAAM,MAAM,wBAAwB,GAAG;IACrC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,wBAAwB,KAAG,IAqBpE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProcHostMetricsRepository } from '../../repositories/ProcHostMetricsRepository';
|
|
2
|
+
export type MachineStatusWriterParams = {
|
|
3
|
+
dashboardDataDir: string | null | undefined;
|
|
4
|
+
allIssuesCacheDir: string | null | undefined;
|
|
5
|
+
hostMetricsRepository?: ProcHostMetricsRepository;
|
|
6
|
+
now?: Date;
|
|
7
|
+
};
|
|
8
|
+
export type MachineStatusFile = {
|
|
9
|
+
memPct: number;
|
|
10
|
+
cpuPct: number;
|
|
11
|
+
load: [number, number, number];
|
|
12
|
+
cycleMinutes: number | null;
|
|
13
|
+
capturedAt: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const writeMachineStatus: (params: MachineStatusWriterParams) => Promise<void>;
|
|
16
|
+
//# sourceMappingURL=machineStatusWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machineStatusWriter.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/machineStatusWriter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EAE1B,MAAM,8CAA8C,CAAC;AAEtD,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,qBAAqB,CAAC,EAAE,yBAAyB,CAAC;IAClD,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8BF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,yBAAyB,KAChC,OAAO,CAAC,IAAI,CA0Bd,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Project } from '../../../domain/entities/Project';
|
|
2
|
+
import { LocalCommandRunner } from '../../../domain/usecases/adapter-interfaces/LocalCommandRunner';
|
|
3
|
+
import { IssueRepository } from '../../../domain/usecases/adapter-interfaces/IssueRepository';
|
|
4
|
+
export type CleanStaleTmuxSessionsParams = {
|
|
5
|
+
project: Project;
|
|
6
|
+
allowCacheMinutes: number;
|
|
7
|
+
issueRepository: Pick<IssueRepository, 'getAllOpened'>;
|
|
8
|
+
localCommandRunner: LocalCommandRunner;
|
|
9
|
+
now: Date;
|
|
10
|
+
};
|
|
11
|
+
export declare const cleanStaleTmuxSessions: (params: CleanStaleTmuxSessionsParams) => Promise<void>;
|
|
12
|
+
//# sourceMappingURL=staleTmuxSessionCleaner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleTmuxSessionCleaner.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/staleTmuxSessionCleaner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gEAAgE,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AAQ9F,MAAM,MAAM,4BAA4B,GAAG;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACvD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,GAAG,EAAE,IAAI,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B,KACnC,OAAO,CAAC,IAAI,CAmBd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Issue } from '../../../domain/entities/Issue';
|
|
2
|
+
import { TokenRateLimitSnapshot, TokenStatus } from '../../../domain/usecases/dashboard/GenerateTokenStatusUseCase';
|
|
3
|
+
import { ClaudeInteractiveSessionRepository } from '../../../domain/usecases/adapter-interfaces/ClaudeInteractiveSessionRepository';
|
|
4
|
+
import { TakeOwnershipSpawnRepository } from '../../../domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository';
|
|
5
|
+
import { RateLimitSnapshot } from '../../proxy/RateLimitCache';
|
|
6
|
+
export type TokenStatusWriterParams = {
|
|
7
|
+
dashboardDataDir: string | null | undefined;
|
|
8
|
+
tokenListJsonPath: string | null | undefined;
|
|
9
|
+
issues: Issue[];
|
|
10
|
+
now?: Date;
|
|
11
|
+
readSnapshot?: (token: string) => RateLimitSnapshot | null;
|
|
12
|
+
interactiveSessionRepository?: ClaudeInteractiveSessionRepository;
|
|
13
|
+
spawnRepository?: TakeOwnershipSpawnRepository;
|
|
14
|
+
};
|
|
15
|
+
export type TokenStatusFile = {
|
|
16
|
+
tokens: TokenStatus[];
|
|
17
|
+
capturedAt: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const toTokenRateLimitSnapshot: (snapshot: RateLimitSnapshot | null) => TokenRateLimitSnapshot | null;
|
|
20
|
+
export declare const writeTokenStatus: (params: TokenStatusWriterParams) => void;
|
|
21
|
+
//# sourceMappingURL=tokenStatusWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenStatusWriter.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/tokenStatusWriter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAEL,sBAAsB,EACtB,WAAW,EAEZ,MAAM,+DAA+D,CAAC;AAGvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,gFAAgF,CAAC;AACpI,OAAO,EAAE,4BAA4B,EAAE,MAAM,0EAA0E,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAiB,MAAM,4BAA4B,CAAC;AAQ9E,MAAM,MAAM,uBAAuB,GAAG;IACpC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,GAAG,IAAI,CAAC;IAC3D,4BAA4B,CAAC,EAAE,kCAAkC,CAAC;IAClE,eAAe,CAAC,EAAE,4BAA4B,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,wBAAwB,GACnC,UAAU,iBAAiB,GAAG,IAAI,KACjC,sBAAsB,GAAG,IA0B3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,uBAAuB,KAAG,IAgElE,CAAC"}
|
|
@@ -12,6 +12,8 @@ export interface RateLimitSnapshot {
|
|
|
12
12
|
unifiedRejected: boolean;
|
|
13
13
|
fiveHourRejected: boolean;
|
|
14
14
|
sevenDayRejected: boolean;
|
|
15
|
+
unifiedStatus: string | null;
|
|
16
|
+
overageDisabledReason: string | null;
|
|
15
17
|
modelWeeklyLimits: Record<string, ModelWeeklyLimit>;
|
|
16
18
|
lastUpdatedEpoch: number;
|
|
17
19
|
blockedUntilEpoch: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RateLimitCache.d.ts","sourceRoot":"","sources":["../../../src/adapter/proxy/RateLimitCache.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B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AO,MAAM,+BAA+B,GAC1C,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC9B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAmBjC,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,UAAS,MAAmB,KAC3B,iBAAiB,GAAG,IA4DtB,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { LocalCommandRunner } from '../../domain/usecases/adapter-interfaces/LocalCommandRunner';
|
|
2
2
|
import { TmuxSessionRepository } from '../../domain/usecases/adapter-interfaces/TmuxSessionRepository';
|
|
3
|
+
import { LiveTmuxSession } from '../../domain/entities/LiveTmuxSession';
|
|
3
4
|
export declare class NodeTmuxSessionRepository implements TmuxSessionRepository {
|
|
4
5
|
private readonly localCommandRunner;
|
|
5
6
|
constructor(localCommandRunner: LocalCommandRunner);
|
|
6
7
|
listLiveSessionNames: () => Promise<string[]>;
|
|
8
|
+
listLiveSessionsWithActivity: () => Promise<LiveTmuxSession[]>;
|
|
7
9
|
listInteractiveProcessCommandLines: () => Promise<string[]>;
|
|
8
10
|
launchDetachedSession: (sessionName: string, launcherCommand: string, issueUrl: string) => Promise<void>;
|
|
11
|
+
killSession: (sessionName: string) => Promise<void>;
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=NodeTmuxSessionRepository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTmuxSessionRepository.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeTmuxSessionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeTmuxSessionRepository.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeTmuxSessionRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AACvG,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,qBAAa,yBAA0B,YAAW,qBAAqB;IACzD,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAAlB,kBAAkB,EAAE,kBAAkB;IAEnE,oBAAoB,QAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAYhD;IAEF,4BAA4B,QAAa,OAAO,CAAC,eAAe,EAAE,CAAC,CAkBjE;IAEF,kCAAkC,QAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAY9D;IAEF,qBAAqB,GACnB,aAAa,MAAM,EACnB,iBAAiB,MAAM,EACvB,UAAU,MAAM,KACf,OAAO,CAAC,IAAI,CAAC,CAcd;IAEF,WAAW,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAYtD;CACH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type CpuSample = {
|
|
2
|
+
total: number;
|
|
3
|
+
idle: number;
|
|
4
|
+
};
|
|
5
|
+
export type LoadAverages = {
|
|
6
|
+
oneMinute: number;
|
|
7
|
+
fiveMinute: number;
|
|
8
|
+
fifteenMinute: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const parseMemoryUsedPercent: (meminfoText: string) => number;
|
|
11
|
+
export declare const parseCpuSample: (statText: string) => CpuSample;
|
|
12
|
+
export declare const cpuUsedPercentFromSamples: (first: CpuSample, second: CpuSample) => number;
|
|
13
|
+
export declare const parseLoadAverages: (loadavgText: string) => LoadAverages;
|
|
14
|
+
export declare const cycleMinutesFromMtimes: (mtimesDescendingSeconds: number[]) => number | null;
|
|
15
|
+
export declare class ProcHostMetricsRepository {
|
|
16
|
+
private readonly procDirectory;
|
|
17
|
+
private readonly sleep;
|
|
18
|
+
constructor(procDirectory?: string, sleep?: (milliseconds: number) => Promise<void>);
|
|
19
|
+
readMemoryUsedPercent: () => number;
|
|
20
|
+
readCpuUsedPercent: () => Promise<number>;
|
|
21
|
+
readLoadAverages: () => LoadAverages;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ProcHostMetricsRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcHostMetricsRepository.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/ProcHostMetricsRepository.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,sBAAsB,GAAI,aAAa,MAAM,KAAG,MA2B5D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,SAiBjD,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,OAAO,SAAS,EAChB,QAAQ,SAAS,KAChB,MAQF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,YAavD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,yBAAyB,MAAM,EAAE,KAChC,MAAM,GAAG,IAOX,CAAC;AAEF,qBAAa,yBAAyB;IAElC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,aAAa,GAAE,MAA+B,EAC9C,KAAK,GAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAK1D;IAGN,qBAAqB,QAAO,MAAM,CAG9B;IAEJ,kBAAkB,QAAa,OAAO,CAAC,MAAM,CAAC,CAS5C;IAEF,gBAAgB,QAAO,YAAY,CAG/B;CACL"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TakeOwnershipSpawn, TakeOwnershipSpawnRepository } from '../../domain/usecases/adapter-interfaces/TakeOwnershipSpawnRepository';
|
|
2
|
+
export declare class ProcTakeOwnershipSpawnRepository implements TakeOwnershipSpawnRepository {
|
|
3
|
+
private readonly procDirectory;
|
|
4
|
+
constructor(procDirectory?: string);
|
|
5
|
+
listSpawns: () => TakeOwnershipSpawn[];
|
|
6
|
+
private listProcessIdDirectories;
|
|
7
|
+
private readSpawn;
|
|
8
|
+
private readRawCmdline;
|
|
9
|
+
private readEnviron;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ProcTakeOwnershipSpawnRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcTakeOwnershipSpawnRepository.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/ProcTakeOwnershipSpawnRepository.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,uEAAuE,CAAC;AAkB/E,qBAAa,gCAAiC,YAAW,4BAA4B;IAEjF,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,GAAE,MAA+B;IAGjE,UAAU,QAAO,kBAAkB,EAAE,CASnC;IAEF,OAAO,CAAC,wBAAwB,CAQ9B;IAEF,OAAO,CAAC,SAAS,CAwBf;IAEF,OAAO,CAAC,cAAc,CAWpB;IAEF,OAAO,CAAC,WAAW,CA4BjB;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveTmuxSession.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/LiveTmuxSession.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC"}
|