@superdoc-dev/sdk 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (67) hide show
  1. package/README.md +126 -0
  2. package/dist/generated/client.cjs +276 -0
  3. package/dist/generated/client.d.ts +7161 -0
  4. package/dist/generated/client.d.ts.map +1 -0
  5. package/dist/generated/client.js +271 -0
  6. package/dist/generated/contract.cjs +71828 -0
  7. package/dist/generated/contract.d.ts +34 -0
  8. package/dist/generated/contract.d.ts.map +1 -0
  9. package/dist/generated/contract.js +71843 -0
  10. package/dist/helpers/format.d.ts +79 -0
  11. package/dist/helpers/format.d.ts.map +1 -0
  12. package/dist/helpers/format.js +121 -0
  13. package/dist/index.cjs +45 -0
  14. package/dist/index.d.ts +23 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +29 -0
  17. package/dist/runtime/embedded-cli.cjs +100 -0
  18. package/dist/runtime/embedded-cli.d.ts +5 -0
  19. package/dist/runtime/embedded-cli.d.ts.map +1 -0
  20. package/dist/runtime/embedded-cli.js +94 -0
  21. package/dist/runtime/errors.cjs +22 -0
  22. package/dist/runtime/errors.d.ts +17 -0
  23. package/dist/runtime/errors.d.ts.map +1 -0
  24. package/dist/runtime/errors.js +18 -0
  25. package/dist/runtime/host.cjs +352 -0
  26. package/dist/runtime/host.d.ts +37 -0
  27. package/dist/runtime/host.d.ts.map +1 -0
  28. package/dist/runtime/host.js +347 -0
  29. package/dist/runtime/process.cjs +32 -0
  30. package/dist/runtime/process.d.ts +16 -0
  31. package/dist/runtime/process.d.ts.map +1 -0
  32. package/dist/runtime/process.js +27 -0
  33. package/dist/runtime/transport-common.cjs +77 -0
  34. package/dist/runtime/transport-common.d.ts +49 -0
  35. package/dist/runtime/transport-common.d.ts.map +1 -0
  36. package/dist/runtime/transport-common.js +72 -0
  37. package/dist/skills.cjs +148 -0
  38. package/dist/skills.d.ts +25 -0
  39. package/dist/skills.d.ts.map +1 -0
  40. package/dist/skills.js +140 -0
  41. package/dist/tools.cjs +378 -0
  42. package/dist/tools.d.ts +113 -0
  43. package/dist/tools.d.ts.map +1 -0
  44. package/dist/tools.js +367 -0
  45. package/package.json +21 -11
  46. package/skills/editing-docx.md +24 -150
  47. package/tools/catalog.json +75676 -0
  48. package/tools/tool-name-map.json +436 -0
  49. package/tools/tools-policy.json +100 -0
  50. package/tools/tools.anthropic.json +31001 -0
  51. package/tools/tools.generic.json +72783 -0
  52. package/tools/tools.openai.json +32303 -0
  53. package/tools/tools.vercel.json +32303 -0
  54. package/src/__tests__/skills.test.ts +0 -166
  55. package/src/__tests__/tools.test.ts +0 -96
  56. package/src/generated/client.ts +0 -3643
  57. package/src/generated/contract.ts +0 -15952
  58. package/src/index.ts +0 -87
  59. package/src/runtime/__tests__/process.test.ts +0 -38
  60. package/src/runtime/__tests__/transport-common.test.ts +0 -174
  61. package/src/runtime/embedded-cli.ts +0 -109
  62. package/src/runtime/errors.ts +0 -30
  63. package/src/runtime/host.ts +0 -481
  64. package/src/runtime/process.ts +0 -45
  65. package/src/runtime/transport-common.ts +0 -169
  66. package/src/skills.ts +0 -195
  67. package/src/tools.ts +0 -701
