@aexhq/cli 0.30.6 → 0.32.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/README.md +1 -1
- package/dist/index.js +18 -55
- 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
|
|
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
|
|
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.
|
|
33
|
+
await aex.listSessions();
|
|
35
34
|
process.stdout.write("Aex API: ok\n");
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
@@ -43,17 +42,12 @@ async function sessionCommand(aex, argv) {
|
|
|
43
42
|
const [command, id, ...tail] = argv;
|
|
44
43
|
switch (command) {
|
|
45
44
|
case "list": {
|
|
46
|
-
|
|
47
|
-
print({
|
|
48
|
-
data: list.data.map(summary),
|
|
49
|
-
hasMore: list.hasMore,
|
|
50
|
-
...(list.nextCursor === undefined ? {} : { nextCursor: list.nextCursor }),
|
|
51
|
-
});
|
|
45
|
+
print(await aex.listSessions());
|
|
52
46
|
return;
|
|
53
47
|
}
|
|
54
48
|
case "get": {
|
|
55
49
|
requireId(id, command);
|
|
56
|
-
print(
|
|
50
|
+
print((await aex.getSession(id)).state);
|
|
57
51
|
return;
|
|
58
52
|
}
|
|
59
53
|
case "send": {
|
|
@@ -61,32 +55,17 @@ async function sessionCommand(aex, argv) {
|
|
|
61
55
|
const message = tail.join(" ").trim();
|
|
62
56
|
if (message === "")
|
|
63
57
|
usage("session send requires a message");
|
|
64
|
-
const session = await aex.
|
|
65
|
-
|
|
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);
|
|
58
|
+
const session = await aex.getSession(id);
|
|
59
|
+
print(await session.send(message));
|
|
81
60
|
return;
|
|
82
61
|
}
|
|
83
62
|
case "events": {
|
|
84
63
|
requireId(id, command);
|
|
85
|
-
const session = await aex.
|
|
64
|
+
const session = await aex.getSession(id);
|
|
86
65
|
const controller = new AbortController();
|
|
87
66
|
process.once("SIGINT", () => controller.abort());
|
|
88
67
|
try {
|
|
89
|
-
for await (const event of session.events(
|
|
68
|
+
for await (const event of session.events()) {
|
|
90
69
|
process.stdout.write(`${JSON.stringify(event)}\n`);
|
|
91
70
|
}
|
|
92
71
|
}
|
|
@@ -98,14 +77,20 @@ async function sessionCommand(aex, argv) {
|
|
|
98
77
|
}
|
|
99
78
|
case "cancel": {
|
|
100
79
|
requireId(id, command);
|
|
101
|
-
const session = await aex.
|
|
80
|
+
const session = await aex.getSession(id);
|
|
102
81
|
await session.cancel();
|
|
103
|
-
print(
|
|
82
|
+
print(session.state);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
case "end": {
|
|
86
|
+
requireId(id, command);
|
|
87
|
+
const session = await aex.getSession(id);
|
|
88
|
+
print(await session.end());
|
|
104
89
|
return;
|
|
105
90
|
}
|
|
106
91
|
case "delete": {
|
|
107
92
|
requireId(id, command);
|
|
108
|
-
const session = await aex.
|
|
93
|
+
const session = await aex.getSession(id);
|
|
109
94
|
await session.delete();
|
|
110
95
|
return;
|
|
111
96
|
}
|
|
@@ -113,21 +98,6 @@ async function sessionCommand(aex, argv) {
|
|
|
113
98
|
usage(command === undefined ? "Missing session command" : `Unknown session command: ${command}`);
|
|
114
99
|
}
|
|
115
100
|
}
|
|
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
101
|
async function client() {
|
|
132
102
|
const apiKey = process.env.AEX_API_KEY ?? (await readConfig())?.apiKey;
|
|
133
103
|
if (apiKey === undefined || apiKey === "") {
|
|
@@ -212,13 +182,6 @@ async function readSecret(prompt) {
|
|
|
212
182
|
process.stdin.on("data", onData);
|
|
213
183
|
});
|
|
214
184
|
}
|
|
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
185
|
function requireId(id, command) {
|
|
223
186
|
if (id === undefined || id === "")
|
|
224
187
|
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.
|
|
3
|
+
"version": "0.32.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.
|
|
34
|
-
"zod": "4.4.3"
|
|
33
|
+
"@aexhq/sdk": "0.64.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/node": "^24.0.0",
|