@gaia-ai/gaia 0.2.0 → 0.4.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.
Files changed (52) hide show
  1. package/bin/gaia +1 -1
  2. package/dist/src/plugins-barrel.d.ts +1 -0
  3. package/dist/src/plugins-barrel.js +1 -0
  4. package/package.json +10 -16
  5. package/dist/src/cli/gaia.d.ts +0 -24
  6. package/dist/src/cli/gaia.js +0 -572
  7. package/dist/src/cli/init.d.ts +0 -74
  8. package/dist/src/cli/init.js +0 -220
  9. package/dist/src/cli/local-registry.d.ts +0 -14
  10. package/dist/src/cli/local-registry.js +0 -56
  11. package/dist/src/config.d.ts +0 -13
  12. package/dist/src/config.js +0 -186
  13. package/dist/src/core/conductor-id.d.ts +0 -1
  14. package/dist/src/core/conductor-id.js +0 -8
  15. package/dist/src/core/conductor.d.ts +0 -47
  16. package/dist/src/core/conductor.js +0 -287
  17. package/dist/src/core/exec.d.ts +0 -33
  18. package/dist/src/core/exec.js +0 -65
  19. package/dist/src/core/logger.d.ts +0 -31
  20. package/dist/src/core/logger.js +0 -36
  21. package/dist/src/core/slug.d.ts +0 -9
  22. package/dist/src/core/slug.js +0 -18
  23. package/dist/src/index.d.ts +0 -16
  24. package/dist/src/index.js +0 -9
  25. package/dist/src/plugin-api.d.ts +0 -7
  26. package/dist/src/plugin-api.js +0 -3
  27. package/dist/src/plugins/agent/agent.d.ts +0 -20
  28. package/dist/src/plugins/agent/agent.js +0 -1
  29. package/dist/src/plugins/auth/basic.d.ts +0 -11
  30. package/dist/src/plugins/auth/basic.js +0 -35
  31. package/dist/src/plugins/executor/executor.d.ts +0 -61
  32. package/dist/src/plugins/executor/executor.js +0 -1
  33. package/dist/src/plugins/plugins.d.ts +0 -38
  34. package/dist/src/plugins/plugins.js +0 -16
  35. package/dist/src/plugins/registry-exports.d.ts +0 -6
  36. package/dist/src/plugins/registry-exports.js +0 -6
  37. package/dist/src/plugins/remote/drupal.d.ts +0 -47
  38. package/dist/src/plugins/remote/drupal.js +0 -337
  39. package/dist/src/plugins/remote/fake.d.ts +0 -81
  40. package/dist/src/plugins/remote/fake.js +0 -203
  41. package/dist/src/plugins/remote/remote.d.ts +0 -143
  42. package/dist/src/plugins/remote/remote.js +0 -1
  43. package/dist/src/plugins/workspace/fake.d.ts +0 -9
  44. package/dist/src/plugins/workspace/fake.js +0 -19
  45. package/dist/src/plugins/workspace/git.d.ts +0 -53
  46. package/dist/src/plugins/workspace/git.js +0 -113
  47. package/dist/src/plugins/workspace/instructions.d.ts +0 -6
  48. package/dist/src/plugins/workspace/instructions.js +0 -16
  49. package/dist/src/plugins/workspace/workspace.d.ts +0 -33
  50. package/dist/src/plugins/workspace/workspace.js +0 -1
  51. package/dist/src/types.d.ts +0 -51
  52. package/dist/src/types.js +0 -1
