@agentuity/cli 1.0.23 → 1.0.25
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/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/user-cache.d.ts +20 -0
- package/dist/cache/user-cache.d.ts.map +1 -0
- package/dist/cache/user-cache.js +79 -0
- package/dist/cache/user-cache.js.map +1 -0
- package/dist/cmd/auth/logout.d.ts.map +1 -1
- package/dist/cmd/auth/logout.js +3 -1
- package/dist/cmd/auth/logout.js.map +1 -1
- package/dist/cmd/build/entry-generator.d.ts +4 -0
- package/dist/cmd/build/entry-generator.d.ts.map +1 -1
- package/dist/cmd/build/entry-generator.js +18 -3
- package/dist/cmd/build/entry-generator.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts +1 -0
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +11 -9
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/cloud/db/index.d.ts.map +1 -1
- package/dist/cmd/cloud/db/index.js +2 -0
- package/dist/cmd/cloud/db/index.js.map +1 -1
- package/dist/cmd/cloud/db/stats.d.ts +3 -0
- package/dist/cmd/cloud/db/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/db/stats.js +66 -0
- package/dist/cmd/cloud/db/stats.js.map +1 -0
- package/dist/cmd/cloud/email/create.d.ts.map +1 -1
- package/dist/cmd/cloud/email/create.js +15 -10
- package/dist/cmd/cloud/email/create.js.map +1 -1
- package/dist/cmd/cloud/email/delete.js +1 -1
- package/dist/cmd/cloud/email/delete.js.map +1 -1
- package/dist/cmd/cloud/email/destination/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/email/destination/delete.js +6 -2
- package/dist/cmd/cloud/email/destination/delete.js.map +1 -1
- package/dist/cmd/cloud/email/destination/list.js +1 -1
- package/dist/cmd/cloud/email/destination/list.js.map +1 -1
- package/dist/cmd/cloud/email/destination/url.d.ts.map +1 -1
- package/dist/cmd/cloud/email/destination/url.js +5 -4
- package/dist/cmd/cloud/email/destination/url.js.map +1 -1
- package/dist/cmd/cloud/email/get.d.ts.map +1 -1
- package/dist/cmd/cloud/email/get.js +2 -4
- package/dist/cmd/cloud/email/get.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/get.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/get.js +2 -3
- package/dist/cmd/cloud/email/inbound/get.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/list.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/list.js +1 -3
- package/dist/cmd/cloud/email/inbound/list.js.map +1 -1
- package/dist/cmd/cloud/email/inbound/schemas.d.ts +3 -1
- package/dist/cmd/cloud/email/inbound/schemas.d.ts.map +1 -1
- package/dist/cmd/cloud/email/inbound/schemas.js +3 -1
- package/dist/cmd/cloud/email/inbound/schemas.js.map +1 -1
- package/dist/cmd/cloud/email/index.d.ts.map +1 -1
- package/dist/cmd/cloud/email/index.js +2 -0
- package/dist/cmd/cloud/email/index.js.map +1 -1
- package/dist/cmd/cloud/email/list.d.ts.map +1 -1
- package/dist/cmd/cloud/email/list.js +9 -2
- package/dist/cmd/cloud/email/list.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/get.js +4 -4
- package/dist/cmd/cloud/email/outbound/get.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/list.js +3 -3
- package/dist/cmd/cloud/email/outbound/list.js.map +1 -1
- package/dist/cmd/cloud/email/outbound/schemas.d.ts +2 -2
- package/dist/cmd/cloud/email/outbound/schemas.js +2 -2
- package/dist/cmd/cloud/email/outbound/schemas.js.map +1 -1
- package/dist/cmd/cloud/email/send.d.ts.map +1 -1
- package/dist/cmd/cloud/email/send.js +9 -15
- package/dist/cmd/cloud/email/send.js.map +1 -1
- package/dist/cmd/cloud/email/stats.d.ts +3 -0
- package/dist/cmd/cloud/email/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/email/stats.js +65 -0
- package/dist/cmd/cloud/email/stats.js.map +1 -0
- package/dist/cmd/cloud/email/util.d.ts +4 -7
- package/dist/cmd/cloud/email/util.d.ts.map +1 -1
- package/dist/cmd/cloud/email/util.js +8 -24
- package/dist/cmd/cloud/email/util.js.map +1 -1
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +2 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/queue/get.js +4 -4
- package/dist/cmd/cloud/queue/get.js.map +1 -1
- package/dist/cmd/cloud/queue/receive.d.ts.map +1 -1
- package/dist/cmd/cloud/queue/receive.js +11 -7
- package/dist/cmd/cloud/queue/receive.js.map +1 -1
- package/dist/cmd/cloud/queue/stats.js +3 -3
- package/dist/cmd/cloud/queue/stats.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.js +71 -0
- package/dist/cmd/cloud/sandbox/checkpoint/create.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js +78 -0
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts +2 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.js +33 -0
- package/dist/cmd/cloud/sandbox/checkpoint/index.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.js +72 -0
- package/dist/cmd/cloud/sandbox/checkpoint/list.js.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js +61 -0
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js.map +1 -0
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +5 -3
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/index.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/index.js +4 -0
- package/dist/cmd/cloud/sandbox/index.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js +13 -10
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js +3 -3
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/stats.d.ts +3 -0
- package/dist/cmd/cloud/sandbox/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/sandbox/stats.js +72 -0
- package/dist/cmd/cloud/sandbox/stats.js.map +1 -0
- package/dist/cmd/cloud/schedule/create.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/create.js +3 -4
- package/dist/cmd/cloud/schedule/create.js.map +1 -1
- package/dist/cmd/cloud/schedule/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delete.js +6 -4
- package/dist/cmd/cloud/schedule/delete.js.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/get.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/get.js +3 -4
- package/dist/cmd/cloud/schedule/delivery/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/delivery/list.js +2 -3
- package/dist/cmd/cloud/schedule/delivery/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/create.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/create.js +10 -5
- package/dist/cmd/cloud/schedule/destination/create.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/delete.js +2 -3
- package/dist/cmd/cloud/schedule/destination/delete.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/get.js +15 -13
- package/dist/cmd/cloud/schedule/destination/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/index.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/index.js.map +1 -1
- package/dist/cmd/cloud/schedule/destination/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/destination/list.js +13 -9
- package/dist/cmd/cloud/schedule/destination/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/get.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/get.js +19 -12
- package/dist/cmd/cloud/schedule/get.js.map +1 -1
- package/dist/cmd/cloud/schedule/index.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/index.js +6 -1
- package/dist/cmd/cloud/schedule/index.js.map +1 -1
- package/dist/cmd/cloud/schedule/list.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/list.js +2 -3
- package/dist/cmd/cloud/schedule/list.js.map +1 -1
- package/dist/cmd/cloud/schedule/stats.d.ts +3 -0
- package/dist/cmd/cloud/schedule/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/stats.js +64 -0
- package/dist/cmd/cloud/schedule/stats.js.map +1 -0
- package/dist/cmd/cloud/schedule/update.js +5 -5
- package/dist/cmd/cloud/schedule/update.js.map +1 -1
- package/dist/cmd/cloud/schedule/util.d.ts +4 -5
- package/dist/cmd/cloud/schedule/util.d.ts.map +1 -1
- package/dist/cmd/cloud/schedule/util.js +6 -7
- package/dist/cmd/cloud/schedule/util.js.map +1 -1
- package/dist/cmd/cloud/services/index.d.ts +3 -0
- package/dist/cmd/cloud/services/index.d.ts.map +1 -0
- package/dist/cmd/cloud/services/index.js +10 -0
- package/dist/cmd/cloud/services/index.js.map +1 -0
- package/dist/cmd/cloud/services/stats.d.ts +3 -0
- package/dist/cmd/cloud/services/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/services/stats.js +153 -0
- package/dist/cmd/cloud/services/stats.js.map +1 -0
- package/dist/cmd/cloud/stream/index.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/index.js +8 -1
- package/dist/cmd/cloud/stream/index.js.map +1 -1
- package/dist/cmd/cloud/stream/stats.d.ts +3 -0
- package/dist/cmd/cloud/stream/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/stream/stats.js +64 -0
- package/dist/cmd/cloud/stream/stats.js.map +1 -0
- package/dist/cmd/cloud/task/attachment.d.ts +2 -0
- package/dist/cmd/cloud/task/attachment.d.ts.map +1 -0
- package/dist/cmd/cloud/task/attachment.js +393 -0
- package/dist/cmd/cloud/task/attachment.js.map +1 -0
- package/dist/cmd/cloud/task/create.d.ts.map +1 -1
- package/dist/cmd/cloud/task/create.js +125 -5
- package/dist/cmd/cloud/task/create.js.map +1 -1
- package/dist/cmd/cloud/task/get.d.ts.map +1 -1
- package/dist/cmd/cloud/task/get.js +33 -14
- package/dist/cmd/cloud/task/get.js.map +1 -1
- package/dist/cmd/cloud/task/index.d.ts.map +1 -1
- package/dist/cmd/cloud/task/index.js +14 -1
- package/dist/cmd/cloud/task/index.js.map +1 -1
- package/dist/cmd/cloud/task/list.d.ts.map +1 -1
- package/dist/cmd/cloud/task/list.js +32 -17
- package/dist/cmd/cloud/task/list.js.map +1 -1
- package/dist/cmd/cloud/task/stats.d.ts +3 -0
- package/dist/cmd/cloud/task/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/task/stats.js +68 -0
- package/dist/cmd/cloud/task/stats.js.map +1 -0
- package/dist/cmd/cloud/task/update.d.ts.map +1 -1
- package/dist/cmd/cloud/task/update.js +0 -1
- package/dist/cmd/cloud/task/update.js.map +1 -1
- package/dist/cmd/cloud/task/util.d.ts +4 -7
- package/dist/cmd/cloud/task/util.d.ts.map +1 -1
- package/dist/cmd/cloud/task/util.js +6 -12
- package/dist/cmd/cloud/task/util.js.map +1 -1
- package/dist/cmd/cloud/vector/get.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/get.js +17 -12
- package/dist/cmd/cloud/vector/get.js.map +1 -1
- package/dist/cmd/cloud/vector/stats.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/stats.js +10 -7
- package/dist/cmd/cloud/vector/stats.js.map +1 -1
- package/dist/cmd/cloud/webhook/create.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/create.js +6 -1
- package/dist/cmd/cloud/webhook/create.js.map +1 -1
- package/dist/cmd/cloud/webhook/deliveries.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/deliveries.js +12 -3
- package/dist/cmd/cloud/webhook/deliveries.js.map +1 -1
- package/dist/cmd/cloud/webhook/destinations.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/destinations.js +19 -9
- package/dist/cmd/cloud/webhook/destinations.js.map +1 -1
- package/dist/cmd/cloud/webhook/get.js +2 -2
- package/dist/cmd/cloud/webhook/get.js.map +1 -1
- package/dist/cmd/cloud/webhook/receipts.d.ts.map +1 -1
- package/dist/cmd/cloud/webhook/receipts.js +19 -3
- package/dist/cmd/cloud/webhook/receipts.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +80 -34
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/tui.d.ts +4 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +8 -0
- package/dist/tui.js.map +1 -1
- package/package.json +6 -6
- package/src/cache/index.ts +2 -0
- package/src/cache/user-cache.ts +93 -0
- package/src/cmd/auth/logout.ts +3 -1
- package/src/cmd/build/entry-generator.ts +34 -4
- package/src/cmd/build/vite/bun-dev-server.ts +21 -9
- package/src/cmd/cloud/db/index.ts +2 -0
- package/src/cmd/cloud/db/stats.ts +72 -0
- package/src/cmd/cloud/email/create.ts +17 -10
- package/src/cmd/cloud/email/delete.ts +1 -1
- package/src/cmd/cloud/email/destination/delete.ts +6 -2
- package/src/cmd/cloud/email/destination/list.ts +1 -1
- package/src/cmd/cloud/email/destination/url.ts +5 -4
- package/src/cmd/cloud/email/get.ts +2 -4
- package/src/cmd/cloud/email/inbound/get.ts +2 -3
- package/src/cmd/cloud/email/inbound/list.ts +1 -3
- package/src/cmd/cloud/email/inbound/schemas.ts +3 -1
- package/src/cmd/cloud/email/index.ts +2 -0
- package/src/cmd/cloud/email/list.ts +9 -2
- package/src/cmd/cloud/email/outbound/get.ts +4 -4
- package/src/cmd/cloud/email/outbound/list.ts +3 -3
- package/src/cmd/cloud/email/outbound/schemas.ts +2 -2
- package/src/cmd/cloud/email/send.ts +9 -15
- package/src/cmd/cloud/email/stats.ts +73 -0
- package/src/cmd/cloud/email/util.ts +11 -31
- package/src/cmd/cloud/index.ts +2 -0
- package/src/cmd/cloud/queue/get.ts +4 -4
- package/src/cmd/cloud/queue/receive.ts +15 -7
- package/src/cmd/cloud/queue/stats.ts +3 -3
- package/src/cmd/cloud/sandbox/checkpoint/create.ts +85 -0
- package/src/cmd/cloud/sandbox/checkpoint/delete.ts +93 -0
- package/src/cmd/cloud/sandbox/checkpoint/index.ts +33 -0
- package/src/cmd/cloud/sandbox/checkpoint/list.ts +83 -0
- package/src/cmd/cloud/sandbox/checkpoint/restore.ts +72 -0
- package/src/cmd/cloud/sandbox/get.ts +6 -3
- package/src/cmd/cloud/sandbox/index.ts +4 -0
- package/src/cmd/cloud/sandbox/snapshot/build.ts +34 -15
- package/src/cmd/cloud/sandbox/snapshot/get.ts +3 -3
- package/src/cmd/cloud/sandbox/stats.ts +82 -0
- package/src/cmd/cloud/schedule/create.ts +3 -4
- package/src/cmd/cloud/schedule/delete.ts +6 -4
- package/src/cmd/cloud/schedule/delivery/get.ts +3 -4
- package/src/cmd/cloud/schedule/delivery/list.ts +17 -16
- package/src/cmd/cloud/schedule/destination/create.ts +19 -7
- package/src/cmd/cloud/schedule/destination/delete.ts +2 -3
- package/src/cmd/cloud/schedule/destination/get.ts +17 -17
- package/src/cmd/cloud/schedule/destination/index.ts +3 -1
- package/src/cmd/cloud/schedule/destination/list.ts +22 -15
- package/src/cmd/cloud/schedule/get.ts +30 -20
- package/src/cmd/cloud/schedule/index.ts +6 -1
- package/src/cmd/cloud/schedule/list.ts +20 -19
- package/src/cmd/cloud/schedule/stats.ts +72 -0
- package/src/cmd/cloud/schedule/update.ts +5 -5
- package/src/cmd/cloud/schedule/util.ts +14 -20
- package/src/cmd/cloud/services/index.ts +11 -0
- package/src/cmd/cloud/services/stats.ts +199 -0
- package/src/cmd/cloud/stream/index.ts +8 -1
- package/src/cmd/cloud/stream/stats.ts +70 -0
- package/src/cmd/cloud/task/attachment.ts +432 -0
- package/src/cmd/cloud/task/create.ts +130 -5
- package/src/cmd/cloud/task/get.ts +35 -16
- package/src/cmd/cloud/task/index.ts +14 -1
- package/src/cmd/cloud/task/list.ts +32 -17
- package/src/cmd/cloud/task/stats.ts +74 -0
- package/src/cmd/cloud/task/update.ts +0 -1
- package/src/cmd/cloud/task/util.ts +14 -28
- package/src/cmd/cloud/vector/get.ts +16 -11
- package/src/cmd/cloud/vector/stats.ts +10 -8
- package/src/cmd/cloud/webhook/create.ts +6 -1
- package/src/cmd/cloud/webhook/deliveries.ts +15 -3
- package/src/cmd/cloud/webhook/destinations.ts +21 -9
- package/src/cmd/cloud/webhook/get.ts +2 -2
- package/src/cmd/cloud/webhook/receipts.ts +16 -3
- package/src/cmd/dev/index.ts +91 -48
- package/src/tui.ts +9 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Database } from 'bun:sqlite';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { mkdirSync } from 'node:fs';
|
|
4
|
+
import { getDefaultConfigDir } from '../config';
|
|
5
|
+
|
|
6
|
+
let db: Database | null = null;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get or create the database connection synchronously.
|
|
10
|
+
* Reuses the existing resource.db file for consistency.
|
|
11
|
+
*/
|
|
12
|
+
function getDatabase(): Database {
|
|
13
|
+
if (db) return db;
|
|
14
|
+
|
|
15
|
+
const configDir = getDefaultConfigDir();
|
|
16
|
+
mkdirSync(configDir, { recursive: true });
|
|
17
|
+
|
|
18
|
+
db = new Database(join(configDir, 'resource.db'));
|
|
19
|
+
db.run(`
|
|
20
|
+
CREATE TABLE IF NOT EXISTS user_info_cache (
|
|
21
|
+
profile TEXT PRIMARY KEY,
|
|
22
|
+
user_id TEXT NOT NULL,
|
|
23
|
+
first_name TEXT NOT NULL,
|
|
24
|
+
last_name TEXT NOT NULL,
|
|
25
|
+
cached_at INTEGER NOT NULL
|
|
26
|
+
)
|
|
27
|
+
`);
|
|
28
|
+
return db;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get cached user info for a profile.
|
|
33
|
+
* Returns null if not found in cache.
|
|
34
|
+
*/
|
|
35
|
+
export function getCachedUserInfo(
|
|
36
|
+
profile: string
|
|
37
|
+
): { userId: string; firstName: string; lastName: string } | null {
|
|
38
|
+
try {
|
|
39
|
+
const row = getDatabase()
|
|
40
|
+
.query<
|
|
41
|
+
{ user_id: string; first_name: string; last_name: string },
|
|
42
|
+
[string]
|
|
43
|
+
>('SELECT user_id, first_name, last_name FROM user_info_cache WHERE profile = ?')
|
|
44
|
+
.get(profile);
|
|
45
|
+
if (!row) return null;
|
|
46
|
+
return {
|
|
47
|
+
userId: row.user_id,
|
|
48
|
+
firstName: row.first_name,
|
|
49
|
+
lastName: row.last_name,
|
|
50
|
+
};
|
|
51
|
+
} catch {
|
|
52
|
+
// Non-critical — return null on error
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Cache user info for a profile.
|
|
59
|
+
* Upserts the entry so repeated calls are safe.
|
|
60
|
+
*/
|
|
61
|
+
export function setCachedUserInfo(
|
|
62
|
+
profile: string,
|
|
63
|
+
userId: string,
|
|
64
|
+
firstName: string,
|
|
65
|
+
lastName: string
|
|
66
|
+
): void {
|
|
67
|
+
try {
|
|
68
|
+
getDatabase().run(
|
|
69
|
+
`INSERT INTO user_info_cache (profile, user_id, first_name, last_name, cached_at)
|
|
70
|
+
VALUES (?, ?, ?, ?, ?)
|
|
71
|
+
ON CONFLICT(profile) DO UPDATE SET
|
|
72
|
+
user_id = excluded.user_id,
|
|
73
|
+
first_name = excluded.first_name,
|
|
74
|
+
last_name = excluded.last_name,
|
|
75
|
+
cached_at = excluded.cached_at`,
|
|
76
|
+
[profile, userId, firstName, lastName, Date.now()]
|
|
77
|
+
);
|
|
78
|
+
} catch {
|
|
79
|
+
// Non-critical — caching failure shouldn't block CLI
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Clear cached user info for a profile.
|
|
85
|
+
* Called on logout to ensure stale data is removed.
|
|
86
|
+
*/
|
|
87
|
+
export function clearCachedUserInfo(profile: string): void {
|
|
88
|
+
try {
|
|
89
|
+
getDatabase().run('DELETE FROM user_info_cache WHERE profile = ?', [profile]);
|
|
90
|
+
} catch {
|
|
91
|
+
// Non-critical — cache cleanup failure shouldn't block logout
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/cmd/auth/logout.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSubcommand } from '../../types';
|
|
2
|
-
import { clearAuth } from '../../config';
|
|
2
|
+
import { clearAuth, defaultProfileName } from '../../config';
|
|
3
|
+
import { clearCachedUserInfo } from '../../cache';
|
|
3
4
|
import * as tui from '../../tui';
|
|
4
5
|
import { getCommand } from '../../command-prefix';
|
|
5
6
|
|
|
@@ -17,6 +18,7 @@ export const logoutCommand = createSubcommand({
|
|
|
17
18
|
async handler(ctx) {
|
|
18
19
|
const { options } = ctx;
|
|
19
20
|
await clearAuth();
|
|
21
|
+
clearCachedUserInfo(ctx.config?.name ?? defaultProfileName);
|
|
20
22
|
if (!options.json) {
|
|
21
23
|
tui.success('You have been logged out');
|
|
22
24
|
}
|
|
@@ -18,14 +18,27 @@ interface GenerateEntryOptions {
|
|
|
18
18
|
workbench?: WorkbenchConfig;
|
|
19
19
|
analytics?: boolean | AnalyticsConfig;
|
|
20
20
|
vitePort?: number; // Port of Vite asset server (dev mode only)
|
|
21
|
+
noBundle?: boolean; // Skip bundling — apply runtime patches instead
|
|
22
|
+
/** Pre-discovered routes to avoid redundant route discovery */
|
|
23
|
+
preDiscoveredRoutes?: Awaited<ReturnType<typeof discoverRoutes>>['routeInfoList'];
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Generate entry file with clean Vite-native architecture
|
|
25
28
|
*/
|
|
26
29
|
export async function generateEntryFile(options: GenerateEntryOptions): Promise<void> {
|
|
27
|
-
const {
|
|
28
|
-
|
|
30
|
+
const {
|
|
31
|
+
rootDir,
|
|
32
|
+
projectId,
|
|
33
|
+
deploymentId,
|
|
34
|
+
logger,
|
|
35
|
+
mode,
|
|
36
|
+
workbench,
|
|
37
|
+
analytics,
|
|
38
|
+
vitePort,
|
|
39
|
+
noBundle,
|
|
40
|
+
preDiscoveredRoutes,
|
|
41
|
+
} = options;
|
|
29
42
|
|
|
30
43
|
const srcDir = join(rootDir, 'src');
|
|
31
44
|
const generatedDir = join(srcDir, 'generated');
|
|
@@ -41,8 +54,10 @@ export async function generateEntryFile(options: GenerateEntryOptions): Promise<
|
|
|
41
54
|
await generateWebAnalyticsFile({ rootDir, logger, analytics });
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
//
|
|
45
|
-
const
|
|
57
|
+
// Use pre-discovered routes if available, otherwise discover them
|
|
58
|
+
const routeInfoList =
|
|
59
|
+
preDiscoveredRoutes ??
|
|
60
|
+
(await discoverRoutes(srcDir, projectId, deploymentId, logger)).routeInfoList;
|
|
46
61
|
|
|
47
62
|
// Check for web and workbench
|
|
48
63
|
const hasWebFrontend =
|
|
@@ -87,6 +102,10 @@ export async function generateEntryFile(options: GenerateEntryOptions): Promise<
|
|
|
87
102
|
` runShutdown,`,
|
|
88
103
|
];
|
|
89
104
|
|
|
105
|
+
if (noBundle) {
|
|
106
|
+
runtimeImports.push(` applyDevPatches,`);
|
|
107
|
+
}
|
|
108
|
+
|
|
90
109
|
if (hasWebFrontend) {
|
|
91
110
|
runtimeImports.push(` mimeTypes,`);
|
|
92
111
|
}
|
|
@@ -610,6 +629,15 @@ if (isDevelopment()) {
|
|
|
610
629
|
}
|
|
611
630
|
`;
|
|
612
631
|
|
|
632
|
+
const devPatchesStep = noBundle
|
|
633
|
+
? `
|
|
634
|
+
// Step 0.1: Apply runtime dev patches (--experimental-no-bundle mode)
|
|
635
|
+
// Replaces build-time Bun.build patches for LLM gateway routing, AI SDK telemetry, and OTel spans
|
|
636
|
+
if (isDevelopment()) {
|
|
637
|
+
await applyDevPatches();
|
|
638
|
+
}
|
|
639
|
+
`
|
|
640
|
+
: '';
|
|
613
641
|
const code = `// @generated
|
|
614
642
|
// Auto-generated by Agentuity
|
|
615
643
|
// DO NOT EDIT - This file is regenerated on every build
|
|
@@ -626,6 +654,8 @@ if (isDevelopment()) {
|
|
|
626
654
|
await bootstrapRuntimeEnv({ projectDir: import.meta.dir + '/../..' });
|
|
627
655
|
}
|
|
628
656
|
|
|
657
|
+
${devPatchesStep}
|
|
658
|
+
|
|
629
659
|
// Step 0.25: load our runtime metadata and cache it
|
|
630
660
|
loadBuildMetadata();
|
|
631
661
|
|
|
@@ -19,6 +19,7 @@ export interface BunDevServerOptions {
|
|
|
19
19
|
inspect?: boolean; // Enable bun debugger
|
|
20
20
|
inspectWait?: boolean; // Enable bun debugger and wait for connection
|
|
21
21
|
inspectBrk?: boolean; // Enable bun debugger with breakpoint at first line
|
|
22
|
+
noBundle?: boolean; // Run src/generated/app.ts directly without bundling
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface BunDevServerResult {
|
|
@@ -39,17 +40,28 @@ export interface BunDevServerResult {
|
|
|
39
40
|
* as a subprocess to enable passing the debugger CLI flags.
|
|
40
41
|
*/
|
|
41
42
|
export async function startBunDevServer(options: BunDevServerOptions): Promise<BunDevServerResult> {
|
|
42
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
rootDir,
|
|
45
|
+
port = 3500,
|
|
46
|
+
logger,
|
|
47
|
+
vitePort,
|
|
48
|
+
inspect,
|
|
49
|
+
inspectWait,
|
|
50
|
+
inspectBrk,
|
|
51
|
+
noBundle,
|
|
52
|
+
} = options;
|
|
43
53
|
|
|
44
54
|
logger.debug('Starting Bun dev server (Vite already running on port %d)...', vitePort);
|
|
45
55
|
|
|
46
|
-
const appPath = `${rootDir}/.agentuity/app.js`;
|
|
56
|
+
const appPath = noBundle ? `${rootDir}/src/generated/app.ts` : `${rootDir}/.agentuity/app.js`;
|
|
47
57
|
|
|
48
|
-
// Verify
|
|
58
|
+
// Verify entry file exists before attempting to load
|
|
49
59
|
const appFile = Bun.file(appPath);
|
|
50
60
|
if (!(await appFile.exists())) {
|
|
51
61
|
throw new Error(
|
|
52
|
-
|
|
62
|
+
noBundle
|
|
63
|
+
? `Generated entry not found at ${appPath}. Run the dev command to generate it.`
|
|
64
|
+
: `Dev bundle not found at ${appPath}. The bundle must be generated before starting the dev server.`
|
|
53
65
|
);
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -126,11 +138,11 @@ export async function startBunDevServer(options: BunDevServerOptions): Promise<B
|
|
|
126
138
|
logger.debug(`Bun dev server started on http://127.0.0.1:${port} with debugger enabled`);
|
|
127
139
|
logger.debug(`Asset requests (/@vite/*, /src/web/*, etc.) proxied to Vite:${vitePort}`);
|
|
128
140
|
} else {
|
|
129
|
-
// Load the
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
logger.debug('📦 Loading
|
|
141
|
+
// Load the app entry - this will start Bun.serve() internally
|
|
142
|
+
// In bundle mode: imports .agentuity/app.js (with build-time LLM patches)
|
|
143
|
+
// In no-bundle mode: imports src/generated/app.ts directly (with runtime patches)
|
|
144
|
+
logger.debug('Loading app from: %s (noBundle: %s)', appPath, !!noBundle);
|
|
145
|
+
logger.debug('📦 Loading app entry (Bun server will start)...');
|
|
134
146
|
|
|
135
147
|
// Import the generated app with cache-busting query parameter.
|
|
136
148
|
// Bun's module cache is keyed by the full specifier including query string,
|
|
@@ -5,6 +5,7 @@ import { deleteSubcommand } from './delete';
|
|
|
5
5
|
import { getSubcommand } from './get';
|
|
6
6
|
import { logsSubcommand } from './logs';
|
|
7
7
|
import { sqlSubcommand } from './sql';
|
|
8
|
+
import { statsSubcommand } from './stats';
|
|
8
9
|
import { getCommand } from '../../../command-prefix';
|
|
9
10
|
|
|
10
11
|
export const dbCommand = createCommand({
|
|
@@ -23,5 +24,6 @@ export const dbCommand = createCommand({
|
|
|
23
24
|
deleteSubcommand,
|
|
24
25
|
logsSubcommand,
|
|
25
26
|
sqlSubcommand,
|
|
27
|
+
statsSubcommand,
|
|
26
28
|
],
|
|
27
29
|
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { getGlobalCatalystAPIClient } from '../../../config';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { getServiceStats, type ServiceStatsData } from '@agentuity/server';
|
|
7
|
+
|
|
8
|
+
function formatNumber(n: number): string {
|
|
9
|
+
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
|
|
10
|
+
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;
|
|
11
|
+
return String(n);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function displayStats(data: ServiceStatsData): void {
|
|
15
|
+
const svc = data.services.database;
|
|
16
|
+
if (!svc) {
|
|
17
|
+
tui.info('No database data found.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
tui.header('Database Statistics');
|
|
21
|
+
tui.newline();
|
|
22
|
+
console.log(` ${tui.muted('Databases:')} ${formatNumber(svc.databaseCount)}`);
|
|
23
|
+
console.log(` ${tui.muted('Tables:')} ${formatNumber(svc.totalTableCount)}`);
|
|
24
|
+
console.log(` ${tui.muted('Records:')} ${formatNumber(svc.totalRecordCount)}`);
|
|
25
|
+
console.log(` ${tui.muted('Total Size:')} ${tui.formatBytes(svc.totalSizeBytes)}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const statsSubcommand = createCommand({
|
|
29
|
+
name: 'stats',
|
|
30
|
+
description: 'View database statistics',
|
|
31
|
+
tags: ['read-only', 'requires-auth'],
|
|
32
|
+
requires: { auth: true, org: true },
|
|
33
|
+
examples: [
|
|
34
|
+
{
|
|
35
|
+
command: getCommand('cloud db stats'),
|
|
36
|
+
description: 'View database statistics',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
schema: {
|
|
40
|
+
options: z.object({
|
|
41
|
+
start: z.string().optional().describe('Start time (ISO 8601)'),
|
|
42
|
+
end: z.string().optional().describe('End time (ISO 8601)'),
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
idempotent: true,
|
|
46
|
+
|
|
47
|
+
async handler(ctx) {
|
|
48
|
+
const { opts, options } = ctx;
|
|
49
|
+
const client = await getGlobalCatalystAPIClient(ctx.logger, ctx.auth, ctx.config?.name);
|
|
50
|
+
const orgId = ctx.orgId ?? ctx.options.orgId ?? ctx.config?.preferences?.orgId;
|
|
51
|
+
|
|
52
|
+
if (!orgId) {
|
|
53
|
+
ctx.logger.fatal('Organization ID is required. Use --org-id or set a preferred org.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const data = await getServiceStats(client, orgId, {
|
|
58
|
+
service: 'database',
|
|
59
|
+
start: opts.start,
|
|
60
|
+
end: opts.end,
|
|
61
|
+
orgIdHeader: orgId,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!options.json) {
|
|
65
|
+
displayStats(data);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return data;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default statsSubcommand;
|
|
@@ -3,7 +3,8 @@ import enquirer from 'enquirer';
|
|
|
3
3
|
import { createCommand } from '../../../types';
|
|
4
4
|
import * as tui from '../../../tui';
|
|
5
5
|
import { setResourceInfo } from '../../../cache';
|
|
6
|
-
import { createEmailAdapter, resolveEmailOrgId,
|
|
6
|
+
import { createEmailAdapter, resolveEmailOrgId, EmailAddressSchema } from './util';
|
|
7
|
+
import { defaultProfileName, getDefaultRegion } from '../../../config';
|
|
7
8
|
|
|
8
9
|
export const createSubcommand = createCommand({
|
|
9
10
|
name: 'create',
|
|
@@ -13,10 +14,7 @@ export const createSubcommand = createCommand({
|
|
|
13
14
|
requires: { auth: true },
|
|
14
15
|
schema: {
|
|
15
16
|
options: z.object({
|
|
16
|
-
localPart: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('Local part for the email address (before @)'),
|
|
17
|
+
localPart: z.string().optional().describe('Local part for the email address (before @)'),
|
|
20
18
|
}),
|
|
21
19
|
response: EmailAddressSchema,
|
|
22
20
|
},
|
|
@@ -29,21 +27,30 @@ export const createSubcommand = createCommand({
|
|
|
29
27
|
const answer = await enquirer.prompt<{ local_part: string }>({
|
|
30
28
|
type: 'input',
|
|
31
29
|
name: 'local_part',
|
|
32
|
-
message: '
|
|
30
|
+
message: 'Email address or username (e.g. "support" or "support@agentuity.email"):',
|
|
33
31
|
});
|
|
34
32
|
localPart = answer.local_part?.trim();
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
if (!localPart) {
|
|
38
|
-
tui.fatal('
|
|
36
|
+
tui.fatal('Email address or username is required');
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
// If user entered a full email, extract just the local part
|
|
40
|
+
if (localPart.includes('@')) {
|
|
41
|
+
localPart = localPart.split('@')[0]?.trim() ?? '';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!localPart) {
|
|
45
|
+
tui.fatal('Email address or username is required');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const profileName = config?.name ?? defaultProfileName;
|
|
49
|
+
const region = await getDefaultRegion(profileName, ctx.config);
|
|
50
|
+
const email = await createEmailAdapter(ctx, region);
|
|
42
51
|
const address = await email.createAddress(localPart);
|
|
43
52
|
|
|
44
|
-
const profileName = config?.name ?? 'production';
|
|
45
53
|
const orgId = resolveEmailOrgId(ctx);
|
|
46
|
-
const region = resolveEmailRegion(ctx);
|
|
47
54
|
await setResourceInfo('email', profileName, address.id, region, orgId);
|
|
48
55
|
|
|
49
56
|
if (!options.json) {
|
|
@@ -43,11 +43,15 @@ export const deleteSubcommand = createCommand({
|
|
|
43
43
|
);
|
|
44
44
|
if (!ok) {
|
|
45
45
|
tui.info('Cancelled');
|
|
46
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
address_id: args.address_id,
|
|
49
|
+
destination_id: args.destination_id,
|
|
50
|
+
};
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
const email = createEmailAdapter(ctx);
|
|
54
|
+
const email = await createEmailAdapter(ctx);
|
|
51
55
|
await email.deleteDestination(args.address_id, args.destination_id);
|
|
52
56
|
|
|
53
57
|
if (!options.json) {
|
|
@@ -19,7 +19,7 @@ export const listSubcommand = createCommand({
|
|
|
19
19
|
|
|
20
20
|
async handler(ctx) {
|
|
21
21
|
const { args, options } = ctx;
|
|
22
|
-
const email = createEmailAdapter(ctx);
|
|
22
|
+
const email = await createEmailAdapter(ctx);
|
|
23
23
|
const destinations = await email.listDestinations(args.address_id);
|
|
24
24
|
|
|
25
25
|
if (!options.json) {
|
|
@@ -2,7 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { createCommand } from '../../../../types';
|
|
3
3
|
import * as tui from '../../../../tui';
|
|
4
4
|
import { setResourceInfo } from '../../../../cache';
|
|
5
|
-
import { createEmailAdapter, resolveEmailOrgId
|
|
5
|
+
import { createEmailAdapter, resolveEmailOrgId } from '../util';
|
|
6
|
+
import { defaultProfileName, getDefaultRegion } from '../../../../config';
|
|
6
7
|
import { DestinationSchema } from './schemas';
|
|
7
8
|
|
|
8
9
|
export const urlSubcommand = createCommand({
|
|
@@ -41,12 +42,12 @@ export const urlSubcommand = createCommand({
|
|
|
41
42
|
destinationConfig.method = opts.method;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const profileName = config?.name ?? defaultProfileName;
|
|
46
|
+
const region = await getDefaultRegion(profileName, ctx.config);
|
|
47
|
+
const email = await createEmailAdapter(ctx, region);
|
|
45
48
|
const destination = await email.createDestination(args.address_id, 'url', destinationConfig);
|
|
46
49
|
|
|
47
|
-
const profileName = config?.name ?? 'production';
|
|
48
50
|
const orgId = resolveEmailOrgId(ctx);
|
|
49
|
-
const region = resolveEmailRegion(ctx);
|
|
50
51
|
setResourceInfo('email', profileName, destination.id, region, orgId).catch(() => {
|
|
51
52
|
// Non-blocking: destination was already created successfully
|
|
52
53
|
});
|
|
@@ -17,7 +17,7 @@ export const getSubcommand = createCommand({
|
|
|
17
17
|
|
|
18
18
|
async handler(ctx) {
|
|
19
19
|
const { args, options } = ctx;
|
|
20
|
-
const email = createEmailAdapter(ctx);
|
|
20
|
+
const email = await createEmailAdapter(ctx);
|
|
21
21
|
const address = await email.getAddress(args.id);
|
|
22
22
|
|
|
23
23
|
if (!address) {
|
|
@@ -35,9 +35,7 @@ export const getSubcommand = createCommand({
|
|
|
35
35
|
Provider: address.provider ?? '-',
|
|
36
36
|
Config: address.config ? JSON.stringify(address.config) : '-',
|
|
37
37
|
Created: new Date(address.created_at).toLocaleString(),
|
|
38
|
-
Updated: address.updated_at
|
|
39
|
-
? new Date(address.updated_at).toLocaleString()
|
|
40
|
-
: '-',
|
|
38
|
+
Updated: address.updated_at ? new Date(address.updated_at).toLocaleString() : '-',
|
|
41
39
|
},
|
|
42
40
|
],
|
|
43
41
|
['ID', 'Email', 'Project', 'Provider', 'Config', 'Created', 'Updated'],
|
|
@@ -18,7 +18,7 @@ export const getSubcommand = createCommand({
|
|
|
18
18
|
|
|
19
19
|
async handler(ctx) {
|
|
20
20
|
const { args, options } = ctx;
|
|
21
|
-
const email = createEmailAdapter(ctx);
|
|
21
|
+
const email = await createEmailAdapter(ctx);
|
|
22
22
|
const inbound = await email.getInbound(args.id);
|
|
23
23
|
|
|
24
24
|
if (!inbound) {
|
|
@@ -35,13 +35,12 @@ export const getSubcommand = createCommand({
|
|
|
35
35
|
To: inbound.to,
|
|
36
36
|
Subject: inbound.subject ?? '-',
|
|
37
37
|
Text: truncate(inbound.text),
|
|
38
|
-
Status: inbound.status ?? '-',
|
|
39
38
|
Received: inbound.received_at
|
|
40
39
|
? new Date(inbound.received_at).toLocaleString()
|
|
41
40
|
: '-',
|
|
42
41
|
},
|
|
43
42
|
],
|
|
44
|
-
['ID', 'From', 'To', 'Subject', 'Text', '
|
|
43
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Received'],
|
|
45
44
|
{ layout: 'vertical', padStart: ' ' }
|
|
46
45
|
);
|
|
47
46
|
}
|
|
@@ -19,7 +19,7 @@ export const listSubcommand = createCommand({
|
|
|
19
19
|
|
|
20
20
|
async handler(ctx) {
|
|
21
21
|
const { opts, options } = ctx;
|
|
22
|
-
const email = createEmailAdapter(ctx);
|
|
22
|
+
const email = await createEmailAdapter(ctx);
|
|
23
23
|
const inbound = await email.listInbound(opts.addressId);
|
|
24
24
|
|
|
25
25
|
if (!options.json) {
|
|
@@ -29,7 +29,6 @@ export const listSubcommand = createCommand({
|
|
|
29
29
|
From: item.from,
|
|
30
30
|
To: item.to,
|
|
31
31
|
Subject: item.subject ?? '-',
|
|
32
|
-
Status: item.status ?? '-',
|
|
33
32
|
Received: item.received_at ? new Date(item.received_at).toLocaleString() : '-',
|
|
34
33
|
})),
|
|
35
34
|
[
|
|
@@ -37,7 +36,6 @@ export const listSubcommand = createCommand({
|
|
|
37
36
|
{ name: 'From', alignment: 'left' },
|
|
38
37
|
{ name: 'To', alignment: 'left' },
|
|
39
38
|
{ name: 'Subject', alignment: 'left' },
|
|
40
|
-
{ name: 'Status', alignment: 'left' },
|
|
41
39
|
{ name: 'Received', alignment: 'left' },
|
|
42
40
|
]
|
|
43
41
|
);
|
|
@@ -6,6 +6,8 @@ export const EmailInboundSchema = z.object({
|
|
|
6
6
|
to: z.string(),
|
|
7
7
|
subject: z.string().optional(),
|
|
8
8
|
text: z.string().optional(),
|
|
9
|
-
|
|
9
|
+
html: z.string().optional(),
|
|
10
10
|
received_at: z.string().optional(),
|
|
11
|
+
headers: z.record(z.string(), z.unknown()).optional(),
|
|
12
|
+
attachments: z.array(z.unknown()).optional(),
|
|
11
13
|
});
|
|
@@ -7,6 +7,7 @@ import { destinationCommand } from './destination';
|
|
|
7
7
|
import { sendSubcommand } from './send';
|
|
8
8
|
import { inboundCommand } from './inbound';
|
|
9
9
|
import { outboundCommand } from './outbound';
|
|
10
|
+
import { statsSubcommand } from './stats';
|
|
10
11
|
|
|
11
12
|
export const emailCommand = createCommand({
|
|
12
13
|
name: 'email',
|
|
@@ -22,6 +23,7 @@ export const emailCommand = createCommand({
|
|
|
22
23
|
sendSubcommand,
|
|
23
24
|
inboundCommand,
|
|
24
25
|
outboundCommand,
|
|
26
|
+
statsSubcommand,
|
|
25
27
|
],
|
|
26
28
|
requires: { auth: true },
|
|
27
29
|
});
|
|
@@ -15,7 +15,7 @@ export const listSubcommand = createCommand({
|
|
|
15
15
|
|
|
16
16
|
async handler(ctx) {
|
|
17
17
|
const { options } = ctx;
|
|
18
|
-
const email = createEmailAdapter(ctx);
|
|
18
|
+
const email = await createEmailAdapter(ctx);
|
|
19
19
|
const addresses = await email.listAddresses();
|
|
20
20
|
|
|
21
21
|
if (!options.json) {
|
|
@@ -37,7 +37,14 @@ export const listSubcommand = createCommand({
|
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return addresses
|
|
40
|
+
return addresses.map((item) => ({
|
|
41
|
+
id: item.id,
|
|
42
|
+
email: item.email,
|
|
43
|
+
project_id: item.project_id,
|
|
44
|
+
provider: item.provider,
|
|
45
|
+
created_at: item.created_at,
|
|
46
|
+
updated_at: item.updated_at,
|
|
47
|
+
}));
|
|
41
48
|
},
|
|
42
49
|
});
|
|
43
50
|
|
|
@@ -18,7 +18,7 @@ export const getSubcommand = createCommand({
|
|
|
18
18
|
|
|
19
19
|
async handler(ctx) {
|
|
20
20
|
const { args, options } = ctx;
|
|
21
|
-
const email = createEmailAdapter(ctx);
|
|
21
|
+
const email = await createEmailAdapter(ctx);
|
|
22
22
|
const outbound = await email.getOutbound(args.id);
|
|
23
23
|
|
|
24
24
|
if (!outbound) {
|
|
@@ -37,12 +37,12 @@ export const getSubcommand = createCommand({
|
|
|
37
37
|
Text: truncate(outbound.text),
|
|
38
38
|
Status: outbound.status ?? '-',
|
|
39
39
|
Error: outbound.error ?? '-',
|
|
40
|
-
|
|
41
|
-
? new Date(outbound.
|
|
40
|
+
Created: outbound.created_at
|
|
41
|
+
? new Date(outbound.created_at).toLocaleString()
|
|
42
42
|
: '-',
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
|
-
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Error', '
|
|
45
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Error', 'Created'],
|
|
46
46
|
{ layout: 'vertical', padStart: ' ' }
|
|
47
47
|
);
|
|
48
48
|
}
|
|
@@ -19,7 +19,7 @@ export const listSubcommand = createCommand({
|
|
|
19
19
|
|
|
20
20
|
async handler(ctx) {
|
|
21
21
|
const { opts, options } = ctx;
|
|
22
|
-
const email = createEmailAdapter(ctx);
|
|
22
|
+
const email = await createEmailAdapter(ctx);
|
|
23
23
|
const outbound = await email.listOutbound(opts.addressId);
|
|
24
24
|
|
|
25
25
|
if (!options.json) {
|
|
@@ -30,7 +30,7 @@ export const listSubcommand = createCommand({
|
|
|
30
30
|
To: item.to,
|
|
31
31
|
Subject: item.subject ?? '-',
|
|
32
32
|
Status: item.status ?? '-',
|
|
33
|
-
|
|
33
|
+
Created: item.created_at ? new Date(item.created_at).toLocaleString() : '-',
|
|
34
34
|
})),
|
|
35
35
|
[
|
|
36
36
|
{ name: 'ID', alignment: 'left' },
|
|
@@ -38,7 +38,7 @@ export const listSubcommand = createCommand({
|
|
|
38
38
|
{ name: 'To', alignment: 'left' },
|
|
39
39
|
{ name: 'Subject', alignment: 'left' },
|
|
40
40
|
{ name: 'Status', alignment: 'left' },
|
|
41
|
-
{ name: '
|
|
41
|
+
{ name: 'Created', alignment: 'left' },
|
|
42
42
|
]
|
|
43
43
|
);
|
|
44
44
|
}
|
|
@@ -9,7 +9,7 @@ export const EmailOutboundSchema = z.object({
|
|
|
9
9
|
html: z.string().optional(),
|
|
10
10
|
status: z.string().optional(),
|
|
11
11
|
error: z.string().optional(),
|
|
12
|
-
sent_at: z.string().optional(),
|
|
13
12
|
created_at: z.string().optional(),
|
|
14
|
-
|
|
13
|
+
headers: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
attachments: z.array(z.unknown()).optional(),
|
|
15
15
|
});
|