headscale leaves the platform. 45 files move to plugins/offscale/ and the
platform stops knowing it exists.
api/router.ts the thin auth-gated proxy, now at /api/offscale
sidecar/ 18 files, the whole headscale contract and its admin keys
db/ schema + queries, offscale_servers
web/ 26 files as panels and a layout — no screen, per the rule
removed from the platform: the hono mount, the `headscale` capability, the
App.tsx route pair, the screen and its barrel, the AppRegistry spread, the
officerdev re-exports, the dock tile, the page-title rule, and both database
barrels. tsgo is clean and nothing references it.
the imports tell the story of what the plugin↔host API actually is. the sidecar
takes @@/sidecar/protocol, @@/sidecar/connect, @@/data-path and
@@/officer-url.mjs; the queries take officerdb/db and officerdb/crypto; the
schema takes officerdb/auth/schema for the one reference a plugin may make; the
web half takes useClient, copyToClipboard, WorkspaceView and TerminalView from
the officerdev barrel. all of it resolves because a plugin lives inside the repo
— no publishing, no version negotiation.
AND IT FOUND A REAL BUG IN THE INSTALLER. createSidecarProxy learns its port
from a one-shot `<name>:server` event and subscribes when the plugin's router is
first imported — at mount. install started the sidecar BEFORE mounting, so the
announcement fired into a void: process online, routes mounted, every request
answering `503 sidecar not available` until something forced a reconnect. it
would have hit every plugin with an http sidecar. `example` never caught it
because it has no listener to announce.
install and enable now mount before starting; disable still unmounts before
stopping. neither direction leaves a mounted route in front of a sidecar that
cannot be reached.
verified live: /api/offscale/_officer/servers answers {"servers":[]}, /offscale
and /offscale/nodes serve, the old /api/headscale is 404, the offscale
capability is registered from the manifest, and officer-offscale is online.
757 pass, same 10 pre-existing failures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
/**
|
|
* Structured logging utility for Pi harness
|
|
*/
|
|
|
|
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
|
|
type LogContext = {
|
|
sessionId?: string;
|
|
email?: string;
|
|
model?: string;
|
|
requestId?: string;
|
|
[key: string]: unknown;
|
|
};
|
|
|
|
const LOG_COLORS = {
|
|
DEBUG: '\x1b[36m', // Cyan
|
|
INFO: '\x1b[32m', // Green
|
|
WARN: '\x1b[33m', // Yellow
|
|
ERROR: '\x1b[31m', // Red
|
|
RESET: '\x1b[0m',
|
|
};
|
|
|
|
function formatTimestamp(): string {
|
|
return new Date().toISOString();
|
|
}
|
|
|
|
function formatContext(context?: LogContext): string {
|
|
if (!context || Object.keys(context).length === 0) return '';
|
|
|
|
const lines = Object.entries(context)
|
|
.map(([key, value]) => ` ${key}=${value}`)
|
|
.join('\n');
|
|
|
|
return '\n' + lines;
|
|
}
|
|
|
|
function log(level: LogLevel, message: string, context?: LogContext) {
|
|
const timestamp = formatTimestamp();
|
|
const color = LOG_COLORS[level];
|
|
const reset = LOG_COLORS.RESET;
|
|
const contextStr = formatContext(context);
|
|
|
|
console.log(`${color}[${timestamp}] [Pi] [${level}]${reset} ${message}${contextStr}`);
|
|
}
|
|
|
|
export const logger = {
|
|
debug(message: string, context?: LogContext) {
|
|
log('DEBUG', message, context);
|
|
},
|
|
|
|
info(message: string, context?: LogContext) {
|
|
log('INFO', message, context);
|
|
},
|
|
|
|
warn(message: string, context?: LogContext) {
|
|
log('WARN', message, context);
|
|
},
|
|
|
|
error(message: string, context?: LogContext) {
|
|
log('ERROR', message, context);
|
|
},
|
|
};
|