diff --git a/.cursor/rules/convex.mdc b/.cursor/rules/convex.mdc deleted file mode 100644 index 4af09241..00000000 --- a/.cursor/rules/convex.mdc +++ /dev/null @@ -1,497 +0,0 @@ ---- -description: -globs: ---- -# Convex guidelines -## Function guidelines -### New function syntax -- ALWAYS use the new function syntax for Convex functions. For example: - ```typescript - import { query } from "./_generated/server"; - import { v } from "convex/values"; - export const f = query({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - // Function body - }, - }); - ``` - -### Http endpoint syntax -- HTTP endpoints are defined in `convex/http.ts` and require an `httpAction` decorator. For example: - ```typescript - import { httpRouter } from "convex/server"; - import { httpAction } from "./_generated/server"; - const http = httpRouter(); - http.route({ - path: "/echo", - method: "POST", - handler: httpAction(async (ctx, req) => { - const body = await req.bytes(); - return new Response(body, { status: 200 }); - }), - }); - ``` - -### Function registration -- Use `internalQuery`, `internalMutation`, and `internalAction` to register internal functions. These functions are private and aren't part of an app's API. They can only be called by other Convex functions. -- Use `query`, `mutation`, and `action` to register public functions. These functions are part of the public API and are exposed to the public Internet. Do NOT use `query`, `mutation`, or `action` to register sensitive internal functions that should be kept private. -- You CANNOT register a function through the `api` or `internal` objects. -- ALWAYS include argument and return validators for all Convex functions. If a function doesn't return anything, include `returns: v.null()` as its output validator. -- If the JavaScript implementation of a Convex function doesn't have a return value, it implicitly returns `null`. - -### Function calling -- Use `ctx.runQuery` to call a query from a query, mutation, or action. -- Use `ctx.runMutation` to call a mutation from a mutation or action. -- Use `ctx.runAction` to call an action from an action. -- ONLY call an action from another action if you need to cross runtimes (e.g. from V8 to Node). Otherwise, pull out the shared code into a helper async function and call that directly instead. -- Try to use as few calls from actions to queries and mutations as possible. Queries and mutations are transactions, so splitting logic up into multiple calls introduces the risk of race conditions. -- All of these calls take in a `FunctionReference`. Do NOT try to pass the callee function directly into one of these calls. -- When using `ctx.runQuery`, `ctx.runMutation`, or `ctx.runAction` to call a function in the same file, specify a type annotation on the return value to work around TypeScript circularity limitations. For example, - ``` - export const f = query({ - args: { name: v.string() }, - returns: v.string(), - handler: async (ctx, args) => { - return "Hello " + args.name; - }, - }); - - export const g = query({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - const result: string = await ctx.runQuery(api.example.f, { name: "Bob" }); - return null; - }, - }); - ``` - -### Function references -- Function references are pointers to registered Convex functions. -- Use the `api` object defined by the framework in `convex/_generated/api.ts` to call public functions registered with `query`, `mutation`, or `action`. -- Use the `internal` object defined by the framework in `convex/_generated/api.ts` to call internal (or private) functions registered with `internalQuery`, `internalMutation`, or `internalAction`. -- Convex uses file-based routing, so a public function defined in `convex/example.ts` named `f` has a function reference of `api.example.f`. -- A private function defined in `convex/example.ts` named `g` has a function reference of `internal.example.g`. -- Functions can also registered within directories nested within the `convex/` folder. For example, a public function `h` defined in `convex/messages/access.ts` has a function reference of `api.messages.access.h`. - -### Api design -- Convex uses file-based routing, so thoughtfully organize files with public query, mutation, or action functions within the `convex/` directory. -- Use `query`, `mutation`, and `action` to define public functions. -- Use `internalQuery`, `internalMutation`, and `internalAction` to define private, internal functions. - - -## Validator guidelines -- `v.bigint()` is deprecated for representing signed 64-bit integers. Use `v.int64()` instead. -- Use `v.record()` for defining a record type. `v.map()` and `v.set()` are not supported. - -## Schema guidelines -- Always define your schema in `convex/schema.ts`. -- Always import the schema definition functions from `convex/server`: -- System fields are automatically added to all documents and are prefixed with an underscore. - -## Typescript guidelines -- You can use the helper typescript type `Id` imported from './_generated/dataModel' to get the type of the id for a given table. For example if there is a table called 'users' you can use `Id<'users'>` to get the type of the id for that table. -- If you need to define a `Record` make sure that you correctly provide the type of the key and value in the type. For example a validator `v.record(v.id('users'), v.string())` would have the type `Record, string>`. -- Be strict with types, particularly around id's of documents. For example, if a function takes in an id for a document in the 'users' table, take in `Id<'users'>` rather than `string`. - -## Full text search guidelines -- A query for "10 messages in channel '#general' that best match the query 'hello hi' in their body" would look like: - -const messages = await ctx.db - .query("messages") - .withSearchIndex("search_body", (q) => - q.search("body", "hello hi").eq("channel", "#general"), - ) - .take(10); - -## Query guidelines -- Do NOT use `filter` in queries. Instead, define an index in the schema and use `withIndex` instead. -- Convex queries do NOT support `.delete()`. Instead, `.collect()` the results, iterate over them, and call `ctx.db.delete(row._id)` on each result. -- Use `.unique()` to get a single document from a query. This method will throw an error if there are multiple documents that match the query. -### Ordering -- By default Convex always returns documents in ascending `_creationTime` order. -- You can use `.order('asc')` or `.order('desc')` to pick whether a query is in ascending or descending order. If the order isn't specified, it defaults to ascending. -- Document queries that use indexes will be ordered based on the columns in the index and can avoid slow table scans. - - -## Mutation guidelines -- Use `ctx.db.replace` to fully replace an existing document. This method will throw an error if the document does not exist. -- Use `ctx.db.patch` to shallow merge updates into an existing document. This method will throw an error if the document does not exist. - -## Scheduling guidelines -### Cron guidelines -- Only use the `crons.interval` or `crons.cron` methods to schedule cron jobs. Do NOT use the `crons.hourly`, `crons.daily`, or `crons.weekly` helpers. -- Both cron methods take in a FunctionReference. Do NOT try to pass the function directly into one of these methods. -- Define crons by declaring the top-level `crons` object, calling some methods on it, and then exporting it as default. For example, - ```ts - import { cronJobs } from "convex/server"; - import { internal } from "./_generated/api"; - - const crons = cronJobs(); - - // Run `internal.users.deleteInactive` every two hours. - crons.interval("delete inactive users", { hours: 2 }, internal.users.deleteInactive, {}); - - export default crons; - ``` -- You can register Convex functions within `crons.ts` just like any other file. -- If a cron calls an internal function, always import the `internal` object from '_generated/api`, even if the internal function is registered in the same file. - - -## File storage guidelines -- Convex includes file storage for large files like images, videos, and PDFs. -- The `ctx.storage.getUrl()` method returns a signed URL for a given file. It returns `null` if the file doesn't exist. -- Do NOT use the deprecated `ctx.storage.getMetadata` call for loading a file's metadata. - - Instead, query the `_storage` system table. For example, you can use `ctx.db.system.get` to get an `Id<"_storage">`. - ``` - import { query } from "./_generated/server"; - import { Id } from "./_generated/dataModel"; - - type FileMetadata = { - _id: Id<"_storage">; - _creationTime: number; - contentType?: string; - sha256: string; - size: number; - } - - export const exampleQuery = query({ - args: { fileId: v.id("_storage") }, - returns: v.null(); - handler: async (ctx, args) => { - const metadata: FileMetadata | null = await ctx.db.system.get(args.fileId); - console.log(metadata); - return null; - }, - }); - ``` - - -# Examples: -## Example: chat-app - -### Task -``` -Create a real-time chat application backend with AI responses. The app should: -- Allow creating users with names -- Support multiple chat channels -- Enable users to send messages to channels -- Automatically generate AI responses to user messages -- Show recent message history - -The backend should provide APIs for: -1. User management (creation) -2. Channel management (creation) -3. Message operations (sending, listing) -4. AI response generation using OpenAI's GPT-4 - -Messages should be stored with their channel, author, and content. The system should maintain message order -and limit history display to the 10 most recent messages per channel. - -``` - -### Analysis -1. Task Requirements Summary: -- Build a real-time chat backend with AI integration -- Support user creation -- Enable channel-based conversations -- Store and retrieve messages with proper ordering -- Generate AI responses automatically - -2. Main Components Needed: -- Database tables: users, channels, messages -- Public APIs for user/channel management -- Message handling functions -- Internal AI response generation system -- Context loading for AI responses - -3. Public API and Internal Functions Design: -Public Mutations: -- createUser: - - file path: convex/index.ts - - arguments: {name: v.string()} - - returns: v.object({userId: v.id("users")}) - - purpose: Create a new user with a given name -- createChannel: - - file path: convex/index.ts - - arguments: {name: v.string()} - - returns: v.object({channelId: v.id("channels")}) - - purpose: Create a new channel with a given name -- sendMessage: - - file path: convex/index.ts - - arguments: {channelId: v.id("channels"), authorId: v.id("users"), content: v.string()} - - returns: v.null() - - purpose: Send a message to a channel and schedule a response from the AI - -Public Queries: -- listMessages: - - file path: convex/index.ts - - arguments: {channelId: v.id("channels")} - - returns: v.array(v.object({ - _id: v.id("messages"), - _creationTime: v.number(), - channelId: v.id("channels"), - authorId: v.optional(v.id("users")), - content: v.string(), - })) - - purpose: List the 10 most recent messages from a channel in descending creation order - -Internal Functions: -- generateResponse: - - file path: convex/index.ts - - arguments: {channelId: v.id("channels")} - - returns: v.null() - - purpose: Generate a response from the AI for a given channel -- loadContext: - - file path: convex/index.ts - - arguments: {channelId: v.id("channels")} - - returns: v.array(v.object({ - _id: v.id("messages"), - _creationTime: v.number(), - channelId: v.id("channels"), - authorId: v.optional(v.id("users")), - content: v.string(), - })) -- writeAgentResponse: - - file path: convex/index.ts - - arguments: {channelId: v.id("channels"), content: v.string()} - - returns: v.null() - - purpose: Write an AI response to a given channel - -4. Schema Design: -- users - - validator: { name: v.string() } - - indexes: -- channels - - validator: { name: v.string() } - - indexes: -- messages - - validator: { channelId: v.id("channels"), authorId: v.optional(v.id("users")), content: v.string() } - - indexes - - by_channel: ["channelId"] - -5. Background Processing: -- AI response generation runs asynchronously after each user message -- Uses OpenAI's GPT-4 to generate contextual responses -- Maintains conversation context using recent message history - - -### Implementation - -#### package.json -```typescript -{ - "name": "chat-app", - "description": "This example shows how to build a chat app without authentication.", - "version": "1.0.0", - "dependencies": { - "convex": "^1.17.4", - "openai": "^4.79.0" - } -} -``` - -#### convex/index.ts -```typescript -import { - query, - mutation, - internalQuery, - internalMutation, - internalAction, -} from "./_generated/server"; -import { v } from "convex/values"; -import OpenAI from "openai"; -import { internal } from "./_generated/api"; - -/** - * Create a user with a given name. - */ -export const createUser = mutation({ - args: { - name: v.string(), - }, - returns: v.id("users"), - handler: async (ctx, args) => { - return await ctx.db.insert("users", { name: args.name }); - }, -}); - -/** - * Create a channel with a given name. - */ -export const createChannel = mutation({ - args: { - name: v.string(), - }, - returns: v.id("channels"), - handler: async (ctx, args) => { - return await ctx.db.insert("channels", { name: args.name }); - }, -}); - -/** - * List the 10 most recent messages from a channel in descending creation order. - */ -export const listMessages = query({ - args: { - channelId: v.id("channels"), - }, - returns: v.array( - v.object({ - _id: v.id("messages"), - _creationTime: v.number(), - channelId: v.id("channels"), - authorId: v.optional(v.id("users")), - content: v.string(), - }), - ), - handler: async (ctx, args) => { - const messages = await ctx.db - .query("messages") - .withIndex("by_channel", (q) => q.eq("channelId", args.channelId)) - .order("desc") - .take(10); - return messages; - }, -}); - -/** - * Send a message to a channel and schedule a response from the AI. - */ -export const sendMessage = mutation({ - args: { - channelId: v.id("channels"), - authorId: v.id("users"), - content: v.string(), - }, - returns: v.null(), - handler: async (ctx, args) => { - const channel = await ctx.db.get(args.channelId); - if (!channel) { - throw new Error("Channel not found"); - } - const user = await ctx.db.get(args.authorId); - if (!user) { - throw new Error("User not found"); - } - await ctx.db.insert("messages", { - channelId: args.channelId, - authorId: args.authorId, - content: args.content, - }); - await ctx.scheduler.runAfter(0, internal.index.generateResponse, { - channelId: args.channelId, - }); - return null; - }, -}); - -const openai = new OpenAI(); - -export const generateResponse = internalAction({ - args: { - channelId: v.id("channels"), - }, - returns: v.null(), - handler: async (ctx, args) => { - const context = await ctx.runQuery(internal.index.loadContext, { - channelId: args.channelId, - }); - const response = await openai.chat.completions.create({ - model: "gpt-4o", - messages: context, - }); - const content = response.choices[0].message.content; - if (!content) { - throw new Error("No content in response"); - } - await ctx.runMutation(internal.index.writeAgentResponse, { - channelId: args.channelId, - content, - }); - return null; - }, -}); - -export const loadContext = internalQuery({ - args: { - channelId: v.id("channels"), - }, - returns: v.array( - v.object({ - role: v.union(v.literal("user"), v.literal("assistant")), - content: v.string(), - }), - ), - handler: async (ctx, args) => { - const channel = await ctx.db.get(args.channelId); - if (!channel) { - throw new Error("Channel not found"); - } - const messages = await ctx.db - .query("messages") - .withIndex("by_channel", (q) => q.eq("channelId", args.channelId)) - .order("desc") - .take(10); - - const result = []; - for (const message of messages) { - if (message.authorId) { - const user = await ctx.db.get(message.authorId); - if (!user) { - throw new Error("User not found"); - } - result.push({ - role: "user" as const, - content: `${user.name}: ${message.content}`, - }); - } else { - result.push({ role: "assistant" as const, content: message.content }); - } - } - return result; - }, -}); - -export const writeAgentResponse = internalMutation({ - args: { - channelId: v.id("channels"), - content: v.string(), - }, - returns: v.null(), - handler: async (ctx, args) => { - await ctx.db.insert("messages", { - channelId: args.channelId, - content: args.content, - }); - return null; - }, -}); -``` - -#### convex/schema.ts -```typescript -import { defineSchema, defineTable } from "convex/server"; -import { v } from "convex/values"; - -export default defineSchema({ - channels: defineTable({ - name: v.string(), - }), - - users: defineTable({ - name: v.string(), - }), - - messages: defineTable({ - channelId: v.id("channels"), - authorId: v.optional(v.id("users")), - content: v.string(), - }).index("by_channel", ["channelId"]), -}); -``` - diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index d8195c8b..00000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Run tests -on: - push: - branches: ["main", "ai-sdk-v5"] - pull_request: - branches: ["main", "ai-sdk-v5"] -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 - - name: Use Node.js - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: - cache-dependency-path: | - example/package.json - package.json - node-version: "20.x" - cache: "npm" - - run: node setup.cjs - - run: cd playground && npm run build && cd .. - - run: npx pkg-pr-new publish ./ ./playground - - run: npm test - - run: npm run typecheck - - run: npm run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..117b322d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Test and lint +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: + push: + branches: [main] + pull_request: + branches: ["**"] + +jobs: + check: + name: Test and lint + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + + - name: Node setup + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5 + with: + cache-dependency-path: package.json + node-version: "20.x" + cache: "npm" + + - name: Install and build + run: | + npm i + npm run build + - name: Publish package for testing branch + run: npx pkg-pr-new publish || echo "Have you set up pkg-pr-new for this repo?" + - name: Test + run: | + npm run test + npm run typecheck + npm run lint diff --git a/.gitignore b/.gitignore index eef15e6a..6c8fe090 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,6 @@ dist-ssr explorations node_modules .eslintcache -# components are libraries! -# package-lock.json # this is a package-json-redirect stub dir, see https://github.com/andrewbranch/example-subpath-exports-ts-compat?tab=readme-ov-file react/package.json diff --git a/.prettierrc.json b/.prettierrc.json index 05a170c1..f3877f7e 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,4 @@ { - "proseWrap": "always", - "trailingComma": "all" + "trailingComma": "all", + "proseWrap": "always" } diff --git a/CHANGELOG.md b/CHANGELOG.md index e297c8e7..898a5bd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.3.0 + +- Adds /test and /\_generated/component.js entrypoints +- Drops commonjs support +- Improves source mapping for generated files +- Changes to a statically generated component API + ## 0.2.12 - Capture tool errors in the message diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fefd4946..b59c18ff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ ## Running locally ```sh -npm run setup +npm i npm run dev ``` @@ -12,9 +12,9 @@ npm run dev ```sh npm run clean npm run build -npm run test npm run typecheck npm run lint +npm run test ``` ## Deploying @@ -23,50 +23,18 @@ npm run lint ```sh npm run clean -npm run build +npm ci npm pack ``` ### Deploying a new version -Patch release: - ```sh npm run release ``` -#### Alpha release - -The same as above, but it requires extra flags so the release is only installed -with `@alpha`: +or for alpha release: ```sh npm run alpha ``` - -# Idea/ feature backlog: - -- Convenience function to create a thread by copying an existing thread (fork) -- Allow aborting normal generateText -- Improve the demo to show more of the features & have nicer UI - - Add an example of using tracing / telemetry. -- Add an example of using MCP with the Agent. -- Automatically turn big text content into a file when saving a message and keep - as a fileId. Re-hydrate it when reading out for generation. - -## Playground feature wishlist (contributions welcome!) - -- List all threads instead of user dropdown. - - If a user is logged in, use their userId instead of the apiKey for auth & - return only their threads. -- Show threads that aren't associated with a user as "no user" in the dropdown. -- Add a "fork thread" button in the right message detail sidebar. -- Add a "retry" button to regenerate a response while tuning the prompt/context. -- Show the contextual messages with their rank in vector & text search, to get a - sense of what is being found via text vs. vector vs. recency search. -- Show the agent's default context & storage options. -- Show tools and allow calling them directly. -- Generate objects from the UI, not just text. -- Archive messages -- Configure which tools are available when doing one-off messaging. -- Trace older messages for what exact context they used. diff --git a/convex.json b/convex.json index a7e9ba38..5dbf6e9c 100644 --- a/convex.json +++ b/convex.json @@ -1,4 +1,7 @@ { "$schema": "./node_modules/convex/schemas/convex.schema.json", - "functions": "example/convex" + "functions": "example/convex", + "codegen": { + "legacyComponentApi": true + } } diff --git a/docs/context.mdx b/docs/context.mdx index 778816d1..f2c4372b 100644 --- a/docs/context.mdx +++ b/docs/context.mdx @@ -131,7 +131,7 @@ const result = await agent.generateText( const related = await getRelatedThreadMessages(ctx, args.threadId); return [ // Summarize or truncate context messages if they are too long. - ...await summarizeOrTruncateIfTooLong(related), + ...(await summarizeOrTruncateIfTooLong(related)), ...relevantSearch, ...userMemories, ...sampleMessages, diff --git a/docs/debugging.mdx b/docs/debugging.mdx index 3dd4ea58..c38293ed 100644 --- a/docs/debugging.mdx +++ b/docs/debugging.mdx @@ -32,8 +32,8 @@ const supportAgent = new Agent(components.agent, { ## Logging the context messages via the contextHandler -You can log the context messages via the contextHandler, if you're curious -what exactly the LLM is receiving. +You can log the context messages via the contextHandler, if you're curious what +exactly the LLM is receiving. ```ts const supportAgent = new Agent(components.agent, { diff --git a/eslint.config.js b/eslint.config.js index eba9abb5..2172580c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,56 +1,98 @@ import globals from "globals"; import pluginJs from "@eslint/js"; import tseslint from "typescript-eslint"; -import reactPlugin from "eslint-plugin-react"; import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; export default [ - { files: ["src/**/*.{js,mjs,cjs,ts,tsx}"] }, { - ignores: ["dist/**", "eslint.config.js", "setup.cjs", "**/_generated/"], + ignores: [ + "dist/**", + "example/dist/**", + "playground/dist/**", + "*.config.js", + "setup.cjs", + "example/**/*.config.{cjs,js,ts}", + "playground/**/*.config.{js,ts}", + "playground/bin/agent-playground.cjs", + "**/_generated/", + "node10stubs.mjs", + ], }, { + files: [ + "src/**/*.{js,mjs,cjs,ts,tsx}", + "example/**/*.{js,mjs,cjs,ts,tsx}", + "playground/**/*.{js,mjs,cjs,ts,tsx}", + ], languageOptions: { - globals: globals.worker, parser: tseslint.parser, - parserOptions: { - project: true, + project: [ + "./tsconfig.json", + "./example/tsconfig.json", + "./example/convex/tsconfig.json", + "./playground/tsconfig.app.json", + "./playground/tsconfig.node.json", + ], tsconfigRootDir: import.meta.dirname, }, }, }, pluginJs.configs.recommended, ...tseslint.configs.recommended, + // Convex code - Worker environment { files: [ - "src/react/**/*.{jsx,tsx}", - "src/react/**/*.js", - "src/react/**/*.ts", + "src/**/*.{ts,tsx}", + "example/convex/**/*.{ts,tsx}", + "playground/convex/**/*.{ts,tsx}", ], - plugins: { react: reactPlugin, "react-hooks": reactHooks }, - settings: { - react: { - version: "detect", - }, + ignores: ["src/react/**"], + languageOptions: { + globals: globals.worker, }, rules: { - ...reactPlugin.configs["recommended"].rules, - "react/jsx-uses-react": "off", - "react/react-in-jsx-scope": "off", - "react/prop-types": "off", - "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "warn", + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/no-explicit-any": "off", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/no-unused-expressions": [ + "error", + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], }, }, + // React app code - Browser environment { + files: [ + "src/react/**/*.{ts,tsx}", + "example/ui/**/*.{ts,tsx}", + "playground/src/**/*.{ts,tsx}", + ], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + "react-hooks": reactHooks, + "react-refresh": reactRefresh, + }, rules: { - "@typescript-eslint/no-floating-promises": "error", - "eslint-comments/no-unused-disable": "off", - - // allow (_arg: number) => {} and const _foo = 1; + ...reactHooks.configs.recommended.rules, + "react-refresh/only-export-components": "off", + "@typescript-eslint/no-explicit-any": "off", "no-unused-vars": "off", - "no-unused-private-class-members": "warn", "@typescript-eslint/no-unused-vars": [ "warn", { diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 983c26fb..00000000 --- a/example/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -!**/glob-import/dir/node_modules -.DS_Store -.idea -*.cpuprofile -*.local -*.log -/.vscode/ -/docs/.vitepress/cache -dist -dist-ssr -explorations -node_modules -playground-temp -temp -TODOs.md -.eslintcache diff --git a/example/.prettierrc b/example/.prettierrc deleted file mode 100644 index 0967ef42..00000000 --- a/example/.prettierrc +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/example/README.md b/example/README.md index 524dad8b..de73a1c5 100644 --- a/example/README.md +++ b/example/README.md @@ -4,17 +4,18 @@ This is an example app that uses the `@convex-dev/agent` package. See the [Agent docs](https://docs.convex.dev/agents) for documentation. -The backend usage is in `convex/`, with folders to organize usecases. -The frontend usage is in `ui/`. +The backend usage is in `convex/`, with folders to organize usecases. The +frontend usage is in `ui/`. -The example exercises many usecases, with the underlying code organized -into folders by category. +The example exercises many usecases, with the underlying code organized into +folders by category. The main difference from your app will be: - What models you use (currently uses `modelsForDemo.ts`) - Usage handling - currently configures agents to use `usageHandler.ts` -- How you handle auth - currently has an example `authorizeThreadAccess` function. +- How you handle auth - currently has an example `authorizeThreadAccess` + function. ## Running the example diff --git a/example/convex/_generated/api.d.ts b/example/convex/_generated/api.d.ts index 3204f088..18706024 100644 --- a/example/convex/_generated/api.d.ts +++ b/example/convex/_generated/api.d.ts @@ -54,14 +54,6 @@ import type { FunctionReference, } from "convex/server"; -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ declare const fullApi: ApiFromModules<{ "agents/config": typeof agents_config; "agents/fashion": typeof agents_fashion; @@ -103,14 +95,30 @@ declare const fullApi: ApiFromModules<{ utils: typeof utils; "workflows/chaining": typeof workflows_chaining; }>; -declare const fullApiWithMounts: typeof fullApi; +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ export declare const api: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ export declare const internal: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; @@ -882,12 +890,6 @@ export declare const components: { }, null >; - getMessageSearchFields: FunctionReference< - "query", - "internal", - { messageId: string }, - { embedding?: Array; embeddingModel?: string; text?: string } - >; getMessagesByIds: FunctionReference< "query", "internal", @@ -1155,6 +1157,12 @@ export declare const components: { >; }> >; + getMessageSearchFields: FunctionReference< + "query", + "internal", + { messageId: string }, + { embedding?: Array; embeddingModel?: string; text?: string } + >; listMessagesByThreadId: FunctionReference< "query", "internal", @@ -2984,7 +2992,7 @@ export declare const components: { | { kind: "success"; returnValue: any } | { error: string; kind: "failed" } | { kind: "canceled" }; - workflowId: string; + workflowId?: string; workpoolOptions?: { defaultRetryBehavior?: { base: number; diff --git a/example/convex/_generated/server.d.ts b/example/convex/_generated/server.d.ts index b5c68288..bec05e68 100644 --- a/example/convex/_generated/server.d.ts +++ b/example/convex/_generated/server.d.ts @@ -10,7 +10,6 @@ import { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,9 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -92,11 +85,12 @@ export declare const internalAction: ActionBuilder; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export declare const httpAction: HttpActionBuilder; diff --git a/example/convex/_generated/server.js b/example/convex/_generated/server.js index 4a21df4f..bf3d25ad 100644 --- a/example/convex/_generated/server.js +++ b/example/convex/_generated/server.js @@ -16,7 +16,6 @@ import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, - componentsGeneric, } from "convex/server"; /** @@ -81,10 +80,14 @@ export const action = actionGeneric; export const internalAction = internalActionGeneric; /** - * Define a Convex HTTP action. + * Define an HTTP action. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. + * + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. + * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export const httpAction = httpActionGeneric; diff --git a/example/convex/tsconfig.json b/example/convex/tsconfig.json index 0c8c2879..891d309e 100644 --- a/example/convex/tsconfig.json +++ b/example/convex/tsconfig.json @@ -1,29 +1,5 @@ { - /* This TypeScript project config describes the environment that - * Convex functions run in and is used to typecheck them. - * You can modify it, but some settings required to use Convex. - */ - "compilerOptions": { - /* These settings are not required by Convex and can be modified. */ - "allowJs": true, - "strict": true, - "skipLibCheck": true, - - /* These compiler options are required by Convex */ - "target": "ESNext", - "lib": ["ES2021", "dom", "ESNext.Array"], - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true, - "module": "ESNext", - "moduleResolution": "Bundler", - - /* This should only be used in this example. Real apps should not attempt - * to compile TypeScript because differences between tsconfig.json files can - * cause the code to be compiled differently. - */ - // "customConditions": ["@convex-dev/component-source"] - "noEmit": true - }, - "include": ["./**/*"], - "exclude": ["./_generated"] + "extends": "../tsconfig.json", + "include": ["."], + "exclude": ["_generated"] } diff --git a/example/eslint.config.js b/example/eslint.config.js deleted file mode 100644 index 84978e47..00000000 --- a/example/eslint.config.js +++ /dev/null @@ -1,75 +0,0 @@ -import js from "@eslint/js"; -import globals from "globals"; -import reactHooks from "eslint-plugin-react-hooks"; -import reactRefresh from "eslint-plugin-react-refresh"; -import tseslint from "typescript-eslint"; - -export default tseslint.config( - { - ignores: [ - "dist", - "eslint.config.js", - "convex/_generated", - "postcss.config.js", - "tailwind.config.js", - "vite.config.ts", - ], - }, - { - extends: [ - js.configs.recommended, - ...tseslint.configs.recommendedTypeChecked, - ], - files: ["**/*.{ts,tsx}"], - languageOptions: { - ecmaVersion: 2020, - globals: { - ...globals.browser, - ...globals.node, - }, - parserOptions: { - project: [ - "./tsconfig.node.json", - "./tsconfig.app.json", - "./convex/tsconfig.json", - ], - tsconfigRootDir: import.meta.dirname, - }, - }, - plugins: { - "react-hooks": reactHooks, - "react-refresh": reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - "react-refresh/only-export-components": [ - "warn", - { allowConstantExport: true }, - ], - // All of these overrides ease getting into - // TypeScript, and can be removed for stricter - // linting down the line. - - // Only warn on unused variables, and ignore variables starting with `_` - "@typescript-eslint/no-unused-vars": "off", - - // Allow escaping the compiler - "@typescript-eslint/ban-ts-comment": "error", - - // Allow explicit `any`s - "@typescript-eslint/no-explicit-any": "off", - - // START: Allow implicit `any`s - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - // END: Allow implicit `any`s - - // Allow async functions without await - // for consistency (esp. Convex `handler`s) - "@typescript-eslint/require-await": "off", - }, - }, -); diff --git a/example/tsconfig.app.json b/example/tsconfig.app.json deleted file mode 100644 index f2aee949..00000000 --- a/example/tsconfig.app.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - - /* This should only be used in this example. Real apps should not attempt - * to compile TypeScript because differences between tsconfig.json files can - * cause the code to be compiled differently. - */ - "customConditions": ["@convex-dev/component-source"], - - /* Force fresh resolution for custom conditions */ - "incremental": false, - "assumeChangesOnlyAffectDirectDependencies": false, - - /* Import paths */ - "paths": { - "@/*": ["./ui/*"] - } - }, - "include": ["ui"] -} diff --git a/example/tsconfig.json b/example/tsconfig.json index 31b7e1e6..a71fcacd 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -1,13 +1,21 @@ { - "files": [], - "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ], "compilerOptions": { - "baseUrl": ".", + "target": "ESNext", "paths": { "@/*": ["ui/*"] - } - } + }, + "baseUrl": ".", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "skipLibCheck": false, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "react-jsx", + "noEmit": true + }, + "include": ["./ui", "vite.config.ts"] } diff --git a/example/tsconfig.node.json b/example/tsconfig.node.json deleted file mode 100644 index c11cc87d..00000000 --- a/example/tsconfig.node.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - - /* This should only be used in this example. Real apps should not attempt - * to compile TypeScript because differences between tsconfig.json files can - * cause the code to be compiled differently. - */ - "customConditions": ["@convex-dev/component-source"], - /* Linting */ - "strict": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/example/ui/hooks/use-toast.ts b/example/ui/hooks/use-toast.ts index 6555e795..8dcddd10 100644 --- a/example/ui/hooks/use-toast.ts +++ b/example/ui/hooks/use-toast.ts @@ -15,12 +15,12 @@ type ToasterToast = ToastProps & { action?: ToastActionElement; }; -const actionTypes = { - ADD_TOAST: "ADD_TOAST", - UPDATE_TOAST: "UPDATE_TOAST", - DISMISS_TOAST: "DISMISS_TOAST", - REMOVE_TOAST: "REMOVE_TOAST", -} as const; +type ActionType = { + ADD_TOAST: "ADD_TOAST"; + UPDATE_TOAST: "UPDATE_TOAST"; + DISMISS_TOAST: "DISMISS_TOAST"; + REMOVE_TOAST: "REMOVE_TOAST"; +}; let count = 0; @@ -29,8 +29,6 @@ function genId() { return count.toString(); } -type ActionType = typeof actionTypes; - type Action = | { type: ActionType["ADD_TOAST"]; diff --git a/example/ui/rag/RagBasic.tsx b/example/ui/rag/RagBasic.tsx index 0f5a3992..2a8ccc29 100644 --- a/example/ui/rag/RagBasic.tsx +++ b/example/ui/rag/RagBasic.tsx @@ -2,7 +2,6 @@ import { useAction, useMutation, usePaginatedQuery } from "convex/react"; import { optimisticallySendMessage, SmoothText, - useSmoothText, useThreadMessages, } from "@convex-dev/agent/react"; import { api } from "../../convex/_generated/api"; diff --git a/package-lock.json b/package-lock.json index f1b91a1f..bfe2fb66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@convex-dev/agent", - "version": "0.2.12", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@convex-dev/agent", - "version": "0.2.12", + "version": "0.3.0", "license": "Apache-2.0", "devDependencies": { "@ai-sdk/anthropic": "2.0.39", @@ -14,7 +14,6 @@ "@ai-sdk/openai": "2.0.57", "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.14", - "@arethetypeswrong/cli": "0.18.2", "@convex-dev/rag": "0.5.4", "@convex-dev/rate-limiter": "0.2.14", "@convex-dev/workflow": "0.2.8-alpha.10", @@ -39,7 +38,7 @@ "chokidar-cli": "3.0.0", "class-variance-authority": "0.7.1", "clsx": "2.1.1", - "convex": "1.28.0", + "convex": "1.29.0", "convex-helpers": "0.1.104", "convex-test": "0.0.38", "cpy-cli": "5.0.0", @@ -79,7 +78,7 @@ "peerDependencies": { "@ai-sdk/provider-utils": "^3.0.7", "ai": "^5.0.29", - "convex": "^1.23.0", + "convex": "^1.24.8", "convex-helpers": "^0.1.103", "react": "^18.3.1 || ^19.0.0" }, @@ -241,68 +240,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@andrewbranch/untar.js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@andrewbranch/untar.js/-/untar.js-1.0.3.tgz", - "integrity": "sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw==", - "dev": true - }, - "node_modules/@arethetypeswrong/cli": { - "version": "0.18.2", - "resolved": "https://registry.npmjs.org/@arethetypeswrong/cli/-/cli-0.18.2.tgz", - "integrity": "sha512-PcFM20JNlevEDKBg4Re29Rtv2xvjvQZzg7ENnrWFSS0PHgdP2njibVFw+dRUhNkPgNfac9iUqO0ohAXqQL4hbw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@arethetypeswrong/core": "0.18.2", - "chalk": "^4.1.2", - "cli-table3": "^0.6.3", - "commander": "^10.0.1", - "marked": "^9.1.2", - "marked-terminal": "^7.1.0", - "semver": "^7.5.4" - }, - "bin": { - "attw": "dist/index.js" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/@arethetypeswrong/core": { - "version": "0.18.2", - "resolved": "https://registry.npmjs.org/@arethetypeswrong/core/-/core-0.18.2.tgz", - "integrity": "sha512-GiwTmBFOU1/+UVNqqCGzFJYfBXEytUkiI+iRZ6Qx7KmUVtLm00sYySkfe203C9QtPG11yOz1ZaMek8dT/xnlgg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@andrewbranch/untar.js": "^1.0.3", - "@loaderkit/resolve": "^1.0.2", - "cjs-module-lexer": "^1.2.3", - "fflate": "^0.8.2", - "lru-cache": "^11.0.1", - "semver": "^7.5.4", - "typescript": "5.6.1-rc", - "validate-npm-package-name": "^5.0.0" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/@arethetypeswrong/core/node_modules/typescript": { - "version": "5.6.1-rc", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.1-rc.tgz", - "integrity": "sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/@babel/code-frame": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", @@ -616,13 +553,6 @@ "node": ">=6.9.0" } }, - "node_modules/@braidai/lang": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@braidai/lang/-/lang-1.1.2.tgz", - "integrity": "sha512-qBcknbBufNHlui137Hft8xauQMTZDKdophmLFv05r2eNmdIv/MlPuP4TdUknHG68UdWLgVZwgxVe735HzJNIwA==", - "dev": true, - "license": "ISC" - }, "node_modules/@cfworker/json-schema": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.1.tgz", @@ -630,17 +560,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/@convex-dev/rag": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/@convex-dev/rag/-/rag-0.5.4.tgz", @@ -1602,16 +1521,6 @@ "@langchain/core": ">=0.2.21 <0.4.0" } }, - "node_modules/@loaderkit/resolve": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@loaderkit/resolve/-/resolve-1.0.4.tgz", - "integrity": "sha512-rJzYKVcV4dxJv+vW6jlvagF8zvGxHJ2+HTr1e2qOejfmGhAApgJHl8Aog4mMszxceTRiKTTbnpgmTO1bEZHV/A==", - "dev": true, - "license": "ISC", - "dependencies": { - "@braidai/lang": "^1.0.0" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2984,19 +2893,6 @@ "win32" ] }, - "node_modules/@sindresorhus/is": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/is?sponsor=1" - } - }, "node_modules/@standard-schema/spec": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", @@ -3692,22 +3588,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ansi-escapes": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.1.1.tgz", - "integrity": "sha512-Zhl0ErHcSRUaVfGUeUdDuLgpkEo8KIFjB4Y9uAc46ScOpdDiU1Dbyplh7qWJeJ/ZHpbyMSM26+X3BySgnIz40Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "environment": "^1.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/ansi-regex": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", @@ -4335,16 +4215,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/char-regex": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", - "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/character-entities": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", @@ -4443,13 +4313,6 @@ "node": ">= 8.10.0" } }, - "node_modules/cjs-module-lexer": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz", - "integrity": "sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==", - "dev": true, - "license": "MIT" - }, "node_modules/class-variance-authority": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", @@ -4492,129 +4355,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cli-highlight": { - "version": "2.1.11", - "resolved": "https://registry.npmjs.org/cli-highlight/-/cli-highlight-2.1.11.tgz", - "integrity": "sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg==", - "dev": true, - "license": "ISC", - "dependencies": { - "chalk": "^4.0.0", - "highlight.js": "^10.7.1", - "mz": "^2.4.0", - "parse5": "^5.1.1", - "parse5-htmlparser2-tree-adapter": "^6.0.0", - "yargs": "^16.0.0" - }, - "bin": { - "highlight": "bin/highlight" - }, - "engines": { - "node": ">=8.0.0", - "npm": ">=5.0.0" - } - }, - "node_modules/cli-highlight/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cli-highlight/node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/cli-highlight/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/cli-highlight/node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/cli-highlight/node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/cli-highlight/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/cli-table3": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz", - "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "string-width": "^4.2.0" - }, - "engines": { - "node": "10.* || >= 12.*" - }, - "optionalDependencies": { - "@colors/colors": "1.5.0" - } - }, "node_modules/cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -4768,16 +4508,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14" - } - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4810,9 +4540,9 @@ "license": "MIT" }, "node_modules/convex": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/convex/-/convex-1.28.0.tgz", - "integrity": "sha512-40FgeJ/LxP9TxnkDDztU/A5gcGTdq1klcTT5mM0Ak+kSlQiDktMpjNX1TfkWLxXaE3lI4qvawKH95v2RiYgFxA==", + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/convex/-/convex-1.29.0.tgz", + "integrity": "sha512-uoIPXRKIp2eLCkkR9WJ2vc9NtgQtx8Pml59WPUahwbrd5EuW2WLI/cf2E7XrUzOSifdQC3kJZepisk4wJNTJaA==", "dev": true, "license": "Apache-2.0", "peer": true, @@ -5296,26 +5026,6 @@ "dev": true, "license": "MIT" }, - "node_modules/emojilib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/emojilib/-/emojilib-2.4.0.tgz", - "integrity": "sha512-5U0rVMU5Y2n2+ykNLQqMoqklN9ICBT/KsvC1Gz6vqHbz2AXXGkG+Pm5rMWk/8Vjrr/mY9985Hi8DYzn1F09Nyw==", - "dev": true, - "license": "MIT" - }, - "node_modules/environment": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", - "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/es-abstract": { "version": "1.24.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.0.tgz", @@ -5931,13 +5641,6 @@ "reusify": "^1.0.4" } }, - "node_modules/fflate": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", - "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", - "dev": true, - "license": "MIT" - }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -6488,16 +6191,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": "*" - } - }, "node_modules/html-url-attributes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", @@ -7420,16 +7113,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lru-cache": { - "version": "11.2.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", - "integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==", - "dev": true, - "license": "ISC", - "engines": { - "node": "20 || >=22" - } - }, "node_modules/lucide-react": { "version": "0.548.0", "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.548.0.tgz", @@ -7450,55 +7133,6 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, - "node_modules/marked": { - "version": "9.1.6", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.6.tgz", - "integrity": "sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q==", - "dev": true, - "license": "MIT", - "peer": true, - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 16" - } - }, - "node_modules/marked-terminal": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-7.3.0.tgz", - "integrity": "sha512-t4rBvPsHc57uE/2nJOLmMbZCQ4tgAccAED3ngXQqW6g+TxA488JzJ+FK3lQkzBQOI1mRV/r/Kq+1ZlJ4D0owQw==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-escapes": "^7.0.0", - "ansi-regex": "^6.1.0", - "chalk": "^5.4.1", - "cli-highlight": "^2.1.11", - "cli-table3": "^0.6.5", - "node-emoji": "^2.2.0", - "supports-hyperlinks": "^3.1.0" - }, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "marked": ">=1 <16" - } - }, - "node_modules/marked-terminal/node_modules/chalk": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", - "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -8277,22 +7911,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-emoji": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-2.2.0.tgz", - "integrity": "sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@sindresorhus/is": "^4.6.0", - "char-regex": "^1.0.2", - "emojilib": "^2.4.0", - "skin-tone": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/node-releases": { "version": "2.0.26", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.26.tgz", @@ -8867,30 +8485,6 @@ "dev": true, "license": "MIT" }, - "node_modules/parse5": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", - "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", - "dev": true, - "license": "MIT" - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", - "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", - "dev": true, - "license": "MIT", - "dependencies": { - "parse5": "^6.0.1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter/node_modules/parse5": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", - "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", - "dev": true, - "license": "MIT" - }, "node_modules/partial-json": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/partial-json/-/partial-json-0.1.7.tgz", @@ -10138,19 +9732,6 @@ "dev": true, "license": "MIT" }, - "node_modules/skin-tone": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/skin-tone/-/skin-tone-2.0.0.tgz", - "integrity": "sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA==", - "dev": true, - "license": "MIT", - "dependencies": { - "unicode-emoji-modifier-base": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/slash": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", @@ -10555,23 +10136,6 @@ "node": ">=8" } }, - "node_modules/supports-hyperlinks": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-3.2.0.tgz", - "integrity": "sha512-zFObLMyZeEwzAoKCyu1B91U79K2t7ApXuQfo8OuxwXLDgcKxuwM+YvcbIhm6QWqz7mHUH1TVytR1PwVVjEuMig==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0", - "supports-color": "^7.0.0" - }, - "engines": { - "node": ">=14.18" - }, - "funding": { - "url": "https://github.com/chalk/supports-hyperlinks?sponsor=1" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -11067,16 +10631,6 @@ "dev": true, "license": "MIT" }, - "node_modules/unicode-emoji-modifier-base": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unicode-emoji-modifier-base/-/unicode-emoji-modifier-base-1.0.0.tgz", - "integrity": "sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/unified": { "version": "11.0.5", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", diff --git a/package.json b/package.json index 27899449..ffe3ae48 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "email": "support@convex.dev", "url": "https://github.com/get-convex/agent/issues" }, - "version": "0.2.12", + "version": "0.3.0", "license": "Apache-2.0", "keywords": [ "convex", @@ -17,27 +17,24 @@ ], "type": "module", "scripts": { - "setup": "node setup.cjs --init", - "dev": "run-p -r 'dev:frontend' 'dev:backend' 'build:watch'", - "predev": "npm run build && npm run dev:backend -- --until-success", - "dev:backend": "convex dev --live-component-sources --typecheck-components", + "dev": "run-p -r 'dev:*'", + "dev:backend": "convex dev --typecheck-components", "dev:frontend": "cd example && vite --clearScreen false", - "build:watch": "npx chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'npm run build' --initial", - "all": "run-p -r 'dev:frontend' 'dev:backend' 'build:watch' 'test:watch'", - "build": "tsc --project ./tsconfig.build.json && npm run copy:dts", - "copy:dts": "rsync -a --include='*/' --include='*.d.ts' --exclude='*' src/ dist/ || cpy 'src/**/*.d.ts' 'dist/' --parents", - "typecheck": "tsc --noEmit && tsc -p example/convex", - "clean": "rm -rf dist *.tsbuildinfo node_modules/.cache", - "alpha": "npm run clean && npm run build && run-p test lint typecheck && npm version prerelease --preid alpha && npm publish --tag alpha && git push --tags", - "release": "npm run clean && npm run build && run-p test lint typecheck && npm version patch && npm publish && git push --tags && git push", - "test": "vitest run --typecheck --config ./src/vitest.config.ts", - "test:watch": "vitest --typecheck --config ./src/vitest.config.ts --clearScreen false", - "test:debug": "vitest --inspect-brk --no-file-parallelism --config ./src/vitest.config.ts", + "dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'convex codegen --component-dir ./src/component && npm run build' --initial", + "predev": "npm run dev:backend -- --until-success", + "clean": "rm -rf dist *.tsbuildinfo", + "build": "tsc --project ./tsconfig.build.json", + "typecheck": "tsc --noEmit && tsc -p example && tsc -p example/convex", + "lint": "eslint .", + "all": "run-p -r 'dev:*' 'test:watch'", + "test": "vitest run --typecheck", + "test:watch": "vitest --typecheck --clearScreen false", + "test:debug": "vitest --inspect-brk --no-file-parallelism", "test:coverage": "vitest run --coverage --coverage.reporter=text", - "lint": "eslint src && eslint example/convex", - "dashboard": "convex dashboard", - "logs": "convex logs", - "version": "pbcopy <<<$npm_package_version; node setup.cjs && vim CHANGELOG.md && prettier --write CHANGELOG.md && git add CHANGELOG.md playground/package-lock.json" + "prepare": "npm run build", + "alpha": "npm run clean && npm ci && run-p test lint typecheck && npm version prerelease --preid alpha && npm publish --tag alpha && git push --tags", + "release": "npm run clean && npm ci && run-p test lint typecheck && npm version patch && npm publish && git push --tags", + "version": "pbcopy <<<$npm_package_version; vim CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md" }, "files": [ "dist", @@ -46,23 +43,26 @@ "exports": { "./package.json": "./package.json", ".": { - "@convex-dev/component-source": "./src/client/index.ts", "types": "./dist/client/index.d.ts", "default": "./dist/client/index.js" }, "./validators": { - "@convex-dev/component-source": "./src/validators.ts", "types": "./dist/validators.d.ts", "default": "./dist/validators.js" }, "./react": { - "@convex-dev/component-source": "./src/react/index.ts", "types": "./dist/react/index.d.ts", "default": "./dist/react/index.js" }, "./test": "./src/test.ts", + "./_generated/component.js": { + "types": "./dist/component/_generated/component.d.ts" + }, "./convex.config": { - "@convex-dev/component-source": "./src/component/convex.config.ts", + "types": "./dist/component/convex.config.d.ts", + "default": "./dist/component/convex.config.js" + }, + "./convex.config.js": { "types": "./dist/component/convex.config.d.ts", "default": "./dist/component/convex.config.js" } @@ -70,7 +70,7 @@ "peerDependencies": { "@ai-sdk/provider-utils": "^3.0.7", "ai": "^5.0.29", - "convex": "^1.23.0", + "convex": "^1.24.8", "convex-helpers": "^0.1.103", "react": "^18.3.1 || ^19.0.0" }, @@ -85,7 +85,6 @@ "@ai-sdk/openai": "2.0.57", "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.14", - "@arethetypeswrong/cli": "0.18.2", "@convex-dev/rag": "0.5.4", "@convex-dev/rate-limiter": "0.2.14", "@convex-dev/workflow": "0.2.8-alpha.10", @@ -110,7 +109,7 @@ "chokidar-cli": "3.0.0", "class-variance-authority": "0.7.1", "clsx": "2.1.1", - "convex": "1.28.0", + "convex": "1.29.0", "convex-helpers": "0.1.104", "convex-test": "0.0.38", "cpy-cli": "5.0.0", @@ -144,7 +143,6 @@ "vitest": "3.2.4", "zod": "3.25.76" }, - "main": "./dist/client/index.js", "types": "./dist/client/index.d.ts", "module": "./dist/client/index.js", "optionalDependencies": { diff --git a/playground/bin/agent-playground.cjs b/playground/bin/agent-playground.cjs index 2cd0b9bf..2706bb83 100755 --- a/playground/bin/agent-playground.cjs +++ b/playground/bin/agent-playground.cjs @@ -34,7 +34,7 @@ const npxBin = process.platform === "win32" ? "npx.cmd" : "npx"; const child = spawn(npxBin, ["vite", "preview", ...args], { cwd: playgroundDir, stdio: "inherit", - env: process.env, + env: process.env, shell: process.platform === "win32", // ✅ needed for Windows }); diff --git a/playground/eslint.config.js b/playground/eslint.config.js deleted file mode 100644 index 160bf8c4..00000000 --- a/playground/eslint.config.js +++ /dev/null @@ -1,22 +0,0 @@ -import js from "@eslint/js"; -import globals from "globals"; -import reactHooks from "eslint-plugin-react-hooks"; -import reactRefresh from "eslint-plugin-react-refresh"; -import tseslint from "typescript-eslint"; - -export default tseslint.config( - { ignores: ["dist", "bin/agent-playground.js"] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ["**/*.{ts,tsx}"], - languageOptions: { ecmaVersion: 2020, globals: globals.browser }, - plugins: { "react-hooks": reactHooks, "react-refresh": reactRefresh }, - rules: { - ...reactHooks.configs.recommended.rules, - "react-refresh/only-export-components": "off", - "@typescript-eslint/no-empty-object-type": "off", - "@typescript-eslint/no-require-imports": "off", - "@typescript-eslint/no-unused-vars": "off", - }, - }, -); diff --git a/playground/src/components/ApiKeyGate.tsx b/playground/src/components/ApiKeyGate.tsx index b3bc1a5d..d2089156 100644 --- a/playground/src/components/ApiKeyGate.tsx +++ b/playground/src/components/ApiKeyGate.tsx @@ -97,7 +97,7 @@ function ApiKeyGate({ } setIsConnected(true); }) - .catch((err) => { + .catch(() => { if (!convex.connectionState().isWebSocketConnected) { setIsConnected(false); } else { diff --git a/playground/src/components/ConvexProviderGate.tsx b/playground/src/components/ConvexProviderGate.tsx index 1ce9a318..98f3b30a 100644 --- a/playground/src/components/ConvexProviderGate.tsx +++ b/playground/src/components/ConvexProviderGate.tsx @@ -48,45 +48,48 @@ function ConvexProviderGate({ children }: { children: ReactNode }) { const [isValid, setIsValid] = useState(false); // Validation function - const validateDeploymentUrl = useCallback(async (url: string) => { - if (loading) return; - if (!url) { - setIsValid(false); - setInstanceName(null); - setError("Please enter a URL"); - setLoading(false); - return; - } - if (!isValidHttpUrl(url)) { - setIsValid(false); + const validateDeploymentUrl = useCallback( + async (url: string) => { + if (loading) return; + if (!url) { + setIsValid(false); + setInstanceName(null); + setError("Please enter a URL"); + setLoading(false); + return; + } + if (!isValidHttpUrl(url)) { + setIsValid(false); + setInstanceName(null); + setError("Please enter a valid HTTP or HTTPS URL"); + setLoading(false); + return; + } + setLoading(true); setInstanceName(null); - setError("Please enter a valid HTTP or HTTPS URL"); - setLoading(false); - return; - } - setLoading(true); - setInstanceName(null); - setError(null); - try { - const res = await fetch(url + "/instance_name"); - if (!res.ok) throw new Error("Invalid response"); - const name = await res.text(); - setInstanceName(name); setError(null); - setLoading(false); - setIsValid(true); - localStorage.setItem(DEPLOYMENT_URL_STORAGE_KEY, url); - // Navigate to the validated URL - navigate(`/play/${encodeURIComponent(url.replace(/\/$/, ""))}`); - } catch { - setInstanceName(null); - setError( - "Could not validate deployment URL. Please check the URL and try again.", - ); - setLoading(false); - setIsValid(false); - } - }, [loading, navigate]); + try { + const res = await fetch(url + "/instance_name"); + if (!res.ok) throw new Error("Invalid response"); + const name = await res.text(); + setInstanceName(name); + setError(null); + setLoading(false); + setIsValid(true); + localStorage.setItem(DEPLOYMENT_URL_STORAGE_KEY, url); + // Navigate to the validated URL + navigate(`/play/${encodeURIComponent(url.replace(/\/$/, ""))}`); + } catch { + setInstanceName(null); + setError( + "Could not validate deployment URL. Please check the URL and try again.", + ); + setLoading(false); + setIsValid(false); + } + }, + [loading, navigate], + ); // Auto-validate deployment URL from path when it changes useEffect(() => { @@ -100,7 +103,14 @@ function ConvexProviderGate({ children }: { children: ReactNode }) { if (!isValid && !error && !instanceName && !loading) { validateDeploymentUrl(deploymentUrl); } - }, [deploymentUrl, validateDeploymentUrl, isValid, error, instanceName, loading]); + }, [ + deploymentUrl, + validateDeploymentUrl, + isValid, + error, + instanceName, + loading, + ]); // Handle input changes and validation const handleInputChange = (e: React.ChangeEvent) => { diff --git a/playground/src/components/JsonEditor.tsx b/playground/src/components/JsonEditor.tsx index 00b7a012..8320baed 100644 --- a/playground/src/components/JsonEditor.tsx +++ b/playground/src/components/JsonEditor.tsx @@ -1,9 +1,8 @@ import React, { useState } from "react"; import { Textarea } from "@/components/ui/textarea"; -import { Infer, Validator, Value, VObject } from "convex/values"; +import { Infer, Validator } from "convex/values"; import { validate, ValidationError } from "convex-helpers/validators"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any const JsonEditor = >({ defaultValue, onChange, diff --git a/playground/src/components/MessageList.tsx b/playground/src/components/MessageList.tsx index 5413e406..49f2a8e1 100644 --- a/playground/src/components/MessageList.tsx +++ b/playground/src/components/MessageList.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState, useRef, useEffect } from "react"; +import React, { useMemo, useRef, useEffect } from "react"; import MessageItem from "./MessageItem"; import { Message, User } from "../types"; import { toUIMessages } from "@convex-dev/agent/react"; diff --git a/playground/src/components/ui/command.tsx b/playground/src/components/ui/command.tsx index 0341e973..445e6a9c 100644 --- a/playground/src/components/ui/command.tsx +++ b/playground/src/components/ui/command.tsx @@ -21,7 +21,7 @@ const Command = React.forwardRef< )); Command.displayName = CommandPrimitive.displayName; -interface CommandDialogProps extends DialogProps {} +type CommandDialogProps = DialogProps; const CommandDialog = ({ children, ...props }: CommandDialogProps) => { return ( diff --git a/playground/src/components/ui/textarea.tsx b/playground/src/components/ui/textarea.tsx index 9f005734..7de5c4a2 100644 --- a/playground/src/components/ui/textarea.tsx +++ b/playground/src/components/ui/textarea.tsx @@ -2,8 +2,7 @@ import * as React from "react"; import { cn } from "@/lib/utils"; -export interface TextareaProps - extends React.TextareaHTMLAttributes {} +export type TextareaProps = React.TextareaHTMLAttributes; const Textarea = React.forwardRef( ({ className, ...props }, ref) => { diff --git a/playground/src/hooks/use-toast.ts b/playground/src/hooks/use-toast.ts index 01f0976b..7a33f5c3 100644 --- a/playground/src/hooks/use-toast.ts +++ b/playground/src/hooks/use-toast.ts @@ -12,13 +12,6 @@ type ToasterToast = ToastProps & { action?: ToastActionElement; }; -const actionTypes = { - ADD_TOAST: "ADD_TOAST", - UPDATE_TOAST: "UPDATE_TOAST", - DISMISS_TOAST: "DISMISS_TOAST", - REMOVE_TOAST: "REMOVE_TOAST", -} as const; - let count = 0; function genId() { @@ -26,7 +19,12 @@ function genId() { return count.toString(); } -type ActionType = typeof actionTypes; +type ActionType = { + ADD_TOAST: "ADD_TOAST"; + UPDATE_TOAST: "UPDATE_TOAST"; + DISMISS_TOAST: "DISMISS_TOAST"; + REMOVE_TOAST: "REMOVE_TOAST"; +}; type Action = | { diff --git a/playground/src/types/index.ts b/playground/src/types/index.ts index 576b728b..97dc404c 100644 --- a/playground/src/types/index.ts +++ b/playground/src/types/index.ts @@ -29,9 +29,7 @@ export interface ToolCall { id: string; type: string; name: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any args: Record; - // eslint-disable-next-line @typescript-eslint/no-explicit-any returnValue?: any; } diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 8d874dce..24704f96 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -4,6 +4,7 @@ import path from "path"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ + envDir: "../", plugins: [react()], resolve: { alias: { diff --git a/src/client/createTool.ts b/src/client/createTool.ts index 9e529cb0..556682f8 100644 --- a/src/client/createTool.ts +++ b/src/client/createTool.ts @@ -109,7 +109,6 @@ export function createTool(def: { return t; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function getCtx(tool: any): Ctx { return (tool as { ctx: Ctx }).ctx; } @@ -124,7 +123,6 @@ export function wrapTools( continue; } for (const [name, tool] of Object.entries(toolSet)) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any if (tool && !(tool as any).__acceptsCtx) { output[name] = tool; } else { diff --git a/src/client/index.test.ts b/src/client/index.test.ts index 0363fb8d..f6e97269 100644 --- a/src/client/index.test.ts +++ b/src/client/index.test.ts @@ -163,7 +163,6 @@ const testApi: ApiFromModules<{ generateObjectAction: typeof generateObjectAction; saveMessageMutation: typeof saveMessageMutation; }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any }>["fns"] = anyApi["index.test"] as any; describe("Agent thick client", () => { diff --git a/src/client/index.ts b/src/client/index.ts index 71d307b6..40c8c716 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -214,7 +214,6 @@ export class Agent< * }); */ CustomCtx extends object = object, - // eslint-disable-next-line @typescript-eslint/no-explicit-any AgentTools extends ToolSet = any, > { constructor( @@ -732,7 +731,6 @@ export class Agent< await this.start(ctx, streamObjectArgs, { ...threadOpts, ...options }); const stream = streamObject({ - // eslint-disable-next-line @typescript-eslint/no-explicit-any ...(args as any), onError: async (error) => { console.error(" streamObject onError", error); @@ -1461,7 +1459,6 @@ export class Agent< : ctx_ ) as UserActionCtx & CustomCtx; if (stream) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any const result = await this.streamText( ctx, targetArgs, @@ -1478,7 +1475,6 @@ export class Agent< savedMessageIds: result.savedMessages?.map((m) => m._id) ?? [], }; } else { - // eslint-disable-next-line @typescript-eslint/no-explicit-any const res = await this.generateText( ctx, targetArgs, @@ -1575,9 +1571,8 @@ export class Agent< } async function willContinue( - // eslint-disable-next-line @typescript-eslint/no-explicit-any steps: StepResult[], - // eslint-disable-next-line @typescript-eslint/no-explicit-any + stopWhen: StopCondition | Array> | undefined, ): Promise { const step = steps.at(-1)!; diff --git a/src/client/saveInputMessages.test.ts b/src/client/saveInputMessages.test.ts index af576526..efc84653 100644 --- a/src/client/saveInputMessages.test.ts +++ b/src/client/saveInputMessages.test.ts @@ -34,7 +34,6 @@ vi.mock("./search.js", async () => { const createMockMessageDoc = ( id: string, role: "user" | "assistant" | "tool" | "system", - // eslint-disable-next-line @typescript-eslint/no-explicit-any content: any, ): MessageDoc => ({ _id: id, diff --git a/src/client/search.test.ts b/src/client/search.test.ts index 71ba75b0..c2749c92 100644 --- a/src/client/search.test.ts +++ b/src/client/search.test.ts @@ -29,7 +29,6 @@ import { saveMessages } from "./messages.js"; const createMockMessageDoc = ( id: string, role: "user" | "assistant" | "tool" | "system", - // eslint-disable-next-line @typescript-eslint/no-explicit-any content: any, order: number = 1, ): MessageDoc => ({ diff --git a/src/client/types.ts b/src/client/types.ts index e5731803..463aae03 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -23,7 +23,6 @@ import type { } from "ai"; import type { Auth, - Expand, FunctionArgs, FunctionReference, FunctionReturnType, @@ -33,8 +32,6 @@ import type { StorageReader, WithoutSystemFields, } from "convex/server"; -import type { GenericId } from "convex/values"; -import type { api } from "../component/_generated/api.js"; import type { MessageDoc, ProviderMetadata, @@ -43,6 +40,7 @@ import type { ThreadDoc, } from "../validators.js"; import type { StreamingOptions } from "./streaming.js"; +import type { ComponentApi } from "../component/_generated/component.js"; export type AgentPrompt = { /** @@ -331,7 +329,7 @@ export type RawRequestResponseHandler = ( }, ) => void | Promise; -export type AgentComponent = UseApi; +export type AgentComponent = ComponentApi; export type TextArgs< AgentTools extends ToolSet, @@ -642,32 +640,3 @@ export type ActionCtx = MutationCtx & { storage: StorageActionWriter; }; export type QueryCtx = RunQueryCtx & { storage: StorageReader }; - -export type OpaqueIds = - T extends GenericId - ? string - : T extends (infer U)[] - ? OpaqueIds[] - : T extends ArrayBuffer - ? ArrayBuffer - : T extends object - ? { [K in keyof T]: OpaqueIds } - : T; - -export type UseApi = Expand<{ - [mod in keyof API]: API[mod] extends FunctionReference< - infer FType, - "public", - infer FArgs, - infer FReturnType, - infer FComponentPath - > - ? FunctionReference< - FType, - "internal", - OpaqueIds, - OpaqueIds, - FComponentPath - > - : UseApi; -}>; diff --git a/src/component/_generated/api.d.ts b/src/component/_generated/api.d.ts deleted file mode 100644 index ca538cff..00000000 --- a/src/component/_generated/api.d.ts +++ /dev/null @@ -1,2604 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import type * as apiKeys from "../apiKeys.js"; -import type * as files from "../files.js"; -import type * as messages from "../messages.js"; -import type * as streams from "../streams.js"; -import type * as threads from "../threads.js"; -import type * as users from "../users.js"; -import type * as vector_index from "../vector/index.js"; -import type * as vector_tables from "../vector/tables.js"; - -import type { - ApiFromModules, - FilterApi, - FunctionReference, -} from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -declare const fullApi: ApiFromModules<{ - apiKeys: typeof apiKeys; - files: typeof files; - messages: typeof messages; - streams: typeof streams; - threads: typeof threads; - users: typeof users; - "vector/index": typeof vector_index; - "vector/tables": typeof vector_tables; -}>; -export type Mounts = { - apiKeys: { - destroy: FunctionReference< - "mutation", - "public", - { apiKey?: string; name?: string }, - | "missing" - | "deleted" - | "name mismatch" - | "must provide either apiKey or name" - >; - issue: FunctionReference<"mutation", "public", { name?: string }, string>; - validate: FunctionReference<"query", "public", { apiKey: string }, boolean>; - }; - files: { - addFile: FunctionReference< - "mutation", - "public", - { filename?: string; hash: string; mimeType: string; storageId: string }, - { fileId: string; storageId: string } - >; - copyFile: FunctionReference<"mutation", "public", { fileId: string }, null>; - deleteFiles: FunctionReference< - "mutation", - "public", - { fileIds: Array; force?: boolean }, - Array - >; - get: FunctionReference< - "query", - "public", - { fileId: string }, - null | { - _creationTime: number; - _id: string; - filename?: string; - hash: string; - lastTouchedAt: number; - mimeType: string; - refcount: number; - storageId: string; - } - >; - getFilesToDelete: FunctionReference< - "query", - "public", - { - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - { - continueCursor: string; - isDone: boolean; - page: Array<{ - _creationTime: number; - _id: string; - filename?: string; - hash: string; - lastTouchedAt: number; - mimeType: string; - refcount: number; - storageId: string; - }>; - } - >; - useExistingFile: FunctionReference< - "mutation", - "public", - { filename?: string; hash: string }, - null | { fileId: string; storageId: string } - >; - }; - messages: { - addMessages: FunctionReference< - "mutation", - "public", - { - agentName?: string; - embeddings?: { - dimension: - | 128 - | 256 - | 512 - | 768 - | 1024 - | 1408 - | 1536 - | 2048 - | 3072 - | 4096; - model: string; - vectors: Array | null>; - }; - failPendingSteps?: boolean; - hideFromUserIdSearch?: boolean; - messages: Array<{ - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - message: - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - provider?: string; - providerMetadata?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status?: "pending" | "success" | "failed"; - text?: string; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }>; - pendingMessageId?: string; - promptMessageId?: string; - threadId: string; - userId?: string; - }, - { - messages: Array<{ - _creationTime: number; - _id: string; - agentName?: string; - embeddingId?: string; - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }>; - } - >; - cloneThread: FunctionReference< - "action", - "public", - { - batchSize?: number; - copyUserIdForVectorSearch?: boolean; - excludeToolMessages?: boolean; - insertAtOrder?: number; - limit?: number; - sourceThreadId: string; - statuses?: Array<"pending" | "success" | "failed">; - targetThreadId: string; - upToAndIncludingMessageId?: string; - }, - number - >; - deleteByIds: FunctionReference< - "mutation", - "public", - { messageIds: Array }, - Array - >; - deleteByOrder: FunctionReference< - "mutation", - "public", - { - endOrder: number; - endStepOrder?: number; - startOrder: number; - startStepOrder?: number; - threadId: string; - }, - { isDone: boolean; lastOrder?: number; lastStepOrder?: number } - >; - finalizeMessage: FunctionReference< - "mutation", - "public", - { - messageId: string; - result: { status: "success" } | { error: string; status: "failed" }; - }, - null - >; - getMessageSearchFields: FunctionReference< - "query", - "public", - { messageId: string }, - { embedding?: Array; embeddingModel?: string; text?: string } - >; - getMessagesByIds: FunctionReference< - "query", - "public", - { messageIds: Array }, - Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }> - >; - listMessagesByThreadId: FunctionReference< - "query", - "public", - { - excludeToolMessages?: boolean; - order: "asc" | "desc"; - paginationOpts?: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - statuses?: Array<"pending" | "success" | "failed">; - threadId: string; - upToAndIncludingMessageId?: string; - }, - { - continueCursor: string; - isDone: boolean; - page: Array<{ - _creationTime: number; - _id: string; - agentName?: string; - embeddingId?: string; - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }>; - pageStatus?: "SplitRecommended" | "SplitRequired" | null; - splitCursor?: string | null; - } - >; - searchMessages: FunctionReference< - "action", - "public", - { - embedding?: Array; - embeddingModel?: string; - limit: number; - messageRange?: { after: number; before: number }; - searchAllMessagesForUserId?: string; - targetMessageId?: string; - text?: string; - textSearch?: boolean; - threadId?: string; - vectorScoreThreshold?: number; - vectorSearch?: boolean; - }, - Array<{ - _creationTime: number; - _id: string; - agentName?: string; - embeddingId?: string; - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }> - >; - textSearch: FunctionReference< - "query", - "public", - { - limit: number; - searchAllMessagesForUserId?: string; - targetMessageId?: string; - text?: string; - threadId?: string; - }, - Array<{ - _creationTime: number; - _id: string; - agentName?: string; - embeddingId?: string; - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - }> - >; - updateMessage: FunctionReference< - "mutation", - "public", - { - messageId: string; - patch: { - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record< - string, - Record - >; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - provider?: string; - providerOptions?: Record>; - status?: "pending" | "success" | "failed"; - }; - }, - { - _creationTime: number; - _id: string; - agentName?: string; - embeddingId?: string; - error?: string; - fileIds?: Array; - finishReason?: - | "stop" - | "length" - | "content-filter" - | "tool-calls" - | "error" - | "other" - | "unknown"; - id?: string; - message?: - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - image: string | ArrayBuffer; - mimeType?: string; - providerOptions?: Record>; - type: "image"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - >; - providerOptions?: Record>; - role: "user"; - } - | { - content: - | string - | Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - text: string; - type: "text"; - } - | { - data: string | ArrayBuffer; - filename?: string; - mimeType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "file"; - } - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { - data: string; - providerMetadata?: Record>; - providerOptions?: Record>; - type: "redacted-reasoning"; - } - | { - args: any; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - toolCallId: string; - toolName: string; - type: "tool-call"; - } - | { - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { - data: string; - mediaType: string; - type: "media"; - } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - } - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - providerOptions?: Record>; - role: "assistant"; - } - | { - content: Array<{ - args?: any; - experimental_content?: Array< - | { text: string; type: "text" } - | { data: string; mimeType?: string; type: "image" } - >; - isError?: boolean; - output?: - | { type: "text"; value: string } - | { type: "json"; value: any } - | { type: "error-text"; value: string } - | { type: "error-json"; value: any } - | { - type: "content"; - value: Array< - | { text: string; type: "text" } - | { data: string; mediaType: string; type: "media" } - >; - }; - providerExecuted?: boolean; - providerMetadata?: Record>; - providerOptions?: Record>; - result?: any; - toolCallId: string; - toolName: string; - type: "tool-result"; - }>; - providerOptions?: Record>; - role: "tool"; - } - | { - content: string; - providerOptions?: Record>; - role: "system"; - }; - model?: string; - order: number; - provider?: string; - providerMetadata?: Record>; - providerOptions?: Record>; - reasoning?: string; - reasoningDetails?: Array< - | { - providerMetadata?: Record>; - providerOptions?: Record>; - signature?: string; - text: string; - type: "reasoning"; - } - | { signature?: string; text: string; type: "text" } - | { data: string; type: "redacted" } - >; - sources?: Array< - | { - id: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "url"; - title?: string; - type?: "source"; - url: string; - } - | { - filename?: string; - id: string; - mediaType: string; - providerMetadata?: Record>; - providerOptions?: Record>; - sourceType: "document"; - title: string; - type: "source"; - } - >; - status: "pending" | "success" | "failed"; - stepOrder: number; - text?: string; - threadId: string; - tool: boolean; - usage?: { - cachedInputTokens?: number; - completionTokens: number; - promptTokens: number; - reasoningTokens?: number; - totalTokens: number; - }; - userId?: string; - warnings?: Array< - | { details?: string; setting: string; type: "unsupported-setting" } - | { details?: string; tool: any; type: "unsupported-tool" } - | { message: string; type: "other" } - >; - } - >; - }; - streams: { - abort: FunctionReference< - "mutation", - "public", - { - finalDelta?: { - end: number; - parts: Array; - start: number; - streamId: string; - }; - reason: string; - streamId: string; - }, - boolean - >; - abortByOrder: FunctionReference< - "mutation", - "public", - { order: number; reason: string; threadId: string }, - boolean - >; - addDelta: FunctionReference< - "mutation", - "public", - { end: number; parts: Array; start: number; streamId: string }, - boolean - >; - create: FunctionReference< - "mutation", - "public", - { - agentName?: string; - format?: "UIMessageChunk" | "TextStreamPart"; - model?: string; - order: number; - provider?: string; - providerOptions?: Record>; - stepOrder: number; - threadId: string; - userId?: string; - }, - string - >; - deleteAllStreamsForThreadIdAsync: FunctionReference< - "mutation", - "public", - { deltaCursor?: string; streamOrder?: number; threadId: string }, - { deltaCursor?: string; isDone: boolean; streamOrder?: number } - >; - deleteAllStreamsForThreadIdSync: FunctionReference< - "action", - "public", - { threadId: string }, - null - >; - deleteStreamAsync: FunctionReference< - "mutation", - "public", - { cursor?: string; streamId: string }, - null - >; - deleteStreamSync: FunctionReference< - "mutation", - "public", - { streamId: string }, - null - >; - finish: FunctionReference< - "mutation", - "public", - { - finalDelta?: { - end: number; - parts: Array; - start: number; - streamId: string; - }; - streamId: string; - }, - null - >; - heartbeat: FunctionReference< - "mutation", - "public", - { streamId: string }, - null - >; - list: FunctionReference< - "query", - "public", - { - startOrder?: number; - statuses?: Array<"streaming" | "finished" | "aborted">; - threadId: string; - }, - Array<{ - agentName?: string; - format?: "UIMessageChunk" | "TextStreamPart"; - model?: string; - order: number; - provider?: string; - providerOptions?: Record>; - status: "streaming" | "finished" | "aborted"; - stepOrder: number; - streamId: string; - userId?: string; - }> - >; - listDeltas: FunctionReference< - "query", - "public", - { - cursors: Array<{ cursor: number; streamId: string }>; - threadId: string; - }, - Array<{ end: number; parts: Array; start: number; streamId: string }> - >; - }; - threads: { - createThread: FunctionReference< - "mutation", - "public", - { - defaultSystemPrompt?: string; - parentThreadIds?: Array; - summary?: string; - title?: string; - userId?: string; - }, - { - _creationTime: number; - _id: string; - status: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - } - >; - deleteAllForThreadIdAsync: FunctionReference< - "mutation", - "public", - { - cursor?: string; - deltaCursor?: string; - limit?: number; - messagesDone?: boolean; - streamOrder?: number; - streamsDone?: boolean; - threadId: string; - }, - { isDone: boolean } - >; - deleteAllForThreadIdSync: FunctionReference< - "action", - "public", - { limit?: number; threadId: string }, - null - >; - getThread: FunctionReference< - "query", - "public", - { threadId: string }, - { - _creationTime: number; - _id: string; - status: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - } | null - >; - listThreadsByUserId: FunctionReference< - "query", - "public", - { - order?: "asc" | "desc"; - paginationOpts?: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - userId?: string; - }, - { - continueCursor: string; - isDone: boolean; - page: Array<{ - _creationTime: number; - _id: string; - status: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - }>; - pageStatus?: "SplitRecommended" | "SplitRequired" | null; - splitCursor?: string | null; - } - >; - searchThreadTitles: FunctionReference< - "query", - "public", - { limit: number; query: string; userId?: string | null }, - Array<{ - _creationTime: number; - _id: string; - status: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - }> - >; - updateThread: FunctionReference< - "mutation", - "public", - { - patch: { - status?: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - }; - threadId: string; - }, - { - _creationTime: number; - _id: string; - status: "active" | "archived"; - summary?: string; - title?: string; - userId?: string; - } - >; - }; - users: { - deleteAllForUserId: FunctionReference< - "action", - "public", - { userId: string }, - null - >; - deleteAllForUserIdAsync: FunctionReference< - "mutation", - "public", - { userId: string }, - boolean - >; - listUsersWithThreads: FunctionReference< - "query", - "public", - { - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - { - continueCursor: string; - isDone: boolean; - page: Array; - pageStatus?: "SplitRecommended" | "SplitRequired" | null; - splitCursor?: string | null; - } - >; - }; - vector: { - index: { - deleteBatch: FunctionReference< - "mutation", - "public", - { - ids: Array< - | string - | string - | string - | string - | string - | string - | string - | string - | string - | string - >; - }, - null - >; - deleteBatchForThread: FunctionReference< - "mutation", - "public", - { - cursor?: string; - limit: number; - model: string; - threadId: string; - vectorDimension: - | 128 - | 256 - | 512 - | 768 - | 1024 - | 1408 - | 1536 - | 2048 - | 3072 - | 4096; - }, - { continueCursor: string; isDone: boolean } - >; - insertBatch: FunctionReference< - "mutation", - "public", - { - vectorDimension: - | 128 - | 256 - | 512 - | 768 - | 1024 - | 1408 - | 1536 - | 2048 - | 3072 - | 4096; - vectors: Array<{ - messageId?: string; - model: string; - table: string; - threadId?: string; - userId?: string; - vector: Array; - }>; - }, - Array< - | string - | string - | string - | string - | string - | string - | string - | string - | string - | string - > - >; - paginate: FunctionReference< - "query", - "public", - { - cursor?: string; - limit: number; - table?: string; - targetModel: string; - vectorDimension: - | 128 - | 256 - | 512 - | 768 - | 1024 - | 1408 - | 1536 - | 2048 - | 3072 - | 4096; - }, - { - continueCursor: string; - ids: Array< - | string - | string - | string - | string - | string - | string - | string - | string - | string - | string - >; - isDone: boolean; - } - >; - updateBatch: FunctionReference< - "mutation", - "public", - { - vectors: Array<{ - id: - | string - | string - | string - | string - | string - | string - | string - | string - | string - | string; - model: string; - vector: Array; - }>; - }, - null - >; - }; - }; -}; -// For now fullApiWithMounts is only fullApi which provides -// jump-to-definition in component client code. -// Use Mounts for the same type without the inference. -declare const fullApiWithMounts: typeof fullApi; - -export declare const api: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; -export declare const internal: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; - -export declare const components: {}; diff --git a/src/component/_generated/api.js b/src/component/_generated/api.js deleted file mode 100644 index 44bf9858..00000000 --- a/src/component/_generated/api.js +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { anyApi, componentsGeneric } from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -export const api = anyApi; -export const internal = anyApi; -export const components = componentsGeneric(); diff --git a/src/component/_generated/api.ts b/src/component/_generated/api.ts new file mode 100644 index 00000000..21a3928d --- /dev/null +++ b/src/component/_generated/api.ts @@ -0,0 +1,64 @@ +/* eslint-disable */ +/** + * Generated `api` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type * as apiKeys from "../apiKeys.js"; +import type * as files from "../files.js"; +import type * as messages from "../messages.js"; +import type * as streams from "../streams.js"; +import type * as threads from "../threads.js"; +import type * as users from "../users.js"; +import type * as vector_index from "../vector/index.js"; +import type * as vector_tables from "../vector/tables.js"; + +import type { + ApiFromModules, + FilterApi, + FunctionReference, +} from "convex/server"; +import { anyApi, componentsGeneric } from "convex/server"; + +const fullApi: ApiFromModules<{ + apiKeys: typeof apiKeys; + files: typeof files; + messages: typeof messages; + streams: typeof streams; + threads: typeof threads; + users: typeof users; + "vector/index": typeof vector_index; + "vector/tables": typeof vector_tables; +}> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ +export const api: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ +export const internal: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +export const components = componentsGeneric() as unknown as {}; diff --git a/src/component/_generated/component.ts b/src/component/_generated/component.ts new file mode 100644 index 00000000..228108ff --- /dev/null +++ b/src/component/_generated/component.ts @@ -0,0 +1,2922 @@ +/* eslint-disable */ +/** + * Generated `ComponentApi` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type { FunctionReference } from "convex/server"; + +/** + * A utility for referencing a Convex component's exposed API. + * + * Useful when expecting a parameter like `components.myComponent`. + * Usage: + * ```ts + * async function myFunction(ctx: QueryCtx, component: ComponentApi) { + * return ctx.runQuery(component.someFile.someQuery, { ...args }); + * } + * ``` + */ +export type ComponentApi = + { + apiKeys: { + destroy: FunctionReference< + "mutation", + "internal", + { apiKey?: string; name?: string }, + | "missing" + | "deleted" + | "name mismatch" + | "must provide either apiKey or name", + Name + >; + issue: FunctionReference< + "mutation", + "internal", + { name?: string }, + string, + Name + >; + validate: FunctionReference< + "query", + "internal", + { apiKey: string }, + boolean, + Name + >; + }; + files: { + addFile: FunctionReference< + "mutation", + "internal", + { + filename?: string; + hash: string; + mimeType: string; + storageId: string; + }, + { fileId: string; storageId: string }, + Name + >; + copyFile: FunctionReference< + "mutation", + "internal", + { fileId: string }, + null, + Name + >; + deleteFiles: FunctionReference< + "mutation", + "internal", + { fileIds: Array; force?: boolean }, + Array, + Name + >; + get: FunctionReference< + "query", + "internal", + { fileId: string }, + null | { + _creationTime: number; + _id: string; + filename?: string; + hash: string; + lastTouchedAt: number; + mimeType: string; + refcount: number; + storageId: string; + }, + Name + >; + getFilesToDelete: FunctionReference< + "query", + "internal", + { + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + { + continueCursor: string; + isDone: boolean; + page: Array<{ + _creationTime: number; + _id: string; + filename?: string; + hash: string; + lastTouchedAt: number; + mimeType: string; + refcount: number; + storageId: string; + }>; + }, + Name + >; + useExistingFile: FunctionReference< + "mutation", + "internal", + { filename?: string; hash: string }, + null | { fileId: string; storageId: string }, + Name + >; + }; + messages: { + addMessages: FunctionReference< + "mutation", + "internal", + { + agentName?: string; + embeddings?: { + dimension: + | 128 + | 256 + | 512 + | 768 + | 1024 + | 1408 + | 1536 + | 2048 + | 3072 + | 4096; + model: string; + vectors: Array | null>; + }; + failPendingSteps?: boolean; + hideFromUserIdSearch?: boolean; + messages: Array<{ + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + message: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record< + string, + Record + >; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { + data: string; + mimeType?: string; + type: "image"; + } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + provider?: string; + providerMetadata?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status?: "pending" | "success" | "failed"; + text?: string; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + warnings?: Array< + | { + details?: string; + setting: string; + type: "unsupported-setting"; + } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>; + pendingMessageId?: string; + promptMessageId?: string; + threadId: string; + userId?: string; + }, + { + messages: Array<{ + _creationTime: number; + _id: string; + agentName?: string; + embeddingId?: string; + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record< + string, + Record + >; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { + data: string; + mimeType?: string; + type: "image"; + } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { + details?: string; + setting: string; + type: "unsupported-setting"; + } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>; + }, + Name + >; + cloneThread: FunctionReference< + "action", + "internal", + { + batchSize?: number; + copyUserIdForVectorSearch?: boolean; + excludeToolMessages?: boolean; + insertAtOrder?: number; + limit?: number; + sourceThreadId: string; + statuses?: Array<"pending" | "success" | "failed">; + targetThreadId: string; + upToAndIncludingMessageId?: string; + }, + number, + Name + >; + deleteByIds: FunctionReference< + "mutation", + "internal", + { messageIds: Array }, + Array, + Name + >; + deleteByOrder: FunctionReference< + "mutation", + "internal", + { + endOrder: number; + endStepOrder?: number; + startOrder: number; + startStepOrder?: number; + threadId: string; + }, + { isDone: boolean; lastOrder?: number; lastStepOrder?: number }, + Name + >; + finalizeMessage: FunctionReference< + "mutation", + "internal", + { + messageId: string; + result: { status: "success" } | { error: string; status: "failed" }; + }, + null, + Name + >; + getMessagesByIds: FunctionReference< + "query", + "internal", + { messageIds: Array }, + Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record>; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { details?: string; setting: string; type: "unsupported-setting" } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>, + Name + >; + getMessageSearchFields: FunctionReference< + "query", + "internal", + { messageId: string }, + { embedding?: Array; embeddingModel?: string; text?: string }, + Name + >; + listMessagesByThreadId: FunctionReference< + "query", + "internal", + { + excludeToolMessages?: boolean; + order: "asc" | "desc"; + paginationOpts?: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + statuses?: Array<"pending" | "success" | "failed">; + threadId: string; + upToAndIncludingMessageId?: string; + }, + { + continueCursor: string; + isDone: boolean; + page: Array<{ + _creationTime: number; + _id: string; + agentName?: string; + embeddingId?: string; + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record< + string, + Record + >; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { + data: string; + mimeType?: string; + type: "image"; + } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { + details?: string; + setting: string; + type: "unsupported-setting"; + } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>; + pageStatus?: "SplitRecommended" | "SplitRequired" | null; + splitCursor?: string | null; + }, + Name + >; + searchMessages: FunctionReference< + "action", + "internal", + { + embedding?: Array; + embeddingModel?: string; + limit: number; + messageRange?: { after: number; before: number }; + searchAllMessagesForUserId?: string; + targetMessageId?: string; + text?: string; + textSearch?: boolean; + threadId?: string; + vectorScoreThreshold?: number; + vectorSearch?: boolean; + }, + Array<{ + _creationTime: number; + _id: string; + agentName?: string; + embeddingId?: string; + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record>; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { details?: string; setting: string; type: "unsupported-setting" } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>, + Name + >; + textSearch: FunctionReference< + "query", + "internal", + { + limit: number; + searchAllMessagesForUserId?: string; + targetMessageId?: string; + text?: string; + threadId?: string; + }, + Array<{ + _creationTime: number; + _id: string; + agentName?: string; + embeddingId?: string; + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record>; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { details?: string; setting: string; type: "unsupported-setting" } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }>, + Name + >; + updateMessage: FunctionReference< + "mutation", + "internal", + { + messageId: string; + patch: { + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record< + string, + Record + >; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { + data: string; + mimeType?: string; + type: "image"; + } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record< + string, + Record + >; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + provider?: string; + providerOptions?: Record>; + status?: "pending" | "success" | "failed"; + }; + }, + { + _creationTime: number; + _id: string; + agentName?: string; + embeddingId?: string; + error?: string; + fileIds?: Array; + finishReason?: + | "stop" + | "length" + | "content-filter" + | "tool-calls" + | "error" + | "other" + | "unknown"; + id?: string; + message?: + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + image: string | ArrayBuffer; + mimeType?: string; + providerOptions?: Record>; + type: "image"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + >; + providerOptions?: Record>; + role: "user"; + } + | { + content: + | string + | Array< + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + text: string; + type: "text"; + } + | { + data: string | ArrayBuffer; + filename?: string; + mimeType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "file"; + } + | { + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { + data: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + type: "redacted-reasoning"; + } + | { + args: any; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + toolCallId: string; + toolName: string; + type: "tool-call"; + } + | { + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { + data: string; + mediaType: string; + type: "media"; + } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + } + | { + id: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record< + string, + Record + >; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + providerOptions?: Record>; + role: "assistant"; + } + | { + content: Array<{ + args?: any; + experimental_content?: Array< + | { text: string; type: "text" } + | { data: string; mimeType?: string; type: "image" } + >; + isError?: boolean; + output?: + | { type: "text"; value: string } + | { type: "json"; value: any } + | { type: "error-text"; value: string } + | { type: "error-json"; value: any } + | { + type: "content"; + value: Array< + | { text: string; type: "text" } + | { data: string; mediaType: string; type: "media" } + >; + }; + providerExecuted?: boolean; + providerMetadata?: Record>; + providerOptions?: Record>; + result?: any; + toolCallId: string; + toolName: string; + type: "tool-result"; + }>; + providerOptions?: Record>; + role: "tool"; + } + | { + content: string; + providerOptions?: Record>; + role: "system"; + }; + model?: string; + order: number; + provider?: string; + providerMetadata?: Record>; + providerOptions?: Record>; + reasoning?: string; + reasoningDetails?: Array< + | { + providerMetadata?: Record>; + providerOptions?: Record>; + signature?: string; + text: string; + type: "reasoning"; + } + | { signature?: string; text: string; type: "text" } + | { data: string; type: "redacted" } + >; + sources?: Array< + | { + id: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "url"; + title?: string; + type?: "source"; + url: string; + } + | { + filename?: string; + id: string; + mediaType: string; + providerMetadata?: Record>; + providerOptions?: Record>; + sourceType: "document"; + title: string; + type: "source"; + } + >; + status: "pending" | "success" | "failed"; + stepOrder: number; + text?: string; + threadId: string; + tool: boolean; + usage?: { + cachedInputTokens?: number; + completionTokens: number; + promptTokens: number; + reasoningTokens?: number; + totalTokens: number; + }; + userId?: string; + warnings?: Array< + | { details?: string; setting: string; type: "unsupported-setting" } + | { details?: string; tool: any; type: "unsupported-tool" } + | { message: string; type: "other" } + >; + }, + Name + >; + }; + streams: { + abort: FunctionReference< + "mutation", + "internal", + { + finalDelta?: { + end: number; + parts: Array; + start: number; + streamId: string; + }; + reason: string; + streamId: string; + }, + boolean, + Name + >; + abortByOrder: FunctionReference< + "mutation", + "internal", + { order: number; reason: string; threadId: string }, + boolean, + Name + >; + addDelta: FunctionReference< + "mutation", + "internal", + { end: number; parts: Array; start: number; streamId: string }, + boolean, + Name + >; + create: FunctionReference< + "mutation", + "internal", + { + agentName?: string; + format?: "UIMessageChunk" | "TextStreamPart"; + model?: string; + order: number; + provider?: string; + providerOptions?: Record>; + stepOrder: number; + threadId: string; + userId?: string; + }, + string, + Name + >; + deleteAllStreamsForThreadIdAsync: FunctionReference< + "mutation", + "internal", + { deltaCursor?: string; streamOrder?: number; threadId: string }, + { deltaCursor?: string; isDone: boolean; streamOrder?: number }, + Name + >; + deleteAllStreamsForThreadIdSync: FunctionReference< + "action", + "internal", + { threadId: string }, + null, + Name + >; + deleteStreamAsync: FunctionReference< + "mutation", + "internal", + { cursor?: string; streamId: string }, + null, + Name + >; + deleteStreamSync: FunctionReference< + "mutation", + "internal", + { streamId: string }, + null, + Name + >; + finish: FunctionReference< + "mutation", + "internal", + { + finalDelta?: { + end: number; + parts: Array; + start: number; + streamId: string; + }; + streamId: string; + }, + null, + Name + >; + heartbeat: FunctionReference< + "mutation", + "internal", + { streamId: string }, + null, + Name + >; + list: FunctionReference< + "query", + "internal", + { + startOrder?: number; + statuses?: Array<"streaming" | "finished" | "aborted">; + threadId: string; + }, + Array<{ + agentName?: string; + format?: "UIMessageChunk" | "TextStreamPart"; + model?: string; + order: number; + provider?: string; + providerOptions?: Record>; + status: "streaming" | "finished" | "aborted"; + stepOrder: number; + streamId: string; + userId?: string; + }>, + Name + >; + listDeltas: FunctionReference< + "query", + "internal", + { + cursors: Array<{ cursor: number; streamId: string }>; + threadId: string; + }, + Array<{ + end: number; + parts: Array; + start: number; + streamId: string; + }>, + Name + >; + }; + threads: { + createThread: FunctionReference< + "mutation", + "internal", + { + defaultSystemPrompt?: string; + parentThreadIds?: Array; + summary?: string; + title?: string; + userId?: string; + }, + { + _creationTime: number; + _id: string; + status: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + }, + Name + >; + deleteAllForThreadIdAsync: FunctionReference< + "mutation", + "internal", + { + cursor?: string; + deltaCursor?: string; + limit?: number; + messagesDone?: boolean; + streamOrder?: number; + streamsDone?: boolean; + threadId: string; + }, + { isDone: boolean }, + Name + >; + deleteAllForThreadIdSync: FunctionReference< + "action", + "internal", + { limit?: number; threadId: string }, + null, + Name + >; + getThread: FunctionReference< + "query", + "internal", + { threadId: string }, + { + _creationTime: number; + _id: string; + status: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + } | null, + Name + >; + listThreadsByUserId: FunctionReference< + "query", + "internal", + { + order?: "asc" | "desc"; + paginationOpts?: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + userId?: string; + }, + { + continueCursor: string; + isDone: boolean; + page: Array<{ + _creationTime: number; + _id: string; + status: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + }>; + pageStatus?: "SplitRecommended" | "SplitRequired" | null; + splitCursor?: string | null; + }, + Name + >; + searchThreadTitles: FunctionReference< + "query", + "internal", + { limit: number; query: string; userId?: string | null }, + Array<{ + _creationTime: number; + _id: string; + status: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + }>, + Name + >; + updateThread: FunctionReference< + "mutation", + "internal", + { + patch: { + status?: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + }; + threadId: string; + }, + { + _creationTime: number; + _id: string; + status: "active" | "archived"; + summary?: string; + title?: string; + userId?: string; + }, + Name + >; + }; + users: { + deleteAllForUserId: FunctionReference< + "action", + "internal", + { userId: string }, + null, + Name + >; + deleteAllForUserIdAsync: FunctionReference< + "mutation", + "internal", + { userId: string }, + boolean, + Name + >; + listUsersWithThreads: FunctionReference< + "query", + "internal", + { + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + { + continueCursor: string; + isDone: boolean; + page: Array; + pageStatus?: "SplitRecommended" | "SplitRequired" | null; + splitCursor?: string | null; + }, + Name + >; + }; + vector: { + index: { + deleteBatch: FunctionReference< + "mutation", + "internal", + { + ids: Array< + | string + | string + | string + | string + | string + | string + | string + | string + | string + | string + >; + }, + null, + Name + >; + deleteBatchForThread: FunctionReference< + "mutation", + "internal", + { + cursor?: string; + limit: number; + model: string; + threadId: string; + vectorDimension: + | 128 + | 256 + | 512 + | 768 + | 1024 + | 1408 + | 1536 + | 2048 + | 3072 + | 4096; + }, + { continueCursor: string; isDone: boolean }, + Name + >; + insertBatch: FunctionReference< + "mutation", + "internal", + { + vectorDimension: + | 128 + | 256 + | 512 + | 768 + | 1024 + | 1408 + | 1536 + | 2048 + | 3072 + | 4096; + vectors: Array<{ + messageId?: string; + model: string; + table: string; + threadId?: string; + userId?: string; + vector: Array; + }>; + }, + Array< + | string + | string + | string + | string + | string + | string + | string + | string + | string + | string + >, + Name + >; + paginate: FunctionReference< + "query", + "internal", + { + cursor?: string; + limit: number; + table?: string; + targetModel: string; + vectorDimension: + | 128 + | 256 + | 512 + | 768 + | 1024 + | 1408 + | 1536 + | 2048 + | 3072 + | 4096; + }, + { + continueCursor: string; + ids: Array< + | string + | string + | string + | string + | string + | string + | string + | string + | string + | string + >; + isDone: boolean; + }, + Name + >; + updateBatch: FunctionReference< + "mutation", + "internal", + { + vectors: Array<{ + id: + | string + | string + | string + | string + | string + | string + | string + | string + | string + | string; + model: string; + vector: Array; + }>; + }, + null, + Name + >; + }; + }; + }; diff --git a/src/component/_generated/dataModel.d.ts b/src/component/_generated/dataModel.ts similarity index 100% rename from src/component/_generated/dataModel.d.ts rename to src/component/_generated/dataModel.ts diff --git a/src/component/_generated/server.js b/src/component/_generated/server.js deleted file mode 100644 index 4a21df4f..00000000 --- a/src/component/_generated/server.js +++ /dev/null @@ -1,90 +0,0 @@ -/* eslint-disable */ -/** - * Generated utilities for implementing server-side Convex query and mutation functions. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { - actionGeneric, - httpActionGeneric, - queryGeneric, - mutationGeneric, - internalActionGeneric, - internalMutationGeneric, - internalQueryGeneric, - componentsGeneric, -} from "convex/server"; - -/** - * Define a query in this Convex app's public API. - * - * This function will be allowed to read your Convex database and will be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const query = queryGeneric; - -/** - * Define a query that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to read from your Convex database. It will not be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const internalQuery = internalQueryGeneric; - -/** - * Define a mutation in this Convex app's public API. - * - * This function will be allowed to modify your Convex database and will be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const mutation = mutationGeneric; - -/** - * Define a mutation that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to modify your Convex database. It will not be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const internalMutation = internalMutationGeneric; - -/** - * Define an action in this Convex app's public API. - * - * An action is a function which can execute any JavaScript code, including non-deterministic - * code and code with side-effects, like calling third-party services. - * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive. - * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}. - * - * @param func - The action. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped action. Include this as an `export` to name it and make it accessible. - */ -export const action = actionGeneric; - -/** - * Define an action that is only accessible from other Convex functions (but not from the client). - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped function. Include this as an `export` to name it and make it accessible. - */ -export const internalAction = internalActionGeneric; - -/** - * Define a Convex HTTP action. - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. - */ -export const httpAction = httpActionGeneric; diff --git a/src/component/_generated/server.d.ts b/src/component/_generated/server.ts similarity index 79% rename from src/component/_generated/server.d.ts rename to src/component/_generated/server.ts index b5c68288..24994e4e 100644 --- a/src/component/_generated/server.d.ts +++ b/src/component/_generated/server.ts @@ -8,9 +8,8 @@ * @module */ -import { +import type { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,18 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, +} from "convex/server"; +import { + actionGeneric, + httpActionGeneric, + queryGeneric, + mutationGeneric, + internalActionGeneric, + internalMutationGeneric, + internalQueryGeneric, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -36,7 +38,7 @@ type GenericCtx = * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const query: QueryBuilder; +export const query: QueryBuilder = queryGeneric; /** * Define a query that is only accessible from other Convex functions (but not from the client). @@ -46,7 +48,8 @@ export declare const query: QueryBuilder; * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const internalQuery: QueryBuilder; +export const internalQuery: QueryBuilder = + internalQueryGeneric; /** * Define a mutation in this Convex app's public API. @@ -56,7 +59,7 @@ export declare const internalQuery: QueryBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const mutation: MutationBuilder; +export const mutation: MutationBuilder = mutationGeneric; /** * Define a mutation that is only accessible from other Convex functions (but not from the client). @@ -66,7 +69,8 @@ export declare const mutation: MutationBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const internalMutation: MutationBuilder; +export const internalMutation: MutationBuilder = + internalMutationGeneric; /** * Define an action in this Convex app's public API. @@ -79,7 +83,7 @@ export declare const internalMutation: MutationBuilder; * @param func - The action. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped action. Include this as an `export` to name it and make it accessible. */ -export declare const action: ActionBuilder; +export const action: ActionBuilder = actionGeneric; /** * Define an action that is only accessible from other Convex functions (but not from the client). @@ -87,19 +91,26 @@ export declare const action: ActionBuilder; * @param func - The function. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped function. Include this as an `export` to name it and make it accessible. */ -export declare const internalAction: ActionBuilder; +export const internalAction: ActionBuilder = + internalActionGeneric; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ -export declare const httpAction: HttpActionBuilder; +export const httpAction: HttpActionBuilder = httpActionGeneric; + +type GenericCtx = + | GenericActionCtx + | GenericMutationCtx + | GenericQueryCtx; /** * A set of services for use within Convex query functions. @@ -107,8 +118,7 @@ export declare const httpAction: HttpActionBuilder; * The query context is passed as the first argument to any Convex query * function run on the server. * - * This differs from the {@link MutationCtx} because all of the services are - * read-only. + * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead. */ export type QueryCtx = GenericQueryCtx; @@ -117,6 +127,8 @@ export type QueryCtx = GenericQueryCtx; * * The mutation context is passed as the first argument to any Convex mutation * function run on the server. + * + * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead. */ export type MutationCtx = GenericMutationCtx; diff --git a/src/component/vector/index.ts b/src/component/vector/index.ts index d298d0d9..854e903f 100644 --- a/src/component/vector/index.ts +++ b/src/component/vector/index.ts @@ -35,11 +35,9 @@ export const paginate = query({ const tableName = getVectorTableName(args.vectorDimension); const vectors = await paginator(ctx.db, schema) .query(tableName) - // eslint-disable-next-line @typescript-eslint/no-explicit-any .withIndex("model_table_threadId" as any, (q) => args.table - ? // eslint-disable-next-line @typescript-eslint/no-explicit-any - (q.eq("model", args.targetModel) as any).eq("table", args.table) + ? (q.eq("model", args.targetModel) as any).eq("table", args.table) : q.eq("model", args.targetModel), ) .paginate({ diff --git a/src/mapping.ts b/src/mapping.ts index 017a4cc2..86253c31 100644 --- a/src/mapping.ts +++ b/src/mapping.ts @@ -60,8 +60,7 @@ export type SerializeUrlsAndUint8Arrays = T extends URL ? ArrayBuffer : T extends Array ? Array> - : // eslint-disable-next-line @typescript-eslint/no-explicit-any - T extends Record + : T extends Record ? { [K in keyof T]: SerializeUrlsAndUint8Arrays } : T; @@ -109,9 +108,7 @@ export async function serializeOrThrow( message: ModelMessage | Message, ): Promise { const { content } = await serializeContent( - // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any, - // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any, message.content, ); diff --git a/src/react/useDeltaStreams.ts b/src/react/useDeltaStreams.ts index c6486785..799feca1 100644 --- a/src/react/useDeltaStreams.ts +++ b/src/react/useDeltaStreams.ts @@ -10,7 +10,6 @@ import { useState } from "react"; import { assert } from "convex-helpers"; export function useDeltaStreams< - // eslint-disable-next-line @typescript-eslint/no-explicit-any Query extends StreamQuery = StreamQuery, >( query: Query, diff --git a/src/react/useStreamingUIMessages.ts b/src/react/useStreamingUIMessages.ts index 7d447374..e8a4b003 100644 --- a/src/react/useStreamingUIMessages.ts +++ b/src/react/useStreamingUIMessages.ts @@ -13,7 +13,6 @@ import { useDeltaStreams } from "./useDeltaStreams.js"; // Polyfill structuredClone to support readUIMessageStream on ReactNative if (!("structuredClone" in globalThis)) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any void import("@ungap/structured-clone" as any).then( ({ default: structuredClone }) => (globalThis.structuredClone = structuredClone), @@ -38,7 +37,6 @@ export function useStreamingUIMessages< METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools, - // eslint-disable-next-line @typescript-eslint/no-explicit-any Query extends StreamQuery = StreamQuery, >( query: Query, diff --git a/src/react/useThreadMessages.ts b/src/react/useThreadMessages.ts index abf742c1..ecd6e8f3 100644 --- a/src/react/useThreadMessages.ts +++ b/src/react/useThreadMessages.ts @@ -116,10 +116,7 @@ export type ThreadMessagesResult< * @returns The messages. If stream is true, it will return a list of messages * that includes both full messages and streaming messages. */ -export function useThreadMessages< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Query extends ThreadMessagesQuery, ->( +export function useThreadMessages>( query: Query, args: ThreadMessagesArgs | "skip", options: { @@ -154,8 +151,7 @@ export function useThreadMessages< args === "skip" || paginated.status === "LoadingFirstPage" ? "skip" - : // eslint-disable-next-line @typescript-eslint/no-explicit-any - ({ ...args, paginationOpts: { cursor: null, numItems: 0 } } as any), + : ({ ...args, paginationOpts: { cursor: null, numItems: 0 } } as any), { startOrder }, ); @@ -222,10 +218,7 @@ export function useThreadMessages< * you want to pass to the query. * @returns The streaming messages. */ -export function useStreamingThreadMessages< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Query extends StreamQuery, ->( +export function useStreamingThreadMessages>( query: Query, args: | (StreamQueryArgs & { diff --git a/src/react/useUIMessages.ts b/src/react/useUIMessages.ts index 5d038cd2..bba3df3d 100644 --- a/src/react/useUIMessages.ts +++ b/src/react/useUIMessages.ts @@ -122,10 +122,7 @@ export type UIMessagesQueryResult< * The streaming messages are materialized as UIMessages. The rest are passed * through from the query. */ -export function useUIMessages< - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Query extends UIMessagesQuery, ->( +export function useUIMessages>( query: Query, args: UIMessagesQueryArgs | "skip", options: { @@ -153,8 +150,7 @@ export function useUIMessages< args === "skip" || paginated.status === "LoadingFirstPage" ? "skip" - : // eslint-disable-next-line @typescript-eslint/no-explicit-any - ({ ...args, paginationOpts: { cursor: null, numItems: 0 } } as any), + : ({ ...args, paginationOpts: { cursor: null, numItems: 0 } } as any), { startOrder, skipStreamIds: options.skipStreamIds }, ); diff --git a/src/test.ts b/src/test.ts index 87758267..42b8473a 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,3 +1,4 @@ +/// import type { TestConvex } from "convex-test"; import type { GenericSchema, SchemaDefinition } from "convex/server"; import schema from "./component/schema.js"; @@ -8,7 +9,7 @@ const modules = import.meta.glob("./component/**/*.ts"); * @param t - The test convex instance, e.g. from calling `convexTest`. * @param name - The name of the component, as registered in convex.config.ts. */ -function register( +export function register( t: TestConvex>, name: string = "agent", ) { diff --git a/src/validators.test.ts b/src/validators.test.ts index 78b2eac0..f24ee082 100644 --- a/src/validators.test.ts +++ b/src/validators.test.ts @@ -1,10 +1,6 @@ -import type { Infer } from "convex/values"; +import type { GenericId, Infer } from "convex/values"; import { expectTypeOf, test } from "vitest"; -import type { - ContextOptions, - OpaqueIds, - StorageOptions, -} from "./client/types.js"; +import type { ContextOptions, StorageOptions } from "./client/types.js"; import { vContextOptions, vMessageDoc, vStorageOptions } from "./validators.js"; import type { Doc } from "./component/_generated/dataModel.js"; @@ -14,10 +10,21 @@ expectTypeOf().toExtend>(); expectTypeOf>().toExtend(); expectTypeOf().toExtend>(); -type MessageBasedOnSchema = OpaqueIds< +type MessageBasedOnSchema = IdsToStrings< Omit, "files" | "stepId" | "parentMessageId"> >; expectTypeOf>().toEqualTypeOf(); expectTypeOf().toEqualTypeOf>(); test("noop", () => {}); + +type IdsToStrings = + T extends GenericId + ? string + : T extends (infer U)[] + ? IdsToStrings[] + : T extends ArrayBuffer + ? ArrayBuffer + : T extends object + ? { [K in keyof T]: IdsToStrings } + : T; diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 00000000..aff52303 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "example/src/**/*.ts", + "example/src/**/*.tsx", + "example/convex/**/*.ts" + ], + "exclude": ["node_modules", "dist", "**/_generated"] +} diff --git a/src/vitest.config.ts b/vitest.config.js similarity index 66% rename from src/vitest.config.ts rename to vitest.config.js index 28ce6fac..e9408f8b 100644 --- a/src/vitest.config.ts +++ b/vitest.config.js @@ -3,5 +3,8 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { environment: "edge-runtime", + typecheck: { + tsconfig: "./tsconfig.test.json", + }, }, });