@gobing-ai/knowledge-kit 0.1.29 → 0.1.30
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/.claude-plugin/marketplace.json +1 -1
- package/dist/board/api.js +8724 -3861
- package/dist/board/collect/index.js +69 -1
- package/dist/board/daily-voice/index.js +474 -265
- package/dist/board/itc/index.js +69 -1
- package/dist/board/wiki/index.css +1305 -0
- package/dist/board/wiki/index.js +1621 -0
- package/dist/index.js +34689 -28532
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +14 -1
- package/plugins/generations/core-facts-gen/dist/index.js +14 -1
- package/plugins/generations/daily-article-gen/dist/index.js +14 -1
- package/plugins/generations/dailynews-gen/dist/index.js +14 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +32 -2
- package/plugins/generations/episode-plan-gen/src/index.ts +19 -1
- package/plugins/generations/gemini-tts/dist/index.js +14 -1
- package/plugins/generations/image-gen/dist/index.js +14 -1
- package/plugins/generations/music-gen/dist/index.js +15 -2
- package/plugins/generations/news-report-gen/dist/index.js +14 -1
- package/plugins/generations/vibe-voice-tts/dist/index.js +14 -1
- package/plugins/generations/video-gen/README.md +245 -8
- package/plugins/generations/video-gen/dist/index.js +22447 -4763
- package/plugins/generations/video-gen/package.json +1 -0
- package/plugins/generations/video-gen/presets/formats/avatar.yaml +5 -0
- package/plugins/generations/video-gen/presets/formats/editorial.yaml +6 -0
- package/plugins/generations/video-gen/presets/formats/hybrid-pip.yaml +5 -0
- package/plugins/generations/video-gen/presets/styles/daily-ai.yaml +5 -0
- package/plugins/generations/video-gen/presets/styles/neutral.yaml +3 -0
- package/plugins/generations/video-gen/python/colab_comfyui_h3.py +322 -0
- package/plugins/generations/video-gen/python/comfyui-h3-i2v-api.json +47 -0
- package/plugins/generations/video-gen/python/comfyui-h3-models.json +32 -0
- package/plugins/generations/video-gen/python/comfyui_model_cache.py +388 -0
- package/plugins/generations/video-gen/python/drive_client.py +187 -0
- package/plugins/generations/video-gen/src/brief-cli.ts +65 -0
- package/plugins/generations/video-gen/src/brief.ts +464 -0
- package/plugins/generations/video-gen/src/ccu-ledger.ts +206 -3
- package/plugins/generations/video-gen/src/colab-runner.ts +346 -35
- package/plugins/generations/video-gen/src/index.ts +141 -109
- package/plugins/generations/video-gen/src/inputs.ts +162 -4
- package/plugins/generations/video-gen/src/layout.ts +33 -0
- package/plugins/generations/video-gen/src/props.ts +27 -3
- package/plugins/generations/video-gen/src/remotion/AvatarReel.tsx +17 -1
- package/plugins/generations/video-gen/src/remotion/EditorialReel.tsx +17 -1
- package/plugins/generations/video-gen/src/remotion/Root.tsx +2 -0
- package/plugins/generations/video-gen/src/remotion/engine.ts +3 -7
- package/plugins/generations/video-gen/src/render.ts +25 -0
- package/plugins/generations/video-gen/src/request.ts +150 -20
- package/plugins/generations/video-gen/src/visual-provider.ts +116 -3
- package/plugins/generations/voice-gen/dist/index.js +14 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +14 -1
- package/plugins/ingestions/aihot-ingest/dist/index.js +14 -1
- package/plugins/ingestions/horizon-ingest/dist/index.js +14 -1
- package/plugins/ingestions/last30days-ingest/dist/index.js +14 -1
- package/plugins/ingestions/web-search/dist/index.js +14 -1
- package/plugins/kk/config.example.yaml +1 -1
- package/plugins/kk/mcp-tools.yaml +47 -0
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/itc-surfdash-locales.json +42 -0
- package/plugins/kk/scripts/daily-stages.ts +87 -6
- package/plugins/kk/scripts/kk-workflow-stages.ts +64 -9
- package/plugins/kk/scripts/video-stages.ts +332 -0
- package/plugins/kk/scripts/wiki-normalize-audio.ts +354 -0
- package/plugins/kk/scripts/wiki-normalize-document.ts +495 -0
- package/plugins/kk/scripts/wiki-normalize-stages.ts +96 -0
- package/plugins/kk/scripts/wiki-stage-runtime.ts +39 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +2 -1
- package/plugins/kk/workflows/kk-collect.yaml +10 -0
- package/plugins/kk/workflows/kk-news-generate.yaml +70 -8
- package/plugins/kk/workflows/kk-smart-seo.yaml +8 -0
- package/plugins/kk/workflows/kk-storm-research.yaml +10 -0
- package/plugins/kk/workflows/kk-video-generate.yaml +169 -0
- package/plugins/kk/workflows/kk-wiki-digest.yaml +49 -0
- package/plugins/publishings/bilibili-pub/dist/index.js +281 -268
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +202 -0
- package/plugins/publishings/cnblogs-pub/dist/index.js +281 -268
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +202 -0
- package/plugins/publishings/csdn-pub/dist/index.js +281 -268
- package/plugins/publishings/csdn-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/emdash-pub/dist/index.js +33 -3
- package/plugins/publishings/infoq-pub/dist/index.js +281 -268
- package/plugins/publishings/infoq-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/jike-pub/dist/index.js +281 -268
- package/plugins/publishings/jike-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/juejin-pub/dist/index.js +281 -268
- package/plugins/publishings/juejin-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +281 -268
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/medium-pub/dist/index.js +281 -268
- package/plugins/publishings/medium-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/podcast-pub/dist/index.js +39 -9
- package/plugins/publishings/qiita-pub/dist/index.js +33 -3
- package/plugins/publishings/shipinhao-pub/dist/index.js +281 -268
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +175 -0
- package/plugins/publishings/sspai-pub/dist/index.js +281 -268
- package/plugins/publishings/sspai-pub/dist/profile-check.js +202 -0
- package/plugins/publishings/substack-pub/dist/index.js +281 -268
- package/plugins/publishings/substack-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +99 -39
- package/plugins/publishings/surfdash-pub/plugin.json +54 -0
- package/plugins/publishings/surfdash-pub/src/index.ts +36 -5
- package/plugins/publishings/threads-pub/dist/index.js +281 -268
- package/plugins/publishings/threads-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/wechatmp-pub/dist/index.js +665 -451
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +215 -3
- package/plugins/publishings/weibo-pub/dist/index.js +281 -268
- package/plugins/publishings/weibo-pub/dist/profile-check.js +189 -1
- package/plugins/publishings/x-pub/dist/index.js +281 -268
- package/plugins/publishings/x-pub/dist/profile-check.js +216 -1
- package/plugins/publishings/xhs-pub/dist/index.js +281 -268
- package/plugins/publishings/xhs-pub/dist/profile-check.js +119 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +281 -268
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +202 -0
- package/plugins/publishings/youtube-pub/dist/index.js +14 -1
- package/plugins/publishings/zenn-pub/dist/index.js +37 -7
|
@@ -0,0 +1,1621 @@
|
|
|
1
|
+
// ../board/src/wiki/index.tsx
|
|
2
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
3
|
+
|
|
4
|
+
// ../board/src/shared/api.ts
|
|
5
|
+
var MAX_OVERVIEW_RUNS = 25;
|
|
6
|
+
function storeItemsQueryString(query) {
|
|
7
|
+
const params = new URLSearchParams;
|
|
8
|
+
if (query.page !== undefined)
|
|
9
|
+
params.set("page", String(query.page));
|
|
10
|
+
if (query.source !== undefined)
|
|
11
|
+
params.set("source", query.source);
|
|
12
|
+
if (query.seen !== undefined)
|
|
13
|
+
params.set("seen", query.seen);
|
|
14
|
+
if (query.decision !== undefined && query.value !== undefined) {
|
|
15
|
+
params.set("decision", query.decision);
|
|
16
|
+
params.set("value", query.value);
|
|
17
|
+
}
|
|
18
|
+
if (query.selection !== undefined)
|
|
19
|
+
params.set("selection", query.selection);
|
|
20
|
+
if (query.search !== undefined && query.search.trim() !== "") {
|
|
21
|
+
params.set("search", query.search.trim());
|
|
22
|
+
}
|
|
23
|
+
return params.toString();
|
|
24
|
+
}
|
|
25
|
+
function storeSelectionsQueryString(query) {
|
|
26
|
+
const params = new URLSearchParams;
|
|
27
|
+
if (query.page !== undefined)
|
|
28
|
+
params.set("page", String(query.page));
|
|
29
|
+
if (query.topic !== undefined && query.topic !== "")
|
|
30
|
+
params.set("topic", query.topic);
|
|
31
|
+
if (query.status !== undefined)
|
|
32
|
+
params.set("status", query.status);
|
|
33
|
+
if (query.runId !== undefined && query.runId !== "")
|
|
34
|
+
params.set("runId", query.runId);
|
|
35
|
+
if (query.search !== undefined && query.search.trim() !== "") {
|
|
36
|
+
params.set("search", query.search.trim());
|
|
37
|
+
}
|
|
38
|
+
return params.toString();
|
|
39
|
+
}
|
|
40
|
+
function storeChannelsQueryString(query) {
|
|
41
|
+
const params = new URLSearchParams({
|
|
42
|
+
from: String(query.fromMs),
|
|
43
|
+
until: String(query.untilMs),
|
|
44
|
+
page: String(query.page)
|
|
45
|
+
});
|
|
46
|
+
return params.toString();
|
|
47
|
+
}
|
|
48
|
+
function isHttpOrigin(origin) {
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
url = new URL(origin);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
56
|
+
return false;
|
|
57
|
+
if (url.username !== "" || url.password !== "")
|
|
58
|
+
return false;
|
|
59
|
+
return url.pathname === "/" && url.search === "" && url.hash === "";
|
|
60
|
+
}
|
|
61
|
+
function parseExternalJobs(raw) {
|
|
62
|
+
if (typeof raw !== "object" || raw === null)
|
|
63
|
+
return null;
|
|
64
|
+
const items = raw.items;
|
|
65
|
+
if (!Array.isArray(items))
|
|
66
|
+
return null;
|
|
67
|
+
const states = new Set(["admitting", "pending", "running", "succeeded", "failed"]);
|
|
68
|
+
const rows = [];
|
|
69
|
+
for (const entry of items) {
|
|
70
|
+
if (typeof entry !== "object" || entry === null)
|
|
71
|
+
return null;
|
|
72
|
+
const row = entry;
|
|
73
|
+
if (typeof row.key !== "string" || typeof row.runId !== "string" || typeof row.workflow !== "string") {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (typeof row.state !== "string" || !states.has(row.state))
|
|
77
|
+
return null;
|
|
78
|
+
rows.push({
|
|
79
|
+
key: row.key,
|
|
80
|
+
node: typeof row.node === "string" ? row.node : "",
|
|
81
|
+
provider: typeof row.provider === "string" ? row.provider : null,
|
|
82
|
+
jobId: typeof row.jobId === "string" ? row.jobId : null,
|
|
83
|
+
state: row.state,
|
|
84
|
+
progress: typeof row.progress === "number" ? row.progress : null,
|
|
85
|
+
message: typeof row.message === "string" ? row.message : null,
|
|
86
|
+
submittedAt: typeof row.submittedAt === "string" ? row.submittedAt : "",
|
|
87
|
+
elapsedMs: typeof row.elapsedMs === "number" ? row.elapsedMs : 0,
|
|
88
|
+
...typeof row.admission === "object" && row.admission !== null ? { admission: row.admission } : {},
|
|
89
|
+
runId: row.runId,
|
|
90
|
+
workflow: row.workflow,
|
|
91
|
+
runStatus: typeof row.runStatus === "string" ? row.runStatus : ""
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return { items: rows };
|
|
95
|
+
}
|
|
96
|
+
function boardBasePath(pathname) {
|
|
97
|
+
const board = pathname.indexOf("/board/");
|
|
98
|
+
return board === -1 ? "" : pathname.slice(0, board);
|
|
99
|
+
}
|
|
100
|
+
function createBoardClient(options) {
|
|
101
|
+
if (!isHttpOrigin(options.boardOrigin)) {
|
|
102
|
+
throw new Error(`board origin must be an http origin, got '${options.boardOrigin}'`);
|
|
103
|
+
}
|
|
104
|
+
const board = new URL(options.boardOrigin).origin + boardBasePath(options.pathname ?? "");
|
|
105
|
+
const moduleApi = `${board}/api/modules/${encodeURIComponent(options.moduleId)}`;
|
|
106
|
+
const doFetch = options.fetchImpl ?? fetch;
|
|
107
|
+
async function getJson(url) {
|
|
108
|
+
const response = await doFetch(url, { headers: { accept: "application/json" } });
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`request failed (${response.status}): ${url}`);
|
|
111
|
+
}
|
|
112
|
+
return await response.json();
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
health: () => getJson(`${moduleApi}/api/health`),
|
|
116
|
+
results: (workflow, runId) => getJson(`${moduleApi}/api/workflows/${encodeURIComponent(workflow)}/runs/${encodeURIComponent(runId)}/results`),
|
|
117
|
+
config: (workflow, runId) => getJson(`${moduleApi}/api/workflows/${encodeURIComponent(workflow)}/runs/${encodeURIComponent(runId)}/config`),
|
|
118
|
+
artifactUrl: (workflow, runId, artifactId) => `${moduleApi}/api/workflows/${encodeURIComponent(workflow)}/runs/${encodeURIComponent(runId)}/artifacts/${encodeURIComponent(artifactId)}`,
|
|
119
|
+
runs: (workflow, cursor) => {
|
|
120
|
+
const params = new URLSearchParams({ workflow, limit: "25" });
|
|
121
|
+
if (cursor !== undefined)
|
|
122
|
+
params.set("cursor", cursor);
|
|
123
|
+
return getJson(`${board}/api/runs?${params.toString()}`);
|
|
124
|
+
},
|
|
125
|
+
storeOverview: (runIds) => {
|
|
126
|
+
const params = new URLSearchParams({ runs: runIds.slice(0, MAX_OVERVIEW_RUNS).join(",") });
|
|
127
|
+
return getJson(`${moduleApi}/api/workflows/kk-collect/store/overview?${params.toString()}`);
|
|
128
|
+
},
|
|
129
|
+
storeRun: (runId) => getJson(`${moduleApi}/api/workflows/kk-collect/runs/${encodeURIComponent(runId)}/store`),
|
|
130
|
+
storeItems: (runId, query = {}) => {
|
|
131
|
+
const qs = storeItemsQueryString(query);
|
|
132
|
+
const path = runId !== undefined && runId.trim() !== "" ? `${moduleApi}/api/workflows/kk-collect/runs/${encodeURIComponent(runId)}/store/items?${qs}` : `${moduleApi}/api/workflows/kk-collect/store/items?${qs}`;
|
|
133
|
+
return getJson(path);
|
|
134
|
+
},
|
|
135
|
+
storeSelections: (query = {}) => getJson(`${moduleApi}/api/workflows/kk-collect/store/selections?${storeSelectionsQueryString(query)}`),
|
|
136
|
+
storeChannels: (query) => getJson(`${moduleApi}/api/workflows/kk-collect/store/channels?${storeChannelsQueryString(query)}`),
|
|
137
|
+
runDetail: (runId) => getJson(`${board}/api/runs/${encodeURIComponent(runId)}`),
|
|
138
|
+
evidence: (workflow, runId) => getJson(`${moduleApi}/api/workflows/${encodeURIComponent(workflow)}/runs/${encodeURIComponent(runId)}/evidence`),
|
|
139
|
+
day: (day) => getJson(`${moduleApi}/api/days/${encodeURIComponent(day)}`),
|
|
140
|
+
dayArtifact: (day, artifact) => getJson(`${moduleApi}/api/days/${encodeURIComponent(day)}/artifacts/${encodeURIComponent(artifact)}`),
|
|
141
|
+
days: (from, until) => getJson(`${moduleApi}/api/days?from=${encodeURIComponent(from)}&until=${encodeURIComponent(until)}`),
|
|
142
|
+
action: async (kind, body) => {
|
|
143
|
+
const response = await doFetch(`${moduleApi}/api/actions/${encodeURIComponent(kind)}`, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
headers: { "content-type": "application/json", "x-kk-action": "1" },
|
|
146
|
+
body: JSON.stringify(body)
|
|
147
|
+
});
|
|
148
|
+
return { status: response.status, body: await response.json() };
|
|
149
|
+
},
|
|
150
|
+
progress: (runId) => getJson(`${board}/api/runs/${encodeURIComponent(runId)}/progress`),
|
|
151
|
+
externalJobs: async (status = "active") => {
|
|
152
|
+
const params = new URLSearchParams({ status });
|
|
153
|
+
return parseExternalJobs(await getJson(`${board}/api/runs/external-jobs?${params.toString()}`));
|
|
154
|
+
},
|
|
155
|
+
wikiComputationRuns: (vaultId, pagePath, cursor) => {
|
|
156
|
+
const params = new URLSearchParams({ path: pagePath });
|
|
157
|
+
if (cursor !== undefined)
|
|
158
|
+
params.set("cursor", String(cursor));
|
|
159
|
+
return getJson(`${moduleApi}/api/wiki/vaults/${encodeURIComponent(vaultId)}/computations/runs?${params.toString()}`);
|
|
160
|
+
},
|
|
161
|
+
wikiComputationRunDetail: (vaultId, runId) => getJson(`${moduleApi}/api/wiki/vaults/${encodeURIComponent(vaultId)}/computation-runs/${encodeURIComponent(runId)}`),
|
|
162
|
+
wikiComputationPreview: async (vaultId, body) => {
|
|
163
|
+
const response = await doFetch(`${moduleApi}/api/wiki/vaults/${encodeURIComponent(vaultId)}/computations/actions/preview`, {
|
|
164
|
+
method: "POST",
|
|
165
|
+
headers: { "content-type": "application/json", "x-kk-action": "1" },
|
|
166
|
+
body: JSON.stringify(body)
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
status: response.status,
|
|
170
|
+
body: await response.json()
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
wikiComputationConfirm: async (vaultId, token) => {
|
|
174
|
+
const response = await doFetch(`${moduleApi}/api/wiki/vaults/${encodeURIComponent(vaultId)}/computations/actions/confirm`, {
|
|
175
|
+
method: "POST",
|
|
176
|
+
headers: { "content-type": "application/json", "x-kk-action": "1" },
|
|
177
|
+
body: JSON.stringify({ token })
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
status: response.status,
|
|
181
|
+
body: await response.json()
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ../board/src/shared/refresh.ts
|
|
188
|
+
var ACTIVE_POLL_MS = 5000;
|
|
189
|
+
|
|
190
|
+
// ../board/src/wiki/computation-panel.tsx
|
|
191
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
192
|
+
function formatExactComputedValue(status) {
|
|
193
|
+
if (!status.eligible || status.historicalProof !== "pass" || status.computedValue === undefined) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return `${status.computedValue.value} ${status.computedValue.unit}`;
|
|
197
|
+
}
|
|
198
|
+
function parseComputationParams(raw) {
|
|
199
|
+
const parsed = JSON.parse(raw);
|
|
200
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
201
|
+
throw new Error("Parameters must be a JSON object.");
|
|
202
|
+
}
|
|
203
|
+
return parsed;
|
|
204
|
+
}
|
|
205
|
+
function WikiComputationView({
|
|
206
|
+
computation,
|
|
207
|
+
runs,
|
|
208
|
+
loadingRuns,
|
|
209
|
+
runsError,
|
|
210
|
+
paramsJson,
|
|
211
|
+
preview,
|
|
212
|
+
actionMessage,
|
|
213
|
+
actionError,
|
|
214
|
+
busy,
|
|
215
|
+
onParamsChange,
|
|
216
|
+
onPreviewAdmit,
|
|
217
|
+
onPreviewRevoke,
|
|
218
|
+
onPreviewRun,
|
|
219
|
+
onConfirm,
|
|
220
|
+
onCancel
|
|
221
|
+
}) {
|
|
222
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
223
|
+
"aria-label": "Attested Computation",
|
|
224
|
+
"data-testid": "wiki-computation-panel",
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ jsx("h3", {
|
|
227
|
+
children: "Attested Computation"
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ jsxs("dl", {
|
|
230
|
+
"aria-label": "Computation trust separation",
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsx("dt", {
|
|
233
|
+
children: "Definition Review (advisory)"
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ jsxs("dd", {
|
|
236
|
+
"data-testid": "comp-definition-review",
|
|
237
|
+
children: [
|
|
238
|
+
"status: ",
|
|
239
|
+
/* @__PURE__ */ jsx("strong", {
|
|
240
|
+
children: computation.definitionReview.status
|
|
241
|
+
}),
|
|
242
|
+
" ·",
|
|
243
|
+
" ",
|
|
244
|
+
computation.definitionReview.recordedMetadataPresent ? "recorded metadata only (not execution proof)" : "unverified"
|
|
245
|
+
]
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ jsx("dt", {
|
|
248
|
+
children: "Execution Admission"
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ jsxs("dd", {
|
|
251
|
+
"data-testid": "comp-admission-state",
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ jsx("strong", {
|
|
254
|
+
children: computation.admission.active ? "admitted" : computation.admission.status
|
|
255
|
+
}),
|
|
256
|
+
computation.admission.approvalEpoch !== undefined && /* @__PURE__ */ jsxs(Fragment, {
|
|
257
|
+
children: [
|
|
258
|
+
" · epoch ",
|
|
259
|
+
computation.admission.approvalEpoch
|
|
260
|
+
]
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ jsx("dt", {
|
|
265
|
+
children: "Runtime"
|
|
266
|
+
}),
|
|
267
|
+
/* @__PURE__ */ jsxs("dd", {
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ jsx("code", {
|
|
270
|
+
children: computation.runtime
|
|
271
|
+
}),
|
|
272
|
+
" · definition",
|
|
273
|
+
" ",
|
|
274
|
+
/* @__PURE__ */ jsx("code", {
|
|
275
|
+
children: computation.definitionSha.slice(0, 12)
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}),
|
|
281
|
+
!computation.supported && /* @__PURE__ */ jsxs("p", {
|
|
282
|
+
role: "alert",
|
|
283
|
+
"data-testid": "comp-unsupported",
|
|
284
|
+
children: [
|
|
285
|
+
"Unsupported computation definition (inert): ",
|
|
286
|
+
computation.unsupportedReason ?? "unsupported runtime"
|
|
287
|
+
]
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsxs("section", {
|
|
290
|
+
"aria-label": "Computation actions",
|
|
291
|
+
children: [
|
|
292
|
+
/* @__PURE__ */ jsx("label", {
|
|
293
|
+
htmlFor: "kk-comp-params",
|
|
294
|
+
children: "Parameters (JSON)"
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ jsx("input", {
|
|
297
|
+
id: "kk-comp-params",
|
|
298
|
+
type: "text",
|
|
299
|
+
value: paramsJson,
|
|
300
|
+
onChange: onParamsChange,
|
|
301
|
+
readOnly: onParamsChange === undefined,
|
|
302
|
+
disabled: busy
|
|
303
|
+
}),
|
|
304
|
+
/* @__PURE__ */ jsx("button", {
|
|
305
|
+
type: "button",
|
|
306
|
+
disabled: busy || !computation.supported,
|
|
307
|
+
onClick: onPreviewAdmit,
|
|
308
|
+
children: "Preview Admit"
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ jsx("button", {
|
|
311
|
+
type: "button",
|
|
312
|
+
disabled: busy,
|
|
313
|
+
onClick: onPreviewRevoke,
|
|
314
|
+
children: "Preview Revoke"
|
|
315
|
+
}),
|
|
316
|
+
/* @__PURE__ */ jsx("button", {
|
|
317
|
+
type: "button",
|
|
318
|
+
disabled: busy || !computation.supported || !computation.admission.active,
|
|
319
|
+
onClick: onPreviewRun,
|
|
320
|
+
children: "Preview Run & Check"
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
}),
|
|
324
|
+
preview !== null && /* @__PURE__ */ jsxs("section", {
|
|
325
|
+
"aria-label": "Action confirmation",
|
|
326
|
+
"data-testid": "comp-preview-box",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ jsxs("p", {
|
|
329
|
+
children: [
|
|
330
|
+
"Confirm ",
|
|
331
|
+
/* @__PURE__ */ jsx("strong", {
|
|
332
|
+
children: preview.action
|
|
333
|
+
}),
|
|
334
|
+
" on ",
|
|
335
|
+
/* @__PURE__ */ jsx("code", {
|
|
336
|
+
children: preview.pagePath
|
|
337
|
+
}),
|
|
338
|
+
" (definition",
|
|
339
|
+
" ",
|
|
340
|
+
/* @__PURE__ */ jsx("code", {
|
|
341
|
+
children: preview.definitionSha.slice(0, 12)
|
|
342
|
+
}),
|
|
343
|
+
preview.planSha ? /* @__PURE__ */ jsxs(Fragment, {
|
|
344
|
+
children: [
|
|
345
|
+
", plan ",
|
|
346
|
+
/* @__PURE__ */ jsx("code", {
|
|
347
|
+
children: preview.planSha.slice(0, 12)
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
}) : null,
|
|
351
|
+
")"
|
|
352
|
+
]
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsxs("button", {
|
|
355
|
+
type: "button",
|
|
356
|
+
disabled: busy,
|
|
357
|
+
onClick: onConfirm,
|
|
358
|
+
children: [
|
|
359
|
+
"Confirm ",
|
|
360
|
+
preview.action
|
|
361
|
+
]
|
|
362
|
+
}),
|
|
363
|
+
/* @__PURE__ */ jsx("button", {
|
|
364
|
+
type: "button",
|
|
365
|
+
disabled: busy,
|
|
366
|
+
onClick: onCancel,
|
|
367
|
+
children: "Cancel"
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}),
|
|
371
|
+
actionMessage !== null && /* @__PURE__ */ jsx("p", {
|
|
372
|
+
role: "status",
|
|
373
|
+
children: actionMessage
|
|
374
|
+
}),
|
|
375
|
+
actionError !== null && /* @__PURE__ */ jsx("p", {
|
|
376
|
+
role: "alert",
|
|
377
|
+
children: actionError
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ jsx("h4", {
|
|
380
|
+
children: "Computation Runs"
|
|
381
|
+
}),
|
|
382
|
+
loadingRuns && /* @__PURE__ */ jsx("p", {
|
|
383
|
+
"aria-busy": "true",
|
|
384
|
+
children: "Loading computation runs…"
|
|
385
|
+
}),
|
|
386
|
+
runsError !== null && /* @__PURE__ */ jsx("p", {
|
|
387
|
+
role: "alert",
|
|
388
|
+
children: runsError
|
|
389
|
+
}),
|
|
390
|
+
!loadingRuns && runs.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
391
|
+
"data-testid": "comp-runs-empty",
|
|
392
|
+
children: "No computation runs recorded yet."
|
|
393
|
+
}) : /* @__PURE__ */ jsx("ul", {
|
|
394
|
+
"aria-label": "Computation run history",
|
|
395
|
+
"data-testid": "comp-runs-list",
|
|
396
|
+
children: runs.map((run) => {
|
|
397
|
+
const formatted = formatExactComputedValue(run.status);
|
|
398
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
399
|
+
"data-run-id": run.runId,
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ jsx("code", {
|
|
402
|
+
children: run.runId
|
|
403
|
+
}),
|
|
404
|
+
" · Proof: ",
|
|
405
|
+
/* @__PURE__ */ jsx("strong", {
|
|
406
|
+
children: run.status.historicalProof
|
|
407
|
+
}),
|
|
408
|
+
" · Eligibility: ",
|
|
409
|
+
/* @__PURE__ */ jsx("strong", {
|
|
410
|
+
children: run.status.eligible ? "eligible" : "ineligible"
|
|
411
|
+
}),
|
|
412
|
+
" · Freshness: ",
|
|
413
|
+
/* @__PURE__ */ jsx("strong", {
|
|
414
|
+
children: run.status.freshness
|
|
415
|
+
}),
|
|
416
|
+
formatted !== null ? /* @__PURE__ */ jsxs("p", {
|
|
417
|
+
"data-testid": `comp-value-${run.runId}`,
|
|
418
|
+
children: [
|
|
419
|
+
"Computed value: ",
|
|
420
|
+
/* @__PURE__ */ jsx("strong", {
|
|
421
|
+
children: formatted
|
|
422
|
+
})
|
|
423
|
+
]
|
|
424
|
+
}) : /* @__PURE__ */ jsxs("p", {
|
|
425
|
+
"data-testid": `comp-diag-${run.runId}`,
|
|
426
|
+
children: [
|
|
427
|
+
"Value withheld — diagnostics:",
|
|
428
|
+
" ",
|
|
429
|
+
run.status.reasons.length > 0 ? run.status.reasons.join(", ") : "not attested"
|
|
430
|
+
]
|
|
431
|
+
})
|
|
432
|
+
]
|
|
433
|
+
}, run.runId);
|
|
434
|
+
})
|
|
435
|
+
})
|
|
436
|
+
]
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// ../board/src/wiki/graph.tsx
|
|
441
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
442
|
+
import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
443
|
+
var SVG_SIZE = 360;
|
|
444
|
+
var CENTER = SVG_SIZE / 2;
|
|
445
|
+
var RING_RADIUS = [0, 110, 168];
|
|
446
|
+
function ringPositions(neighborhood) {
|
|
447
|
+
const positions = new Map;
|
|
448
|
+
for (const depth of [0, 1, 2]) {
|
|
449
|
+
const ring = neighborhood.nodes.filter((node) => node.distance === depth);
|
|
450
|
+
ring.forEach((node, index) => {
|
|
451
|
+
if (depth === 0) {
|
|
452
|
+
positions.set(node.path, { x: CENTER, y: CENTER });
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const angle = 2 * Math.PI * index / Math.max(ring.length, 1) - Math.PI / 2;
|
|
456
|
+
const radius = RING_RADIUS[depth] ?? RING_RADIUS[2] ?? 168;
|
|
457
|
+
positions.set(node.path, {
|
|
458
|
+
x: CENTER + radius * Math.cos(angle),
|
|
459
|
+
y: CENTER + radius * Math.sin(angle)
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return positions;
|
|
464
|
+
}
|
|
465
|
+
async function fetchNeighborhood(source, path, depth) {
|
|
466
|
+
const url = `${source.moduleApiRoot}/api/wiki/vaults/${encodeURIComponent(source.vaultId)}/graph?path=${encodeURIComponent(path)}&depth=${depth}`;
|
|
467
|
+
const res = await fetch(url, { headers: { accept: "application/json" } });
|
|
468
|
+
if (!res.ok) {
|
|
469
|
+
const body = await res.json().catch(() => ({}));
|
|
470
|
+
throw new Error(`${body.code ?? `graph request failed (${res.status})`}: ${body.message ?? ""}`.trim());
|
|
471
|
+
}
|
|
472
|
+
return await res.json();
|
|
473
|
+
}
|
|
474
|
+
function WikiGraphPanel({
|
|
475
|
+
source,
|
|
476
|
+
rootPath,
|
|
477
|
+
onOpen,
|
|
478
|
+
onRecenter
|
|
479
|
+
}) {
|
|
480
|
+
const [depth, setDepth] = useState(1);
|
|
481
|
+
const [root, setRoot] = useState(rootPath);
|
|
482
|
+
const [neighborhood, setNeighborhood] = useState(null);
|
|
483
|
+
const [loading, setLoading] = useState(false);
|
|
484
|
+
const [error, setError] = useState(null);
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
setRoot(rootPath);
|
|
487
|
+
}, [rootPath]);
|
|
488
|
+
const load = useCallback(async (path, nextDepth, signal) => {
|
|
489
|
+
setLoading(true);
|
|
490
|
+
setError(null);
|
|
491
|
+
try {
|
|
492
|
+
const next = await fetchNeighborhood(source, path, nextDepth);
|
|
493
|
+
if (!signal.cancelled)
|
|
494
|
+
setNeighborhood(next);
|
|
495
|
+
} catch (cause) {
|
|
496
|
+
if (!signal.cancelled) {
|
|
497
|
+
setNeighborhood(null);
|
|
498
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
499
|
+
}
|
|
500
|
+
} finally {
|
|
501
|
+
if (!signal.cancelled)
|
|
502
|
+
setLoading(false);
|
|
503
|
+
}
|
|
504
|
+
}, [source]);
|
|
505
|
+
useEffect(() => {
|
|
506
|
+
if (root === null) {
|
|
507
|
+
setNeighborhood(null);
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const signal = { cancelled: false };
|
|
511
|
+
load(root, depth, signal);
|
|
512
|
+
return () => {
|
|
513
|
+
signal.cancelled = true;
|
|
514
|
+
};
|
|
515
|
+
}, [depth, load, root]);
|
|
516
|
+
const positions = useMemo(() => neighborhood === null ? new Map : ringPositions(neighborhood), [neighborhood]);
|
|
517
|
+
const adjacency = useMemo(() => {
|
|
518
|
+
if (neighborhood === null)
|
|
519
|
+
return new Map;
|
|
520
|
+
const map = new Map;
|
|
521
|
+
for (const node of neighborhood.nodes)
|
|
522
|
+
map.set(node.path, { incoming: [], outgoing: [] });
|
|
523
|
+
for (const edge of neighborhood.edges) {
|
|
524
|
+
map.get(edge.from)?.outgoing.push(edge.to);
|
|
525
|
+
map.get(edge.to)?.incoming.push(edge.from);
|
|
526
|
+
}
|
|
527
|
+
return map;
|
|
528
|
+
}, [neighborhood]);
|
|
529
|
+
if (root === null)
|
|
530
|
+
return null;
|
|
531
|
+
const depthLabel = (value) => value === 0 ? "this page" : `${value} hop${value === 1 ? "" : "s"}`;
|
|
532
|
+
return /* @__PURE__ */ jsxs2("section", {
|
|
533
|
+
className: "kk-board-wiki-graph",
|
|
534
|
+
"aria-label": "Wiki neighborhood",
|
|
535
|
+
"data-testid": "wiki-graph",
|
|
536
|
+
children: [
|
|
537
|
+
/* @__PURE__ */ jsxs2("header", {
|
|
538
|
+
className: "kk-board-wiki-graph-header",
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ jsx2("h3", {
|
|
541
|
+
children: "Neighborhood"
|
|
542
|
+
}),
|
|
543
|
+
/* @__PURE__ */ jsx2("label", {
|
|
544
|
+
htmlFor: "kk-wiki-graph-depth",
|
|
545
|
+
children: "Depth"
|
|
546
|
+
}),
|
|
547
|
+
/* @__PURE__ */ jsxs2("select", {
|
|
548
|
+
id: "kk-wiki-graph-depth",
|
|
549
|
+
value: depth,
|
|
550
|
+
onChange: (event) => setDepth(Number(event.target.value) === 0 ? 0 : Number(event.target.value) === 2 ? 2 : 1),
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ jsx2("option", {
|
|
553
|
+
value: 0,
|
|
554
|
+
children: depthLabel(0)
|
|
555
|
+
}),
|
|
556
|
+
/* @__PURE__ */ jsx2("option", {
|
|
557
|
+
value: 1,
|
|
558
|
+
children: depthLabel(1)
|
|
559
|
+
}),
|
|
560
|
+
/* @__PURE__ */ jsx2("option", {
|
|
561
|
+
value: 2,
|
|
562
|
+
children: depthLabel(2)
|
|
563
|
+
})
|
|
564
|
+
]
|
|
565
|
+
}),
|
|
566
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
567
|
+
className: "kk-board-state",
|
|
568
|
+
"data-testid": "wiki-graph-root",
|
|
569
|
+
children: [
|
|
570
|
+
"root: ",
|
|
571
|
+
root
|
|
572
|
+
]
|
|
573
|
+
})
|
|
574
|
+
]
|
|
575
|
+
}),
|
|
576
|
+
loading && /* @__PURE__ */ jsx2("p", {
|
|
577
|
+
"aria-busy": "true",
|
|
578
|
+
children: "Loading neighborhood…"
|
|
579
|
+
}),
|
|
580
|
+
error !== null && /* @__PURE__ */ jsx2("div", {
|
|
581
|
+
role: "alert",
|
|
582
|
+
className: "kk-board-error",
|
|
583
|
+
"data-testid": "wiki-graph-error",
|
|
584
|
+
children: error
|
|
585
|
+
}),
|
|
586
|
+
neighborhood !== null && neighborhood.nodes.length === 1 && /* @__PURE__ */ jsx2("p", {
|
|
587
|
+
"data-testid": "wiki-graph-empty",
|
|
588
|
+
children: "This page has no resolved neighbors at this depth."
|
|
589
|
+
}),
|
|
590
|
+
neighborhood !== null && neighborhood.diagnostics.length > 0 && /* @__PURE__ */ jsxs2("p", {
|
|
591
|
+
className: "kk-board-state",
|
|
592
|
+
"data-testid": "wiki-graph-diagnostics",
|
|
593
|
+
children: [
|
|
594
|
+
neighborhood.diagnostics.length,
|
|
595
|
+
" unresolved reference",
|
|
596
|
+
neighborhood.diagnostics.length === 1 ? "" : "s"
|
|
597
|
+
]
|
|
598
|
+
}),
|
|
599
|
+
neighborhood !== null && neighborhood.nodes.length > 1 && /* @__PURE__ */ jsxs2(Fragment2, {
|
|
600
|
+
children: [
|
|
601
|
+
(neighborhood.truncated.nodes || neighborhood.truncated.edges) && /* @__PURE__ */ jsxs2("p", {
|
|
602
|
+
className: "kk-board-state",
|
|
603
|
+
"data-testid": "wiki-graph-truncated",
|
|
604
|
+
children: [
|
|
605
|
+
"Showing a bounded view: ",
|
|
606
|
+
neighborhood.nodes.length,
|
|
607
|
+
" nodes",
|
|
608
|
+
neighborhood.truncated.nodes ? " · nodes truncated" : "",
|
|
609
|
+
neighborhood.truncated.edges ? " · edges truncated" : ""
|
|
610
|
+
]
|
|
611
|
+
}),
|
|
612
|
+
/* @__PURE__ */ jsxs2("svg", {
|
|
613
|
+
"aria-hidden": "true",
|
|
614
|
+
focusable: "false",
|
|
615
|
+
viewBox: `0 0 ${SVG_SIZE} ${SVG_SIZE}`,
|
|
616
|
+
width: SVG_SIZE,
|
|
617
|
+
height: SVG_SIZE,
|
|
618
|
+
className: "kk-board-wiki-graph-map",
|
|
619
|
+
children: [
|
|
620
|
+
[1, 2].filter((ring) => neighborhood.nodes.some((node) => node.distance === ring)).map((ring) => /* @__PURE__ */ jsx2("circle", {
|
|
621
|
+
cx: CENTER,
|
|
622
|
+
cy: CENTER,
|
|
623
|
+
r: RING_RADIUS[ring] ?? 168,
|
|
624
|
+
fill: "none",
|
|
625
|
+
stroke: "#cbd5e1",
|
|
626
|
+
strokeDasharray: "4 4"
|
|
627
|
+
}, `ring-${ring}`)),
|
|
628
|
+
neighborhood.edges.map((edge) => {
|
|
629
|
+
const from = positions.get(edge.from);
|
|
630
|
+
const to = positions.get(edge.to);
|
|
631
|
+
if (from === undefined || to === undefined)
|
|
632
|
+
return null;
|
|
633
|
+
return /* @__PURE__ */ jsx2("line", {
|
|
634
|
+
x1: from.x,
|
|
635
|
+
y1: from.y,
|
|
636
|
+
x2: to.x,
|
|
637
|
+
y2: to.y,
|
|
638
|
+
stroke: "#94a3b8",
|
|
639
|
+
strokeWidth: 1
|
|
640
|
+
}, `edge-${edge.from}->${edge.to}`);
|
|
641
|
+
}),
|
|
642
|
+
neighborhood.nodes.map((node) => {
|
|
643
|
+
const point = positions.get(node.path);
|
|
644
|
+
if (point === undefined)
|
|
645
|
+
return null;
|
|
646
|
+
return node.distance === 0 ? /* @__PURE__ */ jsx2("rect", {
|
|
647
|
+
x: point.x - 7,
|
|
648
|
+
y: point.y - 7,
|
|
649
|
+
width: 14,
|
|
650
|
+
height: 14,
|
|
651
|
+
fill: "#1d4ed8"
|
|
652
|
+
}, node.path) : /* @__PURE__ */ jsx2("circle", {
|
|
653
|
+
cx: point.x,
|
|
654
|
+
cy: point.y,
|
|
655
|
+
r: 5,
|
|
656
|
+
fill: "#475569"
|
|
657
|
+
}, node.path);
|
|
658
|
+
})
|
|
659
|
+
]
|
|
660
|
+
}),
|
|
661
|
+
/* @__PURE__ */ jsx2("section", {
|
|
662
|
+
"aria-label": "Neighborhood adjacency",
|
|
663
|
+
"data-testid": "wiki-graph-adjacency",
|
|
664
|
+
children: neighborhood.nodes.map((node) => {
|
|
665
|
+
const links = adjacency.get(node.path);
|
|
666
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
667
|
+
className: "kk-board-wiki-graph-node",
|
|
668
|
+
"data-path": node.path,
|
|
669
|
+
children: [
|
|
670
|
+
/* @__PURE__ */ jsxs2("p", {
|
|
671
|
+
children: [
|
|
672
|
+
/* @__PURE__ */ jsx2("strong", {
|
|
673
|
+
children: node.title
|
|
674
|
+
}),
|
|
675
|
+
" ",
|
|
676
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
677
|
+
className: "kk-board-state",
|
|
678
|
+
children: [
|
|
679
|
+
node.path,
|
|
680
|
+
" · ",
|
|
681
|
+
depthLabel(node.distance)
|
|
682
|
+
]
|
|
683
|
+
})
|
|
684
|
+
]
|
|
685
|
+
}),
|
|
686
|
+
/* @__PURE__ */ jsx2("button", {
|
|
687
|
+
type: "button",
|
|
688
|
+
onClick: () => onOpen(node.path),
|
|
689
|
+
children: "Open"
|
|
690
|
+
}),
|
|
691
|
+
" ",
|
|
692
|
+
/* @__PURE__ */ jsx2("button", {
|
|
693
|
+
type: "button",
|
|
694
|
+
onClick: () => onRecenter(node.path),
|
|
695
|
+
children: "Recenter"
|
|
696
|
+
}),
|
|
697
|
+
/* @__PURE__ */ jsxs2("ul", {
|
|
698
|
+
"aria-label": `Neighbors of ${node.title}`,
|
|
699
|
+
children: [
|
|
700
|
+
(links?.outgoing ?? []).map((target) => /* @__PURE__ */ jsxs2("li", {
|
|
701
|
+
children: [
|
|
702
|
+
"→ ",
|
|
703
|
+
target
|
|
704
|
+
]
|
|
705
|
+
}, `out-${target}`)),
|
|
706
|
+
(links?.incoming ?? []).map((source) => /* @__PURE__ */ jsxs2("li", {
|
|
707
|
+
children: [
|
|
708
|
+
"← ",
|
|
709
|
+
source
|
|
710
|
+
]
|
|
711
|
+
}, `in-${source}`))
|
|
712
|
+
]
|
|
713
|
+
})
|
|
714
|
+
]
|
|
715
|
+
}, node.path);
|
|
716
|
+
})
|
|
717
|
+
})
|
|
718
|
+
]
|
|
719
|
+
})
|
|
720
|
+
]
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// ../board/src/wiki/upload.ts
|
|
725
|
+
function moduleApiRoot() {
|
|
726
|
+
if (typeof window === "undefined")
|
|
727
|
+
return "/api/modules/kk-wiki";
|
|
728
|
+
const base = boardBasePath(window.location.pathname);
|
|
729
|
+
return `${window.location.origin}${base}/api/modules/kk-wiki`;
|
|
730
|
+
}
|
|
731
|
+
var WIKI_UPLOAD_MAX_BYTES = 25 * 1024 * 1024;
|
|
732
|
+
|
|
733
|
+
class WikiUploadError extends Error {
|
|
734
|
+
code;
|
|
735
|
+
status;
|
|
736
|
+
constructor(code, message, status = 0) {
|
|
737
|
+
super(message);
|
|
738
|
+
this.code = code;
|
|
739
|
+
this.status = status;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function inferUploadKind(filename) {
|
|
743
|
+
const lower = filename.toLowerCase();
|
|
744
|
+
if (lower.endsWith(".txt") || lower.endsWith(".md") || lower.endsWith(".markdown"))
|
|
745
|
+
return "text";
|
|
746
|
+
if (lower.endsWith(".pdf"))
|
|
747
|
+
return "pdf";
|
|
748
|
+
if (lower.endsWith(".png") || lower.endsWith(".jpg") || lower.endsWith(".jpeg"))
|
|
749
|
+
return "image";
|
|
750
|
+
if (lower.endsWith(".wav") || lower.endsWith(".mp3"))
|
|
751
|
+
return "audio";
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
async function sha256HexFile(file) {
|
|
755
|
+
const buf = await file.arrayBuffer();
|
|
756
|
+
const digest = await crypto.subtle.digest("SHA-256", buf);
|
|
757
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
758
|
+
}
|
|
759
|
+
async function uploadWikiFile(vaultId, file, options = {}) {
|
|
760
|
+
if (file.size < 1 || file.size > WIKI_UPLOAD_MAX_BYTES) {
|
|
761
|
+
throw new WikiUploadError("wiki.upload.too_large", `File must be 1..${WIKI_UPLOAD_MAX_BYTES} bytes`);
|
|
762
|
+
}
|
|
763
|
+
const kind = inferUploadKind(file.name);
|
|
764
|
+
if (kind === undefined) {
|
|
765
|
+
throw new WikiUploadError("wiki.upload.unsupported", `Unsupported file extension '${file.name}'`);
|
|
766
|
+
}
|
|
767
|
+
if (options.signal?.aborted) {
|
|
768
|
+
throw new WikiUploadError("wiki.upload.aborted", "Upload cancelled");
|
|
769
|
+
}
|
|
770
|
+
const sha256 = await sha256HexFile(file);
|
|
771
|
+
if (options.signal?.aborted)
|
|
772
|
+
throw new WikiUploadError("wiki.upload.aborted", "Upload cancelled");
|
|
773
|
+
const url = `${moduleApiRoot()}/api/wiki/vaults/${encodeURIComponent(vaultId)}/inbox/files`;
|
|
774
|
+
options.onProgress?.(0, file.size);
|
|
775
|
+
let res;
|
|
776
|
+
try {
|
|
777
|
+
const headers = {
|
|
778
|
+
"Content-Type": "application/octet-stream",
|
|
779
|
+
"X-KK-Action": "1",
|
|
780
|
+
"X-KK-File-Name": encodeURIComponent(file.name),
|
|
781
|
+
"X-KK-File-Kind": kind,
|
|
782
|
+
"X-KK-File-Size": String(file.size),
|
|
783
|
+
"X-KK-File-Sha256": sha256
|
|
784
|
+
};
|
|
785
|
+
res = options.transport ? await options.transport(url, {
|
|
786
|
+
method: "POST",
|
|
787
|
+
signal: options.signal,
|
|
788
|
+
headers,
|
|
789
|
+
body: file
|
|
790
|
+
}) : await new Promise((resolve, reject) => {
|
|
791
|
+
const xhr = new XMLHttpRequest;
|
|
792
|
+
const cancel = () => xhr.abort();
|
|
793
|
+
const finish = (error) => {
|
|
794
|
+
options.signal?.removeEventListener("abort", cancel);
|
|
795
|
+
if (error)
|
|
796
|
+
reject(error);
|
|
797
|
+
else
|
|
798
|
+
resolve(new Response(xhr.responseText || null, { status: xhr.status }));
|
|
799
|
+
};
|
|
800
|
+
xhr.open("POST", url);
|
|
801
|
+
xhr.timeout = 120000;
|
|
802
|
+
for (const [name, value] of Object.entries(headers))
|
|
803
|
+
xhr.setRequestHeader(name, value);
|
|
804
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
805
|
+
if (event.lengthComputable)
|
|
806
|
+
options.onProgress?.(event.loaded, event.total);
|
|
807
|
+
});
|
|
808
|
+
xhr.addEventListener("load", () => finish());
|
|
809
|
+
xhr.addEventListener("error", () => finish(new WikiUploadError("wiki.upload.network", "Upload connection failed")));
|
|
810
|
+
xhr.addEventListener("timeout", () => finish(new WikiUploadError("wiki.upload.deadline", "Upload timed out")));
|
|
811
|
+
xhr.addEventListener("abort", () => finish(new WikiUploadError("wiki.upload.aborted", "Upload cancelled")));
|
|
812
|
+
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
813
|
+
xhr.send(file);
|
|
814
|
+
});
|
|
815
|
+
} catch (err) {
|
|
816
|
+
if (err instanceof WikiUploadError)
|
|
817
|
+
throw err;
|
|
818
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
819
|
+
throw new WikiUploadError("wiki.upload.aborted", "Upload cancelled", 0);
|
|
820
|
+
}
|
|
821
|
+
throw new WikiUploadError("wiki.upload.network", err instanceof Error ? err.message : String(err), 0);
|
|
822
|
+
}
|
|
823
|
+
let body = {};
|
|
824
|
+
try {
|
|
825
|
+
body = await res.json();
|
|
826
|
+
} catch {}
|
|
827
|
+
if (res.ok && body.inputId && body.captureId && body.attemptId) {
|
|
828
|
+
options.onProgress?.(file.size, file.size);
|
|
829
|
+
return {
|
|
830
|
+
inputId: body.inputId,
|
|
831
|
+
captureId: body.captureId,
|
|
832
|
+
attemptId: body.attemptId,
|
|
833
|
+
status: body.status ?? "received",
|
|
834
|
+
duplicateOrigin: body.duplicateOrigin === true
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
throw new WikiUploadError(body.code ?? "wiki.upload.failed", body.message ?? `Upload failed (${res.status})`, res.status);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// ../board/src/wiki/index.tsx
|
|
841
|
+
import { jsx as jsx3, jsxs as jsxs3, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
842
|
+
function WikiComputationContainer(props) {
|
|
843
|
+
const [runs, setRuns] = useState2([]);
|
|
844
|
+
const [loadingRuns, setLoadingRuns] = useState2(false);
|
|
845
|
+
const [runsError, setRunsError] = useState2(null);
|
|
846
|
+
const [paramsJson, setParamsJson] = useState2("{}");
|
|
847
|
+
const [preview, setPreview] = useState2(null);
|
|
848
|
+
const [actionMessage, setActionMessage] = useState2(null);
|
|
849
|
+
const [actionError, setActionError] = useState2(null);
|
|
850
|
+
const [busy, setBusy] = useState2(false);
|
|
851
|
+
const api = useMemo2(() => createBoardClient({
|
|
852
|
+
boardOrigin: typeof window !== "undefined" ? window.location.origin : "http://127.0.0.1",
|
|
853
|
+
moduleId: "kk-wiki",
|
|
854
|
+
pathname: typeof window !== "undefined" ? window.location.pathname : "/"
|
|
855
|
+
}), []);
|
|
856
|
+
const loadRuns = useCallback2(async () => {
|
|
857
|
+
if (!props.vaultId || !props.pagePath)
|
|
858
|
+
return;
|
|
859
|
+
setLoadingRuns(true);
|
|
860
|
+
setRunsError(null);
|
|
861
|
+
try {
|
|
862
|
+
const res = await api.wikiComputationRuns(props.vaultId, props.pagePath);
|
|
863
|
+
setRuns(res.runs);
|
|
864
|
+
} catch (err) {
|
|
865
|
+
setRunsError(err instanceof Error ? err.message : String(err));
|
|
866
|
+
} finally {
|
|
867
|
+
setLoadingRuns(false);
|
|
868
|
+
}
|
|
869
|
+
}, [api, props.vaultId, props.pagePath]);
|
|
870
|
+
useEffect2(() => {
|
|
871
|
+
setPreview(null);
|
|
872
|
+
setActionMessage(null);
|
|
873
|
+
setActionError(null);
|
|
874
|
+
loadRuns();
|
|
875
|
+
}, [loadRuns]);
|
|
876
|
+
const onPreview = async (action) => {
|
|
877
|
+
setBusy(true);
|
|
878
|
+
setActionError(null);
|
|
879
|
+
setActionMessage(null);
|
|
880
|
+
try {
|
|
881
|
+
const params = action === "run-and-check" ? parseComputationParams(paramsJson) : undefined;
|
|
882
|
+
const res = await api.wikiComputationPreview(props.vaultId, {
|
|
883
|
+
action,
|
|
884
|
+
pagePath: props.pagePath,
|
|
885
|
+
...params !== undefined ? { params } : {}
|
|
886
|
+
});
|
|
887
|
+
if (res.status !== 200 || !("token" in res.body)) {
|
|
888
|
+
const errBody = res.body;
|
|
889
|
+
throw new Error(errBody.message ?? `Preview refused (${res.status})`);
|
|
890
|
+
}
|
|
891
|
+
setPreview(res.body);
|
|
892
|
+
setActionMessage(`Preview ready for ${action}.`);
|
|
893
|
+
} catch (err) {
|
|
894
|
+
setPreview(null);
|
|
895
|
+
setActionError(err instanceof Error ? err.message : String(err));
|
|
896
|
+
} finally {
|
|
897
|
+
setBusy(false);
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const onConfirm = async () => {
|
|
901
|
+
if (preview === null)
|
|
902
|
+
return;
|
|
903
|
+
setBusy(true);
|
|
904
|
+
setActionError(null);
|
|
905
|
+
try {
|
|
906
|
+
const res = await api.wikiComputationConfirm(props.vaultId, preview.token);
|
|
907
|
+
if (res.status !== 200) {
|
|
908
|
+
const errBody = res.body;
|
|
909
|
+
throw new Error(errBody.message ?? `Action failed (${res.status})`);
|
|
910
|
+
}
|
|
911
|
+
setPreview(null);
|
|
912
|
+
setActionMessage(`Completed ${preview.action}.`);
|
|
913
|
+
await loadRuns();
|
|
914
|
+
props.onMutated();
|
|
915
|
+
} catch (err) {
|
|
916
|
+
setActionError(err instanceof Error ? err.message : String(err));
|
|
917
|
+
} finally {
|
|
918
|
+
setBusy(false);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
return /* @__PURE__ */ jsx3(WikiComputationView, {
|
|
922
|
+
computation: props.computation,
|
|
923
|
+
runs,
|
|
924
|
+
loadingRuns,
|
|
925
|
+
runsError,
|
|
926
|
+
paramsJson,
|
|
927
|
+
preview,
|
|
928
|
+
actionMessage,
|
|
929
|
+
actionError,
|
|
930
|
+
busy,
|
|
931
|
+
onParamsChange: (e) => setParamsJson(e.target.value),
|
|
932
|
+
onPreviewAdmit: () => void onPreview("admit"),
|
|
933
|
+
onPreviewRevoke: () => void onPreview("revoke"),
|
|
934
|
+
onPreviewRun: () => void onPreview("run-and-check"),
|
|
935
|
+
onConfirm: () => void onConfirm(),
|
|
936
|
+
onCancel: () => setPreview(null)
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
function WikiBoardPage() {
|
|
940
|
+
const [vaults, setVaults] = useState2([]);
|
|
941
|
+
const [vaultId, setVaultId] = useState2("");
|
|
942
|
+
const [query, setQuery] = useState2("");
|
|
943
|
+
const [pages, setPages] = useState2([]);
|
|
944
|
+
const [selectedPath, setSelectedPath] = useState2("");
|
|
945
|
+
const [graphRoot, setGraphRoot] = useState2(null);
|
|
946
|
+
const [detail, setDetail] = useState2(null);
|
|
947
|
+
const [loading, setLoading] = useState2(true);
|
|
948
|
+
const [error, setError] = useState2(null);
|
|
949
|
+
const [inboxType, setInboxType] = useState2("url");
|
|
950
|
+
const [inboxSource, setInboxSource] = useState2("");
|
|
951
|
+
const [inboxReceipt, setInboxReceipt] = useState2(null);
|
|
952
|
+
const [inputs, setInputs] = useState2([]);
|
|
953
|
+
const [proposal, setProposal] = useState2(null);
|
|
954
|
+
const [busy, setBusy] = useState2(false);
|
|
955
|
+
const [actionStatus, setActionStatus] = useState2(null);
|
|
956
|
+
const [capabilities, setCapabilities] = useState2(null);
|
|
957
|
+
const [selectedFile, setSelectedFile] = useState2(null);
|
|
958
|
+
const [uploadProgress, setUploadProgress] = useState2(null);
|
|
959
|
+
const uploadAbortRef = useRef(null);
|
|
960
|
+
const vaultApi = useCallback2((suffix) => `${moduleApiRoot()}/api/wiki/vaults/${encodeURIComponent(vaultId)}${suffix}`, [vaultId]);
|
|
961
|
+
const loadCapabilities = useCallback2(async () => {
|
|
962
|
+
if (!vaultId)
|
|
963
|
+
return;
|
|
964
|
+
try {
|
|
965
|
+
const res = await fetch(vaultApi("/inbox/capabilities"), { headers: { accept: "application/json" } });
|
|
966
|
+
if (res.ok) {
|
|
967
|
+
const data = await res.json();
|
|
968
|
+
setCapabilities(data.kinds ?? null);
|
|
969
|
+
}
|
|
970
|
+
} catch {}
|
|
971
|
+
}, [vaultId, vaultApi]);
|
|
972
|
+
const loadInputs = useCallback2(async () => {
|
|
973
|
+
if (!vaultId)
|
|
974
|
+
return;
|
|
975
|
+
try {
|
|
976
|
+
const res = await fetch(vaultApi("/inputs"), { headers: { accept: "application/json" } });
|
|
977
|
+
if (!res.ok)
|
|
978
|
+
throw new Error(`Failed to load inputs (${res.status})`);
|
|
979
|
+
setInputs((await res.json()).inputs ?? []);
|
|
980
|
+
} catch (err) {
|
|
981
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
982
|
+
}
|
|
983
|
+
}, [vaultId, vaultApi]);
|
|
984
|
+
useEffect2(() => {
|
|
985
|
+
loadInputs();
|
|
986
|
+
loadCapabilities();
|
|
987
|
+
}, [loadInputs, loadCapabilities]);
|
|
988
|
+
useEffect2(() => {
|
|
989
|
+
if (!inputs.some((input) => ["received", "normalizing", "queued", "proposing", "applying"].includes(input.status)))
|
|
990
|
+
return;
|
|
991
|
+
const timer = setTimeout(() => void loadInputs(), ACTIVE_POLL_MS);
|
|
992
|
+
return () => clearTimeout(timer);
|
|
993
|
+
}, [inputs, loadInputs]);
|
|
994
|
+
const submitFileUpload = async () => {
|
|
995
|
+
if (!vaultId || !selectedFile)
|
|
996
|
+
return;
|
|
997
|
+
const controller = new AbortController;
|
|
998
|
+
uploadAbortRef.current = controller;
|
|
999
|
+
setBusy(true);
|
|
1000
|
+
setError(null);
|
|
1001
|
+
setActionStatus(`Uploading ${selectedFile.name}…`);
|
|
1002
|
+
setUploadProgress({ loaded: 0, total: selectedFile.size });
|
|
1003
|
+
try {
|
|
1004
|
+
const receipt = await uploadWikiFile(vaultId, selectedFile, {
|
|
1005
|
+
signal: controller.signal,
|
|
1006
|
+
onProgress: (loaded, total) => setUploadProgress({ loaded, total })
|
|
1007
|
+
});
|
|
1008
|
+
setInboxReceipt({ inputId: receipt.inputId, attemptId: receipt.attemptId, status: receipt.status });
|
|
1009
|
+
setActionStatus(`Uploaded ${selectedFile.name}`);
|
|
1010
|
+
setSelectedFile(null);
|
|
1011
|
+
await loadInputs();
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1014
|
+
setActionStatus(null);
|
|
1015
|
+
} finally {
|
|
1016
|
+
uploadAbortRef.current = null;
|
|
1017
|
+
setUploadProgress(null);
|
|
1018
|
+
setBusy(false);
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
const cancelFileUpload = () => {
|
|
1022
|
+
uploadAbortRef.current?.abort();
|
|
1023
|
+
};
|
|
1024
|
+
const postAction = useCallback2(async (suffix, body) => {
|
|
1025
|
+
setBusy(true);
|
|
1026
|
+
setError(null);
|
|
1027
|
+
try {
|
|
1028
|
+
const res = await fetch(vaultApi(suffix), {
|
|
1029
|
+
method: "POST",
|
|
1030
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
1031
|
+
body: JSON.stringify(body)
|
|
1032
|
+
});
|
|
1033
|
+
const data = await res.json();
|
|
1034
|
+
if (!res.ok)
|
|
1035
|
+
throw new Error(typeof data.message === "string" ? data.message : `Action failed (${res.status})`);
|
|
1036
|
+
return data;
|
|
1037
|
+
} catch (err) {
|
|
1038
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1039
|
+
return null;
|
|
1040
|
+
} finally {
|
|
1041
|
+
setBusy(false);
|
|
1042
|
+
loadInputs();
|
|
1043
|
+
}
|
|
1044
|
+
}, [vaultApi, loadInputs]);
|
|
1045
|
+
const retryInput = useCallback2(async (inputId) => {
|
|
1046
|
+
const data = await postAction(`/inputs/${encodeURIComponent(inputId)}/retry`, {});
|
|
1047
|
+
if (data !== null)
|
|
1048
|
+
setActionStatus(`Retry queued: ${String(data.attemptId)} for ${inputId}`);
|
|
1049
|
+
}, [postAction]);
|
|
1050
|
+
const openProposal = useCallback2(async (proposalId) => {
|
|
1051
|
+
setError(null);
|
|
1052
|
+
try {
|
|
1053
|
+
const res = await fetch(vaultApi(`/proposals/${encodeURIComponent(proposalId)}`), {
|
|
1054
|
+
headers: { accept: "application/json" }
|
|
1055
|
+
});
|
|
1056
|
+
const data = await res.json();
|
|
1057
|
+
if (!res.ok)
|
|
1058
|
+
throw new Error(data.message ?? `Failed to load proposal (${res.status})`);
|
|
1059
|
+
setProposal(data);
|
|
1060
|
+
} catch (err) {
|
|
1061
|
+
setProposal(null);
|
|
1062
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1063
|
+
}
|
|
1064
|
+
}, [vaultApi]);
|
|
1065
|
+
const reviewProposal = useCallback2(async (decision) => {
|
|
1066
|
+
if (proposal === null)
|
|
1067
|
+
return;
|
|
1068
|
+
const data = await postAction(`/proposals/${encodeURIComponent(proposal.proposalId)}/review`, { decision });
|
|
1069
|
+
if (data !== null) {
|
|
1070
|
+
setActionStatus(`Proposal ${proposal.proposalId}: ${String(data.status)}`);
|
|
1071
|
+
setProposal(null);
|
|
1072
|
+
}
|
|
1073
|
+
}, [proposal, postAction]);
|
|
1074
|
+
const submitInbox = useCallback2(async () => {
|
|
1075
|
+
if (!vaultId || inboxSource.trim() === "")
|
|
1076
|
+
return;
|
|
1077
|
+
setBusy(true);
|
|
1078
|
+
setError(null);
|
|
1079
|
+
try {
|
|
1080
|
+
const res = await fetch(`${moduleApiRoot()}/api/wiki/vaults/${encodeURIComponent(vaultId)}/inbox/capture`, {
|
|
1081
|
+
method: "POST",
|
|
1082
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
1083
|
+
body: JSON.stringify({ type: inboxType, source: inboxSource })
|
|
1084
|
+
});
|
|
1085
|
+
const data = await res.json();
|
|
1086
|
+
if (!res.ok)
|
|
1087
|
+
throw new Error(data.message ?? `Capture failed (${res.status})`);
|
|
1088
|
+
if (data.inputId !== undefined && data.attemptId !== undefined && data.status !== undefined) {
|
|
1089
|
+
setInboxReceipt({ inputId: data.inputId, attemptId: data.attemptId, status: data.status });
|
|
1090
|
+
setInboxSource("");
|
|
1091
|
+
}
|
|
1092
|
+
} catch (err) {
|
|
1093
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1094
|
+
} finally {
|
|
1095
|
+
setBusy(false);
|
|
1096
|
+
loadInputs();
|
|
1097
|
+
}
|
|
1098
|
+
}, [vaultId, inboxType, inboxSource, loadInputs]);
|
|
1099
|
+
useEffect2(() => {
|
|
1100
|
+
let active = true;
|
|
1101
|
+
fetch(`${moduleApiRoot()}/api/wiki/vaults`, { headers: { accept: "application/json" } }).then((r) => r.ok ? r.json() : Promise.reject(new Error(`HTTP ${r.status}`))).then((data) => {
|
|
1102
|
+
if (!active)
|
|
1103
|
+
return;
|
|
1104
|
+
const list = data.vaults ?? [];
|
|
1105
|
+
setVaults(list);
|
|
1106
|
+
if (list[0] !== undefined)
|
|
1107
|
+
setVaultId(list[0].id);
|
|
1108
|
+
setLoading(false);
|
|
1109
|
+
}).catch((err) => {
|
|
1110
|
+
if (!active)
|
|
1111
|
+
return;
|
|
1112
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1113
|
+
setLoading(false);
|
|
1114
|
+
});
|
|
1115
|
+
return () => {
|
|
1116
|
+
active = false;
|
|
1117
|
+
};
|
|
1118
|
+
}, []);
|
|
1119
|
+
const loadPages = useCallback2(async (vid, q) => {
|
|
1120
|
+
if (!vid)
|
|
1121
|
+
return;
|
|
1122
|
+
setLoading(true);
|
|
1123
|
+
setError(null);
|
|
1124
|
+
try {
|
|
1125
|
+
const url = `${moduleApiRoot()}/api/wiki/vaults/${encodeURIComponent(vid)}/pages?q=${encodeURIComponent(q)}`;
|
|
1126
|
+
const res = await fetch(url, { headers: { accept: "application/json" } });
|
|
1127
|
+
if (!res.ok)
|
|
1128
|
+
throw new Error(`Failed to load pages (${res.status})`);
|
|
1129
|
+
const data = await res.json();
|
|
1130
|
+
setPages(data.items ?? []);
|
|
1131
|
+
} catch (err) {
|
|
1132
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1133
|
+
} finally {
|
|
1134
|
+
setLoading(false);
|
|
1135
|
+
}
|
|
1136
|
+
}, []);
|
|
1137
|
+
useEffect2(() => {
|
|
1138
|
+
loadPages(vaultId, query);
|
|
1139
|
+
}, [vaultId, query, loadPages]);
|
|
1140
|
+
const openPage = useCallback2(async (path) => {
|
|
1141
|
+
if (!vaultId || !path)
|
|
1142
|
+
return;
|
|
1143
|
+
setSelectedPath(path);
|
|
1144
|
+
setGraphRoot(path);
|
|
1145
|
+
setError(null);
|
|
1146
|
+
try {
|
|
1147
|
+
const url = `${moduleApiRoot()}/api/wiki/vaults/${encodeURIComponent(vaultId)}/page?path=${encodeURIComponent(path)}`;
|
|
1148
|
+
const res = await fetch(url, { headers: { accept: "application/json" } });
|
|
1149
|
+
if (res.status === 404) {
|
|
1150
|
+
setDetail(null);
|
|
1151
|
+
setError(`Page not found: ${path}`);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
if (!res.ok)
|
|
1155
|
+
throw new Error(`Failed to load page (${res.status})`);
|
|
1156
|
+
setDetail(await res.json());
|
|
1157
|
+
} catch (err) {
|
|
1158
|
+
setDetail(null);
|
|
1159
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
1160
|
+
}
|
|
1161
|
+
}, [vaultId]);
|
|
1162
|
+
const onQueryChange = (event) => setQuery(event.target.value);
|
|
1163
|
+
return /* @__PURE__ */ jsxs3("section", {
|
|
1164
|
+
className: "kk-board-wiki",
|
|
1165
|
+
"aria-label": "Wiki Workspace Reader",
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ jsxs3("header", {
|
|
1168
|
+
className: "kk-board-header",
|
|
1169
|
+
children: [
|
|
1170
|
+
/* @__PURE__ */ jsx3("h1", {
|
|
1171
|
+
children: "Wiki Reader"
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ jsx3("label", {
|
|
1174
|
+
htmlFor: "kk-wiki-vault",
|
|
1175
|
+
children: "Vault"
|
|
1176
|
+
}),
|
|
1177
|
+
/* @__PURE__ */ jsx3("select", {
|
|
1178
|
+
id: "kk-wiki-vault",
|
|
1179
|
+
value: vaultId,
|
|
1180
|
+
onChange: (e) => setVaultId(e.target.value),
|
|
1181
|
+
disabled: vaults.length === 0,
|
|
1182
|
+
children: vaults.map((v) => /* @__PURE__ */ jsx3("option", {
|
|
1183
|
+
value: v.id,
|
|
1184
|
+
children: v.name
|
|
1185
|
+
}, v.id))
|
|
1186
|
+
}),
|
|
1187
|
+
/* @__PURE__ */ jsx3("input", {
|
|
1188
|
+
type: "search",
|
|
1189
|
+
"aria-label": "Search wiki pages",
|
|
1190
|
+
placeholder: "Search pages...",
|
|
1191
|
+
value: query,
|
|
1192
|
+
onChange: onQueryChange
|
|
1193
|
+
})
|
|
1194
|
+
]
|
|
1195
|
+
}),
|
|
1196
|
+
error !== null && /* @__PURE__ */ jsx3("div", {
|
|
1197
|
+
role: "alert",
|
|
1198
|
+
className: "kk-board-error",
|
|
1199
|
+
children: error
|
|
1200
|
+
}),
|
|
1201
|
+
/* @__PURE__ */ jsxs3("section", {
|
|
1202
|
+
className: "kk-board-wiki-inbox",
|
|
1203
|
+
"aria-label": "Wiki Digestion Inbox",
|
|
1204
|
+
children: [
|
|
1205
|
+
/* @__PURE__ */ jsx3("h2", {
|
|
1206
|
+
children: "Inbox"
|
|
1207
|
+
}),
|
|
1208
|
+
/* @__PURE__ */ jsxs3("select", {
|
|
1209
|
+
"aria-label": "Inbox input type",
|
|
1210
|
+
value: inboxType,
|
|
1211
|
+
onChange: (e) => setInboxType(e.target.value === "text" ? "text" : "url"),
|
|
1212
|
+
children: [
|
|
1213
|
+
/* @__PURE__ */ jsx3("option", {
|
|
1214
|
+
value: "url",
|
|
1215
|
+
children: "URL"
|
|
1216
|
+
}),
|
|
1217
|
+
/* @__PURE__ */ jsx3("option", {
|
|
1218
|
+
value: "text",
|
|
1219
|
+
children: "Text"
|
|
1220
|
+
})
|
|
1221
|
+
]
|
|
1222
|
+
}),
|
|
1223
|
+
/* @__PURE__ */ jsx3("input", {
|
|
1224
|
+
type: "text",
|
|
1225
|
+
"aria-label": "URL or text to capture",
|
|
1226
|
+
placeholder: inboxType === "url" ? "https://..." : "Paste text...",
|
|
1227
|
+
value: inboxSource,
|
|
1228
|
+
onChange: (e) => setInboxSource(e.target.value)
|
|
1229
|
+
}),
|
|
1230
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1231
|
+
type: "button",
|
|
1232
|
+
onClick: () => void submitInbox(),
|
|
1233
|
+
disabled: busy || !vaultId || inboxSource.trim() === "",
|
|
1234
|
+
children: "Capture"
|
|
1235
|
+
}),
|
|
1236
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
1237
|
+
className: "kk-board-wiki-file-upload",
|
|
1238
|
+
children: [
|
|
1239
|
+
/* @__PURE__ */ jsx3("label", {
|
|
1240
|
+
htmlFor: "kk-wiki-file-input",
|
|
1241
|
+
children: "File"
|
|
1242
|
+
}),
|
|
1243
|
+
/* @__PURE__ */ jsx3("input", {
|
|
1244
|
+
id: "kk-wiki-file-input",
|
|
1245
|
+
type: "file",
|
|
1246
|
+
accept: ".txt,.md,.pdf,.png,.jpg,.jpeg,.wav,.mp3",
|
|
1247
|
+
disabled: busy || !vaultId,
|
|
1248
|
+
onChange: (e) => setSelectedFile(e.target.files?.[0] ?? null)
|
|
1249
|
+
}),
|
|
1250
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1251
|
+
type: "button",
|
|
1252
|
+
disabled: busy || !vaultId || selectedFile === null || (() => {
|
|
1253
|
+
const k = inferUploadKind(selectedFile.name);
|
|
1254
|
+
return k === undefined || capabilities?.[k]?.available !== true;
|
|
1255
|
+
})(),
|
|
1256
|
+
onClick: () => void submitFileUpload(),
|
|
1257
|
+
children: "Upload File"
|
|
1258
|
+
}),
|
|
1259
|
+
uploadProgress !== null && /* @__PURE__ */ jsxs3(Fragment3, {
|
|
1260
|
+
children: [
|
|
1261
|
+
/* @__PURE__ */ jsx3("progress", {
|
|
1262
|
+
"aria-label": "File upload progress",
|
|
1263
|
+
value: uploadProgress.loaded,
|
|
1264
|
+
max: uploadProgress.total || 1
|
|
1265
|
+
}),
|
|
1266
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1267
|
+
type: "button",
|
|
1268
|
+
onClick: cancelFileUpload,
|
|
1269
|
+
children: "Cancel"
|
|
1270
|
+
})
|
|
1271
|
+
]
|
|
1272
|
+
}),
|
|
1273
|
+
capabilities !== null && /* @__PURE__ */ jsxs3("p", {
|
|
1274
|
+
"aria-live": "polite",
|
|
1275
|
+
children: [
|
|
1276
|
+
"Capabilities:",
|
|
1277
|
+
" ",
|
|
1278
|
+
["text", "pdf", "image", "audio"].map((k) => capabilities[k].available ? `${k}: ready` : `${k}: unavailable (${capabilities[k].reason ?? "missing"})`).join(" · ")
|
|
1279
|
+
]
|
|
1280
|
+
}),
|
|
1281
|
+
capabilities === null && /* @__PURE__ */ jsx3("p", {
|
|
1282
|
+
role: "status",
|
|
1283
|
+
children: "Checking file capabilities…"
|
|
1284
|
+
})
|
|
1285
|
+
]
|
|
1286
|
+
}),
|
|
1287
|
+
inboxReceipt !== null && /* @__PURE__ */ jsxs3("p", {
|
|
1288
|
+
role: "status",
|
|
1289
|
+
children: [
|
|
1290
|
+
"Accepted: ",
|
|
1291
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1292
|
+
children: inboxReceipt.inputId
|
|
1293
|
+
}),
|
|
1294
|
+
" (attempt ",
|
|
1295
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1296
|
+
children: inboxReceipt.attemptId
|
|
1297
|
+
}),
|
|
1298
|
+
" ·",
|
|
1299
|
+
" ",
|
|
1300
|
+
inboxReceipt.status,
|
|
1301
|
+
")"
|
|
1302
|
+
]
|
|
1303
|
+
}),
|
|
1304
|
+
actionStatus !== null && /* @__PURE__ */ jsx3("p", {
|
|
1305
|
+
role: "status",
|
|
1306
|
+
children: actionStatus
|
|
1307
|
+
}),
|
|
1308
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
1309
|
+
children: "Inputs"
|
|
1310
|
+
}),
|
|
1311
|
+
inputs.length === 0 ? /* @__PURE__ */ jsx3("p", {
|
|
1312
|
+
children: "No captured inputs yet."
|
|
1313
|
+
}) : /* @__PURE__ */ jsx3("ul", {
|
|
1314
|
+
"aria-label": "Captured inputs",
|
|
1315
|
+
children: inputs.map((input) => {
|
|
1316
|
+
const latest = input.attempts[input.attempts.length - 1];
|
|
1317
|
+
const proposalId = [...input.attempts].reverse().find((a) => a.proposalId)?.proposalId;
|
|
1318
|
+
const lastError = [...input.attempts].reverse().find((a) => a.error !== undefined)?.error;
|
|
1319
|
+
return /* @__PURE__ */ jsxs3("li", {
|
|
1320
|
+
"data-input-id": input.inputId,
|
|
1321
|
+
children: [
|
|
1322
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1323
|
+
children: input.inputId
|
|
1324
|
+
}),
|
|
1325
|
+
" · ",
|
|
1326
|
+
input.originType,
|
|
1327
|
+
" · ",
|
|
1328
|
+
input.originSummary,
|
|
1329
|
+
" ·",
|
|
1330
|
+
" ",
|
|
1331
|
+
/* @__PURE__ */ jsx3("strong", {
|
|
1332
|
+
children: input.status
|
|
1333
|
+
}),
|
|
1334
|
+
latest !== undefined && /* @__PURE__ */ jsxs3(Fragment3, {
|
|
1335
|
+
children: [
|
|
1336
|
+
" ",
|
|
1337
|
+
"(attempt ",
|
|
1338
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1339
|
+
children: latest.attemptId
|
|
1340
|
+
}),
|
|
1341
|
+
")"
|
|
1342
|
+
]
|
|
1343
|
+
}),
|
|
1344
|
+
input.staleReviewFlagged && /* @__PURE__ */ jsx3(Fragment3, {
|
|
1345
|
+
children: " · stale review"
|
|
1346
|
+
}),
|
|
1347
|
+
lastError !== undefined && /* @__PURE__ */ jsxs3("p", {
|
|
1348
|
+
role: "alert",
|
|
1349
|
+
children: [
|
|
1350
|
+
"Error: ",
|
|
1351
|
+
lastError
|
|
1352
|
+
]
|
|
1353
|
+
}),
|
|
1354
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1355
|
+
type: "button",
|
|
1356
|
+
disabled: busy,
|
|
1357
|
+
onClick: () => void retryInput(input.inputId),
|
|
1358
|
+
children: "Retry"
|
|
1359
|
+
}),
|
|
1360
|
+
proposalId !== undefined && /* @__PURE__ */ jsx3("button", {
|
|
1361
|
+
type: "button",
|
|
1362
|
+
disabled: busy,
|
|
1363
|
+
onClick: () => void openProposal(proposalId),
|
|
1364
|
+
children: "Review proposal"
|
|
1365
|
+
}),
|
|
1366
|
+
input.originType === "file" && input.captureIds && input.captureIds.length > 0 && /* @__PURE__ */ jsx3("a", {
|
|
1367
|
+
href: `${vaultApi(`/inputs/${encodeURIComponent(input.inputId)}/captures/${encodeURIComponent(input.captureIds[input.captureIds.length - 1] ?? "")}/original`)}`,
|
|
1368
|
+
download: true,
|
|
1369
|
+
children: "Download original"
|
|
1370
|
+
}),
|
|
1371
|
+
input.affectedPages.map((page) => /* @__PURE__ */ jsxs3("button", {
|
|
1372
|
+
type: "button",
|
|
1373
|
+
onClick: () => void openPage(page.path),
|
|
1374
|
+
children: [
|
|
1375
|
+
"Open ",
|
|
1376
|
+
page.path
|
|
1377
|
+
]
|
|
1378
|
+
}, page.path))
|
|
1379
|
+
]
|
|
1380
|
+
}, input.inputId);
|
|
1381
|
+
})
|
|
1382
|
+
}),
|
|
1383
|
+
proposal !== null && /* @__PURE__ */ jsxs3("section", {
|
|
1384
|
+
"aria-label": "Proposal review",
|
|
1385
|
+
children: [
|
|
1386
|
+
/* @__PURE__ */ jsxs3("h3", {
|
|
1387
|
+
children: [
|
|
1388
|
+
"Proposal ",
|
|
1389
|
+
proposal.proposalId,
|
|
1390
|
+
" ",
|
|
1391
|
+
/* @__PURE__ */ jsx3("span", {
|
|
1392
|
+
children: "unverified"
|
|
1393
|
+
})
|
|
1394
|
+
]
|
|
1395
|
+
}),
|
|
1396
|
+
proposal.errors.map((e) => /* @__PURE__ */ jsx3("p", {
|
|
1397
|
+
role: "alert",
|
|
1398
|
+
children: e
|
|
1399
|
+
}, e)),
|
|
1400
|
+
/* @__PURE__ */ jsxs3("table", {
|
|
1401
|
+
children: [
|
|
1402
|
+
/* @__PURE__ */ jsx3("thead", {
|
|
1403
|
+
children: /* @__PURE__ */ jsxs3("tr", {
|
|
1404
|
+
children: [
|
|
1405
|
+
/* @__PURE__ */ jsx3("th", {
|
|
1406
|
+
scope: "col",
|
|
1407
|
+
children: "Path"
|
|
1408
|
+
}),
|
|
1409
|
+
/* @__PURE__ */ jsx3("th", {
|
|
1410
|
+
scope: "col",
|
|
1411
|
+
children: "Action"
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ jsx3("th", {
|
|
1414
|
+
scope: "col",
|
|
1415
|
+
children: "Preimage → planned"
|
|
1416
|
+
}),
|
|
1417
|
+
/* @__PURE__ */ jsx3("th", {
|
|
1418
|
+
scope: "col",
|
|
1419
|
+
children: "Sources"
|
|
1420
|
+
})
|
|
1421
|
+
]
|
|
1422
|
+
})
|
|
1423
|
+
}),
|
|
1424
|
+
/* @__PURE__ */ jsx3("tbody", {
|
|
1425
|
+
children: proposal.diffs.map((d) => /* @__PURE__ */ jsxs3("tr", {
|
|
1426
|
+
children: [
|
|
1427
|
+
/* @__PURE__ */ jsx3("td", {
|
|
1428
|
+
children: d.path
|
|
1429
|
+
}),
|
|
1430
|
+
/* @__PURE__ */ jsx3("td", {
|
|
1431
|
+
children: d.action
|
|
1432
|
+
}),
|
|
1433
|
+
/* @__PURE__ */ jsxs3("td", {
|
|
1434
|
+
children: [
|
|
1435
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1436
|
+
children: (d.preimageSha256 ?? "none").slice(0, 12)
|
|
1437
|
+
}),
|
|
1438
|
+
" →",
|
|
1439
|
+
" ",
|
|
1440
|
+
/* @__PURE__ */ jsx3("code", {
|
|
1441
|
+
children: d.plannedSha256.slice(0, 12)
|
|
1442
|
+
})
|
|
1443
|
+
]
|
|
1444
|
+
}),
|
|
1445
|
+
/* @__PURE__ */ jsx3("td", {
|
|
1446
|
+
children: d.sourceLocators.join(", ")
|
|
1447
|
+
})
|
|
1448
|
+
]
|
|
1449
|
+
}, d.path))
|
|
1450
|
+
})
|
|
1451
|
+
]
|
|
1452
|
+
}),
|
|
1453
|
+
proposal.changes.map((c) => /* @__PURE__ */ jsxs3("figure", {
|
|
1454
|
+
children: [
|
|
1455
|
+
/* @__PURE__ */ jsxs3("figcaption", {
|
|
1456
|
+
children: [
|
|
1457
|
+
"Planned content for ",
|
|
1458
|
+
c.path
|
|
1459
|
+
]
|
|
1460
|
+
}),
|
|
1461
|
+
/* @__PURE__ */ jsx3("pre", {
|
|
1462
|
+
className: "kk-wiki-body",
|
|
1463
|
+
children: c.content
|
|
1464
|
+
})
|
|
1465
|
+
]
|
|
1466
|
+
}, c.path)),
|
|
1467
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1468
|
+
type: "button",
|
|
1469
|
+
disabled: busy || !proposal.valid,
|
|
1470
|
+
onClick: () => void reviewProposal("accept"),
|
|
1471
|
+
children: "Accept"
|
|
1472
|
+
}),
|
|
1473
|
+
/* @__PURE__ */ jsx3("button", {
|
|
1474
|
+
type: "button",
|
|
1475
|
+
disabled: busy,
|
|
1476
|
+
onClick: () => void reviewProposal("reject"),
|
|
1477
|
+
children: "Reject"
|
|
1478
|
+
})
|
|
1479
|
+
]
|
|
1480
|
+
})
|
|
1481
|
+
]
|
|
1482
|
+
}),
|
|
1483
|
+
loading && /* @__PURE__ */ jsx3("div", {
|
|
1484
|
+
"aria-busy": "true",
|
|
1485
|
+
children: "Loading wiki pages…"
|
|
1486
|
+
}),
|
|
1487
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
1488
|
+
className: "kk-board-wiki-layout",
|
|
1489
|
+
children: [
|
|
1490
|
+
/* @__PURE__ */ jsx3("nav", {
|
|
1491
|
+
"aria-label": "Wiki pages",
|
|
1492
|
+
children: pages.length === 0 && !loading ? /* @__PURE__ */ jsx3("p", {
|
|
1493
|
+
children: "No pages match your query."
|
|
1494
|
+
}) : /* @__PURE__ */ jsx3("ul", {
|
|
1495
|
+
children: pages.map((p) => /* @__PURE__ */ jsx3("li", {
|
|
1496
|
+
children: /* @__PURE__ */ jsx3("button", {
|
|
1497
|
+
type: "button",
|
|
1498
|
+
"aria-current": selectedPath === p.path ? "page" : undefined,
|
|
1499
|
+
onClick: () => void openPage(p.path),
|
|
1500
|
+
children: p.title
|
|
1501
|
+
})
|
|
1502
|
+
}, p.path))
|
|
1503
|
+
})
|
|
1504
|
+
}),
|
|
1505
|
+
/* @__PURE__ */ jsx3("article", {
|
|
1506
|
+
"aria-label": "Wiki page content",
|
|
1507
|
+
children: detail === null ? /* @__PURE__ */ jsx3("p", {
|
|
1508
|
+
children: "Select a page to inspect content, backlinks, and source provenance."
|
|
1509
|
+
}) : /* @__PURE__ */ jsxs3(Fragment3, {
|
|
1510
|
+
children: [
|
|
1511
|
+
/* @__PURE__ */ jsx3("h2", {
|
|
1512
|
+
children: detail.title
|
|
1513
|
+
}),
|
|
1514
|
+
/* @__PURE__ */ jsxs3("p", {
|
|
1515
|
+
children: [
|
|
1516
|
+
"Trust: ",
|
|
1517
|
+
/* @__PURE__ */ jsx3("strong", {
|
|
1518
|
+
children: detail.trust.advisory
|
|
1519
|
+
}),
|
|
1520
|
+
" · Updated: ",
|
|
1521
|
+
detail.trust.updatedAt
|
|
1522
|
+
]
|
|
1523
|
+
}),
|
|
1524
|
+
detail.outline.length > 0 && /* @__PURE__ */ jsxs3("aside", {
|
|
1525
|
+
"aria-label": "Page outline",
|
|
1526
|
+
children: [
|
|
1527
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
1528
|
+
children: "Outline"
|
|
1529
|
+
}),
|
|
1530
|
+
/* @__PURE__ */ jsx3("ul", {
|
|
1531
|
+
children: detail.outline.map((h) => /* @__PURE__ */ jsx3("li", {
|
|
1532
|
+
children: h.text
|
|
1533
|
+
}, `${h.level}-${h.id}`))
|
|
1534
|
+
})
|
|
1535
|
+
]
|
|
1536
|
+
}),
|
|
1537
|
+
/* @__PURE__ */ jsx3("pre", {
|
|
1538
|
+
className: "kk-wiki-body",
|
|
1539
|
+
children: detail.safeHtml.replace(/<[^>]+>/g, "")
|
|
1540
|
+
}),
|
|
1541
|
+
detail.computation !== undefined && /* @__PURE__ */ jsx3(WikiComputationContainer, {
|
|
1542
|
+
vaultId,
|
|
1543
|
+
pagePath: detail.path,
|
|
1544
|
+
computation: detail.computation,
|
|
1545
|
+
onMutated: () => void openPage(detail.path)
|
|
1546
|
+
}),
|
|
1547
|
+
detail.computation === undefined && /* @__PURE__ */ jsx3(WikiGraphPanel, {
|
|
1548
|
+
source: { vaultId, moduleApiRoot: moduleApiRoot() },
|
|
1549
|
+
rootPath: graphRoot,
|
|
1550
|
+
onOpen: (path) => void openPage(path),
|
|
1551
|
+
onRecenter: (path) => setGraphRoot(path)
|
|
1552
|
+
}),
|
|
1553
|
+
/* @__PURE__ */ jsxs3("section", {
|
|
1554
|
+
"aria-label": "Sources",
|
|
1555
|
+
children: [
|
|
1556
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
1557
|
+
children: "Sources"
|
|
1558
|
+
}),
|
|
1559
|
+
/* @__PURE__ */ jsx3("ul", {
|
|
1560
|
+
children: detail.sources.map((s) => /* @__PURE__ */ jsx3("li", {
|
|
1561
|
+
children: s
|
|
1562
|
+
}, s))
|
|
1563
|
+
})
|
|
1564
|
+
]
|
|
1565
|
+
}),
|
|
1566
|
+
/* @__PURE__ */ jsxs3("section", {
|
|
1567
|
+
"aria-label": "Outgoing links",
|
|
1568
|
+
children: [
|
|
1569
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
1570
|
+
children: "Links"
|
|
1571
|
+
}),
|
|
1572
|
+
/* @__PURE__ */ jsx3("ul", {
|
|
1573
|
+
children: detail.outgoingLinks.map((link) => /* @__PURE__ */ jsx3("li", {
|
|
1574
|
+
children: link.resolvedPath === null ? /* @__PURE__ */ jsxs3("span", {
|
|
1575
|
+
children: [
|
|
1576
|
+
link.surface ?? link.target,
|
|
1577
|
+
" (unresolved)"
|
|
1578
|
+
]
|
|
1579
|
+
}) : /* @__PURE__ */ jsx3("button", {
|
|
1580
|
+
type: "button",
|
|
1581
|
+
onClick: () => void openPage(link.resolvedPath ?? ""),
|
|
1582
|
+
children: link.surface ?? link.target
|
|
1583
|
+
})
|
|
1584
|
+
}, `${link.target}-${link.surface ?? ""}`))
|
|
1585
|
+
})
|
|
1586
|
+
]
|
|
1587
|
+
}),
|
|
1588
|
+
/* @__PURE__ */ jsxs3("section", {
|
|
1589
|
+
"aria-label": "Backlinks",
|
|
1590
|
+
children: [
|
|
1591
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
1592
|
+
children: "Backlinks"
|
|
1593
|
+
}),
|
|
1594
|
+
/* @__PURE__ */ jsx3("ul", {
|
|
1595
|
+
children: detail.backlinks.map((b) => /* @__PURE__ */ jsx3("li", {
|
|
1596
|
+
children: /* @__PURE__ */ jsx3("button", {
|
|
1597
|
+
type: "button",
|
|
1598
|
+
onClick: () => void openPage(b),
|
|
1599
|
+
children: b
|
|
1600
|
+
})
|
|
1601
|
+
}, b))
|
|
1602
|
+
})
|
|
1603
|
+
]
|
|
1604
|
+
})
|
|
1605
|
+
]
|
|
1606
|
+
})
|
|
1607
|
+
})
|
|
1608
|
+
]
|
|
1609
|
+
})
|
|
1610
|
+
]
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
var webModule = {
|
|
1614
|
+
apiVersion: 1,
|
|
1615
|
+
component: WikiBoardPage
|
|
1616
|
+
};
|
|
1617
|
+
export {
|
|
1618
|
+
WikiBoardPage,
|
|
1619
|
+
moduleApiRoot,
|
|
1620
|
+
webModule
|
|
1621
|
+
};
|