@superdoc/sdk 2.9.1-next.2 → 2.10.0-next.10

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 (57) hide show
  1. package/README.md +45 -0
  2. package/dist/action-primitives/doc-index.cjs +6 -4
  3. package/dist/action-primitives/doc-index.js +6 -4
  4. package/dist/action-primitives/engine.cjs +6 -2
  5. package/dist/action-primitives/engine.js +6 -2
  6. package/dist/action-primitives/receipt.d.ts +4 -0
  7. package/dist/action-primitives/tools/structure-insert.d.ts +1 -1
  8. package/dist/agent/actions.cjs +384 -373
  9. package/dist/agent/actions.d.ts +5 -0
  10. package/dist/agent/actions.js +385 -374
  11. package/dist/agent/catalog.cjs +15 -0
  12. package/dist/agent/catalog.js +15 -0
  13. package/dist/agent/doc-snapshot.cjs +205 -86
  14. package/dist/agent/doc-snapshot.d.ts +11 -0
  15. package/dist/agent/doc-snapshot.js +203 -86
  16. package/dist/agent/execution-context.cjs +385 -0
  17. package/dist/agent/execution-context.d.ts +97 -0
  18. package/dist/agent/execution-context.js +376 -0
  19. package/dist/agent/runtime.cjs +123 -117
  20. package/dist/agent/runtime.d.ts +3 -0
  21. package/dist/agent/runtime.js +124 -118
  22. package/dist/agent/v2-preset-compat.cjs +5 -1
  23. package/dist/agent/v2-preset-compat.js +4 -1
  24. package/dist/embedded-tools.generated.cjs +5 -5
  25. package/dist/embedded-tools.generated.js +5 -5
  26. package/dist/generated/client.cjs +2 -0
  27. package/dist/generated/client.d.ts +85 -0
  28. package/dist/generated/client.js +2 -0
  29. package/dist/generated/contract.cjs +1796 -1297
  30. package/dist/generated/contract.js +1797 -1297
  31. package/dist/index.cjs +23 -0
  32. package/dist/index.d.ts +7 -2
  33. package/dist/index.js +23 -0
  34. package/dist/presets/core.cjs +1 -1
  35. package/dist/presets/core.js +1 -1
  36. package/dist/runtime/document-evidence.cjs +40 -0
  37. package/dist/runtime/document-evidence.d.ts +13 -0
  38. package/dist/runtime/document-evidence.js +30 -0
  39. package/dist/runtime/document-rpc.cjs +27 -0
  40. package/dist/runtime/document-rpc.d.ts +2 -0
  41. package/dist/runtime/document-rpc.js +25 -0
  42. package/dist/runtime/host.cjs +65 -4
  43. package/dist/runtime/host.d.ts +3 -0
  44. package/dist/runtime/host.js +66 -5
  45. package/dist/runtime/process.cjs +38 -0
  46. package/dist/runtime/process.d.ts +16 -0
  47. package/dist/runtime/process.js +38 -0
  48. package/dist/runtime/sdk-version.generated.cjs +1 -1
  49. package/dist/runtime/sdk-version.generated.d.ts +1 -1
  50. package/dist/runtime/sdk-version.generated.js +1 -1
  51. package/package.json +10 -8
  52. package/tools/catalog.json +89 -0
  53. package/tools/tools-policy.json +1 -1
  54. package/tools/tools.anthropic.json +89 -0
  55. package/tools/tools.generic.json +89 -0
  56. package/tools/tools.openai.json +89 -0
  57. package/tools/tools.vercel.json +89 -0
