@kernel.chat/kbot 3.54.0 → 3.56.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.
package/dist/cli.js CHANGED
@@ -2681,46 +2681,7 @@ async function main() {
2681
2681
  await handleTeachCommand(args);
2682
2682
  });
2683
2683
  // ── Sessions ──
2684
- program
2685
- .command('sessions')
2686
- .description('Manage multiple parallel kbot sessions')
2687
- .option('--create <name>', 'Create a new named session')
2688
- .option('--switch <name>', 'Switch to a session')
2689
- .option('--kill <name>', 'Kill a session')
2690
- .option('--agent <agent>', 'Set specialist agent for new session')
2691
- .option('--task <task>', 'Set task description for new session')
2692
- .action(async (sessOpts) => {
2693
- const { createSession, listSessions, switchSession, killSession, formatSessionList, formatSessionStatus } = await import('./multi-session.js');
2694
- if (sessOpts.create) {
2695
- const s = createSession({ name: sessOpts.create, agent: sessOpts.agent, task: sessOpts.task });
2696
- console.error(chalk.hex('#6B5B95')(` Created session: ${s.name} (${s.id.slice(0, 8)})`));
2697
- return;
2698
- }
2699
- if (sessOpts.switch) {
2700
- const s = switchSession(sessOpts.switch);
2701
- if (s)
2702
- console.error(chalk.hex('#6B5B95')(` Switched to: ${s.name}`));
2703
- else
2704
- console.error(chalk.red(` Session not found: ${sessOpts.switch}`));
2705
- return;
2706
- }
2707
- if (sessOpts.kill) {
2708
- const ok = killSession(sessOpts.kill);
2709
- if (ok)
2710
- console.error(chalk.hex('#6B5B95')(` Killed session: ${sessOpts.kill}`));
2711
- else
2712
- console.error(chalk.red(` Session not found: ${sessOpts.kill}`));
2713
- return;
2714
- }
2715
- // Default: list sessions
2716
- const sessions = listSessions();
2717
- if (sessions.length === 0) {
2718
- console.error(chalk.dim(' No active sessions. Create one with `kbot sessions --create <name>`'));
2719
- }
2720
- else {
2721
- console.error(formatSessionList(sessions));
2722
- }
2723
- });
2684
+ program;
2724
2685
  program
2725
2686
  .command('release')
2726
2687
  .description('Create a GitHub release with auto-generated changelog')
@@ -2884,6 +2845,318 @@ async function main() {
2884
2845
  const { generateCompletions } = await import('./completions.js');
2885
2846
  process.stdout.write(generateCompletions(shell));
2886
2847
  });
