@getnote/dsh-plugin 0.2.0 → 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 CHANGED
@@ -24,9 +24,8 @@ npx @deepseek-ai/dsh plugin --profile web add @getnote/dsh-plugin
24
24
  确认码,在浏览器打开链接、登录并确认即可。授权页上的应用名是
25
25
  「DeepSeek Harness 插件」。
26
26
 
27
- **免费账号也可以使用,无需先开通会员。** 免费与会员享有不同额度,可以对 Agent
28
- 说「查看得到大脑额度」查看当前实际额度。额度用尽后按返回的重置时间等待;需要
29
- 更高默认额度时,可[升级会员](https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_dsh)。
27
+ 所有得到大脑用户授权后都可以调用,会员享有更高额度([了解会员](https://www.biji.com/checkout?product_alias=9Ab36BB3ZD&spm=openapi_dsh))。
28
+ 对 Agent 说「查看得到大脑额度」可以看当前额度,额度用完后按返回的重置时间等待。
30
29
 
31
30
  ### 3. 开始使用
32
31
 
package/lib/index.js CHANGED
@@ -530,7 +530,7 @@ function apply(ctx, config, runtime = createRuntime(config)) {
530
530
  });
531
531
  tool({
532
532
  name: "getnote_quota",
533
- description: "Show the account's current API quota and usage. Free accounts can use GetNote; free and member accounts have different quotas.",
533
+ description: "Show the account's current API quota and usage. All users can call the API; members have higher quotas.",
534
534
  parameters: {},
535
535
  readOnly: true,
536
536
  run: (_a, signal) => api.get("/resource/rate-limit/quota", {}, signal)
@@ -578,7 +578,7 @@ function apply(ctx, config, runtime = createRuntime(config)) {
578
578
  });
579
579
  tool({
580
580
  name: "getnote_list_notes",
581
- description: "List the user's notes, newest first, with optional filters. Paginate with next_cursor from the previous page.",
581
+ description: "List the user's notes, newest first, with optional filters. Paginate with next_cursor from the previous page. 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.",
582
582
  parameters: {
583
583
  limit: {
584
584
  type: "integer",
@@ -610,7 +610,7 @@ function apply(ctx, config, runtime = createRuntime(config)) {
610
610
  });
611
611
  tool({
612
612
  name: "getnote_get_note",
613
- 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.",
613
+ 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. 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.",
614
614
  parameters: { note_id: noteId },
615
615
  readOnly: true,
616
616
  run: (a, signal) => api.get("/resource/note/detail", { id: a.note_id }, signal)
@@ -883,7 +883,7 @@ function apply(ctx, config, runtime = createRuntime(config)) {
883
883
  });
884
884
  tool({
885
885
  name: "getnote_list_kb_notes",
886
- description: "List the notes in one knowledge base, with optional filters.",
886
+ description: "List the notes in one knowledge base, with optional filters. 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.",
887
887
  parameters: {
888
888
  topic_id: topicId,
889
889
  page: {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
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\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. Free accounts can use GetNote; free and member accounts have different 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.',\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.',\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.',\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_CLIEN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AAM,eAAe,EAAE,MAAM,GAAG,GAAG,GAAO;GAC1C,WAAW,eAAe,EAAE,WAAW,KAAA,GAAW,GAAG,GAAG;GACxD,GAAG,YAAY,CAAC;EAClB,GAAG,MAAM;CACX,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,sCAAsC;GAAE,UAAU,EAAE;GAAU,UAAU,IAAI,EAAE,UAAU,YAAY,EAAE;EAAE,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"}
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,OAAO;CACd;AACF;AAEA,SAAgB,sBAAsB,MAAyB,QAAQ,KAAa;CAClF,MAAM,UAAU,IAAI,YAAY,KAAK,QAAQ,GAAG,MAAM;CACtD,OAAO,KAAK,SAAS,WAAW,kBAAkB;AACpD;;AAGA,SAAgB,QAAQ,KAAqB;CAC3C,IAAI,OAAO,IAAI,QAAQ,QAAQ,EAAE;CACjC,IAAI,KAAK,SAAS,cAAc,GAAG,OAAO;CAC1C,IAAI,KAAK,SAAS,OAAO,GAAG,OAAO,GAAG,KAAK;CAC3C,OAAO,GAAG,KAAK;AACjB;;AAGA,IAAa,kBAAb,MAA6B;CACN;CAArB,YAAY,MAAuB;EAAd,KAAA,OAAA;CAAe;CAEpC,MAAM,OAAwC;EAC5C,IAAI;GACF,MAAM,OAAO,KAAK,MAAM,MAAM,SAAS,KAAK,MAAM,MAAM,CAAC;GACzD,IAAI,OAAO,KAAK,WAAW,YAAY,CAAC,KAAK,UAAU,OAAO,KAAK,aAAa,YAAY,CAAC,KAAK,UA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-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "在 DeepSeek Harness 中用自然语言搜索、保存和阅读得到大脑笔记",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -13,9 +13,9 @@ description: 在 DeepSeek Harness 中使用得到大脑。用户要登录得到
13
13
  - 用户说已确认后,调用 `getnote_auth_status` 确认结果,再继续原来的操作。
14
14
  - `getnote_logout` 只清除本机授权;要彻底取消,请用户在得到大脑账号设置里撤销。
15
15
 
16
- ## 免费账号与额度
16
+ ## 调用额度
17
17
 
18
- - 免费账号授权后即可使用,无需先购买会员;免费和会员额度不同。不要因为账号是免费的就提前拒绝、要求升级或重新登录。
18
+ - 所有用户授权后都可以调用,会员享有更高额度。不要预先因为用户不是会员就拒绝、要求升级或重新登录。
19
19
  - 用 `getnote_quota` 查看当前实际额度,不要自己写死额度数字。
20
20
  - 工具报额度或频率超限时,按返回的等待时间告诉用户,不要连续重试。
21
21
  - 只有服务端明确返回非会员错误(10201 / not_member)时,才把错误里的会员链接告诉用户。
@@ -31,6 +31,7 @@ description: 在 DeepSeek Harness 中使用得到大脑。用户要登录得到
31
31
  - `getnote_get_note`:读一条笔记全文和标签(含标签 ID)。
32
32
  - 长笔记先 `getnote_note_outline` 拿目录和 offset,再用 `getnote_note_section` 按 offset 或关键词读片段;offset 只用接口返回的,不要自己算。
33
33
  - `getnote_read_notes`:一次读多条(最多 20),没读完的在 `pending_ids` 里,再调一次。
34
+ - 笔记带 `generation_status` 且不是 `completed`(生成中、附件处理中、失败等)时,正文可能为空或不完整,不要当最终内容,告诉用户还在生成,过会儿再用 `getnote_get_note` 读;没有这个字段时照常处理。
34
35
 
35
36
  ## 写笔记
36
37