Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103import { z } from "zod";import type { SkillRequirements } from "./skill-permissions";
export const SKILL_FORMAT_VERSION = 1;export const SKILL_MAX_FILES = 128;export const SKILL_MAX_FILE_BYTES = 256 * 1024;export const SKILL_MAX_PACKAGE_BYTES = 2 * 1024 * 1024;export const SKILL_MAX_INSTRUCTION_BYTES = 32 * 1024;export const skillName = z .string() .max(64) .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);export const skillVersion = z .string() .max(64) .regex( /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/, ) .refine((version) => { const prerelease = version.split("+")[0].split("-").slice(1).join("-"); return prerelease.split(".").every((part) => !/^0\d+$/.test(part)); });const publicSourceUrl = z .url() .max(2048) .refine((value) => { try { const url = new URL(value); return url.protocol === "https:" && !url.username && !url.password; } catch { return false; } }, "Use an HTTPS source without embedded credentials") .transform((value) => { const url = new URL(value); url.search = ""; url.hash = ""; return url.href; }) .pipe(z.string().max(2048));export const skillOrigin = z.discriminatedUnion("kind", [ z.strictObject({ kind: z.literal("bundled"), release: z.string().min(1).max(100), }), z.strictObject({ kind: z.literal("upload"), filename: z .string() .min(1) .max(200) .regex(/^[^\\/\u0000-\u001f\u007f]+$/), }), z.strictObject({ kind: z.literal("url"), url: publicSourceUrl }),]);export type SkillOrigin = z.infer<typeof skillOrigin>;export const skillPackageInput = z.strictObject({ formatVersion: z.literal(SKILL_FORMAT_VERSION), files: z .array( z.strictObject({ path: z.string().min(1).max(240), encoding: z.enum(["text", "base64"]).default("text"), content: z.string().max(Math.ceil(SKILL_MAX_FILE_BYTES / 3) * 4), }), ) .min(1) .max(SKILL_MAX_FILES),});export type SkillPackageInput = z.input<typeof skillPackageInput>;export type SkillPackageFile = z.output< typeof skillPackageInput>["files"][number];export interface SkillPackageMetadata { formatVersion: typeof SKILL_FORMAT_VERSION; name: string; description: string; version: string; fingerprint: string; origin: SkillOrigin; fileCount: number; totalBytes: number; scripts: string[]; permissions: SkillRequirements;}
export interface SkillListing extends SkillPackageMetadata { enabled: boolean; revision: number;}export const skillSelection = z.strictObject({ source: z.enum(["bundled", "installed"]), name: skillName, fingerprint: z.string().regex(/^[a-f0-9]{64}$/), revision: z .number() .int() .min(0) .max(Number.MAX_SAFE_INTEGER - 1), enabled: z.boolean(),});export type SkillSelection = z.infer<typeof skillSelection>;