@sanity/cli 8.27.0 → 8.28.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/README.md +1515 -408
- package/dist/actions/context/commandTable.js +215 -0
- package/dist/actions/context/commandTable.js.map +1 -0
- package/dist/actions/context/contextCommand.js +246 -0
- package/dist/actions/context/contextCommand.js.map +1 -0
- package/dist/actions/context/contextSpec.js +18 -0
- package/dist/actions/context/contextSpec.js.map +1 -0
- package/dist/actions/context/distillContextOperations.js +335 -0
- package/dist/actions/context/distillContextOperations.js.map +1 -0
- package/dist/actions/context/mcpEndpoint.js.map +1 -1
- package/dist/actions/context/operationInput.js +226 -0
- package/dist/actions/context/operationInput.js.map +1 -0
- package/dist/actions/context/operationTypes.js +3 -0
- package/dist/actions/context/operationTypes.js.map +1 -0
- package/dist/actions/context/removedCommands.js +26 -0
- package/dist/actions/context/removedCommands.js.map +1 -0
- package/dist/actions/context/renderOperationResult.js +72 -0
- package/dist/actions/context/renderOperationResult.js.map +1 -0
- package/dist/actions/context/sourceFile.js +31 -0
- package/dist/actions/context/sourceFile.js.map +1 -0
- package/dist/actions/context/syncOutput.js +17 -0
- package/dist/actions/context/syncOutput.js.map +1 -0
- package/dist/actions/context/table.js +13 -0
- package/dist/actions/context/table.js.map +1 -0
- package/dist/actions/context/waitForJob.js.map +1 -1
- package/dist/actions/context/waitForSourceSync.js +48 -0
- package/dist/actions/context/waitForSourceSync.js.map +1 -0
- package/dist/actions/context/watchJob.js.map +1 -1
- package/dist/actions/context/watchSourceSync.js +40 -0
- package/dist/actions/context/watchSourceSync.js.map +1 -0
- package/dist/actions/dev/servers/startStudioDevServer.js +4 -1
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/commands/context/build.js +19 -81
- package/dist/commands/context/build.js.map +1 -1
- package/dist/commands/context/create.js +3 -90
- package/dist/commands/context/create.js.map +1 -1
- package/dist/commands/context/delete.js +3 -73
- package/dist/commands/context/delete.js.map +1 -1
- package/dist/commands/context/documents/content.js +117 -0
- package/dist/commands/context/documents/content.js.map +1 -0
- package/dist/commands/context/documents/delete.js +5 -0
- package/dist/commands/context/documents/delete.js.map +1 -0
- package/dist/commands/context/documents/edit.js +5 -0
- package/dist/commands/context/documents/edit.js.map +1 -0
- package/dist/commands/context/documents/get.js +5 -0
- package/dist/commands/context/documents/get.js.map +1 -0
- package/dist/commands/context/documents/list.js +5 -0
- package/dist/commands/context/documents/list.js.map +1 -0
- package/dist/commands/context/entries/list.js +2 -2
- package/dist/commands/context/entries/list.js.map +1 -1
- package/dist/commands/context/entries/rebuild.js +3 -93
- package/dist/commands/context/entries/rebuild.js.map +1 -1
- package/dist/commands/context/get.js +3 -88
- package/dist/commands/context/get.js.map +1 -1
- package/dist/commands/context/instructions/create.js +5 -0
- package/dist/commands/context/instructions/create.js.map +1 -0
- package/dist/commands/context/instructions/delete.js +5 -0
- package/dist/commands/context/instructions/delete.js.map +1 -0
- package/dist/commands/context/instructions/edit.js +5 -0
- package/dist/commands/context/instructions/edit.js.map +1 -0
- package/dist/commands/context/issues/apply.js +3 -84
- package/dist/commands/context/issues/apply.js.map +1 -1
- package/dist/commands/context/issues/dismiss.js +3 -50
- package/dist/commands/context/issues/dismiss.js.map +1 -1
- package/dist/commands/context/issues/reopen.js +3 -51
- package/dist/commands/context/issues/reopen.js.map +1 -1
- package/dist/commands/context/issues/resolve.js +23 -92
- package/dist/commands/context/issues/resolve.js.map +1 -1
- package/dist/commands/context/jobs/get.js +3 -88
- package/dist/commands/context/jobs/get.js.map +1 -1
- package/dist/commands/context/list.js +3 -95
- package/dist/commands/context/list.js.map +1 -1
- package/dist/commands/context/mcp/initial-context.js +5 -0
- package/dist/commands/context/mcp/initial-context.js.map +1 -0
- package/dist/commands/context/mcp/list.js +2 -2
- package/dist/commands/context/mcp/list.js.map +1 -1
- package/dist/commands/context/mcp/status.js.map +1 -1
- package/dist/commands/context/mcp/update.js.map +1 -1
- package/dist/commands/context/sources/create.js +175 -0
- package/dist/commands/context/sources/create.js.map +1 -0
- package/dist/commands/context/sources/delete.js +5 -0
- package/dist/commands/context/sources/delete.js.map +1 -0
- package/dist/commands/context/sources/edit.js +29 -0
- package/dist/commands/context/sources/edit.js.map +1 -0
- package/dist/commands/context/sources/get.js +5 -0
- package/dist/commands/context/sources/get.js.map +1 -0
- package/dist/commands/context/sources/list.js +5 -0
- package/dist/commands/context/sources/list.js.map +1 -0
- package/dist/commands/context/sources/sync.js +5 -0
- package/dist/commands/context/sources/sync.js.map +1 -0
- package/dist/commands/context/sources/syncs/confirm.js +5 -0
- package/dist/commands/context/sources/syncs/confirm.js.map +1 -0
- package/dist/commands/context/sources/syncs/discard.js +5 -0
- package/dist/commands/context/sources/syncs/discard.js.map +1 -0
- package/dist/commands/context/sources/syncs/get.js +5 -0
- package/dist/commands/context/sources/syncs/get.js.map +1 -0
- package/dist/commands/context/sources/syncs/list.js +5 -0
- package/dist/commands/context/sources/syncs/list.js.map +1 -0
- package/dist/commands/context/sources/upload.js +63 -0
- package/dist/commands/context/sources/upload.js.map +1 -0
- package/dist/commands/context/sync.js +5 -0
- package/dist/commands/context/sync.js.map +1 -0
- package/dist/commands/context/update.js +3 -136
- package/dist/commands/context/update.js.map +1 -1
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +41 -26
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
- package/dist/generated/apiRoutes.js +28 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/generated/contextOperations.js +1116 -0
- package/dist/generated/contextOperations.js.map +1 -0
- package/dist/hooks/commandNotFound/topicAliases.js +8 -2
- package/dist/hooks/commandNotFound/topicAliases.js.map +1 -1
- package/dist/services/context.js +241 -268
- package/dist/services/context.js.map +1 -1
- package/dist/util/telemetry/cliCommandIdentity.js +10 -18
- package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
- package/oclif.manifest.json +3380 -1910
- package/package.json +24 -23
- package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-quickstart/AGENTS.md +49 -0
- package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-sanity-ui/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-quickstart/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +49 -0
- package/dist/commands/context/imports/create.js +0 -270
- package/dist/commands/context/imports/create.js.map +0 -1
- package/dist/commands/context/imports/delete.js +0 -73
- package/dist/commands/context/imports/delete.js.map +0 -1
- package/dist/commands/context/imports/download.js +0 -60
- package/dist/commands/context/imports/download.js.map +0 -1
- package/dist/commands/context/imports/get.js +0 -88
- package/dist/commands/context/imports/get.js.map +0 -1
- package/dist/commands/context/imports/list.js +0 -100
- package/dist/commands/context/imports/list.js.map +0 -1
- package/dist/commands/context/refresh.js +0 -46
- package/dist/commands/context/refresh.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/context.ts"],"sourcesContent":["import {getGlobalCliClient, subdebug} from '@sanity/cli-core'\nimport {type Context, EXPERIMENTAL_API_WARNING, isHttpError} from '@sanity/client'\n\nconst CONTEXT_API_VERSION = 'v2026-08-25'\nconst BLUEPRINTS_API_VERSION = 'vX'\nconst BLUEPRINTS_LOOKUP_TIMEOUT_MS = 5000\n// The version in the URLs the Context API returns for agents to connect to MCP endpoints\nconst MCP_CONNECT_API_VERSION = 'v2026-11-10'\n\nconst blueprintOwnershipDebug = subdebug('context:blueprint-ownership')\n\n/**\n * Knowledge-base-scoped methods on `client.context` operate on the client's\n * configured `resource`; collection-level methods\n * (`client.context.knowledgeBases.*`) are addressed per call and need none.\n * GROQ-backed reads also need `context.organizationId`.\n */\nasync function getContextClient(knowledgeBaseId?: string, organizationId?: string) {\n return getGlobalCliClient({\n apiVersion: CONTEXT_API_VERSION,\n requireUser: true,\n ...(knowledgeBaseId === undefined\n ? {}\n : {resource: {id: knowledgeBaseId, type: 'knowledge-base' as const}}),\n ...(organizationId === undefined ? {} : {context: {organizationId}}),\n })\n}\n\n/**\n * GROQ-backed reads (issues, entries) query the organization's\n * document store, where documents are keyed by the knowledge base's public ID.\n * Fetching the knowledge base resolves both, whichever of its IDs was passed.\n */\nasync function getContextStoreClient(knowledgeBaseId: string) {\n const {organizationId, publicId} = await getKnowledgeBase(knowledgeBaseId)\n return getContextClient(publicId, organizationId)\n}\n\n/**\n * Create a knowledge base in an organization\n */\nexport async function createKnowledgeBase(\n params: Context.CreateKnowledgeBaseParams,\n): Promise<Context.KnowledgeBase> {\n const client = await getContextClient()\n return client.context.knowledgeBases.create(params)\n}\n\n/**\n * List all knowledge bases in an organization (drains pagination)\n */\nexport async function listKnowledgeBases(organizationId: string): Promise<Context.KnowledgeBase[]> {\n const client = await getContextClient()\n\n const knowledgeBases: Context.KnowledgeBase[] = []\n let cursor: string | undefined\n do {\n const page = await client.context.knowledgeBases.list({\n cursor,\n organizationId,\n })\n knowledgeBases.push(...page.data)\n cursor = page.nextCursor ?? undefined\n } while (cursor !== undefined)\n\n return knowledgeBases\n}\n\n/**\n * Get a single knowledge base by ID\n */\nexport async function getKnowledgeBase(knowledgeBaseId: string): Promise<Context.KnowledgeBase> {\n const client = await getContextClient()\n return client.context.knowledgeBases.get(knowledgeBaseId)\n}\n\n/**\n * Update a knowledge base's configuration\n */\nexport async function updateKnowledgeBase(\n knowledgeBaseId: string,\n params: Context.EditKnowledgeBaseParams,\n): Promise<Context.KnowledgeBase> {\n const client = await getContextClient()\n return client.context.knowledgeBases.edit(knowledgeBaseId, params)\n}\n\n/**\n * `stackName` is `null` when the caller can't read Blueprints: the search then\n * only says whether a blueprint manages the resource.\n */\nexport type BlueprintOwnership = {managed: false} | {managed: true; stackName: string | null}\n\n/**\n * Who manages a resource, for refusal messages: the stack by name when the caller can read it\n */\nexport function describeBlueprintManager(stackName: string | null): string {\n return stackName ? `The blueprint stack \"${stackName}\"` : 'A blueprint'\n}\n\n/**\n * Whether a live blueprint stack manages the knowledge base\n */\nexport function getKnowledgeBaseBlueprintOwnership(\n knowledgeBaseId: string,\n): Promise<BlueprintOwnership> {\n return getBlueprintOwnership('sanity.context.knowledge-base', async () => {\n const {organizationId, publicId} = await getKnowledgeBase(knowledgeBaseId)\n return {organizationId, publicId}\n })\n}\n\n/**\n * Whether a live blueprint stack manages the MCP endpoint\n */\nexport function getMcpEndpointBlueprintOwnership(\n organizationId: string,\n {id}: Pick<Context.McpEndpoint, 'id'>,\n): Promise<BlueprintOwnership> {\n return getBlueprintOwnership('sanity.context.mcp', async () => ({organizationId, publicId: id}))\n}\n\n/**\n * Looks the resource up in the Blueprints resource search. Fails open: a\n * failed lookup answers not managed, so a Blueprints outage never blocks a\n * command. A resource that doesn't exist isn't managed either.\n */\nasync function getBlueprintOwnership(\n type: string,\n resolveResource: () => Promise<{organizationId: string; publicId: string} | null>,\n): Promise<BlueprintOwnership> {\n try {\n const resource = await resolveResource()\n if (!resource) return {managed: false}\n const {organizationId, publicId} = resource\n const client = await getGlobalCliClient({\n apiVersion: BLUEPRINTS_API_VERSION,\n // The Blueprints API has no stable version yet, and the warning would interrupt command output.\n // The client splits the warning header on commas, so its second clause is matched separately.\n ignoreWarnings: [EXPERIMENTAL_API_WARNING, 'which will change without warning'],\n // The lookup fails open, so an unreachable Blueprints API must not hold the command for the client's defaults.\n maxRetries: 0,\n requireUser: true,\n timeout: BLUEPRINTS_LOOKUP_TIMEOUT_MS,\n })\n const headers = {\n 'x-sanity-scope-id': organizationId,\n 'x-sanity-scope-type': 'organization',\n }\n const matches = await client.request<{stackId?: string}[]>({\n headers,\n query: {id: publicId, type},\n url: '/blueprints/resources/search',\n })\n const stackId = matches.find((match) => typeof match.stackId === 'string')?.stackId\n if (!stackId) return {managed: false}\n const stackName = await client\n .request<{name?: string}>({\n headers,\n url: `/blueprints/stacks/${encodeURIComponent(stackId)}`,\n })\n .then((stack) => stack.name ?? null)\n .catch(() => null)\n return {managed: true, stackName}\n } catch (error) {\n if (isHttpError(error)) {\n if (error.statusCode === 403 && errorCode(error) === 'RESOURCE_MANAGED') {\n return {managed: true, stackName: null}\n }\n if (error.statusCode === 404 && errorCode(error) === 'RESOURCE_NOT_MANAGED') {\n return {managed: false}\n }\n }\n blueprintOwnershipDebug('Blueprint ownership lookup failed, treating as not managed', error)\n return {managed: false}\n }\n}\n\nfunction errorCode(error: {response: {body: unknown}}): unknown {\n const {body} = error.response\n return body && typeof body === 'object' && 'errorCode' in body ? body.errorCode : undefined\n}\n\n/**\n * Delete a knowledge base and its generated content\n */\nexport async function deleteKnowledgeBase(knowledgeBaseId: string): Promise<void> {\n const client = await getContextClient()\n await client.context.knowledgeBases.delete(knowledgeBaseId)\n}\n\n/**\n * Import content into a knowledge base. File imports are staged and uploaded\n * to signed storage by the client.\n */\nexport async function createImport(\n knowledgeBaseId: string,\n params: Context.CreateFileImportParams | Context.CreateImportParams,\n): Promise<Context.JobAccepted> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.imports.create(params)\n}\n\n/**\n * List all imports for a knowledge base (drains pagination)\n */\nexport async function listImports(knowledgeBaseId: string): Promise<Context.Import[]> {\n const client = await getContextClient(knowledgeBaseId)\n\n const imports: Context.Import[] = []\n let cursor: string | undefined\n do {\n const page = await client.context.imports.list({cursor})\n imports.push(...page.data)\n cursor = page.nextCursor ?? undefined\n } while (cursor !== undefined)\n\n return imports\n}\n\n/**\n * Get a single import by ID\n */\nexport async function getImport(\n knowledgeBaseId: string,\n importId: string,\n): Promise<Context.ImportDetail> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.imports.get({importId})\n}\n\n/**\n * Get a short-lived signed URL for an import's original uploaded bytes\n */\nexport async function downloadImport(\n knowledgeBaseId: string,\n importId: string,\n): Promise<Context.ImportDownloadResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.imports.download({importId})\n}\n\n/**\n * Delete an import from a knowledge base\n */\nexport async function deleteImport(knowledgeBaseId: string, importId: string): Promise<void> {\n const client = await getContextClient(knowledgeBaseId)\n await client.context.imports.delete({importId})\n}\n\n/**\n * Start a build of a knowledge base\n */\nexport async function buildKnowledgeBase(knowledgeBaseId: string): Promise<Context.JobAccepted> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.build()\n}\n\n/**\n * Cancel the running build of a knowledge base, if any\n */\nexport async function cancelKnowledgeBaseBuild(\n knowledgeBaseId: string,\n): Promise<{cancelled: boolean}> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.cancelBuild()\n}\n\n/**\n * Run an incremental refresh: re-check sources and apply what changed\n */\nexport async function refreshKnowledgeBase(\n knowledgeBaseId: string,\n): Promise<{jobId: string; started: boolean}> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.refresh()\n}\n\n/**\n * Get an async job (build, import) by ID\n */\nexport async function getJob(knowledgeBaseId: string, jobId: string): Promise<Context.Job> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.jobs.get({jobId})\n}\n\n/**\n * List all issues for a knowledge base, optionally narrowed to one status\n */\nexport async function listIssues(\n knowledgeBaseId: string,\n status?: Context.IssueDoc['status'],\n): Promise<Context.IssueDoc[]> {\n const client = await getContextStoreClient(knowledgeBaseId)\n return client.context.issues.list({status})\n}\n\n/**\n * Get a single issue by ID, or `null` when it does not exist\n */\nexport async function getIssue(\n knowledgeBaseId: string,\n issueId: string,\n): Promise<Context.IssueDoc | null> {\n const client = await getContextStoreClient(knowledgeBaseId)\n return client.context.issues.get({issueId})\n}\n\n/**\n * Resolve a conflict issue by choosing one of its sides (by index). Choosing\n * a side other than the entry's current content starts a rewrite job.\n */\nexport async function resolveIssue(\n knowledgeBaseId: string,\n issueId: string,\n resolution: number,\n): Promise<Context.ResolveIssueResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.issues.resolve({issueId, resolution})\n}\n\n/**\n * Dismiss an issue\n */\nexport async function dismissIssue(\n knowledgeBaseId: string,\n issueId: string,\n): Promise<Context.DismissIssueResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.issues.dismiss({issueId})\n}\n\n/**\n * Reopen a resolved conflict issue\n */\nexport async function reopenIssue(\n knowledgeBaseId: string,\n issueId: string,\n): Promise<Context.ReopenIssueResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.issues.reopen({issueId})\n}\n\n/**\n * Apply accepted issues to a knowledge base in one batch\n */\nexport async function applyIssues(\n knowledgeBaseId: string,\n issueIds: string[],\n): Promise<Context.ApplyIssuesResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.issues.apply({issueIds})\n}\n\n/**\n * List all entries for a knowledge base, path-ordered, without bodies\n */\nexport async function listEntries(knowledgeBaseId: string): Promise<Context.Entry[]> {\n const client = await getContextStoreClient(knowledgeBaseId)\n return client.context.entries.list()\n}\n\n/**\n * Get a single entry with its body and citations by outline path, or `null`\n * when no entry sits at that path\n */\nexport async function getEntry(\n knowledgeBaseId: string,\n path: string,\n): Promise<Context.EntryDoc | null> {\n const client = await getContextStoreClient(knowledgeBaseId)\n return client.context.entries.get({path})\n}\n\n/**\n * Rebuild one entry from its sources by outline path\n */\nexport async function rebuildEntry(\n knowledgeBaseId: string,\n path: string,\n): Promise<Context.RebuildEntryResponse> {\n const client = await getContextClient(knowledgeBaseId)\n return client.context.entries.rebuild({path})\n}\n\n/**\n * Run a GROQ query against an organization's Context documents\n */\nexport async function queryContext(\n organizationId: string,\n query: string,\n params?: Record<string, unknown>,\n): Promise<unknown> {\n const client = await getContextClient(undefined, organizationId)\n return client.context.fetch(query, params)\n}\n\n/**\n * List an organization's MCP endpoints, oldest first\n */\nexport async function listMcpEndpoints(organizationId: string): Promise<Context.McpEndpoint[]> {\n const client = await getContextClient(undefined, organizationId)\n const docs = await client.context.mcpEndpoints.list()\n const connectClient = client.withConfig({apiVersion: MCP_CONNECT_API_VERSION})\n return docs.map((doc) => toMcpEndpoint(connectClient, doc))\n}\n\n/**\n * Get an MCP endpoint by name or ID, or `null` when the organization has none.\n * Update and delete accept either, so the lookups guarding them must too.\n */\nexport async function getMcpEndpoint(\n organizationId: string,\n nameOrId: string,\n): Promise<Context.McpEndpoint | null> {\n const client = await getContextClient(undefined, organizationId)\n const doc = await client.context.fetch<Context.McpDoc | null>(\n '*[_type == \"sanity.context.mcp\" && organizationId == $org && (name == $nameOrId || publicId == $nameOrId)][0]',\n {nameOrId, org: organizationId},\n )\n return doc && toMcpEndpoint(client.withConfig({apiVersion: MCP_CONNECT_API_VERSION}), doc)\n}\n\n/**\n * The stored configuration in the shape create and edit return, so every command outputs the\n * same fields. The URL isn't stored, so it is built from the same route and API version.\n */\nfunction toMcpEndpoint(\n connectClient: {getUrl: (uri: string) => string},\n doc: Context.McpDoc,\n): Context.McpEndpoint {\n return {\n createdAt: doc._createdAt,\n groqFilter: doc.groqFilter ?? null,\n id: doc.publicId,\n instructions: doc.instructions ?? null,\n name: doc.name,\n organizationId: doc.organizationId,\n sources: doc.sources,\n title: doc.title,\n updatedAt: doc._updatedAt,\n url: connectClient.getUrl(\n `/context/organizations/${encodeURIComponent(doc.organizationId)}/mcp/${encodeURIComponent(doc.name)}`,\n ),\n }\n}\n\n/**\n * Create an MCP endpoint\n */\nexport async function createMcpEndpoint(\n organizationId: string,\n params: Context.CreateMcpEndpointParams,\n): Promise<Context.McpEndpoint> {\n const client = await getContextClient(undefined, organizationId)\n return client.context.mcpEndpoints.create(params)\n}\n\n/**\n * Update an MCP endpoint's configuration\n */\nexport async function updateMcpEndpoint(\n organizationId: string,\n name: string,\n params: Context.EditMcpEndpointParams,\n): Promise<Context.McpEndpoint> {\n const client = await getContextClient(undefined, organizationId)\n return client.context.mcpEndpoints.edit({...params, name})\n}\n\n/**\n * Delete an MCP endpoint\n */\nexport async function deleteMcpEndpoint(organizationId: string, name: string): Promise<void> {\n const client = await getContextClient(undefined, organizationId)\n await client.context.mcpEndpoints.delete({name})\n}\n\n/**\n * Check whether an agent connecting with the current credentials can use an MCP endpoint\n */\nexport async function getMcpEndpointStatus(\n organizationId: string,\n name: string,\n): Promise<Context.McpEndpointStatus> {\n const client = await getContextClient(undefined, organizationId)\n return client.context.mcpEndpoints.status({name})\n}\n"],"names":["getGlobalCliClient","subdebug","EXPERIMENTAL_API_WARNING","isHttpError","CONTEXT_API_VERSION","BLUEPRINTS_API_VERSION","BLUEPRINTS_LOOKUP_TIMEOUT_MS","MCP_CONNECT_API_VERSION","blueprintOwnershipDebug","getContextClient","knowledgeBaseId","organizationId","apiVersion","requireUser","undefined","resource","id","type","context","getContextStoreClient","publicId","getKnowledgeBase","createKnowledgeBase","params","client","knowledgeBases","create","listKnowledgeBases","cursor","page","list","push","data","nextCursor","get","updateKnowledgeBase","edit","describeBlueprintManager","stackName","getKnowledgeBaseBlueprintOwnership","getBlueprintOwnership","getMcpEndpointBlueprintOwnership","resolveResource","managed","ignoreWarnings","maxRetries","timeout","headers","matches","request","query","url","stackId","find","match","encodeURIComponent","then","stack","name","catch","error","statusCode","errorCode","body","response","deleteKnowledgeBase","delete","createImport","imports","listImports","getImport","importId","downloadImport","download","deleteImport","buildKnowledgeBase","build","cancelKnowledgeBaseBuild","cancelBuild","refreshKnowledgeBase","refresh","getJob","jobId","jobs","listIssues","status","issues","getIssue","issueId","resolveIssue","resolution","resolve","dismissIssue","dismiss","reopenIssue","reopen","applyIssues","issueIds","apply","listEntries","entries","getEntry","path","rebuildEntry","rebuild","queryContext","fetch","listMcpEndpoints","docs","mcpEndpoints","connectClient","withConfig","map","doc","toMcpEndpoint","getMcpEndpoint","nameOrId","org","createdAt","_createdAt","groqFilter","instructions","sources","title","updatedAt","_updatedAt","getUrl","createMcpEndpoint","updateMcpEndpoint","deleteMcpEndpoint","getMcpEndpointStatus"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,QAAQ,QAAO,mBAAkB;AAC7D,SAAsBC,wBAAwB,EAA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CAACxB,MAAM,CAAC;QAAC3B;IAAI;AACjD"}
|
|
1
|
+
{"version":3,"sources":["../../src/services/context.ts"],"sourcesContent":["import {getGlobalCliClient, subdebug} from '@sanity/cli-core'\nimport {type Context, EXPERIMENTAL_API_WARNING, isHttpError} from '@sanity/client'\n\nconst CONTEXT_API_VERSION = 'v2026-08-25'\nconst BLUEPRINTS_API_VERSION = 'vX'\nconst BLUEPRINTS_LOOKUP_TIMEOUT_MS = 5000\n// The version in the URLs the Context API returns for agents to connect to MCP endpoints\nconst MCP_CONNECT_API_VERSION = 'v2026-11-03'\n// Documents per page while a GROQ list read drains the store\nconst STORE_PAGE_SIZE = 200\nconst MCP_LIST_LIMIT = 500\n\nconst blueprintOwnershipDebug = subdebug('context:blueprint-ownership')\n\n/** A knowledge base */\nexport type KnowledgeBase = Context.Response<'GET /knowledge-bases/{knowledgeBaseId}'>\n/** An async job: a build, an update or a `files` sync */\nexport type Job = Context.Response<'GET /knowledge-bases/{knowledgeBaseId}/jobs/{jobId}'>\n/** One run of a source's connector */\nexport type Sync =\n Context.Response<'GET /knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}'>\n\n/** The request a command builds: path parameters, query and body */\nexport interface ContextRequest {\n body?: unknown\n params?: Record<string, string>\n query?: Record<string, string>\n}\n\ntype Page = {data: unknown[]; nextCursor: string | null}\n\nfunction isPage(value: unknown): value is Page {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'data' in value &&\n Array.isArray(value.data) &&\n 'nextCursor' in value\n )\n}\n\nasync function getContextClient(organizationId?: string) {\n return getGlobalCliClient({\n apiVersion: CONTEXT_API_VERSION,\n requireUser: true,\n ...(organizationId === undefined ? {} : {context: {organizationId}}),\n })\n}\n\n/**\n * Call a Context API operation by its route. Commands build requests at\n * runtime from the spec, so this is the one place the route-typed client call\n * is loosened to a runtime route and request.\n */\nexport async function requestContext(\n route: Context.Route,\n request: ContextRequest = {},\n): Promise<unknown> {\n const client = await getContextClient()\n const call = client.context.request as (route: string, init: ContextRequest) => Promise<unknown>\n return call.call(client.context, route, request)\n}\n\n/**\n * Call a paginated list operation and drain its pages into one list, asking\n * for `pageSize` items a page. A `limit` in the query caps the total instead of\n * one page, so the list stops once it has that many.\n */\nexport async function requestAllPages(\n route: Context.Route,\n request: ContextRequest = {},\n pageSize?: number,\n): Promise<unknown[]> {\n const {limit, ...query} = request.query ?? {}\n const total = limit === undefined ? undefined : Number(limit)\n const items: unknown[] = []\n let cursor: string | undefined\n do {\n const remaining = total === undefined ? undefined : total - items.length\n const size = remaining === undefined ? pageSize : Math.min(pageSize ?? remaining, remaining)\n const page = await requestContext(route, {\n ...request,\n query: {...query, ...(size !== undefined && {limit: String(size)}), ...(cursor && {cursor})},\n })\n if (!isPage(page)) throw new Error(`${route} answered with something other than a page`)\n items.push(...page.data)\n cursor = page.nextCursor ?? undefined\n } while (cursor !== undefined && (total === undefined || items.length < total))\n return total === undefined ? items : items.slice(0, total)\n}\n\n/** A document's content as the bytes its source gave (`format: 'raw'`) */\nexport async function getDocumentBytes(request: ContextRequest): Promise<Uint8Array> {\n const client = await getContextClient()\n const call = client.context.requestBytes as (\n route: string,\n init: ContextRequest,\n ) => Promise<Uint8Array>\n return call.call(\n client.context,\n 'GET /knowledge-bases/{knowledgeBaseId}/documents/{documentId}/content',\n request,\n )\n}\n\n/** Get a knowledge base */\nasync function getKnowledgeBase(knowledgeBaseId: string): Promise<KnowledgeBase> {\n const client = await getContextClient()\n return client.context.request('GET /knowledge-bases/{knowledgeBaseId}', {\n params: {knowledgeBaseId},\n })\n}\n\n/** Get a source, with its latest sync */\nexport async function getSource(\n knowledgeBaseId: string,\n sourceId: string,\n): Promise<Context.Source> {\n const client = await getContextClient()\n return client.context.request('GET /knowledge-bases/{knowledgeBaseId}/sources/{sourceId}', {\n params: {knowledgeBaseId, sourceId},\n })\n}\n\n/** Get a sync of a source by ID */\nexport async function getSync(\n knowledgeBaseId: string,\n sourceId: string,\n syncId: string,\n): Promise<Sync> {\n const client = await getContextClient()\n return client.context.request(\n 'GET /knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}',\n {params: {knowledgeBaseId, sourceId, syncId}},\n )\n}\n\n/** Get a job by ID */\nexport async function getJob(knowledgeBaseId: string, jobId: string): Promise<Job> {\n const client = await getContextClient()\n return client.context.request('GET /knowledge-bases/{knowledgeBaseId}/jobs/{jobId}', {\n params: {jobId, knowledgeBaseId},\n })\n}\n\n/**\n * Add a `files` source holding a local file: add the source, upload the file\n * and sync it. Resolves with the source as created and the sync's `jobId`.\n */\nexport async function createFileSource(\n knowledgeBaseId: string,\n params: Omit<Context.CreateFileSourceParams, 'knowledgeBaseId'>,\n): Promise<{source: Context.Source; sync: Context.SyncAccepted}> {\n const client = await getContextClient()\n return client.context.createFileSource({...params, knowledgeBaseId})\n}\n\n/** Upload a file to a `files` source, replacing the file it holds, and sync it */\nexport async function uploadSourceFile(\n knowledgeBaseId: string,\n sourceId: string,\n upload: Context.FileUpload,\n): Promise<Context.SyncAccepted> {\n const client = await getContextClient()\n return client.context.uploadFile({...upload, knowledgeBaseId, sourceId})\n}\n\n/** Run a GROQ query against an organization's Context documents */\nexport async function queryContext(\n organizationId: string,\n query: string,\n params?: Record<string, unknown>,\n): Promise<unknown> {\n const client = await getContextClient(organizationId)\n return client.context.fetch(query, params)\n}\n\n/**\n * GROQ reads of a knowledge base's documents query the organization's document\n * store, where documents are keyed by the knowledge base's public ID. Fetching\n * the knowledge base resolves both, whichever of its IDs was passed.\n */\nasync function getStoreScope(knowledgeBaseId: string) {\n const {organizationId, publicId} = await getKnowledgeBase(knowledgeBaseId)\n return {client: await getContextClient(organizationId), kb: publicId}\n}\n\n/** Drain a `(_createdAt, _id)`-keyset GROQ read */\nasync function drainByCreatedAt<T extends {_createdAt: string; _id: string}>(\n organizationId: string,\n filter: string,\n params: Record<string, unknown>,\n): Promise<T[]> {\n const client = await getContextClient(organizationId)\n const all: T[] = []\n let cursor: {c: string; i: string} | undefined\n for (;;) {\n const paged = cursor\n ? `${filter} && (_createdAt > $c || (_createdAt == $c && _id > $i))`\n : filter\n const page = await client.context.fetch<T[]>(\n `*[${paged}] | order(_createdAt asc, _id asc) [0...${STORE_PAGE_SIZE}]`,\n {...params, ...cursor},\n )\n all.push(...page)\n if (page.length < STORE_PAGE_SIZE) return all\n const last = page.at(-1)!\n cursor = {c: last._createdAt, i: last._id}\n }\n}\n\n/** The fields `entries list` shows of each entry */\nexport type EntrySummary = Pick<Context.EntryDoc, '_id' | 'path' | 'status' | 'title' | 'tldr'>\n\n/** List all entries of a knowledge base, path-ordered, without bodies */\nexport async function listEntries(knowledgeBaseId: string): Promise<EntrySummary[]> {\n const {client, kb} = await getStoreScope(knowledgeBaseId)\n const all: EntrySummary[] = []\n let after = ''\n for (;;) {\n const page = await client.context.fetch<EntrySummary[]>(\n `*[_type == \"sanity.context.entry\" && knowledgeBaseId == $kb && path > $after] | order(path asc) [0...${STORE_PAGE_SIZE}] {_id, path, title, tldr, status}`,\n {after, kb},\n )\n all.push(...page)\n if (page.length < STORE_PAGE_SIZE) return all\n after = page.at(-1)!.path\n }\n}\n\n/** Get an entry with its body and citations by outline path, or `null` when no entry sits there */\nexport async function getEntry(\n knowledgeBaseId: string,\n path: string,\n): Promise<Context.EntryDoc | null> {\n const {client, kb} = await getStoreScope(knowledgeBaseId)\n return client.context.fetch<Context.EntryDoc | null>(\n '*[_type == \"sanity.context.entry\" && knowledgeBaseId == $kb && path == $path][0]',\n {kb, path},\n )\n}\n\n/** List all issues of a knowledge base, optionally only those in one status */\nexport async function listIssues(\n knowledgeBaseId: string,\n status?: Context.IssueDoc['status'],\n): Promise<Context.IssueDoc[]> {\n const {organizationId, publicId} = await getKnowledgeBase(knowledgeBaseId)\n const filter = `_type == \"sanity.context.issue\" && knowledgeBaseId == $kb${status === undefined ? '' : ' && status == $status'}`\n return drainByCreatedAt<Context.IssueDoc>(organizationId, filter, {\n kb: publicId,\n ...(status !== undefined && {status}),\n })\n}\n\n/** Get an issue by ID, or `null` when it doesn't exist */\nexport async function getIssue(\n knowledgeBaseId: string,\n issueId: string,\n): Promise<Context.IssueDoc | null> {\n const {client, kb} = await getStoreScope(knowledgeBaseId)\n return client.context.fetch<Context.IssueDoc | null>(\n '*[_type == \"sanity.context.issue\" && knowledgeBaseId == $kb && _id == $id][0]',\n {id: issueId, kb},\n )\n}\n\n/** The configuration of an MCP endpoint, as create and update return it */\nexport type McpEndpoint = Context.Response<'POST /organizations/{organizationId}/mcp'>\n\n/** List an organization's MCP endpoints, oldest first */\nexport async function listMcpEndpoints(organizationId: string): Promise<McpEndpoint[]> {\n const client = await getContextClient(organizationId)\n const docs = await client.context.fetch<Context.McpDoc[]>(\n `*[_type == \"sanity.context.mcp\" && organizationId == $org] | order(_createdAt asc, _id asc) [0...${MCP_LIST_LIMIT}]`,\n {org: organizationId},\n )\n const connectClient = client.withConfig({apiVersion: MCP_CONNECT_API_VERSION})\n return docs.map((doc) => toMcpEndpoint(connectClient, doc))\n}\n\n/**\n * Get an MCP endpoint by name or ID, or `null` when the organization has none.\n * Update and delete accept either, so the lookups guarding them must too.\n */\nexport async function getMcpEndpoint(\n organizationId: string,\n nameOrId: string,\n): Promise<McpEndpoint | null> {\n const client = await getContextClient(organizationId)\n const doc = await client.context.fetch<Context.McpDoc | null>(\n '*[_type == \"sanity.context.mcp\" && organizationId == $org && (name == $nameOrId || publicId == $nameOrId)][0]',\n {nameOrId, org: organizationId},\n )\n return doc && toMcpEndpoint(client.withConfig({apiVersion: MCP_CONNECT_API_VERSION}), doc)\n}\n\n/**\n * The stored configuration in the shape create and edit return, so every command outputs the\n * same fields. The URL isn't stored, so it is built from the same route and API version.\n */\nfunction toMcpEndpoint(\n connectClient: {getUrl: (uri: string) => string},\n doc: Context.McpDoc,\n): McpEndpoint {\n return {\n createdAt: doc._createdAt,\n groqFilter: doc.groqFilter ?? null,\n id: doc.publicId,\n instructions: doc.instructions ?? null,\n lastUsedAt: doc.lastUsedAt ?? null,\n name: doc.name,\n organizationId: doc.organizationId,\n sources: doc.sources,\n title: doc.title,\n updatedAt: doc._updatedAt,\n url: connectClient.getUrl(\n `/context/organizations/${encodeURIComponent(doc.organizationId)}/mcp/${encodeURIComponent(doc.name)}`,\n ),\n }\n}\n\n/** Create an MCP endpoint */\nexport async function createMcpEndpoint(\n organizationId: string,\n body: Context.Body<'POST /organizations/{organizationId}/mcp'>,\n): Promise<McpEndpoint> {\n const client = await getContextClient()\n return client.context.request('POST /organizations/{organizationId}/mcp', {\n body,\n params: {organizationId},\n })\n}\n\n/** Update an MCP endpoint's configuration */\nexport async function updateMcpEndpoint(\n organizationId: string,\n name: string,\n body: Context.Body<'PATCH /organizations/{organizationId}/mcp/{mcpEndpoint}'>,\n): Promise<McpEndpoint> {\n const client = await getContextClient()\n return client.context.request('PATCH /organizations/{organizationId}/mcp/{mcpEndpoint}', {\n body,\n params: {mcpEndpoint: name, organizationId},\n })\n}\n\n/** Delete an MCP endpoint */\nexport async function deleteMcpEndpoint(organizationId: string, name: string): Promise<void> {\n const client = await getContextClient()\n await client.context.request('DELETE /organizations/{organizationId}/mcp/{mcpEndpoint}', {\n params: {mcpEndpoint: name, organizationId},\n })\n}\n\n/** The checks of whether agents can use an MCP endpoint */\nexport type McpEndpointStatus =\n Context.Response<'GET /organizations/{organizationId}/mcp/{mcpEndpoint}/status'>\n\n/** Check whether an agent connecting with the current credentials can use an MCP endpoint */\nexport async function getMcpEndpointStatus(\n organizationId: string,\n name: string,\n): Promise<McpEndpointStatus> {\n const client = await getContextClient()\n return client.context.request('GET /organizations/{organizationId}/mcp/{mcpEndpoint}/status', {\n params: {mcpEndpoint: name, organizationId},\n })\n}\n\n/**\n * `stackName` is `null` when the caller can't read Blueprints: the search then\n * only says whether a blueprint manages the resource.\n */\nexport type BlueprintOwnership = {managed: false} | {managed: true; stackName: string | null}\n\n/**\n * Who manages a resource, for refusal messages: the stack by name when the caller can read it\n */\nexport function describeBlueprintManager(stackName: string | null): string {\n return stackName ? `The blueprint stack \"${stackName}\"` : 'A blueprint'\n}\n\n/**\n * Whether a live blueprint stack manages the knowledge base\n */\nexport function getKnowledgeBaseBlueprintOwnership(\n knowledgeBaseId: string,\n): Promise<BlueprintOwnership> {\n return getBlueprintOwnership('sanity.context.knowledge-base', async () => {\n const {organizationId, publicId} = await getKnowledgeBase(knowledgeBaseId)\n return {organizationId, publicId}\n })\n}\n\n/**\n * Whether a live blueprint stack manages the MCP endpoint\n */\nexport function getMcpEndpointBlueprintOwnership(\n organizationId: string,\n {id}: Pick<McpEndpoint, 'id'>,\n): Promise<BlueprintOwnership> {\n return getBlueprintOwnership('sanity.context.mcp', async () => ({organizationId, publicId: id}))\n}\n\n/**\n * Looks the resource up in the Blueprints resource search. Fails open: a\n * failed lookup answers not managed, so a Blueprints outage never blocks a\n * command. A resource that doesn't exist isn't managed either.\n */\nasync function getBlueprintOwnership(\n type: string,\n resolveResource: () => Promise<{organizationId: string; publicId: string} | null>,\n): Promise<BlueprintOwnership> {\n try {\n const resource = await resolveResource()\n if (!resource) return {managed: false}\n const {organizationId, publicId} = resource\n const client = await getGlobalCliClient({\n apiVersion: BLUEPRINTS_API_VERSION,\n // The Blueprints API has no stable version yet, and the warning would interrupt command output.\n // The client splits the warning header on commas, so its second clause is matched separately.\n ignoreWarnings: [EXPERIMENTAL_API_WARNING, 'which will change without warning'],\n // The lookup fails open, so an unreachable Blueprints API must not hold the command for the client's defaults.\n maxRetries: 0,\n requireUser: true,\n timeout: BLUEPRINTS_LOOKUP_TIMEOUT_MS,\n })\n const headers = {\n 'x-sanity-scope-id': organizationId,\n 'x-sanity-scope-type': 'organization',\n }\n const matches = await client.request<{stackId?: string}[]>({\n headers,\n query: {id: publicId, type},\n url: '/blueprints/resources/search',\n })\n const stackId = matches.find((match) => typeof match.stackId === 'string')?.stackId\n if (!stackId) return {managed: false}\n const stackName = await client\n .request<{name?: string}>({\n headers,\n url: `/blueprints/stacks/${encodeURIComponent(stackId)}`,\n })\n .then((stack) => stack.name ?? null)\n .catch(() => null)\n return {managed: true, stackName}\n } catch (error) {\n if (isHttpError(error)) {\n if (error.statusCode === 403 && errorCode(error) === 'RESOURCE_MANAGED') {\n return {managed: true, stackName: null}\n }\n if (error.statusCode === 404 && errorCode(error) === 'RESOURCE_NOT_MANAGED') {\n return {managed: false}\n }\n }\n blueprintOwnershipDebug('Blueprint ownership lookup failed, treating as not managed', error)\n return {managed: false}\n }\n}\n\nfunction errorCode(error: {response: {body: unknown}}): unknown {\n const {body} = error.response\n return body && typeof body === 'object' && 'errorCode' in body ? body.errorCode : undefined\n}\n"],"names":["getGlobalCliClient","subdebug","EXPERIMENTAL_API_WARNING","isHttpError","CONTEXT_API_VERSION","BLUEPRINTS_API_VERSION","BLUEPRINTS_LOOKUP_TIMEOUT_MS","MCP_CONNECT_API_VERSION","STORE_PAGE_SIZE","MCP_LIST_LIMIT","blueprintOwnershipDebug","isPage","value","Array","isArray","data","getContextClient","organizationId","apiVersion","requireUser","undefined","context","requestContext","route","request","client","call","requestAllPages","pageSize","limit","query","total","Number","items","cursor","remaining","length","size","Math","min","page","String","Error","push","nextCursor","slice","getDocumentBytes","requestBytes","getKnowledgeBase","knowledgeBaseId","params","getSource","sourceId","getSync","syncId","getJob","jobId","createFileSource","uploadSourceFile","upload","uploadFile","queryContext","fetch","getStoreScope","publicId","kb","drainByCreatedAt","filter","all","paged","last","at","c","_createdAt","i","_id","listEntries","after","path","getEntry","listIssues","status","getIssue","issueId","id","listMcpEndpoints","docs","org","connectClient","withConfig","map","doc","toMcpEndpoint","getMcpEndpoint","nameOrId","createdAt","groqFilter","instructions","lastUsedAt","name","sources","title","updatedAt","_updatedAt","url","getUrl","encodeURIComponent","createMcpEndpoint","body","updateMcpEndpoint","mcpEndpoint","deleteMcpEndpoint","getMcpEndpointStatus","describeBlueprintManager","stackName","getKnowledgeBaseBlueprintOwnership","getBlueprintOwnership","getMcpEndpointBlueprintOwnership","type","resolveResource","resource","managed","ignoreWarnings","maxRetries","timeout","headers","matches","stackId","find","match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AmBqB,UAAU;QAC1D,GACCG,IAAI,CAAC,CAACC,QAAUA,MAAMhC,IAAI,IAAI,MAC9BiC,KAAK,CAAC,IAAM;QACf,OAAO;YAACX,SAAS;YAAMP;QAAS;IAClC,EAAE,OAAOmB,OAAO;QACd,IAAIlI,YAAYkI,QAAQ;YACtB,IAAIA,MAAMC,UAAU,KAAK,OAAOC,UAAUF,WAAW,oBAAoB;gBACvE,OAAO;oBAACZ,SAAS;oBAAMP,WAAW;gBAAI;YACxC;YACA,IAAImB,MAAMC,UAAU,KAAK,OAAOC,UAAUF,WAAW,wBAAwB;gBAC3E,OAAO;oBAACZ,SAAS;gBAAK;YACxB;QACF;QACA/G,wBAAwB,8DAA8D2H;QACtF,OAAO;YAACZ,SAAS;QAAK;IACxB;AACF;AAEA,SAASc,UAAUF,KAAkC;IACnD,MAAM,EAACzB,IAAI,EAAC,GAAGyB,MAAMG,QAAQ;IAC7B,OAAO5B,QAAQ,OAAOA,SAAS,YAAY,eAAeA,OAAOA,KAAK2B,SAAS,GAAGnH;AACpF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { contextCommandTable } from '../../actions/context/commandTable.js';
|
|
1
2
|
// Command paths only: positional user input must never become command identity.
|
|
2
3
|
const commandPaths = new Set([
|
|
3
4
|
'api',
|
|
@@ -25,26 +26,12 @@ const commandPaths = new Set([
|
|
|
25
26
|
'build',
|
|
26
27
|
'check',
|
|
27
28
|
'codemod',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'context delete',
|
|
29
|
+
// Generated context commands come from the command table
|
|
30
|
+
...contextCommandTable.map((entry)=>entry.id),
|
|
31
31
|
'context entries get',
|
|
32
32
|
'context entries list',
|
|
33
|
-
'context entries rebuild',
|
|
34
|
-
'context get',
|
|
35
|
-
'context imports create',
|
|
36
|
-
'context imports delete',
|
|
37
|
-
'context imports download',
|
|
38
|
-
'context imports get',
|
|
39
|
-
'context imports list',
|
|
40
|
-
'context issues apply',
|
|
41
|
-
'context issues dismiss',
|
|
42
33
|
'context issues get',
|
|
43
34
|
'context issues list',
|
|
44
|
-
'context issues reopen',
|
|
45
|
-
'context issues resolve',
|
|
46
|
-
'context jobs get',
|
|
47
|
-
'context list',
|
|
48
35
|
'context mcp create',
|
|
49
36
|
'context mcp delete',
|
|
50
37
|
'context mcp get',
|
|
@@ -52,8 +39,6 @@ const commandPaths = new Set([
|
|
|
52
39
|
'context mcp status',
|
|
53
40
|
'context mcp update',
|
|
54
41
|
'context query',
|
|
55
|
-
'context refresh',
|
|
56
|
-
'context update',
|
|
57
42
|
'cors add',
|
|
58
43
|
'cors delete',
|
|
59
44
|
'cors list',
|
|
@@ -179,10 +164,17 @@ const commandPaths = new Set([
|
|
|
179
164
|
'whoami',
|
|
180
165
|
'workflows abort',
|
|
181
166
|
'workflows blueprint generate',
|
|
167
|
+
'workflows blueprints generate',
|
|
182
168
|
'workflows definition delete',
|
|
183
169
|
'workflows definition diff',
|
|
184
170
|
'workflows definition list',
|
|
171
|
+
'workflows definitions delete',
|
|
172
|
+
'workflows definitions diff',
|
|
185
173
|
'workflows definition show',
|
|
174
|
+
'workflows definitions list',
|
|
175
|
+
'workflows definitions show',
|
|
176
|
+
'workflows definitions validate',
|
|
177
|
+
'workflows definition validate',
|
|
186
178
|
'workflows deploy',
|
|
187
179
|
'workflows diagnose',
|
|
188
180
|
'workflows fire-action',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/util/telemetry/cliCommandIdentity.ts"],"sourcesContent":["// Command paths only: positional user input must never become command identity.\nconst commandPaths = new Set([\n 'api',\n 'assets upload',\n 'backup disable',\n 'backup download',\n 'backup enable',\n 'backup list',\n 'backups disable',\n 'backups download',\n 'backups enable',\n 'backups list',\n 'blueprints add',\n 'blueprints config',\n 'blueprints deploy',\n 'blueprints destroy',\n 'blueprints doctor',\n 'blueprints info',\n 'blueprints init',\n 'blueprints logs',\n 'blueprints mint-deploy-token',\n 'blueprints plan',\n 'blueprints promote',\n 'blueprints stacks',\n 'build',\n 'check',\n 'codemod',\n
|
|
1
|
+
{"version":3,"sources":["../../../src/util/telemetry/cliCommandIdentity.ts"],"sourcesContent":["import {contextCommandTable} from '../../actions/context/commandTable.js'\n\n// Command paths only: positional user input must never become command identity.\nconst commandPaths = new Set([\n 'api',\n 'assets upload',\n 'backup disable',\n 'backup download',\n 'backup enable',\n 'backup list',\n 'backups disable',\n 'backups download',\n 'backups enable',\n 'backups list',\n 'blueprints add',\n 'blueprints config',\n 'blueprints deploy',\n 'blueprints destroy',\n 'blueprints doctor',\n 'blueprints info',\n 'blueprints init',\n 'blueprints logs',\n 'blueprints mint-deploy-token',\n 'blueprints plan',\n 'blueprints promote',\n 'blueprints stacks',\n 'build',\n 'check',\n 'codemod',\n // Generated context commands come from the command table\n ...contextCommandTable.map((entry) => entry.id),\n 'context entries get',\n 'context entries list',\n 'context issues get',\n 'context issues list',\n 'context mcp create',\n 'context mcp delete',\n 'context mcp get',\n 'context mcp list',\n 'context mcp status',\n 'context mcp update',\n 'context query',\n 'cors add',\n 'cors delete',\n 'cors list',\n 'dataset alias create',\n 'dataset alias delete',\n 'dataset alias link',\n 'dataset alias unlink',\n 'dataset copy',\n 'dataset create',\n 'dataset delete',\n 'dataset export',\n 'dataset import',\n 'dataset list',\n 'datasets alias create',\n 'datasets alias delete',\n 'datasets alias link',\n 'datasets alias unlink',\n 'datasets copy',\n 'datasets create',\n 'datasets delete',\n 'datasets embeddings disable',\n 'datasets embeddings enable',\n 'datasets embeddings status',\n 'datasets export',\n 'datasets import',\n 'datasets list',\n 'datasets visibility get',\n 'datasets visibility set',\n 'dataset visibility get',\n 'dataset visibility set',\n 'debug',\n 'deploy',\n 'dev',\n 'docs browse',\n 'docs read',\n 'docs search',\n 'doctor',\n 'documents create',\n 'documents delete',\n 'documents get',\n 'documents query',\n 'documents validate',\n 'exec',\n 'functions add',\n 'functions build',\n 'functions deploy',\n 'functions dev',\n 'functions env add',\n 'functions env list',\n 'functions env remove',\n 'functions list',\n 'functions logs',\n 'functions test',\n 'graphql deploy',\n 'graphql list',\n 'graphql undeploy',\n 'help',\n 'hook list',\n 'hooks attempt',\n 'hooks create',\n 'hooks delete',\n 'hooks list',\n 'hooks logs',\n 'init',\n 'init plugin',\n 'install',\n 'learn',\n 'login',\n 'logout',\n 'manage',\n 'manifest extract',\n 'mcp configure',\n 'media create-aspect',\n 'media delete-aspect',\n 'media deploy-aspect',\n 'media export',\n 'media import',\n 'media prune-aspect-data',\n 'media pull-aspects',\n 'migration create',\n 'migration list',\n 'migration run',\n 'migrations create',\n 'migrations list',\n 'migrations run',\n 'new',\n 'openapi get',\n 'openapi list',\n 'organizations create',\n 'organizations delete',\n 'organizations get',\n 'organizations list',\n 'organizations update',\n 'preview',\n 'projects create',\n 'projects list',\n 'projects unclaimed',\n 'schema delete',\n 'schema deploy',\n 'schema extract',\n 'schema list',\n 'schemas delete',\n 'schemas deploy',\n 'schemas extract',\n 'schemas list',\n 'schemas validate',\n 'schema validate',\n 'skills install',\n 'telemetry disable',\n 'telemetry enable',\n 'telemetry status',\n 'tokens create',\n 'tokens delete',\n 'tokens list',\n 'tokens rotate',\n 'typegen generate',\n 'undeploy',\n 'uninstall',\n 'upgrade',\n 'users invite',\n 'users list',\n 'versions',\n 'whoami',\n 'workflows abort',\n 'workflows blueprint generate',\n 'workflows blueprints generate',\n 'workflows definition delete',\n 'workflows definition diff',\n 'workflows definition list',\n 'workflows definitions delete',\n 'workflows definitions diff',\n 'workflows definition show',\n 'workflows definitions list',\n 'workflows definitions show',\n 'workflows definitions validate',\n 'workflows definition validate',\n 'workflows deploy',\n 'workflows diagnose',\n 'workflows fire-action',\n 'workflows list',\n 'workflows nuke',\n 'workflows reset-activity',\n 'workflows set-stage',\n 'workflows show',\n 'workflows start',\n 'workflows tail',\n])\n\nconst knownRoots = new Set([...commandPaths].map((path) => path.split(' ')[0]))\n\nexport function commandIdentity(group: unknown, args: unknown) {\n const root = typeof group === 'string' ? group.split(':') : []\n const parts = [...root, ...(Array.isArray(args) ? args : [])]\n if (!knownRoots.has(root[0])) return {commandArguments: [], groupOrCommand: 'unknown'}\n\n let commandArguments: string[] = []\n for (let length = 2; length <= Math.min(parts.length, 4); length++) {\n const candidate = parts.slice(0, length)\n if (!candidate.every((part) => typeof part === 'string')) break\n if (commandPaths.has(candidate.join(' '))) commandArguments = candidate.slice(1)\n }\n return {commandArguments, groupOrCommand: root[0]}\n}\n"],"names":["contextCommandTable","commandPaths","Set","map","entry","id","knownRoots","path","split","commandIdentity","group","args","root","parts","Array","isArray","has","commandArguments","groupOrCommand","length","Math","min","candidate","slice","every","part","join"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,wCAAuC;AAEzE,gFAAgF;AAChF,MAAMC,eAAe,IAAIC,IAAI;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,yDAAyD;OACtDF,oBAAoBG,GAAG,CAAC,CAACC,QAAUA,MAAMC,EAAE;IAC9C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,aAAa,IAAIJ,IAAI;OAAID;CAAa,CAACE,GAAG,CAAC,CAACI,OAASA,KAAKC,KAAK,CAAC,IAAI,CAAC,EAAE;AAE7E,OAAO,SAASC,gBAAgBC,KAAc,EAAEC,IAAa;IAC3D,MAAMC,OAAO,OAAOF,UAAU,WAAWA,MAAMF,KAAK,CAAC,OAAO,EAAE;IAC9D,MAAMK,QAAQ;WAAID;WAAUE,MAAMC,OAAO,CAACJ,QAAQA,OAAO,EAAE;KAAE;IAC7D,IAAI,CAACL,WAAWU,GAAG,CAACJ,IAAI,CAAC,EAAE,GAAG,OAAO;QAACK,kBAAkB,EAAE;QAAEC,gBAAgB;IAAS;IAErF,IAAID,mBAA6B,EAAE;IACnC,IAAK,IAAIE,SAAS,GAAGA,UAAUC,KAAKC,GAAG,CAACR,MAAMM,MAAM,EAAE,IAAIA,SAAU;QAClE,MAAMG,YAAYT,MAAMU,KAAK,CAAC,GAAGJ;QACjC,IAAI,CAACG,UAAUE,KAAK,CAAC,CAACC,OAAS,OAAOA,SAAS,WAAW;QAC1D,IAAIxB,aAAae,GAAG,CAACM,UAAUI,IAAI,CAAC,OAAOT,mBAAmBK,UAAUC,KAAK,CAAC;IAChF;IACA,OAAO;QAACN;QAAkBC,gBAAgBN,IAAI,CAAC,EAAE;IAAA;AACnD"}
|