@aeolus-fleet/trierarch 0.24.1 → 0.25.1
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/README.md +1 -0
- package/dist/adapters/claude-code-home.d.ts +43 -0
- package/dist/adapters/claude-code-home.js +51 -0
- package/dist/adapters/claude-code-home.js.map +1 -0
- package/dist/adapters/claude-code.d.ts +12 -5
- package/dist/adapters/claude-code.js +33 -10
- package/dist/adapters/claude-code.js.map +1 -1
- package/dist/adapters/clone-workspace.d.ts +6 -0
- package/dist/adapters/clone-workspace.js +79 -0
- package/dist/adapters/clone-workspace.js.map +1 -0
- package/dist/adapters/codex.d.ts +2 -3
- package/dist/adapters/codex.js +9 -4
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/container-host.d.ts +15 -0
- package/dist/adapters/container-host.js +52 -0
- package/dist/adapters/container-host.js.map +1 -0
- package/dist/adapters/container.d.ts +43 -0
- package/dist/adapters/container.js +176 -0
- package/dist/adapters/container.js.map +1 -0
- package/dist/adapters/harnesses.d.ts +7 -3
- package/dist/adapters/harnesses.js +2 -2
- package/dist/adapters/harnesses.js.map +1 -1
- package/dist/adapters/json-state.js +0 -1
- package/dist/adapters/json-state.js.map +1 -1
- package/dist/adapters/paths.d.ts +7 -0
- package/dist/adapters/paths.js +6 -0
- package/dist/adapters/paths.js.map +1 -1
- package/dist/adapters/plugin-identity.d.ts +9 -1
- package/dist/adapters/plugin-identity.js +23 -3
- package/dist/adapters/plugin-identity.js.map +1 -1
- package/dist/adapters/runtime-adapters.d.ts +27 -0
- package/dist/adapters/runtime-adapters.js +30 -0
- package/dist/adapters/runtime-adapters.js.map +1 -0
- package/dist/adapters/tmux.d.ts +12 -30
- package/dist/adapters/tmux.js +11 -0
- package/dist/adapters/tmux.js.map +1 -1
- package/dist/cli/config-check.d.ts +13 -2
- package/dist/cli/config-check.js +20 -1
- package/dist/cli/config-check.js.map +1 -1
- package/dist/cli/main.js +2 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/run.js +16 -8
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/status.d.ts +2 -2
- package/dist/core/check-session-runtime.d.ts +15 -0
- package/dist/core/check-session-runtime.js +49 -0
- package/dist/core/check-session-runtime.js.map +1 -0
- package/dist/core/entry.d.ts +0 -5
- package/dist/core/entry.js.map +1 -1
- package/dist/core/ports.d.ts +60 -8
- package/dist/core/reconciler.d.ts +2 -1
- package/dist/core/reconciler.js +7 -10
- package/dist/core/reconciler.js.map +1 -1
- package/dist/core/report-self.d.ts +2 -2
- package/dist/core/report-self.js +2 -0
- package/dist/core/report-self.js.map +1 -1
- package/dist/core/run-pass.d.ts +2 -2
- package/dist/core/run-pass.js +15 -10
- package/dist/core/run-pass.js.map +1 -1
- package/dist/core/uninstall.d.ts +2 -2
- package/dist/core/uninstall.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ To stop the trierarch: `aeolus-trierarch stop`, or `aeolus-trierarch uninstall`
|
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
- **runtime** (optional): where the sessions run, on the host when left out, or each in a container of its own: `{ "kind": "container", "binary": "podman", "memory": "4g", "cpus": 2 }`, with the model token in `~/.aeolus/trierarch/model-token`. What a container holds and what `config check` refuses with it: [docs/trierarch.md](../../docs/trierarch.md#session-runtime).
|
|
83
84
|
- **caps**: how many ships it takes (the trierarch plugin assigns it no more), and how many sessions run at once.
|
|
84
85
|
- **repositories**: by name. A crew request for a worktree of one gets a git worktree under `~/.aeolus/trierarch/worktrees/<repository>/<ship>`, detached at the settings' ref or the repository's HEAD. It fetches the repository first, and a ref `origin` has a branch for checks out that remote branch (`origin/<ref>`), so a ship starts from current code; when the fetch fails it uses what the repository has. `worktreeRoot` moves that root.
|
|
85
86
|
- **folders**: by name, used as they are, one ship per folder, never removed.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ShipId } from '@aeolus-fleet/common';
|
|
2
|
+
import { type ClaudeCodeSetup } from './claude-code-setup.js';
|
|
3
|
+
import type { AeolusPlugin } from './plugin-identity.js';
|
|
4
|
+
/** Where a ship's Claude Code session keeps its files: its identity through the aeolus plugin, its conversations, and Claude Code's own files. */
|
|
5
|
+
export interface ClaudeCodeHome {
|
|
6
|
+
readonly plugin: AeolusPlugin;
|
|
7
|
+
/** Claude Code's projects folder, where it keeps each folder's conversations. */
|
|
8
|
+
readonly projects: string;
|
|
9
|
+
readonly setup: Pick<ClaudeCodeSetup, 'completeOnboarding' | 'defaultPermissionMode'>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The homes of the Claude Code sessions (decision 0039): on the host every
|
|
13
|
+
* session shares the user's own home; in containers each ship has a home of
|
|
14
|
+
* its own, which its container gets as its home.
|
|
15
|
+
*/
|
|
16
|
+
export interface ClaudeCodeHomes {
|
|
17
|
+
of(shipId: ShipId): ClaudeCodeHome;
|
|
18
|
+
/** Answers Claude Code's one-time questions in the ship's home before a launch, a restart too, so the session asks nothing (#403). */
|
|
19
|
+
prepare(session: {
|
|
20
|
+
shipId: ShipId;
|
|
21
|
+
folder: string;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/** Removes the ship's home, once its identity goes. */
|
|
24
|
+
remove(shipId: ShipId): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/** The host's own home for every session: its onboarding completed before each launch; it is never removed. */
|
|
27
|
+
export declare function createHostClaudeCodeHomes(home: ClaudeCodeHome): ClaudeCodeHomes;
|
|
28
|
+
/**
|
|
29
|
+
* A home of each ship's own under `homes` (`~/.aeolus/trierarch/homes/<shipId>`),
|
|
30
|
+
* holding its identity and Claude Code's files and nothing of another ship.
|
|
31
|
+
* The identity goes through the host's aeolus plugin scripts into the home's
|
|
32
|
+
* crews folder, where the image's plugin of the same version finds it. Before
|
|
33
|
+
* each launch, the onboarding is completed and the workspace trusted at its
|
|
34
|
+
* path, which the container mounts at the same path; bypass permissions mode
|
|
35
|
+
* is accepted only where the operator accepted it on the host (#403). It goes
|
|
36
|
+
* with the ship's identity, as on a release.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createShipClaudeCodeHomes(at: {
|
|
39
|
+
homes: string;
|
|
40
|
+
managedSettings: string;
|
|
41
|
+
pluginRoot: string;
|
|
42
|
+
host: Pick<ClaudeCodeSetup, 'isSkipPermissionsAccepted'>;
|
|
43
|
+
}): ClaudeCodeHomes;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mkdir, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { createClaudeCodeSetup } from './claude-code-setup.js';
|
|
4
|
+
import { shipHome } from './paths.js';
|
|
5
|
+
import { PLUGIN_DATA_FOLDER } from './plugin.js';
|
|
6
|
+
/** The host's own home for every session: its onboarding completed before each launch; it is never removed. */
|
|
7
|
+
export function createHostClaudeCodeHomes(home) {
|
|
8
|
+
return {
|
|
9
|
+
of: () => home,
|
|
10
|
+
prepare: () => home.setup.completeOnboarding(),
|
|
11
|
+
remove: () => Promise.resolve(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** A home only its owner reads, as it holds the ship's crew token. */
|
|
15
|
+
const PRIVATE_FOLDER_MODE = 0o700;
|
|
16
|
+
/**
|
|
17
|
+
* A home of each ship's own under `homes` (`~/.aeolus/trierarch/homes/<shipId>`),
|
|
18
|
+
* holding its identity and Claude Code's files and nothing of another ship.
|
|
19
|
+
* The identity goes through the host's aeolus plugin scripts into the home's
|
|
20
|
+
* crews folder, where the image's plugin of the same version finds it. Before
|
|
21
|
+
* each launch, the onboarding is completed and the workspace trusted at its
|
|
22
|
+
* path, which the container mounts at the same path; bypass permissions mode
|
|
23
|
+
* is accepted only where the operator accepted it on the host (#403). It goes
|
|
24
|
+
* with the ship's identity, as on a release.
|
|
25
|
+
*/
|
|
26
|
+
export function createShipClaudeCodeHomes(at) {
|
|
27
|
+
const setupOf = (shipId) => createClaudeCodeSetup({ homeDirectory: shipHome(at.homes, shipId), managedSettings: at.managedSettings });
|
|
28
|
+
return {
|
|
29
|
+
of: (shipId) => {
|
|
30
|
+
const home = shipHome(at.homes, shipId);
|
|
31
|
+
return {
|
|
32
|
+
plugin: { root: at.pluginRoot, data: join(home, '.claude', 'plugins', 'data', PLUGIN_DATA_FOLDER), crews: join(home, '.aeolus', 'crews', 'claude-code') },
|
|
33
|
+
projects: join(home, '.claude', 'projects'),
|
|
34
|
+
setup: setupOf(shipId),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
prepare: async ({ shipId, folder }) => {
|
|
38
|
+
await mkdir(shipHome(at.homes, shipId), { recursive: true, mode: PRIVATE_FOLDER_MODE });
|
|
39
|
+
const setup = setupOf(shipId);
|
|
40
|
+
await setup.completeOnboarding();
|
|
41
|
+
await setup.trust(folder);
|
|
42
|
+
if (await at.host.isSkipPermissionsAccepted()) {
|
|
43
|
+
await setup.acceptSkipPermissions();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
remove: async (shipId) => {
|
|
47
|
+
await rm(shipHome(at.homes, shipId), { recursive: true, force: true });
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=claude-code-home.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-home.js","sourceRoot":"","sources":["../../src/adapters/claude-code-home.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAuBjD,+GAA+G;AAC/G,MAAM,UAAU,yBAAyB,CAAC,IAAoB;IAC5D,OAAO;QACL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ACxF,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,MAAM,KAAK,CAAC,kBAAkB,EAAE,CAAC;YACjC,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,CAAC;gBAC9C,MAAM,KAAK,CAAC,qBAAqB,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACvB,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { TrierarchConfiguration } from '@aeolus-fleet/common';
|
|
2
|
-
import type { AdapterFlag, HarnessPort } from '../core/ports.js';
|
|
2
|
+
import type { AdapterFlag, HarnessPort, SessionRuntime } from '../core/ports.js';
|
|
3
3
|
import { type ClaudeCodeSetup, type SettingsDefaultMode } from './claude-code-setup.js';
|
|
4
4
|
import { type CommandPart } from './command-line.js';
|
|
5
5
|
import { type AeolusPlugin } from './plugin-identity.js';
|
|
6
|
-
import type { Tmux } from './tmux.js';
|
|
7
6
|
/**
|
|
8
7
|
* Claude Code as a harness (docs/architecture.md, "First adapters"): `claude`
|
|
9
8
|
* in the folder, `--continue` on a restart when the folder has a conversation
|
|
@@ -22,7 +21,10 @@ import type { Tmux } from './tmux.js';
|
|
|
22
21
|
* where Claude Code never ran by hand stops at no first-run screen (#403). A
|
|
23
22
|
* session's identity is written and read through the aeolus
|
|
24
23
|
* plugin's own `aeolus-identity.sh`, never a copy of how the plugin names its
|
|
25
|
-
* files.
|
|
24
|
+
* files. On the host every session shares the user's home; with ship homes,
|
|
25
|
+
* for sessions in containers, each ship's identity, conversations and Claude
|
|
26
|
+
* Code's files live in a home of its own, removed with its identity
|
|
27
|
+
* (decision 0039).
|
|
26
28
|
*/
|
|
27
29
|
export declare const WAKE_PROMPT = "/aeolus:wake";
|
|
28
30
|
/** The variable a session's launch id is passed in, for the plugin's hooks to mark that launch (#490). */
|
|
@@ -50,11 +52,16 @@ export declare function claudeCodeCommandLine(at: {
|
|
|
50
52
|
export declare function createClaudeCodeHarness(options: {
|
|
51
53
|
configuration: TrierarchConfiguration;
|
|
52
54
|
plugin: AeolusPlugin;
|
|
53
|
-
sessions: Pick<
|
|
55
|
+
sessions: Pick<SessionRuntime, 'start' | 'type' | 'screen'>;
|
|
54
56
|
/** Claude Code's projects folder, where it keeps each folder's conversations. */
|
|
55
57
|
projects: string;
|
|
56
58
|
/** Claude Code's own files, where its onboarding is completed before each launch (#403) and its settings' default mode is read (#505, #507). */
|
|
57
|
-
setup: Pick<ClaudeCodeSetup, 'completeOnboarding' | 'defaultPermissionMode'>;
|
|
59
|
+
setup: Pick<ClaudeCodeSetup, 'completeOnboarding' | 'defaultPermissionMode' | 'isSkipPermissionsAccepted'>;
|
|
60
|
+
/** For sessions in containers: a home of each ship's own under `homes`, in place of the host's (decision 0039). */
|
|
61
|
+
shipHomes?: {
|
|
62
|
+
homes: string;
|
|
63
|
+
managedSettings: string;
|
|
64
|
+
};
|
|
58
65
|
/** The permission modes the installed Claude Code lists, as detection last found them (#517); undefined before it found any. */
|
|
59
66
|
permissionModes: () => readonly string[] | undefined;
|
|
60
67
|
/** The program to run; `claude` unless a test runs another. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdir } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { createHostClaudeCodeHomes, createShipClaudeCodeHomes } from './claude-code-home.js';
|
|
3
4
|
import { claudeCodeScreenStoppedAt } from './claude-code-screen.js';
|
|
4
5
|
import { SETTING_SOURCES } from './claude-code-setup.js';
|
|
5
6
|
import { partsWithWords, wordsOf } from './command-line.js';
|
|
@@ -25,7 +26,10 @@ import { createPluginIdentity } from './plugin-identity.js';
|
|
|
25
26
|
* where Claude Code never ran by hand stops at no first-run screen (#403). A
|
|
26
27
|
* session's identity is written and read through the aeolus
|
|
27
28
|
* plugin's own `aeolus-identity.sh`, never a copy of how the plugin names its
|
|
28
|
-
* files.
|
|
29
|
+
* files. On the host every session shares the user's home; with ship homes,
|
|
30
|
+
* for sessions in containers, each ship's identity, conversations and Claude
|
|
31
|
+
* Code's files live in a home of its own, removed with its identity
|
|
32
|
+
* (decision 0039).
|
|
29
33
|
*/
|
|
30
34
|
export const WAKE_PROMPT = '/aeolus:wake';
|
|
31
35
|
/** The variable a session's launch id is passed in, for the plugin's hooks to mark that launch (#490). */
|
|
@@ -134,36 +138,55 @@ async function hasConversation(projects, folder) {
|
|
|
134
138
|
}
|
|
135
139
|
export function createClaudeCodeHarness(options) {
|
|
136
140
|
const { configuration, plugin, sessions } = options;
|
|
137
|
-
const
|
|
141
|
+
const homes = options.shipHomes === undefined
|
|
142
|
+
? createHostClaudeCodeHomes({ plugin, projects: options.projects, setup: options.setup })
|
|
143
|
+
: createShipClaudeCodeHomes({ ...options.shipHomes, pluginRoot: plugin.root, host: options.setup });
|
|
144
|
+
const identityOf = (shipId) => createPluginIdentity(homes.of(shipId).plugin);
|
|
145
|
+
const marksOf = (shipId) => createLaunchMarks(homes.of(shipId).plugin);
|
|
138
146
|
return {
|
|
139
|
-
|
|
147
|
+
prepareIdentity: (at) => identityOf(at.identity.shipId).prepareIdentity(at),
|
|
148
|
+
crewTokenOf: (session) => identityOf(session.shipId).crewTokenOf(session),
|
|
149
|
+
removeIdentity: async (session) => {
|
|
150
|
+
await identityOf(session.shipId).removeIdentity(session);
|
|
151
|
+
await homes.remove(session.shipId);
|
|
152
|
+
},
|
|
153
|
+
turnOf: (session) => identityOf(session.shipId).turnOf(session),
|
|
140
154
|
launch: async ({ shipId, shipName, folder, workspace, harness, options: picked, isFirstStart, launchId, firstPrompt }) => {
|
|
141
155
|
const settings = configuration.harnesses[harness];
|
|
142
156
|
if (settings === undefined) {
|
|
143
157
|
throw new Error(`The configuration has no harness ${harness}`);
|
|
144
158
|
}
|
|
159
|
+
const home = homes.of(shipId);
|
|
160
|
+
await homes.prepare({ shipId, folder });
|
|
145
161
|
const prompt = isFirstStart && firstPrompt !== undefined ? firstPromptOf(firstPrompt) : wakePromptOf(WAKE_PROMPT);
|
|
146
162
|
const flags = effectiveFlags(settings, picked);
|
|
147
163
|
const command = claudeCodeCommandLine({
|
|
148
164
|
flags,
|
|
149
165
|
sessionName: `[${workspace.kind === 'worktree' ? workspace.repository : workspace.name}] ${shipName}`,
|
|
150
166
|
prompt,
|
|
151
|
-
isFirstStart: isFirstStart || !(await hasConversation(
|
|
152
|
-
defaultPermissionMode: await claudeCodeSettingsDefaultMode(
|
|
167
|
+
isFirstStart: isFirstStart || !(await hasConversation(home.projects, folder)),
|
|
168
|
+
defaultPermissionMode: await claudeCodeSettingsDefaultMode(home.setup, { flags, folder }),
|
|
153
169
|
permissionModes: options.permissionModes(),
|
|
154
170
|
...(options.command !== undefined && { program: options.command }),
|
|
155
171
|
});
|
|
156
|
-
|
|
172
|
+
const marks = marksOf(shipId);
|
|
157
173
|
await marks.clear(folder);
|
|
158
174
|
await sessions.start({ shipId, folder, command: wordsOf(command), env: { [LAUNCH_VARIABLE]: launchId } });
|
|
159
175
|
},
|
|
160
|
-
|
|
161
|
-
|
|
176
|
+
handOver: async (session) => {
|
|
177
|
+
const line = await identityOf(session.shipId).handOverLine(session);
|
|
178
|
+
if (line === undefined) {
|
|
179
|
+
return 'nothing';
|
|
180
|
+
}
|
|
181
|
+
await sessions.type({ shipId: session.shipId, text: wakePromptOf(line) });
|
|
182
|
+
return 'handed';
|
|
162
183
|
},
|
|
163
|
-
|
|
184
|
+
isHolding: (session) => identityOf(session.shipId).isHolding(session),
|
|
185
|
+
sessionDied: (session) => identityOf(session.shipId).sessionDied(session),
|
|
186
|
+
marksLaunches: () => createLaunchMarks(plugin).isMarking(),
|
|
164
187
|
// The marker says what the session did; the screen only names one that stopped it before its hooks ran (#490).
|
|
165
188
|
launchSeen: async ({ shipId, folder, launchId, model }) => {
|
|
166
|
-
const marker = await
|
|
189
|
+
const marker = await marksOf(shipId).read({ folder, launchId });
|
|
167
190
|
if (marker?.refused !== undefined) {
|
|
168
191
|
const refused = model ?? marker.refused.model;
|
|
169
192
|
return { kind: 'refused', ...(refused !== undefined && { model: refused }) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAsE,MAAM,wBAAwB,CAAC;AAC7H,OAAO,EAAE,cAAc,EAAE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAqB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAsE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AAO,CAAC,KAAK,CAAC;gBAC9C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;YAC/E,CAAC;YACD,IAAI,MAAM,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC9B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC5B,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACjH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACnE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { mkdir, rm, stat } from 'node:fs/promises';
|
|
2
|
+
import { join, relative, sep } from 'node:path';
|
|
3
|
+
import { createGitWorkspace } from './git-workspace.js';
|
|
4
|
+
import { runCommand } from './run-command.js';
|
|
5
|
+
/**
|
|
6
|
+
* Workspaces for sessions in containers (decision 0039; trierarch.md, "Session
|
|
7
|
+
* runtime"): a per-ship clone of a configured repository in place of a
|
|
8
|
+
* worktree, at the same path (`<root>/<repository>/<ship>`). A worktree points
|
|
9
|
+
* into the repository's `.git`, its hooks and every other ship's worktree data;
|
|
10
|
+
* a clone has a `.git` of its own. `--reference` with `--dissociate` borrows
|
|
11
|
+
* the repository's objects only while cloning, so the clone holds its own and
|
|
12
|
+
* no gc of the repository can break it. Its origin is the repository's own
|
|
13
|
+
* remote, so the session pushes without the host, with the remote branches as
|
|
14
|
+
* the repository last fetched them; a repository with no remote leaves the
|
|
15
|
+
* clone with none. The ref resolves as a worktree's does. A configured folder,
|
|
16
|
+
* cleanliness, what removing discards and the listing are a worktree's.
|
|
17
|
+
*/
|
|
18
|
+
const REMOTE = 'origin';
|
|
19
|
+
export function createCloneWorkspace(options) {
|
|
20
|
+
const { configuration, root } = options;
|
|
21
|
+
const worktrees = createGitWorkspace(options);
|
|
22
|
+
const git = async (args) => {
|
|
23
|
+
const result = await runCommand('git', { args });
|
|
24
|
+
if (result.status !== 0) {
|
|
25
|
+
throw new Error(`git ${args.join(' ')} failed: ${result.stderr.trim()}`);
|
|
26
|
+
}
|
|
27
|
+
return result.stdout;
|
|
28
|
+
};
|
|
29
|
+
/** The commit of the remote branch for the ref when the remote has one, else of the ref as it is, or of HEAD with none. */
|
|
30
|
+
const resolve = async (repository, ref) => {
|
|
31
|
+
if (ref === undefined) {
|
|
32
|
+
return (await git(['-C', repository, 'rev-parse', '--verify', 'HEAD^{commit}'])).trim();
|
|
33
|
+
}
|
|
34
|
+
const remote = await runCommand('git', { args: ['-C', repository, 'rev-parse', '--verify', '--quiet', `refs/remotes/${REMOTE}/${ref}^{commit}`] });
|
|
35
|
+
return remote.status === 0 ? remote.stdout.trim() : (await git(['-C', repository, 'rev-parse', '--verify', `${ref}^{commit}`])).trim();
|
|
36
|
+
};
|
|
37
|
+
const exists = async (path) => (await stat(path).catch(() => undefined)) !== undefined;
|
|
38
|
+
const isUnderRoot = (folder) => {
|
|
39
|
+
const [repository, ship, ...rest] = relative(root, folder).split(sep);
|
|
40
|
+
return repository !== undefined && ship !== undefined && rest.length === 0 && configuration.repositories[repository] !== undefined && ship !== '' && ship !== '..';
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
...worktrees,
|
|
44
|
+
prepare: async (request) => {
|
|
45
|
+
const { shipName, workspace } = request;
|
|
46
|
+
if (workspace.kind === 'folder') {
|
|
47
|
+
return worktrees.prepare(request);
|
|
48
|
+
}
|
|
49
|
+
const repository = configuration.repositories[workspace.repository]?.path;
|
|
50
|
+
if (repository === undefined) {
|
|
51
|
+
throw new Error(`The configuration has no repository ${workspace.repository}`);
|
|
52
|
+
}
|
|
53
|
+
const folder = join(root, workspace.repository, shipName);
|
|
54
|
+
// A clone a stop mid-crew left is used as it is.
|
|
55
|
+
if (!(await exists(folder))) {
|
|
56
|
+
await mkdir(join(root, workspace.repository), { recursive: true });
|
|
57
|
+
await runCommand('git', { args: ['-C', repository, 'fetch', '--quiet', REMOTE] });
|
|
58
|
+
const commit = await resolve(repository, workspace.ref);
|
|
59
|
+
await git(['clone', '--quiet', '--no-checkout', '--reference', repository, '--dissociate', repository, folder]);
|
|
60
|
+
// The clone's origin is the repository's checkout, whose branches are no remote's: dropped with it.
|
|
61
|
+
await git(['-C', folder, 'remote', 'remove', REMOTE]);
|
|
62
|
+
const remote = await runCommand('git', { args: ['-C', repository, 'remote', 'get-url', REMOTE] });
|
|
63
|
+
if (remote.status === 0) {
|
|
64
|
+
await git(['-C', folder, 'remote', 'add', REMOTE, remote.stdout.trim()]);
|
|
65
|
+
await git(['-C', folder, 'fetch', '--quiet', '--no-tags', repository, `+refs/remotes/${REMOTE}/*:refs/remotes/${REMOTE}/*`]);
|
|
66
|
+
}
|
|
67
|
+
await git(['-C', folder, 'checkout', '--quiet', '--detach', commit]);
|
|
68
|
+
}
|
|
69
|
+
return { folder };
|
|
70
|
+
},
|
|
71
|
+
remove: async (folder) => {
|
|
72
|
+
if (!isUnderRoot(folder)) {
|
|
73
|
+
throw new Error(`${folder} is no clone under ${root}: the trierarch removes only what it made`);
|
|
74
|
+
}
|
|
75
|
+
await rm(folder, { recursive: true, force: true });
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=clone-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-workspace.js","sourceRoot":"","sources":["../../src/adapters/clone-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,E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C,IAAI,EAAE,CAAC,CAAC,CAAC;oBACzE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,MAAM,mBAAmB,MAAM,IAAI,CAAC,CAAC,CAAC;gBAC/H,CAAC;gBACD,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACvB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,sBAAsB,IAAI,2CAA2C,CAAC,CAAC;YAClG,CAAC;YACD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/adapters/codex.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { TrierarchConfiguration } from '@aeolus-fleet/common';
|
|
2
|
-
import type { AdapterFlag, HarnessPort } from '../core/ports.js';
|
|
2
|
+
import type { AdapterFlag, HarnessPort, SessionRuntime } from '../core/ports.js';
|
|
3
3
|
import type { CodexSetup } from './codex-setup.js';
|
|
4
4
|
import { type CommandPart } from './command-line.js';
|
|
5
5
|
import { type AeolusPlugin } from './plugin-identity.js';
|
|
6
|
-
import type { Tmux } from './tmux.js';
|
|
7
6
|
/**
|
|
8
7
|
* Codex as a harness (docs/architecture.md, "First adapters"): `codex` in the
|
|
9
8
|
* folder, `codex resume --last` on a restart (the folder's last conversation;
|
|
@@ -34,7 +33,7 @@ export declare function codexCommandLine(at: {
|
|
|
34
33
|
export declare function createCodexHarness(options: {
|
|
35
34
|
configuration: TrierarchConfiguration;
|
|
36
35
|
plugin: AeolusPlugin;
|
|
37
|
-
sessions: Pick<
|
|
36
|
+
sessions: Pick<SessionRuntime, 'start' | 'type' | 'screen'>;
|
|
38
37
|
/** Codex's own answers, where the aeolus plugin's hooks are trusted before each launch (#581). */
|
|
39
38
|
setup: Pick<CodexSetup, 'trustAeolusHooks'>;
|
|
40
39
|
/** The program to run; `codex` unless a test runs another. */
|
package/dist/adapters/codex.js
CHANGED
|
@@ -66,8 +66,9 @@ async function sessionLog(path) {
|
|
|
66
66
|
export function createCodexHarness(options) {
|
|
67
67
|
const { configuration, plugin, sessions } = options;
|
|
68
68
|
const marks = createLaunchMarks(plugin);
|
|
69
|
+
const { handOverLine, ...identity } = createPluginIdentity(plugin);
|
|
69
70
|
return {
|
|
70
|
-
...
|
|
71
|
+
...identity,
|
|
71
72
|
launch: async ({ shipId, folder, harness, options: picked, isFirstStart, launchId, firstPrompt }) => {
|
|
72
73
|
const settings = configuration.harnesses[harness];
|
|
73
74
|
if (settings === undefined) {
|
|
@@ -79,9 +80,13 @@ export function createCodexHarness(options) {
|
|
|
79
80
|
await marks.clear(folder);
|
|
80
81
|
await sessions.start({ shipId, folder, command: wordsOf(command), env: { [LAUNCH_VARIABLE]: launchId } });
|
|
81
82
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
handOver: async (session) => {
|
|
84
|
+
const line = await handOverLine(session);
|
|
85
|
+
if (line === undefined) {
|
|
86
|
+
return 'nothing';
|
|
87
|
+
}
|
|
88
|
+
await sessions.type({ shipId: session.shipId, text: wakePromptOf(line), settleMs: CODEX_TYPING_SETTLE_MS });
|
|
89
|
+
return 'handed';
|
|
85
90
|
},
|
|
86
91
|
marksLaunches: () => marks.isMarking(),
|
|
87
92
|
// The marker says what the session did (#490); Codex has no hook for a failed turn, so a refusal is read from the session log its session start named.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAqB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAK5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAqB,MAAM,sBAAsB,CAAC;AAE/E;;;;;;;;;;GAUG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAA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IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAC7C,CAAC;YACD,IAAI,MAAM,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC9B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC5B,CAAC;YACD,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/G,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;QACjF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContainerHostPort } from '../core/ports.js';
|
|
2
|
+
import { type CommandResult } from './run-command.js';
|
|
3
|
+
type Run = (command: string, options: {
|
|
4
|
+
args: readonly string[];
|
|
5
|
+
}) => Promise<CommandResult>;
|
|
6
|
+
/**
|
|
7
|
+
* The machine as the container runtime's checks read it (decision 0039): how
|
|
8
|
+
* the runtime runs, from the info Podman and docker both give as JSON; the
|
|
9
|
+
* user's groups, from `id`; and whether the model token file holds a token.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createContainerHost(options: {
|
|
12
|
+
modelTokenFile: string;
|
|
13
|
+
run?: Run;
|
|
14
|
+
}): ContainerHostPort;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { runCommand } from './run-command.js';
|
|
4
|
+
/** What Podman's info says of how it runs. */
|
|
5
|
+
const podmanInfoSchema = z.object({ host: z.object({ security: z.object({ rootless: z.boolean() }) }) });
|
|
6
|
+
/** What docker's info says of how its daemon runs: `name=rootless` among its security options when rootless. */
|
|
7
|
+
const dockerInfoSchema = z.object({ SecurityOptions: z.array(z.string()) });
|
|
8
|
+
const DOCKER_ROOTLESS = 'name=rootless';
|
|
9
|
+
function modeOfInfo(stdout) {
|
|
10
|
+
let body;
|
|
11
|
+
try {
|
|
12
|
+
body = JSON.parse(stdout);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return 'missing';
|
|
16
|
+
}
|
|
17
|
+
const podman = podmanInfoSchema.safeParse(body);
|
|
18
|
+
if (podman.success) {
|
|
19
|
+
return podman.data.host.security.rootless ? 'rootless' : 'rootful';
|
|
20
|
+
}
|
|
21
|
+
const docker = dockerInfoSchema.safeParse(body);
|
|
22
|
+
if (docker.success) {
|
|
23
|
+
return docker.data.SecurityOptions.includes(DOCKER_ROOTLESS) ? 'rootless' : 'rootful';
|
|
24
|
+
}
|
|
25
|
+
return 'missing';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The machine as the container runtime's checks read it (decision 0039): how
|
|
29
|
+
* the runtime runs, from the info Podman and docker both give as JSON; the
|
|
30
|
+
* user's groups, from `id`; and whether the model token file holds a token.
|
|
31
|
+
*/
|
|
32
|
+
export function createContainerHost(options) {
|
|
33
|
+
const run = options.run ?? runCommand;
|
|
34
|
+
return {
|
|
35
|
+
runtimeMode: async (binary) => {
|
|
36
|
+
const answered = await run(binary, { args: ['info', '--format', 'json'] }).catch(() => undefined);
|
|
37
|
+
return answered?.status === 0 ? modeOfInfo(answered.stdout) : 'missing';
|
|
38
|
+
},
|
|
39
|
+
userGroups: async () => {
|
|
40
|
+
const answered = await run('id', { args: ['-Gn'] });
|
|
41
|
+
if (answered.status !== 0) {
|
|
42
|
+
throw new Error(`id -Gn failed: ${answered.stderr.trim()}`);
|
|
43
|
+
}
|
|
44
|
+
return answered.stdout.split(/\s+/).filter((group) => group !== '');
|
|
45
|
+
},
|
|
46
|
+
isModelTokenWritten: async () => {
|
|
47
|
+
const content = await readFile(options.modelTokenFile, 'utf8').catch(() => '');
|
|
48
|
+
return content.trim() !== '';
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=container-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-host.js","sourceRoot":"","sources":["../../src/adapters/container-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAsB,MAAM,kBAAkB,CAAC;AAIlE,8CAA8C;AAC9C,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACzG,gHAAgH;AAChH,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC5E,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,SAAS,UAAU,CAAC,MAAc;IAChC,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAA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AAC,CAAC;QACtE,CAAC;QACD,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAC9B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAC/E,OAAO,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SessionRuntime } from '../core/ports.js';
|
|
2
|
+
import { type CommandResult } from './run-command.js';
|
|
3
|
+
/** The variable Claude Code reads its long-lived model token from (`claude setup-token`). */
|
|
4
|
+
export declare const MODEL_TOKEN_VARIABLE = "CLAUDE_CODE_OAUTH_TOKEN";
|
|
5
|
+
/** The session user's home in the image, where each container gets its ship's own home. */
|
|
6
|
+
export declare const SESSION_HOME = "/home/ubuntu";
|
|
7
|
+
type Run = (command: string, options: {
|
|
8
|
+
args: readonly string[];
|
|
9
|
+
}) => Promise<CommandResult>;
|
|
10
|
+
export interface ContainerRuntimeOptions {
|
|
11
|
+
/** The docker-style binary of a rootless runtime: podman on Linux, docker in a Colima context on macOS. */
|
|
12
|
+
readonly binary: string;
|
|
13
|
+
readonly image: string;
|
|
14
|
+
/** The file holding the machine's long-lived model token, read at every start. */
|
|
15
|
+
readonly tokenFile: string;
|
|
16
|
+
/** Where the ships' homes are kept on the host, one folder per ship, each mounted as its container's home. */
|
|
17
|
+
readonly homes: string;
|
|
18
|
+
/** The memory cap of each container, as the runtime takes it (`4g`). */
|
|
19
|
+
readonly memory: string;
|
|
20
|
+
readonly cpus: number;
|
|
21
|
+
/** Tells this trierarch's containers apart from any other on the machine. */
|
|
22
|
+
readonly owner?: string;
|
|
23
|
+
/** What the runtime's run goes through: a systemd scope of its own under a systemd unit (see sessionsLaunch). */
|
|
24
|
+
readonly launch?: readonly string[];
|
|
25
|
+
readonly run?: Run;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The container session runtime (decision 0039): one container per ship,
|
|
29
|
+
* named after its ship id, with tmux inside, so typing and screen reads are an
|
|
30
|
+
* exec into it. Rootless only, with hard memory and cpu caps and no restart
|
|
31
|
+
* policy: the trierarch starts a dead container again itself. The container
|
|
32
|
+
* sees its folder and its ship's own home, as its home, and nothing else of
|
|
33
|
+
* the host, never the runtime's socket. The home is made, for its owner
|
|
34
|
+
* alone, when the ship has none yet.
|
|
35
|
+
*
|
|
36
|
+
* The model token and the session's environment reach the container through
|
|
37
|
+
* an env file only its owner reads, removed once the container runs, never a
|
|
38
|
+
* command line (#445). Under a systemd unit the run goes through a scope of its
|
|
39
|
+
* own, so the container's monitor is not in the service's control group and a
|
|
40
|
+
* restart or upgrade ends no session (#479, #537).
|
|
41
|
+
*/
|
|
42
|
+
export declare function createContainerRuntime(options: ContainerRuntimeOptions): SessionRuntime;
|
|
43
|
+
export {};
|