@gaia-ai/core 0.5.5 → 0.6.1

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.
Files changed (53) hide show
  1. package/README.md +2 -2
  2. package/dist/src/cli/commands.d.ts +27 -0
  3. package/dist/src/cli/gaia-dir.d.ts +51 -0
  4. package/dist/src/cli/gaia-dir.js +152 -0
  5. package/dist/src/cli/load-gaia-config.d.ts +25 -0
  6. package/dist/src/cli/load-gaia-config.js +117 -0
  7. package/dist/src/cli/machine-context.d.ts +24 -0
  8. package/dist/src/cli/machine-context.js +45 -0
  9. package/dist/src/cli/paths.d.ts +11 -0
  10. package/dist/src/cli/paths.js +31 -0
  11. package/dist/src/cli/resolve-module.d.ts +6 -0
  12. package/dist/src/cli/resolve-module.js +24 -0
  13. package/dist/src/conductor-registry/index.d.ts +23 -0
  14. package/dist/src/conductor-registry/index.js +59 -0
  15. package/dist/src/core/exec.d.ts +1 -1
  16. package/dist/src/core/exec.js +1 -1
  17. package/dist/src/index.d.ts +11 -8
  18. package/dist/src/index.js +23 -3
  19. package/dist/src/plugins/discover-addons.d.ts +33 -0
  20. package/dist/src/plugins/discover-addons.js +238 -0
  21. package/dist/src/plugins/preset.d.ts +94 -0
  22. package/dist/src/plugins/preset.js +52 -0
  23. package/dist/src/workflow/step-contract.d.ts +119 -0
  24. package/dist/src/workflow/step-contract.js +430 -0
  25. package/package.json +11 -6
  26. package/dist/src/plugins/agent/agent.d.ts +0 -61
  27. package/dist/src/plugins/agent/agent.js +0 -11
  28. package/dist/src/plugins/auth/basic.d.ts +0 -11
  29. package/dist/src/plugins/auth/basic.js +0 -35
  30. package/dist/src/plugins/executor/executor.d.ts +0 -104
  31. package/dist/src/plugins/plugins.d.ts +0 -60
  32. package/dist/src/plugins/plugins.js +0 -42
  33. package/dist/src/plugins/registry-exports.d.ts +0 -6
  34. package/dist/src/plugins/registry-exports.js +0 -6
  35. package/dist/src/plugins/remote/drupal.d.ts +0 -35
  36. package/dist/src/plugins/remote/drupal.js +0 -369
  37. package/dist/src/plugins/remote/fake.d.ts +0 -109
  38. package/dist/src/plugins/remote/fake.js +0 -243
  39. package/dist/src/plugins/remote/remote.d.ts +0 -193
  40. package/dist/src/plugins/remote/remote.js +0 -1
  41. package/dist/src/plugins/workspace/fake.d.ts +0 -6
  42. package/dist/src/plugins/workspace/fake.js +0 -16
  43. package/dist/src/plugins/workspace/git.d.ts +0 -37
  44. package/dist/src/plugins/workspace/git.js +0 -89
  45. package/dist/src/plugins/workspace/instructions.d.ts +0 -6
  46. package/dist/src/plugins/workspace/instructions.js +0 -16
  47. package/dist/src/plugins/workspace/workspace.d.ts +0 -35
  48. package/dist/src/plugins/workspace/workspace.js +0 -1
  49. package/dist/src/plugins-index.d.ts +0 -1
  50. package/dist/src/plugins-index.js +0 -1
  51. package/dist/src/types.d.ts +0 -52
  52. package/dist/src/types.js +0 -1
  53. /package/dist/src/{plugins/executor/executor.js → cli/commands.js} +0 -0
