Restore agentctl runtime compatibility across Node and Bare.

Add a runtime helper and gate module loading so preflight/doctor/ping run in Node without pulling Bare-only modules, while preserving Bare paths for headless flows and worker-attached startup.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-02 10:56:39 -04:00
co-authored by Cursor
parent aeb1841871
commit 1a40cd8b88
5 changed files with 39 additions and 16 deletions
+23 -11
View File
@@ -1,15 +1,20 @@
#!/usr/bin/env bare
'use strict'
const fs = require('bare-fs')
const path = require('bare-path')
const {
AgentClient,
HeadlessSession,
PearcordMeshCluster,
resolveAgentctlAddress,
resolveLogPath
} = require('..')
const { isBareRuntime } = require('../runtime')
const fs = isBareRuntime() ? require('bare-fs') : require('fs')
const path = isBareRuntime() ? require('bare-path') : require('path')
const { resolveAgentctlAddress, resolveLogPath } = require('../resolve')
function loadRuntimeClientApi () {
const { AgentClient } = require('../client')
return { AgentClient }
}
function loadRuntimeHeadlessApi () {
const { HeadlessSession, PearcordMeshCluster } = require('..')
return { HeadlessSession, PearcordMeshCluster }
}
function usage () {
console.log(`pearcord-agentctl — control a running Pearcord worker or run headless IPC
@@ -71,6 +76,7 @@ function parseArgs (argv) {
}
function clientFromArgs (args) {
const { AgentClient } = loadRuntimeClientApi()
const def = resolveAgentctlAddress()
return new AgentClient({
host: args.host || def.host,
@@ -250,6 +256,7 @@ async function main () {
}
if (cmd === 'headless') {
const { HeadlessSession, PearcordMeshCluster } = loadRuntimeHeadlessApi()
const sub = args._[1]
if (sub === 'mesh') {
const meshSub = args._[2]
@@ -290,6 +297,7 @@ async function main () {
}
if (cmd === 'mesh') {
const { PearcordMeshCluster } = loadRuntimeHeadlessApi()
const meshSub = args._[1]
if (meshSub !== 'run') throw new Error('use: mesh run <scenario.json>')
const file = args._[2]
@@ -387,11 +395,15 @@ async function main () {
}
main().catch((err) => {
const args = parseArgs(process.argv)
const argv = typeof process !== 'undefined' && Array.isArray(process.argv)
? process.argv
: ['agentctl']
const args = parseArgs(argv)
const def = resolveAgentctlAddress()
printCliError(err, {
host: args.host || def.host,
port: args.port || def.port
})
process.exit(1)
if (typeof process !== 'undefined' && typeof process.exit === 'function') process.exit(1)
throw err
})