@bakers-build/core 0.8.0 → 0.8.1-next.10

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 (37) hide show
  1. package/dist/src/cli/bakers-dir.d.ts +8 -8
  2. package/dist/src/cli/bakers-dir.js +30 -33
  3. package/dist/src/cli/config-inventory.d.ts +2 -0
  4. package/dist/src/cli/config-inventory.js +45 -72
  5. package/dist/src/cli/config-report.d.ts +2 -2
  6. package/dist/src/cli/config-source.js +1 -1
  7. package/dist/src/cli/config-validate.d.ts +49 -0
  8. package/dist/src/cli/config-validate.js +400 -0
  9. package/dist/src/cli/import-config.d.ts +2 -2
  10. package/dist/src/cli/import-config.js +5 -5
  11. package/dist/src/cli/load-bakers-config.d.ts +2 -2
  12. package/dist/src/cli/load-bakers-config.js +20 -49
  13. package/dist/src/cli/machine-connection.d.ts +2 -0
  14. package/dist/src/cli/machine-connection.js +47 -0
  15. package/dist/src/cli/machine-context.d.ts +9 -12
  16. package/dist/src/cli/machine-context.js +12 -18
  17. package/dist/src/cli/version-check.d.ts +1 -1
  18. package/dist/src/cli/version-check.js +1 -1
  19. package/dist/src/config-types.generated.d.ts +175 -0
  20. package/dist/src/config-types.generated.js +3 -0
  21. package/dist/src/core/logger.d.ts +3 -3
  22. package/dist/src/core/logger.js +5 -5
  23. package/dist/src/core/proc.d.ts +1 -1
  24. package/dist/src/core/proc.js +8 -5
  25. package/dist/src/index.d.ts +4 -1
  26. package/dist/src/index.js +3 -3
  27. package/dist/src/plugins/discover-addons.d.ts +2 -2
  28. package/dist/src/plugins/discover-addons.js +9 -9
  29. package/dist/src/plugins/preset.d.ts +9 -20
  30. package/dist/src/plugins/preset.js +6 -6
  31. package/dist/src/plugins/scoped-addons.d.ts +5 -14
  32. package/dist/src/plugins/scoped-addons.js +11 -36
  33. package/package.json +6 -4
  34. package/schema/connection.schema.json +57 -0
  35. package/schema/harness-options.schema.json +78 -0
  36. package/schema/machine.schema.json +81 -0
  37. package/schema/project.schema.json +262 -0
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // The three bakers.build surfaces (each named for its config home):
10
10
  // - command → the `@bakers-build/bakers` host registry (CommandDescriptor[]).
11
- // - conductor → the run engine (remote / executor / workspace / agent /
11
+ // - conductor → the run engine (server / executor / worktree / agent /
12
12
  // lifecycle hook listeners).
13
13
  // - connection → dropsh (auth + renderer plugins).
14
14
  //
@@ -28,15 +28,15 @@
28
28
  /** The extension points each surface runs (the preset function names to call). */
29
29
  export const SURFACE_KEYS = {
30
30
  command: ['commands'],
31
- conductor: ['remotes', 'executors', 'workspaces', 'agents', 'hooks'],
31
+ conductor: ['servers', 'executors', 'worktrees', 'agents', 'hooks'],
32
32
  connection: ['connectionPlugins', 'uiEntries'],
33
33
  };
34
34
  /** The preset function keys, for shape-detection during discovery. */
