@gencode/cli 0.11.0 → 0.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @gencode/cli
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5773651: Add the `aimax-server` one-shot prestart entry for container deployments. It starts a local HTTP server, warms system-level AIMax runtime state before the user request arrives, accepts one `/run` request with the same run options used by `aimax run`, delegates execution through the CLI path, and exits after the agent loop finishes. The normal `aimax run` command remains available as the cold-path fallback.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5773651]
12
+ - @gencode/agents@0.14.0
13
+
3
14
  ## 0.11.0
4
15
 
5
16
  ### Minor Changes
package/dist/bin.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as e,i as t,r as n,t as r}from"./program-C9mX7rDy.js";function i(){globalThis.getPkgPath||(globalThis.getPkgPath=()=>`@wizard/aimax`)}i();function a(e){return e instanceof Error?e.stack??`${e.name}: ${e.message}`:String(e)}function o(e){let t=e.shutdownTimeoutMs??2e3,n=!1,r=(r,i)=>{if(e.logError(`Fatal ${r}: ${a(i)}`),n)return;n=!0;let o=setTimeout(()=>e.exit(1),t);typeof o.unref==`function`&&o.unref(),Promise.resolve().then(()=>e.shutdown()).catch(()=>{}).finally(()=>{clearTimeout(o),e.exit(1)})};e.proc.on(`uncaughtException`,e=>r(`uncaughtException`,e)),e.proc.on(`unhandledRejection`,e=>r(`unhandledRejection`,e))}const s=Date.now(),c=process.env.AIMAX_DATA_DIR,l=process.argv.includes(`run`)&&process.argv.includes(`--encrypt-sessions`),u=process.argv.includes(`run`)||process.argv.includes(`resume`);function d(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--message-id`||n===`--messageId`)return e[t+1];if(n?.startsWith(`--message-id=`))return n.slice(13);if(n?.startsWith(`--messageId=`))return n.slice(12)}}c&&!l&&!u&&n(c,{messageId:d(process.argv)}),o({proc:process,logError:e=>t.error(e),shutdown:e,exit:e=>process.exit(e)}),t.info(`AIMax CLI starting (pid=${process.pid})`,{dataDir:c,encryptedRun:l,loggerDeferred:!!(c&&(l||u))}),r().parseAsync(process.argv).catch(e=>{t.error(`Unexpected error: ${e.message}`),process.exit(1)}).finally(()=>{let n=Date.now()-s;return t.info(`AIMax CLI exited (total uptime: ${n}ms)`),e()});export{};
2
+ import{a as e,i as t,o as n,t as r}from"./program-BM-oBQl9.js";function i(){globalThis.getPkgPath||(globalThis.getPkgPath=()=>`@wizard/aimax`)}i();function a(e){return e instanceof Error?e.stack??`${e.name}: ${e.message}`:String(e)}function o(e){let t=e.shutdownTimeoutMs??2e3,n=!1,r=(r,i)=>{if(e.logError(`Fatal ${r}: ${a(i)}`),n)return;n=!0;let o=setTimeout(()=>e.exit(1),t);typeof o.unref==`function`&&o.unref(),Promise.resolve().then(()=>e.shutdown()).catch(()=>{}).finally(()=>{clearTimeout(o),e.exit(1)})};e.proc.on(`uncaughtException`,e=>r(`uncaughtException`,e)),e.proc.on(`unhandledRejection`,e=>r(`unhandledRejection`,e))}const s=Date.now(),c=process.env.AIMAX_DATA_DIR,l=process.argv.includes(`run`)&&process.argv.includes(`--encrypt-sessions`),u=process.argv.includes(`run`)||process.argv.includes(`resume`);function d(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`--message-id`||n===`--messageId`)return e[t+1];if(n?.startsWith(`--message-id=`))return n.slice(13);if(n?.startsWith(`--messageId=`))return n.slice(12)}}c&&!l&&!u&&t(c,{messageId:d(process.argv)}),o({proc:process,logError:t=>e.error(t),shutdown:n,exit:e=>process.exit(e)}),e.info(`AIMax CLI starting (pid=${process.pid})`,{dataDir:c,encryptedRun:l,loggerDeferred:!!(c&&(l||u))}),r().parseAsync(process.argv).catch(t=>{e.error(`Unexpected error: ${t.message}`),process.exit(1)}).finally(()=>{let t=Date.now()-s;return e.info(`AIMax CLI exited (total uptime: ${t}ms)`),n()});export{};
@@ -0,0 +1,53 @@
1
+ import { createProgram, getDataDir } from "./program.js";
2
+ import { Command } from "commander";
3
+ import { Channel } from "@gencode/shared";
4
+
5
+ //#region src/output.d.ts
6
+ type OutputFormat = "text" | "json";
7
+ //#endregion
8
+ //#region src/commands/run.d.ts
9
+ type RunOptions = {
10
+ dataDir?: string;
11
+ projectDir?: string;
12
+ systemAgentsDir?: string;
13
+ agent?: string;
14
+ user?: string;
15
+ message?: string;
16
+ fromFile?: string;
17
+ skillsLoadPaths?: string;
18
+ autoSkillsLoadEnabled?: string;
19
+ autoSkillsReviewMode?: string;
20
+ sessionId?: string;
21
+ sessionStore?: string;
22
+ messageId?: string;
23
+ channel?: Channel;
24
+ baseUrl?: string;
25
+ apiKey?: string;
26
+ authToken?: string;
27
+ model?: string;
28
+ apiFormat?: string;
29
+ contextWindow?: string;
30
+ flashModel?: string;
31
+ thinking?: string;
32
+ callbackUrl?: string;
33
+ streamUrl?: string;
34
+ streamAuthToken?: string;
35
+ streamEvents?: string;
36
+ timeout?: string;
37
+ output?: OutputFormat;
38
+ pluginsConfig?: string;
39
+ artifactsUrlWhitelist?: string;
40
+ env?: string;
41
+ resumeRequestId?: string;
42
+ resumeInputJson?: string;
43
+ resumeFromFile?: string;
44
+ goal?: string;
45
+ goalFile?: string;
46
+ tokenBudget?: string;
47
+ force?: boolean;
48
+ encryptSessions?: boolean;
49
+ disableTopicSegmentation?: boolean;
50
+ };
51
+ declare function executeRun(options: RunOptions): Promise<void>;
52
+ //#endregion
53
+ export { type RunOptions, createProgram, executeRun, getDataDir };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./program-BM-oBQl9.js";export{n as createProgram,t as executeRun,e as getDataDir};
@@ -37,4 +37,4 @@ ${n}
37
37
  </tbody>
38
38
  </table>
39
39
  </body>
40
- </html>`,i=w(e,`index.html`);return Te(i,r,`utf8`),i}async function za(e,t,n){Se(t,{recursive:!0});let r=fe(e,n),i=[],a=[],o=[],s=[],c;try{c=await ke(r)}catch(e){throw e.code===`ENOENT`?Error(`Sessions directory not found: ${r}`):e}for(let r of c.sort()){let c=pe(e,r,n);if(!x(c)){a.push({sessionId:r,reason:`no transcript.jsonl`});continue}try{let a=w(t,`${r}.html`),l=await Ia(e,r,{...n,outputPath:a});o.push(...l.warnings),i.push({sessionId:r,path:l.outputPath}),s.push({sessionId:r,fileName:`${r}.html`,sourcePath:c})}catch(e){a.push({sessionId:r,reason:e.message})}}let l;return n?.writeIndex!==!1&&s.length>0&&(l=Ra(t,s)),{exported:i,skipped:a,warnings:o,indexPath:l}}async function Ba(e,t,n){Se(t,{recursive:!0});let r=[],i=[],a=[],o=[],s=[];for await(let t of Oe(e,{cwd:process.cwd()}))s.push(t);if(s.sort(),s.length===0)throw Error(`No files matched glob: ${e}`);for(let e of s){let n=T(e),s=Ee(C(n));if(!x(n)){i.push({sessionId:s,reason:`file missing`});continue}try{let e=await Pa(n,{outputPath:w(t,`${s}.html`),sessionId:s,dataDir:xa(n)});a.push(...e.warnings),r.push({sessionId:s,path:e.outputPath}),o.push({sessionId:s,fileName:`${s}.html`,sourcePath:n})}catch(e){i.push({sessionId:s,reason:e.message})}}let c;return n?.writeIndex!==!1&&o.length>0&&(c=Ra(t,o)),{exported:r,skipped:i,warnings:a,indexPath:c}}function Va(e){e.command(`export-html`).description(`Export transcript.jsonl to standalone HTML files for browsing`).argument(`[transcript]`,`Path to transcript.jsonl (or use -d/-s, --all, or --glob)`).option(`-d, --data-dir <path>`,`Data directory containing .aimax/sessions`).option(`-s, --session-id <id>`,`Session ID under the data directory`).option(`--session-store <name>`,`Session store under .aimax (default: sessions)`).option(`-o, --output <path>`,`Output HTML path for a single export`).option(`--output-dir <path>`,`Output directory for batch export`).option(`--all`,`Export all sessions under --data-dir (requires --output-dir)`).option(`--glob <pattern>`,`Export transcripts matching a glob (requires --output-dir)`).option(`--no-index`,`Skip writing index.html in batch mode`).option(`--encrypt-sessions`,`Enable gocryptfs-backed encryption for the .aimax data directory`).action(async(e,t,n)=>{let r=n.opts();try{if(r.glob){r.outputDir||(F(`error: --glob requires --output-dir`),process.exit(1)),Ua(await Ba(r.glob,T(r.outputDir),{writeIndex:!r.noIndex}));return}if(r.all){(!r.dataDir||!r.outputDir)&&(F(`error: --all requires --data-dir and --output-dir`),process.exit(1)),await H(r.dataDir,r,async()=>{let e=r.sessionStore?y(r.sessionStore):void 0;Ua(await za(r.dataDir,T(r.outputDir),{storeName:e,writeIndex:!r.noIndex}))});return}if(e){let t=T(e);x(t)||(F(`File not found: ${t}`),process.exit(1)),r.outputDir&&Se(T(r.outputDir),{recursive:!0});let n=await Fa(t,{outputPath:r.outputDir?w(T(r.outputDir),`${Ee(C(t))}.html`):r.output});console.log(n);return}(!r.dataDir||!r.sessionId)&&(F(`error: specify <transcript.jsonl>, --glob, (-d --all --output-dir), or (-d -s)`),process.exit(1)),Ha(r.sessionId),await H(r.dataDir,r,async()=>{let e=r.sessionStore?y(r.sessionStore):void 0;r.outputDir&&Se(T(r.outputDir),{recursive:!0});let t=r.outputDir?T(r.outputDir,`${r.sessionId}.html`):r.output,n=await La(r.dataDir,r.sessionId,{outputPath:t,storeName:e});console.log(n)})}catch(e){F(`Error exporting HTML: ${e.message}`),process.exit(1)}})}function Ha(e){if(e.includes(`..`)||e.startsWith(`/`))throw Error(`Invalid session id: ${e}`)}function Ua(e){for(let t of e.exported)console.log(t.path);for(let t of e.warnings??[])F(`warning: ${t}`);for(let t of e.skipped)F(`skipped ${t.sessionId}: ${t.reason}`);e.indexPath&&console.log(e.indexPath),console.log(`exported ${e.exported.length}, skipped ${e.skipped.length}`)}const Wa=e(import.meta.url)(`../package.json`);function Ga(){return process.env.AIMAX_DATA_DIR||process.cwd()}function Ka(){let e=new t;return e.name(`aimax`).description(`AIMax CLI — runs agent tasks in a containerized environment`).version(Wa.version),pi(e),_r(e),Gi(e),Qi(e),mi(e),Va(e),oa(e),Ri(e),rn(e),Ci(e),Mi(e,Ga),Li(e,Ga),e}export{ct as a,N as i,Ga as n,M as r,Ka as t};
40
+ </html>`,i=w(e,`index.html`);return Te(i,r,`utf8`),i}async function za(e,t,n){Se(t,{recursive:!0});let r=fe(e,n),i=[],a=[],o=[],s=[],c;try{c=await ke(r)}catch(e){throw e.code===`ENOENT`?Error(`Sessions directory not found: ${r}`):e}for(let r of c.sort()){let c=pe(e,r,n);if(!x(c)){a.push({sessionId:r,reason:`no transcript.jsonl`});continue}try{let a=w(t,`${r}.html`),l=await Ia(e,r,{...n,outputPath:a});o.push(...l.warnings),i.push({sessionId:r,path:l.outputPath}),s.push({sessionId:r,fileName:`${r}.html`,sourcePath:c})}catch(e){a.push({sessionId:r,reason:e.message})}}let l;return n?.writeIndex!==!1&&s.length>0&&(l=Ra(t,s)),{exported:i,skipped:a,warnings:o,indexPath:l}}async function Ba(e,t,n){Se(t,{recursive:!0});let r=[],i=[],a=[],o=[],s=[];for await(let t of Oe(e,{cwd:process.cwd()}))s.push(t);if(s.sort(),s.length===0)throw Error(`No files matched glob: ${e}`);for(let e of s){let n=T(e),s=Ee(C(n));if(!x(n)){i.push({sessionId:s,reason:`file missing`});continue}try{let e=await Pa(n,{outputPath:w(t,`${s}.html`),sessionId:s,dataDir:xa(n)});a.push(...e.warnings),r.push({sessionId:s,path:e.outputPath}),o.push({sessionId:s,fileName:`${s}.html`,sourcePath:n})}catch(e){i.push({sessionId:s,reason:e.message})}}let c;return n?.writeIndex!==!1&&o.length>0&&(c=Ra(t,o)),{exported:r,skipped:i,warnings:a,indexPath:c}}function Va(e){e.command(`export-html`).description(`Export transcript.jsonl to standalone HTML files for browsing`).argument(`[transcript]`,`Path to transcript.jsonl (or use -d/-s, --all, or --glob)`).option(`-d, --data-dir <path>`,`Data directory containing .aimax/sessions`).option(`-s, --session-id <id>`,`Session ID under the data directory`).option(`--session-store <name>`,`Session store under .aimax (default: sessions)`).option(`-o, --output <path>`,`Output HTML path for a single export`).option(`--output-dir <path>`,`Output directory for batch export`).option(`--all`,`Export all sessions under --data-dir (requires --output-dir)`).option(`--glob <pattern>`,`Export transcripts matching a glob (requires --output-dir)`).option(`--no-index`,`Skip writing index.html in batch mode`).option(`--encrypt-sessions`,`Enable gocryptfs-backed encryption for the .aimax data directory`).action(async(e,t,n)=>{let r=n.opts();try{if(r.glob){r.outputDir||(F(`error: --glob requires --output-dir`),process.exit(1)),Ua(await Ba(r.glob,T(r.outputDir),{writeIndex:!r.noIndex}));return}if(r.all){(!r.dataDir||!r.outputDir)&&(F(`error: --all requires --data-dir and --output-dir`),process.exit(1)),await H(r.dataDir,r,async()=>{let e=r.sessionStore?y(r.sessionStore):void 0;Ua(await za(r.dataDir,T(r.outputDir),{storeName:e,writeIndex:!r.noIndex}))});return}if(e){let t=T(e);x(t)||(F(`File not found: ${t}`),process.exit(1)),r.outputDir&&Se(T(r.outputDir),{recursive:!0});let n=await Fa(t,{outputPath:r.outputDir?w(T(r.outputDir),`${Ee(C(t))}.html`):r.output});console.log(n);return}(!r.dataDir||!r.sessionId)&&(F(`error: specify <transcript.jsonl>, --glob, (-d --all --output-dir), or (-d -s)`),process.exit(1)),Ha(r.sessionId),await H(r.dataDir,r,async()=>{let e=r.sessionStore?y(r.sessionStore):void 0;r.outputDir&&Se(T(r.outputDir),{recursive:!0});let t=r.outputDir?T(r.outputDir,`${r.sessionId}.html`):r.output,n=await La(r.dataDir,r.sessionId,{outputPath:t,storeName:e});console.log(n)})}catch(e){F(`Error exporting HTML: ${e.message}`),process.exit(1)}})}function Ha(e){if(e.includes(`..`)||e.startsWith(`/`))throw Error(`Invalid session id: ${e}`)}function Ua(e){for(let t of e.exported)console.log(t.path);for(let t of e.warnings??[])F(`warning: ${t}`);for(let t of e.skipped)F(`skipped ${t.sessionId}: ${t.reason}`);e.indexPath&&console.log(e.indexPath),console.log(`exported ${e.exported.length}, skipped ${e.skipped.length}`)}const Wa=e(import.meta.url)(`../package.json`);function Ga(){return process.env.AIMAX_DATA_DIR||process.cwd()}function Ka(){let e=new t;return e.name(`aimax`).description(`AIMax CLI — runs agent tasks in a containerized environment`).version(Wa.version),pi(e),_r(e),Gi(e),Qi(e),mi(e),Va(e),oa(e),Ri(e),rn(e),Ci(e),Mi(e,Ga),Li(e,Ga),e}export{N as a,M as i,Ga as n,ct as o,di as r,Ka as t};
package/dist/program.js CHANGED
@@ -1 +1 @@
1
- import{n as e,t}from"./program-C9mX7rDy.js";export{t as createProgram,e as getDataDir};
1
+ import{n as e,t}from"./program-BM-oBQl9.js";export{t as createProgram,e as getDataDir};
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@gencode/cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "aimax": "./dist/bin.js"
7
7
  },
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./program": {
10
14
  "types": "./dist/program.d.ts",
11
15
  "default": "./dist/program.js"
12
16
  }
@@ -24,7 +28,7 @@
24
28
  "commander": "^14.0.3",
25
29
  "gensign-node": "latest",
26
30
  "log4js": "^6.9.1",
27
- "@gencode/agents": "0.13.0",
31
+ "@gencode/agents": "0.14.0",
28
32
  "@gencode/shared": "0.3.0"
29
33
  },
30
34
  "devDependencies": {