content-agent 1.1.0 → 1.2.0
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/dist/_chunks-dts/sanity-agent-provider.d.ts +2 -793
- package/dist/_chunks-dts/sanity-agent-provider.d.ts.map +1 -1
- package/dist/_chunks-dts/types.d.ts +794 -0
- package/dist/_chunks-dts/types.d.ts.map +1 -0
- package/dist/_chunks-es/utils.js +310 -0
- package/dist/_chunks-es/utils.js.map +1 -0
- package/dist/chat-transport.d.ts +90 -0
- package/dist/chat-transport.d.ts.map +1 -0
- package/dist/chat-transport.js +91 -0
- package/dist/chat-transport.js.map +1 -0
- package/dist/content-agent.d.ts +2 -1
- package/dist/content-agent.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -291
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +106 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +79 -0
- package/dist/messages.js.map +1 -0
- package/dist/react.d.ts +110 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +84 -0
- package/dist/react.js.map +1 -0
- package/package.json +25 -2
|
@@ -1,796 +1,5 @@
|
|
|
1
|
+
import { _ as GenerateSettings, d as ContentAgentProviderSettings, g as GenerateResult, m as GenerateOptions, n as Application, t as AgentSettings } from "./types.js";
|
|
1
2
|
import { LanguageModelV3 } from "@ai-sdk/provider";
|
|
2
|
-
/**
|
|
3
|
-
* This file was auto-generated by openapi-typescript.
|
|
4
|
-
* Do not make direct changes to the file.
|
|
5
|
-
*/
|
|
6
|
-
type paths = {
|
|
7
|
-
'/{organizationId}/threads/{threadId}': {
|
|
8
|
-
parameters: {
|
|
9
|
-
query?: never;
|
|
10
|
-
header?: never;
|
|
11
|
-
path?: never;
|
|
12
|
-
cookie?: never;
|
|
13
|
-
};
|
|
14
|
-
get?: never;
|
|
15
|
-
put?: never;
|
|
16
|
-
/**
|
|
17
|
-
* Send a chat message
|
|
18
|
-
* @description Send a message to the agent and receive a streaming response.
|
|
19
|
-
* This endpoint manages conversation threads and persists message history.
|
|
20
|
-
*/
|
|
21
|
-
post: operations['chat'];
|
|
22
|
-
delete?: never;
|
|
23
|
-
options?: never;
|
|
24
|
-
head?: never;
|
|
25
|
-
patch?: never;
|
|
26
|
-
trace?: never;
|
|
27
|
-
};
|
|
28
|
-
'/prompt': {
|
|
29
|
-
parameters: {
|
|
30
|
-
query?: never;
|
|
31
|
-
header?: never;
|
|
32
|
-
path?: never;
|
|
33
|
-
cookie?: never;
|
|
34
|
-
};
|
|
35
|
-
get?: never;
|
|
36
|
-
put?: never;
|
|
37
|
-
/**
|
|
38
|
-
* Send a one-shot prompt
|
|
39
|
-
* @description Stateless one-shot prompt endpoint. No thread management or message persistence.
|
|
40
|
-
* Ideal for simple, single-turn interactions.
|
|
41
|
-
*/
|
|
42
|
-
post: operations['prompt'];
|
|
43
|
-
delete?: never;
|
|
44
|
-
options?: never;
|
|
45
|
-
head?: never;
|
|
46
|
-
patch?: never;
|
|
47
|
-
trace?: never;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
type components = {
|
|
51
|
-
schemas: {
|
|
52
|
-
ChatRequest: {
|
|
53
|
-
/** @description Array of message objects */messages: components['schemas']['Message'][];
|
|
54
|
-
application?: components['schemas']['Application'];
|
|
55
|
-
config?: components['schemas']['Config'];
|
|
56
|
-
/**
|
|
57
|
-
* @description Enable or disable streaming responses
|
|
58
|
-
* @default true
|
|
59
|
-
*/
|
|
60
|
-
stream: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* @description Controls how directives in the response are formatted.
|
|
63
|
-
* - markdown (default): Directives are resolved server-side into standard markdown (e.g., links with titles).
|
|
64
|
-
* - directives: Raw directive syntax is preserved (e.g., `::document{id="doc-id"}`), useful for clients that render custom UI components.
|
|
65
|
-
* @default markdown
|
|
66
|
-
* @enum {string}
|
|
67
|
-
*/
|
|
68
|
-
format: 'markdown' | 'directives';
|
|
69
|
-
};
|
|
70
|
-
PromptRequest: {
|
|
71
|
-
/**
|
|
72
|
-
* @description Your Sanity organization ID
|
|
73
|
-
* @example abc123
|
|
74
|
-
*/
|
|
75
|
-
organizationId: string;
|
|
76
|
-
/**
|
|
77
|
-
* @description The prompt message
|
|
78
|
-
* @example Summarize my latest blog posts
|
|
79
|
-
*/
|
|
80
|
-
message: string;
|
|
81
|
-
config?: components['schemas']['Config'];
|
|
82
|
-
/**
|
|
83
|
-
* @description Custom instructions for the agent
|
|
84
|
-
* @example Be concise and use bullet points
|
|
85
|
-
*/
|
|
86
|
-
instructions?: string;
|
|
87
|
-
/**
|
|
88
|
-
* @description Controls how directives in the response are formatted.
|
|
89
|
-
* - markdown (default): Directives are resolved server-side into standard markdown.
|
|
90
|
-
* - directives: Raw directive syntax is preserved for clients that render custom UI.
|
|
91
|
-
* @default markdown
|
|
92
|
-
* @enum {string}
|
|
93
|
-
*/
|
|
94
|
-
format: 'markdown' | 'directives';
|
|
95
|
-
};
|
|
96
|
-
Message: {
|
|
97
|
-
/**
|
|
98
|
-
* @description The role of the message sender
|
|
99
|
-
* @enum {string}
|
|
100
|
-
*/
|
|
101
|
-
role: 'user' | 'assistant' | 'system'; /** @description The message content */
|
|
102
|
-
content: string; /** @description Optional unique identifier for the message */
|
|
103
|
-
id?: string; /** @description Optional name for the message sender */
|
|
104
|
-
name?: string;
|
|
105
|
-
}; /** @description Target Sanity application configuration */
|
|
106
|
-
Application: {
|
|
107
|
-
/**
|
|
108
|
-
* @description Application key in format "projectId.datasetName"
|
|
109
|
-
* @example abc123.production
|
|
110
|
-
*/
|
|
111
|
-
key?: string;
|
|
112
|
-
resource?: {
|
|
113
|
-
/**
|
|
114
|
-
* @description Resource ID in format "projectId.datasetName"
|
|
115
|
-
* @example abc123.production
|
|
116
|
-
*/
|
|
117
|
-
id?: string;
|
|
118
|
-
/**
|
|
119
|
-
* @description Resource type
|
|
120
|
-
* @enum {string}
|
|
121
|
-
*/
|
|
122
|
-
type?: 'dataset';
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Format: uri
|
|
126
|
-
* @description Base URL for the Sanity Studio
|
|
127
|
-
* @example https://your-studio.sanity.studio
|
|
128
|
-
*/
|
|
129
|
-
intentBaseUrl?: string; /** @description Bundle version */
|
|
130
|
-
bundleVersion?: string; /** @description Application name */
|
|
131
|
-
name?: string; /** @description Application title */
|
|
132
|
-
title?: string; /** @description Schema descriptor ID */
|
|
133
|
-
schemaDescriptorId?: string;
|
|
134
|
-
}; /** @description Agent configuration. Controls behavior, capabilities, and document access. */
|
|
135
|
-
Config: {
|
|
136
|
-
/**
|
|
137
|
-
* @description Custom instruction string to include in the system prompt
|
|
138
|
-
* @example You are a helpful content assistant.
|
|
139
|
-
*/
|
|
140
|
-
instruction?: string;
|
|
141
|
-
/**
|
|
142
|
-
* @description Key-value pairs appended to each user message as XML tags.
|
|
143
|
-
* Each key becomes an XML tag with the value as content.
|
|
144
|
-
* Example: { "slack-channel": "#marketing" } renders as <slack-channel>#marketing</slack-channel>
|
|
145
|
-
* @example {
|
|
146
|
-
* "slack-channel": "#marketing",
|
|
147
|
-
* "user-role": "editor"
|
|
148
|
-
* }
|
|
149
|
-
*/
|
|
150
|
-
userMessageContext?: {
|
|
151
|
-
[key: string]: string;
|
|
152
|
-
};
|
|
153
|
-
capabilities?: components['schemas']['Capabilities'];
|
|
154
|
-
filter?: components['schemas']['Filter'];
|
|
155
|
-
perspectives?: components['schemas']['Perspectives'];
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* @description Agent capabilities that control what operations are allowed.
|
|
159
|
-
* Each capability can be a boolean or an object with a preset.
|
|
160
|
-
* @example {
|
|
161
|
-
* "read": true,
|
|
162
|
-
* "write": false
|
|
163
|
-
* }
|
|
164
|
-
*/
|
|
165
|
-
Capabilities: {
|
|
166
|
-
read?: components['schemas']['Capability'];
|
|
167
|
-
write?: components['schemas']['Capability'];
|
|
168
|
-
features?: components['schemas']['FeatureOverrides'];
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* @description Explicit feature overrides applied on top of capability-derived defaults.
|
|
172
|
-
* When not specified, features use values derived from read/write capability presets.
|
|
173
|
-
*/
|
|
174
|
-
FeatureOverrides: {
|
|
175
|
-
/**
|
|
176
|
-
* @description Override web search availability.
|
|
177
|
-
* By default, web search is enabled when read capability is 'standard'.
|
|
178
|
-
*/
|
|
179
|
-
webSearch?: boolean;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* @description A capability can be:
|
|
183
|
-
* - true: Full access (standard preset)
|
|
184
|
-
* - false: No access
|
|
185
|
-
* - { preset: 'minimal' | 'standard' }: Explicit preset selection
|
|
186
|
-
*/
|
|
187
|
-
Capability: boolean | components['schemas']['CapabilityPreset'];
|
|
188
|
-
CapabilityPreset: {
|
|
189
|
-
/**
|
|
190
|
-
* @description For read capability:
|
|
191
|
-
* - minimal: Basic queries only (no bulk document analysis)
|
|
192
|
-
* - standard: All read tools including bulk analysis
|
|
193
|
-
*
|
|
194
|
-
* For write capability:
|
|
195
|
-
* - minimal: Basic mutations only (no bulk mutations)
|
|
196
|
-
* - standard: All write tools including bulk mutations
|
|
197
|
-
* @enum {string}
|
|
198
|
-
*/
|
|
199
|
-
preset: 'minimal' | 'standard';
|
|
200
|
-
}; /** @description GROQ filter expressions for document access control */
|
|
201
|
-
Filter: {
|
|
202
|
-
/**
|
|
203
|
-
* @description GROQ boolean expression for document visibility.
|
|
204
|
-
* Documents matching this filter are visible to the agent.
|
|
205
|
-
* @example _type in ['post', 'author']
|
|
206
|
-
*/
|
|
207
|
-
read?: string;
|
|
208
|
-
/**
|
|
209
|
-
* @description GROQ boolean expression for mutation permissions.
|
|
210
|
-
* Documents matching this filter can be mutated.
|
|
211
|
-
* @example _type == 'post'
|
|
212
|
-
*/
|
|
213
|
-
write?: string;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* @description Perspective locking configuration.
|
|
217
|
-
* Controls which document perspectives the agent can read from and write to.
|
|
218
|
-
* Values are Sanity perspective IDs: 'drafts', 'published', 'raw', or release/bundle IDs.
|
|
219
|
-
*/
|
|
220
|
-
Perspectives: {
|
|
221
|
-
/**
|
|
222
|
-
* @description Allowed read perspectives. When set, query tools can only use these perspectives.
|
|
223
|
-
* If the agent tries to use a disallowed perspective, the request is rejected with an error.
|
|
224
|
-
* @example [
|
|
225
|
-
* "drafts",
|
|
226
|
-
* "published"
|
|
227
|
-
* ]
|
|
228
|
-
*/
|
|
229
|
-
read?: string[];
|
|
230
|
-
/**
|
|
231
|
-
* @description The write perspective. When set, new documents are created in this perspective
|
|
232
|
-
* and mutations are restricted to documents whose ID matches it.
|
|
233
|
-
* @example drafts
|
|
234
|
-
*/
|
|
235
|
-
write?: string;
|
|
236
|
-
}; /** @description JSON response when streaming is disabled */
|
|
237
|
-
ChatResponse: {
|
|
238
|
-
/** @description The agent's response text */text?: string; /** @description The application key used for this conversation */
|
|
239
|
-
applicationKey?: string;
|
|
240
|
-
};
|
|
241
|
-
ErrorResponse: {
|
|
242
|
-
/**
|
|
243
|
-
* @description Error type
|
|
244
|
-
* @example Invalid request
|
|
245
|
-
*/
|
|
246
|
-
error: string;
|
|
247
|
-
/**
|
|
248
|
-
* @description Human-readable error description
|
|
249
|
-
* @example Request body validation failed
|
|
250
|
-
*/
|
|
251
|
-
details?: string; /** @description Validation issues (when applicable) */
|
|
252
|
-
issues?: components['schemas']['ValidationIssue'][];
|
|
253
|
-
};
|
|
254
|
-
ValidationIssue: {
|
|
255
|
-
/**
|
|
256
|
-
* @description Error code
|
|
257
|
-
* @example invalid_type
|
|
258
|
-
*/
|
|
259
|
-
code?: string;
|
|
260
|
-
/**
|
|
261
|
-
* @description Path to the invalid field
|
|
262
|
-
* @example [
|
|
263
|
-
* "messages"
|
|
264
|
-
* ]
|
|
265
|
-
*/
|
|
266
|
-
path?: string[];
|
|
267
|
-
/**
|
|
268
|
-
* @description Error message
|
|
269
|
-
* @example Required
|
|
270
|
-
*/
|
|
271
|
-
message?: string;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
responses: {
|
|
275
|
-
/** @description Bad Request - Request validation failed */BadRequest: {
|
|
276
|
-
headers: {
|
|
277
|
-
[name: string]: unknown;
|
|
278
|
-
};
|
|
279
|
-
content: {
|
|
280
|
-
/**
|
|
281
|
-
* @example {
|
|
282
|
-
* "error": "Invalid request",
|
|
283
|
-
* "details": "Request body validation failed",
|
|
284
|
-
* "issues": [
|
|
285
|
-
* {
|
|
286
|
-
* "code": "invalid_type",
|
|
287
|
-
* "path": [
|
|
288
|
-
* "messages"
|
|
289
|
-
* ],
|
|
290
|
-
* "message": "Required"
|
|
291
|
-
* }
|
|
292
|
-
* ]
|
|
293
|
-
* }
|
|
294
|
-
*/
|
|
295
|
-
'application/json': components['schemas']['ErrorResponse'];
|
|
296
|
-
};
|
|
297
|
-
}; /** @description Unauthorized - Missing or invalid authentication token */
|
|
298
|
-
Unauthorized: {
|
|
299
|
-
headers: {
|
|
300
|
-
[name: string]: unknown;
|
|
301
|
-
};
|
|
302
|
-
content: {
|
|
303
|
-
/**
|
|
304
|
-
* @example {
|
|
305
|
-
* "error": "Unauthorized",
|
|
306
|
-
* "details": "Missing authorization token"
|
|
307
|
-
* }
|
|
308
|
-
*/
|
|
309
|
-
'application/json': components['schemas']['ErrorResponse'];
|
|
310
|
-
};
|
|
311
|
-
}; /** @description Internal Server Error */
|
|
312
|
-
InternalServerError: {
|
|
313
|
-
headers: {
|
|
314
|
-
[name: string]: unknown;
|
|
315
|
-
};
|
|
316
|
-
content: {
|
|
317
|
-
/**
|
|
318
|
-
* @example {
|
|
319
|
-
* "error": "Internal Server Error",
|
|
320
|
-
* "details": "An unexpected error occurred"
|
|
321
|
-
* }
|
|
322
|
-
*/
|
|
323
|
-
'application/json': components['schemas']['ErrorResponse'];
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
};
|
|
327
|
-
parameters: never;
|
|
328
|
-
requestBodies: never;
|
|
329
|
-
headers: never;
|
|
330
|
-
pathItems: never;
|
|
331
|
-
};
|
|
332
|
-
interface operations {
|
|
333
|
-
chat: {
|
|
334
|
-
parameters: {
|
|
335
|
-
query?: never;
|
|
336
|
-
header?: never;
|
|
337
|
-
path: {
|
|
338
|
-
/**
|
|
339
|
-
* @description Your Sanity organization ID
|
|
340
|
-
* @example abc123
|
|
341
|
-
*/
|
|
342
|
-
organizationId: string;
|
|
343
|
-
/**
|
|
344
|
-
* @description Unique identifier for the conversation thread
|
|
345
|
-
* @example my-conversation-thread
|
|
346
|
-
*/
|
|
347
|
-
threadId: string;
|
|
348
|
-
};
|
|
349
|
-
cookie?: never;
|
|
350
|
-
};
|
|
351
|
-
requestBody: {
|
|
352
|
-
content: {
|
|
353
|
-
'application/json': components['schemas']['ChatRequest'];
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
responses: {
|
|
357
|
-
/** @description Streaming response */200: {
|
|
358
|
-
headers: {
|
|
359
|
-
'Content-Type'?: string;
|
|
360
|
-
'X-Vercel-AI-Data-Stream'?: string;
|
|
361
|
-
[name: string]: unknown;
|
|
362
|
-
};
|
|
363
|
-
content: {
|
|
364
|
-
'text/event-stream': string; /** @description JSON response when stream is false */
|
|
365
|
-
'application/json': components['schemas']['ChatResponse'];
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
400: components['responses']['BadRequest'];
|
|
369
|
-
401: components['responses']['Unauthorized'];
|
|
370
|
-
500: components['responses']['InternalServerError'];
|
|
371
|
-
};
|
|
372
|
-
};
|
|
373
|
-
prompt: {
|
|
374
|
-
parameters: {
|
|
375
|
-
query?: never;
|
|
376
|
-
header?: never;
|
|
377
|
-
path?: never;
|
|
378
|
-
cookie?: never;
|
|
379
|
-
};
|
|
380
|
-
requestBody: {
|
|
381
|
-
content: {
|
|
382
|
-
'application/json': components['schemas']['PromptRequest'];
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
responses: {
|
|
386
|
-
/** @description Streaming response */200: {
|
|
387
|
-
headers: {
|
|
388
|
-
'Content-Type'?: string;
|
|
389
|
-
'X-Vercel-AI-Data-Stream'?: string;
|
|
390
|
-
[name: string]: unknown;
|
|
391
|
-
};
|
|
392
|
-
content: {
|
|
393
|
-
'text/event-stream': string;
|
|
394
|
-
};
|
|
395
|
-
};
|
|
396
|
-
400: components['responses']['BadRequest'];
|
|
397
|
-
401: components['responses']['Unauthorized'];
|
|
398
|
-
500: components['responses']['InternalServerError'];
|
|
399
|
-
};
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Request body for the conversation thread endpoint (`POST /{organizationId}/threads/{threadId}`).
|
|
404
|
-
* @category API Types
|
|
405
|
-
*/
|
|
406
|
-
type ChatRequest = components['schemas']['ChatRequest'];
|
|
407
|
-
/**
|
|
408
|
-
* Request body for the one-shot prompt endpoint (`POST /prompt`).
|
|
409
|
-
* @category API Types
|
|
410
|
-
*/
|
|
411
|
-
type GenerateRequest = components['schemas']['PromptRequest'];
|
|
412
|
-
/**
|
|
413
|
-
* Controls how directives in the response are formatted (`'markdown'` or `'directives'`).
|
|
414
|
-
* @category Configuration
|
|
415
|
-
*/
|
|
416
|
-
type OutputFormat = ChatRequest['format'];
|
|
417
|
-
/**
|
|
418
|
-
* Response from the conversation thread endpoint when `stream: false`.
|
|
419
|
-
* @category API Types
|
|
420
|
-
*/
|
|
421
|
-
type ChatResponse = components['schemas']['ChatResponse'];
|
|
422
|
-
/**
|
|
423
|
-
* Error response body returned by the API on failure.
|
|
424
|
-
* @category API Types
|
|
425
|
-
*/
|
|
426
|
-
type ErrorResponse = components['schemas']['ErrorResponse'];
|
|
427
|
-
/**
|
|
428
|
-
* Individual validation issue within an {@link ErrorResponse}.
|
|
429
|
-
* @category API Types
|
|
430
|
-
*/
|
|
431
|
-
type ValidationIssue = components['schemas']['ValidationIssue'];
|
|
432
|
-
/**
|
|
433
|
-
* A message in a conversation (user, assistant, or system).
|
|
434
|
-
* @category API Types
|
|
435
|
-
*/
|
|
436
|
-
type Message = components['schemas']['Message'];
|
|
437
|
-
/**
|
|
438
|
-
* The role of a {@link Message}: `'user'`, `'assistant'`, or `'system'`.
|
|
439
|
-
* @category API Types
|
|
440
|
-
*/
|
|
441
|
-
type MessageRole = Message['role'];
|
|
442
|
-
/**
|
|
443
|
-
* Specifies which Sanity project and dataset the agent should work with.
|
|
444
|
-
*
|
|
445
|
-
* @category Configuration
|
|
446
|
-
*
|
|
447
|
-
* @example
|
|
448
|
-
* ```ts
|
|
449
|
-
* const application = {
|
|
450
|
-
* key: 'project-id.dataset-name',
|
|
451
|
-
* }
|
|
452
|
-
* ```
|
|
453
|
-
*/
|
|
454
|
-
type Application = components['schemas']['Application'];
|
|
455
|
-
/**
|
|
456
|
-
* Resource within an {@link Application}.
|
|
457
|
-
* @category Configuration
|
|
458
|
-
*/
|
|
459
|
-
type ApplicationResource = NonNullable<Application['resource']>;
|
|
460
|
-
/**
|
|
461
|
-
* Agent configuration for controlling behavior, capabilities, and document access.
|
|
462
|
-
*
|
|
463
|
-
* @category Configuration
|
|
464
|
-
*
|
|
465
|
-
* @example Read-only with custom instruction and user message context
|
|
466
|
-
* ```ts
|
|
467
|
-
* const config = {
|
|
468
|
-
* instruction: 'You are a Slack bot helping users manage content.',
|
|
469
|
-
* userMessageContext: {
|
|
470
|
-
* 'slack-channel': '#content-team',
|
|
471
|
-
* 'slack-user': '@john.doe',
|
|
472
|
-
* },
|
|
473
|
-
* capabilities: {
|
|
474
|
-
* read: true,
|
|
475
|
-
* write: false,
|
|
476
|
-
* },
|
|
477
|
-
* }
|
|
478
|
-
* ```
|
|
479
|
-
*
|
|
480
|
-
* @example Read-only document explorer with type filtering
|
|
481
|
-
* ```ts
|
|
482
|
-
* const config = {
|
|
483
|
-
* capabilities: {
|
|
484
|
-
* read: { preset: 'standard' },
|
|
485
|
-
* write: false,
|
|
486
|
-
* },
|
|
487
|
-
* filter: {
|
|
488
|
-
* read: '_type in ["post", "author", "page"]',
|
|
489
|
-
* },
|
|
490
|
-
* }
|
|
491
|
-
* ```
|
|
492
|
-
*/
|
|
493
|
-
type Config = components['schemas']['Config'];
|
|
494
|
-
/**
|
|
495
|
-
* Controls what operations the agent can perform.
|
|
496
|
-
*
|
|
497
|
-
* Each capability (`read`, `write`) can be:
|
|
498
|
-
* - `true` — Full access (standard preset)
|
|
499
|
-
* - `false` — No access
|
|
500
|
-
* - `{ preset: 'minimal' }` — Basic tools only
|
|
501
|
-
* - `{ preset: 'standard' }` — All tools available
|
|
502
|
-
*
|
|
503
|
-
* Use `features` to override individual feature toggles independently of presets.
|
|
504
|
-
*
|
|
505
|
-
* @example Read-only access
|
|
506
|
-
* ```ts
|
|
507
|
-
* const capabilities = { read: true, write: false }
|
|
508
|
-
* ```
|
|
509
|
-
*
|
|
510
|
-
* @example Full read, minimal write
|
|
511
|
-
* ```ts
|
|
512
|
-
* const capabilities = {
|
|
513
|
-
* read: true,
|
|
514
|
-
* write: { preset: 'minimal' },
|
|
515
|
-
* }
|
|
516
|
-
* ```
|
|
517
|
-
*
|
|
518
|
-
* @example Standard read with web search disabled
|
|
519
|
-
* ```ts
|
|
520
|
-
* const capabilities = {
|
|
521
|
-
* read: true,
|
|
522
|
-
* write: false,
|
|
523
|
-
* features: { webSearch: false },
|
|
524
|
-
* }
|
|
525
|
-
* ```
|
|
526
|
-
*
|
|
527
|
-
* @category Configuration
|
|
528
|
-
*/
|
|
529
|
-
type Capabilities = components['schemas']['Capabilities'];
|
|
530
|
-
/**
|
|
531
|
-
* A single capability value: `true`, `false`, or a {@link CapabilityPreset}.
|
|
532
|
-
* @category Configuration
|
|
533
|
-
*/
|
|
534
|
-
type Capability = components['schemas']['Capability'];
|
|
535
|
-
/**
|
|
536
|
-
* A capability preset object, e.g. `{ preset: 'minimal' }` or `{ preset: 'standard' }`.
|
|
537
|
-
* @category Configuration
|
|
538
|
-
*/
|
|
539
|
-
type CapabilityPreset = components['schemas']['CapabilityPreset'];
|
|
540
|
-
/**
|
|
541
|
-
* The preset level string: `'minimal'` or `'standard'`.
|
|
542
|
-
* @category Configuration
|
|
543
|
-
*/
|
|
544
|
-
type CapabilityPresetValue = CapabilityPreset['preset'];
|
|
545
|
-
/**
|
|
546
|
-
* GROQ boolean expressions to control document visibility and mutation permissions.
|
|
547
|
-
*
|
|
548
|
-
* @category Configuration
|
|
549
|
-
*
|
|
550
|
-
* @example
|
|
551
|
-
* ```ts
|
|
552
|
-
* const filter = {
|
|
553
|
-
* read: '_type in ["post", "author", "category"]',
|
|
554
|
-
* write: '_type == "post"',
|
|
555
|
-
* }
|
|
556
|
-
* ```
|
|
557
|
-
*/
|
|
558
|
-
type Filter = components['schemas']['Filter'];
|
|
559
|
-
/**
|
|
560
|
-
* Key-value pairs appended to each user message as XML tags.
|
|
561
|
-
*
|
|
562
|
-
* @category Configuration
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```ts
|
|
566
|
-
* const userMessageContext = {
|
|
567
|
-
* 'slack-channel': '#marketing',
|
|
568
|
-
* 'user-role': 'editor',
|
|
569
|
-
* }
|
|
570
|
-
* // Renders in the user message as:
|
|
571
|
-
* // <slack-channel>#marketing</slack-channel>
|
|
572
|
-
* // <user-role>editor</user-role>
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
type UserMessageContext = NonNullable<Config['userMessageContext']>;
|
|
576
|
-
/**
|
|
577
|
-
* Settings for creating a Content Agent provider instance via {@link createContentAgent}.
|
|
578
|
-
*
|
|
579
|
-
* @category Provider
|
|
580
|
-
*
|
|
581
|
-
* @example
|
|
582
|
-
* ```ts
|
|
583
|
-
* import { createContentAgent } from 'content-agent'
|
|
584
|
-
*
|
|
585
|
-
* const contentAgent = createContentAgent({
|
|
586
|
-
* organizationId: 'your-org-id',
|
|
587
|
-
* token: 'your-sanity-token',
|
|
588
|
-
* // Optional overrides:
|
|
589
|
-
* // baseURL: 'https://api.sanity.io',
|
|
590
|
-
* // apiVersion: 'v2026-01-01',
|
|
591
|
-
* })
|
|
592
|
-
* ```
|
|
593
|
-
*/
|
|
594
|
-
interface ContentAgentProviderSettings {
|
|
595
|
-
/**
|
|
596
|
-
* Your Sanity organization ID.
|
|
597
|
-
*
|
|
598
|
-
* When using {@link createStudioAgent}, this is fetched automatically
|
|
599
|
-
* from the project metadata.
|
|
600
|
-
*/
|
|
601
|
-
organizationId: string;
|
|
602
|
-
/**
|
|
603
|
-
* Default application for all agent and prompt calls.
|
|
604
|
-
*
|
|
605
|
-
* When set, this application is used unless overridden per-call via
|
|
606
|
-
* {@link AgentSettings.application} or {@link GenerateSettings.application}.
|
|
607
|
-
*
|
|
608
|
-
* Typically set automatically by {@link createStudioAgent}.
|
|
609
|
-
*/
|
|
610
|
-
application?: Application;
|
|
611
|
-
/**
|
|
612
|
-
* Base URL for the Sanity API.
|
|
613
|
-
* @default 'https://api.sanity.io'
|
|
614
|
-
*/
|
|
615
|
-
baseURL?: string;
|
|
616
|
-
/**
|
|
617
|
-
* API version to use for requests.
|
|
618
|
-
* Should be in format 'vYYYY-MM-DD' (e.g., 'v2026-01-01').
|
|
619
|
-
* @default 'v2026-01-01'
|
|
620
|
-
*/
|
|
621
|
-
apiVersion?: string;
|
|
622
|
-
/**
|
|
623
|
-
* Authentication token for the Sanity API.
|
|
624
|
-
* If not provided, requests will be made without authentication
|
|
625
|
-
* (useful for browser contexts where auth may come from cookies).
|
|
626
|
-
*/
|
|
627
|
-
token?: string;
|
|
628
|
-
/**
|
|
629
|
-
* Custom headers to include in requests.
|
|
630
|
-
*/
|
|
631
|
-
headers?: Record<string, string>;
|
|
632
|
-
/**
|
|
633
|
-
* Custom fetch implementation.
|
|
634
|
-
* Useful for testing or adding middleware.
|
|
635
|
-
*/
|
|
636
|
-
fetch?: typeof globalThis.fetch;
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Base settings shared between agent and generate requests.
|
|
640
|
-
*
|
|
641
|
-
* @example Read-only agent with document type filtering
|
|
642
|
-
* ```ts
|
|
643
|
-
* const settings = {
|
|
644
|
-
* application: { key: 'projectId.datasetName' },
|
|
645
|
-
* config: {
|
|
646
|
-
* instruction: 'You are a helpful content assistant for our blog.',
|
|
647
|
-
* capabilities: {
|
|
648
|
-
* read: true,
|
|
649
|
-
* write: false,
|
|
650
|
-
* },
|
|
651
|
-
* filter: {
|
|
652
|
-
* read: '_type in ["post", "author", "category"]',
|
|
653
|
-
* },
|
|
654
|
-
* },
|
|
655
|
-
* }
|
|
656
|
-
* ```
|
|
657
|
-
*
|
|
658
|
-
* @example Read/write agent with perspective locking
|
|
659
|
-
* ```ts
|
|
660
|
-
* const settings = {
|
|
661
|
-
* application: { key: 'projectId.datasetName' },
|
|
662
|
-
* config: {
|
|
663
|
-
* capabilities: {
|
|
664
|
-
* read: true,
|
|
665
|
-
* write: { preset: 'minimal' },
|
|
666
|
-
* },
|
|
667
|
-
* filter: {
|
|
668
|
-
* read: '_type in ["post", "author", "category"]',
|
|
669
|
-
* write: '_type == "post"',
|
|
670
|
-
* },
|
|
671
|
-
* perspectives: {
|
|
672
|
-
* read: ['drafts', 'published'],
|
|
673
|
-
* write: 'drafts',
|
|
674
|
-
* },
|
|
675
|
-
* },
|
|
676
|
-
* }
|
|
677
|
-
* ```
|
|
678
|
-
*/
|
|
679
|
-
interface BaseAgentSettings {
|
|
680
|
-
/**
|
|
681
|
-
* Target Sanity application configuration.
|
|
682
|
-
*/
|
|
683
|
-
application?: Application;
|
|
684
|
-
/**
|
|
685
|
-
* Agent configuration for controlling behavior, capabilities, and document access.
|
|
686
|
-
*/
|
|
687
|
-
config?: Config;
|
|
688
|
-
/**
|
|
689
|
-
* Controls how directives in the response are formatted.
|
|
690
|
-
* - `markdown` (default): Directives are resolved server-side into standard markdown.
|
|
691
|
-
* - `directives`: Raw directive syntax is preserved for clients that render custom UI.
|
|
692
|
-
* @default 'markdown'
|
|
693
|
-
*/
|
|
694
|
-
format?: OutputFormat;
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Settings for creating an agent instance (per-thread).
|
|
698
|
-
*
|
|
699
|
-
* Passed as the second argument to {@link ContentAgentProvider.agent | contentAgent.agent(threadId, settings)}.
|
|
700
|
-
*
|
|
701
|
-
* @example
|
|
702
|
-
* ```ts
|
|
703
|
-
* const model = contentAgent.agent('my-thread-id', {
|
|
704
|
-
* application: { key: 'projectId.datasetName' },
|
|
705
|
-
* config: {
|
|
706
|
-
* capabilities: { read: true, write: false },
|
|
707
|
-
* },
|
|
708
|
-
* })
|
|
709
|
-
* ```
|
|
710
|
-
*
|
|
711
|
-
* @category Configuration
|
|
712
|
-
*/
|
|
713
|
-
interface AgentSettings extends BaseAgentSettings {
|
|
714
|
-
/**
|
|
715
|
-
* Identifies the client that created the thread (e.g. `'slack'`, `'linear'`, `'dashboard'`).
|
|
716
|
-
*
|
|
717
|
-
* Stored in thread metadata and used by the dashboard to filter its thread list.
|
|
718
|
-
* When omitted, the server assigns a default value.
|
|
719
|
-
*/
|
|
720
|
-
clientId?: string;
|
|
721
|
-
/**
|
|
722
|
-
* Called when a custom `data-*` SSE part arrives during streaming.
|
|
723
|
-
*
|
|
724
|
-
* @param type - The data part type with the `data-` prefix stripped (e.g. `'agent-status'`).
|
|
725
|
-
* @param data - The parsed payload.
|
|
726
|
-
*/
|
|
727
|
-
onStreamData?: (type: string, data: unknown) => void;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Settings for one-shot generation requests via {@link ContentAgentProvider.prompt | contentAgent.prompt()}.
|
|
731
|
-
*
|
|
732
|
-
* Extends {@link BaseAgentSettings} with an additional `instructions` field
|
|
733
|
-
* for providing custom system-level instructions.
|
|
734
|
-
*
|
|
735
|
-
* @example
|
|
736
|
-
* ```ts
|
|
737
|
-
* const { text } = await contentAgent.prompt(
|
|
738
|
-
* {
|
|
739
|
-
* application: { key: 'projectId.datasetName' },
|
|
740
|
-
* config: { capabilities: { read: true, write: false } },
|
|
741
|
-
* instructions: 'Be concise',
|
|
742
|
-
* },
|
|
743
|
-
* { message: 'List my 5 most recent posts' },
|
|
744
|
-
* )
|
|
745
|
-
* ```
|
|
746
|
-
*
|
|
747
|
-
* @category Configuration
|
|
748
|
-
*/
|
|
749
|
-
interface GenerateSettings extends BaseAgentSettings {
|
|
750
|
-
/**
|
|
751
|
-
* Custom instructions for the agent.
|
|
752
|
-
*/
|
|
753
|
-
instructions?: string;
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Options for a one-shot generation request via {@link ContentAgentProvider.prompt | contentAgent.prompt()}.
|
|
757
|
-
*
|
|
758
|
-
* @category Configuration
|
|
759
|
-
*
|
|
760
|
-
* @example
|
|
761
|
-
* ```ts
|
|
762
|
-
* const { text } = await contentAgent.prompt(
|
|
763
|
-
* { instructions: 'Be concise' },
|
|
764
|
-
* { message: 'List all authors in my dataset' },
|
|
765
|
-
* )
|
|
766
|
-
* ```
|
|
767
|
-
*/
|
|
768
|
-
interface GenerateOptions {
|
|
769
|
-
/**
|
|
770
|
-
* The prompt message to send.
|
|
771
|
-
*/
|
|
772
|
-
message: string;
|
|
773
|
-
/**
|
|
774
|
-
* Enable streaming response.
|
|
775
|
-
* @default false
|
|
776
|
-
*/
|
|
777
|
-
stream?: boolean;
|
|
778
|
-
/**
|
|
779
|
-
* Signal to abort the request.
|
|
780
|
-
*/
|
|
781
|
-
abortSignal?: AbortSignal;
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Result from a one-shot generation request via {@link ContentAgentProvider.prompt | contentAgent.prompt()}.
|
|
785
|
-
*
|
|
786
|
-
* @category Configuration
|
|
787
|
-
*/
|
|
788
|
-
interface GenerateResult {
|
|
789
|
-
/**
|
|
790
|
-
* The generated text response.
|
|
791
|
-
*/
|
|
792
|
-
text: string;
|
|
793
|
-
}
|
|
794
3
|
/**
|
|
795
4
|
* Narrow client interface — only needs `config()`.
|
|
796
5
|
* Used by {@link resolveApplication} which doesn't need URL generation.
|
|
@@ -973,5 +182,5 @@ interface ContentAgentProvider {
|
|
|
973
182
|
* @param options - Provider configuration including organization ID, token, and optional overrides.
|
|
974
183
|
*/
|
|
975
184
|
declare function createContentAgent(options: ContentAgentProviderSettings): ContentAgentProvider;
|
|
976
|
-
export {
|
|
185
|
+
export { SanityClientLike as a, SanityClientConfig as i, createContentAgent as n, fromClient as o, ClientDerivedConfig as r, getBaseUrl as s, ContentAgentProvider as t };
|
|
977
186
|
//# sourceMappingURL=sanity-agent-provider.d.ts.map
|