@open-mercato/cezar 0.9.1-pr693.809 → 0.9.1-pr694.810
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/dist/automations/coordinator.d.ts +26 -0
- package/dist/automations/coordinator.js +66 -0
- package/dist/automations/coordinator.js.map +1 -0
- package/dist/automations/github-poller.d.ts +134 -0
- package/dist/automations/github-poller.js +159 -0
- package/dist/automations/github-poller.js.map +1 -0
- package/dist/automations/scheduler.d.ts +42 -0
- package/dist/automations/scheduler.js +170 -0
- package/dist/automations/scheduler.js.map +1 -0
- package/dist/automations/store.d.ts +65 -0
- package/dist/automations/store.js +298 -0
- package/dist/automations/store.js.map +1 -0
- package/dist/automations/task-template.d.ts +18 -0
- package/dist/automations/task-template.js +95 -0
- package/dist/automations/task-template.js.map +1 -0
- package/dist/automations/types.d.ts +3650 -0
- package/dist/automations/types.js +157 -0
- package/dist/automations/types.js.map +1 -0
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/runs/store.d.ts +34 -0
- package/dist/runs/store.js +10 -0
- package/dist/runs/store.js.map +1 -1
- package/dist/server/project-context.d.ts +2 -0
- package/dist/server/project-context.js +5 -1
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/server.d.ts +3 -1
- package/dist/server/server.js +310 -3
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/run.d.ts +1 -8
- package/dist/workflows/run.js +5 -80
- package/dist/workflows/run.js.map +1 -1
- package/package.json +1 -1
- package/web/dist/assets/{centered-state-Bg5rOXEx.js → centered-state-D-hkkRHv.js} +11 -11
- package/web/dist/assets/{commit-list-C3zeFmAm.js → commit-list-BXNfseD5.js} +1 -1
- package/web/dist/assets/{compare-variants-Cboe8dyN.js → compare-variants-CkvpSWZa.js} +1 -1
- package/web/dist/assets/{diff-DnvqRrMZ.js → diff-CITBzanN.js} +2 -2
- package/web/dist/assets/{diff-view-CY-kSaX7.js → diff-view-BBgUutQ0.js} +1 -1
- package/web/dist/assets/{dist-CmM4ohL9.js → dist-C553orO_.js} +1 -1
- package/web/dist/assets/{git-toolbar-Dty9Ym9s.js → git-toolbar-ChCEnVjR.js} +1 -1
- package/web/dist/assets/github-B8nK4e73.js +1 -0
- package/web/dist/assets/index-BWzcnzgp.js +30 -0
- package/web/dist/assets/index-pJfUoRGK.css +2 -0
- package/web/dist/assets/{project-router-P22lL0KR.js → project-router-C-gp_QmI.js} +1 -1
- package/web/dist/assets/{repo-git-B9xABw5K.js → repo-git-DW8ekpNQ.js} +1 -1
- package/web/dist/assets/{run-diff-DEmYJiqI.js → run-diff-DeWQ1xve.js} +1 -1
- package/web/dist/assets/run-header-BaLnTHQf.js +1 -0
- package/web/dist/assets/{skills-B2-xg0pU.js → skills-Bt9YVDdo.js} +1 -1
- package/web/dist/assets/{tab-link-D1uaDMQQ.js → tab-link-C2tgsylt.js} +1 -1
- package/web/dist/assets/{task-changes-BXRocRAH.js → task-changes-CluQWIkd.js} +1 -1
- package/web/dist/assets/task-commits-BJRUd8fY.js +1 -0
- package/web/dist/assets/{task-files-dGLG8EaX.js → task-files-CpWfXD2B.js} +2 -2
- package/web/dist/assets/{task-thread-COp81_g4.js → task-thread-x1axqNnn.js} +7 -7
- package/web/dist/assets/{use-desktop-DQp6McVl.js → use-desktop-BB0Ck5sN.js} +1 -1
- package/web/dist/assets/{workflows-DOb7pvOX.js → workflows-C3gTBtmF.js} +3 -3
- package/web/dist/index.html +5 -5
- package/web/dist/assets/github-Bm0vyzru.js +0 -1
- package/web/dist/assets/index-C2MYcg0H.css +0 -2
- package/web/dist/assets/index-DnwwXiEu.js +0 -30
- package/web/dist/assets/run-header-hnBvmejN.js +0 -1
- package/web/dist/assets/task-commits-PLa6Ynuz.js +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AutomationStore } from './store.js';
|
|
2
|
+
export interface AutomationProjectSource {
|
|
3
|
+
id: string;
|
|
4
|
+
root: string;
|
|
5
|
+
status: 'ok' | 'missing' | 'not-git';
|
|
6
|
+
}
|
|
7
|
+
export interface AutomationCoordinatorOptions {
|
|
8
|
+
listProjects: () => Promise<readonly AutomationProjectSource[]>;
|
|
9
|
+
warn?: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Lightweight workspace index for project automation state. Discovery checks
|
|
13
|
+
* only the optional definitions file and never materializes a RunManager or a
|
|
14
|
+
* full ProjectContext. Schedulers attach to these handles in Phase 4.
|
|
15
|
+
*/
|
|
16
|
+
export declare class AutomationCoordinator {
|
|
17
|
+
private readonly options;
|
|
18
|
+
private readonly stores;
|
|
19
|
+
private readonly roots;
|
|
20
|
+
constructor(options: AutomationCoordinatorOptions);
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
store(projectId: string, root?: string): AutomationStore | undefined;
|
|
23
|
+
enabledProjectIds(): string[];
|
|
24
|
+
remove(projectId: string): void;
|
|
25
|
+
ids(): string[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AutomationStore } from './store.js';
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight workspace index for project automation state. Discovery checks
|
|
6
|
+
* only the optional definitions file and never materializes a RunManager or a
|
|
7
|
+
* full ProjectContext. Schedulers attach to these handles in Phase 4.
|
|
8
|
+
*/
|
|
9
|
+
export class AutomationCoordinator {
|
|
10
|
+
options;
|
|
11
|
+
stores = new Map();
|
|
12
|
+
roots = new Map();
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async refresh() {
|
|
17
|
+
let projects;
|
|
18
|
+
try {
|
|
19
|
+
projects = await this.options.listProjects();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
this.options.warn?.(`Unable to refresh GitHub automations: ${error instanceof Error ? error.message : String(error)}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const present = new Set(projects.map((project) => project.id));
|
|
26
|
+
for (const id of this.stores.keys()) {
|
|
27
|
+
if (!present.has(id))
|
|
28
|
+
this.remove(id);
|
|
29
|
+
}
|
|
30
|
+
for (const project of projects) {
|
|
31
|
+
if (project.status === 'missing') {
|
|
32
|
+
this.remove(project.id);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
this.roots.set(project.id, project.root);
|
|
36
|
+
const definitions = join(project.root, '.ai/cezar/automations.json');
|
|
37
|
+
if (existsSync(definitions))
|
|
38
|
+
this.store(project.id, project.root);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
store(projectId, root) {
|
|
42
|
+
const existing = this.stores.get(projectId);
|
|
43
|
+
if (existing)
|
|
44
|
+
return existing;
|
|
45
|
+
const projectRoot = root ?? this.roots.get(projectId);
|
|
46
|
+
if (!projectRoot)
|
|
47
|
+
return undefined;
|
|
48
|
+
const store = AutomationStore.open(join(projectRoot, '.ai/cezar'), { warn: this.options.warn });
|
|
49
|
+
this.stores.set(projectId, store);
|
|
50
|
+
this.roots.set(projectId, projectRoot);
|
|
51
|
+
return store;
|
|
52
|
+
}
|
|
53
|
+
enabledProjectIds() {
|
|
54
|
+
return [...this.stores.entries()]
|
|
55
|
+
.filter(([, store]) => store.list().some((definition) => definition.enabled))
|
|
56
|
+
.map(([id]) => id);
|
|
57
|
+
}
|
|
58
|
+
remove(projectId) {
|
|
59
|
+
this.stores.delete(projectId);
|
|
60
|
+
this.roots.delete(projectId);
|
|
61
|
+
}
|
|
62
|
+
ids() {
|
|
63
|
+
return [...this.stores.keys()];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../src/automations/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAA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SAAiB;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AutomationDefinition, AutomationEvent } from './types.js';
|
|
3
|
+
declare const githubItemSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
node_id: z.ZodString;
|
|
6
|
+
number: z.ZodNumber;
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
html_url: z.ZodString;
|
|
9
|
+
created_at: z.ZodString;
|
|
10
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
11
|
+
user: z.ZodObject<{
|
|
12
|
+
login: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
login: string;
|
|
15
|
+
}, {
|
|
16
|
+
login: string;
|
|
17
|
+
}>;
|
|
18
|
+
assignees: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
19
|
+
login: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
login: string;
|
|
22
|
+
}, {
|
|
23
|
+
login: string;
|
|
24
|
+
}>, "many">>;
|
|
25
|
+
labels: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
name: string;
|
|
29
|
+
}, {
|
|
30
|
+
name: string;
|
|
31
|
+
}>, "many">>;
|
|
32
|
+
repository_url: z.ZodString;
|
|
33
|
+
pull_request: z.ZodOptional<z.ZodUnknown>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
id?: number | undefined;
|
|
36
|
+
node_id: string;
|
|
37
|
+
number: number;
|
|
38
|
+
title: string;
|
|
39
|
+
html_url: string;
|
|
40
|
+
created_at: string;
|
|
41
|
+
updated_at?: string | undefined;
|
|
42
|
+
user: {
|
|
43
|
+
login: string;
|
|
44
|
+
};
|
|
45
|
+
assignees: {
|
|
46
|
+
login: string;
|
|
47
|
+
}[];
|
|
48
|
+
labels: {
|
|
49
|
+
name: string;
|
|
50
|
+
}[];
|
|
51
|
+
repository_url: string;
|
|
52
|
+
pull_request?: unknown;
|
|
53
|
+
}, {
|
|
54
|
+
id?: number | undefined;
|
|
55
|
+
node_id: string;
|
|
56
|
+
number: number;
|
|
57
|
+
title: string;
|
|
58
|
+
html_url: string;
|
|
59
|
+
created_at: string;
|
|
60
|
+
updated_at?: string | undefined;
|
|
61
|
+
user: {
|
|
62
|
+
login: string;
|
|
63
|
+
};
|
|
64
|
+
assignees?: {
|
|
65
|
+
login: string;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
labels?: {
|
|
68
|
+
name: string;
|
|
69
|
+
}[] | undefined;
|
|
70
|
+
repository_url: string;
|
|
71
|
+
pull_request?: unknown;
|
|
72
|
+
}>;
|
|
73
|
+
declare const timelineEventSchema: z.ZodObject<{
|
|
74
|
+
id: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
node_id: z.ZodOptional<z.ZodString>;
|
|
76
|
+
event: z.ZodEnum<["labeled", "unlabeled"]>;
|
|
77
|
+
created_at: z.ZodString;
|
|
78
|
+
label: z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
name: string;
|
|
82
|
+
}, {
|
|
83
|
+
name: string;
|
|
84
|
+
}>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
id?: number | undefined;
|
|
87
|
+
node_id?: string | undefined;
|
|
88
|
+
event: "labeled" | "unlabeled";
|
|
89
|
+
created_at: string;
|
|
90
|
+
label: {
|
|
91
|
+
name: string;
|
|
92
|
+
};
|
|
93
|
+
}, {
|
|
94
|
+
id?: number | undefined;
|
|
95
|
+
node_id?: string | undefined;
|
|
96
|
+
event: "labeled" | "unlabeled";
|
|
97
|
+
created_at: string;
|
|
98
|
+
label: {
|
|
99
|
+
name: string;
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
export interface GithubCandidate {
|
|
103
|
+
eventId: string;
|
|
104
|
+
event: AutomationEvent;
|
|
105
|
+
timestamp: string;
|
|
106
|
+
tieBreaker: string;
|
|
107
|
+
repo: string;
|
|
108
|
+
nodeId: string;
|
|
109
|
+
number: number;
|
|
110
|
+
title: string;
|
|
111
|
+
url: string;
|
|
112
|
+
author: string;
|
|
113
|
+
assignees: string[];
|
|
114
|
+
labels: string[];
|
|
115
|
+
changedLabel?: string;
|
|
116
|
+
}
|
|
117
|
+
export interface GithubPollResult {
|
|
118
|
+
candidates: GithubCandidate[];
|
|
119
|
+
truncated: boolean;
|
|
120
|
+
pages: number;
|
|
121
|
+
}
|
|
122
|
+
export interface GithubPollerOptions {
|
|
123
|
+
run?: (executable: string, args: readonly string[]) => Promise<string>;
|
|
124
|
+
}
|
|
125
|
+
export declare class GithubPoller {
|
|
126
|
+
private readonly run;
|
|
127
|
+
constructor(options?: GithubPollerOptions);
|
|
128
|
+
poll(owner: string, repo: string, definition: AutomationDefinition): Promise<GithubPollResult>;
|
|
129
|
+
private timeline;
|
|
130
|
+
}
|
|
131
|
+
export declare function buildSearchQuery(owner: string, repo: string, definition: AutomationDefinition, family?: 'issues' | 'prs' | 'mixed'): string;
|
|
132
|
+
export declare function reconstructLabelEvents(owner: string, repo: string, item: z.infer<typeof githubItemSchema>, timeline: z.infer<typeof timelineEventSchema>[]): GithubCandidate[];
|
|
133
|
+
export declare function matchesFilters(candidate: GithubCandidate, definition: AutomationDefinition): boolean;
|
|
134
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
const HARD_CANDIDATE_CAP = 100;
|
|
6
|
+
const githubItemSchema = z.object({
|
|
7
|
+
id: z.number().int().positive().optional(),
|
|
8
|
+
node_id: z.string().min(1),
|
|
9
|
+
number: z.number().int().positive(),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
html_url: z.string().url(),
|
|
12
|
+
created_at: z.string().datetime(),
|
|
13
|
+
updated_at: z.string().datetime().optional(),
|
|
14
|
+
user: z.object({ login: z.string() }),
|
|
15
|
+
assignees: z.array(z.object({ login: z.string() })).default([]),
|
|
16
|
+
labels: z.array(z.object({ name: z.string() })).default([]),
|
|
17
|
+
repository_url: z.string().url(),
|
|
18
|
+
pull_request: z.unknown().optional(),
|
|
19
|
+
});
|
|
20
|
+
const searchResponseSchema = z.object({ items: z.array(githubItemSchema) });
|
|
21
|
+
const timelineEventSchema = z.object({
|
|
22
|
+
id: z.number().int().positive().optional(),
|
|
23
|
+
node_id: z.string().optional(),
|
|
24
|
+
event: z.enum(['labeled', 'unlabeled']),
|
|
25
|
+
created_at: z.string().datetime(),
|
|
26
|
+
label: z.object({ name: z.string() }),
|
|
27
|
+
});
|
|
28
|
+
export class GithubPoller {
|
|
29
|
+
run;
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
this.run = options.run ?? (async (executable, args) => (await execFileAsync(executable, [...args], { maxBuffer: 4 * 1024 * 1024 })).stdout);
|
|
32
|
+
}
|
|
33
|
+
async poll(owner, repo, definition) {
|
|
34
|
+
const family = definition.events.some((event) => event === 'issue.labeled' || event === 'issue.unlabeled')
|
|
35
|
+
? 'issues'
|
|
36
|
+
: definition.events.every((event) => event === 'pull_request.opened') ? 'prs' : 'mixed';
|
|
37
|
+
const query = buildSearchQuery(owner, repo, definition, family);
|
|
38
|
+
const perPage = Math.min(definition.filters.maxRecords, HARD_CANDIDATE_CAP);
|
|
39
|
+
const args = ['api', '--method', 'GET', '/search/issues', '-f', `q=${query}`, '-f', `per_page=${perPage}`, '-f', 'sort=created', '-f', 'order=desc'];
|
|
40
|
+
const raw = await this.run('gh', args);
|
|
41
|
+
const response = searchResponseSchema.parse(JSON.parse(raw));
|
|
42
|
+
const expectedRepoUrl = `https://api.github.com/repos/${owner}/${repo}`.toLowerCase();
|
|
43
|
+
const candidates = [];
|
|
44
|
+
for (const item of response.items.slice(0, HARD_CANDIDATE_CAP)) {
|
|
45
|
+
if (item.repository_url.toLowerCase() !== expectedRepoUrl)
|
|
46
|
+
continue;
|
|
47
|
+
if (item.pull_request && definition.events.includes('pull_request.opened')) {
|
|
48
|
+
const candidate = normalizeOpened(owner, repo, item, 'pull_request.opened');
|
|
49
|
+
if (matchesFilters(candidate, definition))
|
|
50
|
+
candidates.push(candidate);
|
|
51
|
+
}
|
|
52
|
+
else if (!item.pull_request && definition.events.includes('issue.opened')) {
|
|
53
|
+
const candidate = normalizeOpened(owner, repo, item, 'issue.opened');
|
|
54
|
+
if (matchesFilters(candidate, definition))
|
|
55
|
+
candidates.push(candidate);
|
|
56
|
+
}
|
|
57
|
+
if (!item.pull_request && definition.events.some((event) => event === 'issue.labeled' || event === 'issue.unlabeled')) {
|
|
58
|
+
const timeline = await this.timeline(owner, repo, item.number);
|
|
59
|
+
for (const event of reconstructLabelEvents(owner, repo, item, timeline)) {
|
|
60
|
+
if (definition.events.includes(event.event) && matchesFilters(event, definition))
|
|
61
|
+
candidates.push(event);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (candidates.length >= definition.filters.maxRecords)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
candidates.sort((a, b) => a.timestamp.localeCompare(b.timestamp) || a.tieBreaker.localeCompare(b.tieBreaker));
|
|
68
|
+
return {
|
|
69
|
+
candidates: candidates.slice(0, definition.filters.maxRecords),
|
|
70
|
+
truncated: response.items.length >= perPage || candidates.length > definition.filters.maxRecords,
|
|
71
|
+
pages: 1,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async timeline(owner, repo, number) {
|
|
75
|
+
const raw = await this.run('gh', [
|
|
76
|
+
'api', '--method', 'GET', `repos/${owner}/${repo}/issues/${number}/timeline`,
|
|
77
|
+
'-H', 'Accept: application/vnd.github+json', '-f', 'per_page=100',
|
|
78
|
+
]);
|
|
79
|
+
return z.array(timelineEventSchema).parse(JSON.parse(raw));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function buildSearchQuery(owner, repo, definition, family = 'mixed') {
|
|
83
|
+
const start = new Date(Date.now() - definition.filters.lookbackDays * 86_400_000).toISOString().slice(0, 10);
|
|
84
|
+
const terms = [`repo:${owner}/${repo}`, family === 'prs' ? 'is:pr' : family === 'issues' ? 'is:issue' : '', `created:>=${start}`];
|
|
85
|
+
for (const author of definition.filters.authors ?? [])
|
|
86
|
+
terms.push(`author:${safeQualifier(author)}`);
|
|
87
|
+
for (const assignee of definition.filters.assignees ?? [])
|
|
88
|
+
terms.push(`assignee:${safeQualifier(assignee)}`);
|
|
89
|
+
for (const label of definition.filters.allLabels ?? [])
|
|
90
|
+
terms.push(`label:${JSON.stringify(label)}`);
|
|
91
|
+
return terms.filter(Boolean).join(' ');
|
|
92
|
+
}
|
|
93
|
+
function safeQualifier(value) {
|
|
94
|
+
return value.replace(/[^A-Za-z0-9_.-]/g, '');
|
|
95
|
+
}
|
|
96
|
+
function normalizeOpened(owner, repo, item, event) {
|
|
97
|
+
const eventId = `${owner}/${repo}:${item.node_id}:${event}:${item.created_at}`;
|
|
98
|
+
return {
|
|
99
|
+
eventId,
|
|
100
|
+
event,
|
|
101
|
+
timestamp: item.created_at,
|
|
102
|
+
tieBreaker: item.node_id,
|
|
103
|
+
repo: `${owner}/${repo}`,
|
|
104
|
+
nodeId: item.node_id,
|
|
105
|
+
number: item.number,
|
|
106
|
+
title: sanitize(item.title, 500),
|
|
107
|
+
url: item.html_url,
|
|
108
|
+
author: item.user.login,
|
|
109
|
+
assignees: item.assignees.map((assignee) => assignee.login),
|
|
110
|
+
labels: item.labels.map((label) => label.name),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export function reconstructLabelEvents(owner, repo, item, timeline) {
|
|
114
|
+
const current = new Set(item.labels.map((label) => label.name));
|
|
115
|
+
const ordered = [...timeline].sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
116
|
+
const rows = [];
|
|
117
|
+
for (const entry of ordered) {
|
|
118
|
+
const postLabels = [...current];
|
|
119
|
+
if (entry.event === 'labeled')
|
|
120
|
+
current.delete(entry.label.name);
|
|
121
|
+
else
|
|
122
|
+
current.add(entry.label.name);
|
|
123
|
+
const labels = entry.event === 'labeled' ? postLabels : [...current];
|
|
124
|
+
const kind = entry.event === 'labeled' ? 'issue.labeled' : 'issue.unlabeled';
|
|
125
|
+
const stable = entry.node_id ?? String(entry.id ?? `${entry.created_at}:${entry.label.name.toLowerCase()}`);
|
|
126
|
+
rows.push({
|
|
127
|
+
...normalizeOpened(owner, repo, item, 'issue.opened'),
|
|
128
|
+
event: kind,
|
|
129
|
+
eventId: `${owner}/${repo}:${item.node_id}:${kind}:${stable}`,
|
|
130
|
+
timestamp: entry.created_at,
|
|
131
|
+
tieBreaker: stable,
|
|
132
|
+
labels,
|
|
133
|
+
changedLabel: entry.label.name,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return rows;
|
|
137
|
+
}
|
|
138
|
+
export function matchesFilters(candidate, definition) {
|
|
139
|
+
const lower = (values) => new Set(values.map((value) => value.toLowerCase()));
|
|
140
|
+
const labels = lower(candidate.labels);
|
|
141
|
+
const filters = definition.filters;
|
|
142
|
+
if (filters.authors?.length && !lower(filters.authors).has(candidate.author.toLowerCase()))
|
|
143
|
+
return false;
|
|
144
|
+
if (filters.assignees?.length && !candidate.assignees.some((value) => lower(filters.assignees).has(value.toLowerCase())))
|
|
145
|
+
return false;
|
|
146
|
+
if (filters.allLabels?.some((value) => !labels.has(value.toLowerCase())))
|
|
147
|
+
return false;
|
|
148
|
+
if (filters.anyLabels?.length && !filters.anyLabels.some((value) => labels.has(value.toLowerCase())))
|
|
149
|
+
return false;
|
|
150
|
+
if (filters.excludeLabels?.some((value) => labels.has(value.toLowerCase())))
|
|
151
|
+
return false;
|
|
152
|
+
if (candidate.changedLabel && filters.changedLabels?.length && !lower(filters.changedLabels).has(candidate.changedLabel.toLowerCase()))
|
|
153
|
+
return false;
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
function sanitize(value, max) {
|
|
157
|
+
return value.replace(/[\u0000-\u001f\u007f]/g, ' ').slice(0, max);
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=github-poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-poller.js","sourceRoot":"","sources":["../../src/automations/github-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,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E,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1F,IAAI,SAAS,CAAC,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;QAAE,OAAO,KAAK,CAAC;IACrJ,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AutomationCoordinator } from './coordinator.js';
|
|
2
|
+
import type { GithubCandidate, GithubPoller, GithubPollResult } from './github-poller.js';
|
|
3
|
+
import type { AutomationStore } from './store.js';
|
|
4
|
+
import type { AutomationDefinition } from './types.js';
|
|
5
|
+
export interface AutomationLaunchResult {
|
|
6
|
+
runId: string;
|
|
7
|
+
}
|
|
8
|
+
export type AutomationLauncher = (definition: AutomationDefinition, candidate: GithubCandidate, receiptId: string) => Promise<AutomationLaunchResult>;
|
|
9
|
+
export interface ProjectAutomationHandle {
|
|
10
|
+
projectId: string;
|
|
11
|
+
owner: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
store: AutomationStore;
|
|
14
|
+
poller: GithubPoller;
|
|
15
|
+
launch?: AutomationLauncher;
|
|
16
|
+
onChange?: (automationId: string, revision: number) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class ProjectAutomationScheduler {
|
|
19
|
+
private readonly handle;
|
|
20
|
+
constructor(handle: ProjectAutomationHandle);
|
|
21
|
+
check(definition: AutomationDefinition, mode?: 'preview' | 'execute'): Promise<GithubPollResult>;
|
|
22
|
+
private launch;
|
|
23
|
+
private recordFailure;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkspaceAutomationSchedulerOptions {
|
|
26
|
+
coordinator: AutomationCoordinator;
|
|
27
|
+
handle: (projectId: string, store: AutomationStore) => ProjectAutomationHandle | undefined;
|
|
28
|
+
now?: () => number;
|
|
29
|
+
}
|
|
30
|
+
/** One workspace timer, created only while at least one enabled definition exists. */
|
|
31
|
+
export declare class WorkspaceAutomationScheduler {
|
|
32
|
+
private readonly options;
|
|
33
|
+
private timer?;
|
|
34
|
+
private stopped;
|
|
35
|
+
private scheduleGeneration;
|
|
36
|
+
constructor(options: WorkspaceAutomationSchedulerOptions);
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
reschedule(): Promise<void>;
|
|
39
|
+
stop(): void;
|
|
40
|
+
hasTimer(): boolean;
|
|
41
|
+
private schedule;
|
|
42
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** One request chain process-wide. The promise tail also prevents a failed request from
|
|
2
|
+
* poisoning later projects. */
|
|
3
|
+
class GithubRequestArbiter {
|
|
4
|
+
tail = Promise.resolve();
|
|
5
|
+
run(operation) {
|
|
6
|
+
const current = this.tail.then(operation, operation);
|
|
7
|
+
this.tail = current.catch(() => undefined);
|
|
8
|
+
return current;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const githubRequests = new GithubRequestArbiter();
|
|
12
|
+
export class ProjectAutomationScheduler {
|
|
13
|
+
handle;
|
|
14
|
+
constructor(handle) {
|
|
15
|
+
this.handle = handle;
|
|
16
|
+
}
|
|
17
|
+
async check(definition, mode = 'execute') {
|
|
18
|
+
const detectionOnly = mode === 'execute' && !this.handle.launch;
|
|
19
|
+
if (detectionOnly)
|
|
20
|
+
mode = 'preview';
|
|
21
|
+
const { store } = this.handle;
|
|
22
|
+
const lease = store.acquireLease();
|
|
23
|
+
if (!lease)
|
|
24
|
+
throw new Error('automation polling lease is held by another process');
|
|
25
|
+
const started = Date.now();
|
|
26
|
+
try {
|
|
27
|
+
const state = store.state(definition.id) ?? {};
|
|
28
|
+
if (state.backoffUntil && Date.parse(state.backoffUntil) > Date.now()) {
|
|
29
|
+
throw new Error(`automation is backed off until ${state.backoffUntil}`);
|
|
30
|
+
}
|
|
31
|
+
const result = await githubRequests.run(() => this.handle.poller.poll(this.handle.owner, this.handle.repo, definition));
|
|
32
|
+
const eligible = result.candidates.filter((candidate) => {
|
|
33
|
+
if (state.baselineAt && candidate.timestamp <= state.baselineAt)
|
|
34
|
+
return false;
|
|
35
|
+
if (!state.cursor)
|
|
36
|
+
return true;
|
|
37
|
+
const overlap = Date.parse(state.cursor.timestamp) - 120_000;
|
|
38
|
+
return Date.parse(candidate.timestamp) >= overlap;
|
|
39
|
+
});
|
|
40
|
+
if (mode === 'execute' && this.handle.launch) {
|
|
41
|
+
for (const candidate of eligible)
|
|
42
|
+
await this.launch(definition, candidate);
|
|
43
|
+
}
|
|
44
|
+
if (mode === 'execute') {
|
|
45
|
+
const last = eligible.at(-1);
|
|
46
|
+
const now = new Date().toISOString();
|
|
47
|
+
store.setState(definition.id, {
|
|
48
|
+
...state,
|
|
49
|
+
revision: definition.revision,
|
|
50
|
+
cursor: last ? { timestamp: last.timestamp, tieBreaker: last.tieBreaker } : state.cursor,
|
|
51
|
+
frozenHighWatermark: result.truncated && last ? { timestamp: last.timestamp, tieBreaker: last.tieBreaker } : undefined,
|
|
52
|
+
lastSuccessAt: now,
|
|
53
|
+
nextCheckAt: new Date(Date.now() + definition.intervalSeconds * 1_000).toISOString(),
|
|
54
|
+
consecutiveFailures: 0,
|
|
55
|
+
backoffUntil: undefined,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else if (detectionOnly) {
|
|
59
|
+
store.setState(definition.id, {
|
|
60
|
+
...state,
|
|
61
|
+
revision: definition.revision,
|
|
62
|
+
nextCheckAt: new Date(Date.now() + definition.intervalSeconds * 1_000).toISOString(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
this.handle.onChange?.(definition.id, definition.revision);
|
|
66
|
+
return { ...result, candidates: eligible };
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (mode === 'execute')
|
|
70
|
+
this.recordFailure(definition, error);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
store.appendLog({ automationId: definition.id, revision: definition.revision, result: 'no-match', reason: mode === 'preview' ? 'Bounded preview completed without launching tasks.' : 'Scheduled check completed.', durationMs: Date.now() - started });
|
|
75
|
+
try {
|
|
76
|
+
store.maybeCompact();
|
|
77
|
+
}
|
|
78
|
+
catch { /* append-only state remains readable; next check retries */ }
|
|
79
|
+
lease.release();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async launch(definition, candidate) {
|
|
83
|
+
const receipt = this.handle.store.reserveReceipt({ automationId: definition.id, revision: definition.revision, eventId: candidate.eventId, candidate });
|
|
84
|
+
if (!receipt) {
|
|
85
|
+
this.handle.store.appendLog({ automationId: definition.id, revision: definition.revision, event: candidate.event, result: 'duplicate', reason: 'A durable receipt already exists for this automation and event.', githubNumber: candidate.number, githubTitle: candidate.title, githubUrl: candidate.url });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const launched = await this.handle.launch(definition, candidate, receipt.receiptId);
|
|
90
|
+
this.handle.store.appendReceipt({ ...receipt, status: 'launched', runId: launched.runId, updatedAt: new Date().toISOString() });
|
|
91
|
+
this.handle.store.appendLog({ automationId: definition.id, revision: definition.revision, event: candidate.event, result: 'launched', receiptId: receipt.receiptId, runId: launched.runId, githubNumber: candidate.number, githubTitle: candidate.title, githubUrl: candidate.url });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.handle.store.appendReceipt({ ...receipt, status: 'launch-error', error: error instanceof Error ? error.message : String(error), updatedAt: new Date().toISOString() });
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
recordFailure(definition, error) {
|
|
99
|
+
const state = this.handle.store.state(definition.id) ?? {};
|
|
100
|
+
const failures = (state.consecutiveFailures ?? 0) + 1;
|
|
101
|
+
const delay = Math.min(6 * 60 * 60_000, 60_000 * 2 ** (failures - 1));
|
|
102
|
+
this.handle.store.setState(definition.id, {
|
|
103
|
+
...state,
|
|
104
|
+
consecutiveFailures: failures,
|
|
105
|
+
backoffUntil: new Date(Date.now() + delay).toISOString(),
|
|
106
|
+
nextCheckAt: new Date(Date.now() + delay).toISOString(),
|
|
107
|
+
});
|
|
108
|
+
this.handle.store.appendLog({ automationId: definition.id, revision: definition.revision, result: 'error', reason: error instanceof Error ? error.message : String(error) });
|
|
109
|
+
this.handle.onChange?.(definition.id, definition.revision);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** One workspace timer, created only while at least one enabled definition exists. */
|
|
113
|
+
export class WorkspaceAutomationScheduler {
|
|
114
|
+
options;
|
|
115
|
+
timer;
|
|
116
|
+
stopped = true;
|
|
117
|
+
scheduleGeneration = 0;
|
|
118
|
+
constructor(options) {
|
|
119
|
+
this.options = options;
|
|
120
|
+
}
|
|
121
|
+
async start() {
|
|
122
|
+
this.stopped = false;
|
|
123
|
+
await this.reschedule();
|
|
124
|
+
}
|
|
125
|
+
async reschedule() {
|
|
126
|
+
if (this.stopped)
|
|
127
|
+
return;
|
|
128
|
+
const generation = ++this.scheduleGeneration;
|
|
129
|
+
if (this.timer)
|
|
130
|
+
clearTimeout(this.timer);
|
|
131
|
+
this.timer = undefined;
|
|
132
|
+
await this.options.coordinator.refresh();
|
|
133
|
+
if (this.stopped || generation !== this.scheduleGeneration)
|
|
134
|
+
return;
|
|
135
|
+
this.schedule();
|
|
136
|
+
}
|
|
137
|
+
stop() {
|
|
138
|
+
this.stopped = true;
|
|
139
|
+
this.scheduleGeneration += 1;
|
|
140
|
+
if (this.timer)
|
|
141
|
+
clearTimeout(this.timer);
|
|
142
|
+
this.timer = undefined;
|
|
143
|
+
}
|
|
144
|
+
hasTimer() { return this.timer !== undefined; }
|
|
145
|
+
schedule() {
|
|
146
|
+
if (this.stopped)
|
|
147
|
+
return;
|
|
148
|
+
const due = [];
|
|
149
|
+
for (const projectId of this.options.coordinator.enabledProjectIds()) {
|
|
150
|
+
const store = this.options.coordinator.store(projectId);
|
|
151
|
+
if (!store)
|
|
152
|
+
continue;
|
|
153
|
+
const handle = this.options.handle(projectId, store);
|
|
154
|
+
if (!handle)
|
|
155
|
+
continue;
|
|
156
|
+
for (const definition of store.list().filter((item) => item.enabled)) {
|
|
157
|
+
due.push({ at: Date.parse(store.state(definition.id)?.nextCheckAt ?? new Date().toISOString()), definition, scheduler: new ProjectAutomationScheduler(handle) });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (!due.length)
|
|
161
|
+
return;
|
|
162
|
+
due.sort((a, b) => a.at - b.at);
|
|
163
|
+
const next = due[0];
|
|
164
|
+
this.timer = setTimeout(() => {
|
|
165
|
+
this.timer = undefined;
|
|
166
|
+
void next.scheduler.check(next.definition).catch(() => undefined).finally(() => this.schedule());
|
|
167
|
+
}, Math.max(0, next.at - (this.options.now?.() ?? Date.now())));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/automations/scheduler.ts"],"names":[],"mappings":"AAsBA;+BAC+B;AAC/B,MAAM,oBAAoB;IAChB,IAAI,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACnD,GAAG,CAAI,SAA2B;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AACD,MAAM,cAAc,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAElD,MAAM,OAAO,0BAA0B;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