@herjarsa/omo-meta-governor 0.24.4 → 0.24.7

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.
@@ -0,0 +1,71 @@
1
+ /**
2
+ * CI Monitor — v0.25.0
3
+ *
4
+ * Auto-triggers GitHub Actions workflow on `git push` and surfaces failures
5
+ * to the agent so it can fix issues without waiting for local test runs.
6
+ *
7
+ * Why this exists: local `bun test` takes ~3 min (e2e + sqlite integration
8
+ * tests). The user prefers to push and have the plugin monitor CI in the
9
+ * cloud, then inject failure context if CI breaks. This is faster than local
10
+ * runs because CI runs all 3 OS jobs (linux/macos/windows) in parallel.
11
+ *
12
+ * Architecture:
13
+ * - On `tool.execute.after` (after `bash` with `git push`), spawn a fire-and-
14
+ * forget async IIFE that:
15
+ * 1. Calls `gh workflow run <workflow> --ref <branch>` via gh CLI
16
+ * 2. Polls `gh run list --limit 1 --json databaseId,status,conclusion` every
17
+ * `pollIntervalMs` up to `maxWaitMs`
18
+ * 3. On failure, stores result in `sessionState.ciFailure` and emits a
19
+ * `session.prompt` via `persistSessionMessage()` surfacing the failure
20
+ * to the agent
21
+ * - Auth: gh CLI auto-picks up `$GH_TOKEN` env var (or `~/.config/gh/` auth).
22
+ *
23
+ * Config (in meta_governor block):
24
+ * ciMonitor.enabled: boolean (default true)
25
+ * ciMonitor.workflow: string (default "CI")
26
+ * ciMonitor.pollIntervalMs: number (default 15000)
27
+ * ciMonitor.maxWaitMs: number (default 600000 = 10 min)
28
+ * ciMonitor.failOnly: boolean (default true) — only inject if CI failed
29
+ */
30
+ export interface CIMonitorConfig {
31
+ enabled: boolean;
32
+ workflow: string;
33
+ pollIntervalMs: number;
34
+ maxWaitMs: number;
35
+ failOnly: boolean;
36
+ }
37
+ export declare const DEFAULT_CI_MONITOR_CONFIG: CIMonitorConfig;
38
+ export interface CIRunStatus {
39
+ databaseId: number;
40
+ status: "queued" | "in_progress" | "completed" | "waiting" | "requested";
41
+ conclusion: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required" | null;
42
+ displayTitle: string;
43
+ url: string;
44
+ headSha: string;
45
+ }
46
+ /**
47
+ * Get the latest run for the given SHA. Returns null if no run exists yet
48
+ * (workflow may have been queued — poll again after a short delay).
49
+ */
50
+ export declare function getLatestRunForSha(sha: string): CIRunStatus | null;
51
+ /**
52
+ * Poll the given run ID until it completes or the timeout elapses.
53
+ * Returns the final status, or a synthetic "timed_out" run when the deadline
54
+ * is hit (caller decides whether to surface this as a CI failure).
55
+ */
56
+ export declare function pollRunUntilComplete(databaseId: number, config: CIMonitorConfig): CIRunStatus | null;
57
+ /**
58
+ * Trigger a workflow_dispatch event for the current branch. Returns the run
59
+ * ID or null on failure. Does NOT wait — caller should poll separately.
60
+ *
61
+ * Note: `gh workflow run` requires either an existing .github/workflows/*.yml
62
+ * with `workflow_dispatch` trigger, OR a push event that already started.
63
+ * For repo's where CI only runs on push, the run starts automatically when
64
+ * the push lands — we poll for the resulting run instead.
65
+ */
66
+ export declare function triggerWorkflow(workflow: string, branch: string): number | null;
67
+ /**
68
+ * Pull the failed-job logs (truncated) for injection. Uses `gh run view
69
+ * --log-failed` which already excludes passing steps.
70
+ */
71
+ export declare function getFailedLogs(databaseId: number, maxChars?: number): string;