2848
+ // ── Admin — manage users, billing, moderation ──
2849
+ const adminCmd = program
2850
+ .command('admin')
2851
+ .description('Platform administration — users, billing, moderation, stats');
2852
+ adminCmd
2853
+ .command('users')
2854
+ .description('List platform users')
2855
+ .option('--filter <filter>', 'Filter: all, free, pro, max, active, churned', 'all')
2856
+ .option('--search <email>', 'Search by email')
2857
+ .option('--limit <n>', 'Max results', '50')
2858
+ .action(async (opts) => {
2859
+ await ensureLazyToolsLoaded();
2860
+ const { executeTool } = await import('./tools/index.js');
2861
+ const result = await executeTool({ id: 'admin_users', name: 'admin_users', arguments: opts });
2862
+ console.log(result.result);
2863
+ });
2864
+ adminCmd
2865
+ .command('user <email>')
2866
+ .description('Get detailed info for a user')
2867
+ .action(async (email) => {
2868
+ await ensureLazyToolsLoaded();
2869
+ const { executeTool } = await import('./tools/index.js');
2870
+ const result = await executeTool({ id: 'admin_user_detail', name: 'admin_user_detail', arguments: { email } });
2871
+ console.log(result.result);
2872
+ });
2873
+ adminCmd
2874
+ .command('stats')
2875
+ .description('Platform-wide stats')
2876
+ .action(async () => {
2877
+ await ensureLazyToolsLoaded();
2878
+ const { executeTool } = await import('./tools/index.js');
2879
+ const result = await executeTool({ id: 'admin_stats', name: 'admin_stats', arguments: {} });
2880
+ console.log(result.result);
2881
+ });
2882
+ adminCmd
2883
+ .command('billing <action>')
2884
+ .description('Billing: mrr, invoices, customer, create-invoice')
2885
+ .option('--email <email>', 'Customer email')
2886
+ .option('--amount <cents>', 'Amount in cents')
2887
+ .option('--description <desc>', 'Invoice description')
2888
+ .action(async (action, opts) => {
2889
+ await ensureLazyToolsLoaded();
2890
+ const { executeTool } = await import('./tools/index.js');
2891
+ const result = await executeTool({ id: 'admin_billing', name: 'admin_billing', arguments: { action, ...opts } });
2892
+ console.log(result.result);
2893
+ });
2894
+ adminCmd
2895
+ .command('moderate')
2896
+ .description('View moderation queue')
2897
+ .option('--approve <id>', 'Approve item')
2898
+ .option('--reject <id>', 'Reject item')
2899
+ .option('--reason <reason>', 'Rejection reason')
2900
+ .action(async (opts) => {
2901
+ await ensureLazyToolsLoaded();
2902
+ const { executeTool } = await import('./tools/index.js');
2903
+ const action = opts.approve ? 'approve' : opts.reject ? 'reject' : 'queue';
2904
+ const result = await executeTool({ id: 'admin_moderate', name: 'admin_moderate', arguments: {
2905
+ action, item_id: opts.approve || opts.reject || '', reason: opts.reason || '',
2906
+ } });
2907
+ console.log(result.result);
2908
+ });
2909
+ // ── Monitor — platform health dashboard ──
2910
+ program
2911
+ .command('monitor')
2912
+ .description('Platform health dashboard — messages, errors, costs, services')
2913
+ .option('--period <period>', 'Period: 1h, 24h, 7d', '24h')
2914
+ .option('--logs', 'Show recent platform logs')
2915
+ .option('--uptime', 'Service health check only')
2916
+ .option('--alerts', 'Show active alerts only')
2917
+ .action(async (opts) => {
2918
+ await ensureLazyToolsLoaded();
2919
+ const { executeTool } = await import('./tools/index.js');
2920
+ if (opts.uptime) {
2921
+ const r = await executeTool({ id: 'platform_uptime', name: 'platform_uptime', arguments: {} });
2922
+ console.log(r.result);
2923
+ return;
2924
+ }
2925
+ if (opts.logs) {
2926
+ const r = await executeTool({ id: 'platform_logs', name: 'platform_logs', arguments: { limit: '30' } });
2927
+ console.log(r.result);
2928
+ return;
2929
+ }
2930
+ if (opts.alerts) {
2931
+ const r = await executeTool({ id: 'platform_alerts', name: 'platform_alerts', arguments: { period: opts.period } });
2932
+ console.log(r.result);
2933
+ return;
2934
+ }
2935
+ const r = await executeTool({ id: 'platform_monitor', name: 'platform_monitor', arguments: { period: opts.period } });
2936
+ console.log(r.result);
2937
+ });
2938
+ // ── Analytics — downloads, stars, users, revenue ──
2939
+ const analyticsCmd = program
2940
+ .command('analytics')
2941
+ .description('Analytics dashboard — npm, GitHub, users, revenue');
2942
+ analyticsCmd
2943
+ .command('overview')
2944
+ .description('Full analytics dashboard')
2945
+ .action(async () => {
2946
+ await ensureLazyToolsLoaded();
2947
+ const { executeTool } = await import('./tools/index.js');
2948
+ const r = await executeTool({ id: 'analytics_overview', name: 'analytics_overview', arguments: {} });
2949
+ console.log(r.result);
2950
+ });
2951
+ analyticsCmd
2952
+ .command('npm')
2953
+ .description('npm download stats and trends')
2954
+ .option('--period <period>', 'week, month, year', 'month')
2955
+ .option('--compare <pkg>', 'Compare against another package')
2956
+ .action(async (opts) => {
2957
+ await ensureLazyToolsLoaded();
2958
+ const { executeTool } = await import('./tools/index.js');
2959
+ const r = await executeTool({ id: 'analytics_npm', name: 'analytics_npm', arguments: opts });
2960
+ console.log(r.result);
2961
+ });
2962
+ analyticsCmd
2963
+ .command('github')
2964
+ .description('GitHub repo stats and traffic')
2965
+ .action(async () => {
2966
+ await ensureLazyToolsLoaded();
2967
+ const { executeTool } = await import('./tools/index.js');
2968
+ const r = await executeTool({ id: 'analytics_github', name: 'analytics_github', arguments: {} });
2969
+ console.log(r.result);
2970
+ });
2971
+ analyticsCmd
2972
+ .command('users')
2973
+ .description('User growth and churn metrics')
2974
+ .option('--period <period>', '7d, 30d, 90d', '30d')
2975
+ .action(async (opts) => {
2976
+ await ensureLazyToolsLoaded();
2977
+ const { executeTool } = await import('./tools/index.js');
2978
+ const r = await executeTool({ id: 'analytics_users', name: 'analytics_users', arguments: opts });
2979
+ console.log(r.result);
2980
+ });
2981
+ analyticsCmd
2982
+ .command('revenue')
2983
+ .description('Revenue: MRR, subscriptions, API costs')
2984
+ .action(async () => {
2985
+ await ensureLazyToolsLoaded();
2986
+ const { executeTool } = await import('./tools/index.js');
2987
+ const r = await executeTool({ id: 'analytics_revenue', name: 'analytics_revenue', arguments: {} });
2988
+ console.log(r.result);
2989
+ });
2990
+ // ── Deploy — ship everything from terminal ──
2991
+ const deployCmd = program
2992
+ .command('deploy')
2993
+ .description('Deploy: web, edge functions, npm, GitHub release — or all at once');
2994
+ deployCmd
2995
+ .command('all')
2996
+ .description('Ship everything: typecheck → web → functions → npm → release')
2997
+ .option('--skip <steps>', 'Skip: web,functions,npm,release')
2998
+ .option('--dry-run', 'Show plan without executing')
2999
+ .action(async (opts) => {
3000
+ await ensureLazyToolsLoaded();
3001
+ const { executeTool } = await import('./tools/index.js');
3002
+ const r = await executeTool({ id: 'deploy_all', name: 'deploy_all', arguments: {
3003
+ skip: opts.skip, dry_run: opts.dryRun ? 'true' : 'false',
3004
+ } });
3005
+ console.log(r.result);
3006
+ });
3007
+ deployCmd
3008
+ .command('web')
3009
+ .description('Build and deploy web to GitHub Pages')
3010
+ .action(async () => {
3011
+ await ensureLazyToolsLoaded();
3012
+ const { executeTool } = await import('./tools/index.js');
3013
+ const r = await executeTool({ id: 'deploy_web', name: 'deploy_web', arguments: {} });
3014
+ console.log(r.result);
3015
+ });
3016
+ deployCmd
3017
+ .command('functions [name]')
3018
+ .description('Deploy Supabase edge functions')
3019
+ .action(async (name) => {
3020
+ await ensureLazyToolsLoaded();
3021
+ const { executeTool } = await import('./tools/index.js');
3022
+ const r = await executeTool({ id: 'deploy_functions', name: 'deploy_functions', arguments: { function_name: name } });
3023
+ console.log(r.result);
3024
+ });
3025
+ deployCmd
3026
+ .command('npm')
3027
+ .description('Build and publish to npm')
3028
+ .option('--dry-run', 'Build only, do not publish')
3029
+ .action(async (opts) => {
3030
+ await ensureLazyToolsLoaded();
3031
+ const { executeTool } = await import('./tools/index.js');
3032
+ const r = await executeTool({ id: 'deploy_npm', name: 'deploy_npm', arguments: { dry_run: opts.dryRun ? 'true' : 'false' } });
3033
+ console.log(r.result);
3034
+ });
3035
+ deployCmd
3036
+ .command('release')
3037
+ .description('Create GitHub release')
3038
+ .option('--notes <notes>', 'Release notes')
3039
+ .action(async (opts) => {
3040
+ await ensureLazyToolsLoaded();
3041
+ const { executeTool } = await import('./tools/index.js');
3042
+ const r = await executeTool({ id: 'deploy_release', name: 'deploy_release', arguments: { notes: opts.notes } });
3043
+ console.log(r.result);
3044
+ });
3045
+ // ── Env — environment variable management ──
3046
+ const envCmd = program
3047
+ .command('env')
3048
+ .description('Manage environment variables and secrets');
3049
+ envCmd
3050
+ .command('check')
3051
+ .description('Verify all required env vars are set')
3052
+ .action(async () => {
3053
+ await ensureLazyToolsLoaded();
3054
+ const { executeTool } = await import('./tools/index.js');
3055
+ const r = await executeTool({ id: 'env_check', name: 'env_check', arguments: {} });
3056
+ console.log(r.result);
3057
+ });
3058
+ envCmd
3059
+ .command('list')
3060
+ .description('List Supabase secrets')
3061
+ .action(async () => {
3062
+ await ensureLazyToolsLoaded();
3063
+ const { executeTool } = await import('./tools/index.js');
3064
+ const r = await executeTool({ id: 'env_list', name: 'env_list', arguments: {} });
3065
+ console.log(r.result);
3066
+ });
3067
+ envCmd
3068
+ .command('set <name> <value>')
3069
+ .description('Set a Supabase secret')
3070
+ .action(async (name, value) => {
3071
+ await ensureLazyToolsLoaded();
3072
+ const { executeTool } = await import('./tools/index.js');
3073
+ const r = await executeTool({ id: 'env_set', name: 'env_set', arguments: { name, value } });
3074
+ console.log(r.result);
3075
+ });
3076
+ envCmd
3077
+ .command('sync <keys>')
3078
+ .description('Sync local .env keys to Supabase secrets')
3079
+ .option('--dry-run', 'Show what would be synced')
3080
+ .action(async (keys, opts) => {
3081
+ await ensureLazyToolsLoaded();
3082
+ const { executeTool } = await import('./tools/index.js');
3083
+ const r = await executeTool({ id: 'env_sync', name: 'env_sync', arguments: { keys, dry_run: opts.dryRun ? 'true' : 'false' } });
3084
+ console.log(r.result);
3085
+ });
3086
+ envCmd
3087
+ .command('rotate <key>')
3088
+ .description('Rotate a secret (shows guide or applies new value)')
3089
+ .option('--value <value>', 'New value')
3090
+ .action(async (key, opts) => {
3091
+ await ensureLazyToolsLoaded();
3092
+ const { executeTool } = await import('./tools/index.js');
3093
+ const r = await executeTool({ id: 'env_rotate', name: 'env_rotate', arguments: { key, new_value: opts.value } });
3094
+ console.log(r.result);
3095
+ });
3096
+ // ── DB — database administration ──
3097
+ const dbCmd = program
3098
+ .command('db')
3099
+ .description('Database administration — backup, inspect, query, migrate');
3100
+ dbCmd
3101
+ .command('backup')
3102
+ .description('Dump database to file')
3103
+ .option('--output <path>', 'Output file path')
3104
+ .option('--schema-only', 'Schema only, no data')
3105
+ .action(async (opts) => {
3106
+ await ensureLazyToolsLoaded();
3107
+ const { executeTool } = await import('./tools/index.js');
3108
+ const r = await executeTool({ id: 'db_backup', name: 'db_backup', arguments: { output: opts.output, schema_only: opts.schemaOnly ? 'true' : 'false' } });
3109
+ console.log(r.result);
3110
+ });
3111
+ dbCmd
3112
+ .command('tables')
3113
+ .description('List all tables with row counts')
3114
+ .action(async () => {
3115
+ await ensureLazyToolsLoaded();
3116
+ const { executeTool } = await import('./tools/index.js');
3117
+ const r = await executeTool({ id: 'db_tables', name: 'db_tables', arguments: {} });
3118
+ console.log(r.result);
3119
+ });
3120
+ dbCmd
3121
+ .command('inspect <table>')
3122
+ .description('Inspect table schema and sample data')
3123
+ .option('--sample <n>', 'Number of sample rows', '5')
3124
+ .action(async (table, opts) => {
3125
+ await ensureLazyToolsLoaded();
3126
+ const { executeTool } = await import('./tools/index.js');
3127
+ const r = await executeTool({ id: 'db_inspect', name: 'db_inspect', arguments: { table, sample: opts.sample } });
3128
+ console.log(r.result);
3129
+ });
3130
+ dbCmd
3131
+ .command('sql <query>')
3132
+ .description('Run SQL query (read-only recommended)')
3133
+ .action(async (query) => {
3134
+ await ensureLazyToolsLoaded();
3135
+ const { executeTool } = await import('./tools/index.js');
3136
+ const r = await executeTool({ id: 'db_sql', name: 'db_sql', arguments: { query } });
3137
+ console.log(r.result);
3138
+ });
3139
+ dbCmd
3140
+ .command('migrations')
3141
+ .description('List and run database migrations')
3142
+ .option('--run', 'Apply pending migrations')
3143
+ .option('--new <name>', 'Create new migration')
3144
+ .action(async (opts) => {
3145
+ await ensureLazyToolsLoaded();
3146
+ const { executeTool } = await import('./tools/index.js');
3147
+ const action = opts.run ? 'run' : opts.new ? 'new' : 'list';
3148
+ const r = await executeTool({ id: 'db_migrations', name: 'db_migrations', arguments: { action, name: opts.new } });
3149
+ console.log(r.result);
3150
+ });
3151
+ dbCmd
3152
+ .command('health')
3153
+ .description('Database health check')
3154
+ .action(async () => {
3155
+ await ensureLazyToolsLoaded();
3156
+ const { executeTool } = await import('./tools/index.js');
3157
+ const r = await executeTool({ id: 'db_health', name: 'db_health', arguments: {} });
3158
+ console.log(r.result);
3159
+ });
2887
3160
  program.parse(process.argv);
