@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
111 lines (110 loc) • 4.9 kB
JavaScript
// GENERATED from packages/api-contract/src/docs/v1/operations.ts by scripts/vendor-api-contract.mjs — do not edit
import { z } from 'zod';
import { defineOperation, defineOperations } from '../../core/operation.js';
/**
* Docs v1: search and read docs.vigilbase.com, for agents and scripts. Served
* on https://api.vigilbase.com/docs/v1 by the com Worker, which holds the docs
* content; the unified MCP server's `search_docs` and `get_docs_page`
* tools call these operations. Published pages only: drafts never show here.
* There are no legacy aliases: the docs site's own search route
* (`/api/docs/search`) is the ⌘K dialog's, not a public API.
*/
/** The docs-wide limit, per client IP. */
const anonymous = [{ kind: 'anonymous', rateLimit: 'docs' }];
const ERRORS = ['bad_request', 'rate_limit_exceeded', 'service_unavailable'];
const url = z.string().meta({ format: 'uri' });
/** A page path as in its URL: `one/api/keys`; the empty string is the docs home. */
const pagePath = z.string().meta({ example: 'tools/developers/agent-api' });
export const DocsSearchResult = z
.looseObject({
path: pagePath,
title: z.string(),
description: z.string(),
url: url.meta({ description: 'The page on docs.vigilbase.com, with the heading anchor when the match is under one.' }),
markdownUrl: url.meta({ description: 'The page as Markdown.' }),
heading: z.object({ id: z.string(), text: z.string() }).optional().meta({ description: 'The heading the match is under, when it is one.' }),
})
.meta({ id: 'DocsSearchResult' });
export const searchDocs = defineOperation({
id: 'docs.search.query',
product: 'docs',
version: 'v1',
method: 'GET',
path: '/search',
summary: 'Search the docs',
description: 'Pages of docs.vigilbase.com that contain every word of `q`, best first: matches in the title, then a heading, then the description, then the body. English only.',
tags: ['Docs'],
stability: 'beta',
audience: 'public',
auth: anonymous,
rateLimit: 'docs',
request: {
query: z.object({
q: z.string().trim().min(2).max(200).meta({ description: 'Words to find, at least two characters. Up to eight words count.', example: 'api keys' }),
limit: z.coerce.number().int().min(1).max(20).default(10).meta({ description: 'At most this many results.' }),
}),
},
responses: { 200: z.object({ results: z.array(DocsSearchResult) }) },
errors: ERRORS,
examples: [
{
request: { query: { q: 'api keys', limit: 1 } },
response: {
status: 200,
body: {
results: [
{
path: 'tools/developers/api-keys',
title: 'API keys',
description: 'Create a developer API key to raise the Agent API rate limits.',
url: 'https://docs.vigilbase.com/tools/developers/api-keys',
markdownUrl: 'https://docs.vigilbase.com/tools/developers/api-keys.md',
},
],
},
},
},
],
expose: { mcp: 'tool', llms: true },
});
export const getDocsPage = defineOperation({
id: 'docs.pages.get',
product: 'docs',
version: 'v1',
method: 'GET',
path: '/pages',
summary: 'Get a docs page',
description: 'One page of docs.vigilbase.com as Markdown, with links made absolute. `path` is the page URL without the host, as `path` in a search result.',
tags: ['Docs'],
stability: 'beta',
audience: 'public',
auth: anonymous,
rateLimit: 'docs',
request: {
query: z.object({
path: z
.string()
.trim()
.max(300)
.regex(/^\/?(?:[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)*)?\/?$/, 'A docs path such as one/api, without a host or query')
.meta({ description: 'The page path, for example `one/api`. A leading or trailing slash is ignored; empty is the docs home.', example: 'tools/developers/agent-api' }),
}),
},
responses: {
200: z
.looseObject({
path: pagePath,
title: z.string(),
description: z.string(),
url,
markdownUrl: url,
updatedAt: z.string().optional().meta({ description: 'When the page last changed (ISO 8601), when known.' }),
markdown: z.string().meta({ description: 'The page body as Markdown, without its title.' }),
})
.meta({ id: 'DocsPage' }),
},
errors: [...ERRORS, 'not_found'],
expose: { mcp: 'tool', llms: true },
});
/** Every Docs v1 operation, checked at module load. */
export const DOCS_V1_OPERATIONS = defineOperations('docs', [searchDocs, getDocsPage]);