UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 9.52 kB
import{D as parseStrictPositiveInteger,E as parseStrictNonNegativeInteger}from"./number-coercion-B3CfI447.mjs";import{r as theme}from"./theme-DS2CtI9X.mjs";import{t as formatDocsLink}from"./links-C_FK9uVv.mjs";import{t as runWithLocalStateOwner}from"./local-state-owner-fjzTarAw.mjs";import"./number-runtime-G0nhUVZu.mjs";import{n as formatHelpExamples}from"./help-format-DLfgiheF.mjs";import"./cli-state-owner-DaSXYnIM.mjs";import"./memory-core-host-runtime-cli-0DNFBqTu.mjs";import{f as configureMemoryCoreDreamingState}from"./dreaming-state-CWg6oPZQ.mjs";import{n as DEFAULT_PROMOTION_MIN_SCORE,r as DEFAULT_PROMOTION_MIN_UNIQUE_QUERIES,t as DEFAULT_PROMOTION_MIN_RECALL_COUNT}from"./short-term-promotion-types-BuMo0TR1.mjs"; //!extensions/memory-core/src/cli.ts const DECIMAL_NUMBER_RE=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/;const DEFAULT_SESSION_BACKFILL_LIMIT_DAYS=92;function memoryCliNumberOption(e,t){return n=>{const r=t===`positive integer`?parseStrictPositiveInteger(n):t===`non-negative integer`?parseStrictNonNegativeInteger(n):DECIMAL_NUMBER_RE.test(n.trim())?Number(n.trim()):void 0;if(r===void 0||!Number.isFinite(r))throw Object.assign(/* @__PURE__ */ new Error(`${e} must be a ${t}.`),{name:`InvalidArgumentError`,code:`commander.invalidArgument`,exitCode:1});return r}}function collectMemoryCliValues(e,t){return[...t,e]}function runMemoryCliCommand(e){return runWithLocalStateOwner({method:`memory.cli`,params:{},target:`memory stores`,databaseEngine:`configured`,onForeignOwner:`refuse`,runLocal:e})}function registerMemoryCli(e,t){if(t?.openKeyedStore)configureMemoryCoreDreamingState(t.openKeyedStore);const lazyAction=e=>async n=>{await runMemoryCliCommand(async()=>{await(await import(`./cli.runtime-Of87jA9X.mjs`))[e](n,t)})};const n=e.command(`memory`).description(`Search, inspect, and reindex memory files`).addHelpText(`after`,()=>`\n${theme.heading(`Examples:`)}\n${formatHelpExamples([[`openclaw memory status`,`Show index and provider status.`],[`openclaw memory status --fix`,`Repair stale recall locks and normalize promotion metadata.`],[`openclaw memory status --deep`,`Check embedding provider readiness.`],[`openclaw memory index --force`,`Force a full reindex.`],[`openclaw memory search "meeting notes"`,`Quick search using positional query.`],[`openclaw memory search --query "deployment" --max-results 20`,`Limit results for focused troubleshooting.`],[`openclaw memory forget --hook-source gmail --dry-run`,`Preview deletion of memories derived from matching sessions.`],[`openclaw memory promote --limit 10 --min-score ${DEFAULT_PROMOTION_MIN_SCORE}`,`Review weighted short-term candidates for long-term memory.`],[`openclaw memory promote --apply`,`Append top-ranked short-term candidates into MEMORY.md.`],[`openclaw memory promote-explain "router vlan"`,`Explain why a specific candidate would or would not promote.`],[`openclaw memory rem-harness --json`,`Preview REM reflections, candidate truths, and deep promotion output.`],[`openclaw memory rem-backfill --path ./memory`,`Write grounded historical REM entries into DREAMS.md for UI review.`],[`openclaw memory rem-backfill --path ./memory --stage-short-term`,`Also seed durable grounded candidates into the live short-term promotion store.`],[`openclaw memory session-backfill --agent main --from 2026-01-01`,`Preview trusted candidates from retained session history.`],[`openclaw memory status --json`,`Output machine-readable JSON (good for scripts).`]])}\n\n${theme.muted(`Docs:`)} ${formatDocsLink(`/cli/memory`,`docs.openclaw.ai/cli/memory`)}\n`);const agentCommand=(e,t,r=false)=>n.command(e).description(t).option(`--agent <id>`,r?`Agent id (default: all configured agents)`:`Agent id (default: default agent)`);agentCommand(`status`,`Show memory search index status`,true).option(`--json`,`Print JSON`).option(`--deep`,`Check embedding provider availability`).option(`--index`,`Reindex if dirty (implies --deep)`).option(`--fix`,`Repair stale recall locks and normalize promotion metadata`).option(`--verbose`,`Verbose logging`,false).action(lazyAction(`runMemoryStatus`));agentCommand(`index`,`Reindex memory files`,true).option(`--force`,`Force full reindex`,false).option(`--verbose`,`Verbose logging`,false).action(lazyAction(`runMemoryIndex`));agentCommand(`reset`,`Clear the derived memory index and embedding cache without deleting sessions`,true).option(`--yes`,`Skip confirmation`,false).action(lazyAction(`runMemoryReset`));n.command(`search`).description(`Search memory files`).argument(`[query]`,`Search query`).option(`--query <text>`,`Search query (alternative to positional argument)`).option(`--agent <id>`,`Agent id (default: default agent)`).option(`--max-results <n>`,`Max results`,memoryCliNumberOption(`--max-results`,`positive integer`)).option(`--min-score <n>`,`Minimum score`,memoryCliNumberOption(`--min-score`,`finite number`)).option(`--json`,`Print JSON`).action(async(e,n)=>{const r=n.query??e;if(!r)throw new Error(`Missing search query. Provide a positional query or use --query <text>.`);const{runMemorySearchWithOwner:i}=await import(`./cli-search-owner.runtime-H-gUafKD.mjs`);await i(r,n,t)});agentCommand(`forget`,`Delete memories and derived artifacts from selected sessions`).option(`--session <id-or-key>`,`Source session ID or key (repeatable)`,collectMemoryCliValues,[]).option(`--hook-source <source>`,`External-content hook source (repeatable)`,collectMemoryCliValues,[]).option(`--participant <actor-id>`,`Session participant actor ID (repeatable)`,collectMemoryCliValues,[]).option(`--since <date>`,`Only include sessions observed on or after this date`).option(`--dry-run`,`Report everything that would be deleted without writing`,false).option(`--json`,`Print the complete machine-readable deletion report`).action(async e=>{if(!e.session?.length&&!e.hookSource?.length&&!e.participant?.length)throw new Error(`Memory forget requires --session <id-or-key>, --hook-source <source>, or --participant <actor-id>.`);await runMemoryCliCommand(async()=>{await(await import(`./cli.runtime-Of87jA9X.mjs`)).runMemoryForget(e)})});agentCommand(`promote`,`Rank short-term recalls and optionally append top entries to MEMORY.md`).option(`--limit <n>`,`Max candidates`,memoryCliNumberOption(`--limit`,`positive integer`)).option(`--min-score <n>`,`Minimum weighted score (default: ${DEFAULT_PROMOTION_MIN_SCORE})`,memoryCliNumberOption(`--min-score`,`finite number`)).option(`--min-recall-count <n>`,`Minimum recall count (default: ${DEFAULT_PROMOTION_MIN_RECALL_COUNT})`,memoryCliNumberOption(`--min-recall-count`,`non-negative integer`)).option(`--min-unique-queries <n>`,`Minimum distinct query count (default: ${DEFAULT_PROMOTION_MIN_UNIQUE_QUERIES})`,memoryCliNumberOption(`--min-unique-queries`,`non-negative integer`)).option(`--apply`,`Append selected candidates to MEMORY.md`,false).option(`--include-promoted`,`Include already promoted candidates`,false).option(`--json`,`Print JSON`).action(lazyAction(`runMemoryPromote`));n.command(`promote-explain`).description(`Explain a specific promotion candidate and its score breakdown`).argument(`<selector>`,`Candidate key, path fragment, or snippet fragment`).option(`--agent <id>`,`Agent id (default: default agent)`).option(`--include-promoted`,`Include already promoted candidates`,false).option(`--json`,`Print JSON`).action(async(e,n)=>{const r=e?.trim();if(!r)throw new Error(`Memory promote-explain requires a non-empty selector.`);await runMemoryCliCommand(async()=>{await(await import(`./cli.runtime-Of87jA9X.mjs`)).runMemoryPromoteExplain(r,n,t)})});agentCommand(`rem-harness`,`Preview REM reflections, candidate truths, and deep promotions without writing`).option(`--path <file-or-dir>`,`Seed the harness from historical daily memory file(s)`).option(`--grounded`,`Also render a grounded day-level REM preview`).option(`--include-promoted`,`Include already promoted deep candidates`,false).option(`--json`,`Print JSON`).action(lazyAction(`runMemoryRemHarness`));agentCommand(`rem-backfill`,`Write grounded historical REM summaries into DREAMS.md for UI review`).option(`--path <file-or-dir>`,`Historical daily memory file(s) or directory`).option(`--rollback`,`Remove previously written grounded REM backfill entries`,false).option(`--stage-short-term`,`Also seed grounded durable candidates into the short-term promotion store`,false).option(`--rollback-short-term`,`Remove previously seeded grounded short-term candidates`,false).option(`--json`,`Print JSON`).action(lazyAction(`runMemoryRemBackfill`));agentCommand(`session-backfill`,`Distill retained session history into staged memory candidates`).option(`--from <YYYY-MM-DD>`,`Oldest transcript day to include`).option(`--to <YYYY-MM-DD>`,`Newest transcript day to include`).option(`--limit-days <n>`,`Maximum unprocessed days (default: ${DEFAULT_SESSION_BACKFILL_LIMIT_DAYS})`,memoryCliNumberOption(`--limit-days`,`positive integer`),DEFAULT_SESSION_BACKFILL_LIMIT_DAYS).option(`--rem`,`Write grounded per-day REM previews to DREAMS.md`,false).option(`--apply`,`Stage candidates and write DREAMS.md diary entries`,false).option(`--rollback`,`Remove all grounded backfill candidates and shared backfill diary entries`,false).option(`--archive-files <path...>`,`Also inspect foreign transcript archive files conservatively`).option(`--json`,`Print JSON`).action(async e=>{const{runMemorySessionBackfillCli:n}=await import(`./cli-session-backfill-DgZfAYf7.mjs`);await n(e,t)});n.action(()=>{n.outputHelp();process.exitCode=0})}export{registerMemoryCli as t};