Bridge server lifecycle:
- Move createBridgeServer() out of register() into an api.on("gateway_start", ...)
handler. register() runs in every CLI subprocess that loads plugins
(e.g. `openclaw completion`, `openclaw doctor`); eagerly binding the
bridge HTTP listener there could pin those processes when no gateway
is already holding the port.
- Call server.unref() so the listener never pins the host's event loop,
even if startup somehow runs outside the gateway.
Plugin SDK convention update:
- Wrap default export with definePluginEntry({ id, name, description, register })
per the current openclaw plugin authoring contract.
- Switch imports from the deprecated root barrel "openclaw/plugin-sdk" to
focused "openclaw/plugin-sdk/core" / "openclaw/plugin-sdk/plugin-entry".
- Modernize openclaw.plugin.json: drop version/main, add activation.onStartup
so gateway_start fires for this plugin at boot, declare commandAliases
for the contractor-agents CLI command.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
import { runContractorAgentsAdd } from "./contractor-agents-add.js";
|
|
|
|
export function registerCli(api: OpenClawPluginApi): void {
|
|
api.registerCli(
|
|
(ctx) => {
|
|
// Use ctx.program.command() directly — do NOT import Commander separately.
|
|
// Importing a different Commander version causes _prepareForParse failures.
|
|
const contractorAgents = ctx.program.command("contractor-agents")
|
|
.description("Manage Claude-backed contractor agents");
|
|
|
|
contractorAgents
|
|
.command("add")
|
|
.description("Provision a new Claude-backed contractor agent")
|
|
.requiredOption("--agent-id <id>", "Agent id")
|
|
.requiredOption("--workspace <path>", "Workspace directory")
|
|
.requiredOption("--contractor <kind>", "Contractor kind (claude)")
|
|
.action(async (opts: { agentId: string; workspace: string; contractor: string }) => {
|
|
try {
|
|
await runContractorAgentsAdd({
|
|
agentId: opts.agentId,
|
|
workspace: opts.workspace,
|
|
contractor: opts.contractor,
|
|
});
|
|
} catch (err) {
|
|
console.error(`[contractor-agents add] Error: ${String(err)}`);
|
|
process.exitCode = 1;
|
|
}
|
|
});
|
|
|
|
contractorAgents
|
|
.command("status")
|
|
.description("Show status of a contractor agent (not yet implemented)")
|
|
.requiredOption("--agent-id <id>", "Agent id")
|
|
.action(() => {
|
|
console.log("[contractor-agents status] not yet implemented");
|
|
});
|
|
},
|
|
{
|
|
commands: ["contractor-agents"],
|
|
descriptors: [
|
|
{
|
|
name: "contractor-agents",
|
|
description: "Manage Claude-backed contractor agents",
|
|
hasSubcommands: true,
|
|
},
|
|
],
|
|
},
|
|
);
|
|
}
|