@superdoc/sdk 2.12.0-next.3 → 2.12.0-next.5
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.
- package/README.md +15 -0
- package/dist/agent/doc-snapshot.cjs +30 -24
- package/dist/agent/doc-snapshot.d.ts +1 -0
- package/dist/agent/doc-snapshot.js +29 -24
- package/dist/agent/runtime.cjs +6 -1
- package/dist/agent/runtime.d.ts +5 -1
- package/dist/agent/runtime.js +6 -1
- package/dist/agent/textbox-snapshot.cjs +65 -0
- package/dist/agent/textbox-snapshot.d.ts +22 -0
- package/dist/agent/textbox-snapshot.js +60 -0
- package/dist/index.d.ts +1 -1
- package/dist/runtime/sdk-version.generated.cjs +1 -1
- package/dist/runtime/sdk-version.generated.d.ts +1 -1
- package/dist/runtime/sdk-version.generated.js +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -96,3 +96,18 @@ automatically replay the write.
|
|
|
96
96
|
## License
|
|
97
97
|
|
|
98
98
|
AGPL-3.0. Commercial licenses are available from [SuperDoc](https://www.superdoc.dev).
|
|
99
|
+
|
|
100
|
+
## Inspecting textbox sections
|
|
101
|
+
|
|
102
|
+
`superdoc_inspect` includes discovered text-bearing textbox stories in `textboxes` when
|
|
103
|
+
block inspection is enabled. Each entry contains its explicit `story` locator,
|
|
104
|
+
its story-local `total`, and normalized `blocks` with text, identities, and list
|
|
105
|
+
markers. The top-level `blocks` array and its ordinals continue to refer to the
|
|
106
|
+
body; textbox block ordinals belong to their containing story.
|
|
107
|
+
|
|
108
|
+
The block offset, limit, text cap, and block filters also apply within each
|
|
109
|
+
textbox. Count-only inspections and inspections excluding the blocks domain do
|
|
110
|
+
not collect textbox text. Check `diagnostics` for incomplete story discovery or
|
|
111
|
+
reads. To edit a discovered heading, use `query.match` with its story locator
|
|
112
|
+
and pass the returned reference to `replace`; a textbox ordinal is not a body
|
|
113
|
+
action selector.
|
|
@@ -141,6 +141,33 @@ function populateTableCellsFromExtract(tables, extractRaw, tableOrdinalBase = 0)
|
|
|
141
141
|
table.cells = [...cellMap.values()].sort((left, right) => left.rowIndex - right.rowIndex || left.columnIndex - right.columnIndex);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
function normalizeSnapshotBlock(value, fallbackOrdinal, blockTextLimit) {
|
|
145
|
+
const rec = asRecord(value) ?? {};
|
|
146
|
+
const fullText = asString(rec.text);
|
|
147
|
+
const text = truncateBlockText(fullText, blockTextLimit);
|
|
148
|
+
const textPreview = typeof rec.textPreview === 'string' ? truncateBlockText(rec.textPreview, blockTextLimit) : null;
|
|
149
|
+
const block = {
|
|
150
|
+
// doc-api block.ordinal is 0-based; the model-facing convention is
|
|
151
|
+
// 1-based (matches paragraphOrdinal/tableOrdinal and ordinal selectors).
|
|
152
|
+
ordinal: asNumber(rec.ordinal, fallbackOrdinal) + 1,
|
|
153
|
+
nodeId: asString(rec.nodeId),
|
|
154
|
+
nodeType: asString(rec.nodeType, 'paragraph'),
|
|
155
|
+
text,
|
|
156
|
+
textPreview,
|
|
157
|
+
styleId: typeof rec.styleId === 'string' ? rec.styleId : null,
|
|
158
|
+
headingLevel: typeof rec.headingLevel === 'number' ? rec.headingLevel : undefined,
|
|
159
|
+
...(asRecord(rec.numbering)
|
|
160
|
+
? {
|
|
161
|
+
numbering: {
|
|
162
|
+
marker: asString(asRecord(rec.numbering).marker) || null,
|
|
163
|
+
path: Array.isArray(asRecord(rec.numbering).path) ? asRecord(rec.numbering).path : null,
|
|
164
|
+
kind: asString(asRecord(rec.numbering).kind) || null,
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
: {}),
|
|
168
|
+
};
|
|
169
|
+
return block;
|
|
170
|
+
}
|
|
144
171
|
/**
|
|
145
172
|
* Build a deterministic snapshot of a document. The snapshot uses only
|
|
146
173
|
* read-mode operations from the generated contract — it never mutates state,
|
|
@@ -259,30 +286,8 @@ async function buildDocumentSnapshot(doc, options = {}) {
|
|
|
259
286
|
const rawBlocks = Array.isArray(blocksRec?.blocks) ? blocksRec.blocks : [];
|
|
260
287
|
const fullBlockText = new Map();
|
|
261
288
|
const normalizedBlocks = rawBlocks.map((b, index) => {
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
const text = truncateBlockText(fullText, blockTextLimit);
|
|
265
|
-
const textPreview = typeof rec.textPreview === 'string' ? truncateBlockText(rec.textPreview, blockTextLimit) : null;
|
|
266
|
-
const block = {
|
|
267
|
-
// doc-api block.ordinal is 0-based; the model-facing convention is
|
|
268
|
-
// 1-based (matches paragraphOrdinal/tableOrdinal and ordinal selectors).
|
|
269
|
-
ordinal: asNumber(rec.ordinal, blockOffset + index) + 1,
|
|
270
|
-
nodeId: asString(rec.nodeId),
|
|
271
|
-
nodeType: asString(rec.nodeType, 'paragraph'),
|
|
272
|
-
text,
|
|
273
|
-
textPreview,
|
|
274
|
-
styleId: typeof rec.styleId === 'string' ? rec.styleId : null,
|
|
275
|
-
headingLevel: typeof rec.headingLevel === 'number' ? rec.headingLevel : undefined,
|
|
276
|
-
...(asRecord(rec.numbering)
|
|
277
|
-
? {
|
|
278
|
-
numbering: {
|
|
279
|
-
marker: asString(asRecord(rec.numbering).marker) || null,
|
|
280
|
-
path: Array.isArray(asRecord(rec.numbering).path) ? asRecord(rec.numbering).path : null,
|
|
281
|
-
kind: asString(asRecord(rec.numbering).kind) || null,
|
|
282
|
-
},
|
|
283
|
-
}
|
|
284
|
-
: {}),
|
|
285
|
-
};
|
|
289
|
+
const fullText = asString(asRecord(b)?.text);
|
|
290
|
+
const block = normalizeSnapshotBlock(b, blockOffset + index, blockTextLimit);
|
|
286
291
|
fullBlockText.set(block, fullText);
|
|
287
292
|
return block;
|
|
288
293
|
});
|
|
@@ -1003,4 +1008,5 @@ exports.MutationSnapshotError = MutationSnapshotError;
|
|
|
1003
1008
|
exports.buildDocumentSnapshot = buildDocumentSnapshot;
|
|
1004
1009
|
exports.buildMutationSnapshot = buildMutationSnapshot;
|
|
1005
1010
|
exports.matchRunsForBlock = matchRunsForBlock;
|
|
1011
|
+
exports.normalizeSnapshotBlock = normalizeSnapshotBlock;
|
|
1006
1012
|
exports.resolveSnapshotSelector = resolveSnapshotSelector;
|
|
@@ -306,6 +306,7 @@ type SnapshotOptions = {
|
|
|
306
306
|
/** Max blocks to enrich with runs when includeBlockRuns is set (default 30). */
|
|
307
307
|
blockRunsLimit?: number;
|
|
308
308
|
};
|
|
309
|
+
export declare function normalizeSnapshotBlock(value: unknown, fallbackOrdinal: number, blockTextLimit: number | null): SnapshotBlock;
|
|
309
310
|
/**
|
|
310
311
|
* Build a deterministic snapshot of a document. The snapshot uses only
|
|
311
312
|
* read-mode operations from the generated contract — it never mutates state,
|
|
@@ -139,6 +139,33 @@ function populateTableCellsFromExtract(tables, extractRaw, tableOrdinalBase = 0)
|
|
|
139
139
|
table.cells = [...cellMap.values()].sort((left, right) => left.rowIndex - right.rowIndex || left.columnIndex - right.columnIndex);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
+
export function normalizeSnapshotBlock(value, fallbackOrdinal, blockTextLimit) {
|
|
143
|
+
const rec = asRecord(value) ?? {};
|
|
144
|
+
const fullText = asString(rec.text);
|
|
145
|
+
const text = truncateBlockText(fullText, blockTextLimit);
|
|
146
|
+
const textPreview = typeof rec.textPreview === 'string' ? truncateBlockText(rec.textPreview, blockTextLimit) : null;
|
|
147
|
+
const block = {
|
|
148
|
+
// doc-api block.ordinal is 0-based; the model-facing convention is
|
|
149
|
+
// 1-based (matches paragraphOrdinal/tableOrdinal and ordinal selectors).
|
|
150
|
+
ordinal: asNumber(rec.ordinal, fallbackOrdinal) + 1,
|
|
151
|
+
nodeId: asString(rec.nodeId),
|
|
152
|
+
nodeType: asString(rec.nodeType, 'paragraph'),
|
|
153
|
+
text,
|
|
154
|
+
textPreview,
|
|
155
|
+
styleId: typeof rec.styleId === 'string' ? rec.styleId : null,
|
|
156
|
+
headingLevel: typeof rec.headingLevel === 'number' ? rec.headingLevel : undefined,
|
|
157
|
+
...(asRecord(rec.numbering)
|
|
158
|
+
? {
|
|
159
|
+
numbering: {
|
|
160
|
+
marker: asString(asRecord(rec.numbering).marker) || null,
|
|
161
|
+
path: Array.isArray(asRecord(rec.numbering).path) ? asRecord(rec.numbering).path : null,
|
|
162
|
+
kind: asString(asRecord(rec.numbering).kind) || null,
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
: {}),
|
|
166
|
+
};
|
|
167
|
+
return block;
|
|
168
|
+
}
|
|
142
169
|
/**
|
|
143
170
|
* Build a deterministic snapshot of a document. The snapshot uses only
|
|
144
171
|
* read-mode operations from the generated contract — it never mutates state,
|
|
@@ -257,30 +284,8 @@ export async function buildDocumentSnapshot(doc, options = {}) {
|
|
|
257
284
|
const rawBlocks = Array.isArray(blocksRec?.blocks) ? blocksRec.blocks : [];
|
|
258
285
|
const fullBlockText = new Map();
|
|
259
286
|
const normalizedBlocks = rawBlocks.map((b, index) => {
|
|
260
|
-
const
|
|
261
|
-
const
|
|
262
|
-
const text = truncateBlockText(fullText, blockTextLimit);
|
|
263
|
-
const textPreview = typeof rec.textPreview === 'string' ? truncateBlockText(rec.textPreview, blockTextLimit) : null;
|
|
264
|
-
const block = {
|
|
265
|
-
// doc-api block.ordinal is 0-based; the model-facing convention is
|
|
266
|
-
// 1-based (matches paragraphOrdinal/tableOrdinal and ordinal selectors).
|
|
267
|
-
ordinal: asNumber(rec.ordinal, blockOffset + index) + 1,
|
|
268
|
-
nodeId: asString(rec.nodeId),
|
|
269
|
-
nodeType: asString(rec.nodeType, 'paragraph'),
|
|
270
|
-
text,
|
|
271
|
-
textPreview,
|
|
272
|
-
styleId: typeof rec.styleId === 'string' ? rec.styleId : null,
|
|
273
|
-
headingLevel: typeof rec.headingLevel === 'number' ? rec.headingLevel : undefined,
|
|
274
|
-
...(asRecord(rec.numbering)
|
|
275
|
-
? {
|
|
276
|
-
numbering: {
|
|
277
|
-
marker: asString(asRecord(rec.numbering).marker) || null,
|
|
278
|
-
path: Array.isArray(asRecord(rec.numbering).path) ? asRecord(rec.numbering).path : null,
|
|
279
|
-
kind: asString(asRecord(rec.numbering).kind) || null,
|
|
280
|
-
},
|
|
281
|
-
}
|
|
282
|
-
: {}),
|
|
283
|
-
};
|
|
287
|
+
const fullText = asString(asRecord(b)?.text);
|
|
288
|
+
const block = normalizeSnapshotBlock(b, blockOffset + index, blockTextLimit);
|
|
284
289
|
fullBlockText.set(block, fullText);
|
|
285
290
|
return block;
|
|
286
291
|
});
|
package/dist/agent/runtime.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var textboxSnapshot = require('./textbox-snapshot.cjs');
|
|
3
4
|
var executionContext = require('./execution-context.cjs');
|
|
4
5
|
var contract = require('../generated/contract.cjs');
|
|
5
6
|
var errors = require('../runtime/errors.cjs');
|
|
@@ -162,7 +163,11 @@ async function agentInspect(doc, args = {}) {
|
|
|
162
163
|
const listsInScope = !args.countsOnly &&
|
|
163
164
|
(!Array.isArray(args.includeDomains) || args.includeDomains.length === 0 || args.includeDomains.includes('lists'));
|
|
164
165
|
const effective = args.includeListItemRuns === undefined && listsInScope ? { ...args, includeListItemRuns: true } : args;
|
|
165
|
-
|
|
166
|
+
const snapshot = await docSnapshot.buildDocumentSnapshot(doc, effective);
|
|
167
|
+
const includeTextboxes = !args.countsOnly && (!args.includeDomains?.length || args.includeDomains.includes('blocks'));
|
|
168
|
+
const diagnostics = [...snapshot.diagnostics];
|
|
169
|
+
const textboxes = includeTextboxes ? await textboxSnapshot.readTextboxSnapshots(doc, effective, diagnostics) : [];
|
|
170
|
+
return { ...snapshot, diagnostics, textboxes };
|
|
166
171
|
}
|
|
167
172
|
function checkAgainstSnapshot(snapshot, check) {
|
|
168
173
|
switch (check.kind) {
|
package/dist/agent/runtime.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SnapshotTextbox } from './textbox-snapshot.js';
|
|
1
2
|
import { type EvidencePolicy } from './execution-context.js';
|
|
2
3
|
/**
|
|
3
4
|
* Clean agent runtime.
|
|
@@ -119,7 +120,10 @@ export type AgentReceipt = {
|
|
|
119
120
|
/** Action-specific evidence (editsApplied, marker, placement, …). */
|
|
120
121
|
[key: string]: unknown;
|
|
121
122
|
};
|
|
122
|
-
export
|
|
123
|
+
export type AgentInspectResult = DocumentSnapshot & {
|
|
124
|
+
textboxes: readonly SnapshotTextbox[];
|
|
125
|
+
};
|
|
126
|
+
export declare function agentInspect(doc: BoundDocApi, args?: AgentInspectArgs): Promise<AgentInspectResult>;
|
|
123
127
|
export declare function agentApply(doc: BoundDocApi, args: AgentApplyArgs): Promise<AgentReceipt>;
|
|
124
128
|
export declare function agentVerify(doc: BoundDocApi, args: AgentVerifyArgs): Promise<AgentReceipt>;
|
|
125
129
|
/**
|
package/dist/agent/runtime.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readTextboxSnapshots } from './textbox-snapshot.js';
|
|
1
2
|
import { ExecutionContext, evaluateFactChecks } from './execution-context.js';
|
|
2
3
|
import { CONTRACT } from '../generated/contract.js';
|
|
3
4
|
import { SuperDocCliError } from '../runtime/errors.js';
|
|
@@ -159,7 +160,11 @@ export async function agentInspect(doc, args = {}) {
|
|
|
159
160
|
const listsInScope = !args.countsOnly &&
|
|
160
161
|
(!Array.isArray(args.includeDomains) || args.includeDomains.length === 0 || args.includeDomains.includes('lists'));
|
|
161
162
|
const effective = args.includeListItemRuns === undefined && listsInScope ? { ...args, includeListItemRuns: true } : args;
|
|
162
|
-
|
|
163
|
+
const snapshot = await buildDocumentSnapshot(doc, effective);
|
|
164
|
+
const includeTextboxes = !args.countsOnly && (!args.includeDomains?.length || args.includeDomains.includes('blocks'));
|
|
165
|
+
const diagnostics = [...snapshot.diagnostics];
|
|
166
|
+
const textboxes = includeTextboxes ? await readTextboxSnapshots(doc, effective, diagnostics) : [];
|
|
167
|
+
return { ...snapshot, diagnostics, textboxes };
|
|
163
168
|
}
|
|
164
169
|
function checkAgainstSnapshot(snapshot, check) {
|
|
165
170
|
switch (check.kind) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var docSnapshot = require('./doc-snapshot.cjs');
|
|
4
|
+
|
|
5
|
+
async function readTextboxSnapshots(doc, options, diagnostics) {
|
|
6
|
+
if (typeof doc.query?.match !== 'function' || typeof doc.blocks?.list !== 'function')
|
|
7
|
+
return [];
|
|
8
|
+
const stories = new Map();
|
|
9
|
+
const snapshots = [];
|
|
10
|
+
try {
|
|
11
|
+
// Text discovery includes nested stories; blocks.list remains story-scoped
|
|
12
|
+
// so body ordinals used by existing action selectors cannot shift.
|
|
13
|
+
// Match one character per nonempty line. Cross-paragraph matches are
|
|
14
|
+
// rejected and retried at each character by the engine's regex scanner.
|
|
15
|
+
let offset = 0;
|
|
16
|
+
for (;;) {
|
|
17
|
+
const found = await doc.query.match({
|
|
18
|
+
select: { type: 'text', pattern: '(?<=^|\\n)[^\\n]', mode: 'regex' },
|
|
19
|
+
offset,
|
|
20
|
+
limit: 1000,
|
|
21
|
+
});
|
|
22
|
+
for (const item of found.items) {
|
|
23
|
+
const story = item.address.story;
|
|
24
|
+
if (story?.storyType === 'textbox')
|
|
25
|
+
stories.set(story.textboxId, story);
|
|
26
|
+
}
|
|
27
|
+
offset += found.items.length;
|
|
28
|
+
if (offset >= found.total)
|
|
29
|
+
break;
|
|
30
|
+
if (found.items.length === 0)
|
|
31
|
+
throw new Error('Textbox discovery stopped before the reported match total.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
diagnostics.push({
|
|
36
|
+
section: 'textboxes.discover',
|
|
37
|
+
message: error instanceof Error ? error.message : String(error),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const offset = Math.max(0, options.blockOffset ?? 0);
|
|
41
|
+
const limit = options.blockLimit != null && options.blockLimit > 0 ? options.blockLimit : 1000;
|
|
42
|
+
const textLimit = options.blockTextLimit != null && Number.isFinite(options.blockTextLimit) && options.blockTextLimit > 0
|
|
43
|
+
? options.blockTextLimit
|
|
44
|
+
: null;
|
|
45
|
+
for (const story of stories.values()) {
|
|
46
|
+
try {
|
|
47
|
+
const listed = await doc.blocks.list({ in: story, includeText: true, offset, limit });
|
|
48
|
+
const blocks = listed.blocks
|
|
49
|
+
.filter((block) => !options.omitEmptyBlocks || Boolean(block.text?.trim()))
|
|
50
|
+
.map((block, index) => docSnapshot.normalizeSnapshotBlock(block, offset + index, textLimit))
|
|
51
|
+
.filter((block) => !options.blockNodeTypes?.length || options.blockNodeTypes.includes(block.nodeType))
|
|
52
|
+
.map((block) => (options.dropTextPreview ? { ...block, textPreview: null } : block));
|
|
53
|
+
snapshots.push({ story, total: listed.total, blocks });
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
diagnostics.push({
|
|
57
|
+
section: `textboxes.blocks:${story.textboxId}`,
|
|
58
|
+
message: error instanceof Error ? error.message : String(error),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return snapshots;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.readTextboxSnapshots = readTextboxSnapshots;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BoundDocApi } from '../generated/client.js';
|
|
2
|
+
import { type SnapshotBlock, type SnapshotDiagnostic } from './doc-snapshot.js';
|
|
3
|
+
export type SnapshotTextbox = {
|
|
4
|
+
story: {
|
|
5
|
+
kind: 'story';
|
|
6
|
+
storyType: 'textbox';
|
|
7
|
+
textboxId: string;
|
|
8
|
+
};
|
|
9
|
+
/** Story-local block count; blocks contains the requested window in this story. */
|
|
10
|
+
total: number;
|
|
11
|
+
blocks: readonly SnapshotBlock[];
|
|
12
|
+
};
|
|
13
|
+
type TextboxSnapshotOptions = {
|
|
14
|
+
blockOffset?: number;
|
|
15
|
+
blockLimit?: number;
|
|
16
|
+
blockTextLimit?: number;
|
|
17
|
+
blockNodeTypes?: readonly string[];
|
|
18
|
+
omitEmptyBlocks?: boolean;
|
|
19
|
+
dropTextPreview?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function readTextboxSnapshots(doc: BoundDocApi, options: TextboxSnapshotOptions, diagnostics: SnapshotDiagnostic[]): Promise<SnapshotTextbox[]>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { normalizeSnapshotBlock } from './doc-snapshot.js';
|
|
2
|
+
export async function readTextboxSnapshots(doc, options, diagnostics) {
|
|
3
|
+
if (typeof doc.query?.match !== 'function' || typeof doc.blocks?.list !== 'function')
|
|
4
|
+
return [];
|
|
5
|
+
const stories = new Map();
|
|
6
|
+
const snapshots = [];
|
|
7
|
+
try {
|
|
8
|
+
// Text discovery includes nested stories; blocks.list remains story-scoped
|
|
9
|
+
// so body ordinals used by existing action selectors cannot shift.
|
|
10
|
+
// Match one character per nonempty line. Cross-paragraph matches are
|
|
11
|
+
// rejected and retried at each character by the engine's regex scanner.
|
|
12
|
+
let offset = 0;
|
|
13
|
+
for (;;) {
|
|
14
|
+
const found = await doc.query.match({
|
|
15
|
+
select: { type: 'text', pattern: '(?<=^|\\n)[^\\n]', mode: 'regex' },
|
|
16
|
+
offset,
|
|
17
|
+
limit: 1000,
|
|
18
|
+
});
|
|
19
|
+
for (const item of found.items) {
|
|
20
|
+
const story = item.address.story;
|
|
21
|
+
if (story?.storyType === 'textbox')
|
|
22
|
+
stories.set(story.textboxId, story);
|
|
23
|
+
}
|
|
24
|
+
offset += found.items.length;
|
|
25
|
+
if (offset >= found.total)
|
|
26
|
+
break;
|
|
27
|
+
if (found.items.length === 0)
|
|
28
|
+
throw new Error('Textbox discovery stopped before the reported match total.');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
diagnostics.push({
|
|
33
|
+
section: 'textboxes.discover',
|
|
34
|
+
message: error instanceof Error ? error.message : String(error),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const offset = Math.max(0, options.blockOffset ?? 0);
|
|
38
|
+
const limit = options.blockLimit != null && options.blockLimit > 0 ? options.blockLimit : 1000;
|
|
39
|
+
const textLimit = options.blockTextLimit != null && Number.isFinite(options.blockTextLimit) && options.blockTextLimit > 0
|
|
40
|
+
? options.blockTextLimit
|
|
41
|
+
: null;
|
|
42
|
+
for (const story of stories.values()) {
|
|
43
|
+
try {
|
|
44
|
+
const listed = await doc.blocks.list({ in: story, includeText: true, offset, limit });
|
|
45
|
+
const blocks = listed.blocks
|
|
46
|
+
.filter((block) => !options.omitEmptyBlocks || Boolean(block.text?.trim()))
|
|
47
|
+
.map((block, index) => normalizeSnapshotBlock(block, offset + index, textLimit))
|
|
48
|
+
.filter((block) => !options.blockNodeTypes?.length || options.blockNodeTypes.includes(block.nodeType))
|
|
49
|
+
.map((block) => (options.dropTextPreview ? { ...block, textPreview: null } : block));
|
|
50
|
+
snapshots.push({ story, total: listed.total, blocks });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
diagnostics.push({
|
|
54
|
+
section: `textboxes.blocks:${story.textboxId}`,
|
|
55
|
+
message: error instanceof Error ? error.message : String(error),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return snapshots;
|
|
60
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export { dispatchIntentTool } from './generated/intent-dispatch.generated.js';
|
|
|
94
94
|
export { wrapV2PresetCompat } from './agent/v2-preset-compat.js';
|
|
95
95
|
export type { BoundDocApi } from './generated/client.js';
|
|
96
96
|
export type { ActionName } from './agent/actions.js';
|
|
97
|
-
export type { AgentReceipt, AgentApplyArgs, AgentVerifyArgs } from './agent/runtime.js';
|
|
97
|
+
export type { AgentReceipt, AgentApplyArgs, AgentVerifyArgs, AgentInspectResult } from './agent/runtime.js';
|
|
98
98
|
export type { GetSystemPromptOptions, GetToolsOptions, GetToolsResult, PresetDescriptor } from './presets.js';
|
|
99
99
|
export { createAgentToolkit } from './tools.js';
|
|
100
100
|
export type { AgentToolkit, CreateAgentToolkitInput } from './tools.js';
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
// AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
|
|
4
4
|
// Source of truth: package.json. Regenerated on every SDK build so the
|
|
5
5
|
// SDK retains its own version identity when bundled into another package.
|
|
6
|
-
const SDK_VERSION = '2.12.0-next.
|
|
6
|
+
const SDK_VERSION = '2.12.0-next.5';
|
|
7
7
|
|
|
8
8
|
exports.SDK_VERSION = SDK_VERSION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.12.0-next.
|
|
1
|
+
export declare const SDK_VERSION = "2.12.0-next.5";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
|
|
2
2
|
// Source of truth: package.json. Regenerated on every SDK build so the
|
|
3
3
|
// SDK retains its own version identity when bundled into another package.
|
|
4
|
-
export const SDK_VERSION = '2.12.0-next.
|
|
4
|
+
export const SDK_VERSION = '2.12.0-next.5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/sdk",
|
|
3
|
-
"version": "2.12.0-next.
|
|
3
|
+
"version": "2.12.0-next.5",
|
|
4
4
|
"description": "Node SDK for SuperDoc, wrapping the SuperDoc CLI to read and edit .docx files from JavaScript and TypeScript.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"typescript": "^5.9.2"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@superdoc/sdk-darwin-arm64": "2.12.0-next.
|
|
42
|
-
"@superdoc/sdk-darwin-x64": "2.12.0-next.
|
|
43
|
-
"@superdoc/sdk-linux-x64": "2.12.0-next.
|
|
44
|
-
"@superdoc/sdk-linux-arm64": "2.12.0-next.
|
|
45
|
-
"@superdoc/sdk-windows-x64": "2.12.0-next.
|
|
41
|
+
"@superdoc/sdk-darwin-arm64": "2.12.0-next.5",
|
|
42
|
+
"@superdoc/sdk-darwin-x64": "2.12.0-next.5",
|
|
43
|
+
"@superdoc/sdk-linux-x64": "2.12.0-next.5",
|
|
44
|
+
"@superdoc/sdk-linux-arm64": "2.12.0-next.5",
|
|
45
|
+
"@superdoc/sdk-windows-x64": "2.12.0-next.5"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"build": "rm -rf dist && node scripts/embed-version.mjs && node scripts/embed-prompts.mjs && node scripts/embed-tools.mjs && tsc && pnpm run typecheck:consumer && rollup -c rollup.cjs.config.mjs && rm -rf dist/prompts && mkdir -p dist/prompts && cp src/prompts/*.md dist/prompts/ && pnpm run audit:publish",
|
|
52
52
|
"audit:publish": "node ../../../../scripts/audit-publish-artifact.mjs dist --label sdk-node-dist",
|
|
53
53
|
"typecheck": "tsc --noEmit",
|
|
54
|
-
"typecheck:consumer": "tsc --noEmit --strict --skipLibCheck --target ES2022 --module NodeNext --moduleResolution NodeNext ../../../../tests/consumer-typecheck/src/sdk-per-open-collaboration-auth.mts ../../../../tests/consumer-typecheck/src/sdk-replace-file.mts ../../../../tests/consumer-typecheck/src/sdk-agent-evidence.mts ../../../../tests/consumer-typecheck/src/sdk-custom-actions.mts",
|
|
55
|
-
"test:agent-actions": "bun test src/__tests__/actions.test.ts src/__tests__/agent-runtime.test.ts src/__tests__/custom-actions.test.ts",
|
|
54
|
+
"typecheck:consumer": "tsc --noEmit --strict --skipLibCheck --target ES2022 --module NodeNext --moduleResolution NodeNext ../../../../tests/consumer-typecheck/src/sdk-per-open-collaboration-auth.mts ../../../../tests/consumer-typecheck/src/sdk-replace-file.mts ../../../../tests/consumer-typecheck/src/sdk-agent-evidence.mts ../../../../tests/consumer-typecheck/src/sdk-custom-actions.mts ../../../../tests/consumer-typecheck/src/sd4807-sdk-inspect.mts",
|
|
55
|
+
"test:agent-actions": "bun test src/__tests__/actions.test.ts src/__tests__/agent-runtime.test.ts src/__tests__/custom-actions.test.ts src/__tests__/textbox-snapshot.test.ts",
|
|
56
56
|
"test:document-host": "bun test src/runtime/__tests__/host-spawn-args.test.ts src/runtime/__tests__/document-rpc.test.ts src/__tests__/structured-document-rpc.e2e.test.ts src/__tests__/request-timeout-ms.e2e.test.ts src/__tests__/agent-evidence.e2e.test.ts src/__tests__/agent-apply.e2e.test.ts src/__tests__/find-text.e2e.test.ts src/__tests__/custom-actions.e2e.test.ts",
|
|
57
57
|
"smoke:product-action": "node scripts/product-action-smoke.mjs"
|
|
58
58
|
}
|