@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,89 +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 defaultGitRunner = async (args, cwd) => {
18
- await exec('git', args, { cwd });
19
- };
20
- export class GitWorkspace {
21
- runGit;
22
- root;
23
- worktreesRoot;
24
- branchPrefix;
25
- branchTemplate;
26
- constructor(options) {
27
- this.runGit = options.runGit ?? defaultGitRunner;
28
- this.root = resolve(options.root);
29
- this.worktreesRoot = options.worktreesRoot
30
- ? resolve(options.worktreesRoot)
31
- : `${this.root}-worktrees`;
32
- this.branchPrefix = options.branchPrefix ?? 'gaia/';
33
- this.branchTemplate = options.branchTemplate ?? DEFAULT_BRANCH_TEMPLATE;
34
- }
35
- /** Render the branch name for a ticket from the configured template. */
36
- branchFor(identifier, title) {
37
- return renderBranchTemplate(this.branchTemplate, {
38
- branchPrefix: this.branchPrefix,
39
- key: this.keyFor(identifier),
40
- identifier,
41
- titleSlug: slugify(title ?? ''),
42
- });
43
- }
44
- keyFor(identifier) {
45
- return identifier.replace(/[^A-Za-z0-9._-]/g, '_');
46
- }
47
- pathFor(key) {
48
- return resolve(join(this.worktreesRoot, key));
49
- }
50
- async ensure(identifier, title, _baseRef) {
51
- const key = this.keyFor(identifier);
52
- // Reject empty and dot-leading keys: a dot-leading key would produce an
53
- // invalid git ref (e.g. `gaia/.hidden`) and covers '.'/'..' too.
54
- if (key === '' || key.startsWith('.')) {
55
- throw new Error(`invalid workspace identifier: ${identifier}`);
56
- }
57
- const path = this.pathFor(key);
58
- if (existsSync(path)) {
59
- return { path, instructions: loadInstructions(path), created: false };
60
- }
61
- const branch = this.branchFor(identifier, title);
62
- await this.runGit(['-C', this.root, 'worktree', 'add', '--force', '-B', branch, path], this.root);
63
- // The `after_create` hook is run by the executor (GAIA-84), not here — the
64
- // workspace only reports that it created a fresh worktree.
65
- return { path, instructions: loadInstructions(path), created: true };
66
- }
67
- async remove(identifier) {
68
- const key = this.keyFor(identifier);
69
- const path = this.pathFor(key);
70
- await this.runGit(['-C', this.root, 'worktree', 'remove', '--force', path], this.root);
71
- }
72
- }
73
- export function gitWorkspace(opts = {}) {
74
- return {
75
- kind: 'workspace',
76
- id: 'git',
77
- requiredModules: [],
78
- async createWorkspace(config) {
79
- const root = config.config_path
80
- ? dirname(config.config_path)
81
- : process.cwd();
82
- return new GitWorkspace({
83
- root,
84
- ...(opts.branchPrefix ? { branchPrefix: opts.branchPrefix } : {}),
85
- ...(opts.branchTemplate ? { branchTemplate: opts.branchTemplate } : {}),
86
- });
87
- },
88
- };
89
- }
@@ -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,35 +0,0 @@
1
- export interface EnsuredWorkspace {
2
- path: string;
3
- instructions: {
4
- path: string;
5
- sha256: string;
6
- text: string;
7
- } | null;
8
- /**
9
- * Whether this call CREATED the worktree (true) or reused an existing one
10
- * (false). The core runs the `after_create` lifecycle hook only on a fresh
11
- * worktree, so it needs to know which happened. Lifecycle hooks themselves
12
- * are no longer a workspace concern (GAIA-84): the executor owns and runs
13
- * them best-effort.
14
- */
15
- created: boolean;
16
- }
17
- export interface GaiaWorkspace {
18
- /**
19
- * Ensure a per-ticket worktree exists. `branch`, when given, is the branch
20
- * name the dispatcher computed for the ticket. The git plugin treats it as a
21
- * readable title to slug into its branch template; the herdr plugin uses it
22
- * verbatim as the worktree branch. The worktree directory key/path stays
23
- * identifier- or branch-derived so reuse is stable across runs.
24
- *
25
- * `baseRef`, when given, overrides the base the new branch is created from
26
- * (e.g. `origin/<base_branch>` so a sub-ticket stacks on its parent); if it
27
- * does not resolve on the remote the implementation falls back to its default
28
- * base — never a hard error.
29
- *
30
- * Reports `created` so the caller can run the `after_create` hook only on a
31
- * fresh worktree. Lifecycle-hook invocation is NOT a workspace responsibility
32
- * anymore — the executor owns all hooks (GAIA-84).
33
- */
34
- ensure(identifier: string, branch?: string, baseRef?: string): Promise<EnsuredWorkspace>;
35
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from './plugins/registry-exports.js';
@@ -1 +0,0 @@
1
- export * from './plugins/registry-exports.js';
@@ -1,52 +0,0 @@
1
- import type { DropSHPlugin } from 'dropsh/plugin';
2
- import type { AgentCandidate, 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
- /** The agent slot: a single candidate or an array of candidates (shape preserved as authored). Selection normalizes + picks one per dispatch. */
48
- agent: AgentCandidate | AgentCandidate[];
49
- workspace: WorkspacePlugin;
50
- /** dropsh-layer plugins (auth etc.); separate from the GAIA slots. */
51
- plugins?: DropSHPlugin[];
52
- }
package/dist/src/types.js DELETED
@@ -1 +0,0 @@
1
- export {};