{"_id":"@ainote/sdk","_rev":"2-3e33da726862ca73217e164580d4a47a","name":"@ainote/sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@ainote/sdk","version":"0.1.0","keywords":["ainote","sdk","api-client","tasks","todo","mcp","productivity","typescript"],"author":{"name":"AI Note Team","email":"support@ainote.app"},"license":"MIT","_id":"@ainote/sdk@0.1.0","maintainers":[{"name":"beast2025","email":"theqwe2000@gmail.com"}],"homepage":"https://docs.ainote.dev/build/","bugs":{"url":"https://github.com/seunghan91/ainote/issues"},"dist":{"shasum":"3d6d79371b4eb675626ced83cbe7446edbe89a2a","tarball":"https://registry.npmjs.org/@ainote/sdk/-/sdk-0.1.0.tgz","fileCount":9,"integrity":"sha512-xpLsrevEangUs6jXOCpC/yz2mmHDshnMlqZhIqB30kX9ZICvBKUlB6Rw9T8F+4rDxaswVwDNms+Wv8j9weR8cg==","signatures":[{"sig":"MEUCIQCLN6vwoRVRuoTPX4uUzFUXWFSqnAyU9j44xnHIHCoQPQIgUP0bp0C+Xs5S7EJCNn5u1uOMTfXiyUUOgCxlxxWNYG4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":228625},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"e519ec48ce7599ab6ef28d3c27c93ddd4829b1c9","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","generate:types":"node scripts/generate-types.mjs","prepublishOnly":"npm run build"},"_npmUser":{"name":"beast2025","email":"theqwe2000@gmail.com"},"repository":{"url":"git+https://github.com/seunghan91/ainote.git","type":"git","directory":"sdk"},"_npmVersion":"10.9.2","description":"TypeScript SDK for the ainote API — typed REST client for tasks, categories & papers, plus an MCP tool-mirror escape hatch for vault/sync.","directories":{},"sideEffects":false,"_nodeVersion":"22.14.0","dependencies":{},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","vitest":"^3.2.0","typescript":"^5.9.3","openapi-typescript":"^7.10.1"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1780925003075_0.9287158135630038","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@ainote/sdk","version":"0.1.1","description":"TypeScript SDK for the ainote API — typed REST client for tasks, categories & papers, plus an MCP tool-mirror escape hatch for vault/sync.","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"sideEffects":false,"engines":{"node":">=18.0.0"},"scripts":{"generate:types":"node scripts/generate-types.mjs","build":"tsup","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","prepublishOnly":"npm run build"},"keywords":["ainote","sdk","api-client","tasks","todo","mcp","productivity","typescript"],"author":{"name":"AI Note Team","email":"support@ainote.app"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/seunghan91/ainote.git","directory":"sdk"},"homepage":"https://docs.ainote.dev/build/","bugs":{"url":"https://github.com/seunghan91/ainote/issues"},"dependencies":{},"devDependencies":{"openapi-typescript":"^7.10.1","tsup":"^8.5.0","typescript":"^5.9.3","vitest":"^3.2.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_id":"@ainote/sdk@0.1.1","gitHead":"15170b167bb3db8d5b3b8c55e2e022c800668edc","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-CP2c2dgSF9SL/FYJAqhWH357npZq8oGttoEAQ2xMsvEocw6X/41NGoeXEdlVOtq2AOn1yKFO6SiYAYsbfjYNZA==","shasum":"87069cde62dba6275006b15a504bcf2e0d94cfad","tarball":"https://registry.npmjs.org/@ainote/sdk/-/sdk-0.1.1.tgz","fileCount":10,"unpackedSize":233259,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB+3tHggLjUkPTjvL1TJMyha+UEgrzgdyh36gJp1lseaAiEAq9Qkgm+RcVsv+vBGKKWtj1EWNp/nfRgd38NL/IYsIHM="}]},"_npmUser":{"name":"beast2025","email":"theqwe2000@gmail.com"},"directories":{},"maintainers":[{"name":"beast2025","email":"theqwe2000@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.1_1780957836288_0.4407881787045351"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-08T13:23:22.885Z","modified":"2026-06-08T22:30:36.564Z","0.1.0":"2026-06-08T13:23:23.289Z","0.1.1":"2026-06-08T22:30:36.435Z"},"bugs":{"url":"https://github.com/seunghan91/ainote/issues"},"author":{"name":"AI Note Team","email":"support@ainote.app"},"license":"MIT","homepage":"https://docs.ainote.dev/build/","keywords":["ainote","sdk","api-client","tasks","todo","mcp","productivity","typescript"],"repository":{"type":"git","url":"git+https://github.com/seunghan91/ainote.git","directory":"sdk"},"description":"TypeScript SDK for the ainote API — typed REST client for tasks, categories & papers, plus an MCP tool-mirror escape hatch for vault/sync.","maintainers":[{"name":"beast2025","email":"theqwe2000@gmail.com"}],"readme":"# @ainote/sdk\n\n[![npm version](https://img.shields.io/npm/v/@ainote/sdk.svg)](https://www.npmjs.com/package/@ainote/sdk)\n[![license](https://img.shields.io/npm/l/@ainote/sdk.svg)](./LICENSE)\n\nTypeScript SDK for [ainote](https://ainote.dev) — use ainote as a backend for your\nown app. Typed REST client for **tasks, categories, and papers**, plus an **MCP tool-mirror**\nescape hatch for vault & file-sync.\n\n- Zero runtime dependencies (uses the built-in `fetch`, Node ≥18)\n- ESM + CJS + `.d.ts`\n- Types generated from the live API spec, so they track the server contract\n\n```bash\nnpm install @ainote/sdk\n```\n\n## Quickstart\n\n```ts\nimport { AiNote } from '@ainote/sdk';\n\nconst ai = new AiNote({ apiKey: process.env.AINOTE_KEY! });\n\n// list (typed Task[])\nconst { data: tasks } = await ai.tasks.list({ is_important: true });\n\n// create → update → delete\nconst task = await ai.tasks.create({ content: 'Ship the SDK', due_date: '2026-06-10' });\nawait ai.tasks.update(task.id, { is_important: true });\nawait ai.tasks.delete(task.id);\n\n// iterate every task across pages\nfor await (const t of ai.tasks.listAll()) {\n  console.log(t.content);\n}\n```\n\n## Two audiences\n\n**1. App developers** — wrap ainote's typed REST surface (`ai.tasks`, `ai.categories`).\nStructured JSON in, typed objects out.\n\n**2. Sync-tool builders** — reach vault & file-sync via the MCP mirror. These tools\nreturn human-readable **text** plus **structured JSON**, surfaced honestly as\n`{ content, text, resources }`:\n\n```ts\nconst res = await ai.mcp.call('list_tasks', { limit: 1 });\nconsole.log(res.text);        // \"Found 1 tasks: ⏳ ...\"  (human)\n\n// convenience wrappers\nawait ai.vault.list();\nconst conflicts = await ai.sync.pendingConflicts();\nconst [data] = conflicts.resources; // parsed JSON (machine) — use this to build sync engines\nawait ai.sync.diff({ path: 'global/MEMORY.md' });\n```\n\n## Auth\n\nOne ainote key works for both surfaces — the SDK sends the right header per call\n(`Bearer` for REST, `McpKey` for MCP):\n\n```ts\nnew AiNote({ apiKey: '<your-key>' });               // both surfaces\nnew AiNote({ auth: { type: 'bearer', token } });    // REST + MCP (Bearer drives both)\nnew AiNote({ auth: { type: 'mcpKey', key } });      // MCP only\n```\n\nGet a key from your ainote account **Settings › MCP keys**, or mint one with no prior\nauth via the onboarding tools (`signup_and_get_key` / `login_and_get_key`) — see\n[docs.ainote.dev/build/auth](https://docs.ainote.dev/build/auth). Keep it server-side —\nit's account-wide access; never ship it in a browser bundle.\n\n## Error handling\n\nNon-2xx responses throw typed errors you can branch on:\n\n```ts\nimport { AuthError, NotFoundError, ValidationError, RateLimitError } from '@ainote/sdk';\n\n// sleep() and reauth() below are your app's helpers, not SDK exports.\ntry {\n  await ai.tasks.create({ content: '' });\n} catch (e) {\n  if (e instanceof ValidationError) console.log(e.fieldErrors);\n  else if (e instanceof RateLimitError) await sleep(e.retryAfterMs ?? 1000);\n  else if (e instanceof AuthError) reauth();\n}\n```\n\n**Retries:** only **idempotent** requests (`GET`/`HEAD`/`DELETE`) are auto-retried on\n429/5xx with backoff (configurable via `maxRetries`). Writes (`create`/`update`/`publish`)\nand MCP calls are **never** retried — retrying a committed POST/PATCH could duplicate data.\n\n**MCP errors:** MCP-mirror tool failures (`ai.mcp` / `ai.vault` / `ai.sync`) arrive as\nJSON-RPC errors inside an HTTP **200** body. The SDK still throws `AiNoteApiError`, but\nwith `status === 200` and `code` set to the JSON-RPC error code — so branch on the error\n**class**, not on `e.status >= 400`.\n\n## Options\n\n```ts\nnew AiNote({\n  apiKey,\n  baseUrl,      // default https://api.ainote.dev\n  userAgent,    // default @ainote/sdk/<version>\n  maxRetries,   // default 2\n  fetchImpl,    // inject a custom fetch (tests/proxies)\n});\n```\n\n## Status\n\nv0.1 covers **tasks, categories, and papers** (typed REST) plus the **vault/sync MCP\nmirror** (text + structured `resources`). Not yet wrapped: a `signup`/`login` onboarding\nhelper and \"Sign in with logi\" SSO (planned). See\n[docs.ainote.dev/build](https://docs.ainote.dev/build/).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}