// linkagent SDK — run on any honeycomb machine. import { la } from './linkagent.mjs'; await la.sh('pro','uname -a') import fs from 'node:fs'; import os from 'node:os'; export class LinkAgent { constructor(url, key) { this.url = url || process.env.LA_URL || 'https://linkagent.marcusx.fun'; try { this.key = key || process.env.LA_KEY || fs.readFileSync(os.homedir() + '/.config/linkagent.key', 'utf8').trim() } catch { this.key = key || '' } } async post(p, b) { const r = await fetch(this.url + p, { method: 'POST', headers: { 'content-type': 'application/json', 'x-key': this.key }, body: JSON.stringify(b) }); return r.json() } machines() { return fetch(this.url + '/machines').then(r => r.json()) } run(machine, code) { return this.post('/run', { machine, code }) } async sh(machine, code) { return (await this.run(machine, code)).output } async link(machine, code) { return (await this.post('/link', { machine, code })).url } async tool(name, args = {}) { const r = await this.post('/mcp', { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args } }); return r.result.content[0].text } keyRun(machine, name, ...args) { return this.tool('key_run', { machine, name, args }) } mintKey(name, template, description = '') { return this.tool('mint_key', { name, template, description }) } } export const la = new LinkAgent();