Skip to content

Commit 0c49bee

Browse files
committed
update docs for asTextAction
1 parent c1acd37 commit 0c49bee

File tree

9 files changed

+63
-2643
lines changed

9 files changed

+63
-2643
lines changed

docs/agent-usage.mdx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ Note that the action doesn't need to return anything. All messages are saved by
172172
default, so any client subscribed to the thread messages will receive the new
173173
message as it is generated asynchronously.
174174

175-
The Step 2 code is common enough that there's a utility to save you some typing.
176-
It takes in some parameters to control streaming, etc. For more details, see
177-
[the code](../src/client/index.ts#L1475-L1557).
178-
179-
```ts
180-
// Equivalent to Step 2 above.
181-
export const generateResponseAsync = agent.asTextAction();
182-
```
183-
184175
### Generating an object
185176

186177
Similar to the AI SDK, you can generate or stream an object. The same arguments

example/.gitignore

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/convex/_generated/api.d.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ import type {
5454
FunctionReference,
5555
} from "convex/server";
5656

57-
/**
58-
* A utility for referencing Convex functions in your app's API.
59-
*
60-
* Usage:
61-
* ```js
62-
* const myFunctionReference = api.myModule.myFunction;
63-
* ```
64-
*/
6557
declare const fullApi: ApiFromModules<{
6658
"agents/config": typeof agents_config;
6759
"agents/fashion": typeof agents_fashion;
@@ -103,14 +95,30 @@ declare const fullApi: ApiFromModules<{
10395
utils: typeof utils;
10496
"workflows/chaining": typeof workflows_chaining;
10597
}>;
106-
declare const fullApiWithMounts: typeof fullApi;
10798

99+
/**
100+
* A utility for referencing Convex functions in your app's public API.
101+
*
102+
* Usage:
103+
* ```js
104+
* const myFunctionReference = api.myModule.myFunction;
105+
* ```
106+
*/
108107
export declare const api: FilterApi<
109-
typeof fullApiWithMounts,
108+
typeof fullApi,
110109
FunctionReference<any, "public">
111110
>;
111+
112+
/**
113+
* A utility for referencing Convex functions in your app's internal API.
114+
*
115+
* Usage:
116+
* ```js
117+
* const myFunctionReference = internal.myModule.myFunction;
118+
* ```
119+
*/
112120
export declare const internal: FilterApi<
113-
typeof fullApiWithMounts,
121+
typeof fullApi,
114122
FunctionReference<any, "internal">
115123
>;
116124

@@ -2984,7 +2992,7 @@ export declare const components: {
29842992
| { kind: "success"; returnValue: any }
29852993
| { error: string; kind: "failed" }
29862994
| { kind: "canceled" };
2987-
workflowId: string;
2995+
workflowId?: string;
29882996
workpoolOptions?: {
29892997
defaultRetryBehavior?: {
29902998
base: number;

example/convex/chat/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const generateResponse = internalAction({
5353
});
5454

5555
// Equivalent:
56-
// export const generateResponse = agent.asTextAction();
56+
export const generateResponseEquivalent = agent.asTextAction({});
5757

5858
/**
5959
* Query & subscribe to messages & threads

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"@radix-ui/react-slot": "1.2.3",
102102
"@radix-ui/react-toast": "1.2.15",
103103
"@tailwindcss/typography": "0.5.19",
104-
"@types/node": "20.19.24",
104+
"@types/node": "^22.18.13",
105105
"@types/react": "19.2.2",
106106
"@types/react-dom": "19.2.2",
107107
"@vitejs/plugin-react": "4.7.0",
@@ -141,7 +141,7 @@
141141
"typescript": "5.9.3",
142142
"typescript-eslint": "8.46.2",
143143
"vite": "6.4.1",
144-
"vitest": "3.2.4",
144+
"vitest": "^3.2.4",
145145
"zod": "3.25.76"
146146
},
147147
"main": "./dist/client/index.js",

src/client/types.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import type {
3434
WithoutSystemFields,
3535
} from "convex/server";
3636
import type { GenericId } from "convex/values";
37-
import type { api } from "../component/_generated/api.js";
3837
import type {
3938
MessageDoc,
4039
ProviderMetadata,
@@ -43,6 +42,7 @@ import type {
4342
ThreadDoc,
4443
} from "../validators.js";
4544
import type { StreamingOptions } from "./streaming.js";
45+
import type { ComponentApi } from "../component/_generated/component.js";
4646

4747
export type AgentPrompt = {
4848
/**
@@ -331,7 +331,7 @@ export type RawRequestResponseHandler = (
331331
},
332332
) => void | Promise<void>;
333333

334-
export type AgentComponent = UseApi<typeof api>;
334+
export type AgentComponent = ComponentApi;
335335

336336
export type TextArgs<
337337
AgentTools extends ToolSet,
@@ -642,32 +642,3 @@ export type ActionCtx = MutationCtx & {
642642
storage: StorageActionWriter;
643643
};
644644
export type QueryCtx = RunQueryCtx & { storage: StorageReader };
645-
646-
export type OpaqueIds<T> =
647-
T extends GenericId<infer _T>
648-
? string
649-
: T extends (infer U)[]
650-
? OpaqueIds<U>[]
651-
: T extends ArrayBuffer
652-
? ArrayBuffer
653-
: T extends object
654-
? { [K in keyof T]: OpaqueIds<T[K]> }
655-
: T;
656-
657-
export type UseApi<API> = Expand<{
658-
[mod in keyof API]: API[mod] extends FunctionReference<
659-
infer FType,
660-
"public",
661-
infer FArgs,
662-
infer FReturnType,
663-
infer FComponentPath
664-
>
665-
? FunctionReference<
666-
FType,
667-
"internal",
668-
OpaqueIds<FArgs>,
669-
OpaqueIds<FReturnType>,
670-
FComponentPath
671-
>
672-
: UseApi<API[mod]>;
673-
}>;

0 commit comments

Comments
 (0)