@leitwerk-dev/woodpecker 0.0.0-bootstrap.0 → 0.2.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 +64 -1
- package/dist/LICENSE +13 -0
- package/dist/binding.d.ts +4 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/capability.d.ts +8 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/chunk-L6GKOYHO.js +13 -0
- package/dist/chunk-L6GKOYHO.js.map +1 -0
- package/dist/client.d.ts +36 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/external.d.ts +20 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +351 -0
- package/dist/index.js.map +1 -0
- package/dist/logs.d.ts +3 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/provider.d.ts +9 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/testing.d.ts +55 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +92 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -0
- package/package.json +54 -14
- package/src/binding.ts +6 -0
- package/src/capability.ts +11 -0
- package/src/client.ts +142 -0
- package/src/external.ts +27 -0
- package/src/index.ts +41 -0
- package/src/logs.ts +8 -0
- package/src/provider.ts +121 -0
- package/src/testing.ts +122 -0
- package/src/tools.ts +117 -0
package/README.md
CHANGED
|
@@ -1 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
# Woodpecker integration
|
|
2
|
+
|
|
3
|
+
Server-owned Woodpecker profiles, pipeline external sources, bounded log access, and workflow-focused LLM tools. Tokens never enter workers.
|
|
4
|
+
|
|
5
|
+
```yaml
|
|
6
|
+
extensions:
|
|
7
|
+
woodpecker:
|
|
8
|
+
profiles:
|
|
9
|
+
primary:
|
|
10
|
+
base_url: https://ci.example.test
|
|
11
|
+
token: "..."
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The extension targets the Woodpecker 3 API. Tools resolve the current process
|
|
15
|
+
repository, list or inspect pipelines, decode and bound step logs, and explicitly
|
|
16
|
+
restart a diagnosed pipeline. The external source waits indefinitely until the
|
|
17
|
+
newest repository/SHA/event match is terminal. Push pipelines must also match
|
|
18
|
+
the configured source branch. Woodpecker reports the target branch for pull
|
|
19
|
+
request pipelines, so pull request events match by source-head SHA instead.
|
|
20
|
+
|
|
21
|
+
## Explicit integration composition
|
|
22
|
+
|
|
23
|
+
`WoodpeckerClientLike` and `setupWoodpeckerIntegration` support alternate clients
|
|
24
|
+
with the same tool registration, durable writes and correlated pipeline polling.
|
|
25
|
+
An optional clock permits deterministic local polling.
|
|
26
|
+
|
|
27
|
+
## Project binding
|
|
28
|
+
|
|
29
|
+
Server launch code writes a non-secret `metadata.woodpecker` object containing
|
|
30
|
+
`{ owner, repo, profile }` on each process project. Tools use only the project
|
|
31
|
+
selected and authorized by the server, never repository/profile tool arguments.
|
|
32
|
+
`WoodpeckerProjectBinding` and `resolveWoodpeckerProjectBinding` expose this contract.
|
|
33
|
+
Different projects in one process may use different profiles. Credentials remain
|
|
34
|
+
in the server integration; bindings contain only a profile identifier.
|
|
35
|
+
|
|
36
|
+
When `metadata.woodpecker` is absent, the compatibility reader uses the old
|
|
37
|
+
`metadata.forgejo` repository and `woodpeckerProfile` process parameter.
|
|
38
|
+
An explicit Woodpecker binding must contain all three fields.
|
|
39
|
+
Malformed explicit values fail instead of selecting another profile.
|
|
40
|
+
Capability, watcher, external-source and write identifiers retain their original
|
|
41
|
+
strings, including historical `@leitwerk-private/` prefixes. Package names do not
|
|
42
|
+
rename durable protocol identities.
|
|
43
|
+
|
|
44
|
+
## Local adapter
|
|
45
|
+
|
|
46
|
+
Import `LocalWoodpeckerAdapter` from `@leitwerk-dev/woodpecker/testing` and supply its
|
|
47
|
+
`client()` through `setupWoodpeckerIntegration`. Construct the adapter with an owned
|
|
48
|
+
`root` directory, a local `baseUrl`, and an optional `now` clock. Provider state
|
|
49
|
+
persists in `woodpecker.json`; unknown resources fail locally. Production registration
|
|
50
|
+
does not import this entrypoint. The adapter never falls back to HTTP.
|
|
51
|
+
|
|
52
|
+
`seed(fullName)` registers a CI repository without a Git-host dependency.
|
|
53
|
+
`publish(repository, { branch, commit, event, status, logs })` supplies correlated
|
|
54
|
+
pipeline results. Local Git compositions resolve the actual commit before calling it.
|
|
55
|
+
|
|
56
|
+
## Pipeline lookup window
|
|
57
|
+
|
|
58
|
+
`listPipelines(repoId, signal?, { page, perPage })` defaults to page 1 with 100
|
|
59
|
+
pipelines. Correlated polling searches up to 10 pages (1,000 newest pipelines),
|
|
60
|
+
stopping at the newest match, exhausted history, or `afterPipelineNumber`.
|
|
61
|
+
A newest pending match continues waiting even if an older match is terminal.
|
|
62
|
+
An inconclusive scan reports a lookup-window error; inspect repository history
|
|
63
|
+
and adjust the watched pipeline floor before retrying. No match within exhausted
|
|
64
|
+
history is an ordinary wait for a future pipeline.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export type { RepositoryProjectBinding as WoodpeckerProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
export declare const resolveWoodpeckerProjectBinding: (ctx: Parameters<typeof resolveRepositoryProjectBinding>[0]) => import("@leitwerk-dev/process-sdk").RepositoryProjectBinding;
|
|
4
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,YAAY,EAAE,wBAAwB,IAAI,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACtG,eAAO,MAAM,+BAA+B,GAC3C,KAAK,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,iEACO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WoodpeckerClient } from "./client.js";
|
|
2
|
+
/** Public contract shared by HTTP and local adapters. */
|
|
3
|
+
export type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;
|
|
4
|
+
export interface WoodpeckerIntegration {
|
|
5
|
+
client(profile: string): WoodpeckerClientLike;
|
|
6
|
+
}
|
|
7
|
+
export declare const woodpeckerIntegration: import("@leitwerk-dev/process-sdk").CapabilityToken<WoodpeckerIntegration>;
|
|
8
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC,CAAC;AAElF,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC9C;AACD,eAAO,MAAM,qBAAqB,4EAEjC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/logs.ts
|
|
2
|
+
function boundedLogTail(lines, tailLines, maxBytes) {
|
|
3
|
+
const encoded = Buffer.from(lines.slice(-Math.min(Math.max(tailLines, 1), 2e3)).join("\n"));
|
|
4
|
+
const cap = Math.min(Math.max(maxBytes, 1), 1048576);
|
|
5
|
+
let start = Math.max(0, encoded.length - cap);
|
|
6
|
+
while (start < encoded.length && (encoded[start] & 192) === 128) start++;
|
|
7
|
+
return encoded.subarray(start).toString("utf8");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
boundedLogTail
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-L6GKOYHO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logs.ts"],"sourcesContent":["/** Keep a bounded tail without splitting a UTF-8 character. */\nexport function boundedLogTail(lines: string[], tailLines: number, maxBytes: number): string {\n\tconst encoded = Buffer.from(lines.slice(-Math.min(Math.max(tailLines, 1), 2_000)).join(\"\\n\"));\n\tconst cap = Math.min(Math.max(maxBytes, 1), 1_048_576);\n\tlet start = Math.max(0, encoded.length - cap);\n\twhile (start < encoded.length && (encoded[start] & 0xc0) === 0x80) start++;\n\treturn encoded.subarray(start).toString(\"utf8\");\n}\n"],"mappings":";AACO,SAAS,eAAe,OAAiB,WAAmB,UAA0B;AAC5F,QAAM,UAAU,OAAO,KAAK,MAAM,MAAM,CAAC,KAAK,IAAI,KAAK,IAAI,WAAW,CAAC,GAAG,GAAK,CAAC,EAAE,KAAK,IAAI,CAAC;AAC5F,QAAM,MAAM,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC,GAAG,OAAS;AACrD,MAAI,QAAQ,KAAK,IAAI,GAAG,QAAQ,SAAS,GAAG;AAC5C,SAAO,QAAQ,QAAQ,WAAW,QAAQ,KAAK,IAAI,SAAU,IAAM;AACnE,SAAO,QAAQ,SAAS,KAAK,EAAE,SAAS,MAAM;AAC/C;","names":[]}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IntegrationHttpClient } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export interface WoodpeckerProfile {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WoodpeckerRepository {
|
|
7
|
+
id: number;
|
|
8
|
+
full_name: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WoodpeckerPipeline {
|
|
11
|
+
id: number;
|
|
12
|
+
number: number;
|
|
13
|
+
status: string;
|
|
14
|
+
event: string;
|
|
15
|
+
branch: string;
|
|
16
|
+
commit: string;
|
|
17
|
+
created_at?: number;
|
|
18
|
+
workflows?: unknown[];
|
|
19
|
+
}
|
|
20
|
+
export declare function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile>;
|
|
21
|
+
export declare class WoodpeckerClient extends IntegrationHttpClient {
|
|
22
|
+
readonly profile: WoodpeckerProfile;
|
|
23
|
+
constructor(profile: WoodpeckerProfile);
|
|
24
|
+
lookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository>;
|
|
25
|
+
listPipelines(repoId: number, signal?: AbortSignal, pagination?: {
|
|
26
|
+
page: number;
|
|
27
|
+
perPage?: number;
|
|
28
|
+
}): Promise<WoodpeckerPipeline[]>;
|
|
29
|
+
getPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline>;
|
|
30
|
+
getStepLogs(repoId: number, number: number, stepId: number, tailLines?: number, maxBytes?: number, signal?: AbortSignal): Promise<{
|
|
31
|
+
logs: string;
|
|
32
|
+
truncated: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
restartPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client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M,EAAE,MAAM,EACd,SAAS,SAAM,EACf,QAAQ,SAAU,EAClB,MAAM,CAAC,EAAE,WAAW;;;;IA2BrB,eAAe,CACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,kBAAkB,CAAC;CAM9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExternalActionSource } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export declare const WOODPECKER_PIPELINE_KIND = "@leitwerk-private/woodpecker.pipeline";
|
|
3
|
+
export interface WoodpeckerPipelineSourceConfig {
|
|
4
|
+
profile: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
branch: string;
|
|
8
|
+
headSha: string;
|
|
9
|
+
afterPipelineNumber?: number;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
pollInterval?: string;
|
|
12
|
+
statuses?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare const woodpeckerExternal: {
|
|
15
|
+
pipeline<TParams, TState>(resolve: (ctx: {
|
|
16
|
+
params: TParams;
|
|
17
|
+
state: TState;
|
|
18
|
+
}) => WoodpeckerPipelineSourceConfig): ExternalActionSource<TParams, TState>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAChF,MAAM,WAAW,8BAA8B;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,eAAO,MAAM,kBAAkB;aACrB,OAAO,EAAE,MAAM,WACd,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,8BAA8B,GAClF,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC;CAUxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import { type WoodpeckerIntegration } from "./capability.js";
|
|
3
|
+
export declare const manifest: {
|
|
4
|
+
readonly id: "woodpecker";
|
|
5
|
+
readonly version: "0.1.9";
|
|
6
|
+
};
|
|
7
|
+
declare const extension: LeitwerkExtensionModule;
|
|
8
|
+
export * from "./capability.js";
|
|
9
|
+
export * from "./client.js";
|
|
10
|
+
export * from "./external.js";
|
|
11
|
+
export default extension;
|
|
12
|
+
/** Register shared tools and polling with an explicit integration. */
|
|
13
|
+
export declare function setupWoodpeckerIntegration(api: Parameters<NonNullable<LeitwerkExtensionModule["setupServer"]>>[0], integration: WoodpeckerIntegration, options?: {
|
|
14
|
+
now?: () => number;
|
|
15
|
+
}): import("@leitwerk-dev/process-sdk").PollingHandleLike<import("@leitwerk-dev/watcher-utils").PollResult> | undefined;
|
|
16
|
+
export * from "./binding.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,iBAAiB,CAAC;AAIpF,eAAO,MAAM,QAAQ;;;CAAkD,CAAC;AACxE,QAAA,MAAM,SAAS,EAAE,uBAahB,CAAC;AAEF,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,eAAe,SAAS,CAAC;AAEzB,sEAAsE;AACtE,wBAAgB,0BAA0B,CACzC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvE,WAAW,EAAE,qBAAqB,EAClC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,uHAOpC;AAED,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import {
|
|
2
|
+
boundedLogTail
|
|
3
|
+
} from "./chunk-L6GKOYHO.js";
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
import { coreHostCapabilities } from "@leitwerk-dev/process-sdk";
|
|
7
|
+
|
|
8
|
+
// src/capability.ts
|
|
9
|
+
import { createCapabilityToken } from "@leitwerk-dev/process-sdk";
|
|
10
|
+
var woodpeckerIntegration = createCapabilityToken(
|
|
11
|
+
"@leitwerk-private/woodpecker.integration"
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// src/client.ts
|
|
15
|
+
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
16
|
+
import { IntegrationHttpClient } from "@leitwerk-dev/process-sdk";
|
|
17
|
+
function decodeLogData(data) {
|
|
18
|
+
if (Array.isArray(data)) {
|
|
19
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(Uint8Array.from(data));
|
|
20
|
+
}
|
|
21
|
+
if (typeof data !== "string") return "";
|
|
22
|
+
if (/^[A-Za-z0-9+/]*={0,2}$/.test(data) && data.length % 4 === 0) {
|
|
23
|
+
try {
|
|
24
|
+
const binary = atob(data);
|
|
25
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(
|
|
26
|
+
Uint8Array.from(binary, (character) => character.charCodeAt(0))
|
|
27
|
+
);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
function parseWoodpeckerProfiles(value) {
|
|
34
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const [name, raw] of Object.entries(
|
|
36
|
+
asUnknownRecord(asUnknownRecord(value)?.profiles) ?? {}
|
|
37
|
+
)) {
|
|
38
|
+
const config = asUnknownRecord(raw) ?? {};
|
|
39
|
+
const baseUrl = typeof config.base_url === "string" ? config.base_url.replace(/\/+$/, "") : "";
|
|
40
|
+
const token = typeof config.token === "string" ? config.token.trim() : "";
|
|
41
|
+
if (!/^https:\/\//.test(baseUrl))
|
|
42
|
+
throw new Error(`Woodpecker profile '${name}' requires an HTTPS base_url`);
|
|
43
|
+
if (!token) throw new Error(`Woodpecker profile '${name}' requires a token`);
|
|
44
|
+
profiles.set(name, { baseUrl, token });
|
|
45
|
+
}
|
|
46
|
+
return profiles;
|
|
47
|
+
}
|
|
48
|
+
var WoodpeckerClient = class extends IntegrationHttpClient {
|
|
49
|
+
constructor(profile) {
|
|
50
|
+
super("Woodpecker", `${profile.baseUrl}/api`, {
|
|
51
|
+
Authorization: `Bearer ${profile.token}`,
|
|
52
|
+
Accept: "application/json"
|
|
53
|
+
});
|
|
54
|
+
this.profile = profile;
|
|
55
|
+
}
|
|
56
|
+
profile;
|
|
57
|
+
lookupRepository(fullName, signal) {
|
|
58
|
+
return this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {
|
|
59
|
+
signal
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
listPipelines(repoId, signal, pagination = { page: 1 }) {
|
|
63
|
+
const { page, perPage = 100 } = pagination;
|
|
64
|
+
if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(perPage) || perPage < 1 || perPage > 100)
|
|
65
|
+
throw new Error("Invalid Woodpecker pipeline pagination");
|
|
66
|
+
return this.request(`/repos/${repoId}/pipelines?page=${page}&perPage=${perPage}`, {
|
|
67
|
+
signal
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getPipeline(repoId, number, signal) {
|
|
71
|
+
return this.request(`/repos/${repoId}/pipelines/${number}`, { signal });
|
|
72
|
+
}
|
|
73
|
+
async getStepLogs(repoId, number, stepId, tailLines = 400, maxBytes = 262144, signal) {
|
|
74
|
+
const body = await (await this.response(`/repos/${repoId}/logs/${number}/${stepId}`, {
|
|
75
|
+
signal
|
|
76
|
+
})).text();
|
|
77
|
+
let text = body;
|
|
78
|
+
try {
|
|
79
|
+
const entries = JSON.parse(body);
|
|
80
|
+
if (Array.isArray(entries)) {
|
|
81
|
+
text = entries.map(
|
|
82
|
+
(entry) => decodeLogData(asUnknownRecord(entry)?.data).replace(
|
|
83
|
+
/\r?\n$/,
|
|
84
|
+
""
|
|
85
|
+
)
|
|
86
|
+
).join("\n");
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
const output = boundedLogTail(text.split(/\r?\n/), tailLines, maxBytes);
|
|
91
|
+
return { logs: output, truncated: output.length < text.length };
|
|
92
|
+
}
|
|
93
|
+
restartPipeline(repoId, number, signal) {
|
|
94
|
+
return this.request(`/repos/${repoId}/pipelines/${number}`, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
signal
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/provider.ts
|
|
102
|
+
import { asUnknownRecord as asUnknownRecord2 } from "@leitwerk-dev/domain";
|
|
103
|
+
import {
|
|
104
|
+
createExternalSourcePollReporter
|
|
105
|
+
} from "@leitwerk-dev/process-sdk";
|
|
106
|
+
import { createPollSchedule, emptyPollResult } from "@leitwerk-dev/watcher-utils";
|
|
107
|
+
|
|
108
|
+
// src/external.ts
|
|
109
|
+
var WOODPECKER_PIPELINE_KIND = "@leitwerk-private/woodpecker.pipeline";
|
|
110
|
+
var woodpeckerExternal = {
|
|
111
|
+
pipeline(resolve) {
|
|
112
|
+
return {
|
|
113
|
+
kind: WOODPECKER_PIPELINE_KIND,
|
|
114
|
+
label: "Woodpecker pipeline completion",
|
|
115
|
+
description: "Fires when a pipeline matching the current source head completes",
|
|
116
|
+
config: {},
|
|
117
|
+
inputMode: "none",
|
|
118
|
+
resolve
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// src/provider.ts
|
|
124
|
+
function parse(value) {
|
|
125
|
+
const config = asUnknownRecord2(value) ?? {};
|
|
126
|
+
if (["profile", "owner", "repo", "branch", "headSha"].some(
|
|
127
|
+
(key) => typeof config[key] !== "string" || !config[key].trim()
|
|
128
|
+
))
|
|
129
|
+
return null;
|
|
130
|
+
return {
|
|
131
|
+
profile: config.profile,
|
|
132
|
+
owner: config.owner,
|
|
133
|
+
repo: config.repo,
|
|
134
|
+
branch: config.branch,
|
|
135
|
+
headSha: config.headSha,
|
|
136
|
+
afterPipelineNumber: typeof config.afterPipelineNumber === "number" ? config.afterPipelineNumber : 0,
|
|
137
|
+
disabled: config.disabled === true,
|
|
138
|
+
pollInterval: typeof config.pollInterval === "string" ? config.pollInterval : "30s",
|
|
139
|
+
statuses: Array.isArray(config.statuses) ? config.statuses.filter((value2) => typeof value2 === "string") : void 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
var terminal = /* @__PURE__ */ new Set([
|
|
143
|
+
"success",
|
|
144
|
+
"failure",
|
|
145
|
+
"error",
|
|
146
|
+
"killed",
|
|
147
|
+
"canceled",
|
|
148
|
+
"cancelled",
|
|
149
|
+
"declined",
|
|
150
|
+
"blocked"
|
|
151
|
+
]);
|
|
152
|
+
var supportedEvents = /* @__PURE__ */ new Set(["push", "pull_request", "pull_request_closed"]);
|
|
153
|
+
function matchesBranch(event, pipelineBranch, sourceBranch) {
|
|
154
|
+
return event !== "push" || pipelineBranch === sourceBranch;
|
|
155
|
+
}
|
|
156
|
+
function createWoodpeckerProvider(deps, integration, options = {}) {
|
|
157
|
+
const due = createPollSchedule(options.now);
|
|
158
|
+
return deps.polling.create({
|
|
159
|
+
id: "woodpecker",
|
|
160
|
+
pollInterval: () => "5s",
|
|
161
|
+
isEnabled: () => true,
|
|
162
|
+
defaultIntervalMs: 5e3,
|
|
163
|
+
async pollOnce() {
|
|
164
|
+
const result = emptyPollResult();
|
|
165
|
+
const report = createExternalSourcePollReporter(deps.externalSources, result);
|
|
166
|
+
await report.poll(WOODPECKER_PIPELINE_KIND, async (armed) => {
|
|
167
|
+
const config = parse(armed.resolved);
|
|
168
|
+
if (!config) {
|
|
169
|
+
result.errors.push(`${armed.id}:invalid_config`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (config.disabled) return;
|
|
173
|
+
const key = `${armed.instanceId}:${armed.id}`;
|
|
174
|
+
if (!due(key, config.pollInterval)) return;
|
|
175
|
+
const client = integration.client(config.profile);
|
|
176
|
+
const repo = await client.lookupRepository(`${config.owner}/${config.repo}`);
|
|
177
|
+
const pipeline = await findLatestPipeline(client, repo.id, config);
|
|
178
|
+
if (!pipeline || !terminal.has(pipeline.status) || config.statuses && !config.statuses.includes(pipeline.status))
|
|
179
|
+
return;
|
|
180
|
+
await report.fire(
|
|
181
|
+
armed,
|
|
182
|
+
{ repositoryId: repo.id, pipeline },
|
|
183
|
+
`${pipeline.number}:${pipeline.status}`
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async function findLatestPipeline(client, repoId, config) {
|
|
191
|
+
for (let page = 1; page <= 10; page++) {
|
|
192
|
+
const pipelines = (await client.listPipelines(repoId, void 0, { page, perPage: 100 })).sort(
|
|
193
|
+
(a, b) => b.number - a.number
|
|
194
|
+
);
|
|
195
|
+
const match = pipelines.find(
|
|
196
|
+
(candidate) => candidate.number > (config.afterPipelineNumber ?? 0) && candidate.commit === config.headSha && supportedEvents.has(candidate.event) && matchesBranch(candidate.event, candidate.branch, config.branch)
|
|
197
|
+
);
|
|
198
|
+
if (match) return match;
|
|
199
|
+
if (pipelines.length < 100 || pipelines.some((candidate) => candidate.number <= (config.afterPipelineNumber ?? 0)))
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
throw new Error(
|
|
203
|
+
"Woodpecker pipeline lookup window exhausted (1000 pipelines); inspect the repository and update the watched pipeline floor before retrying"
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/tools.ts
|
|
208
|
+
import {
|
|
209
|
+
createWriteIdentity,
|
|
210
|
+
ensureWrite
|
|
211
|
+
} from "@leitwerk-dev/external-writes";
|
|
212
|
+
import {
|
|
213
|
+
numberArg,
|
|
214
|
+
projectParameters,
|
|
215
|
+
stringArg
|
|
216
|
+
} from "@leitwerk-dev/process-sdk";
|
|
217
|
+
|
|
218
|
+
// src/binding.ts
|
|
219
|
+
import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
220
|
+
var resolveWoodpeckerProjectBinding = (ctx) => resolveRepositoryProjectBinding(ctx, "woodpecker", "forgejo");
|
|
221
|
+
|
|
222
|
+
// src/tools.ts
|
|
223
|
+
function target(ctx) {
|
|
224
|
+
const binding = resolveWoodpeckerProjectBinding(ctx);
|
|
225
|
+
return { fullName: `${binding.owner}/${binding.repo}`, profile: binding.profile };
|
|
226
|
+
}
|
|
227
|
+
function registerWoodpeckerTools(api, integration, writes) {
|
|
228
|
+
const schema = projectParameters();
|
|
229
|
+
api.tool({
|
|
230
|
+
name: "woodpecker_lookup_repository",
|
|
231
|
+
description: "Resolve the current process repository in Woodpecker",
|
|
232
|
+
parameters: schema,
|
|
233
|
+
async execute(ctx) {
|
|
234
|
+
const t = target(ctx);
|
|
235
|
+
return integration.client(t.profile).lookupRepository(t.fullName, ctx.signal);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
api.tool({
|
|
239
|
+
name: "woodpecker_list_pipelines",
|
|
240
|
+
description: "List recent Woodpecker pipelines for the current process repository",
|
|
241
|
+
parameters: schema,
|
|
242
|
+
async execute(ctx) {
|
|
243
|
+
const t = target(ctx);
|
|
244
|
+
const client = integration.client(t.profile);
|
|
245
|
+
const repo = await client.lookupRepository(t.fullName, ctx.signal);
|
|
246
|
+
return client.listPipelines(repo.id, ctx.signal);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
for (const name of ["woodpecker_get_pipeline", "woodpecker_restart_pipeline"]) {
|
|
250
|
+
api.tool({
|
|
251
|
+
name,
|
|
252
|
+
description: name.endsWith("restart_pipeline") ? "Restart a diagnosed Woodpecker pipeline" : "Read a Woodpecker pipeline",
|
|
253
|
+
parameters: projectParameters({
|
|
254
|
+
pipelineNumber: { type: "integer" },
|
|
255
|
+
...name === "woodpecker_restart_pipeline" ? {
|
|
256
|
+
diagnosis: {
|
|
257
|
+
type: "string",
|
|
258
|
+
description: "Why this is an infrastructure or flaky failure rather than a repository defect"
|
|
259
|
+
},
|
|
260
|
+
logEvidence: {
|
|
261
|
+
type: "string",
|
|
262
|
+
description: "Concrete bounded-log evidence supporting a restart"
|
|
263
|
+
}
|
|
264
|
+
} : {}
|
|
265
|
+
}),
|
|
266
|
+
async execute(ctx, args) {
|
|
267
|
+
const t = target(ctx);
|
|
268
|
+
const client = integration.client(t.profile);
|
|
269
|
+
const repo = await client.lookupRepository(t.fullName, ctx.signal);
|
|
270
|
+
const number = numberArg(args, "pipelineNumber");
|
|
271
|
+
if (name === "woodpecker_get_pipeline")
|
|
272
|
+
return client.getPipeline(repo.id, number, ctx.signal);
|
|
273
|
+
const diagnosis = stringArg(args, "diagnosis");
|
|
274
|
+
const logEvidence = stringArg(args, "logEvidence");
|
|
275
|
+
await ensureWrite(
|
|
276
|
+
writes,
|
|
277
|
+
ctx.process.id,
|
|
278
|
+
createWriteIdentity("woodpecker.restart", ctx.idempotencyKey),
|
|
279
|
+
async () => {
|
|
280
|
+
await client.restartPipeline(repo.id, number, ctx.signal);
|
|
281
|
+
return { repoId: repo.id, number, diagnosis, logEvidence };
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
return { ok: true };
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
api.tool({
|
|
289
|
+
name: "woodpecker_get_step_logs",
|
|
290
|
+
description: "Read bounded logs for a Woodpecker pipeline step",
|
|
291
|
+
parameters: projectParameters(
|
|
292
|
+
{
|
|
293
|
+
pipelineNumber: { type: "integer" },
|
|
294
|
+
stepId: { type: "integer" },
|
|
295
|
+
tailLines: { type: "integer" },
|
|
296
|
+
maxBytes: { type: "integer" }
|
|
297
|
+
},
|
|
298
|
+
["pipelineNumber", "stepId"]
|
|
299
|
+
),
|
|
300
|
+
async execute(ctx, args) {
|
|
301
|
+
const t = target(ctx);
|
|
302
|
+
const client = integration.client(t.profile);
|
|
303
|
+
const repo = await client.lookupRepository(t.fullName, ctx.signal);
|
|
304
|
+
return client.getStepLogs(
|
|
305
|
+
repo.id,
|
|
306
|
+
numberArg(args, "pipelineNumber"),
|
|
307
|
+
numberArg(args, "stepId"),
|
|
308
|
+
typeof args.tailLines === "number" ? args.tailLines : 400,
|
|
309
|
+
typeof args.maxBytes === "number" ? args.maxBytes : 262144,
|
|
310
|
+
ctx.signal
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/index.ts
|
|
317
|
+
var manifest = { id: "woodpecker", version: "0.1.9" };
|
|
318
|
+
var extension = {
|
|
319
|
+
manifest,
|
|
320
|
+
setupServer(api, config) {
|
|
321
|
+
const profiles = parseWoodpeckerProfiles(config);
|
|
322
|
+
const integration = {
|
|
323
|
+
client(profile) {
|
|
324
|
+
const value = profiles.get(profile);
|
|
325
|
+
if (!value) throw new Error(`Unknown Woodpecker profile '${profile}'`);
|
|
326
|
+
return new WoodpeckerClient(value);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
setupWoodpeckerIntegration(api, integration);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
var index_default = extension;
|
|
333
|
+
function setupWoodpeckerIntegration(api, integration, options = {}) {
|
|
334
|
+
api.provide(woodpeckerIntegration, integration);
|
|
335
|
+
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
336
|
+
if (!deps || Array.isArray(deps)) return;
|
|
337
|
+
registerWoodpeckerTools(api, integration, deps.externalWrites);
|
|
338
|
+
return createWoodpeckerProvider(deps, integration, options);
|
|
339
|
+
}
|
|
340
|
+
export {
|
|
341
|
+
WOODPECKER_PIPELINE_KIND,
|
|
342
|
+
WoodpeckerClient,
|
|
343
|
+
index_default as default,
|
|
344
|
+
manifest,
|
|
345
|
+
parseWoodpeckerProfiles,
|
|
346
|
+
resolveWoodpeckerProjectBinding,
|
|
347
|
+
setupWoodpeckerIntegration,
|
|
348
|
+
woodpeckerExternal,
|
|
349
|
+
woodpeckerIntegration
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/capability.ts","../src/client.ts","../src/provider.ts","../src/external.ts","../src/tools.ts","../src/binding.ts"],"sourcesContent":["import type { ExternalWriteLogRepoLike } from \"@leitwerk-dev/external-writes\";\nimport { coreHostCapabilities, type LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { type WoodpeckerIntegration, woodpeckerIntegration } from \"./capability.js\";\nimport { parseWoodpeckerProfiles, WoodpeckerClient } from \"./client.js\";\nimport { createWoodpeckerProvider } from \"./provider.js\";\nimport { registerWoodpeckerTools } from \"./tools.js\";\nexport const manifest = { id: \"woodpecker\", version: \"0.1.9\" } as const;\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseWoodpeckerProfiles(config);\n\t\tconst integration: WoodpeckerIntegration = {\n\t\t\tclient(profile) {\n\t\t\t\tconst value = profiles.get(profile);\n\t\t\t\tif (!value) throw new Error(`Unknown Woodpecker profile '${profile}'`);\n\t\t\t\treturn new WoodpeckerClient(value);\n\t\t\t},\n\t\t};\n\t\tsetupWoodpeckerIntegration(api, integration);\n\t},\n};\n\nexport * from \"./capability.js\";\nexport * from \"./client.js\";\nexport * from \"./external.js\";\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. */\nexport function setupWoodpeckerIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: WoodpeckerIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tapi.provide(woodpeckerIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterWoodpeckerTools(api, integration, deps.externalWrites as ExternalWriteLogRepoLike);\n\treturn createWoodpeckerProvider(deps, integration, options);\n}\n\nexport * from \"./binding.js\";\n","import { createCapabilityToken } from \"@leitwerk-dev/process-sdk\";\nimport type { WoodpeckerClient } from \"./client.js\";\n/** Public contract shared by HTTP and local adapters. */\nexport type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;\n\nexport interface WoodpeckerIntegration {\n\tclient(profile: string): WoodpeckerClientLike;\n}\nexport const woodpeckerIntegration = createCapabilityToken<WoodpeckerIntegration>(\n\t\"@leitwerk-private/woodpecker.integration\",\n);\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport { IntegrationHttpClient } from \"@leitwerk-dev/process-sdk\";\nimport { boundedLogTail } from \"./logs.js\";\n\nexport interface WoodpeckerProfile {\n\tbaseUrl: string;\n\ttoken: string;\n}\nexport interface WoodpeckerRepository {\n\tid: number;\n\tfull_name: string;\n}\nexport interface WoodpeckerPipeline {\n\tid: number;\n\tnumber: number;\n\tstatus: string;\n\tevent: string;\n\tbranch: string;\n\tcommit: string;\n\tcreated_at?: number;\n\tworkflows?: unknown[];\n}\n\ninterface WoodpeckerLogEntry {\n\tdata?: number[] | string;\n}\n\nfunction decodeLogData(data: WoodpeckerLogEntry[\"data\"]): string {\n\tif (Array.isArray(data)) {\n\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(Uint8Array.from(data));\n\t}\n\tif (typeof data !== \"string\") return \"\";\n\tif (/^[A-Za-z0-9+/]*={0,2}$/.test(data) && data.length % 4 === 0) {\n\t\ttry {\n\t\t\tconst binary = atob(data);\n\t\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(\n\t\t\t\tUint8Array.from(binary, (character) => character.charCodeAt(0)),\n\t\t\t);\n\t\t} catch {\n\t\t\t// Preserve an unexpected plain-text representation instead of hiding logs.\n\t\t}\n\t}\n\treturn data;\n}\n\nexport function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile> {\n\tconst profiles = new Map<string, WoodpeckerProfile>();\n\tfor (const [name, raw] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(value)?.profiles) ?? {},\n\t)) {\n\t\tconst config = asUnknownRecord(raw) ?? {};\n\t\tconst baseUrl = typeof config.base_url === \"string\" ? config.base_url.replace(/\\/+$/, \"\") : \"\";\n\t\tconst token = typeof config.token === \"string\" ? config.token.trim() : \"\";\n\t\tif (!/^https:\\/\\//.test(baseUrl))\n\t\t\tthrow new Error(`Woodpecker profile '${name}' requires an HTTPS base_url`);\n\t\tif (!token) throw new Error(`Woodpecker profile '${name}' requires a token`);\n\t\tprofiles.set(name, { baseUrl, token });\n\t}\n\treturn profiles;\n}\n\nexport class WoodpeckerClient extends IntegrationHttpClient {\n\tconstructor(readonly profile: WoodpeckerProfile) {\n\t\tsuper(\"Woodpecker\", `${profile.baseUrl}/api`, {\n\t\t\tAuthorization: `Bearer ${profile.token}`,\n\t\t\tAccept: \"application/json\",\n\t\t});\n\t}\n\n\tlookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository> {\n\t\treturn this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tlistPipelines(\n\t\trepoId: number,\n\t\tsignal?: AbortSignal,\n\t\tpagination: { page: number; perPage?: number } = { page: 1 },\n\t): Promise<WoodpeckerPipeline[]> {\n\t\tconst { page, perPage = 100 } = pagination;\n\t\tif (\n\t\t\t!Number.isSafeInteger(page) ||\n\t\t\tpage < 1 ||\n\t\t\t!Number.isSafeInteger(perPage) ||\n\t\t\tperPage < 1 ||\n\t\t\tperPage > 100\n\t\t)\n\t\t\tthrow new Error(\"Invalid Woodpecker pipeline pagination\");\n\t\treturn this.request(`/repos/${repoId}/pipelines?page=${page}&perPage=${perPage}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tgetPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, { signal });\n\t}\n\n\tasync getStepLogs(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tstepId: number,\n\t\ttailLines = 400,\n\t\tmaxBytes = 262_144,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\tconst body = await (\n\t\t\tawait this.response(`/repos/${repoId}/logs/${number}/${stepId}`, {\n\t\t\t\tsignal,\n\t\t\t})\n\t\t).text();\n\t\tlet text = body;\n\t\ttry {\n\t\t\tconst entries = JSON.parse(body) as unknown;\n\t\t\tif (Array.isArray(entries)) {\n\t\t\t\ttext = entries\n\t\t\t\t\t.map((entry) =>\n\t\t\t\t\t\tdecodeLogData(asUnknownRecord(entry)?.data as WoodpeckerLogEntry[\"data\"]).replace(\n\t\t\t\t\t\t\t/\\r?\\n$/,\n\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t}\n\t\t} catch {\n\t\t\t// Older adapters may return text directly; retain it as-is.\n\t\t}\n\t\tconst output = boundedLogTail(text.split(/\\r?\\n/), tailLines, maxBytes);\n\t\treturn { logs: output, truncated: output.length < text.length };\n\t}\n\n\trestartPipeline(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, {\n\t\t\tmethod: \"POST\",\n\t\t\tsignal,\n\t\t});\n\t}\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\tcreateExternalSourcePollReporter,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { WoodpeckerClientLike, WoodpeckerIntegration } from \"./capability.js\";\nimport { WOODPECKER_PIPELINE_KIND, type WoodpeckerPipelineSourceConfig } from \"./external.js\";\n\nfunction parse(value: unknown): WoodpeckerPipelineSourceConfig | null {\n\tconst config = asUnknownRecord(value) ?? {};\n\tif (\n\t\t[\"profile\", \"owner\", \"repo\", \"branch\", \"headSha\"].some(\n\t\t\t(key) => typeof config[key] !== \"string\" || !(config[key] as string).trim(),\n\t\t)\n\t)\n\t\treturn null;\n\treturn {\n\t\tprofile: config.profile as string,\n\t\towner: config.owner as string,\n\t\trepo: config.repo as string,\n\t\tbranch: config.branch as string,\n\t\theadSha: config.headSha as string,\n\t\tafterPipelineNumber:\n\t\t\ttypeof config.afterPipelineNumber === \"number\" ? config.afterPipelineNumber : 0,\n\t\tdisabled: config.disabled === true,\n\t\tpollInterval: typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\",\n\t\tstatuses: Array.isArray(config.statuses)\n\t\t\t? config.statuses.filter((value): value is string => typeof value === \"string\")\n\t\t\t: undefined,\n\t};\n}\nconst terminal = new Set([\n\t\"success\",\n\t\"failure\",\n\t\"error\",\n\t\"killed\",\n\t\"canceled\",\n\t\"cancelled\",\n\t\"declined\",\n\t\"blocked\",\n]);\nconst supportedEvents = new Set([\"push\", \"pull_request\", \"pull_request_closed\"]);\n\nfunction matchesBranch(event: string, pipelineBranch: string, sourceBranch: string): boolean {\n\t// Woodpecker reports the PR target branch in `branch`. The commit uniquely\n\t// identifies the watched source head, so branch filtering only applies to pushes.\n\treturn event !== \"push\" || pipelineBranch === sourceBranch;\n}\n\nexport function createWoodpeckerProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: WoodpeckerIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst due = createPollSchedule(options.now);\n\treturn deps.polling.create({\n\t\tid: \"woodpecker\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5_000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tconst report = createExternalSourcePollReporter(deps.externalSources, result);\n\t\t\tawait report.poll(WOODPECKER_PIPELINE_KIND, async (armed) => {\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tif (!config) {\n\t\t\t\t\tresult.errors.push(`${armed.id}:invalid_config`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (config.disabled) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}`;\n\t\t\t\tif (!due(key, config.pollInterval)) return;\n\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\tconst repo = await client.lookupRepository(`${config.owner}/${config.repo}`);\n\t\t\t\tconst pipeline = await findLatestPipeline(client, repo.id, config);\n\t\t\t\tif (\n\t\t\t\t\t!pipeline ||\n\t\t\t\t\t!terminal.has(pipeline.status) ||\n\t\t\t\t\t(config.statuses && !config.statuses.includes(pipeline.status))\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tawait report.fire(\n\t\t\t\t\tarmed,\n\t\t\t\t\t{ repositoryId: repo.id, pipeline },\n\t\t\t\t\t`${pipeline.number}:${pipeline.status}`,\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\n/** The bounded lookup reports incomplete history instead of waiting silently. */\nexport async function findLatestPipeline(\n\tclient: WoodpeckerClientLike,\n\trepoId: number,\n\tconfig: WoodpeckerPipelineSourceConfig,\n) {\n\tfor (let page = 1; page <= 10; page++) {\n\t\tconst pipelines = (await client.listPipelines(repoId, undefined, { page, perPage: 100 })).sort(\n\t\t\t(a, b) => b.number - a.number,\n\t\t);\n\t\tconst match = pipelines.find(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.number > (config.afterPipelineNumber ?? 0) &&\n\t\t\t\tcandidate.commit === config.headSha &&\n\t\t\t\tsupportedEvents.has(candidate.event) &&\n\t\t\t\tmatchesBranch(candidate.event, candidate.branch, config.branch),\n\t\t);\n\t\tif (match) return match;\n\t\tif (\n\t\t\tpipelines.length < 100 ||\n\t\t\tpipelines.some((candidate) => candidate.number <= (config.afterPipelineNumber ?? 0))\n\t\t)\n\t\t\treturn null;\n\t}\n\tthrow new Error(\n\t\t\"Woodpecker pipeline lookup window exhausted (1000 pipelines); inspect the repository and update the watched pipeline floor before retrying\",\n\t);\n}\n","import type { ExternalActionSource } from \"@leitwerk-dev/process-sdk\";\nexport const WOODPECKER_PIPELINE_KIND = \"@leitwerk-private/woodpecker.pipeline\";\nexport interface WoodpeckerPipelineSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tbranch: string;\n\theadSha: string;\n\tafterPipelineNumber?: number;\n\tdisabled?: boolean;\n\tpollInterval?: string;\n\tstatuses?: string[];\n}\nexport const woodpeckerExternal = {\n\tpipeline<TParams, TState>(\n\t\tresolve: (ctx: { params: TParams; state: TState }) => WoodpeckerPipelineSourceConfig,\n\t): ExternalActionSource<TParams, TState> {\n\t\treturn {\n\t\t\tkind: WOODPECKER_PIPELINE_KIND,\n\t\t\tlabel: \"Woodpecker pipeline completion\",\n\t\t\tdescription: \"Fires when a pipeline matching the current source head completes\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n};\n","import {\n\tcreateWriteIdentity,\n\ttype ExternalWriteLogRepoLike,\n\tensureWrite,\n} from \"@leitwerk-dev/external-writes\";\nimport {\n\ttype IntegrationToolExecutionContext,\n\tnumberArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveWoodpeckerProjectBinding } from \"./binding.js\";\nimport type { WoodpeckerIntegration } from \"./capability.js\";\n\nfunction target(ctx: IntegrationToolExecutionContext) {\n\tconst binding = resolveWoodpeckerProjectBinding(ctx);\n\treturn { fullName: `${binding.owner}/${binding.repo}`, profile: binding.profile };\n}\n\nexport function registerWoodpeckerTools(\n\tapi: ServerExtensionAPI,\n\tintegration: WoodpeckerIntegration,\n\twrites: ExternalWriteLogRepoLike,\n) {\n\tconst schema = projectParameters();\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_lookup_repository\",\n\t\tdescription: \"Resolve the current process repository in Woodpecker\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration.client(t.profile).lookupRepository(t.fullName, ctx.signal);\n\t\t},\n\t});\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_list_pipelines\",\n\t\tdescription: \"List recent Woodpecker pipelines for the current process repository\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.listPipelines(repo.id, ctx.signal);\n\t\t},\n\t});\n\tfor (const name of [\"woodpecker_get_pipeline\", \"woodpecker_restart_pipeline\"] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription: name.endsWith(\"restart_pipeline\")\n\t\t\t\t? \"Restart a diagnosed Woodpecker pipeline\"\n\t\t\t\t: \"Read a Woodpecker pipeline\",\n\t\t\tparameters: projectParameters({\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\t...(name === \"woodpecker_restart_pipeline\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdiagnosis: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Why this is an infrastructure or flaky failure rather than a repository defect\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlogEvidence: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription: \"Concrete bounded-log evidence supporting a restart\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\t\tconst number = numberArg(args, \"pipelineNumber\");\n\t\t\t\tif (name === \"woodpecker_get_pipeline\")\n\t\t\t\t\treturn client.getPipeline(repo.id, number, ctx.signal);\n\t\t\t\tconst diagnosis = stringArg(args, \"diagnosis\");\n\t\t\t\tconst logEvidence = stringArg(args, \"logEvidence\");\n\t\t\t\tawait ensureWrite(\n\t\t\t\t\twrites,\n\t\t\t\t\tctx.process.id,\n\t\t\t\t\tcreateWriteIdentity(\"woodpecker.restart\", ctx.idempotencyKey),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tawait client.restartPipeline(repo.id, number, ctx.signal);\n\t\t\t\t\t\treturn { repoId: repo.id, number, diagnosis, logEvidence };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn { ok: true };\n\t\t\t},\n\t\t});\n\t}\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_get_step_logs\",\n\t\tdescription: \"Read bounded logs for a Woodpecker pipeline step\",\n\t\tparameters: projectParameters(\n\t\t\t{\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\tstepId: { type: \"integer\" },\n\t\t\t\ttailLines: { type: \"integer\" },\n\t\t\t\tmaxBytes: { type: \"integer\" },\n\t\t\t},\n\t\t\t[\"pipelineNumber\", \"stepId\"],\n\t\t),\n\t\tasync execute(ctx, args) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.getStepLogs(\n\t\t\t\trepo.id,\n\t\t\t\tnumberArg(args, \"pipelineNumber\"),\n\t\t\t\tnumberArg(args, \"stepId\"),\n\t\t\t\ttypeof args.tailLines === \"number\" ? args.tailLines : 400,\n\t\t\t\ttypeof args.maxBytes === \"number\" ? args.maxBytes : 262_144,\n\t\t\t\tctx.signal,\n\t\t\t);\n\t\t},\n\t});\n}\n","import { resolveRepositoryProjectBinding } from \"@leitwerk-dev/process-sdk\";\n\nexport type { RepositoryProjectBinding as WoodpeckerProjectBinding } from \"@leitwerk-dev/process-sdk\";\nexport const resolveWoodpeckerProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"woodpecker\", \"forgejo\");\n"],"mappings":";;;;;AACA,SAAS,4BAA0D;;;ACDnE,SAAS,6BAA6B;AAQ/B,IAAM,wBAAwB;AAAA,EACpC;AACD;;;ACVA,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AA0BtC,SAAS,cAAc,MAA0C;AAChE,MAAI,MAAM,QAAQ,IAAI,GAAG;AACxB,WAAO,IAAI,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,EAAE,OAAO,WAAW,KAAK,IAAI,CAAC;AAAA,EAC/E;AACA,MAAI,OAAO,SAAS,SAAU,QAAO;AACrC,MAAI,yBAAyB,KAAK,IAAI,KAAK,KAAK,SAAS,MAAM,GAAG;AACjE,QAAI;AACH,YAAM,SAAS,KAAK,IAAI;AACxB,aAAO,IAAI,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,EAAE;AAAA,QACjD,WAAW,KAAK,QAAQ,CAAC,cAAc,UAAU,W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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../src/logs.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM3F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CoreServerSetupDeps } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
import type { WoodpeckerClientLike, WoodpeckerIntegration } from "./capability.js";
|
|
3
|
+
import { type WoodpeckerPipelineSourceConfig } from "./external.js";
|
|
4
|
+
export declare function createWoodpeckerProvider(deps: CoreServerSetupDeps, integration: WoodpeckerIntegration, options?: {
|
|
5
|
+
now?: () => number;
|
|
6
|
+
}): import("@leitwerk-dev/process-sdk").PollingHandleLike<import("@leitwerk-dev/watcher-utils").PollResult>;
|
|
7
|
+
/** The bounded lookup reports incomplete history instead of waiting silently. */
|
|
8
|
+
export declare function findLatestPipeline(client: WoodpeckerClientLike, repoId: number, config: WoodpeckerPipelineSourceConfig): Promise<import("./client.js").WoodpeckerPipeline | null>;
|
|
9
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAA4B,KAAK,8BAA8B,EAAE,MAAM,eAAe,CAAC;AA2C9F,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,2GAsCpC;AAED,iFAAiF;AACjF,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,8BAA8B,4DAuBtC"}
|