@agentuity/cli 1.0.22 → 1.0.23
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/auth.d.ts.map +1 -1
- package/dist/auth.js +7 -0
- package/dist/auth.js.map +1 -1
- package/dist/cache/resource-region.d.ts +1 -1
- package/dist/cache/resource-region.d.ts.map +1 -1
- package/dist/cache/resource-region.js.map +1 -1
- package/dist/cmd/ai/claude-code/install.d.ts.map +1 -1
- package/dist/cmd/ai/claude-code/install.js +0 -1
- package/dist/cmd/ai/claude-code/install.js.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts +4 -2
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.js +18 -4
- package/dist/cmd/build/vite/public-asset-path-plugin.js.map +1 -1
- package/dist/cmd/cloud/email/create.d.ts +3 -0
- package/dist/cmd/cloud/email/create.d.ts.map +1 -0
- package/dist/cmd/cloud/email/create.js +58 -0
- package/dist/cmd/cloud/email/create.js.map +1 -0
- package/dist/cmd/cloud/email/delete.d.ts +3 -0
- package/dist/cmd/cloud/email/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/email/delete.js +47 -0
- package/dist/cmd/cloud/email/delete.js.map +1 -0
- package/dist/cmd/cloud/email/destination/delete.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/delete.js +54 -0
- package/dist/cmd/cloud/email/destination/delete.js.map +1 -0
- package/dist/cmd/cloud/email/destination/index.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/index.js +14 -0
- package/dist/cmd/cloud/email/destination/index.js.map +1 -0
- package/dist/cmd/cloud/email/destination/list.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/list.js +39 -0
- package/dist/cmd/cloud/email/destination/list.js.map +1 -0
- package/dist/cmd/cloud/email/destination/schemas.d.ts +9 -0
- package/dist/cmd/cloud/email/destination/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/schemas.js +9 -0
- package/dist/cmd/cloud/email/destination/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/destination/url.d.ts +3 -0
- package/dist/cmd/cloud/email/destination/url.d.ts.map +1 -0
- package/dist/cmd/cloud/email/destination/url.js +64 -0
- package/dist/cmd/cloud/email/destination/url.js.map +1 -0
- package/dist/cmd/cloud/email/get.d.ts +3 -0
- package/dist/cmd/cloud/email/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/get.js +43 -0
- package/dist/cmd/cloud/email/get.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/get.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/get.js +44 -0
- package/dist/cmd/cloud/email/inbound/get.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/index.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/index.js +12 -0
- package/dist/cmd/cloud/email/inbound/index.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/list.d.ts +3 -0
- package/dist/cmd/cloud/email/inbound/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/list.js +43 -0
- package/dist/cmd/cloud/email/inbound/list.js.map +1 -0
- package/dist/cmd/cloud/email/inbound/schemas.d.ts +11 -0
- package/dist/cmd/cloud/email/inbound/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/inbound/schemas.js +11 -0
- package/dist/cmd/cloud/email/inbound/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/index.d.ts +3 -0
- package/dist/cmd/cloud/email/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/index.js +28 -0
- package/dist/cmd/cloud/email/index.js.map +1 -0
- package/dist/cmd/cloud/email/list.d.ts +3 -0
- package/dist/cmd/cloud/email/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/list.js +37 -0
- package/dist/cmd/cloud/email/list.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/get.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/get.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/get.js +45 -0
- package/dist/cmd/cloud/email/outbound/get.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/index.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/index.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/index.js +12 -0
- package/dist/cmd/cloud/email/outbound/index.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/list.d.ts +3 -0
- package/dist/cmd/cloud/email/outbound/list.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/list.js +43 -0
- package/dist/cmd/cloud/email/outbound/list.js.map +1 -0
- package/dist/cmd/cloud/email/outbound/schemas.d.ts +15 -0
- package/dist/cmd/cloud/email/outbound/schemas.d.ts.map +1 -0
- package/dist/cmd/cloud/email/outbound/schemas.js +15 -0
- package/dist/cmd/cloud/email/outbound/schemas.js.map +1 -0
- package/dist/cmd/cloud/email/send.d.ts +3 -0
- package/dist/cmd/cloud/email/send.d.ts.map +1 -0
- package/dist/cmd/cloud/email/send.js +77 -0
- package/dist/cmd/cloud/email/send.js.map +1 -0
- package/dist/cmd/cloud/email/util.d.ts +26 -0
- package/dist/cmd/cloud/email/util.d.ts.map +1 -0
- package/dist/cmd/cloud/email/util.js +57 -0
- package/dist/cmd/cloud/email/util.js.map +1 -0
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/index.js +8 -0
- package/dist/cmd/cloud/index.js.map +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts.map +1 -1
- package/dist/cmd/cloud/region-lookup.js +44 -2
- package/dist/cmd/cloud/region-lookup.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts +7 -0
- package/dist/cmd/cloud/sandbox/snapshot/build.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js +46 -28
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.js +5 -1
- package/dist/cmd/cloud/sandbox/snapshot/generate.js.map +1 -1
- package/dist/cmd/cloud/schedule/create.d.ts +3 -0
- package/dist/cmd/cloud/schedule/create.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/create.js +72 -0
- package/dist/cmd/cloud/schedule/create.js.map +1 -0
- package/dist/cmd/cloud/schedule/delete.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delete.js +38 -0
- package/dist/cmd/cloud/schedule/delete.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/get.js +78 -0
- package/dist/cmd/cloud/schedule/delivery/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/index.js +23 -0
- package/dist/cmd/cloud/schedule/delivery/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/delivery/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/delivery/list.js +67 -0
- package/dist/cmd/cloud/schedule/delivery/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/create.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/create.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/create.js +97 -0
- package/dist/cmd/cloud/schedule/destination/create.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/delete.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/delete.js +41 -0
- package/dist/cmd/cloud/schedule/destination/delete.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/get.js +57 -0
- package/dist/cmd/cloud/schedule/destination/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/index.js +26 -0
- package/dist/cmd/cloud/schedule/destination/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/destination/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/destination/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/destination/list.js +58 -0
- package/dist/cmd/cloud/schedule/destination/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/get.d.ts +3 -0
- package/dist/cmd/cloud/schedule/get.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/get.js +76 -0
- package/dist/cmd/cloud/schedule/get.js.map +1 -0
- package/dist/cmd/cloud/schedule/index.d.ts +3 -0
- package/dist/cmd/cloud/schedule/index.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/index.js +35 -0
- package/dist/cmd/cloud/schedule/index.js.map +1 -0
- package/dist/cmd/cloud/schedule/list.d.ts +3 -0
- package/dist/cmd/cloud/schedule/list.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/list.js +60 -0
- package/dist/cmd/cloud/schedule/list.js.map +1 -0
- package/dist/cmd/cloud/schedule/update.d.ts +3 -0
- package/dist/cmd/cloud/schedule/update.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/update.js +65 -0
- package/dist/cmd/cloud/schedule/update.js.map +1 -0
- package/dist/cmd/cloud/schedule/util.d.ts +11 -0
- package/dist/cmd/cloud/schedule/util.d.ts.map +1 -0
- package/dist/cmd/cloud/schedule/util.js +17 -0
- package/dist/cmd/cloud/schedule/util.js.map +1 -0
- package/dist/cmd/cloud/task/create.d.ts +3 -0
- package/dist/cmd/cloud/task/create.d.ts.map +1 -0
- package/dist/cmd/cloud/task/create.js +108 -0
- package/dist/cmd/cloud/task/create.js.map +1 -0
- package/dist/cmd/cloud/task/get.d.ts +3 -0
- package/dist/cmd/cloud/task/get.d.ts.map +1 -0
- package/dist/cmd/cloud/task/get.js +124 -0
- package/dist/cmd/cloud/task/get.js.map +1 -0
- package/dist/cmd/cloud/task/index.d.ts +3 -0
- package/dist/cmd/cloud/task/index.d.ts.map +1 -0
- package/dist/cmd/cloud/task/index.js +33 -0
- package/dist/cmd/cloud/task/index.js.map +1 -0
- package/dist/cmd/cloud/task/list.d.ts +3 -0
- package/dist/cmd/cloud/task/list.d.ts.map +1 -0
- package/dist/cmd/cloud/task/list.js +174 -0
- package/dist/cmd/cloud/task/list.js.map +1 -0
- package/dist/cmd/cloud/task/update.d.ts +3 -0
- package/dist/cmd/cloud/task/update.d.ts.map +1 -0
- package/dist/cmd/cloud/task/update.js +118 -0
- package/dist/cmd/cloud/task/update.js.map +1 -0
- package/dist/cmd/cloud/task/util.d.ts +18 -0
- package/dist/cmd/cloud/task/util.d.ts.map +1 -0
- package/dist/cmd/cloud/task/util.js +45 -0
- package/dist/cmd/cloud/task/util.js.map +1 -0
- package/dist/cmd/cloud/webhook/create.d.ts +3 -0
- package/dist/cmd/cloud/webhook/create.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/create.js +54 -0
- package/dist/cmd/cloud/webhook/create.js.map +1 -0
- package/dist/cmd/cloud/webhook/delete.d.ts +3 -0
- package/dist/cmd/cloud/webhook/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/delete.js +50 -0
- package/dist/cmd/cloud/webhook/delete.js.map +1 -0
- package/dist/cmd/cloud/webhook/deliveries.d.ts +3 -0
- package/dist/cmd/cloud/webhook/deliveries.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/deliveries.js +123 -0
- package/dist/cmd/cloud/webhook/deliveries.js.map +1 -0
- package/dist/cmd/cloud/webhook/destinations.d.ts +3 -0
- package/dist/cmd/cloud/webhook/destinations.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/destinations.js +212 -0
- package/dist/cmd/cloud/webhook/destinations.js.map +1 -0
- package/dist/cmd/cloud/webhook/get.d.ts +3 -0
- package/dist/cmd/cloud/webhook/get.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/get.js +50 -0
- package/dist/cmd/cloud/webhook/get.js.map +1 -0
- package/dist/cmd/cloud/webhook/index.d.ts +3 -0
- package/dist/cmd/cloud/webhook/index.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/index.js +45 -0
- package/dist/cmd/cloud/webhook/index.js.map +1 -0
- package/dist/cmd/cloud/webhook/list.d.ts +3 -0
- package/dist/cmd/cloud/webhook/list.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/list.js +72 -0
- package/dist/cmd/cloud/webhook/list.js.map +1 -0
- package/dist/cmd/cloud/webhook/receipts.d.ts +3 -0
- package/dist/cmd/cloud/webhook/receipts.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/receipts.js +128 -0
- package/dist/cmd/cloud/webhook/receipts.js.map +1 -0
- package/dist/cmd/cloud/webhook/util.d.ts +27 -0
- package/dist/cmd/cloud/webhook/util.d.ts.map +1 -0
- package/dist/cmd/cloud/webhook/util.js +20 -0
- package/dist/cmd/cloud/webhook/util.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -2
- package/dist/types.js.map +1 -1
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +18 -3
- package/dist/version-check.js.map +1 -1
- package/package.json +6 -6
- package/src/auth.ts +7 -0
- package/src/cache/resource-region.ts +4 -1
- package/src/cmd/ai/claude-code/install.ts +0 -3
- package/src/cmd/build/vite/public-asset-path-plugin.ts +18 -4
- package/src/cmd/cloud/email/create.ts +70 -0
- package/src/cmd/cloud/email/delete.ts +53 -0
- package/src/cmd/cloud/email/destination/delete.ts +65 -0
- package/src/cmd/cloud/email/destination/index.ts +15 -0
- package/src/cmd/cloud/email/destination/list.ts +46 -0
- package/src/cmd/cloud/email/destination/schemas.ts +9 -0
- package/src/cmd/cloud/email/destination/url.ts +75 -0
- package/src/cmd/cloud/email/get.ts +52 -0
- package/src/cmd/cloud/email/inbound/get.ts +53 -0
- package/src/cmd/cloud/email/inbound/index.ts +13 -0
- package/src/cmd/cloud/email/inbound/list.ts +50 -0
- package/src/cmd/cloud/email/inbound/schemas.ts +11 -0
- package/src/cmd/cloud/email/index.ts +29 -0
- package/src/cmd/cloud/email/list.ts +44 -0
- package/src/cmd/cloud/email/outbound/get.ts +54 -0
- package/src/cmd/cloud/email/outbound/index.ts +13 -0
- package/src/cmd/cloud/email/outbound/list.ts +50 -0
- package/src/cmd/cloud/email/outbound/schemas.ts +15 -0
- package/src/cmd/cloud/email/send.ts +91 -0
- package/src/cmd/cloud/email/util.ts +89 -0
- package/src/cmd/cloud/index.ts +8 -0
- package/src/cmd/cloud/region-lookup.ts +58 -2
- package/src/cmd/cloud/sandbox/snapshot/build.ts +59 -55
- package/src/cmd/cloud/sandbox/snapshot/generate.ts +5 -1
- package/src/cmd/cloud/schedule/create.ts +83 -0
- package/src/cmd/cloud/schedule/delete.ts +43 -0
- package/src/cmd/cloud/schedule/delivery/get.ts +85 -0
- package/src/cmd/cloud/schedule/delivery/index.ts +24 -0
- package/src/cmd/cloud/schedule/delivery/list.ts +82 -0
- package/src/cmd/cloud/schedule/destination/create.ts +110 -0
- package/src/cmd/cloud/schedule/destination/delete.ts +46 -0
- package/src/cmd/cloud/schedule/destination/get.ts +66 -0
- package/src/cmd/cloud/schedule/destination/index.ts +27 -0
- package/src/cmd/cloud/schedule/destination/list.ts +72 -0
- package/src/cmd/cloud/schedule/get.ts +92 -0
- package/src/cmd/cloud/schedule/index.ts +36 -0
- package/src/cmd/cloud/schedule/list.ts +78 -0
- package/src/cmd/cloud/schedule/update.ts +74 -0
- package/src/cmd/cloud/schedule/util.ts +34 -0
- package/src/cmd/cloud/task/create.ts +124 -0
- package/src/cmd/cloud/task/get.ts +138 -0
- package/src/cmd/cloud/task/index.ts +34 -0
- package/src/cmd/cloud/task/list.ts +191 -0
- package/src/cmd/cloud/task/update.ts +123 -0
- package/src/cmd/cloud/task/util.ts +74 -0
- package/src/cmd/cloud/webhook/create.ts +66 -0
- package/src/cmd/cloud/webhook/delete.ts +57 -0
- package/src/cmd/cloud/webhook/deliveries.ts +149 -0
- package/src/cmd/cloud/webhook/destinations.ts +274 -0
- package/src/cmd/cloud/webhook/get.ts +59 -0
- package/src/cmd/cloud/webhook/index.ts +46 -0
- package/src/cmd/cloud/webhook/list.ts +82 -0
- package/src/cmd/cloud/webhook/receipts.ts +157 -0
- package/src/cmd/cloud/webhook/util.ts +35 -0
- package/src/types.ts +3 -1
- package/src/version-check.ts +22 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { setResourceInfo } from '../../../../cache';
|
|
5
|
+
import { createEmailAdapter, resolveEmailOrgId, resolveEmailRegion } from '../util';
|
|
6
|
+
import { DestinationSchema } from './schemas';
|
|
7
|
+
|
|
8
|
+
export const urlSubcommand = createCommand({
|
|
9
|
+
name: 'url',
|
|
10
|
+
description: 'Add a URL destination to an email address',
|
|
11
|
+
tags: ['mutating', 'creates-resource', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
args: z.object({
|
|
15
|
+
address_id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
16
|
+
url: z
|
|
17
|
+
.string()
|
|
18
|
+
.url()
|
|
19
|
+
.refine((u) => /^https?:\/\//i.test(u), {
|
|
20
|
+
message: 'URL must use http or https protocol',
|
|
21
|
+
})
|
|
22
|
+
.describe('Destination webhook URL'),
|
|
23
|
+
}),
|
|
24
|
+
options: z.object({
|
|
25
|
+
method: z
|
|
26
|
+
.enum(['POST', 'PUT', 'PATCH'])
|
|
27
|
+
.optional()
|
|
28
|
+
.default('POST')
|
|
29
|
+
.describe('HTTP method (default: POST)'),
|
|
30
|
+
}),
|
|
31
|
+
response: DestinationSchema,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
async handler(ctx) {
|
|
35
|
+
const { args, opts, options, config } = ctx;
|
|
36
|
+
|
|
37
|
+
const destinationConfig: Record<string, unknown> = {
|
|
38
|
+
url: args.url,
|
|
39
|
+
};
|
|
40
|
+
if (opts.method && opts.method !== 'POST') {
|
|
41
|
+
destinationConfig.method = opts.method;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const email = createEmailAdapter(ctx);
|
|
45
|
+
const destination = await email.createDestination(args.address_id, 'url', destinationConfig);
|
|
46
|
+
|
|
47
|
+
const profileName = config?.name ?? 'production';
|
|
48
|
+
const orgId = resolveEmailOrgId(ctx);
|
|
49
|
+
const region = resolveEmailRegion(ctx);
|
|
50
|
+
setResourceInfo('email', profileName, destination.id, region, orgId).catch(() => {
|
|
51
|
+
// Non-blocking: destination was already created successfully
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!options.json) {
|
|
55
|
+
tui.success(`Destination created: ${tui.bold(destination.id)}`);
|
|
56
|
+
tui.table(
|
|
57
|
+
[
|
|
58
|
+
{
|
|
59
|
+
ID: destination.id,
|
|
60
|
+
Type: 'url',
|
|
61
|
+
URL: args.url,
|
|
62
|
+
Method: opts.method ?? 'POST',
|
|
63
|
+
Created: new Date(destination.created_at).toLocaleString(),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
['ID', 'Type', 'URL', 'Method', 'Created'],
|
|
67
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return destination;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default urlSubcommand;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createEmailAdapter, EmailAddressSchema } from './util';
|
|
5
|
+
|
|
6
|
+
export const getSubcommand = createCommand({
|
|
7
|
+
name: 'get',
|
|
8
|
+
description: 'Get an email address by ID',
|
|
9
|
+
tags: ['read-only', 'requires-auth'],
|
|
10
|
+
requires: { auth: true },
|
|
11
|
+
schema: {
|
|
12
|
+
args: z.object({
|
|
13
|
+
id: z.string().min(1).describe('Email address ID (eaddr_*)'),
|
|
14
|
+
}),
|
|
15
|
+
response: EmailAddressSchema,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
async handler(ctx) {
|
|
19
|
+
const { args, options } = ctx;
|
|
20
|
+
const email = createEmailAdapter(ctx);
|
|
21
|
+
const address = await email.getAddress(args.id);
|
|
22
|
+
|
|
23
|
+
if (!address) {
|
|
24
|
+
tui.fatal(`Email address not found: ${args.id}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!options.json) {
|
|
28
|
+
tui.success(`Email Address: ${tui.bold(address.email)}`);
|
|
29
|
+
tui.table(
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
ID: address.id,
|
|
33
|
+
Email: address.email,
|
|
34
|
+
Project: address.project_id ?? '-',
|
|
35
|
+
Provider: address.provider ?? '-',
|
|
36
|
+
Config: address.config ? JSON.stringify(address.config) : '-',
|
|
37
|
+
Created: new Date(address.created_at).toLocaleString(),
|
|
38
|
+
Updated: address.updated_at
|
|
39
|
+
? new Date(address.updated_at).toLocaleString()
|
|
40
|
+
: '-',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
['ID', 'Email', 'Project', 'Provider', 'Config', 'Created', 'Updated'],
|
|
44
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return address;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter, truncate } from '../util';
|
|
5
|
+
import { EmailInboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const getSubcommand = createCommand({
|
|
8
|
+
name: 'get',
|
|
9
|
+
description: 'Get a received email by ID',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
args: z.object({
|
|
14
|
+
id: z.string().min(1).describe('Inbound email ID (ein_*)'),
|
|
15
|
+
}),
|
|
16
|
+
response: EmailInboundSchema,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
const { args, options } = ctx;
|
|
21
|
+
const email = createEmailAdapter(ctx);
|
|
22
|
+
const inbound = await email.getInbound(args.id);
|
|
23
|
+
|
|
24
|
+
if (!inbound) {
|
|
25
|
+
tui.fatal(`Inbound email not found: ${args.id}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!options.json) {
|
|
29
|
+
tui.success(`Inbound Email: ${tui.bold(inbound.id)}`);
|
|
30
|
+
tui.table(
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
ID: inbound.id,
|
|
34
|
+
From: inbound.from,
|
|
35
|
+
To: inbound.to,
|
|
36
|
+
Subject: inbound.subject ?? '-',
|
|
37
|
+
Text: truncate(inbound.text),
|
|
38
|
+
Status: inbound.status ?? '-',
|
|
39
|
+
Received: inbound.received_at
|
|
40
|
+
? new Date(inbound.received_at).toLocaleString()
|
|
41
|
+
: '-',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Received'],
|
|
45
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return inbound;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../../types';
|
|
2
|
+
import { listSubcommand } from './list';
|
|
3
|
+
import { getSubcommand } from './get';
|
|
4
|
+
|
|
5
|
+
export const inboundCommand = createCommand({
|
|
6
|
+
name: 'inbound',
|
|
7
|
+
description: 'Manage inbound (received) emails',
|
|
8
|
+
tags: ['requires-auth'],
|
|
9
|
+
requires: { auth: true },
|
|
10
|
+
subcommands: [listSubcommand, getSubcommand],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default inboundCommand;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter } from '../util';
|
|
5
|
+
import { EmailInboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createCommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List received emails',
|
|
11
|
+
tags: ['read-only', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
options: z.object({
|
|
15
|
+
addressId: z.string().optional().describe('Filter by email address ID'),
|
|
16
|
+
}),
|
|
17
|
+
response: z.array(EmailInboundSchema),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async handler(ctx) {
|
|
21
|
+
const { opts, options } = ctx;
|
|
22
|
+
const email = createEmailAdapter(ctx);
|
|
23
|
+
const inbound = await email.listInbound(opts.addressId);
|
|
24
|
+
|
|
25
|
+
if (!options.json) {
|
|
26
|
+
tui.table(
|
|
27
|
+
inbound.map((item) => ({
|
|
28
|
+
ID: item.id,
|
|
29
|
+
From: item.from,
|
|
30
|
+
To: item.to,
|
|
31
|
+
Subject: item.subject ?? '-',
|
|
32
|
+
Status: item.status ?? '-',
|
|
33
|
+
Received: item.received_at ? new Date(item.received_at).toLocaleString() : '-',
|
|
34
|
+
})),
|
|
35
|
+
[
|
|
36
|
+
{ name: 'ID', alignment: 'left' },
|
|
37
|
+
{ name: 'From', alignment: 'left' },
|
|
38
|
+
{ name: 'To', alignment: 'left' },
|
|
39
|
+
{ name: 'Subject', alignment: 'left' },
|
|
40
|
+
{ name: 'Status', alignment: 'left' },
|
|
41
|
+
{ name: 'Received', alignment: 'left' },
|
|
42
|
+
]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return inbound;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const EmailInboundSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
from: z.string(),
|
|
6
|
+
to: z.string(),
|
|
7
|
+
subject: z.string().optional(),
|
|
8
|
+
text: z.string().optional(),
|
|
9
|
+
status: z.string().optional(),
|
|
10
|
+
received_at: z.string().optional(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCommand } from '../../../types';
|
|
2
|
+
import { createSubcommand } from './create';
|
|
3
|
+
import { listSubcommand } from './list';
|
|
4
|
+
import { getSubcommand } from './get';
|
|
5
|
+
import { deleteSubcommand } from './delete';
|
|
6
|
+
import { destinationCommand } from './destination';
|
|
7
|
+
import { sendSubcommand } from './send';
|
|
8
|
+
import { inboundCommand } from './inbound';
|
|
9
|
+
import { outboundCommand } from './outbound';
|
|
10
|
+
|
|
11
|
+
export const emailCommand = createCommand({
|
|
12
|
+
name: 'email',
|
|
13
|
+
aliases: ['mail'],
|
|
14
|
+
description: 'Manage email addresses and messages',
|
|
15
|
+
tags: ['requires-auth'],
|
|
16
|
+
subcommands: [
|
|
17
|
+
createSubcommand,
|
|
18
|
+
listSubcommand,
|
|
19
|
+
getSubcommand,
|
|
20
|
+
deleteSubcommand,
|
|
21
|
+
destinationCommand,
|
|
22
|
+
sendSubcommand,
|
|
23
|
+
inboundCommand,
|
|
24
|
+
outboundCommand,
|
|
25
|
+
],
|
|
26
|
+
requires: { auth: true },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default emailCommand;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createEmailAdapter, EmailAddressSchema } from './util';
|
|
5
|
+
|
|
6
|
+
export const listSubcommand = createCommand({
|
|
7
|
+
name: 'list',
|
|
8
|
+
aliases: ['ls'],
|
|
9
|
+
description: 'List email addresses',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
response: z.array(EmailAddressSchema),
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async handler(ctx) {
|
|
17
|
+
const { options } = ctx;
|
|
18
|
+
const email = createEmailAdapter(ctx);
|
|
19
|
+
const addresses = await email.listAddresses();
|
|
20
|
+
|
|
21
|
+
if (!options.json) {
|
|
22
|
+
tui.table(
|
|
23
|
+
addresses.map((item) => ({
|
|
24
|
+
ID: item.id,
|
|
25
|
+
Email: item.email,
|
|
26
|
+
Project: item.project_id ?? '-',
|
|
27
|
+
Provider: item.provider ?? '-',
|
|
28
|
+
Created: new Date(item.created_at).toLocaleString(),
|
|
29
|
+
})),
|
|
30
|
+
[
|
|
31
|
+
{ name: 'ID', alignment: 'left' },
|
|
32
|
+
{ name: 'Email', alignment: 'left' },
|
|
33
|
+
{ name: 'Project', alignment: 'left' },
|
|
34
|
+
{ name: 'Provider', alignment: 'left' },
|
|
35
|
+
{ name: 'Created', alignment: 'left' },
|
|
36
|
+
]
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return addresses;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter, truncate } from '../util';
|
|
5
|
+
import { EmailOutboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const getSubcommand = createCommand({
|
|
8
|
+
name: 'get',
|
|
9
|
+
description: 'Get a sent email by ID',
|
|
10
|
+
tags: ['read-only', 'requires-auth'],
|
|
11
|
+
requires: { auth: true },
|
|
12
|
+
schema: {
|
|
13
|
+
args: z.object({
|
|
14
|
+
id: z.string().min(1).describe('Outbound email ID (eout_*)'),
|
|
15
|
+
}),
|
|
16
|
+
response: EmailOutboundSchema,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async handler(ctx) {
|
|
20
|
+
const { args, options } = ctx;
|
|
21
|
+
const email = createEmailAdapter(ctx);
|
|
22
|
+
const outbound = await email.getOutbound(args.id);
|
|
23
|
+
|
|
24
|
+
if (!outbound) {
|
|
25
|
+
tui.fatal(`Outbound email not found: ${args.id}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!options.json) {
|
|
29
|
+
tui.success(`Outbound Email: ${tui.bold(outbound.id)}`);
|
|
30
|
+
tui.table(
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
ID: outbound.id,
|
|
34
|
+
From: outbound.from,
|
|
35
|
+
To: outbound.to,
|
|
36
|
+
Subject: outbound.subject ?? '-',
|
|
37
|
+
Text: truncate(outbound.text),
|
|
38
|
+
Status: outbound.status ?? '-',
|
|
39
|
+
Error: outbound.error ?? '-',
|
|
40
|
+
Sent: outbound.sent_at
|
|
41
|
+
? new Date(outbound.sent_at).toLocaleString()
|
|
42
|
+
: '-',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Error', 'Sent'],
|
|
46
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return outbound;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default getSubcommand;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCommand } from '../../../../types';
|
|
2
|
+
import { listSubcommand } from './list';
|
|
3
|
+
import { getSubcommand } from './get';
|
|
4
|
+
|
|
5
|
+
export const outboundCommand = createCommand({
|
|
6
|
+
name: 'outbound',
|
|
7
|
+
description: 'Manage outbound (sent) emails',
|
|
8
|
+
tags: ['requires-auth'],
|
|
9
|
+
requires: { auth: true },
|
|
10
|
+
subcommands: [listSubcommand, getSubcommand],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default outboundCommand;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../../types';
|
|
3
|
+
import * as tui from '../../../../tui';
|
|
4
|
+
import { createEmailAdapter } from '../util';
|
|
5
|
+
import { EmailOutboundSchema } from './schemas';
|
|
6
|
+
|
|
7
|
+
export const listSubcommand = createCommand({
|
|
8
|
+
name: 'list',
|
|
9
|
+
aliases: ['ls'],
|
|
10
|
+
description: 'List sent emails',
|
|
11
|
+
tags: ['read-only', 'requires-auth'],
|
|
12
|
+
requires: { auth: true },
|
|
13
|
+
schema: {
|
|
14
|
+
options: z.object({
|
|
15
|
+
addressId: z.string().optional().describe('Filter by email address ID'),
|
|
16
|
+
}),
|
|
17
|
+
response: z.array(EmailOutboundSchema),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
async handler(ctx) {
|
|
21
|
+
const { opts, options } = ctx;
|
|
22
|
+
const email = createEmailAdapter(ctx);
|
|
23
|
+
const outbound = await email.listOutbound(opts.addressId);
|
|
24
|
+
|
|
25
|
+
if (!options.json) {
|
|
26
|
+
tui.table(
|
|
27
|
+
outbound.map((item) => ({
|
|
28
|
+
ID: item.id,
|
|
29
|
+
From: item.from,
|
|
30
|
+
To: item.to,
|
|
31
|
+
Subject: item.subject ?? '-',
|
|
32
|
+
Status: item.status ?? '-',
|
|
33
|
+
Sent: item.sent_at ? new Date(item.sent_at).toLocaleString() : '-',
|
|
34
|
+
})),
|
|
35
|
+
[
|
|
36
|
+
{ name: 'ID', alignment: 'left' },
|
|
37
|
+
{ name: 'From', alignment: 'left' },
|
|
38
|
+
{ name: 'To', alignment: 'left' },
|
|
39
|
+
{ name: 'Subject', alignment: 'left' },
|
|
40
|
+
{ name: 'Status', alignment: 'left' },
|
|
41
|
+
{ name: 'Sent', alignment: 'left' },
|
|
42
|
+
]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return outbound;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default listSubcommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const EmailOutboundSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
from: z.string(),
|
|
6
|
+
to: z.string(),
|
|
7
|
+
subject: z.string().optional(),
|
|
8
|
+
text: z.string().optional(),
|
|
9
|
+
html: z.string().optional(),
|
|
10
|
+
status: z.string().optional(),
|
|
11
|
+
error: z.string().optional(),
|
|
12
|
+
sent_at: z.string().optional(),
|
|
13
|
+
created_at: z.string().optional(),
|
|
14
|
+
updated_at: z.string().optional(),
|
|
15
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { EmailAttachment } from '@agentuity/core';
|
|
4
|
+
import { createCommand } from '../../../types';
|
|
5
|
+
import * as tui from '../../../tui';
|
|
6
|
+
import { createEmailAdapter, truncate } from './util';
|
|
7
|
+
import { EmailOutboundSchema } from './outbound/schemas';
|
|
8
|
+
|
|
9
|
+
export const sendSubcommand = createCommand({
|
|
10
|
+
name: 'send',
|
|
11
|
+
description: 'Send an email',
|
|
12
|
+
tags: ['mutating', 'requires-auth'],
|
|
13
|
+
requires: { auth: true },
|
|
14
|
+
schema: {
|
|
15
|
+
args: z.object({
|
|
16
|
+
to: z.string().email().describe('Destination email address'),
|
|
17
|
+
}),
|
|
18
|
+
options: z.object({
|
|
19
|
+
from: z.string().email().describe('Sender email address (must be owned by org)'),
|
|
20
|
+
subject: z.string().min(1).describe('Email subject'),
|
|
21
|
+
text: z.string().optional().describe('Plain text body'),
|
|
22
|
+
html: z.string().optional().describe('HTML body'),
|
|
23
|
+
file: z.array(z.string()).optional().describe('Attachment file path (repeatable)'),
|
|
24
|
+
}),
|
|
25
|
+
response: EmailOutboundSchema,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async handler(ctx) {
|
|
29
|
+
const { args, opts, options } = ctx;
|
|
30
|
+
|
|
31
|
+
if (!opts.text && !opts.html) {
|
|
32
|
+
tui.fatal('At least one of --text or --html is required');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const fileValues = Array.isArray(opts.file)
|
|
36
|
+
? opts.file
|
|
37
|
+
: opts.file
|
|
38
|
+
? [opts.file]
|
|
39
|
+
: [];
|
|
40
|
+
|
|
41
|
+
const attachments: EmailAttachment[] = [];
|
|
42
|
+
for (const filePath of fileValues) {
|
|
43
|
+
const file = Bun.file(filePath);
|
|
44
|
+
if (!(await file.exists())) {
|
|
45
|
+
tui.fatal(`Attachment file not found: ${filePath}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
49
|
+
attachments.push({
|
|
50
|
+
filename: basename(filePath),
|
|
51
|
+
contentType: file.type || 'application/octet-stream',
|
|
52
|
+
content: buffer.toString('base64'),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const email = createEmailAdapter(ctx);
|
|
57
|
+
const outbound = await email.send({
|
|
58
|
+
to: [args.to],
|
|
59
|
+
from: opts.from,
|
|
60
|
+
subject: opts.subject,
|
|
61
|
+
text: opts.text,
|
|
62
|
+
html: opts.html,
|
|
63
|
+
attachments: attachments.length > 0 ? attachments : undefined,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (!options.json) {
|
|
67
|
+
tui.success('Email queued for delivery');
|
|
68
|
+
tui.table(
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
ID: outbound.id,
|
|
72
|
+
From: outbound.from,
|
|
73
|
+
To: outbound.to,
|
|
74
|
+
Subject: outbound.subject ?? '-',
|
|
75
|
+
Text: truncate(outbound.text),
|
|
76
|
+
Status: outbound.status ?? '-',
|
|
77
|
+
Sent: outbound.sent_at
|
|
78
|
+
? new Date(outbound.sent_at).toLocaleString()
|
|
79
|
+
: '-',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
['ID', 'From', 'To', 'Subject', 'Text', 'Status', 'Sent'],
|
|
83
|
+
{ layout: 'vertical', padStart: ' ' }
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return outbound;
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export default sendSubcommand;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EmailStorageService, type Logger } from '@agentuity/core';
|
|
3
|
+
import { createServerFetchAdapter } from '@agentuity/server';
|
|
4
|
+
import type { AuthData, Config, GlobalOptions, ProjectConfig } from '../../../types';
|
|
5
|
+
import { getCatalystUrl } from '../../../catalyst';
|
|
6
|
+
import * as tui from '../../../tui';
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
EmailAddress,
|
|
10
|
+
EmailDestination,
|
|
11
|
+
EmailInbound,
|
|
12
|
+
EmailOutbound,
|
|
13
|
+
EmailAttachment,
|
|
14
|
+
EmailSendParams,
|
|
15
|
+
} from '@agentuity/core';
|
|
16
|
+
|
|
17
|
+
interface EmailContext {
|
|
18
|
+
logger: Logger;
|
|
19
|
+
auth: AuthData;
|
|
20
|
+
region?: string;
|
|
21
|
+
project?: ProjectConfig;
|
|
22
|
+
config: Config | null;
|
|
23
|
+
options: GlobalOptions;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveEmailOrgId(ctx: EmailContext, explicitOrgId?: string): string {
|
|
27
|
+
const orgId =
|
|
28
|
+
explicitOrgId ??
|
|
29
|
+
ctx.project?.orgId ??
|
|
30
|
+
ctx.options.orgId ??
|
|
31
|
+
(process.env.AGENTUITY_CLOUD_ORG_ID || ctx.config?.preferences?.orgId);
|
|
32
|
+
|
|
33
|
+
if (!orgId) {
|
|
34
|
+
tui.fatal(
|
|
35
|
+
'Organization ID is required. Either run from a project directory or use --org-id flag.'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return orgId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function resolveEmailRegion(ctx: EmailContext): string {
|
|
43
|
+
if (ctx.region) {
|
|
44
|
+
return ctx.region;
|
|
45
|
+
}
|
|
46
|
+
if (process.env.AGENTUITY_REGION) {
|
|
47
|
+
return process.env.AGENTUITY_REGION;
|
|
48
|
+
}
|
|
49
|
+
if (ctx.config?.name === 'local') {
|
|
50
|
+
return 'local';
|
|
51
|
+
}
|
|
52
|
+
if (ctx.config?.preferences?.region) {
|
|
53
|
+
return ctx.config.preferences.region;
|
|
54
|
+
}
|
|
55
|
+
return 'usc';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const EmailAddressSchema = z.object({
|
|
59
|
+
id: z.string(),
|
|
60
|
+
email: z.string(),
|
|
61
|
+
project_id: z.string().optional(),
|
|
62
|
+
provider: z.string().optional(),
|
|
63
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
64
|
+
created_at: z.string(),
|
|
65
|
+
updated_at: z.string().optional(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export function truncate(value: string | undefined, length = 200): string {
|
|
69
|
+
if (!value) {
|
|
70
|
+
return '-';
|
|
71
|
+
}
|
|
72
|
+
return value.length > length ? `${value.slice(0, length - 3)}...` : value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function createEmailAdapter(ctx: EmailContext, explicitOrgId?: string) {
|
|
76
|
+
const orgId = resolveEmailOrgId(ctx, explicitOrgId);
|
|
77
|
+
const adapter = createServerFetchAdapter(
|
|
78
|
+
{
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: `Bearer ${ctx.auth.apiKey}`,
|
|
81
|
+
'x-agentuity-orgid': orgId,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
ctx.logger
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const baseUrl = getCatalystUrl(resolveEmailRegion(ctx));
|
|
88
|
+
return new EmailStorageService(baseUrl, adapter);
|
|
89
|
+
}
|
package/src/cmd/cloud/index.ts
CHANGED
|
@@ -10,12 +10,16 @@ import { scpSubcommand } from './scp';
|
|
|
10
10
|
import { deploymentCommand } from './deployment';
|
|
11
11
|
import keyvalueCommand from './keyvalue';
|
|
12
12
|
import queueCommand from './queue';
|
|
13
|
+
import webhookCommand from './webhook';
|
|
13
14
|
import { agentCommand } from './agent';
|
|
14
15
|
import envCommand from './env';
|
|
15
16
|
import apikeyCommand from './apikey';
|
|
16
17
|
import streamCommand from './stream';
|
|
17
18
|
import vectorCommand from './vector';
|
|
19
|
+
import { emailCommand } from './email';
|
|
20
|
+
import taskCommand from './task';
|
|
18
21
|
import sandboxCommand from './sandbox';
|
|
22
|
+
import scheduleCommand from './schedule';
|
|
19
23
|
import { regionSubcommand } from './region';
|
|
20
24
|
import { machineCommand } from './machine';
|
|
21
25
|
import { evalCommand } from './eval';
|
|
@@ -35,10 +39,14 @@ export const command = createCommand({
|
|
|
35
39
|
apikeyCommand,
|
|
36
40
|
keyvalueCommand,
|
|
37
41
|
queueCommand,
|
|
42
|
+
webhookCommand,
|
|
43
|
+
taskCommand,
|
|
38
44
|
agentCommand,
|
|
39
45
|
streamCommand,
|
|
46
|
+
emailCommand,
|
|
40
47
|
vectorCommand,
|
|
41
48
|
sandboxCommand,
|
|
49
|
+
scheduleCommand,
|
|
42
50
|
envCommand,
|
|
43
51
|
evalCommand,
|
|
44
52
|
evalRunCommand,
|