@@ -1,109 +0,0 @@
1
- import type { RemotePlugin } from '../plugins.js';
2
- import type { ActiveRun, ClaimedRun, ClaimOptions, ConductorRegistration, ConductorStatus, FinalizableRun, GaiaRemote, RunMetrics, RunWriteAttributes, Ticket, UncleanTicket } from './remote.js';
3
- export interface FakeSeedRun {
4
- runUuid: string;
5
- /** Numeric (drupal_internal__id) run id. Defaults to a stable 1-based counter when omitted. */
6
- id?: number;
7
- ticketUuid: string;
8
- stateAtStart: string;
9
- /** Override the initial state (defaults to stateAtStart). */
10
- state?: string;
11
- handler?: string;
12
- worktreePath?: string;
13
- closed?: boolean;
14
- /** Id of the agent that ran (GAIA-144) — routes footprint parsing at finalize. */
15
- agent?: string;
16
- }
17
- export interface FakeSeedTicket {
18
- identifier: string;
19
- title: string;
20
- state: string;
21
- branchName?: string;
22
- /** Computed base branch (parent branch / project default / 'main'). */
23
- baseBranch?: string;
24
- /** Effective env vars (parent-chain resolved) as `.env`-style lines. */
25
- effectiveEnvVars?: string;
26
- url?: string;
27
- workflow?: string;
28
- /** Label term names sideloaded for agent selection (GAIA-144). */
29
- labels?: string[];
30
- /** Environments sideloaded for agent selection (GAIA-144). */
31
- environments?: {
32
- name: string;
33
- tier: string;
34
- }[];
35
- /** Whether the ticket is already closed (its lifecycle wound up). */
36
- closed?: boolean;
37
- /** Whether the ticket's worktree is already torn down (cleaned_up flag). */
38
- cleanedUp?: boolean;
39
- /**
40
- * machine_id of the conductor this ticket is assigned to (GAIA-121). Omit to
41
- * mean "belongs to the querying conductor" (the common case for reaper tests);
42
- * set an explicit value to test conductor-scoping, or `''` for unassigned.
43
- */
44
- conductorId?: string;
45
- }
46
- export interface FakeRemoteSeed {
47
- runs?: FakeSeedRun[];
48
- tickets?: Record<string, FakeSeedTicket>;
49
- }
50
- export interface MarkRunningCall {
51
- runUuid: string;
52
- attrs?: {
53
- worktree_path?: string;
54
- agent?: string;
55
- };
56
- }
57
- export interface FinalizeRunCall {
58
- runUuid: string;
59
- log: string;
60
- metrics?: RunMetrics;
61
- }
62
- export interface MarkFailedCall {
63
- runUuid: string;
64
- errorLog: string;
65
- }
66
- export declare class FakeGaiaRemote implements GaiaRemote {
67
- readonly calls: {
68
- markRunning: MarkRunningCall[];
69
- markFailed: MarkFailedCall[];
70
- finalizeRun: FinalizeRunCall[];
71
- closeTicket: string[];
72
- markCleanedUp: string[];
73
- };
74
- /**
75
- * Override for reconcile tests: when set, `fetchActiveRuns` returns this
76
- * list verbatim instead of deriving it from the internal runs map.
77
- */
78
- activeRuns: ActiveRun[] | null;
79
- private readonly runs;
80
- private readonly queue;
81
- private readonly tickets;
82
- private conductorStatus;
83
- /** Stable counter for assigning numeric ids to unseeded runs. */
84
- private runIdCounter;
85
- constructor(seed?: FakeRemoteSeed);
86
- registerConductor(_reg: ConductorRegistration): Promise<string>;
87
- heartbeat(): Promise<string>;
88
- getConductorStatus(_conductorId: string): Promise<string | null>;
89
- setConductorStatus(_conductorId: string, status: 'offline' | 'online'): Promise<void>;
90
- listConductors(_owner?: 'me'): Promise<ConductorStatus[]>;
91
- activeRunCount(_conductorId: string): Promise<number>;
92
- fetchActiveRuns(_conductorId: string): Promise<ActiveRun[]>;
93
- claimNext(_claim: ClaimOptions): Promise<ClaimedRun | null>;
94
- getTicket(ticketUuid: string): Promise<Ticket>;
95
- getRunWorktree(runUuid: string): Promise<string>;
96
- getRunTicketIdentifier(runUuid: string): Promise<string>;
97
- getRunTicketBranchName(runUuid: string): Promise<string>;
98
- markRunning(runUuid: string, attrs?: RunWriteAttributes): Promise<void>;
99
- markFailed(runUuid: string, errorLog: string): Promise<void>;
100
- fetchFinalizableRuns(_conductorId: string): Promise<FinalizableRun[]>;
101
- finalizeRun(runUuid: string, log: string, metrics?: RunMetrics): Promise<void>;
102
- fetchUncleanedTickets(conductorId: string): Promise<UncleanTicket[]>;
103
- closeTicket(uuid: string): Promise<void>;
104
- markTicketCleanedUp(uuid: string): Promise<void>;
105
- /** Worktree path of the ticket's most recently seeded run, or '' when none. */
106
- private latestRunWorktree;
107
- private internalActiveRuns;
108
- }
109
- export declare function fakeRemote(seed?: FakeRemoteSeed): RemotePlugin;
@@ -1,243 +0,0 @@
1
- const ACTIVE = ['claimed', 'running'];
2
- export class FakeGaiaRemote {
3
- calls = {
4
- markRunning: [],
5
- markFailed: [],
6
- finalizeRun: [],
7
- closeTicket: [],
8
- markCleanedUp: [],
9
- };
10
- /**
11
- * Override for reconcile tests: when set, `fetchActiveRuns` returns this
12
- * list verbatim instead of deriving it from the internal runs map.
13
- */
14
- activeRuns = null;
15
- runs = new Map();
16
- queue = [];
17
- tickets;
18
- conductorStatus = 'online';
19
- /** Stable counter for assigning numeric ids to unseeded runs. */
20
- runIdCounter = 0;
21
- constructor(seed = {}) {
22
- this.tickets = seed.tickets ?? {};
23
- for (const r of seed.runs ?? []) {
24
- const handler = r.handler ?? 'code';
25
- // Use the seeded id when provided; otherwise assign a deterministic counter.
26
- const runId = r.id ?? ++this.runIdCounter;
27
- this.runs.set(r.runUuid, {
28
- runUuid: r.runUuid,
29
- runId,
30
- ticketUuid: r.ticketUuid,
31
- handler,
32
- state: r.state ?? r.stateAtStart,
33
- stateAtStart: r.stateAtStart,
34
- ...(r.worktreePath !== undefined
35
- ? { worktreePath: r.worktreePath }
36
- : {}),
37
- ...(r.agent !== undefined ? { agent: r.agent } : {}),
38
- ...(r.closed !== undefined ? { closed: r.closed } : {}),
39
- });
40
- this.queue.push({
41
- runUuid: r.runUuid,
42
- runId,
43
- ticketUuid: r.ticketUuid,
44
- stateAtStart: r.stateAtStart,
45
- handler,
46
- });
47
- }
48
- }
49
- async registerConductor(_reg) {
50
- this.conductorStatus = 'online';
51
- return 'fake-conductor-uuid';
52
- }
53
- async heartbeat() {
54
- // Mirrors the server: a heartbeat always brings the conductor online.
55
- this.conductorStatus = 'online';
56
- return this.conductorStatus;
57
- }
58
- async getConductorStatus(_conductorId) {
59
- return this.conductorStatus;
60
- }
61
- async setConductorStatus(_conductorId, status) {
62
- this.conductorStatus = status;
63
- }
64
- async listConductors(_owner) {
65
- return [];
66
- }
67
- async activeRunCount(_conductorId) {
68
- return this.internalActiveRuns().length;
69
- }
70
- async fetchActiveRuns(_conductorId) {
71
- if (this.activeRuns !== null) {
72
- return this.activeRuns;
73
- }
74
- return this.internalActiveRuns().map((r) => {
75
- const ticket = this.tickets[r.ticketUuid];
76
- const identifier = ticket?.identifier ?? '';
77
- const branchName = ticket?.branchName ??
78
- (identifier ? `gaia/${identifier.toLowerCase()}` : '');
79
- return {
80
- runUuid: r.runUuid,
81
- ticketUuid: r.ticketUuid,
82
- ticketIdentifier: identifier,
83
- branchName,
84
- state: r.state,
85
- stateAtStart: r.stateAtStart,
86
- worktreePath: r.worktreePath ?? '',
87
- };
88
- });
89
- }
90
- async claimNext(_claim) {
91
- return this.queue.shift() ?? null;
92
- }
93
- async getTicket(ticketUuid) {
94
- const t = this.tickets[ticketUuid];
95
- if (!t) {
96
- throw new Error(`fake remote: ticket ${ticketUuid} not seeded`);
97
- }
98
- const branchName = t.branchName ?? `gaia/${t.identifier.toLowerCase()}`;
99
- return {
100
- uuid: ticketUuid,
101
- identifier: t.identifier,
102
- title: t.title,
103
- state: t.state,
104
- branchName,
105
- ...(t.baseBranch ? { baseBranch: t.baseBranch } : {}),
106
- ...(t.effectiveEnvVars ? { effectiveEnvVars: t.effectiveEnvVars } : {}),
107
- ...(t.url ? { issueUrl: t.url } : {}),
108
- labels: t.labels ?? [],
109
- environments: t.environments ?? [],
110
- };
111
- }
112
- async getRunWorktree(runUuid) {
113
- return this.runs.get(runUuid)?.worktreePath ?? '';
114
- }
115
- async getRunTicketIdentifier(runUuid) {
116
- const ticketUuid = this.runs.get(runUuid)?.ticketUuid;
117
- if (!ticketUuid) {
118
- return '';
119
- }
120
- return this.tickets[ticketUuid]?.identifier ?? '';
121
- }
122
- async getRunTicketBranchName(runUuid) {
123
- const ticketUuid = this.runs.get(runUuid)?.ticketUuid;
124
- if (!ticketUuid) {
125
- return '';
126
- }
127
- const ticket = this.tickets[ticketUuid];
128
- if (!ticket) {
129
- return '';
130
- }
131
- return ticket.branchName ?? `gaia/${ticket.identifier.toLowerCase()}`;
132
- }
133
- async markRunning(runUuid, attrs) {
134
- this.calls.markRunning.push({
135
- runUuid,
136
- ...(attrs
137
- ? {
138
- attrs: {
139
- ...(attrs.worktree_path
140
- ? { worktree_path: attrs.worktree_path }
141
- : {}),
142
- ...(attrs.agent ? { agent: attrs.agent } : {}),
143
- },
144
- }
145
- : {}),
146
- });
147
- const run = this.runs.get(runUuid);
148
- if (run) {
149
- run.state = 'running';
150
- if (attrs?.worktree_path) {
151
- run.worktreePath = attrs.worktree_path;
152
- }
153
- if (attrs?.agent) {
154
- run.agent = attrs.agent;
155
- }
156
- }
157
- }
158
- async markFailed(runUuid, errorLog) {
159
- this.calls.markFailed.push({ runUuid, errorLog });
160
- const run = this.runs.get(runUuid);
161
- if (run) {
162
- run.state = 'failed';
163
- run.closed = true;
164
- }
165
- }
166
- async fetchFinalizableRuns(_conductorId) {
167
- return [...this.runs.values()]
168
- .filter((r) => r.state === 'done' && !r.closed)
169
- .map((r) => ({
170
- runUuid: r.runUuid,
171
- runId: r.runId,
172
- worktreePath: r.worktreePath ?? '',
173
- agent: r.agent ?? '',
174
- }));
175
- }
176
- async finalizeRun(runUuid, log, metrics) {
177
- this.calls.finalizeRun.push({
178
- runUuid,
179
- log,
180
- ...(metrics ? { metrics } : {}),
181
- });
182
- const run = this.runs.get(runUuid);
183
- if (run) {
184
- run.closed = true;
185
- if (log)
186
- run.log = log;
187
- }
188
- }
189
- async fetchUncleanedTickets(conductorId) {
190
- // Scoped to the querying conductor (GAIA-121). A seed without an explicit
191
- // `conductorId` defaults to the querying conductor (the common reaper-test
192
- // case); an explicit value scopes it, and `''` models an unassigned ticket.
193
- return Object.entries(this.tickets)
194
- .filter(([, t]) => (t.state === 'done' || t.closed) &&
195
- !t.cleanedUp &&
196
- (t.conductorId ?? conductorId) === conductorId)
197
- .map(([ticketUuid, t]) => ({
198
- ticketUuid,
199
- branchName: t.branchName ?? `gaia/${t.identifier.toLowerCase()}`,
200
- worktreePath: this.latestRunWorktree(ticketUuid),
201
- state: t.state,
202
- closed: t.closed ?? false,
203
- }));
204
- }
205
- async closeTicket(uuid) {
206
- this.calls.closeTicket.push(uuid);
207
- const t = this.tickets[uuid];
208
- if (t) {
209
- t.closed = true;
210
- }
211
- }
212
- async markTicketCleanedUp(uuid) {
213
- this.calls.markCleanedUp.push(uuid);
214
- const t = this.tickets[uuid];
215
- if (t) {
216
- t.cleanedUp = true;
217
- }
218
- }
219
- /** Worktree path of the ticket's most recently seeded run, or '' when none. */
220
- latestRunWorktree(ticketUuid) {
221
- let worktree = '';
222
- for (const r of this.runs.values()) {
223
- if (r.ticketUuid === ticketUuid && r.worktreePath) {
224
- worktree = r.worktreePath;
225
- }
226
- }
227
- return worktree;
228
- }
229
- internalActiveRuns() {
230
- return [...this.runs.values()].filter((r) => ACTIVE.includes(r.state));
231
- }
232
- }
233
- export function fakeRemote(seed = {}) {
234
- const remote = new FakeGaiaRemote(seed);
235
- return {
236
- kind: 'remote',
237
- id: 'fake',
238
- requiredModules: [],
239
- async createRemote(_config) {
240
- return remote;
241
- },
242
- };
243
- }
@@ -1,193 +0,0 @@
1
- export interface ConductorRegistration {
2
- id: string;
3
- project: string;
4
- states: string[];
5
- workspace: string;
6
- label: string;
7
- max_parallel: number;
8
- }
9
- export interface ClaimOptions {
10
- leaseSeconds: number;
11
- conductorId: string;
12
- }
13
- export interface ClaimedRun {
14
- runUuid: string;
15
- runId: number;
16
- ticketUuid: string;
17
- stateAtStart: string;
18
- handler: string;
19
- }
20
- export interface Ticket {
21
- uuid: string;
22
- identifier: string;
23
- title: string;
24
- state: string;
25
- branchName: string;
26
- /** Branch the ticket's work is based on (computed server-side): parent branch, project default, or 'main'. */
27
- baseBranch?: string;
28
- /**
29
- * Effective environment variables (GAIA-99), resolved server-side along the
30
- * parent_id chain (child wins) as canonical `.env`-style `KEY=value` lines.
31
- * The conductor parses this, strips reserved keys, overlays the core GAIA_*
32
- * vars, and injects the result into the agent run env AND the workspace hooks.
33
- * Omitted when the ticket (and its ancestors) set none. Values may be secret.
34
- */
35
- effectiveEnvVars?: string;
36
- issueUrl?: string;
37
- /** Ticket label term names (gaia_labels vocab), sideloaded for agent selection. Empty when none. */
38
- labels: string[];
39
- /** Ticket environments (gaia_environment refs), each as name + tier, sideloaded for agent selection. Empty when none. */
40
- environments: {
41
- name: string;
42
- tier: string;
43
- }[];
44
- }
45
- export interface ActiveRun {
46
- runUuid: string;
47
- ticketUuid: string;
48
- ticketIdentifier: string;
49
- branchName: string;
50
- state: string;
51
- stateAtStart: string;
52
- /** Absolute path of the per-run git worktree, or '' when unset. */
53
- worktreePath: string;
54
- }
55
- export interface ConductorStatus {
56
- id: string;
57
- project: string;
58
- label: string;
59
- status: string;
60
- lastSeen: number;
61
- load: number;
62
- }
63
- export interface FinalizableRun {
64
- runUuid: string;
65
- /** Numeric run id (the `#<runId>` tab-label token); scopes the run's tab-close at finalise (GAIA-183). */
66
- runId: number;
67
- /** Absolute path of the per-run git worktree, or '' when unset. */
68
- worktreePath: string;
69
- /** Id of the agent that ran (GAIA-144); routes footprint parsing at finalize. '' / undefined when unset. */
70
- agent?: string;
71
- }
72
- /**
73
- * Per-run effort footprint the conductor writes onto `gaia_run` at close
74
- * (GAIA-132). Six integer metrics, all parsed from the agent transcript —
75
- * including `duration_s`, the run's wall-clock length derived from the
76
- * transcript's first→last timestamps (GAIA-151), not a re-read `started_at`.
77
- */
78
- export interface RunMetrics {
79
- tokens: number;
80
- duration_s: number;
81
- agent_turns: number;
82
- tool_calls: number;
83
- user_prompts: number;
84
- user_prompt_words: number;
85
- }
86
- /**
87
- * A finished ticket whose worktree has not yet been torn down — the
88
- * conductor's teardown work list, driven by the durable `cleaned_up` flag
89
- * (GAIA-89). "Finished" = reached `done` OR already `closed`; `cleaned_up=0`
90
- * means the herdr worktree still needs reclaiming. The reconciliation is NOT
91
- * scoped to a conductor's machine_id, so it also surfaces tickets whose
92
- * conductor was down at `done` or whose `conductor_id` was reassigned.
93
- */
94
- export interface UncleanTicket {
95
- ticketUuid: string;
96
- /** The ticket's git branch — the key herdr resolves the worktree by. */
97
- branchName: string;
98
- /**
99
- * Absolute path of the ticket's worktree (from its latest run's
100
- * `worktree_path`), or '' when unresolved. The cwd the teardown runs in.
101
- */
102
- worktreePath: string;
103
- /** Workflow state (e.g. `coding`, `done`). */
104
- state: string;
105
- /** Whether the ticket's lifecycle has already been closed out. */
106
- closed: boolean;
107
- }
108
- /** Extra conductor-writable gaia_run attributes (besides state/lease). */
109
- export interface RunWriteAttributes {
110
- /** Absolute path of the per-run git worktree (set by the conductor). */
111
- worktree_path?: string;
112
- /** Id of the agent the conductor chose for this run (GAIA-144), for footprint routing. */
113
- agent?: string;
114
- }
115
- export interface GaiaRemote {
116
- /** Upserts by machine_id; sets status=online. Returns the Drupal entity uuid. */
117
- registerConductor(reg: ConductorRegistration): Promise<string>;
118
- /**
119
- * Records a heartbeat server-side: upserts by machine_id (recreating a
120
- * vanished registration), refreshes last_seen/lease/load, and brings the
121
- * conductor online. Keyed on machine_id, so it never 404s — the self-heal
122
- * lives on the server, not the client. Returns the resulting status
123
- * (`online` | `offline`).
124
- */
125
- heartbeat(reg: ConductorRegistration, currentLoad: number, leaseSeconds?: number): Promise<string>;
126
- getConductorStatus(conductorId: string): Promise<string | null>;
127
- setConductorStatus(conductorId: string, status: 'offline' | 'online'): Promise<void>;
128
- listConductors(owner?: 'me'): Promise<ConductorStatus[]>;
129
- activeRunCount(conductorId: string): Promise<number>;
130
- fetchActiveRuns(conductorId: string): Promise<ActiveRun[]>;
131
- claimNext(claim: ClaimOptions): Promise<ClaimedRun | null>;
132
- getTicket(ticketUuid: string): Promise<Ticket>;
133
- /** Returns the run's worktree_path, or '' when unset. */
134
- getRunWorktree(runUuid: string): Promise<string>;
135
- /**
136
- * Returns the identifier of the run's ticket, or '' when unresolved. Lets the
137
- * release path derive the tab matching ref (the ticket identifier) from a run
138
- * uuid alone.
139
- */
140
- getRunTicketIdentifier(runUuid: string): Promise<string>;
141
- /**
142
- * Returns the branch_name of the run's ticket, or '' when unresolved. Used
143
- * by dispatch for the per-(branch,state) herdr tab model.
144
- */
145
- getRunTicketBranchName(runUuid: string): Promise<string>;
146
- markRunning(runUuid: string, attrs?: RunWriteAttributes): Promise<void>;
147
- /**
148
- * Terminalise a run to the `failed` state on a dispatch/setup error (GAIA-149).
149
- * PATCHes state=failed, records the failure detail in `error_log`, and closes
150
- * the run (closed + closed_date). `failed` is a terminal sibling of `expired`
151
- * (dispatch error vs lease lapse), so the run stops counting toward capacity
152
- * and its ticket is no longer blocked by the single-active-run gate — instead
153
- * of the old "leave it `claimed` to expire after ~300s" silent stall. The
154
- * failure is visible immediately and its cause is recorded.
155
- */
156
- markFailed(runUuid: string, errorLog: string): Promise<void>;
157
- /**
158
- * Runs this conductor owns that are state=done but not yet closed — the
159
- * conductor's one-shot finalisation work list.
160
- */
161
- fetchFinalizableRuns(conductorId: string): Promise<FinalizableRun[]>;
162
- /**
163
- * Finalise a run: set closed + closed_date, (when non-empty) log, and (when
164
- * given) the per-run footprint metrics (GAIA-132). No state change — the run
165
- * is already done.
166
- */
167
- finalizeRun(uuid: string, log: string, metrics?: RunMetrics): Promise<void>;
168
- /**
169
- * Finished tickets (state=done OR closed) whose worktree is not yet torn
170
- * down (cleaned_up=0) — the conductor's teardown work list (GAIA-89). Driven
171
- * by the durable `cleaned_up` flag AND scoped to the reaping conductor
172
- * (GAIA-121): only tickets assigned to `conductorId` are loaded, so every
173
- * ticket on the list is unambiguously this conductor's — a missing worktree
174
- * means "already torn down on this host", not "belongs to another host". The
175
- * same query backs the live tick and the standalone `gaia conductor reap`.
176
- * Empty once every finished ticket this conductor owns is cleaned.
177
- */
178
- fetchUncleanedTickets(conductorId: string): Promise<UncleanTicket[]>;
179
- /**
180
- * Close a ticket: set closed=true + closed_date. Ticket-lifecycle only, and
181
- * decoupled from teardown — a done ticket is closed even if its worktree
182
- * teardown later fails. No state change (the ticket is already done).
183
- */
184
- closeTicket(uuid: string): Promise<void>;
185
- /**
186
- * Mark a ticket's worktree torn down: set cleaned_up=true so it drops off the
187
- * {@link fetchUncleanedTickets} work list. Written ONLY after a verified
188
- * teardown, so a teardown miss leaves cleaned_up=0 and the next reconciliation
189
- * retries — one miss never orphans the workspace, and a re-run on an
190
- * already-cleaned ticket is a no-op (it is no longer on the list).
191
- */
192
- markTicketCleanedUp(uuid: string): Promise<void>;
193
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import type { WorkspacePlugin } from '../plugins.js';
2
- import type { EnsuredWorkspace, GaiaWorkspace } from './workspace.js';
3
- export declare class FakeWorkspace implements GaiaWorkspace {
4
- ensure(identifier: string, _title?: string): Promise<EnsuredWorkspace>;
5
- }
6
- export declare function fakeWorkspace(): WorkspacePlugin;
@@ -1,16 +0,0 @@
1
- export class FakeWorkspace {
2
- async ensure(identifier, _title) {
3
- return { path: `/fake/${identifier}`, instructions: null, created: true };
4
- }
5
- }
6
- export function fakeWorkspace() {
7
- const workspace = new FakeWorkspace();
8
- return {
9
- kind: 'workspace',
10
- id: 'fake',
11
- requiredModules: [],
12
- async createWorkspace(_config) {
13
- return workspace;
14
- },
15
- };
16
- }
@@ -1,37 +0,0 @@
1
- import type { WorkspacePlugin } from '../plugins.js';
2
- import type { EnsuredWorkspace, GaiaWorkspace } from './workspace.js';
3
- /** Default branch template: `<prefix><key>-<title-slug>` (readable). */
4
- export declare const DEFAULT_BRANCH_TEMPLATE = "{branchPrefix}{key}-{titleSlug}";
5
- export type GitRunner = (args: string[], cwd: string) => Promise<void>;
6
- export interface GitWorkspaceOptions {
7
- /** Main clone (a git repo): config source + worktree base. */
8
- root: string;
9
- /** Where per-ticket worktrees live. Default: `${root}-worktrees`. */
10
- worktreesRoot?: string;
11
- /** Branch name prefix per ticket. Default: 'gaia/'. */
12
- branchPrefix?: string;
13
- /**
14
- * Branch name template. Vars: {branchPrefix}, {key} (sanitized identifier),
15
- * {identifier}, {titleSlug}. Default: `{branchPrefix}{key}-{titleSlug}`.
16
- */
17
- branchTemplate?: string;
18
- runGit?: GitRunner;
19
- }
20
- export declare class GitWorkspace implements GaiaWorkspace {
21
- private readonly runGit;
22
- private readonly root;
23
- private readonly worktreesRoot;
24
- private readonly branchPrefix;
25
- private readonly branchTemplate;
26
- constructor(options: GitWorkspaceOptions);
27
- /** Render the branch name for a ticket from the configured template. */
28
- branchFor(identifier: string, title?: string): string;
29
- keyFor(identifier: string): string;
30
- private pathFor;
31
- ensure(identifier: string, title?: string, _baseRef?: string): Promise<EnsuredWorkspace>;
32
- remove(identifier: string): Promise<void>;
33
- }
34
- export declare function gitWorkspace(opts?: {
35
- branchPrefix?: string;
36
- branchTemplate?: string;
37
- }): WorkspacePlugin;