@avocadostudio-ai/orchestrator-core 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 (196) hide show
  1. package/LICENSE +201 -0
  2. package/dist/agent/agent-context.d.ts +19 -0
  3. package/dist/agent/agent-context.js +67 -0
  4. package/dist/agent/agent-logger.d.ts +5 -0
  5. package/dist/agent/agent-logger.js +22 -0
  6. package/dist/agent/agent-loop-openai.d.ts +8 -0
  7. package/dist/agent/agent-loop-openai.js +172 -0
  8. package/dist/agent/agent-loop.d.ts +56 -0
  9. package/dist/agent/agent-loop.js +167 -0
  10. package/dist/agent/agent-provider.d.ts +28 -0
  11. package/dist/agent/agent-provider.js +63 -0
  12. package/dist/agent/agent-tools.d.ts +28 -0
  13. package/dist/agent/agent-tools.js +899 -0
  14. package/dist/agent/context/editing-guidelines.md +46 -0
  15. package/dist/agent/context/role.md +39 -0
  16. package/dist/agent/integration-prompt.d.ts +9 -0
  17. package/dist/agent/integration-prompt.js +154 -0
  18. package/dist/agent/sites-agent-context.d.ts +12 -0
  19. package/dist/agent/sites-agent-context.js +316 -0
  20. package/dist/agent/sites-agent-shared.d.ts +161 -0
  21. package/dist/agent/sites-agent-shared.js +1101 -0
  22. package/dist/agent/sites-agent-tools.d.ts +18 -0
  23. package/dist/agent/sites-agent-tools.js +1227 -0
  24. package/dist/chat/anthropic-cache.d.ts +20 -0
  25. package/dist/chat/anthropic-cache.js +54 -0
  26. package/dist/chat/anthropic-planner.d.ts +98 -0
  27. package/dist/chat/anthropic-planner.js +1012 -0
  28. package/dist/chat/changelog-coverage-validator.d.ts +37 -0
  29. package/dist/chat/changelog-coverage-validator.js +215 -0
  30. package/dist/chat/chat-pipeline-context.d.ts +211 -0
  31. package/dist/chat/chat-pipeline-context.js +249 -0
  32. package/dist/chat/chat-pipeline-deterministic.d.ts +61 -0
  33. package/dist/chat/chat-pipeline-deterministic.js +407 -0
  34. package/dist/chat/chat-pipeline-image.d.ts +86 -0
  35. package/dist/chat/chat-pipeline-image.js +897 -0
  36. package/dist/chat/chat-pipeline-shared.d.ts +69 -0
  37. package/dist/chat/chat-pipeline-shared.js +212 -0
  38. package/dist/chat/chat-pipeline-translation.d.ts +27 -0
  39. package/dist/chat/chat-pipeline-translation.js +417 -0
  40. package/dist/chat/chat-pipeline-ui.d.ts +14 -0
  41. package/dist/chat/chat-pipeline-ui.js +244 -0
  42. package/dist/chat/chat-pipeline.d.ts +99 -0
  43. package/dist/chat/chat-pipeline.js +3999 -0
  44. package/dist/chat/decomposer.d.ts +21 -0
  45. package/dist/chat/decomposer.js +65 -0
  46. package/dist/chat/gemini-planner.d.ts +70 -0
  47. package/dist/chat/gemini-planner.js +541 -0
  48. package/dist/chat/hallucination-validator.d.ts +36 -0
  49. package/dist/chat/hallucination-validator.js +110 -0
  50. package/dist/chat/locale-strings.d.ts +47 -0
  51. package/dist/chat/locale-strings.js +100 -0
  52. package/dist/chat/plan-json-schema.d.ts +133 -0
  53. package/dist/chat/plan-json-schema.js +112 -0
  54. package/dist/chat/planner-types.d.ts +120 -0
  55. package/dist/chat/planner-types.js +66 -0
  56. package/dist/chat/planner.d.ts +148 -0
  57. package/dist/chat/planner.js +1361 -0
  58. package/dist/chat/prompts.d.ts +67 -0
  59. package/dist/chat/prompts.js +356 -0
  60. package/dist/chat/provider-routing.d.ts +14 -0
  61. package/dist/chat/provider-routing.js +27 -0
  62. package/dist/chat/variation-pipeline.d.ts +135 -0
  63. package/dist/chat/variation-pipeline.js +837 -0
  64. package/dist/chat/vision-alt-generator.d.ts +35 -0
  65. package/dist/chat/vision-alt-generator.js +152 -0
  66. package/dist/cms/adapter.d.ts +62 -0
  67. package/dist/cms/adapter.js +1 -0
  68. package/dist/cms/bootstrap.d.ts +17 -0
  69. package/dist/cms/bootstrap.js +85 -0
  70. package/dist/cms/editor-api-adapter.d.ts +23 -0
  71. package/dist/cms/editor-api-adapter.js +71 -0
  72. package/dist/cms/index.d.ts +4 -0
  73. package/dist/cms/index.js +3 -0
  74. package/dist/cms/json-file-adapter.d.ts +11 -0
  75. package/dist/cms/json-file-adapter.js +62 -0
  76. package/dist/demo-mode.d.ts +59 -0
  77. package/dist/demo-mode.js +201 -0
  78. package/dist/errors.d.ts +67 -0
  79. package/dist/errors.js +129 -0
  80. package/dist/http/chat-stream-resumable.d.ts +108 -0
  81. package/dist/http/chat-stream-resumable.js +290 -0
  82. package/dist/http/chat-stream.d.ts +99 -0
  83. package/dist/http/chat-stream.js +92 -0
  84. package/dist/image/gdrive-client.d.ts +22 -0
  85. package/dist/image/gdrive-client.js +215 -0
  86. package/dist/image/image-helpers.d.ts +95 -0
  87. package/dist/image/image-helpers.js +488 -0
  88. package/dist/index.d.ts +1 -0
  89. package/dist/index.js +1 -0
  90. package/dist/jira/jira-approval.d.ts +22 -0
  91. package/dist/jira/jira-approval.js +51 -0
  92. package/dist/jira/jira-client.d.ts +44 -0
  93. package/dist/jira/jira-client.js +313 -0
  94. package/dist/jira/jira-poller.d.ts +46 -0
  95. package/dist/jira/jira-poller.js +184 -0
  96. package/dist/jira/jira-processor.d.ts +103 -0
  97. package/dist/jira/jira-processor.js +1085 -0
  98. package/dist/jira/jira-types.d.ts +117 -0
  99. package/dist/jira/jira-types.js +38 -0
  100. package/dist/logger.d.ts +12 -0
  101. package/dist/logger.js +28 -0
  102. package/dist/migration/mcp-server-stdio.d.ts +8 -0
  103. package/dist/migration/mcp-server-stdio.js +672 -0
  104. package/dist/migration/migration-prompt.d.ts +7 -0
  105. package/dist/migration/migration-prompt.js +197 -0
  106. package/dist/migration/migration-tools.d.ts +17 -0
  107. package/dist/migration/migration-tools.js +159 -0
  108. package/dist/migration/scrape-cache.d.ts +9 -0
  109. package/dist/migration/scrape-cache.js +19 -0
  110. package/dist/nlp/deterministic-planner-context.d.ts +141 -0
  111. package/dist/nlp/deterministic-planner-context.js +362 -0
  112. package/dist/nlp/deterministic-planner-pages.d.ts +26 -0
  113. package/dist/nlp/deterministic-planner-pages.js +170 -0
  114. package/dist/nlp/deterministic-planner-patches.d.ts +80 -0
  115. package/dist/nlp/deterministic-planner-patches.js +508 -0
  116. package/dist/nlp/deterministic-planner-refs.d.ts +33 -0
  117. package/dist/nlp/deterministic-planner-refs.js +164 -0
  118. package/dist/nlp/deterministic-planner-suggestions.d.ts +49 -0
  119. package/dist/nlp/deterministic-planner-suggestions.js +579 -0
  120. package/dist/nlp/deterministic-planner.d.ts +85 -0
  121. package/dist/nlp/deterministic-planner.js +1631 -0
  122. package/dist/nlp/intent-detection.d.ts +309 -0
  123. package/dist/nlp/intent-detection.js +730 -0
  124. package/dist/nlp/intent-helpers.d.ts +15 -0
  125. package/dist/nlp/intent-helpers.js +243 -0
  126. package/dist/nlp/intent-patterns.d.ts +40 -0
  127. package/dist/nlp/intent-patterns.js +223 -0
  128. package/dist/nlp/plan-normalizer.d.ts +41 -0
  129. package/dist/nlp/plan-normalizer.js +1537 -0
  130. package/dist/ops/destructive-action-gate.d.ts +44 -0
  131. package/dist/ops/destructive-action-gate.js +90 -0
  132. package/dist/ops/ops-engine.d.ts +151 -0
  133. package/dist/ops/ops-engine.js +1394 -0
  134. package/dist/publish/diff-engine.d.ts +18 -0
  135. package/dist/publish/diff-engine.js +305 -0
  136. package/dist/publish/publish-helpers.d.ts +87 -0
  137. package/dist/publish/publish-helpers.js +521 -0
  138. package/dist/publish/publish-target-registry.d.ts +7 -0
  139. package/dist/publish/publish-target-registry.js +61 -0
  140. package/dist/publish/publish-target.d.ts +81 -0
  141. package/dist/publish/publish-target.js +1 -0
  142. package/dist/publish/targets/deploy-hook.d.ts +13 -0
  143. package/dist/publish/targets/deploy-hook.js +123 -0
  144. package/dist/publish/targets/git.d.ts +13 -0
  145. package/dist/publish/targets/git.js +55 -0
  146. package/dist/publish/targets/site-contract.d.ts +19 -0
  147. package/dist/publish/targets/site-contract.js +124 -0
  148. package/dist/state/content-source.d.ts +17 -0
  149. package/dist/state/content-source.js +1 -0
  150. package/dist/state/in-memory-content-source.d.ts +27 -0
  151. package/dist/state/in-memory-content-source.js +51 -0
  152. package/dist/state/session-lock.d.ts +13 -0
  153. package/dist/state/session-lock.js +29 -0
  154. package/dist/state/session-state.d.ts +310 -0
  155. package/dist/state/session-state.js +1083 -0
  156. package/dist/state/sqlite-store-singleton.d.ts +31 -0
  157. package/dist/state/sqlite-store-singleton.js +170 -0
  158. package/dist/state/sqlite-store.d.ts +135 -0
  159. package/dist/state/sqlite-store.js +421 -0
  160. package/dist/telemetry/chat-telemetry.d.ts +105 -0
  161. package/dist/telemetry/chat-telemetry.js +247 -0
  162. package/dist/telemetry/eval-candidate-store.d.ts +50 -0
  163. package/dist/telemetry/eval-candidate-store.js +120 -0
  164. package/dist/telemetry/feedback-store.d.ts +34 -0
  165. package/dist/telemetry/feedback-store.js +76 -0
  166. package/dist/telemetry/jira-telemetry.d.ts +57 -0
  167. package/dist/telemetry/jira-telemetry.js +68 -0
  168. package/dist/telemetry/migration-telemetry.d.ts +35 -0
  169. package/dist/telemetry/migration-telemetry.js +40 -0
  170. package/dist/telemetry/usage.d.ts +24 -0
  171. package/dist/telemetry/usage.js +80 -0
  172. package/dist/tools/builtin-registrations.d.ts +12 -0
  173. package/dist/tools/builtin-registrations.js +33 -0
  174. package/dist/tools/builtins/gdrive-browse.d.ts +3 -0
  175. package/dist/tools/builtins/gdrive-browse.js +68 -0
  176. package/dist/tools/builtins/image-generate.d.ts +3 -0
  177. package/dist/tools/builtins/image-generate.js +211 -0
  178. package/dist/tools/builtins/unsplash-get-by-id.d.ts +23 -0
  179. package/dist/tools/builtins/unsplash-get-by-id.js +119 -0
  180. package/dist/tools/builtins/unsplash-search.d.ts +3 -0
  181. package/dist/tools/builtins/unsplash-search.js +74 -0
  182. package/dist/tools/executor.d.ts +23 -0
  183. package/dist/tools/executor.js +169 -0
  184. package/dist/tools/index.d.ts +5 -0
  185. package/dist/tools/index.js +5 -0
  186. package/dist/tools/registry.d.ts +21 -0
  187. package/dist/tools/registry.js +75 -0
  188. package/dist/tools/runtime.d.ts +27 -0
  189. package/dist/tools/runtime.js +48 -0
  190. package/dist/tools/schema-validator.d.ts +24 -0
  191. package/dist/tools/schema-validator.js +88 -0
  192. package/dist/tools/types.d.ts +86 -0
  193. package/dist/tools/types.js +1 -0
  194. package/dist/variation-images.d.ts +19 -0
  195. package/dist/variation-images.js +12 -0
  196. package/package.json +78 -0
