@lumen-ops/plugin-sdk 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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/package.json +36 -0
- package/src/index.ts +214 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zaidhaan
|
|
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,53 @@
|
|
|
1
|
+
# @lumen-ops/plugin-sdk
|
|
2
|
+
|
|
3
|
+
Type definitions for [Lumen](https://github.com/zaidhaan/lumen) plugins.
|
|
4
|
+
|
|
5
|
+
This package contains only types — no runtime code. Import it in your plugin for a typed `LumenPlugin` contract.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev @lumen-ops/plugin-sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add -d @lumen-ops/plugin-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Declare it as a peer dependency in published plugins:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@lumen-ops/plugin-sdk": "^1.0.0"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import type { LumenPlugin } from "@lumen-ops/plugin-sdk"
|
|
27
|
+
|
|
28
|
+
const plugin: LumenPlugin = {
|
|
29
|
+
name: "my-plugin",
|
|
30
|
+
description: "Does something useful",
|
|
31
|
+
configSchema: [
|
|
32
|
+
{ key: "webhookUrl", label: "Webhook URL", type: "secret", required: true },
|
|
33
|
+
],
|
|
34
|
+
hooks: {
|
|
35
|
+
"task:completed": async (ctx, { task, prUrl }) => {
|
|
36
|
+
const url = ctx.config.webhookUrl as string
|
|
37
|
+
if (!url) return
|
|
38
|
+
await ctx.http(url, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: JSON.stringify({ text: `${task.issueKey} done — ${prUrl}` }),
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default plugin
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Versioning
|
|
50
|
+
|
|
51
|
+
`@lumen-ops/plugin-sdk` is versioned independently of Lumen. Minor versions (`1.x`) add new hook types or context properties and are backwards-compatible. Major versions change existing interfaces and are rare.
|
|
52
|
+
|
|
53
|
+
See [docs/plugins.md](../../docs/plugins.md) for the full guide including self-hosting, Docker setup, and all hook/interceptor types.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export interface Task {
|
|
2
|
+
id: string;
|
|
3
|
+
projectId: string;
|
|
4
|
+
issueKey: string;
|
|
5
|
+
issueTitle: string;
|
|
6
|
+
issueDescription: string | null;
|
|
7
|
+
issueType: string;
|
|
8
|
+
repositoryId: string | null;
|
|
9
|
+
baseBranch: string | null;
|
|
10
|
+
workBranch: string | null;
|
|
11
|
+
status: "pending" | "running" | "awaiting_approval" | "awaiting_feedback" | "merging" | "complete" | "failed";
|
|
12
|
+
flow: "direct" | "planned";
|
|
13
|
+
assignedUserId: string | null;
|
|
14
|
+
approvedByUserId: string | null;
|
|
15
|
+
metadata: Record<string, unknown> | null;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
}
|
|
19
|
+
export interface User {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
email: string;
|
|
23
|
+
role: "admin" | "developer" | "collaborator" | null;
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
updatedAt: Date;
|
|
26
|
+
}
|
|
27
|
+
export interface Project {
|
|
28
|
+
id: string;
|
|
29
|
+
organizationId: string;
|
|
30
|
+
name: string;
|
|
31
|
+
trackerProjectKey: string;
|
|
32
|
+
defaultFlow: "direct" | "planned";
|
|
33
|
+
createdAt: Date;
|
|
34
|
+
}
|
|
35
|
+
export interface Run {
|
|
36
|
+
id: string;
|
|
37
|
+
taskId: string;
|
|
38
|
+
iterationId: string | null;
|
|
39
|
+
type: "plan" | "implement";
|
|
40
|
+
status: "queued" | "running" | "success" | "failed" | "cancelled";
|
|
41
|
+
harnessType: string;
|
|
42
|
+
executionBackend: string;
|
|
43
|
+
executionRef: string | null;
|
|
44
|
+
input: Record<string, unknown> | null;
|
|
45
|
+
output: Record<string, unknown> | null;
|
|
46
|
+
startedAt: Date | null;
|
|
47
|
+
completedAt: Date | null;
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
}
|
|
50
|
+
export interface Iteration {
|
|
51
|
+
id: string;
|
|
52
|
+
taskId: string;
|
|
53
|
+
/** 1-based sequence number within the task */
|
|
54
|
+
number: number;
|
|
55
|
+
/** Amendment feedback that triggered this iteration; null for iteration 1 */
|
|
56
|
+
feedback: string | null;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
}
|
|
59
|
+
export interface Artifact {
|
|
60
|
+
id: string;
|
|
61
|
+
taskId: string;
|
|
62
|
+
iterationId: string | null;
|
|
63
|
+
runId: string | null;
|
|
64
|
+
key: string;
|
|
65
|
+
value: string;
|
|
66
|
+
label: string | null;
|
|
67
|
+
type: "url" | "text" | "number" | "image";
|
|
68
|
+
createdAt: Date;
|
|
69
|
+
}
|
|
70
|
+
export type HookPayloads = {
|
|
71
|
+
"task:created": {
|
|
72
|
+
task: Task;
|
|
73
|
+
};
|
|
74
|
+
"task:assigned": {
|
|
75
|
+
task: Task;
|
|
76
|
+
assignee: User;
|
|
77
|
+
};
|
|
78
|
+
"task:planning": {
|
|
79
|
+
task: Task;
|
|
80
|
+
};
|
|
81
|
+
"task:plan-ready": {
|
|
82
|
+
task: Task;
|
|
83
|
+
plan: string;
|
|
84
|
+
};
|
|
85
|
+
"task:plan-approved": {
|
|
86
|
+
task: Task;
|
|
87
|
+
plan: string;
|
|
88
|
+
};
|
|
89
|
+
"task:plan-rejected": {
|
|
90
|
+
task: Task;
|
|
91
|
+
feedback: string;
|
|
92
|
+
};
|
|
93
|
+
"task:implementing": {
|
|
94
|
+
task: Task;
|
|
95
|
+
};
|
|
96
|
+
"task:awaiting_feedback": {
|
|
97
|
+
task: Task;
|
|
98
|
+
prUrl: string;
|
|
99
|
+
iterationNumber: number;
|
|
100
|
+
};
|
|
101
|
+
"task:amendment_requested": {
|
|
102
|
+
task: Task;
|
|
103
|
+
feedback: string;
|
|
104
|
+
iterationNumber: number;
|
|
105
|
+
};
|
|
106
|
+
"task:merging": {
|
|
107
|
+
task: Task;
|
|
108
|
+
prUrl: string;
|
|
109
|
+
};
|
|
110
|
+
"task:complete": {
|
|
111
|
+
task: Task;
|
|
112
|
+
prUrl: string;
|
|
113
|
+
};
|
|
114
|
+
"task:failed": {
|
|
115
|
+
task: Task;
|
|
116
|
+
error: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export type InterceptorPayloads = {
|
|
120
|
+
"plan:before-dispatch": {
|
|
121
|
+
task: Task;
|
|
122
|
+
prompt: string;
|
|
123
|
+
};
|
|
124
|
+
"implement:before-dispatch": {
|
|
125
|
+
task: Task;
|
|
126
|
+
plan: string | undefined;
|
|
127
|
+
prompt: string;
|
|
128
|
+
};
|
|
129
|
+
"amendment:before-dispatch": {
|
|
130
|
+
task: Task;
|
|
131
|
+
feedback: string;
|
|
132
|
+
prompt: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export type InterceptorResult<K extends keyof InterceptorPayloads> = Pick<InterceptorPayloads[K], "prompt">;
|
|
136
|
+
export interface PluginContext {
|
|
137
|
+
tasks: {
|
|
138
|
+
get(id: string): Promise<Task>;
|
|
139
|
+
list(filters?: {
|
|
140
|
+
projectId?: string;
|
|
141
|
+
status?: Task["status"];
|
|
142
|
+
}): Promise<Task[]>;
|
|
143
|
+
};
|
|
144
|
+
projects: {
|
|
145
|
+
get(id: string): Promise<Project>;
|
|
146
|
+
list(): Promise<Project[]>;
|
|
147
|
+
};
|
|
148
|
+
runs: {
|
|
149
|
+
get(id: string): Promise<Run>;
|
|
150
|
+
listForTask(taskId: string): Promise<Run[]>;
|
|
151
|
+
};
|
|
152
|
+
iterations: {
|
|
153
|
+
get(id: string): Promise<Iteration>;
|
|
154
|
+
listForTask(taskId: string): Promise<Iteration[]>;
|
|
155
|
+
};
|
|
156
|
+
artifacts: {
|
|
157
|
+
listForTask(taskId: string): Promise<Artifact[]>;
|
|
158
|
+
listForIteration(iterationId: string): Promise<Artifact[]>;
|
|
159
|
+
};
|
|
160
|
+
http: typeof globalThis.fetch;
|
|
161
|
+
logger: {
|
|
162
|
+
info(msg: string, data?: Record<string, unknown>): void;
|
|
163
|
+
warn(msg: string, data?: Record<string, unknown>): void;
|
|
164
|
+
error(msg: string, data?: Record<string, unknown>): void;
|
|
165
|
+
};
|
|
166
|
+
/** Values from installed_plugin.config for this plugin */
|
|
167
|
+
config: Readonly<Record<string, unknown>>;
|
|
168
|
+
}
|
|
169
|
+
export interface PluginConfigField {
|
|
170
|
+
key: string;
|
|
171
|
+
label: string;
|
|
172
|
+
type: "string" | "secret" | "boolean" | "number" | "select";
|
|
173
|
+
/** Literal string options for "select" fields — inferred as a union when using definePlugin */
|
|
174
|
+
options?: readonly string[];
|
|
175
|
+
required?: boolean;
|
|
176
|
+
description?: string;
|
|
177
|
+
}
|
|
178
|
+
type FieldValueType<F extends PluginConfigField> = F["type"] extends "boolean" ? boolean : F["type"] extends "number" ? number : F["type"] extends "select" ? F["options"] extends readonly string[] ? F["options"][number] : string : string;
|
|
179
|
+
type ConfigFromSchema<Fields extends readonly PluginConfigField[]> = {
|
|
180
|
+
[F in Fields[number] as F["key"]]: F["required"] extends true ? FieldValueType<F> : FieldValueType<F> | undefined;
|
|
181
|
+
};
|
|
182
|
+
/** PluginContext with config narrowed to the type inferred from configSchema */
|
|
183
|
+
type TypedPluginContext<Config extends Record<string, unknown>> = Omit<PluginContext, "config"> & {
|
|
184
|
+
config: Readonly<Config>;
|
|
185
|
+
};
|
|
186
|
+
export interface LumenPlugin {
|
|
187
|
+
name: string;
|
|
188
|
+
version?: string;
|
|
189
|
+
description?: string;
|
|
190
|
+
configSchema?: PluginConfigField[];
|
|
191
|
+
hooks?: {
|
|
192
|
+
[K in keyof HookPayloads]?: (ctx: PluginContext, payload: HookPayloads[K]) => Promise<void>;
|
|
193
|
+
};
|
|
194
|
+
intercept?: {
|
|
195
|
+
[K in keyof InterceptorPayloads]?: (ctx: PluginContext, payload: InterceptorPayloads[K]) => Promise<InterceptorResult<K>>;
|
|
196
|
+
};
|
|
197
|
+
routes?: (app: any) => any;
|
|
198
|
+
ui?: Record<string, unknown>;
|
|
199
|
+
}
|
|
200
|
+
type PluginDefinition<Config extends Record<string, unknown>> = Omit<LumenPlugin, "hooks" | "intercept"> & {
|
|
201
|
+
hooks?: {
|
|
202
|
+
[K in keyof HookPayloads]?: (ctx: TypedPluginContext<Config>, payload: HookPayloads[K]) => Promise<void>;
|
|
203
|
+
};
|
|
204
|
+
intercept?: {
|
|
205
|
+
[K in keyof InterceptorPayloads]?: (ctx: TypedPluginContext<Config>, payload: InterceptorPayloads[K]) => Promise<InterceptorResult<K>>;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
export declare function definePlugin<const Fields extends readonly PluginConfigField[]>(plugin: {
|
|
209
|
+
configSchema: Fields;
|
|
210
|
+
} & PluginDefinition<ConfigFromSchema<Fields>>): LumenPlugin;
|
|
211
|
+
export declare function definePlugin(plugin: LumenPlugin): LumenPlugin;
|
|
212
|
+
export {};
|
|
213
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC7G,IAA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mB,CAAC,CAAC,CAAC,KAC9B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;KACrC,CAAA;CACJ,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,MAAM,SAAS,SAAS,iBAAiB,EAAE,EAC1E,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAC9E,WAAW,CAAA;AACd,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAAA"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lumen-ops/plugin-sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Type definitions for Lumen plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"elysia": ">=1.2"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"elysia": {
|
|
29
|
+
"optional": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc --project tsconfig.build.json",
|
|
34
|
+
"typecheck": "tsc --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// Simplified entity types exposed to plugins.
|
|
2
|
+
|
|
3
|
+
export interface Task {
|
|
4
|
+
id: string
|
|
5
|
+
projectId: string
|
|
6
|
+
issueKey: string
|
|
7
|
+
issueTitle: string
|
|
8
|
+
issueDescription: string | null
|
|
9
|
+
issueType: string
|
|
10
|
+
repositoryId: string | null
|
|
11
|
+
baseBranch: string | null
|
|
12
|
+
workBranch: string | null
|
|
13
|
+
status: "pending" | "running" | "awaiting_approval" | "awaiting_feedback" | "merging" | "complete" | "failed"
|
|
14
|
+
flow: "direct" | "planned"
|
|
15
|
+
assignedUserId: string | null
|
|
16
|
+
approvedByUserId: string | null
|
|
17
|
+
metadata: Record<string, unknown> | null
|
|
18
|
+
createdAt: Date
|
|
19
|
+
updatedAt: Date
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface User {
|
|
23
|
+
id: string
|
|
24
|
+
name: string
|
|
25
|
+
email: string
|
|
26
|
+
role: "admin" | "developer" | "collaborator" | null
|
|
27
|
+
createdAt: Date
|
|
28
|
+
updatedAt: Date
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Project {
|
|
32
|
+
id: string
|
|
33
|
+
organizationId: string
|
|
34
|
+
name: string
|
|
35
|
+
trackerProjectKey: string
|
|
36
|
+
defaultFlow: "direct" | "planned"
|
|
37
|
+
createdAt: Date
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Run {
|
|
41
|
+
id: string
|
|
42
|
+
taskId: string
|
|
43
|
+
iterationId: string | null
|
|
44
|
+
type: "plan" | "implement"
|
|
45
|
+
status: "queued" | "running" | "success" | "failed" | "cancelled"
|
|
46
|
+
harnessType: string
|
|
47
|
+
executionBackend: string
|
|
48
|
+
executionRef: string | null
|
|
49
|
+
input: Record<string, unknown> | null
|
|
50
|
+
output: Record<string, unknown> | null
|
|
51
|
+
startedAt: Date | null
|
|
52
|
+
completedAt: Date | null
|
|
53
|
+
createdAt: Date
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface Iteration {
|
|
57
|
+
id: string
|
|
58
|
+
taskId: string
|
|
59
|
+
/** 1-based sequence number within the task */
|
|
60
|
+
number: number
|
|
61
|
+
/** Amendment feedback that triggered this iteration; null for iteration 1 */
|
|
62
|
+
feedback: string | null
|
|
63
|
+
createdAt: Date
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface Artifact {
|
|
67
|
+
id: string
|
|
68
|
+
taskId: string
|
|
69
|
+
iterationId: string | null
|
|
70
|
+
runId: string | null
|
|
71
|
+
key: string
|
|
72
|
+
value: string
|
|
73
|
+
label: string | null
|
|
74
|
+
type: "url" | "text" | "number" | "image"
|
|
75
|
+
createdAt: Date
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Hook payloads
|
|
79
|
+
|
|
80
|
+
export type HookPayloads = {
|
|
81
|
+
"task:created": { task: Task }
|
|
82
|
+
"task:assigned": { task: Task; assignee: User }
|
|
83
|
+
// Emitted when a plan run is dispatched (task status is "running")
|
|
84
|
+
"task:planning": { task: Task }
|
|
85
|
+
"task:plan-ready": { task: Task; plan: string }
|
|
86
|
+
"task:plan-approved": { task: Task; plan: string }
|
|
87
|
+
"task:plan-rejected": { task: Task; feedback: string }
|
|
88
|
+
// Emitted when an implement run is dispatched (task status is "running")
|
|
89
|
+
"task:implementing": { task: Task }
|
|
90
|
+
// Emitted when an implement run succeeds and the PR is ready for feedback
|
|
91
|
+
"task:awaiting_feedback": { task: Task; prUrl: string; iterationNumber: number }
|
|
92
|
+
// Emitted when an amendment is requested, triggering a new iteration
|
|
93
|
+
"task:amendment_requested": { task: Task; feedback: string; iterationNumber: number }
|
|
94
|
+
// Emitted when a merge is triggered
|
|
95
|
+
"task:merging": { task: Task; prUrl: string }
|
|
96
|
+
// Emitted when the task is fully complete (PR merged)
|
|
97
|
+
"task:complete": { task: Task; prUrl: string }
|
|
98
|
+
"task:failed": { task: Task; error: string }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Interceptor payloads - return value modifies what gets dispatched
|
|
102
|
+
|
|
103
|
+
export type InterceptorPayloads = {
|
|
104
|
+
"plan:before-dispatch": { task: Task; prompt: string }
|
|
105
|
+
"implement:before-dispatch": { task: Task; plan: string | undefined; prompt: string }
|
|
106
|
+
"amendment:before-dispatch": { task: Task; feedback: string; prompt: string }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type InterceptorResult<K extends keyof InterceptorPayloads> = Pick<InterceptorPayloads[K], "prompt">
|
|
110
|
+
|
|
111
|
+
// Plugin context - interface-only access to Lumen data
|
|
112
|
+
|
|
113
|
+
export interface PluginContext {
|
|
114
|
+
tasks: {
|
|
115
|
+
get(id: string): Promise<Task>
|
|
116
|
+
list(filters?: { projectId?: string; status?: Task["status"] }): Promise<Task[]>
|
|
117
|
+
}
|
|
118
|
+
projects: {
|
|
119
|
+
get(id: string): Promise<Project>
|
|
120
|
+
list(): Promise<Project[]>
|
|
121
|
+
}
|
|
122
|
+
runs: {
|
|
123
|
+
get(id: string): Promise<Run>
|
|
124
|
+
listForTask(taskId: string): Promise<Run[]>
|
|
125
|
+
}
|
|
126
|
+
iterations: {
|
|
127
|
+
get(id: string): Promise<Iteration>
|
|
128
|
+
listForTask(taskId: string): Promise<Iteration[]>
|
|
129
|
+
}
|
|
130
|
+
artifacts: {
|
|
131
|
+
listForTask(taskId: string): Promise<Artifact[]>
|
|
132
|
+
listForIteration(iterationId: string): Promise<Artifact[]>
|
|
133
|
+
}
|
|
134
|
+
http: typeof globalThis.fetch
|
|
135
|
+
logger: {
|
|
136
|
+
info(msg: string, data?: Record<string, unknown>): void
|
|
137
|
+
warn(msg: string, data?: Record<string, unknown>): void
|
|
138
|
+
error(msg: string, data?: Record<string, unknown>): void
|
|
139
|
+
}
|
|
140
|
+
/** Values from installed_plugin.config for this plugin */
|
|
141
|
+
config: Readonly<Record<string, unknown>>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Config schema - drives the admin UI config form
|
|
145
|
+
|
|
146
|
+
export interface PluginConfigField {
|
|
147
|
+
key: string
|
|
148
|
+
label: string
|
|
149
|
+
type: "string" | "secret" | "boolean" | "number" | "select"
|
|
150
|
+
/** Literal string options for "select" fields — inferred as a union when using definePlugin */
|
|
151
|
+
options?: readonly string[]
|
|
152
|
+
required?: boolean
|
|
153
|
+
description?: string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Config type inference from schema
|
|
157
|
+
|
|
158
|
+
type FieldValueType<F extends PluginConfigField> = F["type"] extends "boolean"
|
|
159
|
+
? boolean
|
|
160
|
+
: F["type"] extends "number"
|
|
161
|
+
? number
|
|
162
|
+
: F["type"] extends "select"
|
|
163
|
+
? F["options"] extends readonly string[]
|
|
164
|
+
? F["options"][number]
|
|
165
|
+
: string
|
|
166
|
+
: string
|
|
167
|
+
|
|
168
|
+
type ConfigFromSchema<Fields extends readonly PluginConfigField[]> = {
|
|
169
|
+
[F in Fields[number] as F["key"]]: F["required"] extends true ? FieldValueType<F> : FieldValueType<F> | undefined
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** PluginContext with config narrowed to the type inferred from configSchema */
|
|
173
|
+
type TypedPluginContext<Config extends Record<string, unknown>> = Omit<PluginContext, "config"> & {
|
|
174
|
+
config: Readonly<Config>
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface LumenPlugin {
|
|
178
|
+
name: string
|
|
179
|
+
version?: string
|
|
180
|
+
description?: string
|
|
181
|
+
configSchema?: PluginConfigField[]
|
|
182
|
+
hooks?: {
|
|
183
|
+
[K in keyof HookPayloads]?: (ctx: PluginContext, payload: HookPayloads[K]) => Promise<void>
|
|
184
|
+
}
|
|
185
|
+
intercept?: {
|
|
186
|
+
[K in keyof InterceptorPayloads]?: (
|
|
187
|
+
ctx: PluginContext,
|
|
188
|
+
payload: InterceptorPayloads[K],
|
|
189
|
+
) => Promise<InterceptorResult<K>>
|
|
190
|
+
}
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
|
+
routes?: (app: any) => any
|
|
193
|
+
ui?: Record<string, unknown>
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
type PluginDefinition<Config extends Record<string, unknown>> = Omit<LumenPlugin, "hooks" | "intercept"> & {
|
|
197
|
+
hooks?: {
|
|
198
|
+
[K in keyof HookPayloads]?: (ctx: TypedPluginContext<Config>, payload: HookPayloads[K]) => Promise<void>
|
|
199
|
+
}
|
|
200
|
+
intercept?: {
|
|
201
|
+
[K in keyof InterceptorPayloads]?: (
|
|
202
|
+
ctx: TypedPluginContext<Config>,
|
|
203
|
+
payload: InterceptorPayloads[K],
|
|
204
|
+
) => Promise<InterceptorResult<K>>
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function definePlugin<const Fields extends readonly PluginConfigField[]>(
|
|
209
|
+
plugin: { configSchema: Fields } & PluginDefinition<ConfigFromSchema<Fields>>,
|
|
210
|
+
): LumenPlugin
|
|
211
|
+
export function definePlugin(plugin: LumenPlugin): LumenPlugin
|
|
212
|
+
export function definePlugin(plugin: unknown): LumenPlugin {
|
|
213
|
+
return plugin as LumenPlugin
|
|
214
|
+
}
|