@jurislm/woodpecker-ci-plugin 0.1.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/.app.json.example +3 -0
- package/.codex-plugin/plugin.json +12 -0
- package/.mcp.json.example +12 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/assets/.gitkeep +1 -0
- package/dist/client.d.ts +24 -0
- package/dist/client.js +93 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +37 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/operations.d.ts +22 -0
- package/dist/generated/operations.js +123 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/generated/woodpecker-api.d.ts +5108 -0
- package/dist/generated/woodpecker-api.js +6 -0
- package/dist/generated/woodpecker-api.js.map +1 -0
- package/dist/generated/woodpecker-zod.d.ts +1229 -0
- package/dist/generated/woodpecker-zod.js +56 -0
- package/dist/generated/woodpecker-zod.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +60 -0
- package/dist/server.js.map +1 -0
- package/dist/stream.d.ts +5 -0
- package/dist/stream.js +57 -0
- package/dist/stream.js.map +1 -0
- package/dist/transports/stdio.d.ts +1 -0
- package/dist/transports/stdio.js +8 -0
- package/dist/transports/stdio.js.map +1 -0
- package/mcp.json +10 -0
- package/package.json +56 -0
- package/plugin.json +27 -0
- package/skills/woodpecker-ci/SKILL.md +14 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "woodpecker-ci",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Manage Woodpecker CI through agent tools.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "JurisLM",
|
|
8
|
+
"url": "https://github.com/jurislm"
|
|
9
|
+
},
|
|
10
|
+
"repository": "https://github.com/jurislm/woodpecker-ci-plugin",
|
|
11
|
+
"license": "MIT"
|
|
12
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JurisLM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @jurislm/woodpecker-ci-plugin
|
|
2
|
+
|
|
3
|
+
Local stdio MCP server for Woodpecker CI.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Bun >= 1.1
|
|
8
|
+
- Woodpecker API base URL, including `/api`
|
|
9
|
+
- Woodpecker personal access token
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
export WOODPECKER_URL=https://ci.example.com/api
|
|
15
|
+
export WOODPECKER_API_TOKEN=...
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The server does not read `DRONE_TOKEN`.
|
|
19
|
+
|
|
20
|
+
## Local MCP configuration
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"woodpecker": {
|
|
26
|
+
"command": "bunx",
|
|
27
|
+
"args": ["-y", "@jurislm/woodpecker-ci-plugin@latest"],
|
|
28
|
+
"env": {
|
|
29
|
+
"WOODPECKER_URL": "https://ci.example.com/api",
|
|
30
|
+
"WOODPECKER_API_TOKEN": "..."
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The server exposes one MCP tool for each operation in the committed official
|
|
38
|
+
Woodpecker OpenAPI snapshot. It is a local stdio package, not a hosted
|
|
39
|
+
ChatGPT plugin endpoint.
|
|
40
|
+
|
|
41
|
+
The current snapshot contains 118 operations. Generated tool names, input
|
|
42
|
+
schemas, output schemas, and annotations live under `src/generated/`.
|
|
43
|
+
|
|
44
|
+
## OpenAI Plugin package
|
|
45
|
+
|
|
46
|
+
This repository also contains the portable Agent Plugin layer:
|
|
47
|
+
|
|
48
|
+
- `plugin.json` — portable plugin identity and OpenAI presentation metadata.
|
|
49
|
+
- `mcp.json` — stdio MCP server configuration.
|
|
50
|
+
- `.codex-plugin/plugin.json` — Codex compatibility fallback.
|
|
51
|
+
- `.mcp.json.example` — local configuration example without secrets.
|
|
52
|
+
- `skills/woodpecker-ci/SKILL.md` — service-specific tool-selection guidance.
|
|
53
|
+
|
|
54
|
+
This version is private/local distribution. It does not provide a public
|
|
55
|
+
HTTPS `/mcp` endpoint or OAuth flow.
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bun install
|
|
61
|
+
bun run api:fetch
|
|
62
|
+
bun run api:generate
|
|
63
|
+
bun run check
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`api:fetch` is the only command that updates the committed API snapshot.
|
|
67
|
+
|
|
68
|
+
For a live read-only configuration check:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
WOODPECKER_URL=https://ci.example.com/api \
|
|
72
|
+
WOODPECKER_API_TOKEN=... \
|
|
73
|
+
bun run smoke:read
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Validate the portable Plugin package with:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
bun run manifest:check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Security
|
|
83
|
+
|
|
84
|
+
Tokens are sent only as bearer authentication and are not included in logs or
|
|
85
|
+
tool request metadata. Mutation requests are not retried automatically.
|
package/assets/.gitkeep
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GeneratedOperation } from "./generated/operations.js";
|
|
2
|
+
import type { WoodpeckerConfig } from "./config.js";
|
|
3
|
+
import { WoodpeckerApiError } from "./errors.js";
|
|
4
|
+
export interface ToolEnvelope<T> {
|
|
5
|
+
data: T;
|
|
6
|
+
status: number;
|
|
7
|
+
request: {
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface BinaryEnvelope {
|
|
13
|
+
encoding: "base64";
|
|
14
|
+
contentType: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
18
|
+
export declare class WoodpeckerClient {
|
|
19
|
+
private readonly config;
|
|
20
|
+
private readonly fetchImpl;
|
|
21
|
+
constructor(config: WoodpeckerConfig, fetchImpl?: FetchLike);
|
|
22
|
+
request<T>(operation: Pick<GeneratedOperation, "method" | "path" | "parameters" | "stream">, input: Record<string, unknown>): Promise<ToolEnvelope<T | null | BinaryEnvelope | string>>;
|
|
23
|
+
}
|
|
24
|
+
export { WoodpeckerApiError };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { WoodpeckerApiError } from "./errors.js";
|
|
2
|
+
import { collectServerSentEvents } from "./stream.js";
|
|
3
|
+
function pathValue(value, name) {
|
|
4
|
+
if (value === undefined || value === null) {
|
|
5
|
+
throw new Error("Missing required path parameter: " + name);
|
|
6
|
+
}
|
|
7
|
+
return encodeURIComponent(String(value));
|
|
8
|
+
}
|
|
9
|
+
function appendQuery(url, name, value) {
|
|
10
|
+
if (value === undefined || value === null)
|
|
11
|
+
return;
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
for (const item of value)
|
|
14
|
+
url.searchParams.append(name, String(item));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
url.searchParams.set(name, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
18
|
+
}
|
|
19
|
+
function decodeBinary(bytes, contentType) {
|
|
20
|
+
return {
|
|
21
|
+
encoding: "base64",
|
|
22
|
+
contentType,
|
|
23
|
+
value: Buffer.from(bytes).toString("base64"),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export class WoodpeckerClient {
|
|
27
|
+
config;
|
|
28
|
+
fetchImpl;
|
|
29
|
+
constructor(config, fetchImpl = fetch) {
|
|
30
|
+
this.config = config;
|
|
31
|
+
this.fetchImpl = fetchImpl;
|
|
32
|
+
}
|
|
33
|
+
async request(operation, input) {
|
|
34
|
+
let path = operation.path;
|
|
35
|
+
for (const parameter of operation.parameters) {
|
|
36
|
+
if (parameter.location !== "path")
|
|
37
|
+
continue;
|
|
38
|
+
path = path.replace("{" + parameter.name + "}", pathValue(input[parameter.name], parameter.name));
|
|
39
|
+
}
|
|
40
|
+
if (path.includes("{"))
|
|
41
|
+
throw new Error("Unresolved path parameter in " + operation.path);
|
|
42
|
+
const url = new URL(this.config.baseUrl + path);
|
|
43
|
+
for (const parameter of operation.parameters) {
|
|
44
|
+
if (parameter.location === "query")
|
|
45
|
+
appendQuery(url, parameter.name, input[parameter.name]);
|
|
46
|
+
}
|
|
47
|
+
const headers = new Headers({
|
|
48
|
+
accept: operation.stream ? "text/event-stream" : "application/json, text/plain, */*",
|
|
49
|
+
authorization: "Bearer " + this.config.token,
|
|
50
|
+
});
|
|
51
|
+
const init = {
|
|
52
|
+
method: operation.method,
|
|
53
|
+
headers,
|
|
54
|
+
signal: AbortSignal.timeout(this.config.timeoutMs),
|
|
55
|
+
};
|
|
56
|
+
if (input.body !== undefined && operation.method !== "GET" && operation.method !== "HEAD") {
|
|
57
|
+
headers.set("content-type", "application/json");
|
|
58
|
+
init.body = JSON.stringify(input.body);
|
|
59
|
+
}
|
|
60
|
+
let response;
|
|
61
|
+
try {
|
|
62
|
+
response = await this.fetchImpl(url, init);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new WoodpeckerApiError(0, operation.method, path, "Woodpecker request failed for " + operation.method + " " + path + ": " +
|
|
66
|
+
(error instanceof Error ? error.message : String(error)));
|
|
67
|
+
}
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
throw new WoodpeckerApiError(response.status, operation.method, path, "Woodpecker API returned " + response.status + " for " + operation.method + " " + path);
|
|
70
|
+
}
|
|
71
|
+
let data = null;
|
|
72
|
+
if (operation.stream) {
|
|
73
|
+
const durationMs = Math.min(30_000, Math.max(1, typeof input.duration_ms === "number" ? input.duration_ms : 5_000));
|
|
74
|
+
data = (await collectServerSentEvents(response, durationMs));
|
|
75
|
+
}
|
|
76
|
+
else if (response.status !== 204) {
|
|
77
|
+
const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
|
|
78
|
+
if (contentType.includes("json"))
|
|
79
|
+
data = (await response.json());
|
|
80
|
+
else if (contentType.startsWith("text/") || contentType.includes("xml"))
|
|
81
|
+
data = await response.text();
|
|
82
|
+
else
|
|
83
|
+
data = decodeBinary(await response.arrayBuffer(), contentType || "application/octet-stream");
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
data,
|
|
87
|
+
status: response.status,
|
|
88
|
+
request: { method: operation.method, path },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export { WoodpeckerApiError };
|
|
93
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAmBtD,SAAS,SAAS,CAAC,KAAc,EAAE,IAAY;IAC7C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,GAAQ,EAAE,IAAY,EAAE,KAAc;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,OAAO;IACT,CAAC;IACD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO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,CAAC,MAAM;YACvB,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface WoodpeckerConfig {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
token: string;
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class ConfigError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function loadConfig(env?: Record<string, string | undefined>): WoodpeckerConfig;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ConfigError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "ConfigError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function loadConfig(env = process.env) {
|
|
8
|
+
const rawUrl = env.WOODPECKER_URL?.trim();
|
|
9
|
+
const token = env.WOODPECKER_API_TOKEN?.trim();
|
|
10
|
+
if (!rawUrl)
|
|
11
|
+
throw new ConfigError("WOODPECKER_URL is required");
|
|
12
|
+
if (!token)
|
|
13
|
+
throw new ConfigError("WOODPECKER_API_TOKEN is required");
|
|
14
|
+
let url;
|
|
15
|
+
try {
|
|
16
|
+
url = new URL(rawUrl);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new ConfigError("WOODPECKER_URL must be a valid HTTP(S) URL");
|
|
20
|
+
}
|
|
21
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
22
|
+
throw new ConfigError("WOODPECKER_URL must use http:// or https://");
|
|
23
|
+
}
|
|
24
|
+
url.pathname = url.pathname.replace(/\/+$/u, "");
|
|
25
|
+
if (!url.pathname.endsWith("/api")) {
|
|
26
|
+
throw new ConfigError("WOODPECKER_URL must include the /api path");
|
|
27
|
+
}
|
|
28
|
+
if (url.search || url.hash) {
|
|
29
|
+
throw new ConfigError("WOODPECKER_URL must not include a query or fragment");
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
baseUrl: url.toString().replace(/\/$/u, ""),
|
|
33
|
+
token,
|
|
34
|
+
timeoutMs: 30_000,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,MAA0C,OAAO,CAAC,GAAG;IAC9E,MAAM,MAAM,GAAG,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAC;IAC/C,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,WAAW,CAAC,kCAAkC,CAAC,CAAC;IAEtE,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,WAAW,CAAC,4CAA4C,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1D,MAAM,IAAI,WAAW,CAAC,6CAA6C,CAAC,CAAC;IACvE,CAAC;IACD,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,WAAW,CAAC,2CAA2C,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,WAAW,CAAC,qDAAqD,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAC3C,KAAK;QACL,SAAS,EAAE,MAAM;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class WoodpeckerApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
method;
|
|
4
|
+
path;
|
|
5
|
+
constructor(status, method, path, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "WoodpeckerApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.method = method;
|
|
10
|
+
this.path = path;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACf,MAAM,CAAS;IACf,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,MAAc,EAAE,IAAY,EAAE,OAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type GeneratedOperation = {
|
|
3
|
+
name: string;
|
|
4
|
+
method: string;
|
|
5
|
+
path: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: z.ZodType;
|
|
8
|
+
responseSchema: z.ZodType;
|
|
9
|
+
responseKind: string;
|
|
10
|
+
parameters: Array<{
|
|
11
|
+
location: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}>;
|
|
14
|
+
stream: boolean;
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: boolean;
|
|
17
|
+
destructiveHint: boolean;
|
|
18
|
+
idempotentHint: boolean;
|
|
19
|
+
openWorldHint: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const operations: GeneratedOperation[];
|