{"_id":"@botdojo/sdk-types","name":"@botdojo/sdk-types","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@botdojo/sdk-types","version":"0.1.1","description":"Shared TypeScript types for BotDojo SDK and Canvas Client","license":"MIT","main":"lib/index.js","types":"lib/index.d.ts","exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.js","require":"./lib/index.js"}},"devDependencies":{"@types/node":"^20.0.0","ts-node":"^10.9.2","typescript":"5.4.5"},"publishConfig":{"access":"public"},"scripts":{"sync-backend-types":"node scripts/sync-backend-types.js","sync-tool-response-mapper":"node scripts/sync-tool-response-mapper.js","sync-model-context-translation":"node scripts/sync-model-context-translation.js","watch-tool-response-mapper":"node scripts/watch-tool-response-mapper.js","prebuild":"pnpm sync-backend-types && pnpm sync-tool-response-mapper && pnpm sync-model-context-translation","build":"tsc","dev":"pnpm sync-tool-response-mapper && (pnpm watch-tool-response-mapper & tsc --watch)","clean":"rm -rf lib","test":"tsc --noEmit"},"_id":"@botdojo/sdk-types@0.1.1","_integrity":"sha512-ADNKEA/yyAf2hKo9rzcBL8fb/2FBpKUnmFqlaYqx6jK90iF68TMimsRH+ZNa/kHpDGRBAEatn70kDnve9a+olQ==","_resolved":"/private/var/folders/cs/j5zd7gjj1ls7xjz695jm_njm0000gn/T/9aa3d6c49c473510f6ddb724edc6c026/botdojo-sdk-types-0.1.1.tgz","_from":"file:botdojo-sdk-types-0.1.1.tgz","_nodeVersion":"18.20.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-ADNKEA/yyAf2hKo9rzcBL8fb/2FBpKUnmFqlaYqx6jK90iF68TMimsRH+ZNa/kHpDGRBAEatn70kDnve9a+olQ==","shasum":"5547e655d7fc28644dbed341700c8b1eb7315286","tarball":"https://registry.npmjs.org/@botdojo/sdk-types/-/sdk-types-0.1.1.tgz","fileCount":35,"unpackedSize":126455,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFT1r+Ql/7wDz+QQZ8iV+gm+kjcRY3OBMGwT7t0MMpR3AiAlHWbrS7fFITn2744k+Wzn93tmiSTewzZtUayajzpZNw=="}]},"_npmUser":{"name":"botdojo-ai","email":"paul@botdojo.com"},"directories":{},"maintainers":[{"name":"botdojo-ai","email":"paul@botdojo.com"},{"name":"hunain.zubair","email":"hunain.zubair@botdojo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk-types_0.1.1_1765024483580_0.5909375485383679"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-06T12:34:43.517Z","0.1.1":"2025-12-06T12:34:43.800Z","modified":"2025-12-06T12:34:45.561Z"},"maintainers":[{"name":"botdojo-ai","email":"paul@botdojo.com"},{"name":"hunain.zubair","email":"hunain.zubair@botdojo.com"}],"description":"Shared TypeScript types for BotDojo SDK and Canvas Client","license":"MIT","readme":"# botdojo-sdk-types\n\nShared TypeScript type definitions for BotDojo SDK and Canvas Client.\n\n## Purpose\n\nThis package contains pure TypeScript type definitions with no JSX or React dependencies. It provides common types used across:\n\n- `@botdojo/sdk` - BotDojo SDK for running flows via API\n- `botdojo-canvas-client` - Canvas client with React components\n- Other BotDojo packages\n\n## Why a Separate Package?\n\nBy separating types into their own package, we avoid requiring JSX configuration in projects that only need type definitions. This makes it easier to use BotDojo types in any TypeScript project.\n\n## Installation\n\n```bash\nnpm install botdojo-sdk-types\n# or\npnpm add botdojo-sdk-types\n```\n\n## Usage\n\n```typescript\nimport type { ModelContext, ToolDefinition, ToolResponse } from 'botdojo-sdk-types';\n\nconst myContext: ModelContext = {\n  name: 'my-tools',\n  description: 'My custom tools',\n  tools: [\n    {\n      name: 'getThing',\n      description: 'Gets a thing',\n      inputSchema: {\n        type: 'object',\n        properties: {\n          id: { type: 'string' }\n        }\n      }\n    }\n  ]\n};\n```\n\n## Exported Types\n\n### Core Types\n- `ModelContext` - Model context definition\n- `ToolDefinition` - Tool definition with parameters\n- `ToolResponse` - Rich tool response with actions\n- `ToolResponseAction` - Actions that can be performed\n- `ConnectorToolCalls` - Tool handler functions\n\n### Legacy/Deprecated Types\n- `CanvasModelContext` - Use `ModelContext` instead\n- `CanvasModelContextTool` - Use `ToolDefinition` instead\n- `MCPModelContext` - Use `ModelContext` instead\n- `MCPToolHandlers` - Use `ConnectorToolCalls` instead\n\n### Flow Types\n- `FlowRequestOptions` - Options for flow requests\n- `FlowRequestBody` - Flow request body\n- `FlowResponse` - Flow response data\n\n## Build-Time Sync Mechanism\n\nThis package uses a **build-time sync** approach to avoid circular dependencies while keeping implementations in sync with `botdojo-core`.\n\n### What Gets Synced\n\n1. **Backend Type Validation** (`backend-types-snapshot.ts`)\n   - Synced from `botdojo-sdk-backend-types`\n   - Used for type validation only\n   - No runtime dependency\n\n2. **Tool Response Mapper** (`toolResponseMapper-snapshot.ts`)\n   - Synced from `botdojo-core/src/utils/toolResponseMapper.ts`\n   - Converts SDK ToolResponse format to backend IToolResponse format\n   - Single source of truth in botdojo-core\n\n### How It Works\n\n**During Build:**\n```bash\n# prebuild hook automatically runs before build\npnpm build  # Internally: sync-backend-types → sync-tool-response-mapper → tsc\n```\n\n**During Development:**\n```bash\n# dev mode syncs once, then watches for changes\npnpm dev  # Internally: sync → (watch-tool-response-mapper & tsc --watch)\n```\n\nThe file watcher automatically re-syncs when `botdojo-core/src/utils/toolResponseMapper.ts` changes during development.\n\n### Manual Sync\n\nIf you need to manually sync:\n```bash\npnpm sync-backend-types          # Sync backend types\npnpm sync-tool-response-mapper   # Sync tool response mapper\n```\n\n### Build Order Requirements\n\nFor CI/CD or fresh builds:\n```bash\n# Correct order:\npnpm --filter botdojo-core build              # 1. Core types and utils\npnpm --filter botdojo-sdk-backend-types build # 2. Backend type exports\npnpm --filter @botdojo/sdk-types build        # 3. SDK types (syncs during prebuild)\n```\n\nThe workspace build system (Turbo) handles this automatically via dependency order.\n\n### Why This Approach?\n\n- ✅ **Avoids circular dependencies** - No runtime dependency on botdojo-core\n- ✅ **Single source of truth** - Logic lives in botdojo-core\n- ✅ **Type safety** - Still validates against backend types\n- ✅ **Dev experience** - Auto-syncs during development\n- ✅ **Simple** - Just build scripts, no complex tooling\n\nSee `BACKEND_TYPES.md` for more details on the architecture.\n\n## License\n\nMIT\n\n\n\n\n\n","readmeFilename":"README.md","_rev":"1-c067d3b5d120b375835c9dd6dfcf94ad"}