@sixthsummit/ship-api 0.0.0-stage → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +605 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +58 -2
- package/cli/commands/add.js +537 -0
- package/cli/commands/contract.js +2 -0
- package/cli/commands/create.js +250 -0
- package/cli/commands/dev.js +227 -0
- package/cli/commands/doctor.js +286 -0
- package/cli/commands/generate.js +937 -0
- package/cli/commands/graph.js +2 -0
- package/cli/commands/migrate-orm.js +1171 -0
- package/cli/commands/update.js +37 -0
- package/cli/ship-api.js +285 -0
- package/lib/app/auth/AuthProvider.d.ts +91 -0
- package/lib/app/auth/AuthProvider.d.ts.map +1 -0
- package/lib/app/auth/AuthProvider.js +13 -0
- package/lib/app/auth/AuthProvider.js.map +1 -0
- package/lib/app/auth/adapters/firebase.d.ts +79 -0
- package/lib/app/auth/adapters/firebase.d.ts.map +1 -0
- package/lib/app/auth/adapters/firebase.js +122 -0
- package/lib/app/auth/adapters/firebase.js.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts +55 -0
- package/lib/app/auth/adapters/jwtCookie.d.ts.map +1 -0
- package/lib/app/auth/adapters/jwtCookie.js +120 -0
- package/lib/app/auth/adapters/jwtCookie.js.map +1 -0
- package/lib/app/auth/index.d.ts +8 -0
- package/lib/app/auth/index.d.ts.map +1 -0
- package/lib/app/auth/index.js +7 -0
- package/lib/app/auth/index.js.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts +94 -0
- package/lib/app/auth/jwt/AuthFlow.d.ts.map +1 -0
- package/lib/app/auth/jwt/AuthFlow.js +127 -0
- package/lib/app/auth/jwt/AuthFlow.js.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts +80 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js +134 -0
- package/lib/app/auth/jwt/DrizzleRefreshTokenStore.js.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts +123 -0
- package/lib/app/auth/jwt/JwtSigner.d.ts.map +1 -0
- package/lib/app/auth/jwt/JwtSigner.js +118 -0
- package/lib/app/auth/jwt/JwtSigner.js.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts +97 -0
- package/lib/app/auth/jwt/RefreshTokenStore.d.ts.map +1 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js +122 -0
- package/lib/app/auth/jwt/RefreshTokenStore.js.map +1 -0
- package/lib/app/auth/permissionDefinition.d.ts +20 -0
- package/lib/app/auth/permissionDefinition.d.ts.map +1 -0
- package/lib/app/auth/permissionDefinition.js +2 -0
- package/lib/app/auth/permissionDefinition.js.map +1 -0
- package/lib/app/context/RequestContext.d.ts +59 -0
- package/lib/app/context/RequestContext.d.ts.map +1 -0
- package/lib/app/context/RequestContext.js +25 -0
- package/lib/app/context/RequestContext.js.map +1 -0
- package/lib/app/db/QueryOptions.d.ts +82 -0
- package/lib/app/db/QueryOptions.d.ts.map +1 -0
- package/lib/app/db/QueryOptions.js +37 -0
- package/lib/app/db/QueryOptions.js.map +1 -0
- package/lib/app/db/baseFields.d.ts +60 -0
- package/lib/app/db/baseFields.d.ts.map +1 -0
- package/lib/app/db/baseFields.js +54 -0
- package/lib/app/db/baseFields.js.map +1 -0
- package/lib/app/db/buildWhere.d.ts +22 -0
- package/lib/app/db/buildWhere.d.ts.map +1 -0
- package/lib/app/db/buildWhere.js +75 -0
- package/lib/app/db/buildWhere.js.map +1 -0
- package/lib/app/db/client.d.ts +111 -0
- package/lib/app/db/client.d.ts.map +1 -0
- package/lib/app/db/client.js +99 -0
- package/lib/app/db/client.js.map +1 -0
- package/lib/app/db/tenantScoped.d.ts +59 -0
- package/lib/app/db/tenantScoped.d.ts.map +1 -0
- package/lib/app/db/tenantScoped.js +54 -0
- package/lib/app/db/tenantScoped.js.map +1 -0
- package/lib/app/db/transaction.d.ts +58 -0
- package/lib/app/db/transaction.d.ts.map +1 -0
- package/lib/app/db/transaction.js +106 -0
- package/lib/app/db/transaction.js.map +1 -0
- package/lib/app/health/HealthCheck.d.ts +121 -0
- package/lib/app/health/HealthCheck.d.ts.map +1 -0
- package/lib/app/health/HealthCheck.js +151 -0
- package/lib/app/health/HealthCheck.js.map +1 -0
- package/lib/app/health/redisHealthCheck.d.ts +14 -0
- package/lib/app/health/redisHealthCheck.d.ts.map +1 -0
- package/lib/app/health/redisHealthCheck.js +21 -0
- package/lib/app/health/redisHealthCheck.js.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts +92 -0
- package/lib/app/lifecycle/Bootstrapper.d.ts.map +1 -0
- package/lib/app/lifecycle/Bootstrapper.js +99 -0
- package/lib/app/lifecycle/Bootstrapper.js.map +1 -0
- package/lib/app/registry/routes.d.ts +89 -0
- package/lib/app/registry/routes.d.ts.map +1 -0
- package/lib/app/registry/routes.js +72 -0
- package/lib/app/registry/routes.js.map +1 -0
- package/lib/app/services/DrizzleEntityService.d.ts +123 -0
- package/lib/app/services/DrizzleEntityService.d.ts.map +1 -0
- package/lib/app/services/DrizzleEntityService.js +342 -0
- package/lib/app/services/DrizzleEntityService.js.map +1 -0
- package/lib/app/services/RedisProvider.d.ts +52 -0
- package/lib/app/services/RedisProvider.d.ts.map +1 -0
- package/lib/app/services/RedisProvider.js +75 -0
- package/lib/app/services/RedisProvider.js.map +1 -0
- package/lib/app/services/cache/Cache.d.ts +70 -0
- package/lib/app/services/cache/Cache.d.ts.map +1 -0
- package/lib/app/services/cache/Cache.js +18 -0
- package/lib/app/services/cache/Cache.js.map +1 -0
- package/lib/app/services/cache/InMemoryCache.d.ts +35 -0
- package/lib/app/services/cache/InMemoryCache.d.ts.map +1 -0
- package/lib/app/services/cache/InMemoryCache.js +76 -0
- package/lib/app/services/cache/InMemoryCache.js.map +1 -0
- package/lib/app/services/cache/RedisCache.d.ts +99 -0
- package/lib/app/services/cache/RedisCache.d.ts.map +1 -0
- package/lib/app/services/cache/RedisCache.js +150 -0
- package/lib/app/services/cache/RedisCache.js.map +1 -0
- package/lib/app/services/cache/cached.d.ts +30 -0
- package/lib/app/services/cache/cached.d.ts.map +1 -0
- package/lib/app/services/cache/cached.js +38 -0
- package/lib/app/services/cache/cached.js.map +1 -0
- package/lib/app/services/cache/index.d.ts +5 -0
- package/lib/app/services/cache/index.d.ts.map +1 -0
- package/lib/app/services/cache/index.js +4 -0
- package/lib/app/services/cache/index.js.map +1 -0
- package/lib/app/services/cron/defineCron.d.ts +57 -0
- package/lib/app/services/cron/defineCron.d.ts.map +1 -0
- package/lib/app/services/cron/defineCron.js +15 -0
- package/lib/app/services/cron/defineCron.js.map +1 -0
- package/lib/app/services/cron/index.d.ts +2 -0
- package/lib/app/services/cron/index.d.ts.map +1 -0
- package/lib/app/services/cron/index.js +2 -0
- package/lib/app/services/cron/index.js.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts +61 -0
- package/lib/app/services/hooks/LifecycleHooks.d.ts.map +1 -0
- package/lib/app/services/hooks/LifecycleHooks.js +85 -0
- package/lib/app/services/hooks/LifecycleHooks.js.map +1 -0
- package/lib/app/services/jobs/JobsManager.d.ts +67 -0
- package/lib/app/services/jobs/JobsManager.d.ts.map +1 -0
- package/lib/app/services/jobs/JobsManager.js +121 -0
- package/lib/app/services/jobs/JobsManager.js.map +1 -0
- package/lib/app/services/jobs/bullBoard.d.ts +72 -0
- package/lib/app/services/jobs/bullBoard.d.ts.map +1 -0
- package/lib/app/services/jobs/bullBoard.js +96 -0
- package/lib/app/services/jobs/bullBoard.js.map +1 -0
- package/lib/app/services/jobs/defineJob.d.ts +81 -0
- package/lib/app/services/jobs/defineJob.d.ts.map +1 -0
- package/lib/app/services/jobs/defineJob.js +49 -0
- package/lib/app/services/jobs/defineJob.js.map +1 -0
- package/lib/app/services/jobs/index.d.ts +4 -0
- package/lib/app/services/jobs/index.d.ts.map +1 -0
- package/lib/app/services/jobs/index.js +4 -0
- package/lib/app/services/jobs/index.js.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts +23 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js +51 -0
- package/lib/app/services/rateLimit/InMemorySlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts +41 -0
- package/lib/app/services/rateLimit/RateLimitBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js +19 -0
- package/lib/app/services/rateLimit/RateLimitBackend.js.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts +16 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.d.ts.map +1 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js +80 -0
- package/lib/app/services/rateLimit/RedisSlidingWindowBackend.js.map +1 -0
- package/lib/app/services/rateLimit/index.d.ts +4 -0
- package/lib/app/services/rateLimit/index.d.ts.map +1 -0
- package/lib/app/services/rateLimit/index.js +3 -0
- package/lib/app/services/rateLimit/index.js.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts +62 -0
- package/lib/app/services/storage/DiskStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/DiskStorageAdapter.js +295 -0
- package/lib/app/services/storage/DiskStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts +44 -0
- package/lib/app/services/storage/GCSStorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/GCSStorageAdapter.js +133 -0
- package/lib/app/services/storage/GCSStorageAdapter.js.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts +57 -0
- package/lib/app/services/storage/S3StorageAdapter.d.ts.map +1 -0
- package/lib/app/services/storage/S3StorageAdapter.js +162 -0
- package/lib/app/services/storage/S3StorageAdapter.js.map +1 -0
- package/lib/app/services/storage/StorageService.d.ts +88 -0
- package/lib/app/services/storage/StorageService.d.ts.map +1 -0
- package/lib/app/services/storage/StorageService.js +18 -0
- package/lib/app/services/storage/StorageService.js.map +1 -0
- package/lib/app/services/storage/index.d.ts +5 -0
- package/lib/app/services/storage/index.d.ts.map +1 -0
- package/lib/app/services/storage/index.js +4 -0
- package/lib/app/services/storage/index.js.map +1 -0
- package/lib/app/utils/ContextValidators.d.ts +46 -0
- package/lib/app/utils/ContextValidators.d.ts.map +1 -0
- package/lib/app/utils/ContextValidators.js +81 -0
- package/lib/app/utils/ContextValidators.js.map +1 -0
- package/lib/app/utils/defineEnv.d.ts +80 -0
- package/lib/app/utils/defineEnv.d.ts.map +1 -0
- package/lib/app/utils/defineEnv.js +95 -0
- package/lib/app/utils/defineEnv.js.map +1 -0
- package/lib/client.d.ts +139 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +98 -0
- package/lib/client.js.map +1 -0
- package/lib/contract/application.d.ts +3 -0
- package/lib/contract/application.d.ts.map +1 -0
- package/lib/contract/application.js +2 -0
- package/lib/contract/application.js.map +1 -0
- package/lib/contract/client.d.ts +3 -0
- package/lib/contract/client.d.ts.map +1 -0
- package/lib/contract/client.js +3 -0
- package/lib/contract/client.js.map +1 -0
- package/lib/contract/index.d.ts +3 -0
- package/lib/contract/index.d.ts.map +1 -0
- package/lib/contract/index.js +3 -0
- package/lib/contract/index.js.map +1 -0
- package/lib/contract/manifest.d.ts +3 -0
- package/lib/contract/manifest.d.ts.map +1 -0
- package/lib/contract/manifest.js +2 -0
- package/lib/contract/manifest.js.map +1 -0
- package/lib/contract/openapi.d.ts +3 -0
- package/lib/contract/openapi.d.ts.map +1 -0
- package/lib/contract/openapi.js +3 -0
- package/lib/contract/openapi.js.map +1 -0
- package/lib/contract/project.d.ts +3 -0
- package/lib/contract/project.d.ts.map +1 -0
- package/lib/contract/project.js +3 -0
- package/lib/contract/project.js.map +1 -0
- package/lib/contract/schema.d.ts +3 -0
- package/lib/contract/schema.d.ts.map +1 -0
- package/lib/contract/schema.js +3 -0
- package/lib/contract/schema.js.map +1 -0
- package/lib/drizzle/index.d.ts +3 -0
- package/lib/drizzle/index.d.ts.map +1 -0
- package/lib/drizzle/index.js +3 -0
- package/lib/drizzle/index.js.map +1 -0
- package/lib/hono/auth.d.ts +6 -0
- package/lib/hono/auth.d.ts.map +1 -0
- package/lib/hono/auth.js +54 -0
- package/lib/hono/auth.js.map +1 -0
- package/lib/hono/index.d.ts +4 -0
- package/lib/hono/index.d.ts.map +1 -0
- package/lib/hono/index.js +4 -0
- package/lib/hono/index.js.map +1 -0
- package/lib/http/app/createApp.d.ts +132 -0
- package/lib/http/app/createApp.d.ts.map +1 -0
- package/lib/http/app/createApp.js +215 -0
- package/lib/http/app/createApp.js.map +1 -0
- package/lib/http/app/devRoutes.d.ts +31 -0
- package/lib/http/app/devRoutes.d.ts.map +1 -0
- package/lib/http/app/devRoutes.js +145 -0
- package/lib/http/app/devRoutes.js.map +1 -0
- package/lib/http/app/errors.d.ts +45 -0
- package/lib/http/app/errors.d.ts.map +1 -0
- package/lib/http/app/errors.js +93 -0
- package/lib/http/app/errors.js.map +1 -0
- package/lib/http/app/health.d.ts +66 -0
- package/lib/http/app/health.d.ts.map +1 -0
- package/lib/http/app/health.js +104 -0
- package/lib/http/app/health.js.map +1 -0
- package/lib/http/errors/AppError.d.ts +10 -0
- package/lib/http/errors/AppError.d.ts.map +1 -0
- package/lib/http/errors/AppError.js +19 -0
- package/lib/http/errors/AppError.js.map +1 -0
- package/lib/http/errors/AuthenticationError.d.ts +8 -0
- package/lib/http/errors/AuthenticationError.d.ts.map +1 -0
- package/lib/http/errors/AuthenticationError.js +10 -0
- package/lib/http/errors/AuthenticationError.js.map +1 -0
- package/lib/http/errors/AuthorizationError.d.ts +8 -0
- package/lib/http/errors/AuthorizationError.d.ts.map +1 -0
- package/lib/http/errors/AuthorizationError.js +10 -0
- package/lib/http/errors/AuthorizationError.js.map +1 -0
- package/lib/http/errors/BadRequestError.d.ts +8 -0
- package/lib/http/errors/BadRequestError.d.ts.map +1 -0
- package/lib/http/errors/BadRequestError.js +10 -0
- package/lib/http/errors/BadRequestError.js.map +1 -0
- package/lib/http/errors/ConflictError.d.ts +8 -0
- package/lib/http/errors/ConflictError.d.ts.map +1 -0
- package/lib/http/errors/ConflictError.js +10 -0
- package/lib/http/errors/ConflictError.js.map +1 -0
- package/lib/http/errors/InternalServerError.d.ts +8 -0
- package/lib/http/errors/InternalServerError.d.ts.map +1 -0
- package/lib/http/errors/InternalServerError.js +10 -0
- package/lib/http/errors/InternalServerError.js.map +1 -0
- package/lib/http/errors/NotFoundError.d.ts +8 -0
- package/lib/http/errors/NotFoundError.d.ts.map +1 -0
- package/lib/http/errors/NotFoundError.js +10 -0
- package/lib/http/errors/NotFoundError.js.map +1 -0
- package/lib/http/errors/RateLimitError.d.ts +13 -0
- package/lib/http/errors/RateLimitError.d.ts.map +1 -0
- package/lib/http/errors/RateLimitError.js +16 -0
- package/lib/http/errors/RateLimitError.js.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts +8 -0
- package/lib/http/errors/ServiceUnavailableError.d.ts.map +1 -0
- package/lib/http/errors/ServiceUnavailableError.js +10 -0
- package/lib/http/errors/ServiceUnavailableError.js.map +1 -0
- package/lib/http/errors/ValidationError.d.ts +9 -0
- package/lib/http/errors/ValidationError.d.ts.map +1 -0
- package/lib/http/errors/ValidationError.js +12 -0
- package/lib/http/errors/ValidationError.js.map +1 -0
- package/lib/http/errors/index.d.ts +11 -0
- package/lib/http/errors/index.d.ts.map +1 -0
- package/lib/http/errors/index.js +12 -0
- package/lib/http/errors/index.js.map +1 -0
- package/lib/http/middleware/apiKey.d.ts +9 -0
- package/lib/http/middleware/apiKey.d.ts.map +1 -0
- package/lib/http/middleware/apiKey.js +71 -0
- package/lib/http/middleware/apiKey.js.map +1 -0
- package/lib/http/middleware/csrf.d.ts +63 -0
- package/lib/http/middleware/csrf.d.ts.map +1 -0
- package/lib/http/middleware/csrf.js +169 -0
- package/lib/http/middleware/csrf.js.map +1 -0
- package/lib/http/middleware/httpLogger.d.ts +39 -0
- package/lib/http/middleware/httpLogger.d.ts.map +1 -0
- package/lib/http/middleware/httpLogger.js +118 -0
- package/lib/http/middleware/httpLogger.js.map +1 -0
- package/lib/http/middleware/idempotency.d.ts +48 -0
- package/lib/http/middleware/idempotency.d.ts.map +1 -0
- package/lib/http/middleware/idempotency.js +180 -0
- package/lib/http/middleware/idempotency.js.map +1 -0
- package/lib/http/middleware/rateLimit.d.ts +105 -0
- package/lib/http/middleware/rateLimit.d.ts.map +1 -0
- package/lib/http/middleware/rateLimit.js +84 -0
- package/lib/http/middleware/rateLimit.js.map +1 -0
- package/lib/http/middleware/requireAuth.d.ts +58 -0
- package/lib/http/middleware/requireAuth.d.ts.map +1 -0
- package/lib/http/middleware/requireAuth.js +63 -0
- package/lib/http/middleware/requireAuth.js.map +1 -0
- package/lib/http/middleware/requirePermission.d.ts +23 -0
- package/lib/http/middleware/requirePermission.d.ts.map +1 -0
- package/lib/http/middleware/requirePermission.js +50 -0
- package/lib/http/middleware/requirePermission.js.map +1 -0
- package/lib/http/middleware/resolveTenant.d.ts +41 -0
- package/lib/http/middleware/resolveTenant.d.ts.map +1 -0
- package/lib/http/middleware/resolveTenant.js +17 -0
- package/lib/http/middleware/resolveTenant.js.map +1 -0
- package/lib/http/streaming/sse.d.ts +31 -0
- package/lib/http/streaming/sse.d.ts.map +1 -0
- package/lib/http/streaming/sse.js +11 -0
- package/lib/http/streaming/sse.js.map +1 -0
- package/lib/http/streaming/streamLLM.d.ts +94 -0
- package/lib/http/streaming/streamLLM.d.ts.map +1 -0
- package/lib/http/streaming/streamLLM.js +94 -0
- package/lib/http/streaming/streamLLM.js.map +1 -0
- package/lib/http/utils/authCookies.d.ts +74 -0
- package/lib/http/utils/authCookies.d.ts.map +1 -0
- package/lib/http/utils/authCookies.js +102 -0
- package/lib/http/utils/authCookies.js.map +1 -0
- package/lib/http/utils/clientIp.d.ts +85 -0
- package/lib/http/utils/clientIp.d.ts.map +1 -0
- package/lib/http/utils/clientIp.js +249 -0
- package/lib/http/utils/clientIp.js.map +1 -0
- package/lib/http/utils/index.d.ts +4 -0
- package/lib/http/utils/index.d.ts.map +1 -0
- package/lib/http/utils/index.js +5 -0
- package/lib/http/utils/index.js.map +1 -0
- package/lib/http/utils/metaTags.d.ts +49 -0
- package/lib/http/utils/metaTags.d.ts.map +1 -0
- package/lib/http/utils/metaTags.js +32 -0
- package/lib/http/utils/metaTags.js.map +1 -0
- package/lib/http/utils/publicSuffix.d.ts +34 -0
- package/lib/http/utils/publicSuffix.d.ts.map +1 -0
- package/lib/http/utils/publicSuffix.js +276 -0
- package/lib/http/utils/publicSuffix.js.map +1 -0
- package/lib/http/utils/uploads.d.ts +92 -0
- package/lib/http/utils/uploads.d.ts.map +1 -0
- package/lib/http/utils/uploads.js +126 -0
- package/lib/http/utils/uploads.js.map +1 -0
- package/lib/http/utils/validate.d.ts +41 -0
- package/lib/http/utils/validate.d.ts.map +1 -0
- package/lib/http/utils/validate.js +55 -0
- package/lib/http/utils/validate.js.map +1 -0
- package/lib/http/utils/webhooks.d.ts +63 -0
- package/lib/http/utils/webhooks.d.ts.map +1 -0
- package/lib/http/utils/webhooks.js +133 -0
- package/lib/http/utils/webhooks.js.map +1 -0
- package/lib/http/ws/auth.d.ts +46 -0
- package/lib/http/ws/auth.d.ts.map +1 -0
- package/lib/http/ws/auth.js +123 -0
- package/lib/http/ws/auth.js.map +1 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +61 -0
- package/lib/index.js.map +1 -0
- package/lib/kernel/index.d.ts +3 -0
- package/lib/kernel/index.d.ts.map +1 -0
- package/lib/kernel/index.js +3 -0
- package/lib/kernel/index.js.map +1 -0
- package/lib/libraries/.gitkeep +0 -0
- package/lib/libraries/ai/CHANGELOG.md +17 -0
- package/lib/libraries/ai/README.md +164 -0
- package/lib/libraries/ai/adapters/AnthropicAdapter.ts +382 -0
- package/lib/libraries/ai/adapters/LLMProvider.ts +76 -0
- package/lib/libraries/ai/adapters/OpenAIAdapter.ts +466 -0
- package/lib/libraries/ai/experimental/index.ts +20 -0
- package/lib/libraries/ai/index.ts +128 -0
- package/lib/libraries/ai/library.json +19 -0
- package/lib/libraries/ai/loop/agentLoop.ts +377 -0
- package/lib/libraries/ai/prompts/definePrompt.ts +0 -0
- package/lib/libraries/ai/rag/retrieveAndAnswer.ts +177 -0
- package/lib/libraries/ai/streaming/streamLLM.ts +94 -0
- package/lib/libraries/ai/structured/completeStructured.ts +143 -0
- package/lib/libraries/ai/tokens/Tokenizer.ts +216 -0
- package/lib/libraries/ai/tools/defineTool.ts +208 -0
- package/lib/libraries/ai/types.ts +260 -0
- package/lib/libraries/chunking/ChunkingService.ts +103 -0
- package/lib/libraries/chunking/README.md +104 -0
- package/lib/libraries/chunking/docs/api-reference.md +549 -0
- package/lib/libraries/chunking/docs/best-practices.md +321 -0
- package/lib/libraries/chunking/docs/code-organization.md +538 -0
- package/lib/libraries/chunking/docs/configuration.md +418 -0
- package/lib/libraries/chunking/docs/index.md +236 -0
- package/lib/libraries/chunking/docs/quick-start.md +298 -0
- package/lib/libraries/chunking/docs/strategies.md +407 -0
- package/lib/libraries/chunking/docs/summary.md +258 -0
- package/lib/libraries/chunking/docs/troubleshooting.md +527 -0
- package/lib/libraries/chunking/index.ts +17 -0
- package/lib/libraries/chunking/library.json +16 -0
- package/lib/libraries/chunking/strategies/ChunkingStrategy.ts +13 -0
- package/lib/libraries/chunking/strategies/FixedLengthChunkingStrategy.ts +88 -0
- package/lib/libraries/chunking/strategies/SemanticChunkingStrategy.ts +389 -0
- package/lib/libraries/chunking/strategies/SlidingWindowChunkingStrategy.ts +258 -0
- package/lib/libraries/chunking/types/index.ts +63 -0
- package/lib/libraries/email/EmailService.ts +591 -0
- package/lib/libraries/email/README.md +777 -0
- package/lib/libraries/email/TemplateRegistry.ts +148 -0
- package/lib/libraries/email/TemplateRenderer.ts +273 -0
- package/lib/libraries/email/index.ts +4 -0
- package/lib/libraries/email/initializeEmailService.ts +60 -0
- package/lib/libraries/email/library.json +12 -0
- package/lib/libraries/email/types/EmailAddress.ts +4 -0
- package/lib/libraries/email/types/EmailAttachment.ts +11 -0
- package/lib/libraries/email/types/EmailTag.ts +9 -0
- package/lib/libraries/email/types/EmailTemplate.ts +124 -0
- package/lib/libraries/email/types/SendBatchEmailsOptions.ts +9 -0
- package/lib/libraries/email/types/SendBatchEmailsResult.ts +9 -0
- package/lib/libraries/email/types/SendEmailOptions.ts +33 -0
- package/lib/libraries/email/types/SendEmailResult.ts +9 -0
- package/lib/libraries/email/types/index.ts +8 -0
- package/lib/libraries/weaviate/QueryBuilder.ts +292 -0
- package/lib/libraries/weaviate/README.md +284 -0
- package/lib/libraries/weaviate/Weaviate.ts +1419 -0
- package/lib/libraries/weaviate/WeaviateConfig.ts +268 -0
- package/lib/libraries/weaviate/docs/.gitkeep +1 -0
- package/lib/libraries/weaviate/docs/API_REFERENCE.md +1067 -0
- package/lib/libraries/weaviate/docs/CONFIGURATION.md +320 -0
- package/lib/libraries/weaviate/docs/ERROR_HANDLING.md +271 -0
- package/lib/libraries/weaviate/docs/MULTI_TENANCY.md +348 -0
- package/lib/libraries/weaviate/docs/PERFORMANCE.md +602 -0
- package/lib/libraries/weaviate/docs/PLUGIN_DEVELOPMENT.md +547 -0
- package/lib/libraries/weaviate/docs/QUICK_START.md +443 -0
- package/lib/libraries/weaviate/docs/README.md +269 -0
- package/lib/libraries/weaviate/docs/SCHEMA_GUIDE.md +630 -0
- package/lib/libraries/weaviate/docs/WEAVIATE_README.md +520 -0
- package/lib/libraries/weaviate/errors/WeaviateError.ts +92 -0
- package/lib/libraries/weaviate/errors/index.ts +1 -0
- package/lib/libraries/weaviate/index.ts +35 -0
- package/lib/libraries/weaviate/library.json +26 -0
- package/lib/libraries/weaviate/plugins/index.ts +2 -0
- package/lib/libraries/weaviate/schemas/SchemaRegistry.ts +284 -0
- package/lib/libraries/weaviate/schemas/index.ts +2 -0
- package/lib/libraries/weaviate/types/BM25SearchOptions.ts +9 -0
- package/lib/libraries/weaviate/types/ExtendedWeaviateClient.ts +7 -0
- package/lib/libraries/weaviate/types/HybridSearchOptions.ts +11 -0
- package/lib/libraries/weaviate/types/MultiTenancy.ts +81 -0
- package/lib/libraries/weaviate/types/Plugin.ts +17 -0
- package/lib/libraries/weaviate/types/SchemaConfig.ts +25 -0
- package/lib/libraries/weaviate/types/SearchMethod.ts +8 -0
- package/lib/libraries/weaviate/types/SearchOptions.ts +16 -0
- package/lib/libraries/weaviate/types/SearchRequest.ts +19 -0
- package/lib/libraries/weaviate/types/SearchResult.ts +16 -0
- package/lib/libraries/weaviate/types/SearchableField.ts +87 -0
- package/lib/libraries/weaviate/types/VectorIndexConfig.ts +19 -0
- package/lib/libraries/weaviate/types/VectorSearchOptions.ts +18 -0
- package/lib/libraries/weaviate/types/VectorizerConfig.ts +8 -0
- package/lib/libraries/weaviate/types/index.ts +29 -0
- package/lib/libraries/weaviate/utils/TenantContextManager.ts +94 -0
- package/lib/modules/accounts/index.ts +47 -0
- package/lib/modules/accounts/module.json +15 -0
- package/lib/modules/accounts/permissions.ts +33 -0
- package/lib/modules/accounts/routes.ts +200 -0
- package/lib/modules/accounts/schema.ts +219 -0
- package/lib/modules/accounts/services/AccountService.ts +44 -0
- package/lib/modules/accounts/validation/schemas.ts +70 -0
- package/lib/modules/oauth/adapters/GmailOAuthAdapter.ts +35 -0
- package/lib/modules/oauth/adapters/GoogleOAuthAdapter.ts +278 -0
- package/lib/modules/oauth/adapters/MicrosoftOAuthAdapter.ts +269 -0
- package/lib/modules/oauth/adapters/MockOAuthAdapter.ts +138 -0
- package/lib/modules/oauth/adapters/OAuthAdapter.ts +211 -0
- package/lib/modules/oauth/adapters/OAuthAdapterRegistry.ts +77 -0
- package/lib/modules/oauth/adapters/OutlookOAuthAdapter.ts +38 -0
- package/lib/modules/oauth/index.ts +79 -0
- package/lib/modules/oauth/module.json +23 -0
- package/lib/modules/oauth/permissions.ts +39 -0
- package/lib/modules/oauth/routes.ts +497 -0
- package/lib/modules/oauth/schema.ts +127 -0
- package/lib/modules/oauth/services/OAuthConnectionService.ts +147 -0
- package/lib/modules/oauth/state.ts +234 -0
- package/lib/modules/oauth/stateJtiCache.ts +85 -0
- package/lib/modules/oauth/verifyIdToken.ts +178 -0
- package/lib/modules/outbox/EventEmitter.ts +106 -0
- package/lib/modules/outbox/OutboxDrainer.ts +163 -0
- package/lib/modules/outbox/handlers/EventHandler.ts +115 -0
- package/lib/modules/outbox/index.ts +43 -0
- package/lib/modules/outbox/module.json +15 -0
- package/lib/modules/outbox/permissions.ts +36 -0
- package/lib/modules/outbox/routes.ts +219 -0
- package/lib/modules/outbox/schema.ts +207 -0
- package/lib/modules/outbox/services/OutboxEventService.ts +223 -0
- package/lib/observability/logger.d.ts +30 -0
- package/lib/observability/logger.d.ts.map +1 -0
- package/lib/observability/logger.js +110 -0
- package/lib/observability/logger.js.map +1 -0
- package/lib/observability/metrics.d.ts +3 -0
- package/lib/observability/metrics.d.ts.map +1 -0
- package/lib/observability/metrics.js +3 -0
- package/lib/observability/metrics.js.map +1 -0
- package/lib/observability/otel.d.ts +3 -0
- package/lib/observability/otel.d.ts.map +1 -0
- package/lib/observability/otel.js +3 -0
- package/lib/observability/otel.js.map +1 -0
- package/lib/observability/safeErrorFields.d.ts +14 -0
- package/lib/observability/safeErrorFields.d.ts.map +1 -0
- package/lib/observability/safeErrorFields.js +14 -0
- package/lib/observability/safeErrorFields.js.map +1 -0
- package/lib/observability/tracing.d.ts +3 -0
- package/lib/observability/tracing.d.ts.map +1 -0
- package/lib/observability/tracing.js +3 -0
- package/lib/observability/tracing.js.map +1 -0
- package/lib/package.json +4 -0
- package/lib/testing.d.ts +3 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +3 -0
- package/lib/testing.js.map +1 -0
- package/package.json +193 -3
- package/templates/default/.claude/agents/qa-brief.md +106 -0
- package/templates/default/.claude/commands/sherpa-brief.md +23 -0
- package/templates/default/.cursor/rules/api.mdc +80 -0
- package/templates/default/.cursor/rules/commits.mdc +88 -0
- package/templates/default/.cursor/rules/security.mdc +92 -0
- package/templates/default/.cursor/rules/testing.mdc +123 -0
- package/templates/default/.cursor/rules/typescript.mdc +86 -0
- package/templates/default/.env.example +79 -0
- package/templates/default/.github/workflows/sherpa-brief.yml +180 -0
- package/templates/default/AGENTS.md +166 -0
- package/templates/default/CLAUDE.md +17 -0
- package/templates/default/README.md +97 -0
- package/templates/default/_gitignore +27 -0
- package/templates/default/docker-compose.yml +83 -0
- package/templates/default/drizzle.config.ts +34 -0
- package/templates/default/eslint.config.mjs +106 -0
- package/templates/default/package.json +57 -0
- package/templates/default/ship-api.config.ts +21 -0
- package/templates/default/src/client.ts +34 -0
- package/templates/default/src/config/modules.ts +23 -0
- package/templates/default/src/db/schema.ts +26 -0
- package/templates/default/src/environment.ts +81 -0
- package/templates/default/src/index.test.ts +53 -0
- package/templates/default/src/index.ts +11 -0
- package/templates/default/src/instrumentation.ts +13 -0
- package/templates/default/src/server.ts +90 -0
- package/templates/default/tsconfig.json +24 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompleteOptions,
|
|
3
|
+
CompleteResult,
|
|
4
|
+
EmbedOptions,
|
|
5
|
+
EmbedResult,
|
|
6
|
+
StreamCompleteOptions,
|
|
7
|
+
StreamEvent,
|
|
8
|
+
} from "../types.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Pluggable LLM provider contract — the v4 LLM helper library's load-
|
|
12
|
+
* bearing seam. Every adapter (Anthropic, OpenAI, Bedrock-via-bedrock,
|
|
13
|
+
* Vertex, local Ollama, …) implements this surface; downstream code
|
|
14
|
+
* (agent loop, prompt registry, RAG pipeline, `streamLLM(c, ...)`)
|
|
15
|
+
* targets the interface, not a concrete provider.
|
|
16
|
+
*
|
|
17
|
+
* Provider-specific tunables ride in `CompleteOptions.providerOptions`
|
|
18
|
+
* so the cross-provider surface stays narrow. Provider-specific outputs
|
|
19
|
+
* ride in `CompleteResult.providerExtras` (e.g. Anthropic prompt-cache
|
|
20
|
+
* metadata) for the same reason.
|
|
21
|
+
*
|
|
22
|
+
* Why pluggable instead of "just use Anthropic": (1) cost-routing —
|
|
23
|
+
* cheap local models for development, frontier models for production;
|
|
24
|
+
* (2) graceful degradation — fall back to a different provider when one
|
|
25
|
+
* is degraded; (3) consumer choice — the framework doesn't pre-decide
|
|
26
|
+
* which provider a downstream app uses; (4) testability — a `MockLLM`
|
|
27
|
+
* adapter implementing this interface drives every higher-level
|
|
28
|
+
* abstraction (agent loop, structured output) without the network.
|
|
29
|
+
*
|
|
30
|
+
* Adapters MUST:
|
|
31
|
+
* - Convert provider-specific stop reasons / usage shapes to the
|
|
32
|
+
* normalized `StopReason` / `TokenUsage` types.
|
|
33
|
+
* - Aggregate streaming chunks into the well-defined `StreamEvent`
|
|
34
|
+
* order (`start` → `text_delta` / tool-call group(s) → `stop`).
|
|
35
|
+
* - Honor `opts.signal` — abort the in-flight provider request when
|
|
36
|
+
* the signal fires; rejecting the returned promise / iterator.
|
|
37
|
+
* - Normalize transient failures into a thrown `LLMProviderError`
|
|
38
|
+
* (later commit defines this) so callers don't switch on SDK type.
|
|
39
|
+
*
|
|
40
|
+
* Adapters SHOULD:
|
|
41
|
+
* - Accept an injected `fetch` / SDK client in their constructor so
|
|
42
|
+
* tests can swap it without monkey-patching globals.
|
|
43
|
+
* - Default to the provider's IANA-blessed base URL but allow
|
|
44
|
+
* override via constructor option (corp proxies, edge gateways).
|
|
45
|
+
* - Set request-level metadata (e.g. `metadata.user_id`) when the
|
|
46
|
+
* caller passes `opts.metadata` — used by usage trackers (v4.x).
|
|
47
|
+
*/
|
|
48
|
+
export interface LLMProvider {
|
|
49
|
+
/** Stable identifier ("anthropic", "openai", "bedrock", …). */
|
|
50
|
+
readonly name: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Single-turn completion. Resolves with the full response (all
|
|
54
|
+
* content parts the model emitted, normalized stop reason, token
|
|
55
|
+
* usage). Rejects with `LLMProviderError` on transient failures or
|
|
56
|
+
* `AbortError` when `opts.signal` fires.
|
|
57
|
+
*/
|
|
58
|
+
complete(opts: CompleteOptions): Promise<CompleteResult>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Streaming variant. Returns an async iterator of `StreamEvent`s in
|
|
62
|
+
* the documented order (`start` → deltas → `stop`). Consumers
|
|
63
|
+
* `for await` to drive UI / `streamSSE`. The iterator throws on
|
|
64
|
+
* abort (`opts.signal`) or transient failure — callers wrap in
|
|
65
|
+
* try/catch when they need recovery.
|
|
66
|
+
*/
|
|
67
|
+
streamComplete(opts: StreamCompleteOptions): AsyncIterable<StreamEvent>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Embed one or more strings. Optional — providers without embeddings
|
|
71
|
+
* may throw `LLMProviderUnsupportedError` (later commit) instead.
|
|
72
|
+
* Adapters that DO support embeddings must batch internally to
|
|
73
|
+
* respect provider per-request input limits.
|
|
74
|
+
*/
|
|
75
|
+
embed?(opts: EmbedOptions): Promise<EmbedResult>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import type {
|
|
3
|
+
ChatCompletion,
|
|
4
|
+
ChatCompletionChunk,
|
|
5
|
+
ChatCompletionCreateParamsBase,
|
|
6
|
+
ChatCompletionCreateParamsNonStreaming,
|
|
7
|
+
ChatCompletionCreateParamsStreaming,
|
|
8
|
+
ChatCompletionMessageParam,
|
|
9
|
+
ChatCompletionMessageToolCall,
|
|
10
|
+
ChatCompletionTool,
|
|
11
|
+
ChatCompletionToolChoiceOption,
|
|
12
|
+
} from "openai/resources/chat/completions";
|
|
13
|
+
import type {
|
|
14
|
+
CompleteOptions,
|
|
15
|
+
CompleteResult,
|
|
16
|
+
Message,
|
|
17
|
+
MessageContentPart,
|
|
18
|
+
StopReason,
|
|
19
|
+
StreamCompleteOptions,
|
|
20
|
+
StreamEvent,
|
|
21
|
+
TokenUsage,
|
|
22
|
+
ToolChoice,
|
|
23
|
+
ToolDefinition,
|
|
24
|
+
} from "../types.js";
|
|
25
|
+
import type { LLMProvider } from "./LLMProvider.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Concrete `LLMProvider` implementation backed by `openai`.
|
|
29
|
+
*
|
|
30
|
+
* Translation surface:
|
|
31
|
+
* - Cross-provider `Message` (string-or-content-parts) →
|
|
32
|
+
* `ChatCompletionMessageParam[]`. System prompt is prepended as a
|
|
33
|
+
* `role: "system"` message (OpenAI convention) rather than a
|
|
34
|
+
* top-level field. Tool-results from our content-parts shape map
|
|
35
|
+
* to `role: "tool"` messages.
|
|
36
|
+
* - `ToolDefinition` → OpenAI "function" tool (`type: "function"`,
|
|
37
|
+
* `function.parameters` = our `inputSchema`).
|
|
38
|
+
* - `ToolChoice` (auto / any / none / tool) → OpenAI
|
|
39
|
+
* `tool_choice` (`auto` / `required` / `none` / `{type: "function",
|
|
40
|
+
* function: { name }}`).
|
|
41
|
+
* - `ChatCompletion` response → `CompleteResult` with normalized
|
|
42
|
+
* `StopReason` (`stop` → `end_turn`, `length` → `max_tokens`,
|
|
43
|
+
* `content_filter` → `content_filter`, `tool_calls` →
|
|
44
|
+
* `tool_use`).
|
|
45
|
+
* - `ChatCompletionChunk` stream → normalized `StreamEvent` stream.
|
|
46
|
+
* Tool-call argument deltas accumulate per `tool_calls[index]`
|
|
47
|
+
* and emit the parsed object on the matching tool-call's first
|
|
48
|
+
* `finish_reason` chunk.
|
|
49
|
+
*
|
|
50
|
+
* Constructor takes either an `apiKey` or a pre-built `client`
|
|
51
|
+
* (structurally typed via `OpenAIChatClient`) — tests inject a stub
|
|
52
|
+
* without monkey-patching the SDK module.
|
|
53
|
+
*
|
|
54
|
+
* Default model: `gpt-4.1` (the most capable production GPT as of v4
|
|
55
|
+
* launch). Callers override per request via `opts.model`.
|
|
56
|
+
*
|
|
57
|
+
* Default `max_tokens` (4096) applied when caller doesn't supply one;
|
|
58
|
+
* paired with the Anthropic adapter's same default for cross-provider
|
|
59
|
+
* call-site parity.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export interface OpenAIAdapterOptions {
|
|
63
|
+
/** OpenAI API key. Required unless `client` is supplied. */
|
|
64
|
+
apiKey?: string;
|
|
65
|
+
/** Override the default OpenAI API base URL. */
|
|
66
|
+
baseURL?: string;
|
|
67
|
+
/** Forwarded as `defaultHeaders` to the SDK. */
|
|
68
|
+
defaultHeaders?: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Pre-built / stubbed SDK client. When supplied, `apiKey` /
|
|
71
|
+
* `baseURL` are ignored — useful for tests and for shared client
|
|
72
|
+
* reuse.
|
|
73
|
+
*/
|
|
74
|
+
client?: OpenAIChatClient;
|
|
75
|
+
/** Default `max_tokens` when caller doesn't supply one. Defaults 4096. */
|
|
76
|
+
defaultMaxTokens?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Structural slice of `OpenAI` we actually call — narrows what tests
|
|
81
|
+
* have to stub. The real `OpenAI` client satisfies this trivially.
|
|
82
|
+
*/
|
|
83
|
+
export interface OpenAIChatClient {
|
|
84
|
+
chat: {
|
|
85
|
+
completions: {
|
|
86
|
+
create(
|
|
87
|
+
body: ChatCompletionCreateParamsNonStreaming,
|
|
88
|
+
options?: { signal?: AbortSignal },
|
|
89
|
+
): Promise<ChatCompletion>;
|
|
90
|
+
create(
|
|
91
|
+
body: ChatCompletionCreateParamsStreaming,
|
|
92
|
+
options?: { signal?: AbortSignal },
|
|
93
|
+
): Promise<AsyncIterable<ChatCompletionChunk>>;
|
|
94
|
+
create(
|
|
95
|
+
body: ChatCompletionCreateParamsBase,
|
|
96
|
+
options?: { signal?: AbortSignal },
|
|
97
|
+
): Promise<ChatCompletion | AsyncIterable<ChatCompletionChunk>>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const DEFAULT_MAX_TOKENS = 4096;
|
|
103
|
+
const DEFAULT_MODEL = "gpt-4.1";
|
|
104
|
+
|
|
105
|
+
export class OpenAIAdapter implements LLMProvider {
|
|
106
|
+
readonly name = "openai";
|
|
107
|
+
|
|
108
|
+
private readonly client: OpenAIChatClient;
|
|
109
|
+
private readonly defaultMaxTokens: number;
|
|
110
|
+
|
|
111
|
+
constructor(opts: OpenAIAdapterOptions = {}) {
|
|
112
|
+
if (opts.client) {
|
|
113
|
+
this.client = opts.client;
|
|
114
|
+
} else {
|
|
115
|
+
if (!opts.apiKey) {
|
|
116
|
+
throw new Error("OpenAIAdapter requires `apiKey` or a pre-built `client`");
|
|
117
|
+
}
|
|
118
|
+
this.client = new OpenAI({
|
|
119
|
+
apiKey: opts.apiKey,
|
|
120
|
+
baseURL: opts.baseURL,
|
|
121
|
+
defaultHeaders: opts.defaultHeaders,
|
|
122
|
+
}) as unknown as OpenAIChatClient;
|
|
123
|
+
}
|
|
124
|
+
this.defaultMaxTokens = opts.defaultMaxTokens ?? DEFAULT_MAX_TOKENS;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async complete(opts: CompleteOptions): Promise<CompleteResult> {
|
|
128
|
+
const body = this.buildRequestBody(opts, false) as ChatCompletionCreateParamsNonStreaming;
|
|
129
|
+
const response = (await this.client.chat.completions.create(body, {
|
|
130
|
+
signal: opts.signal,
|
|
131
|
+
})) as ChatCompletion;
|
|
132
|
+
return translateResponse(response);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async *streamComplete(opts: StreamCompleteOptions): AsyncIterable<StreamEvent> {
|
|
136
|
+
const body = this.buildRequestBody(opts, true) as ChatCompletionCreateParamsStreaming;
|
|
137
|
+
const stream = (await this.client.chat.completions.create(body, {
|
|
138
|
+
signal: opts.signal,
|
|
139
|
+
})) as AsyncIterable<ChatCompletionChunk>;
|
|
140
|
+
|
|
141
|
+
let started = false;
|
|
142
|
+
let stopReason: StopReason = "unknown";
|
|
143
|
+
let usage: TokenUsage = { inputTokens: 0, outputTokens: 0 };
|
|
144
|
+
// Per-tool-call index buffers — OpenAI streams tool_call argument
|
|
145
|
+
// deltas indexed by `tool_calls[i].index`. We accumulate args and
|
|
146
|
+
// emit `tool_use_end` when finish_reason fires.
|
|
147
|
+
const toolBuffers = new Map<
|
|
148
|
+
number,
|
|
149
|
+
{ id: string; name: string; emitted: boolean; args: string }
|
|
150
|
+
>();
|
|
151
|
+
|
|
152
|
+
for await (const chunk of stream) {
|
|
153
|
+
if (!started) {
|
|
154
|
+
started = true;
|
|
155
|
+
yield { type: "start", id: chunk.id, model: chunk.model };
|
|
156
|
+
}
|
|
157
|
+
const choice = chunk.choices[0];
|
|
158
|
+
if (!choice) continue;
|
|
159
|
+
const delta = choice.delta;
|
|
160
|
+
|
|
161
|
+
if (typeof delta.content === "string" && delta.content.length > 0) {
|
|
162
|
+
yield { type: "text_delta", delta: delta.content };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const toolCallDeltas = delta.tool_calls;
|
|
166
|
+
if (toolCallDeltas) {
|
|
167
|
+
for (const tc of toolCallDeltas) {
|
|
168
|
+
const idx = tc.index;
|
|
169
|
+
let buf = toolBuffers.get(idx);
|
|
170
|
+
if (!buf) {
|
|
171
|
+
buf = {
|
|
172
|
+
id: tc.id ?? `tu_${idx}`,
|
|
173
|
+
name: tc.function?.name ?? "",
|
|
174
|
+
emitted: false,
|
|
175
|
+
args: "",
|
|
176
|
+
};
|
|
177
|
+
toolBuffers.set(idx, buf);
|
|
178
|
+
}
|
|
179
|
+
// The first chunk for a given index typically carries the id
|
|
180
|
+
// + name; subsequent chunks carry only argument fragments.
|
|
181
|
+
if (tc.id && !buf.id.startsWith("tu_")) buf.id = tc.id;
|
|
182
|
+
else if (tc.id) buf.id = tc.id;
|
|
183
|
+
if (tc.function?.name) buf.name = tc.function.name;
|
|
184
|
+
if (!buf.emitted && buf.name) {
|
|
185
|
+
yield { type: "tool_use_start", id: buf.id, name: buf.name };
|
|
186
|
+
buf.emitted = true;
|
|
187
|
+
}
|
|
188
|
+
const partial = tc.function?.arguments;
|
|
189
|
+
if (partial) {
|
|
190
|
+
buf.args += partial;
|
|
191
|
+
yield {
|
|
192
|
+
type: "tool_input_delta",
|
|
193
|
+
id: buf.id,
|
|
194
|
+
partialJson: partial,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (choice.finish_reason) {
|
|
201
|
+
stopReason = translateStopReason(choice.finish_reason);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (chunk.usage) {
|
|
205
|
+
usage = {
|
|
206
|
+
inputTokens: chunk.usage.prompt_tokens ?? 0,
|
|
207
|
+
outputTokens: chunk.usage.completion_tokens ?? 0,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Close out any outstanding tool-call buffers with parsed inputs.
|
|
213
|
+
for (const buf of toolBuffers.values()) {
|
|
214
|
+
const input = parseToolArgs(buf.args);
|
|
215
|
+
yield { type: "tool_use_end", id: buf.id, input };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
yield { type: "stop", stopReason, usage };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// --- Translation helpers ------------------------------------------------
|
|
222
|
+
|
|
223
|
+
private buildRequestBody(opts: CompleteOptions, stream: boolean): ChatCompletionCreateParamsBase {
|
|
224
|
+
const messages: ChatCompletionMessageParam[] = [];
|
|
225
|
+
if (opts.system) {
|
|
226
|
+
messages.push({ role: "system", content: opts.system });
|
|
227
|
+
}
|
|
228
|
+
for (const msg of opts.messages) {
|
|
229
|
+
pushTranslatedMessage(messages, msg);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const body: ChatCompletionCreateParamsBase = {
|
|
233
|
+
model: opts.model || DEFAULT_MODEL,
|
|
234
|
+
messages,
|
|
235
|
+
max_completion_tokens: opts.maxTokens ?? this.defaultMaxTokens,
|
|
236
|
+
};
|
|
237
|
+
if (opts.temperature !== undefined) body.temperature = opts.temperature;
|
|
238
|
+
if (opts.stopSequences?.length) body.stop = opts.stopSequences;
|
|
239
|
+
if (opts.tools?.length) body.tools = opts.tools.map(toOpenAITool);
|
|
240
|
+
if (opts.toolChoice) body.tool_choice = toOpenAIToolChoice(opts.toolChoice);
|
|
241
|
+
if (opts.metadata) {
|
|
242
|
+
body.metadata = opts.metadata as Record<string, string>;
|
|
243
|
+
}
|
|
244
|
+
if (stream) {
|
|
245
|
+
(body as ChatCompletionCreateParamsStreaming).stream = true;
|
|
246
|
+
// Ask for usage on streaming responses (off by default).
|
|
247
|
+
(body as ChatCompletionCreateParamsStreaming).stream_options = { include_usage: true };
|
|
248
|
+
}
|
|
249
|
+
if (opts.providerOptions) Object.assign(body, opts.providerOptions);
|
|
250
|
+
return body;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function pushTranslatedMessage(messages: ChatCompletionMessageParam[], msg: Message): void {
|
|
255
|
+
if (msg.role === "tool") {
|
|
256
|
+
// Cross-provider `Message` doesn't model OpenAI's tool-result
|
|
257
|
+
// message directly. Caller should have used content-part shape;
|
|
258
|
+
// this branch is defensive.
|
|
259
|
+
if (typeof msg.content === "string") {
|
|
260
|
+
messages.push({
|
|
261
|
+
role: "tool",
|
|
262
|
+
tool_call_id: msg.name ?? "",
|
|
263
|
+
content: msg.content,
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
// Multi-part tool message — flatten text parts.
|
|
267
|
+
messages.push({
|
|
268
|
+
role: "tool",
|
|
269
|
+
tool_call_id: msg.name ?? "",
|
|
270
|
+
content: contentPartsToString(msg.content),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (msg.role === "assistant") {
|
|
277
|
+
const param = translateAssistantMessage(msg);
|
|
278
|
+
messages.push(param);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// role === "user"
|
|
283
|
+
if (typeof msg.content === "string") {
|
|
284
|
+
messages.push({ role: "user", content: msg.content });
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Multi-part user content: text + image directly; tool_result split
|
|
289
|
+
// into separate role:"tool" messages because OpenAI's chat schema
|
|
290
|
+
// requires tool-results as their own messages, not embedded user
|
|
291
|
+
// content.
|
|
292
|
+
const userContent: Array<
|
|
293
|
+
| { type: "text"; text: string }
|
|
294
|
+
| {
|
|
295
|
+
type: "image_url";
|
|
296
|
+
image_url: { url: string };
|
|
297
|
+
}
|
|
298
|
+
> = [];
|
|
299
|
+
const trailingToolResults: ChatCompletionMessageParam[] = [];
|
|
300
|
+
for (const part of msg.content) {
|
|
301
|
+
if (part.type === "text") {
|
|
302
|
+
userContent.push({ type: "text", text: part.text });
|
|
303
|
+
} else if (part.type === "image") {
|
|
304
|
+
userContent.push({
|
|
305
|
+
type: "image_url",
|
|
306
|
+
image_url: { url: `data:${part.mediaType};base64,${part.data}` },
|
|
307
|
+
});
|
|
308
|
+
} else if (part.type === "tool_result") {
|
|
309
|
+
trailingToolResults.push({
|
|
310
|
+
role: "tool",
|
|
311
|
+
tool_call_id: part.toolUseId,
|
|
312
|
+
content: part.content,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// tool_use parts are valid only on assistant messages — skip on user.
|
|
316
|
+
}
|
|
317
|
+
if (userContent.length > 0) {
|
|
318
|
+
messages.push({ role: "user", content: userContent });
|
|
319
|
+
}
|
|
320
|
+
for (const tr of trailingToolResults) messages.push(tr);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function translateAssistantMessage(msg: Message): ChatCompletionMessageParam {
|
|
324
|
+
if (typeof msg.content === "string") {
|
|
325
|
+
return { role: "assistant", content: msg.content };
|
|
326
|
+
}
|
|
327
|
+
const text: string[] = [];
|
|
328
|
+
const toolCalls: ChatCompletionMessageToolCall[] = [];
|
|
329
|
+
for (const part of msg.content) {
|
|
330
|
+
if (part.type === "text") {
|
|
331
|
+
text.push(part.text);
|
|
332
|
+
} else if (part.type === "tool_use") {
|
|
333
|
+
toolCalls.push({
|
|
334
|
+
id: part.id,
|
|
335
|
+
type: "function",
|
|
336
|
+
function: {
|
|
337
|
+
name: part.name,
|
|
338
|
+
arguments: JSON.stringify(part.input ?? {}),
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const out: ChatCompletionMessageParam = {
|
|
344
|
+
role: "assistant",
|
|
345
|
+
content: text.length > 0 ? text.join("") : null,
|
|
346
|
+
};
|
|
347
|
+
if (toolCalls.length > 0) {
|
|
348
|
+
(out as { tool_calls?: ChatCompletionMessageToolCall[] }).tool_calls = toolCalls;
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function contentPartsToString(parts: MessageContentPart[]): string {
|
|
354
|
+
return parts
|
|
355
|
+
.filter((p): p is { type: "text"; text: string } => p.type === "text")
|
|
356
|
+
.map((p) => p.text)
|
|
357
|
+
.join("");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function toOpenAITool(tool: ToolDefinition): ChatCompletionTool {
|
|
361
|
+
return {
|
|
362
|
+
type: "function",
|
|
363
|
+
function: {
|
|
364
|
+
name: tool.name,
|
|
365
|
+
description: tool.description,
|
|
366
|
+
parameters: tool.inputSchema as Record<string, unknown>,
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function toOpenAIToolChoice(choice: ToolChoice): ChatCompletionToolChoiceOption {
|
|
372
|
+
switch (choice.type) {
|
|
373
|
+
case "auto":
|
|
374
|
+
return "auto";
|
|
375
|
+
case "any":
|
|
376
|
+
return "required";
|
|
377
|
+
case "none":
|
|
378
|
+
return "none";
|
|
379
|
+
case "tool":
|
|
380
|
+
return { type: "function", function: { name: choice.name } };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function translateResponse(response: ChatCompletion): CompleteResult {
|
|
385
|
+
const choice = response.choices[0];
|
|
386
|
+
const message = choice?.message;
|
|
387
|
+
const content: MessageContentPart[] = [];
|
|
388
|
+
if (message?.content) {
|
|
389
|
+
content.push({ type: "text", text: message.content });
|
|
390
|
+
}
|
|
391
|
+
if (message?.tool_calls) {
|
|
392
|
+
for (const tc of message.tool_calls) {
|
|
393
|
+
if (tc.type !== "function" && !("function" in tc)) continue;
|
|
394
|
+
const fn = "function" in tc ? tc.function : undefined;
|
|
395
|
+
if (!fn) continue;
|
|
396
|
+
let input: Record<string, unknown> = {};
|
|
397
|
+
try {
|
|
398
|
+
input = JSON.parse(fn.arguments) as Record<string, unknown>;
|
|
399
|
+
} catch {
|
|
400
|
+
// OpenAI may emit invalid JSON on truncated responses — keep
|
|
401
|
+
// the raw text on a sentinel field so consumers can recover.
|
|
402
|
+
input = { __ship_api_raw: fn.arguments };
|
|
403
|
+
}
|
|
404
|
+
content.push({
|
|
405
|
+
type: "tool_use",
|
|
406
|
+
id: tc.id,
|
|
407
|
+
name: fn.name,
|
|
408
|
+
input,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const text = content
|
|
413
|
+
.filter((p): p is { type: "text"; text: string } => p.type === "text")
|
|
414
|
+
.map((p) => p.text)
|
|
415
|
+
.join("");
|
|
416
|
+
|
|
417
|
+
const usage: TokenUsage = {
|
|
418
|
+
inputTokens: response.usage?.prompt_tokens ?? 0,
|
|
419
|
+
outputTokens: response.usage?.completion_tokens ?? 0,
|
|
420
|
+
raw: response.usage,
|
|
421
|
+
};
|
|
422
|
+
const reasoningTokens = (
|
|
423
|
+
response.usage as { completion_tokens_details?: { reasoning_tokens?: number } } | undefined
|
|
424
|
+
)?.completion_tokens_details?.reasoning_tokens;
|
|
425
|
+
if (reasoningTokens !== undefined) usage.reasoningTokens = reasoningTokens;
|
|
426
|
+
|
|
427
|
+
const result: CompleteResult = {
|
|
428
|
+
id: response.id,
|
|
429
|
+
model: response.model,
|
|
430
|
+
content,
|
|
431
|
+
text,
|
|
432
|
+
stopReason: translateStopReason(choice?.finish_reason ?? null),
|
|
433
|
+
usage,
|
|
434
|
+
raw: response,
|
|
435
|
+
};
|
|
436
|
+
// Pass native fields the unified surface drops through `providerExtras` (AI-R1).
|
|
437
|
+
if (message?.refusal) result.providerExtras = { refusal: message.refusal };
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function translateStopReason(
|
|
442
|
+
reason: ChatCompletion.Choice["finish_reason"] | string | null,
|
|
443
|
+
): StopReason {
|
|
444
|
+
switch (reason) {
|
|
445
|
+
case "stop":
|
|
446
|
+
return "end_turn";
|
|
447
|
+
case "length":
|
|
448
|
+
return "max_tokens";
|
|
449
|
+
case "content_filter":
|
|
450
|
+
return "content_filter";
|
|
451
|
+
case "tool_calls":
|
|
452
|
+
case "function_call":
|
|
453
|
+
return "tool_use";
|
|
454
|
+
default:
|
|
455
|
+
return "unknown";
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function parseToolArgs(buffer: string): Record<string, unknown> {
|
|
460
|
+
if (!buffer) return {};
|
|
461
|
+
try {
|
|
462
|
+
return JSON.parse(buffer) as Record<string, unknown>;
|
|
463
|
+
} catch {
|
|
464
|
+
return { __ship_api_partial: buffer };
|
|
465
|
+
}
|
|
466
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@sixthsummit/ship-api/libraries/ai/experimental` — surfaces that work but
|
|
3
|
+
* carry **no stability promise** and may change or be removed in any release.
|
|
4
|
+
*
|
|
5
|
+
* `agentLoop` lives here (AI-R2): the hand-rolled model→tool→model loop is the
|
|
6
|
+
* most volatile surface in the library — the ecosystem is moving to MCP /
|
|
7
|
+
* provider-native agent runtimes, so this is the piece most likely to be
|
|
8
|
+
* superseded. Durable code should prefer `completeStructured` (single-shot) or
|
|
9
|
+
* call `llm.complete` directly. The loop's `defineTool` / `toolRegistry`
|
|
10
|
+
* building blocks stay on the **stable** barrel — they're independently useful.
|
|
11
|
+
*/
|
|
12
|
+
export {
|
|
13
|
+
type AgentEvent,
|
|
14
|
+
AgentLoopError,
|
|
15
|
+
AgentLoopMaxIterationsError,
|
|
16
|
+
type AgentLoopOptions,
|
|
17
|
+
type AgentLoopResult,
|
|
18
|
+
agentLoop,
|
|
19
|
+
collectAssistantText,
|
|
20
|
+
} from "../loop/agentLoop.js";
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@sixthsummit/ship-api/libraries/ai` — LLM helper library public API.
|
|
3
|
+
*
|
|
4
|
+
* Add via `ship-api add -l ai`. Install only the SDK for the providers
|
|
5
|
+
* you use (Anthropic / OpenAI / …) — the library itself takes no SDK
|
|
6
|
+
* runtime dependency; concrete adapters are opt-in.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Adapters — concrete `LLMProvider` implementations. Install only the
|
|
10
|
+
// SDK for the providers you use (see `library.json#optionalNpmDependencies`).
|
|
11
|
+
export {
|
|
12
|
+
AnthropicAdapter,
|
|
13
|
+
type AnthropicAdapterOptions,
|
|
14
|
+
type AnthropicMessagesClient,
|
|
15
|
+
} from "./adapters/AnthropicAdapter.js";
|
|
16
|
+
// Interface — the load-bearing contract every provider adapter implements.
|
|
17
|
+
export type { LLMProvider } from "./adapters/LLMProvider.js";
|
|
18
|
+
export {
|
|
19
|
+
OpenAIAdapter,
|
|
20
|
+
type OpenAIAdapterOptions,
|
|
21
|
+
type OpenAIChatClient,
|
|
22
|
+
} from "./adapters/OpenAIAdapter.js";
|
|
23
|
+
|
|
24
|
+
// Tool-calling primitive — pairs a Zod schema with a typed handler;
|
|
25
|
+
// produces a `Tool` value the agent loop dispatches against.
|
|
26
|
+
export {
|
|
27
|
+
type DefineToolOptions,
|
|
28
|
+
defineTool,
|
|
29
|
+
type Tool,
|
|
30
|
+
type ToolContext,
|
|
31
|
+
type ToolExecuteResult,
|
|
32
|
+
type ToolHandler,
|
|
33
|
+
ToolRegistry,
|
|
34
|
+
toolRegistry,
|
|
35
|
+
} from "./tools/defineTool.js";
|
|
36
|
+
|
|
37
|
+
// Agent loop — moved OFF the stable surface to `./experimental` (AI-R2):
|
|
38
|
+
// the hand-rolled model→tool→model loop is the most volatile surface in the
|
|
39
|
+
// library (the ecosystem is moving to MCP / provider-native agent runtimes),
|
|
40
|
+
// so it carries no stability promise. Import it from
|
|
41
|
+
// `@sixthsummit/ship-api/libraries/ai/experimental`. The `defineTool` /
|
|
42
|
+
// `toolRegistry` building blocks above stay on the stable barrel — durable.
|
|
43
|
+
|
|
44
|
+
// Prompt registry — versioned, schema-validated prompt primitive with
|
|
45
|
+
// typed `{{name}}` substitution. Pairs with PromptRegistry for id-keyed
|
|
46
|
+
// lookup; supports multiple versions per id (eval-suite pinning).
|
|
47
|
+
export {
|
|
48
|
+
definePrompt,
|
|
49
|
+
type Prompt,
|
|
50
|
+
type PromptDefinition,
|
|
51
|
+
PromptError,
|
|
52
|
+
PromptRegistry,
|
|
53
|
+
PromptRenderError,
|
|
54
|
+
PromptValidationError,
|
|
55
|
+
promptRegistry,
|
|
56
|
+
} from "./prompts/definePrompt.js";
|
|
57
|
+
// RAG pipeline — pluggable VectorStore + LLMProvider driver.
|
|
58
|
+
// Library takes no dep on libraries/weaviate or any specific store —
|
|
59
|
+
// consumers inject their own VectorStore implementation.
|
|
60
|
+
export {
|
|
61
|
+
RAG_DEFAULT_PROMPT,
|
|
62
|
+
type RetrieveAndAnswerOptions,
|
|
63
|
+
type RetrieveAndAnswerResult,
|
|
64
|
+
type RetrievedDocument,
|
|
65
|
+
retrieveAndAnswer,
|
|
66
|
+
type VectorStore,
|
|
67
|
+
type VectorStoreSearchOptions,
|
|
68
|
+
} from "./rag/retrieveAndAnswer.js";
|
|
69
|
+
// Streaming seam — pipes a provider stream through a kernel streaming
|
|
70
|
+
// operation's `stream.emit`. The compatibility Hono `streamLLM(c, events)`
|
|
71
|
+
// helper remains in `@sixthsummit/ship-api` for route-first apps.
|
|
72
|
+
export {
|
|
73
|
+
type LLMFrameStream,
|
|
74
|
+
type LLMStreamFrame,
|
|
75
|
+
type StreamLLMOptions,
|
|
76
|
+
type StreamLLMResult,
|
|
77
|
+
streamLLM,
|
|
78
|
+
} from "./streaming/streamLLM.js";
|
|
79
|
+
// Structured outputs — single-shot Zod-typed completion via synthetic
|
|
80
|
+
// "respond" tool. Provider-portable (any LLMProvider that honors
|
|
81
|
+
// tools + toolChoice).
|
|
82
|
+
export {
|
|
83
|
+
type CompleteStructuredOptions,
|
|
84
|
+
type CompleteStructuredResult,
|
|
85
|
+
completeStructured,
|
|
86
|
+
StructuredOutputError,
|
|
87
|
+
} from "./structured/completeStructured.js";
|
|
88
|
+
|
|
89
|
+
// Token counting — the pluggable `Tokenizer` interface (durable: a real
|
|
90
|
+
// tiktoken/claude tokenizer implements it) + thin pre-call estimate helpers.
|
|
91
|
+
// Token *truth* is on `CompleteResult.usage` (AI-R3); `HeuristicTokenizer` /
|
|
92
|
+
// `countMessageTokens` are deprecated but kept exported for back-compat.
|
|
93
|
+
export {
|
|
94
|
+
type CountMessagesOptions,
|
|
95
|
+
countMessageTokens,
|
|
96
|
+
estimateMessageTokens,
|
|
97
|
+
estimateTokens,
|
|
98
|
+
// Deprecated (AI-R3) — prefer the estimators above for pre-call budgeting
|
|
99
|
+
// and the response `usage` for real counts.
|
|
100
|
+
HeuristicTokenizer,
|
|
101
|
+
type Tokenizer,
|
|
102
|
+
} from "./tokens/Tokenizer.js";
|
|
103
|
+
|
|
104
|
+
// Shared types — message format, completion options, streaming events.
|
|
105
|
+
export type {
|
|
106
|
+
CompleteOptions,
|
|
107
|
+
CompleteResult,
|
|
108
|
+
EmbedOptions,
|
|
109
|
+
EmbedResult,
|
|
110
|
+
ImagePart,
|
|
111
|
+
Message,
|
|
112
|
+
MessageContentPart,
|
|
113
|
+
StopReason,
|
|
114
|
+
StreamCompleteOptions,
|
|
115
|
+
StreamEvent,
|
|
116
|
+
StreamStartEvent,
|
|
117
|
+
StreamStopEvent,
|
|
118
|
+
StreamTextDeltaEvent,
|
|
119
|
+
StreamToolInputDeltaEvent,
|
|
120
|
+
StreamToolUseEndEvent,
|
|
121
|
+
StreamToolUseStartEvent,
|
|
122
|
+
TextPart,
|
|
123
|
+
TokenUsage,
|
|
124
|
+
ToolChoice,
|
|
125
|
+
ToolDefinition,
|
|
126
|
+
ToolResultPart,
|
|
127
|
+
ToolUsePart,
|
|
128
|
+
} from "./types.js";
|