@@ -1,203 +0,0 @@
1
- const ACTIVE = ['claimed', 'running'];
2
- export class FakeGaiaRemote {
3
- calls = {
4
- markRunning: [],
5
- finalizeRun: [],
6
- closeTicket: [],
7
- };
8
- /**
9
- * Override for reconcile tests: when set, `fetchActiveRuns` returns this
10
- * list verbatim instead of deriving it from the internal runs map.
11
- */
12
- activeRuns = null;
13
- runs = new Map();
14
- queue = [];
15
- tickets;
16
- conductorStatus = 'online';
17
- /** Stable counter for assigning numeric ids to unseeded runs. */
18
- runIdCounter = 0;
19
- constructor(seed = {}) {
20
- this.tickets = seed.tickets ?? {};
21
- for (const r of seed.runs ?? []) {
22
- const handler = r.handler ?? 'code';
23
- // Use the seeded id when provided; otherwise assign a deterministic counter.
24
- const runId = r.id ?? ++this.runIdCounter;
25
- this.runs.set(r.runUuid, {
26
- runUuid: r.runUuid,
27
- runId,
28
- ticketUuid: r.ticketUuid,
29
- handler,
30
- state: r.state ?? r.stateAtStart,
31
- stateAtStart: r.stateAtStart,
32
- ...(r.worktreePath !== undefined
33
- ? { worktreePath: r.worktreePath }
34
- : {}),
35
- ...(r.closed !== undefined ? { closed: r.closed } : {}),
36
- });
37
- this.queue.push({
38
- runUuid: r.runUuid,
39
- runId,
40
- ticketUuid: r.ticketUuid,
41
- stateAtStart: r.stateAtStart,
42
- handler,
43
- });
44
- }
45
- }
46
- async registerConductor(_reg) {
47
- this.conductorStatus = 'online';
48
- return 'fake-conductor-uuid';
49
- }
50
- async heartbeat() {
51
- // Mirrors the server: a heartbeat always brings the conductor online.
52
- this.conductorStatus = 'online';
53
- return this.conductorStatus;
54
- }
55
- async getConductorStatus(_conductorId) {
56
- return this.conductorStatus;
57
- }
58
- async setConductorStatus(_conductorId, status) {
59
- this.conductorStatus = status;
60
- }
61
- async listConductors(_owner) {
62
- return [];
63
- }
64
- async activeRunCount(_conductorId) {
65
- return this.internalActiveRuns().length;
66
- }
67
- async fetchActiveRuns(_conductorId) {
68
- if (this.activeRuns !== null) {
69
- return this.activeRuns;
70
- }
71
- return this.internalActiveRuns().map((r) => {
72
- const ticket = this.tickets[r.ticketUuid];
73
- const identifier = ticket?.identifier ?? '';
74
- const branchName = ticket?.branchName ??
75
- (identifier ? `gaia/${identifier.toLowerCase()}` : '');
76
- return {
77
- runUuid: r.runUuid,
78
- ticketUuid: r.ticketUuid,
79
- ticketIdentifier: identifier,
80
- branchName,
81
- state: r.state,
82
- stateAtStart: r.stateAtStart,
83
- worktreePath: r.worktreePath ?? '',
84
- };
85
- });
86
- }
87
- async claimNext(_claim) {
88
- return this.queue.shift() ?? null;
89
- }
90
- async getTicket(ticketUuid) {
91
- const t = this.tickets[ticketUuid];
92
- if (!t) {
93
- throw new Error(`fake remote: ticket ${ticketUuid} not seeded`);
94
- }
95
- const branchName = t.branchName ?? `gaia/${t.identifier.toLowerCase()}`;
96
- return {
97
- uuid: ticketUuid,
98
- identifier: t.identifier,
99
- title: t.title,
100
- state: t.state,
101
- branchName,
102
- ...(t.baseBranch ? { baseBranch: t.baseBranch } : {}),
103
- comments: t.comments ?? [],
104
- ...(t.url ? { issueUrl: t.url } : {}),
105
- };
106
- }
107
- async getRunWorktree(runUuid) {
108
- return this.runs.get(runUuid)?.worktreePath ?? '';
109
- }
110
- async getRunTicketIdentifier(runUuid) {
111
- const ticketUuid = this.runs.get(runUuid)?.ticketUuid;
112
- if (!ticketUuid) {
113
- return '';
114
- }
115
- return this.tickets[ticketUuid]?.identifier ?? '';
116
- }
117
- async getRunTicketBranchName(runUuid) {
118
- const ticketUuid = this.runs.get(runUuid)?.ticketUuid;
119
- if (!ticketUuid) {
120
- return '';
121
- }
122
- const ticket = this.tickets[ticketUuid];
123
- if (!ticket) {
124
- return '';
125
- }
126
- return ticket.branchName ?? `gaia/${ticket.identifier.toLowerCase()}`;
127
- }
128
- async markRunning(runUuid, attrs) {
129
- this.calls.markRunning.push({
130
- runUuid,
131
- ...(attrs
132
- ? {
133
- attrs: {
134
- ...(attrs.worktree_path
135
- ? { worktree_path: attrs.worktree_path }
136
- : {}),
137
- },
138
- }
139
- : {}),
140
- });
141
- const run = this.runs.get(runUuid);
142
- if (run) {
143
- run.state = 'running';
144
- if (attrs?.worktree_path) {
145
- run.worktreePath = attrs.worktree_path;
146
- }
147
- }
148
- }
149
- async fetchFinalizableRuns(_conductorId) {
150
- return [...this.runs.values()]
151
- .filter((r) => r.state === 'done' && !r.closed)
152
- .map((r) => ({ runUuid: r.runUuid, worktreePath: r.worktreePath ?? '' }));
153
- }
154
- async finalizeRun(runUuid, log) {
155
- this.calls.finalizeRun.push({ runUuid, log });
156
- const run = this.runs.get(runUuid);
157
- if (run) {
158
- run.closed = true;
159
- if (log)
160
- run.log = log;
161
- }
162
- }
163
- async fetchFinalizableTickets(_conductorId) {
164
- return Object.entries(this.tickets)
165
- .filter(([, t]) => t.state === 'done' && !t.closed)
166
- .map(([ticketUuid, t]) => ({
167
- ticketUuid,
168
- branchName: t.branchName ?? `gaia/${t.identifier.toLowerCase()}`,
169
- worktreePath: this.latestRunWorktree(ticketUuid),
170
- }));
171
- }
172
- async closeTicket(uuid) {
173
- this.calls.closeTicket.push(uuid);
174
- const t = this.tickets[uuid];
175
- if (t) {
176
- t.closed = true;
177
- }
178
- }
179
- /** Worktree path of the ticket's most recently seeded run, or '' when none. */
180
- latestRunWorktree(ticketUuid) {
181
- let worktree = '';
182
- for (const r of this.runs.values()) {
183
- if (r.ticketUuid === ticketUuid && r.worktreePath) {
184
- worktree = r.worktreePath;
185
- }
186
- }
187
- return worktree;
188
- }
189
- internalActiveRuns() {
190
- return [...this.runs.values()].filter((r) => ACTIVE.includes(r.state));
191
- }
192
- }
193
- export function fakeRemote(seed = {}) {
194
- const remote = new FakeGaiaRemote(seed);
195
- return {
196
- kind: 'remote',
197
- id: 'fake',
198
- requiredModules: [],
199
- async createRemote(_config) {
200
- return remote;
201
- },
202
- };
203
- }
@@ -1,143 +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
- /** A ticket comment, as the conductor injects it into the dispatch prompt. */
21
- export interface TicketComment {
22
- /** comment | spec | plan | debug_diagnose | summary | acceptance | test */
23
- type: string;
24
- /** Raw body (gaia_rich HTML). */
25
- body: string;
26
- /** ISO 8601 creation timestamp. */
27
- created: string;
28
- }
29
- export interface Ticket {
30
- uuid: string;
31
- identifier: string;
32
- title: string;
33
- state: string;
34
- branchName: string;
35
- /** Branch the ticket's work is based on (computed server-side): parent branch, project default, or 'main'. */
36
- baseBranch?: string;
37
- issueUrl?: string;
38
- /**
39
- * Comments on the ticket, oldest first. The conductor renders these into the
40
- * dispatch prompt so a review→coding bounce carries the review summary to the
41
- * coder. Empty when the ticket has none — or when the session role lacks
42
- * `view gaia_comment` (the include degrades to an empty set, never an error).
43
- */
44
- comments: TicketComment[];
45
- }
46
- export interface ActiveRun {
47
- runUuid: string;
48
- ticketUuid: string;
49
- ticketIdentifier: string;
50
- branchName: string;
51
- state: string;
52
- stateAtStart: string;
53
- /** Absolute path of the per-run git worktree, or '' when unset. */
54
- worktreePath: string;
55
- }
56
- export interface ConductorStatus {
57
- id: string;
58
- project: string;
59
- label: string;
60
- status: string;
61
- lastSeen: number;
62
- load: number;
63
- }
64
- export interface FinalizableRun {
65
- runUuid: string;
66
- /** Absolute path of the per-run git worktree, or '' when unset. */
67
- worktreePath: string;
68
- }
69
- /**
70
- * A ticket this conductor owns that is state=done but not yet closed — the
71
- * conductor's ticket-cleanup work list (worktree teardown + close), symmetric
72
- * to {@link FinalizableRun}.
73
- */
74
- export interface FinalizableTicket {
75
- ticketUuid: string;
76
- /** The ticket's git branch — the key herdr resolves the worktree by. */
77
- branchName: string;
78
- /**
79
- * Absolute path of the ticket's worktree (from its latest run's
80
- * `worktree_path`), or '' when unresolved. The cwd the cleanup command runs in.
81
- */
82
- worktreePath: string;
83
- }
84
- /** Extra conductor-writable gaia_run attributes (besides state/lease). */
85
- export interface RunWriteAttributes {
86
- /** Absolute path of the per-run git worktree (set by the conductor). */
87
- worktree_path?: string;
88
- }
89
- export interface GaiaRemote {
90
- /** Upserts by machine_id; sets status=online. Returns the Drupal entity uuid. */
91
- registerConductor(reg: ConductorRegistration): Promise<string>;
92
- /**
93
- * Records a heartbeat server-side: upserts by machine_id (recreating a
94
- * vanished registration), refreshes last_seen/lease/load, and brings the
95
- * conductor online. Keyed on machine_id, so it never 404s — the self-heal
96
- * lives on the server, not the client. Returns the resulting status
97
- * (`online` | `offline`).
98
- */
99
- heartbeat(reg: ConductorRegistration, currentLoad: number, leaseSeconds?: number): Promise<string>;
100
- getConductorStatus(conductorId: string): Promise<string | null>;
101
- setConductorStatus(conductorId: string, status: 'offline' | 'online'): Promise<void>;
102
- listConductors(owner?: 'me'): Promise<ConductorStatus[]>;
103
- activeRunCount(conductorId: string): Promise<number>;
104
- fetchActiveRuns(conductorId: string): Promise<ActiveRun[]>;
105
- claimNext(claim: ClaimOptions): Promise<ClaimedRun | null>;
106
- getTicket(ticketUuid: string): Promise<Ticket>;
107
- /** Returns the run's worktree_path, or '' when unset. */
108
- getRunWorktree(runUuid: string): Promise<string>;
109
- /**
110
- * Returns the identifier of the run's ticket, or '' when unresolved. Lets the
111
- * release path derive the tab matching ref (the ticket identifier) from a run
112
- * uuid alone.
113
- */
114
- getRunTicketIdentifier(runUuid: string): Promise<string>;
115
- /**
116
- * Returns the branch_name of the run's ticket, or '' when unresolved. Used
117
- * by dispatch for the per-(branch,state) herdr tab model.
118
- */
119
- getRunTicketBranchName(runUuid: string): Promise<string>;
120
- markRunning(runUuid: string, attrs?: RunWriteAttributes): Promise<void>;
121
- /**
122
- * Runs this conductor owns that are state=done but not yet closed — the
123
- * conductor's one-shot finalisation work list.
124
- */
125
- fetchFinalizableRuns(conductorId: string): Promise<FinalizableRun[]>;
126
- /**
127
- * Finalise a run: set closed + closed_date and (when non-empty) log. No state
128
- * change — the run is already done.
129
- */
130
- finalizeRun(uuid: string, log: string): Promise<void>;
131
- /**
132
- * Tickets this conductor owns that are state=done but not yet closed — the
133
- * conductor's one-shot ticket-cleanup work list. Durable-query driven (no
134
- * in-memory state), mirroring {@link fetchFinalizableRuns}.
135
- */
136
- fetchFinalizableTickets(conductorId: string): Promise<FinalizableTicket[]>;
137
- /**
138
- * Close a ticket: set closed=true + closed_date so it is not reprocessed on
139
- * the next tick. No state change — the ticket is already done. Mirrors
140
- * {@link finalizeRun}.
141
- */
142
- closeTicket(uuid: string): Promise<void>;
143
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +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
- beforeRun(_path: string): Promise<void>;
6
- afterRun(_path: string): Promise<void>;
7
- afterDone(_path: string): Promise<void>;
8
- }
9
- export declare function fakeWorkspace(): WorkspacePlugin;
@@ -1,19 +0,0 @@
1
- export class FakeWorkspace {
2
- async ensure(identifier, _title) {
3
- return { path: `/fake/${identifier}`, instructions: null };
4
- }
5
- async beforeRun(_path) { }
6
- async afterRun(_path) { }
7
- async afterDone(_path) { }
8
- }
9
- export function fakeWorkspace() {
10
- const workspace = new FakeWorkspace();
11
- return {
12
- kind: 'workspace',
13
- id: 'fake',
14
- requiredModules: [],
15
- async createWorkspace(_config) {
16
- return workspace;
17
- },
18
- };
19
- }
@@ -1,53 +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 HookRunner = (command: string, cwd: string) => Promise<void>;
6
- export type GitRunner = (args: string[], cwd: string) => Promise<void>;
7
- export interface WorkspaceHooks {
8
- after_create?: string;
9
- before_run?: string;
10
- after_run?: string;
11
- /** Run in the worktree once its ticket is done, before teardown. */
12
- after_done?: string;
13
- }
14
- export interface GitWorkspaceOptions {
15
- /** Main clone (a git repo): config source + worktree base. */
16
- root: string;
17
- /** Where per-ticket worktrees live. Default: `${root}-worktrees`. */
18
- worktreesRoot?: string;
19
- /** Branch name prefix per ticket. Default: 'gaia/'. */
20
- branchPrefix?: string;
21
- /**
22
- * Branch name template. Vars: {branchPrefix}, {key} (sanitized identifier),
23
- * {identifier}, {titleSlug}. Default: `{branchPrefix}{key}-{titleSlug}`.
24
- */
25
- branchTemplate?: string;
26
- hooks?: WorkspaceHooks;
27
- runHook?: HookRunner;
28
- runGit?: GitRunner;
29
- }
30
- export declare class GitWorkspace implements GaiaWorkspace {
31
- private readonly options;
32
- private readonly runHook;
33
- private readonly runGit;
34
- private readonly root;
35
- private readonly worktreesRoot;
36
- private readonly branchPrefix;
37
- private readonly branchTemplate;
38
- constructor(options: GitWorkspaceOptions);
39
- /** Render the branch name for a ticket from the configured template. */
40
- branchFor(identifier: string, title?: string): string;
41
- keyFor(identifier: string): string;
42
- private pathFor;
43
- ensure(identifier: string, title?: string, _baseRef?: string): Promise<EnsuredWorkspace>;
44
- remove(identifier: string): Promise<void>;
45
- beforeRun(path: string): Promise<void>;
46
- afterRun(path: string): Promise<void>;
47
- afterDone(path: string): Promise<void>;
48
- }
49
- export declare function gitWorkspace(opts?: {
50
- hooks?: WorkspaceHooks;
51
- branchPrefix?: string;
52
- branchTemplate?: string;
53
- }): WorkspacePlugin;
@@ -1,113 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
3
- import { exec } from '../../core/exec.js';
4
- import { slugify } from '../../core/slug.js';
5
- import { loadInstructions } from './instructions.js';
6
- /** Default branch template: `<prefix><key>-<title-slug>` (readable). */
7
- export const DEFAULT_BRANCH_TEMPLATE = '{branchPrefix}{key}-{titleSlug}';
8
- function renderBranchTemplate(template, vars) {
9
- const rendered = template.replace(/\{(\w+)\}/g, (whole, key) => {
10
- const value = vars[key];
11
- return value === undefined ? whole : value;
12
- });
13
- // An empty title slug leaves a dangling separator (e.g. `gaia/GL-9-`) —
14
- // trim trailing branch separators so the branch stays a valid, tidy ref.
15
- return rendered.replace(/[-_./]+$/g, '');
16
- }
17
- const defaultHookRunner = async (command, cwd) => {
18
- await exec('sh', ['-c', command], { cwd });
19
- };
20
- const defaultGitRunner = async (args, cwd) => {
21
- await exec('git', args, { cwd });
22
- };
23
- export class GitWorkspace {
24
- options;
25
- runHook;
26
- runGit;
27
- root;
28
- worktreesRoot;
29
- branchPrefix;
30
- branchTemplate;
31
- constructor(options) {
32
- this.options = options;
33
- this.runHook = options.runHook ?? defaultHookRunner;
34
- this.runGit = options.runGit ?? defaultGitRunner;
35
- this.root = resolve(options.root);
36
- this.worktreesRoot = options.worktreesRoot
37
- ? resolve(options.worktreesRoot)
38
- : `${this.root}-worktrees`;
39
- this.branchPrefix = options.branchPrefix ?? 'gaia/';
40
- this.branchTemplate = options.branchTemplate ?? DEFAULT_BRANCH_TEMPLATE;
41
- }
42
- /** Render the branch name for a ticket from the configured template. */
43
- branchFor(identifier, title) {
44
- return renderBranchTemplate(this.branchTemplate, {
45
- branchPrefix: this.branchPrefix,
46
- key: this.keyFor(identifier),
47
- identifier,
48
- titleSlug: slugify(title ?? ''),
49
- });
50
- }
51
- keyFor(identifier) {
52
- return identifier.replace(/[^A-Za-z0-9._-]/g, '_');
53
- }
54
- pathFor(key) {
55
- return resolve(join(this.worktreesRoot, key));
56
- }
57
- async ensure(identifier, title, _baseRef) {
58
- const key = this.keyFor(identifier);
59
- // Reject empty and dot-leading keys: a dot-leading key would produce an
60
- // invalid git ref (e.g. `gaia/.hidden`) and covers '.'/'..' too.
61
- if (key === '' || key.startsWith('.')) {
62
- throw new Error(`invalid workspace identifier: ${identifier}`);
63
- }
64
- const path = this.pathFor(key);
65
- if (existsSync(path)) {
66
- return { path, instructions: loadInstructions(path) };
67
- }
68
- const branch = this.branchFor(identifier, title);
69
- await this.runGit(['-C', this.root, 'worktree', 'add', '--force', '-B', branch, path], this.root);
70
- if (this.options.hooks?.after_create) {
71
- await this.runHook(this.options.hooks.after_create, path);
72
- }
73
- return { path, instructions: loadInstructions(path) };
74
- }
75
- async remove(identifier) {
76
- const key = this.keyFor(identifier);
77
- const path = this.pathFor(key);
78
- await this.runGit(['-C', this.root, 'worktree', 'remove', '--force', path], this.root);
79
- }
80
- async beforeRun(path) {
81
- if (this.options.hooks?.before_run) {
82
- await this.runHook(this.options.hooks.before_run, path);
83
- }
84
- }
85
- async afterRun(path) {
86
- if (this.options.hooks?.after_run) {
87
- await this.runHook(this.options.hooks.after_run, path);
88
- }
89
- }
90
- async afterDone(path) {
91
- if (this.options.hooks?.after_done) {
92
- await this.runHook(this.options.hooks.after_done, path);
93
- }
94
- }
95
- }
96
- export function gitWorkspace(opts = {}) {
97
- return {
98
- kind: 'workspace',
99
- id: 'git',
100
- requiredModules: [],
101
- async createWorkspace(config) {
102
- const root = config.config_path
103
- ? dirname(config.config_path)
104
- : process.cwd();
105
- return new GitWorkspace({
106
- root,
107
- ...(opts.hooks ? { hooks: opts.hooks } : {}),
108
- ...(opts.branchPrefix ? { branchPrefix: opts.branchPrefix } : {}),
109
- ...(opts.branchTemplate ? { branchTemplate: opts.branchTemplate } : {}),
110
- });
111
- },
112
- };
113
- }
@@ -1,6 +0,0 @@
1
- /** Loads ./WORKFLOW.md from the workspace, hashing its content. */
2
- export declare function loadInstructions(workspacePath: string): {
3
- path: string;
4
- sha256: string;
5
- text: string;
6
- } | null;
@@ -1,16 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { resolve } from 'node:path';
4
- /** Loads ./WORKFLOW.md from the workspace, hashing its content. */
5
- export function loadInstructions(workspacePath) {
6
- const path = resolve(workspacePath, 'WORKFLOW.md');
7
- if (!existsSync(path)) {
8
- return null;
9
- }
10
- const text = readFileSync(path, 'utf8');
11
- return {
12
- path,
13
- sha256: createHash('sha256').update(text).digest('hex'),
14
- text,
15
- };
16
- }
@@ -1,33 +0,0 @@
1
- export interface EnsuredWorkspace {
2
- path: string;
3
- instructions: {
4
- path: string;
5
- sha256: string;
6
- text: string;
7
- } | null;
8
- }
9
- export interface GaiaWorkspace {
10
- /**
11
- * Ensure a per-ticket worktree exists. `branch`, when given, is the branch
12
- * name the dispatcher computed for the ticket. The git plugin treats it as a
13
- * readable title to slug into its branch template; the herdr plugin uses it
14
- * verbatim as the worktree branch. The worktree directory key/path stays
15
- * identifier- or branch-derived so reuse is stable across runs.
16
- *
17
- * `baseRef`, when given, overrides the base the new branch is created from
18
- * (e.g. `origin/<base_branch>` so a sub-ticket stacks on its parent); if it
19
- * does not resolve on the remote the implementation falls back to its default
20
- * base — never a hard error.
21
- */
22
- ensure(identifier: string, branch?: string, baseRef?: string): Promise<EnsuredWorkspace>;
23
- beforeRun(path: string): Promise<void>;
24
- afterRun(path: string): Promise<void>;
25
- /**
26
- * Run the `after_done` hook in the worktree once its ticket is done, just
27
- * before the executor tears the worktree down — the ticket-lifecycle
28
- * counterpart to the `after_create` setup hook. Lets a configured command
29
- * (e.g. `ddev delete`) reclaim environment state. A no-op when no hook is
30
- * configured.
31
- */
32
- afterDone(path: string): Promise<void>;
33
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import type { DropSHPlugin } from 'dropsh/plugin';
2
- import type { AgentPlugin, ExecutorPlugin, RemotePlugin, WorkspacePlugin } from './plugins/plugins.js';
3
- /** Normalized single conductor. */
4
- export interface ConductorSettings {
5
- /** Default: `${project} @ ${checkoutRoot}`. */
6
- label: string;
7
- /**
8
- * Stable node identity (gaia_conductor.machine_id) this process registers as.
9
- * Defaults to a hash of hostname + checkout path. Set it to pin a conductor to
10
- * a known identity — e.g. so a ticket can be pre-assigned to it (conductor
11
- * assignment is the run-start trigger), which the e2e fixtures rely on.
12
- */
13
- machine_id?: string;
14
- /** Project name (gaia_project.name); resolved at registration. */
15
- project: string;
16
- /** Workflow states this conductor serves. */
17
- states: string[];
18
- /**
19
- * Agent prompt template - the GAIA run contract, NOT project workflow. Bounds
20
- * the agent to exactly one state and tells it to release + stop, keeping run
21
- * mechanics out of the repo's WORKFLOW.md. Placeholders: `{identifier}`,
22
- * `{state}`, `{runUuid}`. Defaults to `DEFAULT_AGENT_PROMPT`.
23
- */
24
- prompt: string;
25
- /** Default: 1. */
26
- max_parallel: number;
27
- poll_interval_ms: number;
28
- lease_seconds: number;
29
- hooks?: {
30
- after_create?: string;
31
- before_run?: string;
32
- after_run?: string;
33
- after_done?: string;
34
- };
35
- /** Control-plane site settings used for dropsh and agent env. */
36
- site: {
37
- base_url: string;
38
- jsonapi_prefix: string;
39
- };
40
- /** Absolute path of the loaded config. */
41
- config_path: string;
42
- }
43
- /** Whole conductor.config.js (dropsh-superset): site + named plugin slots. */
44
- export interface ConductorFileConfig extends ConductorSettings {
45
- remote: RemotePlugin;
46
- executor: ExecutorPlugin;
47
- agent: AgentPlugin;
48
- workspace: WorkspacePlugin;
49
- /** dropsh-layer plugins (auth etc.); separate from the GAIA slots. */
50
- plugins?: DropSHPlugin[];
51
- }
package/dist/src/types.js DELETED
@@ -1 +0,0 @@
1
- export {};