@sanity/context 0.0.1 → 0.0.2

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 CHANGED
@@ -1,6 +1,28 @@
1
+ import {DocumentDefinition} from 'sanity'
1
2
  import {Plugin as Plugin_2} from 'sanity'
3
+ import {PreviewConfig} from 'sanity'
2
4
 
3
- /** @beta */
5
+ /**
6
+ * The name of the agent context schema type.
7
+ * @beta
8
+ */
9
+ export declare const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'agentContext'
10
+
11
+ /**
12
+ * The schema for the agent context document.
13
+ * @beta
14
+ */
15
+ export declare const agentContextSchema: {
16
+ type: 'document'
17
+ name: 'agentContext'
18
+ } & Omit<DocumentDefinition, 'preview'> & {
19
+ preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
20
+ }
21
+
22
+ /**
23
+ * The plugin for the agent context.
24
+ * @beta
25
+ */
4
26
  export declare const contextPlugin: Plugin_2<void>
5
27
 
6
28
  export {}
package/dist/studio.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { DatabaseIcon, CopyIcon } from "@sanity/icons";
2
+ import { defineType, defineField, useDataset, useProjectId, getValueAtPath, definePlugin } from "sanity";
1
3
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { defineType, defineField, useDataset, useProjectId, getValueAtPath, getPublishedId, definePlugin } from "sanity";
3
4
  import { structureTool } from "sanity/structure";
4
- import { DatabaseIcon, CopyIcon } from "@sanity/icons";
5
5
  import { useToast, Stack, Card, Text, Flex, Button, Box } from "@sanity/ui";
6
6
  const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "agentContext", agentContextSchema = defineType({
7
7
  name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
@@ -9,6 +9,24 @@ const AGENT_CONTEXT_SCHEMA_TYPE_NAME = "agentContext", agentContextSchema = defi
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(), _id = getValueAtPath(props.value, ["_id"]) || "", contextId = _id && typeof _id == "string" ? getPublishedId(_id) : "", MCP_URL = `https://context-mcp.sanity.io/${projectId}/${dataset}/${contextId}`;
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
- contextId ? /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
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
  } }),
@@ -65,7 +85,7 @@ const contextPlugin = definePlugin({
65
85
  },
66
86
  plugins: [
67
87
  structureTool({
68
- title: "Agent context",
88
+ title: "Agent Context",
69
89
  name: "agent-context",
70
90
  structure: (S) => S.list().title("Agent Contexts").items([
71
91
  S.listItem().title("Contexts").child(S.documentTypeList(AGENT_CONTEXT_SCHEMA_TYPE_NAME).title("Contexts"))
@@ -74,6 +94,8 @@ const contextPlugin = definePlugin({
74
94
  ]
75
95
  });
76
96
  export {
97
+ AGENT_CONTEXT_SCHEMA_TYPE_NAME,
98
+ agentContextSchema,
77
99
  contextPlugin
78
100
  };
79
101
  //# sourceMappingURL=studio.js.map
@@ -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/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.documentTyp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K;AAAA,cACT,OAAO;AAAA,cACP,aAAa;AAAA,cACb,QAAQ;AAAA,YAAA,CACT;AAAA,UACH,QAAQ;AACN,kBAAM,KAAK;AAAA,cACT,OAAO;AAAA,cACP,aAAa;AAAA,cACb,QAAQ;AAAA,YAAA,CACT;AAAA,UACH;AAAA,QACF,GAY+F;AAAA,QAEnF,oBAAC,KAAA,EAAI,MAAM,GACT,UAAA,oBAAC,MAAA,EAAK,MAAM,GAAG,OAAK,IACjB,UAAA,QAAA,CACH,EAAA,CACF;AAAA,MAAA,EAAA,CACF,IAEA,oBAAC,KAAA,EAAI,UAAU,GACb,UAAA,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;"}
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 * @beta\n */\nexport const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'agentContext'\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',\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 {AGENT_CONTEXT_SCHEMA_TYPE_NAME, agentContextSchema} 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\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":";;;;;AAOO,MAAM,iCAAiC,gBAMjC,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;AAA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AA,CACX;AAAA,UACH,QAAQ;AACN,kBAAM,KAAK;AAAA,cACT,OAAO;AAAA,cACP,aAAa;AAAA,cACb,QAAQ;AAAA,cACR,UAAU;AAAA,YAAA,CACX;AAAA,UACH;AAAA,QACF,GAY+F;AAAA,QAEnF,oBAAC,KAAA,EAAI,MAAM,GACT,UAAA,oBAAC,MAAA,EAAK,MAAM,GAAG,OAAK,IACjB,UAAA,QAAA,CACH,EAAA,CACF;AAAA,MAAA,EAAA,CACF,IAEA,oBAAC,KAAA,EAAI,UAAU,GACb,UAAA,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;ACrDO,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/context",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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 {getPublishedId, getValueAtPath, type InputProps, useDataset, useProjectId} from 'sanity'
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 _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}`
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
- {contextId ? (
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,40 @@
1
1
  import {DatabaseIcon} from '@sanity/icons'
2
2
  import {defineField, defineType} from 'sanity'
3
3
 
4
+ /**
5
+ * The name of the agent context schema type.
6
+ * @beta
7
+ */
4
8
  export const AGENT_CONTEXT_SCHEMA_TYPE_NAME = 'agentContext'
5
9
 
10
+ /**
11
+ * The schema for the agent context document.
12
+ * @beta
13
+ */
6
14
  export const agentContextSchema = defineType({
7
15
  name: AGENT_CONTEXT_SCHEMA_TYPE_NAME,
8
16
  title: 'Agent context',
9
17
  type: 'document',
10
18
  icon: DatabaseIcon,
11
19
  fields: [
20
+ defineField({
21
+ name: 'name',
22
+ title: 'Name',
23
+ type: 'string',
24
+ }),
25
+ defineField({
26
+ name: 'slug',
27
+ title: 'Slug',
28
+ type: 'slug',
29
+ options: {
30
+ source: 'name',
31
+ },
32
+ }),
33
+ defineField({
34
+ name: 'organizationId',
35
+ title: 'Organization ID',
36
+ type: 'string',
37
+ }),
12
38
  defineField({
13
39
  name: 'projectId',
14
40
  title: 'Project ID',
@@ -0,0 +1,2 @@
1
+ export * from './agentContextSchema'
2
+ export * from './plugin'
@@ -4,7 +4,10 @@ import {type StructureBuilder, structureTool} from 'sanity/structure'
4
4
  import {AGENT_CONTEXT_SCHEMA_TYPE_NAME, agentContextSchema} from './agentContextSchema'
5
5
  import {AgentDocumentInput} from './AgentDocumentInput'
6
6
 
7
- /** @beta */
7
+ /**
8
+ * The plugin for the agent context.
9
+ * @beta
10
+ */
8
11
  export const contextPlugin = definePlugin({
9
12
  name: 'sanity/context/plugin',
10
13
 
@@ -26,7 +29,7 @@ export const contextPlugin = definePlugin({
26
29
 
27
30
  plugins: [
28
31
  structureTool({
29
- title: 'Agent context',
32
+ title: 'Agent Context',
30
33
  name: 'agent-context',
31
34
  structure: (S: StructureBuilder) => {
32
35
  return S.list()