35
35
  export const PRESET_FUNCTION_KEYS = [
36
36
  'commands',
37
- 'remotes',
37
+ 'servers',
38
38
  'executors',
39
- 'workspaces',
39
+ 'worktrees',
40
40
  'agents',
41
41
  'hooks',
42
42
  'connectionPlugins',
@@ -46,9 +46,9 @@ export const PRESET_FUNCTION_KEYS = [
46
46
  export function emptyContributions() {
47
47
  return {
48
48
  commands: [],
49
- remotes: [],
49
+ servers: [],
50
50
  executors: [],
51
- workspaces: [],
51
+ worktrees: [],
52
52
  agents: [],
53
53
  hooks: [],
54
54
  connectionPlugins: [],
@@ -18,22 +18,13 @@ export interface EffectiveAddon {
18
18
  /** The resolved preset module path. */
19
19
  key: string;
20
20
  }
21
- /** An entry listed in a scope its addon does not declare, or whose own
22
- * `with` its addon's `checkWith` rejects (`index` into that scope's list). */
21
+ /** An entry listed in a scope its addon does not declare. */
23
22
  export type AddonScopeFinding = {
24
23
  code: 'addon_scope_not_allowed';
25
24
  spec: string;
26
25
  path: string;
27
26
  scope: AddonScope;
28
27
  allowed: AddonScope[];
29
- } | {
30
- code: 'addon_with_invalid';
31
- spec: string;
32
- path: string;
33
- scope: AddonScope;
34
- index: number;
35
- key: string;
36
- message: string;
37
28
  };
38
29
  /**
39
30
  * Build the effective addon list from the machine and project scopes. An
@@ -51,19 +42,19 @@ export declare function scopeAddons(inputs: AddonScopeInput[], opts?: {
51
42
  /** Run `surface` over the effective list, each entry against its own bases. */
52
43
  export declare function discoverScoped(addons: EffectiveAddon[], surface: BbSurface, opts?: Omit<NonNullable<Parameters<typeof discoverAddons>[3]>, 'entryBases'>): Promise<DiscoveredContributions>;
53
44
  /**
54
- * `<BB_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
45
+ * `<BAKERS_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
55
46
  * given, still wins (a fixture that pins an explicit home) — but an absent one
56
47
  * must reach `homeBbDir()`'s resolver rather than collapsing to the OS home
57
- * first, or `BB_HOME` never relocates this file.
48
+ * first, or `BAKERS_HOME` never relocates this file.
58
49
  */
59
50
  export declare function machineUiConfigPath(home?: string): string;
60
- /** The nearest project `.bakers/conductor.config.js` above `cwd`, or undefined. */
51
+ /** The nearest project `.bakers/project.config.js` above `cwd`, or undefined. */
61
52
  export declare function projectConductorConfigPath(cwd: string, home?: string): string | undefined;
62
53
  /** A config file's `addons[]`, or `[]` when the file is absent or broken. */
63
54
  export declare function readConfigAddons(path: string): Promise<AddonEntry[]>;
64
55
  /**
65
56
  * The effective entry for one addon package from `machine.config.js` and the
66
- * nearest project `.bakers/conductor.config.js` above `cwd` (or `projectPath`).
57
+ * nearest project `.bakers/project.config.js` above `cwd` (or `projectPath`).
67
58
  * `bases` are appended to each scope's own (e.g. the caller's install).
68
59
  */
69
60
  export declare function readEffectiveAddon(spec: string, opts: {
@@ -1,5 +1,5 @@
1
1
  // The effective addon list: `~/.bakers/machine.config.js` and the project's
2
- // `.bakers/conductor.config.js` each carry one `addons[]`, read the same way.
2
+ // `.bakers/project.config.js` each carry one `addons[]`, read the same way.
3
3
  // The addon decides where it may be listed (its preset's `scopes`, default
4
4
  // both); an entry in a scope it does not declare is reported and not loaded.
5
5
  // The same addon (resolved module + alias) in both scopes becomes one entry
@@ -11,34 +11,18 @@ import { dirname, join } from 'node:path';
11
11
  import { pathToFileURL } from 'node:url';
12
12
  import { findConfigProjectBbDir, homeBbDir } from '../cli/bakers-dir.js';
13
13
  import { AddonUnresolvedError, discoverAddons, isRetiredAddon, loadAddonPreset, normalizeEntry, } from './discover-addons.js';
14
- /** The addon's own findings for one entry's `with`; a throwing check is one. */
15
- function checkEntryWith(preset, entry) {
16
- if (!preset.checkWith)
17
- return [];
18
- try {
19
- return preset.checkWith(entryWith(entry));
20
- }
21
- catch (error) {
22
- return [
23
- {
24
- key: '',
25
- message: `checkWith failed: ${error instanceof Error ? error.message : String(error)}`,
26
- },
27
- ];
28
- }
29
- }
30
14
  const ALL_SCOPES = ['machine', 'project'];
31
15
  const SCOPE_FILE = {
32
16
  machine: '~/.bakers/machine.config.js',
33
- project: '.bakers/conductor.config.js',
17
+ project: '.bakers/project.config.js',
34
18
  };
35
- /** The `with` an entry carries (`options` is its alias). */
19
+ /** The `with` an entry carries. */
36
20
  function entryWith(entry) {
37
21
  return normalizeEntry(entry).opts;
38
22
  }
39
23
  /** `entry` as a descriptor carrying `with` (or none when undefined). */
40
24
  function withReplaced(entry, value) {
41
- const { with: _with, options: _options, ...rest } = typeof entry === 'string' ? { use: entry } : entry;
25
+ const { with: _with, ...rest } = typeof entry === 'string' ? { use: entry } : entry;
42
26
  return value === undefined ? rest : { ...rest, with: value };
43
27
  }
44
28
  /**
@@ -62,7 +46,7 @@ export async function scopeAddons(inputs, opts = {}) {
62
46
  ...inputs.filter((i) => i.scope !== 'machine'),
63
47
  ];
64
48
  for (const input of ordered) {
65
- for (const [index, entry] of input.entries.entries()) {
49
+ for (const entry of input.entries) {
66
50
  const { spec, alias } = normalizeEntry(entry);
67
51
  if (isRetiredAddon(spec)) {
68
52
  // discoverAddons warns once and skips it.
@@ -101,15 +85,6 @@ export async function scopeAddons(inputs, opts = {}) {
101
85
  `be configured only in ${allowed.map((s) => SCOPE_FILE[s]).join(' or ')}.`);
102
86
  continue;
103
87
  }
104
- for (const problem of checkEntryWith(loaded.preset, entry))
105
- findings.push({
106
- code: 'addon_with_invalid',
107
- spec,
108
- path: input.path,
109
- scope: input.scope,
110
- index,
111
- ...problem,
112
- });
113
88
  const match = `${loaded.key}\0${alias ?? ''}`;
114
89
  const at = input.scope === 'project' ? machineAt.get(match) : undefined;
115
90
  if (at !== undefined) {
@@ -142,20 +117,20 @@ export function discoverScoped(addons, surface, opts = {}) {
142
117
  return discoverAddons(addons.map((a) => a.entry), surface, addons[0]?.bases ?? [], { ...opts, entryBases: addons.map((a) => a.bases) });
143
118
  }
144
119
  /**
145
- * `<BB_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
120
+ * `<BAKERS_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
146
121
  * given, still wins (a fixture that pins an explicit home) — but an absent one
147
122
  * must reach `homeBbDir()`'s resolver rather than collapsing to the OS home
148
- * first, or `BB_HOME` never relocates this file.
123
+ * first, or `BAKERS_HOME` never relocates this file.
149
124
  */
150
125
  export function machineUiConfigPath(home) {
151
126
  return join(homeBbDir(home), 'machine.config.js');
152
127
  }
153
- /** The nearest project `.bakers/conductor.config.js` above `cwd`, or undefined. */
128
+ /** The nearest project `.bakers/project.config.js` above `cwd`, or undefined. */
154
129
  export function projectConductorConfigPath(cwd, home) {
155
130
  const bakersDir = findConfigProjectBbDir(cwd, home);
156
131
  if (bakersDir === undefined)
157
132
  return undefined;
158
- const path = join(dirname(bakersDir), '.bakers', 'conductor.config.js');
133
+ const path = join(dirname(bakersDir), '.bakers', 'project.config.js');
159
134
  return existsSync(path) ? path : undefined;
160
135
  }
161
136
  /** A config file's `addons[]`, or `[]` when the file is absent or broken. */
@@ -174,7 +149,7 @@ export async function readConfigAddons(path) {
174
149
  }
175
150
  /**
176
151
  * The effective entry for one addon package from `machine.config.js` and the
177
- * nearest project `.bakers/conductor.config.js` above `cwd` (or `projectPath`).
152
+ * nearest project `.bakers/project.config.js` above `cwd` (or `projectPath`).
178
153
  * `bases` are appended to each scope's own (e.g. the caller's install).
179
154
  */
180
155
  export async function readEffectiveAddon(spec, opts) {
@@ -202,7 +177,7 @@ export async function readEffectiveAddon(spec, opts) {
202
177
  });
203
178
  // Only this addon's entries: an unrelated broken entry must not block it.
204
179
  for (const input of inputs)
205
- input.entries = input.entries.filter((e) => (typeof e === 'string' ? e : (e?.use ?? e?.name)) === spec);
180
+ input.entries = input.entries.filter((e) => (typeof e === 'string' ? e : e?.use) === spec);
206
181
  const { addons } = await scopeAddons(inputs, { unresolved: 'skip' });
207
182
  return addons[0];
208
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.1-next.10",
4
4
  "description": "bakers.build surface-agnostic kernel: host contract, split-config helpers, addon preset/discovery machinery, shared primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,10 +10,12 @@
10
10
  "exports": {
11
11
  ".": "./dist/src/index.js",
12
12
  "./conductor-registry": "./dist/src/conductor-registry/index.js",
13
- "./package.json": "./package.json"
13
+ "./package.json": "./package.json",
14
+ "./schema/*": "./schema/*"
14
15
  },
15
16
  "files": [
16
17
  "dist/src",
18
+ "schema",
17
19
  "README.md",
18
20
  "LICENSE"
19
21
  ],
@@ -38,7 +40,7 @@
38
40
  "yaml": "^2.7.0"
39
41
  },
40
42
  "bakersBuild": {
41
- "commit": "082d8c57436f78e751f5a9a26a4446cec42209ce",
42
- "channel": "latest"
43
+ "commit": "ceb44a12624feaa85cb2b0c9f84345399b38bf50",
44
+ "channel": "next"
43
45
  }
44
46
  }
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/connection.schema.json",
4
+ "title": "ConnectionConfig",
5
+ "description": "A connection to a bakers.build server: ~/.bakers/connections/<id>.js, or a project's .bakers/connection.config.js. dropsh reads the same file.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "const": 1,
10
+ "description": "Configuration schema version."
11
+ },
12
+ "site": {
13
+ "type": "object",
14
+ "properties": {
15
+ "base_url": {
16
+ "type": "string",
17
+ "pattern": "^https?://[^\\s/]+",
18
+ "description": "The server's absolute HTTP(S) URL."
19
+ },
20
+ "jsonapi_prefix": {
21
+ "type": "string",
22
+ "description": "JSON:API path prefix. Default /jsonapi."
23
+ }
24
+ },
25
+ "required": ["base_url"],
26
+ "additionalProperties": false
27
+ },
28
+ "workspace_id": {
29
+ "type": "string",
30
+ "description": "Workspace bakers ui starts focused on."
31
+ },
32
+ "plugins": {
33
+ "type": "array",
34
+ "description": "dropsh plugins: { plugin, export?, with?, options? }, or constructed plugins.",
35
+ "items": {
36
+ "if": { "type": "object", "required": ["plugin"] },
37
+ "then": {
38
+ "properties": {
39
+ "plugin": { "$ref": "project.schema.json#/$defs/nonempty" },
40
+ "export": { "$ref": "project.schema.json#/$defs/nonempty" },
41
+ "with": {},
42
+ "options": {}
43
+ },
44
+ "additionalProperties": false
45
+ },
46
+ "else": { "type": "object" }
47
+ }
48
+ },
49
+ "addons": {
50
+ "type": "array",
51
+ "description": "Connection addons, such as auth providers.",
52
+ "items": { "$ref": "project.schema.json#/$defs/addon" }
53
+ }
54
+ },
55
+ "required": ["site"],
56
+ "additionalProperties": false
57
+ }
@@ -0,0 +1,78 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/harness-options.schema.json",
4
+ "title": "Options every agent harness takes",
5
+ "description": "Composed by each harness addon's options.schema.json, which adds its own keys and rejects unknown ones with unevaluatedProperties: false.",
6
+ "type": "object",
7
+ "properties": {
8
+ "args": {
9
+ "type": "array",
10
+ "items": {
11
+ "type": "string"
12
+ },
13
+ "description": "Extra command-line arguments appended to the agent launch, each shell-quoted.",
14
+ "default": []
15
+ },
16
+ "model": {
17
+ "type": "string",
18
+ "description": "Model the agent runs."
19
+ },
20
+ "effort": {
21
+ "type": "string",
22
+ "description": "Reasoning effort the agent runs at."
23
+ },
24
+ "permissions": {
25
+ "enum": [
26
+ "sandbox",
27
+ "system",
28
+ "yolo",
29
+ "custom"
30
+ ],
31
+ "description": "Permission mode: how strictly a run starts; see the addon's Security section.",
32
+ "default": "system"
33
+ },
34
+ "sandbox": {
35
+ "type": "object",
36
+ "description": "Sandbox lists; only valid with `permissions: 'sandbox'`. Each key set replaces its default; lists are not merged.",
37
+ "properties": {
38
+ "trusted_commands": {
39
+ "$ref": "#/$defs/string_list",
40
+ "description": "Commands that run outside the sandbox."
41
+ },
42
+ "deny_read": {
43
+ "$ref": "#/$defs/string_list",
44
+ "description": "Paths the agent may not read."
45
+ },
46
+ "allow_write": {
47
+ "$ref": "#/$defs/string_list",
48
+ "description": "Paths the agent may write besides the worktree and the temporary directory."
49
+ },
50
+ "network": {
51
+ "$ref": "#/$defs/string_list",
52
+ "description": "Hosts the agent may reach; `*` allows every host."
53
+ },
54
+ "mcp_servers": {
55
+ "type": "object",
56
+ "description": "MCP servers of a sandboxed run, in the agent's own shape; the `bakers` server is always added."
57
+ }
58
+ },
59
+ "additionalProperties": false
60
+ },
61
+ "config": {
62
+ "type": "object",
63
+ "description": "The agent's own permission configuration; required with, and only valid with, `permissions: 'custom'`."
64
+ },
65
+ "env_deny": {
66
+ "$ref": "#/$defs/string_list",
67
+ "description": "Ticket environment variable names (`*` globs) removed from the run environment; replaces the default list."
68
+ }
69
+ },
70
+ "$defs": {
71
+ "string_list": {
72
+ "type": "array",
73
+ "items": {
74
+ "type": "string"
75
+ }
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/machine.schema.json",
4
+ "title": "MachineConfig",
5
+ "description": "This machine's private configuration: ~/.bakers/machine.config.js.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "const": 1,
10
+ "description": "Configuration schema version."
11
+ },
12
+ "machine_id": {
13
+ "$ref": "project.schema.json#/$defs/nonempty",
14
+ "description": "Host key; bakers init writes a UUID."
15
+ },
16
+ "label": {
17
+ "$ref": "project.schema.json#/$defs/nonempty",
18
+ "description": "Display name for people."
19
+ },
20
+ "connection_url": {
21
+ "anyOf": [{ "type": "string" }, { "type": "null" }],
22
+ "description": "Public SSH or HTTPS connection address; null clears it at the next conductor start."
23
+ },
24
+ "agents": {
25
+ "type": "object",
26
+ "description": "Selection policy for the agents the addons contribute.",
27
+ "properties": {
28
+ "catalog": {
29
+ "type": "array",
30
+ "description": "Extra agent variants built from installed harnesses.",
31
+ "items": {
32
+ "type": "object",
33
+ "properties": {
34
+ "harness": { "$ref": "project.schema.json#/$defs/nonempty" },
35
+ "alias": { "$ref": "project.schema.json#/$defs/nonempty" },
36
+ "with": { "description": "The harness options." }
37
+ },
38
+ "required": ["harness"],
39
+ "additionalProperties": false
40
+ }
41
+ },
42
+ "enabled": { "$ref": "#/$defs/alias_list" },
43
+ "disabled": { "$ref": "#/$defs/alias_list" },
44
+ "routes": {
45
+ "type": "object",
46
+ "description": "Named routes from states (or *) to aliases; routes.default is the automatic one.",
47
+ "additionalProperties": {
48
+ "type": "object",
49
+ "minProperties": 1,
50
+ "additionalProperties": {
51
+ "$ref": "project.schema.json#/$defs/nonempty"
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "additionalProperties": false
57
+ },
58
+ "addons": {
59
+ "type": "array",
60
+ "description": "Addons this machine uses.",
61
+ "items": { "$ref": "project.schema.json#/$defs/addon" }
62
+ },
63
+ "tunnel": {
64
+ "type": "boolean",
65
+ "description": "Share local preview links through bakers ports. Default false."
66
+ },
67
+ "permissions": { "$ref": "project.schema.json#/$defs/permissions" },
68
+ "executor": {
69
+ "$ref": "project.schema.json#/$defs/slot",
70
+ "description": "This machine's executor; overrides every project's."
71
+ }
72
+ },
73
+ "required": ["machine_id", "label"],
74
+ "additionalProperties": false,
75
+ "$defs": {
76
+ "alias_list": {
77
+ "type": "array",
78
+ "items": { "$ref": "project.schema.json#/$defs/nonempty" }
79
+ }
80
+ }
81
+ }