@superdoc-dev/sdk 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +124 -0
- package/dist/generated/client.cjs +479 -0
- package/dist/generated/client.d.ts +11940 -1167
- package/dist/generated/client.d.ts.map +1 -1
- package/dist/generated/client.js +433 -25
- package/dist/generated/contract.cjs +123158 -0
- package/dist/generated/contract.d.ts +30 -13672
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +116698 -11334
- package/dist/helpers/format.d.ts +79 -0
- package/dist/helpers/format.d.ts.map +1 -0
- package/dist/helpers/format.js +121 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/embedded-cli.cjs +100 -0
- package/dist/runtime/errors.cjs +22 -0
- package/dist/runtime/host.cjs +352 -0
- package/dist/runtime/host.d.ts +2 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/host.js +3 -1
- package/dist/runtime/process.cjs +32 -0
- package/dist/runtime/process.d.ts +1 -1
- package/dist/runtime/process.d.ts.map +1 -1
- package/dist/runtime/transport-common.cjs +79 -0
- package/dist/runtime/transport-common.d.ts +6 -1
- package/dist/runtime/transport-common.d.ts.map +1 -1
- package/dist/runtime/transport-common.js +13 -4
- package/dist/skills.cjs +148 -0
- package/dist/tools.cjs +312 -0
- package/dist/tools.d.ts +42 -65
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +75 -134
- package/package.json +15 -14
- package/skills/editing-docx.md +31 -0
- package/tools/catalog.json +59826 -15216
- package/tools/tool-name-map.json +300 -71
- package/tools/tools-policy.json +79 -82
- package/tools/tools.anthropic.json +25742 -2983
- package/tools/tools.generic.json +58182 -15148
- package/tools/tools.openai.json +26715 -3266
- package/tools/tools.vercel.json +26715 -3266
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format helper methods for the Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* These are hand-written convenience wrappers that call the canonical
|
|
5
|
+
* `format.apply` operation with pre-filled inline directives. They are NOT generated
|
|
6
|
+
* from the contract and will not be overwritten by `pnpm run generate:all`.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createSuperDocClient } from 'superdoc';
|
|
11
|
+
* import { formatBold, unformatBold, clearBold } from 'superdoc/helpers/format';
|
|
12
|
+
*
|
|
13
|
+
* const client = createSuperDocClient();
|
|
14
|
+
* await client.connect();
|
|
15
|
+
*
|
|
16
|
+
* // Apply bold ON:
|
|
17
|
+
* await formatBold(client.doc, { target: { kind: 'text', blockId: 'p1', range: { start: 0, end: 5 } } });
|
|
18
|
+
*
|
|
19
|
+
* // Apply explicit bold OFF (override style inheritance):
|
|
20
|
+
* await unformatBold(client.doc, { blockId: 'p1', start: 0, end: 5 });
|
|
21
|
+
*
|
|
22
|
+
* // Clear direct bold formatting (inherit from style cascade):
|
|
23
|
+
* await clearBold(client.doc, { blockId: 'p1', start: 0, end: 5 });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { InvokeOptions, OperationSpec } from '../runtime/transport-common.js';
|
|
27
|
+
export interface FormatHelperParams {
|
|
28
|
+
doc?: string;
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
target?: {
|
|
31
|
+
kind: 'text';
|
|
32
|
+
blockId: string;
|
|
33
|
+
range: {
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Flat-flag shorthand for target.blockId (normalized before dispatch). */
|
|
39
|
+
blockId?: string;
|
|
40
|
+
/** Flat-flag shorthand for target.range.start (normalized before dispatch). */
|
|
41
|
+
start?: number;
|
|
42
|
+
/** Flat-flag shorthand for target.range.end (normalized before dispatch). */
|
|
43
|
+
end?: number;
|
|
44
|
+
dryRun?: boolean;
|
|
45
|
+
changeMode?: 'direct' | 'tracked';
|
|
46
|
+
expectedRevision?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generic invoke function that works with the SuperDocRuntime.
|
|
50
|
+
* The doc API proxy created by `createDocApi(runtime)` exposes generated methods,
|
|
51
|
+
* but helpers call the runtime directly for forward-compatibility.
|
|
52
|
+
*/
|
|
53
|
+
type RuntimeInvokeFn = <T = unknown>(operation: OperationSpec, params?: Record<string, unknown>, options?: InvokeOptions) => Promise<T>;
|
|
54
|
+
/** Apply bold ON. Equivalent to `format.apply` with `inline: { bold: 'on' }`. */
|
|
55
|
+
export declare function formatBold(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
56
|
+
/** Apply italic ON. Equivalent to `format.apply` with `inline: { italic: 'on' }`. */
|
|
57
|
+
export declare function formatItalic(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
58
|
+
/** Apply underline ON. Equivalent to `format.apply` with `inline: { underline: 'on' }`. */
|
|
59
|
+
export declare function formatUnderline(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
60
|
+
/** Apply strikethrough ON. Equivalent to `format.apply` with `inline: { strike: 'on' }`. */
|
|
61
|
+
export declare function formatStrikethrough(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
62
|
+
/** Apply bold OFF. Equivalent to `format.apply` with `inline: { bold: 'off' }`. */
|
|
63
|
+
export declare function unformatBold(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
64
|
+
/** Apply italic OFF. Equivalent to `format.apply` with `inline: { italic: 'off' }`. */
|
|
65
|
+
export declare function unformatItalic(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
66
|
+
/** Apply underline OFF. Equivalent to `format.apply` with `inline: { underline: 'off' }`. */
|
|
67
|
+
export declare function unformatUnderline(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
68
|
+
/** Apply strikethrough OFF. Equivalent to `format.apply` with `inline: { strike: 'off' }`. */
|
|
69
|
+
export declare function unformatStrikethrough(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
70
|
+
/** Clear bold formatting. Equivalent to `format.apply` with `inline: { bold: 'clear' }`. */
|
|
71
|
+
export declare function clearBold(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
72
|
+
/** Clear italic formatting. Equivalent to `format.apply` with `inline: { italic: 'clear' }`. */
|
|
73
|
+
export declare function clearItalic(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
74
|
+
/** Clear underline formatting. Equivalent to `format.apply` with `inline: { underline: 'clear' }`. */
|
|
75
|
+
export declare function clearUnderline(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
76
|
+
/** Clear strikethrough formatting. Equivalent to `format.apply` with `inline: { strike: 'clear' }`. */
|
|
77
|
+
export declare function clearStrikethrough(invoke: RuntimeInvokeFn, params?: FormatHelperParams, options?: InvokeOptions): Promise<unknown>;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/helpers/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAwBnF,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM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AE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAE7G;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAE/G;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAElH;AAED,8FAA8F;AAC9F,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,MAAM,GAAE,kBAAuB,EAC/B,OAAO,CAAC,EAAE,aAAa,oBAGxB;AAMD,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAE1G;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAE5G;AAED,sGAAsG;AACtG,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAE/G;AAED,uGAAuG;AACvG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa,oBAEnH"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format helper methods for the Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* These are hand-written convenience wrappers that call the canonical
|
|
5
|
+
* `format.apply` operation with pre-filled inline directives. They are NOT generated
|
|
6
|
+
* from the contract and will not be overwritten by `pnpm run generate:all`.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createSuperDocClient } from 'superdoc';
|
|
11
|
+
* import { formatBold, unformatBold, clearBold } from 'superdoc/helpers/format';
|
|
12
|
+
*
|
|
13
|
+
* const client = createSuperDocClient();
|
|
14
|
+
* await client.connect();
|
|
15
|
+
*
|
|
16
|
+
* // Apply bold ON:
|
|
17
|
+
* await formatBold(client.doc, { target: { kind: 'text', blockId: 'p1', range: { start: 0, end: 5 } } });
|
|
18
|
+
*
|
|
19
|
+
* // Apply explicit bold OFF (override style inheritance):
|
|
20
|
+
* await unformatBold(client.doc, { blockId: 'p1', start: 0, end: 5 });
|
|
21
|
+
*
|
|
22
|
+
* // Clear direct bold formatting (inherit from style cascade):
|
|
23
|
+
* await clearBold(client.doc, { blockId: 'p1', start: 0, end: 5 });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Minimal operation spec for `format.apply`. Used to invoke the canonical
|
|
28
|
+
* operation through the runtime without depending on generated code.
|
|
29
|
+
*
|
|
30
|
+
* Only canonical params are listed here. Flat-flag shortcuts (blockId,
|
|
31
|
+
* start, end) are accepted via FormatHelperParams and normalized into
|
|
32
|
+
* a `target` object before invoke.
|
|
33
|
+
*/
|
|
34
|
+
const FORMAT_APPLY_SPEC = {
|
|
35
|
+
operationId: 'doc.format.apply',
|
|
36
|
+
commandTokens: ['format', 'apply'],
|
|
37
|
+
params: [
|
|
38
|
+
{ name: 'doc', kind: 'doc', type: 'string' },
|
|
39
|
+
{ name: 'sessionId', kind: 'doc', flag: 'session', type: 'string' },
|
|
40
|
+
{ name: 'target', kind: 'jsonFlag', type: 'json' },
|
|
41
|
+
{ name: 'inline', kind: 'jsonFlag', type: 'json' },
|
|
42
|
+
{ name: 'dryRun', kind: 'flag', type: 'boolean' },
|
|
43
|
+
{ name: 'changeMode', kind: 'flag', type: 'string' },
|
|
44
|
+
{ name: 'expectedRevision', kind: 'flag', type: 'string' },
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Normalizes flat-flag shorthand params (blockId, start, end) into a
|
|
49
|
+
* canonical `target` object. If `target` is already provided, flat flags
|
|
50
|
+
* are left untouched (the caller provided the canonical form directly).
|
|
51
|
+
*/
|
|
52
|
+
function normalizeFormatParams(params) {
|
|
53
|
+
const { blockId, start, end, target, ...rest } = params;
|
|
54
|
+
if (blockId !== undefined && target === undefined) {
|
|
55
|
+
return {
|
|
56
|
+
...rest,
|
|
57
|
+
target: { kind: 'text', blockId, range: { start: start ?? 0, end: end ?? 0 } },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return params;
|
|
61
|
+
}
|
|
62
|
+
function mergeInlineStyles(params, inline) {
|
|
63
|
+
return { ...normalizeFormatParams(params), inline };
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// format* helpers — apply ON directive
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/** Apply bold ON. Equivalent to `format.apply` with `inline: { bold: 'on' }`. */
|
|
69
|
+
export function formatBold(invoke, params = {}, options) {
|
|
70
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { bold: 'on' }), options);
|
|
71
|
+
}
|
|
72
|
+
/** Apply italic ON. Equivalent to `format.apply` with `inline: { italic: 'on' }`. */
|
|
73
|
+
export function formatItalic(invoke, params = {}, options) {
|
|
74
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { italic: 'on' }), options);
|
|
75
|
+
}
|
|
76
|
+
/** Apply underline ON. Equivalent to `format.apply` with `inline: { underline: 'on' }`. */
|
|
77
|
+
export function formatUnderline(invoke, params = {}, options) {
|
|
78
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { underline: 'on' }), options);
|
|
79
|
+
}
|
|
80
|
+
/** Apply strikethrough ON. Equivalent to `format.apply` with `inline: { strike: 'on' }`. */
|
|
81
|
+
export function formatStrikethrough(invoke, params = {}, options) {
|
|
82
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { strike: 'on' }), options);
|
|
83
|
+
}
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// unformat* helpers — apply explicit OFF directive (style override)
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/** Apply bold OFF. Equivalent to `format.apply` with `inline: { bold: 'off' }`. */
|
|
88
|
+
export function unformatBold(invoke, params = {}, options) {
|
|
89
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { bold: 'off' }), options);
|
|
90
|
+
}
|
|
91
|
+
/** Apply italic OFF. Equivalent to `format.apply` with `inline: { italic: 'off' }`. */
|
|
92
|
+
export function unformatItalic(invoke, params = {}, options) {
|
|
93
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { italic: 'off' }), options);
|
|
94
|
+
}
|
|
95
|
+
/** Apply underline OFF. Equivalent to `format.apply` with `inline: { underline: 'off' }`. */
|
|
96
|
+
export function unformatUnderline(invoke, params = {}, options) {
|
|
97
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { underline: 'off' }), options);
|
|
98
|
+
}
|
|
99
|
+
/** Apply strikethrough OFF. Equivalent to `format.apply` with `inline: { strike: 'off' }`. */
|
|
100
|
+
export function unformatStrikethrough(invoke, params = {}, options) {
|
|
101
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { strike: 'off' }), options);
|
|
102
|
+
}
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// clear* helpers — remove direct formatting (inherit from style cascade)
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
/** Clear bold formatting. Equivalent to `format.apply` with `inline: { bold: 'clear' }`. */
|
|
107
|
+
export function clearBold(invoke, params = {}, options) {
|
|
108
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { bold: 'clear' }), options);
|
|
109
|
+
}
|
|
110
|
+
/** Clear italic formatting. Equivalent to `format.apply` with `inline: { italic: 'clear' }`. */
|
|
111
|
+
export function clearItalic(invoke, params = {}, options) {
|
|
112
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { italic: 'clear' }), options);
|
|
113
|
+
}
|
|
114
|
+
/** Clear underline formatting. Equivalent to `format.apply` with `inline: { underline: 'clear' }`. */
|
|
115
|
+
export function clearUnderline(invoke, params = {}, options) {
|
|
116
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { underline: 'clear' }), options);
|
|
117
|
+
}
|
|
118
|
+
/** Clear strikethrough formatting. Equivalent to `format.apply` with `inline: { strike: 'clear' }`. */
|
|
119
|
+
export function clearStrikethrough(invoke, params = {}, options) {
|
|
120
|
+
return invoke(FORMAT_APPLY_SPEC, mergeInlineStyles(params, { strike: 'clear' }), options);
|
|
121
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('./generated/client.cjs');
|
|
4
|
+
var process = require('./runtime/process.cjs');
|
|
5
|
+
var skills = require('./skills.cjs');
|
|
6
|
+
var tools = require('./tools.cjs');
|
|
7
|
+
var errors = require('./runtime/errors.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* High-level client for interacting with SuperDoc documents via the CLI.
|
|
11
|
+
*
|
|
12
|
+
* Provides a typed `doc` API for opening, querying, and mutating documents.
|
|
13
|
+
* Call {@link connect} before operations and {@link dispose} when finished
|
|
14
|
+
* to manage the host process lifecycle.
|
|
15
|
+
*/
|
|
16
|
+
class SuperDocClient {
|
|
17
|
+
runtime;
|
|
18
|
+
doc;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.runtime = new process.SuperDocRuntime(options);
|
|
21
|
+
this.doc = client.createDocApi(this.runtime);
|
|
22
|
+
}
|
|
23
|
+
async connect() {
|
|
24
|
+
await this.runtime.connect();
|
|
25
|
+
}
|
|
26
|
+
async dispose() {
|
|
27
|
+
await this.runtime.dispose();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function createSuperDocClient(options = {}) {
|
|
31
|
+
return new SuperDocClient(options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.getSkill = skills.getSkill;
|
|
35
|
+
exports.installSkill = skills.installSkill;
|
|
36
|
+
exports.listSkills = skills.listSkills;
|
|
37
|
+
exports.chooseTools = tools.chooseTools;
|
|
38
|
+
exports.dispatchSuperDocTool = tools.dispatchSuperDocTool;
|
|
39
|
+
exports.getAvailableGroups = tools.getAvailableGroups;
|
|
40
|
+
exports.getToolCatalog = tools.getToolCatalog;
|
|
41
|
+
exports.listTools = tools.listTools;
|
|
42
|
+
exports.resolveToolOperation = tools.resolveToolOperation;
|
|
43
|
+
exports.SuperDocCliError = errors.SuperDocCliError;
|
|
44
|
+
exports.SuperDocClient = SuperDocClient;
|
|
45
|
+
exports.createSuperDocClient = createSuperDocClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export declare class SuperDocClient {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function createSuperDocClient(options?: SuperDocClientOptions): SuperDocClient;
|
|
18
18
|
export { getSkill, installSkill, listSkills } from './skills.js';
|
|
19
|
-
export { chooseTools, dispatchSuperDocTool,
|
|
19
|
+
export { chooseTools, dispatchSuperDocTool, getAvailableGroups, getToolCatalog, listTools, resolveToolOperation, } from './tools.js';
|
|
20
20
|
export { SuperDocCliError } from './runtime/errors.js';
|
|
21
|
-
export type { InvokeOptions, OperationSpec, OperationParamSpec, SuperDocClientOptions
|
|
22
|
-
export type {
|
|
21
|
+
export type { InvokeOptions, OperationSpec, OperationParamSpec, SuperDocClientOptions } from './runtime/process.js';
|
|
22
|
+
export type { ToolChooserInput, ToolChooserMode, ToolGroup, ToolProvider } from './tools.js';
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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AkB,EAClB,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpH,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,5 +25,5 @@ export function createSuperDocClient(options = {}) {
|
|
|
25
25
|
return new SuperDocClient(options);
|
|
26
26
|
}
|
|
27
27
|
export { getSkill, installSkill, listSkills } from './skills.js';
|
|
28
|
-
export { chooseTools, dispatchSuperDocTool,
|
|
28
|
+
export { chooseTools, dispatchSuperDocTool, getAvailableGroups, getToolCatalog, listTools, resolveToolOperation, } from './tools.js';
|
|
29
29
|
export { SuperDocCliError } from './runtime/errors.js';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_fs = require('node:fs');
|
|
4
|
+
var node_module = require('node:module');
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var node_url = require('node:url');
|
|
7
|
+
var errors = require('./errors.cjs');
|
|
8
|
+
|
|
9
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('runtime/embedded-cli.cjs', document.baseURI).href)));
|
|
11
|
+
const TARGET_TO_PACKAGE = {
|
|
12
|
+
'darwin-arm64': '@superdoc-dev/sdk-darwin-arm64',
|
|
13
|
+
'darwin-x64': '@superdoc-dev/sdk-darwin-x64',
|
|
14
|
+
'linux-x64': '@superdoc-dev/sdk-linux-x64',
|
|
15
|
+
'linux-arm64': '@superdoc-dev/sdk-linux-arm64',
|
|
16
|
+
'windows-x64': '@superdoc-dev/sdk-windows-x64',
|
|
17
|
+
};
|
|
18
|
+
const TARGET_TO_DIR = {
|
|
19
|
+
'darwin-arm64': 'sdk-darwin-arm64',
|
|
20
|
+
'darwin-x64': 'sdk-darwin-x64',
|
|
21
|
+
'linux-x64': 'sdk-linux-x64',
|
|
22
|
+
'linux-arm64': 'sdk-linux-arm64',
|
|
23
|
+
'windows-x64': 'sdk-windows-x64',
|
|
24
|
+
};
|
|
25
|
+
function resolveTarget() {
|
|
26
|
+
const platform = process.platform;
|
|
27
|
+
const arch = process.arch;
|
|
28
|
+
if (platform === 'darwin' && arch === 'arm64')
|
|
29
|
+
return 'darwin-arm64';
|
|
30
|
+
if (platform === 'darwin' && arch === 'x64')
|
|
31
|
+
return 'darwin-x64';
|
|
32
|
+
if (platform === 'linux' && arch === 'x64')
|
|
33
|
+
return 'linux-x64';
|
|
34
|
+
if (platform === 'linux' && arch === 'arm64')
|
|
35
|
+
return 'linux-arm64';
|
|
36
|
+
if (platform === 'win32' && arch === 'x64')
|
|
37
|
+
return 'windows-x64';
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function binaryNameForTarget(target) {
|
|
41
|
+
return target === 'windows-x64' ? 'superdoc.exe' : 'superdoc';
|
|
42
|
+
}
|
|
43
|
+
function ensureExecutable(binaryPath) {
|
|
44
|
+
if (process.platform === 'win32')
|
|
45
|
+
return;
|
|
46
|
+
try {
|
|
47
|
+
node_fs.chmodSync(binaryPath, 0o755);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Non-fatal: if chmod fails, spawn() will surface the real execution error.
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function resolveFromPlatformPackage(target) {
|
|
54
|
+
const pkg = TARGET_TO_PACKAGE[target];
|
|
55
|
+
const binaryName = binaryNameForTarget(target);
|
|
56
|
+
try {
|
|
57
|
+
return require$1.resolve(`${pkg}/bin/${binaryName}`);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function resolveFromWorkspaceFallback(target) {
|
|
64
|
+
const binaryName = binaryNameForTarget(target);
|
|
65
|
+
const dirName = TARGET_TO_DIR[target];
|
|
66
|
+
const filePath = path.resolve(node_url.fileURLToPath(new URL('../../platforms', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('runtime/embedded-cli.cjs', document.baseURI).href)))), dirName, 'bin', binaryName);
|
|
67
|
+
if (!node_fs.existsSync(filePath))
|
|
68
|
+
return null;
|
|
69
|
+
return filePath;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the path to the embedded SuperDoc CLI binary for the current platform.
|
|
73
|
+
*/
|
|
74
|
+
function resolveEmbeddedCliBinary() {
|
|
75
|
+
const target = resolveTarget();
|
|
76
|
+
if (!target) {
|
|
77
|
+
throw new errors.SuperDocCliError('No embedded SuperDoc CLI binary is available for this platform.', {
|
|
78
|
+
code: 'UNSUPPORTED_PLATFORM',
|
|
79
|
+
details: {
|
|
80
|
+
platform: process.platform,
|
|
81
|
+
arch: process.arch,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const platformPackagePath = resolveFromPlatformPackage(target);
|
|
86
|
+
const resolvedPath = platformPackagePath ?? resolveFromWorkspaceFallback(target);
|
|
87
|
+
if (!resolvedPath) {
|
|
88
|
+
throw new errors.SuperDocCliError('Embedded SuperDoc CLI binary is missing for this platform.', {
|
|
89
|
+
code: 'CLI_BINARY_MISSING',
|
|
90
|
+
details: {
|
|
91
|
+
target,
|
|
92
|
+
packageName: TARGET_TO_PACKAGE[target],
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
ensureExecutable(resolvedPath);
|
|
97
|
+
return resolvedPath;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
exports.resolveEmbeddedCliBinary = resolveEmbeddedCliBinary;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown by the SuperDoc SDK when a CLI operation fails.
|
|
5
|
+
*
|
|
6
|
+
* Includes a machine-readable `code` for programmatic error handling
|
|
7
|
+
* and optional `details` with structured diagnostic context.
|
|
8
|
+
*/
|
|
9
|
+
class SuperDocCliError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
details;
|
|
12
|
+
exitCode;
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'SuperDocCliError';
|
|
16
|
+
this.code = options.code;
|
|
17
|
+
this.details = options.details;
|
|
18
|
+
this.exitCode = options.exitCode;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.SuperDocCliError = SuperDocCliError;
|