feat: plugin package skeleton with validated Config

This commit is contained in:
zeyu.fz
2026-08-15 18:28:48 +08:00
parent 3aedb7b7fb
commit fba98bf65e
5 changed files with 1136 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
{
"name": "dsh-tool-bailian-kb",
"version": "0.1.0",
"description": "Bailian knowledge-base tools for DeepSeek Harness: kb_service_list, kb_search, kb_chat over the DashScope RAG API, plus the kscli management skill.",
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
"./package.json": "./package.json"
},
"files": ["lib", "skills"],
"scripts": { "build": "tsc -b" },
"peerDependencies": {
"@deepseek-ai/cordis": "^4.0.1",
"@deepseek-ai/dsh-tools": "*",
"@deepseek-ai/dsh-credentials": "*",
"@deepseek-ai/dsh-skill": "*",
"@deepseek-ai/schemastery": "^3.18.1"
},
"devDependencies": {
"@deepseek-ai/cordis": "link:../../../deepseek-harness/vendor/cordis",
"@deepseek-ai/dsh-tools": "link:../../../deepseek-harness/packages/core/tools",
"@deepseek-ai/dsh-credentials": "link:../../../deepseek-harness/packages/credentials/credentials",
"@deepseek-ai/dsh-skill": "link:../../../deepseek-harness/packages/skill/skill",
"@deepseek-ai/schemastery": "link:../../../deepseek-harness/vendor/schemastery",
"@types/node": "^22.0.0"
}
}
+33
View File
@@ -0,0 +1,33 @@
/**
* Bailian knowledge-base consumer plugin: registers kb_service_list, kb_search,
* and kb_chat over the DashScope RAG API, plus the kscli management skill.
* @module dsh-tool-bailian-kb
*/
import z from '@deepseek-ai/schemastery'
export const name = 'tool-bailian-kb'
export const inject = ['tools', 'credentials']
/** Bailian knowledge-base plugin configuration. */
export interface Config {
/** Bailian workspace id; the API host is the workspace subdomain `https://<workspaceId>.<endpointHost>`. */
workspaceId: string
/** API host suffix; replace for other regions or private deployments. */
endpointHost: string
/** Retrieval-service id pinned by this deployment; when set, the tools' agent_id parameter becomes optional. */
defaultAgentId?: string
/** Service version to call: `beta` (draft) or a published number; defaults to the latest published version. Never model-visible. */
agentVersion?: string
/** kb_chat timeout in milliseconds; the server side is a minutes-scale agentic loop. */
chatTimeoutMs: number
}
/** Schemastery validation for {@link Config}; a missing workspaceId fails at load. */
export const Config: z<Config> = z.object({
workspaceId: z.string().required(),
endpointHost: z.string().default('cn-beijing.maas.aliyuncs.com'),
defaultAgentId: z.string(),
agentVersion: z.string(),
chatTimeoutMs: z.number().default(300_000),
})
@@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest'
import { Config } from '../src/index.js'
describe('Config', () => {
it('applies defaults and keeps required workspaceId', () => {
const resolved = new Config({ workspaceId: 'ws-1' })
expect(resolved.workspaceId).toBe('ws-1')
expect(resolved.endpointHost).toBe('cn-beijing.maas.aliyuncs.com')
expect(resolved.chatTimeoutMs).toBe(300_000)
expect(resolved.defaultAgentId).toBeUndefined()
})
it('rejects a missing workspaceId (fail loud at load)', () => {
expect(() => new Config({} as never)).toThrow()
})
})
+5
View File
@@ -0,0 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": { "rootDir": "src", "outDir": "lib" },
"include": ["src"]
}
+1053
View File
File diff suppressed because it is too large Load Diff