@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.
- package/README.md +45 -0
- package/dist/action-primitives/doc-index.cjs +6 -4
- package/dist/action-primitives/doc-index.js +6 -4
- package/dist/action-primitives/engine.cjs +6 -2
- package/dist/action-primitives/engine.js +6 -2
- package/dist/action-primitives/receipt.d.ts +4 -0
- package/dist/action-primitives/tools/structure-insert.d.ts +1 -1
- package/dist/agent/actions.cjs +384 -373
- package/dist/agent/actions.d.ts +5 -0
- package/dist/agent/actions.js +385 -374
- package/dist/agent/catalog.cjs +15 -0
- package/dist/agent/catalog.js +15 -0
- package/dist/agent/doc-snapshot.cjs +205 -86
- package/dist/agent/doc-snapshot.d.ts +11 -0
- package/dist/agent/doc-snapshot.js +203 -86
- package/dist/agent/execution-context.cjs +385 -0
- package/dist/agent/execution-context.d.ts +97 -0
- package/dist/agent/execution-context.js +376 -0
- package/dist/agent/runtime.cjs +123 -117
- package/dist/agent/runtime.d.ts +3 -0
- package/dist/agent/runtime.js +124 -118
- package/dist/agent/v2-preset-compat.cjs +5 -1
- package/dist/agent/v2-preset-compat.js +4 -1
- package/dist/embedded-tools.generated.cjs +5 -5
- package/dist/embedded-tools.generated.js +5 -5
- package/dist/generated/client.cjs +2 -0
- package/dist/generated/client.d.ts +85 -0
- package/dist/generated/client.js +2 -0
- package/dist/generated/contract.cjs +1796 -1297
- package/dist/generated/contract.js +1797 -1297
- package/dist/index.cjs +23 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +23 -0
- package/dist/presets/core.cjs +1 -1
- package/dist/presets/core.js +1 -1
- package/dist/runtime/document-evidence.cjs +40 -0
- package/dist/runtime/document-evidence.d.ts +13 -0
- package/dist/runtime/document-evidence.js +30 -0
- package/dist/runtime/document-rpc.cjs +27 -0
- package/dist/runtime/document-rpc.d.ts +2 -0
- package/dist/runtime/document-rpc.js +25 -0
- package/dist/runtime/host.cjs +65 -4
- package/dist/runtime/host.d.ts +3 -0
- package/dist/runtime/host.js +66 -5
- package/dist/runtime/process.cjs +38 -0
- package/dist/runtime/process.d.ts +16 -0
- package/dist/runtime/process.js +38 -0
- 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 +10 -8
- package/tools/catalog.json +89 -0
- package/tools/tools-policy.json +1 -1
- package/tools/tools.anthropic.json +89 -0
- package/tools/tools.generic.json +89 -0
- package/tools/tools.openai.json +89 -0
- package/tools/tools.vercel.json +89 -0
package/README.md
CHANGED
|
@@ -48,6 +48,51 @@ is not supported for Liveblocks or the standalone document host.
|
|
|
48
48
|
|
|
49
49
|
See the [Node.js SDK guide](https://docs.superdoc.dev/agents/automation/node-sdk) for a complete workflow.
|
|
50
50
|
|
|
51
|
+
## Agent execution evidence
|
|
52
|
+
|
|
53
|
+
The core preset's `agent_apply`, `agent_verify`, and supported named actions
|
|
54
|
+
collect the facts their targets and checks need. Supported document-host sessions
|
|
55
|
+
can read body block identities and text, table shape, exact requested block
|
|
56
|
+
counts, and document revisions without collecting complete snapshots. The named
|
|
57
|
+
paths cover table creation and cell styling, body paragraph formatting and
|
|
58
|
+
rewriting, and paragraph insertion around a selected anchor.
|
|
59
|
+
|
|
60
|
+
The shared execution paths on supported hosts guard edits with document revisions.
|
|
61
|
+
An intervening edit can stop a later step; a failed action may therefore include operations that already committed.
|
|
62
|
+
|
|
63
|
+
This changes default receipts for eligible plans: `preSnapshot.counts` and
|
|
64
|
+
`postSnapshot.counts` are absent, not zero. Callers that previously consumed these
|
|
65
|
+
counts should request `evidence: 'full'`:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { dispatchSuperDocTool } from '@superdoc/sdk';
|
|
69
|
+
|
|
70
|
+
const receipt = await dispatchSuperDocTool(document, 'agent_apply', {
|
|
71
|
+
evidence: 'full',
|
|
72
|
+
plan: {
|
|
73
|
+
intent: 'Append a paragraph with complete count evidence',
|
|
74
|
+
steps: [
|
|
75
|
+
{ kind: 'apply', operationId: 'doc.create.paragraph', args: { text: 'Approved.' } },
|
|
76
|
+
{ kind: 'verify', checks: [{ kind: 'revision-changed' }] },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
}, { preset: 'core' });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`evidence: 'required'` is the default. Requested block-count checks remain exact
|
|
83
|
+
without adding unrequested receipt summaries. `evidence: 'full'` is also available
|
|
84
|
+
on `agent_verify` and the named `create_table`, `format_paragraph`, `rewrite_block`,
|
|
85
|
+
and `insert_paragraphs` actions.
|
|
86
|
+
|
|
87
|
+
Unsupported selectors and checks, inspection dependencies, multiple-operation
|
|
88
|
+
plans, atomic plans, and save verification retain complete evidence. Older hosts
|
|
89
|
+
with compact revision support retain the single-paragraph, revision-only path;
|
|
90
|
+
other unsupported hosts and plain bound API handles use complete snapshots.
|
|
91
|
+
|
|
92
|
+
A failed receipt can disclose a committed mutation when post-edit verification
|
|
93
|
+
fails. Inspect `executedOperations` and the reported error before retrying; do not
|
|
94
|
+
automatically replay the write.
|
|
95
|
+
|
|
51
96
|
## License
|
|
52
97
|
|
|
53
98
|
AGPL-3.0. Commercial licenses are available from [SuperDoc](https://www.superdoc.dev).
|
|
@@ -26,9 +26,10 @@ async function listAllBlocks(documentHandle, invokeOptions, pageLimit) {
|
|
|
26
26
|
const page = await documentHandle.blocks.list({ offset, limit: pageLimit, includeText: false }, invokeOptions);
|
|
27
27
|
blocks.push(...page.blocks);
|
|
28
28
|
offset += page.blocks.length;
|
|
29
|
-
if (
|
|
29
|
+
if (offset >= page.total)
|
|
30
30
|
break;
|
|
31
|
-
|
|
31
|
+
if (page.blocks.length === 0)
|
|
32
|
+
throw new Error('Required complete block index stopped before the reported total.');
|
|
32
33
|
}
|
|
33
34
|
return blocks;
|
|
34
35
|
}
|
|
@@ -39,9 +40,10 @@ async function listAllListItems(documentHandle, invokeOptions, pageLimit) {
|
|
|
39
40
|
const page = await documentHandle.lists.list({ offset, limit: pageLimit }, invokeOptions);
|
|
40
41
|
items.push(...page.items);
|
|
41
42
|
offset += page.items.length;
|
|
42
|
-
if (
|
|
43
|
+
if (offset >= page.total)
|
|
43
44
|
break;
|
|
44
|
-
|
|
45
|
+
if (page.items.length === 0)
|
|
46
|
+
throw new Error('Required complete list index stopped before the reported total.');
|
|
45
47
|
}
|
|
46
48
|
return items;
|
|
47
49
|
}
|
|
@@ -24,9 +24,10 @@ async function listAllBlocks(documentHandle, invokeOptions, pageLimit) {
|
|
|
24
24
|
const page = await documentHandle.blocks.list({ offset, limit: pageLimit, includeText: false }, invokeOptions);
|
|
25
25
|
blocks.push(...page.blocks);
|
|
26
26
|
offset += page.blocks.length;
|
|
27
|
-
if (
|
|
27
|
+
if (offset >= page.total)
|
|
28
28
|
break;
|
|
29
|
-
|
|
29
|
+
if (page.blocks.length === 0)
|
|
30
|
+
throw new Error('Required complete block index stopped before the reported total.');
|
|
30
31
|
}
|
|
31
32
|
return blocks;
|
|
32
33
|
}
|
|
@@ -37,9 +38,10 @@ async function listAllListItems(documentHandle, invokeOptions, pageLimit) {
|
|
|
37
38
|
const page = await documentHandle.lists.list({ offset, limit: pageLimit }, invokeOptions);
|
|
38
39
|
items.push(...page.items);
|
|
39
40
|
offset += page.items.length;
|
|
40
|
-
if (
|
|
41
|
+
if (offset >= page.total)
|
|
41
42
|
break;
|
|
42
|
-
|
|
43
|
+
if (page.items.length === 0)
|
|
44
|
+
throw new Error('Required complete list index stopped before the reported total.');
|
|
43
45
|
}
|
|
44
46
|
return items;
|
|
45
47
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var executionContext = require('../agent/execution-context.cjs');
|
|
3
4
|
var docIndex = require('./doc-index.cjs');
|
|
4
5
|
var receipt = require('./receipt.cjs');
|
|
5
6
|
var sessionCache = require('./session-cache.cjs');
|
|
@@ -22,6 +23,7 @@ function workflowNotImplementedFailure(input) {
|
|
|
22
23
|
function toIndexSummary(index) {
|
|
23
24
|
return {
|
|
24
25
|
revision: index.revision,
|
|
26
|
+
evidence: { coverage: 'complete', reason: 'action primitives require complete block/list/table indexes' },
|
|
25
27
|
blocks: index.blocks.length,
|
|
26
28
|
lists: index.lists.length,
|
|
27
29
|
tables: index.tables.length,
|
|
@@ -40,12 +42,14 @@ async function ensureDocIndex(input) {
|
|
|
40
42
|
if (cached != null) {
|
|
41
43
|
return { sessionState, info, index: cached };
|
|
42
44
|
}
|
|
43
|
-
const
|
|
45
|
+
const facts = new executionContext.DocumentFacts(input.documentHandle, info.revision);
|
|
46
|
+
const acquired = await facts.completeIndex('action primitives require complete block/list/table indexes', () => docIndex.buildWorkflowDocIndex({
|
|
44
47
|
documentHandle: input.documentHandle,
|
|
45
48
|
documentKey: sessionState.documentKey,
|
|
46
49
|
invokeOptions: input.invokeOptions,
|
|
47
50
|
info,
|
|
48
|
-
});
|
|
51
|
+
}));
|
|
52
|
+
const index = acquired.value;
|
|
49
53
|
input.cache.setCachedIndex(input.documentHandle, index);
|
|
50
54
|
return { sessionState, info, index };
|
|
51
55
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DocumentFacts } from '../agent/execution-context.js';
|
|
1
2
|
import { buildWorkflowDocIndex } from './doc-index.js';
|
|
2
3
|
import { createWorkflowFailureReceipt, createWorkflowNotImplementedReceipt, createWorkflowSuccessReceipt, } from './receipt.js';
|
|
3
4
|
import { workflowPocSessionCache } from './session-cache.js';
|
|
@@ -19,6 +20,7 @@ export function workflowNotImplementedFailure(input) {
|
|
|
19
20
|
function toIndexSummary(index) {
|
|
20
21
|
return {
|
|
21
22
|
revision: index.revision,
|
|
23
|
+
evidence: { coverage: 'complete', reason: 'action primitives require complete block/list/table indexes' },
|
|
22
24
|
blocks: index.blocks.length,
|
|
23
25
|
lists: index.lists.length,
|
|
24
26
|
tables: index.tables.length,
|
|
@@ -37,12 +39,14 @@ async function ensureDocIndex(input) {
|
|
|
37
39
|
if (cached != null) {
|
|
38
40
|
return { sessionState, info, index: cached };
|
|
39
41
|
}
|
|
40
|
-
const
|
|
42
|
+
const facts = new DocumentFacts(input.documentHandle, info.revision);
|
|
43
|
+
const acquired = await facts.completeIndex('action primitives require complete block/list/table indexes', () => buildWorkflowDocIndex({
|
|
41
44
|
documentHandle: input.documentHandle,
|
|
42
45
|
documentKey: sessionState.documentKey,
|
|
43
46
|
invokeOptions: input.invokeOptions,
|
|
44
47
|
info,
|
|
45
|
-
});
|
|
48
|
+
}));
|
|
49
|
+
const index = acquired.value;
|
|
46
50
|
input.cache.setCachedIndex(input.documentHandle, index);
|
|
47
51
|
return { sessionState, info, index };
|
|
48
52
|
}
|
|
@@ -3,6 +3,10 @@ export declare const WORKFLOW_POC_PROFILE: "workflow-poc";
|
|
|
3
3
|
export type WorkflowExecutionPhase = 'resolve' | 'plan' | 'execute' | 'verify';
|
|
4
4
|
export type WorkflowReceiptStatus = 'success' | 'failed' | 'not_implemented';
|
|
5
5
|
export type WorkflowIndexSummary = {
|
|
6
|
+
evidence?: {
|
|
7
|
+
coverage: 'complete';
|
|
8
|
+
reason: string;
|
|
9
|
+
};
|
|
6
10
|
revision: string;
|
|
7
11
|
blocks: number;
|
|
8
12
|
lists: number;
|
|
@@ -165,7 +165,7 @@ export type RunSuperdocStructureInsertInput = {
|
|
|
165
165
|
};
|
|
166
166
|
declare function summarizePlacement(placement: SuperdocStructureInsertPlacement): {
|
|
167
167
|
mode: "document";
|
|
168
|
-
at: "
|
|
168
|
+
at: "document_start" | "document_end";
|
|
169
169
|
source: "default" | "provided";
|
|
170
170
|
position?: undefined;
|
|
171
171
|
targetNodeId?: undefined;
|