@rudderjs/ai 1.17.3 → 1.18.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/README.md +19 -1274
- package/dist/budget-orm/index.d.ts +1 -95
- package/dist/budget-orm/index.d.ts.map +1 -1
- package/dist/budget-orm/index.js +4 -176
- package/dist/budget-orm/index.js.map +1 -1
- package/dist/chat-mentions.d.ts +1 -58
- package/dist/chat-mentions.d.ts.map +1 -1
- package/dist/chat-mentions.js +4 -80
- package/dist/chat-mentions.js.map +1 -1
- package/dist/commands/ai-eval.d.ts +1 -92
- package/dist/commands/ai-eval.d.ts.map +1 -1
- package/dist/commands/ai-eval.js +4 -377
- package/dist/commands/ai-eval.js.map +1 -1
- package/dist/commands/make-agent.d.ts +1 -2
- package/dist/commands/make-agent.d.ts.map +1 -1
- package/dist/commands/make-agent.js +4 -22
- package/dist/commands/make-agent.js.map +1 -1
- package/dist/computer-use/index.d.ts +1 -52
- package/dist/computer-use/index.d.ts.map +1 -1
- package/dist/computer-use/index.js +4 -50
- package/dist/computer-use/index.js.map +1 -1
- package/dist/conversation-orm/index.d.ts +1 -108
- package/dist/conversation-orm/index.d.ts.map +1 -1
- package/dist/conversation-orm/index.js +4 -214
- package/dist/conversation-orm/index.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +4 -65
- package/dist/doctor.js.map +1 -1
- package/dist/eval/index.d.ts +1 -270
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +4 -509
- package/dist/eval/index.js.map +1 -1
- package/dist/gateway/index.d.ts +1 -10
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js +4 -10
- package/dist/gateway/index.js.map +1 -1
- package/dist/index.d.ts +1 -66
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -78
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -15
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -14
- package/dist/mcp/index.js.map +1 -1
- package/dist/memory-embedding/index.d.ts +1 -120
- package/dist/memory-embedding/index.d.ts.map +1 -1
- package/dist/memory-embedding/index.js +4 -228
- package/dist/memory-embedding/index.js.map +1 -1
- package/dist/memory-orm/index.d.ts +1 -117
- package/dist/memory-orm/index.d.ts.map +1 -1
- package/dist/memory-orm/index.js +4 -186
- package/dist/memory-orm/index.js.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +4 -2
- package/dist/node/index.js.map +1 -1
- package/dist/observers.d.ts +1 -129
- package/dist/observers.d.ts.map +1 -1
- package/dist/observers.js +4 -39
- package/dist/observers.js.map +1 -1
- package/dist/react/index.d.ts +1 -15
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -15
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +9 -13
- package/boost/guidelines.md +0 -260
- package/boost/skills/ai-agents/SKILL.md +0 -240
- package/boost/skills/ai-tools/SKILL.md +0 -260
- package/dist/agent-run-store.d.ts +0 -161
- package/dist/agent-run-store.d.ts.map +0 -1
- package/dist/agent-run-store.js +0 -98
- package/dist/agent-run-store.js.map +0 -1
- package/dist/agent-sse.d.ts +0 -153
- package/dist/agent-sse.d.ts.map +0 -1
- package/dist/agent-sse.js +0 -282
- package/dist/agent-sse.js.map +0 -1
- package/dist/agent.d.ts +0 -508
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -1538
- package/dist/agent.js.map +0 -1
- package/dist/attachment.d.ts +0 -31
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -89
- package/dist/attachment.js.map +0 -1
- package/dist/audio.d.ts +0 -45
- package/dist/audio.d.ts.map +0 -1
- package/dist/audio.js +0 -93
- package/dist/audio.js.map +0 -1
- package/dist/base64.d.ts +0 -7
- package/dist/base64.d.ts.map +0 -1
- package/dist/base64.js +0 -39
- package/dist/base64.js.map +0 -1
- package/dist/budget/pricing.d.ts +0 -124
- package/dist/budget/pricing.d.ts.map +0 -1
- package/dist/budget/pricing.js +0 -175
- package/dist/budget/pricing.js.map +0 -1
- package/dist/budget/storage.d.ts +0 -104
- package/dist/budget/storage.d.ts.map +0 -1
- package/dist/budget/storage.js +0 -0
- package/dist/budget/storage.js.map +0 -1
- package/dist/budget/with-budget.d.ts +0 -119
- package/dist/budget/with-budget.d.ts.map +0 -1
- package/dist/budget/with-budget.js +0 -175
- package/dist/budget/with-budget.js.map +0 -1
- package/dist/cached-embedding.d.ts +0 -14
- package/dist/cached-embedding.d.ts.map +0 -1
- package/dist/cached-embedding.js +0 -44
- package/dist/cached-embedding.js.map +0 -1
- package/dist/computer-use/actions.d.ts +0 -214
- package/dist/computer-use/actions.d.ts.map +0 -1
- package/dist/computer-use/actions.js +0 -48
- package/dist/computer-use/actions.js.map +0 -1
- package/dist/computer-use/errors.d.ts +0 -57
- package/dist/computer-use/errors.d.ts.map +0 -1
- package/dist/computer-use/errors.js +0 -76
- package/dist/computer-use/errors.js.map +0 -1
- package/dist/computer-use/playwright.d.ts +0 -76
- package/dist/computer-use/playwright.d.ts.map +0 -1
- package/dist/computer-use/playwright.js +0 -270
- package/dist/computer-use/playwright.js.map +0 -1
- package/dist/computer-use/tool.d.ts +0 -154
- package/dist/computer-use/tool.d.ts.map +0 -1
- package/dist/computer-use/tool.js +0 -210
- package/dist/computer-use/tool.js.map +0 -1
- package/dist/continuation-validation.d.ts +0 -85
- package/dist/continuation-validation.d.ts.map +0 -1
- package/dist/continuation-validation.js +0 -166
- package/dist/continuation-validation.js.map +0 -1
- package/dist/conversation-persistence.d.ts +0 -46
- package/dist/conversation-persistence.d.ts.map +0 -1
- package/dist/conversation-persistence.js +0 -176
- package/dist/conversation-persistence.js.map +0 -1
- package/dist/conversation.d.ts +0 -11
- package/dist/conversation.d.ts.map +0 -1
- package/dist/conversation.js +0 -55
- package/dist/conversation.js.map +0 -1
- package/dist/eval/fixtures.d.ts +0 -65
- package/dist/eval/fixtures.d.ts.map +0 -1
- package/dist/eval/fixtures.js +0 -110
- package/dist/eval/fixtures.js.map +0 -1
- package/dist/eval/html-reporter.d.ts +0 -25
- package/dist/eval/html-reporter.d.ts.map +0 -1
- package/dist/eval/html-reporter.js +0 -209
- package/dist/eval/html-reporter.js.map +0 -1
- package/dist/eval/json-reporter.d.ts +0 -43
- package/dist/eval/json-reporter.d.ts.map +0 -1
- package/dist/eval/json-reporter.js +0 -40
- package/dist/eval/json-reporter.js.map +0 -1
- package/dist/facade.d.ts +0 -96
- package/dist/facade.d.ts.map +0 -1
- package/dist/facade.js +0 -146
- package/dist/facade.js.map +0 -1
- package/dist/fake.d.ts +0 -201
- package/dist/fake.d.ts.map +0 -1
- package/dist/fake.js +0 -428
- package/dist/fake.js.map +0 -1
- package/dist/file-search.d.ts +0 -168
- package/dist/file-search.d.ts.map +0 -1
- package/dist/file-search.js +0 -158
- package/dist/file-search.js.map +0 -1
- package/dist/files.d.ts +0 -27
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -44
- package/dist/files.js.map +0 -1
- package/dist/gateway/http-gateway-adapter.d.ts +0 -94
- package/dist/gateway/http-gateway-adapter.d.ts.map +0 -1
- package/dist/gateway/http-gateway-adapter.js +0 -106
- package/dist/gateway/http-gateway-adapter.js.map +0 -1
- package/dist/gateway/sse.d.ts +0 -28
- package/dist/gateway/sse.d.ts.map +0 -1
- package/dist/gateway/sse.js +0 -78
- package/dist/gateway/sse.js.map +0 -1
- package/dist/handoff.d.ts +0 -95
- package/dist/handoff.d.ts.map +0 -1
- package/dist/handoff.js +0 -78
- package/dist/handoff.js.map +0 -1
- package/dist/handoffs-driver.d.ts +0 -58
- package/dist/handoffs-driver.d.ts.map +0 -1
- package/dist/handoffs-driver.js +0 -103
- package/dist/handoffs-driver.js.map +0 -1
- package/dist/image.d.ts +0 -40
- package/dist/image.d.ts.map +0 -1
- package/dist/image.js +0 -109
- package/dist/image.js.map +0 -1
- package/dist/mcp/client-tools.d.ts +0 -39
- package/dist/mcp/client-tools.d.ts.map +0 -1
- package/dist/mcp/client-tools.js +0 -147
- package/dist/mcp/client-tools.js.map +0 -1
- package/dist/mcp/server-from-agent.d.ts +0 -24
- package/dist/mcp/server-from-agent.d.ts.map +0 -1
- package/dist/mcp/server-from-agent.js +0 -113
- package/dist/mcp/server-from-agent.js.map +0 -1
- package/dist/mcp/types.d.ts +0 -64
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js +0 -6
- package/dist/mcp/types.js.map +0 -1
- package/dist/memory-extract.d.ts +0 -60
- package/dist/memory-extract.d.ts.map +0 -1
- package/dist/memory-extract.js +0 -163
- package/dist/memory-extract.js.map +0 -1
- package/dist/memory-inject.d.ts +0 -39
- package/dist/memory-inject.d.ts.map +0 -1
- package/dist/memory-inject.js +0 -135
- package/dist/memory-inject.js.map +0 -1
- package/dist/memory.d.ts +0 -55
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js +0 -132
- package/dist/memory.js.map +0 -1
- package/dist/middleware.d.ts +0 -18
- package/dist/middleware.d.ts.map +0 -1
- package/dist/middleware.js +0 -72
- package/dist/middleware.js.map +0 -1
- package/dist/node/attachment.d.ts +0 -6
- package/dist/node/attachment.d.ts.map +0 -1
- package/dist/node/attachment.js +0 -35
- package/dist/node/attachment.js.map +0 -1
- package/dist/node/transcription.d.ts +0 -4
- package/dist/node/transcription.d.ts.map +0 -1
- package/dist/node/transcription.js +0 -8
- package/dist/node/transcription.js.map +0 -1
- package/dist/output.d.ts +0 -22
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -60
- package/dist/output.js.map +0 -1
- package/dist/provider-tools.d.ts +0 -87
- package/dist/provider-tools.d.ts.map +0 -1
- package/dist/provider-tools.js +0 -189
- package/dist/provider-tools.js.map +0 -1
- package/dist/providers/anthropic.d.ts +0 -24
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js +0 -405
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/azure.d.ts +0 -13
- package/dist/providers/azure.d.ts.map +0 -1
- package/dist/providers/azure.js +0 -15
- package/dist/providers/azure.js.map +0 -1
- package/dist/providers/bedrock.d.ts +0 -75
- package/dist/providers/bedrock.d.ts.map +0 -1
- package/dist/providers/bedrock.js +0 -181
- package/dist/providers/bedrock.js.map +0 -1
- package/dist/providers/cohere.d.ts +0 -13
- package/dist/providers/cohere.d.ts.map +0 -1
- package/dist/providers/cohere.js +0 -87
- package/dist/providers/cohere.js.map +0 -1
- package/dist/providers/deepseek.d.ts +0 -12
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js +0 -15
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/elevenlabs.d.ts +0 -98
- package/dist/providers/elevenlabs.d.ts.map +0 -1
- package/dist/providers/elevenlabs.js +0 -229
- package/dist/providers/elevenlabs.js.map +0 -1
- package/dist/providers/google-cache-registry.d.ts +0 -132
- package/dist/providers/google-cache-registry.d.ts.map +0 -1
- package/dist/providers/google-cache-registry.js +0 -209
- package/dist/providers/google-cache-registry.js.map +0 -1
- package/dist/providers/google.d.ts +0 -38
- package/dist/providers/google.d.ts.map +0 -1
- package/dist/providers/google.js +0 -903
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/groq.d.ts +0 -12
- package/dist/providers/groq.d.ts.map +0 -1
- package/dist/providers/groq.js +0 -15
- package/dist/providers/groq.js.map +0 -1
- package/dist/providers/jina.d.ts +0 -13
- package/dist/providers/jina.d.ts.map +0 -1
- package/dist/providers/jina.js +0 -90
- package/dist/providers/jina.js.map +0 -1
- package/dist/providers/mistral.d.ts +0 -13
- package/dist/providers/mistral.d.ts.map +0 -1
- package/dist/providers/mistral.js +0 -46
- package/dist/providers/mistral.js.map +0 -1
- package/dist/providers/ollama.d.ts +0 -11
- package/dist/providers/ollama.d.ts.map +0 -1
- package/dist/providers/ollama.js +0 -15
- package/dist/providers/ollama.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -79
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js +0 -792
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/openrouter.d.ts +0 -43
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js +0 -21
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/voyage.d.ts +0 -91
- package/dist/providers/voyage.d.ts.map +0 -1
- package/dist/providers/voyage.js +0 -166
- package/dist/providers/voyage.js.map +0 -1
- package/dist/providers/xai.d.ts +0 -12
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js +0 -15
- package/dist/providers/xai.js.map +0 -1
- package/dist/queue-job.d.ts +0 -100
- package/dist/queue-job.d.ts.map +0 -1
- package/dist/queue-job.js +0 -185
- package/dist/queue-job.js.map +0 -1
- package/dist/react/agent-run.d.ts +0 -111
- package/dist/react/agent-run.d.ts.map +0 -1
- package/dist/react/agent-run.js +0 -107
- package/dist/react/agent-run.js.map +0 -1
- package/dist/react/useAgentRun.d.ts +0 -68
- package/dist/react/useAgentRun.d.ts.map +0 -1
- package/dist/react/useAgentRun.js +0 -125
- package/dist/react/useAgentRun.js.map +0 -1
- package/dist/registry.d.ts +0 -45
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -131
- package/dist/registry.js.map +0 -1
- package/dist/rerank.d.ts +0 -20
- package/dist/rerank.d.ts.map +0 -1
- package/dist/rerank.js +0 -40
- package/dist/rerank.js.map +0 -1
- package/dist/resume-approval.d.ts +0 -30
- package/dist/resume-approval.d.ts.map +0 -1
- package/dist/resume-approval.js +0 -147
- package/dist/resume-approval.js.map +0 -1
- package/dist/sanitize-conversation.d.ts +0 -43
- package/dist/sanitize-conversation.d.ts.map +0 -1
- package/dist/sanitize-conversation.js +0 -85
- package/dist/sanitize-conversation.js.map +0 -1
- package/dist/scoped-tool.d.ts +0 -98
- package/dist/scoped-tool.d.ts.map +0 -1
- package/dist/scoped-tool.js +0 -174
- package/dist/scoped-tool.js.map +0 -1
- package/dist/server/provider.d.ts +0 -22
- package/dist/server/provider.d.ts.map +0 -1
- package/dist/server/provider.js +0 -194
- package/dist/server/provider.js.map +0 -1
- package/dist/similarity-search.d.ts +0 -163
- package/dist/similarity-search.d.ts.map +0 -1
- package/dist/similarity-search.js +0 -147
- package/dist/similarity-search.js.map +0 -1
- package/dist/sub-agent-run-store.d.ts +0 -157
- package/dist/sub-agent-run-store.d.ts.map +0 -1
- package/dist/sub-agent-run-store.js +0 -87
- package/dist/sub-agent-run-store.js.map +0 -1
- package/dist/tool-execution.d.ts +0 -16
- package/dist/tool-execution.d.ts.map +0 -1
- package/dist/tool-execution.js +0 -498
- package/dist/tool-execution.js.map +0 -1
- package/dist/tool-helpers.d.ts +0 -77
- package/dist/tool-helpers.d.ts.map +0 -1
- package/dist/tool-helpers.js +0 -117
- package/dist/tool-helpers.js.map +0 -1
- package/dist/tool.d.ts +0 -216
- package/dist/tool.d.ts.map +0 -1
- package/dist/tool.js +0 -175
- package/dist/tool.js.map +0 -1
- package/dist/transcription.d.ts +0 -42
- package/dist/transcription.d.ts.map +0 -1
- package/dist/transcription.js +0 -77
- package/dist/transcription.js.map +0 -1
- package/dist/types.d.ts +0 -1020
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/util/hash.d.ts +0 -11
- package/dist/util/hash.d.ts.map +0 -1
- package/dist/util/hash.js +0 -23
- package/dist/util/hash.js.map +0 -1
- package/dist/vector-stores/index.d.ts +0 -96
- package/dist/vector-stores/index.d.ts.map +0 -1
- package/dist/vector-stores/index.js +0 -153
- package/dist/vector-stores/index.js.map +0 -1
- package/dist/vercel-protocol.d.ts +0 -18
- package/dist/vercel-protocol.d.ts.map +0 -1
- package/dist/vercel-protocol.js +0 -75
- package/dist/vercel-protocol.js.map +0 -1
- package/dist/zod-to-json-schema.d.ts +0 -16
- package/dist/zod-to-json-schema.d.ts.map +0 -1
- package/dist/zod-to-json-schema.js +0 -17
- package/dist/zod-to-json-schema.js.map +0 -1
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* `@rudderjs/ai/conversation-orm` - ORM-backed {@link ConversationStore}.
|
|
3
|
-
*
|
|
4
|
-
* Production-grade replacement for `MemoryConversationStore` (which is
|
|
5
|
-
* single-process, in-memory, and loses every thread on restart). Persists
|
|
6
|
-
* conversation threads and their messages via the registered `@rudderjs/orm`
|
|
7
|
-
* adapter - works across web processes, queue workers, and horizontally
|
|
8
|
-
* scaled deployments. Mirrors the `@rudderjs/ai/memory-orm` /
|
|
9
|
-
* `@rudderjs/ai/budget-orm` pattern.
|
|
10
|
-
*
|
|
11
|
-
* Wire it as the conversation store:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { setConversationStore } from '@rudderjs/ai'
|
|
15
|
-
* import { OrmConversationStore } from '@rudderjs/ai/conversation-orm'
|
|
16
|
-
*
|
|
17
|
-
* setConversationStore(new OrmConversationStore())
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The schema lives at {@link conversationOrmPrismaSchema} - copy it into your
|
|
21
|
-
* Prisma schema (or a new `prisma/schema/<file>.prisma` if you use the
|
|
22
|
-
* multi-file setup). On the native engine, add an equivalent migration; on
|
|
23
|
-
* Drizzle, define matching tables and register them via `tables: { ... }`.
|
|
24
|
-
*
|
|
25
|
-
* # Adapter coverage
|
|
26
|
-
*
|
|
27
|
-
* - Prisma - works out of the box; copy {@link conversationOrmPrismaSchema}.
|
|
28
|
-
* - Native - add a migration with the same columns.
|
|
29
|
-
* - Drizzle - define the two tables and register them on the `drizzle()`
|
|
30
|
-
* config.
|
|
31
|
-
*
|
|
32
|
-
* # Ordering & concurrency
|
|
33
|
-
*
|
|
34
|
-
* Messages carry a monotonic per-thread `position` so `load()` returns them
|
|
35
|
-
* in append order regardless of timestamp granularity. `append()` reads the
|
|
36
|
-
* current max position and assigns the next slots; like
|
|
37
|
-
* `OrmBudgetStorage.checkAndDebit`, the read-then-write is not isolated, so
|
|
38
|
-
* two concurrent appends to the SAME thread could collide on a position.
|
|
39
|
-
* Conversation threads are single-writer in practice (one user, one turn at
|
|
40
|
-
* a time), so this is a non-issue for typical apps. File an issue if you hit
|
|
41
|
-
* it; strict ordering needs a serializable transaction or a DB sequence.
|
|
42
|
-
*/
|
|
43
|
-
import { Model } from '@rudderjs/orm';
|
|
44
|
-
import type { AiMessage, ConversationStore, ConversationStoreListEntry, ConversationStoreMeta } from '../types.js';
|
|
45
|
-
/**
|
|
46
|
-
* The thread row backing {@link OrmConversationStore}. Exposed so apps that
|
|
47
|
-
* want their own queries (admin views, analytics) can use
|
|
48
|
-
* `AiConversationRecord.where(...).get()` directly.
|
|
49
|
-
*
|
|
50
|
-
* `userId` / `agent` mirror {@link ConversationStoreMeta} - `userId` scopes
|
|
51
|
-
* `list()`, `agent` carries the thread-segregation key the auto-persist
|
|
52
|
-
* machinery uses to keep one user's threads per agent class apart.
|
|
53
|
-
*/
|
|
54
|
-
export declare class AiConversationRecord extends Model {
|
|
55
|
-
static table: string;
|
|
56
|
-
static fillable: string[];
|
|
57
|
-
id: string;
|
|
58
|
-
title: string;
|
|
59
|
-
userId: string | null;
|
|
60
|
-
agent: string | null;
|
|
61
|
-
createdAt: Date;
|
|
62
|
-
updatedAt: Date | null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* One message row in a thread. `content` and `toolCalls` are JSON-encoded
|
|
66
|
-
* strings (so a `string` content and a `ContentPart[]` content both
|
|
67
|
-
* round-trip through a portable `text` column); `position` orders them.
|
|
68
|
-
*/
|
|
69
|
-
export declare class AiConversationMessageRecord extends Model {
|
|
70
|
-
static table: string;
|
|
71
|
-
static fillable: string[];
|
|
72
|
-
id: string;
|
|
73
|
-
conversationId: string;
|
|
74
|
-
position: number;
|
|
75
|
-
role: string;
|
|
76
|
-
/** JSON-encoded `string | ContentPart[]`. */
|
|
77
|
-
content: string;
|
|
78
|
-
toolCallId: string | null;
|
|
79
|
-
/** JSON-encoded `ToolCall[]` or null. */
|
|
80
|
-
toolCalls: string | null;
|
|
81
|
-
createdAt: Date;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* {@link ConversationStore} implementation that persists rows to the
|
|
85
|
-
* registered ORM adapter. Designed for production use - the in-process
|
|
86
|
-
* `MemoryConversationStore` is for tests and dev.
|
|
87
|
-
*/
|
|
88
|
-
export declare class OrmConversationStore implements ConversationStore {
|
|
89
|
-
create(title?: string, meta?: ConversationStoreMeta): Promise<string>;
|
|
90
|
-
load(conversationId: string): Promise<AiMessage[]>;
|
|
91
|
-
append(conversationId: string, messages: AiMessage[]): Promise<void>;
|
|
92
|
-
setTitle(conversationId: string, title: string): Promise<void>;
|
|
93
|
-
list(userId?: string): Promise<ConversationStoreListEntry[]>;
|
|
94
|
-
delete(conversationId: string): Promise<void>;
|
|
95
|
-
/** Throw the same not-found error shape as `MemoryConversationStore`. */
|
|
96
|
-
private requireThread;
|
|
97
|
-
/** Next monotonic position for the thread (0 when empty). */
|
|
98
|
-
private nextPosition;
|
|
99
|
-
}
|
|
100
|
-
/** Convenience factory mirroring `ormBudgetStorage()` / `OrmUserMemory`. */
|
|
101
|
-
export declare function ormConversationStore(): OrmConversationStore;
|
|
102
|
-
/**
|
|
103
|
-
* Reference Prisma schema for `OrmConversationStore`. Copy into your
|
|
104
|
-
* `prisma/schema/<file>.prisma`. SQLite stores the `text` content as TEXT;
|
|
105
|
-
* Postgres as `text`. The `@@index` keeps `list()` (by user) and `load()`
|
|
106
|
-
* (by thread, ordered) cheap.
|
|
107
|
-
*/
|
|
108
|
-
export declare const conversationOrmPrismaSchema = "model AiConversation {\n id String @id @default(cuid())\n title String\n userId String?\n /// Thread-segregation key - the agent class name by default\n agent String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n}\n\nmodel AiConversationMessage {\n id String @id @default(cuid())\n conversationId String\n /// Monotonic per-thread ordering\n position Int\n role String\n /// JSON-encoded `string | ContentPart[]`\n content String\n toolCallId String?\n /// JSON-encoded `ToolCall[]` or null\n toolCalls String?\n createdAt DateTime @default(now())\n\n @@index([conversationId, position])\n}\n";
|
|
1
|
+
export * from '@gemstack/ai-sdk/conversation-orm';
|
|
109
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"AAGA,cAAc,mCAAmC,CAAA"}
|
|
@@ -1,215 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* single-process, in-memory, and loses every thread on restart). Persists
|
|
6
|
-
* conversation threads and their messages via the registered `@rudderjs/orm`
|
|
7
|
-
* adapter - works across web processes, queue workers, and horizontally
|
|
8
|
-
* scaled deployments. Mirrors the `@rudderjs/ai/memory-orm` /
|
|
9
|
-
* `@rudderjs/ai/budget-orm` pattern.
|
|
10
|
-
*
|
|
11
|
-
* Wire it as the conversation store:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { setConversationStore } from '@rudderjs/ai'
|
|
15
|
-
* import { OrmConversationStore } from '@rudderjs/ai/conversation-orm'
|
|
16
|
-
*
|
|
17
|
-
* setConversationStore(new OrmConversationStore())
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The schema lives at {@link conversationOrmPrismaSchema} - copy it into your
|
|
21
|
-
* Prisma schema (or a new `prisma/schema/<file>.prisma` if you use the
|
|
22
|
-
* multi-file setup). On the native engine, add an equivalent migration; on
|
|
23
|
-
* Drizzle, define matching tables and register them via `tables: { ... }`.
|
|
24
|
-
*
|
|
25
|
-
* # Adapter coverage
|
|
26
|
-
*
|
|
27
|
-
* - Prisma - works out of the box; copy {@link conversationOrmPrismaSchema}.
|
|
28
|
-
* - Native - add a migration with the same columns.
|
|
29
|
-
* - Drizzle - define the two tables and register them on the `drizzle()`
|
|
30
|
-
* config.
|
|
31
|
-
*
|
|
32
|
-
* # Ordering & concurrency
|
|
33
|
-
*
|
|
34
|
-
* Messages carry a monotonic per-thread `position` so `load()` returns them
|
|
35
|
-
* in append order regardless of timestamp granularity. `append()` reads the
|
|
36
|
-
* current max position and assigns the next slots; like
|
|
37
|
-
* `OrmBudgetStorage.checkAndDebit`, the read-then-write is not isolated, so
|
|
38
|
-
* two concurrent appends to the SAME thread could collide on a position.
|
|
39
|
-
* Conversation threads are single-writer in practice (one user, one turn at
|
|
40
|
-
* a time), so this is a non-issue for typical apps. File an issue if you hit
|
|
41
|
-
* it; strict ordering needs a serializable transaction or a DB sequence.
|
|
42
|
-
*/
|
|
43
|
-
import { Model } from '@rudderjs/orm';
|
|
44
|
-
import { sanitizeConversation } from '../sanitize-conversation.js';
|
|
45
|
-
// ─── ORM Models ───────────────────────────────────────────
|
|
46
|
-
/**
|
|
47
|
-
* The thread row backing {@link OrmConversationStore}. Exposed so apps that
|
|
48
|
-
* want their own queries (admin views, analytics) can use
|
|
49
|
-
* `AiConversationRecord.where(...).get()` directly.
|
|
50
|
-
*
|
|
51
|
-
* `userId` / `agent` mirror {@link ConversationStoreMeta} - `userId` scopes
|
|
52
|
-
* `list()`, `agent` carries the thread-segregation key the auto-persist
|
|
53
|
-
* machinery uses to keep one user's threads per agent class apart.
|
|
54
|
-
*/
|
|
55
|
-
export class AiConversationRecord extends Model {
|
|
56
|
-
static table = 'aiConversation';
|
|
57
|
-
static fillable = ['title', 'userId', 'agent', 'updatedAt'];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* One message row in a thread. `content` and `toolCalls` are JSON-encoded
|
|
61
|
-
* strings (so a `string` content and a `ContentPart[]` content both
|
|
62
|
-
* round-trip through a portable `text` column); `position` orders them.
|
|
63
|
-
*/
|
|
64
|
-
export class AiConversationMessageRecord extends Model {
|
|
65
|
-
static table = 'aiConversationMessage';
|
|
66
|
-
static fillable = ['conversationId', 'position', 'role', 'content', 'toolCallId', 'toolCalls'];
|
|
67
|
-
}
|
|
68
|
-
// ─── ConversationStore adapter ────────────────────────────
|
|
69
|
-
/**
|
|
70
|
-
* {@link ConversationStore} implementation that persists rows to the
|
|
71
|
-
* registered ORM adapter. Designed for production use - the in-process
|
|
72
|
-
* `MemoryConversationStore` is for tests and dev.
|
|
73
|
-
*/
|
|
74
|
-
export class OrmConversationStore {
|
|
75
|
-
async create(title, meta) {
|
|
76
|
-
const data = { title: title ?? 'New conversation' };
|
|
77
|
-
if (meta?.userId !== undefined)
|
|
78
|
-
data['userId'] = meta.userId;
|
|
79
|
-
if (meta?.agent !== undefined)
|
|
80
|
-
data['agent'] = meta.agent;
|
|
81
|
-
const created = await AiConversationRecord.create(data);
|
|
82
|
-
return created.id;
|
|
83
|
-
}
|
|
84
|
-
async load(conversationId) {
|
|
85
|
-
await this.requireThread(conversationId);
|
|
86
|
-
const rows = await AiConversationMessageRecord
|
|
87
|
-
.where('conversationId', conversationId)
|
|
88
|
-
.orderBy('position', 'ASC')
|
|
89
|
-
.get();
|
|
90
|
-
// A thread persisted mid-turn (crash between the assistant row and its
|
|
91
|
-
// tool-result rows) would otherwise replay into a provider 400. Drop the
|
|
92
|
-
// incomplete turns at the load boundary so the history is replay-safe.
|
|
93
|
-
return sanitizeConversation(rows.map(rowToMessage));
|
|
94
|
-
}
|
|
95
|
-
async append(conversationId, messages) {
|
|
96
|
-
await this.requireThread(conversationId);
|
|
97
|
-
if (messages.length === 0)
|
|
98
|
-
return;
|
|
99
|
-
let position = await this.nextPosition(conversationId);
|
|
100
|
-
for (const message of messages) {
|
|
101
|
-
await AiConversationMessageRecord.create(messageToRow(conversationId, position, message));
|
|
102
|
-
position++;
|
|
103
|
-
}
|
|
104
|
-
await AiConversationRecord.where('id', conversationId).updateAll({ updatedAt: new Date() });
|
|
105
|
-
}
|
|
106
|
-
async setTitle(conversationId, title) {
|
|
107
|
-
const updated = await AiConversationRecord
|
|
108
|
-
.where('id', conversationId)
|
|
109
|
-
.updateAll({ title, updatedAt: new Date() });
|
|
110
|
-
if (!updated)
|
|
111
|
-
throw notFound(conversationId);
|
|
112
|
-
}
|
|
113
|
-
async list(userId) {
|
|
114
|
-
let q = AiConversationRecord.query();
|
|
115
|
-
if (userId != null)
|
|
116
|
-
q = q.where('userId', userId);
|
|
117
|
-
const rows = await q.orderBy('updatedAt', 'DESC').get();
|
|
118
|
-
return rows.map(rowToListEntry);
|
|
119
|
-
}
|
|
120
|
-
async delete(conversationId) {
|
|
121
|
-
await AiConversationMessageRecord.where('conversationId', conversationId).deleteAll();
|
|
122
|
-
await AiConversationRecord.where('id', conversationId).deleteAll();
|
|
123
|
-
}
|
|
124
|
-
/** Throw the same not-found error shape as `MemoryConversationStore`. */
|
|
125
|
-
async requireThread(conversationId) {
|
|
126
|
-
const thread = await AiConversationRecord.where('id', conversationId).first();
|
|
127
|
-
if (!thread)
|
|
128
|
-
throw notFound(conversationId);
|
|
129
|
-
}
|
|
130
|
-
/** Next monotonic position for the thread (0 when empty). */
|
|
131
|
-
async nextPosition(conversationId) {
|
|
132
|
-
const last = await AiConversationMessageRecord
|
|
133
|
-
.where('conversationId', conversationId)
|
|
134
|
-
.orderBy('position', 'DESC')
|
|
135
|
-
.first();
|
|
136
|
-
return last ? last.position + 1 : 0;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
/** Convenience factory mirroring `ormBudgetStorage()` / `OrmUserMemory`. */
|
|
140
|
-
export function ormConversationStore() {
|
|
141
|
-
return new OrmConversationStore();
|
|
142
|
-
}
|
|
143
|
-
// ─── Schema reference ─────────────────────────────────────
|
|
144
|
-
/**
|
|
145
|
-
* Reference Prisma schema for `OrmConversationStore`. Copy into your
|
|
146
|
-
* `prisma/schema/<file>.prisma`. SQLite stores the `text` content as TEXT;
|
|
147
|
-
* Postgres as `text`. The `@@index` keeps `list()` (by user) and `load()`
|
|
148
|
-
* (by thread, ordered) cheap.
|
|
149
|
-
*/
|
|
150
|
-
export const conversationOrmPrismaSchema = `model AiConversation {
|
|
151
|
-
id String @id @default(cuid())
|
|
152
|
-
title String
|
|
153
|
-
userId String?
|
|
154
|
-
/// Thread-segregation key - the agent class name by default
|
|
155
|
-
agent String?
|
|
156
|
-
createdAt DateTime @default(now())
|
|
157
|
-
updatedAt DateTime @updatedAt
|
|
158
|
-
|
|
159
|
-
@@index([userId])
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
model AiConversationMessage {
|
|
163
|
-
id String @id @default(cuid())
|
|
164
|
-
conversationId String
|
|
165
|
-
/// Monotonic per-thread ordering
|
|
166
|
-
position Int
|
|
167
|
-
role String
|
|
168
|
-
/// JSON-encoded \`string | ContentPart[]\`
|
|
169
|
-
content String
|
|
170
|
-
toolCallId String?
|
|
171
|
-
/// JSON-encoded \`ToolCall[]\` or null
|
|
172
|
-
toolCalls String?
|
|
173
|
-
createdAt DateTime @default(now())
|
|
174
|
-
|
|
175
|
-
@@index([conversationId, position])
|
|
176
|
-
}
|
|
177
|
-
`;
|
|
178
|
-
// ─── Helpers ──────────────────────────────────────────────
|
|
179
|
-
function notFound(conversationId) {
|
|
180
|
-
return new Error(`[Rudder AI] Conversation "${conversationId}" not found.`);
|
|
181
|
-
}
|
|
182
|
-
function messageToRow(conversationId, position, m) {
|
|
183
|
-
return {
|
|
184
|
-
conversationId,
|
|
185
|
-
position,
|
|
186
|
-
role: m.role,
|
|
187
|
-
content: JSON.stringify(m.content),
|
|
188
|
-
toolCallId: m.toolCallId ?? null,
|
|
189
|
-
toolCalls: m.toolCalls ? JSON.stringify(m.toolCalls) : null,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function rowToMessage(row) {
|
|
193
|
-
const out = {
|
|
194
|
-
role: row.role,
|
|
195
|
-
content: JSON.parse(row.content),
|
|
196
|
-
};
|
|
197
|
-
if (row.toolCallId != null)
|
|
198
|
-
out.toolCallId = row.toolCallId;
|
|
199
|
-
if (row.toolCalls != null)
|
|
200
|
-
out.toolCalls = JSON.parse(row.toolCalls);
|
|
201
|
-
return out;
|
|
202
|
-
}
|
|
203
|
-
function rowToListEntry(row) {
|
|
204
|
-
const out = {
|
|
205
|
-
id: row.id,
|
|
206
|
-
title: row.title,
|
|
207
|
-
createdAt: row.createdAt,
|
|
208
|
-
};
|
|
209
|
-
if (row.updatedAt != null)
|
|
210
|
-
out.updatedAt = row.updatedAt;
|
|
211
|
-
if (row.agent != null)
|
|
212
|
-
out.agent = row.agent;
|
|
213
|
-
return out;
|
|
214
|
-
}
|
|
1
|
+
// @rudderjs/ai is deprecated. The AI engine now lives in @gemstack/ai-sdk.
|
|
2
|
+
// This module re-exports it for backwards compatibility; import from
|
|
3
|
+
// '@gemstack/ai-sdk/conversation-orm' directly in new code.
|
|
4
|
+
export * from '@gemstack/ai-sdk/conversation-orm';
|
|
215
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/conversation-orm/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,4DAA4D;AAC5D,cAAc,mCAAmC,CAAA"}
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from '@gemstack/ai-sdk/doctor';
|
|
2
2
|
//# sourceMappingURL=doctor.d.ts.map
|
package/dist/doctor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAA"}
|
package/dist/doctor.js
CHANGED
|
@@ -1,66 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function readFileSafe(rel) {
|
|
6
|
-
try {
|
|
7
|
-
return fs.readFileSync(path.join(process.cwd(), rel), 'utf-8');
|
|
8
|
-
}
|
|
9
|
-
catch {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
// Maps provider driver name → env var the user must set. Mirrors the
|
|
14
|
-
// driver names listed in @rudderjs/ai's provider implementations.
|
|
15
|
-
const PROVIDER_ENV = {
|
|
16
|
-
anthropic: 'ANTHROPIC_API_KEY',
|
|
17
|
-
openai: 'OPENAI_API_KEY',
|
|
18
|
-
google: 'GOOGLE_AI_API_KEY',
|
|
19
|
-
bedrock: 'AWS_ACCESS_KEY_ID',
|
|
20
|
-
groq: 'GROQ_API_KEY',
|
|
21
|
-
openrouter: 'OPENROUTER_API_KEY',
|
|
22
|
-
// ollama, lmstudio: local — no key needed.
|
|
23
|
-
};
|
|
24
|
-
// Extracts driver names referenced by config/ai.ts WITHOUT importing the
|
|
25
|
-
// module. We grep for `driver: '<name>'` literals — covers the scaffolded
|
|
26
|
-
// shape.
|
|
27
|
-
function declaredProviders() {
|
|
28
|
-
const text = readFileSafe('config/ai.ts') ??
|
|
29
|
-
readFileSafe('config/ai.js') ??
|
|
30
|
-
readFileSafe('config/ai.mjs') ?? '';
|
|
31
|
-
const matches = [...text.matchAll(/driver\s*:\s*['"]([^'"]+)['"]/g)];
|
|
32
|
-
return [...new Set(matches.map(m => m[1]).filter(Boolean))];
|
|
33
|
-
}
|
|
34
|
-
registerDoctorCheck({
|
|
35
|
-
id: 'ai:provider-keys',
|
|
36
|
-
category: 'ai',
|
|
37
|
-
title: 'AI provider API keys',
|
|
38
|
-
run() {
|
|
39
|
-
const providers = declaredProviders();
|
|
40
|
-
if (providers.length === 0) {
|
|
41
|
-
return { status: 'ok', message: 'no config/ai.ts or no providers declared — skip' };
|
|
42
|
-
}
|
|
43
|
-
const needsKey = providers.filter(p => p in PROVIDER_ENV);
|
|
44
|
-
if (needsKey.length === 0) {
|
|
45
|
-
return { status: 'ok', message: `${providers.length} provider(s) — all local (no keys required)` };
|
|
46
|
-
}
|
|
47
|
-
const missing = needsKey.filter(p => !process.env[PROVIDER_ENV[p]]);
|
|
48
|
-
if (missing.length === needsKey.length) {
|
|
49
|
-
return {
|
|
50
|
-
status: 'warn',
|
|
51
|
-
message: `none of ${needsKey.length} cloud provider(s) have an API key set`,
|
|
52
|
-
fix: `Set at least one of: ${needsKey.map(p => PROVIDER_ENV[p]).join(', ')} (or remove the providers from config/ai.ts if unused)`,
|
|
53
|
-
detail: `Declared providers: ${needsKey.join(', ')}`,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (missing.length > 0) {
|
|
57
|
-
return {
|
|
58
|
-
status: 'warn',
|
|
59
|
-
message: `${needsKey.length - missing.length}/${needsKey.length} cloud provider(s) have keys`,
|
|
60
|
-
fix: `Set missing keys: ${missing.map(p => PROVIDER_ENV[p]).join(', ')} (or remove the providers from config/ai.ts if unused)`,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return { status: 'ok', message: `${needsKey.length} cloud provider(s), all keys present` };
|
|
64
|
-
},
|
|
65
|
-
});
|
|
1
|
+
// @rudderjs/ai is deprecated. The AI engine now lives in @gemstack/ai-sdk.
|
|
2
|
+
// This module re-exports it for backwards compatibility; import from
|
|
3
|
+
// '@gemstack/ai-sdk/doctor' directly in new code.
|
|
4
|
+
export * from '@gemstack/ai-sdk/doctor';
|
|
66
5
|
//# sourceMappingURL=doctor.js.map
|
package/dist/doctor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qEAAqE;AACrE,kDAAkD;AAClD,cAAc,yBAAyB,CAAA"}
|