@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.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/dist/stega.d.cts CHANGED
@@ -33,6 +33,18 @@ export declare interface ActionErrorItem {
33
33
  index: number
34
34
  }
35
35
 
36
+ /** @public */
37
+ declare class AiClient {
38
+ #private
39
+ constructor(client: SanityClient, httpRequest: HttpRequest)
40
+ instruct(request: InstructAsyncInstruction): Promise<{
41
+ _id: string
42
+ }>
43
+ instruct<DocumentShape extends Record<string, Any>>(
44
+ request: InstructSyncInstruction<DocumentShape>,
45
+ ): Promise<IdentifiedSanityDocumentStub & DocumentShape>
46
+ }
47
+
36
48
  /** @internal */
37
49
  export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
38
50
  returnFirst: false
@@ -110,117 +122,6 @@ export declare class AssetsClient {
110
122
  ): Promise<SanityAssetDocument | SanityImageAssetDocument>
111
123
  }
112
124
 
113
- /** @beta */
114
- export declare type AssistAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
115
- | ExistingDocumentRequest
116
- | CreateDocumentRequest<T>
117
- ) &
118
- AssistRequestBase &
119
- Async
120
-
121
- /** @public */
122
- declare class AssistClient {
123
- #private
124
- constructor(client: SanityClient, httpRequest: HttpRequest)
125
- instruct(request: AssistAsyncInstruction): Promise<{
126
- _id: string
127
- }>
128
- instruct<DocumentShape extends Record<string, Any>>(
129
- request: AssistSyncInstruction<DocumentShape>,
130
- ): Promise<IdentifiedSanityDocumentStub & DocumentShape>
131
- }
132
-
133
- /** @beta */
134
- export declare type AssistInstruction<T extends Record<string, Any> = Record<string, Any>> =
135
- | AssistSyncInstruction<T>
136
- | AssistAsyncInstruction<T>
137
-
138
- declare interface AssistRequestBase {
139
- /** schemaId as reported by sanity deploy / sanity schema store */
140
- schemaId: string
141
- /** string template using $variable – more on this below under "Dynamic instruction" */
142
- instruction: string
143
- /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
144
- instructionParams?: InstructionParams
145
- /**
146
- * Optional document path output target for the instruction.
147
- * When provided, the instruction will apply to this path in the document and its children.
148
- *
149
- * ## Examples
150
- * - `path: 'title'` will output to the title field in the document
151
- * - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
152
- */
153
- path?: string
154
- /**
155
- * Controls sub-paths in the document that can be output to.
156
- *
157
- * The string-paths are relative to the `path` param
158
- *
159
- * Note: these path strings are less strictly validated than the `path` param itself:
160
- * if an relative-path does not exist or is invalid, it will be silently ignored.
161
- *
162
- * @see AssistRequestBase#conditionalPaths
163
- * @see AssistRequestBase#outputTypes
164
- */
165
- relativeOutputPaths?:
166
- | {
167
- include: string[]
168
- }
169
- | {
170
- exclude: string[]
171
- }
172
- /**
173
- * Controls which types the instruction is allowed to output to.
174
- *
175
- * @see AssistRequestBase#relativeOutputPaths
176
- * @see AssistRequestBase#conditionalPaths
177
- */
178
- outputTypes?:
179
- | {
180
- include: string[]
181
- }
182
- | {
183
- exclude: string[]
184
- }
185
- /**
186
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
187
- *
188
- * By default, AI Assist will not output to conditional `readOnly` and `hidden` fields,
189
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
190
- *
191
- * `conditionalPaths` param allows setting the default conditional value for
192
- * `hidden` and `readOnly` to false,
193
- * or individually set `hidden` and `readOnly` state for individual document paths.
194
- *
195
- *
196
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Assist,
197
- * and cannot be changed via conditionalPaths.
198
- *
199
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
200
- *
201
- * @see AssistRequestBase#relativeOutputPaths
202
- * @see AssistRequestBase#outputTypes
203
- */
204
- conditionalPaths?: {
205
- defaultReadOnly?: boolean
206
- defaultHidden?: boolean
207
- paths?: {
208
- /** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
209
- path: string
210
- readOnly: boolean
211
- hidden: boolean
212
- }[]
213
- }
214
- }
215
-
216
- /** @beta */
217
- export declare type AssistSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
218
- | ExistingDocumentRequest
219
- | CreateDocumentRequest<T>
220
- ) &
221
- AssistRequestBase &
222
- Sync
223
-
224
125
  declare interface Async {
225
126
  /**
226
127
  * When async: true, requests responds with status 201 and {_id} as response body as soon as the request is validated.
@@ -578,12 +479,6 @@ export declare class ConnectionFailedError extends Error {
578
479
  readonly name = 'ConnectionFailedError'
579
480
  }
580
481
 
581
- /** @beta */
582
- export declare interface ConstantInstructionParam {
583
- type: 'constant'
584
- value: string
585
- }
586
-
587
482
  /** @public */
588
483
  export declare interface ContentSourceMap {
589
484
  mappings: ContentSourceMapMappings
@@ -1040,23 +935,6 @@ declare interface ExistingDocumentRequest {
1040
935
  documentId: string
1041
936
  }
1042
937
 
1043
- /**
1044
- *
1045
- * Includes a LLM-friendly version of the field value in the instruction
1046
- * @beta
1047
- * */
1048
- export declare interface FieldInstructionParam {
1049
- type: 'field'
1050
- /**
1051
- * Examples: 'title', 'array[_key=="key"].field
1052
- */
1053
- path: string
1054
- /**
1055
- * If omitted, implicitly uses the documentId of the instruction target
1056
- */
1057
- documentId?: string
1058
- }
1059
-
1060
938
  /** @public */
1061
939
  export declare type FilterDefault = (props: {
1062
940
  /**
@@ -1172,13 +1050,6 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
1172
1050
  returnDocuments?: true
1173
1051
  }
1174
1052
 
1175
- /** @beta */
1176
- export declare interface GroqInstructionParam {
1177
- type: 'groq'
1178
- query: string
1179
- params?: Record<string, string>
1180
- }
1181
-
1182
1053
  /** @public */
1183
1054
  export declare type HttpRequest = {
1184
1055
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1250,15 +1121,143 @@ export declare type InsertPatch =
1250
1121
  }
1251
1122
 
1252
1123
  /** @beta */
1253
- export declare type InstructionParam =
1124
+ export declare type InstructAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> =
1125
+ (ExistingDocumentRequest | CreateDocumentRequest<T>) & InstructRequestBase & Async
1126
+
1127
+ /** @beta */
1128
+ export declare interface InstructConstantInstructionParam {
1129
+ type: 'constant'
1130
+ value: string
1131
+ }
1132
+
1133
+ /**
1134
+ *
1135
+ * Includes a LLM-friendly version of the field value in the instruction
1136
+ * @beta
1137
+ * */
1138
+ export declare interface InstructFieldInstructionParam {
1139
+ type: 'field'
1140
+ /**
1141
+ * Examples: 'title', 'array[_key=="key"].field'
1142
+ */
1143
+ path: string
1144
+ /**
1145
+ * If omitted, implicitly uses the documentId of the instruction target
1146
+ */
1147
+ documentId?: string
1148
+ }
1149
+
1150
+ /**
1151
+ * Includes a LLM-friendly version of GROQ query result in the instruction
1152
+ * @beta
1153
+ * */
1154
+ export declare interface InstructGroqInstructionParam {
1155
+ type: 'groq'
1156
+ query: string
1157
+ params?: Record<string, string>
1158
+ }
1159
+
1160
+ /** @beta */
1161
+ export declare type InstructInstruction<T extends Record<string, Any> = Record<string, Any>> =
1162
+ | InstructSyncInstruction<T>
1163
+ | InstructAsyncInstruction<T>
1164
+
1165
+ /** @beta */
1166
+ export declare type InstructInstructionParam =
1254
1167
  | string
1255
- | ConstantInstructionParam
1256
- | FieldInstructionParam
1168
+ | InstructConstantInstructionParam
1169
+ | InstructFieldInstructionParam
1257
1170
  | DocumentInstructionParam
1258
- | GroqInstructionParam
1171
+ | InstructGroqInstructionParam
1172
+
1173
+ /** @beta */
1174
+ export declare type InstructInstructionParams = Record<string, InstructInstructionParam>
1175
+
1176
+ declare interface InstructRequestBase {
1177
+ /** schemaId as reported by sanity deploy / sanity schema store */
1178
+ schemaId: string
1179
+ /** string template using $variable – more on this below under "Dynamic instruction" */
1180
+ instruction: string
1181
+ /** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
1182
+ instructionParams?: InstructInstructionParams
1183
+ /**
1184
+ * Optional document path output target for the instruction.
1185
+ * When provided, the instruction will apply to this path in the document and its children.
1186
+ *
1187
+ * ## Examples
1188
+ * - `path: 'title'` will output to the title field in the document
1189
+ * - `path: 'array[_key="xx"]'` will output to the item with `_key: 'xx'` in the array field
1190
+ */
1191
+ path?: string
1192
+ /**
1193
+ * Controls sub-paths in the document that can be output to.
1194
+ *
1195
+ * The string-paths are relative to the `path` param
1196
+ *
1197
+ * Note: these path strings are less strictly validated than the `path` param itself:
1198
+ * if an relative-path does not exist or is invalid, it will be silently ignored.
1199
+ *
1200
+ * @see InstructRequestBase#conditionalPaths
1201
+ * @see InstructRequestBase#outputTypes
1202
+ */
1203
+ relativeOutputPaths?:
1204
+ | {
1205
+ include: string[]
1206
+ }
1207
+ | {
1208
+ exclude: string[]
1209
+ }
1210
+ /**
1211
+ * Controls which types the instruction is allowed to output to.
1212
+ *
1213
+ * @see InstructRequestBase#relativeOutputPaths
1214
+ * @see InstructRequestBase#conditionalPaths
1215
+ */
1216
+ outputTypes?:
1217
+ | {
1218
+ include: string[]
1219
+ }
1220
+ | {
1221
+ exclude: string[]
1222
+ }
1223
+ /**
1224
+ * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
1225
+ *
1226
+ * By default, AI Instruct will not output to conditional `readOnly` and `hidden` fields,
1227
+ * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
1228
+ *
1229
+ * `conditionalPaths` param allows setting the default conditional value for
1230
+ * `hidden` and `readOnly` to false,
1231
+ * or individually set `hidden` and `readOnly` state for individual document paths.
1232
+ *
1233
+ *
1234
+ * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Instruct,
1235
+ * and cannot be changed via conditionalPaths.
1236
+ *
1237
+ * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
1238
+ *
1239
+ * @see InstructRequestBase#relativeOutputPaths
1240
+ * @see InstructRequestBase#outputTypes
1241
+ */
1242
+ conditionalPaths?: {
1243
+ defaultReadOnly?: boolean
1244
+ defaultHidden?: boolean
1245
+ paths?: {
1246
+ /** path here is not a relative path: it must be the full document path, regardless of `path` param on the request itself */
1247
+ path: string
1248
+ readOnly: boolean
1249
+ hidden: boolean
1250
+ }[]
1251
+ }
1252
+ }
1259
1253
 
1260
1254
  /** @beta */
1261
- export declare type InstructionParams = Record<string, InstructionParam>
1255
+ export declare type InstructSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1256
+ | ExistingDocumentRequest
1257
+ | CreateDocumentRequest<T>
1258
+ ) &
1259
+ InstructRequestBase &
1260
+ Sync
1262
1261
 
1263
1262
  /**
1264
1263
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
@@ -1627,6 +1626,18 @@ export declare type MutationSelectionQueryParams = {
1627
1626
  [key: string]: Any
1628
1627
  }
1629
1628
 
1629
+ /** @public */
1630
+ declare class ObservableAiClient {
1631
+ #private
1632
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1633
+ instruct(request: InstructAsyncInstruction): Observable<{
1634
+ _id: string
1635
+ }>
1636
+ instruct<DocumentShape extends Record<string, Any>>(
1637
+ request: InstructSyncInstruction<DocumentShape>,
1638
+ ): Observable<IdentifiedSanityDocumentStub & DocumentShape>
1639
+ }
1640
+
1630
1641
  /** @internal */
1631
1642
  export declare class ObservableAssetsClient {
1632
1643
  #private
@@ -1681,18 +1692,6 @@ export declare class ObservableAssetsClient {
1681
1692
  >
1682
1693
  }
1683
1694
 
1684
- /** @public */
1685
- declare class ObservableAssistClient {
1686
- #private
1687
- constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
1688
- instruct(request: AssistAsyncInstruction): Observable<{
1689
- _id: string
1690
- }>
1691
- instruct<DocumentShape extends Record<string, Any>>(
1692
- request: AssistSyncInstruction<DocumentShape>,
1693
- ): Observable<IdentifiedSanityDocumentStub & DocumentShape>
1694
- }
1695
-
1696
1695
  /** @internal */
1697
1696
  export declare class ObservableDatasetsClient {
1698
1697
  #private
@@ -1816,7 +1815,7 @@ export declare class ObservableSanityClient {
1816
1815
  live: LiveClient
1817
1816
  projects: ObservableProjectsClient
1818
1817
  users: ObservableUsersClient
1819
- assist: ObservableAssistClient
1818
+ ai: ObservableAiClient
1820
1819
  /**
1821
1820
  * Instance properties
1822
1821
  */
@@ -2748,7 +2747,7 @@ export declare class SanityClient {
2748
2747
  live: LiveClient
2749
2748
  projects: ProjectsClient
2750
2749
  users: UsersClient
2751
- assist: AssistClient
2750
+ ai: AiClient
2752
2751
  /**
2753
2752
  * Observable version of the Sanity client, with the same configuration as the promise-based one
2754
2753
  */