@graphorin/cli 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +3 -3
  3. package/dist/bin/graphorin.js +51 -13
  4. package/dist/bin/graphorin.js.map +1 -1
  5. package/dist/commands/audit.d.ts.map +1 -1
  6. package/dist/commands/audit.js +2 -1
  7. package/dist/commands/audit.js.map +1 -1
  8. package/dist/commands/consolidator.d.ts +56 -1
  9. package/dist/commands/consolidator.d.ts.map +1 -1
  10. package/dist/commands/consolidator.js +88 -2
  11. package/dist/commands/consolidator.js.map +1 -1
  12. package/dist/commands/doctor.d.ts.map +1 -1
  13. package/dist/commands/index.d.ts +4 -4
  14. package/dist/commands/index.js +4 -4
  15. package/dist/commands/init.d.ts +11 -4
  16. package/dist/commands/init.d.ts.map +1 -1
  17. package/dist/commands/init.js +15 -11
  18. package/dist/commands/init.js.map +1 -1
  19. package/dist/commands/memory.d.ts +26 -1
  20. package/dist/commands/memory.d.ts.map +1 -1
  21. package/dist/commands/memory.js +56 -3
  22. package/dist/commands/memory.js.map +1 -1
  23. package/dist/commands/pricing.d.ts +6 -0
  24. package/dist/commands/pricing.d.ts.map +1 -1
  25. package/dist/commands/pricing.js +5 -2
  26. package/dist/commands/pricing.js.map +1 -1
  27. package/dist/commands/secrets.d.ts.map +1 -1
  28. package/dist/commands/secrets.js +2 -2
  29. package/dist/commands/secrets.js.map +1 -1
  30. package/dist/commands/skills.d.ts.map +1 -1
  31. package/dist/commands/skills.js +1 -1
  32. package/dist/commands/skills.js.map +1 -1
  33. package/dist/commands/storage.d.ts +41 -1
  34. package/dist/commands/storage.d.ts.map +1 -1
  35. package/dist/commands/storage.js +75 -1
  36. package/dist/commands/storage.js.map +1 -1
  37. package/dist/commands/token.d.ts.map +1 -1
  38. package/dist/commands/token.js +2 -2
  39. package/dist/commands/token.js.map +1 -1
  40. package/dist/commands/tools-lint.js +1 -1
  41. package/dist/commands/tools-lint.js.map +1 -1
  42. package/dist/commands/traces.d.ts +14 -2
  43. package/dist/commands/traces.d.ts.map +1 -1
  44. package/dist/commands/traces.js +39 -22
  45. package/dist/commands/traces.js.map +1 -1
  46. package/dist/commands/triggers.d.ts.map +1 -1
  47. package/dist/commands/triggers.js +5 -2
  48. package/dist/commands/triggers.js.map +1 -1
  49. package/dist/index.d.ts +4 -4
  50. package/dist/index.js +4 -5
  51. package/dist/index.js.map +1 -1
  52. package/dist/internal/output.js +6 -0
  53. package/dist/internal/output.js.map +1 -1
  54. package/dist/internal/store-context.js +13 -2
  55. package/dist/internal/store-context.js.map +1 -1
  56. package/dist/package.js +1 -1
  57. package/dist/package.js.map +1 -1
  58. package/package.json +18 -14
  59. package/src/bin/graphorin.ts +1387 -0
  60. package/src/commands/audit.ts +256 -0
  61. package/src/commands/auth.ts +238 -0
  62. package/src/commands/consolidator.ts +382 -0
  63. package/src/commands/doctor.ts +253 -0
  64. package/src/commands/guard.ts +144 -0
  65. package/src/commands/index.ts +223 -0
  66. package/src/commands/init.ts +194 -0
  67. package/src/commands/memory.ts +1052 -0
  68. package/src/commands/migrate-config.ts +77 -0
  69. package/src/commands/migrate-export.ts +117 -0
  70. package/src/commands/migrate.ts +83 -0
  71. package/src/commands/pricing.ts +244 -0
  72. package/src/commands/secrets.ts +309 -0
  73. package/src/commands/skills.ts +272 -0
  74. package/src/commands/start.ts +180 -0
  75. package/src/commands/storage.ts +659 -0
  76. package/src/commands/telemetry.ts +91 -0
  77. package/src/commands/token.ts +361 -0
  78. package/src/commands/tools-lint.ts +430 -0
  79. package/src/commands/traces.ts +188 -0
  80. package/src/commands/triggers.ts +237 -0
  81. package/src/index.ts +30 -0
  82. package/src/internal/exit.ts +62 -0
  83. package/src/internal/load-config.ts +107 -0
  84. package/src/internal/offline.ts +81 -0
  85. package/src/internal/output.ts +146 -0
  86. package/src/internal/prompts.ts +58 -0
  87. package/src/internal/store-context.ts +165 -0
