hacklab 0.22.2 → 26.921.1

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 (259) hide show
  1. package/README.md +23 -430
  2. package/dist/index.js +132 -23
  3. package/package.json +20 -42
  4. package/LICENSE +0 -21
  5. package/dist/agent-handoff.d.ts +0 -51
  6. package/dist/agent-handoff.d.ts.map +0 -1
  7. package/dist/agent-handoff.js +0 -91
  8. package/dist/agent-handoff.js.map +0 -1
  9. package/dist/api-client.d.ts +0 -18
  10. package/dist/api-client.d.ts.map +0 -1
  11. package/dist/api-client.js +0 -40
  12. package/dist/api-client.js.map +0 -1
  13. package/dist/belt.d.ts +0 -25
  14. package/dist/belt.d.ts.map +0 -1
  15. package/dist/belt.js +0 -113
  16. package/dist/belt.js.map +0 -1
  17. package/dist/card.d.ts +0 -66
  18. package/dist/card.d.ts.map +0 -1
  19. package/dist/card.js +0 -151
  20. package/dist/card.js.map +0 -1
  21. package/dist/cli.d.ts +0 -2
  22. package/dist/cli.d.ts.map +0 -1
  23. package/dist/cli.js +0 -238
  24. package/dist/cli.js.map +0 -1
  25. package/dist/commands/book.d.ts +0 -14
  26. package/dist/commands/book.d.ts.map +0 -1
  27. package/dist/commands/book.js +0 -90
  28. package/dist/commands/book.js.map +0 -1
  29. package/dist/commands/chat.d.ts +0 -36
  30. package/dist/commands/chat.d.ts.map +0 -1
  31. package/dist/commands/chat.js +0 -642
  32. package/dist/commands/chat.js.map +0 -1
  33. package/dist/commands/config.d.ts +0 -2
  34. package/dist/commands/config.d.ts.map +0 -1
  35. package/dist/commands/config.js +0 -84
  36. package/dist/commands/config.js.map +0 -1
  37. package/dist/commands/daemon.d.ts +0 -19
  38. package/dist/commands/daemon.d.ts.map +0 -1
  39. package/dist/commands/daemon.js +0 -72
  40. package/dist/commands/daemon.js.map +0 -1
  41. package/dist/commands/drop.d.ts +0 -12
  42. package/dist/commands/drop.d.ts.map +0 -1
  43. package/dist/commands/drop.js +0 -103
  44. package/dist/commands/drop.js.map +0 -1
  45. package/dist/commands/drops.d.ts +0 -9
  46. package/dist/commands/drops.d.ts.map +0 -1
  47. package/dist/commands/drops.js +0 -96
  48. package/dist/commands/drops.js.map +0 -1
  49. package/dist/commands/essay.d.ts +0 -40
  50. package/dist/commands/essay.d.ts.map +0 -1
  51. package/dist/commands/essay.js +0 -651
  52. package/dist/commands/essay.js.map +0 -1
  53. package/dist/commands/hackathon.d.ts +0 -2
  54. package/dist/commands/hackathon.d.ts.map +0 -1
  55. package/dist/commands/hackathon.js +0 -893
  56. package/dist/commands/hackathon.js.map +0 -1
  57. package/dist/commands/hacker.d.ts +0 -2
  58. package/dist/commands/hacker.d.ts.map +0 -1
  59. package/dist/commands/hacker.js +0 -87
  60. package/dist/commands/hacker.js.map +0 -1
  61. package/dist/commands/jobs.d.ts +0 -18
  62. package/dist/commands/jobs.d.ts.map +0 -1
  63. package/dist/commands/jobs.js +0 -138
  64. package/dist/commands/jobs.js.map +0 -1
  65. package/dist/commands/keys.d.ts +0 -2
  66. package/dist/commands/keys.d.ts.map +0 -1
  67. package/dist/commands/keys.js +0 -138
  68. package/dist/commands/keys.js.map +0 -1
  69. package/dist/commands/login.d.ts +0 -83
  70. package/dist/commands/login.d.ts.map +0 -1
  71. package/dist/commands/login.js +0 -236
  72. package/dist/commands/login.js.map +0 -1
  73. package/dist/commands/logout.d.ts +0 -2
  74. package/dist/commands/logout.d.ts.map +0 -1
  75. package/dist/commands/logout.js +0 -22
  76. package/dist/commands/logout.js.map +0 -1
  77. package/dist/commands/org-jobs.d.ts +0 -50
  78. package/dist/commands/org-jobs.d.ts.map +0 -1
  79. package/dist/commands/org-jobs.js +0 -383
  80. package/dist/commands/org-jobs.js.map +0 -1
  81. package/dist/commands/org.d.ts +0 -67
  82. package/dist/commands/org.d.ts.map +0 -1
  83. package/dist/commands/org.js +0 -1244
  84. package/dist/commands/org.js.map +0 -1
  85. package/dist/commands/ping.d.ts +0 -2
  86. package/dist/commands/ping.d.ts.map +0 -1
  87. package/dist/commands/ping.js +0 -50
  88. package/dist/commands/ping.js.map +0 -1
  89. package/dist/commands/profile.d.ts +0 -72
  90. package/dist/commands/profile.d.ts.map +0 -1
  91. package/dist/commands/profile.js +0 -672
  92. package/dist/commands/profile.js.map +0 -1
  93. package/dist/commands/project.d.ts +0 -2
  94. package/dist/commands/project.d.ts.map +0 -1
  95. package/dist/commands/project.js +0 -583
  96. package/dist/commands/project.js.map +0 -1
  97. package/dist/commands/referral.d.ts +0 -6
  98. package/dist/commands/referral.d.ts.map +0 -1
  99. package/dist/commands/referral.js +0 -93
  100. package/dist/commands/referral.js.map +0 -1
  101. package/dist/commands/rtfm.d.ts +0 -9
  102. package/dist/commands/rtfm.d.ts.map +0 -1
  103. package/dist/commands/rtfm.js +0 -114
  104. package/dist/commands/rtfm.js.map +0 -1
  105. package/dist/commands/scan.d.ts +0 -13
  106. package/dist/commands/scan.d.ts.map +0 -1
  107. package/dist/commands/scan.js +0 -286
  108. package/dist/commands/scan.js.map +0 -1
  109. package/dist/commands/scout.d.ts +0 -18
  110. package/dist/commands/scout.d.ts.map +0 -1
  111. package/dist/commands/scout.js +0 -232
  112. package/dist/commands/scout.js.map +0 -1
  113. package/dist/commands/setup-rail.d.ts +0 -58
  114. package/dist/commands/setup-rail.d.ts.map +0 -1
  115. package/dist/commands/setup-rail.js +0 -135
  116. package/dist/commands/setup-rail.js.map +0 -1
  117. package/dist/commands/setup.d.ts +0 -29
  118. package/dist/commands/setup.d.ts.map +0 -1
  119. package/dist/commands/setup.js +0 -442
  120. package/dist/commands/setup.js.map +0 -1
  121. package/dist/commands/sync.d.ts +0 -9
  122. package/dist/commands/sync.d.ts.map +0 -1
  123. package/dist/commands/sync.js +0 -345
  124. package/dist/commands/sync.js.map +0 -1
  125. package/dist/commands/update.d.ts +0 -2
  126. package/dist/commands/update.d.ts.map +0 -1
  127. package/dist/commands/update.js +0 -92
  128. package/dist/commands/update.js.map +0 -1
  129. package/dist/commands/whoami.d.ts +0 -2
  130. package/dist/commands/whoami.d.ts.map +0 -1
  131. package/dist/commands/whoami.js +0 -41
  132. package/dist/commands/whoami.js.map +0 -1
  133. package/dist/config.d.ts +0 -78
  134. package/dist/config.d.ts.map +0 -1
  135. package/dist/config.js +0 -93
  136. package/dist/config.js.map +0 -1
  137. package/dist/daily-sync.d.ts +0 -150
  138. package/dist/daily-sync.d.ts.map +0 -1
  139. package/dist/daily-sync.js +0 -665
  140. package/dist/daily-sync.js.map +0 -1
  141. package/dist/dossier.d.ts +0 -73
  142. package/dist/dossier.d.ts.map +0 -1
  143. package/dist/dossier.js +0 -141
  144. package/dist/dossier.js.map +0 -1
  145. package/dist/field-normalize.d.ts +0 -4
  146. package/dist/field-normalize.d.ts.map +0 -1
  147. package/dist/field-normalize.js +0 -8
  148. package/dist/field-normalize.js.map +0 -1
  149. package/dist/index.d.ts +0 -3
  150. package/dist/index.d.ts.map +0 -1
  151. package/dist/index.js.map +0 -1
  152. package/dist/job-fields.d.ts +0 -47
  153. package/dist/job-fields.d.ts.map +0 -1
  154. package/dist/job-fields.js +0 -148
  155. package/dist/job-fields.js.map +0 -1
  156. package/dist/machine.d.ts +0 -15
  157. package/dist/machine.d.ts.map +0 -1
  158. package/dist/machine.js +0 -64
  159. package/dist/machine.js.map +0 -1
  160. package/dist/org-fields.d.ts +0 -57
  161. package/dist/org-fields.d.ts.map +0 -1
  162. package/dist/org-fields.js +0 -167
  163. package/dist/org-fields.js.map +0 -1
  164. package/dist/posthog.d.ts +0 -38
  165. package/dist/posthog.d.ts.map +0 -1
  166. package/dist/posthog.js +0 -224
  167. package/dist/posthog.js.map +0 -1
  168. package/dist/project-fields.d.ts +0 -40
  169. package/dist/project-fields.d.ts.map +0 -1
  170. package/dist/project-fields.js +0 -79
  171. package/dist/project-fields.js.map +0 -1
  172. package/dist/prompt-consent.d.ts +0 -73
  173. package/dist/prompt-consent.d.ts.map +0 -1
  174. package/dist/prompt-consent.js +0 -191
  175. package/dist/prompt-consent.js.map +0 -1
  176. package/dist/prompt-stats.d.ts +0 -226
  177. package/dist/prompt-stats.d.ts.map +0 -1
  178. package/dist/prompt-stats.js +0 -561
  179. package/dist/prompt-stats.js.map +0 -1
  180. package/dist/referral.d.ts +0 -14
  181. package/dist/referral.d.ts.map +0 -1
  182. package/dist/referral.js +0 -28
  183. package/dist/referral.js.map +0 -1
  184. package/dist/registry.d.ts +0 -15
  185. package/dist/registry.d.ts.map +0 -1
  186. package/dist/registry.js +0 -180
  187. package/dist/registry.js.map +0 -1
  188. package/dist/resolve-command.d.ts +0 -20
  189. package/dist/resolve-command.d.ts.map +0 -1
  190. package/dist/resolve-command.js +0 -21
  191. package/dist/resolve-command.js.map +0 -1
  192. package/dist/scanners/antigravity.d.ts +0 -41
  193. package/dist/scanners/antigravity.d.ts.map +0 -1
  194. package/dist/scanners/antigravity.js +0 -210
  195. package/dist/scanners/antigravity.js.map +0 -1
  196. package/dist/scanners/github-copilot-telemetry.d.ts +0 -23
  197. package/dist/scanners/github-copilot-telemetry.d.ts.map +0 -1
  198. package/dist/scanners/github-copilot-telemetry.js +0 -220
  199. package/dist/scanners/github-copilot-telemetry.js.map +0 -1
  200. package/dist/scanners/github-copilot.d.ts +0 -68
  201. package/dist/scanners/github-copilot.d.ts.map +0 -1
  202. package/dist/scanners/github-copilot.js +0 -262
  203. package/dist/scanners/github-copilot.js.map +0 -1
  204. package/dist/scanners/incremental.d.ts +0 -282
  205. package/dist/scanners/incremental.d.ts.map +0 -1
  206. package/dist/scanners/incremental.js +0 -788
  207. package/dist/scanners/incremental.js.map +0 -1
  208. package/dist/scanners/index.d.ts +0 -116
  209. package/dist/scanners/index.d.ts.map +0 -1
  210. package/dist/scanners/index.js +0 -726
  211. package/dist/scanners/index.js.map +0 -1
  212. package/dist/scanners/sqlite.d.ts +0 -18
  213. package/dist/scanners/sqlite.d.ts.map +0 -1
  214. package/dist/scanners/sqlite.js +0 -63
  215. package/dist/scanners/sqlite.js.map +0 -1
  216. package/dist/scanners/util.d.ts +0 -112
  217. package/dist/scanners/util.d.ts.map +0 -1
  218. package/dist/scanners/util.js +0 -167
  219. package/dist/scanners/util.js.map +0 -1
  220. package/dist/session.d.ts +0 -106
  221. package/dist/session.d.ts.map +0 -1
  222. package/dist/session.js +0 -191
  223. package/dist/session.js.map +0 -1
  224. package/dist/share-card-colors.d.ts +0 -19
  225. package/dist/share-card-colors.d.ts.map +0 -1
  226. package/dist/share-card-colors.js +0 -36
  227. package/dist/share-card-colors.js.map +0 -1
  228. package/dist/share-card.d.ts +0 -32
  229. package/dist/share-card.d.ts.map +0 -1
  230. package/dist/share-card.js +0 -420
  231. package/dist/share-card.js.map +0 -1
  232. package/dist/share.d.ts +0 -17
  233. package/dist/share.d.ts.map +0 -1
  234. package/dist/share.js +0 -77
  235. package/dist/share.js.map +0 -1
  236. package/dist/sync.d.ts +0 -100
  237. package/dist/sync.d.ts.map +0 -1
  238. package/dist/sync.js +0 -304
  239. package/dist/sync.js.map +0 -1
  240. package/dist/ui.d.ts +0 -33
  241. package/dist/ui.d.ts.map +0 -1
  242. package/dist/ui.js +0 -127
  243. package/dist/ui.js.map +0 -1
  244. package/dist/utils/npmGlobal.d.ts +0 -30
  245. package/dist/utils/npmGlobal.d.ts.map +0 -1
  246. package/dist/utils/npmGlobal.js +0 -69
  247. package/dist/utils/npmGlobal.js.map +0 -1
  248. package/dist/utils/openBrowser.d.ts +0 -14
  249. package/dist/utils/openBrowser.d.ts.map +0 -1
  250. package/dist/utils/openBrowser.js +0 -47
  251. package/dist/utils/openBrowser.js.map +0 -1
  252. package/dist/utils/updateCheck.d.ts +0 -16
  253. package/dist/utils/updateCheck.d.ts.map +0 -1
  254. package/dist/utils/updateCheck.js +0 -111
  255. package/dist/utils/updateCheck.js.map +0 -1
  256. package/dist/utils/waitForEnter.d.ts +0 -12
  257. package/dist/utils/waitForEnter.d.ts.map +0 -1
  258. package/dist/utils/waitForEnter.js +0 -43
  259. package/dist/utils/waitForEnter.js.map +0 -1
