@agent-native/core 0.138.0 → 0.139.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/corpus/README.md +1 -1
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +2 -0
- package/corpus/templates/analytics/server/lib/emails.ts +51 -0
- package/corpus/templates/analytics/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/calendar/server/lib/booking-emails.ts +154 -70
- package/corpus/templates/calendar/server/lib/emails.ts +167 -0
- package/corpus/templates/calendar/server/lib/event-guest-notifications.ts +64 -28
- package/corpus/templates/calendar/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/clips/actions/invite-member.ts +39 -15
- package/corpus/templates/clips/server/lib/emails.ts +256 -0
- package/corpus/templates/clips/server/lib/transactional-email-templates.ts +24 -0
- package/corpus/templates/clips/server/plugins/transactional-email-catalog.ts +5 -0
- package/corpus/templates/content/server/lib/comment-notifications.ts +57 -26
- package/corpus/templates/content/server/lib/emails.ts +70 -0
- package/corpus/templates/content/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/dispatch/app/routes/transactional-email.$appId.$id.tsx +4 -0
- package/corpus/templates/dispatch/app/routes/transactional-email.tsx +4 -0
- package/corpus/templates/forms/server/lib/emails.ts +52 -0
- package/corpus/templates/forms/server/lib/response-email.ts +2 -0
- package/corpus/templates/forms/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/plan/actions/request-plan-access.ts +33 -12
- package/corpus/templates/plan/server/lib/comment-notifications.ts +53 -27
- package/corpus/templates/plan/server/lib/emails.ts +67 -0
- package/corpus/templates/plan/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/slides/server/lib/comment-notifications.ts +44 -21
- package/corpus/templates/slides/server/lib/emails.ts +40 -0
- package/corpus/templates/slides/server/plugins/transactional-emails.ts +5 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/email-catalog/actions/list-email-activity.d.ts +6 -0
- package/dist/email-catalog/actions/list-email-activity.js +15 -0
- package/dist/email-catalog/actions/list-email-engagement.d.ts +6 -0
- package/dist/email-catalog/actions/list-email-engagement.js +15 -0
- package/dist/email-catalog/actions/list-email-log.d.ts +8 -0
- package/dist/email-catalog/actions/list-email-log.js +22 -0
- package/dist/email-catalog/actions/list-transactional-emails.d.ts +23 -0
- package/dist/email-catalog/actions/list-transactional-emails.js +61 -0
- package/dist/email-catalog/actions/render-transactional-email-preview.d.ts +10 -0
- package/dist/email-catalog/actions/render-transactional-email-preview.js +24 -0
- package/dist/email-catalog/authorize.d.ts +2 -0
- package/dist/email-catalog/authorize.js +10 -0
- package/dist/email-catalog/log.d.ts +57 -0
- package/dist/email-catalog/log.js +117 -0
- package/dist/email-catalog/provider-metrics.d.ts +34 -0
- package/dist/email-catalog/provider-metrics.js +165 -0
- package/dist/email-catalog/registry.d.ts +79 -0
- package/dist/email-catalog/registry.js +71 -0
- package/dist/email-catalog/schema.d.ts +212 -0
- package/dist/email-catalog/schema.js +49 -0
- package/dist/email-catalog/system-emails.d.ts +14 -0
- package/dist/email-catalog/system-emails.js +68 -0
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/localization/default-messages.d.ts +45 -0
- package/dist/localization/default-messages.js +45 -0
- package/dist/notifications/routes.d.ts +5 -5
- package/dist/org/handlers.js +8 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
- package/dist/provider-api/actions/provider-api.d.ts +12 -12
- package/dist/server/action-discovery.js +22 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/better-auth-instance.js +17 -2
- package/dist/server/email.d.ts +9 -0
- package/dist/server/email.js +44 -3
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/package.json +2 -1
|
@@ -517,6 +517,28 @@ export async function mergeCoreSharingActions(registry) {
|
|
|
517
517
|
() => import("../sharing/actions/create-agent-resource-link.js"),
|
|
518
518
|
],
|
|
519
519
|
["upload-image", () => import("../file-upload/actions/upload-image.js")],
|
|
520
|
+
// Transactional email catalog — mounted everywhere so Dispatch can ask any
|
|
521
|
+
// app what it sends without that app opting in.
|
|
522
|
+
[
|
|
523
|
+
"list-transactional-emails",
|
|
524
|
+
() => import("../email-catalog/actions/list-transactional-emails.js"),
|
|
525
|
+
],
|
|
526
|
+
[
|
|
527
|
+
"render-transactional-email-preview",
|
|
528
|
+
() => import("../email-catalog/actions/render-transactional-email-preview.js"),
|
|
529
|
+
],
|
|
530
|
+
[
|
|
531
|
+
"list-email-log",
|
|
532
|
+
() => import("../email-catalog/actions/list-email-log.js"),
|
|
533
|
+
],
|
|
534
|
+
[
|
|
535
|
+
"list-email-activity",
|
|
536
|
+
() => import("../email-catalog/actions/list-email-activity.js"),
|
|
537
|
+
],
|
|
538
|
+
[
|
|
539
|
+
"list-email-engagement",
|
|
540
|
+
() => import("../email-catalog/actions/list-email-engagement.js"),
|
|
541
|
+
],
|
|
520
542
|
[
|
|
521
543
|
"get-feature-flags",
|
|
522
544
|
() => import("../feature-flags/actions/get-feature-flags.js"),
|
|
@@ -27,11 +27,11 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
|
|
|
27
27
|
export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
28
28
|
error: any;
|
|
29
29
|
} | {
|
|
30
|
-
error?: undefined;
|
|
31
30
|
ok: boolean;
|
|
32
31
|
key: string;
|
|
33
32
|
baseUrlKey?: string;
|
|
34
33
|
scope: AgentEngineApiKeyScope;
|
|
34
|
+
error?: undefined;
|
|
35
35
|
}>>;
|
|
36
36
|
export {};
|
|
37
37
|
//# sourceMappingURL=agent-engine-api-key-route.d.ts.map
|
|
@@ -18,6 +18,7 @@ import { TEMPLATES } from "../cli/templates-meta.js";
|
|
|
18
18
|
import { getDbExec, isPostgres } from "../db/client.js";
|
|
19
19
|
import { getDialect, getDatabaseUrl, getDatabaseAuthToken, closePgliteClients, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgPoolOptions, neonPoolMax, attachNeonPoolErrorLogger, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
|
|
20
20
|
import { ensureTableExists } from "../db/ddl-guard.js";
|
|
21
|
+
import { CORE_RESET_PASSWORD_EMAIL_ID, CORE_VERIFY_SIGNUP_EMAIL_ID, } from "../email-catalog/system-emails.js";
|
|
21
22
|
import { saveOAuthTokens } from "../oauth-tokens/store.js";
|
|
22
23
|
import { acceptPendingInvitationsForEmail } from "../org/accept-pending.js";
|
|
23
24
|
import { getAuthEmailForUserId, getRequiredAuthProviderForEmail, } from "../org/auth-policy.js";
|
|
@@ -918,7 +919,14 @@ async function createBetterAuthInstance(config) {
|
|
|
918
919
|
email: user.email,
|
|
919
920
|
resetUrl,
|
|
920
921
|
});
|
|
921
|
-
await sendEmail({
|
|
922
|
+
await sendEmail({
|
|
923
|
+
to: user.email,
|
|
924
|
+
subject,
|
|
925
|
+
html,
|
|
926
|
+
text,
|
|
927
|
+
appSender,
|
|
928
|
+
templateId: CORE_RESET_PASSWORD_EMAIL_ID,
|
|
929
|
+
});
|
|
922
930
|
},
|
|
923
931
|
},
|
|
924
932
|
emailVerification: {
|
|
@@ -942,7 +950,14 @@ async function createBetterAuthInstance(config) {
|
|
|
942
950
|
email: user.email,
|
|
943
951
|
verifyUrl,
|
|
944
952
|
});
|
|
945
|
-
await sendEmail({
|
|
953
|
+
await sendEmail({
|
|
954
|
+
to: user.email,
|
|
955
|
+
subject,
|
|
956
|
+
html,
|
|
957
|
+
text,
|
|
958
|
+
appSender,
|
|
959
|
+
templateId: CORE_VERIFY_SIGNUP_EMAIL_ID,
|
|
960
|
+
});
|
|
946
961
|
},
|
|
947
962
|
},
|
|
948
963
|
socialProviders,
|
package/dist/server/email.d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export interface SendEmailArgs {
|
|
|
58
58
|
references?: string;
|
|
59
59
|
attachments?: EmailAttachment[];
|
|
60
60
|
timeoutMs?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Registered transactional email id (see `defineTransactionalEmail`), e.g.
|
|
63
|
+
* `calendar.booking-confirmed`. Tags the message at the provider so delivery
|
|
64
|
+
* and open metrics attribute to one email instead of to the whole account,
|
|
65
|
+
* and keys the row written to `email_log`. Omit for genuinely one-off sends.
|
|
66
|
+
*/
|
|
67
|
+
templateId?: string;
|
|
68
|
+
/** App slug that owns the send. Defaults to the running app. */
|
|
69
|
+
app?: string;
|
|
61
70
|
}
|
|
62
71
|
export declare function isEmailConfigured(): Promise<boolean>;
|
|
63
72
|
/**
|
package/dist/server/email.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* so the reset-password flow still works end-to-end for local development.
|
|
11
11
|
*/
|
|
12
12
|
import { FAVICON_PNG_BASE64 } from "../assets/branding/favicon-base64.js";
|
|
13
|
+
import { recordEmailSend } from "../email-catalog/log.js";
|
|
14
|
+
import { getAppSlug } from "./app-name.js";
|
|
13
15
|
import { resolveSecret } from "./credential-provider.js";
|
|
14
16
|
import { AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID } from "./email-template.js";
|
|
15
17
|
let cachedAgentNativeLogo;
|
|
@@ -154,7 +156,7 @@ function resolveAppSender(configuredFrom, appSender) {
|
|
|
154
156
|
replyTo: appSender.replyTo,
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
|
-
async function
|
|
159
|
+
async function deliverEmail(args, signal) {
|
|
158
160
|
const config = await resolveEmailTransport();
|
|
159
161
|
signal?.throwIfAborted();
|
|
160
162
|
const provider = config.provider;
|
|
@@ -206,7 +208,7 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
206
208
|
const body = await res.text().catch(() => "");
|
|
207
209
|
throw new Error(`Resend error ${res.status}: ${body}`);
|
|
208
210
|
}
|
|
209
|
-
return;
|
|
211
|
+
return { provider, from };
|
|
210
212
|
}
|
|
211
213
|
if (provider === "sendgrid") {
|
|
212
214
|
const personalization = {
|
|
@@ -227,6 +229,12 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
227
229
|
};
|
|
228
230
|
if (replyTo)
|
|
229
231
|
sgPayload.reply_to = parseSendGridFrom(replyTo);
|
|
232
|
+
// Categories are how per-email delivery/open stats are attributed. Without
|
|
233
|
+
// them every send lands in one undifferentiated account-wide bucket, which
|
|
234
|
+
// is indistinguishable from an email that never sent.
|
|
235
|
+
const categories = [args.templateId, args.app ?? getAppSlug()].filter((value) => Boolean(value));
|
|
236
|
+
if (categories.length)
|
|
237
|
+
sgPayload.categories = categories;
|
|
230
238
|
const sgHeaders = {};
|
|
231
239
|
if (args.inReplyTo)
|
|
232
240
|
sgHeaders["In-Reply-To"] = args.inReplyTo;
|
|
@@ -258,7 +266,7 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
258
266
|
const body = await res.text().catch(() => "");
|
|
259
267
|
throw new Error(`SendGrid error ${res.status}: ${body}`);
|
|
260
268
|
}
|
|
261
|
-
return;
|
|
269
|
+
return { provider, from };
|
|
262
270
|
}
|
|
263
271
|
// Dev fallback — no provider configured. Logging the full body exposes
|
|
264
272
|
// reset tokens, so only do it outside production. In production, refuse
|
|
@@ -270,6 +278,39 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
270
278
|
`Save RESEND_API_KEY or SENDGRID_API_KEY in settings to send real emails.\n` +
|
|
271
279
|
`---\nTo: ${args.to}\nFrom: ${from}\nSubject: ${args.subject}\n\n` +
|
|
272
280
|
`${args.text || stripHtml(args.html)}\n---\n`);
|
|
281
|
+
return { provider, from };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Deliver, then record the attempt. Recording lives here rather than in each
|
|
285
|
+
* provider branch so a new transport cannot be added without being logged.
|
|
286
|
+
*/
|
|
287
|
+
async function sendEmailWithSignal(args, signal) {
|
|
288
|
+
let outcome;
|
|
289
|
+
try {
|
|
290
|
+
outcome = await deliverEmail(args, signal);
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
await recordEmailSend({
|
|
294
|
+
templateId: args.templateId,
|
|
295
|
+
app: args.app ?? getAppSlug() ?? "unknown",
|
|
296
|
+
recipient: args.to,
|
|
297
|
+
sender: outcome?.from ?? args.from ?? "unknown",
|
|
298
|
+
subject: args.subject,
|
|
299
|
+
status: "failed",
|
|
300
|
+
error: error instanceof Error ? error.message : String(error),
|
|
301
|
+
provider: outcome?.provider ?? "unknown",
|
|
302
|
+
});
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
await recordEmailSend({
|
|
306
|
+
templateId: args.templateId,
|
|
307
|
+
app: args.app ?? getAppSlug() ?? "unknown",
|
|
308
|
+
recipient: args.to,
|
|
309
|
+
sender: outcome.from,
|
|
310
|
+
subject: args.subject,
|
|
311
|
+
status: "sent",
|
|
312
|
+
provider: outcome.provider,
|
|
313
|
+
});
|
|
273
314
|
}
|
|
274
315
|
export async function sendEmail(args) {
|
|
275
316
|
const requestedTimeoutMs = Number(args.timeoutMs);
|
package/dist/server/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export { builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSyst
|
|
|
66
66
|
export { getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, runBuilderAgent, type RunBuilderAgentResult, } from "./builder-browser.js";
|
|
67
67
|
export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, type FusionBranchRef, type EnsureFusionContainerResult, type SendFusionMessageResult, } from "./fusion-app.js";
|
|
68
68
|
export { sendEmail, isEmailConfigured, getEmailProvider, type EmailAttachment, type EmailProvider, type SendEmailArgs, } from "./email.js";
|
|
69
|
+
export { defineTransactionalEmail, listTransactionalEmails, getTransactionalEmail, renderTransactionalEmailPreview, type TransactionalEmailDefinition, type RegisteredTransactionalEmail, } from "../email-catalog/registry.js";
|
|
69
70
|
export { notifyActivity, runActivityNotification, resolveActivityRecipients, type ActivityDeliveryFailure, type ActivityNotificationResult, type ActivityNotificationStatus, type NotifyActivityInput, type ResolveActivityRecipientsInput, } from "./activity-notifications.js";
|
|
70
71
|
export { renderEmail, emailStrong, emailLink, type RenderEmailArgs, type RenderedEmail, type EmailCta, } from "./email-template.js";
|
|
71
72
|
export { getAppProductionUrl, getFirstPartyProdUrl } from "./app-url.js";
|
package/dist/server/index.js
CHANGED
|
@@ -67,6 +67,7 @@ export { builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSyst
|
|
|
67
67
|
export { getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, runBuilderAgent, } from "./builder-browser.js";
|
|
68
68
|
export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, } from "./fusion-app.js";
|
|
69
69
|
export { sendEmail, isEmailConfigured, getEmailProvider, } from "./email.js";
|
|
70
|
+
export { defineTransactionalEmail, listTransactionalEmails, getTransactionalEmail, renderTransactionalEmailPreview, } from "../email-catalog/registry.js";
|
|
70
71
|
export { notifyActivity, runActivityNotification, resolveActivityRecipients, } from "./activity-notifications.js";
|
|
71
72
|
export { renderEmail, emailStrong, emailLink, } from "./email-template.js";
|
|
72
73
|
export { getAppProductionUrl, getFirstPartyProdUrl } from "./app-url.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -240,6 +240,7 @@
|
|
|
240
240
|
"./comments-review/actions/get-review-feedback": "./dist/review/actions/get-review-feedback.js",
|
|
241
241
|
"./comments-review/actions/set-review-status": "./dist/review/actions/set-review-status.js",
|
|
242
242
|
"./comments-review/actions/send-review-thread-to-agent": "./dist/review/actions/send-review-thread-to-agent.js",
|
|
243
|
+
"./email-catalog": "./dist/email-catalog/registry.js",
|
|
243
244
|
"./sharing": "./dist/sharing/index.js",
|
|
244
245
|
"./sharing/actions/share-resource": "./dist/sharing/actions/share-resource.js",
|
|
245
246
|
"./sharing/actions/unshare-resource": "./dist/sharing/actions/unshare-resource.js",
|