@sanity/context 0.0.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.
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export declare function main(): void
3
+
4
+ export {}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ function main() {
2
+ }
3
+ export {
4
+ main
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/** @public */\nexport function main(): void {\n //\n}\n"],"names":[],"mappings":"AACO,SAAS,OAAa;AAE7B;"}
@@ -0,0 +1,6 @@
1
+ import {Plugin as Plugin_2} from 'sanity'
2
+
3
+ /** @beta */
4
+ export declare const contextPlugin: Plugin_2<void>
5
+
6
+ export {}
package/dist/studio.js ADDED
@@ -0,0 +1,79 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { defineType, defineField, useDataset, useProjectId, getValueAtPath, getPublishedId, definePlugin } from "sanity";
3
+ import { structureTool } from "sanity/structure";
4
+ import { DatabaseIcon, CopyIcon } from "@sanity/icons";
5
+ import { useToast, Stack, Card, Text, Flex, Button, Box } from "@sanity/ui";
6
+ const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "agentContext", agentContextSchema = defineType({
7
+ name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
8
+ title: "Agent context",
9
+ type: "document",
10
+ icon: DatabaseIcon,
11
+ fields: [
12
+ defineField({
13
+ name: "projectId",
14
+ title: "Project ID",
15
+ type: "string"
16
+ }),
17
+ defineField({
18
+ name: "dataset",
19
+ title: "Dataset",
20
+ type: "string"
21
+ }),
22
+ defineField({
23
+ name: "groqFilter",
24
+ title: "GROQ filter",
25
+ type: "text"
26
+ })
27
+ ]
28
+ });
29
+ function AgentDocumentInput(props) {
30
+ const dataset = useDataset(), projectId = useProjectId(), toast = useToast(), _id = getValueAtPath(props.value, ["_id"]) || "", contextId = _id && typeof _id == "string" ? getPublishedId(_id) : "", MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${contextId}`;
31
+ return /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
32
+ /* @__PURE__ */ jsx(Card, { shadow: 1, padding: 4, paddingLeft: 4, radius: 2, tone: "primary", children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
33
+ /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, weight: "medium", children: "Context MCP URL" }),
34
+ contextId ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
35
+ /* @__PURE__ */ jsx(Button, { icon: CopyIcon, mode: "bleed", fontSize: 1, padding: 2, onClick: () => {
36
+ try {
37
+ navigator.clipboard.writeText(MCP_URL), toast.push({
38
+ title: "Copied to clipboard",
39
+ description: "The MCP URL has been copied to your clipboard",
40
+ status: "success"
41
+ });
42
+ } catch {
43
+ toast.push({
44
+ title: "Error copying to clipboard",
45
+ description: "Please copy the MCP URL manually",
46
+ status: "error"
47
+ });
48
+ }
49
+ } }),
50
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: MCP_URL }) })
51
+ ] }) : /* @__PURE__ */ jsx(Box, { paddingY: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "No slug found. Please generate a slug to see the Context MCP URL." }) })
52
+ ] }) }),
53
+ props.renderDefault(props)
54
+ ] });
55
+ }
56
+ const contextPlugin = definePlugin({
57
+ name: "sanity/context/plugin",
58
+ schema: {
59
+ types: [agentContextSchema]
60
+ },
61
+ form: {
62
+ components: {
63
+ input: (props) => props.schemaType.name === AGENT_CONTEXT_SCHEMA_TYPE_NAME ? /* @__PURE__ */ jsx(AgentDocumentInput, { ...props }) : props.renderDefault(props)
64
+ }
65
+ },
66
+ plugins: [
67
+ structureTool({
68
+ title: "Agent context",
69
+ name: "agent-context",
70
+ structure: (S) => S.list().title("Agent Contexts").items([
71
+ S.listItem().title("Contexts").child(S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title("Contexts"))
72
+ ])
73
+ })
74
+ ]
75
+ });
76
+ export {
77
+ contextPlugin
78
+ };
79
+ //# sourceMappingURL=studio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio.js","sources":["../src/studio/context-plugin/agentContextSchema.ts","../src/studio/context-plugin/AgentDocumentInput.tsx","../src/studio/context-plugin/index.tsx"],"sourcesContent":["import {DatabaseIcon} from '@sanity/icons'\nimport {defineField, defineType} from 'sanity'\n\nexport const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'agentContext'\n\nexport const agentContextSchema = defineType({\n name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,\n title: 'Agent context',\n type: 'document',\n icon: DatabaseIcon,\n fields: [\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 {getPublishedId, 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 _id = getValueAtPath(props.value, ['_id']) || ''\n const contextId = _id && typeof _id === 'string' ? getPublishedId(_id) : ''\n const MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${contextId}`\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 })\n } catch {\n toast.push({\n title: 'Error copying to clipboard',\n description: 'Please copy the MCP URL manually',\n status: 'error',\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 {contextId ? (\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 {AGENT_CONTEXT_SCHEMA_TYPE_NAME, agentContextSchema} from './agentContextSchema'\nimport {AgentDocumentInput} from './AgentDocumentInput'\n\n/** @beta */\nexport const contextPlugin = definePlugin({\n name: 'sanity/context/plugin',\n\n schema: {\n types: [agentContextSchema],\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',\n name: 'agent-context',\n structure: (S: StructureBuilder) => {\n return S.list()\n .title('Agent Contexts')\n .items([\n S.listItem()\n .title('Contexts')\n .child(S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title('Contexts')),\n ])\n },\n }),\n ],\n})\n"],"names":[],"mappings":";;;;;AAGO,MAAM,iCAAiC,gBAEjC,qBAAqB,WAAW;AAAA,EAC3C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,YAAY;AAAA,MACV,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,IAAA,CACP;AAAA,IACD,YAAY;AAAA,MACV,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM;AAAA,IAAA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AAA,oBAAC,MAAA,EAAK,MAAM,GAAG,OAAK,IAAC,UAAA,oEAAA,CAErB,EAAA,CACF;AAAA,IAAA,EAAA,CAEJ,EAAA,CACF;AAAA,IAEC,MAAM,cAAc,KAAK;AAAA,EAAA,GAC5B;AAEJ;ACtDO,MAAM,gBAAgB,aAAa;AAAA,EACxC,MAAM;AAAA,EAEN,QAAQ;AAAA,IACN,OAAO,CAAC,kBAAkB;AAAA,EAAA;AAAA,EAG5B,MAAM;AAAA,IACJ,YAAY;AAAA,MACV,OAAO,CAAC,UACF,MAAM,WAAW,SAAS,iCACrB,oBAAC,oBAAA,EAAoB,GAAG,MAAA,CAAO,IAGjC,MAAM,cAAc,KAAK;AAAA,IAAA;AAAA,EAEpC;AAAA,EAGF,SAAS;AAAA,IACP,cAAc;AAAA,MACZ,OAAO;AAAA,MACP,MAAM;AAAA,MACN,WAAW,CAAC,MACH,EAAE,OACN,MAAM,gBAAgB,EACtB,MAAM;AAAA,QACL,EAAE,SAAA,EACC,MAAM,UAAU,EAChB,MAAM,EAAE,iBAAiB,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAAA,MAAA,CAC9E;AAAA,IAAA,CAEN;AAAA,EAAA;AAEL,CAAC;"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@sanity/context",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+ssh://git@github.com/sanity-io/context.git",
8
+ "directory": "packages/context"
9
+ },
10
+ "license": "MIT",
11
+ "author": "Sanity.io <hello@sanity.io>",
12
+ "sideEffects": false,
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "source": "./src/index.ts",
17
+ "import": "./dist/index.js",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./studio": {
21
+ "source": "./src/studio/index.ts",
22
+ "import": "./dist/studio.js",
23
+ "default": "./dist/studio.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "files": [
31
+ "dist",
32
+ "src"
33
+ ],
34
+ "browserslist": "extends @sanity/browserslist-config",
35
+ "devDependencies": {
36
+ "@sanity/icons": "^3",
37
+ "@sanity/pkg-utils": "^10.3.2",
38
+ "@sanity/tsconfig": "^2.1.0",
39
+ "@sanity/ui": "^3",
40
+ "@types/react": "^19",
41
+ "@types/react-dom": "^19",
42
+ "react": "^19",
43
+ "react-dom": "^19",
44
+ "sanity": "^5.3.1",
45
+ "styled-components": "^6",
46
+ "typescript": "^5.9.2",
47
+ "@repo/eslint-config": "0.0.0"
48
+ },
49
+ "peerDependencies": {
50
+ "@sanity/icons": "^3",
51
+ "@sanity/ui": "^3",
52
+ "react": "^19",
53
+ "react-dom": "^19",
54
+ "sanity": "^5",
55
+ "styled-components": "^6"
56
+ },
57
+ "engines": {
58
+ "node": ">=20.19 <22 || >=22.12"
59
+ },
60
+ "publishConfig": {
61
+ "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
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ /** @public */
2
+ export function main(): void {
3
+ //
4
+ }
@@ -0,0 +1,62 @@
1
+ import {CopyIcon} from '@sanity/icons'
2
+ import {Box, Button, Card, Flex, Stack, Text, useToast} from '@sanity/ui'
3
+ import {getPublishedId, getValueAtPath, type InputProps, useDataset, useProjectId} from 'sanity'
4
+
5
+ export function AgentDocumentInput(props: InputProps) {
6
+ const dataset = useDataset()
7
+ const projectId = useProjectId()
8
+ const toast = useToast()
9
+
10
+ const _id = getValueAtPath(props.value, ['_id']) || ''
11
+ const contextId = _id && typeof _id === 'string' ? getPublishedId(_id) : ''
12
+ const MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${contextId}`
13
+
14
+ const handleCopy = () => {
15
+ try {
16
+ navigator.clipboard.writeText(MCP_URL)
17
+ toast.push({
18
+ title: 'Copied to clipboard',
19
+ description: 'The MCP URL has been copied to your clipboard',
20
+ status: 'success',
21
+ })
22
+ } catch {
23
+ toast.push({
24
+ title: 'Error copying to clipboard',
25
+ description: 'Please copy the MCP URL manually',
26
+ status: 'error',
27
+ })
28
+ }
29
+ }
30
+
31
+ return (
32
+ <Stack space={4}>
33
+ <Card shadow={1} padding={4} paddingLeft={4} radius={2} tone="primary">
34
+ <Stack space={4}>
35
+ <Text size={1} muted weight="medium">
36
+ Context MCP URL
37
+ </Text>
38
+
39
+ {contextId ? (
40
+ <Flex align="center" gap={2}>
41
+ <Button icon={CopyIcon} mode="bleed" fontSize={1} padding={2} onClick={handleCopy} />
42
+
43
+ <Box flex={1}>
44
+ <Text size={1} muted>
45
+ {MCP_URL}
46
+ </Text>
47
+ </Box>
48
+ </Flex>
49
+ ) : (
50
+ <Box paddingY={2}>
51
+ <Text size={1} muted>
52
+ No slug found. Please generate a slug to see the Context MCP URL.
53
+ </Text>
54
+ </Box>
55
+ )}
56
+ </Stack>
57
+ </Card>
58
+
59
+ {props.renderDefault(props)}
60
+ </Stack>
61
+ )
62
+ }
@@ -0,0 +1,28 @@
1
+ import {DatabaseIcon} from '@sanity/icons'
2
+ import {defineField, defineType} from 'sanity'
3
+
4
+ export const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'agentContext'
5
+
6
+ export const agentContextSchema = defineType({
7
+ name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
8
+ title: 'Agent context',
9
+ type: 'document',
10
+ icon: DatabaseIcon,
11
+ fields: [
12
+ defineField({
13
+ name: 'projectId',
14
+ title: 'Project ID',
15
+ type: 'string',
16
+ }),
17
+ defineField({
18
+ name: 'dataset',
19
+ title: 'Dataset',
20
+ type: 'string',
21
+ }),
22
+ defineField({
23
+ name: 'groqFilter',
24
+ title: 'GROQ filter',
25
+ type: 'text',
26
+ }),
27
+ ],
28
+ })
@@ -0,0 +1,42 @@
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
+ })
@@ -0,0 +1 @@
1
+ export * from './context-plugin'