Skip to content

Commit ec9ee1f

Browse files
committed
bump 0.9.7: named register export, Commander CLI, proRun, drop direct jacs dep
1 parent 0d33387 commit ec9ee1f

9 files changed

Lines changed: 69 additions & 26 deletions

File tree

marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"jacs_hai_reply",
8787
"jacs_hai_get_email_status",
8888
"jacs_hai_free_chaotic_run",
89-
"jacs_hai_dns_certified_run",
89+
"jacs_hai_pro_run",
9090
"jacs_hai_submit_response",
9191
"jacs_hai_benchmark_run",
9292
"jacs_audit",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "moltyjacs",
3-
"version": "0.9.6",
3+
"version": "0.9.7",
44
"description": "JACS cryptographic provenance plugin for OpenClaw - signing, verification, commitments, todos, agent state, and conversations",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface OpenClawPluginAPI {
7878
fs: typeof fs;
7979
jacs?: JACSRuntime;
8080
};
81-
registerCli: (opts: any) => void;
81+
registerCli: (registrar: any, opts?: any) => void;
8282
registerCommand: (opts: any) => void;
8383
registerTool: (opts: any, options?: { optional?: boolean }) => void;
8484
registerGatewayMethod?: (opts: any) => void;
@@ -107,7 +107,7 @@ let haiClientPromise: Promise<HaiClient | null> | null = null;
107107
/**
108108
* Main plugin registration function called by OpenClaw
109109
*/
110-
export default function register(api: OpenClawPluginAPI): void {
110+
export function register(api: OpenClawPluginAPI): void {
111111
const config = api.config;
112112
const logger = api.logger;
113113

@@ -168,19 +168,60 @@ export default function register(api: OpenClawPluginAPI): void {
168168
logger.info("JACS not configured - run 'openclaw haiai init' to set up");
169169
}
170170

171-
// Register CLI commands
172-
api.registerCli({
173-
name: "haiai",
174-
description: "HAI.AI cryptographic provenance commands",
175-
subcommands: cliCommands(api),
176-
});
171+
// Register CLI commands (Commander.js-style registrar)
172+
const commands = cliCommands(api);
173+
const initHandler = setupCommand(api);
177174

178-
// Register setup/init command
179-
api.registerCommand({
180-
name: "haiai-init",
181-
description: "Initialize JACS with key generation and agent creation",
182-
handler: setupCommand(api),
183-
});
175+
if (api.registerCli) {
176+
api.registerCli((program: any) => {
177+
const haiai = program.command("haiai").description("HAI.AI cryptographic provenance commands");
178+
179+
// Register init subcommand
180+
const initCmd = haiai.command("init").description(
181+
"Initialize JACS with key generation"
182+
);
183+
initCmd.option("--algorithm <algo>", "Key algorithm");
184+
initCmd.option("--name <name>", "Agent name");
185+
initCmd.option("--description <description>", "Agent description");
186+
initCmd.option("--domain <domain>", "Agent domain");
187+
initCmd.option("--password-file <path>", "Password file path");
188+
initCmd.action(async (opts: any) => {
189+
const result = await initHandler(opts);
190+
if (result.text) console.log(result.text);
191+
});
192+
193+
// Register all other subcommands from cliCommands
194+
for (const [name, cmd] of Object.entries(commands)) {
195+
const sub = haiai.command(name).description(cmd.description);
196+
if (cmd.args) {
197+
for (const arg of cmd.args) {
198+
if (arg.startsWith("[--") || arg.startsWith("--")) {
199+
const match = arg.match(/--(\S+)\s*(?:<(\S+)>)?/);
200+
if (match) sub.option(`--${match[1]}${match[2] ? ` <${match[2]}>` : ""}`, "");
201+
} else {
202+
sub.argument(arg, "");
203+
}
204+
}
205+
}
206+
sub.action(async (...actionArgs: any[]) => {
207+
// Commander passes positional args then opts then command
208+
const opts = actionArgs.length > 1 ? actionArgs[actionArgs.length - 2] : {};
209+
const positional = actionArgs.length > 2 ? actionArgs.slice(0, -2) : [];
210+
// Map positional args to named params based on arg definitions
211+
const args: any = { ...opts, _: positional };
212+
if (cmd.args) {
213+
const positionalDefs = cmd.args.filter(a => !a.startsWith("-"));
214+
positionalDefs.forEach((def, i) => {
215+
const paramName = def.replace(/[<>\[\]]/g, "");
216+
if (positional[i] !== undefined) args[paramName] = positional[i];
217+
});
218+
}
219+
const result = await cmd.handler(args);
220+
if (result.text) console.log(result.text);
221+
});
222+
}
223+
}, { commands: ["haiai"] });
224+
}
184225

185226
// Register agent tools for AI use
186227
registerTools(api);
@@ -241,6 +282,8 @@ export function setAgentInstance(agent: JacsAgent, agentId: string, publicKey: s
241282
isInitialized = true;
242283
}
243284

285+
export default register;
286+
244287
export { setupCommand } from "./setup";
245288
export { cliCommands } from "./cli";
246289
export { registerTools } from "./tools";

src/tools/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,9 +2713,9 @@ export function registerTools(api: OpenClawPluginAPI): void {
27132713

27142714
// Tool: DNS-certified benchmark
27152715
registerOpenClawTool(api, {
2716-
name: "jacs_hai_dns_certified_run",
2716+
name: "jacs_hai_pro_run",
27172717
description:
2718-
"Start and run the HAI DNS-certified benchmark tier. Returns checkout URL when payment is pending.",
2718+
"Start and run the HAI pro benchmark tier. Returns checkout URL when payment is pending.",
27192719
parameters: {
27202720
type: "object",
27212721
properties: {
@@ -2737,7 +2737,7 @@ export function registerTools(api: OpenClawPluginAPI): void {
27372737
handler: async (params: HaiDnsCertifiedRunParams): Promise<ToolResult> => {
27382738
let checkoutUrl: string | undefined;
27392739
const result = await withHaiClient((haiClient) =>
2740-
haiClient.dnsCertifiedRun({
2740+
haiClient.proRun({
27412741
transport: params.transport,
27422742
pollIntervalMs: params.pollIntervalMs,
27432743
pollTimeoutMs: params.pollTimeoutMs,

src/tools/openclaw.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const OPTIONAL_SIDE_EFFECT_TOOLS = new Set<string>([
2626
"jacs_hai_delete_message",
2727
"jacs_hai_reply",
2828
"jacs_hai_free_chaotic_run",
29-
"jacs_hai_dns_certified_run",
29+
"jacs_hai_pro_run",
3030
"jacs_hai_submit_response",
3131
"jacs_hai_benchmark_run",
3232
"jacs_create_agentstate",

test/__mocks__/haiai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ export class HaiClient {
651651
};
652652
}
653653

654-
async dnsCertifiedRun(options?: {
654+
async proRun(options?: {
655655
transport?: "sse" | "ws";
656656
pollIntervalMs?: number;
657657
pollTimeoutMs?: number;

test/hai.api.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ describe("HaiClient integration via tools", () => {
107107
expect(result.result.status).toBe("queued");
108108
});
109109

110-
it("jacs_hai_dns_certified_run exposes checkout URL", async () => {
111-
const result = await invokeTool(api, "jacs_hai_dns_certified_run", {});
110+
it("jacs_hai_pro_run exposes checkout URL", async () => {
111+
const result = await invokeTool(api, "jacs_hai_pro_run", {});
112112
expect(result.error).toBeUndefined();
113113
expect(result.result.checkoutUrl).toContain("checkout.hai.ai");
114114
});

test/tools.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ describe("Document Tool Handlers", () => {
668668
"jacs_hai_get_email_status",
669669
"jacs_hai_forward_email", "jacs_hai_archive_message", "jacs_hai_unarchive_message",
670670
"jacs_hai_get_contacts", "jacs_hai_lookup_key_by_email", "jacs_onboard_status",
671-
"jacs_hai_free_chaotic_run", "jacs_hai_dns_certified_run",
671+
"jacs_hai_free_chaotic_run", "jacs_hai_pro_run",
672672
"jacs_hai_submit_response", "jacs_hai_benchmark_run",
673673
"jacs_audit",
674674
"jacs_create_agentstate", "jacs_sign_file_as_state", "jacs_verify_agentstate",

0 commit comments

Comments
 (0)