@superdoc-dev/sdk 1.0.0-next.73 → 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 +28 -21
- package/dist/generated/client.cjs +476 -0
- package/dist/generated/client.d.ts +9035 -150
- package/dist/generated/client.d.ts.map +1 -1
- package/dist/generated/client.js +475 -0
- package/dist/generated/contract.cjs +762 -41
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +762 -41
- 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 +130 -8
- package/dist/index.d.ts +73 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -8
- package/dist/runtime/process.d.ts +2 -2
- package/dist/runtime/process.d.ts.map +1 -1
- package/dist/runtime/transport-common.d.ts +7 -0
- package/dist/runtime/transport-common.d.ts.map +1 -1
- package/dist/tools.cjs +11 -7
- package/dist/tools.d.ts +8 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +11 -7
- package/package.json +6 -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 +0 -72
- package/tools/tools-policy.json +1 -1
- package/tools/tools.anthropic.json +0 -72
- package/tools/tools.generic.json +0 -72
- package/tools/tools.openai.json +0 -72
- package/tools/tools.vercel.json +0 -72
package/dist/helpers/format.d.ts
CHANGED
|
@@ -12,21 +12,20 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const client = createSuperDocClient();
|
|
14
14
|
* await client.connect();
|
|
15
|
+
* const doc = await client.open({ doc: './file.docx' });
|
|
15
16
|
*
|
|
16
17
|
* // Apply bold ON:
|
|
17
|
-
* await formatBold(
|
|
18
|
+
* await formatBold(doc.format.apply, { target: { kind: 'text', blockId: 'p1', range: { start: 0, end: 5 } } });
|
|
18
19
|
*
|
|
19
20
|
* // Apply explicit bold OFF (override style inheritance):
|
|
20
|
-
* await unformatBold(
|
|
21
|
+
* await unformatBold(doc.format.apply, { blockId: 'p1', start: 0, end: 5 });
|
|
21
22
|
*
|
|
22
23
|
* // Clear direct bold formatting (inherit from style cascade):
|
|
23
|
-
* await clearBold(
|
|
24
|
+
* await clearBold(doc.format.apply, { blockId: 'p1', start: 0, end: 5 });
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
import type { InvokeOptions, OperationSpec } from '../runtime/transport-common.js';
|
|
27
28
|
export interface FormatHelperParams {
|
|
28
|
-
doc?: string;
|
|
29
|
-
sessionId?: string;
|
|
30
29
|
target?: {
|
|
31
30
|
kind: 'text';
|
|
32
31
|
blockId: string;
|
|
@@ -46,9 +45,8 @@ export interface FormatHelperParams {
|
|
|
46
45
|
expectedRevision?: string;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
|
-
* Generic invoke function that works with
|
|
50
|
-
*
|
|
51
|
-
* but helpers call the runtime directly for forward-compatibility.
|
|
48
|
+
* Generic invoke function that works with a bound document handle runtime.
|
|
49
|
+
* Accepts the same signature as SuperDocRuntime.invoke.
|
|
52
50
|
*/
|
|
53
51
|
type RuntimeInvokeFn = <T = unknown>(operation: OperationSpec, params?: Record<string, unknown>, options?: InvokeOptions) => Promise<T>;
|
|
54
52
|
/** Apply bold ON. Equivalent to `format.apply` with `inline: { bold: 'on' }`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/helpers/format.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/helpers/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAoBnF,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE;Q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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"}
|
package/dist/helpers/format.js
CHANGED
|
@@ -12,31 +12,28 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const client = createSuperDocClient();
|
|
14
14
|
* await client.connect();
|
|
15
|
+
* const doc = await client.open({ doc: './file.docx' });
|
|
15
16
|
*
|
|
16
17
|
* // Apply bold ON:
|
|
17
|
-
* await formatBold(
|
|
18
|
+
* await formatBold(doc.format.apply, { target: { kind: 'text', blockId: 'p1', range: { start: 0, end: 5 } } });
|
|
18
19
|
*
|
|
19
20
|
* // Apply explicit bold OFF (override style inheritance):
|
|
20
|
-
* await unformatBold(
|
|
21
|
+
* await unformatBold(doc.format.apply, { blockId: 'p1', start: 0, end: 5 });
|
|
21
22
|
*
|
|
22
23
|
* // Clear direct bold formatting (inherit from style cascade):
|
|
23
|
-
* await clearBold(
|
|
24
|
+
* await clearBold(doc.format.apply, { blockId: 'p1', start: 0, end: 5 });
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
/**
|
|
27
28
|
* Minimal operation spec for `format.apply`. Used to invoke the canonical
|
|
28
29
|
* operation through the runtime without depending on generated code.
|
|
29
30
|
*
|
|
30
|
-
*
|
|
31
|
-
* start, end) are accepted via FormatHelperParams and normalized into
|
|
32
|
-
* a `target` object before invoke.
|
|
31
|
+
* doc and sessionId are omitted — the bound document handle injects them.
|
|
33
32
|
*/
|
|
34
33
|
const FORMAT_APPLY_SPEC = {
|
|
35
34
|
operationId: 'doc.format.apply',
|
|
36
35
|
commandTokens: ['format', 'apply'],
|
|
37
36
|
params: [
|
|
38
|
-
{ name: 'doc', kind: 'doc', type: 'string' },
|
|
39
|
-
{ name: 'sessionId', kind: 'doc', flag: 'session', type: 'string' },
|
|
40
37
|
{ name: 'target', kind: 'jsonFlag', type: 'json' },
|
|
41
38
|
{ name: 'inline', kind: 'jsonFlag', type: 'json' },
|
|
42
39
|
{ name: 'dryRun', kind: 'flag', type: 'boolean' },
|
package/dist/index.cjs
CHANGED
|
@@ -1,37 +1,159 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var client = require('./generated/client.cjs');
|
|
4
|
+
var contract = require('./generated/contract.cjs');
|
|
4
5
|
var process = require('./runtime/process.cjs');
|
|
6
|
+
var errors = require('./runtime/errors.cjs');
|
|
5
7
|
var skills = require('./skills.cjs');
|
|
6
8
|
var tools = require('./tools.cjs');
|
|
7
9
|
var intentDispatch_generated = require('./generated/intent-dispatch.generated.cjs');
|
|
8
|
-
var errors = require('./runtime/errors.cjs');
|
|
9
10
|
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Session-bound runtime wrapper
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Wraps a raw runtime and injects a fixed sessionId into every invoke call.
|
|
16
|
+
* Implements RuntimeInvoker so generated code can use it directly.
|
|
12
17
|
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
class BoundRuntime {
|
|
21
|
+
runtime;
|
|
22
|
+
sessionId;
|
|
23
|
+
closed = false;
|
|
24
|
+
constructor(runtime, sessionId) {
|
|
25
|
+
this.runtime = runtime;
|
|
26
|
+
this.sessionId = sessionId;
|
|
27
|
+
}
|
|
28
|
+
async invoke(operation, params = {}, options = {}) {
|
|
29
|
+
if (this.closed) {
|
|
30
|
+
throw new errors.SuperDocCliError('Document handle is closed.', {
|
|
31
|
+
code: 'DOCUMENT_CLOSED',
|
|
32
|
+
details: { sessionId: this.sessionId },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return this.runtime.invoke(operation, { ...params, sessionId: this.sessionId }, options);
|
|
36
|
+
}
|
|
37
|
+
markClosed() {
|
|
38
|
+
this.closed = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Document handle
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
/**
|
|
45
|
+
* Bound document handle. All document operations are available as typed methods.
|
|
46
|
+
* The handle injects its session id automatically — callers never pass
|
|
47
|
+
* doc or sessionId.
|
|
48
|
+
*/
|
|
49
|
+
class SuperDocDocumentCore {
|
|
50
|
+
boundRuntime;
|
|
51
|
+
_sessionId;
|
|
52
|
+
_openResult;
|
|
53
|
+
client;
|
|
54
|
+
/** @internal */
|
|
55
|
+
constructor(boundRuntime, sessionId, openResult, client$1) {
|
|
56
|
+
this.boundRuntime = boundRuntime;
|
|
57
|
+
this._sessionId = sessionId;
|
|
58
|
+
this._openResult = openResult;
|
|
59
|
+
this.client = client$1;
|
|
60
|
+
attachBoundDocApi(this, client.createBoundDocApi(this.boundRuntime));
|
|
61
|
+
}
|
|
62
|
+
get sessionId() {
|
|
63
|
+
return this._sessionId;
|
|
64
|
+
}
|
|
65
|
+
/** Read-only snapshot of the initial doc.open response metadata. */
|
|
66
|
+
get openResult() {
|
|
67
|
+
return this._openResult;
|
|
68
|
+
}
|
|
69
|
+
async save(params = {}, options = {}) {
|
|
70
|
+
return this.boundRuntime.invoke(contract.CONTRACT.operations['doc.save'], params, options);
|
|
71
|
+
}
|
|
72
|
+
async close(params = {}, options = {}) {
|
|
73
|
+
const result = await this.boundRuntime.invoke(contract.CONTRACT.operations['doc.close'], params, options);
|
|
74
|
+
this.boundRuntime.markClosed();
|
|
75
|
+
this.client.removeHandle(this._sessionId);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
markClosed() {
|
|
80
|
+
this.boundRuntime.markClosed();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function attachBoundDocApi(target, api) {
|
|
84
|
+
const { save: _save, close: _close, ...boundMethods } = api;
|
|
85
|
+
Object.assign(target, boundMethods);
|
|
86
|
+
}
|
|
87
|
+
const SuperDocDocument = SuperDocDocumentCore;
|
|
88
|
+
/**
|
|
89
|
+
* SuperDoc client — transport manager and document factory.
|
|
90
|
+
*
|
|
91
|
+
* Use `client.open()` to get bound document handles. Each handle is
|
|
92
|
+
* independently session-scoped and safe for concurrent use.
|
|
93
|
+
*
|
|
94
|
+
* const client = new SuperDocClient({ user: { name: 'bot' } });
|
|
95
|
+
* await client.connect();
|
|
96
|
+
* const doc = await client.open({ doc: './file.docx' });
|
|
97
|
+
* const markdown = await doc.getMarkdown();
|
|
98
|
+
* await doc.close();
|
|
99
|
+
* await client.dispose();
|
|
16
100
|
*/
|
|
17
101
|
class SuperDocClient {
|
|
18
102
|
runtime;
|
|
19
|
-
|
|
103
|
+
rawApi;
|
|
104
|
+
handles = new Map();
|
|
20
105
|
constructor(options = {}) {
|
|
21
106
|
this.runtime = new process.SuperDocRuntime(options);
|
|
22
|
-
this.
|
|
107
|
+
this.rawApi = client.createDocApi(this.runtime);
|
|
23
108
|
}
|
|
24
109
|
async connect() {
|
|
25
110
|
await this.runtime.connect();
|
|
26
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Open a document and return a bound document handle.
|
|
114
|
+
*
|
|
115
|
+
* The returned handle injects its session id into every operation
|
|
116
|
+
* automatically. The same file can be opened multiple times with
|
|
117
|
+
* different session ids (useful for diff workflows).
|
|
118
|
+
*/
|
|
119
|
+
async open(params, options) {
|
|
120
|
+
const explicitSessionId = params.sessionId;
|
|
121
|
+
if (typeof explicitSessionId === 'string' && this.handles.has(explicitSessionId)) {
|
|
122
|
+
throw new errors.SuperDocCliError(`Session id already open in this client: ${explicitSessionId}`, {
|
|
123
|
+
code: 'SESSION_ALREADY_OPEN',
|
|
124
|
+
details: { sessionId: explicitSessionId },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const result = (await this.rawApi.open(params, options));
|
|
128
|
+
const contextId = result.contextId;
|
|
129
|
+
const boundRuntime = new BoundRuntime(this.runtime, contextId);
|
|
130
|
+
const handle = new SuperDocDocument(boundRuntime, contextId, result, this);
|
|
131
|
+
this.handles.set(contextId, handle);
|
|
132
|
+
return handle;
|
|
133
|
+
}
|
|
134
|
+
async describe(params = {}, options) {
|
|
135
|
+
return this.rawApi.describe(params, options);
|
|
136
|
+
}
|
|
137
|
+
async describeCommand(params, options) {
|
|
138
|
+
return this.rawApi.describeCommand(params, options);
|
|
139
|
+
}
|
|
27
140
|
async dispose() {
|
|
141
|
+
for (const handle of this.handles.values()) {
|
|
142
|
+
handle.markClosed();
|
|
143
|
+
}
|
|
144
|
+
this.handles.clear();
|
|
28
145
|
await this.runtime.dispose();
|
|
29
146
|
}
|
|
147
|
+
/** @internal */
|
|
148
|
+
removeHandle(sessionId) {
|
|
149
|
+
this.handles.delete(sessionId);
|
|
150
|
+
}
|
|
30
151
|
}
|
|
31
152
|
function createSuperDocClient(options = {}) {
|
|
32
153
|
return new SuperDocClient(options);
|
|
33
154
|
}
|
|
34
155
|
|
|
156
|
+
exports.SuperDocCliError = errors.SuperDocCliError;
|
|
35
157
|
exports.getSkill = skills.getSkill;
|
|
36
158
|
exports.installSkill = skills.installSkill;
|
|
37
159
|
exports.listSkills = skills.listSkills;
|
|
@@ -41,6 +163,6 @@ exports.getSystemPrompt = tools.getSystemPrompt;
|
|
|
41
163
|
exports.getToolCatalog = tools.getToolCatalog;
|
|
42
164
|
exports.listTools = tools.listTools;
|
|
43
165
|
exports.dispatchIntentTool = intentDispatch_generated.dispatchIntentTool;
|
|
44
|
-
exports.SuperDocCliError = errors.SuperDocCliError;
|
|
45
166
|
exports.SuperDocClient = SuperDocClient;
|
|
167
|
+
exports.SuperDocDocument = SuperDocDocument;
|
|
46
168
|
exports.createSuperDocClient = createSuperDocClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type SuperDocClientOptions } from './runtime/process.js';
|
|
1
|
+
import { type BoundDocApi, type DocCloseBoundParams, type DocCloseResult, type DocSaveBoundParams, type DocSaveResult } from './generated/client.js';
|
|
2
|
+
import { SuperDocRuntime, type SuperDocClientOptions, type InvokeOptions, type OperationSpec, type RuntimeInvoker } from './runtime/process.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Wraps a raw runtime and injects a fixed sessionId into every invoke call.
|
|
5
|
+
* Implements RuntimeInvoker so generated code can use it directly.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
declare class BoundRuntime implements RuntimeInvoker {
|
|
10
|
+
private readonly runtime;
|
|
11
|
+
private readonly sessionId;
|
|
12
|
+
private closed;
|
|
13
|
+
constructor(runtime: SuperDocRuntime, sessionId: string);
|
|
14
|
+
invoke<TData = unknown>(operation: OperationSpec, params?: Record<string, unknown>, options?: InvokeOptions): Promise<TData>;
|
|
15
|
+
markClosed(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Bound document handle. All document operations are available as typed methods.
|
|
19
|
+
* The handle injects its session id automatically — callers never pass
|
|
20
|
+
* doc or sessionId.
|
|
21
|
+
*/
|
|
22
|
+
declare class SuperDocDocumentCore {
|
|
23
|
+
private readonly boundRuntime;
|
|
24
|
+
private readonly _sessionId;
|
|
25
|
+
private readonly _openResult;
|
|
26
|
+
private readonly client;
|
|
27
|
+
/** @internal */
|
|
28
|
+
constructor(boundRuntime: BoundRuntime, sessionId: string, openResult: Record<string, unknown>, client: SuperDocClient);
|
|
29
|
+
get sessionId(): string;
|
|
30
|
+
/** Read-only snapshot of the initial doc.open response metadata. */
|
|
31
|
+
get openResult(): Record<string, unknown>;
|
|
32
|
+
save(params?: DocSaveBoundParams, options?: InvokeOptions): Promise<DocSaveResult>;
|
|
33
|
+
close(params?: DocCloseBoundParams, options?: InvokeOptions): Promise<DocCloseResult>;
|
|
34
|
+
/** @internal */
|
|
35
|
+
markClosed(): void;
|
|
36
|
+
}
|
|
37
|
+
type SuperDocDocumentInstance = SuperDocDocumentCore & BoundDocApi;
|
|
38
|
+
export declare const SuperDocDocument: new (boundRuntime: BoundRuntime, sessionId: string, openResult: Record<string, unknown>, client: SuperDocClient) => SuperDocDocumentInstance;
|
|
39
|
+
export type SuperDocDocument = SuperDocDocumentInstance;
|
|
40
|
+
export interface DocOpenParams {
|
|
41
|
+
doc?: string;
|
|
42
|
+
sessionId?: string;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface DocDescribeCommandParams {
|
|
46
|
+
operationId: string;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* SuperDoc client — transport manager and document factory.
|
|
51
|
+
*
|
|
52
|
+
* Use `client.open()` to get bound document handles. Each handle is
|
|
53
|
+
* independently session-scoped and safe for concurrent use.
|
|
54
|
+
*
|
|
55
|
+
* const client = new SuperDocClient({ user: { name: 'bot' } });
|
|
56
|
+
* await client.connect();
|
|
57
|
+
* const doc = await client.open({ doc: './file.docx' });
|
|
58
|
+
* const markdown = await doc.getMarkdown();
|
|
59
|
+
* await doc.close();
|
|
60
|
+
* await client.dispose();
|
|
9
61
|
*/
|
|
10
62
|
export declare class SuperDocClient {
|
|
11
63
|
private readonly runtime;
|
|
12
|
-
readonly
|
|
64
|
+
private readonly rawApi;
|
|
65
|
+
private readonly handles;
|
|
13
66
|
constructor(options?: SuperDocClientOptions);
|
|
14
67
|
connect(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Open a document and return a bound document handle.
|
|
70
|
+
*
|
|
71
|
+
* The returned handle injects its session id into every operation
|
|
72
|
+
* automatically. The same file can be opened multiple times with
|
|
73
|
+
* different session ids (useful for diff workflows).
|
|
74
|
+
*/
|
|
75
|
+
open(params: DocOpenParams, options?: InvokeOptions): Promise<SuperDocDocument>;
|
|
76
|
+
describe(params?: Record<string, unknown>, options?: InvokeOptions): Promise<unknown>;
|
|
77
|
+
describeCommand(params: DocDescribeCommandParams, options?: InvokeOptions): Promise<unknown>;
|
|
15
78
|
dispose(): Promise<void>;
|
|
79
|
+
/** @internal */
|
|
80
|
+
removeHandle(sessionId: string): void;
|
|
16
81
|
}
|
|
17
82
|
export declare function createSuperDocClient(options?: SuperDocClientOptions): SuperDocClient;
|
|
18
83
|
export { getSkill, installSkill, listSkills } from './skills.js';
|
|
19
84
|
export { chooseTools, dispatchSuperDocTool, getSystemPrompt, getToolCatalog, listTools } from './tools.js';
|
|
20
85
|
export { dispatchIntentTool } from './generated/intent-dispatch.generated.js';
|
|
21
86
|
export { SuperDocCliError } from './runtime/errors.js';
|
|
22
|
-
export type { InvokeOptions, OperationSpec, OperationParamSpec, SuperDocClientOptions } from './runtime/process.js';
|
|
87
|
+
export type { InvokeOptions, OperationSpec, OperationParamSpec, RuntimeInvoker, SuperDocClientOptions, } from './runtime/process.js';
|
|
23
88
|
export type { ToolChooserInput, ToolProvider } from './tools.js';
|
|
24
89
|
//# 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.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAO9B;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM;IAKjD,MAAM,CAAC,KAAK,GAAG,OAAO,EAC1B,SAAS,EAAE,aAAa,EACxB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,KAAK,CAAC;IAUjB,UAAU,IAAI,IAAI;CAGnB;AAMD;;;;GAIG;AACH,cAAM,oBAAoB;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,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ACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;gBAEnD,OAAO,GAAE,qBAA0B;IAKzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;;;;OAMG;IACG,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkB/E,QAAQ,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzF,eAAe,CAAC,MAAM,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAI5F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,gBAAgB;IAChB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGtC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAExF;AAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,147 @@
|
|
|
1
|
-
import { createDocApi } from './generated/client.js';
|
|
2
|
-
import {
|
|
1
|
+
import { createDocApi, createBoundDocApi, } from './generated/client.js';
|
|
2
|
+
import { CONTRACT } from './generated/contract.js';
|
|
3
|
+
import { SuperDocRuntime, } from './runtime/process.js';
|
|
4
|
+
import { SuperDocCliError } from './runtime/errors.js';
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Session-bound runtime wrapper
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
9
|
+
* Wraps a raw runtime and injects a fixed sessionId into every invoke call.
|
|
10
|
+
* Implements RuntimeInvoker so generated code can use it directly.
|
|
5
11
|
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
class BoundRuntime {
|
|
15
|
+
runtime;
|
|
16
|
+
sessionId;
|
|
17
|
+
closed = false;
|
|
18
|
+
constructor(runtime, sessionId) {
|
|
19
|
+
this.runtime = runtime;
|
|
20
|
+
this.sessionId = sessionId;
|
|
21
|
+
}
|
|
22
|
+
async invoke(operation, params = {}, options = {}) {
|
|
23
|
+
if (this.closed) {
|
|
24
|
+
throw new SuperDocCliError('Document handle is closed.', {
|
|
25
|
+
code: 'DOCUMENT_CLOSED',
|
|
26
|
+
details: { sessionId: this.sessionId },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return this.runtime.invoke(operation, { ...params, sessionId: this.sessionId }, options);
|
|
30
|
+
}
|
|
31
|
+
markClosed() {
|
|
32
|
+
this.closed = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Document handle
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/**
|
|
39
|
+
* Bound document handle. All document operations are available as typed methods.
|
|
40
|
+
* The handle injects its session id automatically — callers never pass
|
|
41
|
+
* doc or sessionId.
|
|
42
|
+
*/
|
|
43
|
+
class SuperDocDocumentCore {
|
|
44
|
+
boundRuntime;
|
|
45
|
+
_sessionId;
|
|
46
|
+
_openResult;
|
|
47
|
+
client;
|
|
48
|
+
/** @internal */
|
|
49
|
+
constructor(boundRuntime, sessionId, openResult, client) {
|
|
50
|
+
this.boundRuntime = boundRuntime;
|
|
51
|
+
this._sessionId = sessionId;
|
|
52
|
+
this._openResult = openResult;
|
|
53
|
+
this.client = client;
|
|
54
|
+
attachBoundDocApi(this, createBoundDocApi(this.boundRuntime));
|
|
55
|
+
}
|
|
56
|
+
get sessionId() {
|
|
57
|
+
return this._sessionId;
|
|
58
|
+
}
|
|
59
|
+
/** Read-only snapshot of the initial doc.open response metadata. */
|
|
60
|
+
get openResult() {
|
|
61
|
+
return this._openResult;
|
|
62
|
+
}
|
|
63
|
+
async save(params = {}, options = {}) {
|
|
64
|
+
return this.boundRuntime.invoke(CONTRACT.operations['doc.save'], params, options);
|
|
65
|
+
}
|
|
66
|
+
async close(params = {}, options = {}) {
|
|
67
|
+
const result = await this.boundRuntime.invoke(CONTRACT.operations['doc.close'], params, options);
|
|
68
|
+
this.boundRuntime.markClosed();
|
|
69
|
+
this.client.removeHandle(this._sessionId);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/** @internal */
|
|
73
|
+
markClosed() {
|
|
74
|
+
this.boundRuntime.markClosed();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function attachBoundDocApi(target, api) {
|
|
78
|
+
const { save: _save, close: _close, ...boundMethods } = api;
|
|
79
|
+
Object.assign(target, boundMethods);
|
|
80
|
+
}
|
|
81
|
+
export const SuperDocDocument = SuperDocDocumentCore;
|
|
82
|
+
/**
|
|
83
|
+
* SuperDoc client — transport manager and document factory.
|
|
84
|
+
*
|
|
85
|
+
* Use `client.open()` to get bound document handles. Each handle is
|
|
86
|
+
* independently session-scoped and safe for concurrent use.
|
|
87
|
+
*
|
|
88
|
+
* const client = new SuperDocClient({ user: { name: 'bot' } });
|
|
89
|
+
* await client.connect();
|
|
90
|
+
* const doc = await client.open({ doc: './file.docx' });
|
|
91
|
+
* const markdown = await doc.getMarkdown();
|
|
92
|
+
* await doc.close();
|
|
93
|
+
* await client.dispose();
|
|
9
94
|
*/
|
|
10
95
|
export class SuperDocClient {
|
|
11
96
|
runtime;
|
|
12
|
-
|
|
97
|
+
rawApi;
|
|
98
|
+
handles = new Map();
|
|
13
99
|
constructor(options = {}) {
|
|
14
100
|
this.runtime = new SuperDocRuntime(options);
|
|
15
|
-
this.
|
|
101
|
+
this.rawApi = createDocApi(this.runtime);
|
|
16
102
|
}
|
|
17
103
|
async connect() {
|
|
18
104
|
await this.runtime.connect();
|
|
19
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Open a document and return a bound document handle.
|
|
108
|
+
*
|
|
109
|
+
* The returned handle injects its session id into every operation
|
|
110
|
+
* automatically. The same file can be opened multiple times with
|
|
111
|
+
* different session ids (useful for diff workflows).
|
|
112
|
+
*/
|
|
113
|
+
async open(params, options) {
|
|
114
|
+
const explicitSessionId = params.sessionId;
|
|
115
|
+
if (typeof explicitSessionId === 'string' && this.handles.has(explicitSessionId)) {
|
|
116
|
+
throw new SuperDocCliError(`Session id already open in this client: ${explicitSessionId}`, {
|
|
117
|
+
code: 'SESSION_ALREADY_OPEN',
|
|
118
|
+
details: { sessionId: explicitSessionId },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const result = (await this.rawApi.open(params, options));
|
|
122
|
+
const contextId = result.contextId;
|
|
123
|
+
const boundRuntime = new BoundRuntime(this.runtime, contextId);
|
|
124
|
+
const handle = new SuperDocDocument(boundRuntime, contextId, result, this);
|
|
125
|
+
this.handles.set(contextId, handle);
|
|
126
|
+
return handle;
|
|
127
|
+
}
|
|
128
|
+
async describe(params = {}, options) {
|
|
129
|
+
return this.rawApi.describe(params, options);
|
|
130
|
+
}
|
|
131
|
+
async describeCommand(params, options) {
|
|
132
|
+
return this.rawApi.describeCommand(params, options);
|
|
133
|
+
}
|
|
20
134
|
async dispose() {
|
|
135
|
+
for (const handle of this.handles.values()) {
|
|
136
|
+
handle.markClosed();
|
|
137
|
+
}
|
|
138
|
+
this.handles.clear();
|
|
21
139
|
await this.runtime.dispose();
|
|
22
140
|
}
|
|
141
|
+
/** @internal */
|
|
142
|
+
removeHandle(sessionId) {
|
|
143
|
+
this.handles.delete(sessionId);
|
|
144
|
+
}
|
|
23
145
|
}
|
|
24
146
|
export function createSuperDocClient(options = {}) {
|
|
25
147
|
return new SuperDocClient(options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InvokeOptions, OperationParamSpec, OperationSpec, SuperDocClientOptions } from './transport-common.js';
|
|
1
|
+
import type { InvokeOptions, OperationParamSpec, OperationSpec, RuntimeInvoker, SuperDocClientOptions } from './transport-common.js';
|
|
2
2
|
/**
|
|
3
3
|
* Internal runtime that delegates CLI invocations to a persistent host transport.
|
|
4
4
|
*
|
|
@@ -12,5 +12,5 @@ export declare class SuperDocRuntime {
|
|
|
12
12
|
dispose(): Promise<void>;
|
|
13
13
|
invoke<TData = unknown>(operation: OperationSpec, params?: Record<string, unknown>, options?: InvokeOptions): Promise<TData>;
|
|
14
14
|
}
|
|
15
|
-
export type { InvokeOptions, OperationParamSpec, OperationSpec, SuperDocClientOptions };
|
|
15
|
+
export type { InvokeOptions, OperationParamSpec, OperationSpec, RuntimeInvoker, SuperDocClientOptions };
|
|
16
16
|
//# sourceMappingURL=process.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/runtime/process.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/runtime/process.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAE/B;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,OAAO,GAAE,qBAA0B;IASzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,MAAM,CAAC,KAAK,GAAG,OAAO,EAC1B,SAAS,EAAE,aAAa,EACxB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,KAAK,CAAC;CAGlB;AAED,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -16,6 +16,13 @@ export interface InvokeOptions {
|
|
|
16
16
|
timeoutMs?: number;
|
|
17
17
|
stdinBytes?: Uint8Array;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Minimal invoke interface that both SuperDocRuntime and BoundRuntime satisfy.
|
|
21
|
+
* Generated code depends on this interface, not on the concrete runtime class.
|
|
22
|
+
*/
|
|
23
|
+
export interface RuntimeInvoker {
|
|
24
|
+
invoke<TData = unknown>(operation: OperationSpec, params?: Record<string, unknown>, options?: InvokeOptions): Promise<TData>;
|
|
25
|
+
}
|
|
19
26
|
export type ChangeMode = 'direct' | 'tracked';
|
|
20
27
|
export interface UserIdentity {
|
|
21
28
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-common.d.ts","sourceRoot":"","sources":["../../src/runtime/transport-common.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAC9E,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ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3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAMD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAU/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,EACtB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,iBAAiB,CAAC,EAAE,UAAU,EAC9B,IAAI,CAAC,EAAE,YAAY,GAClB,MAAM,EAAE,CAiEV"}
|
package/dist/tools.cjs
CHANGED
|
@@ -87,9 +87,9 @@ async function chooseTools(input) {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
function resolveDocApiMethod(
|
|
90
|
+
function resolveDocApiMethod(documentHandle, operationId) {
|
|
91
91
|
const tokens = operationId.split('.').slice(1);
|
|
92
|
-
let cursor =
|
|
92
|
+
let cursor = documentHandle;
|
|
93
93
|
for (const token of tokens) {
|
|
94
94
|
if (!isRecord(cursor) || !(token in cursor)) {
|
|
95
95
|
throw new errors.SuperDocCliError(`No SDK doc method found for operation ${operationId}.`, {
|
|
@@ -189,7 +189,13 @@ function validateOperationRequired(toolName, action, args, op) {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Dispatch a tool call against a bound document handle.
|
|
194
|
+
*
|
|
195
|
+
* The document handle injects session targeting automatically.
|
|
196
|
+
* Tool arguments should not contain `doc` or `sessionId`.
|
|
197
|
+
*/
|
|
198
|
+
async function dispatchSuperDocTool(documentHandle, toolName, args = {}, invokeOptions) {
|
|
193
199
|
if (!isRecord(args)) {
|
|
194
200
|
throw new errors.SuperDocCliError(`Tool arguments for ${toolName} must be an object.`, {
|
|
195
201
|
code: 'INVALID_ARGUMENT',
|
|
@@ -206,10 +212,8 @@ async function dispatchSuperDocTool(client, toolName, args = {}, invokeOptions)
|
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
214
|
validateToolArgs(toolName, args, tool);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return intentDispatch_generated.dispatchIntentTool(toolName, cleanArgs, (operationId, input) => {
|
|
212
|
-
const method = resolveDocApiMethod(client, operationId);
|
|
215
|
+
return intentDispatch_generated.dispatchIntentTool(toolName, args, (operationId, input) => {
|
|
216
|
+
const method = resolveDocApiMethod(documentHandle, operationId);
|
|
213
217
|
return method(input, invokeOptions);
|
|
214
218
|
});
|
|
215
219
|
}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BoundDocApi } from './generated/client.js';
|
|
1
2
|
import type { InvokeOptions } from './runtime/process.js';
|
|
2
3
|
export type ToolProvider = 'openai' | 'anthropic' | 'vercel' | 'generic';
|
|
3
4
|
export type ToolCatalog = {
|
|
@@ -41,9 +42,13 @@ export declare function chooseTools(input: ToolChooserInput): Promise<{
|
|
|
41
42
|
toolCount: number;
|
|
42
43
|
};
|
|
43
44
|
}>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Dispatch a tool call against a bound document handle.
|
|
47
|
+
*
|
|
48
|
+
* The document handle injects session targeting automatically.
|
|
49
|
+
* Tool arguments should not contain `doc` or `sessionId`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function dispatchSuperDocTool(documentHandle: BoundDocApi, toolName: string, args?: Record<string, unknown>, invokeOptions?: InvokeOptions): Promise<unknown>;
|
|
47
52
|
/**
|
|
48
53
|
* Read the bundled system prompt for intent tools.
|
|
49
54
|
*/
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAWzE,MAAM,MAAM,WAAW,GAAG;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B,CAAC;AA6CF,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CA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