UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

52 lines (51 loc) • 2.05 kB
import { D as parseStrictPositiveInteger } from "./number-coercion-D6u-4YD8.mjs"; import { r as truncateUtf16Safe } from "./utf16-slice-CuDyEXgS.mjs"; import "./text-utility-runtime-Ds8jsG0J.mjs"; import "./number-runtime-W4chuk8B.mjs"; //#region extensions/onepassword/src/cli.ts function parseLimit(e) { if (e === void 0) return 50; const t = parseStrictPositiveInteger(e); if (t === void 0 || t > 1e3) throw new Error("--limit must be an integer from 1 to 1000"); return t; } function truncateReason(e) { return e.length <= 80 ? e : `${truncateUtf16Safe(e, 77)}...`; } async function readAuditRows(e, t) { return (await e.entries()).toSorted((e, t) => t.value.timestampMs - e.value.timestampMs || t.key.localeCompare(e.key)).slice(0, t).map(({ value: e }) => Object.assign({ timestamp: new Date(e.timestampMs).toISOString(), agent: e.agentId, slug: e.slug, outcome: e.outcome, reason: truncateReason(e.reason) }, e.errorCode ? { errorCode: e.errorCode } : {})); } function registerOnePasswordCommands(e) { const write = (e) => process.stdout.write(`${e}\n`); const t = e.program.command("onepassword").description("Inspect the 1Password broker"); e.registerAdditionalCommands?.(t); t.command("status").description("Show broker readiness without secret values").action(async () => { const t = e.resolveConfig(); const n = e.resolveOpClient(); const r = { auto: 0, approve: 0, deny: 0 }; for (const e of Object.values(t?.items ?? {})) r[e.policy] += 1; const i = { tokenFilePresent: await n.tokenFilePresent(), opBinaryResolved: Boolean(n.opBin), opBinaryPath: n.opBin ?? null, itemCount: Object.keys(t?.items ?? {}).length, policyCounts: r }; write(JSON.stringify(i, null, 2)); }); t.command("audit").description("Show recent 1Password access audit rows").option("--limit <number>", "Maximum rows to print", "50").action(async (t) => { write(JSON.stringify(await readAuditRows(e.auditStore, parseLimit(t.limit)), null, 2)); }); } //#endregion export { registerOnePasswordCommands };