bailian-kb-dsh 0.1.18
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/README.md +169 -0
- package/cordis.patch.yml +13 -0
- package/dist/api-types.d.ts +89 -0
- package/dist/api-types.js +2 -0
- package/dist/bl-cli.d.ts +28 -0
- package/dist/bl-cli.js +46 -0
- package/dist/chat.d.ts +11 -0
- package/dist/chat.js +44 -0
- package/dist/client.d.ts +40 -0
- package/dist/client.js +76 -0
- package/dist/console-login.d.ts +83 -0
- package/dist/console-login.js +263 -0
- package/dist/endpoints.d.ts +20 -0
- package/dist/endpoints.js +22 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +557 -0
- package/dist/service-cache.d.ts +151 -0
- package/dist/service-cache.js +234 -0
- package/dist/service-catalog.d.ts +34 -0
- package/dist/service-catalog.js +115 -0
- package/dist/service-context.d.ts +40 -0
- package/dist/service-context.js +125 -0
- package/dist/services.d.ts +41 -0
- package/dist/services.js +78 -0
- package/dist/skill.d.ts +39 -0
- package/dist/skill.js +119 -0
- package/dist/sse.d.ts +11 -0
- package/dist/sse.js +48 -0
- package/dist/tools.d.ts +38 -0
- package/dist/tools.js +244 -0
- package/dist/web/client.js +1052 -0
- package/dist/web/client.js.map +1 -0
- package/package.json +118 -0
- package/skills/bailian-kb/SKILL.md +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["createSnapshotStore","useState","css"],"sources":["../../src/web/bailian-card-controller.ts","../../src/web/BailianCard.tsx","../../src/web/locales.ts","../../src/web/index.ts"],"sourcesContent":["/**\n * The Bailian page's controller: a hybrid form over two domains.\n *\n * The workspace, default-retrieval-service and default-chat-service ids live\n * in the `bailian-kb` settings section the Host half registers. The Host\n * exposes them over a bridge route (`/bailian-kb/settings`) so the page can\n * read and write without riding the settings wire (which requires an apiproxy\n * allowlist entry the composition does not grant out-of-tree namespaces).\n *\n * The API key always rides its credential reference (write-only by design:\n * the wire is structurally value-free), so that control starts blank and\n * reports only configured/unconfigured.\n */\n\nimport type { IApiClient } from \"@deepseek-ai/dsh-client-connection/client\";\nimport { createSnapshotStore, type SnapshotStore } from \"@deepseek-ai/dsh-client-runtime/client\";\n\n/** The credential references this page addresses, keyed by their ref names. */\nexport const BAILIAN_CARD_REFS = [\n \"DASHSCOPE_API_KEY\",\n \"BAILIAN_WORKSPACE_ID\",\n \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\",\n \"BAILIAN_DEFAULT_CHAT_AGENT_ID\",\n] as const;\n\n/** One page field, addressed by its credential reference. */\nexport type BailianFieldKey = (typeof BAILIAN_CARD_REFS)[number];\n\n/** Settings-section field names of the echoing controls. */\nexport type BailianSettingsField = \"workspaceId\" | \"defaultRetrieveAgentId\" | \"defaultChatAgentId\";\n\n/** Credential reference → settings-section field, for the hybrid controls. */\nexport const SETTINGS_FIELDS: Partial<Record<BailianFieldKey, BailianSettingsField>> = {\n BAILIAN_WORKSPACE_ID: \"workspaceId\",\n BAILIAN_DEFAULT_RETRIEVE_AGENT_ID: \"defaultRetrieveAgentId\",\n BAILIAN_DEFAULT_CHAT_AGENT_ID: \"defaultChatAgentId\",\n};\n\n/** The section subset this page reads and writes (the namespace holds the whole plugin Config). */\nexport interface BailianKbSection {\n workspaceId?: string;\n defaultRetrieveAgentId?: string;\n defaultChatAgentId?: string;\n}\n\n/** What the credentials domain reports for one reference (never the value). */\nexport interface BailianCredentialView {\n /** Whether any layer supplies a value for the reference. */\n configured: boolean;\n /** Whether `credentials.set` can affect it; false disables the control. */\n writable: boolean;\n}\n\n/** The page's mirror of the settings scope. */\nexport interface BailianSettingsView {\n /** `ready` enables echo; `unavailable` degrades to write-only credentials. */\n status: \"loading\" | \"ready\" | \"unavailable\";\n /** Whether the Host settings document accepts writes. */\n writable: boolean;\n /** Resolved section values (entry base + user layer) for the two hybrid controls. */\n values: BailianKbSection;\n}\n\n/** Where the autofill flow (adopt a Bailian console login) currently stands. */\nexport type BailianAutofillStatus = \"idle\" | \"running\" | \"awaitingLogin\" | \"done\" | \"failed\";\n\n/** One cached retrieval or Q&A service, as the picker lists it. */\nexport interface BailianServiceEntry {\n agent_id: string;\n agent_name: string;\n scene: \"search\" | \"chat\";\n status: string;\n modify_time?: string;\n}\n\n/**\n * The service cache as the panel shows it.\n *\n * This exists because cache staleness is otherwise invisible: an agent that\n * silently stops retrieving looks identical whether the workspace is empty or the\n * list is merely out of date. `fetchedAt` with the per-scene counts distinguishes\n * those two in one glance, which is the whole reason the panel earns its space.\n */\nexport interface BailianCacheView {\n /** `unconfigured` = no workspace id yet; `unavailable` = the bridge route failed. */\n status: \"loading\" | \"ready\" | \"unconfigured\" | \"unavailable\";\n /** Epoch millis of the last successful fetch; absent when nothing is cached. */\n fetchedAt?: number;\n searchCount: number;\n chatCount: number;\n /** Server-reported total, which exceeds the counts when the fetch was capped. */\n total: number;\n truncated: boolean;\n stale: boolean;\n search: BailianServiceEntry[];\n chat: BailianServiceEntry[];\n /** Whether a forced refresh is in flight. */\n refreshing: boolean;\n}\n\n/** What the Bailian page renders. */\nexport interface BailianCardState {\n /** Staged drafts; undefined = untouched (the control shows the echoed value). */\n drafts: Record<BailianFieldKey, string | undefined>;\n /** Last credentials-domain answer per reference; unknown refs read as writable. */\n credentials: Record<BailianFieldKey, BailianCredentialView>;\n /** Settings-scope echo state for the id fields. */\n settings: BailianSettingsView;\n /** Whether a save is in flight. */\n saving: boolean;\n /** Whether a default-service clear is in flight. */\n clearing: boolean;\n /** Whether the last save or clear was refused; drafts are kept for correction. */\n failed: boolean;\n /** The autofill flow's state; feeds the button label and its result notice. */\n autofill: BailianAutofillStatus;\n /** Console login URL while `awaitingLogin`, shown in case the host could not open a browser. */\n autofillLoginUrl?: string;\n /** Service cache diagnostics and the pickable services. */\n cache: BailianCacheView;\n}\n\n/** The registration-side face the page's slot entry injects. */\nexport interface BailianCardFace {\n hooks: {\n /** Page snapshot bound by the renderer as useBailianCard. */\n bailianCard: SnapshotStore<BailianCardState>;\n };\n /** Stage one draft. */\n edit: (key: BailianFieldKey, text: string) => void;\n /** Write every staged draft through its domain, then re-read. */\n save: () => Promise<void>;\n /** Drop every staged draft. */\n discard: () => void;\n /** Remove the stored default service from every writable layer, then re-read. */\n clearDefaultAgent: (\n key: \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\" | \"BAILIAN_DEFAULT_CHAT_AGENT_ID\",\n ) => Promise<void>;\n /** Adopt a Bailian console login (api key + workspace id) via the Host. */\n autofill: () => Promise<void>;\n /** Force a service-cache refresh, bypassing the TTL. */\n refreshServices: () => Promise<void>;\n /**\n * Pin one scene's default service, or clear it when `agentId` is undefined.\n * Clearing removes the value from the settings user layer AND the credential\n * store, so the fallback chain cannot resurrect what the user just cleared.\n */\n selectDefaultAgent: (scene: \"search\" | \"chat\", agentId: string | undefined) => Promise<void>;\n}\n\n/** The text a field's control shows when its draft is untouched. */\nexport function echoedValue(state: BailianCardState, key: BailianFieldKey): string {\n const field = SETTINGS_FIELDS[key];\n if (field === undefined || state.settings.status !== \"ready\") return \"\";\n return state.settings.values[field] ?? \"\";\n}\n\n/** Whether one field stages a change a save would write. */\nfunction staged(state: BailianCardState, key: BailianFieldKey): boolean {\n const draft = state.drafts[key];\n if (draft === undefined) return false;\n const field = SETTINGS_FIELDS[key];\n if (field !== undefined && state.settings.status === \"ready\") {\n return draft !== echoedValue(state, key);\n }\n // Write-only control: blank means untouched, never \"erase the stored value\".\n return draft !== \"\";\n}\n\n/** Whether any field stages a change (enables Save/Discard). */\nexport function dirtyOf(state: BailianCardState): boolean {\n return BAILIAN_CARD_REFS.some((key) => staged(state, key));\n}\n\n/** Bridge the settings bridge route and the credentials domain onto the page. */\nexport class BailianCardController {\n private readonly store: SnapshotStore<BailianCardState>;\n\n /**\n * @param api - wire face used for the three credential references.\n */\n constructor(private readonly api: Pick<IApiClient, \"credentials\">) {\n this.store = createSnapshotStore<BailianCardState>({\n drafts: {\n DASHSCOPE_API_KEY: undefined,\n BAILIAN_WORKSPACE_ID: undefined,\n BAILIAN_DEFAULT_RETRIEVE_AGENT_ID: undefined,\n BAILIAN_DEFAULT_CHAT_AGENT_ID: undefined,\n },\n credentials: {\n DASHSCOPE_API_KEY: { configured: false, writable: true },\n BAILIAN_WORKSPACE_ID: { configured: false, writable: true },\n BAILIAN_DEFAULT_RETRIEVE_AGENT_ID: { configured: false, writable: true },\n BAILIAN_DEFAULT_CHAT_AGENT_ID: { configured: false, writable: true },\n },\n settings: { status: \"loading\", writable: false, values: {} },\n saving: false,\n clearing: false,\n failed: false,\n autofill: \"idle\",\n autofillLoginUrl: undefined,\n cache: {\n status: \"loading\",\n searchCount: 0,\n chatCount: 0,\n total: 0,\n truncated: false,\n stale: true,\n search: [],\n chat: [],\n refreshing: false,\n },\n });\n void this.fetchSettings();\n void this.fetchServices();\n void this.read();\n }\n\n /**\n * Fetch the current settings from the Host bridge route. Called at\n * construction and after every mutation (save, clear).\n */\n async fetchSettings(): Promise<void> {\n try {\n const resp = await fetch(\"/bailian-kb/settings\");\n if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n const value = (await resp.json()) as Record<string, unknown>;\n this.store.update((draft) => {\n draft.settings = {\n status: \"ready\",\n writable: true,\n values: {\n ...(typeof value.workspaceId === \"string\" ? { workspaceId: value.workspaceId } : {}),\n ...(typeof value.defaultRetrieveAgentId === \"string\"\n ? { defaultRetrieveAgentId: value.defaultRetrieveAgentId }\n : {}),\n ...(typeof value.defaultChatAgentId === \"string\"\n ? { defaultChatAgentId: value.defaultChatAgentId }\n : {}),\n },\n };\n });\n } catch (_fetchFailure) {\n this.store.update((draft) => {\n draft.settings = { status: \"unavailable\", writable: false, values: {} };\n });\n }\n }\n\n /**\n * Read the service cache snapshot from the Host bridge route.\n * @param force - POST instead of GET, making the Host refetch regardless of TTL.\n */\n async fetchServices(force = false): Promise<void> {\n if (force)\n this.store.update((draft) => {\n draft.cache.refreshing = true;\n });\n try {\n const resp = await fetch(\"/bailian-kb/services\", { method: force ? \"POST\" : \"GET\" });\n if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n const value = (await resp.json()) as {\n configured?: boolean;\n status?: {\n fetchedAt?: number;\n searchCount?: number;\n chatCount?: number;\n total?: number;\n truncated?: boolean;\n stale?: boolean;\n };\n search?: BailianServiceEntry[];\n chat?: BailianServiceEntry[];\n };\n this.store.update((draft) => {\n draft.cache.refreshing = false;\n if (value.configured !== true) {\n // No workspace id yet: the panel says so rather than showing zeros,\n // which would read as \"the workspace has no services\".\n draft.cache.status = \"unconfigured\";\n return;\n }\n draft.cache.status = \"ready\";\n draft.cache.fetchedAt = value.status?.fetchedAt;\n draft.cache.searchCount = value.status?.searchCount ?? 0;\n draft.cache.chatCount = value.status?.chatCount ?? 0;\n draft.cache.total = value.status?.total ?? 0;\n draft.cache.truncated = value.status?.truncated === true;\n draft.cache.stale = value.status?.stale === true;\n draft.cache.search = value.search ?? [];\n draft.cache.chat = value.chat ?? [];\n });\n } catch (_routeFailure) {\n this.store.update((draft) => {\n draft.cache.refreshing = false;\n draft.cache.status = \"unavailable\";\n });\n }\n }\n\n /** Force a refresh, bypassing the TTL, and show the updated numbers. */\n async refreshServices(): Promise<void> {\n if (this.store.getSnapshot().cache.refreshing) return;\n await this.fetchServices(true);\n }\n\n /**\n * Pin or clear one scene's default service.\n *\n * Clearing delegates to {@link clearDefaultAgent}, which removes the value from\n * the settings user layer AND the credential store — without the second\n * removal the fallback chain would resurrect what the user just cleared.\n * @param scene - which tool's default to set.\n * @param agentId - the service id to pin, or undefined to clear.\n */\n async selectDefaultAgent(scene: \"search\" | \"chat\", agentId: string | undefined): Promise<void> {\n const key =\n scene === \"search\" ? \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\" : \"BAILIAN_DEFAULT_CHAT_AGENT_ID\";\n if (agentId === undefined) {\n await this.clearDefaultAgent(key);\n return;\n }\n const field: BailianSettingsField =\n scene === \"search\" ? \"defaultRetrieveAgentId\" : \"defaultChatAgentId\";\n this.store.update((draft) => {\n draft.saving = true;\n });\n try {\n const resp = await fetch(\"/bailian-kb/settings\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ [field]: agentId }),\n });\n if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n this.store.update((draft) => {\n draft.failed = false;\n });\n } catch (_writeFailure) {\n this.store.update((draft) => {\n draft.failed = true;\n });\n } finally {\n this.store.update((draft) => {\n draft.saving = false;\n });\n await this.fetchSettings();\n }\n }\n\n /**\n * Stage one draft; any edit clears the failure mark so the banner does not\n * outlive the correction it asks for.\n * @param key - the field's credential reference.\n * @param text - the staged text.\n */\n edit(key: BailianFieldKey, text: string): void {\n this.store.update((draft) => {\n draft.drafts[key] = text;\n draft.failed = false;\n });\n }\n\n /**\n * Write every staged draft through its domain: echoing fields go to the\n * settings user layer via the bridge route (blank = removal, falling back\n * to entry config and the credential store), write-only fields go to\n * `credentials.set`. A refused credential write keeps its draft; a refused\n * settings write self-heals by re-fetching the Host value.\n */\n async save(): Promise<void> {\n const state = this.store.getSnapshot();\n if (state.saving || !dirtyOf(state)) return;\n this.store.update((draft) => {\n draft.saving = true;\n });\n let failed = false;\n const settingsPatch: Record<string, unknown> = {};\n let hasSettingsWrite = false;\n const credentialWrites: Promise<void>[] = [];\n const settled: BailianFieldKey[] = [];\n for (const key of BAILIAN_CARD_REFS) {\n if (!staged(state, key)) continue;\n const text = state.drafts[key] as string;\n const field = SETTINGS_FIELDS[key];\n if (field !== undefined && state.settings.status === \"ready\") {\n settingsPatch[field] = text === \"\" ? null : text;\n hasSettingsWrite = true;\n settled.push(key);\n continue;\n }\n credentialWrites.push(\n (async () => {\n try {\n const response = await this.api.credentials.set({ ref: key, value: text });\n if (response.result.ok) settled.push(key);\n else failed = true;\n } catch (_credentialWriteFailure) {\n failed = true;\n }\n })(),\n );\n }\n if (hasSettingsWrite) {\n try {\n await this.saveSettings(settingsPatch);\n } catch (_settingsWriteFailure) {\n failed = true;\n }\n }\n await Promise.all(credentialWrites);\n this.store.update((draft) => {\n draft.saving = false;\n draft.failed = failed;\n for (const key of settled) draft.drafts[key] = undefined;\n });\n await this.fetchSettings();\n await this.read();\n }\n\n /** Drop every staged draft and the failure mark. */\n discard(): void {\n this.store.update((draft) => {\n for (const ref of BAILIAN_CARD_REFS) draft.drafts[ref] = undefined;\n draft.failed = false;\n });\n }\n\n /**\n * Fetch credentials by signing in to the Bailian console. The Host drives\n * the console browser login itself, always requesting a freshly issued api\n * key, then persists the key into the credential store and the workspace id\n * into the settings section — so both values belong to the account that just\n * signed in, and the plain key never rides the wire to this page.\n *\n * Deliberately does NOT adopt the bl CLI's stored login: that path can pair\n * one account's key with another account's workspace id, and nothing would\n * flag the mismatch until a knowledge-base call fails.\n */\n async autofill(): Promise<void> {\n const phase = this.store.getSnapshot().autofill;\n if (phase === \"running\" || phase === \"awaitingLogin\") return;\n this.store.update((draft) => {\n draft.autofill = \"running\";\n draft.autofillLoginUrl = undefined;\n });\n await this.runConsoleLogin();\n await this.fetchSettings();\n await this.read();\n }\n\n /**\n * Ask the Host to open the console login page, then poll for the outcome.\n * The Host persists the credentials itself when the callback lands, always\n * requesting a freshly issued key — so the key and the workspace id both come\n * from the account signing in.\n */\n private async runConsoleLogin(): Promise<void> {\n let started: { status?: string; loginUrl?: string };\n try {\n started = (await this.postAutofill(\"login\")) as { status?: string; loginUrl?: string };\n } catch (_routeFailure) {\n this.store.update((draft) => {\n draft.autofill = \"failed\";\n });\n return;\n }\n if (started.status !== \"started\" && started.status !== \"already-running\") {\n this.store.update((draft) => {\n draft.autofill = \"failed\";\n });\n return;\n }\n this.store.update((draft) => {\n draft.autofill = \"awaitingLogin\";\n draft.autofillLoginUrl = started.loginUrl;\n });\n await this.pollConsoleLogin();\n }\n\n /**\n * Poll the Host until the console login resolves. Bounded so a login the\n * user abandons does not leave the button spinning forever; the Host keeps\n * its own (longer) timeout, so a late callback still persists and shows up\n * on the next page read.\n */\n private async pollConsoleLogin(): Promise<void> {\n const deadline = Date.now() + 5 * 60 * 1000;\n while (Date.now() < deadline) {\n await new Promise((resolve) => setTimeout(resolve, 2000));\n let phase: string | undefined;\n try {\n phase = ((await this.postAutofill(\"loginStatus\")) as { phase?: string }).phase;\n } catch (_pollFailure) {\n continue;\n }\n if (phase === \"done\") {\n this.store.update((draft) => {\n draft.autofill = \"done\";\n draft.autofillLoginUrl = undefined;\n });\n return;\n }\n if (phase === \"failed\") {\n this.store.update((draft) => {\n draft.autofill = \"failed\";\n draft.autofillLoginUrl = undefined;\n });\n return;\n }\n }\n this.store.update((draft) => {\n draft.autofill = \"failed\";\n });\n }\n\n /**\n * Remove the stored default service from every writable layer — the\n * settings user layer AND the credential store, so the fallback chain does\n * not resurrect the value the user just cleared. Both removals are\n * idempotent; the credential unset is skipped when nothing is stored there.\n * @param key - which default service credential to clear.\n */\n async clearDefaultAgent(\n key: \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\" | \"BAILIAN_DEFAULT_CHAT_AGENT_ID\",\n ): Promise<void> {\n const settingsField: BailianSettingsField =\n key === \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\" ? \"defaultRetrieveAgentId\" : \"defaultChatAgentId\";\n const state = this.store.getSnapshot();\n if (state.clearing) return;\n this.store.update((draft) => {\n draft.clearing = true;\n });\n let failed = false;\n if (state.settings.status === \"ready\") {\n try {\n await this.saveSettings({ [settingsField]: null });\n } catch (_settingsWriteFailure) {\n failed = true;\n }\n }\n if (state.credentials[key].configured) {\n try {\n const response = await this.api.credentials.unset({ ref: key });\n if (!response.result.ok) failed = true;\n } catch (_credentialWriteFailure) {\n failed = true;\n }\n }\n this.store.update((draft) => {\n draft.clearing = false;\n draft.failed = failed;\n draft.drafts[key] = undefined;\n });\n await this.fetchSettings();\n await this.read();\n }\n\n /**\n * Re-read after the Host reports a change to a reference this page watches.\n *\n * A value can be written from somewhere else — the Models page addresses\n * DASHSCOPE_API_KEY too, and the file store accepts external edits — so\n * without this the badges keep reporting a state the Host already replaced.\n * (Settings-document changes reach the page through the scope instead.)\n * @param ref - the reference the Host reports as changed.\n */\n refresh(ref: string): void {\n if (!(BAILIAN_CARD_REFS as readonly string[]).includes(ref)) return;\n void this.read();\n }\n\n /**\n * Build the face the page's slot registration injects.\n * @returns the page's snapshot and its actions.\n */\n inject(): BailianCardFace {\n return {\n hooks: { bailianCard: this.store },\n edit: (key, text) => {\n this.edit(key, text);\n },\n save: () => this.save(),\n discard: () => {\n this.discard();\n },\n clearDefaultAgent: (key) => this.clearDefaultAgent(key),\n autofill: () => this.autofill(),\n refreshServices: () => this.refreshServices(),\n selectDefaultAgent: (scene, agentId) => this.selectDefaultAgent(scene, agentId),\n };\n }\n\n /**\n * Post one autofill action to the Host bridge route.\n * @param action - `login` starts the console browser flow; `loginStatus`\n * reads that flow's progress.\n * @returns the route's JSON answer.\n */\n private async postAutofill(action: \"login\" | \"loginStatus\"): Promise<unknown> {\n const resp = await fetch(\"/bailian-kb/autofill\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ action }),\n });\n if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n return resp.json();\n }\n\n /**\n * Send a settings patch to the Host bridge route. `null`-valued keys are\n * removals (the field falls back to the entry config and then the\n * credential store); other values are merged into the user layer.\n * @param patch - the partial settings update.\n */\n private async saveSettings(patch: Record<string, unknown>): Promise<void> {\n const resp = await fetch(\"/bailian-kb/settings\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(patch),\n });\n if (!resp.ok) {\n const body = (await resp.json().catch(() => ({}))) as { error?: string };\n throw new Error(body.error ?? `HTTP ${resp.status}`);\n }\n }\n\n /**\n * Ask the credentials domain about all three references and publish the\n * answer. A failed read keeps the last known state: the page stays usable\n * and a write still reaches the Host.\n */\n private async read(): Promise<void> {\n let response: Awaited<ReturnType<IApiClient[\"credentials\"][\"describe\"]>>;\n try {\n response = await this.api.credentials.describe({ refs: [...BAILIAN_CARD_REFS] });\n } catch (_credentialReadFailure) {\n return;\n }\n if (!response.result.ok) return;\n const view = response.result.value.credentials;\n this.store.update((draft) => {\n for (const ref of BAILIAN_CARD_REFS) {\n // An unknown reference reads as writable: the control stays usable and\n // the Host is what refuses, rather than the page guessing a refusal.\n draft.credentials[ref] = {\n configured: view[ref]?.configured ?? false,\n writable: view[ref]?.writable ?? true,\n };\n }\n });\n }\n}\n","/**\n * The Bailian knowledge-base settings page: one section page in the\n * Settings left nav. The workspace, default-retrieval-service and\n * default-chat-service ids echo from the `bailian-kb` settings section\n * while the scope is ready (clearing one falls back down the resolution\n * chain), and degrade to write-only credential controls otherwise; the\n * API key is always write-only — it drafts behind a password mask,\n * starts blank, and reports only configured/unconfigured.\n */\n\nimport { useState } from \"react\";\nimport type { InjectFace, PropsLocale, PropsRuntime } from \"@deepseek-ai/dsh-client-ui-slots\";\nimport {\n dirtyOf,\n echoedValue,\n SETTINGS_FIELDS,\n type BailianCardFace,\n type BailianCardState,\n type BailianFieldKey,\n} from \"./bailian-card-controller.ts\";\nimport type { BailianKbLocaleKey } from \"./locales.ts\";\nimport css from \"./BailianCard.module.css\";\n\n/** Bailian console URL that lets the user create or copy an API key. */\nconst BAILIAN_CONSOLE_API_KEY_URL =\n \"https://bailian.console.aliyun.com/cn-beijing?tab=globalset#/efm/api_key\";\n\n/** Props the renderer binds for the Bailian section page. */\nexport type BailianCardProps = PropsRuntime<\"settings.section\"> &\n PropsLocale<\"tool-bailian-kb\"> &\n InjectFace<BailianCardFace>;\n\n/** One field's render description. */\ninterface FieldView {\n key: BailianFieldKey;\n labelKey: BailianKbLocaleKey;\n /** Locale key for the \"get\" link shown next to the label. */\n getKey?: BailianKbLocaleKey;\n /** Echo-mode explanation (settings-backed value, blank save = fall back). */\n hintKey: BailianKbLocaleKey;\n /** Write-only explanation (credential store, blank = keep the stored value). */\n fallbackHintKey: BailianKbLocaleKey;\n setKey: BailianKbLocaleKey;\n unsetKey: BailianKbLocaleKey;\n /** Password-masked drafting; only the API key is an actual secret. */\n secret: boolean;\n /** When true the field is hidden inside the collapsible advanced section. */\n advanced?: boolean;\n /** External console URL for the \"get\" link. */\n getUrl?: string;\n}\n\n/**\n * The controls, in page order.\n *\n * The two default-service ids are NOT here: they render as pickers inside the\n * advanced section instead, driven by the cached service list. A free-text id\n * field beside a picker for the same setting is the same value twice, and the\n * pair drifts the moment one of them writes.\n */\nconst FIELDS: readonly FieldView[] = [\n {\n key: \"DASHSCOPE_API_KEY\",\n labelKey: \"apiKey\",\n getKey: \"apiKeyGet\",\n hintKey: \"apiKeyHint\",\n fallbackHintKey: \"apiKeyHint\",\n setKey: \"apiKeySet\",\n unsetKey: \"apiKeyUnset\",\n secret: true,\n advanced: true,\n getUrl: BAILIAN_CONSOLE_API_KEY_URL,\n },\n {\n key: \"BAILIAN_WORKSPACE_ID\",\n labelKey: \"workspaceId\",\n getKey: \"workspaceIdGet\",\n hintKey: \"workspaceIdHint\",\n fallbackHintKey: \"workspaceIdHintFallback\",\n setKey: \"workspaceIdSet\",\n unsetKey: \"workspaceIdUnset\",\n secret: false,\n advanced: true,\n getUrl: BAILIAN_CONSOLE_API_KEY_URL,\n },\n];\n\nconst ADVANCED_FIELDS = FIELDS.filter((field) => field.advanced);\n\n/** Whether both the API key and the workspace id already hold values. */\nfunction fullyConfigured(state: BailianCardState): boolean {\n const apiKeyConfigured = state.credentials.DASHSCOPE_API_KEY.configured;\n const workspaceConfigured =\n state.credentials.BAILIAN_WORKSPACE_ID.configured ||\n echoedValue(state, \"BAILIAN_WORKSPACE_ID\") !== \"\";\n return apiKeyConfigured && workspaceConfigured;\n}\n\n/**\n * Render the Bailian section page.\n * @param props - locale copy, the page snapshot, and its actions.\n * @returns the section page.\n */\nexport function BailianCard(props: BailianCardProps) {\n const { t } = props;\n const [advancedOpen, setAdvancedOpen] = useState(false);\n const state = props.useBailianCard((snapshot) => snapshot);\n const dirty = dirtyOf(state);\n const busy = state.saving || state.clearing;\n\n // The flow spans a browser login, so the button stays disabled until it settles.\n const autofillBusy = state.autofill === \"running\" || state.autofill === \"awaitingLogin\";\n\n // Pick the notice under the autofill button: settled outcome first, then\n // a green \"already configured\" hint, then the default invitation.\n let autofillNotice: BailianKbLocaleKey | undefined;\n let autofillNoticeSuccess = false;\n if (state.autofill === \"done\") {\n autofillNotice = \"autofillDone\";\n autofillNoticeSuccess = true;\n } else if (state.autofill === \"awaitingLogin\") {\n autofillNotice = \"autofillAwaitingLogin\";\n } else if (state.autofill === \"failed\") {\n autofillNotice = \"autofillFailed\";\n } else if (fullyConfigured(state)) {\n autofillNotice = \"autofillConfigured\";\n autofillNoticeSuccess = true;\n }\n\n const renderField = (field: FieldView) => {\n const credential = state.credentials[field.key];\n // Echo mode: the settings scope answers with the resolved value, so\n // the control is an ordinary pre-filled input. Otherwise the control\n // is write-only and the badge is all the state there is.\n const echo = SETTINGS_FIELDS[field.key] !== undefined && state.settings.status === \"ready\";\n const echoed = echoedValue(state, field.key);\n const value = state.drafts[field.key] ?? (echo ? echoed : \"\");\n const disabled = busy || (echo ? !state.settings.writable : !credential.writable);\n // The launch environment wins over the credential store and refuses\n // writes; in echo mode a non-empty settings value shadows both, so\n // the badge only reports the fallback under an empty input.\n const badge = echo\n ? echoed !== \"\"\n ? undefined\n : credential.configured\n ? { label: t(\"fallbackConfigured\"), set: true }\n : { label: t(field.unsetKey), set: false }\n : credential.configured\n ? { label: credential.writable ? t(field.setKey) : t(\"fromEnv\"), set: true }\n : { label: t(field.unsetKey), set: false };\n const showClear =\n (field.key === \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\" ||\n field.key === \"BAILIAN_DEFAULT_CHAT_AGENT_ID\") &&\n (credential.configured || (echo && echoed !== \"\"));\n return (\n <div className={css.field} key={field.key}>\n <div className={css.head}>\n <span className={css.labelWrap}>\n <label className={css.label} htmlFor={`bailian-kb-${field.key}`}>\n {t(field.labelKey)}\n </label>\n {field.getUrl !== undefined && field.getKey !== undefined ? (\n <a className={css.getLink} href={field.getUrl} target=\"_blank\" rel=\"noreferrer\">\n {t(field.getKey)}\n </a>\n ) : null}\n </span>\n <span className={css.badges}>\n {showClear ? (\n <button\n type=\"button\"\n className={css.clear}\n disabled={busy}\n onClick={() => {\n void props.clearDefaultAgent(\n field.key as\n | \"BAILIAN_DEFAULT_RETRIEVE_AGENT_ID\"\n | \"BAILIAN_DEFAULT_CHAT_AGENT_ID\",\n );\n }}\n >\n {t(state.clearing ? \"clearing\" : \"clear\")}\n </button>\n ) : null}\n {badge !== undefined ? (\n <span className={badge.set ? css.badgeSuccess : css.badgeMuted}>{badge.label}</span>\n ) : null}\n </span>\n </div>\n <input\n id={`bailian-kb-${field.key}`}\n className={css.input}\n type={field.secret ? \"password\" : \"text\"}\n autoComplete=\"off\"\n value={value}\n disabled={disabled}\n onChange={(event) => {\n props.edit(field.key, event.target.value);\n }}\n />\n <p className={css.hint}>{t(echo ? field.hintKey : field.fallbackHintKey)}</p>\n </div>\n );\n };\n\n /**\n * One scene's default-service picker — the sole control for that setting.\n *\n * The cached list is the menu, but a value already pinned outside this list\n * (the fetch is capped, so an older service can be absent) is prepended as its\n * own option: dropping it would make the panel silently forget a live setting.\n */\n function renderPicker(scene: \"search\" | \"chat\") {\n const cache = state.cache;\n const entries = scene === \"search\" ? cache.search : cache.chat;\n const pinned =\n scene === \"search\"\n ? state.settings.values.defaultRetrieveAgentId\n : state.settings.values.defaultChatAgentId;\n const isPinned = pinned !== undefined && pinned !== \"\";\n const pinnedIsListed = isPinned && entries.some((entry) => entry.agent_id === pinned);\n return (\n <div className={css.field}>\n <div className={css.head}>\n <span className={css.label}>\n {t(scene === \"search\" ? \"retrieveAgentId\" : \"chatAgentId\")}\n </span>\n {isPinned ? (\n <button\n type=\"button\"\n className={css.clear}\n disabled={busy}\n onClick={() => {\n void props.selectDefaultAgent(scene, undefined);\n }}\n >\n {t(state.clearing ? \"clearing\" : \"pickerClear\")}\n </button>\n ) : null}\n </div>\n <select\n className={css.input}\n value={pinned ?? \"\"}\n disabled={busy || cache.status !== \"ready\"}\n onChange={(event) => {\n const next = event.target.value;\n // The empty option is the clear path, which must remove the value\n // from both the settings layer and the credential store.\n void props.selectDefaultAgent(scene, next === \"\" ? undefined : next);\n }}\n >\n <option value=\"\">{t(\"pickerNone\")}</option>\n {isPinned && !pinnedIsListed ? <option value={pinned}>{pinned}</option> : null}\n {entries.map((entry) => (\n <option key={entry.agent_id} value={entry.agent_id}>\n {entry.agent_name === \"\" ? entry.agent_id : entry.agent_name}\n </option>\n ))}\n </select>\n <p className={css.hint}>\n {entries.length === 0\n ? t(\"cacheEmpty\")\n : t(scene === \"search\" ? \"retrieveAgentIdHint\" : \"chatAgentIdHint\")}\n </p>\n </div>\n );\n }\n\n /**\n * The service-cache diagnostics: last fetch, per-scene counts, refresh.\n *\n * This stays OUTSIDE the advanced fold on purpose. It is the answer to \"why did\n * the agent stop retrieving\" — an empty workspace and a stale list look\n * identical from the outside, and before this the only way to tell them apart\n * was reading the cache JSON off disk.\n */\n function renderCacheStatus() {\n const cache = state.cache;\n if (cache.status === \"loading\") return <p className={css.hint}>{t(\"cacheLoading\")}</p>;\n if (cache.status === \"unconfigured\")\n return <p className={css.notice}>{t(\"cacheUnconfigured\")}</p>;\n if (cache.status === \"unavailable\")\n return <p className={css.notice}>{t(\"cacheUnavailable\")}</p>;\n\n const fetched =\n cache.fetchedAt === undefined ? t(\"cacheNever\") : new Date(cache.fetchedAt).toLocaleString();\n\n return (\n <div className={css.field}>\n <div className={css.head}>\n <span className={css.label}>{t(\"cacheTitle\")}</span>\n <button\n type=\"button\"\n className={css.clear}\n disabled={cache.refreshing}\n onClick={() => {\n void props.refreshServices();\n }}\n >\n {t(cache.refreshing ? \"cacheRefreshing\" : \"cacheRefresh\")}\n </button>\n </div>\n <p className={css.hint}>\n {t(\"cacheFetchedAt\")}: {fetched}\n {cache.stale ? ` (${t(\"cacheStale\")})` : \"\"}\n {\" · \"}\n {t(\"cacheSearchCount\")}: {cache.searchCount}\n {\" · \"}\n {t(\"cacheChatCount\")}: {cache.chatCount}\n </p>\n {cache.truncated ? <p className={css.notice}>{t(\"cacheTruncated\")}</p> : null}\n {cache.searchCount === 0 && cache.chatCount === 0 ? (\n <p className={css.notice}>{t(\"cacheEmpty\")}</p>\n ) : null}\n <p className={css.hint}>{t(\"cacheHint\")}</p>\n </div>\n );\n }\n\n return (\n <section className={css.section}>\n <div className={css.headRow}>\n <h2 className={css.title}>{t(\"title\")}</h2>\n {dirty ? <span className={css.pending}>{t(\"unsaved\")}</span> : null}\n </div>\n <p className={css.intro}>{t(\"description\")}</p>\n <div className={css.autofillRow}>\n <button\n type=\"button\"\n className={css.discard}\n disabled={busy || autofillBusy}\n onClick={() => {\n void props.autofill();\n }}\n >\n {t(state.autofill === \"running\" ? \"autofilling\" : \"autofill\")}\n </button>\n <span className={autofillNoticeSuccess ? css.autofillNoticeSuccess : css.hint}>\n {autofillNotice !== undefined ? t(autofillNotice) : t(\"autofillHint\")}\n {/* The host opens the page itself; this link is the fallback when it cannot. */}\n {state.autofillLoginUrl !== undefined && state.autofillLoginUrl !== \"\" ? (\n <>\n {\" \"}\n <a href={state.autofillLoginUrl} target=\"_blank\" rel=\"noreferrer\">\n {t(\"autofillOpenUrl\")}\n </a>\n </>\n ) : null}\n </span>\n </div>\n <div className={css.form}>\n {state.settings.status === \"unavailable\" ? (\n <p className={css.notice}>{t(\"settingsUnavailable\")}</p>\n ) : null}\n {renderCacheStatus()}\n <div className={css.advancedSection}>\n <button\n type=\"button\"\n className={css.advancedToggle}\n aria-expanded={advancedOpen}\n onClick={() => {\n setAdvancedOpen((open) => !open);\n }}\n >\n {t(\"advancedConfig\")}\n </button>\n {advancedOpen ? (\n <div className={css.advancedFields}>\n {ADVANCED_FIELDS.map(renderField)}\n {renderPicker(\"search\")}\n {renderPicker(\"chat\")}\n <div className={css.footer}>\n {state.failed ? (\n <p className={css.failed} role=\"status\">\n {t(\"saveFailed\")}\n </p>\n ) : null}\n <button\n type=\"button\"\n className={css.discard}\n disabled={!dirty || busy}\n onClick={props.discard}\n >\n {t(\"discard\")}\n </button>\n <button\n type=\"button\"\n className={css.save}\n disabled={!dirty || busy}\n onClick={() => {\n void props.save();\n }}\n >\n {t(state.saving ? \"saving\" : \"save\")}\n </button>\n </div>\n </div>\n ) : null}\n </div>\n </div>\n </section>\n );\n}\n","/**\n * Locale bundles for the Bailian knowledge-base settings page. The workspace,\n * default-retrieval-service and default-chat-service ids echo from the\n * settings section while it is available and fall back to write-only\n * credential controls otherwise; the API key copy is always written for a\n * write-only control: state is reported as configured/unconfigured, and a\n * stored key is never echoed back.\n */\n\n/** Locale keys this page renders. */\nexport type BailianKbLocaleKey =\n | \"nav\"\n | \"title\"\n | \"description\"\n | \"settingsUnavailable\"\n | \"fallbackConfigured\"\n | \"apiKey\"\n | \"apiKeyHint\"\n | \"apiKeySet\"\n | \"apiKeyUnset\"\n | \"apiKeyGet\"\n | \"workspaceId\"\n | \"workspaceIdHint\"\n | \"workspaceIdHintFallback\"\n | \"workspaceIdSet\"\n | \"workspaceIdUnset\"\n | \"workspaceIdGet\"\n | \"retrieveAgentId\"\n | \"retrieveAgentIdHint\"\n | \"chatAgentId\"\n | \"chatAgentIdHint\"\n | \"fromEnv\"\n | \"clear\"\n | \"clearing\"\n | \"save\"\n | \"saving\"\n | \"discard\"\n | \"unsaved\"\n | \"saveFailed\"\n | \"advancedConfig\"\n | \"autofill\"\n | \"autofilling\"\n | \"autofillHint\"\n | \"autofillDone\"\n | \"autofillAwaitingLogin\"\n | \"autofillOpenUrl\"\n | \"autofillFailed\"\n | \"autofillConfigured\"\n | \"cacheTitle\"\n | \"cacheHint\"\n | \"cacheLoading\"\n | \"cacheUnconfigured\"\n | \"cacheUnavailable\"\n | \"cacheFetchedAt\"\n | \"cacheNever\"\n | \"cacheStale\"\n | \"cacheSearchCount\"\n | \"cacheChatCount\"\n | \"cacheTruncated\"\n | \"cacheEmpty\"\n | \"cacheRefresh\"\n | \"cacheRefreshing\"\n | \"pickerNone\"\n | \"pickerClear\";\n\n/** English copy. */\nexport const en: Record<BailianKbLocaleKey, string> = {\n nav: \"Bailian KB\",\n title: \"Bailian knowledge base\",\n description: \"Account for the knowledge tools: API key, workspace, and default services.\",\n settingsUnavailable:\n \"The settings document is not reachable from this browser; values below are write-only and stored in the credential store.\",\n fallbackConfigured: \"Falling back to a configured credential-store value.\",\n apiKey: \"API key\",\n apiKeyHint:\n \"DashScope API key. Stored in the credentials store and never shown again; leave blank to keep the current one.\",\n apiKeySet: \"A key is configured.\",\n apiKeyUnset: \"No key is configured; knowledge tools fail until one is.\",\n apiKeyGet: \"Get\",\n workspaceId: \"Workspace id\",\n workspaceIdHint:\n \"Bailian workspace id — the subdomain of your endpoints. Stored in the settings document; clear and save to fall back to the credential store.\",\n workspaceIdHintFallback:\n \"Bailian workspace id — the subdomain of your endpoints. Leave blank to keep the current one.\",\n workspaceIdSet: \"A workspace is configured.\",\n workspaceIdUnset: \"No workspace is configured; knowledge tools fail until one is.\",\n workspaceIdGet: \"Get\",\n retrieveAgentId: \"Default retrieval service\",\n retrieveAgentIdHint:\n \"The agent_id kb_search falls back to. Left unset, the injected catalog lists every deployed service instead.\",\n chatAgentId: \"Default Q&A service\",\n chatAgentIdHint:\n \"The agent_id kb_chat falls back to. Left unset, the injected catalog lists every deployed service instead.\",\n fromEnv: \"Set by the environment (read-only here)\",\n clear: \"Clear default\",\n clearing: \"Clearing…\",\n save: \"Save\",\n saving: \"Saving…\",\n discard: \"Discard\",\n unsaved: \"Unsaved\",\n saveFailed: \"The Host did not accept these values; they were left for you to correct.\",\n advancedConfig: \"Advanced configuration\",\n autofill: \"Fetch from console login\",\n autofilling: \"Starting…\",\n autofillHint:\n \"Sign in to the Bailian console to fill in that account’s API key and workspace id.\",\n autofillDone: \"Credentials adopted; the fields below reflect the new values.\",\n autofillAwaitingLogin:\n \"Waiting for the Bailian console login to finish in a browser on the host machine…\",\n autofillOpenUrl: \"Open the login page manually\",\n autofillFailed:\n \"Auto-fill failed — the credential may be locked by an environment variable, the Host refused the write, or the login was abandoned.\",\n autofillConfigured:\n \"Configured. Click button to fetch this account’s API key and workspace id again.\",\n cacheTitle: \"Retrieval service cache\",\n cacheHint:\n \"The service list injected into each conversation. Refreshes on its own; refresh here when you have just created a service and want it picked up now.\",\n cacheLoading: \"Reading…\",\n cacheUnconfigured: \"Set a workspace id first.\",\n cacheUnavailable: \"Not reachable from this browser.\",\n cacheFetchedAt: \"Last fetched\",\n cacheNever: \"never\",\n cacheStale: \"refresh due\",\n cacheSearchCount: \"Retrieval services\",\n cacheChatCount: \"Q&A services\",\n cacheTruncated: \"List truncated — the workspace holds more than were fetched.\",\n cacheEmpty: \"No deployed services cached. If you just created one, refresh.\",\n cacheRefresh: \"Refresh\",\n cacheRefreshing: \"Refreshing…\",\n pickerNone: \"Not set — the full list is injected instead\",\n pickerClear: \"Clear\",\n};\n\n/** Simplified Chinese copy. */\nexport const zh: Record<BailianKbLocaleKey, string> = {\n nav: \"百炼知识库\",\n title: \"百炼知识库\",\n description: \"知识库工具的账号信息:API 密钥、工作空间与默认服务。\",\n settingsUnavailable: \"当前浏览器无法访问设置文档;以下字段仅可写入凭据存储,不回显。\",\n fallbackConfigured: \"回退:凭据存储中已有值。\",\n apiKey: \"API 密钥\",\n apiKeyHint: \"DashScope API key。保存在凭据存储中且不会再次显示;留空表示保持当前值。\",\n apiKeySet: \"已配置密钥。\",\n apiKeyUnset: \"未配置密钥;配置前知识库工具不可用。\",\n apiKeyGet: \"去获取\",\n workspaceId: \"工作空间 ID\",\n workspaceIdHint:\n \"百炼工作空间 ID,即终端节点地址的子域名。存入设置文档;清空并保存则回退到凭据存储。\",\n workspaceIdHintFallback: \"百炼工作空间 ID,即终端节点地址的子域名。留空表示保持当前值。\",\n workspaceIdSet: \"已配置工作空间。\",\n workspaceIdUnset: \"未配置工作空间;配置前知识库工具不可用。\",\n workspaceIdGet: \"去获取\",\n retrieveAgentId: \"默认检索服务\",\n retrieveAgentIdHint: \"kb_search 缺省使用的 agent_id。不设置时,注入的清单会列出全部已部署服务。\",\n chatAgentId: \"默认对话服务\",\n chatAgentIdHint: \"kb_chat 缺省使用的 agent_id。不设置时,注入的清单会列出全部已部署服务。\",\n fromEnv: \"来自环境变量(此处只读)\",\n clear: \"清除默认\",\n clearing: \"清除中…\",\n save: \"保存\",\n saving: \"保存中…\",\n discard: \"放弃\",\n unsaved: \"未保存\",\n saveFailed: \"宿主未接受这些值,已保留供你修改。\",\n advancedConfig: \"高级配置\",\n autofill: \"自动获取\",\n autofilling: \"启动中…\",\n autofillHint: \"登录百炼控制台,自动填入该账号的 API 密钥与工作空间 ID。\",\n autofillDone: \"已回填凭据,下方字段已更新。\",\n autofillAwaitingLogin: \"等待在宿主机浏览器中完成百炼控制台登录…\",\n autofillOpenUrl: \"手动打开登录页\",\n autofillFailed: \"自动获取失败——凭据可能被环境变量锁定、宿主拒绝了写入,或登录未完成。\",\n autofillConfigured: \"已配置完成,点击按钮重新获取该账号的 API 密钥与工作空间 ID。\",\n cacheTitle: \"检索服务缓存\",\n cacheHint: \"注入到每次对话的服务清单。会自动刷新;刚建完服务想立即生效时在这里刷一下。\",\n cacheLoading: \"读取中…\",\n cacheUnconfigured: \"请先设置工作空间 ID。\",\n cacheUnavailable: \"当前浏览器无法访问。\",\n cacheFetchedAt: \"上次拉取\",\n cacheNever: \"尚未拉取\",\n cacheStale: \"待刷新\",\n cacheSearchCount: \"检索服务\",\n cacheChatCount: \"问答服务\",\n cacheTruncated: \"清单已截断 —— 工作空间里的服务多于已拉取的数量。\",\n cacheEmpty: \"缓存里没有已部署的服务。如果刚创建过,请刷新。\",\n cacheRefresh: \"刷新\",\n cacheRefreshing: \"刷新中…\",\n pickerNone: \"未设置 —— 会注入完整清单\",\n pickerClear: \"清空\",\n};\n","/**\n * Bailian knowledge-base plugin, browser half: one section page in the\n * Settings left nav. The workspace, default-retrieval-service and\n * default-chat-service ids ride the Host bridge route\n * (`/bailian-kb/settings`) the Host half registers, bypassing the settings\n * wire (which requires an apiproxy allowlist entry the composition does not\n * grant out-of-tree namespaces); the API key stays pure credentials-domain\n * and never echoes.\n */\n\nimport type { ConnectionHandle } from \"@deepseek-ai/dsh-client-connection/client\";\n// Type-only: the locale plugin's Context merge (ctx.locale).\nimport type {} from \"@deepseek-ai/dsh-client-locale/client\";\nimport type { ClientContext } from \"@deepseek-ai/dsh-client-runtime/client\";\n// Type-only: the remote service's Context merge (ctx.remote) and the forwarded\n// credential-update events.\nimport type {} from \"@deepseek-ai/dsh-api-remotes/client\";\nimport type {} from \"@deepseek-ai/dsh-client-ui-slots\";\n// The 'settings.section' SlotMap merge AND the ctx.settingsScope service,\n// both declared by the settings domain base (type-only: the service arrives\n// through cordis, never a value import).\nimport type {} from \"@deepseek-ai/dsh-client-ui-settings/client\";\nimport { BailianCard } from \"./BailianCard.tsx\";\nimport { BailianCardController } from \"./bailian-card-controller.ts\";\nimport { en, zh, type BailianKbLocaleKey } from \"./locales.ts\";\ndeclare module \"@deepseek-ai/dsh-client-ui-slots\" {\n interface LocaleNamespaceMap {\n /** The Bailian section page's copy. */\n \"tool-bailian-kb\": BailianKbLocaleKey;\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nconst NS = \"tool-bailian-kb\";\n\n/** Required services (cordis fiber inject). */\nexport const inject = [\"slots\", \"locale\", \"connection\", \"remote\"];\n\n/**\n * Mount the Bailian section page into the Settings left nav.\n * @param ctx - the browser plugin context.\n */\nexport function apply(ctx: ClientContext): void {\n const { api } = ctx.get(\"connection\") as ConnectionHandle;\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), \"tool-bailian-kb: dictionaries\");\n\n // Registration-time text: the nav label is a thunk the shell resolves per\n // render, so copy freshness rides the locale revision without re-registering.\n const t = ctx.locale.bind(NS);\n\n // The echo transport: the Host bridge route (`/bailian-kb/settings`) lets\n // the page read and write the resolved section without riding the settings\n // wire (which requires an apiproxy allowlist entry).\n const card = new BailianCardController(api);\n // Values can change elsewhere (Models page, external file edits); the badges\n // must follow the Host, not the card's last write.\n ctx.effect(\n () =>\n ctx.remote.$on(\"credentials/updated\", (ref) => {\n card.refresh(ref);\n }),\n \"tool-bailian-kb: credential invalidations\",\n );\n\n ctx.slots.inject(\"settings.section\", () =>\n ctx.slots.register(\n {\n name: \"settings.section\",\n id: \"bailian-kb\",\n order: 20,\n label: () => t(\"nav\"),\n locale: NS,\n inject: () => card.inject(),\n },\n BailianCard,\n ),\n );\n}\n"],"mappings":";;;;;;;;;;;EAkBA,MAAa,oBAAoB;GAC/B;GACA;GACA;GACA;EACF;;EASA,MAAa,kBAA0E;GACrF,sBAAsB;GACtB,mCAAmC;GACnC,+BAA+B;EACjC;;EAmHA,SAAgB,YAAY,OAAyB,KAA8B;GACjF,MAAM,QAAQ,gBAAgB;GAC9B,IAAI,UAAU,KAAA,KAAa,MAAM,SAAS,WAAW,SAAS,OAAO;GACrE,OAAO,MAAM,SAAS,OAAO,UAAU;EACzC;;EAGA,SAAS,OAAO,OAAyB,KAA+B;GACtE,MAAM,QAAQ,MAAM,OAAO;GAC3B,IAAI,UAAU,KAAA,GAAW,OAAO;GAEhC,IADc,gBAAgB,SAChB,KAAA,KAAa,MAAM,SAAS,WAAW,SACnD,OAAO,UAAU,YAAY,OAAO,GAAG;GAGzC,OAAO,UAAU;EACnB;;EAGA,SAAgB,QAAQ,OAAkC;GACxD,OAAO,kBAAkB,MAAM,QAAQ,OAAO,OAAO,GAAG,CAAC;EAC3D;;EAGA,IAAa,wBAAb,MAAmC;GAMJ;GAL7B;;;;GAKA,YAAY,KAAuD;IAAtC,KAAA,MAAA;IAC3B,KAAK,SAAA,GAAQA,uCAAAA,oBAAAA,CAAsC;KACjD,QAAQ;MACN,mBAAmB,KAAA;MACnB,sBAAsB,KAAA;MACtB,mCAAmC,KAAA;MACnC,+BAA+B,KAAA;KACjC;KACA,aAAa;MACX,mBAAmB;OAAE,YAAY;OAAO,UAAU;MAAK;MACvD,sBAAsB;OAAE,YAAY;OAAO,UAAU;MAAK;MAC1D,mCAAmC;OAAE,YAAY;OAAO,UAAU;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kb-dsh",
|
|
3
|
+
"version": "0.1.18",
|
|
4
|
+
"description": "Bailian knowledge-base tools for DeepSeek Harness: kb_search and kb_chat over the DashScope RAG API, plus the bl CLI management skill.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"alibaba-cloud",
|
|
7
|
+
"aliyun",
|
|
8
|
+
"bailian",
|
|
9
|
+
"dashscope",
|
|
10
|
+
"deepseek-harness",
|
|
11
|
+
"dsh",
|
|
12
|
+
"knowledge-base",
|
|
13
|
+
"rag"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/modelstudioai/cli/tree/main/packages/bailian-kb-dsh",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/modelstudioai/cli/issues"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"author": "Aliyun Model Studio",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/modelstudioai/cli.git",
|
|
24
|
+
"directory": "packages/bailian-kb-dsh"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"skills",
|
|
29
|
+
"cordis.patch.yml"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "dist/index.js",
|
|
33
|
+
"types": "dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./client": {
|
|
40
|
+
"default": "./dist/web/client.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -b tsconfig.build.json && tsc -p tsconfig.web.json && tsdown",
|
|
50
|
+
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.web.json",
|
|
51
|
+
"test": "vp test",
|
|
52
|
+
"check": "vp check"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"yaml": "catalog:"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
59
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
60
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.6",
|
|
61
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.0-rc.6",
|
|
62
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
|
|
63
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.6",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
|
|
66
|
+
"@deepseek-ai/dsh-credentials": "^0.1.0-rc.6",
|
|
67
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
|
|
68
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.6",
|
|
69
|
+
"@deepseek-ai/dsh-settings": "^0.1.0-rc.6",
|
|
70
|
+
"@deepseek-ai/dsh-skill": "^0.1.0-rc.6",
|
|
71
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
|
|
72
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
73
|
+
"@types/node": "catalog:",
|
|
74
|
+
"@types/react": "~18.3.1",
|
|
75
|
+
"lightningcss": "^1.32.0",
|
|
76
|
+
"react": "^18.2.0",
|
|
77
|
+
"tsdown": "^0.22.2",
|
|
78
|
+
"typescript": "catalog:",
|
|
79
|
+
"vite-plus": "catalog:",
|
|
80
|
+
"yaml": "catalog:"
|
|
81
|
+
},
|
|
82
|
+
"peerDependencies": {
|
|
83
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
84
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
85
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.6",
|
|
86
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.0-rc.6",
|
|
87
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
|
|
88
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
|
|
89
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.6",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
|
|
91
|
+
"@deepseek-ai/dsh-credentials": "^0.1.0-rc.6",
|
|
92
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
|
|
93
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.6",
|
|
94
|
+
"@deepseek-ai/dsh-settings": "^0.1.0-rc.6",
|
|
95
|
+
"@deepseek-ai/dsh-skill": "^0.1.0-rc.6",
|
|
96
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
|
|
97
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
98
|
+
"react": "^18.2.0"
|
|
99
|
+
},
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=22.12.0"
|
|
102
|
+
},
|
|
103
|
+
"dsh": {
|
|
104
|
+
"bundle": {
|
|
105
|
+
"patch": "./cordis.patch.yml"
|
|
106
|
+
},
|
|
107
|
+
"client": {
|
|
108
|
+
"inject": [
|
|
109
|
+
"@deepseek-ai/dsh-client-connection",
|
|
110
|
+
"@deepseek-ai/dsh-client-locale",
|
|
111
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
112
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
113
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
114
|
+
],
|
|
115
|
+
"platform": "web"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bailian-kb
|
|
3
|
+
description: >-
|
|
4
|
+
管理阿里云百炼知识库(建库、上传文档、部署检索服务、Chunk 运维、数据中心文件管理),命令行工具为 bl(bailian-cli)。
|
|
5
|
+
当用户要创建/更新/删除知识库、上传或导入文档(本地/OSS)、创建/部署/调参检索或问答服务、
|
|
6
|
+
增删改查 Chunk、管理数据中心类目/文件/集合时使用本 skill。
|
|
7
|
+
检索与问答不走本 skill——用原生工具 kb_search(取证据)/ kb_chat(成品问答);
|
|
8
|
+
bl knowledge search / chat 仅用于部署后的验证调试(如 --agent-version beta 调试草稿版)。
|
|
9
|
+
kb_search / kb_chat 的凭据与工作空间由插件自动解析(~/.dsh/settings.yaml 的 bailian-kb 段、
|
|
10
|
+
~/.dsh/.credentials.yaml 的 DASHSCOPE_API_KEY),不要自己去读或传。
|
|
11
|
+
普通问答、编程、写作、翻译、泛搜索不触发本 skill。
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# 百炼知识库管理(bl)
|
|
15
|
+
|
|
16
|
+
检索面与管理面的分工:**查知识用 `kb_search`(取证据)/ `kb_chat`(成品问答)原生工具;本 skill 只覆盖管理长尾**——知识库全生命周期、文档、检索服务、Chunk、数据中心。
|
|
17
|
+
|
|
18
|
+
本 skill **不负责**判断何时该检索。可用检索服务的清单(含 agent_id)由插件自动注入到会话上下文里,`kb_search` / `kb_chat` 直接取用;不需要为了检索先加载本 skill。
|
|
19
|
+
|
|
20
|
+
## 检索服务清单的行为语义
|
|
21
|
+
|
|
22
|
+
- 清单由插件从百炼 API 拉取后缓存,按会话周期性刷新(约 30 分钟),只含 **deployed** 状态的服务;
|
|
23
|
+
- **刚用 `bl` 新建或部署的服务不会立刻出现在清单里**。不用等刷新——命令输出里刚拿到的 `agent_id` 直接可用;
|
|
24
|
+
- 服务很多时清单只列最近修改的若干条并标明总数。要找特定服务用 `bl knowledge service list --scene search --name <关键词>`;
|
|
25
|
+
- 清单里确实没有能回答用户问题的服务时,如实告知用户,**不要挑一个最像的 agent_id 去试**。
|
|
26
|
+
|
|
27
|
+
## 前置检查
|
|
28
|
+
|
|
29
|
+
1. 安装校验:运行 `bl knowledge list --help`。若报 `Unknown command` 或 bl 未安装,执行
|
|
30
|
+
`npm install -g bailian-cli`(需 Node.js ≥ 18.17);已安装但命令缺失时先 `bl update` 升级。
|
|
31
|
+
安装失败时把错误原样报告给用户,不要静默跳过。
|
|
32
|
+
2. 鉴权:需要 `DASHSCOPE_API_KEY`(环境变量,或 `bl auth login --api-key sk-xxx`,或 `bl config set --key api_key --value sk-xxx`)。
|
|
33
|
+
3. workspace 解析优先级:`--workspace-id` 参数 > 环境变量 `BAILIAN_WORKSPACE_ID` > `bl config set --key workspace_id --value ws-xxx`。
|
|
34
|
+
|
|
35
|
+
## 何时用哪个命令
|
|
36
|
+
|
|
37
|
+
| 用户意图 | 命令 | 备注 |
|
|
38
|
+
| ---------------------------------------- | --------------------------------------------------- | -------------------------------- |
|
|
39
|
+
| 查知识 / 问答(日常检索) | 原生工具 `kb_search` / `kb_chat` | 不走 bl |
|
|
40
|
+
| 建库 / 查看 / 改名 / 删库 / 监控 | `bl knowledge create/list/info/update/delete/stats` | `bl knowledge create --help` |
|
|
41
|
+
| 上传本地文档、看解析状态、删文档、打标签 | `bl knowledge doc upload/list/status/delete/tag` | `bl knowledge doc upload --help` |
|
|
42
|
+
| 从 OSS 批量导入 | `bl knowledge doc import-oss` | Bucket 需预先授权服务角色 |
|
|
43
|
+
| 创建 / 部署 / 调参检索(问答)服务 | `bl knowledge service create/update/deploy/…` | `bl knowledge service --help` |
|
|
44
|
+
| 修正错误切片、屏蔽某段内容 | `bl knowledge chunk add/list/update/delete` | `bl knowledge chunk --help` |
|
|
45
|
+
| 数据中心类目 / 文件 / 集合管理 | `bl knowledge category/file/collection …` | `bl knowledge category --help` |
|
|
46
|
+
| CLI 配置、升级 | `bl config show/set`、`bl update` | `bl config --help` |
|
|
47
|
+
| 部署后验证、调试草稿版服务 | `bl knowledge search/chat --agent-version beta` | `bl knowledge search --help` |
|
|
48
|
+
|
|
49
|
+
## 核心工作流:建库到可检索
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bl knowledge doc upload --file ./docs/ --workspace-id ws-xxx # 1. 上传本地文件/目录 → 得 fileId
|
|
53
|
+
bl knowledge create --name my-kb --description '产品文档' --doc-id <fileId> --wait # 2. 建库并导入 → 得 index-id (pipelineId)
|
|
54
|
+
bl knowledge service create --name my-search --scene search --index-id <index-id> # 3. 建检索服务 → 得 agent-id(draft)
|
|
55
|
+
bl knowledge service deploy --agent-id <agent-id> --yes # 4. 发布服务(此后可被默认版本调用)
|
|
56
|
+
bl knowledge service list --scene search --status deployed # 5. 确认服务可见
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
部署完成后用原生工具 `kb_search` 带该 `agent_id` 验证检索;若要在部署前调试草稿配置,用 `bl knowledge search --agent-id <id> --agent-version beta`。
|
|
60
|
+
|
|
61
|
+
已有文件再入库的简写:`bl knowledge doc upload --file ./a.md --index-id <index-id> --wait`(上传+导入一步完成)。
|
|
62
|
+
|
|
63
|
+
## ID 速查(极易混淆)
|
|
64
|
+
|
|
65
|
+
| ID | 来源 | 用在哪 |
|
|
66
|
+
| ----------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
67
|
+
| `index-id` | `knowledge create` 返回的 pipelineId / `knowledge list` | 所有 knowledge/doc/chunk 命令的 `--index-id` |
|
|
68
|
+
| `fileId` | `doc upload` / `doc import-oss` 返回 | 数据中心命令(`file get/delete`、`knowledge create --doc-id`、`doc tag`) |
|
|
69
|
+
| `doc_id`(库内文档 ID) | `doc list` 输出 | `doc delete`、`chunk add/update` 的 `--doc-id`;**可能带 workspace 后缀,≠ fileId** |
|
|
70
|
+
| `job-id` | 导入命令返回的 ingestionId | `doc status`(必须同时给 `--index-id` 和 `--job-id`) |
|
|
71
|
+
| chunk id | `chunk list` 输出的 `metadata._id` | `chunk update/delete` 的 `--chunk-id` |
|
|
72
|
+
| `agent-id` | `service create/list` | `service *`、`kb_search`/`kb_chat`、`bl knowledge search/chat` |
|
|
73
|
+
|
|
74
|
+
## 命令参考
|
|
75
|
+
|
|
76
|
+
执行不熟悉的命令前,跑 `bl <命令> --help` 查看完整 Usage / Flags / Notes / Examples。**不要猜 flag。**
|
|
77
|
+
全部命令支持 `--output json`(结构化输出)、`--dry-run`(预览请求)、`--quiet`、`--verbose`。
|
|
78
|
+
|
|
79
|
+
## 危险与不可逆操作
|
|
80
|
+
|
|
81
|
+
执行以下操作前须向用户确认,脚本化时才用 `--yes` 跳过交互确认:
|
|
82
|
+
|
|
83
|
+
- `knowledge delete`:不可逆,库和全部索引内容永久删除(数据中心源文件保留)。
|
|
84
|
+
- `file delete`:不可逆,且引用该文件的知识库文档索引会失效;只想从单个库移除用 `doc delete`。
|
|
85
|
+
- `chunk delete`:不可逆。
|
|
86
|
+
- `service deploy`:发布影响线上调用方;`service delete` 后 agent_id 不可再用(软删、幂等)。
|
|
87
|
+
- `collection create`:**没有删除 API**,创建集合要慎重。
|
|
88
|
+
- 索引配置(embedding 模型、chunk size 等)建库后不可改,只能重建。
|
|
89
|
+
|
|
90
|
+
## 最佳实践
|
|
91
|
+
|
|
92
|
+
- **建服务时必须把名字写清楚**:`service create --name` 的名称是模型判断"这个服务能查什么"的主要依据(服务描述暂未随列表接口返回)。`检索服务1` 这类无语义的名字会让后续检索无法路由;写成 `产品文档检索`、`HR制度问答` 这种能看出覆盖内容的名字。同时填 `--description`(≤1000 字符),列表接口返回该字段后即可自动生效。
|
|
93
|
+
- 服务有 draft/deployed 两种状态:只有 deployed 可被默认版本调用,也只有 deployed 会进入模型看到的服务清单;draft 调试用 `--agent-version beta`。改已发布版本的配置:先改 beta 草稿(`service update`),验证后 `service deploy` 发新版本。
|
|
94
|
+
- 导入类命令(`knowledge create`、`doc upload --index-id`、`doc status`)优先带 `--wait` 轮询到终态,避免手工轮询;文档解析失败(如 PARSE_FAILED)会以非零退出码透传错误。
|
|
95
|
+
- `chunk add` 有 10 QPS 限流,批量脚本注意节流;响应不带 chunk id,需要 `chunk list` 反查。
|
|
96
|
+
- `service list` 必须带 `--scene chat|search`,两个场景要分别查询。
|