@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,310 @@
1
+ import type { Logger } from "../logger.ts";
2
+ import { type EditPlan, type Operation, type PageDoc, type SiteConfig } from "@avocadostudio-ai/shared";
3
+ import { toErrorDetail as _unifiedToErrorDetail } from "../errors.ts";
4
+ import type { PublishLogEntry } from "./sqlite-store.ts";
5
+ export type { PublishLogEntry, PublishLogStatus } from "./sqlite-store.ts";
6
+ export declare const HISTORY_DEPTH_MAX = 50;
7
+ export declare const VERSION_LOG_MAX = 100;
8
+ export declare const CHAT_HISTORY_MAX_TURNS = 6;
9
+ export declare const PUBLISH_LOG_MAX = 200;
10
+ export type ModelKey = "fast" | "balanced" | "reasoning" | "codex";
11
+ export type AIProvider = "openai" | "anthropic" | "gemini";
12
+ export declare const DEFAULT_SITE_ID = "avocado-stories";
13
+ export declare const DEFAULT_SESSION = "dev";
14
+ export declare function normalizeSiteId(value: unknown): string;
15
+ export declare function normalizeSession(value: unknown): string;
16
+ /** Returns true for the default JSON-file site (avocado-stories). */
17
+ export declare function isLegacySiteId(siteId: string): siteId is "avocado-stories" | "default";
18
+ export declare function scopedSessionKey(session: unknown, siteId: unknown): string;
19
+ export type PendingImageGeneration = {
20
+ blockId: string;
21
+ pageSlug: string;
22
+ path?: string;
23
+ altPath?: string;
24
+ query: string;
25
+ provider: "openai" | "unsplash" | "gdrive" | "auto";
26
+ };
27
+ export type PendingApprovalPlan = {
28
+ id: string;
29
+ createdAt: string;
30
+ promptHash: string;
31
+ requestedSlug: string;
32
+ effectiveSlug: string;
33
+ summary: string;
34
+ source: "openai" | "anthropic" | "gemini" | "demo";
35
+ modelUsed: string;
36
+ modelKey: ModelKey;
37
+ plan: EditPlan;
38
+ pendingImageOps?: PendingImageGeneration[];
39
+ originalMessage?: string;
40
+ /**
41
+ * Human-readable reasons from the tier-1 destructive-action gate. Present
42
+ * when the approval gate was triggered by destructive ops (as opposed to,
43
+ * say, pending image generation). The editor renders these in the approval
44
+ * card so the user knows exactly what the plan will delete.
45
+ */
46
+ destructiveReasons?: string[];
47
+ };
48
+ export type ContinuationChain = {
49
+ id: string;
50
+ steps: string[];
51
+ stepLabels: string[];
52
+ currentStep: number;
53
+ totalSteps: number;
54
+ originalMessage: string;
55
+ effectiveSlug: string;
56
+ siteContextBlock: string | null;
57
+ };
58
+ export declare const continuationChainBySession: Map<string, ContinuationChain>;
59
+ export type PublishTracker = {
60
+ session: string;
61
+ status: "triggered" | "failed";
62
+ startedAt: string;
63
+ updatedAt: string;
64
+ slugs: string[];
65
+ deployStatus?: number;
66
+ deployResponse?: string;
67
+ inspectUrl?: string;
68
+ deploymentId?: string;
69
+ deploymentUrl?: string;
70
+ vercelState?: string;
71
+ lastCheckError?: string;
72
+ };
73
+ export type IssueTouchedEntry = {
74
+ slugs: string[];
75
+ updatedAt: string;
76
+ };
77
+ export type PersistedState = {
78
+ publishedPages: PageDoc[];
79
+ draftPages: Record<string, Record<string, PageDoc>>;
80
+ historyUndo: Record<string, Record<string, (PageDoc | null)[]>>;
81
+ historyRedo: Record<string, Record<string, (PageDoc | null)[]>>;
82
+ versions: Record<string, number>;
83
+ recentEdits: Record<string, Array<{
84
+ slug: string;
85
+ summary: string;
86
+ ops: Operation[];
87
+ at: string;
88
+ }>>;
89
+ chatHistory: Record<string, Array<{
90
+ role: "user" | "assistant";
91
+ content: string;
92
+ }>>;
93
+ siteConfigs?: Record<string, SiteConfig>;
94
+ versionLog?: Record<string, VersionEntry[]>;
95
+ issueTouchedSlugs?: Record<string, IssueTouchedEntry>;
96
+ /**
97
+ * Persisted publish-log rows. Absent in legacy JSON state files (publish log
98
+ * was introduced after the JSON-to-SQLite migration), so the hydrate path is
99
+ * the only real source — this field exists for symmetry / future round-trip.
100
+ */
101
+ publishLog?: Record<string, PublishLogEntry[]>;
102
+ };
103
+ export declare const publishedPages: Map<string, PageDoc>;
104
+ export declare const draftPages: Map<string, Map<string, PageDoc>>;
105
+ export declare const historyUndo: Map<string, Map<string, (PageDoc | null)[]>>;
106
+ export declare const historyRedo: Map<string, Map<string, (PageDoc | null)[]>>;
107
+ export declare const versions: Map<string, number>;
108
+ export declare const recentEdits: Map<string, {
109
+ slug: string;
110
+ summary: string;
111
+ ops: Operation[];
112
+ at: string;
113
+ }[]>;
114
+ export type VersionEntry = {
115
+ version: number;
116
+ slug: string;
117
+ summary: string;
118
+ opTypes: string[];
119
+ opCount: number;
120
+ at: string;
121
+ source: "chat" | "direct" | "undo" | "redo" | "bootstrap" | "restore";
122
+ /**
123
+ * Full snapshot of the page state at this version. Enables the version
124
+ * history panel to jump back and forth between any two versions directly,
125
+ * independent of the undo/redo stacks. `null` means the page did not exist
126
+ * at this version (e.g. before it was created, or after it was removed).
127
+ * Omit the field when capturing a snapshot is impossible (legacy entries).
128
+ */
129
+ snapshot?: PageDoc | null;
130
+ };
131
+ export declare const versionLog: Map<string, VersionEntry[]>;
132
+ /**
133
+ * Per-session publish-log entries — one row per `POST /publish` attempt.
134
+ * Mirrors the SQLite `publish_log` table. Unlike most other state maps, this
135
+ * one is NOT included in `writeAllStateToStore`'s drop-and-reinsert pass:
136
+ * publish entries support async UPDATE (deploy resolves seconds later) and
137
+ * the SQLite row is the source of truth. Writes go straight through via
138
+ * `pushPublishLogEntry` / `updatePublishLogStatus`; this Map is a read cache.
139
+ */
140
+ export declare const publishLogBySession: Map<string, PublishLogEntry[]>;
141
+ /**
142
+ * Per-ticket slugs touched by an agent run. Survives the execute→publish
143
+ * invocation gap so the publish-mode comment can list exactly what this
144
+ * ticket changed, rather than every page in the shared session. Capped at
145
+ * ISSUE_TOUCHED_MAX entries (oldest dropped by updatedAt).
146
+ */
147
+ export declare const issueTouchedSlugsByKey: Map<string, IssueTouchedEntry>;
148
+ export declare function setIssueTouchedSlugs(issueKey: string, slugs: string[]): void;
149
+ export declare function getIssueTouchedSlugs(issueKey: string): string[];
150
+ export declare const pendingClarificationBySession: Map<string, {
151
+ baseRequest: string;
152
+ updatedAt: string;
153
+ }>;
154
+ export declare const chatHistoryBySession: Map<string, {
155
+ role: "user" | "assistant";
156
+ content: string;
157
+ }[]>;
158
+ export declare const pendingApprovalPlanBySession: Map<string, PendingApprovalPlan>;
159
+ /**
160
+ * Per-session image-source preference ("unsplash" | "genai" | "either"), set when
161
+ * the user resolves a source-ambiguity clarification. Stops repeated prompting
162
+ * within the same session. Ephemeral (in-memory) only.
163
+ */
164
+ export type ImageSourcePreference = "unsplash" | "genai" | "either";
165
+ export declare const imageSourcePreferenceBySession: Map<string, ImageSourcePreference>;
166
+ export declare const publishStatusBySession: Map<string, PublishTracker>;
167
+ export declare const siteConfigs: Map<string, {
168
+ name?: string | undefined;
169
+ logo?: string | undefined;
170
+ purpose?: string | undefined;
171
+ tone?: string | undefined;
172
+ constraints?: string[] | undefined;
173
+ navLabels?: Record<string, string> | undefined;
174
+ navGroups?: Record<string, string[]> | undefined;
175
+ themeOverrides?: Record<string, string> | undefined;
176
+ }>;
177
+ export declare let lastPublishedScopedSession: string | undefined;
178
+ export declare function setLastPublishedScopedSession(key: string): void;
179
+ export type SessionSummary = {
180
+ /** Full key as stored in the in-memory maps (`{siteId}::{session}` or just `{session}` for the legacy site). */
181
+ sessionKey: string;
182
+ /** Session segment after the "::" separator. */
183
+ session: string;
184
+ /** Site segment before the "::" separator. Falls back to DEFAULT_SITE_ID for legacy bare-session keys. */
185
+ siteId: string;
186
+ /** Monotonic preview version (post-mutation counter). 0 when nothing has been written. */
187
+ version: number;
188
+ /** Distinct page count in the draft map. Reads existing state without auto-seeding. */
189
+ draftPageCount: number;
190
+ /** ISO timestamp of the most recent versionLog entry, or null if none. */
191
+ lastMutatedAt: string | null;
192
+ };
193
+ export declare function getSessionSummary(sessionKey: string): SessionSummary;
194
+ export declare function listSessionSummaries(): SessionSummary[];
195
+ /** Total published pages across all sites (currently just the JSON-file legacy site). */
196
+ export declare function publishedPageCountGlobal(): number;
197
+ export declare function markRecentlyRestored(session: string): void;
198
+ export declare function consumeRecentlyRestored(session: string): boolean;
199
+ export declare const toErrorDetail: typeof _unifiedToErrorDetail;
200
+ export declare function ensureHeroImageProps(page: PageDoc): void;
201
+ export declare function orderSlugsHomeFirst(slugs: string[]): string[];
202
+ /**
203
+ * Monorepo-only: backfill the in-memory siteConfig from the bundled
204
+ * apps/site/lib/published-content.json on first session touch.
205
+ *
206
+ * Why: the orch's draft siteConfig can drift narrower than what's actually
207
+ * published (e.g. SQLite outage loses a session's nav state, or a fresh boot
208
+ * of an already-published site has nothing in SQLite). Without this fill-in,
209
+ * the next publish silently wipes nav fields the live site still depends on.
210
+ *
211
+ * SDK consumers wire `getSiteConfig` into `createEditorApiHandler` and the
212
+ * orchestrator picks the live state up through `/publish/diff`'s
213
+ * loadPublishedForDiff path; this helper is only for the bundled apps/site.
214
+ *
215
+ * Exported for tests; production callers omit `publishedPathOverride`.
216
+ */
217
+ export declare function hydrateSiteConfigFromPublished(session: string, publishedPathOverride?: string): void;
218
+ export declare function getSessionDraft(session: string): Map<string, PageDoc>;
219
+ export declare function getHistoryMap(store: Map<string, Map<string, (PageDoc | null)[]>>, session: string): Map<string, (PageDoc | null)[]>;
220
+ export declare function getPage(session: string, slug: string): PageDoc | null;
221
+ export declare function getSessionPages(session: string): PageDoc[];
222
+ export declare function getContextCache(session: string): {
223
+ version: number;
224
+ pageDirectory?: string;
225
+ } | undefined;
226
+ export declare function setContextCache(session: string, entry: {
227
+ version: number;
228
+ pageDirectory?: string;
229
+ }): void;
230
+ export declare function setPage(session: string, page: PageDoc): void;
231
+ export declare function removePage(session: string, slug: string): void;
232
+ /**
233
+ * Append `snapshot` to an undo/redo stack, evicting the oldest entries
234
+ * once `HISTORY_DEPTH_MAX` is exceeded. Mutates `list` in place.
235
+ */
236
+ export declare function pushCappedHistory(list: (PageDoc | null)[], snapshot: PageDoc | null): void;
237
+ export declare function pushUndo(session: string, slug: string, snapshot: PageDoc | null): void;
238
+ export declare function bumpVersion(session: string): number;
239
+ export declare function pushRecentEdit(session: string, entry: {
240
+ slug: string;
241
+ summary: string;
242
+ ops: Operation[];
243
+ }): void;
244
+ export declare function pushVersionEntry(session: string, entry: Omit<VersionEntry, "at">): void;
245
+ export declare function getVersionLog(session: string, slug?: string, limit?: number): VersionEntry[];
246
+ /**
247
+ * Insert a publish-log row. Writes through to SQLite immediately so the row
248
+ * survives a process restart between the initial publish and the later async
249
+ * status update (deploy resolution can take seconds to minutes). Also mirrors
250
+ * into `publishLogBySession` for cheap reads.
251
+ *
252
+ * The `id` field is generated here (UUID) so callers don't need to import
253
+ * crypto. Returns the full materialised entry, including `id` / timestamps.
254
+ */
255
+ export declare function pushPublishLogEntry(partial: Omit<PublishLogEntry, "id" | "at" | "updatedAt">): PublishLogEntry;
256
+ /**
257
+ * Patch an existing publish-log row by `id`. Updates SQLite and the in-memory
258
+ * mirror. Used by `GET /publish/status` to transition `triggered` → `success`
259
+ * or `failed` when Vercel resolves. Returns the updated entry, or null if the
260
+ * id was not found.
261
+ */
262
+ export declare function updatePublishLogStatusById(id: string, patch: Partial<Omit<PublishLogEntry, "id" | "session" | "at">>): PublishLogEntry | null;
263
+ /**
264
+ * Resolve a publish-log row to update when an async deploy status arrives.
265
+ * Prefers an exact `deploymentId` match; falls back to the most recent
266
+ * `triggered` row for the session (covers deploy-hook targets that don't
267
+ * parse a deployment id out of their response).
268
+ */
269
+ export declare function findPublishLogForStatusUpdate(session: string, deploymentId: string | undefined): PublishLogEntry | null;
270
+ export declare function listPublishLog(session: string, limit?: number): PublishLogEntry[];
271
+ export declare function pushChatHistory(session: string, userMessage: string, assistantSummary: string): void;
272
+ export declare function getRecentEdits(session: string, slug: string): {
273
+ at: string;
274
+ summary: string;
275
+ ops: ("update_props" | "create_page" | "add_block" | "remove_block" | "move_block" | "duplicate_block" | "add_item" | "update_item" | "remove_item" | "move_item" | "reorder_items" | "reorder_blocks" | "rename_page" | "remove_page" | "move_page" | "duplicate_page" | "update_page_meta" | "update_site_config" | "update_theme")[];
276
+ }[];
277
+ export declare function getSiteConfig(session: string): SiteConfig;
278
+ export declare function setSiteConfig(session: string, config: SiteConfig): void;
279
+ /**
280
+ * Walk the in-memory `siteConfigs` map and return one entry per unique siteId,
281
+ * preferring entries that match `wantedSession` over legacy unscoped ones.
282
+ *
283
+ * The map keys come from `scopedSessionKey()`: either `{siteId}::{session}` or
284
+ * just `{session}` for legacy sites (avocado-stories convention). Owning that
285
+ * parsing here keeps route handlers from having to know about the key format.
286
+ */
287
+ export declare function listSitesForSession(wantedSession: string): Array<SiteConfig & {
288
+ id: string;
289
+ }>;
290
+ export declare function nestedPageMapToObject(source: Map<string, Map<string, PageDoc>>): Record<string, Record<string, PageDoc>>;
291
+ export declare function nestedHistoryMapToObject(source: Map<string, Map<string, (PageDoc | null)[]>>): Record<string, Record<string, (PageDoc | null)[]>>;
292
+ export declare function objectToNestedPageMap(source: unknown): Map<string, Map<string, PageDoc>>;
293
+ export declare function objectToNestedHistoryMap(source: unknown): Map<string, Map<string, (PageDoc | null)[]>>;
294
+ export declare function applyPersistedState(parsed: Partial<PersistedState>): void;
295
+ /**
296
+ * Persist the current in-memory state to SQLite. Always flushes any pending
297
+ * debounced write first, then runs synchronously (better-sqlite3 is sync).
298
+ * Async signature preserved for callers that want to `await` (publish flow
299
+ * does). Errors are logged and rethrown.
300
+ */
301
+ export declare function persistStateNow(logger: Logger): Promise<void>;
302
+ export declare function schedulePersistState(logger: Logger): void;
303
+ /**
304
+ * Evict stale/excess entries from ephemeral in-memory maps.
305
+ * Called on a periodic timer (see index.ts). Safe to call at any time.
306
+ */
307
+ export declare function evictStaleEphemeralMaps(): void;
308
+ export declare function loadStateFromDisk(logger: Logger): Promise<void>;
309
+ export type { ContentSource } from "./content-source.ts";
310
+ export { InMemoryContentSource } from "./in-memory-content-source.ts";