Files
spark-control/package/startos/actions/showPublicKey.ts
T
Grant 0ddab99468 Bump to 0.1.0:1 — portability + endpoint display
- configureSparks.ts: generic placeholders (e.g. 192.168.1.10), no Alice-specific IPs; descriptions explain the role of each node instead of naming his hardware
- showPublicKey.ts: reads sparkConfig.yaml; emits a ready-to-paste one-liner (KEY='...' followed by 'ssh user@host "echo $KEY >> authorized_keys"' for each configured Spark). Falls back to generic instructions if Configure Sparks hasn't been run yet.
- /api/status now includes vllm.base_url for the OpenAI endpoint
- New endpoint panel in UI: base URL + model ID rows with copy buttons + collapsible curl example
- Bump version to 0.1.0:1
2026-05-12 10:38:18 -05:00

82 lines
2.9 KiB
TypeScript

import { sdk } from '../sdk'
import { promises as fs } from 'fs'
import * as path from 'path'
import { sparkConfigYaml } from '../fileModels/sparkConfig.yaml'
export const showPublicKey = sdk.Action.withoutInput(
'show-public-key',
async () => ({
name: 'Show Public Key',
description:
'Display the SSH public key and a ready-to-paste install command for granting this package SSH access to your Sparks.',
warning: null,
visibility: 'enabled',
allowedStatuses: 'any',
group: null,
}),
async ({ effects }) => {
// The container generates the key under /data/ssh/id_ed25519.pub on first boot.
const pubKeyPath = path.join(
sdk.volumes.main.path,
'ssh',
'id_ed25519.pub',
)
let key: string
try {
key = (await fs.readFile(pubKeyPath, 'utf8')).trim()
} catch (e) {
return {
version: '1' as const,
title: 'Public Key Not Ready',
message:
'The service has not generated its SSH keypair yet. Start the service from the dashboard, wait a few seconds, then run this action again.',
result: null,
}
}
// If hosts are configured, construct a ready-to-paste one-liner.
const cfg = await sparkConfigYaml.read().once()
const hosts: Array<{ user: string; host: string }> = []
if (cfg) {
if (cfg.spark1_host) hosts.push({ user: cfg.spark1_user || '<spark-user>', host: cfg.spark1_host })
if (cfg.spark2_host) hosts.push({ user: cfg.spark2_user || '<spark-user>', host: cfg.spark2_host })
}
let message: string
if (hosts.length > 0) {
const sshLines = hosts
.map(
(h) =>
`ssh ${h.user}@${h.host} "mkdir -p ~/.ssh && echo '$KEY' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"`,
)
.join('\n')
const oneLiner = `KEY='${key}'\n${sshLines}`
message =
'Paste this block into any machine that already has SSH access to your Sparks (your laptop or one of the Sparks itself). It grants this Spark Control service permission to log in.\n\n' +
oneLiner +
'\n\nYou will be prompted for the SSH password of each Spark once. After both commands succeed, run "Test Connection" or open the Web Interface to verify.'
} else {
message =
'Run the "Configure Sparks" action first, then come back to this one — once your Spark hostnames are saved, this message will include a ready-to-paste install command.\n\nFor reference, the raw public key is:\n\n' +
key
}
return {
version: '1' as const,
title: 'SSH Public Key',
message,
result: {
type: 'single' as const,
name: 'Raw Public Key',
description:
'The bare public key line. Copy the full message above for the ready-to-paste install command.',
value: key,
masked: false,
copyable: true,
qr: false,
},
}
},
)