@avocadostudio-ai/orchestrator-core 0.3.2 → 0.3.3

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 (69) hide show
  1. package/dist/chat/anthropic-planner.d.ts +8 -0
  2. package/dist/chat/anthropic-planner.js +166 -12
  3. package/dist/chat/chat-pipeline-translation.d.ts +13 -0
  4. package/dist/chat/chat-pipeline-translation.js +109 -45
  5. package/dist/chat/chat-pipeline.d.ts +1 -1
  6. package/dist/chat/chat-pipeline.js +296 -53
  7. package/dist/chat/gemini-planner.d.ts +2 -0
  8. package/dist/chat/gemini-planner.js +2 -1
  9. package/dist/chat/planner-types.d.ts +15 -0
  10. package/dist/chat/planner-types.js +2 -2
  11. package/dist/chat/planner.d.ts +12 -0
  12. package/dist/chat/planner.js +16 -2
  13. package/dist/chat/translation-chunking.d.ts +124 -0
  14. package/dist/chat/translation-chunking.js +371 -0
  15. package/dist/checks/field-walk.d.ts +25 -0
  16. package/dist/checks/field-walk.js +152 -0
  17. package/dist/checks/index.d.ts +5 -0
  18. package/dist/checks/index.js +4 -0
  19. package/dist/checks/page-weight.d.ts +22 -0
  20. package/dist/checks/page-weight.js +200 -0
  21. package/dist/checks/rules-draft.d.ts +2 -0
  22. package/dist/checks/rules-draft.js +375 -0
  23. package/dist/checks/run-checks.d.ts +32 -0
  24. package/dist/checks/run-checks.js +152 -0
  25. package/dist/checks/session-runner.d.ts +19 -0
  26. package/dist/checks/session-runner.js +95 -0
  27. package/dist/checks/types.d.ts +65 -0
  28. package/dist/checks/types.js +1 -0
  29. package/dist/durable/durable-store-singleton.d.ts +37 -0
  30. package/dist/durable/durable-store-singleton.js +179 -0
  31. package/dist/durable/finding-impact.d.ts +30 -0
  32. package/dist/durable/finding-impact.js +53 -0
  33. package/dist/durable/in-memory-durable-store.d.ts +203 -0
  34. package/dist/durable/in-memory-durable-store.js +363 -0
  35. package/dist/durable/index.d.ts +5 -0
  36. package/dist/durable/index.js +4 -0
  37. package/dist/durable/pending-plan-store.d.ts +28 -0
  38. package/dist/durable/pending-plan-store.js +156 -0
  39. package/dist/durable/sqlite-durable-store.d.ts +71 -0
  40. package/dist/durable/sqlite-durable-store.js +631 -0
  41. package/dist/durable/types.d.ts +265 -0
  42. package/dist/durable/types.js +1 -0
  43. package/dist/handler/create-orchestrator.d.ts +4 -0
  44. package/dist/handler/create-orchestrator.js +67 -4
  45. package/dist/http/audio-actions.d.ts +1 -1
  46. package/dist/http/checks-actions.d.ts +39 -0
  47. package/dist/http/checks-actions.js +122 -0
  48. package/dist/http/history-actions.d.ts +1 -1
  49. package/dist/http/image-generate-actions.d.ts +2 -2
  50. package/dist/http/ops-actions.d.ts +2 -2
  51. package/dist/http/publish-actions.d.ts +4 -4
  52. package/dist/http/restore-actions.d.ts +3 -3
  53. package/dist/http/screenshot-actions.d.ts +2 -2
  54. package/dist/http/session-actions.d.ts +1 -1
  55. package/dist/http/telemetry-feedback-actions.d.ts +2 -2
  56. package/dist/http/unsplash-actions.d.ts +2 -2
  57. package/dist/http/variations-actions.d.ts +2 -2
  58. package/dist/index.d.ts +7 -0
  59. package/dist/index.js +27 -0
  60. package/dist/nlp/deterministic-planner-context.d.ts +16 -0
  61. package/dist/nlp/deterministic-planner-context.js +33 -7
  62. package/dist/nlp/plan-normalizer.js +54 -6
  63. package/dist/ops/destructive-action-gate.js +7 -2
  64. package/dist/ops/ops-engine.d.ts +12 -1
  65. package/dist/ops/ops-engine.js +41 -14
  66. package/dist/publish/publish-target-registry.js +1 -1
  67. package/dist/publish/publish-target.d.ts +1 -1
  68. package/dist/state/session-state.js +8 -1
  69. package/package.json +3 -3
