content-agent 0.2.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/index.d.ts +500 -52
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +240 -78
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -64,6 +64,44 @@ const model = contentAgent.agent("my-thread", {
|
|
|
64
64
|
});
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## Tools
|
|
68
|
+
|
|
69
|
+
Pass AI SDK tools to `streamText` or `generateText` — tool schemas are forwarded to the agent, and execution happens locally on the client:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { streamText, tool, stepCountIs } from "ai";
|
|
73
|
+
import { z } from "zod";
|
|
74
|
+
|
|
75
|
+
const result = streamText({
|
|
76
|
+
model: contentAgent.agent("my-thread", { application: { key: "my-studio" } }),
|
|
77
|
+
prompt: `Find all blog posts still in draft and submit them for review. Assign them to anna@example.com.`,
|
|
78
|
+
tools: {
|
|
79
|
+
submit_for_review: tool({
|
|
80
|
+
description: `Submit a document for editorial review. The document must be in draft state.`,
|
|
81
|
+
inputSchema: z.object({
|
|
82
|
+
documentId: z.string().describe("The Sanity document _id"),
|
|
83
|
+
email: z.string().email().describe("Assign a specific reviewer"),
|
|
84
|
+
note: z.string().optional().describe("Note for the reviewer"),
|
|
85
|
+
}),
|
|
86
|
+
execute: async ({ documentId, email, note }) => {
|
|
87
|
+
const res = await fetch(
|
|
88
|
+
"https://workflows.internal.example.com/api/review",
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
body: JSON.stringify({ documentId, email, note }),
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const { ticketUrl } = await res.json();
|
|
96
|
+
return { success: true, documentId, ticketUrl };
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The model decides when to call your tools. `stopWhen` controls how many round-trips are allowed between the model and tool execution.
|
|
104
|
+
|
|
67
105
|
## Configuration
|
|
68
106
|
|
|
69
107
|
Pass settings to `.agent()` to configure capabilities:
|