{"_id":"@abstime/sdk","name":"@abstime/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@abstime/sdk","version":"0.1.0","description":"AbsTime resolves natural language time expressions for AI systems. Built for agents, assistants, and workflows that need accurate time resolution.","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"}},"repository":{"type":"git","url":"git+https://github.com/abstime-ai/abstime-node.git"},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","lint":"eslint src tests","test":"node --test tests/*.test.js"},"keywords":["abstime","time","datetime","nlp","library"],"author":{"name":"AbsTime Team"},"license":"MIT","homepage":"https://abstime.ai","engines":{"node":">=18"},"devDependencies":{"@eslint/js":"^9.22.0","@types/node":"^20.11.0","eslint":"^9.22.0","globals":"^16.0.0","tsup":"^8.0.1","typescript-eslint":"^8.26.1","typescript":"^5.4.0"},"gitHead":"3a22518112b90f64ffb794c20bdcd19d91e60eea","_id":"@abstime/sdk@0.1.0","bugs":{"url":"https://github.com/abstime-ai/abstime-node/issues"},"_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-/+pli6ZowSzhBLOfu2vy6eg0cQuYFWOZGfoIDj7QLrmy5hFi0l2xmseL0C73hM9tjG/4RHsria4Tl5p2sDoGjQ==","shasum":"b36936c0a18ea458a7c916ec7e8cf9c7366c2fff","tarball":"https://registry.npmjs.org/@abstime/sdk/-/sdk-0.1.0.tgz","fileCount":7,"unpackedSize":42617,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIE0AFV0NgfHNwamOvWaIvHNpMxCVjezonfG2XcclLwf5AiABjum9FKfc4MsQXyqvFkNU18DZcGXqegwxfe5z4wT8jw=="}]},"_npmUser":{"name":"euvj","email":"weijinemail@gmail.com"},"directories":{},"maintainers":[{"name":"euvj","email":"weijinemail@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1775769300818_0.6780385034736203"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-09T21:15:00.707Z","0.1.0":"2026-04-09T21:15:00.961Z","modified":"2026-04-09T21:15:01.212Z"},"maintainers":[{"name":"euvj","email":"weijinemail@gmail.com"}],"description":"AbsTime resolves natural language time expressions for AI systems. Built for agents, assistants, and workflows that need accurate time resolution.","homepage":"https://abstime.ai","keywords":["abstime","time","datetime","nlp","library"],"repository":{"type":"git","url":"git+https://github.com/abstime-ai/abstime-node.git"},"author":{"name":"AbsTime Team"},"bugs":{"url":"https://github.com/abstime-ai/abstime-node/issues"},"license":"MIT","readme":"# AbsTime TypeScript and JavaScript API Library\r\n\r\nAbsTime resolves natural language time expressions for AI systems.\r\n\r\nBuilt for agents, assistants, and workflows that need accurate time resolution.\r\n\r\nThis library provides convenient access to the AbsTime REST API from TypeScript or JavaScript.\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install @abstime/sdk\r\n```\r\n\r\n## Quickstart\r\n\r\n```ts\r\nimport { AbsTime } from \"@abstime/sdk\";\r\n\r\nconst client = new AbsTime({ apiKey: process.env.ABSTIME_API_KEY });\r\n\r\nconst result = await client.resolve({\r\n  text: \"the last Friday of this month at 2 pm\",\r\n  refTime: \"2026-04-09T17:30:00Z\",\r\n  refTimezone: \"America/Los_Angeles\",\r\n});\r\n\r\nconsole.log(result.time);\r\nconsole.log(result.view);\r\n// 2026-04-24T21:00:00Z\r\n// Apr 24, 2026 2 PM\r\n```\r\n\r\n## Output\r\n\r\nThe core result fields are:\r\n\r\n| Field | Meaning | Example | Use |\r\n| --- | --- | --- | --- |\r\n| `time` | Resolved UTC timestamp | `2026-04-24T21:00:00Z` | Store, compare, or pass to downstream systems |\r\n| `view` | Human-readable local time | `Apr 24, 2026 2 PM` | Show the result in user interfaces |\r\n| `confidence` | Resolution confidence signal | `C0` | Guide result presentation and handling |\r\n\r\nUnderstand `confidence`:\r\n- `C0`: a clear resolution; safe to use directly.\r\n- `C1`: less obvious but the most reasonable resolution; still safe to use directly.\r\n- `C2`: sometimes arguable; user confirmation is recommended.\r\n\r\n## Input\r\n\r\nThe core input fields are:\r\n\r\n| Field | Meaning | Use | Instead of |\r\n| --- | --- | --- | --- |\r\n| `text` | Natural language time expression | `two days before Christmas` | `Schedule a meeting with Lily two days before Christmas.` |\r\n| `refTime` | UTC reference time | `2026-04-09T17:30:00Z` | `2026-04-09T10:30:00-07:00` |\r\n| `refTimezone` | IANA reference timezone | `America/Los_Angeles` | `PST` |\r\n\r\n## Handling Errors\r\n\r\nWhen the library is unable to connect to the API, for example due to a network failure or timeout, an `abstime.APIConnectionError` is thrown.\r\n\r\nWhen the API returns a non-success status code, a subclass of `abstime.AbsTimeError` is thrown.\r\n\r\n```ts\r\nimport * as abstime from \"@abstime/sdk\";\r\n\r\nconst client = new abstime.AbsTime();\r\n\r\ntry {\r\n  await client.resolve({\r\n    text: \"the last Friday of this month at 2 pm\",\r\n    refTime: \"2026-04-09T17:30:00Z\",\r\n    refTimezone: \"America/Los_Angeles\",\r\n  });\r\n} catch (err) {\r\n  if (err instanceof abstime.InputError) {\r\n    console.log(`Invalid input: ${err.message}`);\r\n  } else if (err instanceof abstime.RateLimitError) {\r\n    console.log(`Request ID: ${err.requestId}`);\r\n  } else if (err instanceof abstime.APIConnectionError) {\r\n    console.log(\"The API could not be reached.\");\r\n  }\r\n}\r\n```\r\n\r\nError codes are as follows:\r\n\r\n| Status Code | Error |\r\n| --- | --- |\r\n| `400` | `InputError` |\r\n| `401` | `AuthenticationError` |\r\n| `403` | `PermissionDeniedError` |\r\n| `429` | `RateLimitError` |\r\n| `>=500` | `InternalError` |\r\n| `N/A` | `APIConnectionError` |\r\n\r\n## Request IDs\r\n\r\nAll successful responses provide a `requestId` from the `X-Request-Id` response header.\r\n\r\n```ts\r\nconsole.log(result.requestId);\r\n```\r\n\r\nFor failed requests, catch the error and read `err.requestId`:\r\n\r\n```ts\r\nimport * as abstime from \"@abstime/sdk\";\r\n\r\ntry {\r\n  await client.resolve({\r\n    text: \"the last Friday of this month at 2 pm\",\r\n    refTime: \"2026-04-09T17:30:00Z\",\r\n    refTimezone: \"America/Los_Angeles\",\r\n  });\r\n} catch (err) {\r\n  if (err instanceof abstime.AbsTimeError) {\r\n    console.log(err.requestId);\r\n  }\r\n}\r\n```\r\n\r\n## Retries and Timeouts\r\n\r\nThe client retries certain transient failures once by default with a short backoff.\r\n\r\nRequests time out after 15 seconds by default.\r\n\r\nYou can configure both when creating the client.\r\n\r\n```ts\r\nconst client = new AbsTime({\r\n  timeout: 5000,\r\n  maxRetries: 0,\r\n});\r\n```\r\n\r\n## Requirements\r\n\r\n- Node.js 18+\r\n\r\n## Docs\r\n\r\nSee [docs.abstime.ai](https://docs.abstime.ai) for the full API contract, response details, and integration guides.\r\n","readmeFilename":"README.md","_rev":"1-351ea32c01824091e3b6fcc06525a47b"}