@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
503 lines (502 loc) • 21.7 kB
JavaScript
// GENERATED from packages/api-contract/src/one/v1/support-services.ts by scripts/vendor-api-contract.mjs — do not edit
import { z } from 'zod';
import { defineOperation } from '../../core/operation.js';
import { CustomerParams, Id, ListQuery, ONE_READ_AUTH, ONE_PERSON_WRITE_AUTH, ONE_WRITE_AUTH, page, READ_ERRORS, Timestamp, WRITE_ERRORS, } from './shared.js';
// ---------------------------------------------------------------- shared pieces
/** A Cloudflare account or zone ID: 32 hexadecimal characters. */
export const CloudflareId = z.string().regex(/^[a-f0-9]{32}$/).meta({ description: 'A Cloudflare ID: 32 lower-case hexadecimal characters.' });
/** A Pylon support request ID. */
export const SupportTicketId = z.string().regex(/^[A-Za-z0-9-]{1,64}$/);
const TicketParams = z.object({ ticketId: SupportTicketId });
const ZoneParams = z.object({ zoneId: CloudflareId });
const Bool = z.enum(['true', 'false']).default('false').transform((value) => value === 'true');
const SUPPORT_DESCRIPTION = 'Staff must name the customer with customerId; everyone else gets their own organisation’s customer.';
/** Files uploaded through Vigilbase first; One refuses any link that is not one of Pylon's. */
const SupportAttachmentUrls = z
.array(z.string().max(2048))
.max(5)
.meta({ description: 'Up to five file links from Vigilbase’s support attachment upload (Pylon links only).' });
// ---------------------------------------------------------------- support tickets
export const SupportPerson = z.object({ name: z.string().nullable(), email: z.string().nullable() }).meta({ id: 'SupportPerson' });
/** A support request as customers see it. Never Pylon’s HTML or its signed file links. */
export const SupportTicket = z
.object({
id: SupportTicketId,
number: z.number().int().nullable(),
title: z.string(),
state: z.string().meta({ description: 'Pylon state: new, waiting_on_you, waiting_on_customer, on_hold, closed, …' }),
priority: z.string().nullable(),
tags: z.array(z.string()),
requester: SupportPerson.nullable(),
assignee: SupportPerson.nullable(),
bodyText: z.string().nullable().meta({ description: 'The request’s text, without markup or file links.' }),
createdAt: Timestamp.nullable(),
updatedAt: Timestamp.nullable(),
closedAt: Timestamp.nullable(),
})
.meta({ id: 'SupportTicket' });
export const SupportTicketAttachment = z
.object({
index: z.number().int().min(0).meta({ description: 'Position of the file on its message.' }),
name: z.string(),
kind: z.enum(['image', 'pdf', 'file']),
})
.meta({ id: 'SupportTicketAttachment' });
/** One message on a support request. Customers never receive internal notes. */
export const SupportTicketMessage = z
.object({
id: z.string(),
authorName: z.string(),
fromVigilbase: z.boolean(),
isInternalNote: z.boolean().meta({ description: 'Always false for customers; staff also see internal notes.' }),
source: z.string().nullable(),
text: z.string(),
attachments: z.array(SupportTicketAttachment),
createdAt: Timestamp.nullable(),
})
.meta({ id: 'SupportTicketMessage' });
export const SupportTicketCreated = z
.object({
ticketId: SupportTicketId,
ticketNumber: z.string(),
replayed: z.boolean().meta({ description: 'True when an earlier request with the same Idempotency-Key already created it.' }),
})
.meta({ id: 'SupportTicketCreated' });
export const SupportTicketReplyPosted = z
.object({ messageId: z.string().nullable() })
.meta({ id: 'SupportTicketReplyPosted' });
export const listSupportTickets = defineOperation({
id: 'one.supportTickets.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/support-tickets',
summary: 'List support tickets',
description: `The customer’s support requests, open ones only unless includeClosed is true (at most the newest 100). ${SUPPORT_DESCRIPTION}`,
tags: ['support'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['support:access'],
pagination: 'cursor',
request: { query: ListQuery.extend({ customerId: Id.optional(), includeClosed: Bool }) },
responses: { 200: page(SupportTicket) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/support/tickets' }],
expose: { mcp: 'code-mode', cli: 'support tickets', llms: true },
});
export const createSupportTicket = defineOperation({
id: 'one.supportTickets.create',
product: 'one',
version: 'v1',
method: 'POST',
path: '/support-tickets',
summary: 'Open a support ticket',
description: `Opens a support request with Vigilbase. Send an Idempotency-Key so a retry never opens a second request. ${SUPPORT_DESCRIPTION}`,
tags: ['support'],
stability: 'beta',
audience: 'customer',
auth: ONE_PERSON_WRITE_AUTH,
permissions: ['support:access'],
idempotency: 'optional',
request: {
body: z.strictObject({
subject: z.string().trim().min(5).max(200),
description: z.string().trim().min(20).max(40_000),
priority: z.enum(['low', 'medium', 'high', 'urgent']).default('medium'),
serviceCategory: z.string().trim().min(1).max(128).optional(),
ccEmails: z.array(z.string().trim().max(320).pipe(z.email())).max(20).optional(),
attachmentUrls: SupportAttachmentUrls.optional(),
customerId: Id.optional(),
}),
},
responses: { 201: SupportTicketCreated, 200: SupportTicketCreated },
errors: WRITE_ERRORS,
legacy: [{ host: 'one', path: '/api/support/tickets' }],
expose: { mcp: 'code-mode', llms: true },
});
export const listSupportTicketMessages = defineOperation({
id: 'one.supportTicketMessages.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/support-tickets/{ticketId}/messages',
summary: 'List a support ticket’s messages',
description: `The conversation on one support request, oldest first (the newest 200 messages). ${SUPPORT_DESCRIPTION}`,
tags: ['support'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['support:access'],
pagination: 'cursor',
request: { params: TicketParams, query: ListQuery.extend({ customerId: Id.optional() }) },
responses: { 200: page(SupportTicketMessage) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/support/tickets/{issueId}/messages' }],
expose: { mcp: 'code-mode', llms: true },
});
export const replyToSupportTicket = defineOperation({
id: 'one.supportTicketReplies.create',
product: 'one',
version: 'v1',
method: 'POST',
path: '/support-tickets/{ticketId}/replies',
summary: 'Reply to a support ticket',
description: `Posts a reply on the request as the caller’s support contact, or for Vigilbase staff an internal note customers never see. Send an Idempotency-Key so a retry never posts twice. ${SUPPORT_DESCRIPTION}`,
tags: ['support'],
stability: 'beta',
audience: 'customer',
auth: ONE_PERSON_WRITE_AUTH,
permissions: ['support:access'],
idempotency: 'optional',
request: {
params: TicketParams,
body: z.strictObject({
body: z.string().trim().min(1).max(10_000),
attachmentUrls: SupportAttachmentUrls.optional(),
internalNote: z.boolean().default(false).meta({ description: 'Vigilbase staff only: post an internal note instead of a reply.' }),
customerId: Id.optional(),
}),
},
responses: { 201: SupportTicketReplyPosted },
errors: WRITE_ERRORS,
legacy: [{ host: 'one', path: '/api/support/tickets/{issueId}/reply' }],
expose: { mcp: 'code-mode', llms: true },
});
// ---------------------------------------------------------------- Cloudflare
/** A Cloudflare zone of the customer’s linked accounts, without plan prices. */
export const CloudflareZone = z
.object({
id: z.string(),
name: z.string(),
status: z.string().meta({ description: 'active, pending, initializing, moved, deleted, deactivated' }),
paused: z.boolean(),
type: z.string().nullable().meta({ description: 'full or partial' }),
developmentMode: z.boolean(),
planName: z.string().nullable(),
nameServers: z.array(z.string()),
accountId: z.string().nullable(),
accountName: z.string().nullable(),
createdAt: Timestamp.nullable(),
activatedAt: Timestamp.nullable(),
modifiedAt: Timestamp.nullable(),
})
.meta({ id: 'CloudflareZone' });
export const CloudflareDnsRecord = z
.object({
id: z.string(),
name: z.string(),
type: z.string().meta({ description: 'A, AAAA, CNAME, MX, TXT, NS, SRV, CAA, PTR, …' }),
content: z.string(),
ttl: z.number().int().meta({ description: 'Seconds; 1 means automatic.' }),
priority: z.number().int().nullable(),
proxied: z.boolean(),
proxiable: z.boolean().nullable(),
locked: z.boolean(),
createdAt: Timestamp.nullable(),
modifiedAt: Timestamp.nullable(),
})
.meta({ id: 'CloudflareDnsRecord' });
const CheckStatus = z.enum(['pass', 'warning', 'fail', 'error', 'info', 'skipped', 'locked']);
const SettingKey = z.enum(['ssl', 'waf', 'browserCheck', 'challengeTtl', 'securityLevel', 'opportunisticEncryption', 'automaticHttpsRewrites', 'alwaysUseHttps']);
export const CloudflareZoneSecuritySetting = z
.object({
enabled: z.boolean().nullable().meta({ description: 'Pass is true, warning or fail is false; null when not graded or not read.' }),
status: CheckStatus.nullable(),
details: z.string(),
source: z.enum(['live', 'checkup']).nullable(),
value: z.union([z.string(), z.number(), z.boolean()]).nullable().meta({ description: 'The Cloudflare setting value (live reads only).' }),
checkedAt: Timestamp.nullable(),
})
.meta({ id: 'CloudflareZoneSecuritySetting' });
export const CloudflareZoneSecurity = z
.object({
zoneId: z.string(),
source: z.enum(['live', 'checkup']).nullable(),
readAt: Timestamp.nullable(),
liveError: z.string().nullable().meta({ description: 'Why Cloudflare could not be read live; settings then come from the latest checkup.' }),
checkup: z.object({ toolRunId: Id, checkedAt: Timestamp }).nullable(),
settings: z.object({
ssl: CloudflareZoneSecuritySetting,
waf: CloudflareZoneSecuritySetting,
browserCheck: CloudflareZoneSecuritySetting,
challengeTtl: CloudflareZoneSecuritySetting,
securityLevel: CloudflareZoneSecuritySetting,
opportunisticEncryption: CloudflareZoneSecuritySetting,
automaticHttpsRewrites: CloudflareZoneSecuritySetting,
alwaysUseHttps: CloudflareZoneSecuritySetting,
}),
defaults: z.object({
applied: z.boolean().nullable().meta({ description: 'Whether the zone has every recommended default (live values only).' }),
pending: z.array(SettingKey),
}),
})
.meta({ id: 'CloudflareZoneSecurity' });
const ToolRunStatus = z.string().meta({ description: 'pending, running, completed, failed, …' });
export const CloudflareCheckupStatus = z
.object({
requiresSetup: z.boolean().meta({ description: 'True when no Cloudflare account with checkups is connected.' }),
account: z
.object({
id: z.string(),
name: z.string().nullable(),
status: z.string(),
scope: z.object({ type: z.enum(['account', 'zones']), zoneIds: z.array(z.string()).nullable() }),
})
.nullable(),
credentialSource: z.string().nullable().meta({ description: 'Whose Cloudflare credentials the checkup uses: default, customer or partner.' }),
latestRun: z
.object({
id: Id,
status: ToolRunStatus,
grade: z.string().nullable(),
gradeScore: z.number().nullable(),
createdAt: Timestamp.nullable(),
completedAt: Timestamp.nullable(),
})
.nullable()
.meta({ description: 'The latest completed checkup; GET /tool-runs/{runId} has its results.' }),
activeRun: z
.object({ id: Id, status: ToolRunStatus, createdAt: Timestamp.nullable(), startedAt: Timestamp.nullable() })
.nullable(),
lastValidatedAt: Timestamp.nullable(),
})
.meta({ id: 'CloudflareCheckupStatus' });
export const listCustomerCloudflareZones = defineOperation({
id: 'one.cloudflareZones.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/customers/{customerId}/cloudflare-zones',
summary: 'List a customer’s Cloudflare zones',
description: 'Zones of every Cloudflare account linked to the customer, limited to the zones its services cover. Read live from Cloudflare when One can, otherwise from One’s last sync.',
tags: ['cloudflare'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
pagination: 'cursor',
request: { params: CustomerParams, query: ListQuery },
responses: { 200: page(CloudflareZone) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/customers/{id}/cloudflare/zones' }],
expose: { mcp: 'code-mode', llms: true },
});
export const listCloudflareDnsRecords = defineOperation({
id: 'one.cloudflareDnsRecords.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/cloudflare/zones/{zoneId}/dns-records',
summary: 'List a zone’s DNS records',
description: 'The zone’s DNS records, read live from Cloudflare. customerId names the customer that holds the zone.',
tags: ['cloudflare'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
pagination: 'cursor',
request: { params: ZoneParams, query: ListQuery.extend({ customerId: Id }) },
responses: { 200: page(CloudflareDnsRecord) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/services/cloudflare/zones/{zoneId}/dns' }],
expose: { mcp: 'code-mode', cli: 'cf dns', llms: true },
});
export const getCloudflareZoneSecurity = defineOperation({
id: 'one.cloudflareZoneSecurity.get',
product: 'one',
version: 'v1',
method: 'GET',
path: '/cloudflare/zones/{zoneId}/security',
summary: 'Get a zone’s security settings',
description: 'The zone’s security defaults, read live from Cloudflare and graded by the Cloudflare Checkup’s checks; a setting Cloudflare could not answer comes from the latest checkup.',
tags: ['cloudflare'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
request: { params: ZoneParams, query: z.object({ customerId: Id }) },
responses: { 200: CloudflareZoneSecurity },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/services/cloudflare/zones/{zoneId}/security' }],
expose: { mcp: 'code-mode', llms: true },
});
export const getCloudflareCheckupStatus = defineOperation({
id: 'one.cloudflareCheckups.get',
product: 'one',
version: 'v1',
method: 'GET',
path: '/cloudflare/checkups',
summary: 'Get Cloudflare Checkup status',
description: `The Cloudflare account the checkup covers, its latest completed run and any run in progress. accountId picks one of several linked accounts. ${SUPPORT_DESCRIPTION}`,
tags: ['cloudflare'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
request: { query: z.object({ customerId: Id.optional(), accountId: CloudflareId.optional() }) },
responses: { 200: CloudflareCheckupStatus },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/services/cloudflare/checkups' }],
expose: { mcp: 'code-mode', cli: 'cf checkup status', llms: true },
});
// ---------------------------------------------------------------- change requests
const ChangeStatus = z.enum([
'requested', 'awaiting_customer_approval', 'ready', 'executing', 'applied', 'awaiting_propagation', 'verification_failed',
'failed', 'uncertain', 'rejected', 'expired', 'rolling_back', 'rolled_back', 'rollback_awaiting_propagation',
'rollback_uncertain', 'completed_manually',
]);
/** A change the customer asked Vigilbase to make, and where it stands. */
export const ChangeRequest = z
.object({
id: Id,
customerId: Id,
title: z.string(),
description: z.string(),
reference: z.string().nullable(),
status: ChangeStatus,
revision: z.number().int(),
hasPlan: z.boolean().meta({ description: 'Whether Vigilbase has prepared the exact change.' }),
approvalExpiresAt: Timestamp.nullable(),
error: z.string().nullable(),
createdAt: Timestamp,
updatedAt: Timestamp,
})
.meta({ id: 'ChangeRequest' });
export const listChangeRequests = defineOperation({
id: 'one.changeRequests.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/change-requests',
summary: 'List change requests',
description: 'The customer’s change requests, newest first, optionally of one status. Customers get their own; staff name the customer with customerId.',
tags: ['change-requests'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
pagination: 'cursor',
request: {
query: ListQuery.extend({
limit: z.coerce.number().int().positive().max(100).default(50),
customerId: Id.optional(),
status: ChangeStatus.optional(),
}),
},
responses: { 200: page(ChangeRequest) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/change-requests' }],
expose: { mcp: 'code-mode', llms: true },
});
export const createChangeRequest = defineOperation({
id: 'one.changeRequests.create',
product: 'one',
version: 'v1',
method: 'POST',
path: '/change-requests',
summary: 'Request a change',
description: 'Asks Vigilbase to make a change for the customer. Needs a verified email for customer callers.',
tags: ['change-requests'],
stability: 'beta',
audience: 'customer',
auth: ONE_WRITE_AUTH,
permissions: ['read:services'],
idempotency: 'optional',
request: {
body: z.strictObject({
customerId: Id,
title: z.string().trim().min(5).max(200),
description: z.string().trim().min(10).max(5000),
reference: z.string().trim().min(1).max(1000).optional(),
}),
},
responses: { 201: ChangeRequest },
errors: WRITE_ERRORS,
legacy: [{ host: 'one', path: '/api/change-requests' }],
expose: { mcp: 'code-mode', llms: true },
});
// ---------------------------------------------------------------- tool runs
/** A tool run (a scan or checkup) the caller’s organisation can see. */
export const ToolRun = z
.object({
id: Id,
toolName: z.string(),
target: z.string(),
targetType: z.string(),
status: ToolRunStatus,
grade: z.string().nullable(),
gradeScore: z.number().nullable(),
sourceApp: z.string().nullable(),
email: z.string().nullable().meta({ description: 'Who ran it.' }),
createdAt: Timestamp.nullable(),
startedAt: Timestamp.nullable(),
completedAt: Timestamp.nullable(),
})
.meta({ id: 'ToolRun' });
export const ToolRunDetail = ToolRun.extend({
customerId: Id.nullable(),
unlocked: z.boolean(),
errorMessage: z.string().nullable(),
results: z.record(z.string(), z.unknown()).nullable().meta({ description: 'The tool’s stored result.' }),
}).meta({ id: 'ToolRunDetail' });
export const listToolRuns = defineOperation({
id: 'one.toolRuns.list',
product: 'one',
version: 'v1',
method: 'GET',
path: '/tool-runs',
summary: 'List tool runs',
description: 'Tool runs the caller’s organisation can see, newest first. accountId matches a Cloudflare account ID or the stored target. Staff name the customer with customerId.',
tags: ['tool-runs'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
pagination: 'cursor',
request: {
query: ListQuery.extend({
limit: z.coerce.number().int().positive().max(100).default(50),
customerId: Id.optional(),
toolName: z.string().min(1).max(64).optional(),
accountId: z.string().min(1).max(255).optional(),
}),
},
responses: { 200: page(ToolRun) },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/tool-runs' }],
expose: { mcp: 'code-mode', cli: 'runs list', llms: true },
});
export const getToolRun = defineOperation({
id: 'one.toolRuns.get',
product: 'one',
version: 'v1',
method: 'GET',
path: '/tool-runs/{runId}',
summary: 'Get a tool run',
description: 'One tool run with its stored result.',
tags: ['tool-runs'],
stability: 'beta',
audience: 'customer',
auth: ONE_READ_AUTH,
permissions: ['read:services'],
request: { params: z.object({ runId: Id }), query: z.object({ customerId: Id.optional() }) },
responses: { 200: ToolRunDetail },
errors: READ_ERRORS,
legacy: [{ host: 'one', path: '/api/tool-runs/{id}' }],
expose: { mcp: 'code-mode', cli: 'runs show', llms: true },
});
export const supportServicesOperations = [
listSupportTickets,
createSupportTicket,
listSupportTicketMessages,
replyToSupportTicket,
listCustomerCloudflareZones,
listCloudflareDnsRecords,
getCloudflareZoneSecurity,
getCloudflareCheckupStatus,
listChangeRequests,
createChangeRequest,
listToolRuns,
getToolRun,
];