theokit 0.48.2 → 0.48.3

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/index.js CHANGED
@@ -65,8 +65,8 @@ cli.command(
65
65
  });
66
66
  cli.command("agent sessions gc", "Collect old transcripts for this project (dry run unless --apply)").option("--apply", "Actually delete. Without it the command prints the plan and changes nothing.").option("--keep-last <n>", "Newest N sessions always survive (floor 1)", { default: 10 }).option("--max-age-days <n>", "Only sessions older than this may go (floor 1)", { default: 30 }).action(async (options) => {
67
67
  try {
68
- const { sessionsGcCommand } = await import("../sessions-gc-H4WC4IXB.js");
69
- const { lines, failed } = sessionsGcCommand({
68
+ const { sessionsGcCommand } = await import("../sessions-gc-VAZR654G.js");
69
+ const { lines, failed } = await sessionsGcCommand({
70
70
  apply: options.apply,
71
71
  keepLast: Number(options.keepLast),
72
72
  maxAgeDays: Number(options.maxAgeDays)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["import cac from 'cac'\n\ninterface CliOptions {\n port?: string | number\n target?: string\n upgradeReadiness?: string | number\n json?: boolean\n allowWarnings?: boolean\n force?: boolean\n dryRun?: boolean\n}\n\nconst cli = cac('theokit')\n\ncli\n .command('dev', 'Start development server')\n .option('--port <port>', 'Port number')\n .action(async (options: CliOptions) => {\n const { devCommand } = await import('./commands/dev.js')\n await devCommand({ port: options.port ? Number(options.port) : undefined })\n })\n\ncli\n .command('build', 'Build for production')\n .option('--target <target>', 'Deploy target (node, vercel, cloudflare)')\n .action(async (options: CliOptions) => {\n try {\n const { buildCommand } = await import('./commands/build.js')\n await buildCommand({ target: options.target })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('start', 'Start production server')\n .option('--port <port>', 'Port number')\n .action(async (options: CliOptions) => {\n try {\n const { startCommand } = await import('./commands/start/index.js')\n await startCommand({ port: options.port ? Number(options.port) : undefined })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'generate <type> <name> [...fields]',\n 'Scaffold a route, action, page, ws, controller, agent, toolbox, workflow, eval, sandbox, schedule, memory, or resource (resource accepts field:type args)',\n )\n .action(async (type: string, name: string, fields: string[]) => {\n try {\n const { generateCommand } = await import('./commands/generate.js')\n await generateCommand(type, name, fields.length > 0 ? fields : undefined)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'agent <name> [message]',\n 'Run an agent in the terminal (stream + tool calls + approval)',\n )\n .action(async (name: string, message: string | undefined) => {\n try {\n const { agentCommand } = await import('./commands/agent.js')\n const { sawError } = await agentCommand(name, message)\n // The run ended with an error chunk (already rendered) — exit non-zero so `$?` / CI reflects it.\n if (sawError) process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('agent sessions gc', 'Collect old transcripts for this project (dry run unless --apply)')\n .option('--apply', 'Actually delete. Without it the command prints the plan and changes nothing.')\n .option('--keep-last <n>', 'Newest N sessions always survive (floor 1)', { default: 10 })\n .option('--max-age-days <n>', 'Only sessions older than this may go (floor 1)', { default: 30 })\n .action(async (options: { apply?: boolean; keepLast?: number; maxAgeDays?: number }) => {\n try {\n const { sessionsGcCommand } = await import('./commands/sessions-gc.js')\n const { lines, failed } = sessionsGcCommand({\n apply: options.apply,\n keepLast: Number(options.keepLast),\n maxAgeDays: Number(options.maxAgeDays),\n })\n for (const line of lines) console.log(line)\n // A partial failure exits non-zero: the collector is fail-open per candidate, and an operator\n // scripting this needs `$?` to reflect that something did not go.\n if (failed > 0) process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('mcp <agent>', 'Serve an agent as an MCP server over stdio (for desktop MCP clients)')\n .action(async (agent: string) => {\n try {\n const { mcpCommand } = await import('./commands/mcp.js')\n await mcpCommand(agent)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli.command('routes', 'List all routes, actions, and WebSocket endpoints').action(async () => {\n try {\n const { routesCommand } = await import('./commands/routes.js')\n await routesCommand()\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n})\n\ncli\n .command('check', 'Run typecheck + scan + (optional) eslint')\n .option(\n '--upgrade-readiness <version>',\n 'Scan source for anticipated breakage under a future TheoKit version (currently supports 0.3). See docs/migration/0.2-to-0.3.md',\n )\n .option('--json', 'Emit machine-readable JSON (only with --upgrade-readiness)')\n .option(\n '--allow-warnings',\n 'Do not fail the build when violations are present (only with --upgrade-readiness)',\n )\n .action(async (options: CliOptions) => {\n // cac may coerce `0.3` to a JS number — normalize before comparing.\n const targetRaw = options.upgradeReadiness\n if (targetRaw !== undefined) {\n const target = String(targetRaw)\n if (target !== '0.3') {\n console.error(`\\n ✗ --upgrade-readiness: only '0.3' is supported (got '${target}')\\n`)\n process.exit(1)\n }\n const { upgradeReadinessCommand } = await import('./commands/upgrade-readiness.js')\n await upgradeReadinessCommand({\n json: Boolean(options.json),\n allowWarnings: Boolean(options.allowWarnings),\n })\n return\n }\n const { checkCommand } = await import('./commands/check.js')\n await checkCommand()\n })\n\ncli\n .command('add <package>', 'Install a known TheoKit adapter or plugin (whitelist-only)')\n .action(async (pkg: string) => {\n const { addCommand } = await import('./commands/add.js')\n await addCommand(pkg)\n })\n\ncli.command('info', 'Print environment info (runtime, config, routes)').action(async () => {\n const { infoCommand } = await import('./commands/info.js')\n await infoCommand()\n})\n\n// M84 — `theokit doctor`. `info` answers \"does my project parse?\"; this answers \"what will this\n// installation DO?\" — which credential, which MCP servers, which subagents. The exit code is a\n// contract, so `theokit doctor && deploy` means what it reads like, and `process.exitCode` is set\n// rather than `process.exit()` called: the latter truncates stdout that is still flushing.\ncli\n .command('doctor', 'Report the RESOLVED state of this installation (never prints a secret)')\n .action(async () => {\n const { doctorCommand } = await import('./commands/doctor.js')\n process.exitCode = await doctorCommand()\n })\n\ncli\n .command(\n 'openapi',\n 'Generate <distDir>/openapi.json from route schemas (opt-in via config.openapi)',\n )\n .option('--dry-run', 'Print the document to stdout without writing to disk (EC-3)')\n .action(async (options: CliOptions) => {\n try {\n const { openapiCommand } = await import('./commands/openapi.js')\n await openapiCommand({ dryRun: Boolean(options.dryRun) })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'migrate <kind>',\n 'Run a one-shot convention migration. Supported: router (G6 dotted→nested), services-json-v1-to-v2 (Plan v1.2 T2.3)',\n )\n .option('--dry-run', 'Print the migration plan but do not touch the filesystem')\n .option('--force', 'Skip the dev-server port pre-flight check (CI / non-TTY)')\n .option('--name <slug>', 'Explicit project name (DNS-1123). Services-json migrate only.')\n .action(async (kind: string, options: CliOptions & { name?: string }) => {\n try {\n if (kind === 'router') {\n const { routerMigrateCommand } = await import('./commands/migrate/router.js')\n await routerMigrateCommand({\n dryRun: Boolean(options.dryRun),\n force: Boolean(options.force),\n })\n return\n }\n if (kind === 'services-json-v1-to-v2' || kind === 'services-json') {\n const { servicesJsonMigrateCommand } = await import('./commands/migrate/services-json.js')\n await servicesJsonMigrateCommand({\n dryRun: Boolean(options.dryRun),\n name: options.name,\n })\n return\n }\n console.error(\n `\\n ✗ Unknown migration kind: ${kind}. Supported: router, services-json-v1-to-v2\\n`,\n )\n process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('docker', 'Generate Dockerfile for production')\n .option('--force', 'Overwrite existing Dockerfile')\n .action(async (options: CliOptions) => {\n try {\n const { dockerCommand } = await import('./commands/docker.js')\n await dockerCommand({ force: options.force })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('db <action>', 'Database commands: migrate (push schema), generate (SQL files), seed')\n .action(async (action: string) => {\n try {\n const { dbCommandCli } = await import('./commands/db.js')\n dbCommandCli(action)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli.help()\ncli.version('0.1.0-alpha.0')\n\nexport function main(): void {\n cli.parse()\n}\n\n// Auto-execute when run as script\nmain()\n"],"mappings":";;;;AAAA,OAAO,SAAS;AAYhB,IAAM,MAAM,IAAI,SAAS;AAEzB,IACG,QAAQ,OAAO,0BAA0B,EACzC,OAAO,iBAAiB,aAAa,EACrC,OAAO,OAAO,YAAwB;AACrC,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,oBAAmB;AACvD,QAAM,WAAW,EAAE,MAAM,QAAQ,OAAO,OAAO,QAAQ,IAAI,IAAI,OAAU,CAAC;AAC5E,CAAC;AAEH,IACG,QAAQ,SAAS,sBAAsB,EACvC,OAAO,qBAAqB,0CAA0C,EACtE,OAAO,OAAO,YAAwB;AACrC,MAAI;AACF,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,sBAAqB;AAC3D,UAAM,aAAa,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC/C,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IACG,QAAQ,SAAS,yBAAyB,EAC1C,OAAO,iBAA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AAO,QAAQ,MAAM,CAAC;AAAA,EAC9C,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IACG,QAAQ,eAAe,sEAAsE,EAC7F,OAAO,OAAO,WAAmB;AAChC,MAAI;AACF,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,mBAAkB;AACxD,iBAAa,MAAM;AAAA,EACrB,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IAAI,KAAK;AACT,IAAI,QAAQ,eAAe;AAEpB,SAAS,OAAa;AAC3B,MAAI,MAAM;AACZ;AAGA,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["import cac from 'cac'\n\ninterface CliOptions {\n port?: string | number\n target?: string\n upgradeReadiness?: string | number\n json?: boolean\n allowWarnings?: boolean\n force?: boolean\n dryRun?: boolean\n}\n\nconst cli = cac('theokit')\n\ncli\n .command('dev', 'Start development server')\n .option('--port <port>', 'Port number')\n .action(async (options: CliOptions) => {\n const { devCommand } = await import('./commands/dev.js')\n await devCommand({ port: options.port ? Number(options.port) : undefined })\n })\n\ncli\n .command('build', 'Build for production')\n .option('--target <target>', 'Deploy target (node, vercel, cloudflare)')\n .action(async (options: CliOptions) => {\n try {\n const { buildCommand } = await import('./commands/build.js')\n await buildCommand({ target: options.target })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('start', 'Start production server')\n .option('--port <port>', 'Port number')\n .action(async (options: CliOptions) => {\n try {\n const { startCommand } = await import('./commands/start/index.js')\n await startCommand({ port: options.port ? Number(options.port) : undefined })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'generate <type> <name> [...fields]',\n 'Scaffold a route, action, page, ws, controller, agent, toolbox, workflow, eval, sandbox, schedule, memory, or resource (resource accepts field:type args)',\n )\n .action(async (type: string, name: string, fields: string[]) => {\n try {\n const { generateCommand } = await import('./commands/generate.js')\n await generateCommand(type, name, fields.length > 0 ? fields : undefined)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'agent <name> [message]',\n 'Run an agent in the terminal (stream + tool calls + approval)',\n )\n .action(async (name: string, message: string | undefined) => {\n try {\n const { agentCommand } = await import('./commands/agent.js')\n const { sawError } = await agentCommand(name, message)\n // The run ended with an error chunk (already rendered) — exit non-zero so `$?` / CI reflects it.\n if (sawError) process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('agent sessions gc', 'Collect old transcripts for this project (dry run unless --apply)')\n .option('--apply', 'Actually delete. Without it the command prints the plan and changes nothing.')\n .option('--keep-last <n>', 'Newest N sessions always survive (floor 1)', { default: 10 })\n .option('--max-age-days <n>', 'Only sessions older than this may go (floor 1)', { default: 30 })\n .action(async (options: { apply?: boolean; keepLast?: number; maxAgeDays?: number }) => {\n try {\n const { sessionsGcCommand } = await import('./commands/sessions-gc.js')\n const { lines, failed } = await sessionsGcCommand({\n apply: options.apply,\n keepLast: Number(options.keepLast),\n maxAgeDays: Number(options.maxAgeDays),\n })\n for (const line of lines) console.log(line)\n // A partial failure exits non-zero: the collector is fail-open per candidate, and an operator\n // scripting this needs `$?` to reflect that something did not go.\n if (failed > 0) process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('mcp <agent>', 'Serve an agent as an MCP server over stdio (for desktop MCP clients)')\n .action(async (agent: string) => {\n try {\n const { mcpCommand } = await import('./commands/mcp.js')\n await mcpCommand(agent)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli.command('routes', 'List all routes, actions, and WebSocket endpoints').action(async () => {\n try {\n const { routesCommand } = await import('./commands/routes.js')\n await routesCommand()\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n})\n\ncli\n .command('check', 'Run typecheck + scan + (optional) eslint')\n .option(\n '--upgrade-readiness <version>',\n 'Scan source for anticipated breakage under a future TheoKit version (currently supports 0.3). See docs/migration/0.2-to-0.3.md',\n )\n .option('--json', 'Emit machine-readable JSON (only with --upgrade-readiness)')\n .option(\n '--allow-warnings',\n 'Do not fail the build when violations are present (only with --upgrade-readiness)',\n )\n .action(async (options: CliOptions) => {\n // cac may coerce `0.3` to a JS number — normalize before comparing.\n const targetRaw = options.upgradeReadiness\n if (targetRaw !== undefined) {\n const target = String(targetRaw)\n if (target !== '0.3') {\n console.error(`\\n ✗ --upgrade-readiness: only '0.3' is supported (got '${target}')\\n`)\n process.exit(1)\n }\n const { upgradeReadinessCommand } = await import('./commands/upgrade-readiness.js')\n await upgradeReadinessCommand({\n json: Boolean(options.json),\n allowWarnings: Boolean(options.allowWarnings),\n })\n return\n }\n const { checkCommand } = await import('./commands/check.js')\n await checkCommand()\n })\n\ncli\n .command('add <package>', 'Install a known TheoKit adapter or plugin (whitelist-only)')\n .action(async (pkg: string) => {\n const { addCommand } = await import('./commands/add.js')\n await addCommand(pkg)\n })\n\ncli.command('info', 'Print environment info (runtime, config, routes)').action(async () => {\n const { infoCommand } = await import('./commands/info.js')\n await infoCommand()\n})\n\n// M84 — `theokit doctor`. `info` answers \"does my project parse?\"; this answers \"what will this\n// installation DO?\" — which credential, which MCP servers, which subagents. The exit code is a\n// contract, so `theokit doctor && deploy` means what it reads like, and `process.exitCode` is set\n// rather than `process.exit()` called: the latter truncates stdout that is still flushing.\ncli\n .command('doctor', 'Report the RESOLVED state of this installation (never prints a secret)')\n .action(async () => {\n const { doctorCommand } = await import('./commands/doctor.js')\n process.exitCode = await doctorCommand()\n })\n\ncli\n .command(\n 'openapi',\n 'Generate <distDir>/openapi.json from route schemas (opt-in via config.openapi)',\n )\n .option('--dry-run', 'Print the document to stdout without writing to disk (EC-3)')\n .action(async (options: CliOptions) => {\n try {\n const { openapiCommand } = await import('./commands/openapi.js')\n await openapiCommand({ dryRun: Boolean(options.dryRun) })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command(\n 'migrate <kind>',\n 'Run a one-shot convention migration. Supported: router (G6 dotted→nested), services-json-v1-to-v2 (Plan v1.2 T2.3)',\n )\n .option('--dry-run', 'Print the migration plan but do not touch the filesystem')\n .option('--force', 'Skip the dev-server port pre-flight check (CI / non-TTY)')\n .option('--name <slug>', 'Explicit project name (DNS-1123). Services-json migrate only.')\n .action(async (kind: string, options: CliOptions & { name?: string }) => {\n try {\n if (kind === 'router') {\n const { routerMigrateCommand } = await import('./commands/migrate/router.js')\n await routerMigrateCommand({\n dryRun: Boolean(options.dryRun),\n force: Boolean(options.force),\n })\n return\n }\n if (kind === 'services-json-v1-to-v2' || kind === 'services-json') {\n const { servicesJsonMigrateCommand } = await import('./commands/migrate/services-json.js')\n await servicesJsonMigrateCommand({\n dryRun: Boolean(options.dryRun),\n name: options.name,\n })\n return\n }\n console.error(\n `\\n ✗ Unknown migration kind: ${kind}. Supported: router, services-json-v1-to-v2\\n`,\n )\n process.exit(1)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('docker', 'Generate Dockerfile for production')\n .option('--force', 'Overwrite existing Dockerfile')\n .action(async (options: CliOptions) => {\n try {\n const { dockerCommand } = await import('./commands/docker.js')\n await dockerCommand({ force: options.force })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli\n .command('db <action>', 'Database commands: migrate (push schema), generate (SQL files), seed')\n .action(async (action: string) => {\n try {\n const { dbCommandCli } = await import('./commands/db.js')\n dbCommandCli(action)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n console.error(`\\n ✗ ${msg}\\n`)\n process.exit(1)\n }\n })\n\ncli.help()\ncli.version('0.1.0-alpha.0')\n\nexport function main(): void {\n cli.parse()\n}\n\n// Auto-execute when run as script\nmain()\n"],"mappings":";;;;AAAA,OAAO,SAAS;AAYhB,IAAM,MAAM,IAAI,SAAS;AAEzB,IACG,QAAQ,OAAO,0BAA0B,EACzC,OAAO,iBAAiB,aAAa,EACrC,OAAO,OAAO,YAAwB;AACrC,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,oBAAmB;AACvD,QAAM,WAAW,EAAE,MAAM,QAAQ,OAAO,OAAO,QAAQ,IAAI,IAAI,OAAU,CAAC;AAC5E,CAAC;AAEH,IACG,QAAQ,SAAS,sBAAsB,EACvC,OAAO,qBAAqB,0CAA0C,EACtE,OAAO,OAAO,YAAwB;AACrC,MAAI;AACF,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,sBAAqB;AAC3D,UAAM,aAAa,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC/C,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IACG,QAA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OAAO,uBAAsB;AAC7D,UAAM,cAAc,EAAE,OAAO,QAAQ,MAAM,CAAC;AAAA,EAC9C,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IACG,QAAQ,eAAe,sEAAsE,EAC7F,OAAO,OAAO,WAAmB;AAChC,MAAI;AACF,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,mBAAkB;AACxD,iBAAa,MAAM;AAAA,EACrB,SAAS,KAAK;AACZ,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,YAAQ,MAAM;AAAA,WAAS,GAAG;AAAA,CAAI;AAC9B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,IAAI,KAAK;AACT,IAAI,QAAQ,eAAe;AAEpB,SAAS,OAAa;AAC3B,MAAI,MAAM;AACZ;AAGA,KAAK;","names":[]}
@@ -22,17 +22,17 @@ function formatGcPlan(plan, result) {
22
22
  }
23
23
  return lines;
24
24
  }
25
- function sessionsGcCommand(options = {}) {
25
+ async function sessionsGcCommand(options = {}) {
26
26
  const plan = planTranscriptGC({
27
27
  cwd: options.cwd ?? process.cwd(),
28
28
  keepLast: options.keepLast ?? DEFAULTS.keepLast,
29
29
  maxAgeDays: options.maxAgeDays ?? DEFAULTS.maxAgeDays
30
30
  });
31
- const result = runTranscriptGC(plan, { apply: options.apply === true });
31
+ const result = await runTranscriptGC(plan, { apply: options.apply === true });
32
32
  return { lines: formatGcPlan(plan, result), failed: result.errors.length };
33
33
  }
34
34
  export {
35
35
  formatGcPlan,
36
36
  sessionsGcCommand
37
37
  };
38
- //# sourceMappingURL=sessions-gc-H4WC4IXB.js.map
38
+ //# sourceMappingURL=sessions-gc-VAZR654G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/sessions-gc.ts"],"sourcesContent":["import { planTranscriptGC, runTranscriptGC } from '@theokit/agents/session'\nimport type { TranscriptGCPlan } from '@theokit/agents/session'\n\n/**\n * M72 — `theokit agent sessions gc`: bound the disk state the framework creates.\n *\n * ## Why the default is a dry run\n *\n * This deletes conversation history. Without `--apply` the command PRINTS the plan and changes\n * nothing, because a destructive retention policy an operator has never seen the output of is a\n * policy nobody reviewed. Making `--apply` the default would save one flag and cost the review.\n *\n * The plan is printed in both modes, not just the dry one: an operator applying a policy still needs\n * to see what it decided, and \"removed 12 sessions\" without which ones is a report nobody can act\n * on.\n */\n\n/**\n * Not exported: its only consumer is the signature below, in this same file.\n *\n * Publishing it would put a name in the package surface that nobody imports — the G7 shape knip\n * caught in M76. When a caller needs to hold these options in a typed variable, exporting it then is\n * one line; exporting it now is a promise to keep a name stable for an audience that does not exist.\n */\ninterface SessionsGcOptions {\n /** Actually delete. Absent ⇒ dry run. */\n readonly apply?: boolean\n /** Newest N sessions always survive (floor 1). */\n readonly keepLast?: number\n /** Only sessions older than this may go (floor 1). */\n readonly maxAgeDays?: number\n /** Where to collect. Defaults to the process cwd — the project the operator is standing in. */\n readonly cwd?: string\n}\n\n/** Defaults chosen to be boring: a month of history, never fewer than ten sessions. */\nconst DEFAULTS = { keepLast: 10, maxAgeDays: 30 } as const\n\n/** Render the plan for a human. Returns lines so the command is testable without capturing stdout. */\nexport function formatGcPlan(\n plan: TranscriptGCPlan,\n // `Awaited<>` because `runTranscriptGC` is async (T2.2). Without it the parameter type IS the\n // Promise, and every field read below type-checks against a thenable that has none of them.\n result: Awaited<ReturnType<typeof runTranscriptGC>>,\n): string[] {\n const lines: string[] = [result.dryRun ? ' Dry run — nothing was deleted.' : ' Applied.', '']\n\n if (result.removed.length === 0) {\n lines.push(' Nothing to collect.')\n } else {\n lines.push(` ${result.dryRun ? 'Would remove' : 'Removed'} ${String(result.removed.length)}:`)\n for (const id of result.removed) lines.push(` - ${id}`)\n }\n\n // The kept list carries the REASON per session. \"Skipped 4\" tells an operator nothing; \"kept\n // because it holds an active writer lease\" tells them whether to go stop something.\n if (plan.kept.length > 0) {\n lines.push('', ` Kept ${String(plan.kept.length)}:`)\n for (const keep of plan.kept) lines.push(` - ${keep.id} — ${keep.reason}`)\n }\n\n if (result.errors.length > 0) {\n lines.push('', ` ${String(result.errors.length)} failed (the rest still ran):`)\n for (const error of result.errors) lines.push(` ✗ ${error.id} — ${error.message}`)\n }\n\n return lines\n}\n\n/**\n * Plan and (optionally) apply transcript retention for one project.\n *\n * Returns the result so a caller can decide the exit code: a partial failure is reported, never\n * swallowed into a zero exit.\n */\nexport async function sessionsGcCommand(options: SessionsGcOptions = {}): Promise<{\n readonly lines: readonly string[]\n readonly failed: number\n}> {\n const plan = planTranscriptGC({\n cwd: options.cwd ?? process.cwd(),\n keepLast: options.keepLast ?? DEFAULTS.keepLast,\n maxAgeDays: options.maxAgeDays ?? DEFAULTS.maxAgeDays,\n })\n // AWAITED. T2.2 made this async and this caller was not updated; `result.removed` was then\n // `undefined` on a Promise and the command threw before printing anything. The workspace\n // typecheck missed it because `packages/agents/dist/session.d.ts` was a day older than the source\n // and still declared the synchronous return.\n const result = await runTranscriptGC(plan, { apply: options.apply === true })\n return { lines: formatGcPlan(plan, result), failed: result.errors.length }\n}\n"],"mappings":";;;;AAAA,SAAS,kBAAkB,uBAAuB;AAoClD,IAAM,WAAW,EAAE,UAAU,IAAI,YAAY,GAAG;AAGzC,SAAS,aACd,MAGA,QACU;AACV,QAAM,QAAkB,CAAC,OAAO,SAAS,0CAAqC,cAAc,EAAE;AAE9F,MAAI,OAAO,QAAQ,WAAW,GAAG;AAC/B,UAAM,KAAK,uBAAuB;AAAA,EACpC,OAAO;AACL,UAAM,KAAK,KAAK,OAAO,SAAS,iBAAiB,SAAS,IAAI,OAAO,OAAO,QAAQ,MAAM,CAAC,GAAG;AAC9F,eAAW,MAAM,OAAO,QAAS,OAAM,KAAK,SAAS,EAAE,EAAE;AAAA,EAC3D;AAIA,MAAI,KAAK,KAAK,SAAS,GAAG;AACxB,UAAM,KAAK,IAAI,UAAU,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG;AACpD,eAAW,QAAQ,KAAK,KAAM,OAAM,KAAK,SAAS,KAAK,EAAE,WAAM,KAAK,MAAM,EAAE;AAAA,EAC9E;AAEA,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,KAAK,IAAI,KAAK,OAAO,OAAO,OAAO,MAAM,CAAC,+BAA+B;AAC/E,eAAW,SAAS,OAAO,OAAQ,OAAM,KAAK,cAAS,MAAM,EAAE,WAAM,MAAM,OAAO,EAAE;AAAA,EACtF;AAEA,SAAO;AACT;AAQA,eAAsB,kBAAkB,UAA6B,CAAC,GAGnE;AACD,QAAM,OAAO,iBAAiB;AAAA,IAC5B,KAAK,QAAQ,OAAO,QAAQ,IAAI;AAAA,IAChC,UAAU,QAAQ,YAAY,SAAS;AAAA,IACvC,YAAY,QAAQ,cAAc,SAAS;AAAA,EAC7C,CAAC;AAKD,QAAM,SAAS,MAAM,gBAAgB,MAAM,EAAE,OAAO,QAAQ,UAAU,KAAK,CAAC;AAC5E,SAAO,EAAE,OAAO,aAAa,MAAM,MAAM,GAAG,QAAQ,OAAO,OAAO,OAAO;AAC3E;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "theokit",
3
- "version": "0.48.2",
3
+ "version": "0.48.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "Apache-2.0",
@@ -123,9 +123,9 @@
123
123
  "tsx": "^4.22.4",
124
124
  "typescript": "^5.9.3",
125
125
  "vite": "^6.4.3",
126
- "@theokit/agents": "^9.4.0",
127
- "@theokit/http": "^1.1.0",
128
- "@theokit/presenter": "^0.7.0"
126
+ "@theokit/presenter": "^0.7.0",
127
+ "@theokit/agents": "^10.0.0",
128
+ "@theokit/http": "^1.1.0"
129
129
  },
130
130
  "peerDependencies": {
131
131
  "@theokit/sdk": "^4.52.1",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/commands/sessions-gc.ts"],"sourcesContent":["import { planTranscriptGC, runTranscriptGC } from '@theokit/agents/session'\nimport type { TranscriptGCPlan } from '@theokit/agents/session'\n\n/**\n * M72 — `theokit agent sessions gc`: bound the disk state the framework creates.\n *\n * ## Why the default is a dry run\n *\n * This deletes conversation history. Without `--apply` the command PRINTS the plan and changes\n * nothing, because a destructive retention policy an operator has never seen the output of is a\n * policy nobody reviewed. Making `--apply` the default would save one flag and cost the review.\n *\n * The plan is printed in both modes, not just the dry one: an operator applying a policy still needs\n * to see what it decided, and \"removed 12 sessions\" without which ones is a report nobody can act\n * on.\n */\n\n/**\n * Not exported: its only consumer is the signature below, in this same file.\n *\n * Publishing it would put a name in the package surface that nobody imports — the G7 shape knip\n * caught in M76. When a caller needs to hold these options in a typed variable, exporting it then is\n * one line; exporting it now is a promise to keep a name stable for an audience that does not exist.\n */\ninterface SessionsGcOptions {\n /** Actually delete. Absent ⇒ dry run. */\n readonly apply?: boolean\n /** Newest N sessions always survive (floor 1). */\n readonly keepLast?: number\n /** Only sessions older than this may go (floor 1). */\n readonly maxAgeDays?: number\n /** Where to collect. Defaults to the process cwd — the project the operator is standing in. */\n readonly cwd?: string\n}\n\n/** Defaults chosen to be boring: a month of history, never fewer than ten sessions. */\nconst DEFAULTS = { keepLast: 10, maxAgeDays: 30 } as const\n\n/** Render the plan for a human. Returns lines so the command is testable without capturing stdout. */\nexport function formatGcPlan(\n plan: TranscriptGCPlan,\n result: ReturnType<typeof runTranscriptGC>,\n): string[] {\n const lines: string[] = [result.dryRun ? ' Dry run — nothing was deleted.' : ' Applied.', '']\n\n if (result.removed.length === 0) {\n lines.push(' Nothing to collect.')\n } else {\n lines.push(` ${result.dryRun ? 'Would remove' : 'Removed'} ${String(result.removed.length)}:`)\n for (const id of result.removed) lines.push(` - ${id}`)\n }\n\n // The kept list carries the REASON per session. \"Skipped 4\" tells an operator nothing; \"kept\n // because it holds an active writer lease\" tells them whether to go stop something.\n if (plan.kept.length > 0) {\n lines.push('', ` Kept ${String(plan.kept.length)}:`)\n for (const keep of plan.kept) lines.push(` - ${keep.id} — ${keep.reason}`)\n }\n\n if (result.errors.length > 0) {\n lines.push('', ` ${String(result.errors.length)} failed (the rest still ran):`)\n for (const error of result.errors) lines.push(` ✗ ${error.id} — ${error.message}`)\n }\n\n return lines\n}\n\n/**\n * Plan and (optionally) apply transcript retention for one project.\n *\n * Returns the result so a caller can decide the exit code: a partial failure is reported, never\n * swallowed into a zero exit.\n */\nexport function sessionsGcCommand(options: SessionsGcOptions = {}): {\n readonly lines: readonly string[]\n readonly failed: number\n} {\n const plan = planTranscriptGC({\n cwd: options.cwd ?? process.cwd(),\n keepLast: options.keepLast ?? DEFAULTS.keepLast,\n maxAgeDays: options.maxAgeDays ?? DEFAULTS.maxAgeDays,\n })\n const result = runTranscriptGC(plan, { apply: options.apply === true })\n return { lines: formatGcPlan(plan, result), failed: result.errors.length }\n}\n"],"mappings":";;;;AAAA,SAAS,kBAAkB,uBAAuB;AAoClD,IAAM,WAAW,EAAE,UAAU,IAAI,YAAY,GAAG;AAGzC,SAAS,aACd,MACA,QACU;AACV,QAAM,QAAkB,CAAC,OAAO,SAAS,0CAAqC,cAAc,EAAE;AAE9F,MAAI,OAAO,QAAQ,WAAW,GAAG;AAC/B,UAAM,KAAK,uBAAuB;AAAA,EACpC,OAAO;AACL,UAAM,KAAK,KAAK,OAAO,SAAS,iBAAiB,SAAS,IAAI,OAAO,OAAO,QAAQ,MAAM,CAAC,GAAG;AAC9F,eAAW,MAAM,OAAO,QAAS,OAAM,KAAK,SAAS,EAAE,EAAE;AAAA,EAC3D;AAIA,MAAI,KAAK,KAAK,SAAS,GAAG;AACxB,UAAM,KAAK,IAAI,UAAU,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG;AACpD,eAAW,QAAQ,KAAK,KAAM,OAAM,KAAK,SAAS,KAAK,EAAE,WAAM,KAAK,MAAM,EA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