@bakers-build/core 0.9.1-next.3 → 0.9.1-next.5
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/core/exec.d.ts +1 -0
- package/dist/src/core/git-quarantine.d.ts +6 -0
- package/dist/src/core/git-quarantine.js +75 -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 +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/plugins/discover-addons.d.ts +5 -3
- package/dist/src/plugins/discover-addons.js +2 -0
- package/dist/src/plugins/preset.d.ts +3 -0
- package/dist/src/plugins/preset.js +10 -1
- package/package.json +2 -2
|
@@ -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
|
};
|
package/dist/src/core/exec.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type GitExec = (file: string, args: string[]) => Promise<{
|
|
2
|
+
stdout: string;
|
|
3
|
+
}>;
|
|
4
|
+
/** Quarantine only repositories host Git follows through the index, never symlinks. */
|
|
5
|
+
export declare function quarantinePlanted(workspace: string, gitCommonDir: string, exec?: GitExec): Promise<string[]>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { chmodSync, lstatSync, readFileSync, realpathSync, renameSync, statSync, } from 'node:fs';
|
|
4
|
+
import { dirname, join, resolve, sep } from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
const run = promisify(execFile);
|
|
7
|
+
/** Quarantine only repositories host Git follows through the index, never symlinks. */
|
|
8
|
+
export async function quarantinePlanted(workspace, gitCommonDir, exec = (file, args) => run(file, args)) {
|
|
9
|
+
const ws = realpathSync(workspace);
|
|
10
|
+
const modules = join(gitCommonDir, 'modules') + sep;
|
|
11
|
+
const moved = [];
|
|
12
|
+
const git = (...args) => exec('git', ['-C', ws, '-c', 'core.fsmonitor=false', ...args]);
|
|
13
|
+
const quarantineIndex = async () => {
|
|
14
|
+
// A planted index.lock or oversized index must not leave unsafe entries active.
|
|
15
|
+
const { stdout: indexPath } = await git('rev-parse', '--git-path', 'index');
|
|
16
|
+
const index = resolve(ws, indexPath.trim());
|
|
17
|
+
const parent = dirname(index);
|
|
18
|
+
chmodSync(parent, statSync(parent).mode | 0o700);
|
|
19
|
+
renameSync(index, `${index}.bakers-quarantine-${randomUUID()}`);
|
|
20
|
+
moved.push(index);
|
|
21
|
+
};
|
|
22
|
+
let stdout;
|
|
23
|
+
try {
|
|
24
|
+
({ stdout } = await git('ls-files', '--stage', '-z'));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
await quarantineIndex();
|
|
28
|
+
return moved;
|
|
29
|
+
}
|
|
30
|
+
let unresolved = false;
|
|
31
|
+
const links = new Set(stdout.split('\0').flatMap((line) => {
|
|
32
|
+
const match = /^160000 [0-9a-f]+ [0-3]\t(.+)$/s.exec(line);
|
|
33
|
+
return match?.[1] ? [match[1]] : [];
|
|
34
|
+
}));
|
|
35
|
+
linksLoop: for (const name of links) {
|
|
36
|
+
try {
|
|
37
|
+
const parts = name.split('/');
|
|
38
|
+
if (parts.some((part) => !part ||
|
|
39
|
+
part === '.' ||
|
|
40
|
+
part === '..' ||
|
|
41
|
+
part.toLowerCase() === '.git'))
|
|
42
|
+
throw new Error(`unsafe gitlink: ${name}`);
|
|
43
|
+
let path = ws;
|
|
44
|
+
for (const part of [...parts, '.git']) {
|
|
45
|
+
path = join(path, part);
|
|
46
|
+
const entry = lstatSync(path, { throwIfNoEntry: false });
|
|
47
|
+
if (!entry)
|
|
48
|
+
continue linksLoop; // An uninitialised submodule has no config to execute.
|
|
49
|
+
if (entry.isSymbolicLink())
|
|
50
|
+
throw new Error(`symlink: ${name}`);
|
|
51
|
+
}
|
|
52
|
+
if (lstatSync(path).isFile()) {
|
|
53
|
+
const target = /^gitdir:\s*(.+)$/m.exec(readFileSync(path, 'utf8'))?.[1];
|
|
54
|
+
if (target &&
|
|
55
|
+
realpathSync(resolve(ws, name, target.trim())).startsWith(modules))
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
renameSync(path, `${path}.bakers-quarantine-${randomUUID()}`);
|
|
59
|
+
moved.push(path);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// If inspection or rename fails, stop host Git following this entry instead.
|
|
63
|
+
try {
|
|
64
|
+
await git('update-index', '--force-remove', '--', name);
|
|
65
|
+
moved.push(name);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
unresolved = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (unresolved)
|
|
73
|
+
await quarantineIndex();
|
|
74
|
+
return moved;
|
|
75
|
+
}
|
|
@@ -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
|
@@ -19,11 +19,13 @@ export { discoverBbWorkspaces, loadReadyBbConnection, resolveWorkspaceSelector,
|
|
|
19
19
|
export type { ConnectionConfig, MachineConfig, ProjectConfig, } from './config-types.generated.js';
|
|
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
|
+
export { quarantinePlanted } from './core/git-quarantine.js';
|
|
22
23
|
export { type GitSandboxPaths, gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.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';
|
|
26
27
|
export { normalizeRepoUrl } from './core/repo-url.js';
|
|
28
|
+
export { cliRootOf } from './core/runtime-paths.js';
|
|
27
29
|
export { shellQuote } from './core/shell.js';
|
|
28
30
|
export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
|
|
29
31
|
export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
package/dist/src/index.js
CHANGED
|
@@ -20,11 +20,13 @@ export { BB_PACKAGE, checkForUpdate, declineUpdate, defaultUpdateCachePath, fetc
|
|
|
20
20
|
export { discoverBbWorkspaces, loadReadyBbConnection, resolveWorkspaceSelector, workspaceSearchCommand, } from './cli/workspace-recovery.js';
|
|
21
21
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, } from './core/checkout-root.js';
|
|
22
22
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
23
|
+
export { quarantinePlanted } from './core/git-quarantine.js';
|
|
23
24
|
export { gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.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';
|
|
27
28
|
export { normalizeRepoUrl } from './core/repo-url.js';
|
|
29
|
+
export { cliRootOf } from './core/runtime-paths.js';
|
|
28
30
|
export { shellQuote } from './core/shell.js';
|
|
29
31
|
export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
|
|
30
32
|
export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
|
@@ -56,17 +56,19 @@ export declare function discoverAddons(entries: AddonEntry[] | undefined, surfac
|
|
|
56
56
|
* `narrowConductorContributions`) and gets `RemotePlugin`/`ExecutorPlugin`/
|
|
57
57
|
* `WorkspacePlugin`/`AgentCandidate` back.
|
|
58
58
|
*/
|
|
59
|
-
export interface ResolvedConductorSlots<R = unknown, E = unknown, W = unknown, A = unknown> {
|
|
59
|
+
export interface ResolvedConductorSlots<R = unknown, E = unknown, W = unknown, A = unknown, U = unknown> {
|
|
60
60
|
remote?: R;
|
|
61
61
|
executor?: E;
|
|
62
62
|
workspace?: W;
|
|
63
|
+
runtime?: U;
|
|
63
64
|
agents: A[];
|
|
64
65
|
}
|
|
65
66
|
/** Resolve discovered conductor contributions into the four engine slots. */
|
|
66
|
-
export declare function resolveConductorSlots<R, E, W, A>(contributions: {
|
|
67
|
+
export declare function resolveConductorSlots<R, E, W, A, U = unknown>(contributions: {
|
|
67
68
|
servers: R[];
|
|
68
69
|
executors: E[];
|
|
69
70
|
worktrees: W[];
|
|
70
71
|
agents: A[];
|
|
71
|
-
|
|
72
|
+
runtimes?: U[];
|
|
73
|
+
}, logger?: ConductorLogger): ResolvedConductorSlots<R, E, W, A, U>;
|
|
72
74
|
export {};
|
|
@@ -362,10 +362,12 @@ export function resolveConductorSlots(contributions, logger) {
|
|
|
362
362
|
const remote = resolveSingleton(contributions.servers, 'server', logger);
|
|
363
363
|
const executor = resolveSingleton(contributions.executors, 'executor', logger);
|
|
364
364
|
const workspace = resolveSingleton(contributions.worktrees, 'worktree', logger);
|
|
365
|
+
const runtime = resolveSingleton(contributions.runtimes ?? [], 'runtime', logger);
|
|
365
366
|
return {
|
|
366
367
|
...(remote ? { remote } : {}),
|
|
367
368
|
...(executor ? { executor } : {}),
|
|
368
369
|
...(workspace ? { workspace } : {}),
|
|
370
|
+
...(runtime ? { runtime } : {}),
|
|
369
371
|
agents: contributions.agents,
|
|
370
372
|
};
|
|
371
373
|
}
|
|
@@ -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
|
|
@@ -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: [],
|
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.5",
|
|
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": "d9242cad6cabee1faf010b5d46ac1bac33f6e0a1",
|
|
44
44
|
"channel": "next"
|
|
45
45
|
}
|
|
46
46
|
}
|