@@ -0,0 +1,65 @@
1
+ import type { BlockManifest, FieldKind, Operation, PageDoc, SiteConfig } from "@avocadostudio-ai/shared";
2
+ import type { FindingEvidence, FindingSeverity } from "../durable/types.ts";
3
+ /** One field on one block, located by the manifest rather than by block type. */
4
+ export type FieldEntry = {
5
+ blockId: string;
6
+ blockType: string;
7
+ /** Editable-path form: `title`, `cards[0].imageAlt`. */
8
+ path: string;
9
+ kind: FieldKind;
10
+ label?: string;
11
+ /**
12
+ * What a reader would call the block this field belongs to — its own heading,
13
+ * not the block type. A page with three Card Grids produces three findings
14
+ * reading `cards[0].imageAlt`, and the type name distinguishes none of them.
15
+ */
16
+ blockLabel?: string;
17
+ value: unknown;
18
+ /**
19
+ * The container this field sits in — `""` for a top-level prop, `cards[0]`
20
+ * for a list item. Pairing an image with its alt text is a question about
21
+ * siblings, and the container is what makes "sibling" meaningful.
22
+ */
23
+ container: string;
24
+ };
25
+ /** The other pages, for the rules that cannot be answered from one page. */
26
+ export type SiteView = {
27
+ slugs: string[];
28
+ pages: Array<Pick<PageDoc, "slug" | "title"> & {
29
+ meta?: PageDoc["meta"];
30
+ }>;
31
+ config: SiteConfig;
32
+ };
33
+ export type CheckContext = {
34
+ scopeKey: string;
35
+ page: PageDoc;
36
+ site: SiteView;
37
+ manifest: BlockManifest;
38
+ /** Every field on the page, already flattened. Rules should not re-walk. */
39
+ fields: FieldEntry[];
40
+ };
41
+ /**
42
+ * What a rule returns.
43
+ *
44
+ * Deliberately *not* a `FindingInput`: the fingerprint is computed by the
45
+ * runner from `(scopeKey, slug, ruleId, key)`, so a rule cannot accidentally
46
+ * fold the offending value into it. That mistake is invisible until the day
47
+ * somebody half-fixes a title and gets a second finding instead of an updated
48
+ * one, and the dismissal they made last week stops applying.
49
+ */
50
+ export type RuleFinding = {
51
+ /** Distinguishes several findings from one rule on one page. Stable, not a value. */
52
+ key?: string;
53
+ severity?: FindingSeverity;
54
+ title: string;
55
+ detail?: string;
56
+ evidence?: FindingEvidence;
57
+ proposedOps?: Operation[];
58
+ };
59
+ export type CheckRule = {
60
+ id: string;
61
+ agent: string;
62
+ /** Used when a finding does not override it. */
63
+ severity: FindingSeverity;
64
+ run(ctx: CheckContext): RuleFinding[];
65
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { DurableStore } from "./types.ts";
2
+ export declare function getDurableStore(): DurableStore;
3
+ /**
4
+ * Whether findings, memory and proposals are reaching disk, and why not.
5
+ *
6
+ * Deliberately separate from `persistenceHealth()`, which answers the same
7
+ * question about page state and whose warning text is about losing edits.
8
+ */
9
+ export declare function durableHealth(): {
10
+ ok: boolean;
11
+ reason: string | null;
12
+ };
13
+ /**
14
+ * Record a durable-store write failure. Separate from the page-state channel:
15
+ * a proposal row that did not save must not tell the user their edits are gone.
16
+ */
17
+ export declare function noteDurableFailure(reason: string): void;
18
+ /**
19
+ * True when findings, memory and proposals are living in memory only. Callers
20
+ * that are about to promise durability — a scheduled run leaving a plan for the
21
+ * morning — should say so rather than assume.
22
+ */
23
+ export declare function durableStoreIsEphemeral(): boolean;
24
+ /** Drop the singleton. Tests and graceful shutdown; `getStore()` owns closing. */
25
+ export declare function resetDurableStore(): void;
26
+ /** Swap in a store — for tests, and for a host that brings its own backend. */
27
+ export declare function setDurableStore(next: DurableStore | null, ephemeral?: boolean): void;
28
+ export declare function isDiscardInFlight(scopeKey: string): boolean;
29
+ /**
30
+ * Discard any pending proposal for a session being deleted.
31
+ *
32
+ * Without this, deleting a session leaves a `pending` row behind, and the next
33
+ * session with that id would rehydrate a plan the user had already thrown away.
34
+ */
35
+ export declare function discardPendingProposalsForSession(scopeKey: string): void;
36
+ /** Sweep proposals past their TTL, alongside the ephemeral-map eviction pass. */
37
+ export declare function sweepExpiredProposals(): void;
@@ -0,0 +1,179 @@
1
+ import { getStore } from "../state/sqlite-store-singleton.js";
2
+ import { SqliteDurableStore } from "./sqlite-durable-store.js";
3
+ import { InMemoryDurableStore } from "./in-memory-durable-store.js";
4
+ /*
5
+ * Singleton access to the durable store, mirroring `getStore()` next door.
6
+ *
7
+ * The one interesting decision here is what to do when SQLite is unavailable.
8
+ * `getStore()` throws: the driver could not load, and there is no page state
9
+ * without it. This one falls back to `InMemoryDurableStore` instead, for the
10
+ * same reason `createOrchestrator()` already keeps serving edits in that
11
+ * situation — a findings panel that 500s because a native module is missing is
12
+ * worse than one that works and says it is not saving anything.
13
+ *
14
+ * The failure is recorded here rather than through `notePersistenceFailure`.
15
+ * That channel is about *page state*: its warning tells the user "this edit was
16
+ * applied in memory but could not be saved", and every mutation response starts
17
+ * carrying `persisted: false`. Reporting a failed *proposal* row through it
18
+ * would tell somebody their content edits are being lost when they are not —
19
+ * a worse lie than the one the channel exists to prevent.
20
+ *
21
+ * Findings and proposals are capable of exactly the same lie on their own
22
+ * account, and an overnight run is precisely when nobody is watching the log,
23
+ * so they get their own flag with its own wording.
24
+ */
25
+ let store = null;
26
+ let usingFallback = false;
27
+ let overridden = false;
28
+ let failureReason = null;
29
+ let lastAttemptAt = 0;
30
+ /** How long to stay on the fallback before re-trying SQLite. */
31
+ const RETRY_COOLDOWN_MS = 30_000;
32
+ /*
33
+ * The connection `store` was built against.
34
+ *
35
+ * `resetStore()` next door closes the database and drops its singleton, and the
36
+ * next `getStore()` opens a fresh one — which used to leave this module holding
37
+ * prepared statements on a closed handle. Rather than have `resetStore()` call
38
+ * in here (a cycle: this module imports that one), we notice: a different `db`
39
+ * object means a different database, and the store is rebuilt against it.
40
+ */
41
+ let boundDb = null;
42
+ export function getDurableStore() {
43
+ // An explicitly-set store is sticky; the fallback is not.
44
+ if (store && overridden)
45
+ return store;
46
+ /*
47
+ * The fallback must not be permanent. `getStore()` next door leaves its own
48
+ * singleton null on a constructor throw and retries on the next call, so page
49
+ * state recovers from a transient failure — a `.data` directory not yet
50
+ * writable at boot, say — while this store, if it latched, would stay
51
+ * memory-only for the life of the process with no way back.
52
+ *
53
+ * Retrying on a cooldown rather than every call keeps a genuinely broken
54
+ * install from paying for a constructor on every finding. Whatever the
55
+ * fallback accumulated is lost on a successful retry; it was never durable,
56
+ * and saying so is the honest trade.
57
+ */
58
+ if (store && usingFallback && Date.now() - lastAttemptAt < RETRY_COOLDOWN_MS)
59
+ return store;
60
+ try {
61
+ lastAttemptAt = Date.now();
62
+ // Share `SqliteStore`'s connection: one WAL, one backup, one VACUUM INTO.
63
+ const db = getStore().db;
64
+ if (!store || usingFallback || boundDb !== db) {
65
+ store = new SqliteDurableStore(db);
66
+ boundDb = db;
67
+ usingFallback = false;
68
+ failureReason = null;
69
+ }
70
+ }
71
+ catch (err) {
72
+ failureReason = err instanceof Error ? err.message : String(err);
73
+ if (!store || !usingFallback) {
74
+ store = new InMemoryDurableStore();
75
+ boundDb = null;
76
+ usingFallback = true;
77
+ }
78
+ }
79
+ return store;
80
+ }
81
+ /**
82
+ * Whether findings, memory and proposals are reaching disk, and why not.
83
+ *
84
+ * Deliberately separate from `persistenceHealth()`, which answers the same
85
+ * question about page state and whose warning text is about losing edits.
86
+ */
87
+ export function durableHealth() {
88
+ return { ok: !usingFallback, reason: usingFallback ? failureReason : null };
89
+ }
90
+ /**
91
+ * Record a durable-store write failure. Separate from the page-state channel:
92
+ * a proposal row that did not save must not tell the user their edits are gone.
93
+ */
94
+ export function noteDurableFailure(reason) {
95
+ failureReason ??= reason;
96
+ }
97
+ /**
98
+ * True when findings, memory and proposals are living in memory only. Callers
99
+ * that are about to promise durability — a scheduled run leaving a plan for the
100
+ * morning — should say so rather than assume.
101
+ */
102
+ export function durableStoreIsEphemeral() {
103
+ if (!store)
104
+ getDurableStore();
105
+ return usingFallback;
106
+ }
107
+ /** Drop the singleton. Tests and graceful shutdown; `getStore()` owns closing. */
108
+ export function resetDurableStore() {
109
+ store = null;
110
+ usingFallback = false;
111
+ overridden = false;
112
+ boundDb = null;
113
+ failureReason = null;
114
+ lastAttemptAt = 0;
115
+ }
116
+ /** Swap in a store — for tests, and for a host that brings its own backend. */
117
+ export function setDurableStore(next, ephemeral = false) {
118
+ store = next;
119
+ usingFallback = next ? ephemeral : false;
120
+ overridden = next !== null;
121
+ boundDb = null;
122
+ }
123
+ /*
124
+ * The two lifecycle hooks `session-state.ts` needs, living here rather than in
125
+ * `pending-plan-store.ts` so that session-state can call them without importing
126
+ * a module that imports session-state back. The cycle would probably work —
127
+ * neither side touches the other at module scope — but this repo has already
128
+ * been bitten by ESM evaluation order once, and a cleanup call is not worth
129
+ * finding out a second time.
130
+ *
131
+ * Both are fire-and-forget: they are called from synchronous state mutators
132
+ * whose signatures a durability concern has no business changing, and neither
133
+ * result affects what the caller returns.
134
+ */
135
+ /**
136
+ * Sessions whose pending rows are being discarded right now.
137
+ *
138
+ * The set is added to *synchronously*, before the async discard starts, and the
139
+ * rehydration path consults it. `forgetSession` is a synchronous mutator, so
140
+ * without this a caller that forgets a session and immediately opens a new chat
141
+ * on the same id — ids are caller-supplied and routinely reused — races the
142
+ * discard and reads back the plan the delete was meant to remove.
143
+ *
144
+ * It lives here rather than in `pending-plan-store.ts` for the same reason the
145
+ * hooks below do: session-state must be able to reach it without importing a
146
+ * module that imports session-state back.
147
+ */
148
+ const discardInFlight = new Set();
149
+ export function isDiscardInFlight(scopeKey) {
150
+ return discardInFlight.has(scopeKey);
151
+ }
152
+ /**
153
+ * Discard any pending proposal for a session being deleted.
154
+ *
155
+ * Without this, deleting a session leaves a `pending` row behind, and the next
156
+ * session with that id would rehydrate a plan the user had already thrown away.
157
+ */
158
+ export function discardPendingProposalsForSession(scopeKey) {
159
+ discardInFlight.add(scopeKey);
160
+ void (async () => {
161
+ const active = getDurableStore();
162
+ const rows = await active.listProposals({ scopeKey, status: "pending" });
163
+ for (const row of rows)
164
+ await active.setProposalStatus(row.id, "discarded");
165
+ })()
166
+ .catch(() => {
167
+ /* best-effort: an orphan row is inert until something reads it, and the
168
+ read path re-checks expiry and payload validity anyway. */
169
+ })
170
+ .finally(() => discardInFlight.delete(scopeKey));
171
+ }
172
+ /** Sweep proposals past their TTL, alongside the ephemeral-map eviction pass. */
173
+ export function sweepExpiredProposals() {
174
+ void getDurableStore()
175
+ .expireProposals()
176
+ .catch(() => {
177
+ /* best-effort */
178
+ });
179
+ }
@@ -0,0 +1,30 @@
1
+ import type { FindingSeverity } from "./types.ts";
2
+ /**
3
+ * What a severity is worth before the page is taken into account.
4
+ *
5
+ * Not linear, and deliberately: `info` is defined in `rules-draft.ts` as "worth
6
+ * a look, and safe to ignore forever", so an info finding on the home page
7
+ * should sit below a warning on a secondary page, and 0.3 × 1.0 < 0.6 × 0.55
8
+ * is what makes that true.
9
+ */
10
+ export declare const SEVERITY_WEIGHT: Record<FindingSeverity, number>;
11
+ /**
12
+ * The weight given to a page nothing has scored — a row written by a build
13
+ * before impact existed, or by a caller that supplied no weights.
14
+ *
15
+ * Mid-scale rather than 1, so old rows interleave with scored ones instead of
16
+ * sorting above every finding on the site until the next run corrects them.
17
+ */
18
+ export declare const NEUTRAL_PAGE_WEIGHT = 0.5;
19
+ /** Severity × page weight, rounded to something a human can read in a log. */
20
+ export declare function impactFor(severity: FindingSeverity, pageWeight: number): number;
21
+ /** What an unscored finding is worth. Must match `IMPACT_FALLBACK_SQL`. */
22
+ export declare function fallbackImpact(severity: FindingSeverity): number;
23
+ /**
24
+ * The same fallback, for SQLite's ORDER BY.
25
+ *
26
+ * Generated from the constants above rather than written out, because the one
27
+ * failure mode here is the two drifting apart — the list would then be sorted
28
+ * by one rule and explained by another, and nothing would look wrong.
29
+ */
30
+ export declare const IMPACT_FALLBACK_SQL: string;
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Impact — severity times how much the page matters.
3
+ *
4
+ * It lives beside the types rather than in `checks/` because both stores need
5
+ * it: a finding written before this shipped has no `impact` column, and the
6
+ * ORDER BY has to put it somewhere defensible rather than at one end.
7
+ *
8
+ * The two axes stay separate on the record. Severity is a claim about the
9
+ * problem and belongs to the rule; impact is a claim about the page and is
10
+ * recomputed by every run, because the link graph moves. Multiplying them into
11
+ * one stored number instead would make a finding's severity unrecoverable, and
12
+ * severity is what the icon in the panel means.
13
+ */
14
+ /**
15
+ * What a severity is worth before the page is taken into account.
16
+ *
17
+ * Not linear, and deliberately: `info` is defined in `rules-draft.ts` as "worth
18
+ * a look, and safe to ignore forever", so an info finding on the home page
19
+ * should sit below a warning on a secondary page, and 0.3 × 1.0 < 0.6 × 0.55
20
+ * is what makes that true.
21
+ */
22
+ export const SEVERITY_WEIGHT = {
23
+ error: 1,
24
+ warning: 0.6,
25
+ info: 0.3
26
+ };
27
+ /**
28
+ * The weight given to a page nothing has scored — a row written by a build
29
+ * before impact existed, or by a caller that supplied no weights.
30
+ *
31
+ * Mid-scale rather than 1, so old rows interleave with scored ones instead of
32
+ * sorting above every finding on the site until the next run corrects them.
33
+ */
34
+ export const NEUTRAL_PAGE_WEIGHT = 0.5;
35
+ /** Severity × page weight, rounded to something a human can read in a log. */
36
+ export function impactFor(severity, pageWeight) {
37
+ const clamped = Math.max(0, Math.min(pageWeight, 1));
38
+ return Math.round(SEVERITY_WEIGHT[severity] * clamped * 1000) / 1000;
39
+ }
40
+ /** What an unscored finding is worth. Must match `IMPACT_FALLBACK_SQL`. */
41
+ export function fallbackImpact(severity) {
42
+ return impactFor(severity, NEUTRAL_PAGE_WEIGHT);
43
+ }
44
+ /**
45
+ * The same fallback, for SQLite's ORDER BY.
46
+ *
47
+ * Generated from the constants above rather than written out, because the one
48
+ * failure mode here is the two drifting apart — the list would then be sorted
49
+ * by one rule and explained by another, and nothing would look wrong.
50
+ */
51
+ export const IMPACT_FALLBACK_SQL = `COALESCE(impact, CASE severity ${Object.keys(SEVERITY_WEIGHT)
52
+ .map((severity) => `WHEN '${severity}' THEN ${fallbackImpact(severity)}`)
53
+ .join(" ")} END)`;
@@ -0,0 +1,203 @@
1
+ import type { CheckRunInput, CheckRunPatch, CorrectionInput, CorrectionQuery, DurableStore, FindingInput, FindingQuery, FindingSeverity, FindingStatus, MemoryInput, MemoryQuery, MemoryStatus, ProposalInput, ProposalQuery, ProposalStatus } from "./types.ts";
2
+ export type InMemoryDurableStoreOptions = {
3
+ now?: () => number;
4
+ };
5
+ export declare class InMemoryDurableStore implements DurableStore {
6
+ private readonly findings;
7
+ /** (scopeKey, fingerprint) → finding id. Mirrors the SQLite unique index. */
8
+ private readonly byFingerprint;
9
+ private readonly runs;
10
+ private readonly memory;
11
+ private readonly corrections;
12
+ private readonly proposals;
13
+ private readonly now;
14
+ constructor(options?: InMemoryDurableStoreOptions);
15
+ /** Keep the newest `cap` rows per scope, matching the SQLite store's trim. */
16
+ private trim;
17
+ recordFindings(runId: string, findings: FindingInput[]): Promise<{
18
+ opened: number;
19
+ updated: number;
20
+ }>;
21
+ reconcileFindings(args: {
22
+ runId: string;
23
+ scopeKey: string;
24
+ slugs: string[];
25
+ agent?: string;
26
+ at?: number;
27
+ }): Promise<{
28
+ closed: number;
29
+ }>;
30
+ listFindings(query: FindingQuery): Promise<{
31
+ fingerprint: string;
32
+ scopeKey: string;
33
+ slug: string;
34
+ ruleId: string;
35
+ agent: string;
36
+ severity: FindingSeverity;
37
+ impact: number;
38
+ title: string;
39
+ detail?: string;
40
+ evidence?: import("./types.ts").FindingEvidence;
41
+ proposedOps?: import("@avocadostudio-ai/shared").Operation[];
42
+ id: string;
43
+ status: FindingStatus;
44
+ lastRunId: string;
45
+ firstSeenAt: number;
46
+ lastSeenAt: number;
47
+ resolvedAt?: number;
48
+ snoozedUntil?: number;
49
+ }[]>;
50
+ getFinding(id: string): Promise<{
51
+ fingerprint: string;
52
+ scopeKey: string;
53
+ slug: string;
54
+ ruleId: string;
55
+ agent: string;
56
+ severity: FindingSeverity;
57
+ impact: number;
58
+ title: string;
59
+ detail?: string;
60
+ evidence?: import("./types.ts").FindingEvidence;
61
+ proposedOps?: import("@avocadostudio-ai/shared").Operation[];
62
+ id: string;
63
+ status: FindingStatus;
64
+ lastRunId: string;
65
+ firstSeenAt: number;
66
+ lastSeenAt: number;
67
+ resolvedAt?: number;
68
+ snoozedUntil?: number;
69
+ } | null>;
70
+ setFindingStatus(id: string, status: FindingStatus, at?: number): Promise<void>;
71
+ wakeSnoozedFindings(scopeKey: string, now?: number): Promise<{
72
+ woken: number;
73
+ }>;
74
+ startCheckRun(run: CheckRunInput): Promise<{
75
+ id: string;
76
+ scopeKey: string;
77
+ agent: string;
78
+ trigger: import("./types.ts").CheckRunTrigger;
79
+ startedAt: number;
80
+ finishedAt?: number;
81
+ pagesScanned: number;
82
+ findingsOpened: number;
83
+ findingsClosed: number;
84
+ costUsd: number;
85
+ error?: string;
86
+ }>;
87
+ finishCheckRun(id: string, patch: CheckRunPatch): Promise<void>;
88
+ listCheckRuns(scopeKey: string, limit?: number): Promise<{
89
+ id: string;
90
+ scopeKey: string;
91
+ agent: string;
92
+ trigger: import("./types.ts").CheckRunTrigger;
93
+ startedAt: number;
94
+ finishedAt?: number;
95
+ pagesScanned: number;
96
+ findingsOpened: number;
97
+ findingsClosed: number;
98
+ costUsd: number;
99
+ error?: string;
100
+ }[]>;
101
+ putMemory(input: MemoryInput, at?: number): Promise<{
102
+ confidence: number;
103
+ scope: import("./types.ts").MemoryScope;
104
+ scopeKey: string;
105
+ kind: import("./types.ts").MemoryKind;
106
+ key: string;
107
+ value: string;
108
+ source: import("./types.ts").MemorySource;
109
+ sourceRef?: string;
110
+ id: string;
111
+ status: MemoryStatus;
112
+ supersedesId?: string;
113
+ createdAt: number;
114
+ lastUsedAt?: number;
115
+ useCount: number;
116
+ }>;
117
+ listMemory(query?: MemoryQuery): Promise<{
118
+ confidence: number;
119
+ scope: import("./types.ts").MemoryScope;
120
+ scopeKey: string;
121
+ kind: import("./types.ts").MemoryKind;
122
+ key: string;
123
+ value: string;
124
+ source: import("./types.ts").MemorySource;
125
+ sourceRef?: string;
126
+ id: string;
127
+ status: MemoryStatus;
128
+ supersedesId?: string;
129
+ createdAt: number;
130
+ lastUsedAt?: number;
131
+ useCount: number;
132
+ }[]>;
133
+ touchMemory(ids: string[], at?: number): Promise<void>;
134
+ setMemoryStatus(id: string, status: MemoryStatus): Promise<void>;
135
+ recordCorrection(input: CorrectionInput, at?: number): Promise<{
136
+ traceId: string;
137
+ scopeKey: string;
138
+ slug?: string;
139
+ request: string;
140
+ proposed: import("@avocadostudio-ai/shared").Operation[];
141
+ outcome: import("./types.ts").CorrectionOutcome;
142
+ applied?: import("@avocadostudio-ai/shared").Operation[];
143
+ id: string;
144
+ at: number;
145
+ }>;
146
+ listCorrections(query?: CorrectionQuery): Promise<{
147
+ traceId: string;
148
+ scopeKey: string;
149
+ slug?: string;
150
+ request: string;
151
+ proposed: import("@avocadostudio-ai/shared").Operation[];
152
+ outcome: import("./types.ts").CorrectionOutcome;
153
+ applied?: import("@avocadostudio-ai/shared").Operation[];
154
+ id: string;
155
+ at: number;
156
+ }[]>;
157
+ putProposal(input: ProposalInput): Promise<{
158
+ id: string;
159
+ scopeKey: string;
160
+ origin: string;
161
+ summary: string;
162
+ ops: import("@avocadostudio-ai/shared").Operation[];
163
+ slugs: string[];
164
+ findingId?: string;
165
+ payload?: Record<string, unknown>;
166
+ createdAt: number;
167
+ expiresAt?: number;
168
+ status: ProposalStatus;
169
+ resolvedAt?: number;
170
+ }>;
171
+ getProposal(id: string): Promise<{
172
+ id: string;
173
+ scopeKey: string;
174
+ origin: string;
175
+ summary: string;
176
+ ops: import("@avocadostudio-ai/shared").Operation[];
177
+ slugs: string[];
178
+ findingId?: string;
179
+ payload?: Record<string, unknown>;
180
+ createdAt: number;
181
+ expiresAt?: number;
182
+ status: ProposalStatus;
183
+ resolvedAt?: number;
184
+ } | null>;
185
+ listProposals(query: ProposalQuery): Promise<{
186
+ id: string;
187
+ scopeKey: string;
188
+ origin: string;
189
+ summary: string;
190
+ ops: import("@avocadostudio-ai/shared").Operation[];
191
+ slugs: string[];
192
+ findingId?: string;
193
+ payload?: Record<string, unknown>;
194
+ createdAt: number;
195
+ expiresAt?: number;
196
+ status: ProposalStatus;
197
+ resolvedAt?: number;
198
+ }[]>;
199
+ setProposalStatus(id: string, status: ProposalStatus, at?: number): Promise<void>;
200
+ expireProposals(now?: number): Promise<{
201
+ expired: number;
202
+ }>;
203
+ }