@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
package/dist/cli.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createInterface } from "node:readline/promises";
|
|
3
|
+
import { execFile, spawn } from "node:child_process";
|
|
4
|
+
import { realpath, readFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { AuthoringBridgeError } from "@world-engines/authoring-bridge";
|
|
8
|
+
import { runWorldengineCli } from "./cli-command.js";
|
|
9
|
+
import { createProjectAuthTransport } from "./project-auth-transport.js";
|
|
10
|
+
import { writeCliPublicError } from "./public-error.js";
|
|
11
|
+
import { createCachedEmbeddingPort } from "./embedding-cache.js";
|
|
12
|
+
import { createLocalAccountEmbeddingPort } from "./local-account-embedding.js";
|
|
13
|
+
import { startLocalAccountModelProxy } from "./account-model-proxy.js";
|
|
14
|
+
import { createPreparedEmbeddingSnapshotReader, persistPreparedFrozenEmbeddingBatch } from "./prepared-embedding-cache.js";
|
|
15
|
+
import { createFrozenReviewEmbeddingBatch, createFrozenReviewLocalArtifactAssembler, createFrozenReviewLocalPipeline, createCompilerReleaseProfileAdmission, createFrozenReviewRecoveryPort, } from "./frozen-review-local-pipeline.js";
|
|
16
|
+
import { createFrozenReviewSourceCapture } from "./frozen-review-source-capture.js";
|
|
17
|
+
import { createHarnessCallbackCapabilities } from "./harness-callback-transport.js";
|
|
18
|
+
import { runProjectHostMcpPipe } from "./mcp-pipe-internal.js";
|
|
19
|
+
import { LocalPreviewRuntime } from "./preview-runtime.js";
|
|
20
|
+
import { createAuthoringBrowserRuntime } from "./authoring-browser-runtime.js";
|
|
21
|
+
import { runProjectGitCli } from "./project-git-cli.js";
|
|
22
|
+
const argv = process.argv.slice(2);
|
|
23
|
+
const execFileAsync = promisify(execFile);
|
|
24
|
+
/** 只有实际使用向量时才解析账户;cache 命中也必须验证登录与账户 identity。 */
|
|
25
|
+
function accountEmbeddingResolver(projectRoot, projectId) {
|
|
26
|
+
return async () => {
|
|
27
|
+
const remote = await createLocalAccountEmbeddingPort({ projectRoot, projectId });
|
|
28
|
+
const cached = await createCachedEmbeddingPort({ projectRoot, embedding: remote, origin: remote.origin });
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
...cached,
|
|
31
|
+
assertCurrentAccount: remote.assertCurrentAccount,
|
|
32
|
+
async embed(texts, options) {
|
|
33
|
+
await remote.assertCurrentAccount(options);
|
|
34
|
+
const result = await cached.embed(texts, options);
|
|
35
|
+
await remote.assertCurrentAccount(options);
|
|
36
|
+
return result;
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function openSystemBrowser(url) {
|
|
42
|
+
const invocation = process.platform === "win32"
|
|
43
|
+
? { command: "rundll32.exe", args: ["url.dll,FileProtocolHandler", url] }
|
|
44
|
+
: process.platform === "darwin"
|
|
45
|
+
? { command: "open", args: [url] }
|
|
46
|
+
: { command: "xdg-open", args: [url] };
|
|
47
|
+
const child = spawn(invocation.command, invocation.args, { detached: true, stdio: "ignore", windowsHide: true, shell: false });
|
|
48
|
+
child.once("error", () => undefined);
|
|
49
|
+
child.unref();
|
|
50
|
+
}
|
|
51
|
+
async function main() {
|
|
52
|
+
const canonicalRoot = await realpath(resolve(process.cwd()));
|
|
53
|
+
if (argv[0] === "mcp" && argv[1] === "--pipe" && argv[3] === "--challenge" && argv.length === 5) {
|
|
54
|
+
return runProjectHostMcpPipe(canonicalRoot, argv[2] ?? "", argv[4] ?? "");
|
|
55
|
+
}
|
|
56
|
+
const needsTransport = argv[0] === "upload" || argv[0] === "download" || argv[0] === "review" || argv[0] === "git";
|
|
57
|
+
const manifest = JSON.parse(await readFile(resolve(canonicalRoot, "worldengine.project.json"), "utf8"));
|
|
58
|
+
const projectId = String(manifest.project_id ?? "");
|
|
59
|
+
const transport = needsTransport ? await createProjectAuthTransport(projectId) : undefined;
|
|
60
|
+
if (argv[0] === "git") {
|
|
61
|
+
return runProjectGitCli(argv.slice(1), canonicalRoot, transport, {
|
|
62
|
+
stdout: (text) => process.stdout.write(text),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const questions = (argv[0] === "upload" || (argv[0] === "tool" && argv[1] === "ask_user")) && process.stdin.isTTY === true
|
|
66
|
+
? createInterface({ input: process.stdin, output: process.stderr, terminal: process.stdin.isTTY === true })
|
|
67
|
+
: undefined;
|
|
68
|
+
const previewRuntime = new LocalPreviewRuntime();
|
|
69
|
+
const browserRuntime = createAuthoringBrowserRuntime(canonicalRoot, previewRuntime);
|
|
70
|
+
try {
|
|
71
|
+
const stagingRoot = join(canonicalRoot, ".worldengine", "download-staging");
|
|
72
|
+
const installViewDependencies = async (stagingViewRoot) => {
|
|
73
|
+
const canonicalStaging = await realpath(stagingViewRoot);
|
|
74
|
+
if (!canonicalStaging.startsWith(`${stagingRoot}${sep}`) || !canonicalStaging.endsWith(`${sep}incoming${sep}view`))
|
|
75
|
+
throw new Error("download_staging_view_root_rejected");
|
|
76
|
+
const npmCli = process.platform === "win32" ? join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js") : undefined;
|
|
77
|
+
await execFileAsync(npmCli === undefined ? "npm" : process.execPath, [...(npmCli === undefined ? [] : [npmCli]), "ci", "--ignore-scripts", "--no-audit", "--no-fund"], { cwd: canonicalStaging, timeout: 5 * 60_000, windowsHide: true, maxBuffer: 1024 * 1024 });
|
|
78
|
+
};
|
|
79
|
+
const command = argv[0] ?? "";
|
|
80
|
+
const resolveEmbedding = accountEmbeddingResolver(canonicalRoot, projectId);
|
|
81
|
+
const brokerCallbacks = await createHarnessCallbackCapabilities(projectId);
|
|
82
|
+
const terminalAskUser = questions === undefined || command !== "tool" || argv[1] !== "ask_user"
|
|
83
|
+
? {}
|
|
84
|
+
: {
|
|
85
|
+
async ask_user(input) {
|
|
86
|
+
const prompt = String(input.prompt ?? "");
|
|
87
|
+
const choices = Array.isArray(input.choices) ? input.choices.filter((value) => typeof value === "string") : [];
|
|
88
|
+
const label = choices.length === 0 ? `${prompt} ` : `${prompt}\n${choices.map((choice, index) => `${index + 1}. ${choice}`).join("\n")}\n> `;
|
|
89
|
+
const raw = (await questions.question(label)).trim();
|
|
90
|
+
const indexed = /^\d+$/.test(raw) ? choices[Number(raw) - 1] : undefined;
|
|
91
|
+
const answer = indexed ?? raw;
|
|
92
|
+
if (answer.length === 0 || (choices.length > 0 && input.allow_freeform !== true && !choices.includes(answer))) {
|
|
93
|
+
throw new AuthoringBridgeError("E_VALIDATION_FAILED", "ask_user TTY 回答无效");
|
|
94
|
+
}
|
|
95
|
+
return { answer, ...(choices.includes(answer) ? { selected_choice: answer } : {}), transport: "terminal" };
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const desktopAuthoringCapabilities = {
|
|
99
|
+
...brokerCallbacks,
|
|
100
|
+
...browserRuntime.capabilities,
|
|
101
|
+
...terminalAskUser,
|
|
102
|
+
get_prepared_embedding_snapshot: async (request) => {
|
|
103
|
+
const embedding = await resolveEmbedding();
|
|
104
|
+
return createPreparedEmbeddingSnapshotReader({
|
|
105
|
+
projectRoot: canonicalRoot, projectId, embedding, origin: embedding.origin,
|
|
106
|
+
})(request);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const authoringRuntime = {
|
|
110
|
+
desktopAuthoringCapabilities,
|
|
111
|
+
resolveEmbedding,
|
|
112
|
+
};
|
|
113
|
+
const runtimeForTransport = (activeTransport) => ({
|
|
114
|
+
transport: activeTransport,
|
|
115
|
+
recovery: createFrozenReviewRecoveryPort({
|
|
116
|
+
project_root: canonicalRoot,
|
|
117
|
+
project_id: projectId,
|
|
118
|
+
transport: activeTransport,
|
|
119
|
+
}),
|
|
120
|
+
pipeline: createFrozenReviewLocalPipeline({
|
|
121
|
+
project_root: canonicalRoot,
|
|
122
|
+
project_id: projectId,
|
|
123
|
+
run_embedding_batch: persistPreparedFrozenEmbeddingBatch({
|
|
124
|
+
projectRoot: canonicalRoot,
|
|
125
|
+
projectId,
|
|
126
|
+
runBatch: async (request) => createFrozenReviewEmbeddingBatch(await resolveEmbedding())(request),
|
|
127
|
+
}),
|
|
128
|
+
read_source_ready: createFrozenReviewSourceCapture({
|
|
129
|
+
project_root: canonicalRoot,
|
|
130
|
+
project_id: projectId,
|
|
131
|
+
transport: activeTransport,
|
|
132
|
+
}),
|
|
133
|
+
assembler: createFrozenReviewLocalArtifactAssembler({
|
|
134
|
+
project_root: canonicalRoot,
|
|
135
|
+
project_id: projectId,
|
|
136
|
+
transport: activeTransport,
|
|
137
|
+
}),
|
|
138
|
+
admit_profile: createCompilerReleaseProfileAdmission(activeTransport, projectId),
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
const reviewRuntime = command === "review" && transport !== undefined
|
|
142
|
+
? runtimeForTransport(transport)
|
|
143
|
+
: transport === undefined ? {} : { transport };
|
|
144
|
+
return await runWorldengineCli(argv, canonicalRoot, {
|
|
145
|
+
stdout: (text) => process.stdout.write(text),
|
|
146
|
+
stderr: (text) => process.stderr.write(text),
|
|
147
|
+
...(questions === undefined ? {} : {
|
|
148
|
+
confirmUploadTarget: async (target) => (await questions.question(`确认目标 ${String(target.client_target_key ?? "unknown")} force_overwrite? [y/N] `)).trim().toLowerCase() === "y",
|
|
149
|
+
}),
|
|
150
|
+
}, previewRuntime, { ...(transport === undefined ? {} : { transport }), dependencies: { installViewDependencies } }, transport === undefined ? {} : { transport }, authoringRuntime, reviewRuntime, {
|
|
151
|
+
openBrowser: openSystemBrowser,
|
|
152
|
+
startModelProxy: async (server, project) => {
|
|
153
|
+
if (server.auth === undefined)
|
|
154
|
+
throw new AuthoringBridgeError("E_AUTH_REQUIRED", "模型代理需要项目登录模块");
|
|
155
|
+
return startLocalAccountModelProxy({ projectRoot: project.root, projectId: project.project_id, auth: server.auth });
|
|
156
|
+
},
|
|
157
|
+
onServerStarted: (server) => {
|
|
158
|
+
const closeOnSignal = (exitCode) => {
|
|
159
|
+
void browserRuntime.close().finally(() => server.close()).finally(() => { process.exitCode = exitCode; });
|
|
160
|
+
};
|
|
161
|
+
process.once("SIGINT", () => closeOnSignal(130));
|
|
162
|
+
process.once("SIGTERM", () => closeOnSignal(143));
|
|
163
|
+
},
|
|
164
|
+
runtimesForTransport: (activeTransport) => ({
|
|
165
|
+
download: { transport: activeTransport, dependencies: { installViewDependencies } },
|
|
166
|
+
upload: { transport: activeTransport },
|
|
167
|
+
review: runtimeForTransport(activeTransport),
|
|
168
|
+
}),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
questions?.close();
|
|
173
|
+
if (argv[0] !== "gui")
|
|
174
|
+
await browserRuntime.close();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
main().then((code) => {
|
|
178
|
+
process.exitCode = code;
|
|
179
|
+
}).catch((error) => {
|
|
180
|
+
writeCliPublicError((text) => process.stderr.write(text), error);
|
|
181
|
+
process.exitCode = 1;
|
|
182
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type AuthoringBridgeAdapter, type AuthoringToolReceiptV1 } from "@world-engines/authoring-bridge";
|
|
2
|
+
import { type FrozenArtifactEmbeddingRequestEntity, type PreparedNeutralArtifactEmbeddingSnapshot } from "@world-engines/scenario-review-snapshot";
|
|
3
|
+
import { type LadybugEmbeddingPort, type LadybugGraphSnapshot, type LadybugGraphSnapshotRequest } from "./ladybug-runtime.js";
|
|
4
|
+
import type { AuthoringEmbeddingPort } from "./authoring-model-connection.js";
|
|
5
|
+
import type { ScenarioSourceReadback, ScenarioWriteRequest } from "./scenario-writer.js";
|
|
6
|
+
/** ProjectHost 向 runtime 提供的唯一 source capability;不暴露任意文件或 statement。 */
|
|
7
|
+
export interface DesktopAuthoringSourcePort {
|
|
8
|
+
readSourceReadback(): Promise<ScenarioSourceReadback>;
|
|
9
|
+
writeScenario(request: ScenarioWriteRequest): Promise<AuthoringToolReceiptV1>;
|
|
10
|
+
}
|
|
11
|
+
export interface DesktopAuthoringCapabilities {
|
|
12
|
+
readonly ask_user?: (input: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
|
|
13
|
+
readonly preview_inspect?: (input: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
|
|
14
|
+
readonly preview_interact?: (input: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
|
|
15
|
+
/** Desktop model provider 的真实 embedding seam;缺失时 semantic/hybrid recall fail-closed。 */
|
|
16
|
+
readonly ladybug_embedding_port?: LadybugEmbeddingPort;
|
|
17
|
+
/** 登录态 embedding 延迟解析;keyword/tools/list/world_apply 不得触发账户登录。 */
|
|
18
|
+
readonly resolve_ladybug_embedding_port?: () => Promise<AuthoringEmbeddingPort>;
|
|
19
|
+
/** 只能回读已显式准备的冻结向量;不得在此触发 capture/compile/embed。 */
|
|
20
|
+
readonly get_prepared_embedding_snapshot?: (request: Readonly<{
|
|
21
|
+
project_id: string;
|
|
22
|
+
project_revision: number;
|
|
23
|
+
source_sha256: string;
|
|
24
|
+
scope_id?: string;
|
|
25
|
+
entities: readonly Readonly<{
|
|
26
|
+
entity_id: string;
|
|
27
|
+
source_kind: "entity" | "chunk" | "statement" | "edge_assertion";
|
|
28
|
+
source_text: string;
|
|
29
|
+
source_text_sha256: string;
|
|
30
|
+
}>[];
|
|
31
|
+
}>) => Promise<PreparedAuthoringRecallSnapshot | null>;
|
|
32
|
+
}
|
|
33
|
+
export interface PreparedAuthoringRecallSnapshot {
|
|
34
|
+
readonly project_id: string;
|
|
35
|
+
readonly project_revision: number;
|
|
36
|
+
readonly source_sha256: string;
|
|
37
|
+
readonly scope_id: string;
|
|
38
|
+
readonly snapshot: PreparedNeutralArtifactEmbeddingSnapshot;
|
|
39
|
+
}
|
|
40
|
+
export type AuthoringRecallGraph = Readonly<{
|
|
41
|
+
entities: readonly Readonly<Record<string, unknown>>[];
|
|
42
|
+
relations: readonly Readonly<Record<string, unknown>>[];
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* 本地 prepare 与正式 review reader 共用的 corpus 文本 seam。
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildAuthoringRecallCorpus(graph: AuthoringRecallGraph): readonly Readonly<{
|
|
48
|
+
entity_id: string;
|
|
49
|
+
source_kind: FrozenArtifactEmbeddingRequestEntity["source_kind"];
|
|
50
|
+
source_text: string;
|
|
51
|
+
}>[];
|
|
52
|
+
export type GraphProjectionReadback = Readonly<{
|
|
53
|
+
schema_version: 1;
|
|
54
|
+
project_revision: number;
|
|
55
|
+
source_sha256: string;
|
|
56
|
+
graph: LadybugGraphSnapshot;
|
|
57
|
+
authoring: Readonly<{
|
|
58
|
+
metadata: JsonRecord;
|
|
59
|
+
runtime_definitions: JsonRecord;
|
|
60
|
+
entities: readonly Entity[];
|
|
61
|
+
relations: readonly Relation[];
|
|
62
|
+
}>;
|
|
63
|
+
}>;
|
|
64
|
+
type JsonRecord = Record<string, unknown>;
|
|
65
|
+
type Entity = JsonRecord & {
|
|
66
|
+
id: string;
|
|
67
|
+
kind: string;
|
|
68
|
+
props: JsonRecord;
|
|
69
|
+
};
|
|
70
|
+
type Relation = JsonRecord & {
|
|
71
|
+
src: string;
|
|
72
|
+
dst: string;
|
|
73
|
+
kind: string;
|
|
74
|
+
props: JsonRecord;
|
|
75
|
+
};
|
|
76
|
+
export declare class DesktopAuthoringRuntime {
|
|
77
|
+
#private;
|
|
78
|
+
private readonly root;
|
|
79
|
+
private readonly port;
|
|
80
|
+
private readonly capabilities;
|
|
81
|
+
readonly adapter: AuthoringBridgeAdapter;
|
|
82
|
+
private constructor();
|
|
83
|
+
static open(root: string, port: DesktopAuthoringSourcePort, capabilities?: DesktopAuthoringCapabilities): Promise<DesktopAuthoringRuntime>;
|
|
84
|
+
close(): Promise<void>;
|
|
85
|
+
/** 固定完整 Node/Edge 读回;派生 graph-only cache 不调用模型,不能成为第二 source authority。 */
|
|
86
|
+
readGraphProjectionReadback(request?: LadybugGraphSnapshotRequest): Promise<GraphProjectionReadback>;
|
|
87
|
+
}
|
|
88
|
+
export {};
|