@gaia-ai/conductor 0.6.0 → 0.6.2

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 (38) hide show
  1. package/README.md +1 -1
  2. package/dist/src/cli/config-schema.d.ts +42 -7
  3. package/dist/src/cli/config-schema.js +64 -9
  4. package/dist/src/cli/init.js +16 -10
  5. package/dist/src/cli/migrate-addon-names.d.ts +82 -0
  6. package/dist/src/cli/migrate-addon-names.js +351 -0
  7. package/dist/src/cli/upgrade.d.ts +15 -0
  8. package/dist/src/cli/upgrade.js +87 -8
  9. package/dist/src/commands/conductor.d.ts +27 -3
  10. package/dist/src/commands/conductor.js +39 -52
  11. package/dist/src/config.d.ts +15 -1
  12. package/dist/src/config.js +119 -4
  13. package/dist/src/contract.d.ts +8 -0
  14. package/dist/src/contract.js +16 -0
  15. package/dist/src/core/conductor.d.ts +16 -1
  16. package/dist/src/core/conductor.js +23 -1
  17. package/dist/src/index.d.ts +6 -4
  18. package/dist/src/index.js +20 -3
  19. package/dist/src/plugins/agent.d.ts +61 -0
  20. package/dist/src/plugins/agent.js +11 -0
  21. package/dist/src/plugins/executor.d.ts +104 -0
  22. package/dist/src/plugins/executor.js +1 -0
  23. package/dist/src/plugins/plugins.d.ts +60 -0
  24. package/dist/src/plugins/plugins.js +42 -0
  25. package/dist/src/plugins/preset.d.ts +48 -0
  26. package/dist/src/plugins/preset.js +23 -0
  27. package/dist/src/plugins/remote.d.ts +203 -0
  28. package/dist/src/plugins/remote.js +1 -0
  29. package/dist/src/plugins/workspace.d.ts +35 -0
  30. package/dist/src/plugins/workspace.js +1 -0
  31. package/dist/src/preset.d.ts +2 -2
  32. package/dist/src/types.d.ts +65 -0
  33. package/dist/src/types.js +1 -0
  34. package/package.json +4 -3
  35. package/dist/src/cli/conductor-registry.d.ts +0 -7
  36. package/dist/src/cli/conductor-registry.js +0 -6
  37. package/dist/src/cli/deployment.d.ts +0 -34
  38. package/dist/src/cli/deployment.js +0 -63
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  GAIA conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.
4
4
 
5
- Part of the GAIA conductor. Install the meta package `@gaia-ai/gaia` to get the `gaia` CLI with all plugins. Source: https://git.key-tec.de/keytec/gaia (conductor/).
5
+ Part of the GAIA CLI. Install the meta package `@gaia-ai/gaia` to get the `gaia` CLI with all addons. Source: https://git.key-tec.de/keytec/gaia (gaia-cli/).
@@ -18,12 +18,36 @@ export interface ConnectionConfigMigration {
18
18
  apply(currentText: string): string;
19
19
  }
