@superdoc/sdk 2.10.0-next.5 → 2.10.0-next.7
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/dist/agent/actions.cjs +135 -57
- package/dist/agent/actions.js +136 -58
- package/dist/agent/doc-snapshot.cjs +183 -40
- package/dist/agent/doc-snapshot.d.ts +11 -0
- package/dist/agent/doc-snapshot.js +181 -40
- package/dist/agent/runtime.cjs +54 -6
- package/dist/agent/runtime.js +55 -7
- 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 +7 -6
package/dist/agent/runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CONTRACT } from '../generated/contract.js';
|
|
2
2
|
import { SuperDocCliError } from '../runtime/errors.js';
|
|
3
3
|
import { validatePlan } from './ir.js';
|
|
4
|
-
import { buildDocumentSnapshot, resolveSnapshotSelector, AmbiguousSelectorError, } from './doc-snapshot.js';
|
|
4
|
+
import { buildDocumentSnapshot, buildMutationSnapshot, resolveSnapshotSelector, AmbiguousSelectorError, MutationSnapshotError, } from './doc-snapshot.js';
|
|
5
5
|
import { getOperationCatalogEntry } from './operation-catalog.js';
|
|
6
6
|
const RESERVED_ARG_KEYS = new Set(['sessionId', 'doc']);
|
|
7
7
|
function ensureKnownOperation(operationId) {
|
|
@@ -224,8 +224,8 @@ function computeDeltaChecks(pre, post, checks, saveReopen) {
|
|
|
224
224
|
else if (check.kind === 'comment-count-delta') {
|
|
225
225
|
results.push({
|
|
226
226
|
check,
|
|
227
|
-
passed: post.comments
|
|
228
|
-
detail: `pre=${pre.comments
|
|
227
|
+
passed: post.counts.comments - pre.counts.comments === check.delta,
|
|
228
|
+
detail: `pre=${pre.counts.comments} post=${post.counts.comments}`,
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
else if (check.kind === 'tracked-change-count-delta') {
|
|
@@ -310,7 +310,7 @@ async function trySaveReopen(doc, checks) {
|
|
|
310
310
|
await saveAny.call(doc, {});
|
|
311
311
|
// Rebuild a fresh snapshot after save. Host-level true reopen still needs
|
|
312
312
|
// a new document handle, which this runtime cannot force on its own.
|
|
313
|
-
const fresh = await
|
|
313
|
+
const fresh = await buildMutationSnapshot(doc);
|
|
314
314
|
for (const check of checks) {
|
|
315
315
|
if (check.kind === 'save-reopen-text-contains') {
|
|
316
316
|
const found = fresh.blocks.some((b) => b.text.includes(check.text));
|
|
@@ -347,7 +347,23 @@ export async function agentApply(doc, args) {
|
|
|
347
347
|
errors: validation.errors.map((e) => ({ code: e.code, message: e.message })),
|
|
348
348
|
};
|
|
349
349
|
}
|
|
350
|
-
|
|
350
|
+
let preSnapshot;
|
|
351
|
+
try {
|
|
352
|
+
preSnapshot = await buildMutationSnapshot(doc);
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
if (!(error instanceof MutationSnapshotError))
|
|
356
|
+
throw error;
|
|
357
|
+
return {
|
|
358
|
+
status: 'failed',
|
|
359
|
+
intent: plan.intent,
|
|
360
|
+
preSnapshot: { revision: 'unknown', counts: emptyCounts() },
|
|
361
|
+
selectedTargets: [],
|
|
362
|
+
executedOperations: [],
|
|
363
|
+
verification: [],
|
|
364
|
+
errors: [{ code: error.code, message: error.message, recovery: { kind: 'retry' } }],
|
|
365
|
+
};
|
|
366
|
+
}
|
|
351
367
|
const selectedTargets = [];
|
|
352
368
|
const executedOperations = [];
|
|
353
369
|
const bindings = new Map();
|
|
@@ -412,7 +428,23 @@ export async function agentApply(doc, args) {
|
|
|
412
428
|
errors: [{ code: 'APPLY_FAILED', message }],
|
|
413
429
|
};
|
|
414
430
|
}
|
|
415
|
-
|
|
431
|
+
let postSnapshot;
|
|
432
|
+
try {
|
|
433
|
+
postSnapshot = await buildMutationSnapshot(doc);
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
if (!(error instanceof MutationSnapshotError))
|
|
437
|
+
throw error;
|
|
438
|
+
return {
|
|
439
|
+
status: 'failed',
|
|
440
|
+
intent: plan.intent,
|
|
441
|
+
preSnapshot: { revision: preSnapshot.revision, counts: preSnapshot.counts },
|
|
442
|
+
selectedTargets,
|
|
443
|
+
executedOperations,
|
|
444
|
+
verification: [],
|
|
445
|
+
errors: [{ code: error.code, message: error.message, recovery: { kind: 'reinspect' } }],
|
|
446
|
+
};
|
|
447
|
+
}
|
|
416
448
|
const verifyStep = plan.steps.find((s) => s.kind === 'verify');
|
|
417
449
|
let saveReopen;
|
|
418
450
|
const shouldSaveReopen = (verifyStep?.kind === 'verify' && (verifyStep.saveReopen || verificationNeedsSaveReopen(verifyStep.checks))) ||
|
|
@@ -434,7 +466,23 @@ export async function agentApply(doc, args) {
|
|
|
434
466
|
};
|
|
435
467
|
}
|
|
436
468
|
export async function agentVerify(doc, args) {
|
|
437
|
-
|
|
469
|
+
let snapshot;
|
|
470
|
+
try {
|
|
471
|
+
snapshot = await buildMutationSnapshot(doc);
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
if (!(error instanceof MutationSnapshotError))
|
|
475
|
+
throw error;
|
|
476
|
+
return {
|
|
477
|
+
status: 'failed',
|
|
478
|
+
intent: 'verify',
|
|
479
|
+
preSnapshot: { revision: 'unknown', counts: emptyCounts() },
|
|
480
|
+
selectedTargets: [],
|
|
481
|
+
executedOperations: [],
|
|
482
|
+
verification: [],
|
|
483
|
+
errors: [{ code: error.code, message: error.message, recovery: { kind: 'retry' } }],
|
|
484
|
+
};
|
|
485
|
+
}
|
|
438
486
|
let saveReopen;
|
|
439
487
|
if (args.saveReopen || verificationNeedsSaveReopen(args.checks)) {
|
|
440
488
|
saveReopen = await trySaveReopen(doc, args.checks);
|
|
@@ -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.10.0-next.
|
|
6
|
+
const SDK_VERSION = '2.10.0-next.7';
|
|
7
7
|
|
|
8
8
|
exports.SDK_VERSION = SDK_VERSION;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.10.0-next.
|
|
1
|
+
export declare const SDK_VERSION = "2.10.0-next.7";
|
|
@@ -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.10.0-next.
|
|
4
|
+
export const SDK_VERSION = '2.10.0-next.7';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/sdk",
|
|
3
|
-
"version": "2.10.0-next.
|
|
3
|
+
"version": "2.10.0-next.7",
|
|
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",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"typescript": "^5.9.2"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@superdoc/sdk-darwin-arm64": "2.10.0-next.
|
|
41
|
-
"@superdoc/sdk-darwin-x64": "2.10.0-next.
|
|
42
|
-
"@superdoc/sdk-linux-x64": "2.10.0-next.
|
|
43
|
-
"@superdoc/sdk-linux-arm64": "2.10.0-next.
|
|
44
|
-
"@superdoc/sdk-windows-x64": "2.10.0-next.
|
|
40
|
+
"@superdoc/sdk-darwin-arm64": "2.10.0-next.7",
|
|
41
|
+
"@superdoc/sdk-darwin-x64": "2.10.0-next.7",
|
|
42
|
+
"@superdoc/sdk-linux-x64": "2.10.0-next.7",
|
|
43
|
+
"@superdoc/sdk-linux-arm64": "2.10.0-next.7",
|
|
44
|
+
"@superdoc/sdk-windows-x64": "2.10.0-next.7"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"audit:publish": "node ../../../../scripts/audit-publish-artifact.mjs dist --label sdk-node-dist",
|
|
52
52
|
"typecheck": "tsc --noEmit",
|
|
53
53
|
"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",
|
|
54
|
+
"test:agent-actions": "bun test src/__tests__/actions.test.ts",
|
|
54
55
|
"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",
|
|
55
56
|
"smoke:product-action": "node scripts/product-action-smoke.mjs"
|
|
56
57
|
}
|