workday-daemon 0.1.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.
Files changed (56) hide show
  1. package/README.md +95 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +710 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/collectors/git-client.d.ts +16 -0
  6. package/dist/collectors/git-client.js +58 -0
  7. package/dist/collectors/git-client.js.map +1 -0
  8. package/dist/collectors/git-tracker.d.ts +43 -0
  9. package/dist/collectors/git-tracker.js +168 -0
  10. package/dist/collectors/git-tracker.js.map +1 -0
  11. package/dist/collectors/reflog-parser.d.ts +30 -0
  12. package/dist/collectors/reflog-parser.js +71 -0
  13. package/dist/collectors/reflog-parser.js.map +1 -0
  14. package/dist/collectors/snapshot-parser.d.ts +34 -0
  15. package/dist/collectors/snapshot-parser.js +79 -0
  16. package/dist/collectors/snapshot-parser.js.map +1 -0
  17. package/dist/core/activity-evaluator.d.ts +33 -0
  18. package/dist/core/activity-evaluator.js +94 -0
  19. package/dist/core/activity-evaluator.js.map +1 -0
  20. package/dist/core/config.d.ts +18 -0
  21. package/dist/core/config.js +174 -0
  22. package/dist/core/config.js.map +1 -0
  23. package/dist/core/constants.d.ts +39 -0
  24. package/dist/core/constants.js +51 -0
  25. package/dist/core/constants.js.map +1 -0
  26. package/dist/core/daily-log.d.ts +56 -0
  27. package/dist/core/daily-log.js +366 -0
  28. package/dist/core/daily-log.js.map +1 -0
  29. package/dist/core/session-tracker.d.ts +110 -0
  30. package/dist/core/session-tracker.js +460 -0
  31. package/dist/core/session-tracker.js.map +1 -0
  32. package/dist/core/status-renderer.d.ts +20 -0
  33. package/dist/core/status-renderer.js +178 -0
  34. package/dist/core/status-renderer.js.map +1 -0
  35. package/dist/core/types.d.ts +320 -0
  36. package/dist/core/types.js +52 -0
  37. package/dist/core/types.js.map +1 -0
  38. package/dist/daemon.d.ts +31 -0
  39. package/dist/daemon.js +266 -0
  40. package/dist/daemon.js.map +1 -0
  41. package/dist/http-server.d.ts +30 -0
  42. package/dist/http-server.js +342 -0
  43. package/dist/http-server.js.map +1 -0
  44. package/dist/push/jira-client.d.ts +5 -0
  45. package/dist/push/jira-client.js +84 -0
  46. package/dist/push/jira-client.js.map +1 -0
  47. package/dist/push/report-builder.d.ts +9 -0
  48. package/dist/push/report-builder.js +77 -0
  49. package/dist/push/report-builder.js.map +1 -0
  50. package/dist/push/tempo-client.d.ts +27 -0
  51. package/dist/push/tempo-client.js +92 -0
  52. package/dist/push/tempo-client.js.map +1 -0
  53. package/dist/push/tempo-pusher.d.ts +17 -0
  54. package/dist/push/tempo-pusher.js +317 -0
  55. package/dist/push/tempo-pusher.js.map +1 -0
  56. package/package.json +35 -0
