{"_id":"@defaulthq/ai-tools","_rev":"3-403bd2078a88543c3800381dbc2d30bc","name":"@defaulthq/ai-tools","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@defaulthq/ai-tools","version":"0.1.0","license":"MIT","_id":"@defaulthq/ai-tools@0.1.0","maintainers":[{"name":"earldefault","email":"earl@default.com"}],"dist":{"shasum":"50f2ca6bd98204ccecbf493d9b12f6a297fc3a00","tarball":"https://registry.npmjs.org/@defaulthq/ai-tools/-/ai-tools-0.1.0.tgz","fileCount":8,"integrity":"sha512-xDhkbPOSWhwgy9hZMMBLCAtbVvT0ZoUnaFdt7r1EUG6pl5U4T7Tswoe2twIH3cG5rQUdRjQOpaOuVCZHkXfczA==","signatures":[{"sig":"MEUCIFw9GVWffhcMwHOkyE262kUYp/S25l2gJnYFgg2d8M2IAiEA9V7jEGAuY9+n/c9iK8d3aPJ834wCJd4fNpvJVurfuSk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39291},"main":"./dist/index.cjs","type":"module","_from":"file:defaulthq-ai-tools-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"tsc --noEmit && eslint src/ examples/","test":"TZ=UTC NODE_OPTIONS=--experimental-vm-modules jest","build":"tsup","lint:fix":"tsc --noEmit && eslint src/ examples/ --fix","typecheck":"tsc --noEmit","lint:staged":"eslint --fix --no-warn-ignored"},"_npmUser":{"name":"earldefault","email":"earl@default.com"},"_resolved":"/private/var/folders/mv/b8j6w26n3xg0q89lh6f56b9r0000gn/T/ccb900d8a06e5e20b55047594d70a00a/defaulthq-ai-tools-0.1.0.tgz","_integrity":"sha512-xDhkbPOSWhwgy9hZMMBLCAtbVvT0ZoUnaFdt7r1EUG6pl5U4T7Tswoe2twIH3cG5rQUdRjQOpaOuVCZHkXfczA==","_npmVersion":"11.6.2","description":"Vercel AI SDK tools for the Default public API","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","dependencies":{"zod":"^4.3.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ai":"^6.0.221","jest":"^30.0.0","tsup":"^8.3.5","ts-jest":"^29.4.11","typescript":"^5.7.3","@types/jest":"^30.0.0","@types/node":"^22","@workspace/eslint-config":"0.0.0","@workspace/typescript-config":"0.0.0"},"peerDependencies":{"ai":"^6.0.0 || ^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ai-tools_0.1.0_1787252198837_0.24442307058181112","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@defaulthq/ai-tools","version":"0.1.1","license":"MIT","_id":"@defaulthq/ai-tools@0.1.1","maintainers":[{"name":"earldefault","email":"earl@default.com"}],"dist":{"shasum":"5f50a4154f539813aeb80d830a26268e92175311","tarball":"https://registry.npmjs.org/@defaulthq/ai-tools/-/ai-tools-0.1.1.tgz","fileCount":8,"integrity":"sha512-UmJJ4efqULwpK5oXwKht5Hmu5cYtFiQdO+OCf6it1zZaC1fMA/FcJRma7jFMEShHoSE1ssy0iRY31YAL5O7/8A==","signatures":[{"sig":"MEYCIQDChy/3FnMvzm/DBq5gUAythsGkupaiFvhWHQoKNQNhAAIhAO5HNy7o3uncZWrwyO+6oMMkr95SJ4H7MWrZ7zYX2qtS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39357},"main":"./dist/index.cjs","type":"module","_from":"file:defaulthq-ai-tools-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"tsc --noEmit && eslint src/ examples/","test":"TZ=UTC NODE_OPTIONS=--experimental-vm-modules jest","build":"tsup","lint:fix":"tsc --noEmit && eslint src/ examples/ --fix","typecheck":"tsc --noEmit","lint:staged":"eslint --fix --no-warn-ignored"},"_npmUser":{"name":"earldefault","email":"earl@default.com"},"_resolved":"/private/var/folders/mv/b8j6w26n3xg0q89lh6f56b9r0000gn/T/3191dfb4f91a2eb4022b15c18707bb9c/defaulthq-ai-tools-0.1.1.tgz","_integrity":"sha512-UmJJ4efqULwpK5oXwKht5Hmu5cYtFiQdO+OCf6it1zZaC1fMA/FcJRma7jFMEShHoSE1ssy0iRY31YAL5O7/8A==","_npmVersion":"11.6.2","description":"Vercel AI SDK tools for the Default public API","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","dependencies":{"zod":"^4.3.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ai":"^6.0.221","jest":"^30.0.0","tsup":"^8.3.5","ts-jest":"^29.4.11","typescript":"^5.7.3","@types/jest":"^30.0.0","@types/node":"^22","@workspace/eslint-config":"0.0.0","@workspace/typescript-config":"0.0.0"},"peerDependencies":{"ai":"^6.0.0 || ^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ai-tools_0.1.1_1787252592033_0.4808754610716961","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@defaulthq/ai-tools","version":"0.2.0","description":"Vercel AI SDK tools for the Default public API","license":"MIT","type":"module","sideEffects":false,"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"},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"engines":{"node":">=22"},"peerDependencies":{"ai":"^6.0.0 || ^7.0.0"},"dependencies":{"zod":"^4.3.6"},"devDependencies":{"@types/jest":"^30.0.0","@types/node":"^22","ai":"^6.0.221","jest":"^30.0.0","ts-jest":"^29.4.11","tsup":"^8.3.5","typescript":"^5.7.3","@workspace/eslint-config":"0.0.0","@workspace/typescript-config":"0.0.0"},"scripts":{"build":"tsup","lint":"tsc --noEmit && eslint src/ examples/","lint:fix":"tsc --noEmit && eslint src/ examples/ --fix","lint:staged":"eslint --fix --no-warn-ignored","typecheck":"tsc --noEmit","test":"TZ=UTC NODE_OPTIONS=--experimental-vm-modules jest"},"_id":"@defaulthq/ai-tools@0.2.0","_integrity":"sha512-TVkyggRCtfBoD09ByFz75c7bSibxSe7w1s1JF7iViC4/ZEGecXIT0yDEk+HmtUwepDrrrrw8I57B+Pp41Jeotg==","_resolved":"/private/var/folders/mv/b8j6w26n3xg0q89lh6f56b9r0000gn/T/cbae9a07bcf2d320b19f91eeead97837/defaulthq-ai-tools-0.2.0.tgz","_from":"file:defaulthq-ai-tools-0.2.0.tgz","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-TVkyggRCtfBoD09ByFz75c7bSibxSe7w1s1JF7iViC4/ZEGecXIT0yDEk+HmtUwepDrrrrw8I57B+Pp41Jeotg==","shasum":"e368cb3b77756e5ca6432fd6e9e09b0c8e3fd1cd","tarball":"https://registry.npmjs.org/@defaulthq/ai-tools/-/ai-tools-0.2.0.tgz","fileCount":8,"unpackedSize":43194,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGKH+jVIcFgbSKSXOoDDEs033eOwoL4KMuby1mahby+VAiEA2NbX1+Qj/iMGpmTBq6qe9AR+VFh7jg+cAHXh9QiQIyo="}]},"_npmUser":{"name":"earldefault","email":"earl@default.com"},"directories":{},"maintainers":[{"name":"earldefault","email":"earl@default.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-tools_0.2.0_1788217613692_0.9489847321196692"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-20T18:56:38.667Z","modified":"2026-08-31T23:06:54.009Z","0.1.0":"2026-08-20T18:56:38.981Z","0.1.1":"2026-08-20T19:03:12.189Z","0.2.0":"2026-08-31T23:06:53.826Z"},"license":"MIT","description":"Vercel AI SDK tools for the Default public API","maintainers":[{"name":"earldefault","email":"earl@default.com"}],"readme":"# @defaulthq/ai-tools\n\nVercel AI SDK tools for the [Default public API](https://docs.os.default.com/api/route-and-book). Give an AI agent the ability to route a lead through a Default workflow and book a meeting on the calendar it picks.\n\nThis is a server-side package. The API key is a bearer credential and must never reach a browser.\n\n## Install\n\n```bash\nnpm install @defaulthq/ai-tools ai\n```\n\nRequires Node 22+ and `ai` v6 or v7 as a peer dependency.\n\n## Usage\n\n```ts\nimport { createDefaultTools } from '@defaulthq/ai-tools'\nimport { streamText } from 'ai'\n\nconst defaultTools = createDefaultTools({\n\tapiKey: process.env.DEFAULT_API_KEY,\n})\n\nstreamText({ model, messages, tools: { ...defaultTools } })\n```\n\nCreate an API key in **Settings** → **API Keys** with the `triggers:write` and `scheduling:write` permissions.\n\n## The tools\n\nThe core four mirror the [route and book flow](https://docs.os.default.com/api/route-and-book):\n\n1. `listTriggers` - discover trigger IDs and the form fields each one expects\n2. `fireTrigger` - submit a lead; the workflow routes them and returns an `outcome` (`scheduler`, `redirect`, or `none`)\n3. `getAvailableSlots` - open times for the `schedulingLinkId` from a scheduler outcome\n4. `bookMeeting` - book a slot, linking it back to the workflow via `workflowExecutionId`\n\nThe rest cover the full scheduling surface:\n\n- `listEvents` and `getEvent` - discover bookable events for direct booking without a workflow\n- `getMeeting` - fetch a meeting and its status\n- `getMeetingSlots` and `rescheduleMeeting` - move an existing meeting, no reservation needed\n- `cancelMeeting` - cancel with an optional reason\n\nResponse shapes are exported as types: `ListTriggersResponse`, `FireTriggerResponse`, `TriggerOutcome`, `SlotsResponse`, `PublicMeeting`, `ListEventsResponse`, `EventDetailsResponse`, `DefaultApiError`.\n\n## Errors\n\nAPI errors are returned as tool results (not thrown) so the model can read the code and recover:\n\n| Code | Recovery |\n| --- | --- |\n| `SLOT_TAKEN` | Call `getAvailableSlots` again with the same `reservationId`, pick another slot |\n| `RESERVATION_EXPIRED` | Request slots again for a fresh reservation |\n| `RESERVATION_USED` | An earlier booking attempt likely succeeded, do not book again |\n| `CONFLICT` on book | The scheduling session expired, fire the trigger again |\n| `WORK_EMAIL_REQUIRED` | Ask the lead for a work email address |\n| `RATE_LIMITED` | Wait `retryAfterSeconds` (limit is 30 requests per minute per key) |\n\nIf a book request times out without a response, the booking almost always succeeded. A retry\nreturns `CONFLICT`, `RESERVATION_USED`, or `RESERVATION_EXPIRED` and, with the same\n`workflowExecutionId`, can never create a second meeting for the same workflow run. Treat those\nerrors after a timeout as booked.\n\nEvery error is `{ error: { code, message, details? } }` - see `DefaultApiErrorCode` for the full list. Only transport failures (network down, non-JSON response) throw.\n\n## Example\n\n`examples/book-meeting.ts` runs the full flow with `generateText`:\n\n```bash\nDEFAULT_API_KEY=sk_... npx tsx examples/book-meeting.ts\n```\n\n## Releasing\n\nPublished manually. Bump `version`, add a CHANGELOG entry, then `pnpm publish` from this directory (`prepublishOnly` builds).\n","readmeFilename":"README.md"}