@dsh-libing/knowledge-base 0.1.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +80 -0
  3. package/cordis.patch.yml +3 -0
  4. package/icon.svg +6 -0
  5. package/lib/chunks.d.ts +8 -0
  6. package/lib/chunks.js +197 -0
  7. package/lib/client-types/client/BrowsePanel.d.ts +13 -0
  8. package/lib/client-types/client/Icon.d.ts +4 -0
  9. package/lib/client-types/client/ImageReview.d.ts +20 -0
  10. package/lib/client-types/client/ImportPanel.d.ts +19 -0
  11. package/lib/client-types/client/JobsPanel.d.ts +6 -0
  12. package/lib/client-types/client/KnowledgePage.d.ts +7 -0
  13. package/lib/client-types/client/Metadata.d.ts +10 -0
  14. package/lib/client-types/client/QualityReport.d.ts +6 -0
  15. package/lib/client-types/client/SettingsPanel.d.ts +6 -0
  16. package/lib/client-types/client/SourceText.d.ts +3 -0
  17. package/lib/client-types/client/UsageGuide.d.ts +8 -0
  18. package/lib/client-types/client/api.d.ts +953 -0
  19. package/lib/client-types/client/common.d.ts +11 -0
  20. package/lib/client-types/client/index.d.ts +14 -0
  21. package/lib/client-types/client/locales.d.ts +284 -0
  22. package/lib/client-types/client/searchCommand.d.ts +2 -0
  23. package/lib/client-types/client/useKnowledge.d.ts +251 -0
  24. package/lib/client-types/contract.d.ts +1197 -0
  25. package/lib/client-types/data.d.ts +1972 -0
  26. package/lib/client-types/settings.d.ts +33 -0
  27. package/lib/client-types/shared.d.ts +95 -0
  28. package/lib/client.js +305 -0
  29. package/lib/config.d.ts +13 -0
  30. package/lib/config.js +13 -0
  31. package/lib/contract.d.ts +1197 -0
  32. package/lib/contract.js +18 -0
  33. package/lib/data.d.ts +1972 -0
  34. package/lib/data.js +80 -0
  35. package/lib/document/convert.d.ts +5 -0
  36. package/lib/document/convert.js +325 -0
  37. package/lib/document/pdf-data.d.ts +99 -0
  38. package/lib/document/pdf-data.js +9 -0
  39. package/lib/document/pdf-layout.d.ts +24 -0
  40. package/lib/document/pdf-layout.js +234 -0
  41. package/lib/document/pdf-session.d.ts +39 -0
  42. package/lib/document/pdf-session.js +127 -0
  43. package/lib/document/pdf-vision.d.ts +26 -0
  44. package/lib/document/pdf-vision.js +115 -0
  45. package/lib/document/pdf-worker.d.ts +1 -0
  46. package/lib/document/pdf-worker.js +210 -0
  47. package/lib/document/pdf.d.ts +3 -0
  48. package/lib/document/pdf.js +218 -0
  49. package/lib/document/zip.d.ts +3 -0
  50. package/lib/document/zip.js +59 -0
  51. package/lib/figures/process.d.ts +187 -0
  52. package/lib/figures/process.js +159 -0
  53. package/lib/figures/prompts.d.ts +7 -0
  54. package/lib/figures/prompts.js +27 -0
  55. package/lib/index.d.ts +8 -0
  56. package/lib/index.js +42 -0
  57. package/lib/indexes.d.ts +38 -0
  58. package/lib/indexes.js +101 -0
  59. package/lib/jobs.d.ts +2806 -0
  60. package/lib/jobs.js +435 -0
  61. package/lib/models.d.ts +24 -0
  62. package/lib/models.js +120 -0
  63. package/lib/retrieval.d.ts +209 -0
  64. package/lib/retrieval.js +173 -0
  65. package/lib/routes.d.ts +3 -0
  66. package/lib/routes.js +152 -0
  67. package/lib/runtime.d.ts +48 -0
  68. package/lib/runtime.js +41 -0
  69. package/lib/settings.d.ts +33 -0
  70. package/lib/settings.js +19 -0
  71. package/lib/shared.d.ts +95 -0
  72. package/lib/shared.js +17 -0
  73. package/lib/skills.d.ts +3 -0
  74. package/lib/skills.js +21 -0
  75. package/lib/store.d.ts +409 -0
  76. package/lib/store.js +328 -0
  77. package/lib/tools.d.ts +3 -0
  78. package/lib/tools.js +72 -0
  79. package/lib/util.d.ts +25 -0
  80. package/lib/util.js +89 -0
  81. package/package.json +125 -0
  82. package/skills/libing-kb-build/SKILL.md +10 -0
  83. package/skills/libing-kb-search/SKILL.md +10 -0
  84. package/skills/libing-knowledge-base/SKILL.md +15 -0
  85. package/skills/libing-knowledge-base/references/build.md +23 -0
  86. package/skills/libing-knowledge-base/references/search.md +21 -0
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ export declare const settingsSchema: z.ZodObject<{
3
+ dataRoot: z.ZodString;
4
+ chunkTargetChars: z.ZodDefault<z.ZodNumber>;
5
+ evidenceMaxChars: z.ZodDefault<z.ZodNumber>;
6
+ catalogMaxChars: z.ZodDefault<z.ZodNumber>;
7
+ candidateLimit: z.ZodDefault<z.ZodNumber>;
8
+ maxInputBytes: z.ZodDefault<z.ZodNumber>;
9
+ maxUncompressedBytes: z.ZodDefault<z.ZodNumber>;
10
+ maxArchiveEntries: z.ZodDefault<z.ZodNumber>;
11
+ modelTimeoutMs: z.ZodDefault<z.ZodNumber>;
12
+ modelAttempts: z.ZodDefault<z.ZodNumber>;
13
+ visionConcurrency: z.ZodDefault<z.ZodNumber>;
14
+ maxModelCalls: z.ZodDefault<z.ZodNumber>;
15
+ maxModelTokens: z.ZodDefault<z.ZodNumber>;
16
+ visionMaxEdge: z.ZodDefault<z.ZodNumber>;
17
+ visionTileSize: z.ZodDefault<z.ZodNumber>;
18
+ visionMaxTiles: z.ZodDefault<z.ZodNumber>;
19
+ modelMaxOutputTokens: z.ZodDefault<z.ZodNumber>;
20
+ summaryMaxChars: z.ZodDefault<z.ZodNumber>;
21
+ figureMaxChars: z.ZodDefault<z.ZodNumber>;
22
+ pdfMaxPages: z.ZodDefault<z.ZodNumber>;
23
+ pdfMaxPagePixels: z.ZodDefault<z.ZodNumber>;
24
+ pdfPageTimeoutMs: z.ZodDefault<z.ZodNumber>;
25
+ libreOfficePath: z.ZodDefault<z.ZodString>;
26
+ visionProvider: z.ZodDefault<z.ZodString>;
27
+ visionModel: z.ZodDefault<z.ZodString>;
28
+ summaryProvider: z.ZodDefault<z.ZodString>;
29
+ summaryModel: z.ZodDefault<z.ZodString>;
30
+ skipImages: z.ZodDefault<z.ZodBoolean>;
31
+ acceptPartial: z.ZodDefault<z.ZodBoolean>;
32
+ }, z.core.$strict>;
33
+ export type Settings = z.output<typeof settingsSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ const positive = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
3
+ export const settingsSchema = z.strictObject({
4
+ dataRoot: z.string().min(1),
5
+ chunkTargetChars: positive.min(256).max(60000).default(6000), evidenceMaxChars: positive.min(512).default(12000),
6
+ catalogMaxChars: positive.min(512).default(6000), candidateLimit: positive.max(30).default(6),
7
+ maxInputBytes: positive.default(64 * 1024 * 1024), maxUncompressedBytes: positive.default(256 * 1024 * 1024), maxArchiveEntries: positive.default(10000),
8
+ modelTimeoutMs: positive.default(90000), modelAttempts: positive.default(3), visionConcurrency: positive.max(8).default(2),
9
+ maxModelCalls: positive.default(1000), maxModelTokens: positive.default(2000000), visionMaxEdge: positive.default(2048),
10
+ visionTileSize: positive.default(1536), visionMaxTiles: positive.default(12), modelMaxOutputTokens: positive.default(4096),
11
+ summaryMaxChars: positive.default(160), figureMaxChars: positive.default(6000), pdfMaxPages: positive.default(2000),
12
+ pdfMaxPagePixels: positive.default(12000000), pdfPageTimeoutMs: positive.default(60000),
13
+ libreOfficePath: z.string().default(''), visionProvider: z.string().default(''), visionModel: z.string().default(''),
14
+ summaryProvider: z.string().default(''), summaryModel: z.string().default(''), skipImages: z.boolean().default(false), acceptPartial: z.boolean().default(false),
15
+ }).superRefine((value, context) => {
16
+ for (const kind of ['vision', 'summary'])
17
+ if (Boolean(value[`${kind}Provider`]) !== Boolean(value[`${kind}Model`]))
18
+ context.addIssue({ code: 'custom', message: `${kind}Provider / ${kind}Model 必须成对配置` });
19
+ });
@@ -0,0 +1,95 @@
1
+ import { z } from 'zod';
2
+ export declare const API = "/api/libing-knowledge-base";
3
+ export declare const buildSchema: z.ZodObject<{
4
+ kbId: z.ZodString;
5
+ createKb: z.ZodOptional<z.ZodBoolean>;
6
+ sourcePath: z.ZodOptional<z.ZodString>;
7
+ receiptId: z.ZodOptional<z.ZodString>;
8
+ title: z.ZodOptional<z.ZodString>;
9
+ sourceVersion: z.ZodOptional<z.ZodString>;
10
+ docId: z.ZodOptional<z.ZodString>;
11
+ chunkTargetChars: z.ZodOptional<z.ZodNumber>;
12
+ pageStart: z.ZodOptional<z.ZodNumber>;
13
+ pageEnd: z.ZodOptional<z.ZodNumber>;
14
+ confirmRangeChange: z.ZodOptional<z.ZodBoolean>;
15
+ visionProvider: z.ZodOptional<z.ZodString>;
16
+ visionModel: z.ZodOptional<z.ZodString>;
17
+ summaryProvider: z.ZodOptional<z.ZodString>;
18
+ summaryModel: z.ZodOptional<z.ZodString>;
19
+ skipImages: z.ZodOptional<z.ZodBoolean>;
20
+ acceptPartial: z.ZodOptional<z.ZodBoolean>;
21
+ }, z.core.$strict>;
22
+ export declare const browserBuildSchema: z.ZodObject<{
23
+ chunkTargetChars: z.ZodOptional<z.ZodNumber>;
24
+ visionProvider: z.ZodOptional<z.ZodString>;
25
+ visionModel: z.ZodOptional<z.ZodString>;
26
+ summaryProvider: z.ZodOptional<z.ZodString>;
27
+ summaryModel: z.ZodOptional<z.ZodString>;
28
+ skipImages: z.ZodOptional<z.ZodBoolean>;
29
+ acceptPartial: z.ZodOptional<z.ZodBoolean>;
30
+ title: z.ZodOptional<z.ZodString>;
31
+ docId: z.ZodOptional<z.ZodString>;
32
+ sourceVersion: z.ZodOptional<z.ZodString>;
33
+ kbId: z.ZodString;
34
+ pageStart: z.ZodOptional<z.ZodNumber>;
35
+ pageEnd: z.ZodOptional<z.ZodNumber>;
36
+ confirmRangeChange: z.ZodOptional<z.ZodBoolean>;
37
+ receiptId: z.ZodString;
38
+ }, z.core.$strict>;
39
+ export type BuildArgs = z.infer<typeof buildSchema> & {
40
+ sourceFilename?: string | undefined;
41
+ figureRefresh?: {
42
+ occurrenceId: string;
43
+ token: string;
44
+ } | undefined;
45
+ };
46
+ export declare const jobActionSchema: z.ZodObject<{
47
+ jobId: z.ZodString;
48
+ action: z.ZodDefault<z.ZodEnum<{
49
+ status: "status";
50
+ retry: "retry";
51
+ cancel: "cancel";
52
+ }>>;
53
+ acceptPartial: z.ZodOptional<z.ZodBoolean>;
54
+ maxModelCalls: z.ZodOptional<z.ZodNumber>;
55
+ maxModelTokens: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strict>;
57
+ export type JobOptions = Pick<z.infer<typeof jobActionSchema>, 'acceptPartial' | 'maxModelCalls' | 'maxModelTokens'>;
58
+ export declare const catalogQuerySchema: z.ZodObject<{
59
+ kbId: z.ZodOptional<z.ZodString>;
60
+ revision: z.ZodOptional<z.ZodString>;
61
+ docId: z.ZodOptional<z.ZodString>;
62
+ nodeId: z.ZodOptional<z.ZodString>;
63
+ page: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
64
+ }, z.core.$strict>;
65
+ export type CatalogArgs = z.infer<typeof catalogQuerySchema>;
66
+ export declare const keywordsSchema: z.ZodArray<z.ZodString>;
67
+ export declare const searchSchema: z.ZodObject<{
68
+ kbId: z.ZodString;
69
+ revision: z.ZodOptional<z.ZodString>;
70
+ docId: z.ZodOptional<z.ZodString>;
71
+ query: z.ZodString;
72
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ limit: z.ZodOptional<z.ZodNumber>;
74
+ }, z.core.$strict>;
75
+ export type SearchArgs = z.infer<typeof searchSchema>;
76
+ export declare const readQuerySchema: z.ZodObject<{
77
+ kbId: z.ZodString;
78
+ revision: z.ZodOptional<z.ZodString>;
79
+ chunkId: z.ZodString;
80
+ query: z.ZodOptional<z.ZodString>;
81
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
+ segmentIndex: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
83
+ offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
84
+ }, z.core.$strict>;
85
+ export type ReadArgs = z.infer<typeof readQuerySchema>;
86
+ export declare const assetQuerySchema: z.ZodObject<{
87
+ kbId: z.ZodString;
88
+ revision: z.ZodOptional<z.ZodString>;
89
+ docId: z.ZodString;
90
+ assetId: z.ZodString;
91
+ }, z.core.$strict>;
92
+ export declare const revisionQuerySchema: z.ZodObject<{
93
+ kbId: z.ZodString;
94
+ revision: z.ZodOptional<z.ZodString>;
95
+ }, z.core.$strict>;
package/lib/shared.js ADDED
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ export const API = '/api/libing-knowledge-base';
3
+ const id = z.string().regex(/^[a-z0-9][a-z0-9-]{0,95}$/u);
4
+ const selector = z.string().trim().min(1).max(120);
5
+ const positive = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
6
+ export const buildSchema = z.strictObject({ kbId: selector, createKb: z.boolean().optional(), sourcePath: z.string().min(1).max(4000).optional(), receiptId: id.optional(),
7
+ title: z.string().trim().min(1).max(300).optional(), sourceVersion: z.string().trim().min(1).max(120).optional(), docId: id.max(80).optional(), chunkTargetChars: positive.min(256).max(60000).optional(),
8
+ pageStart: positive.optional(), pageEnd: positive.optional(), confirmRangeChange: z.boolean().optional(), visionProvider: z.string().optional(), visionModel: z.string().optional(),
9
+ summaryProvider: z.string().optional(), summaryModel: z.string().optional(), skipImages: z.boolean().optional(), acceptPartial: z.boolean().optional() });
10
+ export const browserBuildSchema = buildSchema.omit({ sourcePath: true, createKb: true }).extend({ receiptId: id });
11
+ export const jobActionSchema = z.strictObject({ jobId: id, action: z.enum(['status', 'retry', 'cancel']).default('status'), acceptPartial: z.boolean().optional(), maxModelCalls: positive.optional(), maxModelTokens: positive.optional() });
12
+ export const catalogQuerySchema = z.strictObject({ kbId: selector.optional(), revision: id.optional(), docId: id.optional(), nodeId: id.optional(), page: z.coerce.number().int().nonnegative().optional() });
13
+ export const keywordsSchema = z.array(z.string().max(100)).max(32);
14
+ export const searchSchema = z.strictObject({ kbId: selector, revision: id.optional(), docId: id.optional(), query: z.string().trim().min(1).max(2000), keywords: keywordsSchema.optional(), limit: positive.max(30).optional() });
15
+ export const readQuerySchema = z.strictObject({ kbId: selector, revision: id.optional(), chunkId: id, query: z.string().max(2000).optional(), keywords: keywordsSchema.optional(), segmentIndex: z.coerce.number().int().nonnegative().optional(), offset: z.coerce.number().int().nonnegative().optional() });
16
+ export const assetQuerySchema = z.strictObject({ kbId: selector, revision: id.optional(), docId: id, assetId: id });
17
+ export const revisionQuerySchema = z.strictObject({ kbId: selector, revision: id.optional() });
@@ -0,0 +1,3 @@
1
+ import type { SkillProvider } from '@deepseek-ai/dsh-skill';
2
+ /** Packaged, invocation-neutral skills; no copies in the operator's user directory. */
3
+ export declare function skillProvider(): SkillProvider;
package/lib/skills.js ADDED
@@ -0,0 +1,21 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { checkAbort, required } from "./util.js";
4
+ /** Packaged, invocation-neutral skills; no copies in the operator's user directory. */
5
+ export function skillProvider() {
6
+ const provider = 'libing-knowledge-base', names = ['libing-knowledge-base', 'libing-kb-build', 'libing-kb-search'];
7
+ const candidates = names.map(name => {
8
+ const directory = fileURLToPath(new URL(`../skills/${name}/`, import.meta.url)), path = fileURLToPath(new URL(`../skills/${name}/SKILL.md`, import.meta.url));
9
+ const raw = readFileSync(path, 'utf8'), header = required(/^---\n([\s\S]*?)\n---\n/u.exec(raw), `skill frontmatter: ${name}`);
10
+ const description = required(/^description:\s*(.+)$/mu.exec(required(header[1]))?.[1], `skill description: ${name}`);
11
+ return { name, description, source: 'bundled', provider, rank: 600, path, resourceBase: { kind: 'directory', path: directory }, invocation: { modelInvocable: true, userInvocable: true }, locator: path };
12
+ });
13
+ return { name: provider, list: async (options) => { checkAbort(options.signal); return candidates; }, get: async (candidate, options) => {
14
+ checkAbort(options.signal);
15
+ const owned = candidates.find(value => value.name === candidate.name && value.locator === candidate.locator);
16
+ if (!owned || typeof owned.locator !== 'string')
17
+ return undefined;
18
+ const { rank: _rank, locator: _locator, ...summary } = owned;
19
+ return { ...summary, content: readFileSync(owned.locator, 'utf8').replace(/^---\n[\s\S]*?\n---\n/u, '').trim() };
20
+ } };
21
+ }
package/lib/store.d.ts ADDED
@@ -0,0 +1,409 @@
1
+ import type { Settings } from './config.ts';
2
+ import { z } from 'zod';
3
+ import { registrySchema } from './data.ts';
4
+ import type { Library, Manifest, Snapshot, Chunk, PublishedDocument, BuildDocument, Overlay } from './data.ts';
5
+ export declare const DEFAULT_SCHEMA = "# \u77E5\u8BC6\u5E93\u6CBB\u7406\u7EA6\u5B9A\n\n\u4FDD\u7559\u539F\u6587\u4E2D\u7684\u578B\u53F7\u3001\u7BA1\u811A\u3001\u5355\u4F4D\u3001\u6570\u503C\u3001\u6781\u6027\u548C\u9002\u7528\u6761\u4EF6\u3002\u56FE\u7247\u63CF\u8FF0\u4E0E\u539F\u6587\u5206\u522B\u6807\u6CE8\uFF1B\u4E0D\u786E\u5B9A\u7684\u4FE1\u606F\u4FDD\u7559\u5F85\u590D\u6838\u3002\u6458\u8981\u7528\u4E8E\u5BFC\u822A\uFF0C\u56DE\u7B54\u4F9D\u636E\u539F\u6587\u548C\u53EF\u6838\u9A8C\u56FE\u50CF\u3002\u5F15\u7528\u5305\u542B\u6587\u6863\u7248\u672C\u3001\u7AE0\u8282\u3001\u7247\u6BB5\u548C\u56FE\u8868\u7F16\u53F7\u3002\n";
6
+ export declare class Store {
7
+ readonly config: Settings;
8
+ readonly root: string;
9
+ private registryTail;
10
+ constructor(config: Settings);
11
+ init(): Promise<void>;
12
+ serialized<T>(fn: () => Promise<T>): Promise<T>;
13
+ list(includeDeleted?: boolean): Promise<Library[]>;
14
+ deleted(): Promise<{
15
+ kbId: string;
16
+ name: string;
17
+ createdAt: string;
18
+ deletedAt?: string | undefined;
19
+ purge?: {
20
+ startedAt: string;
21
+ jobIds: string[];
22
+ error?: string | undefined;
23
+ } | undefined;
24
+ }[]>;
25
+ activities(): Promise<{
26
+ eventId: string;
27
+ at: string;
28
+ action: "purge" | "create" | "trash" | "restore";
29
+ kbId: string;
30
+ name: string;
31
+ }[]>;
32
+ record(registry: z.infer<typeof registrySchema>, action: 'create' | 'trash' | 'restore' | 'purge', kb: Library): void;
33
+ trash(kbId: string, expectedName: string): Promise<{
34
+ kbId: string;
35
+ name: string;
36
+ createdAt: string;
37
+ deletedAt?: string | undefined;
38
+ purge?: {
39
+ startedAt: string;
40
+ jobIds: string[];
41
+ error?: string | undefined;
42
+ } | undefined;
43
+ }>;
44
+ restore(kbId: string): Promise<{
45
+ kbId: string;
46
+ name: string;
47
+ createdAt: string;
48
+ deletedAt?: string | undefined;
49
+ purge?: {
50
+ startedAt: string;
51
+ jobIds: string[];
52
+ error?: string | undefined;
53
+ } | undefined;
54
+ }>;
55
+ purgeTarget(group: 'kbs' | 'jobs', key: string): Promise<string>;
56
+ removePurgeTree(path: string): Promise<void>;
57
+ purge(kbId: string, expectedName: string, confirmed: boolean, jobIds?: string[]): Promise<{
58
+ kbId: string;
59
+ name: string;
60
+ purged: boolean;
61
+ }>;
62
+ kb(selector: string): Promise<{
63
+ kbId: string;
64
+ name: string;
65
+ createdAt: string;
66
+ deletedAt?: string | undefined;
67
+ purge?: {
68
+ startedAt: string;
69
+ jobIds: string[];
70
+ error?: string | undefined;
71
+ } | undefined;
72
+ }>;
73
+ create(name: string): Promise<{
74
+ kbId: string;
75
+ name: string;
76
+ createdAt: string;
77
+ }>;
78
+ kbRoot(kbId: string): string;
79
+ inspect(kbId: string, revision?: string): Promise<{
80
+ location: {
81
+ kbPath: string;
82
+ revision: null;
83
+ wikiPath: null;
84
+ indexPath: null;
85
+ };
86
+ summary: {
87
+ revision: null;
88
+ documentCount: number;
89
+ chunkCount: number;
90
+ coverageIncomplete: boolean;
91
+ };
92
+ } | {
93
+ location: {
94
+ kbPath: string;
95
+ revision: string;
96
+ wikiPath: string;
97
+ indexPath: string;
98
+ };
99
+ summary: {
100
+ revision: string;
101
+ documentCount: number;
102
+ chunkCount: number;
103
+ coverageIncomplete: boolean;
104
+ };
105
+ }>;
106
+ location(kbId: string, revision?: string): Promise<{
107
+ kbPath: string;
108
+ revision: null;
109
+ wikiPath: null;
110
+ indexPath: null;
111
+ } | {
112
+ kbPath: string;
113
+ revision: string;
114
+ wikiPath: string;
115
+ indexPath: string;
116
+ }>;
117
+ schema(kbId: string): Promise<string>;
118
+ setSchema(kbId: string, content: string, expectedHash: string): Promise<{
119
+ content: string;
120
+ hash: string;
121
+ }>;
122
+ upload(data: Buffer, filename: string): Promise<{
123
+ receiptId: string;
124
+ filename: string;
125
+ bytes: number;
126
+ }>;
127
+ uploaded(receiptId: string): Promise<{
128
+ data: Buffer<ArrayBufferLike>;
129
+ receiptId: string;
130
+ filename: string;
131
+ createdAt: string;
132
+ bytes: number;
133
+ hash: string;
134
+ }>;
135
+ current(kbId: string): Promise<{
136
+ revision: string;
137
+ publishedAt: string;
138
+ buildKey: string;
139
+ coverageIncomplete: boolean;
140
+ } | null>;
141
+ revision(kbId: string, requested?: string): Promise<Snapshot>;
142
+ readChunk(kbId: string, revision: string | undefined, chunkId: string): Promise<{
143
+ chunk: {
144
+ chunkId: string;
145
+ docId: string;
146
+ sourceHash: string;
147
+ sourceVersion: string;
148
+ title: string;
149
+ nodeId: string;
150
+ headingPath: string[];
151
+ blockRange: [string, string];
152
+ assetRefs: string[];
153
+ tableRefs: string[];
154
+ relatedChunks: string[];
155
+ reviewStatus: "source" | "generated" | "needs-review";
156
+ path: string;
157
+ segments: {
158
+ text: string;
159
+ blockIds: string[];
160
+ type: "code" | "caption" | "table" | "heading" | "paragraph" | "figure" | "list" | "note" | "formula";
161
+ sourceLocations?: import("./data.ts").Source[] | undefined;
162
+ startLine?: number | undefined;
163
+ endLine?: number | undefined;
164
+ }[];
165
+ anchors: string[];
166
+ fullChars: number;
167
+ bodyChars: number;
168
+ contentHash: string;
169
+ summary: string;
170
+ keywords: string[];
171
+ sourceFormat?: "docx" | "pdf" | undefined;
172
+ sourceLocations?: import("./data.ts").Source[] | undefined;
173
+ pageRange?: [number, number] | undefined;
174
+ selectedPages?: {
175
+ start: number;
176
+ end: number;
177
+ count: number;
178
+ total: number;
179
+ partial: boolean;
180
+ } | undefined;
181
+ oversizedReason?: string | undefined;
182
+ summaryFallback?: boolean | undefined;
183
+ };
184
+ content: string;
185
+ root: string;
186
+ revision: string;
187
+ manifest: Manifest;
188
+ }>;
189
+ chunkContent(snapshot: Snapshot, chunk: Chunk): Promise<string>;
190
+ asset(kbId: string, revision: string | undefined, docId: string, assetId: string): Promise<{
191
+ asset: {
192
+ assetId: string;
193
+ mime: string;
194
+ path: string;
195
+ bytes: number;
196
+ origin: string;
197
+ source?: import("./data.ts").Source | undefined;
198
+ };
199
+ file: string;
200
+ doc: {
201
+ docId: string;
202
+ title: string;
203
+ filename: string;
204
+ sourceHash: string;
205
+ sourceVersion: string;
206
+ nodes: {
207
+ nodeId: string;
208
+ title: string;
209
+ level: number;
210
+ parentId: string | null;
211
+ headingPath: string[];
212
+ children: string[];
213
+ anchor?: string | null | undefined;
214
+ indexPath?: string | undefined;
215
+ }[];
216
+ chunks: {
217
+ chunkId: string;
218
+ docId: string;
219
+ sourceHash: string;
220
+ sourceVersion: string;
221
+ title: string;
222
+ nodeId: string;
223
+ headingPath: string[];
224
+ blockRange: [string, string];
225
+ assetRefs: string[];
226
+ tableRefs: string[];
227
+ relatedChunks: string[];
228
+ reviewStatus: "source" | "generated" | "needs-review";
229
+ path: string;
230
+ segments: {
231
+ text: string;
232
+ blockIds: string[];
233
+ type: "code" | "caption" | "table" | "heading" | "paragraph" | "figure" | "list" | "note" | "formula";
234
+ sourceLocations?: import("./data.ts").Source[] | undefined;
235
+ startLine?: number | undefined;
236
+ endLine?: number | undefined;
237
+ }[];
238
+ anchors: string[];
239
+ fullChars: number;
240
+ bodyChars: number;
241
+ contentHash: string;
242
+ summary: string;
243
+ keywords: string[];
244
+ sourceFormat?: "docx" | "pdf" | undefined;
245
+ sourceLocations?: import("./data.ts").Source[] | undefined;
246
+ pageRange?: [number, number] | undefined;
247
+ selectedPages?: {
248
+ start: number;
249
+ end: number;
250
+ count: number;
251
+ total: number;
252
+ partial: boolean;
253
+ } | undefined;
254
+ oversizedReason?: string | undefined;
255
+ summaryFallback?: boolean | undefined;
256
+ }[];
257
+ assets: {
258
+ assetId: string;
259
+ mime: string;
260
+ path: string;
261
+ bytes: number;
262
+ origin: string;
263
+ source?: import("./data.ts").Source | undefined;
264
+ }[];
265
+ figures: {
266
+ status: "decoration" | "generated" | "failed" | "skipped" | "ignored" | "reviewed";
267
+ assetId: string;
268
+ occurrenceId: string;
269
+ caption: string;
270
+ cacheKey: string;
271
+ overlayKey: string;
272
+ overlayHash: string;
273
+ humanReviewed: boolean;
274
+ needsReview: boolean;
275
+ types?: ("architecture" | "pinout" | "schematic" | "timing" | "flowchart" | "table" | "curve" | "other" | "decoration")[] | undefined;
276
+ visibleLabels?: string[] | undefined;
277
+ description?: string | undefined;
278
+ relations?: {
279
+ from: string;
280
+ to: string;
281
+ label: string;
282
+ }[] | undefined;
283
+ uncertainties?: string[] | undefined;
284
+ contextNotes?: string | undefined;
285
+ pins?: z.core.util.JSONType[] | undefined;
286
+ timingConstraints?: z.core.util.JSONType[] | undefined;
287
+ tableRows?: z.core.util.JSONType[] | undefined;
288
+ error?: string | undefined;
289
+ classification?: {
290
+ types: ("architecture" | "pinout" | "schematic" | "timing" | "flowchart" | "table" | "curve" | "other" | "decoration")[];
291
+ reason: string;
292
+ } | undefined;
293
+ width?: number | undefined;
294
+ height?: number | undefined;
295
+ model?: {
296
+ provider: string;
297
+ model: string;
298
+ } | undefined;
299
+ promptVersion?: string | undefined;
300
+ context?: {
301
+ headingPath: string[];
302
+ nearby: string[];
303
+ caption?: string | undefined;
304
+ } | undefined;
305
+ source?: import("./data.ts").Source | undefined;
306
+ nativeLabels?: string[] | undefined;
307
+ refreshToken?: string | undefined;
308
+ ignore?: boolean | undefined;
309
+ skip?: boolean | undefined;
310
+ previous?: Overlay | null | undefined;
311
+ updatedAt?: string | undefined;
312
+ }[];
313
+ sourceFormat?: "docx" | "pdf" | undefined;
314
+ pageCount?: number | undefined;
315
+ selectedPages?: {
316
+ start: number;
317
+ end: number;
318
+ count: number;
319
+ total: number;
320
+ partial: boolean;
321
+ } | undefined;
322
+ parserVersion?: string | undefined;
323
+ audit?: {
324
+ pages: {
325
+ page: number;
326
+ status: "failed" | "needs-review" | "navigation" | "parsed";
327
+ ocr: boolean;
328
+ tables: number;
329
+ figures: number;
330
+ headings: {
331
+ text: string;
332
+ level: number;
333
+ basis?: string | undefined;
334
+ }[];
335
+ width?: number | undefined;
336
+ height?: number | undefined;
337
+ pageLabel?: string | null | undefined;
338
+ spanCount?: number | undefined;
339
+ artifactCount?: number | undefined;
340
+ excluded?: {
341
+ kind: string;
342
+ bbox: [number, number, number, number] | null;
343
+ text?: string | undefined;
344
+ }[] | undefined;
345
+ previewAssetId?: string | null | undefined;
346
+ error?: string | undefined;
347
+ }[];
348
+ outlineCount: number;
349
+ matchedBookmarks: number;
350
+ convertedFigures: number;
351
+ convertedTables: number;
352
+ warnings?: {
353
+ code: string;
354
+ message: string;
355
+ blocking: boolean;
356
+ page?: number | undefined;
357
+ kind?: string | undefined;
358
+ snippet?: string | undefined;
359
+ reason?: string | undefined;
360
+ }[] | undefined;
361
+ styleLevels?: Record<string, number> | undefined;
362
+ headingLevels?: Record<string, number> | undefined;
363
+ outlineLevels?: Record<string, number> | undefined;
364
+ expectedFigures?: number | undefined;
365
+ expectedTables?: number | undefined;
366
+ expectedHeadings?: string[] | undefined;
367
+ textBoxes?: number | undefined;
368
+ footnoteRefs?: number | undefined;
369
+ anchors?: string[] | undefined;
370
+ rawMediaCount?: number | undefined;
371
+ } | undefined;
372
+ chunkTargetChars?: number | undefined;
373
+ coverageIncomplete?: boolean | undefined;
374
+ warnings?: {
375
+ code: string;
376
+ message: string;
377
+ blocking: boolean;
378
+ page?: number | undefined;
379
+ kind?: string | undefined;
380
+ snippet?: string | undefined;
381
+ reason?: string | undefined;
382
+ }[] | undefined;
383
+ };
384
+ root: string;
385
+ revision: string;
386
+ manifest: Manifest;
387
+ }>;
388
+ rawSnapshot(kbId: string, docId: string, sourceHash: string, data: Buffer, info: {
389
+ sourceFormat: string;
390
+ [key: string]: unknown;
391
+ }): Promise<{
392
+ root: string;
393
+ file: string;
394
+ }>;
395
+ rawSource(kbId: string, doc: PublishedDocument): Promise<{
396
+ file: string;
397
+ data: Buffer<ArrayBufferLike>;
398
+ }>;
399
+ carryPrevious(kbId: string, destination: string, replaceDocId: string): Promise<BuildDocument[]>;
400
+ publish(kbId: string, revision: string, stage: string, manifest: Manifest, operation: {
401
+ jobId: string;
402
+ kind: string;
403
+ docId: string;
404
+ }): Promise<string>;
405
+ overlays(kbId: string): Promise<Record<string, Overlay>>;
406
+ setOverlay(kbId: string, key: string, value: Overlay | null, expectedHash: string): Promise<Overlay | undefined>;
407
+ jobDirectories(): Promise<string[]>;
408
+ acquireOwner(): Promise<() => Promise<void>>;
409
+ }