@@ -1,282 +0,0 @@
1
- import { IDE_PROMPT_SOURCES, type PromptActivityAggregate, type PromptLine, type ScannedPromptActivity } from '../prompt-stats.js';
2
- import { type AggregateScan, type PromptActivity, type ScanResult, type TokensMessages, type Tool, type UsageLine } from './index.js';
3
- /**
4
- * Bumping this makes `loadScanState` return null, which re-reads every log
5
- * from scratch and re-derives the aggregates.
6
- *
7
- * 3: the prompt scanner learned to skip harness-written `user` entries
8
- * (PROMPT_SCANNER_VERSION 2). The server is wiping the prompt tables once that
9
- * ships, and `replacePromptActivity` only re-sends sessions and dates whose
10
- * numbers *moved* — so a day that happened to contain no harness noise would
11
- * stay identical locally and never be re-uploaded after the wipe. A cold
12
- * rebuild marks every session and date within local retention dirty exactly
13
- * once, and they all go back out.
14
- *
15
- * 4: the same wipe, for the machines 3 couldn't save. The wipe landed
16
- * 2026-09-10, and a machine that had already upgraded to 0.21.0 did its one
17
- * cold rebuild *before* that — it re-uploaded everything, cleared every dirty
18
- * flag, and then watched the server delete the lot. Nothing on that machine
19
- * moves afterwards, so `replacePromptActivity` re-sends nothing and the history
20
- * is simply gone. This bump is the one-shot rescue: another cold rebuild, after
21
- * the wipe this time. For anyone still on an older CLI it costs one extra
22
- * rescan and nothing else.
23
- *
24
- * 5: prompt activity is partitioned by source, so rebuilding a Claude log or
25
- * rotating an IDE transcript cannot erase or double-count another harness.
26
- *
27
- * Token totals are unaffected: they travel as cumulative absolutes that the
28
- * server diffs against its own per-machine snapshot, and `state.uploaded` is
29
- * only the tick's "nothing moved" short-circuit — so a rebuild re-baselines
30
- * rather than double-counting.
31
- */
32
- export declare const SCAN_STATE_VERSION = 5;
33
- /** How long a session is kept in the state after its last prompt. */
34
- export declare const PROMPT_SESSION_RETENTION_DAYS = 45;
35
- /** How long a per-day prompt tally is kept. Matches the wire's date cap. */
36
- export declare const PROMPT_DAILY_RETENTION_DAYS = 400;
37
- /** Where a file's tail-follow stands: what we saw, and how far we read. */
38
- export type FileState = {
39
- size: number;
40
- mtimeMs: number;
41
- offset: number;
42
- };
43
- /** Codex only: the running total a session file has reported so far. */
44
- export type CodexFileState = {
45
- maxTotal: number;
46
- model: string;
47
- date: string;
48
- };
49
- export type HarnessState = {
50
- /** JSONL harnesses: per-file read cursor, keyed by absolute path. */
51
- files: Record<string, FileState>;
52
- /** Codex only: per-file running totals (see codexFileTotals). */
53
- codexTotals?: Record<string, CodexFileState>;
54
- /** SQLite harnesses: fingerprints of the db and its -wal. */
55
- dbMtimeMs?: number;
56
- walMtimeMs?: number;
57
- /** "date|model" -> tokens/messages */
58
- daily: Record<string, TokensMessages>;
59
- /** model -> cumulative tokens */
60
- models: Record<string, number>;
61
- };
62
- /**
63
- * The prompt half of the state: the same tail-read that counts tokens also
64
- * counts the user's own prompts, so `promptActivity` can ride out on the tick
65
- * instead of waiting a day.
66
- *
67
- * Unlike the token rows, prompt rows are upserted with GREATEST semantics per
68
- * (machine, session) and (machine, date), so a resend is free and a date never
69
- * has to go out "complete". That's why the dirty sets here are per-session and
70
- * per-date and can be drained a capped batch at a time.
71
- */
72
- export type PromptState = PromptActivityAggregate & {
73
- /** Session ids changed since the last accepted upload. */
74
- dirtySessions: string[];
75
- /** Dates whose tally changed since the last accepted upload. */
76
- dirtyDates: string[];
77
- /**
78
- * Exactly what the last `tickPayload` put on the wire. `markUploaded` clears
79
- * this and nothing else, so anything a cap held back stays dirty.
80
- */
81
- sent?: {
82
- sessions: string[];
83
- dates: string[];
84
- };
85
- };
86
- export type ScanState = {
87
- version: number;
88
- harnesses: Record<string, HarnessState>;
89
- /**
90
- * Dates whose rows changed since the last accepted upload. Dates, not
91
- * (harness, date) pairs, because the server reconciles a synced date by
92
- * deleting this machine's rows for that date that the payload didn't
93
- * mention — so a date we touch has to go out complete, with every harness's
94
- * rows for it. Cleared only on a 200, so a failed POST retries next tick.
95
- */
96
- dirty: string[];
97
- /** Prompt sessions and per-day counts, plus what's outstanding. */
98
- prompts: PromptState;
99
- promptSources: Record<string, PromptActivityAggregate>;
100
- /** Prompt-only snapshots are re-read only when their file set changes. */
101
- promptFiles: Record<string, Record<string, FileState>>;
102
- /** Cumulative totals as of the last accepted upload. */
103
- uploaded: {
104
- toolTotals: Record<string, number>;
105
- modelTotals: Record<string, number>;
106
- };
107
- /** 429 backoff: ticks before this epoch-ms do nothing. */
108
- nextAllowedAt?: number;
109
- /** The last failure written to sync.log, so a stuck tick can't fill it. */
110
- lastError?: string;
111
- };
112
- /** Lives next to the session file, so it honors HACKLAB_SESSION_PATH. */
113
- export declare function scanStatePath(): string;
114
- export declare function emptyHarness(): HarnessState;
115
- export declare function emptyPromptState(): PromptState;
116
- export declare function emptyState(): ScanState;
117
- /**
118
- * The saved state, or null when there isn't a usable one — missing, corrupt, or
119
- * written by an older layout. Null means "re-read everything from scratch";
120
- * callers must treat that rebuild as a baseline, not as new tokens.
121
- */
122
- export declare function loadScanState(): Promise<ScanState | null>;
123
- /** Persist the state, pruning prompt rows that aged out of their retention
124
- * window (they'd otherwise accumulate forever). Best-effort. */
125
- export declare function saveScanState(state: ScanState): Promise<void>;
126
- type Aggregates = {
127
- daily: Record<string, TokensMessages>;
128
- models: Record<string, number>;
129
- };
130
- /** A full scanner's result as the maps the state stores. */
131
- export declare function aggregatesOfResult(result: ScanResult): Aggregates;
132
- /**
133
- * Read `[from, to)` and hand back only whole lines. A harness may be mid-append
134
- * when we look, so the trailing partial line is left for the next tick — that's
135
- * what the returned offset points at.
136
- */
137
- export declare function readCompleteLines(path: string, from: number, to: number): Promise<{
138
- text: string;
139
- offset: number;
140
- }>;
141
- export type JsonlSource = {
142
- tool: Tool;
143
- files: () => Promise<string[]>;
144
- parse: (line: string) => UsageLine | null;
145
- /**
146
- * Claude Code only: the same line read as prompt activity. Set here rather
147
- * than branching on `tool` so the tail-read stays one pass and a test can
148
- * point a prompt-bearing harness at a tmp dir.
149
- */
150
- parsePrompt?: (line: string) => PromptLine | null;
151
- };
152
- export type CodexSource = {
153
- files: () => Promise<string[]>;
154
- /** Session date from the path layout, or null to fall back to the mtime day. */
155
- dateFor: (path: string) => string | null;
156
- };
157
- export type SqliteSource = {
158
- tool: Tool;
159
- dbPath: () => string;
160
- scan: () => Promise<ScanResult>;
161
- };
162
- export type SnapshotSource = {
163
- tool: Tool;
164
- files: () => Promise<string[]>;
165
- scan: () => Promise<ScanResult>;
166
- };
167
- export type TickSources = {
168
- jsonl: JsonlSource[];
169
- codex: CodexSource;
170
- sqlite: SqliteSource[];
171
- prompts?: typeof IDE_PROMPT_SOURCES;
172
- snapshots?: SnapshotSource[];
173
- };
174
- /** The real harnesses. Injectable so the tick can be tested against a tmp dir. */
175
- export declare function defaultSources(): TickSources;
176
- export type TickOutcome = {
177
- state: ScanState;
178
- /** Did anything on disk move? (If not, the state file isn't worth rewriting.) */
179
- changed: boolean;
180
- };
181
- /**
182
- * One incremental pass over every harness. `prev` is the saved state, or null
183
- * for a cold start — in which case this reads everything and marks no *token*
184
- * date dirty: those tokens are already on the server (the daily job put them
185
- * there), and re-uploading every date would only invite the reconcile to prune
186
- * rows this scan can't see (Cursor's, above all).
187
- *
188
- * Prompt rows go the other way on a cold start: everything found is marked
189
- * dirty. They're idempotent GREATEST upserts, so a resend costs nothing, and a
190
- * cold start (fresh install, or a state file this version can't read) is
191
- * exactly the case where we have no evidence any of it ever reached the server.
192
- */
193
- export declare function runTick(prev: ScanState | null, sources?: TickSources, options?: {
194
- promptActivity?: boolean;
195
- }): Promise<TickOutcome>;
196
- /** Cumulative per-tool and per-model totals for this machine. */
197
- export declare function cumulativeTotals(state: ScanState): {
198
- toolTotals: Record<string, number>;
199
- modelTotals: Record<string, number>;
200
- };
201
- export declare function sameTotals(a: Record<string, number>, b: Record<string, number>): boolean;
202
- /**
203
- * Is there prompt activity waiting to go out?
204
- *
205
- * A dirty id whose row is gone (pruned between the mark and the send) doesn't
206
- * count: it would have the tick POST an empty block every minute forever, since
207
- * there'd be nothing for `markUploaded` to clear.
208
- */
209
- export declare function hasPromptActivity(state: ScanState): boolean;
210
- /**
211
- * What a tick uploads: cumulative tool/model totals (the server diffs those
212
- * against its own per-machine snapshot) plus the daily rows for the dirty dates
213
- * only, and — under the `stats` or `full` tier — the outstanding prompt
214
- * activity.
215
- *
216
- * Every harness's rows go out for a dirty date, including Cursor's — which the
217
- * tick never scans, and carries over from the last full scan instead. The
218
- * server reconciles a date by deleting this machine's rows for it that the
219
- * payload didn't mention, so a date has to be reported complete or the harnesses
220
- * left out of it lose that day.
221
- */
222
- export declare function tickPayload(state: ScanState, opts?: {
223
- promptActivity?: boolean;
224
- }): AggregateScan;
225
- /** Called on a 200: whatever that payload carried is on the server now. */
226
- export declare function markUploaded(state: ScanState): void;
227
- /**
228
- * What a full scan knows about prompts, and may therefore rewrite.
229
- *
230
- * The three cases are genuinely different, and collapsing any two of them
231
- * loses data: a command that never looked at prompts must not be read as a
232
- * command that found none.
233
- */
234
- export type StagedPrompts =
235
- /** A prompt scan ran — re-base the prompt state on its aggregate. */
236
- {
237
- scanned: ScannedPromptActivity;
238
- }
239
- /** The user is at the `none` tier — drop the prompt state entirely. */
240
- | {
241
- scanned: null;
242
- }
243
- /** This command never reads prompts (`hacklab scan`) — leave them alone. */
244
- | 'untouched';
245
- /**
246
- * A full scan, re-based and ready to upload: the prompt rows this upload should
247
- * carry, and the `commit` that records the whole thing as delivered.
248
- */
249
- export type StagedFullScan = {
250
- /**
251
- * Outstanding prompt activity to put on this upload, or undefined when there
252
- * is none (or the user is at the `none` tier).
253
- */
254
- promptActivity?: PromptActivity;
255
- /**
256
- * Call once the server took the payload. Persists the re-based state, clears
257
- * the prompt rows this upload claimed, and leaves anything a cap held back
258
- * dirty for the next run. Best-effort and never throws.
259
- */
260
- commit: () => Promise<void>;
261
- };
262
- /**
263
- * Rebuild the whole state from a full scan's results — the self-healing half of
264
- * the design. Whatever the tick's tail-follow got wrong (a rotated log, a
265
- * mid-file model switch, a Codex date guessed from an mtime) is corrected here,
266
- * so incremental drift can never outlive a day. Best-effort: a state we failed
267
- * to rebuild costs a tick, never the sync that called us.
268
- *
269
- * Staged rather than persisted outright, because the full-scan paths carry
270
- * prompt activity too — a machine with no daemon has no tick to drain it. The
271
- * rebuild diffs the scan's aggregate against what was already sent, claims the
272
- * difference for this upload, and only `commit` (on a 200) clears it. A failed
273
- * POST therefore leaves every row dirty for the next run, which the server's
274
- * GREATEST upserts make free to resend.
275
- *
276
- * `prompts` says whether this caller has any authority over the prompt state —
277
- * see `StagedPrompts`. Only a caller that actually resolved the consent tier
278
- * gets to rewrite it, and only such a caller claims prompt rows for the upload.
279
- */
280
- export declare function stageFullScan(results: ScanResult[], prompts?: StagedPrompts, sources?: TickSources): Promise<StagedFullScan>;
281
- export {};
282
- //# sourceMappingURL=incremental.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"incremental.d.ts","sourceRoot":"","sources":["../../src/scanners/incremental.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,kBAAkB,EAElB,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAEf,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EACL,KAAK,aAAa,EAalB,KAAK,cAAc,EAInB,KAAK,UAAU,EAGf,KAAK,cAAc,EACnB,KAAK,IAAI,EAET,KAAK,SAAS,EACf,MAAM,YAAY,CAAA;AAiBnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,qEAAqE;AACrE,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAC/C,4EAA4E;AAC5E,eAAO,MAAM,2BAA2B,MAA2B,CAAA;AAEnE,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzE,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IA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