@aiti-ai/aiti-git-review 0.2.11 → 0.2.12

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.
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Late-answer store for AI runs that outlive their deadline.
3
+ *
4
+ * A generation that runs past its deadline keeps running server-side: the caller gets the session
5
+ * id and may pull the answer afterwards instead of losing the work (provider retries alone can take
6
+ * minutes). This store remembers which session ids are still pullable (`track`), holds the final
7
+ * text once the session settles (`settle`), and serves it for `ttlMs` (`get`).
8
+ *
9
+ * Pure bookkeeping (no timers, no network) so it can be unit-tested; the caller owns the clock.
10
+ */
11
+ export interface LateResultStore {
12
+ /** Mark a session id as pullable (after its caller timed out). */
13
+ track(sessionId: string, now?: number): void;
14
+ isTracked(sessionId: string): boolean;
15
+ /** Cache the settled answer. Returns true when the id was tracked by a timed-out caller. */
16
+ settle(sessionId: string, text: string, now?: number): boolean;
17
+ /** Record that the run failed without an answer (text stays null). */
18
+ fail(sessionId: string, error: string, now?: number): boolean;
19
+ /** Failure reason of a tracked session, or null while running / after success / expired. */
20
+ errorOf(sessionId: string, now?: number): string | null;
21
+ /** Final answer for a tracked session, or null while it is still running / unknown / expired. */
22
+ get(sessionId: string, now?: number): string | null;
23
+ /** Number of live entries (tests/diagnostics). */
24
+ size(now?: number): number;
25
+ }
26
+
27
+ export interface LateResultStoreOptions {
28
+ /** How long a timed-out session stays pullable (default 10 minutes). */
29
+ ttlMs?: number;
30
+ /** Maximum tracked sessions; the oldest ones are dropped first (default 20). */
31
+ max?: number;
32
+ }
33
+
34
+ export function createLateResultStore(opts: LateResultStoreOptions = {}): LateResultStore {
35
+ const ttlMs = opts.ttlMs && opts.ttlMs > 0 ? opts.ttlMs : 10 * 60_000;
36
+ const max = opts.max && opts.max > 0 ? opts.max : 20;
37
+ const entries = new Map<string, { at: number; text: string | null; error: string | null }>();
38
+
39
+ const prune = (now: number): void => {
40
+ for (const [sid, e] of entries) {
41
+ if (now - e.at > ttlMs) entries.delete(sid);
42
+ }
43
+ };
44
+
45
+ return {
46
+ track(sessionId, now = Date.now()) {
47
+ const sid = String(sessionId ?? "");
48
+ if (!sid) return;
49
+ prune(now);
50
+ const prev = entries.get(sid);
51
+ entries.set(sid, { at: now, text: prev?.text ?? null, error: prev?.error ?? null });
52
+ while (entries.size > max) {
53
+ const oldest = entries.keys().next();
54
+ if (oldest.done) break;
55
+ entries.delete(oldest.value);
56
+ }
57
+ },
58
+ isTracked(sessionId) {
59
+ const sid = String(sessionId ?? "");
60
+ return !!sid && entries.has(sid);
61
+ },
62
+ settle(sessionId, text, now = Date.now()) {
63
+ const sid = String(sessionId ?? "");
64
+ const e = entries.get(sid);
65
+ if (!e) return false;
66
+ e.text = String(text ?? "");
67
+ e.error = null;
68
+ e.at = now;
69
+ return true;
70
+ },
71
+ fail(sessionId, error, now = Date.now()) {
72
+ const sid = String(sessionId ?? "");
73
+ const e = entries.get(sid);
74
+ if (!e) return false;
75
+ e.text = null;
76
+ e.error = String(error ?? "") || "the run failed without an answer";
77
+ e.at = now;
78
+ return true;
79
+ },
80
+ errorOf(sessionId, now = Date.now()) {
81
+ const sid = String(sessionId ?? "");
82
+ const e = entries.get(sid);
83
+ if (!e) return null;
84
+ if (now - e.at > ttlMs) {
85
+ entries.delete(sid);
86
+ return null;
87
+ }
88
+ return e.error;
89
+ },
90
+ get(sessionId, now = Date.now()) {
91
+ const sid = String(sessionId ?? "");
92
+ const e = entries.get(sid);
93
+ if (!e) return null;
94
+ if (now - e.at > ttlMs) {
95
+ entries.delete(sid);
96
+ return null;
97
+ }
98
+ return e.text;
99
+ },
100
+ size(now = Date.now()) {
101
+ prune(now);
102
+ return entries.size;
103
+ },
104
+ };
105
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiti-ai/aiti-git-review",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "description": "Dedicated to reviewing uncommitted changes — Monaco diff workspace (side-by-side/merged/new-only/outline) + line-level annotations (must/suggest/question) + anchor flag-line re-mapping (stays valid while editing mid-review) + summary final-review checklist + AI pre-review (aiti_review_* tools injected only into review sessions, zero tools day-to-day)",
6
6
  "displayNameI18n": {
@@ -31,7 +31,7 @@
31
31
  "@aiti-ai/ext-shared": "^0.1.12"
32
32
  },
33
33
  "license": "MIT",
34
- "contentHash": "61a19362fb01c69e",
34
+ "contentHash": "9c71fd7b15b543a6",
35
35
  "repository": {
36
36
  "type": "git",
37
37
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",
package/vite.config.ts CHANGED
@@ -14,6 +14,10 @@ export default defineConfig({
14
14
  esbuild: {
15
15
  jsx: "automatic",
16
16
  jsxImportSource: "react",
17
+ // Production lib bundle: never let the JSX runtime follow the build shell's NODE_ENV.
18
+ // Vite infers jsxDev from NODE_ENV; a build from a dev-instance shell inherits
19
+ // NODE_ENV=development -> jsxDEV(), but jsx-runtime.ts only exports jsx/jsxs/Fragment.
20
+ jsxDev: false,
17
21
  },
18
22
  resolve: {
19
23
  alias: [