@@ -0,0 +1,385 @@
1
+ 'use strict';
2
+
3
+ var documentEvidence = require('../runtime/document-evidence.cjs');
4
+ var errors = require('../runtime/errors.cjs');
5
+ var docSnapshot = require('./doc-snapshot.cjs');
6
+ var operationCatalog = require('./operation-catalog.cjs');
7
+
8
+ function supportsLocalSelector(selector) {
9
+ return (selector.kind === 'nodeId' ||
10
+ selector.kind === 'textSearch' ||
11
+ selector.kind === 'placement' ||
12
+ (selector.kind === 'ordinal' &&
13
+ ['blockOrdinal', 'headingOrdinal', 'tableOrdinal'].includes(selector.ordinalKind)) ||
14
+ (selector.kind === 'relative' && supportsLocalSelector(selector.target)));
15
+ }
16
+ function localCheck(check) {
17
+ return (['revision-changed', 'revision-unchanged', 'block-text-contains', 'block-text-equals', 'table-shape'].includes(check.kind) ||
18
+ (check.kind === 'block-count-delta' && ['paragraph', 'heading', 'listItem', 'table'].includes(check.nodeType)));
19
+ }
20
+ async function readPublicRevision(doc) {
21
+ const revision = await documentEvidence.getDocumentRevisionReader(doc)?.();
22
+ if (revision !== undefined)
23
+ return revision;
24
+ const page = await doc.blocks.list({ offset: Number.MAX_SAFE_INTEGER, limit: 1 });
25
+ if (!page.revision || page.revision === 'unknown')
26
+ throw new errors.SuperDocCliError('Required document revision is unavailable.', { code: 'EVIDENCE_UNAVAILABLE' });
27
+ return page.revision;
28
+ }
29
+ class DocumentFacts {
30
+ doc;
31
+ revision;
32
+ complete;
33
+ summaryCounts;
34
+ blocks = new Map();
35
+ counts = new Map();
36
+ selections = new Map();
37
+ constructor(doc, revision, complete, summaryCounts = complete?.counts) {
38
+ this.doc = doc;
39
+ this.revision = revision;
40
+ this.complete = complete;
41
+ this.summaryCounts = summaryCounts;
42
+ }
43
+ get summary() {
44
+ return { revision: this.revision, ...(this.summaryCounts ? { counts: this.summaryCounts } : {}) };
45
+ }
46
+ async fence() {
47
+ if ((await readPublicRevision(this.doc)) !== this.revision)
48
+ throw new errors.SuperDocCliError('Document changed while acquiring execution evidence.', { code: 'REVISION_CONFLICT' });
49
+ }
50
+ async page(input) {
51
+ const result = await this.doc.blocks.list({ ...input, includeText: true });
52
+ if (result.revision !== this.revision)
53
+ throw new errors.SuperDocCliError('Document changed while resolving a target.', { code: 'REVISION_CONFLICT' });
54
+ const blocks = result.blocks.map((block) => ({
55
+ ...block,
56
+ ordinal: block.ordinal + 1,
57
+ text: block.text ?? '',
58
+ textPreview: block.textPreview ?? null,
59
+ styleId: block.styleId ?? null,
60
+ }));
61
+ for (const block of blocks)
62
+ this.blocks.set(block.nodeId, block);
63
+ return blocks;
64
+ }
65
+ async count(nodeType) {
66
+ const key = nodeType ?? '*';
67
+ if (this.counts.has(key))
68
+ return this.counts.get(key);
69
+ if (this.complete)
70
+ return nodeType
71
+ ? this.complete.blocks.filter((block) => block.nodeType === nodeType).length
72
+ : this.complete.blocks.length;
73
+ const result = await this.doc.blocks.list({
74
+ offset: Number.MAX_SAFE_INTEGER,
75
+ limit: 1,
76
+ ...(nodeType ? { nodeTypes: [nodeType] } : {}),
77
+ });
78
+ if (result.revision !== this.revision || !Number.isSafeInteger(result.total))
79
+ throw new errors.SuperDocCliError('Required count is unavailable at the execution revision.', {
80
+ code: 'EVIDENCE_UNAVAILABLE',
81
+ });
82
+ this.counts.set(key, result.total);
83
+ return result.total;
84
+ }
85
+ async block(nodeId) {
86
+ if (this.complete)
87
+ return this.complete.blocks.find((block) => block.nodeId === nodeId);
88
+ if (!this.blocks.has(nodeId))
89
+ await this.page({ nodeIds: [nodeId], limit: 1 });
90
+ return this.blocks.get(nodeId);
91
+ }
92
+ async select(selector) {
93
+ if (this.complete)
94
+ return docSnapshot.resolveSnapshotSelector(this.complete, selector);
95
+ const key = JSON.stringify(selector);
96
+ if (this.selections.has(key))
97
+ return this.selections.get(key);
98
+ let blocks = [];
99
+ if (selector.kind === 'nodeId') {
100
+ const block = await this.block(selector.nodeId);
101
+ if (block)
102
+ blocks = [block];
103
+ }
104
+ else if (selector.kind === 'textSearch') {
105
+ const terms = selector.terms.filter((term) => term.trim());
106
+ if (terms.length && selector.nodeTypes?.length !== 0)
107
+ blocks = await this.page({
108
+ textSearch: { terms: [...terms], match: selector.match, caseSensitive: selector.caseSensitive },
109
+ nodeTypes: [...(selector.nodeTypes ?? ['paragraph', 'heading', 'listItem'])],
110
+ offset: (selector.occurrence ?? 1) - 1,
111
+ limit: 1,
112
+ });
113
+ }
114
+ else if (selector.kind === 'placement') {
115
+ const offset = selector.at === 'document_start' ? 0 : (await this.count()) - 1;
116
+ if (offset >= 0)
117
+ blocks = await this.page({ offset, limit: 1 });
118
+ }
119
+ else if (selector.kind === 'ordinal') {
120
+ blocks = await this.page({
121
+ offset: selector.value - 1,
122
+ limit: 1,
123
+ ...(selector.ordinalKind === 'headingOrdinal'
124
+ ? { nodeTypes: ['heading'] }
125
+ : selector.ordinalKind === 'tableOrdinal'
126
+ ? { nodeTypes: ['table'] }
127
+ : {}),
128
+ });
129
+ }
130
+ else if (selector.kind === 'relative') {
131
+ for (const id of await this.select(selector.target)) {
132
+ const target = await this.block(id);
133
+ const offset = target ? target.ordinal - 1 + (selector.position === 'before' ? -1 : 1) : -1;
134
+ if (offset >= 0)
135
+ blocks.push(...(await this.page({ offset, limit: 1 })));
136
+ }
137
+ }
138
+ else
139
+ throw new errors.SuperDocCliError('Selector requires complete evidence.', { code: 'EVIDENCE_UNAVAILABLE' });
140
+ const ids = [...new Set(blocks.map((block) => block.nodeId))];
141
+ this.selections.set(key, ids);
142
+ return ids;
143
+ }
144
+ async target(selector) {
145
+ const ids = await this.select(selector);
146
+ if (this.complete && selector.kind === 'tableCell' && ids.length === 1) {
147
+ const cell = this.complete.tables.flatMap((table) => table.cells).find((cell) => cell.nodeId === ids[0]);
148
+ if (cell?.nodeId)
149
+ return {
150
+ nodeId: cell.nodeId,
151
+ nodeType: 'paragraph',
152
+ text: cell.text,
153
+ textPreview: cell.text,
154
+ styleId: null,
155
+ ordinal: 0,
156
+ };
157
+ }
158
+ return ids.length === 1 ? this.block(ids[0]) : undefined;
159
+ }
160
+ async tableShape(nodeId) {
161
+ if (this.complete)
162
+ return this.complete.tables.find((table) => table.nodeId === nodeId);
163
+ return this.doc.tables.get({ nodeId });
164
+ }
165
+ async completeIndex(reason, acquire) {
166
+ const value = await acquire();
167
+ await this.fence();
168
+ return { value, coverage: 'complete', reason };
169
+ }
170
+ async prepare(checks) {
171
+ for (const check of checks)
172
+ if (check.kind === 'block-count-delta')
173
+ await this.count(check.nodeType);
174
+ }
175
+ }
176
+ class ExecutionContext {
177
+ source;
178
+ requirements;
179
+ document;
180
+ executedOperations = [];
181
+ selectedTargets = [];
182
+ pre;
183
+ post;
184
+ fallbackReason;
185
+ currentRevision;
186
+ legacyRevisionOnly = false;
187
+ constructor(source, requirements = {}) {
188
+ this.source = source;
189
+ this.requirements = requirements;
190
+ if (requirements.evidence !== undefined && !['required', 'full'].includes(requirements.evidence))
191
+ throw new errors.SuperDocCliError('evidence must be required or full.', { code: 'INVALID_ARGUMENT' });
192
+ const wrap = (value, path) => new Proxy(value, {
193
+ get: (target, property, receiver) => {
194
+ const member = Reflect.get(target, property, receiver);
195
+ if (typeof property !== 'string')
196
+ return member;
197
+ const memberPath = [...path, property];
198
+ const operationId = `doc.${memberPath.join('.')}`;
199
+ if (typeof member === 'function' && operationCatalog.getOperationCatalogEntry(operationId)?.isMutating) {
200
+ return async (args = {}, options) => {
201
+ if (operationId === 'doc.format.apply' &&
202
+ documentEvidence.supportsDocumentFacts(this.source) &&
203
+ typeof args.blockId === 'string') {
204
+ const { blockId, start, end, ...rest } = args;
205
+ args = {
206
+ ...rest,
207
+ target: {
208
+ kind: 'selection',
209
+ start: { kind: 'text', blockId, offset: start },
210
+ end: { kind: 'text', blockId, offset: end },
211
+ },
212
+ };
213
+ }
214
+ if (this.legacyRevisionOnly && this.executedOperations.length)
215
+ throw new errors.SuperDocCliError('This host cannot bind revisions across multiple writes.', {
216
+ code: 'EVIDENCE_UNAVAILABLE',
217
+ });
218
+ const guarded = (documentEvidence.supportsDocumentFacts(this.source) || this.legacyRevisionOnly) &&
219
+ !['doc.history.undo', 'doc.history.redo', 'doc.plan.execute'].includes(operationId);
220
+ const revision = guarded ? (this.currentRevision ?? (await readPublicRevision(this.source))) : undefined;
221
+ const result = await Reflect.apply(member, target, guarded
222
+ ? [
223
+ { ...args, expectedRevision: args.expectedRevision ?? revision },
224
+ { ...options, expectedRevision: options?.expectedRevision ?? revision },
225
+ ]
226
+ : [args, options]);
227
+ this.executedOperations.push({ operationId, result });
228
+ if (result?.success === false)
229
+ throw new errors.SuperDocCliError('Document operation did not apply.', {
230
+ code: result.failure?.code ?? 'APPLY_FAILED',
231
+ details: result,
232
+ });
233
+ if (documentEvidence.supportsDocumentFacts(this.source)) {
234
+ const applied = documentEvidence.getMutationRevision(result);
235
+ if (!applied ||
236
+ applied.before !== this.currentRevision ||
237
+ !applied.after ||
238
+ applied.after === 'unknown')
239
+ throw new errors.SuperDocCliError('Committed operation revision is unavailable or changed.', {
240
+ code: 'EVIDENCE_UNAVAILABLE',
241
+ });
242
+ this.currentRevision = applied.after;
243
+ }
244
+ return result;
245
+ };
246
+ }
247
+ if (member && typeof member === 'object')
248
+ return wrap(member, memberPath);
249
+ return member;
250
+ },
251
+ });
252
+ this.document = wrap(source, []);
253
+ documentEvidence.forwardDocumentEvidence(source, this.document);
254
+ }
255
+ async start() {
256
+ const { evidence, selectors = [], checks = [], completeReason } = this.requirements;
257
+ const compactRevision = this.requirements.revisionOnly && evidence !== 'full' && !completeReason
258
+ ? await documentEvidence.getDocumentRevisionReader(this.source)?.()
259
+ : undefined;
260
+ this.legacyRevisionOnly = compactRevision !== undefined && !documentEvidence.supportsDocumentFacts(this.source);
261
+ this.fallbackReason =
262
+ completeReason ??
263
+ (!documentEvidence.supportsDocumentFacts(this.source) && !this.legacyRevisionOnly
264
+ ? 'host lacks typed execution facts'
265
+ : selectors.some((selector) => !supportsLocalSelector(selector))
266
+ ? 'selector requires complete index'
267
+ : checks.some((check) => !localCheck(check))
268
+ ? 'verification requires complete evidence'
269
+ : undefined);
270
+ const complete = evidence === 'full' || this.fallbackReason ? await docSnapshot.buildMutationSnapshot(this.source) : undefined;
271
+ if (complete && (complete.revision === 'unknown' || complete.diagnostics.some((item) => item.section === 'info')))
272
+ throw new errors.SuperDocCliError('Required complete evidence is unavailable.', { code: 'EVIDENCE_UNAVAILABLE' });
273
+ this.pre = new DocumentFacts(this.source, complete?.revision ?? compactRevision ?? (await readPublicRevision(this.source)), complete);
274
+ this.currentRevision = this.pre.revision;
275
+ await this.pre.prepare(checks);
276
+ return this.pre;
277
+ }
278
+ async finishRevision() {
279
+ if (this.requirements.evidence === 'full')
280
+ return this.finish();
281
+ const summary = this.pre?.complete ? await docSnapshot.buildDocumentSnapshot(this.source, { countsOnly: true }) : undefined;
282
+ if (summary && (summary.revision === 'unknown' || summary.diagnostics.some((item) => item.section === 'info')))
283
+ throw new errors.SuperDocCliError('Required summary is unavailable.', { code: 'EVIDENCE_UNAVAILABLE' });
284
+ const revision = summary?.revision ?? (await readPublicRevision(this.source));
285
+ this.assertExecutionRevision(revision);
286
+ this.post = new DocumentFacts(this.source, revision, undefined, summary?.counts);
287
+ this.currentRevision = this.post.revision;
288
+ return this.post;
289
+ }
290
+ async finish() {
291
+ const complete = this.pre?.complete ? await docSnapshot.buildMutationSnapshot(this.source) : undefined;
292
+ if (complete && (complete.revision === 'unknown' || complete.diagnostics.some((item) => item.section === 'info')))
293
+ throw new errors.SuperDocCliError('Required complete evidence is unavailable.', { code: 'EVIDENCE_UNAVAILABLE' });
294
+ const revision = complete?.revision ?? (await readPublicRevision(this.source));
295
+ this.assertExecutionRevision(revision);
296
+ this.post = new DocumentFacts(this.source, revision, complete);
297
+ this.currentRevision = this.post.revision;
298
+ return this.post;
299
+ }
300
+ assertExecutionRevision(revision) {
301
+ if (documentEvidence.supportsDocumentFacts(this.source) && this.currentRevision !== revision)
302
+ throw new errors.SuperDocCliError('Document changed outside this execution.', { code: 'REVISION_CONFLICT' });
303
+ }
304
+ receipt(intent, verification, extra = {}) {
305
+ return {
306
+ status: verification.every((check) => check.passed) ? 'ok' : 'failed',
307
+ intent,
308
+ preSnapshot: this.pre?.summary,
309
+ postSnapshot: this.post?.summary,
310
+ selectedTargets: this.selectedTargets,
311
+ executedOperations: this.executedOperations,
312
+ verification,
313
+ ...(this.fallbackReason ? { evidenceFallback: this.fallbackReason } : {}),
314
+ ...extra,
315
+ };
316
+ }
317
+ failure(intent, error) {
318
+ const err = error;
319
+ return this.receipt(intent, [], {
320
+ status: err?.code === 'AMBIGUOUS_SELECTOR' ? 'aborted' : 'failed',
321
+ errors: [
322
+ { code: err?.code ?? 'ACTION_FAILED', message: err?.message ?? String(error), recovery: { kind: 'reinspect' } },
323
+ ],
324
+ });
325
+ }
326
+ }
327
+ async function evaluateFactChecks(pre, post, checks) {
328
+ const results = [];
329
+ for (const check of checks) {
330
+ if ([
331
+ 'revision-changed',
332
+ 'revision-unchanged',
333
+ 'block-count-delta',
334
+ 'comment-count-delta',
335
+ 'tracked-change-count-delta',
336
+ ].includes(check.kind) &&
337
+ !pre) {
338
+ results.push({ check, passed: false, detail: `${check.kind} requires a baseline snapshot` });
339
+ continue;
340
+ }
341
+ if (check.kind === 'revision-changed' || check.kind === 'revision-unchanged')
342
+ results.push({
343
+ check,
344
+ passed: check.kind === 'revision-changed' ? pre.revision !== post.revision : pre.revision === post.revision,
345
+ detail: `pre=${pre.revision} post=${post.revision}`,
346
+ });
347
+ else if (check.kind === 'block-count-delta') {
348
+ const before = await pre.count(check.nodeType), after = await post.count(check.nodeType);
349
+ results.push({
350
+ check,
351
+ passed: after - before === check.delta,
352
+ detail: `pre=${before} post=${after} delta=${after - before}`,
353
+ });
354
+ }
355
+ else if (check.kind === 'block-text-contains' || check.kind === 'block-text-equals') {
356
+ const block = await post.block(check.nodeId);
357
+ results.push({
358
+ check,
359
+ passed: !!block && (check.kind === 'block-text-equals' ? block.text === check.text : block.text.includes(check.text)),
360
+ });
361
+ }
362
+ else if (check.kind === 'table-shape') {
363
+ const table = await post.tableShape(check.nodeId);
364
+ results.push({ check, passed: !!table && table.rows === check.rows && table.columns === check.columns });
365
+ }
366
+ else if (check.kind === 'comment-count-delta' || check.kind === 'tracked-change-count-delta') {
367
+ const key = check.kind === 'comment-count-delta' ? 'comments' : 'trackedChanges';
368
+ const before = pre?.complete?.counts[key], after = post.complete?.counts[key];
369
+ results.push({
370
+ check,
371
+ passed: before !== undefined && after !== undefined && after - before === check.delta,
372
+ detail: `pre=${before} post=${after}`,
373
+ });
374
+ }
375
+ else
376
+ results.push({ check, passed: false, detail: 'Check requires domain-specific evidence.' });
377
+ }
378
+ return results;
379
+ }
380
+
381
+ exports.DocumentFacts = DocumentFacts;
382
+ exports.ExecutionContext = ExecutionContext;
383
+ exports.evaluateFactChecks = evaluateFactChecks;
384
+ exports.readPublicRevision = readPublicRevision;
385
+ exports.supportsLocalSelector = supportsLocalSelector;
@@ -0,0 +1,97 @@
1
+ import type { BoundDocApi, DocBlocksListBoundParams } from '../generated/client.js';
2
+ import { type DocumentSnapshot, type SnapshotBlock } from './doc-snapshot.js';
3
+ import type { AgentSelector, AgentVerificationCheck } from './ir.js';
4
+ import type { AgentReceipt, VerificationResult } from './runtime.js';
5
+ export type EvidencePolicy = 'required' | 'full';
6
+ export type EvidenceRequirements = {
7
+ evidence?: EvidencePolicy;
8
+ selectors?: readonly AgentSelector[];
9
+ checks?: readonly AgentVerificationCheck[];
10
+ completeReason?: string;
11
+ revisionOnly?: boolean;
12
+ };
13
+ export declare function supportsLocalSelector(selector: AgentSelector): boolean;
14
+ export declare function readPublicRevision(doc: BoundDocApi): Promise<string>;
15
+ export declare class DocumentFacts {
16
+ readonly doc: BoundDocApi;
17
+ readonly revision: string;
18
+ readonly complete?: DocumentSnapshot | undefined;
19
+ readonly summaryCounts: {
20
+ blocks: number;
21
+ paragraphs: number;
22
+ headings: number;
23
+ tables: number;
24
+ lists: number;
25
+ images: number;
26
+ comments: number;
27
+ trackedChanges: number;
28
+ sections: number;
29
+ fields: number;
30
+ hyperlinks: number;
31
+ bookmarks: number;
32
+ contentControls: number;
33
+ permissionRanges: number;
34
+ styles: number;
35
+ headers: number;
36
+ footers: number;
37
+ } | undefined;
38
+ readonly blocks: Map<string, SnapshotBlock>;
39
+ private readonly counts;
40
+ private readonly selections;
41
+ constructor(doc: BoundDocApi, revision: string, complete?: DocumentSnapshot | undefined, summaryCounts?: {
42
+ blocks: number;
43
+ paragraphs: number;
44
+ headings: number;
45
+ tables: number;
46
+ lists: number;
47
+ images: number;
48
+ comments: number;
49
+ trackedChanges: number;
50
+ sections: number;
51
+ fields: number;
52
+ hyperlinks: number;
53
+ bookmarks: number;
54
+ contentControls: number;
55
+ permissionRanges: number;
56
+ styles: number;
57
+ headers: number;
58
+ footers: number;
59
+ } | undefined);
60
+ get summary(): NonNullable<AgentReceipt['preSnapshot']>;
61
+ fence(): Promise<void>;
62
+ page(input: DocBlocksListBoundParams): Promise<SnapshotBlock[]>;
63
+ count(nodeType?: string): Promise<number>;
64
+ block(nodeId: string): Promise<SnapshotBlock | undefined>;
65
+ select(selector: AgentSelector): Promise<readonly string[]>;
66
+ target(selector: AgentSelector): Promise<SnapshotBlock | undefined>;
67
+ tableShape(nodeId: string): Promise<{
68
+ rows: number;
69
+ columns: number;
70
+ } | undefined>;
71
+ completeIndex<T>(reason: string, acquire: () => Promise<T>): Promise<{
72
+ value: T;
73
+ coverage: 'complete';
74
+ reason: string;
75
+ }>;
76
+ prepare(checks: readonly AgentVerificationCheck[]): Promise<void>;
77
+ }
78
+ export declare class ExecutionContext {
79
+ readonly source: BoundDocApi;
80
+ readonly requirements: EvidenceRequirements;
81
+ readonly document: BoundDocApi;
82
+ readonly executedOperations: NonNullable<AgentReceipt['executedOperations']>[number][];
83
+ readonly selectedTargets: NonNullable<AgentReceipt['selectedTargets']>[number][];
84
+ pre?: DocumentFacts;
85
+ post?: DocumentFacts;
86
+ fallbackReason?: string;
87
+ private currentRevision?;
88
+ private legacyRevisionOnly;
89
+ constructor(source: BoundDocApi, requirements?: EvidenceRequirements);
90
+ start(): Promise<DocumentFacts>;
91
+ finishRevision(): Promise<DocumentFacts>;
92
+ finish(): Promise<DocumentFacts>;
93
+ private assertExecutionRevision;
94
+ receipt(intent: string, verification: readonly VerificationResult[], extra?: Partial<AgentReceipt>): AgentReceipt;
95
+ failure(intent: string, error: unknown): AgentReceipt;
96
+ }
97
+ export declare function evaluateFactChecks(pre: DocumentFacts | undefined, post: DocumentFacts, checks: readonly AgentVerificationCheck[]): Promise<VerificationResult[]>;