@@ -1 +1 @@
1
- {"version":3,"file":"graphorin.js","names":[],"sources":["../../src/bin/graphorin.ts"],"sourcesContent":["/**\n * `graphorin` CLI entry point. Built into `dist/bin/graphorin.js`\n * with a shebang prepended by `tsdown`; the `package.json` `bin`\n * field points npm at the compiled file.\n *\n * Phase 14a installs three subcommands grouped by lifecycle phase:\n *\n * Bootstrap:\n * - graphorin init\n *\n * Maintenance:\n * - graphorin migrate\n *\n * Runtime:\n * - graphorin start\n *\n * Phase 15 extends this binary with the full operator surface\n * (`doctor`, `token`, `secrets`, `audit`, `storage`, `memory`,\n * `consolidator`, `triggers`, `auth`, `pricing`, `skills`, `traces`,\n * `migrate-export`, `migrate-config`, `guard`, `telemetry`,\n * `tools lint`).\n *\n * `GRAPHORIN_OFFLINE=1` is honoured by every subcommand - the v0.1\n * surface never makes implicit network calls. Phase 15 commands that\n * do touch the network (e.g. `graphorin pricing refresh`) consult\n * the same flag through the helper in `../internal/offline.ts`.\n *\n * @packageDocumentation\n */\n\nimport process from 'node:process';\n\nimport { Command } from 'commander';\n\nimport {\n runAuditExport,\n runAuditPrune,\n runAuditVerify,\n runAuthList,\n runAuthLogin,\n runAuthRefresh,\n runAuthRevoke,\n runAuthStatus,\n runConsolidatorSetTier,\n runConsolidatorStatus,\n runConsolidatorStop,\n runDoctor,\n runGuardExplain,\n runGuardStatus,\n runInit,\n runMemoryActivity,\n runMemoryInspect,\n runMemoryMigrate,\n runMemoryReview,\n runMemoryStatus,\n runMemoryWhy,\n runMigrate,\n runMigrateConfig,\n runMigrateExport,\n runPricingDiff,\n runPricingLookup,\n runPricingMissing,\n runPricingRefresh,\n runPricingStatus,\n runSecretsDelete,\n runSecretsGet,\n runSecretsList,\n runSecretsRef,\n runSecretsRotate,\n runSecretsSet,\n runSkillsAudit,\n runSkillsInspect,\n runSkillsInstall,\n runSkillsMigrateFrontmatter,\n runStart,\n runStorageBackup,\n runStorageCleanupBackups,\n runStorageEncrypt,\n runStorageRekey,\n runStorageStatus,\n runTelemetryDisable,\n runTelemetryEnable,\n runTelemetryInspect,\n runTelemetryStatus,\n runTokenCreate,\n runTokenList,\n runTokenRekey,\n runTokenRevoke,\n runTokenRotate,\n runTokenVerify,\n runToolsLint,\n runTracesPrune,\n runTracesStatus,\n runTriggersDisable,\n runTriggersFire,\n runTriggersList,\n runTriggersPrune,\n runTriggersStatus,\n VERSION,\n} from '../index.js';\nimport { isOfflineMode } from '../internal/offline.js';\n\nasync function main(): Promise<void> {\n const program = new Command();\n program\n .name('graphorin')\n .description(\n [\n 'Operator CLI for the Graphorin framework.',\n '',\n 'Commands grouped by purpose:',\n ' Bootstrap: init, migrate, migrate-config',\n ' Runtime: start',\n ' Diagnostics: doctor, telemetry, traces, guard',\n ' Auth: token, secrets, auth',\n ' Storage: storage, audit, memory, consolidator, triggers, migrate-export',\n ' Catalogue: pricing, skills, tools',\n '',\n 'Honours GRAPHORIN_OFFLINE=1 - the v0.1 surface never makes implicit network calls.',\n ].join('\\n'),\n )\n .version(VERSION);\n\n registerLifecycleCommands(program);\n registerDoctorCommand(program);\n registerTokenCommands(program);\n registerSecretsCommands(program);\n registerStorageCommands(program);\n registerAuditCommands(program);\n registerMemoryCommands(program);\n registerConsolidatorCommands(program);\n registerTriggersCommands(program);\n registerAuthCommands(program);\n registerPricingCommands(program);\n registerSkillsCommands(program);\n registerTracesCommands(program);\n registerMigrateExportCommand(program);\n registerMigrateConfigCommand(program);\n registerGuardCommands(program);\n registerTelemetryCommands(program);\n registerToolsCommands(program);\n\n await program.parseAsync(process.argv);\n}\n\nfunction registerLifecycleCommands(program: Command): void {\n program\n .command('start')\n .description('[Runtime] Start the @graphorin/server daemon.')\n .option('-c, --config <path>', 'Path to the graphorin.config file (TS / JS / JSON).')\n .option('-h, --host <host>', 'Override the configured listen host.')\n .option('-p, --port <port>', 'Override the configured listen port.', (value) =>\n Number.parseInt(value, 10),\n )\n .option(\n '--secrets-source <kind>',\n 'Override secrets.source: auto | keyring | encrypted-file | env (DEC-136).',\n )\n .option('--strict-secrets', 'Refuse to fall back to a different secrets store (DEC-136).')\n .action(\n async (opts: {\n config?: string;\n host?: string;\n port?: number;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - running with no implicit network calls.\\n',\n );\n }\n await runStart({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.host !== undefined ? { host: opts.host } : {}),\n ...(opts.port !== undefined ? { port: opts.port } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n });\n },\n );\n\n program\n .command('init')\n .description(\n '[Bootstrap] Generate a fresh graphorin.config.ts and a one-shot bootstrap admin token.',\n )\n .option('-o, --out <path>', 'Output path; defaults to ./graphorin.config.ts.')\n .option('--non-interactive', 'Accept defaults / env vars without prompting.', false)\n .option(\n '--cloud-consent <tier>',\n 'Cloud-upload consent tier: public-only | public-and-internal | all-with-warnings.',\n )\n .option('--encrypted', 'Enable storage encryption opt-in.')\n .option('--no-encrypted', 'Disable storage encryption opt-in.')\n .action(\n async (opts: {\n out?: string;\n nonInteractive?: boolean;\n cloudConsent?: 'public-only' | 'public-and-internal' | 'all-with-warnings';\n encrypted?: boolean;\n }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - init never reaches the network.\\n',\n );\n }\n await runInit({\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.nonInteractive !== undefined ? { nonInteractive: opts.nonInteractive } : {}),\n ...(opts.cloudConsent !== undefined ? { cloudConsent: opts.cloudConsent } : {}),\n ...(opts.encrypted !== undefined ? { encrypted: opts.encrypted } : {}),\n });\n },\n );\n\n program\n .command('migrate')\n .description(\n '[Maintenance] Apply pending storage migrations against the configured SQLite store.',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--target <version>', 'Reserved for the Phase 15 partial-migration runner.')\n .action(async (opts: { config?: string; target?: string }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - migrate is a local-only operation.\\n',\n );\n }\n await runMigrate({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.target !== undefined ? { target: opts.target } : {}),\n });\n });\n}\n\nfunction registerDoctorCommand(program: Command): void {\n program\n .command('doctor')\n .description('[Diagnostics] Health check (perms + secrets + encryption + systemd).')\n .option('--fix-perms', 'Repair drifted POSIX file modes.')\n .option('--check-perms', 'Run the file-perms check.')\n .option('--check-secrets', 'Run the secrets-store check.')\n .option('--check-encryption', 'Run the audit-encryption check.')\n .option('--check-systemd', 'Run the systemd-hardening check (Linux only).')\n .option('--all', 'Run every check.')\n .option('--json', 'Emit a structured JSON report on stdout.')\n .action(\n async (opts: {\n fixPerms?: boolean;\n checkPerms?: boolean;\n checkSecrets?: boolean;\n checkEncryption?: boolean;\n checkSystemd?: boolean;\n all?: boolean;\n json?: boolean;\n }) => {\n await runDoctor({\n ...(opts.fixPerms !== undefined ? { fixPerms: opts.fixPerms } : {}),\n ...(opts.checkPerms !== undefined ? { checkPerms: opts.checkPerms } : {}),\n ...(opts.checkSecrets !== undefined ? { checkSecrets: opts.checkSecrets } : {}),\n ...(opts.checkEncryption !== undefined ? { checkEncryption: opts.checkEncryption } : {}),\n ...(opts.checkSystemd !== undefined ? { checkSystemd: opts.checkSystemd } : {}),\n ...(opts.all !== undefined ? { all: opts.all } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTokenCommands(program: Command): void {\n const token = program.command('token').description('[Auth] Manage server auth tokens.');\n token\n .command('create')\n .description('Mint a new token. Prints the raw value once.')\n .requiredOption('--scopes <list>', 'Comma-separated scope list.')\n .option('--label <name>', 'Optional label.')\n .option('--expires-in <duration>', 'Duration string: 30d, 12h, 90m, 45s.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n scopes: string;\n label?: string;\n expiresIn?: string;\n env?: 'live' | 'test';\n config?: string;\n json?: boolean;\n }) => {\n await runTokenCreate({\n scopes: opts.scopes\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n ...(opts.label !== undefined ? { label: opts.label } : {}),\n ...(opts.expiresIn !== undefined ? { expiresIn: opts.expiresIn } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n token\n .command('list')\n .description('List token metadata.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--include-revoked', 'Include revoked tokens.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; includeRevoked?: boolean; json?: boolean }) => {\n await runTokenList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.includeRevoked !== undefined ? { includeRevoked: opts.includeRevoked } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('revoke <id>')\n .description('Revoke a single token.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTokenRevoke({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('rotate <id>')\n .description('Revoke + reissue a token with the same scopes.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (id: string, opts: { config?: string; env?: 'live' | 'test'; json?: boolean }) => {\n await runTokenRotate({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n token\n .command('rekey')\n .description('Re-issue every active token (use after a known compromise).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; env?: 'live' | 'test'; json?: boolean }) => {\n await runTokenRekey({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('verify <token>')\n .description('Offline checksum verification - never consults the store.')\n .option('--prefix <prefix>', 'Override the expected token prefix.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((tok: string, opts: { prefix?: string; json?: boolean }) => {\n runTokenVerify({\n token: tok,\n ...(opts.prefix !== undefined ? { prefix: opts.prefix } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerSecretsCommands(program: Command): void {\n const secrets = program\n .command('secrets')\n .description('[Auth] Manage secrets in the configured store.');\n const commonOpts = (cmd: Command): Command =>\n cmd\n .option('--secrets-source <kind>', 'auto | keyring | encrypted-file | env (DEC-136).')\n .option('--strict-secrets', 'Refuse to fall back to a different secrets store.')\n .option('--json', 'Emit a structured JSON document on stdout.');\n commonOpts(secrets.command('list').description('List secret metadata.')).action(\n async (opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n }) => {\n await runSecretsList({\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('get <key>')\n .description('Read a secret. Use --reveal to print the bytes.')\n .option('--reveal', 'Print the raw value.'),\n ).action(\n async (\n key: string,\n opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n reveal?: boolean;\n },\n ) => {\n await runSecretsGet({\n key,\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n ...(opts.reveal !== undefined ? { reveal: opts.reveal } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('set <key>')\n .description('Persist a secret. Pass --value <v> or --from-stdin.')\n .option('--value <v>', 'Inline value.')\n .option('--from-stdin', 'Read the value from stdin.'),\n ).action(\n async (\n key: string,\n opts: {\n value?: string;\n fromStdin?: boolean;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsSet({\n key,\n ...(opts.value !== undefined ? { value: opts.value } : {}),\n ...(opts.fromStdin !== undefined ? { fromStdin: opts.fromStdin } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(secrets.command('delete <key>').description('Delete a secret.')).action(\n async (\n key: string,\n opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsDelete({\n key,\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('ref <uri>')\n .description('Test resolution of a SecretRef URI.')\n .option('--reveal', 'Include the resolved value in the report.'),\n ).action(async (uri: string, opts: { reveal?: boolean; json?: boolean }) => {\n await runSecretsRef({\n uri,\n ...(opts.reveal !== undefined ? { reveal: opts.reveal } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n commonOpts(\n secrets\n .command('rotate <key>')\n .description('Replace an existing secret with a fresh value.')\n .option('--new-value <v>', 'Inline new value.')\n .option('--from-stdin', 'Read the new value from stdin.'),\n ).action(\n async (\n key: string,\n opts: {\n newValue?: string;\n fromStdin?: boolean;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsRotate({\n key,\n ...(opts.newValue !== undefined ? { newValue: opts.newValue } : {}),\n ...(opts.fromStdin !== undefined ? { fromStdin: opts.fromStdin } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerStorageCommands(program: Command): void {\n const storage = program\n .command('storage')\n .description('[Storage] SQLite + encryption-at-rest commands.');\n storage\n .command('status')\n .description('Report current store state + cipher peer availability.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runStorageStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n storage\n .command('encrypt')\n .description(\n 'Encrypt the store. Requires the @graphorin/store-sqlite-encrypted sub-pack (Phase 16).',\n )\n .requiredOption('--passphrase-from <ref>', 'SecretRef URI for the new passphrase.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option(\n '--target-path <path>',\n 'Override the encrypted output path. Default <storage>.encrypted.',\n )\n .option(\n '--swap',\n 'Atomically swap the encrypted output into the storage path; original kept under .bak.<ts>.',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n passphraseFrom: string;\n config?: string;\n targetPath?: string;\n swap?: boolean;\n json?: boolean;\n }) => {\n await runStorageEncrypt({\n passphraseFrom: opts.passphraseFrom,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.targetPath !== undefined ? { targetPath: opts.targetPath } : {}),\n ...(opts.swap === true ? { swap: true } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('rekey')\n .description('Rekey an already-encrypted store.')\n .requiredOption('--old-passphrase-from <ref>', 'SecretRef URI for the existing passphrase.')\n .requiredOption('--new-passphrase-from <ref>', 'SecretRef URI for the new passphrase.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n oldPassphraseFrom: string;\n newPassphraseFrom: string;\n config?: string;\n json?: boolean;\n }) => {\n await runStorageRekey({\n oldPassphraseFrom: opts.oldPassphraseFrom,\n newPassphraseFrom: opts.newPassphraseFrom,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('backup')\n .description(\n 'Online, consistent copy of the store via the page-level backup API (safe under a live writer; never use VACUUM INTO).',\n )\n .argument('<dest>', 'Destination file path for the backup copy.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--overwrite', 'Replace an existing destination file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (dest: string, opts: { config?: string; overwrite?: boolean; json?: boolean }) => {\n await runStorageBackup({\n dest,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.overwrite === true ? { overwrite: true } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('cleanup-backups')\n .description('Drop stale .bak / .tmp.<ts> files left by previous encrypt / rekey runs.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--dry-run', 'Print what would be removed without touching the filesystem.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; dryRun?: boolean; json?: boolean }) => {\n await runStorageCleanupBackups({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerAuditCommands(program: Command): void {\n const audit = program\n .command('audit')\n .description('[Storage] Operate on the encrypted audit log.');\n audit\n .command('verify')\n .description('Replay the chain and report the first broken link (if any).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuditVerify({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n audit\n .command('prune')\n .description('Drop entries older than --before (cutoff is required).')\n .requiredOption('--before <date>', 'ISO date / epoch ms cutoff.')\n .option('--retain <n>', 'Minimum number of entries that must survive.', (v) =>\n Number.parseInt(v, 10),\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before: string; retain?: number; config?: string; json?: boolean }) => {\n await runAuditPrune({\n before: opts.before,\n ...(opts.retain !== undefined ? { retain: opts.retain } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n audit\n .command('export')\n .description('Stream every audit entry as JSONL into --to.')\n .requiredOption('--to <file>', 'Output path.')\n .option('--from-seq <n>', 'Lower bound (inclusive).', (v) => Number.parseInt(v, 10))\n .option('--to-seq <n>', 'Upper bound (inclusive).', (v) => Number.parseInt(v, 10))\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n to: string;\n fromSeq?: number;\n toSeq?: number;\n config?: string;\n json?: boolean;\n }) => {\n await runAuditExport({\n to: opts.to,\n ...(opts.fromSeq !== undefined ? { fromSeq: opts.fromSeq } : {}),\n ...(opts.toSeq !== undefined ? { toSeq: opts.toSeq } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerMemoryCommands(program: Command): void {\n const memory = program\n .command('memory')\n .description('[Storage] Long-term memory operator commands.');\n memory\n .command('status')\n .description('Report counts + active embedder + migration state.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runMemoryStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('migrate')\n .description('Embedder swap. Requires --embedders module that exports the factories.')\n .requiredOption('--from <id>', 'Source embedder id.')\n .requiredOption('--to <id>', 'Target embedder id.')\n .requiredOption('--strategy <s>', 'lock-on-first | auto-migrate | multi-active.')\n .option('--embedders <path>', 'Path to a module exporting embedder factories.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(\n async (opts: {\n from: string;\n to: string;\n strategy: string;\n embedders?: string;\n config?: string;\n }) => {\n await runMemoryMigrate({\n from: opts.from,\n to: opts.to,\n strategy: opts.strategy as 'lock-on-first' | 'auto-migrate' | 'multi-active',\n ...(opts.embedders !== undefined ? { embeddersModule: opts.embedders } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n },\n );\n memory\n .command('inspect')\n .description('Inspect one fact: supersede chain, quarantine, conflicts, citing insights.')\n .argument('<factId>', 'Id of the fact to inspect.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (factId: string, opts: { config?: string; json?: boolean }) => {\n await runMemoryInspect({\n factId,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('activity')\n .description('Store-wide consolidator / reflection activity: quarantine, history, conflicts.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--limit <n>', 'Cap on recent history / conflict rows (default 20).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; limit?: string; json?: boolean }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryActivity({\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('why')\n .description(\n 'Explain why facts were recalled (ranking signals) from the persisted recall spans.',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--session <id>', \"Restrict to one session's recall spans.\")\n .option('--limit <n>', 'Cap on the most-recent recall spans (default 5).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; session?: string; limit?: string; json?: boolean }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryWhy({\n ...(opts.session !== undefined ? { sessionId: opts.session } : {}),\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('review')\n .description('List quarantined memory by tier, or promote a reviewed item with --promote.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--limit <n>', 'Cap on rows listed per type (default 20).')\n .option('--promote <id>', 'Promote this quarantined memory id out of quarantine.')\n .option('--reason <text>', 'Audit reason recorded with the promotion.')\n .option('--force', 'Override the injection-refusal gate (operator action, after review).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n config?: string;\n limit?: string;\n promote?: string;\n reason?: string;\n force?: boolean;\n json?: boolean;\n }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryReview({\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.promote !== undefined ? { promote: opts.promote } : {}),\n ...(opts.reason !== undefined ? { reason: opts.reason } : {}),\n ...(opts.force !== undefined ? { force: opts.force } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerConsolidatorCommands(program: Command): void {\n const c = program\n .command('consolidator')\n .description('[Storage] Inspect and steer the memory consolidator.');\n c.command('status')\n .description('Current tier hint + DLQ size + recent run history.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runConsolidatorStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('set-tier <tier>')\n .description('Persist a tier hint (free | cheap | standard | full | custom).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (tier: string, opts: { config?: string; json?: boolean }) => {\n await runConsolidatorSetTier({\n tier: tier as 'free' | 'cheap' | 'standard' | 'full' | 'custom',\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('stop')\n .description('Persist a pause flag the running daemon honours.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runConsolidatorStop({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerTriggersCommands(program: Command): void {\n const t = program\n .command('triggers')\n .description('[Storage] Operate on the durable trigger registry.');\n t.command('list')\n .description('Every persisted trigger.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runTriggersList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('status <id>')\n .description('Single-trigger detail.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersStatus({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('fire <id>')\n .description('Operator-fired side-effect (admin only).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersFire({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('disable <id>')\n .description('Flip the disabled column on the registry row.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersDisable({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('prune')\n .description('Drop disabled triggers older than --before.')\n .option(\n '--before <date>',\n 'ISO date / epoch ms cutoff. Defaults to 0 (drop every disabled row).',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before?: string; config?: string; json?: boolean }) => {\n await runTriggersPrune({\n ...(opts.before !== undefined ? { before: opts.before } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerAuthCommands(program: Command): void {\n const a = program.command('auth').description('[Auth] Outbound OAuth (e.g. for MCP servers).');\n a.command('login')\n .description('Drive an interactive login flow.')\n .requiredOption('--server <url>', 'Authorization server URL.')\n .option('--server-id <id>', 'Override the persisted server identifier.')\n .option('--scope <scope>', 'OAuth scope.')\n .option('--device-flow', 'Use the Device Authorization Grant.')\n .option('--client-id <id>', 'Pre-existing client identifier (skip DCR).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(\n async (opts: {\n server: string;\n serverId?: string;\n scope?: string;\n deviceFlow?: boolean;\n clientId?: string;\n config?: string;\n }) => {\n await runAuthLogin({\n serverUrl: opts.server,\n ...(opts.serverId !== undefined ? { serverId: opts.serverId } : {}),\n ...(opts.scope !== undefined ? { scope: opts.scope } : {}),\n ...(opts.deviceFlow !== undefined ? { deviceFlow: opts.deviceFlow } : {}),\n ...(opts.clientId !== undefined ? { clientId: opts.clientId } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n },\n );\n a.command('list')\n .description('List persisted OAuth sessions.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuthList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n a.command('refresh <id>')\n .description('Refresh a session.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(async (id: string, opts: { config?: string }) => {\n await runAuthRefresh({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n });\n a.command('revoke <id>')\n .description('Revoke a session.')\n .option('--reason <text>', 'Optional reason persisted in the audit log.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(async (id: string, opts: { reason?: string; config?: string }) => {\n await runAuthRevoke({\n id,\n ...(opts.reason !== undefined ? { reason: opts.reason } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n });\n a.command('status')\n .description('OAuth subsystem snapshot.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuthStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerPricingCommands(program: Command): void {\n const p = program.command('pricing').description('[Catalogue] Bundled LLM pricing snapshot.');\n p.command('status')\n .description('Show bundled snapshot version + entry count + digest.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runPricingStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n p.command('refresh')\n .description('Pull a fresh snapshot from --url (network).')\n .requiredOption('--url <url>', 'Snapshot URL.')\n .option('--out <file>', 'Optional path to write the refreshed snapshot to.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { url: string; out?: string; json?: boolean }) => {\n await runPricingRefresh({\n url: opts.url,\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('diff')\n .description('Diff a supplied snapshot against the bundled one.')\n .requiredOption('--snapshot <file>', 'JSON file containing a PricingSnapshot.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { snapshot: string; json?: boolean }) => {\n await runPricingDiff({\n snapshot: opts.snapshot,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('lookup')\n .description('Print the per-token price for a single (provider, model) pair.')\n .requiredOption('--provider <name>', 'Provider id.')\n .requiredOption('--model <id>', 'Model id.')\n .option('--region <region>', 'Optional region.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { provider: string; model: string; region?: string; json?: boolean }) => {\n runPricingLookup({\n provider: opts.provider,\n model: opts.model,\n ...(opts.region !== undefined ? { region: opts.region } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('missing')\n .description('Report (provider, model) pairs absent from the bundled snapshot.')\n .requiredOption('--spans <file>', 'JSON file containing trace spans (array of { attributes }).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { spans: string; json?: boolean }) => {\n await runPricingMissing({\n spans: opts.spans,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerSkillsCommands(program: Command): void {\n const s = program\n .command('skills')\n .description('[Catalogue] Manage operator-managed skill packages.');\n s.command('install <source>')\n .description('Install a skill from npm:<name>[@version] or git:<url>.')\n .option('--version <version>', 'npm version pin.')\n .option('--ref <ref>', 'git ref (branch / tag / sha).')\n .option('--trust-level <level>', 'trusted | trusted-with-scripts | untrusted.')\n .option('--cwd <dir>', 'Working directory for npm installs.')\n .option('--dry-run', 'Skip the install; run the policy + audit pipeline only.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (\n source: string,\n opts: {\n version?: string;\n ref?: string;\n trustLevel?: 'trusted' | 'trusted-with-scripts' | 'untrusted';\n cwd?: string;\n dryRun?: boolean;\n json?: boolean;\n },\n ) => {\n await runSkillsInstall({\n source,\n ...(opts.version !== undefined ? { version: opts.version } : {}),\n ...(opts.ref !== undefined ? { ref: opts.ref } : {}),\n ...(opts.trustLevel !== undefined ? { trustLevel: opts.trustLevel } : {}),\n ...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),\n ...(opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n s.command('inspect <name>')\n .description('Print a single recorded installation.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (name: string, opts: { json?: boolean }) => {\n await runSkillsInspect({\n name,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n s.command('audit')\n .description('Audit every recorded installation in this process.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runSkillsAudit({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n s.command('migrate-frontmatter')\n .description(\n 'Migrate legacy graphorin-* frontmatter fields onto upstream equivalents (DEC-156).',\n )\n .option('--path <dir>', 'Directory to walk. Defaults to cwd.')\n .option('--recursive', 'Walk subdirectories.')\n .option('--apply', 'Actually rewrite files (default: dry-run).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: { path?: string; recursive?: boolean; apply?: boolean; json?: boolean }) => {\n await runSkillsMigrateFrontmatter({\n ...(opts.path !== undefined ? { path: opts.path } : {}),\n ...(opts.recursive !== undefined ? { recursive: opts.recursive } : {}),\n ...(opts.apply !== undefined ? { apply: opts.apply } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTracesCommands(program: Command): void {\n const t = program.command('traces').description('[Diagnostics] Operate on the trace cache.');\n t.command('status')\n .description('Count rows + report TTL config.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runTracesStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('prune')\n .description('Manual TTL enforcement (cutoff is required).')\n .requiredOption('--before <date>', 'ISO date / epoch ms cutoff.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before: string; config?: string; json?: boolean }) => {\n await runTracesPrune({\n before: opts.before,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerMigrateExportCommand(program: Command): void {\n program\n .command('migrate-export <input>')\n .description('[Storage] Migrate a session export file to the current schema (DEC-155).')\n .requiredOption('--to <file>', 'Output path.')\n .option('--to-schema <version>', 'Target schema version.', '1.0')\n .option('--writer <id>', 'Writer identifier surfaced on the meta header.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (\n input: string,\n opts: { to: string; toSchema?: string; writer?: string; json?: boolean },\n ) => {\n await runMigrateExport({\n input,\n to: opts.to,\n ...(opts.toSchema !== undefined ? { toSchema: opts.toSchema } : {}),\n ...(opts.writer !== undefined ? { writer: opts.writer } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerMigrateConfigCommand(program: Command): void {\n program\n .command('migrate-config <input>')\n .description('[Bootstrap] Migrate an old config file to the current schema.')\n .option('--out <file>', 'Output path. Defaults to <input>.migrated.json next to the source.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (input: string, opts: { out?: string; json?: boolean }) => {\n await runMigrateConfig({\n input,\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerGuardCommands(program: Command): void {\n const g = program\n .command('guard')\n .description('[Diagnostics] Inspect the memory-modification guard.');\n g.command('status')\n .description('Print the four guard tiers and their variants.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runGuardStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n g.command('explain <toolName>')\n .description(\n 'Derive the tier the classifier would assign to a tool with the supplied metadata.',\n )\n .option('--tags <list>', 'Comma-separated tag list.')\n .option('--secrets-allowed <list>', 'Comma-separated secret allowlist.')\n .option('--trust-level <level>', 'built-in | user-defined | trusted | untrusted.')\n .option(\n '--explicit-tier <tier>',\n 'pure | side-effecting-no-memory | memory-aware | unknown | untrusted.',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n (\n toolName: string,\n opts: {\n tags?: string;\n secretsAllowed?: string;\n trustLevel?: 'built-in' | 'user-defined' | 'trusted' | 'untrusted';\n explicitTier?:\n | 'pure'\n | 'side-effecting-no-memory'\n | 'memory-aware'\n | 'unknown'\n | 'untrusted';\n json?: boolean;\n },\n ) => {\n runGuardExplain({\n toolName,\n ...(opts.tags !== undefined\n ? {\n tags: opts.tags\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n }\n : {}),\n ...(opts.secretsAllowed !== undefined\n ? {\n secretsAllowed: opts.secretsAllowed\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n }\n : {}),\n ...(opts.trustLevel !== undefined ? { trustLevel: opts.trustLevel } : {}),\n ...(opts.explicitTier !== undefined ? { explicitTier: opts.explicitTier } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTelemetryCommands(program: Command): void {\n const t = program\n .command('telemetry')\n .description('[Diagnostics] Telemetry policy (zero-default per ADR-041).');\n t.command('status')\n .description('Always reports disabled.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('enable')\n .description('Refuses; opt-in collector is on the v0.2+ roadmap.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryEnable({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('disable')\n .description('No-op; telemetry is always disabled.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryDisable({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('inspect')\n .description('Informational summary of the zero-default promise.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryInspect({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n}\n\nfunction registerToolsCommands(program: Command): void {\n const tools = program.command('tools').description('[Catalogue] Operate on the tool registry.');\n tools\n .command('lint')\n .description(\n [\n 'Static AST analysis of every tool({...}) registration; per-tool grader + threshold gate (RB-49).',\n '',\n 'Grader rubric (40 + 30 + 30 = 100 points):',\n ' description axis (0..40): 0 if missing/placeholder/<20 chars; 16/24/32/40 by length.',\n ' examples axis (0..30): 0 if none or >5; 12 base + 6 per additional, cap 30; -6 per PII.',\n ' parameter naming (0..30): 30 base; -30/N per ambiguous name; -10/N per numeric suffix.',\n '',\n 'Exit codes (CI-friendly):',\n ' 0 every tool meets or exceeds --threshold.',\n ' 1 at least one tool falls below --threshold.',\n ' 2 invocation could not start (config missing, walker failed).',\n ].join('\\n'),\n )\n .option('-c, --config <path>', 'Optional tsconfig.json whose include overrides the file glob.')\n .option('--threshold <n>', 'Minimum acceptable per-tool score (default 60).', (v) =>\n Number.parseInt(v, 10),\n )\n .option('--format <fmt>', 'text | json (default text).')\n .option('--source <pattern>', 'File glob override (e.g. src/skills/**/tools/*.ts).')\n .action(\n async (opts: {\n config?: string;\n threshold?: number;\n format?: 'text' | 'json';\n source?: string;\n }) => {\n await runToolsLint({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.threshold !== undefined ? { threshold: opts.threshold } : {}),\n ...(opts.format !== undefined ? { format: opts.format } : {}),\n ...(opts.source !== undefined ? { source: opts.source } : {}),\n });\n },\n );\n}\n\nmain().catch((err) => {\n process.stderr.write(`[graphorin/cli] ${(err as Error).message}\\n`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,eAAe,OAAsB;CACnC,MAAM,UAAU,IAAI,SAAS;AAC7B,SACG,KAAK,YAAY,CACjB,YACC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK,CACb,CACA,QAAQ,QAAQ;AAEnB,2BAA0B,QAAQ;AAClC,uBAAsB,QAAQ;AAC9B,uBAAsB,QAAQ;AAC9B,yBAAwB,QAAQ;AAChC,yBAAwB,QAAQ;AAChC,uBAAsB,QAAQ;AAC9B,wBAAuB,QAAQ;AAC/B,8BAA6B,QAAQ;AACrC,0BAAyB,QAAQ;AACjC,sBAAqB,QAAQ;AAC7B,yBAAwB,QAAQ;AAChC,wBAAuB,QAAQ;AAC/B,wBAA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AAa;GACjB,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE;GAC5D,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,WAAW,GAAG,EAAE;GACrE,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE;GAC5D,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE;GAC7D,CAAC;GAEL;;AAGL,MAAM,CAAC,OAAO,QAAQ;AACpB,SAAQ,OAAO,MAAM,mBAAoB,IAAc,QAAQ,IAAI;AACnE,SAAQ,KAAK,EAAE;EACf"}
1
+ {"version":3,"file":"graphorin.js","names":[],"sources":["../../src/bin/graphorin.ts"],"sourcesContent":["/**\n * `graphorin` CLI entry point. Built into `dist/bin/graphorin.js`\n * with a shebang prepended by `tsdown`; the `package.json` `bin`\n * field points npm at the compiled file.\n *\n * Phase 14a installs three subcommands grouped by lifecycle phase:\n *\n * Bootstrap:\n * - graphorin init\n *\n * Maintenance:\n * - graphorin migrate\n *\n * Runtime:\n * - graphorin start\n *\n * Phase 15 extends this binary with the full operator surface\n * (`doctor`, `token`, `secrets`, `audit`, `storage`, `memory`,\n * `consolidator`, `triggers`, `auth`, `pricing`, `skills`, `traces`,\n * `migrate-export`, `migrate-config`, `guard`, `telemetry`,\n * `tools lint`).\n *\n * `GRAPHORIN_OFFLINE=1` is honoured by every subcommand - the v0.1\n * surface never makes implicit network calls. Phase 15 commands that\n * do touch the network (e.g. `graphorin pricing refresh`) consult\n * the same flag through the helper in `../internal/offline.ts`.\n *\n * @packageDocumentation\n */\n\nimport process from 'node:process';\n\nimport { Command } from 'commander';\n\nimport {\n runAuditExport,\n runAuditPrune,\n runAuditVerify,\n runAuthList,\n runAuthLogin,\n runAuthRefresh,\n runAuthRevoke,\n runAuthStatus,\n runConsolidatorDlqClear,\n runConsolidatorDlqList,\n runConsolidatorSetTier,\n runConsolidatorStatus,\n runConsolidatorStop,\n runDoctor,\n runGuardExplain,\n runGuardStatus,\n runInit,\n runMemoryActivity,\n runMemoryInspect,\n runMemoryMigrate,\n runMemoryPruneHistory,\n runMemoryReview,\n runMemoryStatus,\n runMemoryWhy,\n runMigrate,\n runMigrateConfig,\n runMigrateExport,\n runPricingDiff,\n runPricingLookup,\n runPricingMissing,\n runPricingRefresh,\n runPricingStatus,\n runSecretsDelete,\n runSecretsGet,\n runSecretsList,\n runSecretsRef,\n runSecretsRotate,\n runSecretsSet,\n runSkillsAudit,\n runSkillsInspect,\n runSkillsInstall,\n runSkillsMigrateFrontmatter,\n runStart,\n runStorageBackup,\n runStorageCleanupBackups,\n runStorageCompact,\n runStorageEncrypt,\n runStorageRekey,\n runStorageStatus,\n runTelemetryDisable,\n runTelemetryEnable,\n runTelemetryInspect,\n runTelemetryStatus,\n runTokenCreate,\n runTokenList,\n runTokenRekey,\n runTokenRevoke,\n runTokenRotate,\n runTokenVerify,\n runToolsLint,\n runTracesPrune,\n runTracesStatus,\n runTriggersDisable,\n runTriggersFire,\n runTriggersList,\n runTriggersPrune,\n runTriggersStatus,\n VERSION,\n} from '../index.js';\nimport { isOfflineMode } from '../internal/offline.js';\n\nasync function main(): Promise<void> {\n const program = new Command();\n program\n .name('graphorin')\n .description(\n [\n 'Operator CLI for the Graphorin framework.',\n '',\n 'Commands grouped by purpose:',\n ' Bootstrap: init, migrate, migrate-config',\n ' Runtime: start',\n ' Diagnostics: doctor, telemetry, traces, guard',\n ' Auth: token, secrets, auth',\n ' Storage: storage, audit, memory, consolidator, triggers, migrate-export',\n ' Catalogue: pricing, skills, tools',\n '',\n 'Honours GRAPHORIN_OFFLINE=1 - the v0.1 surface never makes implicit network calls.',\n ].join('\\n'),\n )\n .version(VERSION);\n\n registerLifecycleCommands(program);\n registerDoctorCommand(program);\n registerTokenCommands(program);\n registerSecretsCommands(program);\n registerStorageCommands(program);\n registerAuditCommands(program);\n registerMemoryCommands(program);\n registerConsolidatorCommands(program);\n registerTriggersCommands(program);\n registerAuthCommands(program);\n registerPricingCommands(program);\n registerSkillsCommands(program);\n registerTracesCommands(program);\n registerMigrateExportCommand(program);\n registerMigrateConfigCommand(program);\n registerGuardCommands(program);\n registerTelemetryCommands(program);\n registerToolsCommands(program);\n\n await program.parseAsync(process.argv);\n}\n\nfunction registerLifecycleCommands(program: Command): void {\n program\n .command('start')\n .description('[Runtime] Start the @graphorin/server daemon.')\n .option('-c, --config <path>', 'Path to the graphorin.config file (TS / JS / JSON).')\n .option('-h, --host <host>', 'Override the configured listen host.')\n .option('-p, --port <port>', 'Override the configured listen port.', (value) =>\n Number.parseInt(value, 10),\n )\n .option(\n '--secrets-source <kind>',\n 'Override secrets.source: auto | keyring | encrypted-file | env (DEC-136).',\n )\n .option('--strict-secrets', 'Refuse to fall back to a different secrets store (DEC-136).')\n .action(\n async (opts: {\n config?: string;\n host?: string;\n port?: number;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - running with no implicit network calls.\\n',\n );\n }\n await runStart({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.host !== undefined ? { host: opts.host } : {}),\n ...(opts.port !== undefined ? { port: opts.port } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n });\n },\n );\n\n program\n .command('init')\n .description(\n '[Bootstrap] Generate a fresh graphorin.config.ts + the server pepper (mint tokens afterwards with token create).',\n )\n .option('-o, --out <path>', 'Output path; defaults to ./graphorin.config.ts.')\n .option('--non-interactive', 'Accept defaults / env vars without prompting.', false)\n .option(\n '--cloud-consent <tier>',\n 'Cloud-upload consent tier: public-only | public-and-internal | all-with-warnings.',\n )\n .option('--encrypted', 'Enable storage encryption opt-in.')\n .option('--no-encrypted', 'Disable storage encryption opt-in.')\n .action(\n async (opts: {\n out?: string;\n nonInteractive?: boolean;\n cloudConsent?: 'public-only' | 'public-and-internal' | 'all-with-warnings';\n encrypted?: boolean;\n }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - init never reaches the network.\\n',\n );\n }\n await runInit({\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.nonInteractive !== undefined ? { nonInteractive: opts.nonInteractive } : {}),\n ...(opts.cloudConsent !== undefined ? { cloudConsent: opts.cloudConsent } : {}),\n ...(opts.encrypted !== undefined ? { encrypted: opts.encrypted } : {}),\n });\n },\n );\n\n program\n .command('migrate')\n .description(\n '[Maintenance] Apply pending storage migrations against the configured SQLite store.',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--target <version>', 'Reserved for the Phase 15 partial-migration runner.')\n .action(async (opts: { config?: string; target?: string }) => {\n if (isOfflineMode()) {\n process.stderr.write(\n '[graphorin/cli] GRAPHORIN_OFFLINE=1 - migrate is a local-only operation.\\n',\n );\n }\n await runMigrate({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.target !== undefined ? { target: opts.target } : {}),\n });\n });\n}\n\nfunction registerDoctorCommand(program: Command): void {\n program\n .command('doctor')\n .description('[Diagnostics] Health check (perms + secrets + encryption + systemd).')\n .option('--fix-perms', 'Repair drifted POSIX file modes.')\n .option('--check-perms', 'Run the file-perms check.')\n .option('--check-secrets', 'Run the secrets-store check.')\n .option('--check-encryption', 'Run the audit-encryption check.')\n .option('--check-systemd', 'Run the systemd-hardening check (Linux only).')\n .option('--all', 'Run every check.')\n .option('--json', 'Emit a structured JSON report on stdout.')\n .action(\n async (opts: {\n fixPerms?: boolean;\n checkPerms?: boolean;\n checkSecrets?: boolean;\n checkEncryption?: boolean;\n checkSystemd?: boolean;\n all?: boolean;\n json?: boolean;\n }) => {\n await runDoctor({\n ...(opts.fixPerms !== undefined ? { fixPerms: opts.fixPerms } : {}),\n ...(opts.checkPerms !== undefined ? { checkPerms: opts.checkPerms } : {}),\n ...(opts.checkSecrets !== undefined ? { checkSecrets: opts.checkSecrets } : {}),\n ...(opts.checkEncryption !== undefined ? { checkEncryption: opts.checkEncryption } : {}),\n ...(opts.checkSystemd !== undefined ? { checkSystemd: opts.checkSystemd } : {}),\n ...(opts.all !== undefined ? { all: opts.all } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTokenCommands(program: Command): void {\n const token = program.command('token').description('[Auth] Manage server auth tokens.');\n token\n .command('create')\n .description('Mint a new token. Prints the raw value once.')\n .requiredOption('--scopes <list>', 'Comma-separated scope list.')\n .option('--label <name>', 'Optional label.')\n .option('--expires-in <duration>', 'Duration string: 30d, 12h, 90m, 45s.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n scopes: string;\n label?: string;\n expiresIn?: string;\n env?: 'live' | 'test';\n config?: string;\n json?: boolean;\n }) => {\n await runTokenCreate({\n scopes: opts.scopes\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n ...(opts.label !== undefined ? { label: opts.label } : {}),\n ...(opts.expiresIn !== undefined ? { expiresIn: opts.expiresIn } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n token\n .command('list')\n .description('List token metadata.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--include-revoked', 'Include revoked tokens.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; includeRevoked?: boolean; json?: boolean }) => {\n await runTokenList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.includeRevoked !== undefined ? { includeRevoked: opts.includeRevoked } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('revoke <id>')\n .description('Revoke a single token.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTokenRevoke({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('rotate <id>')\n .description('Revoke + reissue a token with the same scopes.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (id: string, opts: { config?: string; env?: 'live' | 'test'; json?: boolean }) => {\n await runTokenRotate({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n token\n .command('rekey')\n .description('Re-issue every active token (use after a known compromise).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--env <env>', 'Token environment: live | test.', 'live')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; env?: 'live' | 'test'; json?: boolean }) => {\n await runTokenRekey({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n token\n .command('verify <token>')\n .description('Offline checksum verification - never consults the store.')\n .option('--prefix <prefix>', 'Override the expected token prefix.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((tok: string, opts: { prefix?: string; json?: boolean }) => {\n runTokenVerify({\n token: tok,\n ...(opts.prefix !== undefined ? { prefix: opts.prefix } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerSecretsCommands(program: Command): void {\n const secrets = program\n .command('secrets')\n .description('[Auth] Manage secrets in the configured store.');\n const commonOpts = (cmd: Command): Command =>\n cmd\n .option('--secrets-source <kind>', 'auto | keyring | encrypted-file | env (DEC-136).')\n .option('--strict-secrets', 'Refuse to fall back to a different secrets store.')\n .option('--json', 'Emit a structured JSON document on stdout.');\n commonOpts(secrets.command('list').description('List secret metadata.')).action(\n async (opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n }) => {\n await runSecretsList({\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('get <key>')\n .description('Read a secret. Use --reveal to print the bytes.')\n .option('--reveal', 'Print the raw value.'),\n ).action(\n async (\n key: string,\n opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n reveal?: boolean;\n },\n ) => {\n await runSecretsGet({\n key,\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n ...(opts.reveal !== undefined ? { reveal: opts.reveal } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('set <key>')\n .description('Persist a secret. Pass --value <v> or --from-stdin.')\n .option('--value <v>', 'Inline value.')\n .option('--from-stdin', 'Read the value from stdin.'),\n ).action(\n async (\n key: string,\n opts: {\n value?: string;\n fromStdin?: boolean;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsSet({\n key,\n ...(opts.value !== undefined ? { value: opts.value } : {}),\n ...(opts.fromStdin !== undefined ? { fromStdin: opts.fromStdin } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(secrets.command('delete <key>').description('Delete a secret.')).action(\n async (\n key: string,\n opts: {\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsDelete({\n key,\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n commonOpts(\n secrets\n .command('ref <uri>')\n .description('Test resolution of a SecretRef URI.')\n .option('--reveal', 'Include the resolved value in the report.'),\n ).action(async (uri: string, opts: { reveal?: boolean; json?: boolean }) => {\n await runSecretsRef({\n uri,\n ...(opts.reveal !== undefined ? { reveal: opts.reveal } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n commonOpts(\n secrets\n .command('rotate <key>')\n .description('Replace an existing secret with a fresh value.')\n .option('--new-value <v>', 'Inline new value.')\n .option('--from-stdin', 'Read the new value from stdin.'),\n ).action(\n async (\n key: string,\n opts: {\n newValue?: string;\n fromStdin?: boolean;\n secretsSource?: 'auto' | 'keyring' | 'encrypted-file' | 'env';\n strictSecrets?: boolean;\n json?: boolean;\n },\n ) => {\n await runSecretsRotate({\n key,\n ...(opts.newValue !== undefined ? { newValue: opts.newValue } : {}),\n ...(opts.fromStdin !== undefined ? { fromStdin: opts.fromStdin } : {}),\n ...(opts.secretsSource !== undefined ? { secretsSource: opts.secretsSource } : {}),\n ...(opts.strictSecrets !== undefined ? { strictSecrets: opts.strictSecrets } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerStorageCommands(program: Command): void {\n const storage = program\n .command('storage')\n .description('[Storage] SQLite + encryption-at-rest commands.');\n storage\n .command('status')\n .description('Report current store state + cipher peer availability.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runStorageStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n storage\n .command('encrypt')\n .description(\n 'Encrypt the store. Requires the @graphorin/store-sqlite-encrypted sub-pack (Phase 16).',\n )\n .requiredOption('--passphrase-from <ref>', 'SecretRef URI for the new passphrase.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option(\n '--target-path <path>',\n 'Override the encrypted output path. Default <storage>.encrypted.',\n )\n .option(\n '--swap',\n 'Atomically swap the encrypted output into the storage path (REQUIRES a stopped server - refused when another process holds the DB); original kept under .bak.<ts>.',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n passphraseFrom: string;\n config?: string;\n targetPath?: string;\n swap?: boolean;\n json?: boolean;\n }) => {\n await runStorageEncrypt({\n passphraseFrom: opts.passphraseFrom,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.targetPath !== undefined ? { targetPath: opts.targetPath } : {}),\n ...(opts.swap === true ? { swap: true } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('rekey')\n .description('Rekey an already-encrypted store.')\n .requiredOption('--old-passphrase-from <ref>', 'SecretRef URI for the existing passphrase.')\n .requiredOption('--new-passphrase-from <ref>', 'SecretRef URI for the new passphrase.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n oldPassphraseFrom: string;\n newPassphraseFrom: string;\n config?: string;\n json?: boolean;\n }) => {\n await runStorageRekey({\n oldPassphraseFrom: opts.oldPassphraseFrom,\n newPassphraseFrom: opts.newPassphraseFrom,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('backup')\n .description(\n 'Online, consistent copy of the store via the page-level backup API (safe under a live writer; never use VACUUM INTO).',\n )\n .argument('<dest>', 'Destination file path for the backup copy.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--overwrite', 'Replace an existing destination file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (dest: string, opts: { config?: string; overwrite?: boolean; json?: boolean }) => {\n await runStorageBackup({\n dest,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.overwrite === true ? { overwrite: true } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n storage\n .command('compact')\n .description(\n 'Return pruned pages to the OS via batched incremental_vacuum (rowid-safe, unlike the forbidden VACUUM). Requires a database created with auto_vacuum=2; reports the high-water-mark limitation honestly on older files.',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option(\n '--batch-pages <n>',\n 'Free pages released per incremental_vacuum batch (keeps writer locks short). Default 1000.',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; batchPages?: string; json?: boolean }) => {\n await runStorageCompact({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.batchPages !== undefined ? { batchPages: Number(opts.batchPages) } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n storage\n .command('cleanup-backups')\n .description('Drop stale .bak / .tmp.<ts> files left by previous encrypt / rekey runs.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--dry-run', 'Print what would be removed without touching the filesystem.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; dryRun?: boolean; json?: boolean }) => {\n await runStorageCleanupBackups({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerAuditCommands(program: Command): void {\n const audit = program\n .command('audit')\n .description('[Storage] Operate on the encrypted audit log.');\n audit\n .command('verify')\n .description('Replay the chain and report the first broken link (if any).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuditVerify({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n audit\n .command('prune')\n .description('Drop entries older than --before (cutoff is required).')\n .requiredOption('--before <date>', 'ISO date / epoch ms cutoff.')\n .option('--retain <n>', 'Minimum number of entries that must survive.', (v) =>\n Number.parseInt(v, 10),\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before: string; retain?: number; config?: string; json?: boolean }) => {\n await runAuditPrune({\n before: opts.before,\n ...(opts.retain !== undefined ? { retain: opts.retain } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n audit\n .command('export')\n .description('Stream every audit entry as JSONL into --to.')\n .requiredOption('--to <file>', 'Output path.')\n .option('--from-seq <n>', 'Lower bound (inclusive).', (v) => Number.parseInt(v, 10))\n .option('--to-seq <n>', 'Upper bound (inclusive).', (v) => Number.parseInt(v, 10))\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n to: string;\n fromSeq?: number;\n toSeq?: number;\n config?: string;\n json?: boolean;\n }) => {\n await runAuditExport({\n to: opts.to,\n ...(opts.fromSeq !== undefined ? { fromSeq: opts.fromSeq } : {}),\n ...(opts.toSeq !== undefined ? { toSeq: opts.toSeq } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerMemoryCommands(program: Command): void {\n const memory = program\n .command('memory')\n .description('[Storage] Long-term memory operator commands.');\n memory\n .command('status')\n .description('Report counts + active embedder + migration state.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runMemoryStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('migrate')\n .description('Embedder swap. Requires --embedders module that exports the factories.')\n .requiredOption('--from <id>', 'Source embedder id.')\n .requiredOption('--to <id>', 'Target embedder id.')\n .requiredOption('--strategy <s>', 'lock-on-first | auto-migrate | multi-active.')\n .option('--embedders <path>', 'Path to a module exporting embedder factories.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(\n async (opts: {\n from: string;\n to: string;\n strategy: string;\n embedders?: string;\n config?: string;\n }) => {\n await runMemoryMigrate({\n from: opts.from,\n to: opts.to,\n strategy: opts.strategy as 'lock-on-first' | 'auto-migrate' | 'multi-active',\n ...(opts.embedders !== undefined ? { embeddersModule: opts.embedders } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n },\n );\n memory\n .command('inspect')\n .description('Inspect one fact: supersede chain, quarantine, conflicts, citing insights.')\n .argument('<factId>', 'Id of the fact to inspect.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (factId: string, opts: { config?: string; json?: boolean }) => {\n await runMemoryInspect({\n factId,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('activity')\n .description('Store-wide consolidator / reflection activity: quarantine, history, conflicts.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--limit <n>', 'Cap on recent history / conflict rows (default 20).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; limit?: string; json?: boolean }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryActivity({\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('prune-history')\n .description(\n 'Delete memory_history rows older than the threshold (storage-cost hygiene; purge() already scrubs sensitive text).',\n )\n .requiredOption(\n '--older-than <duration|date>',\n \"Age threshold: a duration ('30d', '12h') or a past ISO date. Mandatory - destructive.\",\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { olderThan: string; config?: string; json?: boolean }) => {\n await runMemoryPruneHistory({\n olderThan: opts.olderThan,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('why')\n .description(\n 'Explain why facts were recalled (ranking signals) from the persisted recall spans.',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--session <id>', \"Restrict to one session's recall spans.\")\n .option('--limit <n>', 'Cap on the most-recent recall spans (default 5).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; session?: string; limit?: string; json?: boolean }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryWhy({\n ...(opts.session !== undefined ? { sessionId: opts.session } : {}),\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n memory\n .command('review')\n .description('List quarantined memory by tier, or promote a reviewed item with --promote.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--limit <n>', 'Cap on rows listed per type (default 20).')\n .option('--promote <id>', 'Promote this quarantined memory id out of quarantine.')\n .option('--reason <text>', 'Audit reason recorded with the promotion.')\n .option('--force', 'Override the injection-refusal gate (operator action, after review).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n config?: string;\n limit?: string;\n promote?: string;\n reason?: string;\n force?: boolean;\n json?: boolean;\n }) => {\n const limit = opts.limit !== undefined ? Number.parseInt(opts.limit, 10) : undefined;\n await runMemoryReview({\n ...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),\n ...(opts.promote !== undefined ? { promote: opts.promote } : {}),\n ...(opts.reason !== undefined ? { reason: opts.reason } : {}),\n ...(opts.force !== undefined ? { force: opts.force } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerConsolidatorCommands(program: Command): void {\n const c = program\n .command('consolidator')\n .description('[Storage] Inspect and steer the memory consolidator.');\n c.command('status')\n .description('Current tier hint + DLQ size + recent run history.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runConsolidatorStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('set-tier <tier>')\n .description(\n 'Runtime tier switching is not wired yet: reports UNSUPPORTED (exit 2) and points at consolidator.tier in the config (IP-4).',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (tier: string, opts: { config?: string; json?: boolean }) => {\n await runConsolidatorSetTier({\n tier: tier as 'free' | 'cheap' | 'standard' | 'full' | 'custom',\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('stop')\n .description(\n 'Runtime pause is not wired yet: reports UNSUPPORTED (exit 2); stop the server process to stop consolidation (IP-4).',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runConsolidatorStop({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('dlq-list')\n .description('List dead-letter batches (all users; narrow with --user).')\n .option('--user <id>', 'Only batches scoped to this user id.')\n .option('--limit <n>', 'Maximum rows to list.', '100')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { user?: string; limit?: string; config?: string; json?: boolean }) => {\n await runConsolidatorDlqList({\n ...(opts.user !== undefined ? { user: opts.user } : {}),\n ...(opts.limit !== undefined ? { limit: Number(opts.limit) } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n c.command('dlq-clear')\n .description(\n 'Delete dead-letter batches. Default: only EXHAUSTED batches (retries used up); batches awaiting retry need --exhausted-only=false.',\n )\n .option('--exhausted-only [bool]', 'Only exhausted batches (default true).', 'true')\n .option('--before <date>', 'Only batches that failed before this ISO date / epoch ms.')\n .option('--id <id>', 'Clear one batch by id.')\n .option('--user <id>', 'Only batches scoped to this user id.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: {\n exhaustedOnly?: string | boolean;\n before?: string;\n id?: string;\n user?: string;\n config?: string;\n json?: boolean;\n }) => {\n await runConsolidatorDlqClear({\n exhaustedOnly: String(opts.exhaustedOnly ?? 'true') !== 'false',\n ...(opts.before !== undefined ? { before: opts.before } : {}),\n ...(opts.id !== undefined ? { id: opts.id } : {}),\n ...(opts.user !== undefined ? { user: opts.user } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTriggersCommands(program: Command): void {\n const t = program\n .command('triggers')\n .description('[Storage] Operate on the durable trigger registry.');\n t.command('list')\n .description('Every persisted trigger.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runTriggersList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('status <id>')\n .description('Single-trigger detail.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersStatus({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('fire <id>')\n .description('Operator-fired side-effect (admin only).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersFire({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('disable <id>')\n .description('Flip the disabled column on the registry row.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (id: string, opts: { config?: string; json?: boolean }) => {\n await runTriggersDisable({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('prune')\n .description('Drop disabled triggers older than --before.')\n .option(\n '--before <date>',\n 'ISO date / epoch ms cutoff. Defaults to 0 (drop every disabled row).',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before?: string; config?: string; json?: boolean }) => {\n await runTriggersPrune({\n ...(opts.before !== undefined ? { before: opts.before } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerAuthCommands(program: Command): void {\n const a = program.command('auth').description('[Auth] Outbound OAuth (e.g. for MCP servers).');\n a.command('login')\n .description('Drive an interactive login flow.')\n .requiredOption('--server <url>', 'Authorization server URL.')\n .option('--server-id <id>', 'Override the persisted server identifier.')\n .option('--scope <scope>', 'OAuth scope.')\n .option('--device-flow', 'Use the Device Authorization Grant.')\n .option('--client-id <id>', 'Pre-existing client identifier (skip DCR).')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(\n async (opts: {\n server: string;\n serverId?: string;\n scope?: string;\n deviceFlow?: boolean;\n clientId?: string;\n config?: string;\n }) => {\n await runAuthLogin({\n serverUrl: opts.server,\n ...(opts.serverId !== undefined ? { serverId: opts.serverId } : {}),\n ...(opts.scope !== undefined ? { scope: opts.scope } : {}),\n ...(opts.deviceFlow !== undefined ? { deviceFlow: opts.deviceFlow } : {}),\n ...(opts.clientId !== undefined ? { clientId: opts.clientId } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n },\n );\n a.command('list')\n .description('List persisted OAuth sessions.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuthList({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n a.command('refresh <id>')\n .description('Refresh a session.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(async (id: string, opts: { config?: string }) => {\n await runAuthRefresh({\n id,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n });\n a.command('revoke <id>')\n .description('Revoke a session.')\n .option('--reason <text>', 'Optional reason persisted in the audit log.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .action(async (id: string, opts: { reason?: string; config?: string }) => {\n await runAuthRevoke({\n id,\n ...(opts.reason !== undefined ? { reason: opts.reason } : {}),\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n });\n });\n a.command('status')\n .description('OAuth subsystem snapshot.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runAuthStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerPricingCommands(program: Command): void {\n const p = program.command('pricing').description('[Catalogue] Bundled LLM pricing snapshot.');\n p.command('status')\n .description('Show bundled snapshot version + entry count + digest.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runPricingStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n p.command('refresh')\n .description('Pull a fresh snapshot from --url (network).')\n .requiredOption('--url <url>', 'Snapshot URL.')\n .option('--out <file>', 'Optional path to write the refreshed snapshot to.')\n .option(\n '--format <format>',\n \"Body format: 'auto' (default), 'graphorin', or 'genai-prices'.\",\n 'auto',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { url: string; out?: string; format?: string; json?: boolean }) => {\n const format = opts.format ?? 'auto';\n if (format !== 'auto' && format !== 'graphorin' && format !== 'genai-prices') {\n process.stderr.write(\n `graphorin pricing refresh: invalid --format '${format}' (expected auto | graphorin | genai-prices)\\n`,\n );\n process.exit(2);\n }\n await runPricingRefresh({\n url: opts.url,\n format,\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('diff')\n .description('Diff a supplied snapshot against the bundled one.')\n .requiredOption('--snapshot <file>', 'JSON file containing a PricingSnapshot.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { snapshot: string; json?: boolean }) => {\n await runPricingDiff({\n snapshot: opts.snapshot,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('lookup')\n .description('Print the per-token price for a single (provider, model) pair.')\n .requiredOption('--provider <name>', 'Provider id.')\n .requiredOption('--model <id>', 'Model id.')\n .option('--region <region>', 'Optional region.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { provider: string; model: string; region?: string; json?: boolean }) => {\n runPricingLookup({\n provider: opts.provider,\n model: opts.model,\n ...(opts.region !== undefined ? { region: opts.region } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n p.command('missing')\n .description('Report (provider, model) pairs absent from the bundled snapshot.')\n .requiredOption('--spans <file>', 'JSON file containing trace spans (array of { attributes }).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { spans: string; json?: boolean }) => {\n await runPricingMissing({\n spans: opts.spans,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerSkillsCommands(program: Command): void {\n const s = program\n .command('skills')\n .description('[Catalogue] Manage operator-managed skill packages.');\n s.command('install <source>')\n .description('Install a skill from npm:<name>[@version] or git:<url>.')\n .option('--version <version>', 'npm version pin.')\n .option('--ref <ref>', 'git ref (branch / tag / sha).')\n .option('--trust-level <level>', 'trusted | trusted-with-scripts | untrusted.')\n .option('--cwd <dir>', 'Working directory for npm installs.')\n .option('--dry-run', 'Skip the install; run the policy + audit pipeline only.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (\n source: string,\n opts: {\n version?: string;\n ref?: string;\n trustLevel?: 'trusted' | 'trusted-with-scripts' | 'untrusted';\n cwd?: string;\n dryRun?: boolean;\n json?: boolean;\n },\n ) => {\n await runSkillsInstall({\n source,\n ...(opts.version !== undefined ? { version: opts.version } : {}),\n ...(opts.ref !== undefined ? { ref: opts.ref } : {}),\n ...(opts.trustLevel !== undefined ? { trustLevel: opts.trustLevel } : {}),\n ...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),\n ...(opts.dryRun !== undefined ? { dryRun: opts.dryRun } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n s.command('inspect <name>')\n .description('Print a single recorded installation.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (name: string, opts: { json?: boolean }) => {\n await runSkillsInspect({\n name,\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n s.command('audit')\n .description('Audit every recorded installation in this process.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runSkillsAudit({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n s.command('migrate-frontmatter')\n .description(\n 'Migrate legacy graphorin-* frontmatter fields onto upstream equivalents (DEC-156).',\n )\n .option('--path <dir>', 'Directory to walk. Defaults to cwd.')\n .option('--recursive', 'Walk subdirectories.')\n .option('--apply', 'Actually rewrite files (default: dry-run).')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (opts: { path?: string; recursive?: boolean; apply?: boolean; json?: boolean }) => {\n await runSkillsMigrateFrontmatter({\n ...(opts.path !== undefined ? { path: opts.path } : {}),\n ...(opts.recursive !== undefined ? { recursive: opts.recursive } : {}),\n ...(opts.apply !== undefined ? { apply: opts.apply } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTracesCommands(program: Command): void {\n const t = program.command('traces').description('[Diagnostics] Operate on persisted spans.');\n t.command('status')\n .description('Count persisted spans + report their time range.')\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { config?: string; json?: boolean }) => {\n await runTracesStatus({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n t.command('prune')\n .description('Delete spans that FINISHED before the cutoff (cutoff is required).')\n .requiredOption(\n '--before <date>',\n 'ISO date / epoch ms cutoff (spans ending strictly before it are deleted).',\n )\n .option('-c, --config <path>', 'Path to the graphorin.config file.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (opts: { before: string; config?: string; json?: boolean }) => {\n await runTracesPrune({\n before: opts.before,\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerMigrateExportCommand(program: Command): void {\n program\n .command('migrate-export <input>')\n .description('[Storage] Migrate a session export file to the current schema (DEC-155).')\n .requiredOption('--to <file>', 'Output path.')\n .option('--to-schema <version>', 'Target schema version.', '1.0')\n .option('--writer <id>', 'Writer identifier surfaced on the meta header.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n async (\n input: string,\n opts: { to: string; toSchema?: string; writer?: string; json?: boolean },\n ) => {\n await runMigrateExport({\n input,\n to: opts.to,\n ...(opts.toSchema !== undefined ? { toSchema: opts.toSchema } : {}),\n ...(opts.writer !== undefined ? { writer: opts.writer } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerMigrateConfigCommand(program: Command): void {\n program\n .command('migrate-config <input>')\n .description('[Bootstrap] Migrate an old config file to the current schema.')\n .option('--out <file>', 'Output path. Defaults to <input>.migrated.json next to the source.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(async (input: string, opts: { out?: string; json?: boolean }) => {\n await runMigrateConfig({\n input,\n ...(opts.out !== undefined ? { out: opts.out } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n });\n}\n\nfunction registerGuardCommands(program: Command): void {\n const g = program\n .command('guard')\n .description('[Diagnostics] Inspect the memory-modification guard.');\n g.command('status')\n .description('Print the four guard tiers and their variants.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runGuardStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n g.command('explain <toolName>')\n .description(\n 'Derive the tier the classifier would assign to a tool with the supplied metadata.',\n )\n .option('--tags <list>', 'Comma-separated tag list.')\n .option('--secrets-allowed <list>', 'Comma-separated secret allowlist.')\n .option('--trust-level <level>', 'built-in | user-defined | trusted | untrusted.')\n .option(\n '--explicit-tier <tier>',\n 'pure | side-effecting-no-memory | memory-aware | unknown | untrusted.',\n )\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action(\n (\n toolName: string,\n opts: {\n tags?: string;\n secretsAllowed?: string;\n trustLevel?: 'built-in' | 'user-defined' | 'trusted' | 'untrusted';\n explicitTier?:\n | 'pure'\n | 'side-effecting-no-memory'\n | 'memory-aware'\n | 'unknown'\n | 'untrusted';\n json?: boolean;\n },\n ) => {\n runGuardExplain({\n toolName,\n ...(opts.tags !== undefined\n ? {\n tags: opts.tags\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n }\n : {}),\n ...(opts.secretsAllowed !== undefined\n ? {\n secretsAllowed: opts.secretsAllowed\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean),\n }\n : {}),\n ...(opts.trustLevel !== undefined ? { trustLevel: opts.trustLevel } : {}),\n ...(opts.explicitTier !== undefined ? { explicitTier: opts.explicitTier } : {}),\n ...(opts.json !== undefined ? { json: opts.json } : {}),\n });\n },\n );\n}\n\nfunction registerTelemetryCommands(program: Command): void {\n const t = program\n .command('telemetry')\n .description('[Diagnostics] Telemetry policy (zero-default per ADR-041).');\n t.command('status')\n .description('Always reports disabled.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryStatus({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('enable')\n .description('Refuses; opt-in collector is on the v0.2+ roadmap.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryEnable({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('disable')\n .description('No-op; telemetry is always disabled.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryDisable({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n t.command('inspect')\n .description('Informational summary of the zero-default promise.')\n .option('--json', 'Emit a structured JSON document on stdout.')\n .action((opts: { json?: boolean }) => {\n runTelemetryInspect({ ...(opts.json !== undefined ? { json: opts.json } : {}) });\n });\n}\n\nfunction registerToolsCommands(program: Command): void {\n const tools = program.command('tools').description('[Catalogue] Operate on the tool registry.');\n tools\n .command('lint')\n .description(\n [\n 'Text-based static scan of every tool({...}) registration; per-tool grader + threshold gate (RB-49).',\n '',\n 'Grader rubric (40 + 30 + 30 = 100 points):',\n ' description axis (0..40): 0 if missing/placeholder/<20 chars; 16/24/32/40 by length; degenerate text (under 4 unique words or one word over half the text) caps at 16 (W-044).',\n ' examples axis (0..30): 0 if none or >5; 12 base + 6 per additional, cap 30; -6 per PII.',\n ' parameter naming (0..30): 30 base; -30/N per ambiguous name; -10/N per numeric suffix.',\n '',\n 'Exit codes (CI-friendly):',\n ' 0 every tool meets or exceeds --threshold.',\n ' 1 at least one tool falls below --threshold.',\n ' 2 invocation could not start (config missing, walker failed).',\n ].join('\\n'),\n )\n .option('-c, --config <path>', 'Optional tsconfig.json whose include overrides the file glob.')\n .option('--threshold <n>', 'Minimum acceptable per-tool score (default 60).', (v) =>\n Number.parseInt(v, 10),\n )\n .option('--format <fmt>', 'text | json (default text).')\n .option('--source <pattern>', 'File glob override (e.g. src/skills/**/tools/*.ts).')\n .action(\n async (opts: {\n config?: string;\n threshold?: number;\n format?: 'text' | 'json';\n source?: string;\n }) => {\n await runToolsLint({\n ...(opts.config !== undefined ? { config: opts.config } : {}),\n ...(opts.threshold !== undefined ? { threshold: opts.threshold } : {}),\n ...(opts.format !== undefined ? { format: opts.format } : {}),\n ...(opts.source !== undefined ? { source: opts.source } : {}),\n });\n },\n );\n}\n\nmain().catch((err) => {\n process.stderr.write(`[graphorin/cli] ${(err as Error).message}\\n`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GA,eAAe,OAAsB;CACnC,MAAM,UAAU,IAAI,SAAS;AAC7B,SACG,KAAK,YAAY,CACjB,YACC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK,CACb,CACA,QAAQ,QAAQ;AAEnB,2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AAW,GAAG,EAAE;GACrE,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE;GAC5D,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,EAAE;GAC7D,CAAC;GAEL;;AAGL,MAAM,CAAC,OAAO,QAAQ;AACpB,SAAQ,OAAO,MAAM,mBAAoB,IAAc,QAAQ,IAAI;AACnE,SAAQ,KAAK,EAAE;EACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","names":[],"sources":["../../src/commands/audit.ts"],"sourcesContent":[],"mappings":";;;;;AA6JA;AAA8C,UA/G7B,kBAAA,SAA2B,mBA+GE,CAAA;EAA6B,SAAA,MAAA,CAAA,EAAA,MAAA;;;UA1G1D,iBAAA;;;;;;;;;;;;;;;;iBAaK,cAAA,WAAwB,qBAA0B,QAAQ;;UAoC/D,iBAAA,SAA0B;;;;;;;;;;iBAWrB,aAAA,UAAuB,oBAAoB,QAAQ;;UA6BxD,kBAAA,SAA2B;;;;;;UAO3B,iBAAA;;;;;;;;;iBAUK,cAAA,UAAwB,qBAAqB,QAAQ"}
1
+ {"version":3,"file":"audit.d.ts","names":[],"sources":["../../src/commands/audit.ts"],"sourcesContent":[],"mappings":";;;;;AA0KA;AAA8C,UA5H7B,kBAAA,SAA2B,mBA4HE,CAAA;EAA6B,SAAA,MAAA,CAAA,EAAA,MAAA;;;UAvH1D,iBAAA;;;;;;;;;;;;;;;;iBAaK,cAAA,WAAwB,qBAA0B,QAAQ;;UAwC/D,iBAAA,SAA0B;;;;;;;;;;iBAWrB,aAAA,UAAuB,oBAAoB,QAAQ;;UAsCxD,kBAAA,SAA2B;;;;;;UAO3B,iBAAA;;;;;;;;;iBAUK,cAAA,UAAwB,qBAAqB,QAAQ"}
@@ -58,8 +58,8 @@ async function runAuditVerify(options = {}) {
58
58
  print(brand(`audit chain ${statusMarker("fail")} broken at seq ${out.broken?.seq}`));
59
59
  print(` expected prevHash=${out.broken?.expected}`);
60
60
  print(` actual prevHash=${out.broken?.actual}`);
61
- process.exitCode = EXIT_CODES.RECOVERABLE_FAILURE;
62
61
  });
62
+ if (!out.ok) process.exitCode = EXIT_CODES.RECOVERABLE_FAILURE;
63
63
  return out;
64
64
  } finally {
65
65
  await ctx.close();
@@ -81,6 +81,7 @@ async function runAuditPrune(options) {
81
81
  return;
82
82
  }
83
83
  print(brand(`pruned ${result.deleted} audit entries (cutoff=${new Date(cutoff).toISOString()}, surviving from seq=${result.firstSurvivingSeq ?? "<empty>"})`));
84
+ print(brand("note: Merkle checkpoints signed before this prune no longer verify (the chain was re-rooted). Sign and distribute a fresh checkpoint now (signAuditCheckpoint) and mark the old anchors superseded - see the \"Retention and anchoring\" runbook in the security guide."));
84
85
  });
