@superdoc-dev/sdk 1.0.0-next.72 → 1.0.0-next.74
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 +50 -35
- package/dist/generated/client.cjs +734 -6
- package/dist/generated/client.d.ts +20380 -2887
- package/dist/generated/client.d.ts.map +1 -1
- package/dist/generated/client.js +733 -6
- package/dist/generated/contract.cjs +115396 -33890
- package/dist/generated/contract.d.ts +30 -46113
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +115396 -33890
- package/dist/generated/intent-dispatch.generated.cjs +94 -0
- package/dist/generated/intent-dispatch.generated.d.ts +2 -0
- package/dist/generated/intent-dispatch.generated.d.ts.map +1 -0
- package/dist/generated/intent-dispatch.generated.js +90 -0
- package/dist/helpers/format.d.ts +6 -8
- package/dist/helpers/format.d.ts.map +1 -1
- package/dist/helpers/format.js +5 -8
- package/dist/index.cjs +133 -10
- package/dist/index.d.ts +76 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +132 -9
- package/dist/runtime/process.d.ts +2 -2
- package/dist/runtime/process.d.ts.map +1 -1
- package/dist/runtime/transport-common.cjs +10 -0
- package/dist/runtime/transport-common.d.ts +7 -0
- package/dist/runtime/transport-common.d.ts.map +1 -1
- package/dist/runtime/transport-common.js +10 -0
- package/dist/tools.cjs +148 -286
- package/dist/tools.d.ts +37 -93
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +147 -284
- package/package.json +7 -6
- package/tools/__pycache__/__init__.cpython-312.pyc +0 -0
- package/tools/__pycache__/intent_dispatch_generated.cpython-312.pyc +0 -0
- package/tools/catalog.json +4288 -66383
- package/tools/intent_dispatch_generated.py +122 -0
- package/tools/system-prompt.md +113 -0
- package/tools/tools-policy.json +37 -94
- package/tools/tools.anthropic.json +4290 -27847
- package/tools/tools.generic.json +4357 -64146
- package/tools/tools.openai.json +4309 -28991
- package/tools/tools.vercel.json +4309 -28991
- package/tools/tool-name-map.json +0 -386
package/README.md
CHANGED
|
@@ -36,20 +36,26 @@ import { createSuperDocClient } from '@superdoc-dev/sdk';
|
|
|
36
36
|
const client = createSuperDocClient();
|
|
37
37
|
await client.connect();
|
|
38
38
|
|
|
39
|
-
await client.
|
|
39
|
+
const doc = await client.open({ doc: './contract.docx' });
|
|
40
40
|
|
|
41
|
-
const info = await
|
|
41
|
+
const info = await doc.info();
|
|
42
42
|
console.log(info.counts);
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
target: results.items[0].context.textRanges[0],
|
|
48
|
-
text: 'expiration',
|
|
44
|
+
const match = await doc.query.match({
|
|
45
|
+
select: { type: 'text', pattern: 'termination' },
|
|
46
|
+
require: 'first',
|
|
49
47
|
});
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const target = match.items?.[0]?.target;
|
|
50
|
+
if (target) {
|
|
51
|
+
await doc.replace({
|
|
52
|
+
target,
|
|
53
|
+
text: 'expiration',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await doc.save({ inPlace: true });
|
|
58
|
+
await doc.close();
|
|
53
59
|
await client.dispose();
|
|
54
60
|
```
|
|
55
61
|
|
|
@@ -65,57 +71,66 @@ await client.connect(); // start the host process
|
|
|
65
71
|
await client.dispose(); // shut down gracefully
|
|
66
72
|
```
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
Open documents from the client, then operate on the returned handle:
|
|
69
75
|
|
|
70
76
|
```ts
|
|
71
|
-
client.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
const doc = await client.open(params)
|
|
78
|
+
await doc.find(params)
|
|
79
|
+
await doc.insert(params)
|
|
80
|
+
await doc.save(params)
|
|
81
|
+
await doc.close(params)
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
### Operations
|
|
78
85
|
|
|
79
86
|
| Category | Operations |
|
|
80
87
|
|----------|-----------|
|
|
81
|
-
| **Query** | `find`, `getNode`, `getNodeById`, `info` |
|
|
88
|
+
| **Query** | `find`, `query.match`, `getNode`, `getNodeById`, `info` |
|
|
82
89
|
| **Mutation** | `insert`, `replace`, `delete` |
|
|
83
|
-
| **Format** | `format.bold`, `format.italic`, `format.underline`, `format.
|
|
90
|
+
| **Format** | `format.bold`, `format.italic`, `format.underline`, `format.strike` |
|
|
84
91
|
| **Create** | `create.paragraph` |
|
|
85
92
|
| **Lists** | `lists.list`, `lists.get`, `lists.insert`, `lists.create`, `lists.attach`, `lists.detach`, `lists.indent`, `lists.outdent`, `lists.join`, `lists.separate`, `lists.setLevel`, `lists.setValue`, `lists.continuePrevious`, `lists.setLevelRestart`, `lists.convertToText`, `lists.canJoin`, `lists.canContinuePrevious` |
|
|
86
93
|
| **Comments** | `comments.create`, `comments.patch`, `comments.delete`, `comments.get`, `comments.list` |
|
|
87
94
|
| **Track Changes** | `trackChanges.list`, `trackChanges.get`, `trackChanges.decide` |
|
|
88
|
-
| **Lifecycle** | `open`, `save`, `close` |
|
|
89
|
-
| **
|
|
90
|
-
| **Introspection** | `status`, `describe`, `describeCommand` |
|
|
95
|
+
| **Lifecycle** | `client.open`, `doc.save`, `doc.close` |
|
|
96
|
+
| **Client** | `client.describe`, `client.describeCommand` |
|
|
91
97
|
|
|
92
98
|
### AI Tool Integration
|
|
93
99
|
|
|
94
|
-
The SDK includes built-in support for exposing
|
|
100
|
+
The SDK includes built-in support for exposing grouped intent tools as AI tool definitions:
|
|
95
101
|
|
|
96
102
|
```ts
|
|
97
|
-
import {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
import {
|
|
104
|
+
chooseTools,
|
|
105
|
+
dispatchSuperDocTool,
|
|
106
|
+
getToolCatalog,
|
|
107
|
+
} from '@superdoc-dev/sdk';
|
|
108
|
+
|
|
109
|
+
// Get the full grouped tool set for your AI provider
|
|
110
|
+
const { tools, meta } = await chooseTools({
|
|
111
|
+
provider: 'openai', // 'openai' | 'anthropic' | 'vercel' | 'generic'
|
|
105
112
|
});
|
|
106
113
|
|
|
114
|
+
// Optional: inspect the generated tool catalog
|
|
115
|
+
const catalog = await getToolCatalog();
|
|
116
|
+
|
|
107
117
|
// Dispatch a tool call from the AI model
|
|
108
|
-
const
|
|
118
|
+
const doc = await client.open({ doc: './contract.docx' });
|
|
119
|
+
const result = await dispatchSuperDocTool(doc, toolName, args);
|
|
109
120
|
```
|
|
110
121
|
|
|
122
|
+
The current catalog contains 9 grouped tools:
|
|
123
|
+
`superdoc_get_content`, `superdoc_edit`, `superdoc_format`, `superdoc_create`, `superdoc_list`, `superdoc_comment`, `superdoc_track_changes`, `superdoc_search`, and `superdoc_mutations`.
|
|
124
|
+
|
|
125
|
+
Multi-action tools use an `action` field to select the underlying operation. Single-action tools like `superdoc_search` do not require `action`.
|
|
126
|
+
|
|
111
127
|
| Function | Description |
|
|
112
128
|
|----------|-------------|
|
|
113
|
-
| `chooseTools(input)` |
|
|
114
|
-
| `listTools(provider
|
|
115
|
-
| `dispatchSuperDocTool(
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `inferDocumentFeatures(infoResult)` | Derive feature flags from `doc.info` output |
|
|
129
|
+
| `chooseTools(input)` | Load grouped tool definitions for a provider |
|
|
130
|
+
| `listTools(provider)` | List all tool definitions for a provider |
|
|
131
|
+
| `dispatchSuperDocTool(doc, toolName, args)` | Execute a tool call against a bound document handle |
|
|
132
|
+
| `getToolCatalog()` | Load the grouped tool catalog with metadata |
|
|
133
|
+
| `getSystemPrompt()` | Read the bundled system prompt for intent tools |
|
|
119
134
|
|
|
120
135
|
## Part of SuperDoc
|
|
121
136
|
|