revise 1.0.0 → 2.0.0
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/CHANGELOG.md +962 -0
- package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
- package/FONT-LICENSE-KATEX.txt +95 -0
- package/FONT-LICENSE-LIBERATION.txt +102 -0
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
- package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
- package/FONT-LICENSE-NOTO.txt +94 -0
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
- package/LICENSE +41 -21
- package/README.md +39 -1
- package/THIRD-PARTY-NOTICES.md +3376 -0
- package/assets/historyMaterializeWorker-CoAX9ZAi.js +3 -0
- package/backend.d.ts +133 -0
- package/backend.js +1 -0
- package/chunks/AgentPageRenderer-C0n4EnuW.js +1 -0
- package/chunks/AgentPageRenderer-DURfmiu0.js +1 -0
- package/chunks/AttachmentDocumentImporter-DSic_6At.js +1 -0
- package/chunks/AttachmentDocumentImporter-dNMtkxrv.js +1 -0
- package/chunks/BidiText-B4Hzrjg9.js +1 -0
- package/chunks/ColorParserFull-BKH72fK8.js +1 -0
- package/chunks/DocumentStylesheet-byN5dtC6.js +1 -0
- package/chunks/DocxConverter-B7P52lw7.js +11 -0
- package/chunks/DocxConverter-COV6CjUM.js +11 -0
- package/chunks/DocxConverter-Cq_zCEJC.js +11 -0
- package/chunks/DocxGraft-CJ12C9WP.js +1 -0
- package/chunks/DocxGraft-CQpvFcYb.js +1 -0
- package/chunks/DocxGraft-DcmFuUkd.js +1 -0
- package/chunks/FileImporter-DVnYOJHp.js +1 -0
- package/chunks/FileImporter-q9mCch0J.js +1 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +1 -0
- package/chunks/HtmlConverter-JvRlkQM3.js +61 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +1 -0
- package/chunks/MarkdownConverter-B-tPY7X3.js +17 -0
- package/chunks/MathRenderer-B0Y1h1JU.js +33 -0
- package/chunks/OdtConverter-Br81BSoJ.js +1 -0
- package/chunks/OdtConverter-CQjh0vlo.js +1 -0
- package/chunks/OdtConverter-DYHnR4E8.js +1 -0
- package/chunks/PdfConverter-D26rXumc.js +21 -0
- package/chunks/PdfConverter-DGZpUSVf.js +21 -0
- package/chunks/PdfConverter-DZzVP0-B.js +21 -0
- package/chunks/PdfImportService-CBD8TL1k.js +2 -0
- package/chunks/PdfImportService-D6uUKGMf.js +2 -0
- package/chunks/RtfConverter-BQGge3K-.js +14 -0
- package/chunks/RtfConverter-CMfZ4olw.js +14 -0
- package/chunks/RtfConverter-oIwzoqCD.js +14 -0
- package/chunks/TableBorders-BLkZYt1k.js +1 -0
- package/chunks/TableGrid-DVWaRZv0.js +1 -0
- package/chunks/TextFileDecoder--rsVs3NR.js +2 -0
- package/chunks/TxtConverter-C1lp6dBS.js +11 -0
- package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +1 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -0
- package/chunks/ar-kgSWdrXF.js +8 -0
- package/chunks/backend-Cq-khfdG.js +1 -0
- package/chunks/base64-CfDUyGi8.js +36 -0
- package/chunks/browser-module-6b2Fq-5C.js +3 -0
- package/chunks/browser-module-CFmqfGkE.js +3 -0
- package/chunks/browser-module-CkO57IPL.js +3 -0
- package/chunks/bundle.min-DRpfgV69.js +8 -0
- package/chunks/capture-DU3MC7tb.js +1 -0
- package/chunks/carrier-WgcRSu7a.js +1 -0
- package/chunks/de-C2QTHrqo.js +8 -0
- package/chunks/es-BKboUn4q.js +8 -0
- package/chunks/footnoteFlatten-CW-DUcgK.js +1 -0
- package/chunks/graftExport-CVg7PO2A.js +2 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +5 -0
- package/chunks/index-BWdRWxoH.js +24 -0
- package/chunks/index-CLw_BlSL.js +353 -0
- package/chunks/index-F-kHIwWT.js +353 -0
- package/chunks/index.es-CI0QPo8w.js +5 -0
- package/chunks/index.es-DOqegDGr.js +5 -0
- package/chunks/index.es-tXDO0RMv.js +5 -0
- package/chunks/jspdf.es.min-CzYti8jo.js +77 -0
- package/chunks/jspdf.es.min-DU74zN8b.js +77 -0
- package/chunks/jspdf.es.min-ejWOGhkJ.js +77 -0
- package/chunks/jszip.min-CPW0h1Kx.js +2 -0
- package/chunks/katex-DWj8TvwO.js +261 -0
- package/chunks/pdf-BLWDCiFF.js +12 -0
- package/chunks/persistInlineDocumentImages-DQj2iaqg.js +1 -0
- package/chunks/pseudoLocale-CdBtPHRi.js +1 -0
- package/chunks/pseudoLocale-DEVWLkGC.js +1 -0
- package/chunks/purify.es-BwLardii.js +2 -0
- package/chunks/serverDocumentSession-DZrYbdpk.js +42 -0
- package/chunks/tree-sitter-D6zWWUMP.js +4 -0
- package/chunks/wasmInline.generated-CBYFkdSM.js +1 -0
- package/chunks/web-tree-sitter-BXGZGnNj.js +1 -0
- package/full.js +1 -0
- package/index.d.ts +929 -0
- package/index.js +1 -0
- package/package.json +93 -26
- package/root.d.ts +5 -0
- package/root.js +2 -0
- package/serverToolContract.d.ts +373 -0
- package/serverToolInputs.generated.d.ts +229 -0
- package/style.css +1 -0
- package/.npmignore +0 -4
- package/.travis.yml +0 -16
- package/revise.js +0 -16
- package/t/cover +0 -18
- package/t/revise/comparator.t.js +0 -31
- package/t/revise/extractor.t.js +0 -29
- package/t/test +0 -20
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c8 as s,c7 as a,ca as e,cd as c,cb as r,c9 as o,ca as E,ce as t,cc as R}from"./chunks/index-CLw_BlSL.js";export{s as REVISE_SDK_BUILD,a as REVISE_SDK_VERSION,e as ReviseEditor,c as ReviseRoleError,r as ReviseToolError,o as createEmptyDocx,E as default,t as rolePolicy,R as setAssetBaseUrl};
|
package/package.json
CHANGED
|
@@ -1,32 +1,99 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"name": "revise",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "A word processor for React: DOCX in and out, real pagination, tracked changes, comments, collaboration, and agent tools. Free for evaluation, personal projects, and education.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"docx",
|
|
7
|
+
"word",
|
|
8
|
+
"word-processor",
|
|
9
|
+
"document-editor",
|
|
10
|
+
"rich-text-editor",
|
|
11
|
+
"react",
|
|
12
|
+
"tracked-changes",
|
|
13
|
+
"redlines",
|
|
14
|
+
"comments",
|
|
15
|
+
"yjs",
|
|
16
|
+
"ai",
|
|
17
|
+
"agent"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./root.js",
|
|
21
|
+
"module": "./root.js",
|
|
22
|
+
"types": "./root.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./root.d.ts",
|
|
26
|
+
"import": "./root.js"
|
|
19
27
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
"./editor": {
|
|
29
|
+
"types": "./index.d.ts",
|
|
30
|
+
"import": "./index.js"
|
|
23
31
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
"./editor/full": {
|
|
33
|
+
"types": "./index.d.ts",
|
|
34
|
+
"import": "./full.js"
|
|
27
35
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
"./server": {
|
|
37
|
+
"types": "./backend.d.ts",
|
|
38
|
+
"import": "./backend.js"
|
|
39
|
+
},
|
|
40
|
+
"./style.css": "./style.css",
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"root.js",
|
|
45
|
+
"root.d.ts",
|
|
46
|
+
"index.js",
|
|
47
|
+
"index.d.ts",
|
|
48
|
+
"full.js",
|
|
49
|
+
"backend.js",
|
|
50
|
+
"backend.d.ts",
|
|
51
|
+
"serverToolContract.d.ts",
|
|
52
|
+
"serverToolInputs.generated.d.ts",
|
|
53
|
+
"style.css",
|
|
54
|
+
"chunks",
|
|
55
|
+
"assets",
|
|
56
|
+
"README.md",
|
|
57
|
+
"CHANGELOG.md",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"THIRD-PARTY-NOTICES.md",
|
|
60
|
+
"FONT-LICENSE-LIBERATION.txt",
|
|
61
|
+
"FONT-LICENSE-NOTO-SANS-SC.txt",
|
|
62
|
+
"FONT-LICENSE-NOTO-MULTILINGUAL.txt",
|
|
63
|
+
"FONT-LICENSE-NOTO.txt",
|
|
64
|
+
"FONT-LICENSE-HAN-EXT-B.txt",
|
|
65
|
+
"FONT-LICENSE-SOURCE-SERIF-4.txt",
|
|
66
|
+
"FONT-LICENSE-SOURCE-CODE-PRO.txt",
|
|
67
|
+
"FONT-LICENSE-KATEX.txt"
|
|
68
|
+
],
|
|
69
|
+
"sideEffects": [
|
|
70
|
+
"*.css"
|
|
71
|
+
],
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"react": ">=18",
|
|
74
|
+
"react-dom": ">=18",
|
|
75
|
+
"yjs": "^13.6.0",
|
|
76
|
+
"y-protocols": "^1.0.6",
|
|
77
|
+
"jsdom": ">=22"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"jsdom": {
|
|
81
|
+
"optional": true
|
|
31
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=18"
|
|
86
|
+
},
|
|
87
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
88
|
+
"homepage": "https://revise.io",
|
|
89
|
+
"bugs": {
|
|
90
|
+
"email": "sdk@revise.io",
|
|
91
|
+
"url": "https://developer.revise.io/editor-sdk/support"
|
|
92
|
+
},
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"access": "public"
|
|
95
|
+
},
|
|
96
|
+
"scripts": {
|
|
97
|
+
"prepublishOnly": "node -e \"if(process.env.REVISE_SDK_VERIFIED_PUBLISH!=='1'){console.error('Refusing to publish: use npm run publish:sdk in frontend/, which audits the exact tarball first.');process.exit(1)}\""
|
|
98
|
+
}
|
|
32
99
|
}
|
package/root.d.ts
ADDED
package/root.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical tool contract, shared by both surfaces. The `Server` prefix
|
|
3
|
+
* marks the headless origin of these types, but since 1.0.0 the browser
|
|
4
|
+
* surface (`editor.tools`) speaks exactly the same envelope: `execute()`
|
|
5
|
+
* returns the same discriminated `ReviseToolResult`, `call()` throws the same
|
|
6
|
+
* `ReviseToolError`, and inputs are typed by the same generated map. Hosts
|
|
7
|
+
* can share result-handling code between web and Node verbatim.
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
ReviseJsonObject,
|
|
11
|
+
ReviseJsonValue,
|
|
12
|
+
ReviseToolInput,
|
|
13
|
+
ReviseToolName,
|
|
14
|
+
} from "./serverToolInputs.generated.js";
|
|
15
|
+
|
|
16
|
+
export type {
|
|
17
|
+
ReviseJsonObject,
|
|
18
|
+
ReviseJsonPrimitive,
|
|
19
|
+
ReviseJsonValue,
|
|
20
|
+
ReviseToolInput,
|
|
21
|
+
ReviseToolInputMap,
|
|
22
|
+
ReviseToolName,
|
|
23
|
+
} from "./serverToolInputs.generated.js";
|
|
24
|
+
|
|
25
|
+
export type ServerDocumentMode = "editing" | "suggesting";
|
|
26
|
+
|
|
27
|
+
export interface ServerDocumentSessionOptions {
|
|
28
|
+
documentId: string;
|
|
29
|
+
/**
|
|
30
|
+
* Initial mode; the session's mode methods can change it later. Defaults to
|
|
31
|
+
* "suggesting" — the same posture as the browser surface, and the safe one:
|
|
32
|
+
* a service proposes tracked changes unless it explicitly opts into
|
|
33
|
+
* applying edits directly.
|
|
34
|
+
*/
|
|
35
|
+
mode?: ServerDocumentMode;
|
|
36
|
+
searchPageSize?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ReviseToolCallOptions {
|
|
40
|
+
/** Apply this mutation directly, even when the session is suggesting. */
|
|
41
|
+
directMode?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Discriminant of a pending tracked-suggestion record. */
|
|
45
|
+
export type ReviseSuggestionType =
|
|
46
|
+
| "inline-text"
|
|
47
|
+
| "inline-format"
|
|
48
|
+
| "block-change"
|
|
49
|
+
| "block-insert"
|
|
50
|
+
| "block-delete"
|
|
51
|
+
| "table-change"
|
|
52
|
+
| "paragraph-split"
|
|
53
|
+
| "paragraph-merge";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One pending tracked-suggestion record, projected for host review flows.
|
|
57
|
+
* Metadata fields are absent when the underlying record predates uniform
|
|
58
|
+
* authorship stamping or was written by an older client.
|
|
59
|
+
*/
|
|
60
|
+
export interface ReviseSuggestionRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
/** Absent when only stamped content marks carry the suggestion, which is
|
|
63
|
+
* the norm for inline text edits and for restored documents. */
|
|
64
|
+
type?: ReviseSuggestionType;
|
|
65
|
+
/** The top-level block the suggestion targets, for block-scoped types. */
|
|
66
|
+
blockId?: string;
|
|
67
|
+
/** The table the suggestion targets, for table-change records. */
|
|
68
|
+
tableId?: string;
|
|
69
|
+
authorType?: "ai" | "human";
|
|
70
|
+
/** Author display name: an agent name or a human's display name. */
|
|
71
|
+
agentName?: string;
|
|
72
|
+
/** Provider-qualified model that authored an AI suggestion. */
|
|
73
|
+
agentModel?: string;
|
|
74
|
+
source?: string;
|
|
75
|
+
label?: string;
|
|
76
|
+
createdAt?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Per-ID outcome of an accept or reject call. IDs a host persisted from an
|
|
81
|
+
* earlier tool result can go stale — a later suggestion can supersede an
|
|
82
|
+
* earlier one — so the settled and unknown sets are reported explicitly
|
|
83
|
+
* instead of an inferred count.
|
|
84
|
+
*/
|
|
85
|
+
export interface ReviseSuggestionDecision {
|
|
86
|
+
/** Requested IDs that were pending and are now settled. */
|
|
87
|
+
resolved: string[];
|
|
88
|
+
/** Requested IDs that were not pending suggestions when the call ran. */
|
|
89
|
+
missing: string[];
|
|
90
|
+
/** Requested IDs that were pending but could not be settled. Rare. */
|
|
91
|
+
unresolved: string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ReviseToolDefinition<
|
|
95
|
+
Name extends ReviseToolName = ReviseToolName,
|
|
96
|
+
> {
|
|
97
|
+
name: Name;
|
|
98
|
+
description: string;
|
|
99
|
+
inputSchema: ReviseJsonObject;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ReviseReadCoverage {
|
|
103
|
+
requestedBlockCount: number;
|
|
104
|
+
readBlocksThisTurn: number;
|
|
105
|
+
readTokenBudgetMax: number;
|
|
106
|
+
requestedRanges: Array<{ start: number; end: number }>;
|
|
107
|
+
fullDocumentLoaded: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface ReviseReadData {
|
|
111
|
+
kind: "read_context";
|
|
112
|
+
tool: "read_blocks_from_index" | "read_specific_blocks";
|
|
113
|
+
loaded: ReviseJsonObject;
|
|
114
|
+
next: { index: number; blockId?: string } | null;
|
|
115
|
+
endOfDocument: boolean;
|
|
116
|
+
coverage: ReviseReadCoverage;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ReviseSearchMatch {
|
|
120
|
+
blockId: string;
|
|
121
|
+
blockIndex: number;
|
|
122
|
+
matchedQueries?: string[];
|
|
123
|
+
matchedColors?: string[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface ReviseSearchData {
|
|
127
|
+
kind: "search_context";
|
|
128
|
+
tool: "search_document" | "find_highlights";
|
|
129
|
+
queries?: string[];
|
|
130
|
+
color?: string;
|
|
131
|
+
totalMatches: number;
|
|
132
|
+
search_result_id?: string;
|
|
133
|
+
page: {
|
|
134
|
+
current: number;
|
|
135
|
+
total: number;
|
|
136
|
+
startResult: number;
|
|
137
|
+
endResult: number;
|
|
138
|
+
};
|
|
139
|
+
nextPage: number | null;
|
|
140
|
+
matches: ReviseSearchMatch[];
|
|
141
|
+
coverage: ReviseReadCoverage;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ReviseDocumentMeasurementSection {
|
|
145
|
+
startIndex: number;
|
|
146
|
+
endIndex: number;
|
|
147
|
+
startBlockId: string;
|
|
148
|
+
endBlockId: string;
|
|
149
|
+
headingLevel: 1 | 2 | 3;
|
|
150
|
+
title: string;
|
|
151
|
+
wordCount: number;
|
|
152
|
+
paragraphCount: number;
|
|
153
|
+
characterCount: number;
|
|
154
|
+
inclusive: true;
|
|
155
|
+
blockCount: number;
|
|
156
|
+
pageStart?: number;
|
|
157
|
+
pageEnd?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ReviseDocumentMeasurementData {
|
|
161
|
+
kind: "document_measurement";
|
|
162
|
+
tool: "measure_document";
|
|
163
|
+
inclusive: true;
|
|
164
|
+
totalBlocks: number;
|
|
165
|
+
wordCount: number;
|
|
166
|
+
paragraphCount: number;
|
|
167
|
+
characterCount: number;
|
|
168
|
+
pageCount?: number;
|
|
169
|
+
fractionalPageCount?: number;
|
|
170
|
+
sections?: ReviseDocumentMeasurementSection[];
|
|
171
|
+
sectionCount?: number;
|
|
172
|
+
sectionOffset?: number;
|
|
173
|
+
sectionLimit?: number;
|
|
174
|
+
returnedSectionCount?: number;
|
|
175
|
+
hasMoreSections?: boolean;
|
|
176
|
+
nextSectionOffset?: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface ReviseMeasuredBlockRange {
|
|
180
|
+
startIndex: number;
|
|
181
|
+
endIndex: number;
|
|
182
|
+
startBlockId: string;
|
|
183
|
+
endBlockId: string;
|
|
184
|
+
inclusive: true;
|
|
185
|
+
blockCount: number;
|
|
186
|
+
wordCount: number;
|
|
187
|
+
paragraphCount: number;
|
|
188
|
+
characterCount: number;
|
|
189
|
+
pageStart?: number;
|
|
190
|
+
pageEnd?: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface ReviseBlockMeasurementData {
|
|
194
|
+
kind: "document_measurement";
|
|
195
|
+
tool: "measure_blocks";
|
|
196
|
+
inclusive: true;
|
|
197
|
+
totalBlocks: number;
|
|
198
|
+
ranges: ReviseMeasuredBlockRange[];
|
|
199
|
+
errors: Array<{
|
|
200
|
+
startBlockId?: string;
|
|
201
|
+
endBlockId?: string;
|
|
202
|
+
error: string;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface ReviseMutationData {
|
|
207
|
+
tool: string;
|
|
208
|
+
target_reference?: string;
|
|
209
|
+
summary?: string;
|
|
210
|
+
effect: {
|
|
211
|
+
requested_target_count: number;
|
|
212
|
+
changed_target_count: number;
|
|
213
|
+
removed_target_count: number;
|
|
214
|
+
inserted_block_count: number;
|
|
215
|
+
top_level_blocks_before: number;
|
|
216
|
+
top_level_blocks_after: number;
|
|
217
|
+
[key: string]: ReviseJsonValue;
|
|
218
|
+
};
|
|
219
|
+
before_block?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface ReviseCommentData {
|
|
223
|
+
commentId: string;
|
|
224
|
+
blockId: string;
|
|
225
|
+
anchor: ReviseJsonObject;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type ReviseReadToolName = "read_blocks_from_index" | "read_specific_blocks";
|
|
229
|
+
type ReviseSearchToolName = "search_document" | "find_highlights";
|
|
230
|
+
type ReviseMeasurementToolName = "measure_document" | "measure_blocks";
|
|
231
|
+
type ReviseSpecializedToolName =
|
|
232
|
+
| ReviseReadToolName
|
|
233
|
+
| ReviseSearchToolName
|
|
234
|
+
| ReviseMeasurementToolName
|
|
235
|
+
| "leave_comment";
|
|
236
|
+
type ReviseMutationToolName = Exclude<
|
|
237
|
+
ReviseToolName,
|
|
238
|
+
ReviseSpecializedToolName
|
|
239
|
+
>;
|
|
240
|
+
|
|
241
|
+
export type ReviseToolDataMap = {
|
|
242
|
+
[Name in ReviseReadToolName]: ReviseReadData;
|
|
243
|
+
} & {
|
|
244
|
+
[Name in ReviseSearchToolName]: ReviseSearchData;
|
|
245
|
+
} & {
|
|
246
|
+
measure_document: ReviseDocumentMeasurementData;
|
|
247
|
+
measure_blocks: ReviseBlockMeasurementData;
|
|
248
|
+
leave_comment: ReviseCommentData;
|
|
249
|
+
} & {
|
|
250
|
+
[Name in ReviseMutationToolName]: ReviseMutationData | null;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type ReviseToolData<Name extends ReviseToolName> =
|
|
254
|
+
ReviseToolDataMap[Name];
|
|
255
|
+
|
|
256
|
+
/** Tool arguments, with input optional only when its schema has no required fields. */
|
|
257
|
+
export type ReviseToolArguments<Name extends ReviseToolName> =
|
|
258
|
+
Record<string, never> extends ReviseToolInput<Name>
|
|
259
|
+
? [input?: ReviseToolInput<Name>, options?: ReviseToolCallOptions]
|
|
260
|
+
: [input: ReviseToolInput<Name>, options?: ReviseToolCallOptions];
|
|
261
|
+
|
|
262
|
+
/** Semantic document context returned by read and search calls. */
|
|
263
|
+
export interface ReviseDocumentContext {
|
|
264
|
+
format: "revise-html";
|
|
265
|
+
html: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** A successful tool call, ready for application code or a model transcript. */
|
|
269
|
+
export interface ReviseToolResponse<Name extends string = ReviseToolName> {
|
|
270
|
+
callId: string;
|
|
271
|
+
tool: Name;
|
|
272
|
+
/** Concise model-oriented summary of what happened. */
|
|
273
|
+
message: string | null;
|
|
274
|
+
/** Tool-specific structured data. Literal tool names infer this type. */
|
|
275
|
+
data: Name extends ReviseToolName
|
|
276
|
+
? ReviseToolData<Name>
|
|
277
|
+
: ReviseJsonValue | null;
|
|
278
|
+
/** Block-ID-preserving semantic HTML, when the call loaded document text. */
|
|
279
|
+
context: ReviseDocumentContext | null;
|
|
280
|
+
/**
|
|
281
|
+
* For mutation tools, the tracked suggestion records this call created:
|
|
282
|
+
* non-empty only in suggesting mode. Empty when the edit applied directly,
|
|
283
|
+
* changed nothing, or extended an existing pending suggestion instead of
|
|
284
|
+
* creating its own record. Null for read, search, and measurement tools.
|
|
285
|
+
*/
|
|
286
|
+
suggestionIds: string[] | null;
|
|
287
|
+
/**
|
|
288
|
+
* Image payload from browser-only tools (`view_image`). Never present on
|
|
289
|
+
* the server surface, whose sessions exclude the image pipeline.
|
|
290
|
+
*/
|
|
291
|
+
image?: {
|
|
292
|
+
id: string;
|
|
293
|
+
fileName?: string;
|
|
294
|
+
urls?: string[];
|
|
295
|
+
dimensions?: Array<{ width: number; height: number }>;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** An expected tool rejection: invalid input, stale context, or unavailable tool. */
|
|
300
|
+
export interface ReviseToolFailure<Name extends string = ReviseToolName> {
|
|
301
|
+
callId: string;
|
|
302
|
+
tool: Name;
|
|
303
|
+
code: string;
|
|
304
|
+
message: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export type ReviseToolResult<Name extends string = ReviseToolName> =
|
|
308
|
+
| { ok: true; value: ReviseToolResponse<Name> }
|
|
309
|
+
| { ok: false; error: ReviseToolFailure<Name> };
|
|
310
|
+
|
|
311
|
+
export interface ServerDocumentTools {
|
|
312
|
+
getDefinitions(): ReviseToolDefinition[];
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Execute a known tool and preserve expected failures as a discriminated
|
|
316
|
+
* result. Environment and disposed-session errors still reject the promise.
|
|
317
|
+
*/
|
|
318
|
+
execute<Name extends ReviseToolName>(
|
|
319
|
+
name: Name,
|
|
320
|
+
...args: ReviseToolArguments<Name>
|
|
321
|
+
): Promise<ReviseToolResult<Name>>;
|
|
322
|
+
|
|
323
|
+
/** Execute an untrusted model-provided name and JSON input. */
|
|
324
|
+
executeDynamic(
|
|
325
|
+
name: string,
|
|
326
|
+
input?: ReviseJsonObject,
|
|
327
|
+
options?: ReviseToolCallOptions,
|
|
328
|
+
): Promise<ReviseToolResult<string>>;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Convenient application-code form. Returns only the successful response
|
|
332
|
+
* and throws ReviseToolError when the tool rejects the call.
|
|
333
|
+
*/
|
|
334
|
+
call<Name extends ReviseToolName>(
|
|
335
|
+
name: Name,
|
|
336
|
+
...args: ReviseToolArguments<Name>
|
|
337
|
+
): Promise<ReviseToolResponse<Name>>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface ServerDocumentSession {
|
|
341
|
+
/** Return the mode subsequent mutations will capture. */
|
|
342
|
+
getMode(): ServerDocumentMode;
|
|
343
|
+
/** Make subsequent mutations produce tracked suggestions. */
|
|
344
|
+
setSuggestingMode(): void;
|
|
345
|
+
/** Make subsequent mutations apply directly. */
|
|
346
|
+
setEditingMode(): void;
|
|
347
|
+
readonly tools: ServerDocumentTools;
|
|
348
|
+
/** IDs of pending tracked suggestions currently stored in the Y.Doc. */
|
|
349
|
+
getPendingSuggestionIds(): string[];
|
|
350
|
+
/**
|
|
351
|
+
* Every pending tracked suggestion in the Y.Doc as a reviewable record —
|
|
352
|
+
* including collaborators' suggestions in a shared document. Filter by
|
|
353
|
+
* author metadata before making bulk decisions on someone else's work.
|
|
354
|
+
*/
|
|
355
|
+
listSuggestions(): ReviseSuggestionRecord[];
|
|
356
|
+
/**
|
|
357
|
+
* Accept specific pending suggestions by ID — the primary review path.
|
|
358
|
+
* Collect IDs from mutation results' `suggestionIds` or from
|
|
359
|
+
* `listSuggestions()`.
|
|
360
|
+
*/
|
|
361
|
+
acceptSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
|
|
362
|
+
/** Reject specific pending suggestions by ID. */
|
|
363
|
+
rejectSuggestions(suggestionIds: string[]): ReviseSuggestionDecision;
|
|
364
|
+
/**
|
|
365
|
+
* Accept every pending suggestion in the Y.Doc, including collaborators'.
|
|
366
|
+
* Prefer `acceptSuggestions(ids)` unless the host owns the whole document.
|
|
367
|
+
*/
|
|
368
|
+
acceptAllSuggestions(): ReviseSuggestionDecision;
|
|
369
|
+
/** Reject every pending suggestion in the Y.Doc, including collaborators'. */
|
|
370
|
+
rejectAllSuggestions(): ReviseSuggestionDecision;
|
|
371
|
+
/** Release observers without destroying the supplied Y.Doc. */
|
|
372
|
+
dispose(): void;
|
|
373
|
+
}
|