@ours.network/install 1.2.1-nightly.6 → 1.2.1-nightly.61
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/GATEWAY_SETUP.md +178 -0
- package/README.md +573 -9
- package/ROOTLESS_PODMAN_VALIDATION.md +210 -0
- package/assets/Dockerfile +15 -12
- package/assets/Dockerfile.gateway +5 -0
- package/assets/docker-compose.yaml +8 -1
- package/assets/fleet-settings.example.json +48 -0
- package/assets/gateway-entrypoint.sh +37 -0
- package/assets/release-lock.json +1221 -4516
- package/assets/release.json +37 -19
- package/assets/scripts/build/build-common.mjs +10 -1
- package/assets/scripts/build/build-sdk.mjs +6 -1
- package/assets/scripts/maintenance/build-context.mjs +1 -1
- package/assets/scripts/maintenance/daemon-owner.mjs +15 -0
- package/assets/scripts/maintenance/docker-layout-conversion.mjs +22 -7
- package/assets/scripts/maintenance/recover-notifications.mjs +36 -0
- package/assets/scripts/maintenance/release-graph.mjs +18 -1
- package/assets/scripts/maintenance/state-operation.mjs +76 -8
- package/assets/scripts/runtime/README.md +7 -0
- package/assets/scripts/runtime/client-setup.mjs +105 -20
- package/assets/scripts/runtime/daemon-client-prefix.mjs +115 -0
- package/assets/scripts/runtime/dependency-ready.mjs +13 -0
- package/assets/scripts/runtime/diagnostics.mjs +72 -0
- package/assets/scripts/runtime/entrypoint.sh +5 -1
- package/assets/scripts/runtime/health-messenger.mjs +7 -6
- package/assets/scripts/runtime/healthcheck.mjs +49 -15
- package/assets/scripts/runtime/notifications-gateway.mjs +90 -0
- package/assets/scripts/runtime/recover.mjs +202 -0
- package/assets/scripts/runtime/start-cowork.sh +5 -0
- package/assets/scripts/runtime/start-messenger.sh +29 -4
- package/assets/scripts/runtime/start-telegram.sh +5 -0
- package/assets/scripts/runtime/supervise.mjs +35 -0
- package/assets/sources.json +54 -28
- package/install.mjs +7 -2
- package/lib/boot-readiness.mjs +96 -0
- package/lib/build-transition.mjs +16 -0
- package/lib/client-cli.mjs +127 -0
- package/lib/container-engine.mjs +127 -0
- package/lib/diagnostics.mjs +1 -0
- package/lib/docker-conversion-runtime.mjs +7 -4
- package/lib/docker-layout-installation.mjs +2 -1
- package/lib/docker-recovery.mjs +60 -0
- package/lib/docker-runtime-repair.mjs +49 -14
- package/lib/effects.mjs +482 -140
- package/lib/gateway-transition.mjs +87 -0
- package/lib/gateway.mjs +227 -0
- package/lib/legacy-migration.mjs +13 -2
- package/lib/orchestrate-uninstall.mjs +23 -6
- package/lib/orchestrate.mjs +335 -44
- package/lib/ownership.mjs +63 -0
- package/lib/plan.mjs +37 -11
- package/lib/podman-preflight.mjs +40 -0
- package/lib/product.mjs +69 -0
- package/lib/removal-plan.mjs +437 -0
- package/lib/removal.mjs +749 -0
- package/lib/server-onboarding.mjs +182 -16
- package/lib/server-ports.mjs +17 -0
- package/lib/setup-options.mjs +119 -29
- package/lib/setup.mjs +93 -22
- package/lib/target.mjs +24 -8
- package/lib/uninstall.mjs +2 -2
- package/lib/usage.mjs +35 -9
- package/lib/welcome.mjs +219 -0
- package/lib/workspace-setup.mjs +154 -0
- package/package.json +4 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Ownership records written at installation time, read by complete removal.
|
|
2
|
+
//
|
|
3
|
+
// A client generation under ~/.ours-client-install can serve more than one
|
|
4
|
+
// managed installation, and identical selections are not proof of who uses it.
|
|
5
|
+
// Each acquisition therefore records the installation instances it was acquired
|
|
6
|
+
// for. Server roots record the image IDs this installer built, so removal never
|
|
7
|
+
// relies on an image name alone.
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
export const OWNERS_FILE = 'owners.json';
|
|
11
|
+
export const OWNED_IMAGES_FILE = 'owned-images.json';
|
|
12
|
+
const UUID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;
|
|
13
|
+
|
|
14
|
+
const IMAGE_ID = /^sha256:[0-9a-f]{64}$/;
|
|
15
|
+
const IMAGE_TAG = /^ours-[a-z0-9]+:[a-z-]+$/;
|
|
16
|
+
|
|
17
|
+
/** A generation's owner record: absent, invalid (damaged or unknown format) or the owner IDs. */
|
|
18
|
+
export function readOwners(effects, generation) {
|
|
19
|
+
const text = effects.readText(join(generation, OWNERS_FILE));
|
|
20
|
+
if (text === null) return { state: 'absent' };
|
|
21
|
+
const instances = parseOwners(text);
|
|
22
|
+
return instances ? { state: 'valid', instances } : { state: 'invalid' };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function parseOwners(text) {
|
|
26
|
+
try {
|
|
27
|
+
const value = JSON.parse(text);
|
|
28
|
+
if (value?.schema !== 1 || !Array.isArray(value.instances) || value.instances.some(id => !UUID.test(id)) || Object.keys(value).length !== 2) return null;
|
|
29
|
+
return [...new Set(value.instances)];
|
|
30
|
+
} catch { return null; }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The next owner record for a generation, or null when nothing changes. A
|
|
35
|
+
* damaged record is never replaced: that would forget its earlier owners.
|
|
36
|
+
*/
|
|
37
|
+
export function addOwner(text, instanceId) {
|
|
38
|
+
if (!UUID.test(instanceId ?? '')) return null;
|
|
39
|
+
const instances = text === null || text === undefined ? [] : parseOwners(text);
|
|
40
|
+
if (instances === null) throw new Error('The owner record of the downloaded Ours programs is damaged; it was left unchanged');
|
|
41
|
+
if (instances.includes(instanceId)) return null;
|
|
42
|
+
return JSON.stringify({ schema: 1, instances: [...instances, instanceId] }, null, 2) + '\n';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The next owned-images record for a server root; a damaged record is left as it is. */
|
|
46
|
+
export function ownedImagesRecord(text, images) {
|
|
47
|
+
let current = {};
|
|
48
|
+
if (text !== null && text !== undefined) {
|
|
49
|
+
let value;
|
|
50
|
+
try { value = JSON.parse(text); } catch { return null; }
|
|
51
|
+
if (value?.schema !== 1 || !value.images || typeof value.images !== 'object' || Array.isArray(value.images)
|
|
52
|
+
|| Object.entries(value.images).some(([tag, id]) => !IMAGE_TAG.test(tag) || !IMAGE_ID.test(id))) return null;
|
|
53
|
+
current = value.images;
|
|
54
|
+
}
|
|
55
|
+
const added = Object.fromEntries(Object.entries(images ?? {}).filter(([tag, id]) => IMAGE_TAG.test(tag) && IMAGE_ID.test(id)));
|
|
56
|
+
const next = { ...current, ...added };
|
|
57
|
+
return JSON.stringify(current) === JSON.stringify(next) ? null : JSON.stringify({ schema: 1, images: next }, null, 2) + '\n';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Tags whose image this run created or replaced: a tag it found unchanged is never adopted. */
|
|
61
|
+
export function changedImages(before, after) {
|
|
62
|
+
return Object.fromEntries(Object.entries(after ?? {}).filter(([tag, id]) => (before ?? {})[tag] !== id));
|
|
63
|
+
}
|
package/lib/plan.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { validateContainerEngine } from './container-engine.mjs';
|
|
2
|
+
import { gatewayAddress } from './gateway.mjs';
|
|
3
|
+
import { PRODUCTS } from './product.mjs';
|
|
1
4
|
// ours-install v3 — daemon creation and boot-service installation.
|
|
2
5
|
//
|
|
3
6
|
// Pure planning code, like lib/target.mjs: the orchestrator
|
|
@@ -97,7 +100,7 @@ export function launchdLabelForStateDir(stateDir) {
|
|
|
97
100
|
export function classifyUnit(text) {
|
|
98
101
|
if (text === null || text === undefined) return { kind: 'absent' };
|
|
99
102
|
const s = String(text);
|
|
100
|
-
if (s.startsWith(CLI_UNIT_MARKER)) return { kind: 'cli-managed' };
|
|
103
|
+
if ((s.startsWith(CLI_UNIT_MARKER) || s.startsWith('# Managed by @ours.network/daemon'))) return { kind: 'cli-managed' };
|
|
101
104
|
const looksLikeOursMcp = /ExecStart=.*\bours-mcp\b/.test(s)
|
|
102
105
|
|| /^Description=ours MCP daemon\b/m.test(s)
|
|
103
106
|
|| (/^Environment=OURS_STATE_DIR=/m.test(s) && /^Environment=OURS_TRANSPORT=http$/m.test(s));
|
|
@@ -138,7 +141,7 @@ export function planServiceInstall({ stateDir, home, readText, platform = 'linux
|
|
|
138
141
|
platform,
|
|
139
142
|
reason: 'no-service-manager',
|
|
140
143
|
message: `installing a boot service is not available on ${platform} — the ours CLI supports Linux user systemd and macOS launchd`,
|
|
141
|
-
manual: ['ours
|
|
144
|
+
manual: ['ours-daemon', 'serve', '--config'],
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -224,7 +227,7 @@ export function serviceInstallCommand({ stateDir, adoptLegacyUnit = false }) {
|
|
|
224
227
|
// --json so the caller can read back whether the unit actually CHANGED rather
|
|
225
228
|
// than assuming it did. --force is reachable only through the explicit argument
|
|
226
229
|
// above, and the CLI refuses to overwrite a unit it did not write.
|
|
227
|
-
const cmd = ['ours
|
|
230
|
+
const cmd = ['ours-daemon', 'install-service', '--yes', '--json', '--state-dir', dir, '--config', join(dir, 'config.json')];
|
|
228
231
|
if (adoptLegacyUnit) cmd.push('--force');
|
|
229
232
|
return cmd;
|
|
230
233
|
}
|
|
@@ -265,20 +268,27 @@ export function planDaemonSteps(target, { cliVersionChanged = false, cliStartedI
|
|
|
265
268
|
const steps = [{ id: 'cli', label: 'install the ours-sdk CLI', command: ['npm', 'i', '-g', '@ours.network/cli'] }];
|
|
266
269
|
steps.push({ id: 'config', label: `write ${join(dir, 'config.json')}`, port: target.port });
|
|
267
270
|
if (target.action === 'create') {
|
|
268
|
-
steps.push({ id: 'start', label: `start the daemon on port ${target.port}`, command: ['ours
|
|
271
|
+
steps.push({ id: 'start', label: `start the daemon on port ${target.port}`, command: ['ours-daemon', 'start', '--config', join(dir, 'config.json')] });
|
|
269
272
|
} else if (cliVersionChanged) {
|
|
270
273
|
// `ours daemon stop` refuses to signal a daemon it did not start, so a
|
|
271
274
|
// daemon under another launcher is left running and the caller says which
|
|
272
275
|
// launcher must be restarted instead.
|
|
273
276
|
steps.push(cliStartedIt
|
|
274
|
-
? { id: 'restart', label: 'restart the daemon (package version changed)', command: ['ours
|
|
277
|
+
? { id: 'restart', label: 'restart the daemon (package version changed)', command: ['ours-daemon', 'restart', '--config', join(dir, 'config.json')] }
|
|
275
278
|
: { id: 'restart-external', label: 'daemon was not started by the CLI — restart it with its own launcher', command: null });
|
|
276
279
|
}
|
|
277
280
|
steps.push({ id: 'service', label: 'install the boot service', command: serviceInstallCommand({ stateDir: dir }) });
|
|
278
281
|
return steps;
|
|
279
282
|
}
|
|
280
283
|
|
|
281
|
-
export const SERVER_PACKAGES = ['sdk', 'cli', '
|
|
284
|
+
export const SERVER_PACKAGES = ['sdk', 'cli', 'daemon', 'tg-connector', 'cowork', 'messenger-server'].map(n => `@ours.network/${n}`);
|
|
285
|
+
/** Selected when the policy names it; retained policies from before it existed stay valid. */
|
|
286
|
+
export const NOTIFICATIONS_PACKAGE = '@ours.network/notifications';
|
|
287
|
+
/** Plugin-only installations select only these; no application packages. */
|
|
288
|
+
export const DAEMON_PACKAGES = ['sdk', 'cli', 'daemon'].map(n => `@ours.network/${n}`);
|
|
289
|
+
const serverPackages = (manifest, role = 'server') => role === 'daemon' ? DAEMON_PACKAGES
|
|
290
|
+
: [...SERVER_PACKAGES, ...(manifest?.packages?.[NOTIFICATIONS_PACKAGE] ? [NOTIFICATIONS_PACKAGE] : [])];
|
|
291
|
+
const serverRoles = ['server', 'daemon'];
|
|
282
292
|
export const SERVER_DEPENDENCIES = {
|
|
283
293
|
daemon: [], telegram: ['daemon'], cowork: ['daemon'], messenger: ['daemon'],
|
|
284
294
|
};
|
|
@@ -294,7 +304,7 @@ export function maintenanceServices(record, domain) {
|
|
|
294
304
|
|
|
295
305
|
/** Validate exact supplied selections, without rewriting the source authority. */
|
|
296
306
|
export function selectSourcePackages(manifest, role, clients = []) {
|
|
297
|
-
const names = role
|
|
307
|
+
const names = serverRoles.includes(role) ? serverPackages(manifest, role) : clients.map(n => `@ours.network/${n}`);
|
|
298
308
|
const result = {};
|
|
299
309
|
for (const name of names) {
|
|
300
310
|
const selected = manifest?.packages?.[name];
|
|
@@ -312,7 +322,7 @@ export function selectSourcePackages(manifest, role, clients = []) {
|
|
|
312
322
|
/** Resolve a packaged compatibility policy into a role-filtered exact selection. */
|
|
313
323
|
export async function resolveSourcePolicy(manifest, role, clients = [], resolveNpm) {
|
|
314
324
|
const release = releaseBinding(manifest);
|
|
315
|
-
const names = role
|
|
325
|
+
const names = serverRoles.includes(role) ? serverPackages(manifest, role) : clients.map(name => `@ours.network/${name}`);
|
|
316
326
|
const packages = {};
|
|
317
327
|
const sourceNames = new Set();
|
|
318
328
|
for (const name of names) {
|
|
@@ -356,15 +366,26 @@ export function installationPaths(record) {
|
|
|
356
366
|
}
|
|
357
367
|
|
|
358
368
|
export function validateInstallation(record, root) {
|
|
369
|
+
if (record) validateContainerEngine(record);
|
|
359
370
|
if (!record || ![1, 2].includes(record.schema) || !['docker', 'packages'].includes(record.mode)
|
|
360
371
|
|| record.root !== root || record.configPath !== installationPaths(record).config
|
|
361
372
|
|| record.sourcesPath !== join(root, 'sources.json') || record.workDir !== join(root, 'runtime')
|
|
362
373
|
|| !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(record.instanceId ?? '')
|
|
363
374
|
|| !/^ours-[a-z0-9]+$/.test(record.project ?? '')
|
|
364
375
|
|| (record.sourcePolicyHash !== undefined && !/^[0-9a-f]{64}$/.test(record.sourcePolicyHash))
|
|
365
|
-
|| !Array.isArray(record.services) || record.services[0] !== 'daemon' || new Set(record.services).size !== record.services.length || record.services.some(s => !SERVER_SERVICES.includes(s))) {
|
|
376
|
+
|| !Array.isArray(record.services) || record.services[0] !== 'daemon' || new Set(record.services).size !== record.services.length || record.services.some(s => !SERVER_SERVICES.includes(s) && !(s === 'gateway' && record.gateway?.version === 1))) {
|
|
366
377
|
throw new Error('Invalid or conflicting installation selection');
|
|
367
378
|
}
|
|
379
|
+
if (record.product !== undefined && (!PRODUCTS.includes(record.product) || record.product === 'workspace'
|
|
380
|
+
|| record.schema !== 2 || record.mode !== 'docker' || record.gateway !== undefined
|
|
381
|
+
|| JSON.stringify(record.services) !== JSON.stringify(['daemon']))) {
|
|
382
|
+
throw new Error('Invalid plugin-only installation selection');
|
|
383
|
+
}
|
|
384
|
+
if (record.gateway !== undefined && (record.schema !== 2 || record.mode !== 'docker' || record.gateway?.version !== 1
|
|
385
|
+
|| Object.keys(record.gateway).some(key => !['version', 'serverUrl'].includes(key)) || record.services.at(-1) !== 'gateway')) {
|
|
386
|
+
throw new Error('Invalid gateway installation selection');
|
|
387
|
+
}
|
|
388
|
+
if (record.gateway) gatewayAddress(record);
|
|
368
389
|
if (record.layoutConversion !== undefined) {
|
|
369
390
|
// DEPRECATED (introduced in 2.0): legacy managed-layout conversion only.
|
|
370
391
|
// Removal target: 3.0, after supported installs convert and upgrade inputs
|
|
@@ -380,7 +401,8 @@ export function validateInstallation(record, root) {
|
|
|
380
401
|
throw new Error('Invalid layout conversion record');
|
|
381
402
|
}
|
|
382
403
|
validateInstallation(source, root);
|
|
383
|
-
if (
|
|
404
|
+
if (JSON.stringify(source.containerBinding) !== JSON.stringify(record.containerBinding)) throw new Error('Conflicting conversion backend');
|
|
405
|
+
if (['mode', 'containerEngine', 'instanceId', 'project', 'sourcesPath', 'workDir'].some(key => source[key] !== record[key])
|
|
384
406
|
|| JSON.stringify(source.services) !== JSON.stringify(record.services)
|
|
385
407
|
|| conversion.runningServices.some(service => !source.services.includes(service))) {
|
|
386
408
|
throw new Error('Conflicting layout conversion source');
|
|
@@ -402,7 +424,7 @@ export function validateInstallation(record, root) {
|
|
|
402
424
|
throw new Error('Invalid server build transition');
|
|
403
425
|
}
|
|
404
426
|
validateInstallation(candidate, candidate.root);
|
|
405
|
-
for (const key of ['schema', 'mode', 'instanceId', 'services', 'port', 'coworkPort', 'messengerPort', 'messengerIdentity', 'uid', 'gid']) {
|
|
427
|
+
for (const key of ['schema', 'mode', 'product', 'containerEngine', 'containerBinding', 'instanceId', 'services', 'gateway', 'port', 'coworkPort', 'messengerPort', 'messengerIdentity', 'uid', 'gid']) {
|
|
406
428
|
if (JSON.stringify(candidate[key]) !== JSON.stringify(record[key])) throw new Error('Conflicting server build candidate');
|
|
407
429
|
}
|
|
408
430
|
}
|
|
@@ -470,3 +492,7 @@ export function consumerServiceState(text, service, platform) {
|
|
|
470
492
|
}
|
|
471
493
|
return matches === 1 ? selected : undefined;
|
|
472
494
|
}
|
|
495
|
+
|
|
496
|
+
export function clientPackageNames(integrations) {
|
|
497
|
+
return [...new Set(['sdk', 'cli', ...(integrations.some(name => ['codex', 'claude-code'].includes(name)) ? ['mcp'] : []), ...integrations])];
|
|
498
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { runContainer } from './container-engine.mjs';
|
|
6
|
+
|
|
7
|
+
export const PROBE_IMAGE = 'docker.io/library/nginx:1.28-alpine@sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236';
|
|
8
|
+
/** Behavioral checks, in disposable resources, before touching installation storage. */
|
|
9
|
+
export async function qualifyPodman(effects, record) {
|
|
10
|
+
const root = mkdtempSync(join(tmpdir(), 'ours-podman-preflight-'));
|
|
11
|
+
const project = `ours-probe-${randomUUID()}`;
|
|
12
|
+
const file = join(root, 'compose.json'), overlay = join(root, 'reset.yaml');
|
|
13
|
+
const common = { image: PROBE_IMAGE, entrypoint: ['/bin/sh', '-ec'], read_only: true, cap_drop: ['ALL'], security_opt: ['no-new-privileges:true'] };
|
|
14
|
+
writeFileSync(file, JSON.stringify({ services: {
|
|
15
|
+
prepare: { ...common, user: '0:0', network_mode: 'none', cap_add: ['CHOWN', 'DAC_OVERRIDE'],
|
|
16
|
+
command: ['mkdir -p /storage/state/daemon /storage/state/sibling; chmod 700 /storage/state/daemon; chown 1000:1000 /storage/state/daemon'],
|
|
17
|
+
volumes: [{ type: 'volume', source: 'data', target: '/storage', volume: { nocopy: true } }] },
|
|
18
|
+
probe: { ...common, user: '1000:1000', command: ['test ! -e /data/sibling; test "$(stat -c %a /data)" = 700; nslookup -type=A probe.; echo ready > /data/probe; sleep 120'],
|
|
19
|
+
healthcheck: { test: ['CMD-SHELL', 'test -s /data/probe'], interval: '1s', timeout: '2s', retries: 10 },
|
|
20
|
+
volumes: [{ type: 'volume', source: 'data', target: '/data', volume: { nocopy: true, subpath: 'state/daemon' } }] },
|
|
21
|
+
}, volumes: { data: {} } }), { mode: 0o600 });
|
|
22
|
+
writeFileSync(overlay, 'services:\n probe:\n ports: !reset []\n', { mode: 0o600 });
|
|
23
|
+
const compose = args => runContainer(effects, record, ['compose', '-p', project, '-f', file, '-f', overlay, ...args], { timeout: 180000 });
|
|
24
|
+
try {
|
|
25
|
+
await compose(['config', '--format', 'json']);
|
|
26
|
+
await compose(['run', '--rm', '--no-deps', '-T', 'prepare']);
|
|
27
|
+
await compose(['up', '-d', '--no-build', '--wait', 'probe']);
|
|
28
|
+
const result = await compose(['ps', '--format', 'json']);
|
|
29
|
+
const rows = result.stdout.trim().startsWith('[') ? JSON.parse(result.stdout) : result.stdout.trim().split('\n').map(s => JSON.parse(s));
|
|
30
|
+
if (!rows.some(r => r.Service === 'probe' && r.State === 'running')) throw new Error('Compose JSON status is incompatible');
|
|
31
|
+
await compose(['exec', '-T', 'probe', '/bin/sh', '-ec', 'test -s /data/probe; test ! -e /data/state']);
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
let logs = '';
|
|
34
|
+
try { logs = (await compose(['logs', '--no-color', '--tail', '30'])).stdout; } catch {}
|
|
35
|
+
throw new Error(`Podman capability check failed (Compose !reset/wait/status, DNS, rootless UID, volume subpath): ${cause.message}\n${logs}`, { cause });
|
|
36
|
+
} finally {
|
|
37
|
+
try { await compose(['down', '--volumes', '--remove-orphans']); }
|
|
38
|
+
finally { rmSync(root, { recursive: true, force: true }); }
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/product.mjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a managed installation is for. Recorded once in installation.json and
|
|
3
|
+
* retained by every later repair, update and removal: neither choice is ever
|
|
4
|
+
* widened or narrowed implicitly.
|
|
5
|
+
*
|
|
6
|
+
* workspace the complete Ours workspace: daemon, Telegram, Cowork,
|
|
7
|
+
* Messenger (with Notifications) and the one-URL gateway, plus
|
|
8
|
+
* Fleet on the host. Records without a product are workspaces.
|
|
9
|
+
* plugin-only collaboration tools for existing agent apps: only the daemon
|
|
10
|
+
* container, reached by Claude Code / Codex through the daemon's
|
|
11
|
+
* own client prefix. No gateway, Cowork, Messenger, Telegram,
|
|
12
|
+
* Notifications or Fleet.
|
|
13
|
+
*/
|
|
14
|
+
export const PRODUCTS = ['workspace', 'plugin-only'];
|
|
15
|
+
export const PLUGIN_ONLY = 'plugin-only';
|
|
16
|
+
export const PLUGIN_ONLY_INTEGRATIONS = ['claude-code', 'codex'];
|
|
17
|
+
/** Container port of the daemon's client prefix; the raw daemon port stays internal. */
|
|
18
|
+
export const CLIENT_PREFIX_PORT = 3049;
|
|
19
|
+
|
|
20
|
+
export const productOf = record => record?.product ?? 'workspace';
|
|
21
|
+
export const isPluginOnly = value => (typeof value === 'string' ? value : productOf(value)) === PLUGIN_ONLY;
|
|
22
|
+
/** Package selection role: plugin-only selects only the SDK, CLI and daemon. */
|
|
23
|
+
export const serverRole = value => isPluginOnly(value) ? 'daemon' : 'server';
|
|
24
|
+
/** Applications whose state, credentials and services the installation owns. */
|
|
25
|
+
export const applicationsOf = record => record.services.filter(service => service !== 'gateway');
|
|
26
|
+
|
|
27
|
+
export const PRODUCT_LABELS = {
|
|
28
|
+
'plugin-only': 'Collaboration tools for my existing agent apps',
|
|
29
|
+
workspace: 'The complete Ours workspace',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Compose overlay for a plugin-only installation. The daemon container serves
|
|
34
|
+
* the client prefix itself and publishes only that port, on loopback; the raw
|
|
35
|
+
* daemon API is not published. Administrative jobs see only daemon state, so no
|
|
36
|
+
* application state, configuration or credential is created for services this
|
|
37
|
+
* installation does not run.
|
|
38
|
+
*/
|
|
39
|
+
export function pluginOnlyCompose() {
|
|
40
|
+
const volume = (target, subpath) => ` - {type: volume, source: server-storage, target: ${target}, volume: {nocopy: true${subpath ? `, subpath: ${subpath}` : ''}}}`;
|
|
41
|
+
const locks = ' - {type: volume, source: owner-locks, target: "/tmp/ours-${OURS_UID:-1000}", volume: {nocopy: true}}';
|
|
42
|
+
return `services:
|
|
43
|
+
prepare:
|
|
44
|
+
environment:
|
|
45
|
+
OURS_SERVER_APPLICATIONS: daemon
|
|
46
|
+
daemon:
|
|
47
|
+
entrypoint: [node, /opt/ours/docker/daemon-client-prefix.mjs]
|
|
48
|
+
environment:
|
|
49
|
+
OURS_SERVER_APPLICATIONS: daemon
|
|
50
|
+
OURS_DAEMON_CLIENT_PREFIX_PORT: "${CLIENT_PREFIX_PORT}"
|
|
51
|
+
ports: !override
|
|
52
|
+
- {target: ${CLIENT_PREFIX_PORT}, published: "\${OURS_HOST_PORT:-3050}", host_ip: 127.0.0.1}
|
|
53
|
+
access:
|
|
54
|
+
environment:
|
|
55
|
+
OURS_SERVER_APPLICATIONS: daemon
|
|
56
|
+
volumes: !override
|
|
57
|
+
${volume('/var/lib/ours', 'state/daemon')}
|
|
58
|
+
${volume('/var/lib/ours-mcp', 'state/mcp')}
|
|
59
|
+
${locks}
|
|
60
|
+
state-operation:
|
|
61
|
+
environment:
|
|
62
|
+
OURS_SERVER_APPLICATIONS: daemon
|
|
63
|
+
volumes: !override
|
|
64
|
+
${volume('/storage')}
|
|
65
|
+
${volume('/var/lib/ours', 'state/daemon')}
|
|
66
|
+
${volume('/var/lib/ours-mcp', 'state/mcp')}
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
export const PLUGIN_ONLY_COMPOSE = 'compose.plugin-only.yaml';
|