@sanity/blueprints 0.31.0 → 0.33.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/README.md +2 -0
- package/dist/definers/agents.d.ts +43 -0
- package/dist/definers/agents.js +55 -0
- package/dist/definers/agents.js.map +1 -0
- package/dist/definers/context.d.ts +2 -4
- package/dist/definers/context.js +2 -4
- package/dist/definers/context.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types/agents.d.ts +53 -0
- package/dist/types/agents.js +2 -0
- package/dist/types/agents.js.map +1 -0
- package/dist/types/applications.d.ts +5 -0
- package/dist/types/context.d.ts +7 -14
- package/dist/types/studios.d.ts +18 -0
- package/dist/utils/validation.d.ts +12 -0
- package/dist/utils/validation.js +19 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/agents.d.ts +12 -0
- package/dist/validation/agents.js +143 -0
- package/dist/validation/agents.js.map +1 -0
- package/dist/validation/applications.js +11 -0
- package/dist/validation/applications.js.map +1 -1
- package/dist/validation/context.d.ts +0 -4
- package/dist/validation/context.js +0 -4
- package/dist/validation/context.js.map +1 -1
- package/dist/validation/studios.js +70 -1
- package/dist/validation/studios.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/agents.ts +58 -0
- package/src/definers/context.ts +2 -4
- package/src/index.ts +3 -0
- package/src/types/agents.ts +56 -0
- package/src/types/applications.ts +6 -0
- package/src/types/context.ts +7 -14
- package/src/types/studios.ts +20 -0
- package/src/utils/validation.ts +21 -0
- package/src/validation/agents.ts +149 -0
- package/src/validation/applications.ts +10 -0
- package/src/validation/context.ts +0 -4
- package/src/validation/studios.ts +77 -1
package/README.md
CHANGED
|
@@ -73,6 +73,8 @@ export default defineBlueprint({
|
|
|
73
73
|
| `defineDocumentFunction` | Function triggered by document events |
|
|
74
74
|
| `defineMediaLibraryAssetFunction` | Function triggered by media library events |
|
|
75
75
|
| `defineContentResource` β | Content resource as in the Manage UI, made from document types and a filter |
|
|
76
|
+
| `defineContextKnowledgeBase` β | Context knowledge base that agents draw on |
|
|
77
|
+
| `defineContextMcpEndpoint` β | Context MCP endpoint that serves knowledge bases and a dataset to agents |
|
|
76
78
|
| `defineCorsOrigin` β | CORS origin allowing browser requests to your project |
|
|
77
79
|
| `defineDocumentWebhook` β | Webhook triggered by document changes |
|
|
78
80
|
| `definePermission` β | Custom permission that roles can grant, in the Access API shape |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type BlueprintAgentConfig, type BlueprintAgentResource } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an Agent to be managed in a Blueprint.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `model` is required; its `apiKey` is passed by reference and resolved at blueprint-eval time.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* defineAgent({
|
|
11
|
+
* name: 'demo-agent',
|
|
12
|
+
* region: 'virginia',
|
|
13
|
+
* model: {
|
|
14
|
+
* provider: 'openrouter',
|
|
15
|
+
* id: 'anthropic/claude-haiku-4.5',
|
|
16
|
+
* apiKey: process.env.OPEN_ROUTER_KEY,
|
|
17
|
+
* },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example All options
|
|
22
|
+
* ```ts
|
|
23
|
+
* defineAgent({
|
|
24
|
+
* name: 'demo-agent',
|
|
25
|
+
* description: 'end-to-end blueprints demo agent',
|
|
26
|
+
* region: 'virginia',
|
|
27
|
+
* src: 'agents/demo-agent',
|
|
28
|
+
* model: {
|
|
29
|
+
* provider: 'openrouter',
|
|
30
|
+
* id: 'anthropic/claude-haiku-4.5',
|
|
31
|
+
* baseURL: 'https://openrouter.ai/api/v1',
|
|
32
|
+
* apiKey: process.env.OPEN_ROUTER_KEY,
|
|
33
|
+
* },
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
* @param config The agent configuration
|
|
37
|
+
* @alpha Deploying Agents via Blueprints is experimental. This feature is subject to breaking changes.
|
|
38
|
+
* @hidden
|
|
39
|
+
* @category Definers
|
|
40
|
+
* @expandType BlueprintAgentConfig
|
|
41
|
+
* @returns The agent resource
|
|
42
|
+
*/
|
|
43
|
+
export declare function defineAgent(config: BlueprintAgentConfig): BlueprintAgentResource;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { validateAgent } from '../index.js';
|
|
2
|
+
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Defines an Agent to be managed in a Blueprint.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* `model` is required; its `apiKey` is passed by reference and resolved at blueprint-eval time.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* defineAgent({
|
|
12
|
+
* name: 'demo-agent',
|
|
13
|
+
* region: 'virginia',
|
|
14
|
+
* model: {
|
|
15
|
+
* provider: 'openrouter',
|
|
16
|
+
* id: 'anthropic/claude-haiku-4.5',
|
|
17
|
+
* apiKey: process.env.OPEN_ROUTER_KEY,
|
|
18
|
+
* },
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example All options
|
|
23
|
+
* ```ts
|
|
24
|
+
* defineAgent({
|
|
25
|
+
* name: 'demo-agent',
|
|
26
|
+
* description: 'end-to-end blueprints demo agent',
|
|
27
|
+
* region: 'virginia',
|
|
28
|
+
* src: 'agents/demo-agent',
|
|
29
|
+
* model: {
|
|
30
|
+
* provider: 'openrouter',
|
|
31
|
+
* id: 'anthropic/claude-haiku-4.5',
|
|
32
|
+
* baseURL: 'https://openrouter.ai/api/v1',
|
|
33
|
+
* apiKey: process.env.OPEN_ROUTER_KEY,
|
|
34
|
+
* },
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
* @param config The agent configuration
|
|
38
|
+
* @alpha Deploying Agents via Blueprints is experimental. This feature is subject to breaking changes.
|
|
39
|
+
* @hidden
|
|
40
|
+
* @category Definers
|
|
41
|
+
* @expandType BlueprintAgentConfig
|
|
42
|
+
* @returns The agent resource
|
|
43
|
+
*/
|
|
44
|
+
export function defineAgent(config) {
|
|
45
|
+
const { name, src, ...rest } = config;
|
|
46
|
+
const agentResource = {
|
|
47
|
+
...rest,
|
|
48
|
+
name,
|
|
49
|
+
type: 'sanity.agent',
|
|
50
|
+
src: src ?? `agents/${name}`,
|
|
51
|
+
};
|
|
52
|
+
runValidation(() => validateAgent(agentResource));
|
|
53
|
+
return agentResource;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/definers/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAC,MAAM,aAAa,CAAA;AACjG,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,WAAW,CAAC,MAA4B;IACtD,MAAM,EAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAC,GAAG,MAAM,CAAA;IAEnC,MAAM,aAAa,GAA2B;QAC5C,GAAG,IAAI;QACP,IAAI;QACJ,IAAI,EAAE,cAAc;QACpB,GAAG,EAAE,GAAG,IAAI,UAAU,IAAI,EAAE;KAC7B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAA;IAEjD,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
|
@@ -32,8 +32,7 @@ import { type BlueprintContextKnowledgeBaseConfig, type BlueprintContextKnowledg
|
|
|
32
32
|
* ```
|
|
33
33
|
* @param parameters The knowledge base configuration
|
|
34
34
|
* @public
|
|
35
|
-
* @
|
|
36
|
-
* @hidden
|
|
35
|
+
* @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
37
36
|
* @category Definers
|
|
38
37
|
* @expandType BlueprintContextKnowledgeBaseConfig
|
|
39
38
|
* @returns The knowledge base resource
|
|
@@ -81,8 +80,7 @@ export declare function defineContextKnowledgeBase(parameters: BlueprintContextK
|
|
|
81
80
|
* ```
|
|
82
81
|
* @param parameters The MCP endpoint configuration
|
|
83
82
|
* @public
|
|
84
|
-
* @
|
|
85
|
-
* @hidden
|
|
83
|
+
* @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
86
84
|
* @category Definers
|
|
87
85
|
* @expandType BlueprintContextMcpEndpointConfig
|
|
88
86
|
* @returns The MCP endpoint resource
|
package/dist/definers/context.js
CHANGED
|
@@ -33,8 +33,7 @@ import { runValidation } from '../utils/validation.js';
|
|
|
33
33
|
* ```
|
|
34
34
|
* @param parameters The knowledge base configuration
|
|
35
35
|
* @public
|
|
36
|
-
* @
|
|
37
|
-
* @hidden
|
|
36
|
+
* @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
38
37
|
* @category Definers
|
|
39
38
|
* @expandType BlueprintContextKnowledgeBaseConfig
|
|
40
39
|
* @returns The knowledge base resource
|
|
@@ -89,8 +88,7 @@ export function defineContextKnowledgeBase(parameters) {
|
|
|
89
88
|
* ```
|
|
90
89
|
* @param parameters The MCP endpoint configuration
|
|
91
90
|
* @public
|
|
92
|
-
* @
|
|
93
|
-
* @hidden
|
|
91
|
+
* @beta Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
94
92
|
* @category Definers
|
|
95
93
|
* @expandType BlueprintContextMcpEndpointConfig
|
|
96
94
|
* @returns The MCP endpoint resource
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/definers/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,4BAA4B,EAC5B,0BAA0B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CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @categoryDescription Referencers
|
|
7
7
|
* These functions are used to reference resources in another Blueprint.
|
|
8
8
|
*/
|
|
9
|
+
export * from './definers/agents.js';
|
|
9
10
|
export * from './definers/applications.js';
|
|
10
11
|
export * from './definers/blueprints.js';
|
|
11
12
|
export * from './definers/context.js';
|
|
@@ -36,6 +37,7 @@ export * from './definers/webhooks.js';
|
|
|
36
37
|
* @categoryDescription Functions Types
|
|
37
38
|
* Resource types for functions in a Blueprint.
|
|
38
39
|
*/
|
|
40
|
+
export * from './types/agents.js';
|
|
39
41
|
export * from './types/applications.js';
|
|
40
42
|
export * from './types/blueprints.js';
|
|
41
43
|
export * from './types/context.js';
|
|
@@ -56,6 +58,7 @@ export * from './types/webhooks.js';
|
|
|
56
58
|
* @categoryDescription Validation
|
|
57
59
|
* These functions are used to validate resources in a Blueprint.
|
|
58
60
|
*/
|
|
61
|
+
export * from './validation/agents.js';
|
|
59
62
|
export * from './validation/applications.js';
|
|
60
63
|
export * from './validation/blueprints.js';
|
|
61
64
|
export * from './validation/context.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @categoryDescription Referencers
|
|
8
8
|
* These functions are used to reference resources in another Blueprint.
|
|
9
9
|
*/
|
|
10
|
+
export * from './definers/agents.js';
|
|
10
11
|
export * from './definers/applications.js';
|
|
11
12
|
export * from './definers/blueprints.js';
|
|
12
13
|
export * from './definers/context.js';
|
|
@@ -38,6 +39,7 @@ export * from './definers/webhooks.js';
|
|
|
38
39
|
* @categoryDescription Functions Types
|
|
39
40
|
* Resource types for functions in a Blueprint.
|
|
40
41
|
*/
|
|
42
|
+
export * from './types/agents.js';
|
|
41
43
|
export * from './types/applications.js';
|
|
42
44
|
export * from './types/blueprints.js';
|
|
43
45
|
export * from './types/context.js';
|
|
@@ -59,6 +61,7 @@ export * from './types/webhooks.js';
|
|
|
59
61
|
* @categoryDescription Validation
|
|
60
62
|
* These functions are used to validate resources in a Blueprint.
|
|
61
63
|
*/
|
|
64
|
+
export * from './validation/agents.js';
|
|
62
65
|
export * from './validation/applications.js';
|
|
63
66
|
export * from './validation/blueprints.js';
|
|
64
67
|
export * from './validation/context.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AACH;;;GAGG;AACH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kCAAkC,CAAA;AAChD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uCAAuC,CAAA;AACrD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mCAAmC,CAAA;AACjD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AAEtC,uCAAuC;AACvC;;;GAGG;AACH;;;GAGG;AACH,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC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AAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AAEtC,uCAAuC;AACvC;;;GAGG;AACH;;;GAGG;AACH,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AAEnC,4CAA4C;AAC5C;;;GAGG;AACH,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AAExC,yEAAyE;AACzE;;;GAGG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The model value carried on a {@link BlueprintAgentResource}.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `provider`, `id`, and `baseURL` are non-secret and ride on the resource literally; `apiKey` is passed by reference and resolved at blueprint-eval time.
|
|
7
|
+
* @alpha This feature is subject to breaking changes.
|
|
8
|
+
* @hidden
|
|
9
|
+
* @category Resource Types
|
|
10
|
+
*/
|
|
11
|
+
export interface BlueprintAgentModel {
|
|
12
|
+
/** Model provider, e.g. `openrouter`. */
|
|
13
|
+
provider: string;
|
|
14
|
+
/** Model identifier, e.g. `anthropic/claude-haiku-4.5`. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Optional base URL override. */
|
|
17
|
+
baseURL?: string;
|
|
18
|
+
/** Secret model API key, passed by reference at eval time; presence-checked only. */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents an Agent resource.
|
|
23
|
+
* @alpha This feature is subject to breaking changes.
|
|
24
|
+
* @hidden
|
|
25
|
+
* @category Resource Types
|
|
26
|
+
*/
|
|
27
|
+
export interface BlueprintAgentResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
28
|
+
type: 'sanity.agent';
|
|
29
|
+
/** Agent name slug, max 63 characters. */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Agent description. */
|
|
32
|
+
description?: string;
|
|
33
|
+
/** Deploy region, one of the allowlisted cities. */
|
|
34
|
+
region: string;
|
|
35
|
+
/** The model the agent uses to serve a turn. */
|
|
36
|
+
model: BlueprintAgentModel;
|
|
37
|
+
/** Author-time source path; rewritten to an `AS-...` asset id before deploy. */
|
|
38
|
+
src: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for an Agent resource.
|
|
42
|
+
* @alpha This feature is subject to breaking changes.
|
|
43
|
+
* @hidden
|
|
44
|
+
* @category Resource Types
|
|
45
|
+
* @interface
|
|
46
|
+
*/
|
|
47
|
+
export type BlueprintAgentConfig = Omit<BlueprintAgentResource, 'type' | 'src'> & {
|
|
48
|
+
/**
|
|
49
|
+
* Source path for the authored agent package.
|
|
50
|
+
* @defaultValue `agents/${name}`
|
|
51
|
+
*/
|
|
52
|
+
src?: string;
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/types/agents.ts"],"names":[],"mappings":""}
|
|
@@ -186,6 +186,11 @@ export interface BlueprintApplicationResource extends BlueprintResource {
|
|
|
186
186
|
views?: BlueprintApplicationView[];
|
|
187
187
|
/** The background web workers the application runs. */
|
|
188
188
|
webWorkers?: BlueprintWebWorker[];
|
|
189
|
+
/** Auto update settings for the application. Off when omitted. */
|
|
190
|
+
autoUpdates?: {
|
|
191
|
+
/** Whether auto updates are enabled for the application */
|
|
192
|
+
enabled: boolean;
|
|
193
|
+
};
|
|
189
194
|
/** Module federation manifest */
|
|
190
195
|
mfManifest?: Record<string, unknown>;
|
|
191
196
|
}
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* A knowledge base that a Context MCP endpoint serves.
|
|
4
|
-
* @
|
|
5
|
-
* @hidden
|
|
4
|
+
* @beta This feature is subject to breaking changes.
|
|
6
5
|
* @category Resource Types
|
|
7
6
|
*/
|
|
8
7
|
export interface ContextKnowledgeBaseSource {
|
|
@@ -12,8 +11,7 @@ export interface ContextKnowledgeBaseSource {
|
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* A Sanity dataset that a Context MCP endpoint serves.
|
|
15
|
-
* @
|
|
16
|
-
* @hidden
|
|
14
|
+
* @beta This feature is subject to breaking changes.
|
|
17
15
|
* @category Resource Types
|
|
18
16
|
*/
|
|
19
17
|
export interface ContextDatasetSource {
|
|
@@ -32,15 +30,13 @@ export interface ContextDatasetSource {
|
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* Content that a Context MCP endpoint serves.
|
|
35
|
-
* @
|
|
36
|
-
* @hidden
|
|
33
|
+
* @beta This feature is subject to breaking changes.
|
|
37
34
|
* @category Resource Types
|
|
38
35
|
*/
|
|
39
36
|
export type ContextMcpEndpointSource = ContextKnowledgeBaseSource | ContextDatasetSource;
|
|
40
37
|
/**
|
|
41
38
|
* A Context knowledge base resource.
|
|
42
|
-
* @
|
|
43
|
-
* @hidden
|
|
39
|
+
* @beta This feature is subject to breaking changes.
|
|
44
40
|
* @category Resource Types
|
|
45
41
|
*/
|
|
46
42
|
export interface BlueprintContextKnowledgeBaseResource extends BlueprintResource {
|
|
@@ -57,16 +53,14 @@ export interface BlueprintContextKnowledgeBaseResource extends BlueprintResource
|
|
|
57
53
|
}
|
|
58
54
|
/**
|
|
59
55
|
* Configuration for a Context knowledge base.
|
|
60
|
-
* @
|
|
61
|
-
* @hidden
|
|
56
|
+
* @beta This feature is subject to breaking changes.
|
|
62
57
|
* @category Resource Types
|
|
63
58
|
* @interface
|
|
64
59
|
*/
|
|
65
60
|
export type BlueprintContextKnowledgeBaseConfig = Omit<BlueprintContextKnowledgeBaseResource, 'type'>;
|
|
66
61
|
/**
|
|
67
62
|
* A Context MCP endpoint resource.
|
|
68
|
-
* @
|
|
69
|
-
* @hidden
|
|
63
|
+
* @beta This feature is subject to breaking changes.
|
|
70
64
|
* @category Resource Types
|
|
71
65
|
*/
|
|
72
66
|
export interface BlueprintContextMcpEndpointResource extends BlueprintResource {
|
|
@@ -88,8 +82,7 @@ export interface BlueprintContextMcpEndpointResource extends BlueprintResource {
|
|
|
88
82
|
}
|
|
89
83
|
/**
|
|
90
84
|
* Configuration for a Context MCP endpoint.
|
|
91
|
-
* @
|
|
92
|
-
* @hidden
|
|
85
|
+
* @beta This feature is subject to breaking changes.
|
|
93
86
|
* @category Resource Types
|
|
94
87
|
* @interface
|
|
95
88
|
*/
|
package/dist/types/studios.d.ts
CHANGED
|
@@ -23,6 +23,22 @@ export declare const APPLICATION_VISIBILITIES: readonly ['default', 'unlisted',
|
|
|
23
23
|
* @hidden
|
|
24
24
|
*/
|
|
25
25
|
export type ApplicationVisibility = (typeof APPLICATION_VISIBILITIES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* A workspace definition extracted from a studio's configuration during the build.
|
|
28
|
+
* @beta This feature is subject to breaking changes.
|
|
29
|
+
* @category Resource Types
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
export type StudioWorkspace = {
|
|
33
|
+
projectId: string;
|
|
34
|
+
dataset: string;
|
|
35
|
+
schemaDescriptorId: string;
|
|
36
|
+
name: string;
|
|
37
|
+
title: string | undefined;
|
|
38
|
+
subtitle: string | undefined;
|
|
39
|
+
basePath: string | undefined;
|
|
40
|
+
icon: string | undefined;
|
|
41
|
+
};
|
|
26
42
|
/**
|
|
27
43
|
* Represents a Studio resource.
|
|
28
44
|
* @see https://www.sanity.io/docs/studio
|
|
@@ -72,6 +88,8 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
72
88
|
vite?: UserViteConfig;
|
|
73
89
|
/** Schema inputs extracted from the studio's schema definition. */
|
|
74
90
|
schemaInputs?: WorkspaceSchemaInput[];
|
|
91
|
+
/** Workspaces extracted from the studio's configuration. */
|
|
92
|
+
workspaces?: StudioWorkspace[];
|
|
75
93
|
/** Module federation manifest */
|
|
76
94
|
mfManifest?: Record<string, unknown>;
|
|
77
95
|
}
|
|
@@ -28,3 +28,15 @@ export declare function resetCollectedErrors(): void;
|
|
|
28
28
|
* @internal
|
|
29
29
|
*/
|
|
30
30
|
export declare function isReference(value: unknown): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Validates a string field on an object, optionally requiring it to be present and non-empty.
|
|
33
|
+
* @param obj The object containing the field
|
|
34
|
+
* @param field The field name
|
|
35
|
+
* @param label The label used as the prefix of error messages
|
|
36
|
+
* @param options Whether the field is required
|
|
37
|
+
* @returns A list of validation errors
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateStringField(obj: object, field: string, label: string, options: {
|
|
41
|
+
required: boolean;
|
|
42
|
+
}): BlueprintError[];
|
package/dist/utils/validation.js
CHANGED
|
@@ -40,4 +40,23 @@ const REFERENCE_PREFIXES = ['$.resources.', '$.values.', '$.parameters.', '$.par
|
|
|
40
40
|
export function isReference(value) {
|
|
41
41
|
return typeof value === 'string' && REFERENCE_PREFIXES.some((prefix) => value.startsWith(prefix));
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Validates a string field on an object, optionally requiring it to be present and non-empty.
|
|
45
|
+
* @param obj The object containing the field
|
|
46
|
+
* @param field The field name
|
|
47
|
+
* @param label The label used as the prefix of error messages
|
|
48
|
+
* @param options Whether the field is required
|
|
49
|
+
* @returns A list of validation errors
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export function validateStringField(obj, field, label, options) {
|
|
53
|
+
const value = Reflect.get(obj, field);
|
|
54
|
+
if (typeof value === 'undefined' || (options.required && !value)) {
|
|
55
|
+
return options.required ? [{ type: 'missing_parameter', message: `${label}.${field} is required` }] : [];
|
|
56
|
+
}
|
|
57
|
+
if (typeof value !== 'string') {
|
|
58
|
+
return [{ type: 'invalid_type', message: `${label}.${field} must be a string` }];
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
43
62
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAqB,EAAE,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiC,EAAE,OAAgC;IAC/F,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,IAAI,OAAO,EAAE,UAAU,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAA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
|
1
|
+
import type { BlueprintError } from '../types/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that the given resource is a valid Agent.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Validates the `name` slug, optional `description`, the `region` allowlist, and the `model` shape; `model.apiKey` is presence-checked only.
|
|
7
|
+
* @param resource The Agent resource
|
|
8
|
+
* @hidden
|
|
9
|
+
* @category Validation
|
|
10
|
+
* @returns A list of validation errors
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateAgent(resource: unknown): BlueprintError[];
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** Slug pattern an agent `name` must match. */
|
|
2
|
+
const AGENT_NAME_SLUG = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
|
|
3
|
+
/** Maximum length of an agent `name`. */
|
|
4
|
+
const AGENT_NAME_MAX_LENGTH = 63;
|
|
5
|
+
/** Maximum length of an agent `description`. */
|
|
6
|
+
const AGENT_DESCRIPTION_MAX_LENGTH = 255;
|
|
7
|
+
/** Allowlisted deploy regions (cities). */
|
|
8
|
+
const AGENT_REGIONS = [
|
|
9
|
+
'virginia',
|
|
10
|
+
'ohio',
|
|
11
|
+
'california',
|
|
12
|
+
'portland',
|
|
13
|
+
'montreal',
|
|
14
|
+
'calgary',
|
|
15
|
+
'ireland',
|
|
16
|
+
'london',
|
|
17
|
+
'paris',
|
|
18
|
+
'frankfurt',
|
|
19
|
+
'zurich',
|
|
20
|
+
'stockholm',
|
|
21
|
+
'milan',
|
|
22
|
+
'spain',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Validates that the given resource is a valid Agent.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Validates the `name` slug, optional `description`, the `region` allowlist, and the `model` shape; `model.apiKey` is presence-checked only.
|
|
29
|
+
* @param resource The Agent resource
|
|
30
|
+
* @hidden
|
|
31
|
+
* @category Validation
|
|
32
|
+
* @returns A list of validation errors
|
|
33
|
+
*/
|
|
34
|
+
export function validateAgent(resource) {
|
|
35
|
+
if (!resource)
|
|
36
|
+
return [{ type: 'invalid_value', message: 'Agent config must be provided' }];
|
|
37
|
+
if (typeof resource !== 'object')
|
|
38
|
+
return [{ type: 'invalid_type', message: 'Agent config must be an object' }];
|
|
39
|
+
const errors = [];
|
|
40
|
+
if ('type' in resource && resource.type !== 'sanity.agent') {
|
|
41
|
+
errors.push({ type: 'invalid_value', message: 'Agent type must be `sanity.agent`' });
|
|
42
|
+
}
|
|
43
|
+
if (!('name' in resource)) {
|
|
44
|
+
errors.push({ type: 'missing_parameter', message: '`name` is required' });
|
|
45
|
+
}
|
|
46
|
+
else if (typeof resource.name !== 'string') {
|
|
47
|
+
errors.push({ type: 'invalid_type', message: '`name` must be a string' });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
if (resource.name.length > AGENT_NAME_MAX_LENGTH) {
|
|
51
|
+
errors.push({ type: 'invalid_value', message: `\`name\` must be at most ${AGENT_NAME_MAX_LENGTH} characters` });
|
|
52
|
+
}
|
|
53
|
+
if (!AGENT_NAME_SLUG.test(resource.name)) {
|
|
54
|
+
errors.push({ type: 'invalid_format', message: '`name` must match the slug pattern `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`' });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if ('description' in resource && typeof resource.description !== 'undefined') {
|
|
58
|
+
if (typeof resource.description !== 'string') {
|
|
59
|
+
errors.push({ type: 'invalid_type', message: '`description` must be a string' });
|
|
60
|
+
}
|
|
61
|
+
else if (resource.description.length > AGENT_DESCRIPTION_MAX_LENGTH) {
|
|
62
|
+
errors.push({ type: 'invalid_value', message: `\`description\` must be at most ${AGENT_DESCRIPTION_MAX_LENGTH} characters` });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!('region' in resource)) {
|
|
66
|
+
errors.push({ type: 'missing_parameter', message: '`region` is required' });
|
|
67
|
+
}
|
|
68
|
+
else if (typeof resource.region !== 'string') {
|
|
69
|
+
errors.push({ type: 'invalid_type', message: '`region` must be a string' });
|
|
70
|
+
}
|
|
71
|
+
else if (!AGENT_REGIONS.includes(resource.region)) {
|
|
72
|
+
errors.push({ type: 'invalid_value', message: `\`region\` must be one of ${AGENT_REGIONS.join(', ')}` });
|
|
73
|
+
}
|
|
74
|
+
errors.push(...validateAgentModel(resource));
|
|
75
|
+
return errors;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validates the `model` value on an agent resource; `apiKey` is presence-checked only.
|
|
79
|
+
* @param resource The agent resource (already known to be an object)
|
|
80
|
+
* @returns A list of validation errors
|
|
81
|
+
*/
|
|
82
|
+
function validateAgentModel(resource) {
|
|
83
|
+
if (!('model' in resource) || typeof resource.model === 'undefined' || resource.model === null) {
|
|
84
|
+
return [{ type: 'missing_parameter', message: '`model` is required' }];
|
|
85
|
+
}
|
|
86
|
+
const { model } = resource;
|
|
87
|
+
if (typeof model !== 'object') {
|
|
88
|
+
return [{ type: 'invalid_type', message: '`model` must be an object' }];
|
|
89
|
+
}
|
|
90
|
+
const errors = [];
|
|
91
|
+
if (!('provider' in model)) {
|
|
92
|
+
errors.push({ type: 'missing_parameter', message: '`model.provider` is required' });
|
|
93
|
+
}
|
|
94
|
+
else if (typeof model.provider !== 'string') {
|
|
95
|
+
errors.push({ type: 'invalid_type', message: '`model.provider` must be a string' });
|
|
96
|
+
}
|
|
97
|
+
else if (model.provider.length === 0) {
|
|
98
|
+
errors.push({ type: 'invalid_value', message: '`model.provider` must be a non-empty string' });
|
|
99
|
+
}
|
|
100
|
+
if (!('id' in model)) {
|
|
101
|
+
errors.push({ type: 'missing_parameter', message: '`model.id` is required' });
|
|
102
|
+
}
|
|
103
|
+
else if (typeof model.id !== 'string') {
|
|
104
|
+
errors.push({ type: 'invalid_type', message: '`model.id` must be a string' });
|
|
105
|
+
}
|
|
106
|
+
else if (model.id.length === 0) {
|
|
107
|
+
errors.push({ type: 'invalid_value', message: '`model.id` must be a non-empty string' });
|
|
108
|
+
}
|
|
109
|
+
if ('baseURL' in model && typeof model.baseURL !== 'undefined') {
|
|
110
|
+
if (typeof model.baseURL !== 'string') {
|
|
111
|
+
errors.push({ type: 'invalid_type', message: '`model.baseURL` must be a string' });
|
|
112
|
+
}
|
|
113
|
+
else if (!isWellFormedUrl(model.baseURL)) {
|
|
114
|
+
errors.push({ type: 'invalid_format', message: '`model.baseURL` must be a well-formed URL' });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!('apiKey' in model)) {
|
|
118
|
+
errors.push({ type: 'missing_parameter', message: '`model.apiKey` is required' });
|
|
119
|
+
}
|
|
120
|
+
else if (typeof model.apiKey !== 'string') {
|
|
121
|
+
errors.push({ type: 'invalid_type', message: '`model.apiKey` must be a string' });
|
|
122
|
+
}
|
|
123
|
+
else if (model.apiKey.length === 0) {
|
|
124
|
+
errors.push({ type: 'invalid_value', message: 'model.apiKey is empty' });
|
|
125
|
+
}
|
|
126
|
+
return errors;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks whether a value is a well-formed absolute URL.
|
|
130
|
+
* @param value The value to check
|
|
131
|
+
* @returns `true` if the value parses as a URL
|
|
132
|
+
*/
|
|
133
|
+
function isWellFormedUrl(value) {
|
|
134
|
+
try {
|
|
135
|
+
// eslint-disable-next-line no-new
|
|
136
|
+
new URL(value);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/validation/agents.ts"],"names":[],"mappings":"AAEA,+CAA+C;AAC/C,MAAM,eAAe,GAAG,iCAAiC,CAAA;AAEzD,yCAAyC;AACzC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC,gDAAgD;AAChD,MAAM,4BAA4B,GAAG,GAAG,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C5C,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iCAAiC,EAAC,CAAC,CAAA;IACjF,CAAC;SAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,uBAAuB,EAAC,CAAC,CAAA;IACxE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,CAAC;QACH,kCAAkC;QAClC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -272,6 +272,17 @@ export function validateApplication(resource) {
|
|
|
272
272
|
!APPLICATION_VISIBILITIES.some((av) => av === resource.visibility)) {
|
|
273
273
|
errors.push({ type: 'invalid_value', message: 'visibility must be one of `default`, `unlisted`, or `disabled`' });
|
|
274
274
|
}
|
|
275
|
+
if ('autoUpdates' in resource && typeof resource.autoUpdates !== 'undefined') {
|
|
276
|
+
if (!resource.autoUpdates || typeof resource.autoUpdates !== 'object') {
|
|
277
|
+
errors.push({ type: 'invalid_type', message: 'Application autoUpdates must be an object' });
|
|
278
|
+
}
|
|
279
|
+
else if (!('enabled' in resource.autoUpdates)) {
|
|
280
|
+
errors.push({ type: 'missing_parameter', message: 'Application autoUpdates.enabled is required' });
|
|
281
|
+
}
|
|
282
|
+
else if (typeof resource.autoUpdates.enabled !== 'boolean') {
|
|
283
|
+
errors.push({ type: 'invalid_type', message: 'Application autoUpdates.enabled must be a boolean' });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
275
286
|
if (!('views' in resource) || typeof resource.views === 'undefined') {
|
|
276
287
|
errors.push({ type: 'missing_parameter', message: 'Application must declare at least one view' });
|
|
277
288
|
}
|