@sanity/cli 8.26.0 → 8.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1534 -411
- 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 +165 -0
- package/dist/actions/context/mcpEndpoint.js.map +1 -0
- 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/resolveOrganizationId.js +8 -1
- package/dist/actions/context/resolveOrganizationId.js.map +1 -1
- 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/commands/context/build.js +19 -81
- package/dist/commands/context/build.js.map +1 -1
- package/dist/commands/context/create.js +3 -104
- 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/list.js +0 -5
- package/dist/commands/context/issues/list.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 -103
- package/dist/commands/context/list.js.map +1 -1
- package/dist/commands/context/mcp/create.js +152 -0
- package/dist/commands/context/mcp/create.js.map +1 -0
- package/dist/commands/context/mcp/delete.js +82 -0
- package/dist/commands/context/mcp/delete.js.map +1 -0
- package/dist/commands/context/mcp/get.js +42 -0
- package/dist/commands/context/mcp/get.js.map +1 -0
- 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 +87 -0
- package/dist/commands/context/mcp/list.js.map +1 -0
- package/dist/commands/context/mcp/status.js +98 -0
- package/dist/commands/context/mcp/status.js.map +1 -0
- package/dist/commands/context/mcp/update.js +225 -0
- package/dist/commands/context/mcp/update.js.map +1 -0
- package/dist/commands/context/query.js +6 -14
- package/dist/commands/context/query.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 +47 -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/prompts/promptForText.js +12 -0
- package/dist/prompts/promptForText.js.map +1 -0
- package/dist/services/context.js +276 -202
- package/dist/services/context.js.map +1 -1
- package/dist/util/sharedFlags.js.map +1 -1
- package/dist/util/telemetry/cliCommandIdentity.js +16 -18
- package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
- package/oclif.config.js +1 -1
- package/oclif.manifest.json +4854 -2834
- package/package.json +20 -19
- 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/commands/context/issues/reopen.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/issues/reopen.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ReopenIssueCommand = contextCommand('context issues reopen')\n"],"names":["contextCommand","ReopenIssueCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,yBAAwB"}
|
|
@@ -1,111 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { exitCodes
|
|
3
|
-
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { exitCodes } from '@sanity/cli-core';
|
|
4
3
|
import { requiredWhenUnattended } from '@sanity/cli-core/flags';
|
|
5
4
|
import { select } from '@sanity/cli-core/ux';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
knowledgeBaseId: Args.string({
|
|
14
|
-
description: 'Knowledge base ID',
|
|
15
|
-
required: true
|
|
16
|
-
}),
|
|
17
|
-
// eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first
|
|
18
|
-
issueId: Args.string({
|
|
19
|
-
description: 'Issue ID',
|
|
20
|
-
required: true
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
static description = 'Resolve a conflict issue by choosing the correct side\n\nResolving also creates a standing instruction that future builds follow. `sanity context issues reopen` removes it.';
|
|
5
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
6
|
+
import { getIssue } from '../../../services/context.js';
|
|
7
|
+
const BaseCommand = contextCommand('context issues resolve');
|
|
8
|
+
/**
|
|
9
|
+
* `context issues resolve` keeps `--side`, and without it, asks which side of
|
|
10
|
+
* the conflict is correct, listing the sides from the issue document
|
|
11
|
+
*/ export class ResolveIssueCommand extends BaseCommand {
|
|
24
12
|
static examples = [
|
|
25
13
|
{
|
|
26
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue
|
|
27
|
-
description: '
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456 --side 1 --watch',
|
|
31
|
-
description: 'Choose side 1 and wait for the entry to be rewritten'
|
|
14
|
+
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue-def456',
|
|
15
|
+
description: 'Choose the correct side interactively'
|
|
32
16
|
},
|
|
33
17
|
{
|
|
34
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue
|
|
35
|
-
description: '
|
|
18
|
+
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue-def456 --side 1 --watch',
|
|
19
|
+
description: 'Choose side 1 and wait for the entry rewrite'
|
|
36
20
|
}
|
|
37
21
|
];
|
|
38
22
|
static flags = {
|
|
23
|
+
...BaseCommand.flags,
|
|
39
24
|
side: requiredWhenUnattended(Flags.integer({
|
|
40
25
|
description: 'Index of the correct side, as listed by `sanity context issues get`',
|
|
41
26
|
min: 0
|
|
42
|
-
}))
|
|
43
|
-
watch: Flags.boolean({
|
|
44
|
-
default: false,
|
|
45
|
-
description: 'Wait for the entry rewrite to finish, exiting non-zero if it fails'
|
|
46
|
-
})
|
|
27
|
+
}))
|
|
47
28
|
};
|
|
48
|
-
async
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
resolved = await resolveIssue(knowledgeBaseId, issueId, side);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
resolveIssueDebug('Error resolving issue', error);
|
|
57
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
58
|
-
this.error(`Issue "${issueId}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
59
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
60
|
-
});
|
|
29
|
+
async send(request, values) {
|
|
30
|
+
const side = typeof values.side === 'number' ? values.side : await this.promptForSide(request.params.knowledgeBaseId, request.params.issueId);
|
|
31
|
+
return super.send({
|
|
32
|
+
...request,
|
|
33
|
+
body: {
|
|
34
|
+
resolution: side
|
|
61
35
|
}
|
|
62
|
-
|
|
63
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
this.log('Issue resolved');
|
|
67
|
-
const { jobId } = resolved;
|
|
68
|
-
if (jobId === null) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.log(formatKeyValue('Job ID', jobId));
|
|
72
|
-
this.log(`Track it with: sanity context jobs get ${knowledgeBaseId} ${jobId}`);
|
|
73
|
-
if (!watch) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let job;
|
|
77
|
-
try {
|
|
78
|
-
job = await watchJob(knowledgeBaseId, jobId, {
|
|
79
|
-
label: 'Rewriting entry',
|
|
80
|
-
successText: 'Entry rewritten'
|
|
81
|
-
});
|
|
82
|
-
} catch (error) {
|
|
83
|
-
resolveIssueDebug('Error watching rewrite job', error);
|
|
84
|
-
this.error(`Failed to watch rewrite job: ${getErrorMessage(error)}`, {
|
|
85
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (job.status !== 'succeeded') {
|
|
89
|
-
this.error(formatJobFailure('Rewrite', job), {
|
|
90
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
91
|
-
});
|
|
92
|
-
}
|
|
36
|
+
}, values);
|
|
93
37
|
}
|
|
94
38
|
async promptForSide(knowledgeBaseId, issueId) {
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
issue = await getIssue(knowledgeBaseId, issueId);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
resolveIssueDebug('Error getting issue', error);
|
|
100
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
101
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
102
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
this.error(`Failed to get issue: ${getErrorMessage(error)}`, {
|
|
106
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
107
|
-
});
|
|
108
|
-
}
|
|
39
|
+
const issue = await getIssue(knowledgeBaseId, issueId);
|
|
109
40
|
if (!issue) {
|
|
110
41
|
this.error(`Issue "${issueId}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
111
42
|
exit: exitCodes.RUNTIME_ERROR
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/issues/resolve.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/issues/resolve.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes} from '@sanity/cli-core'\nimport {requiredWhenUnattended} from '@sanity/cli-core/flags'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\nimport {type OperationRequest} from '../../../actions/context/operationInput.js'\nimport {getIssue} from '../../../services/context.js'\n\nconst BaseCommand = contextCommand('context issues resolve')\n\n/**\n * `context issues resolve` keeps `--side`, and without it, asks which side of\n * the conflict is correct, listing the sides from the issue document\n */\nexport class ResolveIssueCommand extends BaseCommand {\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 issue-def456',\n description: 'Choose the correct side interactively',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 issue-def456 --side 1 --watch',\n description: 'Choose side 1 and wait for the entry rewrite',\n },\n ]\n\n static override flags = {\n ...BaseCommand.flags,\n side: requiredWhenUnattended(\n Flags.integer({\n description: 'Index of the correct side, as listed by `sanity context issues get`',\n min: 0,\n }),\n ),\n } satisfies FlagInput\n\n public override async send(\n request: OperationRequest,\n values: Record<string, unknown>,\n ): Promise<unknown> {\n const side =\n typeof values.side === 'number'\n ? values.side\n : await this.promptForSide(request.params.knowledgeBaseId, request.params.issueId)\n return super.send({...request, body: {resolution: side}}, values)\n }\n\n private async promptForSide(knowledgeBaseId: string, issueId: string): Promise<number> {\n const issue = await getIssue(knowledgeBaseId, issueId)\n if (!issue) {\n this.error(`Issue \"${issueId}\" not found on knowledge base \"${knowledgeBaseId}\"`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n if (issue.status === 'rejected') {\n this.error(`Issue \"${issueId}\" is rejected (dismissed) and cannot be resolved`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n const {content} = issue\n if (content.kind !== 'conflict') {\n this.error(`Only conflict issues can be resolved, \"${issueId}\" is of kind ${content.kind}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n return select({\n choices: content.sides.map((side, index) => ({\n name: `[${index}] ${side.claim}`,\n value: index,\n })),\n // Re-resolving keeps the current choice preselected, so Enter can't flip it\n default: issue.resolution ?? content.suggested,\n message: 'Which side is correct?',\n })\n }\n}\n"],"names":["Flags","exitCodes","requiredWhenUnattended","select","contextCommand","getIssue","BaseCommand","ResolveIssueCommand","examples","command","description","flags","side","integer","min","send","request","values","promptForSide","params","knowledgeBaseId","issueId","body","resolution","issue","error","exit","RUNTIME_ERROR","status","content","kind","choices","sides","map","index","name","claim","value","default","suggested","message"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAEjC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,sBAAsB,QAAO,yBAAwB;AAC7D,SAAQC,MAAM,QAAO,sBAAqB;AAE1C,SAAQC,cAAc,QAAO,6CAA4C;AAEzE,SAAQC,QAAQ,QAAO,+BAA8B;AAErD,MAAMC,cAAcF,eAAe;AAEnC;;;CAGC,GACD,OAAO,MAAMG,4BAA4BD;IACvC,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTC,aAAa;QACf;QACA;YACED,SAAS;YACTC,a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AM,EAAE,EAAEtB,KAAKwB,KAAK,EAAE;oBAChCC,OAAOH;gBACT,CAAA;YACA,4EAA4E;YAC5EI,SAASd,MAAMD,UAAU,IAAIM,QAAQU,SAAS;YAC9CC,SAAS;QACX;IACF;AACF"}
|
|
@@ -1,90 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { isHttpError } from '@sanity/client';
|
|
5
|
-
import { formatJobFailure, watchJob } from '../../../actions/context/watchJob.js';
|
|
6
|
-
import { formatKeyValue } from '../../../actions/debug/output.js';
|
|
7
|
-
import { getJob } from '../../../services/context.js';
|
|
8
|
-
const getJobDebug = subdebug('context:jobs:get');
|
|
9
|
-
export class GetJobCommand extends SanityCommand {
|
|
10
|
-
static args = {
|
|
11
|
-
knowledgeBaseId: Args.string({
|
|
12
|
-
description: 'Knowledge base ID',
|
|
13
|
-
required: true
|
|
14
|
-
}),
|
|
15
|
-
// eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first
|
|
16
|
-
jobId: Args.string({
|
|
17
|
-
description: 'Job ID',
|
|
18
|
-
required: true
|
|
19
|
-
})
|
|
20
|
-
};
|
|
21
|
-
static description = 'Get the status of a knowledge base job';
|
|
22
|
-
static enableJsonFlag = true;
|
|
23
|
-
static examples = [
|
|
24
|
-
{
|
|
25
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 job-def456',
|
|
26
|
-
description: 'Get the current status of a job'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 job-def456 --watch',
|
|
30
|
-
description: 'Wait for the job to finish (non-zero exit if it does not succeed)'
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
static flags = {
|
|
34
|
-
watch: Flags.boolean({
|
|
35
|
-
default: false,
|
|
36
|
-
description: 'Poll until the job reaches a terminal state'
|
|
37
|
-
})
|
|
38
|
-
};
|
|
39
|
-
async run() {
|
|
40
|
-
const { jobId, knowledgeBaseId } = this.args;
|
|
41
|
-
const { json, watch } = this.flags;
|
|
42
|
-
let job;
|
|
43
|
-
try {
|
|
44
|
-
job = watch ? await watchJob(knowledgeBaseId, jobId, {
|
|
45
|
-
label: 'Waiting for job'
|
|
46
|
-
}) : await getJob(knowledgeBaseId, jobId);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
getJobDebug('Error getting job', error);
|
|
49
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
50
|
-
this.error(`Job "${jobId}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
51
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
this.error(`Failed to get job: ${getErrorMessage(error)}`, {
|
|
55
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const jobFailed = watch && job.status !== 'succeeded';
|
|
59
|
-
const failureMessage = formatJobFailure('Job', job);
|
|
60
|
-
if (json) {
|
|
61
|
-
if (jobFailed) throw new JsonOutputError(failureMessage, job, exitCodes.RUNTIME_ERROR);
|
|
62
|
-
this.logJson(job);
|
|
63
|
-
} else {
|
|
64
|
-
const padTo = 9 // "Completed" is the longest key
|
|
65
|
-
;
|
|
66
|
-
this.log(formatKeyValue('ID', job.id, {
|
|
67
|
-
padTo
|
|
68
|
-
}));
|
|
69
|
-
this.log(formatKeyValue('Status', job.status, {
|
|
70
|
-
padTo
|
|
71
|
-
}));
|
|
72
|
-
this.log(formatKeyValue('Started', job.startedAt ?? '-', {
|
|
73
|
-
padTo
|
|
74
|
-
}));
|
|
75
|
-
this.log(formatKeyValue('Completed', job.completedAt ?? '-', {
|
|
76
|
-
padTo
|
|
77
|
-
}));
|
|
78
|
-
this.log(formatKeyValue('Error', job.error ?? '-', {
|
|
79
|
-
padTo
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
if (jobFailed) {
|
|
83
|
-
this.error(failureMessage, {
|
|
84
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const GetJobCommand = contextCommand('context jobs get');
|
|
89
4
|
|
|
90
5
|
//# sourceMappingURL=get.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/jobs/get.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/jobs/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const GetJobCommand = contextCommand('context jobs get')\n"],"names":["contextCommand","GetJobCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,gBAAgBD,eAAe,oBAAmB"}
|
|
@@ -1,105 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { listKnowledgeBases } from '../../services/context.js';
|
|
5
|
-
import { Table } from '../../util/responsiveTable.js';
|
|
6
|
-
import { getOrganizationFlag } from '../../util/sharedFlags.js';
|
|
7
|
-
const listContextDebug = subdebug('context:list');
|
|
8
|
-
export class ListKnowledgeBasesCommand extends SanityCommand {
|
|
9
|
-
static description = 'List knowledge bases in an organization';
|
|
10
|
-
static enableJsonFlag = true;
|
|
11
|
-
static examples = [
|
|
12
|
-
{
|
|
13
|
-
command: '<%= config.bin %> <%= command.id %>',
|
|
14
|
-
description: 'List knowledge bases, selecting the organization interactively'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
command: '<%= config.bin %> <%= command.id %> --organization org-abc123',
|
|
18
|
-
description: 'List knowledge bases in a specific organization'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
command: '<%= config.bin %> <%= command.id %> --organization org-abc123 --json',
|
|
22
|
-
description: 'Output knowledge bases as JSON'
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
static flags = {
|
|
26
|
-
...getOrganizationFlag({
|
|
27
|
-
description: 'Organization to list knowledge bases for',
|
|
28
|
-
semantics: 'override'
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
async run() {
|
|
32
|
-
const { json, organization } = this.flags;
|
|
33
|
-
let organizationId;
|
|
34
|
-
try {
|
|
35
|
-
organizationId = await resolveOrganizationId({
|
|
36
|
-
configuredOrganizationId: (await this.tryGetCliConfig()).app?.organizationId,
|
|
37
|
-
flagOrganizationId: organization,
|
|
38
|
-
unattended: this.isUnattended()
|
|
39
|
-
});
|
|
40
|
-
} catch (error) {
|
|
41
|
-
listContextDebug('Error resolving organization', error);
|
|
42
|
-
this.error(getErrorMessage(error), {
|
|
43
|
-
exit: error instanceof MissingOrganizationError ? exitCodes.USAGE_ERROR : exitCodes.RUNTIME_ERROR
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
let knowledgeBases;
|
|
47
|
-
try {
|
|
48
|
-
knowledgeBases = await listKnowledgeBases(organizationId);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
listContextDebug('Error listing knowledge bases', error);
|
|
51
|
-
this.error(`Failed to list knowledge bases: ${getErrorMessage(error)}`, {
|
|
52
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (json) {
|
|
56
|
-
this.logJson(knowledgeBases);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (knowledgeBases.length === 0) {
|
|
60
|
-
this.log('No knowledge bases found');
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const table = new Table({
|
|
64
|
-
columns: [
|
|
65
|
-
{
|
|
66
|
-
alignment: 'left',
|
|
67
|
-
name: 'id',
|
|
68
|
-
title: 'ID'
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
alignment: 'left',
|
|
72
|
-
name: 'title',
|
|
73
|
-
title: 'Title'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
alignment: 'left',
|
|
77
|
-
name: 'state',
|
|
78
|
-
title: 'State'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
alignment: 'right',
|
|
82
|
-
name: 'openIssues',
|
|
83
|
-
title: 'Open issues'
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
alignment: 'left',
|
|
87
|
-
name: 'updatedAt',
|
|
88
|
-
title: 'Updated'
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
});
|
|
92
|
-
for (const { openIssueCount, publicId, state, title, updatedAt } of knowledgeBases){
|
|
93
|
-
table.addRow({
|
|
94
|
-
id: publicId,
|
|
95
|
-
openIssues: openIssueCount,
|
|
96
|
-
state,
|
|
97
|
-
title,
|
|
98
|
-
updatedAt
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
this.log(table.render());
|
|
102
|
-
}
|
|
103
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../actions/context/contextCommand.js';
|
|
3
|
+
export const ListKnowledgeBasesCommand = contextCommand('context list');
|
|
104
4
|
|
|
105
5
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/context/list.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/context/list.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const ListKnowledgeBasesCommand = contextCommand('context list')\n"],"names":["contextCommand","ListKnowledgeBasesCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,4BAA4BD,eAAe,gBAAe"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
|
+
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
4
|
+
import { requiredWhenUnattended } from '@sanity/cli-core/flags';
|
|
5
|
+
import { spinner } from '@sanity/cli-core/ux';
|
|
6
|
+
import { datasetSourceId, editSources, formatMcpEndpoint, parseEndpointName, parseNonEmpty } from '../../../actions/context/mcpEndpoint.js';
|
|
7
|
+
import { resolveOrganizationId } from '../../../actions/context/resolveOrganizationId.js';
|
|
8
|
+
import { promptForText } from '../../../prompts/promptForText.js';
|
|
9
|
+
import { createMcpEndpoint } from '../../../services/context.js';
|
|
10
|
+
import { getDatasetFlag, getOrganizationFlag, getProjectIdFlag } from '../../../util/sharedFlags.js';
|
|
11
|
+
import { defineCommandTelemetry } from '../../../util/telemetry/commandTelemetry.js';
|
|
12
|
+
const createMcpDebug = subdebug('context:mcp:create');
|
|
13
|
+
const SOURCE_FLAGS = [
|
|
14
|
+
'knowledge-base',
|
|
15
|
+
'dataset'
|
|
16
|
+
];
|
|
17
|
+
const flags = {
|
|
18
|
+
...getOrganizationFlag({
|
|
19
|
+
description: 'Organization to create the MCP endpoint in',
|
|
20
|
+
semantics: 'override'
|
|
21
|
+
}),
|
|
22
|
+
...getDatasetFlag({
|
|
23
|
+
atLeastOne: SOURCE_FLAGS,
|
|
24
|
+
description: 'Dataset the endpoint serves',
|
|
25
|
+
semantics: 'specify'
|
|
26
|
+
}),
|
|
27
|
+
...getProjectIdFlag({
|
|
28
|
+
dependsOn: [
|
|
29
|
+
'dataset'
|
|
30
|
+
],
|
|
31
|
+
description: 'Project the dataset belongs to',
|
|
32
|
+
semantics: 'override'
|
|
33
|
+
}),
|
|
34
|
+
'groq-filter': Flags.string({
|
|
35
|
+
dependsOn: [
|
|
36
|
+
'dataset'
|
|
37
|
+
],
|
|
38
|
+
description: 'GROQ filter that limits which dataset documents the endpoint serves',
|
|
39
|
+
parse: parseNonEmpty('groq-filter')
|
|
40
|
+
}),
|
|
41
|
+
instructions: Flags.string({
|
|
42
|
+
description: 'Instructions the endpoint serves to connecting agents',
|
|
43
|
+
parse: parseNonEmpty('instructions')
|
|
44
|
+
}),
|
|
45
|
+
'knowledge-base': Flags.string({
|
|
46
|
+
atLeastOne: SOURCE_FLAGS,
|
|
47
|
+
description: 'Knowledge base the endpoint serves; repeat the flag to serve several',
|
|
48
|
+
helpValue: '<id>',
|
|
49
|
+
multiple: true,
|
|
50
|
+
parse: parseNonEmpty('knowledge-base')
|
|
51
|
+
}),
|
|
52
|
+
perspective: Flags.custom({
|
|
53
|
+
dependsOn: [
|
|
54
|
+
'dataset'
|
|
55
|
+
],
|
|
56
|
+
description: 'Perspective agents query the dataset with',
|
|
57
|
+
options: [
|
|
58
|
+
'published',
|
|
59
|
+
'drafts',
|
|
60
|
+
'raw'
|
|
61
|
+
]
|
|
62
|
+
})(),
|
|
63
|
+
'semantic-search': Flags.boolean({
|
|
64
|
+
allowNo: true,
|
|
65
|
+
dependsOn: [
|
|
66
|
+
'dataset'
|
|
67
|
+
],
|
|
68
|
+
description: 'Let agents use semantic search on the dataset (--no-semantic-search to turn it off)'
|
|
69
|
+
}),
|
|
70
|
+
title: requiredWhenUnattended(Flags.string({
|
|
71
|
+
description: 'MCP endpoint title',
|
|
72
|
+
parse: parseNonEmpty('title')
|
|
73
|
+
})),
|
|
74
|
+
workspace: Flags.string({
|
|
75
|
+
dependsOn: [
|
|
76
|
+
'dataset'
|
|
77
|
+
],
|
|
78
|
+
description: 'Studio workspace whose schema agents use, instead of the first workspace',
|
|
79
|
+
parse: parseNonEmpty('workspace')
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
export class CreateMcpEndpointCommand extends SanityCommand {
|
|
83
|
+
static args = {
|
|
84
|
+
name: Args.string({
|
|
85
|
+
description: 'Permanent MCP endpoint name used in its URL, made of lowercase letters, digits and hyphens',
|
|
86
|
+
parse: parseEndpointName,
|
|
87
|
+
required: true
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
static description = 'Create a Context MCP endpoint that serves knowledge bases and a dataset to agents';
|
|
91
|
+
static examples = [
|
|
92
|
+
{
|
|
93
|
+
command: '<%= config.bin %> <%= command.id %> support --title "Support" --knowledge-base kb-abc123 --knowledge-base kb-def456',
|
|
94
|
+
description: 'Create an MCP endpoint that serves two knowledge bases'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
command: '<%= config.bin %> <%= command.id %> catalog --title "Catalog" --project abc123 --dataset production --perspective drafts --groq-filter \'_type in ["product"]\'',
|
|
98
|
+
description: 'Create an MCP endpoint that serves the products in a dataset'
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
static flags = flags;
|
|
102
|
+
static telemetry = defineCommandTelemetry(flags, {
|
|
103
|
+
redact: [
|
|
104
|
+
'title',
|
|
105
|
+
'instructions',
|
|
106
|
+
'groq-filter'
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
async run() {
|
|
110
|
+
const { name } = this.args;
|
|
111
|
+
const { dataset, 'groq-filter': groqFilter, instructions, 'knowledge-base': knowledgeBaseIds = [], organization, perspective, project, 'semantic-search': semanticSearch, title: titleFlag, workspace } = this.flags;
|
|
112
|
+
const cliConfig = await this.tryGetCliConfig();
|
|
113
|
+
const datasetId = datasetSourceId(dataset, project ?? cliConfig.api?.projectId);
|
|
114
|
+
const organizationId = await resolveOrganizationId({
|
|
115
|
+
configuredOrganizationId: cliConfig.app?.organizationId,
|
|
116
|
+
flagOrganizationId: organization,
|
|
117
|
+
unattended: this.isUnattended()
|
|
118
|
+
});
|
|
119
|
+
const title = titleFlag || await promptForText('MCP endpoint title:');
|
|
120
|
+
const spin = spinner('Creating MCP endpoint').start();
|
|
121
|
+
try {
|
|
122
|
+
const endpoint = await createMcpEndpoint(organizationId, {
|
|
123
|
+
groqFilter,
|
|
124
|
+
instructions,
|
|
125
|
+
name,
|
|
126
|
+
sources: editSources([], {
|
|
127
|
+
addKnowledgeBases: knowledgeBaseIds,
|
|
128
|
+
dataset: datasetId,
|
|
129
|
+
removeKnowledgeBases: [],
|
|
130
|
+
settings: {
|
|
131
|
+
perspective,
|
|
132
|
+
semanticSearch,
|
|
133
|
+
workspace
|
|
134
|
+
}
|
|
135
|
+
}).sources,
|
|
136
|
+
title
|
|
137
|
+
});
|
|
138
|
+
spin.succeed('MCP endpoint created');
|
|
139
|
+
for (const line of formatMcpEndpoint(endpoint)){
|
|
140
|
+
this.log(line);
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
spin.fail();
|
|
144
|
+
createMcpDebug('Error creating MCP endpoint', error);
|
|
145
|
+
this.error(`Failed to create MCP endpoint: ${getErrorMessage(error)}`, {
|
|
146
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/mcp/create.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {requiredWhenUnattended} from '@sanity/cli-core/flags'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {\n datasetSourceId,\n editSources,\n formatMcpEndpoint,\n parseEndpointName,\n parseNonEmpty,\n} from '../../../actions/context/mcpEndpoint.js'\nimport {resolveOrganizationId} from '../../../actions/context/resolveOrganizationId.js'\nimport {promptForText} from '../../../prompts/promptForText.js'\nimport {createMcpEndpoint} from '../../../services/context.js'\nimport {getDatasetFlag, getOrganizationFlag, getProjectIdFlag} from '../../../util/sharedFlags.js'\nimport {defineCommandTelemetry} from '../../../util/telemetry/commandTelemetry.js'\n\nconst createMcpDebug = subdebug('context:mcp:create')\n\nconst SOURCE_FLAGS = ['knowledge-base', 'dataset']\n\nconst flags = {\n ...getOrganizationFlag({\n description: 'Organization to create the MCP endpoint in',\n semantics: 'override',\n }),\n ...getDatasetFlag({\n atLeastOne: SOURCE_FLAGS,\n description: 'Dataset the endpoint serves',\n semantics: 'specify',\n }),\n ...getProjectIdFlag({\n dependsOn: ['dataset'],\n description: 'Project the dataset belongs to',\n semantics: 'override',\n }),\n 'groq-filter': Flags.string({\n dependsOn: ['dataset'],\n description: 'GROQ filter that limits which dataset documents the endpoint serves',\n parse: parseNonEmpty('groq-filter'),\n }),\n instructions: Flags.string({\n description: 'Instructions the endpoint serves to connecting agents',\n parse: parseNonEmpty('instructions'),\n }),\n 'knowledge-base': Flags.string({\n atLeastOne: SOURCE_FLAGS,\n description: 'Knowledge base the endpoint serves; repeat the flag to serve several',\n helpValue: '<id>',\n multiple: true,\n parse: parseNonEmpty('knowledge-base'),\n }),\n perspective: Flags.custom<'drafts' | 'published' | 'raw'>({\n dependsOn: ['dataset'],\n description: 'Perspective agents query the dataset with',\n options: ['published', 'drafts', 'raw'],\n })(),\n 'semantic-search': Flags.boolean({\n allowNo: true,\n dependsOn: ['dataset'],\n description:\n 'Let agents use semantic search on the dataset (--no-semantic-search to turn it off)',\n }),\n title: requiredWhenUnattended(\n Flags.string({\n description: 'MCP endpoint title',\n parse: parseNonEmpty('title'),\n }),\n ),\n workspace: Flags.string({\n dependsOn: ['dataset'],\n description: 'Studio workspace whose schema agents use, instead of the first workspace',\n parse: parseNonEmpty('workspace'),\n }),\n} satisfies FlagInput\n\nexport class CreateMcpEndpointCommand extends SanityCommand<typeof CreateMcpEndpointCommand> {\n static override args = {\n name: Args.string({\n description:\n 'Permanent MCP endpoint name used in its URL, made of lowercase letters, digits and hyphens',\n parse: parseEndpointName,\n required: true,\n }),\n }\n\n static override description =\n 'Create a Context MCP endpoint that serves knowledge bases and a dataset to agents'\n\n static override examples = [\n {\n command:\n '<%= config.bin %> <%= command.id %> support --title \"Support\" --knowledge-base kb-abc123 --knowledge-base kb-def456',\n description: 'Create an MCP endpoint that serves two knowledge bases',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> catalog --title \"Catalog\" --project abc123 --dataset production --perspective drafts --groq-filter \\'_type in [\"product\"]\\'',\n description: 'Create an MCP endpoint that serves the products in a dataset',\n },\n ]\n\n static override flags = flags\n\n static telemetry = defineCommandTelemetry(flags, {\n redact: ['title', 'instructions', 'groq-filter'],\n })\n\n public async run(): Promise<void> {\n const {name} = this.args\n const {\n dataset,\n 'groq-filter': groqFilter,\n instructions,\n 'knowledge-base': knowledgeBaseIds = [],\n organization,\n perspective,\n project,\n 'semantic-search': semanticSearch,\n title: titleFlag,\n workspace,\n } = this.flags\n\n const cliConfig = await this.tryGetCliConfig()\n const datasetId = datasetSourceId(dataset, project ?? cliConfig.api?.projectId)\n\n const organizationId = await resolveOrganizationId({\n configuredOrganizationId: cliConfig.app?.organizationId,\n flagOrganizationId: organization,\n unattended: this.isUnattended(),\n })\n\n const title = titleFlag || (await promptForText('MCP endpoint title:'))\n\n const spin = spinner('Creating MCP endpoint').start()\n try {\n const endpoint = await createMcpEndpoint(organizationId, {\n groqFilter,\n instructions,\n name,\n sources: editSources([], {\n addKnowledgeBases: knowledgeBaseIds,\n dataset: datasetId,\n removeKnowledgeBases: [],\n settings: {perspective, semanticSearch, workspace},\n }).sources,\n title,\n })\n spin.succeed('MCP endpoint created')\n for (const line of formatMcpEndpoint(endpoint)) {\n this.log(line)\n }\n } catch (error) {\n spin.fail()\n createMcpDebug('Error creating MCP endpoint', error)\n this.error(`Failed to create MCP endpoint: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n }\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","requiredWhenUnattended","spinner","datasetSourceId","editSources","formatMcpEndpoint","parseEndpointName","parseNonEmpty","resolveOrganizationId","promptForText","createMcpEndpoint","getDatasetFlag","getOrganizationFlag","getProjectIdFlag","defineCommandTelemetry","createMcpDebug","SOURCE_FLAGS","flags","description","semantics","atLeastOne","dependsOn","string","parse","instructions","helpValue","multiple","perspective","custom","options","boolean","allowNo","title","workspace","CreateMcpEndpointCommand","args","name","required","examples","command","telemetry","redact","run","dataset","groqFilter","knowledgeBaseIds","organization","project","semanticSearch","titleFlag","cliConfig","tryGetCliConfig","datasetId","api","projectId","organizationId","configuredOrganizationId","app","flagOrganizationId","unattended","isUnattended","spin","start","endpoint","sources","addKnowledgeBases","removeKnowledgeBases","settings","succeed","line","log","error","fail","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AAEvC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,sBAAsB,QAAO,yBAAwB;AAC7D,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SACEC,eAAe,EACfC,WAAW,EACXC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,QACR,0CAAyC;AAChD,SAAQC,qBAAqB,QAAO,oDAAmD;AACvF,SAAQC,aAAa,QAAO,oCAAmC;AAC/D,SAAQC,iBAAiB,QAAO,+BAA8B;AAC9D,SAAQC,cAAc,EAAEC,mBAAmB,EAAEC,gBAAgB,QAAO,+BAA8B;AAClG,SAAQC,sBAAsB,QAAO,8CAA6C;AAElF,MAAMC,iBAAiBhB,SAAS;AAEhC,MAAMiB,eAAe;IAAC;IAAkB;CAAU;AAElD,MAAMC,QAAQ;IACZ,GAAGL,oBAAoB;QACrBM,aAAa;QACbC,WAAW;IACb,EAAE;IACF,GAAGR,eAAe;QAChBS,YAAYJ;QACZE,aAAa;QACbC,WAAW;IACb,EAAE;IACF,GAAGN,iBAAiB;QAClBQ,WAAW;YAAC;SAAU;QACtBH,aAAa;QACbC,WAAW;IACb,EAAE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