20
20
  /**
21
- * The ordered, contiguous migration chain. Ships EMPTY at v1: nothing below v1
22
- * is a versioned config (v0 = seed / hand-authored / untouched). The FIRST real
23
- * shape change adds the first `{ from: 1, to: 2, … }` method here, which bumps
24
- * the derived CURRENT to 2 automatically. The extension point is real and
25
- * exercised by tests now, so the first shape change is a one-method addition,
26
- * never a re-plumb.
21
+ * GAIA-226: the package name whose `plugins[]` entry contributes the `md`
22
+ * renderer (plus the authoritative JSON:API schema) to a connection config. The
23
+ * AGGREGATOR is named, not `@dropsh/plugin-markdown` directly: a direct
24
+ * `@dropsh/*` descriptor is unresolvable from `loadGaiaConfig`'s bases
25
+ * (config dir / host module / cwd), whereas `@gaia-ai/addon-essentials` is a
26
+ * real dependency of both the host and the engine and therefore resolves in the
27
+ * monorepo AND from a global `@gaia-ai/gaia` install. No `export:` is needed —
28
+ * the package default-exports its factory.
29
+ */
30
+ export declare const RENDERER_PLUGIN_PACKAGE = "@gaia-ai/addon-essentials";
31
+ /** The exact `plugins[]` element text the v1→v2 migration and the scaffold emit. */
32
+ export declare const RENDERER_PLUGIN_ENTRY = "{ plugin: '@gaia-ai/addon-essentials' },";
33
+ /**
34
+ * GAIA-226 (v1 → v2): insert the renderer aggregator as the FIRST `plugins[]`
35
+ * element, so `gaia dropsh --format md` works instead of failing with
36
+ * `E_CONFIG: Unknown format 'md'. Available: json`.
37
+ *
38
+ * A pure TEXT transform — the upgrade runner must never execute a possibly
39
+ * side-effecting config module. Idempotent: text that already names the package
40
+ * in CODE is returned unchanged (whole-line `//` comments are stripped for that
41
+ * probe, so the template's own explanatory header does not read as a hit), and a
42
+ * config with no `plugins: [` array literal (an `addons: []`-shaped or
43
+ * hand-reshaped file) is left alone rather than guessed at.
44
+ */
45
+ export declare function addRendererPluginEntry(text: string): string;
46
+ /**
47
+ * The ordered, contiguous migration chain. v1 was the pre-GAIA-226 shape (auth
48
+ * plugins only); v2 adds the markdown renderer entry. Nothing below v1 is a
49
+ * versioned config (v0 = seed / hand-authored / untouched). `GAIA_CONFIG_SCHEMA_VERSION`
50
+ * derives from the chain's last `to` — never hardcode it.
27
51
  */
28
52
  export declare const CONNECTION_MIGRATIONS: ConnectionConfigMigration[];
29
53
  /** The current connection-config schema version — single source of truth. */
@@ -40,6 +64,15 @@ export declare function readConfigSchemaVersion(path: string): number;
40
64
  export declare function stripVersionHeader(text: string): string;
41
65
  /** Prepend (replacing any existing) a `// @gaia-schema-version <N>` header. */
42
66
  export declare function stampVersion(text: string, version: number): string;
67
+ /**
68
+ * Re-stamp the in-body `schema_version: <N>` field, which the generated config
69
+ * carries alongside the header marker for programmatic reads. The header is the
70
+ * upgrade decision's source of truth and is stamped by the runner; this keeps the
71
+ * FIELD from going stale when a migration bumps the version (GAIA-226 — the first
72
+ * migration is where the two could first disagree). No-op when the field is
73
+ * absent (a hand-authored config need not carry it).
74
+ */
75
+ export declare function stampSchemaVersionField(text: string, version: number): string;
43
76
  /**
44
77
  * Validate a migration chain is contiguous: each `to === from + 1`, the first
45
78
  * migrates from v1, no gaps, and the chain ends at `current` (default CURRENT).
@@ -49,6 +82,8 @@ export declare function assertContiguous(chain: ConnectionConfigMigration[], cur
49
82
  /**
50
83
  * Walk the migration chain from `from` up to `to`, applying each method's
51
84
  * `apply` in sequence. Input/output text is WITHOUT the version header — the
52
- * caller stamps CURRENT after. `chain` is injectable for tests.
85
+ * caller stamps CURRENT after. After each step the in-body `schema_version:`
86
+ * field is re-stamped to that step's `to`, so no individual method has to know
87
+ * (or hardcode) its own number twice. `chain` is injectable for tests.
53
88
  */
54
89
  export declare function applyMigrations(text: string, from: number, to: number, chain?: ConnectionConfigMigration[]): string;
@@ -11,15 +11,57 @@ import { readFileSync } from 'node:fs';
11
11
  const MARKER_RE = /@gaia-schema-version\s+(\d+)/;
12
12
  const HEADER_LINE_RE = /^\/\/ @gaia-schema-version \d+\n/;