@@ -0,0 +1,31 @@
1
+ import type { Logger } from "../logger.ts";
2
+ import { SqliteStore } from "./sqlite-store.ts";
3
+ export declare function resolveDbFile(): string;
4
+ export declare function resolveJsonMigrationTtlDays(): number;
5
+ export declare function resolveBackupLimit(): number;
6
+ export declare function resolveBackupIntervalHours(): number;
7
+ export declare function getStore(): SqliteStore;
8
+ /** Close & clear the singleton. Intended for tests + graceful shutdown. */
9
+ export declare function resetStore(): void;
10
+ /**
11
+ * Rename `<path>` to `<path>.migrated-<iso-ts>` so it won't be re-imported.
12
+ * Returns the new path, or null on failure.
13
+ */
14
+ export declare function archiveMigratedJson(jsonPath: string): Promise<string | null>;
15
+ /**
16
+ * Delete `.migrated-*` sibling files older than `ttlDays` in the same dir.
17
+ * Silent on failures — cleanup is opportunistic.
18
+ */
19
+ export declare function sweepStaleMigrations(jsonPath: string, ttlDays: number, logger: Logger): Promise<number>;
20
+ /**
21
+ * If `jsonPath` exists and is non-empty, read + parse it and return the raw
22
+ * payload. Caller is responsible for applying it into Maps + DB.
23
+ */
24
+ export declare function readLegacyJson<T>(jsonPath: string): Promise<T | null>;
25
+ /**
26
+ * Run a `VACUUM INTO '<dbPath>.backup-<ts>'` snapshot and rotate off the
27
+ * oldest copies once more than `limit` accumulate. Opens a fresh short-lived
28
+ * connection so the live handle's prepared statements stay untouched.
29
+ * Silent on failures — backups are best-effort.
30
+ */
31
+ export declare function runSqliteBackup(dbPath: string, limit: number, logger: Logger): Promise<string | null>;
@@ -0,0 +1,170 @@
1
+ import { existsSync } from "node:fs";
2
+ import { rename, readFile, readdir, stat, unlink } from "node:fs/promises";
3
+ import { basename, dirname, resolve } from "node:path";
4
+ import { SqliteStore } from "./sqlite-store.js";
5
+ // ---------------------------------------------------------------------------
6
+ // Config
7
+ // ---------------------------------------------------------------------------
8
+ export function resolveDbFile() {
9
+ const explicit = process.env.ORCHESTRATOR_DB_FILE;
10
+ // Treat unset AND empty-string as "use the default" — matches how users
11
+ // get `.env.example` (which has `ORCHESTRATOR_DB_FILE=` empty). Ephemeral
12
+ // mode is still reachable via DEMO_MODE=1, NODE_ENV=test, or setting the
13
+ // env var to the literal ":memory:".
14
+ if (explicit && explicit.length > 0)
15
+ return explicit;
16
+ if (process.env.DEMO_MODE === "1")
17
+ return ":memory:";
18
+ if (process.env.NODE_ENV === "test")
19
+ return ":memory:";
20
+ return resolve(process.cwd(), "../../.data/orchestrator.db");
21
+ }
22
+ export function resolveJsonMigrationTtlDays() {
23
+ const raw = Number(process.env.ORCHESTRATOR_JSON_MIGRATION_TTL_DAYS ?? 14);
24
+ return Number.isFinite(raw) && raw >= 0 ? Math.floor(raw) : 14;
25
+ }
26
+ export function resolveBackupLimit() {
27
+ const raw = Number(process.env.ORCHESTRATOR_DB_BACKUP_LIMIT ?? 14);
28
+ return Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : 14;
29
+ }
30
+ export function resolveBackupIntervalHours() {
31
+ const raw = Number(process.env.ORCHESTRATOR_DB_BACKUP_INTERVAL_HOURS ?? 24);
32
+ return Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : 24;
33
+ }
34
+ // ---------------------------------------------------------------------------
35
+ // Singleton access
36
+ // ---------------------------------------------------------------------------
37
+ let store = null;
38
+ export function getStore() {
39
+ if (!store) {
40
+ store = new SqliteStore({ file: resolveDbFile() });
41
+ }
42
+ return store;
43
+ }
44
+ /** Close & clear the singleton. Intended for tests + graceful shutdown. */
45
+ export function resetStore() {
46
+ if (store) {
47
+ try {
48
+ store.close();
49
+ }
50
+ catch { /* ignore */ }
51
+ }
52
+ store = null;
53
+ }
54
+ // ---------------------------------------------------------------------------
55
+ // JSON migration helpers
56
+ // ---------------------------------------------------------------------------
57
+ /**
58
+ * Rename `<path>` to `<path>.migrated-<iso-ts>` so it won't be re-imported.
59
+ * Returns the new path, or null on failure.
60
+ */
61
+ export async function archiveMigratedJson(jsonPath) {
62
+ try {
63
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
64
+ const dest = `${jsonPath}.migrated-${stamp}`;
65
+ await rename(jsonPath, dest);
66
+ return dest;
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ }
72
+ /**
73
+ * Delete `.migrated-*` sibling files older than `ttlDays` in the same dir.
74
+ * Silent on failures — cleanup is opportunistic.
75
+ */
76
+ export async function sweepStaleMigrations(jsonPath, ttlDays, logger) {
77
+ if (ttlDays <= 0)
78
+ return 0;
79
+ const dir = dirname(jsonPath);
80
+ const prefix = `${basename(jsonPath)}.migrated-`;
81
+ let removed = 0;
82
+ try {
83
+ const entries = await readdir(dir);
84
+ const cutoff = Date.now() - ttlDays * 24 * 60 * 60 * 1000;
85
+ for (const name of entries) {
86
+ if (!name.startsWith(prefix))
87
+ continue;
88
+ const full = resolve(dir, name);
89
+ try {
90
+ const st = await stat(full);
91
+ if (st.mtimeMs < cutoff) {
92
+ await unlink(full);
93
+ removed++;
94
+ logger.info({ file: full, ttlDays }, "Removed stale migrated state file");
95
+ }
96
+ }
97
+ catch { /* ignore individual failures */ }
98
+ }
99
+ }
100
+ catch { /* dir missing — nothing to do */ }
101
+ return removed;
102
+ }
103
+ /**
104
+ * If `jsonPath` exists and is non-empty, read + parse it and return the raw
105
+ * payload. Caller is responsible for applying it into Maps + DB.
106
+ */
107
+ export async function readLegacyJson(jsonPath) {
108
+ if (!existsSync(jsonPath))
109
+ return null;
110
+ try {
111
+ const raw = await readFile(jsonPath, "utf8");
112
+ if (raw.trim().length === 0)
113
+ return null;
114
+ return JSON.parse(raw);
115
+ }
116
+ catch {
117
+ return null;
118
+ }
119
+ }
120
+ // ---------------------------------------------------------------------------
121
+ // SQLite binary backups — periodic full-DB copies via `VACUUM INTO` so that
122
+ // if the live .db ever corrupts (WAL torn write, bit rot, accidental rm)
123
+ // we have a recent known-good snapshot. Uses the same rolling-limit
124
+ // discipline the old JSON backup path had.
125
+ // ---------------------------------------------------------------------------
126
+ /**
127
+ * Run a `VACUUM INTO '<dbPath>.backup-<ts>'` snapshot and rotate off the
128
+ * oldest copies once more than `limit` accumulate. Opens a fresh short-lived
129
+ * connection so the live handle's prepared statements stay untouched.
130
+ * Silent on failures — backups are best-effort.
131
+ */
132
+ export async function runSqliteBackup(dbPath, limit, logger) {
133
+ if (dbPath === ":memory:")
134
+ return null;
135
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
136
+ const backupPath = `${dbPath}.backup-${stamp}`;
137
+ try {
138
+ // Short-lived connection to the live DB, just to issue VACUUM INTO.
139
+ // better-sqlite3 is loaded lazily by the singleton; import locally to
140
+ // avoid a top-level dependency cycle with SqliteStore.
141
+ const { default: Database } = await import("better-sqlite3");
142
+ const db = new Database(dbPath, { readonly: false });
143
+ try {
144
+ db.prepare(`VACUUM INTO ?`).run(backupPath);
145
+ }
146
+ finally {
147
+ db.close();
148
+ }
149
+ logger.info({ file: backupPath }, "Wrote orchestrator SQLite backup");
150
+ }
151
+ catch (err) {
152
+ logger.error({ err, backupPath }, "Failed to write SQLite backup");
153
+ return null;
154
+ }
155
+ // Rotate — keep the newest `limit` by filename (ISO-timestamped, so
156
+ // lexical order == chronological order).
157
+ try {
158
+ const dir = dirname(dbPath);
159
+ const prefix = `${basename(dbPath)}.backup-`;
160
+ const entries = await readdir(dir);
161
+ const backups = entries.filter((n) => n.startsWith(prefix)).sort();
162
+ if (backups.length > limit) {
163
+ const toDelete = backups.slice(0, backups.length - limit);
164
+ await Promise.all(toDelete.map((name) => unlink(resolve(dir, name)).catch(() => { })));
165
+ logger.info({ removed: toDelete.length, kept: limit }, "Rotated old SQLite backups");
166
+ }
167
+ }
168
+ catch { /* ignore rotation failures */ }
169
+ return backupPath;
170
+ }
@@ -0,0 +1,135 @@
1
+ import type { Database as BetterSqliteDatabase } from "better-sqlite3";
2
+ import type { PageDoc, Operation, SiteConfig } from "@avocadostudio-ai/shared";
3
+ export declare const HISTORY_DEPTH_CAP = 50;
4
+ export declare const VERSION_LOG_CAP = 100;
5
+ export declare const RECENT_EDITS_CAP = 10;
6
+ export declare const CHAT_HISTORY_CAP = 6;
7
+ export declare const PUBLISH_LOG_CAP = 200;
8
+ export type PageKind = "draft" | "published";
9
+ export type HistoryDirection = "undo" | "redo";
10
+ export type RecentEditEntry = {
11
+ slug: string;
12
+ summary: string;
13
+ ops: Operation[];
14
+ at: string;
15
+ };
16
+ export type VersionLogEntry = {
17
+ version: number;
18
+ slug: string;
19
+ summary: string;
20
+ opTypes: string[];
21
+ opCount: number;
22
+ at: string;
23
+ source: "chat" | "direct" | "undo" | "redo" | "bootstrap" | "restore";
24
+ snapshot?: PageDoc | null;
25
+ };
26
+ export type ChatMessage = {
27
+ role: "user" | "assistant";
28
+ content: string;
29
+ };
30
+ export type IssueTouchedRow = {
31
+ slugs: string[];
32
+ updatedAt: string;
33
+ };
34
+ export type PublishLogStatus = "triggered" | "success" | "failed";
35
+ export type PublishLogActor = {
36
+ kind: "user" | "agent" | "ci";
37
+ id?: string;
38
+ };
39
+ export type PublishLogDiffSummary = {
40
+ added: number;
41
+ removed: number;
42
+ changed: number;
43
+ };
44
+ export type PublishLogEntry = {
45
+ /** Stable id (UUID). Lets async status updates target a specific row. */
46
+ id: string;
47
+ /** Scoped session key (matches version_log keying). */
48
+ session: string;
49
+ siteId: string;
50
+ /** Publish target name, e.g. "site-contract" | "git" | "deploy-hook" | plugin. */
51
+ target: string;
52
+ status: PublishLogStatus;
53
+ /** ISO timestamp when the row was first inserted. */
54
+ at: string;
55
+ /** ISO timestamp of the most recent status mutation. */
56
+ updatedAt: string;
57
+ /** Human-readable summary, e.g. "Published Home, Pricing". */
58
+ summary: string;
59
+ pageCount: number;
60
+ /** Slugs included in this publish (small list — useful for the panel). */
61
+ slugs: string[];
62
+ /** Short commit SHA, when the target produced one. */
63
+ commit?: string;
64
+ deploymentId?: string;
65
+ deploymentUrl?: string;
66
+ /** Provider-specific deep link (e.g. Vercel inspect URL). */
67
+ inspectUrl?: string;
68
+ /** Present when status === "failed". */
69
+ error?: string;
70
+ /**
71
+ * Forward-compatibility slots — reserved but unpopulated today. They live in
72
+ * the JSON blob so adding values does not require a schema migration.
73
+ */
74
+ actor?: PublishLogActor;
75
+ diffSummary?: PublishLogDiffSummary;
76
+ };
77
+ export type SqliteStoreOptions = {
78
+ /** File path. Use ":memory:" for an ephemeral DB. */
79
+ file: string;
80
+ /** Disable WAL (e.g. in tests). Defaults to true for file-backed DBs. */
81
+ wal?: boolean;
82
+ /** Optional logger for one-shot messages (open/close/migrate). */
83
+ onLog?: (msg: string) => void;
84
+ };
85
+ export declare class SqliteStore {
86
+ readonly db: BetterSqliteDatabase;
87
+ private readonly stmt;
88
+ constructor(options: SqliteStoreOptions);
89
+ private ensureSchemaVersion;
90
+ private prepareAll;
91
+ setPage(session: string, page: PageDoc, kind?: PageKind): void;
92
+ getPage(session: string, slug: string, kind?: PageKind): PageDoc | null;
93
+ removePage(session: string, slug: string, kind?: PageKind): void;
94
+ listPages(session: string, kind?: PageKind): PageDoc[];
95
+ listDraftSessions(): string[];
96
+ pushHistory(session: string, slug: string, direction: HistoryDirection, snapshot: PageDoc | null): void;
97
+ popHistory(session: string, slug: string, direction: HistoryDirection): PageDoc | null | undefined;
98
+ clearHistory(session: string, slug: string, direction: HistoryDirection): void;
99
+ listHistory(session: string, slug: string, direction: HistoryDirection): (PageDoc | null)[];
100
+ getVersion(session: string): number;
101
+ setVersion(session: string, version: number): void;
102
+ bumpVersion(session: string): number;
103
+ pushVersionLog(session: string, entry: VersionLogEntry): void;
104
+ listVersionLog(session: string, slug?: string, limit?: number): VersionLogEntry[];
105
+ pushRecentEdit(session: string, entry: RecentEditEntry): void;
106
+ listRecentEdits(session: string): RecentEditEntry[];
107
+ pushChatMessage(session: string, role: ChatMessage["role"], content: string): void;
108
+ listChatHistory(session: string): ChatMessage[];
109
+ setSiteConfig(session: string, config: SiteConfig): void;
110
+ getSiteConfig(session: string): SiteConfig | null;
111
+ listSiteConfigs(): Array<{
112
+ session: string;
113
+ config: SiteConfig;
114
+ }>;
115
+ setIssueTouched(issueKey: string, row: IssueTouchedRow, cap?: number): void;
116
+ getIssueTouched(issueKey: string): IssueTouchedRow | null;
117
+ listIssueTouched(): Array<{
118
+ issueKey: string;
119
+ row: IssueTouchedRow;
120
+ }>;
121
+ pushPublishLog(entry: PublishLogEntry): void;
122
+ getPublishLogById(id: string): PublishLogEntry | null;
123
+ getPublishLogByDeploymentId(session: string, deploymentId: string): PublishLogEntry | null;
124
+ getMostRecentTriggeredPublishLog(session: string): PublishLogEntry | null;
125
+ /**
126
+ * Patch an existing publish-log row. Merges `patch` into the stored JSON,
127
+ * bumps `updatedAt`, and updates the hoisted `status` column. Returns the
128
+ * full updated entry, or null if the id was not found.
129
+ */
130
+ updatePublishLogById(id: string, patch: Partial<Omit<PublishLogEntry, "id" | "session" | "at">>): PublishLogEntry | null;
131
+ listPublishLog(session: string, limit?: number): PublishLogEntry[];
132
+ listPublishLogSessions(): string[];
133
+ transaction<T>(fn: () => T): T;
134
+ close(): void;
135
+ }