dsh-industry-knowledge 0.4.1-poc → 0.4.2-poc

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/lib/client.js CHANGED
@@ -1582,13 +1582,72 @@ function safeRemoteNamespace(remote, name) {
1582
1582
  return null;
1583
1583
  }
1584
1584
  }
1585
- function createRemoteNamespaceFacade(getNamespace, methods = ["describe", "validate", "testSearchEngine", "initializeWorkspace", "autoSetup", "save"]) {
1585
+ function createHttpConfigFallback({ fetchImpl = (...args) => globalThis.fetch?.(...args) } = {}) {
1586
+ const fetchJson = async (url, init) => {
1587
+ try {
1588
+ const res = await fetchImpl(url, init);
1589
+ if (!res) {
1590
+ return { ok: false, error: { code: "ikConfig/unavailable", message: "HTTP fetch unavailable" } };
1591
+ }
1592
+ const data = await res.json().catch(() => null);
1593
+ if (!res.ok) {
1594
+ return {
1595
+ ok: false,
1596
+ error: {
1597
+ code: data?.error ?? `HTTP_${res.status}`,
1598
+ message: data?.message ?? `HTTP ${res.status}`
1599
+ }
1600
+ };
1601
+ }
1602
+ return { ok: true, value: data };
1603
+ } catch (error) {
1604
+ return { ok: false, error: { code: "ikConfig/transport", message: errorMessage(error, "HTTP fallback failed") } };
1605
+ }
1606
+ };
1607
+ return {
1608
+ describe: () => fetchJson("/api/ik/config/describe", { headers: { accept: "application/json" } }),
1609
+ validate: (config) => fetchJson("/api/ik/config/validate", {
1610
+ method: "POST",
1611
+ headers: { "content-type": "application/json", accept: "application/json" },
1612
+ body: JSON.stringify({ config })
1613
+ }),
1614
+ testSearchEngine: (request) => fetchJson("/api/ik/config/test-search-engine", {
1615
+ method: "POST",
1616
+ headers: { "content-type": "application/json", accept: "application/json" },
1617
+ body: JSON.stringify(request ?? {})
1618
+ }),
1619
+ save: async () => ({
1620
+ ok: false,
1621
+ error: {
1622
+ code: "ikConfig/read-only",
1623
+ message: "当前 DSH 宿主未挂载 typert 配置写入通道,部署配置为只读,请通过 profile 配置文件修改"
1624
+ }
1625
+ })
1626
+ };
1627
+ }
1628
+ function createRemoteNamespaceFacade(getNamespace, methods = ["describe", "validate", "testSearchEngine", "initializeWorkspace", "autoSetup", "save"], { fallback = null } = {}) {
1586
1629
  const facade = {};
1587
1630
  for (const method of methods) {
1588
- facade[method] = (...args) => {
1631
+ facade[method] = async (...args) => {
1589
1632
  const namespace = getNamespace();
1590
- if (!namespace || typeof namespace[method] !== "function") throw new Error(`Remote namespace method unavailable: ${method}`);
1591
- return namespace[method](...args);
1633
+ if (namespace && typeof namespace[method] === "function") {
1634
+ try {
1635
+ const result = await namespace[method](...args);
1636
+ if (result?.ok === false && fallback && typeof fallback[method] === "function" && isTransientRemoteError(result.error)) {
1637
+ return await fallback[method](...args);
1638
+ }
1639
+ return result;
1640
+ } catch (error) {
1641
+ if (fallback && typeof fallback[method] === "function" && isTransientRemoteError(error)) {
1642
+ return await fallback[method](...args);
1643
+ }
1644
+ throw error;
1645
+ }
1646
+ }
1647
+ if (fallback && typeof fallback[method] === "function") {
1648
+ return await fallback[method](...args);
1649
+ }
1650
+ throw new Error(`Remote namespace method unavailable: ${method}`);
1592
1651
  };
1593
1652
  }
1594
1653
  return facade;
@@ -5809,7 +5868,15 @@ function Glyph({ size = 18 }) {
5809
5868
  var inject = ["slots", "locale"];
5810
5869
  function apply(ctx) {
5811
5870
  const t = createTranslate(ctx);
5871
+ const httpConfigFallback = createHttpConfigFallback();
5812
5872
  const configAccess = createConfigAccessStore();
5873
+ configAccess.set({
5874
+ remote: null,
5875
+ industryConfig: httpConfigFallback,
5876
+ configForms: null,
5877
+ settingsRemote: null,
5878
+ remoteError: null
5879
+ });
5813
5880
  const reviewAccess = createReviewAccessStore();
5814
5881
  const openClaim = (claimId, releaseId) => {
5815
5882
  const right = ctx.get("sidebarRight");
@@ -5947,12 +6014,16 @@ function apply(ctx) {
5947
6014
  const settingsRemote = child.remote.settings;
5948
6015
  let industryNamespace = null;
5949
6016
  let industryConfig = null;
5950
- const namespaceFacade = () => industryConfig ??= createRemoteNamespaceFacade(() => industryNamespace);
6017
+ const namespaceFacade = () => industryConfig ??= createRemoteNamespaceFacade(
6018
+ () => industryNamespace,
6019
+ void 0,
6020
+ { fallback: httpConfigFallback }
6021
+ );
5951
6022
  const publish = (remote, remoteError = null, nextIndustryConfig = industryNamespace) => {
5952
6023
  industryNamespace = nextIndustryConfig;
5953
6024
  configAccess.set({
5954
6025
  remote,
5955
- industryConfig: industryNamespace ? namespaceFacade() : null,
6026
+ industryConfig: namespaceFacade(),
5956
6027
  configForms: child.configForms,
5957
6028
  settingsRemote,
5958
6029
  remoteError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-industry-knowledge",
3
- "version": "0.4.1-poc",
3
+ "version": "0.4.2-poc",
4
4
  "description": "Auditable industry knowledge search, evidence tracing, and research workflows for DeepSeek Harness.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,16 +67,80 @@ export function safeRemoteNamespace(remote, name) {
67
67
  }
68
68
  }
69
69
 
70
+ export function createHttpConfigFallback({ fetchImpl = (...args) => globalThis.fetch?.(...args) } = {}) {
71
+ const fetchJson = async (url, init) => {
72
+ try {
73
+ const res = await fetchImpl(url, init)
74
+ if (!res) {
75
+ return { ok: false, error: { code: 'ikConfig/unavailable', message: 'HTTP fetch unavailable' } }
76
+ }
77
+ const data = await res.json().catch(() => null)
78
+ if (!res.ok) {
79
+ return {
80
+ ok: false,
81
+ error: {
82
+ code: data?.error ?? `HTTP_${res.status}`,
83
+ message: data?.message ?? `HTTP ${res.status}`,
84
+ },
85
+ }
86
+ }
87
+ return { ok: true, value: data }
88
+ } catch (error) {
89
+ return { ok: false, error: { code: 'ikConfig/transport', message: errorMessage(error, 'HTTP fallback failed') } }
90
+ }
91
+ }
92
+ return {
93
+ describe: () => fetchJson('/api/ik/config/describe', { headers: { accept: 'application/json' } }),
94
+ validate: config => fetchJson('/api/ik/config/validate', {
95
+ method: 'POST',
96
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
97
+ body: JSON.stringify({ config }),
98
+ }),
99
+ testSearchEngine: request => fetchJson('/api/ik/config/test-search-engine', {
100
+ method: 'POST',
101
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
102
+ body: JSON.stringify(request ?? {}),
103
+ }),
104
+ save: async () => ({
105
+ ok: false,
106
+ error: {
107
+ code: 'ikConfig/read-only',
108
+ message: '当前 DSH 宿主未挂载 typert 配置写入通道,部署配置为只读,请通过 profile 配置文件修改',
109
+ },
110
+ }),
111
+ }
112
+ }
113
+
70
114
  // Cordis may hand out a fresh namespace proxy on each injection callback. Keep
71
115
  // one stable facade so form models are not recreated (and drafts lost) when the
72
116
  // underlying proxy identity changes.
73
- export function createRemoteNamespaceFacade(getNamespace, methods = ['describe', 'validate', 'testSearchEngine', 'initializeWorkspace', 'autoSetup', 'save']) {
117
+ export function createRemoteNamespaceFacade(
118
+ getNamespace,
119
+ methods = ['describe', 'validate', 'testSearchEngine', 'initializeWorkspace', 'autoSetup', 'save'],
120
+ { fallback = null } = {},
121
+ ) {
74
122
  const facade = {}
75
123
  for (const method of methods) {
76
- facade[method] = (...args) => {
124
+ facade[method] = async (...args) => {
77
125
  const namespace = getNamespace()
78
- if (!namespace || typeof namespace[method] !== 'function') throw new Error(`Remote namespace method unavailable: ${method}`)
79
- return namespace[method](...args)
126
+ if (namespace && typeof namespace[method] === 'function') {
127
+ try {
128
+ const result = await namespace[method](...args)
129
+ if (result?.ok === false && fallback && typeof fallback[method] === 'function' && isTransientRemoteError(result.error)) {
130
+ return await fallback[method](...args)
131
+ }
132
+ return result
133
+ } catch (error) {
134
+ if (fallback && typeof fallback[method] === 'function' && isTransientRemoteError(error)) {
135
+ return await fallback[method](...args)
136
+ }
137
+ throw error
138
+ }
139
+ }
140
+ if (fallback && typeof fallback[method] === 'function') {
141
+ return await fallback[method](...args)
142
+ }
143
+ throw new Error(`Remote namespace method unavailable: ${method}`)
80
144
  }
81
145
  }
82
146
  return facade
@@ -1,7 +1,7 @@
1
1
  import { ArtifactTab, ArtifactTabTitle } from './artifactTab.jsx'
2
2
  import { ClaimTab, ClaimTabTitle } from './claimTab.jsx'
3
3
  import { createConfigAccessStore } from './configAccess.js'
4
- import { CONFIG_NAMESPACE, CONFIG_ROW_KEY, createRemoteNamespaceFacade } from './configForm.js'
4
+ import { CONFIG_NAMESPACE, CONFIG_ROW_KEY, createHttpConfigFallback, createRemoteNamespaceFacade } from './configForm.js'
5
5
  import { PluginBundleConfigPage, PluginRowConfigPage } from './config.jsx'
6
6
  import { Panel } from './Panel.jsx'
7
7
  import { HeaderStatus, PluginDetailSection } from './integrations.jsx'
@@ -57,7 +57,15 @@ export const inject = ['slots', 'locale']
57
57
 
58
58
  export function apply(ctx) {
59
59
  const t = createTranslate(ctx)
60
+ const httpConfigFallback = createHttpConfigFallback()
60
61
  const configAccess = createConfigAccessStore()
62
+ configAccess.set({
63
+ remote: null,
64
+ industryConfig: httpConfigFallback,
65
+ configForms: null,
66
+ settingsRemote: null,
67
+ remoteError: null,
68
+ })
61
69
  const reviewAccess = createReviewAccessStore()
62
70
 
63
71
  const openClaim = (claimId, releaseId) => {
@@ -203,12 +211,16 @@ export function apply(ctx) {
203
211
  const settingsRemote = child.remote.settings
204
212
  let industryNamespace = null
205
213
  let industryConfig = null
206
- const namespaceFacade = () => industryConfig ??= createRemoteNamespaceFacade(() => industryNamespace)
214
+ const namespaceFacade = () => industryConfig ??= createRemoteNamespaceFacade(
215
+ () => industryNamespace,
216
+ undefined,
217
+ { fallback: httpConfigFallback },
218
+ )
207
219
  const publish = (remote, remoteError = null, nextIndustryConfig = industryNamespace) => {
208
220
  industryNamespace = nextIndustryConfig
209
221
  configAccess.set({
210
222
  remote,
211
- industryConfig: industryNamespace ? namespaceFacade() : null,
223
+ industryConfig: namespaceFacade(),
212
224
  configForms: child.configForms,
213
225
  settingsRemote,
214
226
  remoteError,
@@ -18,6 +18,44 @@ function ownerOnly(ctx) {
18
18
  }
19
19
  }
20
20
 
21
+ export async function probeSearchEngines(request = {}, signal) {
22
+ const search = request?.search && typeof request.search === 'object' ? request.search : {}
23
+ const query = typeof request?.query === 'string' && request.query.trim() !== ''
24
+ ? request.query.trim().slice(0, 200)
25
+ : '2024 年 行业研究报告'
26
+ const specs = resolveEngineSpecs(search, process.env)
27
+ if (specs.length === 0) {
28
+ return { ok: false, query, engines: [], error: { code: 'NO_ENGINE', message: '没有已启用且配置了 Key 的引擎' } }
29
+ }
30
+ const engines = await Promise.all(specs.map(async spec => {
31
+ const startedAt = Date.now()
32
+ try {
33
+ const engine = createEngine({
34
+ ...spec,
35
+ count: Math.min(Number(spec.count) || 3, 5),
36
+ timeoutMs: Math.min(Number(spec.timeoutMs) || 8_000, 20_000),
37
+ })
38
+ const result = await engine.search({ query, maxResults: 3, signal })
39
+ return {
40
+ engine: spec.id,
41
+ ok: true,
42
+ count: result.sources.length,
43
+ ms: Date.now() - startedAt,
44
+ samples: result.sources.slice(0, 3).map(({ url, title }) => ({ url, title: title ?? null })),
45
+ }
46
+ } catch (error) {
47
+ return {
48
+ engine: spec.id,
49
+ ok: false,
50
+ count: 0,
51
+ ms: Date.now() - startedAt,
52
+ error: { code: String(error?.code ?? 'ENGINE_UNAVAILABLE'), message: String(error?.message ?? error).slice(0, 300) },
53
+ }
54
+ }
55
+ }))
56
+ return { ok: engines.some(row => row.ok), query, engines }
57
+ }
58
+
21
59
  export class IkConfigService extends TypertRemoteService {
22
60
  static inject = ['typert']
23
61
 
@@ -70,41 +108,7 @@ export class IkConfigService extends TypertRemoteService {
70
108
  */
71
109
  async testSearchEngine(request = {}, signal) {
72
110
  ownerOnly(this.ctx)
73
- const search = request?.search && typeof request.search === 'object' ? request.search : {}
74
- const query = typeof request?.query === 'string' && request.query.trim() !== ''
75
- ? request.query.trim().slice(0, 200)
76
- : '2024 年 行业研究报告'
77
- const specs = resolveEngineSpecs(search, process.env)
78
- if (specs.length === 0) {
79
- return { ok: false, query, engines: [], error: { code: 'NO_ENGINE', message: '没有已启用且配置了 Key 的引擎' } }
80
- }
81
- const engines = await Promise.all(specs.map(async spec => {
82
- const startedAt = Date.now()
83
- try {
84
- const engine = createEngine({
85
- ...spec,
86
- count: Math.min(Number(spec.count) || 3, 5),
87
- timeoutMs: Math.min(Number(spec.timeoutMs) || 8_000, 20_000),
88
- })
89
- const result = await engine.search({ query, maxResults: 3, signal })
90
- return {
91
- engine: spec.id,
92
- ok: true,
93
- count: result.sources.length,
94
- ms: Date.now() - startedAt,
95
- samples: result.sources.slice(0, 3).map(({ url, title }) => ({ url, title: title ?? null })),
96
- }
97
- } catch (error) {
98
- return {
99
- engine: spec.id,
100
- ok: false,
101
- count: 0,
102
- ms: Date.now() - startedAt,
103
- error: { code: String(error?.code ?? 'ENGINE_UNAVAILABLE'), message: String(error?.message ?? error).slice(0, 300) },
104
- }
105
- }
106
- }))
107
- return { ok: engines.some(row => row.ok), query, engines }
111
+ return probeSearchEngines(request, signal)
108
112
  }
109
113
 
110
114
  initializeWorkspace(request, signal) {
@@ -46,6 +46,10 @@ export function createKnowledgeApiHandler({
46
46
  getMode = () => 'host',
47
47
  getAutoSetupState = () => ({ status: 'idle', code: null, message: null }),
48
48
  getActiveRun = () => ({ active: false, runId: null, question: '', stage: 'idle', stages: [], updatedAt: null, error: null }),
49
+ getRemoteStatus = () => null,
50
+ getConfigDescribe = null,
51
+ validateConfig = null,
52
+ testSearchEngine = null,
49
53
  }) {
50
54
  let cachedStore = null
51
55
  let cachedPath = null
@@ -152,12 +156,14 @@ export function createKnowledgeApiHandler({
152
156
 
153
157
  function emptyStatus(state, extra = {}) {
154
158
  const setup = getAutoSetupState()
159
+ const remote = getRemoteStatus?.() ?? null
155
160
  return {
156
161
  configured: state === 'ready',
157
162
  state,
158
163
  exists: false,
159
164
  mode: getMode(),
160
165
  autoSetup: { status: setup?.status ?? 'idle', code: setup?.code ?? null, message: setup?.message ?? null },
166
+ ...(remote ? { remote } : {}),
161
167
  workspaceId: getWorkspaceId?.() ?? 'workspace:default',
162
168
  dbPath: maskPath(getDbPath?.() ?? null),
163
169
  activeReleaseId: null,
@@ -186,12 +192,14 @@ export function createKnowledgeApiHandler({
186
192
  const pendingClaimsCount = db.prepare(`SELECT count(*) AS n FROM claims WHERE workspace_id=? AND lifecycle_status='pending_review'`).get(workspaceId)?.n ?? 0
187
193
  const runsCount = db.prepare('SELECT count(*) AS n FROM runs WHERE workspace_id=?').get(workspaceId)?.n ?? 0
188
194
  const snapshotsCount = db.prepare('SELECT count(*) AS n FROM snapshots WHERE workspace_id=?').get(workspaceId)?.n ?? 0
195
+ const remote = getRemoteStatus?.() ?? null
189
196
  return sendJson(res, 200, {
190
197
  configured: true,
191
198
  state: 'ready',
192
199
  exists: true,
193
200
  mode: getMode(),
194
201
  autoSetup: autoSetupPublicState(),
202
+ ...(remote ? { remote } : {}),
195
203
  workspaceId,
196
204
  dbPath: maskPath(dbPath),
197
205
  workspaceDir: maskPath(getWorkspaceDir?.() ?? null),
@@ -624,6 +632,28 @@ export function createKnowledgeApiHandler({
624
632
  })
625
633
  }
626
634
 
635
+ async function readJsonBody(req, maxBytes = 256 * 1024) {
636
+ if (req.body && typeof req.body === 'object') return req.body
637
+ const chunks = []
638
+ let total = 0
639
+ for await (const chunk of req) {
640
+ const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))
641
+ total += buf.length
642
+ if (total > maxBytes) {
643
+ throw Object.assign(new Error('请求体过大'), { code: 'PAYLOAD_TOO_LARGE', status: 413 })
644
+ }
645
+ chunks.push(buf)
646
+ }
647
+ const raw = Buffer.concat(chunks).toString('utf8').trim()
648
+ if (!raw) return {}
649
+ try {
650
+ const parsed = JSON.parse(raw)
651
+ return parsed && typeof parsed === 'object' ? parsed : {}
652
+ } catch {
653
+ throw Object.assign(new Error('请求体不是合法 JSON'), { code: 'INVALID_JSON', status: 400 })
654
+ }
655
+ }
656
+
627
657
  async function handler(req, res) {
628
658
  try {
629
659
  const url = new URL(req.url, 'http://127.0.0.1')
@@ -631,10 +661,31 @@ export function createKnowledgeApiHandler({
631
661
  if (req.method === 'POST' && pathname === '/api/ik/reviews/decide') {
632
662
  return await handleReviewDecide(req, res)
633
663
  }
664
+ if (req.method === 'POST' && pathname === '/api/ik/config/validate') {
665
+ if (typeof validateConfig !== 'function') {
666
+ return sendJson(res, 501, { error: 'NOT_IMPLEMENTED', message: '配置校验接口未启用' })
667
+ }
668
+ const body = await readJsonBody(req)
669
+ const candidate = body?.config && typeof body.config === 'object' ? body.config : body
670
+ return sendJson(res, 200, validateConfig(candidate))
671
+ }
672
+ if (req.method === 'POST' && pathname === '/api/ik/config/test-search-engine') {
673
+ if (typeof testSearchEngine !== 'function') {
674
+ return sendJson(res, 501, { error: 'NOT_IMPLEMENTED', message: '搜索引擎探测接口未启用' })
675
+ }
676
+ const body = await readJsonBody(req)
677
+ return sendJson(res, 200, await testSearchEngine(body))
678
+ }
634
679
  if (req.method !== 'GET' && req.method !== 'HEAD') {
635
680
  return sendJson(res, 405, { error: 'METHOD_NOT_ALLOWED', message: '只读 API 仅支持 GET/HEAD' })
636
681
  }
637
682
  if (pathname === '/api/ik/status') return handleStatus(res)
683
+ if (pathname === '/api/ik/config/describe') {
684
+ if (typeof getConfigDescribe !== 'function') {
685
+ return sendJson(res, 501, { error: 'NOT_IMPLEMENTED', message: '配置描述接口未启用' })
686
+ }
687
+ return sendJson(res, 200, getConfigDescribe())
688
+ }
638
689
  if (pathname === '/api/ik/releases') return handleReleases(res)
639
690
  if (pathname === '/api/ik/claims') return handleClaims(res, url)
640
691
  if (pathname === '/api/ik/diff') {
@@ -52,8 +52,8 @@ import { exportDrl, recordConflict, saveBoundaryCard } from '../core/methodology
52
52
  import { addEntityRelation, queryEntityGraph } from '../core/entity-graph.mjs'
53
53
  import { composeDeliverableFromTemplate } from '../core/deliverable-templates.mjs'
54
54
  import { summarizeWorkspaceTelemetry } from '../core/telemetry.mjs'
55
- import { Config, countActiveRuns, toPlainConfig } from './config.mjs'
56
- import { IkConfigService } from './config-service.mjs'
55
+ import { Config, configFingerprint, countActiveRuns, toPlainConfig, validateRawConfig } from './config.mjs'
56
+ import { IkConfigService, probeSearchEngines } from './config-service.mjs'
57
57
  import { IkReviewService } from './review-service.mjs'
58
58
  import { registerIkRemote } from './ik-remote-registration.mjs'
59
59
  import { createIkMultiSearchProvider } from './search-provider.mjs'
@@ -148,27 +148,49 @@ export function apply(ctx, rawConfig = {}) {
148
148
  })
149
149
  }
150
150
 
151
+ const remoteStatus = {
152
+ typertInjected: false,
153
+ configEditorPresent: false,
154
+ ikConfigMounted: false,
155
+ ikReviewMounted: false,
156
+ error: null,
157
+ }
158
+
151
159
  if (mode === 'host') {
152
160
  let hostService = null
153
161
  let reviewService = null
154
162
  ctx.inject(['typert'], scoped => {
155
- hostService = new IkConfigService(scoped, {
156
- entry: ctx.fiber?.entry,
157
- getConfig: () => config,
158
- getActiveRuns: () => Math.max(activeRuns, countActiveRuns(dbPath, workspaceId)),
159
- setConfigSaving: value => { configSaving = Math.max(0, configSaving + (value ? 1 : -1)) },
160
- setAutoSetupState,
161
- applyAutoSetup: value => {
162
- dbPath = value.dbPath
163
- workspaceId = value.workspaceId
164
- },
165
- })
166
- reviewService = new IkReviewService(scoped, {
167
- getDbPath: () => dbPath,
168
- getWorkspaceId: () => workspaceId,
169
- })
170
- registerIkRemote(scoped)
163
+ remoteStatus.typertInjected = true
164
+ remoteStatus.configEditorPresent = Boolean(scoped.get?.('configEditor') ?? scoped.configEditor)
165
+ remoteStatus.error = null
166
+ try {
167
+ hostService = new IkConfigService(scoped, {
168
+ entry: ctx.fiber?.entry,
169
+ getConfig: () => config,
170
+ getActiveRuns: () => Math.max(activeRuns, countActiveRuns(dbPath, workspaceId)),
171
+ setConfigSaving: value => { configSaving = Math.max(0, configSaving + (value ? 1 : -1)) },
172
+ setAutoSetupState,
173
+ applyAutoSetup: value => {
174
+ dbPath = value.dbPath
175
+ workspaceId = value.workspaceId
176
+ },
177
+ })
178
+ remoteStatus.ikConfigMounted = true
179
+ reviewService = new IkReviewService(scoped, {
180
+ getDbPath: () => dbPath,
181
+ getWorkspaceId: () => workspaceId,
182
+ })
183
+ remoteStatus.ikReviewMounted = true
184
+ registerIkRemote(scoped)
185
+ } catch (cause) {
186
+ remoteStatus.error = String(cause?.message ?? cause)
187
+ ctx.logger?.warn?.(`industry-knowledge: remote service mount failed: ${remoteStatus.error}`)
188
+ }
171
189
  scoped.on('dispose', () => {
190
+ remoteStatus.typertInjected = false
191
+ remoteStatus.configEditorPresent = false
192
+ remoteStatus.ikConfigMounted = false
193
+ remoteStatus.ikReviewMounted = false
172
194
  if (hostService) hostService = null
173
195
  if (reviewService) reviewService = null
174
196
  })
@@ -1238,6 +1260,26 @@ export function apply(ctx, rawConfig = {}) {
1238
1260
  getMode: () => mode,
1239
1261
  getAutoSetupState: () => autoSetupState,
1240
1262
  getActiveRun: () => activeRunProgress,
1263
+ getRemoteStatus: () => ({ ...remoteStatus }),
1264
+ getConfigDescribe: () => {
1265
+ const current = toPlainConfig(config)
1266
+ let runs = null
1267
+ try { runs = Math.max(activeRuns, countActiveRuns(dbPath, workspaceId)) } catch { /* ignore */ }
1268
+ return {
1269
+ config: current,
1270
+ revision: configFingerprint(current, {}),
1271
+ activeRuns: runs,
1272
+ writable: false,
1273
+ saving: configSaving > 0,
1274
+ autoSetupError: autoSetupState.status === 'error' ? autoSetupState.message : null,
1275
+ transport: 'http-fallback',
1276
+ }
1277
+ },
1278
+ validateConfig: candidate => {
1279
+ const effective = resolveEffectiveConfig(candidate ?? {}, { defaultPath: hostDefaultPath() })
1280
+ return validateRawConfig(candidate ?? {}, { effective })
1281
+ },
1282
+ testSearchEngine: (request, signal) => probeSearchEngines(request, signal),
1241
1283
  })
1242
1284
  const unregisterApi = scoped.webServer.register({ kind: 'prefix', path: '/api/ik', handler: api.handler })
1243
1285
  scoped.on('dispose', () => {