- Add SSO QR status poller and assist platform HTTP client - Add assist-platform session store with 0600 secure permissions - Implement domains/assist-platform (api, services, types) for corporation search, detail, tickets, staff query and passwordless token generation - Implement cli/commands/assist-platform with aliases assist-center and ap - Support seamless --save --switch --elevate pipeline to import tenant and extract persistent OpenAPI credentials - Update embedded skill documentation, reference guide, and test suites
225 lines
7.2 KiB
TypeScript
225 lines
7.2 KiB
TypeScript
import { handleAuthCommand } from "./commands/auth.js";
|
|
import { handleCorpsCommand } from "./commands/corps/index.js";
|
|
import { handleConfigCommand } from "./commands/config.js";
|
|
import { handleWorkflowCommand } from "./commands/workflow/index.js";
|
|
import { handlePlatformCommand } from "./commands/platform/index.js";
|
|
import { handleAppCommand } from "./commands/app.js";
|
|
import { handleMenuCommand } from "./commands/menu.js";
|
|
import { handleSkillCommand } from "./commands/skill.js";
|
|
import { handleProbeCommand } from "./commands/probe.js";
|
|
import { handleMcpCommand } from "./commands/mcp.js";
|
|
import { handleUpdateCommand } from "./commands/update/index.js";
|
|
import { handleOpenApiCommand } from "./commands/openapi.js";
|
|
import { handleBillCommand } from "./commands/bill/index.js";
|
|
import { handleFlowCommand } from "./commands/flow.js";
|
|
import { handleContactCommand } from "./commands/contact.js";
|
|
import { handleServiceCommand } from "./commands/service.js";
|
|
import { handleHttpCommand } from "./commands/http.js";
|
|
import { handleTaskCommand } from "./commands/task.js";
|
|
import { handleMessageCommand } from "./commands/message.js";
|
|
import { handleDimensionCommand } from "./commands/dimension.js";
|
|
import { handleRoleCommand } from "./commands/role.js";
|
|
import { handlePermissionCommand } from "./commands/permission.js";
|
|
import { handleRuleCommand } from "./commands/rule.js";
|
|
import { handleApprovalCommand } from "./commands/approval.js";
|
|
import { handleContextCommand } from "./commands/context.js";
|
|
import { handleKeysCommand } from "./commands/keys.js";
|
|
import { handleStoreCommand } from "./commands/store.js";
|
|
import { handleFeeTypeCommand } from "./commands/feetype.js";
|
|
import { handleAssistPlatformCommand } from "./commands/assist-platform/index.js";
|
|
import { COMMAND_METADATA, type CliCommandMetadata } from "./command-metadata.js";
|
|
import type { CliParsedArgs, CliResult, CliRunOptions, CliRuntime } from "./types.js";
|
|
|
|
export type CliCommandHandler = (
|
|
parsed: CliParsedArgs,
|
|
runtime: CliRuntime,
|
|
options: CliRunOptions
|
|
) => Promise<CliResult>;
|
|
|
|
export interface CliCommandDefinition extends CliCommandMetadata {
|
|
area: string;
|
|
standing?: boolean | ((args: string[]) => boolean);
|
|
handler: CliCommandHandler;
|
|
}
|
|
|
|
export const CLI_COMMAND_REGISTRY: readonly CliCommandDefinition[] = [
|
|
{
|
|
area: "context",
|
|
...COMMAND_METADATA.context,
|
|
handler: (parsed, runtime) => handleContextCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "aipro",
|
|
...COMMAND_METADATA.aipro,
|
|
handler: async (parsed) => {
|
|
const { runAiProCli } = await import("../aipro-cli.js");
|
|
const aiproIdx = parsed.raw.findIndex((a) => a.toLowerCase() === "aipro");
|
|
const subArgs = aiproIdx !== -1 ? parsed.raw.slice(aiproIdx + 1) : parsed.raw.slice(1);
|
|
return runAiProCli(subArgs);
|
|
},
|
|
},
|
|
{
|
|
area: "auth",
|
|
...COMMAND_METADATA.auth,
|
|
handler: (parsed, runtime) => handleAuthCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "corps",
|
|
...COMMAND_METADATA.corps,
|
|
handler: (parsed, runtime) => handleCorpsCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "config",
|
|
...COMMAND_METADATA.config,
|
|
handler: (parsed, runtime) => handleConfigCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "workflow",
|
|
...COMMAND_METADATA.workflow,
|
|
handler: (parsed, runtime) => handleWorkflowCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "bill",
|
|
...COMMAND_METADATA.bill,
|
|
handler: (parsed, runtime) => handleBillCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "flow",
|
|
...COMMAND_METADATA.flow,
|
|
handler: (parsed, runtime) => handleFlowCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "contact",
|
|
...COMMAND_METADATA.contact,
|
|
handler: (parsed, runtime) => handleContactCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "task",
|
|
...COMMAND_METADATA.task,
|
|
handler: (parsed, runtime) => handleTaskCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "dimension",
|
|
...COMMAND_METADATA.dimension,
|
|
handler: (parsed, runtime) => handleDimensionCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "feetype",
|
|
...COMMAND_METADATA.feetype,
|
|
handler: (parsed, runtime) => handleFeeTypeCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "role",
|
|
...COMMAND_METADATA.role,
|
|
handler: (parsed, runtime) => handleRoleCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "permission",
|
|
...COMMAND_METADATA.permission,
|
|
handler: (parsed, runtime) => handlePermissionCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "rule",
|
|
...COMMAND_METADATA.rule,
|
|
handler: (parsed, runtime) => handleRuleCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "approval",
|
|
...COMMAND_METADATA.approval,
|
|
handler: (parsed, runtime) => handleApprovalCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "message",
|
|
...COMMAND_METADATA.message,
|
|
handler: (parsed, runtime) => handleMessageCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "platform",
|
|
...COMMAND_METADATA.platform,
|
|
handler: (parsed, runtime) => handlePlatformCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "app",
|
|
...COMMAND_METADATA.app,
|
|
handler: (parsed, runtime) => handleAppCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "menu",
|
|
...COMMAND_METADATA.menu,
|
|
handler: (parsed, runtime) => handleMenuCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "skill",
|
|
...COMMAND_METADATA.skill,
|
|
handler: (parsed, runtime) => handleSkillCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "probe",
|
|
...COMMAND_METADATA.probe,
|
|
handler: (parsed, runtime) => handleProbeCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "update",
|
|
...COMMAND_METADATA.update,
|
|
handler: (parsed, runtime, options) => handleUpdateCommand(parsed, runtime, options),
|
|
},
|
|
{
|
|
area: "openapi",
|
|
...COMMAND_METADATA.openapi,
|
|
handler: (parsed, runtime) => handleOpenApiCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "keys",
|
|
...COMMAND_METADATA.keys,
|
|
handler: (parsed, runtime) => handleKeysCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "store",
|
|
...COMMAND_METADATA.store,
|
|
handler: (parsed, runtime) => handleStoreCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "http",
|
|
...COMMAND_METADATA.http,
|
|
standing: true,
|
|
handler: (parsed, runtime) => handleHttpCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "service",
|
|
...COMMAND_METADATA.service,
|
|
standing: (args) => args[1]?.toLowerCase() === "run",
|
|
handler: (parsed, runtime) => handleServiceCommand(parsed, runtime),
|
|
},
|
|
{
|
|
area: "mcp",
|
|
...COMMAND_METADATA.mcp,
|
|
standing: true,
|
|
handler: (parsed, _runtime, options) => handleMcpCommand(parsed, options),
|
|
},
|
|
{
|
|
area: "assist-platform",
|
|
...COMMAND_METADATA["assist-platform"],
|
|
handler: (parsed, runtime) => handleAssistPlatformCommand(parsed, runtime),
|
|
},
|
|
];
|
|
|
|
const COMMAND_LOOKUP = new Map<string, CliCommandDefinition>();
|
|
for (const def of CLI_COMMAND_REGISTRY) {
|
|
COMMAND_LOOKUP.set(def.area.toLowerCase(), def);
|
|
for (const alias of def.aliases) {
|
|
COMMAND_LOOKUP.set(alias.toLowerCase(), def);
|
|
}
|
|
}
|
|
|
|
export function findCommandByArea(area?: string): CliCommandDefinition | undefined {
|
|
if (!area) return undefined;
|
|
return COMMAND_LOOKUP.get(area.toLowerCase());
|
|
}
|
|
|
|
export function isStandingCommand(args: string[]): boolean {
|
|
if (!args.length) return false;
|
|
const def = findCommandByArea(args[0]);
|
|
if (!def?.standing) return false;
|
|
return typeof def.standing === "function" ? def.standing(args) : def.standing;
|
|
}
|