@mean-weasel/lineage 0.1.16 → 0.1.18
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/CHANGELOG.md +13 -0
- package/README.md +226 -17
- package/dist/cli/lineage-channel.js +25 -5
- package/dist/cli/lineage-channel.js.map +2 -2
- package/dist/cli/lineage-dev.js +163 -12
- package/dist/cli/lineage-dev.js.map +3 -3
- package/dist/cli/lineage-preview.js +163 -12
- package/dist/cli/lineage-preview.js.map +3 -3
- package/dist/cli/lineage.js +163 -12
- package/dist/cli/lineage.js.map +3 -3
- package/dist/cli/managed-service.js +46 -9
- package/dist/cli/managed-service.js.map +3 -3
- package/dist/runtime-build.json +4 -4
- package/dist/server.js +42 -8
- package/dist/server.js.map +2 -2
- package/dist/web/assets/agent-shared-state-DOfpTLiw.webp +0 -0
- package/dist/web/assets/agent-to-canvas-DtIu_cPq.mp4 +0 -0
- package/dist/web/assets/{app-DwTFac4u.css → app-B-fAyNsU.css} +1 -1
- package/dist/web/assets/app-XjkwA_uj.js +16 -0
- package/dist/web/assets/attempt-history-D6wdic6n.webp +0 -0
- package/dist/web/assets/branching-tree-B8I5_S6D.png +0 -0
- package/dist/web/assets/canvas-cli-DHBacq7r.png +0 -0
- package/dist/web/assets/hero-agent-sync-CSyh0tHy.mp4 +0 -0
- package/dist/web/assets/hero-board-DG3ED4AW.webp +0 -0
- package/dist/web/assets/hero-lineage-growth-Bsl9tiq-.mp4 +0 -0
- package/dist/web/assets/hero-trace-connections-Bb52ABBc.mp4 +0 -0
- package/dist/web/assets/human-selection-BdDBDE-I.webp +0 -0
- package/dist/web/assets/human-to-agent-D1z92ZO9.mp4 +0 -0
- package/dist/web/assets/{jsx-runtime-_Rdg6et1.js → jsx-runtime-DAFSxiwi.js} +1 -1
- package/dist/web/assets/landing-BogL3MNz.js +1 -0
- package/dist/web/assets/landing-D79qigX-.css +1 -0
- package/dist/web/assets/reroll-history-DQcEH42R.mp4 +0 -0
- package/dist/web/index.html +3 -3
- package/dist/web/landing/index.html +3 -3
- package/fixtures/demo-project/lineage/swissifier-rich-demo.json +13 -13
- package/package.json +4 -3
- package/dist/web/assets/app-JYTx_Sd4.js +0 -16
- package/dist/web/assets/landing-D3Y679_B.css +0 -1
- package/dist/web/assets/landing-ii8AH_DG.js +0 -1
|
@@ -88,9 +88,26 @@ function serviceRoot() {
|
|
|
88
88
|
}
|
|
89
89
|
function defaultLauncher(channel) {
|
|
90
90
|
if (channel === "dev") return [process.execPath, "--import", "tsx", join(root, "src", "cli", "lineage-dev.ts")];
|
|
91
|
-
const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT || (platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Lineage", "runtimes") : join(homedir(), ".local", "share", "lineage", "runtimes"));
|
|
92
91
|
const envName = channel === "stable" ? "LINEAGE_STABLE_BIN" : "LINEAGE_PREVIEW_BIN";
|
|
93
|
-
|
|
92
|
+
const explicit = process.env[envName] || process.env.LINEAGE_CHANNEL_LAUNCHER;
|
|
93
|
+
if (explicit) return [explicit];
|
|
94
|
+
const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;
|
|
95
|
+
if (receiptPath) {
|
|
96
|
+
if (!existsSync(receiptPath)) throw new Error(`${channel} service manager runtime receipt does not exist: ${receiptPath}`);
|
|
97
|
+
const resolvedReceipt = realpathSync(receiptPath);
|
|
98
|
+
const runtimeRoot2 = dirname(dirname(dirname(dirname(resolvedReceipt))));
|
|
99
|
+
const pointerPath = join(runtimeRoot2, "channels", `${channel}.json`);
|
|
100
|
+
if (!existsSync(pointerPath)) throw new Error(`${channel} service manager could not find its receipt-bound channel pointer: ${pointerPath}`);
|
|
101
|
+
const pointer = JSON.parse(readFileSync(pointerPath, "utf8"));
|
|
102
|
+
if (pointer.channel !== channel) throw new Error(`${channel} service manager channel pointer reports ${pointer.channel || "(missing)"}`);
|
|
103
|
+
if (!pointer.receipt_path || !existsSync(pointer.receipt_path) || realpathSync(pointer.receipt_path) !== resolvedReceipt) {
|
|
104
|
+
throw new Error(`${channel} service manager channel pointer is not bound to its runtime receipt`);
|
|
105
|
+
}
|
|
106
|
+
if (!pointer.shim || !existsSync(pointer.shim)) throw new Error(`${channel} service manager channel pointer launcher is missing: ${pointer.shim || "(missing)"}`);
|
|
107
|
+
return [realpathSync(pointer.shim)];
|
|
108
|
+
}
|
|
109
|
+
const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT || (platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Lineage", "runtimes") : join(homedir(), ".local", "share", "lineage", "runtimes"));
|
|
110
|
+
return [join(runtimeRoot, "bin", channel === "stable" ? "lineage-stable" : "lineage-preview")];
|
|
94
111
|
}
|
|
95
112
|
function launcherFor(channel, args) {
|
|
96
113
|
const explicit = readOption(args, "--launcher");
|
|
@@ -103,15 +120,29 @@ function invoke(launcher, args, options = {}) {
|
|
|
103
120
|
...options
|
|
104
121
|
});
|
|
105
122
|
}
|
|
123
|
+
function invocationFailure(result) {
|
|
124
|
+
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
125
|
+
const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
|
|
126
|
+
const spawnError = result.error instanceof Error ? result.error.message : result.error ? String(result.error) : "";
|
|
127
|
+
return stderr || stdout || spawnError || `process exited with status ${result.status ?? "unknown"}`;
|
|
128
|
+
}
|
|
129
|
+
function shellDisplay(parts) {
|
|
130
|
+
return parts.map((part) => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(" ");
|
|
131
|
+
}
|
|
106
132
|
function profileDoctor(launcher, selector) {
|
|
107
133
|
const result = invoke(launcher, ["profile", "doctor", "--profile", selector, "--json"]);
|
|
108
134
|
let doctor;
|
|
109
135
|
try {
|
|
110
136
|
doctor = JSON.parse(result.stdout || "{}");
|
|
111
137
|
} catch {
|
|
112
|
-
throw new Error(`Profile doctor did not return JSON: ${(result
|
|
138
|
+
throw new Error(`Profile doctor did not return JSON: ${invocationFailure(result)}`);
|
|
139
|
+
}
|
|
140
|
+
if (!doctor.profile) {
|
|
141
|
+
const detail = doctor.error || (doctor.checks || []).filter((check) => check.status === "fail").map((check) => check.message).join("; ") || invocationFailure(result) || "profile manifest was not found or could not be read";
|
|
142
|
+
const doctorCommand = shellDisplay([...launcher, "profile", "doctor", "--profile", selector, "--json"]);
|
|
143
|
+
const initCommand = shellDisplay([...launcher, "profile", "init", "--profile", selector, "--confirm-write", "--json"]);
|
|
144
|
+
throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \`${doctorCommand}\`. If this is a new profile, run \`${initCommand}\` instead.`);
|
|
113
145
|
}
|
|
114
|
-
if (!doctor.profile) throw new Error(`Profile doctor could not resolve ${selector}: ${(result.stderr || JSON.stringify(doctor)).trim()}`);
|
|
115
146
|
return { doctor, status: result.status ?? 1 };
|
|
116
147
|
}
|
|
117
148
|
function runtimeDoctor(launcher) {
|
|
@@ -120,9 +151,9 @@ function runtimeDoctor(launcher) {
|
|
|
120
151
|
try {
|
|
121
152
|
runtime = JSON.parse(result.stdout || "{}");
|
|
122
153
|
} catch {
|
|
123
|
-
throw new Error(`Runtime doctor did not return JSON: ${(result
|
|
154
|
+
throw new Error(`Runtime doctor did not return JSON: ${invocationFailure(result)}`);
|
|
124
155
|
}
|
|
125
|
-
if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${(result
|
|
156
|
+
if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${invocationFailure(result) || JSON.stringify(runtime)}`);
|
|
126
157
|
return runtime;
|
|
127
158
|
}
|
|
128
159
|
function statePaths(channel, profile) {
|
|
@@ -203,6 +234,7 @@ function managedServiceIdentityErrors(runtime, receipt) {
|
|
|
203
234
|
if (resolve(runtime.database?.path || "") !== resolve(receipt.database_path)) errors.push(`database ${runtime.database?.path || "missing"} != ${receipt.database_path}`);
|
|
204
235
|
if (runtime.service?.instance_id !== receipt.instance_id) errors.push(`instance ${runtime.service?.instance_id || "missing"} != ${receipt.instance_id}`);
|
|
205
236
|
if (runtime.service?.launcher_pid !== receipt.pid) errors.push(`launcher pid ${runtime.service?.launcher_pid || "missing"} != ${receipt.pid}`);
|
|
237
|
+
if (runtime.service?.mode !== "managed") errors.push(`service mode ${runtime.service?.mode || "missing"} != managed`);
|
|
206
238
|
return errors;
|
|
207
239
|
}
|
|
208
240
|
function desiredReceiptErrors(channel, doctor, receipt) {
|
|
@@ -286,7 +318,10 @@ async function startManaged(channel, selector, launcher, args) {
|
|
|
286
318
|
if (existing) {
|
|
287
319
|
const health = await inspectHealth(existing);
|
|
288
320
|
const desiredErrors = desiredReceiptErrors(channel, doctor, existing);
|
|
289
|
-
if (health.healthy && desiredErrors.length === 0)
|
|
321
|
+
if (health.healthy && desiredErrors.length === 0) {
|
|
322
|
+
if (args.includes("--open")) openBrowser(existing.service_origin);
|
|
323
|
+
return { already_running: true, healthy: true, receipt: existing, runtime: health.runtime, state_path: paths.receipt };
|
|
324
|
+
}
|
|
290
325
|
if (processAlive(existing.pid)) throw new Error(`Managed service pid ${existing.pid} exists but is stale or unhealthy: ${[...desiredErrors, ...health.errors].join("; ")}`);
|
|
291
326
|
rmSync(paths.receipt, { force: true });
|
|
292
327
|
}
|
|
@@ -297,7 +332,7 @@ async function startManaged(channel, selector, launcher, args) {
|
|
|
297
332
|
const child = spawn(launcher[0], [...launcher.slice(1), ...startArgs], {
|
|
298
333
|
cwd: root,
|
|
299
334
|
detached: true,
|
|
300
|
-
env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId },
|
|
335
|
+
env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId, LINEAGE_SERVICE_MODE: "managed" },
|
|
301
336
|
stdio: ["ignore", logFd, logFd]
|
|
302
337
|
});
|
|
303
338
|
closeSync(logFd);
|
|
@@ -420,7 +455,9 @@ async function main() {
|
|
|
420
455
|
var invokedAs = process.argv[1] ? basename(process.argv[1]) : "";
|
|
421
456
|
if (process.argv[1] && (resolve(process.argv[1]) === fileURLToPath(import.meta.url) || ["lineage-service", "lineage-stable-service", "lineage-preview-service", "managed-service.js", "managed-service.mjs"].includes(invokedAs))) {
|
|
422
457
|
main().catch((error) => {
|
|
423
|
-
|
|
458
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
459
|
+
if (process.argv.includes("--json")) console.error(JSON.stringify({ error: message, ok: false }, null, 2));
|
|
460
|
+
else console.error(`managed-service: ${message}`);
|
|
424
461
|
process.exitCode = 1;
|
|
425
462
|
});
|
|
426
463
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../scripts/managed-service.mjs"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\nimport { randomUUID, createHash } from 'node:crypto';\nimport { spawn, spawnSync } from 'node:child_process';\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n readdirSync,\n readlinkSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir, platform } from 'node:os';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst scriptDirectory = dirname(fileURLToPath(import.meta.url));\nconst root = [resolve(scriptDirectory, '../..'), resolve(scriptDirectory, '..')].find(candidate => {\n try {\n const packageInfo = JSON.parse(readFileSync(join(candidate, 'package.json'), 'utf8'));\n return packageInfo.name === '@mean-weasel/lineage';\n } catch {\n return false;\n }\n});\nif (!root) throw new Error('Unable to locate the Lineage package root for managed service control');\nconst receiptSchema = 'lineage.managed_service.v1';\n\nfunction packageTreeSha256(packageRoot) {\n const hash = createHash('sha256');\n const visit = (directory, relativeDirectory = '') => {\n for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {\n const relativePath = relativeDirectory ? join(relativeDirectory, entry.name) : entry.name;\n const path = join(directory, entry.name);\n hash.update(relativePath.replaceAll('\\\\', '/'));\n hash.update('\\0');\n if (entry.isDirectory()) {\n hash.update('directory\\0');\n visit(path, relativePath);\n } else if (entry.isSymbolicLink()) {\n hash.update('symlink\\0');\n hash.update(readlinkSync(path));\n } else if (entry.isFile()) {\n hash.update('file\\0');\n hash.update(readFileSync(path));\n } else {\n hash.update('other\\0');\n }\n hash.update('\\0');\n }\n };\n visit(packageRoot);\n return hash.digest('hex');\n}\n\nfunction assertServiceManagerOrigin(channel) {\n const checkoutController = resolve(scriptDirectory) === resolve(root, 'scripts');\n if (channel === 'dev') {\n if (!checkoutController) throw new Error('Dev service control is checkout-only; run node scripts/managed-service.mjs from the intended worktree');\n return;\n }\n if (checkoutController) throw new Error(`${channel} service control requires the matching attested packaged manager`);\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (!receiptPath || !existsSync(receiptPath)) throw new Error(`${channel} service manager is missing its runtime install receipt`);\n const receipt = JSON.parse(readFileSync(receiptPath, 'utf8'));\n if (receipt.channel !== channel || process.env.LINEAGE_RELEASE_CHANNEL !== channel) {\n throw new Error(`${channel} service manager receipt channel does not match the requested channel`);\n }\n if (!receipt.package_root || realpathSync(receipt.package_root) !== realpathSync(root)) {\n throw new Error(`${channel} service manager receipt package root ${receipt.package_root || '(missing)'} does not match controller root ${root}`);\n }\n if (packageTreeSha256(root) !== receipt.package_tree_sha256) throw new Error(`${channel} service manager package tree does not match its install receipt`);\n}\n\nfunction readOption(args, name) {\n const inline = args.find(arg => arg.startsWith(`${name}=`));\n if (inline) return inline.slice(name.length + 1);\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction serviceRoot() {\n if (process.env.LINEAGE_SERVICE_ROOT) return resolve(process.env.LINEAGE_SERVICE_ROOT);\n if (platform() === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Lineage', 'services');\n if (platform() === 'win32') return join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Lineage', 'services');\n return join(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'lineage', 'services');\n}\n\nfunction defaultLauncher(channel) {\n if (channel === 'dev') return [process.execPath, '--import', 'tsx', join(root, 'src', 'cli', 'lineage-dev.ts')];\n const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT\n || (platform() === 'darwin'\n ? join(homedir(), 'Library', 'Application Support', 'Lineage', 'runtimes')\n : join(homedir(), '.local', 'share', 'lineage', 'runtimes'));\n const envName = channel === 'stable' ? 'LINEAGE_STABLE_BIN' : 'LINEAGE_PREVIEW_BIN';\n return [process.env[envName] || join(runtimeRoot, 'bin', channel === 'stable' ? 'lineage-stable' : 'lineage-preview')];\n}\n\nfunction launcherFor(channel, args) {\n const explicit = readOption(args, '--launcher');\n return explicit ? [resolve(explicit)] : defaultLauncher(channel);\n}\n\nfunction invoke(launcher, args, options = {}) {\n return spawnSync(launcher[0], [...launcher.slice(1), ...args], {\n cwd: root,\n encoding: 'utf8',\n ...options,\n });\n}\n\nfunction profileDoctor(launcher, selector) {\n const result = invoke(launcher, ['profile', 'doctor', '--profile', selector, '--json']);\n let doctor;\n try {\n doctor = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Profile doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);\n }\n if (!doctor.profile) throw new Error(`Profile doctor could not resolve ${selector}: ${(result.stderr || JSON.stringify(doctor)).trim()}`);\n return { doctor, status: result.status ?? 1 };\n}\n\nfunction runtimeDoctor(launcher) {\n const result = invoke(launcher, ['runtime', 'doctor', '--json']);\n let runtime;\n try {\n runtime = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Runtime doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);\n }\n if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${(result.stderr || JSON.stringify(runtime)).trim()}`);\n return runtime;\n}\n\nfunction statePaths(channel, profile) {\n const digest = createHash('sha256').update(profile.manifest_path).digest('hex').slice(0, 12);\n const key = `${channel}--${profile.profile_id}--${digest}`;\n const directory = join(serviceRoot(), key);\n return {\n directory,\n lock: `${directory}.manager.lock`,\n log: join(directory, 'service.log'),\n receipt: join(directory, 'service.json'),\n };\n}\n\nfunction processAlive(pid) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return error?.code !== 'ESRCH';\n }\n}\n\nfunction processStartToken(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'lstart='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction processCommand(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction acquireManagerLock(path) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(path, { mode: 0o700 });\n writeFileSync(join(path, 'owner.json'), `${JSON.stringify({ acquired_at: new Date().toISOString(), pid: process.pid })}\\n`, { mode: 0o600 });\n return () => rmSync(path, { force: true, recursive: true });\n } catch (error) {\n if (error?.code !== 'EEXIST') throw error;\n try {\n const owner = JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8'));\n if (Number.isSafeInteger(owner.pid) && processAlive(owner.pid)) {\n throw new Error(`Another service manager operation is active (pid ${owner.pid})`, { cause: error });\n }\n } catch (ownerError) {\n if (ownerError instanceof Error && ownerError.message.startsWith('Another service manager')) throw ownerError;\n }\n rmSync(path, { force: true, recursive: true });\n }\n }\n throw new Error(`Could not acquire service manager lock ${path}`);\n}\n\nfunction readReceipt(path) {\n if (!existsSync(path)) return undefined;\n const receipt = JSON.parse(readFileSync(path, 'utf8'));\n if (\n receipt.schema_version !== receiptSchema\n || !Number.isSafeInteger(receipt.pid)\n || typeof receipt.instance_id !== 'string'\n || typeof receipt.profile_fingerprint !== 'string'\n || !Array.isArray(receipt.launcher)\n ) throw new Error(`Managed service receipt is invalid: ${path}`);\n return receipt;\n}\n\nfunction writeReceipt(path, receipt) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporary, `${JSON.stringify(receipt, null, 2)}\\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });\n renameSync(temporary, path);\n}\n\nexport function managedServiceIdentityErrors(runtime, receipt) {\n const errors = [];\n if (runtime.channel !== receipt.channel) errors.push(`channel ${runtime.channel} != ${receipt.channel}`);\n if (!runtime.code?.verified) errors.push('code identity is not verified');\n if (runtime.code?.fingerprint !== receipt.code_fingerprint) errors.push(`code fingerprint ${runtime.code?.fingerprint || 'missing'} != ${receipt.code_fingerprint}`);\n if (runtime.profile?.id !== receipt.profile_id) errors.push(`profile ${runtime.profile?.id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.profile?.environment !== receipt.environment) errors.push(`environment ${runtime.profile?.environment || 'missing'} != ${receipt.environment}`);\n if (runtime.profile?.fingerprint !== receipt.profile_fingerprint) errors.push(`profile fingerprint ${runtime.profile?.fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (runtime.schema?.profile_id !== receipt.profile_id) errors.push(`database profile ${runtime.schema?.profile_id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.schema?.profile_fingerprint !== receipt.profile_fingerprint) errors.push(`database fingerprint ${runtime.schema?.profile_fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (resolve(runtime.database?.path || '') !== resolve(receipt.database_path)) errors.push(`database ${runtime.database?.path || 'missing'} != ${receipt.database_path}`);\n if (runtime.service?.instance_id !== receipt.instance_id) errors.push(`instance ${runtime.service?.instance_id || 'missing'} != ${receipt.instance_id}`);\n if (runtime.service?.launcher_pid !== receipt.pid) errors.push(`launcher pid ${runtime.service?.launcher_pid || 'missing'} != ${receipt.pid}`);\n return errors;\n}\n\nfunction desiredReceiptErrors(channel, doctor, receipt) {\n const errors = [];\n if (receipt.channel !== channel) errors.push(`receipt channel ${receipt.channel} != ${channel}`);\n if (receipt.code_fingerprint !== doctor.runtime?.code_fingerprint) errors.push(`receipt code fingerprint ${receipt.code_fingerprint} != current ${doctor.runtime?.code_fingerprint || 'missing'}`);\n if (receipt.code_origin !== doctor.runtime?.code_origin) errors.push(`receipt code origin ${receipt.code_origin} != current ${doctor.runtime?.code_origin || 'missing'}`);\n if (receipt.profile_id !== doctor.profile.profile_id) errors.push(`receipt profile ${receipt.profile_id} != ${doctor.profile.profile_id}`);\n if (receipt.environment !== doctor.profile.environment) errors.push(`receipt environment ${receipt.environment} != ${doctor.profile.environment}`);\n if (receipt.profile_fingerprint !== doctor.profile.profile_fingerprint) errors.push(`receipt profile fingerprint ${receipt.profile_fingerprint} != current ${doctor.profile.profile_fingerprint}`);\n if (resolve(receipt.database_path) !== resolve(doctor.profile.database_path)) errors.push('receipt database path does not match current profile');\n if (receipt.service_origin !== doctor.profile.service_origin) errors.push('receipt service origin does not match current profile');\n if (receipt.manifest_path !== doctor.profile.manifest_path) errors.push('receipt manifest path does not match current profile');\n return errors;\n}\n\nasync function fetchRuntime(origin) {\n const response = await fetch(`${origin}/api/runtime`, { signal: AbortSignal.timeout(1_000) });\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const body = await response.json();\n if (!body?.runtime) throw new Error('Runtime response is missing runtime identity');\n return body.runtime;\n}\n\nasync function inspectHealth(receipt) {\n const errors = [];\n if (!processAlive(receipt.pid)) errors.push(`launcher pid ${receipt.pid} is not alive`);\n if (receipt.process_start && processStartToken(receipt.pid) !== receipt.process_start) errors.push(`launcher pid ${receipt.pid} was reused`);\n let runtime;\n try {\n runtime = await fetchRuntime(receipt.service_origin);\n errors.push(...managedServiceIdentityErrors(runtime, receipt));\n } catch (error) {\n errors.push(`runtime health failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n return { errors, healthy: errors.length === 0, runtime };\n}\n\nasync function waitForHealthy(receipt, timeoutMs = 20_000) {\n const deadline = Date.now() + timeoutMs;\n let health = { errors: ['service did not respond'], healthy: false };\n while (Date.now() < deadline && processAlive(receipt.pid)) {\n health = await inspectHealth(receipt);\n if (health.healthy) return health;\n await new Promise(resolveDelay => setTimeout(resolveDelay, 250));\n }\n throw new Error(`Service failed readiness: ${health.errors.join('; ')}`);\n}\n\nfunction openBrowser(origin) {\n const command = platform() === 'darwin' ? 'open' : platform() === 'win32' ? 'cmd' : 'xdg-open';\n const args = platform() === 'win32' ? ['/c', 'start', '', origin] : [origin];\n const child = spawn(command, args, { detached: true, stdio: 'ignore' });\n child.unref();\n}\n\nfunction terminate(receipt, force = false) {\n if (!processAlive(receipt.pid)) return;\n const currentStart = processStartToken(receipt.pid);\n const command = processCommand(receipt.pid);\n const processMatches = receipt.process_start\n ? currentStart === receipt.process_start\n : Boolean(command?.includes('start') && command.includes(receipt.manifest_path));\n if (!processMatches && !force) {\n throw new Error(`Refusing to signal pid ${receipt.pid}: process identity no longer matches the service receipt; inspect manually or pass --force`);\n }\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGTERM'); } catch (error) { if (error?.code !== 'ESRCH') throw error; }\n}\n\nasync function startManaged(channel, selector, launcher, args) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const runtimeIdentity = runtimeDoctor(launcher);\n if (status !== 0 || !doctor.ok || !doctor.runtime?.code_verified) {\n const failures = (doctor.checks || []).filter(check => check.status === 'fail').map(check => `${check.id}: ${check.message}`);\n throw new Error(`Profile doctor must pass before service start: ${failures.join('; ') || 'unverified runtime'}`);\n }\n if (runtimeIdentity.fingerprint !== doctor.runtime.code_fingerprint || runtimeIdentity.channel !== channel) {\n throw new Error('Runtime doctor identity changed while resolving the service profile');\n }\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const existing = readReceipt(paths.receipt);\n if (existing) {\n const health = await inspectHealth(existing);\n const desiredErrors = desiredReceiptErrors(channel, doctor, existing);\n if (health.healthy && desiredErrors.length === 0) throw new Error(`Managed service is already healthy at ${existing.service_origin}`);\n if (processAlive(existing.pid)) throw new Error(`Managed service pid ${existing.pid} exists but is stale or unhealthy: ${[...desiredErrors, ...health.errors].join('; ')}`);\n rmSync(paths.receipt, { force: true });\n }\n mkdirSync(paths.directory, { recursive: true, mode: 0o700 });\n const logFd = openSync(paths.log, 'a', 0o600);\n const instanceId = randomUUID();\n const startArgs = ['start', '--profile', doctor.profile.manifest_path, '--json'];\n const child = spawn(launcher[0], [...launcher.slice(1), ...startArgs], {\n cwd: root,\n detached: true,\n env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId },\n stdio: ['ignore', logFd, logFd],\n });\n closeSync(logFd);\n child.unref();\n const receipt = {\n channel,\n code_fingerprint: doctor.runtime.code_fingerprint,\n code_origin: doctor.runtime.code_origin,\n code_root: runtimeIdentity.root,\n database_path: doctor.profile.database_path,\n environment: doctor.profile.environment,\n instance_id: instanceId,\n launcher,\n log_path: paths.log,\n manifest_path: doctor.profile.manifest_path,\n pid: child.pid,\n process_start: processStartToken(child.pid),\n profile_fingerprint: doctor.profile.profile_fingerprint,\n profile_id: doctor.profile.profile_id,\n schema_version: receiptSchema,\n service_origin: doctor.profile.service_origin,\n started_at: new Date().toISOString(),\n };\n writeReceipt(paths.receipt, receipt);\n try {\n const health = await waitForHealthy(receipt, Number(readOption(args, '--timeout-ms') || 20_000));\n if (args.includes('--open')) openBrowser(receipt.service_origin);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n } catch (error) {\n terminate(receipt, true);\n throw error;\n }\n } finally {\n release();\n }\n}\n\nasync function statusManaged(channel, selector, launcher) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n if (!receipt) throw new Error(`No managed service receipt exists for ${channel}/${doctor.profile.profile_id}`);\n const health = await inspectHealth(receipt);\n const doctorFailures = status === 0 && doctor.ok\n ? []\n : (doctor.checks || []).filter(check => check.status === 'fail').map(check => `current doctor ${check.id}: ${check.message}`);\n const errors = [...doctorFailures, ...desiredReceiptErrors(channel, doctor, receipt), ...health.errors];\n if (errors.length > 0) throw new Error(`Managed service is not healthy: ${errors.join('; ')}`);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n}\n\nasync function stopManaged(channel, selector, launcher, force) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const receipt = readReceipt(paths.receipt);\n if (!receipt) return { already_stopped: true, profile_id: doctor.profile.profile_id };\n if (receipt.manifest_path !== doctor.profile.manifest_path || receipt.profile_id !== doctor.profile.profile_id) {\n throw new Error('Service receipt identity does not match the requested profile');\n }\n terminate(receipt, force);\n const deadline = Date.now() + 5_000;\n while (processAlive(receipt.pid) && Date.now() < deadline) await new Promise(resolveDelay => setTimeout(resolveDelay, 100));\n if (processAlive(receipt.pid) && force) {\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGKILL'); } catch { /* already exited */ }\n }\n if (processAlive(receipt.pid)) throw new Error(`Service pid ${receipt.pid} did not stop`);\n rmSync(paths.receipt, { force: true });\n return { profile_id: receipt.profile_id, stopped: true };\n } finally {\n release();\n }\n}\n\nfunction logsManaged(channel, selector, launcher, lines) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n const logPath = receipt?.log_path || paths.log;\n if (!existsSync(logPath)) throw new Error(`No managed service log exists: ${logPath}`);\n return readFileSync(logPath, 'utf8').split('\\n').slice(-lines).join('\\n');\n}\n\nfunction usage() {\n return `Usage:\n lineage-service start --channel stable|preview|dev --profile <id-or-manifest> [--open] [--json]\n lineage-service status --channel stable|preview|dev --profile <id-or-manifest> [--json]\n lineage-service stop --channel stable|preview|dev --profile <id-or-manifest> [--force] [--json]\n lineage-service logs --channel stable|preview|dev --profile <id-or-manifest> [--lines 100]\n\nStart writes a profile-scoped receipt, waits for /api/runtime to match the exact\ncode/profile/database/service instance, and only then opens a browser. Status is\nnonzero for a stale PID, failed health request, or any identity mismatch.`;\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\n console.log(usage());\n return;\n }\n const command = args[0];\n const channel = readOption(args, '--channel');\n const selector = readOption(args, '--profile');\n if (!['stable', 'preview', 'dev'].includes(channel)) throw new Error('--channel must be stable, preview, or dev');\n if (!selector) throw new Error('--profile is required; managed services never use legacy-unbound data');\n assertServiceManagerOrigin(channel);\n const launcher = launcherFor(channel, args);\n let result;\n if (command === 'start') result = await startManaged(channel, selector, launcher, args);\n else if (command === 'status') result = await statusManaged(channel, selector, launcher);\n else if (command === 'stop') result = await stopManaged(channel, selector, launcher, args.includes('--force'));\n else if (command === 'logs') {\n const output = logsManaged(channel, selector, launcher, Number(readOption(args, '--lines') || 100));\n console.log(output);\n return;\n } else throw new Error(`Unknown managed-service command: ${command}`);\n if (args.includes('--json')) console.log(JSON.stringify(result, null, 2));\n else if (command === 'status' || command === 'start') console.log(`Lineage ${channel}/${result.receipt.profile_id} healthy at ${result.receipt.service_origin}`);\n else console.log(`Lineage ${channel}/${result.profile_id} stopped`);\n}\n\nconst invokedAs = process.argv[1] ? basename(process.argv[1]) : '';\nif (process.argv[1] && (\n resolve(process.argv[1]) === fileURLToPath(import.meta.url)\n || ['lineage-service', 'lineage-stable-service', 'lineage-preview-service', 'managed-service.js', 'managed-service.mjs'].includes(invokedAs)\n)) {\n main().catch(error => {\n console.error(`managed-service: ${error instanceof Error ? error.message : String(error)}`);\n process.exitCode = 1;\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;AAEA,SAAS,YAAY,kBAAkB;AACvC,SAAS,OAAO,iBAAiB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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YAAY,QAAQ,KAAK,CAAC,IAAI,SAAS,QAAQ,KAAK,CAAC,CAAC,IAAI;AAChE,IAAI,QAAQ,KAAK,CAAC,MAChB,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,cAAc,YAAY,GAAG,KACvD,CAAC,mBAAmB,0BAA0B,2BAA2B,sBAAsB,qBAAqB,EAAE,SAAS,SAAS,IAC1I;AACD,OAAK,EAAE,MAAM,WAAS;AACpB,YAAQ,MAAM,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAC1F,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;",
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport { randomUUID, createHash } from 'node:crypto';\nimport { spawn, spawnSync } from 'node:child_process';\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n readdirSync,\n readlinkSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir, platform } from 'node:os';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst scriptDirectory = dirname(fileURLToPath(import.meta.url));\nconst root = [resolve(scriptDirectory, '../..'), resolve(scriptDirectory, '..')].find(candidate => {\n try {\n const packageInfo = JSON.parse(readFileSync(join(candidate, 'package.json'), 'utf8'));\n return packageInfo.name === '@mean-weasel/lineage';\n } catch {\n return false;\n }\n});\nif (!root) throw new Error('Unable to locate the Lineage package root for managed service control');\nconst receiptSchema = 'lineage.managed_service.v1';\n\nfunction packageTreeSha256(packageRoot) {\n const hash = createHash('sha256');\n const visit = (directory, relativeDirectory = '') => {\n for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {\n const relativePath = relativeDirectory ? join(relativeDirectory, entry.name) : entry.name;\n const path = join(directory, entry.name);\n hash.update(relativePath.replaceAll('\\\\', '/'));\n hash.update('\\0');\n if (entry.isDirectory()) {\n hash.update('directory\\0');\n visit(path, relativePath);\n } else if (entry.isSymbolicLink()) {\n hash.update('symlink\\0');\n hash.update(readlinkSync(path));\n } else if (entry.isFile()) {\n hash.update('file\\0');\n hash.update(readFileSync(path));\n } else {\n hash.update('other\\0');\n }\n hash.update('\\0');\n }\n };\n visit(packageRoot);\n return hash.digest('hex');\n}\n\nfunction assertServiceManagerOrigin(channel) {\n const checkoutController = resolve(scriptDirectory) === resolve(root, 'scripts');\n if (channel === 'dev') {\n if (!checkoutController) throw new Error('Dev service control is checkout-only; run node scripts/managed-service.mjs from the intended worktree');\n return;\n }\n if (checkoutController) throw new Error(`${channel} service control requires the matching attested packaged manager`);\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (!receiptPath || !existsSync(receiptPath)) throw new Error(`${channel} service manager is missing its runtime install receipt`);\n const receipt = JSON.parse(readFileSync(receiptPath, 'utf8'));\n if (receipt.channel !== channel || process.env.LINEAGE_RELEASE_CHANNEL !== channel) {\n throw new Error(`${channel} service manager receipt channel does not match the requested channel`);\n }\n if (!receipt.package_root || realpathSync(receipt.package_root) !== realpathSync(root)) {\n throw new Error(`${channel} service manager receipt package root ${receipt.package_root || '(missing)'} does not match controller root ${root}`);\n }\n if (packageTreeSha256(root) !== receipt.package_tree_sha256) throw new Error(`${channel} service manager package tree does not match its install receipt`);\n}\n\nfunction readOption(args, name) {\n const inline = args.find(arg => arg.startsWith(`${name}=`));\n if (inline) return inline.slice(name.length + 1);\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction serviceRoot() {\n if (process.env.LINEAGE_SERVICE_ROOT) return resolve(process.env.LINEAGE_SERVICE_ROOT);\n if (platform() === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Lineage', 'services');\n if (platform() === 'win32') return join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Lineage', 'services');\n return join(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'lineage', 'services');\n}\n\nfunction defaultLauncher(channel) {\n if (channel === 'dev') return [process.execPath, '--import', 'tsx', join(root, 'src', 'cli', 'lineage-dev.ts')];\n const envName = channel === 'stable' ? 'LINEAGE_STABLE_BIN' : 'LINEAGE_PREVIEW_BIN';\n const explicit = process.env[envName] || process.env.LINEAGE_CHANNEL_LAUNCHER;\n if (explicit) return [explicit];\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (receiptPath) {\n if (!existsSync(receiptPath)) throw new Error(`${channel} service manager runtime receipt does not exist: ${receiptPath}`);\n const resolvedReceipt = realpathSync(receiptPath);\n const runtimeRoot = dirname(dirname(dirname(dirname(resolvedReceipt))));\n const pointerPath = join(runtimeRoot, 'channels', `${channel}.json`);\n if (!existsSync(pointerPath)) throw new Error(`${channel} service manager could not find its receipt-bound channel pointer: ${pointerPath}`);\n const pointer = JSON.parse(readFileSync(pointerPath, 'utf8'));\n if (pointer.channel !== channel) throw new Error(`${channel} service manager channel pointer reports ${pointer.channel || '(missing)'}`);\n if (!pointer.receipt_path || !existsSync(pointer.receipt_path) || realpathSync(pointer.receipt_path) !== resolvedReceipt) {\n throw new Error(`${channel} service manager channel pointer is not bound to its runtime receipt`);\n }\n if (!pointer.shim || !existsSync(pointer.shim)) throw new Error(`${channel} service manager channel pointer launcher is missing: ${pointer.shim || '(missing)'}`);\n return [realpathSync(pointer.shim)];\n }\n const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT\n || (platform() === 'darwin'\n ? join(homedir(), 'Library', 'Application Support', 'Lineage', 'runtimes')\n : join(homedir(), '.local', 'share', 'lineage', 'runtimes'));\n return [join(runtimeRoot, 'bin', channel === 'stable' ? 'lineage-stable' : 'lineage-preview')];\n}\n\nfunction launcherFor(channel, args) {\n const explicit = readOption(args, '--launcher');\n return explicit ? [resolve(explicit)] : defaultLauncher(channel);\n}\n\nfunction invoke(launcher, args, options = {}) {\n return spawnSync(launcher[0], [...launcher.slice(1), ...args], {\n cwd: root,\n encoding: 'utf8',\n ...options,\n });\n}\n\nfunction invocationFailure(result) {\n const stderr = typeof result.stderr === 'string' ? result.stderr.trim() : '';\n const stdout = typeof result.stdout === 'string' ? result.stdout.trim() : '';\n const spawnError = result.error instanceof Error ? result.error.message : result.error ? String(result.error) : '';\n return stderr || stdout || spawnError || `process exited with status ${result.status ?? 'unknown'}`;\n}\n\nfunction shellDisplay(parts) {\n return parts.map(part => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(' ');\n}\n\nfunction profileDoctor(launcher, selector) {\n const result = invoke(launcher, ['profile', 'doctor', '--profile', selector, '--json']);\n let doctor;\n try {\n doctor = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Profile doctor did not return JSON: ${invocationFailure(result)}`);\n }\n if (!doctor.profile) {\n const detail = doctor.error\n || (doctor.checks || []).filter(check => check.status === 'fail').map(check => check.message).join('; ')\n || invocationFailure(result)\n || 'profile manifest was not found or could not be read';\n const doctorCommand = shellDisplay([...launcher, 'profile', 'doctor', '--profile', selector, '--json']);\n const initCommand = shellDisplay([...launcher, 'profile', 'init', '--profile', selector, '--confirm-write', '--json']);\n throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \\`${doctorCommand}\\`. If this is a new profile, run \\`${initCommand}\\` instead.`);\n }\n return { doctor, status: result.status ?? 1 };\n}\n\nfunction runtimeDoctor(launcher) {\n const result = invoke(launcher, ['runtime', 'doctor', '--json']);\n let runtime;\n try {\n runtime = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Runtime doctor did not return JSON: ${invocationFailure(result)}`);\n }\n if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${invocationFailure(result) || JSON.stringify(runtime)}`);\n return runtime;\n}\n\nfunction statePaths(channel, profile) {\n const digest = createHash('sha256').update(profile.manifest_path).digest('hex').slice(0, 12);\n const key = `${channel}--${profile.profile_id}--${digest}`;\n const directory = join(serviceRoot(), key);\n return {\n directory,\n lock: `${directory}.manager.lock`,\n log: join(directory, 'service.log'),\n receipt: join(directory, 'service.json'),\n };\n}\n\nfunction processAlive(pid) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return error?.code !== 'ESRCH';\n }\n}\n\nfunction processStartToken(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'lstart='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction processCommand(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction acquireManagerLock(path) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(path, { mode: 0o700 });\n writeFileSync(join(path, 'owner.json'), `${JSON.stringify({ acquired_at: new Date().toISOString(), pid: process.pid })}\\n`, { mode: 0o600 });\n return () => rmSync(path, { force: true, recursive: true });\n } catch (error) {\n if (error?.code !== 'EEXIST') throw error;\n try {\n const owner = JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8'));\n if (Number.isSafeInteger(owner.pid) && processAlive(owner.pid)) {\n throw new Error(`Another service manager operation is active (pid ${owner.pid})`, { cause: error });\n }\n } catch (ownerError) {\n if (ownerError instanceof Error && ownerError.message.startsWith('Another service manager')) throw ownerError;\n }\n rmSync(path, { force: true, recursive: true });\n }\n }\n throw new Error(`Could not acquire service manager lock ${path}`);\n}\n\nfunction readReceipt(path) {\n if (!existsSync(path)) return undefined;\n const receipt = JSON.parse(readFileSync(path, 'utf8'));\n if (\n receipt.schema_version !== receiptSchema\n || !Number.isSafeInteger(receipt.pid)\n || typeof receipt.instance_id !== 'string'\n || typeof receipt.profile_fingerprint !== 'string'\n || !Array.isArray(receipt.launcher)\n ) throw new Error(`Managed service receipt is invalid: ${path}`);\n return receipt;\n}\n\nfunction writeReceipt(path, receipt) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporary, `${JSON.stringify(receipt, null, 2)}\\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });\n renameSync(temporary, path);\n}\n\nexport function managedServiceIdentityErrors(runtime, receipt) {\n const errors = [];\n if (runtime.channel !== receipt.channel) errors.push(`channel ${runtime.channel} != ${receipt.channel}`);\n if (!runtime.code?.verified) errors.push('code identity is not verified');\n if (runtime.code?.fingerprint !== receipt.code_fingerprint) errors.push(`code fingerprint ${runtime.code?.fingerprint || 'missing'} != ${receipt.code_fingerprint}`);\n if (runtime.profile?.id !== receipt.profile_id) errors.push(`profile ${runtime.profile?.id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.profile?.environment !== receipt.environment) errors.push(`environment ${runtime.profile?.environment || 'missing'} != ${receipt.environment}`);\n if (runtime.profile?.fingerprint !== receipt.profile_fingerprint) errors.push(`profile fingerprint ${runtime.profile?.fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (runtime.schema?.profile_id !== receipt.profile_id) errors.push(`database profile ${runtime.schema?.profile_id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.schema?.profile_fingerprint !== receipt.profile_fingerprint) errors.push(`database fingerprint ${runtime.schema?.profile_fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (resolve(runtime.database?.path || '') !== resolve(receipt.database_path)) errors.push(`database ${runtime.database?.path || 'missing'} != ${receipt.database_path}`);\n if (runtime.service?.instance_id !== receipt.instance_id) errors.push(`instance ${runtime.service?.instance_id || 'missing'} != ${receipt.instance_id}`);\n if (runtime.service?.launcher_pid !== receipt.pid) errors.push(`launcher pid ${runtime.service?.launcher_pid || 'missing'} != ${receipt.pid}`);\n if (runtime.service?.mode !== 'managed') errors.push(`service mode ${runtime.service?.mode || 'missing'} != managed`);\n return errors;\n}\n\nfunction desiredReceiptErrors(channel, doctor, receipt) {\n const errors = [];\n if (receipt.channel !== channel) errors.push(`receipt channel ${receipt.channel} != ${channel}`);\n if (receipt.code_fingerprint !== doctor.runtime?.code_fingerprint) errors.push(`receipt code fingerprint ${receipt.code_fingerprint} != current ${doctor.runtime?.code_fingerprint || 'missing'}`);\n if (receipt.code_origin !== doctor.runtime?.code_origin) errors.push(`receipt code origin ${receipt.code_origin} != current ${doctor.runtime?.code_origin || 'missing'}`);\n if (receipt.profile_id !== doctor.profile.profile_id) errors.push(`receipt profile ${receipt.profile_id} != ${doctor.profile.profile_id}`);\n if (receipt.environment !== doctor.profile.environment) errors.push(`receipt environment ${receipt.environment} != ${doctor.profile.environment}`);\n if (receipt.profile_fingerprint !== doctor.profile.profile_fingerprint) errors.push(`receipt profile fingerprint ${receipt.profile_fingerprint} != current ${doctor.profile.profile_fingerprint}`);\n if (resolve(receipt.database_path) !== resolve(doctor.profile.database_path)) errors.push('receipt database path does not match current profile');\n if (receipt.service_origin !== doctor.profile.service_origin) errors.push('receipt service origin does not match current profile');\n if (receipt.manifest_path !== doctor.profile.manifest_path) errors.push('receipt manifest path does not match current profile');\n return errors;\n}\n\nasync function fetchRuntime(origin) {\n const response = await fetch(`${origin}/api/runtime`, { signal: AbortSignal.timeout(1_000) });\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const body = await response.json();\n if (!body?.runtime) throw new Error('Runtime response is missing runtime identity');\n return body.runtime;\n}\n\nasync function inspectHealth(receipt) {\n const errors = [];\n if (!processAlive(receipt.pid)) errors.push(`launcher pid ${receipt.pid} is not alive`);\n if (receipt.process_start && processStartToken(receipt.pid) !== receipt.process_start) errors.push(`launcher pid ${receipt.pid} was reused`);\n let runtime;\n try {\n runtime = await fetchRuntime(receipt.service_origin);\n errors.push(...managedServiceIdentityErrors(runtime, receipt));\n } catch (error) {\n errors.push(`runtime health failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n return { errors, healthy: errors.length === 0, runtime };\n}\n\nasync function waitForHealthy(receipt, timeoutMs = 20_000) {\n const deadline = Date.now() + timeoutMs;\n let health = { errors: ['service did not respond'], healthy: false };\n while (Date.now() < deadline && processAlive(receipt.pid)) {\n health = await inspectHealth(receipt);\n if (health.healthy) return health;\n await new Promise(resolveDelay => setTimeout(resolveDelay, 250));\n }\n throw new Error(`Service failed readiness: ${health.errors.join('; ')}`);\n}\n\nfunction openBrowser(origin) {\n const command = platform() === 'darwin' ? 'open' : platform() === 'win32' ? 'cmd' : 'xdg-open';\n const args = platform() === 'win32' ? ['/c', 'start', '', origin] : [origin];\n const child = spawn(command, args, { detached: true, stdio: 'ignore' });\n child.unref();\n}\n\nfunction terminate(receipt, force = false) {\n if (!processAlive(receipt.pid)) return;\n const currentStart = processStartToken(receipt.pid);\n const command = processCommand(receipt.pid);\n const processMatches = receipt.process_start\n ? currentStart === receipt.process_start\n : Boolean(command?.includes('start') && command.includes(receipt.manifest_path));\n if (!processMatches && !force) {\n throw new Error(`Refusing to signal pid ${receipt.pid}: process identity no longer matches the service receipt; inspect manually or pass --force`);\n }\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGTERM'); } catch (error) { if (error?.code !== 'ESRCH') throw error; }\n}\n\nasync function startManaged(channel, selector, launcher, args) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const runtimeIdentity = runtimeDoctor(launcher);\n if (status !== 0 || !doctor.ok || !doctor.runtime?.code_verified) {\n const failures = (doctor.checks || []).filter(check => check.status === 'fail').map(check => `${check.id}: ${check.message}`);\n throw new Error(`Profile doctor must pass before service start: ${failures.join('; ') || 'unverified runtime'}`);\n }\n if (runtimeIdentity.fingerprint !== doctor.runtime.code_fingerprint || runtimeIdentity.channel !== channel) {\n throw new Error('Runtime doctor identity changed while resolving the service profile');\n }\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const existing = readReceipt(paths.receipt);\n if (existing) {\n const health = await inspectHealth(existing);\n const desiredErrors = desiredReceiptErrors(channel, doctor, existing);\n if (health.healthy && desiredErrors.length === 0) {\n if (args.includes('--open')) openBrowser(existing.service_origin);\n return { already_running: true, healthy: true, receipt: existing, runtime: health.runtime, state_path: paths.receipt };\n }\n if (processAlive(existing.pid)) throw new Error(`Managed service pid ${existing.pid} exists but is stale or unhealthy: ${[...desiredErrors, ...health.errors].join('; ')}`);\n rmSync(paths.receipt, { force: true });\n }\n mkdirSync(paths.directory, { recursive: true, mode: 0o700 });\n const logFd = openSync(paths.log, 'a', 0o600);\n const instanceId = randomUUID();\n const startArgs = ['start', '--profile', doctor.profile.manifest_path, '--json'];\n const child = spawn(launcher[0], [...launcher.slice(1), ...startArgs], {\n cwd: root,\n detached: true,\n env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId, LINEAGE_SERVICE_MODE: 'managed' },\n stdio: ['ignore', logFd, logFd],\n });\n closeSync(logFd);\n child.unref();\n const receipt = {\n channel,\n code_fingerprint: doctor.runtime.code_fingerprint,\n code_origin: doctor.runtime.code_origin,\n code_root: runtimeIdentity.root,\n database_path: doctor.profile.database_path,\n environment: doctor.profile.environment,\n instance_id: instanceId,\n launcher,\n log_path: paths.log,\n manifest_path: doctor.profile.manifest_path,\n pid: child.pid,\n process_start: processStartToken(child.pid),\n profile_fingerprint: doctor.profile.profile_fingerprint,\n profile_id: doctor.profile.profile_id,\n schema_version: receiptSchema,\n service_origin: doctor.profile.service_origin,\n started_at: new Date().toISOString(),\n };\n writeReceipt(paths.receipt, receipt);\n try {\n const health = await waitForHealthy(receipt, Number(readOption(args, '--timeout-ms') || 20_000));\n if (args.includes('--open')) openBrowser(receipt.service_origin);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n } catch (error) {\n terminate(receipt, true);\n throw error;\n }\n } finally {\n release();\n }\n}\n\nasync function statusManaged(channel, selector, launcher) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n if (!receipt) throw new Error(`No managed service receipt exists for ${channel}/${doctor.profile.profile_id}`);\n const health = await inspectHealth(receipt);\n const doctorFailures = status === 0 && doctor.ok\n ? []\n : (doctor.checks || []).filter(check => check.status === 'fail').map(check => `current doctor ${check.id}: ${check.message}`);\n const errors = [...doctorFailures, ...desiredReceiptErrors(channel, doctor, receipt), ...health.errors];\n if (errors.length > 0) throw new Error(`Managed service is not healthy: ${errors.join('; ')}`);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n}\n\nasync function stopManaged(channel, selector, launcher, force) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const receipt = readReceipt(paths.receipt);\n if (!receipt) return { already_stopped: true, profile_id: doctor.profile.profile_id };\n if (receipt.manifest_path !== doctor.profile.manifest_path || receipt.profile_id !== doctor.profile.profile_id) {\n throw new Error('Service receipt identity does not match the requested profile');\n }\n terminate(receipt, force);\n const deadline = Date.now() + 5_000;\n while (processAlive(receipt.pid) && Date.now() < deadline) await new Promise(resolveDelay => setTimeout(resolveDelay, 100));\n if (processAlive(receipt.pid) && force) {\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGKILL'); } catch { /* already exited */ }\n }\n if (processAlive(receipt.pid)) throw new Error(`Service pid ${receipt.pid} did not stop`);\n rmSync(paths.receipt, { force: true });\n return { profile_id: receipt.profile_id, stopped: true };\n } finally {\n release();\n }\n}\n\nfunction logsManaged(channel, selector, launcher, lines) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n const logPath = receipt?.log_path || paths.log;\n if (!existsSync(logPath)) throw new Error(`No managed service log exists: ${logPath}`);\n return readFileSync(logPath, 'utf8').split('\\n').slice(-lines).join('\\n');\n}\n\nfunction usage() {\n return `Usage:\n lineage-service start --channel stable|preview|dev --profile <id-or-manifest> [--open] [--json]\n lineage-service status --channel stable|preview|dev --profile <id-or-manifest> [--json]\n lineage-service stop --channel stable|preview|dev --profile <id-or-manifest> [--force] [--json]\n lineage-service logs --channel stable|preview|dev --profile <id-or-manifest> [--lines 100]\n\nStart writes a profile-scoped receipt, waits for /api/runtime to match the exact\ncode/profile/database/service instance, and only then opens a browser. Status is\nnonzero for a stale PID, failed health request, or any identity mismatch.`;\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\n console.log(usage());\n return;\n }\n const command = args[0];\n const channel = readOption(args, '--channel');\n const selector = readOption(args, '--profile');\n if (!['stable', 'preview', 'dev'].includes(channel)) throw new Error('--channel must be stable, preview, or dev');\n if (!selector) throw new Error('--profile is required; managed services never use legacy-unbound data');\n assertServiceManagerOrigin(channel);\n const launcher = launcherFor(channel, args);\n let result;\n if (command === 'start') result = await startManaged(channel, selector, launcher, args);\n else if (command === 'status') result = await statusManaged(channel, selector, launcher);\n else if (command === 'stop') result = await stopManaged(channel, selector, launcher, args.includes('--force'));\n else if (command === 'logs') {\n const output = logsManaged(channel, selector, launcher, Number(readOption(args, '--lines') || 100));\n console.log(output);\n return;\n } else throw new Error(`Unknown managed-service command: ${command}`);\n if (args.includes('--json')) console.log(JSON.stringify(result, null, 2));\n else if (command === 'status' || command === 'start') console.log(`Lineage ${channel}/${result.receipt.profile_id} healthy at ${result.receipt.service_origin}`);\n else console.log(`Lineage ${channel}/${result.profile_id} stopped`);\n}\n\nconst invokedAs = process.argv[1] ? basename(process.argv[1]) : '';\nif (process.argv[1] && (\n resolve(process.argv[1]) === fileURLToPath(import.meta.url)\n || ['lineage-service', 'lineage-stable-service', 'lineage-preview-service', 'managed-service.js', 'managed-service.mjs'].includes(invokedAs)\n)) {\n main().catch(error => {\n const message = error instanceof Error ? error.message : String(error);\n if (process.argv.includes('--json')) console.error(JSON.stringify({ error: message, ok: false }, null, 2));\n else console.error(`managed-service: ${message}`);\n process.exitCode = 1;\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;AAEA,S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AAK,UAAU,EAAE,OAAO,SAAS,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC;AAAA,QACpG,SAAQ,MAAM,oBAAoB,OAAO,EAAE;AAChD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;",
|
|
6
|
+
"names": ["runtimeRoot"]
|
|
7
7
|
}
|
package/dist/runtime-build.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"build_fingerprint": "
|
|
2
|
+
"build_fingerprint": "06b247a5facc91f5229fcc17b7ae8bb22a2d3e663f4fd1520bb50152254669fe",
|
|
3
3
|
"package_name": "@mean-weasel/lineage",
|
|
4
|
-
"package_version": "0.1.
|
|
4
|
+
"package_version": "0.1.18",
|
|
5
5
|
"schema_version": "lineage.runtime_build.v1",
|
|
6
6
|
"source_dirty": false,
|
|
7
|
-
"source_fingerprint": "
|
|
8
|
-
"source_git_sha": "
|
|
7
|
+
"source_fingerprint": "f57dfbc56b806bf349bab7a5a4431c014e76cdb04321e610178a8b85707679b0",
|
|
8
|
+
"source_git_sha": "7b7a0ba3166359522a78bf918bf3e88e471bf933"
|
|
9
9
|
}
|
package/dist/server.js
CHANGED
|
@@ -815,7 +815,7 @@ function acquireProfileWriterLease(profile, channel, role = "service") {
|
|
|
815
815
|
}
|
|
816
816
|
function assertProfileWriterLeaseHeld() {
|
|
817
817
|
if (!process.env.LINEAGE_PROFILE) {
|
|
818
|
-
throw new Error("Persistent writes require a selected named Lineage profile and its writer lease; legacy-unbound access is read-only");
|
|
818
|
+
throw new Error("Persistent writes require a selected named Lineage profile and its writer lease; legacy-unbound access is read-only. Create a fresh profile with `profile init --profile <id> --confirm-write`, then pass that profile to the command");
|
|
819
819
|
}
|
|
820
820
|
const profileId = process.env.LINEAGE_PROFILE_ID;
|
|
821
821
|
const profileFingerprint = process.env.LINEAGE_PROFILE_FINGERPRINT;
|
|
@@ -8645,6 +8645,23 @@ function upsertSwissifierRerollAttempts(project, manifest) {
|
|
|
8645
8645
|
}
|
|
8646
8646
|
return { total: attempts.length };
|
|
8647
8647
|
}
|
|
8648
|
+
function backfillSwissifierEdgeSummaries(project, manifest) {
|
|
8649
|
+
const database = lineageDb();
|
|
8650
|
+
const timestamp = nowIso();
|
|
8651
|
+
try {
|
|
8652
|
+
const statement = database.prepare(`
|
|
8653
|
+
update asset_edges
|
|
8654
|
+
set summary = ?, summary_created_by = 'system', summary_updated_by = 'system', summary_updated_at = ?
|
|
8655
|
+
where project_id = ? and parent_asset_id = ? and child_asset_id = ? and relation_type = 'derived_from'
|
|
8656
|
+
and summary is null and summary_created_by is null and summary_updated_by is null and summary_updated_at is null
|
|
8657
|
+
`);
|
|
8658
|
+
for (const edge of manifest.edges) {
|
|
8659
|
+
statement.run(requireEdgeSummary(edge.summary), timestamp, project, edge.parent, edge.child);
|
|
8660
|
+
}
|
|
8661
|
+
} finally {
|
|
8662
|
+
database.close();
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8648
8665
|
function seedDemoLineageWorkspace(project, fields) {
|
|
8649
8666
|
const ids = fields.confirmWrite ? writeDemoFiles(project) : demoAssetIds();
|
|
8650
8667
|
const rootAssetId = ids.root;
|
|
@@ -8707,6 +8724,7 @@ function seedSwissifierRichDemoWorkspace(project, fields) {
|
|
|
8707
8724
|
for (const edge of manifest.edges) {
|
|
8708
8725
|
linkLineageAssets(project, { parentAssetId: edge.parent, childAssetId: edge.child, confirmWrite: true });
|
|
8709
8726
|
}
|
|
8727
|
+
backfillSwissifierEdgeSummaries(project, manifest);
|
|
8710
8728
|
const reroll_attempts = upsertSwissifierRerollAttempts(project, manifest);
|
|
8711
8729
|
updateSelectedAsset(project, {
|
|
8712
8730
|
assetIds: manifest.selected_asset_ids,
|
|
@@ -9112,6 +9130,9 @@ function getLineageRuntimeInfo(options = {}) {
|
|
|
9112
9130
|
const code = options.code || getLineageCodeIdentity(channel);
|
|
9113
9131
|
const databaseInfo = { exists: existsSync11(dbPath), path: dbPath };
|
|
9114
9132
|
const schema = { migration_keys: [] };
|
|
9133
|
+
const serviceInstanceId = process.env.LINEAGE_SERVICE_INSTANCE_ID;
|
|
9134
|
+
const launcherPid = process.env.LINEAGE_LAUNCHER_PID ? Number(process.env.LINEAGE_LAUNCHER_PID) : void 0;
|
|
9135
|
+
const isServiceProcess = Boolean(serviceInstanceId && Number.isInteger(launcherPid) && launcherPid > 0);
|
|
9115
9136
|
if (databaseInfo.exists) {
|
|
9116
9137
|
try {
|
|
9117
9138
|
const stat = statSync5(dbPath);
|
|
@@ -9149,14 +9170,22 @@ function getLineageRuntimeInfo(options = {}) {
|
|
|
9149
9170
|
git_sha: code.git_sha,
|
|
9150
9171
|
node_env: process.env.NODE_ENV,
|
|
9151
9172
|
package_name: info.name,
|
|
9152
|
-
|
|
9153
|
-
schema,
|
|
9154
|
-
service: {
|
|
9155
|
-
instance_id: process.env.LINEAGE_SERVICE_INSTANCE_ID,
|
|
9156
|
-
launcher_pid: process.env.LINEAGE_LAUNCHER_PID ? Number(process.env.LINEAGE_LAUNCHER_PID) : void 0,
|
|
9173
|
+
process: {
|
|
9157
9174
|
pid: process.pid,
|
|
9175
|
+
role: isServiceProcess ? "service" : "command",
|
|
9158
9176
|
started_at: processStartedAt
|
|
9159
9177
|
},
|
|
9178
|
+
profile: runtimeProfileIdentity(channel),
|
|
9179
|
+
schema,
|
|
9180
|
+
...isServiceProcess ? {
|
|
9181
|
+
service: {
|
|
9182
|
+
instance_id: serviceInstanceId,
|
|
9183
|
+
launcher_pid: launcherPid,
|
|
9184
|
+
mode: process.env.LINEAGE_SERVICE_MODE === "managed" ? "managed" : "foreground",
|
|
9185
|
+
pid: process.pid,
|
|
9186
|
+
started_at: processStartedAt
|
|
9187
|
+
}
|
|
9188
|
+
} : {},
|
|
9160
9189
|
version: info.version
|
|
9161
9190
|
};
|
|
9162
9191
|
}
|
|
@@ -10122,7 +10151,12 @@ var runtimeChannel = normalizeRuntimeChannel(process.env.LINEAGE_CHANNEL || proc
|
|
|
10122
10151
|
var startupCode = assertLineageCodeOrigin(runtimeChannel);
|
|
10123
10152
|
assertRuntimeProfileSafety(runtimeChannel);
|
|
10124
10153
|
var startupRuntime = getLineageRuntimeInfo({ channel: runtimeChannel, code: startupCode });
|
|
10125
|
-
if (!process.env.LINEAGE_PROFILE)
|
|
10154
|
+
if (!process.env.LINEAGE_PROFILE) {
|
|
10155
|
+
if (process.env.LINEAGE_ALLOW_UNBOUND_DIAGNOSTIC !== "1") {
|
|
10156
|
+
throw new Error("Lineage server startup requires a named profile. Use a channel launcher with start --profile <id>, or use `npm run dev -- --profile <id>` for hot reload. Set LINEAGE_ALLOW_UNBOUND_DIAGNOSTIC=1 only for an explicit read-only diagnostic server.");
|
|
10157
|
+
}
|
|
10158
|
+
assertUnselectedDatabaseIsUnbound(startupRuntime);
|
|
10159
|
+
}
|
|
10126
10160
|
var startupProfile;
|
|
10127
10161
|
if (process.env.LINEAGE_PROFILE) {
|
|
10128
10162
|
if (!process.env.LINEAGE_PROFILE_ID || !process.env.LINEAGE_PROFILE_ENVIRONMENT || !process.env.LINEAGE_PROFILE_MANIFEST) {
|
|
@@ -10174,7 +10208,7 @@ app.use((req, res, next) => {
|
|
|
10174
10208
|
if (startupProfile || req.method === "GET" || req.method === "HEAD" || req.method === "OPTIONS") return next();
|
|
10175
10209
|
res.status(409).json({
|
|
10176
10210
|
error: "profile_required",
|
|
10177
|
-
message: "Persistent writes require a selected named Lineage profile; legacy-unbound service access is read-only."
|
|
10211
|
+
message: "Persistent writes require a selected named Lineage profile; legacy-unbound service access is read-only. Create a fresh profile with `profile init --profile <id> --confirm-write`, then start with that profile."
|
|
10178
10212
|
});
|
|
10179
10213
|
});
|
|
10180
10214
|
function projectFrom(input) {
|