13
13
  /**
14
- * The ordered, contiguous migration chain. Ships EMPTY at v1: nothing below v1
15
- * is a versioned config (v0 = seed / hand-authored / untouched). The FIRST real
16
- * shape change adds the first `{ from: 1, to: 2, … }` method here, which bumps
17
- * the derived CURRENT to 2 automatically. The extension point is real and
18
- * exercised by tests now, so the first shape change is a one-method addition,
19
- * never a re-plumb.
14
+ * GAIA-226: the package name whose `plugins[]` entry contributes the `md`
15
+ * renderer (plus the authoritative JSON:API schema) to a connection config. The
16
+ * AGGREGATOR is named, not `@dropsh/plugin-markdown` directly: a direct
17
+ * `@dropsh/*` descriptor is unresolvable from `loadGaiaConfig`'s bases
18
+ * (config dir / host module / cwd), whereas `@gaia-ai/addon-essentials` is a
19
+ * real dependency of both the host and the engine and therefore resolves in the
20
+ * monorepo AND from a global `@gaia-ai/gaia` install. No `export:` is needed —
21
+ * the package default-exports its factory.
22
+ */
23
+ export const RENDERER_PLUGIN_PACKAGE = '@gaia-ai/addon-essentials';
24
+ /** The exact `plugins[]` element text the v1→v2 migration and the scaffold emit. */
25
+ export const RENDERER_PLUGIN_ENTRY = `{ plugin: '${RENDERER_PLUGIN_PACKAGE}' },`;
26
+ /** `plugins: [` — captures its own indentation so the inserted element aligns. */
27
+ const PLUGINS_ARRAY_OPEN_RE = /^([ \t]*)plugins:\s*\[[ \t]*$/m;
28
+ /** Whole-line `//` comments — stripped before the presence probe (see below). */
29
+ const LINE_COMMENT_RE = /^[ \t]*\/\/.*$/gm;
30
+ /**
31
+ * GAIA-226 (v1 → v2): insert the renderer aggregator as the FIRST `plugins[]`
32
+ * element, so `gaia dropsh --format md` works instead of failing with
33
+ * `E_CONFIG: Unknown format 'md'. Available: json`.
34
+ *
35
+ * A pure TEXT transform — the upgrade runner must never execute a possibly
36
+ * side-effecting config module. Idempotent: text that already names the package
37
+ * in CODE is returned unchanged (whole-line `//` comments are stripped for that
38
+ * probe, so the template's own explanatory header does not read as a hit), and a
39
+ * config with no `plugins: [` array literal (an `addons: []`-shaped or
40
+ * hand-reshaped file) is left alone rather than guessed at.
41
+ */
42
+ export function addRendererPluginEntry(text) {
43
+ if (text.replace(LINE_COMMENT_RE, '').includes(RENDERER_PLUGIN_PACKAGE)) {
44
+ return text;
45
+ }
46
+ const m = PLUGINS_ARRAY_OPEN_RE.exec(text);
47
+ if (m === null)
48
+ return text;
49
+ const indent = `${m[1]} `;
50
+ return text.replace(PLUGINS_ARRAY_OPEN_RE, (line) => `${line}\n${indent}${RENDERER_PLUGIN_ENTRY}`);
51
+ }
52
+ /**
53
+ * The ordered, contiguous migration chain. v1 was the pre-GAIA-226 shape (auth
54
+ * plugins only); v2 adds the markdown renderer entry. Nothing below v1 is a
55
+ * versioned config (v0 = seed / hand-authored / untouched). `GAIA_CONFIG_SCHEMA_VERSION`
56
+ * derives from the chain's last `to` — never hardcode it.
20
57
  */
21
58
  export const CONNECTION_MIGRATIONS = [
22
- // { from: 1, to: 2, description: 'add site.jsonapi_prefix default', apply: (t) => … },
59
+ {
60
+ from: 1,
61
+ to: 2,
62
+ description: `add the ${RENDERER_PLUGIN_PACKAGE} renderer entry to plugins[]`,
63
+ apply: addRendererPluginEntry,
64
+ },
23
65
  ];
24
66
  /** The current connection-config schema version — single source of truth. */
25
67
  export const GAIA_CONFIG_SCHEMA_VERSION = CONNECTION_MIGRATIONS.at(-1)?.to ?? 1;
@@ -49,6 +91,17 @@ export function stripVersionHeader(text) {
49
91
  export function stampVersion(text, version) {
50
92
  return `// @gaia-schema-version ${version}\n${stripVersionHeader(text)}`;
51
93
  }
94
+ /**
95
+ * Re-stamp the in-body `schema_version: <N>` field, which the generated config
96
+ * carries alongside the header marker for programmatic reads. The header is the
97
+ * upgrade decision's source of truth and is stamped by the runner; this keeps the
98
+ * FIELD from going stale when a migration bumps the version (GAIA-226 — the first
99
+ * migration is where the two could first disagree). No-op when the field is
100
+ * absent (a hand-authored config need not carry it).
101
+ */
102
+ export function stampSchemaVersionField(text, version) {
103
+ return text.replace(/^([ \t]*)schema_version:\s*\d+\s*,/m, `$1schema_version: ${version},`);
104
+ }
52
105
  /**
53
106
  * Validate a migration chain is contiguous: each `to === from + 1`, the first
54
107
  * migrates from v1, no gaps, and the chain ends at `current` (default CURRENT).
@@ -74,7 +127,9 @@ export function assertContiguous(chain, current = GAIA_CONFIG_SCHEMA_VERSION) {
74
127
  /**
75
128
  * Walk the migration chain from `from` up to `to`, applying each method's
76
129
  * `apply` in sequence. Input/output text is WITHOUT the version header — the
77
- * caller stamps CURRENT after. `chain` is injectable for tests.
130
+ * caller stamps CURRENT after. After each step the in-body `schema_version:`
131
+ * field is re-stamped to that step's `to`, so no individual method has to know
132
+ * (or hardcode) its own number twice. `chain` is injectable for tests.
78
133
  */
79
134
  export function applyMigrations(text, from, to, chain = CONNECTION_MIGRATIONS) {
80
135
  let cur = from;
@@ -84,7 +139,7 @@ export function applyMigrations(text, from, to, chain = CONNECTION_MIGRATIONS) {
84
139
  if (step === undefined) {
85
140
  throw new Error(`no migration from v${cur} (chain incomplete)`);
86
141
  }
87
- out = step.apply(out);
142
+ out = stampSchemaVersionField(step.apply(out), step.to);
88
143
  cur = step.to;
89
144
  }
90
145
  return out;
@@ -2,7 +2,7 @@ import { chmodSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import { hostname } from 'node:os';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { machineContextPath, readMachineContext, } from '@gaia-ai/core';
5
- import { GAIA_CONFIG_SCHEMA_VERSION } from './config-schema.js';
5
+ import { GAIA_CONFIG_SCHEMA_VERSION, RENDERER_PLUGIN_ENTRY, } from './config-schema.js';
6
6
  export { machineContextPath, readMachineContext };
7
7
  /** JS single-quoted string literal for a trusted, simple value. */
8
8
  function q(value) {
@@ -29,10 +29,12 @@ export function renderCommittedConfig(inputs) {
29
29
  // IMPORT-FREE (GAIA-78): the plugin slots are \`{ plugin, with }\` descriptors
30
30
  // naming the REAL published package, not \`import\`ed constructors.
31
31
  // loadConductorConfig resolves each name ESLint-style (config dir → cwd →
32
- // conductor install). Each plugin package default-exports its factory (no
33
- // \`export:\`) EXCEPT the multi-export host barrel and the merged herdr workspace
34
- // (\`@gaia-ai/plugin-herdr\` default-exports the executor, so the workspace names
35
- // \`export: 'herdrWorkspace'\` — GAIA-139).
32
+ // conductor install). Every addon package default-exports its single factory, so
33
+ // no slot needs an \`export:\` EXCEPT the merged herdr workspace
34
+ // (\`@gaia-ai/addon-herdr\` default-exports the executor, so the workspace names
35
+ // \`export: 'herdrWorkspace'\` — GAIA-139). GAIA-224 replaced the old
36
+ // \`{ plugin: '@gaia-ai/gaia/plugins', export: 'drupalRemote' }\` host-barrel
37
+ // descriptor with the real addon package \`@gaia-ai/addon-remote-drupal\`.
36
38
 
37
39
  // The user-global machine context: identity + connection (incl. secret), shared
38
40
  // by every project on this machine. Never committed.
@@ -67,16 +69,16 @@ export default {
67
69
  // Lifecycle hooks are executor-owned (GAIA-84): they live at the config top
68
70
  // level — NOT on a plugin descriptor's \`with.hooks\`.
69
71
  hooks: { after_create: 'ddev init-worktree', after_done: 'ddev delete -Oy' },
70
- remote: { plugin: '@gaia-ai/gaia/plugins', export: 'drupalRemote' },
71
- executor: { plugin: '@gaia-ai/plugin-herdr' },
72
+ remote: { plugin: '@gaia-ai/addon-remote-drupal' },
73
+ executor: { plugin: '@gaia-ai/addon-herdr' },
72
74
  agent: {
73
- plugin: '@gaia-ai/plugin-claude',
75
+ plugin: '@gaia-ai/addon-claude',
74
76
  with: { model: local.model ?? 'claude-opus-4-8' },
75
77
  },
76
- // GAIA-139: the herdr workspace ships in @gaia-ai/plugin-herdr, which
78
+ // GAIA-139: the herdr workspace ships in @gaia-ai/addon-herdr, which
77
79
  // default-exports the EXECUTOR — so the workspace slot names export: 'herdrWorkspace'.
78
80
  workspace: {
79
- plugin: '@gaia-ai/plugin-herdr',
81
+ plugin: '@gaia-ai/addon-herdr',
80
82
  export: 'herdrWorkspace',
81
83
  },
82
84
  };
@@ -99,6 +101,9 @@ export function renderGaiaConfig() {
99
101
  //
100
102
  // plugins[] is consumed by DROPSH, whose resolver has no sole-function
101
103
  // auto-pick, so @dropsh/plugin-oauth2 entries MUST name export: 'oauth2Plugin'.
104
+ // The '@gaia-ai/addon-essentials' entry (GAIA-226) needs NO export: — that
105
+ // package default-exports its factory. It contributes the markdown renderer
106
+ // ('gaia dropsh --format md') plus the authoritative JSON:API schema.
102
107
  async function loadMachine() {
103
108
  try {
104
109
  return (await import(\`\${process.env.HOME}/.gaia/machine.config.js\`)).default ?? {};
@@ -123,6 +128,7 @@ export default {
123
128
  schema_version: ${GAIA_CONFIG_SCHEMA_VERSION},
124
129
  site: { base_url: baseUrl, jsonapi_prefix: local.jsonapi_prefix ?? '/jsonapi' },
125
130
  plugins: [
131
+ ${RENDERER_PLUGIN_ENTRY}
126
132
  {
127
133
  plugin: '@dropsh/plugin-oauth2',
128
134
  export: 'oauth2Plugin',
@@ -0,0 +1,82 @@
1
+ /** Suffix of the pre-rewrite backup a real (non-dry) rewrite leaves behind. */
2
+ export declare const ADDON_RENAME_BAK_SUFFIX = ".pre-addon-rename.bak";
3
+ /**
4
+ * The 14 addon packages renamed by GAIA-224 (spec v3 decision 14), including
5
+ * the GAIA-220 `pi` agent addon merged in from develop. A CLOSED
6
+ * set — the pass rewrites only these exact specifiers, so an unknown
7
+ * `@gaia-ai/plugin-something` is left alone rather than silently retargeted at a
8
+ * package that does not exist.
9
+ */
10
+ export declare const RENAMED_ADDONS: readonly ["auth-basic", "claude", "codex", "deployment", "dropsh", "essentials", "fake", "gaia-ui", "herdr", "kimi", "opencode", "pi", "remote-drupal", "workspace-git"];
11
+ /**
12
+ * Where each export of the host barrels lives now — the DELETED
13
+ * `@gaia-ai/core/plugins` and (GAIA-230) the meta package's
14
+ * `@gaia-ai/gaia/plugins`, which is unresolvable from a dev-clone install.
15
+ *
16
+ * The key set is the barrel's own export list — `core/src/plugins/registry-exports.ts`
17
+ * as of the commit that deleted it — re-pointed at the addon that owns each
18
+ * factory today. `defaultExport` records whether the target package
19
+ * DEFAULT-exports exactly that factory; when it does, the descriptor's `export:`
20
+ * becomes redundant and is dropped.
21
+ *
22
+ * Deliberately absent, so they are left untouched:
23
+ * - `selectRemote`/`selectWorkspace`/`selectExecutor`/`selectAgent(s)` — moved
24
+ * to `@gaia-ai/conductor/contract`, but they are config-shape SELECTORS, not
25
+ * plugin factories, so no descriptor can legitimately name them;
26
+ * - any other/unknown export name — a config naming one is reported by the
27
+ * loader rather than silently retargeted at a package that may not have it.
28
+ */
29
+ export declare const CORE_PLUGINS_BARREL_EXPORTS: Readonly<Record<string, {
30
+ target: string;
31
+ defaultExport: boolean;
32
+ }>>;
33
+ /**
34
+ * The host-barrel specifiers a descriptor may name. Both map through
35
+ * `CORE_PLUGINS_BARREL_EXPORTS`: `@gaia-ai/core/plugins` is DELETED, and
36
+ * `@gaia-ai/gaia/plugins` (GAIA-230) is unresolvable from a dev-clone install
37
+ * because the meta package that exports it is the workspace's leaf sink.
38
+ */
39
+ export declare const HOST_BARREL_PATHS: readonly ["@gaia-ai/core/plugins", "@gaia-ai/gaia/plugins"];
40
+ /** Which surface a config file speaks — decides the ambiguous builtins mapping. */
41
+ export type ConfigSurface = 'connection' | 'engine';
42
+ /**
43
+ * Rewrite the legacy specifiers in one config's SOURCE TEXT — all of them: the
44
+ * renamed `@gaia-ai/plugin-*` packages, the deleted `@gaia-ai/core/builtins`
45
+ * preset, and the host-barrel descriptors naming either `@gaia-ai/core/plugins`
46
+ * (deleted) or `@gaia-ai/gaia/plugins` (GAIA-230). Pure; line
47
+ * count is preserved (every replacement is line-local), which is what lets the
48
+ * reported diff be a plain index-aligned line diff.
49
+ */
50
+ export declare function migrateAddonNames(text: string, surface: ConfigSurface): {
51
+ text: string;
52
+ count: number;
53
+ };
54
+ /** The outcome of the rename pass over a single config file. */
55
+ export interface AddonRenameResult {
56
+ /** Report line, in the shape of the other upgrade steps. */
57
+ action: string;
58
+ /** `- old` / `+ new` lines for the rewritten specifiers. */
59
+ diff: string[];
60
+ /** Number of rewritten specifiers. */
61
+ count: number;
62
+ }
63
+ /**
64
+ * Rename pass over ONE config file. Returns `undefined` when the file is absent
65
+ * or already on the new names (idempotency: no write, no backup, no report
66
+ * line — the file stays byte-identical).
67
+ */
68
+ export declare function migrateAddonNamesInFile(path: string, surface: ConfigSurface, opts?: {
69
+ dryRun?: boolean;
70
+ }): AddonRenameResult | undefined;
71
+ /**
72
+ * Rename pass over every recognised config in the given `.gaia/` dirs (project
73
+ * + home). Emits report lines ONLY for files it actually rewrites, so an install
74
+ * already on `addon-*` adds no noise to the upgrade report.
75
+ */
76
+ export declare function runAddonRenameMigration(opts?: {
77
+ gaiaDirs: string[];
78
+ dryRun?: boolean;
79
+ }): {
80
+ actions: string[];
81
+ changed: boolean;
82
+ };