@kubb/studio 5.12.8 → 5.13.1
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 -1
- package/dist/index.cjs +1200 -1031
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -41
- package/dist/index.d.ts +3 -41
- package/dist/index.js +1199 -1030
- package/dist/index.js.map +1 -1
- package/dist/{protocol-C4loKcxw.d.ts → protocol-DQTwqmNO.d.cts} +127 -175
- package/dist/{protocol-C4loKcxw.d.cts → protocol-DQTwqmNO.d.ts} +127 -175
- package/dist/protocol-DQnAN8NE.js +118 -0
- package/dist/protocol-DQnAN8NE.js.map +1 -0
- package/dist/protocol-n7fVO3_7.cjs +183 -0
- package/dist/protocol-n7fVO3_7.cjs.map +1 -0
- package/dist/protocol.cjs +11 -121
- package/dist/protocol.d.cts +2 -2
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +1 -112
- package/package.json +16 -7
- package/dist/protocol.cjs.map +0 -1
- package/dist/protocol.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
//#region ../../internals/shared/src/configFile/types.ts
|
|
2
|
+
const extensionKinds = {
|
|
3
|
+
plugin: "plugin",
|
|
4
|
+
adapter: "adapter",
|
|
5
|
+
parser: "parser"
|
|
6
|
+
};
|
|
7
|
+
const ConfigEditOperation = {
|
|
8
|
+
SET_OPTION: "set-option",
|
|
9
|
+
REMOVE_OPTION: "remove-option",
|
|
10
|
+
ADD_PLUGIN: "add-plugin",
|
|
11
|
+
REMOVE_EXTENSION: "remove-extension",
|
|
12
|
+
DISABLE_PLUGIN: "disable-plugin",
|
|
13
|
+
ENABLE_PLUGIN: "enable-plugin",
|
|
14
|
+
SET_INPUT: "set-input",
|
|
15
|
+
SET_OUTPUT: "set-output",
|
|
16
|
+
REMOVE_OUTPUT: "remove-output"
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/protocol.ts
|
|
20
|
+
/**
|
|
21
|
+
* The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
|
|
22
|
+
* adding a core hook does not publish it to Studio until it is listed here and projected below.
|
|
23
|
+
*/
|
|
24
|
+
const generationEventTypes = [
|
|
25
|
+
"kubb:plugin:start",
|
|
26
|
+
"kubb:plugin:end",
|
|
27
|
+
"kubb:build:start",
|
|
28
|
+
"kubb:build:end",
|
|
29
|
+
"kubb:files:processing:start",
|
|
30
|
+
"kubb:files:processing:update",
|
|
31
|
+
"kubb:files:processing:end",
|
|
32
|
+
"kubb:info",
|
|
33
|
+
"kubb:success",
|
|
34
|
+
"kubb:warn",
|
|
35
|
+
"kubb:error",
|
|
36
|
+
"kubb:diagnostic",
|
|
37
|
+
"kubb:generation:start",
|
|
38
|
+
"kubb:generation:end",
|
|
39
|
+
"kubb:generation:summary",
|
|
40
|
+
"kubb:lifecycle:start",
|
|
41
|
+
"kubb:lifecycle:end",
|
|
42
|
+
"kubb:format:start",
|
|
43
|
+
"kubb:format:end",
|
|
44
|
+
"kubb:lint:start",
|
|
45
|
+
"kubb:lint:end",
|
|
46
|
+
"kubb:hooks:start",
|
|
47
|
+
"kubb:hooks:end",
|
|
48
|
+
"kubb:hook:start",
|
|
49
|
+
"kubb:hook:line",
|
|
50
|
+
"kubb:hook:end"
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Why the agent refuses a request. Studio matches on these to answer with the right status.
|
|
54
|
+
*/
|
|
55
|
+
const AgentMessage = {
|
|
56
|
+
GENERATION_IN_PROGRESS: "A generation is already in progress, please wait for it to finish",
|
|
57
|
+
INSTALL_IN_PROGRESS: "An extension install or update is running, please wait for it to finish",
|
|
58
|
+
SAVE_IN_PROGRESS: "The config is being saved, please wait for it to finish",
|
|
59
|
+
SANDBOX_INPUT_ONLY: "A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL",
|
|
60
|
+
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",
|
|
61
|
+
CONFIG_ENTRY_NOT_FOUND: "The config file has no entry at that position or with that name",
|
|
62
|
+
JOB_REQUIRED: "The request must name a job",
|
|
63
|
+
FILE_REQUEST_INVALID: "The request must name an output set and carry paths",
|
|
64
|
+
TOO_MANY_FILES: "Too many paths were requested at once",
|
|
65
|
+
INVALID_PAGE: "The requested file page is invalid",
|
|
66
|
+
DIFF_REQUEST_INVALID: "The request must name a job, a base, and a path",
|
|
67
|
+
HASHES_ONLY: "This agent kept only the hashes of that job",
|
|
68
|
+
/**
|
|
69
|
+
* A read for a job whose files the agent no longer keeps.
|
|
70
|
+
*/
|
|
71
|
+
GENERATION_GONE: "The files of this generation are no longer kept on the agent, run the generation again",
|
|
72
|
+
READ_NOT_ALLOWED: "The agent was not granted permission to read generated files",
|
|
73
|
+
/**
|
|
74
|
+
* Reading the parsed spec is its own permission.
|
|
75
|
+
*/
|
|
76
|
+
READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec",
|
|
77
|
+
NO_INPUT: "This job kept no API input"
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
|
|
81
|
+
* was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
|
|
82
|
+
* included, is an ordinary drop and the agent reconnects.
|
|
83
|
+
*/
|
|
84
|
+
const AgentCloseCode = {
|
|
85
|
+
UNAUTHORIZED: 4001,
|
|
86
|
+
SUPERSEDED: 4002,
|
|
87
|
+
INCOMPATIBLE: 4003
|
|
88
|
+
};
|
|
89
|
+
const AGENT_SOCKET_PATH = "/api/agent/socket";
|
|
90
|
+
/**
|
|
91
|
+
* Optional header naming the process a socket belongs to, for agents that run several processes.
|
|
92
|
+
*/
|
|
93
|
+
const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
|
|
94
|
+
/**
|
|
95
|
+
* How many files a single `readFiles` request may ask for at once.
|
|
96
|
+
*/
|
|
97
|
+
const MAX_FILES_PER_REQUEST = 50;
|
|
98
|
+
/** Most lines one page may ask for. */
|
|
99
|
+
const MAX_PAGE_LINES = 2e3;
|
|
100
|
+
const MAX_SNAPSHOT_BYTES = 52428800;
|
|
101
|
+
/**
|
|
102
|
+
* The keys of {@link AgentPermissions}, such as the permission a refused request names.
|
|
103
|
+
*/
|
|
104
|
+
const AgentPermission = {
|
|
105
|
+
READ: "allowRead",
|
|
106
|
+
READ_AST: "allowReadAst",
|
|
107
|
+
WRITE: "allowWrite",
|
|
108
|
+
CONFIG_EDIT: "allowConfigEdit",
|
|
109
|
+
INSTALL: "allowInstall",
|
|
110
|
+
UPDATE: "allowUpdate",
|
|
111
|
+
REMOVE: "allowRemove",
|
|
112
|
+
SAVE_INPUT: "allowSaveInput",
|
|
113
|
+
EXEC: "allowExec"
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
Object.defineProperty(exports, "AGENT_INSTANCE_HEADER", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function() {
|
|
119
|
+
return AGENT_INSTANCE_HEADER;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(exports, "AGENT_SOCKET_PATH", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function() {
|
|
125
|
+
return AGENT_SOCKET_PATH;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "AgentCloseCode", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function() {
|
|
131
|
+
return AgentCloseCode;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, "AgentMessage", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function() {
|
|
137
|
+
return AgentMessage;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "AgentPermission", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return AgentPermission;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, "ConfigEditOperation", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function() {
|
|
149
|
+
return ConfigEditOperation;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, "MAX_FILES_PER_REQUEST", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function() {
|
|
155
|
+
return MAX_FILES_PER_REQUEST;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(exports, "MAX_PAGE_LINES", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function() {
|
|
161
|
+
return MAX_PAGE_LINES;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, "MAX_SNAPSHOT_BYTES", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return MAX_SNAPSHOT_BYTES;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, "extensionKinds", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function() {
|
|
173
|
+
return extensionKinds;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "generationEventTypes", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function() {
|
|
179
|
+
return generationEventTypes;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=protocol-n7fVO3_7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-n7fVO3_7.cjs","names":[],"sources":["../../../internals/shared/src/configFile/types.ts","../src/protocol.ts"],"sourcesContent":["import 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 = (typeof ConfigEditOperation)[keyof 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 { 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 = (typeof AgentMessage)[keyof 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 * What Studio knows about the agent on the other end of a socket. Studio passes it with every\n * {@link AgentApi.connect} call, so it stays the authority on whether the agent is a sandbox.\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 /**\n * Whether the agent shares existing output on connect and hands back file source through\n * `readFiles`. A sandbox 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.\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 EXEC: 'allowExec',\n} as const satisfies Record<string, keyof AgentPermissions>\nexport type AgentPermission = (typeof AgentPermission)[keyof 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":";AAQA,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;;;;;;AA8EA,MAAa,iBAAiB;CAC5B,cAAc;CACd,YAAY;CACZ,cAAc;AAChB;AAEA,MAAa,oBAAoB;;;;AAKjC,MAAa,wBAAwB;;;;AAKrC,MAAa,wBAAwB;;AAGrC,MAAa,iBAAiB;AAE9B,MAAa,qBAAqB;;;;AA8HlC,MAAa,kBAAkB;CAC7B,MAAM;CACN,UAAU;CACV,OAAO;CACP,aAAa;CACb,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,MAAM;AACR"}
|
package/dist/protocol.cjs
CHANGED
|
@@ -1,122 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
SET_OUTPUT: "set-output",
|
|
14
|
-
REMOVE_OUTPUT: "remove-output"
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
|
|
18
|
-
* adding a core hook does not publish it to Studio until it is listed here and projected below.
|
|
19
|
-
*/
|
|
20
|
-
const generationEventTypes = [
|
|
21
|
-
"kubb:plugin:start",
|
|
22
|
-
"kubb:plugin:end",
|
|
23
|
-
"kubb:build:start",
|
|
24
|
-
"kubb:build:end",
|
|
25
|
-
"kubb:files:processing:start",
|
|
26
|
-
"kubb:files:processing:update",
|
|
27
|
-
"kubb:files:processing:end",
|
|
28
|
-
"kubb:info",
|
|
29
|
-
"kubb:success",
|
|
30
|
-
"kubb:warn",
|
|
31
|
-
"kubb:error",
|
|
32
|
-
"kubb:diagnostic",
|
|
33
|
-
"kubb:generation:start",
|
|
34
|
-
"kubb:generation:end",
|
|
35
|
-
"kubb:generation:summary",
|
|
36
|
-
"kubb:lifecycle:start",
|
|
37
|
-
"kubb:lifecycle:end",
|
|
38
|
-
"kubb:format:start",
|
|
39
|
-
"kubb:format:end",
|
|
40
|
-
"kubb:lint:start",
|
|
41
|
-
"kubb:lint:end",
|
|
42
|
-
"kubb:hooks:start",
|
|
43
|
-
"kubb:hooks:end",
|
|
44
|
-
"kubb:hook:start",
|
|
45
|
-
"kubb:hook:line",
|
|
46
|
-
"kubb:hook:end"
|
|
47
|
-
];
|
|
48
|
-
/**
|
|
49
|
-
* Why the agent refuses a request. Studio matches on these to answer with the right status.
|
|
50
|
-
*/
|
|
51
|
-
const AgentMessage = {
|
|
52
|
-
GENERATION_IN_PROGRESS: "A generation is already in progress, please wait for it to finish",
|
|
53
|
-
INSTALL_IN_PROGRESS: "An extension install or update is running, please wait for it to finish",
|
|
54
|
-
SAVE_IN_PROGRESS: "The config is being saved, please wait for it to finish",
|
|
55
|
-
SANDBOX_INPUT_ONLY: "A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL",
|
|
56
|
-
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",
|
|
57
|
-
CONFIG_ENTRY_NOT_FOUND: "The config file has no entry at that position or with that name",
|
|
58
|
-
JOB_REQUIRED: "The request must name a job",
|
|
59
|
-
FILE_REQUEST_INVALID: "The request must name an output set and carry paths",
|
|
60
|
-
TOO_MANY_FILES: "Too many paths were requested at once",
|
|
61
|
-
INVALID_PAGE: "The requested file page is invalid",
|
|
62
|
-
DIFF_REQUEST_INVALID: "The request must name a job, a base, and a path",
|
|
63
|
-
HASHES_ONLY: "This agent kept only the hashes of that job",
|
|
64
|
-
/**
|
|
65
|
-
* A read for a job whose files the agent no longer keeps.
|
|
66
|
-
*/
|
|
67
|
-
GENERATION_GONE: "The files of this generation are no longer kept on the agent, run the generation again",
|
|
68
|
-
READ_NOT_ALLOWED: "The agent was not granted permission to read generated files",
|
|
69
|
-
/**
|
|
70
|
-
* Reading the parsed spec is its own permission.
|
|
71
|
-
*/
|
|
72
|
-
READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec",
|
|
73
|
-
NO_INPUT: "This job kept no API input"
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
|
|
77
|
-
* was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
|
|
78
|
-
* included, is an ordinary drop and the agent reconnects.
|
|
79
|
-
*/
|
|
80
|
-
const AgentCloseCode = {
|
|
81
|
-
UNAUTHORIZED: 4001,
|
|
82
|
-
SUPERSEDED: 4002,
|
|
83
|
-
INCOMPATIBLE: 4003
|
|
84
|
-
};
|
|
85
|
-
const AGENT_SOCKET_PATH = "/api/agent/socket";
|
|
86
|
-
/**
|
|
87
|
-
* Optional header naming the process a socket belongs to, for agents that run several processes.
|
|
88
|
-
*/
|
|
89
|
-
const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
|
|
90
|
-
/**
|
|
91
|
-
* How many files a single `readFiles` request may ask for at once.
|
|
92
|
-
*/
|
|
93
|
-
const MAX_FILES_PER_REQUEST = 50;
|
|
94
|
-
/** Most lines one page may ask for. */
|
|
95
|
-
const MAX_PAGE_LINES = 2e3;
|
|
96
|
-
const MAX_SNAPSHOT_BYTES = 52428800;
|
|
97
|
-
/**
|
|
98
|
-
* The keys of {@link AgentPermissions}, such as the permission a refused request names.
|
|
99
|
-
*/
|
|
100
|
-
const AgentPermission = {
|
|
101
|
-
READ: "allowRead",
|
|
102
|
-
READ_AST: "allowReadAst",
|
|
103
|
-
WRITE: "allowWrite",
|
|
104
|
-
CONFIG_EDIT: "allowConfigEdit",
|
|
105
|
-
INSTALL: "allowInstall",
|
|
106
|
-
UPDATE: "allowUpdate",
|
|
107
|
-
SAVE_INPUT: "allowSaveInput",
|
|
108
|
-
EXEC: "allowExec"
|
|
109
|
-
};
|
|
110
|
-
//#endregion
|
|
111
|
-
exports.AGENT_INSTANCE_HEADER = AGENT_INSTANCE_HEADER;
|
|
112
|
-
exports.AGENT_SOCKET_PATH = AGENT_SOCKET_PATH;
|
|
113
|
-
exports.AgentCloseCode = AgentCloseCode;
|
|
114
|
-
exports.AgentMessage = AgentMessage;
|
|
115
|
-
exports.AgentPermission = AgentPermission;
|
|
116
|
-
exports.ConfigEditOperation = ConfigEditOperation;
|
|
117
|
-
exports.MAX_FILES_PER_REQUEST = MAX_FILES_PER_REQUEST;
|
|
118
|
-
exports.MAX_PAGE_LINES = MAX_PAGE_LINES;
|
|
119
|
-
exports.MAX_SNAPSHOT_BYTES = MAX_SNAPSHOT_BYTES;
|
|
120
|
-
exports.generationEventTypes = generationEventTypes;
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=protocol.cjs.map
|
|
2
|
+
const require_protocol = require("./protocol-n7fVO3_7.cjs");
|
|
3
|
+
exports.AGENT_INSTANCE_HEADER = require_protocol.AGENT_INSTANCE_HEADER;
|
|
4
|
+
exports.AGENT_SOCKET_PATH = require_protocol.AGENT_SOCKET_PATH;
|
|
5
|
+
exports.AgentCloseCode = require_protocol.AgentCloseCode;
|
|
6
|
+
exports.AgentMessage = require_protocol.AgentMessage;
|
|
7
|
+
exports.AgentPermission = require_protocol.AgentPermission;
|
|
8
|
+
exports.ConfigEditOperation = require_protocol.ConfigEditOperation;
|
|
9
|
+
exports.MAX_FILES_PER_REQUEST = require_protocol.MAX_FILES_PER_REQUEST;
|
|
10
|
+
exports.MAX_PAGE_LINES = require_protocol.MAX_PAGE_LINES;
|
|
11
|
+
exports.MAX_SNAPSHOT_BYTES = require_protocol.MAX_SNAPSHOT_BYTES;
|
|
12
|
+
exports.generationEventTypes = require_protocol.generationEventTypes;
|
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, BranchSnapshotChanges, ConfigEdit, ConfigEditOperation, ConfigEditOutcome, ConfigEntryView, ConfigFileView, ConfigRef, ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, InstalledExtensions, JSONKubbConfig, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, OptionValue, OptionsView, PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
|
1
|
+
import { $ as ExtensionEntry, A as ReadDiffResult, B as SnapshotUploadMetadata, C as InstallExtensionResult, D as MAX_SNAPSHOT_BYTES, E as MAX_PAGE_LINES, F as RemoveExtensionInput, H as UpdateExtensionsInput, I as RemoveExtensionResult, J as ConfigEditOperation, L as SaveConfigInput, M as ReadFilesResult, N as ReadInputInput, O as PublishedSnapshot, P as ReadInputResult, Q as ConfigView, R as SaveResult, S as InstallExtensionInput, T as MAX_FILES_PER_REQUEST, U as UpdateExtensionsResult, V as StudioApi, W as generationEventTypes, X as ConfigFileView, Y as ConfigEditOutcome, Z as ConfigRef, _ as GenerateResult, a as AgentConnectInfo, b as GenerationEventType, c as AgentPermissions, d as ConnectMessagePayload, et as InstalledExtensions, f as DiffHunk, g as GenerateInput, h as FilePage, i as AgentCloseCode, j as ReadFilesInput, k as ReadDiffInput, l as BranchSnapshotChanges, m as DiskOutput, n as AGENT_SOCKET_PATH, nt as OptionsView, o as AgentMessage, p as DiffStats, q as ConfigEdit, r as AgentApi, rt as PluginView, s as AgentPermission, t as AGENT_INSTANCE_HEADER, tt as OptionValue, u as ConfigEntryView, v as GenerationEvent, w as JSONKubbConfig, x as GenerationRun, y as GenerationEventPayloads, z as SnapshotChanges } from "./protocol-DQTwqmNO.cjs";
|
|
2
|
+
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, 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 };
|
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, BranchSnapshotChanges, ConfigEdit, ConfigEditOperation, ConfigEditOutcome, ConfigEntryView, ConfigFileView, ConfigRef, ConfigView, ConnectMessagePayload, DiffHunk, DiffStats, DiskOutput, ExtensionEntry, FilePage, GenerateInput, GenerateResult, GenerationEvent, GenerationEventPayloads, GenerationEventType, GenerationRun, InstallExtensionInput, InstallExtensionResult, InstalledExtensions, JSONKubbConfig, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, OptionValue, OptionsView, PluginView, PublishedSnapshot, ReadDiffInput, ReadDiffResult, ReadFilesInput, ReadFilesResult, ReadInputInput, ReadInputResult, SaveConfigInput, SaveResult, SnapshotChanges, SnapshotUploadMetadata, StudioApi, UpdateExtensionsInput, UpdateExtensionsResult, generationEventTypes };
|
|
1
|
+
import { $ as ExtensionEntry, A as ReadDiffResult, B as SnapshotUploadMetadata, C as InstallExtensionResult, D as MAX_SNAPSHOT_BYTES, E as MAX_PAGE_LINES, F as RemoveExtensionInput, H as UpdateExtensionsInput, I as RemoveExtensionResult, J as ConfigEditOperation, L as SaveConfigInput, M as ReadFilesResult, N as ReadInputInput, O as PublishedSnapshot, P as ReadInputResult, Q as ConfigView, R as SaveResult, S as InstallExtensionInput, T as MAX_FILES_PER_REQUEST, U as UpdateExtensionsResult, V as StudioApi, W as generationEventTypes, X as ConfigFileView, Y as ConfigEditOutcome, Z as ConfigRef, _ as GenerateResult, a as AgentConnectInfo, b as GenerationEventType, c as AgentPermissions, d as ConnectMessagePayload, et as InstalledExtensions, f as DiffHunk, g as GenerateInput, h as FilePage, i as AgentCloseCode, j as ReadFilesInput, k as ReadDiffInput, l as BranchSnapshotChanges, m as DiskOutput, n as AGENT_SOCKET_PATH, nt as OptionsView, o as AgentMessage, p as DiffStats, q as ConfigEdit, r as AgentApi, rt as PluginView, s as AgentPermission, t as AGENT_INSTANCE_HEADER, tt as OptionValue, u as ConfigEntryView, v as GenerationEvent, w as JSONKubbConfig, x as GenerationRun, y as GenerationEventPayloads, z as SnapshotChanges } from "./protocol-DQTwqmNO.js";
|
|
2
|
+
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentApi, AgentCloseCode, AgentConnectInfo, AgentMessage, AgentPermission, AgentPermissions, 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 };
|
package/dist/protocol.js
CHANGED
|
@@ -1,112 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* The kinds of {@link ConfigEdit}, one per `operation`.
|
|
4
|
-
*/
|
|
5
|
-
const ConfigEditOperation = {
|
|
6
|
-
SET: "set",
|
|
7
|
-
REMOVE: "remove",
|
|
8
|
-
ADD_PLUGIN: "add-plugin",
|
|
9
|
-
DISABLE_PLUGIN: "disable-plugin",
|
|
10
|
-
ENABLE_PLUGIN: "enable-plugin",
|
|
11
|
-
SET_INPUT: "set-input",
|
|
12
|
-
SET_OUTPUT: "set-output",
|
|
13
|
-
REMOVE_OUTPUT: "remove-output"
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* The public, JSON-safe subset of Kubb lifecycle hooks. The core registry remains extensible;
|
|
17
|
-
* adding a core hook does not publish it to Studio until it is listed here and projected below.
|
|
18
|
-
*/
|
|
19
|
-
const generationEventTypes = [
|
|
20
|
-
"kubb:plugin:start",
|
|
21
|
-
"kubb:plugin:end",
|
|
22
|
-
"kubb:build:start",
|
|
23
|
-
"kubb:build:end",
|
|
24
|
-
"kubb:files:processing:start",
|
|
25
|
-
"kubb:files:processing:update",
|
|
26
|
-
"kubb:files:processing:end",
|
|
27
|
-
"kubb:info",
|
|
28
|
-
"kubb:success",
|
|
29
|
-
"kubb:warn",
|
|
30
|
-
"kubb:error",
|
|
31
|
-
"kubb:diagnostic",
|
|
32
|
-
"kubb:generation:start",
|
|
33
|
-
"kubb:generation:end",
|
|
34
|
-
"kubb:generation:summary",
|
|
35
|
-
"kubb:lifecycle:start",
|
|
36
|
-
"kubb:lifecycle:end",
|
|
37
|
-
"kubb:format:start",
|
|
38
|
-
"kubb:format:end",
|
|
39
|
-
"kubb:lint:start",
|
|
40
|
-
"kubb:lint:end",
|
|
41
|
-
"kubb:hooks:start",
|
|
42
|
-
"kubb:hooks:end",
|
|
43
|
-
"kubb:hook:start",
|
|
44
|
-
"kubb:hook:line",
|
|
45
|
-
"kubb:hook:end"
|
|
46
|
-
];
|
|
47
|
-
/**
|
|
48
|
-
* Why the agent refuses a request. Studio matches on these to answer with the right status.
|
|
49
|
-
*/
|
|
50
|
-
const AgentMessage = {
|
|
51
|
-
GENERATION_IN_PROGRESS: "A generation is already in progress, please wait for it to finish",
|
|
52
|
-
INSTALL_IN_PROGRESS: "An extension install or update is running, please wait for it to finish",
|
|
53
|
-
SAVE_IN_PROGRESS: "The config is being saved, please wait for it to finish",
|
|
54
|
-
SANDBOX_INPUT_ONLY: "A sandbox agent generates only from the OpenAPI document content Studio sends, not from a file path or URL",
|
|
55
|
-
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",
|
|
56
|
-
CONFIG_ENTRY_NOT_FOUND: "The config file has no entry at that position or with that name",
|
|
57
|
-
JOB_REQUIRED: "The request must name a job",
|
|
58
|
-
FILE_REQUEST_INVALID: "The request must name an output set and carry paths",
|
|
59
|
-
TOO_MANY_FILES: "Too many paths were requested at once",
|
|
60
|
-
INVALID_PAGE: "The requested file page is invalid",
|
|
61
|
-
DIFF_REQUEST_INVALID: "The request must name a job, a base, and a path",
|
|
62
|
-
HASHES_ONLY: "This agent kept only the hashes of that job",
|
|
63
|
-
/**
|
|
64
|
-
* A read for a job whose files the agent no longer keeps.
|
|
65
|
-
*/
|
|
66
|
-
GENERATION_GONE: "The files of this generation are no longer kept on the agent, run the generation again",
|
|
67
|
-
READ_NOT_ALLOWED: "The agent was not granted permission to read generated files",
|
|
68
|
-
/**
|
|
69
|
-
* Reading the parsed spec is its own permission.
|
|
70
|
-
*/
|
|
71
|
-
READ_AST_NOT_ALLOWED: "The agent was not granted permission to read the parsed spec",
|
|
72
|
-
NO_INPUT: "This job kept no API input"
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Close codes Studio sends when it ends an agent socket on purpose. `UNAUTHORIZED` means the token
|
|
76
|
-
* was refused, so pair again. `SUPERSEDED` and `INCOMPATIBLE` mean stop. Any other code, `1011`
|
|
77
|
-
* included, is an ordinary drop and the agent reconnects.
|
|
78
|
-
*/
|
|
79
|
-
const AgentCloseCode = {
|
|
80
|
-
UNAUTHORIZED: 4001,
|
|
81
|
-
SUPERSEDED: 4002,
|
|
82
|
-
INCOMPATIBLE: 4003
|
|
83
|
-
};
|
|
84
|
-
const AGENT_SOCKET_PATH = "/api/agent/socket";
|
|
85
|
-
/**
|
|
86
|
-
* Optional header naming the process a socket belongs to, for agents that run several processes.
|
|
87
|
-
*/
|
|
88
|
-
const AGENT_INSTANCE_HEADER = "x-kubb-instance-id";
|
|
89
|
-
/**
|
|
90
|
-
* How many files a single `readFiles` request may ask for at once.
|
|
91
|
-
*/
|
|
92
|
-
const MAX_FILES_PER_REQUEST = 50;
|
|
93
|
-
/** Most lines one page may ask for. */
|
|
94
|
-
const MAX_PAGE_LINES = 2e3;
|
|
95
|
-
const MAX_SNAPSHOT_BYTES = 52428800;
|
|
96
|
-
/**
|
|
97
|
-
* The keys of {@link AgentPermissions}, such as the permission a refused request names.
|
|
98
|
-
*/
|
|
99
|
-
const AgentPermission = {
|
|
100
|
-
READ: "allowRead",
|
|
101
|
-
READ_AST: "allowReadAst",
|
|
102
|
-
WRITE: "allowWrite",
|
|
103
|
-
CONFIG_EDIT: "allowConfigEdit",
|
|
104
|
-
INSTALL: "allowInstall",
|
|
105
|
-
UPDATE: "allowUpdate",
|
|
106
|
-
SAVE_INPUT: "allowSaveInput",
|
|
107
|
-
EXEC: "allowExec"
|
|
108
|
-
};
|
|
109
|
-
//#endregion
|
|
110
|
-
export { AGENT_INSTANCE_HEADER, AGENT_SOCKET_PATH, AgentCloseCode, AgentMessage, AgentPermission, ConfigEditOperation, MAX_FILES_PER_REQUEST, MAX_PAGE_LINES, MAX_SNAPSHOT_BYTES, generationEventTypes };
|
|
111
|
-
|
|
112
|
-
//# sourceMappingURL=protocol.js.map
|
|
1
|
+
export { t as AGENT_INSTANCE_HEADER, n as AGENT_SOCKET_PATH, r as AgentCloseCode, i as AgentMessage, a as AgentPermission, u as ConfigEditOperation, o as MAX_FILES_PER_REQUEST, s as MAX_PAGE_LINES, c as MAX_SNAPSHOT_BYTES, l as generationEventTypes } from "./protocol-DQnAN8NE.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/studio",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.13.1",
|
|
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,21 +79,30 @@
|
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubb/ast": "5.
|
|
83
|
-
"@kubb/core": "5.
|
|
82
|
+
"@kubb/ast": "5.13.1",
|
|
83
|
+
"@kubb/core": "5.13.1",
|
|
84
84
|
"capnweb": "^0.12.0",
|
|
85
85
|
"diff": "^9.0.0",
|
|
86
|
-
"magicast": "^0.5.5",
|
|
87
86
|
"ofetch": "^1.5.1",
|
|
88
87
|
"tinyexec": "^1.3.1",
|
|
89
|
-
"
|
|
88
|
+
"yuku-parser": "^0.19.0"
|
|
90
89
|
},
|
|
91
90
|
"devDependencies": {
|
|
91
|
+
"@internals/shared": "0.0.1",
|
|
92
92
|
"@internals/utils": "0.0.1",
|
|
93
|
-
"@kubb/adapter-oas": "5.
|
|
93
|
+
"@kubb/adapter-oas": "5.13.1",
|
|
94
|
+
"tsdown": "^0.23.1"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"tsdown": "^0.23.1"
|
|
98
|
+
},
|
|
99
|
+
"peerDependenciesMeta": {
|
|
100
|
+
"tsdown": {
|
|
101
|
+
"optional": true
|
|
102
|
+
}
|
|
94
103
|
},
|
|
95
104
|
"engines": {
|
|
96
|
-
"node": ">=22.
|
|
105
|
+
"node": ">=22.22"
|
|
97
106
|
},
|
|
98
107
|
"scripts": {
|
|
99
108
|
"build": "tsdown",
|