85
86
  return result;
86
87
  } finally {
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","names":["result: AuditChainVerifyResult","out: AuditVerifyResult","lines: string[]","out: AuditExportResult","passphrase: SecretValue"],"sources":["../../src/commands/audit.ts"],"sourcesContent":["/**\n * `graphorin audit` - operate on the tamper-evident audit log\n * (`audit.db`).\n *\n * Surface (per Phase 15 § Audit):\n *\n * - `graphorin audit verify` - full hash chain integrity check.\n * - `graphorin audit prune --before <date>` - drop entries older than\n * a cutoff while preserving the surviving suffix's chain integrity.\n * - `graphorin audit export --to <file>` - stream every entry as JSONL.\n *\n * The CLI opens `audit.db` through the framework default binding\n * registered by `@graphorin/server` (`ensureStoreAuditBinding()`); it\n * never re-implements the cipher path.\n *\n * @packageDocumentation\n */\n\nimport { writeFile } from 'node:fs/promises';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport process from 'node:process';\n\nimport {\n type AuditChainVerifyResult,\n exportAudit,\n openAuditDb,\n type PruneAuditResult,\n pruneAudit,\n resolveSecret,\n type SecretValue,\n type StoredAuditEntry,\n verifyAuditChain,\n} from '@graphorin/security';\nimport { ensureStoreAuditBinding, parseServerConfig } from '@graphorin/server';\n\nimport { EXIT_CODES } from '../internal/exit.js';\nimport { loadConfig } from '../internal/load-config.js';\nimport {\n brand,\n type CommonOutputOptions,\n defaultPrintSink,\n emitReport,\n statusMarker,\n} from '../internal/output.js';\n\n/** @stable */\nexport interface AuditCommonOptions extends CommonOutputOptions {\n readonly config?: string;\n}\n\n/** @stable */\nexport interface AuditVerifyResult {\n readonly ok: boolean;\n readonly path: string;\n readonly entries: number;\n readonly broken?: { readonly seq: number; readonly expected: string; readonly actual: string };\n}\n\n/**\n * `graphorin audit verify` - replay the chain and report the first\n * broken link (if any).\n *\n * @stable\n */\nexport async function runAuditVerify(options: AuditCommonOptions = {}): Promise<AuditVerifyResult> {\n const ctx = await openAuditContext(options);\n try {\n const result: AuditChainVerifyResult = await verifyAuditChain(ctx.auditDb);\n const out: AuditVerifyResult = result.ok\n ? Object.freeze({ ok: true, path: ctx.auditDb.path, entries: result.count })\n : Object.freeze({\n ok: false,\n path: ctx.auditDb.path,\n entries: 0,\n broken: Object.freeze({\n seq: result.brokenAt,\n expected: result.expected,\n actual: result.actual,\n }),\n });\n emitReport(options, out, () => {\n const print = options.print ?? defaultPrintSink;\n if (out.ok) {\n print(\n brand(`audit chain ${statusMarker('ok')} (${out.entries} entries verified, ${out.path})`),\n );\n return;\n }\n print(brand(`audit chain ${statusMarker('fail')} broken at seq ${out.broken?.seq}`));\n print(` expected prevHash=${out.broken?.expected}`);\n print(` actual prevHash=${out.broken?.actual}`);\n process.exitCode = EXIT_CODES.RECOVERABLE_FAILURE;\n });\n return out;\n } finally {\n await ctx.close();\n }\n}\n\n/** @stable */\nexport interface AuditPruneOptions extends AuditCommonOptions {\n /**\n * ISO-8601 date / `YYYY-MM-DD` / millis-since-epoch. The helper\n * drops entries older than this cutoff.\n */\n readonly before: string;\n /** Minimum number of entries that must survive. Default `1`. */\n readonly retain?: number;\n}\n\n/** @stable */\nexport async function runAuditPrune(options: AuditPruneOptions): Promise<PruneAuditResult> {\n const cutoff = parseCutoff(options.before);\n const ctx = await openAuditContext(options);\n try {\n const result = await pruneAudit(ctx.auditDb, {\n before: cutoff,\n ...(options.retain !== undefined ? { retain: options.retain } : {}),\n });\n emitReport(options, result, () => {\n const print = options.print ?? defaultPrintSink;\n if (result.deleted === 0) {\n print(\n brand(`no audit entries qualified for prune (cutoff=${new Date(cutoff).toISOString()}).`),\n );\n return;\n }\n print(\n brand(\n `pruned ${result.deleted} audit entries (cutoff=${new Date(cutoff).toISOString()}, surviving from seq=${result.firstSurvivingSeq ?? '<empty>'})`,\n ),\n );\n });\n return result;\n } finally {\n await ctx.close();\n }\n}\n\n/** @stable */\nexport interface AuditExportOptions extends AuditCommonOptions {\n readonly to: string;\n readonly fromSeq?: number;\n readonly toSeq?: number;\n}\n\n/** @stable */\nexport interface AuditExportResult {\n readonly path: string;\n readonly rows: number;\n}\n\n/**\n * `graphorin audit export --to <file>` - stream every entry as JSONL.\n *\n * @stable\n */\nexport async function runAuditExport(options: AuditExportOptions): Promise<AuditExportResult> {\n const cwd = process.cwd();\n const targetPath = isAbsolute(options.to) ? options.to : resolve(cwd, options.to);\n const ctx = await openAuditContext(options);\n try {\n const lines: string[] = [];\n const { rows } = await exportAudit(ctx.auditDb, {\n writer: { write: (line: string) => void lines.push(line) },\n ...(options.fromSeq !== undefined ? { fromSeq: options.fromSeq } : {}),\n ...(options.toSeq !== undefined ? { toSeq: options.toSeq } : {}),\n });\n await writeFile(targetPath, lines.join(''), { mode: 0o600 });\n const out: AuditExportResult = Object.freeze({ path: targetPath, rows });\n emitReport(options, out, () => {\n const print = options.print ?? defaultPrintSink;\n print(brand(`exported ${rows} audit entries to ${targetPath} (mode 0600).`));\n });\n return out;\n } finally {\n await ctx.close();\n }\n}\n\ninterface AuditContext {\n readonly auditDb: Awaited<ReturnType<typeof openAuditDb>>;\n readonly path: string;\n readonly close: () => Promise<void>;\n}\n\nasync function openAuditContext(options: AuditCommonOptions): Promise<AuditContext> {\n const loaded = await loadConfig(options.config);\n const config = parseServerConfig(loaded.config);\n if (!config.audit.enabled) {\n throw new Error(\n '[graphorin/cli] this command requires audit.enabled = true in the resolved config.',\n );\n }\n const passphraseRef = config.audit.passphraseRef ?? config.storage.encryption.passphraseRef;\n if (passphraseRef === undefined) {\n throw new Error(\n `[graphorin/cli] audit.enabled is true but no audit.passphraseRef (or storage.encryption.passphraseRef) is configured. audit.db is mandatory-encrypted by DEC-124.`,\n );\n }\n let passphrase: SecretValue;\n try {\n passphrase = await resolveSecret(passphraseRef);\n } catch (err) {\n throw new Error(\n `[graphorin/cli] failed to resolve audit passphrase '${passphraseRef}': ${(err as Error).message}`,\n { cause: err },\n );\n }\n const auditPath = config.audit.path ?? deriveAuditPath(config.storage.path);\n ensureStoreAuditBinding();\n const auditDb = await openAuditDb({\n path: auditPath,\n passphrase,\n ...(config.audit.cipher !== undefined ? { cipher: config.audit.cipher } : {}),\n });\n return Object.freeze({\n auditDb,\n path: auditPath,\n close: () => auditDb.close(),\n });\n}\n\nfunction deriveAuditPath(storagePath: string): string {\n const dir = dirname(storagePath);\n return resolve(dir, 'audit.db');\n}\n\nfunction parseCutoff(input: string): number {\n const numeric = Number(input);\n if (Number.isFinite(numeric) && numeric > 0) return numeric;\n const ms = Date.parse(input);\n if (!Number.isFinite(ms)) {\n throw new Error(\n `[graphorin/cli] --before '${input}' is not a valid ISO date or epoch-ms value.`,\n );\n }\n return ms;\n}\n\n// Internal type-only consumers - keep in scope so tree-shaking\n// preserves the entry point.\nvoid ((_e?: StoredAuditEntry) => undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,eAAsB,eAAe,UAA8B,EAAE,EAA8B;CACjG,MAAM,MAAM,MAAM,iBAAiB,QAAQ;AAC3C,KAAI;EACF,MAAMA,SAAiC,MAAM,iBAAiB,IAAI,QAAQ;EAC1E,MAAMC,MAAyB,OAAO,KAClC,OAAO,OAAO;GAAE,IAAI;GAAM,MAAM,IAAI,QAAQ;GAAM,SAAS,OAAO;GAAO,CAAC,GAC1E,OAAO,OAAO;GACZ,IAA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OAAO,MAAM,WAAW,SAAY,EAAE,QAAQ,OAAO,MAAM,QAAQ,GAAG,EAAE;EAC7E,CAAC;AACF,QAAO,OAAO,OAAO;EACnB;EACA,MAAM;EACN,aAAa,QAAQ,OAAO;EAC7B,CAAC;;AAGJ,SAAS,gBAAgB,aAA6B;AAEpD,QAAO,QADK,QAAQ,YAAY,EACZ,WAAW;;AAGjC,SAAS,YAAY,OAAuB;CAC1C,MAAM,UAAU,OAAO,MAAM;AAC7B,KAAI,OAAO,SAAS,QAAQ,IAAI,UAAU,EAAG,QAAO;CACpD,MAAM,KAAK,KAAK,MAAM,MAAM;AAC5B,KAAI,CAAC,OAAO,SAAS,GAAG,CACtB,OAAM,IAAI,MACR,6BAA6B,MAAM,8CACpC;AAEH,QAAO"}
1
+ {"version":3,"file":"audit.js","names":["result: AuditChainVerifyResult","out: AuditVerifyResult","lines: string[]","out: AuditExportResult","passphrase: SecretValue"],"sources":["../../src/commands/audit.ts"],"sourcesContent":["/**\n * `graphorin audit` - operate on the tamper-evident audit log\n * (`audit.db`).\n *\n * Surface (per Phase 15 § Audit):\n *\n * - `graphorin audit verify` - full hash chain integrity check.\n * - `graphorin audit prune --before <date>` - drop entries older than\n * a cutoff while preserving the surviving suffix's chain integrity.\n * - `graphorin audit export --to <file>` - stream every entry as JSONL.\n *\n * The CLI opens `audit.db` through the framework default binding\n * registered by `@graphorin/server` (`ensureStoreAuditBinding()`); it\n * never re-implements the cipher path.\n *\n * @packageDocumentation\n */\n\nimport { writeFile } from 'node:fs/promises';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport process from 'node:process';\n\nimport {\n type AuditChainVerifyResult,\n exportAudit,\n openAuditDb,\n type PruneAuditResult,\n pruneAudit,\n resolveSecret,\n type SecretValue,\n type StoredAuditEntry,\n verifyAuditChain,\n} from '@graphorin/security';\nimport { ensureStoreAuditBinding, parseServerConfig } from '@graphorin/server';\n\nimport { EXIT_CODES } from '../internal/exit.js';\nimport { loadConfig } from '../internal/load-config.js';\nimport {\n brand,\n type CommonOutputOptions,\n defaultPrintSink,\n emitReport,\n statusMarker,\n} from '../internal/output.js';\n\n/** @stable */\nexport interface AuditCommonOptions extends CommonOutputOptions {\n readonly config?: string;\n}\n\n/** @stable */\nexport interface AuditVerifyResult {\n readonly ok: boolean;\n readonly path: string;\n readonly entries: number;\n readonly broken?: { readonly seq: number; readonly expected: string; readonly actual: string };\n}\n\n/**\n * `graphorin audit verify` - replay the chain and report the first\n * broken link (if any).\n *\n * @stable\n */\nexport async function runAuditVerify(options: AuditCommonOptions = {}): Promise<AuditVerifyResult> {\n const ctx = await openAuditContext(options);\n try {\n const result: AuditChainVerifyResult = await verifyAuditChain(ctx.auditDb);\n const out: AuditVerifyResult = result.ok\n ? Object.freeze({ ok: true, path: ctx.auditDb.path, entries: result.count })\n : Object.freeze({\n ok: false,\n path: ctx.auditDb.path,\n entries: 0,\n broken: Object.freeze({\n seq: result.brokenAt,\n expected: result.expected,\n actual: result.actual,\n }),\n });\n emitReport(options, out, () => {\n const print = options.print ?? defaultPrintSink;\n if (out.ok) {\n print(\n brand(`audit chain ${statusMarker('ok')} (${out.entries} entries verified, ${out.path})`),\n );\n return;\n }\n print(brand(`audit chain ${statusMarker('fail')} broken at seq ${out.broken?.seq}`));\n print(` expected prevHash=${out.broken?.expected}`);\n print(` actual prevHash=${out.broken?.actual}`);\n });\n // W-002: the exit code is part of the machine contract - it must be\n // set OUTSIDE the human() callback (emitReport skips that callback\n // entirely under --json, so a broken chain exited 0 for exactly the\n // CI consumers the flag exists for).\n if (!out.ok) process.exitCode = EXIT_CODES.RECOVERABLE_FAILURE;\n return out;\n } finally {\n await ctx.close();\n }\n}\n\n/** @stable */\nexport interface AuditPruneOptions extends AuditCommonOptions {\n /**\n * ISO-8601 date / `YYYY-MM-DD` / millis-since-epoch. The helper\n * drops entries older than this cutoff.\n */\n readonly before: string;\n /** Minimum number of entries that must survive. Default `1`. */\n readonly retain?: number;\n}\n\n/** @stable */\nexport async function runAuditPrune(options: AuditPruneOptions): Promise<PruneAuditResult> {\n const cutoff = parseCutoff(options.before);\n const ctx = await openAuditContext(options);\n try {\n const result = await pruneAudit(ctx.auditDb, {\n before: cutoff,\n ...(options.retain !== undefined ? { retain: options.retain } : {}),\n });\n emitReport(options, result, () => {\n const print = options.print ?? defaultPrintSink;\n if (result.deleted === 0) {\n print(\n brand(`no audit entries qualified for prune (cutoff=${new Date(cutoff).toISOString()}).`),\n );\n return;\n }\n print(\n brand(\n `pruned ${result.deleted} audit entries (cutoff=${new Date(cutoff).toISOString()}, surviving from seq=${result.firstSurvivingSeq ?? '<empty>'})`,\n ),\n );\n // W-062: the prune re-rooted the chain - every Merkle checkpoint\n // signed BEFORE it now fails verification by design.\n print(\n brand(\n 'note: Merkle checkpoints signed before this prune no longer verify (the chain was re-rooted). ' +\n 'Sign and distribute a fresh checkpoint now (signAuditCheckpoint) and mark the old anchors superseded - ' +\n 'see the \"Retention and anchoring\" runbook in the security guide.',\n ),\n );\n });\n return result;\n } finally {\n await ctx.close();\n }\n}\n\n/** @stable */\nexport interface AuditExportOptions extends AuditCommonOptions {\n readonly to: string;\n readonly fromSeq?: number;\n readonly toSeq?: number;\n}\n\n/** @stable */\nexport interface AuditExportResult {\n readonly path: string;\n readonly rows: number;\n}\n\n/**\n * `graphorin audit export --to <file>` - stream every entry as JSONL.\n *\n * @stable\n */\nexport async function runAuditExport(options: AuditExportOptions): Promise<AuditExportResult> {\n const cwd = process.cwd();\n const targetPath = isAbsolute(options.to) ? options.to : resolve(cwd, options.to);\n const ctx = await openAuditContext(options);\n try {\n const lines: string[] = [];\n const { rows } = await exportAudit(ctx.auditDb, {\n writer: { write: (line: string) => void lines.push(line) },\n ...(options.fromSeq !== undefined ? { fromSeq: options.fromSeq } : {}),\n ...(options.toSeq !== undefined ? { toSeq: options.toSeq } : {}),\n });\n await writeFile(targetPath, lines.join(''), { mode: 0o600 });\n const out: AuditExportResult = Object.freeze({ path: targetPath, rows });\n emitReport(options, out, () => {\n const print = options.print ?? defaultPrintSink;\n print(brand(`exported ${rows} audit entries to ${targetPath} (mode 0600).`));\n });\n return out;\n } finally {\n await ctx.close();\n }\n}\n\ninterface AuditContext {\n readonly auditDb: Awaited<ReturnType<typeof openAuditDb>>;\n readonly path: string;\n readonly close: () => Promise<void>;\n}\n\nasync function openAuditContext(options: AuditCommonOptions): Promise<AuditContext> {\n const loaded = await loadConfig(options.config);\n const config = parseServerConfig(loaded.config);\n if (!config.audit.enabled) {\n throw new Error(\n '[graphorin/cli] this command requires audit.enabled = true in the resolved config.',\n );\n }\n const passphraseRef = config.audit.passphraseRef ?? config.storage.encryption.passphraseRef;\n if (passphraseRef === undefined) {\n throw new Error(\n `[graphorin/cli] audit.enabled is true but no audit.passphraseRef (or storage.encryption.passphraseRef) is configured. audit.db is mandatory-encrypted by DEC-124.`,\n );\n }\n let passphrase: SecretValue;\n try {\n passphrase = await resolveSecret(passphraseRef);\n } catch (err) {\n throw new Error(\n `[graphorin/cli] failed to resolve audit passphrase '${passphraseRef}': ${(err as Error).message}`,\n { cause: err },\n );\n }\n const auditPath = config.audit.path ?? deriveAuditPath(config.storage.path);\n ensureStoreAuditBinding();\n const auditDb = await openAuditDb({\n path: auditPath,\n passphrase,\n ...(config.audit.cipher !== undefined ? { cipher: config.audit.cipher } : {}),\n });\n return Object.freeze({\n auditDb,\n path: auditPath,\n close: () => auditDb.close(),\n });\n}\n\nfunction deriveAuditPath(storagePath: string): string {\n const dir = dirname(storagePath);\n return resolve(dir, 'audit.db');\n}\n\nfunction parseCutoff(input: string): number {\n const numeric = Number(input);\n if (Number.isFinite(numeric) && numeric > 0) return numeric;\n const ms = Date.parse(input);\n if (!Number.isFinite(ms)) {\n throw new Error(\n `[graphorin/cli] --before '${input}' is not a valid ISO date or epoch-ms value.`,\n );\n }\n return ms;\n}\n\n// Internal type-only consumers - keep in scope so tree-shaking\n// preserves the entry point.\nvoid ((_e?: StoredAuditEntry) => undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;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OAAO,QAAQ,WAAW;AAC9E,KAAI,kBAAkB,OACpB,OAAM,IAAI,MACR,oKACD;CAEH,IAAIC;AACJ,KAAI;AACF,eAAa,MAAM,cAAc,cAAc;UACxC,KAAK;AACZ,QAAM,IAAI,MACR,uDAAuD,cAAc,KAAM,IAAc,WACzF,EAAE,OAAO,KAAK,CACf;;CAEH,MAAM,YAAY,OAAO,MAAM,QAAQ,gBAAgB,OAAO,QAAQ,KAAK;AAC3E,0BAAyB;CACzB,MAAM,UAAU,MAAM,YAAY;EAChC,MAAM;EACN;EACA,GAAI,OAAO,MAAM,WAAW,SAAY,EAAE,QAAQ,OAAO,MAAM,QAAQ,GAAG,EAAE;EAC7E,CAAC;AACF,QAAO,OAAO,OAAO;EACnB;EACA,MAAM;EACN,aAAa,QAAQ,OAAO;EAC7B,CAAC;;AAGJ,SAAS,gBAAgB,aAA6B;AAEpD,QAAO,QADK,QAAQ,YAAY,EACZ,WAAW;;AAGjC,SAAS,YAAY,OAAuB;CAC1C,MAAM,UAAU,OAAO,MAAM;AAC7B,KAAI,OAAO,SAAS,QAAQ,IAAI,UAAU,EAAG,QAAO;CACpD,MAAM,KAAK,KAAK,MAAM,MAAM;AAC5B,KAAI,CAAC,OAAO,SAAS,GAAG,CACtB,OAAM,IAAI,MACR,6BAA6B,MAAM,8CACpC;AAEH,QAAO"}
@@ -37,6 +37,61 @@ declare function runConsolidatorStop(options?: ConsolidatorStopOptions): Promise
37
37
  readonly stopped: false;
38
38
  readonly unsupported: true;
39
39
  }>;
40
+ /** One dead-letter batch as surfaced by `consolidator dlq list`. @stable */
41
+ interface ConsolidatorDlqEntry {
42
+ readonly id: string;
43
+ readonly userId: string | null;
44
+ readonly phase: string | null;
45
+ readonly errorKind: string | null;
46
+ readonly retryCount: number;
47
+ readonly failedAt: string;
48
+ /** `true` when retries are exhausted (`next_retry_at IS NULL`). */
49
+ readonly exhausted: boolean;
50
+ }
51
+ /** @stable */
52
+ interface ConsolidatorDlqListOptions extends ConsolidatorCommonOptions {
53
+ /** Narrow to one user's batches (`scope_user_id`). */
54
+ readonly user?: string;
55
+ readonly limit?: number;
56
+ }
57
+ /**
58
+ * W-065: make the permanent `dead-letter queue: N` status warning
59
+ * actionable. Operator-level (DB-wide) view, like the `dlqSize`
60
+ * counter in `runConsolidatorStatus` - `listFailedBatches` on the
61
+ * store is scoped to one `SessionScope.userId`, which a CLI does not
62
+ * have; use `--user` to narrow.
63
+ *
64
+ * @stable
65
+ */
66
+ declare function runConsolidatorDlqList(options?: ConsolidatorDlqListOptions): Promise<ReadonlyArray<ConsolidatorDlqEntry>>;
67
+ /** @stable */
68
+ interface ConsolidatorDlqClearOptions extends ConsolidatorCommonOptions {
69
+ /**
70
+ * Only clear EXHAUSTED batches (`next_retry_at IS NULL`). Default
71
+ * `true` - batches still awaiting retry belong to
72
+ * `claimReadyBatches` and are only removed with an explicit
73
+ * `--exhausted-only=false`.
74
+ */
75
+ readonly exhaustedOnly?: boolean;
76
+ /** ISO date / epoch-ms: only batches that failed before this instant. */
77
+ readonly before?: string;
78
+ /** Clear one batch by id. */
79
+ readonly id?: string;
80
+ /** Narrow to one user's batches (`scope_user_id`). */
81
+ readonly user?: string;
82
+ }
83
+ /** @stable */
84
+ interface ConsolidatorDlqClearResult {
85
+ readonly removed: number;
86
+ }
87
+ /**
88
+ * W-065: clear dead-letter batches. Defaults are conservative:
89
+ * exhausted-only, all users, no age bound. The batch payload (message
90
+ * ids) is lost on delete - that is the explicit point of the command.
91
+ *
92
+ * @stable
93
+ */
94
+ declare function runConsolidatorDlqClear(options?: ConsolidatorDlqClearOptions): Promise<ConsolidatorDlqClearResult>;
40
95
  /**
41
96
  * Exit code emitted when a tier value fails validation. Re-exported
42
97
  * so the binary can surface the same code to downstream callers.
@@ -45,5 +100,5 @@ declare function runConsolidatorStop(options?: ConsolidatorStopOptions): Promise
45
100
  */
46
101
  declare const CONSOLIDATOR_INVALID_TIER_EXIT: 1;
47
102
  //#endregion
48
- export { CONSOLIDATOR_INVALID_TIER_EXIT, ConsolidatorCommonOptions, ConsolidatorSetTierOptions, ConsolidatorStatusResult, ConsolidatorStopOptions, runConsolidatorSetTier, runConsolidatorStatus, runConsolidatorStop };
103
+ export { CONSOLIDATOR_INVALID_TIER_EXIT, ConsolidatorCommonOptions, ConsolidatorDlqClearOptions, ConsolidatorDlqClearResult, ConsolidatorDlqEntry, ConsolidatorDlqListOptions, ConsolidatorSetTierOptions, ConsolidatorStatusResult, ConsolidatorStopOptions, runConsolidatorDlqClear, runConsolidatorDlqList, runConsolidatorSetTier, runConsolidatorStatus, runConsolidatorStop };
49
104
  //# sourceMappingURL=consolidator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consolidator.d.ts","names":[],"sources":["../../src/commands/consolidator.ts"],"sourcesContent":[],"mappings":";;;;;;UA8CiB,yBAAA,SAAkC;;;;UAKlC,wBAAA;sBACK;;;;;;;;;;iBAWA,qBAAA,WACX,4BACR,QAAQ;;UA6DM,0BAAA,SAAmC;iBACnC;;;iBAIK,sBAAA,UAAgC,6BAA6B;iBAClE;;;;;UAmCA,uBAAA,SAAgC;;iBAG3B,mBAAA,WACX,0BACR;;;;;;;;;;cAuCU"}
1
+ {"version":3,"file":"consolidator.d.ts","names":[],"sources":["../../src/commands/consolidator.ts"],"sourcesContent":[],"mappings":";;;;;;AA8RiB,UAhPA,yBAAA,SAAkC,mBAgPE,CAAA;EAiBpC,SAAA,MAAA,CAAA,EAAA,MAAA;AAWjB;;AAEW,UAzQM,wBAAA,CAyQN;EAAR,SAAA,QAAA,CAAA,EAxQmB,gBAwQnB;EAAO,SAAA,UAAA,EAAA,MAAA;EAiEG,SAAA,cAAA,EAAA,MAAA;;;;;;;;iBA9TS,qBAAA,WACX,4BACR,QAAQ;;UA+DM,0BAAA,SAAmC;iBACnC;;;iBAIK,sBAAA,UAAgC,6BAA6B;iBAClE;;;;;UAmCA,uBAAA,SAAgC;;iBAG3B,mBAAA,WACX,0BACR;;;;;UA8Bc,oBAAA;;;;;;;;;;;UAYA,0BAAA,SAAmC;;;;;;;;;;;;;;iBAe9B,sBAAA,WACX,6BACR,QAAQ,cAAc;;UAqDR,2BAAA,SAAoC;;;;;;;;;;;;;;;;UAiBpC,0BAAA;;;;;;;;;;iBAWK,uBAAA,WACX,8BACR,QAAQ;;;;;;;cAiEE"}