@getnote/dsh-plugin 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -75
- package/lib/index.js +851 -208
- package/lib/index.js.map +1 -1
- package/lib/types/api.d.ts +103 -0
- package/lib/types/api.d.ts.map +1 -0
- package/lib/types/index.d.ts +23 -5
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/getnote-dsh/SKILL.md +41 -16
- package/lib/types/cli-runner.d.ts +0 -16
- package/lib/types/cli-runner.d.ts.map +0 -1
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cli-runner.ts","../src/index.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { accessSync, constants } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { delimiter, dirname, join } from 'node:path'\n\nconst require = createRequire(import.meta.url)\n\nexport interface RunGetnoteOptions {\n binaryPath?: string\n apiUrl?: string\n signal?: AbortSignal\n timeoutMs?: number\n maxOutputBytes?: number\n}\n\nexport class GetnoteCliError extends Error {\n constructor(\n message: string,\n readonly exitCode: number | null,\n readonly stderr: string,\n ) {\n super(message)\n this.name = 'GetnoteCliError'\n }\n}\n\nexport function resolveGetnoteBinary(): string {\n const packageJson = require.resolve('@getnote/cli/package.json')\n const binary = process.platform === 'win32' ? 'getnote.exe' : 'getnote'\n return join(dirname(packageJson), 'bin', binary)\n}\n\ninterface GetnoteInvocation {\n command: string\n prefixArgs: string[]\n}\n\nexport function resolveGetnoteFromPath(\n pathValue = process.env.PATH ?? '',\n pathExtValue = process.env.PATHEXT ?? '.EXE;.CMD;.BAT;.COM',\n): string | undefined {\n const extensions = process.platform === 'win32'\n ? pathExtValue.split(';').filter(Boolean)\n : ['']\n\n for (const directory of pathValue.split(delimiter).filter(Boolean)) {\n for (const extension of extensions) {\n const candidate = join(directory, `getnote${extension.toLowerCase()}`)\n try {\n accessSync(candidate, constants.X_OK)\n return candidate\n } catch {\n // Continue searching the remaining PATH entries.\n }\n }\n }\n}\n\nfunction resolveGetnoteInvocation(binaryPath?: string): GetnoteInvocation {\n if (binaryPath) return { command: binaryPath, prefixArgs: [] }\n\n const pathBinary = resolveGetnoteFromPath()\n if (pathBinary) return { command: pathBinary, prefixArgs: [] }\n\n try {\n return { command: resolveGetnoteBinary(), prefixArgs: [] }\n } catch {\n return {\n command: process.platform === 'win32' ? 'npx.cmd' : 'npx',\n prefixArgs: ['--yes', '--package', '@getnote/cli@1.5.3', '--', 'getnote'],\n }\n }\n}\n\nexport async function runGetnote(\n args: readonly string[],\n options: RunGetnoteOptions = {},\n): Promise<unknown> {\n const invocation = resolveGetnoteInvocation(options.binaryPath)\n const timeoutMs = options.timeoutMs ?? 120_000\n const maxOutputBytes = options.maxOutputBytes ?? 10 * 1024 * 1024\n const commandArgs = [...invocation.prefixArgs, ...args, '--output', 'json']\n\n return await new Promise((resolve, reject) => {\n const child = spawn(invocation.command, commandArgs, {\n env: {\n ...process.env,\n ...(options.apiUrl ? { GETNOTE_API_URL: options.apiUrl } : {}),\n },\n stdio: ['ignore', 'pipe', 'pipe'],\n windowsHide: true,\n signal: options.signal,\n })\n\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let outputBytes = 0\n let settled = false\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const finish = (callback: () => void) => {\n if (settled) return\n settled = true\n if (timer !== undefined) clearTimeout(timer)\n callback()\n }\n\n const capture = (target: Buffer[], chunk: Buffer) => {\n outputBytes += chunk.length\n if (outputBytes > maxOutputBytes) {\n child.kill('SIGTERM')\n finish(() => reject(new GetnoteCliError(\n `getnote output exceeded ${maxOutputBytes} bytes`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n return\n }\n target.push(chunk)\n }\n\n child.stdout.on('data', (chunk: Buffer) => capture(stdout, chunk))\n child.stderr.on('data', (chunk: Buffer) => capture(stderr, chunk))\n\n timer = setTimeout(() => {\n child.kill('SIGTERM')\n finish(() => reject(new GetnoteCliError(\n `getnote command timed out after ${timeoutMs} ms`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n }, timeoutMs)\n\n child.on('error', (error) => {\n finish(() => reject(new GetnoteCliError(\n `failed to start getnote: ${error.message}`,\n null,\n Buffer.concat(stderr).toString('utf8'),\n )))\n })\n\n child.on('close', (code) => {\n finish(() => {\n const stdoutText = Buffer.concat(stdout).toString('utf8').trim()\n const stderrText = Buffer.concat(stderr).toString('utf8').trim()\n if (code !== 0) {\n reject(new GetnoteCliError(\n stderrText || stdoutText || `getnote exited with code ${String(code)}`,\n code,\n stderrText,\n ))\n return\n }\n\n if (!stdoutText) {\n resolve(null)\n return\n }\n\n try {\n resolve(JSON.parse(stdoutText))\n } catch {\n // A few informational CLI commands (notably auth status in CLI 1.5)\n // still return plain text even when --output json is requested.\n resolve(stdoutText)\n }\n })\n })\n })\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { apply as applySkillFilesystem } from '@deepseek-ai/dsh-skill-filesystem'\nimport { defineTool } from '@deepseek-ai/dsh-tools'\nimport Schema from '@deepseek-ai/schemastery'\nimport { fileURLToPath } from 'node:url'\nimport { runGetnote, type RunGetnoteOptions } from './cli-runner.js'\n\nexport const name = 'getnote-tools'\nexport const inject = ['tools', 'skills']\n\nexport interface Config {\n binaryPath?: string\n apiUrl?: string\n timeoutMs: number\n maxOutputBytes: number\n}\n\nexport const Config: Schema<Config> = Schema.object({\n binaryPath: Schema.string().description('Optional absolute path to the getnote executable.'),\n apiUrl: Schema.string().description('Optional GetNote OpenAPI base URL for explicit integration testing.'),\n timeoutMs: Schema.number().min(1_000).default(120_000),\n maxOutputBytes: Schema.number().min(1_024).default(10 * 1024 * 1024),\n})\n\nfunction renderJson(value: unknown): string {\n if (typeof value === 'string') return value\n return JSON.stringify(value, null, 2)\n}\n\nfunction runnerOptions(config: Config, signal?: AbortSignal): RunGetnoteOptions {\n return {\n binaryPath: config.binaryPath,\n apiUrl: config.apiUrl,\n timeoutMs: config.timeoutMs,\n maxOutputBytes: config.maxOutputBytes,\n signal,\n }\n}\n\nfunction textOutput() {\n return {\n schema: { type: 'string' as const },\n render: (_args: unknown, value: string) => [{ type: 'text' as const, text: value }],\n }\n}\n\nfunction integerInRange(value: number | undefined, fallback: number, min: number, max: number): number {\n const resolved = value ?? fallback\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new RangeError(`value must be an integer between ${min} and ${max}`)\n }\n return resolved\n}\n\nexport function apply(ctx: Context, config: Config) {\n applySkillFilesystem(ctx, {\n providerName: 'getnote',\n includeDefaultRoots: false,\n bundledSkillDir: fileURLToPath(new URL('../skills', import.meta.url)),\n })\n\n ctx.tools.register(defineTool({\n name: 'getnote_auth_status',\n description: 'Check whether the current user is authenticated with GetNote (得到大脑).',\n parameters: {},\n output: textOutput(),\n async execute(_args, exec) {\n await runGetnote(['auth', 'status'], runnerOptions(config, exec.signal))\n return 'Authenticated with GetNote.'\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_search',\n description: 'Semantically search notes in GetNote, optionally within one knowledge base.',\n parameters: {\n query: { type: 'string', required: true, description: 'Natural-language search query.' },\n knowledge_base_id: { type: 'string', description: 'Optional knowledge base/topic ID.' },\n limit: { type: 'integer', default: 10, description: 'Maximum results, from 1 to 10.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const limit = integerInRange(args.limit, 10, 1, 10)\n const cliArgs = ['search', args.query, '--limit', String(limit)]\n if (args.knowledge_base_id) cliArgs.push('--kb', args.knowledge_base_id)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_save',\n description: 'Save text, a URL, or a local image path as a note in GetNote.',\n parameters: {\n content: { type: 'string', required: true, description: 'Text, URL, or local image path to save.' },\n title: { type: 'string', description: 'Optional note title.' },\n tags: { type: 'array', items: { type: 'string' }, description: 'Optional note tags.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const cliArgs = ['save', args.content]\n if (args.title) cliArgs.push('--title', args.title)\n for (const tag of args.tags ?? []) cliArgs.push('--tag', tag)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_list_notes',\n description: 'List recent notes from GetNote.',\n parameters: {\n limit: { type: 'integer', default: 20, description: 'Number of notes, from 1 to 100.' },\n since_id: { type: 'string', description: 'Optional pagination cursor note ID.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n const limit = integerInRange(args.limit, 20, 1, 100)\n const cliArgs = ['notes', '--limit', String(limit)]\n if (args.since_id) cliArgs.push('--since-id', args.since_id)\n return renderJson(await runGetnote(cliArgs, runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_get_note',\n description: 'Get the complete details of one GetNote note by its string ID.',\n parameters: {\n note_id: { type: 'string', required: true, description: 'Note ID. Keep it as a string.' },\n },\n output: textOutput(),\n async execute(args, exec) {\n return renderJson(await runGetnote(['note', args.note_id], runnerOptions(config, exec.signal)))\n },\n }))\n\n ctx.tools.register(defineTool({\n name: 'getnote_list_knowledge_bases',\n description: 'List the current user\\'s GetNote knowledge bases.',\n parameters: {},\n output: textOutput(),\n async execute(_args, exec) {\n return renderJson(await runGetnote(['kbs'], runnerOptions(config, exec.signal)))\n },\n }))\n}\n\nexport {\n GetnoteCliError,\n resolveGetnoteBinary,\n resolveGetnoteFromPath,\n runGetnote,\n} from './cli-runner.js'\n"],"mappings":";;;;;;;;;AAKA,MAAM,UAAU,cAAc,YAAY,GAAG;AAU7C,IAAa,kBAAb,cAAqC,MAAM;CAG9B;CACA;CAHX,YACE,SACA,UACA,QACA;EACA,MAAM,OAAO;EAHJ,KAAA,WAAA;EACA,KAAA,SAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,uBAA+B;CAC7C,MAAM,cAAc,QAAQ,QAAQ,2BAA2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W,MAAM,WAAW,CAAC,KAAK,GAAG,cAAc,QAAQ,KAAK,MAAM,CAAC,CAAC;EACjF;CACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/api.ts","../src/index.ts"],"sourcesContent":["import { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { dirname, join } from 'node:path'\n\n/** OpenAPI client ID used by this plugin for authorization. */\nexport const DSH_CLIENT_ID = 'cli_35ca47aab229ebb0c4c4dd12'\nexport const DEFAULT_API_URL = 'https://openapi.biji.com'\n\nexport interface Credential {\n apiKey: string\n clientId: string\n expiresAt?: number\n}\n\nexport const MEMBERSHIP_URL = 'https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_dsh'\n\nexport class GetnoteApiError extends Error {\n constructor(\n message: string,\n readonly code?: string | number,\n readonly status?: number,\n ) {\n super(message)\n this.name = 'GetnoteApiError'\n }\n}\n\nexport class NotLoggedInError extends GetnoteApiError {\n constructor() {\n super('Not logged in to GetNote. Call getnote_login and ask the user to open the returned link.', 'not_logged_in')\n this.name = 'NotLoggedInError'\n }\n}\n\nexport function defaultCredentialPath(env: NodeJS.ProcessEnv = process.env): string {\n const dshHome = env.DSH_HOME || join(homedir(), '.dsh')\n return join(dshHome, 'getnote', 'credentials.json')\n}\n\n/** Normalize a base URL to the `/open/api/v1` prefix, accepting the same forms as the CLI. */\nexport function apiBase(url: string): string {\n let base = url.replace(/\\/+$/, '')\n if (base.endsWith('/open/api/v1')) return base\n if (base.endsWith('/open')) return `${base}/api/v1`\n return `${base}/open/api/v1`\n}\n\n/** Credential file stored with 0600 permissions. The key never reaches the model. */\nexport class CredentialStore {\n constructor(readonly path: string) {}\n\n async load(): Promise<Credential | undefined> {\n try {\n const data = JSON.parse(await readFile(this.path, 'utf8')) as Partial<Credential>\n if (typeof data.apiKey !== 'string' || !data.apiKey || typeof data.clientId !== 'string' || !data.clientId) return undefined\n return { apiKey: data.apiKey, clientId: data.clientId, expiresAt: data.expiresAt }\n } catch {\n return undefined\n }\n }\n\n async save(credential: Credential): Promise<void> {\n await mkdir(dirname(this.path), { recursive: true, mode: 0o700 })\n const tmp = `${this.path}.${process.pid}.tmp`\n await writeFile(tmp, JSON.stringify(credential, null, 2), { mode: 0o600 })\n await chmod(tmp, 0o600)\n await rename(tmp, this.path)\n }\n\n async clear(): Promise<void> {\n await rm(this.path, { force: true })\n }\n}\n\n/**\n * Parse JSON while keeping integers beyond Number.MAX_SAFE_INTEGER as strings.\n * GetNote IDs are 64-bit; a plain JSON.parse would silently corrupt them.\n */\nexport function parseJson(text: string): unknown {\n let out = ''\n let last = 0\n let inString = false\n for (let i = 0; i < text.length; i++) {\n const ch = text[i]\n if (inString) {\n if (ch === '\\\\') i++\n else if (ch === '\"') inString = false\n continue\n }\n if (ch === '\"') { inString = true; continue }\n if (ch === '-' || (ch >= '0' && ch <= '9')) {\n let j = i + 1\n while (j < text.length && /[0-9.eE+-]/.test(text[j])) j++\n const token = text.slice(i, j)\n if (/^-?\\d+$/.test(token) && !Number.isSafeInteger(Number(token))) {\n out += `${text.slice(last, i)}\"${token}\"`\n last = j\n }\n i = j - 1\n }\n }\n return JSON.parse(last === 0 ? text : out + text.slice(last))\n}\n\nexport interface ApiOptions {\n apiUrl: string\n clientId: string\n store: CredentialStore\n timeoutMs: number\n fetchImpl?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\ntype Query = Record<string, string | number | boolean | undefined | null>\n\ninterface Envelope {\n success?: boolean\n data?: unknown\n error?: {\n code?: string | number\n message?: string\n reason?: string\n retry_after_seconds?: number\n rate_limit_detail?: { retry_after_seconds?: number } | null\n } | null\n // Legacy console-style envelope\n h?: { c?: number, e?: string }\n c?: unknown\n}\n\nexport class GetnoteApi {\n readonly base: string\n private readonly fetchImpl: typeof fetch\n\n constructor(readonly options: ApiOptions) {\n this.base = apiBase(options.apiUrl)\n this.fetchImpl = options.fetchImpl ?? fetch\n }\n\n /** Environment variables override the stored credential (useful for CI and testing). */\n async credential(): Promise<Credential | undefined> {\n const env = this.options.env ?? process.env\n if (env.GETNOTE_API_KEY) {\n return { apiKey: env.GETNOTE_API_KEY, clientId: env.GETNOTE_CLIENT_ID || this.options.clientId }\n }\n return await this.options.store.load()\n }\n\n async get(path: string, query: Query = {}, signal?: AbortSignal): Promise<unknown> {\n const qs = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null || value === '') continue\n qs.set(key, String(value))\n }\n const suffix = qs.size > 0 ? `?${qs.toString()}` : ''\n return await this.request('GET', `${path}${suffix}`, undefined, signal)\n }\n\n async post(path: string, body: unknown, signal?: AbortSignal): Promise<unknown> {\n return await this.request('POST', path, body, signal)\n }\n\n /** Unauthenticated OAuth call (device code / token). Returns the raw parsed body. */\n async oauth(path: string, body: unknown, signal?: AbortSignal): Promise<{ status: number, body: Envelope | string }> {\n const response = await this.fetchImpl(`${this.base}${path}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal: this.signal(signal),\n })\n const text = await response.text()\n try {\n return { status: response.status, body: parseJson(text) as Envelope }\n } catch {\n return { status: response.status, body: text }\n }\n }\n\n private signal(signal?: AbortSignal): AbortSignal {\n const timeout = AbortSignal.timeout(this.options.timeoutMs)\n return signal ? AbortSignal.any([signal, timeout]) : timeout\n }\n\n private async request(method: string, path: string, body: unknown, signal?: AbortSignal): Promise<unknown> {\n const credential = await this.credential()\n if (!credential) throw new NotLoggedInError()\n\n const response = await this.fetchImpl(`${this.base}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${credential.apiKey}`,\n 'X-Client-ID': credential.clientId,\n 'Content-Type': 'application/json',\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n signal: this.signal(signal),\n })\n const text = await response.text()\n let parsed: Envelope\n try {\n parsed = parseJson(text) as Envelope\n } catch {\n throw new GetnoteApiError(`GetNote API returned HTTP ${response.status}: ${text.slice(0, 300)}`, undefined, response.status)\n }\n\n if (parsed.success === true) return parsed.data ?? null\n if (parsed.h && parsed.h.c === 0) return parsed.c ?? null\n\n const code = parsed.error?.code ?? parsed.h?.c\n const message = parsed.error?.message ?? parsed.h?.e ?? `GetNote API request failed (HTTP ${response.status})`\n if (response.status === 401 || code === 10004 || code === 'unauthorized') {\n throw new GetnoteApiError(\n `${message}. The GetNote authorization is missing, expired, or revoked; call getnote_login to authorize again.`,\n code,\n response.status,\n )\n }\n throw new GetnoteApiError(describeError(String(message), code, parsed.error ?? undefined, response), code, response.status)\n }\n}\n\n/** Add the guidance the model needs for quota, rate-limit and membership errors. */\nfunction describeError(message: string, code: string | number | undefined, error: Envelope['error'] | undefined, response: Response): string {\n const parts = [message]\n if (error?.reason) parts.push(`(reason: ${error.reason})`)\n if (code === 10201 || error?.reason === 'not_member') {\n parts.push(`This operation needs a GetNote membership: ${MEMBERSHIP_URL}`)\n } else if (response.status === 429 || code === 10202 || code === 10005) {\n const header = Number(response.headers.get('Retry-After'))\n const wait = error?.retry_after_seconds ?? error?.rate_limit_detail?.retry_after_seconds ?? (Number.isFinite(header) && header > 0 ? header : undefined)\n const when = wait !== undefined ? ` Retry after about ${wait} seconds.` : ''\n parts.push(`Rate limit or quota reached.${when} Do not retry repeatedly; call getnote_quota to see the current quota.`)\n }\n return parts.join(' ')\n}\n\nexport interface LoginStart {\n verificationUri: string\n userCode: string\n expiresIn: number\n}\n\n/**\n * RFC 8628-style device authorization against the GetNote OpenAPI. `start()`\n * returns the link immediately; polling continues in the background and stores\n * the credential once the user confirms in the browser.\n */\nexport class DeviceLogin {\n private pending?: { start: LoginStart, done: Promise<void>, controller: AbortController, error?: string }\n lastResult?: 'authorized' | 'rejected' | 'expired' | 'failed'\n lastError?: string\n\n constructor(\n private readonly api: GetnoteApi,\n private readonly sleep: (ms: number, signal: AbortSignal) => Promise<void> = defaultSleep,\n ) {}\n\n get inProgress(): LoginStart | undefined {\n return this.pending?.start\n }\n\n async start(signal?: AbortSignal): Promise<LoginStart> {\n if (this.pending) return this.pending.start\n const clientId = this.api.options.clientId\n const { body } = await this.api.oauth('/oauth/device/code', { client_id: clientId }, signal)\n const data = typeof body === 'object' && body ? (body.data as Record<string, unknown> | undefined) : undefined\n if (!data || typeof data.code !== 'string' || typeof data.verification_uri !== 'string') {\n const message = typeof body === 'object' && body ? body.error?.message : String(body).slice(0, 200)\n throw new GetnoteApiError(`Could not start GetNote authorization: ${message ?? 'unexpected response'}`)\n }\n const start: LoginStart = {\n verificationUri: data.verification_uri,\n userCode: String(data.user_code ?? ''),\n expiresIn: Number(data.expires_in ?? 600),\n }\n const intervalMs = Math.max(1, Number(data.interval ?? 5)) * 1000\n const controller = new AbortController()\n this.lastResult = undefined\n this.lastError = undefined\n const done = this.poll(clientId, data.code, intervalMs, start.expiresIn * 1000, controller.signal)\n .finally(() => { this.pending = undefined })\n this.pending = { start, done, controller }\n return start\n }\n\n /** Wait for the current background login (tests and graceful shutdown). */\n async wait(): Promise<void> {\n await this.pending?.done\n }\n\n cancel(): void {\n this.pending?.controller.abort()\n }\n\n private async poll(clientId: string, code: string, intervalMs: number, ttlMs: number, signal: AbortSignal): Promise<void> {\n const deadline = Date.now() + ttlMs\n try {\n while (Date.now() < deadline) {\n await this.sleep(intervalMs, signal)\n let result: { status: number, body: Envelope | string }\n try {\n result = await this.api.oauth('/oauth/token', { grant_type: 'device_code', client_id: clientId, code }, signal)\n } catch {\n if (signal.aborted) return\n continue\n }\n const raw = typeof result.body === 'string' ? result.body : JSON.stringify(result.body)\n if (raw.includes('authorization_pending') || raw.includes('slow_down')) continue\n if (raw.includes('rejected')) { this.lastResult = 'rejected'; return }\n if (raw.includes('expired_token') || raw.includes('already_consumed')) { this.lastResult = 'expired'; return }\n const data = typeof result.body === 'object' ? (result.body.data as Record<string, unknown> | undefined) : undefined\n if (typeof result.body === 'object' && result.body.success && data && typeof data.api_key === 'string' && data.api_key) {\n await this.api.options.store.save({\n apiKey: data.api_key,\n clientId: typeof data.client_id === 'string' && data.client_id ? data.client_id : clientId,\n expiresAt: typeof data.expires_at === 'number' ? data.expires_at : undefined,\n })\n this.lastResult = 'authorized'\n return\n }\n }\n this.lastResult = 'expired'\n } catch (error) {\n if (signal.aborted) return\n this.lastResult = 'failed'\n this.lastError = error instanceof Error ? error.message : String(error)\n }\n }\n}\n\nfunction defaultSleep(ms: number, signal: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal.aborted) { reject(signal.reason); return }\n const timer = setTimeout(resolve, ms)\n timer.unref?.()\n signal.addEventListener('abort', () => { clearTimeout(timer); reject(signal.reason) }, { once: true })\n })\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { apply as applySkillFilesystem } from '@deepseek-ai/dsh-skill-filesystem'\nimport { defineTool, type InferArgs, type ParameterSchemaSpec } from '@deepseek-ai/dsh-tools'\nimport Schema from '@deepseek-ai/schemastery'\nimport { fileURLToPath } from 'node:url'\nimport {\n CredentialStore,\n DEFAULT_API_URL,\n defaultCredentialPath,\n DeviceLogin,\n DSH_CLIENT_ID,\n GetnoteApi,\n} from './api.js'\n\nexport const name = 'getnote-tools'\nexport const inject = ['tools', 'skills']\n\nexport interface Config {\n apiUrl: string\n clientId: string\n credentialPath?: string\n timeoutMs: number\n}\n\nexport const Config: Schema<Config> = Schema.object({\n apiUrl: Schema.string().default(DEFAULT_API_URL).description('GetNote OpenAPI base URL. Change only for integration testing.'),\n clientId: Schema.string().default(DSH_CLIENT_ID).description('OpenAPI client ID used for authorization.'),\n credentialPath: Schema.string().description('Where the authorized API key is stored. Default: $DSH_HOME/getnote/credentials.json.'),\n timeoutMs: Schema.number().min(1_000).default(60_000),\n})\n\nfunction textOutput() {\n return {\n schema: { type: 'string' as const },\n render: (_args: unknown, value: string) => [{ type: 'text' as const, text: value }],\n }\n}\n\nfunction renderJson(value: unknown): string {\n if (typeof value === 'string') return value\n return JSON.stringify(value, null, 2)\n}\n\nexport function integerInRange(value: number | undefined, fallback: number | undefined, min: number, max: number): number | undefined {\n const resolved = value ?? fallback\n if (resolved === undefined) return undefined\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new RangeError(`value must be an integer between ${min} and ${max}`)\n }\n return resolved\n}\n\nfunction ids(values: readonly string[] | undefined, label: string, max: number): string[] {\n const list = [...new Set((values ?? []).map(v => v.trim()).filter(Boolean))]\n if (list.length === 0) throw new RangeError(`${label} must contain at least one ID`)\n if (list.length > max) throw new RangeError(`${label} accepts at most ${max} IDs`)\n return list\n}\n\nconst URL_PATTERN = /^https?:\\/\\/\\S+$/i\n\nconst GENERATION_HINT = ' If a note\\'s generation_status is present and not \"completed\", its content may be empty or partial; do not treat it as final, read the note again later.'\n\n// ---------------------------------------------------------------------------\n// Confirmation policy\n// ---------------------------------------------------------------------------\n\n/**\n * Tools that delete, publish, or overwrite user data. The plugin asks the user\n * (DSH approval) before dispatching them; without an approval seam DSH turns\n * the ask into a denial, so these never run unattended.\n */\nexport function confirmationReason(toolName: string, args: unknown): string | undefined {\n const a = (args ?? {}) as Record<string, unknown>\n switch (toolName) {\n case 'getnote_delete_note':\n return `删除得到大脑笔记 ${String(a.note_id)}(移入回收站)`\n case 'getnote_share_note':\n return `公开分享笔记 ${String(a.note_id)},任何拿到链接的人都能查看`\n case 'getnote_update_note': {\n const parts: string[] = []\n if (a.content !== undefined) parts.push('替换正文')\n if (a.tags !== undefined) parts.push('替换全部标签')\n return parts.length > 0 ? `${parts.join('并')}:笔记 ${String(a.note_id)}` : undefined\n }\n case 'getnote_kb_remove_notes':\n return `把 ${Array.isArray(a.note_ids) ? a.note_ids.length : 0} 条笔记移出知识库 ${String(a.topic_id)}`\n default:\n return undefined\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shared parameter specs\n// ---------------------------------------------------------------------------\n\nconst noteId = { type: 'string', required: true, description: 'Note ID. Always keep it as a string.' } as const\nconst topicId = { type: 'string', required: true, description: 'Knowledge base ID (topic_id) from getnote_list_knowledge_bases.' } as const\n\nconst NOTE_TYPES = [\n 'plain_text', 'link', 'img_text', 'ref', 'audio', 'local_audio', 'class_audio',\n 'meeting', 'internal_record', 'recorder_audio', 'recorder_flash_audio',\n] as const\n\nconst noteFilters = {\n note_type: {\n type: 'string',\n enum: NOTE_TYPES,\n description: 'Exact note type. plain_text=文本, link=链接, img_text=图片, ref=引用, audio=即时录音, local_audio=上传音频, class_audio=课堂录音, meeting=会议(含录音台/耳机), internal_record=内录, recorder_audio/recorder_flash_audio=录音卡长录音/闪念.',\n },\n source: { type: 'string', description: 'Exact note source, e.g. vendor_moan=录音台, getseed=录音卡, dedao=得到.' },\n created_from: { type: 'string', description: 'Created at or after this RFC3339 time (inclusive).' },\n created_to: { type: 'string', description: 'Created before this RFC3339 time (exclusive).' },\n edited_from: { type: 'string', description: 'Edited at or after this RFC3339 time (inclusive).' },\n edited_to: { type: 'string', description: 'Edited before this RFC3339 time (exclusive).' },\n} as const\n\ntype FilterArgs = {\n note_type?: string, source?: string,\n created_from?: string, created_to?: string, edited_from?: string, edited_to?: string,\n}\n\nfunction filterQuery(a: FilterArgs): Record<string, string | undefined> {\n return {\n note_type: a.note_type,\n source: a.source,\n created_from: a.created_from,\n created_to: a.created_to,\n edited_from: a.edited_from,\n edited_to: a.edited_to,\n }\n}\n\nfunction hasFilters(a: FilterArgs): boolean {\n return Object.values(filterQuery(a)).some(v => v !== undefined && v !== '')\n}\n\n/**\n * The unfiltered note list returns a fixed page (20) regardless of `limit`.\n * Trim it like the CLI does and continue from the last returned note.\n */\nexport function trimPage(page: unknown, limit: number): unknown {\n const data = page as { notes?: Array<{ note_id?: unknown, id?: unknown }>, [key: string]: unknown } | null\n if (!data || !Array.isArray(data.notes) || data.notes.length <= limit) return page\n const notes = data.notes.slice(0, limit)\n const last = notes[notes.length - 1]\n const cursor = String(last?.note_id || last?.id || '')\n return { ...data, notes, cursor, next_cursor: cursor, has_more: true }\n}\n\n// ---------------------------------------------------------------------------\n// Plugin\n// ---------------------------------------------------------------------------\n\nexport interface Runtime {\n api: GetnoteApi\n login: DeviceLogin\n}\n\nexport function createRuntime(config: Config, fetchImpl?: typeof fetch): Runtime {\n const store = new CredentialStore(config.credentialPath || defaultCredentialPath())\n const api = new GetnoteApi({\n apiUrl: config.apiUrl || DEFAULT_API_URL,\n clientId: config.clientId || DSH_CLIENT_ID,\n store,\n timeoutMs: config.timeoutMs ?? 60_000,\n fetchImpl,\n })\n return { api, login: new DeviceLogin(api) }\n}\n\nexport function apply(ctx: Context, config: Config, runtime: Runtime = createRuntime(config)) {\n const { api, login } = runtime\n\n applySkillFilesystem(ctx, {\n providerName: 'getnote',\n includeDefaultRoots: false,\n bundledSkillDir: fileURLToPath(new URL('../skills', import.meta.url)),\n })\n\n ctx.on('tools/pre-execute', async (exec, next) => {\n const reason = confirmationReason(exec.name, exec.arguments)\n if (reason) return { kind: 'ask', reason }\n return next()\n })\n // Stop background authorization polling when the plugin is unloaded.\n ctx.effect(() => () => login.cancel(), 'getnote device login')\n\n function tool<const S extends ParameterSchemaSpec>(def: {\n name: string\n description: string\n parameters: S\n readOnly?: boolean\n run(args: InferArgs<S>, signal: AbortSignal): Promise<unknown>\n }) {\n ctx.tools.register(defineTool({\n name: def.name,\n description: def.description,\n parameters: def.parameters,\n output: textOutput(),\n ...(def.readOnly ? { isConcurrencySafe: () => true } : {}),\n async execute(args, exec) {\n return renderJson(await def.run(args, exec.signal))\n },\n }))\n }\n\n // ---- Authorization -------------------------------------------------------\n\n tool({\n name: 'getnote_login',\n description: 'Start GetNote (得到大脑) authorization. Returns a link and a code; show both to the user and ask them to open the link, log in, and confirm. The plugin finishes in the background; then call getnote_auth_status.',\n parameters: {},\n async run(_args, signal) {\n if (await api.credential()) {\n return 'Already authorized with GetNote. To switch accounts, call getnote_logout first.'\n }\n const start = await login.start(signal)\n const minutes = Math.max(1, Math.round(start.expiresIn / 60))\n return [\n 'Ask the user to open this link, log in to 得到大脑, and confirm the authorization:',\n start.verificationUri,\n `Confirmation code shown on the page: ${start.userCode}`,\n `The link expires in about ${minutes} minutes. After the user confirms, call getnote_auth_status.`,\n ].join('\\n')\n },\n })\n\n tool({\n name: 'getnote_auth_status',\n description: 'Check whether GetNote is authorized and the authorization still works.',\n parameters: {},\n readOnly: true,\n async run(_args, signal) {\n if (!(await api.credential())) {\n if (login.inProgress) return `Authorization pending: the user has not confirmed yet. Link: ${login.inProgress.verificationUri}`\n if (login.lastResult === 'rejected') return 'The user rejected the authorization. Call getnote_login to try again.'\n if (login.lastResult === 'expired') return 'The authorization link expired. Call getnote_login to get a new one.'\n if (login.lastResult === 'failed') return `Authorization failed: ${login.lastError ?? 'unknown error'}. Call getnote_login to try again.`\n return 'Not authorized. Call getnote_login.'\n }\n await api.get('/resource/rate-limit/quota', {}, signal)\n return 'Authorized with GetNote.'\n },\n })\n\n tool({\n name: 'getnote_logout',\n description: 'Remove the locally stored GetNote authorization. It does not revoke the grant on the server; the user can revoke it in the GetNote account settings.',\n parameters: {},\n async run() {\n login.cancel()\n await api.options.store.clear()\n return 'Local GetNote authorization removed.'\n },\n })\n\n tool({\n name: 'getnote_quota',\n description: 'Show the account\\'s current API quota and usage. All users can call the API; members have higher quotas.',\n parameters: {},\n readOnly: true,\n run: (_a, signal) => api.get('/resource/rate-limit/quota', {}, signal),\n })\n\n // ---- Finding notes -------------------------------------------------------\n\n tool({\n name: 'getnote_search',\n description: 'Semantically search the user\\'s notes, optionally within one knowledge base.',\n parameters: {\n query: { type: 'string', required: true, description: 'Natural-language search query.' },\n knowledge_base_id: { type: 'string', description: 'Optional knowledge base (topic) ID.' },\n limit: { type: 'integer', default: 10, description: 'Maximum results, 1-10.' },\n snippet_chars: { type: 'integer', description: 'Return snippets of at most this many characters (100-1000) instead of full bodies, to keep results compact.' },\n },\n readOnly: true,\n async run(a, signal) {\n const body: Record<string, unknown> = { query: a.query, top_k: integerInRange(a.limit, 10, 1, 10) }\n const snippet = integerInRange(a.snippet_chars, undefined, 100, 1000)\n if (snippet !== undefined) Object.assign(body, { response_mode: 'snippet', max_snippet_chars: snippet })\n if (a.knowledge_base_id) {\n body.topic_id = a.knowledge_base_id\n return await api.post('/resource/recall/knowledge', body, signal)\n }\n return await api.post('/resource/recall', body, signal)\n },\n })\n\n tool({\n name: 'getnote_list_notes',\n description: 'List the user\\'s notes, newest first, with optional filters. Paginate with next_cursor from the previous page.' + GENERATION_HINT,\n parameters: {\n limit: { type: 'integer', default: 20, description: 'Notes per page, 1-100.' },\n cursor: { type: 'string', description: 'next_cursor returned by the previous page.' },\n topic_id: { type: 'string', description: 'Only notes in this knowledge base.' },\n ...noteFilters,\n },\n readOnly: true,\n async run(a, signal) {\n const size = integerInRange(a.limit, 20, 1, 100)\n const filtered = hasFilters(a) || Boolean(a.topic_id)\n const page = await api.get('/resource/note/list', {\n ...(filtered ? { page_size: size } : { limit: size }),\n cursor: a.cursor,\n topic_id: a.topic_id,\n ...filterQuery(a),\n }, signal)\n return filtered ? page : trimPage(page, size!)\n },\n })\n\n // ---- Reading notes -------------------------------------------------------\n\n tool({\n name: 'getnote_get_note',\n description: 'Get one note in full by its string ID, including its tags (with tag IDs). For very long notes use getnote_note_outline and getnote_note_section instead.' + GENERATION_HINT,\n parameters: { note_id: noteId },\n readOnly: true,\n run: (a, signal) => api.get('/resource/note/detail', { id: a.note_id }, signal),\n })\n\n tool({\n name: 'getnote_note_outline',\n description: 'Read the outline of a long note: headings with UTF-16 offsets and a version. Use it before getnote_note_section.',\n parameters: { note_id: noteId },\n readOnly: true,\n run: (a, signal) => api.get('/resource/note/outline', { id: a.note_id }, signal),\n })\n\n tool({\n name: 'getnote_note_section',\n description: 'Read part of a long note, at an offset returned by getnote_note_outline or around literal keywords. Never compute offsets yourself; if the version changed, read the outline again.',\n parameters: {\n note_id: noteId,\n keyword: { type: 'string', description: 'Literal keyword(s), alternatives separated by |. Not semantic search.' },\n offset: { type: 'integer', description: 'UTF-16 offset returned by the outline or a previous section.' },\n limit: { type: 'integer', description: 'UTF-16 units to read (or keyword search window), 1-30000. Default 8000.' },\n version: { type: 'string', description: 'Version returned by the outline.' },\n },\n readOnly: true,\n run: (a, signal) => api.get('/resource/note/section', {\n id: a.note_id,\n keyword: a.keyword,\n offset: integerInRange(a.offset, undefined, 0, 3_000_000),\n limit: integerInRange(a.limit, undefined, 1, 30_000),\n version: a.version,\n }, signal),\n })\n\n tool({\n name: 'getnote_read_notes',\n description: 'Read several notes at once within a character budget. Notes that do not fit are listed in pending_ids; read them in a follow-up call.',\n parameters: {\n note_ids: { type: 'array', required: true, items: { type: 'string' }, description: 'Note IDs (strings), 1-20.' },\n fields: { type: 'array', items: { type: 'string', enum: ['content', 'ref_content', 'reference', 'original'] }, description: 'Fields to return; original (transcript/original text) is opt-in.' },\n max_total_chars: { type: 'integer', description: 'Total character budget, 1-64000 (server default 32000).' },\n },\n readOnly: true,\n run: (a, signal) => api.post('/resource/note/batch-detail', {\n ids: ids(a.note_ids, 'note_ids', 20),\n ...(a.fields && a.fields.length > 0 ? { fields: a.fields } : {}),\n ...(a.max_total_chars !== undefined ? { max_total_chars: integerInRange(a.max_total_chars, undefined, 1, 64_000) } : {}),\n }, signal),\n })\n\n tool({\n name: 'getnote_task_status',\n description: 'Check an asynchronous save task (e.g. a saved link) and get the resulting note ID.',\n parameters: { task_id: { type: 'string', required: true, description: 'task_id returned by getnote_save.' } },\n readOnly: true,\n run: (a, signal) => api.post('/resource/note/task/progress', { task_id: a.task_id }, signal),\n })\n\n // ---- Writing notes -------------------------------------------------------\n\n tool({\n name: 'getnote_save',\n description: 'Save a text note, a web link (processed asynchronously; check getnote_task_status), or images by HTTPS URL. Local image files are not supported.',\n parameters: {\n content: { type: 'string', description: 'Note text, or a single http(s) URL to save as a link note.' },\n image_urls: { type: 'array', items: { type: 'string' }, description: 'HTTPS image URLs to save as an image note.' },\n title: { type: 'string', description: 'Optional title.' },\n tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags.' },\n topic_id: { type: 'string', description: 'Save directly into this knowledge base.' },\n parent_id: { type: 'string', description: 'Create as a child note of this note.' },\n idempotency_key: { type: 'string', description: 'Reuse the same key (1-128 ASCII chars) when retrying the same save to avoid duplicates.' },\n },\n async run(a, signal) {\n const content = a.content?.trim() ?? ''\n const images = (a.image_urls ?? []).map(u => u.trim()).filter(Boolean)\n let body: Record<string, unknown>\n if (images.length > 0) {\n if (images.some(u => !/^https:\\/\\//i.test(u))) throw new RangeError('image_urls must be https URLs')\n body = { note_type: 'img_text', image_urls: images, ...(content ? { content } : {}) }\n } else if (URL_PATTERN.test(content)) {\n body = { note_type: 'link', link_url: content }\n } else if (content) {\n body = { note_type: 'plain_text', content: a.content }\n } else {\n throw new RangeError('provide content or image_urls')\n }\n if (a.idempotency_key !== undefined && !/^[\\x21-\\x7e]{1,128}$/.test(a.idempotency_key)) {\n throw new RangeError('idempotency_key must be 1-128 printable ASCII characters')\n }\n return await api.post('/resource/note/save', {\n ...body,\n title: a.title || undefined,\n tags: a.tags && a.tags.length > 0 ? a.tags : undefined,\n topic_id: a.topic_id || undefined,\n parent_id: a.parent_id || undefined,\n client_request_id: a.idempotency_key || undefined,\n }, signal)\n },\n })\n\n tool({\n name: 'getnote_update_note',\n description: 'Update a note\\'s title, body (plain-text notes only), or full tag list. Replacing the body or all tags requires user confirmation.',\n parameters: {\n note_id: noteId,\n title: { type: 'string', description: 'New title.' },\n content: { type: 'string', description: 'New full body; replaces the existing body. Plain-text notes only.' },\n tags: { type: 'array', items: { type: 'string' }, description: 'New complete tag list; replaces all existing tags.' },\n },\n async run(a, signal) {\n if (a.title === undefined && a.content === undefined && a.tags === undefined) {\n throw new RangeError('provide title, content, or tags')\n }\n return await api.post('/resource/note/update', {\n id: a.note_id,\n ...(a.title !== undefined ? { title: a.title } : {}),\n ...(a.content !== undefined ? { content: a.content } : {}),\n ...(a.tags !== undefined ? { tags: a.tags } : {}),\n }, signal)\n },\n })\n\n tool({\n name: 'getnote_add_note_tags',\n description: 'Add tags to a note, keeping its existing tags.',\n parameters: {\n note_id: noteId,\n tags: { type: 'array', required: true, items: { type: 'string' }, description: 'Tag names to add.' },\n },\n async run(a, signal) {\n const tags = [...new Set(a.tags.map(t => t.trim()).filter(Boolean))]\n if (tags.length === 0) throw new RangeError('tags must not be empty')\n return await api.post('/resource/note/tags/add', { note_id: a.note_id, tags }, signal)\n },\n })\n\n tool({\n name: 'getnote_remove_note_tag',\n description: 'Remove one tag from a note by tag ID (from getnote_get_note).',\n parameters: {\n note_id: noteId,\n tag_id: { type: 'string', required: true, description: 'Tag ID.' },\n },\n run: (a, signal) => api.post('/resource/note/tags/delete', { note_id: a.note_id, tag_id: a.tag_id }, signal),\n })\n\n tool({\n name: 'getnote_delete_note',\n description: 'Move a note to the recycle bin (restorable in the GetNote App). Requires user confirmation.',\n parameters: { note_id: noteId },\n run: (a, signal) => api.post('/resource/note/delete', { note_id: a.note_id }, signal),\n })\n\n tool({\n name: 'getnote_share_note',\n description: 'Make a note public and return its share link; anyone with the link can read it. Requires user confirmation.',\n parameters: {\n note_id: noteId,\n exclude_audio: { type: 'boolean', description: 'Do not include the audio in the shared note.' },\n },\n run: (a, signal) => api.post('/resource/note/sharing', { note_id: a.note_id, share_exclude_audio: Boolean(a.exclude_audio) }, signal),\n })\n\n // ---- Knowledge bases -----------------------------------------------------\n\n tool({\n name: 'getnote_list_knowledge_bases',\n description: 'List the user\\'s own knowledge bases, or the ones the user subscribes to.',\n parameters: {\n subscribed: { type: 'boolean', description: 'List subscribed knowledge bases instead of the user\\'s own.' },\n scope: { type: 'string', enum: ['DEFAULT', 'CUSTOMER', 'BOOKSPACE', 'TEAMSPACE'], description: 'Knowledge base type. Default DEFAULT.' },\n page: { type: 'integer', description: 'Page number, starting from 1.' },\n },\n readOnly: true,\n run: (a, signal) => api.get(a.subscribed ? '/resource/knowledge/subscribe/list' : '/resource/knowledge/list', {\n page: integerInRange(a.page, 1, 1, 100_000),\n scope: a.scope ?? 'DEFAULT',\n }, signal),\n })\n\n tool({\n name: 'getnote_list_kb_notes',\n description: 'List the notes in one knowledge base, with optional filters.' + GENERATION_HINT,\n parameters: {\n topic_id: topicId,\n page: { type: 'integer', description: 'Page number, starting from 1.' },\n page_size: { type: 'integer', description: 'Notes per page, 1-100.' },\n ...noteFilters,\n },\n readOnly: true,\n run: (a, signal) => api.get('/resource/knowledge/notes', {\n topic_id: a.topic_id,\n page: integerInRange(a.page, 1, 1, 100_000),\n page_size: integerInRange(a.page_size, undefined, 1, 100),\n ...filterQuery(a),\n }, signal),\n })\n\n tool({\n name: 'getnote_kb_add_notes',\n description: 'Add notes to a knowledge base. At most 20 per call.',\n parameters: {\n topic_id: topicId,\n note_ids: { type: 'array', required: true, items: { type: 'string' }, description: 'Note IDs (strings), 1-20.' },\n },\n run: (a, signal) => api.post('/resource/knowledge/note/batch-add', { topic_id: a.topic_id, note_ids: ids(a.note_ids, 'note_ids', 20) }, signal),\n })\n\n tool({\n name: 'getnote_kb_remove_notes',\n description: 'Remove notes from a knowledge base; the notes themselves are kept. At most 20 per call. Requires user confirmation.',\n parameters: {\n topic_id: topicId,\n note_ids: { type: 'array', required: true, items: { type: 'string' }, description: 'Note IDs (strings), 1-20.' },\n },\n run: (a, signal) => api.post('/resource/knowledge/note/remove', { topic_id: a.topic_id, note_ids: ids(a.note_ids, 'note_ids', 20) }, signal),\n })\n}\n\nexport {\n apiBase,\n parseJson,\n CredentialStore,\n DEFAULT_API_URL,\n DeviceLogin,\n DSH_CLIENT_ID,\n GetnoteApi,\n GetnoteApiError,\n MEMBERSHIP_URL,\n NotLoggedInError,\n} from './api.js'\n"],"mappings":";;;;;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,kBAAkB;AAQ/B,MAAa,iBAAiB;AAE9B,IAAa,kBAAb,cAAqC,MAAM;CAG9B;CACA;CAHX,YACE,SACA,MACA,QACA;EACA,MAAM,OAAO;EAHJ,KAAA,OAAA;EACA,KAAA,SAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,IAAa,mBAAb,cAAsC,gBAAgB;CACpD,cAAc;EACZ,MAAM,4FAA4F,eAAe;EACjH,KAAK,OA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E,GAAG,MAAM;CAChJ,CAAC;CAED,KAAK;EACH,MAAM;EACN,aAAa;EACb,YAAY;GACV,UAAU;GACV,UAAU;IAAE,MAAM;IAAS,UAAU;IAAM,OAAO,EAAE,MAAM,SAAS;IAAG,aAAa;GAA4B;EACjH;EACA,MAAM,GAAG,WAAW,IAAI,KAAK,mCAAmC;GAAE,UAAU,EAAE;GAAU,UAAU,IAAI,EAAE,UAAU,YAAY,EAAE;EAAE,GAAG,MAAM;CAC7I,CAAC;AACH"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** OpenAPI client ID used by this plugin for authorization. */
|
|
2
|
+
export declare const DSH_CLIENT_ID = "cli_35ca47aab229ebb0c4c4dd12";
|
|
3
|
+
export declare const DEFAULT_API_URL = "https://openapi.biji.com";
|
|
4
|
+
export interface Credential {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
expiresAt?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const MEMBERSHIP_URL = "https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_dsh";
|
|
10
|
+
export declare class GetnoteApiError extends Error {
|
|
11
|
+
readonly code?: string | number | undefined;
|
|
12
|
+
readonly status?: number | undefined;
|
|
13
|
+
constructor(message: string, code?: string | number | undefined, status?: number | undefined);
|
|
14
|
+
}
|
|
15
|
+
export declare class NotLoggedInError extends GetnoteApiError {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
export declare function defaultCredentialPath(env?: NodeJS.ProcessEnv): string;
|
|
19
|
+
/** Normalize a base URL to the `/open/api/v1` prefix, accepting the same forms as the CLI. */
|
|
20
|
+
export declare function apiBase(url: string): string;
|
|
21
|
+
/** Credential file stored with 0600 permissions. The key never reaches the model. */
|
|
22
|
+
export declare class CredentialStore {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
constructor(path: string);
|
|
25
|
+
load(): Promise<Credential | undefined>;
|
|
26
|
+
save(credential: Credential): Promise<void>;
|
|
27
|
+
clear(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse JSON while keeping integers beyond Number.MAX_SAFE_INTEGER as strings.
|
|
31
|
+
* GetNote IDs are 64-bit; a plain JSON.parse would silently corrupt them.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseJson(text: string): unknown;
|
|
34
|
+
export interface ApiOptions {
|
|
35
|
+
apiUrl: string;
|
|
36
|
+
clientId: string;
|
|
37
|
+
store: CredentialStore;
|
|
38
|
+
timeoutMs: number;
|
|
39
|
+
fetchImpl?: typeof fetch;
|
|
40
|
+
env?: NodeJS.ProcessEnv;
|
|
41
|
+
}
|
|
42
|
+
type Query = Record<string, string | number | boolean | undefined | null>;
|
|
43
|
+
interface Envelope {
|
|
44
|
+
success?: boolean;
|
|
45
|
+
data?: unknown;
|
|
46
|
+
error?: {
|
|
47
|
+
code?: string | number;
|
|
48
|
+
message?: string;
|
|
49
|
+
reason?: string;
|
|
50
|
+
retry_after_seconds?: number;
|
|
51
|
+
rate_limit_detail?: {
|
|
52
|
+
retry_after_seconds?: number;
|
|
53
|
+
} | null;
|
|
54
|
+
} | null;
|
|
55
|
+
h?: {
|
|
56
|
+
c?: number;
|
|
57
|
+
e?: string;
|
|
58
|
+
};
|
|
59
|
+
c?: unknown;
|
|
60
|
+
}
|
|
61
|
+
export declare class GetnoteApi {
|
|
62
|
+
readonly options: ApiOptions;
|
|
63
|
+
readonly base: string;
|
|
64
|
+
private readonly fetchImpl;
|
|
65
|
+
constructor(options: ApiOptions);
|
|
66
|
+
/** Environment variables override the stored credential (useful for CI and testing). */
|
|
67
|
+
credential(): Promise<Credential | undefined>;
|
|
68
|
+
get(path: string, query?: Query, signal?: AbortSignal): Promise<unknown>;
|
|
69
|
+
post(path: string, body: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
70
|
+
/** Unauthenticated OAuth call (device code / token). Returns the raw parsed body. */
|
|
71
|
+
oauth(path: string, body: unknown, signal?: AbortSignal): Promise<{
|
|
72
|
+
status: number;
|
|
73
|
+
body: Envelope | string;
|
|
74
|
+
}>;
|
|
75
|
+
private signal;
|
|
76
|
+
private request;
|
|
77
|
+
}
|
|
78
|
+
export interface LoginStart {
|
|
79
|
+
verificationUri: string;
|
|
80
|
+
userCode: string;
|
|
81
|
+
expiresIn: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* RFC 8628-style device authorization against the GetNote OpenAPI. `start()`
|
|
85
|
+
* returns the link immediately; polling continues in the background and stores
|
|
86
|
+
* the credential once the user confirms in the browser.
|
|
87
|
+
*/
|
|
88
|
+
export declare class DeviceLogin {
|
|
89
|
+
private readonly api;
|
|
90
|
+
private readonly sleep;
|
|
91
|
+
private pending?;
|
|
92
|
+
lastResult?: 'authorized' | 'rejected' | 'expired' | 'failed';
|
|
93
|
+
lastError?: string;
|
|
94
|
+
constructor(api: GetnoteApi, sleep?: (ms: number, signal: AbortSignal) => Promise<void>);
|
|
95
|
+
get inProgress(): LoginStart | undefined;
|
|
96
|
+
start(signal?: AbortSignal): Promise<LoginStart>;
|
|
97
|
+
/** Wait for the current background login (tests and graceful shutdown). */
|
|
98
|
+
wait(): Promise<void>;
|
|
99
|
+
cancel(): void;
|
|
100
|
+
private poll;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,eAAO,MAAM,aAAa,iCAAiC,CAAA;AAC3D,eAAO,MAAM,eAAe,6BAA6B,CAAA;AAEzD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,cAAc,2EAA2E,CAAA;AAEtG,qBAAa,eAAgB,SAAQ,KAAK;I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,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IANxB,OAAO,CAAC,OAAO,CAAC,CAAyF;IACzG,UAAU,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAA;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAA;gBAGC,GAAG,EAAE,UAAU,EACf,KAAK,GAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAgB;IAG3F,IAAI,UAAU,IAAI,UAAU,GAAG,SAAS,CAEvC;IAEK,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAwBtD,2EAA2E;IACrE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,IAAI,IAAI;YAIA,IAAI;CAkCnB"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import Schema from '@deepseek-ai/schemastery';
|
|
3
|
+
import { DeviceLogin, GetnoteApi } from './api.js';
|
|
3
4
|
export declare const name = "getnote-tools";
|
|
4
5
|
export declare const inject: string[];
|
|
5
6
|
export interface Config {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
credentialPath?: string;
|
|
8
10
|
timeoutMs: number;
|
|
9
|
-
maxOutputBytes: number;
|
|
10
11
|
}
|
|
11
12
|
export declare const Config: Schema<Config>;
|
|
12
|
-
export declare function
|
|
13
|
-
|
|
13
|
+
export declare function integerInRange(value: number | undefined, fallback: number | undefined, min: number, max: number): number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Tools that delete, publish, or overwrite user data. The plugin asks the user
|
|
16
|
+
* (DSH approval) before dispatching them; without an approval seam DSH turns
|
|
17
|
+
* the ask into a denial, so these never run unattended.
|
|
18
|
+
*/
|
|
19
|
+
export declare function confirmationReason(toolName: string, args: unknown): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The unfiltered note list returns a fixed page (20) regardless of `limit`.
|
|
22
|
+
* Trim it like the CLI does and continue from the last returned note.
|
|
23
|
+
*/
|
|
24
|
+
export declare function trimPage(page: unknown, limit: number): unknown;
|
|
25
|
+
export interface Runtime {
|
|
26
|
+
api: GetnoteApi;
|
|
27
|
+
login: DeviceLogin;
|
|
28
|
+
}
|
|
29
|
+
export declare function createRuntime(config: Config, fetchImpl?: typeof fetch): Runtime;
|
|
30
|
+
export declare function apply(ctx: Context, config: Config, runtime?: Runtime): void;
|
|
31
|
+
export { apiBase, parseJson, CredentialStore, DEFAULT_API_URL, DeviceLogin, DSH_CLIENT_ID, GetnoteApi, GetnoteApiError, MEMBERSHIP_URL, NotLoggedInError, } from './api.js';
|
|
14
32
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,MAAM,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAE7C,OAAO,EAIL,WAAW,EAEX,UAAU,EACX,MAAM,UAAU,CAAA;AAEjB,eAAO,MAAM,IAAI,kBAAkB,CAAA;AACnC,eAAO,MAAM,MAAM,UAAsB,CAAA;AAEzC,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,CAKhC,CAAA;AAcF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpI;AAiBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAkBtF;AA+CD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO9D;AAMD,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,GAAG,OAAO,CAU/E;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,OAA+B,QA0W3F;AAED,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,eAAe,EACf,WAAW,EACX,aAAa,EACb,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,52 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: getnote-dsh
|
|
3
|
-
description: 在 DeepSeek Harness
|
|
3
|
+
description: 在 DeepSeek Harness 中使用得到大脑。用户要登录得到大脑,搜索、保存、列出、阅读、修改、删除或分享笔记,管理标签和知识库时使用。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# 得到大脑(DSH)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
使用插件提供的 `getnote_*` 原生工具完成操作,不需要本机安装 GetNote CLI。
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
- `getnote_search`:语义搜索笔记,可限定知识库。
|
|
12
|
-
- `getnote_save`:保存文字、链接或本地图片,可设置标题和标签。
|
|
13
|
-
- `getnote_list_notes`:列出最近笔记。
|
|
14
|
-
- `getnote_get_note`:按字符串 ID 打开笔记。
|
|
15
|
-
- `getnote_list_knowledge_bases`:列出知识库。
|
|
10
|
+
## 登录
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
- 任何工具提示未登录时,调用 `getnote_login`,把返回的链接和确认码原样告诉用户,请用户在浏览器打开、登录并确认。
|
|
13
|
+
- 用户说已确认后,调用 `getnote_auth_status` 确认结果,再继续原来的操作。
|
|
14
|
+
- `getnote_logout` 只清除本机授权;要彻底取消,请用户在得到大脑账号设置里撤销。
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
不要为了绕过工具边界自行拼接未经说明的 Shell 命令。若没有相应 Skill,说明当前
|
|
21
|
-
插件尚未支持该操作,并建议用户安装或更新 GetNote Skills。
|
|
16
|
+
## 调用额度
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
- 所有用户授权后都可以调用,会员享有更高额度。不要预先因为用户不是会员就拒绝、要求升级或重新登录。
|
|
19
|
+
- 用 `getnote_quota` 查看当前实际额度,不要自己写死额度数字。
|
|
20
|
+
- 工具报额度或频率超限时,按返回的等待时间告诉用户,不要连续重试。
|
|
21
|
+
- 只有服务端明确返回非会员错误(10201 / not_member)时,才把错误里的会员链接告诉用户。
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
## 找笔记
|
|
24
|
+
|
|
25
|
+
- `getnote_search`:语义搜索,可用 `knowledge_base_id` 限定知识库;结果多时加 `snippet_chars` 只取片段。
|
|
26
|
+
- `getnote_list_notes`:按时间倒序列笔记,可按类型、来源、创建/编辑时间、知识库筛选;翻页用上一页的 `next_cursor`。
|
|
27
|
+
- 录音台笔记:`source=vendor_moan`;录音卡:`source=getseed`。
|
|
28
|
+
|
|
29
|
+
## 读笔记
|
|
30
|
+
|
|
31
|
+
- `getnote_get_note`:读一条笔记全文和标签(含标签 ID)。
|
|
32
|
+
- 长笔记先 `getnote_note_outline` 拿目录和 offset,再用 `getnote_note_section` 按 offset 或关键词读片段;offset 只用接口返回的,不要自己算。
|
|
33
|
+
- `getnote_read_notes`:一次读多条(最多 20),没读完的在 `pending_ids` 里,再调一次。
|
|
34
|
+
- 笔记带 `generation_status` 且不是 `completed`(生成中、附件处理中、失败等)时,正文可能为空或不完整,不要当最终内容,告诉用户还在生成,过会儿再用 `getnote_get_note` 读;没有这个字段时照常处理。
|
|
35
|
+
|
|
36
|
+
## 写笔记
|
|
37
|
+
|
|
38
|
+
- `getnote_save`:保存文字、网页链接或 HTTPS 图片链接,可带标题、标签、知识库、父笔记。链接是异步处理,用 `getnote_task_status` 查结果;重试同一次保存时带同一个 `idempotency_key`,避免重复。
|
|
39
|
+
- `getnote_update_note`:改标题;正文只能改纯文本笔记;`tags` 会替换全部标签。只加标签用 `getnote_add_note_tags`,删一个用 `getnote_remove_note_tag`。
|
|
40
|
+
- `getnote_delete_note`:移入回收站(可在 App 恢复)。
|
|
41
|
+
- `getnote_share_note`:公开分享,拿到链接的人都能看。
|
|
42
|
+
|
|
43
|
+
## 知识库
|
|
44
|
+
|
|
45
|
+
- `getnote_list_knowledge_bases`:自己的知识库;`subscribed=true` 看订阅的。
|
|
46
|
+
- `getnote_list_kb_notes`、`getnote_kb_add_notes`、`getnote_kb_remove_notes`(只移出,不删笔记)。
|
|
47
|
+
|
|
48
|
+
## 规则
|
|
49
|
+
|
|
50
|
+
- 笔记 ID、知识库 ID、标签 ID 一律按字符串处理,不要转成数字。
|
|
51
|
+
- 删除、公开分享、替换正文或全部标签、移出知识库会先请用户确认;用户拒绝就停下,不要换别的工具绕过去。
|
|
52
|
+
- 不支持的操作(如上传本地图片、新建知识库)直接告诉用户插件暂不支持。
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface RunGetnoteOptions {
|
|
2
|
-
binaryPath?: string;
|
|
3
|
-
apiUrl?: string;
|
|
4
|
-
signal?: AbortSignal;
|
|
5
|
-
timeoutMs?: number;
|
|
6
|
-
maxOutputBytes?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class GetnoteCliError extends Error {
|
|
9
|
-
readonly exitCode: number | null;
|
|
10
|
-
readonly stderr: string;
|
|
11
|
-
constructor(message: string, exitCode: number | null, stderr: string);
|
|
12
|
-
}
|
|
13
|
-
export declare function resolveGetnoteBinary(): string;
|
|
14
|
-
export declare function resolveGetnoteFromPath(pathValue?: string, pathExtValue?: string): string | undefined;
|
|
15
|
-
export declare function runGetnote(args: readonly string[], options?: RunGetnoteOptions): Promise<unknown>;
|
|
16
|
-
//# sourceMappingURL=cli-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runner.d.ts","sourceRoot":"","sources":["../../src/cli-runner.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAFvB,OAAO,EAAE,MAAM,EACN,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM;CAK1B;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAOD,wBAAgB,sBAAsB,CACpC,SAAS,SAAyB,EAClC,YAAY,SAA+C,GAC1D,MAAM,GAAG,SAAS,CAgBpB;AAkBD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,OAAO,CAAC,CA4FlB"}
|