2888
3161
  const opts = program.opts();
2889
3162
  const promptArgs = program.args;
@@ -2891,7 +3164,7 @@ async function main() {
2891
3164
  if (opts.quiet)
2892
3165
  setQuiet(true);
2893
3166
  // If a sub-command was run, we're done
2894
- if (['byok', 'auth', 'ide', 'local', 'ollama', 'kbot-local', 'pull', 'doctor', 'serve', 'agents', 'watch', 'voice', 'export', 'plugins', 'changelog', 'release', 'completions', 'automate', 'status', 'spec', 'a2a', 'init', 'email-agent', 'imessage-agent', 'consultation', 'observe', 'discovery', 'bench', 'lab', 'teach', 'sessions'].includes(program.args[0]))
3167
+ if (['byok', 'auth', 'ide', 'local', 'ollama', 'kbot-local', 'pull', 'doctor', 'serve', 'agents', 'watch', 'voice', 'export', 'plugins', 'changelog', 'release', 'completions', 'automate', 'status', 'spec', 'a2a', 'init', 'email-agent', 'imessage-agent', 'consultation', 'observe', 'discovery', 'bench', 'lab', 'teach', 'sessions', 'admin', 'monitor', 'analytics', 'deploy', 'env', 'db'].includes(program.args[0]))
2895
3168
  return;
2896
3169
  // Check for API key (BYOK or local provider)
2897
3170
  let byokActive = isByokEnabled();