@bakers-build/core 0.9.1-next.4 → 0.9.1-next.6
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.
- package/dist/src/cli/config-online.d.ts +2 -0
- package/dist/src/cli/config-online.js +19 -2
- package/dist/src/cli/config-report.d.ts +2 -0
- package/dist/src/cli/load-bakers-config.d.ts +2 -0
- package/dist/src/cli/load-bakers-config.js +1 -0
- package/dist/src/config-types.generated.d.ts +17 -0
- package/dist/src/core/exec.d.ts +3 -0
- package/dist/src/core/exec.js +8 -2
- package/dist/src/core/git-sandbox.d.ts +1 -1
- package/dist/src/core/git-sandbox.js +4 -1
- package/dist/src/core/isolated-git.d.ts +14 -0
- package/dist/src/core/isolated-git.js +249 -0
- package/dist/src/core/protected-project-paths.d.ts +2 -0
- package/dist/src/core/protected-project-paths.js +35 -0
- package/dist/src/core/run-clone.d.ts +46 -0
- package/dist/src/core/run-clone.js +177 -0
- package/dist/src/core/runtime-paths.d.ts +2 -0
- package/dist/src/core/runtime-paths.js +17 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.js +5 -1
- package/dist/src/plugins/discover-addons.d.ts +7 -3
- package/dist/src/plugins/discover-addons.js +5 -1
- package/dist/src/plugins/preset.d.ts +4 -1
- package/dist/src/plugins/preset.js +10 -1
- package/dist/src/plugins/scoped-addons.d.ts +14 -0
- package/dist/src/plugins/scoped-addons.js +133 -61
- package/package.json +2 -2
- package/schema/connection.schema.json +4 -0
- package/schema/project.schema.json +28 -0
|
@@ -11,6 +11,7 @@ export declare function createBbConnectionContext(connection: Pick<BbConnectionC
|
|
|
11
11
|
cwd?: string;
|
|
12
12
|
profile?: string;
|
|
13
13
|
auth?: AuthAdapter;
|
|
14
|
+
signal?: AbortSignal;
|
|
14
15
|
/** Decorates the transport, e.g. to filter responses for agent reads. */
|
|
15
16
|
wrapHttp?: (http: HttpClient) => HttpClient;
|
|
16
17
|
}): Promise<import('dropsh').CommandContext>;
|
|
@@ -18,6 +19,7 @@ export declare function createBbConnectionClient(connection: Pick<BbConnectionCo
|
|
|
18
19
|
stateDir?: string;
|
|
19
20
|
http?: HttpClient;
|
|
20
21
|
auth?: AuthAdapter;
|
|
22
|
+
signal?: AbortSignal;
|
|
21
23
|
}): Promise<JsonApiClient>;
|
|
22
24
|
/**
|
|
23
25
|
* Whether a session is already stored for the selected connection.
|
|
@@ -19,8 +19,25 @@ export async function createBbConnectionContext(connection, options = {}) {
|
|
|
19
19
|
// dropsh's client retries every request after a network failure; a
|
|
20
20
|
// re-sent POST created the same entity up to four times. Reads keep the
|
|
21
21
|
// retries; a write is sent once and its failure stays uncertain.
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const signal = options.signal;
|
|
23
|
+
const cancellable = signal
|
|
24
|
+
? {
|
|
25
|
+
// dropsh retries aborted requests; a cancellable operation must stop immediately.
|
|
26
|
+
maxRetries: 0,
|
|
27
|
+
fetch: ((input, init) => {
|
|
28
|
+
signal.throwIfAborted();
|
|
29
|
+
return fetch(input, {
|
|
30
|
+
...init,
|
|
31
|
+
signal: AbortSignal.any([
|
|
32
|
+
signal,
|
|
33
|
+
...(init?.signal ? [init.signal] : []),
|
|
34
|
+
]),
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
}
|
|
38
|
+
: {};
|
|
39
|
+
const reads = createHttpClient(cancellable);
|
|
40
|
+
const writes = createHttpClient({ ...cancellable, maxRetries: 0 });
|
|
24
41
|
const transport = options.http ?? {
|
|
25
42
|
send: (request) => (request.method === 'GET' ? reads : writes).send(request),
|
|
26
43
|
};
|
|
@@ -80,6 +80,8 @@ export interface ConfigReport {
|
|
|
80
80
|
* is then discovered from `addons[]`).
|
|
81
81
|
*/
|
|
82
82
|
executor_source?: string;
|
|
83
|
+
/** Resolved project slot package names, including nested preset origins. */
|
|
84
|
+
slot_sources?: Record<string, string>;
|
|
83
85
|
verification: {
|
|
84
86
|
offline: {
|
|
85
87
|
status: 'passed' | 'blocked' | 'incomplete';
|
|
@@ -22,6 +22,8 @@ export interface BbConnectionConfig {
|
|
|
22
22
|
jsonapi_prefix: string;
|
|
23
23
|
};
|
|
24
24
|
plugins: DropSHPlugin[];
|
|
25
|
+
/** The conductor server slot, as written; the conductor resolves it. */
|
|
26
|
+
server?: unknown;
|
|
25
27
|
/**
|
|
26
28
|
* BB-351: the uuid of the `bb_workspace` this connection is focused on.
|
|
27
29
|
* BB-495: optional. `bakers dropsh` needs none — the caller names the
|
|
@@ -346,6 +346,7 @@ export async function loadBbConnectionBootstrap(host, opts = {}) {
|
|
|
346
346
|
return {
|
|
347
347
|
site: { base_url: baseUrl, jsonapi_prefix: jsonapiPrefix },
|
|
348
348
|
plugins,
|
|
349
|
+
...(raw.server !== undefined ? { server: raw.server } : {}),
|
|
349
350
|
workspace_id: workspaceId || undefined,
|
|
350
351
|
config_path: configPath,
|
|
351
352
|
fallback: resolution.fallback,
|
|
@@ -79,6 +79,10 @@ export interface ProjectConfig {
|
|
|
79
79
|
provision_up?: string | {
|
|
80
80
|
[key: string]: string;
|
|
81
81
|
};
|
|
82
|
+
/** Commands by key, offered to runs as provision_exec(key, args). Arguments follow the command as argv, never through a shell. */
|
|
83
|
+
provision_exec?: {
|
|
84
|
+
[key: string]: string;
|
|
85
|
+
};
|
|
82
86
|
};
|
|
83
87
|
/** Agent plugin marketplaces every run of this project installs. */
|
|
84
88
|
marketplaces?: Array<{
|
|
@@ -90,6 +94,9 @@ export interface ProjectConfig {
|
|
|
90
94
|
}>;
|
|
91
95
|
/** Function choosing the agent for a ticket; replaces the shipped selection. */
|
|
92
96
|
select_agent?: (...args: never[]) => unknown;
|
|
97
|
+
runtime?: {
|
|
98
|
+
read_only?: Array<string>;
|
|
99
|
+
};
|
|
93
100
|
}
|
|
94
101
|
/** This machine's private configuration: ~/.bakers/machine.config.js. */
|
|
95
102
|
export interface MachineConfig {
|
|
@@ -164,6 +171,16 @@ export interface ConnectionConfig {
|
|
|
164
171
|
plugins?: Array<unknown | {
|
|
165
172
|
[key: string]: unknown;
|
|
166
173
|
}>;
|
|
174
|
+
/** Conductor server slot for this connection; a project server slot or server addon wins. Default @bakers-build/addon-remote-drupal. */
|
|
175
|
+
server?: {
|
|
176
|
+
kind: string;
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
} | {
|
|
179
|
+
use: string;
|
|
180
|
+
export?: string;
|
|
181
|
+
/** Options passed to the factory. */
|
|
182
|
+
with?: unknown;
|
|
183
|
+
};
|
|
167
184
|
/** Connection addons, such as auth providers. */
|
|
168
185
|
addons?: Array<string | {
|
|
169
186
|
use: string;
|
package/dist/src/core/exec.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class ExecError extends Error {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
export interface ExecOpts {
|
|
12
|
+
signal?: AbortSignal;
|
|
12
13
|
cwd?: string;
|
|
13
14
|
env?: Record<string, string>;
|
|
14
15
|
/**
|
|
@@ -19,6 +20,8 @@ export interface ExecOpts {
|
|
|
19
20
|
* secret to the log.
|
|
20
21
|
*/
|
|
21
22
|
redactArgs?: (args: string[]) => string[];
|
|
23
|
+
/** Written to the child's stdin, which is then closed. */
|
|
24
|
+
input?: string;
|
|
22
25
|
}
|
|
23
26
|
export declare class CommandRunner {
|
|
24
27
|
private readonly logger;
|
package/dist/src/core/exec.js
CHANGED
|
@@ -32,16 +32,22 @@ export class CommandRunner {
|
|
|
32
32
|
// for logging only; the real args are still executed verbatim.
|
|
33
33
|
const logArgs = opts.redactArgs ? opts.redactArgs(args) : args;
|
|
34
34
|
try {
|
|
35
|
-
const { env, redactArgs: _redact, ...rest } = opts;
|
|
35
|
+
const { env, redactArgs: _redact, input, ...rest } = opts;
|
|
36
36
|
// Merge over process.env, never replace it: a caller-supplied env adds/
|
|
37
37
|
// overrides keys but the child still inherits PATH etc. Values may be
|
|
38
38
|
// sensitive (BB-99) — never log them; only cwd is logged below.
|
|
39
39
|
const childEnv = env ? { ...process.env, ...env } : undefined;
|
|
40
|
-
const
|
|
40
|
+
const pending = execFileAsync(file, args, {
|
|
41
41
|
encoding: 'utf8',
|
|
42
42
|
...rest,
|
|
43
43
|
...(childEnv ? { env: childEnv } : {}),
|
|
44
44
|
});
|
|
45
|
+
if (input !== undefined) {
|
|
46
|
+
// A child that exits before reading gives EPIPE; its exit status rejects below.
|
|
47
|
+
pending.child.stdin?.on('error', () => { });
|
|
48
|
+
pending.child.stdin?.end(input);
|
|
49
|
+
}
|
|
50
|
+
const { stdout } = await pending;
|
|
45
51
|
this.logger.debug({ file, args: logArgs, cwd: opts.cwd }, 'exec ok');
|
|
46
52
|
return stdout;
|
|
47
53
|
}
|
|
@@ -10,7 +10,7 @@ export interface GitSandboxPaths {
|
|
|
10
10
|
* Only existing paths are named: a sandbox mounts over a missing protected
|
|
11
11
|
* path by creating an empty placeholder in the real repository.
|
|
12
12
|
*/
|
|
13
|
-
export declare function gitSandboxPaths(workspacePath: string): GitSandboxPaths;
|
|
13
|
+
export declare function gitSandboxPaths(workspacePath: string, isolated?: boolean): GitSandboxPaths;
|
|
14
14
|
/**
|
|
15
15
|
* `allow_write` without entries that are, or lie inside, a `.git` directory:
|
|
16
16
|
* granting one whole makes the sandbox protect metadata inside it, which it
|
|
@@ -31,7 +31,10 @@ function revParse(workspacePath, option) {
|
|
|
31
31
|
* Only existing paths are named: a sandbox mounts over a missing protected
|
|
32
32
|
* path by creating an empty placeholder in the real repository.
|
|
33
33
|
*/
|
|
34
|
-
export function gitSandboxPaths(workspacePath) {
|
|
34
|
+
export function gitSandboxPaths(workspacePath, isolated = false) {
|
|
35
|
+
// A run clone: its Git directory is mounted there, and the host asks Git nothing.
|
|
36
|
+
if (isolated)
|
|
37
|
+
return { write: [join(workspacePath, '.git')], protect: [] };
|
|
35
38
|
const gitDir = revParse(workspacePath, '--git-dir');
|
|
36
39
|
if (gitDir === null)
|
|
37
40
|
return { write: [], protect: [] };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RunClone } from './run-clone.js';
|
|
2
|
+
/** The run's ticket branch tip, read as plain files: Git never runs under the run's config. */
|
|
3
|
+
export declare function runCloneTip(record: RunClone): string;
|
|
4
|
+
/**
|
|
5
|
+
* Give the run the parent's current `origin/<branch>` refs (default: its
|
|
6
|
+
* target): objects as one new pack, each ref as a plain file. Nothing here
|
|
7
|
+
* runs Git inside the run's directory.
|
|
8
|
+
*/
|
|
9
|
+
export declare function refreshRunTarget(record: RunClone, branches?: readonly string[]): void;
|
|
10
|
+
/**
|
|
11
|
+
* Import verified objects through clean metadata and fast-forward the ticket
|
|
12
|
+
* branch in the parent with compare-and-swap. Defaults to the run's branch tip.
|
|
13
|
+
*/
|
|
14
|
+
export declare function transferIsolatedCommit(record: RunClone, commit?: string): string;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, posix, sep } from 'node:path';
|
|
5
|
+
const git = (cwd, ...args) => execFileSync('git', args, {
|
|
6
|
+
cwd,
|
|
7
|
+
encoding: 'utf8',
|
|
8
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
9
|
+
}).trim();
|
|
10
|
+
function normalizeProtectedPaths(paths) {
|
|
11
|
+
return [
|
|
12
|
+
...new Set(['.bakers', ...paths].map((path) => {
|
|
13
|
+
if (!path ||
|
|
14
|
+
path.startsWith('/') ||
|
|
15
|
+
path.includes('\0') ||
|
|
16
|
+
path.includes('\\') ||
|
|
17
|
+
path.includes(':') ||
|
|
18
|
+
path.split('/').includes('..'))
|
|
19
|
+
throw new Error(`isolated Git: invalid protected path ${path}`);
|
|
20
|
+
const normalized = posix.normalize(path).replace(/\/$/, '');
|
|
21
|
+
if (normalized === '.')
|
|
22
|
+
throw new Error(`isolated Git: invalid protected path ${path}`);
|
|
23
|
+
return normalized;
|
|
24
|
+
})),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function rejectGitlinks(entries) {
|
|
28
|
+
if (entries.split('\0').some((entry) => entry.startsWith('160000 ')))
|
|
29
|
+
throw new Error('isolated Git: submodules are not supported');
|
|
30
|
+
}
|
|
31
|
+
/** Read object bytes without following a run-planted symlink, including raced ancestors. */
|
|
32
|
+
function copyObjects(source, target) {
|
|
33
|
+
if (!lstatSync(source).isDirectory() || realpathSync(source) !== source)
|
|
34
|
+
throw new Error('isolated Git: invalid object store');
|
|
35
|
+
const root = source;
|
|
36
|
+
const copy = (from, to) => {
|
|
37
|
+
// O_NONBLOCK: a FIFO the run planted must fail the isFile check, not block the open.
|
|
38
|
+
const fd = openSync(from, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
39
|
+
try {
|
|
40
|
+
const actual = realpathSync(`/proc/self/fd/${fd}`);
|
|
41
|
+
if (!actual.startsWith(root + sep) || !fstatSync(fd).isFile())
|
|
42
|
+
throw new Error('isolated Git: object escaped its private store');
|
|
43
|
+
writeFileSync(to, readFileSync(fd), { flag: 'wx' });
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
closeSync(fd);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
for (const name of readdirSync(source)) {
|
|
50
|
+
if (name === 'info')
|
|
51
|
+
continue; // Never import alternates or source-side configuration.
|
|
52
|
+
if (name !== 'pack' && !/^[a-f0-9]{2}$/.test(name))
|
|
53
|
+
continue;
|
|
54
|
+
const from = join(source, name);
|
|
55
|
+
if (!lstatSync(from).isDirectory())
|
|
56
|
+
throw new Error('isolated Git: invalid object directory');
|
|
57
|
+
mkdirSync(join(target, name), { recursive: true });
|
|
58
|
+
for (const file of readdirSync(from)) {
|
|
59
|
+
const valid = name === 'pack'
|
|
60
|
+
? /^pack-[a-f0-9]{40,64}\.(pack|idx|rev)$/.test(file)
|
|
61
|
+
: /^[a-f0-9]{38}$|^[a-f0-9]{62}$/.test(file);
|
|
62
|
+
if (!valid)
|
|
63
|
+
continue; // Auxiliary indexes and retention markers are not objects.
|
|
64
|
+
copy(join(from, file), join(target, name, file));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// shortcut: /proc/self/fd pins directories against swapped symlinks, Linux only; use openat when another host OS runs isolating runtimes.
|
|
69
|
+
/** Open `rel` below `root` one component at a time, never through a link the run planted. */
|
|
70
|
+
function pinDir(root, rel, create = false) {
|
|
71
|
+
const flags = constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW;
|
|
72
|
+
let fd = openSync(root, flags);
|
|
73
|
+
for (const part of rel.split('/').filter(Boolean)) {
|
|
74
|
+
const next = `/proc/self/fd/${fd}/${part}`;
|
|
75
|
+
try {
|
|
76
|
+
if (part === '..')
|
|
77
|
+
throw new Error('isolated Git: invalid path');
|
|
78
|
+
if (create && !existsSync(next))
|
|
79
|
+
mkdirSync(next);
|
|
80
|
+
const child = openSync(next, flags);
|
|
81
|
+
closeSync(fd);
|
|
82
|
+
fd = child;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
closeSync(fd);
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return fd;
|
|
90
|
+
}
|
|
91
|
+
/** A small file below the run's Git directory; `undefined` when it does not exist. */
|
|
92
|
+
function readRunFile(root, path) {
|
|
93
|
+
let dir;
|
|
94
|
+
try {
|
|
95
|
+
dir = pinDir(root, posix.dirname(path));
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err.code === 'ENOENT')
|
|
99
|
+
return undefined;
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const fd = openSync(`/proc/self/fd/${dir}/${posix.basename(path)}`, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
104
|
+
try {
|
|
105
|
+
if (!fstatSync(fd).isFile())
|
|
106
|
+
throw new Error(`isolated Git: ${path} is not a file`);
|
|
107
|
+
return readFileSync(fd, 'utf8');
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
closeSync(fd);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (err.code === 'ENOENT')
|
|
115
|
+
return undefined;
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
closeSync(dir);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const HASH = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
|
|
123
|
+
/** The run's ticket branch tip, read as plain files: Git never runs under the run's config. */
|
|
124
|
+
export function runCloneTip(record) {
|
|
125
|
+
const ref = `refs/heads/${record.branch}`;
|
|
126
|
+
if (readRunFile(record.gitDir, 'HEAD')?.trim() !== `ref: ${ref}`)
|
|
127
|
+
throw new Error('isolated Git: the run left its ticket branch');
|
|
128
|
+
const tip = readRunFile(record.gitDir, ref)?.trim() ??
|
|
129
|
+
readRunFile(record.gitDir, 'packed-refs')
|
|
130
|
+
?.split('\n')
|
|
131
|
+
.find((line) => line.endsWith(` ${ref}`))
|
|
132
|
+
?.split(' ')[0];
|
|
133
|
+
if (!tip || !HASH.test(tip))
|
|
134
|
+
throw new Error('isolated Git: the run ticket branch has no readable tip');
|
|
135
|
+
return tip;
|
|
136
|
+
}
|
|
137
|
+
/** The parent's tip of a branch as the run sees it under `origin/`. */
|
|
138
|
+
function parentOrigin(record, branch) {
|
|
139
|
+
for (const ref of [`refs/remotes/origin/${branch}`, `refs/heads/${branch}`]) {
|
|
140
|
+
try {
|
|
141
|
+
return git(record.parentGitDir, `--git-dir=${record.parentGitDir}`, 'rev-parse', '--verify', '--quiet', `${ref}^{commit}`);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// Try the next spelling.
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
/** One ref of the run's clone, written as a plain file below pinned directories. */
|
|
150
|
+
function writeRunRef(record, ref, tip) {
|
|
151
|
+
const dir = pinDir(record.gitDir, posix.dirname(ref), true);
|
|
152
|
+
try {
|
|
153
|
+
const fd = openSync(`/proc/self/fd/${dir}/${posix.basename(ref)}`, constants.O_WRONLY |
|
|
154
|
+
constants.O_CREAT |
|
|
155
|
+
constants.O_TRUNC |
|
|
156
|
+
constants.O_NOFOLLOW, 0o644);
|
|
157
|
+
try {
|
|
158
|
+
writeFileSync(fd, `${tip}\n`);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
closeSync(fd);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
closeSync(dir);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Give the run the parent's current `origin/<branch>` refs (default: its
|
|
170
|
+
* target): objects as one new pack, each ref as a plain file. Nothing here
|
|
171
|
+
* runs Git inside the run's directory.
|
|
172
|
+
*/
|
|
173
|
+
export function refreshRunTarget(record, branches = record.target ? [record.target] : []) {
|
|
174
|
+
const tips = branches.flatMap((branch) => {
|
|
175
|
+
git(record.parentGitDir, 'check-ref-format', `refs/heads/${branch}`);
|
|
176
|
+
const tip = parentOrigin(record, branch);
|
|
177
|
+
return tip ? [{ branch, tip }] : [];
|
|
178
|
+
});
|
|
179
|
+
if (tips.length === 0)
|
|
180
|
+
return;
|
|
181
|
+
// pack-objects renames its pack from the parent's objects dir; /tmp may be another filesystem (EXDEV).
|
|
182
|
+
const scratch = mkdtempSync(join(record.parentGitDir, 'bb-target-refresh-'));
|
|
183
|
+
try {
|
|
184
|
+
execFileSync('git', [
|
|
185
|
+
`--git-dir=${record.parentGitDir}`,
|
|
186
|
+
'pack-objects',
|
|
187
|
+
'--quiet',
|
|
188
|
+
'--revs',
|
|
189
|
+
join(scratch, 'pack'),
|
|
190
|
+
], {
|
|
191
|
+
input: `${tips.map(({ tip }) => tip).join('\n')}\n^${record.expected}\n`,
|
|
192
|
+
stdio: ['pipe', 'ignore', 'pipe'],
|
|
193
|
+
});
|
|
194
|
+
const pack = pinDir(record.gitDir, 'objects/pack', true);
|
|
195
|
+
try {
|
|
196
|
+
for (const file of readdirSync(scratch)) {
|
|
197
|
+
try {
|
|
198
|
+
writeFileSync(`/proc/self/fd/${pack}/${file}`, readFileSync(join(scratch, file)), { flag: 'wx', mode: 0o444 });
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
if (err.code !== 'EEXIST')
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
closeSync(pack);
|
|
208
|
+
}
|
|
209
|
+
for (const { branch, tip } of tips)
|
|
210
|
+
writeRunRef(record, `refs/remotes/origin/${branch}`, tip);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Import verified objects through clean metadata and fast-forward the ticket
|
|
218
|
+
* branch in the parent with compare-and-swap. Defaults to the run's branch tip.
|
|
219
|
+
*/
|
|
220
|
+
export function transferIsolatedCommit(record, commit = runCloneTip(record)) {
|
|
221
|
+
if (!HASH.test(commit))
|
|
222
|
+
throw new Error('isolated Git: transfer requires a full commit hash');
|
|
223
|
+
if (commit === record.expected)
|
|
224
|
+
return commit;
|
|
225
|
+
const parent = (...args) => git(record.parentGitDir, `--git-dir=${record.parentGitDir}`, ...args);
|
|
226
|
+
const scratch = mkdtempSync(join(tmpdir(), 'bb-commit-transfer-'));
|
|
227
|
+
try {
|
|
228
|
+
git(scratch, 'init', '--bare', '--template=', `--object-format=${commit.length === 64 ? 'sha256' : 'sha1'}`, '-q');
|
|
229
|
+
// History the parent already holds is read from there, never from the run.
|
|
230
|
+
mkdirSync(join(scratch, 'objects/info'), { recursive: true });
|
|
231
|
+
writeFileSync(join(scratch, 'objects/info/alternates'), `${join(record.parentGitDir, 'objects')}\n`);
|
|
232
|
+
copyObjects(join(record.gitDir, 'objects'), join(scratch, 'objects'));
|
|
233
|
+
git(scratch, 'fsck', '--strict', '--no-reflogs', '--no-dangling', commit);
|
|
234
|
+
if (git(scratch, 'cat-file', '-t', commit) !== 'commit')
|
|
235
|
+
throw new Error('isolated Git: transfer requires a commit');
|
|
236
|
+
rejectGitlinks(git(scratch, 'ls-tree', '-r', '-z', commit));
|
|
237
|
+
git(scratch, 'merge-base', '--is-ancestor', record.expected, commit);
|
|
238
|
+
// Against the tip the run started from, so a merge of the target passes.
|
|
239
|
+
if (git(scratch, 'diff-tree', '-r', '--name-only', '-z', '--no-renames', record.expected, commit, '--', ...normalizeProtectedPaths(record.protectedPaths ?? []).map((path) => `:(literal)${path}`)))
|
|
240
|
+
throw new Error(`isolated Git: commit ${commit} changes a protected path`);
|
|
241
|
+
// Only scratch's clean config is read; the run's hooks/config never reach host Git.
|
|
242
|
+
parent('-c', 'protocol.file.allow=always', 'fetch', '--no-tags', '--no-write-fetch-head', scratch, commit);
|
|
243
|
+
parent('update-ref', `refs/heads/${record.branch}`, commit, record.expected);
|
|
244
|
+
return commit;
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
/** Protect top-level entries so writable ancestors cannot rename protected files. */
|
|
4
|
+
export function protectedProjectPaths(workspace, paths) {
|
|
5
|
+
const root = realpathSync(workspace);
|
|
6
|
+
const protectedRoots = [
|
|
7
|
+
...new Set(['.bakers', ...paths].map((path) => {
|
|
8
|
+
if (!path ||
|
|
9
|
+
path.startsWith('/') ||
|
|
10
|
+
path.split(/[\\/]/).includes('..') ||
|
|
11
|
+
path.includes('\0'))
|
|
12
|
+
throw new Error(`Invalid protected project path: ${path}`);
|
|
13
|
+
const absolute = resolve(root, path);
|
|
14
|
+
const actual = realpathSync(absolute);
|
|
15
|
+
if (!actual.startsWith(root + sep) || actual !== absolute)
|
|
16
|
+
throw new Error(`Protected project path escapes or redirects its worktree: ${path}`);
|
|
17
|
+
return join(root, relative(root, absolute).split(sep)[0]);
|
|
18
|
+
})),
|
|
19
|
+
];
|
|
20
|
+
const scan = (path) => {
|
|
21
|
+
const stat = lstatSync(path);
|
|
22
|
+
if (stat.isSymbolicLink())
|
|
23
|
+
throw new Error(`Protected project tree contains a symlink: ${path}`);
|
|
24
|
+
if (!stat.isFile() && !stat.isDirectory())
|
|
25
|
+
throw new Error(`Protected project tree contains an unsupported file type: ${path}`);
|
|
26
|
+
if (stat.isFile() && stat.nlink > 1)
|
|
27
|
+
throw new Error(`Protected project tree contains a hardlink: ${path}`);
|
|
28
|
+
if (stat.isDirectory())
|
|
29
|
+
for (const name of readdirSync(path))
|
|
30
|
+
scan(join(path, name));
|
|
31
|
+
};
|
|
32
|
+
for (const path of protectedRoots)
|
|
33
|
+
scan(path);
|
|
34
|
+
return protectedRoots;
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Host-owned record of one isolated run's clone; never store it where the run can write. */
|
|
2
|
+
export interface RunClone {
|
|
3
|
+
/**
|
|
4
|
+
* The run's Git directory, outside the workspace; mounted as `.git` only
|
|
5
|
+
* inside the run. On the host `<workspace>/.git` is a host-written stub
|
|
6
|
+
* without objects that only names the ticket branch.
|
|
7
|
+
*/
|
|
8
|
+
gitDir: string;
|
|
9
|
+
workspace: string;
|
|
10
|
+
/** The parent repository's common Git directory. */
|
|
11
|
+
parentGitDir: string;
|
|
12
|
+
branch: string;
|
|
13
|
+
/** The ticket branch tip the run started from; the transfer's compare-and-swap base. */
|
|
14
|
+
expected: string;
|
|
15
|
+
target?: string;
|
|
16
|
+
shared: boolean;
|
|
17
|
+
protectedPaths?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface RunCloneOptions {
|
|
20
|
+
/** Any path inside the parent checkout. */
|
|
21
|
+
parent: string;
|
|
22
|
+
/** Stable per-ticket directory; refreshed in place. */
|
|
23
|
+
workspace: string;
|
|
24
|
+
/** Default: {@link runCloneGitDir}, in the conductor's cache. */
|
|
25
|
+
gitDir?: string;
|
|
26
|
+
env?: Env;
|
|
27
|
+
branch: string;
|
|
28
|
+
/** Carried as `origin/<target>`; nothing is merged. */
|
|
29
|
+
target?: string;
|
|
30
|
+
/** Borrow the parent's objects through alternates instead of copying them. */
|
|
31
|
+
shared?: boolean;
|
|
32
|
+
}
|
|
33
|
+
type Env = Record<string, string | undefined>;
|
|
34
|
+
/** Where a workspace's run Git directory lives: the conductor's cache, never the workspace. */
|
|
35
|
+
export declare function runCloneGitDir(workspace: string, env?: Env): string;
|
|
36
|
+
export declare function saveRunClone(record: RunClone): void;
|
|
37
|
+
/** The record of the workspace's current run clone; `undefined` for a linked worktree. */
|
|
38
|
+
export declare function loadRunClone(workspace: string, env?: Env): RunClone | undefined;
|
|
39
|
+
export declare function removeRunClone(workspace: string, env?: Env): void;
|
|
40
|
+
/**
|
|
41
|
+
* A fresh clone of the ticket branch for one isolated run. The previous run's
|
|
42
|
+
* Git directory is discarded, so no ref, config or hook it wrote survives; the
|
|
43
|
+
* workspace keeps only ignored files.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createRunClone(options: RunCloneOptions): RunClone;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { transferIsolatedCommit } from './isolated-git.js';
|
|
7
|
+
import { UI_REFRESH_FILE } from './ui-refresh.js';
|
|
8
|
+
/** Where a workspace's run Git directory lives: the conductor's cache, never the workspace. */
|
|
9
|
+
export function runCloneGitDir(workspace, env = process.env) {
|
|
10
|
+
const cache = env.XDG_CACHE_HOME || join(env.HOME || homedir(), '.cache');
|
|
11
|
+
const key = createHash('sha256').update(resolve(workspace)).digest('hex');
|
|
12
|
+
return join(cache, 'bakers/run-git', `${key.slice(0, 16)}.git`);
|
|
13
|
+
}
|
|
14
|
+
const recordOf = (gitDir) => `${gitDir}.json`;
|
|
15
|
+
export function saveRunClone(record) {
|
|
16
|
+
writeFileSync(recordOf(record.gitDir), JSON.stringify(record), {
|
|
17
|
+
mode: 0o600,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** The record of the workspace's current run clone; `undefined` for a linked worktree. */
|
|
21
|
+
export function loadRunClone(workspace, env = process.env) {
|
|
22
|
+
return loadRecord(runCloneGitDir(workspace, env));
|
|
23
|
+
}
|
|
24
|
+
function loadRecord(gitDir) {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(readFileSync(recordOf(gitDir), 'utf8'));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function removeRunClone(workspace, env = process.env) {
|
|
33
|
+
const gitDir = runCloneGitDir(workspace, env);
|
|
34
|
+
rmSync(gitDir, { recursive: true, force: true });
|
|
35
|
+
rmSync(recordOf(gitDir), { force: true });
|
|
36
|
+
}
|
|
37
|
+
const git = (args, cwd) => execFileSync('git', args, {
|
|
38
|
+
cwd,
|
|
39
|
+
encoding: 'utf8',
|
|
40
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
41
|
+
}).trim();
|
|
42
|
+
const tryGit = (args) => {
|
|
43
|
+
try {
|
|
44
|
+
return git(args);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A fresh clone of the ticket branch for one isolated run. The previous run's
|
|
52
|
+
* Git directory is discarded, so no ref, config or hook it wrote survives; the
|
|
53
|
+
* workspace keeps only ignored files.
|
|
54
|
+
*/
|
|
55
|
+
export function createRunClone(options) {
|
|
56
|
+
const { workspace, branch, target, shared = false } = options;
|
|
57
|
+
const gitDir = options.gitDir ?? runCloneGitDir(workspace, options.env);
|
|
58
|
+
const parentGitDir = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], options.parent);
|
|
59
|
+
const parent = (...args) => git(['--git-dir', parentGitDir, ...args]);
|
|
60
|
+
git(['check-ref-format', `refs/heads/${branch}`]);
|
|
61
|
+
// A linked worktree from before isolation: the refresh below would delete
|
|
62
|
+
// its uncommitted work, and the parent would keep a stale worktree entry.
|
|
63
|
+
const link = join(workspace, '.git');
|
|
64
|
+
if (lstatSync(link, { throwIfNoEntry: false })?.isFile()) {
|
|
65
|
+
const admin = readFileSync(link, 'utf8')
|
|
66
|
+
.replace(/^gitdir: /, '')
|
|
67
|
+
.trim();
|
|
68
|
+
if (dirname(admin) !== join(parentGitDir, 'worktrees'))
|
|
69
|
+
throw new Error(`run clone: ${workspace} belongs to another repository`);
|
|
70
|
+
if (git(['status', '--porcelain'], workspace))
|
|
71
|
+
throw new Error(`run clone: ${workspace} is a linked worktree with uncommitted work; commit or remove it, then dispatch again`);
|
|
72
|
+
rmSync(admin, { recursive: true, force: true });
|
|
73
|
+
rmSync(link);
|
|
74
|
+
}
|
|
75
|
+
// A run that ended without its transfer (a crash, a re-dispatch) still
|
|
76
|
+
// holds commits: bring them over, or set its Git directory aside when the
|
|
77
|
+
// transfer refuses them, so starting fresh never destroys work.
|
|
78
|
+
const previous = loadRecord(gitDir);
|
|
79
|
+
if (previous) {
|
|
80
|
+
try {
|
|
81
|
+
transferIsolatedCommit(previous);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
rmSync(`${gitDir}.unsaved`, { recursive: true, force: true });
|
|
85
|
+
renameSync(gitDir, `${gitDir}.unsaved`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const expected = parent('rev-parse', '--verify', `refs/heads/${branch}^{commit}`);
|
|
89
|
+
// Git runs a submodule's own config; the host never checks one out for a run.
|
|
90
|
+
if (parent('ls-tree', '-r', '-z', expected)
|
|
91
|
+
.split('\0')
|
|
92
|
+
.some((entry) => entry.startsWith('160000 ')))
|
|
93
|
+
throw new Error('run clone: submodules are not supported');
|
|
94
|
+
rmSync(gitDir, { recursive: true, force: true });
|
|
95
|
+
mkdirSync(dirname(gitDir), { recursive: true });
|
|
96
|
+
git([
|
|
97
|
+
'-c',
|
|
98
|
+
'init.defaultRefFormat=files',
|
|
99
|
+
'clone',
|
|
100
|
+
'--quiet',
|
|
101
|
+
'--bare',
|
|
102
|
+
'--template=',
|
|
103
|
+
'--no-tags',
|
|
104
|
+
'--single-branch',
|
|
105
|
+
'--branch',
|
|
106
|
+
branch,
|
|
107
|
+
...(shared ? ['--shared'] : ['--no-local', '--no-hardlinks']),
|
|
108
|
+
parentGitDir,
|
|
109
|
+
gitDir,
|
|
110
|
+
]);
|
|
111
|
+
const run = (...args) => git(['--git-dir', gitDir, ...args]);
|
|
112
|
+
run('config', 'core.bare', 'false');
|
|
113
|
+
// The conductor's reload signal is not the run's untracked work.
|
|
114
|
+
mkdirSync(join(gitDir, 'info'), { recursive: true });
|
|
115
|
+
writeFileSync(join(gitDir, 'info/exclude'), `/.bakers/${UI_REFRESH_FILE}\n`);
|
|
116
|
+
run('config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*');
|
|
117
|
+
// The parent path means nothing inside the run; forge tools do the real fetch and push.
|
|
118
|
+
const url = tryGit([
|
|
119
|
+
'--git-dir',
|
|
120
|
+
parentGitDir,
|
|
121
|
+
'config',
|
|
122
|
+
'--get',
|
|
123
|
+
'remote.origin.url',
|
|
124
|
+
]);
|
|
125
|
+
if (url)
|
|
126
|
+
run('config', 'remote.origin.url', url);
|
|
127
|
+
else
|
|
128
|
+
run('config', '--unset', 'remote.origin.url');
|
|
129
|
+
if (target) {
|
|
130
|
+
const source = [
|
|
131
|
+
`refs/remotes/origin/${target}`,
|
|
132
|
+
`refs/heads/${target}`,
|
|
133
|
+
].find((ref) => tryGit([
|
|
134
|
+
'--git-dir',
|
|
135
|
+
parentGitDir,
|
|
136
|
+
'rev-parse',
|
|
137
|
+
'--verify',
|
|
138
|
+
'--quiet',
|
|
139
|
+
ref,
|
|
140
|
+
]));
|
|
141
|
+
if (source)
|
|
142
|
+
run('fetch', '--quiet', '--no-tags', '--no-write-fetch-head', parentGitDir, `+${source}:refs/remotes/origin/${target}`);
|
|
143
|
+
}
|
|
144
|
+
mkdirSync(workspace, { recursive: true });
|
|
145
|
+
// On the host `.git` is a stub the host writes: just enough for host tools
|
|
146
|
+
// (herdr, `bakers ui --here`) to name the ticket branch instead of finding
|
|
147
|
+
// the parent checkout above. The directory itself stays, because the run's
|
|
148
|
+
// and the site containers' mounts sit on it; whatever is inside is replaced,
|
|
149
|
+
// and rm removes a planted link itself, never its target.
|
|
150
|
+
const stub = join(workspace, '.git');
|
|
151
|
+
if (!lstatSync(stub, { throwIfNoEntry: false })?.isDirectory()) {
|
|
152
|
+
rmSync(stub, { recursive: true, force: true });
|
|
153
|
+
mkdirSync(stub);
|
|
154
|
+
}
|
|
155
|
+
for (const entry of readdirSync(stub))
|
|
156
|
+
rmSync(join(stub, entry), { recursive: true, force: true });
|
|
157
|
+
mkdirSync(join(stub, 'objects'));
|
|
158
|
+
mkdirSync(join(stub, 'refs'));
|
|
159
|
+
writeFileSync(join(stub, 'HEAD'), `ref: refs/heads/${branch}\n`);
|
|
160
|
+
writeFileSync(join(stub, 'config'), `[core]\n\trepositoryformatversion = 0\n\tbare = false\n${url ? `[remote "origin"]\n\turl = ${url}\n` : ''}`);
|
|
161
|
+
const tree = (...args) => git(['--git-dir', gitDir, '--work-tree', workspace, ...args], workspace);
|
|
162
|
+
// Index first, so clean removes only untracked files and reset rewrites only changed ones.
|
|
163
|
+
tree('read-tree', 'HEAD');
|
|
164
|
+
tree('clean', '-ffdq');
|
|
165
|
+
tree('reset', '--hard', '--quiet');
|
|
166
|
+
const record = {
|
|
167
|
+
gitDir,
|
|
168
|
+
workspace,
|
|
169
|
+
parentGitDir,
|
|
170
|
+
branch,
|
|
171
|
+
expected,
|
|
172
|
+
...(target ? { target } : {}),
|
|
173
|
+
shared,
|
|
174
|
+
};
|
|
175
|
+
saveRunClone(record);
|
|
176
|
+
return record;
|
|
177
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isAbsolute, relative, sep } from 'node:path';
|
|
2
|
+
/** The CLI build root for two package dirs; refuses one that would expose the operator home. */
|
|
3
|
+
export function cliRootOf(a, b, home) {
|
|
4
|
+
const x = a.split(sep);
|
|
5
|
+
const y = b.split(sep);
|
|
6
|
+
let i = 0;
|
|
7
|
+
while (i < x.length && x[i] === y[i])
|
|
8
|
+
i++;
|
|
9
|
+
let cliRoot = x.slice(0, i).join(sep) || sep;
|
|
10
|
+
const nm = cliRoot.indexOf(`${sep}node_modules`);
|
|
11
|
+
if (nm >= 0)
|
|
12
|
+
cliRoot = cliRoot.slice(0, nm + `${sep}node_modules`.length);
|
|
13
|
+
const rel = relative(cliRoot, home);
|
|
14
|
+
if (rel === '' || (!rel.startsWith('..') && !isAbsolute(rel)))
|
|
15
|
+
throw new Error(`runtime: the CLI build ${cliRoot} would mount ${home} into every run; install the CLI and its addons in one tree`);
|
|
16
|
+
return cliRoot;
|
|
17
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -20,13 +20,17 @@ export type { ConnectionConfig, MachineConfig, ProjectConfig, } from './config-t
|
|
|
20
20
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, type RootGitExec, } from './core/checkout-root.js';
|
|
21
21
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
22
22
|
export { type GitSandboxPaths, gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
|
|
23
|
+
export { refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
23
24
|
export { type ConductorLiveness, type ConductorLivenessInput, deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
|
|
24
25
|
export { type ConductorLogger, createLogger } from './core/logger.js';
|
|
25
26
|
export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, type ProcProbe, type RunProcessProbe, type SignalFailureReason, type SignalOutcome, type SignalVerifiedInput, signalVerifiedProcess, type VerifyOutcome, type VerifyProcessInput, verifyConductorProcess, } from './core/proc.js';
|
|
27
|
+
export { protectedProjectPaths } from './core/protected-project-paths.js';
|
|
26
28
|
export { normalizeRepoUrl } from './core/repo-url.js';
|
|
29
|
+
export { createRunClone, loadRunClone, type RunClone, type RunCloneOptions, removeRunClone, runCloneGitDir, saveRunClone, } from './core/run-clone.js';
|
|
30
|
+
export { cliRootOf } from './core/runtime-paths.js';
|
|
27
31
|
export { shellQuote } from './core/shell.js';
|
|
28
32
|
export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
|
|
29
33
|
export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
|
30
34
|
export { AddonUnresolvedError, discoverAddons, loadAddonPreset, type ResolvedConductorSlots, resolveConductorSlots, } from './plugins/discover-addons.js';
|
|
31
35
|
export { type AddonEntry, type AddonScope, type BbPreset, type BbSurface, type CommandDescriptor, type DiscoveredContributions, emptyContributions, type OpaqueAccumulator, PRESET_FUNCTION_KEYS, SURFACE_KEYS, } from './plugins/preset.js';
|
|
32
|
-
export { type AddonScopeFinding, type AddonScopeInput, discoverScoped, type EffectiveAddon, readConfigAddons, readEffectiveAddon, scopeAddons, } from './plugins/scoped-addons.js';
|
|
36
|
+
export { type AddonCapabilities, type AddonCapability, type AddonScopeFinding, type AddonScopeInput, discoverScoped, type EffectiveAddon, readAddonCapabilities, readConfigAddons, readEffectiveAddon, scopeAddons, } from './plugins/scoped-addons.js';
|
package/dist/src/index.js
CHANGED
|
@@ -21,10 +21,14 @@ export { discoverBbWorkspaces, loadReadyBbConnection, resolveWorkspaceSelector,
|
|
|
21
21
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, } from './core/checkout-root.js';
|
|
22
22
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
23
23
|
export { gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
|
|
24
|
+
export { refreshRunTarget, runCloneTip, transferIsolatedCommit, } from './core/isolated-git.js';
|
|
24
25
|
export { deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
|
|
25
26
|
export { createLogger } from './core/logger.js';
|
|
26
27
|
export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, signalVerifiedProcess, verifyConductorProcess, } from './core/proc.js';
|
|
28
|
+
export { protectedProjectPaths } from './core/protected-project-paths.js';
|
|
27
29
|
export { normalizeRepoUrl } from './core/repo-url.js';
|
|
30
|
+
export { createRunClone, loadRunClone, removeRunClone, runCloneGitDir, saveRunClone, } from './core/run-clone.js';
|
|
31
|
+
export { cliRootOf } from './core/runtime-paths.js';
|
|
28
32
|
export { shellQuote } from './core/shell.js';
|
|
29
33
|
export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
|
|
30
34
|
export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
|
@@ -41,4 +45,4 @@ export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
|
|
41
45
|
// `@bakers-build/addon-workspace-git`. Core ships NO plugin implementations.
|
|
42
46
|
export { AddonUnresolvedError, discoverAddons, loadAddonPreset, resolveConductorSlots, } from './plugins/discover-addons.js';
|
|
43
47
|
export { emptyContributions, PRESET_FUNCTION_KEYS, SURFACE_KEYS, } from './plugins/preset.js';
|
|
44
|
-
export { discoverScoped, readConfigAddons, readEffectiveAddon, scopeAddons, } from './plugins/scoped-addons.js';
|
|
48
|
+
export { discoverScoped, readAddonCapabilities, readConfigAddons, readEffectiveAddon, scopeAddons, } from './plugins/scoped-addons.js';
|
|
@@ -34,6 +34,8 @@ export declare function loadAddonPreset(spec: string, bases: string[], warn?: Wa
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function discoverAddons(entries: AddonEntry[] | undefined, surface: BbSurface, bases: string[], opts?: {
|
|
36
36
|
logger?: ConductorLogger;
|
|
37
|
+
/** Already expanded by scopeAddons. */
|
|
38
|
+
expandNested?: boolean;
|
|
37
39
|
globals?: unknown;
|
|
38
40
|
/** Like `globals`, but seen only by the `agents` accumulators (the
|
|
39
41
|
* conductor's shared run security). */
|
|
@@ -56,17 +58,19 @@ export declare function discoverAddons(entries: AddonEntry[] | undefined, surfac
|
|
|
56
58
|
* `narrowConductorContributions`) and gets `RemotePlugin`/`ExecutorPlugin`/
|
|
57
59
|
* `WorkspacePlugin`/`AgentCandidate` back.
|
|
58
60
|
*/
|
|
59
|
-
export interface ResolvedConductorSlots<R = unknown, E = unknown, W = unknown, A = unknown> {
|
|
61
|
+
export interface ResolvedConductorSlots<R = unknown, E = unknown, W = unknown, A = unknown, U = unknown> {
|
|
60
62
|
remote?: R;
|
|
61
63
|
executor?: E;
|
|
62
64
|
workspace?: W;
|
|
65
|
+
runtime?: U;
|
|
63
66
|
agents: A[];
|
|
64
67
|
}
|
|
65
68
|
/** Resolve discovered conductor contributions into the four engine slots. */
|
|
66
|
-
export declare function resolveConductorSlots<R, E, W, A>(contributions: {
|
|
69
|
+
export declare function resolveConductorSlots<R, E, W, A, U = unknown>(contributions: {
|
|
67
70
|
servers: R[];
|
|
68
71
|
executors: E[];
|
|
69
72
|
worktrees: W[];
|
|
70
73
|
agents: A[];
|
|
71
|
-
|
|
74
|
+
runtimes?: U[];
|
|
75
|
+
}, logger?: ConductorLogger): ResolvedConductorSlots<R, E, W, A, U>;
|
|
72
76
|
export {};
|
|
@@ -276,7 +276,9 @@ export async function discoverAddons(entries, surface, bases, opts = {}) {
|
|
|
276
276
|
}
|
|
277
277
|
visited.add(dedupKey);
|
|
278
278
|
// Depth-first: meta-addon children apply BEFORE the declaring preset.
|
|
279
|
-
if (
|
|
279
|
+
if (opts.expandNested !== false &&
|
|
280
|
+
Array.isArray(preset.addons) &&
|
|
281
|
+
preset.addons.length > 0) {
|
|
280
282
|
await walk(preset.addons, listBases);
|
|
281
283
|
}
|
|
282
284
|
const presetOpts = mergeGlobals(opts.globals, withOpts);
|
|
@@ -362,10 +364,12 @@ export function resolveConductorSlots(contributions, logger) {
|
|
|
362
364
|
const remote = resolveSingleton(contributions.servers, 'server', logger);
|
|
363
365
|
const executor = resolveSingleton(contributions.executors, 'executor', logger);
|
|
364
366
|
const workspace = resolveSingleton(contributions.worktrees, 'worktree', logger);
|
|
367
|
+
const runtime = resolveSingleton(contributions.runtimes ?? [], 'runtime', logger);
|
|
365
368
|
return {
|
|
366
369
|
...(remote ? { remote } : {}),
|
|
367
370
|
...(executor ? { executor } : {}),
|
|
368
371
|
...(workspace ? { workspace } : {}),
|
|
372
|
+
...(runtime ? { runtime } : {}),
|
|
369
373
|
agents: contributions.agents,
|
|
370
374
|
};
|
|
371
375
|
}
|
|
@@ -69,6 +69,8 @@ export interface DiscoveredContributions {
|
|
|
69
69
|
agents: unknown[];
|
|
70
70
|
/** Opaque: `HookListener[]` on the conductor surface (BB-599). */
|
|
71
71
|
hooks: unknown[];
|
|
72
|
+
/** Opaque: `RuntimePlugin[]` on the conductor surface — where runs execute. */
|
|
73
|
+
runtimes: unknown[];
|
|
72
74
|
connectionPlugins: DropSHPlugin[];
|
|
73
75
|
/**
|
|
74
76
|
* BB-373: UI extension entry MODULES — specifiers, never constructed
|
|
@@ -124,7 +126,7 @@ export declare const SURFACE_KEYS: Record<BbSurface, Array<keyof DiscoveredContr
|
|
|
124
126
|
* (override semantics — the user config participates as the final preset).
|
|
125
127
|
*/
|
|
126
128
|
export interface BbPreset<O = unknown> {
|
|
127
|
-
/**
|
|
129
|
+
/** Children load as if listed in the same scope, depth-first BEFORE this preset. */
|
|
128
130
|
addons?: AddonEntry[];
|
|
129
131
|
/** The config scopes this addon may be listed in; absent means both. */
|
|
130
132
|
scopes?: AddonScope[];
|
|
@@ -140,6 +142,7 @@ export interface BbPreset<O = unknown> {
|
|
|
140
142
|
worktrees?: OpaqueAccumulator<O>;
|
|
141
143
|
agents?: OpaqueAccumulator<O>;
|
|
142
144
|
hooks?: OpaqueAccumulator<O>;
|
|
145
|
+
runtimes?: OpaqueAccumulator<O>;
|
|
143
146
|
connectionPlugins?: (acc: DropSHPlugin[], opts: O) => DropSHPlugin[] | Promise<DropSHPlugin[]>;
|
|
144
147
|
uiEntries?: (acc: string[], opts: O) => string[] | Promise<string[]>;
|
|
145
148
|
inbox?: unknown;
|
|
@@ -28,7 +28,14 @@
|
|
|
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: [
|
|
31
|
+
conductor: [
|
|
32
|
+
'servers',
|
|
33
|
+
'executors',
|
|
34
|
+
'worktrees',
|
|
35
|
+
'agents',
|
|
36
|
+
'hooks',
|
|
37
|
+
'runtimes',
|
|
38
|
+
],
|
|
32
39
|
connection: ['connectionPlugins', 'uiEntries'],
|
|
33
40
|
};
|
|
34
41
|
/** The preset function keys, for shape-detection during discovery. */
|
|
@@ -39,6 +46,7 @@ export const PRESET_FUNCTION_KEYS = [
|
|
|
39
46
|
'worktrees',
|
|
40
47
|
'agents',
|
|
41
48
|
'hooks',
|
|
49
|
+
'runtimes',
|
|
42
50
|
'connectionPlugins',
|
|
43
51
|
'uiEntries',
|
|
44
52
|
];
|
|
@@ -51,6 +59,7 @@ export function emptyContributions() {
|
|
|
51
59
|
worktrees: [],
|
|
52
60
|
agents: [],
|
|
53
61
|
hooks: [],
|
|
62
|
+
runtimes: [],
|
|
54
63
|
connectionPlugins: [],
|
|
55
64
|
uiEntries: [],
|
|
56
65
|
addonInbox: [],
|
|
@@ -17,6 +17,8 @@ export interface EffectiveAddon {
|
|
|
17
17
|
bases: string[];
|
|
18
18
|
/** The resolved preset module path. */
|
|
19
19
|
key: string;
|
|
20
|
+
/** The preset that brought this addon into the scope. */
|
|
21
|
+
via?: string;
|
|
20
22
|
}
|
|
21
23
|
/** An entry listed in a scope its addon does not declare. */
|
|
22
24
|
export type AddonScopeFinding = {
|
|
@@ -63,3 +65,15 @@ export declare function readEffectiveAddon(spec: string, opts: {
|
|
|
63
65
|
projectPath?: string;
|
|
64
66
|
bases?: string[];
|
|
65
67
|
}): Promise<EffectiveAddon | undefined>;
|
|
68
|
+
/** Preset declarations used by synchronous config planning; no accumulators run. */
|
|
69
|
+
export interface AddonCapability {
|
|
70
|
+
scopes: AddonScope[];
|
|
71
|
+
slots: string[];
|
|
72
|
+
contributions: Array<{
|
|
73
|
+
slot: string;
|
|
74
|
+
spec: string;
|
|
75
|
+
via?: string;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
export type AddonCapabilities = Record<string, AddonCapability | undefined>;
|
|
79
|
+
export declare function readAddonCapabilities(specs: string[], bases: string[], scope?: AddonScope): Promise<AddonCapabilities>;
|
|
@@ -40,81 +40,112 @@ export async function scopeAddons(inputs, opts = {}) {
|
|
|
40
40
|
};
|
|
41
41
|
const addons = [];
|
|
42
42
|
const findings = [];
|
|
43
|
-
const
|
|
43
|
+
const effectiveAt = new Map();
|
|
44
44
|
const ordered = [
|
|
45
45
|
...inputs.filter((i) => i.scope === 'machine'),
|
|
46
46
|
...inputs.filter((i) => i.scope !== 'machine'),
|
|
47
47
|
];
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// discoverAddons warns once and skips it.
|
|
53
|
-
addons.push({
|
|
54
|
-
entry,
|
|
55
|
-
scope: input.scope,
|
|
56
|
-
path: input.path,
|
|
57
|
-
bases: input.bases,
|
|
58
|
-
key: spec,
|
|
59
|
-
});
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
let loaded;
|
|
63
|
-
try {
|
|
64
|
-
loaded = await loadAddonPreset(spec, input.bases, warn);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
const soft = input.scope === 'machine' || opts.unresolved === 'skip';
|
|
68
|
-
if (soft && error instanceof AddonUnresolvedError) {
|
|
69
|
-
warn(`addons[] in ${input.path}: cannot resolve addon '${spec}' — it is ` +
|
|
70
|
-
'skipped; install it where that config can resolve it.');
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
const allowed = loaded.preset.scopes ?? ALL_SCOPES;
|
|
76
|
-
if (!allowed.includes(input.scope)) {
|
|
77
|
-
findings.push({
|
|
78
|
-
code: 'addon_scope_not_allowed',
|
|
79
|
-
spec,
|
|
80
|
-
path: input.path,
|
|
81
|
-
scope: input.scope,
|
|
82
|
-
allowed,
|
|
83
|
-
});
|
|
84
|
-
warn(`addons[] in ${input.path}: addon '${spec}' is not loaded — it may ` +
|
|
85
|
-
`be configured only in ${allowed.map((s) => SCOPE_FILE[s]).join(' or ')}.`);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const match = `${loaded.key}\0${alias ?? ''}`;
|
|
89
|
-
const at = input.scope === 'project' ? machineAt.get(match) : undefined;
|
|
90
|
-
if (at !== undefined) {
|
|
91
|
-
const winner = addons[at];
|
|
92
|
-
const project = entryWith(entry);
|
|
93
|
-
const machine = entryWith(winner.entry);
|
|
94
|
-
const merged = loaded.preset.mergeWith
|
|
95
|
-
? loaded.preset.mergeWith(project, machine)
|
|
96
|
-
: machine !== undefined
|
|
97
|
-
? machine
|
|
98
|
-
: project;
|
|
99
|
-
addons[at] = { ...winner, entry: withReplaced(winner.entry, merged) };
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (input.scope === 'machine' && !machineAt.has(match))
|
|
103
|
-
machineAt.set(match, addons.length);
|
|
48
|
+
const walk = async (input, entry, chain = []) => {
|
|
49
|
+
const { spec, alias } = normalizeEntry(entry);
|
|
50
|
+
if (isRetiredAddon(spec)) {
|
|
51
|
+
// discoverAddons warns once and skips it.
|
|
104
52
|
addons.push({
|
|
105
53
|
entry,
|
|
106
54
|
scope: input.scope,
|
|
107
55
|
path: input.path,
|
|
108
56
|
bases: input.bases,
|
|
109
|
-
key:
|
|
57
|
+
key: spec,
|
|
110
58
|
});
|
|
59
|
+
return;
|
|
111
60
|
}
|
|
112
|
-
|
|
61
|
+
let loaded;
|
|
62
|
+
try {
|
|
63
|
+
loaded = await loadAddonPreset(spec, input.bases, warn);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const parent = chain.at(-1)?.spec;
|
|
67
|
+
if (parent && error instanceof AddonUnresolvedError)
|
|
68
|
+
error.message += ` (via ${parent})`;
|
|
69
|
+
const soft = input.scope === 'machine' || opts.unresolved === 'skip';
|
|
70
|
+
if (soft && error instanceof AddonUnresolvedError) {
|
|
71
|
+
warn(`addons[] in ${input.path}: cannot resolve addon '${spec}'${parent ? ` (via ${parent})` : ''} — it is ` +
|
|
72
|
+
'skipped; install it where that config can resolve it.');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
if (chain.some((parent) => parent.key === loaded.key))
|
|
78
|
+
throw new Error(`Addon cycle: ${[...chain.map((p) => p.spec), spec].join(' -> ')}`);
|
|
79
|
+
const via = chain.at(-1)?.spec;
|
|
80
|
+
const allowed = loaded.preset.scopes ?? ALL_SCOPES;
|
|
81
|
+
if (!allowed.includes(input.scope)) {
|
|
82
|
+
if (via)
|
|
83
|
+
return;
|
|
84
|
+
findings.push({
|
|
85
|
+
code: 'addon_scope_not_allowed',
|
|
86
|
+
spec,
|
|
87
|
+
path: input.path,
|
|
88
|
+
scope: input.scope,
|
|
89
|
+
allowed,
|
|
90
|
+
});
|
|
91
|
+
warn(`addons[] in ${input.path}: addon '${spec}' is not loaded — it may ` +
|
|
92
|
+
`be configured only in ${allowed.map((s) => SCOPE_FILE[s]).join(' or ')}.`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const child of loaded.preset.addons ?? [])
|
|
96
|
+
await walk({
|
|
97
|
+
...input,
|
|
98
|
+
bases: [
|
|
99
|
+
pathToFileURL(`${dirname(loaded.key)}/`).href,
|
|
100
|
+
...input.bases,
|
|
101
|
+
],
|
|
102
|
+
}, child, [...chain, { key: loaded.key, spec }]);
|
|
103
|
+
const match = `${loaded.key}\0${alias ?? ''}`;
|
|
104
|
+
const at = effectiveAt.get(match);
|
|
105
|
+
if (at !== undefined) {
|
|
106
|
+
const winner = addons[at];
|
|
107
|
+
if (winner.scope === input.scope) {
|
|
108
|
+
if (winner.via && !via) {
|
|
109
|
+
const { via: _via, ...explicit } = winner;
|
|
110
|
+
addons[at] = { ...explicit, entry };
|
|
111
|
+
}
|
|
112
|
+
else if (!winner.via &&
|
|
113
|
+
!via &&
|
|
114
|
+
alias === undefined &&
|
|
115
|
+
typeof loaded.preset.agents === 'function') {
|
|
116
|
+
// Legacy priority-only variants share a package but have separate options.
|
|
117
|
+
addons.push({ ...winner, entry });
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const project = entryWith(entry);
|
|
122
|
+
const machine = entryWith(winner.entry);
|
|
123
|
+
const merged = loaded.preset.mergeWith
|
|
124
|
+
? loaded.preset.mergeWith(project, machine)
|
|
125
|
+
: machine !== undefined
|
|
126
|
+
? machine
|
|
127
|
+
: project;
|
|
128
|
+
addons[at] = { ...winner, entry: withReplaced(winner.entry, merged) };
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
effectiveAt.set(match, addons.length);
|
|
132
|
+
addons.push({
|
|
133
|
+
entry,
|
|
134
|
+
scope: input.scope,
|
|
135
|
+
path: input.path,
|
|
136
|
+
bases: input.bases,
|
|
137
|
+
key: loaded.key,
|
|
138
|
+
...(via ? { via } : {}),
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
for (const input of ordered)
|
|
142
|
+
for (const entry of input.entries)
|
|
143
|
+
await walk(input, entry);
|
|
113
144
|
return { addons, findings };
|
|
114
145
|
}
|
|
115
146
|
/** Run `surface` over the effective list, each entry against its own bases. */
|
|
116
147
|
export function discoverScoped(addons, surface, opts = {}) {
|
|
117
|
-
return discoverAddons(addons.map((a) => a.entry), surface, addons[0]?.bases ?? [], { ...opts, entryBases: addons.map((a) => a.bases) });
|
|
148
|
+
return discoverAddons(addons.map((a) => a.entry), surface, addons[0]?.bases ?? [], { ...opts, expandNested: false, entryBases: addons.map((a) => a.bases) });
|
|
118
149
|
}
|
|
119
150
|
/**
|
|
120
151
|
* `<BAKERS_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
|
|
@@ -179,5 +210,46 @@ export async function readEffectiveAddon(spec, opts) {
|
|
|
179
210
|
for (const input of inputs)
|
|
180
211
|
input.entries = input.entries.filter((e) => (typeof e === 'string' ? e : e?.use) === spec);
|
|
181
212
|
const { addons } = await scopeAddons(inputs, { unresolved: 'skip' });
|
|
182
|
-
return addons
|
|
213
|
+
return addons.find((a) => normalizeEntry(a.entry).spec === spec);
|
|
214
|
+
}
|
|
215
|
+
export async function readAddonCapabilities(specs, bases, scope = 'project') {
|
|
216
|
+
const result = {};
|
|
217
|
+
for (const spec of new Set(specs)) {
|
|
218
|
+
try {
|
|
219
|
+
const { preset } = await loadAddonPreset(spec, bases);
|
|
220
|
+
const scopes = preset.scopes ?? ALL_SCOPES;
|
|
221
|
+
const { addons } = await scopeAddons(scopes.includes(scope)
|
|
222
|
+
? [{ scope, path: '<capabilities>', entries: [spec], bases }]
|
|
223
|
+
: []);
|
|
224
|
+
const contributions = [];
|
|
225
|
+
for (const addon of addons) {
|
|
226
|
+
const name = normalizeEntry(addon.entry).spec;
|
|
227
|
+
const { preset: child } = await loadAddonPreset(name, addon.bases);
|
|
228
|
+
for (const [slot, key] of Object.entries({
|
|
229
|
+
server: 'servers',
|
|
230
|
+
executor: 'executors',
|
|
231
|
+
worktree: 'worktrees',
|
|
232
|
+
agent: 'agents',
|
|
233
|
+
runtime: 'runtimes',
|
|
234
|
+
}))
|
|
235
|
+
if (typeof child[key] === 'function')
|
|
236
|
+
contributions.push({
|
|
237
|
+
slot,
|
|
238
|
+
spec: name,
|
|
239
|
+
...(addon.via ? { via: addon.via } : {}),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
result[spec] = {
|
|
243
|
+
scopes,
|
|
244
|
+
slots: [...new Set(contributions.map((c) => c.slot))],
|
|
245
|
+
contributions,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (!(error instanceof AddonUnresolvedError))
|
|
250
|
+
throw error;
|
|
251
|
+
result[spec] = undefined;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
183
255
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/core",
|
|
3
|
-
"version": "0.9.1-next.
|
|
3
|
+
"version": "0.9.1-next.6",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"yaml": "^2.7.0"
|
|
41
41
|
},
|
|
42
42
|
"bakersBuild": {
|
|
43
|
-
"commit": "
|
|
43
|
+
"commit": "e7d9921d51d5c045f29ca7e35d1e6a348e6ddf08",
|
|
44
44
|
"channel": "next"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"else": { "type": "object" }
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
"server": {
|
|
50
|
+
"$ref": "project.schema.json#/$defs/slot",
|
|
51
|
+
"description": "Conductor server slot for this connection; a project server slot or server addon wins. Default @bakers-build/addon-remote-drupal."
|
|
52
|
+
},
|
|
49
53
|
"addons": {
|
|
50
54
|
"type": "array",
|
|
51
55
|
"description": "Connection addons, such as auth providers.",
|
|
@@ -113,6 +113,17 @@
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
]
|
|
116
|
+
},
|
|
117
|
+
"provision_exec": {
|
|
118
|
+
"description": "Commands by key, offered to runs as provision_exec(key, args). Arguments follow the command as argv, never through a shell.",
|
|
119
|
+
"type": "object",
|
|
120
|
+
"propertyNames": {
|
|
121
|
+
"pattern": "^[A-Za-z0-9_-]+$"
|
|
122
|
+
},
|
|
123
|
+
"additionalProperties": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"minLength": 1
|
|
126
|
+
}
|
|
116
127
|
}
|
|
117
128
|
},
|
|
118
129
|
"additionalProperties": false
|
|
@@ -151,6 +162,9 @@
|
|
|
151
162
|
"select_agent": {
|
|
152
163
|
"function": true,
|
|
153
164
|
"description": "Function choosing the agent for a ticket; replaces the shipped selection."
|
|
165
|
+
},
|
|
166
|
+
"runtime": {
|
|
167
|
+
"$ref": "#/$defs/runtime"
|
|
154
168
|
}
|
|
155
169
|
},
|
|
156
170
|
"required": [
|
|
@@ -257,6 +271,20 @@
|
|
|
257
271
|
],
|
|
258
272
|
"additionalProperties": false
|
|
259
273
|
}
|
|
274
|
+
},
|
|
275
|
+
"runtime": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"properties": {
|
|
278
|
+
"read_only": {
|
|
279
|
+
"type": "array",
|
|
280
|
+
"items": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"pattern": "^(?:(?!/)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*//)(?!.*?/$)[^\\\\:\\u0000$]+)$"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"additionalProperties": false,
|
|
287
|
+
"description": "Under an isolating runtime: worktree-relative paths the run sees read-only and may not change in a commit. Host commands must start in one of them. .bakers is always protected."
|
|
260
288
|
}
|
|
261
289
|
}
|
|
262
290
|
}
|