@@ -0,0 +1,178 @@
1
+ import { basename } from 'node:path';
2
+ import { computeEffectiveDuration, computeTotalPauseDuration, computeDaySummary, computeManualMinutes, computeDayStart, computeBudgetMs, computeTotalClaimedMs, getRemainingBudgetMs, isBudgetExhausted, getOpenPause, } from './daily-log.js';
3
+ import { MS_PER_MINUTE } from './constants.js';
4
+ // ANSI helpers
5
+ const CLEAR = '\x1b[2J\x1b[H';
6
+ const BOLD = '\x1b[1m';
7
+ const DIM = '\x1b[2m';
8
+ const RESET = '\x1b[0m';
9
+ const GREEN = '\x1b[32m';
10
+ const YELLOW = '\x1b[33m';
11
+ const RED = '\x1b[31m';
12
+ const CYAN = '\x1b[36m';
13
+ const MAGENTA = '\x1b[35m';
14
+ const LINE_WIDTH = 60;
15
+ const LABEL_WIDTH = 10;
16
+ const INDENT = ' ';
17
+ const BAR_WIDTH = 10;
18
+ export class StatusRenderer {
19
+ ctx;
20
+ tickCount = 0;
21
+ constructor(ctx) {
22
+ this.ctx = ctx;
23
+ }
24
+ updateDate(date) {
25
+ this.ctx.currentDate = date;
26
+ }
27
+ renderError(message) {
28
+ this.render();
29
+ process.stdout.write(`\n ${RED}ERROR${RESET} ${message}\n`);
30
+ }
31
+ render() {
32
+ this.tickCount++;
33
+ const lines = [];
34
+ const now = Date.now();
35
+ // Header
36
+ lines.push(`${BOLD}${CYAN} WORKDAY DAEMON${RESET}`);
37
+ lines.push(`${DIM}${'─'.repeat(LINE_WIDTH)}${RESET}`);
38
+ // Daemon info
39
+ const uptime = formatDuration(now - this.ctx.startedAt);
40
+ const tracker = this.ctx.sessionTracker;
41
+ const log = tracker.getDailyLog();
42
+ const dayStartTs = computeDayStart(log, this.ctx.config);
43
+ const dayStartTime = formatTime(dayStartTs, this.ctx.timezone);
44
+ lines.push(` ${DIM}PID${RESET} ${process.pid} ${DIM}Date${RESET} ${this.ctx.currentDate} ${DIM}Start${RESET} ${dayStartTime} ${DIM}Up${RESET} ${uptime} ${DIM}(#${this.tickCount})${RESET}`);
45
+ lines.push('');
46
+ // Sessions
47
+ const openSessions = log.sessions.filter(s => !s.closedBy);
48
+ const closedSessions = log.sessions.filter(s => s.closedBy);
49
+ const evalResult = tracker.getLastEvaluatorResult();
50
+ if (openSessions.length === 0 && closedSessions.length === 0) {
51
+ lines.push(` ${DIM}No sessions yet. Waiting for git activity...${RESET}`);
52
+ }
53
+ else {
54
+ // Open sessions
55
+ if (openSessions.length > 0) {
56
+ lines.push(`${BOLD} ACTIVE SESSIONS${RESET} ${DIM}(${openSessions.length})${RESET}`);
57
+ lines.push(`${DIM}${'─'.repeat(LINE_WIDTH)}${RESET}`);
58
+ for (let si = 0; si < openSessions.length; si++) {
59
+ const session = openSessions[si];
60
+ const globalIdx = log.sessions.indexOf(session) + 1;
61
+ const sessionScore = evalResult?.scores.get(session.id);
62
+ const isPaused = tracker.hasOpenPause(session);
63
+ const openPause = getOpenPause(session);
64
+ const repoLabel = basename(session.repo);
65
+ const dur = formatDuration(computeEffectiveDuration(session));
66
+ const manualMin = computeManualMinutes(session);
67
+ const manualStr = manualMin > 0 ? ` ${MAGENTA}+ ${manualMin}m manual${RESET}` : '';
68
+ const ema = sessionScore?.ema ?? 0;
69
+ // Status badge + dot indicator
70
+ let badge;
71
+ if (isPaused && openPause) {
72
+ badge = `${RED}PAUSED:${openPause.source}${RESET}`;
73
+ }
74
+ else if (session.state === 'active') {
75
+ badge = `${GREEN}ACTIVE${RESET}`;
76
+ }
77
+ else {
78
+ badge = `${YELLOW}PENDING${RESET}`;
79
+ }
80
+ const dot = (!isPaused && session.state === 'active') ? ` ${GREEN}●${RESET}` : '';
81
+ const autoPauseOff = tracker.isAutoPauseDisabled(session.id) ? ` ${DIM}[AP OFF]${RESET}` : '';
82
+ const COL1 = 18; // first value column width
83
+ lines.push(` ${DIM}#${globalIdx}${RESET} ${BOLD}${repoLabel}${RESET}${dot} ${badge}${autoPauseOff}`);
84
+ const L = (label) => `${INDENT}${DIM}${label.padEnd(LABEL_WIDTH)}${RESET}`;
85
+ const R = (label) => `${DIM}${label}${RESET} `;
86
+ lines.push(`${L('Task')}${(session.task ?? '—').padEnd(COL1)}${R('branch')}${session.branch}`);
87
+ const sinceTs = session.activatedAt ?? session.startedAt;
88
+ const sinceTime = formatTime(new Date(sinceTs).getTime(), this.ctx.timezone);
89
+ lines.push(`${L('Time')}${dur}${manualStr}${''.padEnd(Math.max(0, COL1 - dur.length))}${R('since')}${sinceTime}`);
90
+ // Intensity bar (EMA) with autopause countdown
91
+ const rawScore = sessionScore?.score ?? 0;
92
+ const showAutopause = !isPaused && session.state === 'active' && rawScore > 0;
93
+ const autoPauseStr = showAutopause
94
+ ? ` ${DIM}auto-pause${RESET} ${formatDuration(rawScore * this.ctx.pollSeconds * 1000)}`
95
+ : '';
96
+ lines.push(`${L('Intensity')}${renderBar(ema, BAR_WIDTH)}${autoPauseStr}`);
97
+ // Evidence: GitHub-style stats
98
+ const ev = session.evidence;
99
+ const filesStr = ev.filesChanged > 0 ? `${ev.filesChanged} files ` : '';
100
+ lines.push(`${L('Changes')}${ev.commits} commits ${filesStr}${GREEN}+${ev.linesAdded}${RESET} ${RED}-${ev.linesRemoved}${RESET}`);
101
+ if (session.pauses.length > 0) {
102
+ const totalPause = formatDuration(computeTotalPauseDuration(session));
103
+ lines.push(`${L('Pauses')}${session.pauses.length} (${totalPause} total)`);
104
+ }
105
+ lines.push('');
106
+ }
107
+ }
108
+ // Closed sessions summary
109
+ if (closedSessions.length > 0) {
110
+ lines.push(`${BOLD} CLOSED SESSIONS${RESET} ${DIM}(${closedSessions.length})${RESET}`);
111
+ lines.push(`${DIM}${'─'.repeat(LINE_WIDTH)}${RESET}`);
112
+ for (const session of closedSessions) {
113
+ const repoLabel = basename(session.repo).padEnd(18);
114
+ const task = (session.task ?? '—').padEnd(14);
115
+ const dur = formatDuration(computeEffectiveDuration(session)).padEnd(10);
116
+ lines.push(` ${DIM}${repoLabel}${task}${dur}closed(${session.closedBy})${RESET}`);
117
+ }
118
+ lines.push('');
119
+ }
120
+ }
121
+ // Footer: actual work/downtime via interval merge + budget
122
+ const { workMs, downtimeMs, spanMs } = computeDaySummary(log.sessions);
123
+ lines.push(`${DIM}${'─'.repeat(LINE_WIDTH)}${RESET}`);
124
+ lines.push(` ${BOLD}Worktime${RESET} ${formatDuration(workMs)} ${BOLD}Idle${RESET} ${formatDuration(downtimeMs)} ${BOLD}Total${RESET} ${formatDuration(spanMs)}`);
125
+ // Budget bar
126
+ const config = this.ctx.config;
127
+ const budgetMs = computeBudgetMs(log, config);
128
+ const claimedMs = computeTotalClaimedMs(log);
129
+ const remainingMs = getRemainingBudgetMs(log, config);
130
+ const totalManualMs = log.sessions.reduce((sum, s) => sum + computeManualMinutes(s) * MS_PER_MINUTE, 0);
131
+ const autoWorkMs = claimedMs - totalManualMs;
132
+ const budgetLine = ` ${BOLD}Budget${RESET} ${formatDuration(budgetMs)} | ` +
133
+ `${BOLD}Work${RESET} ${formatDuration(autoWorkMs)}` +
134
+ (totalManualMs > 0 ? ` + ${MAGENTA}Manual ${formatDuration(totalManualMs)}${RESET}` : '') +
135
+ ` | ${BOLD}Free${RESET} ${formatDuration(remainingMs)}`;
136
+ lines.push(budgetLine);
137
+ if (isBudgetExhausted(log, config)) {
138
+ lines.push(` ${RED}${BOLD}BUDGET EXHAUSTED${RESET} ${DIM}— tracking paused until budget freed or day resets${RESET}`);
139
+ }
140
+ // Write to stdout
141
+ process.stdout.write(CLEAR + lines.join('\n') + '\n');
142
+ }
143
+ }
144
+ function formatDuration(ms) {
145
+ const totalSeconds = Math.floor(ms / 1000);
146
+ const hours = Math.floor(totalSeconds / 3600);
147
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
148
+ const seconds = totalSeconds % 60;
149
+ if (hours > 0) {
150
+ return `${hours}h ${String(minutes).padStart(2, '0')}m`;
151
+ }
152
+ if (minutes > 0) {
153
+ return `${minutes}m ${String(seconds).padStart(2, '0')}s`;
154
+ }
155
+ return `${seconds}s`;
156
+ }
157
+ function formatTime(ts, timezone) {
158
+ return new Intl.DateTimeFormat('en-GB', {
159
+ hour: '2-digit',
160
+ minute: '2-digit',
161
+ second: '2-digit',
162
+ hour12: false,
163
+ timeZone: timezone,
164
+ }).format(new Date(ts));
165
+ }
166
+ function renderBar(value, width) {
167
+ const clamped = Math.max(0, Math.min(1, value));
168
+ const filled = Math.round(clamped * width);
169
+ const empty = width - filled;
170
+ const pct = (clamped * 100).toFixed(0).padStart(3);
171
+ let color = RED;
172
+ if (clamped >= 0.6)
173
+ color = GREEN;
174
+ else if (clamped >= 0.3)
175
+ color = YELLOW;
176
+ return `${color}${'█'.repeat(filled)}${DIM}${'░'.repeat(empty)}${RESET} ${pct}%`;
177
+ }
178
+ //# sourceMappingURL=status-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-renderer.js","sourceRoot":"","sources":["../../src/core/status-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,gBAAgB,CAAC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AG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,GAAG,GAAG,CAAC;AACnF,CAAC"}
@@ -0,0 +1,320 @@
1
+ export interface AppConfig {
2
+ readonly repos: readonly string[];
3
+ readonly dayBoundaryHour: number;
4
+ readonly timezone: string;
5
+ readonly taskPattern: string;
6
+ readonly genericBranches: readonly string[];
7
+ readonly session: SessionConfig;
8
+ readonly report: ReportConfig;
9
+ readonly workDays: readonly number[];
10
+ readonly holidays: readonly string[];
11
+ readonly apiPort: number;
12
+ }
13
+ export interface SessionConfig {
14
+ readonly diffPollSeconds: number;
15
+ readonly signalDeduplicationSeconds: number;
16
+ readonly dayBoundaryCheckSeconds: number;
17
+ readonly reflogCount: number;
18
+ }
19
+ export interface ReportConfig {
20
+ readonly roundingMinutes: number;
21
+ }
22
+ export interface Secrets {
23
+ readonly Developer: string;
24
+ readonly Jira_Email: string;
25
+ readonly Jira_BaseUrl: string;
26
+ readonly Jira_Token: string;
27
+ readonly Tempo_Token: string;
28
+ }
29
+ export declare enum PauseSource {
30
+ Manual = "manual",
31
+ IdleTimeout = "idle_timeout",
32
+ Superseded = "superseded"
33
+ }
34
+ export interface Pause {
35
+ readonly from: string;
36
+ to: string | null;
37
+ readonly source: PauseSource;
38
+ }
39
+ export declare enum SessionState {
40
+ Pending = "pending",
41
+ Active = "active"
42
+ }
43
+ export declare enum ClosedBy {
44
+ CheckoutOtherTask = "checkout_other_task",
45
+ DayBoundary = "day_boundary",
46
+ DaemonStop = "daemon_stop",
47
+ DaemonCrash = "daemon_crash",
48
+ ManualStop = "manual_stop",
49
+ BudgetExhausted = "budget_exhausted"
50
+ }
51
+ export interface ManualAdjustment {
52
+ readonly minutes: number;
53
+ readonly reason: string;
54
+ readonly addedAt: string;
55
+ }
56
+ export interface Evidence {
57
+ commits: number;
58
+ reflogEvents: number;
59
+ linesAdded: number;
60
+ linesRemoved: number;
61
+ filesChanged: number;
62
+ }
63
+ export interface Session {
64
+ readonly id: string;
65
+ readonly repo: string;
66
+ readonly task: string | null;
67
+ readonly branch: string;
68
+ state: SessionState;
69
+ startedAt: string;
70
+ activatedAt: string | null;
71
+ lastSeenAt: string;
72
+ closedBy: ClosedBy | null;
73
+ evidence: Evidence;
74
+ pauses: Pause[];
75
+ manualAdjustments: ManualAdjustment[];
76
+ }
77
+ export declare enum SignalType {
78
+ DiffDynamics = "diff_dynamics",
79
+ Commit = "commit",
80
+ Checkout = "checkout"
81
+ }
82
+ export interface DiffDynamicsSignal {
83
+ readonly ts: number;
84
+ readonly type: SignalType.DiffDynamics;
85
+ readonly repo: string;
86
+ readonly delta: {
87
+ readonly added: number;
88
+ readonly removed: number;
89
+ readonly untracked?: number;
90
+ };
91
+ }
92
+ export interface CommitSignal {
93
+ readonly ts: number;
94
+ readonly type: SignalType.Commit;
95
+ readonly repo: string;
96
+ readonly task: string | null;
97
+ }
98
+ export interface CheckoutSignal {
99
+ readonly ts: number;
100
+ readonly type: SignalType.Checkout;
101
+ readonly repo: string;
102
+ readonly task: string | null;
103
+ }
104
+ export type Signal = DiffDynamicsSignal | CommitSignal | CheckoutSignal;
105
+ export declare enum DayStatus {
106
+ Draft = "draft",
107
+ Confirmed = "confirmed",
108
+ Pushed = "pushed"
109
+ }
110
+ export declare enum DayType {
111
+ Workday = "workday",
112
+ Weekend = "weekend",
113
+ Holiday = "holiday",
114
+ Overtime = "overtime"
115
+ }
116
+ export interface DailyLog {
117
+ readonly date: string;
118
+ status: DayStatus;
119
+ dayType: DayType;
120
+ manualStart: string | null;
121
+ dayStartedAt: string | null;
122
+ sessions: Session[];
123
+ signals: Signal[];
124
+ pushedAt: string | null;
125
+ }
126
+ export interface GitSnapshot {
127
+ readonly branch: string;
128
+ readonly trackedLines: {
129
+ readonly added: number;
130
+ readonly removed: number;
131
+ };
132
+ readonly trackedFileCount: number;
133
+ readonly untrackedCount: number;
134
+ readonly timestamp: number;
135
+ }
136
+ export interface GitDelta {
137
+ readonly addedDelta: number;
138
+ readonly removedDelta: number;
139
+ readonly untrackedDelta: number;
140
+ readonly hasDynamics: boolean;
141
+ }
142
+ export type ReflogEntryType = 'commit' | 'checkout' | 'reset' | 'other';
143
+ export interface ReflogEntry {
144
+ readonly ts: number;
145
+ readonly type: ReflogEntryType;
146
+ readonly message: string;
147
+ }
148
+ export interface RawGitOutput {
149
+ readonly branch: string;
150
+ readonly diffNumstat: string;
151
+ readonly statusPorcelain: string;
152
+ readonly reflog: string;
153
+ }
154
+ export interface PollResult {
155
+ readonly repoPath: string;
156
+ readonly branch: string;
157
+ readonly task: string | null;
158
+ readonly snapshot: GitSnapshot;
159
+ readonly delta: GitDelta;
160
+ readonly newReflogEntries: ReflogEntry[];
161
+ }
162
+ export declare enum RepoState {
163
+ Idle = "idle",
164
+ Pending = "pending",
165
+ Active = "active"
166
+ }
167
+ export interface RepoTracker {
168
+ state: RepoState;
169
+ currentBranch: string | null;
170
+ currentTask: string | null;
171
+ activeSessionId: string | null;
172
+ previousSnapshot: GitSnapshot | null;
173
+ lastReflogTs: number;
174
+ }
175
+ export interface ApiResponse<T = unknown> {
176
+ readonly ok: boolean;
177
+ readonly data?: T;
178
+ readonly error?: string;
179
+ }
180
+ export interface StatusResponse {
181
+ readonly running: boolean;
182
+ readonly pid: number;
183
+ readonly date: string;
184
+ readonly uptime: number;
185
+ readonly openSessions: readonly SessionSummary[];
186
+ }
187
+ export interface SessionSummary {
188
+ readonly id: string;
189
+ readonly repo: string;
190
+ readonly task: string | null;
191
+ readonly branch: string;
192
+ readonly state: string;
193
+ readonly startedAt: string;
194
+ readonly activatedAt: string | null;
195
+ readonly lastSeenAt: string;
196
+ readonly paused: boolean;
197
+ readonly pauseSource: string | null;
198
+ readonly effectiveDurationMs: number;
199
+ readonly manualMinutes: number;
200
+ readonly score: number;
201
+ readonly normalizedScore: number;
202
+ readonly isLeader: boolean;
203
+ readonly autoPauseDisabled: boolean;
204
+ }
205
+ export interface TodayResponse {
206
+ readonly date: string;
207
+ readonly dayType: string;
208
+ readonly status: string;
209
+ readonly sessions: readonly SessionDetail[];
210
+ readonly totalEffectiveMs: number;
211
+ readonly signalCount: number;
212
+ readonly budgetMs: number;
213
+ readonly claimedMs: number;
214
+ readonly remainingBudgetMs: number;
215
+ readonly dayStartedAt: string | null;
216
+ }
217
+ export interface SessionDetail extends SessionSummary {
218
+ readonly closedBy: string | null;
219
+ readonly evidence: Evidence;
220
+ readonly pauseCount: number;
221
+ readonly totalPauseDurationMs: number;
222
+ }
223
+ export interface PauseResponse {
224
+ readonly paused: readonly string[];
225
+ }
226
+ export interface ResumeResponse {
227
+ readonly resumed: readonly string[];
228
+ }
229
+ export interface StopResponse {
230
+ readonly message: string;
231
+ }
232
+ export interface AutoPauseResponse {
233
+ readonly repo: string | null;
234
+ readonly autoPauseDisabled: boolean;
235
+ }
236
+ export interface AdjustResponse {
237
+ readonly sessionId: string;
238
+ readonly repo: string;
239
+ readonly task: string | null;
240
+ readonly addedMinutes: number;
241
+ readonly totalManualMinutes: number;
242
+ readonly remainingBudgetMs: number;
243
+ }
244
+ export interface SetStartResponse {
245
+ readonly dayStart: string;
246
+ readonly budgetMs: number;
247
+ readonly remainingBudgetMs: number;
248
+ }
249
+ export interface TaskDayReport {
250
+ readonly date: string;
251
+ readonly task: string;
252
+ readonly totalSeconds: number;
253
+ readonly sessionCount: number;
254
+ }
255
+ export interface TempoWorklog {
256
+ readonly tempoWorklogId: number;
257
+ readonly issueId: number;
258
+ readonly startDate: string;
259
+ readonly timeSpentSeconds: number;
260
+ }
261
+ export interface JiraIssue {
262
+ readonly issueId: number;
263
+ readonly summary: string;
264
+ }
265
+ export type PushActionType = 'create' | 'update' | 'skip' | 'error';
266
+ export interface PushPlanEntry {
267
+ readonly date: string;
268
+ readonly task: string;
269
+ readonly targetSeconds: number;
270
+ readonly action: PushActionType;
271
+ readonly detail: string;
272
+ readonly issueId?: number;
273
+ readonly existingWorklogId?: number;
274
+ readonly extraWorklogIds?: readonly number[];
275
+ }
276
+ export interface PushResult {
277
+ readonly posted: number;
278
+ readonly updated: number;
279
+ readonly deleted: number;
280
+ readonly skipped: number;
281
+ readonly failed: number;
282
+ }
283
+ export interface ReportResponse {
284
+ readonly from: string;
285
+ readonly to: string;
286
+ readonly entries: readonly TaskDayReport[];
287
+ readonly taskTotals: Readonly<Record<string, number>>;
288
+ readonly totalSeconds: number;
289
+ }
290
+ export interface PushLogEntry {
291
+ readonly tempoWorklogId: number;
292
+ readonly timeSpentSeconds: number;
293
+ readonly pushedAt: string;
294
+ }
295
+ export interface PushResponse {
296
+ readonly dryRun: boolean;
297
+ readonly plan: readonly PushPlanEntry[];
298
+ readonly result?: PushResult;
299
+ }
300
+ export interface ActivitySignals {
301
+ readonly hasDynamics: boolean;
302
+ readonly hasCommit: boolean;
303
+ readonly deltaMagnitude: number;
304
+ }
305
+ export interface TickInput {
306
+ readonly sessionId: string;
307
+ readonly signals: ActivitySignals;
308
+ readonly autoPauseDisabled: boolean;
309
+ }
310
+ export interface EvaluatorResult {
311
+ readonly scores: Map<string, SessionScore>;
312
+ readonly leaderId: string | null;
313
+ }
314
+ export interface SessionScore {
315
+ readonly score: number;
316
+ readonly maxScore: number;
317
+ readonly normalizedScore: number;
318
+ readonly ema: number;
319
+ readonly isIdleTimeout: boolean;
320
+ }
@@ -0,0 +1,52 @@
1
+ // ─── Config ──────────────────────────────────────────────────────────────
2
+ // ─── Pause ──────────────────────────────────────────────────────────────
3
+ export var PauseSource;
4
+ (function (PauseSource) {
5
+ PauseSource["Manual"] = "manual";
6
+ PauseSource["IdleTimeout"] = "idle_timeout";
7
+ PauseSource["Superseded"] = "superseded";
8
+ })(PauseSource || (PauseSource = {}));
9
+ // ─── Session state machine ───────────────────────────────────────────────
10
+ export var SessionState;
11
+ (function (SessionState) {
12
+ SessionState["Pending"] = "pending";
13
+ SessionState["Active"] = "active";
14
+ })(SessionState || (SessionState = {}));
15
+ export var ClosedBy;
16
+ (function (ClosedBy) {
17
+ ClosedBy["CheckoutOtherTask"] = "checkout_other_task";
18
+ ClosedBy["DayBoundary"] = "day_boundary";
19
+ ClosedBy["DaemonStop"] = "daemon_stop";
20
+ ClosedBy["DaemonCrash"] = "daemon_crash";
21
+ ClosedBy["ManualStop"] = "manual_stop";
22
+ ClosedBy["BudgetExhausted"] = "budget_exhausted";
23
+ })(ClosedBy || (ClosedBy = {}));
24
+ // ─── Signals ─────────────────────────────────────────────────────────────
25
+ export var SignalType;
26
+ (function (SignalType) {
27
+ SignalType["DiffDynamics"] = "diff_dynamics";
28
+ SignalType["Commit"] = "commit";
29
+ SignalType["Checkout"] = "checkout";
30
+ })(SignalType || (SignalType = {}));
31
+ // ─── Daily Log ───────────────────────────────────────────────────────────
32
+ export var DayStatus;
33
+ (function (DayStatus) {
34
+ DayStatus["Draft"] = "draft";
35
+ DayStatus["Confirmed"] = "confirmed";
36
+ DayStatus["Pushed"] = "pushed";
37
+ })(DayStatus || (DayStatus = {}));
38
+ export var DayType;
39
+ (function (DayType) {
40
+ DayType["Workday"] = "workday";
41
+ DayType["Weekend"] = "weekend";
42
+ DayType["Holiday"] = "holiday";
43
+ DayType["Overtime"] = "overtime";
44
+ })(DayType || (DayType = {}));
45
+ // ─── Daemon runtime state (per repo, not persisted) ─────────────────────
46
+ export var RepoState;
47
+ (function (RepoState) {
48
+ RepoState["Idle"] = "idle";
49
+ RepoState["Pending"] = "pending";
50
+ RepoState["Active"] = "active";
51
+ })(RepoState || (RepoState = {}));
52
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAkC5E,2EAA2E;AAE3E,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,2CAA4B,CAAA;IAC5B,wCAAyB,CAAA;AAC3B,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAQD,4EAA4E;AAE5E,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,qDAAyC,CAAA;IACzC,wCAA4B,CAAA;IAC5B,sCAA0B,CAAA;IAC1B,wCAA4B,CAAA;IAC5B,sCAA0B,CAAA;IAC1B,gDAAoC,CAAA;AACtC,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;AAoCD,4EAA4E;AAE5E,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,4CAA8B,CAAA;IAC9B,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACvB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAyBD,4EAA4E;AAE5E,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAED,MAAM,CAAN,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;AACvB,CAAC,EALW,OAAO,KAAP,OAAO,QAKlB;AA0DD,2EAA2E;AAE3E,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;AACnB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"}
@@ -0,0 +1,31 @@
1
+ export declare class Daemon {
2
+ private config;
3
+ private secrets;
4
+ private gitTracker;
5
+ private sessionTracker;
6
+ private activityEvaluator;
7
+ private httpServer;
8
+ private statusRenderer;
9
+ private pollTimer;
10
+ private dayBoundaryTimer;
11
+ private currentDate;
12
+ private running;
13
+ private foreground;
14
+ private startedAt;
15
+ private budgetExhaustedLogged;
16
+ start(options?: {
17
+ foreground?: boolean;
18
+ }): Promise<void>;
19
+ stop(): Promise<void>;
20
+ private stopAndExit;
21
+ private pollTick;
22
+ /** Scan recent daily logs for orphaned sessions (cross-day crash) */
23
+ private recoverOrphanedLogs;
24
+ private checkDayBoundary;
25
+ private getPidFilePath;
26
+ private ensureSingleInstance;
27
+ private static isProcessRunning;
28
+ private writePidFile;
29
+ private removePidFile;
30
+ private registerShutdownHandlers;
31
+ }