@kubb/studio 5.19.1 → 5.20.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 +0 -104
- package/dist/index.cjs +136 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -3
- package/dist/index.d.ts +65 -3
- package/dist/index.js +132 -8
- package/dist/index.js.map +1 -1
- package/dist/{protocol-xk8P0Zhv.js → protocol-BYLMyS9H.js} +10 -2
- package/dist/{protocol-xk8P0Zhv.js.map → protocol-BYLMyS9H.js.map} +1 -1
- package/dist/{protocol-BFIUEXLA.d.cts → protocol-CgearBUc.d.cts} +29 -2
- package/dist/{protocol-BFIUEXLA.d.ts → protocol-CgearBUc.d.ts} +29 -2
- package/dist/{protocol-CmX5XTPc.cjs → protocol-D-n2Uczq.cjs} +21 -1
- package/dist/{protocol-CmX5XTPc.cjs.map → protocol-D-n2Uczq.cjs.map} +1 -1
- package/dist/protocol.cjs +3 -1
- package/dist/protocol.d.cts +2 -2
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +1 -1
- package/package.json +4 -4
|
@@ -75,6 +75,14 @@ const AgentMessage = {
|
|
|
75
75
|
READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec",
|
|
76
76
|
NO_INPUT: "This job kept no API input"
|
|
77
77
|
};
|
|
78
|
+
const MAX_CONNECT_CHALLENGE_LENGTH = 1024;
|
|
79
|
+
/**
|
|
80
|
+
* What a signature is for. A signature made for one context never verifies for another.
|
|
81
|
+
*/
|
|
82
|
+
const AgentSignatureContext = {
|
|
83
|
+
CONNECT: "kubb-studio/agent-connect/v1",
|
|
84
|
+
TOKEN_REFRESH: "kubb-studio/agent-token-refresh/v1"
|
|
85
|
+
};
|
|
78
86
|
/**
|
|
79
87
|
* Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
|
|
80
88
|
* was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
|
|
@@ -112,6 +120,6 @@ const AgentPermission = {
|
|
|
112
120
|
FILE_REFS: "allowFileRefs",
|
|
113
121
|
EXEC: "allowExec"
|
|
114
122
|
};
|
|
115
|
-
export { AgentPermission as a,
|
|
123
|
+
export { AgentPermission as a, MAX_FILES_PER_REQUEST as c, generationEventTypes as d, ConfigEditOperation as f, AgentMessage as i, MAX_PAGE_LINES as l, AGENT_SOCKET_PATH as n, AgentSignatureContext as o, extensionKinds as p, AgentCloseCode as r, MAX_CONNECT_CHALLENGE_LENGTH as s, AGENT_INSTANCE_HEADER as t, MAX_SNAPSHOT_BYTES as u };
|
|
116
124
|
|
|
117
|
-
//# sourceMappingURL=protocol-
|
|
125
|
+
//# sourceMappingURL=protocol-BYLMyS9H.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-xk8P0Zhv.js","names":[],"sources":["../../../internals/shared/src/configFile/types.ts","../src/protocol.ts"],"sourcesContent":["import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import type { ValueOf } from '@internals/utils'\nimport type { InputNode } from '@kubb/ast'\nimport type { KubbHooks } from '@kubb/core'\nimport type { ConfigEdit, ConfigEditOutcome, ConfigFileView, ConfigRef, ExtensionEntry } from '@internals/shared'\n\nexport {\n ConfigEditOperation,\n type ConfigEdit,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n type ExtensionEntry,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from '@internals/shared'\n\n/**\n * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds\n * functions and class instances that cannot survive JSON, so both sides pass this flattened shape\n * and rebuild the real config from it.\n */\nexport type JSONKubbConfig = {\n /**\n * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)\n * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry\n * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.\n */\n plugins?: Array<{\n name: string\n options?: object\n disabled?: boolean\n }>\n /**\n * Raw OpenAPI / Swagger spec content (YAML or JSON string), never a file path.\n * Required by a 'sandbox' agent, which has no disk config of its own and refuses anything else.\n * A 'managed' agent also takes a URL or a `git+<repo>#<ref>:<path>` input, and falls back to its disk config without one.\n * Any other agent always reads its spec from disk, so this is ignored with a `kubb:warn`.\n */\n input?: string\n /**\n * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options\n * and re-applied through the same adapter factory, since an adapter instance's functions\n * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.\n */\n adapter?: object\n /**\n * Parser option overrides from Studio, matched to the disk config's parsers by `name` and\n * re-applied through each parser's factory, the same way `adapter` is.\n */\n parsers?: Array<{\n name: string\n options?: object\n }>\n /** Root `output` overrides for `barrel`, `format`, `lint`, `clean`, and `defaultBanner`. Other members are ignored. */\n output?: object\n /**\n * Which `defineConfig(...)` entry to generate from. Omitted runs the first one.\n */\n config?: ConfigRef\n}\n\n/**\n * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;\n * adding a core hook does not publish it to Studio until it is listed here and projected below.\n */\nexport const generationEventTypes = [\n 'kubb:plugin:start',\n 'kubb:plugin:end',\n 'kubb:build:start',\n 'kubb:build:end',\n 'kubb:files:processing:start',\n 'kubb:files:processing:update',\n 'kubb:files:processing:end',\n 'kubb:info',\n 'kubb:success',\n 'kubb:warn',\n 'kubb:error',\n 'kubb:diagnostic',\n 'kubb:generation:start',\n 'kubb:generation:end',\n 'kubb:generation:summary',\n 'kubb:lifecycle:start',\n 'kubb:lifecycle:end',\n 'kubb:format:start',\n 'kubb:format:end',\n 'kubb:lint:start',\n 'kubb:lint:end',\n 'kubb:hooks:start',\n 'kubb:hooks:end',\n 'kubb:hook:start',\n 'kubb:hook:line',\n 'kubb:hook:end',\n] as const satisfies ReadonlyArray<keyof KubbHooks>\n\n/**\n * One of the lifecycle hooks {@link generationEventTypes} publishes.\n */\nexport type GenerationEventType = (typeof generationEventTypes)[number]\n\n/**\n * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook\n * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.\n */\nexport type GenerationEventPayloads = {\n 'kubb:plugin:start': [ctx: { plugin: { name: string } }]\n 'kubb:plugin:end': [ctx: { plugin: { name: string }; duration: number; success: boolean }]\n 'kubb:build:start': [ctx: { config: { name?: string }; adapter: { name: string } }]\n 'kubb:build:end': [ctx: { files: Array<{ path: string; name: string }>; outputDir: string }]\n 'kubb:files:processing:start': [ctx: { total: number }]\n 'kubb:files:processing:update': [\n ctx: {\n files: Array<{\n file: string\n processed: number\n total: number\n percentage: number\n }>\n },\n ]\n 'kubb:files:processing:end': [ctx: { total: number }]\n 'kubb:info': [ctx: { message: string; info?: string }]\n 'kubb:success': [ctx: { message: string; info?: string }]\n 'kubb:warn': [ctx: { message: string; info?: string }]\n 'kubb:error': [ctx: { message: string; stack?: string }]\n 'kubb:diagnostic': [\n ctx: {\n code: string\n message: string\n severity: string\n location?: { kind: string; pointer?: string; ref?: string }\n help?: string\n plugin?: string\n stack?: string\n },\n ]\n 'kubb:generation:start': [ctx: { name?: string; plugins: number }]\n /**\n * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and\n * `readFiles` for contents.\n */\n 'kubb:generation:end': []\n 'kubb:generation:summary': [ctx: { duration: number; fileCount: number; failedPlugins: number; status: 'success' | 'failed' }]\n 'kubb:lifecycle:start': []\n 'kubb:lifecycle:end': []\n 'kubb:format:start': []\n 'kubb:format:end': []\n 'kubb:lint:start': []\n 'kubb:lint:end': []\n 'kubb:hooks:start': []\n 'kubb:hooks:end': []\n 'kubb:hook:start': [ctx: { id?: string; command: string; args?: Array<string> }]\n 'kubb:hook:line': [ctx: { id: string; line: string }]\n 'kubb:hook:end': [\n ctx: {\n id?: string\n command: string\n args?: Array<string>\n success: boolean\n error?: { message: string; stack?: string }\n },\n ]\n}\n\n/**\n * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent\n * emitted them in, so the receiver replays a run by reading the stream straight through.\n */\nexport type GenerationEvent = {\n [Type in GenerationEventType]: { type: Type; data: GenerationEventPayloads[Type] }\n}[GenerationEventType] & {\n version: 1\n jobId: string\n timestamp: number\n}\n\n/**\n * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller\n * watching several runs can tell them apart. `requestedBy` names the Studio user in the agent's\n * command log, and Studio leaves it out for a shared agent.\n */\nexport type GenerateInput = {\n jobId: string\n config: JSONKubbConfig\n /**\n * Display name of the Studio user who asked for the run, shown in the agent's job log.\n */\n requestedBy?: string\n /**\n * A short-lived `Authorization` header value that a managed agent sends with the git fetch of a `git+` input, to its origin only.\n */\n gitAuth?: { authorization: string }\n}\n\n/**\n * What a finished run produced.\n */\nexport type GenerateResult = {\n status: 'success' | 'failed'\n /**\n * Paths of the generated files, relative to the output directory.\n */\n files: Array<string>\n fileCount: number\n /**\n * Content fingerprint per file in `files`, to tell changed files apart without reading them.\n */\n hashes: Record<string, string>\n}\n\n/**\n * Asks the agent to apply a batch of edits to the config file on disk. `requestedBy` as for {@link GenerateInput}.\n */\nexport type SaveConfigInput = {\n edits: Array<ConfigEdit>\n /**\n * Display name of the Studio user who asked for the save, shown in the agent's job log.\n */\n requestedBy?: string\n}\n\n/**\n * Per-edit outcomes. `changed` is false when every edit was a no-op, so a caller can skip reloading.\n */\nexport type SaveResult = { outcomes: Array<ConfigEditOutcome>; changed: boolean }\n\n/** Asks the agent to run `kubb add <id>`: `owner/slug`, or a bare `slug` for an official extension. `requestedBy` as for {@link GenerateInput}. */\nexport type InstallExtensionInput = { id: string; requestedBy?: string }\n\n/** `installed` is false when the agent refused or `kubb add` failed, with `reason` saying why. */\nexport type InstallExtensionResult = { installed: boolean; reason?: string }\n\n/** Asks the agent to run `kubb update [ids] --yes`. Empty `ids` updates every installed extension the registry lists. */\nexport type UpdateExtensionsInput = { ids?: Array<string>; requestedBy?: string }\n\n/** `updated` is false when the agent refused or `kubb update` failed, with `reason` saying why. */\nexport type UpdateExtensionsResult = { updated: boolean; reason?: string }\n\n/** Asks the agent to run `kubb remove <id> --yes`. `requestedBy` as for {@link GenerateInput}. */\nexport type RemoveExtensionInput = { id: string; requestedBy?: string }\n\n/** `removed` is false when the agent refused or `kubb remove` failed, with `reason` saying why. */\nexport type RemoveExtensionResult = { removed: boolean; reason?: string }\n\n/**\n * Reads an immutable output set kept on disk, from a generation or the initial connection.\n */\nexport type ReadFilesInput = {\n jobId: string\n paths: Array<string>\n cursor?: number\n limit?: number\n}\n\n/**\n * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.\n */\nexport type FilePage = { nextCursor: number | null; totalLines: number }\n\n/**\n * What a file read returns. `pages` is set only for a paged read.\n */\nexport type ReadFilesResult = { files: Record<string, string>; pages?: Record<string, FilePage> }\n\n/**\n * Asks for one page of a file's line diff between two kept sets, so a large file never leaves the agent whole.\n * `jobId`'s `output` is the newer side, `base` the older one. `cursor` and `limit` page the patch lines.\n */\nexport type ReadDiffInput = { jobId: string; path: string; base: { jobId: string }; cursor?: number; limit: number }\n\n/**\n * One hunk of a diff page, with its `@@` header. Pages hold whole hunks, and only a hunk longer than a page is\n * split: its parts keep `index` and the header.\n */\nexport type DiffHunk = { index: number; oldStart: number; oldLines: number; newStart: number; newLines: number; lines: Array<string> }\n\n/**\n * The size of the whole diff, sent with every page, so a viewer can summarize it before reading every page.\n */\nexport type DiffStats = {\n additions: number\n deletions: number\n hunks: number\n /**\n * Patch lines in all hunks, the range `cursor` pages through.\n */\n lines: number\n /**\n * True when part of the diff ran out of time and shows as one block that replaces those lines.\n */\n coarse: boolean\n}\n\n/**\n * One page of a diff. `hasBase` is false, and the page empty, when the base set does not hold the path.\n */\nexport type ReadDiffResult = { hunks: Array<DiffHunk>; nextCursor: number | null; hasBase: boolean; stats: DiffStats }\n\n/**\n * Asks for the Kubb AST one job parsed its spec into. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.\n */\nexport type ReadInputInput = { jobId: string }\n\n/**\n * The job's `InputNode`, as JSON. A ref schema names its target, which `input.schemas` holds, without a copy.\n */\nexport type ReadInputResult = { input: InputNode }\n\n/**\n * Why the agent refuses a request. Studio matches on these to answer with the right status.\n */\nexport const AgentMessage = {\n GENERATION_IN_PROGRESS: 'A generation is already in progress, please wait for it to finish',\n INSTALL_IN_PROGRESS: 'An extension install or update is running, please wait for it to finish',\n SAVE_IN_PROGRESS: 'The config is being saved, please wait for it to finish',\n SANDBOX_INPUT_ONLY: 'A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL',\n MANAGED_INPUT_KIND: 'A managed agent generates from the OpenAPI document content, a URL, or a git file that Studio sends, not from a file path',\n CONFIG_ENTRY_NOT_FOUND: 'The config file has no entry at that position or with that name',\n JOB_REQUIRED: 'The request must name a job',\n FILE_REQUEST_INVALID: 'The request must name an output set and carry paths',\n TOO_MANY_FILES: 'Too many paths were requested at once',\n INVALID_PAGE: 'The requested file page is invalid',\n DIFF_REQUEST_INVALID: 'The request must name a job, a base, and a path',\n HASHES_ONLY: 'This agent kept only the hashes of that job',\n /**\n * A read for a job whose files the agent no longer keeps.\n */\n GENERATION_GONE: 'The files of this generation are no longer kept on the agent, run the generation again',\n READ_NOT_ALLOWED: 'The agent was not granted permission to read generated files',\n /**\n * Reading the parsed spec is its own permission.\n */\n READ_AST_NOT_ALLOWED: 'The agent was not granted permission to read the parsed spec',\n NO_INPUT: 'This job kept no API input',\n} as const\nexport type AgentMessage = ValueOf<typeof AgentMessage>\n\n/**\n * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can\n * read `events()` while `result()` is still pending and `cancel()` stops it early.\n */\nexport type GenerationRun = {\n events: () => Promise<ReadableStream<GenerationEvent>>\n result: () => Promise<GenerateResult>\n cancel: () => Promise<void>\n}\n\n/**\n * Every kind of agent Studio knows. A host passes its own kind to `connectAgent`.\n */\nexport type AgentType = 'user' | 'cli' | 'ci' | 'sandbox' | 'global' | 'managed'\n\n/**\n * What Studio knows about the agent on the other end of a socket. Studio passes it with every\n * {@link AgentApi.connect} call. Its `sandbox` flag can only take permissions away. The host decides the rest.\n */\nexport type AgentConnectInfo = {\n /**\n * A shared `sandbox` or `global` agent. It keeps generations on temporary disk, runs each job in a\n * temporary root, and generates from the spec Studio sends without editing a project or its config.\n */\n sandbox: boolean\n /**\n * A `managed` agent Studio hosts for the organization. It has no project spec on disk, so it\n * may generate from a spec Studio sends: the content, a URL, or a git file.\n */\n managed?: boolean\n agentSlug: string\n /**\n * Absent for a sandbox or global agent, which belongs to no organization.\n */\n organizationSlug?: string\n studioVersion: string\n}\n\n/**\n * Operations Studio invokes on an agent over its socket.\n */\nexport type AgentApi = {\n /**\n * The first call on every socket, and again whenever Studio needs the current config.\n */\n connect: (info: AgentConnectInfo) => Promise<ConnectMessagePayload>\n startGeneration: (input: GenerateInput) => GenerationRun\n saveConfig: (input: SaveConfigInput) => Promise<SaveResult>\n /** Refused without `allowInstall` and `allowConfigEdit`. An agent from before `installExtension` rejects the call. */\n installExtension: (input: InstallExtensionInput) => Promise<InstallExtensionResult>\n /** Refused without `allowUpdate`. Installs packages only, so `kubb.config.ts` stays as it is. */\n updateExtensions: (input: UpdateExtensionsInput) => Promise<UpdateExtensionsResult>\n /** Refused without `allowRemove` and `allowConfigEdit`. An agent from before `removeExtension` rejects the call. */\n removeExtension: (input: RemoveExtensionInput) => Promise<RemoveExtensionResult>\n readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readInput: (input: ReadInputInput) => Promise<ReadInputResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readDiff: (input: ReadDiffInput) => Promise<ReadDiffResult>\n}\n\n/**\n * Operations an agent invokes on Studio over its socket.\n */\nexport type StudioApi = {\n /**\n * Keeps the connection alive. A ping that does not settle in time makes the agent reconnect.\n */\n ping: () => Promise<void>\n}\n\n/**\n * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token\n * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`\n * included, is an ordinary drop and the agent reconnects.\n */\nexport const AgentCloseCode = {\n UNAUTHORIZED: 4001,\n SUPERSEDED: 4002,\n INCOMPATIBLE: 4003,\n} as const\n\nexport const AGENT_SOCKET_PATH = '/api/agent/socket'\n\n/**\n * Optional header naming the process a socket belongs to, for agents that run several processes.\n */\nexport const AGENT_INSTANCE_HEADER = 'x-kubb-instance-id'\n\n/**\n * How many files a single `readFiles` request may ask for at once.\n */\nexport const MAX_FILES_PER_REQUEST = 50\n\n/** Most lines one page may ask for. */\nexport const MAX_PAGE_LINES = 2000\n\nexport const MAX_SNAPSHOT_BYTES = 50 * 1024 * 1024\n\n/**\n * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with\n * everything about the config under one key.\n */\nexport type ConnectMessagePayload = {\n /**\n * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these\n * and the host prints them.\n */\n versions: {\n /**\n * The version of the `@kubb/studio` runtime the agent runs.\n */\n kubb: string\n /**\n * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).\n */\n agent: string\n }\n /**\n * The agent's project root. This is the workspace that generation runs against.\n */\n root: string\n /**\n * The baseline every generation starts from.\n */\n config: {\n /**\n * The config path as the host gave it, relative to `root` unless absolute.\n */\n path: string\n /**\n * What the agent read out of the config file itself, so Studio can render the plugin editor\n * against the real file. Absent when the agent could not read it, or was not granted\n * `allowConfigEdit`.\n */\n file?: ConfigFileView\n /** Installed packages that ship a `kubb-extension.json`, including plugins the config does not use yet. */\n extensions?: Array<ExtensionEntry>\n /** Every entry the config exports, in source order. */\n configs: Array<ConfigEntryView>\n }\n permissions: AgentPermissions\n}\n\nexport type DiskOutput = {\n jobId: string\n files: Array<string>\n hashes: Record<string, string>\n}\n\n/**\n * One `defineConfig(...)` entry as the agent runs it. Every option is a JSON copy: anything JSON cannot\n * hold, such as a function, is left out. A plugin defined in the project keeps its own `name`.\n */\nexport type ConfigEntryView = {\n name?: string\n /** The input file path or URL, without credentials. Omitted for an inline or parsed document. */\n input?: string\n /** The output directory as the entry gives it, relative to the project root unless absolute. */\n output: string\n /** The root `output` members Studio may set, as a JSON copy. */\n outputOptions?: object\n /**\n * The output directory's current file list, readable through `readFiles` without generating.\n * Absent for a sandbox or when the host has not granted `allowRead`.\n */\n disk?: DiskOutput\n plugins: Array<{\n name: string\n options?: object\n }>\n adapter?: {\n name: string\n options?: object\n }\n parsers: Array<{\n name: string\n options?: object\n }>\n}\n\n/**\n * What an agent may do in the project it serves. Every one is off unless the host granted it, and\n * a sandbox narrows them further.\n */\nexport type AgentPermissions = {\n /**\n * Whether the agent writes generated files to disk. Always false for a sandbox.\n */\n allowWrite: boolean\n /**\n * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child\n * processes after a generation.\n */\n allowExec: boolean\n /**\n * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from\n * `allowWrite`, which covers generated output: this one edits a hand-authored source file.\n */\n allowConfigEdit: boolean\n /** Whether the agent may run `kubb add` in the project, which also edits `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowInstall: boolean\n /** Whether the agent may run `kubb update` in the project, which installs newer extension versions and leaves `kubb.config.ts` alone. */\n allowUpdate: boolean\n /** Whether the agent may run `kubb remove` in the project, which edits `kubb.config.ts` and uninstalls packages. Needs `allowConfigEdit` as well. */\n allowRemove: boolean\n /** Whether the agent may keep the spec Studio sends: a document in `openapi.yaml` and `input` in `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowSaveInput: boolean\n /** Whether a `$ref` in the spec may read a local file outside the project. Never on a sandbox or managed agent, which read none. */\n allowFileRefs: boolean\n /**\n * Whether the agent shares existing output on connect and hands back file source through\n * `readFiles`. A sandbox the host declares always permits reads of its generated files.\n */\n allowRead: boolean\n /**\n * Whether the agent hands back the parsed spec (the Kubb AST) in response to `readInput`.\n * Separate from `allowRead`, which covers generated files. Always true for a sandbox the host declares.\n */\n allowReadAst: boolean\n}\n\n/**\n * The keys of {@link AgentPermissions}, such as the permission a refused request names.\n */\nexport const AgentPermission = {\n READ: 'allowRead',\n READ_AST: 'allowReadAst',\n WRITE: 'allowWrite',\n CONFIG_EDIT: 'allowConfigEdit',\n INSTALL: 'allowInstall',\n UPDATE: 'allowUpdate',\n REMOVE: 'allowRemove',\n SAVE_INPUT: 'allowSaveInput',\n FILE_REFS: 'allowFileRefs',\n EXEC: 'allowExec',\n} as const satisfies Record<string, keyof AgentPermissions>\nexport type AgentPermission = ValueOf<typeof AgentPermission>\n\n/**\n * Metadata part of `POST /api/snapshots`. The `tarball` part carries the packed package.\n */\nexport type SnapshotUploadMetadata = {\n /**\n * Stable CI identity, such as `gh:<repoId>:<pr>`. Snapshots with the same `id` share one CI agent.\n */\n id: string\n name: string\n packageName: string\n version: string\n /**\n * The commit the snapshot is built from, so the next one can name it as its base.\n */\n commit?: string\n /**\n * The `id` of another CI agent, such as the base branch's, to also compare with.\n */\n baseId?: string\n /**\n * Content fingerprint per generated file, keyed by path relative to the project root.\n */\n hashes: Record<string, string>\n peerDependencies: Record<string, string>\n}\n\n/**\n * How a snapshot's files differ from an earlier snapshot of the same package.\n */\nexport type SnapshotChanges = {\n /**\n * The snapshot these changes are measured against, `null` when there is none to compare with.\n */\n base: { id: string; version: string | null; commit?: string; createdAt: string; number?: number } | null\n added: Array<string>\n changed: Array<string>\n removed: Array<string>\n}\n\n/**\n * {@link SnapshotChanges} against another CI agent. `baseFound` is `false` when Studio has no CI\n * agent with that id yet, and `true` when it has one without a snapshot of this package.\n */\nexport type BranchSnapshotChanges = SnapshotChanges & { baseFound: boolean }\n\n/**\n * Response body of `POST /api/snapshots`: `{ snapshot: PublishedSnapshot }`.\n */\nexport type PublishedSnapshot = {\n id: string\n name: string | null\n version: string | null\n integrity: string | null\n agent: { id: string; name: string; slug: string | null }\n /**\n * Readable download path, often `/packages/{agentSlug}/{name}.tgz`.\n */\n url: string\n snapshotIdUrl: string\n /**\n * Studio page of this snapshot, such as `/kubb-labs/petstore/182`. Absent from a Studio that does not send it.\n */\n webUrl?: string\n /**\n * The snapshot's sequence number on its CI agent, shown as `#182`. Absent from a Studio that does not send it.\n */\n number?: number\n createdAt: string\n expiresAt: string\n /**\n * What changed since the previous snapshot of this package on the same CI agent.\n */\n changes?: SnapshotChanges\n /**\n * What differs from the latest snapshot of the CI agent `baseId` names. Absent without a base.\n */\n branchChanges?: BranchSnapshotChanges\n}\n"],"mappings":";AASA,MAAa,iBAAiB;CAAE,QAAQ;CAAU,SAAS;CAAW,QAAQ;AAAS;AAEvF,MAAa,sBAAsB;CACjC,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,WAAW;CACX,YAAY;CACZ,eAAe;AACjB;;;;;;AC+CA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AA0NA,MAAa,eAAe;CAC1B,wBAAwB;CACxB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,oBAAoB;CACpB,wBAAwB;CACxB,cAAc;CACd,sBAAsB;CACtB,gBAAgB;CAChB,cAAc;CACd,sBAAsB;CACtB,aAAa;;;;CAIb,iBAAiB;CACjB,kBAAkB;;;;CAIlB,sBAAsB;CACtB,UAAU;AACZ;;;;;;AAmFA,MAAa,iBAAiB;CAC5B,cAAc;CACd,YAAY;CACZ,cAAc;AAChB;AAEA,MAAa,oBAAoB;;;;AAKjC,MAAa,wBAAwB;;;;AAKrC,MAAa,wBAAwB;;AAGrC,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;;;;AAgIlC,MAAa,kBAAkB;CAC7B,MAAM;CACN,UAAU;CACV,OAAO;CACP,aAAa;CACb,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,MAAM;AACR"}
|
|
1
|
+
{"version":3,"file":"protocol-BYLMyS9H.js","names":[],"sources":["../../../internals/shared/src/configFile/types.ts","../src/protocol.ts"],"sourcesContent":["import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import type { ValueOf } from '@internals/utils'\nimport type { InputNode } from '@kubb/ast'\nimport type { KubbHooks } from '@kubb/core'\nimport type { ConfigEdit, ConfigEditOutcome, ConfigFileView, ConfigRef, ExtensionEntry } from '@internals/shared'\n\nexport {\n ConfigEditOperation,\n type ConfigEdit,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n type ExtensionEntry,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from '@internals/shared'\n\n/**\n * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds\n * functions and class instances that cannot survive JSON, so both sides pass this flattened shape\n * and rebuild the real config from it.\n */\nexport type JSONKubbConfig = {\n /**\n * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)\n * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry\n * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.\n */\n plugins?: Array<{\n name: string\n options?: object\n disabled?: boolean\n }>\n /**\n * Raw OpenAPI / Swagger spec content (YAML or JSON string), never a file path.\n * Required by a 'sandbox' agent, which has no disk config of its own and refuses anything else.\n * A 'managed' agent also takes a URL or a `git+<repo>#<ref>:<path>` input, and falls back to its disk config without one.\n * Any other agent always reads its spec from disk, so this is ignored with a `kubb:warn`.\n */\n input?: string\n /**\n * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options\n * and re-applied through the same adapter factory, since an adapter instance's functions\n * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.\n */\n adapter?: object\n /**\n * Parser option overrides from Studio, matched to the disk config's parsers by `name` and\n * re-applied through each parser's factory, the same way `adapter` is.\n */\n parsers?: Array<{\n name: string\n options?: object\n }>\n /** Root `output` overrides for `barrel`, `format`, `lint`, `clean`, and `defaultBanner`. Other members are ignored. */\n output?: object\n /**\n * Which `defineConfig(...)` entry to generate from. Omitted runs the first one.\n */\n config?: ConfigRef\n}\n\n/**\n * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;\n * adding a core hook does not publish it to Studio until it is listed here and projected below.\n */\nexport const generationEventTypes = [\n 'kubb:plugin:start',\n 'kubb:plugin:end',\n 'kubb:build:start',\n 'kubb:build:end',\n 'kubb:files:processing:start',\n 'kubb:files:processing:update',\n 'kubb:files:processing:end',\n 'kubb:info',\n 'kubb:success',\n 'kubb:warn',\n 'kubb:error',\n 'kubb:diagnostic',\n 'kubb:generation:start',\n 'kubb:generation:end',\n 'kubb:generation:summary',\n 'kubb:lifecycle:start',\n 'kubb:lifecycle:end',\n 'kubb:format:start',\n 'kubb:format:end',\n 'kubb:lint:start',\n 'kubb:lint:end',\n 'kubb:hooks:start',\n 'kubb:hooks:end',\n 'kubb:hook:start',\n 'kubb:hook:line',\n 'kubb:hook:end',\n] as const satisfies ReadonlyArray<keyof KubbHooks>\n\n/**\n * One of the lifecycle hooks {@link generationEventTypes} publishes.\n */\nexport type GenerationEventType = (typeof generationEventTypes)[number]\n\n/**\n * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook\n * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.\n */\nexport type GenerationEventPayloads = {\n 'kubb:plugin:start': [ctx: { plugin: { name: string } }]\n 'kubb:plugin:end': [ctx: { plugin: { name: string }; duration: number; success: boolean }]\n 'kubb:build:start': [ctx: { config: { name?: string }; adapter: { name: string } }]\n 'kubb:build:end': [ctx: { files: Array<{ path: string; name: string }>; outputDir: string }]\n 'kubb:files:processing:start': [ctx: { total: number }]\n 'kubb:files:processing:update': [\n ctx: {\n files: Array<{\n file: string\n processed: number\n total: number\n percentage: number\n }>\n },\n ]\n 'kubb:files:processing:end': [ctx: { total: number }]\n 'kubb:info': [ctx: { message: string; info?: string }]\n 'kubb:success': [ctx: { message: string; info?: string }]\n 'kubb:warn': [ctx: { message: string; info?: string }]\n 'kubb:error': [ctx: { message: string; stack?: string }]\n 'kubb:diagnostic': [\n ctx: {\n code: string\n message: string\n severity: string\n location?: { kind: string; pointer?: string; ref?: string }\n help?: string\n plugin?: string\n stack?: string\n },\n ]\n 'kubb:generation:start': [ctx: { name?: string; plugins: number }]\n /**\n * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and\n * `readFiles` for contents.\n */\n 'kubb:generation:end': []\n 'kubb:generation:summary': [ctx: { duration: number; fileCount: number; failedPlugins: number; status: 'success' | 'failed' }]\n 'kubb:lifecycle:start': []\n 'kubb:lifecycle:end': []\n 'kubb:format:start': []\n 'kubb:format:end': []\n 'kubb:lint:start': []\n 'kubb:lint:end': []\n 'kubb:hooks:start': []\n 'kubb:hooks:end': []\n 'kubb:hook:start': [ctx: { id?: string; command: string; args?: Array<string> }]\n 'kubb:hook:line': [ctx: { id: string; line: string }]\n 'kubb:hook:end': [\n ctx: {\n id?: string\n command: string\n args?: Array<string>\n success: boolean\n error?: { message: string; stack?: string }\n },\n ]\n}\n\n/**\n * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent\n * emitted them in, so the receiver replays a run by reading the stream straight through.\n */\nexport type GenerationEvent = {\n [Type in GenerationEventType]: { type: Type; data: GenerationEventPayloads[Type] }\n}[GenerationEventType] & {\n version: 1\n jobId: string\n timestamp: number\n}\n\n/**\n * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller\n * watching several runs can tell them apart. `requestedBy` names the Studio user in the agent's\n * command log, and Studio leaves it out for a shared agent.\n */\nexport type GenerateInput = {\n jobId: string\n config: JSONKubbConfig\n /**\n * Display name of the Studio user who asked for the run, shown in the agent's job log.\n */\n requestedBy?: string\n /**\n * A short-lived `Authorization` header value that a managed agent sends with the git fetch of a `git+` input, to its origin only.\n */\n gitAuth?: { authorization: string }\n}\n\n/**\n * What a finished run produced.\n */\nexport type GenerateResult = {\n status: 'success' | 'failed'\n /**\n * Paths of the generated files, relative to the output directory.\n */\n files: Array<string>\n fileCount: number\n /**\n * Content fingerprint per file in `files`, to tell changed files apart without reading them.\n */\n hashes: Record<string, string>\n}\n\n/**\n * Asks the agent to apply a batch of edits to the config file on disk. `requestedBy` as for {@link GenerateInput}.\n */\nexport type SaveConfigInput = {\n edits: Array<ConfigEdit>\n /**\n * Display name of the Studio user who asked for the save, shown in the agent's job log.\n */\n requestedBy?: string\n}\n\n/**\n * Per-edit outcomes. `changed` is false when every edit was a no-op, so a caller can skip reloading.\n */\nexport type SaveResult = { outcomes: Array<ConfigEditOutcome>; changed: boolean }\n\n/** Asks the agent to run `kubb add <id>`: `owner/slug`, or a bare `slug` for an official extension. `requestedBy` as for {@link GenerateInput}. */\nexport type InstallExtensionInput = { id: string; requestedBy?: string }\n\n/** `installed` is false when the agent refused or `kubb add` failed, with `reason` saying why. */\nexport type InstallExtensionResult = { installed: boolean; reason?: string }\n\n/** Asks the agent to run `kubb update [ids] --yes`. Empty `ids` updates every installed extension the registry lists. */\nexport type UpdateExtensionsInput = { ids?: Array<string>; requestedBy?: string }\n\n/** `updated` is false when the agent refused or `kubb update` failed, with `reason` saying why. */\nexport type UpdateExtensionsResult = { updated: boolean; reason?: string }\n\n/** Asks the agent to run `kubb remove <id> --yes`. `requestedBy` as for {@link GenerateInput}. */\nexport type RemoveExtensionInput = { id: string; requestedBy?: string }\n\n/** `removed` is false when the agent refused or `kubb remove` failed, with `reason` saying why. */\nexport type RemoveExtensionResult = { removed: boolean; reason?: string }\n\n/**\n * Reads an immutable output set kept on disk, from a generation or the initial connection.\n */\nexport type ReadFilesInput = {\n jobId: string\n paths: Array<string>\n cursor?: number\n limit?: number\n}\n\n/**\n * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.\n */\nexport type FilePage = { nextCursor: number | null; totalLines: number }\n\n/**\n * What a file read returns. `pages` is set only for a paged read.\n */\nexport type ReadFilesResult = { files: Record<string, string>; pages?: Record<string, FilePage> }\n\n/**\n * Asks for one page of a file's line diff between two kept sets, so a large file never leaves the agent whole.\n * `jobId`'s `output` is the newer side, `base` the older one. `cursor` and `limit` page the patch lines.\n */\nexport type ReadDiffInput = { jobId: string; path: string; base: { jobId: string }; cursor?: number; limit: number }\n\n/**\n * One hunk of a diff page, with its `@@` header. Pages hold whole hunks, and only a hunk longer than a page is\n * split: its parts keep `index` and the header.\n */\nexport type DiffHunk = { index: number; oldStart: number; oldLines: number; newStart: number; newLines: number; lines: Array<string> }\n\n/**\n * The size of the whole diff, sent with every page, so a viewer can summarize it before reading every page.\n */\nexport type DiffStats = {\n additions: number\n deletions: number\n hunks: number\n /**\n * Patch lines in all hunks, the range `cursor` pages through.\n */\n lines: number\n /**\n * True when part of the diff ran out of time and shows as one block that replaces those lines.\n */\n coarse: boolean\n}\n\n/**\n * One page of a diff. `hasBase` is false, and the page empty, when the base set does not hold the path.\n */\nexport type ReadDiffResult = { hunks: Array<DiffHunk>; nextCursor: number | null; hasBase: boolean; stats: DiffStats }\n\n/**\n * Asks for the Kubb AST one job parsed its spec into. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.\n */\nexport type ReadInputInput = { jobId: string }\n\n/**\n * The job's `InputNode`, as JSON. A ref schema names its target, which `input.schemas` holds, without a copy.\n */\nexport type ReadInputResult = { input: InputNode }\n\n/**\n * Why the agent refuses a request. Studio matches on these to answer with the right status.\n */\nexport const AgentMessage = {\n GENERATION_IN_PROGRESS: 'A generation is already in progress, please wait for it to finish',\n INSTALL_IN_PROGRESS: 'An extension install or update is running, please wait for it to finish',\n SAVE_IN_PROGRESS: 'The config is being saved, please wait for it to finish',\n SANDBOX_INPUT_ONLY: 'A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL',\n MANAGED_INPUT_KIND: 'A managed agent generates from the OpenAPI document content, a URL, or a git file that Studio sends, not from a file path',\n CONFIG_ENTRY_NOT_FOUND: 'The config file has no entry at that position or with that name',\n JOB_REQUIRED: 'The request must name a job',\n FILE_REQUEST_INVALID: 'The request must name an output set and carry paths',\n TOO_MANY_FILES: 'Too many paths were requested at once',\n INVALID_PAGE: 'The requested file page is invalid',\n DIFF_REQUEST_INVALID: 'The request must name a job, a base, and a path',\n HASHES_ONLY: 'This agent kept only the hashes of that job',\n /**\n * A read for a job whose files the agent no longer keeps.\n */\n GENERATION_GONE: 'The files of this generation are no longer kept on the agent, run the generation again',\n READ_NOT_ALLOWED: 'The agent was not granted permission to read generated files',\n /**\n * Reading the parsed spec is its own permission.\n */\n READ_AST_NOT_ALLOWED: 'The agent was not granted permission to read the parsed spec',\n NO_INPUT: 'This job kept no API input',\n} as const\nexport type AgentMessage = ValueOf<typeof AgentMessage>\n\n/**\n * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can\n * read `events()` while `result()` is still pending and `cancel()` stops it early.\n */\nexport type GenerationRun = {\n events: () => Promise<ReadableStream<GenerationEvent>>\n result: () => Promise<GenerateResult>\n cancel: () => Promise<void>\n}\n\n/**\n * Every kind of agent Studio knows. A host passes its own kind to `connectAgent`.\n */\nexport type AgentType = 'user' | 'cli' | 'ci' | 'sandbox' | 'global' | 'managed'\n\n/**\n * What Studio knows about the agent on the other end of a socket. Studio passes it with every\n * {@link AgentApi.connect} call. Its `sandbox` flag can only take permissions away. The host decides the rest.\n */\nexport type AgentConnectInfo = {\n /**\n * A shared `sandbox` or `global` agent. It keeps generations on temporary disk, runs each job in a\n * temporary root, and generates from the spec Studio sends without editing a project or its config.\n */\n sandbox: boolean\n /**\n * A `managed` agent Studio hosts for the organization. It has no project spec on disk, so it\n * may generate from a spec Studio sends: the content, a URL, or a git file.\n */\n managed?: boolean\n agentSlug: string\n /**\n * Absent for a sandbox or global agent, which belongs to no organization.\n */\n organizationSlug?: string\n studioVersion: string\n /**\n * A challenge that an agent with a key signs in {@link ConnectMessagePayload.signature}.\n */\n challenge?: string\n}\n\nexport const MAX_CONNECT_CHALLENGE_LENGTH = 1024\n\n/**\n * What a signature is for. A signature made for one context never verifies for another.\n */\nexport const AgentSignatureContext = {\n CONNECT: 'kubb-studio/agent-connect/v1',\n TOKEN_REFRESH: 'kubb-studio/agent-token-refresh/v1',\n} as const\nexport type AgentSignatureContext = ValueOf<typeof AgentSignatureContext>\n\n/**\n * The proof an agent with a key adds to a token refresh.\n */\nexport type TokenRefreshProof = {\n /**\n * When the proof was signed, in milliseconds since the Unix epoch.\n */\n signed_at: number\n signature: string\n}\n\n/**\n * Operations Studio invokes on an agent over its socket.\n */\nexport type AgentApi = {\n /**\n * The first call on every socket, and again whenever Studio needs the current config.\n */\n connect: (info: AgentConnectInfo) => Promise<ConnectMessagePayload>\n startGeneration: (input: GenerateInput) => GenerationRun\n saveConfig: (input: SaveConfigInput) => Promise<SaveResult>\n /** Refused without `allowInstall` and `allowConfigEdit`. An agent from before `installExtension` rejects the call. */\n installExtension: (input: InstallExtensionInput) => Promise<InstallExtensionResult>\n /** Refused without `allowUpdate`. Installs packages only, so `kubb.config.ts` stays as it is. */\n updateExtensions: (input: UpdateExtensionsInput) => Promise<UpdateExtensionsResult>\n /** Refused without `allowRemove` and `allowConfigEdit`. An agent from before `removeExtension` rejects the call. */\n removeExtension: (input: RemoveExtensionInput) => Promise<RemoveExtensionResult>\n readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readInput: (input: ReadInputInput) => Promise<ReadInputResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readDiff: (input: ReadDiffInput) => Promise<ReadDiffResult>\n}\n\n/**\n * Operations an agent invokes on Studio over its socket.\n */\nexport type StudioApi = {\n /**\n * Keeps the connection alive. A ping that does not settle in time makes the agent reconnect.\n */\n ping: () => Promise<void>\n}\n\n/**\n * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token\n * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`\n * included, is an ordinary drop and the agent reconnects.\n */\nexport const AgentCloseCode = {\n UNAUTHORIZED: 4001,\n SUPERSEDED: 4002,\n INCOMPATIBLE: 4003,\n} as const\n\nexport const AGENT_SOCKET_PATH = '/api/agent/socket'\n\n/**\n * Optional header naming the process a socket belongs to, for agents that run several processes.\n */\nexport const AGENT_INSTANCE_HEADER = 'x-kubb-instance-id'\n\n/**\n * How many files a single `readFiles` request may ask for at once.\n */\nexport const MAX_FILES_PER_REQUEST = 50\n\n/** Most lines one page may ask for. */\nexport const MAX_PAGE_LINES = 2000\n\nexport const MAX_SNAPSHOT_BYTES = 50 * 1024 * 1024\n\n/**\n * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with\n * everything about the config under one key.\n */\nexport type ConnectMessagePayload = {\n /**\n * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these\n * and the host prints them.\n */\n versions: {\n /**\n * The version of the `@kubb/studio` runtime the agent runs.\n */\n kubb: string\n /**\n * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).\n */\n agent: string\n }\n /**\n * The agent's project root. This is the workspace that generation runs against.\n */\n root: string\n /**\n * The baseline every generation starts from.\n */\n config: {\n /**\n * The config path as the host gave it, relative to `root` unless absolute.\n */\n path: string\n /**\n * What the agent read out of the config file itself, so Studio can render the plugin editor\n * against the real file. Absent when the agent could not read it, or was not granted\n * `allowConfigEdit`.\n */\n file?: ConfigFileView\n /** Installed packages that ship a `kubb-extension.json`, including plugins the config does not use yet. */\n extensions?: Array<ExtensionEntry>\n /** Every entry the config exports, in source order. */\n configs: Array<ConfigEntryView>\n }\n permissions: AgentPermissions\n /**\n * The signed {@link AgentConnectInfo.challenge}, from an agent that holds a key.\n */\n signature?: string\n}\n\nexport type DiskOutput = {\n jobId: string\n files: Array<string>\n hashes: Record<string, string>\n}\n\n/**\n * One `defineConfig(...)` entry as the agent runs it. Every option is a JSON copy: anything JSON cannot\n * hold, such as a function, is left out. A plugin defined in the project keeps its own `name`.\n */\nexport type ConfigEntryView = {\n name?: string\n /** The input file path or URL, without credentials. Omitted for an inline or parsed document. */\n input?: string\n /** The output directory as the entry gives it, relative to the project root unless absolute. */\n output: string\n /** The root `output` members Studio may set, as a JSON copy. */\n outputOptions?: object\n /**\n * The output directory's current file list, readable through `readFiles` without generating.\n * Absent for a sandbox or when the host has not granted `allowRead`.\n */\n disk?: DiskOutput\n plugins: Array<{\n name: string\n options?: object\n }>\n adapter?: {\n name: string\n options?: object\n }\n parsers: Array<{\n name: string\n options?: object\n }>\n}\n\n/**\n * What an agent may do in the project it serves. Every one is off unless the host granted it, and\n * a sandbox narrows them further.\n */\nexport type AgentPermissions = {\n /**\n * Whether the agent writes generated files to disk. Always false for a sandbox.\n */\n allowWrite: boolean\n /**\n * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child\n * processes after a generation.\n */\n allowExec: boolean\n /**\n * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from\n * `allowWrite`, which covers generated output: this one edits a hand-authored source file.\n */\n allowConfigEdit: boolean\n /** Whether the agent may run `kubb add` in the project, which also edits `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowInstall: boolean\n /** Whether the agent may run `kubb update` in the project, which installs newer extension versions and leaves `kubb.config.ts` alone. */\n allowUpdate: boolean\n /** Whether the agent may run `kubb remove` in the project, which edits `kubb.config.ts` and uninstalls packages. Needs `allowConfigEdit` as well. */\n allowRemove: boolean\n /** Whether the agent may keep the spec Studio sends: a document in `openapi.yaml` and `input` in `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowSaveInput: boolean\n /** Whether a `$ref` in the spec may read a local file outside the project. Never on a sandbox or managed agent, which read none. */\n allowFileRefs: boolean\n /**\n * Whether the agent shares existing output on connect and hands back file source through\n * `readFiles`. A sandbox the host declares always permits reads of its generated files.\n */\n allowRead: boolean\n /**\n * Whether the agent hands back the parsed spec (the Kubb AST) in response to `readInput`.\n * Separate from `allowRead`, which covers generated files. Always true for a sandbox the host declares.\n */\n allowReadAst: boolean\n}\n\n/**\n * The keys of {@link AgentPermissions}, such as the permission a refused request names.\n */\nexport const AgentPermission = {\n READ: 'allowRead',\n READ_AST: 'allowReadAst',\n WRITE: 'allowWrite',\n CONFIG_EDIT: 'allowConfigEdit',\n INSTALL: 'allowInstall',\n UPDATE: 'allowUpdate',\n REMOVE: 'allowRemove',\n SAVE_INPUT: 'allowSaveInput',\n FILE_REFS: 'allowFileRefs',\n EXEC: 'allowExec',\n} as const satisfies Record<string, keyof AgentPermissions>\nexport type AgentPermission = ValueOf<typeof AgentPermission>\n\n/**\n * Metadata part of `POST /api/snapshots`. The `tarball` part carries the packed package.\n */\nexport type SnapshotUploadMetadata = {\n /**\n * Stable CI identity, such as `gh:<repoId>:<pr>`. Snapshots with the same `id` share one CI agent.\n */\n id: string\n name: string\n packageName: string\n version: string\n /**\n * The commit the snapshot is built from, so the next one can name it as its base.\n */\n commit?: string\n /**\n * The `id` of another CI agent, such as the base branch's, to also compare with.\n */\n baseId?: string\n /**\n * Content fingerprint per generated file, keyed by path relative to the project root.\n */\n hashes: Record<string, string>\n peerDependencies: Record<string, string>\n}\n\n/**\n * How a snapshot's files differ from an earlier snapshot of the same package.\n */\nexport type SnapshotChanges = {\n /**\n * The snapshot these changes are measured against, `null` when there is none to compare with.\n */\n base: { id: string; version: string | null; commit?: string; createdAt: string; number?: number } | null\n added: Array<string>\n changed: Array<string>\n removed: Array<string>\n}\n\n/**\n * {@link SnapshotChanges} against another CI agent. `baseFound` is `false` when Studio has no CI\n * agent with that id yet, and `true` when it has one without a snapshot of this package.\n */\nexport type BranchSnapshotChanges = SnapshotChanges & { baseFound: boolean }\n\n/**\n * Response body of `POST /api/snapshots`: `{ snapshot: PublishedSnapshot }`.\n */\nexport type PublishedSnapshot = {\n id: string\n name: string | null\n version: string | null\n integrity: string | null\n agent: { id: string; name: string; slug: string | null }\n /**\n * Readable download path, often `/packages/{agentSlug}/{name}.tgz`.\n */\n url: string\n snapshotIdUrl: string\n /**\n * Studio page of this snapshot, such as `/kubb-labs/petstore/182`. Absent from a Studio that does not send it.\n */\n webUrl?: string\n /**\n * The snapshot's sequence number on its CI agent, shown as `#182`. Absent from a Studio that does not send it.\n */\n number?: number\n createdAt: string\n expiresAt: string\n /**\n * What changed since the previous snapshot of this package on the same CI agent.\n */\n changes?: SnapshotChanges\n /**\n * What differs from the latest snapshot of the CI agent `baseId` names. Absent without a base.\n */\n branchChanges?: BranchSnapshotChanges\n}\n"],"mappings":";AASA,MAAa,iBAAiB;CAAE,QAAQ;CAAU,SAAS;CAAW,QAAQ;AAAS;AAEvF,MAAa,sBAAsB;CACjC,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,WAAW;CACX,YAAY;CACZ,eAAe;AACjB;;;;;;AC+CA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AA0NA,MAAa,eAAe;CAC1B,wBAAwB;CACxB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,oBAAoB;CACpB,wBAAwB;CACxB,cAAc;CACd,sBAAsB;CACtB,gBAAgB;CAChB,cAAc;CACd,sBAAsB;CACtB,aAAa;;;;CAIb,iBAAiB;CACjB,kBAAkB;;;;CAIlB,sBAAsB;CACtB,UAAU;AACZ;AA6CA,MAAa,+BAA+B;;;;AAK5C,MAAa,wBAAwB;CACnC,SAAS;CACT,eAAe;AACjB;;;;;;AAwDA,MAAa,iBAAiB;CAC5B,cAAc;CACd,YAAY;CACZ,cAAc;AAChB;AAEA,MAAa,oBAAoB;;;;AAKjC,MAAa,wBAAwB;;;;AAKrC,MAAa,wBAAwB;;AAGrC,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;;;;AAoIlC,MAAa,kBAAkB;CAC7B,MAAM;CACN,UAAU;CACV,OAAO;CACP,aAAa;CACb,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,MAAM;AACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtensionKind, ExtensionManifest } from "@kubb/core";
|
|
2
1
|
import { InputNode } from "@kubb/ast";
|
|
2
|
+
import { ExtensionKind, ExtensionManifest } from "@kubb/core";
|
|
3
3
|
/**
|
|
4
4
|
* Union of the values of an object type, such as `ValueOf<typeof nodeKinds>` for an `as const` table.
|
|
5
5
|
*/
|
|
@@ -556,6 +556,29 @@ type AgentConnectInfo = {
|
|
|
556
556
|
*/
|
|
557
557
|
organizationSlug?: string;
|
|
558
558
|
studioVersion: string;
|
|
559
|
+
/**
|
|
560
|
+
* A challenge that an agent with a key signs in {@link ConnectMessagePayload.signature}.
|
|
561
|
+
*/
|
|
562
|
+
challenge?: string;
|
|
563
|
+
};
|
|
564
|
+
declare const MAX_CONNECT_CHALLENGE_LENGTH = 1024;
|
|
565
|
+
/**
|
|
566
|
+
* What a signature is for. A signature made for one context never verifies for another.
|
|
567
|
+
*/
|
|
568
|
+
declare const AgentSignatureContext: {
|
|
569
|
+
readonly CONNECT: 'kubb-studio/agent-connect/v1';
|
|
570
|
+
readonly TOKEN_REFRESH: 'kubb-studio/agent-token-refresh/v1';
|
|
571
|
+
};
|
|
572
|
+
type AgentSignatureContext = ValueOf<typeof AgentSignatureContext>;
|
|
573
|
+
/**
|
|
574
|
+
* The proof an agent with a key adds to a token refresh.
|
|
575
|
+
*/
|
|
576
|
+
type TokenRefreshProof = {
|
|
577
|
+
/**
|
|
578
|
+
* When the proof was signed, in milliseconds since the Unix epoch.
|
|
579
|
+
*/
|
|
580
|
+
signed_at: number;
|
|
581
|
+
signature: string;
|
|
559
582
|
};
|
|
560
583
|
/**
|
|
561
584
|
* Operations Studio invokes on an agent over its socket.
|
|
@@ -657,6 +680,10 @@ type ConnectMessagePayload = {
|
|
|
657
680
|
configs: Array<ConfigEntryView>;
|
|
658
681
|
};
|
|
659
682
|
permissions: AgentPermissions;
|
|
683
|
+
/**
|
|
684
|
+
* The signed {@link AgentConnectInfo.challenge}, from an agent that holds a key.
|
|
685
|
+
*/
|
|
686
|
+
signature?: string;
|
|
660
687
|
};
|
|
661
688
|
type DiskOutput = {
|
|
662
689
|
jobId: string;
|
|
@@ -836,4 +863,4 @@ type PublishedSnapshot = {
|
|
|
836
863
|
*/
|
|
837
864
|
branchChanges?: BranchSnapshotChanges;
|
|
838
865
|
};
|
|
839
|
-
export {
|
|
866
|
+
export { ConfigEditOutcome as $, MAX_SNAPSHOT_BYTES as A, SaveConfigInput as B, GenerationRun as C, MAX_CONNECT_CHALLENGE_LENGTH as D, JSONKubbConfig as E, ReadFilesResult as F, TokenRefreshProof as G, SnapshotChanges as H, ReadInputInput as I, generationEventTypes as J, UpdateExtensionsInput as K, ReadInputResult as L, ReadDiffInput as M, ReadDiffResult as N, MAX_FILES_PER_REQUEST as O, ReadFilesInput as P, ConfigEditOperation as Q, RemoveExtensionInput as R, GenerationEventType as S, InstallExtensionResult as T, SnapshotUploadMetadata as U, SaveResult as V, StudioApi as W, editConfigFile as X, editConfig as Y, ConfigEdit as Z, FilePage as _, AgentConnectInfo as a, OptionValue as at, GenerationEvent as b, AgentPermissions as c, BranchSnapshotChanges as d, ConfigFileView as et, ConfigEntryView as f, DiskOutput as g, DiffStats as h, AgentCloseCode as i, InstalledExtensions as it, PublishedSnapshot as j, MAX_PAGE_LINES as k, AgentSignatureContext as l, DiffHunk as m, AGENT_SOCKET_PATH as n, ConfigView as nt, AgentMessage as o, OptionsView as ot, ConnectMessagePayload as p, UpdateExtensionsResult as q, AgentApi as r, ExtensionEntry as rt, AgentPermission as s, PluginView as st, AGENT_INSTANCE_HEADER as t, ConfigRef as tt, AgentType as u, GenerateInput as v, InstallExtensionInput as w, GenerationEventPayloads as x, GenerateResult as y, RemoveExtensionResult as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtensionKind, ExtensionManifest } from "@kubb/core";
|
|
2
1
|
import { InputNode } from "@kubb/ast";
|
|
2
|
+
import { ExtensionKind, ExtensionManifest } from "@kubb/core";
|
|
3
3
|
/**
|
|
4
4
|
* Union of the values of an object type, such as `ValueOf<typeof nodeKinds>` for an `as const` table.
|
|
5
5
|
*/
|
|
@@ -556,6 +556,29 @@ type AgentConnectInfo = {
|
|
|
556
556
|
*/
|
|
557
557
|
organizationSlug?: string;
|
|
558
558
|
studioVersion: string;
|
|
559
|
+
/**
|
|
560
|
+
* A challenge that an agent with a key signs in {@link ConnectMessagePayload.signature}.
|
|
561
|
+
*/
|
|
562
|
+
challenge?: string;
|
|
563
|
+
};
|
|
564
|
+
declare const MAX_CONNECT_CHALLENGE_LENGTH = 1024;
|
|
565
|
+
/**
|
|
566
|
+
* What a signature is for. A signature made for one context never verifies for another.
|
|
567
|
+
*/
|
|
568
|
+
declare const AgentSignatureContext: {
|
|
569
|
+
readonly CONNECT: 'kubb-studio/agent-connect/v1';
|
|
570
|
+
readonly TOKEN_REFRESH: 'kubb-studio/agent-token-refresh/v1';
|
|
571
|
+
};
|
|
572
|
+
type AgentSignatureContext = ValueOf<typeof AgentSignatureContext>;
|
|
573
|
+
/**
|
|
574
|
+
* The proof an agent with a key adds to a token refresh.
|
|
575
|
+
*/
|
|
576
|
+
type TokenRefreshProof = {
|
|
577
|
+
/**
|
|
578
|
+
* When the proof was signed, in milliseconds since the Unix epoch.
|
|
579
|
+
*/
|
|
580
|
+
signed_at: number;
|
|
581
|
+
signature: string;
|
|
559
582
|
};
|
|
560
583
|
/**
|
|
561
584
|
* Operations Studio invokes on an agent over its socket.
|
|
@@ -657,6 +680,10 @@ type ConnectMessagePayload = {
|
|
|
657
680
|
configs: Array<ConfigEntryView>;
|
|
658
681
|
};
|
|
659
682
|
permissions: AgentPermissions;
|
|
683
|
+
/**
|
|
684
|
+
* The signed {@link AgentConnectInfo.challenge}, from an agent that holds a key.
|
|
685
|
+
*/
|
|
686
|
+
signature?: string;
|
|
660
687
|
};
|
|
661
688
|
type DiskOutput = {
|
|
662
689
|
jobId: string;
|
|
@@ -836,4 +863,4 @@ type PublishedSnapshot = {
|
|
|
836
863
|
*/
|
|
837
864
|
branchChanges?: BranchSnapshotChanges;
|
|
838
865
|
};
|
|
839
|
-
export {
|
|
866
|
+
export { ConfigEditOutcome as $, MAX_SNAPSHOT_BYTES as A, SaveConfigInput as B, GenerationRun as C, MAX_CONNECT_CHALLENGE_LENGTH as D, JSONKubbConfig as E, ReadFilesResult as F, TokenRefreshProof as G, SnapshotChanges as H, ReadInputInput as I, generationEventTypes as J, UpdateExtensionsInput as K, ReadInputResult as L, ReadDiffInput as M, ReadDiffResult as N, MAX_FILES_PER_REQUEST as O, ReadFilesInput as P, ConfigEditOperation as Q, RemoveExtensionInput as R, GenerationEventType as S, InstallExtensionResult as T, SnapshotUploadMetadata as U, SaveResult as V, StudioApi as W, editConfigFile as X, editConfig as Y, ConfigEdit as Z, FilePage as _, AgentConnectInfo as a, OptionValue as at, GenerationEvent as b, AgentPermissions as c, BranchSnapshotChanges as d, ConfigFileView as et, ConfigEntryView as f, DiskOutput as g, DiffStats as h, AgentCloseCode as i, InstalledExtensions as it, PublishedSnapshot as j, MAX_PAGE_LINES as k, AgentSignatureContext as l, DiffHunk as m, AGENT_SOCKET_PATH as n, ConfigView as nt, AgentMessage as o, OptionsView as ot, ConnectMessagePayload as p, UpdateExtensionsResult as q, AgentApi as r, ExtensionEntry as rt, AgentPermission as s, PluginView as st, AGENT_INSTANCE_HEADER as t, ConfigRef as tt, AgentType as u, GenerateInput as v, InstallExtensionInput as w, GenerationEventPayloads as x, GenerateResult as y, RemoveExtensionResult as z };
|
|
@@ -75,6 +75,14 @@ const AgentMessage = {
|
|
|
75
75
|
READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec",
|
|
76
76
|
NO_INPUT: "This job kept no API input"
|
|
77
77
|
};
|
|
78
|
+
const MAX_CONNECT_CHALLENGE_LENGTH = 1024;
|
|
79
|
+
/**
|
|
80
|
+
* What a signature is for. A signature made for one context never verifies for another.
|
|
81
|
+
*/
|
|
82
|
+
const AgentSignatureContext = {
|
|
83
|
+
CONNECT: "kubb-studio/agent-connect/v1",
|
|
84
|
+
TOKEN_REFRESH: "kubb-studio/agent-token-refresh/v1"
|
|
85
|
+
};
|
|
78
86
|
/**
|
|
79
87
|
* Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
|
|
80
88
|
* was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
|
|
@@ -142,12 +150,24 @@ Object.defineProperty(exports, "AgentPermission", {
|
|
|
142
150
|
return AgentPermission;
|
|
143
151
|
}
|
|
144
152
|
});
|
|
153
|
+
Object.defineProperty(exports, "AgentSignatureContext", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function() {
|
|
156
|
+
return AgentSignatureContext;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
145
159
|
Object.defineProperty(exports, "ConfigEditOperation", {
|
|
146
160
|
enumerable: true,
|
|
147
161
|
get: function() {
|
|
148
162
|
return ConfigEditOperation;
|
|
149
163
|
}
|
|
150
164
|
});
|
|
165
|
+
Object.defineProperty(exports, "MAX_CONNECT_CHALLENGE_LENGTH", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function() {
|
|
168
|
+
return MAX_CONNECT_CHALLENGE_LENGTH;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
151
171
|
Object.defineProperty(exports, "MAX_FILES_PER_REQUEST", {
|
|
152
172
|
enumerable: true,
|
|
153
173
|
get: function() {
|
|
@@ -179,4 +199,4 @@ Object.defineProperty(exports, "generationEventTypes", {
|
|
|
179
199
|
}
|
|
180
200
|
});
|
|
181
201
|
|
|
182
|
-
//# sourceMappingURL=protocol-
|
|
202
|
+
//# sourceMappingURL=protocol-D-n2Uczq.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-CmX5XTPc.cjs","names":[],"sources":["../../../internals/shared/src/configFile/types.ts","../src/protocol.ts"],"sourcesContent":["import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import type { ValueOf } from '@internals/utils'\nimport type { InputNode } from '@kubb/ast'\nimport type { KubbHooks } from '@kubb/core'\nimport type { ConfigEdit, ConfigEditOutcome, ConfigFileView, ConfigRef, ExtensionEntry } from '@internals/shared'\n\nexport {\n ConfigEditOperation,\n type ConfigEdit,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n type ExtensionEntry,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from '@internals/shared'\n\n/**\n * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds\n * functions and class instances that cannot survive JSON, so both sides pass this flattened shape\n * and rebuild the real config from it.\n */\nexport type JSONKubbConfig = {\n /**\n * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)\n * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry\n * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.\n */\n plugins?: Array<{\n name: string\n options?: object\n disabled?: boolean\n }>\n /**\n * Raw OpenAPI / Swagger spec content (YAML or JSON string), never a file path.\n * Required by a 'sandbox' agent, which has no disk config of its own and refuses anything else.\n * A 'managed' agent also takes a URL or a `git+<repo>#<ref>:<path>` input, and falls back to its disk config without one.\n * Any other agent always reads its spec from disk, so this is ignored with a `kubb:warn`.\n */\n input?: string\n /**\n * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options\n * and re-applied through the same adapter factory, since an adapter instance's functions\n * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.\n */\n adapter?: object\n /**\n * Parser option overrides from Studio, matched to the disk config's parsers by `name` and\n * re-applied through each parser's factory, the same way `adapter` is.\n */\n parsers?: Array<{\n name: string\n options?: object\n }>\n /** Root `output` overrides for `barrel`, `format`, `lint`, `clean`, and `defaultBanner`. Other members are ignored. */\n output?: object\n /**\n * Which `defineConfig(...)` entry to generate from. Omitted runs the first one.\n */\n config?: ConfigRef\n}\n\n/**\n * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;\n * adding a core hook does not publish it to Studio until it is listed here and projected below.\n */\nexport const generationEventTypes = [\n 'kubb:plugin:start',\n 'kubb:plugin:end',\n 'kubb:build:start',\n 'kubb:build:end',\n 'kubb:files:processing:start',\n 'kubb:files:processing:update',\n 'kubb:files:processing:end',\n 'kubb:info',\n 'kubb:success',\n 'kubb:warn',\n 'kubb:error',\n 'kubb:diagnostic',\n 'kubb:generation:start',\n 'kubb:generation:end',\n 'kubb:generation:summary',\n 'kubb:lifecycle:start',\n 'kubb:lifecycle:end',\n 'kubb:format:start',\n 'kubb:format:end',\n 'kubb:lint:start',\n 'kubb:lint:end',\n 'kubb:hooks:start',\n 'kubb:hooks:end',\n 'kubb:hook:start',\n 'kubb:hook:line',\n 'kubb:hook:end',\n] as const satisfies ReadonlyArray<keyof KubbHooks>\n\n/**\n * One of the lifecycle hooks {@link generationEventTypes} publishes.\n */\nexport type GenerationEventType = (typeof generationEventTypes)[number]\n\n/**\n * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook\n * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.\n */\nexport type GenerationEventPayloads = {\n 'kubb:plugin:start': [ctx: { plugin: { name: string } }]\n 'kubb:plugin:end': [ctx: { plugin: { name: string }; duration: number; success: boolean }]\n 'kubb:build:start': [ctx: { config: { name?: string }; adapter: { name: string } }]\n 'kubb:build:end': [ctx: { files: Array<{ path: string; name: string }>; outputDir: string }]\n 'kubb:files:processing:start': [ctx: { total: number }]\n 'kubb:files:processing:update': [\n ctx: {\n files: Array<{\n file: string\n processed: number\n total: number\n percentage: number\n }>\n },\n ]\n 'kubb:files:processing:end': [ctx: { total: number }]\n 'kubb:info': [ctx: { message: string; info?: string }]\n 'kubb:success': [ctx: { message: string; info?: string }]\n 'kubb:warn': [ctx: { message: string; info?: string }]\n 'kubb:error': [ctx: { message: string; stack?: string }]\n 'kubb:diagnostic': [\n ctx: {\n code: string\n message: string\n severity: string\n location?: { kind: string; pointer?: string; ref?: string }\n help?: string\n plugin?: string\n stack?: string\n },\n ]\n 'kubb:generation:start': [ctx: { name?: string; plugins: number }]\n /**\n * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and\n * `readFiles` for contents.\n */\n 'kubb:generation:end': []\n 'kubb:generation:summary': [ctx: { duration: number; fileCount: number; failedPlugins: number; status: 'success' | 'failed' }]\n 'kubb:lifecycle:start': []\n 'kubb:lifecycle:end': []\n 'kubb:format:start': []\n 'kubb:format:end': []\n 'kubb:lint:start': []\n 'kubb:lint:end': []\n 'kubb:hooks:start': []\n 'kubb:hooks:end': []\n 'kubb:hook:start': [ctx: { id?: string; command: string; args?: Array<string> }]\n 'kubb:hook:line': [ctx: { id: string; line: string }]\n 'kubb:hook:end': [\n ctx: {\n id?: string\n command: string\n args?: Array<string>\n success: boolean\n error?: { message: string; stack?: string }\n },\n ]\n}\n\n/**\n * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent\n * emitted them in, so the receiver replays a run by reading the stream straight through.\n */\nexport type GenerationEvent = {\n [Type in GenerationEventType]: { type: Type; data: GenerationEventPayloads[Type] }\n}[GenerationEventType] & {\n version: 1\n jobId: string\n timestamp: number\n}\n\n/**\n * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller\n * watching several runs can tell them apart. `requestedBy` names the Studio user in the agent's\n * command log, and Studio leaves it out for a shared agent.\n */\nexport type GenerateInput = {\n jobId: string\n config: JSONKubbConfig\n /**\n * Display name of the Studio user who asked for the run, shown in the agent's job log.\n */\n requestedBy?: string\n /**\n * A short-lived `Authorization` header value that a managed agent sends with the git fetch of a `git+` input, to its origin only.\n */\n gitAuth?: { authorization: string }\n}\n\n/**\n * What a finished run produced.\n */\nexport type GenerateResult = {\n status: 'success' | 'failed'\n /**\n * Paths of the generated files, relative to the output directory.\n */\n files: Array<string>\n fileCount: number\n /**\n * Content fingerprint per file in `files`, to tell changed files apart without reading them.\n */\n hashes: Record<string, string>\n}\n\n/**\n * Asks the agent to apply a batch of edits to the config file on disk. `requestedBy` as for {@link GenerateInput}.\n */\nexport type SaveConfigInput = {\n edits: Array<ConfigEdit>\n /**\n * Display name of the Studio user who asked for the save, shown in the agent's job log.\n */\n requestedBy?: string\n}\n\n/**\n * Per-edit outcomes. `changed` is false when every edit was a no-op, so a caller can skip reloading.\n */\nexport type SaveResult = { outcomes: Array<ConfigEditOutcome>; changed: boolean }\n\n/** Asks the agent to run `kubb add <id>`: `owner/slug`, or a bare `slug` for an official extension. `requestedBy` as for {@link GenerateInput}. */\nexport type InstallExtensionInput = { id: string; requestedBy?: string }\n\n/** `installed` is false when the agent refused or `kubb add` failed, with `reason` saying why. */\nexport type InstallExtensionResult = { installed: boolean; reason?: string }\n\n/** Asks the agent to run `kubb update [ids] --yes`. Empty `ids` updates every installed extension the registry lists. */\nexport type UpdateExtensionsInput = { ids?: Array<string>; requestedBy?: string }\n\n/** `updated` is false when the agent refused or `kubb update` failed, with `reason` saying why. */\nexport type UpdateExtensionsResult = { updated: boolean; reason?: string }\n\n/** Asks the agent to run `kubb remove <id> --yes`. `requestedBy` as for {@link GenerateInput}. */\nexport type RemoveExtensionInput = { id: string; requestedBy?: string }\n\n/** `removed` is false when the agent refused or `kubb remove` failed, with `reason` saying why. */\nexport type RemoveExtensionResult = { removed: boolean; reason?: string }\n\n/**\n * Reads an immutable output set kept on disk, from a generation or the initial connection.\n */\nexport type ReadFilesInput = {\n jobId: string\n paths: Array<string>\n cursor?: number\n limit?: number\n}\n\n/**\n * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.\n */\nexport type FilePage = { nextCursor: number | null; totalLines: number }\n\n/**\n * What a file read returns. `pages` is set only for a paged read.\n */\nexport type ReadFilesResult = { files: Record<string, string>; pages?: Record<string, FilePage> }\n\n/**\n * Asks for one page of a file's line diff between two kept sets, so a large file never leaves the agent whole.\n * `jobId`'s `output` is the newer side, `base` the older one. `cursor` and `limit` page the patch lines.\n */\nexport type ReadDiffInput = { jobId: string; path: string; base: { jobId: string }; cursor?: number; limit: number }\n\n/**\n * One hunk of a diff page, with its `@@` header. Pages hold whole hunks, and only a hunk longer than a page is\n * split: its parts keep `index` and the header.\n */\nexport type DiffHunk = { index: number; oldStart: number; oldLines: number; newStart: number; newLines: number; lines: Array<string> }\n\n/**\n * The size of the whole diff, sent with every page, so a viewer can summarize it before reading every page.\n */\nexport type DiffStats = {\n additions: number\n deletions: number\n hunks: number\n /**\n * Patch lines in all hunks, the range `cursor` pages through.\n */\n lines: number\n /**\n * True when part of the diff ran out of time and shows as one block that replaces those lines.\n */\n coarse: boolean\n}\n\n/**\n * One page of a diff. `hasBase` is false, and the page empty, when the base set does not hold the path.\n */\nexport type ReadDiffResult = { hunks: Array<DiffHunk>; nextCursor: number | null; hasBase: boolean; stats: DiffStats }\n\n/**\n * Asks for the Kubb AST one job parsed its spec into. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.\n */\nexport type ReadInputInput = { jobId: string }\n\n/**\n * The job's `InputNode`, as JSON. A ref schema names its target, which `input.schemas` holds, without a copy.\n */\nexport type ReadInputResult = { input: InputNode }\n\n/**\n * Why the agent refuses a request. Studio matches on these to answer with the right status.\n */\nexport const AgentMessage = {\n GENERATION_IN_PROGRESS: 'A generation is already in progress, please wait for it to finish',\n INSTALL_IN_PROGRESS: 'An extension install or update is running, please wait for it to finish',\n SAVE_IN_PROGRESS: 'The config is being saved, please wait for it to finish',\n SANDBOX_INPUT_ONLY: 'A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL',\n MANAGED_INPUT_KIND: 'A managed agent generates from the OpenAPI document content, a URL, or a git file that Studio sends, not from a file path',\n CONFIG_ENTRY_NOT_FOUND: 'The config file has no entry at that position or with that name',\n JOB_REQUIRED: 'The request must name a job',\n FILE_REQUEST_INVALID: 'The request must name an output set and carry paths',\n TOO_MANY_FILES: 'Too many paths were requested at once',\n INVALID_PAGE: 'The requested file page is invalid',\n DIFF_REQUEST_INVALID: 'The request must name a job, a base, and a path',\n HASHES_ONLY: 'This agent kept only the hashes of that job',\n /**\n * A read for a job whose files the agent no longer keeps.\n */\n GENERATION_GONE: 'The files of this generation are no longer kept on the agent, run the generation again',\n READ_NOT_ALLOWED: 'The agent was not granted permission to read generated files',\n /**\n * Reading the parsed spec is its own permission.\n */\n READ_AST_NOT_ALLOWED: 'The agent was not granted permission to read the parsed spec',\n NO_INPUT: 'This job kept no API input',\n} as const\nexport type AgentMessage = ValueOf<typeof AgentMessage>\n\n/**\n * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can\n * read `events()` while `result()` is still pending and `cancel()` stops it early.\n */\nexport type GenerationRun = {\n events: () => Promise<ReadableStream<GenerationEvent>>\n result: () => Promise<GenerateResult>\n cancel: () => Promise<void>\n}\n\n/**\n * Every kind of agent Studio knows. A host passes its own kind to `connectAgent`.\n */\nexport type AgentType = 'user' | 'cli' | 'ci' | 'sandbox' | 'global' | 'managed'\n\n/**\n * What Studio knows about the agent on the other end of a socket. Studio passes it with every\n * {@link AgentApi.connect} call. Its `sandbox` flag can only take permissions away. The host decides the rest.\n */\nexport type AgentConnectInfo = {\n /**\n * A shared `sandbox` or `global` agent. It keeps generations on temporary disk, runs each job in a\n * temporary root, and generates from the spec Studio sends without editing a project or its config.\n */\n sandbox: boolean\n /**\n * A `managed` agent Studio hosts for the organization. It has no project spec on disk, so it\n * may generate from a spec Studio sends: the content, a URL, or a git file.\n */\n managed?: boolean\n agentSlug: string\n /**\n * Absent for a sandbox or global agent, which belongs to no organization.\n */\n organizationSlug?: string\n studioVersion: string\n}\n\n/**\n * Operations Studio invokes on an agent over its socket.\n */\nexport type AgentApi = {\n /**\n * The first call on every socket, and again whenever Studio needs the current config.\n */\n connect: (info: AgentConnectInfo) => Promise<ConnectMessagePayload>\n startGeneration: (input: GenerateInput) => GenerationRun\n saveConfig: (input: SaveConfigInput) => Promise<SaveResult>\n /** Refused without `allowInstall` and `allowConfigEdit`. An agent from before `installExtension` rejects the call. */\n installExtension: (input: InstallExtensionInput) => Promise<InstallExtensionResult>\n /** Refused without `allowUpdate`. Installs packages only, so `kubb.config.ts` stays as it is. */\n updateExtensions: (input: UpdateExtensionsInput) => Promise<UpdateExtensionsResult>\n /** Refused without `allowRemove` and `allowConfigEdit`. An agent from before `removeExtension` rejects the call. */\n removeExtension: (input: RemoveExtensionInput) => Promise<RemoveExtensionResult>\n readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readInput: (input: ReadInputInput) => Promise<ReadInputResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readDiff: (input: ReadDiffInput) => Promise<ReadDiffResult>\n}\n\n/**\n * Operations an agent invokes on Studio over its socket.\n */\nexport type StudioApi = {\n /**\n * Keeps the connection alive. A ping that does not settle in time makes the agent reconnect.\n */\n ping: () => Promise<void>\n}\n\n/**\n * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token\n * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`\n * included, is an ordinary drop and the agent reconnects.\n */\nexport const AgentCloseCode = {\n UNAUTHORIZED: 4001,\n SUPERSEDED: 4002,\n INCOMPATIBLE: 4003,\n} as const\n\nexport const AGENT_SOCKET_PATH = '/api/agent/socket'\n\n/**\n * Optional header naming the process a socket belongs to, for agents that run several processes.\n */\nexport const AGENT_INSTANCE_HEADER = 'x-kubb-instance-id'\n\n/**\n * How many files a single `readFiles` request may ask for at once.\n */\nexport const MAX_FILES_PER_REQUEST = 50\n\n/** Most lines one page may ask for. */\nexport const MAX_PAGE_LINES = 2000\n\nexport const MAX_SNAPSHOT_BYTES = 50 * 1024 * 1024\n\n/**\n * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with\n * everything about the config under one key.\n */\nexport type ConnectMessagePayload = {\n /**\n * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these\n * and the host prints them.\n */\n versions: {\n /**\n * The version of the `@kubb/studio` runtime the agent runs.\n */\n kubb: string\n /**\n * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).\n */\n agent: string\n }\n /**\n * The agent's project root. This is the workspace that generation runs against.\n */\n root: string\n /**\n * The baseline every generation starts from.\n */\n config: {\n /**\n * The config path as the host gave it, relative to `root` unless absolute.\n */\n path: string\n /**\n * What the agent read out of the config file itself, so Studio can render the plugin editor\n * against the real file. Absent when the agent could not read it, or was not granted\n * `allowConfigEdit`.\n */\n file?: ConfigFileView\n /** Installed packages that ship a `kubb-extension.json`, including plugins the config does not use yet. */\n extensions?: Array<ExtensionEntry>\n /** Every entry the config exports, in source order. */\n configs: Array<ConfigEntryView>\n }\n permissions: AgentPermissions\n}\n\nexport type DiskOutput = {\n jobId: string\n files: Array<string>\n hashes: Record<string, string>\n}\n\n/**\n * One `defineConfig(...)` entry as the agent runs it. Every option is a JSON copy: anything JSON cannot\n * hold, such as a function, is left out. A plugin defined in the project keeps its own `name`.\n */\nexport type ConfigEntryView = {\n name?: string\n /** The input file path or URL, without credentials. Omitted for an inline or parsed document. */\n input?: string\n /** The output directory as the entry gives it, relative to the project root unless absolute. */\n output: string\n /** The root `output` members Studio may set, as a JSON copy. */\n outputOptions?: object\n /**\n * The output directory's current file list, readable through `readFiles` without generating.\n * Absent for a sandbox or when the host has not granted `allowRead`.\n */\n disk?: DiskOutput\n plugins: Array<{\n name: string\n options?: object\n }>\n adapter?: {\n name: string\n options?: object\n }\n parsers: Array<{\n name: string\n options?: object\n }>\n}\n\n/**\n * What an agent may do in the project it serves. Every one is off unless the host granted it, and\n * a sandbox narrows them further.\n */\nexport type AgentPermissions = {\n /**\n * Whether the agent writes generated files to disk. Always false for a sandbox.\n */\n allowWrite: boolean\n /**\n * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child\n * processes after a generation.\n */\n allowExec: boolean\n /**\n * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from\n * `allowWrite`, which covers generated output: this one edits a hand-authored source file.\n */\n allowConfigEdit: boolean\n /** Whether the agent may run `kubb add` in the project, which also edits `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowInstall: boolean\n /** Whether the agent may run `kubb update` in the project, which installs newer extension versions and leaves `kubb.config.ts` alone. */\n allowUpdate: boolean\n /** Whether the agent may run `kubb remove` in the project, which edits `kubb.config.ts` and uninstalls packages. Needs `allowConfigEdit` as well. */\n allowRemove: boolean\n /** Whether the agent may keep the spec Studio sends: a document in `openapi.yaml` and `input` in `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowSaveInput: boolean\n /** Whether a `$ref` in the spec may read a local file outside the project. Never on a sandbox or managed agent, which read none. */\n allowFileRefs: boolean\n /**\n * Whether the agent shares existing output on connect and hands back file source through\n * `readFiles`. A sandbox the host declares always permits reads of its generated files.\n */\n allowRead: boolean\n /**\n * Whether the agent hands back the parsed spec (the Kubb AST) in response to `readInput`.\n * Separate from `allowRead`, which covers generated files. Always true for a sandbox the host declares.\n */\n allowReadAst: boolean\n}\n\n/**\n * The keys of {@link AgentPermissions}, such as the permission a refused request names.\n */\nexport const AgentPermission = {\n READ: 'allowRead',\n READ_AST: 'allowReadAst',\n WRITE: 'allowWrite',\n CONFIG_EDIT: 'allowConfigEdit',\n INSTALL: 'allowInstall',\n UPDATE: 'allowUpdate',\n REMOVE: 'allowRemove',\n SAVE_INPUT: 'allowSaveInput',\n FILE_REFS: 'allowFileRefs',\n EXEC: 'allowExec',\n} as const satisfies Record<string, keyof AgentPermissions>\nexport type AgentPermission = ValueOf<typeof AgentPermission>\n\n/**\n * Metadata part of `POST /api/snapshots`. The `tarball` part carries the packed package.\n */\nexport type SnapshotUploadMetadata = {\n /**\n * Stable CI identity, such as `gh:<repoId>:<pr>`. Snapshots with the same `id` share one CI agent.\n */\n id: string\n name: string\n packageName: string\n version: string\n /**\n * The commit the snapshot is built from, so the next one can name it as its base.\n */\n commit?: string\n /**\n * The `id` of another CI agent, such as the base branch's, to also compare with.\n */\n baseId?: string\n /**\n * Content fingerprint per generated file, keyed by path relative to the project root.\n */\n hashes: Record<string, string>\n peerDependencies: Record<string, string>\n}\n\n/**\n * How a snapshot's files differ from an earlier snapshot of the same package.\n */\nexport type SnapshotChanges = {\n /**\n * The snapshot these changes are measured against, `null` when there is none to compare with.\n */\n base: { id: string; version: string | null; commit?: string; createdAt: string; number?: number } | null\n added: Array<string>\n changed: Array<string>\n removed: Array<string>\n}\n\n/**\n * {@link SnapshotChanges} against another CI agent. `baseFound` is `false` when Studio has no CI\n * agent with that id yet, and `true` when it has one without a snapshot of this package.\n */\nexport type BranchSnapshotChanges = SnapshotChanges & { baseFound: boolean }\n\n/**\n * Response body of `POST /api/snapshots`: `{ snapshot: PublishedSnapshot }`.\n */\nexport type PublishedSnapshot = {\n id: string\n name: string | null\n version: string | null\n integrity: string | null\n agent: { id: string; name: string; slug: string | null }\n /**\n * Readable download path, often `/packages/{agentSlug}/{name}.tgz`.\n */\n url: string\n snapshotIdUrl: string\n /**\n * Studio page of this snapshot, such as `/kubb-labs/petstore/182`. Absent from a Studio that does not send it.\n */\n webUrl?: string\n /**\n * The snapshot's sequence number on its CI agent, shown as `#182`. Absent from a Studio that does not send it.\n */\n number?: number\n createdAt: string\n expiresAt: string\n /**\n * What changed since the previous snapshot of this package on the same CI agent.\n */\n changes?: SnapshotChanges\n /**\n * What differs from the latest snapshot of the CI agent `baseId` names. Absent without a base.\n */\n branchChanges?: BranchSnapshotChanges\n}\n"],"mappings":";AASA,MAAa,iBAAiB;CAAE,QAAQ;CAAU,SAAS;CAAW,QAAQ;AAAS;AAEvF,MAAa,sBAAsB;CACjC,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,WAAW;CACX,YAAY;CACZ,eAAe;AACjB;;;;;;AC+CA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AA0NA,MAAa,eAAe;CAC1B,wBAAwB;CACxB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,oBAAoB;CACpB,wBAAwB;CACxB,cAAc;CACd,sBAAsB;CACtB,gBAAgB;CAChB,cAAc;CACd,sBAAsB;CACtB,aAAa;;;;CAIb,iBAAiB;CACjB,kBAAkB;;;;CAIlB,sBAAsB;CACtB,UAAU;AACZ;;;;;;AAmFA,MAAa,iBAAiB;CAC5B,cAAc;CACd,YAAY;CACZ,cAAc;AAChB;AAEA,MAAa,oBAAoB;;;;AAKjC,MAAa,wBAAwB;;;;AAKrC,MAAa,wBAAwB;;AAGrC,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;;;;AAgIlC,MAAa,kBAAkB;CAC7B,MAAM;CACN,UAAU;CACV,OAAO;CACP,aAAa;CACb,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,MAAM;AACR"}
|
|
1
|
+
{"version":3,"file":"protocol-D-n2Uczq.cjs","names":[],"sources":["../../../internals/shared/src/configFile/types.ts","../src/protocol.ts"],"sourcesContent":["import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import type { ValueOf } from '@internals/utils'\nimport type { InputNode } from '@kubb/ast'\nimport type { KubbHooks } from '@kubb/core'\nimport type { ConfigEdit, ConfigEditOutcome, ConfigFileView, ConfigRef, ExtensionEntry } from '@internals/shared'\n\nexport {\n ConfigEditOperation,\n type ConfigEdit,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n type ExtensionEntry,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from '@internals/shared'\n\n/**\n * JSON-serializable Kubb config exchanged over RPC. A live `kubb/kit` config holds\n * functions and class instances that cannot survive JSON, so both sides pass this flattened shape\n * and rebuild the real config from it.\n */\nexport type JSONKubbConfig = {\n /**\n * Plugins with their serialized options. `name` is the package name (e.g. `@kubb/plugin-ts`)\n * and `options` is an opaque blob the agent forwards unchanged to the plugin factory. An entry\n * with `disabled: true` is dropped even when the disk config's `plugins` array still lists it.\n */\n plugins?: Array<{\n name: string\n options?: object\n disabled?: boolean\n }>\n /**\n * Raw OpenAPI / Swagger spec content (YAML or JSON string), never a file path.\n * Required by a 'sandbox' agent, which has no disk config of its own and refuses anything else.\n * A 'managed' agent also takes a URL or a `git+<repo>#<ref>:<path>` input, and falls back to its disk config without one.\n * Any other agent always reads its spec from disk, so this is ignored with a `kubb:warn`.\n */\n input?: string\n /**\n * Adapter option overrides sent from Studio UI. Merged into the disk config's adapter options\n * and re-applied through the same adapter factory, since an adapter instance's functions\n * (`parse`, `getImports`, ...) can't survive JSON serialization over the WebSocket.\n */\n adapter?: object\n /**\n * Parser option overrides from Studio, matched to the disk config's parsers by `name` and\n * re-applied through each parser's factory, the same way `adapter` is.\n */\n parsers?: Array<{\n name: string\n options?: object\n }>\n /** Root `output` overrides for `barrel`, `format`, `lint`, `clean`, and `defaultBanner`. Other members are ignored. */\n output?: object\n /**\n * Which `defineConfig(...)` entry to generate from. Omitted runs the first one.\n */\n config?: ConfigRef\n}\n\n/**\n * The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;\n * adding a core hook does not publish it to Studio until it is listed here and projected below.\n */\nexport const generationEventTypes = [\n 'kubb:plugin:start',\n 'kubb:plugin:end',\n 'kubb:build:start',\n 'kubb:build:end',\n 'kubb:files:processing:start',\n 'kubb:files:processing:update',\n 'kubb:files:processing:end',\n 'kubb:info',\n 'kubb:success',\n 'kubb:warn',\n 'kubb:error',\n 'kubb:diagnostic',\n 'kubb:generation:start',\n 'kubb:generation:end',\n 'kubb:generation:summary',\n 'kubb:lifecycle:start',\n 'kubb:lifecycle:end',\n 'kubb:format:start',\n 'kubb:format:end',\n 'kubb:lint:start',\n 'kubb:lint:end',\n 'kubb:hooks:start',\n 'kubb:hooks:end',\n 'kubb:hook:start',\n 'kubb:hook:line',\n 'kubb:hook:end',\n] as const satisfies ReadonlyArray<keyof KubbHooks>\n\n/**\n * One of the lifecycle hooks {@link generationEventTypes} publishes.\n */\nexport type GenerationEventType = (typeof generationEventTypes)[number]\n\n/**\n * The JSON-safe payload each published event carries. These are flattened on purpose: a core hook\n * context holds live objects (a `Config`, a `Storage`) that cannot cross the wire.\n */\nexport type GenerationEventPayloads = {\n 'kubb:plugin:start': [ctx: { plugin: { name: string } }]\n 'kubb:plugin:end': [ctx: { plugin: { name: string }; duration: number; success: boolean }]\n 'kubb:build:start': [ctx: { config: { name?: string }; adapter: { name: string } }]\n 'kubb:build:end': [ctx: { files: Array<{ path: string; name: string }>; outputDir: string }]\n 'kubb:files:processing:start': [ctx: { total: number }]\n 'kubb:files:processing:update': [\n ctx: {\n files: Array<{\n file: string\n processed: number\n total: number\n percentage: number\n }>\n },\n ]\n 'kubb:files:processing:end': [ctx: { total: number }]\n 'kubb:info': [ctx: { message: string; info?: string }]\n 'kubb:success': [ctx: { message: string; info?: string }]\n 'kubb:warn': [ctx: { message: string; info?: string }]\n 'kubb:error': [ctx: { message: string; stack?: string }]\n 'kubb:diagnostic': [\n ctx: {\n code: string\n message: string\n severity: string\n location?: { kind: string; pointer?: string; ref?: string }\n help?: string\n plugin?: string\n stack?: string\n },\n ]\n 'kubb:generation:start': [ctx: { name?: string; plugins: number }]\n /**\n * A run finished. See `kubb:build:end` for files, `kubb:generation:summary` for the count, and\n * `readFiles` for contents.\n */\n 'kubb:generation:end': []\n 'kubb:generation:summary': [ctx: { duration: number; fileCount: number; failedPlugins: number; status: 'success' | 'failed' }]\n 'kubb:lifecycle:start': []\n 'kubb:lifecycle:end': []\n 'kubb:format:start': []\n 'kubb:format:end': []\n 'kubb:lint:start': []\n 'kubb:lint:end': []\n 'kubb:hooks:start': []\n 'kubb:hooks:end': []\n 'kubb:hook:start': [ctx: { id?: string; command: string; args?: Array<string> }]\n 'kubb:hook:line': [ctx: { id: string; line: string }]\n 'kubb:hook:end': [\n ctx: {\n id?: string\n command: string\n args?: Array<string>\n success: boolean\n error?: { message: string; stack?: string }\n },\n ]\n}\n\n/**\n * Versioned envelope around one lifecycle event. Cap'n Web streams preserve the order the agent\n * emitted them in, so the receiver replays a run by reading the stream straight through.\n */\nexport type GenerationEvent = {\n [Type in GenerationEventType]: { type: Type; data: GenerationEventPayloads[Type] }\n}[GenerationEventType] & {\n version: 1\n jobId: string\n timestamp: number\n}\n\n/**\n * Asks the agent to run one generation. `jobId` tags every event the run emits so a caller\n * watching several runs can tell them apart. `requestedBy` names the Studio user in the agent's\n * command log, and Studio leaves it out for a shared agent.\n */\nexport type GenerateInput = {\n jobId: string\n config: JSONKubbConfig\n /**\n * Display name of the Studio user who asked for the run, shown in the agent's job log.\n */\n requestedBy?: string\n /**\n * A short-lived `Authorization` header value that a managed agent sends with the git fetch of a `git+` input, to its origin only.\n */\n gitAuth?: { authorization: string }\n}\n\n/**\n * What a finished run produced.\n */\nexport type GenerateResult = {\n status: 'success' | 'failed'\n /**\n * Paths of the generated files, relative to the output directory.\n */\n files: Array<string>\n fileCount: number\n /**\n * Content fingerprint per file in `files`, to tell changed files apart without reading them.\n */\n hashes: Record<string, string>\n}\n\n/**\n * Asks the agent to apply a batch of edits to the config file on disk. `requestedBy` as for {@link GenerateInput}.\n */\nexport type SaveConfigInput = {\n edits: Array<ConfigEdit>\n /**\n * Display name of the Studio user who asked for the save, shown in the agent's job log.\n */\n requestedBy?: string\n}\n\n/**\n * Per-edit outcomes. `changed` is false when every edit was a no-op, so a caller can skip reloading.\n */\nexport type SaveResult = { outcomes: Array<ConfigEditOutcome>; changed: boolean }\n\n/** Asks the agent to run `kubb add <id>`: `owner/slug`, or a bare `slug` for an official extension. `requestedBy` as for {@link GenerateInput}. */\nexport type InstallExtensionInput = { id: string; requestedBy?: string }\n\n/** `installed` is false when the agent refused or `kubb add` failed, with `reason` saying why. */\nexport type InstallExtensionResult = { installed: boolean; reason?: string }\n\n/** Asks the agent to run `kubb update [ids] --yes`. Empty `ids` updates every installed extension the registry lists. */\nexport type UpdateExtensionsInput = { ids?: Array<string>; requestedBy?: string }\n\n/** `updated` is false when the agent refused or `kubb update` failed, with `reason` saying why. */\nexport type UpdateExtensionsResult = { updated: boolean; reason?: string }\n\n/** Asks the agent to run `kubb remove <id> --yes`. `requestedBy` as for {@link GenerateInput}. */\nexport type RemoveExtensionInput = { id: string; requestedBy?: string }\n\n/** `removed` is false when the agent refused or `kubb remove` failed, with `reason` saying why. */\nexport type RemoveExtensionResult = { removed: boolean; reason?: string }\n\n/**\n * Reads an immutable output set kept on disk, from a generation or the initial connection.\n */\nexport type ReadFilesInput = {\n jobId: string\n paths: Array<string>\n cursor?: number\n limit?: number\n}\n\n/**\n * Where a paged read stands for one file: the cursor of the next page, `null` after the last one.\n */\nexport type FilePage = { nextCursor: number | null; totalLines: number }\n\n/**\n * What a file read returns. `pages` is set only for a paged read.\n */\nexport type ReadFilesResult = { files: Record<string, string>; pages?: Record<string, FilePage> }\n\n/**\n * Asks for one page of a file's line diff between two kept sets, so a large file never leaves the agent whole.\n * `jobId`'s `output` is the newer side, `base` the older one. `cursor` and `limit` page the patch lines.\n */\nexport type ReadDiffInput = { jobId: string; path: string; base: { jobId: string }; cursor?: number; limit: number }\n\n/**\n * One hunk of a diff page, with its `@@` header. Pages hold whole hunks, and only a hunk longer than a page is\n * split: its parts keep `index` and the header.\n */\nexport type DiffHunk = { index: number; oldStart: number; oldLines: number; newStart: number; newLines: number; lines: Array<string> }\n\n/**\n * The size of the whole diff, sent with every page, so a viewer can summarize it before reading every page.\n */\nexport type DiffStats = {\n additions: number\n deletions: number\n hunks: number\n /**\n * Patch lines in all hunks, the range `cursor` pages through.\n */\n lines: number\n /**\n * True when part of the diff ran out of time and shows as one block that replaces those lines.\n */\n coarse: boolean\n}\n\n/**\n * One page of a diff. `hasBase` is false, and the page empty, when the base set does not hold the path.\n */\nexport type ReadDiffResult = { hunks: Array<DiffHunk>; nextCursor: number | null; hasBase: boolean; stats: DiffStats }\n\n/**\n * Asks for the Kubb AST one job parsed its spec into. A job the agent no longer keeps fails with {@link AgentMessage.GENERATION_GONE}.\n */\nexport type ReadInputInput = { jobId: string }\n\n/**\n * The job's `InputNode`, as JSON. A ref schema names its target, which `input.schemas` holds, without a copy.\n */\nexport type ReadInputResult = { input: InputNode }\n\n/**\n * Why the agent refuses a request. Studio matches on these to answer with the right status.\n */\nexport const AgentMessage = {\n GENERATION_IN_PROGRESS: 'A generation is already in progress, please wait for it to finish',\n INSTALL_IN_PROGRESS: 'An extension install or update is running, please wait for it to finish',\n SAVE_IN_PROGRESS: 'The config is being saved, please wait for it to finish',\n SANDBOX_INPUT_ONLY: 'A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL',\n MANAGED_INPUT_KIND: 'A managed agent generates from the OpenAPI document content, a URL, or a git file that Studio sends, not from a file path',\n CONFIG_ENTRY_NOT_FOUND: 'The config file has no entry at that position or with that name',\n JOB_REQUIRED: 'The request must name a job',\n FILE_REQUEST_INVALID: 'The request must name an output set and carry paths',\n TOO_MANY_FILES: 'Too many paths were requested at once',\n INVALID_PAGE: 'The requested file page is invalid',\n DIFF_REQUEST_INVALID: 'The request must name a job, a base, and a path',\n HASHES_ONLY: 'This agent kept only the hashes of that job',\n /**\n * A read for a job whose files the agent no longer keeps.\n */\n GENERATION_GONE: 'The files of this generation are no longer kept on the agent, run the generation again',\n READ_NOT_ALLOWED: 'The agent was not granted permission to read generated files',\n /**\n * Reading the parsed spec is its own permission.\n */\n READ_AST_NOT_ALLOWED: 'The agent was not granted permission to read the parsed spec',\n NO_INPUT: 'This job kept no API input',\n} as const\nexport type AgentMessage = ValueOf<typeof AgentMessage>\n\n/**\n * A generation in flight. Cap'n Web keeps the three calls pointed at the same run, so a caller can\n * read `events()` while `result()` is still pending and `cancel()` stops it early.\n */\nexport type GenerationRun = {\n events: () => Promise<ReadableStream<GenerationEvent>>\n result: () => Promise<GenerateResult>\n cancel: () => Promise<void>\n}\n\n/**\n * Every kind of agent Studio knows. A host passes its own kind to `connectAgent`.\n */\nexport type AgentType = 'user' | 'cli' | 'ci' | 'sandbox' | 'global' | 'managed'\n\n/**\n * What Studio knows about the agent on the other end of a socket. Studio passes it with every\n * {@link AgentApi.connect} call. Its `sandbox` flag can only take permissions away. The host decides the rest.\n */\nexport type AgentConnectInfo = {\n /**\n * A shared `sandbox` or `global` agent. It keeps generations on temporary disk, runs each job in a\n * temporary root, and generates from the spec Studio sends without editing a project or its config.\n */\n sandbox: boolean\n /**\n * A `managed` agent Studio hosts for the organization. It has no project spec on disk, so it\n * may generate from a spec Studio sends: the content, a URL, or a git file.\n */\n managed?: boolean\n agentSlug: string\n /**\n * Absent for a sandbox or global agent, which belongs to no organization.\n */\n organizationSlug?: string\n studioVersion: string\n /**\n * A challenge that an agent with a key signs in {@link ConnectMessagePayload.signature}.\n */\n challenge?: string\n}\n\nexport const MAX_CONNECT_CHALLENGE_LENGTH = 1024\n\n/**\n * What a signature is for. A signature made for one context never verifies for another.\n */\nexport const AgentSignatureContext = {\n CONNECT: 'kubb-studio/agent-connect/v1',\n TOKEN_REFRESH: 'kubb-studio/agent-token-refresh/v1',\n} as const\nexport type AgentSignatureContext = ValueOf<typeof AgentSignatureContext>\n\n/**\n * The proof an agent with a key adds to a token refresh.\n */\nexport type TokenRefreshProof = {\n /**\n * When the proof was signed, in milliseconds since the Unix epoch.\n */\n signed_at: number\n signature: string\n}\n\n/**\n * Operations Studio invokes on an agent over its socket.\n */\nexport type AgentApi = {\n /**\n * The first call on every socket, and again whenever Studio needs the current config.\n */\n connect: (info: AgentConnectInfo) => Promise<ConnectMessagePayload>\n startGeneration: (input: GenerateInput) => GenerationRun\n saveConfig: (input: SaveConfigInput) => Promise<SaveResult>\n /** Refused without `allowInstall` and `allowConfigEdit`. An agent from before `installExtension` rejects the call. */\n installExtension: (input: InstallExtensionInput) => Promise<InstallExtensionResult>\n /** Refused without `allowUpdate`. Installs packages only, so `kubb.config.ts` stays as it is. */\n updateExtensions: (input: UpdateExtensionsInput) => Promise<UpdateExtensionsResult>\n /** Refused without `allowRemove` and `allowConfigEdit`. An agent from before `removeExtension` rejects the call. */\n removeExtension: (input: RemoveExtensionInput) => Promise<RemoveExtensionResult>\n readFiles: (input: ReadFilesInput) => Promise<ReadFilesResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readInput: (input: ReadInputInput) => Promise<ReadInputResult>\n /**\n * Refused unless the agent was granted `allowRead`, like {@link AgentApi.readFiles}.\n */\n readDiff: (input: ReadDiffInput) => Promise<ReadDiffResult>\n}\n\n/**\n * Operations an agent invokes on Studio over its socket.\n */\nexport type StudioApi = {\n /**\n * Keeps the connection alive. A ping that does not settle in time makes the agent reconnect.\n */\n ping: () => Promise<void>\n}\n\n/**\n * Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token\n * was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`\n * included, is an ordinary drop and the agent reconnects.\n */\nexport const AgentCloseCode = {\n UNAUTHORIZED: 4001,\n SUPERSEDED: 4002,\n INCOMPATIBLE: 4003,\n} as const\n\nexport const AGENT_SOCKET_PATH = '/api/agent/socket'\n\n/**\n * Optional header naming the process a socket belongs to, for agents that run several processes.\n */\nexport const AGENT_INSTANCE_HEADER = 'x-kubb-instance-id'\n\n/**\n * How many files a single `readFiles` request may ask for at once.\n */\nexport const MAX_FILES_PER_REQUEST = 50\n\n/** Most lines one page may ask for. */\nexport const MAX_PAGE_LINES = 2000\n\nexport const MAX_SNAPSHOT_BYTES = 50 * 1024 * 1024\n\n/**\n * Connection payload returned by {@link AgentApi.connect}. Carries only what Studio renders, with\n * everything about the config under one key.\n */\nexport type ConnectMessagePayload = {\n /**\n * Always sent, so a mismatch is visible on both sides: Studio badges the connection with these\n * and the host prints them.\n */\n versions: {\n /**\n * The version of the `@kubb/studio` runtime the agent runs.\n */\n kubb: string\n /**\n * The version of the host itself (the `kubb.agent` package or the `kubb` CLI).\n */\n agent: string\n }\n /**\n * The agent's project root. This is the workspace that generation runs against.\n */\n root: string\n /**\n * The baseline every generation starts from.\n */\n config: {\n /**\n * The config path as the host gave it, relative to `root` unless absolute.\n */\n path: string\n /**\n * What the agent read out of the config file itself, so Studio can render the plugin editor\n * against the real file. Absent when the agent could not read it, or was not granted\n * `allowConfigEdit`.\n */\n file?: ConfigFileView\n /** Installed packages that ship a `kubb-extension.json`, including plugins the config does not use yet. */\n extensions?: Array<ExtensionEntry>\n /** Every entry the config exports, in source order. */\n configs: Array<ConfigEntryView>\n }\n permissions: AgentPermissions\n /**\n * The signed {@link AgentConnectInfo.challenge}, from an agent that holds a key.\n */\n signature?: string\n}\n\nexport type DiskOutput = {\n jobId: string\n files: Array<string>\n hashes: Record<string, string>\n}\n\n/**\n * One `defineConfig(...)` entry as the agent runs it. Every option is a JSON copy: anything JSON cannot\n * hold, such as a function, is left out. A plugin defined in the project keeps its own `name`.\n */\nexport type ConfigEntryView = {\n name?: string\n /** The input file path or URL, without credentials. Omitted for an inline or parsed document. */\n input?: string\n /** The output directory as the entry gives it, relative to the project root unless absolute. */\n output: string\n /** The root `output` members Studio may set, as a JSON copy. */\n outputOptions?: object\n /**\n * The output directory's current file list, readable through `readFiles` without generating.\n * Absent for a sandbox or when the host has not granted `allowRead`.\n */\n disk?: DiskOutput\n plugins: Array<{\n name: string\n options?: object\n }>\n adapter?: {\n name: string\n options?: object\n }\n parsers: Array<{\n name: string\n options?: object\n }>\n}\n\n/**\n * What an agent may do in the project it serves. Every one is off unless the host granted it, and\n * a sandbox narrows them further.\n */\nexport type AgentPermissions = {\n /**\n * Whether the agent writes generated files to disk. Always false for a sandbox.\n */\n allowWrite: boolean\n /**\n * Whether the agent runs the formatter, the linter, and `output.postGenerate` as child\n * processes after a generation.\n */\n allowExec: boolean\n /**\n * Whether the agent may change plugin options in the user's `kubb.config.ts`. Separate from\n * `allowWrite`, which covers generated output: this one edits a hand-authored source file.\n */\n allowConfigEdit: boolean\n /** Whether the agent may run `kubb add` in the project, which also edits `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowInstall: boolean\n /** Whether the agent may run `kubb update` in the project, which installs newer extension versions and leaves `kubb.config.ts` alone. */\n allowUpdate: boolean\n /** Whether the agent may run `kubb remove` in the project, which edits `kubb.config.ts` and uninstalls packages. Needs `allowConfigEdit` as well. */\n allowRemove: boolean\n /** Whether the agent may keep the spec Studio sends: a document in `openapi.yaml` and `input` in `kubb.config.ts`. Needs `allowConfigEdit` as well. */\n allowSaveInput: boolean\n /** Whether a `$ref` in the spec may read a local file outside the project. Never on a sandbox or managed agent, which read none. */\n allowFileRefs: boolean\n /**\n * Whether the agent shares existing output on connect and hands back file source through\n * `readFiles`. A sandbox the host declares always permits reads of its generated files.\n */\n allowRead: boolean\n /**\n * Whether the agent hands back the parsed spec (the Kubb AST) in response to `readInput`.\n * Separate from `allowRead`, which covers generated files. Always true for a sandbox the host declares.\n */\n allowReadAst: boolean\n}\n\n/**\n * The keys of {@link AgentPermissions}, such as the permission a refused request names.\n */\nexport const AgentPermission = {\n READ: 'allowRead',\n READ_AST: 'allowReadAst',\n WRITE: 'allowWrite',\n CONFIG_EDIT: 'allowConfigEdit',\n INSTALL: 'allowInstall',\n UPDATE: 'allowUpdate',\n REMOVE: 'allowRemove',\n SAVE_INPUT: 'allowSaveInput',\n FILE_REFS: 'allowFileRefs',\n EXEC: 'allowExec',\n} as const satisfies Record<string, keyof AgentPermissions>\nexport type AgentPermission = ValueOf<typeof AgentPermission>\n\n/**\n * Metadata part of `POST /api/snapshots`. The `tarball` part carries the packed package.\n */\nexport type SnapshotUploadMetadata = {\n /**\n * Stable CI identity, such as `gh:<repoId>:<pr>`. Snapshots with the same `id` share one CI agent.\n */\n id: string\n name: string\n packageName: string\n version: string\n /**\n * The commit the snapshot is built from, so the next one can name it as its base.\n */\n commit?: string\n /**\n * The `id` of another CI agent, such as the base branch's, to also compare with.\n */\n baseId?: string\n /**\n * Content fingerprint per generated file, keyed by path relative to the project root.\n */\n hashes: Record<string, string>\n peerDependencies: Record<string, string>\n}\n\n/**\n * How a snapshot's files differ from an earlier snapshot of the same package.\n */\nexport type SnapshotChanges = {\n /**\n * The snapshot these changes are measured against, `null` when there is none to compare with.\n */\n base: { id: string; version: string | null; commit?: string; createdAt: string; number?: number } | null\n added: Array<string>\n changed: Array<string>\n removed: Array<string>\n}\n\n/**\n * {@link SnapshotChanges} against another CI agent. `baseFound` is `false` when Studio has no CI\n * agent with that id yet, and `true` when it has one without a snapshot of this package.\n */\nexport type BranchSnapshotChanges = SnapshotChanges & { baseFound: boolean }\n\n/**\n * Response body of `POST /api/snapshots`: `{ snapshot: PublishedSnapshot }`.\n */\nexport type PublishedSnapshot = {\n id: string\n name: string | null\n version: string | null\n integrity: string | null\n agent: { id: string; name: string; slug: string | null }\n /**\n * Readable download path, often `/packages/{agentSlug}/{name}.tgz`.\n */\n url: string\n snapshotIdUrl: string\n /**\n * Studio page of this snapshot, such as `/kubb-labs/petstore/182`. Absent from a Studio that does not send it.\n */\n webUrl?: string\n /**\n * The snapshot's sequence number on its CI agent, shown as `#182`. Absent from a Studio that does not send it.\n */\n number?: number\n createdAt: string\n expiresAt: string\n /**\n * What changed since the previous snapshot of this package on the same CI agent.\n */\n changes?: SnapshotChanges\n /**\n * What differs from the latest snapshot of the CI agent `baseId` names. Absent without a base.\n */\n branchChanges?: BranchSnapshotChanges\n}\n"],"mappings":";AASA,MAAa,iBAAiB;CAAE,QAAQ;CAAU,SAAS;CAAW,QAAQ;AAAS;AAEvF,MAAa,sBAAsB;CACjC,YAAY;CACZ,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,WAAW;CACX,YAAY;CACZ,eAAe;AACjB;;;;;;AC+CA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AA0NA,MAAa,eAAe;CAC1B,wBAAwB;CACxB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,oBAAoB;CACpB,wBAAwB;CACxB,cAAc;CACd,sBAAsB;CACtB,gBAAgB;CAChB,cAAc;CACd,sBAAsB;CACtB,aAAa;;;;CAIb,iBAAiB;CACjB,kBAAkB;;;;CAIlB,sBAAsB;CACtB,UAAU;AACZ;AA6CA,MAAa,+BAA+B;;;;AAK5C,MAAa,wBAAwB;CACnC,SAAS;CACT,eAAe;AACjB;;;;;;AAwDA,MAAa,iBAAiB;CAC5B,cAAc;CACd,YAAY;CACZ,cAAc;AAChB;AAEA,MAAa,oBAAoB;;;;AAKjC,MAAa,wBAAwB;;;;AAKrC,MAAa,wBAAwB;;AAGrC,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;;;;AAoIlC,MAAa,kBAAkB;CAC7B,MAAM;CACN,UAAU;CACV,OAAO;CACP,aAAa;CACb,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,WAAW;CACX,MAAM;AACR"}
|
package/dist/protocol.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_protocol = require("./protocol-
|
|
2
|
+
const require_protocol = require("./protocol-D-n2Uczq.cjs");
|
|
3
3
|
exports.AGENT_INSTANCE_HEADER = require_protocol.AGENT_INSTANCE_HEADER;
|
|
4
4
|
exports.AGENT_SOCKET_PATH = require_protocol.AGENT_SOCKET_PATH;
|
|
5
5
|
exports.AgentCloseCode = require_protocol.AgentCloseCode;
|
|
6
6
|
exports.AgentMessage = require_protocol.AgentMessage;
|
|
7
7
|
exports.AgentPermission = require_protocol.AgentPermission;
|
|
8
|
+
exports.AgentSignatureContext = require_protocol.AgentSignatureContext;
|
|
8
9
|
exports.ConfigEditOperation = require_protocol.ConfigEditOperation;
|
|
10
|
+
exports.MAX_CONNECT_CHALLENGE_LENGTH = require_protocol.MAX_CONNECT_CHALLENGE_LENGTH;
|
|
9
11
|
exports.MAX_FILES_PER_REQUEST = require_protocol.MAX_FILES_PER_REQUEST;
|
|
10
12
|
exports.MAX_PAGE_LINES = require_protocol.MAX_PAGE_LINES;
|
|
11
13
|
exports.MAX_SNAPSHOT_BYTES = require_protocol.MAX_SNAPSHOT_BYTES;
|
package/dist/protocol.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, AgentType, BranchSnapshotChanges, type ConfigEdit, ConfigEditOperation, type ConfigEditOutcome, ConfigEntryView, type ConfigFileView, type ConfigRef, type ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, type ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, type InstalledExtensions, JSONKubbConfig, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, type OptionValue, type OptionsView, type PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, RemoveExtensionInput, RemoveExtensionResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
|
1
|
+
import { $ as ConfigEditOutcome, A as MAX_SNAPSHOT_BYTES, B as SaveConfigInput, C as GenerationRun, D as MAX_CONNECT_CHALLENGE_LENGTH, E as JSONKubbConfig, F as ReadFilesResult, G as TokenRefreshProof, H as SnapshotChanges, I as ReadInputInput, J as generationEventTypes, K as UpdateExtensionsInput, L as ReadInputResult, M as ReadDiffInput, N as ReadDiffResult, O as MAX_FILES_PER_REQUEST, P as ReadFilesInput, Q as ConfigEditOperation, R as RemoveExtensionInput, S as GenerationEventType, T as InstallExtensionResult, U as SnapshotUploadMetadata, V as SaveResult, W as StudioApi, Z as ConfigEdit, _ as FilePage, a as AgentConnectInfo, at as OptionValue, b as GenerationEvent, c as AgentPermissions, d as BranchSnapshotChanges, et as ConfigFileView, f as ConfigEntryView, g as DiskOutput, h as DiffStats, i as AgentCloseCode, it as InstalledExtensions, j as PublishedSnapshot, k as MAX_PAGE_LINES, l as AgentSignatureContext, m as DiffHunk, n as AGENT_SOCKET_PATH, nt as ConfigView, o as AgentMessage, ot as OptionsView, p as ConnectMessagePayload, q as UpdateExtensionsResult, r as AgentApi, rt as ExtensionEntry, s as AgentPermission, st as PluginView, t as AGENT_INSTANCE_HEADER, tt as ConfigRef, u as AgentType, v as GenerateInput, w as InstallExtensionInput, x as GenerationEventPayloads, y as GenerateResult, z as RemoveExtensionResult } from "./protocol-CgearBUc.cjs";
|
|
2
|
+
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, AgentSignatureContext, AgentType, BranchSnapshotChanges, type ConfigEdit, ConfigEditOperation, type ConfigEditOutcome, ConfigEntryView, type ConfigFileView, type ConfigRef, type ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, type ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, type InstalledExtensions, JSONKubbConfig, MAX_CONNECT_CHALLENGE_LENGTH, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, type OptionValue, type OptionsView, type PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, RemoveExtensionInput, RemoveExtensionResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, TokenRefreshProof, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, AgentType, BranchSnapshotChanges, type ConfigEdit, ConfigEditOperation, type ConfigEditOutcome, ConfigEntryView, type ConfigFileView, type ConfigRef, type ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, type ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, type InstalledExtensions, JSONKubbConfig, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, type OptionValue, type OptionsView, type PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, RemoveExtensionInput, RemoveExtensionResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
|
1
|
+
import { $ as ConfigEditOutcome, A as MAX_SNAPSHOT_BYTES, B as SaveConfigInput, C as GenerationRun, D as MAX_CONNECT_CHALLENGE_LENGTH, E as JSONKubbConfig, F as ReadFilesResult, G as TokenRefreshProof, H as SnapshotChanges, I as ReadInputInput, J as generationEventTypes, K as UpdateExtensionsInput, L as ReadInputResult, M as ReadDiffInput, N as ReadDiffResult, O as MAX_FILES_PER_REQUEST, P as ReadFilesInput, Q as ConfigEditOperation, R as RemoveExtensionInput, S as GenerationEventType, T as InstallExtensionResult, U as SnapshotUploadMetadata, V as SaveResult, W as StudioApi, Z as ConfigEdit, _ as FilePage, a as AgentConnectInfo, at as OptionValue, b as GenerationEvent, c as AgentPermissions, d as BranchSnapshotChanges, et as ConfigFileView, f as ConfigEntryView, g as DiskOutput, h as DiffStats, i as AgentCloseCode, it as InstalledExtensions, j as PublishedSnapshot, k as MAX_PAGE_LINES, l as AgentSignatureContext, m as DiffHunk, n as AGENT_SOCKET_PATH, nt as ConfigView, o as AgentMessage, ot as OptionsView, p as ConnectMessagePayload, q as UpdateExtensionsResult, r as AgentApi, rt as ExtensionEntry, s as AgentPermission, st as PluginView, t as AGENT_INSTANCE_HEADER, tt as ConfigRef, u as AgentType, v as GenerateInput, w as InstallExtensionInput, x as GenerationEventPayloads, y as GenerateResult, z as RemoveExtensionResult } from "./protocol-CgearBUc.js";
|
|
2
|
+
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, AgentSignatureContext, AgentType, BranchSnapshotChanges, type ConfigEdit, ConfigEditOperation, type ConfigEditOutcome, ConfigEntryView, type ConfigFileView, type ConfigRef, type ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, type ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, type InstalledExtensions, JSONKubbConfig, MAX_CONNECT_CHALLENGE_LENGTH, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, type OptionValue, type OptionsView, type PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, RemoveExtensionInput, RemoveExtensionResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, TokenRefreshProof, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
package/dist/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as AGENT_INSTANCE_HEADER, n as AGENT_SOCKET_PATH, r as AgentCloseCode, i as AgentMessage, a as AgentPermission,
|
|
1
|
+
export { t as AGENT_INSTANCE_HEADER, n as AGENT_SOCKET_PATH, r as AgentCloseCode, i as AgentMessage, a as AgentPermission, o as AgentSignatureContext, f as ConfigEditOperation, s as MAX_CONNECT_CHALLENGE_LENGTH, c as MAX_FILES_PER_REQUEST, l as MAX_PAGE_LINES, u as MAX_SNAPSHOT_BYTES, d as generationEventTypes } from "./protocol-BYLMyS9H.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/studio",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0",
|
|
4
4
|
"description": "Kubb Studio client runtime. Connects a Kubb project to Kubb Studio over one WebSocket and publishes CI snapshots, shared by the `kubb studio` CLI command and the Docker agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubb/ast": "^5.
|
|
83
|
-
"@kubb/core": "^5.
|
|
82
|
+
"@kubb/ast": "^5.20.0",
|
|
83
|
+
"@kubb/core": "^5.20.0",
|
|
84
84
|
"capnweb": "^0.12.0",
|
|
85
85
|
"diff": "^9.0.0",
|
|
86
86
|
"ofetch": "^1.5.1",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@internals/shared": "0.0.1",
|
|
92
92
|
"@internals/utils": "0.0.1",
|
|
93
|
-
"@kubb/adapter-oas": "5.
|
|
93
|
+
"@kubb/adapter-oas": "5.20.0",
|
|
94
94
|
"tsdown": "^0.23.7"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|