openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.79 kB
JavaScript
import{D as parseStrictPositiveInteger}from"./number-coercion-B3CfI447.mjs";import{r as truncateUtf16Safe}from"./utf16-slice-DA3Mllbx.mjs";import"./text-utility-runtime-CDtGqkrl.mjs";import"./number-runtime-G0nhUVZu.mjs";
//!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))})}export{registerOnePasswordCommands};