@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.
Files changed (42) hide show
  1. package/README.md +50 -35
  2. package/dist/generated/client.cjs +734 -6
  3. package/dist/generated/client.d.ts +20380 -2887
  4. package/dist/generated/client.d.ts.map +1 -1
  5. package/dist/generated/client.js +733 -6
  6. package/dist/generated/contract.cjs +115396 -33890
  7. package/dist/generated/contract.d.ts +30 -46113
  8. package/dist/generated/contract.d.ts.map +1 -1
  9. package/dist/generated/contract.js +115396 -33890
  10. package/dist/generated/intent-dispatch.generated.cjs +94 -0
  11. package/dist/generated/intent-dispatch.generated.d.ts +2 -0
  12. package/dist/generated/intent-dispatch.generated.d.ts.map +1 -0
  13. package/dist/generated/intent-dispatch.generated.js +90 -0
  14. package/dist/helpers/format.d.ts +6 -8
  15. package/dist/helpers/format.d.ts.map +1 -1
  16. package/dist/helpers/format.js +5 -8
  17. package/dist/index.cjs +133 -10
  18. package/dist/index.d.ts +76 -10
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +132 -9
  21. package/dist/runtime/process.d.ts +2 -2
  22. package/dist/runtime/process.d.ts.map +1 -1
  23. package/dist/runtime/transport-common.cjs +10 -0
  24. package/dist/runtime/transport-common.d.ts +7 -0
  25. package/dist/runtime/transport-common.d.ts.map +1 -1
  26. package/dist/runtime/transport-common.js +10 -0
  27. package/dist/tools.cjs +148 -286
  28. package/dist/tools.d.ts +37 -93
  29. package/dist/tools.d.ts.map +1 -1
  30. package/dist/tools.js +147 -284
  31. package/package.json +7 -6
  32. package/tools/__pycache__/__init__.cpython-312.pyc +0 -0
  33. package/tools/__pycache__/intent_dispatch_generated.cpython-312.pyc +0 -0
  34. package/tools/catalog.json +4288 -66383
  35. package/tools/intent_dispatch_generated.py +122 -0
  36. package/tools/system-prompt.md +113 -0
  37. package/tools/tools-policy.json +37 -94
  38. package/tools/tools.anthropic.json +4290 -27847
  39. package/tools/tools.generic.json +4357 -64146
  40. package/tools/tools.openai.json +4309 -28991
  41. package/tools/tools.vercel.json +4309 -28991
  42. 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.doc.open({ doc: './contract.docx' });
39
+ const doc = await client.open({ doc: './contract.docx' });
40
40
 
41
- const info = await client.doc.info();
41
+ const info = await doc.info();
42
42
  console.log(info.counts);
43
43
 
44
- const results = await client.doc.find({ type: 'text', pattern: 'termination' });
45
-
46
- await client.doc.replace({
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
- await client.doc.save({ inPlace: true });
52
- await client.doc.close();
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
- All document operations are on `client.doc`:
74
+ Open documents from the client, then operate on the returned handle:
69
75
 
70
76
  ```ts
71
- client.doc.open(params)
72
- client.doc.find(params)
73
- client.doc.insert(params)
74
- // ... etc
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.strikethrough` |
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
- | **Session** | `session.list`, `session.save`, `session.close`, `session.setDefault` |
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 document operations as AI tool definitions:
100
+ The SDK includes built-in support for exposing grouped intent tools as AI tool definitions:
95
101
 
96
102
  ```ts
97
- import { chooseTools, dispatchSuperDocTool, inferDocumentFeatures } from '@superdoc-dev/sdk';
98
-
99
- // Get tool definitions for your AI provider
100
- const { tools, selected } = await chooseTools({
101
- provider: 'openai', // 'openai' | 'anthropic' | 'vercel' | 'generic'
102
- profile: 'intent', // human-friendly tool names
103
- taskContext: { phase: 'mutate' },
104
- documentFeatures: inferDocumentFeatures(await client.doc.info()),
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 result = await dispatchSuperDocTool(client, toolName, args);
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)` | Select tools filtered by phase, capabilities, and budget |
114
- | `listTools(provider, options?)` | List all tool definitions for a provider |
115
- | `dispatchSuperDocTool(client, toolName, args)` | Execute a tool call against a client |
116
- | `resolveToolOperation(toolName)` | Map a tool name to its operation ID |
117
- | `getToolCatalog(options?)` | Load the full tool catalog |
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