{"_id":"agnostai","_rev":"4-815ad51a7c4726a39c6ed42d361cee36","name":"agnostai","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"agnostai","version":"0.1.0","keywords":["agnost","ai","agent","conversation","tracking","analytics","llm","observability"],"author":{"name":"Agnost AI","email":"founders@agnost.ai"},"license":"MIT","_id":"agnostai@0.1.0","maintainers":[{"name":"prrthh132","email":"ajmeraparth132@gmail.com"}],"homepage":"https://agnost.ai","bugs":{"url":"https://github.com/agnost-ai/agnost-ai/issues"},"dist":{"shasum":"f8ddcaa42e7fbf61629bbd00c46dddf72d4d2020","tarball":"https://registry.npmjs.org/agnostai/-/agnostai-0.1.0.tgz","fileCount":8,"integrity":"sha512-43eN4kyL3GuPjRFkLDBB2HduG2C8o4xsyEaae4zZFv5E33KSXd4Kfx6a6Cv46Im9fHGav7f9TBV7JBsDQ1w5FQ==","signatures":[{"sig":"MEUCIE7XkFWHRNismTgjHBrTSU9hzPKj1t5PiO0nj3QnMbtQAiEAzwaO59VUuR2gqWqgfZEEP0k+hRzlDK/Mgr1I3/IkrBU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":165875},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"2d606cd6822981364af9bfb11c9e903f2dd71407","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","clean":"rm -rf dist","test:run":"vitest run","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"prrthh132","email":"ajmeraparth132@gmail.com"},"repository":{"url":"git+https://github.com/agnost-ai/agnost-ai.git","type":"git"},"_npmVersion":"10.9.2","description":"Agnost Conversation SDK for TypeScript - Track AI agent conversations with automatic latency measurement","directories":{},"_nodeVersion":"23.11.0","dependencies":{"uuid":"^9.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/uuid":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/agnostai_0.1.0_1772654088016_0.006829382238425108","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"agnostai","version":"0.1.1","keywords":["agnost","ai","agent","conversation","tracking","analytics","llm","observability"],"author":{"name":"Agnost AI","email":"founders@agnost.ai"},"license":"MIT","_id":"agnostai@0.1.1","maintainers":[{"name":"prrthh132","email":"ajmeraparth132@gmail.com"}],"homepage":"https://agnost.ai","bugs":{"url":"https://github.com/agnost-ai/agnost-ai/issues"},"dist":{"shasum":"5f34eaaed0b637e73e78afef7a5d28497faded82","tarball":"https://registry.npmjs.org/agnostai/-/agnostai-0.1.1.tgz","fileCount":8,"integrity":"sha512-nAbehh1pM8MEzn3Ym+hJoDjWIinLhhfVL5zfiXv3iteYozqpt1A3/axklbvZA1AGkaEY5JWgc3gAO938kXTg3w==","signatures":[{"sig":"MEUCIHShg7hM0HUSDiW4fuBOmJP+1pPlviZ6Js4t8jHtonIDAiEAjnM66CLfxoI3sm4UXTKnUwpuFa41ZnSehzignL/9zRc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":165763},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"2fa51077c14fea94146047d9ec3bf9b662a46441","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","clean":"rm -rf dist","test:run":"vitest run","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"prrthh132","email":"ajmeraparth132@gmail.com"},"repository":{"url":"git+https://github.com/agnost-ai/agnost-ai.git","type":"git"},"_npmVersion":"10.9.2","description":"Agnost Conversation SDK for TypeScript - Track AI agent conversations with automatic latency measurement","directories":{},"_nodeVersion":"23.11.0","dependencies":{"uuid":"^9.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/uuid":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/agnostai_0.1.1_1772654249059_0.6564179834341479","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"agnostai","version":"0.1.2","keywords":["agnost","ai","agent","conversation","tracking","analytics","llm","observability"],"author":{"name":"Agnost AI","email":"founders@agnost.ai"},"license":"MIT","_id":"agnostai@0.1.2","maintainers":[{"name":"prrthh132","email":"ajmeraparth132@gmail.com"}],"homepage":"https://agnost.ai","bugs":{"url":"https://github.com/agnost-ai/agnost-ai/issues"},"dist":{"shasum":"24a19db193a62c05392031e3c084cf4a521c2e29","tarball":"https://registry.npmjs.org/agnostai/-/agnostai-0.1.2.tgz","fileCount":8,"integrity":"sha512-BpXHRNpNQSXF2WUXeTX1HirSg055BHBo9Kg7/ffkQxbUeMF/DXRzkVoCeUVsYY9EkYBa5H/21QxvQ9YEgtEGJg==","signatures":[{"sig":"MEUCICpJjy07XbXvH+oXfw3GfXj93vNJWfC8UTlcbD8a/53DAiEAqR6RkDpi+uXsY9F6Ddl8gGo9+U18TdJ9h/2UnPGzDDQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":172170},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"2fa51077c14fea94146047d9ec3bf9b662a46441","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest","build":"tsup","clean":"rm -rf dist","test:run":"vitest run","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"prrthh132","email":"ajmeraparth132@gmail.com"},"repository":{"url":"git+https://github.com/agnost-ai/agnost-ai.git","type":"git"},"_npmVersion":"10.9.2","description":"Agnost Conversation SDK for TypeScript - Track AI agent conversations with automatic latency measurement","directories":{},"_nodeVersion":"23.11.0","dependencies":{"uuid":"^9.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/uuid":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/agnostai_0.1.2_1772657469905_0.750278186118162","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"agnostai","version":"0.2.0","description":"Agnost Conversation SDK for TypeScript - Track AI agent conversations with automatic latency measurement","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest","test:run":"vitest run","typecheck":"tsc --noEmit","clean":"rm -rf dist","prepublishOnly":"npm run build"},"keywords":["agnost","ai","agent","conversation","tracking","analytics","llm","observability"],"author":{"name":"Agnost AI","email":"founders@agnost.ai"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/agnost-ai/agnost-ai.git"},"bugs":{"url":"https://github.com/agnost-ai/agnost-ai/issues"},"homepage":"https://agnost.ai","dependencies":{"uuid":"^14.0.0"},"devDependencies":{"@types/node":"^20.0.0","@types/uuid":"^9.0.0","tsup":"^8.0.0","typescript":"^5.0.0","vitest":"^4.0.18"},"engines":{"node":">=18.0.0"},"_id":"agnostai@0.2.0","gitHead":"cab26d29876d709e00ecdaecd747c43188e346fb","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-8ir37phVHrvAG2utbW0BY3/NHflWnhobxsoYUInAay/h8RfA/4hDSnRr8UrhCERGdiwNvVOVEdrthWx5NOvyRQ==","shasum":"d858f6d096ebfb362f30250b6e7e26674f00ea45","tarball":"https://registry.npmjs.org/agnostai/-/agnostai-0.2.0.tgz","fileCount":6,"unpackedSize":50924,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCNDcDJ9XHFXYE8WC+a6O9JhFPgLtzM+p2p9d0DqxGFrQIgGJjhSmGA+MRIbatCtKmYlcD7SeBh3wnQEmCTUz+haJ8="}]},"_npmUser":{"name":"prrthh132","email":"ajmeraparth132@gmail.com"},"directories":{},"maintainers":[{"name":"prrthh132","email":"ajmeraparth132@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agnostai_0.2.0_1783796563696_0.9391728570123925"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-04T19:54:48.015Z","modified":"2026-07-11T19:02:43.999Z","0.1.0":"2026-03-04T19:54:48.198Z","0.1.1":"2026-03-04T19:57:29.209Z","0.1.2":"2026-03-04T20:51:10.049Z","0.2.0":"2026-07-11T19:02:43.912Z"},"bugs":{"url":"https://github.com/agnost-ai/agnost-ai/issues"},"author":{"name":"Agnost AI","email":"founders@agnost.ai"},"license":"MIT","homepage":"https://agnost.ai","keywords":["agnost","ai","agent","conversation","tracking","analytics","llm","observability"],"repository":{"type":"git","url":"git+https://github.com/agnost-ai/agnost-ai.git"},"description":"Agnost Conversation SDK for TypeScript - Track AI agent conversations with automatic latency measurement","maintainers":[{"name":"prrthh132","email":"ajmeraparth132@gmail.com"}],"readme":"# Agnost Conversation SDK for TypeScript\n\n[![npm version](https://badge.fury.io/js/agnostai.svg)](https://badge.fury.io/js/agnostai)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)\n\nTypeScript/JavaScript SDK for tracking AI conversations and events. Monitor your AI agent interactions, track user conversations, and gain insights into how your AI applications are performing.\n\n## Installation\n\n```bash\nnpm install agnostai\n```\n\n## Basic Usage\n\n```typescript\nimport * as agnost from 'agnostai';\n\n// Initialize with your organization ID\nagnost.init('your-org-id');\n\n// Begin an AI interaction\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'weather-agent',\n  input: 'What is the weather?'\n});\n\n// ... do async work ...\n\n// Complete the interaction (latency auto-calculated)\ninteraction.end('The weather is sunny.');\n```\n\n## API Reference\n\n### `init(writeKey, config?)`\n\nInitialize the SDK with your organization ID.\n\n```typescript\nagnost.init('your-org-id');\n\n// With custom configuration\nagnost.init('your-org-id', {\n  endpoint: 'https://api.agnost.ai',\n  debug: true\n});\n```\n\n### `identify(userId, traits)`\n\nAssociate user characteristics with a user ID.\n\n```typescript\nagnost.identify('user_123', {\n  name: 'John Doe',\n  email: 'john@example.com',\n  age: 30,\n  plan: 'paid'\n});\n```\n\n### `begin(options)`\n\nBegin a partial interaction for deferred completion. Use this when the output is not immediately available.\n\n**Automatic latency tracking** - Latency is automatically calculated from `begin()` to `end()`!\n\n```typescript\n// Pass input directly (recommended)\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'weather-agent',\n  input: 'What is the weather?'\n});\n\ninteraction.setProperty('temperature', '0.7');\n\n// ... do async work ...\n\ninteraction.end('The weather is sunny.');\n// Latency automatically calculated! (~duration from begin to end)\n```\n\n**Alternative: Set input later:**\n```typescript\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'weather-agent'\n});\ninteraction.setInput('What is the weather?');\ninteraction.end('The weather is sunny.');\n```\n\n**Manual latency override (optional):**\n```typescript\ninteraction.end(\n  'The weather is sunny.',\n  true,   // success\n  1500    // Override auto-calculation if needed\n);\n```\n\n**BeginOptions:**\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `userId` | `string` | Yes | User identifier |\n| `agentName` | `string` | Yes | Agent name |\n| `input` | `string` | No | Input text/prompt (can be set later) |\n| `conversationId` | `string` | No | Conversation ID for grouping (auto-generated if not provided) |\n| `properties` | `object` | No | Additional event properties |\n| `event` | `string` | No | Optional event name |\n| `interactionId` | `string` | No | Custom interaction ID (auto-generated if not provided). Useful for retrieving the interaction later with `getInteraction()` |\n\n**Interaction Methods:**\n\n| Method | Description |\n|--------|-------------|\n| `setInput(text)` | Set the input text (optional if passed to `begin()`) |\n| `setProperties(obj)` | Set multiple properties |\n| `setProperty(key, value)` | Set a single property |\n| `end(output, success?, latency?)` | Complete the interaction. **When `success=false`, `output` is the error message.** Latency is auto-calculated if not provided |\n\n### `getInteraction(interactionId)`\n\nRetrieve an active interaction by its ID. Useful when you need to complete an interaction from a different context (e.g., callback, different function) without passing the Interaction object around.\n\n```typescript\n// In your request handler\nfunction handleRequest(requestId: string, userMessage: string) {\n  agnost.begin({\n    userId: 'user_123',\n    agentName: 'chat-agent',\n    input: userMessage,\n    interactionId: requestId  // Use your own ID\n  });\n\n  // Pass only the ID to your AI service\n  callAIService(requestId, userMessage);\n}\n\n// Later, in a callback or different function\nfunction onAIResponse(requestId: string, response: string) {\n  const interaction = agnost.getInteraction(requestId);\n  if (interaction) {\n    interaction\n      .setProperty('model', 'gpt-4')\n      .setProperty('tokens', 250)\n      .end(response);\n  }\n}\n```\n\nReturns `null` if the interaction is not found or has already been completed.\n\n### `flush()`\n\nManually flush all queued events.\n\n```typescript\nawait agnost.flush();\n```\n\n### `shutdown()`\n\nShutdown the SDK and flush remaining events.\n\n```typescript\nawait agnost.shutdown();\n```\n\n### `setDebugLogs(enabled)`\n\nEnable or disable debug logging.\n\n```typescript\nagnost.setDebugLogs(true);  // See queued events\n```\n\n## Configuration\n\nYou can customize the SDK behavior using the configuration object:\n\n```typescript\nimport * as agnost from 'agnostai';\nimport { ConversationConfig } from 'agnostai';\n\n// Create a custom configuration\nconst config: ConversationConfig = {\n  endpoint: 'https://api.agnost.ai',\n  debug: false\n};\n\n// Apply the configuration\nagnost.init('your-org-id', config);\n```\n\n### Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `endpoint` | `string` | `\"https://api.agnost.ai\"` | API endpoint URL |\n| `debug` | `boolean` | `false` | Enable debug logging |\n\n## Advanced Usage\n\n### Conversation Tracking\n\nGroup related events using `conversationId`:\n\n```typescript\nimport { v4 as uuidv4 } from 'uuid';\n\nconst conversationId = `conv_${uuidv4()}`;\n\n// First message\nconst turn1 = agnost.begin({\n  userId: 'user_123',\n  agentName: 'support-bot',\n  input: 'Hello!',\n  conversationId\n});\nturn1.end('Hi there! How can I help?');\n\n// Follow-up message\nconst turn2 = agnost.begin({\n  userId: 'user_123',\n  agentName: 'support-bot',\n  input: \"What's the weather?\",\n  conversationId\n});\nturn2.end('The weather is sunny.');\n```\n\n### Direct Client Instantiation\n\nFor multiple clients or advanced use cases:\n\n```typescript\nimport { ConversationClient } from 'agnostai';\n\nconst client = new ConversationClient();\nclient.init('your-org-id');\n\nconst interaction = client.begin({\n  userId: 'user_123',\n  agentName: 'greeting-bot',\n  input: 'Hello!'\n});\n\ninteraction.end('Hello! How can I help you today?');\n\nawait client.shutdown();\n```\n\n### Error Handling\n\nWhen tracking errors, set `success=false` and pass the error message as the `output`:\n\n```typescript\n// With begin() and end()\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'image-agent',\n  input: 'Generate an image'\n});\n\ntry {\n  const result = await generateImage();\n  interaction.end(result);\n} catch (error) {\n  // Error message goes in output when success=false\n  interaction.end(error.message, false);\n}\n```\n\n### Chainable Property Setting\n\n```typescript\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'chat-agent',\n  input: 'Tell me a story'\n});\n\n// Chain multiple property setters\ninteraction\n  .setProperty('model', 'gpt-4')\n  .setProperty('temperature', '0.9')\n  .setProperty('max_tokens', '2000')\n  .setProperties({\n    genre: 'fantasy',\n    length: 'short'\n  });\n\n// ... generate story ...\n\ninteraction.end('Once upon a time...');\n```\n\n### Deferred Input Setting\n\nSometimes you might not know the input until after beginning the interaction:\n\n```typescript\nconst interaction = agnost.begin({\n  userId: 'user_123',\n  agentName: 'dynamic-agent'\n});\n\n// Collect user input later\nconst userInput = await getUserInput();\ninteraction.setInput(userInput);\n\n// Process and complete\nconst response = await processInput(userInput);\ninteraction.end(response);\n```\n\n## TypeScript Support\n\nThis SDK is written in TypeScript and provides full type definitions:\n\n```typescript\nimport * as agnost from 'agnostai';\nimport {\n  ConversationClient,\n  ConversationConfig,\n  BeginOptions,\n  Interaction,\n  UserTraits,\n  EventProperties\n} from 'agnostai';\n\n// All types are available for use\nconst options: BeginOptions = {\n  userId: 'user_123',\n  agentName: 'my-agent',\n  input: 'Hello'\n};\n\nconst traits: UserTraits = {\n  name: 'John',\n  email: 'john@example.com'\n};\n\nconst config: ConversationConfig = {\n  endpoint: 'https://api.agnost.ai',\n  debug: true\n};\n```\n\n## Browser Support\n\nThis SDK works in both Node.js and browser environments. It uses the native `fetch` API which is available in:\n\n- Node.js 18+\n- All modern browsers\n\nFor older Node.js versions, you may need to install a fetch polyfill.\n\n## Contact\n\nFor support or questions, contact the founders: [founders@agnost.ai](mailto:founders@agnost.ai)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}