mirab 0.0.0 → 0.2.0
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/LICENSE +201 -0
- package/README.md +223 -3
- package/package.json +56 -7
- package/src/agent/approved.ts +261 -0
- package/src/agent/define.ts +235 -0
- package/src/agent/guest.ts +138 -0
- package/src/agent/init.ts +150 -0
- package/src/agent/manifest.ts +141 -0
- package/src/agent/modules.ts +23 -0
- package/src/agent/runtime.ts +239 -0
- package/src/agent-profiles.ts +327 -0
- package/src/api/bootstrap-contract.ts +95 -0
- package/src/api/channel-contract.ts +19 -0
- package/src/api/client.ts +100 -0
- package/src/api/contract.ts +2454 -0
- package/src/api/events-contract.ts +103 -0
- package/src/api/import-contract.ts +22 -0
- package/src/api/orchestrator-contract.ts +73 -0
- package/src/api/runner-contract.ts +25 -0
- package/src/api/scopes.ts +41 -0
- package/src/api/sessions-contract.ts +71 -0
- package/src/api/settings-contract.ts +50 -0
- package/src/channel/bridge.ts +97 -0
- package/src/channel/local.ts +154 -0
- package/src/channel/state.ts +11 -0
- package/src/channel/wire.ts +104 -0
- package/src/dev-sync.ts +206 -0
- package/src/dev.ts +453 -0
- package/src/events-tail.ts +75 -0
- package/src/images.ts +498 -0
- package/src/index.ts +21 -0
- package/src/invocation.ts +34 -0
- package/src/isolation/anchored-fs.ts +284 -0
- package/src/isolation/colima.ts +159 -0
- package/src/isolation/container.ts +189 -0
- package/src/isolation/firecracker.ts +414 -0
- package/src/isolation/guest-protocol.json +1 -0
- package/src/isolation/host-user.ts +247 -0
- package/src/isolation/image.ts +336 -0
- package/src/isolation/index.ts +477 -0
- package/src/isolation/multipass.ts +541 -0
- package/src/isolation/network.ts +167 -0
- package/src/isolation/policy.ts +86 -0
- package/src/isolation/session.ts +385 -0
- package/src/isolation/sync.ts +329 -0
- package/src/isolation/vz-network-setup.ts +247 -0
- package/src/isolation/vz.ts +312 -0
- package/src/mirab-main.ts +536 -0
- package/src/mirab.ts +13 -0
- package/src/runner/define.ts +187 -0
- package/src/runner/image.ts +239 -0
- package/src/runner/index.ts +37 -0
- package/src/runner/serve.ts +491 -0
- package/src/runner/toolsets.ts +205 -0
- package/src/spawn-adapters/claude.ts +112 -0
- package/src/spawn-adapters/codex-logs.ts +130 -0
- package/src/spawn-adapters/codex-notify.ts +73 -0
- package/src/spawn-adapters/codex.ts +89 -0
- package/src/spawn-adapters/index.ts +40 -0
- package/src/spawn-adapters/types.ts +55 -0
- package/src/spawn-attach.ts +243 -0
- package/src/spawn-binary.ts +90 -0
- package/src/spawn-bridge.ts +504 -0
- package/src/spawn-bundle.ts +16 -0
- package/src/spawn-detach.ts +301 -0
- package/src/spawn-events.ts +35 -0
- package/src/spawn-hook.ts +86 -0
- package/src/spawn-input.ts +107 -0
- package/src/spawn-native.ts +49 -0
- package/src/spawn-nudge-worker.ts +61 -0
- package/src/spawn-nudge.ts +446 -0
- package/src/spawn-output.ts +45 -0
- package/src/spawn-queue.ts +135 -0
- package/src/spawn-quiet.ts +69 -0
- package/src/spawn-report.ts +114 -0
- package/src/spawn-sessions.ts +166 -0
- package/src/spawn-vm.ts +356 -0
- package/src/spawn-worker.ts +766 -0
- package/src/spawn.ts +468 -0
- package/src/station/config.ts +89 -0
- package/src/station/gateway.ts +94 -0
- package/src/station/vault.ts +96 -0
- package/src/test-cli.ts +90 -0
- package/src/tools.ts +3 -0
- package/types/agent/define.d.ts +76 -0
- package/types/agent/manifest.d.ts +53 -0
- package/types/agent/modules.d.ts +1 -0
- package/types/images.d.ts +124 -0
- package/types/index.d.ts +6 -0
- package/types/isolation/colima.d.ts +37 -0
- package/types/isolation/container.d.ts +25 -0
- package/types/isolation/firecracker.d.ts +55 -0
- package/types/isolation/host-user.d.ts +47 -0
- package/types/isolation/image.d.ts +158 -0
- package/types/isolation/index.d.ts +128 -0
- package/types/isolation/network.d.ts +33 -0
- package/types/isolation/policy.d.ts +29 -0
- package/types/isolation/session.d.ts +99 -0
- package/types/isolation/vz.d.ts +63 -0
- package/types/runner/define.d.ts +101 -0
- package/types/runner/image.d.ts +52 -0
- package/types/runner/index.d.ts +13 -0
- package/types/runner/serve.d.ts +69 -0
- package/types/runner/toolsets.d.ts +35 -0
- package/types/tools.d.ts +2 -0
- package/index.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './define';
|
|
2
|
+
export { buildSteps, cachedRunnerImage, runnerImage, runnerImageKey, runnerImagesDir, runnerRecipe, } from './image';
|
|
3
|
+
export type { RunnerImage, RunnerImageMeta, RunnerRecipe } from './image';
|
|
4
|
+
export { admission, hostLabel, jobEnv, redact, runnersDir, serveRunners, startRunnerVm, stepArgv, } from './serve';
|
|
5
|
+
export type { RunnerState, ServeDeps, ServeOptions, SlotPhase, SlotState, } from './serve';
|
|
6
|
+
export { resolveTools, TOOL_CACHE } from './toolsets';
|
|
7
|
+
/** The VM this host runs runners on: the published guest image (fetched on
|
|
8
|
+
* first use) and the backend's settings from <config dir>/isolation.json. */
|
|
9
|
+
export { requireVm as runnerHostVm } from '../isolation';
|
|
10
|
+
/** This copy's package version: with the commit a package pins mirab at, it
|
|
11
|
+
* names that commit's canary (`<version>-canary-<sha7>`) for runnerHostVm. */
|
|
12
|
+
export { MIRAB_VERSION } from '../isolation/image';
|
|
13
|
+
export type { ResolvedTool } from './toolsets';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type VmConfig } from '../isolation';
|
|
2
|
+
import type { Isolation } from '../isolation/session';
|
|
3
|
+
import { hostRunnerPlatform, type RunnerDefinition, type RunnerPlatform, type RunnerStep } from './define';
|
|
4
|
+
import { type RunnerImage, type RunnerRecipe } from './image';
|
|
5
|
+
export declare const runnersDir: (configDir: string) => string;
|
|
6
|
+
export type SlotPhase = 'image' | 'booting' | 'waiting' | 'busy' | 'stopping';
|
|
7
|
+
export interface SlotState {
|
|
8
|
+
vmName: string;
|
|
9
|
+
phase: SlotPhase;
|
|
10
|
+
since: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RunnerState {
|
|
13
|
+
name: string;
|
|
14
|
+
host: string;
|
|
15
|
+
forge: string;
|
|
16
|
+
image?: string;
|
|
17
|
+
slots: SlotState[];
|
|
18
|
+
jobs: number;
|
|
19
|
+
lastError?: {
|
|
20
|
+
at: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Things serveRunners does to the world; tests pass their own. */
|
|
25
|
+
export interface ServeDeps {
|
|
26
|
+
startVm: (vm: VmConfig, vmDir: string, log: (line: string) => void) => Promise<Isolation>;
|
|
27
|
+
image: (def: RunnerDefinition, recipe: RunnerRecipe) => Promise<RunnerImage>;
|
|
28
|
+
recipe: (def: RunnerDefinition) => Promise<RunnerRecipe>;
|
|
29
|
+
sleep: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
30
|
+
now: () => Date;
|
|
31
|
+
/** How long a minute is (the job and idle timers); tests shorten it. */
|
|
32
|
+
minuteMs: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ServeOptions {
|
|
35
|
+
configDir: string;
|
|
36
|
+
vm: VmConfig;
|
|
37
|
+
/** Names registrations `<host>-<name>-<random>`. */
|
|
38
|
+
host?: string;
|
|
39
|
+
/** RAM all slots together may use (default: host RAM − 3 GiB). */
|
|
40
|
+
budgetMiB?: number;
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
log?: (line: string) => void;
|
|
43
|
+
deps?: Partial<ServeDeps>;
|
|
44
|
+
}
|
|
45
|
+
/** A runner's VM: nothing of the host's inside (no work share or drive) and
|
|
46
|
+
* no guest-to-host port. */
|
|
47
|
+
export declare function startRunnerVm(vm: VmConfig, vmDir: string, log: (line: string) => void): Promise<Isolation>;
|
|
48
|
+
/** A host name usable in a registration name. */
|
|
49
|
+
export declare function hostLabel(name?: string): string;
|
|
50
|
+
/** Replaces every secret value in `line` (the ticket's, while it lives). */
|
|
51
|
+
export declare function redact(line: string, secrets: Iterable<string>): string;
|
|
52
|
+
/** The env every job step gets: base, then the image's toolsets, then the
|
|
53
|
+
* forge's job env, then the step's own (later wins). PATH is composed. */
|
|
54
|
+
export declare function jobEnv(def: RunnerDefinition, image: Pick<RunnerImage['meta'], 'env' | 'path'>, job: Record<string, string>, step?: Record<string, string>): Record<string, string>;
|
|
55
|
+
/** The argv mirab really execs for a step: as the runner user unless asRoot,
|
|
56
|
+
* output lines cut to 4000 characters (the guest channel refuses a line over
|
|
57
|
+
* 32 KiB, which would end the job), the step's exit status kept. */
|
|
58
|
+
export declare function stepArgv(step: RunnerStep): string[];
|
|
59
|
+
/** Refuses a host that can't run these definitions safely. */
|
|
60
|
+
export declare function admission(defs: RunnerDefinition[], o: {
|
|
61
|
+
configDir: string;
|
|
62
|
+
budgetMiB: number;
|
|
63
|
+
backend: 'vz' | 'firecracker';
|
|
64
|
+
filtered: boolean;
|
|
65
|
+
freeBytes: number;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
export declare function serveRunners(defs: RunnerDefinition[], o: ServeOptions): Promise<void>;
|
|
68
|
+
export { hostRunnerPlatform };
|
|
69
|
+
export type { RunnerPlatform };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RunnerPlatform, RunnerStep } from './define';
|
|
2
|
+
export declare const TOOL_CACHE = "/opt/hostedtoolcache";
|
|
3
|
+
export declare const RUST_HOME = "/opt/rust";
|
|
4
|
+
export interface ResolvedTool {
|
|
5
|
+
tool: 'rust' | 'node' | 'go';
|
|
6
|
+
version: string;
|
|
7
|
+
url: string;
|
|
8
|
+
sha256: string;
|
|
9
|
+
/** Hosts the build VM fetches from. */
|
|
10
|
+
hosts: string[];
|
|
11
|
+
}
|
|
12
|
+
export type Fetcher = (url: string) => Promise<string>;
|
|
13
|
+
/** `24` matches 24.x.y, `24.21` matches 24.21.y, `24.21.0` only itself. */
|
|
14
|
+
export declare function versionMatches(spec: string, version: string): boolean;
|
|
15
|
+
declare const nodeArch: (p: RunnerPlatform) => "arm64" | "x64";
|
|
16
|
+
/** The tool cache's arch directory (setup-node and setup-go use these). */
|
|
17
|
+
export declare const cacheArch: typeof nodeArch;
|
|
18
|
+
export declare function resolveNode(spec: string, platform: RunnerPlatform, get?: Fetcher): Promise<ResolvedTool>;
|
|
19
|
+
export declare function resolveGo(spec: string, platform: RunnerPlatform, get?: Fetcher): Promise<ResolvedTool>;
|
|
20
|
+
/** Rust: rustup-init (checked by its published sha256) installs the toolchain
|
|
21
|
+
* `spec`; rustup checks every component it downloads itself. */
|
|
22
|
+
export declare function resolveRust(spec: string, platform: RunnerPlatform, get?: Fetcher): Promise<ResolvedTool>;
|
|
23
|
+
export declare function resolveTools(tools: {
|
|
24
|
+
rust?: string;
|
|
25
|
+
node?: string;
|
|
26
|
+
go?: string;
|
|
27
|
+
}, platform: RunnerPlatform, get?: Fetcher): Promise<ResolvedTool[]>;
|
|
28
|
+
/** The build steps (root, in the build VM) for the resolved toolsets. */
|
|
29
|
+
export declare function toolSteps(tools: ResolvedTool[], platform: RunnerPlatform): RunnerStep[];
|
|
30
|
+
/** What a job's env needs to find the toolsets (merged into the base env). */
|
|
31
|
+
export declare function toolEnv(tools: ResolvedTool[], platform: RunnerPlatform): {
|
|
32
|
+
env: Record<string, string>;
|
|
33
|
+
path: string[];
|
|
34
|
+
};
|
|
35
|
+
export {};
|
package/types/tools.d.ts
ADDED
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
throw new Error("mirab isn't released yet. This version reserves the name; watch https://addis.gg for the first release.")
|