@@ -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":"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"}
@@ -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.getToolCatalog = tools.getToolCatalog;
40
+ exports.inferDocumentFeatures = tools.inferDocumentFeatures;
41
+ exports.listTools = tools.listTools;
42
+ exports.resolveToolOperation = tools.resolveToolOperation;
43
+ exports.SuperDocCliError = errors.SuperDocCliError;
44
+ exports.SuperDocClient = SuperDocClient;
45
+ exports.createSuperDocClient = createSuperDocClient;
@@ -0,0 +1,23 @@
1
+ import { createDocApi } from './generated/client.js';
2
+ import { type SuperDocClientOptions } from './runtime/process.js';
3
+ /**
4
+ * High-level client for interacting with SuperDoc documents via the CLI.
5
+ *
6
+ * Provides a typed `doc` API for opening, querying, and mutating documents.
7
+ * Call {@link connect} before operations and {@link dispose} when finished
8
+ * to manage the host process lifecycle.
9
+ */
10
+ export declare class SuperDocClient {
11
+ private readonly runtime;
12
+ readonly doc: ReturnType<typeof createDocApi>;
13
+ constructor(options?: SuperDocClientOptions);
14
+ connect(): Promise<void>;
15
+ dispose(): Promise<void>;
16
+ }
17
+ export declare function createSuperDocClient(options?: SuperDocClientOptions): SuperDocClient;
18
+ export { getSkill, installSkill, listSkills } from './skills.js';
19
+ export { chooseTools, dispatchSuperDocTool, getToolCatalog, inferDocumentFeatures, listTools, resolveToolOperation, } from './tools.js';
20
+ export { SuperDocCliError } from './runtime/errors.js';
21
+ export type { InvokeOptions, OperationSpec, OperationParamSpec, SuperDocClientOptions } from './runtime/process.js';
22
+ export type { DocumentFeatures, ToolChooserInput, ToolPhase, ToolProfile, ToolProvider } from './tools.js';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEnF;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;gBAElC,OAAO,GAAE,qBAA0B;IAKzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAExF;AAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,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,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import { createDocApi } from './generated/client.js';
2
+ import { SuperDocRuntime } from './runtime/process.js';
3
+ /**
4
+ * High-level client for interacting with SuperDoc documents via the CLI.
5
+ *
6
+ * Provides a typed `doc` API for opening, querying, and mutating documents.
7
+ * Call {@link connect} before operations and {@link dispose} when finished
8
+ * to manage the host process lifecycle.
9
+ */
10
+ export class SuperDocClient {
11
+ runtime;
12
+ doc;
13
+ constructor(options = {}) {
14
+ this.runtime = new SuperDocRuntime(options);
15
+ this.doc = createDocApi(this.runtime);
16
+ }
17
+ async connect() {
18
+ await this.runtime.connect();
19
+ }
20
+ async dispose() {
21
+ await this.runtime.dispose();
22
+ }
23
+ }
24
+ export function createSuperDocClient(options = {}) {
25
+ return new SuperDocClient(options);
26
+ }
27
+ export { getSkill, installSkill, listSkills } from './skills.js';
28
+ export { chooseTools, dispatchSuperDocTool, getToolCatalog, inferDocumentFeatures, listTools, resolveToolOperation, } from './tools.js';
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,5 @@
1
+ /**
2
+ * Resolve the path to the embedded SuperDoc CLI binary for the current platform.
3
+ */
4
+ export declare function resolveEmbeddedCliBinary(): string;
5
+ //# sourceMappingURL=embedded-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedded-cli.d.ts","sourceRoot":"","sources":["../../src/runtime/embedded-cli.ts"],"names":[],"mappings":"AAuEA;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA2BjD"}
@@ -0,0 +1,94 @@
1
+ import { chmodSync, existsSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { SuperDocCliError } from './errors.js';
6
+ const require = createRequire(import.meta.url);
7
+ const TARGET_TO_PACKAGE = {
8
+ 'darwin-arm64': '@superdoc-dev/sdk-darwin-arm64',
9
+ 'darwin-x64': '@superdoc-dev/sdk-darwin-x64',
10
+ 'linux-x64': '@superdoc-dev/sdk-linux-x64',
11
+ 'linux-arm64': '@superdoc-dev/sdk-linux-arm64',
12
+ 'windows-x64': '@superdoc-dev/sdk-windows-x64',
13
+ };
14
+ const TARGET_TO_DIR = {
15
+ 'darwin-arm64': 'sdk-darwin-arm64',
16
+ 'darwin-x64': 'sdk-darwin-x64',
17
+ 'linux-x64': 'sdk-linux-x64',
18
+ 'linux-arm64': 'sdk-linux-arm64',
19
+ 'windows-x64': 'sdk-windows-x64',
20
+ };
21
+ function resolveTarget() {
22
+ const platform = process.platform;
23
+ const arch = process.arch;
24
+ if (platform === 'darwin' && arch === 'arm64')
25
+ return 'darwin-arm64';
26
+ if (platform === 'darwin' && arch === 'x64')
27
+ return 'darwin-x64';
28
+ if (platform === 'linux' && arch === 'x64')
29
+ return 'linux-x64';
30
+ if (platform === 'linux' && arch === 'arm64')
31
+ return 'linux-arm64';
32
+ if (platform === 'win32' && arch === 'x64')
33
+ return 'windows-x64';
34
+ return null;
35
+ }
36
+ function binaryNameForTarget(target) {
37
+ return target === 'windows-x64' ? 'superdoc.exe' : 'superdoc';
38
+ }
39
+ function ensureExecutable(binaryPath) {
40
+ if (process.platform === 'win32')
41
+ return;
42
+ try {
43
+ chmodSync(binaryPath, 0o755);
44
+ }
45
+ catch {
46
+ // Non-fatal: if chmod fails, spawn() will surface the real execution error.
47
+ }
48
+ }
49
+ function resolveFromPlatformPackage(target) {
50
+ const pkg = TARGET_TO_PACKAGE[target];
51
+ const binaryName = binaryNameForTarget(target);
52
+ try {
53
+ return require.resolve(`${pkg}/bin/${binaryName}`);
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ function resolveFromWorkspaceFallback(target) {
60
+ const binaryName = binaryNameForTarget(target);
61
+ const dirName = TARGET_TO_DIR[target];
62
+ const filePath = path.resolve(fileURLToPath(new URL('../../platforms', import.meta.url)), dirName, 'bin', binaryName);
63
+ if (!existsSync(filePath))
64
+ return null;
65
+ return filePath;
66
+ }
67
+ /**
68
+ * Resolve the path to the embedded SuperDoc CLI binary for the current platform.
69
+ */
70
+ export function resolveEmbeddedCliBinary() {
71
+ const target = resolveTarget();
72
+ if (!target) {
73
+ throw new SuperDocCliError('No embedded SuperDoc CLI binary is available for this platform.', {
74
+ code: 'UNSUPPORTED_PLATFORM',
75
+ details: {
76
+ platform: process.platform,
77
+ arch: process.arch,
78
+ },
79
+ });
80
+ }
81
+ const platformPackagePath = resolveFromPlatformPackage(target);
82
+ const resolvedPath = platformPackagePath ?? resolveFromWorkspaceFallback(target);
83
+ if (!resolvedPath) {
84
+ throw new SuperDocCliError('Embedded SuperDoc CLI binary is missing for this platform.', {
85
+ code: 'CLI_BINARY_MISSING',
86
+ details: {
87
+ target,
88
+ packageName: TARGET_TO_PACKAGE[target],
89
+ },
90
+ });
91
+ }
92
+ ensureExecutable(resolvedPath);
93
+ return resolvedPath;
94
+ }
@@ -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;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Error thrown by the SuperDoc SDK when a CLI operation fails.
3
+ *
4
+ * Includes a machine-readable `code` for programmatic error handling
5
+ * and optional `details` with structured diagnostic context.
6
+ */
7
+ export declare class SuperDocCliError extends Error {
8
+ readonly code: string;
9
+ readonly details?: unknown;
10
+ readonly exitCode?: number;
11
+ constructor(message: string, options: {
12
+ code: string;
13
+ details?: unknown;
14
+ exitCode?: number;
15
+ });
16
+ }
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/runtime/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CAO7F"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Error thrown by the SuperDoc SDK when a CLI operation fails.
3
+ *
4
+ * Includes a machine-readable `code` for programmatic error handling
5
+ * and optional `details` with structured diagnostic context.
6
+ */
7
+ export class SuperDocCliError extends Error {
8
+ code;
9
+ details;
10
+ exitCode;
11
+ constructor(message, options) {
12
+ super(message);
13
+ this.name = 'SuperDocCliError';
14
+ this.code = options.code;
15
+ this.details = options.details;
16
+ this.exitCode = options.exitCode;
17
+ }
18
+ }