@aexhq/cli 0.30.5 → 0.31.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +14 -50
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -5,7 +5,7 @@ npm install --global @aexhq/cli
5
5
  aex login
6
6
  aex session list
7
7
  aex session send ses_... "Summarise the repository."
8
- aex session output ses_... --schema result.schema.json "Return the key findings."
8
+ aex session events ses_...
9
9
  ```
10
10
 
11
11
  The CLI stores the pasted API key in `~/.aex/config.json`, requests mode `0600` on POSIX systems,
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join } from "node:path";
5
5
  import process from "node:process";
6
6
  import { Aex, AexError } from "@aexhq/sdk";
7
- import * as z from "zod";
8
7
  const HELP = `Aex — the session backend for AI apps
9
8
 
10
9
  Usage:
@@ -13,9 +12,9 @@ Usage:
13
12
  aex session list
14
13
  aex session get <session-id>
15
14
  aex session send <session-id> <message>
16
- aex session output <session-id> --schema <schema.json> <message>
17
15
  aex session events <session-id>
18
16
  aex session cancel <session-id>
17
+ aex session end <session-id>
19
18
  aex session delete <session-id>
20
19
 
21
20
  The API defaults to https://api.aex.dev.`;
@@ -31,7 +30,7 @@ async function main(argv) {
31
30
  }
32
31
  const aex = await client();
33
32
  if (command === "doctor") {
34
- await aex.sessions.list({ limit: 1 });
33
+ await aex.sessions.list();
35
34
  process.stdout.write("Aex API: ok\n");
36
35
  return;
37
36
  }
@@ -44,16 +43,12 @@ async function sessionCommand(aex, argv) {
44
43
  switch (command) {
45
44
  case "list": {
46
45
  const list = await aex.sessions.list();
47
- print({
48
- data: list.data.map(summary),
49
- hasMore: list.hasMore,
50
- ...(list.nextCursor === undefined ? {} : { nextCursor: list.nextCursor }),
51
- });
46
+ print(list.map((session) => session.state));
52
47
  return;
53
48
  }
54
49
  case "get": {
55
50
  requireId(id, command);
56
- print(summary(await aex.sessions.get(id)));
51
+ print((await aex.sessions.get(id)).state);
57
52
  return;
58
53
  }
59
54
  case "send": {
@@ -62,22 +57,7 @@ async function sessionCommand(aex, argv) {
62
57
  if (message === "")
63
58
  usage("session send requires a message");
64
59
  const session = await aex.sessions.get(id);
65
- process.stdout.write(`${await session.send(message)}\n`);
66
- return;
67
- }
68
- case "output": {
69
- requireId(id, command);
70
- const { value: schemaPath, rest } = takeFlag(tail, "--schema");
71
- if (schemaPath === undefined)
72
- usage("session output requires --schema <schema.json>");
73
- const document = JSON.parse(await readFile(resolve(schemaPath), "utf8"));
74
- const schema = z.fromJSONSchema(document);
75
- const input = rest.join(" ").trim();
76
- if (input === "")
77
- usage("session output requires a message");
78
- const session = await aex.sessions.get(id);
79
- const result = await session.send(input, { output: schema });
80
- print(result);
60
+ print(await session.send(message));
81
61
  return;
82
62
  }
83
63
  case "events": {
@@ -86,7 +66,7 @@ async function sessionCommand(aex, argv) {
86
66
  const controller = new AbortController();
87
67
  process.once("SIGINT", () => controller.abort());
88
68
  try {
89
- for await (const event of session.events({ signal: controller.signal })) {
69
+ for await (const event of session.events()) {
90
70
  process.stdout.write(`${JSON.stringify(event)}\n`);
91
71
  }
92
72
  }
@@ -100,7 +80,13 @@ async function sessionCommand(aex, argv) {
100
80
  requireId(id, command);
101
81
  const session = await aex.sessions.get(id);
102
82
  await session.cancel();
103
- print(summary(session));
83
+ print(session.state);
84
+ return;
85
+ }
86
+ case "end": {
87
+ requireId(id, command);
88
+ const session = await aex.sessions.get(id);
89
+ print(await session.end());
104
90
  return;
105
91
  }
106
92
  case "delete": {
@@ -113,21 +99,6 @@ async function sessionCommand(aex, argv) {
113
99
  usage(command === undefined ? "Missing session command" : `Unknown session command: ${command}`);
114
100
  }
115
101
  }
116
- function summary(session) {
117
- return {
118
- id: session.id,
119
- parentId: session.parentId,
120
- rootId: session.rootId,
121
- depth: session.depth,
122
- state: session.state,
123
- turnState: session.turnState,
124
- model: session.model,
125
- createdAt: session.createdAt,
126
- updatedAt: session.updatedAt,
127
- retainUntil: session.retainUntil,
128
- metadata: session.metadata,
129
- };
130
- }
131
102
  async function client() {
132
103
  const apiKey = process.env.AEX_API_KEY ?? (await readConfig())?.apiKey;
133
104
  if (apiKey === undefined || apiKey === "") {
@@ -212,13 +183,6 @@ async function readSecret(prompt) {
212
183
  process.stdin.on("data", onData);
213
184
  });
214
185
  }
215
- function takeFlag(argv, name) {
216
- const index = argv.indexOf(name);
217
- if (index === -1)
218
- return { value: undefined, rest: argv };
219
- const value = argv[index + 1];
220
- return { value, rest: argv.filter((_, itemIndex) => itemIndex !== index && itemIndex !== index + 1) };
221
- }
222
186
  function requireId(id, command) {
223
187
  if (id === undefined || id === "")
224
188
  usage(`session ${command} requires a session id`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexhq/cli",
3
- "version": "0.30.5",
3
+ "version": "0.31.0",
4
4
  "description": "Command-line client for Aex sessions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://aex.dev",
@@ -30,8 +30,7 @@
30
30
  "test": "tsc -p tsconfig.json && node --test"
31
31
  },
32
32
  "dependencies": {
33
- "@aexhq/sdk": "0.62.0",
34
- "zod": "4.4.3"
33
+ "@aexhq/sdk": "0.63.0"
35
34
  },
36
35
  "devDependencies": {
37
36
  "@types/node": "^24.0.0",