@world-engines/project-host 0.1.0-alpha.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/LICENSE +46 -0
- package/assets/gui/WELogo-title.svg +11 -0
- package/assets/gui/app.js +1326 -0
- package/assets/gui/index.html +118 -0
- package/assets/gui/local-preview-asset-urls.js +61 -0
- package/assets/gui/local-preview-bridge.js +393 -0
- package/assets/gui/spatial-template-panel.js +233 -0
- package/assets/gui/styles.css +115 -0
- package/assets/gui/terrain-render.js +120 -0
- package/assets/gui/workspace-status.css +17 -0
- package/assets/gui/workspace-status.js +255 -0
- package/assets/gui/world-map-globe.js +187 -0
- package/assets/gui/world-map-worker.js +62 -0
- package/assets/gui/world-map.css +30 -0
- package/assets/gui/world-map.js +2466 -0
- package/dist/account-model-proxy.d.ts +21 -0
- package/dist/account-model-proxy.js +470 -0
- package/dist/authoring-browser-runtime.d.ts +7 -0
- package/dist/authoring-browser-runtime.js +110 -0
- package/dist/authoring-ingestion.d.ts +38 -0
- package/dist/authoring-ingestion.js +410 -0
- package/dist/authoring-model-connection.d.ts +166 -0
- package/dist/authoring-model-connection.js +757 -0
- package/dist/chinese-lexical.d.ts +152 -0
- package/dist/chinese-lexical.js +555 -0
- package/dist/chromium-preview-browser-driver.d.ts +43 -0
- package/dist/chromium-preview-browser-driver.js +575 -0
- package/dist/cli/download.d.ts +12 -0
- package/dist/cli/download.js +50 -0
- package/dist/cli/dump.d.ts +32 -0
- package/dist/cli/dump.js +91 -0
- package/dist/cli/ingest.d.ts +49 -0
- package/dist/cli/ingest.js +225 -0
- package/dist/cli/review.d.ts +10 -0
- package/dist/cli/review.js +44 -0
- package/dist/cli/upload.d.ts +57 -0
- package/dist/cli/upload.js +112 -0
- package/dist/cli-command.d.ts +60 -0
- package/dist/cli-command.js +613 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +182 -0
- package/dist/desktop-authoring-runtime.d.ts +88 -0
- package/dist/desktop-authoring-runtime.js +1602 -0
- package/dist/desktop-sidecar.d.ts +11 -0
- package/dist/desktop-sidecar.js +143 -0
- package/dist/document-dump.d.ts +113 -0
- package/dist/document-dump.js +431 -0
- package/dist/document-graph-extractor.d.ts +125 -0
- package/dist/document-graph-extractor.js +588 -0
- package/dist/document-ingestion-journal.d.ts +68 -0
- package/dist/document-ingestion-journal.js +471 -0
- package/dist/document-ingestion.d.ts +183 -0
- package/dist/document-ingestion.js +976 -0
- package/dist/document-query-path-proof.d.ts +30 -0
- package/dist/document-query-path-proof.js +34 -0
- package/dist/document-query-path-renderer.d.ts +50 -0
- package/dist/document-query-path-renderer.js +75 -0
- package/dist/document-query-proof-paths.d.ts +22 -0
- package/dist/document-query-proof-paths.js +71 -0
- package/dist/document-query.d.ts +97 -0
- package/dist/document-query.js +1106 -0
- package/dist/document-relation-role.d.ts +14 -0
- package/dist/document-relation-role.js +86 -0
- package/dist/document-source.d.ts +107 -0
- package/dist/document-source.js +255 -0
- package/dist/embedding-cache.d.ts +35 -0
- package/dist/embedding-cache.js +317 -0
- package/dist/frozen-review-local-pipeline.d.ts +88 -0
- package/dist/frozen-review-local-pipeline.js +609 -0
- package/dist/frozen-review-source-capture.d.ts +15 -0
- package/dist/frozen-review-source-capture.js +551 -0
- package/dist/frozen-review-wasm-encryptor.d.ts +16 -0
- package/dist/frozen-review-wasm-encryptor.js +72 -0
- package/dist/frozen-review.d.ts +131 -0
- package/dist/frozen-review.js +802 -0
- package/dist/graph-traversal.d.ts +23 -0
- package/dist/graph-traversal.js +100 -0
- package/dist/gui/graph-layout-worker.js +1 -0
- package/dist/gui/graph-layout.wasm +0 -0
- package/dist/gui/graph.css +1 -0
- package/dist/gui/graph.js +76 -0
- package/dist/gui/plane-generation.js +112 -0
- package/dist/gui/plane-generator.js +310 -0
- package/dist/gui/plane-generator_bg.wasm +0 -0
- package/dist/gui/procedural-city.js +595 -0
- package/dist/gui/road-generation.js +129 -0
- package/dist/gui/road-parcels.js +1584 -0
- package/dist/gui/score.css +1 -0
- package/dist/gui/score.js +54 -0
- package/dist/gui/spatial-runtime.js +1231 -0
- package/dist/gui/spatial-templates.js +200 -0
- package/dist/gui/trigger.css +1 -0
- package/dist/gui/trigger.js +142 -0
- package/dist/harness-callback-transport.d.ts +17 -0
- package/dist/harness-callback-transport.js +128 -0
- package/dist/harness-document-ingestion.d.ts +77 -0
- package/dist/harness-document-ingestion.js +343 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +43 -0
- package/dist/ingestion-source-reconciliation.d.ts +88 -0
- package/dist/ingestion-source-reconciliation.js +253 -0
- package/dist/ladybug-runtime.d.ts +117 -0
- package/dist/ladybug-runtime.js +886 -0
- package/dist/local-account-embedding.d.ts +34 -0
- package/dist/local-account-embedding.js +294 -0
- package/dist/local-gallery.d.ts +35 -0
- package/dist/local-gallery.js +227 -0
- package/dist/local-gui-auth.d.ts +96 -0
- package/dist/local-gui-auth.js +703 -0
- package/dist/local-gui-contract.d.ts +53 -0
- package/dist/local-gui-contract.js +5 -0
- package/dist/local-gui-image-assets.d.ts +17 -0
- package/dist/local-gui-image-assets.js +96 -0
- package/dist/local-gui-preview-client.d.ts +3 -0
- package/dist/local-gui-preview-client.js +111 -0
- package/dist/local-gui-score.d.ts +72 -0
- package/dist/local-gui-score.js +184 -0
- package/dist/local-gui-server.d.ts +10 -0
- package/dist/local-gui-server.js +987 -0
- package/dist/local-gui-version.d.ts +17 -0
- package/dist/local-gui-version.js +147 -0
- package/dist/local-gui-workspace.d.ts +14 -0
- package/dist/local-gui-workspace.js +171 -0
- package/dist/local-model-settings.d.ts +28 -0
- package/dist/local-model-settings.js +124 -0
- package/dist/local-preview-assets.d.ts +28 -0
- package/dist/local-preview-assets.js +124 -0
- package/dist/local-preview-bound-resources.d.ts +12 -0
- package/dist/local-preview-bound-resources.js +80 -0
- package/dist/local-preview-message-store.d.ts +63 -0
- package/dist/local-preview-message-store.js +214 -0
- package/dist/local-preview-player-read-models.d.ts +47 -0
- package/dist/local-preview-player-read-models.js +90 -0
- package/dist/local-preview-projections.d.ts +61 -0
- package/dist/local-preview-projections.js +117 -0
- package/dist/local-preview-runtime.d.ts +105 -0
- package/dist/local-preview-runtime.js +553 -0
- package/dist/local-preview-session.d.ts +73 -0
- package/dist/local-preview-session.js +395 -0
- package/dist/local-preview-source.d.ts +40 -0
- package/dist/local-preview-source.js +192 -0
- package/dist/local-preview-view-events.d.ts +101 -0
- package/dist/local-preview-view-events.js +179 -0
- package/dist/local-preview-view-state-sqlite.d.ts +24 -0
- package/dist/local-preview-view-state-sqlite.js +263 -0
- package/dist/local-preview-view-state.d.ts +93 -0
- package/dist/local-preview-view-state.js +108 -0
- package/dist/local-preview-vite-config.d.ts +6 -0
- package/dist/local-preview-vite-config.js +122 -0
- package/dist/local-preview-world-effects.d.ts +9 -0
- package/dist/local-preview-world-effects.js +55 -0
- package/dist/local-preview-worldline-store.d.ts +47 -0
- package/dist/local-preview-worldline-store.js +282 -0
- package/dist/local-preview-worldlines.d.ts +95 -0
- package/dist/local-preview-worldlines.js +136 -0
- package/dist/mcp-async-dispatcher.d.ts +3 -0
- package/dist/mcp-async-dispatcher.js +129 -0
- package/dist/mcp-line-queue.d.ts +14 -0
- package/dist/mcp-line-queue.js +184 -0
- package/dist/mcp-pipe-internal.d.ts +6 -0
- package/dist/mcp-pipe-internal.js +151 -0
- package/dist/mcp-pipe-response.d.ts +14 -0
- package/dist/mcp-pipe-response.js +50 -0
- package/dist/mcp-stdio-response.d.ts +12 -0
- package/dist/mcp-stdio-response.js +27 -0
- package/dist/mcp.d.ts +27 -0
- package/dist/mcp.js +194 -0
- package/dist/prepared-embedding-cache.d.ts +38 -0
- package/dist/prepared-embedding-cache.js +238 -0
- package/dist/preview-browser-adapter.d.ts +53 -0
- package/dist/preview-browser-adapter.js +171 -0
- package/dist/preview-runtime.d.ts +67 -0
- package/dist/preview-runtime.js +460 -0
- package/dist/project-auth-transport.d.ts +27 -0
- package/dist/project-auth-transport.js +121 -0
- package/dist/project-auth.d.ts +51 -0
- package/dist/project-auth.js +108 -0
- package/dist/project-git-capture-recovery.d.ts +16 -0
- package/dist/project-git-capture-recovery.js +347 -0
- package/dist/project-git-cli.d.ts +5 -0
- package/dist/project-git-cli.js +40 -0
- package/dist/project-git-scenario-source.d.ts +10 -0
- package/dist/project-git-scenario-source.js +240 -0
- package/dist/project-git-view-source.d.ts +13 -0
- package/dist/project-git-view-source.js +134 -0
- package/dist/project-git.d.ts +97 -0
- package/dist/project-git.js +656 -0
- package/dist/project-host.d.ts +59 -0
- package/dist/project-host.js +471 -0
- package/dist/project-writer-lease.d.ts +18 -0
- package/dist/project-writer-lease.js +430 -0
- package/dist/public-error.d.ts +7 -0
- package/dist/public-error.js +61 -0
- package/dist/retrieval-benchmark.d.ts +46 -0
- package/dist/retrieval-benchmark.js +58 -0
- package/dist/safe-project-path.d.ts +8 -0
- package/dist/safe-project-path.js +93 -0
- package/dist/scenario-writer.d.ts +32 -0
- package/dist/scenario-writer.js +191 -0
- package/dist/transfer/download.d.ts +159 -0
- package/dist/transfer/download.js +598 -0
- package/dist/transfer/transport.d.ts +26 -0
- package/dist/transfer/transport.js +1 -0
- package/dist/transfer/upload.d.ts +162 -0
- package/dist/transfer/upload.js +354 -0
- package/dist/transfer-types.d.ts +95 -0
- package/dist/transfer-types.js +1 -0
- package/dist/transfer.d.ts +18 -0
- package/dist/transfer.js +273 -0
- package/dist/trigger-runtime.d.ts +121 -0
- package/dist/trigger-runtime.js +153 -0
- package/dist/vendor/wasm-core/asset-hashes.json +5 -0
- package/dist/vendor/wasm-core/wasm_core.d.ts +490 -0
- package/dist/vendor/wasm-core/wasm_core.js +1 -0
- package/dist/vendor/wasm-core/wasm_core_bg.wasm +0 -0
- package/dist/view-watcher.d.ts +9 -0
- package/dist/view-watcher.js +34 -0
- package/package.json +110 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DESKTOP_PRIVATE_PROTOCOL: "worldengine.project-transfer.private.v1";
|
|
2
|
+
export declare const DESKTOP_PRIVATE_MAX_REQUEST_BYTES: number;
|
|
3
|
+
export interface DesktopPrivateRequest {
|
|
4
|
+
readonly namespace: typeof DESKTOP_PRIVATE_PROTOCOL;
|
|
5
|
+
readonly capability: "project_transfer";
|
|
6
|
+
readonly method: "upload.prepare" | "download.inspect" | "download.apply" | "download.restore";
|
|
7
|
+
readonly request_digest: string;
|
|
8
|
+
readonly payload: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** 与 MCP tools/list 完全分离的版本化 Desktop RPC。 */
|
|
11
|
+
export declare function handleDesktopPrivateRequest(root: string, request: DesktopPrivateRequest): Promise<unknown>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { AuthoringBridgeError } from "@world-engines/authoring-bridge";
|
|
5
|
+
import { assertSafeExistingProjectPath } from "./safe-project-path.js";
|
|
6
|
+
import { DownloadReplaceCoordinator, decodeRemoteViewBundle, parseRemoteDownloadPlan } from "./transfer/download.js";
|
|
7
|
+
import { captureUploadSnapshot } from "./transfer/upload.js";
|
|
8
|
+
import { LocalProjectHost } from "./project-host.js";
|
|
9
|
+
export const DESKTOP_PRIVATE_PROTOCOL = "worldengine.project-transfer.private.v1";
|
|
10
|
+
export const DESKTOP_PRIVATE_MAX_REQUEST_BYTES = 8 * 1024 * 1024;
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
function record(value, code) {
|
|
13
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
14
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", code);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function digest(bytes) { return createHash("sha256").update(bytes).digest("hex"); }
|
|
18
|
+
function exactKeys(value, keys, code) {
|
|
19
|
+
const actual = Object.keys(value).sort();
|
|
20
|
+
const expected = [...keys].sort();
|
|
21
|
+
if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index]))
|
|
22
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", code);
|
|
23
|
+
}
|
|
24
|
+
function incomingObject(value, objectRef, expectedMediaType, code) {
|
|
25
|
+
const input = record(value, code);
|
|
26
|
+
exactKeys(input, ["content_base64", "sha256", "byte_length"], code);
|
|
27
|
+
if (typeof input.content_base64 !== "string" || input.sha256 !== objectRef.sha256 || input.byte_length !== objectRef.byteLength || objectRef.mediaType !== expectedMediaType)
|
|
28
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", code);
|
|
29
|
+
const bytes = new Uint8Array(Buffer.from(input.content_base64, "base64"));
|
|
30
|
+
if (bytes.length !== objectRef.byteLength || digest(bytes) !== objectRef.sha256)
|
|
31
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", code);
|
|
32
|
+
return bytes;
|
|
33
|
+
}
|
|
34
|
+
function downloadPlanFromGuiPayload(payload, operationId, expectedProjectRevision) {
|
|
35
|
+
const remotePayload = record(payload.remote_plan, "download remote_plan 无效");
|
|
36
|
+
const remote = parseRemoteDownloadPlan(remotePayload);
|
|
37
|
+
const objects = record(payload.objects, "download objects 无效");
|
|
38
|
+
exactKeys(objects, remote.parts, "download objects 与 frozen parts 不一致");
|
|
39
|
+
const scenario = remote.scenarioObject === undefined ? undefined : incomingObject(objects.scenario, remote.scenarioObject, "application/vnd.worldengine.wesp", "download scenario object 无效");
|
|
40
|
+
const view = remote.viewObject === undefined ? undefined : incomingObject(objects.view, remote.viewObject, "application/vnd.worldengine.svp", "download view object 无效");
|
|
41
|
+
return {
|
|
42
|
+
remote,
|
|
43
|
+
plan: {
|
|
44
|
+
schema_version: 1,
|
|
45
|
+
operation_id: operationId,
|
|
46
|
+
plan_digest: remote.planDigest,
|
|
47
|
+
expected_project_revision: expectedProjectRevision,
|
|
48
|
+
selection: remote.parts.length === 2 ? "both" : remote.parts[0],
|
|
49
|
+
...(scenario === undefined ? {} : { scenario: { source_base64: Buffer.from(scenario).toString("base64"), sha256: digest(scenario) } }),
|
|
50
|
+
...(view === undefined ? {} : { view: decodeRemoteViewBundle(view) }),
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function validateEnvelope(request) {
|
|
55
|
+
if (request.namespace !== DESKTOP_PRIVATE_PROTOCOL || request.capability !== "project_transfer") {
|
|
56
|
+
throw new AuthoringBridgeError("E_AUTH_REQUIRED", "private sidecar capability 无效");
|
|
57
|
+
}
|
|
58
|
+
const bytes = new TextEncoder().encode(JSON.stringify(request.payload));
|
|
59
|
+
if (bytes.length > DESKTOP_PRIVATE_MAX_REQUEST_BYTES)
|
|
60
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", "private sidecar 请求过大");
|
|
61
|
+
if (!/^[a-f0-9]{64}$/.test(request.request_digest) || digest(bytes) !== request.request_digest) {
|
|
62
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", "private sidecar request digest 不匹配");
|
|
63
|
+
}
|
|
64
|
+
return record(request.payload, "private sidecar payload 无效");
|
|
65
|
+
}
|
|
66
|
+
/** 与 MCP tools/list 完全分离的版本化 Desktop RPC。 */
|
|
67
|
+
export async function handleDesktopPrivateRequest(root, request) {
|
|
68
|
+
const canonicalRoot = await assertSafeExistingProjectPath(root, root);
|
|
69
|
+
const payload = validateEnvelope(request);
|
|
70
|
+
switch (request.method) {
|
|
71
|
+
case "upload.prepare": {
|
|
72
|
+
const operationId = payload.operation_id;
|
|
73
|
+
if (typeof operationId !== "string" || operationId.length === 0 || operationId.length > 256)
|
|
74
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", "upload operation_id 无效");
|
|
75
|
+
const captured = await captureUploadSnapshot(canonicalRoot);
|
|
76
|
+
return {
|
|
77
|
+
schema_version: 1,
|
|
78
|
+
operation_id: operationId,
|
|
79
|
+
snapshot: captured.snapshot,
|
|
80
|
+
objects: captured.objects.map(({ bytes, ...object }) => ({ ...object, content_base64: Buffer.from(bytes).toString("base64") })),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
case "download.apply": {
|
|
84
|
+
exactKeys(payload, ["remote_plan", "objects", "inspection", "confirmation"], "download apply payload 无效");
|
|
85
|
+
const confirmation = record(payload.confirmation, "download confirmation 无效");
|
|
86
|
+
if (typeof confirmation.operation_id !== "string" || typeof confirmation.plan_digest !== "string")
|
|
87
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", "download confirmation 无效");
|
|
88
|
+
const inspection = record(payload.inspection, "download inspection 无效");
|
|
89
|
+
if (typeof inspection.expected_project_revision !== "number" || !Number.isSafeInteger(inspection.expected_project_revision) || inspection.expected_project_revision < 0)
|
|
90
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", "download inspection revision 无效");
|
|
91
|
+
if (confirmation.local_inspection_digest !== undefined && confirmation.local_inspection_digest !== inspection.local_inspection_digest)
|
|
92
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", "download confirmation inspection digest 不匹配");
|
|
93
|
+
const { plan } = downloadPlanFromGuiPayload(payload, confirmation.operation_id, inspection.expected_project_revision);
|
|
94
|
+
if (confirmation.plan_digest !== plan.plan_digest || inspection.remote_plan_digest !== plan.plan_digest)
|
|
95
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", "download confirmation 未绑定 frozen plan");
|
|
96
|
+
const coordinator = await DownloadReplaceCoordinator.open(canonicalRoot, {
|
|
97
|
+
installViewDependencies: async (stagingViewRoot) => {
|
|
98
|
+
await execFileAsync(process.platform === "win32" ? "npm.cmd" : "npm", ["ci", "--ignore-scripts", "--no-audit", "--no-fund"], {
|
|
99
|
+
cwd: stagingViewRoot,
|
|
100
|
+
timeout: 5 * 60_000,
|
|
101
|
+
windowsHide: true,
|
|
102
|
+
maxBuffer: 1024 * 1024,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
readProjection: async (receipt) => {
|
|
106
|
+
const host = await LocalProjectHost.open(canonicalRoot);
|
|
107
|
+
try {
|
|
108
|
+
const readback = await host.readTransferReadback();
|
|
109
|
+
if (readback.project_revision !== receipt.next_project_revision || readback.snapshot_digest !== receipt.project_snapshot_digest || readback.scenario_sha256 !== receipt.scenario_sha256 || readback.view_source_tree_sha256 !== receipt.view_source_tree_sha256)
|
|
110
|
+
throw new AuthoringBridgeError("E_OPERATION_UNCERTAIN", "download ProjectHost transfer readback 不匹配");
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
await host.close();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
try {
|
|
118
|
+
const receipt = await coordinator.apply(plan, {
|
|
119
|
+
operation_id: String(confirmation.operation_id ?? ""),
|
|
120
|
+
plan_digest: String(confirmation.plan_digest ?? ""),
|
|
121
|
+
}, inspection);
|
|
122
|
+
return receipt;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
await coordinator.restore(String(confirmation.operation_id ?? "")).catch(() => undefined);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
case "download.inspect": {
|
|
130
|
+
exactKeys(payload, ["remote_plan", "objects"], "download inspect payload 无效");
|
|
131
|
+
const remote = parseRemoteDownloadPlan(record(payload.remote_plan, "download remote_plan 无效"));
|
|
132
|
+
const { plan } = downloadPlanFromGuiPayload(payload, `download.inspect.${remote.planId}`, 0);
|
|
133
|
+
return (await DownloadReplaceCoordinator.open(canonicalRoot)).inspect(plan, remote.planId);
|
|
134
|
+
}
|
|
135
|
+
case "download.restore": {
|
|
136
|
+
const operationId = payload.operation_id;
|
|
137
|
+
if (typeof operationId !== "string" || operationId.length === 0 || operationId.length > 256)
|
|
138
|
+
throw new AuthoringBridgeError("E_SCHEMA_INVALID", "restore operation_id 无效");
|
|
139
|
+
await (await DownloadReplaceCoordinator.open(canonicalRoot)).restore(operationId);
|
|
140
|
+
return { schema_version: 1, operation_id: operationId, restored: true };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ScenarioSourceReadback } from "./scenario-writer.js";
|
|
2
|
+
import { type LadybugGraphSnapshot } from "./ladybug-runtime.js";
|
|
3
|
+
type Span = {
|
|
4
|
+
startOffset: number;
|
|
5
|
+
endOffset: number;
|
|
6
|
+
};
|
|
7
|
+
export interface DocumentDumpExtractionStatus {
|
|
8
|
+
graphStatus: "partial" | "complete" | "not_recorded";
|
|
9
|
+
processedWindows: number | null;
|
|
10
|
+
authorityMarkerId: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface DocumentDumpProjectionVerification {
|
|
13
|
+
status: "verified" | "mismatch" | "not_checked";
|
|
14
|
+
sourceSha256: string | null;
|
|
15
|
+
projectRevision: number | null;
|
|
16
|
+
counts: {
|
|
17
|
+
expectedNodes: number;
|
|
18
|
+
actualNodes: number | null;
|
|
19
|
+
expectedEdges: number;
|
|
20
|
+
actualEdges: number | null;
|
|
21
|
+
};
|
|
22
|
+
missing: {
|
|
23
|
+
nodeIds: string[];
|
|
24
|
+
edgeIds: string[];
|
|
25
|
+
};
|
|
26
|
+
extra: {
|
|
27
|
+
nodeIds: string[];
|
|
28
|
+
edgeIds: string[];
|
|
29
|
+
};
|
|
30
|
+
mismatch: {
|
|
31
|
+
nodeIds: string[];
|
|
32
|
+
edgeIds: string[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface DocumentPlainTextDumpHost {
|
|
36
|
+
readSourceReadback(): Promise<ScenarioSourceReadback>;
|
|
37
|
+
readGraphProjectionReadback?(request: {
|
|
38
|
+
scopeId?: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
project_revision: number;
|
|
41
|
+
source_sha256: string;
|
|
42
|
+
graph: LadybugGraphSnapshot;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
export interface DocumentPlainTextDumpManifest {
|
|
46
|
+
schemaVersion: 1;
|
|
47
|
+
documentId: string;
|
|
48
|
+
projectRevision: number;
|
|
49
|
+
scopeId: string;
|
|
50
|
+
sourceId: string;
|
|
51
|
+
sourceRevision: string;
|
|
52
|
+
authority: {
|
|
53
|
+
projectId: string;
|
|
54
|
+
wespSha256: string;
|
|
55
|
+
enumeration: "complete_logical_graph";
|
|
56
|
+
};
|
|
57
|
+
integrity: {
|
|
58
|
+
status: "verified" | "incomplete";
|
|
59
|
+
warnings: string[];
|
|
60
|
+
};
|
|
61
|
+
source: {
|
|
62
|
+
integrityStatus: "verified";
|
|
63
|
+
byteLength: number;
|
|
64
|
+
sha256: string;
|
|
65
|
+
utf16Length: number;
|
|
66
|
+
unicodeCodePoints: number;
|
|
67
|
+
hanCharacters: number;
|
|
68
|
+
};
|
|
69
|
+
extraction: DocumentDumpExtractionStatus;
|
|
70
|
+
projection: DocumentDumpProjectionVerification;
|
|
71
|
+
chunks: {
|
|
72
|
+
count: number;
|
|
73
|
+
reconstructedSha256: string;
|
|
74
|
+
coverageRatio: number;
|
|
75
|
+
gaps: Span[];
|
|
76
|
+
overlaps: Span[];
|
|
77
|
+
invalidCount: number;
|
|
78
|
+
};
|
|
79
|
+
graph: {
|
|
80
|
+
nodeCount: number;
|
|
81
|
+
edgeCount: number;
|
|
82
|
+
semanticEntityCount: number;
|
|
83
|
+
sourceChunkCount: number;
|
|
84
|
+
statementAssertionCount: number;
|
|
85
|
+
edgeAssertionCount: number;
|
|
86
|
+
structuralEdgeCount: number;
|
|
87
|
+
semanticEdgeCount: number;
|
|
88
|
+
unknownEdgeCount: number;
|
|
89
|
+
nodesByKind: Record<string, number>;
|
|
90
|
+
edgesByKind: Record<string, number>;
|
|
91
|
+
uniqueAssertionCount: number;
|
|
92
|
+
assertionBodyUtf16Length: number;
|
|
93
|
+
externalReferenceCount: number;
|
|
94
|
+
};
|
|
95
|
+
evidence: {
|
|
96
|
+
uniqueSpanCount: number;
|
|
97
|
+
coveredUtf16Length: number;
|
|
98
|
+
coverageRatio: number;
|
|
99
|
+
invalidCount: number;
|
|
100
|
+
};
|
|
101
|
+
interpretation: string[];
|
|
102
|
+
}
|
|
103
|
+
export interface DocumentPlainTextDump {
|
|
104
|
+
sourceBytes: Uint8Array;
|
|
105
|
+
graphText: string;
|
|
106
|
+
reviewText: string;
|
|
107
|
+
manifest: DocumentPlainTextDumpManifest;
|
|
108
|
+
}
|
|
109
|
+
/** 原文与枚举只消费一次 WESP authority;真实 Ladybug 只作同版本投影校验,不成为第二 authority。 */
|
|
110
|
+
export declare function createDocumentPlainTextDump(host: DocumentPlainTextDumpHost, request: {
|
|
111
|
+
documentId: string;
|
|
112
|
+
}): Promise<DocumentPlainTextDump>;
|
|
113
|
+
export {};
|