@mean-weasel/lineage 0.1.17 → 0.1.20
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 +12 -0
- package/dist/cli/lineage-channel.js.map +1 -1
- package/dist/cli/lineage-dev.js +50 -27
- package/dist/cli/lineage-dev.js.map +4 -4
- package/dist/cli/lineage-preview.js +50 -27
- package/dist/cli/lineage-preview.js.map +4 -4
- package/dist/cli/lineage.js +50 -27
- package/dist/cli/lineage.js.map +4 -4
- package/dist/cli/managed-service.js +29 -6
- package/dist/cli/managed-service.js.map +3 -3
- package/dist/runtime-build.json +4 -4
- package/dist/server.js +76 -52
- package/dist/server.js.map +4 -4
- package/dist/web/assets/app-536tsqAD.js +16 -0
- package/dist/web/assets/hero-agent-sync-D8ibW83E.mp4 +0 -0
- package/dist/web/assets/hero-agent-sync-poster-zBB3KpbO.png +0 -0
- package/dist/web/assets/landing-CPZnU7M8.js +1 -0
- package/dist/web/assets/landing-Dmkx4R_N.css +1 -0
- package/dist/web/index.html +1 -1
- package/dist/web/landing/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/app-DMogkUoS.js +0 -16
- package/dist/web/assets/hero-agent-sync-CSyh0tHy.mp4 +0 -0
- package/dist/web/assets/landing-Bn4qKbIO.css +0 -1
- package/dist/web/assets/landing-CoyGmxBo.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,6 +120,12 @@ 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
|
+
}
|
|
106
129
|
function shellDisplay(parts) {
|
|
107
130
|
return parts.map((part) => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(" ");
|
|
108
131
|
}
|
|
@@ -112,10 +135,10 @@ function profileDoctor(launcher, selector) {
|
|
|
112
135
|
try {
|
|
113
136
|
doctor = JSON.parse(result.stdout || "{}");
|
|
114
137
|
} catch {
|
|
115
|
-
throw new Error(`Profile doctor did not return JSON: ${(result
|
|
138
|
+
throw new Error(`Profile doctor did not return JSON: ${invocationFailure(result)}`);
|
|
116
139
|
}
|
|
117
140
|
if (!doctor.profile) {
|
|
118
|
-
const detail = doctor.error || (doctor.checks || []).filter((check) => check.status === "fail").map((check) => check.message).join("; ") || result
|
|
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";
|
|
119
142
|
const doctorCommand = shellDisplay([...launcher, "profile", "doctor", "--profile", selector, "--json"]);
|
|
120
143
|
const initCommand = shellDisplay([...launcher, "profile", "init", "--profile", selector, "--confirm-write", "--json"]);
|
|
121
144
|
throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \`${doctorCommand}\`. If this is a new profile, run \`${initCommand}\` instead.`);
|
|
@@ -128,9 +151,9 @@ function runtimeDoctor(launcher) {
|
|
|
128
151
|
try {
|
|
129
152
|
runtime = JSON.parse(result.stdout || "{}");
|
|
130
153
|
} catch {
|
|
131
|
-
throw new Error(`Runtime doctor did not return JSON: ${(result
|
|
154
|
+
throw new Error(`Runtime doctor did not return JSON: ${invocationFailure(result)}`);
|
|
132
155
|
}
|
|
133
|
-
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)}`);
|
|
134
157
|
return runtime;
|
|
135
158
|
}
|
|
136
159
|
function statePaths(channel, profile) {
|
|
@@ -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]\n || process.env.LINEAGE_CHANNEL_LAUNCHER\n || 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 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: ${(result.stderr || result.stdout).trim()}`);\n }\n if (!doctor.profile) {\n const detail = doctor.error\n || (doctor.checks || []).filter(check => check.status === 'fail').map(check => check.message).join('; ')\n || result.stderr.trim()\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: ${(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 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,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,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU,SAAS,MAAM,eAAe;AACjD,SAAS,qBAAqB;AAE9B,IAAM,kBAAkB,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC9D,IAAM,OAAO,CAAC,QAAQ,iBAAiB,OAAO,GAAG,QAAQ,iBAAiB,IAAI,CAAC,EAAE,KAAK,eAAa;AACjG,MAAI;AACF,UAAM,cAAc,KAAK,MAAM,aAAa,KAAK,WAAW,cAAc,GAAG,MAAM,CAAC;AACpF,WAAO,YAAY,SAAS;AAAA,EAC9B,QAAQ;AACN,WAAO;AAAA,EACT;AACF,CAAC;AACD,IAAI,CAAC,KAAM,OAAM,IAAI,MAAM,uEAAuE;AAClG,IAAM,gBAAgB;AAEtB,SAAS,kBAAkB,aAAa;AACtC,QAAM,OAAO,WAAW,QAAQ;AAChC,QAAM,QAAQ,CAAC,WAAW,oBAAoB,OAAO;AACnD,eAAW,SAAS,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC,GAAG;A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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,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAI,QAAQ,KAAK,SAAS,QAAQ,EAAG,SAAQ,MAAM,KAAK,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": []
|
|
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,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,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU,SAAS,MAAM,eAAe;AACjD,SAAS,qBAAqB;AAE9B,IAAM,kBAAkB,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC9D,IAAM,OAAO,CAAC,QAAQ,iBAAiB,OAAO,GAAG,QAAQ,iBAAiB,IAAI,CAAC,EAAE,KAAK,eAAa;AACjG,MAAI;AACF,UAAM,cAAc,KAAK,MAAM,aAAa,KAAK,WAAW,cAAc,GAAG,MAAM,CAAC;AACpF,WAAO,YAAY,SAAS;AAAA,EAC9B,QAAQ;AACN,WAAO;AAAA,EACT;AACF,CAAC;AACD,IAAI,CAAC,KAAM,OAAM,IAAI,MAAM,uEAAuE;AAClG,IAAM,gBAAgB;AAEtB,SAAS,kBAAkB,aAAa;AACtC,QAAM,OAAO,WAAW,QAAQ;AAChC,QAAM,QAAQ,CAAC,WAAW,oBAAoB,OAAO;AACnD,eAAW,SAAS,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC,GAAG;AAC9H,YAAM,eAAe,oBAAoB,KAAK,mBAAmB,MAAM,IAAI,IAAI,MAAM;AACrF,YAAM,OAAO,KAAK,WAAW,MAAM,IAAI;AACvC,WAAK,OAAO,aAAa,WAAW,MAAM,GAAG,CAAC;AAC9C,WAAK,OAAO,IAAI;AAChB,UAAI,MAAM,YAAY,GA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I;AACD,OAAK,EAAE,MAAM,WAAS;AACpB,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAI,QAAQ,KAAK,SAAS,QAAQ,EAAG,SAAQ,MAAM,KAAK,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": "de1fd2e2ce5b6d3ac17b832c06fe62e8780bf94bdc5d5d07221dde3392452510",
|
|
3
3
|
"package_name": "@mean-weasel/lineage",
|
|
4
|
-
"package_version": "0.1.
|
|
4
|
+
"package_version": "0.1.20",
|
|
5
5
|
"schema_version": "lineage.runtime_build.v1",
|
|
6
6
|
"source_dirty": false,
|
|
7
|
-
"source_fingerprint": "
|
|
8
|
-
"source_git_sha": "
|
|
7
|
+
"source_fingerprint": "c7f120476e5880d644e3da2ac1b46ff26964935e9dcca490a79b461d4726cae5",
|
|
8
|
+
"source_git_sha": "9b3e36ba2e2752b4f9dd414ffdade8dd946b69b4"
|
|
9
9
|
}
|
package/dist/server.js
CHANGED
|
@@ -282,7 +282,6 @@ function createS3StorageAdapter(deps) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
// src/server/assetLineageDb.ts
|
|
285
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
286
285
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4 } from "node:fs";
|
|
287
286
|
import { join as join5 } from "node:path";
|
|
288
287
|
|
|
@@ -293,7 +292,6 @@ import { dirname as dirname3, join as join4, resolve as resolve3 } from "node:pa
|
|
|
293
292
|
|
|
294
293
|
// src/server/lineageProfiles.ts
|
|
295
294
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
296
|
-
import { createRequire } from "node:module";
|
|
297
295
|
import {
|
|
298
296
|
chmodSync,
|
|
299
297
|
closeSync,
|
|
@@ -319,8 +317,26 @@ import { dirname as dirname2, isAbsolute, join as join3, relative as relative2,
|
|
|
319
317
|
var lineageProfileSchemaVersion = "lineage.profile.v1";
|
|
320
318
|
var lineageProfileDoctorSchemaVersion = "lineage.profile_doctor.v1";
|
|
321
319
|
|
|
322
|
-
// src/server/
|
|
320
|
+
// src/server/nodeSqlite.ts
|
|
321
|
+
import { createRequire } from "node:module";
|
|
323
322
|
var require2 = createRequire(import.meta.url);
|
|
323
|
+
var sqliteExperimentalWarning = "SQLite is an experimental feature and might change at any time";
|
|
324
|
+
function loadNodeSqlite() {
|
|
325
|
+
const emitWarning = process.emitWarning;
|
|
326
|
+
process.emitWarning = ((warning, ...args) => {
|
|
327
|
+
const message = warning instanceof Error ? warning.message : warning;
|
|
328
|
+
const type = typeof args[0] === "string" ? args[0] : warning instanceof Error ? warning.name : void 0;
|
|
329
|
+
if (message === sqliteExperimentalWarning && type === "ExperimentalWarning") return;
|
|
330
|
+
return Reflect.apply(emitWarning, process, [warning, ...args]);
|
|
331
|
+
});
|
|
332
|
+
try {
|
|
333
|
+
return require2("node:sqlite");
|
|
334
|
+
} finally {
|
|
335
|
+
process.emitWarning = emitWarning;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/server/lineageProfiles.ts
|
|
324
340
|
var profileIdPattern = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
325
341
|
function lineageDataRoot() {
|
|
326
342
|
if (process.env.LINEAGE_HOME) return resolve2(process.env.LINEAGE_HOME);
|
|
@@ -499,7 +515,7 @@ function inspectDatabase(profile) {
|
|
|
499
515
|
};
|
|
500
516
|
if (!result.exists) return result;
|
|
501
517
|
try {
|
|
502
|
-
const { DatabaseSync } =
|
|
518
|
+
const { DatabaseSync } = loadNodeSqlite();
|
|
503
519
|
const database = new DatabaseSync(profile.database_path, { readOnly: true });
|
|
504
520
|
try {
|
|
505
521
|
if (tableExists(database, "lineage_profile_identity")) {
|
|
@@ -857,7 +873,6 @@ function assertSelectedProfileDatabaseIdentity(database) {
|
|
|
857
873
|
}
|
|
858
874
|
|
|
859
875
|
// src/server/assetLineageDb.ts
|
|
860
|
-
var require3 = createRequire2(import.meta.url);
|
|
861
876
|
function nowIso() {
|
|
862
877
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
863
878
|
}
|
|
@@ -871,7 +886,7 @@ function lineageDb() {
|
|
|
871
886
|
throw new Error(`Refusing writable open of missing profile database ${lineageDbPath()}; bind an existing database or create a non-production clone first`);
|
|
872
887
|
}
|
|
873
888
|
if (!readOnly) mkdirSync4(join5(lineageDbPath(), ".."), { recursive: true });
|
|
874
|
-
const { DatabaseSync } =
|
|
889
|
+
const { DatabaseSync } = loadNodeSqlite();
|
|
875
890
|
const database = readOnly ? new DatabaseSync(lineageDbPath(), { readOnly: true }) : new DatabaseSync(lineageDbPath());
|
|
876
891
|
if (process.env.LINEAGE_PROFILE) assertSelectedProfileDatabaseIdentity(database);
|
|
877
892
|
database.exec("PRAGMA foreign_keys = ON");
|
|
@@ -4504,32 +4519,38 @@ function updateAssetReview(project, fields) {
|
|
|
4504
4519
|
|
|
4505
4520
|
// src/server/lineageRuntimeCommand.ts
|
|
4506
4521
|
import { existsSync as existsSync7 } from "node:fs";
|
|
4507
|
-
import { createRequire as
|
|
4522
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
4508
4523
|
import { join as join8 } from "node:path";
|
|
4509
|
-
var
|
|
4510
|
-
function
|
|
4511
|
-
if (
|
|
4524
|
+
var require3 = createRequire2(import.meta.url);
|
|
4525
|
+
function lineageCliLauncher(channel = process.env.LINEAGE_CHANNEL) {
|
|
4526
|
+
if (channel === "dev") {
|
|
4512
4527
|
const sourceCli = join8(packageRoot, "src", "cli", "lineage-dev.ts");
|
|
4513
4528
|
const builtCli = join8(packageRoot, "dist", "cli", "lineage-dev.js");
|
|
4514
|
-
return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(
|
|
4529
|
+
return existsSync7(sourceCli) ? `${shellQuote(process.execPath)} --import ${shellQuote(require3.resolve("tsx"))} ${shellQuote(sourceCli)}` : `${shellQuote(process.execPath)} ${shellQuote(builtCli)}`;
|
|
4515
4530
|
}
|
|
4516
|
-
if (
|
|
4517
|
-
return "
|
|
4531
|
+
if (channel === "preview") return "lineage-preview";
|
|
4532
|
+
if (channel === "stable") return "lineage-stable";
|
|
4533
|
+
throw new Error("LINEAGE_CHANNEL must be stable, preview, or dev before generating a Lineage command");
|
|
4518
4534
|
}
|
|
4519
4535
|
function shellQuote(value) {
|
|
4520
4536
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
4521
4537
|
}
|
|
4522
|
-
function lineageRuntimeSelector() {
|
|
4538
|
+
function lineageRuntimeSelector(databasePath) {
|
|
4523
4539
|
const manifest = process.env.LINEAGE_PROFILE_MANIFEST?.trim();
|
|
4524
|
-
|
|
4540
|
+
const database = databasePath || process.env.LINEAGE_DB || join8(packageRoot, ".lineage", "asset-lineage.sqlite");
|
|
4541
|
+
return manifest ? `--profile ${shellQuote(manifest)}` : `--db ${shellQuote(database)}`;
|
|
4542
|
+
}
|
|
4543
|
+
function lineageCliCommand(command) {
|
|
4544
|
+
const normalized = command.trim().replace(/\s+--json$/, "");
|
|
4545
|
+
return `${lineageCliLauncher()} ${normalized} ${lineageRuntimeSelector()} --json`;
|
|
4525
4546
|
}
|
|
4526
4547
|
|
|
4527
4548
|
// src/server/assetLineageHandoff.ts
|
|
4528
4549
|
function lineageCommand(command, project, rootAssetId) {
|
|
4529
|
-
return `${
|
|
4550
|
+
return lineageCliCommand(`${command} --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)}`);
|
|
4530
4551
|
}
|
|
4531
4552
|
function linkChildCommand(project, rootAssetId) {
|
|
4532
|
-
return
|
|
4553
|
+
return lineageCliCommand(`link-child --project ${shellQuote(project)} --root ${shellQuote(rootAssetId)} --child <asset-id> --summary "<one-or-two-words>" --confirm-write`);
|
|
4533
4554
|
}
|
|
4534
4555
|
function rerollImportGuidance(rootAssetId, targetAssetId) {
|
|
4535
4556
|
return `Use lineage reroll plan --root ${rootAssetId} --target ${targetAssetId} and lineage reroll import instead.`;
|
|
@@ -4571,7 +4592,7 @@ function getLineageBrief(project, rootAssetId) {
|
|
|
4571
4592
|
},
|
|
4572
4593
|
handoff: {
|
|
4573
4594
|
next_command: lineageCommand("next", project, next.root_asset_id),
|
|
4574
|
-
inspect_command: asset ?
|
|
4595
|
+
inspect_command: asset ? lineageCliCommand(`inspect --project ${shellQuote(project)} --asset-id ${shellQuote(asset.asset_id)}`) : void 0,
|
|
4575
4596
|
link_child_command: asset ? linkChildCommand(project, next.root_asset_id) : void 0
|
|
4576
4597
|
},
|
|
4577
4598
|
fetchedAt: nowIso()
|
|
@@ -5379,13 +5400,13 @@ function laneFor(channel, localAssets2, catalogAssets, limit) {
|
|
|
5379
5400
|
};
|
|
5380
5401
|
}
|
|
5381
5402
|
function handoff(project) {
|
|
5382
|
-
const
|
|
5403
|
+
const quotedProject = shellQuote(project);
|
|
5383
5404
|
return {
|
|
5384
|
-
backupTemplate:
|
|
5385
|
-
lineageNextTemplate:
|
|
5386
|
-
localListCommand:
|
|
5387
|
-
queueCommand:
|
|
5388
|
-
scheduleTemplate:
|
|
5405
|
+
backupTemplate: lineageCliCommand(`local backup --project ${quotedProject} --asset-id <local-id> --dry-run`),
|
|
5406
|
+
lineageNextTemplate: lineageCliCommand(`lineage next --project ${quotedProject} --root <root-id>`),
|
|
5407
|
+
localListCommand: lineageCliCommand(`local list --project ${quotedProject}`),
|
|
5408
|
+
queueCommand: lineageCliCommand(`review queue --project ${quotedProject}`),
|
|
5409
|
+
scheduleTemplate: lineageCliCommand(`placement mark-scheduled --project ${quotedProject} --asset-id <asset-id> --channel <channel> --scheduled-at <iso> --dry-run`)
|
|
5389
5410
|
};
|
|
5390
5411
|
}
|
|
5391
5412
|
function getReviewQueue(project = defaultProject, options = {}) {
|
|
@@ -6197,19 +6218,19 @@ function readinessForPost(post) {
|
|
|
6197
6218
|
return post.assets.length === 0 ? "needs_asset" : "draft_ready";
|
|
6198
6219
|
}
|
|
6199
6220
|
function contentPostHandoff(project, post) {
|
|
6200
|
-
const
|
|
6201
|
-
const postId = post
|
|
6202
|
-
const batchId = post?.batch_id;
|
|
6221
|
+
const quotedProject = shellQuote(project);
|
|
6222
|
+
const postId = post ? shellQuote(post.id) : "<post-id>";
|
|
6223
|
+
const batchId = post?.batch_id ? shellQuote(post.batch_id) : void 0;
|
|
6203
6224
|
return {
|
|
6204
6225
|
agentPrompt: post ? `Continue content iterations for ${post.title} (${post.id}) on ${post.channel}. Inspect the target, generate or choose assets, attach approved candidates, then move the post through review before scheduling.` : "Inspect or set a content target before generating content or asset variations.",
|
|
6205
|
-
attachAssetTemplate:
|
|
6206
|
-
clearTargetCommand:
|
|
6207
|
-
...batchId ? { inspectBatchCommand:
|
|
6208
|
-
inspectTargetCommand:
|
|
6209
|
-
markPostedTemplate:
|
|
6210
|
-
moveToReviewCommand:
|
|
6211
|
-
scheduleTemplate:
|
|
6212
|
-
setTargetTemplate:
|
|
6226
|
+
attachAssetTemplate: lineageCliCommand(`content post attach-asset --project ${quotedProject} --post-id ${postId} --asset-id <asset-id> --role primary --confirm-write`),
|
|
6227
|
+
clearTargetCommand: lineageCliCommand(`content target clear --project ${quotedProject} --confirm-write`),
|
|
6228
|
+
...batchId ? { inspectBatchCommand: lineageCliCommand(`content batch inspect --project ${quotedProject} --batch-id ${batchId}`) } : {},
|
|
6229
|
+
inspectTargetCommand: lineageCliCommand(`content target inspect --project ${quotedProject}`),
|
|
6230
|
+
markPostedTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase posted --posted-at <iso> --url <url> --confirm-write`),
|
|
6231
|
+
moveToReviewCommand: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase review --confirm-write`),
|
|
6232
|
+
scheduleTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id ${postId} --phase scheduled --scheduled-at <iso> --confirm-write`),
|
|
6233
|
+
setTargetTemplate: lineageCliCommand(`content target set --project ${quotedProject} --post-id ${postId} --notes <notes> --confirm-write`)
|
|
6213
6234
|
};
|
|
6214
6235
|
}
|
|
6215
6236
|
|
|
@@ -6309,12 +6330,13 @@ function phaseCounts(posts) {
|
|
|
6309
6330
|
return Object.fromEntries([...phases].map((phase) => [phase, posts.filter((post) => post.phase === phase).length]));
|
|
6310
6331
|
}
|
|
6311
6332
|
function handoff2(project, batchId) {
|
|
6312
|
-
const
|
|
6333
|
+
const quotedProject = shellQuote(project);
|
|
6334
|
+
const quotedBatch = shellQuote(batchId);
|
|
6313
6335
|
return {
|
|
6314
|
-
inspectCommand:
|
|
6315
|
-
createPostTemplate:
|
|
6316
|
-
attachAssetTemplate:
|
|
6317
|
-
phaseTemplate:
|
|
6336
|
+
inspectCommand: lineageCliCommand(`content batch inspect --project ${quotedProject} --batch-id ${quotedBatch}`),
|
|
6337
|
+
createPostTemplate: lineageCliCommand(`content post create --project ${quotedProject} --batch-id ${quotedBatch} --post-id <post-id> --channel <channel> --title <title> --confirm-write`),
|
|
6338
|
+
attachAssetTemplate: lineageCliCommand(`content post attach-asset --project ${quotedProject} --post-id <post-id> --asset-id <asset-id> --role primary --confirm-write`),
|
|
6339
|
+
phaseTemplate: lineageCliCommand(`content post phase --project ${quotedProject} --post-id <post-id> --phase scheduled --scheduled-at <iso> --confirm-write`)
|
|
6318
6340
|
};
|
|
6319
6341
|
}
|
|
6320
6342
|
function listContentBatches(project) {
|
|
@@ -6991,10 +7013,10 @@ function backupCueForPost(project, post, sources) {
|
|
|
6991
7013
|
approved_local: approvedLocal,
|
|
6992
7014
|
label,
|
|
6993
7015
|
local_and_s3: localAndS3,
|
|
6994
|
-
local_backup_command: firstLocalOnly ? `
|
|
7016
|
+
local_backup_command: firstLocalOnly ? lineageCliCommand(`local backup --project ${shellQuote(project)} --asset-id ${shellQuote(firstLocalOnly)} --dry-run`) : void 0,
|
|
6995
7017
|
local_only: localOnly,
|
|
6996
|
-
local_queue_command: firstLocalOnly ? `
|
|
6997
|
-
local_review_command: firstLocalOnly ? `
|
|
7018
|
+
local_queue_command: firstLocalOnly ? lineageCliCommand(`local queue --project ${shellQuote(project)}`) : void 0,
|
|
7019
|
+
local_review_command: firstLocalOnly ? lineageCliCommand(`local review --project ${shellQuote(project)} --asset-id ${shellQuote(firstLocalOnly)} --state approved --dry-run`) : void 0,
|
|
6998
7020
|
needs_review: needsReview,
|
|
6999
7021
|
s3_backed: s3Backed,
|
|
7000
7022
|
unresolved
|
|
@@ -7040,13 +7062,13 @@ function getContentOpsQueue(project) {
|
|
|
7040
7062
|
const nextAction = firstLaneItem(queueLanes, actionableLaneOrder);
|
|
7041
7063
|
const storage = items.reduce((total, item) => addStorage(total, item.asset_storage), emptyStorage());
|
|
7042
7064
|
const laneTotals = Object.fromEntries(queueLanes.map((lane) => [lane.id, lane.total]));
|
|
7043
|
-
const
|
|
7065
|
+
const quotedProject = shellQuote(project);
|
|
7044
7066
|
return {
|
|
7045
7067
|
fetchedAt: nowIso(),
|
|
7046
7068
|
handoff: {
|
|
7047
|
-
inspectQueueCommand:
|
|
7048
|
-
inspectTargetCommand:
|
|
7049
|
-
listPostsCommand:
|
|
7069
|
+
inspectQueueCommand: lineageCliCommand(`content queue inspect --project ${quotedProject}`),
|
|
7070
|
+
inspectTargetCommand: lineageCliCommand(`content target inspect --project ${quotedProject}`),
|
|
7071
|
+
listPostsCommand: lineageCliCommand(`content post list --project ${quotedProject}`)
|
|
7050
7072
|
},
|
|
7051
7073
|
lanes: queueLanes,
|
|
7052
7074
|
next_action: nextAction?.item || null,
|
|
@@ -7377,7 +7399,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
|
|
|
7377
7399
|
if (!parent) throw new GenerationReceiptError("Missing lineage next base");
|
|
7378
7400
|
const parents = parentMappings(next, perBaseCount);
|
|
7379
7401
|
const outputManifest = createGenerationOutputManifestDraft({ id, expected_output_count: count, inputs });
|
|
7380
|
-
const importCommand =
|
|
7402
|
+
const importCommand = lineageCliCommand(`generate image import --project ${quote(project)} --job-id ${quote(id)} --manifest ${quote(".asset-scratch/generation-output-manifest.json")} --confirm-write`);
|
|
7381
7403
|
return {
|
|
7382
7404
|
schema_version: "lineage.generation_handoff.v2",
|
|
7383
7405
|
provider,
|
|
@@ -7414,7 +7436,7 @@ function buildHandoff(project, id, prompt, count, perBaseCount, next, inputs) {
|
|
|
7414
7436
|
};
|
|
7415
7437
|
}
|
|
7416
7438
|
function buildRerollHandoff(project, id, prompt, rootAssetId, target, request) {
|
|
7417
|
-
const importCommand =
|
|
7439
|
+
const importCommand = lineageCliCommand(`reroll import --project ${quote(project)} --job-id ${quote(id)} --file <.asset-scratch-file> --confirm-write`);
|
|
7418
7440
|
return {
|
|
7419
7441
|
schema_version: "lineage.generation_handoff.v1",
|
|
7420
7442
|
provider,
|
|
@@ -8864,7 +8886,6 @@ function registerLineageWorkspaceRoutes(app2, projectFrom2, asyncRoute2) {
|
|
|
8864
8886
|
// src/server/runtimeInfo.ts
|
|
8865
8887
|
import { createHash as createHash6 } from "node:crypto";
|
|
8866
8888
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8867
|
-
import { createRequire as createRequire4 } from "node:module";
|
|
8868
8889
|
import { existsSync as existsSync11, lstatSync as lstatSync3, readFileSync as readFileSync7, readdirSync as readdirSync4, readlinkSync, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
|
|
8869
8890
|
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join12, resolve as resolve6 } from "node:path";
|
|
8870
8891
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -8874,7 +8895,6 @@ var lineageRuntimeBuildSchemaVersion = "lineage.runtime_build.v1";
|
|
|
8874
8895
|
var lineageRuntimeInstallSchemaVersion = "lineage.runtime_install.v1";
|
|
8875
8896
|
|
|
8876
8897
|
// src/server/runtimeInfo.ts
|
|
8877
|
-
var require5 = createRequire4(import.meta.url);
|
|
8878
8898
|
var processStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8879
8899
|
function isLineagePackageRoot(root) {
|
|
8880
8900
|
try {
|
|
@@ -9138,7 +9158,7 @@ function getLineageRuntimeInfo(options = {}) {
|
|
|
9138
9158
|
const stat = statSync5(dbPath);
|
|
9139
9159
|
databaseInfo.modified_at = stat.mtime.toISOString();
|
|
9140
9160
|
databaseInfo.size_bytes = stat.size;
|
|
9141
|
-
const { DatabaseSync } =
|
|
9161
|
+
const { DatabaseSync } = loadNodeSqlite();
|
|
9142
9162
|
const database = new DatabaseSync(dbPath, { readOnly: true });
|
|
9143
9163
|
try {
|
|
9144
9164
|
databaseInfo.projects = tableCount(database, "projects");
|
|
@@ -9164,6 +9184,10 @@ function getLineageRuntimeInfo(options = {}) {
|
|
|
9164
9184
|
return {
|
|
9165
9185
|
asset_root: repoRoot,
|
|
9166
9186
|
channel,
|
|
9187
|
+
cli: {
|
|
9188
|
+
launcher: lineageCliLauncher(channel),
|
|
9189
|
+
runtime_selector: lineageRuntimeSelector(dbPath)
|
|
9190
|
+
},
|
|
9167
9191
|
code,
|
|
9168
9192
|
database: databaseInfo,
|
|
9169
9193
|
fetchedAt: nowIso(),
|