wiki-graph 0.3.0 → 0.4.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/README.md +10 -271
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2983 -4
- package/dist/cli.js.map +1 -0
- package/{data → dist/data}/editor/text_compressor.jinja +17 -13
- package/{data → dist/data}/help/commands/archive/next.jinja +7 -2
- package/{data → dist/data}/help/commands/gc.jinja +2 -1
- package/{data → dist/data}/help/commands/legacy/migrate.jinja +6 -1
- package/{data → dist/data}/help/commands/legacy.jinja +3 -2
- package/dist/data/help/commands/library-predicate.jinja +296 -0
- package/dist/data/help/commands/library.jinja +235 -0
- package/{data → dist/data}/help/commands/maintenance/chapter/add.jinja +3 -3
- package/{data → dist/data}/help/commands/maintenance/chapter/list.jinja +4 -4
- package/{data → dist/data}/help/commands/maintenance/chapter/move.jinja +4 -4
- package/{data → dist/data}/help/commands/maintenance/chapter/remove.jinja +1 -1
- package/{data → dist/data}/help/commands/maintenance/chapter/reset.jinja +1 -1
- package/{data → dist/data}/help/commands/maintenance/chapter/set-source.jinja +2 -2
- package/{data → dist/data}/help/commands/maintenance/chapter/set-summary.jinja +1 -1
- package/{data → dist/data}/help/commands/maintenance/chapter/set-title.jinja +3 -3
- package/{data → dist/data}/help/commands/maintenance/chapter/tree.jinja +6 -6
- package/{data → dist/data}/help/commands/maintenance/chapter.jinja +10 -10
- package/{data → dist/data}/help/commands/maintenance/meta.jinja +7 -7
- package/dist/data/help/commands/maintenance/upgrade.jinja +35 -0
- package/dist/data/help/commands/maintenance.jinja +23 -0
- package/{data → dist/data}/help/commands/predicate.jinja +204 -28
- package/{data → dist/data}/help/commands/root.jinja +10 -3
- package/{data → dist/data}/help/commands/uri.jinja +165 -6
- package/{data → dist/data}/help/topics/config.jinja +10 -3
- package/dist/data/help/topics/library.jinja +87 -0
- package/{data → dist/data}/help/topics/readiness.jinja +32 -2
- package/{data → dist/data}/help/topics/recipe.jinja +42 -17
- package/{data → dist/data}/help/topics/runtime.jinja +20 -3
- package/{data → dist/data}/help/topics/uri.jinja +51 -25
- package/dist/gc-worker.d.ts +1 -0
- package/dist/gc-worker.js +548 -0
- package/dist/gc-worker.js.map +1 -0
- package/dist/index.cjs +12463 -19690
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -842
- package/dist/index.d.ts +36 -842
- package/dist/index.js +13871 -9
- package/dist/index.js.map +1 -0
- package/dist/queue-worker.d.ts +1 -0
- package/dist/queue-worker.js +2110 -0
- package/dist/queue-worker.js.map +1 -0
- package/package.json +18 -45
- package/dist/cli.cjs +0 -41734
- package/dist/cli.cjs.map +0 -1
- package/docs/images/flowchart.excalidraw +0 -3293
- package/docs/images/flowchart.svg +0 -4
- package/docs/images/terminal-cn.png +0 -0
- package/docs/images/terminal-en.png +0 -0
- package/docs/wikispine-runtime.md +0 -143
- /package/{data → dist/data}/editor/clue_reviewer.jinja +0 -0
- /package/{data → dist/data}/editor/clue_reviewer_generator.jinja +0 -0
- /package/{data → dist/data}/editor/revision_feedback.jinja +0 -0
- /package/{data → dist/data}/guaranteed/response_intent_classifier.jinja +0 -0
- /package/{data → dist/data}/help/commands/maintenance/cover.jinja +0 -0
- /package/{data → dist/data}/help/commands/transform.jinja +0 -0
- /package/{data → dist/data}/help/topics/format.jinja +0 -0
- /package/{data → dist/data}/output/epub/cover.xhtml.jinja +0 -0
- /package/{data → dist/data}/output/epub/nav.xhtml.jinja +0 -0
- /package/{data → dist/data}/output/epub/package.opf.xml.jinja +0 -0
- /package/{data → dist/data}/output/epub/section.xhtml.jinja +0 -0
- /package/{data → dist/data}/topologization/book_coherence_extraction.jinja +0 -0
- /package/{data → dist/data}/topologization/chunk_extraction.jinja +0 -0
- /package/{data → dist/data}/topologization/evidence_choice.jinja +0 -0
- /package/{data → dist/data}/topologization/translate_chunks.jinja +0 -0
- /package/{data → dist/data}/topologization/user_focused_extraction.jinja +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,842 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
French = "fr",
|
|
38
|
-
German = "de",
|
|
39
|
-
Hindi = "hi",
|
|
40
|
-
Indonesian = "id",
|
|
41
|
-
Italian = "it",
|
|
42
|
-
Japanese = "ja",
|
|
43
|
-
Korean = "ko",
|
|
44
|
-
Norwegian = "no",
|
|
45
|
-
Polish = "pl",
|
|
46
|
-
Portuguese = "pt",
|
|
47
|
-
Russian = "ru",
|
|
48
|
-
Spanish = "es",
|
|
49
|
-
Swedish = "sv",
|
|
50
|
-
Thai = "th",
|
|
51
|
-
Turkish = "tr",
|
|
52
|
-
Vietnamese = "vi"
|
|
53
|
-
}
|
|
54
|
-
declare function getLanguageCode(language: Language): LanguageCode;
|
|
55
|
-
declare function formatLanguageForPrompt(code: LanguageCode): Language;
|
|
56
|
-
declare function normalizeLanguageCode(language: Language | string | null | undefined): LanguageCode | undefined;
|
|
57
|
-
declare function getWikipageLanguageCode(language: Language | string | null | undefined): "en" | "zh" | undefined;
|
|
58
|
-
|
|
59
|
-
declare const SPINE_DIGEST_CONTEXT_VERSION = 1;
|
|
60
|
-
declare const TASK_STATUS_VERSION = 1;
|
|
61
|
-
type SpineDigestTaskType = "source-to-graph" | "source-graph-to-summary";
|
|
62
|
-
interface SpineDigestTaskIdentity {
|
|
63
|
-
readonly normalizedSource: string;
|
|
64
|
-
readonly parameters: unknown;
|
|
65
|
-
readonly taskType: SpineDigestTaskType;
|
|
66
|
-
readonly version?: number;
|
|
67
|
-
}
|
|
68
|
-
interface SpineDigestTaskContextOptions {
|
|
69
|
-
readonly rootDirPath: string;
|
|
70
|
-
}
|
|
71
|
-
interface TaskStatus {
|
|
72
|
-
readonly completedAt?: string | undefined;
|
|
73
|
-
readonly startedAt: string;
|
|
74
|
-
readonly status: "running" | "succeeded";
|
|
75
|
-
readonly version: typeof TASK_STATUS_VERSION;
|
|
76
|
-
}
|
|
77
|
-
declare class SpineDigestTaskContext {
|
|
78
|
-
#private;
|
|
79
|
-
constructor(options: SpineDigestTaskContextOptions);
|
|
80
|
-
createTask(identity: SpineDigestTaskIdentity): SpineDigestTask;
|
|
81
|
-
runTask<T>(identity: SpineDigestTaskIdentity, operation: (task: SpineDigestTask) => Promise<T> | T): Promise<T>;
|
|
82
|
-
}
|
|
83
|
-
declare class SpineDigestTask {
|
|
84
|
-
#private;
|
|
85
|
-
constructor(id: string, path: string);
|
|
86
|
-
get artifactDirPath(): string;
|
|
87
|
-
get id(): string;
|
|
88
|
-
get path(): string;
|
|
89
|
-
readStatus(): Promise<TaskStatus | undefined>;
|
|
90
|
-
run<T>(operation: (task: SpineDigestTask) => Promise<T> | T): Promise<T>;
|
|
91
|
-
remove(): Promise<void>;
|
|
92
|
-
}
|
|
93
|
-
declare function createSpineDigestTaskId(identity: SpineDigestTaskIdentity): string;
|
|
94
|
-
|
|
95
|
-
type LLMessage = ModelMessage;
|
|
96
|
-
|
|
97
|
-
declare class LLMPaymentRequiredError extends Error {
|
|
98
|
-
readonly isRetryable = false;
|
|
99
|
-
readonly statusCode = 402;
|
|
100
|
-
constructor(message?: string, options?: ErrorOptions);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
type SqliteDatabase = Sqlite3Namespace.Database;
|
|
104
|
-
type SqlBindValue = Buffer | Uint8Array | number | string | null;
|
|
105
|
-
type SqlBindParams = readonly SqlBindValue[];
|
|
106
|
-
type SqlRowValue = SqlBindValue;
|
|
107
|
-
type SqlRow = Record<string, SqlRowValue>;
|
|
108
|
-
declare class Database {
|
|
109
|
-
#private;
|
|
110
|
-
constructor(database: SqliteDatabase, options?: {
|
|
111
|
-
readonly onWrite?: () => void;
|
|
112
|
-
});
|
|
113
|
-
static open(databasePath: string, schemaSql?: string, options?: {
|
|
114
|
-
readonly onWrite?: () => void;
|
|
115
|
-
readonly readonly?: boolean;
|
|
116
|
-
}): Promise<Database>;
|
|
117
|
-
static initialize(databasePath: string, schemaSql: string): Promise<void>;
|
|
118
|
-
queryAll<T>(sql: string, params: SqlBindParams | undefined, mapRow: (row: SqlRow) => T): Promise<T[]>;
|
|
119
|
-
queryOne<T>(sql: string, params: SqlBindParams | undefined, mapRow: (row: SqlRow) => T): Promise<T | undefined>;
|
|
120
|
-
run(sql: string, params?: SqlBindParams): Promise<void>;
|
|
121
|
-
transaction<T>(operation: () => Promise<T> | T): Promise<T>;
|
|
122
|
-
flush(): Promise<void>;
|
|
123
|
-
close(): Promise<void>;
|
|
124
|
-
getLastInsertRowId(): Promise<number>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
declare enum ChunkRetention {
|
|
128
|
-
Verbatim = "verbatim",
|
|
129
|
-
Detailed = "detailed",
|
|
130
|
-
Focused = "focused",
|
|
131
|
-
Relevant = "relevant"
|
|
132
|
-
}
|
|
133
|
-
declare enum ChunkImportance {
|
|
134
|
-
Critical = "critical",
|
|
135
|
-
Important = "important",
|
|
136
|
-
Helpful = "helpful"
|
|
137
|
-
}
|
|
138
|
-
type SentenceId = readonly [chapterId: number, sentenceIndex: number];
|
|
139
|
-
interface SentenceRecord {
|
|
140
|
-
readonly text: string;
|
|
141
|
-
readonly wordsCount: number;
|
|
142
|
-
}
|
|
143
|
-
interface FragmentRecord {
|
|
144
|
-
readonly serialId: number;
|
|
145
|
-
readonly fragmentId: number;
|
|
146
|
-
readonly summary: string;
|
|
147
|
-
readonly sentences: readonly SentenceRecord[];
|
|
148
|
-
}
|
|
149
|
-
interface SerialRecord {
|
|
150
|
-
readonly documentOrder: number;
|
|
151
|
-
readonly knowledgeGraphReady: boolean;
|
|
152
|
-
readonly knowledgeGraphParameterHash?: string;
|
|
153
|
-
readonly id: number;
|
|
154
|
-
readonly revision: number;
|
|
155
|
-
readonly topologyParameterHash?: string;
|
|
156
|
-
readonly topologyReady: boolean;
|
|
157
|
-
}
|
|
158
|
-
interface GraphBuildParameterRecord {
|
|
159
|
-
readonly createdAt: string;
|
|
160
|
-
readonly hash: string;
|
|
161
|
-
readonly language?: string;
|
|
162
|
-
readonly prompt: string;
|
|
163
|
-
}
|
|
164
|
-
interface ChunkRecord {
|
|
165
|
-
readonly id: number;
|
|
166
|
-
readonly generation: number;
|
|
167
|
-
readonly sentenceId: SentenceId;
|
|
168
|
-
readonly label: string;
|
|
169
|
-
readonly content: string;
|
|
170
|
-
readonly sentenceIds: readonly SentenceId[];
|
|
171
|
-
readonly retention?: ChunkRetention;
|
|
172
|
-
readonly importance?: ChunkImportance;
|
|
173
|
-
readonly wordsCount: number;
|
|
174
|
-
readonly weight: number;
|
|
175
|
-
}
|
|
176
|
-
interface ReadingEdgeRecord {
|
|
177
|
-
readonly fromId: number;
|
|
178
|
-
readonly toId: number;
|
|
179
|
-
readonly strength?: string;
|
|
180
|
-
readonly weight: number;
|
|
181
|
-
}
|
|
182
|
-
interface MentionRecord {
|
|
183
|
-
readonly id: string;
|
|
184
|
-
readonly chapterId: number;
|
|
185
|
-
readonly fragmentId?: number;
|
|
186
|
-
readonly sentenceIndex?: number;
|
|
187
|
-
readonly rangeStart: number;
|
|
188
|
-
readonly rangeEnd: number;
|
|
189
|
-
readonly surface: string;
|
|
190
|
-
readonly qid: string;
|
|
191
|
-
readonly confidence?: number;
|
|
192
|
-
readonly note?: string;
|
|
193
|
-
}
|
|
194
|
-
interface MentionLinkRecord {
|
|
195
|
-
readonly id: string;
|
|
196
|
-
readonly sourceMentionId: string;
|
|
197
|
-
readonly targetMentionId: string;
|
|
198
|
-
readonly predicate: string;
|
|
199
|
-
readonly evidenceSentenceIds: readonly SentenceId[];
|
|
200
|
-
readonly confidence?: number;
|
|
201
|
-
readonly note?: string;
|
|
202
|
-
}
|
|
203
|
-
interface SnakeRecord {
|
|
204
|
-
readonly id: number;
|
|
205
|
-
readonly serialId: number;
|
|
206
|
-
readonly groupId: number;
|
|
207
|
-
readonly localSnakeId: number;
|
|
208
|
-
readonly size: number;
|
|
209
|
-
readonly firstLabel: string;
|
|
210
|
-
readonly lastLabel: string;
|
|
211
|
-
readonly wordsCount: number;
|
|
212
|
-
readonly weight: number;
|
|
213
|
-
}
|
|
214
|
-
interface SnakeChunkRecord {
|
|
215
|
-
readonly snakeId: number;
|
|
216
|
-
readonly chunkId: number;
|
|
217
|
-
readonly position: number;
|
|
218
|
-
}
|
|
219
|
-
interface SnakeEdgeRecord {
|
|
220
|
-
readonly fromSnakeId: number;
|
|
221
|
-
readonly toSnakeId: number;
|
|
222
|
-
readonly weight: number;
|
|
223
|
-
}
|
|
224
|
-
interface SentenceGroupRecord {
|
|
225
|
-
readonly serialId: number;
|
|
226
|
-
readonly groupId: number;
|
|
227
|
-
readonly startSentenceIndex: number;
|
|
228
|
-
readonly endSentenceIndex: number;
|
|
229
|
-
readonly fragmentId?: number;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
interface ReadonlySerialTextStream {
|
|
233
|
-
getFragment(fragmentId: number): Promise<FragmentRecord>;
|
|
234
|
-
getSentence?(sentenceIndex: number): Promise<SentenceRecord>;
|
|
235
|
-
listSentencesInRange?(startSentenceIndex: number, endSentenceIndex: number): Promise<readonly SentenceRecord[]>;
|
|
236
|
-
listFragmentIds(): Promise<readonly number[]>;
|
|
237
|
-
listSentences?(): Promise<readonly SentenceRecord[]>;
|
|
238
|
-
readText?(): Promise<string | undefined>;
|
|
239
|
-
readTextInRange?(startSentenceIndex: number, endSentenceIndex: number): Promise<string | undefined>;
|
|
240
|
-
readonly path: string;
|
|
241
|
-
readonly serialId: number;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
declare const bookMetaSchema: z.ZodObject<{
|
|
245
|
-
version: z.ZodLiteral<1>;
|
|
246
|
-
sourceFormat: z.ZodEnum<{
|
|
247
|
-
epub: "epub";
|
|
248
|
-
pdf: "pdf";
|
|
249
|
-
txt: "txt";
|
|
250
|
-
markdown: "markdown";
|
|
251
|
-
}>;
|
|
252
|
-
title: z.ZodNullable<z.ZodString>;
|
|
253
|
-
authors: z.ZodArray<z.ZodString>;
|
|
254
|
-
language: z.ZodNullable<z.ZodString>;
|
|
255
|
-
identifier: z.ZodNullable<z.ZodString>;
|
|
256
|
-
publisher: z.ZodNullable<z.ZodString>;
|
|
257
|
-
publishedAt: z.ZodNullable<z.ZodString>;
|
|
258
|
-
description: z.ZodNullable<z.ZodString>;
|
|
259
|
-
}, z.core.$strip>;
|
|
260
|
-
type BookMeta = z.infer<typeof bookMetaSchema>;
|
|
261
|
-
|
|
262
|
-
interface TocItem {
|
|
263
|
-
readonly title?: string | null | undefined;
|
|
264
|
-
readonly serialId?: number | undefined;
|
|
265
|
-
readonly children: readonly TocItem[];
|
|
266
|
-
}
|
|
267
|
-
declare const tocFileSchema: z.ZodObject<{
|
|
268
|
-
version: z.ZodLiteral<1>;
|
|
269
|
-
items: z.ZodArray<z.ZodType<TocItem, unknown, z.core.$ZodTypeInternals<TocItem, unknown>>>;
|
|
270
|
-
}, z.core.$strip>;
|
|
271
|
-
type TocFile = z.infer<typeof tocFileSchema>;
|
|
272
|
-
|
|
273
|
-
interface SourceAsset {
|
|
274
|
-
readonly path: string;
|
|
275
|
-
readonly mediaType: string;
|
|
276
|
-
readonly data: Uint8Array;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
interface ReadonlySerialStore {
|
|
280
|
-
getById(serialId: number): Promise<SerialRecord | undefined>;
|
|
281
|
-
getRevision(serialId: number): Promise<number>;
|
|
282
|
-
getRevisions(serialIds: readonly number[]): Promise<ReadonlyMap<number, number>>;
|
|
283
|
-
getMaxId(): Promise<number>;
|
|
284
|
-
getChaptersRevision(): Promise<number>;
|
|
285
|
-
listIds(): Promise<number[]>;
|
|
286
|
-
listDocumentOrders(): Promise<ReadonlyMap<number, number>>;
|
|
287
|
-
}
|
|
288
|
-
interface ReadonlyGraphBuildParameterStore {
|
|
289
|
-
getByHash(hash: string): Promise<GraphBuildParameterRecord | undefined>;
|
|
290
|
-
}
|
|
291
|
-
interface ReadonlyChunkStore {
|
|
292
|
-
countAll(): Promise<number>;
|
|
293
|
-
getById(chunkId: number): Promise<ChunkRecord | undefined>;
|
|
294
|
-
listAll(): Promise<ChunkRecord[]>;
|
|
295
|
-
listBySentenceStartIndexes(serialId: number, sentenceStartIndexes: readonly number[]): Promise<ChunkRecord[]>;
|
|
296
|
-
listBySentenceRange(serialId: number, startSentenceIndex: number, endSentenceIndex: number): Promise<ChunkRecord[]>;
|
|
297
|
-
listBySerial(serialId: number): Promise<ChunkRecord[]>;
|
|
298
|
-
getMaxId(): Promise<number>;
|
|
299
|
-
listFragmentPairs(): Promise<ReadonlyArray<readonly [number, number]>>;
|
|
300
|
-
}
|
|
301
|
-
interface ReadonlyReadingEdgeStore {
|
|
302
|
-
countAll(): Promise<number>;
|
|
303
|
-
listAll(): Promise<ReadingEdgeRecord[]>;
|
|
304
|
-
listBySerial(serialId: number): Promise<ReadingEdgeRecord[]>;
|
|
305
|
-
listIncoming(chunkId: number): Promise<ReadingEdgeRecord[]>;
|
|
306
|
-
listOutgoing(chunkId: number): Promise<ReadingEdgeRecord[]>;
|
|
307
|
-
}
|
|
308
|
-
interface ReadonlyMentionStore {
|
|
309
|
-
getById(mentionId: string): Promise<MentionRecord | undefined>;
|
|
310
|
-
listAll(): Promise<MentionRecord[]>;
|
|
311
|
-
listBySurfaceTerms(terms: readonly string[]): Promise<MentionRecord[]>;
|
|
312
|
-
listBySurfaces(surfaces: readonly string[]): Promise<MentionRecord[]>;
|
|
313
|
-
listByQid(qid: string): Promise<MentionRecord[]>;
|
|
314
|
-
listByChapter(chapterId: number): Promise<MentionRecord[]>;
|
|
315
|
-
}
|
|
316
|
-
interface ReadonlyMentionLinkStore {
|
|
317
|
-
getById(linkId: string): Promise<MentionLinkRecord | undefined>;
|
|
318
|
-
listByTriple(input: {
|
|
319
|
-
readonly objectQid: string;
|
|
320
|
-
readonly predicate: string;
|
|
321
|
-
readonly subjectQid: string;
|
|
322
|
-
}): Promise<MentionLinkRecord[]>;
|
|
323
|
-
listByChapter(chapterId: number): Promise<MentionLinkRecord[]>;
|
|
324
|
-
}
|
|
325
|
-
interface ReadonlySnakeStore {
|
|
326
|
-
getById(snakeId: number): Promise<SnakeRecord | undefined>;
|
|
327
|
-
listIdsByGroup(serialId: number, groupId: number): Promise<number[]>;
|
|
328
|
-
listBySerial(serialId: number): Promise<SnakeRecord[]>;
|
|
329
|
-
}
|
|
330
|
-
interface ReadonlySnakeChunkStore {
|
|
331
|
-
listChunkIds(snakeId: number): Promise<number[]>;
|
|
332
|
-
listBySnake(snakeId: number): Promise<SnakeChunkRecord[]>;
|
|
333
|
-
}
|
|
334
|
-
interface ReadonlySnakeEdgeStore {
|
|
335
|
-
listIncoming(snakeId: number): Promise<SnakeEdgeRecord[]>;
|
|
336
|
-
listOutgoing(snakeId: number): Promise<SnakeEdgeRecord[]>;
|
|
337
|
-
listWithin(snakeIds: readonly number[]): Promise<SnakeEdgeRecord[]>;
|
|
338
|
-
listBySerial(serialId: number): Promise<SnakeEdgeRecord[]>;
|
|
339
|
-
}
|
|
340
|
-
interface ReadonlyFragmentGroupStore {
|
|
341
|
-
listBySerial(serialId: number): Promise<SentenceGroupRecord[]>;
|
|
342
|
-
listSerialIds(): Promise<number[]>;
|
|
343
|
-
listGroupIdsForSerial(serialId: number): Promise<number[]>;
|
|
344
|
-
}
|
|
345
|
-
interface ReadonlyObjectMetadataStore {
|
|
346
|
-
getMap(objectPath: string): Promise<Readonly<Record<string, unknown>>>;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
interface ReadonlyDocument {
|
|
350
|
-
readonly chunks: ReadonlyChunkStore;
|
|
351
|
-
readonly fragmentGroups: ReadonlyFragmentGroupStore;
|
|
352
|
-
readonly graphBuildParameters: ReadonlyGraphBuildParameterStore;
|
|
353
|
-
readonly readingEdges: ReadonlyReadingEdgeStore;
|
|
354
|
-
readonly mentionLinks: ReadonlyMentionLinkStore;
|
|
355
|
-
readonly mentions: ReadonlyMentionStore;
|
|
356
|
-
readonly metadata: ReadonlyObjectMetadataStore;
|
|
357
|
-
readonly serials: ReadonlySerialStore;
|
|
358
|
-
readonly snakeChunks: ReadonlySnakeChunkStore;
|
|
359
|
-
readonly snakeEdges: ReadonlySnakeEdgeStore;
|
|
360
|
-
readonly snakes: ReadonlySnakeStore;
|
|
361
|
-
getSentence(sentenceId: SentenceId): Promise<string>;
|
|
362
|
-
getSerialFragments(serialId: number): ReadonlySerialTextStream;
|
|
363
|
-
getSummaryFragments(serialId: number): ReadonlySerialTextStream;
|
|
364
|
-
openSession<T>(operation: (document: ReadonlyDocument) => Promise<T> | T): Promise<T>;
|
|
365
|
-
readDatabase<T>(operation: (database: Database) => Promise<T> | T): Promise<T>;
|
|
366
|
-
readSearchIndexDatabase<T>(operation: (database: Database) => Promise<T> | T): Promise<T>;
|
|
367
|
-
readBookMeta(): Promise<BookMeta | undefined>;
|
|
368
|
-
readCover(): Promise<SourceAsset | undefined>;
|
|
369
|
-
readSummary(serialId: number): Promise<string | undefined>;
|
|
370
|
-
readToc(): Promise<TocFile | undefined>;
|
|
371
|
-
release(): Promise<void>;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
declare const EVIDENCE_SELECTION_PROMPT_FRAGMENT: string;
|
|
375
|
-
declare const EVIDENCE_SELECTION_JSON_SHAPE: readonly [{
|
|
376
|
-
readonly quote: "exact short source quote copied from the selected sentence";
|
|
377
|
-
readonly sentence_id: "sentence id from the source context, such as S1";
|
|
378
|
-
}];
|
|
379
|
-
declare function formatEvidenceSelectionChoicePrompt(input: {
|
|
380
|
-
readonly evidenceLabel: string;
|
|
381
|
-
readonly generatedEvidence: unknown;
|
|
382
|
-
readonly candidates: readonly {
|
|
383
|
-
readonly nextText: string;
|
|
384
|
-
readonly occurrenceId: string;
|
|
385
|
-
readonly prevText: string;
|
|
386
|
-
readonly score: number;
|
|
387
|
-
readonly text: string;
|
|
388
|
-
}[];
|
|
389
|
-
}): string;
|
|
390
|
-
|
|
391
|
-
type EvidenceQuoteMatchStrategy = "empty" | "exact" | "normalized_exact" | "normalized_substring" | "fuzzy_window";
|
|
392
|
-
interface EvidenceQuoteScore {
|
|
393
|
-
readonly exactRaw: boolean;
|
|
394
|
-
readonly exactNormalized: boolean;
|
|
395
|
-
readonly exactSubstring: boolean;
|
|
396
|
-
readonly matchEnd: number;
|
|
397
|
-
readonly matchStart: number;
|
|
398
|
-
readonly normalizedQuote: string;
|
|
399
|
-
readonly normalizedSentence: string;
|
|
400
|
-
readonly score: number;
|
|
401
|
-
readonly strategy: EvidenceQuoteMatchStrategy;
|
|
402
|
-
}
|
|
403
|
-
declare function normalizeEvidenceDisplayText(text: string): string;
|
|
404
|
-
declare function normalizeEvidenceText(text: string): string;
|
|
405
|
-
declare function scoreEvidenceQuote(input: {
|
|
406
|
-
readonly quote: string;
|
|
407
|
-
readonly sentence: string;
|
|
408
|
-
}): EvidenceQuoteScore;
|
|
409
|
-
|
|
410
|
-
type EvidenceSentenceId = readonly [number, number];
|
|
411
|
-
interface EvidenceSelectionSentence {
|
|
412
|
-
readonly id: string;
|
|
413
|
-
readonly sentenceId: EvidenceSentenceId;
|
|
414
|
-
readonly text: string;
|
|
415
|
-
}
|
|
416
|
-
interface EvidenceSelection {
|
|
417
|
-
readonly quote?: string;
|
|
418
|
-
readonly sentence_id?: string;
|
|
419
|
-
}
|
|
420
|
-
type EvidenceSelectionList = EvidenceSelection | readonly EvidenceSelection[];
|
|
421
|
-
interface EvidenceSelectionCandidate {
|
|
422
|
-
readonly exactNormalized: boolean;
|
|
423
|
-
readonly exactRaw: boolean;
|
|
424
|
-
readonly exactSubstring: boolean;
|
|
425
|
-
readonly index: number;
|
|
426
|
-
readonly nextText: string;
|
|
427
|
-
readonly occurrenceId: string;
|
|
428
|
-
readonly prevText: string;
|
|
429
|
-
readonly score: number;
|
|
430
|
-
readonly sentence: EvidenceSelectionSentence;
|
|
431
|
-
readonly strategy: string;
|
|
432
|
-
}
|
|
433
|
-
interface EvidenceSelectionResolution {
|
|
434
|
-
readonly candidate: EvidenceSelectionCandidate;
|
|
435
|
-
readonly confidence: number;
|
|
436
|
-
readonly sentenceIds: readonly EvidenceSentenceId[];
|
|
437
|
-
readonly strategy: string;
|
|
438
|
-
}
|
|
439
|
-
interface EvidenceSelectionFailure {
|
|
440
|
-
readonly candidates: readonly EvidenceSelectionCandidate[];
|
|
441
|
-
readonly code: "ambiguous" | "invalid" | "low_confidence" | "missing_sentence" | "none";
|
|
442
|
-
readonly message: string;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
declare function resolveEvidenceSelection(input: {
|
|
446
|
-
readonly evidence: EvidenceSelection;
|
|
447
|
-
readonly sentences: readonly EvidenceSelectionSentence[];
|
|
448
|
-
}): readonly [
|
|
449
|
-
resolution: EvidenceSelectionResolution | undefined,
|
|
450
|
-
failure: EvidenceSelectionFailure | undefined
|
|
451
|
-
];
|
|
452
|
-
declare function resolveEvidenceSelectionList(input: {
|
|
453
|
-
readonly evidence: EvidenceSelectionList;
|
|
454
|
-
readonly sentences: readonly EvidenceSelectionSentence[];
|
|
455
|
-
}): readonly [
|
|
456
|
-
resolution: EvidenceSelectionResolution | undefined,
|
|
457
|
-
failure: EvidenceSelectionFailure | undefined
|
|
458
|
-
];
|
|
459
|
-
declare function rankEvidenceQuote(quote: string, sentences: readonly EvidenceSelectionSentence[]): EvidenceSelectionCandidate[];
|
|
460
|
-
|
|
461
|
-
interface WikipageResolverOptions {
|
|
462
|
-
readonly cacheDatabasePath?: string;
|
|
463
|
-
readonly concurrency?: number;
|
|
464
|
-
readonly fetch?: typeof fetch;
|
|
465
|
-
readonly language?: string;
|
|
466
|
-
readonly maxBatchSize?: number;
|
|
467
|
-
readonly minRequestIntervalMs?: number;
|
|
468
|
-
readonly normalizer?: DisambiguationProfileNormalizer;
|
|
469
|
-
readonly progress?: WikipageResolveProgressReporter;
|
|
470
|
-
readonly retryBaseDelayMs?: number;
|
|
471
|
-
readonly retryTimes?: number;
|
|
472
|
-
readonly userAgent?: string;
|
|
473
|
-
readonly wiki?: string;
|
|
474
|
-
}
|
|
475
|
-
type WikipageResolveProgressDetail = "disambiguation-page" | "entity" | "linked-page" | "page" | "qid";
|
|
476
|
-
interface WikipageResolveProgress {
|
|
477
|
-
readonly detail: WikipageResolveProgressDetail;
|
|
478
|
-
readonly done: number;
|
|
479
|
-
readonly total: number;
|
|
480
|
-
}
|
|
481
|
-
type WikipageResolveProgressReporter = (event: WikipageResolveProgress) => Promise<void> | void;
|
|
482
|
-
interface QidResolution {
|
|
483
|
-
readonly description?: string;
|
|
484
|
-
readonly disambiguation?: DisambiguationExpansion;
|
|
485
|
-
readonly disambiguationPages?: readonly DisambiguationPageText[];
|
|
486
|
-
readonly isDisambiguation: boolean;
|
|
487
|
-
readonly label?: string;
|
|
488
|
-
readonly qid: string;
|
|
489
|
-
readonly sitelink?: WikipageSitelink;
|
|
490
|
-
readonly sitelinks?: readonly WikipageSitelink[];
|
|
491
|
-
}
|
|
492
|
-
interface WikipageSitelink {
|
|
493
|
-
readonly title: string;
|
|
494
|
-
readonly wiki: string;
|
|
495
|
-
}
|
|
496
|
-
interface DisambiguationExpansion {
|
|
497
|
-
readonly checkedAt: string;
|
|
498
|
-
readonly disambiguationQid: string;
|
|
499
|
-
readonly linkedQids: readonly DisambiguationLinkedQid[];
|
|
500
|
-
readonly pages: readonly DisambiguationPageText[];
|
|
501
|
-
readonly profile?: DisambiguationProfile;
|
|
502
|
-
}
|
|
503
|
-
interface DisambiguationPageText {
|
|
504
|
-
readonly linkedQids: readonly DisambiguationLinkedQid[];
|
|
505
|
-
readonly pageId?: number;
|
|
506
|
-
readonly text: string;
|
|
507
|
-
readonly title: string;
|
|
508
|
-
readonly wiki: "enwiki" | "zhwiki";
|
|
509
|
-
}
|
|
510
|
-
interface DisambiguationLinkedQid {
|
|
511
|
-
readonly qid: string;
|
|
512
|
-
readonly title: string;
|
|
513
|
-
}
|
|
514
|
-
interface CachedQidRecord {
|
|
515
|
-
readonly checkedAt: string;
|
|
516
|
-
readonly description?: string;
|
|
517
|
-
readonly label?: string;
|
|
518
|
-
readonly qid: string;
|
|
519
|
-
readonly sitelinks: readonly CachedPageRecord[];
|
|
520
|
-
readonly updatedAt: string;
|
|
521
|
-
}
|
|
522
|
-
interface CachedDisambiguationRecord {
|
|
523
|
-
readonly checkedAt: string;
|
|
524
|
-
readonly disambiguationQid: string;
|
|
525
|
-
readonly pages: readonly DisambiguationPageText[];
|
|
526
|
-
readonly profile?: DisambiguationProfile;
|
|
527
|
-
}
|
|
528
|
-
interface CachedPageRecord {
|
|
529
|
-
readonly isDisambiguation: boolean;
|
|
530
|
-
readonly pageId?: number;
|
|
531
|
-
readonly title: string;
|
|
532
|
-
readonly wiki: "enwiki" | "zhwiki";
|
|
533
|
-
}
|
|
534
|
-
type DisambiguationMeaningPriority = "other" | "primary" | "secondary";
|
|
535
|
-
interface DisambiguationProfile {
|
|
536
|
-
readonly meanings: readonly DisambiguationProfileMeaning[];
|
|
537
|
-
readonly sourceQid: string;
|
|
538
|
-
readonly surface?: string;
|
|
539
|
-
}
|
|
540
|
-
interface DisambiguationProfileMeaning {
|
|
541
|
-
readonly category?: string;
|
|
542
|
-
readonly information: string;
|
|
543
|
-
readonly name: string;
|
|
544
|
-
readonly priority: DisambiguationMeaningPriority;
|
|
545
|
-
readonly qid: string;
|
|
546
|
-
}
|
|
547
|
-
type DisambiguationProfileNormalizer = (input: DisambiguationProfileNormalizerInput) => Promise<DisambiguationProfile>;
|
|
548
|
-
interface DisambiguationProfileNormalizerInput {
|
|
549
|
-
readonly pageQidLinks: readonly DisambiguationLinkedQid[];
|
|
550
|
-
readonly pages: readonly DisambiguationPageText[];
|
|
551
|
-
readonly sourceQid: string;
|
|
552
|
-
readonly surface?: string;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
declare class WikipageCache {
|
|
556
|
-
#private;
|
|
557
|
-
constructor(database: Database);
|
|
558
|
-
static open(path?: string): Promise<WikipageCache>;
|
|
559
|
-
close(): Promise<void>;
|
|
560
|
-
getQids(qids: readonly string[], language: string): Promise<ReadonlyMap<string, CachedQidRecord>>;
|
|
561
|
-
putQids(records: readonly CachedQidRecord[], language: string): Promise<void>;
|
|
562
|
-
getDisambiguations(qids: readonly string[], wiki: string): Promise<ReadonlyMap<string, CachedDisambiguationRecord>>;
|
|
563
|
-
putDisambiguations(records: readonly CachedDisambiguationRecord[], wiki: string): Promise<void>;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
type GuaranteedRequest = (messages: readonly LLMessage[], index: number, maxRetries: number) => Promise<string | undefined>;
|
|
567
|
-
|
|
568
|
-
interface CreateDisambiguationProfileNormalizerOptions {
|
|
569
|
-
readonly maxMeanings?: number;
|
|
570
|
-
readonly maxRetries?: number;
|
|
571
|
-
readonly request: GuaranteedRequest;
|
|
572
|
-
}
|
|
573
|
-
declare function createDisambiguationProfileNormalizer(options: CreateDisambiguationProfileNormalizerOptions): DisambiguationProfileNormalizer;
|
|
574
|
-
|
|
575
|
-
interface RateLimiterOptions {
|
|
576
|
-
readonly concurrency: number;
|
|
577
|
-
readonly minRequestIntervalMs: number;
|
|
578
|
-
}
|
|
579
|
-
declare class RateLimiter {
|
|
580
|
-
#private;
|
|
581
|
-
constructor(options: RateLimiterOptions);
|
|
582
|
-
use<T>(operation: () => Promise<T>): Promise<T>;
|
|
583
|
-
blockFor(ms: number): void;
|
|
584
|
-
}
|
|
585
|
-
declare function parseRetryAfterMs(value: string | null): number | undefined;
|
|
586
|
-
|
|
587
|
-
type SupportedWiki = "enwiki" | "zhwiki";
|
|
588
|
-
interface WikimediaClientOptions {
|
|
589
|
-
readonly concurrency: number;
|
|
590
|
-
readonly fetch?: typeof fetch;
|
|
591
|
-
readonly language: string;
|
|
592
|
-
readonly minRequestIntervalMs: number;
|
|
593
|
-
readonly retryBaseDelayMs: number;
|
|
594
|
-
readonly retryTimes: number;
|
|
595
|
-
readonly userAgent?: string;
|
|
596
|
-
readonly wiki: string;
|
|
597
|
-
}
|
|
598
|
-
interface WikidataEntityInfo {
|
|
599
|
-
readonly description?: string;
|
|
600
|
-
readonly label?: string;
|
|
601
|
-
readonly qid: string;
|
|
602
|
-
readonly sitelinks: readonly WikidataSitelinkInfo[];
|
|
603
|
-
}
|
|
604
|
-
interface WikidataSitelinkInfo {
|
|
605
|
-
readonly title: string;
|
|
606
|
-
readonly wiki: SupportedWiki;
|
|
607
|
-
}
|
|
608
|
-
interface WikiPageInfo {
|
|
609
|
-
readonly isDisambiguation: boolean;
|
|
610
|
-
readonly pageId?: number;
|
|
611
|
-
readonly title: string;
|
|
612
|
-
readonly wiki: SupportedWiki;
|
|
613
|
-
readonly wikibaseItem?: string;
|
|
614
|
-
}
|
|
615
|
-
interface ParsedDisambiguationPage {
|
|
616
|
-
readonly linkedTitles: readonly string[];
|
|
617
|
-
readonly pageId?: number;
|
|
618
|
-
readonly text: string;
|
|
619
|
-
readonly title: string;
|
|
620
|
-
readonly wiki: SupportedWiki;
|
|
621
|
-
}
|
|
622
|
-
declare class WikimediaClient {
|
|
623
|
-
#private;
|
|
624
|
-
constructor(options: WikimediaClientOptions);
|
|
625
|
-
getEntities(qids: readonly string[]): Promise<ReadonlyMap<string, WikidataEntityInfo>>;
|
|
626
|
-
getPagesByTitles(titles: readonly string[], wiki?: SupportedWiki): Promise<ReadonlyMap<string, WikiPageInfo>>;
|
|
627
|
-
parseDisambiguationPage(title: string, wiki: SupportedWiki): Promise<ParsedDisambiguationPage>;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
declare class WikipageResolver {
|
|
631
|
-
#private;
|
|
632
|
-
constructor(input: {
|
|
633
|
-
readonly cache: WikipageCache;
|
|
634
|
-
readonly client: WikimediaClient;
|
|
635
|
-
readonly language: string;
|
|
636
|
-
readonly maxBatchSize: number;
|
|
637
|
-
readonly normalizer: DisambiguationProfileNormalizer | undefined;
|
|
638
|
-
readonly ownsCache: boolean;
|
|
639
|
-
readonly progress: WikipageResolveProgressReporter | undefined;
|
|
640
|
-
readonly wiki: string;
|
|
641
|
-
});
|
|
642
|
-
static open(options?: WikipageResolverOptions): Promise<WikipageResolver>;
|
|
643
|
-
close(): Promise<void>;
|
|
644
|
-
resolveQids(qids: readonly string[]): Promise<readonly QidResolution[]>;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
interface WikimatchCandidate {
|
|
648
|
-
readonly hasMoreOptions?: boolean;
|
|
649
|
-
readonly id: string;
|
|
650
|
-
readonly qidOptions: readonly WikimatchQidOption[];
|
|
651
|
-
readonly range: WikimatchTextRange;
|
|
652
|
-
readonly surface: string;
|
|
653
|
-
}
|
|
654
|
-
interface WikimatchQidOption {
|
|
655
|
-
readonly description?: string;
|
|
656
|
-
readonly disambiguation?: DisambiguationExpansion;
|
|
657
|
-
readonly isDisambiguation?: boolean;
|
|
658
|
-
readonly label?: string;
|
|
659
|
-
readonly qid: string;
|
|
660
|
-
}
|
|
661
|
-
interface WikimatchTextRange {
|
|
662
|
-
readonly end: number;
|
|
663
|
-
readonly start: number;
|
|
664
|
-
}
|
|
665
|
-
interface WikimatchWindow {
|
|
666
|
-
readonly baseOffset: number;
|
|
667
|
-
readonly candidates: readonly WikimatchCandidate[];
|
|
668
|
-
readonly groups: readonly WikimatchConflictGroup[];
|
|
669
|
-
readonly text: string;
|
|
670
|
-
}
|
|
671
|
-
interface WikimatchConflictGroup {
|
|
672
|
-
readonly candidateIds: readonly string[];
|
|
673
|
-
readonly id: string;
|
|
674
|
-
readonly range: WikimatchTextRange;
|
|
675
|
-
}
|
|
676
|
-
interface BuildWikimatchWindowsOptions {
|
|
677
|
-
readonly candidates: readonly WikimatchCandidate[];
|
|
678
|
-
readonly contextWords: number;
|
|
679
|
-
readonly optionBudget: number;
|
|
680
|
-
readonly text: string;
|
|
681
|
-
}
|
|
682
|
-
type WikimatchPolicyDecision = "continue" | "never_recall" | "recall" | "skip_this_time";
|
|
683
|
-
interface WikimatchPolicyJudgeInput {
|
|
684
|
-
readonly candidates: readonly WikimatchCandidate[];
|
|
685
|
-
readonly policyPrompt: string;
|
|
686
|
-
readonly window: WikimatchWindow;
|
|
687
|
-
}
|
|
688
|
-
interface WikimatchPolicyJudgeResult {
|
|
689
|
-
readonly continuations: readonly WikimatchPolicyContinuation[];
|
|
690
|
-
readonly fallback?: WikimatchPolicyFallback;
|
|
691
|
-
readonly mentions: readonly WikimatchAcceptedMention[];
|
|
692
|
-
readonly policyUpdates: readonly WikimatchPolicyUpdate[];
|
|
693
|
-
}
|
|
694
|
-
interface WikimatchAcceptedMention {
|
|
695
|
-
readonly candidateId: string;
|
|
696
|
-
readonly confidence?: number;
|
|
697
|
-
readonly qid: string;
|
|
698
|
-
readonly range: WikimatchTextRange;
|
|
699
|
-
readonly note?: string;
|
|
700
|
-
readonly surface: string;
|
|
701
|
-
}
|
|
702
|
-
interface WikimatchPolicyUpdate {
|
|
703
|
-
readonly candidateId: string;
|
|
704
|
-
readonly decision: Exclude<WikimatchPolicyDecision, "recall" | "continue">;
|
|
705
|
-
readonly note?: string;
|
|
706
|
-
readonly qid?: string;
|
|
707
|
-
readonly surface: string;
|
|
708
|
-
}
|
|
709
|
-
interface WikimatchPolicyContinuation {
|
|
710
|
-
readonly candidateIds: readonly string[];
|
|
711
|
-
readonly groupId: string;
|
|
712
|
-
}
|
|
713
|
-
interface WikimatchPolicyFallback {
|
|
714
|
-
readonly issues: readonly string[];
|
|
715
|
-
readonly reason: "guaranteed_json_failed";
|
|
716
|
-
}
|
|
717
|
-
interface WikimatchPolicyDecisionOutput {
|
|
718
|
-
readonly candidateId: string;
|
|
719
|
-
readonly confidence?: number;
|
|
720
|
-
readonly decision: WikimatchPolicyDecision;
|
|
721
|
-
readonly qid?: string;
|
|
722
|
-
}
|
|
723
|
-
interface WikimatchPolicyGroupOutput {
|
|
724
|
-
readonly decisions: readonly WikimatchPolicyDecisionOutput[];
|
|
725
|
-
readonly groupId: string;
|
|
726
|
-
}
|
|
727
|
-
interface WikimatchPolicyResponse {
|
|
728
|
-
readonly groups: readonly WikimatchPolicyGroupOutput[];
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
interface JudgeWikimatchPolicyOptions extends WikimatchPolicyJudgeInput {
|
|
732
|
-
readonly maxRetries?: number;
|
|
733
|
-
readonly request: GuaranteedRequest;
|
|
734
|
-
}
|
|
735
|
-
declare function judgeWikimatchPolicy(options: JudgeWikimatchPolicyOptions): Promise<WikimatchPolicyJudgeResult>;
|
|
736
|
-
declare function parsePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): WikimatchPolicyJudgeResult;
|
|
737
|
-
declare function validatePolicyResponse(candidates: readonly WikimatchCandidate[], response: WikimatchPolicyResponse, groups?: readonly WikimatchConflictGroup[]): readonly string[];
|
|
738
|
-
|
|
739
|
-
declare function buildWikimatchWindows(options: BuildWikimatchWindowsOptions): readonly WikimatchWindow[];
|
|
740
|
-
|
|
741
|
-
type SpineDigestOperation = "digest-epub" | "digest-markdown" | "digest-text-stream" | "digest-txt";
|
|
742
|
-
interface SerialDiscoveryItem {
|
|
743
|
-
readonly id: number;
|
|
744
|
-
readonly fragments?: number | undefined;
|
|
745
|
-
readonly title?: string | undefined;
|
|
746
|
-
readonly words: number;
|
|
747
|
-
}
|
|
748
|
-
interface SerialsDiscoveredEvent {
|
|
749
|
-
readonly type: "serials-discovered";
|
|
750
|
-
readonly available: boolean;
|
|
751
|
-
readonly serials: readonly SerialDiscoveryItem[];
|
|
752
|
-
}
|
|
753
|
-
interface SerialProgressEvent {
|
|
754
|
-
readonly type: "serial-progress";
|
|
755
|
-
readonly id: number;
|
|
756
|
-
readonly completedWords: number;
|
|
757
|
-
readonly completedFragments: number;
|
|
758
|
-
}
|
|
759
|
-
interface DigestProgressEvent {
|
|
760
|
-
readonly type: "digest-progress";
|
|
761
|
-
readonly completedWords: number;
|
|
762
|
-
readonly totalWords: number;
|
|
763
|
-
}
|
|
764
|
-
type SpineDigestProgressEventType = SpineDigestProgressEvent["type"];
|
|
765
|
-
type SpineDigestProgressEvent = SerialsDiscoveredEvent | SerialProgressEvent | DigestProgressEvent;
|
|
766
|
-
type SpineDigestProgressCallback = (event: SpineDigestProgressEvent) => void | Promise<void>;
|
|
767
|
-
|
|
768
|
-
declare const CHAPTER_STAGES: readonly ["planned", "sourced", "graphed", "summarized"];
|
|
769
|
-
type ChapterStage = (typeof CHAPTER_STAGES)[number];
|
|
770
|
-
|
|
771
|
-
interface SpineDigestSerialEntry {
|
|
772
|
-
readonly fragmentCount: number;
|
|
773
|
-
readonly serialId: number;
|
|
774
|
-
readonly title: string | null;
|
|
775
|
-
readonly tocPath: readonly string[];
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
declare class SpineDigest {
|
|
779
|
-
#private;
|
|
780
|
-
constructor(document: ReadonlyDocument, documentDirectoryPath: string);
|
|
781
|
-
exportEpub(path: string): Promise<void>;
|
|
782
|
-
exportText(path: string): Promise<void>;
|
|
783
|
-
readCover(): Promise<SourceAsset | undefined>;
|
|
784
|
-
readMeta(): Promise<BookMeta | undefined>;
|
|
785
|
-
readToc(): Promise<TocFile | undefined>;
|
|
786
|
-
readArchiveFormatVersion(): Promise<number>;
|
|
787
|
-
readChapterStage(serialId: number): Promise<ChapterStage>;
|
|
788
|
-
listSerials(): Promise<readonly SpineDigestSerialEntry[]>;
|
|
789
|
-
readSerialSummary(serialId: number): Promise<string>;
|
|
790
|
-
saveAs(path: string): Promise<void>;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
interface DigestDocumentSessionOptions {
|
|
794
|
-
readonly documentDirPath?: string;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
interface SpineDigestLLMOptions {
|
|
798
|
-
readonly cacheDirPath?: string;
|
|
799
|
-
readonly concurrent?: number;
|
|
800
|
-
readonly logDirPath?: string;
|
|
801
|
-
readonly model: LanguageModel;
|
|
802
|
-
readonly retryIntervalSeconds?: number;
|
|
803
|
-
readonly retryTimes?: number;
|
|
804
|
-
readonly stream?: boolean;
|
|
805
|
-
readonly temperature?: number | readonly number[];
|
|
806
|
-
readonly timeout?: number;
|
|
807
|
-
readonly topP?: number | readonly number[];
|
|
808
|
-
}
|
|
809
|
-
interface SpineDigestAppOptions {
|
|
810
|
-
readonly debugLogDirPath?: string;
|
|
811
|
-
readonly llm?: LanguageModel | SpineDigestLLMOptions;
|
|
812
|
-
readonly verbose?: boolean;
|
|
813
|
-
}
|
|
814
|
-
type SpineDigestOpenSessionOptions = DigestDocumentSessionOptions;
|
|
815
|
-
interface SpineDigestSourceSessionOptions extends DigestDocumentSessionOptions {
|
|
816
|
-
readonly extractionPrompt?: string;
|
|
817
|
-
readonly onProgress?: SpineDigestProgressCallback;
|
|
818
|
-
readonly path: string;
|
|
819
|
-
readonly targetStage?: ChapterStage;
|
|
820
|
-
readonly userLanguage?: Language;
|
|
821
|
-
}
|
|
822
|
-
interface SpineDigestTextStreamSessionOptions extends DigestDocumentSessionOptions {
|
|
823
|
-
readonly bookLanguage?: string | null;
|
|
824
|
-
readonly extractionPrompt?: string;
|
|
825
|
-
readonly onProgress?: SpineDigestProgressCallback;
|
|
826
|
-
readonly sourceFormat?: "markdown" | "txt";
|
|
827
|
-
readonly stream: AsyncIterable<string> | Iterable<string>;
|
|
828
|
-
readonly targetStage?: ChapterStage;
|
|
829
|
-
readonly title?: string | null;
|
|
830
|
-
readonly userLanguage?: Language;
|
|
831
|
-
}
|
|
832
|
-
declare class SpineDigestApp {
|
|
833
|
-
#private;
|
|
834
|
-
constructor(options: SpineDigestAppOptions);
|
|
835
|
-
digestEpubSession<T>(options: SpineDigestSourceSessionOptions, operation: (digest: SpineDigest) => Promise<T> | T): Promise<T>;
|
|
836
|
-
digestMarkdownSession<T>(options: SpineDigestSourceSessionOptions, operation: (digest: SpineDigest) => Promise<T> | T): Promise<T>;
|
|
837
|
-
digestTextStreamSession<T>(options: SpineDigestTextStreamSessionOptions, operation: (digest: SpineDigest) => Promise<T> | T): Promise<T>;
|
|
838
|
-
digestTxtSession<T>(options: SpineDigestSourceSessionOptions, operation: (digest: SpineDigest) => Promise<T> | T): Promise<T>;
|
|
839
|
-
openSession<T>(path: string, operation: (digest: SpineDigest) => Promise<T> | T, options?: SpineDigestOpenSessionOptions): Promise<T>;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
export { type BuildWikimatchWindowsOptions, type CachedDisambiguationRecord, type CachedPageRecord, type CachedQidRecord, type DigestProgressEvent, type DisambiguationExpansion, type DisambiguationLinkedQid, type DisambiguationMeaningPriority, type DisambiguationPageText, type DisambiguationProfile, type DisambiguationProfileMeaning, type DisambiguationProfileNormalizer, type DisambiguationProfileNormalizerInput, EVIDENCE_SELECTION_JSON_SHAPE, EVIDENCE_SELECTION_PROMPT_FRAGMENT, type EvidenceQuoteMatchStrategy, type EvidenceQuoteScore, type EvidenceSelection, type EvidenceSelectionCandidate, type EvidenceSelectionFailure, type EvidenceSelectionList, type EvidenceSelectionResolution, type EvidenceSelectionSentence, type EvidenceSentenceId, type JudgeWikimatchPolicyOptions, LLMPaymentRequiredError, Language, LanguageCode, type QidResolution, RateLimiter, SPINE_DIGEST_CONTEXT_VERSION, type SerialDiscoveryItem, type SerialProgressEvent, type SerialsDiscoveredEvent, SpineDigest, SpineDigestApp, type SpineDigestAppOptions, type SpineDigestLLMOptions, type SpineDigestOpenSessionOptions, type SpineDigestOperation, type SpineDigestProgressCallback, type SpineDigestProgressEvent, type SpineDigestProgressEventType, type SpineDigestSerialEntry, type SpineDigestSourceSessionOptions, SpineDigestTask, SpineDigestTaskContext, type SpineDigestTaskContextOptions, type SpineDigestTaskIdentity, type SpineDigestTaskType, type SpineDigestTextStreamSessionOptions, type WikimatchAcceptedMention, type WikimatchCandidate, type WikimatchConflictGroup, type WikimatchPolicyDecision, type WikimatchPolicyDecisionOutput, type WikimatchPolicyFallback, type WikimatchPolicyJudgeInput, type WikimatchPolicyJudgeResult, type WikimatchPolicyResponse, type WikimatchPolicyUpdate, type WikimatchQidOption, type WikimatchTextRange, type WikimatchWindow, WikimediaClient, WikipageCache, WikipageResolver, type WikipageResolverOptions, type WikipageSitelink, buildWikimatchWindows, createDisambiguationProfileNormalizer, createSpineDigestTaskId, formatEvidenceSelectionChoicePrompt, formatLanguageForPrompt, getLanguageCode, getWikipageLanguageCode, judgeWikimatchPolicy, normalizeEvidenceDisplayText, normalizeEvidenceText, normalizeLanguageCode, parsePolicyResponse, parseRetryAfterMs, rankEvidenceQuote, resolveEvidenceSelection, resolveEvidenceSelectionList, scoreEvidenceQuote, validatePolicyResponse };
|
|
1
|
+
export * from 'wiki-graph-core';
|
|
2
|
+
|
|
3
|
+
interface RunWikiGraphCLIInput {
|
|
4
|
+
/**
|
|
5
|
+
* CLI arguments without the executable name. For example, `["--help"]`
|
|
6
|
+
* simulates `wg --help`.
|
|
7
|
+
*/
|
|
8
|
+
readonly argv?: readonly string[] | undefined;
|
|
9
|
+
readonly cwd?: string | undefined;
|
|
10
|
+
readonly devProjectRoot?: string | undefined;
|
|
11
|
+
readonly env?: NodeJS.ProcessEnv | undefined;
|
|
12
|
+
readonly signal?: AbortSignal | undefined;
|
|
13
|
+
readonly stateDir?: string | undefined;
|
|
14
|
+
readonly stderr?: NodeJS.WritableStream | undefined;
|
|
15
|
+
readonly stderrIsTTY?: boolean | undefined;
|
|
16
|
+
readonly stdin?: NodeJS.ReadableStream | Uint8Array | string | undefined;
|
|
17
|
+
readonly stdinIsTTY?: boolean | undefined;
|
|
18
|
+
readonly stdout?: NodeJS.WritableStream | undefined;
|
|
19
|
+
readonly stdoutIsTTY?: boolean | undefined;
|
|
20
|
+
}
|
|
21
|
+
interface RunWikiGraphCLIResult {
|
|
22
|
+
readonly exitCode: number;
|
|
23
|
+
}
|
|
24
|
+
interface RunWikiGraphCLICapturedResult extends RunWikiGraphCLIResult {
|
|
25
|
+
readonly stderr: string;
|
|
26
|
+
readonly stdout: string;
|
|
27
|
+
}
|
|
28
|
+
interface WikiGraphCLI {
|
|
29
|
+
run(argv?: readonly string[], overrides?: RunWikiGraphCLIInput): Promise<RunWikiGraphCLIResult>;
|
|
30
|
+
runCaptured(argv?: readonly string[], overrides?: RunWikiGraphCLIInput): Promise<RunWikiGraphCLICapturedResult>;
|
|
31
|
+
}
|
|
32
|
+
declare function runWikiGraphCLI(input?: RunWikiGraphCLIInput): Promise<RunWikiGraphCLIResult>;
|
|
33
|
+
declare function runWikiGraphCLICaptured(input?: RunWikiGraphCLIInput): Promise<RunWikiGraphCLICapturedResult>;
|
|
34
|
+
declare function createWikiGraphCLI(defaults?: RunWikiGraphCLIInput): WikiGraphCLI;
|
|
35
|
+
|
|
36
|
+
export { type RunWikiGraphCLICapturedResult, type RunWikiGraphCLIInput, type RunWikiGraphCLIResult, type WikiGraphCLI, createWikiGraphCLI, runWikiGraphCLI, runWikiGraphCLICaptured };
|