@sanity/context 0.0.1 → 0.0.3
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/studio.d.ts +4 -1
- package/dist/studio.js +47 -12
- package/dist/studio.js.map +1 -1
- package/package.json +10 -9
- package/src/studio/context-plugin/AgentDocumentInput.tsx +7 -5
- package/src/studio/context-plugin/agentContextSchema.ts +32 -2
- package/src/studio/context-plugin/plugin.tsx +65 -0
- package/src/studio/index.ts +1 -1
- package/src/studio/context-plugin/index.tsx +0 -42
package/dist/studio.d.ts
CHANGED
package/dist/studio.js
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { defineType, defineField, useDataset, useProjectId, getValueAtPath,
|
|
2
|
+
import { defineType, defineField, useDataset, useProjectId, getValueAtPath, definePlugin } from "sanity";
|
|
3
3
|
import { structureTool } from "sanity/structure";
|
|
4
4
|
import { DatabaseIcon, CopyIcon } from "@sanity/icons";
|
|
5
5
|
import { useToast, Stack, Card, Text, Flex, Button, Box } from "@sanity/ui";
|
|
6
|
-
const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "agentContext", agentContextSchema = defineType({
|
|
6
|
+
const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "sanity.agentContext", AGENT_CONTEXT_SCHEMA_TITLE = "Agent Context", agentContextSchema = defineType({
|
|
7
7
|
name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
8
|
-
title:
|
|
8
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
9
9
|
type: "document",
|
|
10
10
|
icon: DatabaseIcon,
|
|
11
11
|
fields: [
|
|
12
|
+
defineField({
|
|
13
|
+
name: "name",
|
|
14
|
+
title: "Name",
|
|
15
|
+
type: "string"
|
|
16
|
+
}),
|
|
17
|
+
defineField({
|
|
18
|
+
name: "slug",
|
|
19
|
+
title: "Slug",
|
|
20
|
+
type: "slug",
|
|
21
|
+
options: {
|
|
22
|
+
source: "name"
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
defineField({
|
|
26
|
+
name: "organizationId",
|
|
27
|
+
title: "Organization ID",
|
|
28
|
+
type: "string"
|
|
29
|
+
}),
|
|
12
30
|
defineField({
|
|
13
31
|
name: "projectId",
|
|
14
32
|
title: "Project ID",
|
|
@@ -27,23 +45,25 @@ const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "agentContext", agentContextSchema = defi
|
|
|
27
45
|
]
|
|
28
46
|
});
|
|
29
47
|
function AgentDocumentInput(props) {
|
|
30
|
-
const dataset = useDataset(), projectId = useProjectId(), toast = useToast(),
|
|
48
|
+
const dataset = useDataset(), projectId = useProjectId(), toast = useToast(), slug = getValueAtPath(props.value, ["slug"]), currentSlug = slug && typeof slug == "object" && "current" in slug ? slug.current : "", MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${currentSlug}`;
|
|
31
49
|
return /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
32
50
|
/* @__PURE__ */ jsx(Card, { shadow: 1, padding: 4, paddingLeft: 4, radius: 2, tone: "primary", children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
33
51
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, weight: "medium", children: "Context MCP URL" }),
|
|
34
|
-
|
|
52
|
+
slug ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
|
|
35
53
|
/* @__PURE__ */ jsx(Button, { icon: CopyIcon, mode: "bleed", fontSize: 1, padding: 2, onClick: () => {
|
|
36
54
|
try {
|
|
37
55
|
navigator.clipboard.writeText(MCP_URL), toast.push({
|
|
38
56
|
title: "Copied to clipboard",
|
|
39
57
|
description: "The MCP URL has been copied to your clipboard",
|
|
40
|
-
status: "success"
|
|
58
|
+
status: "success",
|
|
59
|
+
closable: !0
|
|
41
60
|
});
|
|
42
61
|
} catch {
|
|
43
62
|
toast.push({
|
|
44
63
|
title: "Error copying to clipboard",
|
|
45
64
|
description: "Please copy the MCP URL manually",
|
|
46
|
-
status: "error"
|
|
65
|
+
status: "error",
|
|
66
|
+
closable: !0
|
|
47
67
|
});
|
|
48
68
|
}
|
|
49
69
|
} }),
|
|
@@ -56,7 +76,18 @@ function AgentDocumentInput(props) {
|
|
|
56
76
|
const contextPlugin = definePlugin({
|
|
57
77
|
name: "sanity/context/plugin",
|
|
58
78
|
schema: {
|
|
59
|
-
types: [agentContextSchema]
|
|
79
|
+
types: [agentContextSchema],
|
|
80
|
+
// Add template configuration for the `sanity.agentContext` type
|
|
81
|
+
// as the sanity.* namespace is filtered by default.
|
|
82
|
+
templates: (prev) => [
|
|
83
|
+
...prev,
|
|
84
|
+
{
|
|
85
|
+
id: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
86
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
87
|
+
schemaType: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
88
|
+
value: {}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
60
91
|
},
|
|
61
92
|
form: {
|
|
62
93
|
components: {
|
|
@@ -65,10 +96,14 @@ const contextPlugin = definePlugin({
|
|
|
65
96
|
},
|
|
66
97
|
plugins: [
|
|
67
98
|
structureTool({
|
|
68
|
-
title:
|
|
69
|
-
name: "agent-context",
|
|
70
|
-
structure: (S) => S.list().title("
|
|
71
|
-
S.listItem().title(
|
|
99
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
100
|
+
name: "agent-context-structure",
|
|
101
|
+
structure: (S) => S.list().title("Content").items([
|
|
102
|
+
S.listItem().title(AGENT_CONTEXT_SCHEMA_TITLE).child(
|
|
103
|
+
S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title(
|
|
104
|
+
AGENT_CONTEXT_SCHEMA_TITLE
|
|
105
|
+
)
|
|
106
|
+
)
|
|
72
107
|
])
|
|
73
108
|
})
|
|
74
109
|
]
|
package/dist/studio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio.js","sources":["../src/studio/context-plugin/agentContextSchema.ts","../src/studio/context-plugin/AgentDocumentInput.tsx","../src/studio/context-plugin/
|
|
1
|
+
{"version":3,"file":"studio.js","sources":["../src/studio/context-plugin/agentContextSchema.ts","../src/studio/context-plugin/AgentDocumentInput.tsx","../src/studio/context-plugin/plugin.tsx"],"sourcesContent":["import {DatabaseIcon} from '@sanity/icons'\nimport {defineField, defineType} from 'sanity'\n\n/**\n * The name of the agent context schema type.\n */\nexport const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'sanity.agentContext'\n\n/**\n * The title of the agent context schema type.\n */\nexport const AGENT_CONTEXT_SCHEMA_TITLE = 'Agent Context'\n\n/**\n * The schema for the agent context document.\n * @beta\n */\nexport const agentContextSchema = defineType({\n name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,\n title: AGENT_CONTEXT_SCHEMA_TITLE,\n type: 'document',\n icon: DatabaseIcon,\n fields: [\n defineField({\n name: 'name',\n title: 'Name',\n type: 'string',\n }),\n defineField({\n name: 'slug',\n title: 'Slug',\n type: 'slug',\n options: {\n source: 'name',\n },\n }),\n defineField({\n name: 'organizationId',\n title: 'Organization ID',\n type: 'string',\n }),\n defineField({\n name: 'projectId',\n title: 'Project ID',\n type: 'string',\n }),\n defineField({\n name: 'dataset',\n title: 'Dataset',\n type: 'string',\n }),\n defineField({\n name: 'groqFilter',\n title: 'GROQ filter',\n type: 'text',\n }),\n ],\n})\n","import {CopyIcon} from '@sanity/icons'\nimport {Box, Button, Card, Flex, Stack, Text, useToast} from '@sanity/ui'\nimport {getValueAtPath, type InputProps, useDataset, useProjectId} from 'sanity'\n\nexport function AgentDocumentInput(props: InputProps) {\n const dataset = useDataset()\n const projectId = useProjectId()\n const toast = useToast()\n\n const slug = getValueAtPath(props.value, ['slug'])\n const currentSlug = slug && typeof slug === 'object' && 'current' in slug ? slug.current : ''\n const MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${currentSlug}`\n\n const handleCopy = () => {\n try {\n navigator.clipboard.writeText(MCP_URL)\n toast.push({\n title: 'Copied to clipboard',\n description: 'The MCP URL has been copied to your clipboard',\n status: 'success',\n closable: true,\n })\n } catch {\n toast.push({\n title: 'Error copying to clipboard',\n description: 'Please copy the MCP URL manually',\n status: 'error',\n closable: true,\n })\n }\n }\n\n return (\n <Stack space={4}>\n <Card shadow={1} padding={4} paddingLeft={4} radius={2} tone=\"primary\">\n <Stack space={4}>\n <Text size={1} muted weight=\"medium\">\n Context MCP URL\n </Text>\n\n {slug ? (\n <Flex align=\"center\" gap={2}>\n <Button icon={CopyIcon} mode=\"bleed\" fontSize={1} padding={2} onClick={handleCopy} />\n\n <Box flex={1}>\n <Text size={1} muted>\n {MCP_URL}\n </Text>\n </Box>\n </Flex>\n ) : (\n <Box paddingY={2}>\n <Text size={1} muted>\n No slug found. Please generate a slug to see the Context MCP URL.\n </Text>\n </Box>\n )}\n </Stack>\n </Card>\n\n {props.renderDefault(props)}\n </Stack>\n )\n}\n","import {definePlugin} from 'sanity'\nimport {type StructureBuilder, structureTool} from 'sanity/structure'\n\nimport {\n AGENT_CONTEXT_SCHEMA_TITLE,\n AGENT_CONTEXT_SCHEMA_TYPE_NAME,\n agentContextSchema,\n} from './agentContextSchema'\nimport {AgentDocumentInput} from './AgentDocumentInput'\n\n/**\n * The plugin for the agent context.\n * @beta\n */\nexport const contextPlugin = definePlugin({\n name: 'sanity/context/plugin',\n\n schema: {\n types: [agentContextSchema],\n\n // Add template configuration for the `sanity.agentContext` type\n // as the sanity.* namespace is filtered by default.\n templates: (prev) => [\n ...prev,\n {\n id: AGENT_CONTEXT_SCHEMA_TYPE_NAME,\n title: AGENT_CONTEXT_SCHEMA_TITLE,\n schemaType: AGENT_CONTEXT_SCHEMA_TYPE_NAME,\n value: {},\n },\n ],\n },\n\n form: {\n components: {\n input: (props) => {\n if (props.schemaType.name === AGENT_CONTEXT_SCHEMA_TYPE_NAME) {\n return <AgentDocumentInput {...props} />\n }\n\n return props.renderDefault(props)\n },\n },\n },\n\n plugins: [\n structureTool({\n title: AGENT_CONTEXT_SCHEMA_TITLE,\n name: 'agent-context-structure',\n structure: (S: StructureBuilder) => {\n return S.list()\n .title('Content')\n .items([\n S.listItem()\n .title(AGENT_CONTEXT_SCHEMA_TITLE)\n .child(\n S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title(\n AGENT_CONTEXT_SCHEMA_TITLE,\n ),\n ),\n ])\n },\n }),\n ],\n})\n"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/context",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,8 +31,14 @@
|
|
|
31
31
|
"dist",
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "pkg build --strict --clean --check",
|
|
36
|
+
"dev": "pkg-utils watch",
|
|
37
|
+
"test": "echo \"No tests yet\""
|
|
38
|
+
},
|
|
34
39
|
"browserslist": "extends @sanity/browserslist-config",
|
|
35
40
|
"devDependencies": {
|
|
41
|
+
"@repo/eslint-config": "workspace:*",
|
|
36
42
|
"@sanity/icons": "^3",
|
|
37
43
|
"@sanity/pkg-utils": "^10.3.2",
|
|
38
44
|
"@sanity/tsconfig": "^2.1.0",
|
|
@@ -43,8 +49,7 @@
|
|
|
43
49
|
"react-dom": "^19",
|
|
44
50
|
"sanity": "^5.3.1",
|
|
45
51
|
"styled-components": "^6",
|
|
46
|
-
"typescript": "^5.9.2"
|
|
47
|
-
"@repo/eslint-config": "0.0.0"
|
|
52
|
+
"typescript": "^5.9.2"
|
|
48
53
|
},
|
|
49
54
|
"peerDependencies": {
|
|
50
55
|
"@sanity/icons": "^3",
|
|
@@ -54,15 +59,11 @@
|
|
|
54
59
|
"sanity": "^5",
|
|
55
60
|
"styled-components": "^6"
|
|
56
61
|
},
|
|
62
|
+
"packageManager": "pnpm@10.19.0",
|
|
57
63
|
"engines": {
|
|
58
64
|
"node": ">=20.19 <22 || >=22.12"
|
|
59
65
|
},
|
|
60
66
|
"publishConfig": {
|
|
61
67
|
"access": "public"
|
|
62
|
-
},
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "pkg build --strict --clean --check",
|
|
65
|
-
"dev": "pkg-utils watch",
|
|
66
|
-
"test": "echo \"No tests yet\""
|
|
67
68
|
}
|
|
68
|
-
}
|
|
69
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {CopyIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Button, Card, Flex, Stack, Text, useToast} from '@sanity/ui'
|
|
3
|
-
import {
|
|
3
|
+
import {getValueAtPath, type InputProps, useDataset, useProjectId} from 'sanity'
|
|
4
4
|
|
|
5
5
|
export function AgentDocumentInput(props: InputProps) {
|
|
6
6
|
const dataset = useDataset()
|
|
7
7
|
const projectId = useProjectId()
|
|
8
8
|
const toast = useToast()
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${
|
|
10
|
+
const slug = getValueAtPath(props.value, ['slug'])
|
|
11
|
+
const currentSlug = slug && typeof slug === 'object' && 'current' in slug ? slug.current : ''
|
|
12
|
+
const MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${currentSlug}`
|
|
13
13
|
|
|
14
14
|
const handleCopy = () => {
|
|
15
15
|
try {
|
|
@@ -18,12 +18,14 @@ export function AgentDocumentInput(props: InputProps) {
|
|
|
18
18
|
title: 'Copied to clipboard',
|
|
19
19
|
description: 'The MCP URL has been copied to your clipboard',
|
|
20
20
|
status: 'success',
|
|
21
|
+
closable: true,
|
|
21
22
|
})
|
|
22
23
|
} catch {
|
|
23
24
|
toast.push({
|
|
24
25
|
title: 'Error copying to clipboard',
|
|
25
26
|
description: 'Please copy the MCP URL manually',
|
|
26
27
|
status: 'error',
|
|
28
|
+
closable: true,
|
|
27
29
|
})
|
|
28
30
|
}
|
|
29
31
|
}
|
|
@@ -36,7 +38,7 @@ export function AgentDocumentInput(props: InputProps) {
|
|
|
36
38
|
Context MCP URL
|
|
37
39
|
</Text>
|
|
38
40
|
|
|
39
|
-
{
|
|
41
|
+
{slug ? (
|
|
40
42
|
<Flex align="center" gap={2}>
|
|
41
43
|
<Button icon={CopyIcon} mode="bleed" fontSize={1} padding={2} onClick={handleCopy} />
|
|
42
44
|
|
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
import {DatabaseIcon} from '@sanity/icons'
|
|
2
2
|
import {defineField, defineType} from 'sanity'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The name of the agent context schema type.
|
|
6
|
+
*/
|
|
7
|
+
export const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'sanity.agentContext'
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The title of the agent context schema type.
|
|
11
|
+
*/
|
|
12
|
+
export const AGENT_CONTEXT_SCHEMA_TITLE = 'Agent Context'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The schema for the agent context document.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
6
18
|
export const agentContextSchema = defineType({
|
|
7
19
|
name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
8
|
-
title:
|
|
20
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
9
21
|
type: 'document',
|
|
10
22
|
icon: DatabaseIcon,
|
|
11
23
|
fields: [
|
|
24
|
+
defineField({
|
|
25
|
+
name: 'name',
|
|
26
|
+
title: 'Name',
|
|
27
|
+
type: 'string',
|
|
28
|
+
}),
|
|
29
|
+
defineField({
|
|
30
|
+
name: 'slug',
|
|
31
|
+
title: 'Slug',
|
|
32
|
+
type: 'slug',
|
|
33
|
+
options: {
|
|
34
|
+
source: 'name',
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
defineField({
|
|
38
|
+
name: 'organizationId',
|
|
39
|
+
title: 'Organization ID',
|
|
40
|
+
type: 'string',
|
|
41
|
+
}),
|
|
12
42
|
defineField({
|
|
13
43
|
name: 'projectId',
|
|
14
44
|
title: 'Project ID',
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {definePlugin} from 'sanity'
|
|
2
|
+
import {type StructureBuilder, structureTool} from 'sanity/structure'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AGENT_CONTEXT_SCHEMA_TITLE,
|
|
6
|
+
AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
7
|
+
agentContextSchema,
|
|
8
|
+
} from './agentContextSchema'
|
|
9
|
+
import {AgentDocumentInput} from './AgentDocumentInput'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The plugin for the agent context.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export const contextPlugin = definePlugin({
|
|
16
|
+
name: 'sanity/context/plugin',
|
|
17
|
+
|
|
18
|
+
schema: {
|
|
19
|
+
types: [agentContextSchema],
|
|
20
|
+
|
|
21
|
+
// Add template configuration for the `sanity.agentContext` type
|
|
22
|
+
// as the sanity.* namespace is filtered by default.
|
|
23
|
+
templates: (prev) => [
|
|
24
|
+
...prev,
|
|
25
|
+
{
|
|
26
|
+
id: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
27
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
28
|
+
schemaType: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
|
|
29
|
+
value: {},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
form: {
|
|
35
|
+
components: {
|
|
36
|
+
input: (props) => {
|
|
37
|
+
if (props.schemaType.name === AGENT_CONTEXT_SCHEMA_TYPE_NAME) {
|
|
38
|
+
return <AgentDocumentInput {...props} />
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return props.renderDefault(props)
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
plugins: [
|
|
47
|
+
structureTool({
|
|
48
|
+
title: AGENT_CONTEXT_SCHEMA_TITLE,
|
|
49
|
+
name: 'agent-context-structure',
|
|
50
|
+
structure: (S: StructureBuilder) => {
|
|
51
|
+
return S.list()
|
|
52
|
+
.title('Content')
|
|
53
|
+
.items([
|
|
54
|
+
S.listItem()
|
|
55
|
+
.title(AGENT_CONTEXT_SCHEMA_TITLE)
|
|
56
|
+
.child(
|
|
57
|
+
S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title(
|
|
58
|
+
AGENT_CONTEXT_SCHEMA_TITLE,
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
])
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
})
|
package/src/studio/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {contextPlugin} from './context-plugin/plugin'
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {definePlugin} from 'sanity'
|
|
2
|
-
import {type StructureBuilder, structureTool} from 'sanity/structure'
|
|
3
|
-
|
|
4
|
-
import {AGENT_CONTEXT_SCHEMA_TYPE_NAME, agentContextSchema} from './agentContextSchema'
|
|
5
|
-
import {AgentDocumentInput} from './AgentDocumentInput'
|
|
6
|
-
|
|
7
|
-
/** @beta */
|
|
8
|
-
export const contextPlugin = definePlugin({
|
|
9
|
-
name: 'sanity/context/plugin',
|
|
10
|
-
|
|
11
|
-
schema: {
|
|
12
|
-
types: [agentContextSchema],
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
form: {
|
|
16
|
-
components: {
|
|
17
|
-
input: (props) => {
|
|
18
|
-
if (props.schemaType.name === AGENT_CONTEXT_SCHEMA_TYPE_NAME) {
|
|
19
|
-
return <AgentDocumentInput {...props} />
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return props.renderDefault(props)
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
plugins: [
|
|
28
|
-
structureTool({
|
|
29
|
-
title: 'Agent context',
|
|
30
|
-
name: 'agent-context',
|
|
31
|
-
structure: (S: StructureBuilder) => {
|
|
32
|
-
return S.list()
|
|
33
|
-
.title('Agent Contexts')
|
|
34
|
-
.items([
|
|
35
|
-
S.listItem()
|
|
36
|
-
.title('Contexts')
|
|
37
|
-
.child(S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title('Contexts')),
|
|
38
|
-
])
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
})
|